code-as-plan 2.0.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/LICENSE +21 -0
- package/README.ja-JP.md +834 -0
- package/README.ko-KR.md +823 -0
- package/README.md +1006 -0
- package/README.pt-BR.md +452 -0
- package/README.zh-CN.md +800 -0
- package/agents/cap-brainstormer.md +154 -0
- package/agents/cap-debugger.md +221 -0
- package/agents/cap-prototyper.md +170 -0
- package/agents/cap-reviewer.md +230 -0
- package/agents/cap-tester.md +193 -0
- package/bin/install.js +5002 -0
- package/cap/bin/gsd-tools.cjs +1141 -0
- package/cap/bin/lib/arc-scanner.cjs +341 -0
- package/cap/bin/lib/cap-feature-map.cjs +506 -0
- package/cap/bin/lib/cap-session.cjs +191 -0
- package/cap/bin/lib/cap-stack-docs.cjs +598 -0
- package/cap/bin/lib/cap-tag-scanner.cjs +458 -0
- package/cap/bin/lib/commands.cjs +959 -0
- package/cap/bin/lib/config.cjs +466 -0
- package/cap/bin/lib/convention-reader.cjs +180 -0
- package/cap/bin/lib/core.cjs +1230 -0
- package/cap/bin/lib/feature-aggregator.cjs +422 -0
- package/cap/bin/lib/frontmatter.cjs +336 -0
- package/cap/bin/lib/init.cjs +1442 -0
- package/cap/bin/lib/manifest-generator.cjs +381 -0
- package/cap/bin/lib/milestone.cjs +252 -0
- package/cap/bin/lib/model-profiles.cjs +68 -0
- package/cap/bin/lib/monorepo-context.cjs +224 -0
- package/cap/bin/lib/monorepo-migrator.cjs +507 -0
- package/cap/bin/lib/phase.cjs +888 -0
- package/cap/bin/lib/profile-output.cjs +952 -0
- package/cap/bin/lib/profile-pipeline.cjs +539 -0
- package/cap/bin/lib/roadmap.cjs +329 -0
- package/cap/bin/lib/security.cjs +382 -0
- package/cap/bin/lib/session-manager.cjs +290 -0
- package/cap/bin/lib/skeleton-generator.cjs +177 -0
- package/cap/bin/lib/state.cjs +1031 -0
- package/cap/bin/lib/template.cjs +222 -0
- package/cap/bin/lib/test-detector.cjs +61 -0
- package/cap/bin/lib/uat.cjs +282 -0
- package/cap/bin/lib/verify.cjs +888 -0
- package/cap/bin/lib/workspace-detector.cjs +369 -0
- package/cap/bin/lib/workstream.cjs +491 -0
- package/cap/commands/gsd/workstreams.md +63 -0
- package/cap/references/arc-standard.md +315 -0
- package/cap/references/cap-agent-architecture.md +102 -0
- package/cap/references/cap-gitignore-template +9 -0
- package/cap/references/cap-zero-deps.md +158 -0
- package/cap/references/checkpoints.md +778 -0
- package/cap/references/continuation-format.md +249 -0
- package/cap/references/decimal-phase-calculation.md +64 -0
- package/cap/references/feature-map-template.md +25 -0
- package/cap/references/git-integration.md +295 -0
- package/cap/references/git-planning-commit.md +38 -0
- package/cap/references/model-profile-resolution.md +36 -0
- package/cap/references/model-profiles.md +139 -0
- package/cap/references/phase-argument-parsing.md +61 -0
- package/cap/references/planning-config.md +202 -0
- package/cap/references/questioning.md +162 -0
- package/cap/references/session-template.json +8 -0
- package/cap/references/tdd.md +263 -0
- package/cap/references/ui-brand.md +160 -0
- package/cap/references/user-profiling.md +681 -0
- package/cap/references/verification-patterns.md +612 -0
- package/cap/references/workstream-flag.md +58 -0
- package/cap/templates/DEBUG.md +164 -0
- package/cap/templates/UAT.md +265 -0
- package/cap/templates/UI-SPEC.md +100 -0
- package/cap/templates/VALIDATION.md +76 -0
- package/cap/templates/claude-md.md +122 -0
- package/cap/templates/codebase/architecture.md +255 -0
- package/cap/templates/codebase/concerns.md +310 -0
- package/cap/templates/codebase/conventions.md +307 -0
- package/cap/templates/codebase/integrations.md +280 -0
- package/cap/templates/codebase/stack.md +186 -0
- package/cap/templates/codebase/structure.md +285 -0
- package/cap/templates/codebase/testing.md +480 -0
- package/cap/templates/config.json +44 -0
- package/cap/templates/context.md +352 -0
- package/cap/templates/continue-here.md +78 -0
- package/cap/templates/copilot-instructions.md +7 -0
- package/cap/templates/debug-subagent-prompt.md +91 -0
- package/cap/templates/dev-preferences.md +21 -0
- package/cap/templates/discovery.md +146 -0
- package/cap/templates/discussion-log.md +63 -0
- package/cap/templates/milestone-archive.md +123 -0
- package/cap/templates/milestone.md +115 -0
- package/cap/templates/phase-prompt.md +610 -0
- package/cap/templates/planner-subagent-prompt.md +117 -0
- package/cap/templates/project.md +186 -0
- package/cap/templates/requirements.md +231 -0
- package/cap/templates/research-project/ARCHITECTURE.md +204 -0
- package/cap/templates/research-project/FEATURES.md +147 -0
- package/cap/templates/research-project/PITFALLS.md +200 -0
- package/cap/templates/research-project/STACK.md +120 -0
- package/cap/templates/research-project/SUMMARY.md +170 -0
- package/cap/templates/research.md +552 -0
- package/cap/templates/retrospective.md +54 -0
- package/cap/templates/roadmap.md +202 -0
- package/cap/templates/state.md +176 -0
- package/cap/templates/summary-complex.md +59 -0
- package/cap/templates/summary-minimal.md +41 -0
- package/cap/templates/summary-standard.md +48 -0
- package/cap/templates/summary.md +248 -0
- package/cap/templates/user-profile.md +146 -0
- package/cap/templates/user-setup.md +311 -0
- package/cap/templates/verification-report.md +322 -0
- package/cap/workflows/add-phase.md +112 -0
- package/cap/workflows/add-tests.md +351 -0
- package/cap/workflows/add-todo.md +158 -0
- package/cap/workflows/audit-milestone.md +340 -0
- package/cap/workflows/audit-uat.md +109 -0
- package/cap/workflows/autonomous.md +891 -0
- package/cap/workflows/check-todos.md +177 -0
- package/cap/workflows/cleanup.md +152 -0
- package/cap/workflows/complete-milestone.md +767 -0
- package/cap/workflows/diagnose-issues.md +231 -0
- package/cap/workflows/discovery-phase.md +289 -0
- package/cap/workflows/discuss-phase-assumptions.md +653 -0
- package/cap/workflows/discuss-phase.md +1049 -0
- package/cap/workflows/do.md +104 -0
- package/cap/workflows/execute-phase.md +846 -0
- package/cap/workflows/execute-plan.md +514 -0
- package/cap/workflows/fast.md +105 -0
- package/cap/workflows/forensics.md +265 -0
- package/cap/workflows/health.md +181 -0
- package/cap/workflows/help.md +660 -0
- package/cap/workflows/insert-phase.md +130 -0
- package/cap/workflows/list-phase-assumptions.md +178 -0
- package/cap/workflows/list-workspaces.md +56 -0
- package/cap/workflows/manager.md +362 -0
- package/cap/workflows/map-codebase.md +377 -0
- package/cap/workflows/milestone-summary.md +223 -0
- package/cap/workflows/new-milestone.md +486 -0
- package/cap/workflows/new-project.md +1250 -0
- package/cap/workflows/new-workspace.md +237 -0
- package/cap/workflows/next.md +97 -0
- package/cap/workflows/node-repair.md +92 -0
- package/cap/workflows/note.md +156 -0
- package/cap/workflows/pause-work.md +176 -0
- package/cap/workflows/plan-milestone-gaps.md +273 -0
- package/cap/workflows/plan-phase.md +859 -0
- package/cap/workflows/plant-seed.md +169 -0
- package/cap/workflows/pr-branch.md +129 -0
- package/cap/workflows/profile-user.md +450 -0
- package/cap/workflows/progress.md +507 -0
- package/cap/workflows/quick.md +757 -0
- package/cap/workflows/remove-phase.md +155 -0
- package/cap/workflows/remove-workspace.md +90 -0
- package/cap/workflows/research-phase.md +82 -0
- package/cap/workflows/resume-project.md +326 -0
- package/cap/workflows/review.md +228 -0
- package/cap/workflows/session-report.md +146 -0
- package/cap/workflows/settings.md +283 -0
- package/cap/workflows/ship.md +228 -0
- package/cap/workflows/stats.md +60 -0
- package/cap/workflows/transition.md +671 -0
- package/cap/workflows/ui-phase.md +302 -0
- package/cap/workflows/ui-review.md +165 -0
- package/cap/workflows/update.md +323 -0
- package/cap/workflows/validate-phase.md +174 -0
- package/cap/workflows/verify-phase.md +254 -0
- package/cap/workflows/verify-work.md +637 -0
- package/commands/cap/annotate.md +165 -0
- package/commands/cap/brainstorm.md +238 -0
- package/commands/cap/debug.md +297 -0
- package/commands/cap/init.md +262 -0
- package/commands/cap/iterate.md +234 -0
- package/commands/cap/prototype.md +281 -0
- package/commands/cap/refresh-docs.md +37 -0
- package/commands/cap/review.md +272 -0
- package/commands/cap/scan.md +249 -0
- package/commands/cap/start.md +234 -0
- package/commands/cap/status.md +189 -0
- package/commands/cap/test.md +250 -0
- package/hooks/dist/gsd-check-update.js +114 -0
- package/hooks/dist/gsd-context-monitor.js +156 -0
- package/hooks/dist/gsd-prompt-guard.js +96 -0
- package/hooks/dist/gsd-statusline.js +119 -0
- package/hooks/dist/gsd-workflow-guard.js +94 -0
- package/package.json +51 -0
- package/scripts/base64-scan.sh +262 -0
- package/scripts/build-hooks.js +82 -0
- package/scripts/cap-removal-checklist.md +202 -0
- package/scripts/prompt-injection-scan.sh +198 -0
- package/scripts/run-tests.cjs +29 -0
- package/scripts/secret-scan.sh +227 -0
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
# ARC Annotation Standard
|
|
2
|
+
|
|
3
|
+
**Version:** 1.0
|
|
4
|
+
**Stability:** Stable — tag names and parenthesized keys will not change in v1.x. New optional metadata keys may be added in future versions. Tag types will not be renamed.
|
|
5
|
+
**Purpose:** @gsd-tags embedded in source code comments are machine-readable planning metadata. They allow the tag scanner to extract CODE-INVENTORY.md and allow agents to understand code structure and intent without reading every file.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Tag Syntax
|
|
10
|
+
|
|
11
|
+
Tags use a single-line structured format:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
@gsd-<type>[(key:value, key:value)] Description text
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
The metadata block (parenthesized key-value pairs) is optional. All three of these are valid:
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
// @gsd-context JWT validation module — stateless, RS256 only
|
|
21
|
+
// @gsd-todo(phase:2) Add refresh token rotation
|
|
22
|
+
// @gsd-todo(phase:2, priority:high) Add refresh token rotation
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Rules:
|
|
26
|
+
- Tags are single-line only — no multi-line tag bodies
|
|
27
|
+
- The `@gsd-` prefix is lowercase and case-sensitive
|
|
28
|
+
- Tag type names are lowercase (e.g., `context`, not `Context`)
|
|
29
|
+
- Description text runs to end of line after the optional metadata block
|
|
30
|
+
- Whitespace between the comment token and `@gsd-` is permitted
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Comment Anchor Rule
|
|
35
|
+
|
|
36
|
+
A tag is ONLY valid when it appears on a line where the first non-whitespace content is a comment-opening token.
|
|
37
|
+
|
|
38
|
+
Valid comment-opening tokens:
|
|
39
|
+
- `//` — C-style single-line comment (JavaScript, TypeScript, Go, Rust, Java, C, C++)
|
|
40
|
+
- `//+` — Variant single-line comment
|
|
41
|
+
- `/*` — C-style block comment opener
|
|
42
|
+
- `*` — Block comment continuation line (inside `/* ... */`)
|
|
43
|
+
- `#` — Hash comment (Python, Ruby, Shell, YAML)
|
|
44
|
+
- `--` — SQL single-line comment
|
|
45
|
+
- `"""` — Python docstring opener (triple double-quote)
|
|
46
|
+
- `'''` — Python docstring opener (triple single-quote)
|
|
47
|
+
|
|
48
|
+
**@gsd- appearing inside a string literal, URL path, or template literal is NOT a tag and the scanner will skip it.**
|
|
49
|
+
|
|
50
|
+
Side-by-side examples:
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
// @gsd-context Valid tag — anchored to comment token (VALID)
|
|
54
|
+
const x = "// @gsd-todo this is NOT a tag"; (INVALID — inside string)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
More examples:
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
# @gsd-constraint No external HTTP calls allowed (VALID — hash comment)
|
|
61
|
+
url := "http://pkg.go.dev/@gsd-pattern/something" (INVALID — inside string)
|
|
62
|
+
-- @gsd-context Partitioned by tenant_id (VALID — SQL comment)
|
|
63
|
+
const tmpl = `@gsd-todo fix this` (INVALID — template literal)
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
The scanner regex anchors to `^[ \t]*` (optional leading whitespace only) followed by the comment token, then optional whitespace, then `@gsd-`. Any line where non-whitespace content precedes the comment token does not match.
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Tag Types
|
|
71
|
+
|
|
72
|
+
| Tag | Purpose |
|
|
73
|
+
|-----|---------|
|
|
74
|
+
| @gsd-context | Explain WHY this code exists, what problem it solves, architectural context |
|
|
75
|
+
| @gsd-decision | Record a design/implementation choice and its rationale |
|
|
76
|
+
| @gsd-todo | Planned future work, optionally scoped to a phase |
|
|
77
|
+
| @gsd-constraint | Hard boundaries the code must respect (performance, security, compatibility) |
|
|
78
|
+
| @gsd-pattern | Document a reusable pattern established here that should be followed elsewhere |
|
|
79
|
+
| @gsd-ref | Cross-reference to another file, doc, issue, or external resource |
|
|
80
|
+
| @gsd-risk | Flag known risks, edge cases, or fragile areas |
|
|
81
|
+
| @gsd-api | Document a public API surface: contract, parameters, return shape |
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
### @gsd-context
|
|
86
|
+
|
|
87
|
+
Use `@gsd-context` to explain why a module, function, or block of code exists — what problem it solves and where it fits in the architecture. This is the most important tag type. Future maintainers and agents reading CODE-INVENTORY.md will use context tags to understand the codebase without reading every file. Place it near the top of a file or at the start of a significant function.
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
// @gsd-context(phase:1) Auth middleware — validates JWT on every protected route. Stateless, RS256 only.
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
### @gsd-decision
|
|
96
|
+
|
|
97
|
+
Use `@gsd-decision` to record a design or implementation choice and the reasoning behind it. Decisions are the "why we did it this way" that gets lost over time. Tag the exact location where the decision manifests in code so the rationale travels with the implementation. Include the alternatives considered when space permits.
|
|
98
|
+
|
|
99
|
+
```
|
|
100
|
+
// @gsd-decision Using jose over jsonwebtoken: jose is ESM-compatible and actively maintained. jsonwebtoken has no ESM export.
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
### @gsd-todo
|
|
106
|
+
|
|
107
|
+
Use `@gsd-todo` for planned future work, bug fixes not yet addressed, or features deferred to a later phase. The optional `phase:N` metadata ties the todo to a specific project phase so `extract-plan` can group planned work by phase. Use `priority:high` for items that block other work.
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
// @gsd-todo(phase:2, priority:high) Add refresh token rotation — currently tokens never expire
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
### @gsd-constraint
|
|
116
|
+
|
|
117
|
+
Use `@gsd-constraint` to document hard boundaries the code must respect: performance budgets, security requirements, compatibility limits, or regulatory rules. Constraints differ from decisions — a constraint is a non-negotiable boundary, not a choice. Annotate the code that enforces or depends on the constraint.
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
// @gsd-constraint Max response time 200ms — SLA requirement. Do not add synchronous I/O in this path.
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
### @gsd-pattern
|
|
126
|
+
|
|
127
|
+
Use `@gsd-pattern` to document a reusable pattern established at this location that should be followed elsewhere in the codebase. Patterns are standards-in-waiting: they describe a recurring structure, idiom, or convention that agents and developers should replicate rather than reinvent. Place the tag where the canonical implementation lives.
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
// @gsd-pattern Use sync.Once for all singleton initializations in this package — see Init() as the reference implementation
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
### @gsd-ref
|
|
136
|
+
|
|
137
|
+
Use `@gsd-ref` to create a cross-reference from code to another file, documentation page, issue tracker entry, pull request, or external resource. Refs preserve traceability: they connect an implementation decision to its origin. Use the `ref:` metadata key for machine-readable IDs.
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
// @gsd-ref(ref:ISSUE-142) Rate limiting logic — see docs/rate-limiting.md for the algorithm specification
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
### @gsd-risk
|
|
146
|
+
|
|
147
|
+
Use `@gsd-risk` to flag known risks, edge cases, fragile areas, or technical debt that could cause future failures. Risks are not todos (they may never need fixing) and not constraints (they describe potential problems, not rules). Tag the exact code location where the risk lives so it surfaces in CODE-INVENTORY.md risk reports.
|
|
148
|
+
|
|
149
|
+
```
|
|
150
|
+
// @gsd-risk(ref:ISSUE-142) Race condition possible if Init() called before DB connection pool is ready
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
### @gsd-api
|
|
156
|
+
|
|
157
|
+
Use `@gsd-api` to document a public API surface: its contract, parameter types, return shape, and any side effects. This tag is for the API boundary itself — exported functions, HTTP endpoints, public class methods, CLI interfaces. It gives agents reading CODE-INVENTORY.md a compact API reference without reading implementation code.
|
|
158
|
+
|
|
159
|
+
```
|
|
160
|
+
// @gsd-api POST /auth/token — body: {email, password} — returns: {token, expiresAt} or 401 on invalid credentials
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## Metadata Keys
|
|
166
|
+
|
|
167
|
+
Metadata is a parenthesized comma-separated list of `key:value` pairs. Any key is valid. Conventional standard keys:
|
|
168
|
+
|
|
169
|
+
- `phase:<N>` — project phase this tag applies to (e.g., `phase:2`)
|
|
170
|
+
- `priority:<value>` — urgency level (`priority:high`, `priority:medium`, `priority:low`)
|
|
171
|
+
- `ref:<id>` — external reference (issue number, requirement ID, PR number, e.g., `ref:ISSUE-142`, `ref:REQ-AUTH-01`)
|
|
172
|
+
|
|
173
|
+
Examples:
|
|
174
|
+
|
|
175
|
+
```
|
|
176
|
+
// @gsd-todo(phase:2) Single key
|
|
177
|
+
// @gsd-todo(phase:2, priority:high) Two keys
|
|
178
|
+
// @gsd-risk(ref:ISSUE-142, priority:high) Two keys with external reference
|
|
179
|
+
// @gsd-context(phase:1) Single phase scoping
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
The scanner stores all metadata as a flat key-value object. Agents interpret keys by convention, not by schema enforcement. Future versions of the ARC standard may add new conventional keys — existing keys will not be renamed.
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
## Language Examples
|
|
187
|
+
|
|
188
|
+
### JavaScript / TypeScript
|
|
189
|
+
|
|
190
|
+
```typescript
|
|
191
|
+
// @gsd-context(phase:1) Auth middleware — validates JWT on every protected route
|
|
192
|
+
// @gsd-decision Using jose over jsonwebtoken: jose is ESM-compatible, no CommonJS issues
|
|
193
|
+
export async function authMiddleware(req, res, next) { ... }
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
```typescript
|
|
197
|
+
// @gsd-api POST /users — body: {email, password, name} — returns: {id, email, createdAt} or 400/409
|
|
198
|
+
// @gsd-constraint No plaintext passwords stored — bcrypt hash only, cost factor 12
|
|
199
|
+
export async function createUser(body: CreateUserBody): Promise<User> { ... }
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Python
|
|
203
|
+
|
|
204
|
+
```python
|
|
205
|
+
# @gsd-constraint No external HTTP calls from this module — must be pure compute
|
|
206
|
+
# @gsd-todo(phase:2, priority:high) Add caching layer for repeated signature verifications
|
|
207
|
+
def verify_token(token: str) -> dict:
|
|
208
|
+
"""
|
|
209
|
+
@gsd-api Parameters: token (str) — raw JWT. Returns: decoded payload dict or raises AuthError.
|
|
210
|
+
"""
|
|
211
|
+
...
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
```python
|
|
215
|
+
# @gsd-decision Using bcrypt not argon2 — bcrypt is available on all target deployment platforms without custom compile
|
|
216
|
+
# @gsd-risk Memory: bcrypt is CPU-bound; under load this blocks the event loop in sync contexts
|
|
217
|
+
def hash_password(password: str) -> str:
|
|
218
|
+
...
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Go
|
|
222
|
+
|
|
223
|
+
```go
|
|
224
|
+
// @gsd-pattern Use sync.Once for all singleton initializations in this package
|
|
225
|
+
// @gsd-risk(ref:ISSUE-142) Race condition possible if Init() called before DB is ready
|
|
226
|
+
func Init() *DB { ... }
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
```go
|
|
230
|
+
// @gsd-context Connection pool — shared across all handlers, initialized once at startup
|
|
231
|
+
// @gsd-constraint Max 25 connections — production database limit. Do not increase without DBA approval.
|
|
232
|
+
var pool *sql.DB
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### Rust
|
|
236
|
+
|
|
237
|
+
```rust
|
|
238
|
+
// @gsd-context FFI boundary to the C crypto library — unsafe block intentional
|
|
239
|
+
// @gsd-risk Memory safety: caller must ensure buf lives longer than the returned slice
|
|
240
|
+
unsafe fn decrypt_raw(buf: *const u8, len: usize) -> &'static [u8] { ... }
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
```rust
|
|
244
|
+
// @gsd-decision Chose ring over openssl: ring has a smaller attack surface and is pure Rust
|
|
245
|
+
// @gsd-constraint FIPS compliance required — ring is FIPS 140-2 validated for production use
|
|
246
|
+
fn init_crypto() -> CryptoContext { ... }
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### SQL
|
|
250
|
+
|
|
251
|
+
```sql
|
|
252
|
+
-- @gsd-context Partitioned by tenant_id for query isolation — max 50K rows per partition
|
|
253
|
+
-- @gsd-constraint No cross-tenant JOINs allowed in this view
|
|
254
|
+
CREATE VIEW tenant_events AS ...
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
```sql
|
|
258
|
+
-- @gsd-decision Storing UTC timestamps as BIGINT (epoch ms) not TIMESTAMPTZ — avoids timezone conversion bugs in legacy importers
|
|
259
|
+
-- @gsd-todo(phase:3) Migrate to TIMESTAMPTZ once legacy importers are decommissioned
|
|
260
|
+
CREATE TABLE events (
|
|
261
|
+
id BIGSERIAL PRIMARY KEY,
|
|
262
|
+
occurred_at BIGINT NOT NULL
|
|
263
|
+
);
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### Shell
|
|
267
|
+
|
|
268
|
+
```sh
|
|
269
|
+
# @gsd-context Bootstraps the dev environment — must be idempotent
|
|
270
|
+
# @gsd-todo(phase:3) Add --dry-run flag for CI validation without side effects
|
|
271
|
+
set -euo pipefail
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
```sh
|
|
275
|
+
# @gsd-constraint Requires bash >=4.0 — uses associative arrays. macOS ships bash 3.2; install via Homebrew.
|
|
276
|
+
# @gsd-risk If HOME is unset this script silently writes to //.config — add guard before production use
|
|
277
|
+
main() {
|
|
278
|
+
...
|
|
279
|
+
}
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
## What the Scanner Extracts
|
|
285
|
+
|
|
286
|
+
For each @gsd-tag found in source code, the scanner produces one JSON object:
|
|
287
|
+
|
|
288
|
+
```json
|
|
289
|
+
{
|
|
290
|
+
"type": "context",
|
|
291
|
+
"file": "src/auth/jwt.js",
|
|
292
|
+
"line": 12,
|
|
293
|
+
"metadata": { "phase": "1" },
|
|
294
|
+
"description": "JWT validation module — stateless, RS256 only",
|
|
295
|
+
"raw": "// @gsd-context(phase:1) JWT validation module — stateless, RS256 only"
|
|
296
|
+
}
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
Field notes:
|
|
300
|
+
- `type` — the tag name without the `@gsd-` prefix (always lowercase)
|
|
301
|
+
- `file` — path relative to project root
|
|
302
|
+
- `line` — 1-based line number in the source file
|
|
303
|
+
- `metadata` — key-value object parsed from the parenthesized block; `{}` when no parenthesized keys are present; all values are strings
|
|
304
|
+
- `description` — text after the optional metadata block, trimmed of leading and trailing whitespace
|
|
305
|
+
- `raw` — the complete original line including the comment token, for reference and debugging
|
|
306
|
+
|
|
307
|
+
The scanner outputs an array of these objects. When writing CODE-INVENTORY.md, the scanner groups tags by type, then by file, within each type group.
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
## GSD Commands
|
|
312
|
+
|
|
313
|
+
`extract-plan` scans the project for all @gsd-tags and writes `.planning/prototype/CODE-INVENTORY.md` grouped by tag type and file, with a summary statistics table and a phase reference index. Run it after annotating code or after a significant annotation session to update the inventory.
|
|
314
|
+
|
|
315
|
+
`annotate` spawns gsd-annotator — an agent that reads existing source code alongside PROJECT.md and REQUIREMENTS.md to determine appropriate @gsd-tags and adds them inline as comments. On completion, `annotate` automatically runs `extract-plan` to produce an updated CODE-INVENTORY.md. Use `annotate` to retroactively add ARC annotations to an existing codebase.
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# CAP Agent Architecture
|
|
2
|
+
|
|
3
|
+
<!-- @gsd-context Reference document defining the CAP v2.0 agent architecture. All agents read this file to understand boundaries, communication rules, and naming conventions. -->
|
|
4
|
+
<!-- @gsd-decision Exactly 5 agents -- no more, no fewer. This is a hard constraint to prevent agent proliferation. New capabilities go into existing agents as modes. -->
|
|
5
|
+
<!-- @gsd-decision Communication via shared artifacts only -- agents never invoke each other directly. This eliminates coupling and makes each agent independently testable. -->
|
|
6
|
+
|
|
7
|
+
<!-- @gsd-todo(ref:AC-67) The system shall have exactly 5 agents: cap-brainstormer, cap-prototyper, cap-tester, cap-reviewer, cap-debugger -->
|
|
8
|
+
<!-- @gsd-todo(ref:AC-68) Each agent defined as Markdown file with Claude Code agent frontmatter (YAML) -->
|
|
9
|
+
<!-- @gsd-todo(ref:AC-69) Agents shall not depend on each other's internals -- communication via shared artifacts only -->
|
|
10
|
+
<!-- @gsd-todo(ref:AC-70) Agents placed in agents/ directory with cap- prefix naming -->
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Agent Roster (Exactly 5)
|
|
15
|
+
|
|
16
|
+
| Agent | File | Purpose | Spawned By |
|
|
17
|
+
|-------|------|---------|------------|
|
|
18
|
+
| cap-brainstormer | `agents/cap-brainstormer.md` | Feature discovery via conversation | `/cap:brainstorm` |
|
|
19
|
+
| cap-prototyper | `agents/cap-prototyper.md` | Code generation in 4 modes: prototype, iterate, architecture, annotate | `/cap:prototype`, `/cap:iterate`, `/cap:annotate` |
|
|
20
|
+
| cap-tester | `agents/cap-tester.md` | RED-GREEN test writing against Feature Map ACs | `/cap:test` |
|
|
21
|
+
| cap-reviewer | `agents/cap-reviewer.md` | Two-stage review: spec compliance then code quality | `/cap:review` |
|
|
22
|
+
| cap-debugger | `agents/cap-debugger.md` | Scientific method debugging with persistent state | `/cap:debug` |
|
|
23
|
+
|
|
24
|
+
**Hard constraint:** No additional agents shall be created. If a new capability is needed, it must be added as a mode to an existing agent (preferably cap-prototyper).
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## Agent File Format (AC-68)
|
|
29
|
+
|
|
30
|
+
Every agent file follows this exact structure:
|
|
31
|
+
|
|
32
|
+
```yaml
|
|
33
|
+
---
|
|
34
|
+
name: cap-{name}
|
|
35
|
+
description: "{one-line description}"
|
|
36
|
+
tools: {comma-separated tool list}
|
|
37
|
+
permissionMode: acceptEdits
|
|
38
|
+
color: {color}
|
|
39
|
+
---
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Followed by markdown content with:
|
|
43
|
+
- `<role>` section defining agent identity and behavior
|
|
44
|
+
- `<project_context>` section for context loading
|
|
45
|
+
- `<execution_flow>` section with numbered steps
|
|
46
|
+
- `@cap-feature` and `@cap-todo` tags embedded in HTML comments
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Communication Rules (AC-69)
|
|
51
|
+
|
|
52
|
+
Agents communicate ONLY through shared artifacts. No agent may:
|
|
53
|
+
- Import or require another agent's code
|
|
54
|
+
- Read another agent's internal state
|
|
55
|
+
- Assume another agent has run or will run
|
|
56
|
+
- Call Task() to spawn another agent (only commands do this)
|
|
57
|
+
|
|
58
|
+
### Shared Artifacts (the communication bus)
|
|
59
|
+
|
|
60
|
+
| Artifact | Location | Purpose | Read By | Written By |
|
|
61
|
+
|----------|----------|---------|---------|------------|
|
|
62
|
+
| FEATURE-MAP.md | Project root | Feature identity, state, ACs | All agents | brainstormer, prototyper, tester, reviewer |
|
|
63
|
+
| SESSION.json | `.cap/SESSION.json` | Ephemeral workflow state | All agents | Commands only |
|
|
64
|
+
| Source code with @cap-* tags | Project tree | Implementation state | All agents | prototyper |
|
|
65
|
+
| Stack docs | `.cap/stack-docs/` | Library documentation | All agents | `/cap:init`, `/cap:refresh-docs` |
|
|
66
|
+
| REVIEW.md | `.cap/REVIEW.md` | Review findings | prototyper (to address) | reviewer |
|
|
67
|
+
| Debug sessions | `.cap/debug/` | Debug state | debugger | debugger |
|
|
68
|
+
|
|
69
|
+
### Information Flow
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
brainstormer -> FEATURE-MAP.md -> prototyper -> code with @cap-* tags
|
|
73
|
+
|
|
|
74
|
+
v
|
|
75
|
+
/cap:scan -> FEATURE-MAP.md (enriched)
|
|
76
|
+
|
|
|
77
|
+
v
|
|
78
|
+
tester -> test files -> reviewer
|
|
79
|
+
|
|
|
80
|
+
v
|
|
81
|
+
REVIEW.md -> prototyper (iterate)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Naming Convention (AC-70)
|
|
87
|
+
|
|
88
|
+
- Agent files: `cap-{name}.md` in `agents/` directory
|
|
89
|
+
- Command files: `{name}.md` in `commands/cap/` directory
|
|
90
|
+
- CJS library files: `cap-{name}.cjs` in `cap/bin/lib/`
|
|
91
|
+
- Test files: `cap-{name}.test.cjs` in `tests/`
|
|
92
|
+
- Tag prefix: `@cap-` (not `@gsd-`)
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Anti-Patterns
|
|
97
|
+
|
|
98
|
+
1. **Do NOT create a 6th agent.** If you need new behavior, add a mode to cap-prototyper.
|
|
99
|
+
2. **Do NOT have agents call Task() to spawn other agents.** Only commands orchestrate agents.
|
|
100
|
+
3. **Do NOT have agents read SESSION.json to determine what another agent did.** Each agent reads FEATURE-MAP.md and code for state.
|
|
101
|
+
4. **Do NOT have agents write to .planning/ directory.** CAP artifacts go in project root (FEATURE-MAP.md) or .cap/ directory.
|
|
102
|
+
5. **Do NOT create .planning/codebase/ documents.** The 7-document codebase analysis from GSD is eliminated in CAP v2.0.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# CAP runtime state -- ephemeral, not committed to git
|
|
2
|
+
SESSION.json
|
|
3
|
+
|
|
4
|
+
# Debug sessions -- ephemeral per-developer state
|
|
5
|
+
debug/
|
|
6
|
+
|
|
7
|
+
# Stack docs are NOT gitignored -- they can be committed for offline use
|
|
8
|
+
# To ignore them, uncomment the next line:
|
|
9
|
+
# stack-docs/
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# CAP Zero Runtime Dependencies Reference
|
|
2
|
+
|
|
3
|
+
<!-- @gsd-context Reference document defining the zero-dependency constraint for CAP v2.0. All developers and agents must follow these rules when adding code to the distributed package. -->
|
|
4
|
+
<!-- @gsd-decision Zero runtime dependencies is a HARD constraint, not a guideline. The distributed package must have exactly 0 entries in package.json dependencies. -->
|
|
5
|
+
<!-- @gsd-constraint The entire runtime surface uses only Node.js built-in modules. No npm packages at runtime. -->
|
|
6
|
+
|
|
7
|
+
<!-- @gsd-todo(ref:AC-93) The distributed package shall have zero runtime dependencies -->
|
|
8
|
+
<!-- @gsd-todo(ref:AC-94) The tag scanner shall use native RegExp -- no comment-parser or AST parser -->
|
|
9
|
+
<!-- @gsd-todo(ref:AC-95) File discovery shall use fs.readdirSync with recursive walk -- no glob library -->
|
|
10
|
+
<!-- @gsd-todo(ref:AC-96) CLI argument parsing shall use the existing parseNamedArgs() pattern -->
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Core Rule
|
|
15
|
+
|
|
16
|
+
**The distributed CAP package shall have zero runtime dependencies.**
|
|
17
|
+
|
|
18
|
+
This means:
|
|
19
|
+
- `package.json` `dependencies` field must be empty or absent
|
|
20
|
+
- No `require()` or `import` of any npm package in runtime code
|
|
21
|
+
- Only Node.js built-in modules (prefixed with `node:` or not) are allowed
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Allowed Node.js Built-ins
|
|
26
|
+
|
|
27
|
+
These are the ONLY modules that may be imported in CJS runtime code:
|
|
28
|
+
|
|
29
|
+
| Module | Usage in CAP |
|
|
30
|
+
|--------|-------------|
|
|
31
|
+
| `node:fs` | File system operations -- reading source files, writing Feature Map, Session |
|
|
32
|
+
| `node:path` | Path resolution -- cross-platform file path handling |
|
|
33
|
+
| `node:child_process` | Context7 invocation -- `execSync` to call `npx ctx7@latest` |
|
|
34
|
+
| `node:os` | Temporary directory paths for tests |
|
|
35
|
+
| `node:crypto` | Hashing for deduplication if needed |
|
|
36
|
+
| `node:test` | Test runner (test-time only, not runtime) |
|
|
37
|
+
| `node:assert` | Test assertions (test-time only, not runtime) |
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Specific Constraints
|
|
42
|
+
|
|
43
|
+
### Tag Scanner (AC-94)
|
|
44
|
+
|
|
45
|
+
The tag scanner SHALL use native `RegExp` for all tag extraction:
|
|
46
|
+
|
|
47
|
+
```javascript
|
|
48
|
+
// ALLOWED: native RegExp
|
|
49
|
+
const CAP_TAG_RE = /^[ \t]*(?:\/\/|\/\*|\*|#|--|"""|''')[ \t]*@cap-(feature|todo|risk|decision)(?:\(([^)]*)\))?[ \t]*(.*)/;
|
|
50
|
+
|
|
51
|
+
// FORBIDDEN: comment-parser npm package
|
|
52
|
+
const { parse } = require('comment-parser'); // DO NOT USE
|
|
53
|
+
|
|
54
|
+
// FORBIDDEN: AST parsers
|
|
55
|
+
const acorn = require('acorn'); // DO NOT USE
|
|
56
|
+
const { parse } = require('@babel/parser'); // DO NOT USE
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**Rationale:** The `@cap-` prefix makes tags structurally simple. They live in comment lines only. Regex is sufficient and language-agnostic.
|
|
60
|
+
|
|
61
|
+
### File Discovery (AC-95)
|
|
62
|
+
|
|
63
|
+
File discovery SHALL use `fs.readdirSync` with recursive walk:
|
|
64
|
+
|
|
65
|
+
```javascript
|
|
66
|
+
// ALLOWED: native recursive walk
|
|
67
|
+
function walk(dir, exclude) {
|
|
68
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
69
|
+
for (const entry of entries) {
|
|
70
|
+
if (entry.isDirectory() && !exclude.includes(entry.name)) {
|
|
71
|
+
walk(path.join(dir, entry.name), exclude);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// FORBIDDEN: glob npm package
|
|
77
|
+
const glob = require('glob'); // DO NOT USE
|
|
78
|
+
|
|
79
|
+
// FORBIDDEN: fast-glob
|
|
80
|
+
const fg = require('fast-glob'); // DO NOT USE
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**Note:** Node.js 22+ has `fs.glob()` built-in, but we target Node.js >=20.0.0 so cannot rely on it.
|
|
84
|
+
|
|
85
|
+
### CLI Argument Parsing (AC-96)
|
|
86
|
+
|
|
87
|
+
CLI arguments SHALL use the existing `parseNamedArgs()` pattern from `gsd-tools.cjs`:
|
|
88
|
+
|
|
89
|
+
```javascript
|
|
90
|
+
// ALLOWED: existing parseNamedArgs() pattern
|
|
91
|
+
const args = parseNamedArgs(process.argv.slice(2));
|
|
92
|
+
|
|
93
|
+
// FORBIDDEN: commander
|
|
94
|
+
const { program } = require('commander'); // DO NOT USE
|
|
95
|
+
|
|
96
|
+
// FORBIDDEN: yargs
|
|
97
|
+
const yargs = require('yargs'); // DO NOT USE
|
|
98
|
+
|
|
99
|
+
// FORBIDDEN: oclif
|
|
100
|
+
const { Command } = require('@oclif/core'); // DO NOT USE
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Dev Dependencies (Allowed)
|
|
106
|
+
|
|
107
|
+
These are allowed as `devDependencies` because they do NOT ship with the package:
|
|
108
|
+
|
|
109
|
+
| Package | Purpose |
|
|
110
|
+
|---------|---------|
|
|
111
|
+
| `esbuild` | Build tool -- bundles hooks for distribution |
|
|
112
|
+
| `c8` | Code coverage reporting |
|
|
113
|
+
| `vitest` | SDK TypeScript tests only (scoped to `sdk/`) |
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## Context7 Exception
|
|
118
|
+
|
|
119
|
+
Context7 (`ctx7`) is invoked via `npx ctx7@latest` through `child_process.execSync`. This is NOT a runtime dependency -- it is an external CLI tool that the user may or may not have installed. The code handles its absence gracefully:
|
|
120
|
+
|
|
121
|
+
```javascript
|
|
122
|
+
try {
|
|
123
|
+
const output = execSync('npx ctx7@latest docs ...', { timeout: 60000 });
|
|
124
|
+
} catch (_e) {
|
|
125
|
+
// ctx7 not available -- return graceful failure
|
|
126
|
+
return { success: false, error: 'Context7 unreachable' };
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## Verification
|
|
133
|
+
|
|
134
|
+
To verify zero runtime dependencies:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
# Check package.json has no dependencies
|
|
138
|
+
node -e "const pkg = require('./package.json'); console.log(Object.keys(pkg.dependencies || {}).length === 0 ? 'PASS' : 'FAIL')"
|
|
139
|
+
|
|
140
|
+
# Check no external requires in lib files
|
|
141
|
+
grep -rn "require(" cap/bin/lib/cap-*.cjs | grep -v "node:" | grep -v "require('./cap-" | grep -v "require('../"
|
|
142
|
+
# Should return empty (no external requires)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Testing Infrastructure (AC-100, AC-101, AC-102)
|
|
148
|
+
|
|
149
|
+
<!-- @gsd-todo(ref:AC-100) All CJS code tested with node:test and node:assert -->
|
|
150
|
+
<!-- @gsd-todo(ref:AC-101) SDK TypeScript code tested with vitest -- scoped via vitest.config.ts -->
|
|
151
|
+
<!-- @gsd-todo(ref:AC-102) Coverage measured with c8 with minimum 70% line coverage threshold -->
|
|
152
|
+
|
|
153
|
+
| Layer | Test Framework | Coverage Tool | Threshold |
|
|
154
|
+
|-------|---------------|---------------|-----------|
|
|
155
|
+
| CJS (`cap/bin/lib/*.cjs`) | `node:test` + `node:assert` | `c8` | 70% lines |
|
|
156
|
+
| SDK (`sdk/src/**/*.ts`) | `vitest` | vitest built-in | 70% lines |
|
|
157
|
+
|
|
158
|
+
**NEVER use vitest for CJS tests. NEVER use node:test for SDK TypeScript tests.**
|