draht-codex 2026.10.23-1 → 2026.10.31-1

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "draht",
3
- "version": "2026.10.23-1",
3
+ "version": "2026.10.31-1",
4
4
  "description": "Draht GSD, multi-agent, TDD and DDD workflows as a Codex plugin.",
5
5
  "author": {
6
6
  "name": "Oskar Freye",
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [2026.10.31-1] - 2026-10-31
4
+
5
+ ### Added
6
+
7
+ - add opt-in per-file token budgets for draht and the Claude Code and Codex plugins
8
+
9
+ ### Fixed
10
+
11
+ - generate the budget runtime bundle identically under hoisted and isolated installs
12
+ - pair moved files by shared content and leave deletions of ignored files uncharged
13
+ - keep allowances for files Git ignores temporarily and pair moves by content first
14
+ - harden checks for new worktrees, missing Git, named pipes, stale locks, moves, and ignored files
15
+ - run checks in the compiled binary without Node and preflight Codex apply_patch edits
16
+
3
17
  ## [2026.10.23-1] - 2026-10-23
4
18
 
5
19
  ### Added
package/README.md CHANGED
@@ -40,6 +40,7 @@ Session continuity:
40
40
 
41
41
  Ad-hoc:
42
42
 
43
+ - `commands/budget.md` - guided configuration of this repository's token budgets
43
44
  - `commands/quick.md`
44
45
  - `commands/fix.md`
45
46
  - `commands/review.md`
@@ -93,8 +94,9 @@ Codex treats agent `model:` as reference metadata — `configure --list` shows i
93
94
 
94
95
  ### Command prompt wrappers
95
96
 
96
- The plugin ships 17 command prompt wrappers, one per `commands/*.md` template:
97
+ The plugin ships a command prompt wrapper for each `commands/*.md` template:
97
98
 
99
+ - `budget`
98
100
  - `new-project`
99
101
  - `init-project`
100
102
  - `map-codebase`
@@ -121,7 +123,7 @@ The plugin ships 17 command prompt wrappers, one per `commands/*.md` template:
121
123
 
122
124
  ### Support skills
123
125
 
124
- The GSD workflow templates live in `commands/`. Alongside the 23 command wrappers above, the plugin ships 16 support skills (39 skill directories in total), loaded by description match or by name.
126
+ The GSD workflow templates live in `commands/`. Alongside the command wrappers above, support skills load by description match or by name.
125
127
 
126
128
  Router:
127
129
 
@@ -177,6 +179,12 @@ The plugin includes `hooks/hooks.json` plus these scripts:
177
179
 
178
180
  Codex loads plugin-bundled hooks only after the user reviews and trusts them.
179
181
 
182
+ ### Token budgets
183
+
184
+ Opt-in per-file token limits encourage readable, cohesive code and concise documentation. `$draht:budget`, or `budget` in `/skills`, guides you through writing the repository's `.draht/budgets.json`; repositories without that file are not measured. The defaults are 5,000 tokens per code file and 1,500 per documentation file. Lockfiles, changelogs, and generated files are skipped, and task totals are optional. Trusted plugin hooks enforce the same offline accounting as native draht, shared by subagents and linked worktrees. Chat responses have no budget.
185
+
186
+ Add `status` to inspect limits and usage. Only the user starts a new task, by submitting `$draht:budget new` as the whole prompt. See the [budget guide](https://github.com/draht-dev/draht/blob/main/packages/coding-agent/docs/budgets.md).
187
+
180
188
  ## Installation
181
189
 
182
190
  ```bash
@@ -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.
package/hooks/hooks.json CHANGED
@@ -1,6 +1,16 @@
1
1
  {
2
2
  "hooks": {
3
3
  "SessionStart": [
4
+ {
5
+ "matcher": "",
6
+ "hooks": [
7
+ {
8
+ "type": "command",
9
+ "command": "node \"${PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT}}/scripts/budgets-hook.cjs\" SessionStart",
10
+ "timeout": 60
11
+ }
12
+ ]
13
+ },
4
14
  {
5
15
  "matcher": "",
6
16
  "hooks": [
@@ -12,6 +22,16 @@
12
22
  }
13
23
  ],
14
24
  "UserPromptSubmit": [
25
+ {
26
+ "matcher": "",
27
+ "hooks": [
28
+ {
29
+ "type": "command",
30
+ "command": "node \"${PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT}}/scripts/budgets-hook.cjs\" UserPromptSubmit",
31
+ "timeout": 60
32
+ }
33
+ ]
34
+ },
15
35
  {
16
36
  "matcher": "",
17
37
  "hooks": [
@@ -28,6 +48,16 @@
28
48
  }
29
49
  ],
30
50
  "PostToolUse": [
51
+ {
52
+ "matcher": "",
53
+ "hooks": [
54
+ {
55
+ "type": "command",
56
+ "command": "node \"${PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT}}/scripts/budgets-hook.cjs\" PostToolUse",
57
+ "timeout": 60
58
+ }
59
+ ]
60
+ },
31
61
  {
32
62
  "matcher": "Edit|Write|MultiEdit",
33
63
  "hooks": [
@@ -45,6 +75,16 @@
45
75
  }
46
76
  ],
47
77
  "PreToolUse": [
78
+ {
79
+ "matcher": "",
80
+ "hooks": [
81
+ {
82
+ "type": "command",
83
+ "command": "node \"${PLUGIN_ROOT:-${CLAUDE_PLUGIN_ROOT}}/scripts/budgets-hook.cjs\" PreToolUse",
84
+ "timeout": 60
85
+ }
86
+ ]
87
+ },
48
88
  {
49
89
  "matcher": "Bash|bash|exec_command|shell_command",
50
90
  "hooks": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "draht-codex",
3
- "version": "2026.10.23-1",
3
+ "version": "2026.10.31-1",
4
4
  "description": "Draht GSD, multi-agent, TDD and DDD workflows as a Codex plugin. Install with `npx draht-codex install`.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -27,7 +27,7 @@
27
27
  "prepublishOnly": "node ../../scripts/sync-draht-tools.mjs && node ../../scripts/generate-skills-artifacts.mjs --check && node ../../scripts/sync-checks-runtime.mjs --check"
28
28
  },
29
29
  "dependencies": {
30
- "@draht/tools": "2026.10.23-1"
30
+ "@draht/tools": "2026.10.31-1"
31
31
  },
32
32
  "keywords": [
33
33
  "codex",
Binary file
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ const { readFileSync } = require("node:fs");
4
+ try {
5
+ const { runHook } = require("./budgets-runtime.cjs");
6
+ runHook(process.argv[2], readFileSync(0, "utf8"));
7
+ } catch (error) {
8
+ process.stderr.write(`Budget hook unavailable: ${error.message}\n`);
9
+ process.exitCode = 2;
10
+ }
@@ -0,0 +1,95 @@
1
+ gpt-tokenizer
2
+ MIT License
3
+
4
+ Copyright (c) 2023-2024 Bazyli Brzoska
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
23
+
24
+
25
+ diff
26
+ BSD 3-Clause License
27
+
28
+ Copyright (c) 2009-2015, Kevin Decker <kpdecker@gmail.com>
29
+ All rights reserved.
30
+
31
+ Redistribution and use in source and binary forms, with or without
32
+ modification, are permitted provided that the following conditions are met:
33
+
34
+ 1. Redistributions of source code must retain the above copyright notice, this
35
+ list of conditions and the following disclaimer.
36
+
37
+ 2. Redistributions in binary form must reproduce the above copyright notice,
38
+ this list of conditions and the following disclaimer in the documentation
39
+ and/or other materials provided with the distribution.
40
+
41
+ 3. Neither the name of the copyright holder nor the names of its
42
+ contributors may be used to endorse or promote products derived from
43
+ this software without specific prior written permission.
44
+
45
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
46
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
47
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
48
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
49
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
51
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
52
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
53
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
54
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
55
+
56
+
57
+ UNICODE LICENSE V3
58
+
59
+ COPYRIGHT AND PERMISSION NOTICE
60
+
61
+ Copyright © 1991-2026 Unicode, Inc.
62
+
63
+ NOTICE TO USER: Carefully read the following legal agreement. BY
64
+ DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING DATA FILES, AND/OR
65
+ SOFTWARE, YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE
66
+ TERMS AND CONDITIONS OF THIS AGREEMENT. IF YOU DO NOT AGREE, DO NOT
67
+ DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE THE DATA FILES OR SOFTWARE.
68
+
69
+ Permission is hereby granted, free of charge, to any person obtaining a
70
+ copy of data files and any associated documentation (the "Data Files") or
71
+ software and any associated documentation (the "Software") to deal in the
72
+ Data Files or Software without restriction, including without limitation
73
+ the rights to use, copy, modify, merge, publish, distribute, and/or sell
74
+ copies of the Data Files or Software, and to permit persons to whom the
75
+ Data Files or Software are furnished to do so, provided that either (a)
76
+ this copyright and permission notice appear with all copies of the Data
77
+ Files or Software, or (b) this copyright and permission notice appear in
78
+ associated Documentation.
79
+
80
+ THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
81
+ KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
82
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
83
+ THIRD PARTY RIGHTS.
84
+
85
+ IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE
86
+ BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES,
87
+ OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
88
+ WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
89
+ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA
90
+ FILES OR SOFTWARE.
91
+
92
+ Except as contained in this notice, the name of a copyright holder shall
93
+ not be used in advertising or otherwise to promote the sale, use or other
94
+ dealings in these Data Files or Software without prior written
95
+ authorization of the copyright holder.