@workit-dev/opencode 2.29.2 → 2.29.4
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/assets/skills/workit-ship/SKILL.md +1 -1
- package/dist/plugin.js +502 -52
- package/package.json +2 -2
|
@@ -53,7 +53,7 @@ the same check. Fix round and recheck both failed: the decider agent (call the s
|
|
|
53
53
|
with `workit check`, fix the root cause, batch every fix in one push, one focused commit per fix (unrelated hunks in one file: `workit git stage --patch <file>`, then `workit git commit -m "<msg>" --staged`). A tool warning is a finding: fix it in this PR in the right layer, or record the false positive with evidence; pre-existing ones get their own PR.
|
|
54
54
|
6. **Verified.** The lane in `workit pr status` decides: none, no verdict; self, your `--self` verdict; focused or full (or `verification: self|independent`), one non-author verifier per PR after the last push, never per push (call the skill tool with `workit-review`), on Claude Code with the `model` and `effort` of `workit models show --role verifier`. A docs-only push (or test-only under a unit verdict) keeps the verdict (`carried`); `reverify: focused` re-checks only the new diff, reusing green CI; one verdict at a stack's top covers its unchanged lower PRs. Land only when
|
|
55
55
|
granted: `workit stack land` or `workit pr merge`; `--unverified --reason` if user-asked.
|
|
56
|
-
Never pipe a delivery verb through `grep`, `tail` or `head`: read its exit code, or use `--json`. Trunk CI after a merge: `workit ci wait --branch <trunk>`.
|
|
56
|
+
Never pipe a delivery verb through `grep`, `tail` or `head`: read its exit code, or use `--json`. Trunk CI after a merge: `workit ci wait --branch <trunk>`. Run each delivery verb alone, verb first (`workit pr merge --cwd <dir> …`), never chained. A classifier denial of a chained granted verb: rerun it once alone; a plain call denied: ask the user in chat, never hand it to their terminal.
|
|
57
57
|
7. **Observe it landed:** `workit verify-delivery pr` or `merge`. After a failed
|
|
58
58
|
verdict or a check red 3+ times, at any endpoint: offer `/wk-retro` in one
|
|
59
59
|
line of the final or stop report; never pause the babysit loop for it.
|
package/dist/plugin.js
CHANGED
|
@@ -18979,7 +18979,9 @@ Autonomy contract:
|
|
|
18979
18979
|
- Continue to the requested endpoint without asking "continue?", running
|
|
18980
18980
|
checks and repairs.
|
|
18981
18981
|
Stop only for a new consequential choice, a host denial, a conflicting edit
|
|
18982
|
-
or an unresolved blocker; report open gaps and uncertain workers.
|
|
18982
|
+
or an unresolved blocker; report open gaps and uncertain workers. A
|
|
18983
|
+
classifier denying a chained granted verb: rerun it once alone, verb first;
|
|
18984
|
+
a plain call denied: ask in chat, never a terminal hand-off.
|
|
18983
18985
|
- No endpoint named: stop at a local commit on a policy-compliant branch and
|
|
18984
18986
|
state the next command. If the request implies delivery (fix, implement,
|
|
18985
18987
|
ship), go to the effective endpoint in \`workit grant show\`: \`pr\` stops
|
|
@@ -21007,7 +21009,7 @@ function walk2(command, dialect, depth, seen, inherited = {}) {
|
|
|
21007
21009
|
for (const invocation of inside)
|
|
21008
21010
|
found.push({ ...invocation, dir: rebase(dir, invocation.dir) });
|
|
21009
21011
|
};
|
|
21010
|
-
const visit = (input, stdin, hops) => {
|
|
21012
|
+
const visit = (input, stdin, hops, expands = "all") => {
|
|
21011
21013
|
const line = /^\$[\w:]+$/.test(input[0] ?? "") && input[1] === "=" ? input.slice(2) : input;
|
|
21012
21014
|
const split = splitString(line);
|
|
21013
21015
|
if (split !== null)
|
|
@@ -21069,15 +21071,18 @@ function walk2(command, dialect, depth, seen, inherited = {}) {
|
|
|
21069
21071
|
nested(cmdScript(words), "powershell");
|
|
21070
21072
|
else if (name === "xargs" || name === "find")
|
|
21071
21073
|
runs(name === "xargs" ? xargsCommands(words, stdin) : findCommands(words));
|
|
21072
|
-
else if (name === "gh" || name === "glab")
|
|
21074
|
+
else if (name === "gh" || name === "glab") {
|
|
21075
|
+
const shift = input.length - words.length + 1;
|
|
21076
|
+
const expanded = expands === "all" ? expands : expands.filter((at) => at >= shift).map((at) => at - shift);
|
|
21073
21077
|
found.push({
|
|
21074
21078
|
tool: name,
|
|
21075
21079
|
dir,
|
|
21076
21080
|
args: words.slice(1),
|
|
21077
21081
|
...Object.keys({ ...exported, ...env }).length ? { env: { ...exported, ...env } } : {},
|
|
21078
|
-
...stdin === undefined ? {} : { stdin }
|
|
21082
|
+
...stdin === undefined ? {} : { stdin },
|
|
21083
|
+
...expanded.length ? { expanded } : {}
|
|
21079
21084
|
});
|
|
21080
|
-
else if (name === "git") {
|
|
21085
|
+
} else if (name === "git") {
|
|
21081
21086
|
const invocation = gitInvocation(words.slice(1), dir, { ...exported, ...env }, stdin, sessionConfig);
|
|
21082
21087
|
found.push(invocation);
|
|
21083
21088
|
sessionConfig.push(...configSetBy(invocation.args));
|
|
@@ -21110,7 +21115,7 @@ function walk2(command, dialect, depth, seen, inherited = {}) {
|
|
|
21110
21115
|
}
|
|
21111
21116
|
const stdin = stdinOf(segment, segments[index - 1]);
|
|
21112
21117
|
for (const line of substitute(segment.words, vars))
|
|
21113
|
-
visit(line, stdin, 0);
|
|
21118
|
+
visit(line, stdin, 0, segment.expands ?? []);
|
|
21114
21119
|
}
|
|
21115
21120
|
return found;
|
|
21116
21121
|
}
|
|
@@ -21405,55 +21410,232 @@ var API_VALUES = new Set(["--method", "--header", "--raw-field", "--field", "--j
|
|
|
21405
21410
|
var API_SHORT_VALUES = "XHfFqtp";
|
|
21406
21411
|
var API_FIELDS = new Set(["-f", "-F", "--raw-field", "--field"]);
|
|
21407
21412
|
var API_MERGE = {
|
|
21408
|
-
gh: /(?:^|\/)(?:pulls\/[^/?#]+\/merge|merges)
|
|
21409
|
-
glab: /(?:^|\/)merge_requests\/[^/?#]+\/merge
|
|
21413
|
+
gh: /(?:^|\/)(?:pulls\/[^/?#]+\/merge|merges)\/?$/i,
|
|
21414
|
+
glab: /(?:^|\/)merge_requests\/[^/?#]+\/merge\/?$/i
|
|
21410
21415
|
};
|
|
21411
21416
|
var GRAPHQL_MERGE = /\b(?:mergePullRequest|enablePullRequestAutoMerge|mergeBranch|mergeRequestAccept)\b/;
|
|
21412
|
-
var
|
|
21413
|
-
|
|
21417
|
+
var GH_REPO_PATH = String.raw`(?:^|\/)(?:repos\/[^/]+\/[^/]+|repositories\/[^/]+)`;
|
|
21418
|
+
var ghPath = (rest) => new RegExp(`${GH_REPO_PATH}\\/${rest}(?:\\/|$)`, "i");
|
|
21419
|
+
var called = (names) => new RegExp(String.raw`\b(?:${names})(?:[\s,\uFEFF]|#[^\n\r]*[\n\r])*\(`);
|
|
21420
|
+
var GRAPHQL_REF = [
|
|
21421
|
+
[called("createRef|updateRefs?|deleteRef"), "ref"],
|
|
21422
|
+
[
|
|
21423
|
+
called("createCommitOnBranch|createLinkedBranch|createBranch|branchDelete|commitCreate"),
|
|
21424
|
+
"branch"
|
|
21425
|
+
],
|
|
21426
|
+
[called("tagCreate|tagDelete"), "tag"]
|
|
21427
|
+
];
|
|
21428
|
+
var GRAPHQL_SETTING = called("(?:create|update|delete)(?:BranchProtectionRule|RepositoryRuleset)|branchRule(?:Create|Update|Delete)");
|
|
21429
|
+
var API_REF = {
|
|
21430
|
+
gh: [
|
|
21431
|
+
[ghPath(String.raw`git\/refs?`), "ref"],
|
|
21432
|
+
[ghPath(String.raw`(?:branches\/.+\/rename|merge-upstream|contents)`), "branch"]
|
|
21433
|
+
],
|
|
21434
|
+
glab: [
|
|
21435
|
+
[/(?:^|\/)repository\/tags(?:\/|$)/i, "tag"],
|
|
21436
|
+
[/(?:^|\/)repository\/(?:branches|merged_branches|files|submodules)(?:\/|$)/i, "branch"],
|
|
21437
|
+
[/(?:^|\/)repository\/commits(?:\/[^/]+\/(?:cherry_pick|revert))?\/?$/i, "branch"]
|
|
21438
|
+
]
|
|
21439
|
+
};
|
|
21440
|
+
var API_SETTING = {
|
|
21441
|
+
gh: [
|
|
21442
|
+
ghPath(String.raw`(?:branches\/.+|tags)\/protection`),
|
|
21443
|
+
ghPath("rulesets"),
|
|
21444
|
+
ghPath(String.raw`environments\/[^/]+\/deployment-branch-policies`),
|
|
21445
|
+
/(?:^|\/)orgs\/[^/]+\/rulesets(?:\/|$)/i
|
|
21446
|
+
],
|
|
21447
|
+
glab: [
|
|
21448
|
+
/(?:^|\/)(?:projects|groups)\/[^/]+\/protected_(?:branches|tags)(?:\/|$)/i,
|
|
21449
|
+
/(?:^|\/)projects\/[^/]+\/push_rule(?:\/|$)/i
|
|
21450
|
+
]
|
|
21451
|
+
};
|
|
21452
|
+
var API_REPOSITORY = {
|
|
21453
|
+
gh: new RegExp(`${GH_REPO_PATH}\\/?$`, "i"),
|
|
21454
|
+
glab: /(?:^|\/)projects\/[^/]+\/?$/i
|
|
21455
|
+
};
|
|
21456
|
+
var PLAIN_REF = /^refs\/(?:heads|tags)\/(?!.*\.\.)[^\s$`\\%]+$/;
|
|
21457
|
+
var BY_ID = called("updateRefs?|deleteRef");
|
|
21458
|
+
var createdRefs = (query) => {
|
|
21459
|
+
if (/[\\$]|"""/.test(query))
|
|
21460
|
+
return null;
|
|
21461
|
+
const tokens = query.match(/#[^\n\r]*|"[^"\n\r]*"|[_A-Za-z]\w*|[^\s,\uFEFF]/g) ?? [];
|
|
21462
|
+
const named = [];
|
|
21463
|
+
for (let at = 0;at < tokens.length; at++) {
|
|
21464
|
+
if (tokens[at] !== "createRef")
|
|
21465
|
+
continue;
|
|
21466
|
+
const args = tokens.slice(at + 1).filter((token) => !token.startsWith("#"));
|
|
21467
|
+
if (args[0] !== "(")
|
|
21468
|
+
continue;
|
|
21469
|
+
let depth = 0;
|
|
21470
|
+
const names = [];
|
|
21471
|
+
for (let index = 0;index < args.length; index++) {
|
|
21472
|
+
const token = args[index];
|
|
21473
|
+
if (token === "(" || token === "{" || token === "[")
|
|
21474
|
+
depth++;
|
|
21475
|
+
else if (token === ")" || token === "}" || token === "]") {
|
|
21476
|
+
if (--depth === 0)
|
|
21477
|
+
break;
|
|
21478
|
+
} else if (token === "name" && args[index + 1] === ":")
|
|
21479
|
+
names.push(args[index + 2] ?? "");
|
|
21480
|
+
}
|
|
21481
|
+
if (depth !== 0 || names.length !== 1 || !names[0].startsWith('"'))
|
|
21482
|
+
return null;
|
|
21483
|
+
named.push(names[0].slice(1, -1));
|
|
21484
|
+
}
|
|
21485
|
+
return named;
|
|
21486
|
+
};
|
|
21487
|
+
var provablyRead = (query) => /^[\s,\uFEFF]*(?:\{|query[\s,\uFEFF]*[({])/.test(query) && !/\b(?:mutation|subscription)\b/.test(query);
|
|
21488
|
+
var refWrite = (forge, shapes, named, certain) => {
|
|
21489
|
+
const sure = certain && named.length > 0 && named.every((ref) => PLAIN_REF.test(ref));
|
|
21490
|
+
const tags = !sure || named.some((ref) => ref.startsWith("refs/tags/"));
|
|
21491
|
+
const heads = !sure || named.some((ref) => ref.startsWith("refs/heads/"));
|
|
21492
|
+
const ref = shapes.has("ref");
|
|
21493
|
+
return {
|
|
21494
|
+
kind: "ref-write",
|
|
21495
|
+
forge,
|
|
21496
|
+
tag: shapes.has("tag") || ref && tags,
|
|
21497
|
+
branch: shapes.has("branch") || ref && heads,
|
|
21498
|
+
...ref && sure ? { ref: named[0] } : {}
|
|
21499
|
+
};
|
|
21500
|
+
};
|
|
21501
|
+
var restRef = (route, fields, readable) => {
|
|
21502
|
+
const inPath = /\/git\/refs?\/(.+)$/i.exec(route)?.[1];
|
|
21503
|
+
if (inPath)
|
|
21504
|
+
return { named: [`refs/${inPath}`], certain: true };
|
|
21505
|
+
const refs = fields.filter((field) => field.startsWith("ref=")).map((field) => field.slice(4));
|
|
21506
|
+
const mentions = fields.filter((field) => /refs\//.test(field)).length;
|
|
21507
|
+
return { named: refs, certain: readable && refs.length === 1 && mentions === 1 };
|
|
21508
|
+
};
|
|
21509
|
+
var routeOf = (endpoint) => endpoint.replace(/(?<!:)\/{2,}/g, "/").replace(/[?#][\s\S]*$/, "").replace(/%([\da-f]{2})/gi, (escape, hex) => {
|
|
21510
|
+
const char = String.fromCodePoint(Number.parseInt(hex, 16));
|
|
21511
|
+
return /[\w.~-]/.test(char) ? char : escape;
|
|
21512
|
+
});
|
|
21513
|
+
var apiAction = (tool, args, stdin, expanded = []) => {
|
|
21514
|
+
const request = { method: null, body: false, input: false, unread: false };
|
|
21414
21515
|
let endpoint = null;
|
|
21516
|
+
let endpointAt = -1;
|
|
21415
21517
|
const values = [];
|
|
21416
|
-
const
|
|
21518
|
+
const fields = [];
|
|
21519
|
+
const queries = [];
|
|
21520
|
+
const field = (value, expands) => {
|
|
21521
|
+
fields.push(value);
|
|
21522
|
+
values.push(value);
|
|
21523
|
+
if (!value.startsWith("query="))
|
|
21524
|
+
return;
|
|
21525
|
+
const text = value.slice(6);
|
|
21526
|
+
const read = expanded !== "all" && (!(expands && /[$`]/.test(text)) || provablyRead(text));
|
|
21527
|
+
queries.push({ text, read });
|
|
21528
|
+
};
|
|
21529
|
+
const fromStdin = (name, value, text) => {
|
|
21530
|
+
if (name !== "--input") {
|
|
21531
|
+
if (text.includes("\\"))
|
|
21532
|
+
request.unread = true;
|
|
21533
|
+
return field(`${value.slice(0, value.indexOf("=") + 1)}${text}`, true);
|
|
21534
|
+
}
|
|
21535
|
+
values.push(text);
|
|
21536
|
+
let body;
|
|
21537
|
+
try {
|
|
21538
|
+
body = JSON.parse(text);
|
|
21539
|
+
} catch {
|
|
21540
|
+
request.unread = true;
|
|
21541
|
+
return;
|
|
21542
|
+
}
|
|
21543
|
+
const strings = (each) => typeof each === "string" ? [each] : each && typeof each === "object" ? Object.entries(each).flatMap(([key, inner]) => [key, ...strings(inner)]) : [];
|
|
21544
|
+
if (!body || typeof body !== "object" || Array.isArray(body)) {
|
|
21545
|
+
values.push(...strings(body));
|
|
21546
|
+
return;
|
|
21547
|
+
}
|
|
21548
|
+
for (const [key, inner] of Object.entries(body)) {
|
|
21549
|
+
if (typeof inner === "string")
|
|
21550
|
+
field(`${key}=${inner}`, true);
|
|
21551
|
+
else
|
|
21552
|
+
values.push(key, ...strings(inner));
|
|
21553
|
+
}
|
|
21554
|
+
};
|
|
21555
|
+
const take = (name, value, at) => {
|
|
21556
|
+
const expands = expanded === "all" || expanded.includes(at);
|
|
21417
21557
|
if (name === "-X" || name === "--method")
|
|
21418
21558
|
request.method = value.toUpperCase();
|
|
21419
21559
|
if (API_FIELDS.has(name) || name === "--input")
|
|
21420
21560
|
request.body = true;
|
|
21421
|
-
|
|
21422
|
-
|
|
21423
|
-
|
|
21424
|
-
|
|
21561
|
+
if (name === "--input")
|
|
21562
|
+
request.input = true;
|
|
21563
|
+
const piped = name === "--input" ? value === "-" : /^(?:-F|--field)$/.test(name) && /^[^=]*=@-$/.test(value);
|
|
21564
|
+
if (piped && stdin !== undefined) {
|
|
21565
|
+
values.push(value);
|
|
21566
|
+
return fromStdin(name, value, stdin);
|
|
21567
|
+
}
|
|
21568
|
+
if (API_FIELDS.has(name))
|
|
21569
|
+
field(value, expands);
|
|
21570
|
+
else
|
|
21571
|
+
values.push(value);
|
|
21572
|
+
const file = name === "--input" || /^(?:-F|--field)$/.test(name) && /^[^=]*=@/.test(value);
|
|
21573
|
+
if (file)
|
|
21574
|
+
request.unread = true;
|
|
21425
21575
|
};
|
|
21426
21576
|
for (let index = 1;index < args.length; index++) {
|
|
21427
21577
|
const arg = args[index];
|
|
21428
21578
|
if (arg === "--") {
|
|
21429
|
-
endpoint
|
|
21579
|
+
if (endpoint === null)
|
|
21580
|
+
[endpoint, endpointAt] = [args[index + 1] ?? null, index + 1];
|
|
21430
21581
|
break;
|
|
21431
21582
|
}
|
|
21432
21583
|
if (arg.startsWith("--")) {
|
|
21433
21584
|
const eq = arg.indexOf("=");
|
|
21434
21585
|
const name = eq > 0 ? arg.slice(0, eq) : arg;
|
|
21435
21586
|
if (API_VALUES.has(name))
|
|
21436
|
-
take(name, eq > 0 ? arg.slice(eq + 1) : args[++index] ?? "");
|
|
21587
|
+
take(name, eq > 0 ? arg.slice(eq + 1) : args[++index] ?? "", index);
|
|
21437
21588
|
} else if (arg.startsWith("-") && arg.length > 1) {
|
|
21438
21589
|
for (let at = 1;at < arg.length; at++) {
|
|
21439
21590
|
if (!API_SHORT_VALUES.includes(arg[at]))
|
|
21440
21591
|
continue;
|
|
21441
|
-
take(`-${arg[at]}`, at + 1 < arg.length ? arg.slice(at + 1) : args[++index] ?? "");
|
|
21592
|
+
take(`-${arg[at]}`, at + 1 < arg.length ? arg.slice(at + 1) : args[++index] ?? "", index);
|
|
21442
21593
|
break;
|
|
21443
21594
|
}
|
|
21444
|
-
} else
|
|
21445
|
-
endpoint
|
|
21595
|
+
} else if (endpoint === null)
|
|
21596
|
+
[endpoint, endpointAt] = [arg, index];
|
|
21446
21597
|
}
|
|
21447
21598
|
if (!endpoint)
|
|
21448
21599
|
return null;
|
|
21449
|
-
|
|
21600
|
+
const atEndpoint = expanded === "all" || expanded.includes(endpointAt);
|
|
21601
|
+
for (const pair of /[?]([^#]*)/.exec(endpoint)?.[1].split("&") ?? []) {
|
|
21602
|
+
let decoded = pair;
|
|
21603
|
+
try {
|
|
21604
|
+
decoded = decodeURIComponent(pair.replaceAll("+", " "));
|
|
21605
|
+
} catch {
|
|
21606
|
+
request.unread = true;
|
|
21607
|
+
}
|
|
21608
|
+
field(decoded, atEndpoint);
|
|
21609
|
+
if (/refs\//i.test(decoded))
|
|
21610
|
+
request.input = true;
|
|
21611
|
+
}
|
|
21612
|
+
const route = routeOf(endpoint);
|
|
21450
21613
|
const merge = { kind: "merge", forge: tool, via: "api" };
|
|
21451
|
-
|
|
21452
|
-
|
|
21614
|
+
const setting = {
|
|
21615
|
+
kind: "ref-write",
|
|
21616
|
+
forge: tool,
|
|
21617
|
+
tag: false,
|
|
21618
|
+
branch: true,
|
|
21619
|
+
setting: true
|
|
21620
|
+
};
|
|
21621
|
+
if (/(?:^|\/)graphql\/?$/i.test(route)) {
|
|
21622
|
+
if (request.unread || queries.some((query) => !query.read))
|
|
21623
|
+
return { kind: "ref-write", forge: tool, tag: true, branch: true, unread: true };
|
|
21624
|
+
if (values.some((value) => GRAPHQL_MERGE.test(value)))
|
|
21625
|
+
return merge;
|
|
21626
|
+
if (values.some((value) => GRAPHQL_SETTING.test(value)))
|
|
21627
|
+
return setting;
|
|
21628
|
+
const shapes = new Set(GRAPHQL_REF.filter(([pattern]) => values.some((value) => pattern.test(value))).map(([, shape]) => shape));
|
|
21629
|
+
if (!shapes.size)
|
|
21630
|
+
return null;
|
|
21631
|
+
const created = queries.map((query) => createdRefs(query.text));
|
|
21632
|
+
const certain = !values.some((value) => BY_ID.test(value)) && created.every((named) => named !== null);
|
|
21633
|
+
return refWrite(tool, shapes, created.flatMap((named) => named ?? []), certain);
|
|
21634
|
+
}
|
|
21453
21635
|
const verb = request.method ?? (request.body ? "POST" : "GET");
|
|
21454
21636
|
if (verb === "GET" || verb === "HEAD")
|
|
21455
21637
|
return null;
|
|
21456
|
-
const named = tool === "gh" ? /(?:^|\/)repos\/([^/{]+\/[^/{]+)
|
|
21638
|
+
const named = tool === "gh" ? /(?:^|\/)repos\/([^/{]+\/[^/{]+)(?:\/|$)/i.exec(route)?.[1] ?? (/(?:^|\/)repositories\/[^/]+(?:\/|$)/i.test(route) ? "?" : undefined) : /(?:^|\/)projects\/([^/]+)(?:\/|$)/i.exec(route)?.[1];
|
|
21457
21639
|
let repo;
|
|
21458
21640
|
try {
|
|
21459
21641
|
repo = named === undefined ? undefined : decodeURIComponent(named) || "?";
|
|
@@ -21461,9 +21643,17 @@ var apiAction = (tool, args, stdin) => {
|
|
|
21461
21643
|
repo = "?";
|
|
21462
21644
|
}
|
|
21463
21645
|
const at = repo === undefined ? {} : { repo };
|
|
21464
|
-
if (API_MERGE[tool].test(
|
|
21646
|
+
if (API_MERGE[tool].test(route))
|
|
21465
21647
|
return { ...merge, ...at };
|
|
21466
|
-
const
|
|
21648
|
+
const defaultBranch = API_REPOSITORY[tool].test(route) && (request.unread || values.some((value) => /default_branch/.test(value)));
|
|
21649
|
+
if (defaultBranch || API_SETTING[tool].some((pattern) => pattern.test(route)))
|
|
21650
|
+
return { ...setting, ...at };
|
|
21651
|
+
const shape = API_REF[tool].find(([pattern]) => pattern.test(route))?.[1];
|
|
21652
|
+
if (shape) {
|
|
21653
|
+
const { named: refs, certain } = restRef(route, fields, !request.unread && !request.input);
|
|
21654
|
+
return { ...refWrite(tool, new Set([shape]), refs, certain), ...at };
|
|
21655
|
+
}
|
|
21656
|
+
const grant = /\/releases(?:\/|$)/i.test(route) ? "release" : (tool === "gh" ? /\/pulls(?:\/\d+)?\/?$/i : /\/merge_requests(?:\/\d+)?\/?$/i).test(route) ? "pr" : null;
|
|
21467
21657
|
return grant ? { kind: "forge", forge: tool, grant, ...at } : null;
|
|
21468
21658
|
};
|
|
21469
21659
|
var subtreePush = (args) => {
|
|
@@ -21481,7 +21671,7 @@ var subtreePush = (args) => {
|
|
|
21481
21671
|
function rawAction(invocation) {
|
|
21482
21672
|
const args = invocation.args;
|
|
21483
21673
|
if (invocation.tool !== "git" && args[0] === "api")
|
|
21484
|
-
return apiAction(invocation.tool, args, invocation.stdin);
|
|
21674
|
+
return apiAction(invocation.tool, args, invocation.stdin, invocation.expanded);
|
|
21485
21675
|
if (asksHelp(invocation))
|
|
21486
21676
|
return null;
|
|
21487
21677
|
const [first] = args;
|
|
@@ -21757,6 +21947,223 @@ var refusal = (action, branch, dir) => {
|
|
|
21757
21947
|
return `workit: raw ${quote("git push")} onto ${branch}, a protected release branch, bypasses workit's protected-branch check. To finish a release or hotfix, push it with ${quote(`workit git push --release ${branch} [--release ${releaseTagPrefixOf(dir)}<version>]`)}: it pushes ${branch} (fast-forward only) and the release tag, verifies the remote and records it, under the ${quote("release")} grant (if refused, ask the user to run ${quote("workit grant set <workspace> release=true")}). Feature work goes through ${quote("workit git push")} and ${quote("workit pr merge")}.`;
|
|
21758
21948
|
return `workit: raw ${quote("git push")}${action.kind === "push" && action.blindForce ? " --force" : ""} onto ${branch}, a protected branch or the default target, bypasses workit's protected-branch check. Push your feature branch with ${quote("workit git push")} (${quote("workit git push --force-with-lease")} to rewrite it) and land it with ${quote("workit pr merge")}.`;
|
|
21759
21949
|
};
|
|
21950
|
+
var PLAIN_EXPANSION = /^(?:[^$`]|\$[A-Za-z_]\w*|\$\{[A-Za-z_]\w*\})*$/u;
|
|
21951
|
+
var shellWord = (text, expands = false) => {
|
|
21952
|
+
if (/^[\w@%+=:,./-]+$/u.test(text))
|
|
21953
|
+
return text;
|
|
21954
|
+
if (expands && text.includes("$") && PLAIN_EXPANSION.test(text))
|
|
21955
|
+
return `"${text.replaceAll(/["\\]/gu, "\\$&")}"`;
|
|
21956
|
+
return `'${text.replaceAll("'", "'\\''")}'`;
|
|
21957
|
+
};
|
|
21958
|
+
var expandingWords = (command, dialect, found = new Set, depth = 0) => {
|
|
21959
|
+
for (const segment of segmentsOf(command, dialect))
|
|
21960
|
+
segment.words.forEach((text, index) => {
|
|
21961
|
+
if (segment.expands?.includes(index))
|
|
21962
|
+
found.add(text);
|
|
21963
|
+
else if (depth < MAX_DEPTH && /\s/u.test(text))
|
|
21964
|
+
expandingWords(text, "posix", found, depth + 1);
|
|
21965
|
+
});
|
|
21966
|
+
return found;
|
|
21967
|
+
};
|
|
21968
|
+
var wordsOf = (command, dialect = "posix") => {
|
|
21969
|
+
const expands = expandsIn(command, dialect);
|
|
21970
|
+
return (text) => shellWord(text, expands(text));
|
|
21971
|
+
};
|
|
21972
|
+
var expandsIn = (command, dialect = "posix") => {
|
|
21973
|
+
let expanding;
|
|
21974
|
+
return (text) => (expanding ??= expandingWords(command, dialect)).has(text);
|
|
21975
|
+
};
|
|
21976
|
+
var oneCall = (command, dialect) => {
|
|
21977
|
+
const steps = /^(?:\s*cd\s+[^\s;&|<>()$`'"\\]+\s*&&)*([\s\S]*)$/u.exec(command);
|
|
21978
|
+
return !!steps && !!simpleCommand(steps[1], dialect);
|
|
21979
|
+
};
|
|
21980
|
+
var flagWord = (flag, value, asWritten) => value.startsWith("-") ? [`${flag}=${asWritten(value)}`] : [flag, asWritten(value)];
|
|
21981
|
+
var PR_FLAGS = {
|
|
21982
|
+
"gh ready": { verb: "ready", booleans: { "--undo": ["--undo"] }, values: {} },
|
|
21983
|
+
"gh merge": {
|
|
21984
|
+
verb: "merge",
|
|
21985
|
+
booleans: {
|
|
21986
|
+
"--squash": ["--squash"],
|
|
21987
|
+
"-s": ["--squash"],
|
|
21988
|
+
"--merge": ["--merge"],
|
|
21989
|
+
"-m": ["--merge"],
|
|
21990
|
+
"--rebase": ["--rebase"],
|
|
21991
|
+
"-r": ["--rebase"],
|
|
21992
|
+
"--delete-branch": ["--delete-branch"],
|
|
21993
|
+
"-d": ["--delete-branch"]
|
|
21994
|
+
},
|
|
21995
|
+
values: {
|
|
21996
|
+
"--subject": { flag: "--subject" },
|
|
21997
|
+
"-t": { flag: "--subject" },
|
|
21998
|
+
"--body": { flag: "--body" },
|
|
21999
|
+
"-b": { flag: "--body" },
|
|
22000
|
+
"--body-file": { flag: "--body-file" },
|
|
22001
|
+
"-F": { flag: "--body-file" }
|
|
22002
|
+
}
|
|
22003
|
+
},
|
|
22004
|
+
"gh edit": {
|
|
22005
|
+
verb: "edit",
|
|
22006
|
+
booleans: {},
|
|
22007
|
+
values: {
|
|
22008
|
+
"--title": { flag: "--title" },
|
|
22009
|
+
"-t": { flag: "--title" },
|
|
22010
|
+
"--body-file": { flag: "--body-file" },
|
|
22011
|
+
"-F": { flag: "--body-file" },
|
|
22012
|
+
"--add-label": { flag: "--add-label", split: true },
|
|
22013
|
+
"--remove-label": { flag: "--remove-label", split: true },
|
|
22014
|
+
"--add-reviewer": { flag: "--add-reviewer", split: true },
|
|
22015
|
+
"--base": { flag: "--base" },
|
|
22016
|
+
"-B": { flag: "--base" }
|
|
22017
|
+
}
|
|
22018
|
+
},
|
|
22019
|
+
"glab merge": {
|
|
22020
|
+
verb: "merge",
|
|
22021
|
+
booleans: {
|
|
22022
|
+
"--squash": ["--squash"],
|
|
22023
|
+
"-s": ["--squash"],
|
|
22024
|
+
"--rebase": ["--rebase"],
|
|
22025
|
+
"-r": ["--rebase"],
|
|
22026
|
+
"--remove-source-branch": ["--delete-branch"],
|
|
22027
|
+
"-d": ["--delete-branch"],
|
|
22028
|
+
"--yes": [],
|
|
22029
|
+
"-y": []
|
|
22030
|
+
},
|
|
22031
|
+
values: {}
|
|
22032
|
+
},
|
|
22033
|
+
"glab update": {
|
|
22034
|
+
verb: "edit",
|
|
22035
|
+
booleans: { "--ready": [], "-r": [], "--draft": ["--undo"], "--yes": [], "-y": [] },
|
|
22036
|
+
values: {
|
|
22037
|
+
"--title": { flag: "--title" },
|
|
22038
|
+
"-t": { flag: "--title" },
|
|
22039
|
+
"--label": { flag: "--add-label", split: true },
|
|
22040
|
+
"-l": { flag: "--add-label", split: true },
|
|
22041
|
+
"--unlabel": { flag: "--remove-label", split: true },
|
|
22042
|
+
"-u": { flag: "--remove-label", split: true },
|
|
22043
|
+
"--target-branch": { flag: "--base" }
|
|
22044
|
+
}
|
|
22045
|
+
}
|
|
22046
|
+
};
|
|
22047
|
+
var prRetry = (cwd, repo, invocation, cache, asWritten) => {
|
|
22048
|
+
const forge = invocation.tool;
|
|
22049
|
+
if (forge === "git")
|
|
22050
|
+
return null;
|
|
22051
|
+
const values = VALUE_OPTIONS[forge];
|
|
22052
|
+
const args = invocation.args;
|
|
22053
|
+
let verb;
|
|
22054
|
+
let at = 1;
|
|
22055
|
+
for (;at < args.length; at++) {
|
|
22056
|
+
if (!args[at].startsWith("-")) {
|
|
22057
|
+
verb = args[at];
|
|
22058
|
+
break;
|
|
22059
|
+
}
|
|
22060
|
+
if (values.has(args[at]))
|
|
22061
|
+
at++;
|
|
22062
|
+
}
|
|
22063
|
+
const table = PR_FLAGS[`${forge} ${verb}`];
|
|
22064
|
+
if (!table)
|
|
22065
|
+
return null;
|
|
22066
|
+
const words = [];
|
|
22067
|
+
const repos = [];
|
|
22068
|
+
let selector;
|
|
22069
|
+
let ready = false;
|
|
22070
|
+
const rest = [...args.slice(1, at), ...args.slice(at + 1)];
|
|
22071
|
+
for (let index = 0;index < rest.length; index++) {
|
|
22072
|
+
const arg = rest[index];
|
|
22073
|
+
const eq = arg.startsWith("--") ? arg.indexOf("=") : -1;
|
|
22074
|
+
const name = eq > 0 ? arg.slice(0, eq) : arg;
|
|
22075
|
+
const value = () => eq > 0 ? arg.slice(eq + 1) : rest[++index];
|
|
22076
|
+
if (name === "-R" || name === "--repo") {
|
|
22077
|
+
const named = value();
|
|
22078
|
+
if (named === undefined)
|
|
22079
|
+
return null;
|
|
22080
|
+
repos.push(named);
|
|
22081
|
+
} else if (/^-R./.test(arg))
|
|
22082
|
+
repos.push(arg.slice(2).replace(/^=/, ""));
|
|
22083
|
+
else if (eq < 0 && Object.hasOwn(table.booleans, arg)) {
|
|
22084
|
+
if (forge === "glab" && (arg === "--ready" || arg === "-r" || arg === "--draft")) {
|
|
22085
|
+
if (ready && words.includes("--undo") !== (arg === "--draft"))
|
|
22086
|
+
return null;
|
|
22087
|
+
ready = true;
|
|
22088
|
+
}
|
|
22089
|
+
words.push(...table.booleans[arg]);
|
|
22090
|
+
} else if (Object.hasOwn(table.values, name)) {
|
|
22091
|
+
const given = value();
|
|
22092
|
+
if (given === undefined)
|
|
22093
|
+
return null;
|
|
22094
|
+
const { flag, split } = table.values[name];
|
|
22095
|
+
if (split && given.includes(",") && /[$`]/.test(given))
|
|
22096
|
+
return null;
|
|
22097
|
+
for (const item of split ? given.split(",").filter(Boolean) : [given])
|
|
22098
|
+
words.push(...flagWord(flag, item, asWritten));
|
|
22099
|
+
} else if (arg.startsWith("-") || selector !== undefined)
|
|
22100
|
+
return null;
|
|
22101
|
+
else
|
|
22102
|
+
selector = arg;
|
|
22103
|
+
}
|
|
22104
|
+
const workitVerb = ready ? "ready" : table.verb;
|
|
22105
|
+
if (ready && words.some((word) => word !== "--undo"))
|
|
22106
|
+
return null;
|
|
22107
|
+
const pr = [];
|
|
22108
|
+
if (selector !== undefined) {
|
|
22109
|
+
const url = /^(https?:\/\/[^/]+\/.+?)\/(?:-\/)?(?:pull|merge_requests)\/(\d+)(?:[/?#].*)?$/.exec(selector);
|
|
22110
|
+
const number = url?.[2] ?? /^[#!]?(\d+)$/.exec(selector)?.[1];
|
|
22111
|
+
if (url)
|
|
22112
|
+
repos.push(url[1]);
|
|
22113
|
+
if (number)
|
|
22114
|
+
pr.push("--pr", number);
|
|
22115
|
+
else if (/\$[A-Za-z_{]/.test(selector))
|
|
22116
|
+
pr.push("--pr", asWritten(selector));
|
|
22117
|
+
else if (selector !== repo.branch)
|
|
22118
|
+
return null;
|
|
22119
|
+
}
|
|
22120
|
+
const env = invocation.env ?? {};
|
|
22121
|
+
if (forge === "gh" && (env.GH_REPO ?? process.env.GH_REPO))
|
|
22122
|
+
repos.push(env.GH_REPO ?? process.env.GH_REPO ?? "");
|
|
22123
|
+
if (repos.length) {
|
|
22124
|
+
const config = gitConfig(repo.dir, invocation, cache);
|
|
22125
|
+
const { GH_REPO: _named, ...own } = env;
|
|
22126
|
+
const key = (named, from) => {
|
|
22127
|
+
const found = forgeRepo(forge === "gh", named, from, config, repo.branch, repo.dir);
|
|
22128
|
+
return found instanceof Error ? null : found.remotes[0]?.key.toLowerCase() ?? null;
|
|
22129
|
+
};
|
|
22130
|
+
const checkout = key("", own);
|
|
22131
|
+
if (!checkout || repos.some((named) => /[$`]/.test(named) || key(named, own) !== checkout))
|
|
22132
|
+
return null;
|
|
22133
|
+
}
|
|
22134
|
+
const dir = path31.resolve(cwd, invocation.dir ?? ".");
|
|
22135
|
+
const call = [
|
|
22136
|
+
`workit pr ${workitVerb}`,
|
|
22137
|
+
...dir === path31.resolve(cwd) ? [] : ["--cwd", shellWord(dir)],
|
|
22138
|
+
...pr,
|
|
22139
|
+
...words
|
|
22140
|
+
].join(" ");
|
|
22141
|
+
return { raw: `${forge} ${forge === "gh" ? "pr" : "mr"} ${verb}`, call };
|
|
22142
|
+
};
|
|
22143
|
+
var prWriteRefusal = (writes, retry) => {
|
|
22144
|
+
const raws = [...new Set(writes.map((write) => quote(write.raw)))].join(", ");
|
|
22145
|
+
const calls = writes.map((write) => quote(write.call)).join(", ");
|
|
22146
|
+
const why = `workit: raw ${raws} changes the PR past workit's checks (the pr grant, and that the PR is this session's own).`;
|
|
22147
|
+
if (retry && writes.length === 1)
|
|
22148
|
+
return `${why} Run ${calls} instead.
|
|
22149
|
+
Retry as: ${writes[0].call}`;
|
|
22150
|
+
return `${why} Run ${writes.length > 1 ? `each as its own call: ${calls}` : `${calls} as its own call`}, in place of the raw ${writes.length > 1 ? "ones" : "one"}; the rest of this command is yours to run apart.`;
|
|
22151
|
+
};
|
|
22152
|
+
var refWriteRefusal = (action) => {
|
|
22153
|
+
if (action.unread)
|
|
22154
|
+
return `workit: raw ${quote(`${action.forge} api graphql`)} sends a document the hook cannot read (a file, stdin it does not see, or a shell expansion), so it may merge, write a ref or change branch protection past workit's checks. Write the document inline in single quotes, run the change through ${quote("workit git push")}, ${quote("workit release tag <vX.Y.Z>")} or ${quote("workit pr merge")}, or ask the user to run it.`;
|
|
22155
|
+
if (action.setting)
|
|
22156
|
+
return `workit: raw ${quote(`${action.forge} api`)} changes branch protection, a ruleset or the default branch on the forge directly: that guards what ${quote("workit git push")} and ${quote("workit pr merge")} may do, and no agent call changes it. Ask the user to change it in the forge's settings.`;
|
|
22157
|
+
const steers = [
|
|
22158
|
+
...action.branch ? [
|
|
22159
|
+
`push a branch with ${quote("workit git push")} (it refuses protected branches and verifies the remote tip)`
|
|
22160
|
+
] : [],
|
|
22161
|
+
...action.tag ? [
|
|
22162
|
+
`tag a release with ${quote("workit release tag <vX.Y.Z>")} or ${quote("workit git push --release <tag>")}, under the ${quote("release")} grant`
|
|
22163
|
+
] : []
|
|
22164
|
+
];
|
|
22165
|
+
return `workit: raw ${quote(`${action.forge} api`)} writes ${action.ref ?? (action.tag && !action.branch ? "a tag" : action.branch && !action.tag ? "a branch" : "a ref")} on the forge directly, past workit's protected-branch check${action.tag ? " and the release grant" : ""}. Instead, ${steers.join("; ")}.`;
|
|
22166
|
+
};
|
|
21760
22167
|
var refFacts = (repo, remote) => {
|
|
21761
22168
|
const facts = {
|
|
21762
22169
|
heads: new Set,
|
|
@@ -21905,6 +22312,7 @@ var nudgeFor = (action, host, session) => {
|
|
|
21905
22312
|
case "pr-read":
|
|
21906
22313
|
case "forge":
|
|
21907
22314
|
case "merge":
|
|
22315
|
+
case "ref-write":
|
|
21908
22316
|
return null;
|
|
21909
22317
|
}
|
|
21910
22318
|
};
|
|
@@ -21922,8 +22330,10 @@ var pushRefusal = (action, repo, config) => {
|
|
|
21922
22330
|
return offPolicy;
|
|
21923
22331
|
for (const target of targets) {
|
|
21924
22332
|
const guarded = guardedTarget(repo.dir, target ?? repo.branch ?? "");
|
|
21925
|
-
if (guarded)
|
|
21926
|
-
|
|
22333
|
+
if (!guarded)
|
|
22334
|
+
continue;
|
|
22335
|
+
const first = !action.blindForce && !action.deletes && !facts.remoteHeads.has(guarded) ? ` ${remote} has no ${guarded} as last fetched: if it is a new, empty remote, ${quote("workit git push")} from ${guarded} makes that first push (it checks the remote first).` : "";
|
|
22336
|
+
return refusal(action, guarded, repo.dir) + first;
|
|
21927
22337
|
}
|
|
21928
22338
|
return tagRefusal(pushed, facts, repo.dir) ?? (action.deletes ? null : offPolicyPush(pushed, repo, facts, remote));
|
|
21929
22339
|
};
|
|
@@ -22105,6 +22515,8 @@ var commitRefusal = (input, command, dialect, { action, repo, invocation, workit
|
|
|
22105
22515
|
try {
|
|
22106
22516
|
guarded = !!repo.branch && resolveBranchPolicyFor(repo.dir).protected.has(repo.branch.toLowerCase());
|
|
22107
22517
|
} catch {}
|
|
22518
|
+
if (guarded && !switches && noRefs(repo))
|
|
22519
|
+
return `workit: raw ${quote("git commit")} on ${repo.branch}, a protected branch. This repository has no commit yet, so its root commit may go there: run ${quote("workit git commit -m '<msg>' [--all | -- <paths>]")} (it adds the Workit-Session trailer; later work goes on a branch).`;
|
|
22108
22520
|
if (guarded && !switches)
|
|
22109
22521
|
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>")}.`;
|
|
22110
22522
|
const call = action.amend || dialect !== "posix" || typeof invocation.dir !== "string" ? null : cdCommitCall(input, command, path31.resolve(input.cwd, invocation.dir), repo);
|
|
@@ -22114,6 +22526,8 @@ function rawGitPre(input, command, options = {}) {
|
|
|
22114
22526
|
try {
|
|
22115
22527
|
const dialect = dialectOf(input);
|
|
22116
22528
|
const nudges = new Map;
|
|
22529
|
+
const prWrites = [];
|
|
22530
|
+
const asWritten = wordsOf(command, dialect);
|
|
22117
22531
|
let store = null;
|
|
22118
22532
|
const cache = new Map;
|
|
22119
22533
|
const blind = rawInvocations(command, dialect).find((raw) => raw.redirect && rawAction(raw)?.kind === "push");
|
|
@@ -22134,8 +22548,19 @@ function rawGitPre(input, command, options = {}) {
|
|
|
22134
22548
|
if (!workit)
|
|
22135
22549
|
continue;
|
|
22136
22550
|
store ??= repo.location.dir;
|
|
22137
|
-
if (action.kind === "merge")
|
|
22138
|
-
|
|
22551
|
+
if (action.kind === "merge") {
|
|
22552
|
+
const retry = prRetry(input.cwd, repo, invocation, cache, asWritten);
|
|
22553
|
+
const named = !retry ? "" : oneCall(command, dialect) ? `
|
|
22554
|
+
Retry as: ${retry.call}` : ` Run ${quote(retry.call)} as its own call, in place of the raw one; the rest of this command is yours to run apart.`;
|
|
22555
|
+
return deny(`${refusal(action, null)}${named}`);
|
|
22556
|
+
}
|
|
22557
|
+
if (action.kind === "ref-write")
|
|
22558
|
+
return deny(refWriteRefusal(action));
|
|
22559
|
+
if (action.kind === "forge" && action.grant === "pr") {
|
|
22560
|
+
const retry = prRetry(input.cwd, repo, invocation, cache, asWritten);
|
|
22561
|
+
if (retry)
|
|
22562
|
+
prWrites.push(retry);
|
|
22563
|
+
}
|
|
22139
22564
|
if (action.kind === "push") {
|
|
22140
22565
|
const refused = pushRefusal(action, repo, gitConfig(repo.dir, invocation, cache));
|
|
22141
22566
|
if (refused)
|
|
@@ -22145,6 +22570,8 @@ function rawGitPre(input, command, options = {}) {
|
|
|
22145
22570
|
if (nudge && !nudges.has(nudgeKind(action)))
|
|
22146
22571
|
nudges.set(nudgeKind(action), nudge);
|
|
22147
22572
|
}
|
|
22573
|
+
if (prWrites.length)
|
|
22574
|
+
return deny(prWriteRefusal(prWrites, oneCall(command, dialect)));
|
|
22148
22575
|
const pkill = options.nudge === false ? null : pkillSelfMatch(command, dialect);
|
|
22149
22576
|
const pkillNote = pkill ? { kind: "context", text: pkill } : NONE2;
|
|
22150
22577
|
if (options.nudge === false || !store || nudges.size === 0)
|
|
@@ -22228,6 +22655,8 @@ var grantRefusal = (action, repo, invocation, cache) => {
|
|
|
22228
22655
|
kinds.push("pr");
|
|
22229
22656
|
else if (action.kind === "forge")
|
|
22230
22657
|
kinds.push(action.grant);
|
|
22658
|
+
else if (action.kind === "ref-write")
|
|
22659
|
+
kinds.push(...action.branch ? ["push"] : [], ...action.tag ? ["release"] : [], ...action.unread ? ["merge"] : []);
|
|
22231
22660
|
for (const kind of kinds) {
|
|
22232
22661
|
const denied = rawGrantDenial(repo.dir, kind, target);
|
|
22233
22662
|
if (denied)
|
|
@@ -22235,6 +22664,21 @@ var grantRefusal = (action, repo, invocation, cache) => {
|
|
|
22235
22664
|
}
|
|
22236
22665
|
return null;
|
|
22237
22666
|
};
|
|
22667
|
+
var noRefs = (repo) => {
|
|
22668
|
+
const common = path31.dirname(repo.location.dir);
|
|
22669
|
+
const holds = (dir) => {
|
|
22670
|
+
try {
|
|
22671
|
+
return fs22.readdirSync(dir, { withFileTypes: true }).some((entry) => entry.isFile() || entry.isDirectory() && holds(path31.join(dir, entry.name)));
|
|
22672
|
+
} catch {
|
|
22673
|
+
return false;
|
|
22674
|
+
}
|
|
22675
|
+
};
|
|
22676
|
+
try {
|
|
22677
|
+
if (/ refs\//.test(fs22.readFileSync(path31.join(common, "packed-refs"), "utf8")))
|
|
22678
|
+
return false;
|
|
22679
|
+
} catch {}
|
|
22680
|
+
return fs22.existsSync(path31.join(common, "refs")) && !holds(path31.join(common, "refs"));
|
|
22681
|
+
};
|
|
22238
22682
|
var localTag = (repo, name) => {
|
|
22239
22683
|
const common = path31.dirname(repo.location.dir);
|
|
22240
22684
|
try {
|
|
@@ -27445,8 +27889,7 @@ var linesOf = (command, dialect) => {
|
|
|
27445
27889
|
return null;
|
|
27446
27890
|
}
|
|
27447
27891
|
};
|
|
27448
|
-
var
|
|
27449
|
-
var leaseCommand = (words) => `workit check --heavy -- ${words.map(quoteWord).join(" ")}`;
|
|
27892
|
+
var leaseCommand = (words, word) => `workit check --heavy -- ${words.map(word).join(" ")}`;
|
|
27450
27893
|
function heavyPlan(command, options) {
|
|
27451
27894
|
const dialect = options.dialect ?? "posix";
|
|
27452
27895
|
if (dialect !== "posix" || !gitTop(options.cwd))
|
|
@@ -27479,7 +27922,8 @@ function heavyPlan(command, options) {
|
|
|
27479
27922
|
}));
|
|
27480
27923
|
return rewrite ? { kind: "rewrite", command: rewrite, reason: single.reason } : { kind: "none" };
|
|
27481
27924
|
}
|
|
27482
|
-
const
|
|
27925
|
+
const word = wordsOf(command, dialect);
|
|
27926
|
+
const parts = heavy.map((match) => leaseCommand(match.line, word));
|
|
27483
27927
|
return {
|
|
27484
27928
|
kind: "split",
|
|
27485
27929
|
reason: `heavy_command: \`${command.trim()}\` chains heavy work (${heavy.map((match) => match.reason).join("; ")}) with other commands, and a chain cannot run under the machine-wide heavy-check lease. Run the heavy part alone, now: \`${parts[0]}\`; then run the other parts as their own commands${parts.length > 1 ? ", each heavy one the same way" : ""}.`,
|
|
@@ -27501,7 +27945,7 @@ function serverPlan(command, options) {
|
|
|
27501
27945
|
const rewrite = leaseRewrite(command)?.replace("workit check --heavy --", "workit run --bg --");
|
|
27502
27946
|
return rewrite ? { kind: "rewrite", command: rewrite, reason: single, server: true } : { kind: "none" };
|
|
27503
27947
|
}
|
|
27504
|
-
const start = `workit run --bg -- ${found.line.map(
|
|
27948
|
+
const start = `workit run --bg -- ${found.line.map(wordsOf(command, dialect)).join(" ")}`;
|
|
27505
27949
|
return {
|
|
27506
27950
|
kind: "split",
|
|
27507
27951
|
reason: `dev_server: \`${command.trim()}\` chains a dev server (${found.reason}) with other commands. Start it alone, now: \`${start}\`; then run the other parts as their own commands.`,
|
|
@@ -27536,7 +27980,7 @@ function leaseRewrite(command) {
|
|
|
27536
27980
|
import fs27 from "node:fs";
|
|
27537
27981
|
import path40 from "node:path";
|
|
27538
27982
|
var HEAVY_WORDS = new Set(("npm npx pnpm pnpx yarn bun bunx deno corepack make gmake docker podman nerdctl " + "python python3 py uv poetry pdm pipenv hatch rye bundle rake nx " + "jest vitest mocha ava tap karma jasmine nyc c8 tsc vue-tsc svelte-check eslint stylelint " + "tslint webpack webpack-cli rollup parcel tsup vite next nuxt nuxi astro ng react-scripts " + "playwright cypress wdio testcafe turbo lerna sonar-scanner sonarless sonarless-mcp go " + "golangci-lint gotestsum staticcheck cargo mvn mvnw gradle gradlew ant sbt bazel bazelisk " + "buck2 dotnet msbuild pytest py.test tox nox mypy pyright pylint coverage maturin pip pip3 " + "rspec rails phpunit pest phpstan psalm composer mix swift xcodebuild flutter dart pod cmake " + "ninja meson ctest scons docker-compose buildah earthly").split(" "));
|
|
27539
|
-
var
|
|
27983
|
+
var wordsOf2 = (command) => command.split(/[\s;&|()<>`'"]+/u).map((word) => (word.split(/[\\/]/u).at(-1) ?? "").toLowerCase().replace(/\.(?:exe|cmd|bat)$/u, "")).filter(Boolean);
|
|
27540
27984
|
var stateDir3 = (env) => stateDir(env);
|
|
27541
27985
|
var readJson2 = (file) => {
|
|
27542
27986
|
try {
|
|
@@ -27562,7 +28006,7 @@ var patternWords = (cwd, env) => {
|
|
|
27562
28006
|
for (const pattern of patterns) {
|
|
27563
28007
|
if (typeof pattern !== "string")
|
|
27564
28008
|
continue;
|
|
27565
|
-
const first =
|
|
28009
|
+
const first = wordsOf2(pattern)[0];
|
|
27566
28010
|
if (!first || first.includes("*"))
|
|
27567
28011
|
return null;
|
|
27568
28012
|
words.add(first);
|
|
@@ -27571,7 +28015,7 @@ var patternWords = (cwd, env) => {
|
|
|
27571
28015
|
};
|
|
27572
28016
|
function maybeHeavy(command, cwd, env = process.env) {
|
|
27573
28017
|
try {
|
|
27574
|
-
const words =
|
|
28018
|
+
const words = wordsOf2(command);
|
|
27575
28019
|
if (words.some((word) => HEAVY_WORDS.has(word) || /^python[\d.]*$/u.test(word)))
|
|
27576
28020
|
return true;
|
|
27577
28021
|
const extra = patternWords(cwd, env);
|
|
@@ -28279,7 +28723,7 @@ var wrappedScript = (input) => {
|
|
|
28279
28723
|
const script = shellScript3(tail.argv);
|
|
28280
28724
|
if (SCRIPT_SHELLS.has((tail.argv[0]?.split(/[\\/]/).at(-1) ?? "").toLowerCase()) && script)
|
|
28281
28725
|
return script;
|
|
28282
|
-
return tail.argv.map(
|
|
28726
|
+
return tail.argv.map(quoteWord).join(" ");
|
|
28283
28727
|
};
|
|
28284
28728
|
var editsOf = (input) => {
|
|
28285
28729
|
const words = pastLead(input);
|
|
@@ -29155,7 +29599,7 @@ var cdInto = (dir, words, strict = false, vars = new Map, globs = false) => {
|
|
|
29155
29599
|
return lost;
|
|
29156
29600
|
return target === undefined ? os10.homedir() : path43.resolve(dir, target);
|
|
29157
29601
|
};
|
|
29158
|
-
var
|
|
29602
|
+
var quoteWord = (word) => /^[\w@%+=:,./-]+$/.test(word) ? word : `'${word.replaceAll("'", "'\\''")}'`;
|
|
29159
29603
|
var expandVars = (text, vars) => vars.size === 0 || !text.includes("$") ? text : text.replace(/\$(?:(\w+)|\{(\w+)\})/g, (whole, bare, braced) => {
|
|
29160
29604
|
const value = vars.get(bare ?? braced ?? "");
|
|
29161
29605
|
return value === undefined ? whole : value;
|
|
@@ -29553,7 +29997,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
29553
29997
|
targets.push(cmd && CMD_VAR.test(file) ? placeholderIn(dir, `${OPAQUE_TARGET}cmd`) : file);
|
|
29554
29998
|
const bare = strict && depth < 4 ? unwrapped2(words) : null;
|
|
29555
29999
|
if (bare?.length && dir !== undefined)
|
|
29556
|
-
targets.push(...segmentTargets(dir, bare.flatMap((word) => expansions(word, vars, loops)).map(
|
|
30000
|
+
targets.push(...segmentTargets(dir, bare.flatMap((word) => expansions(word, vars, loops)).map(quoteWord).join(" "), "posix", depth + 1, strict, vars));
|
|
29557
30001
|
if (strict === "registry" && dir !== undefined && depth < 4) {
|
|
29558
30002
|
const run = words.slice(Math.max(0, words.findIndex((word) => !PREFIXES2.has(word))));
|
|
29559
30003
|
const [verb = "", ...args] = run.map((word, index) => index ? word : (word.split(/[\\/]/).at(-1) ?? "").toLowerCase());
|
|
@@ -29688,7 +30132,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
29688
30132
|
if (!/^\/dev\/(?:null|stdout|stderr|tty)$/.test(file) && !(dialect === "powershell" && /^(?:\$null|nul)$/i.test(file)))
|
|
29689
30133
|
targets.push(...atAll(file));
|
|
29690
30134
|
if (dir !== undefined)
|
|
29691
|
-
for (const invocation of workitInvocations(body.map(
|
|
30135
|
+
for (const invocation of workitInvocations(body.map(quoteWord).join(" "), "posix")) {
|
|
29692
30136
|
const { at: runsIn, args } = workitCwd(dir, invocation, atAll);
|
|
29693
30137
|
if (args[0] === "git" && MUTATING_WORKIT_GIT.has(args[1] ?? "") && !inert(args.slice(2), ""))
|
|
29694
30138
|
targets.push(...runsIn.map((runs) => placeholderIn(runs, DIR_TARGET)));
|
|
@@ -29697,7 +30141,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
29697
30141
|
return targets;
|
|
29698
30142
|
};
|
|
29699
30143
|
var workitRunDir = (dir, words, resolve) => {
|
|
29700
|
-
for (const invocation of workitInvocations(words.map(
|
|
30144
|
+
for (const invocation of workitInvocations(words.map(quoteWord).join(" "), "posix")) {
|
|
29701
30145
|
const { at, args } = workitCwd(dir, invocation, resolve);
|
|
29702
30146
|
if (args[0] === "check" || args[0] === "lock" && args[1] === "run")
|
|
29703
30147
|
return at;
|
|
@@ -30880,6 +31324,7 @@ var FLAGS = {
|
|
|
30880
31324
|
// packages/workit-core/src/approvals/inline.ts
|
|
30881
31325
|
var DIR2 = "<dir>";
|
|
30882
31326
|
var OPAQUE_RELEASE_FIX = `workit release --cwd ${DIR2} notes approve <version>`;
|
|
31327
|
+
var OPAQUE_RELEASE_FIRST = `workit release notes approve --cwd ${DIR2} <version>`;
|
|
30883
31328
|
|
|
30884
31329
|
// packages/workit-core/src/hooks/hosts/claude-code.ts
|
|
30885
31330
|
var CLAUDE_CODE_DESCRIPTOR = {
|
|
@@ -32717,11 +33162,12 @@ var hinted = (write) => write.hint ? {
|
|
|
32717
33162
|
plain: false,
|
|
32718
33163
|
workit: write.hint
|
|
32719
33164
|
} : write;
|
|
32720
|
-
var ytrackArgs = (line, found, depth, names, plain) => {
|
|
33165
|
+
var ytrackArgs = (line, found, depth, names, plain, expands = () => false) => {
|
|
32721
33166
|
const inner = (script) => void found.push(...ytrackWrites(script, "posix", depth + 1, plain));
|
|
32722
33167
|
const tail = workitCheckTail(line);
|
|
32723
33168
|
if (tail) {
|
|
32724
|
-
|
|
33169
|
+
const live = (text) => expands(text) && /[$`]/.test(text) ? `"${text.replaceAll(/["\\]/g, "\\$&")}"` : quote2(text);
|
|
33170
|
+
inner("script" in tail ? tail.script : tail.argv.map(live).join(" "));
|
|
32725
33171
|
return true;
|
|
32726
33172
|
}
|
|
32727
33173
|
const flag = SHELLS3.test(name2(line[0])) ? line.findIndex((word, index) => index > 0 && /^-[a-zA-Z]*c[a-zA-Z]*$/.test(word)) : -1;
|
|
@@ -32751,8 +33197,9 @@ var ytrackArgs = (line, found, depth, names, plain) => {
|
|
|
32751
33197
|
const argv = [...alias ?? [], ...line.slice(at + 1)];
|
|
32752
33198
|
const write = classify2(argv);
|
|
32753
33199
|
if (write) {
|
|
33200
|
+
const word = (text) => plain ? quote2(text) : shellWord(text, expands(text));
|
|
32754
33201
|
const one = {
|
|
32755
|
-
command: ["ytrack", ...argv].map(
|
|
33202
|
+
command: ["ytrack", ...argv].map(word).join(" "),
|
|
32756
33203
|
...write,
|
|
32757
33204
|
...hostsOf(argv),
|
|
32758
33205
|
plain
|
|
@@ -32855,14 +33302,15 @@ var ytrackWrites = (command, dialect = "posix", depth = 0, plain = true) => {
|
|
|
32855
33302
|
let found = [];
|
|
32856
33303
|
const lines = plain ? plainLines(command, dialect) : null;
|
|
32857
33304
|
const none = new Map;
|
|
33305
|
+
const expands = expandsIn(command, dialect);
|
|
32858
33306
|
const plainFirst = lines ? ytrackArgs(lines.first, found, depth, none, true) : false;
|
|
32859
33307
|
const joined = lines && plainFirst ? chained(found, lines.chain, depth) : null;
|
|
32860
33308
|
if (joined)
|
|
32861
33309
|
found = joined;
|
|
32862
|
-
if (!lines || !plainFirst || !(joined ? [] : lines.chain).every((line) => ytrackArgs(line, found, depth, none, false)) || !lines.later.every((line) => ytrackArgs(line, found, depth, none, false))) {
|
|
33310
|
+
if (!lines || !plainFirst || !(joined ? [] : lines.chain).every((line) => ytrackArgs(line, found, depth, none, false, expands)) || !lines.later.every((line) => ytrackArgs(line, found, depth, none, false, expands))) {
|
|
32863
33311
|
found = [];
|
|
32864
33312
|
for (const line of commandLines(command, dialect))
|
|
32865
|
-
ytrackArgs(line, found, depth, aliases(command), false);
|
|
33313
|
+
ytrackArgs(line, found, depth, aliases(command), false, expands);
|
|
32866
33314
|
found = found.map(hinted);
|
|
32867
33315
|
}
|
|
32868
33316
|
READ.set(key, found);
|
|
@@ -32872,7 +33320,7 @@ var ytrackWrites = (command, dialect = "posix", depth = 0, plain = true) => {
|
|
|
32872
33320
|
};
|
|
32873
33321
|
var RELOCATES = /(?<![$\w])YTRACK_CONFIG_DIR\b/;
|
|
32874
33322
|
var reachesOnly = (allowed, write) => write.plain && !!write.hosts?.length && write.hosts.every((host) => youTrackHostAllowed(allowed, host));
|
|
32875
|
-
var scopedGate = (allowed, command, writes) => {
|
|
33323
|
+
var scopedGate = (allowed, command, dialect, writes) => {
|
|
32876
33324
|
const scope = `youtrack.autoHosts (${allowed.join(", ")})`;
|
|
32877
33325
|
if (RELOCATES.test(command))
|
|
32878
33326
|
return {
|
|
@@ -32887,8 +33335,10 @@ var scopedGate = (allowed, command, writes) => {
|
|
|
32887
33335
|
if (!unnamed.length)
|
|
32888
33336
|
return null;
|
|
32889
33337
|
const why = (write) => write.hosts === null ? "its --host is no literal host" : !write.hosts.length ? "it names no --host" : "it is not a plain command of its own";
|
|
32890
|
-
const
|
|
32891
|
-
const
|
|
33338
|
+
const hostless = unnamed.find((each) => each.bare);
|
|
33339
|
+
const expands = expandsIn(command, dialect);
|
|
33340
|
+
const word = (text) => hostless?.plain ? quote2(text) : shellWord(text, expands(text));
|
|
33341
|
+
const retry = hostless?.bare ? ["ytrack", "--host", first, ...hostless.bare].map(word).join(" ") : null;
|
|
32892
33342
|
return {
|
|
32893
33343
|
kind: "deny",
|
|
32894
33344
|
reason: `${scope} posts to YouTrack unasked only from a plain ytrack call that names an allowed host with --host: ${unnamed.map((write) => `\`${write.command}\` (${why(write)})`).join(", ")}. Name the host, as its own plain call.${retry ? `
|
|
@@ -32924,7 +33374,7 @@ var ytrackGate = (cwd, command, dialect, ask) => {
|
|
|
32924
33374
|
const hosts = policy.hosts;
|
|
32925
33375
|
if (hosts === null)
|
|
32926
33376
|
return null;
|
|
32927
|
-
const scoped = scopedGate(hosts, command, writes);
|
|
33377
|
+
const scoped = scopedGate(hosts, command, dialect, writes);
|
|
32928
33378
|
if (scoped)
|
|
32929
33379
|
return scoped;
|
|
32930
33380
|
writes = writes.filter((write) => !reachesOnly(hosts, write));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workit-dev/opencode",
|
|
3
|
-
"version": "2.29.
|
|
3
|
+
"version": "2.29.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Workit OpenCode plugin — native tools, adaptive policy, and sixteen method skills",
|
|
6
6
|
"keywords": [
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@opencode/plugin": "2.3.2",
|
|
44
|
-
"@workit-dev/core": "^2.29.
|
|
44
|
+
"@workit-dev/core": "^2.29.4"
|
|
45
45
|
},
|
|
46
46
|
"engines": {
|
|
47
47
|
"node": ">=24"
|