@workit-dev/opencode 1.5.0 → 1.6.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.
Files changed (2) hide show
  1. package/dist/plugin.js +89 -65
  2. package/package.json +2 -2
package/dist/plugin.js CHANGED
@@ -16677,12 +16677,11 @@ function checkVerdictsOnce(cwd, branch, ledgerRows) {
16677
16677
  }
16678
16678
  return reasons;
16679
16679
  };
16680
- const retired = new Set;
16680
+ const voided = verdictVoids(rows, { chained: true });
16681
+ const retired = new Set(voided.keys());
16681
16682
  for (const row of rows)
16682
- if (row.type === "verdict" && row.supersedes && !row.supersedeIgnored && trustReasons(cwd, row).length === 0)
16683
+ if (row.type === "verdict" && row.supersedes && !row.supersedeIgnored && !voided.has(row.id) && trustReasons(cwd, row).length === 0)
16683
16684
  retired.add(row.supersedes);
16684
- for (const id of verdictVoids(rows, { chained: true }).keys())
16685
- retired.add(id);
16686
16685
  const byKind = new Map;
16687
16686
  for (const row of rows.toSorted(byRank))
16688
16687
  if (isLiveVerdict(row, retired) && scope(row)) {
@@ -24514,7 +24513,8 @@ var WORKIT_USER_ONLY = [
24514
24513
  ["release", "notes", "approve"],
24515
24514
  ["grant", "set"],
24516
24515
  ["grant", "raise"],
24517
- ["ledger", "void"]
24516
+ ["ledger", "void"],
24517
+ ["approve"]
24518
24518
  ];
24519
24519
  var ALLOWED = new Set(WORKIT_ALLOWED_VERBS);
24520
24520
  var hasWordsInOrder = (words, needle) => {
@@ -26306,7 +26306,12 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
26306
26306
  };
26307
26307
  for (const segment of segments) {
26308
26308
  if (segment.group === "open") {
26309
- groups.push({ dir, stack: [...stack], vars: new Map(vars), loops: new Map(loops) });
26309
+ groups.push({
26310
+ dir,
26311
+ stack: [...stack],
26312
+ vars: new Map(vars),
26313
+ loops: new Map(loops)
26314
+ });
26310
26315
  continue;
26311
26316
  }
26312
26317
  if (segment.group === "close") {
@@ -26514,39 +26519,60 @@ var claimAll = (owner, targets, deps) => {
26514
26519
  claimLiveSession(target, owner, deps);
26515
26520
  };
26516
26521
  var liveTargets = (cwd, paths) => paths?.length ? paths.map((file) => path39.resolve(cwd, file)) : [path39.join(cwd, DIR_TARGET)];
26517
- var issuedTarget = (cwd, targets) => {
26522
+ var registryTarget = (cwd, targets) => {
26518
26523
  const state = resolveStateDir();
26519
- const found = targets.find((target) => underIssued(state, cwd, homeExpanded(target), process.platform, canonical3));
26520
- return found ?? null;
26524
+ for (const target of targets) {
26525
+ const registry = underRegistry(state, cwd, homeExpanded(target), process.platform, canonical3);
26526
+ if (registry)
26527
+ return { file: target, registry };
26528
+ }
26529
+ return null;
26521
26530
  };
26522
- var underIssued = (state, cwd, target, platform = process.platform, real = (file) => file) => {
26531
+ var underRegistry = (state, cwd, target, platform = process.platform, real = (file) => file) => {
26523
26532
  const win = platform === "win32";
26524
26533
  const p = win ? path39.win32 : path39.posix;
26525
26534
  const fold = (value) => win || platform === "darwin" ? value.toLowerCase() : value;
26526
26535
  const named = win ? target.replace(/^\/([a-zA-Z])(?=\/|$)/, "$1:") : target;
26527
26536
  const relative = p.relative(fold(real(p.resolve(state))), fold(real(p.resolve(cwd, named))));
26528
26537
  if (relative.startsWith("..") || p.isAbsolute(relative))
26529
- return false;
26530
- return relative.split(p.sep)[0].startsWith("issued");
26538
+ return null;
26539
+ const first = relative.split(p.sep)[0];
26540
+ if (first.startsWith("issued"))
26541
+ return "issued";
26542
+ return first === "approvals" ? "approvals" : null;
26531
26543
  };
26532
- var unquotedWindowsIssued = (command) => {
26544
+ var unquotedWindowsRegistry = (command) => {
26533
26545
  if (process.platform !== "win32" || !command.includes("\\"))
26534
- return false;
26546
+ return null;
26535
26547
  const flat = (value) => value.replaceAll("\\", "/").toLowerCase();
26536
- return flat(command).includes(`${flat(resolveStateDir())}/issued`) && shellWrites(command).writes;
26548
+ const text = flat(command);
26549
+ const state = flat(resolveStateDir());
26550
+ const registry = text.includes(`${state}/issued`) ? "issued" : text.includes(`${state}/approvals`) ? "approvals" : null;
26551
+ return registry && shellWrites(command).writes ? registry : null;
26552
+ };
26553
+ var REGISTRY_DENY = {
26554
+ issued: {
26555
+ label: "issued-registry guard",
26556
+ unblock: "Issued ids and tokens are written only by Workit's SubagentStart hook. Run the verifier or reviewer agent so the host issues its own session; never edit the issued registries by hand."
26557
+ },
26558
+ approvals: {
26559
+ label: "approvals guard",
26560
+ unblock: "Approval requests and the user's yes are written only by Workit: run `workit approve <id>` as its own call so the host asks the user, or ask the user to run it in their own terminal; never edit the approvals registry by hand."
26561
+ }
26537
26562
  };
26538
- var issuedDeny = (file) => {
26539
- const unblock = "Issued ids and tokens are written only by Workit's SubagentStart hook. Run the verifier or reviewer agent so the host issues its own session; never edit the issued registries by hand.";
26563
+ var registryDeny = ({ file, registry }) => {
26564
+ const { label, unblock } = REGISTRY_DENY[registry];
26565
+ const what = registry === "issued" ? "issued-session state" : "host-approval state";
26540
26566
  return {
26541
26567
  kind: "deny",
26542
- reason: `workit issued-registry guard: ${file} is under Workit's issued-session state. ${unblock}`,
26568
+ reason: `workit ${label}: ${file} is under Workit's ${what}. ${unblock}`,
26543
26569
  unblock
26544
26570
  };
26545
26571
  };
26546
26572
  function writeGate(cwd, paths, owner, deps) {
26547
- const forged = paths?.length ? issuedTarget(cwd, paths) : null;
26573
+ const forged = paths?.length ? registryTarget(cwd, paths) : null;
26548
26574
  if (forged)
26549
- return issuedDeny(forged);
26575
+ return registryDeny(forged);
26550
26576
  if (!owner)
26551
26577
  return beforeWriteGate(cwd, paths);
26552
26578
  const targets = liveTargets(cwd, paths);
@@ -26560,9 +26586,10 @@ function writeGate(cwd, paths, owner, deps) {
26560
26586
  }
26561
26587
  function shellGate(cwd, command, owner, dialect = "posix", deps) {
26562
26588
  try {
26563
- const forged = issuedTarget(cwd, segmentTargets(cwd, command, dialect)) ?? (unquotedWindowsIssued(command) ? "the issued registry" : null);
26589
+ const windows = unquotedWindowsRegistry(command);
26590
+ const forged = registryTarget(cwd, segmentTargets(cwd, command, dialect)) ?? (windows ? { file: `the ${windows} registry`, registry: windows } : null);
26564
26591
  if (forged)
26565
- return issuedDeny(forged);
26592
+ return registryDeny(forged);
26566
26593
  } catch {}
26567
26594
  const writes = shellWrites(command);
26568
26595
  let targets = [];
@@ -26959,40 +26986,37 @@ var SKILL_HOST = {
26959
26986
  };
26960
26987
  var PROMPT_INTENTS = [
26961
26988
  [
26962
- "workit-debug",
26963
- /\b(flaky|regressed|(?:is|introduced) a regression|regression (?:in|after|since|from)|(?:is|are|got|looks) broken|debug (?:this|it|the|why)|fix (?:the|this|a) bug)\b/i
26964
- ],
26965
- [
26966
- "workit-continue",
26967
- /\b(pick up where|where (?:were|did) we|resume (?:the|this|my|our|work|where)|hand ?off)\b/i
26989
+ "debug",
26990
+ /\b(flaky|regressed|(is|introduced) a regression|regression (in|after|since|from)|(is|are|got|looks) broken|debug (this|it|the|why)|fix (the|this|a) bug)\b/i
26968
26991
  ],
26969
26992
  [
26970
- "workit-review",
26971
- /\b(blast radius|code review|review (?:the|this|my|PR|pr|#\d+|branch|diff|changes))\b/i
26993
+ "continue",
26994
+ /\b(pick up where|where (were|did) we|resume (the|this|my|our|work|where)|hand ?off)\b/i
26972
26995
  ],
26973
26996
  [
26974
- "workit-ship",
26975
- /\b(ship (?:it|this|the)|babysit|open (?:a|the) (?:PR|pr|MR|mr)(?=\s*$|\s+(?:for|to|on|with|and|against|into|from|after|once)\b|[.!,;])|merge (?:the|this|my) (?:PR|pr|MR|mr|branch)|(?:get|until|make) CI (?:is )?green)\b/i
26997
+ "review",
26998
+ /\b(blast radius|code review|review (the|this|my|PR|pr|#\d+|branch|diff|changes))\b/i
26976
26999
  ],
26977
- ["workit-bdd", /\b(BDD|TDD|acceptance criteria|Given\/When\/Then)(?![\w/])/],
26978
- ["workit-test-audit", /\b(test audit|audit the tests|tautolog\w*|weak tests)\b/i],
26979
- ["workit-deslop", /\b(deslop|slop|dead code)\b/i],
26980
27000
  [
26981
- "workit-fanout",
26982
- /\b(fan(?: |-)?out|parallelize|parallel agents|agent swarm|swarm of agents)\b/i
27001
+ "ship",
27002
+ /\b(ship (it|this|the)|babysit|open (a|the) (PR|pr|MR|mr)(?=\s*$|\s+(for|to|on|with|and|against|into|from|after|once)\b|[.!,;])|merge (the|this|my) (PR|pr|MR|mr|branch)|(get|until|make) CI (is )?green)\b/i
26983
27003
  ],
26984
- ["workit-verify-app", /\b(verify the app|smoke test|prove it works)\b/i],
26985
- ["workit-retro", /\b((?:a|the) retro(?![-\w]|\.\w)|retrospective)/i],
26986
- ["workit-architecture", /\b(deepen (?:the )?modules|architecture (?:review|pass|audit))\b/i],
27004
+ ["bdd", /\b(BDD|TDD|acceptance criteria|Given\/When\/Then)(?![\w/])/],
27005
+ ["test-audit", /\b(test audit|audit the tests|tautolog\w*|weak tests)\b/i],
27006
+ ["deslop", /\b(deslop|slop|dead code)\b/i],
27007
+ ["fanout", /\b(fan( |-)?out|parallelize|parallel agents|agent swarm|swarm of agents)\b/i],
27008
+ ["verify-app", /\b(verify the app|smoke test|prove it works)\b/i],
27009
+ ["retro", /\b((a|the) retro(?![-\w]|\.\w)|retrospective)/i],
27010
+ ["architecture", /\b(deepen (the )?modules|architecture (review|pass|audit))\b/i],
26987
27011
  [
26988
- "workit-shape",
26989
- /\b(brainstorm\w*|grill me|should we|let'?s plan|plan (?:out|how|the|a|for)|(?:write|draft) (?:a|the) spec)\b/i
27012
+ "shape",
27013
+ /\b(brainstorm\w*|grill me|should we|let'?s plan|plan (out|how|the|a|for)|(write|draft) (a|the) spec)\b/i
26990
27014
  ],
26991
27015
  [
26992
- "workit-implement",
26993
- /\b(implement (?:the|this|a|it)|add (?:a|the) feature|build (?:a|an|the) (?:new )?(?:feature|command|verb|page|endpoint|component|cli|tool))\b/i
27016
+ "implement",
27017
+ /\b(implement (the|this|a|it)|add (a|the) feature|build (a|an|the) (new )?(feature|command|verb|page|endpoint|component|cli|tool))\b/i
26994
27018
  ]
26995
- ];
27019
+ ].map(([name, pattern]) => [`workit-${name}`, pattern]);
26996
27020
  var workitSkillOf = (name) => {
26997
27021
  const bare = name.trim().replace(/^\//, "").toLowerCase();
26998
27022
  const alias = WORKIT_SKILL_ALIASES[bare];
@@ -27001,10 +27025,13 @@ var workitSkillOf = (name) => {
27001
27025
  const skill = bare.replace(/^workit:/, "workit-");
27002
27026
  return WORKIT_METHOD_SKILLS.includes(skill) ? skill : null;
27003
27027
  };
27028
+ var QUOTED = /```[\s\S]*?```|["`“][^"`”\n]*["`”]|\B'[^'\n]*'\B/g;
27029
+ var COMPLAINT = /\b(why \w+ you|you keep|stop \w+ing)\b.*?(?=\b(and|but)\b|[?.,;\n]|$)/gi;
27004
27030
  var promptTrigger = (prompt) => {
27005
- const text = prompt.replace(/```[\s\S]*?```/g, " ").slice(0, 4000);
27031
+ let asking = false;
27032
+ const text = prompt.slice(0, 4000).replace(QUOTED, " ").replace(COMPLAINT, (clause) => (asking ||= /ask|quest/i.test(clause), " "));
27006
27033
  for (const [skill, pattern] of PROMPT_INTENTS) {
27007
- const match = pattern.exec(text);
27034
+ const match = !(asking && skill === "workit-shape") && pattern.exec(text);
27008
27035
  if (match)
27009
27036
  return { skill, trigger: match[1] ?? match[0] };
27010
27037
  }
@@ -27020,19 +27047,7 @@ var loadedSkills = (cwd, session) => {
27020
27047
  loaded.add(row.skill);
27021
27048
  return loaded;
27022
27049
  };
27023
- var READERS = new Set([
27024
- "cat",
27025
- "sed",
27026
- "head",
27027
- "tail",
27028
- "less",
27029
- "more",
27030
- "bat",
27031
- "nl",
27032
- "get-content",
27033
- "gc",
27034
- "type"
27035
- ]);
27050
+ var READERS = new Set("cat sed head tail less more bat nl get-content gc type".split(" "));
27036
27051
  function recordSkillLoad(input, name, via) {
27037
27052
  try {
27038
27053
  const skill = workitSkillOf(name);
@@ -27070,9 +27085,9 @@ var nudgeOnce = (input, session, skill, line) => {
27070
27085
  writeSessionMarker(file, { ...marker, nudged: [...marker.nudged, skill] });
27071
27086
  return line;
27072
27087
  };
27073
- var nudgeText = (input, skill, why) => USER_INVOKED.has(skill) ? `Workit: ${why} looks like ${skill} work, which the user starts; offer it (/${skill.replace(/^workit-/, "wk-")}) rather than loading it.` : `Workit: ${why} looks like ${skill} work; if it is, ${skillLoadWording(SKILL_HOST[input.host], skill)} first.`;
27088
+ var nudgeText = (input, skill, why) => `Workit: ${why} looks like ${skill} work${USER_INVOKED.has(skill) ? `, which the user starts; offer it (/${skill.replace(/^workit-/, "wk-")}) rather than loading it.` : `; if it is, ${skillLoadWording(SKILL_HOST[input.host], skill)} first.`}`;
27074
27089
  var promptLoads = (prompt) => /^\s*\/(?:skill:)?([\w:-]+)/.exec(prompt)?.[1] ?? /^\s*<skill name="([\w:-]+)"/.exec(prompt)?.[1] ?? /^\s*Load the (workit-[a-z-]+) skill with the skill tool\b/.exec(prompt)?.[1] ?? null;
27075
- var relayedMessage = (prompt) => /^\s*(?:Another Claude session sent a message\b|<agent-message\s+from=|\[SYSTEM NOTIFICATION\b|<task-notification>)/.test(prompt);
27090
+ var relayedMessage = (prompt) => /^\s*(Another Claude session sent a message\b|<agent-message\s+from=|\[SYSTEM NOTIFICATION\b|<task-notification>)/.test(prompt);
27076
27091
  function promptNudge(input, prompt) {
27077
27092
  try {
27078
27093
  const session = input.session.id;
@@ -27091,7 +27106,7 @@ function promptNudge(input, prompt) {
27091
27106
  return null;
27092
27107
  }
27093
27108
  }
27094
- var WORKIT_DELIVERY = /^(?:pr (?:create|merge)|ci wait|git push)\b/;
27109
+ var WORKIT_DELIVERY = /^(pr (create|merge)|ci wait|git push)\b/;
27095
27110
  var runsWorkitDelivery = (command, dialect) => workitInvocations(command, dialect).some((args) => !args.some((arg) => arg === "--help" || arg === "-h" || arg === "--dry-run") && WORKIT_DELIVERY.test(args.join(" ")));
27096
27111
  var isDeliveryCommand = (cwd, command, dialect = "posix") => rawDelivery(cwd, command, dialect) || runsWorkitDelivery(command, dialect) && inWorkitWorkspace(cwd);
27097
27112
  function shipNudge(input, command) {
@@ -27143,6 +27158,10 @@ var WRITE_TOOLS = new Set([
27143
27158
  import fs28 from "node:fs";
27144
27159
  import path41 from "node:path";
27145
27160
 
27161
+ // packages/workit-core/src/approvals/store.ts
27162
+ var REQUEST_TTL_MS = 30 * 60000;
27163
+ var GRANT_TTL_MS = 15 * 60000;
27164
+
27146
27165
  // packages/workit-core/src/hooks/hosts/claude-code.ts
27147
27166
  var CLAUDE_CODE_DESCRIPTOR = {
27148
27167
  host: "claude_code",
@@ -27184,7 +27203,11 @@ var CLAUDE_CODE_DESCRIPTOR = {
27184
27203
  maxConcurrency: "undocumented",
27185
27204
  agentPrefix: "workit:"
27186
27205
  },
27187
- provenance: { sessionId: "native", agentIdOnTool: "native", postToolObserve: "native" },
27206
+ provenance: {
27207
+ sessionId: "native",
27208
+ agentIdOnTool: "native",
27209
+ postToolObserve: "native"
27210
+ },
27188
27211
  interaction: { questions: "undocumented", writeBoundary: "partial" },
27189
27212
  stopControl: "native",
27190
27213
  shellAvailable: "native",
@@ -27246,6 +27269,7 @@ var CONTEXT_EVENTS = new Set([
27246
27269
  "PreToolUse",
27247
27270
  "PostToolUse"
27248
27271
  ]);
27272
+ var ASKING_MODES = new Set(["default", "acceptEdits", "plan"]);
27249
27273
 
27250
27274
  // packages/workit-core/src/hooks/hosts/codex.ts
27251
27275
  var CODEX_DESCRIPTOR = {
@@ -28755,7 +28779,7 @@ var DEFAULT_MAX_HOLD_MS = 15 * 60000;
28755
28779
  var SILENT_MS = 5 * 60000;
28756
28780
  var UNITS2 = { "": 1, K: 1024, M: 1024 ** 2, G: 1024 ** 3, T: 1024 ** 4 };
28757
28781
  var START_CACHE = new Map;
28758
- var GRANT_TTL_MS = 2 * 3600000;
28782
+ var GRANT_TTL_MS2 = 2 * 3600000;
28759
28783
  var NOTICE_TTL_MS = 7 * 86400000;
28760
28784
 
28761
28785
  // packages/workit-core/src/stack.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/opencode",
3
- "version": "1.5.0",
3
+ "version": "1.6.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": "^1.5.0"
44
+ "@workit-dev/core": "^1.6.0"
45
45
  },
46
46
  "engines": {
47
47
  "node": ">=24"