@workit-dev/opencode 2.16.1 → 2.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,16 +20,15 @@ units of ~100+ lines each. Coupled work stays with one owner. Workit never spawn
20
20
  PR (`references/orchestration.md`).
21
21
  2. **Record standing orders** (`workit ledger standing add "<order>"`): every
22
22
  user directive all workers share. Directives decay across resumes.
23
- 3. **Brief each worker verbatim**: `workit fanout worktree create <slice>`
24
- (every host), then `workit fanout brief <slice>` (WORKTREE, SCRATCH, rules).
25
- Never hand-edit it; change the plan or the standing orders and render again.
23
+ 3. **Make the worktrees**: `workit fanout worktree create <slice>…` (every host; `--name <plan.json>`
24
+ registers the file) prints per slice its `WORKTREE:` line and the exact spawn, whose prompt points
25
+ the worker at `workit fanout brief <slice> --name <plan>`. Never hand-edit it; change the plan or
26
+ the standing orders. One unplanned slice needs no plan (`--branch <b>` optional).
26
27
  4. **Spawn in a rolling window**, in the background, each in its own worktree:
27
- keep 4-6 in flight and refill from `spawnable` in `workit fanout status` as
28
- each one finishes. Assign before spawn (OpenCode: `workit worker assign`); each prompt carries
29
- the brief, or a pointer: its `WORKER`, `TIER`, `TIMEBOX` and `WORKTREE` lines plus "run `workit fanout brief <slice>` and follow it"
30
- (budget and model hooks read those lines), so batched OpenCode launches each bind their worker.
31
- Model: the brief's `model:` and `effort:` lines (`workit models show`), else TIER (`references/orchestration.md`).
32
- Claude Code: the `implementer` agent; its spawn hook drops `isolation` and refuses a prompt without a WORKTREE line.
28
+ keep 4-6 in flight and refill from `spawnable` in `workit fanout status`.
29
+ Assign before spawn (OpenCode: `workit worker assign`); each prompt is the printed one
30
+ (budget and model hooks read its WORKTREE, WORKER, TIER and TIMEBOX lines), so batched OpenCode launches each bind their worker.
31
+ Claude Code: copy the printed `SPAWN:` args (a model only when the TIER differs from the agent file); the hook drops `isolation` and refuses a prompt naming no Workit worktree with a `Retry as:`.
33
32
  5. **Judge liveness by side effects only:** `workit fanout status` (head age,
34
33
  PR, CI, verdict, landed; STUCK past the TIMEBOX). Stop a stuck worker and
35
34
  observe that it exited (a timeout is not proof); stop a finished one when its
@@ -103,6 +103,27 @@ is the slice's STUCK threshold in `workit fanout status`. `"fanIn":
103
103
  }
104
104
  ```
105
105
 
106
+ ## Worktrees and the spawn they print
107
+
108
+ `workit fanout worktree create a b c` makes each slice's worktree and prints,
109
+ per slice, `WORKTREE: <path>` and the spawn that carries it. Its prompt starts
110
+ with that WORKTREE line, then `WORKER`, `TIER`, `TIMEBOX` and
111
+ "Run `workit fanout brief <slice> --name <plan>` and follow it exactly.";
112
+ Claude Code's `SPAWN:` line names `model` only when the TIER differs from the
113
+ `implementer` agent file. `--name` takes the plan's name or its file (`--plan`
114
+ is the same flag): a file is registered in that call, and a name no plan has
115
+ registers the one file in `workit dir plans` that starts with it. The plan
116
+ check refuses a slice branch the workspace branch policy refuses and names the
117
+ allowed one.
118
+
119
+ One unplanned slice: `workit fanout worktree create fix-login [--branch
120
+ fix/login] [--base <b>] [--tier <t>]` (no plan holds it) records a one-slice plan named after it
121
+ (the lead's prompt states the task) and prints the same lines; two or more
122
+ slices need a plan file. Claude Code's spawn gate passes a
123
+ `workit:implementer` prompt that names a Workit-made worktree as a WORKTREE
124
+ line, as its path, or as a brief file holding a WORKTREE line; otherwise its
125
+ deny is two lines ending in that ad-hoc command as `Retry as:`.
126
+
106
127
  ## Identity and git rules per host
107
128
 
108
129
  `workit fanout brief` renders the identity line, the model lines and RULES 1
@@ -31,7 +31,7 @@ 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
32
  the same check. Fix round and recheck both failed: the decider agent (call the skill tool with `workit-fanout`).
33
33
 
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`).
34
+ 1. **Open.** Last before the PR, if `workit grant show` has `changelog: update|create`: pass the Unreleased entry as `workit pr create … --changelog "<Section>: <entry>"` (it commits and pushes 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`).
36
36
  `workit pr create --title "<title>" --body-file <f|->` refuses a body that leaves a repo template (or `prTemplate: workit`) unfilled; add `--issue <#n|ID>` (`--refs`: no close; `workit pr edit`).
37
37
  YouTrack issue work: `workit youtrack …` (`--help`; the `ytrack` skill for the rest). A draft that needs the user's yes (YouTrack text, release notes, a PR body they asked to review): paste it whole in chat before asking, never only its path, and again after every edit (the verb prints the diff and the new text).
@@ -17,19 +17,23 @@ belongs to). Otherwise:
17
17
  do, not with internals: "Added: `workit pr create --no-changelog <reason>`
