@brainervirus/workit-codex 8.0.0 → 8.1.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.
@@ -6624,12 +6624,12 @@ var require_dist = __commonJS(function(exports, module) {
6624
6624
  import { existsSync as existsSync9, realpathSync as realpathSync7, statSync as statSync3 } from "node:fs";
6625
6625
  import path21 from "node:path";
6626
6626
 
6627
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core.ts
6628
- import { spawnSync as spawnSync12 } from "node:child_process";
6627
+ // packages/workit-core/src/core.ts
6628
+ import { spawnSync as spawnSync13 } from "node:child_process";
6629
6629
  import { existsSync as existsSync7, realpathSync as realpathSync5 } from "node:fs";
6630
6630
  import path19 from "node:path";
6631
6631
 
6632
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/task-contract.ts
6632
+ // packages/workit-core/src/core/task-contract.ts
6633
6633
  import { createHash, randomUUID } from "node:crypto";
6634
6634
 
6635
6635
  // node_modules/zod/v4/core/util.js
@@ -14203,7 +14203,7 @@ function preprocess(fn, schema) {
14203
14203
  function datetime2(params) {
14204
14204
  return _isoDateTime(ZodISODateTime, params);
14205
14205
  }
14206
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/task-contract.ts
14206
+ // packages/workit-core/src/core/task-contract.ts
14207
14207
  var SCHEMA_VERSION = 1;
14208
14208
  var POLICY_VERSION = "1.0.0";
14209
14209
  var OPERATION_FAMILIES = [
@@ -15058,7 +15058,7 @@ function requirementId(input) {
15058
15058
  }
15059
15059
  });
15060
15060
  }
15061
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/operation-input.ts
15061
+ // packages/workit-core/src/core/operation-input.ts
15062
15062
  var str = (d, values) => ({
15063
15063
  type: "string",
15064
15064
  ...values ? { enum: values } : {},
@@ -15454,7 +15454,7 @@ function parseAdvertisedOperation(family, input, host) {
15454
15454
  }))
15455
15455
  });
15456
15456
  }
15457
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/task-store.ts
15457
+ // packages/workit-core/src/core/task-store.ts
15458
15458
  import { createHash as createHash4, randomUUID as randomUUID3 } from "node:crypto";
15459
15459
  import * as fs7 from "node:fs";
15460
15460
  import path6 from "node:path";
@@ -16060,7 +16060,7 @@ function acquireFileLockSync(targetPath, options) {
16060
16060
  }
16061
16061
  }
16062
16062
  }
16063
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/package-root.ts
16063
+ // packages/workit-core/src/core/package-root.ts
16064
16064
  import { existsSync } from "node:fs";
16065
16065
  import path3 from "node:path";
16066
16066
  import { fileURLToPath } from "node:url";
@@ -16079,12 +16079,12 @@ var assetRoot = () => {
16079
16079
  return existsSync(assets) ? assets : root;
16080
16080
  };
16081
16081
 
16082
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/store-lock.ts
16082
+ // packages/workit-core/src/core/store-lock.ts
16083
16083
  import { spawnSync as spawnSync2 } from "node:child_process";
16084
16084
  import fs5 from "node:fs";
16085
16085
  import { hostname } from "node:os";
16086
16086
 
16087
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/store/paths.ts
16087
+ // packages/workit-core/src/store/paths.ts
16088
16088
  import { spawnSync } from "node:child_process";
16089
16089
  import { createHash as createHash2 } from "node:crypto";
16090
16090
  import fs4 from "node:fs";
@@ -16364,7 +16364,7 @@ var checkoutSlug = (root) => {
16364
16364
  return `${base}-${shortHash(canonical)}`;
16365
16365
  };
16366
16366
 
