@workit-dev/opencode 2.4.3 → 2.5.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 +131 -13
  2. package/package.json +2 -2
package/dist/plugin.js CHANGED
@@ -26522,7 +26522,21 @@ var gitOutputs = (args) => {
26522
26522
  if (output !== undefined)
26523
26523
  files.push(output);
26524
26524
  if (sub === "init")
26525
- files.push(names[0] ?? ".");
26525
+ files.push(names[0] ?? "./");
26526
+ if (sub === "init" || sub === "clone") {
26527
+ const separate = valueOf(rest, /^--separate-git-dir=?(.*)$/s);
26528
+ if (separate !== undefined)
26529
+ files.push(separate);
26530
+ }
26531
+ if (sub === "worktree") {
26532
+ const end = rest.includes("--") ? rest.indexOf("--") : rest.length;
26533
+ const named = [
26534
+ ...rest.slice(1, end).filter((arg, index, words) => !arg.startsWith("-") && !/^(?:-[bB]|--reason)$/.test(words[index - 1] ?? "")),
26535
+ ...rest.slice(end + 1)
26536
+ ];
26537
+ const count = { add: 1, move: 2, remove: 1, repair: named.length || 1 }[rest[0] ?? ""] ?? 0;
26538
+ files.push(...(named.length ? named : ["."]).slice(0, count));
26539
+ }
26526
26540
  if (sub === "clone")
26527
26541
  files.push(names[1] ?? names[0]?.replace(/(?:\.git)?[\\/]*$/, "").split(/[\\/:]/).at(-1) ?? ".");
26528
26542
  if (sub === "format-patch" && !has(/^--stdout$/))
@@ -26640,6 +26654,27 @@ var MUTATING_GIT = new Set([
26640
26654
  var DRY_N = new Set(["add", "clean", "rm", "mv"]);
26641
26655
  var MUTATING_WORKIT_GIT = new Set(["commit", "branch", "stage", "unstage"]);
26642
26656
  var DIR_TARGET = ".workit-live-target";
26657
+ var PLACEHOLDERS = new WeakMap;
26658
+ var collecting = null;
26659
+ var placeholderIn = (dir, name) => {
26660
+ const target = path41.join(dir, name);
26661
+ collecting?.add(target);
26662
+ return target;
26663
+ };
26664
+ var recording = (make) => {
26665
+ const outer = collecting;
26666
+ const found = new Set;
26667
+ collecting = found;
26668
+ try {
26669
+ const targets = make();
26670
+ PLACEHOLDERS.set(targets, found);
26671
+ for (const target of found)
26672
+ outer?.add(target);
26673
+ return targets;
26674
+ } finally {
26675
+ collecting = outer;
26676
+ }
26677
+ };
26643
26678
  var OPAQUE_TARGET = ".workit-runs-";
26644
26679
  var UNRESOLVED_TARGET = ".workit-unresolved-target";
26645
26680
  var OVERRIDE = "WORKIT_LIVE_SESSION=override";
@@ -26911,7 +26946,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
26911
26946
  return [unknownVarTarget(home)];
26912
26947
  if (path41.isAbsolute(home))
26913
26948
  return [home];
26914
- return base === undefined ? [] : [path41.resolve(base, home)];
26949
+ return base === undefined ? [] : [resolvedUnder(base, home)];
26915
26950
  });
26916
26951
  const at = (file) => {
26917
26952
  const all = atAll(file);
@@ -27143,7 +27178,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
27143
27178
  for (const file of opaque ?? [])
27144
27179
  for (const resolved of atAll(file))
27145
27180
  if (!quiet || !isRoot(resolved))
27146
- targets.push(file === "." ? path41.join(resolved, here) : resolved);
27181
+ targets.push(file === "." ? placeholderIn(resolved, here) : path41.basename(resolved).startsWith(OPAQUE_TARGET) ? placeholderIn(path41.dirname(resolved), path41.basename(resolved)) : resolved);
27147
27182
  const ln = words.findIndex((word) => /^ln$/i.test(word.split(/[\\/]/).at(-1) ?? ""));
27148
27183
  const lnArgs = words.slice(ln + 1);
27149
27184
  if (ln >= 0 && words.slice(0, ln).every((word) => PREFIXES2.has(word)) && (strict !== "registry" || !lnArgs.some((arg) => /^-[a-zA-Z]*s|^--symbolic$/.test(arg))))
@@ -27155,7 +27190,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
27155
27190
  const edits = editsOf(body);
27156
27191
  if (edits === null) {
27157
27192
  if (dir !== undefined)
27158
- targets.push(path41.join(dir, DIR_TARGET));
27193
+ targets.push(placeholderIn(dir, DIR_TARGET));
27159
27194
  } else
27160
27195
  for (const file of edits)
27161
27196
  targets.push(...atAll(file));
@@ -27163,7 +27198,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
27163
27198
  for (const invocation of workitInvocations(body.map(quoteWord2).join(" "), "posix")) {
27164
27199
  const { at: runsIn, args } = workitCwd(dir, invocation, atAll);
27165
27200
  if (args[0] === "git" && MUTATING_WORKIT_GIT.has(args[1] ?? "") && !inert(args.slice(2), ""))
27166
- targets.push(...runsIn.map((runs) => path41.join(runs, DIR_TARGET)));
27201
+ targets.push(...runsIn.map((runs) => placeholderIn(runs, DIR_TARGET)));
27167
27202
  }
27168
27203
  }
27169
27204
  return targets;
@@ -27183,10 +27218,10 @@ var workitCwd = (dir, args, resolve) => {
27183
27218
  var shellMutationTargets = (cwd, command, dialect = "posix", strict = false) => {
27184
27219
  try {
27185
27220
  const env = new Map(strict === "registry" ? [...command.matchAll(/\$\{?([A-Za-z_]\w*)/g)].filter((match) => !/^(?:OLD)?PWD$/.test(match[1])).map((match) => [match[1], process.env[match[1]] ?? ""]) : []);
27186
- return [
27221
+ return recording(() => [
27187
27222
  ...segmentTargets(cwd, command, dialect, 0, strict, env),
27188
- ...gitMutationDirs(cwd, command, dialect).map((dir) => path41.join(dir, DIR_TARGET))
27189
- ];
27223
+ ...gitMutationDirs(cwd, command, dialect).map((dir) => placeholderIn(dir, DIR_TARGET))
27224
+ ]);
27190
27225
  } catch (error) {
27191
27226
  if (strict === "registry")
27192
27227
  throw error;
@@ -27245,7 +27280,8 @@ var claimAll = (owner, targets, deps) => {
27245
27280
  for (const target of guarded(targets))
27246
27281
  claimLiveSession(target, owner, deps);
27247
27282
  };
27248
- var liveTargets = (cwd, paths) => paths?.length ? paths.map((file) => path41.resolve(cwd, file)) : [path41.join(cwd, DIR_TARGET)];
27283
+ var resolvedUnder = (dir, file) => !/(?:^|[\\/])\.\.(?:[\\/]|$)/.test(file) ? path41.resolve(dir, file) : path41.isAbsolute(file) ? file : `${dir}${path41.sep}${file}`;
27284
+ var liveTargets = (cwd, paths) => recording(() => paths?.length ? paths.map((file) => resolvedUnder(cwd, file)) : [placeholderIn(cwd, DIR_TARGET)]);
27249
27285
  var CONFIG_FILES = ["workspaces.json", SEAL_FILE];
27250
27286
  var configDirs = () => [resolveConfigDir(), grantsDir()];
27251
27287
  var globbed = (cwd, target, state, configs) => {
@@ -28009,6 +28045,19 @@ import path43 from "node:path";
28009
28045
  var REQUEST_TTL_MS = 30 * 60000;
28010
28046
  var GRANT_TTL_MS = 15 * 60000;
28011
28047
  var ASKING_HOSTS = new Set(["claude_code", "pi"]);
28048
+ var INLINE_ASK_TTL_MS = 2 * 60000;
28049
+ var namesTicket = (text) => /WORKIT_APPROVAL_(?:TICKET|UNASKED)/u.test(text.replace(/['"\\]/gu, ""));
28050
+ var TICKET_DENY = "Only the host's prompt adds an approval ticket.";
28051
+
28052
+ // packages/workit-core/src/approvals/youtrack-ask.ts
28053
+ var TIME = "markdown file minutes text date";
28054
+ var FLAGS = {
28055
+ note: TIME,
28056
+ time: TIME,
28057
+ meeting: TIME,
28058
+ update: `${TIME} attach state command`,
28059
+ create: "project summary description file attach command"
28060
+ };
28012
28061
 
28013
28062
  // packages/workit-core/src/hooks/hosts/claude-code.ts
28014
28063
  var CLAUDE_CODE_DESCRIPTOR = {
@@ -28117,7 +28166,7 @@ var CONTEXT_EVENTS = new Set([
28117
28166
  "PreToolUse",
28118
28167
  "PostToolUse"
28119
28168
  ]);
28120
- var ASKING_MODES = new Set(["default", "acceptEdits", "plan"]);
28169
+ var ASKING_MODES = new Set(["default", "acceptEdits", "plan", "auto"]);
28121
28170
 
28122
28171
  // packages/workit-core/src/hooks/hosts/codex.ts
28123
28172
  var CODEX_DESCRIPTOR = {
@@ -28485,6 +28534,60 @@ var MUTATING_REMOTE = new Set([
28485
28534
  "set-branches",
28486
28535
  "prune"
28487
28536
  ]);
28537
+ var GIT_VERBS = {
28538
+ log: "@d@l|@d @l",
28539
+ show: "@d@l|@d @l",
28540
+ diff: "@d|@d cached staged merge-base no-index",
28541
+ "diff-tree": "@drtcm|@d root stdin no-commit-id",
28542
+ "diff-index": "@dm|@d cached merge-base",
28543
+ status: "sbu?zv|short branch porcelain? long untracked-files? ignored? ignore-submodules? show-stash ahead-behind no-ahead-behind renames no-renames find-renames? column? no-column null verbose",
28544
+ "rev-parse": "q|verify short? abbrev-ref? symbolic symbolic-full-name show-toplevel show-prefix git-dir git-common-dir absolute-git-dir is-inside-work-tree is-inside-git-dir is-bare-repository show-cdup quiet all branches? tags? remotes? since= until= default= path-format= sq-quote",
28545
+ "rev-list": "@l|@l count objects? left-only right-only",
28546
+ "ls-files": "cdmoiskuvtzfx:X:|cached deleted modified others ignored stage unmerged killed directory no-empty-directory exclude-standard exclude= exclude-from= full-name abbrev? error-unmatch with-tree= eol deduplicate format= recurse-submodules sparse",
28547
+ "ls-tree": "rdtlz|long name-only name-status object-only full-name full-tree abbrev? format=",
28548
+ "cat-file": "tsepz|batch? batch-check? batch-all-objects follow-symlinks unordered buffer allow-unknown-type mailmap use-mailmap",
28549
+ blame: "L:lstfnepwbcM?C?|porcelain line-porcelain incremental root show-stats show-name show-number show-email abbrev= reverse= first-parent date= ignore-rev= ignore-revs-file= minimal contents=",
28550
+ describe: "|tags all long abbrev= contains always dirty? broken? match= exclude= first-parent exact-match candidates= debug",
28551
+ "merge-base": "a|all octopus independent is-ancestor fork-point",
28552
+ "for-each-ref": "|count= sort= format= color? shell perl python tcl points-at= merged? no-merged? contains? no-contains? ignore-case omit-empty exclude=",
28553
+ shortlog: "@lsnec|@l summary numbered email committer group= format=",
28554
+ "show-ref": "dsq|head verify heads tags branches hash? abbrev? quiet dereference exists",
28555
+ "name-rev": "|tags refs= exclude= all annotate-stdin name-only no-undefined always",
28556
+ grep: "aiIvnhHcEGFPlLzoWqwe:A:B:C:m:f:|cached untracked no-index no-exclude-standard exclude-standard recurse-submodules text ignore-case word-regexp invert-match line-number column count full-name extended-regexp basic-regexp fixed-strings perl-regexp files-with-matches name-only files-without-match null only-matching heading break show-function function-context max-depth= threads= and or not all-match quiet after-context= before-context= context= max-count= color? no-color",
28557
+ "format-patch": "@do:nNks|@d stdout output-directory= numbered no-numbered start-number= subject-prefix= root cover-letter thread? signoff attach? inline? suffix= base=",
28558
+ reflog: "@l|@l all expire= expire-unreachable= rewrite updateref stale-fix dry-run verbose",
28559
+ "count-objects": "vH|verbose human-readable",
28560
+ "check-ignore": "qvnz|quiet verbose stdin non-matching no-index",
28561
+ var: "l|",
28562
+ version: "|build-options",
28563
+ "ls-remote": "htbq|heads tags branches refs quiet exit-code get-url symref sort=",
28564
+ remote: "v|verbose",
28565
+ config: "lz|get get-all get-regexp list local name-only null type= default=",
28566
+ worktree: "fdqvzb:B:|force detach lock reason= orphan no-checkout checkout quiet track no-track guess-remote porcelain expire= verbose",
28567
+ branch: "dDmMcCfvraliu:|delete move copy force list all remotes verbose contains? merged? no-merged? points-at= show-current set-upstream-to= unset-upstream track? no-track sort= format= color? column? ignore-case create-reflog",
28568
+ tag: "lam:dfF:n?|list annotate message= file= delete force sort= format= contains? merged? no-merged? points-at= column? create-reflog ignore-case",
28569
+ init: "+qb:|quiet bare initial-branch= object-format= ref-format= shared? separate-git-dir=",
28570
+ add: "+AunNvf|all update intent-to-add force dry-run verbose ignore-errors ignore-removal no-all renormalize chmod= sparse",
28571
+ commit: "+m:aqsnF:C:ouv|message= all amend no-edit allow-empty allow-empty-message author= date= signoff no-verify quiet file= reuse-message= fixup= squash= only include dry-run no-gpg-sign untracked-files? cleanup= reset-author verbose",
28572
+ checkout: "+b:B:fqm|detach force orphan= quiet track? no-track merge ours theirs",
28573
+ switch: "+c:C:dfqm|create= force-create= detach discard-changes force orphan= quiet track? no-track merge",
28574
+ restore: "+s:SWq|source= staged worktree ours theirs merge quiet overlay no-overlay",
28575
+ reset: "+qN|soft mixed hard merge keep quiet no-refresh",
28576
+ rm: "+rfnq|cached force dry-run quiet ignore-unmatch",
28577
+ mv: "+fnkv|force dry-run verbose",
28578
+ merge: "+m:qvnX:|no-ff ff ff-only squash no-squash commit no-commit message= no-edit abort continue quit allow-unrelated-histories stat no-stat quiet verbose no-verify signoff strategy-option=",
28579
+ stash: "+m:ukqa|message= include-untracked keep-index quiet all index staged",
28580
+ apply: "+p:C:R3qv|check stat numstat summary index cached 3way reverse reject allow-empty exclude= include= verbose quiet whitespace= recount",
28581
+ am: "+skq3|signoff keep 3way quiet abort continue skip quit whitespace= reject",
28582
+ fetch: "+fqvptn|all depth= deepen= shallow-since= unshallow tags no-tags prune force quiet verbose dry-run update-shallow refmap=",
28583
+ clone: "+nqlsb:o:|bare no-checkout depth= branch= origin= single-branch no-single-branch no-tags quiet shared local no-local filter= separate-git-dir=",
28584
+ "cherry-pick": "+nm:sxX:|no-commit mainline= signoff abort continue skip quit allow-empty keep-redundant-commits ff strategy-option=",
28585
+ revert: "+nm:sX:|no-commit mainline= signoff abort continue skip quit strategy-option= no-edit",
28586
+ rebase: "+qvfnX:|onto= root abort continue skip quit keep-base no-ff force-rebase autosquash no-autosquash autostash no-autostash update-refs signoff quiet verbose stat no-stat committer-date-is-author-date reset-author-date rebase-merges? no-rebase-merges empty= strategy-option= apply merge",
28587
+ clean: "+dfnqxXe:|dry-run force quiet exclude=",
28588
+ bisect: "+|term-old= term-new= no-checkout first-parent"
28589
+ };
28590
+ var JUDGE_GIT = `a judge runs git ${Object.keys(GIT_VERBS).join(" ")} with the options each documents (no abbreviations), writing only in a scratch repo; no -c, no wrapper but timeout, nice, time, command, no env but PAGER=cat, GIT_PAGER=cat, GIT_OPTIONAL_LOCKS=0, LC_*, LANG, TZ; status outside scratch needs --no-optional-locks`;
28488
28591
  var JUDGE_VERBS = {
28489
28592
  check: true,
28490
28593
  dir: true,
@@ -29140,7 +29243,13 @@ var SHELLS3 = /^(?:sh|bash|zsh|dash|ksh|ash|mksh|yash|fish)$/;
29140
29243
  var MAX_DEPTH2 = 4;
29141
29244
  var READ = new Map;
29142
29245
  var NOT_PLAIN = gap("a ytrack call that is not a plain command of its own (a wrapper, loop, substitution or script around it can change or repeat it)");
29143
- var ungrant = (write) => write.workit ? { command: write.command, ...NOT_PLAIN } : write;
29246
+ var timeOnly = (effect) => effect?.minutes !== undefined && Object.keys(effect).every((key) => /^(?:issue|minutes|text|date)$/u.test(key));
29247
+ var ungrant = (write) => write.workit ? {
29248
+ command: write.command,
29249
+ ...NOT_PLAIN,
29250
+ ...timeOnly(write.effect) ? { hint: write.workit } : {}
29251
+ } : write;
29252
+ var hinted = (write) => write.hint ? { command: write.command, workit: write.hint } : write;
29144
29253
  var ytrackArgs = (line, found, depth, names, plain) => {
29145
29254
  const inner = (script) => void found.push(...ytrackWrites(script, "posix", depth + 1, plain));
29146
29255
  const tail = workitCheckTail(line);
@@ -29274,6 +29383,7 @@ var ytrackWrites = (command, dialect = "posix", depth = 0, plain = true) => {
29274
29383
  found = [];
29275
29384
  for (const line of commandLines(command, dialect))
29276
29385
  ytrackArgs(line, found, depth, aliases(command), false);
29386
+ found = found.map(hinted);
29277
29387
  }
29278
29388
  READ.set(key, found);
29279
29389
  if (READ.size > 64)
@@ -29281,6 +29391,8 @@ var ytrackWrites = (command, dialect = "posix", depth = 0, plain = true) => {
29281
29391
  return found;
29282
29392
  };
29283
29393
  var ytrackGate = (cwd, command, dialect, ask) => {
29394
+ if (namesTicket(command))
29395
+ return { kind: "deny", reason: TICKET_DENY, unblock: null };
29284
29396
  let writes;
29285
29397
  try {
29286
29398
  const merged = new Map;
@@ -29308,8 +29420,8 @@ var ytrackGate = (cwd, command, dialect, ask) => {
29308
29420
  reason: `${bare.join(", ")} writes to YouTrack: the user decides this call (#780).`
29309
29421
  };
29310
29422
  const why = `A raw ytrack write posts to YouTrack without the user's yes (#780).`;
29311
- const run = calls.length ? ` Run ${calls.join(", then ")} instead: it asks the user first. When it answers approval_needed, run exactly the \`workit approve <id>\` it names, now, with nothing around it (no 2>&1, pipe or echo), so the host asks the user; then rerun the workit call once.` : "";
29312
- const user = bare.length ? ` For ${bare.join(", ")}, the user decides: ask the user, and if they agree they run it in their own terminal.` : "";
29423
+ const run = calls.length ? ` Run ${calls.join(", then ")} instead, each as its own plain call: it asks the user first.` : "";
29424
+ const user = bare.length ? ask ? ` For ${bare.join(", ")}, run it as its own plain call: the host asks the user.` : ` For ${bare.join(", ")}, the user decides: ask the user, and if they agree they run it in their own terminal.` : "";
29313
29425
  const rerun = writes.some((write) => write.gap === NOT_PLAIN.gap) ? " To get the named workit youtrack call instead, rerun the ytrack call as one plain command, with no wrapper, loop, substitution or script around it." : "";
29314
29426
  return {
29315
29427
  kind: "deny",
@@ -31447,6 +31559,11 @@ var injectCompactionContext = (root, sessionID, system) => {
31447
31559
 
31448
31560
  // packages/workit-opencode/src/v2/permissions.ts
31449
31561
  var WRITE_ACTIONS = new Set(["edit", "write", "patch"]);
31562
+ var WRITE_TOOLS2 = new Set(["write", "edit", "multiedit", "patch", "apply_patch"]);
31563
+ var checkWriteArgs = (tool, input) => {
31564
+ if (WRITE_TOOLS2.has(tool) && namesTicket(JSON.stringify(input ?? {})))
31565
+ throw new Error(TICKET_DENY);
31566
+ };
31450
31567
  var evaluateShellPermission = (root, event, workdirs = new Map) => {
31451
31568
  if (event.effect === "deny")
31452
31569
  return;
@@ -32213,6 +32330,7 @@ var setup = async (ctx) => {
32213
32330
  const spawnNotes = new Map;
32214
32331
  const switchNotices = new Set;
32215
32332
  await ctx.tool.hook("execute.before", async (event) => {
32333
+ checkWriteArgs(event.tool, event.input);
32216
32334
  const budgetEvent = {
32217
32335
  tool: event.tool,
32218
32336
  sessionID: String(event.sessionID),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/opencode",
3
- "version": "2.4.3",
3
+ "version": "2.5.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.4.3"
44
+ "@workit-dev/core": "^2.5.0"
45
45
  },
46
46
  "engines": {
47
47
  "node": ">=24"