@bradygaster/squad-cli 0.8.25 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +284 -32
- package/dist/cli/commands/aspire.d.ts.map +1 -1
- package/dist/cli/commands/aspire.js +3 -0
- package/dist/cli/commands/aspire.js.map +1 -1
- package/dist/cli/commands/build.js +3 -3
- package/dist/cli/commands/build.js.map +1 -1
- package/dist/cli/commands/cast.d.ts +13 -0
- package/dist/cli/commands/cast.d.ts.map +1 -0
- package/dist/cli/commands/cast.js +77 -0
- package/dist/cli/commands/cast.js.map +1 -0
- package/dist/cli/commands/cost.d.ts +2 -0
- package/dist/cli/commands/cost.d.ts.map +1 -0
- package/dist/cli/commands/cost.js +170 -0
- package/dist/cli/commands/cost.js.map +1 -0
- package/dist/cli/commands/cross-squad.d.ts +12 -0
- package/dist/cli/commands/cross-squad.d.ts.map +1 -0
- package/dist/cli/commands/cross-squad.js +80 -0
- package/dist/cli/commands/cross-squad.js.map +1 -0
- package/dist/cli/commands/doctor.d.ts +5 -0
- package/dist/cli/commands/doctor.d.ts.map +1 -1
- package/dist/cli/commands/doctor.js +156 -0
- package/dist/cli/commands/doctor.js.map +1 -1
- package/dist/cli/commands/economy.d.ts +10 -0
- package/dist/cli/commands/economy.d.ts.map +1 -0
- package/dist/cli/commands/economy.js +64 -0
- package/dist/cli/commands/economy.js.map +1 -0
- package/dist/cli/commands/export.d.ts.map +1 -1
- package/dist/cli/commands/export.js +11 -4
- package/dist/cli/commands/export.js.map +1 -1
- package/dist/cli/commands/import.js +2 -2
- package/dist/cli/commands/import.js.map +1 -1
- package/dist/cli/commands/personal.d.ts +16 -0
- package/dist/cli/commands/personal.d.ts.map +1 -0
- package/dist/cli/commands/personal.js +213 -0
- package/dist/cli/commands/personal.js.map +1 -0
- package/dist/cli/commands/roles.d.ts +2 -0
- package/dist/cli/commands/roles.d.ts.map +1 -0
- package/dist/cli/commands/roles.js +54 -0
- package/dist/cli/commands/roles.js.map +1 -0
- package/dist/cli/commands/schedule.d.ts +14 -0
- package/dist/cli/commands/schedule.d.ts.map +1 -0
- package/dist/cli/commands/schedule.js +208 -0
- package/dist/cli/commands/schedule.js.map +1 -0
- package/dist/cli/commands/watch.d.ts.map +1 -1
- package/dist/cli/commands/watch.js +17 -5
- package/dist/cli/commands/watch.js.map +1 -1
- package/dist/cli/core/cast.d.ts +9 -0
- package/dist/cli/core/cast.d.ts.map +1 -1
- package/dist/cli/core/cast.js +170 -60
- package/dist/cli/core/cast.js.map +1 -1
- package/dist/cli/core/detect-squad-dir.d.ts +10 -0
- package/dist/cli/core/detect-squad-dir.d.ts.map +1 -1
- package/dist/cli/core/detect-squad-dir.js +47 -0
- package/dist/cli/core/detect-squad-dir.js.map +1 -1
- package/dist/cli/core/init.d.ts +8 -0
- package/dist/cli/core/init.d.ts.map +1 -1
- package/dist/cli/core/init.js +115 -2
- package/dist/cli/core/init.js.map +1 -1
- package/dist/cli/core/migrations.d.ts.map +1 -1
- package/dist/cli/core/migrations.js +21 -0
- package/dist/cli/core/migrations.js.map +1 -1
- package/dist/cli/core/templates.d.ts.map +1 -1
- package/dist/cli/core/templates.js +8 -1
- package/dist/cli/core/templates.js.map +1 -1
- package/dist/cli/core/upgrade.d.ts +14 -0
- package/dist/cli/core/upgrade.d.ts.map +1 -1
- package/dist/cli/core/upgrade.js +182 -48
- package/dist/cli/core/upgrade.js.map +1 -1
- package/dist/cli/core/version.js +2 -2
- package/dist/cli/core/version.js.map +1 -1
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +2 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/self-update.d.ts +21 -0
- package/dist/cli/self-update.d.ts.map +1 -0
- package/dist/cli/self-update.js +113 -0
- package/dist/cli/self-update.js.map +1 -0
- package/dist/cli/shell/autocomplete.d.ts.map +1 -1
- package/dist/cli/shell/autocomplete.js +5 -0
- package/dist/cli/shell/autocomplete.js.map +1 -1
- package/dist/cli/shell/commands.d.ts.map +1 -1
- package/dist/cli/shell/commands.js +55 -24
- package/dist/cli/shell/commands.js.map +1 -1
- package/dist/cli/shell/components/AgentPanel.d.ts.map +1 -1
- package/dist/cli/shell/components/AgentPanel.js +21 -6
- package/dist/cli/shell/components/AgentPanel.js.map +1 -1
- package/dist/cli/shell/components/App.d.ts.map +1 -1
- package/dist/cli/shell/components/App.js +33 -15
- package/dist/cli/shell/components/App.js.map +1 -1
- package/dist/cli/shell/components/InputPrompt.js +1 -1
- package/dist/cli/shell/components/InputPrompt.js.map +1 -1
- package/dist/cli/shell/components/MessageStream.d.ts +2 -0
- package/dist/cli/shell/components/MessageStream.d.ts.map +1 -1
- package/dist/cli/shell/components/MessageStream.js +20 -20
- package/dist/cli/shell/components/MessageStream.js.map +1 -1
- package/dist/cli/shell/components/ThinkingIndicator.d.ts +4 -0
- package/dist/cli/shell/components/ThinkingIndicator.d.ts.map +1 -1
- package/dist/cli/shell/components/ThinkingIndicator.js +23 -4
- package/dist/cli/shell/components/ThinkingIndicator.js.map +1 -1
- package/dist/cli/shell/coordinator.d.ts +7 -0
- package/dist/cli/shell/coordinator.d.ts.map +1 -1
- package/dist/cli/shell/coordinator.js +206 -88
- package/dist/cli/shell/coordinator.js.map +1 -1
- package/dist/cli/shell/error-messages.d.ts +14 -0
- package/dist/cli/shell/error-messages.d.ts.map +1 -1
- package/dist/cli/shell/error-messages.js +65 -1
- package/dist/cli/shell/error-messages.js.map +1 -1
- package/dist/cli/shell/index.d.ts +1 -1
- package/dist/cli/shell/index.d.ts.map +1 -1
- package/dist/cli/shell/index.js +83 -12
- package/dist/cli/shell/index.js.map +1 -1
- package/dist/cli/shell/router.d.ts.map +1 -1
- package/dist/cli/shell/router.js +21 -2
- package/dist/cli/shell/router.js.map +1 -1
- package/dist/cli/shell/stream-bridge.d.ts +2 -0
- package/dist/cli/shell/stream-bridge.d.ts.map +1 -1
- package/dist/cli/shell/stream-bridge.js +11 -2
- package/dist/cli/shell/stream-bridge.js.map +1 -1
- package/dist/cli/shell/terminal.d.ts +5 -5
- package/dist/cli/shell/terminal.d.ts.map +1 -1
- package/dist/cli/shell/terminal.js +35 -26
- package/dist/cli/shell/terminal.js.map +1 -1
- package/dist/cli-entry.js +124 -42
- package/dist/cli-entry.js.map +1 -1
- package/package.json +20 -4
- package/scripts/patch-esm-imports.mjs +84 -55
- package/scripts/patch-ink-rendering.mjs +115 -0
- package/templates/casting/Futurama.json +10 -0
- package/templates/casting-policy.json +4 -2
- package/templates/casting-reference.md +104 -0
- package/templates/cooperative-rate-limiting.md +229 -0
- package/templates/issue-lifecycle.md +412 -0
- package/templates/keda-scaler.md +164 -0
- package/templates/machine-capabilities.md +75 -0
- package/templates/orchestration-log.md +1 -1
- package/templates/ralph-circuit-breaker.md +313 -0
- package/templates/routing.md +5 -20
- package/templates/scribe-charter.md +1 -1
- package/templates/skills/agent-collaboration/SKILL.md +42 -0
- package/templates/skills/agent-conduct/SKILL.md +24 -0
- package/templates/skills/architectural-proposals/SKILL.md +151 -0
- package/templates/skills/ci-validation-gates/SKILL.md +84 -0
- package/templates/skills/cli-wiring/SKILL.md +47 -0
- package/templates/skills/client-compatibility/SKILL.md +89 -0
- package/templates/skills/cross-squad/SKILL.md +114 -0
- package/templates/skills/distributed-mesh/SKILL.md +287 -0
- package/templates/skills/distributed-mesh/mesh.json.example +30 -0
- package/templates/skills/distributed-mesh/sync-mesh.ps1 +111 -0
- package/templates/skills/distributed-mesh/sync-mesh.sh +104 -0
- package/templates/skills/docs-standards/SKILL.md +71 -0
- package/templates/skills/economy-mode/SKILL.md +114 -0
- package/templates/skills/external-comms/SKILL.md +329 -0
- package/templates/skills/gh-auth-isolation/SKILL.md +183 -0
- package/templates/skills/git-workflow/SKILL.md +204 -0
- package/templates/skills/github-multi-account/SKILL.md +95 -0
- package/templates/skills/history-hygiene/SKILL.md +36 -0
- package/templates/skills/humanizer/SKILL.md +105 -0
- package/templates/skills/init-mode/SKILL.md +102 -0
- package/templates/skills/model-selection/SKILL.md +117 -0
- package/templates/skills/nap/SKILL.md +24 -0
- package/templates/skills/personal-squad/SKILL.md +57 -0
- package/templates/skills/release-process/SKILL.md +423 -0
- package/templates/skills/reskill/SKILL.md +92 -0
- package/templates/skills/reviewer-protocol/SKILL.md +79 -0
- package/templates/skills/secret-handling/SKILL.md +200 -0
- package/templates/skills/session-recovery/SKILL.md +155 -0
- package/templates/skills/test-discipline/SKILL.md +37 -0
- package/templates/skills/windows-compatibility/SKILL.md +74 -0
- package/templates/squad.agent.md +1287 -1146
- package/templates/workflows/squad-docs.yml +8 -4
- package/templates/workflows/squad-heartbeat.yml +3 -4
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Skill: CLI Command Wiring
|
|
2
|
+
|
|
3
|
+
**Bug class:** Commands implemented in `packages/squad-cli/src/cli/commands/` but never routed in `cli-entry.ts`.
|
|
4
|
+
|
|
5
|
+
## Checklist — Adding a New CLI Command
|
|
6
|
+
|
|
7
|
+
1. **Create command file** in `packages/squad-cli/src/cli/commands/<name>.ts`
|
|
8
|
+
- Export a `run<Name>(cwd, options)` async function (or class with static methods for utility modules)
|
|
9
|
+
|
|
10
|
+
2. **Add routing block** in `packages/squad-cli/src/cli-entry.ts` inside `main()`:
|
|
11
|
+
```ts
|
|
12
|
+
if (cmd === '<name>') {
|
|
13
|
+
const { run<Name> } = await import('./cli/commands/<name>.js');
|
|
14
|
+
// parse args, call function
|
|
15
|
+
await run<Name>(process.cwd(), options);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
3. **Add help text** in the help section of `cli-entry.ts` (search for `Commands:`):
|
|
21
|
+
```ts
|
|
22
|
+
console.log(` ${BOLD}<name>${RESET} <description>`);
|
|
23
|
+
console.log(` Usage: <name> [flags]`);
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
4. **Verify both exist** — the recurring bug is doing step 1 but missing steps 2-3.
|
|
27
|
+
|
|
28
|
+
## Wiring Patterns by Command Type
|
|
29
|
+
|
|
30
|
+
| Type | Example | How to wire |
|
|
31
|
+
|------|---------|-------------|
|
|
32
|
+
| Standard command | `export.ts`, `build.ts` | `run*()` function, parse flags from `args` |
|
|
33
|
+
| Placeholder command | `loop`, `hire` | Inline in cli-entry.ts, prints pending message |
|
|
34
|
+
| Utility/check module | `rc-tunnel.ts`, `copilot-bridge.ts` | Wire as diagnostic check (e.g., `isDevtunnelAvailable()`) |
|
|
35
|
+
| Subcommand of another | `init-remote.ts` | Already used inside parent + standalone alias |
|
|
36
|
+
|
|
37
|
+
## Common Import Pattern
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import { BOLD, RESET, DIM, RED, GREEN, YELLOW } from './cli/core/output.js';
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Use dynamic `await import()` for command modules to keep startup fast (lazy loading).
|
|
44
|
+
|
|
45
|
+
## History
|
|
46
|
+
|
|
47
|
+
- **#237 / PR #244:** 4 commands wired (rc, copilot-bridge, init-remote, rc-tunnel). aspire, link, loop, hire were already present.
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "client-compatibility"
|
|
3
|
+
description: "Platform detection and adaptive spawning for CLI vs VS Code vs other surfaces"
|
|
4
|
+
domain: "orchestration"
|
|
5
|
+
confidence: "high"
|
|
6
|
+
source: "extracted"
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Context
|
|
10
|
+
|
|
11
|
+
Squad runs on multiple Copilot surfaces (CLI, VS Code, JetBrains, GitHub.com). The coordinator must detect its platform and adapt spawning behavior accordingly. Different tools are available on different platforms, requiring conditional logic for agent spawning, SQL usage, and response timing.
|
|
12
|
+
|
|
13
|
+
## Patterns
|
|
14
|
+
|
|
15
|
+
### Platform Detection
|
|
16
|
+
|
|
17
|
+
Before spawning agents, determine the platform by checking available tools:
|
|
18
|
+
|
|
19
|
+
1. **CLI mode** — `task` tool is available → full spawning control. Use `task` with `agent_type`, `mode`, `model`, `description`, `prompt` parameters. Collect results via `read_agent`.
|
|
20
|
+
|
|
21
|
+
2. **VS Code mode** — `runSubagent` or `agent` tool is available → conditional behavior. Use `runSubagent` with the task prompt. Drop `agent_type`, `mode`, and `model` parameters. Multiple subagents in one turn run concurrently (equivalent to background mode). Results return automatically — no `read_agent` needed.
|
|
22
|
+
|
|
23
|
+
3. **Fallback mode** — neither `task` nor `runSubagent`/`agent` available → work inline. Do not apologize or explain the limitation. Execute the task directly.
|
|
24
|
+
|
|
25
|
+
If both `task` and `runSubagent` are available, prefer `task` (richer parameter surface).
|
|
26
|
+
|
|
27
|
+
### VS Code Spawn Adaptations
|
|
28
|
+
|
|
29
|
+
When in VS Code mode, the coordinator changes behavior in these ways:
|
|
30
|
+
|
|
31
|
+
- **Spawning tool:** Use `runSubagent` instead of `task`. The prompt is the only required parameter — pass the full agent prompt (charter, identity, task, hygiene, response order) exactly as you would on CLI.
|
|
32
|
+
- **Parallelism:** Spawn ALL concurrent agents in a SINGLE turn. They run in parallel automatically. This replaces `mode: "background"` + `read_agent` polling.
|
|
33
|
+
- **Model selection:** Accept the session model. Do NOT attempt per-spawn model selection or fallback chains — they only work on CLI. In Phase 1, all subagents use whatever model the user selected in VS Code's model picker.
|
|
34
|
+
- **Scribe:** Cannot fire-and-forget. Batch Scribe as the LAST subagent in any parallel group. Scribe is light work (file ops only), so the blocking is tolerable.
|
|
35
|
+
- **Launch table:** Skip it. Results arrive with the response, not separately. By the time the coordinator speaks, the work is already done.
|
|
36
|
+
- **`read_agent`:** Skip entirely. Results return automatically when subagents complete.
|
|
37
|
+
- **`agent_type`:** Drop it. All VS Code subagents have full tool access by default. Subagents inherit the parent's tools.
|
|
38
|
+
- **`description`:** Drop it. The agent name is already in the prompt.
|
|
39
|
+
- **Prompt content:** Keep ALL prompt structure — charter, identity, task, hygiene, response order blocks are surface-independent.
|
|
40
|
+
|
|
41
|
+
### Feature Degradation Table
|
|
42
|
+
|
|
43
|
+
| Feature | CLI | VS Code | Degradation |
|
|
44
|
+
|---------|-----|---------|-------------|
|
|
45
|
+
| Parallel fan-out | `mode: "background"` + `read_agent` | Multiple subagents in one turn | None — equivalent concurrency |
|
|
46
|
+
| Model selection | Per-spawn `model` param (4-layer hierarchy) | Session model only (Phase 1) | Accept session model, log intent |
|
|
47
|
+
| Scribe fire-and-forget | Background, never read | Sync, must wait | Batch with last parallel group |
|
|
48
|
+
| Launch table UX | Show table → results later | Skip table → results with response | UX only — results are correct |
|
|
49
|
+
| SQL tool | Available | Not available | Avoid SQL in cross-platform code paths |
|
|
50
|
+
| Response order bug | Critical workaround | Possibly necessary (unverified) | Keep the block — harmless if unnecessary |
|
|
51
|
+
|
|
52
|
+
### SQL Tool Caveat
|
|
53
|
+
|
|
54
|
+
The `sql` tool is **CLI-only**. It does not exist on VS Code, JetBrains, or GitHub.com. Any coordinator logic or agent workflow that depends on SQL (todo tracking, batch processing, session state) will silently fail on non-CLI surfaces. Cross-platform code paths must not depend on SQL. Use filesystem-based state (`.squad/` files) for anything that must work everywhere.
|
|
55
|
+
|
|
56
|
+
## Examples
|
|
57
|
+
|
|
58
|
+
**Example 1: CLI parallel spawn**
|
|
59
|
+
```typescript
|
|
60
|
+
// Coordinator detects task tool available → CLI mode
|
|
61
|
+
task({ agent_type: "general-purpose", mode: "background", model: "claude-sonnet-4.5", ... })
|
|
62
|
+
task({ agent_type: "general-purpose", mode: "background", model: "claude-haiku-4.5", ... })
|
|
63
|
+
// Later: read_agent for both
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Example 2: VS Code parallel spawn**
|
|
67
|
+
```typescript
|
|
68
|
+
// Coordinator detects runSubagent available → VS Code mode
|
|
69
|
+
runSubagent({ prompt: "...Fenster charter + task..." })
|
|
70
|
+
runSubagent({ prompt: "...Hockney charter + task..." })
|
|
71
|
+
runSubagent({ prompt: "...Scribe charter + task..." }) // Last in group
|
|
72
|
+
// Results return automatically, no read_agent
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Example 3: Fallback mode**
|
|
76
|
+
```typescript
|
|
77
|
+
// Neither task nor runSubagent available → work inline
|
|
78
|
+
// Coordinator executes the task directly without spawning
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Anti-Patterns
|
|
82
|
+
|
|
83
|
+
- ❌ Using SQL tool in cross-platform workflows (breaks on VS Code/JetBrains/GitHub.com)
|
|
84
|
+
- ❌ Attempting per-spawn model selection on VS Code (Phase 1 — only session model works)
|
|
85
|
+
- ❌ Fire-and-forget Scribe on VS Code (must batch as last subagent)
|
|
86
|
+
- ❌ Showing launch table on VS Code (results already inline)
|
|
87
|
+
- ❌ Apologizing or explaining platform limitations to the user
|
|
88
|
+
- ❌ Using `task` when only `runSubagent` is available
|
|
89
|
+
- ❌ Dropping prompt structure (charter/identity/task) on non-CLI platforms
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "cross-squad"
|
|
3
|
+
description: "Coordinating work across multiple Squad instances"
|
|
4
|
+
domain: "orchestration"
|
|
5
|
+
confidence: "medium"
|
|
6
|
+
source: "manual"
|
|
7
|
+
tools:
|
|
8
|
+
- name: "squad-discover"
|
|
9
|
+
description: "List known squads and their capabilities"
|
|
10
|
+
when: "When you need to find which squad can handle a task"
|
|
11
|
+
- name: "squad-delegate"
|
|
12
|
+
description: "Create work in another squad's repository"
|
|
13
|
+
when: "When a task belongs to another squad's domain"
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Context
|
|
17
|
+
When an organization runs multiple Squad instances (e.g., platform-squad, frontend-squad, data-squad), those squads need to discover each other, share context, and hand off work across repository boundaries. This skill teaches agents how to coordinate across squads without creating tight coupling.
|
|
18
|
+
|
|
19
|
+
Cross-squad orchestration applies when:
|
|
20
|
+
- A task requires capabilities owned by another squad
|
|
21
|
+
- An architectural decision affects multiple squads
|
|
22
|
+
- A feature spans multiple repositories with different squads
|
|
23
|
+
- A squad needs to request infrastructure, tooling, or support from another squad
|
|
24
|
+
|
|
25
|
+
## Patterns
|
|
26
|
+
|
|
27
|
+
### Discovery via Manifest
|
|
28
|
+
Each squad publishes a `.squad/manifest.json` declaring its name, capabilities, and contact information. Squads discover each other through:
|
|
29
|
+
1. **Well-known paths**: Check `.squad/manifest.json` in known org repos
|
|
30
|
+
2. **Upstream config**: Squads already listed in `.squad/upstream.json` are checked for manifests
|
|
31
|
+
3. **Explicit registry**: A central `squad-registry.json` can list all squads in an org
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"name": "platform-squad",
|
|
36
|
+
"version": "1.0.0",
|
|
37
|
+
"description": "Platform infrastructure team",
|
|
38
|
+
"capabilities": ["kubernetes", "helm", "monitoring", "ci-cd"],
|
|
39
|
+
"contact": {
|
|
40
|
+
"repo": "org/platform",
|
|
41
|
+
"labels": ["squad:platform"]
|
|
42
|
+
},
|
|
43
|
+
"accepts": ["issues", "prs"],
|
|
44
|
+
"skills": ["helm-developer", "operator-developer", "pipeline-engineer"]
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Context Sharing
|
|
49
|
+
When delegating work, share only what the target squad needs:
|
|
50
|
+
- **Capability list**: What this squad can do (from manifest)
|
|
51
|
+
- **Relevant decisions**: Only decisions that affect the target squad
|
|
52
|
+
- **Handoff context**: A concise description of why this work is being delegated
|
|
53
|
+
|
|
54
|
+
Do NOT share:
|
|
55
|
+
- Internal team state (casting history, session logs)
|
|
56
|
+
- Full decision archives (send only relevant excerpts)
|
|
57
|
+
- Authentication credentials or secrets
|
|
58
|
+
|
|
59
|
+
### Work Handoff Protocol
|
|
60
|
+
1. **Check manifest**: Verify the target squad accepts the work type (issues, PRs)
|
|
61
|
+
2. **Create issue**: Use `gh issue create` in the target repo with:
|
|
62
|
+
- Title: `[cross-squad] <description>`
|
|
63
|
+
- Label: `squad:cross-squad` (or the squad's configured label)
|
|
64
|
+
- Body: Context, acceptance criteria, and link back to originating issue
|
|
65
|
+
3. **Track**: Record the cross-squad issue URL in the originating squad's orchestration log
|
|
66
|
+
4. **Poll**: Periodically check if the delegated issue is closed/completed
|
|
67
|
+
|
|
68
|
+
### Feedback Loop
|
|
69
|
+
Track delegated work completion:
|
|
70
|
+
- Poll target issue status via `gh issue view`
|
|
71
|
+
- Update originating issue with status changes
|
|
72
|
+
- Close the feedback loop when delegated work merges
|
|
73
|
+
|
|
74
|
+
## Examples
|
|
75
|
+
|
|
76
|
+
### Discovering squads
|
|
77
|
+
```bash
|
|
78
|
+
# List all squads discoverable from upstreams and known repos
|
|
79
|
+
squad discover
|
|
80
|
+
|
|
81
|
+
# Output:
|
|
82
|
+
# platform-squad → org/platform (kubernetes, helm, monitoring)
|
|
83
|
+
# frontend-squad → org/frontend (react, nextjs, storybook)
|
|
84
|
+
# data-squad → org/data (spark, airflow, dbt)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Delegating work
|
|
88
|
+
```bash
|
|
89
|
+
# Delegate a task to the platform squad
|
|
90
|
+
squad delegate platform-squad "Add Prometheus metrics endpoint for the auth service"
|
|
91
|
+
|
|
92
|
+
# Creates issue in org/platform with cross-squad label and context
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Manifest in squad.config.ts
|
|
96
|
+
```typescript
|
|
97
|
+
export default defineSquad({
|
|
98
|
+
manifest: {
|
|
99
|
+
name: 'platform-squad',
|
|
100
|
+
capabilities: ['kubernetes', 'helm'],
|
|
101
|
+
contact: { repo: 'org/platform', labels: ['squad:platform'] },
|
|
102
|
+
accepts: ['issues', 'prs'],
|
|
103
|
+
skills: ['helm-developer', 'operator-developer'],
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Anti-Patterns
|
|
109
|
+
- **Direct file writes across repos** — Never modify another squad's `.squad/` directory. Use issues and PRs as the communication protocol.
|
|
110
|
+
- **Tight coupling** — Don't depend on another squad's internal structure. Use the manifest as the public API contract.
|
|
111
|
+
- **Unbounded delegation** — Always include acceptance criteria and a timeout. Don't create open-ended requests.
|
|
112
|
+
- **Skipping discovery** — Don't hardcode squad locations. Use manifests and the discovery protocol.
|
|
113
|
+
- **Sharing secrets** — Never include credentials, tokens, or internal URLs in cross-squad issues.
|
|
114
|
+
- **Circular delegation** — Track delegation chains. If squad A delegates to B which delegates back to A, something is wrong.
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "distributed-mesh"
|
|
3
|
+
description: "How to coordinate with squads on different machines using git as transport"
|
|
4
|
+
domain: "distributed-coordination"
|
|
5
|
+
confidence: "high"
|
|
6
|
+
source: "multi-model-consensus (Opus 4.6, Sonnet 4.5, GPT-5.4)"
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## SCOPE
|
|
10
|
+
|
|
11
|
+
**✅ THIS SKILL PRODUCES (exactly these, nothing more):**
|
|
12
|
+
|
|
13
|
+
1. **`mesh.json`** — Generated from user answers about zones and squads (which squads participate, what zone each is in, paths/URLs for each), using `mesh.json.example` in this skill's directory as the schema template
|
|
14
|
+
2. **`sync-mesh.sh` and `sync-mesh.ps1`** — Copied from this skill's directory into the project root (these are bundled resources, NOT generated code)
|
|
15
|
+
3. **Zone 2 state repo initialization** (if applicable) — If the user specified a Zone 2 shared state repo, run `sync-mesh.sh --init` to scaffold the state repo structure
|
|
16
|
+
4. **A decision entry** in `.squad/decisions/inbox/` documenting the mesh configuration for team awareness
|
|
17
|
+
|
|
18
|
+
**❌ THIS SKILL DOES NOT PRODUCE:**
|
|
19
|
+
|
|
20
|
+
- **No application code** — No validators, libraries, or modules of any kind
|
|
21
|
+
- **No test files** — No test suites, test cases, or test scaffolding
|
|
22
|
+
- **No GENERATING sync scripts** — They are bundled with this skill as pre-built resources. COPY them, don't generate them.
|
|
23
|
+
- **No daemons or services** — No background processes, servers, or persistent runtimes
|
|
24
|
+
- **No modifications to existing squad files** beyond the decision entry (no changes to team.md, routing.md, agent charters, etc.)
|
|
25
|
+
|
|
26
|
+
**Your role:** Configure the mesh topology and install the bundled sync scripts. Nothing more.
|
|
27
|
+
|
|
28
|
+
## Context
|
|
29
|
+
|
|
30
|
+
When squads are on different machines (developer laptops, CI runners, cloud VMs, partner orgs), the local file-reading convention still works — but remote files need to arrive on your disk first. This skill teaches the pattern for distributed squad communication.
|
|
31
|
+
|
|
32
|
+
**When this applies:**
|
|
33
|
+
- Squads span multiple machines, VMs, or CI runners
|
|
34
|
+
- Squads span organizations or companies
|
|
35
|
+
- An agent needs context from a squad whose files aren't on the local filesystem
|
|
36
|
+
|
|
37
|
+
**When this does NOT apply:**
|
|
38
|
+
- All squads are on the same machine (just read the files directly)
|
|
39
|
+
|
|
40
|
+
## Patterns
|
|
41
|
+
|
|
42
|
+
### The Core Principle
|
|
43
|
+
|
|
44
|
+
> "The filesystem is the mesh, and git is how the mesh crosses machine boundaries."
|
|
45
|
+
|
|
46
|
+
The agent interface never changes. Agents always read local files. The distributed layer's only job is to make remote files appear locally before the agent reads them.
|
|
47
|
+
|
|
48
|
+
### Three Zones of Communication
|
|
49
|
+
|
|
50
|
+
**Zone 1 — Local:** Same filesystem. Read files directly. Zero transport.
|
|
51
|
+
|
|
52
|
+
**Zone 2 — Remote-Trusted:** Different host, same org, shared git auth. Transport: `git pull` from a shared repo. This collapses Zone 2 into Zone 1 — files materialize on disk, agent reads them normally.
|
|
53
|
+
|
|
54
|
+
**Zone 3 — Remote-Opaque:** Different org, no shared auth. Transport: `curl` to fetch published contracts (SUMMARY.md). One-way visibility — you see only what they publish.
|
|
55
|
+
|
|
56
|
+
### Agent Lifecycle (Distributed)
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
1. SYNC: git pull (Zone 2) + curl (Zone 3) — materialize remote state
|
|
60
|
+
2. READ: cat .mesh/**/state.md — all files are local now
|
|
61
|
+
3. WORK: do their assigned work (the agent's normal task, NOT mesh-building)
|
|
62
|
+
4. WRITE: update own billboard, log, drops
|
|
63
|
+
5. PUBLISH: git add + commit + push — share state with remote peers
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Steps 2–4 are identical to local-only. Steps 1 and 5 are the entire distributed extension. **Note:** "WORK" means the agent performs its normal squad duties — it does NOT mean "build mesh infrastructure."
|
|
67
|
+
|
|
68
|
+
### The mesh.json Config
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"squads": {
|
|
73
|
+
"auth-squad": { "zone": "local", "path": "../auth-squad/.mesh" },
|
|
74
|
+
"ci-squad": {
|
|
75
|
+
"zone": "remote-trusted",
|
|
76
|
+
"source": "git@github.com:our-org/ci-squad.git",
|
|
77
|
+
"ref": "main",
|
|
78
|
+
"sync_to": ".mesh/remotes/ci-squad"
|
|
79
|
+
},
|
|
80
|
+
"partner-fraud": {
|
|
81
|
+
"zone": "remote-opaque",
|
|
82
|
+
"source": "https://partner.dev/squad-contracts/fraud/SUMMARY.md",
|
|
83
|
+
"sync_to": ".mesh/remotes/partner-fraud",
|
|
84
|
+
"auth": "bearer"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Three zone types, one file. Local squads need only a path. Remote-trusted need a git URL. Remote-opaque need an HTTP URL.
|
|
91
|
+
|
|
92
|
+
### Write Partitioning
|
|
93
|
+
|
|
94
|
+
Each squad writes only to its own directory (`boards/{self}.md`, `squads/{self}/*`, `drops/{date}-{self}-*.md`). No two squads write to the same file. Git push/pull never conflicts. If push fails ("branch is behind"), the fix is always `git pull --rebase && git push`.
|
|
95
|
+
|
|
96
|
+
### Trust Boundaries
|
|
97
|
+
|
|
98
|
+
Trust maps to git permissions:
|
|
99
|
+
- **Same repo access** = full mesh visibility
|
|
100
|
+
- **Read-only access** = can observe, can't write
|
|
101
|
+
- **No access** = invisible (correct behavior)
|
|
102
|
+
|
|
103
|
+
For selective visibility, use separate repos per audience (internal, partner, public). Git permissions ARE the trust negotiation.
|
|
104
|
+
|
|
105
|
+
### Phased Rollout
|
|
106
|
+
|
|
107
|
+
- **Phase 0:** Convention only — document zones, agree on mesh.json fields, manually run `git pull`/`git push`. Zero new code.
|
|
108
|
+
- **Phase 1:** Sync script (~30 lines bash or PowerShell) when manual sync gets tedious.
|
|
109
|
+
- **Phase 2:** Published contracts + curl fetch when a Zone 3 partner appears.
|
|
110
|
+
- **Phase 3:** Never. No MCP federation, A2A, service discovery, message queues.
|
|
111
|
+
|
|
112
|
+
**Important:** Phases are NOT auto-advanced. These are project-level decisions — you start at Phase 0 (manual sync) and only move forward when the team decides complexity is justified.
|
|
113
|
+
|
|
114
|
+
### Mesh State Repo
|
|
115
|
+
|
|
116
|
+
The shared mesh state repo is a plain git repository — NOT a Squad project. It holds:
|
|
117
|
+
- One directory per participating squad
|
|
118
|
+
- Each directory contains at minimum a SUMMARY.md with the squad's current state
|
|
119
|
+
- A root README explaining what the repo is and who participates
|
|
120
|
+
|
|
121
|
+
No `.squad/` folder, no agents, no automation. Write partitioning means each squad only pushes to its own directory. The repo is a rendezvous point, not an intelligent system.
|
|
122
|
+
|
|
123
|
+
If you want a squad that *observes* mesh health, that's a separate Squad project that lists the state repo as a Zone 2 remote in its `mesh.json` — it does NOT live inside the state repo.
|
|
124
|
+
|
|
125
|
+
## Examples
|
|
126
|
+
|
|
127
|
+
### Developer Laptop + CI Squad (Zone 2)
|
|
128
|
+
|
|
129
|
+
Auth-squad agent wakes up. `git pull` brings ci-squad's latest results. Agent reads: "3 test failures in auth module." Adjusts work. Pushes results when done. **Overhead: one `git pull`, one `git push`.**
|
|
130
|
+
|
|
131
|
+
### Two Orgs Collaborating (Zone 3)
|
|
132
|
+
|
|
133
|
+
Payment-squad fetches partner's published SUMMARY.md via curl. Reads: "Risk scoring v3 API deprecated April 15. New field `device_fingerprint` required." The consuming agent (in payment-squad's team) reads this information and uses it to inform its work — for example, updating payment integration code to include the new field. Partner can't see payment-squad's internals.
|
|
134
|
+
|
|
135
|
+
### Same Org, Shared Mesh Repo (Zone 2)
|
|
136
|
+
|
|
137
|
+
Three squads on different machines. One shared git repo holds the mesh. Each squad: `git pull` before work, `git push` after. Write partitioning ensures zero merge conflicts.
|
|
138
|
+
|
|
139
|
+
## AGENT WORKFLOW (Deterministic Setup)
|
|
140
|
+
|
|
141
|
+
When a user invokes this skill to set up a distributed mesh, follow these steps **exactly, in order:**
|
|
142
|
+
|
|
143
|
+
### Step 1: ASK the user for mesh topology
|
|
144
|
+
|
|
145
|
+
Ask these questions (adapt phrasing naturally, but get these answers):
|
|
146
|
+
|
|
147
|
+
1. **Which squads are participating?** (List of squad names)
|
|
148
|
+
2. **For each squad, which zone is it in?**
|
|
149
|
+
- `local` — same filesystem (just need a path)
|
|
150
|
+
- `remote-trusted` — different machine, same org, shared git access (need git URL + ref)
|
|
151
|
+
- `remote-opaque` — different org, no shared auth (need HTTPS URL to published contract)
|
|
152
|
+
3. **For each squad, what's the connection info?**
|
|
153
|
+
- Local: relative or absolute path to their `.mesh/` directory
|
|
154
|
+
- Remote-trusted: git URL (SSH or HTTPS), ref (branch/tag), and where to sync it to locally
|
|
155
|
+
- Remote-opaque: HTTPS URL to their SUMMARY.md, where to sync it, and auth type (none/bearer)
|
|
156
|
+
4. **Where should the shared state live?** (For Zone 2 squads: git repo URL for the mesh state, or confirm each squad syncs independently)
|
|
157
|
+
|
|
158
|
+
### Step 2: GENERATE `mesh.json`
|
|
159
|
+
|
|
160
|
+
Using the answers from Step 1, create a `mesh.json` file at the project root. Use `mesh.json.example` from THIS skill's directory (`.squad/skills/distributed-mesh/mesh.json.example`) as the schema template.
|
|
161
|
+
|
|
162
|
+
Structure:
|
|
163
|
+
|
|
164
|
+
```json
|
|
165
|
+
{
|
|
166
|
+
"squads": {
|
|
167
|
+
"<squad-name>": { "zone": "local", "path": "<relative-or-absolute-path>" },
|
|
168
|
+
"<squad-name>": {
|
|
169
|
+
"zone": "remote-trusted",
|
|
170
|
+
"source": "<git-url>",
|
|
171
|
+
"ref": "<branch-or-tag>",
|
|
172
|
+
"sync_to": ".mesh/remotes/<squad-name>"
|
|
173
|
+
},
|
|
174
|
+
"<squad-name>": {
|
|
175
|
+
"zone": "remote-opaque",
|
|
176
|
+
"source": "<https-url-to-summary>",
|
|
177
|
+
"sync_to": ".mesh/remotes/<squad-name>",
|
|
178
|
+
"auth": "<none|bearer>"
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Write this file to the project root. Do NOT write any other code.
|
|
185
|
+
|
|
186
|
+
### Step 3: COPY sync scripts
|
|
187
|
+
|
|
188
|
+
Copy the bundled sync scripts from THIS skill's directory into the project root:
|
|
189
|
+
|
|
190
|
+
- **Source:** `.squad/skills/distributed-mesh/sync-mesh.sh`
|
|
191
|
+
- **Destination:** `sync-mesh.sh` (project root)
|
|
192
|
+
|
|
193
|
+
- **Source:** `.squad/skills/distributed-mesh/sync-mesh.ps1`
|
|
194
|
+
- **Destination:** `sync-mesh.ps1` (project root)
|
|
195
|
+
|
|
196
|
+
These are bundled resources. Do NOT generate them — COPY them directly.
|
|
197
|
+
|
|
198
|
+
### Step 4: RUN `--init` (if Zone 2 state repo exists)
|
|
199
|
+
|
|
200
|
+
If the user specified a Zone 2 shared state repo in Step 1, run the initialization:
|
|
201
|
+
|
|
202
|
+
**On Unix/Linux/macOS:**
|
|
203
|
+
```bash
|
|
204
|
+
bash sync-mesh.sh --init
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
**On Windows:**
|
|
208
|
+
```powershell
|
|
209
|
+
.\sync-mesh.ps1 -Init
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
This scaffolds the state repo structure (squad directories, placeholder SUMMARY.md files, root README).
|
|
213
|
+
|
|
214
|
+
**Skip this step if:**
|
|
215
|
+
- No Zone 2 squads are configured (local/opaque only)
|
|
216
|
+
- The state repo already exists and is initialized
|
|
217
|
+
|
|
218
|
+
### Step 5: WRITE a decision entry
|
|
219
|
+
|
|
220
|
+
Create a decision file at `.squad/decisions/inbox/<your-agent-name>-mesh-setup.md` with this content:
|
|
221
|
+
|
|
222
|
+
```markdown
|
|
223
|
+
### <YYYY-MM-DD>: Mesh configuration
|
|
224
|
+
|
|
225
|
+
**By:** <your-agent-name> (via distributed-mesh skill)
|
|
226
|
+
|
|
227
|
+
**What:** Configured distributed mesh with <N> squads across zones <list-zones-used>
|
|
228
|
+
|
|
229
|
+
**Squads:**
|
|
230
|
+
- `<squad-name>` — Zone <X> — <brief-connection-info>
|
|
231
|
+
- `<squad-name>` — Zone <X> — <brief-connection-info>
|
|
232
|
+
- ...
|
|
233
|
+
|
|
234
|
+
**State repo:** <git-url-if-zone-2-used, or "N/A (local/opaque only)">
|
|
235
|
+
|
|
236
|
+
**Why:** <user's stated reason for setting up the mesh, or "Enable cross-machine squad coordination">
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
Write this file. The Scribe will merge it into the main decisions file later.
|
|
240
|
+
|
|
241
|
+
### Step 6: STOP
|
|
242
|
+
|
|
243
|
+
**You are done.** Do not:
|
|
244
|
+
- Generate sync scripts (they're bundled with this skill — COPY them)
|
|
245
|
+
- Write validator code
|
|
246
|
+
- Write test files
|
|
247
|
+
- Create any other modules, libraries, or application code
|
|
248
|
+
- Modify existing squad files (team.md, routing.md, charters)
|
|
249
|
+
- Auto-advance to Phase 2 or Phase 3
|
|
250
|
+
|
|
251
|
+
Output a simple completion message:
|
|
252
|
+
|
|
253
|
+
```
|
|
254
|
+
✅ Mesh configured. Created:
|
|
255
|
+
- mesh.json (<N> squads)
|
|
256
|
+
- sync-mesh.sh and sync-mesh.ps1 (copied from skill bundle)
|
|
257
|
+
- Decision entry: .squad/decisions/inbox/<filename>
|
|
258
|
+
|
|
259
|
+
Run `bash sync-mesh.sh` (or `.\sync-mesh.ps1` on Windows) before agents start to materialize remote state.
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
## Anti-Patterns
|
|
265
|
+
|
|
266
|
+
**❌ Code generation anti-patterns:**
|
|
267
|
+
- Writing `mesh-config-validator.js` or any validator module
|
|
268
|
+
- Writing test files for mesh configuration
|
|
269
|
+
- Generating sync scripts instead of copying the bundled ones from this skill's directory
|
|
270
|
+
- Creating library modules or utilities
|
|
271
|
+
- Building any code that "runs the mesh" — the mesh is read by agents, not executed
|
|
272
|
+
|
|
273
|
+
**❌ Architectural anti-patterns:**
|
|
274
|
+
- Building a federation protocol — Git push/pull IS federation
|
|
275
|
+
- Running a sync daemon or server — Agents are not persistent. Sync at startup, publish at shutdown
|
|
276
|
+
- Real-time notifications — Agents don't need real-time. They need "recent enough." `git pull` is recent enough
|
|
277
|
+
- Schema validation for markdown — The LLM reads markdown. If the format changes, it adapts
|
|
278
|
+
- Service discovery protocol — mesh.json is a file with 10 entries. Not a "discovery problem"
|
|
279
|
+
- Auth framework — Git SSH keys and HTTPS tokens. Not a framework. Already configured
|
|
280
|
+
- Message queues / event buses — Agents wake, read, work, write, sleep. Nobody's home to receive events
|
|
281
|
+
- Any component requiring a running process — That's the line. Don't cross it
|
|
282
|
+
|
|
283
|
+
**❌ Scope creep anti-patterns:**
|
|
284
|
+
- Auto-advancing phases without user decision
|
|
285
|
+
- Modifying agent charters or routing rules
|
|
286
|
+
- Setting up CI/CD pipelines for mesh sync
|
|
287
|
+
- Creating dashboards or monitoring tools
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"squads": {
|
|
3
|
+
"auth-squad": {
|
|
4
|
+
"zone": "local",
|
|
5
|
+
"path": "../auth-squad/.mesh"
|
|
6
|
+
},
|
|
7
|
+
"api-squad": {
|
|
8
|
+
"zone": "local",
|
|
9
|
+
"path": "../api-squad/.mesh"
|
|
10
|
+
},
|
|
11
|
+
"ci-squad": {
|
|
12
|
+
"zone": "remote-trusted",
|
|
13
|
+
"source": "git@github.com:our-org/ci-squad.git",
|
|
14
|
+
"ref": "main",
|
|
15
|
+
"sync_to": ".mesh/remotes/ci-squad"
|
|
16
|
+
},
|
|
17
|
+
"data-squad": {
|
|
18
|
+
"zone": "remote-trusted",
|
|
19
|
+
"source": "git@github.com:our-org/data-pipeline.git",
|
|
20
|
+
"ref": "main",
|
|
21
|
+
"sync_to": ".mesh/remotes/data-squad"
|
|
22
|
+
},
|
|
23
|
+
"partner-fraud": {
|
|
24
|
+
"zone": "remote-opaque",
|
|
25
|
+
"source": "https://partner.example.com/squad-contracts/fraud/SUMMARY.md",
|
|
26
|
+
"sync_to": ".mesh/remotes/partner-fraud",
|
|
27
|
+
"auth": "bearer"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# sync-mesh.ps1 — Materialize remote squad state locally
|
|
2
|
+
#
|
|
3
|
+
# Reads mesh.json, fetches remote squads into local directories.
|
|
4
|
+
# Run before agent reads. No daemon. No service. ~40 lines.
|
|
5
|
+
#
|
|
6
|
+
# Usage: .\sync-mesh.ps1 [path-to-mesh.json]
|
|
7
|
+
# .\sync-mesh.ps1 -Init [path-to-mesh.json]
|
|
8
|
+
# Requires: git
|
|
9
|
+
param(
|
|
10
|
+
[switch]$Init,
|
|
11
|
+
[string]$MeshJson = "mesh.json"
|
|
12
|
+
)
|
|
13
|
+
$ErrorActionPreference = "Stop"
|
|
14
|
+
|
|
15
|
+
# Handle -Init mode
|
|
16
|
+
if ($Init) {
|
|
17
|
+
if (-not (Test-Path $MeshJson)) {
|
|
18
|
+
Write-Host "❌ $MeshJson not found"
|
|
19
|
+
exit 1
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
Write-Host "🚀 Initializing mesh state repository..."
|
|
23
|
+
$config = Get-Content $MeshJson -Raw | ConvertFrom-Json
|
|
24
|
+
$squads = $config.squads.PSObject.Properties.Name
|
|
25
|
+
|
|
26
|
+
# Create squad directories with placeholder SUMMARY.md
|
|
27
|
+
foreach ($squad in $squads) {
|
|
28
|
+
if (-not (Test-Path $squad)) {
|
|
29
|
+
New-Item -ItemType Directory -Path $squad | Out-Null
|
|
30
|
+
Write-Host " ✓ Created $squad/"
|
|
31
|
+
} else {
|
|
32
|
+
Write-Host " • $squad/ exists (skipped)"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
$summaryPath = "$squad/SUMMARY.md"
|
|
36
|
+
if (-not (Test-Path $summaryPath)) {
|
|
37
|
+
"# $squad`n`n_No state published yet._" | Set-Content $summaryPath
|
|
38
|
+
Write-Host " ✓ Created $summaryPath"
|
|
39
|
+
} else {
|
|
40
|
+
Write-Host " • $summaryPath exists (skipped)"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
# Generate root README.md
|
|
45
|
+
if (-not (Test-Path "README.md")) {
|
|
46
|
+
$readme = @"
|
|
47
|
+
# Squad Mesh State Repository
|
|
48
|
+
|
|
49
|
+
This repository tracks published state from participating squads.
|
|
50
|
+
|
|
51
|
+
## Participating Squads
|
|
52
|
+
|
|
53
|
+
"@
|
|
54
|
+
foreach ($squad in $squads) {
|
|
55
|
+
$zone = $config.squads.$squad.zone
|
|
56
|
+
$readme += "- **$squad** (Zone: $zone)`n"
|
|
57
|
+
}
|
|
58
|
+
$readme += @"
|
|
59
|
+
|
|
60
|
+
Each squad directory contains a ``SUMMARY.md`` with their latest published state.
|
|
61
|
+
State is synchronized using ``sync-mesh.sh`` or ``sync-mesh.ps1``.
|
|
62
|
+
"@
|
|
63
|
+
$readme | Set-Content "README.md"
|
|
64
|
+
Write-Host " ✓ Created README.md"
|
|
65
|
+
} else {
|
|
66
|
+
Write-Host " • README.md exists (skipped)"
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
Write-Host ""
|
|
70
|
+
Write-Host "✅ Mesh state repository initialized"
|
|
71
|
+
exit 0
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
$config = Get-Content $MeshJson -Raw | ConvertFrom-Json
|
|
75
|
+
|
|
76
|
+
# Zone 2: Remote-trusted — git clone/pull
|
|
77
|
+
foreach ($entry in $config.squads.PSObject.Properties | Where-Object { $_.Value.zone -eq "remote-trusted" }) {
|
|
78
|
+
$squad = $entry.Name
|
|
79
|
+
$source = $entry.Value.source
|
|
80
|
+
$ref = if ($entry.Value.ref) { $entry.Value.ref } else { "main" }
|
|
81
|
+
$target = $entry.Value.sync_to
|
|
82
|
+
|
|
83
|
+
if (Test-Path "$target/.git") {
|
|
84
|
+
git -C $target pull --rebase --quiet 2>$null
|
|
85
|
+
if ($LASTEXITCODE -ne 0) { Write-Host "⚠ ${squad}: pull failed (using stale)" }
|
|
86
|
+
} else {
|
|
87
|
+
New-Item -ItemType Directory -Force -Path (Split-Path $target -Parent) | Out-Null
|
|
88
|
+
git clone --quiet --depth 1 --branch $ref $source $target 2>$null
|
|
89
|
+
if ($LASTEXITCODE -ne 0) { Write-Host "⚠ ${squad}: clone failed (unavailable)" }
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
# Zone 3: Remote-opaque — fetch published contracts
|
|
94
|
+
foreach ($entry in $config.squads.PSObject.Properties | Where-Object { $_.Value.zone -eq "remote-opaque" }) {
|
|
95
|
+
$squad = $entry.Name
|
|
96
|
+
$source = $entry.Value.source
|
|
97
|
+
$target = $entry.Value.sync_to
|
|
98
|
+
$auth = $entry.Value.auth
|
|
99
|
+
|
|
100
|
+
New-Item -ItemType Directory -Force -Path $target | Out-Null
|
|
101
|
+
$params = @{ Uri = $source; OutFile = "$target/SUMMARY.md"; UseBasicParsing = $true }
|
|
102
|
+
if ($auth -eq "bearer") {
|
|
103
|
+
$tokenVar = ($squad.ToUpper() -replace '-', '_') + "_TOKEN"
|
|
104
|
+
$token = [Environment]::GetEnvironmentVariable($tokenVar)
|
|
105
|
+
if ($token) { $params.Headers = @{ Authorization = "Bearer $token" } }
|
|
106
|
+
}
|
|
107
|
+
try { Invoke-WebRequest @params -ErrorAction Stop }
|
|
108
|
+
catch { "# ${squad} — unavailable ($(Get-Date))" | Set-Content "$target/SUMMARY.md" }
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
Write-Host "✓ Mesh sync complete"
|