archgen-mcp 0.0.0-stage → 0.0.7

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 (65) hide show
  1. package/README.md +134 -2
  2. package/assets/briefs/investigate.md +22 -0
  3. package/assets/briefs/review.md +35 -0
  4. package/assets/briefs/survey.md +22 -0
  5. package/assets/briefs/verifier.md +44 -0
  6. package/assets/depth-ladder.json +90 -0
  7. package/assets/harness-mcp.json +389 -0
  8. package/assets/mcp-template.json +45 -0
  9. package/assets/platform-capabilities.json +252 -0
  10. package/assets/references/artifact-templates.md +285 -0
  11. package/assets/references/interview.md +277 -0
  12. package/assets/references/mcp-and-skills.md +152 -0
  13. package/assets/references/orchestration.md +262 -0
  14. package/assets/references/platforms.md +142 -0
  15. package/assets/skill-registry.json +119 -0
  16. package/assets/templates/adr.md +8 -0
  17. package/assets/templates/architecture.yaml +58 -0
  18. package/assets/templates/edge-matrix.md +8 -0
  19. package/assets/templates/mermaid.md +47 -0
  20. package/assets/templates/prd.md +31 -0
  21. package/assets/templates/tasks.yaml +40 -0
  22. package/bin/archgen-mcp.mjs +35 -0
  23. package/package.json +47 -4
  24. package/src/cli.mjs +245 -0
  25. package/src/context.mjs +228 -0
  26. package/src/core/briefs.mjs +60 -0
  27. package/src/core/codegraph-manager.mjs +500 -0
  28. package/src/core/compat.mjs +187 -0
  29. package/src/core/doc-navigator.mjs +532 -0
  30. package/src/core/docs.mjs +156 -0
  31. package/src/core/errors.mjs +65 -0
  32. package/src/core/fs-safety.mjs +228 -0
  33. package/src/core/graph.mjs +227 -0
  34. package/src/core/harness-wiring.mjs +477 -0
  35. package/src/core/impact-analyzer.mjs +89 -0
  36. package/src/core/mcp-server-manager.mjs +141 -0
  37. package/src/core/plan-coverage.mjs +69 -0
  38. package/src/core/plan-grapher.mjs +338 -0
  39. package/src/core/platform-caps.mjs +95 -0
  40. package/src/core/refs.mjs +187 -0
  41. package/src/core/registry-updater.mjs +232 -0
  42. package/src/core/resume-snapshot.mjs +120 -0
  43. package/src/core/scaffold.mjs +193 -0
  44. package/src/core/scope.mjs +99 -0
  45. package/src/core/skill-manager.mjs +311 -0
  46. package/src/core/status-mutator.mjs +121 -0
  47. package/src/core/ui-channel.mjs +222 -0
  48. package/src/core/validator.mjs +121 -0
  49. package/src/core/verifier.mjs +99 -0
  50. package/src/core/wave-resolver.mjs +116 -0
  51. package/src/core/worker-contract.mjs +170 -0
  52. package/src/core/yaml.mjs +517 -0
  53. package/src/envelope.mjs +65 -0
  54. package/src/server.mjs +61 -0
  55. package/src/tools/_register.mjs +120 -0
  56. package/src/tools/codegraph.mjs +53 -0
  57. package/src/tools/docs.mjs +105 -0
  58. package/src/tools/help.mjs +294 -0
  59. package/src/tools/plan.mjs +162 -0
  60. package/src/tools/refs.mjs +62 -0
  61. package/src/tools/registry.mjs +35 -0
  62. package/src/tools/setup.mjs +179 -0
  63. package/src/tools/skills.mjs +135 -0
  64. package/src/tools/tasks.mjs +180 -0
  65. package/src/tools/ui.mjs +67 -0
