@workit-dev/codex 1.6.0 → 1.6.1

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "workit",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "description": "Adaptive engineering workflow rails for Codex",
5
5
  "author": {
6
6
  "name": "BrainerVirus"
@@ -18897,7 +18897,10 @@ var actionsIn = (cwd, command, dialect, cache = new Map, all = false) => {
18897
18897
  continue;
18898
18898
  const action = rawAction(invocation);
18899
18899
  const at = !action ? null : repoFor(invocation.dir) ?? (all && invocation.tool !== "git" && explicitRepo(invocation.tool === "gh", "repo" in action && action.repo || "", invocation.env ?? {}) ? {
18900
- repo: { dir: path23.resolve(cwd, invocation.dir ?? "."), branch: null },
18900
+ repo: {
18901
+ dir: path23.resolve(cwd, invocation.dir ?? "."),
18902
+ branch: null
18903
+ },
18901
18904
  workit: false
18902
18905
  } : null);
18903
18906
  if (action && at)
@@ -18944,6 +18947,109 @@ var pkillSelfMatch = (command, dialect) => {
18944
18947
  }
18945
18948
  return null;
18946
18949
  };
18950
+ var policyDeclared = () => {
18951
+ try {
18952
+ return !!readConfigTyped().config?.branchPolicy?.protected?.length;
18953
+ } catch {
18954
+ return false;
18955
+ }
18956
+ };
18957
+ var word = (text) => /^[\w./@%+:,=-]+$/u.test(text) ? text : shellQuote(text);
18958
+ var HEREDOC = /^cat <<(['"])(\w+)\1\n([\s\S]*)\n\2\n?$/u;
18959
+ var messageOf = (segment, index) => {
18960
+ const text = segment.words[index];
18961
+ if (text === undefined)
18962
+ return null;
18963
+ if (!segment.expands?.includes(index))
18964
+ return text;
18965
+ const sub = segment.subs?.find((each) => text === `$(${each})`);
18966
+ const match = sub === undefined ? null : HEREDOC.exec(sub);
18967
+ if (!match || match[3].split(`
18968
+ `).includes(match[2]))
18969
+ return null;
18970
+ return match[3].replace(/\n+$/u, "");
18971
+ };
18972
+ var cdCommitCall = (input, command, target, repo) => {
18973
+ const { top, git, dir: store } = repo.location;
18974
+ if (!top || !git || git.gitDir === path23.dirname(store) || repoAt(input.cwd)?.location.top === top)
18975
+ return null;
18976
+ const bare = command.replaceAll(/'[^']*'|"(?:[^"\\]|\\.)*"/gu, "").replaceAll("&&", "");
18977
+ if (/[;|&<>`$()\n\\]/u.test(bare))
18978
+ return null;
18979
+ const [cd, ...rest] = segmentsOf(command);
18980
+ const commit = rest.at(-1);
18981
+ if (cd?.words[0] !== "cd" || cd.words.length !== 2 || cd.expands?.length || !commit)
18982
+ return null;
18983
+ if (path23.resolve(input.cwd, cd.words[1]) !== target)
18984
+ return null;
18985
+ if (rest.some((each) => each.redirects.length || each.stdin?.length || each.group))
18986
+ return null;
18987
+ const adds = rest.slice(0, -1);
18988
+ if (!adds.length || commit.words[0] !== "git" || commit.words[1] !== "commit")
18989
+ return null;
18990
+ const paths = [];
18991
+ let all = false;
18992
+ for (const add of adds) {
18993
+ const [tool, verb, ...args] = add.words;
18994
+ if (tool !== "git" || verb !== "add" || add.expands?.length || add.subs?.length)
18995
+ return null;
18996
+ const named = args.filter((arg) => !["-A", "--all", "--"].includes(arg));
18997
+ if (named.some((arg) => arg.startsWith("-") || /[*?[\]]/u.test(arg)))
18998
+ return null;
18999
+ if (!named.length && !args.some((arg) => arg === "-A" || arg === "--all"))
19000
+ return null;
19001
+ if (named.length)
19002
+ paths.push(...named);
19003
+ else
19004
+ all = true;
19005
+ }
19006
+ const messages = [];
19007
+ let allowEmpty = false;
19008
+ for (let index = 2;index < commit.words.length; index++) {
19009
+ const arg = commit.words[index];
19010
+ let message = null;
19011
+ if (arg === "--allow-empty") {
19012
+ allowEmpty = true;
19013
+ continue;
19014
+ }
19015
+ if (arg === "-m" || arg === "--message")
19016
+ message = messageOf(commit, ++index);
19017
+ else if (!commit.expands?.includes(index) && /^(?:-m|--message=)./u.test(arg))
19018
+ message = arg.replace(/^(?:-m|--message=)/u, "");
19019
+ if (!message || message.startsWith("-"))
19020
+ return null;
19021
+ messages.push(message);
19022
+ }
19023
+ if (!messages.length)
19024
+ return null;
19025
+ if (!all) {
19026
+ const staged = spawnSync12("git", ["diff", "--cached", "--quiet"], {
19027
+ cwd: target,
19028
+ timeout: 5000
19029
+ });
19030
+ if (staged.status !== 0)
19031
+ return null;
19032
+ }
19033
+ return [
19034
+ `workit git --cwd ${word(target)} commit`,
19035
+ ...messages.map((message) => `-m ${shellQuote(message)}`),
19036
+ ...allowEmpty ? ["--allow-empty"] : [],
19037
+ all ? "--all" : `-- ${[...new Set(paths)].map(word).join(" ")}`
19038
+ ].join(" ");
19039
+ };
19040
+ var commitRefusal = (input, command, dialect, { action, repo, invocation, workit }) => {
19041
+ if (action.kind !== "commit" || !(workit || policyDeclared()))
19042
+ return null;
19043
+ const switches = workitInvocations(command, dialect).length > 0 || rawInvocations(command, dialect).some((raw) => ["switch", "checkout", "worktree"].includes(raw.args[0] ?? ""));
19044
+ let guarded = false;
19045
+ try {
19046
+ guarded = !!repo.branch && resolveBranchPolicyFor(repo.dir).protected.has(repo.branch.toLowerCase());
19047
+ } catch {}
19048
+ if (guarded && !switches)
19049
+ return `workit: raw ${quote("git commit")} on ${repo.branch}, a protected branch. Branch first: ${quote("workit git branch --kind feature --slug <slug>")} (uncommitted changes come along), then ${quote("workit git commit -m '<msg>' -- <paths>")}.`;
19050
+ const call = action.amend || dialect !== "posix" || typeof invocation.dir !== "string" ? null : cdCommitCall(input, command, path23.resolve(input.cwd, invocation.dir), repo);
19051
+ return call && `workit: no ${quote("cd … &&")} chain; run ${quote(call)}.`;
19052
+ };
18947
19053
  function rawGitPre(input, command, options = {}) {
18948
19054
  try {
18949
19055
  const dialect = dialectOf(input);
@@ -18959,6 +19065,11 @@ function rawGitPre(input, command, options = {}) {
18959
19065
  if (refused)
18960
19066
  return deny(refused);
18961
19067
  }
19068
+ for (const found of located) {
19069
+ const refused = commitRefusal(input, command, dialect, found);
19070
+ if (refused)
19071
+ return deny(refused);
19072
+ }
18962
19073
  for (const { action, repo, invocation, workit } of located) {
18963
19074
  if (!workit)
18964
19075
  continue;
@@ -23805,7 +23916,11 @@ var usageLimitOnStop = (input, agentId, text) => {
23805
23916
  return;
23806
23917
  if (!firstSighting(`subagent-stop:${input.session.id}:${agentId ?? ""}`))
23807
23918
  return;
23808
- recordUsageLimit(text, { cwd: input.cwd, host: input.host, model: input.model ?? null });
23919
+ recordUsageLimit(text, {
23920
+ cwd: input.cwd,
23921
+ host: input.host,
23922
+ model: input.model ?? null
23923
+ });
23809
23924
  } catch {}
23810
23925
  };
23811
23926
  var subagentSession = (session, agentId) => [session, agentId].filter((part) => Boolean(part)).join(":").replace(/[^A-Za-z0-9_.:@/+-]/g, "-").slice(0, 128);
@@ -23901,9 +24016,6 @@ function decide(input, deps) {
23901
24016
  const postTool = usable2(descriptor.events["shell.post"].support);
23902
24017
  if (!postTool)
23903
24018
  settlePendingCommit(input);
23904
- const raw = canDeny ? rawGitPre(input, event.command, { nudge: false }) : NONE6;
23905
- if (raw.kind === "deny")
23906
- return raw;
23907
24019
  const userOnly = userOnlyWorkitCall(event.command, event.dialect);
23908
24020
  if (userOnly) {
23909
24021
  if (input.host === "claude_code")
@@ -23924,6 +24036,9 @@ function decide(input, deps) {
23924
24036
  if (confined.kind === "deny")
23925
24037
  return confined;
23926
24038
  }
24039
+ const raw = canDeny ? rawGitPre(input, event.command, { nudge: false }) : NONE6;
24040
+ if (raw.kind === "deny")
24041
+ return raw;
23927
24042
  const owner = role === "judge" ? null : liveOwner(input, descriptor.transport);
23928
24043
  const gate = usable2(descriptor.events["write.pre"].support) ? shellGate(input.cwd, event.command, owner, event.dialect) : NONE6;
23929
24044
  if (gate.kind === "deny")
@@ -23986,7 +24101,11 @@ function decide(input, deps) {
23986
24101
  trackJudge(input, event.agentId, true);
23987
24102
  seedStanding({
23988
24103
  ...input,
23989
- session: { ...input.session, agentId: event.agentId, agentType: event.agentType }
24104
+ session: {
24105
+ ...input.session,
24106
+ agentId: event.agentId,
24107
+ agentType: event.agentType
24108
+ }
23990
24109
  });
23991
24110
  deps.budget?.start(input, event.agentId, event.agentType);
23992
24111
  return {
@@ -84,7 +84,7 @@ if (quiet) {
84
84
  `);
85
85
  } else {
86
86
  try {
87
- const { runCodexHook } = await import("./workit-hook-ecwds2tm.js");
87
+ const { runCodexHook } = await import("./workit-hook-n63mrn52.js");
88
88
  await runCodexHook([payload]);
89
89
  } catch (error) {
90
90
  const { answerRuntimeFailure } = await import("./workit-hook-ehy7rps6.js");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/codex",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "private": false,
5
5
  "description": "Workit Codex CLI/desktop plugin — shared MCP transport, hooks, method skills, and verifier/reviewer/implementer agents",
6
6
  "keywords": [
@@ -41,8 +41,8 @@
41
41
  "build": "bun scripts/build.ts"
42
42
  },
43
43
  "devDependencies": {
44
- "@workit-dev/core": "^1.6.0",
45
- "@workit-dev/mcp": "^1.6.0"
44
+ "@workit-dev/core": "^1.6.1",
45
+ "@workit-dev/mcp": "^1.6.1"
46
46
  },
47
47
  "engines": {
48
48
  "node": ">=24"