@workit-dev/codex 2.13.0 → 2.15.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-babysitter.toml +26 -0
- package/agents/workit-decider.toml +27 -0
- package/dist/launch-mcp.js +48 -17
- package/dist/{workit-hook-ve6718aj.js → workit-hook-azjr1ew1.js} +5 -6
- package/dist/workit-hook-dzfxvq92.js +10 -0
- package/dist/{workit-hook-4wfr9txp.js → workit-hook-x0h085t0.js} +226 -46
- package/dist/workit-hook.js +2 -2
- package/package.json +3 -3
- package/skills/workit-fanout/SKILL.md +1 -1
- package/skills/workit-fanout/references/orchestration.md +33 -32
- package/skills/workit-review/SKILL.md +1 -1
- package/skills/workit-ship/SKILL.md +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Generated by Workit from packages/workit-claude-code/agents/babysitter.md; edits are overwritten on the next plugin start.
|
|
2
|
+
name = "workit-babysitter"
|
|
3
|
+
description = "Drives one pushed PR to its endpoint - polls its status, fixes red CI in the PR's own worktree, answers review threads - and reports when it is ready, merged or blocked. Use to babysit a PR in the background after it is opened."
|
|
4
|
+
developer_instructions = '''You are the workit babysitter for one PR. Follow the workit-ship skill
|
|
5
|
+
(`$workit-ship`): its babysit loop is your job.
|
|
6
|
+
|
|
7
|
+
1. Work only in the checkout or worktree your prompt names, on the PR's own
|
|
8
|
+
branch; never in another branch. Run Workit against it, one verb per call:
|
|
9
|
+
`workit pr status --cwd <worktree> --json`, `workit check --cwd <worktree> <name>`,
|
|
10
|
+
`workit git --cwd <worktree> commit …`.
|
|
11
|
+
2. Act on `babysit` in `workit pr status --json`: wait, fix a red check at its
|
|
12
|
+
root (reproduce it with `workit check` first), answer each unresolved thread,
|
|
13
|
+
or stop at the endpoint your prompt names (`ready` by default).
|
|
14
|
+
3. Merge only when your prompt or the grant says `merged`; never force-push,
|
|
15
|
+
rebase or retarget unless your prompt says so.
|
|
16
|
+
4. A fix you cannot make in one round, a product choice, or a check that stays
|
|
17
|
+
red after one fix: stop and report it.
|
|
18
|
+
|
|
19
|
+
Before your final report, wait for or stop every background command you started
|
|
20
|
+
(the host shows you running while one lives); never report with one still running.
|
|
21
|
+
|
|
22
|
+
Report: the PR, its head SHA and endpoint, each check and thread you acted on,
|
|
23
|
+
and anything left for the lead.
|
|
24
|
+
|
|
25
|
+
Codex does not isolate subagents: work only in the checkout or worktree your prompt names, never in another one.
|
|
26
|
+
'''
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Generated by Workit from packages/workit-claude-code/agents/decider.md; edits are overwritten on the next plugin start.
|
|
2
|
+
name = "workit-decider"
|
|
3
|
+
description = "Fresh read-only decider for a stuck call - a failed fix round and recheck, or a worker and a reviewer who disagree - that returns the options, a pick by reversibility and the exact change list. Use instead of a third review round; never for a product choice."
|
|
4
|
+
sandbox_mode = "read-only"
|
|
5
|
+
developer_instructions = '''You are the workit decider. You wrote none of the work and change none of it:
|
|
6
|
+
you read, decide and report. Follow the workit-fanout skill
|
|
7
|
+
(`$workit-fanout`, "Stuck calls: the decider").
|
|
8
|
+
|
|
9
|
+
1. Read the dispute itself: the brief or acceptance, the diff
|
|
10
|
+
(`git -C <worktree> diff <base>...HEAD`), the failed findings and the
|
|
11
|
+
author's answer, and `workit ledger list --type decision`.
|
|
12
|
+
2. List the real options (two or three), each with what it costs if wrong.
|
|
13
|
+
3. Pick one by reversibility: the option cheapest to undo wins a tie.
|
|
14
|
+
4. Give the exact change list for the pick: file, what changes, and the check
|
|
15
|
+
that proves it, so the fixer applies it once.
|
|
16
|
+
|
|
17
|
+
A product choice, or authority nobody here has, is not yours: say so and name
|
|
18
|
+
the question for the user. The lead records your pick with
|
|
19
|
+
`workit ledger decision`; you record nothing.
|
|
20
|
+
|
|
21
|
+
Before your final report, wait for or stop every background command you started
|
|
22
|
+
(the host shows you running while one lives); never report with one still running.
|
|
23
|
+
|
|
24
|
+
Never commit, push, merge or edit. Write only in your session's scratchpad.
|
|
25
|
+
|
|
26
|
+
Codex runs you in a read-only sandbox: read and run read-only commands only, and record nothing.
|
|
27
|
+
'''
|
package/dist/launch-mcp.js
CHANGED
|
@@ -15515,7 +15515,7 @@ var workspaceConfigSchema = object({
|
|
|
15515
15515
|
fanout: object({
|
|
15516
15516
|
tierModels: unknown().optional().describe("The model per slice TIER (mundane, standard, hard), as one name or per host.")
|
|
15517
15517
|
}).passthrough().optional().describe("Fanout settings."),
|
|
15518
|
-
models: object({ roles: modelRoles }).passthrough().optional().describe("Model and effort per role and host (roles), the lead's own advisory model (lead) and whether a model the lead names on a spawn wins (allowLeadOverride, default false); the same key at the top of workspaces.json is the global default."),
|
|
15518
|
+
models: object({ roles: modelRoles }).passthrough().optional().describe("Model and effort per role and host (roles), the lead's own advisory model (lead), how a role model applies (enforce: advise, the default, or strict) and, under strict, whether a model the lead names on a spawn wins (allowLeadOverride, default false); the same key at the top of workspaces.json is the global default."),
|
|
15519
15519
|
resources: unknown().optional().describe("Heavy-check limits on this machine: slots, scope, heavy, light, memoryMax, cpuQuota, wait."),
|
|
15520
15520
|
remotes: array(nonBlank.refine((pattern) => remotePattern(pattern) !== null, "is not a remote URL (https://host/owner/repo, git@host:owner/repo, a path, or owner/*)")).optional().describe("Remote URLs this entry owns: a checkout pushing to or opening PRs on one never exceeds this entry's grants, wherever the folder is (`owner/*` claims a whole owner). Only the user changes it, in their own terminal."),
|
|
15521
15521
|
autonomy: object(Object.fromEntries(["push", "pr", "merge", "release", "rerun"].map((kind) => [
|
|
@@ -15553,7 +15553,7 @@ var workspaceConfigSchema = object({
|
|
|
15553
15553
|
});
|
|
15554
15554
|
var workspacesFileSchema = object({
|
|
15555
15555
|
workspaces: array(workspaceConfigSchema).optional().describe("Workspace entries, each mapping a path glob to its forge, policies and grants."),
|
|
15556
|
-
models: object({ roles: modelRoles }).passthrough().optional().describe("The global default model and effort per role and host (roles), the lead's own advisory model (lead) and whether a model the lead names on a spawn wins (allowLeadOverride, default false).")
|
|
15556
|
+
models: object({ roles: modelRoles }).passthrough().optional().describe("The global default model and effort per role and host (roles), the lead's own advisory model (lead), how a role model applies (enforce: advise, the default, or strict) and, under strict, whether a model the lead names on a spawn wins (allowLeadOverride, default false).")
|
|
15557
15557
|
}).passthrough().superRefine((file, context) => {
|
|
15558
15558
|
const names = new Set;
|
|
15559
15559
|
for (const [index, workspace] of (file.workspaces ?? []).entries()) {
|
|
@@ -23668,16 +23668,19 @@ var HOST_KEYS = new Set([
|
|
|
23668
23668
|
"pi",
|
|
23669
23669
|
"default"
|
|
23670
23670
|
]);
|
|
23671
|
-
var
|
|
23671
|
+
var CLAUDE_AGENT_FILES = {
|
|
23672
23672
|
decider: { model: "fable", effort: "high" },
|
|
23673
|
-
|
|
23674
|
-
"implementer.standard": { model: "sonnet" },
|
|
23675
|
-
"implementer.mundane": { model: "haiku" },
|
|
23673
|
+
implementer: { model: "sonnet" },
|
|
23676
23674
|
verifier: { model: "sonnet" },
|
|
23677
23675
|
reviewer: { model: "opus" },
|
|
23678
|
-
explore: { model: "haiku" },
|
|
23679
23676
|
babysit: { model: "haiku" }
|
|
23680
23677
|
};
|
|
23678
|
+
var BUILT_IN_CLAUDE_CODE = {
|
|
23679
|
+
...CLAUDE_AGENT_FILES,
|
|
23680
|
+
"implementer.hard": { model: "opus" },
|
|
23681
|
+
"implementer.standard": { model: "sonnet" },
|
|
23682
|
+
"implementer.mundane": { model: "haiku" }
|
|
23683
|
+
};
|
|
23681
23684
|
var isObject6 = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
23682
23685
|
var name = (value) => typeof value === "string" && value.trim() ? value.trim() : null;
|
|
23683
23686
|
var leaf = (value) => {
|
|
@@ -23761,18 +23764,20 @@ var firstAvailable = (candidates, host, now = new Date) => {
|
|
|
23761
23764
|
}
|
|
23762
23765
|
return { ...primary, skipped, allExhausted: true };
|
|
23763
23766
|
};
|
|
23767
|
+
var FILE_ROLES = new Set(["decider", "verifier", "reviewer", "babysit"]);
|
|
23764
23768
|
var CLAUDE_ALIASES = new Set(["sonnet", "opus", "haiku", "fable"]);
|
|
23765
23769
|
var CLAUDE_EFFORTS = new Set(["low", "medium", "high", "xhigh", "max"]);
|
|
23766
23770
|
var CLAUDE_SPAWNS = [
|
|
23767
|
-
...
|
|
23768
|
-
label:
|
|
23771
|
+
...MODEL_TIERS.map((tier) => ({
|
|
23772
|
+
label: `workit:implementer ${tier}`,
|
|
23769
23773
|
selector: { role: "implementer", tier }
|
|
23770
23774
|
})),
|
|
23771
|
-
|
|
23772
|
-
|
|
23775
|
+
...["verifier", "reviewer", "decider"].map((role) => ({
|
|
23776
|
+
label: `workit:${role}`,
|
|
23777
|
+
selector: { role }
|
|
23778
|
+
})),
|
|
23779
|
+
{ label: "workit:babysitter", selector: { role: "babysit" } },
|
|
23773
23780
|
{ label: "Explore", selector: { role: "explore" } },
|
|
23774
|
-
{ label: "ROLE: decider", selector: { role: "decider" } },
|
|
23775
|
-
{ label: "ROLE: babysit", selector: { role: "babysit" } },
|
|
23776
23781
|
{ label: "general-purpose", selector: { role: "default" } }
|
|
23777
23782
|
];
|
|
23778
23783
|
var uniformImplementerModel = (cwd, host, dir) => {
|
|
@@ -30936,11 +30941,12 @@ var FLAGS = {
|
|
|
30936
30941
|
var CLAUDE_CODE_DESCRIPTOR = {
|
|
30937
30942
|
host: "claude_code",
|
|
30938
30943
|
label: "Claude Code",
|
|
30939
|
-
verifiedAgainst: "claude 2.1.288 (hook zod schemas in the binary)",
|
|
30944
|
+
verifiedAgainst: "claude 2.1.288 (hook zod schemas in the binary; SessionEnd: 2.1.327)",
|
|
30940
30945
|
docs: ["https://code.claude.com/docs/en/hooks"],
|
|
30941
30946
|
transport: "hook-process",
|
|
30942
30947
|
events: {
|
|
30943
30948
|
"session.start": { support: "native", native: "SessionStart" },
|
|
30949
|
+
"session.end": { support: "native", native: "SessionEnd" },
|
|
30944
30950
|
"context.turn": { support: "native", native: "UserPromptSubmit" },
|
|
30945
30951
|
"shell.pre": { support: "native", native: "PreToolUse" },
|
|
30946
30952
|
"tool.pre": { support: "native", native: "PreToolUse" },
|
|
@@ -31053,6 +31059,7 @@ var CODEX_DESCRIPTOR = {
|
|
|
31053
31059
|
transport: "hook-process",
|
|
31054
31060
|
events: {
|
|
31055
31061
|
"session.start": { support: "native", native: "SessionStart" },
|
|
31062
|
+
"session.end": { support: "none", native: null },
|
|
31056
31063
|
"context.turn": { support: "native", native: "UserPromptSubmit" },
|
|
31057
31064
|
"shell.pre": { support: "native", native: "PreToolUse" },
|
|
31058
31065
|
"tool.pre": { support: "native", native: "PreToolUse" },
|
|
@@ -31324,6 +31331,7 @@ var CURSOR_DESCRIPTOR = {
|
|
|
31324
31331
|
transport: "hook-process",
|
|
31325
31332
|
events: {
|
|
31326
31333
|
"session.start": { support: "native", native: "sessionStart" },
|
|
31334
|
+
"session.end": { support: "native", native: "sessionEnd" },
|
|
31327
31335
|
"context.turn": none,
|
|
31328
31336
|
"shell.pre": { support: "native", native: "beforeShellExecution" },
|
|
31329
31337
|
"tool.pre": { support: "native", native: "preToolUse" },
|
|
@@ -31430,6 +31438,7 @@ var OPENCODE_DESCRIPTOR = {
|
|
|
31430
31438
|
transport: "in-process-plugin",
|
|
31431
31439
|
events: {
|
|
31432
31440
|
"session.start": { support: "none", native: null },
|
|
31441
|
+
"session.end": { support: "partial", native: 'event("session.deleted")' },
|
|
31433
31442
|
"context.turn": { support: "native", native: 'session.hook("context")' },
|
|
31434
31443
|
"shell.pre": { support: "native", native: 'permission.hook("evaluate")' },
|
|
31435
31444
|
"tool.pre": { support: "native", native: 'tool.hook("execute.before")' },
|
|
@@ -31499,6 +31508,7 @@ var PI_DESCRIPTOR = {
|
|
|
31499
31508
|
transport: "in-process-plugin",
|
|
31500
31509
|
events: {
|
|
31501
31510
|
"session.start": { support: "native", native: "session_start" },
|
|
31511
|
+
"session.end": { support: "native", native: "session_shutdown" },
|
|
31502
31512
|
"context.turn": { support: "native", native: "before_agent_start" },
|
|
31503
31513
|
"shell.pre": { support: "native", native: "tool_call" },
|
|
31504
31514
|
"tool.pre": { support: "native", native: "tool_call" },
|
|
@@ -31609,6 +31619,16 @@ var SCAN_MS = 30 * 60000;
|
|
|
31609
31619
|
// packages/workit-core/src/hooks/agent-model.ts
|
|
31610
31620
|
var UNLISTED = new Set(["description", "prompt"]);
|
|
31611
31621
|
|
|
31622
|
+
// packages/workit-core/src/hooks/teardown.ts
|
|
31623
|
+
var REAP_INTERVAL_MS = 10 * 60000;
|
|
31624
|
+
var LOG_MAX_BYTES = 1 << 20;
|
|
31625
|
+
var ENDS = {
|
|
31626
|
+
claude_code: new Set(["logout", "prompt_input_exit", "other"]),
|
|
31627
|
+
cursor: new Set(["completed", "aborted", "error", "window_close", "user_close"]),
|
|
31628
|
+
pi: new Set(["quit"]),
|
|
31629
|
+
opencode: new Set(["deleted"])
|
|
31630
|
+
};
|
|
31631
|
+
|
|
31612
31632
|
// packages/workit-core/src/hooks/ytrack-guard.ts
|
|
31613
31633
|
var VALUE = new Set(("--host --body -b --body-file --text --date --duration --type --project -p --summary -s " + "--description --description-file --field --tag --add-tag --remove-tag --assignee --comment " + "--json --jq -X --method -f -F --raw-field --input --fields -q --query --author --since --limit " + "--attach -H --header").split(" "));
|
|
31614
31634
|
var BARE = new Set("--debug --no-color --paginate --include --dry-run --silent --yes --meeting --help -h".split(" "));
|
|
@@ -31762,7 +31782,13 @@ import {
|
|
|
31762
31782
|
} from "node:fs";
|
|
31763
31783
|
import os6 from "node:os";
|
|
31764
31784
|
import path37 from "node:path";
|
|
31765
|
-
var CODEX_AGENT_ROLES = [
|
|
31785
|
+
var CODEX_AGENT_ROLES = [
|
|
31786
|
+
"verifier",
|
|
31787
|
+
"reviewer",
|
|
31788
|
+
"implementer",
|
|
31789
|
+
"decider",
|
|
31790
|
+
"babysitter"
|
|
31791
|
+
];
|
|
31766
31792
|
var CODEX_AGENT_MARKER = "# Generated by Workit";
|
|
31767
31793
|
var codexAgentName = (role) => `workit-${role}`;
|
|
31768
31794
|
var codexAgentFile = (role) => `${codexAgentName(role)}.toml`;
|
|
@@ -31918,10 +31944,15 @@ var codexContextProvider = (host = detectCodexSurface(process.env), root) => ({
|
|
|
31918
31944
|
var pluginRoot = () => path38.resolve(path38.dirname(fileURLToPath3(import.meta.url)), "..");
|
|
31919
31945
|
var codexRoleModels = (cwd) => {
|
|
31920
31946
|
const out = {};
|
|
31921
|
-
for (const role of [
|
|
31947
|
+
for (const [file, role] of [
|
|
31948
|
+
["verifier", "verifier"],
|
|
31949
|
+
["reviewer", "reviewer"],
|
|
31950
|
+
["decider", "decider"],
|
|
31951
|
+
["babysitter", "babysit"]
|
|
31952
|
+
]) {
|
|
31922
31953
|
const found = resolveRoleModel(cwd, { role }, "codex");
|
|
31923
31954
|
if (found)
|
|
31924
|
-
out[
|
|
31955
|
+
out[file] = { model: found.model, effort: found.effort };
|
|
31925
31956
|
}
|
|
31926
31957
|
const implementer = uniformImplementerModel(cwd, "codex");
|
|
31927
31958
|
if (implementer)
|
|
@@ -30,7 +30,7 @@ var head = (file) => {
|
|
|
30
30
|
closeSync(fd);
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
|
-
var
|
|
33
|
+
var locateWorkitCli2 = (options = {}) => {
|
|
34
34
|
const env = options.env ?? process.env;
|
|
35
35
|
const platform = options.platform ?? process.platform;
|
|
36
36
|
const exists = options.exists ?? existsSync;
|
|
@@ -77,12 +77,11 @@ var workitCliEnv = (located, env = process.env, platform = process.platform) =>
|
|
|
77
77
|
}
|
|
78
78
|
return patch;
|
|
79
79
|
};
|
|
80
|
-
var
|
|
80
|
+
var useOwnedWorkitCli2 = (options = {}) => {
|
|
81
81
|
const env = options.env ?? process.env;
|
|
82
|
-
const located =
|
|
82
|
+
const located = locateWorkitCli2({ ...options, env });
|
|
83
83
|
Object.assign(env, workitCliEnv(located, env, options.platform));
|
|
84
84
|
return located;
|
|
85
85
|
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
};
|
|
86
|
+
|
|
87
|
+
export { locateWorkitCli2, useOwnedWorkitCli2 };
|
|
@@ -27,6 +27,9 @@ import {
|
|
|
27
27
|
import {
|
|
28
28
|
takeProcNotice2
|
|
29
29
|
} from "./workit-hook-btkg30rw.js";
|
|
30
|
+
import {
|
|
31
|
+
locateWorkitCli2
|
|
32
|
+
} from "./workit-hook-azjr1ew1.js";
|
|
30
33
|
import {
|
|
31
34
|
recordHookRun2
|
|
32
35
|
} from "./workit-hook-w7w0fe4v.js";
|
|
@@ -7356,7 +7359,7 @@ var workspaceConfigSchema = object({
|
|
|
7356
7359
|
fanout: object({
|
|
7357
7360
|
tierModels: unknown().optional().describe("The model per slice TIER (mundane, standard, hard), as one name or per host.")
|
|
7358
7361
|
}).passthrough().optional().describe("Fanout settings."),
|
|
7359
|
-
models: object({ roles: modelRoles }).passthrough().optional().describe("Model and effort per role and host (roles), the lead's own advisory model (lead) and whether a model the lead names on a spawn wins (allowLeadOverride, default false); the same key at the top of workspaces.json is the global default."),
|
|
7362
|
+
models: object({ roles: modelRoles }).passthrough().optional().describe("Model and effort per role and host (roles), the lead's own advisory model (lead), how a role model applies (enforce: advise, the default, or strict) and, under strict, whether a model the lead names on a spawn wins (allowLeadOverride, default false); the same key at the top of workspaces.json is the global default."),
|
|
7360
7363
|
resources: unknown().optional().describe("Heavy-check limits on this machine: slots, scope, heavy, light, memoryMax, cpuQuota, wait."),
|
|
7361
7364
|
remotes: array(nonBlank.refine((pattern) => remotePattern(pattern) !== null, "is not a remote URL (https://host/owner/repo, git@host:owner/repo, a path, or owner/*)")).optional().describe("Remote URLs this entry owns: a checkout pushing to or opening PRs on one never exceeds this entry's grants, wherever the folder is (`owner/*` claims a whole owner). Only the user changes it, in their own terminal."),
|
|
7362
7365
|
autonomy: object(Object.fromEntries(["push", "pr", "merge", "release", "rerun"].map((kind) => [
|
|
@@ -7394,7 +7397,7 @@ var workspaceConfigSchema = object({
|
|
|
7394
7397
|
});
|
|
7395
7398
|
var workspacesFileSchema = object({
|
|
7396
7399
|
workspaces: array(workspaceConfigSchema).optional().describe("Workspace entries, each mapping a path glob to its forge, policies and grants."),
|
|
7397
|
-
models: object({ roles: modelRoles }).passthrough().optional().describe("The global default model and effort per role and host (roles), the lead's own advisory model (lead) and whether a model the lead names on a spawn wins (allowLeadOverride, default false).")
|
|
7400
|
+
models: object({ roles: modelRoles }).passthrough().optional().describe("The global default model and effort per role and host (roles), the lead's own advisory model (lead), how a role model applies (enforce: advise, the default, or strict) and, under strict, whether a model the lead names on a spawn wins (allowLeadOverride, default false).")
|
|
7398
7401
|
}).passthrough().superRefine((file, context) => {
|
|
7399
7402
|
const names = new Set;
|
|
7400
7403
|
for (const [index, workspace] of (file.workspaces ?? []).entries()) {
|
|
@@ -8907,16 +8910,19 @@ var HOST_KEYS = new Set([
|
|
|
8907
8910
|
"pi",
|
|
8908
8911
|
"default"
|
|
8909
8912
|
]);
|
|
8910
|
-
var
|
|
8913
|
+
var CLAUDE_AGENT_FILES = {
|
|
8911
8914
|
decider: { model: "fable", effort: "high" },
|
|
8912
|
-
|
|
8913
|
-
"implementer.standard": { model: "sonnet" },
|
|
8914
|
-
"implementer.mundane": { model: "haiku" },
|
|
8915
|
+
implementer: { model: "sonnet" },
|
|
8915
8916
|
verifier: { model: "sonnet" },
|
|
8916
8917
|
reviewer: { model: "opus" },
|
|
8917
|
-
explore: { model: "haiku" },
|
|
8918
8918
|
babysit: { model: "haiku" }
|
|
8919
8919
|
};
|
|
8920
|
+
var BUILT_IN_CLAUDE_CODE = {
|
|
8921
|
+
...CLAUDE_AGENT_FILES,
|
|
8922
|
+
"implementer.hard": { model: "opus" },
|
|
8923
|
+
"implementer.standard": { model: "sonnet" },
|
|
8924
|
+
"implementer.mundane": { model: "haiku" }
|
|
8925
|
+
};
|
|
8920
8926
|
var isObject2 = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
8921
8927
|
var name = (value) => typeof value === "string" && value.trim() ? value.trim() : null;
|
|
8922
8928
|
var leaf = (value) => {
|
|
@@ -8948,6 +8954,10 @@ var forHostList = (value, host) => {
|
|
|
8948
8954
|
return [];
|
|
8949
8955
|
};
|
|
8950
8956
|
var rolesOf = (models) => isObject2(models) && isObject2(models.roles) ? models.roles : null;
|
|
8957
|
+
var resolveRoleModel = (cwd, selector, host, dir) => {
|
|
8958
|
+
const chosen = firstAvailable(resolveRoleModels(cwd, selector, host, dir), host);
|
|
8959
|
+
return chosen ? { model: chosen.model, effort: chosen.effort, source: chosen.source } : null;
|
|
8960
|
+
};
|
|
8951
8961
|
var resolveRoleModels = (cwd, selector, host, dir) => {
|
|
8952
8962
|
const { role, tier } = selector;
|
|
8953
8963
|
for (const source of modelSources(cwd, dir)) {
|
|
@@ -9002,12 +9012,15 @@ var fallbackText = (chosen) => {
|
|
|
9002
9012
|
const passed = chosen.skipped.map((one) => `${one.model} (${one.provider} exhausted until ${shortTime(one.until)})`).join(", ");
|
|
9003
9013
|
return chosen.allExhausted ? `every model configured for it is exhausted: ${passed}; it runs on ${chosen.model} anyway. Add a model of another provider to the list in workspaces.json, then run \`workit models show\`.` : `fell back past ${passed}.`;
|
|
9004
9014
|
};
|
|
9005
|
-
var
|
|
9015
|
+
var modelsKey = (cwd, key, dir) => {
|
|
9006
9016
|
for (const source of modelSources(cwd, dir))
|
|
9007
|
-
if (isObject2(source.models) && Object.hasOwn(source.models,
|
|
9008
|
-
return source.models
|
|
9009
|
-
return
|
|
9017
|
+
if (isObject2(source.models) && Object.hasOwn(source.models, key))
|
|
9018
|
+
return source.models[key];
|
|
9019
|
+
return;
|
|
9010
9020
|
};
|
|
9021
|
+
var leadOverrideAllowed = (cwd, dir) => modelsKey(cwd, "allowLeadOverride", dir) === true;
|
|
9022
|
+
var enforceMode = (cwd, dir) => modelsKey(cwd, "enforce", dir) === "strict" ? "strict" : "advise";
|
|
9023
|
+
var FILE_ROLES = new Set(["decider", "verifier", "reviewer", "babysit"]);
|
|
9011
9024
|
var CLAUDE_ALIASES = new Set(["sonnet", "opus", "haiku", "fable"]);
|
|
9012
9025
|
var CLAUDE_EFFORTS = new Set(["low", "medium", "high", "xhigh", "max"]);
|
|
9013
9026
|
var FULL_CLAUDE_ID = /^(?:[\w.-]+[./])?claude-(?:\d[\d.-]*-)?(sonnet|opus|haiku|fable)(?:[-.@[]|$)/u;
|
|
@@ -9033,7 +9046,7 @@ var chooseSpawnModel = (cwd, selector, host, given, accept, dir) => {
|
|
|
9033
9046
|
const givenModel = name(given.model);
|
|
9034
9047
|
const label = roleLabel(selector);
|
|
9035
9048
|
const configured = resolved.source !== "built-in";
|
|
9036
|
-
if (givenModel && (!configured || leadOverrideAllowed(cwd, dir)))
|
|
9049
|
+
if (givenModel && (!configured || enforceMode(cwd, dir) === "advise" || leadOverrideAllowed(cwd, dir)))
|
|
9037
9050
|
return none;
|
|
9038
9051
|
const model = accept(resolved.model);
|
|
9039
9052
|
const effort = resolved.effort && !name(given.effort) ? resolved.effort : null;
|
|
@@ -9059,40 +9072,34 @@ var chooseSpawnModel = (cwd, selector, host, given, accept, dir) => {
|
|
|
9059
9072
|
model,
|
|
9060
9073
|
effort,
|
|
9061
9074
|
basis,
|
|
9062
|
-
note: givenModel ? `Workit replaced model ${givenModel} with ${model} on this spawn: role ${label} is set in ${resolved.source}.${why} Next time ${next} on the spawn
|
|
9063
|
-
};
|
|
9064
|
-
};
|
|
9065
|
-
var claudeSpawnArgs = (cwd, selector, dir) => {
|
|
9066
|
-
const choice = chooseSpawnModel(cwd, selector, "claude_code", {}, claudeAgentModel, dir);
|
|
9067
|
-
if (!choice.model)
|
|
9068
|
-
return null;
|
|
9069
|
-
const effort = choice.effort?.toLowerCase() ?? null;
|
|
9070
|
-
return {
|
|
9071
|
-
model: choice.model,
|
|
9072
|
-
effort: effort && CLAUDE_EFFORTS.has(effort) ? effort : null
|
|
9075
|
+
note: givenModel ? `Workit replaced model ${givenModel} with ${model} on this spawn: role ${label} is set in ${resolved.source}.${why} Next time ${next} on the spawn, or set models.enforce "advise" so a named model wins.` : `Workit set ${model}${effort ? ` (effort ${effort})` : ""} on this spawn: role ${label}, ${resolved.source}.${why}${configured ? "" : " Name a model to choose another."}`
|
|
9073
9076
|
};
|
|
9074
9077
|
};
|
|
9075
9078
|
var CLAUDE_SPAWNS = [
|
|
9076
|
-
...
|
|
9077
|
-
label:
|
|
9079
|
+
...MODEL_TIERS.map((tier) => ({
|
|
9080
|
+
label: `workit:implementer ${tier}`,
|
|
9078
9081
|
selector: { role: "implementer", tier }
|
|
9079
9082
|
})),
|
|
9080
|
-
|
|
9081
|
-
|
|
9083
|
+
...["verifier", "reviewer", "decider"].map((role) => ({
|
|
9084
|
+
label: `workit:${role}`,
|
|
9085
|
+
selector: { role }
|
|
9086
|
+
})),
|
|
9087
|
+
{ label: "workit:babysitter", selector: { role: "babysit" } },
|
|
9082
9088
|
{ label: "Explore", selector: { role: "explore" } },
|
|
9083
|
-
{ label: "ROLE: decider", selector: { role: "decider" } },
|
|
9084
|
-
{ label: "ROLE: babysit", selector: { role: "babysit" } },
|
|
9085
9089
|
{ label: "general-purpose", selector: { role: "default" } }
|
|
9086
9090
|
];
|
|
9087
9091
|
var claudeSpawnTable = (cwd, dir) => {
|
|
9088
9092
|
const rows = CLAUDE_SPAWNS.flatMap(({ label, selector }) => {
|
|
9089
|
-
const
|
|
9090
|
-
|
|
9093
|
+
const want = resolveRoleModel(cwd, selector, "claude_code", dir);
|
|
9094
|
+
const model = want && want.source !== "built-in" ? claudeAgentModel(want.model) : null;
|
|
9095
|
+
const effort = want?.effort?.toLowerCase();
|
|
9096
|
+
const file = label.startsWith("workit:") ? CLAUDE_AGENT_FILES[selector.role] : undefined;
|
|
9097
|
+
return model && (model !== file?.model || effort !== file.effort) ? [`${label} ${model}${effort ? `/${effort}` : ""}`] : [];
|
|
9091
9098
|
});
|
|
9092
|
-
return
|
|
9099
|
+
return `Spawn Workit roles by name (workit:implementer, workit:verifier, workit:reviewer, workit:decider, workit:babysitter; search: Explore), workers with run_in_background: true, and pass no model or effort unless the user named one${rows.length ? `; configured here (pass them): ${rows.join(", ")}` : ""}. Implementer prompt: \`workit fanout brief <slice>\` after \`workit fanout worktree create <slice>\`, even for one slice.`;
|
|
9093
9100
|
};
|
|
9094
9101
|
var ROLE_SELECTORS = MODEL_ROLES.flatMap((role) => role === "implementer" ? MODEL_TIERS.map((tier) => ({ role, tier })) : [{ role }]);
|
|
9095
|
-
var AGENT_ROLE = /^(?:workit[:-])?(decider|implementer|verifier|reviewer|explore|babysit)
|
|
9102
|
+
var AGENT_ROLE = /^(?:workit[:-])?(decider|implementer|verifier|reviewer|explore|babysit)(?:(?<=babysit)ter)?$/iu;
|
|
9096
9103
|
var ROLE_LINE = /^[ \t]*ROLE:[ \t]*(decider|implementer|verifier|reviewer|explore|babysit)\b/imu;
|
|
9097
9104
|
var TIER_LINE = /^[ \t]*TIER:[ \t]*(mundane|standard|hard)\b/imu;
|
|
9098
9105
|
var isBrief = (text) => TIER_LINE.test(text) && /^WORKTREE:/mu.test(text);
|
|
@@ -21930,11 +21937,12 @@ var FLAGS = {
|
|
|
21930
21937
|
var CLAUDE_CODE_DESCRIPTOR = {
|
|
21931
21938
|
host: "claude_code",
|
|
21932
21939
|
label: "Claude Code",
|
|
21933
|
-
verifiedAgainst: "claude 2.1.288 (hook zod schemas in the binary)",
|
|
21940
|
+
verifiedAgainst: "claude 2.1.288 (hook zod schemas in the binary; SessionEnd: 2.1.327)",
|
|
21934
21941
|
docs: ["https://code.claude.com/docs/en/hooks"],
|
|
21935
21942
|
transport: "hook-process",
|
|
21936
21943
|
events: {
|
|
21937
21944
|
"session.start": { support: "native", native: "SessionStart" },
|
|
21945
|
+
"session.end": { support: "native", native: "SessionEnd" },
|
|
21938
21946
|
"context.turn": { support: "native", native: "UserPromptSubmit" },
|
|
21939
21947
|
"shell.pre": { support: "native", native: "PreToolUse" },
|
|
21940
21948
|
"tool.pre": { support: "native", native: "PreToolUse" },
|
|
@@ -22047,6 +22055,7 @@ var CODEX_DESCRIPTOR = {
|
|
|
22047
22055
|
transport: "hook-process",
|
|
22048
22056
|
events: {
|
|
22049
22057
|
"session.start": { support: "native", native: "SessionStart" },
|
|
22058
|
+
"session.end": { support: "none", native: null },
|
|
22050
22059
|
"context.turn": { support: "native", native: "UserPromptSubmit" },
|
|
22051
22060
|
"shell.pre": { support: "native", native: "PreToolUse" },
|
|
22052
22061
|
"tool.pre": { support: "native", native: "PreToolUse" },
|
|
@@ -22318,6 +22327,7 @@ var CURSOR_DESCRIPTOR = {
|
|
|
22318
22327
|
transport: "hook-process",
|
|
22319
22328
|
events: {
|
|
22320
22329
|
"session.start": { support: "native", native: "sessionStart" },
|
|
22330
|
+
"session.end": { support: "native", native: "sessionEnd" },
|
|
22321
22331
|
"context.turn": none,
|
|
22322
22332
|
"shell.pre": { support: "native", native: "beforeShellExecution" },
|
|
22323
22333
|
"tool.pre": { support: "native", native: "preToolUse" },
|
|
@@ -22424,6 +22434,7 @@ var OPENCODE_DESCRIPTOR = {
|
|
|
22424
22434
|
transport: "in-process-plugin",
|
|
22425
22435
|
events: {
|
|
22426
22436
|
"session.start": { support: "none", native: null },
|
|
22437
|
+
"session.end": { support: "partial", native: 'event("session.deleted")' },
|
|
22427
22438
|
"context.turn": { support: "native", native: 'session.hook("context")' },
|
|
22428
22439
|
"shell.pre": { support: "native", native: 'permission.hook("evaluate")' },
|
|
22429
22440
|
"tool.pre": { support: "native", native: 'tool.hook("execute.before")' },
|
|
@@ -22493,6 +22504,7 @@ var PI_DESCRIPTOR = {
|
|
|
22493
22504
|
transport: "in-process-plugin",
|
|
22494
22505
|
events: {
|
|
22495
22506
|
"session.start": { support: "native", native: "session_start" },
|
|
22507
|
+
"session.end": { support: "native", native: "session_shutdown" },
|
|
22496
22508
|
"context.turn": { support: "native", native: "before_agent_start" },
|
|
22497
22509
|
"shell.pre": { support: "native", native: "tool_call" },
|
|
22498
22510
|
"tool.pre": { support: "native", native: "tool_call" },
|
|
@@ -23903,11 +23915,12 @@ var respawn = (input, reasons, dropped, limits) => {
|
|
|
23903
23915
|
return {
|
|
23904
23916
|
kind: "deny",
|
|
23905
23917
|
reason: [
|
|
23906
|
-
`workit spawn args:
|
|
23907
|
-
|
|
23908
|
-
"
|
|
23918
|
+
`workit spawn args: ${reasons.join(" ")}`,
|
|
23919
|
+
`Retry as: Agent ${args} (description and prompt as written${without}).`,
|
|
23920
|
+
"Why: auto mode refuses a hook-rewritten spawn.",
|
|
23909
23921
|
limits
|
|
23910
|
-
].filter(Boolean).join(
|
|
23922
|
+
].filter(Boolean).join(`
|
|
23923
|
+
`),
|
|
23911
23924
|
unblock: args
|
|
23912
23925
|
};
|
|
23913
23926
|
};
|
|
@@ -23942,18 +23955,19 @@ var agentModelDecision = (cwd, tool, options = {}) => {
|
|
|
23942
23955
|
if (!selector)
|
|
23943
23956
|
return asWritten(null);
|
|
23944
23957
|
const choice = chooseSpawnModel(cwd, selector, "claude_code", tool, claudeAgentModel);
|
|
23958
|
+
const file = String(tool.subagent_type).startsWith("workit:") ? CLAUDE_AGENT_FILES[selector.role] : undefined;
|
|
23945
23959
|
const effort = choice.effort?.toLowerCase() ?? null;
|
|
23946
23960
|
const input = { ...tool };
|
|
23947
|
-
if (choice.model)
|
|
23961
|
+
if (choice.model && (given(tool.model) || choice.model !== file?.model))
|
|
23948
23962
|
input.model = choice.model;
|
|
23949
|
-
if (effort && CLAUDE_EFFORTS.has(effort) && !given(tool.effort))
|
|
23963
|
+
if (effort && CLAUDE_EFFORTS.has(effort) && !given(tool.effort) && effort !== file?.effort)
|
|
23950
23964
|
input.effort = effort;
|
|
23951
23965
|
const needs = [
|
|
23952
23966
|
input.model === tool.model ? null : `model ${String(input.model)}`,
|
|
23953
23967
|
input.effort === tool.effort ? null : `effort ${String(input.effort)}`
|
|
23954
23968
|
].filter(Boolean);
|
|
23955
23969
|
if (!needs.length)
|
|
23956
|
-
return asWritten(choice.note);
|
|
23970
|
+
return asWritten(choice.model ? null : choice.note);
|
|
23957
23971
|
if (!auto) {
|
|
23958
23972
|
const note = choice.note ?? `Workit set effort ${String(input.effort)} on this spawn: its role's configured effort.`;
|
|
23959
23973
|
return {
|
|
@@ -23963,12 +23977,18 @@ var agentModelDecision = (cwd, tool, options = {}) => {
|
|
|
23963
23977
|
`)
|
|
23964
23978
|
};
|
|
23965
23979
|
}
|
|
23980
|
+
if (enforceMode(cwd) === "advise") {
|
|
23981
|
+
if (changed)
|
|
23982
|
+
return respawn(tool, change.reasons, change.dropped, limits);
|
|
23983
|
+
const ran = file ? `${file.model}${file.effort ? `/${file.effort}` : ""}` : "its default model";
|
|
23984
|
+
const pass = spawnArgsText({ model: input.model, effort: input.effort });
|
|
23985
|
+
return asWritten(`Workit: this ${String(tool.subagent_type || "general-purpose")} spawn runs on ${ran}; ${choice.basis} sets ${needs.join(" and ")}. To use it, pass ${pass} on the spawn.`);
|
|
23986
|
+
}
|
|
23966
23987
|
const replaced = given(tool.model) && input.model !== tool.model;
|
|
23967
23988
|
return respawn(input, [
|
|
23968
23989
|
...change.reasons,
|
|
23969
|
-
`It needs ${needs.join(" and ")}
|
|
23970
|
-
|
|
23971
|
-
].filter(Boolean), change.dropped, limits);
|
|
23990
|
+
`It needs ${needs.join(" and ")} (${choice.basis}, models.enforce strict)${replaced ? `, not ${String(tool.model)}` : ""}.`
|
|
23991
|
+
], change.dropped, limits);
|
|
23972
23992
|
};
|
|
23973
23993
|
|
|
23974
23994
|
// packages/workit-core/src/hooks/spawn-gate.ts
|
|
@@ -24008,6 +24028,156 @@ var spawnDecision = (descriptor, cwd, tool, permissionMode = null) => {
|
|
|
24008
24028
|
return agentModelDecision(cwd, checked.input, { change: checked.change, permissionMode });
|
|
24009
24029
|
};
|
|
24010
24030
|
|
|
24031
|
+
// packages/workit-core/src/hooks/teardown.ts
|
|
24032
|
+
import { spawn } from "node:child_process";
|
|
24033
|
+
import fs23 from "node:fs";
|
|
24034
|
+
import path35 from "node:path";
|
|
24035
|
+
var REAP_INTERVAL_MS = 10 * 60000;
|
|
24036
|
+
var LOG_MAX_BYTES = 1 << 20;
|
|
24037
|
+
var ENDS = {
|
|
24038
|
+
claude_code: new Set(["logout", "prompt_input_exit", "other"]),
|
|
24039
|
+
cursor: new Set(["completed", "aborted", "error", "window_close", "user_close"]),
|
|
24040
|
+
pi: new Set(["quit"]),
|
|
24041
|
+
opencode: new Set(["deleted"])
|
|
24042
|
+
};
|
|
24043
|
+
var SAFE_SESSION = /^[\w.@+][\w.:@/+-]{0,127}$/u;
|
|
24044
|
+
var HOST_SESSION_VARS = ["OPENCODE_SESSION_ID", "PI_SESSION_ID", "CODEX_THREAD_ID"];
|
|
24045
|
+
var teardownDir = (env) => path35.join(stateDir3(env), "procs");
|
|
24046
|
+
var teardownLog = (env) => path35.join(teardownDir(env), "teardown.log");
|
|
24047
|
+
var reapStamp = (env) => path35.join(teardownDir(env), "reap-at-start.stamp");
|
|
24048
|
+
function spawnDetached(request) {
|
|
24049
|
+
try {
|
|
24050
|
+
const shell = process.platform === "win32" && !/\.exe$/iu.test(request.command);
|
|
24051
|
+
const line = [`"${request.command}"`, ...request.args].join(" ");
|
|
24052
|
+
const child = spawn(shell ? line : request.command, shell ? [] : request.args, {
|
|
24053
|
+
cwd: request.cwd,
|
|
24054
|
+
env: request.env,
|
|
24055
|
+
detached: true,
|
|
24056
|
+
shell,
|
|
24057
|
+
stdio: ["ignore", request.log ?? "ignore", request.log ?? "ignore"],
|
|
24058
|
+
windowsHide: true
|
|
24059
|
+
});
|
|
24060
|
+
child.on("error", () => {});
|
|
24061
|
+
child.unref();
|
|
24062
|
+
return child.pid !== undefined;
|
|
24063
|
+
} catch {
|
|
24064
|
+
return false;
|
|
24065
|
+
}
|
|
24066
|
+
}
|
|
24067
|
+
var teardownDeps = {
|
|
24068
|
+
spawn: (request) => request.env.WORKIT_TEST_RUN === undefined && spawnDetached(request),
|
|
24069
|
+
now: () => Date.now()
|
|
24070
|
+
};
|
|
24071
|
+
var openLog = (env, args) => {
|
|
24072
|
+
try {
|
|
24073
|
+
const file = teardownLog(env);
|
|
24074
|
+
fs23.mkdirSync(path35.dirname(file), { recursive: true });
|
|
24075
|
+
let size = 0;
|
|
24076
|
+
try {
|
|
24077
|
+
size = fs23.statSync(file).size;
|
|
24078
|
+
} catch {}
|
|
24079
|
+
const fd = fs23.openSync(file, size > LOG_MAX_BYTES ? "w" : "a", 384);
|
|
24080
|
+
fs23.writeSync(fd, `${new Date(teardownDeps.now()).toISOString()} workit ${args.join(" ")}
|
|
24081
|
+
`);
|
|
24082
|
+
return fd;
|
|
24083
|
+
} catch {
|
|
24084
|
+
return null;
|
|
24085
|
+
}
|
|
24086
|
+
};
|
|
24087
|
+
function runCli(args, env, cwd) {
|
|
24088
|
+
let log = null;
|
|
24089
|
+
try {
|
|
24090
|
+
const cli = locateWorkitCli2({ env });
|
|
24091
|
+
log = openLog(env, args);
|
|
24092
|
+
const started = teardownDeps.spawn({
|
|
24093
|
+
command: cli.command,
|
|
24094
|
+
args: [...cli.args, ...args],
|
|
24095
|
+
env,
|
|
24096
|
+
cwd: fs23.existsSync(cwd) ? cwd : teardownDir(env),
|
|
24097
|
+
log
|
|
24098
|
+
});
|
|
24099
|
+
if (!started && log !== null)
|
|
24100
|
+
fs23.writeSync(log, ` not started
|
|
24101
|
+
`);
|
|
24102
|
+
return started;
|
|
24103
|
+
} catch {
|
|
24104
|
+
return false;
|
|
24105
|
+
} finally {
|
|
24106
|
+
if (log !== null)
|
|
24107
|
+
try {
|
|
24108
|
+
fs23.closeSync(log);
|
|
24109
|
+
} catch {}
|
|
24110
|
+
}
|
|
24111
|
+
}
|
|
24112
|
+
function endSession(end, env = process.env) {
|
|
24113
|
+
const session = end.session?.trim() ?? "";
|
|
24114
|
+
if (!SAFE_SESSION.test(session) || !ENDS[end.host]?.has(end.reason ?? ""))
|
|
24115
|
+
return false;
|
|
24116
|
+
const outer = env.WORKIT_SESSION_ID?.trim();
|
|
24117
|
+
if (end.agentId || env.WORKIT_PI_WORKER_SESSION || leadOf(session) !== session || outer && leadOf(outer) !== outer)
|
|
24118
|
+
return false;
|
|
24119
|
+
const child = { ...env, WORKIT_SESSION_ID: session, WORKIT_HOST: end.host };
|
|
24120
|
+
for (const key of HOST_SESSION_VARS)
|
|
24121
|
+
delete child[key];
|
|
24122
|
+
return runCli(["stop", "--session", session, "--reason", "session-end"], child, end.cwd);
|
|
24123
|
+
}
|
|
24124
|
+
var claim2 = (file, now) => {
|
|
24125
|
+
for (let attempt = 0;attempt < 2; attempt += 1)
|
|
24126
|
+
try {
|
|
24127
|
+
fs23.writeFileSync(file, String(now), { flag: "wx", mode: 384 });
|
|
24128
|
+
return true;
|
|
24129
|
+
} catch (error) {
|
|
24130
|
+
if (error.code !== "EEXIST")
|
|
24131
|
+
return false;
|
|
24132
|
+
let held = Number.NaN;
|
|
24133
|
+
try {
|
|
24134
|
+
held = Number(fs23.readFileSync(file, "utf8"));
|
|
24135
|
+
} catch {}
|
|
24136
|
+
if (now - held < REAP_INTERVAL_MS)
|
|
24137
|
+
return false;
|
|
24138
|
+
fs23.rmSync(file, { force: true });
|
|
24139
|
+
}
|
|
24140
|
+
return false;
|
|
24141
|
+
};
|
|
24142
|
+
var fresh = (stamp, now) => {
|
|
24143
|
+
try {
|
|
24144
|
+
const last = Number(fs23.readFileSync(stamp, "utf8"));
|
|
24145
|
+
return now - last < REAP_INTERVAL_MS && last <= now;
|
|
24146
|
+
} catch {
|
|
24147
|
+
return false;
|
|
24148
|
+
}
|
|
24149
|
+
};
|
|
24150
|
+
function reapAtStart(cwd, env = process.env) {
|
|
24151
|
+
const stamp = reapStamp(env);
|
|
24152
|
+
const lock = `${stamp}.claim`;
|
|
24153
|
+
const now = teardownDeps.now();
|
|
24154
|
+
try {
|
|
24155
|
+
if (fresh(stamp, now))
|
|
24156
|
+
return false;
|
|
24157
|
+
fs23.mkdirSync(path35.dirname(stamp), { recursive: true });
|
|
24158
|
+
if (!claim2(lock, now))
|
|
24159
|
+
return false;
|
|
24160
|
+
} catch {
|
|
24161
|
+
return false;
|
|
24162
|
+
}
|
|
24163
|
+
let started = false;
|
|
24164
|
+
try {
|
|
24165
|
+
if (fresh(stamp, now))
|
|
24166
|
+
return false;
|
|
24167
|
+
started = runCli(["stop", "--orphans", "--reason", "session-start"], env, cwd);
|
|
24168
|
+
if (started) {
|
|
24169
|
+
const temp = `${stamp}.${process.pid}`;
|
|
24170
|
+
fs23.writeFileSync(temp, String(now), { mode: 384 });
|
|
24171
|
+
fs23.renameSync(temp, stamp);
|
|
24172
|
+
}
|
|
24173
|
+
} catch {} finally {
|
|
24174
|
+
try {
|
|
24175
|
+
fs23.rmSync(lock, { force: true });
|
|
24176
|
+
} catch {}
|
|
24177
|
+
}
|
|
24178
|
+
return started;
|
|
24179
|
+
}
|
|
24180
|
+
|
|
24011
24181
|
// packages/workit-core/src/hooks/ytrack-word.ts
|
|
24012
24182
|
var YTRACK_WORD = /ytrack(?![\w/-]|\.(?!exe|cmd))/i;
|
|
24013
24183
|
var namesYtrack = (text) => {
|
|
@@ -24570,6 +24740,7 @@ function decide(input, deps) {
|
|
|
24570
24740
|
const event = input.event;
|
|
24571
24741
|
switch (event.kind) {
|
|
24572
24742
|
case "session.start": {
|
|
24743
|
+
reapAtStart(input.cwd);
|
|
24573
24744
|
if (!usable2(descriptor.context.sessionStart))
|
|
24574
24745
|
return NONE6;
|
|
24575
24746
|
const key = input.session.id ? `${input.host}\x00${input.session.id}` : null;
|
|
@@ -24584,6 +24755,15 @@ function decide(input, deps) {
|
|
|
24584
24755
|
seedTurnContext(input, descriptor);
|
|
24585
24756
|
return { kind: "context", text };
|
|
24586
24757
|
}
|
|
24758
|
+
case "session.end":
|
|
24759
|
+
endSession({
|
|
24760
|
+
host: input.host,
|
|
24761
|
+
session: input.session.id,
|
|
24762
|
+
agentId: input.session.agentId,
|
|
24763
|
+
reason: event.reason,
|
|
24764
|
+
cwd: input.cwd
|
|
24765
|
+
});
|
|
24766
|
+
return NONE6;
|
|
24587
24767
|
case "context.turn": {
|
|
24588
24768
|
if (!usable2(descriptor.context.perTurn))
|
|
24589
24769
|
return NONE6;
|
|
@@ -24794,7 +24974,7 @@ var dispatchHook = (adapter, raw, env = process.env) => {
|
|
|
24794
24974
|
};
|
|
24795
24975
|
// packages/workit-core/src/hooks/deadline.ts
|
|
24796
24976
|
import { appendFileSync, mkdirSync as mkdirSync4 } from "node:fs";
|
|
24797
|
-
import
|
|
24977
|
+
import path36 from "node:path";
|
|
24798
24978
|
var HOOK_SKIP_TEXT = "workit context skipped: host under load";
|
|
24799
24979
|
var HOOK_DEADLINE_MS = 8000;
|
|
24800
24980
|
var HOST_DEADLINES = {
|
|
@@ -24812,7 +24992,7 @@ var hookDeadlineMs = (env, host = "", native) => {
|
|
|
24812
24992
|
const row = HOST_DEADLINES[host];
|
|
24813
24993
|
return override(env) ?? (row ? native === undefined ? Math.min(...Object.values(row)) : row[native] ?? row[""] : HOOK_DEADLINE_MS);
|
|
24814
24994
|
};
|
|
24815
|
-
var skipsFile = (stateDir) =>
|
|
24995
|
+
var skipsFile = (stateDir) => path36.join(stateDir, HOOK_SKIPS_FILE);
|
|
24816
24996
|
var recordHookSkip = (skip, stateDir = resolveStateDir()) => {
|
|
24817
24997
|
try {
|
|
24818
24998
|
mkdirSync4(stateDir, { recursive: true });
|
package/dist/workit-hook.js
CHANGED
|
@@ -32,7 +32,7 @@ if (tooOld) {
|
|
|
32
32
|
const { belowFloor } = await import("./workit-hook-9k8dtngs.js");
|
|
33
33
|
process.exit(await belowFloor(codexHost(), { ...tooOld, found: foundNode }, fileURLToPath(import.meta.url)));
|
|
34
34
|
}
|
|
35
|
-
var { useOwnedWorkitCli } = await import("./workit-hook-
|
|
35
|
+
var { useOwnedWorkitCli } = await import("./workit-hook-dzfxvq92.js");
|
|
36
36
|
useOwnedWorkitCli();
|
|
37
37
|
var { maybeHeavy, stateDir } = await import("./workit-hook-1xk8mx4h.js");
|
|
38
38
|
var { configDir } = await import("./workit-hook-z09frbdk.js");
|
|
@@ -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-x0h085t0.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.15.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.15.0",
|
|
45
|
+
"@workit-dev/mcp": "^2.15.0"
|
|
46
46
|
},
|
|
47
47
|
"engines": {
|
|
48
48
|
"node": ">=24"
|
|
@@ -39,7 +39,7 @@ units of ~100+ lines each. Coupled work stays with one owner. Workit never spawn
|
|
|
39
39
|
6. **Retry once, then escalate.** A stuck or failed slice gets one retry with
|
|
40
40
|
a fresh brief (`workit fanout brief <slice> --mode resume`, same branch);
|
|
41
41
|
if that fails too, re-slice it, take it over, or report the gap. Never
|
|
42
|
-
chain resumes. A fix round and recheck that both fail:
|
|
42
|
+
chain resumes. A fix round and recheck that both fail: the decider agent, not a
|
|
43
43
|
third round; product choices go to the user (`references/orchestration.md`).
|
|
44
44
|
7. **Verify by the workspace `verification` setting** (`workit grant show`).
|
|
45
45
|
A report is a pointer, never evidence. `proportional` (default): each slice's lane (`workit pr status`) decides; none needs no verdict, self the author's `--self`, focused and full a verifier (Claude Code: the `model` and `effort` of `workit models show --role verifier`) after the last push; one verdict at a stack's top covers its unchanged lower PRs, and a stale one with `reverify: focused` re-checks only the new diff, reusing green CI. `self`: a verifier that wrote none
|
|
@@ -5,35 +5,37 @@ and fans in. Workit records and checks; the host's own subagents run the work.
|
|
|
5
5
|
|
|
6
6
|
## TIER to model
|
|
7
7
|
|
|
8
|
-
TIER is a field of each slice and of its brief.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
| Role or TIER |
|
|
8
|
+
TIER is a field of each slice and of its brief. Each Workit role is a host
|
|
9
|
+
agent that carries its own model: spawn it by name and pass no `model` or
|
|
10
|
+
`effort` unless the user named one (a named model always wins).
|
|
11
|
+
|
|
12
|
+
| Host | Spawn by name |
|
|
13
|
+
| --- | --- |
|
|
14
|
+
| Claude Code | `workit:implementer`, `workit:verifier`, `workit:reviewer`, `workit:decider`, `workit:babysitter`; search: `Explore` |
|
|
15
|
+
| OpenCode | `workit-implementer`, `workit-verifier`, `workit-reviewer`, `workit-decider`, `workit-babysitter` |
|
|
16
|
+
| Codex | the same `workit-*` names |
|
|
17
|
+
| Cursor | `workit-verifier`, `workit-reviewer`, `workit-decider`, `workit-babysitter` |
|
|
18
|
+
|
|
19
|
+
Claude Code, with nothing configured (pass a brief's `SPAWN:` line as printed):
|
|
20
|
+
|
|
21
|
+
| Role or TIER | Model |
|
|
22
22
|
| --- | --- |
|
|
23
|
-
| decider | `fable`, effort `high` |
|
|
24
|
-
| hard | `opus` |
|
|
25
|
-
| standard | `sonnet` |
|
|
26
|
-
| mundane | `haiku` |
|
|
27
|
-
|
|
|
28
|
-
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
`
|
|
35
|
-
`models.
|
|
36
|
-
|
|
23
|
+
| decider | `fable`, effort `high` (agent file) |
|
|
24
|
+
| hard | `opus` (the brief's SPAWN line) |
|
|
25
|
+
| standard, verifier | `sonnet` (agent file) |
|
|
26
|
+
| mundane | `haiku` (the brief's SPAWN line) |
|
|
27
|
+
| reviewer | `opus` (agent file) |
|
|
28
|
+
| babysitter | `haiku` (agent file) |
|
|
29
|
+
|
|
30
|
+
A role
|
|
31
|
+
configured in `models.roles` to another model is listed in your session
|
|
32
|
+
contract (Claude Code) or set on the host's agent (OpenCode, Codex); `workit
|
|
33
|
+
models show [--role r] [--host h]` prints per host whether it comes from the
|
|
34
|
+
`agent file`, a `spawn fill` or is `advisory` (pass it yourself), and the
|
|
35
|
+
`models.enforce` mode. Under `strict` a configured role model beats a named
|
|
36
|
+
one and Claude Code's auto mode denies a spawn that lacks it. A role with no
|
|
37
|
+
model runs on the host's model, and TIER only sizes the timebox and decides
|
|
38
|
+
whether to race. `models.lead` (your own model) is advisory.
|
|
37
39
|
|
|
38
40
|
## Rolling window
|
|
39
41
|
|
|
@@ -66,10 +68,9 @@ reversibility (the option cheapest to undo wins a tie), and the exact change
|
|
|
66
68
|
list. The fixer applies that list once, then one focused recheck follows.
|
|
67
69
|
|
|
68
70
|
- Hard call (shared contract, security, migration): two deciders on different
|
|
69
|
-
models (Claude Code, OpenCode, Cursor:
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
more reversible option.
|
|
71
|
+
models (Claude Code, OpenCode, Cursor: one bare decider spawn and one that
|
|
72
|
+
names another `model`; Codex and Pi: one decider). If they disagree, you
|
|
73
|
+
take the more reversible option.
|
|
73
74
|
- Record it: `workit ledger decision "<pick>" --by decider --why "<why it is
|
|
74
75
|
the more reversible>" --view "<decider A: view>" --view "<decider B: view>"`.
|
|
75
76
|
The row is listed as a decider call; it is never the user's answer to a
|
|
@@ -45,7 +45,7 @@ those files since the judged head and reuse green CI there (no fresh install, no
|
|
|
45
45
|
under your own session (the one the lead or the hook gave you).
|
|
46
46
|
8. **Bound the loop.** A failed verdict gets one fix round and one recheck of
|
|
47
47
|
the changed hunks. Still failing, or stuck: no third round; the lead spawns
|
|
48
|
-
|
|
48
|
+
the decider agent by name, no model (read the `workit-fanout` skill's SKILL.md and follow it). A product choice: the user.
|
|
49
49
|
9. **Harness note** (optional): friction caused by the repo or harness, not
|
|
50
50
|
the change (a flaky fixture, a missing check, a misleading doc or skill
|
|
51
51
|
line), goes on its own `Harness note:` line in the report and any PR
|
|
@@ -29,7 +29,7 @@ once the verdict is accepted. `merged`: step 7. `null` (closed, not merged):
|
|
|
29
29
|
stop and report. Stop early only for a new consequential choice, a host
|
|
30
30
|
denial, a review comment that needs a product decision, a required update
|
|
31
31
|
that repeats because the base keeps moving, or after 3 failed fix attempts on
|
|
32
|
-
the same check. Fix round and recheck both failed:
|
|
32
|
+
the same check. Fix round and recheck both failed: the decider agent (read the `workit-fanout` skill's SKILL.md and follow it).
|
|
33
33
|
|
|
34
34
|
1. **Open.** Last before the PR, if `workit grant show` has `changelog: update|create`: write the Unreleased entry with `workit changelog apply`, commit it; with `docs: when-user-facing` fix only docs the diff made false (`references/changelog.md`).
|
|
35
35
|
Full local check (`workit check ci` when `.workit/checks.json` has a `ci` group), push once: `workit git push`, then `workit pr template` and fill the template it prints: every heading, each `<!-- -->` replaced (Workit's: `references/pr-body.md`).
|