archgen-mcp 0.0.6 → 0.1.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.
Files changed (59) hide show
  1. package/README.md +14 -9
  2. package/assets/briefs/investigate.md +16 -17
  3. package/assets/briefs/review.md +41 -29
  4. package/assets/briefs/survey.md +17 -20
  5. package/assets/briefs/verifier.md +52 -40
  6. package/assets/harness-mcp.json +285 -55
  7. package/assets/platform-capabilities.json +387 -71
  8. package/assets/references/artifact-templates.md +68 -219
  9. package/assets/references/interview.md +83 -199
  10. package/assets/references/mcp-and-skills.md +35 -125
  11. package/assets/references/orchestration.md +96 -209
  12. package/assets/references/platforms.md +41 -108
  13. package/assets/skill-registry.json +10 -1
  14. package/assets/templates/adr.md +3 -3
  15. package/assets/templates/architecture.yaml +31 -28
  16. package/assets/templates/edge-matrix.md +8 -8
  17. package/assets/templates/mermaid.md +3 -10
  18. package/assets/templates/prd.md +15 -15
  19. package/assets/templates/tasks.yaml +25 -18
  20. package/bin/archgen-mcp.mjs +6 -4
  21. package/package.json +2 -2
  22. package/src/cli.mjs +1 -2
  23. package/src/context.mjs +55 -45
  24. package/src/core/brief-context.mjs +106 -0
  25. package/src/core/brief-scope.mjs +218 -0
  26. package/src/core/briefs.mjs +121 -0
  27. package/src/core/codegraph-manager.mjs +124 -48
  28. package/src/core/compat.mjs +13 -3
  29. package/src/core/doc-navigator.mjs +127 -24
  30. package/src/core/errors.mjs +1 -1
  31. package/src/core/fs-safety.mjs +98 -10
  32. package/src/core/graph.mjs +8 -3
  33. package/src/core/harness-wiring.mjs +194 -37
  34. package/src/core/jsonc-config.mjs +706 -0
  35. package/src/core/mcp-server-manager.mjs +2 -3
  36. package/src/core/plan-coverage.mjs +43 -6
  37. package/src/core/plan-grapher.mjs +13 -5
  38. package/src/core/platform-caps.mjs +9 -2
  39. package/src/core/resume-snapshot.mjs +16 -4
  40. package/src/core/scope.mjs +39 -5
  41. package/src/core/skill-manager.mjs +181 -13
  42. package/src/core/skill-roots.mjs +92 -0
  43. package/src/core/status-mutator.mjs +34 -3
  44. package/src/core/tokens.mjs +78 -0
  45. package/src/core/validator.mjs +16 -3
  46. package/src/core/verifier.mjs +3 -9
  47. package/src/core/worker-contract.mjs +161 -20
  48. package/src/core/yaml.mjs +31 -6
  49. package/src/server.mjs +0 -3
  50. package/src/tools/_register.mjs +5 -4
  51. package/src/tools/codegraph.mjs +0 -2
  52. package/src/tools/docs.mjs +6 -6
  53. package/src/tools/help.mjs +18 -35
  54. package/src/tools/plan.mjs +58 -7
  55. package/src/tools/setup.mjs +7 -3
  56. package/src/tools/skills.mjs +67 -5
  57. package/src/tools/tasks.mjs +82 -23
  58. package/src/core/ui-channel.mjs +0 -171
  59. package/src/tools/ui.mjs +0 -67