package/README.md CHANGED
@@ -1,3 +1,135 @@
1
- # Temporary Holding Version
1
+ # archgen-mcp
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The MCP server for [archgen](https://github.com/akashmaurya99/archgen) — it
4
+ owns **every** deterministic capability in the archgen workflow.
5
+
6
+ The archgen skill is orchestration guidance for an agent; this server is the
7
+ runtime it drives. One implementation, three ways in:
8
+
9
+ | Consumer | How it reaches the server |
10
+ |---|---|
11
+ | Coding agents | MCP over stdio — 10 domain tools |
12
+ | `archgen-skill init` / `install` | `archgen-mcp bootstrap` |
13
+ | The VS Code extension | `archgen-mcp exec <tool> '<json>'` |
14
+
15
+ ## Install
16
+
17
+ The archgen installer wires this server into every detected harness for you:
18
+
19
+ ```bash
20
+ npx archgen-skill init
21
+ ```
22
+
23
+ That installs the skill, writes the `archgen` MCP entry into each detected
24
+ harness's own config (with the correct per-platform file and top-level key),
25
+ and ensures CodeGraph.
26
+
27
+ To run it by hand:
28
+
29
+ ```bash
30
+ npx archgen-mcp # serve MCP over stdio
31
+ npx archgen-mcp --list # list the tools
32
+ npx archgen-mcp doctor # health report
33
+ ```
34
+
35
+ Requires **Node.js >= 20** (the official MCP SDK v2 floor).
36
+
37
+ ## The tools
38
+
39
+ | Tool | Use it for |
40
+ |---|---|
41
+ | `archgen_plan` | validate · verifier gate · dependency graph · blast radius · coverage · **scaffold** (the artifact set for a scope class) · **brief** (a dispatch brief) |
42
+ | `archgen_tasks` | next wave · set status · list · resume snapshot · **contract** (the assembled worker prompt) |
43
+ | `archgen_docs` | navigate markdown artifacts: section index, one section, token map, reference integrity |
44
+ | `archgen_registry` | refresh / read the AGENTS.md features registry |
45
+ | `archgen_codegraph` | install CodeGraph if it is missing · wire its MCP · index the project |
46
+ | `archgen_setup` | doctor · bootstrap servers · install/remove the MCP · list harnesses · **harness_info** (a platform's capabilities) |
47
+ | `archgen_ui` | drive the VS Code extension in real time |
48
+ | `archgen_skills` | match / install / load external capability skills |
49
+ | `archgen_refs` | load archgen's own protocol documents — section by section |
50
+ | `archgen_help` | the full briefing for one domain |
51
+
52
+ Every tool returns the same envelope:
53
+
54
+ ```json
55
+ { "ok": true, "data": { }, "error": null, "meta": { "serverVersion": "…", "skillVersion": "…", "projectRoot": "…" } }
56
+ ```
57
+
58
+ `ok` says whether the **call** succeeded. A failed call carries a typed
59
+ `error.code`:
60
+
61
+ `INVALID_INPUT` · `NOT_FOUND` · `CYCLE` · `OWNERSHIP_CONFLICT` · `CONFLICT` ·
62
+ `PERMISSION_DENIED` · `UNAVAILABLE` · `TIMEOUT` · `INTERNAL`
63
+
64
+ Call `archgen_help { topic: "<domain>" }` for the full briefing on any tool —
65
+ including when to call it, every action, and its gotchas.
66
+
67
+ ### The judgment / output split
68
+
69
+ The archgen **skill** carries the judgment (policy, rules, when-to-use). This
70
+ server carries the **deterministic output** — the artifact sets, the skeletons,
71
+ the dispatch briefs, the assembled worker prompt, the harness capability tables.
72
+
73
+ The five orchestrator-facing protocol documents also live **here**, in
74
+ `assets/references/`, and are served section-by-section by `archgen_refs`:
75
+
76
+ ```
77
+ archgen_refs { action: 'index', topic: 'orchestration' }
78
+ archgen_refs { action: 'read', topic: 'orchestration', section: 'dispatch--wave-execution' }
79
+ ```
80
+
81
+ They live here so they are always the same version as the tools they describe.
82
+ One exception stays in the skill as a plain file: `code-standards.md`, because
83
+ WORKER sub-agents read it with their native file tools and may have no MCP
84
+ server at all.
85
+
86
+ ### The capability contract
87
+
88
+ The skill declares the server version it needs:
89
+
90
+ ```yaml
91
+ metadata:
92
+ requires:
93
+ archgen_mcp: ">=x.y.z"
94
+ ```
95
+
96
+ `archgen_setup { action: 'doctor' }` reports a mismatch, `bootstrap` warns
97
+ before wiring, and CI refuses to ship a skill whose declared minimum exceeds
98
+ this package's version.
99
+
100
+ ## The CLI facade
101
+
102
+ ```bash
103
+ archgen-mcp exec archgen_plan '{"action":"validate","tasksYaml":"/abs/tasks.yaml"}'
104
+ archgen-mcp exec archgen_tasks '{"action":"next","tasksYaml":"/abs/tasks.yaml"}'
105
+ archgen-mcp bootstrap --project . --location both --yes
106
+ archgen-mcp doctor --project . --json
107
+ archgen-mcp uninstall-mcp --project . --yes
108
+ ```
109
+
110
+ `exec` runs the **same handlers** the MCP tools expose — there is no second
111
+ implementation of any capability, only a second way to reach it.
112
+
113
+ ## Safety
114
+
115
+ - The server owns a **boundary**: the directory it was started in. A tool's
116
+ `projectRoot` argument selects a directory *inside* that boundary — it
117
+ cannot redefine it, so a model cannot move the edge by naming a different
118
+ root.
119
+ - Every path argument is resolved against the project root and refused if it
120
+ escapes; symlinked targets are never written through, and a symlinked
121
+ *parent* is caught by comparing real paths.
122
+ - The artifact space is anchored to the project: a `.archgen` directory
123
+ elsewhere on the machine is not this project's artifacts.
124
+ - MCP-config writes are approval-gated (`approve: true` / `--yes`); without
125
+ approval the tool reports its **plan** and writes nothing.
126
+ - A config file that cannot be parsed is reported, never rewritten.
127
+ - Writes are atomic (temp file + rename): readers see old-or-new, never a
128
+ partial file. A read-modify-write — a status update, a config merge — runs
129
+ under an exclusive lock, so two workers cannot lose each other's change.
130
+ - UI commands are allowlisted, workspace-scoped, expiring, and idempotent;
131
+ the command queue is pruned, so it cannot grow without bound.
132
+
133
+ ## License
134
+
135
+ MIT
@@ -0,0 +1,22 @@
1
+ TASK: Investigate a recurring issue in this repository.
2
+ TRIGGER: the user reports repetitive/recurring issues AFTER implementation waves
3
+ completed. This is NOT a patch-fix task.
4
+
5
+ DELIVERABLE: all four, or the investigation is incomplete:
6
+ 1. ROOT CAUSE — one sentence naming the actual defect (not the symptom).
7
+ 2. EVIDENCE — files / lines / repro steps that prove it.
8
+ 3. BLAST RADIUS — which tasks and artifacts are affected.
9
+ Use `archgen_plan { action: 'impact', tasksYaml: <tasks.yaml>, target: <id-or-path> }`.
10
+ 4. REMEDIATION — routed through the NORMAL gates: new fix tasks get fresh ids
11
+ inheriting the affected task's ownership globs.
12
+
13
+ SIZING
14
+ - SMALL scope: the main agent investigates directly.
15
+ - MEDIUM/LARGE: 1–3 investigator sub-agents split by suspected subsystem.
16
+
17
+ DISCIPLINE
18
+ - Read narrowly around the evidence — no whole-repo sweeps.
19
+ - A patch-fix WITHOUT a root-cause statement is FORBIDDEN under this protocol.
20
+ - Write your notes under .archgen/<slug>/.agent/notes/<topic>.md and your
21
+ findings under .archgen/<slug>/.agent/reports/investigate-<round>.md.
22
+ NEVER create ad-hoc folders at the repo root.
@@ -0,0 +1,35 @@
1
+ TASK: Review the plan in .archgen/<slug>/ READ-ONLY.
2
+ DELIVERABLE: a numbered findings list; each finding = what + where + why.
3
+ You NEVER edit files. You report only.
4
+
5
+ EXAMINE
6
+ - edge cases per module
7
+ - task ordering / parallelization sanity (waves vs real dependencies)
8
+ - cross-module contract mismatches (interfaces, paths, naming)
9
+ - enhancement recommendations
10
+ - documentation completeness
11
+
12
+ CONTEXT TO ATTACH
13
+ - `archgen_plan { action: 'graph', tasksYaml: <tasks.yaml>, format: 'mermaid', status: true }`
14
+ — the wave-progress render; reviewer reads it to sanity-check ordering.
15
+ - `archgen_docs { action: 'validate', slugDir: <slug dir> }` — the reference
16
+ integrity result; broken references are findings, not noise.
17
+
18
+ SIZING
19
+ - SMALL: the main agent's self-review is acceptable when the harness has no
20
+ reviewer mechanism.
21
+ - MEDIUM: 1 reviewer.
22
+ - LARGE: 1 holistic reviewer on the strongest reasoning tier. A 2nd reviewer
23
+ ONLY if the plan is genuinely too large for one reviewer's context — split by
24
+ ARTIFACT/VOLUME (e.g. plans vs docs), never by concern.
25
+
26
+ ONE holistic reviewer analyzes ALL issues together: cross-issue reasoning catches
27
+ contradictions a narrow per-concern slice misses, and one reviewer costs far
28
+ fewer tokens than several. NEVER dispatch one sub-agent per individual issue.
29
+
30
+ BOUNDS
31
+ - A "more review" approval authorizes EXACTLY ONE additional pass — never a
32
+ fresh loop, never more reviewers. The stage ends ONLY at zero findings or an
33
+ explicit user waiver on record.
34
+ - The ORCHESTRATOR fixes the artifacts, re-runs validate + the verifier gate
35
+ after every change, and re-dispatches. Reviewers never fix.
@@ -0,0 +1,22 @@
1
+ TASK: Survey this repository to prepare a feature plan for: <feature request>
2
+ DELIVERABLE: write .archgen/<slug>/codebase-map.md containing EXACTLY these
3
+ sections:
4
+ ## Structure — top-2-levels folder tree w/ one-line purpose each
5
+ ## Modules — table: module | responsibility | key entry points
6
+ ## Conventions — naming, error-handling, test layout actually observed
7
+ ## Affected — files/modules the feature will touch, with evidence paths
8
+ SCOPE: read-only.
9
+ NAVIGATE: use the CodeGraph MCP tools when available — the index is built once
10
+ at bootstrap and kept live by the server's watcher, so never re-index.
11
+ Otherwise Glob+Grep systematically.
12
+ VERIFY: every claim cites a real path; no guessed APIs. A claim without an
13
+ evidence path is a defect, not a detail.
14
+
15
+ ACCEPTANCE
16
+ The map is accepted only if every section is present and NON-EMPTY. Anything the
17
+ survey could not determine is written down as an explicit unknown, not omitted —
18
+ an omitted section is indistinguishable from an un-surveyed one.
19
+
20
+ THEN: the orchestrator asks ONLY what the survey could not answer. Never
21
+ interrogate the user with what a file already answers — quote the file and ask
22
+ for confirmation instead.
@@ -0,0 +1,44 @@
1
+ TASK: Verify this archgen plan before any execution.
2
+ DELIVERABLE: exactly one line — `APPROVE` or `ISSUES:` followed by a numbered list.
3
+ SCOPE: read-only. You NEVER edit files. You report findings only.
4
+
5
+ RUN THESE FIRST (the deterministic floor — every one must pass):
6
+ 1. `archgen_plan { action: 'verify', tasksYaml: <tasks.yaml>, planDir: <plans dir> }`
7
+ — must return verdict APPROVE. It checks cycles, dangling refs, same-wave
8
+ ownership overlap, missing acceptance criteria and plan<->task coverage.
9
+ 2. `archgen_docs { action: 'validate', slugDir: <slug dir> }` (when markdown
10
+ artifacts exist) — must return valid:true. Broken references BLOCK approval.
11
+
12
+ THEN judge what the tools cannot:
13
+ - Are wave boundaries sensible (no artificial serialization)?
14
+ - Do acceptance criteria objectively verify (a command or an observable)?
15
+ - Is edge-case coverage adequate for the scope class of each task?
16
+ - Is code-standards compliance plausible for the planned structure?
17
+ - CONTRACT-COMPLETENESS sweep — round 1 must confirm OR flag-as-missing every
18
+ APPLICABLE dimension. Apply a dimension only where the system actually has
19
+ that concern, but NEVER skip a dimension the system touches:
20
+ - Functional coverage: every stated requirement has a task + objectively
21
+ verifiable acceptance.
22
+ - Security & data protection (if it authenticates, authorizes, encrypts or
23
+ handles sensitive data): authn/authz flows, session & credential lifecycle,
24
+ replay/CSRF protection, encryption & privacy boundaries, input validation.
25
+ - Data integrity: schemas, relationships, validation, migration / back-compat.
26
+ - State, lifecycle & recovery (if any operation is stateful, long-running or
27
+ multi-step): checkpointing/resume, idempotency, cleanup, expiry,
28
+ compensation/rollback semantics.
29
+ - Resource limits & abuse (if it exposes shared or anonymous resources):
30
+ quotas, rate limits, retention/deletion, anonymous-abuse controls.
31
+ - Operational entrypoints: every stack-required build/deploy/test/bootstrap
32
+ entrypoint is OWNED by some task.
33
+ - Metric traceability: every PRD success metric maps to a task acceptance
34
+ criterion with a reproducible command / sample size / data source.
35
+ - Consistency: cross-contract claims must not contradict each other.
36
+ These failure classes are the TOP cause of multi-round loops — round 1 MUST
37
+ sweep the applicable dimensions exhaustively.
38
+
39
+ RULES
40
+ - Run on the STRONGEST reasoning agent the harness offers. NEVER an explore /
41
+ research / quick / cheap tier: a weak verifier misses real defects AND raises
42
+ false positives, costing MORE rounds, not fewer.
43
+ - Every finding names the file and the reason. No vague findings.
44
+ - If everything passes, return exactly `APPROVE` and nothing else.
@@ -0,0 +1,90 @@
1
+ {
2
+ "version": 1,
3
+ "_readme": [
4
+ "Canonical depth ladder: scope class -> the artifact set a plan MUST have.",
5
+ "",
6
+ "This is the machine-readable twin of references/artifact-templates.md § Plan",
7
+ "depth by scope class. The reference keeps the AUTHORING RULES; this file",
8
+ "owns the ARTIFACT SET, so the orchestrator never guesses which files a",
9
+ "SMALL/MEDIUM/LARGE plan needs. `archgen_plan{action:'scaffold'}` serves it.",
10
+ "",
11
+ "A drift test (packages/mcp/test/core/depth-ladder.test.mjs) pins this file",
12
+ "against the reference's stated minimums."
13
+ ],
14
+ "classes": {
15
+ "SMALL": {
16
+ "label": "SMALL — add or touch a few things",
17
+ "intentDefaults": ["BROWNFIELD-CHANGE"],
18
+ "roundCap": 3,
19
+ "artifacts": [
20
+ { "path": ".archgen/<slug>/tasks.yaml", "required": true, "purpose": "the task contract" },
21
+ { "path": ".archgen/<slug>/plans/<slug>-note.md", "required": true, "purpose": "a lean plan note" }
22
+ ],
23
+ "planSections": ["Intent", "Tasks", "Risks"],
24
+ "minEdgeCasesPerTask": 0,
25
+ "requires": [],
26
+ "forbids": ["docs/prd.md", "architecture.yaml", "decisions/"],
27
+ "notes": [
28
+ "Every task entry STILL carries repo-root-relative paths verbatim in file_ownership, in each step, and in verification commands.",
29
+ "No Context section, no diagrams, no PRD."
30
+ ]
31
+ },
32
+ "MEDIUM": {
33
+ "label": "MEDIUM — a real feature with real risk",
34
+ "intentDefaults": ["GREENFIELD-MODULE", "BROWNFIELD-FEATURE"],
35
+ "roundCap": 3,
36
+ "artifacts": [
37
+ { "path": ".archgen/<slug>/tasks.yaml", "required": true, "purpose": "the task contract" },
38
+ { "path": ".archgen/<slug>/plans/<slug>.md", "required": true, "purpose": "the full plan" }
39
+ ],
40
+ "planSections": ["Context", "Per-task sections", "Verification steps"],
41
+ "minEdgeCasesPerTask": 3,
42
+ "requires": ["plan context of 2-4 paragraphs", "per-task sections with approach + edge cases + out-of-scope", "ordered runnable verification steps"],
43
+ "forbids": ["docs/prd.md", "architecture.yaml"],
44
+ "notes": [
45
+ "One `<id> — <title>` heading per task, in dependency order.",
46
+ "Verification steps are repo-root-relative (no `../`, no `--plan .`), exact, and runnable."
47
+ ]
48
+ },
49
+ "LARGE": {
50
+ "label": "LARGE — a full professional stack (greenfield from scratch)",
51
+ "intentDefaults": ["GREENFIELD-SYSTEM"],
52
+ "roundCap": 6,
53
+ "artifacts": [
54
+ { "path": ".archgen/<slug>/answers.yaml", "required": true, "purpose": "the captured requirements" },
55
+ { "path": ".archgen/<slug>/docs/prd.md", "required": true, "purpose": "the product requirements — FR ids tasks cite" },
56
+ { "path": ".archgen/<slug>/architecture.yaml", "required": true, "purpose": "the contract source of truth" },
57
+ { "path": ".archgen/<slug>/tasks.yaml", "required": true, "purpose": "the task contract" },
58
+ { "path": ".archgen/<slug>/plans/<slug>.md", "required": true, "purpose": "the full plan" },
59
+ { "path": ".archgen/<slug>/decisions/NNNN-<title>.md", "required": false, "purpose": "formal ADRs (one per decision)" },
60
+ { "path": ".archgen/<slug>/docs/<module>.md", "required": false, "purpose": "per-module diagrams (≤15 nodes each)" }
61
+ ],
62
+ "planSections": ["Context", "Per-task sections", "Edge-case matrices", "Verification steps"],
63
+ "minEdgeCasesPerTask": 3,
64
+ "requires": [
65
+ "docs/prd.md written BEFORE tasks.yaml (~1 page per major module)",
66
+ "architecture.yaml with naming_conventions, data_contracts, api_contracts and environment_matrix",
67
+ "an edge-case matrix per task (every row maps to an acceptance bullet)",
68
+ "per-module diagrams (≤15 nodes each) plus one integration diagram",
69
+ "MEDIUM-grade plan sections"
70
+ ],
71
+ "forbids": [],
72
+ "notes": [
73
+ "Requirement ids (FR-<MODULE>-nn) are defined in docs/prd.md and cited from tasks.yaml acceptance lines.",
74
+ "architecture.yaml is the anti-hallucination source of truth: tasks cite its keys instead of restating shapes from memory."
75
+ ]
76
+ }
77
+ },
78
+ "edgeCaseClasses": [
79
+ "empty/null",
80
+ "boundary values",
81
+ "authz denied",
82
+ "concurrent/conflicting write",
83
+ "failure/retry path",
84
+ "i18n/formatting edge"
85
+ ],
86
+ "edgeCaseExtras": {
87
+ "infra": ["partial-failure recovery", "rollback story"],
88
+ "maxRowsPerMatrix": 10
89
+ }
90
+ }