@tekyzinc/gsd-t 2.51.10 → 2.53.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/README.md +379 -373
  3. package/bin/component-registry.js +250 -0
  4. package/bin/graph-cgc.js +510 -510
  5. package/bin/graph-indexer.js +147 -147
  6. package/bin/graph-overlay.js +195 -195
  7. package/bin/graph-parsers.js +327 -327
  8. package/bin/graph-query.js +453 -452
  9. package/bin/graph-store.js +154 -154
  10. package/bin/qa-calibrator.js +194 -0
  11. package/bin/scan-data-collector.js +153 -153
  12. package/bin/scan-diagrams-generators.js +187 -187
  13. package/bin/scan-diagrams.js +79 -79
  14. package/bin/scan-renderer.js +92 -92
  15. package/bin/scan-report-sections.js +121 -121
  16. package/bin/scan-report.js +184 -184
  17. package/bin/scan-schema-parsers.js +199 -199
  18. package/bin/scan-schema.js +103 -103
  19. package/bin/token-budget.js +246 -0
  20. package/commands/Claude-md.md +10 -10
  21. package/commands/branch.md +15 -15
  22. package/commands/checkin.md +45 -45
  23. package/commands/global-change.md +209 -209
  24. package/commands/gsd-t-audit.md +199 -0
  25. package/commands/gsd-t-backlog-add.md +94 -94
  26. package/commands/gsd-t-backlog-edit.md +111 -111
  27. package/commands/gsd-t-backlog-list.md +63 -63
  28. package/commands/gsd-t-backlog-move.md +94 -94
  29. package/commands/gsd-t-backlog-promote.md +123 -123
  30. package/commands/gsd-t-backlog-remove.md +86 -86
  31. package/commands/gsd-t-backlog-settings.md +158 -158
  32. package/commands/gsd-t-complete-milestone.md +528 -515
  33. package/commands/gsd-t-debug.md +506 -482
  34. package/commands/gsd-t-discuss.md +174 -174
  35. package/commands/gsd-t-execute.md +758 -715
  36. package/commands/gsd-t-feature.md +276 -276
  37. package/commands/gsd-t-health.md +142 -142
  38. package/commands/gsd-t-help.md +465 -457
  39. package/commands/gsd-t-impact.md +302 -302
  40. package/commands/gsd-t-init-scan-setup.md +1 -5
  41. package/commands/gsd-t-init.md +314 -280
  42. package/commands/gsd-t-integrate.md +365 -333
  43. package/commands/gsd-t-milestone.md +87 -87
  44. package/commands/gsd-t-partition.md +442 -361
  45. package/commands/gsd-t-pause.md +82 -82
  46. package/commands/gsd-t-plan.md +345 -344
  47. package/commands/gsd-t-populate.md +111 -111
  48. package/commands/gsd-t-prd.md +326 -326
  49. package/commands/gsd-t-project.md +211 -211
  50. package/commands/gsd-t-promote-debt.md +123 -123
  51. package/commands/gsd-t-prompt.md +137 -137
  52. package/commands/gsd-t-qa.md +266 -266
  53. package/commands/gsd-t-quick.md +357 -315
  54. package/commands/gsd-t-reflect.md +134 -134
  55. package/commands/gsd-t-resume.md +72 -72
  56. package/commands/gsd-t-scan.md +615 -615
  57. package/commands/gsd-t-setup.md +76 -0
  58. package/commands/gsd-t-status.md +192 -166
  59. package/commands/gsd-t-test-sync.md +381 -381
  60. package/commands/gsd-t-triage-and-merge.md +171 -171
  61. package/commands/gsd-t-verify.md +382 -382
  62. package/commands/gsd-t-visualize.md +118 -118
  63. package/commands/gsd-t-wave.md +401 -378
  64. package/docs/GSD-T-README.md +425 -424
  65. package/docs/architecture.md +385 -369
  66. package/docs/harness-design-analysis.md +371 -0
  67. package/docs/infrastructure.md +205 -205
  68. package/docs/prd-graph-engine.md +398 -398
  69. package/docs/prd-gsd2-hybrid.md +559 -559
  70. package/docs/prd-harness-evolution.md +583 -0
  71. package/docs/requirements.md +14 -0
  72. package/docs/workflows.md +226 -226
  73. package/examples/.gsd-t/domains/example-domain/scope.md +13 -13
  74. package/package.json +40 -40
  75. package/scripts/gsd-t-auto-route.js +39 -39
  76. package/scripts/gsd-t-dashboard-mockup.html +1143 -1143
  77. package/scripts/gsd-t-dashboard-server.js +171 -171
  78. package/scripts/gsd-t-dashboard.html +262 -262
  79. package/scripts/gsd-t-event-writer.js +128 -128
  80. package/scripts/gsd-t-statusline.js +94 -94
  81. package/scripts/gsd-t-tools.js +175 -175
  82. package/templates/CLAUDE-global.md +638 -634
  83. package/templates/CLAUDE-project.md +24 -0
  84. package/templates/backlog-settings.md +18 -18
  85. package/templates/backlog.md +1 -1
  86. package/templates/progress.md +40 -40
  87. package/templates/shared-services-contract.md +60 -60
  88. package/templates/stacks/desktop.ini +2 -2
  89. package/bin/desktop.ini +0 -2
  90. package/commands/desktop.ini +0 -2
  91. package/docs/ci-examples/desktop.ini +0 -2
  92. package/docs/desktop.ini +0 -2
  93. package/examples/.gsd-t/contracts/desktop.ini +0 -2
  94. package/examples/.gsd-t/desktop.ini +0 -2
  95. package/examples/.gsd-t/domains/desktop.ini +0 -2
  96. package/examples/.gsd-t/domains/example-domain/desktop.ini +0 -2
  97. package/examples/desktop.ini +0 -2
  98. package/examples/rules/desktop.ini +0 -2
  99. package/scripts/desktop.ini +0 -2
  100. package/templates/desktop.ini +0 -2
