@workit-dev/codex 1.14.3 → 2.0.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.14.3",
3
+ "version": "2.0.0",
4
4
  "description": "Adaptive engineering workflow rails for Codex",
5
5
  "author": {
6
6
  "name": "BrainerVirus"
@@ -15204,6 +15204,7 @@ var accountHome = (platform = process.platform, io = hostIo) => {
15204
15204
  return null;
15205
15205
  }
15206
15206
  };
15207
+ var grantsHome = { resolve: () => accountHome() };
15207
15208
 
15208
15209
  // packages/workit-core/src/core/remotes.ts
15209
15210
  var FORGE_SCHEMES = new Set(["ssh", "git", "http", "https", "git+ssh", "ssh+git"]);
@@ -24088,11 +24089,12 @@ var ENTRY_KEYS = [
24088
24089
  "verification",
24089
24090
  "youtrack"
24090
24091
  ];
24092
+ var IDENTITY_KEYS = ["provider", "account", "tokenFile", "host"];
24091
24093
  var sealProjection = (entries) => entries.map((entry) => {
24092
24094
  const all = pick2(entry, ENTRY_KEYS) ?? {};
24093
24095
  return pick2({
24094
24096
  ...all,
24095
- vcs: pick2(all.vcs, ["provider", "account"]),
24097
+ vcs: pick2(all.vcs, IDENTITY_KEYS),
24096
24098
  youtrack: pick2(all.youtrack, ["writes"])
24097
24099
  }, ENTRY_KEYS);
24098
24100
  });
@@ -24124,7 +24126,6 @@ function checkSeal(dir) {
24124
24126
  }
24125
24127
 
24126
24128
  // packages/workit-core/src/autonomy.ts
