Skill Tracer
Skills › Compound Engineering › ce-polish › run.md

run.md

67 lines · skills/ce-polish/references/run.md at 3449230

Open on GitHub

Most marks come from matching words in the file, so treat them as pointers.

1# Prepare the live polish loop
2
3This reference owns checkout safety, server startup, reachability, and browser handoff. It does not own the user's iterative polish decisions.
4

Prepare the live polish loop

This reference owns checkout safety, server startup, reachability, and browser handoff. It does not own the user's iterative polish decisions.

Raw lines 1 to 4
5## Resolve the workspace
6
7If the user named a PR or branch, first locate whether its branch is already checked out in a worktree. Enter that existing worktree when the harness can; if it cannot, report the blocker and stop. Only use the harness's checkout capability in the current workspace when no other worktree owns the target. With no argument, stay in the current checkout.
8
9Confirm the resulting branch is neither the repository's default branch nor detached. Report and stop when a safe feature-branch workspace cannot be reached; do not create another worktree behind the harness or move uncommitted user changes.

Resolve the workspace

If the user named a PR or branch, first locate whether its branch is already checked out in a worktree. Enter that existing worktree when the harness can; if it cannot, report the blocker and stop. Only use the harness's checkout capability in the current workspace when no other worktree owns the target. With no argument, stay in the current checkout.

Confirm the resulting branch is neither the repository's default branch nor detached. Report and stop when a safe feature-branch workspace cannot be reached; do not create another worktree behind the harness or move uncommitted user changes.

Raw lines 5 to 10
11## Resolve the start command
13The commands below execute scripts bundled with this skill. For every self-contained shell call, set `SKILL_DIR` to the absolute directory containing the loaded `ce-polish` `SKILL.md`; shell state does not carry between calls.
15First inspect the repo-root launch configuration:
17```bash
18SKILL_DIR="<absolute path of the directory containing this SKILL.md>";
19bash "$SKILL_DIR/scripts/read-launch-json.sh"
20```
22Resolve one startup tuple: command, working directory, environment, and port. A selected launch configuration supplies every usable fact it declares: `runtimeExecutable` plus optional `runtimeArgs` form the command, `cwd` defaults to the repository root, `env` augments the inherited environment, and `port` must be numeric. Preserve those facts while resolving only what remains unknown. When all four facts are usable, the tuple is complete: skip classification, recipe loading, package-manager resolution, and port resolution, then continue to startup. Ambiguous declarations remain in disambiguation: show their names, ask the user to choose, and rerun with that name. Any operational failure or unresolved tuple fact blocks startup and must be reported.
24Run project classification only when an unresolved command or port requires a project type. Classify the selected working directory when a launch configuration supplied one; otherwise classify the repository root. Omit the path argument for the repository root:
26```bash
27SKILL_DIR="<absolute path of the directory containing this SKILL.md>";
28bash "$SKILL_DIR/scripts/detect-project-type.sh" "<project-root>"
29```
31`<type>` means the classification root; `<type>@<relative-dir>` means that directory under the classification root. Ask the user to choose when the output is `multiple` or `multiple:...`. For `unknown`, ask only for the unresolved tuple facts and do not guess.
33Read `references/dev-server-<base-type>.md` only when the command remains unresolved after a supported classification. If that recipe requires a package-manager executable to complete the command, resolve it in the classified project root rather than guessing:
35```bash
36SKILL_DIR="<absolute path of the directory containing this SKILL.md>";
37bash "$SKILL_DIR/scripts/resolve-package-manager.sh" "<project-root>"
38```
40Run the port resolver only while the port remains unresolved, using the detected type without replacing a selected command, working directory, or environment:
42```bash
43SKILL_DIR="<absolute path of the directory containing this SKILL.md>";
44bash "$SKILL_DIR/scripts/resolve-port.sh" "<project-root>" --type <base-type>
45```
47Startup may proceed only when the tuple has a usable command, working directory, environment, and numeric port. If a classifier, recipe, or resolver fails operationally or leaves its required fact unknown, report that blocker; do not substitute a plausible value. After supported auto-detection supplies a missing fact, offer once to save the completed tuple as `.claude/launch.json`; write it only when the user accepts, after reading `references/launch-json-schema.md` and any recipe used.

Resolve the start command

The commands below execute scripts bundled with this skill. For every self-contained shell call, set SKILL_DIR to the absolute directory containing the loaded ce-polish SKILL.md; shell state does not carry between calls.

First inspect the repo-root launch configuration:

SKILL_DIR="<absolute path of the directory containing this SKILL.md>";
bash "$SKILL_DIR/scripts/read-launch-json.sh"

Resolve one startup tuple: command, working directory, environment, and port. A selected launch configuration supplies every usable fact it declares: runtimeExecutable plus optional runtimeArgs form the command, cwd defaults to the repository root, env augments the inherited environment, and port must be numeric. Preserve those facts while resolving only what remains unknown. When all four facts are usable, the tuple is complete: skip classification, recipe loading, package-manager resolution, and port resolution, then continue to startup. Ambiguous declarations remain in disambiguation: show their names, ask the user to choose, and rerun with that name. Any operational failure or unresolved tuple fact blocks startup and must be reported.

