draht-codex 2026.10.23 → 2026.10.31

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.
@@ -10,6 +10,7 @@
10
10
  * Explicit project checks cover every configured language and committed work.
11
11
  * Passing evidence is reused only while its input scope is unchanged. A failed
12
12
  * repeated Stop remains failed; the host retry flag cannot bypass verification.
13
+ * Token budgets are audited last, after checks that may rewrite files.
13
14
  */
14
15
 
15
16
  const { execFileSync, spawnSync } = require("node:child_process");
@@ -52,6 +53,17 @@ try {
52
53
  const payload = JSON.parse(readStdin() || "{}");
53
54
 
54
55
  const cwd = payload?.cwd || process.cwd();
56
+ const budgets = require("./budgets-runtime.cjs");
57
+ budgets.beginTask({ cwd });
58
+ const finish = () => {
59
+ const { exitCode, message } = budgets.stopBudget({
60
+ cwd,
61
+ retry: payload?.stop_hook_active === true,
62
+ session: typeof payload?.session_id === "string" ? payload.session_id : "",
63
+ });
64
+ if (message) console.error(message);
65
+ process.exit(exitCode);
66
+ };
55
67
  const project = runChecks({ cwd });
56
68
  if (project.configured || project.status === "failed") {
57
69
  if (project.status === "failed") {
@@ -59,14 +71,14 @@ try {
59
71
  for (const check of project.checks) if (check.output) console.error(check.output.slice(0, 1500));
60
72
  process.exit(2);
61
73
  }
62
- process.exit(0);
74
+ finish();
63
75
  }
64
76
  const planning = path.join(cwd, ".planning");
65
77
 
66
78
  // Planning metadata is optional; retain existing projects' explicit opt-out.
67
79
  try {
68
80
  const config = JSON.parse(fs.readFileSync(path.join(planning, "config.json"), "utf-8"));
69
- if (config?.hooks?.stopGate === false) process.exit(0);
81
+ if (config?.hooks?.stopGate === false) finish();
70
82
  } catch { /* no config — gate stays on */ }
71
83
 
72
84
  // Only gate when uncommitted source changes exist — a conversational turn
@@ -77,9 +89,9 @@ try {
77
89
  encoding: "utf-8", cwd, timeout: 10000, stdio: ["ignore", "pipe", "pipe"],
78
90
  });
79
91
  } catch {
80
- process.exit(0); // not a git repo
92
+ finish(); // not a git repo
81
93
  }
82
- if (!hasSourceChanges(dirty)) process.exit(0);
94
+ if (!hasSourceChanges(dirty)) finish();
83
95
 
84
96
  // Run configured types/lint checks, without GSD heuristics or a full test
85
97
  // suite on every turn-end. The gate retains its project strictness policy.
@@ -91,7 +103,7 @@ try {
91
103
  failGate({ error });
92
104
  }
93
105
  if (result.error || result.signal || result.status !== 0) failGate(result);
