@tekyzinc/gsd-t 2.50.12 → 2.53.10
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/CHANGELOG.md +24 -0
- package/README.md +379 -372
- package/bin/component-registry.js +250 -0
- package/bin/graph-cgc.js +510 -510
- package/bin/graph-indexer.js +147 -147
- package/bin/graph-overlay.js +195 -195
- package/bin/graph-parsers.js +327 -327
- package/bin/graph-query.js +453 -452
- package/bin/graph-store.js +154 -154
- package/bin/qa-calibrator.js +194 -0
- package/bin/scan-data-collector.js +153 -153
- package/bin/scan-diagrams-generators.js +187 -187
- package/bin/scan-diagrams.js +79 -79
- package/bin/scan-renderer.js +92 -92
- package/bin/scan-report-sections.js +121 -121
- package/bin/scan-report.js +184 -184
- package/bin/scan-schema-parsers.js +199 -199
- package/bin/scan-schema.js +103 -103
- package/bin/token-budget.js +246 -0
- package/commands/Claude-md.md +10 -10
- package/commands/branch.md +15 -15
- package/commands/checkin.md +45 -45
- package/commands/global-change.md +209 -209
- package/commands/gsd-t-audit.md +199 -0
- package/commands/gsd-t-backlog-add.md +94 -94
- package/commands/gsd-t-backlog-edit.md +111 -111
- package/commands/gsd-t-backlog-list.md +63 -63
- package/commands/gsd-t-backlog-move.md +94 -94
- package/commands/gsd-t-backlog-promote.md +123 -123
- package/commands/gsd-t-backlog-remove.md +86 -86
- package/commands/gsd-t-backlog-settings.md +158 -158
- package/commands/gsd-t-complete-milestone.md +528 -515
- package/commands/gsd-t-debug.md +506 -399
- package/commands/gsd-t-discuss.md +174 -174
- package/commands/gsd-t-execute.md +758 -634
- package/commands/gsd-t-feature.md +276 -276
- package/commands/gsd-t-health.md +142 -142
- package/commands/gsd-t-help.md +465 -457
- package/commands/gsd-t-impact.md +302 -302
- package/commands/gsd-t-init.md +320 -280
- package/commands/gsd-t-integrate.md +365 -249
- package/commands/gsd-t-milestone.md +87 -87
- package/commands/gsd-t-partition.md +442 -361
- package/commands/gsd-t-pause.md +82 -82
- package/commands/gsd-t-plan.md +345 -344
- package/commands/gsd-t-populate.md +111 -111
- package/commands/gsd-t-prd.md +326 -326
- package/commands/gsd-t-project.md +211 -211
- package/commands/gsd-t-promote-debt.md +123 -123
- package/commands/gsd-t-prompt.md +137 -137
- package/commands/gsd-t-qa.md +266 -266
- package/commands/gsd-t-quick.md +357 -234
- package/commands/gsd-t-reflect.md +134 -134
- package/commands/gsd-t-resume.md +72 -72
- package/commands/gsd-t-scan.md +615 -615
- package/commands/gsd-t-setup.md +76 -0
- package/commands/gsd-t-status.md +192 -166
- package/commands/gsd-t-test-sync.md +381 -381
- package/commands/gsd-t-triage-and-merge.md +171 -171
- package/commands/gsd-t-verify.md +382 -382
- package/commands/gsd-t-visualize.md +118 -118
- package/commands/gsd-t-wave.md +401 -378
- package/docs/GSD-T-README.md +425 -422
- package/docs/architecture.md +385 -369
- package/docs/harness-design-analysis.md +371 -0
- package/docs/infrastructure.md +205 -205
- package/docs/prd-graph-engine.md +398 -398
- package/docs/prd-gsd2-hybrid.md +559 -559
- package/docs/prd-harness-evolution.md +583 -0
- package/docs/requirements.md +14 -0
- package/docs/workflows.md +226 -226
- package/examples/.gsd-t/domains/example-domain/scope.md +13 -13
- package/package.json +40 -40
- package/scripts/gsd-t-auto-route.js +39 -39
- package/scripts/gsd-t-dashboard-mockup.html +1143 -1143
- package/scripts/gsd-t-dashboard-server.js +171 -171
- package/scripts/gsd-t-dashboard.html +262 -262
- package/scripts/gsd-t-event-writer.js +128 -128
- package/scripts/gsd-t-statusline.js +94 -94
- package/scripts/gsd-t-tools.js +175 -175
- package/templates/CLAUDE-global.md +639 -614
- package/templates/CLAUDE-project.md +24 -0
- package/templates/backlog-settings.md +18 -18
- package/templates/backlog.md +1 -1
- package/templates/progress.md +40 -40
- package/templates/shared-services-contract.md +60 -60
- package/templates/stacks/desktop.ini +2 -2
- package/bin/desktop.ini +0 -2
- package/commands/desktop.ini +0 -2
- package/docs/ci-examples/desktop.ini +0 -2
- package/docs/desktop.ini +0 -2
- package/examples/.gsd-t/contracts/desktop.ini +0 -2
- package/examples/.gsd-t/desktop.ini +0 -2
- package/examples/.gsd-t/domains/desktop.ini +0 -2
- package/examples/.gsd-t/domains/example-domain/desktop.ini +0 -2
- package/examples/desktop.ini +0 -2
- package/examples/rules/desktop.ini +0 -2
- package/scripts/desktop.ini +0 -2
- package/templates/desktop.ini +0 -2
package/docs/architecture.md
CHANGED
|
@@ -1,369 +1,385 @@
|
|
|
1
|
-
# Architecture — GSD-T Framework (@tekyzinc/gsd-t)
|
|
2
|
-
|
|
3
|
-
## Last Updated: 2026-03-22 (M23 — Headless Mode)
|
|
4
|
-
|
|
5
|
-
## System Overview
|
|
6
|
-
|
|
7
|
-
GSD-T is an npm-distributed methodology framework for Claude Code. It provides slash commands (markdown files), a CLI installer (Node.js), and document templates that together enable contract-driven development with AI assistance.
|
|
8
|
-
|
|
9
|
-
The framework has no runtime — it is consumed entirely by Claude Code's slash command system and the user's shell. The CLI handles installation, updates, and diagnostics. The command files define the workflow methodology that Claude Code follows.
|
|
10
|
-
|
|
11
|
-
**Architecture Pattern**: Distributed Markdown Instruction System with CLI Lifecycle Manager. Command files are the "source code" interpreted by Claude Code. The CLI is a lifecycle manager (install/update/init/status/doctor/uninstall). State files persist across sessions as git-tracked Markdown.
|
|
12
|
-
|
|
13
|
-
## Components
|
|
14
|
-
|
|
15
|
-
### CLI Installer (bin/gsd-t.js)
|
|
16
|
-
- **Purpose**: Install, update, diagnose, and manage GSD-T across projects
|
|
17
|
-
- **Location**: `bin/gsd-t.js` (1,798 lines, 90+ functions, all ≤ 30 lines)
|
|
18
|
-
- **Dependencies**: Node.js built-ins only (fs, path, os, child_process, https, crypto)
|
|
19
|
-
- **Subcommands**: install, update, status, doctor, init, uninstall, update-all, register, changelog, graph (index/status/query), headless (exec/query/--debug-loop)
|
|
20
|
-
- **Organization**: Configuration → Guard section → Helpers → Heartbeat → Commands → Install/Update → Init → Status → Uninstall → Update-All → Doctor → Register → Update Check → Help → Main dispatch
|
|
21
|
-
- **All functions ≤ 30 lines** (M6 refactoring). Largest: `doRegister()` at 30 lines, `summarize()` at 30 lines.
|
|
22
|
-
|
|
23
|
-
### Slash Commands (commands/*.md)
|
|
24
|
-
- **Purpose**: Define the GSD-T methodology as executable workflows for Claude Code
|
|
25
|
-
- **Location**: `commands/`
|
|
26
|
-
- **Count**: 49 (45 GSD-T workflow + 4 utility: gsd, branch, checkin, Claude-md, global-change) — includes gsd-t-health, gsd-t-pause (M13), gsd-t-reflect (M14), gsd-t-visualize (M15), gsd-t-prd (M16), global-change (M20)
|
|
27
|
-
- **Format**: Pure markdown with step-numbered instructions, team mode blocks, document ripple sections, and $ARGUMENTS terminator
|
|
28
|
-
|
|
29
|
-
### Templates (templates/*.md)
|
|
30
|
-
- **Purpose**: Starter files for project initialization
|
|
31
|
-
- **Location**: `templates/`
|
|
32
|
-
- **Count**: 9 (CLAUDE-global, CLAUDE-project, requirements, architecture, workflows, infrastructure, progress, backlog, backlog-settings)
|
|
33
|
-
- **Tokens**: `{Project Name}` and `{Date}` replaced during init via `applyTokens()`
|
|
34
|
-
|
|
35
|
-
### Hook Scripts (scripts/)
|
|
36
|
-
- **gsd-t-heartbeat.js** (181 lines, 6 functions, 5 exports): Real-time event logging via Claude Code hooks. Captures 9 event types as structured JSONL. Input capped at 1MB. Session ID validated. Path traversal protection. Secret scrubbing via `scrubSecrets()`/`scrubUrl()` (M5). Notification message + title scrubbing (M8/M9). EVENT_HANDLERS map pattern (M6). Auto-cleanup after 7 days (SessionStart only, M6). M14: added `buildEventStreamEntry()` (maps SubagentStart/Stop/PostToolUse → events/ schema) and `appendToEventsFile()` (daily-rotated JSONL in `.gsd-t/events/`, symlink-safe).
|
|
37
|
-
- **gsd-t-event-writer.js** (124 lines, 3 exports, NEW in M14): Zero-dep CLI tool + module for structured JSONL event appends to `.gsd-t/events/`. Exports: `validateEvent()`, `resolveEventsFile()`, `appendEvent()`. CLI: `--type`, `--command`, `--phase`, `--reasoning`, `--outcome`, `--agent-id`. Validates all 8 event_type values and 5 outcome values from event-schema-contract. Installed to `~/.claude/scripts/` by CLI installer. Exit codes: 0 success, 1 write error, 2 validation error.
|
|
38
|
-
- **npm-update-check.js** (43 lines): Background npm registry version checker. Spawned detached by CLI when update cache is stale. Path validation within `~/.claude/` (M5). Symlink check before write (M5). 1MB response limit (M5).
|
|
39
|
-
- **gsd-t-fetch-version.js** (26 lines, NEW in M6): Synchronous npm registry fetch. Called by `fetchVersionSync()` via `execFileSync`. HTTPS-only, 5s timeout, 1MB limit. Silent failure on errors (caller validates).
|
|
40
|
-
- **gsd-t-tools.js** (163 lines, NEW in M13): State utility CLI returning compact JSON. Subcommands: state get/set (progress.md), validate (required file presence), parse progress --section, list domains/contracts, git pre-commit-check, template scope/tasks. Zero external dependencies. NOTE: No module.exports — untestable as module (TD-066).
|
|
41
|
-
- **gsd-t-statusline.js** (94 lines, NEW in M13): Context usage bar + project state for Claude Code `statusLine` setting. Reads CLAUDE_CONTEXT_TOKENS_USED/MAX env vars for usage percentage. Color-coded bar (green <50%, yellow <70%, orange <85%, red ≥85%). NOTE: No module.exports — untestable as module (TD-066).
|
|
42
|
-
|
|
43
|
-
### Execution Intelligence Layer (M14 — complete)
|
|
44
|
-
- **`.gsd-t/events/YYYY-MM-DD.jsonl`**: Append-only event stream. One event per line. Schema: `ts`, `event_type`, `command`, `phase`, `agent_id`, `parent_agent_id`, `trace_id`, `reasoning`, `outcome`. Written by hooks (SubagentStart/Stop, PostToolUse via heartbeat.js) and command files at phase transitions.
|
|
45
|
-
- **Outcome-tagged Decision Log**: New Decision Log entries use `[success]`/`[failure]`/`[learning]`/`[deferred]` prefixes for machine-readable filtering (execute, debug, wave, complete-milestone).
|
|
46
|
-
- **Pre-task experience retrieval (execute, debug)**: Grep Decision Log for `[failure]`/`[learning]` entries matching current domain before spawning subagent — Reflexion pattern without fine-tuning. Writes `experience_retrieval` event.
|
|
47
|
-
- **Distillation step (complete-milestone Step 2.5)**: Scans `.gsd-t/events/*.jsonl` for patterns seen ≥3 times, proposes CLAUDE.md / constraints.md rule additions, user confirms before write.
|
|
48
|
-
- **`commands/gsd-t-reflect.md`**: On-demand retrospective command (47th command). Reads current milestone events, generates `.gsd-t/retrospectives/YYYY-MM-DD-{milestone}.md` with sections: What Worked, What Failed, Patterns Found, Proposed Memory Updates.
|
|
49
|
-
|
|
50
|
-
### Auto-Route + Auto-Update Hooks (M16 — complete)
|
|
51
|
-
- **`scripts/gsd-t-auto-route.js`** (39 lines): UserPromptSubmit hook. Reads JSON from stdin (`{ prompt, cwd, session_id }`). If `.gsd-t/progress.md` does not exist in cwd → exits silently. If prompt starts with `/` → exits silently. If plain text in a GSD-T project → emits `[GSD-T AUTO-ROUTE]` signal to Claude's context, routing the message through `/user:gsd`. Catches all exceptions — never blocks the prompt.
|
|
52
|
-
- **`scripts/gsd-t-update-check.js`** (79 lines): SessionStart hook. Reads `~/.claude/.gsd-t-version`. Reads/refreshes `~/.claude/.gsd-t-update-check` cache (1h TTL). If newer version available: runs `npm install -g @tekyzinc/gsd-t@{latest}` + `gsd-t update-all` via execSync. Outputs `[GSD-T AUTO-UPDATE]`, `[GSD-T UPDATE]`, or `[GSD-T]` banner. NOTE: No module.exports — untestable as module (TD-081). Version string not validated before execSync (SEC-N28).
|
|
53
|
-
|
|
54
|
-
### Scan Visual Output (M17 — complete v2.34.10)
|
|
55
|
-
- **`bin/scan-schema.js`** (77 lines): ORM detector + schema extractor. Detects 7 ORM types (Prisma, TypeORM, Drizzle, Mongoose, Sequelize, SQLAlchemy, raw-SQL). Delegates to scan-schema-parsers.js. Returns SchemaData: `{ detected, ormType, entities[], parseWarnings[] }`. Never throws.
|
|
56
|
-
- **`bin/scan-schema-parsers.js`** (199 lines): 7 parser functions (parsePrisma, parseTypeOrm, parseDrizzle, parseMongoose, parseSequelize, parseSqlAlchemy, parseRawSql). Returns Entity[] for each ORM type.
|
|
57
|
-
- **`bin/scan-diagrams.js`** (77 lines): Diagram orchestrator. Calls scan-diagrams-generators.js for each of 6 types. Calls scan-renderer.js to render Mermaid to SVG. Always returns exactly 6 DiagramResult objects. Failed diagrams get placeholder HTML.
|
|
58
|
-
- **`bin/scan-diagrams-generators.js`** (102 lines): Mermaid DSL source generators for 6 types: genSystemArchitecture, genAppArchitecture, genWorkflow, genDataFlow, genSequence, genDatabaseSchema. Falls back to generic diagram if analysisData lacks specific fields.
|
|
59
|
-
- **`bin/scan-renderer.js`** (92 lines): Sync render chain: tryMmdc() → tryD2() → placeholder. Also contains tryKroki() (async, currently dormant — never called in sync path). Uses execSync (not execFileSync — see TD-084/SEC-N30).
|
|
60
|
-
- **`bin/scan-report.js`** (116 lines): Generates self-contained HTML scan report. No external CSS/JS (all inline). Output: `{projectRoot}/scan-report.html` (see TD-092 for placement issue). Exports: generateReport(), buildCss(), buildSidebar(), buildHtmlSkeleton() + section builders.
|
|
61
|
-
- **`bin/scan-report-sections.js`** (74 lines): HTML section builders: buildMetricCards, buildDomainHealth, buildDiagramSection, buildTechDebt, buildFindings.
|
|
62
|
-
- **`bin/scan-export.js`** (49 lines): Export subcommand — DOCX via pandoc, PDF via md-to-pdf. Checks tool availability before attempting. Uses execSync (not execFileSync — see TD-084/SEC-N29).
|
|
63
|
-
|
|
64
|
-
### Real-Time Agent Dashboard (M15 — complete v2.33.10)
|
|
65
|
-
- **`scripts/gsd-t-dashboard-server.js`** (141 lines, zero external deps): Node.js SSE server watching `.gsd-t/events/*.jsonl`. Exports: `startServer(port, eventsDir, htmlPath)`, `tailEventsFile(filePath, callback)`, `readExistingEvents(eventsDir, maxEvents)`, `parseEventLine(line)`, `findEventsDir(projectDir)`. HTTP endpoints: `GET /` (serve dashboard HTML), `GET /events` (SSE stream, max 500 events on connect + tail for new), `GET /ping` (health check), `GET /stop` (graceful shutdown). CLI: `--port`, `--events`, `--detach` (writes PID to `.gsd-t/dashboard.pid`), `--stop` (kills running server). Symlink protection via `lstatSync` pattern. 23 unit tests in `test/dashboard-server.test.js`.
|
|
66
|
-
- **`scripts/gsd-t-dashboard.html`** (194 lines): React 17 + React Flow v11.11.4 + Dagre via CDN (no build step, no npm deps). Dark theme (`#0d1117`). Renders agent hierarchy as directed graph from `parent_agent_id` relationships. Live event feed (max 200, outcome color-coded). Auto-reconnects on SSE disconnect. Port configurable via `?port=` URL param.
|
|
67
|
-
- **`commands/gsd-t-visualize.md`** (104 lines, 48th command): Starts server via `--detach`, polls `/ping` up to 5s, opens browser cross-platform (win32/darwin/linux). Accepts `stop` argument to shut down server. Step 0 self-spawn with OBSERVABILITY LOGGING.
|
|
68
|
-
|
|
69
|
-
### Headless Mode (M23 — complete)
|
|
70
|
-
- **doHeadless(args)**: Dispatch function for the `headless` CLI subcommand.
|
|
71
|
-
- **doHeadlessExec(command, cmdArgs, flags)**: Wraps `claude -p "/user:gsd-t-{command}"` via `execFileSync`. Verifies claude CLI availability, enforces timeout, writes log file if `--log` requested. Returns structured JSON if `--json` flag set.
|
|
72
|
-
- **parseHeadlessFlags(args)**: Extracts `--json`, `--timeout=N`, `--log` from raw args. Returns `{ flags, positional }`.
|
|
73
|
-
- **buildHeadlessCmd(command, cmdArgs)**: Builds the `/user:gsd-t-{command}` prompt string.
|
|
74
|
-
- **mapHeadlessExitCode(processExitCode, output)**: Maps process exit code + output text patterns to GSD-T exit codes (0–4).
|
|
75
|
-
- **headlessLogPath(projectDir, timestamp)**: Generates `.gsd-t/headless-{timestamp}.log` path.
|
|
76
|
-
- **doHeadlessQuery(type)**: Dispatches to one of 7 query functions. All pure Node.js file reads, no LLM calls, <100ms.
|
|
77
|
-
- **Query functions** (7): `queryStatus`, `queryDomains`, `queryContracts`, `queryDebt`, `queryContext`, `queryBacklog`, `queryGraph` — each reads corresponding `.gsd-t/` file and returns typed JSON result.
|
|
78
|
-
- **Exit codes**: 0=success, 1=verify-fail, 2=context-budget-exceeded, 3=error, 4=blocked-needs-human
|
|
79
|
-
- **CI/CD examples**: `docs/ci-examples/github-actions.yml` (GitHub Actions), `docs/ci-examples/gitlab-ci.yml` (GitLab CI)
|
|
80
|
-
|
|
81
|
-
### Compaction-Proof Debug Loop (M29 — complete)
|
|
82
|
-
- **bin/debug-ledger.js** (193 lines): JSONL-based debug persistence layer. 6 exported functions: `readLedger`, `appendEntry`, `compactLedger`, `generateAntiRepetitionPreamble`, `getLedgerStats`, `clearLedger`. Ledger file: `.gsd-t/debug-state.jsonl` (11-field schema per entry). Compaction triggers at 50KB — haiku session condenses history, last 5 raw entries preserved. Anti-repetition preamble lists all STILL_FAILS hypotheses, current narrowing direction, and tests still failing. Zero external deps.
|
|
83
|
-
- **doHeadlessDebugLoop(flags)**: External iteration manager in `bin/gsd-t.js`. Runs test-fix-retest as separate `claude -p` sessions — each session starts with zero accumulated context. Escalation tiers: sonnet (iterations 1-5), opus (6-15), STOP with full diagnostic output (16-20). `--max-iterations N` flag (default 20) enforced by external process.
|
|
84
|
-
- **parseDebugLoopFlags(args)**: Extracts `--max-iterations`, `--test-cmd`, `--fix-scope`, `--json`, `--log` from args. Defaults: maxIterations=20.
|
|
85
|
-
- **getEscalationModel(iteration)**: Returns "sonnet" for 1-5, "opus" for 6-15, null for 16-20 (STOP tier).
|
|
86
|
-
- **Command integration**: execute, wave, test-sync, verify, debug all delegate fix-retest loops to `gsd-t headless --debug-loop` after 2 in-context fix attempts.
|
|
87
|
-
- **Exit codes (debug-loop specific)**: 0=all tests pass (ledger cleared), 1=max iterations reached, 3=process error, 4=escalation stop (needs human)
|
|
88
|
-
|
|
89
|
-
### Graph Engine (M20 — complete)
|
|
90
|
-
- **`bin/graph-store.js`** (147 lines): File-based graph storage in `.gsd-t/graph/`. 8 JSON files (index, calls, imports, contracts, requirements, tests, surfaces, meta). Read/write operations, MD5 file hashing for incremental indexing, staleness detection. Zero external deps. Note: no symlink protection (TD-099).
|
|
91
|
-
- **`bin/graph-parsers.js`** (327 lines): Language-specific entity parsers. JS/TS: function declarations, arrow functions, classes, methods, imports (ES/CJS), exports. Python: def/class/import. Regex-based (no Tree-sitter). Returns `{ entities, imports, calls }`.
|
|
92
|
-
- **`bin/graph-overlay.js`** (195 lines): GSD-T context mapper. Enriches code entities with: domain ownership (from scope.md), contract mapping (from contracts/*.md), requirement traceability (from requirements.md), test mapping (from test/ files), debt mapping (from techdebt.md), surface detection (from directory structure). 8 exports. No dedicated test file (TD-100).
|
|
93
|
-
- **`bin/graph-indexer.js`** (147 lines): Project indexer. Walks source files, calls parsers, builds overlay, writes to storage. Incremental (skips unchanged files via content hash). Exports `indexProject(root, options)`.
|
|
94
|
-
- **`bin/graph-query.js`** (400 lines): Graph abstraction layer. Unified `query(type, params, root)` interface with 21 query types. 3-provider fallback: CGC MCP → native → grep. Provider registry with priority-based selection. Auto-triggers reindex on stale data. WARNING: grep fallback uses execSync with string interpolation — command injection risk (TD-097/SEC-C01).
|
|
95
|
-
- **`bin/graph-cgc.js`** (510 lines): CodeGraphContext MCP provider — fully integrated end-to-end. Communicates via JSON-RPC/stdio MCP protocol with CGC server backed by Neo4j (Docker container `gsd-t-neo4j`). 12+ query types: getCallers, getTransitiveCallers, getCallees, getTransitiveCallees, findDeadCode, findComplexFunctions, getComplexity, findDuplicates, findCircularDeps, getEntity, getCallChain, getModuleDeps, getClassHierarchy, getStats, cypher. Health detection (3s timeout, session-cached). Overlay enrichment maps CGC results to GSD-T domains/contracts/requirements. Auto-installed by `gsd-t install`.
|
|
96
|
-
- **`bin/scan-data-collector.js`** (153 lines, NEW in M20): Aggregates scan markdown files into structured data for report generation.
|
|
97
|
-
- **Storage**: `.gsd-t/graph/` directory (git-ignored). JSON files: index.json (entities), calls.json (edges), imports.json, contracts.json, requirements.json, tests.json, surfaces.json, meta.json (file hashes + stats).
|
|
98
|
-
|
|
99
|
-
### Examples (examples/)
|
|
100
|
-
- **Purpose**: Reference project structure and settings
|
|
101
|
-
- **Location**: `examples/`
|
|
102
|
-
- **Contents**: settings.json, .gsd-t/ with sample contracts and domain structure
|
|
103
|
-
|
|
104
|
-
## Data Flow
|
|
105
|
-
|
|
106
|
-
### Installation Flow
|
|
107
|
-
```
|
|
108
|
-
npm install @tekyzinc/gsd-t → bin/gsd-t.js install
|
|
109
|
-
├── Copy commands/*.md → ~/.claude/commands/
|
|
110
|
-
├── Copy/append templates/CLAUDE-global.md → ~/.claude/CLAUDE.md
|
|
111
|
-
├── Copy scripts/gsd-t-heartbeat.js → ~/.claude/scripts/
|
|
112
|
-
├── Configure 9 hooks in ~/.claude/settings.json
|
|
113
|
-
├── Copy scripts/gsd-t-tools.js → ~/.claude/scripts/ (installUtilityScripts, M13)
|
|
114
|
-
├── Copy scripts/gsd-t-statusline.js → ~/.claude/scripts/ (installUtilityScripts, M13)
|
|
115
|
-
└── Write version to ~/.claude/.gsd-t-version
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
### Project Initialization Flow
|
|
119
|
-
```
|
|
120
|
-
gsd-t init [name] → templates/ → applyTokens()
|
|
121
|
-
├── → {project}/CLAUDE.md
|
|
122
|
-
├── → {project}/docs/{requirements,architecture,workflows,infrastructure}.md
|
|
123
|
-
├── → {project}/.gsd-t/{progress,backlog,backlog-settings}.md
|
|
124
|
-
└── → {project}/.gsd-t/{contracts,domains}/.gitkeep
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
### Runtime Command Execution (within Claude Code)
|
|
128
|
-
```
|
|
129
|
-
User types /user:gsd-t-{command} [args]
|
|
130
|
-
→ Claude Code loads ~/.claude/commands/gsd-t-{command}.md
|
|
131
|
-
→ Claude interprets step-by-step instructions
|
|
132
|
-
→ Reads state files → Executes workflow → Pre-Commit Gate → Updates progress.md
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
### Update Check Flow
|
|
136
|
-
```
|
|
137
|
-
CLI command → Read cache (~/.claude/.gsd-t-update-check)
|
|
138
|
-
├── Fresh (<1h): Show notice if latest > installed
|
|
139
|
-
├── No cache: Synchronous fetch → cache → show notice
|
|
140
|
-
└── Stale (>1h): Spawn background scripts/npm-update-check.js
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
## Configuration Model
|
|
144
|
-
|
|
145
|
-
Three-tier configuration:
|
|
146
|
-
|
|
147
|
-
| Layer | Location | Purpose |
|
|
148
|
-
|-------|----------|---------|
|
|
149
|
-
| **Global** | `~/.claude/CLAUDE.md` | Framework defaults: autonomy rules, code standards, pre-commit gate |
|
|
150
|
-
| **Project** | `{cwd}/CLAUDE.md` | Project-specific: tech stack, branch guard, conventions, overrides |
|
|
151
|
-
| **State** | `{cwd}/.gsd-t/` | Live state: progress, contracts, domains, backlog, scan results |
|
|
152
|
-
|
|
153
|
-
## State Files
|
|
154
|
-
|
|
155
|
-
| File | Purpose | Read By | Written By |
|
|
156
|
-
|------|---------|---------|------------|
|
|
157
|
-
| `progress.md` | Master state, version, decision log | All commands | Most commands |
|
|
158
|
-
| `contracts/*.md` | Domain interfaces | execute, integrate, verify | partition |
|
|
159
|
-
| `domains/{name}/scope.md` | File ownership | execute, quick | partition |
|
|
160
|
-
| `domains/{name}/tasks.md` | Task list | execute, status, resume | plan, execute |
|
|
161
|
-
| `backlog.md` | Priority-ordered backlog | backlog-list, status | backlog-add/edit/move/remove |
|
|
162
|
-
| `backlog-settings.md` | Types, apps, categories | backlog-add/edit/settings | backlog-settings, init |
|
|
163
|
-
| `techdebt.md` | Prioritized tech debt | promote-debt, scan | scan |
|
|
164
|
-
| `scan/*.md` | Codebase analysis | scan (synthesis), setup | scan (teammates) |
|
|
165
|
-
| `CONTEXT.md` | Discuss phase output — Locked Decisions, Deferred Ideas | plan (reads + enforces) | discuss |
|
|
166
|
-
| `continue-here-{ts}.md` | Pause/resume checkpoint — exact position | resume (reads + deletes) | pause |
|
|
167
|
-
| `deferred-items.md` | Log of unresolved issues from execute/quick/debug | (manual review) | execute, quick, debug |
|
|
168
|
-
|
|
169
|
-
## Data Models
|
|
170
|
-
|
|
171
|
-
### Progress State (.gsd-t/progress.md)
|
|
172
|
-
| Field | Type | Notes |
|
|
173
|
-
|-------|------|-------|
|
|
174
|
-
| Project | string | Name from CLAUDE.md |
|
|
175
|
-
| Version | semver | Major.Minor.Patch |
|
|
176
|
-
| Status | enum | READY, INITIALIZED, PARTITIONED, DISCUSSED, PLANNED, IMPACT_ANALYZED, EXECUTING, EXECUTED, TESTS_SYNCED, INTEGRATED, VERIFIED, VERIFY_FAILED, COMPLETED |
|
|
177
|
-
| Current Milestone | string | Active milestone name or "None" |
|
|
178
|
-
| Decision Log | entries | Timestamped log of all changes |
|
|
179
|
-
|
|
180
|
-
### Backlog (.gsd-t/backlog.md)
|
|
181
|
-
| Field | Type | Notes |
|
|
182
|
-
|-------|------|-------|
|
|
183
|
-
| Position | integer | Sequential, 1 = highest priority |
|
|
184
|
-
| Type | enum | bug, feature, improvement, ux, architecture |
|
|
185
|
-
| App | string | Target application |
|
|
186
|
-
| Category | string | Domain/module category |
|
|
187
|
-
| Description | string | Item summary |
|
|
188
|
-
|
|
189
|
-
### Contracts (.gsd-t/contracts/)
|
|
190
|
-
| Contract | Purpose |
|
|
191
|
-
|----------|---------|
|
|
192
|
-
| backlog-command-interface.md | Backlog command interface and promote flow |
|
|
193
|
-
| integration-points.md | How components connect |
|
|
194
|
-
| backlog-file-formats.md | Backlog markdown structure (authoritative — duplicate file-format-contract.md deleted in M9) |
|
|
195
|
-
| domain-structure.md | Domain directory layout |
|
|
196
|
-
| pre-commit-gate.md | Commit checklist contract |
|
|
197
|
-
| progress-file-format.md | Progress.md structure |
|
|
198
|
-
| wave-phase-sequence.md | Phase ordering rules |
|
|
199
|
-
| qa-agent-contract.md | QA agent spawn interface, output per phase, communication protocol |
|
|
200
|
-
|
|
201
|
-
## Workflow Phase Architecture
|
|
202
|
-
|
|
203
|
-
```
|
|
204
|
-
PARTITION → DISCUSS → PLAN → IMPACT → EXECUTE → TEST-SYNC → INTEGRATE → VERIFY → COMPLETE
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
| Phase | Mode | QA Agent | Why |
|
|
208
|
-
|-------|------|----------|-----|
|
|
209
|
-
| Partition | Solo only | NO (removed M10) | Was unnecessary overhead |
|
|
210
|
-
| Discuss | Solo only | No | Always pauses for user input (even Level 3) |
|
|
211
|
-
| Plan | Solo only | NO (removed M10) | Was unnecessary overhead |
|
|
212
|
-
| Impact | Solo only | No | Cross-cutting analysis |
|
|
213
|
-
| Execute | Solo or Team | Task subagent (M10) | Each task gets QA after completion |
|
|
214
|
-
| Test-Sync | Solo only | Inline (M10) | Sequential contract coverage audit |
|
|
215
|
-
| Integrate | Solo only | Task subagent (M10) | Cross-domain integration tests |
|
|
216
|
-
| Verify | Solo or Team | Inline (M10) | Full audit runs directly |
|
|
217
|
-
| Complete | Solo only | Inline (M10) | Final gate runs directly |
|
|
218
|
-
|
|
219
|
-
### Wave Orchestrator (Agent-Per-Phase Model)
|
|
220
|
-
|
|
221
|
-
The wave command spawns an independent agent for each phase via the Task tool with `bypassPermissions`. Each phase agent gets a fresh ~200K token context window, eliminating context accumulation and mid-wave compaction. The orchestrator itself stays lightweight (~30KB), reading only `progress.md` and `CLAUDE.md`. State handoff between phases occurs through `.gsd-t/` files.
|
|
222
|
-
|
|
223
|
-
### QA Agent Integration (Updated M10)
|
|
224
|
-
|
|
225
|
-
QA runs inline or as Task subagent depending on phase (M10 refactor). Removed from partition and plan (were unnecessary). execute and integrate spawn QA as Task subagent after each domain checkpoint. test-sync, verify, and complete-milestone run QA inline. QA failure blocks phase completion (user override available).
|
|
226
|
-
|
|
227
|
-
### Execution Quality (M11)
|
|
228
|
-
|
|
229
|
-
**Deviation Rules**: 4-rule protocol added to execute, quick, debug: (1) Bug → fix up to 3 attempts, then defer; (2) Missing dependency → add minimum; (3) Blocker → fix and log; (4) Architectural change → STOP, apply Destructive Action Guard.
|
|
230
|
-
|
|
231
|
-
**Per-Task Commits**: execute enforces `feat({domain}/task-{N})` commit format after each task. Wave spot-check verifies commits were made.
|
|
232
|
-
|
|
233
|
-
**Between-Phase Spot-Check (Wave)**: After each phase agent completes, wave reads progress.md (status), runs git log (commits), and verifies filesystem output. Re-spawns phase agent once on failure. Stops and reports to user if still failing.
|
|
234
|
-
|
|
235
|
-
### Planning Intelligence (M12)
|
|
236
|
-
|
|
237
|
-
**CONTEXT.md**: discuss phase creates `.gsd-t/CONTEXT.md` with three sections: Locked Decisions (plan MUST implement), Deferred Ideas (plan must NOT implement), Claude's Discretion (implementation details left to executor). Plan reads CONTEXT.md and fails validation if any Locked Decision has no task mapping.
|
|
238
|
-
|
|
239
|
-
**Plan Validation**: After creating task lists, plan spawns a Task subagent to validate REQ coverage, Locked Decision mapping, task completeness, contract existence. Max 3 fix iterations before stopping and reporting to user.
|
|
240
|
-
|
|
241
|
-
**REQ Traceability**: Plan writes a traceability table to docs/requirements.md mapping REQ-IDs to domain/task/status. Verify marks matched requirements complete.
|
|
242
|
-
|
|
243
|
-
### Tooling & UX (M13)
|
|
244
|
-
|
|
245
|
-
**gsd-t-tools.js**: State utility CLI for Claude Code agents. Reduces token-heavy markdown parsing with compact JSON responses. Installed to `~/.claude/scripts/`. See Hook Scripts section.
|
|
246
|
-
|
|
247
|
-
**gsd-t-statusline.js**: Visual context usage bar for Claude Code `statusLine` setting. Shows milestone, status, version, and context percentage. Installed to `~/.claude/scripts/`.
|
|
248
|
-
|
|
249
|
-
**gsd-t-health**: New command — validates .gsd-t/ structure against 12 required items. `--repair` creates missing files from templates. Step 0 subagent pattern.
|
|
250
|
-
|
|
251
|
-
**gsd-t-pause**: New command — creates `.gsd-t/continue-here-{timestamp}.md` with exact position snapshot. More precise than progress.md alone.
|
|
252
|
-
|
|
253
|
-
**gsd-t-resume** (updated): Reads continue-here files first (most recent by timestamp), falls back to progress.md. Deletes continue-here file after reading.
|
|
254
|
-
|
|
255
|
-
### Test Suite (test/)
|
|
256
|
-
- **helpers.test.js** (27 tests): Pure helper functions — validateProjectName, applyTokens, isNewerVersion, normalizeEol, etc.
|
|
257
|
-
- **filesystem.test.js** (37 tests): Filesystem helpers + CLI subcommand integration — ensureDir, isSymlink, writeTemplateFile, status/doctor/help outputs
|
|
258
|
-
- **security.test.js** (30 tests): Security functions — scrubSecrets (18), scrubUrl (5), summarize integration (4), hasSymlinkInPath (3)
|
|
259
|
-
- **cli-quality.test.js** (22 tests): M6 refactored functions — buildEvent (10), readProjectDeps (3), readPyContent (2), insertGuardSection (3), readUpdateCache (1), addHeartbeatHook (3)
|
|
260
|
-
- **Runner**: Node.js built-in (`node --test`), zero test dependencies
|
|
261
|
-
- **Total**: 125 tests, all passing (post-M9)
|
|
262
|
-
|
|
263
|
-
## Security Model
|
|
264
|
-
|
|
265
|
-
- **Zero dependencies**: No supply chain attack surface
|
|
266
|
-
- **Symlink protection**: `isSymlink()` at 15+ write sites + `hasSymlinkInPath()` for parent directory validation (M5)
|
|
267
|
-
- **Secret scrubbing**: `scrubSecrets()` masks passwords/tokens/API keys in heartbeat logs; `scrubUrl()` masks URL query params (M5)
|
|
268
|
-
- **Input validation**: Project names, version strings, session IDs, project paths all validated
|
|
269
|
-
- **Path traversal prevention**: Heartbeat validates session_id regex, resolves paths, verifies containment; npm-update-check validates cache path within `~/.claude/` (M5)
|
|
270
|
-
- **Command injection mitigation**: `execFileSync` with array args (not `execSync`)
|
|
271
|
-
- **Exclusive file creation**: Init uses `{ flag: "wx" }` for atomic create-or-fail
|
|
272
|
-
- **Resource limits**: Heartbeat stdin capped at 1MB, HTTP responses capped at 1MB (M5), 5s/8s timeouts, 7-day file cleanup
|
|
273
|
-
- **Wave security**: `bypassPermissions` mode documented with attack surface analysis and mitigations (M5)
|
|
274
|
-
|
|
275
|
-
## Design Decisions
|
|
276
|
-
|
|
277
|
-
| Date | Decision | Rationale | Alternatives Considered |
|
|
278
|
-
|------|----------|-----------|------------------------|
|
|
279
|
-
| 2026-02-07 | Zero external dependencies for CLI | Simplicity, no install failures, no supply chain risk | Using commander.js, yargs |
|
|
280
|
-
| 2026-02-07 | Markdown-only command files | Claude Code native format, no build step, human-readable | YAML frontmatter, JSON config |
|
|
281
|
-
| 2026-02-09 | Semantic versioning with git tags | Standard npm practice, enables update checks | CalVer, build numbers |
|
|
282
|
-
| 2026-02-12 | Heartbeat via Claude Code hooks | Non-invasive monitoring, no command file changes needed | Polling, WebSocket |
|
|
283
|
-
| 2026-02-13 | Semantic router over keyword matching | Better intent detection, fewer misroutes | Regex patterns, ML classifier |
|
|
284
|
-
| 2026-02-16 | Mandatory Playwright for all projects | Consistent E2E testing, no "we'll add tests later" | Optional testing, Jest-only |
|
|
285
|
-
| 2026-02-16 | Team mode default for scan | Parallel scanning faster, better results | Solo sequential scan |
|
|
286
|
-
| 2026-02-17 | QA Agent as cross-cutting concern | Mandatory test-driven contracts for all code phases | Optional testing, deferred testing |
|
|
287
|
-
| 2026-02-17 | Agent-per-phase wave orchestration | Fresh context window per phase, eliminates compaction | Inline execution (original approach) |
|
|
288
|
-
| 2026-02-18 | QA refactor — remove from partition/plan, Task subagent for execute/integrate | QA on partition/plan added overhead with little value; Task subagent gives QA fresh context | Teammate QA (original), no QA |
|
|
289
|
-
| 2026-02-18 | Deviation Rules + 3-attempt limit | Prevents infinite loops; auto-fixes bugs without blocking; escalates architectural changes | Manual escalation only, no auto-fix |
|
|
290
|
-
| 2026-02-18 | CONTEXT.md from discuss phase | Structured handoff between discuss and plan; fidelity enforcement on Locked Decisions | Free-form decisions in progress.md |
|
|
291
|
-
| 2026-02-18 | gsd-t-tools.js as state utility CLI | Reduces token-heavy markdown parsing; compact JSON responses save ~50K tokens/wave | Parsing progress.md inline (original) |
|
|
292
|
-
| 2026-02-18 | continue-here files for pause/resume | More precise than progress.md; captures exact task+next-action, not just phase | progress.md alone (less precise) |
|
|
293
|
-
|
|
294
|
-
### GSD 2 Tier 1 — Execution Quality (M22 — complete v2.40.10)
|
|
295
|
-
|
|
296
|
-
Five interlocking capabilities eliminate context rot, enable safe parallel execution, and verify behavior rather than structure alone.
|
|
297
|
-
|
|
298
|
-
**Task-Level Fresh Dispatch**
|
|
299
|
-
|
|
300
|
-
Execute dispatches one subagent per TASK (not per domain). Each task agent gets a fresh context window containing only: domain scope.md, relevant contracts, the single current task, graph context for touched files, and prior task summaries (10-20 lines each). Context utilization per task: ~10-20% (down from 60-75% cumulative per domain). Compaction never triggers. The domain dispatcher (lightweight orchestrator) sequences tasks and passes summaries — it never accumulates full task context.
|
|
301
|
-
|
|
302
|
-
```
|
|
303
|
-
Execute orchestrator (summaries only — ~4-8% ctx)
|
|
304
|
-
└── Domain-A task-dispatcher
|
|
305
|
-
├── Task 1 subagent (fresh, 10-20% ctx) → summary → dies
|
|
306
|
-
├── Task 2 subagent (fresh + task 1 summary) → summary → dies
|
|
307
|
-
└── Task N subagent (fresh + prior summaries) → summary → dies
|
|
308
|
-
```
|
|
309
|
-
|
|
310
|
-
**Plan command constraint** (added M22): Every task must fit in one context window. If estimated scope exceeds 70% context, plan splits the task automatically.
|
|
311
|
-
|
|
312
|
-
**Worktree Isolation**
|
|
313
|
-
|
|
314
|
-
Parallel domain agents work in isolated git worktrees via Agent tool's `isolation: "worktree"` parameter. No shared filesystem — domains cannot step on each other's files. Merges are sequential and atomic:
|
|
315
|
-
|
|
316
|
-
```
|
|
317
|
-
Dispatch N domains (isolation: "worktree") → parallel execution
|
|
318
|
-
└── Domain A completes → merge A → run integration tests
|
|
319
|
-
└── Domain B completes → merge B → run integration tests
|
|
320
|
-
└── Conflict or test failure → rollback that domain, others unaffected
|
|
321
|
-
```
|
|
322
|
-
|
|
323
|
-
Rollback granularity is per-domain (not per-commit). Worktrees are cleaned up after all merges complete.
|
|
324
|
-
|
|
325
|
-
**Goal-Backward Verification**
|
|
326
|
-
|
|
327
|
-
After all structural quality gates pass (tests, contracts, file existence), a goal-backward pass verifies behavior. Reads milestone goals, traces each requirement to code, and checks for placeholders:
|
|
328
|
-
- `console.log("TODO")` / `console.log("implement X")`
|
|
329
|
-
- Hardcoded return values (`return "Synced"`, `return 200` on a path that should compute)
|
|
330
|
-
- `// TODO`, `// FIXME`, `// PLACEHOLDER` comments in critical paths
|
|
331
|
-
- UI components rendering static strings where dynamic data is required
|
|
332
|
-
|
|
333
|
-
Applied in: `verify`, `complete-milestone`, `wave` (verification phase).
|
|
334
|
-
|
|
335
|
-
**Adaptive Replanning**
|
|
336
|
-
|
|
337
|
-
After each domain completes in execute, the orchestrator reads the domain's result summary and evaluates whether remaining domain plans remain valid. If execution revealed new constraints (deprecated API, schema mismatch, missing dependency, incompatible library), affected domain `tasks.md` files are rewritten on disk before the next domain is dispatched.
|
|
338
|
-
|
|
339
|
-
Guard: max 2 replanning cycles per execute run. After that, pause for user input (prevents new-constraint → replan → new-constraint loops).
|
|
340
|
-
|
|
341
|
-
**Context Observability**
|
|
342
|
-
|
|
343
|
-
Extended token-log.md format (M22) includes `Domain`, `Task`, and `Ctx%` columns:
|
|
344
|
-
|
|
345
|
-
```
|
|
346
|
-
| Datetime-start | Datetime-end | Command | Step | Model | Duration(s) | Notes | Tokens | Compacted | Domain | Task | Ctx% |
|
|
347
|
-
```
|
|
348
|
-
|
|
349
|
-
Alert thresholds (inline display):
|
|
350
|
-
- `Ctx% >= 70%` → warning: task approaching compaction, consider splitting
|
|
351
|
-
- `Ctx% >= 85%` → critical: compaction likely, task MUST be split
|
|
352
|
-
|
|
353
|
-
`gsd-t-status` displays token breakdown by domain/task/phase. `gsd-t-visualize` consumes the same data for dashboard rendering.
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
1
|
+
# Architecture — GSD-T Framework (@tekyzinc/gsd-t)
|
|
2
|
+
|
|
3
|
+
## Last Updated: 2026-03-22 (M23 — Headless Mode)
|
|
4
|
+
|
|
5
|
+
## System Overview
|
|
6
|
+
|
|
7
|
+
GSD-T is an npm-distributed methodology framework for Claude Code. It provides slash commands (markdown files), a CLI installer (Node.js), and document templates that together enable contract-driven development with AI assistance.
|
|
8
|
+
|
|
9
|
+
The framework has no runtime — it is consumed entirely by Claude Code's slash command system and the user's shell. The CLI handles installation, updates, and diagnostics. The command files define the workflow methodology that Claude Code follows.
|
|
10
|
+
|
|
11
|
+
**Architecture Pattern**: Distributed Markdown Instruction System with CLI Lifecycle Manager. Command files are the "source code" interpreted by Claude Code. The CLI is a lifecycle manager (install/update/init/status/doctor/uninstall). State files persist across sessions as git-tracked Markdown.
|
|
12
|
+
|
|
13
|
+
## Components
|
|
14
|
+
|
|
15
|
+
### CLI Installer (bin/gsd-t.js)
|
|
16
|
+
- **Purpose**: Install, update, diagnose, and manage GSD-T across projects
|
|
17
|
+
- **Location**: `bin/gsd-t.js` (1,798 lines, 90+ functions, all ≤ 30 lines)
|
|
18
|
+
- **Dependencies**: Node.js built-ins only (fs, path, os, child_process, https, crypto)
|
|
19
|
+
- **Subcommands**: install, update, status, doctor, init, uninstall, update-all, register, changelog, graph (index/status/query), headless (exec/query/--debug-loop)
|
|
20
|
+
- **Organization**: Configuration → Guard section → Helpers → Heartbeat → Commands → Install/Update → Init → Status → Uninstall → Update-All → Doctor → Register → Update Check → Help → Main dispatch
|
|
21
|
+
- **All functions ≤ 30 lines** (M6 refactoring). Largest: `doRegister()` at 30 lines, `summarize()` at 30 lines.
|
|
22
|
+
|
|
23
|
+
### Slash Commands (commands/*.md)
|
|
24
|
+
- **Purpose**: Define the GSD-T methodology as executable workflows for Claude Code
|
|
25
|
+
- **Location**: `commands/`
|
|
26
|
+
- **Count**: 49 (45 GSD-T workflow + 4 utility: gsd, branch, checkin, Claude-md, global-change) — includes gsd-t-health, gsd-t-pause (M13), gsd-t-reflect (M14), gsd-t-visualize (M15), gsd-t-prd (M16), global-change (M20)
|
|
27
|
+
- **Format**: Pure markdown with step-numbered instructions, team mode blocks, document ripple sections, and $ARGUMENTS terminator
|
|
28
|
+
|
|
29
|
+
### Templates (templates/*.md)
|
|
30
|
+
- **Purpose**: Starter files for project initialization
|
|
31
|
+
- **Location**: `templates/`
|
|
32
|
+
- **Count**: 9 (CLAUDE-global, CLAUDE-project, requirements, architecture, workflows, infrastructure, progress, backlog, backlog-settings)
|
|
33
|
+
- **Tokens**: `{Project Name}` and `{Date}` replaced during init via `applyTokens()`
|
|
34
|
+
|
|
35
|
+
### Hook Scripts (scripts/)
|
|
36
|
+
- **gsd-t-heartbeat.js** (181 lines, 6 functions, 5 exports): Real-time event logging via Claude Code hooks. Captures 9 event types as structured JSONL. Input capped at 1MB. Session ID validated. Path traversal protection. Secret scrubbing via `scrubSecrets()`/`scrubUrl()` (M5). Notification message + title scrubbing (M8/M9). EVENT_HANDLERS map pattern (M6). Auto-cleanup after 7 days (SessionStart only, M6). M14: added `buildEventStreamEntry()` (maps SubagentStart/Stop/PostToolUse → events/ schema) and `appendToEventsFile()` (daily-rotated JSONL in `.gsd-t/events/`, symlink-safe).
|
|
37
|
+
- **gsd-t-event-writer.js** (124 lines, 3 exports, NEW in M14): Zero-dep CLI tool + module for structured JSONL event appends to `.gsd-t/events/`. Exports: `validateEvent()`, `resolveEventsFile()`, `appendEvent()`. CLI: `--type`, `--command`, `--phase`, `--reasoning`, `--outcome`, `--agent-id`. Validates all 8 event_type values and 5 outcome values from event-schema-contract. Installed to `~/.claude/scripts/` by CLI installer. Exit codes: 0 success, 1 write error, 2 validation error.
|
|
38
|
+
- **npm-update-check.js** (43 lines): Background npm registry version checker. Spawned detached by CLI when update cache is stale. Path validation within `~/.claude/` (M5). Symlink check before write (M5). 1MB response limit (M5).
|
|
39
|
+
- **gsd-t-fetch-version.js** (26 lines, NEW in M6): Synchronous npm registry fetch. Called by `fetchVersionSync()` via `execFileSync`. HTTPS-only, 5s timeout, 1MB limit. Silent failure on errors (caller validates).
|
|
40
|
+
- **gsd-t-tools.js** (163 lines, NEW in M13): State utility CLI returning compact JSON. Subcommands: state get/set (progress.md), validate (required file presence), parse progress --section, list domains/contracts, git pre-commit-check, template scope/tasks. Zero external dependencies. NOTE: No module.exports — untestable as module (TD-066).
|
|
41
|
+
- **gsd-t-statusline.js** (94 lines, NEW in M13): Context usage bar + project state for Claude Code `statusLine` setting. Reads CLAUDE_CONTEXT_TOKENS_USED/MAX env vars for usage percentage. Color-coded bar (green <50%, yellow <70%, orange <85%, red ≥85%). NOTE: No module.exports — untestable as module (TD-066).
|
|
42
|
+
|
|
43
|
+
### Execution Intelligence Layer (M14 — complete)
|
|
44
|
+
- **`.gsd-t/events/YYYY-MM-DD.jsonl`**: Append-only event stream. One event per line. Schema: `ts`, `event_type`, `command`, `phase`, `agent_id`, `parent_agent_id`, `trace_id`, `reasoning`, `outcome`. Written by hooks (SubagentStart/Stop, PostToolUse via heartbeat.js) and command files at phase transitions.
|
|
45
|
+
- **Outcome-tagged Decision Log**: New Decision Log entries use `[success]`/`[failure]`/`[learning]`/`[deferred]` prefixes for machine-readable filtering (execute, debug, wave, complete-milestone).
|
|
46
|
+
- **Pre-task experience retrieval (execute, debug)**: Grep Decision Log for `[failure]`/`[learning]` entries matching current domain before spawning subagent — Reflexion pattern without fine-tuning. Writes `experience_retrieval` event.
|
|
47
|
+
- **Distillation step (complete-milestone Step 2.5)**: Scans `.gsd-t/events/*.jsonl` for patterns seen ≥3 times, proposes CLAUDE.md / constraints.md rule additions, user confirms before write.
|
|
48
|
+
- **`commands/gsd-t-reflect.md`**: On-demand retrospective command (47th command). Reads current milestone events, generates `.gsd-t/retrospectives/YYYY-MM-DD-{milestone}.md` with sections: What Worked, What Failed, Patterns Found, Proposed Memory Updates.
|
|
49
|
+
|
|
50
|
+
### Auto-Route + Auto-Update Hooks (M16 — complete)
|
|
51
|
+
- **`scripts/gsd-t-auto-route.js`** (39 lines): UserPromptSubmit hook. Reads JSON from stdin (`{ prompt, cwd, session_id }`). If `.gsd-t/progress.md` does not exist in cwd → exits silently. If prompt starts with `/` → exits silently. If plain text in a GSD-T project → emits `[GSD-T AUTO-ROUTE]` signal to Claude's context, routing the message through `/user:gsd`. Catches all exceptions — never blocks the prompt.
|
|
52
|
+
- **`scripts/gsd-t-update-check.js`** (79 lines): SessionStart hook. Reads `~/.claude/.gsd-t-version`. Reads/refreshes `~/.claude/.gsd-t-update-check` cache (1h TTL). If newer version available: runs `npm install -g @tekyzinc/gsd-t@{latest}` + `gsd-t update-all` via execSync. Outputs `[GSD-T AUTO-UPDATE]`, `[GSD-T UPDATE]`, or `[GSD-T]` banner. NOTE: No module.exports — untestable as module (TD-081). Version string not validated before execSync (SEC-N28).
|
|
53
|
+
|
|
54
|
+
### Scan Visual Output (M17 — complete v2.34.10)
|
|
55
|
+
- **`bin/scan-schema.js`** (77 lines): ORM detector + schema extractor. Detects 7 ORM types (Prisma, TypeORM, Drizzle, Mongoose, Sequelize, SQLAlchemy, raw-SQL). Delegates to scan-schema-parsers.js. Returns SchemaData: `{ detected, ormType, entities[], parseWarnings[] }`. Never throws.
|
|
56
|
+
- **`bin/scan-schema-parsers.js`** (199 lines): 7 parser functions (parsePrisma, parseTypeOrm, parseDrizzle, parseMongoose, parseSequelize, parseSqlAlchemy, parseRawSql). Returns Entity[] for each ORM type.
|
|
57
|
+
- **`bin/scan-diagrams.js`** (77 lines): Diagram orchestrator. Calls scan-diagrams-generators.js for each of 6 types. Calls scan-renderer.js to render Mermaid to SVG. Always returns exactly 6 DiagramResult objects. Failed diagrams get placeholder HTML.
|
|
58
|
+
- **`bin/scan-diagrams-generators.js`** (102 lines): Mermaid DSL source generators for 6 types: genSystemArchitecture, genAppArchitecture, genWorkflow, genDataFlow, genSequence, genDatabaseSchema. Falls back to generic diagram if analysisData lacks specific fields.
|
|
59
|
+
- **`bin/scan-renderer.js`** (92 lines): Sync render chain: tryMmdc() → tryD2() → placeholder. Also contains tryKroki() (async, currently dormant — never called in sync path). Uses execSync (not execFileSync — see TD-084/SEC-N30).
|
|
60
|
+
- **`bin/scan-report.js`** (116 lines): Generates self-contained HTML scan report. No external CSS/JS (all inline). Output: `{projectRoot}/scan-report.html` (see TD-092 for placement issue). Exports: generateReport(), buildCss(), buildSidebar(), buildHtmlSkeleton() + section builders.
|
|
61
|
+
- **`bin/scan-report-sections.js`** (74 lines): HTML section builders: buildMetricCards, buildDomainHealth, buildDiagramSection, buildTechDebt, buildFindings.
|
|
62
|
+
- **`bin/scan-export.js`** (49 lines): Export subcommand — DOCX via pandoc, PDF via md-to-pdf. Checks tool availability before attempting. Uses execSync (not execFileSync — see TD-084/SEC-N29).
|
|
63
|
+
|
|
64
|
+
### Real-Time Agent Dashboard (M15 — complete v2.33.10)
|
|
65
|
+
- **`scripts/gsd-t-dashboard-server.js`** (141 lines, zero external deps): Node.js SSE server watching `.gsd-t/events/*.jsonl`. Exports: `startServer(port, eventsDir, htmlPath)`, `tailEventsFile(filePath, callback)`, `readExistingEvents(eventsDir, maxEvents)`, `parseEventLine(line)`, `findEventsDir(projectDir)`. HTTP endpoints: `GET /` (serve dashboard HTML), `GET /events` (SSE stream, max 500 events on connect + tail for new), `GET /ping` (health check), `GET /stop` (graceful shutdown). CLI: `--port`, `--events`, `--detach` (writes PID to `.gsd-t/dashboard.pid`), `--stop` (kills running server). Symlink protection via `lstatSync` pattern. 23 unit tests in `test/dashboard-server.test.js`.
|
|
66
|
+
- **`scripts/gsd-t-dashboard.html`** (194 lines): React 17 + React Flow v11.11.4 + Dagre via CDN (no build step, no npm deps). Dark theme (`#0d1117`). Renders agent hierarchy as directed graph from `parent_agent_id` relationships. Live event feed (max 200, outcome color-coded). Auto-reconnects on SSE disconnect. Port configurable via `?port=` URL param.
|
|
67
|
+
- **`commands/gsd-t-visualize.md`** (104 lines, 48th command): Starts server via `--detach`, polls `/ping` up to 5s, opens browser cross-platform (win32/darwin/linux). Accepts `stop` argument to shut down server. Step 0 self-spawn with OBSERVABILITY LOGGING.
|
|
68
|
+
|
|
69
|
+
### Headless Mode (M23 — complete)
|
|
70
|
+
- **doHeadless(args)**: Dispatch function for the `headless` CLI subcommand.
|
|
71
|
+
- **doHeadlessExec(command, cmdArgs, flags)**: Wraps `claude -p "/user:gsd-t-{command}"` via `execFileSync`. Verifies claude CLI availability, enforces timeout, writes log file if `--log` requested. Returns structured JSON if `--json` flag set.
|
|
72
|
+
- **parseHeadlessFlags(args)**: Extracts `--json`, `--timeout=N`, `--log` from raw args. Returns `{ flags, positional }`.
|
|
73
|
+
- **buildHeadlessCmd(command, cmdArgs)**: Builds the `/user:gsd-t-{command}` prompt string.
|
|
74
|
+
- **mapHeadlessExitCode(processExitCode, output)**: Maps process exit code + output text patterns to GSD-T exit codes (0–4).
|
|
75
|
+
- **headlessLogPath(projectDir, timestamp)**: Generates `.gsd-t/headless-{timestamp}.log` path.
|
|
76
|
+
- **doHeadlessQuery(type)**: Dispatches to one of 7 query functions. All pure Node.js file reads, no LLM calls, <100ms.
|
|
77
|
+
- **Query functions** (7): `queryStatus`, `queryDomains`, `queryContracts`, `queryDebt`, `queryContext`, `queryBacklog`, `queryGraph` — each reads corresponding `.gsd-t/` file and returns typed JSON result.
|
|
78
|
+
- **Exit codes**: 0=success, 1=verify-fail, 2=context-budget-exceeded, 3=error, 4=blocked-needs-human
|
|
79
|
+
- **CI/CD examples**: `docs/ci-examples/github-actions.yml` (GitHub Actions), `docs/ci-examples/gitlab-ci.yml` (GitLab CI)
|
|
80
|
+
|
|
81
|
+
### Compaction-Proof Debug Loop (M29 — complete)
|
|
82
|
+
- **bin/debug-ledger.js** (193 lines): JSONL-based debug persistence layer. 6 exported functions: `readLedger`, `appendEntry`, `compactLedger`, `generateAntiRepetitionPreamble`, `getLedgerStats`, `clearLedger`. Ledger file: `.gsd-t/debug-state.jsonl` (11-field schema per entry). Compaction triggers at 50KB — haiku session condenses history, last 5 raw entries preserved. Anti-repetition preamble lists all STILL_FAILS hypotheses, current narrowing direction, and tests still failing. Zero external deps.
|
|
83
|
+
- **doHeadlessDebugLoop(flags)**: External iteration manager in `bin/gsd-t.js`. Runs test-fix-retest as separate `claude -p` sessions — each session starts with zero accumulated context. Escalation tiers: sonnet (iterations 1-5), opus (6-15), STOP with full diagnostic output (16-20). `--max-iterations N` flag (default 20) enforced by external process.
|
|
84
|
+
- **parseDebugLoopFlags(args)**: Extracts `--max-iterations`, `--test-cmd`, `--fix-scope`, `--json`, `--log` from args. Defaults: maxIterations=20.
|
|
85
|
+
- **getEscalationModel(iteration)**: Returns "sonnet" for 1-5, "opus" for 6-15, null for 16-20 (STOP tier).
|
|
86
|
+
- **Command integration**: execute, wave, test-sync, verify, debug all delegate fix-retest loops to `gsd-t headless --debug-loop` after 2 in-context fix attempts.
|
|
87
|
+
- **Exit codes (debug-loop specific)**: 0=all tests pass (ledger cleared), 1=max iterations reached, 3=process error, 4=escalation stop (needs human)
|
|
88
|
+
|
|
89
|
+
### Graph Engine (M20 — complete)
|
|
90
|
+
- **`bin/graph-store.js`** (147 lines): File-based graph storage in `.gsd-t/graph/`. 8 JSON files (index, calls, imports, contracts, requirements, tests, surfaces, meta). Read/write operations, MD5 file hashing for incremental indexing, staleness detection. Zero external deps. Note: no symlink protection (TD-099).
|
|
91
|
+
- **`bin/graph-parsers.js`** (327 lines): Language-specific entity parsers. JS/TS: function declarations, arrow functions, classes, methods, imports (ES/CJS), exports. Python: def/class/import. Regex-based (no Tree-sitter). Returns `{ entities, imports, calls }`.
|
|
92
|
+
- **`bin/graph-overlay.js`** (195 lines): GSD-T context mapper. Enriches code entities with: domain ownership (from scope.md), contract mapping (from contracts/*.md), requirement traceability (from requirements.md), test mapping (from test/ files), debt mapping (from techdebt.md), surface detection (from directory structure). 8 exports. No dedicated test file (TD-100).
|
|
93
|
+
- **`bin/graph-indexer.js`** (147 lines): Project indexer. Walks source files, calls parsers, builds overlay, writes to storage. Incremental (skips unchanged files via content hash). Exports `indexProject(root, options)`.
|
|
94
|
+
- **`bin/graph-query.js`** (400 lines): Graph abstraction layer. Unified `query(type, params, root)` interface with 21 query types. 3-provider fallback: CGC MCP → native → grep. Provider registry with priority-based selection. Auto-triggers reindex on stale data. WARNING: grep fallback uses execSync with string interpolation — command injection risk (TD-097/SEC-C01).
|
|
95
|
+
- **`bin/graph-cgc.js`** (510 lines): CodeGraphContext MCP provider — fully integrated end-to-end. Communicates via JSON-RPC/stdio MCP protocol with CGC server backed by Neo4j (Docker container `gsd-t-neo4j`). 12+ query types: getCallers, getTransitiveCallers, getCallees, getTransitiveCallees, findDeadCode, findComplexFunctions, getComplexity, findDuplicates, findCircularDeps, getEntity, getCallChain, getModuleDeps, getClassHierarchy, getStats, cypher. Health detection (3s timeout, session-cached). Overlay enrichment maps CGC results to GSD-T domains/contracts/requirements. Auto-installed by `gsd-t install`.
|
|
96
|
+
- **`bin/scan-data-collector.js`** (153 lines, NEW in M20): Aggregates scan markdown files into structured data for report generation.
|
|
97
|
+
- **Storage**: `.gsd-t/graph/` directory (git-ignored). JSON files: index.json (entities), calls.json (edges), imports.json, contracts.json, requirements.json, tests.json, surfaces.json, meta.json (file hashes + stats).
|
|
98
|
+
|
|
99
|
+
### Examples (examples/)
|
|
100
|
+
- **Purpose**: Reference project structure and settings
|
|
101
|
+
- **Location**: `examples/`
|
|
102
|
+
- **Contents**: settings.json, .gsd-t/ with sample contracts and domain structure
|
|
103
|
+
|
|
104
|
+
## Data Flow
|
|
105
|
+
|
|
106
|
+
### Installation Flow
|
|
107
|
+
```
|
|
108
|
+
npm install @tekyzinc/gsd-t → bin/gsd-t.js install
|
|
109
|
+
├── Copy commands/*.md → ~/.claude/commands/
|
|
110
|
+
├── Copy/append templates/CLAUDE-global.md → ~/.claude/CLAUDE.md
|
|
111
|
+
├── Copy scripts/gsd-t-heartbeat.js → ~/.claude/scripts/
|
|
112
|
+
├── Configure 9 hooks in ~/.claude/settings.json
|
|
113
|
+
├── Copy scripts/gsd-t-tools.js → ~/.claude/scripts/ (installUtilityScripts, M13)
|
|
114
|
+
├── Copy scripts/gsd-t-statusline.js → ~/.claude/scripts/ (installUtilityScripts, M13)
|
|
115
|
+
└── Write version to ~/.claude/.gsd-t-version
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Project Initialization Flow
|
|
119
|
+
```
|
|
120
|
+
gsd-t init [name] → templates/ → applyTokens()
|
|
121
|
+
├── → {project}/CLAUDE.md
|
|
122
|
+
├── → {project}/docs/{requirements,architecture,workflows,infrastructure}.md
|
|
123
|
+
├── → {project}/.gsd-t/{progress,backlog,backlog-settings}.md
|
|
124
|
+
└── → {project}/.gsd-t/{contracts,domains}/.gitkeep
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Runtime Command Execution (within Claude Code)
|
|
128
|
+
```
|
|
129
|
+
User types /user:gsd-t-{command} [args]
|
|
130
|
+
→ Claude Code loads ~/.claude/commands/gsd-t-{command}.md
|
|
131
|
+
→ Claude interprets step-by-step instructions
|
|
132
|
+
→ Reads state files → Executes workflow → Pre-Commit Gate → Updates progress.md
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Update Check Flow
|
|
136
|
+
```
|
|
137
|
+
CLI command → Read cache (~/.claude/.gsd-t-update-check)
|
|
138
|
+
├── Fresh (<1h): Show notice if latest > installed
|
|
139
|
+
├── No cache: Synchronous fetch → cache → show notice
|
|
140
|
+
└── Stale (>1h): Spawn background scripts/npm-update-check.js
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Configuration Model
|
|
144
|
+
|
|
145
|
+
Three-tier configuration:
|
|
146
|
+
|
|
147
|
+
| Layer | Location | Purpose |
|
|
148
|
+
|-------|----------|---------|
|
|
149
|
+
| **Global** | `~/.claude/CLAUDE.md` | Framework defaults: autonomy rules, code standards, pre-commit gate |
|
|
150
|
+
| **Project** | `{cwd}/CLAUDE.md` | Project-specific: tech stack, branch guard, conventions, overrides |
|
|
151
|
+
| **State** | `{cwd}/.gsd-t/` | Live state: progress, contracts, domains, backlog, scan results |
|
|
152
|
+
|
|
153
|
+
## State Files
|
|
154
|
+
|
|
155
|
+
| File | Purpose | Read By | Written By |
|
|
156
|
+
|------|---------|---------|------------|
|
|
157
|
+
| `progress.md` | Master state, version, decision log | All commands | Most commands |
|
|
158
|
+
| `contracts/*.md` | Domain interfaces | execute, integrate, verify | partition |
|
|
159
|
+
| `domains/{name}/scope.md` | File ownership | execute, quick | partition |
|
|
160
|
+
| `domains/{name}/tasks.md` | Task list | execute, status, resume | plan, execute |
|
|
161
|
+
| `backlog.md` | Priority-ordered backlog | backlog-list, status | backlog-add/edit/move/remove |
|
|
162
|
+
| `backlog-settings.md` | Types, apps, categories | backlog-add/edit/settings | backlog-settings, init |
|
|
163
|
+
| `techdebt.md` | Prioritized tech debt | promote-debt, scan | scan |
|
|
164
|
+
| `scan/*.md` | Codebase analysis | scan (synthesis), setup | scan (teammates) |
|
|
165
|
+
| `CONTEXT.md` | Discuss phase output — Locked Decisions, Deferred Ideas | plan (reads + enforces) | discuss |
|
|
166
|
+
| `continue-here-{ts}.md` | Pause/resume checkpoint — exact position | resume (reads + deletes) | pause |
|
|
167
|
+
| `deferred-items.md` | Log of unresolved issues from execute/quick/debug | (manual review) | execute, quick, debug |
|
|
168
|
+
|
|
169
|
+
## Data Models
|
|
170
|
+
|
|
171
|
+
### Progress State (.gsd-t/progress.md)
|
|
172
|
+
| Field | Type | Notes |
|
|
173
|
+
|-------|------|-------|
|
|
174
|
+
| Project | string | Name from CLAUDE.md |
|
|
175
|
+
| Version | semver | Major.Minor.Patch |
|
|
176
|
+
| Status | enum | READY, INITIALIZED, PARTITIONED, DISCUSSED, PLANNED, IMPACT_ANALYZED, EXECUTING, EXECUTED, TESTS_SYNCED, INTEGRATED, VERIFIED, VERIFY_FAILED, COMPLETED |
|
|
177
|
+
| Current Milestone | string | Active milestone name or "None" |
|
|
178
|
+
| Decision Log | entries | Timestamped log of all changes |
|
|
179
|
+
|
|
180
|
+
### Backlog (.gsd-t/backlog.md)
|
|
181
|
+
| Field | Type | Notes |
|
|
182
|
+
|-------|------|-------|
|
|
183
|
+
| Position | integer | Sequential, 1 = highest priority |
|
|
184
|
+
| Type | enum | bug, feature, improvement, ux, architecture |
|
|
185
|
+
| App | string | Target application |
|
|
186
|
+
| Category | string | Domain/module category |
|
|
187
|
+
| Description | string | Item summary |
|
|
188
|
+
|
|
189
|
+
### Contracts (.gsd-t/contracts/)
|
|
190
|
+
| Contract | Purpose |
|
|
191
|
+
|----------|---------|
|
|
192
|
+
| backlog-command-interface.md | Backlog command interface and promote flow |
|
|
193
|
+
| integration-points.md | How components connect |
|
|
194
|
+
| backlog-file-formats.md | Backlog markdown structure (authoritative — duplicate file-format-contract.md deleted in M9) |
|
|
195
|
+
| domain-structure.md | Domain directory layout |
|
|
196
|
+
| pre-commit-gate.md | Commit checklist contract |
|
|
197
|
+
| progress-file-format.md | Progress.md structure |
|
|
198
|
+
| wave-phase-sequence.md | Phase ordering rules |
|
|
199
|
+
| qa-agent-contract.md | QA agent spawn interface, output per phase, communication protocol |
|
|
200
|
+
|
|
201
|
+
## Workflow Phase Architecture
|
|
202
|
+
|
|
203
|
+
```
|
|
204
|
+
PARTITION → DISCUSS → PLAN → IMPACT → EXECUTE → TEST-SYNC → INTEGRATE → VERIFY → COMPLETE
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
| Phase | Mode | QA Agent | Why |
|
|
208
|
+
|-------|------|----------|-----|
|
|
209
|
+
| Partition | Solo only | NO (removed M10) | Was unnecessary overhead |
|
|
210
|
+
| Discuss | Solo only | No | Always pauses for user input (even Level 3) |
|
|
211
|
+
| Plan | Solo only | NO (removed M10) | Was unnecessary overhead |
|
|
212
|
+
| Impact | Solo only | No | Cross-cutting analysis |
|
|
213
|
+
| Execute | Solo or Team | Task subagent (M10) | Each task gets QA after completion |
|
|
214
|
+
| Test-Sync | Solo only | Inline (M10) | Sequential contract coverage audit |
|
|
215
|
+
| Integrate | Solo only | Task subagent (M10) | Cross-domain integration tests |
|
|
216
|
+
| Verify | Solo or Team | Inline (M10) | Full audit runs directly |
|
|
217
|
+
| Complete | Solo only | Inline (M10) | Final gate runs directly |
|
|
218
|
+
|
|
219
|
+
### Wave Orchestrator (Agent-Per-Phase Model)
|
|
220
|
+
|
|
221
|
+
The wave command spawns an independent agent for each phase via the Task tool with `bypassPermissions`. Each phase agent gets a fresh ~200K token context window, eliminating context accumulation and mid-wave compaction. The orchestrator itself stays lightweight (~30KB), reading only `progress.md` and `CLAUDE.md`. State handoff between phases occurs through `.gsd-t/` files.
|
|
222
|
+
|
|
223
|
+
### QA Agent Integration (Updated M10)
|
|
224
|
+
|
|
225
|
+
QA runs inline or as Task subagent depending on phase (M10 refactor). Removed from partition and plan (were unnecessary). execute and integrate spawn QA as Task subagent after each domain checkpoint. test-sync, verify, and complete-milestone run QA inline. QA failure blocks phase completion (user override available).
|
|
226
|
+
|
|
227
|
+
### Execution Quality (M11)
|
|
228
|
+
|
|
229
|
+
**Deviation Rules**: 4-rule protocol added to execute, quick, debug: (1) Bug → fix up to 3 attempts, then defer; (2) Missing dependency → add minimum; (3) Blocker → fix and log; (4) Architectural change → STOP, apply Destructive Action Guard.
|
|
230
|
+
|
|
231
|
+
**Per-Task Commits**: execute enforces `feat({domain}/task-{N})` commit format after each task. Wave spot-check verifies commits were made.
|
|
232
|
+
|
|
233
|
+
**Between-Phase Spot-Check (Wave)**: After each phase agent completes, wave reads progress.md (status), runs git log (commits), and verifies filesystem output. Re-spawns phase agent once on failure. Stops and reports to user if still failing.
|
|
234
|
+
|
|
235
|
+
### Planning Intelligence (M12)
|
|
236
|
+
|
|
237
|
+
**CONTEXT.md**: discuss phase creates `.gsd-t/CONTEXT.md` with three sections: Locked Decisions (plan MUST implement), Deferred Ideas (plan must NOT implement), Claude's Discretion (implementation details left to executor). Plan reads CONTEXT.md and fails validation if any Locked Decision has no task mapping.
|
|
238
|
+
|
|
239
|
+
**Plan Validation**: After creating task lists, plan spawns a Task subagent to validate REQ coverage, Locked Decision mapping, task completeness, contract existence. Max 3 fix iterations before stopping and reporting to user.
|
|
240
|
+
|
|
241
|
+
**REQ Traceability**: Plan writes a traceability table to docs/requirements.md mapping REQ-IDs to domain/task/status. Verify marks matched requirements complete.
|
|
242
|
+
|
|
243
|
+
### Tooling & UX (M13)
|
|
244
|
+
|
|
245
|
+
**gsd-t-tools.js**: State utility CLI for Claude Code agents. Reduces token-heavy markdown parsing with compact JSON responses. Installed to `~/.claude/scripts/`. See Hook Scripts section.
|
|
246
|
+
|
|
247
|
+
**gsd-t-statusline.js**: Visual context usage bar for Claude Code `statusLine` setting. Shows milestone, status, version, and context percentage. Installed to `~/.claude/scripts/`.
|
|
248
|
+
|
|
249
|
+
**gsd-t-health**: New command — validates .gsd-t/ structure against 12 required items. `--repair` creates missing files from templates. Step 0 subagent pattern.
|
|
250
|
+
|
|
251
|
+
**gsd-t-pause**: New command — creates `.gsd-t/continue-here-{timestamp}.md` with exact position snapshot. More precise than progress.md alone.
|
|
252
|
+
|
|
253
|
+
**gsd-t-resume** (updated): Reads continue-here files first (most recent by timestamp), falls back to progress.md. Deletes continue-here file after reading.
|
|
254
|
+
|
|
255
|
+
### Test Suite (test/)
|
|
256
|
+
- **helpers.test.js** (27 tests): Pure helper functions — validateProjectName, applyTokens, isNewerVersion, normalizeEol, etc.
|
|
257
|
+
- **filesystem.test.js** (37 tests): Filesystem helpers + CLI subcommand integration — ensureDir, isSymlink, writeTemplateFile, status/doctor/help outputs
|
|
258
|
+
- **security.test.js** (30 tests): Security functions — scrubSecrets (18), scrubUrl (5), summarize integration (4), hasSymlinkInPath (3)
|
|
259
|
+
- **cli-quality.test.js** (22 tests): M6 refactored functions — buildEvent (10), readProjectDeps (3), readPyContent (2), insertGuardSection (3), readUpdateCache (1), addHeartbeatHook (3)
|
|
260
|
+
- **Runner**: Node.js built-in (`node --test`), zero test dependencies
|
|
261
|
+
- **Total**: 125 tests, all passing (post-M9)
|
|
262
|
+
|
|
263
|
+
## Security Model
|
|
264
|
+
|
|
265
|
+
- **Zero dependencies**: No supply chain attack surface
|
|
266
|
+
- **Symlink protection**: `isSymlink()` at 15+ write sites + `hasSymlinkInPath()` for parent directory validation (M5)
|
|
267
|
+
- **Secret scrubbing**: `scrubSecrets()` masks passwords/tokens/API keys in heartbeat logs; `scrubUrl()` masks URL query params (M5)
|
|
268
|
+
- **Input validation**: Project names, version strings, session IDs, project paths all validated
|
|
269
|
+
- **Path traversal prevention**: Heartbeat validates session_id regex, resolves paths, verifies containment; npm-update-check validates cache path within `~/.claude/` (M5)
|
|
270
|
+
- **Command injection mitigation**: `execFileSync` with array args (not `execSync`)
|
|
271
|
+
- **Exclusive file creation**: Init uses `{ flag: "wx" }` for atomic create-or-fail
|
|
272
|
+
- **Resource limits**: Heartbeat stdin capped at 1MB, HTTP responses capped at 1MB (M5), 5s/8s timeouts, 7-day file cleanup
|
|
273
|
+
- **Wave security**: `bypassPermissions` mode documented with attack surface analysis and mitigations (M5)
|
|
274
|
+
|
|
275
|
+
## Design Decisions
|
|
276
|
+
|
|
277
|
+
| Date | Decision | Rationale | Alternatives Considered |
|
|
278
|
+
|------|----------|-----------|------------------------|
|
|
279
|
+
| 2026-02-07 | Zero external dependencies for CLI | Simplicity, no install failures, no supply chain risk | Using commander.js, yargs |
|
|
280
|
+
| 2026-02-07 | Markdown-only command files | Claude Code native format, no build step, human-readable | YAML frontmatter, JSON config |
|
|
281
|
+
| 2026-02-09 | Semantic versioning with git tags | Standard npm practice, enables update checks | CalVer, build numbers |
|
|
282
|
+
| 2026-02-12 | Heartbeat via Claude Code hooks | Non-invasive monitoring, no command file changes needed | Polling, WebSocket |
|
|
283
|
+
| 2026-02-13 | Semantic router over keyword matching | Better intent detection, fewer misroutes | Regex patterns, ML classifier |
|
|
284
|
+
| 2026-02-16 | Mandatory Playwright for all projects | Consistent E2E testing, no "we'll add tests later" | Optional testing, Jest-only |
|
|
285
|
+
| 2026-02-16 | Team mode default for scan | Parallel scanning faster, better results | Solo sequential scan |
|
|
286
|
+
| 2026-02-17 | QA Agent as cross-cutting concern | Mandatory test-driven contracts for all code phases | Optional testing, deferred testing |
|
|
287
|
+
| 2026-02-17 | Agent-per-phase wave orchestration | Fresh context window per phase, eliminates compaction | Inline execution (original approach) |
|
|
288
|
+
| 2026-02-18 | QA refactor — remove from partition/plan, Task subagent for execute/integrate | QA on partition/plan added overhead with little value; Task subagent gives QA fresh context | Teammate QA (original), no QA |
|
|
289
|
+
| 2026-02-18 | Deviation Rules + 3-attempt limit | Prevents infinite loops; auto-fixes bugs without blocking; escalates architectural changes | Manual escalation only, no auto-fix |
|
|
290
|
+
| 2026-02-18 | CONTEXT.md from discuss phase | Structured handoff between discuss and plan; fidelity enforcement on Locked Decisions | Free-form decisions in progress.md |
|
|
291
|
+
| 2026-02-18 | gsd-t-tools.js as state utility CLI | Reduces token-heavy markdown parsing; compact JSON responses save ~50K tokens/wave | Parsing progress.md inline (original) |
|
|
292
|
+
| 2026-02-18 | continue-here files for pause/resume | More precise than progress.md; captures exact task+next-action, not just phase | progress.md alone (less precise) |
|
|
293
|
+
|
|
294
|
+
### GSD 2 Tier 1 — Execution Quality (M22 — complete v2.40.10)
|
|
295
|
+
|
|
296
|
+
Five interlocking capabilities eliminate context rot, enable safe parallel execution, and verify behavior rather than structure alone.
|
|
297
|
+
|
|
298
|
+
**Task-Level Fresh Dispatch**
|
|
299
|
+
|
|
300
|
+
Execute dispatches one subagent per TASK (not per domain). Each task agent gets a fresh context window containing only: domain scope.md, relevant contracts, the single current task, graph context for touched files, and prior task summaries (10-20 lines each). Context utilization per task: ~10-20% (down from 60-75% cumulative per domain). Compaction never triggers. The domain dispatcher (lightweight orchestrator) sequences tasks and passes summaries — it never accumulates full task context.
|
|
301
|
+
|
|
302
|
+
```
|
|
303
|
+
Execute orchestrator (summaries only — ~4-8% ctx)
|
|
304
|
+
└── Domain-A task-dispatcher
|
|
305
|
+
├── Task 1 subagent (fresh, 10-20% ctx) → summary → dies
|
|
306
|
+
├── Task 2 subagent (fresh + task 1 summary) → summary → dies
|
|
307
|
+
└── Task N subagent (fresh + prior summaries) → summary → dies
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
**Plan command constraint** (added M22): Every task must fit in one context window. If estimated scope exceeds 70% context, plan splits the task automatically.
|
|
311
|
+
|
|
312
|
+
**Worktree Isolation**
|
|
313
|
+
|
|
314
|
+
Parallel domain agents work in isolated git worktrees via Agent tool's `isolation: "worktree"` parameter. No shared filesystem — domains cannot step on each other's files. Merges are sequential and atomic:
|
|
315
|
+
|
|
316
|
+
```
|
|
317
|
+
Dispatch N domains (isolation: "worktree") → parallel execution
|
|
318
|
+
└── Domain A completes → merge A → run integration tests
|
|
319
|
+
└── Domain B completes → merge B → run integration tests
|
|
320
|
+
└── Conflict or test failure → rollback that domain, others unaffected
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
Rollback granularity is per-domain (not per-commit). Worktrees are cleaned up after all merges complete.
|
|
324
|
+
|
|
325
|
+
**Goal-Backward Verification**
|
|
326
|
+
|
|
327
|
+
After all structural quality gates pass (tests, contracts, file existence), a goal-backward pass verifies behavior. Reads milestone goals, traces each requirement to code, and checks for placeholders:
|
|
328
|
+
- `console.log("TODO")` / `console.log("implement X")`
|
|
329
|
+
- Hardcoded return values (`return "Synced"`, `return 200` on a path that should compute)
|
|
330
|
+
- `// TODO`, `// FIXME`, `// PLACEHOLDER` comments in critical paths
|
|
331
|
+
- UI components rendering static strings where dynamic data is required
|
|
332
|
+
|
|
333
|
+
Applied in: `verify`, `complete-milestone`, `wave` (verification phase).
|
|
334
|
+
|
|
335
|
+
**Adaptive Replanning**
|
|
336
|
+
|
|
337
|
+
After each domain completes in execute, the orchestrator reads the domain's result summary and evaluates whether remaining domain plans remain valid. If execution revealed new constraints (deprecated API, schema mismatch, missing dependency, incompatible library), affected domain `tasks.md` files are rewritten on disk before the next domain is dispatched.
|
|
338
|
+
|
|
339
|
+
Guard: max 2 replanning cycles per execute run. After that, pause for user input (prevents new-constraint → replan → new-constraint loops).
|
|
340
|
+
|
|
341
|
+
**Context Observability**
|
|
342
|
+
|
|
343
|
+
Extended token-log.md format (M22) includes `Domain`, `Task`, and `Ctx%` columns:
|
|
344
|
+
|
|
345
|
+
```
|
|
346
|
+
| Datetime-start | Datetime-end | Command | Step | Model | Duration(s) | Notes | Tokens | Compacted | Domain | Task | Ctx% |
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
Alert thresholds (inline display):
|
|
350
|
+
- `Ctx% >= 70%` → warning: task approaching compaction, consider splitting
|
|
351
|
+
- `Ctx% >= 85%` → critical: compaction likely, task MUST be split
|
|
352
|
+
|
|
353
|
+
`gsd-t-status` displays token breakdown by domain/task/phase. `gsd-t-visualize` consumes the same data for dashboard rendering.
|
|
354
|
+
|
|
355
|
+
### GSD 2 Tier 3 — Quality Culture & Design (M32 — complete v2.53.10)
|
|
356
|
+
|
|
357
|
+
Three enhancements for project-level quality identity and design consistency.
|
|
358
|
+
|
|
359
|
+
**Quality North Star**
|
|
360
|
+
|
|
361
|
+
Projects define a `## Quality North Star` section in their CLAUDE.md (1-3 sentences describing the quality identity). Auto-detected preset options: `library`, `web-app`, `cli`. Configured by `gsd-t-init` (auto-detects from package.json signals: `bin` → cli, React/Vue/Next → web-app, `main` + no `scripts.dev` → library) and `gsd-t-setup` (interactive config for existing projects). Subagents read this section as a quality lens. Silent skip when section absent (backward compatible — no migration required).
|
|
362
|
+
|
|
363
|
+
**Design Brief Artifact**
|
|
364
|
+
|
|
365
|
+
During partition, UI/frontend projects automatically receive `.gsd-t/contracts/design-brief.md` with: color palette, typography, spacing system, component patterns, layout principles, interaction patterns, and tone/voice. Trigger signals: React/Vue/Svelte/Next.js in package.json deps, `pubspec.yaml` exists (Flutter), `.css`/`.scss`/`.jsx`/`.tsx`/`.svelte`/`.vue` files, Tailwind config. Source priority: Tailwind config → theme/token files → Quality North Star for tone → sensible defaults. Non-UI projects: no artifact, no step shown. Preservation rule: if brief already exists, never overwrite (user-authoritative).
|
|
366
|
+
|
|
367
|
+
**Exploratory Testing (Playwright MCP)**
|
|
368
|
+
|
|
369
|
+
When Playwright MCP is registered in Claude Code settings, QA agents get 3 minutes of interactive exploration and Red Team gets 5 minutes after all scripted tests pass. Findings are tagged `[EXPLORATORY]` in qa-issues.md and red-team-report.md, and tracked separately in QA calibration (category key: `exploratory` — does NOT count against scripted pass/fail ratio). Silent skip when Playwright MCP absent. Wired into: execute, quick, integrate, debug.
|
|
370
|
+
|
|
371
|
+
## Planned Architecture Changes (M23-M24)
|
|
372
|
+
|
|
373
|
+
**M23: Headless Mode**
|
|
374
|
+
- New `gsd-t headless` CLI subcommand wrapping `claude -p` for unattended execution.
|
|
375
|
+
- New `gsd-t headless query` for instant JSON state access (no LLM).
|
|
376
|
+
|
|
377
|
+
**M24: Docker**
|
|
378
|
+
- Dockerfile + docker-compose for containerized enterprise execution.
|
|
379
|
+
|
|
380
|
+
## Known Architecture Concerns
|
|
381
|
+
|
|
382
|
+
1. **CLI single-file size**: bin/gsd-t.js at 1,438 lines exceeds the 200-line convention, but splitting adds complexity for questionable benefit given zero-dependency constraint. Accepted deviation.
|
|
383
|
+
2. **Four-file synchronization**: Any command change requires updating README, GSD-T-README, CLAUDE-global template, and gsd-t-help. Manual process — no automated validation.
|
|
384
|
+
3. **Pre-Commit Gate unenforced**: Mental checklist in CLAUDE.md, not a git hook or CI check.
|
|
385
|
+
4. **Progress.md Decision Log growth**: Unbounded append-only log. May need periodic archival strategy for long-lived projects.
|