@workit-dev/codex 2.16.2 → 2.17.0
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 +1 -1
- package/agents/workit-implementer.toml +10 -1
- package/dist/{workit-hook-4vkgc2zt.js → workit-hook-0paqaefq.js} +48 -27
- package/dist/workit-hook.js +1 -1
- package/package.json +3 -3
- package/skills/workit-fanout/SKILL.md +8 -9
- package/skills/workit-fanout/references/brief.md +21 -0
|
@@ -6,16 +6,25 @@ names (its WORKTREE line), which the lead made with
|
|
|
6
6
|
`workit fanout worktree create <slice>` before spawning you; never in the
|
|
7
7
|
lead's checkout.
|
|
8
8
|
|
|
9
|
+
Your first step: a prompt that points at the brief (its WORKTREE, WORKER, TIER
|
|
10
|
+
and TIMEBOX lines and `workit fanout brief <slice> --name <plan>`) means run
|
|
11
|
+
that command and follow its text; a prompt that names a brief file means read
|
|
12
|
+
that file.
|
|
13
|
+
|
|
9
14
|
Refuse to start without a complete brief. It must state: goal, scope (files
|
|
10
15
|
or areas you may touch), acceptance (observable outcomes), verify (exact
|
|
11
16
|
commands), timebox, forbidden (what you must not touch or do), report (what to
|
|
12
17
|
hand back), standing orders, mode (`new` or `resume`) and the worktree path.
|
|
13
|
-
If a field is missing, report which and stop.
|
|
18
|
+
If a field is missing, report which and stop. An unplanned slice
|
|
19
|
+
(`fanout worktree create <slice>` with no plan) has a short brief: the lead's
|
|
20
|
+
prompt states the task, and its acceptance and verify count as the brief's.
|
|
14
21
|
|
|
15
22
|
1. In a Workit worktree (the default), run each git and check command against
|
|
16
23
|
it, one verb per call:
|
|
17
24
|
`workit git --cwd <worktree> commit …`, `workit check --cwd <worktree> <name>`
|
|
18
25
|
(verb first, so the host's allow rules match).
|
|
26
|
+
Read-only git (`status`, `log`, `diff`, `show`) is plain
|
|
27
|
+
`git -C <worktree> …`; `workit git` takes branch, commit, stage and push.
|
|
19
28
|
Never `cd <worktree> && …` chains, `$VAR` paths or compound commands. Edit
|
|
20
29
|
files by their path under the worktree. Workit's hooks deny an edit or a
|
|
21
30
|
mutating git command outside it.
|
|
@@ -23676,6 +23676,10 @@ var cdWorkitSplit = (command) => {
|
|
|
23676
23676
|
return null;
|
|
23677
23677
|
};
|
|
23678
23678
|
|
|
23679
|
+
// packages/workit-core/src/hooks/spawn-gate.ts
|
|
23680
|
+
import fs23 from "node:fs";
|
|
23681
|
+
import path35 from "node:path";
|
|
23682
|
+
|
|
23679
23683
|
// packages/workit-core/src/hooks/model-limit.ts
|
|
23680
23684
|
import { closeSync as closeSync3, openSync as openSync3, readdirSync as readdirSync4, readSync, statSync as statSync5 } from "node:fs";
|
|
23681
23685
|
import os10 from "node:os";
|
|
@@ -23999,20 +24003,37 @@ var agentModelDecision = (cwd, tool, options = {}) => {
|
|
|
23999
24003
|
|
|
24000
24004
|
// packages/workit-core/src/hooks/spawn-gate.ts
|
|
24001
24005
|
var MADE_WORKTREE = /^WORKTREE:[ \t]*(?!not made yet)\S(?![^\n]*not made yet)/mu;
|
|
24002
|
-
var
|
|
24003
|
-
|
|
24006
|
+
var namesMade = (word) => {
|
|
24007
|
+
try {
|
|
24008
|
+
const stat = fs23.statSync(word);
|
|
24009
|
+
if (stat.isFile())
|
|
24010
|
+
return stat.size < 1e6 && MADE_WORKTREE.test(fs23.readFileSync(word, "utf8"));
|
|
24011
|
+
const dotGit = path35.join(word, ".git");
|
|
24012
|
+
const link = fs23.statSync(dotGit);
|
|
24013
|
+
const admin = link.isFile() && link.size <= 4096 && /^gitdir: *(.+)/u.exec(fs23.readFileSync(dotGit, "utf8"));
|
|
24014
|
+
return !!admin && fs23.existsSync(path35.resolve(word, admin[1].trim(), FANOUT_TOKEN_FILE));
|
|
24015
|
+
} catch {
|
|
24016
|
+
return false;
|
|
24017
|
+
}
|
|
24018
|
+
};
|
|
24019
|
+
var namesWorktree = (prompt) => MADE_WORKTREE.test(prompt) || (prompt.match(/(?<![\w.~])(?:[a-z]:[\\/]|\/)[^\s'"`<>|;,()]+/giu) ?? []).some((word) => namesMade(word.replace(/[.:]+$/u, "")));
|
|
24020
|
+
var sliceWord = (tool) => (/(?:\bfanout brief|\bworktree create|\bWORKER:) +([a-z0-9][\w.-]*)/iu.exec(String(tool.prompt))?.[1] ?? String(tool.description ?? "")).toLowerCase().replace(/[^a-z0-9._-]+/gu, "-").replace(/^[-._]+|-+$/gu, "").slice(0, 40) || "slice";
|
|
24004
24021
|
var gate = (descriptor, tool) => {
|
|
24005
24022
|
const type = typeof tool.subagent_type === "string" ? tool.subagent_type : "";
|
|
24006
24023
|
const implementer = workitRole(descriptor, type) === "implementer";
|
|
24007
|
-
if (implementer && (typeof tool.prompt !== "string" || !
|
|
24024
|
+
if (implementer && (typeof tool.prompt !== "string" || !namesWorktree(tool.prompt))) {
|
|
24025
|
+
const slice = sliceWord(tool);
|
|
24026
|
+
const unblock = `workit fanout worktree create ${slice}`;
|
|
24008
24027
|
return {
|
|
24009
24028
|
kind: "deny",
|
|
24010
24029
|
decision: {
|
|
24011
24030
|
kind: "deny",
|
|
24012
|
-
reason: `workit spawn gate:
|
|
24013
|
-
|
|
24031
|
+
reason: `workit spawn gate: this ${type} prompt names no worktree Workit made.
|
|
24032
|
+
Retry as: ${unblock} (or --name <plan> for a planned slice), then spawn again with the WORKTREE line it prints as the prompt's first line.`,
|
|
24033
|
+
unblock
|
|
24014
24034
|
}
|
|
24015
24035
|
};
|
|
24036
|
+
}
|
|
24016
24037
|
if (tool.isolation === undefined)
|
|
24017
24038
|
return { kind: "run", input: tool, change: { dropped: [], reasons: [], notes: [] } };
|
|
24018
24039
|
const { isolation: _dropped, ...input } = tool;
|
|
@@ -24036,8 +24057,8 @@ var spawnDecision = (descriptor, cwd, tool, permissionMode = null) => {
|
|
|
24036
24057
|
|
|
24037
24058
|
// packages/workit-core/src/hooks/teardown.ts
|
|
24038
24059
|
import { spawn } from "node:child_process";
|
|
24039
|
-
import
|
|
24040
|
-
import
|
|
24060
|
+
import fs24 from "node:fs";
|
|
24061
|
+
import path36 from "node:path";
|
|
24041
24062
|
var REAP_INTERVAL_MS = 10 * 60000;
|
|
24042
24063
|
var LOG_MAX_BYTES = 1 << 20;
|
|
24043
24064
|
var ENDS = {
|
|
@@ -24048,9 +24069,9 @@ var ENDS = {
|
|
|
24048
24069
|
};
|
|
24049
24070
|
var SAFE_SESSION = /^[\w.@+][\w.:@/+-]{0,127}$/u;
|
|
24050
24071
|
var HOST_SESSION_VARS = ["OPENCODE_SESSION_ID", "PI_SESSION_ID", "CODEX_THREAD_ID"];
|
|
24051
|
-
var teardownDir = (env) =>
|
|
24052
|
-
var teardownLog = (env) =>
|
|
24053
|
-
var reapStamp = (env) =>
|
|
24072
|
+
var teardownDir = (env) => path36.join(stateDir3(env), "procs");
|
|
24073
|
+
var teardownLog = (env) => path36.join(teardownDir(env), "teardown.log");
|
|
24074
|
+
var reapStamp = (env) => path36.join(teardownDir(env), "reap-at-start.stamp");
|
|
24054
24075
|
function spawnDetached(request) {
|
|
24055
24076
|
try {
|
|
24056
24077
|
const shell = process.platform === "win32" && !/\.exe$/iu.test(request.command);
|
|
@@ -24077,13 +24098,13 @@ var teardownDeps = {
|
|
|
24077
24098
|
var openLog = (env, args) => {
|
|
24078
24099
|
try {
|
|
24079
24100
|
const file = teardownLog(env);
|
|
24080
|
-
|
|
24101
|
+
fs24.mkdirSync(path36.dirname(file), { recursive: true });
|
|
24081
24102
|
let size = 0;
|
|
24082
24103
|
try {
|
|
24083
|
-
size =
|
|
24104
|
+
size = fs24.statSync(file).size;
|
|
24084
24105
|
} catch {}
|
|
24085
|
-
const fd =
|
|
24086
|
-
|
|
24106
|
+
const fd = fs24.openSync(file, size > LOG_MAX_BYTES ? "w" : "a", 384);
|
|
24107
|
+
fs24.writeSync(fd, `${new Date(teardownDeps.now()).toISOString()} workit ${args.join(" ")}
|
|
24087
24108
|
`);
|
|
24088
24109
|
return fd;
|
|
24089
24110
|
} catch {
|
|
@@ -24095,7 +24116,7 @@ function runCli(args, env) {
|
|
|
24095
24116
|
try {
|
|
24096
24117
|
const cli = locateWorkitCli2({ env });
|
|
24097
24118
|
const cwd = teardownDir(env);
|
|
24098
|
-
|
|
24119
|
+
fs24.mkdirSync(cwd, { recursive: true });
|
|
24099
24120
|
log = openLog(env, args);
|
|
24100
24121
|
const started = teardownDeps.spawn({
|
|
24101
24122
|
command: cli.command,
|
|
@@ -24105,7 +24126,7 @@ function runCli(args, env) {
|
|
|
24105
24126
|
log
|
|
24106
24127
|
});
|
|
24107
24128
|
if (!started && log !== null)
|
|
24108
|
-
|
|
24129
|
+
fs24.writeSync(log, ` not started
|
|
24109
24130
|
`);
|
|
24110
24131
|
return started;
|
|
24111
24132
|
} catch {
|
|
@@ -24113,7 +24134,7 @@ function runCli(args, env) {
|
|
|
24113
24134
|
} finally {
|
|
24114
24135
|
if (log !== null)
|
|
24115
24136
|
try {
|
|
24116
|
-
|
|
24137
|
+
fs24.closeSync(log);
|
|
24117
24138
|
} catch {}
|
|
24118
24139
|
}
|
|
24119
24140
|
}
|
|
@@ -24132,24 +24153,24 @@ function endSession(end, env = process.env) {
|
|
|
24132
24153
|
var claim2 = (file, now) => {
|
|
24133
24154
|
for (let attempt = 0;attempt < 2; attempt += 1)
|
|
24134
24155
|
try {
|
|
24135
|
-
|
|
24156
|
+
fs24.writeFileSync(file, String(now), { flag: "wx", mode: 384 });
|
|
24136
24157
|
return true;
|
|
24137
24158
|
} catch (error) {
|
|
24138
24159
|
if (error.code !== "EEXIST")
|
|
24139
24160
|
return false;
|
|
24140
24161
|
let held = Number.NaN;
|
|
24141
24162
|
try {
|
|
24142
|
-
held = Number(
|
|
24163
|
+
held = Number(fs24.readFileSync(file, "utf8"));
|
|
24143
24164
|
} catch {}
|
|
24144
24165
|
if (now - held < REAP_INTERVAL_MS)
|
|
24145
24166
|
return false;
|
|
24146
|
-
|
|
24167
|
+
fs24.rmSync(file, { force: true });
|
|
24147
24168
|
}
|
|
24148
24169
|
return false;
|
|
24149
24170
|
};
|
|
24150
24171
|
var fresh = (stamp, now) => {
|
|
24151
24172
|
try {
|
|
24152
|
-
const last = Number(
|
|
24173
|
+
const last = Number(fs24.readFileSync(stamp, "utf8"));
|
|
24153
24174
|
return now - last < REAP_INTERVAL_MS && last <= now;
|
|
24154
24175
|
} catch {
|
|
24155
24176
|
return false;
|
|
@@ -24162,7 +24183,7 @@ function reapAtStart(_cwd, env = process.env) {
|
|
|
24162
24183
|
try {
|
|
24163
24184
|
if (fresh(stamp, now))
|
|
24164
24185
|
return false;
|
|
24165
|
-
|
|
24186
|
+
fs24.mkdirSync(path36.dirname(stamp), { recursive: true });
|
|
24166
24187
|
if (!claim2(lock, now))
|
|
24167
24188
|
return false;
|
|
24168
24189
|
} catch {
|
|
@@ -24175,12 +24196,12 @@ function reapAtStart(_cwd, env = process.env) {
|
|
|
24175
24196
|
started = runCli(["stop", "--orphans", "--reason", "session-start"], env);
|
|
24176
24197
|
if (started) {
|
|
24177
24198
|
const temp = `${stamp}.${process.pid}`;
|
|
24178
|
-
|
|
24179
|
-
|
|
24199
|
+
fs24.writeFileSync(temp, String(now), { mode: 384 });
|
|
24200
|
+
fs24.renameSync(temp, stamp);
|
|
24180
24201
|
}
|
|
24181
24202
|
} catch {} finally {
|
|
24182
24203
|
try {
|
|
24183
|
-
|
|
24204
|
+
fs24.rmSync(lock, { force: true });
|
|
24184
24205
|
} catch {}
|
|
24185
24206
|
}
|
|
24186
24207
|
return started;
|
|
@@ -24983,7 +25004,7 @@ var dispatchHook = (adapter, raw, env = process.env) => {
|
|
|
24983
25004
|
};
|
|
24984
25005
|
// packages/workit-core/src/hooks/deadline.ts
|
|
24985
25006
|
import { appendFileSync, mkdirSync as mkdirSync4 } from "node:fs";
|
|
24986
|
-
import
|
|
25007
|
+
import path37 from "node:path";
|
|
24987
25008
|
var HOOK_SKIP_TEXT = "workit context skipped: host under load";
|
|
24988
25009
|
var HOOK_DEADLINE_MS = 8000;
|
|
24989
25010
|
var HOST_DEADLINES = {
|
|
@@ -25001,7 +25022,7 @@ var hookDeadlineMs = (env, host = "", native) => {
|
|
|
25001
25022
|
const row = HOST_DEADLINES[host];
|
|
25002
25023
|
return override(env) ?? (row ? native === undefined ? Math.min(...Object.values(row)) : row[native] ?? row[""] : HOOK_DEADLINE_MS);
|
|
25003
25024
|
};
|
|
25004
|
-
var skipsFile = (stateDir) =>
|
|
25025
|
+
var skipsFile = (stateDir) => path37.join(stateDir, HOOK_SKIPS_FILE);
|
|
25005
25026
|
var recordHookSkip = (skip, stateDir = resolveStateDir()) => {
|
|
25006
25027
|
try {
|
|
25007
25028
|
mkdirSync4(stateDir, { recursive: true });
|
package/dist/workit-hook.js
CHANGED
|
@@ -101,7 +101,7 @@ if (quiet) {
|
|
|
101
101
|
`);
|
|
102
102
|
} else {
|
|
103
103
|
try {
|
|
104
|
-
const { runCodexHook } = await import("./workit-hook-
|
|
104
|
+
const { runCodexHook } = await import("./workit-hook-0paqaefq.js");
|
|
105
105
|
await runCodexHook([payload]);
|
|
106
106
|
} catch (error) {
|
|
107
107
|
const { answerRuntimeFailure } = await import("./workit-hook-9k8dtngs.js");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workit-dev/codex",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.17.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Workit Codex CLI/desktop plugin — shared MCP transport, hooks, method skills, and verifier/reviewer/implementer agents",
|
|
6
6
|
"keywords": [
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"build": "bun scripts/build.ts"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@workit-dev/core": "^2.
|
|
45
|
-
"@workit-dev/mcp": "^2.
|
|
44
|
+
"@workit-dev/core": "^2.17.0",
|
|
45
|
+
"@workit-dev/mcp": "^2.17.0"
|
|
46
46
|
},
|
|
47
47
|
"engines": {
|
|
48
48
|
"node": ">=24"
|
|
@@ -20,16 +20,15 @@ units of ~100+ lines each. Coupled work stays with one owner. Workit never spawn
|
|
|
20
20
|
PR (`references/orchestration.md`).
|
|
21
21
|
2. **Record standing orders** (`workit ledger standing add "<order>"`): every
|
|
22
22
|
user directive all workers share. Directives decay across resumes.
|
|
23
|
-
3. **
|
|
24
|
-
|
|
25
|
-
Never hand-edit it; change the plan or
|
|
23
|
+
3. **Make the worktrees**: `workit fanout worktree create <slice>…` (every host; `--name <plan.json>`
|
|
24
|
+
registers the file) prints per slice its `WORKTREE:` line and the exact spawn, whose prompt points
|
|
25
|
+
the worker at `workit fanout brief <slice> --name <plan>`. Never hand-edit it; change the plan or
|
|
26
|
+
the standing orders. One unplanned slice needs no plan (`--branch <b>` optional).
|
|
26
27
|
4. **Spawn in a rolling window**, in the background, each in its own worktree:
|
|
27
|
-
keep 4-6 in flight and refill from `spawnable` in `workit fanout status
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
(
|
|
31
|
-
Model: the brief's `model:` and `effort:` lines (`workit models show`), else TIER (`references/orchestration.md`).
|
|
32
|
-
Claude Code: the `implementer` agent; its spawn hook drops `isolation` and refuses a prompt without a WORKTREE line.
|
|
28
|
+
keep 4-6 in flight and refill from `spawnable` in `workit fanout status`.
|
|
29
|
+
Assign before spawn (OpenCode: `workit worker assign`); each prompt is the printed one
|
|
30
|
+
(budget and model hooks read its WORKTREE, WORKER, TIER and TIMEBOX lines), so batched OpenCode launches each bind their worker.
|
|
31
|
+
Claude Code: copy the printed `SPAWN:` args (a model only when the TIER differs from the agent file); the hook drops `isolation` and refuses a prompt naming no Workit worktree with a `Retry as:`.
|
|
33
32
|
5. **Judge liveness by side effects only:** `workit fanout status` (head age,
|
|
34
33
|
PR, CI, verdict, landed; STUCK past the TIMEBOX). Stop a stuck worker and
|
|
35
34
|
observe that it exited (a timeout is not proof); stop a finished one when its
|
|
@@ -103,6 +103,27 @@ is the slice's STUCK threshold in `workit fanout status`. `"fanIn":
|
|
|
103
103
|
}
|
|
104
104
|
```
|
|
105
105
|
|
|
106
|
+
## Worktrees and the spawn they print
|
|
107
|
+
|
|
108
|
+
`workit fanout worktree create a b c` makes each slice's worktree and prints,
|
|
109
|
+
per slice, `WORKTREE: <path>` and the spawn that carries it. Its prompt starts
|
|
110
|
+
with that WORKTREE line, then `WORKER`, `TIER`, `TIMEBOX` and
|
|
111
|
+
"Run `workit fanout brief <slice> --name <plan>` and follow it exactly.";
|
|
112
|
+
Claude Code's `SPAWN:` line names `model` only when the TIER differs from the
|
|
113
|
+
`implementer` agent file. `--name` takes the plan's name or its file (`--plan`
|
|
114
|
+
is the same flag): a file is registered in that call, and a name no plan has
|
|
115
|
+
registers the one file in `workit dir plans` that starts with it. The plan
|
|
116
|
+
check refuses a slice branch the workspace branch policy refuses and names the
|
|
117
|
+
allowed one.
|
|
118
|
+
|
|
119
|
+
One unplanned slice: `workit fanout worktree create fix-login [--branch
|
|
120
|
+
fix/login] [--base <b>] [--tier <t>]` (no plan holds it) records a one-slice plan named after it
|
|
121
|
+
(the lead's prompt states the task) and prints the same lines; two or more
|
|
122
|
+
slices need a plan file. Claude Code's spawn gate passes a
|
|
123
|
+
`workit:implementer` prompt that names a Workit-made worktree as a WORKTREE
|
|
124
|
+
line, as its path, or as a brief file holding a WORKTREE line; otherwise its
|
|
125
|
+
deny is two lines ending in that ad-hoc command as `Retry as:`.
|
|
126
|
+
|
|
106
127
|
## Identity and git rules per host
|
|
107
128
|
|
|
108
129
|
`workit fanout brief` renders the identity line, the model lines and RULES 1
|