@brainervirus/workit-cursor 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/.cursor-plugin/plugin.json +1 -1
- package/dist/cursor-session-start.js +165 -88
- package/dist/mcp-server.js +252 -176
- package/dist/workit-hook.js +163 -87
- package/package.json +3 -3
|
@@ -7622,7 +7622,7 @@ var init_zod = __esm(() => {
|
|
|
7622
7622
|
init_external();
|
|
7623
7623
|
});
|
|
7624
7624
|
|
|
7625
|
-
// packages/workit-
|
|
7625
|
+
// packages/workit-core/src/core/task-contract.ts
|
|
7626
7626
|
import { createHash, randomUUID } from "node:crypto";
|
|
7627
7627
|
function parseOperation(family, input) {
|
|
7628
7628
|
if (typeof input === "object" && input !== null && "schemaVersion" in input && input.schemaVersion !== SCHEMA_VERSION)
|
|
@@ -8460,7 +8460,7 @@ var init_task_contract = __esm(() => {
|
|
|
8460
8460
|
compiledOperationSchemas = Object.fromEntries(OPERATION_FAMILIES.map((family) => [family, compile(operationSchemas[family])]));
|
|
8461
8461
|
});
|
|
8462
8462
|
|
|
8463
|
-
// packages/workit-
|
|
8463
|
+
// packages/workit-core/src/git/rev.ts
|
|
8464
8464
|
import { spawnSync } from "node:child_process";
|
|
8465
8465
|
import { createHash as createHash2 } from "node:crypto";
|
|
8466
8466
|
import fs from "node:fs";
|
|
@@ -8610,7 +8610,7 @@ var init_rev = __esm(() => {
|
|
|
8610
8610
|
MAX_UNTRACKED_BYTES = 5 * 1024 * 1024;
|
|
8611
8611
|
});
|
|
8612
8612
|
|
|
8613
|
-
// packages/workit-
|
|
8613
|
+
// packages/workit-core/src/store/paths.ts
|
|
8614
8614
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
8615
8615
|
import { createHash as createHash3 } from "node:crypto";
|
|
8616
8616
|
import fs2 from "node:fs";
|
|
@@ -8886,7 +8886,7 @@ var init_paths = __esm(() => {
|
|
|
8886
8886
|
];
|
|
8887
8887
|
});
|
|
8888
8888
|
|
|
8889
|
-
// packages/workit-
|
|
8889
|
+
// packages/workit-core/src/ledger.ts
|
|
8890
8890
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
8891
8891
|
import { createHash as createHash4, randomBytes } from "node:crypto";
|
|
8892
8892
|
import fs3 from "node:fs";
|
|
@@ -9056,7 +9056,7 @@ function authorSessions(cwd, rows, branch, range = { base: null, head: null }) {
|
|
|
9056
9056
|
sessions.add(session);
|
|
9057
9057
|
return sessions;
|
|
9058
9058
|
}
|
|
9059
|
-
function effectiveOf(rows, authors) {
|
|
9059
|
+
function effectiveOf(rows, authors, sameCode) {
|
|
9060
9060
|
let effective = null;
|
|
9061
9061
|
for (const row of rows) {
|
|
9062
9062
|
if (!effective) {
|
|
@@ -9067,7 +9067,7 @@ function effectiveOf(rows, authors) {
|
|
|
9067
9067
|
const effIndependent = independenceReasons(effective, authors).length === 0;
|
|
9068
9068
|
if (effIndependent && !rowIndependent)
|
|
9069
9069
|
continue;
|
|
9070
|
-
if (effIndependent && FAILING.has(String(effective.result)) && row.actor.session === effective.actor.session)
|
|
9070
|
+
if (effIndependent && FAILING.has(String(effective.result)) && row.actor.session === effective.actor.session && sameCode(effective, row))
|
|
9071
9071
|
continue;
|
|
9072
9072
|
effective = row;
|
|
9073
9073
|
}
|
|
@@ -9098,16 +9098,22 @@ function checkVerdicts(cwd, branch, rows) {
|
|
|
9098
9098
|
const head = branchHead(cwd, branch);
|
|
9099
9099
|
const fallbackBase = defaultBase(cwd);
|
|
9100
9100
|
const keyCache = new Map;
|
|
9101
|
-
const
|
|
9102
|
-
if (!base || !
|
|
9101
|
+
const keysAt = (base, at) => {
|
|
9102
|
+
if (!base || !at)
|
|
9103
9103
|
return { patchId: null, diffHash: null };
|
|
9104
|
-
|
|
9104
|
+
const cacheKey = `${base}\x00${at}`;
|
|
9105
|
+
let key = keyCache.get(cacheKey);
|
|
9105
9106
|
if (!key) {
|
|
9106
|
-
key = { patchId: patchId(cwd, base,
|
|
9107
|
-
keyCache.set(
|
|
9107
|
+
key = { patchId: patchId(cwd, base, at), diffHash: diffHash(cwd, base, at) };
|
|
9108
|
+
keyCache.set(cacheKey, key);
|
|
9108
9109
|
}
|
|
9109
9110
|
return key;
|
|
9110
9111
|
};
|
|
9112
|
+
const keyFor = (base) => keysAt(base, head);
|
|
9113
|
+
const sameCode = (failed, row) => verdictBasis(failed, {
|
|
9114
|
+
head: row.head,
|
|
9115
|
+
...keysAt(failed.base ?? fallbackBase, row.head)
|
|
9116
|
+
}) !== "stale" || restackCarries(rows, branch, failed.head, row.head);
|
|
9111
9117
|
const authors = authorSessions(cwd, rows, branch, { base: fallbackBase, head });
|
|
9112
9118
|
const byKind = new Map;
|
|
9113
9119
|
for (const row of rows)
|
|
@@ -9117,7 +9123,7 @@ function checkVerdicts(cwd, branch, rows) {
|
|
|
9117
9123
|
}
|
|
9118
9124
|
const verdicts = [];
|
|
9119
9125
|
for (const [kind, list] of byKind) {
|
|
9120
|
-
const row = effectiveOf(list, authors);
|
|
9126
|
+
const row = effectiveOf(list, authors, sameCode);
|
|
9121
9127
|
if (!row)
|
|
9122
9128
|
continue;
|
|
9123
9129
|
let basis = verdictBasis(row, { head, ...keyFor(row.base ?? fallbackBase) });
|
|
@@ -9143,11 +9149,11 @@ function checkVerdicts(cwd, branch, rows) {
|
|
|
9143
9149
|
verdicts.sort((a, b) => a.verdict.seq - b.verdict.seq);
|
|
9144
9150
|
const newestCurrent = verdicts.findLast((entry) => entry.current) ?? verdicts.at(-1) ?? null;
|
|
9145
9151
|
const failing = verdicts.find((entry) => entry.current && entry.independent && FAILING.has(String(entry.verdict.result)));
|
|
9146
|
-
const newestAccepted = verdicts.findLast((entry) => entry.accepted) ?? null;
|
|
9152
|
+
const newestAccepted = verdicts.findLast((entry) => entry.accepted && STRONG_RESULTS.has(String(entry.verdict.result))) ?? null;
|
|
9147
9153
|
const accepted = newestAccepted && !failing ? { accepted: true, verdict: newestAccepted.verdict, reasons: [] } : {
|
|
9148
9154
|
accepted: false,
|
|
9149
9155
|
verdict: failing?.verdict ?? null,
|
|
9150
|
-
reasons: failing ? ["failing_verdict"] : newestCurrent
|
|
9156
|
+
reasons: failing ? ["failing_verdict"] : !newestCurrent ? ["no_verdict"] : newestCurrent.reasons.length ? newestCurrent.reasons : ["type_check_only"]
|
|
9151
9157
|
};
|
|
9152
9158
|
const selfEntry = failing ? undefined : verdicts.findLast((entry) => entry.current && !entry.independent && STRONG_RESULTS.has(String(entry.verdict.result)));
|
|
9153
9159
|
return {
|
|
@@ -9229,10 +9235,10 @@ var init_ledger = __esm(() => {
|
|
|
9229
9235
|
1196443219,
|
|
9230
9236
|
198183888
|
|
9231
9237
|
]);
|
|
9232
|
-
OBSERVED_ONLY = new Set(["check", ...PR_ROW_TYPES]);
|
|
9238
|
+
OBSERVED_ONLY = new Set(["check", "merge.unverified", ...PR_ROW_TYPES]);
|
|
9233
9239
|
});
|
|
9234
9240
|
|
|
9235
|
-
// packages/workit-
|
|
9241
|
+
// packages/workit-core/src/core/policy/derive.ts
|
|
9236
9242
|
import { existsSync } from "node:fs";
|
|
9237
9243
|
import path4 from "node:path";
|
|
9238
9244
|
function deriveRequirements(judgment, scope, constraints, verification = "self") {
|
|
@@ -9431,7 +9437,7 @@ var init_derive = __esm(() => {
|
|
|
9431
9437
|
};
|
|
9432
9438
|
});
|
|
9433
9439
|
|
|
9434
|
-
// packages/workit-
|
|
9440
|
+
// packages/workit-core/src/core/policy-resolver.ts
|
|
9435
9441
|
function resolvePolicy(input) {
|
|
9436
9442
|
const ids = input.constraints.map((constraint) => constraint.id);
|
|
9437
9443
|
if (new Set(ids).size !== ids.length)
|
|
@@ -9491,7 +9497,7 @@ var init_policy_resolver = __esm(() => {
|
|
|
9491
9497
|
init_derive();
|
|
9492
9498
|
});
|
|
9493
9499
|
|
|
9494
|
-
// packages/workit-
|
|
9500
|
+
// packages/workit-core/src/core/operation-input.ts
|
|
9495
9501
|
function normalizeOperationInput(family, input, host) {
|
|
9496
9502
|
if (!isObject2(input))
|
|
9497
9503
|
return input;
|
|
@@ -9828,7 +9834,7 @@ var init_operation_input = __esm(() => {
|
|
|
9828
9834
|
]);
|
|
9829
9835
|
});
|
|
9830
9836
|
|
|
9831
|
-
// packages/workit-
|
|
9837
|
+
// packages/workit-core/src/core/policy/judgment.ts
|
|
9832
9838
|
function normalizeJudgment(raw, previous) {
|
|
9833
9839
|
const input = isObject3(raw) ? raw : {};
|
|
9834
9840
|
const legacy = Object.keys(input).some((key) => LEGACY_KEYS.has(key));
|
|
@@ -9953,7 +9959,7 @@ var init_judgment = __esm(() => {
|
|
|
9953
9959
|
};
|
|
9954
9960
|
});
|
|
9955
9961
|
|
|
9956
|
-
// packages/workit-
|
|
9962
|
+
// packages/workit-core/src/core/boundary.ts
|
|
9957
9963
|
var EVENT, errorDetail = (err) => {
|
|
9958
9964
|
if (err instanceof Error) {
|
|
9959
9965
|
return { error_name: err.name, error: err.message };
|
|
@@ -9976,7 +9982,7 @@ var init_boundary = __esm(() => {
|
|
|
9976
9982
|
};
|
|
9977
9983
|
});
|
|
9978
9984
|
|
|
9979
|
-
// packages/workit-
|
|
9985
|
+
// packages/workit-core/src/core/config.ts
|
|
9980
9986
|
import {
|
|
9981
9987
|
copyFileSync,
|
|
9982
9988
|
cpSync,
|
|
@@ -10035,7 +10041,7 @@ var diagnosticLogger, PRESETS, mergePreset = (preset, input = {}, current = {
|
|
|
10035
10041
|
if (!migrationFailed)
|
|
10036
10042
|
migratedDir = dir;
|
|
10037
10043
|
return dir;
|
|
10038
|
-
}, configDir = () => ensureConfigDir(), LOCALE_RE, DEFAULTS, readSafe = (p) => {
|
|
10044
|
+
}, configDir = () => ensureConfigDir(), LOCALE_RE, DEFAULTS, unchosenBranchPolicy, readSafe = (p) => {
|
|
10039
10045
|
try {
|
|
10040
10046
|
return readFileSync(p, "utf8");
|
|
10041
10047
|
} catch {
|
|
@@ -10057,22 +10063,21 @@ var diagnosticLogger, PRESETS, mergePreset = (preset, input = {}, current = {
|
|
|
10057
10063
|
const locale = LOCALE_RE.test(String(input.locale ?? "")) ? input.locale : DEFAULTS.locale;
|
|
10058
10064
|
const preset = Object.hasOwn(PRESETS, input.branchPolicy?.preset) ? input.branchPolicy?.preset : "gitflow";
|
|
10059
10065
|
const commitPreset = COMMIT_PRESETS.includes(String(input.commitPolicy?.preset ?? "")) ? input.commitPolicy?.preset : "conventional";
|
|
10060
|
-
|
|
10061
|
-
|
|
10062
|
-
|
|
10063
|
-
|
|
10064
|
-
|
|
10065
|
-
|
|
10066
|
-
|
|
10067
|
-
|
|
10068
|
-
|
|
10069
|
-
}
|
|
10070
|
-
commitPolicy: {
|
|
10071
|
-
preset: commitPreset,
|
|
10072
|
-
...typeof input.commitPolicy?.pattern === "string" ? { pattern: input.commitPolicy.pattern } : {}
|
|
10073
|
-
}
|
|
10066
|
+
const config = {
|
|
10067
|
+
locale,
|
|
10068
|
+
localeOptions: Array.isArray(input.localeOptions) ? input.localeOptions : DEFAULTS.localeOptions,
|
|
10069
|
+
branchPolicy: mergePreset(preset, {
|
|
10070
|
+
allowed: Array.isArray(input.branchPolicy?.allowed) ? input.branchPolicy.allowed : undefined,
|
|
10071
|
+
protectedNames: Array.isArray(input.branchPolicy?.protected) ? input.branchPolicy.protected : undefined
|
|
10072
|
+
}, DEFAULTS),
|
|
10073
|
+
commitPolicy: {
|
|
10074
|
+
preset: commitPreset,
|
|
10075
|
+
...typeof input.commitPolicy?.pattern === "string" ? { pattern: input.commitPolicy.pattern } : {}
|
|
10074
10076
|
}
|
|
10075
10077
|
};
|
|
10078
|
+
if (!Object.hasOwn(PRESETS, input.branchPolicy?.preset))
|
|
10079
|
+
unchosenBranchPolicy.add(config);
|
|
10080
|
+
return { status: "valid", path: file, config };
|
|
10076
10081
|
}, readConfigTyped = (dir) => {
|
|
10077
10082
|
const file = path5.join(dir ?? configDir(), "config.json");
|
|
10078
10083
|
return parseConfigResult(readSafe(file), file);
|
|
@@ -10081,9 +10086,11 @@ var diagnosticLogger, PRESETS, mergePreset = (preset, input = {}, current = {
|
|
|
10081
10086
|
if (result.status === "malformed")
|
|
10082
10087
|
throw new Error(result.error);
|
|
10083
10088
|
return result.config ?? DEFAULTS;
|
|
10084
|
-
}, branchGlobPattern = (glob) => new RegExp(`^${glob.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*")}$`, "i"), resolveBranchPolicy = (config, workspace) => {
|
|
10089
|
+
}, branchGlobPattern = (glob) => new RegExp(`^${glob.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*")}$`, "i"), resolveBranchPolicy = (config, workspace, repoPreset) => {
|
|
10085
10090
|
const wp = workspace?.branchPolicy ?? {};
|
|
10086
|
-
const
|
|
10091
|
+
const workspacePreset = Object.hasOwn(PRESETS, wp.preset);
|
|
10092
|
+
const detected = !workspacePreset && unchosenBranchPolicy.has(config) ? repoPreset?.() ?? null : null;
|
|
10093
|
+
const preset = workspacePreset ? wp.preset : detected ?? config.branchPolicy?.preset ?? "gitflow";
|
|
10087
10094
|
const merged = mergePreset(preset, {
|
|
10088
10095
|
allowed: wp.allowed,
|
|
10089
10096
|
protectedNames: wp.protected
|
|
@@ -10092,9 +10099,10 @@ var diagnosticLogger, PRESETS, mergePreset = (preset, input = {}, current = {
|
|
|
10092
10099
|
return {
|
|
10093
10100
|
preset,
|
|
10094
10101
|
allowed,
|
|
10095
|
-
protected: new Set(merged.protected.map((p) => p.toLowerCase())),
|
|
10102
|
+
protected: new Set([...merged.protected, ...detected ? PRESETS.gitflow.protected : []].map((p) => p.toLowerCase())),
|
|
10096
10103
|
integration: wp.integration === "merge" ? "merge" : "pr",
|
|
10097
|
-
defaultTargetBranch: preset === "github-flow" ? "main" : preset === "trunk-based" ? "master" : "develop"
|
|
10104
|
+
defaultTargetBranch: preset === "github-flow" ? "main" : preset === "trunk-based" ? "master" : "develop",
|
|
10105
|
+
detected: detected !== null
|
|
10098
10106
|
};
|
|
10099
10107
|
}, COMMIT_PRESETS, resolveCommitPolicy = (config, workspace) => {
|
|
10100
10108
|
const wp = workspace?.commitPolicy ?? {};
|
|
@@ -10128,6 +10136,7 @@ var init_config = __esm(() => {
|
|
|
10128
10136
|
},
|
|
10129
10137
|
commitPolicy: { preset: "conventional" }
|
|
10130
10138
|
};
|
|
10139
|
+
unchosenBranchPolicy = new WeakSet([DEFAULTS]);
|
|
10131
10140
|
COMMIT_PRESETS = [
|
|
10132
10141
|
"conventional",
|
|
10133
10142
|
"gitmoji",
|
|
@@ -10138,10 +10147,76 @@ var init_config = __esm(() => {
|
|
|
10138
10147
|
];
|
|
10139
10148
|
});
|
|
10140
10149
|
|
|
10141
|
-
// packages/workit-
|
|
10150
|
+
// packages/workit-core/src/core/safe-write.ts
|
|
10142
10151
|
var init_safe_write = () => {};
|
|
10143
10152
|
|
|
10144
|
-
// packages/workit-
|
|
10153
|
+
// packages/workit-core/src/core/branch-policy.ts
|
|
10154
|
+
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
10155
|
+
var PREFIXES, branchNames = (workspaceRoot) => {
|
|
10156
|
+
const r = spawnSync4("git", ["for-each-ref", "--format=%(refname)", "refs/heads", "refs/remotes/origin"], { cwd: workspaceRoot, encoding: "utf8" });
|
|
10157
|
+
if (r.status !== 0)
|
|
10158
|
+
return new Set;
|
|
10159
|
+
return new Set((r.stdout ?? "").split(`
|
|
10160
|
+
`).filter(Boolean).map((ref) => ref.startsWith("refs/heads/") ? ref.slice("refs/heads/".length) : ref.slice("refs/remotes/origin/".length)));
|
|
10161
|
+
}, detectBranchPolicy = (workspaceRoot) => {
|
|
10162
|
+
const names = branchNames(workspaceRoot);
|
|
10163
|
+
const develop = names.has("develop");
|
|
10164
|
+
const main = names.has("main");
|
|
10165
|
+
const master = names.has("master");
|
|
10166
|
+
const root = main ? "main" : master ? "master" : null;
|
|
10167
|
+
if (develop) {
|
|
10168
|
+
return {
|
|
10169
|
+
preset: "gitflow",
|
|
10170
|
+
developBranch: "develop",
|
|
10171
|
+
integration: "merge",
|
|
10172
|
+
protected: root ? [root, "develop"] : ["develop"],
|
|
10173
|
+
allowed: [...PRESETS.gitflow.allowed],
|
|
10174
|
+
prefixes: PREFIXES
|
|
10175
|
+
};
|
|
10176
|
+
}
|
|
10177
|
+
if (root === "main") {
|
|
10178
|
+
return {
|
|
10179
|
+
preset: "github-flow",
|
|
10180
|
+
developBranch: null,
|
|
10181
|
+
integration: "pr",
|
|
10182
|
+
protected: [root],
|
|
10183
|
+
allowed: ["*"],
|
|
10184
|
+
prefixes: PREFIXES
|
|
10185
|
+
};
|
|
10186
|
+
}
|
|
10187
|
+
if (root === "master") {
|
|
10188
|
+
return {
|
|
10189
|
+
preset: "trunk-based",
|
|
10190
|
+
developBranch: null,
|
|
10191
|
+
integration: "pr",
|
|
10192
|
+
protected: [root],
|
|
10193
|
+
allowed: ["*"],
|
|
10194
|
+
prefixes: PREFIXES
|
|
10195
|
+
};
|
|
10196
|
+
}
|
|
10197
|
+
return {
|
|
10198
|
+
preset: "gitflow",
|
|
10199
|
+
developBranch: null,
|
|
10200
|
+
integration: "merge",
|
|
10201
|
+
protected: [],
|
|
10202
|
+
allowed: [],
|
|
10203
|
+
prefixes: PREFIXES
|
|
10204
|
+
};
|
|
10205
|
+
}, repoBranchPreset = (workspaceRoot) => {
|
|
10206
|
+
const detected = detectBranchPolicy(workspaceRoot);
|
|
10207
|
+
return detected.developBranch || detected.allowed.length ? detected.preset : null;
|
|
10208
|
+
};
|
|
10209
|
+
var init_branch_policy = __esm(() => {
|
|
10210
|
+
init_config();
|
|
10211
|
+
PREFIXES = {
|
|
10212
|
+
feature: "feature/*",
|
|
10213
|
+
bugfix: "bugfix/*",
|
|
10214
|
+
release: "release/*",
|
|
10215
|
+
hotfix: "hotfix/*"
|
|
10216
|
+
};
|
|
10217
|
+
});
|
|
10218
|
+
|
|
10219
|
+
// packages/workit-core/src/core/workspaces.ts
|
|
10145
10220
|
import { createHash as createHash5 } from "node:crypto";
|
|
10146
10221
|
import { readFileSync as readFileSync2, realpathSync } from "node:fs";
|
|
10147
10222
|
import path6 from "node:path";
|
|
@@ -10405,6 +10480,7 @@ var nonBlank, branchPreset, commitPreset, workspaceBranchPolicySchema, workspace
|
|
|
10405
10480
|
var init_workspaces = __esm(() => {
|
|
10406
10481
|
init_zod();
|
|
10407
10482
|
init_config();
|
|
10483
|
+
init_branch_policy();
|
|
10408
10484
|
nonBlank = string2().refine((value) => value.trim().length > 0, "must not be blank");
|
|
10409
10485
|
branchPreset = custom((value) => typeof value === "string" && Object.hasOwn(PRESETS, value), "unsupported branch preset");
|
|
10410
10486
|
commitPreset = custom((value) => typeof value === "string" && COMMIT_PRESETS.includes(value), "unsupported commit preset");
|
|
@@ -10529,7 +10605,7 @@ var init_workspaces = __esm(() => {
|
|
|
10529
10605
|
}).passthrough();
|
|
10530
10606
|
});
|
|
10531
10607
|
|
|
10532
|
-
// packages/workit-
|
|
10608
|
+
// packages/workit-core/src/autonomy.ts
|
|
10533
10609
|
import os3 from "node:os";
|
|
10534
10610
|
import path7 from "node:path";
|
|
10535
10611
|
function endpointOf(entry) {
|
|
@@ -11286,7 +11362,7 @@ var init_file_lock = __esm(() => {
|
|
|
11286
11362
|
init_file_lock_sync();
|
|
11287
11363
|
});
|
|
11288
11364
|
|
|
11289
|
-
// packages/workit-
|
|
11365
|
+
// packages/workit-core/src/core/package-root.ts
|
|
11290
11366
|
import { existsSync as existsSync3 } from "node:fs";
|
|
11291
11367
|
import path10 from "node:path";
|
|
11292
11368
|
import { fileURLToPath } from "node:url";
|
|
@@ -11301,8 +11377,8 @@ var packageRoot = () => {
|
|
|
11301
11377
|
};
|
|
11302
11378
|
var init_package_root = () => {};
|
|
11303
11379
|
|
|
11304
|
-
// packages/workit-
|
|
11305
|
-
import { spawnSync as
|
|
11380
|
+
// packages/workit-core/src/core/store-lock.ts
|
|
11381
|
+
import { spawnSync as spawnSync5 } from "node:child_process";
|
|
11306
11382
|
import fs7 from "node:fs";
|
|
11307
11383
|
import { hostname } from "node:os";
|
|
11308
11384
|
var metadataLockSchema, FOREIGN_LOCK_TTL_MS, UNREADABLE_LOCK_TTL_MS = 30000, RECLAIM_GUARD_TTL_MS = 30000, defaultLockTimeoutMs = 250, defaultLockTimeout = () => defaultLockTimeoutMs, parseMetadataLock = (raw) => {
|
|
@@ -11337,7 +11413,7 @@ var metadataLockSchema, FOREIGN_LOCK_TTL_MS, UNREADABLE_LOCK_TTL_MS = 30000, REC
|
|
|
11337
11413
|
}
|
|
11338
11414
|
if (process.platform === "darwin" || process.platform === "freebsd") {
|
|
11339
11415
|
try {
|
|
11340
|
-
const run =
|
|
11416
|
+
const run = spawnSync5("ps", ["-o", "lstart=", "-p", String(pid)], {
|
|
11341
11417
|
encoding: "utf8",
|
|
11342
11418
|
timeout: 1000
|
|
11343
11419
|
});
|
|
@@ -11426,7 +11502,7 @@ var init_store_lock = __esm(() => {
|
|
|
11426
11502
|
FOREIGN_LOCK_TTL_MS = 10 * 60000;
|
|
11427
11503
|
});
|
|
11428
11504
|
|
|
11429
|
-
// packages/workit-
|
|
11505
|
+
// packages/workit-core/src/store/event-log.ts
|
|
11430
11506
|
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
11431
11507
|
import fs8 from "node:fs";
|
|
11432
11508
|
import path11 from "node:path";
|
|
@@ -11581,7 +11657,7 @@ var init_event_log = __esm(() => {
|
|
|
11581
11657
|
TRANSIENT_WINDOWS_CODES = new Set(["EPERM", "EACCES", "EBUSY"]);
|
|
11582
11658
|
});
|
|
11583
11659
|
|
|
11584
|
-
// packages/workit-
|
|
11660
|
+
// packages/workit-core/src/store/patch.ts
|
|
11585
11661
|
function diff(before, after, path = []) {
|
|
11586
11662
|
if (equal(before, after))
|
|
11587
11663
|
return [];
|
|
@@ -11687,7 +11763,7 @@ var isPlainObject2 = (value) => typeof value === "object" && value !== null && !
|
|
|
11687
11763
|
return false;
|
|
11688
11764
|
});
|
|
11689
11765
|
|
|
11690
|
-
// packages/workit-
|
|
11766
|
+
// packages/workit-core/src/store/reduce.ts
|
|
11691
11767
|
import { createHash as createHash6 } from "node:crypto";
|
|
11692
11768
|
function reduce(state, event, blobs) {
|
|
11693
11769
|
const data = event.data;
|
|
@@ -11813,7 +11889,7 @@ var init_reduce = __esm(() => {
|
|
|
11813
11889
|
]);
|
|
11814
11890
|
});
|
|
11815
11891
|
|
|
11816
|
-
// packages/workit-
|
|
11892
|
+
// packages/workit-core/src/store/notes.ts
|
|
11817
11893
|
var SLOT, reportMigration = (report) => {
|
|
11818
11894
|
try {
|
|
11819
11895
|
const reporter = globalThis[SLOT];
|
|
@@ -11825,7 +11901,7 @@ var init_notes = __esm(() => {
|
|
|
11825
11901
|
SLOT = Symbol.for("workit.migrationReporter");
|
|
11826
11902
|
});
|
|
11827
11903
|
|
|
11828
|
-
// packages/workit-
|
|
11904
|
+
// packages/workit-core/src/core/task-store.ts
|
|
11829
11905
|
import { createHash as createHash7, randomUUID as randomUUID3 } from "node:crypto";
|
|
11830
11906
|
import * as fs9 from "node:fs";
|
|
11831
11907
|
import path12 from "node:path";
|
|
@@ -13452,14 +13528,14 @@ var init_task_store = __esm(() => {
|
|
|
13452
13528
|
heldInProcess = new Map;
|
|
13453
13529
|
});
|
|
13454
13530
|
|
|
13455
|
-
// packages/workit-
|
|
13531
|
+
// packages/workit-core/src/core/workers.ts
|
|
13456
13532
|
var UNCERTAIN_WORKER_STATES, isUncertainWorker = (state) => UNCERTAIN_WORKER_STATES.includes(state), workerBlocksTransition = (transition, state) => transition === "pause" ? false : isUncertainWorker(state);
|
|
13457
13533
|
var init_workers = __esm(() => {
|
|
13458
13534
|
UNCERTAIN_WORKER_STATES = ["dispatching", "running", "cancelling", "unknown"];
|
|
13459
13535
|
});
|
|
13460
13536
|
|
|
13461
|
-
// packages/workit-
|
|
13462
|
-
import { spawnSync as
|
|
13537
|
+
// packages/workit-core/src/check-config.ts
|
|
13538
|
+
import { spawnSync as spawnSync6 } from "node:child_process";
|
|
13463
13539
|
import fs10 from "node:fs";
|
|
13464
13540
|
import path13 from "node:path";
|
|
13465
13541
|
function splitCommand(command) {
|
|
@@ -13627,7 +13703,7 @@ function checkCommand(args, version, onPath = workitAvailable()) {
|
|
|
13627
13703
|
return onPath ? `workit check ${args}` : `npx -y @brainervirus/workit-cli@${version} check ${args}`;
|
|
13628
13704
|
}
|
|
13629
13705
|
var SCRIPT_CHECKS, CHECKS_FILE = "workit.checks.json", isRecord2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value), SHELL_META, git3 = (cwd, args) => {
|
|
13630
|
-
const run =
|
|
13706
|
+
const run = spawnSync6("git", args, {
|
|
13631
13707
|
cwd,
|
|
13632
13708
|
encoding: "utf8",
|
|
13633
13709
|
timeout: 20000,
|
|
@@ -13659,10 +13735,10 @@ var init_check_config = __esm(() => {
|
|
|
13659
13735
|
GATES = ["testing", "verification"];
|
|
13660
13736
|
});
|
|
13661
13737
|
|
|
13662
|
-
// packages/workit-
|
|
13738
|
+
// packages/workit-core/src/core/task-evaluation.ts
|
|
13663
13739
|
import { createHash as createHash8 } from "node:crypto";
|
|
13664
13740
|
import * as fs11 from "node:fs";
|
|
13665
|
-
import { spawnSync as
|
|
13741
|
+
import { spawnSync as spawnSync7 } from "node:child_process";
|
|
13666
13742
|
import path14 from "node:path";
|
|
13667
13743
|
function captureCandidate(root, scope, environment = []) {
|
|
13668
13744
|
let checkout;
|
|
@@ -13740,7 +13816,7 @@ function captureCandidate(root, scope, environment = []) {
|
|
|
13740
13816
|
const values = supplied.toSorted((left, right) => compareCodeUnits3(left.name, right.name)).map(({ name, value }) => ({ name, value, refs: [] }));
|
|
13741
13817
|
if (values.some(({ value }) => value === null))
|
|
13742
13818
|
completeness = "uncertain";
|
|
13743
|
-
const headResult =
|
|
13819
|
+
const headResult = spawnSync7("git", ["rev-parse", "HEAD"], { cwd: checkout, encoding: "utf8" });
|
|
13744
13820
|
if (headResult.status !== 0 && !/not a git repository/i.test(headResult.stderr ?? ""))
|
|
13745
13821
|
completeness = "uncertain";
|
|
13746
13822
|
const head = headResult.status === 0 ? headResult.stdout.trim() : null;
|
|
@@ -14113,7 +14189,7 @@ var digestBytes = (value) => createHash8("sha256").update(value).digest("hex"),
|
|
|
14113
14189
|
}
|
|
14114
14190
|
return left.length - right.length;
|
|
14115
14191
|
}, gitPaths = (root) => {
|
|
14116
|
-
const result =
|
|
14192
|
+
const result = spawnSync7("git", ["ls-files", "-z", "--cached", "--others", "--exclude-standard"], {
|
|
14117
14193
|
cwd: root,
|
|
14118
14194
|
encoding: "buffer"
|
|
14119
14195
|
});
|
|
@@ -14126,7 +14202,7 @@ var digestBytes = (value) => createHash8("sha256").update(value).digest("hex"),
|
|
|
14126
14202
|
};
|
|
14127
14203
|
}
|
|
14128
14204
|
const paths = result.stdout ? result.stdout.toString("utf8").split("\x00").filter(Boolean).map((item) => item.split(path14.sep).join("/")) : [];
|
|
14129
|
-
const stagedDeleted =
|
|
14205
|
+
const stagedDeleted = spawnSync7("git", ["diff", "--cached", "--name-only", "--diff-filter=D", "-z"], { cwd: root, encoding: "buffer" });
|
|
14130
14206
|
if (stagedDeleted.status !== 0) {
|
|
14131
14207
|
const stderr = stagedDeleted.stderr?.toString("utf8") ?? "";
|
|
14132
14208
|
if (!/not a git repository/i.test(stderr))
|
|
@@ -14307,7 +14383,7 @@ var init_task_evaluation = __esm(() => {
|
|
|
14307
14383
|
scopeCovers2 = scopeCovers;
|
|
14308
14384
|
});
|
|
14309
14385
|
|
|
14310
|
-
// packages/workit-
|
|
14386
|
+
// packages/workit-core/src/core/methods.ts
|
|
14311
14387
|
function selectMethods(policy, capabilities) {
|
|
14312
14388
|
return Object.entries(METHODS).flatMap(([id, definition]) => {
|
|
14313
14389
|
const requirements = policy.requirements.filter((requirement) => methodMatches(definition, requirement));
|
|
@@ -14415,7 +14491,7 @@ var init_methods = __esm(() => {
|
|
|
14415
14491
|
};
|
|
14416
14492
|
});
|
|
14417
14493
|
|
|
14418
|
-
// packages/workit-
|
|
14494
|
+
// packages/workit-core/src/core/task-context.ts
|
|
14419
14495
|
function reconcileResume(view, observations = []) {
|
|
14420
14496
|
if (observations.length > 0)
|
|
14421
14497
|
return failure2("permission_denied", "worker observations require native host verification");
|
|
@@ -14528,7 +14604,7 @@ var init_task_context = __esm(() => {
|
|
|
14528
14604
|
privateKey = /-----BEGIN [^-]*PRIVATE KEY-----[\s\S]*?-----END [^-]*PRIVATE KEY-----/gi;
|
|
14529
14605
|
});
|
|
14530
14606
|
|
|
14531
|
-
// packages/workit-
|
|
14607
|
+
// packages/workit-core/src/core/task-engine.ts
|
|
14532
14608
|
import { realpathSync as realpathSync4 } from "node:fs";
|
|
14533
14609
|
|
|
14534
14610
|
class WorkitCore {
|
|
@@ -16110,10 +16186,10 @@ var init_task_engine = __esm(() => {
|
|
|
16110
16186
|
retryPause = new Int32Array(new SharedArrayBuffer(4));
|
|
16111
16187
|
});
|
|
16112
16188
|
|
|
16113
|
-
// packages/workit-
|
|
16189
|
+
// packages/workit-core/src/hooks/protocol.ts
|
|
16114
16190
|
var init_protocol = () => {};
|
|
16115
16191
|
|
|
16116
|
-
// packages/workit-
|
|
16192
|
+
// packages/workit-core/src/hooks/descriptor.ts
|
|
16117
16193
|
var support = (descriptor, axis) => {
|
|
16118
16194
|
if (axis.startsWith("event:"))
|
|
16119
16195
|
return descriptor.events[axis.slice("event:".length)].support;
|
|
@@ -16136,7 +16212,7 @@ var support = (descriptor, axis) => {
|
|
|
16136
16212
|
};
|
|
16137
16213
|
});
|
|
16138
16214
|
|
|
16139
|
-
// packages/workit-
|
|
16215
|
+
// packages/workit-core/src/hooks/context.ts
|
|
16140
16216
|
import path15 from "node:path";
|
|
16141
16217
|
function sessionCompactContext(store, session, context, selection = "session-bound") {
|
|
16142
16218
|
const listed = store.listTaskIndex();
|
|
@@ -16277,13 +16353,13 @@ var init_context = __esm(() => {
|
|
|
16277
16353
|
cache = new Map;
|
|
16278
16354
|
});
|
|
16279
16355
|
|
|
16280
|
-
// packages/workit-
|
|
16356
|
+
// packages/workit-core/src/core/commit-flavors.ts
|
|
16281
16357
|
var init_commit_flavors = () => {};
|
|
16282
16358
|
|
|
16283
|
-
// packages/workit-
|
|
16359
|
+
// packages/workit-core/src/core/git.ts
|
|
16284
16360
|
var init_git = () => {};
|
|
16285
16361
|
|
|
16286
|
-
// packages/workit-
|
|
16362
|
+
// packages/workit-core/src/core/release-tracks.ts
|
|
16287
16363
|
function readReleaseTracks(raw) {
|
|
16288
16364
|
const out = { tracks: [], issues: [], error: null, protectedBranches: [] };
|
|
16289
16365
|
if (raw === undefined || raw === null)
|
|
@@ -16422,20 +16498,20 @@ var init_release_tracks = __esm(() => {
|
|
|
16422
16498
|
memo3 = new Map;
|
|
16423
16499
|
});
|
|
16424
16500
|
|
|
16425
|
-
// packages/workit-
|
|
16501
|
+
// packages/workit-core/src/core/vcs-config.ts
|
|
16426
16502
|
var init_vcs_config = __esm(() => {
|
|
16427
16503
|
init_config();
|
|
16428
16504
|
init_workspaces();
|
|
16429
16505
|
init_release_tracks();
|
|
16430
16506
|
});
|
|
16431
16507
|
|
|
16432
|
-
// packages/workit-
|
|
16508
|
+
// packages/workit-core/src/core/branch.ts
|
|
16433
16509
|
import { createHash as createHash9 } from "node:crypto";
|
|
16434
16510
|
function effectiveWorkspacePolicy(workspaceRoot, kind, profileName) {
|
|
16435
16511
|
const selected = resolveRuntimeWorkspacePolicy(workspaceRoot, kind, profileName?.trim() || process.env.WORKFLOW_PROFILE?.trim() || undefined);
|
|
16436
16512
|
const config = readConfig();
|
|
16437
16513
|
return kind === "branch" ? {
|
|
16438
|
-
branchPolicy: withReleaseTracks(workspaceRoot, resolveBranchPolicy(config, selected.policy ? { branchPolicy: selected.policy } : null)),
|
|
16514
|
+
branchPolicy: withReleaseTracks(workspaceRoot, resolveBranchPolicy(config, selected.policy ? { branchPolicy: selected.policy } : null, () => repoBranchPreset(workspaceRoot))),
|
|
16439
16515
|
provenance: { branchPolicy: selected.source }
|
|
16440
16516
|
} : {
|
|
16441
16517
|
commitPolicy: resolveCommitPolicy(config, selected.policy ? { commitPolicy: selected.policy } : null),
|
|
@@ -16520,6 +16596,7 @@ var withReleaseTracks = (workspaceRoot, policy) => {
|
|
|
16520
16596
|
}
|
|
16521
16597
|
};
|
|
16522
16598
|
var init_branch = __esm(() => {
|
|
16599
|
+
init_branch_policy();
|
|
16523
16600
|
init_commit_flavors();
|
|
16524
16601
|
init_git();
|
|
16525
16602
|
init_config();
|
|
@@ -16528,7 +16605,7 @@ var init_branch = __esm(() => {
|
|
|
16528
16605
|
init_release_tracks();
|
|
16529
16606
|
});
|
|
16530
16607
|
|
|
16531
|
-
// packages/workit-
|
|
16608
|
+
// packages/workit-core/src/core/route-intent.ts
|
|
16532
16609
|
var shellBranchTarget = (command) => {
|
|
16533
16610
|
if (!command.trim() || /[\r\n;&|<>`'"$()\\*?{}~!#]/u.test(command) || command.includes("[") || command.includes("]"))
|
|
16534
16611
|
return null;
|
|
@@ -16546,7 +16623,7 @@ var init_route_intent = __esm(() => {
|
|
|
16546
16623
|
init_branch();
|
|
16547
16624
|
});
|
|
16548
16625
|
|
|
16549
|
-
// packages/workit-
|
|
16626
|
+
// packages/workit-core/src/hooks/policy.ts
|
|
16550
16627
|
var shellPolicy = (cwd, command) => {
|
|
16551
16628
|
const policy = shellBranchPolicyViolation(cwd, command);
|
|
16552
16629
|
return policy && !policy.ok ? { kind: "deny", reason: `branch_policy_denied: ${policy.error}`, unblock: null } : { kind: "none" };
|
|
@@ -16555,7 +16632,7 @@ var init_policy = __esm(() => {
|
|
|
16555
16632
|
init_route_intent();
|
|
16556
16633
|
});
|
|
16557
16634
|
|
|
16558
|
-
// packages/workit-
|
|
16635
|
+
// packages/workit-core/src/hooks/write-gate.ts
|
|
16559
16636
|
import { realpathSync as realpathSync5 } from "node:fs";
|
|
16560
16637
|
import path16 from "node:path";
|
|
16561
16638
|
function writeGate(cwd, paths) {
|
|
@@ -16679,9 +16756,9 @@ var NONE2, CASE_INSENSITIVE, canonical2 = (file) => {
|
|
|
16679
16756
|
}
|
|
16680
16757
|
flushSegment();
|
|
16681
16758
|
return segments;
|
|
16682
|
-
},
|
|
16759
|
+
}, PREFIXES2, operands = (words) => words.filter((item) => !item.startsWith("-")), editsOf = (input) => {
|
|
16683
16760
|
let words = input;
|
|
16684
|
-
while (words.length && (
|
|
16761
|
+
while (words.length && (PREFIXES2.has(words[0]) || /^\w+=/.test(words[0])))
|
|
16685
16762
|
words = words.slice(1);
|
|
16686
16763
|
const [verb, ...args] = words;
|
|
16687
16764
|
const name = (verb?.split(/[\\/]/).at(-1) ?? "").toLowerCase();
|
|
@@ -16812,11 +16889,11 @@ var init_write_gate = __esm(() => {
|
|
|
16812
16889
|
init_ledger();
|
|
16813
16890
|
NONE2 = { kind: "none" };
|
|
16814
16891
|
CASE_INSENSITIVE = process.platform === "darwin" || process.platform === "win32";
|
|
16815
|
-
|
|
16892
|
+
PREFIXES2 = new Set(["sudo", "command", "env", "nohup", "time", "exec", "xargs"]);
|
|
16816
16893
|
cache2 = new Map;
|
|
16817
16894
|
});
|
|
16818
16895
|
|
|
16819
|
-
// packages/workit-
|
|
16896
|
+
// packages/workit-core/src/hooks/hosts/fields.ts
|
|
16820
16897
|
import { existsSync as existsSync6, realpathSync as realpathSync6, statSync as statSync2 } from "node:fs";
|
|
16821
16898
|
import path17 from "node:path";
|
|
16822
16899
|
var isRecord4 = (value) => value !== null && typeof value === "object" && !Array.isArray(value), nonEmpty2 = (value) => typeof value === "string" && value.trim() !== "", optionalText = (value) => typeof value === "string" ? value : null, existingDirectory = (value) => {
|
|
@@ -16880,7 +16957,7 @@ var init_fields = __esm(() => {
|
|
|
16880
16957
|
PATH_KEYS = ["file_path", "filePath", "notebook_path", "path", "target_file", "file"];
|
|
16881
16958
|
});
|
|
16882
16959
|
|
|
16883
|
-
// packages/workit-
|
|
16960
|
+
// packages/workit-core/src/hooks/handle.ts
|
|
16884
16961
|
function handleHook(input, deps) {
|
|
16885
16962
|
const { descriptor } = deps;
|
|
16886
16963
|
const event = input.event;
|
|
@@ -16977,7 +17054,7 @@ var init_handle = __esm(() => {
|
|
|
16977
17054
|
CLAUDE_JUDGES = new Set(["workit:verifier", "workit:reviewer"]);
|
|
16978
17055
|
});
|
|
16979
17056
|
|
|
16980
|
-
// packages/workit-
|
|
17057
|
+
// packages/workit-core/src/hooks/hosts/claude-code.ts
|
|
16981
17058
|
var CLAUDE_CODE_DESCRIPTOR, EVENTS, SOURCES, SHELL_TOOLS, toolCommand = (value) => isRecord4(value.tool_input) ? commandText(value.tool_input.command) : null, eventOf = (name, value) => {
|
|
16982
17059
|
const toolUseId = optionalText(value.tool_use_id);
|
|
16983
17060
|
switch (name) {
|
|
@@ -17221,7 +17298,7 @@ var init_claude_code = __esm(() => {
|
|
|
17221
17298
|
};
|
|
17222
17299
|
});
|
|
17223
17300
|
|
|
17224
|
-
// packages/workit-
|
|
17301
|
+
// packages/workit-core/src/hooks/hosts/codex.ts
|
|
17225
17302
|
function detectCodexSurface(env) {
|
|
17226
17303
|
return env.CODEX_INTERNAL_ORIGINATOR_OVERRIDE === "Codex Desktop" || Boolean(env.CODEX_ELECTRON_RESOURCES_PATH) ? "codex_desktop" : "codex_cli";
|
|
17227
17304
|
}
|
|
@@ -17448,7 +17525,7 @@ var init_codex = __esm(() => {
|
|
|
17448
17525
|
};
|
|
17449
17526
|
});
|
|
17450
17527
|
|
|
17451
|
-
// packages/workit-
|
|
17528
|
+
// packages/workit-core/src/hooks/hosts/cursor.ts
|
|
17452
17529
|
import path18 from "node:path";
|
|
17453
17530
|
var undocumented2, none, CURSOR_DESCRIPTOR, EVENTS3, parseCursorHookInput = (value) => {
|
|
17454
17531
|
if (!isRecord4(value) || !Object.hasOwn(EVENTS3, String(value.hook_event_name)))
|
|
@@ -17689,7 +17766,7 @@ var init_cursor = __esm(() => {
|
|
|
17689
17766
|
};
|
|
17690
17767
|
});
|
|
17691
17768
|
|
|
17692
|
-
// packages/workit-
|
|
17769
|
+
// packages/workit-core/src/hooks/run.ts
|
|
17693
17770
|
async function runHookProcess(host, stdin, stdout, stderr = process.stderr, env = process.env) {
|
|
17694
17771
|
const adapter = typeof host === "string" ? HOOK_ADAPTERS[host] : host;
|
|
17695
17772
|
let text = "";
|
|
@@ -17724,13 +17801,13 @@ var init_run = __esm(async () => {
|
|
|
17724
17801
|
if (false) {}
|
|
17725
17802
|
});
|
|
17726
17803
|
|
|
17727
|
-
// packages/workit-
|
|
17804
|
+
// packages/workit-core/src/hooks/hosts/opencode.ts
|
|
17728
17805
|
var init_opencode = () => {};
|
|
17729
17806
|
|
|
17730
|
-
// packages/workit-
|
|
17807
|
+
// packages/workit-core/src/hooks/hosts/pi.ts
|
|
17731
17808
|
var init_pi = () => {};
|
|
17732
17809
|
|
|
17733
|
-
// packages/workit-
|
|
17810
|
+
// packages/workit-core/src/hooks/index.ts
|
|
17734
17811
|
var init_hooks = __esm(async () => {
|
|
17735
17812
|
init_context();
|
|
17736
17813
|
init_policy();
|