archgen-skill 0.0.3 → 0.0.4

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.
Files changed (33) hide show
  1. package/README.md +10 -0
  2. package/bin/archgen.mjs +23 -0
  3. package/lib/block.js +94 -9
  4. package/lib/config.js +96 -0
  5. package/lib/doctor.js +123 -26
  6. package/lib/init.js +3 -2
  7. package/lib/install.js +105 -14
  8. package/lib/migrate.js +88 -0
  9. package/lib/migrations/001-stamp-provenance.mjs +77 -0
  10. package/lib/migrations/index.mjs +170 -0
  11. package/lib/restore.js +239 -0
  12. package/lib/store.js +27 -12
  13. package/lib/uninstall-project.js +6 -3
  14. package/lib/version-stamp.js +47 -0
  15. package/package.json +37 -9
  16. package/vendor/skills/archgen/SKILL.md +242 -74
  17. package/vendor/skills/archgen/archgen.config.json +16 -0
  18. package/vendor/skills/archgen/assets/skill-registry.json +4 -3
  19. package/vendor/skills/archgen/references/artifact-templates.md +251 -7
  20. package/vendor/skills/archgen/references/interview.md +180 -16
  21. package/vendor/skills/archgen/references/mcp-and-skills.md +88 -17
  22. package/vendor/skills/archgen/references/orchestration.md +102 -39
  23. package/vendor/skills/archgen/references/platforms.md +1 -14
  24. package/vendor/skills/archgen/scripts/doc-index.mjs +457 -0
  25. package/vendor/skills/archgen/scripts/impact.mjs +14 -1
  26. package/vendor/skills/archgen/scripts/lib/graph.mjs +82 -3
  27. package/vendor/skills/archgen/scripts/lib/scope.mjs +65 -0
  28. package/vendor/skills/archgen/scripts/lib/yaml.mjs +19 -3
  29. package/vendor/skills/archgen/scripts/plan-graph.mjs +329 -0
  30. package/vendor/skills/archgen/scripts/set-status.mjs +26 -6
  31. package/vendor/skills/archgen/scripts/update-agents.mjs +4 -2
  32. package/vendor/skills/archgen/scripts/validate.mjs +18 -1
  33. package/vendor/skills/archgen/scripts/verify-plan.mjs +8 -3
@@ -4,43 +4,114 @@
4
4
 
5
5
  1. **Identify** the platform (SKILL.md Step 0), load its row from
6
6
  references/platforms.md section MCP: config file, top-level key, quirks.
7
- 2. **Prefer the platform CLI** where the table lists one. It handles scope and
8
- file selection correctly:
7
+ 2. **Discover** — when the correct installation method or config shape for
8
+ the detected harness is not confidently known, web-search the CURRENT
9
+ official installation docs/command FIRST. Never trust potentially-stale
10
+ memorized commands or invented config shapes; uncertainty triggers search,
11
+ not guessing.
12
+ 3. **Scope** — choose and state the install scope explicitly:
13
+ - **GLOBAL** — server types that are global entries (npx/npm-based MCP
14
+ servers usable across harnesses). Recommended for universally-useful
15
+ servers (codegraph is the canonical example) unless the user prefers
16
+ project-local.
17
+ - **HARNESS-SPECIFIC** — write into the detected platform's config only.
18
+ Recommended when the server only matters to that platform.
19
+ The user's approval covers the stated scope.
20
+ 4. **Prefer the platform CLI** where the table lists one, passing the scope
21
+ flag that matches the chosen scope:
9
22
  - `claude mcp add --scope project --transport http <name> <url>`
10
23
  - `codex mcp add <name> --url <url>` or `codex mcp add <n> -- cmd args`
11
24
  - `gemini mcp add -s project -t http <name> <url>`
12
- 3. No CLI available: draft the exact config diff against the platform's real
25
+ 5. No CLI available: draft the exact config diff against the platform's real
13
26
  shape (see assets/mcp-template.json for annotated canonical forms) and SHOW
14
27
  it to the user. **USER APPROVAL GATE** — wait for an explicit yes before any
15
28
  write; approval is never inferred from earlier steps.
16
- 4. Apply, then apply the restart semantics from the platforms table.
17
- 5. Verify the tool is visible after reload; report failure modes honestly.
29
+ 6. Apply, then apply the restart semantics from the platforms table.
30
+ 7. Verify the tool is visible after reload; report failure modes honestly.
18
31
 
19
32
  Never write MCP configs silently. Never invent config shapes — the four known
20
33
  top-level keys are mcpServers / servers / mcp / context_servers; remote URL