package/README.md CHANGED
@@ -4,13 +4,12 @@ The MCP server for [archgen](https://github.com/akashmaurya99/archgen) — it
4
4
  owns **every** deterministic capability in the archgen workflow.
5
5
 
6
6
  The archgen skill is orchestration guidance for an agent; this server is the
7
- runtime it drives. One implementation, three ways in:
7
+ runtime it drives. One implementation, two ways in:
8
8
 
9
9
  | Consumer | How it reaches the server |
10
10
  |---|---|
11
- | Coding agents | MCP over stdio — 10 domain tools |
11
+ | Coding agents | MCP over stdio — 8 domain tools + `archgen_help` |
12
12
  | `archgen-skill init` / `install` | `archgen-mcp bootstrap` |
13
- | The VS Code extension | `archgen-mcp exec <tool> '<json>'` |
14
13
 
15
14
  ## Install
16
15
 
@@ -42,9 +41,8 @@ Requires **Node.js >= 20** (the official MCP SDK v2 floor).
42
41
  | `archgen_tasks` | next wave · set status · list · resume snapshot · **contract** (the assembled worker prompt) |
43
42
  | `archgen_docs` | navigate markdown artifacts: section index, one section, token map, reference integrity |
44
43
  | `archgen_registry` | refresh / read the AGENTS.md features registry |
45
- | `archgen_codegraph` | install + wire + index CodeGraph and its MCP |
44
+ | `archgen_codegraph` | install CodeGraph if it is missing · wire its MCP · index the project |
46
45
  | `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
46
  | `archgen_skills` | match / install / load external capability skills |
49
47
  | `archgen_refs` | load archgen's own protocol documents — section by section |
50
48
  | `archgen_help` | the full briefing for one domain |
@@ -90,7 +88,7 @@ The skill declares the server version it needs:
90
88
  ```yaml
91
89
  metadata:
92
90
  requires:
93
- archgen_mcp: ">=0.0.6"
91
+ archgen_mcp: ">=x.y.z"
94
92
  ```
95
93
 
96
94
  `archgen_setup { action: 'doctor' }` reports a mismatch, `bootstrap` warns
@@ -112,14 +110,21 @@ implementation of any capability, only a second way to reach it.
112
110
 
113
111
  ## Safety
114
112
 
113
+ - The server owns a **boundary**: the directory it was started in. A tool's
114
+ `projectRoot` argument selects a directory *inside* that boundary — it
115
+ cannot redefine it, so a model cannot move the edge by naming a different
116
+ root.
115
117
  - Every path argument is resolved against the project root and refused if it
116
- escapes; symlinked targets are never written through.
118
+ escapes; symlinked targets are never written through, and a symlinked
119
+ *parent* is caught by comparing real paths.
120
+ - The artifact space is anchored to the project: a `.archgen` directory
121
+ elsewhere on the machine is not this project's artifacts.
117
122
  - MCP-config writes are approval-gated (`approve: true` / `--yes`); without
118
123
  approval the tool reports its **plan** and writes nothing.
119
124
  - A config file that cannot be parsed is reported, never rewritten.
120
125
  - Writes are atomic (temp file + rename): readers see old-or-new, never a
121
- partial file.
122
- - UI commands are allowlisted, workspace-scoped, expiring, and idempotent.
126
+ partial file. A read-modify-write — a status update, a config merge — runs
127
+ under an exclusive lock, so two workers cannot lose each other's change.
123
128
 
124
129
  ## License
125
130
 
@@ -1,22 +1,21 @@
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.
1
+ TASK: Investigate a recurring post-execution defect in this repository.
2
+ TRIGGER: User reports repetitive/recurring issues AFTER implementation waves completed. This is NOT a patch-fix task.
3
+ SCOPE: Read-only analysis and reporting (unless the brief explicitly authorizes edits).
4
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.
5
+ DELIVERABLE — all four sections are MANDATORY:
6
+ 1. ROOT CAUSE: One sentence identifying the underlying defect (never merely the symptom).
7
+ 2. EVIDENCE: Exact file paths, line numbers, and reproduction steps proving the root cause.
8
+ 3. BLAST RADIUS: Affected tasks and artifacts computed via `archgen_plan { action: 'impact', tasksYaml: <tasks.yaml>, target: <id-or-path> }`.
9
+ 4. REMEDIATION: Proposed fix tasks (new task IDs inheriting affected `file_ownership` globs) routed through normal Verifier, Review, and User gates.
12
10
 
13
11
  SIZING
14
- - SMALL scope: the main agent investigates directly.
15
- - MEDIUM/LARGE: 1–3 investigator sub-agents split by suspected subsystem.
12
+ - SMALL: Main agent investigates directly.
13
+ - MEDIUM / LARGE: 1 investigator by default. Dispatch a 2nd investigator ONLY when the suspected defect spans disjoint subsystems—split strictly by SUBSYSTEM with zero file overlap.
16
14
 
17
15
  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.
16
+ - Read narrowly around evidence paths; avoid whole-repo sweeps.
17
+ - Patch-fixing without a verified root-cause statement is FORBIDDEN.
18
+ - Write working notes to `<slug dir>/.agent/notes/<topic>.md` and final report to `<slug dir>/.agent/reports/investigate-<round>.md`. Never create ad-hoc root directories.
19
+
20
+ REUSE
21
+ For any follow-up question, verification, or fix touching these files, CONTINUE THIS AGENT'S SESSION rather than spawning a new agent.
@@ -1,35 +1,47 @@
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.
1
+ TASK: Review the plan in `<slug dir>` READ-ONLY.
2
+ SCOPE: Read-only. NEVER edit files or code; output findings only.
3
+ DELIVERABLE: ONE message in this exact format:
4
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
5
+ ```
6
+ VERDICT: APPROVE
7
+ COVERAGE:
8
+ | area | status | reason |
9
+ | --- | --- | --- |
10
+ | edge cases per module | PASS | matrices cover empty, boundary, authz, concurrency, retry, and i18n states |
11
+ | task ordering & parallelization | N/A | single sequential wave |
12
+ | cross-module contracts | PASS | every shared interface has a single owning task |
13
+ | enhancement opportunities | PASS | none material for this scope |
14
+ | documentation completeness | PASS | every task has a matching plan section |
15
+ ```
11
16
 
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
+ or
17
18
 
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.
19
+ ```
20
+ VERDICT: ISSUES
21
+ COVERAGE:
22
+ | area | status | reason |
23
+ | --- | --- | --- |
24
+ | ... all 5 areas above marked PASS, FAIL, or N/A ... |
25
+ FINDINGS:
26
+ 1. plans/demo.md § API — response type named inconsistently — client/server contract mismatch — standardize on ApiResponse
27
+ 2. docs/prd.md § Grades — FR-GRADE-02 has no owning task — requirement will not be built — add task owning grade-read endpoint
28
+ ```
25
29
 
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.
30
+ EXAMINE ALL 5 AREAS EVERY RUN:
31
+ 1. `edge cases per module`
32
+ 2. `task ordering & parallelization` (waves vs real `depends_on` edges)
33
+ 3. `cross-module contracts` (interfaces, paths, `naming_conventions`)
34
+ 4. `enhancement opportunities`
35
+ 5. `documentation completeness`
36
+
37
+ MANDATORY COVERAGE TABLE: Must appear in every report (even on `APPROVE`). Mark every area `PASS`, `FAIL`, or `N/A` with a 1-line reason. Omitting the table or any row makes the report INCOMPLETE.
38
+
39
+ SIZING & CONTEXT
40
+ - SMALL: Main-agent self-review permitted if no reviewer sub-agent exists.
41
+ - MEDIUM: 1 holistic reviewer.
42
+ - LARGE: 1 top-tier holistic reviewer (2nd allowed ONLY if context limits force splitting `plans/` vs `docs/`; never split by review area).
43
+ - Use the pre-rendered dependency graph and doc-validation results in the `CONTEXT` block below—make zero `archgen_*` tool calls.
29
44
 
30
45
  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.
46
+ - A user "more review" approval grants EXACTLY ONE additional pass. The stage exits only on zero findings or an explicit user waiver.
47
+ - The ORCHESTRATOR applies all fixes and re-runs `validate` + Verifier Gate; reviewers never edit files.
@@ -1,22 +1,19 @@
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.
1
+ TASK: Survey this repository to prepare a feature plan for: `<feature request>`
2
+ SCOPE: Read-only exploration, writing ONLY `<slug dir>/codebase-map.md`.
14
3
 
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.
4
+ DELIVERABLE: Write `<slug dir>/codebase-map.md` containing EXACTLY these four non-empty sections:
5
+ ## Structure — Top 2 directory levels with 1-line purpose per folder
6
+ ## Modules — Table: `module | responsibility | key entry points`
7
+ ## Conventions — Observed file naming, error handling, and test placement patterns
8
+ ## Affected — Files/modules impacted by the feature, citing exact evidence paths
19
9
 
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.
10
+ NAVIGATION & VERIFICATION
11
+ - Prefer CodeGraph MCP tools when `.codegraph/` is present (index is kept live by the watcher—never re-index); otherwise use systematic Glob + Grep.
12
+ - Every architectural claim MUST cite a real repository file path. Never guess APIs.
13
+ - Every section must be present and non-empty; document unresolved items as explicit unknowns rather than omitting sections.
14
+ - Downstream rule: The orchestrator will ask the user ONLY what this map could not answer.
15
+
16
+ SIZING & REUSE
17
+ - SMALL: Main agent surveys in one pass.
18
+ - MEDIUM / LARGE: 1–2 survey agents split strictly by disjoint SUBSYSTEM (zero file overlap).
19
+ - Continue this agent's session for any follow-up questions covering the surveyed subsystem.
@@ -1,44 +1,56 @@
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.
1
+ TASK: Verify the archgen plan in `<slug dir>` before execution.
2
+ SCOPE: Read-only. NEVER edit files; report verdict, coverage table, and findings only.
4
3
 
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.
4
+ STEP 1 — RUN DETERMINISTIC CHECKS FIRST (both must pass):
5
+ 1. `archgen_plan { action: 'verify', tasksYaml: <tasks.yaml>, planDir: <plans dir> }` $\rightarrow$ must return `verdict: 'APPROVE'` (validates DAG, dangling refs, wave ownership disjointness, acceptance presence, and bidirectional plan$\leftrightarrow$task coverage).
6
+ 2. `archgen_docs { action: 'validate', slugDir: <slug dir> }` (if markdown artifacts exist) $\rightarrow$ must return `valid: true` (zero broken links or heading anchors).
11
7
 
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.
8
+ STEP 2 — AUDIT JUDGMENT & CONTRACT COMPLETENESS:
9
+ - Wave boundaries match true dependencies without artificial serialization.
10
+ - Acceptance criteria are objectively verifiable (runnable command or observable output).
11
+ - Edge-case coverage satisfies the scope class (`SMALL` / `MEDIUM` / `LARGE`).
12
+ - Planned structure and naming obey `references/code-standards.md`.
13
+ - **CONTRACT-COMPLETENESS SWEEP** (evaluate every dimension; mark `N/A` only when the system genuinely lacks that surface):
14
+ 1. `functional coverage`: Every requirement maps to a task + objective acceptance check.
15
+ 2. `security & data protection`: Authn/authz flows, session/credential lifecycle, CSRF/replay defense, encryption/privacy boundaries, boundary input validation.
16
+ 3. `data integrity`: Schemas, foreign keys/relations, validation rules, migrations & backward compatibility.
17
+ 4. `state, lifecycle & recovery`: Checkpointing/resume, idempotency, cleanup/TTL, rollback/compensation for stateful or multi-step flows.
18
+ 5. `resource limits & abuse`: Quotas, rate limiting, data retention/deletion, unauthenticated abuse controls.
19
+ 6. `operational entrypoints`: Build, test, deploy, and bootstrap entrypoints are each owned by a task.
20
+ 7. `metric traceability`: Every PRD success metric maps to a task acceptance check with a reproducible command, sample size, or data source.
21
+ 8. `consistency`: Zero contradictions across PRD, `architecture.yaml`, `plans/*.md`, and `tasks.yaml`.
22
+
23
+ DELIVERABLE — ONE message in this exact format:
24
+
25
+ ```
26
+ VERDICT: APPROVE
27
+ COVERAGE:
28
+ | dimension | status | reason |
29
+ | --- | --- | --- |
30
+ | functional coverage | PASS | all FR IDs map to tasks with runnable checks |
31
+ | security & data protection | N/A | internal CLI with no auth or sensitive data |
32
+ | data integrity | PASS | schemas and migrations are fully typed and owned |
33
+ | state, lifecycle & recovery | FAIL | TASK-07 mutates state without rollback or idempotency |
34
+ | resource limits & abuse | N/A | no shared or public network surface |
35
+ | operational entrypoints | PASS | build, test, and CLI entrypoints have owning tasks |
36
+ | metric traceability | PASS | PRD latency target verified by benchmark acceptance command |
37
+ | consistency | PASS | all contracts align across architecture.yaml and plans |
38
+ ```
39
+
40
+ or
41
+
42
+ ```
43
+ VERDICT: ISSUES
44
+ COVERAGE:
45
+ | dimension | status | reason |
46
+ | --- | --- | --- |
47
+ | ... all 8 dimensions above marked PASS, FAIL, or N/A ... |
48
+ FINDINGS:
49
+ 1. tasks.yaml § SCAFFOLD — acceptance #2 has no observable check — worker cannot verify completion — replace with "npm run build exits 0"
50
+ 2. plans/demo.md § Risks — config-drift risk has no owning task — mitigation never built — assign mitigation to TASK-01
51
+ ```
38
52
 
39
53
  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.
54
+ - **MANDATORY COVERAGE TABLE:** Every report (even `APPROVE`) must include all 8 dimensions marked `PASS`, `FAIL`, or `N/A` with a 1-line reason. Missing rows = INCOMPLETE report (treated as `ISSUES`).
55
+ - **Top-tier holistic agent:** Run on the strongest reasoning model available (never a quick/explore/cheap tier) as ONE holistic agent across the entire plan.
56
+ - **Exhaustive single pass:** Report EVERY defect found in this pass with exact `file § section — defect — impact — fix`. Never hold findings back for a later round.