94
- process.exit(0);
106
+ finish();
95
107
  } catch (error) {
96
108
  console.error(`Quality gate could not run: ${error.message}`);
97
109
  process.exit(2);
@@ -0,0 +1,10 @@
1
+ ---
2
+ name: budget
3
+ description: Configure repository code and documentation token limits, inspect active budget usage, or start a new shared budget task. Use for /budget or requests to change .draht/budgets.json.
4
+ ---
5
+
6
+ # Draht Command: budget
7
+
8
+ This skill exposes the Draht prompt command template to Codex's `$draht` and `/skills` surfaces.
9
+
10
+ Read `./command.md` and follow it. Treat the user's text after the skill mention as `$ARGUMENTS`; preserve choices already stated in the conversation.
@@ -0,0 +1,22 @@
1
+ ---
2
+ description: Configure repository code and documentation budgets, inspect usage, or start a new task
3
+ argument-hint: "[configure|status|new]"
4
+ allowed-tools: Bash, Read, Write, Edit
5
+ ---
6
+
7
+ # /budget
8
+
9
+ Request: $ARGUMENTS
10
+
11
+ Budgets are opt-in: they apply only in repositories with `.draht/budgets.json`. Run `node "${PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT:-$HOME/.draht/codex-marketplace/plugins/draht}}/scripts/budgets-runtime.cjs" <action>` from the current session's project directory, not the plugin directory. Its actions are `config` and `status`.
12
+
13
+ - **status**: run `status`, report its result, and stop without editing configuration.
14
+ - **new**: only the user can start a new task, by submitting this command with `new` as the whole prompt; the budget hook then resets the task. If the context confirms "Budget task reset by the user's command", run `status` and report the new limits. Otherwise say that no reset happened.
15
+ - **No argument or configure**: guide the configuration workflow below. Treat additional settings in the request as choices already given.
16
+
17
+ 1. Run `config`. Its JSON contains `configPath`, `exists`, `enabled`, `limits`, and `exclude`, resolved from the current Git working tree; `exists: false` means budgets are off in this repository. Read the existing file when present. If validation fails, report the exact error and offer corrected JSON. Without a Git working tree, explain the requirement and stop; do not initialize one.
18
+ 2. Briefly show the current settings. Ask one compact question for choices still missing; honor existing settings and choices already supplied. Offer defaults of 5,000 tokens per code file and 1,500 per documentation file, 250 tokens of growth per task for files already over their limit, and both task totals disabled. Lockfiles, `CHANGELOG.md`, and files marked `linguist-generated` in `.gitattributes` are never measured; ask which other generated paths belong in `exclude`. Ask about task totals only if the user wants them. These are local content tokens, not model billing or chat limits.
19
+ 3. Once choices are clear, write only `configPath` with `enabled`, `maxFileTokens`, `maxDocFileTokens`, `maxCodeTokens`, `maxDocTokens`, `maxOversizedGrowthTokens`, and `exclude`. File limits are positive safe integers and the growth allowance is a non-negative one; task limits accept positive safe integers or `null` to disable. `exclude` holds glob patterns: one without `/` matches a name at any depth, one with `/` is relative to the repository root, and a trailing `/` matches everything below a directory. Create `.draht/` if needed.
20
+ 4. Run `config` again to validate the saved file. Report the path and selected settings. A repository without an active task starts one at the next prompt; an active task keeps its settings until the user starts a new one. Never reset the task automatically, and never edit or delete the budget files under `.git`.
21
+
22
+ This workflow edits only `.draht/budgets.json`: no source refactoring, other configuration, documentation, or commits.
@@ -14,14 +14,14 @@ This catalog routes to sibling skills; it does not activate them all.
14
14
  ## Two Kinds of Sibling Skills
15
15
 
16
16
  - **16 support skills** — load the relevant discipline or explicitly chosen workflow: `atomic-reasoning`, `blast-radius`, `brainstorming`, `ddd-workflow`, `debugging-workflow`, `epistemics`, `explainers`, `gsd-workflow`, `judge`, `loop-workflow`, `model-tiering`, `saga-spawner`, `tdd-workflow`, `typescript-discipline`, `unslop`, `verification-gate`.
17
- - **23 command skills** — explicit actions, including ad-hoc work and optional GSD lifecycle stages: `new-project`, `init-project`, `map-codebase`, `discuss-phase`, `plan-phase`, `execute-phase`, `verify-work`, `next-milestone`, `pause-work`, `resume-work`, `progress`, `quick`, `fix`, `review`, `atomic-commit`, `orchestrate`, `orchestrate-loop`, `resolve-conflicts`, `grill`, `why`, `create-verification-skill`, `triage`, `speak`.
17
+ - **24 command skills** — explicit actions, including ad-hoc work and optional GSD lifecycle stages: `new-project`, `init-project`, `map-codebase`, `discuss-phase`, `plan-phase`, `execute-phase`, `verify-work`, `next-milestone`, `pause-work`, `resume-work`, `progress`, `quick`, `fix`, `review`, `atomic-commit`, `orchestrate`, `orchestrate-loop`, `resolve-conflicts`, `grill`, `why`, `create-verification-skill`, `triage`, `speak`, `budget`.
18
18
 
19
19
  Every skill's frontmatter `name` matches its directory name, so `skills/<name>/` and the name you invoke are always the same string.
20
20
 
21
21
  ## Repository Layout
22
22
 
23
23
  - `skills/<name>/SKILL.md` — every skill has one; frontmatter (`name`, `description`) plus instructions.
24
- - `skills/<name>/command.md` — the 23 command skills only. This is the full prompt template; the command skill's `SKILL.md` is a thin wrapper that reads it.
24
+ - `skills/<name>/command.md` — the 24 command skills only. This is the full prompt template; the command skill's `SKILL.md` is a thin wrapper that reads it.
25
25
  - The 16 support skills have no `command.md` — their `SKILL.md` is self-contained.
26
26
  - This file, `skills/draht/SKILL.md`, is itself a plain skill (no `command.md`) — it is discovered and loaded the same way any discipline skill is.
27
27
 
@@ -53,6 +53,7 @@ An explicitly selected command may use supporting disciplines; ordinary requests
53
53
  | Pausing work and writing a handoff document | `pause-work` |
54
54
  | Resuming a paused project from its handoff document | `resume-work` |
55
55
  | Checking current position in the roadmap | `progress` |
56
+ | Guided setup of repository code and documentation budgets in `.draht/budgets.json` | `budget` |
56
57
  | Complete an ad-hoc task directly with relevant verification | `quick` |
57
58
  | Diagnosing and fixing one specific bug end to end | `fix` |
58
59
  | Code review and security audit of recent changes | `review` |
@@ -102,8 +103,8 @@ A few sibling pairs are easy to reach for incorrectly:
102
103
 
103
104
  | Host | How to invoke a draht skill |
104
105
  |---|---|
105
- | Claude Code | `/draht:<command>` slash commands for the 23 command skills (for example `/draht:plan-phase`); the 16 discipline skills load automatically by description match or on request |
106
- | Codex | `$draht:<command>` prompts, or `/skills` and pick the wrapper, for the 23 command skills; discipline skills load automatically or by name |
106
+ | Claude Code | `/draht:<command>` slash commands for the 24 command skills (for example `/draht:plan-phase`); the 16 discipline skills load automatically by description match or on request |
107
+ | Codex | `$draht:<command>` prompts, or `/skills` and pick the wrapper, for the 24 command skills; discipline skills load automatically or by name |
107
108
  | Any Agent-Skills-compatible host | invoke the sibling skill directly by name — every `SKILL.md` in this tree is self-contained and portable |
108
109
  | draht CLI (`@draht/coding-agent`) | work directly with the coding tools, or explicitly invoke a bundled command |
109
110