18
18
  skips the changelog check with a recorded reason", not "refactor gate
19
19
  module".
20
- 2. Apply it only with `workit changelog apply --entries '{"Added": ["…"]}'`
21
- (categories: Added, Changed, Deprecated, Removed, Fixed, Security), adding
22
- `--path <file>` when the file is not the root CHANGELOG.md. It
23
- merges into `## [Unreleased]` and creates the Keep a Changelog file when it
24
- is missing. Never clobber CHANGELOG.md: never rewrite, reorder or delete an
20
+ 2. Open the PR with the entry in the same call:
21
+ `workit pr create … --changelog "<Section>: <entry>"` (sections: Added,
22
+ Changed, Deprecated, Removed, Fixed, Security). It merges the bullet into
23
+ `## [Unreleased]` of the right file (creating a missing Keep a Changelog
24
+ file), commits it with a subject commitlint accepts, pushes and opens the
25
+ PR. Never clobber CHANGELOG.md: never rewrite, reorder or delete an
25
26
  existing entry, and never hand-edit released sections.
26
- 3. Commit it (`workit git commit -m "<message>" -- <file>`)
27
- with the change, then push.
27
+ 3. With no PR to open yet, apply it alone with
28
+ `workit changelog apply --entries '{"Added": ["…"]}'` (`--path <file>` when
29
+ it is not the root CHANGELOG.md), then commit it
30
+ (`workit git commit -m "<message>" -- <file>`) with the change and push.
28
31
 
29
32
  `workit pr create` refuses a user-facing PR without a new Unreleased bullet
30
- (`changelog_required`) and prints the exact `workit changelog apply` command.
31
- When the PR truly needs no entry, pass `--no-changelog "<why>"`: the reason is
32
- written into the PR body.
33
+ (`changelog_required`); its `Retry as:` line is your call plus
34
+ `--changelog "<Section>: <what users can now do>"`: fill in the entry and run
35
+ it. When the PR truly needs no entry, pass `--no-changelog "<why>"`: the
36
+ reason is written into the PR body.
33
37
 
34
38
  ## Docs (`docs: when-user-facing`)
35
39
 
package/dist/plugin.js CHANGED
@@ -11384,10 +11384,12 @@ function judgeBranch(cwd) {
11384
11384
  const branch = currentBranch(cwd);
11385
11385
  return branch && !isProtectedTarget(cwd, branch) ? branch : null;
11386
11386
  }
