@workit-dev/pi 1.0.3 → 1.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/dist/worker.js +37 -16
- package/dist/workit.js +48 -21
- package/package.json +1 -1
- package/skills/workit-ship/SKILL.md +1 -1
package/dist/worker.js
CHANGED
|
@@ -9736,36 +9736,54 @@ var DESCRIPTORS = {
|
|
|
9736
9736
|
pi: PI_DESCRIPTOR
|
|
9737
9737
|
};
|
|
9738
9738
|
var workerOfLead = (input) => input.session.agentType === null || workitRole(DESCRIPTORS[input.host], input.session.agentType) !== null;
|
|
9739
|
-
var worksFor = (plan, input,
|
|
9739
|
+
var worksFor = (plan, input, branches) => {
|
|
9740
9740
|
const session = input.session.id;
|
|
9741
9741
|
if (plan.leads.includes(session) && !input.session.agentId)
|
|
9742
|
-
return
|
|
9742
|
+
return null;
|
|
9743
|
+
if (branches.some((branch) => plan.branches.includes(branch)))
|
|
9744
|
+
return "slice";
|
|
9743
9745
|
const lead = leadOf(input);
|
|
9744
9746
|
if (lead && plan.leads.includes(lead) && workerOfLead(input))
|
|
9745
|
-
return
|
|
9746
|
-
|
|
9747
|
-
|
|
9748
|
-
|
|
9749
|
-
|
|
9747
|
+
return "lead";
|
|
9748
|
+
return plan.leads.some((each) => session.startsWith(`${each}-w-`)) ? "lead" : null;
|
|
9749
|
+
};
|
|
9750
|
+
var agentBranches = (input, rows) => {
|
|
9751
|
+
const { id, agentId } = input.session;
|
|
9752
|
+
const bound = agentId ? rows.findLast((row) => row.type === "worktree.bound" && row.actor.session === id && row.actor.agentId === agentId && typeof row.worktree === "string")?.worktree : undefined;
|
|
9753
|
+
const dirs = typeof bound === "string" ? [input.cwd, bound] : [input.cwd];
|
|
9754
|
+
return dirs.map((dir) => currentBranch(dir)).filter((branch) => !!branch);
|
|
9750
9755
|
};
|
|
9751
9756
|
var standingFor = (input, store, rev) => {
|
|
9752
9757
|
const orders = new Map;
|
|
9753
9758
|
const ledger = readLedger(input.cwd);
|
|
9754
9759
|
const rows = ledger.ok ? ledger.value.rows : [];
|
|
9755
|
-
|
|
9756
|
-
const
|
|
9757
|
-
|
|
9758
|
-
|
|
9759
|
-
|
|
9760
|
-
|
|
9761
|
-
|
|
9760
|
+
const branches = agentBranches(input, rows);
|
|
9761
|
+
const matched = readPlans(store).map((plan) => ({
|
|
9762
|
+
plan,
|
|
9763
|
+
how: worksFor(plan, input, branches)
|
|
9764
|
+
}));
|
|
9765
|
+
const tied = matched.some(({ how }) => how === "slice");
|
|
9766
|
+
const plans = matched.filter(({ how }) => tied ? how === "slice" : how !== null);
|
|
9767
|
+
for (const { plan } of plans)
|
|
9768
|
+
for (const row of activeStanding(rows, plan.name, plan.leads.length ? plan.leads : null))
|
|
9769
|
+
orders.set(row.id, row);
|
|
9770
|
+
return {
|
|
9771
|
+
rev,
|
|
9772
|
+
orders,
|
|
9773
|
+
rows,
|
|
9774
|
+
fanouts: new Set(plans.map(({ plan }) => plan.name))
|
|
9775
|
+
};
|
|
9762
9776
|
};
|
|
9763
9777
|
var located = (input) => {
|
|
9764
9778
|
const store = input.session.id ? gitStoreDir(input.cwd) : null;
|
|
9765
9779
|
const rev = store ? readStandingRev(store) : null;
|
|
9766
9780
|
if (!store || rev === null)
|
|
9767
9781
|
return null;
|
|
9768
|
-
return {
|
|
9782
|
+
return {
|
|
9783
|
+
store,
|
|
9784
|
+
rev,
|
|
9785
|
+
file: standingSeenFile(store, input.session.id, input.session.agentId)
|
|
9786
|
+
};
|
|
9769
9787
|
};
|
|
9770
9788
|
var seedStanding = (input) => {
|
|
9771
9789
|
try {
|
|
@@ -9773,7 +9791,10 @@ var seedStanding = (input) => {
|
|
|
9773
9791
|
if (!where)
|
|
9774
9792
|
return;
|
|
9775
9793
|
const now = standingFor(input, where.store, where.rev);
|
|
9776
|
-
writeStandingSeen(where.file, {
|
|
9794
|
+
writeStandingSeen(where.file, {
|
|
9795
|
+
rev: where.rev,
|
|
9796
|
+
ids: [...now.orders.keys()]
|
|
9797
|
+
});
|
|
9777
9798
|
} catch {}
|
|
9778
9799
|
};
|
|
9779
9800
|
var sinceStart = new Map;
|
package/dist/workit.js
CHANGED
|
@@ -15242,6 +15242,7 @@ var DOC_EXT = /\.(?:md|mdx|markdown|rst|adoc)$/iu;
|
|
|
15242
15242
|
var DOC_NAMES = /^(?:license|licence|notice|authors|changelog|changes|contributors)$/iu;
|
|
15243
15243
|
var INSTRUCTIONS = /(?:^|\/)(?:AGENTS|CLAUDE|GEMINI|SKILL)\.md$|(?:^|\/)(?:skills|agents|commands|rules|prompts)\/[^/]+/iu;
|
|
15244
15244
|
var TEST_PATH = /(?:^|\/)(?:test|tests|__tests__)\/|\.(?:test|spec)\.[^/]+$|_test\.[^/]+$/iu;
|
|
15245
|
+
var plural = (count, noun) => `${count} ${noun}${count === 1 ? "" : "s"}`;
|
|
15245
15246
|
var basename = (file) => file.slice(file.lastIndexOf("/") + 1);
|
|
15246
15247
|
var isDoc = (file) => !INSTRUCTIONS.test(file) && (DOC_EXT.test(file) || DOC_NAMES.test(basename(file)));
|
|
15247
15248
|
function kindOf(file) {
|
|
@@ -15300,6 +15301,8 @@ function computeLane(input) {
|
|
|
15300
15301
|
const behavior = kinds.filter((entry) => entry.kind === "behavior" || entry.kind === "test" || entry.kind === "lockfile");
|
|
15301
15302
|
const lines = behavior.filter((entry) => entry.kind !== "lockfile").reduce((sum, entry) => sum + entry.file.added + entry.file.deleted, 0);
|
|
15302
15303
|
const opaque = behavior.filter((entry) => entry.kind === "lockfile" || entry.file.binary);
|
|
15304
|
+
const diffLines = input.files.reduce((sum, file) => sum + file.added + file.deleted, 0);
|
|
15305
|
+
const counted = diffLines === lines && input.files.length === behavior.length ? "" : ` counted (the whole diff is ${plural(diffLines, "line")} in ${plural(input.files.length, "file")}; docs, comments, formatting, generated copies and lockfile lines are not counted)`;
|
|
15303
15306
|
const result = (lane, reasons) => ({
|
|
15304
15307
|
lane,
|
|
15305
15308
|
reasons,
|
|
@@ -15319,9 +15322,9 @@ function computeLane(input) {
|
|
|
15319
15322
|
input.files.length ? "only docs, comments, formatting or generated copies changed" : "no changes"
|
|
15320
15323
|
]);
|
|
15321
15324
|
if (lines >= fullMinLines)
|
|
15322
|
-
return result("full", [`large diff: ${lines} lines (≥ ${fullMinLines})`]);
|
|
15325
|
+
return result("full", [`large diff: ${lines} lines (≥ ${fullMinLines})${counted}`]);
|
|
15323
15326
|
if (lines > selfMaxLines)
|
|
15324
|
-
return result("focused", [`${lines} lines changed (> ${selfMaxLines})`]);
|
|
15327
|
+
return result("focused", [`${lines} lines changed (> ${selfMaxLines})${counted}`]);
|
|
15325
15328
|
if (behavior.length > selfMaxFiles)
|
|
15326
15329
|
return result("focused", [`${behavior.length} behavior files changed (> ${selfMaxFiles})`]);
|
|
15327
15330
|
if (opaque.length)
|
|
@@ -15329,7 +15332,7 @@ function computeLane(input) {
|
|
|
15329
15332
|
`a lockfile or binary changed: ${opaque.slice(0, 3).map((entry) => entry.file.path).join(", ")}${opaque.length > 3 ? ", …" : ""}`
|
|
15330
15333
|
]);
|
|
15331
15334
|
return result("self", [
|
|
15332
|
-
`small change: ${lines
|
|
15335
|
+
`small change: ${plural(lines, "line")} in ${plural(behavior.length, "file")}${counted}, no risk path`
|
|
15333
15336
|
]);
|
|
15334
15337
|
}
|
|
15335
15338
|
function untrackedStat(cwd, file) {
|
|
@@ -27473,36 +27476,54 @@ var DESCRIPTORS = {
|
|
|
27473
27476
|
pi: PI_DESCRIPTOR
|
|
27474
27477
|
};
|
|
27475
27478
|
var workerOfLead = (input) => input.session.agentType === null || workitRole(DESCRIPTORS[input.host], input.session.agentType) !== null;
|
|
27476
|
-
var worksFor = (plan, input,
|
|
27479
|
+
var worksFor = (plan, input, branches) => {
|
|
27477
27480
|
const session = input.session.id;
|
|
27478
27481
|
if (plan.leads.includes(session) && !input.session.agentId)
|
|
27479
|
-
return
|
|
27482
|
+
return null;
|
|
27483
|
+
if (branches.some((branch) => plan.branches.includes(branch)))
|
|
27484
|
+
return "slice";
|
|
27480
27485
|
const lead = leadOf2(input);
|
|
27481
27486
|
if (lead && plan.leads.includes(lead) && workerOfLead(input))
|
|
27482
|
-
return
|
|
27483
|
-
|
|
27484
|
-
|
|
27485
|
-
|
|
27486
|
-
|
|
27487
|
+
return "lead";
|
|
27488
|
+
return plan.leads.some((each) => session.startsWith(`${each}-w-`)) ? "lead" : null;
|
|
27489
|
+
};
|
|
27490
|
+
var agentBranches = (input, rows) => {
|
|
27491
|
+
const { id, agentId } = input.session;
|
|
27492
|
+
const bound = agentId ? rows.findLast((row) => row.type === "worktree.bound" && row.actor.session === id && row.actor.agentId === agentId && typeof row.worktree === "string")?.worktree : undefined;
|
|
27493
|
+
const dirs = typeof bound === "string" ? [input.cwd, bound] : [input.cwd];
|
|
27494
|
+
return dirs.map((dir) => currentBranch(dir)).filter((branch) => !!branch);
|
|
27487
27495
|
};
|
|
27488
27496
|
var standingFor = (input, store, rev) => {
|
|
27489
27497
|
const orders = new Map;
|
|
27490
27498
|
const ledger = readLedger(input.cwd);
|
|
27491
27499
|
const rows = ledger.ok ? ledger.value.rows : [];
|
|
27492
|
-
|
|
27493
|
-
const
|
|
27494
|
-
|
|
27495
|
-
|
|
27496
|
-
|
|
27497
|
-
|
|
27498
|
-
|
|
27500
|
+
const branches = agentBranches(input, rows);
|
|
27501
|
+
const matched = readPlans(store).map((plan) => ({
|
|
27502
|
+
plan,
|
|
27503
|
+
how: worksFor(plan, input, branches)
|
|
27504
|
+
}));
|
|
27505
|
+
const tied = matched.some(({ how }) => how === "slice");
|
|
27506
|
+
const plans = matched.filter(({ how }) => tied ? how === "slice" : how !== null);
|
|
27507
|
+
for (const { plan } of plans)
|
|
27508
|
+
for (const row of activeStanding(rows, plan.name, plan.leads.length ? plan.leads : null))
|
|
27509
|
+
orders.set(row.id, row);
|
|
27510
|
+
return {
|
|
27511
|
+
rev,
|
|
27512
|
+
orders,
|
|
27513
|
+
rows,
|
|
27514
|
+
fanouts: new Set(plans.map(({ plan }) => plan.name))
|
|
27515
|
+
};
|
|
27499
27516
|
};
|
|
27500
27517
|
var located = (input) => {
|
|
27501
27518
|
const store = input.session.id ? gitStoreDir(input.cwd) : null;
|
|
27502
27519
|
const rev = store ? readStandingRev(store) : null;
|
|
27503
27520
|
if (!store || rev === null)
|
|
27504
27521
|
return null;
|
|
27505
|
-
return {
|
|
27522
|
+
return {
|
|
27523
|
+
store,
|
|
27524
|
+
rev,
|
|
27525
|
+
file: standingSeenFile(store, input.session.id, input.session.agentId)
|
|
27526
|
+
};
|
|
27506
27527
|
};
|
|
27507
27528
|
var seedStanding = (input) => {
|
|
27508
27529
|
try {
|
|
@@ -27510,7 +27531,10 @@ var seedStanding = (input) => {
|
|
|
27510
27531
|
if (!where)
|
|
27511
27532
|
return;
|
|
27512
27533
|
const now = standingFor(input, where.store, where.rev);
|
|
27513
|
-
writeStandingSeen(where.file, {
|
|
27534
|
+
writeStandingSeen(where.file, {
|
|
27535
|
+
rev: where.rev,
|
|
27536
|
+
ids: [...now.orders.keys()]
|
|
27537
|
+
});
|
|
27514
27538
|
} catch {}
|
|
27515
27539
|
};
|
|
27516
27540
|
var fanoutOf = (row) => typeof row.fanout === "string" ? row.fanout : "?";
|
|
@@ -27518,7 +27542,7 @@ var changedSince = (now, ids) => {
|
|
|
27518
27542
|
const known = new Set(ids);
|
|
27519
27543
|
const added = [...now.orders.values()].filter((row) => !known.has(row.id));
|
|
27520
27544
|
const byId = new Map(now.rows.map((row) => [row.id, row]));
|
|
27521
|
-
const dropped = ids.filter((id) => !now.orders.has(id)).map((id) => byId.get(id)).filter((row) => row !== undefined);
|
|
27545
|
+
const dropped = ids.filter((id) => !now.orders.has(id)).map((id) => byId.get(id)).filter((row) => row !== undefined && now.fanouts.has(fanoutOf(row)));
|
|
27522
27546
|
if (!added.length && !dropped.length)
|
|
27523
27547
|
return null;
|
|
27524
27548
|
const fanouts = [...new Set([...added, ...dropped].map(fanoutOf))].join(", ");
|
|
@@ -27541,7 +27565,10 @@ var standingDelta = (input) => {
|
|
|
27541
27565
|
if (seen.rev === where.rev)
|
|
27542
27566
|
return null;
|
|
27543
27567
|
const now = standingFor(input, where.store, where.rev);
|
|
27544
|
-
writeStandingSeen(where.file, {
|
|
27568
|
+
writeStandingSeen(where.file, {
|
|
27569
|
+
rev: where.rev,
|
|
27570
|
+
ids: [...now.orders.keys()]
|
|
27571
|
+
});
|
|
27545
27572
|
return changedSince(now, seen.ids);
|
|
27546
27573
|
} catch {
|
|
27547
27574
|
return null;
|
package/package.json
CHANGED
|
@@ -41,7 +41,7 @@ the same check. Fix round and recheck both failed: a decider (read the `workit-f
|
|
|
41
41
|
and the stop point unless merge is granted.
|
|
42
42
|
3. **Conflicts or a required rebase.** Rewrite only a branch this session or
|
|
43
43
|
its stack created (yours in `workit ledger list --type commit.recorded` or
|
|
44
|
-
`workit stack status`):
|
|
44
|
+
`workit stack status`): `workit git rebase`, then `workit git push
|
|
45
45
|
--force-with-lease` (`workit stack sync` in a stack). Anyone else's branch:
|
|
46
46
|
report that a rebase is needed and stop.
|
|
47
47
|
4. **Review threads** (`workit pr threads`). Check each claim in the code; fix
|