Run project classification only when an unresolved command or port requires a project type. Classify the selected working directory when a launch configuration supplied one; otherwise classify the repository root. Omit the path argument for the repository root:

SKILL_DIR="<absolute path of the directory containing this SKILL.md>";
bash "$SKILL_DIR/scripts/detect-project-type.sh" "<project-root>"

<type> means the classification root; <type>@<relative-dir> means that directory under the classification root. Ask the user to choose when the output is multiple or multiple:.... For unknown, ask only for the unresolved tuple facts and do not guess.

Read references/dev-server-<base-type>.md only when the command remains unresolved after a supported classification. If that recipe requires a package-manager executable to complete the command, resolve it in the classified project root rather than guessing:

SKILL_DIR="<absolute path of the directory containing this SKILL.md>";
bash "$SKILL_DIR/scripts/resolve-package-manager.sh" "<project-root>"

Run the port resolver only while the port remains unresolved, using the detected type without replacing a selected command, working directory, or environment:

SKILL_DIR="<absolute path of the directory containing this SKILL.md>";
bash "$SKILL_DIR/scripts/resolve-port.sh" "<project-root>" --type <base-type>

Startup may proceed only when the tuple has a usable command, working directory, environment, and numeric port. If a classifier, recipe, or resolver fails operationally or leaves its required fact unknown, report that blocker; do not substitute a plausible value. After supported auto-detection supplies a missing fact, offer once to save the completed tuple as .claude/launch.json; write it only when the user accepts, after reading references/launch-json-schema.md and any recipe used.

Raw lines 11 to 48
Runs code scripts/read-launch-json.sh :19
Involves a person ask the user :22
Runs code scripts/detect-project-type.sh :28
Involves a person Ask the user :31
Runs code scripts/resolve-package-manager.sh :37
Runs code scripts/resolve-port.sh :44
49## Start and hand off
51Inspect the chosen port and select exactly one intended server instance before handoff. Reuse a process already serving that port only when evidence identifies it as the intended project server. Only when no intended instance is selected may the resolved command be launched in the background with the project's working directory and environment; that process becomes the selected instance. Keep its process or session handle, and write its output under a directory created with `mktemp -d "${TMPDIR:-/tmp}/ce-polish-XXXXXX"`.
53An occupied port that cannot be attributed to the intended project server remains an unresolved collision. Ask the user whether to stop that process, choose another port, or stop this run; never kill it or launch past it.
55Resolve the selected instance's actual URL before handoff. The resolved port seeds `http://localhost:<port>` as the default candidate, but server output or a user correction replaces that candidate when it identifies a different URL. Attribute successful reachability at the resolved actual URL to the selected instance by probing for up to 30 seconds; a response from another process is not success.
57- **Reachable:** use the browser-opening capability already exposed by the active harness with the verified actual URL. If it has none or the handoff fails, print that URL; browser handoff is a convenience, not a gate.
58- **Not reachable:** show diagnostics derived from the selected instance. Include the last 20 log lines only when this run launched it and owns those logs. Ask whether to correct the server URL or start configuration, or stop.
60Do not continue into the polish loop unless reachability is attributed to the selected instance.
62Tell the user:
64```text
65Dev server running on <verified-actual-url>
66Browse the feature and tell me what could be better.
67```

Start and hand off

Inspect the chosen port and select exactly one intended server instance before handoff. Reuse a process already serving that port only when evidence identifies it as the intended project server. Only when no intended instance is selected may the resolved command be launched in the background with the project's working directory and environment; that process becomes the selected instance. Keep its process or session handle, and write its output under a directory created with mktemp -d "${TMPDIR:-/tmp}/ce-polish-XXXXXX".

An occupied port that cannot be attributed to the intended project server remains an unresolved collision. Ask the user whether to stop that process, choose another port, or stop this run; never kill it or launch past it.

Resolve the selected instance's actual URL before handoff. The resolved port seeds http://localhost:<port> as the default candidate, but server output or a user correction replaces that candidate when it identifies a different URL. Attribute successful reachability at the resolved actual URL to the selected instance by probing for up to 30 seconds; a response from another process is not success.

  • Reachable: use the browser-opening capability already exposed by the active harness with the verified actual URL. If it has none or the handoff fails, print that URL; browser handoff is a convenience, not a gate.
  • Not reachable: show diagnostics derived from the selected instance. Include the last 20 log lines only when this run launched it and owns those logs. Ask whether to correct the server URL or start configuration, or stop.

Do not continue into the polish loop unless reachability is attributed to the selected instance.

Tell the user:

Dev server running on <verified-actual-url>
Browse the feature and tell me what could be better.
Raw lines 49 to 67
Involves a person Ask the user :53