11387
+ var shellQuote = (value) => /^[\w@%+=:,./-]+$/u.test(value) ? value : `'${value.replaceAll("'", `'\\''`)}'`;
11387
11388
  function verdictCommand(options) {
11388
11389
  const kind = options.judge === "verifier" ? "<live|unit>" : options.judge === "reviewer" ? "review" : "<live|unit|review>";
11389
11390
  return [
11390
11391
  "workit ledger verdict <verified|failed|blocked>",
11392
+ options.cwd ? `--cwd ${shellQuote(options.cwd)}` : null,
11391
11393
  `--kind ${kind}`,
11392
11394
  `--branch ${options.branch ?? "<branch>"}`,
11393
11395
  options.session ? `--session ${options.session}` : null,
@@ -20827,9 +20829,9 @@ var autocorrected = (name, config) => {
20827
20829
  }
20828
20830
  return tie ? null : best;
20829
20831
  };
20830
- var shellQuote = (word) => `'${word.replaceAll("'", "'\\''")}'`;
20832
+ var shellQuote2 = (word) => `'${word.replaceAll("'", "'\\''")}'`;
20831
20833
  var positional = (script, args) => {
20832
- const word = (arg) => /^[\w./@+:=-]+$/.test(arg) ? arg : shellQuote(arg);
20834
+ const word = (arg) => /^[\w./@+:=-]+$/.test(arg) ? arg : shellQuote2(arg);
20833
20835
  return script.replace(/\$\{?([1-9])\}?/g, (_, n) => word(args[Number(n) - 1] ?? "")).replace(/\$\{?[@*]\}?/g, args.map(word).join(" "));
20834
20836
  };
20835
20837
  var expandGitAliases = (root, invocation, cache = new Map, depth = 0) => {
@@ -20846,7 +20848,7 @@ var expandGitAliases = (root, invocation, cache = new Map, depth = 0) => {
20846
20848
  return corrected ? [{ ...invocation, args: [corrected, ...invocation.args.slice(1)] }] : [invocation];
20847
20849
  }
20848
20850
  const rest = invocation.args.slice(1);
20849
- const expanded = alias.startsWith("!") ? rawInvocations([positional(alias.slice(1), rest), ...rest.map(shellQuote)].join(" ")).map((inner) => ({
20851
+ const expanded = alias.startsWith("!") ? rawInvocations([positional(alias.slice(1), rest), ...rest.map(shellQuote2)].join(" ")).map((inner) => ({
20850
20852
  ...inner,
20851
20853
  dir: rebase(invocation.dir, inner.dir),
20852
20854
  ...inner.tool === "git" && (invocation.config || inner.config) ? { config: [...invocation.config ?? [], ...inner.config ?? []] } : {},
@@ -21173,7 +21175,7 @@ var policyDeclared = () => {
21173
21175
  return false;
21174
21176
  }
21175
21177
  };
21176
- var word = (text) => /^[\w./@%+:,=-]+$/u.test(text) ? text : shellQuote(text);
21178
+ var word = (text) => /^[\w./@%+:,=-]+$/u.test(text) ? text : shellQuote2(text);
21177
21179
  var HEREDOC = /^cat <<(['"])(\w+)\1\n([\s\S]*)\n\2\n?$/u;
21178
21180
  var messageOf = (segment, index) => {
21179
21181
  const text = segment.words[index];
@@ -21257,7 +21259,7 @@ var cdCommitCall = (input, command, target, repo) => {
21257
21259
  }
21258
21260
  return [
21259
21261
  `workit git --cwd ${word(target)} commit`,
21260
- ...messages.map((message) => `-m ${shellQuote(message)}`),
21262
+ ...messages.map((message) => `-m ${shellQuote2(message)}`),
21261
21263
  ...allowEmpty ? ["--allow-empty"] : [],
21262
21264
  all ? "--all" : `-- ${[...new Set(paths)].map(word).join(" ")}`
21263
21265
  ].join(" ");
@@ -25094,6 +25096,7 @@ var isAllowedWorkitCall = (words, expands = []) => {
25094
25096
  return false;
25095
25097
  return !words.slice(0, limit).some(isBypass) && !expands.some((index) => index < limit);
25096
25098
  };
25099
+ var helpOnly = (call, needle) => call.length > needle.length && needle.every((word, index) => call[index] === word) && call.slice(needle.length).every((word) => word === "--help" || word === "-h");
25097
25100
  var userOnlyWorkitCall = (command, dialect = "posix") => {
25098
25101
  if (!mayRunUserOnly(command))
25099
25102
  return null;
@@ -25120,7 +25123,7 @@ var userOnlyWorkitCall = (command, dialect = "posix") => {
25120
25123
  }
25121
25124
  const call = args.slice(at);
25122
25125
  const found = WORKIT_USER_ONLY.find((needle) => call[0] === needle[0] && hasWordsInOrder(call, needle));
25123
- if (found)
25126
+ if (found && !helpOnly(call, found))
25124
25127
  return [...found];
25125
25128
  }
25126
25129
  return null;
@@ -30700,7 +30703,15 @@ import path55 from "node:path";
30700
30703
 
30701
30704
  // packages/workit-core/src/git/ops.ts
30702
30705
  import { spawnSync as spawnSync27 } from "node:child_process";
30703
- import { copyFileSync as copyFileSync3, existsSync as existsSync19, readdirSync as readdirSync7, readFileSync as readFileSync16, rmSync as rmSync4 } from "node:fs";
30706
+ import {
30707
+ copyFileSync as copyFileSync3,
30708
+ existsSync as existsSync19,
30709
+ mkdirSync as mkdirSync6,
30710
+ readdirSync as readdirSync7,
30711
+ readFileSync as readFileSync16,
30712
+ rmSync as rmSync4,
30713
+ writeFileSync as writeFileSync8
30714
+ } from "node:fs";
30704
30715
  import path54 from "node:path";
30705
30716
  var COMMIT_TIMEOUT_MS = 10 * 60000;
30706
30717
  var git5 = (cwd, args, options = {}) => {
@@ -31226,12 +31237,17 @@ function planFinished(cwd, plan, rows) {
31226
31237
  }).landed;
31227
31238
  });
31228
31239
  }
31240
+ var isAdhocPlan = (plan) => plan.slices.length === 1 && plan.slices[0].id === plan.name;
31229
31241
  function selectFanout(cwd, name, current, session = null) {
31230
31242
  if (name) {
31231
31243
  const read = readFanout(cwd, name);
31232
31244
  if (!read.ok)
31233
31245
  return read;
31234
- return read.data ? { ok: true, data: read.data } : fanoutFail("not_found", `no fanout plan named ${name}`, "workit fanout plan <plan.json>");
31246
+ if (read.data)
31247
+ return { ok: true, data: read.data };
31248
+ const names = listFanouts(cwd);
31249
+ const known = names.ok ? names.data.map((plan) => plan.name) : [];
31250
+ return fanoutFail("not_found", `no fanout plan named ${name}${known.length ? ` (registered: ${known.join(", ")})` : " (none is registered)"}`, `workit fanout plan <plan.json>, or pass the plan file as --name <path>/plan.json`, { registered: known });
31235
31251
  }
31236
31252
  const all = listFanouts(cwd);
31237
31253
  if (!all.ok)
@@ -31259,7 +31275,11 @@ function selectFanout(cwd, name, current, session = null) {
31259
31275
  const holding = active(all.data.filter((plan) => plan.slices.some((slice) => slice.branch === current)));
31260
31276
  if (holding.length === 1)
31261
31277
  return { ok: true, data: holding[0] };
31262
- const led = holding.length === 0 && session ? active(all.data.filter((plan) => plan.leadSession === session)) : [];
31278
+ const real = (plans) => {
31279
+ const planned = plans.filter((plan) => !isAdhocPlan(plan));
31280
+ return planned.length ? planned : plans;
31281
+ };
31282
+ const led = holding.length === 0 && session ? real(active(all.data.filter((plan) => plan.leadSession === session))) : [];
31263
31283
  if (led.length === 1)
31264
31284
  return { ok: true, data: led[0] };
31265
31285
  const pool = holding.length > 1 ? holding : led.length > 1 ? led : active(all.data);
@@ -32333,16 +32353,25 @@ names (its WORKTREE line), which the lead made with
32333
32353
  \`workit fanout worktree create <slice>\` before spawning you; never in the
32334
32354
  lead's checkout.
32335
32355
 
32356
+ Your first step: a prompt that points at the brief (its WORKTREE, WORKER, TIER
32357
+ and TIMEBOX lines and \`workit fanout brief <slice> --name <plan>\`) means run
32358
+ that command and follow its text; a prompt that names a brief file means read
32359
+ that file.
32360
+
32336
32361
  Refuse to start without a complete brief. It must state: goal, scope (files
32337
32362
  or areas you may touch), acceptance (observable outcomes), verify (exact
32338
32363
  commands), timebox, forbidden (what you must not touch or do), report (what to
32339
32364
  hand back), standing orders, mode (\`new\` or \`resume\`) and the worktree path.
32340
- If a field is missing, report which and stop.
32365
+ If a field is missing, report which and stop. An unplanned slice
32366
+ (\`fanout worktree create <slice>\` with no plan) has a short brief: the lead's
32367
+ prompt states the task, and its acceptance and verify count as the brief's.
32341
32368
 
32342
32369
  1. In a Workit worktree (the default), run each git and check command against
32343
32370
  it, one verb per call:
32344
32371
  \`workit git --cwd <worktree> commit …\`, \`workit check --cwd <worktree> <name>\`
32345
32372
  (verb first, so the host's allow rules match).
32373
+ Read-only git (\`status\`, \`log\`, \`diff\`, \`show\`) is plain
32374
+ \`git -C <worktree> …\`; \`workit git\` takes branch, commit, stage and push.
32346
32375
  Never \`cd <worktree> && …\` chains, \`$VAR\` paths or compound commands. Edit
32347
32376
  files by their path under the worktree. Workit's hooks deny an edit or a
32348
32377
  mutating git command outside it.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/opencode",
3
- "version": "2.16.1",
3
+ "version": "2.17.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.16.1"
44
+ "@workit-dev/core": "^2.17.0"
45
45
  },
46
46
  "engines": {
47
47
  "node": ">=24"