@workit-dev/pi 1.6.0 → 1.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 +2 -1
- package/dist/workit.js +127 -7
- package/package.json +1 -1
package/dist/worker.js
CHANGED
|
@@ -7373,7 +7373,8 @@ var workspaceConfigSchema = object({
|
|
|
7373
7373
|
]))).passthrough().optional().describe("Autonomy grants (D15): only ever set here, by the user, with `workit grant set`."),
|
|
7374
7374
|
youtrack: object({
|
|
7375
7375
|
baseUrl: nonBlank.optional().describe("This workspace's YouTrack URL."),
|
|
7376
|
-
link_issues: boolean2().optional().describe("Legacy alias of `issues: { provider: youtrack, link: true }`.")
|
|
7376
|
+
link_issues: boolean2().optional().describe("Legacy alias of `issues: { provider: youtrack, link: true }`."),
|
|
7377
|
+
writes: _enum(["ask", "auto"]).optional().describe("ask (default): each workit youtrack write waits for the user's yes. auto: posts without asking, behind WORKIT_YT_WRITE=1.")
|
|
7377
7378
|
}).passthrough().optional().describe("YouTrack settings for this workspace."),
|
|
7378
7379
|
issues: object({
|
|
7379
7380
|
provider: _enum(["github", "gitlab", "youtrack"]).optional().describe("The issue tracker PRs link to."),
|
package/dist/workit.js
CHANGED
|
@@ -9732,7 +9732,8 @@ var workspaceConfigSchema = object({
|
|
|
9732
9732
|
]))).passthrough().optional().describe("Autonomy grants (D15): only ever set here, by the user, with `workit grant set`."),
|
|
9733
9733
|
youtrack: object({
|
|
9734
9734
|
baseUrl: nonBlank.optional().describe("This workspace's YouTrack URL."),
|
|
9735
|
-
link_issues: boolean2().optional().describe("Legacy alias of `issues: { provider: youtrack, link: true }`.")
|
|
9735
|
+
link_issues: boolean2().optional().describe("Legacy alias of `issues: { provider: youtrack, link: true }`."),
|
|
9736
|
+
writes: _enum(["ask", "auto"]).optional().describe("ask (default): each workit youtrack write waits for the user's yes. auto: posts without asking, behind WORKIT_YT_WRITE=1.")
|
|
9736
9737
|
}).passthrough().optional().describe("YouTrack settings for this workspace."),
|
|
9737
9738
|
issues: object({
|
|
9738
9739
|
provider: _enum(["github", "gitlab", "youtrack"]).optional().describe("The issue tracker PRs link to."),
|
|
@@ -20586,7 +20587,10 @@ var actionsIn = (cwd, command, dialect, cache = new Map, all = false) => {
|
|
|
20586
20587
|
continue;
|
|
20587
20588
|
const action = rawAction(invocation);
|
|
20588
20589
|
const at = !action ? null : repoFor(invocation.dir) ?? (all && invocation.tool !== "git" && explicitRepo(invocation.tool === "gh", "repo" in action && action.repo || "", invocation.env ?? {}) ? {
|
|
20589
|
-
repo: {
|
|
20590
|
+
repo: {
|
|
20591
|
+
dir: path27.resolve(cwd, invocation.dir ?? "."),
|
|
20592
|
+
branch: null
|
|
20593
|
+
},
|
|
20590
20594
|
workit: false
|
|
20591
20595
|
} : null);
|
|
20592
20596
|
if (action && at)
|
|
@@ -20633,6 +20637,109 @@ var pkillSelfMatch = (command, dialect) => {
|
|
|
20633
20637
|
}
|
|
20634
20638
|
return null;
|
|
20635
20639
|
};
|
|
20640
|
+
var policyDeclared = () => {
|
|
20641
|
+
try {
|
|
20642
|
+
return !!readConfigTyped().config?.branchPolicy?.protected?.length;
|
|
20643
|
+
} catch {
|
|
20644
|
+
return false;
|
|
20645
|
+
}
|
|
20646
|
+
};
|
|
20647
|
+
var word = (text) => /^[\w./@%+:,=-]+$/u.test(text) ? text : shellQuote(text);
|
|
20648
|
+
var HEREDOC = /^cat <<(['"])(\w+)\1\n([\s\S]*)\n\2\n?$/u;
|
|
20649
|
+
var messageOf = (segment, index) => {
|
|
20650
|
+
const text = segment.words[index];
|
|
20651
|
+
if (text === undefined)
|
|
20652
|
+
return null;
|
|
20653
|
+
if (!segment.expands?.includes(index))
|
|
20654
|
+
return text;
|
|
20655
|
+
const sub = segment.subs?.find((each) => text === `$(${each})`);
|
|
20656
|
+
const match = sub === undefined ? null : HEREDOC.exec(sub);
|
|
20657
|
+
if (!match || match[3].split(`
|
|
20658
|
+
`).includes(match[2]))
|
|
20659
|
+
return null;
|
|
20660
|
+
return match[3].replace(/\n+$/u, "");
|
|
20661
|
+
};
|
|
20662
|
+
var cdCommitCall = (input, command, target, repo) => {
|
|
20663
|
+
const { top, git, dir: store } = repo.location;
|
|
20664
|
+
if (!top || !git || git.gitDir === path27.dirname(store) || repoAt(input.cwd)?.location.top === top)
|
|
20665
|
+
return null;
|
|
20666
|
+
const bare = command.replaceAll(/'[^']*'|"(?:[^"\\]|\\.)*"/gu, "").replaceAll("&&", "");
|
|
20667
|
+
if (/[;|&<>`$()\n\\]/u.test(bare))
|
|
20668
|
+
return null;
|
|
20669
|
+
const [cd, ...rest] = segmentsOf(command);
|
|
20670
|
+
const commit = rest.at(-1);
|
|
20671
|
+
if (cd?.words[0] !== "cd" || cd.words.length !== 2 || cd.expands?.length || !commit)
|
|
20672
|
+
return null;
|
|
20673
|
+
if (path27.resolve(input.cwd, cd.words[1]) !== target)
|
|
20674
|
+
return null;
|
|
20675
|
+
if (rest.some((each) => each.redirects.length || each.stdin?.length || each.group))
|
|
20676
|
+
return null;
|
|
20677
|
+
const adds = rest.slice(0, -1);
|
|
20678
|
+
if (!adds.length || commit.words[0] !== "git" || commit.words[1] !== "commit")
|
|
20679
|
+
return null;
|
|
20680
|
+
const paths = [];
|
|
20681
|
+
let all = false;
|
|
20682
|
+
for (const add of adds) {
|
|
20683
|
+
const [tool, verb, ...args] = add.words;
|
|
20684
|
+
if (tool !== "git" || verb !== "add" || add.expands?.length || add.subs?.length)
|
|
20685
|
+
return null;
|
|
20686
|
+
const named = args.filter((arg) => !["-A", "--all", "--"].includes(arg));
|
|
20687
|
+
if (named.some((arg) => arg.startsWith("-") || /[*?[\]]/u.test(arg)))
|
|
20688
|
+
return null;
|
|
20689
|
+
if (!named.length && !args.some((arg) => arg === "-A" || arg === "--all"))
|
|
20690
|
+
return null;
|
|
20691
|
+
if (named.length)
|
|
20692
|
+
paths.push(...named);
|
|
20693
|
+
else
|
|
20694
|
+
all = true;
|
|
20695
|
+
}
|
|
20696
|
+
const messages = [];
|
|
20697
|
+
let allowEmpty = false;
|
|
20698
|
+
for (let index = 2;index < commit.words.length; index++) {
|
|
20699
|
+
const arg = commit.words[index];
|
|
20700
|
+
let message = null;
|
|
20701
|
+
if (arg === "--allow-empty") {
|
|
20702
|
+
allowEmpty = true;
|
|
20703
|
+
continue;
|
|
20704
|
+
}
|
|
20705
|
+
if (arg === "-m" || arg === "--message")
|
|
20706
|
+
message = messageOf(commit, ++index);
|
|
20707
|
+
else if (!commit.expands?.includes(index) && /^(?:-m|--message=)./u.test(arg))
|
|
20708
|
+
message = arg.replace(/^(?:-m|--message=)/u, "");
|
|
20709
|
+
if (!message || message.startsWith("-"))
|
|
20710
|
+
return null;
|
|
20711
|
+
messages.push(message);
|
|
20712
|
+
}
|
|
20713
|
+
if (!messages.length)
|
|
20714
|
+
return null;
|
|
20715
|
+
if (!all) {
|
|
20716
|
+
const staged = spawnSync15("git", ["diff", "--cached", "--quiet"], {
|
|
20717
|
+
cwd: target,
|
|
20718
|
+
timeout: 5000
|
|
20719
|
+
});
|
|
20720
|
+
if (staged.status !== 0)
|
|
20721
|
+
return null;
|
|
20722
|
+
}
|
|
20723
|
+
return [
|
|
20724
|
+
`workit git --cwd ${word(target)} commit`,
|
|
20725
|
+
...messages.map((message) => `-m ${shellQuote(message)}`),
|
|
20726
|
+
...allowEmpty ? ["--allow-empty"] : [],
|
|
20727
|
+
all ? "--all" : `-- ${[...new Set(paths)].map(word).join(" ")}`
|
|
20728
|
+
].join(" ");
|
|
20729
|
+
};
|
|
20730
|
+
var commitRefusal = (input, command, dialect, { action, repo, invocation, workit }) => {
|
|
20731
|
+
if (action.kind !== "commit" || !(workit || policyDeclared()))
|
|
20732
|
+
return null;
|
|
20733
|
+
const switches = workitInvocations(command, dialect).length > 0 || rawInvocations(command, dialect).some((raw) => ["switch", "checkout", "worktree"].includes(raw.args[0] ?? ""));
|
|
20734
|
+
let guarded = false;
|
|
20735
|
+
try {
|
|
20736
|
+
guarded = !!repo.branch && resolveBranchPolicyFor(repo.dir).protected.has(repo.branch.toLowerCase());
|
|
20737
|
+
} catch {}
|
|
20738
|
+
if (guarded && !switches)
|
|
20739
|
+
return `workit: raw ${quote("git commit")} on ${repo.branch}, a protected branch. Branch first: ${quote("workit git branch --kind feature --slug <slug>")} (uncommitted changes come along), then ${quote("workit git commit -m '<msg>' -- <paths>")}.`;
|
|
20740
|
+
const call = action.amend || dialect !== "posix" || typeof invocation.dir !== "string" ? null : cdCommitCall(input, command, path27.resolve(input.cwd, invocation.dir), repo);
|
|
20741
|
+
return call && `workit: no ${quote("cd … &&")} chain; run ${quote(call)}.`;
|
|
20742
|
+
};
|
|
20636
20743
|
function rawGitPre(input, command, options = {}) {
|
|
20637
20744
|
try {
|
|
20638
20745
|
const dialect = dialectOf(input);
|
|
@@ -20648,6 +20755,11 @@ function rawGitPre(input, command, options = {}) {
|
|
|
20648
20755
|
if (refused)
|
|
20649
20756
|
return deny(refused);
|
|
20650
20757
|
}
|
|
20758
|
+
for (const found of located) {
|
|
20759
|
+
const refused = commitRefusal(input, command, dialect, found);
|
|
20760
|
+
if (refused)
|
|
20761
|
+
return deny(refused);
|
|
20762
|
+
}
|
|
20651
20763
|
for (const { action, repo, invocation, workit } of located) {
|
|
20652
20764
|
if (!workit)
|
|
20653
20765
|
continue;
|
|
@@ -28872,7 +28984,11 @@ var usageLimitOnStop = (input, agentId, text) => {
|
|
|
28872
28984
|
return;
|
|
28873
28985
|
if (!firstSighting(`subagent-stop:${input.session.id}:${agentId ?? ""}`))
|
|
28874
28986
|
return;
|
|
28875
|
-
recordUsageLimit(text, {
|
|
28987
|
+
recordUsageLimit(text, {
|
|
28988
|
+
cwd: input.cwd,
|
|
28989
|
+
host: input.host,
|
|
28990
|
+
model: input.model ?? null
|
|
28991
|
+
});
|
|
28876
28992
|
} catch {}
|
|
28877
28993
|
};
|
|
28878
28994
|
var subagentSession = (session, agentId) => [session, agentId].filter((part) => Boolean(part)).join(":").replace(/[^A-Za-z0-9_.:@/+-]/g, "-").slice(0, 128);
|
|
@@ -28968,9 +29084,6 @@ function decide(input, deps) {
|
|
|
28968
29084
|
const postTool = usable2(descriptor.events["shell.post"].support);
|
|
28969
29085
|
if (!postTool)
|
|
28970
29086
|
settlePendingCommit(input);
|
|
28971
|
-
const raw = canDeny ? rawGitPre(input, event.command, { nudge: false }) : NONE6;
|
|
28972
|
-
if (raw.kind === "deny")
|
|
28973
|
-
return raw;
|
|
28974
29087
|
const userOnly = userOnlyWorkitCall(event.command, event.dialect);
|
|
28975
29088
|
if (userOnly) {
|
|
28976
29089
|
if (input.host === "claude_code")
|
|
@@ -28991,6 +29104,9 @@ function decide(input, deps) {
|
|
|
28991
29104
|
if (confined.kind === "deny")
|
|
28992
29105
|
return confined;
|
|
28993
29106
|
}
|
|
29107
|
+
const raw = canDeny ? rawGitPre(input, event.command, { nudge: false }) : NONE6;
|
|
29108
|
+
if (raw.kind === "deny")
|
|
29109
|
+
return raw;
|
|
28994
29110
|
const owner = role === "judge" ? null : liveOwner(input, descriptor.transport);
|
|
28995
29111
|
const gate = usable2(descriptor.events["write.pre"].support) ? shellGate(input.cwd, event.command, owner, event.dialect) : NONE6;
|
|
28996
29112
|
if (gate.kind === "deny")
|
|
@@ -29053,7 +29169,11 @@ function decide(input, deps) {
|
|
|
29053
29169
|
trackJudge(input, event.agentId, true);
|
|
29054
29170
|
seedStanding({
|
|
29055
29171
|
...input,
|
|
29056
|
-
session: {
|
|
29172
|
+
session: {
|
|
29173
|
+
...input.session,
|
|
29174
|
+
agentId: event.agentId,
|
|
29175
|
+
agentType: event.agentType
|
|
29176
|
+
}
|
|
29057
29177
|
});
|
|
29058
29178
|
deps.budget?.start(input, event.agentId, event.agentType);
|
|
29059
29179
|
return {
|