16367
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/store-lock.ts
16367
+ // packages/workit-core/src/core/store-lock.ts
16368
16368
  var metadataLockSchema = object({
16369
16369
  pid: number2().int().nonnegative().safe(),
16370
16370
  processStart: string2().nullable(),
@@ -16495,7 +16495,7 @@ var clearAbandonedReclaimGuard = (lockPath, nowMs = Date.now()) => {
16495
16495
  }
16496
16496
  };
16497
16497
 
16498
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/store/event-log.ts
16498
+ // packages/workit-core/src/store/event-log.ts
16499
16499
  import { randomUUID as randomUUID2 } from "node:crypto";
16500
16500
  import fs6 from "node:fs";
16501
16501
  import path5 from "node:path";
@@ -16655,7 +16655,7 @@ var retryTransient = (run) => {
16655
16655
  };
16656
16656
  var renameWithRetry = (from, to) => retryTransient(() => fs6.renameSync(from, to));
16657
16657
 
16658
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/store/patch.ts
16658
+ // packages/workit-core/src/store/patch.ts
16659
16659
  var isPlainObject2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
16660
16660
  var equal = (left, right) => {
16661
16661
  if (left === right)
@@ -16765,7 +16765,7 @@ var isPatch = (value) => Array.isArray(value) && value.every((op) => {
16765
16765
  return false;
16766
16766
  });
16767
16767
 
16768
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/store/reduce.ts
16768
+ // packages/workit-core/src/store/reduce.ts
16769
16769
  import { createHash as createHash3 } from "node:crypto";
16770
16770
  var OPENING_TYPES = new Set([
16771
16771
  "task.opened",
@@ -16896,7 +16896,7 @@ function eventType(before, after) {
16896
16896
  return "task.updated";
16897
16897
  }
16898
16898
 
16899
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/store/notes.ts
16899
+ // packages/workit-core/src/store/notes.ts
16900
16900
  var SLOT = Symbol.for("workit.migrationReporter");
16901
16901
  var reportMigration = (report) => {
16902
16902
  try {
@@ -16907,7 +16907,7 @@ var reportMigration = (report) => {
16907
16907
  };
16908
16908
  var migrationReporterInstalled = () => typeof globalThis[SLOT] === "function";
16909
16909
 
16910
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/task-store.ts
16910
+ // packages/workit-core/src/core/task-store.ts
16911
16911
  var MIGRATION_PENDING = "workit migration pending";
16912
16912
  var STORE_FORMAT = 3;
16913
16913
  var STORE_MIN_RUNTIME = "3.0.0";
@@ -18543,18 +18543,18 @@ class TaskStore {
18543
18543
  return failure2(recovery ? "recovery_required" : "storage_error", `lock operation failed: ${String(error)}`, { path: lockPath });
18544
18544
  }
18545
18545
  }
18546
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/workers.ts
18546
+ // packages/workit-core/src/core/workers.ts
18547
18547
  var UNCERTAIN_WORKER_STATES = ["dispatching", "running", "cancelling", "unknown"];
18548
18548
  var isUncertainWorker = (state) => UNCERTAIN_WORKER_STATES.includes(state);
18549
18549
  var workerBlocksTransition = (transition, state) => transition === "pause" ? false : isUncertainWorker(state);
18550
18550
 
18551
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/task-evaluation.ts
18551
+ // packages/workit-core/src/core/task-evaluation.ts
18552
18552
  import { createHash as createHash7 } from "node:crypto";
18553
18553
  import * as fs11 from "node:fs";
18554
18554
  import { spawnSync as spawnSync6 } from "node:child_process";
18555
18555
  import path11 from "node:path";
18556
18556
 
18557
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/check-config.ts
18557
+ // packages/workit-core/src/check-config.ts
18558
18558
  import { spawnSync as spawnSync3 } from "node:child_process";
18559
18559
  import fs8 from "node:fs";
18560
18560
  import path7 from "node:path";
@@ -18759,7 +18759,7 @@ function checkCommand(args, version, onPath = workitAvailable()) {
18759
18759
  return onPath ? `workit check ${args}` : `npx -y @brainervirus/workit-cli@${version} check ${args}`;
18760
18760
  }
18761
18761
 
18762
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/git/rev.ts
18762
+ // packages/workit-core/src/git/rev.ts
18763
18763
  import { spawnSync as spawnSync4 } from "node:child_process";
18764
18764
  import { createHash as createHash5 } from "node:crypto";
18765
18765
  import fs9 from "node:fs";
@@ -18940,11 +18940,11 @@ function pushRemoteName(cwd, branch) {
18940
18940
  return remotes.length === 1 ? remotes[0] : null;
18941
18941
  }
18942
18942
 
18943
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/policy/derive.ts
18943
+ // packages/workit-core/src/core/policy/derive.ts
18944
18944
  import { existsSync as existsSync3 } from "node:fs";
18945
18945
  import path10 from "node:path";
18946
18946
 
18947
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/ledger.ts
18947
+ // packages/workit-core/src/ledger.ts
18948
18948
  import { spawnSync as spawnSync5 } from "node:child_process";
18949
18949
  import { createHash as createHash6, randomBytes as randomBytes2 } from "node:crypto";
18950
18950
  import fs10 from "node:fs";
@@ -19186,7 +19186,7 @@ var independenceReasons = (row, authors) => {
19186
19186
  reasons.push("self");
19187
19187
  return reasons;
19188
19188
  };
19189
- function effectiveOf(rows, authors) {
19189
+ function effectiveOf(rows, authors, sameCode) {
19190
19190
  let effective = null;
19191
19191
  for (const row of rows) {
19192
19192
  if (!effective) {
@@ -19197,7 +19197,7 @@ function effectiveOf(rows, authors) {
19197
19197
  const effIndependent = independenceReasons(effective, authors).length === 0;
19198
19198
  if (effIndependent && !rowIndependent)
19199
19199
  continue;
19200
- if (effIndependent && FAILING.has(String(effective.result)) && row.actor.session === effective.actor.session)
19200
+ if (effIndependent && FAILING.has(String(effective.result)) && row.actor.session === effective.actor.session && sameCode(effective, row))
19201
19201
  continue;
19202
19202
  effective = row;
19203
19203
  }
@@ -19228,16 +19228,22 @@ function checkVerdicts(cwd, branch, rows) {
19228
19228
  const head = branchHead(cwd, branch);
19229
19229
  const fallbackBase = defaultBase(cwd);
19230
19230
  const keyCache = new Map;
19231
- const keyFor = (base) => {
19232
- if (!base || !head)
19231
+ const keysAt = (base, at) => {
19232
+ if (!base || !at)
19233
19233
  return { patchId: null, diffHash: null };
19234
- let key = keyCache.get(base);
19234
+ const cacheKey = `${base}\x00${at}`;
19235
+ let key = keyCache.get(cacheKey);
19235
19236
  if (!key) {
19236
- key = { patchId: patchId(cwd, base, head), diffHash: diffHash(cwd, base, head) };
19237
- keyCache.set(base, key);
19237
+ key = { patchId: patchId(cwd, base, at), diffHash: diffHash(cwd, base, at) };
19238
+ keyCache.set(cacheKey, key);
19238
19239
  }
19239
19240
  return key;
19240
19241
  };
19242
+ const keyFor = (base) => keysAt(base, head);
19243
+ const sameCode = (failed, row) => verdictBasis(failed, {
19244
+ head: row.head,
19245
+ ...keysAt(failed.base ?? fallbackBase, row.head)
19246
+ }) !== "stale" || restackCarries(rows, branch, failed.head, row.head);
19241
19247
  const authors = authorSessions(cwd, rows, branch, { base: fallbackBase, head });
19242
19248
  const byKind = new Map;
19243
19249
  for (const row of rows)
@@ -19247,7 +19253,7 @@ function checkVerdicts(cwd, branch, rows) {
19247
19253
  }
19248
19254
  const verdicts = [];
19249
19255
  for (const [kind, list] of byKind) {
19250
- const row = effectiveOf(list, authors);
19256
+ const row = effectiveOf(list, authors, sameCode);
19251
19257
  if (!row)
19252
19258
  continue;
19253
19259
  let basis = verdictBasis(row, { head, ...keyFor(row.base ?? fallbackBase) });
@@ -19273,11 +19279,11 @@ function checkVerdicts(cwd, branch, rows) {
19273
19279
  verdicts.sort((a, b) => a.verdict.seq - b.verdict.seq);
19274
19280
  const newestCurrent = verdicts.findLast((entry) => entry.current) ?? verdicts.at(-1) ?? null;
19275
19281
  const failing = verdicts.find((entry) => entry.current && entry.independent && FAILING.has(String(entry.verdict.result)));
19276
- const newestAccepted = verdicts.findLast((entry) => entry.accepted) ?? null;
19282
+ const newestAccepted = verdicts.findLast((entry) => entry.accepted && STRONG_RESULTS.has(String(entry.verdict.result))) ?? null;
19277
19283
  const accepted = newestAccepted && !failing ? { accepted: true, verdict: newestAccepted.verdict, reasons: [] } : {
19278
19284
  accepted: false,
19279
19285
  verdict: failing?.verdict ?? null,
19280
- reasons: failing ? ["failing_verdict"] : newestCurrent?.reasons ?? ["no_verdict"]
19286
+ reasons: failing ? ["failing_verdict"] : !newestCurrent ? ["no_verdict"] : newestCurrent.reasons.length ? newestCurrent.reasons : ["type_check_only"]
19281
19287
  };
19282
19288
  const selfEntry = failing ? undefined : verdicts.findLast((entry) => entry.current && !entry.independent && STRONG_RESULTS.has(String(entry.verdict.result)));
19283
19289
  return {
@@ -19293,9 +19299,9 @@ function checkVerdicts(cwd, branch, rows) {
19293
19299
  authors: [...authors].toSorted()
19294
19300
  };
19295
19301
  }
19296
- var OBSERVED_ONLY = new Set(["check", ...PR_ROW_TYPES]);
19302
+ var OBSERVED_ONLY = new Set(["check", "merge.unverified", ...PR_ROW_TYPES]);
19297
19303
 
19298
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/policy/derive.ts
19304
+ // packages/workit-core/src/core/policy/derive.ts
19299
19305
  var RULES = {
19300
19306
  test: "check:test",
19301
19307
  self: "verdict:self",
@@ -19483,7 +19489,7 @@ function derivedRuleStatus(task, requirement, root, ledger) {
19483
19489
  }
19484
19490
  }
19485
19491
 
19486
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/task-evaluation.ts
19492
+ // packages/workit-core/src/core/task-evaluation.ts
19487
19493
  var digestBytes = (value) => createHash7("sha256").update(value).digest("hex");
19488
19494
  var inside = (root, candidate) => candidate === root || candidate.startsWith(`${root}${path11.sep}`);
19489
19495
  var relative = (root, candidate) => path11.relative(root, candidate).split(path11.sep).join("/") || ".";
@@ -20149,7 +20155,7 @@ function evaluateClosure(requestedOutcome, view) {
20149
20155
  });
20150
20156
  }
20151
20157
 
20152
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/methods.ts
20158
+ // packages/workit-core/src/core/methods.ts
20153
20159
  var METHODS = {
20154
20160
  "workit-shape": { dimensions: ["challenge", "decisions", "artifacts", "continuity"] },
20155
20161
  "workit-bdd": { dimensions: ["testing"] },
@@ -20195,7 +20201,7 @@ function selectMethods(policy, capabilities) {
20195
20201
  });
20196
20202
  }
20197
20203
 
20198
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/task-context.ts
20204
+ // packages/workit-core/src/core/task-context.ts
20199
20205
  function reconcileResume(view, observations = []) {
20200
20206
  if (observations.length > 0)
20201
20207
  return failure2("permission_denied", "worker observations require native host verification");
@@ -20309,75 +20315,10 @@ var exportDigest = (bundle) => sha256({
20309
20315
  sourceWorkspaceId: bundle.sourceWorkspaceId,
20310
20316
  task: bundle.task
20311
20317
  });
20312
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/git.ts
20313
- import { execFileSync } from "node:child_process";
20314
- var run = (cwd, args) => {
20315
- try {
20316
- const stdout = execFileSync("git", args, {
20317
- cwd,
20318
- encoding: "utf8",
20319
- stdio: ["pipe", "pipe", "pipe"]
20320
- });
20321
- return { stdout: stdout.trimEnd(), stderr: "", exitCode: 0 };
20322
- } catch (error) {
20323
- const e = error;
20324
- return {
20325
- stdout: (e.stdout ?? "").trimEnd(),
20326
- stderr: (e.stderr ?? "").trimEnd(),
20327
- exitCode: e.status ?? 1
20328
- };
20329
- }
20330
- };
20331
- var gitContext = (workspaceRoot, paths = []) => {
20332
- const cwd = workspaceRoot;
20333
- let failure;
20334
- const runHere = (args) => {
20335
- const result = run(cwd, args);
20336
- if (!failure && result.exitCode !== 0) {
20337
- failure = { stderr: result.stderr, exitCode: result.exitCode };
20338
- }
20339
- return result.stdout;
20340
- };
20341
- const branch = runHere(["rev-parse", "--abbrev-ref", "HEAD"]) || "unknown";
20342
- const status_short = runHere(["status", "--porcelain"]);
20343
- const staged = [];
20344
- const unstaged = [];
20345
- const untracked = [];
20346
- for (const line of status_short.split(`
20347
- `).filter(Boolean)) {
20348
- const code = line.slice(0, 2);
20349
- const file = line.slice(3);
20350
- if (code === "??") {
20351
- untracked.push(file);
20352
- } else {
20353
- if (code[0] !== " " && code[0] !== "?")
20354
- staged.push(file);
20355
- if (code[1] !== " " && code[1] !== "?")
20356
- unstaged.push(file);
20357
- }
20358
- }
20359
- const pathArgs = paths.length ? ["--", ...paths] : [];
20360
- const diff_stat = runHere(["diff", "--stat", ...pathArgs]);
20361
- const cached_stat = runHere(["diff", "--cached", "--stat", ...pathArgs]);
20362
- const stagedSet = new Set(staged);
20363
- const unstagedSet = new Set(unstaged);
20364
- const partial_staged = [...stagedSet].filter((f) => unstagedSet.has(f));
20365
- return {
20366
- workspace_root: cwd,
20367
- branch,
20368
- status_short,
20369
- staged,
20370
- unstaged,
20371
- untracked,
20372
- diff_stat: [diff_stat, cached_stat].filter(Boolean).join(`
20373
- `),
20374
- partial_staged: partial_staged.length > 0,
20375
- partial_staged_files: partial_staged,
20376
- ...failure ? { stderr: failure.stderr, exitCode: failure.exitCode } : {}
20377
- };
20378
- };
20318
+ // packages/workit-core/src/core/branch-policy.ts
20319
+ import { spawnSync as spawnSync7 } from "node:child_process";
20379
20320
 
20380
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/config.ts
20321
+ // packages/workit-core/src/core/config.ts
20381
20322
  import {
20382
20323
  copyFileSync as copyFileSync2,
20383
20324
  cpSync as cpSync2,
@@ -20390,7 +20331,7 @@ import {
20390
20331
  import os2 from "node:os";
20391
20332
  import path12 from "node:path";
20392
20333
 
20393
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/boundary.ts
20334
+ // packages/workit-core/src/core/boundary.ts
20394
20335
  import { statSync as statSync2 } from "node:fs";
20395
20336
  var EVENT = {
20396
20337
  initialization: "initialization",
@@ -20426,7 +20367,7 @@ var changedSourcesSinceLoad = (marker) => {
20426
20367
  return changed;
20427
20368
  };
20428
20369
 
20429
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/config.ts
20370
+ // packages/workit-core/src/core/config.ts
20430
20371
  var diagnosticLogger;
20431
20372
  var PRESETS = {
20432
20373
  gitflow: {
@@ -20501,6 +20442,7 @@ var DEFAULTS = {
20501
20442
  },
20502
20443
  commitPolicy: { preset: "conventional" }
20503
20444
  };
20445
+ var unchosenBranchPolicy = new WeakSet([DEFAULTS]);
20504
20446
  var readSafe = (p) => {
20505
20447
  try {
20506
20448
  return readFileSync3(p, "utf8");
@@ -20525,22 +20467,21 @@ var parseConfigResult = (raw, file) => {
20525
20467
  const locale = LOCALE_RE.test(String(input.locale ?? "")) ? input.locale : DEFAULTS.locale;
20526
20468
  const preset = Object.hasOwn(PRESETS, input.branchPolicy?.preset) ? input.branchPolicy?.preset : "gitflow";
20527
20469
  const commitPreset = COMMIT_PRESETS.includes(String(input.commitPolicy?.preset ?? "")) ? input.commitPolicy?.preset : "conventional";
20528
- return {
20529
- status: "valid",
20530
- path: file,
20531
- config: {
20532
- locale,
20533
- localeOptions: Array.isArray(input.localeOptions) ? input.localeOptions : DEFAULTS.localeOptions,
20534
- branchPolicy: mergePreset(preset, {
20535
- allowed: Array.isArray(input.branchPolicy?.allowed) ? input.branchPolicy.allowed : undefined,
20536
- protectedNames: Array.isArray(input.branchPolicy?.protected) ? input.branchPolicy.protected : undefined
20537
- }, DEFAULTS),
20538
- commitPolicy: {
20539
- preset: commitPreset,
20540
- ...typeof input.commitPolicy?.pattern === "string" ? { pattern: input.commitPolicy.pattern } : {}
20541
- }
20470
+ const config = {
20471
+ locale,
20472
+ localeOptions: Array.isArray(input.localeOptions) ? input.localeOptions : DEFAULTS.localeOptions,
20473
+ branchPolicy: mergePreset(preset, {
20474
+ allowed: Array.isArray(input.branchPolicy?.allowed) ? input.branchPolicy.allowed : undefined,
20475
+ protectedNames: Array.isArray(input.branchPolicy?.protected) ? input.branchPolicy.protected : undefined
20476
+ }, DEFAULTS),
20477
+ commitPolicy: {
20478
+ preset: commitPreset,
20479
+ ...typeof input.commitPolicy?.pattern === "string" ? { pattern: input.commitPolicy.pattern } : {}
20542
20480
  }
20543
20481
  };
20482
+ if (!Object.hasOwn(PRESETS, input.branchPolicy?.preset))
20483
+ unchosenBranchPolicy.add(config);
20484
+ return { status: "valid", path: file, config };
20544
20485
  };
20545
20486
  var readConfigTyped = (dir) => {
20546
20487
  const file = path12.join(dir ?? configDir(), "config.json");
@@ -20554,9 +20495,11 @@ var readConfig = () => {
20554
20495
  };
20555
20496
  var vcsConfigPath = () => process.env.WORKFLOW_VCS_CONFIG ?? path12.join(configDir(), "vcs.json");
20556
20497
  var branchGlobPattern = (glob) => new RegExp(`^${glob.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*")}$`, "i");
20557
- var resolveBranchPolicy = (config, workspace) => {
20498
+ var resolveBranchPolicy = (config, workspace, repoPreset) => {
20558
20499
  const wp = workspace?.branchPolicy ?? {};
20559
- const preset = Object.hasOwn(PRESETS, wp.preset) ? wp.preset : config.branchPolicy?.preset ?? "gitflow";
20500
+ const workspacePreset = Object.hasOwn(PRESETS, wp.preset);
20501
+ const detected = !workspacePreset && unchosenBranchPolicy.has(config) ? repoPreset?.() ?? null : null;
20502
+ const preset = workspacePreset ? wp.preset : detected ?? config.branchPolicy?.preset ?? "gitflow";
20560
20503
  const merged = mergePreset(preset, {
20561
20504
  allowed: wp.allowed,
20562
20505
  protectedNames: wp.protected
@@ -20565,9 +20508,10 @@ var resolveBranchPolicy = (config, workspace) => {
20565
20508
  return {
20566
20509
  preset,
20567
20510
  allowed,
20568
- protected: new Set(merged.protected.map((p) => p.toLowerCase())),
20511
+ protected: new Set([...merged.protected, ...detected ? PRESETS.gitflow.protected : []].map((p) => p.toLowerCase())),
20569
20512
  integration: wp.integration === "merge" ? "merge" : "pr",
20570
- defaultTargetBranch: preset === "github-flow" ? "main" : preset === "trunk-based" ? "master" : "develop"
20513
+ defaultTargetBranch: preset === "github-flow" ? "main" : preset === "trunk-based" ? "master" : "develop",
20514
+ detected: detected !== null
20571
20515
  };
20572
20516
  };
20573
20517
  var COMMIT_PRESETS = [
@@ -20579,7 +20523,139 @@ var COMMIT_PRESETS = [
20579
20523
  "auto"
20580
20524
  ];
20581
20525
 
20582
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/workspaces.ts
20526
+ // packages/workit-core/src/core/branch-policy.ts
20527
+ var PREFIXES = {
20528
+ feature: "feature/*",
20529
+ bugfix: "bugfix/*",
20530
+ release: "release/*",
20531
+ hotfix: "hotfix/*"
20532
+ };
20533
+ var branchNames = (workspaceRoot) => {
20534
+ const r = spawnSync7("git", ["for-each-ref", "--format=%(refname)", "refs/heads", "refs/remotes/origin"], { cwd: workspaceRoot, encoding: "utf8" });
20535
+ if (r.status !== 0)
20536
+ return new Set;
20537
+ return new Set((r.stdout ?? "").split(`
20538
+ `).filter(Boolean).map((ref) => ref.startsWith("refs/heads/") ? ref.slice("refs/heads/".length) : ref.slice("refs/remotes/origin/".length)));
20539
+ };
20540
+ var detectBranchPolicy = (workspaceRoot) => {
20541
+ const names = branchNames(workspaceRoot);
20542
+ const develop = names.has("develop");
20543
+ const main = names.has("main");
20544
+ const master = names.has("master");
20545
+ const root = main ? "main" : master ? "master" : null;
20546
+ if (develop) {
20547
+ return {
20548
+ preset: "gitflow",
20549
+ developBranch: "develop",
20550
+ integration: "merge",
20551
+ protected: root ? [root, "develop"] : ["develop"],
20552
+ allowed: [...PRESETS.gitflow.allowed],
20553
+ prefixes: PREFIXES
20554
+ };
20555
+ }
20556
+ if (root === "main") {
20557
+ return {
20558
+ preset: "github-flow",
20559
+ developBranch: null,
20560
+ integration: "pr",
20561
+ protected: [root],
20562
+ allowed: ["*"],
20563
+ prefixes: PREFIXES
20564
+ };
20565
+ }
20566
+ if (root === "master") {
20567
+ return {
20568
+ preset: "trunk-based",
20569
+ developBranch: null,
20570
+ integration: "pr",
20571
+ protected: [root],
20572
+ allowed: ["*"],
20573
+ prefixes: PREFIXES
20574
+ };
20575
+ }
20576
+ return {
20577
+ preset: "gitflow",
20578
+ developBranch: null,
20579
+ integration: "merge",
20580
+ protected: [],
20581
+ allowed: [],
20582
+ prefixes: PREFIXES
20583
+ };
20584
+ };
20585
+ var repoBranchPreset = (workspaceRoot) => {
20586
+ const detected = detectBranchPolicy(workspaceRoot);
20587
+ return detected.developBranch || detected.allowed.length ? detected.preset : null;
20588
+ };
20589
+
20590
+ // packages/workit-core/src/core/git.ts
20591
+ import { execFileSync } from "node:child_process";
20592
+ var run = (cwd, args) => {
20593
+ try {
20594
+ const stdout = execFileSync("git", args, {
20595
+ cwd,
20596
+ encoding: "utf8",
20597
+ stdio: ["pipe", "pipe", "pipe"]
20598
+ });
20599
+ return { stdout: stdout.trimEnd(), stderr: "", exitCode: 0 };
20600
+ } catch (error) {
20601
+ const e = error;
20602
+ return {
20603
+ stdout: (e.stdout ?? "").trimEnd(),
20604
+ stderr: (e.stderr ?? "").trimEnd(),
20605
+ exitCode: e.status ?? 1
20606
+ };
20607
+ }
20608
+ };
20609
+ var gitContext = (workspaceRoot, paths = []) => {
20610
+ const cwd = workspaceRoot;
20611
+ let failure;
20612
+ const runHere = (args) => {
20613
+ const result = run(cwd, args);
20614
+ if (!failure && result.exitCode !== 0) {
20615
+ failure = { stderr: result.stderr, exitCode: result.exitCode };
20616
+ }
20617
+ return result.stdout;
20618
+ };
20619
+ const branch = runHere(["rev-parse", "--abbrev-ref", "HEAD"]) || "unknown";
20620
+ const status_short = runHere(["status", "--porcelain"]);
20621
+ const staged = [];
20622
+ const unstaged = [];
20623
+ const untracked = [];
20624
+ for (const line of status_short.split(`
20625
+ `).filter(Boolean)) {
20626
+ const code = line.slice(0, 2);
20627
+ const file = line.slice(3);
20628
+ if (code === "??") {
20629
+ untracked.push(file);
20630
+ } else {
20631
+ if (code[0] !== " " && code[0] !== "?")
20632
+ staged.push(file);
20633
+ if (code[1] !== " " && code[1] !== "?")
20634
+ unstaged.push(file);
20635
+ }
20636
+ }
20637
+ const pathArgs = paths.length ? ["--", ...paths] : [];
20638
+ const diff_stat = runHere(["diff", "--stat", ...pathArgs]);
20639
+ const cached_stat = runHere(["diff", "--cached", "--stat", ...pathArgs]);
20640
+ const stagedSet = new Set(staged);
20641
+ const unstagedSet = new Set(unstaged);
20642
+ const partial_staged = [...stagedSet].filter((f) => unstagedSet.has(f));
20643
+ return {
20644
+ workspace_root: cwd,
20645
+ branch,
20646
+ status_short,
20647
+ staged,
20648
+ unstaged,
20649
+ untracked,
20650
+ diff_stat: [diff_stat, cached_stat].filter(Boolean).join(`
20651
+ `),
20652
+ partial_staged: partial_staged.length > 0,
20653
+ partial_staged_files: partial_staged,
20654
+ ...failure ? { stderr: failure.stderr, exitCode: failure.exitCode } : {}
20655
+ };
20656
+ };
20657
+
20658
+ // packages/workit-core/src/core/workspaces.ts
20583
20659
  import { createHash as createHash8 } from "node:crypto";
20584
20660
  import { readFileSync as readFileSync4, realpathSync as realpathSync3 } from "node:fs";
20585
20661
  import path13 from "node:path";
@@ -20984,18 +21060,18 @@ function workspaceDefaultTarget(cwd, globalDefault) {
20984
21060
  const wp = ws?.branchPolicy ?? {};
20985
21061
  const hasWorkspacePolicy = typeof wp.preset === "string" && Object.hasOwn(PRESETS, wp.preset);
20986
21062
  const selected = resolveRuntimeWorkspacePolicy(cwd, "branch", process.env.WORKFLOW_PROFILE?.trim() || undefined);
20987
- const policyDefault = resolveBranchPolicy(readConfig(), selected.policy ? { branchPolicy: selected.policy } : null).defaultTargetBranch;
21063
+ const policyDefault = resolveBranchPolicy(readConfig(), selected.policy ? { branchPolicy: selected.policy } : null, () => repoBranchPreset(cwd)).defaultTargetBranch;
20988
21064
  return String(ws?.vcs?.defaultTargetBranch ?? (hasWorkspacePolicy ? policyDefault : globalDefault ?? policyDefault) ?? "develop");
20989
21065
  }
20990
21066
 
20991
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/vcs-config.ts
21067
+ // packages/workit-core/src/core/vcs-config.ts
20992
21068
  import fs12 from "node:fs";
20993
21069
  import path14 from "node:path";
20994
- import { spawnSync as spawnSync8 } from "node:child_process";
21070
+ import { spawnSync as spawnSync9 } from "node:child_process";
20995
21071
 
20996
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/release-tracks.ts
21072
+ // packages/workit-core/src/core/release-tracks.ts
20997
21073
  import { createHash as createHash9 } from "node:crypto";
20998
- import { spawnSync as spawnSync7 } from "node:child_process";
21074
+ import { spawnSync as spawnSync8 } from "node:child_process";
20999
21075
  var KNOWN_FIELDS = new Set([
21000
21076
  "strategy",
21001
21077
  "productionBranch",
@@ -21267,7 +21343,7 @@ function resolveReleaseTrack(input) {
21267
21343
  return fallback(`${branch} has the same or unrelated fork points with ${[...new Set(newest.map((fork) => `${fork.ref} (${fork.track.name === IMPLICIT ? "workspace default" : fork.track.name})`))].join(" and ")}`);
21268
21344
  }
21269
21345
  var git4 = (cwd, args) => {
21270
- const run = spawnSync7("git", args, {
21346
+ const run = spawnSync8("git", args, {
21271
21347
  cwd,
21272
21348
  encoding: "utf8",
21273
21349
  timeout: 20000,
@@ -21378,11 +21454,11 @@ function resolveTrackFor(cwd, options) {
21378
21454
  return resolution;
21379
21455
  }
21380
21456
 
21381
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/vcs-config.ts
21457
+ // packages/workit-core/src/core/vcs-config.ts
21382
21458
  var workspacesPath = () => path14.join(configDir(), "workspaces.json");
21383
21459
  var vcsCwd = (cwd) => cwd ?? process.env.WORKFLOW_WORKSPACE_ROOT ?? process.cwd();
21384
21460
  var remoteProvider = (cwd) => {
21385
- const r = spawnSync8("git", ["remote", "get-url", "origin"], { cwd, encoding: "utf8" });
21461
+ const r = spawnSync9("git", ["remote", "get-url", "origin"], { cwd, encoding: "utf8" });
21386
21462
  if (r.status !== 0)
21387
21463
  return null;
21388
21464
  const url = (r.stdout ?? "").trim();
@@ -21419,7 +21495,7 @@ var remoteEndpoint = (remote) => {
21419
21495
  var configuredSshEndpoint = (host) => {
21420
21496
  if (host.startsWith("-"))
21421
21497
  return null;
21422
- const resolved = spawnSync8("ssh", ["-G", host], {
21498
+ const resolved = spawnSync9("ssh", ["-G", host], {
21423
21499
  encoding: "utf8",
21424
21500
  timeout: 5000,
21425
21501
  maxBuffer: 1024 * 1024,
@@ -21592,7 +21668,7 @@ function mergedPrStyle(limit = 6, cwd) {
21592
21668
  `).filter((l) => l.startsWith("## ")).map((l) => l.trim()),
21593
21669
  descriptionPreview: desc.slice(0, 600)
21594
21670
  });
21595
- const remoteResult = spawnSync8("git", ["remote", "get-url", "--push", "--all", "origin"], {
21671
+ const remoteResult = spawnSync9("git", ["remote", "get-url", "--push", "--all", "origin"], {
21596
21672
  cwd,
21597
21673
  encoding: "utf8"
21598
21674
  });
@@ -21608,7 +21684,7 @@ function mergedPrStyle(limit = 6, cwd) {
21608
21684
  if (!hostingApiHostMatches(remote, host))
21609
21685
  return { ok: false, error: "PR style target does not match the provider host" };
21610
21686
  if (provider === "gitlab") {
21611
- const run = (args) => spawnSync8("glab", ["api", ...args], {
21687
+ const run = (args) => spawnSync9("glab", ["api", ...args], {
21612
21688
  cwd,
21613
21689
  encoding: "utf8",
21614
21690
  env
@@ -21628,7 +21704,7 @@ function mergedPrStyle(limit = 6, cwd) {
21628
21704
  });
21629
21705
  }
21630
21706
  } else if (provider === "github") {
21631
- const r = spawnSync8("gh", [
21707
+ const r = spawnSync9("gh", [
21632
21708
  "pr",
21633
21709
  "list",
21634
21710
  "--repo",
@@ -21659,10 +21735,10 @@ function mergedPrStyle(limit = 6, cwd) {
21659
21735
  examples
21660
21736
  };
21661
21737
  }
21662
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/task-engine.ts
21738
+ // packages/workit-core/src/core/task-engine.ts
21663
21739
  import { realpathSync as realpathSync4 } from "node:fs";
21664
21740
 
21665
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/policy-resolver.ts
21741
+ // packages/workit-core/src/core/policy-resolver.ts
21666
21742
  function resolvePolicy(input) {
21667
21743
  const ids = input.constraints.map((constraint) => constraint.id);
21668
21744
  if (new Set(ids).size !== ids.length)
@@ -21718,7 +21794,7 @@ function diffPolicy(previous, next, reason, now) {
21718
21794
  return parsed.data;
21719
21795
  }
21720
21796
 
21721
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/policy/judgment.ts
21797
+ // packages/workit-core/src/core/policy/judgment.ts
21722
21798
  var isObject6 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
21723
21799
  var squash = (key) => key.toLowerCase().replace(/[_-]/g, "");
21724
21800
  var ALIASES = {
@@ -21842,7 +21918,7 @@ function normalizeJudgment(raw, previous) {
21842
21918
  return success(null, null, { judgment: parsed.data, ignored, legacy });
21843
21919
  }
21844
21920
 
21845
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/autonomy.ts
21921
+ // packages/workit-core/src/autonomy.ts
21846
21922
  import os3 from "node:os";
21847
21923
  import path15 from "node:path";
21848
21924
  var accountHome = () => {
@@ -21979,7 +22055,7 @@ function resolveAutonomy(cwd) {
21979
22055
  var suggested = (kind) => kind === "merge" ? "verified" : "true";
21980
22056
  var grantHint = (workspace, kind) => `ask the user to run, in their own terminal: workit grant set ${workspace ?? "<workspace>"} ${kind}=${suggested(kind)}`;
21981
22057
 
21982
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/task-engine.ts
22058
+ // packages/workit-core/src/core/task-engine.ts
21983
22059
  var workspaceVerification = (root) => {
21984
22060
  try {
21985
22061
  return resolveAutonomy(root).verification;
@@ -23564,8 +23640,8 @@ class WorkitCore {
23564
23640
  return this.summary(changed.data.task);
23565
23641
  }
23566
23642
  }
23567
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/repo-context.ts
23568
- import { spawnSync as spawnSync9 } from "node:child_process";
23643
+ // packages/workit-core/src/core/repo-context.ts
23644
+ import { spawnSync as spawnSync10 } from "node:child_process";
23569
23645
  import { existsSync as existsSync6, readFileSync as readFileSync5, readdirSync as readdirSync4 } from "node:fs";
23570
23646
  import path16 from "node:path";
23571
23647
  var isSafeContextRange = (value) => value.length <= 4096 && (() => {
@@ -23594,7 +23670,7 @@ var invalidRange = (cwd) => ({
23594
23670
  cwd
23595
23671
  });
23596
23672
  var runGit = (cwd, args) => {
23597
- const result = spawnSync9("git", args, { cwd, encoding: "utf8" });
23673
+ const result = spawnSync10("git", args, { cwd, encoding: "utf8" });
23598
23674
  return {
23599
23675
  stdout: (result.stdout ?? "").trimEnd(),
23600
23676
  stderr: (result.stderr ?? "").trimEnd(),
@@ -24034,20 +24110,20 @@ function releaseNotesContext(root, rangeOrTag) {
24034
24110
  return { stdout, stderr: "", exitCode: 0, cwd };
24035
24111
  }
24036
24112
 
24037
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/tracker-issues.ts
24038
- import { spawnSync as spawnSync11 } from "node:child_process";
24113
+ // packages/workit-core/src/core/tracker-issues.ts
24114
+ import { spawnSync as spawnSync12 } from "node:child_process";
24039
24115
 
24040
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/pr-create.ts
24116
+ // packages/workit-core/src/core/pr-create.ts
24041
24117
  import fs13 from "node:fs";
24042
24118
  import path17 from "node:path";
24043
- import { spawnSync as spawnSync10 } from "node:child_process";
24044
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/forge/pr-body.ts
24119
+ import { spawnSync as spawnSync11 } from "node:child_process";
24120
+ // packages/workit-core/src/forge/pr-body.ts
24045
24121
  function parseGhIssue(value) {
24046
24122
  const m = /issues\/(\d+)/.exec(value);
24047
24123
  return m ? m[1] : String(value).trim().replace(/^#/, "");
24048
24124
  }
24049
24125
 
24050
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/pr-create.ts
24126
+ // packages/workit-core/src/core/pr-create.ts
24051
24127
  function whichOnPath(tool) {
24052
24128
  const names = process.platform === "win32" ? [tool, `${tool}.exe`, `${tool}.cmd`] : [tool];
24053
24129
  for (const dir of (process.env.PATH ?? "").split(path17.delimiter)) {
@@ -24065,7 +24141,7 @@ function whichOnPath(tool) {
24065
24141
  }
24066
24142
  var hostingCliAvailable = (provider) => whichOnPath(provider === "gitlab" ? "glab" : "gh") !== null;
24067
24143
  var pushRemote = (cwd) => {
24068
- const result = spawnSync10("git", ["remote", "get-url", "--push", "--all", "origin"], {
24144
+ const result = spawnSync11("git", ["remote", "get-url", "--push", "--all", "origin"], {
24069
24145
  cwd,
24070
24146
  encoding: "utf8"
24071
24147
  });
@@ -24075,7 +24151,7 @@ var pushRemote = (cwd) => {
24075
24151
  return urls.length === 1 ? urls[0] : null;
24076
24152
  };
24077
24153
 
24078
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/tracker-issues.ts
24154
+ // packages/workit-core/src/core/tracker-issues.ts
24079
24155
  var repoPathFromRemote = (remote) => {
24080
24156
  let rest = (remote || "").trim().replace(/\/+$/, "");
24081
24157
  if (!rest)
@@ -24096,7 +24172,7 @@ var defaultCli = (bin, available) => {
24096
24172
  if (!available)
24097
24173
  return null;
24098
24174
  return (args, root) => {
24099
- const out = spawnSync11(bin, args, {
24175
+ const out = spawnSync12(bin, args, {
24100
24176
  cwd: root,
24101
24177
  encoding: "utf8",
24102
24178
  env: { ...process.env, PATH: process.env.PATH ?? "" }
@@ -24173,19 +24249,19 @@ var fetchGitLabIssueBody = async (ref, root, deps = {}) => {
24173
24249
  return tryCliTriple(deps.cli ?? defaultCli("glab", hostingCliAvailable("gitlab")), "glab", ["issue", "view", id, "-R", repoArg, "-F", "json"], root, id, ["iid"], ["description"]);
24174
24250
  };
24175
24251
 
24176
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/youtrack.ts
24252
+ // packages/workit-core/src/core/youtrack.ts
24177
24253
  import fs14 from "node:fs";
24178
24254
  import path18 from "node:path";
24179
24255
 
24180
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/templates.ts
24256
+ // packages/workit-core/src/core/templates.ts
24181
24257
  var repoRoot2 = assetRoot();
24182
24258
 
24183
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/scripts.ts
24259
+ // packages/workit-core/src/core/scripts.ts
24184
24260
  var PLUGIN_ROOT = packageRoot();
24185
24261
  var ASSET_ROOT = assetRoot();
24186
24262
  var resolveWorkspaceRoot = (explicit) => explicit || process.cwd();
24187
24263
 
24188
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/youtrack.ts
24264
+ // packages/workit-core/src/core/youtrack.ts
24189
24265
  var ISSUE_RE = /^[A-Z]+-\d+$/;
24190
24266
  var TOKEN_PLACEHOLDER = "YOUR_TOKEN_HERE";
24191
24267
  var youTrackConfigPath = () => process.env.WORKFLOW_YOUTRACK_CONFIG ?? path18.join(configDir(), "youtrack.json");
@@ -24476,7 +24552,7 @@ var fetchYouTrackIssueBody = async (issue, creds = youTrackToken, request = youT
24476
24552
  }
24477
24553
  };
24478
24554
 
24479
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/context-read.ts
24555
+ // packages/workit-core/src/core/context-read.ts
24480
24556
  var contextReadSchema = object({
24481
24557
  kind: _enum([
24482
24558
  "git",
@@ -24571,7 +24647,7 @@ var readExternalContext = async (root, payload) => {
24571
24647
  }
24572
24648
  }
24573
24649
  };
24574
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core.ts
24650
+ // packages/workit-core/src/core.ts
24575
24651
  var revision2 = /^[A-Za-z0-9@][A-Za-z0-9@._/~^{}-]*$/;
24576
24652
  function gitRevisionParts(value) {
24577
24653
  if (!value || value.startsWith("-") || /[\s\\'"`$;|&<>]/.test(value)) {
@@ -24614,7 +24690,7 @@ function resolveInside(root, candidate) {
24614
24690
  }
24615
24691
  function run2(root, executable, args, env = {}) {
24616
24692
  const cwd = realpathSync5(root);
24617
- const result = spawnSync12(executable, args, {
24693
+ const result = spawnSync13(executable, args, {
24618
24694
  cwd,
24619
24695
  encoding: "utf8",
24620
24696
  env: { ...process.env, ...env }
@@ -24627,7 +24703,7 @@ function run2(root, executable, args, env = {}) {
24627
24703
  };
24628
24704
  }
24629
24705
 
24630
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/support-matrix.ts
24706
+ // packages/workit-core/src/core/support-matrix.ts
24631
24707
  var SUPPORT_MATRIX = {
24632
24708
  bun: "1.4.1",
24633
24709
  node: { minimum: "24", current: "24.20.0" },
@@ -24637,7 +24713,7 @@ var SUPPORT_MATRIX = {
24637
24713
  os: ["ubuntu-latest", "macos-latest", "windows-latest"]
24638
24714
  };
24639
24715
 
24640
- // packages/workit-codex/node_modules/@brainervirus/workit-mcp/src/server.ts
24716
+ // packages/workit-mcp/src/server.ts
24641
24717
  import { existsSync as existsSync8, readFileSync as readFileSync6, realpathSync as realpathSync6 } from "node:fs";
24642
24718
  import path20 from "node:path";
24643
24719
  // node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
@@ -27014,10 +27090,10 @@ class StdioServerTransport {
27014
27090
  }
27015
27091
  }
27016
27092
 
27017
- // packages/workit-codex/node_modules/@brainervirus/workit-mcp/src/server.ts
27093
+ // packages/workit-mcp/src/server.ts
27018
27094
  import { fileURLToPath as fileURLToPath2 } from "node:url";
27019
27095
 
27020
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/core/logger.ts
27096
+ // packages/workit-core/src/core/logger.ts
27021
27097
  import os4 from "node:os";
27022
27098
  var REDACTED = "[REDACTED]";
27023
27099
  var SECRET_VALUE = /\b(?:Bearer|Basic|Digest|Token)\s+\S+/gi;
@@ -27074,7 +27150,7 @@ var applyPatterns = (value) => {
27074
27150
  };
27075
27151
  var redactSecrets = (value) => applyPatterns(value);
27076
27152
 
27077
- // packages/workit-codex/node_modules/@brainervirus/workit-mcp/src/server.ts
27153
+ // packages/workit-mcp/src/server.ts
27078
27154
  class McpCapabilityUnavailableError extends Error {
27079
27155
  capability;
27080
27156
  constructor(capability) {
@@ -27369,7 +27445,7 @@ async function runStdioServer(host, contextProvider = defaultContextProvider(hos
27369
27445
  await server.connect(new StdioServerTransport);
27370
27446
  return server;
27371
27447
  }
27372
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/hooks/descriptor.ts
27448
+ // packages/workit-core/src/hooks/descriptor.ts
27373
27449
  var support = (descriptor, axis) => {
27374
27450
  if (axis.startsWith("event:"))
27375
27451
  return descriptor.events[axis.slice("event:".length)].support;
@@ -27393,14 +27469,14 @@ var capabilitiesFor = (descriptor, observed = {}) => descriptor.capabilities.map
27393
27469
  refs: rule.refs.map((handle) => ({ kind: "host", host: descriptor.host, handle }))
27394
27470
  };
27395
27471
  });
27396
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/hooks/context.ts
27472
+ // packages/workit-core/src/hooks/context.ts
27397
27473
  var signals = new Map;
27398
27474
  var cache = new Map;
27399
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/hooks/write-gate.ts
27475
+ // packages/workit-core/src/hooks/write-gate.ts
27400
27476
  var CASE_INSENSITIVE = process.platform === "darwin" || process.platform === "win32";
27401
- var PREFIXES = new Set(["sudo", "command", "env", "nohup", "time", "exec", "xargs"]);
27477
+ var PREFIXES2 = new Set(["sudo", "command", "env", "nohup", "time", "exec", "xargs"]);
27402
27478
  var cache2 = new Map;
27403
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/hooks/hosts/fields.ts
27479
+ // packages/workit-core/src/hooks/hosts/fields.ts
27404
27480
  var SHELLS = new Set(["sh", "bash", "zsh", "dash", "pwsh", "powershell", "cmd"]);
27405
27481
  var WRITE_TOOLS = new Set([
27406
27482
  "write",
@@ -27421,15 +27497,15 @@ var WRITE_TOOLS = new Set([
27421
27497
  "editfile",
27422
27498
  "writefile"
27423
27499
  ]);
27424
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/hooks/handle.ts
27500
+ // packages/workit-core/src/hooks/handle.ts
27425
27501
  var offered = new Set;
27426
27502
  var CLAUDE_JUDGES = new Set(["workit:verifier", "workit:reviewer"]);
27427
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/hooks/hosts/claude-code.ts
27503
+ // packages/workit-core/src/hooks/hosts/claude-code.ts
27428
27504
  var SOURCES = new Set(["startup", "resume", "clear", "compact", "fork"]);
27429
27505
  var SHELL_TOOLS = new Set(["Bash", "PowerShell"]);
27430
27506
  var CONTEXT_EVENTS = new Set(["SessionStart", "UserPromptSubmit", "SubagentStart"]);
27431
27507
 
27432
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/hooks/hosts/codex.ts
27508
+ // packages/workit-core/src/hooks/hosts/codex.ts
27433
27509
  function detectCodexSurface(env) {
27434
27510
  return env.CODEX_INTERNAL_ORIGINATOR_OVERRIDE === "Codex Desktop" || Boolean(env.CODEX_ELECTRON_RESOURCES_PATH) ? "codex_desktop" : "codex_cli";
27435
27511
  }
@@ -27534,10 +27610,10 @@ var codexDescriptor = (host) => ({ ...CODEX_DESCRIPTOR, host });
27534
27610
  var SHELL_TOOLS2 = new Set(["bash", "unified-exec"]);
27535
27611
  var SOURCES2 = new Set(["startup", "resume", "clear", "compact"]);
27536
27612
 
27537
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/hooks/hosts/cursor.ts
27613
+ // packages/workit-core/src/hooks/hosts/cursor.ts
27538
27614
  var BLOCKING = new Set(["preToolUse", "beforeShellExecution", "subagentStart"]);
27539
27615
 
27540
- // packages/workit-codex/node_modules/@brainervirus/workit-core/src/hooks/run.ts
27616
+ // packages/workit-core/src/hooks/run.ts
27541
27617
  if (false) {}
27542
27618
  // packages/workit-codex/hooks/workit-hook.ts
27543
27619
  var codexCapabilities = (host, availability = {}) => capabilitiesFor(codexDescriptor(host), {