draht-codex 2026.6.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.
- package/.codex-plugin/plugin.json +44 -0
- package/CHANGELOG.md +15 -0
- package/LICENSE +21 -0
- package/README.md +173 -0
- package/agents/architect.md +56 -0
- package/agents/debugger.md +67 -0
- package/agents/git-committer.md +61 -0
- package/agents/implementer.md +45 -0
- package/agents/reviewer.md +67 -0
- package/agents/security-auditor.md +119 -0
- package/agents/spec-reviewer.md +65 -0
- package/agents/verifier.md +55 -0
- package/bin/draht-tools.cjs +4875 -0
- package/cli.mjs +452 -0
- package/commands/atomic-commit.md +73 -0
- package/commands/discuss-phase.md +55 -0
- package/commands/execute-phase.md +173 -0
- package/commands/fix.md +121 -0
- package/commands/init-project.md +66 -0
- package/commands/map-codebase.md +73 -0
- package/commands/new-project.md +73 -0
- package/commands/next-milestone.md +50 -0
- package/commands/orchestrate.md +83 -0
- package/commands/pause-work.md +38 -0
- package/commands/plan-phase.md +142 -0
- package/commands/progress.md +30 -0
- package/commands/quick.md +95 -0
- package/commands/resume-work.md +35 -0
- package/commands/review.md +87 -0
- package/commands/verify-work.md +122 -0
- package/hooks/hooks.json +26 -0
- package/package.json +55 -0
- package/scripts/gsd-post-phase.cjs +144 -0
- package/scripts/gsd-post-task.cjs +165 -0
- package/scripts/gsd-pre-execute.cjs +146 -0
- package/scripts/gsd-quality-gate.cjs +252 -0
- package/scripts/prompt-context.cjs +36 -0
- package/scripts/session-start.cjs +52 -0
- package/skills/atomic-commit/SKILL.md +14 -0
- package/skills/atomic-reasoning/SKILL.md +107 -0
- package/skills/brainstorming/SKILL.md +120 -0
- package/skills/ddd-workflow/SKILL.md +111 -0
- package/skills/debugging-workflow/SKILL.md +101 -0
- package/skills/discuss-phase/SKILL.md +14 -0
- package/skills/execute-phase/SKILL.md +14 -0
- package/skills/fix/SKILL.md +14 -0
- package/skills/init-project/SKILL.md +14 -0
- package/skills/map-codebase/SKILL.md +14 -0
- package/skills/new-project/SKILL.md +14 -0
- package/skills/next-milestone/SKILL.md +14 -0
- package/skills/orchestrate/SKILL.md +14 -0
- package/skills/pause-work/SKILL.md +14 -0
- package/skills/plan-phase/SKILL.md +14 -0
- package/skills/progress/SKILL.md +14 -0
- package/skills/quick/SKILL.md +14 -0
- package/skills/resume-work/SKILL.md +14 -0
- package/skills/review/SKILL.md +14 -0
- package/skills/tdd-workflow/SKILL.md +117 -0
- package/skills/verification-gate/SKILL.md +82 -0
- package/skills/verify-work/SKILL.md +14 -0
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Draht Quality Gate Hook
|
|
6
|
+
* Runs after task completion to enforce quality standards.
|
|
7
|
+
* Called by the build agent after each verify step.
|
|
8
|
+
*
|
|
9
|
+
* Usage: node gsd-quality-gate.js [--strict]
|
|
10
|
+
* Exit 0 = quality OK, Exit 1 = quality issues
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const { execSync } = require("node:child_process");
|
|
14
|
+
const fs = require("node:fs");
|
|
15
|
+
const path = require("node:path");
|
|
16
|
+
|
|
17
|
+
// ── Toolchain detection — mirrors src/gsd/hook-utils.ts ──────────────────────
|
|
18
|
+
function detectToolchain(cwd) {
|
|
19
|
+
if (fs.existsSync(path.join(cwd, "bun.lockb")) || fs.existsSync(path.join(cwd, "bun.lock"))) {
|
|
20
|
+
return { pm: "bun", testCmd: "bun test", coverageCmd: "bun test --coverage", lintCmd: "bunx biome check ." };
|
|
21
|
+
}
|
|
22
|
+
if (fs.existsSync(path.join(cwd, "pnpm-lock.yaml"))) {
|
|
23
|
+
return { pm: "pnpm", testCmd: "pnpm test", coverageCmd: "pnpm run test:coverage", lintCmd: "pnpm run lint" };
|
|
24
|
+
}
|
|
25
|
+
if (fs.existsSync(path.join(cwd, "yarn.lock"))) {
|
|
26
|
+
return { pm: "yarn", testCmd: "yarn test", coverageCmd: "yarn run test:coverage", lintCmd: "yarn run lint" };
|
|
27
|
+
}
|
|
28
|
+
return { pm: "npm", testCmd: "npm test", coverageCmd: "npm run test:coverage", lintCmd: "npm run lint" };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function readHookConfig(cwd) {
|
|
32
|
+
const defaults = { coverageThreshold: 80, tddMode: "advisory", qualityGateStrict: false };
|
|
33
|
+
const configPath = path.join(cwd, ".planning", "config.json");
|
|
34
|
+
if (!fs.existsSync(configPath)) return defaults;
|
|
35
|
+
try {
|
|
36
|
+
const raw = JSON.parse(fs.readFileSync(configPath, "utf-8"));
|
|
37
|
+
const h = raw.hooks || {};
|
|
38
|
+
return {
|
|
39
|
+
coverageThreshold: typeof h.coverageThreshold === "number" ? h.coverageThreshold : defaults.coverageThreshold,
|
|
40
|
+
tddMode: h.tddMode === "strict" || h.tddMode === "advisory" ? h.tddMode : defaults.tddMode,
|
|
41
|
+
qualityGateStrict: typeof h.qualityGateStrict === "boolean" ? h.qualityGateStrict : defaults.qualityGateStrict,
|
|
42
|
+
};
|
|
43
|
+
} catch { return defaults; }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Inline domain validator — mirrors src/gsd/domain-validator.ts
|
|
47
|
+
function extractGlossaryTerms(content) {
|
|
48
|
+
const terms = new Set();
|
|
49
|
+
const sectionMatch = content.match(/## Ubiquitous Language([\s\S]*?)(?:\n## |$)/);
|
|
50
|
+
const section = sectionMatch ? sectionMatch[1] : content;
|
|
51
|
+
for (const m of section.matchAll(/\*\*([A-Z][a-zA-Z0-9]+)\*\*/g)) terms.add(m[1]);
|
|
52
|
+
for (const m of section.matchAll(/^[-*]\s+([A-Z][a-zA-Z0-9]+)\s*:/gm)) terms.add(m[1]);
|
|
53
|
+
for (const m of section.matchAll(/\|\s*([A-Z][a-zA-Z0-9]+)\s*\|/g)) terms.add(m[1]);
|
|
54
|
+
return terms;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function loadDomainContent(cwd) {
|
|
58
|
+
const modelPath = path.join(cwd, ".planning", "DOMAIN-MODEL.md");
|
|
59
|
+
if (fs.existsSync(modelPath)) return fs.readFileSync(modelPath, "utf-8");
|
|
60
|
+
const domainPath = path.join(cwd, ".planning", "DOMAIN.md");
|
|
61
|
+
if (fs.existsSync(domainPath)) return fs.readFileSync(domainPath, "utf-8");
|
|
62
|
+
return "";
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// ── Main ──────────────────────────────────────────────────────────────────────
|
|
66
|
+
const cwd = process.cwd();
|
|
67
|
+
const toolchain = detectToolchain(cwd);
|
|
68
|
+
const hookConfig = readHookConfig(cwd);
|
|
69
|
+
const strict = process.argv.includes("--strict") || hookConfig.qualityGateStrict;
|
|
70
|
+
const issues = [];
|
|
71
|
+
|
|
72
|
+
// 1. TypeScript check
|
|
73
|
+
try {
|
|
74
|
+
const tsCmd = toolchain.pm === "bun" ? "bun run tsgo --noEmit 2>&1" : "npx tsc --noEmit 2>&1";
|
|
75
|
+
execSync(tsCmd, { timeout: 60000, encoding: "utf-8", cwd });
|
|
76
|
+
} catch (error) {
|
|
77
|
+
const output = error.stdout || error.stderr || "";
|
|
78
|
+
const errorCount = (output.match(/error TS/g) || []).length;
|
|
79
|
+
if (errorCount > 0) {
|
|
80
|
+
issues.push({ severity: strict ? "error" : "warning", message: `${errorCount} TypeScript error(s)`, details: output.slice(0, 500) });
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// 2. Lint check (if biome.json exists use biome, else use toolchain lint)
|
|
85
|
+
if (fs.existsSync(path.join(cwd, "biome.json"))) {
|
|
86
|
+
try {
|
|
87
|
+
execSync(`${toolchain.lintCmd} --error-on-warnings 2>&1`, { timeout: 30000, encoding: "utf-8", cwd });
|
|
88
|
+
} catch (error) {
|
|
89
|
+
const output = error.stdout || error.stderr || "";
|
|
90
|
+
issues.push({ severity: strict ? "error" : "warning", message: "Lint issues", details: output.slice(0, 500) });
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// 3. Run tests
|
|
95
|
+
try {
|
|
96
|
+
const testOutput = execSync(`${toolchain.testCmd} 2>&1`, { timeout: 120000, encoding: "utf-8", cwd });
|
|
97
|
+
const failMatch = testOutput.match(/(\d+) fail/);
|
|
98
|
+
if (failMatch && parseInt(failMatch[1], 10) > 0) {
|
|
99
|
+
issues.push({ severity: strict ? "error" : "warning", message: `${failMatch[1]} test(s) failing` });
|
|
100
|
+
}
|
|
101
|
+
} catch (error) {
|
|
102
|
+
const output = error.stdout || error.stderr || "";
|
|
103
|
+
const failMatch = output.match(/(\d+) fail/);
|
|
104
|
+
if (failMatch && parseInt(failMatch[1], 10) > 0) {
|
|
105
|
+
issues.push({ severity: strict ? "error" : "warning", message: `${failMatch[1]} test(s) failing` });
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// 4. Check for console.log in source files (not tests)
|
|
110
|
+
try {
|
|
111
|
+
const result = execSync(
|
|
112
|
+
"grep -rn 'console\\.log' src/ --include='*.ts' --include='*.tsx' 2>/dev/null | grep -v '// debug' | head -5",
|
|
113
|
+
{ encoding: "utf-8", cwd }
|
|
114
|
+
).trim();
|
|
115
|
+
if (result) {
|
|
116
|
+
issues.push({ severity: "warning", message: "console.log found in source", details: result });
|
|
117
|
+
}
|
|
118
|
+
} catch { /* grep returns 1 when no match — that's fine */ }
|
|
119
|
+
|
|
120
|
+
// 5. Domain glossary compliance (checks DOMAIN-MODEL.md, falls back to DOMAIN.md)
|
|
121
|
+
const domainContent = loadDomainContent(cwd);
|
|
122
|
+
if (domainContent) {
|
|
123
|
+
try {
|
|
124
|
+
const glossaryTerms = extractGlossaryTerms(domainContent);
|
|
125
|
+
const changedFiles = execSync(
|
|
126
|
+
"git diff --cached --name-only 2>/dev/null || git diff --name-only HEAD~1",
|
|
127
|
+
{ encoding: "utf-8", cwd }
|
|
128
|
+
).trim().split("\n").filter((f) => f.endsWith(".ts") || f.endsWith(".tsx"));
|
|
129
|
+
|
|
130
|
+
const unknownTerms = [];
|
|
131
|
+
for (const file of changedFiles) {
|
|
132
|
+
if (!fs.existsSync(path.join(cwd, file))) continue;
|
|
133
|
+
const src = fs.readFileSync(path.join(cwd, file), "utf-8");
|
|
134
|
+
const declarations = [...src.matchAll(/(?:class|interface|type|enum)\s+([A-Z][a-zA-Z0-9]+)/g)].map((m) => m[1]);
|
|
135
|
+
for (const term of declarations) {
|
|
136
|
+
if (!glossaryTerms.has(term)) unknownTerms.push(`${file}: ${term}`);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (unknownTerms.length > 0) {
|
|
140
|
+
issues.push({
|
|
141
|
+
severity: hookConfig.tddMode === "strict" ? "error" : "warning",
|
|
142
|
+
message: `${unknownTerms.length} PascalCase type(s) not in domain glossary (DOMAIN-MODEL.md)`,
|
|
143
|
+
details: unknownTerms.slice(0, 5).join(", "),
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
} catch { /* ignore */ }
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// 6. Bounded context boundary check — flag suspicious cross-directory imports
|
|
150
|
+
try {
|
|
151
|
+
const changedSrcFiles = execSync(
|
|
152
|
+
"git diff --cached --name-only 2>/dev/null || git diff --name-only HEAD~1",
|
|
153
|
+
{ encoding: "utf-8", cwd }
|
|
154
|
+
).trim().split("\n").filter((f) => /^src\/[^/]+\//.test(f) && (f.endsWith(".ts") || f.endsWith(".tsx")));
|
|
155
|
+
|
|
156
|
+
const crossContextImports = [];
|
|
157
|
+
for (const file of changedSrcFiles) {
|
|
158
|
+
if (!fs.existsSync(path.join(cwd, file))) continue;
|
|
159
|
+
const ownContext = file.split("/")[1];
|
|
160
|
+
const src = fs.readFileSync(path.join(cwd, file), "utf-8");
|
|
161
|
+
const imports = [...src.matchAll(/from\s+['"](\.\.\/.+?)['"]/g)].map((m) => m[1]);
|
|
162
|
+
for (const imp of imports) {
|
|
163
|
+
const resolved = path.normalize(path.join(path.dirname(file), imp));
|
|
164
|
+
const parts = resolved.split(path.sep);
|
|
165
|
+
const srcIdx = parts.indexOf("src");
|
|
166
|
+
if (srcIdx !== -1 && parts[srcIdx + 1] && parts[srcIdx + 1] !== ownContext) {
|
|
167
|
+
crossContextImports.push(`${file} → ${parts.slice(srcIdx).join("/")}`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if (crossContextImports.length > 0) {
|
|
172
|
+
issues.push({
|
|
173
|
+
severity: "warning",
|
|
174
|
+
message: `${crossContextImports.length} suspicious cross-context import(s) detected`,
|
|
175
|
+
details: crossContextImports.slice(0, 3).join("; "),
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
} catch { /* ignore */ }
|
|
179
|
+
|
|
180
|
+
// 7. TDD health — check test-to-source file ratio
|
|
181
|
+
try {
|
|
182
|
+
const allSrc = execSync(
|
|
183
|
+
"find src -name '*.ts' -not -name '*.test.ts' -not -name '*.spec.ts' 2>/dev/null | wc -l",
|
|
184
|
+
{ encoding: "utf-8", cwd }
|
|
185
|
+
).trim();
|
|
186
|
+
const allTests = execSync(
|
|
187
|
+
"find src -name '*.test.ts' -o -name '*.spec.ts' 2>/dev/null | wc -l",
|
|
188
|
+
{ encoding: "utf-8", cwd }
|
|
189
|
+
).trim();
|
|
190
|
+
const srcCount = parseInt(allSrc, 10) || 0;
|
|
191
|
+
const testCount = parseInt(allTests, 10) || 0;
|
|
192
|
+
if (srcCount > 0) {
|
|
193
|
+
const ratio = testCount / srcCount;
|
|
194
|
+
if (ratio < 0.3) {
|
|
195
|
+
issues.push({
|
|
196
|
+
severity: "warning",
|
|
197
|
+
message: `TDD health: test-to-source ratio is ${(ratio * 100).toFixed(0)}% (${testCount} tests / ${srcCount} sources) — target ≥ 30%`,
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
} catch { /* ignore — src/ may not exist */ }
|
|
202
|
+
|
|
203
|
+
// 8. Check for TODO/FIXME/HACK comments in changed files
|
|
204
|
+
try {
|
|
205
|
+
const diff = execSync(
|
|
206
|
+
"git diff --cached --name-only 2>/dev/null || git diff --name-only HEAD~1",
|
|
207
|
+
{ encoding: "utf-8", cwd }
|
|
208
|
+
).trim();
|
|
209
|
+
if (diff) {
|
|
210
|
+
const files = diff.split("\n").filter((f) => f.endsWith(".ts") || f.endsWith(".tsx"));
|
|
211
|
+
for (const file of files) {
|
|
212
|
+
try {
|
|
213
|
+
const content = fs.readFileSync(path.join(cwd, file), "utf-8");
|
|
214
|
+
const todos = content.match(/\/\/\s*(TODO|FIXME|HACK|XXX):/gi) || [];
|
|
215
|
+
if (todos.length > 0) {
|
|
216
|
+
issues.push({ severity: "info", message: `${file}: ${todos.length} TODO/FIXME comment(s)` });
|
|
217
|
+
}
|
|
218
|
+
} catch { /* file may not exist */ }
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
} catch { /* ignore */ }
|
|
222
|
+
|
|
223
|
+
// Output
|
|
224
|
+
const errors = issues.filter((i) => i.severity === "error");
|
|
225
|
+
const warnings = issues.filter((i) => i.severity === "warning");
|
|
226
|
+
const infos = issues.filter((i) => i.severity === "info");
|
|
227
|
+
|
|
228
|
+
if (errors.length > 0) {
|
|
229
|
+
console.log(`\n❌ Quality Gate FAILED (${errors.length} error(s)):`);
|
|
230
|
+
for (const e of errors) {
|
|
231
|
+
console.log(` ❌ ${e.message}`);
|
|
232
|
+
if (e.details) console.log(` ${e.details.split("\n")[0]}`);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (warnings.length > 0) {
|
|
237
|
+
console.log(`\n⚠️ ${warnings.length} warning(s):`);
|
|
238
|
+
for (const w of warnings) {
|
|
239
|
+
console.log(` ⚠️ ${w.message}`);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
if (infos.length > 0) {
|
|
244
|
+
console.log(`\nℹ️ ${infos.length} note(s):`);
|
|
245
|
+
for (const i of infos) console.log(` ℹ️ ${i.message}`);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (errors.length === 0 && warnings.length === 0) {
|
|
249
|
+
console.log("✅ Quality gate passed");
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
process.exit(errors.length > 0 ? 1 : 0);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* UserPromptSubmit Hook
|
|
6
|
+
* Injects minimal draht planning context before each user prompt is sent to the model.
|
|
7
|
+
* Only activates in projects with .planning/ and adds at most a short reminder line.
|
|
8
|
+
* Keep output tiny — this runs on every prompt.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const fs = require("node:fs");
|
|
12
|
+
const path = require("node:path");
|
|
13
|
+
|
|
14
|
+
const cwd = process.cwd();
|
|
15
|
+
const PLANNING = path.join(cwd, ".planning");
|
|
16
|
+
|
|
17
|
+
if (!fs.existsSync(PLANNING)) {
|
|
18
|
+
process.exit(0);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const statePath = path.join(PLANNING, "STATE.md");
|
|
22
|
+
if (!fs.existsSync(statePath)) {
|
|
23
|
+
process.exit(0);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
const state = fs.readFileSync(statePath, "utf-8");
|
|
28
|
+
const phaseMatch = state.match(/## Current Phase: (.+)/);
|
|
29
|
+
const statusMatch = state.match(/## Status: (.+)/);
|
|
30
|
+
if (phaseMatch && statusMatch) {
|
|
31
|
+
// Print a single-line reminder. Codex prepends stdout to the prompt context.
|
|
32
|
+
console.log(`[draht] ${phaseMatch[1].trim()} — ${statusMatch[1].trim()}`);
|
|
33
|
+
}
|
|
34
|
+
} catch {}
|
|
35
|
+
|
|
36
|
+
process.exit(0);
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Session Start Hook
|
|
6
|
+
* Surfaces draht planning state when a Codex session starts in a project.
|
|
7
|
+
* - Reports current phase and task from .planning/STATE.md
|
|
8
|
+
* - Flags CONTINUE-HERE.md if the previous session was paused
|
|
9
|
+
* - Silent in projects without .planning/
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const fs = require("node:fs");
|
|
13
|
+
const path = require("node:path");
|
|
14
|
+
|
|
15
|
+
const cwd = process.cwd();
|
|
16
|
+
const PLANNING = path.join(cwd, ".planning");
|
|
17
|
+
|
|
18
|
+
if (!fs.existsSync(PLANNING)) {
|
|
19
|
+
// No draht planning — silent
|
|
20
|
+
process.exit(0);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const lines = [];
|
|
24
|
+
|
|
25
|
+
// STATE.md — current phase + status
|
|
26
|
+
const statePath = path.join(PLANNING, "STATE.md");
|
|
27
|
+
if (fs.existsSync(statePath)) {
|
|
28
|
+
try {
|
|
29
|
+
const state = fs.readFileSync(statePath, "utf-8");
|
|
30
|
+
const phaseMatch = state.match(/## Current Phase: (.+)/);
|
|
31
|
+
const statusMatch = state.match(/## Status: (.+)/);
|
|
32
|
+
const activityMatch = state.match(/## Last Activity: (.+)/);
|
|
33
|
+
if (phaseMatch) lines.push(`Phase: ${phaseMatch[1].trim()}`);
|
|
34
|
+
if (statusMatch) lines.push(`Status: ${statusMatch[1].trim()}`);
|
|
35
|
+
if (activityMatch) lines.push(`Last activity: ${activityMatch[1].trim()}`);
|
|
36
|
+
} catch {}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// CONTINUE-HERE.md — resume marker
|
|
40
|
+
const continuePath = path.join(PLANNING, "CONTINUE-HERE.md");
|
|
41
|
+
if (fs.existsSync(continuePath)) {
|
|
42
|
+
lines.push("");
|
|
43
|
+
lines.push("CONTINUE-HERE.md present — the previous session was paused.");
|
|
44
|
+
lines.push("Run /resume-work to continue, or read .planning/CONTINUE-HERE.md for the handoff.");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (lines.length > 0) {
|
|
48
|
+
console.log("━ Draht planning state ━");
|
|
49
|
+
for (const line of lines) console.log(line);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
process.exit(0);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: atomic-commit
|
|
3
|
+
description: Draht command prompt wrapper for atomic-commit. Use when the user selects the Draht atomic-commit workflow or asks to analyze uncommitted changes and create atomic conventional commits.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Draht Command: atomic-commit
|
|
7
|
+
|
|
8
|
+
This skill exposes the Draht prompt command template to Codex's `$draht` and `/skills` surfaces.
|
|
9
|
+
|
|
10
|
+
When invoked:
|
|
11
|
+
1. Read `../../commands/atomic-commit.md` relative to this `SKILL.md`.
|
|
12
|
+
2. Treat the user's text after the skill mention as `$ARGUMENTS`. If the template uses `$1`, use the first positional argument.
|
|
13
|
+
3. Follow that command template as the active workflow.
|
|
14
|
+
4. Use Draht support skills such as `atomic-reasoning`, `tdd-workflow`, `verification-gate`, or `debugging-workflow` when the command template calls for that discipline.
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: atomic-reasoning
|
|
3
|
+
description: Decompose work into atomic reasoning units before acting — state the logical component, validate independence, verify correctness. The discipline that opens every draht slash command. Use whenever planning, designing, refactoring, breaking down a feature, structuring a commit, or scoping work. Triggers on "plan", "decompose", "break down", "scope", "split", "atomic", "how should I structure", or any moment Codex is about to spawn many parallel changes without first carving the work into independently-verifiable units.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Atomic Reasoning
|
|
7
|
+
|
|
8
|
+
A meta-discipline. Before acting on any non-trivial piece of work, decompose it into atomic units — pieces that can be reasoned about, built, and verified independently.
|
|
9
|
+
|
|
10
|
+
This is the discipline that opens every draht slash command (`/plan-phase`, `/execute-phase`, `/fix`, `/quick`, `/verify-work`, `/atomic-commit`). The skill makes it explicit and available outside those commands too.
|
|
11
|
+
|
|
12
|
+
## The Three Questions
|
|
13
|
+
|
|
14
|
+
For each unit of work you're about to undertake, answer these three questions before doing anything else:
|
|
15
|
+
|
|
16
|
+
### 1. State the Logical Component
|
|
17
|
+
- What does this change do? What is its singular purpose?
|
|
18
|
+
- What observable outcome does it produce?
|
|
19
|
+
- Does it complete a thought, or is it half of one?
|
|
20
|
+
|
|
21
|
+
If you can't state the purpose in one sentence, the unit is not yet atomic — keep decomposing.
|
|
22
|
+
|
|
23
|
+
### 2. Validate Independence
|
|
24
|
+
- Can this be done without touching unrelated features?
|
|
25
|
+
- Does it depend on other units, or is it standalone?
|
|
26
|
+
- Which files does it touch? Are those files coupled to anything outside this unit's concern?
|
|
27
|
+
- If applied alone, would the codebase still build/run?
|
|
28
|
+
|
|
29
|
+
If the answer to "would it build alone" is *no*, the unit is too small — pair it with the dependency. If the answer to "does it touch unrelated concerns" is *yes*, the unit is too big — split it.
|
|
30
|
+
|
|
31
|
+
### 3. Verify Correctness
|
|
32
|
+
- What test or check would prove this unit works?
|
|
33
|
+
- What inputs → what expected outputs or state changes?
|
|
34
|
+
- What edge cases or failure modes exist?
|
|
35
|
+
|
|
36
|
+
If you can't name the proving test, you don't yet understand what "correct" means for this unit. Define it before building.
|
|
37
|
+
|
|
38
|
+
## How to Apply
|
|
39
|
+
|
|
40
|
+
### Before planning a feature
|
|
41
|
+
For each observable user-visible outcome:
|
|
42
|
+
1. State the logical component (what must be true for the user?)
|
|
43
|
+
2. Validate independence (which artifacts prove this? can it be built standalone?)
|
|
44
|
+
3. Verify correctness (what scenarios prove it works?)
|
|
45
|
+
|
|
46
|
+
### Validate a decomposition against the living map
|
|
47
|
+
Run `draht-tools graph-context <file...>` on each unit's files: a unit whose files share one cluster/bounded context is atomic; a unit spanning multiple contexts should be split along the boundary.
|
|
48
|
+
|
|
49
|
+
### Before splitting a commit
|
|
50
|
+
For each file in the diff:
|
|
51
|
+
1. State the logical component (what does this change accomplish?)
|
|
52
|
+
2. Validate independence (would this build alone? does it mix concerns?)
|
|
53
|
+
3. Verify correctness (is the change complete? does it leave a coherent intermediate state?)
|
|
54
|
+
|
|
55
|
+
### Before fixing a bug
|
|
56
|
+
1. State the logical component (what is the observed failure? what should happen vs what does?)
|
|
57
|
+
2. Validate independence (which components are involved? can we isolate it?)
|
|
58
|
+
3. Verify correctness (what test reproduces it reliably? what would prove it fixed?)
|
|
59
|
+
|
|
60
|
+
### Before refactoring
|
|
61
|
+
1. State the logical component (what structural change are you making?)
|
|
62
|
+
2. Validate independence (which behaviour-equivalence test proves this is a refactor, not a rewrite?)
|
|
63
|
+
3. Verify correctness (all tests stay green after the change?)
|
|
64
|
+
|
|
65
|
+
## Atomicity Heuristics
|
|
66
|
+
|
|
67
|
+
A unit is atomic if:
|
|
68
|
+
- ✅ It can be described in one sentence
|
|
69
|
+
- ✅ It can be built or applied in 2–5 minutes of focused work
|
|
70
|
+
- ✅ It can be verified by ONE test or check
|
|
71
|
+
- ✅ It touches ONE concern in the codebase
|
|
72
|
+
- ✅ All files in the atomic unit belong to one bounded context (or explicitly cross a documented boundary) — confirm with `draht-tools graph-context`
|
|
73
|
+
- ✅ It produces ONE commit (or one TDD red→green→refactor trio)
|
|
74
|
+
- ✅ Its `<files>` list contains specific paths, not "all relevant files"
|
|
75
|
+
- ✅ Its outcome is a concrete state change, not "improve X"
|
|
76
|
+
|
|
77
|
+
If any of these fail, decompose further.
|
|
78
|
+
|
|
79
|
+
## Anti-Patterns — STOP
|
|
80
|
+
|
|
81
|
+
- **"Improve performance"** — not atomic. Pick one metric, one bottleneck, one change.
|
|
82
|
+
- **"Refactor the X module"** — not atomic. Pick one structural change with one behaviour-equivalence proof.
|
|
83
|
+
- **"Add error handling"** — not atomic. Pick one error case, one handler, one test.
|
|
84
|
+
- **"Wire up the Y feature"** — not atomic. Decompose into the components, the data flow, and the integration.
|
|
85
|
+
- **"And also fix the related bug while I'm there"** — that's a different atomic unit. Different commit.
|
|
86
|
+
|
|
87
|
+
## Relationship to TDD
|
|
88
|
+
|
|
89
|
+
Atomicity and TDD reinforce each other:
|
|
90
|
+
- TDD's RED phase forces you to name the proving test (Question 3) before building
|
|
91
|
+
- Atomic units fit naturally inside one RED → GREEN → REFACTOR cycle
|
|
92
|
+
- A test that requires changes in multiple unrelated files means the unit is not atomic
|
|
93
|
+
|
|
94
|
+
## Relationship to /atomic-commit
|
|
95
|
+
|
|
96
|
+
`/atomic-commit` is this skill applied to the git history: each commit is one atomic unit. The questions are the same; the artifact is a commit instead of a plan task.
|
|
97
|
+
|
|
98
|
+
## Relationship to subagent dispatch
|
|
99
|
+
|
|
100
|
+
Subagents work best on atomic units. When dispatching:
|
|
101
|
+
- Each subagent task should answer the three questions inside its prompt
|
|
102
|
+
- Parallel dispatch is only safe when units are genuinely independent (Question 2)
|
|
103
|
+
- A subagent returning `STATUS: BLOCKED — complexity` often means the unit wasn't atomic — split it.
|
|
104
|
+
|
|
105
|
+
## Output
|
|
106
|
+
|
|
107
|
+
This skill produces *thought*, not files. The artifact is a clearer plan / commit / fix scope before any code is written.
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: brainstorming
|
|
3
|
+
description: Socratic ideation gate before any project work begins. Use when the user has a fuzzy idea, vague project intent, or asks "what should I build", "I'm thinking about X", "I want to make a Y" without a clear spec. Runs BEFORE /new-project, /init-project, or any code. Refuses to plan or code until the design has been refined through dialogue and written to .planning/specs/. Triggers on phrases like "brainstorm", "idea", "what about", "I'm thinking", "design", "should I", "help me figure out", "let's discuss".
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Brainstorming
|
|
7
|
+
|
|
8
|
+
The pre-planning gate. Before draht's GSD cycle runs, before code is scaffolded, before /new-project or /init-project, the idea has to be converged on. This skill enforces design-first discipline through dialogue.
|
|
9
|
+
|
|
10
|
+
## The Hard Gate
|
|
11
|
+
|
|
12
|
+
> Do NOT invoke any planning skill, write any code, scaffold any project, or take any implementation action until you have:
|
|
13
|
+
> 1. Asked clarifying questions one at a time
|
|
14
|
+
> 2. Proposed 2–3 approaches with trade-offs
|
|
15
|
+
> 3. Presented a structured design and the user has approved it
|
|
16
|
+
> 4. Written the design to `.planning/specs/YYYY-MM-DD-<slug>-design.md`
|
|
17
|
+
|
|
18
|
+
If the user pushes to skip ("just build it"), surface the trade-off: "I can scaffold something now, but skipping brainstorming usually means we throw out the first version. Are you sure?" If yes, proceed but make the assumption explicit in the spec.
|
|
19
|
+
|
|
20
|
+
## The Process
|
|
21
|
+
|
|
22
|
+
### 1. Explore Context
|
|
23
|
+
|
|
24
|
+
Before asking anything, read what's already on disk:
|
|
25
|
+
- `git log --oneline -30` — what has the user been working on recently?
|
|
26
|
+
- `ls -la` — what's in the project root?
|
|
27
|
+
- `.planning/` if it exists — is there an active project?
|
|
28
|
+
- `README.md`, `package.json`, any `*.md` in root — what does this codebase claim to do?
|
|
29
|
+
|
|
30
|
+
If an existing codebase is in play (extending a real project), run `draht-tools map-codebase` + `draht-tools graph-hotspots` first to ground ideation in the real structure — so brainstormed ideas don't contradict existing architecture.
|
|
31
|
+
|
|
32
|
+
Use this to ground questions in reality instead of asking things the user has already told you.
|
|
33
|
+
|
|
34
|
+
### 2. Ask Clarifying Questions — ONE at a time
|
|
35
|
+
|
|
36
|
+
Most failed projects come from rushing past ambiguity. Ask **one focused question per message**, not a long list. Wait for the answer, then ask the next.
|
|
37
|
+
|
|
38
|
+
Question categories (sequence from foundational → detailed):
|
|
39
|
+
- **Goal** — who is this for? what changes for them when it ships?
|
|
40
|
+
- **Constraints** — deadline? budget? team size? language/stack preferences?
|
|
41
|
+
- **Scope** — what's in v1? what's explicitly NOT in v1?
|
|
42
|
+
- **Success criteria** — how do we know it works? what's the demoable outcome?
|
|
43
|
+
- **Domain** — what are the key nouns and verbs in this space? any existing glossary?
|
|
44
|
+
- **Risks** — what's the scariest part of this? what would make it fail?
|
|
45
|
+
|
|
46
|
+
If the project is obviously oversized for one cycle (e.g., "I want to build a social network"), flag it explicitly and propose decomposition into a v1 / v2 / out-of-scope split.
|
|
47
|
+
|
|
48
|
+
### 3. Propose 2–3 Approaches With Trade-offs
|
|
49
|
+
|
|
50
|
+
Once you have enough context, propose multiple approaches:
|
|
51
|
+
- Approach A: the simplest path. What it sacrifices.
|
|
52
|
+
- Approach B: the most flexible. What it costs.
|
|
53
|
+
- (Optional) Approach C: the most ambitious. Why it's tempting and why it might be too much.
|
|
54
|
+
|
|
55
|
+
For each: list trade-offs in plain language (time, complexity, future flexibility, lock-in). Let the user pick — don't pre-pick for them.
|
|
56
|
+
|
|
57
|
+
### 4. Present the Design in Sections, Each With an Approval Gate
|
|
58
|
+
|
|
59
|
+
Once an approach is chosen, present the design **section by section**, not all at once:
|
|
60
|
+
1. Goal & non-goals
|
|
61
|
+
2. User stories / observable truths
|
|
62
|
+
3. Domain model (bounded contexts, key nouns)
|
|
63
|
+
4. Architecture sketch (components, data flow)
|
|
64
|
+
5. v1 scope (what ships) vs v2/out-of-scope (what doesn't)
|
|
65
|
+
6. Open questions / risks
|
|
66
|
+
|
|
67
|
+
After each section, ask: "Does this match what you want, or should we adjust?" Only move to the next section once the current one is approved.
|
|
68
|
+
|
|
69
|
+
### 5. Write the Spec to `.planning/specs/`
|
|
70
|
+
|
|
71
|
+
Once all sections are approved:
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
.planning/specs/YYYY-MM-DD-<topic-slug>-design.md
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
The file should include:
|
|
78
|
+
- Header with date and approver
|
|
79
|
+
- All approved sections
|
|
80
|
+
- Open questions section (the things you flagged but didn't resolve)
|
|
81
|
+
- Next step: which draht command picks this up (`/new-project` or `/init-project`)
|
|
82
|
+
|
|
83
|
+
### 6. Self-Review the Written Spec
|
|
84
|
+
|
|
85
|
+
Before handing off, re-read the spec yourself looking for:
|
|
86
|
+
- Contradictions between sections (the goal says X, the architecture implies not-X)
|
|
87
|
+
- Gaps (a user story with no architectural support)
|
|
88
|
+
- Premature commitments (specific tech choices made before they were needed)
|
|
89
|
+
- Domain language drift (different names for the same thing)
|
|
90
|
+
|
|
91
|
+
Report any findings to the user and update before proceeding.
|
|
92
|
+
|
|
93
|
+
### 7. Hand Off
|
|
94
|
+
|
|
95
|
+
Direct the user to the next command:
|
|
96
|
+
- Greenfield with no codebase → `/new-project`
|
|
97
|
+
- Existing codebase → `/init-project`
|
|
98
|
+
|
|
99
|
+
The spec file becomes input to those commands.
|
|
100
|
+
|
|
101
|
+
## Anti-Patterns — STOP
|
|
102
|
+
|
|
103
|
+
- **Asking multiple questions in one message** — splits the user's attention, lowers answer quality
|
|
104
|
+
- **Pre-deciding before they've answered** — "I'll just assume you mean X" is a failure mode
|
|
105
|
+
- **Skipping the alternatives** — proposing only one approach hides the trade-space
|
|
106
|
+
- **Writing the spec before approval** — the spec records *decisions*, not *proposals*. Get the decision first.
|
|
107
|
+
- **Brainstorming code** — this skill is for the design, not the implementation. Resist the urge to start writing.
|
|
108
|
+
|
|
109
|
+
## Rationalization Table
|
|
110
|
+
|
|
111
|
+
| Excuse | Reality |
|
|
112
|
+
|--------|---------|
|
|
113
|
+
| "It's a simple project, no need to brainstorm" | Simple projects also have ambiguous scope. The skill is fast for simple ones. |
|
|
114
|
+
| "User said 'just build it'" | They'll be unhappier when the wrong thing gets built. Surface the trade-off. |
|
|
115
|
+
| "I already know what they want" | Verify by stating it back and getting confirmation. |
|
|
116
|
+
| "Let's iterate after a first draft" | A first draft in code is more expensive to throw away than a first draft on paper. |
|
|
117
|
+
|
|
118
|
+
## Output
|
|
119
|
+
|
|
120
|
+
Brainstorming ends with a written spec file in `.planning/specs/`. That file is the artifact. If no file is written, the skill did not complete.
|