@workit-dev/codex 1.6.0 → 1.7.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "workit",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "Adaptive engineering workflow rails for Codex",
5
5
  "author": {
6
6
  "name": "BrainerVirus"
@@ -16078,7 +16078,8 @@ var workspaceConfigSchema = object({
16078
16078
  ]))).passthrough().optional().describe("Autonomy grants (D15): only ever set here, by the user, with `workit grant set`."),
16079
16079
  youtrack: object({
16080
16080
  baseUrl: nonBlank.optional().describe("This workspace's YouTrack URL."),
16081
- link_issues: boolean2().optional().describe("Legacy alias of `issues: { provider: youtrack, link: true }`.")
16081
+ link_issues: boolean2().optional().describe("Legacy alias of `issues: { provider: youtrack, link: true }`."),
16082
+ writes: _enum(["ask", "auto"]).optional().describe("ask (default): each workit youtrack write waits for the user's yes. auto: posts without asking, behind WORKIT_YT_WRITE=1.")
16082
16083
  }).passthrough().optional().describe("YouTrack settings for this workspace."),
16083
16084
  issues: object({
16084
16085
  provider: _enum(["github", "gitlab", "youtrack"]).optional().describe("The issue tracker PRs link to."),
@@ -7313,7 +7313,8 @@ var workspaceConfigSchema = object({
7313
7313
  ]))).passthrough().optional().describe("Autonomy grants (D15): only ever set here, by the user, with `workit grant set`."),
7314
7314
  youtrack: object({
7315
7315
  baseUrl: nonBlank.optional().describe("This workspace's YouTrack URL."),
7316
- link_issues: boolean2().optional().describe("Legacy alias of `issues: { provider: youtrack, link: true }`.")
7316
+ link_issues: boolean2().optional().describe("Legacy alias of `issues: { provider: youtrack, link: true }`."),
7317
+ writes: _enum(["ask", "auto"]).optional().describe("ask (default): each workit youtrack write waits for the user's yes. auto: posts without asking, behind WORKIT_YT_WRITE=1.")
7317
7318
  }).passthrough().optional().describe("YouTrack settings for this workspace."),
7318
7319
  issues: object({
7319
7320
  provider: _enum(["github", "gitlab", "youtrack"]).optional().describe("The issue tracker PRs link to."),
@@ -18897,7 +18898,10 @@ var actionsIn = (cwd, command, dialect, cache = new Map, all = false) => {
18897
18898
  continue;
18898
18899
  const action = rawAction(invocation);
18899
18900
  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 },
18901
+ repo: {
18902
+ dir: path23.resolve(cwd, invocation.dir ?? "."),
18903
+ branch: null
18904
+ },
18901
18905
  workit: false
18902
18906
  } : null);
18903
18907
  if (action && at)
@@ -18944,6 +18948,109 @@ var pkillSelfMatch = (command, dialect) => {
18944
18948
  }
18945
18949
  return null;
18946
18950
  };
