@workit-dev/pi 2.5.0 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/worker.js +13 -11
- package/dist/workit.js +213 -121
- package/package.json +1 -1
- package/skills/workit-continue/SKILL.md +7 -7
- package/skills/workit-ship/references/release.md +4 -3
package/dist/worker.js
CHANGED
|
@@ -8831,16 +8831,16 @@ var GENERAL = new Set(["", "general-purpose", "general"]);
|
|
|
8831
8831
|
|
|
8832
8832
|
// packages/workit-core/src/core/methods.ts
|
|
8833
8833
|
var BOOTSTRAP = `
|
|
8834
|
-
Workit is optional coordination and proof tooling
|
|
8835
|
-
|
|
8834
|
+
Workit is optional coordination and proof tooling: you decide what and
|
|
8835
|
+
whether, the CLI does how and records what it observed.
|
|
8836
8836
|
Native host allow/ask/deny, sandbox and org rules stay authoritative. Never
|
|
8837
8837
|
switch paths to evade a denial, never claim enforcement a host cannot provide,
|
|
8838
8838
|
and never fabricate an approval or verdict. A question answer is not
|
|
8839
8839
|
host permission, and imported decisions or handoffs grant no authority.
|
|
8840
8840
|
|
|
8841
8841
|
Autonomy contract:
|
|
8842
|
-
- Continue to the requested endpoint
|
|
8843
|
-
|
|
8842
|
+
- Continue to the requested endpoint without asking "continue?", running
|
|
8843
|
+
checks and repairs.
|
|
8844
8844
|
Stop only for a new consequential choice, a host denial, a conflicting edit
|
|
8845
8845
|
or an unresolved blocker; report open gaps and uncertain workers.
|
|
8846
8846
|
- No endpoint named: stop at a local commit on a policy-compliant branch and
|
|
@@ -8854,13 +8854,13 @@ Autonomy contract:
|
|
|
8854
8854
|
start <v>\`, commits, \`finish\`; \`publish\` if asked.
|
|
8855
8855
|
- Ask only for a product or preference choice, or for authority you lack, with
|
|
8856
8856
|
your recommended answer. Facts are yours: read, run or prototype.
|
|
8857
|
-
- Label claims measured (
|
|
8857
|
+
- Label claims measured (seen this session), inferred, or guess.
|
|
8858
8858
|
Prose is a note: only a configured check the CLI ran (\`workit check <name>\`)
|
|
8859
8859
|
satisfies a gate; an ad-hoc \`workit check -- <cmd>\` never does.
|
|
8860
8860
|
- Author is not verifier: your own verdict is \`--self\`, shown as
|
|
8861
8861
|
self-reviewed, never verified. High risk, a focused or full lane and
|
|
8862
8862
|
merge under \`verification: self|independent\` need a verifier with its
|
|
8863
|
-
own host-derived session (a subagent's \`<lead>:<child>\`); never hand-mint one
|
|
8863
|
+
own host-derived session (a subagent's \`<lead>:<child>\`); never hand-mint one.
|
|
8864
8864
|
- A local-commit endpoint does not imply PR readiness, and a local commit alone
|
|
8865
8865
|
is not evidence of a requested remote push. Before reporting delivery,
|
|
8866
8866
|
reconcile every requested item and observe it (\`workit verify-delivery\`).
|
|
@@ -8873,23 +8873,25 @@ verb per shell call, never \`cd <dir> && workit\`. zsh-safe: no \`echo =====\`
|
|
|
8873
8873
|
Add Co-Authored-By via \`workit git commit --trailer "K: v" -- <paths>\`, never
|
|
8874
8874
|
an amend.
|
|
8875
8875
|
The task families (task, policy, evidence, finding, decision, worker, state)
|
|
8876
|
-
are optional continuity for tracked work;
|
|
8877
|
-
|
|
8878
|
-
|
|
8876
|
+
are optional continuity for tracked work; a solo edit needs no task. A
|
|
8877
|
+
decision records a user choice; it never authorizes an effect. Judge work
|
|
8878
|
+
once with
|
|
8879
8879
|
\`workit policy assess --judge risk= behavior= product-choice= plan=\`.
|
|
8880
8880
|
Across repositories, bind items to checkout, branch and endpoint, resolve
|
|
8881
8881
|
competing targets before a mutation, and reconcile an uncertain
|
|
8882
8882
|
effect before a retry.
|
|
8883
8883
|
|
|
8884
8884
|
Mid-task: never silently drop or resume an objective (workit-continue).
|
|
8885
|
+
Notes, drafts, logs, resume files: \`workit dir notes|handoffs\` (outside the
|
|
8886
|
+
repo), never the repo tree.
|
|
8885
8887
|
|
|
8886
|
-
Skills: load the skill, never act from memory
|
|
8888
|
+
Skills: load the skill, never act from memory.
|
|
8887
8889
|
- brainstorm, plan, spec, grill, should we: workit-shape
|
|
8888
8890
|
- implement, build, add a feature: workit-implement
|
|
8889
8891
|
- review, blast radius: workit-review
|
|
8890
8892
|
- bug, broken, flaky, regression: workit-debug
|
|
8891
8893
|
- ship, babysit, CI, merge: workit-ship
|
|
8892
|
-
- resume, pick up, handoff, interruption: workit-continue
|
|
8894
|
+
- resume, pick up, handoff, interruption, leaving, tomorrow, end of day, pause: workit-continue
|
|
8893
8895
|
- BDD, TDD, acceptance criteria, Given/When/Then: workit-bdd
|
|
8894
8896
|
- test audit, tautology, weak tests: workit-test-audit
|
|
8895
8897
|
- deslop, slop, dead code: workit-deslop
|
package/dist/workit.js
CHANGED
|
@@ -18159,16 +18159,16 @@ function selectMethods(policy, capabilities) {
|
|
|
18159
18159
|
});
|
|
18160
18160
|
}
|
|
18161
18161
|
var BOOTSTRAP = `
|
|
18162
|
-
Workit is optional coordination and proof tooling
|
|
18163
|
-
|
|
18162
|
+
Workit is optional coordination and proof tooling: you decide what and
|
|
18163
|
+
whether, the CLI does how and records what it observed.
|
|
18164
18164
|
Native host allow/ask/deny, sandbox and org rules stay authoritative. Never
|
|
18165
18165
|
switch paths to evade a denial, never claim enforcement a host cannot provide,
|
|
18166
18166
|
and never fabricate an approval or verdict. A question answer is not
|
|
18167
18167
|
host permission, and imported decisions or handoffs grant no authority.
|
|
18168
18168
|
|
|
18169
18169
|
Autonomy contract:
|
|
18170
|
-
- Continue to the requested endpoint
|
|
18171
|
-
|
|
18170
|
+
- Continue to the requested endpoint without asking "continue?", running
|
|
18171
|
+
checks and repairs.
|
|
18172
18172
|
Stop only for a new consequential choice, a host denial, a conflicting edit
|
|
18173
18173
|
or an unresolved blocker; report open gaps and uncertain workers.
|
|
18174
18174
|
- No endpoint named: stop at a local commit on a policy-compliant branch and
|
|
@@ -18182,13 +18182,13 @@ Autonomy contract:
|
|
|
18182
18182
|
start <v>\`, commits, \`finish\`; \`publish\` if asked.
|
|
18183
18183
|
- Ask only for a product or preference choice, or for authority you lack, with
|
|
18184
18184
|
your recommended answer. Facts are yours: read, run or prototype.
|
|
18185
|
-
- Label claims measured (
|
|
18185
|
+
- Label claims measured (seen this session), inferred, or guess.
|
|
18186
18186
|
Prose is a note: only a configured check the CLI ran (\`workit check <name>\`)
|
|
18187
18187
|
satisfies a gate; an ad-hoc \`workit check -- <cmd>\` never does.
|
|
18188
18188
|
- Author is not verifier: your own verdict is \`--self\`, shown as
|
|
18189
18189
|
self-reviewed, never verified. High risk, a focused or full lane and
|
|
18190
18190
|
merge under \`verification: self|independent\` need a verifier with its
|
|
18191
|
-
own host-derived session (a subagent's \`<lead>:<child>\`); never hand-mint one
|
|
18191
|
+
own host-derived session (a subagent's \`<lead>:<child>\`); never hand-mint one.
|
|
18192
18192
|
- A local-commit endpoint does not imply PR readiness, and a local commit alone
|
|
18193
18193
|
is not evidence of a requested remote push. Before reporting delivery,
|
|
18194
18194
|
reconcile every requested item and observe it (\`workit verify-delivery\`).
|
|
@@ -18201,23 +18201,25 @@ verb per shell call, never \`cd <dir> && workit\`. zsh-safe: no \`echo =====\`
|
|
|
18201
18201
|
Add Co-Authored-By via \`workit git commit --trailer "K: v" -- <paths>\`, never
|
|
18202
18202
|
an amend.
|
|
18203
18203
|
The task families (task, policy, evidence, finding, decision, worker, state)
|
|
18204
|
-
are optional continuity for tracked work;
|
|
18205
|
-
|
|
18206
|
-
|
|
18204
|
+
are optional continuity for tracked work; a solo edit needs no task. A
|
|
18205
|
+
decision records a user choice; it never authorizes an effect. Judge work
|
|
18206
|
+
once with
|
|
18207
18207
|
\`workit policy assess --judge risk= behavior= product-choice= plan=\`.
|
|
18208
18208
|
Across repositories, bind items to checkout, branch and endpoint, resolve
|
|
18209
18209
|
competing targets before a mutation, and reconcile an uncertain
|
|
18210
18210
|
effect before a retry.
|
|
18211
18211
|
|
|
18212
18212
|
Mid-task: never silently drop or resume an objective (workit-continue).
|
|
18213
|
+
Notes, drafts, logs, resume files: \`workit dir notes|handoffs\` (outside the
|
|
18214
|
+
repo), never the repo tree.
|
|
18213
18215
|
|
|
18214
|
-
Skills: load the skill, never act from memory
|
|
18216
|
+
Skills: load the skill, never act from memory.
|
|
18215
18217
|
- brainstorm, plan, spec, grill, should we: workit-shape
|
|
18216
18218
|
- implement, build, add a feature: workit-implement
|
|
18217
18219
|
- review, blast radius: workit-review
|
|
18218
18220
|
- bug, broken, flaky, regression: workit-debug
|
|
18219
18221
|
- ship, babysit, CI, merge: workit-ship
|
|
18220
|
-
- resume, pick up, handoff, interruption: workit-continue
|
|
18222
|
+
- resume, pick up, handoff, interruption, leaving, tomorrow, end of day, pause: workit-continue
|
|
18221
18223
|
- BDD, TDD, acceptance criteria, Given/When/Then: workit-bdd
|
|
18222
18224
|
- test audit, tautology, weak tests: workit-test-audit
|
|
18223
18225
|
- deslop, slop, dead code: workit-deslop
|
|
@@ -27971,7 +27973,7 @@ var writePaths = (input) => {
|
|
|
27971
27973
|
};
|
|
27972
27974
|
// packages/workit-core/src/hooks/standing.ts
|
|
27973
27975
|
import fs30 from "node:fs";
|
|
27974
|
-
import
|
|
27976
|
+
import path48 from "node:path";
|
|
27975
27977
|
|
|
27976
27978
|
// packages/workit-core/src/approvals/store.ts
|
|
27977
27979
|
import { createHash as createHash19, randomBytes as randomBytes4 } from "node:crypto";
|
|
@@ -28187,10 +28189,70 @@ var approveCallIn = (command, dialect = "posix") => {
|
|
|
28187
28189
|
};
|
|
28188
28190
|
var approveCallDeny = (fix) => `Run \`${fix}\` as its own call: no chain, pipe, substitution, leading cd, env prefix or redirect around it, so the host can show the request and record the user's answer.`;
|
|
28189
28191
|
|
|
28190
|
-
// packages/workit-core/src/approvals/
|
|
28192
|
+
// packages/workit-core/src/approvals/inline.ts
|
|
28193
|
+
import path46 from "node:path";
|
|
28194
|
+
|
|
28195
|
+
// packages/workit-core/src/approvals/release-notes-ask.ts
|
|
28191
28196
|
import { createHash as createHash20 } from "node:crypto";
|
|
28192
|
-
import {
|
|
28197
|
+
import { existsSync as existsSync15, readFileSync as readFileSync14 } from "node:fs";
|
|
28193
28198
|
import path44 from "node:path";
|
|
28199
|
+
var sha2563 = (data) => createHash20("sha256").update(data).digest("hex");
|
|
28200
|
+
var isReleaseNotesApprove = (words) => words[0] === "notes" && words[1] === "approve";
|
|
28201
|
+
var versionOf = (args) => {
|
|
28202
|
+
const positionals = [];
|
|
28203
|
+
for (let index = 0;index < args.length; index += 1) {
|
|
28204
|
+
const arg = args[index] ?? "";
|
|
28205
|
+
if (arg === "--json")
|
|
28206
|
+
continue;
|
|
28207
|
+
if (arg === "--track")
|
|
28208
|
+
index += 1;
|
|
28209
|
+
else if (!arg.startsWith("--track=")) {
|
|
28210
|
+
if (arg.startsWith("-"))
|
|
28211
|
+
return null;
|
|
28212
|
+
positionals.push(arg);
|
|
28213
|
+
}
|
|
28214
|
+
}
|
|
28215
|
+
const [version] = positionals;
|
|
28216
|
+
return positionals.length === 1 && version && /^[\w@%+.:/-]+$/u.test(version) && !version.includes("..") ? version : null;
|
|
28217
|
+
};
|
|
28218
|
+
var releaseNotesAsk = (args, draft) => {
|
|
28219
|
+
const version = versionOf(args);
|
|
28220
|
+
if (!version)
|
|
28221
|
+
return null;
|
|
28222
|
+
const action = `workit release notes approve ${version}`;
|
|
28223
|
+
return {
|
|
28224
|
+
kind: "release-notes",
|
|
28225
|
+
action,
|
|
28226
|
+
text: `Yes approves the release notes of ${version} (${draft.path}); finish publishes exactly this text:
|
|
28227
|
+
|
|
28228
|
+
${draft.notes.trimEnd()}`,
|
|
28229
|
+
argvHash: sha2563(canonicalJson(args)),
|
|
28230
|
+
contentHash: sha2563(canonicalJson({ args, notes: sha2563(draft.notes) }))
|
|
28231
|
+
};
|
|
28232
|
+
};
|
|
28233
|
+
var releaseNotesAskAt = (args, cwd) => {
|
|
28234
|
+
const version = versionOf(args);
|
|
28235
|
+
const common = version ? gitCommonDir(cwd) : null;
|
|
28236
|
+
if (!version || !common)
|
|
28237
|
+
return null;
|
|
28238
|
+
const dir = path44.join(common, "workit", "release-notes");
|
|
28239
|
+
for (const file of [
|
|
28240
|
+
path44.join(dir, "packages", `${version.replaceAll("/", "%2F")}.md`),
|
|
28241
|
+
path44.join(dir, `${version}.md`)
|
|
28242
|
+
])
|
|
28243
|
+
if (existsSync15(file))
|
|
28244
|
+
try {
|
|
28245
|
+
return releaseNotesAsk(args, { path: file, notes: readFileSync14(file, "utf8") });
|
|
28246
|
+
} catch {
|
|
28247
|
+
return null;
|
|
28248
|
+
}
|
|
28249
|
+
return null;
|
|
28250
|
+
};
|
|
28251
|
+
|
|
28252
|
+
// packages/workit-core/src/approvals/youtrack-ask.ts
|
|
28253
|
+
import { createHash as createHash21 } from "node:crypto";
|
|
28254
|
+
import { readFileSync as readFileSync15, realpathSync as realpathSync11 } from "node:fs";
|
|
28255
|
+
import path45 from "node:path";
|
|
28194
28256
|
var TIME = "markdown file minutes text date";
|
|
28195
28257
|
var FLAGS = {
|
|
28196
28258
|
note: TIME,
|
|
@@ -28200,8 +28262,8 @@ var FLAGS = {
|
|
|
28200
28262
|
create: "project summary description file attach command"
|
|
28201
28263
|
};
|
|
28202
28264
|
var isYouTrackWriteVerb = (word) => Object.hasOwn(FLAGS, word ?? "");
|
|
28203
|
-
var
|
|
28204
|
-
var youTrackAsk = (args, cwd, load =
|
|
28265
|
+
var sha2564 = (data) => createHash21("sha256").update(data).digest("hex");
|
|
28266
|
+
var youTrackAsk = (args, cwd, load = readFileSync15) => {
|
|
28205
28267
|
const [verb = "", ...rest] = args;
|
|
28206
28268
|
if (!isYouTrackWriteVerb(verb))
|
|
28207
28269
|
return null;
|
|
@@ -28234,9 +28296,9 @@ var youTrackAsk = (args, cwd, load = readFileSync14) => {
|
|
|
28234
28296
|
const files = [];
|
|
28235
28297
|
const read = (file) => {
|
|
28236
28298
|
try {
|
|
28237
|
-
const named =
|
|
28299
|
+
const named = path45.resolve(cwd, file);
|
|
28238
28300
|
const content = load(named);
|
|
28239
|
-
files.push([realpathSync11(named),
|
|
28301
|
+
files.push([realpathSync11(named), sha2564(content)]);
|
|
28240
28302
|
return content;
|
|
28241
28303
|
} catch {
|
|
28242
28304
|
return null;
|
|
@@ -28272,7 +28334,7 @@ var youTrackAsk = (args, cwd, load = readFileSync14) => {
|
|
|
28272
28334
|
const content = read(file);
|
|
28273
28335
|
if (!content)
|
|
28274
28336
|
return null;
|
|
28275
|
-
lines.push(`attach: ${
|
|
28337
|
+
lines.push(`attach: ${path45.basename(file)} (${content.length} bytes)`);
|
|
28276
28338
|
}
|
|
28277
28339
|
if (!lines.length)
|
|
28278
28340
|
return null;
|
|
@@ -28281,14 +28343,35 @@ var youTrackAsk = (args, cwd, load = readFileSync14) => {
|
|
|
28281
28343
|
action,
|
|
28282
28344
|
text: [`Yes runs ${action} once:`, ...lines].join(`
|
|
28283
28345
|
`),
|
|
28284
|
-
argvHash:
|
|
28285
|
-
contentHash:
|
|
28346
|
+
argvHash: sha2564(canonicalJson(args)),
|
|
28347
|
+
contentHash: sha2564(canonicalJson({ args, files }))
|
|
28286
28348
|
};
|
|
28287
28349
|
};
|
|
28288
28350
|
|
|
28289
28351
|
// packages/workit-core/src/approvals/inline.ts
|
|
28290
|
-
var
|
|
28352
|
+
var isReleaseNotesCall = (words) => words[0] === "release" && isReleaseNotesApprove(words.slice(1));
|
|
28353
|
+
var asked = (words) => words[0] === "youtrack" && isYouTrackWriteVerb(words[1]) || isReleaseNotesCall(words);
|
|
28291
28354
|
var quote2 = (word) => /^[\w@%+=:,./-]+$/u.test(word) ? word : `'${word.replaceAll("'", `'\\''`)}'`;
|
|
28355
|
+
var routed = (call, globals) => {
|
|
28356
|
+
if (!globals.includes("--json") || call.slice(1).includes("--json"))
|
|
28357
|
+
return call;
|
|
28358
|
+
const end = call.indexOf("--");
|
|
28359
|
+
return end < 0 ? [...call, "--json"] : [...call.slice(0, end), "--json", ...call.slice(end)];
|
|
28360
|
+
};
|
|
28361
|
+
var cwdOf = (globals) => {
|
|
28362
|
+
let cwd = null;
|
|
28363
|
+
for (let index = 0;index < globals.length; index += 1) {
|
|
28364
|
+
const word = globals[index] ?? "";
|
|
28365
|
+
if (word === "--cwd")
|
|
28366
|
+
cwd = globals[++index] ?? null;
|
|
28367
|
+
else if (word.startsWith("--cwd="))
|
|
28368
|
+
cwd = word.slice("--cwd=".length);
|
|
28369
|
+
else if (word === "--session")
|
|
28370
|
+
index += 1;
|
|
28371
|
+
}
|
|
28372
|
+
return cwd;
|
|
28373
|
+
};
|
|
28374
|
+
var inlineCallCwd = (call, base) => call.cwd ? path46.resolve(base, call.cwd) : base;
|
|
28292
28375
|
var inlineCallIn = (command, dialect = "posix") => {
|
|
28293
28376
|
if (!/\bworkit\b/u.test(command))
|
|
28294
28377
|
return null;
|
|
@@ -28297,7 +28380,7 @@ var inlineCallIn = (command, dialect = "posix") => {
|
|
|
28297
28380
|
if (segment.unanalyzable)
|
|
28298
28381
|
continue;
|
|
28299
28382
|
const { words } = segment;
|
|
28300
|
-
const script = (words[0] ?? "").endsWith("sh") ? words.find((word) => /\bworkit\s+youtrack\s/u.test(word)) : undefined;
|
|
28383
|
+
const script = (words[0] ?? "").endsWith("sh") ? words.find((word) => /\bworkit\s+(?:youtrack|release\s+notes\s+approve)\s/u.test(word)) : undefined;
|
|
28301
28384
|
if (script)
|
|
28302
28385
|
return { plain: false, fix: script.trim() };
|
|
28303
28386
|
const start = words.findIndex(isWorkitWord2);
|
|
@@ -28307,9 +28390,13 @@ var inlineCallIn = (command, dialect = "posix") => {
|
|
|
28307
28390
|
const call = words.slice(at);
|
|
28308
28391
|
if (!asked(call))
|
|
28309
28392
|
continue;
|
|
28310
|
-
const plain = segments.length === 1 && start === 0 && words[0] === "workit" &&
|
|
28393
|
+
const plain = segments.length === 1 && start === 0 && words[0] === "workit" && !segment.redirects.length && !segment.subs?.length && !segment.stdin?.length && !segment.expands?.length && !segment.group;
|
|
28311
28394
|
if (plain)
|
|
28312
|
-
return {
|
|
28395
|
+
return {
|
|
28396
|
+
plain: true,
|
|
28397
|
+
words: routed(call, words.slice(1, at)),
|
|
28398
|
+
cwd: cwdOf(words.slice(1, at))
|
|
28399
|
+
};
|
|
28313
28400
|
return {
|
|
28314
28401
|
plain: false,
|
|
28315
28402
|
fix: `workit ${call.map(quote2).join(" ")}`
|
|
@@ -28317,7 +28404,11 @@ var inlineCallIn = (command, dialect = "posix") => {
|
|
|
28317
28404
|
}
|
|
28318
28405
|
return null;
|
|
28319
28406
|
};
|
|
28320
|
-
var inlineAskFor = (words, cwd) =>
|
|
28407
|
+
var inlineAskFor = (words, cwd) => {
|
|
28408
|
+
if (isReleaseNotesCall(words))
|
|
28409
|
+
return releaseNotesAskAt(words.slice(3), cwd);
|
|
28410
|
+
return asked(words) && youTrackWritesMode(cwd) !== "auto" ? youTrackAsk(words.slice(1), cwd) : null;
|
|
28411
|
+
};
|
|
28321
28412
|
var inlineCallDeny = (fix) => `Run \`${fix}\` as its own call so the host can ask the user.`;
|
|
28322
28413
|
|
|
28323
28414
|
// packages/workit-core/src/hooks/hosts/claude-code.ts
|
|
@@ -28793,37 +28884,37 @@ function neededChecks(lane, configured) {
|
|
|
28793
28884
|
}
|
|
28794
28885
|
|
|
28795
28886
|
// packages/workit-core/src/hooks/worktree-confine.ts
|
|
28796
|
-
import { createHash as
|
|
28887
|
+
import { createHash as createHash22 } from "node:crypto";
|
|
28797
28888
|
import fs29 from "node:fs";
|
|
28798
|
-
import
|
|
28889
|
+
import path47 from "node:path";
|
|
28799
28890
|
var FANOUT_TOKEN_FILE = "workit-fanout-token";
|
|
28800
28891
|
var NONE5 = { kind: "none" };
|
|
28801
28892
|
var CASE_INSENSITIVE2 = process.platform === "darwin" || process.platform === "win32";
|
|
28802
28893
|
var realOf = (file) => {
|
|
28803
28894
|
let rest = "";
|
|
28804
|
-
for (let dir = file;; dir =
|
|
28895
|
+
for (let dir = file;; dir = path47.dirname(dir)) {
|
|
28805
28896
|
try {
|
|
28806
|
-
return
|
|
28897
|
+
return path47.join(fs29.realpathSync.native(dir), rest);
|
|
28807
28898
|
} catch {
|
|
28808
|
-
if (
|
|
28899
|
+
if (path47.dirname(dir) === dir)
|
|
28809
28900
|
return file;
|
|
28810
|
-
rest = rest ?
|
|
28901
|
+
rest = rest ? path47.join(path47.basename(dir), rest) : path47.basename(dir);
|
|
28811
28902
|
}
|
|
28812
28903
|
}
|
|
28813
28904
|
};
|
|
28814
28905
|
var canonical5 = (file, hops = { chain: 40, total: 1000 }) => {
|
|
28815
|
-
const start =
|
|
28816
|
-
const { root } =
|
|
28906
|
+
const start = path47.isAbsolute(file) ? file : `${process.cwd()}${path47.sep}${file}`;
|
|
28907
|
+
const { root } = path47.parse(start);
|
|
28817
28908
|
let at = root;
|
|
28818
28909
|
let missing = false;
|
|
28819
28910
|
for (const part of start.slice(root.length).split(/[\\/]+/)) {
|
|
28820
28911
|
if (part === "" || part === ".")
|
|
28821
28912
|
continue;
|
|
28822
28913
|
if (part === "..") {
|
|
28823
|
-
at =
|
|
28914
|
+
at = path47.dirname(at);
|
|
28824
28915
|
continue;
|
|
28825
28916
|
}
|
|
28826
|
-
const next =
|
|
28917
|
+
const next = path47.join(at, part);
|
|
28827
28918
|
let link = null;
|
|
28828
28919
|
if (!missing)
|
|
28829
28920
|
try {
|
|
@@ -28835,25 +28926,25 @@ var canonical5 = (file, hops = { chain: 40, total: 1000 }) => {
|
|
|
28835
28926
|
at = next;
|
|
28836
28927
|
hops.chain = 40;
|
|
28837
28928
|
} else if (hops.chain-- > 0 && hops.total-- > 0)
|
|
28838
|
-
at = canonical5(
|
|
28929
|
+
at = canonical5(path47.isAbsolute(link) ? link : `${at}${path47.sep}${link}`, hops);
|
|
28839
28930
|
else
|
|
28840
|
-
return
|
|
28931
|
+
return path47.resolve(file);
|
|
28841
28932
|
}
|
|
28842
28933
|
return realOf(at);
|
|
28843
28934
|
};
|
|
28844
28935
|
var within = (child, parent) => {
|
|
28845
28936
|
const fold = (value) => CASE_INSENSITIVE2 ? value.toLowerCase() : value;
|
|
28846
|
-
const relative =
|
|
28847
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
28937
|
+
const relative = path47.relative(fold(parent), fold(child));
|
|
28938
|
+
return relative === "" || !relative.startsWith("..") && !path47.isAbsolute(relative);
|
|
28848
28939
|
};
|
|
28849
28940
|
var checkoutOf2 = (file) => {
|
|
28850
|
-
for (let dir = canonical5(file);; dir =
|
|
28851
|
-
const dotGit =
|
|
28941
|
+
for (let dir = canonical5(file);; dir = path47.dirname(dir)) {
|
|
28942
|
+
const dotGit = path47.join(dir, ".git");
|
|
28852
28943
|
if (fs29.existsSync(dotGit)) {
|
|
28853
28944
|
const admin = fs29.statSync(dotGit).isFile() ? gitDirsAt(dir, null, false)?.[0] : undefined;
|
|
28854
|
-
return { root: dir, workit: !!admin && fs29.existsSync(
|
|
28945
|
+
return { root: dir, workit: !!admin && fs29.existsSync(path47.join(admin, FANOUT_TOKEN_FILE)) };
|
|
28855
28946
|
}
|
|
28856
|
-
if (
|
|
28947
|
+
if (path47.dirname(dir) === dir)
|
|
28857
28948
|
return null;
|
|
28858
28949
|
}
|
|
28859
28950
|
};
|
|
@@ -28865,8 +28956,8 @@ var workitWorktreeOf = (file) => {
|
|
|
28865
28956
|
return null;
|
|
28866
28957
|
}
|
|
28867
28958
|
};
|
|
28868
|
-
var bindingDir = () =>
|
|
28869
|
-
var bindingFile = (session, agentId) =>
|
|
28959
|
+
var bindingDir = () => path47.join(resolveStateDir(), "worktree-bind");
|
|
28960
|
+
var bindingFile = (session, agentId) => path47.join(bindingDir(), `${createHash22("sha256").update(`${session}\x00${agentId}`).digest("hex").slice(0, 32)}.json`);
|
|
28870
28961
|
var readBinding = (file) => {
|
|
28871
28962
|
try {
|
|
28872
28963
|
const value = JSON.parse(fs29.readFileSync(file, "utf8"));
|
|
@@ -28891,7 +28982,7 @@ var bind = (input, worktree) => {
|
|
|
28891
28982
|
agentId,
|
|
28892
28983
|
at: new Date().toISOString()
|
|
28893
28984
|
};
|
|
28894
|
-
fs29.mkdirSync(
|
|
28985
|
+
fs29.mkdirSync(path47.dirname(file), { recursive: true });
|
|
28895
28986
|
fs29.writeFileSync(file, JSON.stringify(binding));
|
|
28896
28987
|
try {
|
|
28897
28988
|
if (inWorkitWorkspace(input.cwd))
|
|
@@ -28910,26 +29001,26 @@ var hostIsolated = (cwd, agentId) => {
|
|
|
28910
29001
|
const checkout = checkoutOf2(cwd);
|
|
28911
29002
|
if (!checkout)
|
|
28912
29003
|
return false;
|
|
28913
|
-
const dotGit =
|
|
29004
|
+
const dotGit = path47.join(checkout.root, ".git");
|
|
28914
29005
|
if (!fs29.statSync(dotGit).isFile())
|
|
28915
29006
|
return false;
|
|
28916
29007
|
const [adminDir, gitDir] = gitDirsAt(checkout.root, null, false) ?? [];
|
|
28917
|
-
const back = fs29.readFileSync(
|
|
28918
|
-
if (
|
|
29008
|
+
const back = fs29.readFileSync(path47.join(adminDir, "gitdir"), "utf8").trim();
|
|
29009
|
+
if (path47.relative(canonical5(path47.resolve(adminDir, back)), canonical5(dotGit)) !== "")
|
|
28919
29010
|
return false;
|
|
28920
|
-
const expected =
|
|
28921
|
-
return
|
|
29011
|
+
const expected = path47.join(path47.dirname(gitDir), ".claude", "worktrees", `agent-${agentId}`);
|
|
29012
|
+
return path47.relative(canonical5(expected), checkout.root) === "";
|
|
28922
29013
|
} catch {
|
|
28923
29014
|
return false;
|
|
28924
29015
|
}
|
|
28925
29016
|
};
|
|
28926
29017
|
var runnerAt = (target) => {
|
|
28927
|
-
const base =
|
|
29018
|
+
const base = path47.basename(target);
|
|
28928
29019
|
return base.startsWith(OPAQUE_TARGET) ? decodeURIComponent(base.slice(OPAQUE_TARGET.length)) : null;
|
|
28929
29020
|
};
|
|
28930
29021
|
var shown = (target) => {
|
|
28931
|
-
const named = /^\.workit-(?:live-target$|runs-)/.test(
|
|
28932
|
-
return
|
|
29022
|
+
const named = /^\.workit-(?:live-target$|runs-)/.test(path47.basename(target)) ? path47.dirname(target) : target;
|
|
29023
|
+
return path47.sep === "\\" ? named.replaceAll("/", "\\") : named;
|
|
28933
29024
|
};
|
|
28934
29025
|
var unboundDeny = (input, target) => {
|
|
28935
29026
|
const unblock = "Work only in the worktree your brief names, which the lead made with `workit fanout worktree create <slice>`: edit files under it and run one verb per call against it (`workit git --cwd <worktree> commit -m … -- <paths>`, `workit check --cwd <worktree> <name>`). If your brief names no worktree, stop and report that to the lead.";
|
|
@@ -28968,7 +29059,7 @@ var literalForm = (command, refs) => {
|
|
|
28968
29059
|
};
|
|
28969
29060
|
var unknownVarDeny = (input, worktree, targets, command) => {
|
|
28970
29061
|
const refs = [
|
|
28971
|
-
...new Set(targets.flatMap((target) =>
|
|
29062
|
+
...new Set(targets.flatMap((target) => path47.relative(UNKNOWN_VAR, path47.resolve(target)).split(path47.sep)[0].split("+").filter(Boolean).map(decodeURIComponent)))
|
|
28972
29063
|
];
|
|
28973
29064
|
let text = command ?? "";
|
|
28974
29065
|
const first = [];
|
|
@@ -28997,10 +29088,10 @@ function confineImplementer(input, targets, command) {
|
|
|
28997
29088
|
try {
|
|
28998
29089
|
if (!input.session.agentId || hostIsolated(input.cwd, input.session.agentId))
|
|
28999
29090
|
return NONE5;
|
|
29000
|
-
const unresolved = targets.filter((target) => within(
|
|
29091
|
+
const unresolved = targets.filter((target) => within(path47.resolve(target), UNKNOWN_VAR));
|
|
29001
29092
|
if (unresolved.length > 0)
|
|
29002
29093
|
return unknownVarDeny(input, boundWorktree(input), unresolved, command);
|
|
29003
|
-
if (targets.some((target) => within(
|
|
29094
|
+
if (targets.some((target) => within(path47.resolve(target), UNKNOWN_DIR)))
|
|
29004
29095
|
return unknownDirDeny(input, boundWorktree(input));
|
|
29005
29096
|
const bindings = canonical5(bindingDir());
|
|
29006
29097
|
const judged = targets.map((named) => ({ named, real: canonical5(named) })).filter(({ real }) => within(real, bindings) || checkoutOf2(real) !== null);
|
|
@@ -29111,10 +29202,10 @@ var INLINE = /^-[a-zA-Z]*[ceEpm]$|^--(?:eval|print|test|version|help)$|^-[hvV]$/
|
|
|
29111
29202
|
var VALUED = /^-[WXIrC]$|^--(?:require|import|loader|conditions|input-type)$/;
|
|
29112
29203
|
var commonDir = (root) => gitDirsAt(root, null, false)?.[1] ?? "";
|
|
29113
29204
|
var inScratch = (real, repo) => {
|
|
29114
|
-
for (let dir = real;
|
|
29115
|
-
if (
|
|
29205
|
+
for (let dir = real;path47.dirname(dir) !== dir; dir = path47.dirname(dir)) {
|
|
29206
|
+
if (path47.basename(dir) !== SCRATCH)
|
|
29116
29207
|
continue;
|
|
29117
|
-
const root =
|
|
29208
|
+
const root = path47.dirname(dir);
|
|
29118
29209
|
if (checkoutOf2(root)?.root === root && (repo === null || commonDir(root) === repo))
|
|
29119
29210
|
return true;
|
|
29120
29211
|
}
|
|
@@ -29123,7 +29214,7 @@ var inScratch = (real, repo) => {
|
|
|
29123
29214
|
var inGitDir = (real) => real.split(/[\\/]/).includes(".git");
|
|
29124
29215
|
var SAFE_KEY = /^(?:core\.(?:repositoryformatversion|filemode|bare|logallrefupdates|ignorecase|precomposeunicode|symlinks)|user\..*|init\.defaultbranch|commit\.gpgsign|extensions\.(?:objectformat|refstorage)|branch\..*\.(?:remote|merge)|remote\..*\.fetch)$/;
|
|
29125
29216
|
var literalIn = (value, repo, checkout = false) => {
|
|
29126
|
-
if (/[$`]/.test(value) || !
|
|
29217
|
+
if (/[$`]/.test(value) || !path47.isAbsolute(value))
|
|
29127
29218
|
return false;
|
|
29128
29219
|
const real = canonical5(value);
|
|
29129
29220
|
const root = checkout ? checkoutOf2(real)?.root : undefined;
|
|
@@ -29144,8 +29235,8 @@ var configEntries = (text) => {
|
|
|
29144
29235
|
return entries;
|
|
29145
29236
|
};
|
|
29146
29237
|
function gitDirsAt(dir, repo, scan = true) {
|
|
29147
|
-
for (let at = dir;; at =
|
|
29148
|
-
const dotGit =
|
|
29238
|
+
for (let at = dir;; at = path47.dirname(at)) {
|
|
29239
|
+
const dotGit = path47.join(at, ".git");
|
|
29149
29240
|
let gitDir = null;
|
|
29150
29241
|
try {
|
|
29151
29242
|
if (fs29.statSync(dotGit).isDirectory())
|
|
@@ -29154,19 +29245,19 @@ function gitDirsAt(dir, repo, scan = true) {
|
|
|
29154
29245
|
const named = /^gitdir:\s*(.+?)\s*$/mu.exec(fs29.readFileSync(dotGit, "utf8"))?.[1];
|
|
29155
29246
|
if (!named)
|
|
29156
29247
|
return null;
|
|
29157
|
-
gitDir = canonical5(
|
|
29248
|
+
gitDir = canonical5(path47.resolve(at, named));
|
|
29158
29249
|
}
|
|
29159
29250
|
} catch (error) {
|
|
29160
29251
|
if (error.code !== "ENOENT")
|
|
29161
29252
|
return null;
|
|
29162
|
-
if (["HEAD", "objects", "refs"].every((name) => fs29.existsSync(
|
|
29253
|
+
if (["HEAD", "objects", "refs"].every((name) => fs29.existsSync(path47.join(at, name))))
|
|
29163
29254
|
gitDir = canonical5(at);
|
|
29164
29255
|
}
|
|
29165
29256
|
if (gitDir !== null) {
|
|
29166
|
-
const common =
|
|
29167
|
-
const shared = fs29.existsSync(common) ? canonical5(
|
|
29257
|
+
const common = path47.join(gitDir, "commondir");
|
|
29258
|
+
const shared = fs29.existsSync(common) ? canonical5(path47.resolve(gitDir, fs29.readFileSync(common, "utf8").trim())) : gitDir;
|
|
29168
29259
|
const dirs = [gitDir, shared];
|
|
29169
|
-
for (const config of scan ? new Set([
|
|
29260
|
+
for (const config of scan ? new Set([path47.join(gitDir, "config"), path47.join(shared, "config")]) : []) {
|
|
29170
29261
|
let text = "";
|
|
29171
29262
|
try {
|
|
29172
29263
|
text = fs29.readFileSync(config, "utf8");
|
|
@@ -29175,14 +29266,14 @@ function gitDirsAt(dir, repo, scan = true) {
|
|
|
29175
29266
|
}
|
|
29176
29267
|
for (const [key, value] of configEntries(text)) {
|
|
29177
29268
|
if (key === "core.worktree")
|
|
29178
|
-
dirs.push(canonical5(
|
|
29269
|
+
dirs.push(canonical5(path47.resolve(gitDir, value)));
|
|
29179
29270
|
else if (/^remote\..*\.url$/.test(key) ? !literalIn(value, repo, true) : !SAFE_KEY.test(key))
|
|
29180
29271
|
return null;
|
|
29181
29272
|
}
|
|
29182
29273
|
}
|
|
29183
29274
|
return dirs;
|
|
29184
29275
|
}
|
|
29185
|
-
if (
|
|
29276
|
+
if (path47.dirname(at) === at)
|
|
29186
29277
|
return [];
|
|
29187
29278
|
}
|
|
29188
29279
|
}
|
|
@@ -29322,10 +29413,10 @@ var gitKind = (args, local = () => true) => {
|
|
|
29322
29413
|
};
|
|
29323
29414
|
var JUDGE_GIT = `a judge runs git ${Object.keys(GIT_VERBS).join(" ")} with the options each documents (no abbreviations), writing only in a scratch repo; no -c, no wrapper but timeout, nice, time, command, no env but PAGER=cat, GIT_PAGER=cat, GIT_OPTIONAL_LOCKS=0, LC_*, LANG, TZ; status outside scratch needs --no-optional-locks`;
|
|
29324
29415
|
var remoteIn = (dir, name, repo) => {
|
|
29325
|
-
const shared =
|
|
29416
|
+
const shared = path47.isAbsolute(dir) ? gitDirsAt(canonical5(dir), repo, false)?.[1] : undefined;
|
|
29326
29417
|
if (!shared)
|
|
29327
29418
|
return false;
|
|
29328
|
-
const url = configEntries(fs29.readFileSync(
|
|
29419
|
+
const url = configEntries(fs29.readFileSync(path47.join(shared, "config"), "utf8")).find(([key]) => key === `remote.${name}.url`.toLowerCase())?.[1];
|
|
29329
29420
|
return url !== undefined && literalIn(url, repo, true);
|
|
29330
29421
|
};
|
|
29331
29422
|
var judgeGit = (command, repo, depth = 0) => {
|
|
@@ -29339,7 +29430,7 @@ var judgeGit = (command, repo, depth = 0) => {
|
|
|
29339
29430
|
const lead = [];
|
|
29340
29431
|
while (/^\w+\+?=/.test(words[at] ?? ""))
|
|
29341
29432
|
lead.push(words[at++]);
|
|
29342
|
-
const name =
|
|
29433
|
+
const name = path47.basename(words[at] ?? "");
|
|
29343
29434
|
let start = words.findIndex((word) => /(?:^|[\\/])git(?:\.exe)?(?:=|$)/.test(word));
|
|
29344
29435
|
if (start > at) {
|
|
29345
29436
|
if (/^(?:grep|egrep|rg|echo|printf|ls|wc|head|tail|cat|which|type|test|\[|cd|mkdir)$/.test(name) || name === "command" && /^-[vV]$/.test(words[at + 1] ?? ""))
|
|
@@ -29350,7 +29441,7 @@ var judgeGit = (command, repo, depth = 0) => {
|
|
|
29350
29441
|
if (start >= 0 && words[start].includes("="))
|
|
29351
29442
|
why = "git is redefined";
|
|
29352
29443
|
const run = words[start] ?? "";
|
|
29353
|
-
if (run.includes("/") && (!
|
|
29444
|
+
if (run.includes("/") && (!path47.isAbsolute(run) || literalIn(run, repo, true)))
|
|
29354
29445
|
why ??= `\`${run}\` is not the system git`;
|
|
29355
29446
|
if (segment.expands?.includes(at) && name !== "[" || /\{[^}]*,/.test(words[at] ?? ""))
|
|
29356
29447
|
why = "the command's name is expanded by the shell";
|
|
@@ -29380,12 +29471,12 @@ var judgeGit = (command, repo, depth = 0) => {
|
|
|
29380
29471
|
if (!gitKind(args, local))
|
|
29381
29472
|
why = `\`git ${args.slice(0, 2).join(" ")}\` is not allowed`;
|
|
29382
29473
|
else if (args[0] === "status" && !unlocked) {
|
|
29383
|
-
const dirs =
|
|
29474
|
+
const dirs = path47.isAbsolute(dir) ? gitDirsAt(canonical5(dir), repo) : null;
|
|
29384
29475
|
if (!dirs?.length || !dirs.every((gitDir) => inScratch(gitDir, repo)))
|
|
29385
29476
|
why = "`git status` refreshes the index outside scratch: add --no-optional-locks";
|
|
29386
29477
|
}
|
|
29387
29478
|
}
|
|
29388
|
-
const shell = /^(?:grep|egrep|rg|echo|printf|cat)$/.test(name) ? -1 : words.findIndex((word) => /^(?:sh|bash|zsh|dash|ksh|mksh|ash)$/.test(
|
|
29479
|
+
const shell = /^(?:grep|egrep|rg|echo|printf|cat)$/.test(name) ? -1 : words.findIndex((word) => /^(?:sh|bash|zsh|dash|ksh|mksh|ash)$/.test(path47.basename(word)));
|
|
29389
29480
|
const scripts = [
|
|
29390
29481
|
...words.filter((_, after) => shell >= 0 && after > shell && /^-[a-zA-Z]*c[a-zA-Z]*$/.test(words[after - 1])),
|
|
29391
29482
|
...shell < 0 ? [] : segment.stdin ?? []
|
|
@@ -29426,7 +29517,7 @@ var judgeVerbRefused = (args) => {
|
|
|
29426
29517
|
var CLI_RUNNERS = /^(?:npx|bunx|pnpx|npm|pnpm|yarn|bun|node|nodejs|deno|tsx|ts-node)$/;
|
|
29427
29518
|
var CLI_ENTRY = /(?:^|[=\\/])(?:workit(?:\.(?:exe|cmd|[cm]?js))?|@workit-dev\/cli(?:@\S*)?)$|(?:workit-cli|@workit-dev[\\/]cli)[\\/](?:src[\\/](?:index|main)|dist[\\/]index)\.[cm]?[jt]sx?$/;
|
|
29428
29519
|
var workitCalls = (command, depth = 0, aliases = new Map) => depth > 4 ? [] : commandLines(command).flatMap((words) => {
|
|
29429
|
-
const name =
|
|
29520
|
+
const name = path47.basename(words[0] ?? "").toLowerCase();
|
|
29430
29521
|
if (name === "alias")
|
|
29431
29522
|
return words.flatMap((word) => {
|
|
29432
29523
|
const set = /^([\w-]+)=(.*)$/s.exec(word);
|
|
@@ -29456,11 +29547,11 @@ var judgeRefusal = (command, fed, depth = 0) => {
|
|
|
29456
29547
|
return why;
|
|
29457
29548
|
}
|
|
29458
29549
|
const { words } = segment;
|
|
29459
|
-
const runs = (word = "") => RUNS.test(
|
|
29550
|
+
const runs = (word = "") => RUNS.test(path47.basename(word).toLowerCase());
|
|
29460
29551
|
let at = 0;
|
|
29461
29552
|
while (at < words.length && (LEADS.test(words[at]) || /^-\w$/.test(words[at - 1] ?? "") && !runs(words[at])))
|
|
29462
29553
|
at++;
|
|
29463
|
-
const name =
|
|
29554
|
+
const name = path47.basename(words[at] ?? "").toLowerCase();
|
|
29464
29555
|
const args = words.slice(at + 1);
|
|
29465
29556
|
const unseen = `\`${words.join(" ").slice(0, 80)}\` runs a script Workit cannot read (piped, on stdin, a process substitution or eval): write the case to a file in ${SCRATCH} and dispatch it from a test instead`;
|
|
29466
29557
|
if (/^(?:cd|chdir|pushd|popd)$/.test(name))
|
|
@@ -29539,8 +29630,8 @@ var judgeDeny = (input, what, target) => {
|
|
|
29539
29630
|
const role = input.session.agentType?.endsWith("reviewer") ? "reviewer" : "verifier";
|
|
29540
29631
|
const root = checkoutOf2(input.cwd)?.root;
|
|
29541
29632
|
const candidate = target ? checkoutOf2(target)?.root : undefined;
|
|
29542
|
-
const also = root && candidate && candidate !== root && commonDir(candidate) === commonDir(root) ? ` or ${
|
|
29543
|
-
const scratch = root ? `${
|
|
29633
|
+
const also = root && candidate && candidate !== root && commonDir(candidate) === commonDir(root) ? ` or ${path47.join(candidate, SCRATCH)}` : "";
|
|
29634
|
+
const scratch = root ? `${path47.join(root, SCRATCH)}${also}` : `${SCRATCH}/ at the root of the checkout you judge`;
|
|
29544
29635
|
const unblock = `Write only under ${scratch} (mkdir -p it): put a generated case in a file there with a quoted heredoc (<<'EOF') and never run it in the shell. Reads, \`workit check\` and \`workit ledger verdict|finding\` stay allowed; a change the candidate needs is a finding, not an edit.`;
|
|
29545
29636
|
return {
|
|
29546
29637
|
kind: "deny",
|
|
@@ -29555,12 +29646,12 @@ function confineJudge(input, targets, placeholders = placeholdersOf(targets)) {
|
|
|
29555
29646
|
const judged = checkoutOf2(input.cwd);
|
|
29556
29647
|
const repo = judged ? commonDir(judged.root) : null;
|
|
29557
29648
|
for (const target of targets) {
|
|
29558
|
-
const resolved =
|
|
29649
|
+
const resolved = path47.resolve(target);
|
|
29559
29650
|
if (within(resolved, UNKNOWN_VAR) || within(resolved, UNKNOWN_DIR))
|
|
29560
29651
|
return judgeDeny(input, "it writes to a path Workit cannot resolve (a variable, a command substitution or `cd -`): spell the path out");
|
|
29561
29652
|
const real = canonical5(target);
|
|
29562
|
-
const runsGit = placeholders.has(target) && /^\.workit-(?:runs-git|live-target)$/.test(
|
|
29563
|
-
const gitDirs = runsGit ? gitDirsAt(
|
|
29653
|
+
const runsGit = placeholders.has(target) && /^\.workit-(?:runs-git|live-target)$/.test(path47.basename(target));
|
|
29654
|
+
const gitDirs = runsGit ? gitDirsAt(path47.dirname(real), repo) : [];
|
|
29564
29655
|
if (gitDirs === null)
|
|
29565
29656
|
return judgeDeny(input, `git in ${shown(target)} uses a git dir or config Workit cannot check`);
|
|
29566
29657
|
if (runsGit ? gitDirs.length > 0 ? gitDirs.every((dir) => inScratch(dir, repo)) : inScratch(real, repo) : inScratch(real, repo) && !inGitDir(real))
|
|
@@ -29601,7 +29692,7 @@ function confineJudgeShell(input, command, dialect = "posix") {
|
|
|
29601
29692
|
let git = [];
|
|
29602
29693
|
try {
|
|
29603
29694
|
git = rawInvocations(command, dialect).flatMap(({ tool, dir, args }) => tool === "git" && (args[0] === "push" || leadOwnedGit(args) || gitKind(args) === "write" && !/^(?:init|clone)$/.test(args[0])) ? [
|
|
29604
|
-
|
|
29695
|
+
path47.join(dir === undefined ? UNKNOWN_DIR : path47.resolve(input.cwd, dir ?? "."), `${OPAQUE_TARGET}git`)
|
|
29605
29696
|
] : []);
|
|
29606
29697
|
} catch {}
|
|
29607
29698
|
const lists = [
|
|
@@ -29646,7 +29737,7 @@ var judgeChecksLine = (cwd) => {
|
|
|
29646
29737
|
|
|
29647
29738
|
// packages/workit-core/src/hooks/standing.ts
|
|
29648
29739
|
var readPlans = (store) => {
|
|
29649
|
-
const dir =
|
|
29740
|
+
const dir = path48.join(store, "fanouts");
|
|
29650
29741
|
let names;
|
|
29651
29742
|
try {
|
|
29652
29743
|
names = fs30.readdirSync(dir).filter((name) => name.endsWith(".json"));
|
|
@@ -29656,7 +29747,7 @@ var readPlans = (store) => {
|
|
|
29656
29747
|
const plans = [];
|
|
29657
29748
|
for (const name of names) {
|
|
29658
29749
|
try {
|
|
29659
|
-
const raw = JSON.parse(fs30.readFileSync(
|
|
29750
|
+
const raw = JSON.parse(fs30.readFileSync(path48.join(dir, name), "utf8"));
|
|
29660
29751
|
if (typeof raw.name !== "string" || !Array.isArray(raw.slices))
|
|
29661
29752
|
continue;
|
|
29662
29753
|
const texts = (value) => Array.isArray(value) ? value.filter((item) => typeof item === "string" && item !== "") : [];
|
|
@@ -29867,7 +29958,7 @@ var cdWorkitSplit = (command) => {
|
|
|
29867
29958
|
// packages/workit-core/src/hooks/model-limit.ts
|
|
29868
29959
|
import { closeSync as closeSync3, openSync as openSync3, readdirSync as readdirSync7, readSync, statSync as statSync5 } from "node:fs";
|
|
29869
29960
|
import os10 from "node:os";
|
|
29870
|
-
import
|
|
29961
|
+
import path49 from "node:path";
|
|
29871
29962
|
var MONTHS = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"];
|
|
29872
29963
|
var WEEKDAYS = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"];
|
|
29873
29964
|
var TIME_WORD = String.raw`(?:\d|(?:in|at|on|later|tomorrow|soon)\b|(?:${[...WEEKDAYS, ...MONTHS].join("|")})[a-z]*\b)`;
|
|
@@ -30065,17 +30156,17 @@ var firstPrompt = (file) => {
|
|
|
30065
30156
|
var claudeProjectSlug = (cwd) => cwd.replace(/[^A-Za-z0-9]/gu, "-");
|
|
30066
30157
|
var listDir = (dir) => {
|
|
30067
30158
|
try {
|
|
30068
|
-
return readdirSync7(dir).map((name) =>
|
|
30159
|
+
return readdirSync7(dir).map((name) => path49.join(dir, name));
|
|
30069
30160
|
} catch {
|
|
30070
30161
|
return [];
|
|
30071
30162
|
}
|
|
30072
30163
|
};
|
|
30073
30164
|
var SCAN_MS = 30 * 60000;
|
|
30074
30165
|
var scanClaudeTranscripts = (cwd, env, now = new Date) => {
|
|
30075
|
-
const projects =
|
|
30076
|
-
const project =
|
|
30166
|
+
const projects = path49.join(env.CLAUDE_CONFIG_DIR || path49.join(env.HOME || os10.homedir(), ".claude"), "projects");
|
|
30167
|
+
const project = path49.join(projects, claudeProjectSlug(cwd));
|
|
30077
30168
|
const notes = [];
|
|
30078
|
-
const files = listDir(project).flatMap((entry) => entry.endsWith(".jsonl") ? [{ file: entry, worker: false }] : listDir(
|
|
30169
|
+
const files = listDir(project).flatMap((entry) => entry.endsWith(".jsonl") ? [{ file: entry, worker: false }] : listDir(path49.join(entry, "subagents")).filter((file) => file.endsWith(".jsonl")).map((file) => ({ file, worker: true })));
|
|
30079
30170
|
for (const { file, worker } of files)
|
|
30080
30171
|
try {
|
|
30081
30172
|
const stat = statSync5(file);
|
|
@@ -30090,7 +30181,7 @@ var scanClaudeTranscripts = (cwd, env, now = new Date) => {
|
|
|
30090
30181
|
if (!seen)
|
|
30091
30182
|
continue;
|
|
30092
30183
|
notes.push(worker ? redispatchNote(seen, {
|
|
30093
|
-
label: `worker ${
|
|
30184
|
+
label: `worker ${path49.basename(file, ".jsonl")}`,
|
|
30094
30185
|
prompt: firstPrompt(file)
|
|
30095
30186
|
}, now) : `Workit: this session hit a usage limit (${seen.reason}); ${seen.key} is marked exhausted until ${shortTime(seen.until)}. Claude Code runs only Anthropic models: Workit cannot switch this session, so continue on another host or after the reset.`);
|
|
30096
30187
|
} catch {}
|
|
@@ -30990,12 +31081,12 @@ var modelKey = (model) => {
|
|
|
30990
31081
|
};
|
|
30991
31082
|
|
|
30992
31083
|
// packages/workit-core/src/hooks/budget-signal.ts
|
|
30993
|
-
import { createHash as
|
|
31084
|
+
import { createHash as createHash23 } from "node:crypto";
|
|
30994
31085
|
import fs31 from "node:fs";
|
|
30995
|
-
import
|
|
30996
|
-
var hash2 = (text) =>
|
|
30997
|
-
var budgetDir = (store) =>
|
|
30998
|
-
var agentBase = (store, session, agentId) =>
|
|
31086
|
+
import path50 from "node:path";
|
|
31087
|
+
var hash2 = (text) => createHash23("sha256").update(text).digest("hex").slice(0, 32);
|
|
31088
|
+
var budgetDir = (store) => path50.join(store, "budget");
|
|
31089
|
+
var agentBase = (store, session, agentId) => path50.join(budgetDir(store), hash2(`${session}\x00${agentId ?? ""}`));
|
|
30999
31090
|
var spawnBudget = (prompt) => {
|
|
31000
31091
|
const found = /^TIMEBOX:[^\n]*?\b(\d+)\s+tool calls\b/mu.exec(prompt);
|
|
31001
31092
|
const n = found ? Number(found[1]) : NaN;
|
|
@@ -31015,8 +31106,8 @@ var startBudget = (store, session, agentId, n) => {
|
|
|
31015
31106
|
const cutoff = Date.now() - 604800000;
|
|
31016
31107
|
for (const name of fs31.readdirSync(dir))
|
|
31017
31108
|
try {
|
|
31018
|
-
if (fs31.statSync(
|
|
31019
|
-
fs31.rmSync(
|
|
31109
|
+
if (fs31.statSync(path50.join(dir, name)).mtimeMs < cutoff)
|
|
31110
|
+
fs31.rmSync(path50.join(dir, name));
|
|
31020
31111
|
} catch {}
|
|
31021
31112
|
const base = agentBase(store, session, agentId);
|
|
31022
31113
|
fs31.writeFileSync(`${base}.json`, JSON.stringify({ limit: n, told: 0 }));
|
|
@@ -31155,11 +31246,11 @@ var unfinishedTaskOffer2 = (ctx) => {
|
|
|
31155
31246
|
};
|
|
31156
31247
|
|
|
31157
31248
|
// packages/workit-core/src/hooks/repeat-failure.ts
|
|
31158
|
-
import { createHash as
|
|
31249
|
+
import { createHash as createHash24 } from "node:crypto";
|
|
31159
31250
|
var SAME_CALL_FAILED = "Same call failed twice:";
|
|
31160
31251
|
var MAX_SESSIONS = 256;
|
|
31161
31252
|
var stable = (value) => JSON.stringify(value, (_key, entry) => entry && typeof entry === "object" && !Array.isArray(entry) ? Object.fromEntries(Object.entries(entry).toSorted(([a], [b]) => a.localeCompare(b))) : entry) ?? "null";
|
|
31162
|
-
var hashOf = (call) =>
|
|
31253
|
+
var hashOf = (call) => createHash24("sha256").update(call).digest("hex").slice(0, 32);
|
|
31163
31254
|
var record2 = (memo, sessionId, call, failed, next) => {
|
|
31164
31255
|
const previous = memo.get(sessionId);
|
|
31165
31256
|
memo.delete(sessionId);
|
|
@@ -31352,16 +31443,17 @@ ${shown.join(`
|
|
|
31352
31443
|
};
|
|
31353
31444
|
}
|
|
31354
31445
|
};
|
|
31355
|
-
var askInline = async (
|
|
31446
|
+
var askInline = async (call, command, event, ctx) => {
|
|
31356
31447
|
try {
|
|
31357
|
-
const ask = inlineAskFor(words, ctx.cwd);
|
|
31448
|
+
const ask = inlineAskFor(call.words, inlineCallCwd(call, ctx.cwd));
|
|
31358
31449
|
if (!ask)
|
|
31359
31450
|
return;
|
|
31360
31451
|
const choice = await ctx.ui.select(ask.text, [APPROVE, REJECT]);
|
|
31452
|
+
const nothing = ask.kind === "release-notes" ? "nothing was approved" : "nothing was posted";
|
|
31361
31453
|
if (choice !== APPROVE)
|
|
31362
31454
|
return {
|
|
31363
31455
|
block: true,
|
|
31364
|
-
reason: choice === REJECT ? `The user rejected ${ask.action}: nothing
|
|
31456
|
+
reason: choice === REJECT ? `The user rejected ${ask.action}: ${nothing}. Do not retry it; report that it was not approved.` : `The user dismissed the dialog for ${ask.action}: ${nothing}.`
|
|
31365
31457
|
};
|
|
31366
31458
|
const { ticket } = recordInlineAsk({
|
|
31367
31459
|
kind: ask.kind,
|
|
@@ -31399,12 +31491,12 @@ var enforceToolPolicy = (event, ctx) => {
|
|
|
31399
31491
|
if (inline && !inline.plain)
|
|
31400
31492
|
return { block: true, reason: inlineCallDeny(inline.fix) };
|
|
31401
31493
|
if (inline?.plain && ctx.mode === "tui" && ctx.hasUI) {
|
|
31402
|
-
const gated = gate({
|
|
31494
|
+
const gated = isReleaseNotesCall(inline.words) && inlineAskFor(inline.words, inlineCallCwd(inline, ctx.cwd)) ? undefined : gate({
|
|
31403
31495
|
kind: "shell.pre",
|
|
31404
31496
|
command,
|
|
31405
31497
|
toolUseId: event.toolCallId ?? null
|
|
31406
31498
|
});
|
|
31407
|
-
return gated ?? askInline(inline
|
|
31499
|
+
return gated ?? askInline(inline, command, event, ctx);
|
|
31408
31500
|
}
|
|
31409
31501
|
return typeof command === "string" ? gate({
|
|
31410
31502
|
kind: "shell.pre",
|
|
@@ -31468,14 +31560,14 @@ var observeToolResult = (event, ctx) => {
|
|
|
31468
31560
|
var skillPromptNudge = (prompt, ctx) => process.env.WORKIT_PI_WORKER_SESSION ? null : promptNudge(hookInput(ctx, { kind: "context.turn", prompt }), prompt);
|
|
31469
31561
|
|
|
31470
31562
|
// packages/workit-pi/src/launches.ts
|
|
31471
|
-
import { mkdirSync as mkdirSync7, readFileSync as
|
|
31563
|
+
import { mkdirSync as mkdirSync7, readFileSync as readFileSync16, readdirSync as readdirSync8, rmSync as rmSync4, writeFileSync as writeFileSync6 } from "node:fs";
|
|
31472
31564
|
import os11 from "node:os";
|
|
31473
|
-
import
|
|
31565
|
+
import path51 from "node:path";
|
|
31474
31566
|
var launchDir = (root) => {
|
|
31475
31567
|
const location = resolveStore(root);
|
|
31476
|
-
return location instanceof Error ? null :
|
|
31568
|
+
return location instanceof Error ? null : path51.join(location.dir, "pi-launches");
|
|
31477
31569
|
};
|
|
31478
|
-
var fileFor = (dir, workerId) =>
|
|
31570
|
+
var fileFor = (dir, workerId) => path51.join(dir, `${workerId.replace(/[^A-Za-z0-9-]/g, "_")}.json`);
|
|
31479
31571
|
var recordLaunch = (root, attempt) => {
|
|
31480
31572
|
const dir = launchDir(root);
|
|
31481
31573
|
if (!dir)
|
|
@@ -31521,7 +31613,7 @@ var abandonedLaunches = (root) => {
|
|
|
31521
31613
|
const found = [];
|
|
31522
31614
|
for (const name of names) {
|
|
31523
31615
|
try {
|
|
31524
|
-
const attempt = JSON.parse(
|
|
31616
|
+
const attempt = JSON.parse(readFileSync16(path51.join(dir, name), "utf8"));
|
|
31525
31617
|
if (typeof attempt.workerId === "string" && typeof attempt.session === "string") {
|
|
31526
31618
|
if (!alive(attempt))
|
|
31527
31619
|
found.push(attempt);
|
|
@@ -31533,18 +31625,18 @@ var abandonedLaunches = (root) => {
|
|
|
31533
31625
|
var cancelHint = (workerId) => `cancel it first: workit_worker {"action":"cancel","workerId":"${workerId}","reason":"launch outcome unknown"} (CLI: workit worker cancel --payload '{"workerId":"${workerId}","reason":"launch outcome unknown"}')`;
|
|
31534
31626
|
|
|
31535
31627
|
// packages/workit-core/src/core/cli-locate.ts
|
|
31536
|
-
import { closeSync as closeSync4, existsSync as
|
|
31537
|
-
import
|
|
31628
|
+
import { closeSync as closeSync4, existsSync as existsSync16, openSync as openSync4, readSync as readSync2 } from "node:fs";
|
|
31629
|
+
import path52 from "node:path";
|
|
31538
31630
|
var LAUNCHER_MARKER = "workit-owned-launcher";
|
|
31539
31631
|
var CLI_PACKAGE_PATH = ["node_modules", "@workit-dev", "cli"];
|
|
31540
31632
|
var installRoot = (env, platform = process.platform) => {
|
|
31541
31633
|
if (env.WORKIT_INSTALL_ROOT)
|
|
31542
31634
|
return env.WORKIT_INSTALL_ROOT;
|
|
31543
31635
|
const data = dataDir(env, platform);
|
|
31544
|
-
return platform === "win32" ?
|
|
31636
|
+
return platform === "win32" ? path52.join(data, "install") : data;
|
|
31545
31637
|
};
|
|
31546
|
-
var ownedLauncherPath = (env, platform = process.platform) =>
|
|
31547
|
-
var ownedCurrentEntry = (env, platform = process.platform) =>
|
|
31638
|
+
var ownedLauncherPath = (env, platform = process.platform) => path52.join(installRoot(env, platform), "bin", platform === "win32" ? "workit.cmd" : "workit");
|
|
31639
|
+
var ownedCurrentEntry = (env, platform = process.platform) => path52.join(installRoot(env, platform), "current", ...CLI_PACKAGE_PATH, "dist", "index.js");
|
|
31548
31640
|
var head = (file) => {
|
|
31549
31641
|
let fd;
|
|
31550
31642
|
try {
|
|
@@ -31562,7 +31654,7 @@ var head = (file) => {
|
|
|
31562
31654
|
var locateWorkitCli = (options = {}) => {
|
|
31563
31655
|
const env = options.env ?? process.env;
|
|
31564
31656
|
const platform = options.platform ?? process.platform;
|
|
31565
|
-
const exists = options.exists ??
|
|
31657
|
+
const exists = options.exists ?? existsSync16;
|
|
31566
31658
|
const read = options.read ?? head;
|
|
31567
31659
|
const node = options.node ?? process.execPath;
|
|
31568
31660
|
const launcher = ownedLauncherPath(env, platform);
|
|
@@ -31571,7 +31663,7 @@ var locateWorkitCli = (options = {}) => {
|
|
|
31571
31663
|
source: "owned-launcher",
|
|
31572
31664
|
command: launcher,
|
|
31573
31665
|
args: [],
|
|
31574
|
-
binDir:
|
|
31666
|
+
binDir: path52.dirname(launcher)
|
|
31575
31667
|
};
|
|
31576
31668
|
const current = ownedCurrentEntry(env, platform);
|
|
31577
31669
|
if (exists(current))
|
|
@@ -31600,7 +31692,7 @@ var workitCliEnv = (located, env = process.env, platform = process.platform) =>
|
|
|
31600
31692
|
if (located.binDir) {
|
|
31601
31693
|
const key = pathKey(env);
|
|
31602
31694
|
const delimiter = platform === "win32" ? ";" : ":";
|
|
31603
|
-
const same = (dir) => platform === "win32" ?
|
|
31695
|
+
const same = (dir) => platform === "win32" ? path52.win32.normalize(dir).toLowerCase() === path52.win32.normalize(located.binDir).toLowerCase() : path52.posix.normalize(dir) === path52.posix.normalize(located.binDir);
|
|
31604
31696
|
const rest = (env[key] ?? "").split(delimiter).filter((dir) => dir && !same(dir));
|
|
31605
31697
|
patch[key] = [located.binDir, ...rest].join(delimiter);
|
|
31606
31698
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: workit-continue
|
|
3
|
-
description: Keep work on track across interruptions and sessions - sort new input, checkpoint, hand off with a resume brief,
|
|
3
|
+
description: Keep work on track across interruptions and sessions - sort new input, checkpoint, hand off with a resume brief, pick up by verifying claims. Use for resume, pick up, handoff, leaving, tomorrow, end of day, pause, interruption, change of direction.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Continue without losing the thread
|
|
@@ -12,8 +12,7 @@ description: Keep work on track across interruptions and sessions - sort new inp
|
|
|
12
12
|
keep going.
|
|
13
13
|
- **Separate request:** do not silently resume an old objective, and do not
|
|
14
14
|
drop the current one. Checkpoint it (below) if it must continue later, then
|
|
15
|
-
start the new work. Held items stay parked with their resume condition
|
|
16
|
-
the user resumes them.
|
|
15
|
+
start the new work. Held items stay parked with their resume condition.
|
|
17
16
|
|
|
18
17
|
## Checkpoint and hand off
|
|
19
18
|
|
|
@@ -25,8 +24,9 @@ workit handoff --note "<state in one line>" --next "<next command>" --record
|
|
|
25
24
|
The brief carries the branch, HEAD, dirty state, check freshness, verdict,
|
|
26
25
|
rulings and the next command. Add only what it cannot know: choices still
|
|
27
26
|
open, approaches that failed and why. Work spanning repos gets one brief per
|
|
28
|
-
checkout, each with its branch and delivery endpoint. Notes
|
|
29
|
-
|
|
27
|
+
checkout, each with its branch and delivery endpoint. Notes, drafts and logs
|
|
28
|
+
go in `workit dir notes` or `workit dir handoffs`, never the repo tree; name
|
|
29
|
+
the file in `--note`.
|
|
30
30
|
|
|
31
31
|
## Pick up
|
|
32
32
|
|
|
@@ -40,8 +40,8 @@ checkout, each with its branch and delivery endpoint. Notes too long for
|
|
|
40
40
|
|
|
41
41
|
## Example
|
|
42
42
|
|
|
43
|
-
Bad: a new session re-reads the
|
|
44
|
-
|
|
43
|
+
Bad: a new session re-reads the codebase, re-asks a settled approach and
|
|
44
|
+
redoes a finished slice.
|
|
45
45
|
|
|
46
46
|
Good: "`workit handoff`: feature/usage at 4be1, `test` stale, verdict none,
|
|
47
47
|
next `workit check test`. Re-ran it: exit 0. The brief says PR #42 is open:
|
|
@@ -23,9 +23,10 @@
|
|
|
23
23
|
get, from the user's pointers, in their words, not commit subjects.
|
|
24
24
|
Rerunning draft keeps them. Under `review`, finish refuses
|
|
25
25
|
(`release_notes_unapproved`) until the user approves: show the user the
|
|
26
|
-
draft
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
full draft in chat, then run `workit release notes approve <version>`
|
|
27
|
+
as its own call: Claude Code and Pi ask the user on it. If refused, ask
|
|
28
|
+
the user to run the command it names in their terminal. Edit the draft
|
|
29
|
+
after approval only when they ask, then they approve again.
|
|
29
30
|
4. Interrupted (a conflict, a failed push, no forge release yet): fix the
|
|
30
31
|
cause and rerun the `resume` command it printed. Steps already done are
|
|
31
32
|
skipped, never repeated.
|