24127
- var grantsHome = { resolve: accountHome };
24128
24129
  var accountDir = () => {
24129
24130
  const home = grantsHome.resolve();
24130
24131
  return home === null ? null : configDir({ HOME: home });
@@ -24145,6 +24146,8 @@ var sealOf = () => {
24145
24146
  return dir === null ? { state: "none" } : checkSeal(dir);
24146
24147
  };
24147
24148
  var SEAL_UNBLOCK = `if the user made this change, ask them to run, in their own terminal: ${SEAL_COMMAND}`;
24149
+ var NO_SEAL_UNBLOCK = `ask the user to review and seal the grants, in their own terminal: ${SEAL_COMMAND}`;
24150
+ var NO_SEAL_NOTE = `workspaces.json has no seal yet (${SEAL_COMMAND} has never run), so grants, endpoint, verification and youtrack.writes stay at or below the D4 defaults; ${NO_SEAL_UNBLOCK}`;
24148
24151
  var sealNote = (seal = sealOf()) => seal.state === "broken" ? `workspaces.json does not match its seal (${seal.reason}), so grants, endpoint, verification and youtrack.writes are the stricter of their current and last sealed values; ${SEAL_UNBLOCK}` : null;
24149
24152
  var shownGrantsDir = () => {
24150
24153
  const world = evalWorld(process.cwd());
@@ -24173,8 +24176,9 @@ var grantsOverride = () => {
24173
24176
  if (shown === null)
24174
24177
  return NO_ACCOUNT;
24175
24178
  const configured = path26.resolve(resolveConfigDir());
24176
- return configured === path26.resolve(shown) ? null : `the config directory is redirected to ${configured} (WORKIT_CONFIG, WORKIT_CONFIG_DIR or XDG_CONFIG_HOME), but that override does not apply to grants: grants are read only from ${path26.join(grantsDir(), "workspaces.json")}, so the D4 defaults apply until grants are set there`;
24179
+ return configured === path26.resolve(shown) ? null : `the config directory is redirected to ${configured} (WORKIT_CONFIG, WORKIT_CONFIG_DIR or XDG_CONFIG_HOME), but that override does not apply to grants: grants are read only from ${path26.join(grantsDir(), "workspaces.json")}, and under a redirect they never exceed the D4 defaults`;
24177
24180
  };
24181
+ var redirectUnblock = () => `ask the user: grants above the D4 defaults apply only without a config redirect (WORKIT_CONFIG, WORKIT_CONFIG_DIR or XDG_CONFIG_HOME), and are read from ${path26.join(grantsDir(), "workspaces.json")}`;
24178
24182
  var GRANT_KINDS = ["push", "pr", "merge", "release", "rerun"];
24179
24183
  var DEFAULT_GRANTS = Object.freeze({
24180
24184
  push: true,
@@ -24340,23 +24344,39 @@ function capAt(source, named, where, by, why, main = false) {
24340
24344
  function resolveAutonomy(cwd, target) {
24341
24345
  const world = benchWorld(cwd);
24342
24346
  const override = world ? null : grantsOverride();
24343
- if (override)
24347
+ if (override === NO_ACCOUNT)
24344
24348
  return { ...autonomyOf(null), note: override };
24345
24349
  let resolved;
24346
24350
  const once = typeof target === "function" ? () => resolved ??= target() : target;
24347
- const current = resolveWith(fileSource(), cwd, world, once);
24351
+ const account = accountAuthority(cwd, world, once);
24352
+ return override ? stricter(account, autonomyOf(null), override, redirectUnblock()) : account;
24353
+ }
24354
+ function accountAuthority(cwd, world, target) {
24355
+ const current = resolveWith(fileSource(), cwd, world, target);
24348
24356
  const seal = sealOf();
24349
- if (seal.state !== "broken")
24350
- return current;
24357
+ if (seal.state !== "broken") {
24358
+ if (seal.state === "valid" || current.world)
24359
+ return current;
24360
+ const capped = stricter(current, autonomyOf(null), NO_SEAL_NOTE, NO_SEAL_UNBLOCK);
24361
+ return authorityKey(capped) === authorityKey(current) ? current : capped;
24362
+ }
24351
24363
  let sealed = autonomyOf(null);
24352
24364
  try {
24353
24365
  if (seal.sealed)
24354
- sealed = resolveWith(sealedSource(seal.sealed), cwd, world, once);
24366
+ sealed = resolveWith(sealedSource(seal.sealed), cwd, world, target);
24355
24367
  } catch {
24356
24368
  sealed = null;
24357
24369
  }
24358
- return stricter(current, sealed, sealNote(seal));
24370
+ return stricter(current, sealed, sealNote(seal), SEAL_UNBLOCK);
24359
24371
  }
24372
+ var authorityKey = (autonomy) => JSON.stringify([
24373
+ autonomy.grants,
24374
+ autonomy.configured,
24375
+ autonomy.accountConfigured,
24376
+ autonomy.defaultEndpoint,
24377
+ autonomy.effectiveEndpoint,
24378
+ autonomy.verification
24379
+ ]);
24360
24380
  function resolveWith(source, cwd, world, target) {
24361
24381
  const name = process.env.WORKIT_WORKSPACE_NAME?.trim() || undefined;
24362
24382
  const real = source.resolve(cwd, name);
@@ -24371,7 +24391,7 @@ function resolveWith(source, cwd, world, target) {
24371
24391
  return capAtRemotes(source, autonomy, cwd, target);
24372
24392
  }
24373
24393
  var needsAccount = (autonomy) => autonomy.configured.length > 0 && !autonomy.accountConfigured;
24374
- function stricter(current, sealed, note) {
24394
+ function stricter(current, sealed, note, unblock) {
24375
24395
  const grants = { ...current.grants };
24376
24396
  const unblocks = { ...current.unblocks };
24377
24397
  for (const kind of GRANT_KINDS) {
@@ -24379,7 +24399,7 @@ function stricter(current, sealed, note) {
24379
24399
  if (!raises(kind, floor, grants[kind]))
24380
24400
  continue;
24381
24401
  grants[kind] = floor;
24382
- unblocks[kind] = SEAL_UNBLOCK;
24402
+ unblocks[kind] = unblock;
24383
24403
  }
24384
24404
  const configured = GRANT_KINDS.filter((kind) => current.configured.includes(kind) || sealed?.configured.includes(kind));
24385
24405
  const accountConfigured = !needsAccount(current) && !(sealed && needsAccount(sealed)) && (current.accountConfigured || Boolean(sealed?.accountConfigured));
@@ -24401,9 +24421,9 @@ function stricter(current, sealed, note) {
24401
24421
  accountConfigured,
24402
24422
  defaultEndpoint,
24403
24423
  effectiveEndpoint: endpoint,
24404
- endpointReason: endpoint === current.effectiveEndpoint ? current.endpointReason : SEAL_UNBLOCK,
24424
+ endpointReason: endpoint === current.effectiveEndpoint ? current.endpointReason : unblock,
24405
24425
  verification: looser ? strict : current.verification,
24406
- unblocks,
24426
+ unblocks: Object.keys(unblocks).length > 0 ? unblocks : current.unblocks,
24407
24427
  note: current.note ? `${current.note}; ${note}` : note
24408
24428
  };
24409
24429
  }
@@ -24430,6 +24450,13 @@ var raises = (kind, current, next) => {
24430
24450
  const rank = (value) => value === true ? 2 : value === "verified" ? 1 : 0;
24431
24451
  return rank(normalized(kind, next)) > rank(normalized(kind, current));
24432
24452
  };
24453
+ var SCOPE_FIELDS = new Set([
24454
+ "autonomy",
24455
+ "autoApprove",
24456
+ "defaultEndpoint",
24457
+ "verification",
24458
+ "youtrack"
24459
+ ]);
24433
24460
 
24434
24461
  // packages/workit-core/src/hooks/raw-git.ts
24435
24462
  var SHELLS = new Set(["sh", "bash", "zsh", "dash", "ksh", "ash", "mksh", "yash", "fish"]);
@@ -6947,6 +6947,7 @@ var accountHome = (platform = process.platform, io = hostIo) => {
6947
6947
  return null;
6948
6948
  }
6949
6949
  };
6950
+ var grantsHome = { resolve: () => accountHome() };
6950
6951
 
6951
6952
  // packages/workit-core/src/core/remotes.ts
6952
6953
  var FORGE_SCHEMES = new Set(["ssh", "git", "http", "https", "git+ssh", "ssh+git"]);
@@ -15563,11 +15564,12 @@ var ENTRY_KEYS = [
15563
15564
  "verification",
15564
15565
  "youtrack"
15565
15566
  ];
15567
+ var IDENTITY_KEYS = ["provider", "account", "tokenFile", "host"];
15566
15568
  var sealProjection = (entries) => entries.map((entry) => {
15567
15569
  const all = pick2(entry, ENTRY_KEYS) ?? {};
15568
15570
  return pick2({
15569
15571
  ...all,
15570
- vcs: pick2(all.vcs, ["provider", "account"]),
15572
+ vcs: pick2(all.vcs, IDENTITY_KEYS),
15571
15573
  youtrack: pick2(all.youtrack, ["writes"])
15572
15574
  }, ENTRY_KEYS);
15573
15575
  });
@@ -15599,7 +15601,6 @@ function checkSeal(dir) {
15599
15601
  }
15600
15602
 
15601
15603
  // packages/workit-core/src/autonomy.ts
15602
- var grantsHome = { resolve: accountHome };
15603
15604
  var accountDir = () => {
15604
15605
  const home = grantsHome.resolve();
15605
15606
  return home === null ? null : configDir2({ HOME: home });
@@ -15620,11 +15621,26 @@ var sealOf = () => {
15620
15621
  return dir === null ? { state: "none" } : checkSeal(dir);
15621
15622
  };
15622
15623
  var SEAL_UNBLOCK = `if the user made this change, ask them to run, in their own terminal: ${SEAL_COMMAND}`;
15624
+ var NO_SEAL_UNBLOCK = `ask the user to review and seal the grants, in their own terminal: ${SEAL_COMMAND}`;
15625
+ var NO_SEAL_NOTE = `workspaces.json has no seal yet (${SEAL_COMMAND} has never run), so grants, endpoint, verification and youtrack.writes stay at or below the D4 defaults; ${NO_SEAL_UNBLOCK}`;
15623
15626
  var sealNote = (seal = sealOf()) => seal.state === "broken" ? `workspaces.json does not match its seal (${seal.reason}), so grants, endpoint, verification and youtrack.writes are the stricter of their current and last sealed values; ${SEAL_UNBLOCK}` : null;
15624
15627
  var youTrackWritesMode = (cwd) => {
15625
- const youtrack = resolveRuntimeWorkspaceVcs(cwd)?.youtrack;
15626
- return youtrack && typeof youtrack === "object" && youtrack.writes === "auto" && !sealNote() ? "auto" : "ask";
15628
+ try {
15629
+ const dir = accountDir();
15630
+ if (dir === null || redirected(dir) || evalWorld(cwd))
15631
+ return "ask";
15632
+ if (checkSeal(dir).state !== "valid")
15633
+ return "ask";
15634
+ const auto = (entry) => entry?.youtrack?.writes === "auto";
15635
+ const name = process.env.WORKIT_WORKSPACE_NAME?.trim() || undefined;
15636
+ if (!auto(resolveWorkspaceFrom(cwd, dir, name)))
15637
+ return "ask";
15638
+ return !name || auto(resolveWorkspaceFrom(cwd, dir)) ? "auto" : "ask";
15639
+ } catch {
15640
+ return "ask";
15641
+ }
15627
15642
  };
15643
+ var redirected = (dir) => path22.resolve(resolveConfigDir()) !== path22.resolve(dir);
15628
15644
  var shownGrantsDir = () => {
15629
15645
  const world = evalWorld(process.cwd());
15630
15646
  return world ? path22.join(world, "config") : accountDir();
@@ -15652,8 +15668,9 @@ var grantsOverride = () => {
15652
15668
  if (shown === null)
15653
15669
  return NO_ACCOUNT;
15654
15670
  const configured = path22.resolve(resolveConfigDir());
15655
- return configured === path22.resolve(shown) ? null : `the config directory is redirected to ${configured} (WORKIT_CONFIG, WORKIT_CONFIG_DIR or XDG_CONFIG_HOME), but that override does not apply to grants: grants are read only from ${path22.join(grantsDir(), "workspaces.json")}, so the D4 defaults apply until grants are set there`;
15671
+ return configured === path22.resolve(shown) ? null : `the config directory is redirected to ${configured} (WORKIT_CONFIG, WORKIT_CONFIG_DIR or XDG_CONFIG_HOME), but that override does not apply to grants: grants are read only from ${path22.join(grantsDir(), "workspaces.json")}, and under a redirect they never exceed the D4 defaults`;
15656
15672
  };
15673
+ var redirectUnblock = () => `ask the user: grants above the D4 defaults apply only without a config redirect (WORKIT_CONFIG, WORKIT_CONFIG_DIR or XDG_CONFIG_HOME), and are read from ${path22.join(grantsDir(), "workspaces.json")}`;
15657
15674
  var GRANT_KINDS = ["push", "pr", "merge", "release", "rerun"];
15658
15675
  var DEFAULT_GRANTS = Object.freeze({
15659
15676
  push: true,
@@ -15819,23 +15836,39 @@ function capAt(source, named, where, by, why, main = false) {
15819
15836
  function resolveAutonomy(cwd, target) {
15820
15837
  const world = benchWorld(cwd);
15821
15838
  const override = world ? null : grantsOverride();
15822
- if (override)
15839
+ if (override === NO_ACCOUNT)
15823
15840
  return { ...autonomyOf(null), note: override };
15824
15841
  let resolved;
15825
15842
  const once = typeof target === "function" ? () => resolved ??= target() : target;
15826
- const current = resolveWith(fileSource(), cwd, world, once);
15843
+ const account = accountAuthority(cwd, world, once);
15844
+ return override ? stricter(account, autonomyOf(null), override, redirectUnblock()) : account;
15845
+ }
15846
+ function accountAuthority(cwd, world, target) {
15847
+ const current = resolveWith(fileSource(), cwd, world, target);
15827
15848
  const seal = sealOf();
15828
- if (seal.state !== "broken")
15829
- return current;
15849
+ if (seal.state !== "broken") {
15850
+ if (seal.state === "valid" || current.world)
15851
+ return current;
15852
+ const capped = stricter(current, autonomyOf(null), NO_SEAL_NOTE, NO_SEAL_UNBLOCK);
15853
+ return authorityKey(capped) === authorityKey(current) ? current : capped;
15854
+ }
15830
15855
  let sealed = autonomyOf(null);
15831
15856
  try {
15832
15857
  if (seal.sealed)
15833
- sealed = resolveWith(sealedSource(seal.sealed), cwd, world, once);
15858
+ sealed = resolveWith(sealedSource(seal.sealed), cwd, world, target);
15834
15859
  } catch {
15835
15860
  sealed = null;
15836
15861
  }
15837
- return stricter(current, sealed, sealNote(seal));
15862
+ return stricter(current, sealed, sealNote(seal), SEAL_UNBLOCK);
15838
15863
  }
15864
+ var authorityKey = (autonomy) => JSON.stringify([
15865
+ autonomy.grants,
15866
+ autonomy.configured,
15867
+ autonomy.accountConfigured,
15868
+ autonomy.defaultEndpoint,
15869
+ autonomy.effectiveEndpoint,
15870
+ autonomy.verification
15871
+ ]);
15839
15872
  function resolveWith(source, cwd, world, target) {
15840
15873
  const name = process.env.WORKIT_WORKSPACE_NAME?.trim() || undefined;
15841
15874
  const real = source.resolve(cwd, name);
@@ -15850,7 +15883,7 @@ function resolveWith(source, cwd, world, target) {
15850
15883
  return capAtRemotes(source, autonomy, cwd, target);
15851
15884
  }
15852
15885
  var needsAccount = (autonomy) => autonomy.configured.length > 0 && !autonomy.accountConfigured;
15853
- function stricter(current, sealed, note) {
15886
+ function stricter(current, sealed, note, unblock) {
15854
15887
  const grants = { ...current.grants };
15855
15888
  const unblocks = { ...current.unblocks };
15856
15889
  for (const kind of GRANT_KINDS) {
@@ -15858,7 +15891,7 @@ function stricter(current, sealed, note) {
15858
15891
  if (!raises(kind, floor, grants[kind]))
15859
15892
  continue;
15860
15893
  grants[kind] = floor;
15861
- unblocks[kind] = SEAL_UNBLOCK;
15894
+ unblocks[kind] = unblock;
15862
15895
  }
15863
15896
  const configured = GRANT_KINDS.filter((kind) => current.configured.includes(kind) || sealed?.configured.includes(kind));
15864
15897
  const accountConfigured = !needsAccount(current) && !(sealed && needsAccount(sealed)) && (current.accountConfigured || Boolean(sealed?.accountConfigured));
@@ -15880,9 +15913,9 @@ function stricter(current, sealed, note) {
15880
15913
  accountConfigured,
15881
15914
  defaultEndpoint,
15882
15915
  effectiveEndpoint: endpoint,
15883
- endpointReason: endpoint === current.effectiveEndpoint ? current.endpointReason : SEAL_UNBLOCK,
15916
+ endpointReason: endpoint === current.effectiveEndpoint ? current.endpointReason : unblock,
15884
15917
  verification: looser ? strict : current.verification,
15885
- unblocks,
15918
+ unblocks: Object.keys(unblocks).length > 0 ? unblocks : current.unblocks,
15886
15919
  note: current.note ? `${current.note}; ${note}` : note
15887
15920
  };
15888
15921
  }
@@ -15903,14 +15936,17 @@ function capAtRemotes(source, autonomy, cwd, target) {
15903
15936
  return capped;
15904
15937
  }
15905
15938
  var grantsMatter = (kind) => {
15906
- if (grantsOverride())
15939
+ const override = grantsOverride();
15940
+ if (override === NO_ACCOUNT)
15907
15941
  return false;
15908
- const matters = entriesIn(accountDir()).some((entry) => {
15942
+ const entries = entriesIn(accountDir());
15943
+ const matters = entries.some((entry) => {
15909
15944
  const autonomy = autonomyOf(entry);
15910
15945
  return entry.remotes?.length || autonomy.grants[kind] === false || needsAccount(autonomy);
15911
15946
  });
15912
15947
  const seal = sealOf();
15913
- return matters || seal.state === "broken" && (seal.sealed ? seal.sealed.length > 0 : DEFAULT_GRANTS[kind] === false);
15948
+ const defaults = entries.length > 0 && DEFAULT_GRANTS[kind] === false;
15949
+ return matters || (seal.state === "none" || override !== null) && defaults || seal.state === "broken" && (seal.sealed ? seal.sealed.length > 0 : DEFAULT_GRANTS[kind] === false);
15914
15950
  };
15915
15951
  var authorityEntries = () => {
15916
15952
  const seal = sealOf();
@@ -15968,6 +16004,13 @@ var raises = (kind, current, next) => {
15968
16004
  const rank = (value) => value === true ? 2 : value === "verified" ? 1 : 0;
15969
16005
  return rank(normalized(kind, next)) > rank(normalized(kind, current));
15970
16006
  };
16007
+ var SCOPE_FIELDS = new Set([
16008
+ "autonomy",
16009
+ "autoApprove",
16010
+ "defaultEndpoint",
16011
+ "verification",
16012
+ "youtrack"
16013
+ ]);
15971
16014
 
15972
16015
  // packages/workit-core/src/hooks/session-marker.ts
15973
16016
  import { createHash as createHash13 } from "node:crypto";
@@ -98,7 +98,7 @@ if (quiet) {
98
98
  `);
99
99
  } else {
100
100
  try {
101
- const { runCodexHook } = await import("./workit-hook-gta6gwg4.js");
101
+ const { runCodexHook } = await import("./workit-hook-6vxn9800.js");
102
102
  await runCodexHook([payload]);
103
103
  } catch (error) {
104
104
  const { answerRuntimeFailure } = await import("./workit-hook-9k8dtngs.js");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workit-dev/codex",
3
- "version": "1.14.3",
3
+ "version": "2.0.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.14.3",
45
- "@workit-dev/mcp": "^1.14.3"
44
+ "@workit-dev/core": "^2.0.0",
45
+ "@workit-dev/mcp": "^2.0.0"
46
46
  },
47
47
  "engines": {
48
48
  "node": ">=24"