@@ -0,0 +1,246 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * GSD-T Token Budget — Session-level token tracking and graduated degradation
5
+ *
6
+ * Reads .gsd-t/token-log.md for historical averages, tracks session usage,
7
+ * and returns model override recommendations at degradation thresholds.
8
+ *
9
+ * Zero external dependencies (Node.js built-ins only).
10
+ */
11
+
12
+ const fs = require("fs");
13
+ const path = require("path");
14
+
15
+ // ── Constants ────────────────────────────────────────────────────────────────
16
+
17
+ const MODEL_RATIOS = { haiku: 1, sonnet: 5, opus: 25 };
18
+
19
+ // Base token estimates per task type (in haiku-equivalent units)
20
+ const BASE_ESTIMATES = {
21
+ execute: 8000,
22
+ qa: 5000,
23
+ "red-team": 10000,
24
+ "doc-ripple": 3000,
25
+ plan: 4000,
26
+ integrate: 6000,
27
+ verify: 5000,
28
+ default: 6000,
29
+ };
30
+
31
+ const THRESHOLDS = {
32
+ warn: 60,
33
+ downgrade: 70,
34
+ conserve: 85,
35
+ stop: 95,
36
+ };
37
+
38
+ // ── Exports ──────────────────────────────────────────────────────────────────
39
+
40
+ module.exports = {
41
+ estimateCost,
42
+ getSessionStatus,
43
+ recordUsage,
44
+ getDegradationActions,
45
+ estimateMilestoneCost,
46
+ getModelCostRatios,
47
+ };
48
+
49
+ // ── getModelCostRatios ────────────────────────────────────────────────────────
50
+
51
+ /** @returns {{ haiku: 1, sonnet: 5, opus: 25 }} */
52
+ function getModelCostRatios() {
53
+ return { ...MODEL_RATIOS };
54
+ }
55
+
56
+ // ── estimateCost ──────────────────────────────────────────────────────────────
57
+
58
+ /**
59
+ * @param {string} model - 'haiku' | 'sonnet' | 'opus'
60
+ * @param {string} taskType - 'execute' | 'qa' | 'red-team' | etc.
61
+ * @param {{ complexity?: number, historicalAvg?: number, projectDir?: string }} [options]
62
+ * @returns {number} estimated tokens
63
+ */
64
+ function estimateCost(model, taskType, options) {
65
+ const o = options || {};
66
+ const ratio = MODEL_RATIOS[model] || MODEL_RATIOS.sonnet;
67
+ if (o.historicalAvg) return Math.round(o.historicalAvg * ratio);
68
+ const hist = getHistoricalAvg(model, taskType, o.projectDir);
69
+ if (hist) return Math.round(hist);
70
+ const base = BASE_ESTIMATES[taskType] || BASE_ESTIMATES.default;
71
+ const complexity = o.complexity || 1.0;
72
+ return Math.round(base * ratio * complexity);
73
+ }
74
+
75
+ // ── getSessionStatus ─────────────────────────────────────────────────────────
76
+
77
+ /**
78
+ * @param {string} [projectDir]
79
+ * @returns {{ consumed: number, estimated_remaining: number, pct: number, threshold: string }}
80
+ */
81
+ function getSessionStatus(projectDir) {
82
+ const maxTokens = parseInt(process.env.CLAUDE_CONTEXT_TOKENS_MAX || "200000", 10);
83
+ const consumed = readSessionConsumed(projectDir);
84
+ const pct = maxTokens > 0 ? Math.round((consumed / maxTokens) * 100 * 10) / 10 : 0;
85
+ const threshold = resolveThreshold(pct);
86
+ return { consumed, estimated_remaining: maxTokens - consumed, pct, threshold };
87
+ }
88
+
89
+ // ── recordUsage ──────────────────────────────────────────────────────────────
90
+
91
+ /**
92
+ * @param {{ model: string, taskType: string, tokens: number, duration_s: number, projectDir?: string }} usage
93
+ */
94
+ function recordUsage(usage) {
95
+ const dir = usage.projectDir || process.cwd();
96
+ const fp = tokenLogPath(dir);
97
+ ensureDir(path.dirname(fp));
98
+ const now = fmtDate(new Date());
99
+ const line = `| ${now} | ${now} | token-budget | record | ${usage.model} | ${usage.duration_s}s | recorded | ${usage.tokens} | null | | ${usage.taskType} | N/A |\n`;
100
+ if (!fs.existsSync(fp)) {
101
+ const header = "| Datetime-start | Datetime-end | Command | Step | Model | Duration(s) | Notes | Tokens | Compacted | Domain | Task | Ctx% |\n|----------------|--------------|---------|------|-------|-------------|-------|--------|-----------|--------|------|---------|\n";
102
+ fs.writeFileSync(fp, header);
103
+ }
104
+ fs.appendFileSync(fp, line);
105
+ }
106
+
107
+ // ── getDegradationActions ─────────────────────────────────────────────────────
108
+
109
+ /**
110
+ * @param {string} [projectDir]
111
+ * @returns {{ threshold: string, actions: string[], modelOverrides: object }}
112
+ */
113
+ function getDegradationActions(projectDir) {
114
+ const { threshold } = getSessionStatus(projectDir);
115
+ return buildDegradationResponse(threshold);
116
+ }
117
+
118
+ // ── estimateMilestoneCost ─────────────────────────────────────────────────────
119
+
120
+ /**
121
+ * @param {object[]} remainingTasks - [{ model, taskType, complexity }]
122
+ * @param {string} [projectDir]
123
+ * @returns {{ estimatedTokens: number, estimatedPct: number, feasible: boolean }}
124
+ */
125
+ function estimateMilestoneCost(remainingTasks, projectDir) {
126
+ const { estimated_remaining } = getSessionStatus(projectDir);
127
+ const maxTokens = parseInt(process.env.CLAUDE_CONTEXT_TOKENS_MAX || "200000", 10);
128
+ const estimatedTokens = remainingTasks.reduce((sum, t) => {
129
+ return sum + estimateCost(t.model, t.taskType, { complexity: t.complexity, projectDir });
130
+ }, 0);
131
+ const estimatedPct = maxTokens > 0 ? Math.round((estimatedTokens / maxTokens) * 100 * 10) / 10 : 0;
132
+ const feasible = estimatedTokens <= estimated_remaining * 0.8;
133
+ return { estimatedTokens, estimatedPct, feasible };
134
+ }
135
+
136
+ // ── Internal: threshold resolution ───────────────────────────────────────────
137
+
138
+ function resolveThreshold(pct) {
139
+ if (pct >= THRESHOLDS.stop) return "stop";
140
+ if (pct >= THRESHOLDS.conserve) return "conserve";
141
+ if (pct >= THRESHOLDS.downgrade) return "downgrade";
142
+ if (pct >= THRESHOLDS.warn) return "warn";
143
+ return "normal";
144
+ }
145
+
146
+ function buildDegradationResponse(threshold) {
147
+ const responses = {
148
+ normal: {
149
+ threshold: "normal",
150
+ actions: [],
151
+ modelOverrides: {},
152
+ },
153
+ warn: {
154
+ threshold: "warn",
155
+ actions: ["Display budget alert", "Reduce iteration budgets to minimum (2)"],
156
+ modelOverrides: {},
157
+ },
158
+ downgrade: {
159
+ threshold: "downgrade",
160
+ actions: ["Downgrade non-critical Sonnet to Haiku", "Skip exploratory testing", "Disable shadow-mode audit"],
161
+ modelOverrides: {
162
+ "sonnet:qa": "sonnet",
163
+ "sonnet:execute": "haiku",
164
+ "sonnet:doc-ripple": "skip",
165
+ "opus:red-team": "sonnet",
166
+ "haiku:*": "haiku",
167
+ },
168
+ },
169
+ conserve: {
170
+ threshold: "conserve",
171
+ actions: ["Pause doc-ripple", "Pause design brief generation", "Checkpoint all progress"],
172
+ modelOverrides: {
173
+ "sonnet:qa": "sonnet",
174
+ "sonnet:execute": "haiku",
175
+ "sonnet:doc-ripple": "skip",
176
+ "opus:red-team": "sonnet",
177
+ "haiku:*": "haiku",
178
+ },
179
+ },
180
+ stop: {
181
+ threshold: "stop",
182
+ actions: ["Hard stop", "Save all progress", "Display resume instruction"],
183
+ modelOverrides: {},
184
+ },
185
+ };
186
+ return responses[threshold] || responses.normal;
187
+ }
188
+
189
+ // ── Internal: token-log parsing ───────────────────────────────────────────────
190
+
191
+ function readSessionConsumed(projectDir) {
192
+ const fp = tokenLogPath(projectDir || process.cwd());
193
+ if (!fs.existsSync(fp)) return 0;
194
+ const today = fmtDate(new Date()).slice(0, 10); // YYYY-MM-DD
195
+ const lines = fs.readFileSync(fp, "utf8").split("\n");
196
+ let total = 0;
197
+ for (const line of lines) {
198
+ if (!line.startsWith("|")) continue;
199
+ const cols = parseRow(line);
200
+ if (cols.length < 8) continue;
201
+ const dtStart = (cols[0] || "").trim();
202
+ if (!dtStart.startsWith(today)) continue;
203
+ const tokens = parseInt(cols[7], 10);
204
+ if (!isNaN(tokens) && tokens > 0) total += tokens;
205
+ }
206
+ return total;
207
+ }
208
+
209
+ function getHistoricalAvg(model, taskType, projectDir) {
210
+ const fp = tokenLogPath(projectDir || process.cwd());
211
+ if (!fs.existsSync(fp)) return null;
212
+ const lines = fs.readFileSync(fp, "utf8").split("\n");
213
+ const matches = [];
214
+ for (const line of lines) {
215
+ if (!line.startsWith("|")) continue;
216
+ const cols = parseRow(line);
217
+ if (cols.length < 8) continue;
218
+ const rowModel = (cols[4] || "").trim();
219
+ const rowTask = (cols[10] || (cols[3] || "")).trim();
220
+ const tokens = parseInt(cols[7], 10);
221
+ if (rowModel === model && rowTask === taskType && !isNaN(tokens) && tokens > 0) {
222
+ matches.push(tokens);
223
+ }
224
+ }
225
+ if (matches.length === 0) return null;
226
+ return matches.reduce((s, v) => s + v, 0) / matches.length;
227
+ }
228
+
229
+ function parseRow(line) {
230
+ return line.split("|").slice(1, -1);
231
+ }
232
+
233
+ // ── Internal: helpers ────────────────────────────────────────────────────────
234
+
235
+ function tokenLogPath(dir) {
236
+ return path.join(dir, ".gsd-t", "token-log.md");
237
+ }
238
+
239
+ function ensureDir(d) {
240
+ if (!fs.existsSync(d)) fs.mkdirSync(d, { recursive: true });
241
+ }
242
+
243
+ function fmtDate(d) {
244
+ const pad = (n) => String(n).padStart(2, "0");
245
+ return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}`;
246
+ }
@@ -1,10 +1,10 @@
1
- # Reload CLAUDE.md Directives
2
-
3
- Reload and apply CLAUDE.md directives for this session.
4
-
5
- 1. Read `~/.claude/CLAUDE.md` (global directives). Note any changes from what you've been following.
6
- 2. Read `.claude/CLAUDE.md` or `CLAUDE.md` in the project root (project directives), if either exists. Note any changes from what you've been following.
7
- 3. Summarize what changed (new rules, modified rules, removed rules) compared to what you were previously following.
8
- 4. Confirm the updated directives are now active for the remainder of this session.
9
-
10
- If nothing changed, confirm that all directives are current and being followed.
1
+ # Reload CLAUDE.md Directives
2
+
3
+ Reload and apply CLAUDE.md directives for this session.
4
+
5
+ 1. Read `~/.claude/CLAUDE.md` (global directives). Note any changes from what you've been following.
6
+ 2. Read `.claude/CLAUDE.md` or `CLAUDE.md` in the project root (project directives), if either exists. Note any changes from what you've been following.
7
+ 3. Summarize what changed (new rules, modified rules, removed rules) compared to what you were previously following.
8
+ 4. Confirm the updated directives are now active for the remainder of this session.
9
+
10
+ If nothing changed, confirm that all directives are current and being followed.
@@ -1,15 +1,15 @@
1
- ---
2
- argument-hint: <branch-name>
3
- ---
4
-
5
- # Create a New Branch
6
-
7
- Create and switch to a new branch.
8
-
9
- ## Instructions
10
-
11
- 1. Ask the user for the branch name if not provided as an argument: $ARGUMENTS
12
- 2. Run `git status` to check for uncommitted changes - warn if any exist
13
- 3. Run `git fetch origin` to ensure we have latest remote state
14
- 4. Create and switch to the new branch from main: `git checkout -b <branch-name> origin/main`
15
- 5. Confirm the new branch was created and is now active
1
+ ---
2
+ argument-hint: <branch-name>
3
+ ---
4
+
5
+ # Create a New Branch
6
+
7
+ Create and switch to a new branch.
8
+
9
+ ## Instructions
10
+
11
+ 1. Ask the user for the branch name if not provided as an argument: $ARGUMENTS
12
+ 2. Run `git status` to check for uncommitted changes - warn if any exist
13
+ 3. Run `git fetch origin` to ensure we have latest remote state
14
+ 4. Create and switch to the new branch from main: `git checkout -b <branch-name> origin/main`
15
+ 5. Confirm the new branch was created and is now active
@@ -1,45 +1,45 @@
1
- ---
2
- argument-hint: [commit message]
3
- ---
4
-
5
- # Check in updated files to GitHub
6
-
7
- Automatically stage, commit, and push all updated files to GitHub with automatic version bumping.
8
-
9
- ## Instructions
10
-
11
- 1. Run `git status` to see what files have changed
12
- 2. If there are no changes, inform the user and stop
13
- 3. Run `git diff` to review the changes
14
- 4. Run the **Pre-Commit Gate** checklist from CLAUDE.md — update any docs before proceeding
15
-
16
- ### Version Bump (Automatic)
17
-
18
- 5. Determine the version bump type from the nature of the changes:
19
- - **patch** (default): Bug fixes, doc updates, refactors, minor improvements, cleanup
20
- - **minor**: New features, new commands, new capabilities
21
- - **major**: Breaking changes, major rework, incompatible API changes
22
- 6. Read the current version from `package.json`
23
- 7. Bump the version according to the determined type:
24
- - **patch**: increment patch by 1 (e.g., `2.24.10` → `2.24.11`)
25
- - **minor**: increment minor, reset patch to **10** (e.g., `2.24.11` → `2.25.10`)
26
- - **major**: increment major, reset minor to 0, reset patch to **10** (e.g., `2.24.11` → `3.0.10`)
27
- - **Patch numbers are always 2 digits (≥10).** After any minor/major reset, start at 10, never 0 or 1.
28
- 8. Update the version in `package.json`
29
- 9. If `.gsd-t/progress.md` exists, check for a `## Version` line and update it (or add one after the `## Date` line)
30
-
31
- ### Release Notes
32
-
33
- 10. If `CHANGELOG.md` exists in the project root, prepend an entry for this version:
34
- - Use the format: `## [X.Y.Z] - YYYY-MM-DD` followed by `### Added`, `### Changed`, `### Fixed`, or `### Removed` subsections as appropriate
35
- - Summarize the changes in 1-3 bullet points per subsection
36
- - Place the new entry directly after the file header (before any existing version entries)
37
-
38
- ### Commit and Push
39
-
40
- 11. Stage all changes (including the version bump and changelog) with `git add -A`
41
- 12. Create a commit with a descriptive message summarizing the changes. Include `(vX.Y.Z)` at the end of the first line. Example: `fix: resolve branch guard edge case (v2.3.1)`
42
- 13. Push to origin with `git push`
43
- 14. Confirm success to the user, including the old → new version
44
-
45
- Use the standard commit message format with Co-Authored-By line.
1
+ ---
2
+ argument-hint: [commit message]
3
+ ---
4
+
5
+ # Check in updated files to GitHub
6
+
7
+ Automatically stage, commit, and push all updated files to GitHub with automatic version bumping.
8
+
9
+ ## Instructions
10
+
11
+ 1. Run `git status` to see what files have changed
12
+ 2. If there are no changes, inform the user and stop
13
+ 3. Run `git diff` to review the changes
14
+ 4. Run the **Pre-Commit Gate** checklist from CLAUDE.md — update any docs before proceeding
15
+
16
+ ### Version Bump (Automatic)
17
+
18
+ 5. Determine the version bump type from the nature of the changes:
19
+ - **patch** (default): Bug fixes, doc updates, refactors, minor improvements, cleanup
20
+ - **minor**: New features, new commands, new capabilities
21
+ - **major**: Breaking changes, major rework, incompatible API changes
22
+ 6. Read the current version from `package.json`
23
+ 7. Bump the version according to the determined type:
24
+ - **patch**: increment patch by 1 (e.g., `2.24.10` → `2.24.11`)
25
+ - **minor**: increment minor, reset patch to **10** (e.g., `2.24.11` → `2.25.10`)
26
+ - **major**: increment major, reset minor to 0, reset patch to **10** (e.g., `2.24.11` → `3.0.10`)
27
+ - **Patch numbers are always 2 digits (≥10).** After any minor/major reset, start at 10, never 0 or 1.
28
+ 8. Update the version in `package.json`
29
+ 9. If `.gsd-t/progress.md` exists, check for a `## Version` line and update it (or add one after the `## Date` line)
30
+
31
+ ### Release Notes
32
+
33
+ 10. If `CHANGELOG.md` exists in the project root, prepend an entry for this version:
34
+ - Use the format: `## [X.Y.Z] - YYYY-MM-DD` followed by `### Added`, `### Changed`, `### Fixed`, or `### Removed` subsections as appropriate
35
+ - Summarize the changes in 1-3 bullet points per subsection
36
+ - Place the new entry directly after the file header (before any existing version entries)
37
+
38
+ ### Commit and Push
39
+
40
+ 11. Stage all changes (including the version bump and changelog) with `git add -A`
41
+ 12. Create a commit with a descriptive message summarizing the changes. Include `(vX.Y.Z)` at the end of the first line. Example: `fix: resolve branch guard edge case (v2.3.1)`
42
+ 13. Push to origin with `git push`
43
+ 14. Confirm success to the user, including the old → new version
44
+
45
+ Use the standard commit message format with Co-Authored-By line.