@drafthq/draft 2.7.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/.claude-plugin/marketplace.json +38 -0
- package/.claude-plugin/plugin.json +26 -0
- package/LICENSE +21 -0
- package/README.md +272 -0
- package/bin/README.md +49 -0
- package/cli/bin/draft.js +13 -0
- package/cli/src/cli.js +113 -0
- package/cli/src/hosts/claude-code.js +46 -0
- package/cli/src/hosts/codex.js +33 -0
- package/cli/src/hosts/cursor.js +50 -0
- package/cli/src/hosts/index.js +24 -0
- package/cli/src/hosts/opencode.js +39 -0
- package/cli/src/installer.js +61 -0
- package/cli/src/lib/fsx.js +34 -0
- package/cli/src/lib/graph.js +23 -0
- package/cli/src/lib/log.js +32 -0
- package/cli/src/lib/paths.js +14 -0
- package/core/agents/architect.md +338 -0
- package/core/agents/debugger.md +193 -0
- package/core/agents/ops.md +104 -0
- package/core/agents/planner.md +158 -0
- package/core/agents/rca.md +314 -0
- package/core/agents/reviewer.md +256 -0
- package/core/agents/writer.md +110 -0
- package/core/guardrails/README.md +4 -0
- package/core/guardrails/code-quality.md +4 -0
- package/core/guardrails/dependency-triage.md +4 -0
- package/core/guardrails/design-norms.md +4 -0
- package/core/guardrails/language-standards.md +4 -0
- package/core/guardrails/review-checks.md +4 -0
- package/core/guardrails/secure-patterns.md +4 -0
- package/core/guardrails/security.md +4 -0
- package/core/guardrails.md +22 -0
- package/core/knowledge-base.md +127 -0
- package/core/methodology.md +1221 -0
- package/core/shared/condensation.md +224 -0
- package/core/shared/context-verify.md +44 -0
- package/core/shared/cross-skill-dispatch.md +127 -0
- package/core/shared/discovery-schema.md +75 -0
- package/core/shared/draft-context-loading.md +282 -0
- package/core/shared/git-report-metadata.md +106 -0
- package/core/shared/graph-query.md +239 -0
- package/core/shared/graph-usage-report.md +22 -0
- package/core/shared/jira-sync.md +170 -0
- package/core/shared/parallel-analysis.md +386 -0
- package/core/shared/parallel-fanout.md +10 -0
- package/core/shared/pattern-learning.md +146 -0
- package/core/shared/red-flags.md +58 -0
- package/core/shared/template-contract.md +22 -0
- package/core/shared/template-hygiene.md +10 -0
- package/core/shared/tool-resolver.md +10 -0
- package/core/shared/vcs-commands.md +97 -0
- package/core/shared/verification-gates.md +47 -0
- package/core/templates/CHANGELOG.md +70 -0
- package/core/templates/ai-context-export.md +8 -0
- package/core/templates/ai-context.md +270 -0
- package/core/templates/ai-profile.md +41 -0
- package/core/templates/architecture.md +203 -0
- package/core/templates/dependency-graph.md +103 -0
- package/core/templates/discovery.md +79 -0
- package/core/templates/guardrails.md +143 -0
- package/core/templates/hld.md +327 -0
- package/core/templates/intake-questions.md +403 -0
- package/core/templates/jira.md +119 -0
- package/core/templates/lld.md +283 -0
- package/core/templates/metadata.json +66 -0
- package/core/templates/plan.md +130 -0
- package/core/templates/product.md +110 -0
- package/core/templates/rca.md +86 -0
- package/core/templates/root-architecture.md +127 -0
- package/core/templates/root-product.md +53 -0
- package/core/templates/root-tech-stack.md +117 -0
- package/core/templates/service-index.md +55 -0
- package/core/templates/session-summary.md +8 -0
- package/core/templates/spec.md +165 -0
- package/core/templates/tech-matrix.md +101 -0
- package/core/templates/tech-stack.md +169 -0
- package/core/templates/track-architecture.md +311 -0
- package/core/templates/workflow.md +187 -0
- package/integrations/agents/AGENTS.md +24384 -0
- package/integrations/copilot/.github/copilot-instructions.md +24384 -0
- package/integrations/gemini/.gemini.md +26 -0
- package/package.json +53 -0
- package/scripts/fetch-memory-engine.sh +116 -0
- package/scripts/lib.sh +256 -0
- package/scripts/tools/_lib.sh +220 -0
- package/scripts/tools/adr-index.sh +117 -0
- package/scripts/tools/check-graph-usage-report.sh +95 -0
- package/scripts/tools/check-scope-conflicts.sh +139 -0
- package/scripts/tools/check-skill-line-caps.sh +115 -0
- package/scripts/tools/check-template-noop.sh +87 -0
- package/scripts/tools/check-track-hygiene.sh +230 -0
- package/scripts/tools/classify-files.sh +231 -0
- package/scripts/tools/cycle-detect.sh +75 -0
- package/scripts/tools/detect-test-framework.sh +135 -0
- package/scripts/tools/diff-templates-vs-tracks.sh +176 -0
- package/scripts/tools/emit-skill-metrics.sh +71 -0
- package/scripts/tools/fix-whitespace.sh +192 -0
- package/scripts/tools/freshness-check.sh +143 -0
- package/scripts/tools/git-metadata.sh +203 -0
- package/scripts/tools/graph-callers.sh +74 -0
- package/scripts/tools/graph-impact.sh +93 -0
- package/scripts/tools/graph-snapshot.sh +102 -0
- package/scripts/tools/hotspot-rank.sh +75 -0
- package/scripts/tools/manage-symlinks.sh +85 -0
- package/scripts/tools/mermaid-from-graph.sh +92 -0
- package/scripts/tools/migrate-track-frontmatter.sh +241 -0
- package/scripts/tools/parse-git-log.sh +135 -0
- package/scripts/tools/parse-reports.sh +114 -0
- package/scripts/tools/render-track.sh +145 -0
- package/scripts/tools/run-coverage.sh +153 -0
- package/scripts/tools/scan-markers.sh +144 -0
- package/scripts/tools/skill-caps.conf +24 -0
- package/scripts/tools/validate-frontmatter.sh +125 -0
- package/scripts/tools/verify-citations.sh +250 -0
- package/scripts/tools/verify-doc-anchors.sh +204 -0
- package/scripts/tools/verify-graph-binary.sh +154 -0
- package/skills/GRAPH.md +332 -0
- package/skills/adr/SKILL.md +374 -0
- package/skills/assist-review/SKILL.md +49 -0
- package/skills/bughunt/SKILL.md +668 -0
- package/skills/bughunt/references/regression-tests.md +399 -0
- package/skills/change/SKILL.md +267 -0
- package/skills/coverage/SKILL.md +336 -0
- package/skills/debug/SKILL.md +201 -0
- package/skills/decompose/SKILL.md +656 -0
- package/skills/deep-review/SKILL.md +326 -0
- package/skills/deploy-checklist/SKILL.md +254 -0
- package/skills/discover/SKILL.md +66 -0
- package/skills/docs/SKILL.md +42 -0
- package/skills/documentation/SKILL.md +197 -0
- package/skills/draft/SKILL.md +177 -0
- package/skills/draft/context-files.md +57 -0
- package/skills/draft/intent-mapping.md +37 -0
- package/skills/draft/quality-guide.md +51 -0
- package/skills/graph/SKILL.md +107 -0
- package/skills/impact/SKILL.md +86 -0
- package/skills/implement/SKILL.md +794 -0
- package/skills/incident-response/SKILL.md +245 -0
- package/skills/index/SKILL.md +848 -0
- package/skills/init/SKILL.md +1784 -0
- package/skills/init/references/architecture-spec.md +1259 -0
- package/skills/integrations/SKILL.md +53 -0
- package/skills/jira/SKILL.md +577 -0
- package/skills/jira/references/review.md +1322 -0
- package/skills/learn/SKILL.md +478 -0
- package/skills/new-track/SKILL.md +841 -0
- package/skills/ops/SKILL.md +57 -0
- package/skills/plan/SKILL.md +60 -0
- package/skills/quick-review/SKILL.md +216 -0
- package/skills/revert/SKILL.md +178 -0
- package/skills/review/SKILL.md +1114 -0
- package/skills/standup/SKILL.md +183 -0
- package/skills/status/SKILL.md +183 -0
- package/skills/tech-debt/SKILL.md +318 -0
- package/skills/testing-strategy/SKILL.md +195 -0
- package/skills/tour/SKILL.md +38 -0
- package/skills/upload/SKILL.md +117 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# Jira Sync Protocol
|
|
2
|
+
|
|
3
|
+
Standard procedure for syncing Draft artifacts to Jira tickets via MCP. All skills that produce markdown artifacts follow this protocol to keep Jira updated.
|
|
4
|
+
|
|
5
|
+
Referenced by: `/draft:init`, `/draft:new-track`, `/draft:implement`, `/draft:review`, `/draft:quick-review`, `/draft:upload`, `/draft:bughunt`, `/draft:debug`, `/draft:incident-response`, `/draft:tech-debt`, `/draft:deploy-checklist`, `/draft:documentation`
|
|
6
|
+
|
|
7
|
+
## Prerequisites
|
|
8
|
+
|
|
9
|
+
1. **Jira MCP available:** Verify during context loading (see `core/shared/draft-context-loading.md`)
|
|
10
|
+
2. **Ticket key exists:** From track metadata, spec.md, workflow.md, or `$ARGUMENTS`
|
|
11
|
+
3. **Artifact exists:** The markdown file to sync must exist on disk
|
|
12
|
+
|
|
13
|
+
If any prerequisite is missing, skip sync silently. Do not fail the parent skill.
|
|
14
|
+
|
|
15
|
+
## MCP Operations
|
|
16
|
+
|
|
17
|
+
| Operation | Purpose | Usage |
|
|
18
|
+
|---|---|---|
|
|
19
|
+
| `add_comment(issue_key, body)` | Post concise summaries to Jira | Every sync trigger |
|
|
20
|
+
| `add_attachment(issue_key, file_path)` | Attach markdown artifacts | When artifact file exists |
|
|
21
|
+
| `update_issue(issue_key, fields)` | Update status, labels, fields | When status changes |
|
|
22
|
+
|
|
23
|
+
## Draft Signature
|
|
24
|
+
|
|
25
|
+
All Jira content written by Draft (comments and descriptions) MUST include a signature for traceability. This allows teams to track how Draft is being used across their Jira projects.
|
|
26
|
+
|
|
27
|
+
### Comment Signature
|
|
28
|
+
|
|
29
|
+
Append this signature block at the end of every Jira comment:
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
─────────────────────────────
|
|
33
|
+
🤖 Generated by Draft
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Description Signature
|
|
37
|
+
|
|
38
|
+
Append this signature line inside `{noformat}` blocks at the end of every Jira description:
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
---
|
|
42
|
+
🤖 Generated by Draft
|
|
43
|
+
Branch: [branch-name] | Commit: [short-hash]
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Draft Label
|
|
47
|
+
|
|
48
|
+
Every Jira issue that Draft creates or updates MUST have the label `draft`. This enables tracking and filtering of all Draft-touched issues.
|
|
49
|
+
|
|
50
|
+
### Label Procedure
|
|
51
|
+
|
|
52
|
+
On every sync operation, after posting the comment or attachment:
|
|
53
|
+
|
|
54
|
+
1. Fetch current labels: `get_issue(issue_key)` → extract `labels` field
|
|
55
|
+
2. If `"draft"` is NOT in the labels list:
|
|
56
|
+
- Call: `update_issue(issue_key, { "labels": [existing_labels..., "draft"] })`
|
|
57
|
+
- Log: "Added 'draft' label to {issue_key}"
|
|
58
|
+
3. If `"draft"` already present: skip (no-op)
|
|
59
|
+
|
|
60
|
+
**Important:** Preserve existing labels — append `draft`, never replace the labels array.
|
|
61
|
+
|
|
62
|
+
## Comment Format
|
|
63
|
+
|
|
64
|
+
All Jira comments from Draft follow this format for consistency and scannability:
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
[draft] {action}: {1-line summary}
|
|
68
|
+
─────────────────────────────
|
|
69
|
+
• {key detail 1}
|
|
70
|
+
• {key detail 2}
|
|
71
|
+
• {key detail 3}
|
|
72
|
+
|
|
73
|
+
Attachment: {filename} (if applicable)
|
|
74
|
+
|
|
75
|
+
─────────────────────────────
|
|
76
|
+
🤖 Generated by Draft
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Examples:
|
|
80
|
+
```
|
|
81
|
+
[draft] spec-complete: Specification and plan generated for track add-user-auth
|
|
82
|
+
─────────────────────────────
|
|
83
|
+
• 3 phases, 12 tasks planned
|
|
84
|
+
• Key risk: third-party OAuth provider latency
|
|
85
|
+
• Testing strategy: TDD with 90% coverage target
|
|
86
|
+
|
|
87
|
+
Attachments: spec.md, plan.md
|
|
88
|
+
|
|
89
|
+
─────────────────────────────
|
|
90
|
+
🤖 Generated by Draft
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
[draft] rca-complete: Root cause identified for login timeout
|
|
95
|
+
─────────────────────────────
|
|
96
|
+
• Root cause: connection pool exhaustion under concurrent load
|
|
97
|
+
• Classification: resource exhaustion
|
|
98
|
+
• Prevention: 4 items (2 detection, 1 code, 1 architecture)
|
|
99
|
+
|
|
100
|
+
Attachment: rca.md
|
|
101
|
+
|
|
102
|
+
─────────────────────────────
|
|
103
|
+
🤖 Generated by Draft
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Sync Triggers
|
|
107
|
+
|
|
108
|
+
| When | Artifact | Jira Actions |
|
|
109
|
+
|---|---|---|
|
|
110
|
+
| `/draft:new-track` completes | `spec.md`, `plan.md` | Attach both + comment: "Spec and plan generated" |
|
|
111
|
+
| Auto-triage completes | `rca.md` | Attach + comment: "RCA complete. Root cause: {summary}" |
|
|
112
|
+
| `/draft:review` completes | `review-report-latest.md` | Attach + comment: "Review {PASS/FAIL}. {n} findings" |
|
|
113
|
+
| `/draft:implement` completes | `plan.md` (updated) | Comment: "Implementation complete. {n} tasks done" |
|
|
114
|
+
| `/draft:bughunt` completes | `bughunt-report-latest.md` | Attach + comment: "Bughunt found {n} issues" |
|
|
115
|
+
| `/draft:upload` completes | — | Comment: "Code uploaded for review. {URL}" |
|
|
116
|
+
| `/draft:deploy-checklist` completes | `deploy-checklist.md` | Attach + comment: "Deploy checklist generated" |
|
|
117
|
+
| `/draft:incident-response` completes | `incident-*.md` | Attach + comment: "Incident report updated" |
|
|
118
|
+
|
|
119
|
+
## Sync Procedure
|
|
120
|
+
|
|
121
|
+
```
|
|
122
|
+
1. Verify Jira MCP is available (from context loading state)
|
|
123
|
+
- If unavailable: queue to .jira-sync-queue.json, return
|
|
124
|
+
|
|
125
|
+
2. Extract ticket key:
|
|
126
|
+
- From track metadata.json: $.jira_ticket
|
|
127
|
+
- From spec.md YAML frontmatter: $.jira_ticket
|
|
128
|
+
- From $ARGUMENTS: match pattern [A-Z]+-\d+
|
|
129
|
+
- If no ticket found: skip sync, return
|
|
130
|
+
|
|
131
|
+
3. Attach artifact (if file exists):
|
|
132
|
+
- Call: add_attachment(issue_key, file_path)
|
|
133
|
+
- Log: "Attached {filename} to {issue_key}"
|
|
134
|
+
|
|
135
|
+
4. Post comment:
|
|
136
|
+
- Format using comment template above (MUST include signature block)
|
|
137
|
+
- Call: add_comment(issue_key, formatted_comment)
|
|
138
|
+
- Log: "Posted sync comment to {issue_key}"
|
|
139
|
+
|
|
140
|
+
5. Ensure 'draft' label:
|
|
141
|
+
- Fetch current labels from issue
|
|
142
|
+
- If "draft" not in labels: append it via update_issue
|
|
143
|
+
- Log: "Ensured 'draft' label on {issue_key}"
|
|
144
|
+
|
|
145
|
+
6. Update fields (if applicable):
|
|
146
|
+
- Call: update_issue(issue_key, fields)
|
|
147
|
+
|
|
148
|
+
7. Record sync in track metadata:
|
|
149
|
+
- Add entry to $.jira_syncs array with timestamp and action
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Failure Handling
|
|
153
|
+
|
|
154
|
+
If MCP operation fails:
|
|
155
|
+
1. Do NOT fail the parent skill
|
|
156
|
+
2. Save pending sync to `draft/tracks/<id>/.jira-sync-queue.json`:
|
|
157
|
+
```json
|
|
158
|
+
{
|
|
159
|
+
"pending": [
|
|
160
|
+
{
|
|
161
|
+
"action": "add_attachment",
|
|
162
|
+
"issue_key": "PROJ-123",
|
|
163
|
+
"file_path": "draft/tracks/fix-login/rca.md",
|
|
164
|
+
"queued_at": "2026-03-15T14:30:00Z"
|
|
165
|
+
}
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
3. On next successful MCP connection, retry queued items
|
|
170
|
+
4. Warn user: "Jira sync queued (MCP unavailable). Will retry on next connection."
|
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
# Parallel Analysis Protocol
|
|
2
|
+
|
|
3
|
+
> Shared procedure for `draft:init`. Applies to tiers 3–5.
|
|
4
|
+
> Tiers 1–2 use the Sequential Generation Protocol directly — no parallelism needed, and the IR bottleneck hurts depth more than parallelism helps speed at small scale.
|
|
5
|
+
> Implements Map → IR+Prose → Reduce to cut wall clock by ~60% at XL tier while preserving deep per-module content.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Architecture
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
Phase 1 (Map) N parallel reader agents bounded scope per agent (4 modules each)
|
|
13
|
+
each agent reads source files in its assigned modules
|
|
14
|
+
each agent outputs (A) IR JSON array — structured metadata for tables/diagrams
|
|
15
|
+
(B) Markdown deep-dives — per-module prose (§7 sections)
|
|
16
|
+
|
|
17
|
+
Phase 2 (Reduce) 1 synthesis agent receives all IRs + all reader deep-dives
|
|
18
|
+
assembles architecture.md by composing reader prose (§7) + deriving cross-cutting
|
|
19
|
+
sections from IR; targeted source reads for §6, §14, §15, §18
|
|
20
|
+
context budget: ~20K tokens (reader prose replaces need to re-read source)
|
|
21
|
+
|
|
22
|
+
Phase 3 (Finalize) 2 parallel agents .ai-context.md + .ai-profile.md
|
|
23
|
+
state files (facts.json, freshness.json, etc.)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The **Intermediate Representation (IR)** carries structured metadata — edges, enums, hotspots.
|
|
27
|
+
The **Reader Deep-Dives** carry the prose that IR cannot express — mechanisms, rationale, operational detail.
|
|
28
|
+
Both outputs are produced by the same reader agent in one pass; no extra source reads needed.
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## IR Schema (language-agnostic)
|
|
33
|
+
|
|
34
|
+
Each reader agent outputs a JSON array of objects matching this schema — one object per assigned module:
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"module": "<module_name>",
|
|
39
|
+
"path": "<source_path_relative_to_repo_root>",
|
|
40
|
+
"role": "<1-sentence description of what this module does>",
|
|
41
|
+
"files_read": 12,
|
|
42
|
+
"token_budget_used": 420,
|
|
43
|
+
|
|
44
|
+
"key_classes": [
|
|
45
|
+
{
|
|
46
|
+
"name": "<ClassName or key type>",
|
|
47
|
+
"file": "<path>:<line>",
|
|
48
|
+
"pattern": "<facade|singleton|actor|factory|strategy|observer|coordinator>",
|
|
49
|
+
"public_methods": 14,
|
|
50
|
+
"state_protected_by": "<lock_name or null>"
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
|
|
54
|
+
"state": [
|
|
55
|
+
{
|
|
56
|
+
"field": "<field_name>",
|
|
57
|
+
"type": "<type>",
|
|
58
|
+
"lock": "<lock_name or null>",
|
|
59
|
+
"persistence": "<PostgreSQL|Redis|file|memory|none>"
|
|
60
|
+
}
|
|
61
|
+
],
|
|
62
|
+
|
|
63
|
+
"dependencies_out": ["<ModuleA>", "<ModuleB>"],
|
|
64
|
+
"dependencies_in": ["<CallerA>", "<CallerB>"],
|
|
65
|
+
|
|
66
|
+
"invariants": [
|
|
67
|
+
"<rule that must always hold>",
|
|
68
|
+
"<another invariant>"
|
|
69
|
+
],
|
|
70
|
+
|
|
71
|
+
"hotspots": ["<file>:<lines>L", "<file>:<lines>L"],
|
|
72
|
+
|
|
73
|
+
"extension_point": "<how to add new functionality to this module, or null>",
|
|
74
|
+
|
|
75
|
+
"state_machine": {
|
|
76
|
+
"states": ["STATE_A", "STATE_B"],
|
|
77
|
+
"transitions": [["STATE_A", "event", "STATE_B"]]
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
"error_handling": "<fail-closed|retry|propagate|circuit-breaker|ignore>",
|
|
81
|
+
|
|
82
|
+
"concurrency_model": "<single-threaded|async-await|mutex-lock|rwlock|actor-queue|goroutine-pool|thread-pool>"
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**Token budget per module in IR output: 400–600 tokens.**
|
|
87
|
+
A module with 0 interesting state/concurrency/invariants still needs a valid IR — just shorter.
|
|
88
|
+
|
|
89
|
+
**Reader deep-dive budget per module: minimum 1500 tokens, no upper limit.**
|
|
90
|
+
This prose is the §7 deep-dive section — it must reflect actual source file content.
|
|
91
|
+
Large modules with deep sub-module hierarchies (e.g., 500+ files with 5+ sub-modules) should produce 5000–10000+ tokens of prose covering ALL sub-modules at the same depth as top-level modules. The synthesis agent will paste this verbatim — do NOT abbreviate to save tokens.
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## Module Reader Prompt Template
|
|
96
|
+
|
|
97
|
+
Use this verbatim as the `prompt` field when spawning each reader agent via the `Agent` tool.
|
|
98
|
+
Replace `{MODULE_LIST}`, `{REPO_ROOT}`, and `{GRAPH_DATA_SUMMARY}` before sending.
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
You are a module reader agent. You have two jobs for each assigned module:
|
|
102
|
+
(A) Extract structured IR JSON — metadata for tables and diagrams
|
|
103
|
+
(B) Write a full §7 deep-dive section in Markdown — prose the synthesis agent will paste verbatim into architecture.md
|
|
104
|
+
|
|
105
|
+
ASSIGNED MODULES: {MODULE_LIST}
|
|
106
|
+
Repository root: {REPO_ROOT}
|
|
107
|
+
|
|
108
|
+
Graph context (use to prioritize which files to read):
|
|
109
|
+
{GRAPH_DATA_SUMMARY}
|
|
110
|
+
|
|
111
|
+
## Instructions
|
|
112
|
+
|
|
113
|
+
For each assigned module:
|
|
114
|
+
1. Read the module's directory structure (use Glob/LS)
|
|
115
|
+
2. Read the top-3 hotspot files (highest complexity from graph data above)
|
|
116
|
+
3. Read the interface/header or main entry file
|
|
117
|
+
4. For modules with 200+ files, read at least 5 source files total
|
|
118
|
+
5. Extract one IR JSON object matching the IR Schema below
|
|
119
|
+
6. Write one Markdown deep-dive section matching the Deep-Dive Template below
|
|
120
|
+
|
|
121
|
+
## IR Schema
|
|
122
|
+
|
|
123
|
+
Output a JSON array after the "## IR" heading. Each element is one module:
|
|
124
|
+
|
|
125
|
+
## IR
|
|
126
|
+
[
|
|
127
|
+
{
|
|
128
|
+
"module": "<name>",
|
|
129
|
+
"path": "<source_path>",
|
|
130
|
+
"role": "<1-sentence>",
|
|
131
|
+
"files_read": <N>,
|
|
132
|
+
"key_classes": [{"name":"","file":"","pattern":"","public_methods":0,"state_protected_by":null}],
|
|
133
|
+
"state": [{"field":"","type":"","lock":null,"persistence":"memory"}],
|
|
134
|
+
"dependencies_out": [],
|
|
135
|
+
"dependencies_in": [],
|
|
136
|
+
"invariants": ["<invariant>"],
|
|
137
|
+
"hotspots": ["<file>:<lines>L"],
|
|
138
|
+
"extension_point": null,
|
|
139
|
+
"state_machine": {"states":[],"transitions":[]},
|
|
140
|
+
"error_handling": "propagate",
|
|
141
|
+
"concurrency_model": "single-threaded"
|
|
142
|
+
}
|
|
143
|
+
]
|
|
144
|
+
|
|
145
|
+
## Deep-Dives
|
|
146
|
+
|
|
147
|
+
For each module, write a **graph-first, diagram-centric** Markdown section under the "## Deep-Dives" heading. The primary artifacts are the deterministic graph data and one synthesized workflow/state diagram. Prose is minimal supporting narrative.
|
|
148
|
+
|
|
149
|
+
#### 7.X {ModuleName}
|
|
150
|
+
|
|
151
|
+
**Role** (≤25 words, derived from graph role + primary source).
|
|
152
|
+
|
|
153
|
+
**Primary Workflow / State Diagram** (MANDATORY — highest value output)
|
|
154
|
+
One accurate Mermaid diagram (stateDiagram-v2, sequenceDiagram, or flowchart) that visualizes the dominant control flow, lifecycle, or data transformation for this module, using facts from the graph (entry points, public surface, call targets, hotspots). This diagram is more important than any other text in the section.
|
|
155
|
+
|
|
156
|
+
**Graph Summary** (from the module's graph record)
|
|
157
|
+
- Fan-in / Fan-out, hotspot files, key public symbols (only the architecturally significant ones).
|
|
158
|
+
|
|
159
|
+
**Design Notes** (≤60 words total)
|
|
160
|
+
Only observations from source that add understanding *not already visible* in the graph block or the workflow diagram (e.g., a subtle invariant, error boundary, or concurrency rule). Cite `path:line`.
|
|
161
|
+
|
|
162
|
+
**Sub-modules / Internal Boundaries**
|
|
163
|
+
Only when the graph shows clear internal structure with its own public surface or high internal fan-in. Each child follows the same pattern (graph facts + one workflow diagram + minimal notes).
|
|
164
|
+
|
|
165
|
+
**Anti-patterns for this output:**
|
|
166
|
+
- Do not start with "Source Files:" lists or exhaustive sub-directory tables.
|
|
167
|
+
- Do not emit long "Responsibilities (1. 2. 3.)" paragraphs when the graph + diagram already communicate the design.
|
|
168
|
+
- Short, precise synthesis + one excellent diagram is the goal. Volume is not a virtue.
|
|
169
|
+
|
|
170
|
+
Then, for EACH sub-module within this module:
|
|
171
|
+
|
|
172
|
+
##### 7.X.Y {ParentModule}/{SubModuleName} (if the graph shows a distinct boundary)
|
|
173
|
+
|
|
174
|
+
**Role**: One-line description.
|
|
175
|
+
|
|
176
|
+
**Graph Summary** (from the module's graph record)
|
|
177
|
+
- Fan-in / Fan-out, hotspot files, key public symbols (only the architecturally significant ones).
|
|
178
|
+
|
|
179
|
+
**Design Notes** (≤60 words total)
|
|
180
|
+
Only observations from source that add understanding *not already visible* in the graph block or the workflow diagram (e.g., a subtle invariant, error boundary, or concurrency rule). Cite `path:line`.
|
|
181
|
+
|
|
182
|
+
**Sub-modules / Internal Boundaries**
|
|
183
|
+
Only when the graph shows clear internal structure with its own public surface or high internal fan-in. Each child follows the same pattern (graph facts + one workflow diagram + minimal notes).
|
|
184
|
+
|
|
185
|
+
**Anti-patterns for sub-modules:**
|
|
186
|
+
- Do not produce long "Source Files + Responsibilities + 5+ operations" templates when the graph + one diagram suffice.
|
|
187
|
+
- Recurse only on boundaries the graph itself makes visible.
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## Constraints
|
|
192
|
+
|
|
193
|
+
- IR: max 600 tokens per module; null unknown fields; never omit keys.
|
|
194
|
+
- Deep-dive output per module is graph block + **one mandatory workflow/state diagram** + ≤60 words Design Notes. Volume is not the goal.
|
|
195
|
+
- The diagram must be grounded in the module's graph record (entry points, public surface, call targets).
|
|
196
|
+
- Sub-modules receive their own subsection **only** when the graph data shows a distinct public surface or high internal fan-in. No descent "because the module is large."
|
|
197
|
+
- Ops/handler directories that are primary extension points may receive a short numbered catalog (focus on high-signal operations; exhaustive enumeration of every internal helper is not required).
|
|
198
|
+
- Do NOT read files outside your assigned modules.
|
|
199
|
+
- If a field is unknown in IR, use null or empty array.
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## Synthesis Coordinator Prompt Template
|
|
205
|
+
|
|
206
|
+
Use this as the prompt for the single synthesis agent in Phase 2.
|
|
207
|
+
Replace `{CONCATENATED_IRS}`, `{GRAPH_DEPENDENCY_DIAGRAM}`, and `{ARCHITECTURE_TEMPLATE_STRUCTURE}`.
|
|
208
|
+
|
|
209
|
+
```
|
|
210
|
+
You are the synthesis agent. Your job is to assemble draft/architecture.md from reader outputs.
|
|
211
|
+
|
|
212
|
+
## Inputs
|
|
213
|
+
|
|
214
|
+
Reader deep-dive sections (Markdown prose, one §7.X block per module):
|
|
215
|
+
{CONCATENATED_DEEP_DIVES}
|
|
216
|
+
|
|
217
|
+
IR summaries for all modules (structured metadata):
|
|
218
|
+
{CONCATENATED_IRS}
|
|
219
|
+
|
|
220
|
+
Module dependency diagram (from graph binary):
|
|
221
|
+
{GRAPH_DEPENDENCY_DIAGRAM}
|
|
222
|
+
|
|
223
|
+
Architecture template structure to follow:
|
|
224
|
+
{ARCHITECTURE_TEMPLATE_STRUCTURE}
|
|
225
|
+
|
|
226
|
+
## Your Role
|
|
227
|
+
|
|
228
|
+
You are a composer, not an analyst. Readers already did the source analysis.
|
|
229
|
+
Your job:
|
|
230
|
+
1. Paste reader deep-dives verbatim into Section 7 — do not rewrite them, do not summarize them.
|
|
231
|
+
2. Derive cross-cutting sections from IR fields (edges, enums, invariants).
|
|
232
|
+
3. Read source directly for sections that require it (see policy below).
|
|
233
|
+
|
|
234
|
+
## CRITICAL: Template Compliance
|
|
235
|
+
|
|
236
|
+
Your output MUST follow the EXACT numbered section structure from {ARCHITECTURE_TEMPLATE_STRUCTURE}.
|
|
237
|
+
- Use the EXACT section numbers: ## 1. Executive Summary, ## 2. AI Agent Quick Reference, ## 3. System Identity & Purpose, ... through ## 28. Glossary, then Appendix A–E.
|
|
238
|
+
- Do NOT create custom/freeform sections. Do NOT rename sections. Do NOT skip section numbers.
|
|
239
|
+
- Do NOT collapse multiple template sections into one. Do NOT invent new section names.
|
|
240
|
+
- Every section from the template must appear in your output — if a section does not apply, write the heading and state "N/A — {reason}" beneath it.
|
|
241
|
+
- Sub-modules within Section 7 MUST get the SAME depth of analysis as top-level modules. A sub-module with 50+ files gets a full deep-dive (role, responsibilities, key ops table, state machine, mechanisms). There is no page limit — if the codebase has 14 modules each with 5 sub-modules, Section 7 alone may be 50+ pages. That is correct and expected.
|
|
242
|
+
|
|
243
|
+
## Source Reading Policy
|
|
244
|
+
|
|
245
|
+
Read source files for these sections — IR and reader prose are insufficient:
|
|
246
|
+
- §6 Core Operational Flows — read entry points, stateful services, dispatchers, and generation pipelines to synthesize accurate state/sequence diagrams (use full host indexed knowledge)
|
|
247
|
+
- §12 API Definitions — read route/handler files for endpoint enumeration
|
|
248
|
+
- §14 Integration Points — read adapter/client files for external dependency detail
|
|
249
|
+
- §15 Critical Invariants — verify invariants[] from IR against actual source assertions
|
|
250
|
+
- §18 Key Design Patterns — read 3–5 implementation files for concrete pattern examples
|
|
251
|
+
- §22 Configuration — read config/settings files for the configuration catalog
|
|
252
|
+
|
|
253
|
+
For all other sections (§1–5, §8–11, §13, §16–17, §19–21, §23–28, appendices):
|
|
254
|
+
derive from IR fields and reader deep-dives. Do not read source files for these.
|
|
255
|
+
|
|
256
|
+
## What to Derive from IR
|
|
257
|
+
|
|
258
|
+
- Component map (§4): use dependencies_out + dependencies_in edges across all IRs
|
|
259
|
+
- Concurrency model (§8): collect concurrency_model + state[].lock fields
|
|
260
|
+
- Extension points (§9): collect extension_point fields
|
|
261
|
+
- State machines (§10): collect state_machine fields across IRs
|
|
262
|
+
- Error handling patterns (§17): collect error_handling fields
|
|
263
|
+
- Hotspot catalog (§appendix): collect hotspots[] fields
|
|
264
|
+
|
|
265
|
+
## Output
|
|
266
|
+
|
|
267
|
+
Write the full `draft/architecture.md` following the **10-section graph-primary template** in `core/templates/architecture.md`.
|
|
268
|
+
Begin immediately with the YAML frontmatter, then the mandatory section headings. Do not explain your plan first.
|
|
269
|
+
|
|
270
|
+
MANDATORY output structure (in this exact order):
|
|
271
|
+
1. YAML frontmatter (`project`, `module`, `generated_by`, `generated_at`, graph fidelity block when available)
|
|
272
|
+
2. `# Architecture: {PROJECT_NAME}`
|
|
273
|
+
3. `## 1. Executive Summary + Graph Health Dashboard`
|
|
274
|
+
4. `## 2. Critical Invariants & Safety Rules (with provenance)`
|
|
275
|
+
5. `## 3. Primary Control & Data Flows (Graph + Synthesis)`
|
|
276
|
+
6. `## 4. Module & Dependency Map (Primarily Graph-Derived)`
|
|
277
|
+
7. `## 5. Concurrency, Ownership & Isolation Model`
|
|
278
|
+
8. `## 6. Error Handling & Failure Mode Catalog`
|
|
279
|
+
9. `## 7. State & Data Truth Sources + Reconciliation`
|
|
280
|
+
10. `## 8. Extension Points & Safe Mutation Patterns`
|
|
281
|
+
11. `## 9. Graph Coverage Gaps & Known Limitations (MANDATORY)`
|
|
282
|
+
12. `## 10. Relationship to Other Authoritative Documentation` (when Context Audit is high/medium)
|
|
283
|
+
|
|
284
|
+
Embed reader IR insights inside §3–§8 as graph-grounded diagrams and concise synthesis — not as a separate legacy Section 7 volume.
|
|
285
|
+
Do NOT produce freeform sections or resurrect 28-section numbering.
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## Tier-Adaptive Agent Counts
|
|
291
|
+
|
|
292
|
+
| Tier | Label | Reader Agents |
|
|
293
|
+
|------|--------|--------------------------------|
|
|
294
|
+
| 1 | micro | 1 (all modules) |
|
|
295
|
+
| 2 | small | 1–2 |
|
|
296
|
+
| 3 | medium | ceil(M/6) |
|
|
297
|
+
| 4 | large | ceil(M/4) |
|
|
298
|
+
| 5 | XL | ceil(M/4) |
|
|
299
|
+
|
|
300
|
+
For tier 1–2, skip parallelism — one reader agent handles all modules sequentially.
|
|
301
|
+
|
|
302
|
+
---
|
|
303
|
+
|
|
304
|
+
## Dependency-Aware Module Grouping
|
|
305
|
+
|
|
306
|
+
When assigning modules to reader agents (tier 3+), apply this priority ordering:
|
|
307
|
+
|
|
308
|
+
```
|
|
309
|
+
Rule 1: Assign high fan-in modules to separate readers
|
|
310
|
+
(modules with many callers produce IRs that many other IRs reference)
|
|
311
|
+
|
|
312
|
+
Rule 2: Co-locate modules with shared dependencies in the same reader
|
|
313
|
+
(reader already has context about the dependency → richer IR)
|
|
314
|
+
|
|
315
|
+
Rule 3: Separate state-heavy modules from stateless utilities
|
|
316
|
+
(state-heavy modules produce larger IRs; balance reader token budgets)
|
|
317
|
+
|
|
318
|
+
Rule 4: Use tier table above for modules-per-agent target
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
Example grouping heuristic (adapt to actual fan-in data from graph):
|
|
322
|
+
```
|
|
323
|
+
reader_A: [highest fan-in module alone] — never share high-fan-in with others
|
|
324
|
+
reader_B: [coupled pair: module_X + module_Y] — modules that call each other
|
|
325
|
+
reader_C: [data layer modules] — shared persistence/cache modules together
|
|
326
|
+
reader_D: [consumer/feature modules] — modules that call many others
|
|
327
|
+
reader_E: [infra/bootstrap modules] — low fan-in, foundational
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
---
|
|
331
|
+
|
|
332
|
+
## Failure Modes and Recovery
|
|
333
|
+
|
|
334
|
+
### Reader produces prose instead of IR
|
|
335
|
+
**Detection:** Output doesn't start with `[` or fails JSON.parse.
|
|
336
|
+
**Recovery:** Retry that reader with stricter constraint:
|
|
337
|
+
```
|
|
338
|
+
RETRY INSTRUCTION: Your previous output was not valid JSON. Output ONLY the JSON array.
|
|
339
|
+
The first character of your response MUST be `[`. No preamble. No explanation.
|
|
340
|
+
```
|
|
341
|
+
**Fallback:** If retry fails, run those modules through the standard sequential analysis.
|
|
342
|
+
|
|
343
|
+
### IR is too sparse AND deep-dive is too short
|
|
344
|
+
**Detection:** IR `token_budget_used < 150` for a module with >20 files AND deep-dive < 100 lines.
|
|
345
|
+
**Recovery:** Re-run that reader with explicit instruction to read more source files and expand the deep-dive.
|
|
346
|
+
If only the IR is sparse but the deep-dive is substantive, no action needed — prose is the primary output.
|
|
347
|
+
|
|
348
|
+
### Synthesis agent re-reads source outside policy
|
|
349
|
+
**Detection:** Tool calls to Read for files not in the permitted-sections list during synthesis.
|
|
350
|
+
**Prevention:** The synthesis prompt lists exactly which sections permit source reads. Outside those, synthesis derives from reader prose and IR.
|
|
351
|
+
|
|
352
|
+
### One reader agent fails entirely
|
|
353
|
+
**Detection:** Agent returns error or times out.
|
|
354
|
+
**Recovery:** Run the failed module group through standard sequential analysis.
|
|
355
|
+
The other readers' IRs are still valid — only the failed group needs re-work.
|
|
356
|
+
This is the blast-radius advantage over single-agent: a reader failure is a partial retry.
|
|
357
|
+
|
|
358
|
+
---
|
|
359
|
+
|
|
360
|
+
## Token Budget Model
|
|
361
|
+
|
|
362
|
+
```
|
|
363
|
+
Phase 1 readers (parallel, ceil(M/4) agents):
|
|
364
|
+
Per agent: 4 modules × ~4K source tokens = ~16K input
|
|
365
|
+
IR output: ~2K tokens/agent
|
|
366
|
+
Deep-dive output: ~8K tokens/agent (4 modules × ~2K prose each)
|
|
367
|
+
Total per agent: ~26K
|
|
368
|
+
|
|
369
|
+
Total Phase 1: ceil(M/4) agents × 26K (parallel — wall clock = slowest reader)
|
|
370
|
+
|
|
371
|
+
Phase 2 synthesis:
|
|
372
|
+
Input: N modules × ~450 IR tokens + N modules × ~2K prose tokens + 4K instructions
|
|
373
|
+
≈ 20K context at XL tier (vs 60K+ for raw source re-reads)
|
|
374
|
+
Output: §7 paste (from readers) + cross-cutting sections ≈ 30K output tokens
|
|
375
|
+
Total: ~50K tokens
|
|
376
|
+
|
|
377
|
+
Phase 3 finalizers (parallel, 2 agents):
|
|
378
|
+
~20K tokens total
|
|
379
|
+
|
|
380
|
+
vs single-agent baseline:
|
|
381
|
+
~350K source read tokens + ~34K generation = ~384K total
|
|
382
|
+
~50 min wall clock
|
|
383
|
+
|
|
384
|
+
Savings at XL tier: ~50% fewer tokens, ~55% faster wall clock
|
|
385
|
+
Depth vs single-agent: equivalent (readers read the same source; synthesis composes from prose)
|
|
386
|
+
```
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
---
|
|
2
|
+
shared: parallel-fanout
|
|
3
|
+
applies_to: quality + init + graph skills
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# parallel-fanout (Foundations Stub)
|
|
7
|
+
|
|
8
|
+
Portable generalized stub per manifest §2.1. Full content will be expanded in later agent tranche or manual follow-up.
|
|
9
|
+
|
|
10
|
+
See verification-gates.md and template-hygiene.md for usage contracts.
|