21
- fields vary (url vs serverUrl vs httpUrl) per the platforms table.
34
+ fields vary (url vs serverUrl vs httpUrl) per the platforms table. Uncertainty
35
+ triggers web-search of current official docs, never invention.
22
36
 
23
37
  ## FETCH-SKILL procedure
24
38
 
25
- 1. Read assets/skill-registry.json. Match the current task domain against
26
- entry `matches` patterns (e.g. frontend/UI work matches ui-skills).
27
- 2. Install into the CURRENT platform's skill dir (platforms.md paths):
28
- - Generic: `npx skills add <owner>/<repo>` (writes correct path for 75+
29
- harnesses; `-g` for global).
30
- - Entry-specific command when present (e.g. `npx ui-skills get baseline-ui`).
31
- 3. Confirm files landed where expected; then FOLLOW the fetched skill's own
32
- instructions for the task domain.
33
- 4. Missing capability: web-search reputable skill repos, propose to user,
34
- on approval append an entry to the registry (PR or local edit).
39
+ Capability-skill loading is **REQUIRED, not opportunistic**. Whenever planned
40
+ work touches a registry `matches` domain, the matching skill MUST be loaded —
41
+ during planning (GENERATE / BROWNFIELD / UPDATE) AND re-verified during
42
+ execution (worker dispatch). UI/design/frontend/animation/component/
43
+ landing-page work REQUIRES the design skills (`ui-skills`, `policy:
44
+ "required"`) loaded first. Referenced from elsewhere as:
45
+ *see references/mcp-and-skills.md § FETCH-SKILL procedure*.
46
+
47
+ 0. **WHEN** — mandatory, twice per matched task:
48
+ - **Pre-planning scan**: while planning, check every task's title, summary,
49
+ and `file_ownership` against the registry BEFORE the plan is finalized;
50
+ fetch any matched skill at that point.
51
+ - **Pre-dispatch verification**: immediately before dispatching each worker,
52
+ re-verify its match; if the skill is missing from the platform skill dir,
53
+ install it before dispatch proceeds.
54
+ 1. **MATCH** — read assets/skill-registry.json. Test every task's title,
55
+ summary, and file_ownership globs against each entry's `matches` patterns
56
+ using case-insensitive substring matching (e.g. a task titled "polish
57
+ landing page hero" matches ui-skills via `"landing page"`). One hit = this
58
+ procedure is mandatory for that task.
59
+ 2. **RESOLVE** — determine the CURRENT platform's skill dir from
60
+ references/platforms.md § Skill install paths. That table owns the paths;
61
+ never duplicate them here.
62
+ 3. **INSTALL once if absent** — cached check first: if the skill is already
63
+ present in the resolved platform skill dir, skip reinstall and go to step 4.
64
+ Otherwise run the entry's `install` command (generic fallback:
65
+ `npx skills add <owner>/<repo>`; `-g` for global; entry-specific commands
66
+ like `npx ui-skills get baseline-ui` when present). Then VERIFY presence:
67
+ confirm the skill directory/SKILL.md landed where platforms.md says it
68
+ should. Fetch happens ONCE per project; later runs are cache hits.
69
+ 4. **INTEGRATE** — inject the follow-instruction into (a) the planning context
70
+ so tasks reference the skill's standards, and (b) EVERY affected worker
71
+ prompt, using this sentence template:
72
+
73
+ > `<Domain> work: follow <skill-dir>/SKILL.md (installed via FETCH-SKILL) — apply its standards to every relevant decision.`
74
+
75
+ Concrete design instantiation for ui-skills:
76
+
77
+ > `Design work: follow <skill-dir>/SKILL.md (installed via FETCH-SKILL) — apply its component/motion/baseline standards to every visual decision.`
78
+
79
+ 5. **AUDIT** — workers MUST state in their completion report whether they
80
+ followed the injected skill, one auditable line, e.g.:
81
+ `Skill compliance: followed ui-skills (<skill-dir>/SKILL.md)` or
82
+ `Skill compliance: NOT followed — <reason>`.
83
+ 6. **MISSING CAPABILITY** — unmatched-but-obvious domain (user says "make it
84
+ pretty" with no registry entry): web-search reputable skill repos, propose
85
+ to user, on approval append an entry to the registry (PR or local edit).
86
+ Never add registry entries without explicit user approval.
35
87
 
36
88
  ## Registry entry shape
37
89
 
90
+ Canonical keys, in order — there are no others. Notably there is NO
91
+ `npxCommand` field anywhere in the registry; the executable command lives in
92
+ `install` (with optional `direct_fetch`):
93
+
38
94
  ```json
39
95
  {
40
96
  "name": "short-name",
41
97
  "purpose": "when to reach for it",
42
98
  "repo": "owner/repo",
43
99
  "install": "npx skills add owner/repo",
44
- "matches": ["frontend", "ui", "design"]
100
+ "direct_fetch": "optional per-skill fetch command",
101
+ "browse": "optional listing command",
102
+ "mcp_endpoint": "optional MCP URL",
103
+ "matches": ["frontend", "ui", "design"],
104
+ "policy": "required"
45
105
  }
46
106
  ```
107
+
108
+ - `matches[]`: case-insensitive substrings tested against task titles,
109
+ summaries, and file_ownership during the FETCH-SKILL domain scan (step 1).
110
+ - `policy` (`required` | `on-demand`) — how mandatory loading is:
111
+ - `"required"`: loading is MANDATORY whenever work touches any of the
112
+ entry's `matches` domains — pre-planning fetch plus pre-dispatch
113
+ verification (FETCH-SKILL steps 0–5 all apply). Currently only ui-skills
114
+ carries this; design/UI/frontend work must not proceed without it.
115
+ - `"on-demand"`: fetched only when a task explicitly names the installer or
116
+ another registry entry lacks a usable command (e.g.
117
+ vercel-skills-installer).
@@ -39,9 +39,63 @@ Dispatch AFTER artifacts exist and validate.mjs passes. The verifier:
39
39
  Orchestrator fixes issues (edits artifacts) and re-dispatches. Loop until
40
40
  APPROVE — never present to the user before verifier approval.
41
41
 
42
+ ## §plan-review — post-plan review stage
43
+
44
+ Run AFTER verify-plan returns APPROVE and BEFORE the user gate. Dispatch one
45
+ or more REVIEWER sub-agents; count scales with the right-sizing class:
46
+
47
+ - SMALL: main-agent self-review acceptable if no reviewer mechanism exists.
48
+ - MEDIUM: 1 reviewer.
49
+ - LARGE: 2–3 reviewers split by concern (correctness / ordering / docs).
50
+
51
+ ```
52
+ TASK: Review the plan in .archgen/<slug>/ READ-ONLY.
53
+ EXAMINE:
54
+ - edge cases per module
55
+ - task ordering / parallelization sanity (waves vs real dependencies)
56
+ - cross-module contract mismatches (interfaces, paths, naming)
57
+ - enhancement recommendations
58
+ - documentation completeness
59
+ DELIVERABLE: numbered findings list; each finding = what + where + why.
60
+ You NEVER edit files. Report only.
61
+ ```
62
+
63
+ Reviewers are read-only and report-only — they never edit artifacts or code.
64
+ The orchestrator fixes the artifacts itself, re-runs validate.mjs + re-dispatches
65
+ the verifier gate after every change, and loops until zero findings remain or
66
+ findings are explicitly waived by the user.
67
+
68
+ ## §investigate — root-cause protocol
69
+
70
+ Triggered when the USER reports repetitive/recurring issues AFTER implementation
71
+ waves completed. Do NOT patch-fix under this protocol. Complexity-sized dispatch:
72
+
73
+ - SMALL scope: main agent investigates directly.
74
+ - MEDIUM/LARGE: 1–3 investigator sub-agents split by suspected subsystem.
75
+
76
+ Investigators produce ALL four:
77
+
78
+ 1. Root cause statement — one sentence naming the actual defect.
79
+ 2. Evidence — files/lines/repro steps.
80
+ 3. Blast radius — which tasks/artifacts are affected.
81
+ 4. Remediation plan — routed through the normal gates: new fix tasks get fresh
82
+ ids inheriting the affected task's ownership globs.
83
+
84
+ Token discipline: investigators read narrowly around evidence, not whole-repo
85
+ sweeps. Patch-fixes without a root-cause statement are forbidden under this
86
+ protocol.
87
+
42
88
  ## §dispatch — wave execution
43
89
 
44
- ### Tier 1: native sub-agents (preferred where strong)
90
+ Dispatch policy: dispatch each task to the harness's NATIVE sub-agent mechanism
91
+ when available AND functional. If sub-agents do not exist on this platform, or
92
+ the sub-agent fails, or lacks required tool permissions (read/write/etc.), the
93
+ MAIN AGENT executes the task ITSELF — sequentially, respecting waves and
94
+ ownership globs. Cross-harness/platform delegation is allowed ONLY through an
95
+ explicit user gate (below). There is NO automatic fallback to other harnesses,
96
+ platforms, or CLIs — ever.
97
+
98
+ ### Native sub-agents (preferred)
45
99
 
46
100
  - Claude Code: background Agent tool per task; add worktree isolation for
47
101
  tasks whose ownership might brush shared files.
@@ -51,55 +105,64 @@ APPROVE — never present to the user before verifier approval.
51
105
  - Gemini CLI: parallel @agents are hub-and-spoke only AND have no isolation →
52
106
  use them ONLY for read-only/research waves unless wrapping in worktrees.
53
107
 
54
- ### Tier 2: bash fallback workers (universal floor)
108
+ ### When sub-agents are unavailable or fail
55
109
 
56
- ```bash
57
- #!/usr/bin/env bash
58
- set -uo pipefail
59
- SLUG="<slug>"; ROOT="$(pwd)"; SKILL="<abs-path-to-skills/archgen>"
60
- run_task() { # $1=id $2=prompt-file
61
- local id="$1" pf="$2" log=".archgen/$SLUG/results/$id.log"
62
- mkdir -p "$(dirname "$log")"
63
- local body; body="$(cat "$pf")
64
-
65
- You own exactly the file_ownership globs listed for this task in tasks.yaml. Follow archgen code-standards. On success run: node \"$SKILL/scripts/set-status.mjs\" .archgen/$SLUG/tasks.yaml \"$id\" done ; on failure set-status failed."
66
- case "$ARCHGEN_HARNESS" in
67
- claude) claude -p "$body" --output-format json --permission-mode acceptEdits > "$log" 2>&1 ;;
68
- opencode) opencode run "$body" --auto --format json > "$log" 2>&1 ;;
69
- codex) codex exec --sandbox workspace-write --json -o "$log.final" "$body" > "$log" 2>&1 ;;
70
- gemini) gemini --output-format json "$body" > "$log" 2>&1 ;;
71
- agy) agy -p --output-format json --print-timeout 15m "$body" > "$log" 2>&1 ;;
72
- *) echo "unknown harness: $ARCHGEN_HARNESS" >&2; return 9 ;;
73
- esac
74
-
75
- You own exactly: $(node "$SKILL/scripts/impact.mjs" .archgen/$SLUG/tasks.yaml "$id" >/dev/null 2>&1 && echo 'see tasks.yaml file_ownership'). Follow archgen code-standards. On success run: node "$SKILL/scripts/set-status.mjs" .archgen/$SLUG/tasks.yaml "$id" done ; on failure set-status failed." \
76
- }
77
- # Wave N: launch all frontier tasks in parallel…
78
- for t in $(node "$SKILL/scripts/next-tasks.mjs" .archgen/$SLUG/tasks.yaml \
79
- | node -e 'let d="";process.stdin.on("data",c=>d+=c).on("end",()=>console.log(JSON.parse(d).waves[0].map(t=>t.id).join(" ")))'); do
80
- run_task "$t" ".archgen/$SLUG/results/$t.prompt" & pids="$pids $!"
81
- done
82
- fail=0; for p in $pids; do wait "$p" || fail=1; done
83
- exit $fail # orchestrator inspects statuses before next wave
84
- ```
110
+ Detect first — one of:
111
+
112
+ - mechanism missing on this platform;
113
+ - spawn failure (sub-agent never started / crashed at launch);
114
+ - tool-permission gaps (sub-agent runs but cannot read/write/edit files).
115
+
116
+ Then, in order:
85
117
 
86
- Isolation upgrade for Tier 2 when ownership borders are tight:
118
+ 1. DEFAULT — main agent executes the task itself, sequentially, respecting
119
+ waves and file_ownership globs. No user permission needed for this.
120
+ 2. USER GATE — cross-harness/platform delegation ONLY. When the sub-agent
121
+ problem looks platform-specific, STOP and tell the user the concrete issue,
122
+ propose using another platform/harness for that specific task (name the
123
+ harness + its command shape), and proceed ONLY after the user explicitly
124
+ allows it. Log the user's choice in the final report.
125
+
126
+ Never silently switch harnesses. Never ask permission to fall back for routine
127
+ failures the main agent can simply do itself.
128
+
129
+ A sub-agent MECHANISM failure (missing/spawn/permissions) is not a TASK
130
+ failure — run the diagnose-and-ask flow above first. Mark a task failed only
131
+ after execution was actually attempted (by sub-agent or main agent) and did
132
+ not complete.
133
+
134
+ Isolation for native sub-agents when ownership borders are tight:
87
135
 
88
136
  ```bash
89
137
  git worktree add ".worktrees/$id" -b "task-$id"
90
- # run worker with cwd=.worktrees/$id, then merge task-$id on success
138
+ # point the sub-agent's cwd at .worktrees/$id, then merge task-$id on success
91
139
  ```
92
140
 
93
- ### Worker prompt contract (both tiers)
141
+ ### Worker prompt contract
142
+
143
+ Every worker receives ALL of:
144
+
145
+ - task id + title;
146
+ - its acceptance criteria VERBATIM;
147
+ - its file_ownership globs ("edit NOTHING outside these");
148
+ - the code-standards reference (`references/code-standards.md`);
149
+ - instruction to run set-status done/failed immediately upon finishing:
150
+ `node <skill>/scripts/set-status.mjs .archgen/<slug>/tasks.yaml <id> done|failed`;
151
+ - commit guidance: commit completed work scoped to the owned files;
152
+ - BEFORE writing code run
153
+ `node <skill>/scripts/plan-graph.mjs --node <task-id> --tasks <tasks.yaml>`
154
+ and honor every connected dependency shown;
155
+ - all file paths come from tasks.yaml/architecture.yaml VERBATIM — never
156
+ reconstruct paths from memory.
94
157
 
95
- Every worker receives: task id+title, its acceptance criteria verbatim, its
96
- file_ownership globs ("edit NOTHING outside these"), the code-standards
97
- reference, and the done/failed status-update command. Workers do NOT talk to
98
- each other; coordination happens only through tasks.yaml state.
158
+ Workers do NOT talk to each other; coordination happens only through
159
+ tasks.yaml state.
99
160
 
100
161
  ## Failure policy
101
162
 
102
- - Worker exit ≠ 0 OR status=failed → leave it failed. NEVER auto-retry.
163
+ - Sub-agent mechanism failure (missing/spawn/permissions) → §dispatch
164
+ diagnose-and-ask flow FIRST. It is not yet a task failure.
165
+ - Task exit ≠ 0 OR status=failed → leave it failed. NEVER auto-retry.
103
166
  - Downstream tasks stay blocked by the resolver (blockedByFailure).
104
167
  - Report to user: failed id, log path, proposed fix-task description.
105
168
  [wait for user] A fix task gets fresh id, depends_on=[], ownership of the
@@ -69,24 +69,11 @@ Claude Code project-scope servers.
69
69
  |---|---|---|---|
70
70
  | Claude Code | `Agent` tool + subagent_type; `.claude/agents/*.md` | Yes (default since v2.1.198; cap ~20) | BEST: `isolation: worktree` frontmatter; `/batch` |
71
71
  | OpenCode | task/subagent tool + subagent_type | Yes (fg + background) | None in core → use file-ownership discipline or team-mode plugin worktrees |
72
- | Codex CLI | model-mediated `spawn_agent`; max_depth=1 | Yes but children can't nest | None → prefer top-level parallel `codex exec` + manual git worktrees |
72
+ | Codex CLI | model-mediated `spawn_agent`; max_depth=1 | Yes but children can't nest | None built-in → flatten plans into top-level `spawn_agent` calls (children cannot nest); add manual git worktrees if edits collide |
73
73
  | Gemini CLI | subagents-as-tools; `@agent-name` | Yes BUT strictly hub-and-spoke (no nested calls) | None → restrict parallel workers to read-only roles unless given external worktrees |
74
74
  | Cursor | Subagents w/ `is_background` frontmatter; `/multitask` | Yes | Opt-in per-subagent worktree or cloud VM |
75
75
  | Antigravity | `invoke_subagent` (async by design); `/fork` | Yes | `/fork` workspace separation; per-subagent worktrees UNVERIFIED |
76
76
 
77
- ## Headless invocation templates (fallback workers)
78
-
79
- ```
80
- claude claude -p "<prompt>" --output-format json --permission-mode acceptEdits
81
- opencode opencode run "<prompt>" --auto --format json
82
- codex codex exec --sandbox workspace-write --json -o <out-file> "<prompt>"
83
- gemini gemini --output-format json "<prompt>"
84
- agy agy -p --output-format json --print-timeout 15m "<prompt>"
85
- ```
86
-
87
- Completion signal = process exit (Claude documents 0/non-zero contract).
88
- NEVER pass secrets as arguments. Feature-detect old binaries via `--version`.
89
-
90
77
  ## Unknown platform procedure
91
78
 
92
79
  1. WEB SEARCH: `<platform> official docs MCP configuration` and