@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,270 @@
|
|
|
1
|
+
---
|
|
2
|
+
project: "{PROJECT_NAME}"
|
|
3
|
+
module: "root"
|
|
4
|
+
generated_by: "draft:init"
|
|
5
|
+
generated_at: "{ISO_TIMESTAMP}"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# {PROJECT_NAME} Context Map
|
|
9
|
+
|
|
10
|
+
> Self-contained AI context. Budget: {TIER_MIN}–{TIER_MAX} lines (tier {N}: {LABEL}).
|
|
11
|
+
> Graph metrics: M={modules} F={functions} P={proto_rpcs} E={include_edges}
|
|
12
|
+
> Primary value: faithful structural graph + **core operational models** (workflows, lifecycles, state machines) derived from architecture.md §3 (Primary Control & Data Flows).
|
|
13
|
+
> This file must stand alone — no references to architecture.md or source files needed.
|
|
14
|
+
|
|
15
|
+
| Field | Value |
|
|
16
|
+
|-------|-------|
|
|
17
|
+
| **Branch** | `{LOCAL_BRANCH}` → `{REMOTE/BRANCH}` |
|
|
18
|
+
| **Commit** | `{SHORT_SHA}` — {COMMIT_MESSAGE} |
|
|
19
|
+
| **Generated** | {ISO_TIMESTAMP} |
|
|
20
|
+
| **Synced To** | `{FULL_SHA}` |
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Architecture
|
|
25
|
+
|
|
26
|
+
- **Type**: {type} <!-- e.g., gRPC Microservice, CLI tool, library, REST API -->
|
|
27
|
+
- **Language**: {language} <!-- e.g., TypeScript 5.3, Python 3.12, Go 1.21 -->
|
|
28
|
+
- **Pattern**: {pattern} <!-- e.g., Hexagonal, MVC, Pipeline, Event-driven -->
|
|
29
|
+
- **Build**: `{build_command}`
|
|
30
|
+
- **Test**: `{test_command}`
|
|
31
|
+
- **Entry**: `{entry_file}` → `{entry_function}`
|
|
32
|
+
- **Config**: {config_mechanism} <!-- e.g., .env + config.ts, gflags, Viper -->
|
|
33
|
+
- **Generational**: {generational} <!-- V1/V2 split or "single generation" -->
|
|
34
|
+
|
|
35
|
+
## Component Graph
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
{project_root}/
|
|
39
|
+
├── {module1}/ ← {5-10 word description}
|
|
40
|
+
│ ├── {submod1}/ ← {description} ({Ncc} cc, {Nh} h)
|
|
41
|
+
│ │ └── ops/ ← {description} ({N} operations)
|
|
42
|
+
│ ├── {submod2}/ ← {description}
|
|
43
|
+
│ └── {shared}/ ← {description}
|
|
44
|
+
├── {module2}/ ← {description}
|
|
45
|
+
│ ├── {submod}/ ← {description}
|
|
46
|
+
│ └── {submod}/ ← {description}
|
|
47
|
+
└── {module3}/ ← {description}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
> Include immediate sub-directories for all major modules (not just top-level).
|
|
51
|
+
> Use graph data (`draft/graph/modules/*.jsonl`) for exhaustive sub-module enumeration.
|
|
52
|
+
> Show file counts per sub-module to indicate relative size/importance.
|
|
53
|
+
|
|
54
|
+
## GRAPH:MODULES
|
|
55
|
+
|
|
56
|
+
{module}|{sizeKB}KB|go:{N},proto:{N} → {dep1},{dep2}
|
|
57
|
+
...
|
|
58
|
+
|
|
59
|
+
> One row per module ordered by sizeKB descending. Omit for tier-1 codebases (≤5 modules) where Component Graph is sufficient.
|
|
60
|
+
|
|
61
|
+
## GRAPH:HOTSPOTS
|
|
62
|
+
|
|
63
|
+
{file_path}|{lines}L|fanIn:{N}
|
|
64
|
+
...
|
|
65
|
+
|
|
66
|
+
> Top 10 files by score (lines + fanIn×50). Always include all tiers.
|
|
67
|
+
|
|
68
|
+
## GRAPH:CYCLES
|
|
69
|
+
|
|
70
|
+
None ✓
|
|
71
|
+
|
|
72
|
+
> Or: list cycle paths e.g. "auth → storage → auth". Always include — absence is signal.
|
|
73
|
+
|
|
74
|
+
## GRAPH:MODULE-HOTSPOTS
|
|
75
|
+
|
|
76
|
+
{module}: {file}|{lines}L|fanIn:{N}
|
|
77
|
+
{file}|{lines}L|fanIn:{N}
|
|
78
|
+
{file}|{lines}L|fanIn:{N}
|
|
79
|
+
|
|
80
|
+
> Top 3 hotspot files per module by score (lines + fanIn×50). Tier ≥ 3 only. Omit for tier 1–2.
|
|
81
|
+
> Tells agents which files in a specific module carry the most change risk.
|
|
82
|
+
|
|
83
|
+
## GRAPH:FAN-IN
|
|
84
|
+
|
|
85
|
+
{module}|fanIn:{N}|callers:{caller1},{caller2}
|
|
86
|
+
|
|
87
|
+
> Modules ordered by incoming dependency count descending. Tier ≥ 3 only.
|
|
88
|
+
> High fanIn = high change risk — modifications propagate to many callers.
|
|
89
|
+
|
|
90
|
+
## GRAPH:PROTO-MAP
|
|
91
|
+
|
|
92
|
+
{ServiceName}: {rpc}({RequestType}) → {ResponseType} @{file}
|
|
93
|
+
|
|
94
|
+
> One line per RPC, grouped by service. Present only when proto_rpcs > 0. Omit entirely for non-proto codebases.
|
|
95
|
+
|
|
96
|
+
## GRAPH:OPERATIONAL (Core Behavioral Models)
|
|
97
|
+
|
|
98
|
+
**Primary Operational Models** (from architecture.md §3 — highest fidelity requirement):
|
|
99
|
+
|
|
100
|
+
- **{Flow/Lifecycle Name 1}** (e.g. Request Lifecycle, Init Pipeline, Job Pipeline):
|
|
101
|
+
State1 --(event/func)--> State2 --(error path)--> ErrorState --> Recovery
|
|
102
|
+
(include key decision points, alt paths, and error recovery)
|
|
103
|
+
|
|
104
|
+
- **{Flow/Lifecycle Name 2}**:
|
|
105
|
+
...
|
|
106
|
+
|
|
107
|
+
> For typical apps: main request flow + background processing + startup.
|
|
108
|
+
> For plugin / meta-tooling platforms: init with graph gate, skill/agent dispatch + frontmatter enforcement, condensation, parallel analysis, etc.
|
|
109
|
+
> Represent complex sequence/state diagrams in compact structured text. Preserve error paths and critical transitions.
|
|
110
|
+
|
|
111
|
+
## Dependency Injection / Wiring
|
|
112
|
+
|
|
113
|
+
{One paragraph or bullets explaining how components find each other.}
|
|
114
|
+
|
|
115
|
+
Key injection points:
|
|
116
|
+
- `{token1}`: {what it provides}
|
|
117
|
+
- `{token2}`: {what it provides}
|
|
118
|
+
- `{token3}`: {what it provides}
|
|
119
|
+
|
|
120
|
+
## Critical Invariants (DO NOT BREAK)
|
|
121
|
+
|
|
122
|
+
- [Data] **{name}**: {one-sentence rule} — enforced at `{file}:{line}`
|
|
123
|
+
- [Security] **{name}**: {rule} — enforced at `{file}:{line}`
|
|
124
|
+
- [Concurrency] **{name}**: {rule} — enforced at `{file}:{line}`
|
|
125
|
+
- [Ordering] **{name}**: {rule} — enforced at `{file}:{line}`
|
|
126
|
+
- [Idempotency] **{name}**: {rule} — enforced at `{file}:{line}`
|
|
127
|
+
- [Compatibility] **{name}**: {rule} — enforced at `{file}:{line}`
|
|
128
|
+
|
|
129
|
+
## Interface Contracts (TypeScript-like IDL)
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
// Primary extension interface
|
|
133
|
+
interface {InterfaceName} {
|
|
134
|
+
{method}({param}: {Type}): {ReturnType}; // {brief description}
|
|
135
|
+
{optionalMethod}?({param}: {Type}): {ReturnType};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Service contract
|
|
139
|
+
interface {ServiceName} {
|
|
140
|
+
{rpcMethod}(req: {RequestType}): Promise<{ResponseType}>;
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Dependency Graph
|
|
145
|
+
|
|
146
|
+
```
|
|
147
|
+
[{Component}] -> (HTTP) -> [{ExternalService}]
|
|
148
|
+
[{Component}] -> (SQL) -> [{Database}]
|
|
149
|
+
[{Component}] -> (gRPC) -> [{PeerService}]
|
|
150
|
+
[{Component}] -> (queue) -> [{MessageBroker}]
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Key Data Sources
|
|
154
|
+
|
|
155
|
+
| Source | Type | Readers |
|
|
156
|
+
|--------|------|---------|
|
|
157
|
+
| `{table/topic/endpoint}` | {DB/Queue/API} | `{component1}`, `{component2}` |
|
|
158
|
+
|
|
159
|
+
## Data Flow Summary (tied to Operational Models above)
|
|
160
|
+
|
|
161
|
+
**{FlowName}** (from GRAPH:OPERATIONAL): {concise description of one primary model, including main error/recovery path}.
|
|
162
|
+
|
|
163
|
+
**{FlowName2}**: ...
|
|
164
|
+
|
|
165
|
+
> This section should be a lightweight textual summary of the key models already detailed in GRAPH:OPERATIONAL. Do not duplicate — complement it.
|
|
166
|
+
|
|
167
|
+
## Error Handling & Failure Recovery
|
|
168
|
+
|
|
169
|
+
- **{Scenario}**: {Recovery mechanism} — {where handled}
|
|
170
|
+
- **{Scenario}**: {Recovery mechanism} — {where handled}
|
|
171
|
+
- **Retries**: {policy description}
|
|
172
|
+
- **Circuit breaker**: {if applicable}
|
|
173
|
+
- **Graceful degradation**: {behavior when dependencies unavailable}
|
|
174
|
+
|
|
175
|
+
## Concurrency Safety Rules
|
|
176
|
+
|
|
177
|
+
- **{ComponentName}**: {rule} — violating causes {consequence}
|
|
178
|
+
- **{ComponentName}**: {rule} — violating causes {consequence}
|
|
179
|
+
- **Lock ordering**: {if applicable}
|
|
180
|
+
- **Thread affinity**: {which components are single-threaded}
|
|
181
|
+
|
|
182
|
+
## Implementation Catalog
|
|
183
|
+
|
|
184
|
+
### {Category1}
|
|
185
|
+
|
|
186
|
+
| Name | Type | Description |
|
|
187
|
+
|------|------|-------------|
|
|
188
|
+
| `{impl1}` | `{Class}` | {brief description} |
|
|
189
|
+
| `{impl2}` | `{Class}` | {brief description} |
|
|
190
|
+
|
|
191
|
+
### {Category2}
|
|
192
|
+
|
|
193
|
+
| Name | Type | Description |
|
|
194
|
+
|------|------|-------------|
|
|
195
|
+
| `{impl3}` | `{Class}` | {brief description} |
|
|
196
|
+
|
|
197
|
+
## V1 ↔ V2 Migration Status
|
|
198
|
+
|
|
199
|
+
> Skip if no generational split.
|
|
200
|
+
|
|
201
|
+
| V1 | V2 | Status |
|
|
202
|
+
|----|----|----|
|
|
203
|
+
| `{v1_impl}` | `{v2_impl}` | {Migrated/Pending/Deprecated} |
|
|
204
|
+
|
|
205
|
+
**Rule**: When adding new {X}, prefer {V1/V2} because {reason}.
|
|
206
|
+
|
|
207
|
+
## Thread Pools / Execution Model
|
|
208
|
+
|
|
209
|
+
| Pool | Count | Purpose |
|
|
210
|
+
|------|-------|---------|
|
|
211
|
+
| `{pool_name}` | {N} | {what runs on it} |
|
|
212
|
+
|
|
213
|
+
> For single-threaded: "Single-threaded event loop — N/A"
|
|
214
|
+
|
|
215
|
+
## Key Configuration
|
|
216
|
+
|
|
217
|
+
| Flag/Param | Default | Critical? | Purpose |
|
|
218
|
+
|------------|---------|-----------|---------|
|
|
219
|
+
| `{FLAG_NAME}` | `{value}` | Yes | {description} |
|
|
220
|
+
| `{flag_name}` | `{value}` | No | {description} |
|
|
221
|
+
|
|
222
|
+
## Extension Points — Step-by-Step Cookbooks
|
|
223
|
+
|
|
224
|
+
### Adding a New {ExtensionType}
|
|
225
|
+
|
|
226
|
+
1. Create `{path/to/new_file.ext}` (naming: `{convention}`)
|
|
227
|
+
2. Implement interface:
|
|
228
|
+
- Required: `{method1}()`, `{method2}()`
|
|
229
|
+
- Optional: `{method3}?()`
|
|
230
|
+
3. Register at `{registry_file}:{line}` via `{mechanism}`
|
|
231
|
+
4. Add to build: `{build_dep_instruction}`
|
|
232
|
+
5. Test: create `{test_path}` covering {scenarios}
|
|
233
|
+
|
|
234
|
+
### Adding a New {ExtensionType2}
|
|
235
|
+
|
|
236
|
+
1. {step}
|
|
237
|
+
2. {step}
|
|
238
|
+
3. {step}
|
|
239
|
+
|
|
240
|
+
## Testing Strategy
|
|
241
|
+
|
|
242
|
+
- **Unit**: `{exact_test_command}`
|
|
243
|
+
- **Integration**: `{framework}` in `{location}`
|
|
244
|
+
- **E2E**: `{command}` (if applicable)
|
|
245
|
+
- **Key hooks**: `{injection_point}`, `{mock_pattern}`, `{test_utility}`
|
|
246
|
+
|
|
247
|
+
## File Layout Quick Reference
|
|
248
|
+
|
|
249
|
+
- Entry: `{path}`
|
|
250
|
+
- Config: `{path}`
|
|
251
|
+
- Routes/Handlers: `{path}`
|
|
252
|
+
- Services: `{path}`
|
|
253
|
+
- Repositories: `{path}`
|
|
254
|
+
- Models: `{path}`
|
|
255
|
+
- Tests: `{path}`
|
|
256
|
+
- Build: `{path}`
|
|
257
|
+
|
|
258
|
+
## Glossary (Critical Terms Only)
|
|
259
|
+
|
|
260
|
+
| Term | Definition |
|
|
261
|
+
|------|------------|
|
|
262
|
+
| {term} | {one-sentence definition} |
|
|
263
|
+
| {term} | {one-sentence definition} |
|
|
264
|
+
|
|
265
|
+
## Draft Integration
|
|
266
|
+
|
|
267
|
+
- See `draft/tech-stack.md` for accepted patterns and technology decisions
|
|
268
|
+
- See `draft/workflow.md` for TDD preferences and commit conventions
|
|
269
|
+
- See `draft/guardrails.md` for hard guardrails, learned conventions, and learned anti-patterns
|
|
270
|
+
- See `draft/product.md` for product context and guidelines
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
project: "{PROJECT_NAME}"
|
|
3
|
+
module: "{MODULE_NAME or 'root'}"
|
|
4
|
+
generated_by: "draft:{COMMAND_NAME}"
|
|
5
|
+
generated_at: "{ISO_TIMESTAMP}"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# {PROJECT_NAME} Profile
|
|
9
|
+
|
|
10
|
+
## Project
|
|
11
|
+
- Name: {PROJECT_NAME}
|
|
12
|
+
- One-liner: {ONE_LINE_PRODUCT_DESCRIPTION}
|
|
13
|
+
- Primary users: {USER_TYPES}
|
|
14
|
+
- Repository layout: {monorepo|polyrepo|single-service}
|
|
15
|
+
|
|
16
|
+
## Stack
|
|
17
|
+
- Language: {LANGUAGE}
|
|
18
|
+
- Framework: {FRAMEWORK}
|
|
19
|
+
- Database: {DATABASE}
|
|
20
|
+
- Auth: {AUTH_METHOD}
|
|
21
|
+
- API: {API_STYLE}
|
|
22
|
+
- Testing: {TEST_FRAMEWORK}
|
|
23
|
+
- Deploy: {DEPLOY_TARGET}
|
|
24
|
+
- Build: {BUILD_COMMAND}
|
|
25
|
+
- Entry: {ENTRY_POINT}
|
|
26
|
+
|
|
27
|
+
## INVARIANTS
|
|
28
|
+
{Top 3-5 critical invariants from .ai-context.md, one per line, with file:line refs}
|
|
29
|
+
|
|
30
|
+
## NEVER
|
|
31
|
+
{2-3 safety rules — things that must never happen}
|
|
32
|
+
|
|
33
|
+
## Key Operational Models (from §6 / GRAPH:OPERATIONAL)
|
|
34
|
+
- {Most critical flow 1 — one line}
|
|
35
|
+
- {Most critical flow 2 (if space allows)}
|
|
36
|
+
|
|
37
|
+
## Active Tracks
|
|
38
|
+
{List of active track IDs and one-line descriptions, or "none"}
|
|
39
|
+
|
|
40
|
+
## Recent Changes
|
|
41
|
+
{Last 3-5 significant commits or changes, one per line}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
---
|
|
2
|
+
project: "{PROJECT_NAME}"
|
|
3
|
+
module: "root"
|
|
4
|
+
generated_by: "draft:init"
|
|
5
|
+
generated_at: "{ISO_TIMESTAMP}"
|
|
6
|
+
|
|
7
|
+
# Ownership — enterprise accountability.
|
|
8
|
+
ownership:
|
|
9
|
+
codeowners_file: "{path-to-CODEOWNERS or 'none'}"
|
|
10
|
+
primary_owners: ["{team-or-person}"]
|
|
11
|
+
security_contact: "{email-or-channel-or-'N/A'}"
|
|
12
|
+
oncall: "{pagerduty/opsgenie URL or 'none'}"
|
|
13
|
+
|
|
14
|
+
# Verification — stamped by draft:init at render time.
|
|
15
|
+
verification:
|
|
16
|
+
citations_verified: "{true | false | unchecked}"
|
|
17
|
+
staleness_hash: "{sha256 of tracked source set at synced_to_commit}"
|
|
18
|
+
graph_schema_version: "{semver or 'absent'}"
|
|
19
|
+
|
|
20
|
+
# Graph fidelity (mandatory, forward-looking)
|
|
21
|
+
graph:
|
|
22
|
+
build_status: "{success | failed | absent}"
|
|
23
|
+
overall_fidelity: "{high | mixed | low | stub}"
|
|
24
|
+
language_fidelity:
|
|
25
|
+
python: "{stub (directory-level only) | approximate | high}"
|
|
26
|
+
typescript: "{stub | approximate | high}"
|
|
27
|
+
rust: "{approximate | high}"
|
|
28
|
+
cpp: "{high}"
|
|
29
|
+
go: "{approximate | high}"
|
|
30
|
+
stats:
|
|
31
|
+
modules: "{N from schema.yaml}"
|
|
32
|
+
edges: "{total_edges from architecture.json}"
|
|
33
|
+
hotspots: "{N}"
|
|
34
|
+
notes: "{explicit fidelity summary from architecture.json languages/packages}"
|
|
35
|
+
generation_notes: "{High existing context detected via audit — see §10 Relationship for deference | Standard graph-primary generation}"
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
# Architecture: {PROJECT_NAME}
|
|
39
|
+
|
|
40
|
+
> Graph-primary, high-signal engineering reference for AI coding assistants and humans.
|
|
41
|
+
> For the token-optimized machine version, see `draft/.ai-context.md`.
|
|
42
|
+
> The knowledge graph is the deterministic structural spine. LLM synthesis exists only to interpret dynamic behavior, state machines, and rationale not visible in the static graph. Fidelity is declared explicitly. Provenance is mandatory on all claims.
|
|
43
|
+
|
|
44
|
+
**Graph Health & Fidelity Dashboard** (populated at generation time from the `graph:` block; future agents must read this first):
|
|
45
|
+
|
|
46
|
+
| Language/Area | Fidelity | Modules | Edges | Hotspots | Notes |
|
|
47
|
+
|---------------|----------|---------|-------|----------|-------|
|
|
48
|
+
| Python | {stub} | {N} | {N} | {N} | {e.g. directory-level only} |
|
|
49
|
+
| Rust | {high} | {N} | {N} | {N} | {graph-derived} |
|
|
50
|
+
| ... | ... | ... | ... | ... | ... |
|
|
51
|
+
|
|
52
|
+
> Low-fidelity areas are explicitly called out in §9. This document never pretends richer graph data than actually exists.
|
|
53
|
+
|
|
54
|
+
## Generation Contract (read first — binding)
|
|
55
|
+
|
|
56
|
+
1. **Graph is structural truth.** Module boundaries, dependencies, public surfaces, hotspots, and call relationships come from `draft/graph/`. LLM never invents them.
|
|
57
|
+
2. **Fidelity declaration is non-negotiable.** Every major claim carries an explicit tag: `[Graph:High]`, `[Graph:Stub]`, `[Existing:CLAUDE.md §3]`, `[Human:Synthesis]`, or `[Test-backed:INV-042]`.
|
|
58
|
+
3. **Provenance on all claims.** Invariants, failure modes, lock ordering, and data truth sources must name their source and enforcement.
|
|
59
|
+
4. **Diagrams > prose.** One accurate Mermaid workflow/state/sequence diagram grounded in the graph is worth more than paragraphs of generic description.
|
|
60
|
+
5. **No duplication of excellent existing agent docs.** When the Context Audit detects CLAUDE.md / INVARIANTS.md / ADRs, this document defers and cross-references. It supplies the graph spine and synthesis, not a parallel prose copy.
|
|
61
|
+
6. **Honest gaps.** §9 is mandatory and high-value. Future agents must be able to read the fidelity table + gaps section and know exactly where to distrust the model.
|
|
62
|
+
7. **Accuracy over volume.** Short, precise, graph-anchored sections are correct. Historical line-count or diagram-count targets are retired.
|
|
63
|
+
|
|
64
|
+
Absence is signal. If a section does not apply, state the precise reason referencing graph data or classification.
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## 1. Executive Summary + Graph Health Dashboard
|
|
69
|
+
|
|
70
|
+
One tight paragraph: what the system is, what it does, its role in the larger environment.
|
|
71
|
+
|
|
72
|
+
The Graph Health & Fidelity Dashboard (above) is the first artifact any reader or agent must internalize.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## 2. Critical Invariants & Safety Rules (Highest Priority)
|
|
77
|
+
|
|
78
|
+
The longest and most precise section.
|
|
79
|
+
|
|
80
|
+
Every invariant must include:
|
|
81
|
+
- Precise statement
|
|
82
|
+
- Why violation is dangerous
|
|
83
|
+
- Enforcement mechanism (test, runtime, type system, review, graph constraint, or none)
|
|
84
|
+
- Provenance / Fidelity tag + source (e.g. `docs/INVARIANTS.md:INV-003`, `Graph:High`, `Human Judgment`)
|
|
85
|
+
|
|
86
|
+
Example format:
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
### INV-003: Sentinel Lock Ordering
|
|
90
|
+
**Rule**: `_strategies_lock < _strategy_process_locks < _global_capacity_lock < entry_lock`
|
|
91
|
+
**Fidelity**: High (enforced in code + tests)
|
|
92
|
+
**Graph Evidence**: Not expressible in static graph (dynamic ordering)
|
|
93
|
+
**Source**: docs/INVARIANTS.md + src/.../sentinel/...
|
|
94
|
+
**Enforcement**: test + code review
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## 3. Primary Control & Data Flows (Graph + Synthesis)
|
|
100
|
+
|
|
101
|
+
Focus on the highest-value dynamic behavior:
|
|
102
|
+
|
|
103
|
+
- Dominant request / data / control flows (end-to-end)
|
|
104
|
+
- State machines with financial or safety impact
|
|
105
|
+
- Lifecycle sequences (bootstrap, shutdown, reconciliation, failover)
|
|
106
|
+
|
|
107
|
+
Each backed by:
|
|
108
|
+
- Graph-derived paths where available
|
|
109
|
+
- High-quality Mermaid (stateDiagram-v2, sequenceDiagram, or detailed flowchart)
|
|
110
|
+
- Explicit note when the flow is only partially visible in the graph
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## 4. Module & Dependency Map (Primarily Graph-Derived)
|
|
115
|
+
|
|
116
|
+
- Module dependency graph rendered from `draft/graph/architecture.json` (`.packages`) + `module-deps.mermaid`
|
|
117
|
+
- High fan-in / fan-out modules highlighted
|
|
118
|
+
- Cyclic dependencies called out
|
|
119
|
+
- Cross-language boundaries (FFI, RPC, shared memory) explicitly surfaced with coverage notes
|
|
120
|
+
|
|
121
|
+
Include a short "graph coverage for this view" paragraph.
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## 5. Concurrency, Ownership & Isolation Model
|
|
126
|
+
|
|
127
|
+
- Single-writer patterns and ownership boundaries
|
|
128
|
+
- Lock ordering (explicitly tagged when not graph-expressible)
|
|
129
|
+
- Async / thread-pool / actor boundaries
|
|
130
|
+
- Failure isolation regions
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## 6. Error Handling & Failure Mode Catalog
|
|
135
|
+
|
|
136
|
+
For every major component or flow:
|
|
137
|
+
- What can go wrong
|
|
138
|
+
- How it is detected
|
|
139
|
+
- The defined safe response
|
|
140
|
+
- Whether enforcement is graph, test, runtime, or process
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## 7. State & Data Truth Sources + Reconciliation
|
|
145
|
+
|
|
146
|
+
For each major domain:
|
|
147
|
+
- Authoritative source
|
|
148
|
+
- Derived / cached views
|
|
149
|
+
- Reconciliation mechanisms and lag tolerance
|
|
150
|
+
- Staleness policy
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## 8. Extension Points & Safe Mutation Patterns
|
|
155
|
+
|
|
156
|
+
How to add new behavior without violating invariants. Include registration sites, required vs optional contracts, and test patterns. Graph-derived where possible.
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## 9. Graph Coverage Gaps & Known Limitations (MANDATORY)
|
|
161
|
+
|
|
162
|
+
Explicit, honest list of where the document and underlying graph are weak or absent.
|
|
163
|
+
|
|
164
|
+
- Per-language fidelity shortfalls (copy from Dashboard)
|
|
165
|
+
- Areas where synthesis or existing high-quality docs were the real ground truth
|
|
166
|
+
- Remaining hallucination risk for future agents
|
|
167
|
+
- "Future agents should re-verify X against source before acting here"
|
|
168
|
+
|
|
169
|
+
This section is one of the most valuable outputs for safety-critical or low-graph-fidelity systems.
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## 10. Relationship to Other Authoritative Documentation (MANDATORY when Context Audit high/medium)
|
|
174
|
+
|
|
175
|
+
When the Pre-Check Context Audit detects strong agent-optimized sources (CLAUDE.md, INVARIANTS.md, ADRs, etc.):
|
|
176
|
+
|
|
177
|
+
- List the detected files with one-line characterization
|
|
178
|
+
- State exactly what this architecture.md supplies (graph spine, deterministic maps, visual synthesis, provenance on claims)
|
|
179
|
+
- State what it defers to, with concrete cross-references
|
|
180
|
+
- Explicit confirmation that no large-scale prose duplication of the existing authoritative material occurred
|
|
181
|
+
|
|
182
|
+
When no high context was detected: short note that this document is the primary self-contained reference.
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## Fidelity & Provenance Rules (Strict — apply everywhere)
|
|
187
|
+
|
|
188
|
+
Every claim or section must be tagged with one of:
|
|
189
|
+
|
|
190
|
+
- `Graph-Derived (High)` — direct from rich graph data
|
|
191
|
+
- `Graph-Derived (Approximate)` — tree-sitter / static analysis
|
|
192
|
+
- `Graph-Derived (Stub)` — directory/file counts only
|
|
193
|
+
- `Human + Graph` — graph shows structure; synthesis added rationale or dynamic behavior
|
|
194
|
+
- `Human Judgment` — not (yet) expressible in the graph (lock ordering, certain safety rules) — always call out
|
|
195
|
+
- `Existing Authoritative Doc` — defers to CLAUDE.md / INVARIANTS.md etc.
|
|
196
|
+
|
|
197
|
+
AI agents are trained by the document itself to treat Stub and Human Judgment claims with calibrated caution.
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
**End of clean graph-primary architecture template.**
|
|
202
|
+
|
|
203
|
+
This is the single forward-looking source of truth. Legacy 28-section volume-oriented material has been retired.
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
---
|
|
2
|
+
project: "{PROJECT_NAME}"
|
|
3
|
+
module: "root"
|
|
4
|
+
generated_by: "draft:index"
|
|
5
|
+
generated_at: "{ISO_TIMESTAMP}"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Service Dependency Graph
|
|
9
|
+
|
|
10
|
+
| Field | Value |
|
|
11
|
+
|-------|-------|
|
|
12
|
+
| **Branch** | `{LOCAL_BRANCH}` → `{REMOTE/BRANCH}` |
|
|
13
|
+
| **Commit** | `{SHORT_SHA}` — {COMMIT_MESSAGE} |
|
|
14
|
+
| **Generated** | {ISO_TIMESTAMP} |
|
|
15
|
+
| **Synced To** | `{FULL_SHA}` |
|
|
16
|
+
|
|
17
|
+
> Auto-generated. Do not edit directly.
|
|
18
|
+
> Re-run `/draft:index` to update.
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## System Topology
|
|
23
|
+
|
|
24
|
+
```mermaid
|
|
25
|
+
graph LR
|
|
26
|
+
subgraph "Core Services"
|
|
27
|
+
auth[auth-service]
|
|
28
|
+
users[user-service]
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
subgraph "Business Services"
|
|
32
|
+
billing[billing-service]
|
|
33
|
+
orders[order-service]
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
subgraph "Edge"
|
|
37
|
+
gateway[api-gateway]
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
subgraph "Background"
|
|
41
|
+
notifications[notification-service]
|
|
42
|
+
reports[report-service]
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
gateway --> auth
|
|
46
|
+
gateway --> users
|
|
47
|
+
gateway --> billing
|
|
48
|
+
gateway --> orders
|
|
49
|
+
billing --> auth
|
|
50
|
+
orders --> auth
|
|
51
|
+
orders --> billing
|
|
52
|
+
notifications --> users
|
|
53
|
+
reports --> billing
|
|
54
|
+
reports --> orders
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
> Services without `draft/` are shown with dashed borders when detected.
|
|
58
|
+
|
|
59
|
+
## Dependency Matrix
|
|
60
|
+
|
|
61
|
+
| Service | Depends On | Depended By | Circular? |
|
|
62
|
+
|---------|-----------|-------------|-----------|
|
|
63
|
+
| auth-service | - | billing, orders, gateway | No |
|
|
64
|
+
| user-service | auth | gateway, notifications | No |
|
|
65
|
+
| billing-service | auth | orders, gateway, reports | No |
|
|
66
|
+
| order-service | auth, billing | gateway, reports | No |
|
|
67
|
+
| api-gateway | auth, users, billing, orders | - | No |
|
|
68
|
+
| notification-service | users | - | No |
|
|
69
|
+
| report-service | billing, orders | - | No |
|
|
70
|
+
|
|
71
|
+
## Dependency Order (Topological)
|
|
72
|
+
|
|
73
|
+
Build/deploy order for cross-service changes:
|
|
74
|
+
|
|
75
|
+
1. **auth-service** — foundational, no internal dependencies
|
|
76
|
+
2. **user-service** — depends on: auth
|
|
77
|
+
3. **billing-service** — depends on: auth
|
|
78
|
+
4. **order-service** — depends on: auth, billing
|
|
79
|
+
5. **notification-service** — depends on: users
|
|
80
|
+
6. **report-service** — depends on: billing, orders
|
|
81
|
+
7. **api-gateway** — depends on: auth, users, billing, orders (deploy last)
|
|
82
|
+
|
|
83
|
+
> This ordering helps when planning cross-service changes, understanding blast radius, or sequencing deployments.
|
|
84
|
+
|
|
85
|
+
## Impact Analysis
|
|
86
|
+
|
|
87
|
+
When modifying a service, these services may be affected:
|
|
88
|
+
|
|
89
|
+
| If You Change... | Check These Services |
|
|
90
|
+
|------------------|---------------------|
|
|
91
|
+
| auth-service | billing, orders, gateway, users |
|
|
92
|
+
| billing-service | orders, gateway, reports |
|
|
93
|
+
| user-service | gateway, notifications |
|
|
94
|
+
|
|
95
|
+
## External Dependencies
|
|
96
|
+
|
|
97
|
+
Services depending on external systems:
|
|
98
|
+
|
|
99
|
+
| External System | Used By | Purpose |
|
|
100
|
+
|----------------|---------|---------|
|
|
101
|
+
| [Stripe] | billing-service | Payment processing |
|
|
102
|
+
| [SendGrid] | notification-service | Email delivery |
|
|
103
|
+
| [AWS S3] | report-service | Report storage |
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
---
|
|
2
|
+
project: "{PROJECT_NAME}"
|
|
3
|
+
module: "root"
|
|
4
|
+
track_id: "{TRACK_ID}"
|
|
5
|
+
generated_by: "draft:discover"
|
|
6
|
+
generated_at: "{ISO_TIMESTAMP}"
|
|
7
|
+
links:
|
|
8
|
+
spec: "./spec.md"
|
|
9
|
+
plan: "./plan.md"
|
|
10
|
+
hld: "./hld.md"
|
|
11
|
+
lld: "./lld.md"
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# {TRACK_TITLE} — Discovery
|
|
15
|
+
|
|
16
|
+
> Phase 0 (code spike). Captures the current-state code reading the AI
|
|
17
|
+
> performed before the spec was written, anchored to
|
|
18
|
+
> `metadata.json:synced_to_commit`. See
|
|
19
|
+
> [core/shared/discovery-schema.md](../../core/shared/discovery-schema.md)
|
|
20
|
+
> for the schema. Hygiene validator forbids empty hotspots without an
|
|
21
|
+
> adjacent `_NONE_FOUND_` justification.
|
|
22
|
+
|
|
23
|
+
**Status:** <!-- META:status --> <!-- REQUIRED -->
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Hotspots <!-- REQUIRED -->
|
|
28
|
+
|
|
29
|
+
Code locations the spec must address. Each row cites `path:line` that
|
|
30
|
+
verify-citations.sh resolves against the pinned commit.
|
|
31
|
+
|
|
32
|
+
| Step | Location | Behavior |
|
|
33
|
+
|------|----------|----------|
|
|
34
|
+
| _TBD_hotspot_1_step_ | _TBD_hotspot_1_location_ | _TBD_hotspot_1_behavior_ |
|
|
35
|
+
| _TBD_hotspot_2_step_ | _TBD_hotspot_2_location_ | _TBD_hotspot_2_behavior_ |
|
|
36
|
+
| _TBD_hotspot_3_step_ | _TBD_hotspot_3_location_ | _TBD_hotspot_3_behavior_ |
|
|
37
|
+
|
|
38
|
+
> If the spike found nothing: keep this table empty and add a
|
|
39
|
+
> `_NONE_FOUND_ — <justification>` line below before saving.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Mode Selection <!-- REQUIRED -->
|
|
44
|
+
|
|
45
|
+
Flags, feature gates, environment switches that govern the current code
|
|
46
|
+
path. Receivers of the spec use this to scope rollout planning.
|
|
47
|
+
|
|
48
|
+
| Switch | Location | Notes |
|
|
49
|
+
|--------|----------|-------|
|
|
50
|
+
| _TBD_switch_1_name_ | _TBD_switch_1_location_ | _TBD_switch_1_notes_ |
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Open Questions <!-- REQUIRED -->
|
|
55
|
+
|
|
56
|
+
Load-bearing unknowns that must close before spec freeze. Each question
|
|
57
|
+
must resolve into a decision in `spec.md`, a deferral with a follow-up
|
|
58
|
+
track ID, or `_NONE_FOUND_` with justification.
|
|
59
|
+
|
|
60
|
+
- Q1: _TBD_question_1_
|
|
61
|
+
- Q2: _TBD_question_2_
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## References <!-- REQUIRED -->
|
|
66
|
+
|
|
67
|
+
Flat list of files and functions touched in the spike. Files cited here
|
|
68
|
+
without line numbers are exempt from drift checks (they document
|
|
69
|
+
*familiarity*, not pinned facts).
|
|
70
|
+
|
|
71
|
+
- _TBD_reference_1_path_ — _TBD_reference_1_symbol_ — _TBD_reference_1_role_
|
|
72
|
+
- _TBD_reference_2_path_ — _TBD_reference_2_symbol_ — _TBD_reference_2_role_
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Conversation Log <!-- OPTIONAL -->
|
|
77
|
+
|
|
78
|
+
> Free-form notes captured during the spike. Reviewers can skim this for
|
|
79
|
+
> context the structured sections above don't carry. Not validator-checked.
|