@workit-dev/opencode 2.12.0 → 2.14.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.
|
@@ -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 (call the skill tool with `workit-fanout`). 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 (call the skill tool with `workit-fanout`).
|
|
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`).
|
package/dist/plugin.js
CHANGED
|
@@ -183,7 +183,7 @@ function define(plugin) {
|
|
|
183
183
|
|
|
184
184
|
// packages/workit-core/src/core.ts
|
|
185
185
|
import { spawnSync as spawnSync22 } from "node:child_process";
|
|
186
|
-
import { existsSync as
|
|
186
|
+
import { existsSync as existsSync14, realpathSync as realpathSync9 } from "node:fs";
|
|
187
187
|
import path35 from "node:path";
|
|
188
188
|
|
|
189
189
|
// packages/workit-core/src/core/task-contract.ts
|
|
@@ -9500,7 +9500,7 @@ var workspaceConfigSchema = object({
|
|
|
9500
9500
|
fanout: object({
|
|
9501
9501
|
tierModels: unknown().optional().describe("The model per slice TIER (mundane, standard, hard), as one name or per host.")
|
|
9502
9502
|
}).passthrough().optional().describe("Fanout settings."),
|
|
9503
|
-
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."),
|
|
9503
|
+
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."),
|
|
9504
9504
|
resources: unknown().optional().describe("Heavy-check limits on this machine: slots, scope, heavy, light, memoryMax, cpuQuota, wait."),
|
|
9505
9505
|
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."),
|
|
9506
9506
|
autonomy: object(Object.fromEntries(["push", "pr", "merge", "release", "rerun"].map((kind) => [
|
|
@@ -9538,7 +9538,7 @@ var workspaceConfigSchema = object({
|
|
|
9538
9538
|
});
|
|
9539
9539
|
var workspacesFileSchema = object({
|
|
9540
9540
|
workspaces: array(workspaceConfigSchema).optional().describe("Workspace entries, each mapping a path glob to its forge, policies and grants."),
|
|
9541
|
-
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).")
|
|
9541
|
+
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).")
|
|
9542
9542
|
}).passthrough().superRefine((file, context) => {
|
|
9543
9543
|
const names = new Set;
|
|
9544
9544
|
for (const [index, workspace] of (file.workspaces ?? []).entries()) {
|
|
@@ -9552,6 +9552,7 @@ var workspacesFileSchema = object({
|
|
|
9552
9552
|
names.add(workspace.name);
|
|
9553
9553
|
}
|
|
9554
9554
|
});
|
|
9555
|
+
var workspacesPath = () => path9.join(configDir2(), "workspaces.json");
|
|
9555
9556
|
var workspacesRevision = (contents) => createHash5("sha256").update(contents ?? "<missing>").digest("hex");
|
|
9556
9557
|
var validateWorkspacesDocument = (parsed, file) => {
|
|
9557
9558
|
if (!isConfigObject(parsed)) {
|
|
@@ -10466,7 +10467,7 @@ function resolveTrackFor(cwd, options) {
|
|
|
10466
10467
|
}
|
|
10467
10468
|
|
|
10468
10469
|
// packages/workit-core/src/core/vcs-config.ts
|
|
10469
|
-
var
|
|
10470
|
+
var workspacesPath2 = () => path10.join(configDir2(), "workspaces.json");
|
|
10470
10471
|
var vcsCwd = (cwd) => cwd ?? process.env.WORKIT_WORKSPACE_ROOT ?? process.cwd();
|
|
10471
10472
|
var remoteProvider = (cwd) => {
|
|
10472
10473
|
const url = originUrl(cwd) ?? "";
|
|
@@ -10644,7 +10645,7 @@ function vcsConfig(mode, cwd, options = {}) {
|
|
|
10644
10645
|
defaultBranch: workspaceDefault
|
|
10645
10646
|
});
|
|
10646
10647
|
if (trackResolution.status === "invalid")
|
|
10647
|
-
return { ok: false, error: trackResolution.error, configPath:
|
|
10648
|
+
return { ok: false, error: trackResolution.error, configPath: workspacesPath2() };
|
|
10648
10649
|
const releaseTrack = trackSummary(trackResolution);
|
|
10649
10650
|
const defaultTarget = releaseTrack?.track?.pullRequestTarget ?? workspaceDefault;
|
|
10650
10651
|
const baseBranch = releaseTrack?.track?.baseBranch ?? defaultTarget;
|
|
@@ -18077,16 +18078,19 @@ var HOST_KEYS = new Set([
|
|
|
18077
18078
|
"pi",
|
|
18078
18079
|
"default"
|
|
18079
18080
|
]);
|
|
18080
|
-
var
|
|
18081
|
+
var CLAUDE_AGENT_FILES = {
|
|
18081
18082
|
decider: { model: "fable", effort: "high" },
|
|
18082
|
-
|
|
18083
|
-
"implementer.standard": { model: "sonnet" },
|
|
18084
|
-
"implementer.mundane": { model: "haiku" },
|
|
18083
|
+
implementer: { model: "sonnet" },
|
|
18085
18084
|
verifier: { model: "sonnet" },
|
|
18086
18085
|
reviewer: { model: "opus" },
|
|
18087
|
-
explore: { model: "haiku" },
|
|
18088
18086
|
babysit: { model: "haiku" }
|
|
18089
18087
|
};
|
|
18088
|
+
var BUILT_IN_CLAUDE_CODE = {
|
|
18089
|
+
...CLAUDE_AGENT_FILES,
|
|
18090
|
+
"implementer.hard": { model: "opus" },
|
|
18091
|
+
"implementer.standard": { model: "sonnet" },
|
|
18092
|
+
"implementer.mundane": { model: "haiku" }
|
|
18093
|
+
};
|
|
18090
18094
|
var isObject6 = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
18091
18095
|
var name = (value) => typeof value === "string" && value.trim() ? value.trim() : null;
|
|
18092
18096
|
var leaf = (value) => {
|
|
@@ -18170,6 +18174,7 @@ var firstAvailable = (candidates, host, now = new Date) => {
|
|
|
18170
18174
|
}
|
|
18171
18175
|
return { ...primary, skipped, allExhausted: true };
|
|
18172
18176
|
};
|
|
18177
|
+
var resolveAvailableRoleModel = (cwd, selector, host, now = new Date, dir) => firstAvailable(resolveRoleModels(cwd, selector, host, dir), host, now);
|
|
18173
18178
|
var fallbackText = (chosen) => {
|
|
18174
18179
|
if (!chosen.skipped.length)
|
|
18175
18180
|
return null;
|
|
@@ -18208,12 +18213,15 @@ var leadSwitchNotice = (cwd, host, current, now = new Date, dir) => {
|
|
|
18208
18213
|
const how = SWITCH_HOW[hostFamily(host) ?? ""] ?? "the host's model switch";
|
|
18209
18214
|
return next ? `Workit cannot switch this session's model: ${blocked.provider} is exhausted until ${shortTime(blocked.until)}. Switch the lead to ${next.model} with ${how}${hostFamily(host) === "claude_code" && providerOf(next.model, host) !== "anthropic" ? " (another host: Claude Code runs only Anthropic models)" : ""}.` : `Workit cannot switch this session's model: ${blocked.provider} is exhausted until ${shortTime(blocked.until)}, and models.lead names no model of another provider. Add one to models.lead in workspaces.json, then run \`workit models show\`.`;
|
|
18210
18215
|
};
|
|
18211
|
-
var
|
|
18216
|
+
var modelsKey = (cwd, key, dir) => {
|
|
18212
18217
|
for (const source of modelSources(cwd, dir))
|
|
18213
|
-
if (isObject6(source.models) && Object.hasOwn(source.models,
|
|
18214
|
-
return source.models
|
|
18215
|
-
return
|
|
18218
|
+
if (isObject6(source.models) && Object.hasOwn(source.models, key))
|
|
18219
|
+
return source.models[key];
|
|
18220
|
+
return;
|
|
18216
18221
|
};
|
|
18222
|
+
var leadOverrideAllowed = (cwd, dir) => modelsKey(cwd, "allowLeadOverride", dir) === true;
|
|
18223
|
+
var enforceMode = (cwd, dir) => modelsKey(cwd, "enforce", dir) === "strict" ? "strict" : "advise";
|
|
18224
|
+
var FILE_ROLES = new Set(["decider", "verifier", "reviewer", "babysit"]);
|
|
18217
18225
|
var CLAUDE_ALIASES = new Set(["sonnet", "opus", "haiku", "fable"]);
|
|
18218
18226
|
var CLAUDE_EFFORTS = new Set(["low", "medium", "high", "xhigh", "max"]);
|
|
18219
18227
|
var FULL_CLAUDE_ID = /^(?:[\w.-]+[./])?claude-(?:\d[\d.-]*-)?(sonnet|opus|haiku|fable)(?:[-.@[]|$)/u;
|
|
@@ -18239,7 +18247,7 @@ var chooseSpawnModel = (cwd, selector, host, given, accept, dir) => {
|
|
|
18239
18247
|
const givenModel = name(given.model);
|
|
18240
18248
|
const label = roleLabel(selector);
|
|
18241
18249
|
const configured = resolved.source !== "built-in";
|
|
18242
|
-
if (givenModel && (!configured || leadOverrideAllowed(cwd, dir)))
|
|
18250
|
+
if (givenModel && (!configured || enforceMode(cwd, dir) === "advise" || leadOverrideAllowed(cwd, dir)))
|
|
18243
18251
|
return none;
|
|
18244
18252
|
const model = accept(resolved.model);
|
|
18245
18253
|
const effort = resolved.effort && !name(given.effort) ? resolved.effort : null;
|
|
@@ -18265,40 +18273,39 @@ var chooseSpawnModel = (cwd, selector, host, given, accept, dir) => {
|
|
|
18265
18273
|
model,
|
|
18266
18274
|
effort,
|
|
18267
18275
|
basis,
|
|
18268
|
-
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
|
|
18269
|
-
};
|
|
18270
|
-
};
|
|
18271
|
-
var claudeSpawnArgs = (cwd, selector, dir) => {
|
|
18272
|
-
const choice = chooseSpawnModel(cwd, selector, "claude_code", {}, claudeAgentModel, dir);
|
|
18273
|
-
if (!choice.model)
|
|
18274
|
-
return null;
|
|
18275
|
-
const effort = choice.effort?.toLowerCase() ?? null;
|
|
18276
|
-
return {
|
|
18277
|
-
model: choice.model,
|
|
18278
|
-
effort: effort && CLAUDE_EFFORTS.has(effort) ? effort : null
|
|
18276
|
+
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."}`
|
|
18279
18277
|
};
|
|
18280
18278
|
};
|
|
18281
18279
|
var CLAUDE_SPAWNS = [
|
|
18282
|
-
...
|
|
18283
|
-
label:
|
|
18280
|
+
...MODEL_TIERS.map((tier) => ({
|
|
18281
|
+
label: `workit:implementer ${tier}`,
|
|
18284
18282
|
selector: { role: "implementer", tier }
|
|
18285
18283
|
})),
|
|
18286
|
-
|
|
18287
|
-
|
|
18284
|
+
...["verifier", "reviewer", "decider"].map((role) => ({
|
|
18285
|
+
label: `workit:${role}`,
|
|
18286
|
+
selector: { role }
|
|
18287
|
+
})),
|
|
18288
|
+
{ label: "workit:babysitter", selector: { role: "babysit" } },
|
|
18288
18289
|
{ label: "Explore", selector: { role: "explore" } },
|
|
18289
|
-
{ label: "ROLE: decider", selector: { role: "decider" } },
|
|
18290
|
-
{ label: "ROLE: babysit", selector: { role: "babysit" } },
|
|
18291
18290
|
{ label: "general-purpose", selector: { role: "default" } }
|
|
18292
18291
|
];
|
|
18293
18292
|
var claudeSpawnTable = (cwd, dir) => {
|
|
18294
18293
|
const rows = CLAUDE_SPAWNS.flatMap(({ label, selector }) => {
|
|
18295
|
-
const
|
|
18296
|
-
|
|
18294
|
+
const want = resolveRoleModel(cwd, selector, "claude_code", dir);
|
|
18295
|
+
const model = want && want.source !== "built-in" ? claudeAgentModel(want.model) : null;
|
|
18296
|
+
const effort = want?.effort?.toLowerCase();
|
|
18297
|
+
const file = label.startsWith("workit:") ? CLAUDE_AGENT_FILES[selector.role] : undefined;
|
|
18298
|
+
return model && (model !== file?.model || effort !== file.effort) ? [`${label} ${model}${effort ? `/${effort}` : ""}`] : [];
|
|
18297
18299
|
});
|
|
18298
|
-
return
|
|
18300
|
+
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.`;
|
|
18301
|
+
};
|
|
18302
|
+
var uniformImplementerModel = (cwd, host, dir) => {
|
|
18303
|
+
const tiers = MODEL_TIERS.map((tier) => resolveRoleModel(cwd, { role: "implementer", tier }, host, dir));
|
|
18304
|
+
const [first] = tiers;
|
|
18305
|
+
return first && tiers.every((t) => t?.model === first.model && t.effort === first.effort) ? first : null;
|
|
18299
18306
|
};
|
|
18300
18307
|
var ROLE_SELECTORS = MODEL_ROLES.flatMap((role) => role === "implementer" ? MODEL_TIERS.map((tier) => ({ role, tier })) : [{ role }]);
|
|
18301
|
-
var AGENT_ROLE = /^(?:workit[:-])?(decider|implementer|verifier|reviewer|explore|babysit)
|
|
18308
|
+
var AGENT_ROLE = /^(?:workit[:-])?(decider|implementer|verifier|reviewer|explore|babysit)(?:(?<=babysit)ter)?$/iu;
|
|
18302
18309
|
var ROLE_LINE = /^[ \t]*ROLE:[ \t]*(decider|implementer|verifier|reviewer|explore|babysit)\b/imu;
|
|
18303
18310
|
var TIER_LINE = /^[ \t]*TIER:[ \t]*(mundane|standard|hard)\b/imu;
|
|
18304
18311
|
var isBrief = (text) => TIER_LINE.test(text) && /^WORKTREE:/mu.test(text);
|
|
@@ -18577,7 +18584,7 @@ var exportDigest = (bundle) => sha256({
|
|
|
18577
18584
|
});
|
|
18578
18585
|
// packages/workit-core/src/core/route-intent.ts
|
|
18579
18586
|
import { spawnSync as spawnSync17 } from "node:child_process";
|
|
18580
|
-
import { existsSync as
|
|
18587
|
+
import { existsSync as existsSync12 } from "node:fs";
|
|
18581
18588
|
import path30 from "node:path";
|
|
18582
18589
|
|
|
18583
18590
|
// packages/workit-core/src/hooks/raw-git.ts
|
|
@@ -18588,6 +18595,7 @@ import os6 from "node:os";
|
|
|
18588
18595
|
import path29 from "node:path";
|
|
18589
18596
|
|
|
18590
18597
|
// packages/workit-core/src/autonomy.ts
|
|
18598
|
+
import { closeSync as closeSync2, copyFileSync as copyFileSync2, existsSync as existsSync11, openSync as openSync2 } from "node:fs";
|
|
18591
18599
|
import path27 from "node:path";
|
|
18592
18600
|
|
|
18593
18601
|
// packages/workit-core/src/core/eval-world.ts
|
|
@@ -18684,12 +18692,36 @@ function checkSeal(dir) {
|
|
|
18684
18692
|
}
|
|
18685
18693
|
|
|
18686
18694
|
// packages/workit-core/src/autonomy.ts
|
|
18687
|
-
var
|
|
18695
|
+
var accountHomeDir = () => {
|
|
18688
18696
|
const home = grantsHome.resolve();
|
|
18689
18697
|
return home === null ? null : configDir({ HOME: home });
|
|
18690
18698
|
};
|
|
18691
|
-
var
|
|
18699
|
+
var deniedFile = (dir) => {
|
|
18700
|
+
for (const name of ["workspaces.json", SEAL_FILE]) {
|
|
18701
|
+
const file = path27.join(dir, name);
|
|
18702
|
+
try {
|
|
18703
|
+
closeSync2(openSync2(file, "r"));
|
|
18704
|
+
} catch (error) {
|
|
18705
|
+
const code = error.code;
|
|
18706
|
+
if (code === "EACCES" || code === "EPERM")
|
|
18707
|
+
return file;
|
|
18708
|
+
}
|
|
18709
|
+
}
|
|
18710
|
+
return null;
|
|
18711
|
+
};
|
|
18712
|
+
var accountDir = () => {
|
|
18713
|
+
const dir = accountHomeDir();
|
|
18714
|
+
return dir === null || deniedFile(dir) !== null ? null : dir;
|
|
18715
|
+
};
|
|
18716
|
+
var grantsDir = () => accountHomeDir() ?? resolveConfigDir();
|
|
18692
18717
|
var NO_ACCOUNT = "no OS account record answered (core/account-home.ts), so no grants are read: the D4 defaults apply";
|
|
18718
|
+
var accountUnread = () => {
|
|
18719
|
+
const dir = accountHomeDir();
|
|
18720
|
+
if (dir === null)
|
|
18721
|
+
return NO_ACCOUNT;
|
|
18722
|
+
const file = deniedFile(dir);
|
|
18723
|
+
return file === null ? null : `the account's ${path27.basename(file)} cannot be read (permission denied), so it reads as no workspace entries: no grants, no models, the D4 defaults apply`;
|
|
18724
|
+
};
|
|
18693
18725
|
var entriesIn = (dir) => dir === null ? [] : loadWorkspacesFrom(dir);
|
|
18694
18726
|
var fileSource = (dir = accountDir()) => ({
|
|
18695
18727
|
resolve: (cwd, name) => dir === null ? null : resolveWorkspaceFrom(cwd, dir, name),
|
|
@@ -18749,7 +18781,7 @@ var benchWorld = (cwd) => {
|
|
|
18749
18781
|
var grantsOverride = () => {
|
|
18750
18782
|
const shown = shownGrantsDir();
|
|
18751
18783
|
if (shown === null)
|
|
18752
|
-
return NO_ACCOUNT;
|
|
18784
|
+
return accountUnread() ?? NO_ACCOUNT;
|
|
18753
18785
|
const configured = path27.resolve(resolveConfigDir());
|
|
18754
18786
|
return configured === path27.resolve(shown) ? null : `the config directory is redirected to ${configured} (WORKIT_CONFIG, WORKIT_CONFIG_DIR or XDG_CONFIG_HOME), but that override does not apply to grants: grants are read only from ${path27.join(grantsDir(), "workspaces.json")}, and under a redirect they never exceed the D4 defaults`;
|
|
18755
18787
|
};
|
|
@@ -18918,9 +18950,10 @@ function capAt(source, named, where, by, why, main = false) {
|
|
|
18918
18950
|
}
|
|
18919
18951
|
function resolveAutonomy(cwd, target) {
|
|
18920
18952
|
const world = benchWorld(cwd);
|
|
18953
|
+
const unread = world ? null : accountUnread();
|
|
18954
|
+
if (unread !== null)
|
|
18955
|
+
return { ...autonomyOf(null), note: unread };
|
|
18921
18956
|
const override = world ? null : grantsOverride();
|
|
18922
|
-
if (override === NO_ACCOUNT)
|
|
18923
|
-
return { ...autonomyOf(null), note: override };
|
|
18924
18957
|
let resolved;
|
|
18925
18958
|
const once = typeof target === "function" ? () => resolved ??= target() : target;
|
|
18926
18959
|
const account = accountAuthority(cwd, world, once);
|
|
@@ -19019,9 +19052,9 @@ function capAtRemotes(source, autonomy, cwd, target) {
|
|
|
19019
19052
|
return capped;
|
|
19020
19053
|
}
|
|
19021
19054
|
var grantsMatter = (kind) => {
|
|
19022
|
-
|
|
19023
|
-
if (override === NO_ACCOUNT)
|
|
19055
|
+
if (accountUnread() !== null)
|
|
19024
19056
|
return false;
|
|
19057
|
+
const override = grantsOverride();
|
|
19025
19058
|
const entries = entriesIn(accountDir());
|
|
19026
19059
|
const matters = entries.some((entry) => {
|
|
19027
19060
|
const autonomy = autonomyOf(entry);
|
|
@@ -21599,7 +21632,7 @@ var judgedDir = (root, dir) => {
|
|
|
21599
21632
|
if (dir === null)
|
|
21600
21633
|
return root;
|
|
21601
21634
|
const resolved = path30.resolve(root, dir);
|
|
21602
|
-
return
|
|
21635
|
+
return existsSync12(resolved) && inWorkitWorkspace(resolved) ? resolved : null;
|
|
21603
21636
|
};
|
|
21604
21637
|
var shellBranchPolicyViolation = (root, command, dialect = "posix") => {
|
|
21605
21638
|
let judged = false;
|
|
@@ -23595,7 +23628,7 @@ class WorkitCore {
|
|
|
23595
23628
|
}
|
|
23596
23629
|
// packages/workit-core/src/core/repo-context.ts
|
|
23597
23630
|
import { spawnSync as spawnSync18 } from "node:child_process";
|
|
23598
|
-
import { existsSync as
|
|
23631
|
+
import { existsSync as existsSync13, readFileSync as readFileSync11, readdirSync as readdirSync4 } from "node:fs";
|
|
23599
23632
|
import path31 from "node:path";
|
|
23600
23633
|
var isSafeContextRange = (value) => value.length <= 4096 && (() => {
|
|
23601
23634
|
try {
|
|
@@ -23777,7 +23810,7 @@ var diffStatForRange = (cwd, range) => {
|
|
|
23777
23810
|
};
|
|
23778
23811
|
var packageScripts = (cwd, keys) => {
|
|
23779
23812
|
const pkgPath = path31.join(cwd, "package.json");
|
|
23780
|
-
if (!
|
|
23813
|
+
if (!existsSync13(pkgPath))
|
|
23781
23814
|
return [];
|
|
23782
23815
|
try {
|
|
23783
23816
|
const pkg = JSON.parse(readFileSync11(pkgPath, "utf8"));
|
|
@@ -23812,7 +23845,7 @@ var documentationFiles = (cwd) => {
|
|
|
23812
23845
|
return matches.toSorted().slice(0, 200);
|
|
23813
23846
|
};
|
|
23814
23847
|
var readTrimmed2 = (file, maxLines) => {
|
|
23815
|
-
if (!
|
|
23848
|
+
if (!existsSync13(file))
|
|
23816
23849
|
return "";
|
|
23817
23850
|
const lines = readFileSync11(file, "utf8").split(`
|
|
23818
23851
|
`);
|
|
@@ -23888,7 +23921,7 @@ ${status.stderr}` : "");
|
|
|
23888
23921
|
stdout += `
|
|
23889
23922
|
`;
|
|
23890
23923
|
stdout += printSection("Recent Validation Signals");
|
|
23891
|
-
if (
|
|
23924
|
+
if (existsSync13(path31.join(cwd, "package.json"))) {
|
|
23892
23925
|
stdout += `package.json detected. Common scripts:
|
|
23893
23926
|
`;
|
|
23894
23927
|
const found = packageScripts(cwd, ["lint", "format:check", "test", "build"]);
|
|
@@ -23897,7 +23930,7 @@ ${status.stderr}` : "");
|
|
|
23897
23930
|
`) + `
|
|
23898
23931
|
`;
|
|
23899
23932
|
}
|
|
23900
|
-
if (
|
|
23933
|
+
if (existsSync13(path31.join(cwd, "Cargo.toml")) || existsSync13(path31.join(cwd, "src-tauri/Cargo.toml"))) {
|
|
23901
23934
|
stdout += `Rust project detected.
|
|
23902
23935
|
`;
|
|
23903
23936
|
}
|
|
@@ -23949,7 +23982,7 @@ function changelogContext(root, range) {
|
|
|
23949
23982
|
`;
|
|
23950
23983
|
stdout += printSection("Existing CHANGELOG.md");
|
|
23951
23984
|
const changelogPath = path31.join(cwd, "CHANGELOG.md");
|
|
23952
|
-
if (
|
|
23985
|
+
if (existsSync13(changelogPath)) {
|
|
23953
23986
|
stdout += readTrimmed2(changelogPath, 260) + `
|
|
23954
23987
|
`;
|
|
23955
23988
|
} else {
|
|
@@ -23991,7 +24024,7 @@ function docsRefreshContext(root, range) {
|
|
|
23991
24024
|
`;
|
|
23992
24025
|
stdout += printSection("README Preview");
|
|
23993
24026
|
const readme = path31.join(cwd, "README.md");
|
|
23994
|
-
if (
|
|
24027
|
+
if (existsSync13(readme)) {
|
|
23995
24028
|
stdout += readTrimmed2(readme, 220) + `
|
|
23996
24029
|
`;
|
|
23997
24030
|
} else {
|
|
@@ -24000,7 +24033,7 @@ function docsRefreshContext(root, range) {
|
|
|
24000
24033
|
}
|
|
24001
24034
|
stdout += printSection("Package Scripts");
|
|
24002
24035
|
const pkgPath = path31.join(cwd, "package.json");
|
|
24003
|
-
if (
|
|
24036
|
+
if (existsSync13(pkgPath)) {
|
|
24004
24037
|
try {
|
|
24005
24038
|
const pkg = JSON.parse(readFileSync11(pkgPath, "utf8"));
|
|
24006
24039
|
stdout += JSON.stringify({ name: pkg.name, version: pkg.version, scripts: pkg.scripts }, null, 2) + `
|
|
@@ -24056,7 +24089,7 @@ function releaseNotesContext(root, rangeOrTag) {
|
|
|
24056
24089
|
`;
|
|
24057
24090
|
stdout += printSection("Existing Release Files");
|
|
24058
24091
|
for (const rel of ["CHANGELOG.md", "RELEASE_NOTES.md", ".github/releases.md"]) {
|
|
24059
|
-
if (
|
|
24092
|
+
if (existsSync13(path31.join(cwd, rel)))
|
|
24060
24093
|
stdout += rel + `
|
|
24061
24094
|
`;
|
|
24062
24095
|
}
|
|
@@ -24793,7 +24826,7 @@ function resolveInside(root, candidate) {
|
|
|
24793
24826
|
throw new Error("path must stay inside repository root");
|
|
24794
24827
|
}
|
|
24795
24828
|
let ancestor = target;
|
|
24796
|
-
while (!
|
|
24829
|
+
while (!existsSync14(ancestor))
|
|
24797
24830
|
ancestor = path35.dirname(ancestor);
|
|
24798
24831
|
const canonicalAncestor = realpathSync9(ancestor);
|
|
24799
24832
|
if (canonicalAncestor !== base && !canonicalAncestor.startsWith(base + path35.sep)) {
|
|
@@ -26001,7 +26034,7 @@ function heavyGate(cwd, command, options) {
|
|
|
26001
26034
|
}
|
|
26002
26035
|
// packages/workit-core/src/hooks/write-gate.ts
|
|
26003
26036
|
import {
|
|
26004
|
-
existsSync as
|
|
26037
|
+
existsSync as existsSync15,
|
|
26005
26038
|
readdirSync as readdirSync5,
|
|
26006
26039
|
readFileSync as readFileSync12,
|
|
26007
26040
|
readlinkSync as readlinkSync3,
|
|
@@ -26713,7 +26746,7 @@ var linkSources = (args, at) => {
|
|
|
26713
26746
|
const sources = names.filter((name, index) => into >= 0 ? name !== dest : index < names.length - 1 || names.length === 1);
|
|
26714
26747
|
const target = dest === undefined ? null : at(dest);
|
|
26715
26748
|
const symbolic = args.some((arg) => /^-[a-zA-Z]*s|^--symbolic$/.test(arg));
|
|
26716
|
-
const base = target === null ? null : into >= 0 || sources.length > 1 ||
|
|
26749
|
+
const base = target === null ? null : into >= 0 || sources.length > 1 || existsSync15(target) || /[\\/]$/.test(dest ?? "") ? target : path41.dirname(target);
|
|
26717
26750
|
return sources.flatMap((source) => {
|
|
26718
26751
|
if (symbolic && base !== null && !path41.isAbsolute(homeExpanded(source)))
|
|
26719
26752
|
return [path41.resolve(base, source)];
|
|
@@ -29576,7 +29609,7 @@ if (false) {}
|
|
|
29576
29609
|
import path49 from "node:path";
|
|
29577
29610
|
|
|
29578
29611
|
// packages/workit-core/src/core/gitignore.ts
|
|
29579
|
-
import { existsSync as
|
|
29612
|
+
import { existsSync as existsSync16, readFileSync as readFileSync13, writeFileSync as writeFileSync5 } from "node:fs";
|
|
29580
29613
|
import path45 from "node:path";
|
|
29581
29614
|
var GITIGNORE_ENTRIES = [
|
|
29582
29615
|
"# workit: SDD working state (never commit)",
|
|
@@ -29598,7 +29631,7 @@ var ensureProjectGitignore = (workspaceRoot, confirmed) => {
|
|
|
29598
29631
|
if (!confirmed)
|
|
29599
29632
|
return { ok: false, error: "confirmed: true required" };
|
|
29600
29633
|
const file = path45.join(workspaceRoot, ".gitignore");
|
|
29601
|
-
const existing =
|
|
29634
|
+
const existing = existsSync16(file) ? readFileSync13(file, "utf8") : "";
|
|
29602
29635
|
const existingLines = new Set(existing.split(`
|
|
29603
29636
|
`).map((l) => l.trim()).filter(Boolean));
|
|
29604
29637
|
const added = [];
|
|
@@ -29617,19 +29650,19 @@ var ensureProjectGitignore = (workspaceRoot, confirmed) => {
|
|
|
29617
29650
|
` : "") + append.join(`
|
|
29618
29651
|
`) + `
|
|
29619
29652
|
`, "utf8");
|
|
29620
|
-
} else if (!
|
|
29653
|
+
} else if (!existsSync16(file)) {
|
|
29621
29654
|
writeFileSync5(file, "", "utf8");
|
|
29622
29655
|
}
|
|
29623
29656
|
return { ok: true, path: file, added };
|
|
29624
29657
|
};
|
|
29625
29658
|
|
|
29626
29659
|
// packages/workit-core/src/core/hygiene.ts
|
|
29627
|
-
import { existsSync as
|
|
29660
|
+
import { existsSync as existsSync17, readFileSync as readFileSync14, readdirSync as readdirSync6, writeFileSync as writeFileSync6 } from "node:fs";
|
|
29628
29661
|
import path46 from "node:path";
|
|
29629
29662
|
var repoRoot3 = assetRoot();
|
|
29630
29663
|
var templatesDir = () => path46.join(repoRoot3, "templates", "hygiene");
|
|
29631
29664
|
var packageJson = (root) => {
|
|
29632
|
-
if (!
|
|
29665
|
+
if (!existsSync17(path46.join(root, "package.json")))
|
|
29633
29666
|
return null;
|
|
29634
29667
|
try {
|
|
29635
29668
|
return JSON.parse(readFileSync14(path46.join(root, "package.json"), "utf8"));
|
|
@@ -29638,7 +29671,7 @@ var packageJson = (root) => {
|
|
|
29638
29671
|
}
|
|
29639
29672
|
};
|
|
29640
29673
|
var isOpenSource = (root) => {
|
|
29641
|
-
if (
|
|
29674
|
+
if (existsSync17(path46.join(root, "LICENSE")))
|
|
29642
29675
|
return true;
|
|
29643
29676
|
const pkg = packageJson(root);
|
|
29644
29677
|
if (pkg && !pkg.private)
|
|
@@ -29666,10 +29699,10 @@ var planHygieneFiles = (root, opts = {}) => {
|
|
|
29666
29699
|
files.push("LICENSE", "CONTRIBUTING.md");
|
|
29667
29700
|
const planned = [];
|
|
29668
29701
|
for (const file of files) {
|
|
29669
|
-
if (
|
|
29702
|
+
if (existsSync17(path46.join(root, file)))
|
|
29670
29703
|
continue;
|
|
29671
29704
|
const tpl = path46.join(templatesDir(), file);
|
|
29672
|
-
if (!
|
|
29705
|
+
if (!existsSync17(tpl))
|
|
29673
29706
|
continue;
|
|
29674
29707
|
const content = readFileSync14(tpl, "utf8").replace(/<PROJECT>/g, path46.basename(root)).replace(/<YEAR>/g, String(new Date().getFullYear())).replace(/<HOLDER>\s*/g, licenseHolder(root));
|
|
29675
29708
|
planned.push({ path: path46.join(root, file), content });
|
|
@@ -30418,7 +30451,7 @@ import path53 from "node:path";
|
|
|
30418
30451
|
|
|
30419
30452
|
// packages/workit-core/src/git/ops.ts
|
|
30420
30453
|
import { spawnSync as spawnSync27 } from "node:child_process";
|
|
30421
|
-
import { copyFileSync as
|
|
30454
|
+
import { copyFileSync as copyFileSync3, existsSync as existsSync18, readdirSync as readdirSync7, readFileSync as readFileSync16, rmSync as rmSync4 } from "node:fs";
|
|
30422
30455
|
import path52 from "node:path";
|
|
30423
30456
|
var COMMIT_TIMEOUT_MS = 10 * 60000;
|
|
30424
30457
|
var git5 = (cwd, args, options = {}) => {
|
|
@@ -30456,11 +30489,11 @@ function operationInProgress(cwd) {
|
|
|
30456
30489
|
const conflicted = () => git5(cwd, ["ls-files", "-u"]).stdout.trim() !== "";
|
|
30457
30490
|
for (const [index, [, operation]] of markers.entries()) {
|
|
30458
30491
|
const marker = found[index];
|
|
30459
|
-
if (!marker || !
|
|
30492
|
+
if (!marker || !existsSync18(marker))
|
|
30460
30493
|
continue;
|
|
30461
|
-
if (index === 1 &&
|
|
30494
|
+
if (index === 1 && existsSync18(path52.join(marker, "applying")))
|
|
30462
30495
|
return { operation: "am", commitAllowed: false, branch: null };
|
|
30463
|
-
if (index === 0 &&
|
|
30496
|
+
if (index === 0 && existsSync18(path52.join(marker, "amend")) && !conflicted()) {
|
|
30464
30497
|
let headName = "";
|
|
30465
30498
|
try {
|
|
30466
30499
|
headName = readFileSync16(path52.join(marker, "head-name"), "utf8").trim();
|
|
@@ -31989,6 +32022,237 @@ var injectSkillNudge = (root, session, messages, system) => {
|
|
|
31989
32022
|
} catch {}
|
|
31990
32023
|
};
|
|
31991
32024
|
|
|
32025
|
+
// packages/workit-opencode/src/v2/agents.ts
|
|
32026
|
+
import { unwatchFile, watchFile } from "node:fs";
|
|
32027
|
+
|
|
32028
|
+
// packages/workit-claude-code/agents/babysitter.md
|
|
32029
|
+
var babysitter_default = "---\nname: babysitter\ndescription: 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.\nmodel: haiku\n---\n\nYou are the workit babysitter for one PR. Follow the workit-ship skill\n(`/workit:ship`): its babysit loop is your job.\n\n1. Work only in the checkout or worktree your prompt names, on the PR's own\n branch; never in another branch. Run Workit against it, one verb per call:\n `workit pr status --cwd <worktree> --json`, `workit check --cwd <worktree> <name>`,\n `workit git --cwd <worktree> commit …`.\n2. Act on `babysit` in `workit pr status --json`: wait, fix a red check at its\n root (reproduce it with `workit check` first), answer each unresolved thread,\n or stop at the endpoint your prompt names (`ready` by default).\n3. Merge only when your prompt or the grant says `merged`; never force-push,\n rebase or retarget unless your prompt says so.\n4. A fix you cannot make in one round, a product choice, or a check that stays\n red after one fix: stop and report it.\n\nBefore your final report, wait for or stop every background command you started\n(the host shows you running while one lives); never report with one still running.\n\nReport: the PR, its head SHA and endpoint, each check and thread you acted on,\nand anything left for the lead.\n";
|
|
32030
|
+
|
|
32031
|
+
// packages/workit-claude-code/agents/decider.md
|
|
32032
|
+
var decider_default = `---
|
|
32033
|
+
name: decider
|
|
32034
|
+
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.
|
|
32035
|
+
model: fable
|
|
32036
|
+
effort: high
|
|
32037
|
+
tools: Read, Grep, Glob, Bash, Skill
|
|
32038
|
+
disallowedTools: Write, Edit, NotebookEdit
|
|
32039
|
+
---
|
|
32040
|
+
|
|
32041
|
+
You are the workit decider. You wrote none of the work and change none of it:
|
|
32042
|
+
you read, decide and report. Follow the workit-fanout skill
|
|
32043
|
+
(\`/workit:fanout\`, "Stuck calls: the decider").
|
|
32044
|
+
|
|
32045
|
+
1. Read the dispute itself: the brief or acceptance, the diff
|
|
32046
|
+
(\`git -C <worktree> diff <base>...HEAD\`), the failed findings and the
|
|
32047
|
+
author's answer, and \`workit ledger list --type decision\`.
|
|
32048
|
+
2. List the real options (two or three), each with what it costs if wrong.
|
|
32049
|
+
3. Pick one by reversibility: the option cheapest to undo wins a tie.
|
|
32050
|
+
4. Give the exact change list for the pick: file, what changes, and the check
|
|
32051
|
+
that proves it, so the fixer applies it once.
|
|
32052
|
+
|
|
32053
|
+
A product choice, or authority nobody here has, is not yours: say so and name
|
|
32054
|
+
the question for the user. The lead records your pick with
|
|
32055
|
+
\`workit ledger decision\`; you record nothing.
|
|
32056
|
+
|
|
32057
|
+
Before your final report, wait for or stop every background command you started
|
|
32058
|
+
(the host shows you running while one lives); never report with one still running.
|
|
32059
|
+
|
|
32060
|
+
Never commit, push, merge or edit. Write only in your session's scratchpad.
|
|
32061
|
+
`;
|
|
32062
|
+
|
|
32063
|
+
// packages/workit-claude-code/agents/implementer.md
|
|
32064
|
+
var implementer_default = `---
|
|
32065
|
+
name: implementer
|
|
32066
|
+
description: Implements one scoped workit brief in the git worktree its lead made with \`workit fanout worktree create\`, and reports what changed and how it was checked. Use to delegate a well-defined slice (goal, scope, acceptance, verify, forbidden, report, worktree) so it can run in parallel with other work.
|
|
32067
|
+
model: sonnet
|
|
32068
|
+
---
|
|
32069
|
+
|
|
32070
|
+
You are a workit implementer. You work only in the git worktree your brief
|
|
32071
|
+
names (its WORKTREE line), which the lead made with
|
|
32072
|
+
\`workit fanout worktree create <slice>\` before spawning you; never in the
|
|
32073
|
+
lead's checkout.
|
|
32074
|
+
|
|
32075
|
+
Refuse to start without a complete brief. It must state: goal, scope (files
|
|
32076
|
+
or areas you may touch), acceptance (observable outcomes), verify (exact
|
|
32077
|
+
commands), timebox, forbidden (what you must not touch or do), report (what to
|
|
32078
|
+
hand back), standing orders, mode (\`new\` or \`resume\`) and the worktree path.
|
|
32079
|
+
If a field is missing, report which and stop.
|
|
32080
|
+
|
|
32081
|
+
1. In a Workit worktree (the default), run each git and check command against
|
|
32082
|
+
it, one verb per call:
|
|
32083
|
+
\`workit git --cwd <worktree> commit …\`, \`workit check --cwd <worktree> <name>\`
|
|
32084
|
+
(verb first, so the host's allow rules match).
|
|
32085
|
+
Never \`cd <worktree> && …\` chains, \`$VAR\` paths or compound commands. Edit
|
|
32086
|
+
files by their path under the worktree. Workit's hooks deny an edit or a
|
|
32087
|
+
mutating git command outside it.
|
|
32088
|
+
2. The worktree is already on the brief's branch. If it is not: \`MODE: new\`,
|
|
32089
|
+
\`workit git --cwd <worktree> branch <branch> --base <base>\`; \`MODE: resume\`
|
|
32090
|
+
(you replace a stopped worker), \`git -C <worktree> switch <branch>\` and
|
|
32091
|
+
continue from its head. A hook denies protected or non-compliant names;
|
|
32092
|
+
follow the unblock it prints.
|
|
32093
|
+
3. Stay inside the scope. Anything outside it is a follow-up in the report,
|
|
32094
|
+
not a diff. Follow the workit-implement skill (\`/workit:implement\`).
|
|
32095
|
+
4. Decide ambiguities yourself and record them:
|
|
32096
|
+
\`workit ledger ruling "<what>" --why "<why>" --cost-if-wrong "<cost>"\`.
|
|
32097
|
+
Stop only for an irreversible or security-sensitive action, or a side effect
|
|
32098
|
+
outside your worktree.
|
|
32099
|
+
5. Commit in small steps with
|
|
32100
|
+
\`workit git --cwd <worktree> commit -m "<conventional message>" -- <paths in scope>\`.
|
|
32101
|
+
Add Co-Authored-By in the same commit with
|
|
32102
|
+
\`workit git commit --trailer "Co-Authored-By: <name> <email>" -- <paths>\`
|
|
32103
|
+
(the brief's RULES give your host's exact line), never by amending.
|
|
32104
|
+
6. Run every verify command as \`workit check --cwd <worktree> …\` and keep the
|
|
32105
|
+
real exit codes.
|
|
32106
|
+
7. Never record a verdict on your own work and never pass \`--self\`: a separate
|
|
32107
|
+
verifier judges it. Never push, open a PR, rebase or merge unless the brief
|
|
32108
|
+
says so.
|
|
32109
|
+
|
|
32110
|
+
In a Claude Code host-isolated worktree (\`.claude/worktrees/agent-<id>\`,
|
|
32111
|
+
whose SubagentStart text says "Run git as plain") the rule flips: run git as
|
|
32112
|
+
plain commands there, never \`workit git …\` (Claude Code's isolation refuses a
|
|
32113
|
+
git wrapper), and keep workit for \`check\`, \`ledger\` and \`pr\`.
|
|
32114
|
+
|
|
32115
|
+
Before your final report, wait for or stop every background command you started
|
|
32116
|
+
(the host shows you running while one lives); never report with one still running.
|
|
32117
|
+
|
|
32118
|
+
Report: worktree, branch and head SHA, files changed, each verify command with
|
|
32119
|
+
its exit code, each acceptance item met or not, rulings recorded, and any
|
|
32120
|
+
deviation from the brief.
|
|
32121
|
+
`;
|
|
32122
|
+
|
|
32123
|
+
// packages/workit-claude-code/agents/reviewer.md
|
|
32124
|
+
var reviewer_default = `---
|
|
32125
|
+
name: reviewer
|
|
32126
|
+
description: Fresh-context reviewer for a workit branch or PR - spec fidelity and standards as separate axes, test quality and blast radius - that records findings and a non-author verdict. Use for independent review of a diff, branch or PR.
|
|
32127
|
+
model: opus
|
|
32128
|
+
tools: Read, Grep, Glob, Bash, Skill
|
|
32129
|
+
disallowedTools: Write, Edit, NotebookEdit
|
|
32130
|
+
---
|
|
32131
|
+
|
|
32132
|
+
You are the workit reviewer. Review the real candidate, not the author's
|
|
32133
|
+
account. Follow the workit-review skill (\`/workit:review\`).
|
|
32134
|
+
|
|
32135
|
+
1. Pin the candidate: \`git rev-parse HEAD\`, the base, \`git diff <base>...HEAD\`;
|
|
32136
|
+
for a PR, \`workit pr status --json\` (checks, unresolved threads).
|
|
32137
|
+
2. Read the intent: brief or acceptance, spec, PR body, and
|
|
32138
|
+
\`workit ledger list --type decision\`.
|
|
32139
|
+
3. Judge two axes separately: spec fidelity (missing, creep, wrong; quote the
|
|
32140
|
+
line) and standards (repo rules first, then smells). Then test quality
|
|
32141
|
+
(\`workit test-audit --diff\`) and blast radius: one fact plus one proof per
|
|
32142
|
+
touched contract or caller, run with \`workit check -- <cmd>\`; label anything
|
|
32143
|
+
unproven UNPROVEN.
|
|
32144
|
+
4. Each finding: file:line, severity (blocker, major, minor, nit), evidence
|
|
32145
|
+
(hunk, test or output), concrete fix.
|
|
32146
|
+
5. Record the verdict:
|
|
32147
|
+
start from the exact verdict command the SubagentStart hook gave you (it
|
|
32148
|
+
carries your session and \`--token=<token>\`; the token is yours alone: never put it in a report); it names \`--kind review\`:
|
|
32149
|
+
\`workit ledger verdict verified|failed|blocked --cwd <candidate worktree> --kind review --branch <b> --session <id> --token=<token> --how "<what you read and ran>"\`
|
|
32150
|
+
(\`verified\`: no blocker or major left).
|
|
32151
|
+
Record a design choice as \`workit ledger ruling\`.
|
|
32152
|
+
|
|
32153
|
+
Before your final report, wait for or stop every background command you started
|
|
32154
|
+
(the host shows you running while one lives); never report with one still running.
|
|
32155
|
+
|
|
32156
|
+
Never commit, push, merge or edit. Write only in the candidate
|
|
32157
|
+
worktree's \`.workit-scratch/\` or your session's scratchpad: test cases go into files there via a quoted heredoc
|
|
32158
|
+
(\`<<'EOF'\`), never run by the shell. A \`node -e\` or \`python3 -c\` that only reads runs anywhere. If the ledger refuses you as an author, report that instead of a verdict.
|
|
32159
|
+
`;
|
|
32160
|
+
|
|
32161
|
+
// packages/workit-claude-code/agents/verifier.md
|
|
32162
|
+
var verifier_default = `---
|
|
32163
|
+
name: verifier
|
|
32164
|
+
description: Independently verifies a workit candidate (branch, commit or PR) on its real surface and records a SHA-keyed verdict in the ledger. Use after an implementer finishes and before shipping, never on work this session authored.
|
|
32165
|
+
model: sonnet
|
|
32166
|
+
tools: Read, Grep, Glob, Bash, Skill
|
|
32167
|
+
disallowedTools: Write, Edit, NotebookEdit
|
|
32168
|
+
---
|
|
32169
|
+
|
|
32170
|
+
You are the workit verifier. You did not write the candidate and never
|
|
32171
|
+
change it: you observe, judge and record. Work backward from the goal: what
|
|
32172
|
+
must be true, exist and be wired. The author's summary is a claim:
|
|
32173
|
+
the goal is unmet until you observe it.
|
|
32174
|
+
|
|
32175
|
+
1. Pin the candidate in its own checkout (run workit as
|
|
32176
|
+
\`workit <verb> --cwd <worktree> …\`, verb first; never \`cd\` first): \`git -C <worktree> rev-parse HEAD\` and \`git -C <worktree> status --short\`. A dirty tree
|
|
32177
|
+
or a moving HEAD is a finding; the ledger refuses a verdict on it.
|
|
32178
|
+
2. Read the brief: goal, acceptance (Given/When/Then), verify commands.
|
|
32179
|
+
3. Run every verify command through the CLI:
|
|
32180
|
+
\`workit check <name>\` for configured checks, \`workit check -- <cmd>\` for the
|
|
32181
|
+
rest. Never substitute an easier command. Run every configured check by name
|
|
32182
|
+
(your SubagentStart context lists them) or cite green CI on that head, else \`verified\` is refused.
|
|
32183
|
+
4. Drive the real surface with the project's \`verify-<app>\` skill when it
|
|
32184
|
+
exists (\`/workit:verify-app\` generates one). Tests alone are unit evidence.
|
|
32185
|
+
5. Judge each acceptance line met, not met or not verifiable, citing what
|
|
32186
|
+
you observed. Label every claim measured, inferred or guess.
|
|
32187
|
+
6. Record the verdict, then report it:
|
|
32188
|
+
start from the exact verdict command the SubagentStart hook put in your context (it
|
|
32189
|
+
carries your session and \`--token=<token>\`; you share the lead's
|
|
32190
|
+
\`WORKIT_SESSION_ID\`, which authored the work) and pick its \`--kind <live|unit>\`:
|
|
32191
|
+
\`workit ledger verdict verified|tests-verified|type-check-only|failed|blocked --cwd <candidate worktree> --kind <live|unit> --branch <b> --session <id> --token=<token> --how "<what you ran and saw>"\`.
|
|
32192
|
+
\`verified\` means the change was seen working on its real surface
|
|
32193
|
+
(verify-<app>, \`--kind live\`); \`tests-verified\` means only tests ran. If the ledger refuses you as an author, report that;
|
|
32194
|
+
never pass \`--self\`.
|
|
32195
|
+
|
|
32196
|
+
Before your final report, wait for or stop every background command you started
|
|
32197
|
+
(the host shows you running while one lives); never report with one still running.
|
|
32198
|
+
|
|
32199
|
+
Write only in the candidate worktree's \`.workit-scratch/\` or your session's
|
|
32200
|
+
scratchpad: a test case goes in a file there via a quoted heredoc (\`<<'EOF'\`),
|
|
32201
|
+
never run by the shell. Reads (\`git fetch -q origin\`, a \`node -e\` or \`python3 -c\`
|
|
32202
|
+
that only reads) run anywhere.
|
|
32203
|
+
|
|
32204
|
+
Report: candidate SHA, each check with its exit code, each acceptance line,
|
|
32205
|
+
the verdict row you recorded. Fix nothing: a failing check is a verdict.
|
|
32206
|
+
`;
|
|
32207
|
+
|
|
32208
|
+
// packages/workit-opencode/src/v2/agents.ts
|
|
32209
|
+
var OPENCODE_AGENTS = [
|
|
32210
|
+
{ id: "workit-implementer", role: "implementer", markdown: implementer_default, readOnly: false },
|
|
32211
|
+
{ id: "workit-verifier", role: "verifier", markdown: verifier_default, readOnly: true },
|
|
32212
|
+
{ id: "workit-reviewer", role: "reviewer", markdown: reviewer_default, readOnly: true },
|
|
32213
|
+
{ id: "workit-decider", role: "decider", markdown: decider_default, readOnly: true },
|
|
32214
|
+
{ id: "workit-babysitter", role: "babysit", markdown: babysitter_default, readOnly: false }
|
|
32215
|
+
];
|
|
32216
|
+
var opencodeAgentModel = (value) => {
|
|
32217
|
+
const match = /^([^\s/#]+)\/([^\s#]+)(?:#(\S+))?$/u.exec(value.trim());
|
|
32218
|
+
if (!match)
|
|
32219
|
+
return null;
|
|
32220
|
+
const [, providerID, id, variant] = match;
|
|
32221
|
+
return variant ? { providerID, id, variant } : { providerID, id };
|
|
32222
|
+
};
|
|
32223
|
+
var opencodeAgentText = (markdown) => {
|
|
32224
|
+
const match = /^---\r?\n([\s\S]*?)\r?\n---\r?\n([\s\S]*)$/u.exec(markdown);
|
|
32225
|
+
const description = /^description:\s*(.+)$/mu.exec(match?.[1] ?? "")?.[1].trim() ?? "";
|
|
32226
|
+
const system = (match?.[2] ?? markdown).trim().replace(/\n\nIn a Claude Code host-isolated worktree[\s\S]*?(?=\n\n)/u, "").replace(/\(`\/workit:([a-z-]+)`\)/gu, "(call the skill tool with `workit-$1`)").replace(/`\/workit:([a-z-]+)`/gu, "`workit-$1`").replace(/\(it\s+carries your session and `--token=<token>`;[^)]*\)/gu, "(it names no --session or --token: your shell already acts as your own session)").replaceAll(" --session <id> --token=<token>", "");
|
|
32227
|
+
return { description, system };
|
|
32228
|
+
};
|
|
32229
|
+
var roleModel = (root, role) => role === "implementer" ? uniformImplementerModel(root, "opencode") : resolveAvailableRoleModel(root, { role }, "opencode");
|
|
32230
|
+
var registerRoleAgents = (root, editor) => {
|
|
32231
|
+
for (const agent of OPENCODE_AGENTS) {
|
|
32232
|
+
const { description, system } = opencodeAgentText(agent.markdown);
|
|
32233
|
+
const configured = roleModel(root, agent.role);
|
|
32234
|
+
const model = configured ? opencodeAgentModel(configured.model) : null;
|
|
32235
|
+
editor.update(agent.id, (info) => {
|
|
32236
|
+
info.description = description;
|
|
32237
|
+
info.system = system;
|
|
32238
|
+
info.mode = "subagent";
|
|
32239
|
+
if (model)
|
|
32240
|
+
info.model = model;
|
|
32241
|
+
if (agent.readOnly)
|
|
32242
|
+
info.permissions.push({ action: "edit", resource: "*", effect: "deny" });
|
|
32243
|
+
});
|
|
32244
|
+
}
|
|
32245
|
+
};
|
|
32246
|
+
var installRoleAgents = async (root, agents) => {
|
|
32247
|
+
if (!agents?.transform)
|
|
32248
|
+
return () => {};
|
|
32249
|
+
await agents.transform((editor) => registerRoleAgents(root, editor));
|
|
32250
|
+
const file = workspacesPath();
|
|
32251
|
+
const reload = () => void agents.reload?.().catch(() => {});
|
|
32252
|
+
watchFile(file, { interval: 2000, persistent: false }, reload);
|
|
32253
|
+
return () => unwatchFile(file, reload);
|
|
32254
|
+
};
|
|
32255
|
+
|
|
31992
32256
|
// packages/workit-opencode/src/v2/spawn-model.ts
|
|
31993
32257
|
var opencodeSubagentModel = (value) => {
|
|
31994
32258
|
const trimmed = value.trim();
|
|
@@ -32005,6 +32269,9 @@ var applySpawnModel = (root, event, notes) => {
|
|
|
32005
32269
|
if (!selector)
|
|
32006
32270
|
return;
|
|
32007
32271
|
const choice = chooseSpawnModel(root, selector, "opencode", { model: fields.model }, opencodeSubagentModel);
|
|
32272
|
+
const agentModel = typeof fields.agent === "string" && fields.agent.startsWith("workit-") && selector.role !== "implementer" ? resolveRoleModels(root, selector, "opencode")[0]?.model : undefined;
|
|
32273
|
+
if (choice.model && choice.model === agentModel)
|
|
32274
|
+
return;
|
|
32008
32275
|
if (choice.model)
|
|
32009
32276
|
fields.model = choice.model;
|
|
32010
32277
|
if (choice.note)
|
|
@@ -32107,11 +32374,11 @@ var createStopControl = (root, port) => {
|
|
|
32107
32374
|
};
|
|
32108
32375
|
|
|
32109
32376
|
// packages/workit-opencode/src/v2/registry.ts
|
|
32110
|
-
import { existsSync as
|
|
32377
|
+
import { existsSync as existsSync20, readFileSync as readFileSync17 } from "node:fs";
|
|
32111
32378
|
import path57 from "node:path";
|
|
32112
32379
|
|
|
32113
32380
|
// packages/workit-opencode/src/shared/assets.ts
|
|
32114
|
-
import { existsSync as
|
|
32381
|
+
import { existsSync as existsSync19, realpathSync as realpathSync13 } from "node:fs";
|
|
32115
32382
|
import path56 from "node:path";
|
|
32116
32383
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
32117
32384
|
var moduleDir = () => {
|
|
@@ -32128,7 +32395,7 @@ var packageRoot2 = () => {
|
|
|
32128
32395
|
path56.resolve(dir, "..", ".."),
|
|
32129
32396
|
path56.resolve(dir, "..", "..", "..")
|
|
32130
32397
|
]) {
|
|
32131
|
-
if (
|
|
32398
|
+
if (existsSync19(path56.join(candidate, "package.json")))
|
|
32132
32399
|
return candidate;
|
|
32133
32400
|
}
|
|
32134
32401
|
return path56.resolve(dir, "..");
|
|
@@ -32136,7 +32403,7 @@ var packageRoot2 = () => {
|
|
|
32136
32403
|
var skillsRoot = () => {
|
|
32137
32404
|
const root = packageRoot2();
|
|
32138
32405
|
const canonical = path56.resolve(root, "..", "workit-core", "skills");
|
|
32139
|
-
if (
|
|
32406
|
+
if (existsSync19(path56.join(root, "src")) && existsSync19(canonical))
|
|
32140
32407
|
return canonical;
|
|
32141
32408
|
return path56.join(root, "assets", "skills");
|
|
32142
32409
|
};
|
|
@@ -32162,7 +32429,7 @@ var parseFrontmatter = (markdown) => {
|
|
|
32162
32429
|
};
|
|
32163
32430
|
var registerSkills = async (ctx) => {
|
|
32164
32431
|
const skillsDir = skillsRoot();
|
|
32165
|
-
if (!
|
|
32432
|
+
if (!existsSync20(skillsDir))
|
|
32166
32433
|
return new Set;
|
|
32167
32434
|
const listed = await ctx.skill.list().catch(() => ({ data: [] }));
|
|
32168
32435
|
const own = (skill) => typeof skill.path === "string" && path57.resolve(skill.path).startsWith(skillsDir + path57.sep);
|
|
@@ -32170,7 +32437,7 @@ var registerSkills = async (ctx) => {
|
|
|
32170
32437
|
const packaged = new Map;
|
|
32171
32438
|
for (const id of WORKIT_METHOD_SKILLS) {
|
|
32172
32439
|
const file = path57.join(skillsDir, id, "SKILL.md");
|
|
32173
|
-
if (!userSkills.has(id) &&
|
|
32440
|
+
if (!userSkills.has(id) && existsSync20(file))
|
|
32174
32441
|
packaged.set(id, file);
|
|
32175
32442
|
}
|
|
32176
32443
|
await ctx.skill.transform((editor) => {
|
|
@@ -32216,11 +32483,11 @@ var registerCommands = async (ctx, registeredSkills) => {
|
|
|
32216
32483
|
};
|
|
32217
32484
|
|
|
32218
32485
|
// packages/workit-opencode/src/stale-sources.ts
|
|
32219
|
-
import { existsSync as
|
|
32486
|
+
import { existsSync as existsSync21, readdirSync as readdirSync8 } from "node:fs";
|
|
32220
32487
|
import path58 from "node:path";
|
|
32221
32488
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
32222
32489
|
var typescriptFiles = (directory) => {
|
|
32223
|
-
if (!
|
|
32490
|
+
if (!existsSync21(directory))
|
|
32224
32491
|
return [];
|
|
32225
32492
|
return readdirSync8(directory, { withFileTypes: true }).flatMap((entry) => {
|
|
32226
32493
|
const file = path58.join(directory, entry.name);
|
|
@@ -32234,10 +32501,10 @@ var pluginSourceFiles = [
|
|
|
32234
32501
|
path58.join(packageRoot2(), "..", "workit-core", "src", "core.ts"),
|
|
32235
32502
|
...typescriptFiles(path58.join(packageRoot2(), "..", "workit-core", "src", "core"))
|
|
32236
32503
|
])
|
|
32237
|
-
].filter((file) =>
|
|
32504
|
+
].filter((file) => existsSync21(file)).toSorted();
|
|
32238
32505
|
|
|
32239
32506
|
// packages/workit-core/src/core/cli-locate.ts
|
|
32240
|
-
import { closeSync as
|
|
32507
|
+
import { closeSync as closeSync3, existsSync as existsSync22, openSync as openSync3, readSync } from "node:fs";
|
|
32241
32508
|
import path59 from "node:path";
|
|
32242
32509
|
var LAUNCHER_MARKER = "workit-owned-launcher";
|
|
32243
32510
|
var CLI_PACKAGE_PATH = ["node_modules", "@workit-dev", "cli"];
|
|
@@ -32252,7 +32519,7 @@ var ownedCurrentEntry = (env, platform = process.platform) => path59.join(instal
|
|
|
32252
32519
|
var head = (file) => {
|
|
32253
32520
|
let fd;
|
|
32254
32521
|
try {
|
|
32255
|
-
fd =
|
|
32522
|
+
fd = openSync3(file, "r");
|
|
32256
32523
|
const buffer = Buffer.alloc(256);
|
|
32257
32524
|
const read = readSync(fd, buffer, 0, buffer.length, 0);
|
|
32258
32525
|
return buffer.subarray(0, read).toString("utf8");
|
|
@@ -32260,13 +32527,13 @@ var head = (file) => {
|
|
|
32260
32527
|
return "";
|
|
32261
32528
|
} finally {
|
|
32262
32529
|
if (fd !== undefined)
|
|
32263
|
-
|
|
32530
|
+
closeSync3(fd);
|
|
32264
32531
|
}
|
|
32265
32532
|
};
|
|
32266
32533
|
var locateWorkitCli = (options = {}) => {
|
|
32267
32534
|
const env = options.env ?? process.env;
|
|
32268
32535
|
const platform = options.platform ?? process.platform;
|
|
32269
|
-
const exists = options.exists ??
|
|
32536
|
+
const exists = options.exists ?? existsSync22;
|
|
32270
32537
|
const read = options.read ?? head;
|
|
32271
32538
|
const node = options.node ?? process.execPath;
|
|
32272
32539
|
const launcher = ownedLauncherPath(env, platform);
|
|
@@ -32455,6 +32722,7 @@ var setup = async (ctx) => {
|
|
|
32455
32722
|
});
|
|
32456
32723
|
}
|
|
32457
32724
|
});
|
|
32725
|
+
const stopRoleAgents = await installRoleAgents(root, ctx.agent);
|
|
32458
32726
|
const shellWorkdirs = new Map;
|
|
32459
32727
|
const pendingShells = new Map;
|
|
32460
32728
|
const spawnNotes = new Map;
|
|
@@ -32570,6 +32838,7 @@ var setup = async (ctx) => {
|
|
|
32570
32838
|
})();
|
|
32571
32839
|
return () => {
|
|
32572
32840
|
subscription.abort();
|
|
32841
|
+
stopRoleAgents();
|
|
32573
32842
|
};
|
|
32574
32843
|
};
|
|
32575
32844
|
var definition = define({ id: "workit", setup });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workit-dev/opencode",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.14.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Workit OpenCode plugin — native tools, adaptive policy, and sixteen method skills",
|
|
6
6
|
"keywords": [
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@opencode/plugin": "2.0.18",
|
|
44
|
-
"@workit-dev/core": "^2.
|
|
44
|
+
"@workit-dev/core": "^2.14.0"
|
|
45
45
|
},
|
|
46
46
|
"engines": {
|
|
47
47
|
"node": ">=24"
|