18951
+ var policyDeclared = () => {
18952
+ try {
18953
+ return !!readConfigTyped().config?.branchPolicy?.protected?.length;
18954
+ } catch {
18955
+ return false;
18956
+ }
18957
+ };
18958
+ var word = (text) => /^[\w./@%+:,=-]+$/u.test(text) ? text : shellQuote(text);
18959
+ var HEREDOC = /^cat <<(['"])(\w+)\1\n([\s\S]*)\n\2\n?$/u;
18960
+ var messageOf = (segment, index) => {
18961
+ const text = segment.words[index];
18962
+ if (text === undefined)
18963
+ return null;
18964
+ if (!segment.expands?.includes(index))
18965
+ return text;
18966
+ const sub = segment.subs?.find((each) => text === `$(${each})`);
18967
+ const match = sub === undefined ? null : HEREDOC.exec(sub);
18968
+ if (!match || match[3].split(`
18969
+ `).includes(match[2]))
18970
+ return null;
18971
+ return match[3].replace(/\n+$/u, "");
18972
+ };
18973
+ var cdCommitCall = (input, command, target, repo) => {
18974
+ const { top, git, dir: store } = repo.location;
18975
+ if (!top || !git || git.gitDir === path23.dirname(store) || repoAt(input.cwd)?.location.top === top)
18976
+ return null;
18977
+ const bare = command.replaceAll(/'[^']*'|"(?:[^"\\]|\\.)*"/gu, "").replaceAll("&&", "");
18978
+ if (/[;|&<>`$()\n\\]/u.test(bare))
18979
+ return null;
18980
+ const [cd, ...rest] = segmentsOf(command);
18981
+ const commit = rest.at(-1);
18982
+ if (cd?.words[0] !== "cd" || cd.words.length !== 2 || cd.expands?.length || !commit)
18983
+ return null;
18984
+ if (path23.resolve(input.cwd, cd.words[1]) !== target)
18985
+ return null;
18986
+ if (rest.some((each) => each.redirects.length || each.stdin?.length || each.group))
18987
+ return null;
18988
+ const adds = rest.slice(0, -1);
18989
+ if (!adds.length || commit.words[0] !== "git" || commit.words[1] !== "commit")
18990
+ return null;
18991
+ const paths = [];
18992
+ let all = false;
18993
+ for (const add of adds) {
18994
+ const [tool, verb, ...args] = add.words;
18995
+ if (tool !== "git" || verb !== "add" || add.expands?.length || add.subs?.length)
18996
+ return null;
18997
+ const named = args.filter((arg) => !["-A", "--all", "--"].includes(arg));
18998
+ if (named.some((arg) => arg.startsWith("-") || /[*?[\]]/u.test(arg)))
18999
+ return null;
19000
+ if (!named.length && !args.some((arg) => arg === "-A" || arg === "--all"))
19001
+ return null;
19002
+ if (named.length)
19003
+ paths.push(...named);
19004
+ else
19005
+ all = true;
19006
+ }
19007
+ const messages = [];
19008
+ let allowEmpty = false;
19009
+ for (let index = 2;index < commit.words.length; index++) {
19010
+ const arg = commit.words[index];
19011
+ let message = null;
19012
+ if (arg === "--allow-empty") {
19013
+ allowEmpty = true;
19014
+ continue;
19015
+ }
19016
+ if (arg === "-m" || arg === "--message")
19017
+ message = messageOf(commit, ++index);
19018
+ else if (!commit.expands?.includes(index) && /^(?:-m|--message=)./u.test(arg))
19019
+ message = arg.replace(/^(?:-m|--message=)/u, "");
19020
+ if (!message || message.startsWith("-"))
19021
+ return null;
19022
+ messages.push(message);
19023
+ }
19024
+ if (!messages.length)
19025
+ return null;
19026
+ if (!all) {
19027
+ const staged = spawnSync12("git", ["diff", "--cached", "--quiet"], {
19028
+ cwd: target,
19029
+ timeout: 5000
19030
+ });
19031
+ if (staged.status !== 0)
19032
+ return null;
19033
+ }
19034
+ return [
19035
+ `workit git --cwd ${word(target)} commit`,
19036
+ ...messages.map((message) => `-m ${shellQuote(message)}`),
19037
+ ...allowEmpty ? ["--allow-empty"] : [],
19038
+ all ? "--all" : `-- ${[...new Set(paths)].map(word).join(" ")}`
19039
+ ].join(" ");
19040
+ };
19041
+ var commitRefusal = (input, command, dialect, { action, repo, invocation, workit }) => {
19042
+ if (action.kind !== "commit" || !(workit || policyDeclared()))
19043
+ return null;
19044
+ const switches = workitInvocations(command, dialect).length > 0 || rawInvocations(command, dialect).some((raw) => ["switch", "checkout", "worktree"].includes(raw.args[0] ?? ""));
19045
+ let guarded = false;
19046
+ try {
19047
+ guarded = !!repo.branch && resolveBranchPolicyFor(repo.dir).protected.has(repo.branch.toLowerCase());
19048
+ } catch {}
19049
+ if (guarded && !switches)
19050
+ 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>")}.`;
19051
+ const call = action.amend || dialect !== "posix" || typeof invocation.dir !== "string" ? null : cdCommitCall(input, command, path23.resolve(input.cwd, invocation.dir), repo);
19052
+ return call && `workit: no ${quote("cd … &&")} chain; run ${quote(call)}.`;
19053
+ };
18947
19054
  function rawGitPre(input, command, options = {}) {
18948
19055
  try {
18949
19056
  const dialect = dialectOf(input);
@@ -18959,6 +19066,11 @@ function rawGitPre(input, command, options = {}) {
18959
19066
  if (refused)
18960
19067
  return deny(refused);
18961
19068
  }
19069
+ for (const found of located) {
19070
+ const refused = commitRefusal(input, command, dialect, found);
19071
+ if (refused)
19072
+ return deny(refused);
19073
+ }
18962
19074
  for (const { action, repo, invocation, workit } of located) {
18963
19075
  if (!workit)
18964
19076
  continue;
@@ -23805,7 +23917,11 @@ var usageLimitOnStop = (input, agentId, text) => {
23805
23917
  return;
23806
23918
  if (!firstSighting(`subagent-stop:${input.session.id}:${agentId ?? ""}`))
23807
23919
  return;
23808
- recordUsageLimit(text, { cwd: input.cwd, host: input.host, model: input.model ?? null });
23920
+ recordUsageLimit(text, {
23921
+ cwd: input.cwd,
23922
+ host: input.host,
23923
+ model: input.model ?? null
23924
+ });
23809
23925
  } catch {}
23810
23926
  };
23811
23927
  var subagentSession = (session, agentId) => [session, agentId].filter((part) => Boolean(part)).join(":").replace(/[^A-Za-z0-9_.:@/+-]/g, "-").slice(0, 128);
@@ -23901,9 +24017,6 @@ function decide(input, deps) {
23901
24017
  const postTool = usable2(descriptor.events["shell.post"].support);
23902
24018
  if (!postTool)
23903
24019
  settlePendingCommit(input);
23904
- const raw = canDeny ? rawGitPre(input, event.command, { nudge: false }) : NONE6;
23905
- if (raw.kind === "deny")
23906
- return raw;
23907
24020
  const userOnly = userOnlyWorkitCall(event.command, event.dialect);
23908
24021
  if (userOnly) {
23909
24022
  if (input.host === "claude_code")
@@ -23924,6 +24037,9 @@ function decide(input, deps) {
23924
24037
  if (confined.kind === "deny")
23925
24038
  return confined;
23926
24039
  }
24040
+ const raw = canDeny ? rawGitPre(input, event.command, { nudge: false }) : NONE6;
24041
+ if (raw.kind === "deny")
24042
+ return raw;
23927
24043
  const owner = role === "judge" ? null : liveOwner(input, descriptor.transport);
23928
24044
  const gate = usable2(descriptor.events["write.pre"].support) ? shellGate(input.cwd, event.command, owner, event.dialect) : NONE6;
23929
24045
  if (gate.kind === "deny")
@@ -23986,7 +24102,11 @@ function decide(input, deps) {
23986
24102
  trackJudge(input, event.agentId, true);
23987
24103
  seedStanding({
23988
24104
  ...input,
23989
- session: { ...input.session, agentId: event.agentId, agentType: event.agentType }
24105
+ session: {
24106
+ ...input.session,
24107
+ agentId: event.agentId,
24108
+ agentType: event.agentType
24109
+ }
23990
24110
  });
23991
24111
  deps.budget?.start(input, event.agentId, event.agentType);
23992
24112
  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-dvr5p2pn.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.7.0",
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.7.0",
45
+ "@workit-dev/mcp": "^1.7.0"
46
46
  },
47
47
  "engines": {
48
48
  "node": ">=24"