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
package/cli.mjs
ADDED
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* draht-codex CLI: installs this package as a Codex plugin via a local marketplace.
|
|
4
|
+
*
|
|
5
|
+
* Architecture:
|
|
6
|
+
* 1. Copy plugin files into ~/.draht/codex-marketplace/plugins/draht/
|
|
7
|
+
* 2. Write .agents/plugins/marketplace.json for Codex
|
|
8
|
+
* 3. Shell out to `codex plugin marketplace add` and `codex plugin add`
|
|
9
|
+
* 4. Codex tracks the plugin in its own cache and config
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* npx draht-codex install [--path <dir>] [--force]
|
|
13
|
+
* npx draht-codex uninstall [--path <dir>]
|
|
14
|
+
* npx draht-codex update [--path <dir>]
|
|
15
|
+
* npx draht-codex status [--path <dir>]
|
|
16
|
+
* npx draht-codex draht-tools <subcommand> [...args]
|
|
17
|
+
* npx draht-codex --help
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { execSync, spawnSync } from "node:child_process";
|
|
21
|
+
import * as fs from "node:fs";
|
|
22
|
+
import * as os from "node:os";
|
|
23
|
+
import * as path from "node:path";
|
|
24
|
+
import { fileURLToPath } from "node:url";
|
|
25
|
+
|
|
26
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
27
|
+
const PACKAGE_ROOT = __dirname;
|
|
28
|
+
|
|
29
|
+
const MARKETPLACE_NAME = "draht";
|
|
30
|
+
const PLUGIN_NAME = "draht";
|
|
31
|
+
const DEFAULT_MARKETPLACE_DIR = path.join(os.homedir(), ".draht", "codex-marketplace");
|
|
32
|
+
|
|
33
|
+
const IGNORE = new Set([
|
|
34
|
+
"node_modules",
|
|
35
|
+
"package.json",
|
|
36
|
+
"cli.mjs",
|
|
37
|
+
".npmignore",
|
|
38
|
+
".DS_Store",
|
|
39
|
+
"CHANGELOG.md",
|
|
40
|
+
]);
|
|
41
|
+
|
|
42
|
+
function parseArgs(argv) {
|
|
43
|
+
const args = argv.slice(2);
|
|
44
|
+
const command = args[0];
|
|
45
|
+
const flags = { path: null, force: false, help: false, agent: null, model: null, list: false, reset: false };
|
|
46
|
+
const passthrough = [];
|
|
47
|
+
|
|
48
|
+
for (let i = 1; i < args.length; i++) {
|
|
49
|
+
const a = args[i];
|
|
50
|
+
if (command === "draht-tools") {
|
|
51
|
+
passthrough.push(a);
|
|
52
|
+
} else if (a === "--path" || a === "-p") {
|
|
53
|
+
flags.path = args[++i];
|
|
54
|
+
} else if (a === "--force" || a === "-f") {
|
|
55
|
+
flags.force = true;
|
|
56
|
+
} else if (a === "--help" || a === "-h") {
|
|
57
|
+
flags.help = true;
|
|
58
|
+
} else if (a === "--agent" || a === "-a") {
|
|
59
|
+
flags.agent = args[++i];
|
|
60
|
+
} else if (a === "--model" || a === "-m") {
|
|
61
|
+
flags.model = args[++i];
|
|
62
|
+
} else if (a === "--list" || a === "-l") {
|
|
63
|
+
flags.list = true;
|
|
64
|
+
} else if (a === "--reset" || a === "-r") {
|
|
65
|
+
flags.reset = true;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (!command || command === "--help" || command === "-h") flags.help = true;
|
|
70
|
+
return { command, flags, passthrough };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function printHelp() {
|
|
74
|
+
console.log(`draht-codex - install and configure the draht Codex plugin
|
|
75
|
+
|
|
76
|
+
Usage:
|
|
77
|
+
npx draht-codex install Install as a Codex plugin
|
|
78
|
+
npx draht-codex install --force Reinstall even if already present
|
|
79
|
+
npx draht-codex install --path DIR Custom marketplace directory
|
|
80
|
+
npx draht-codex uninstall Remove the plugin and marketplace
|
|
81
|
+
npx draht-codex update Reinstall (same as install --force)
|
|
82
|
+
npx draht-codex status Show install state
|
|
83
|
+
npx draht-codex configure Configure bundled reference agent models
|
|
84
|
+
--agent <name> --model <model> Set model metadata for a specific agent
|
|
85
|
+
--agent <name> --reset Reset agent model metadata
|
|
86
|
+
--reset Reset all agent model metadata
|
|
87
|
+
--list List current agent model metadata
|
|
88
|
+
npx draht-codex draht-tools ... Run the bundled draht-tools CLI
|
|
89
|
+
|
|
90
|
+
Options:
|
|
91
|
+
-p, --path <dir> Custom local marketplace directory
|
|
92
|
+
-f, --force Overwrite existing install
|
|
93
|
+
-h, --help Show this help
|
|
94
|
+
|
|
95
|
+
What this installs:
|
|
96
|
+
- Local Codex marketplace named "${MARKETPLACE_NAME}" at ~/.draht/codex-marketplace/
|
|
97
|
+
- Plugin "${PLUGIN_NAME}" inside that marketplace
|
|
98
|
+
- Draht command prompt wrappers, reference prompt templates, specialist agent prompts, support skills, hooks, and scripts
|
|
99
|
+
- Self-contained draht-tools CLI
|
|
100
|
+
|
|
101
|
+
After install, restart Codex. Use $draht:<command> or /skills and select the command wrapper.
|
|
102
|
+
Prompt templates remain installed under commands/; Codex CLI currently does not expose plugin commands as slash commands.
|
|
103
|
+
|
|
104
|
+
Docs: https://draht.dev
|
|
105
|
+
`);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function log(msg) {
|
|
109
|
+
console.log(msg);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function err(msg) {
|
|
113
|
+
console.error(`error: ${msg}`);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function readPluginManifest() {
|
|
117
|
+
const manifestPath = path.join(PACKAGE_ROOT, ".codex-plugin", "plugin.json");
|
|
118
|
+
if (!fs.existsSync(manifestPath)) {
|
|
119
|
+
err(`Plugin manifest not found at ${manifestPath}`);
|
|
120
|
+
err("Reinstall via 'npx draht-codex@latest install'.");
|
|
121
|
+
process.exit(1);
|
|
122
|
+
}
|
|
123
|
+
return JSON.parse(fs.readFileSync(manifestPath, "utf-8"));
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function copyRecursive(src, dest) {
|
|
127
|
+
const stat = fs.statSync(src);
|
|
128
|
+
if (stat.isDirectory()) {
|
|
129
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
130
|
+
for (const entry of fs.readdirSync(src)) {
|
|
131
|
+
if (IGNORE.has(entry)) continue;
|
|
132
|
+
copyRecursive(path.join(src, entry), path.join(dest, entry));
|
|
133
|
+
}
|
|
134
|
+
} else {
|
|
135
|
+
fs.copyFileSync(src, dest);
|
|
136
|
+
const parentDir = path.basename(path.dirname(src));
|
|
137
|
+
if ((parentDir === "bin" || parentDir === "scripts") && (stat.mode & 0o111) !== 0) {
|
|
138
|
+
fs.chmodSync(dest, 0o755);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function removeRecursive(target) {
|
|
144
|
+
if (!fs.existsSync(target)) return;
|
|
145
|
+
fs.rmSync(target, { recursive: true, force: true });
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function hasCodexCli() {
|
|
149
|
+
const which = spawnSync(process.platform === "win32" ? "where" : "which", ["codex"], { encoding: "utf-8" });
|
|
150
|
+
return which.status === 0 && which.stdout.trim().length > 0;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function runCodex(args, { allowFail = false } = {}) {
|
|
154
|
+
log(` $ codex ${args.join(" ")}`);
|
|
155
|
+
const res = spawnSync("codex", args, { stdio: "inherit" });
|
|
156
|
+
if (res.status !== 0 && !allowFail) {
|
|
157
|
+
err(`codex ${args[0]} ${args[1] || ""} failed with exit code ${res.status}`);
|
|
158
|
+
process.exit(1);
|
|
159
|
+
}
|
|
160
|
+
return res.status === 0;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function setModelInFrontmatter(content, model) {
|
|
164
|
+
const match = content.match(/^---\n([\s\S]*?)\n---\n?/);
|
|
165
|
+
if (!match) return content;
|
|
166
|
+
const lines = match[1].split("\n");
|
|
167
|
+
const modelIdx = lines.findIndex((line) => line.trim().startsWith("model:"));
|
|
168
|
+
if (model === null || model === undefined) {
|
|
169
|
+
if (modelIdx >= 0) lines.splice(modelIdx, 1);
|
|
170
|
+
} else {
|
|
171
|
+
const modelLine = `model: ${model}`;
|
|
172
|
+
if (modelIdx >= 0) {
|
|
173
|
+
lines[modelIdx] = modelLine;
|
|
174
|
+
} else {
|
|
175
|
+
lines.push(modelLine);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
const body = content.slice(match[0].length);
|
|
179
|
+
return `---\n${lines.join("\n")}\n---\n${body}`;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function writeMarketplaceManifest(marketplaceDir, pluginManifest) {
|
|
183
|
+
const manifest = {
|
|
184
|
+
name: MARKETPLACE_NAME,
|
|
185
|
+
interface: {
|
|
186
|
+
displayName: "Draht",
|
|
187
|
+
},
|
|
188
|
+
plugins: [
|
|
189
|
+
{
|
|
190
|
+
name: PLUGIN_NAME,
|
|
191
|
+
source: {
|
|
192
|
+
source: "local",
|
|
193
|
+
path: `./plugins/${PLUGIN_NAME}`,
|
|
194
|
+
},
|
|
195
|
+
policy: {
|
|
196
|
+
installation: "AVAILABLE",
|
|
197
|
+
authentication: "ON_INSTALL",
|
|
198
|
+
},
|
|
199
|
+
category: pluginManifest.interface?.category || "Coding",
|
|
200
|
+
},
|
|
201
|
+
],
|
|
202
|
+
};
|
|
203
|
+
const manifestDir = path.join(marketplaceDir, ".agents", "plugins");
|
|
204
|
+
fs.mkdirSync(manifestDir, { recursive: true });
|
|
205
|
+
fs.writeFileSync(path.join(manifestDir, "marketplace.json"), `${JSON.stringify(manifest, null, 2)}\n`);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function cmdInstall(flags) {
|
|
209
|
+
const marketplaceDir = flags.path || DEFAULT_MARKETPLACE_DIR;
|
|
210
|
+
const pluginDir = path.join(marketplaceDir, "plugins", PLUGIN_NAME);
|
|
211
|
+
const pluginSpec = `${PLUGIN_NAME}@${MARKETPLACE_NAME}`;
|
|
212
|
+
const manifest = readPluginManifest();
|
|
213
|
+
|
|
214
|
+
log("draht-codex installer");
|
|
215
|
+
log(` plugin: ${manifest.name} v${manifest.version}`);
|
|
216
|
+
log(` source: ${PACKAGE_ROOT}`);
|
|
217
|
+
log(` marketplace: ${marketplaceDir}`);
|
|
218
|
+
log(` plugin dir: ${pluginDir}`);
|
|
219
|
+
log("");
|
|
220
|
+
|
|
221
|
+
if (!hasCodexCli()) {
|
|
222
|
+
err("codex CLI not found in PATH");
|
|
223
|
+
err("Install Codex first: https://developers.openai.com/codex");
|
|
224
|
+
process.exit(1);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (fs.existsSync(pluginDir) && !flags.force) {
|
|
228
|
+
err(`plugin already installed at ${pluginDir}`);
|
|
229
|
+
err("use --force to reinstall, or 'draht-codex update' to refresh");
|
|
230
|
+
process.exit(1);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
log("Copying plugin files...");
|
|
234
|
+
if (flags.force && fs.existsSync(pluginDir)) {
|
|
235
|
+
removeRecursive(pluginDir);
|
|
236
|
+
}
|
|
237
|
+
fs.mkdirSync(pluginDir, { recursive: true });
|
|
238
|
+
copyRecursive(PACKAGE_ROOT, pluginDir);
|
|
239
|
+
|
|
240
|
+
log("Writing marketplace.json...");
|
|
241
|
+
writeMarketplaceManifest(marketplaceDir, manifest);
|
|
242
|
+
|
|
243
|
+
log("Registering marketplace with Codex...");
|
|
244
|
+
runCodex(["plugin", "marketplace", "add", marketplaceDir], { allowFail: true });
|
|
245
|
+
|
|
246
|
+
if (flags.force) {
|
|
247
|
+
log("Removing previous installed plugin cache...");
|
|
248
|
+
runCodex(["plugin", "remove", pluginSpec], { allowFail: true });
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
log("Installing plugin...");
|
|
252
|
+
runCodex(["plugin", "add", pluginSpec]);
|
|
253
|
+
|
|
254
|
+
log("");
|
|
255
|
+
log(`installed ${pluginSpec} v${manifest.version}`);
|
|
256
|
+
log("");
|
|
257
|
+
log("Next steps:");
|
|
258
|
+
log(" 1. Restart Codex so it picks up plugin content and hooks");
|
|
259
|
+
log(" 2. Run `codex plugin list` and confirm draht@draht is installed");
|
|
260
|
+
log(" 3. Use `$draht:<command>` or `/skills` and select the command wrapper");
|
|
261
|
+
log("");
|
|
262
|
+
log("Docs: https://draht.dev");
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function cmdUninstall(flags) {
|
|
266
|
+
const marketplaceDir = flags.path || DEFAULT_MARKETPLACE_DIR;
|
|
267
|
+
const pluginSpec = `${PLUGIN_NAME}@${MARKETPLACE_NAME}`;
|
|
268
|
+
|
|
269
|
+
log("draht-codex uninstaller");
|
|
270
|
+
log(` marketplace: ${marketplaceDir}`);
|
|
271
|
+
log(` plugin: ${pluginSpec}`);
|
|
272
|
+
log("");
|
|
273
|
+
|
|
274
|
+
if (hasCodexCli()) {
|
|
275
|
+
log("Removing plugin from Codex...");
|
|
276
|
+
runCodex(["plugin", "remove", pluginSpec], { allowFail: true });
|
|
277
|
+
log("Removing marketplace from Codex...");
|
|
278
|
+
runCodex(["plugin", "marketplace", "remove", MARKETPLACE_NAME], { allowFail: true });
|
|
279
|
+
} else {
|
|
280
|
+
log("(codex CLI not found; skipping Codex registry cleanup)");
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
if (fs.existsSync(marketplaceDir)) {
|
|
284
|
+
log(`Removing ${marketplaceDir}...`);
|
|
285
|
+
removeRecursive(marketplaceDir);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
log("");
|
|
289
|
+
log("uninstalled");
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function cmdUpdate(flags) {
|
|
293
|
+
cmdInstall({ ...flags, force: true });
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function cmdStatus(flags) {
|
|
297
|
+
const marketplaceDir = flags.path || DEFAULT_MARKETPLACE_DIR;
|
|
298
|
+
const pluginDir = path.join(marketplaceDir, "plugins", PLUGIN_NAME);
|
|
299
|
+
const pluginManifestPath = path.join(pluginDir, ".codex-plugin", "plugin.json");
|
|
300
|
+
|
|
301
|
+
log(`marketplace dir: ${marketplaceDir}`);
|
|
302
|
+
|
|
303
|
+
if (!fs.existsSync(pluginManifestPath)) {
|
|
304
|
+
log("status: not installed");
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
try {
|
|
309
|
+
const manifest = JSON.parse(fs.readFileSync(pluginManifestPath, "utf-8"));
|
|
310
|
+
log("status: files present");
|
|
311
|
+
log(`plugin: ${manifest.name} v${manifest.version}`);
|
|
312
|
+
log(`description: ${manifest.description || "(none)"}`);
|
|
313
|
+
} catch (error) {
|
|
314
|
+
log(`status: files present (manifest unreadable: ${error.message})`);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
if (hasCodexCli()) {
|
|
318
|
+
log("");
|
|
319
|
+
log("Codex plugin list:");
|
|
320
|
+
try {
|
|
321
|
+
const out = execSync("codex plugin list", { encoding: "utf-8" });
|
|
322
|
+
process.stdout.write(out);
|
|
323
|
+
} catch {
|
|
324
|
+
log(" (failed to run `codex plugin list`)");
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
function cmdConfigure(flags) {
|
|
330
|
+
const marketplaceDir = flags.path || DEFAULT_MARKETPLACE_DIR;
|
|
331
|
+
const pluginDir = path.join(marketplaceDir, "plugins", PLUGIN_NAME);
|
|
332
|
+
const agentsDir = path.join(pluginDir, "agents");
|
|
333
|
+
|
|
334
|
+
if (!fs.existsSync(pluginDir)) {
|
|
335
|
+
err(`plugin not installed at ${pluginDir}`);
|
|
336
|
+
err("run 'draht-codex install' first");
|
|
337
|
+
process.exit(1);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
if (flags.list) {
|
|
341
|
+
if (!fs.existsSync(agentsDir)) {
|
|
342
|
+
log("no agents directory found");
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
const files = fs.readdirSync(agentsDir).filter((file) => file.endsWith(".md"));
|
|
346
|
+
if (files.length === 0) {
|
|
347
|
+
log("no agents found");
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
log("Agent model metadata:");
|
|
351
|
+
for (const file of files.sort()) {
|
|
352
|
+
const content = fs.readFileSync(path.join(agentsDir, file), "utf-8");
|
|
353
|
+
const match = content.match(/^---\n([\s\S]*?)\n---\n?/);
|
|
354
|
+
let model = "inherit";
|
|
355
|
+
if (match) {
|
|
356
|
+
const modelLine = match[1].split("\n").find((line) => line.trim().startsWith("model:"));
|
|
357
|
+
if (modelLine) {
|
|
358
|
+
model = modelLine.split(":").slice(1).join(":").trim();
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
log(` ${file.replace(".md", "")}: ${model}`);
|
|
362
|
+
}
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
if (flags.reset) {
|
|
367
|
+
if (flags.agent) {
|
|
368
|
+
const agentFile = path.join(agentsDir, `${flags.agent}.md`);
|
|
369
|
+
if (!fs.existsSync(agentFile)) {
|
|
370
|
+
err(`agent not found: ${flags.agent}`);
|
|
371
|
+
process.exit(1);
|
|
372
|
+
}
|
|
373
|
+
const content = fs.readFileSync(agentFile, "utf-8");
|
|
374
|
+
fs.writeFileSync(agentFile, setModelInFrontmatter(content, null));
|
|
375
|
+
log(`reset model metadata for ${flags.agent}`);
|
|
376
|
+
} else {
|
|
377
|
+
if (!fs.existsSync(agentsDir)) return;
|
|
378
|
+
const files = fs.readdirSync(agentsDir).filter((file) => file.endsWith(".md"));
|
|
379
|
+
for (const file of files) {
|
|
380
|
+
const agentFile = path.join(agentsDir, file);
|
|
381
|
+
const content = fs.readFileSync(agentFile, "utf-8");
|
|
382
|
+
fs.writeFileSync(agentFile, setModelInFrontmatter(content, null));
|
|
383
|
+
}
|
|
384
|
+
log("reset model metadata for all agents");
|
|
385
|
+
}
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
if (!flags.agent || !flags.model) {
|
|
390
|
+
err("configure requires --agent <name> and --model <model>");
|
|
391
|
+
err("run 'draht-codex configure --help' for usage");
|
|
392
|
+
process.exit(1);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
const agentFile = path.join(agentsDir, `${flags.agent}.md`);
|
|
396
|
+
if (!fs.existsSync(agentFile)) {
|
|
397
|
+
err(`agent not found: ${flags.agent}`);
|
|
398
|
+
const available = fs.existsSync(agentsDir)
|
|
399
|
+
? fs.readdirSync(agentsDir).filter((file) => file.endsWith(".md")).map((file) => file.replace(".md", "")).join(", ")
|
|
400
|
+
: "(none)";
|
|
401
|
+
err(`available agents: ${available}`);
|
|
402
|
+
process.exit(1);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
const content = fs.readFileSync(agentFile, "utf-8");
|
|
406
|
+
fs.writeFileSync(agentFile, setModelInFrontmatter(content, flags.model));
|
|
407
|
+
log(`set model metadata for ${flags.agent} to ${flags.model}`);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
function cmdDrahtTools(args) {
|
|
411
|
+
const toolPath = path.join(PACKAGE_ROOT, "bin", "draht-tools.cjs");
|
|
412
|
+
if (!fs.existsSync(toolPath)) {
|
|
413
|
+
err(`bundled draht-tools not found at ${toolPath}`);
|
|
414
|
+
process.exit(1);
|
|
415
|
+
}
|
|
416
|
+
const res = spawnSync(process.execPath, [toolPath, ...args], { stdio: "inherit" });
|
|
417
|
+
process.exit(res.status || 0);
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
const { command, flags, passthrough } = parseArgs(process.argv);
|
|
421
|
+
|
|
422
|
+
if (flags.help) {
|
|
423
|
+
printHelp();
|
|
424
|
+
process.exit(0);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
switch (command) {
|
|
428
|
+
case "install":
|
|
429
|
+
cmdInstall(flags);
|
|
430
|
+
break;
|
|
431
|
+
case "uninstall":
|
|
432
|
+
case "remove":
|
|
433
|
+
cmdUninstall(flags);
|
|
434
|
+
break;
|
|
435
|
+
case "update":
|
|
436
|
+
case "upgrade":
|
|
437
|
+
cmdUpdate(flags);
|
|
438
|
+
break;
|
|
439
|
+
case "status":
|
|
440
|
+
cmdStatus(flags);
|
|
441
|
+
break;
|
|
442
|
+
case "configure":
|
|
443
|
+
cmdConfigure(flags);
|
|
444
|
+
break;
|
|
445
|
+
case "draht-tools":
|
|
446
|
+
cmdDrahtTools(passthrough);
|
|
447
|
+
break;
|
|
448
|
+
default:
|
|
449
|
+
err(`unknown command: ${command}`);
|
|
450
|
+
err("run 'draht-codex --help' for usage");
|
|
451
|
+
process.exit(1);
|
|
452
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Analyze uncommitted changes and create atomic conventional commits (one logical change per commit)
|
|
3
|
+
allowed-tools: Bash, Read, Task
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# /atomic-commit
|
|
7
|
+
|
|
8
|
+
Analyze changes and create atomic commits.
|
|
9
|
+
|
|
10
|
+
## Red Flags — STOP
|
|
11
|
+
|
|
12
|
+
Do NOT proceed with a commit if **any** of these is true:
|
|
13
|
+
|
|
14
|
+
- A single proposed commit mixes unrelated concerns (e.g., a feature + an unrelated refactor + a config tweak)
|
|
15
|
+
- The change set contains potential secrets (`.env`, credentials, API keys in source)
|
|
16
|
+
- Staged content includes files unrelated to the user's stated intent (stale build artifacts, IDE configs, scratch files)
|
|
17
|
+
- Pre-commit hooks fail — fix the cause, never use `--no-verify`
|
|
18
|
+
- You cannot articulate the "why" of a commit in one sentence — that's a sign it contains more than one logical change
|
|
19
|
+
|
|
20
|
+
If any of these triggers, surface the issue to the user and split the change set before continuing.
|
|
21
|
+
|
|
22
|
+
## Atomic Reasoning
|
|
23
|
+
|
|
24
|
+
Before creating commits, decompose changes into atomic reasoning units:
|
|
25
|
+
|
|
26
|
+
**For each file change:**
|
|
27
|
+
1. **State the logical component** — What does this change do? What is its purpose? Does it complete a thought?
|
|
28
|
+
2. **Validate independence** — Can this change be applied independently? Does it depend on other changes? Does it break the build alone?
|
|
29
|
+
3. **Verify correctness** — Is this change logically complete? Does it mix concerns? Should it be split further?
|
|
30
|
+
|
|
31
|
+
**Synthesize commit strategy:**
|
|
32
|
+
- Group changes by logical concern (one commit = one idea)
|
|
33
|
+
- Order commits so each builds successfully
|
|
34
|
+
- Write clear commit messages that explain WHY, not just WHAT
|
|
35
|
+
- Ensure each commit is self-contained and reviewable
|
|
36
|
+
|
|
37
|
+
## Gathering Current State
|
|
38
|
+
|
|
39
|
+
First, gather the current state:
|
|
40
|
+
|
|
41
|
+
1. Run `git status` to see what changed
|
|
42
|
+
2. Run `git diff` to see unstaged changes
|
|
43
|
+
3. Run `git diff --cached` to see staged changes
|
|
44
|
+
|
|
45
|
+
## Strategy
|
|
46
|
+
|
|
47
|
+
Based on the changes, analyze and group them into logical, ATOMIC commits. Each commit should:
|
|
48
|
+
|
|
49
|
+
1. Contain ONE logical change only
|
|
50
|
+
2. Be self-contained and complete
|
|
51
|
+
3. Not break the build if applied independently
|
|
52
|
+
|
|
53
|
+
You may delegate this work to the `git-committer` subagent via Codex subagents with ``git-committer` agent prompt` if the change set is large or spans multiple areas. The git-committer will review diffs, group changes, and create commits with conventional commit messages.
|
|
54
|
+
|
|
55
|
+
For each group of changes you identify:
|
|
56
|
+
- List the specific files that belong together
|
|
57
|
+
- Generate a clear, descriptive commit message following conventional commits format
|
|
58
|
+
- Explain WHY these changes belong in one commit
|
|
59
|
+
|
|
60
|
+
Then execute the `git add <specific-files>` and `git commit` commands for each atomic commit in the order they should be applied.
|
|
61
|
+
|
|
62
|
+
Format each commit message as:
|
|
63
|
+
```
|
|
64
|
+
type(scope): brief description
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Common types: feat, fix, refactor, docs, test, chore, style, perf. For strict TDD cycles, also use `red:`, `green:`, `refactor:`.
|
|
68
|
+
|
|
69
|
+
## Rules
|
|
70
|
+
- NEVER use `git add -A` or `git add .` — always stage specific files
|
|
71
|
+
- NEVER use `git commit --no-verify`
|
|
72
|
+
- NEVER force push
|
|
73
|
+
- Review diffs before committing to ensure nothing unexpected is staged
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Capture implementation decisions before planning a phase
|
|
3
|
+
argument-hint: "<phase-number>"
|
|
4
|
+
allowed-tools: Bash, Read, Write, Edit
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# /discuss-phase
|
|
8
|
+
|
|
9
|
+
Capture implementation decisions before planning a phase.
|
|
10
|
+
|
|
11
|
+
Phase: $1
|
|
12
|
+
|
|
13
|
+
> **Tool note**: Invoke `draht-tools <subcommand>` as `node "${PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT:-$HOME/.draht/codex-marketplace/plugins/draht}}/bin/draht-tools.cjs" <subcommand>` via the Bash tool.
|
|
14
|
+
|
|
15
|
+
## Atomic Reasoning
|
|
16
|
+
|
|
17
|
+
Before questioning, decompose this phase scope into atomic reasoning units:
|
|
18
|
+
|
|
19
|
+
**For each implementation decision:**
|
|
20
|
+
1. **State the logical component** — What gray area exists? What choice needs to be made? Why does this matter?
|
|
21
|
+
2. **Validate independence** — Can this decision be made independently, or does it depend on other choices? What downstream impacts does it have?
|
|
22
|
+
3. **Verify correctness** — What criteria determine the right answer? What trade-offs exist? What domain terms need clarification?
|
|
23
|
+
|
|
24
|
+
**Synthesize discussion strategy:**
|
|
25
|
+
- Identify critical decisions that block planning
|
|
26
|
+
- Group related decisions (e.g., all API decisions together)
|
|
27
|
+
- Sequence questions from foundational to detailed
|
|
28
|
+
- Ensure domain language is established first
|
|
29
|
+
|
|
30
|
+
## Steps
|
|
31
|
+
1. Run `draht-tools phase-info $1` to load phase context
|
|
32
|
+
2. Ground the discussion in current structure: run `draht-tools graph-context <area>` and `draht-tools graph-clusters` on the area being discussed, and cross-check discovered domain terms with `draht-tools graph-query <term>`.
|
|
33
|
+
3. Identify gray areas based on what's being built
|
|
34
|
+
4. Present 1-2 questions at a time about preferences
|
|
35
|
+
5. If `.planning/DOMAIN.md` exists, load it and validate discovered terms against the glossary. Add any new domain terms found during discussion.
|
|
36
|
+
6. Record decisions with `draht-tools save-context $1`
|
|
37
|
+
7. Commit: `draht-tools commit-docs "capture phase $1 context"`
|
|
38
|
+
|
|
39
|
+
## Workflow
|
|
40
|
+
This is one step in the per-phase cycle. Use fresh sessions (`/clear`) between steps:
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
/discuss-phase N → /plan-phase N → /execute-phase N → /verify-work N → /discuss-phase N+1 → ...
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
After completing this command, tell the user to start a fresh session and run `/plan-phase $1`. Do NOT suggest `/next-milestone` — that is only after ALL phases in the milestone are verified.
|
|
47
|
+
|
|
48
|
+
## Gray Area Categories
|
|
49
|
+
- **Visual features** → Layout, density, interactions, empty states
|
|
50
|
+
- **APIs/CLIs** → Response format, error handling, auth
|
|
51
|
+
- **Data models** → Schema, relationships, validation
|
|
52
|
+
- **Content** → Structure, tone, depth, flow
|
|
53
|
+
- **Refactoring** → Grouping, naming, migration strategy
|
|
54
|
+
- **Testability** → What needs testing, test framework preference, coverage goals, integration vs unit boundaries
|
|
55
|
+
- **Domain boundaries** → What are the bounded contexts in play? Are there existing domain terms to respect? What aggregates/entities are involved?
|