@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.
- package/.codex-plugin/plugin.json +1 -1
- package/dist/launch-mcp.js +252 -176
- package/dist/workit-hook.js +156 -80
- package/package.json +3 -3
package/dist/workit-hook.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
4
|
-
// packages/workit-
|
|
4
|
+
// packages/workit-core/src/hooks/descriptor.ts
|
|
5
5
|
var support = (descriptor, axis) => {
|
|
6
6
|
if (axis.startsWith("event:"))
|
|
7
7
|
return descriptor.events[axis.slice("event:".length)].support;
|
|
@@ -25,10 +25,10 @@ var capabilitiesFor = (descriptor, observed = {}) => descriptor.capabilities.map
|
|
|
25
25
|
refs: rule.refs.map((handle) => ({ kind: "host", host: descriptor.host, handle }))
|
|
26
26
|
};
|
|
27
27
|
});
|
|
28
|
-
// packages/workit-
|
|
28
|
+
// packages/workit-core/src/hooks/context.ts
|
|
29
29
|
import path15 from "node:path";
|
|
30
30
|
|
|
31
|
-
// packages/workit-
|
|
31
|
+
// packages/workit-core/src/core/methods.ts
|
|
32
32
|
var METHODS = {
|
|
33
33
|
"workit-shape": { dimensions: ["challenge", "decisions", "artifacts", "continuity"] },
|
|
34
34
|
"workit-bdd": { dimensions: ["testing"] },
|
|
@@ -136,7 +136,7 @@ Skills: load the skill, never act from memory of it (slash aliases /wk-<name>).
|
|
|
136
136
|
- architecture, deepen modules (user-invoked; offer it): workit-architecture
|
|
137
137
|
`.trim();
|
|
138
138
|
|
|
139
|
-
// packages/workit-
|
|
139
|
+
// packages/workit-core/src/core/task-contract.ts
|
|
140
140
|
import { createHash, randomUUID } from "node:crypto";
|
|
141
141
|
|
|
142
142
|
// node_modules/zod/v4/core/util.js
|
|
@@ -7650,7 +7650,7 @@ function refine(fn, _params = {}) {
|
|
|
7650
7650
|
function superRefine(fn, params) {
|
|
7651
7651
|
return _superRefine(fn, params);
|
|
7652
7652
|
}
|
|
7653
|
-
// packages/workit-
|
|
7653
|
+
// packages/workit-core/src/core/task-contract.ts
|
|
7654
7654
|
var SCHEMA_VERSION = 1;
|
|
7655
7655
|
var POLICY_VERSION = "1.0.0";
|
|
7656
7656
|
var OPERATION_FAMILIES = [
|
|
@@ -8506,13 +8506,13 @@ function requirementId(input) {
|
|
|
8506
8506
|
});
|
|
8507
8507
|
}
|
|
8508
8508
|
|
|
8509
|
-
// packages/workit-
|
|
8509
|
+
// packages/workit-core/src/core/task-evaluation.ts
|
|
8510
8510
|
import { createHash as createHash7 } from "node:crypto";
|
|
8511
8511
|
import * as fs11 from "node:fs";
|
|
8512
8512
|
import { spawnSync as spawnSync6 } from "node:child_process";
|
|
8513
8513
|
import path11 from "node:path";
|
|
8514
8514
|
|
|
8515
|
-
// packages/workit-
|
|
8515
|
+
// packages/workit-core/src/check-config.ts
|
|
8516
8516
|
import { spawnSync } from "node:child_process";
|
|
8517
8517
|
import fs from "node:fs";
|
|
8518
8518
|
import path from "node:path";
|
|
@@ -8717,7 +8717,7 @@ function checkCommand(args, version, onPath = workitAvailable()) {
|
|
|
8717
8717
|
return onPath ? `workit check ${args}` : `npx -y @brainervirus/workit-cli@${version} check ${args}`;
|
|
8718
8718
|
}
|
|
8719
8719
|
|
|
8720
|
-
// packages/workit-
|
|
8720
|
+
// packages/workit-core/src/git/rev.ts
|
|
8721
8721
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
8722
8722
|
import { createHash as createHash2 } from "node:crypto";
|
|
8723
8723
|
import fs2 from "node:fs";
|
|
@@ -8869,7 +8869,7 @@ function currentBranch(cwd) {
|
|
|
8869
8869
|
return line(git2(cwd, ["symbolic-ref", "--short", "-q", "HEAD"]));
|
|
8870
8870
|
}
|
|
8871
8871
|
|
|
8872
|
-
// packages/workit-
|
|
8872
|
+
// packages/workit-core/src/core/task-store.ts
|
|
8873
8873
|
import { createHash as createHash5, randomUUID as randomUUID3 } from "node:crypto";
|
|
8874
8874
|
import * as fs9 from "node:fs";
|
|
8875
8875
|
import path8 from "node:path";
|
|
@@ -9475,7 +9475,7 @@ function acquireFileLockSync(targetPath, options) {
|
|
|
9475
9475
|
}
|
|
9476
9476
|
}
|
|
9477
9477
|
}
|
|
9478
|
-
// packages/workit-
|
|
9478
|
+
// packages/workit-core/src/core/package-root.ts
|
|
9479
9479
|
import { existsSync } from "node:fs";
|
|
9480
9480
|
import path5 from "node:path";
|
|
9481
9481
|
import { fileURLToPath } from "node:url";
|
|
@@ -9489,12 +9489,12 @@ var packageRoot = () => {
|
|
|
9489
9489
|
}
|
|
9490
9490
|
};
|
|
9491
9491
|
|
|
9492
|
-
// packages/workit-
|
|
9492
|
+
// packages/workit-core/src/core/store-lock.ts
|
|
9493
9493
|
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
9494
9494
|
import fs7 from "node:fs";
|
|
9495
9495
|
import { hostname } from "node:os";
|
|
9496
9496
|
|
|
9497
|
-
// packages/workit-
|
|
9497
|
+
// packages/workit-core/src/store/paths.ts
|
|
9498
9498
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
9499
9499
|
import { createHash as createHash3 } from "node:crypto";
|
|
9500
9500
|
import fs6 from "node:fs";
|
|
@@ -9774,7 +9774,7 @@ var checkoutSlug = (root) => {
|
|
|
9774
9774
|
return `${base}-${shortHash(canonical)}`;
|
|
9775
9775
|
};
|
|
9776
9776
|
|
|
9777
|
-
// packages/workit-
|
|
9777
|
+
// packages/workit-core/src/core/store-lock.ts
|
|
9778
9778
|
var metadataLockSchema = object({
|
|
9779
9779
|
pid: number2().int().nonnegative().safe(),
|
|
9780
9780
|
processStart: string2().nullable(),
|
|
@@ -9905,7 +9905,7 @@ var clearAbandonedReclaimGuard = (lockPath, nowMs = Date.now()) => {
|
|
|
9905
9905
|
}
|
|
9906
9906
|
};
|
|
9907
9907
|
|
|
9908
|
-
// packages/workit-
|
|
9908
|
+
// packages/workit-core/src/store/event-log.ts
|
|
9909
9909
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
9910
9910
|
import fs8 from "node:fs";
|
|
9911
9911
|
import path7 from "node:path";
|
|
@@ -10065,7 +10065,7 @@ var retryTransient = (run) => {
|
|
|
10065
10065
|
};
|
|
10066
10066
|
var renameWithRetry = (from, to) => retryTransient(() => fs8.renameSync(from, to));
|
|
10067
10067
|
|
|
10068
|
-
// packages/workit-
|
|
10068
|
+
// packages/workit-core/src/store/patch.ts
|
|
10069
10069
|
var isPlainObject2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10070
10070
|
var equal = (left, right) => {
|
|
10071
10071
|
if (left === right)
|
|
@@ -10175,7 +10175,7 @@ var isPatch = (value) => Array.isArray(value) && value.every((op) => {
|
|
|
10175
10175
|
return false;
|
|
10176
10176
|
});
|
|
10177
10177
|
|
|
10178
|
-
// packages/workit-
|
|
10178
|
+
// packages/workit-core/src/store/reduce.ts
|
|
10179
10179
|
import { createHash as createHash4 } from "node:crypto";
|
|
10180
10180
|
var OPENING_TYPES = new Set([
|
|
10181
10181
|
"task.opened",
|
|
@@ -10306,7 +10306,7 @@ function eventType(before, after) {
|
|
|
10306
10306
|
return "task.updated";
|
|
10307
10307
|
}
|
|
10308
10308
|
|
|
10309
|
-
// packages/workit-
|
|
10309
|
+
// packages/workit-core/src/store/notes.ts
|
|
10310
10310
|
var SLOT = Symbol.for("workit.migrationReporter");
|
|
10311
10311
|
var reportMigration = (report) => {
|
|
10312
10312
|
try {
|
|
@@ -10317,7 +10317,7 @@ var reportMigration = (report) => {
|
|
|
10317
10317
|
};
|
|
10318
10318
|
var migrationReporterInstalled = () => typeof globalThis[SLOT] === "function";
|
|
10319
10319
|
|
|
10320
|
-
// packages/workit-
|
|
10320
|
+
// packages/workit-core/src/core/task-store.ts
|
|
10321
10321
|
var MIGRATION_PENDING = "workit migration pending";
|
|
10322
10322
|
var STORE_FORMAT = 3;
|
|
10323
10323
|
var STORE_MIN_RUNTIME = "3.0.0";
|
|
@@ -11954,11 +11954,11 @@ class TaskStore {
|
|
|
11954
11954
|
}
|
|
11955
11955
|
}
|
|
11956
11956
|
|
|
11957
|
-
// packages/workit-
|
|
11957
|
+
// packages/workit-core/src/core/policy/derive.ts
|
|
11958
11958
|
import { existsSync as existsSync3 } from "node:fs";
|
|
11959
11959
|
import path10 from "node:path";
|
|
11960
11960
|
|
|
11961
|
-
// packages/workit-
|
|
11961
|
+
// packages/workit-core/src/ledger.ts
|
|
11962
11962
|
import { spawnSync as spawnSync5 } from "node:child_process";
|
|
11963
11963
|
import { createHash as createHash6, randomBytes as randomBytes2 } from "node:crypto";
|
|
11964
11964
|
import fs10 from "node:fs";
|
|
@@ -12200,7 +12200,7 @@ var independenceReasons = (row, authors) => {
|
|
|
12200
12200
|
reasons.push("self");
|
|
12201
12201
|
return reasons;
|
|
12202
12202
|
};
|
|
12203
|
-
function effectiveOf(rows, authors) {
|
|
12203
|
+
function effectiveOf(rows, authors, sameCode) {
|
|
12204
12204
|
let effective = null;
|
|
12205
12205
|
for (const row of rows) {
|
|
12206
12206
|
if (!effective) {
|
|
@@ -12211,7 +12211,7 @@ function effectiveOf(rows, authors) {
|
|
|
12211
12211
|
const effIndependent = independenceReasons(effective, authors).length === 0;
|
|
12212
12212
|
if (effIndependent && !rowIndependent)
|
|
12213
12213
|
continue;
|
|
12214
|
-
if (effIndependent && FAILING.has(String(effective.result)) && row.actor.session === effective.actor.session)
|
|
12214
|
+
if (effIndependent && FAILING.has(String(effective.result)) && row.actor.session === effective.actor.session && sameCode(effective, row))
|
|
12215
12215
|
continue;
|
|
12216
12216
|
effective = row;
|
|
12217
12217
|
}
|
|
@@ -12242,16 +12242,22 @@ function checkVerdicts(cwd, branch, rows) {
|
|
|
12242
12242
|
const head = branchHead(cwd, branch);
|
|
12243
12243
|
const fallbackBase = defaultBase(cwd);
|
|
12244
12244
|
const keyCache = new Map;
|
|
12245
|
-
const
|
|
12246
|
-
if (!base || !
|
|
12245
|
+
const keysAt = (base, at) => {
|
|
12246
|
+
if (!base || !at)
|
|
12247
12247
|
return { patchId: null, diffHash: null };
|
|
12248
|
-
|
|
12248
|
+
const cacheKey = `${base}\x00${at}`;
|
|
12249
|
+
let key = keyCache.get(cacheKey);
|
|
12249
12250
|
if (!key) {
|
|
12250
|
-
key = { patchId: patchId(cwd, base,
|
|
12251
|
-
keyCache.set(
|
|
12251
|
+
key = { patchId: patchId(cwd, base, at), diffHash: diffHash(cwd, base, at) };
|
|
12252
|
+
keyCache.set(cacheKey, key);
|
|
12252
12253
|
}
|
|
12253
12254
|
return key;
|
|
12254
12255
|
};
|
|
12256
|
+
const keyFor = (base) => keysAt(base, head);
|
|
12257
|
+
const sameCode = (failed, row) => verdictBasis(failed, {
|
|
12258
|
+
head: row.head,
|
|
12259
|
+
...keysAt(failed.base ?? fallbackBase, row.head)
|
|
12260
|
+
}) !== "stale" || restackCarries(rows, branch, failed.head, row.head);
|
|
12255
12261
|
const authors = authorSessions(cwd, rows, branch, { base: fallbackBase, head });
|
|
12256
12262
|
const byKind = new Map;
|
|
12257
12263
|
for (const row of rows)
|
|
@@ -12261,7 +12267,7 @@ function checkVerdicts(cwd, branch, rows) {
|
|
|
12261
12267
|
}
|
|
12262
12268
|
const verdicts = [];
|
|
12263
12269
|
for (const [kind, list] of byKind) {
|
|
12264
|
-
const row = effectiveOf(list, authors);
|
|
12270
|
+
const row = effectiveOf(list, authors, sameCode);
|
|
12265
12271
|
if (!row)
|
|
12266
12272
|
continue;
|
|
12267
12273
|
let basis = verdictBasis(row, { head, ...keyFor(row.base ?? fallbackBase) });
|
|
@@ -12287,11 +12293,11 @@ function checkVerdicts(cwd, branch, rows) {
|
|
|
12287
12293
|
verdicts.sort((a, b) => a.verdict.seq - b.verdict.seq);
|
|
12288
12294
|
const newestCurrent = verdicts.findLast((entry) => entry.current) ?? verdicts.at(-1) ?? null;
|
|
12289
12295
|
const failing = verdicts.find((entry) => entry.current && entry.independent && FAILING.has(String(entry.verdict.result)));
|
|
12290
|
-
const newestAccepted = verdicts.findLast((entry) => entry.accepted) ?? null;
|
|
12296
|
+
const newestAccepted = verdicts.findLast((entry) => entry.accepted && STRONG_RESULTS.has(String(entry.verdict.result))) ?? null;
|
|
12291
12297
|
const accepted = newestAccepted && !failing ? { accepted: true, verdict: newestAccepted.verdict, reasons: [] } : {
|
|
12292
12298
|
accepted: false,
|
|
12293
12299
|
verdict: failing?.verdict ?? null,
|
|
12294
|
-
reasons: failing ? ["failing_verdict"] : newestCurrent
|
|
12300
|
+
reasons: failing ? ["failing_verdict"] : !newestCurrent ? ["no_verdict"] : newestCurrent.reasons.length ? newestCurrent.reasons : ["type_check_only"]
|
|
12295
12301
|
};
|
|
12296
12302
|
const selfEntry = failing ? undefined : verdicts.findLast((entry) => entry.current && !entry.independent && STRONG_RESULTS.has(String(entry.verdict.result)));
|
|
12297
12303
|
return {
|
|
@@ -12307,9 +12313,9 @@ function checkVerdicts(cwd, branch, rows) {
|
|
|
12307
12313
|
authors: [...authors].toSorted()
|
|
12308
12314
|
};
|
|
12309
12315
|
}
|
|
12310
|
-
var OBSERVED_ONLY = new Set(["check", ...PR_ROW_TYPES]);
|
|
12316
|
+
var OBSERVED_ONLY = new Set(["check", "merge.unverified", ...PR_ROW_TYPES]);
|
|
12311
12317
|
|
|
12312
|
-
// packages/workit-
|
|
12318
|
+
// packages/workit-core/src/core/policy/derive.ts
|
|
12313
12319
|
var RULES = {
|
|
12314
12320
|
test: "check:test",
|
|
12315
12321
|
self: "verdict:self",
|
|
@@ -12508,7 +12514,7 @@ function writeBlockers(task, root) {
|
|
|
12508
12514
|
});
|
|
12509
12515
|
}
|
|
12510
12516
|
|
|
12511
|
-
// packages/workit-
|
|
12517
|
+
// packages/workit-core/src/core/task-evaluation.ts
|
|
12512
12518
|
var digestBytes = (value) => createHash7("sha256").update(value).digest("hex");
|
|
12513
12519
|
var inside = (root, candidate) => candidate === root || candidate.startsWith(`${root}${path11.sep}`);
|
|
12514
12520
|
var relative = (root, candidate) => path11.relative(root, candidate).split(path11.sep).join("/") || ".";
|
|
@@ -13174,10 +13180,10 @@ function evaluateClosure(requestedOutcome, view) {
|
|
|
13174
13180
|
});
|
|
13175
13181
|
}
|
|
13176
13182
|
|
|
13177
|
-
// packages/workit-
|
|
13183
|
+
// packages/workit-core/src/core/task-engine.ts
|
|
13178
13184
|
import { realpathSync as realpathSync4 } from "node:fs";
|
|
13179
13185
|
|
|
13180
|
-
// packages/workit-
|
|
13186
|
+
// packages/workit-core/src/core/policy-resolver.ts
|
|
13181
13187
|
function resolvePolicy(input) {
|
|
13182
13188
|
const ids = input.constraints.map((constraint) => constraint.id);
|
|
13183
13189
|
if (new Set(ids).size !== ids.length)
|
|
@@ -13233,7 +13239,7 @@ function diffPolicy(previous, next, reason, now) {
|
|
|
13233
13239
|
return parsed.data;
|
|
13234
13240
|
}
|
|
13235
13241
|
|
|
13236
|
-
// packages/workit-
|
|
13242
|
+
// packages/workit-core/src/core/operation-input.ts
|
|
13237
13243
|
var str2 = (d, values) => ({
|
|
13238
13244
|
type: "string",
|
|
13239
13245
|
...values ? { enum: values } : {},
|
|
@@ -13579,7 +13585,7 @@ function normalizeOperationInput(family, input, host) {
|
|
|
13579
13585
|
return request;
|
|
13580
13586
|
}
|
|
13581
13587
|
|
|
13582
|
-
// packages/workit-
|
|
13588
|
+
// packages/workit-core/src/core/policy/judgment.ts
|
|
13583
13589
|
var isObject6 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
13584
13590
|
var squash = (key) => key.toLowerCase().replace(/[_-]/g, "");
|
|
13585
13591
|
var ALIASES = {
|
|
@@ -13703,11 +13709,11 @@ function normalizeJudgment(raw, previous) {
|
|
|
13703
13709
|
return success(null, null, { judgment: parsed.data, ignored, legacy });
|
|
13704
13710
|
}
|
|
13705
13711
|
|
|
13706
|
-
// packages/workit-
|
|
13712
|
+
// packages/workit-core/src/autonomy.ts
|
|
13707
13713
|
import os3 from "node:os";
|
|
13708
13714
|
import path14 from "node:path";
|
|
13709
13715
|
|
|
13710
|
-
// packages/workit-
|
|
13716
|
+
// packages/workit-core/src/core/config.ts
|
|
13711
13717
|
import {
|
|
13712
13718
|
copyFileSync as copyFileSync2,
|
|
13713
13719
|
cpSync as cpSync2,
|
|
@@ -13720,7 +13726,7 @@ import {
|
|
|
13720
13726
|
import os2 from "node:os";
|
|
13721
13727
|
import path12 from "node:path";
|
|
13722
13728
|
|
|
13723
|
-
// packages/workit-
|
|
13729
|
+
// packages/workit-core/src/core/boundary.ts
|
|
13724
13730
|
var EVENT = {
|
|
13725
13731
|
initialization: "initialization",
|
|
13726
13732
|
provenance: "provenance",
|
|
@@ -13741,7 +13747,7 @@ var errorDetail = (err) => {
|
|
|
13741
13747
|
return { error_name: "unknown", error: String(err) };
|
|
13742
13748
|
};
|
|
13743
13749
|
|
|
13744
|
-
// packages/workit-
|
|
13750
|
+
// packages/workit-core/src/core/config.ts
|
|
13745
13751
|
var diagnosticLogger;
|
|
13746
13752
|
var PRESETS = {
|
|
13747
13753
|
gitflow: {
|
|
@@ -13816,6 +13822,7 @@ var DEFAULTS = {
|
|
|
13816
13822
|
},
|
|
13817
13823
|
commitPolicy: { preset: "conventional" }
|
|
13818
13824
|
};
|
|
13825
|
+
var unchosenBranchPolicy = new WeakSet([DEFAULTS]);
|
|
13819
13826
|
var readSafe = (p) => {
|
|
13820
13827
|
try {
|
|
13821
13828
|
return readFileSync3(p, "utf8");
|
|
@@ -13840,22 +13847,21 @@ var parseConfigResult = (raw, file) => {
|
|
|
13840
13847
|
const locale = LOCALE_RE.test(String(input.locale ?? "")) ? input.locale : DEFAULTS.locale;
|
|
13841
13848
|
const preset = Object.hasOwn(PRESETS, input.branchPolicy?.preset) ? input.branchPolicy?.preset : "gitflow";
|
|
13842
13849
|
const commitPreset = COMMIT_PRESETS.includes(String(input.commitPolicy?.preset ?? "")) ? input.commitPolicy?.preset : "conventional";
|
|
13843
|
-
|
|
13844
|
-
|
|
13845
|
-
|
|
13846
|
-
|
|
13847
|
-
|
|
13848
|
-
|
|
13849
|
-
|
|
13850
|
-
|
|
13851
|
-
|
|
13852
|
-
}
|
|
13853
|
-
commitPolicy: {
|
|
13854
|
-
preset: commitPreset,
|
|
13855
|
-
...typeof input.commitPolicy?.pattern === "string" ? { pattern: input.commitPolicy.pattern } : {}
|
|
13856
|
-
}
|
|
13850
|
+
const config = {
|
|
13851
|
+
locale,
|
|
13852
|
+
localeOptions: Array.isArray(input.localeOptions) ? input.localeOptions : DEFAULTS.localeOptions,
|
|
13853
|
+
branchPolicy: mergePreset(preset, {
|
|
13854
|
+
allowed: Array.isArray(input.branchPolicy?.allowed) ? input.branchPolicy.allowed : undefined,
|
|
13855
|
+
protectedNames: Array.isArray(input.branchPolicy?.protected) ? input.branchPolicy.protected : undefined
|
|
13856
|
+
}, DEFAULTS),
|
|
13857
|
+
commitPolicy: {
|
|
13858
|
+
preset: commitPreset,
|
|
13859
|
+
...typeof input.commitPolicy?.pattern === "string" ? { pattern: input.commitPolicy.pattern } : {}
|
|
13857
13860
|
}
|
|
13858
13861
|
};
|
|
13862
|
+
if (!Object.hasOwn(PRESETS, input.branchPolicy?.preset))
|
|
13863
|
+
unchosenBranchPolicy.add(config);
|
|
13864
|
+
return { status: "valid", path: file, config };
|
|
13859
13865
|
};
|
|
13860
13866
|
var readConfigTyped = (dir) => {
|
|
13861
13867
|
const file = path12.join(dir ?? configDir(), "config.json");
|
|
@@ -13868,9 +13874,11 @@ var readConfig = () => {
|
|
|
13868
13874
|
return result.config ?? DEFAULTS;
|
|
13869
13875
|
};
|
|
13870
13876
|
var branchGlobPattern = (glob) => new RegExp(`^${glob.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*")}$`, "i");
|
|
13871
|
-
var resolveBranchPolicy = (config, workspace) => {
|
|
13877
|
+
var resolveBranchPolicy = (config, workspace, repoPreset) => {
|
|
13872
13878
|
const wp = workspace?.branchPolicy ?? {};
|
|
13873
|
-
const
|
|
13879
|
+
const workspacePreset = Object.hasOwn(PRESETS, wp.preset);
|
|
13880
|
+
const detected = !workspacePreset && unchosenBranchPolicy.has(config) ? repoPreset?.() ?? null : null;
|
|
13881
|
+
const preset = workspacePreset ? wp.preset : detected ?? config.branchPolicy?.preset ?? "gitflow";
|
|
13874
13882
|
const merged = mergePreset(preset, {
|
|
13875
13883
|
allowed: wp.allowed,
|
|
13876
13884
|
protectedNames: wp.protected
|
|
@@ -13879,9 +13887,10 @@ var resolveBranchPolicy = (config, workspace) => {
|
|
|
13879
13887
|
return {
|
|
13880
13888
|
preset,
|
|
13881
13889
|
allowed,
|
|
13882
|
-
protected: new Set(merged.protected.map((p) => p.toLowerCase())),
|
|
13890
|
+
protected: new Set([...merged.protected, ...detected ? PRESETS.gitflow.protected : []].map((p) => p.toLowerCase())),
|
|
13883
13891
|
integration: wp.integration === "merge" ? "merge" : "pr",
|
|
13884
|
-
defaultTargetBranch: preset === "github-flow" ? "main" : preset === "trunk-based" ? "master" : "develop"
|
|
13892
|
+
defaultTargetBranch: preset === "github-flow" ? "main" : preset === "trunk-based" ? "master" : "develop",
|
|
13893
|
+
detected: detected !== null
|
|
13885
13894
|
};
|
|
13886
13895
|
};
|
|
13887
13896
|
var COMMIT_PRESETS = [
|
|
@@ -13903,10 +13912,77 @@ var resolveCommitPolicy = (config, workspace) => {
|
|
|
13903
13912
|
return config.commitPolicy ?? { preset: "conventional" };
|
|
13904
13913
|
};
|
|
13905
13914
|
|
|
13906
|
-
// packages/workit-
|
|
13915
|
+
// packages/workit-core/src/core/workspaces.ts
|
|
13907
13916
|
import { createHash as createHash8 } from "node:crypto";
|
|
13908
13917
|
import { readFileSync as readFileSync4, realpathSync as realpathSync3 } from "node:fs";
|
|
13909
13918
|
import path13 from "node:path";
|
|
13919
|
+
|
|
13920
|
+
// packages/workit-core/src/core/branch-policy.ts
|
|
13921
|
+
import { spawnSync as spawnSync7 } from "node:child_process";
|
|
13922
|
+
var PREFIXES = {
|
|
13923
|
+
feature: "feature/*",
|
|
13924
|
+
bugfix: "bugfix/*",
|
|
13925
|
+
release: "release/*",
|
|
13926
|
+
hotfix: "hotfix/*"
|
|
13927
|
+
};
|
|
13928
|
+
var branchNames = (workspaceRoot) => {
|
|
13929
|
+
const r = spawnSync7("git", ["for-each-ref", "--format=%(refname)", "refs/heads", "refs/remotes/origin"], { cwd: workspaceRoot, encoding: "utf8" });
|
|
13930
|
+
if (r.status !== 0)
|
|
13931
|
+
return new Set;
|
|
13932
|
+
return new Set((r.stdout ?? "").split(`
|
|
13933
|
+
`).filter(Boolean).map((ref) => ref.startsWith("refs/heads/") ? ref.slice("refs/heads/".length) : ref.slice("refs/remotes/origin/".length)));
|
|
13934
|
+
};
|
|
13935
|
+
var detectBranchPolicy = (workspaceRoot) => {
|
|
13936
|
+
const names = branchNames(workspaceRoot);
|
|
13937
|
+
const develop = names.has("develop");
|
|
13938
|
+
const main = names.has("main");
|
|
13939
|
+
const master = names.has("master");
|
|
13940
|
+
const root = main ? "main" : master ? "master" : null;
|
|
13941
|
+
if (develop) {
|
|
13942
|
+
return {
|
|
13943
|
+
preset: "gitflow",
|
|
13944
|
+
developBranch: "develop",
|
|
13945
|
+
integration: "merge",
|
|
13946
|
+
protected: root ? [root, "develop"] : ["develop"],
|
|
13947
|
+
allowed: [...PRESETS.gitflow.allowed],
|
|
13948
|
+
prefixes: PREFIXES
|
|
13949
|
+
};
|
|
13950
|
+
}
|
|
13951
|
+
if (root === "main") {
|
|
13952
|
+
return {
|
|
13953
|
+
preset: "github-flow",
|
|
13954
|
+
developBranch: null,
|
|
13955
|
+
integration: "pr",
|
|
13956
|
+
protected: [root],
|
|
13957
|
+
allowed: ["*"],
|
|
13958
|
+
prefixes: PREFIXES
|
|
13959
|
+
};
|
|
13960
|
+
}
|
|
13961
|
+
if (root === "master") {
|
|
13962
|
+
return {
|
|
13963
|
+
preset: "trunk-based",
|
|
13964
|
+
developBranch: null,
|
|
13965
|
+
integration: "pr",
|
|
13966
|
+
protected: [root],
|
|
13967
|
+
allowed: ["*"],
|
|
13968
|
+
prefixes: PREFIXES
|
|
13969
|
+
};
|
|
13970
|
+
}
|
|
13971
|
+
return {
|
|
13972
|
+
preset: "gitflow",
|
|
13973
|
+
developBranch: null,
|
|
13974
|
+
integration: "merge",
|
|
13975
|
+
protected: [],
|
|
13976
|
+
allowed: [],
|
|
13977
|
+
prefixes: PREFIXES
|
|
13978
|
+
};
|
|
13979
|
+
};
|
|
13980
|
+
var repoBranchPreset = (workspaceRoot) => {
|
|
13981
|
+
const detected = detectBranchPolicy(workspaceRoot);
|
|
13982
|
+
return detected.developBranch || detected.allowed.length ? detected.preset : null;
|
|
13983
|
+
};
|
|
13984
|
+
|
|
13985
|
+
// packages/workit-core/src/core/workspaces.ts
|
|
13910
13986
|
var nonBlank = string2().refine((value) => value.trim().length > 0, "must not be blank");
|
|
13911
13987
|
var branchPreset = custom((value) => typeof value === "string" && Object.hasOwn(PRESETS, value), "unsupported branch preset");
|
|
13912
13988
|
var commitPreset = custom((value) => typeof value === "string" && COMMIT_PRESETS.includes(value), "unsupported commit preset");
|
|
@@ -14303,7 +14379,7 @@ var resolveRuntimeWorkspacePolicy = (cwd, kind, requestedProfile) => {
|
|
|
14303
14379
|
};
|
|
14304
14380
|
};
|
|
14305
14381
|
|
|
14306
|
-
// packages/workit-
|
|
14382
|
+
// packages/workit-core/src/autonomy.ts
|
|
14307
14383
|
var accountHome = () => {
|
|
14308
14384
|
try {
|
|
14309
14385
|
return os3.userInfo().homedir;
|
|
@@ -14438,12 +14514,12 @@ function resolveAutonomy(cwd) {
|
|
|
14438
14514
|
var suggested = (kind) => kind === "merge" ? "verified" : "true";
|
|
14439
14515
|
var grantHint = (workspace, kind) => `ask the user to run, in their own terminal: workit grant set ${workspace ?? "<workspace>"} ${kind}=${suggested(kind)}`;
|
|
14440
14516
|
|
|
14441
|
-
// packages/workit-
|
|
14517
|
+
// packages/workit-core/src/core/workers.ts
|
|
14442
14518
|
var UNCERTAIN_WORKER_STATES = ["dispatching", "running", "cancelling", "unknown"];
|
|
14443
14519
|
var isUncertainWorker = (state) => UNCERTAIN_WORKER_STATES.includes(state);
|
|
14444
14520
|
var workerBlocksTransition = (transition, state) => transition === "pause" ? false : isUncertainWorker(state);
|
|
14445
14521
|
|
|
14446
|
-
// packages/workit-
|
|
14522
|
+
// packages/workit-core/src/core/task-context.ts
|
|
14447
14523
|
function reconcileResume(view, observations = []) {
|
|
14448
14524
|
if (observations.length > 0)
|
|
14449
14525
|
return failure2("permission_denied", "worker observations require native host verification");
|
|
@@ -14558,7 +14634,7 @@ var exportDigest = (bundle) => sha256({
|
|
|
14558
14634
|
task: bundle.task
|
|
14559
14635
|
});
|
|
14560
14636
|
|
|
14561
|
-
// packages/workit-
|
|
14637
|
+
// packages/workit-core/src/core/task-engine.ts
|
|
14562
14638
|
var workspaceVerification = (root) => {
|
|
14563
14639
|
try {
|
|
14564
14640
|
return resolveAutonomy(root).verification;
|
|
@@ -16144,7 +16220,7 @@ class WorkitCore {
|
|
|
16144
16220
|
}
|
|
16145
16221
|
}
|
|
16146
16222
|
|
|
16147
|
-
// packages/workit-
|
|
16223
|
+
// packages/workit-core/src/hooks/context.ts
|
|
16148
16224
|
var MIGRATION_PENDING_NOTE = "workit migration pending — run `workit task status`";
|
|
16149
16225
|
var migrationPending = (result) => !result.ok && result.code === "needs_input" && (result.error ?? "").startsWith(MIGRATION_PENDING);
|
|
16150
16226
|
var boundTo = (entry, session) => entry.sessions.some((item) => item.host === session.host && item.handle === session.handle);
|
|
@@ -16291,10 +16367,10 @@ var turnContextText = (input, descriptor) => {
|
|
|
16291
16367
|
return null;
|
|
16292
16368
|
}
|
|
16293
16369
|
};
|
|
16294
|
-
// packages/workit-
|
|
16370
|
+
// packages/workit-core/src/core/branch.ts
|
|
16295
16371
|
import { createHash as createHash9 } from "node:crypto";
|
|
16296
16372
|
|
|
16297
|
-
// packages/workit-
|
|
16373
|
+
// packages/workit-core/src/core/release-tracks.ts
|
|
16298
16374
|
class ReleaseTrackError extends Error {
|
|
16299
16375
|
}
|
|
16300
16376
|
var KNOWN_FIELDS = new Set([
|
|
@@ -16433,7 +16509,7 @@ function workspaceReleaseTracks(cwd) {
|
|
|
16433
16509
|
}
|
|
16434
16510
|
var memo3 = new Map;
|
|
16435
16511
|
|
|
16436
|
-
// packages/workit-
|
|
16512
|
+
// packages/workit-core/src/core/branch.ts
|
|
16437
16513
|
var withReleaseTracks = (workspaceRoot, policy) => {
|
|
16438
16514
|
const read = workspaceReleaseTracks(workspaceRoot);
|
|
16439
16515
|
if (read.error)
|
|
@@ -16462,7 +16538,7 @@ function effectiveWorkspacePolicy(workspaceRoot, kind, profileName) {
|
|
|
16462
16538
|
const selected = resolveRuntimeWorkspacePolicy(workspaceRoot, kind, profileName?.trim() || process.env.WORKFLOW_PROFILE?.trim() || undefined);
|
|
16463
16539
|
const config = readConfig();
|
|
16464
16540
|
return kind === "branch" ? {
|
|
16465
|
-
branchPolicy: withReleaseTracks(workspaceRoot, resolveBranchPolicy(config, selected.policy ? { branchPolicy: selected.policy } : null)),
|
|
16541
|
+
branchPolicy: withReleaseTracks(workspaceRoot, resolveBranchPolicy(config, selected.policy ? { branchPolicy: selected.policy } : null, () => repoBranchPreset(workspaceRoot))),
|
|
16466
16542
|
provenance: { branchPolicy: selected.source }
|
|
16467
16543
|
} : {
|
|
16468
16544
|
commitPolicy: resolveCommitPolicy(config, selected.policy ? { commitPolicy: selected.policy } : null),
|
|
@@ -16526,7 +16602,7 @@ var validateBranchNameFor = (workspaceRoot, name) => {
|
|
|
16526
16602
|
}
|
|
16527
16603
|
};
|
|
16528
16604
|
|
|
16529
|
-
// packages/workit-
|
|
16605
|
+
// packages/workit-core/src/core/route-intent.ts
|
|
16530
16606
|
var shellBranchTarget = (command) => {
|
|
16531
16607
|
if (!command.trim() || /[\r\n;&|<>`'"$()\\*?{}~!#]/u.test(command) || command.includes("[") || command.includes("]"))
|
|
16532
16608
|
return null;
|
|
@@ -16542,12 +16618,12 @@ var shellBranchPolicyViolation = (root, command) => {
|
|
|
16542
16618
|
return target === null ? null : validateBranchNameFor(root, target);
|
|
16543
16619
|
};
|
|
16544
16620
|
|
|
16545
|
-
// packages/workit-
|
|
16621
|
+
// packages/workit-core/src/hooks/policy.ts
|
|
16546
16622
|
var shellPolicy = (cwd, command) => {
|
|
16547
16623
|
const policy = shellBranchPolicyViolation(cwd, command);
|
|
16548
16624
|
return policy && !policy.ok ? { kind: "deny", reason: `branch_policy_denied: ${policy.error}`, unblock: null } : { kind: "none" };
|
|
16549
16625
|
};
|
|
16550
|
-
// packages/workit-
|
|
16626
|
+
// packages/workit-core/src/hooks/write-gate.ts
|
|
16551
16627
|
import { realpathSync as realpathSync5 } from "node:fs";
|
|
16552
16628
|
import path16 from "node:path";
|
|
16553
16629
|
var NONE2 = { kind: "none" };
|
|
@@ -16659,11 +16735,11 @@ var segmentsOf = (command) => {
|
|
|
16659
16735
|
flushSegment();
|
|
16660
16736
|
return segments;
|
|
16661
16737
|
};
|
|
16662
|
-
var
|
|
16738
|
+
var PREFIXES2 = new Set(["sudo", "command", "env", "nohup", "time", "exec", "xargs"]);
|
|
16663
16739
|
var operands = (words) => words.filter((item) => !item.startsWith("-"));
|
|
16664
16740
|
var editsOf = (input) => {
|
|
16665
16741
|
let words = input;
|
|
16666
|
-
while (words.length && (
|
|
16742
|
+
while (words.length && (PREFIXES2.has(words[0]) || /^\w+=/.test(words[0])))
|
|
16667
16743
|
words = words.slice(1);
|
|
16668
16744
|
const [verb, ...args] = words;
|
|
16669
16745
|
const name = (verb?.split(/[\\/]/).at(-1) ?? "").toLowerCase();
|
|
@@ -16808,7 +16884,7 @@ function writeGate(cwd, paths) {
|
|
|
16808
16884
|
return NONE2;
|
|
16809
16885
|
}
|
|
16810
16886
|
}
|
|
16811
|
-
// packages/workit-
|
|
16887
|
+
// packages/workit-core/src/hooks/hosts/fields.ts
|
|
16812
16888
|
import { existsSync as existsSync6, realpathSync as realpathSync6, statSync as statSync2 } from "node:fs";
|
|
16813
16889
|
import path17 from "node:path";
|
|
16814
16890
|
var isRecord4 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
@@ -16876,7 +16952,7 @@ var writePaths = (input) => {
|
|
|
16876
16952
|
paths.push(match[1].trim());
|
|
16877
16953
|
return [...new Set(paths)];
|
|
16878
16954
|
};
|
|
16879
|
-
// packages/workit-
|
|
16955
|
+
// packages/workit-core/src/hooks/handle.ts
|
|
16880
16956
|
var usable2 = (value) => value === "native" || value === "partial";
|
|
16881
16957
|
var NONE3 = { kind: "none" };
|
|
16882
16958
|
var offered = new Set;
|
|
@@ -16972,7 +17048,7 @@ var dispatchHook = (adapter, raw, env = process.env) => {
|
|
|
16972
17048
|
};
|
|
16973
17049
|
}
|
|
16974
17050
|
};
|
|
16975
|
-
// packages/workit-
|
|
17051
|
+
// packages/workit-core/src/hooks/hosts/claude-code.ts
|
|
16976
17052
|
var CLAUDE_CODE_DESCRIPTOR = {
|
|
16977
17053
|
host: "claude_code",
|
|
16978
17054
|
label: "Claude Code",
|
|
@@ -17215,7 +17291,7 @@ var claudeCodeAdapter = {
|
|
|
17215
17291
|
render
|
|
17216
17292
|
};
|
|
17217
17293
|
|
|
17218
|
-
// packages/workit-
|
|
17294
|
+
// packages/workit-core/src/hooks/hosts/codex.ts
|
|
17219
17295
|
function detectCodexSurface(env) {
|
|
17220
17296
|
return env.CODEX_INTERNAL_ORIGINATOR_OVERRIDE === "Codex Desktop" || Boolean(env.CODEX_ELECTRON_RESOURCES_PATH) ? "codex_desktop" : "codex_cli";
|
|
17221
17297
|
}
|
|
@@ -17444,7 +17520,7 @@ var codexAdapter = {
|
|
|
17444
17520
|
addendum: (input) => `<workit-codex-mutations>Codex MCP is read-only: unattested callers cannot mutate. Run workit verbs with the workit CLI on the shell (node_modules/.bin/workit, or npx -y @brainervirus/workit-cli): check, git branch|commit|push, pr, ci, stack, ledger, handoff; task-family mutations take --json${input.session.id ? ` --actor ${input.session.id}` : ""}. A verifier or reviewer records workit ledger verdict under a session the lead assigns (WORKIT_SESSION_ID=<lead>-v<n>), never the author's. Merge and release need a workspace grant (workit grant show); a question answer is not host permission.</workit-codex-mutations>`
|
|
17445
17521
|
};
|
|
17446
17522
|
|
|
17447
|
-
// packages/workit-
|
|
17523
|
+
// packages/workit-core/src/hooks/hosts/cursor.ts
|
|
17448
17524
|
import path18 from "node:path";
|
|
17449
17525
|
var undocumented2 = { support: "undocumented", native: null };
|
|
17450
17526
|
var none = { support: "none", native: null };
|
|
@@ -17688,7 +17764,7 @@ var cursorAdapter = {
|
|
|
17688
17764
|
render: render3
|
|
17689
17765
|
};
|
|
17690
17766
|
|
|
17691
|
-
// packages/workit-
|
|
17767
|
+
// packages/workit-core/src/hooks/run.ts
|
|
17692
17768
|
var HOOK_ADAPTERS = {
|
|
17693
17769
|
claude_code: claudeCodeAdapter,
|
|
17694
17770
|
codex_cli: codexAdapter,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brainervirus/workit-codex",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.1.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Workit Codex CLI/desktop plugin — shared MCP transport, hooks, and sixteen method skills",
|
|
6
6
|
"keywords": [
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"build": "bun scripts/build.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@brainervirus/workit-core": "^8.
|
|
42
|
-
"@brainervirus/workit-mcp": "^8.
|
|
41
|
+
"@brainervirus/workit-core": "^8.1.0",
|
|
42
|
+
"@brainervirus/workit-mcp": "^8.1.0"
|
|
43
43
|
},
|
|
44
44
|
"engines": {
|
|
45
45
|
"node": ">=24"
|