Launch Mechanics
Launch Mechanics
Section titled “Launch Mechanics”launch.ts is the entry point for starting headless domain squad sessions. It resolves a prompt, initializes the signal protocol, and spawns a detached Copilot session in the team’s workspace.
Prompt Resolution Chain
Section titled “Prompt Resolution Chain”Launch resolves the team prompt using a 4-tier priority chain. The first tier that produces a non-empty string wins—no fallthrough chaining.
Priority 1: --prompt "string" CLI flag, literal prompt │ │ (not set?) ▼Priority 2: --prompt-file ./path.md CLI flag, file contents │ │ (not set?) ▼Priority 3: .squad/launch-prompt.md Team-level template in workspace │ │ (not found?) ▼Priority 4: Generic fallback Built-in minimal promptTemplate Interpolation
Section titled “Template Interpolation”Tier 3 (.squad/launch-prompt.md) supports placeholder interpolation:
| Placeholder | Replaced with | Example value |
|---|---|---|
{team} | Domain name | team-alpha |
{runType} | Detected run type | first-run |
{playbookSkill} | Config playbook skill | domain-playbook |
Example template:
You are team {team}. Follow the {playbookSkill} skill.This is a {runType}. Read DOMAIN_CONTEXT.md for your mission.Check .squad/signals/inbox/ for directives first.Report progress to .squad/signals/status.json.RunType Detection
Section titled “RunType Detection”type RunType = 'first-run' | 'refresh' | 'reset';Detection logic:
.squad/signals/status.json exists? ├── NO → 'first-run' (never been launched) └── YES └── --reset flag passed? ├── YES → 'reset' (clear state, start fresh) └── NO → 'refresh' (prior state exists, incremental)Reset mode (--reset) clears:
- Removes
status.json - Clears inbox
.ackfiles (not the directives themselves) - Runs cleanup hook if present (
.squad/cleanup-hook.shor.squad/cleanup-hook.ts) - Commits the cleanup
OTel MCP Injection
Section titled “OTel MCP Injection”When telemetry.enabled is true in config, the launch script injects an OTel MCP server configuration for the domain session:
const mcpConfig = { mcpServers: { otel: { command: 'npx', args: ['tsx', 'scripts/mcp-otel-server.ts'], env: { OTEL_EXPORTER_OTLP_ENDPOINT: 'http://localhost:4318', OTEL_SERVICE_NAME: `squad-${domain}`, SQUAD_DOMAIN: domain, }, }, },};This gives every domain session access to otel_span, otel_metric, otel_event, and otel_log tools without per-team configuration.
CLI Reference
Section titled “CLI Reference”npx tsx scripts/launch.ts --team <name> # launch single teamnpx tsx scripts/launch.ts --team <name> --reset # clear state, relaunchnpx tsx scripts/launch.ts --team <name> --step <step> # run single stepnpx tsx scripts/launch.ts --team <name> --prompt "do X" # override promptnpx tsx scripts/launch.ts --team <name> --prompt-file X.md # prompt from filenpx tsx scripts/launch.ts --teams a,b,c # launch multiplenpx tsx scripts/launch.ts --all # launch all active teamsnpx tsx scripts/launch.ts --all --non-interactive --output-format json # ADR-001 modeADR-001 Flags
Section titled “ADR-001 Flags”For skill integration and CI use, launch.ts supports:
--non-interactive— Accepted for consistency (launch is always non-interactive)--output-format json— Produces structuredLaunchResultJSON instead of human-readable text
Headless Process Spawn
Section titled “Headless Process Spawn”The spawned Copilot process uses stdio: ['pipe', logFile, logFile] with stdin closed immediately after spawn. This avoids TTY issues that previously caused 0-byte log files when using 'inherit' or 'ignore' for stdin.
Each log file begins with a debug header:
# cwd: /path/to/.worktrees/backend-api# cmd: copilot -p "..." --yolo --no-ask-user --autopilotLaunch Guards
Section titled “Launch Guards”Teams with status: "paused" or status: "retired" are automatically skipped. In --all mode, the count of skipped teams is reported. In targeted mode (single --team), each skipped team produces a warning or a JSON result with skipped: true.
For a complete scripts listing, see Scripts Reference.
Related Pages
Section titled “Related Pages”- Architecture Overview — System design and placement abstractions
- Scripts Reference — All automation scripts
- Monitoring — Observing launched teams