@workit-dev/codex 2.29.2 → 2.29.3
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/launch-mcp.js
CHANGED
|
@@ -25323,6 +25323,46 @@ var API_VALUES = new Set(["--method", "--header", "--raw-field", "--field", "--j
|
|
|
25323
25323
|
"--output"
|
|
25324
25324
|
]));
|
|
25325
25325
|
var API_FIELDS = new Set(["-f", "-F", "--raw-field", "--field"]);
|
|
25326
|
+
var GH_REPO_PATH = String.raw`(?:^|\/)(?:repos\/[^/]+\/[^/]+|repositories\/[^/]+)`;
|
|
25327
|
+
var ghPath = (rest) => new RegExp(`${GH_REPO_PATH}\\/${rest}(?:\\/|$)`, "i");
|
|
25328
|
+
var called = (names) => new RegExp(String.raw`\b(?:${names})(?:[\s,\uFEFF]|#[^\n\r]*[\n\r])*\(`);
|
|
25329
|
+
var GRAPHQL_REF = [
|
|
25330
|
+
[called("createRef|updateRefs?|deleteRef"), "ref"],
|
|
25331
|
+
[
|
|
25332
|
+
called("createCommitOnBranch|createLinkedBranch|createBranch|branchDelete|commitCreate"),
|
|
25333
|
+
"branch"
|
|
25334
|
+
],
|
|
25335
|
+
[called("tagCreate|tagDelete"), "tag"]
|
|
25336
|
+
];
|
|
25337
|
+
var GRAPHQL_SETTING = called("(?:create|update|delete)(?:BranchProtectionRule|RepositoryRuleset)|branchRule(?:Create|Update|Delete)");
|
|
25338
|
+
var API_REF = {
|
|
25339
|
+
gh: [
|
|
25340
|
+
[ghPath(String.raw`git\/refs?`), "ref"],
|
|
25341
|
+
[ghPath(String.raw`(?:branches\/.+\/rename|merge-upstream|contents)`), "branch"]
|
|
25342
|
+
],
|
|
25343
|
+
glab: [
|
|
25344
|
+
[/(?:^|\/)repository\/tags(?:\/|$)/i, "tag"],
|
|
25345
|
+
[/(?:^|\/)repository\/(?:branches|merged_branches|files|submodules)(?:\/|$)/i, "branch"],
|
|
25346
|
+
[/(?:^|\/)repository\/commits(?:\/[^/]+\/(?:cherry_pick|revert))?\/?$/i, "branch"]
|
|
25347
|
+
]
|
|
25348
|
+
};
|
|
25349
|
+
var API_SETTING = {
|
|
25350
|
+
gh: [
|
|
25351
|
+
ghPath(String.raw`(?:branches\/.+|tags)\/protection`),
|
|
25352
|
+
ghPath("rulesets"),
|
|
25353
|
+
ghPath(String.raw`environments\/[^/]+\/deployment-branch-policies`),
|
|
25354
|
+
/(?:^|\/)orgs\/[^/]+\/rulesets(?:\/|$)/i
|
|
25355
|
+
],
|
|
25356
|
+
glab: [
|
|
25357
|
+
/(?:^|\/)(?:projects|groups)\/[^/]+\/protected_(?:branches|tags)(?:\/|$)/i,
|
|
25358
|
+
/(?:^|\/)projects\/[^/]+\/push_rule(?:\/|$)/i
|
|
25359
|
+
]
|
|
25360
|
+
};
|
|
25361
|
+
var API_REPOSITORY = {
|
|
25362
|
+
gh: new RegExp(`${GH_REPO_PATH}\\/?$`, "i"),
|
|
25363
|
+
glab: /(?:^|\/)projects\/[^/]+\/?$/i
|
|
25364
|
+
};
|
|
25365
|
+
var BY_ID = called("updateRefs?|deleteRef");
|
|
25326
25366
|
var GIT_COMMANDS = new Set(("add am annotate apply archive bisect blame branch bugreport bundle cat-file check-attr " + "check-ignore check-mailmap check-ref-format checkout checkout-index cherry cherry-pick " + "citool clean clone column commit commit-graph commit-tree config count-objects credential " + "daemon describe diagnose diff diff-files diff-index diff-tree difftool fast-export " + "fast-import fetch fetch-pack filter-branch fmt-merge-msg for-each-ref for-each-repo " + "format-patch fsck gc get-tar-commit-id grep gui hash-object help hook index-pack init " + "instaweb interpret-trailers lfs log ls-files ls-remote ls-tree mailinfo mailsplit " + "maintenance merge merge-base merge-file merge-index merge-tree mergetool mktag mktree " + "multi-pack-index mv name-rev notes pack-objects pack-refs patch-id prune pull push " + "range-diff read-tree rebase reflog remote repack replace request-pull rerere reset " + "restore rev-list rev-parse revert rm send-email shortlog show show-branch show-ref " + "sparse-checkout stage stash status stripspace submodule subtree switch symbolic-ref tag " + "update-index update-ref var verify-commit verify-pack verify-tag version whatchanged " + "worktree write-tree").split(" "));
|
|
25327
25367
|
|
|
25328
25368
|
// packages/workit-core/src/core/route-intent.ts
|
|
@@ -15136,7 +15136,7 @@ function walk2(command, dialect, depth, seen, inherited = {}) {
|
|
|
15136
15136
|
for (const invocation of inside)
|
|
15137
15137
|
found.push({ ...invocation, dir: rebase(dir, invocation.dir) });
|
|
15138
15138
|
};
|
|
15139
|
-
const visit = (input, stdin, hops) => {
|
|
15139
|
+
const visit = (input, stdin, hops, expands = "all") => {
|
|
15140
15140
|
const line = /^\$[\w:]+$/.test(input[0] ?? "") && input[1] === "=" ? input.slice(2) : input;
|
|
15141
15141
|
const split = splitString(line);
|
|
15142
15142
|
if (split !== null)
|
|
@@ -15198,15 +15198,18 @@ function walk2(command, dialect, depth, seen, inherited = {}) {
|
|
|
15198
15198
|
nested(cmdScript(words), "powershell");
|
|
15199
15199
|
else if (name === "xargs" || name === "find")
|
|
15200
15200
|
runs(name === "xargs" ? xargsCommands(words, stdin) : findCommands(words));
|
|
15201
|
-
else if (name === "gh" || name === "glab")
|
|
15201
|
+
else if (name === "gh" || name === "glab") {
|
|
15202
|
+
const shift = input.length - words.length + 1;
|
|
15203
|
+
const expanded = expands === "all" ? expands : expands.filter((at) => at >= shift).map((at) => at - shift);
|
|
15202
15204
|
found.push({
|
|
15203
15205
|
tool: name,
|
|
15204
15206
|
dir,
|
|
15205
15207
|
args: words.slice(1),
|
|
15206
15208
|
...Object.keys({ ...exported, ...env }).length ? { env: { ...exported, ...env } } : {},
|
|
15207
|
-
...stdin === undefined ? {} : { stdin }
|
|
15209
|
+
...stdin === undefined ? {} : { stdin },
|
|
15210
|
+
...expanded.length ? { expanded } : {}
|
|
15208
15211
|
});
|
|
15209
|
-
else if (name === "git") {
|
|
15212
|
+
} else if (name === "git") {
|
|
15210
15213
|
const invocation = gitInvocation(words.slice(1), dir, { ...exported, ...env }, stdin, sessionConfig);
|
|
15211
15214
|
found.push(invocation);
|
|
15212
15215
|
sessionConfig.push(...configSetBy(invocation.args));
|
|
@@ -15239,7 +15242,7 @@ function walk2(command, dialect, depth, seen, inherited = {}) {
|
|
|
15239
15242
|
}
|
|
15240
15243
|
const stdin = stdinOf(segment, segments[index - 1]);
|
|
15241
15244
|
for (const line of substitute(segment.words, vars))
|
|
15242
|
-
visit(line, stdin, 0);
|
|
15245
|
+
visit(line, stdin, 0, segment.expands ?? []);
|
|
15243
15246
|
}
|
|
15244
15247
|
return found;
|
|
15245
15248
|
}
|
|
@@ -15534,55 +15537,232 @@ var API_VALUES = new Set(["--method", "--header", "--raw-field", "--field", "--j
|
|
|
15534
15537
|
var API_SHORT_VALUES = "XHfFqtp";
|
|
15535
15538
|
var API_FIELDS = new Set(["-f", "-F", "--raw-field", "--field"]);
|
|
15536
15539
|
var API_MERGE = {
|
|
15537
|
-
gh: /(?:^|\/)(?:pulls\/[^/?#]+\/merge|merges)
|
|
15538
|
-
glab: /(?:^|\/)merge_requests\/[^/?#]+\/merge
|
|
15540
|
+
gh: /(?:^|\/)(?:pulls\/[^/?#]+\/merge|merges)\/?$/i,
|
|
15541
|
+
glab: /(?:^|\/)merge_requests\/[^/?#]+\/merge\/?$/i
|
|
15539
15542
|
};
|
|
15540
15543
|
var GRAPHQL_MERGE = /\b(?:mergePullRequest|enablePullRequestAutoMerge|mergeBranch|mergeRequestAccept)\b/;
|
|
15541
|
-
var
|
|
15542
|
-
|
|
15544
|
+
var GH_REPO_PATH = String.raw`(?:^|\/)(?:repos\/[^/]+\/[^/]+|repositories\/[^/]+)`;
|
|
15545
|
+
var ghPath = (rest) => new RegExp(`${GH_REPO_PATH}\\/${rest}(?:\\/|$)`, "i");
|
|
15546
|
+
var called = (names) => new RegExp(String.raw`\b(?:${names})(?:[\s,\uFEFF]|#[^\n\r]*[\n\r])*\(`);
|
|
15547
|
+
var GRAPHQL_REF = [
|
|
15548
|
+
[called("createRef|updateRefs?|deleteRef"), "ref"],
|
|
15549
|
+
[
|
|
15550
|
+
called("createCommitOnBranch|createLinkedBranch|createBranch|branchDelete|commitCreate"),
|
|
15551
|
+
"branch"
|
|
15552
|
+
],
|
|
15553
|
+
[called("tagCreate|tagDelete"), "tag"]
|
|
15554
|
+
];
|
|
15555
|
+
var GRAPHQL_SETTING = called("(?:create|update|delete)(?:BranchProtectionRule|RepositoryRuleset)|branchRule(?:Create|Update|Delete)");
|
|
15556
|
+
var API_REF = {
|
|
15557
|
+
gh: [
|
|
15558
|
+
[ghPath(String.raw`git\/refs?`), "ref"],
|
|
15559
|
+
[ghPath(String.raw`(?:branches\/.+\/rename|merge-upstream|contents)`), "branch"]
|
|
15560
|
+
],
|
|
15561
|
+
glab: [
|
|
15562
|
+
[/(?:^|\/)repository\/tags(?:\/|$)/i, "tag"],
|
|
15563
|
+
[/(?:^|\/)repository\/(?:branches|merged_branches|files|submodules)(?:\/|$)/i, "branch"],
|
|
15564
|
+
[/(?:^|\/)repository\/commits(?:\/[^/]+\/(?:cherry_pick|revert))?\/?$/i, "branch"]
|
|
15565
|
+
]
|
|
15566
|
+
};
|
|
15567
|
+
var API_SETTING = {
|
|
15568
|
+
gh: [
|
|
15569
|
+
ghPath(String.raw`(?:branches\/.+|tags)\/protection`),
|
|
15570
|
+
ghPath("rulesets"),
|
|
15571
|
+
ghPath(String.raw`environments\/[^/]+\/deployment-branch-policies`),
|
|
15572
|
+
/(?:^|\/)orgs\/[^/]+\/rulesets(?:\/|$)/i
|
|
15573
|
+
],
|
|
15574
|
+
glab: [
|
|
15575
|
+
/(?:^|\/)(?:projects|groups)\/[^/]+\/protected_(?:branches|tags)(?:\/|$)/i,
|
|
15576
|
+
/(?:^|\/)projects\/[^/]+\/push_rule(?:\/|$)/i
|
|
15577
|
+
]
|
|
15578
|
+
};
|
|
15579
|
+
var API_REPOSITORY = {
|
|
15580
|
+
gh: new RegExp(`${GH_REPO_PATH}\\/?$`, "i"),
|
|
15581
|
+
glab: /(?:^|\/)projects\/[^/]+\/?$/i
|
|
15582
|
+
};
|
|
15583
|
+
var PLAIN_REF = /^refs\/(?:heads|tags)\/(?!.*\.\.)[^\s$`\\%]+$/;
|
|
15584
|
+
var BY_ID = called("updateRefs?|deleteRef");
|
|
15585
|
+
var createdRefs = (query) => {
|
|
15586
|
+
if (/[\\$]|"""/.test(query))
|
|
15587
|
+
return null;
|
|
15588
|
+
const tokens = query.match(/#[^\n\r]*|"[^"\n\r]*"|[_A-Za-z]\w*|[^\s,\uFEFF]/g) ?? [];
|
|
15589
|
+
const named = [];
|
|
15590
|
+
for (let at = 0;at < tokens.length; at++) {
|
|
15591
|
+
if (tokens[at] !== "createRef")
|
|
15592
|
+
continue;
|
|
15593
|
+
const args = tokens.slice(at + 1).filter((token) => !token.startsWith("#"));
|
|
15594
|
+
if (args[0] !== "(")
|
|
15595
|
+
continue;
|
|
15596
|
+
let depth = 0;
|
|
15597
|
+
const names = [];
|
|
15598
|
+
for (let index = 0;index < args.length; index++) {
|
|
15599
|
+
const token = args[index];
|
|
15600
|
+
if (token === "(" || token === "{" || token === "[")
|
|
15601
|
+
depth++;
|
|
15602
|
+
else if (token === ")" || token === "}" || token === "]") {
|
|
15603
|
+
if (--depth === 0)
|
|
15604
|
+
break;
|
|
15605
|
+
} else if (token === "name" && args[index + 1] === ":")
|
|
15606
|
+
names.push(args[index + 2] ?? "");
|
|
15607
|
+
}
|
|
15608
|
+
if (depth !== 0 || names.length !== 1 || !names[0].startsWith('"'))
|
|
15609
|
+
return null;
|
|
15610
|
+
named.push(names[0].slice(1, -1));
|
|
15611
|
+
}
|
|
15612
|
+
return named;
|
|
15613
|
+
};
|
|
15614
|
+
var provablyRead = (query) => /^[\s,\uFEFF]*(?:\{|query[\s,\uFEFF]*[({])/.test(query) && !/\b(?:mutation|subscription)\b/.test(query);
|
|
15615
|
+
var refWrite = (forge, shapes, named, certain) => {
|
|
15616
|
+
const sure = certain && named.length > 0 && named.every((ref) => PLAIN_REF.test(ref));
|
|
15617
|
+
const tags = !sure || named.some((ref) => ref.startsWith("refs/tags/"));
|
|
15618
|
+
const heads = !sure || named.some((ref) => ref.startsWith("refs/heads/"));
|
|
15619
|
+
const ref = shapes.has("ref");
|
|
15620
|
+
return {
|
|
15621
|
+
kind: "ref-write",
|
|
15622
|
+
forge,
|
|
15623
|
+
tag: shapes.has("tag") || ref && tags,
|
|
15624
|
+
branch: shapes.has("branch") || ref && heads,
|
|
15625
|
+
...ref && sure ? { ref: named[0] } : {}
|
|
15626
|
+
};
|
|
15627
|
+
};
|
|
15628
|
+
var restRef = (route, fields, readable) => {
|
|
15629
|
+
const inPath = /\/git\/refs?\/(.+)$/i.exec(route)?.[1];
|
|
15630
|
+
if (inPath)
|
|
15631
|
+
return { named: [`refs/${inPath}`], certain: true };
|
|
15632
|
+
const refs = fields.filter((field) => field.startsWith("ref=")).map((field) => field.slice(4));
|
|
15633
|
+
const mentions = fields.filter((field) => /refs\//.test(field)).length;
|
|
15634
|
+
return { named: refs, certain: readable && refs.length === 1 && mentions === 1 };
|
|
15635
|
+
};
|
|
15636
|
+
var routeOf = (endpoint) => endpoint.replace(/(?<!:)\/{2,}/g, "/").replace(/[?#][\s\S]*$/, "").replace(/%([\da-f]{2})/gi, (escape, hex) => {
|
|
15637
|
+
const char = String.fromCodePoint(Number.parseInt(hex, 16));
|
|
15638
|
+
return /[\w.~-]/.test(char) ? char : escape;
|
|
15639
|
+
});
|
|
15640
|
+
var apiAction = (tool, args, stdin, expanded = []) => {
|
|
15641
|
+
const request = { method: null, body: false, input: false, unread: false };
|
|
15543
15642
|
let endpoint = null;
|
|
15643
|
+
let endpointAt = -1;
|
|
15544
15644
|
const values = [];
|
|
15545
|
-
const
|
|
15645
|
+
const fields = [];
|
|
15646
|
+
const queries = [];
|
|
15647
|
+
const field = (value, expands) => {
|
|
15648
|
+
fields.push(value);
|
|
15649
|
+
values.push(value);
|
|
15650
|
+
if (!value.startsWith("query="))
|
|
15651
|
+
return;
|
|
15652
|
+
const text = value.slice(6);
|
|
15653
|
+
const read = expanded !== "all" && (!(expands && /[$`]/.test(text)) || provablyRead(text));
|
|
15654
|
+
queries.push({ text, read });
|
|
15655
|
+
};
|
|
15656
|
+
const fromStdin = (name, value, text) => {
|
|
15657
|
+
if (name !== "--input") {
|
|
15658
|
+
if (text.includes("\\"))
|
|
15659
|
+
request.unread = true;
|
|
15660
|
+
return field(`${value.slice(0, value.indexOf("=") + 1)}${text}`, true);
|
|
15661
|
+
}
|
|
15662
|
+
values.push(text);
|
|
15663
|
+
let body;
|
|
15664
|
+
try {
|
|
15665
|
+
body = JSON.parse(text);
|
|
15666
|
+
} catch {
|
|
15667
|
+
request.unread = true;
|
|
15668
|
+
return;
|
|
15669
|
+
}
|
|
15670
|
+
const strings = (each) => typeof each === "string" ? [each] : each && typeof each === "object" ? Object.entries(each).flatMap(([key, inner]) => [key, ...strings(inner)]) : [];
|
|
15671
|
+
if (!body || typeof body !== "object" || Array.isArray(body)) {
|
|
15672
|
+
values.push(...strings(body));
|
|
15673
|
+
return;
|
|
15674
|
+
}
|
|
15675
|
+
for (const [key, inner] of Object.entries(body)) {
|
|
15676
|
+
if (typeof inner === "string")
|
|
15677
|
+
field(`${key}=${inner}`, true);
|
|
15678
|
+
else
|
|
15679
|
+
values.push(key, ...strings(inner));
|
|
15680
|
+
}
|
|
15681
|
+
};
|
|
15682
|
+
const take = (name, value, at) => {
|
|
15683
|
+
const expands = expanded === "all" || expanded.includes(at);
|
|
15546
15684
|
if (name === "-X" || name === "--method")
|
|
15547
15685
|
request.method = value.toUpperCase();
|
|
15548
15686
|
if (API_FIELDS.has(name) || name === "--input")
|
|
15549
15687
|
request.body = true;
|
|
15550
|
-
|
|
15551
|
-
|
|
15552
|
-
|
|
15553
|
-
|
|
15688
|
+
if (name === "--input")
|
|
15689
|
+
request.input = true;
|
|
15690
|
+
const piped = name === "--input" ? value === "-" : /^(?:-F|--field)$/.test(name) && /^[^=]*=@-$/.test(value);
|
|
15691
|
+
if (piped && stdin !== undefined) {
|
|
15692
|
+
values.push(value);
|
|
15693
|
+
return fromStdin(name, value, stdin);
|
|
15694
|
+
}
|
|
15695
|
+
if (API_FIELDS.has(name))
|
|
15696
|
+
field(value, expands);
|
|
15697
|
+
else
|
|
15698
|
+
values.push(value);
|
|
15699
|
+
const file = name === "--input" || /^(?:-F|--field)$/.test(name) && /^[^=]*=@/.test(value);
|
|
15700
|
+
if (file)
|
|
15701
|
+
request.unread = true;
|
|
15554
15702
|
};
|
|
15555
15703
|
for (let index = 1;index < args.length; index++) {
|
|
15556
15704
|
const arg = args[index];
|
|
15557
15705
|
if (arg === "--") {
|
|
15558
|
-
endpoint
|
|
15706
|
+
if (endpoint === null)
|
|
15707
|
+
[endpoint, endpointAt] = [args[index + 1] ?? null, index + 1];
|
|
15559
15708
|
break;
|
|
15560
15709
|
}
|
|
15561
15710
|
if (arg.startsWith("--")) {
|
|
15562
15711
|
const eq = arg.indexOf("=");
|
|
15563
15712
|
const name = eq > 0 ? arg.slice(0, eq) : arg;
|
|
15564
15713
|
if (API_VALUES.has(name))
|
|
15565
|
-
take(name, eq > 0 ? arg.slice(eq + 1) : args[++index] ?? "");
|
|
15714
|
+
take(name, eq > 0 ? arg.slice(eq + 1) : args[++index] ?? "", index);
|
|
15566
15715
|
} else if (arg.startsWith("-") && arg.length > 1) {
|
|
15567
15716
|
for (let at = 1;at < arg.length; at++) {
|
|
15568
15717
|
if (!API_SHORT_VALUES.includes(arg[at]))
|
|
15569
15718
|
continue;
|
|
15570
|
-
take(`-${arg[at]}`, at + 1 < arg.length ? arg.slice(at + 1) : args[++index] ?? "");
|
|
15719
|
+
take(`-${arg[at]}`, at + 1 < arg.length ? arg.slice(at + 1) : args[++index] ?? "", index);
|
|
15571
15720
|
break;
|
|
15572
15721
|
}
|
|
15573
|
-
} else
|
|
15574
|
-
endpoint
|
|
15722
|
+
} else if (endpoint === null)
|
|
15723
|
+
[endpoint, endpointAt] = [arg, index];
|
|
15575
15724
|
}
|
|
15576
15725
|
if (!endpoint)
|
|
15577
15726
|
return null;
|
|
15578
|
-
|
|
15727
|
+
const atEndpoint = expanded === "all" || expanded.includes(endpointAt);
|
|
15728
|
+
for (const pair of /[?]([^#]*)/.exec(endpoint)?.[1].split("&") ?? []) {
|
|
15729
|
+
let decoded = pair;
|
|
15730
|
+
try {
|
|
15731
|
+
decoded = decodeURIComponent(pair.replaceAll("+", " "));
|
|
15732
|
+
} catch {
|
|
15733
|
+
request.unread = true;
|
|
15734
|
+
}
|
|
15735
|
+
field(decoded, atEndpoint);
|
|
15736
|
+
if (/refs\//i.test(decoded))
|
|
15737
|
+
request.input = true;
|
|
15738
|
+
}
|
|
15739
|
+
const route = routeOf(endpoint);
|
|
15579
15740
|
const merge = { kind: "merge", forge: tool, via: "api" };
|
|
15580
|
-
|
|
15581
|
-
|
|
15741
|
+
const setting = {
|
|
15742
|
+
kind: "ref-write",
|
|
15743
|
+
forge: tool,
|
|
15744
|
+
tag: false,
|
|
15745
|
+
branch: true,
|
|
15746
|
+
setting: true
|
|
15747
|
+
};
|
|
15748
|
+
if (/(?:^|\/)graphql\/?$/i.test(route)) {
|
|
15749
|
+
if (request.unread || queries.some((query) => !query.read))
|
|
15750
|
+
return { kind: "ref-write", forge: tool, tag: true, branch: true, unread: true };
|
|
15751
|
+
if (values.some((value) => GRAPHQL_MERGE.test(value)))
|
|
15752
|
+
return merge;
|
|
15753
|
+
if (values.some((value) => GRAPHQL_SETTING.test(value)))
|
|
15754
|
+
return setting;
|
|
15755
|
+
const shapes = new Set(GRAPHQL_REF.filter(([pattern]) => values.some((value) => pattern.test(value))).map(([, shape]) => shape));
|
|
15756
|
+
if (!shapes.size)
|
|
15757
|
+
return null;
|
|
15758
|
+
const created = queries.map((query) => createdRefs(query.text));
|
|
15759
|
+
const certain = !values.some((value) => BY_ID.test(value)) && created.every((named) => named !== null);
|
|
15760
|
+
return refWrite(tool, shapes, created.flatMap((named) => named ?? []), certain);
|
|
15761
|
+
}
|
|
15582
15762
|
const verb = request.method ?? (request.body ? "POST" : "GET");
|
|
15583
15763
|
if (verb === "GET" || verb === "HEAD")
|
|
15584
15764
|
return null;
|
|
15585
|
-
const named = tool === "gh" ? /(?:^|\/)repos\/([^/{]+\/[^/{]+)
|
|
15765
|
+
const named = tool === "gh" ? /(?:^|\/)repos\/([^/{]+\/[^/{]+)(?:\/|$)/i.exec(route)?.[1] ?? (/(?:^|\/)repositories\/[^/]+(?:\/|$)/i.test(route) ? "?" : undefined) : /(?:^|\/)projects\/([^/]+)(?:\/|$)/i.exec(route)?.[1];
|
|
15586
15766
|
let repo;
|
|
15587
15767
|
try {
|
|
15588
15768
|
repo = named === undefined ? undefined : decodeURIComponent(named) || "?";
|
|
@@ -15590,9 +15770,17 @@ var apiAction = (tool, args, stdin) => {
|
|
|
15590
15770
|
repo = "?";
|
|
15591
15771
|
}
|
|
15592
15772
|
const at = repo === undefined ? {} : { repo };
|
|
15593
|
-
if (API_MERGE[tool].test(
|
|
15773
|
+
if (API_MERGE[tool].test(route))
|
|
15594
15774
|
return { ...merge, ...at };
|
|
15595
|
-
const
|
|
15775
|
+
const defaultBranch = API_REPOSITORY[tool].test(route) && (request.unread || values.some((value) => /default_branch/.test(value)));
|
|
15776
|
+
if (defaultBranch || API_SETTING[tool].some((pattern) => pattern.test(route)))
|
|
15777
|
+
return { ...setting, ...at };
|
|
15778
|
+
const shape = API_REF[tool].find(([pattern]) => pattern.test(route))?.[1];
|
|
15779
|
+
if (shape) {
|
|
15780
|
+
const { named: refs, certain } = restRef(route, fields, !request.unread && !request.input);
|
|
15781
|
+
return { ...refWrite(tool, new Set([shape]), refs, certain), ...at };
|
|
15782
|
+
}
|
|
15783
|
+
const grant = /\/releases(?:\/|$)/i.test(route) ? "release" : (tool === "gh" ? /\/pulls(?:\/\d+)?\/?$/i : /\/merge_requests(?:\/\d+)?\/?$/i).test(route) ? "pr" : null;
|
|
15596
15784
|
return grant ? { kind: "forge", forge: tool, grant, ...at } : null;
|
|
15597
15785
|
};
|
|
15598
15786
|
var subtreePush = (args) => {
|
|
@@ -15610,7 +15798,7 @@ var subtreePush = (args) => {
|
|
|
15610
15798
|
function rawAction(invocation) {
|
|
15611
15799
|
const args = invocation.args;
|
|
15612
15800
|
if (invocation.tool !== "git" && args[0] === "api")
|
|
15613
|
-
return apiAction(invocation.tool, args, invocation.stdin);
|
|
15801
|
+
return apiAction(invocation.tool, args, invocation.stdin, invocation.expanded);
|
|
15614
15802
|
if (asksHelp(invocation))
|
|
15615
15803
|
return null;
|
|
15616
15804
|
const [first] = args;
|
|
@@ -15886,6 +16074,223 @@ var refusal = (action, branch, dir) => {
|
|
|
15886
16074
|
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")}.`;
|
|
15887
16075
|
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")}.`;
|
|
15888
16076
|
};
|
|
16077
|
+
var PLAIN_EXPANSION = /^(?:[^$`]|\$[A-Za-z_]\w*|\$\{[A-Za-z_]\w*\})*$/u;
|
|
16078
|
+
var shellWord = (text, expands = false) => {
|
|
16079
|
+
if (/^[\w@%+=:,./-]+$/u.test(text))
|
|
16080
|
+
return text;
|
|
16081
|
+
if (expands && text.includes("$") && PLAIN_EXPANSION.test(text))
|
|
16082
|
+
return `"${text.replaceAll(/["\\]/gu, "\\$&")}"`;
|
|
16083
|
+
return `'${text.replaceAll("'", "'\\''")}'`;
|
|
16084
|
+
};
|
|
16085
|
+
var expandingWords = (command, dialect, found = new Set, depth = 0) => {
|
|
16086
|
+
for (const segment of segmentsOf(command, dialect))
|
|
16087
|
+
segment.words.forEach((text, index) => {
|
|
16088
|
+
if (segment.expands?.includes(index))
|
|
16089
|
+
found.add(text);
|
|
16090
|
+
else if (depth < MAX_DEPTH && /\s/u.test(text))
|
|
16091
|
+
expandingWords(text, "posix", found, depth + 1);
|
|
16092
|
+
});
|
|
16093
|
+
return found;
|
|
16094
|
+
};
|
|
16095
|
+
var wordsOf = (command, dialect = "posix") => {
|
|
16096
|
+
const expands = expandsIn(command, dialect);
|
|
16097
|
+
return (text) => shellWord(text, expands(text));
|
|
16098
|
+
};
|
|
16099
|
+
var expandsIn = (command, dialect = "posix") => {
|
|
16100
|
+
let expanding;
|
|
16101
|
+
return (text) => (expanding ??= expandingWords(command, dialect)).has(text);
|
|
16102
|
+
};
|
|
16103
|
+
var oneCall = (command, dialect) => {
|
|
16104
|
+
const steps = /^(?:\s*cd\s+[^\s;&|<>()$`'"\\]+\s*&&)*([\s\S]*)$/u.exec(command);
|
|
16105
|
+
return !!steps && !!simpleCommand(steps[1], dialect);
|
|
16106
|
+
};
|
|
16107
|
+
var flagWord = (flag, value, asWritten) => value.startsWith("-") ? [`${flag}=${asWritten(value)}`] : [flag, asWritten(value)];
|
|
16108
|
+
var PR_FLAGS = {
|
|
16109
|
+
"gh ready": { verb: "ready", booleans: { "--undo": ["--undo"] }, values: {} },
|
|
16110
|
+
"gh merge": {
|
|
16111
|
+
verb: "merge",
|
|
16112
|
+
booleans: {
|
|
16113
|
+
"--squash": ["--squash"],
|
|
16114
|
+
"-s": ["--squash"],
|
|
16115
|
+
"--merge": ["--merge"],
|
|
16116
|
+
"-m": ["--merge"],
|
|
16117
|
+
"--rebase": ["--rebase"],
|
|
16118
|
+
"-r": ["--rebase"],
|
|
16119
|
+
"--delete-branch": ["--delete-branch"],
|
|
16120
|
+
"-d": ["--delete-branch"]
|
|
16121
|
+
},
|
|
16122
|
+
values: {
|
|
16123
|
+
"--subject": { flag: "--subject" },
|
|
16124
|
+
"-t": { flag: "--subject" },
|
|
16125
|
+
"--body": { flag: "--body" },
|
|
16126
|
+
"-b": { flag: "--body" },
|
|
16127
|
+
"--body-file": { flag: "--body-file" },
|
|
16128
|
+
"-F": { flag: "--body-file" }
|
|
16129
|
+
}
|
|
16130
|
+
},
|
|
16131
|
+
"gh edit": {
|
|
16132
|
+
verb: "edit",
|
|
16133
|
+
booleans: {},
|
|
16134
|
+
values: {
|
|
16135
|
+
"--title": { flag: "--title" },
|
|
16136
|
+
"-t": { flag: "--title" },
|
|
16137
|
+
"--body-file": { flag: "--body-file" },
|
|
16138
|
+
"-F": { flag: "--body-file" },
|
|
16139
|
+
"--add-label": { flag: "--add-label", split: true },
|
|
16140
|
+
"--remove-label": { flag: "--remove-label", split: true },
|
|
16141
|
+
"--add-reviewer": { flag: "--add-reviewer", split: true },
|
|
16142
|
+
"--base": { flag: "--base" },
|
|
16143
|
+
"-B": { flag: "--base" }
|
|
16144
|
+
}
|
|
16145
|
+
},
|
|
16146
|
+
"glab merge": {
|
|
16147
|
+
verb: "merge",
|
|
16148
|
+
booleans: {
|
|
16149
|
+
"--squash": ["--squash"],
|
|
16150
|
+
"-s": ["--squash"],
|
|
16151
|
+
"--rebase": ["--rebase"],
|
|
16152
|
+
"-r": ["--rebase"],
|
|
16153
|
+
"--remove-source-branch": ["--delete-branch"],
|
|
16154
|
+
"-d": ["--delete-branch"],
|
|
16155
|
+
"--yes": [],
|
|
16156
|
+
"-y": []
|
|
16157
|
+
},
|
|
16158
|
+
values: {}
|
|
16159
|
+
},
|
|
16160
|
+
"glab update": {
|
|
16161
|
+
verb: "edit",
|
|
16162
|
+
booleans: { "--ready": [], "-r": [], "--draft": ["--undo"], "--yes": [], "-y": [] },
|
|
16163
|
+
values: {
|
|
16164
|
+
"--title": { flag: "--title" },
|
|
16165
|
+
"-t": { flag: "--title" },
|
|
16166
|
+
"--label": { flag: "--add-label", split: true },
|
|
16167
|
+
"-l": { flag: "--add-label", split: true },
|
|
16168
|
+
"--unlabel": { flag: "--remove-label", split: true },
|
|
16169
|
+
"-u": { flag: "--remove-label", split: true },
|
|
16170
|
+
"--target-branch": { flag: "--base" }
|
|
16171
|
+
}
|
|
16172
|
+
}
|
|
16173
|
+
};
|
|
16174
|
+
var prRetry = (cwd, repo, invocation, cache, asWritten) => {
|
|
16175
|
+
const forge = invocation.tool;
|
|
16176
|
+
if (forge === "git")
|
|
16177
|
+
return null;
|
|
16178
|
+
const values = VALUE_OPTIONS[forge];
|
|
16179
|
+
const args = invocation.args;
|
|
16180
|
+
let verb;
|
|
16181
|
+
let at = 1;
|
|
16182
|
+
for (;at < args.length; at++) {
|
|
16183
|
+
if (!args[at].startsWith("-")) {
|
|
16184
|
+
verb = args[at];
|
|
16185
|
+
break;
|
|
16186
|
+
}
|
|
16187
|
+
if (values.has(args[at]))
|
|
16188
|
+
at++;
|
|
16189
|
+
}
|
|
16190
|
+
const table = PR_FLAGS[`${forge} ${verb}`];
|
|
16191
|
+
if (!table)
|
|
16192
|
+
return null;
|
|
16193
|
+
const words = [];
|
|
16194
|
+
const repos = [];
|
|
16195
|
+
let selector;
|
|
16196
|
+
let ready = false;
|
|
16197
|
+
const rest = [...args.slice(1, at), ...args.slice(at + 1)];
|
|
16198
|
+
for (let index = 0;index < rest.length; index++) {
|
|
16199
|
+
const arg = rest[index];
|
|
16200
|
+
const eq = arg.startsWith("--") ? arg.indexOf("=") : -1;
|
|
16201
|
+
const name = eq > 0 ? arg.slice(0, eq) : arg;
|
|
16202
|
+
const value = () => eq > 0 ? arg.slice(eq + 1) : rest[++index];
|
|
16203
|
+
if (name === "-R" || name === "--repo") {
|
|
16204
|
+
const named = value();
|
|
16205
|
+
if (named === undefined)
|
|
16206
|
+
return null;
|
|
16207
|
+
repos.push(named);
|
|
16208
|
+
} else if (/^-R./.test(arg))
|
|
16209
|
+
repos.push(arg.slice(2).replace(/^=/, ""));
|
|
16210
|
+
else if (eq < 0 && Object.hasOwn(table.booleans, arg)) {
|
|
16211
|
+
if (forge === "glab" && (arg === "--ready" || arg === "-r" || arg === "--draft")) {
|
|
16212
|
+
if (ready && words.includes("--undo") !== (arg === "--draft"))
|
|
16213
|
+
return null;
|
|
16214
|
+
ready = true;
|
|
16215
|
+
}
|
|
16216
|
+
words.push(...table.booleans[arg]);
|
|
16217
|
+
} else if (Object.hasOwn(table.values, name)) {
|
|
16218
|
+
const given = value();
|
|
16219
|
+
if (given === undefined)
|
|
16220
|
+
return null;
|
|
16221
|
+
const { flag, split } = table.values[name];
|
|
16222
|
+
if (split && given.includes(",") && /[$`]/.test(given))
|
|
16223
|
+
return null;
|
|
16224
|
+
for (const item of split ? given.split(",").filter(Boolean) : [given])
|
|
16225
|
+
words.push(...flagWord(flag, item, asWritten));
|
|
16226
|
+
} else if (arg.startsWith("-") || selector !== undefined)
|
|
16227
|
+
return null;
|
|
16228
|
+
else
|
|
16229
|
+
selector = arg;
|
|
16230
|
+
}
|
|
16231
|
+
const workitVerb = ready ? "ready" : table.verb;
|
|
16232
|
+
if (ready && words.some((word) => word !== "--undo"))
|
|
16233
|
+
return null;
|
|
16234
|
+
const pr = [];
|
|
16235
|
+
if (selector !== undefined) {
|
|
16236
|
+
const url = /^(https?:\/\/[^/]+\/.+?)\/(?:-\/)?(?:pull|merge_requests)\/(\d+)(?:[/?#].*)?$/.exec(selector);
|
|
16237
|
+
const number = url?.[2] ?? /^[#!]?(\d+)$/.exec(selector)?.[1];
|
|
16238
|
+
if (url)
|
|
16239
|
+
repos.push(url[1]);
|
|
16240
|
+
if (number)
|
|
16241
|
+
pr.push("--pr", number);
|
|
16242
|
+
else if (/\$[A-Za-z_{]/.test(selector))
|
|
16243
|
+
pr.push("--pr", asWritten(selector));
|
|
16244
|
+
else if (selector !== repo.branch)
|
|
16245
|
+
return null;
|
|
16246
|
+
}
|
|
16247
|
+
const env = invocation.env ?? {};
|
|
16248
|
+
if (forge === "gh" && (env.GH_REPO ?? process.env.GH_REPO))
|
|
16249
|
+
repos.push(env.GH_REPO ?? process.env.GH_REPO ?? "");
|
|
16250
|
+
if (repos.length) {
|
|
16251
|
+
const config = gitConfig(repo.dir, invocation, cache);
|
|
16252
|
+
const { GH_REPO: _named, ...own } = env;
|
|
16253
|
+
const key = (named, from) => {
|
|
16254
|
+
const found = forgeRepo(forge === "gh", named, from, config, repo.branch, repo.dir);
|
|
16255
|
+
return found instanceof Error ? null : found.remotes[0]?.key.toLowerCase() ?? null;
|
|
16256
|
+
};
|
|
16257
|
+
const checkout = key("", own);
|
|
16258
|
+
if (!checkout || repos.some((named) => /[$`]/.test(named) || key(named, own) !== checkout))
|
|
16259
|
+
return null;
|
|
16260
|
+
}
|
|
16261
|
+
const dir = path25.resolve(cwd, invocation.dir ?? ".");
|
|
16262
|
+
const call = [
|
|
16263
|
+
`workit pr ${workitVerb}`,
|
|
16264
|
+
...dir === path25.resolve(cwd) ? [] : ["--cwd", shellWord(dir)],
|
|
16265
|
+
...pr,
|
|
16266
|
+
...words
|
|
16267
|
+
].join(" ");
|
|
16268
|
+
return { raw: `${forge} ${forge === "gh" ? "pr" : "mr"} ${verb}`, call };
|
|
16269
|
+
};
|
|
16270
|
+
var prWriteRefusal = (writes, retry) => {
|
|
16271
|
+
const raws = [...new Set(writes.map((write) => quote(write.raw)))].join(", ");
|
|
16272
|
+
const calls = writes.map((write) => quote(write.call)).join(", ");
|
|
16273
|
+
const why = `workit: raw ${raws} changes the PR past workit's checks (the pr grant, and that the PR is this session's own).`;
|
|
16274
|
+
if (retry && writes.length === 1)
|
|
16275
|
+
return `${why} Run ${calls} instead.
|
|
16276
|
+
Retry as: ${writes[0].call}`;
|
|
16277
|
+
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.`;
|
|
16278
|
+
};
|
|
16279
|
+
var refWriteRefusal = (action) => {
|
|
16280
|
+
if (action.unread)
|
|
16281
|
+
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.`;
|
|
16282
|
+
if (action.setting)
|
|
16283
|
+
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.`;
|
|
16284
|
+
const steers = [
|
|
16285
|
+
...action.branch ? [
|
|
16286
|
+
`push a branch with ${quote("workit git push")} (it refuses protected branches and verifies the remote tip)`
|
|
16287
|
+
] : [],
|
|
16288
|
+
...action.tag ? [
|
|
16289
|
+
`tag a release with ${quote("workit release tag <vX.Y.Z>")} or ${quote("workit git push --release <tag>")}, under the ${quote("release")} grant`
|
|
16290
|
+
] : []
|
|
16291
|
+
];
|
|
16292
|
+
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("; ")}.`;
|
|
16293
|
+
};
|
|
15889
16294
|
var refFacts = (repo, remote) => {
|
|
15890
16295
|
const facts = {
|
|
15891
16296
|
heads: new Set,
|
|
@@ -16034,6 +16439,7 @@ var nudgeFor = (action, host, session) => {
|
|
|
16034
16439
|
case "pr-read":
|
|
16035
16440
|
case "forge":
|
|
16036
16441
|
case "merge":
|
|
16442
|
+
case "ref-write":
|
|
16037
16443
|
return null;
|
|
16038
16444
|
}
|
|
16039
16445
|
};
|
|
@@ -16051,8 +16457,10 @@ var pushRefusal = (action, repo, config) => {
|
|
|
16051
16457
|
return offPolicy;
|
|
16052
16458
|
for (const target of targets) {
|
|
16053
16459
|
const guarded = guardedTarget(repo.dir, target ?? repo.branch ?? "");
|
|
16054
|
-
if (guarded)
|
|
16055
|
-
|
|
16460
|
+
if (!guarded)
|
|
16461
|
+
continue;
|
|
16462
|
+
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).` : "";
|
|
16463
|
+
return refusal(action, guarded, repo.dir) + first;
|
|
16056
16464
|
}
|
|
16057
16465
|
return tagRefusal(pushed, facts, repo.dir) ?? (action.deletes ? null : offPolicyPush(pushed, repo, facts, remote));
|
|
16058
16466
|
};
|
|
@@ -16234,6 +16642,8 @@ var commitRefusal = (input, command, dialect, { action, repo, invocation, workit
|
|
|
16234
16642
|
try {
|
|
16235
16643
|
guarded = !!repo.branch && resolveBranchPolicyFor(repo.dir).protected.has(repo.branch.toLowerCase());
|
|
16236
16644
|
} catch {}
|
|
16645
|
+
if (guarded && !switches && noRefs(repo))
|
|
16646
|
+
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).`;
|
|
16237
16647
|
if (guarded && !switches)
|
|
16238
16648
|
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>")}.`;
|
|
16239
16649
|
const call = action.amend || dialect !== "posix" || typeof invocation.dir !== "string" ? null : cdCommitCall(input, command, path25.resolve(input.cwd, invocation.dir), repo);
|
|
@@ -16243,6 +16653,8 @@ function rawGitPre(input, command, options = {}) {
|
|
|
16243
16653
|
try {
|
|
16244
16654
|
const dialect = dialectOf(input);
|
|
16245
16655
|
const nudges = new Map;
|
|
16656
|
+
const prWrites = [];
|
|
16657
|
+
const asWritten = wordsOf(command, dialect);
|
|
16246
16658
|
let store = null;
|
|
16247
16659
|
const cache = new Map;
|
|
16248
16660
|
const blind = rawInvocations(command, dialect).find((raw) => raw.redirect && rawAction(raw)?.kind === "push");
|
|
@@ -16263,8 +16675,19 @@ function rawGitPre(input, command, options = {}) {
|
|
|
16263
16675
|
if (!workit)
|
|
16264
16676
|
continue;
|
|
16265
16677
|
store ??= repo.location.dir;
|
|
16266
|
-
if (action.kind === "merge")
|
|
16267
|
-
|
|
16678
|
+
if (action.kind === "merge") {
|
|
16679
|
+
const retry = prRetry(input.cwd, repo, invocation, cache, asWritten);
|
|
16680
|
+
const named = !retry ? "" : oneCall(command, dialect) ? `
|
|
16681
|
+
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.`;
|
|
16682
|
+
return deny(`${refusal(action, null)}${named}`);
|
|
16683
|
+
}
|
|
16684
|
+
if (action.kind === "ref-write")
|
|
16685
|
+
return deny(refWriteRefusal(action));
|
|
16686
|
+
if (action.kind === "forge" && action.grant === "pr") {
|
|
16687
|
+
const retry = prRetry(input.cwd, repo, invocation, cache, asWritten);
|
|
16688
|
+
if (retry)
|
|
16689
|
+
prWrites.push(retry);
|
|
16690
|
+
}
|
|
16268
16691
|
if (action.kind === "push") {
|
|
16269
16692
|
const refused = pushRefusal(action, repo, gitConfig(repo.dir, invocation, cache));
|
|
16270
16693
|
if (refused)
|
|
@@ -16274,6 +16697,8 @@ function rawGitPre(input, command, options = {}) {
|
|
|
16274
16697
|
if (nudge && !nudges.has(nudgeKind(action)))
|
|
16275
16698
|
nudges.set(nudgeKind(action), nudge);
|
|
16276
16699
|
}
|
|
16700
|
+
if (prWrites.length)
|
|
16701
|
+
return deny(prWriteRefusal(prWrites, oneCall(command, dialect)));
|
|
16277
16702
|
const pkill = options.nudge === false ? null : pkillSelfMatch(command, dialect);
|
|
16278
16703
|
const pkillNote = pkill ? { kind: "context", text: pkill } : NONE2;
|
|
16279
16704
|
if (options.nudge === false || !store || nudges.size === 0)
|
|
@@ -16357,6 +16782,8 @@ var grantRefusal = (action, repo, invocation, cache) => {
|
|
|
16357
16782
|
kinds.push("pr");
|
|
16358
16783
|
else if (action.kind === "forge")
|
|
16359
16784
|
kinds.push(action.grant);
|
|
16785
|
+
else if (action.kind === "ref-write")
|
|
16786
|
+
kinds.push(...action.branch ? ["push"] : [], ...action.tag ? ["release"] : [], ...action.unread ? ["merge"] : []);
|
|
16360
16787
|
for (const kind of kinds) {
|
|
16361
16788
|
const denied = rawGrantDenial(repo.dir, kind, target);
|
|
16362
16789
|
if (denied)
|
|
@@ -16364,6 +16791,21 @@ var grantRefusal = (action, repo, invocation, cache) => {
|
|
|
16364
16791
|
}
|
|
16365
16792
|
return null;
|
|
16366
16793
|
};
|
|
16794
|
+
var noRefs = (repo) => {
|
|
16795
|
+
const common = path25.dirname(repo.location.dir);
|
|
16796
|
+
const holds = (dir) => {
|
|
16797
|
+
try {
|
|
16798
|
+
return fs17.readdirSync(dir, { withFileTypes: true }).some((entry) => entry.isFile() || entry.isDirectory() && holds(path25.join(dir, entry.name)));
|
|
16799
|
+
} catch {
|
|
16800
|
+
return false;
|
|
16801
|
+
}
|
|
16802
|
+
};
|
|
16803
|
+
try {
|
|
16804
|
+
if (/ refs\//.test(fs17.readFileSync(path25.join(common, "packed-refs"), "utf8")))
|
|
16805
|
+
return false;
|
|
16806
|
+
} catch {}
|
|
16807
|
+
return fs17.existsSync(path25.join(common, "refs")) && !holds(path25.join(common, "refs"));
|
|
16808
|
+
};
|
|
16367
16809
|
var localTag = (repo, name) => {
|
|
16368
16810
|
const common = path25.dirname(repo.location.dir);
|
|
16369
16811
|
try {
|
|
@@ -17574,8 +18016,7 @@ var linesOf = (command, dialect) => {
|
|
|
17574
18016
|
return null;
|
|
17575
18017
|
}
|
|
17576
18018
|
};
|
|
17577
|
-
var
|
|
17578
|
-
var leaseCommand = (words) => `workit check --heavy -- ${words.map(quoteWord).join(" ")}`;
|
|
18019
|
+
var leaseCommand = (words, word) => `workit check --heavy -- ${words.map(word).join(" ")}`;
|
|
17579
18020
|
function heavyPlan(command, options) {
|
|
17580
18021
|
const dialect = options.dialect ?? "posix";
|
|
17581
18022
|
if (dialect !== "posix" || !gitTop(options.cwd))
|
|
@@ -17608,7 +18049,8 @@ function heavyPlan(command, options) {
|
|
|
17608
18049
|
}));
|
|
17609
18050
|
return rewrite ? { kind: "rewrite", command: rewrite, reason: single.reason } : { kind: "none" };
|
|
17610
18051
|
}
|
|
17611
|
-
const
|
|
18052
|
+
const word = wordsOf(command, dialect);
|
|
18053
|
+
const parts = heavy.map((match) => leaseCommand(match.line, word));
|
|
17612
18054
|
return {
|
|
17613
18055
|
kind: "split",
|
|
17614
18056
|
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" : ""}.`,
|
|
@@ -17630,7 +18072,7 @@ function serverPlan(command, options) {
|
|
|
17630
18072
|
const rewrite = leaseRewrite(command)?.replace("workit check --heavy --", "workit run --bg --");
|
|
17631
18073
|
return rewrite ? { kind: "rewrite", command: rewrite, reason: single, server: true } : { kind: "none" };
|
|
17632
18074
|
}
|
|
17633
|
-
const start = `workit run --bg -- ${found.line.map(
|
|
18075
|
+
const start = `workit run --bg -- ${found.line.map(wordsOf(command, dialect)).join(" ")}`;
|
|
17634
18076
|
return {
|
|
17635
18077
|
kind: "split",
|
|
17636
18078
|
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.`,
|
|
@@ -18378,7 +18820,7 @@ var wrappedScript = (input) => {
|
|
|
18378
18820
|
const script = shellScript3(tail.argv);
|
|
18379
18821
|
if (SCRIPT_SHELLS.has((tail.argv[0]?.split(/[\\/]/).at(-1) ?? "").toLowerCase()) && script)
|
|
18380
18822
|
return script;
|
|
18381
|
-
return tail.argv.map(
|
|
18823
|
+
return tail.argv.map(quoteWord).join(" ");
|
|
18382
18824
|
};
|
|
18383
18825
|
var editsOf = (input) => {
|
|
18384
18826
|
const words = pastLead(input);
|
|
@@ -19256,7 +19698,7 @@ var cdInto = (dir, words, strict = false, vars = new Map, globs = false) => {
|
|
|
19256
19698
|
return lost;
|
|
19257
19699
|
return target === undefined ? os9.homedir() : path31.resolve(dir, target);
|
|
19258
19700
|
};
|
|
19259
|
-
var
|
|
19701
|
+
var quoteWord = (word) => /^[\w@%+=:,./-]+$/.test(word) ? word : `'${word.replaceAll("'", "'\\''")}'`;
|
|
19260
19702
|
var expandVars = (text, vars) => vars.size === 0 || !text.includes("$") ? text : text.replace(/\$(?:(\w+)|\{(\w+)\})/g, (whole, bare, braced) => {
|
|
19261
19703
|
const value = vars.get(bare ?? braced ?? "");
|
|
19262
19704
|
return value === undefined ? whole : value;
|
|
@@ -19654,7 +20096,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
19654
20096
|
targets.push(cmd && CMD_VAR.test(file) ? placeholderIn(dir, `${OPAQUE_TARGET}cmd`) : file);
|
|
19655
20097
|
const bare = strict && depth < 4 ? unwrapped2(words) : null;
|
|
19656
20098
|
if (bare?.length && dir !== undefined)
|
|
19657
|
-
targets.push(...segmentTargets(dir, bare.flatMap((word) => expansions(word, vars, loops)).map(
|
|
20099
|
+
targets.push(...segmentTargets(dir, bare.flatMap((word) => expansions(word, vars, loops)).map(quoteWord).join(" "), "posix", depth + 1, strict, vars));
|
|
19658
20100
|
if (strict === "registry" && dir !== undefined && depth < 4) {
|
|
19659
20101
|
const run = words.slice(Math.max(0, words.findIndex((word) => !PREFIXES2.has(word))));
|
|
19660
20102
|
const [verb = "", ...args] = run.map((word, index) => index ? word : (word.split(/[\\/]/).at(-1) ?? "").toLowerCase());
|
|
@@ -19789,7 +20231,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
19789
20231
|
if (!/^\/dev\/(?:null|stdout|stderr|tty)$/.test(file) && !(dialect === "powershell" && /^(?:\$null|nul)$/i.test(file)))
|
|
19790
20232
|
targets.push(...atAll(file));
|
|
19791
20233
|
if (dir !== undefined)
|
|
19792
|
-
for (const invocation of workitInvocations(body.map(
|
|
20234
|
+
for (const invocation of workitInvocations(body.map(quoteWord).join(" "), "posix")) {
|
|
19793
20235
|
const { at: runsIn, args } = workitCwd(dir, invocation, atAll);
|
|
19794
20236
|
if (args[0] === "git" && MUTATING_WORKIT_GIT.has(args[1] ?? "") && !inert(args.slice(2), ""))
|
|
19795
20237
|
targets.push(...runsIn.map((runs) => placeholderIn(runs, DIR_TARGET)));
|
|
@@ -19798,7 +20240,7 @@ var segmentTargets = (cwd, command, dialect, depth = 0, strict = false, inherite
|
|
|
19798
20240
|
return targets;
|
|
19799
20241
|
};
|
|
19800
20242
|
var workitRunDir = (dir, words, resolve) => {
|
|
19801
|
-
for (const invocation of workitInvocations(words.map(
|
|
20243
|
+
for (const invocation of workitInvocations(words.map(quoteWord).join(" "), "posix")) {
|
|
19802
20244
|
const { at, args } = workitCwd(dir, invocation, resolve);
|
|
19803
20245
|
if (args[0] === "check" || args[0] === "lock" && args[1] === "run")
|
|
19804
20246
|
return at;
|
|
@@ -22387,7 +22829,7 @@ var workitCallDir = (command, dialect) => {
|
|
|
22387
22829
|
const call = plainWorkitCall(command, dialect);
|
|
22388
22830
|
return call?.cwd && path36.isAbsolute(call.cwd) ? call.cwd : null;
|
|
22389
22831
|
};
|
|
22390
|
-
var
|
|
22832
|
+
var shellWord2 = (dir) => /^[\w@%+=:,./-]+$/u.test(dir) ? dir : `'${dir.replaceAll("'", `'\\''`)}'`;
|
|
22391
22833
|
var cwdAt = (words, index) => words[index] === "--cwd" && words[index + 1] !== undefined ? 2 : words[index]?.startsWith("--cwd=") ? 1 : 0;
|
|
22392
22834
|
var plainRetry = (dir, command) => {
|
|
22393
22835
|
const call = plainWorkitCall(command, "posix");
|
|
@@ -22436,7 +22878,7 @@ var plainRetry = (dir, command) => {
|
|
|
22436
22878
|
if (parts.includes(null))
|
|
22437
22879
|
return null;
|
|
22438
22880
|
const [envText, globalText, verbText, restText] = parts;
|
|
22439
|
-
const cwd = ["--cwd",
|
|
22881
|
+
const cwd = ["--cwd", shellWord2(dir)];
|
|
22440
22882
|
const body = [...globalText, ...verbText, ...cwd, ...restText];
|
|
22441
22883
|
return { retry: [...envText, "workit", ...body].join(" "), dropped };
|
|
22442
22884
|
};
|
|
@@ -24198,11 +24640,12 @@ var hinted = (write) => write.hint ? {
|
|
|
24198
24640
|
plain: false,
|
|
24199
24641
|
workit: write.hint
|
|
24200
24642
|
} : write;
|
|
24201
|
-
var ytrackArgs = (line, found, depth, names, plain) => {
|
|
24643
|
+
var ytrackArgs = (line, found, depth, names, plain, expands = () => false) => {
|
|
24202
24644
|
const inner = (script) => void found.push(...ytrackWrites(script, "posix", depth + 1, plain));
|
|
24203
24645
|
const tail = workitCheckTail(line);
|
|
24204
24646
|
if (tail) {
|
|
24205
|
-
|
|
24647
|
+
const live = (text) => expands(text) && /[$`]/.test(text) ? `"${text.replaceAll(/["\\]/g, "\\$&")}"` : quote2(text);
|
|
24648
|
+
inner("script" in tail ? tail.script : tail.argv.map(live).join(" "));
|
|
24206
24649
|
return true;
|
|
24207
24650
|
}
|
|
24208
24651
|
const flag = SHELLS3.test(name2(line[0])) ? line.findIndex((word, index) => index > 0 && /^-[a-zA-Z]*c[a-zA-Z]*$/.test(word)) : -1;
|
|
@@ -24232,8 +24675,9 @@ var ytrackArgs = (line, found, depth, names, plain) => {
|
|
|
24232
24675
|
const argv = [...alias ?? [], ...line.slice(at + 1)];
|
|
24233
24676
|
const write = classify(argv);
|
|
24234
24677
|
if (write) {
|
|
24678
|
+
const word = (text) => plain ? quote2(text) : shellWord(text, expands(text));
|
|
24235
24679
|
const one = {
|
|
24236
|
-
command: ["ytrack", ...argv].map(
|
|
24680
|
+
command: ["ytrack", ...argv].map(word).join(" "),
|
|
24237
24681
|
...write,
|
|
24238
24682
|
...hostsOf(argv),
|
|
24239
24683
|
plain
|
|
@@ -24336,14 +24780,15 @@ var ytrackWrites = (command, dialect = "posix", depth = 0, plain = true) => {
|
|
|
24336
24780
|
let found = [];
|
|
24337
24781
|
const lines = plain ? plainLines(command, dialect) : null;
|
|
24338
24782
|
const none = new Map;
|
|
24783
|
+
const expands = expandsIn(command, dialect);
|
|
24339
24784
|
const plainFirst = lines ? ytrackArgs(lines.first, found, depth, none, true) : false;
|
|
24340
24785
|
const joined = lines && plainFirst ? chained(found, lines.chain, depth) : null;
|
|
24341
24786
|
if (joined)
|
|
24342
24787
|
found = joined;
|
|
24343
|
-
if (!lines || !plainFirst || !(joined ? [] : lines.chain).every((line) => ytrackArgs(line, found, depth, none, false)) || !lines.later.every((line) => ytrackArgs(line, found, depth, none, false))) {
|
|
24788
|
+
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))) {
|
|
24344
24789
|
found = [];
|
|
24345
24790
|
for (const line of commandLines(command, dialect))
|
|
24346
|
-
ytrackArgs(line, found, depth, aliases(command), false);
|
|
24791
|
+
ytrackArgs(line, found, depth, aliases(command), false, expands);
|
|
24347
24792
|
found = found.map(hinted);
|
|
24348
24793
|
}
|
|
24349
24794
|
READ.set(key, found);
|
|
@@ -24353,7 +24798,7 @@ var ytrackWrites = (command, dialect = "posix", depth = 0, plain = true) => {
|
|
|
24353
24798
|
};
|
|
24354
24799
|
var RELOCATES = /(?<![$\w])YTRACK_CONFIG_DIR\b/;
|
|
24355
24800
|
var reachesOnly = (allowed, write) => write.plain && !!write.hosts?.length && write.hosts.every((host) => youTrackHostAllowed(allowed, host));
|
|
24356
|
-
var scopedGate = (allowed, command, writes) => {
|
|
24801
|
+
var scopedGate = (allowed, command, dialect, writes) => {
|
|
24357
24802
|
const scope = `youtrack.autoHosts (${allowed.join(", ")})`;
|
|
24358
24803
|
if (RELOCATES.test(command))
|
|
24359
24804
|
return {
|
|
@@ -24368,8 +24813,10 @@ var scopedGate = (allowed, command, writes) => {
|
|
|
24368
24813
|
if (!unnamed.length)
|
|
24369
24814
|
return null;
|
|
24370
24815
|
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";
|
|
24371
|
-
const
|
|
24372
|
-
const
|
|
24816
|
+
const hostless = unnamed.find((each) => each.bare);
|
|
24817
|
+
const expands = expandsIn(command, dialect);
|
|
24818
|
+
const word = (text) => hostless?.plain ? quote2(text) : shellWord(text, expands(text));
|
|
24819
|
+
const retry = hostless?.bare ? ["ytrack", "--host", first, ...hostless.bare].map(word).join(" ") : null;
|
|
24373
24820
|
return {
|
|
24374
24821
|
kind: "deny",
|
|
24375
24822
|
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 ? `
|
|
@@ -24405,7 +24852,7 @@ var ytrackGate = (cwd, command, dialect, ask) => {
|
|
|
24405
24852
|
const hosts = policy.hosts;
|
|
24406
24853
|
if (hosts === null)
|
|
24407
24854
|
return null;
|
|
24408
|
-
const scoped = scopedGate(hosts, command, writes);
|
|
24855
|
+
const scoped = scopedGate(hosts, command, dialect, writes);
|
|
24409
24856
|
if (scoped)
|
|
24410
24857
|
return scoped;
|
|
24411
24858
|
writes = writes.filter((write) => !reachesOnly(hosts, write));
|
package/dist/workit-hook.js
CHANGED
|
@@ -106,7 +106,7 @@ if (quiet) {
|
|
|
106
106
|
`);
|
|
107
107
|
} else {
|
|
108
108
|
try {
|
|
109
|
-
const { runCodexHook } = await import("./workit-hook-
|
|
109
|
+
const { runCodexHook } = await import("./workit-hook-yg9cg2jz.js");
|
|
110
110
|
await runCodexHook([payload]);
|
|
111
111
|
} catch (error) {
|
|
112
112
|
const { answerRuntimeFailure } = await import("./workit-hook-8kebgc9b.js");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workit-dev/codex",
|
|
3
|
-
"version": "2.29.
|
|
3
|
+
"version": "2.29.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Workit Codex CLI/desktop plugin — shared MCP transport, hooks, method skills, and verifier/reviewer/implementer agents",
|
|
6
6
|
"keywords": [
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"build": "bun scripts/build.ts"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@workit-dev/core": "^2.29.
|
|
45
|
-
"@workit-dev/mcp": "^2.29.
|
|
44
|
+
"@workit-dev/core": "^2.29.3",
|
|
45
|
+
"@workit-dev/mcp": "^2.29.3"
|
|
46
46
|
},
|
|
47
47
|
"engines": {
|
|
48
48
|
"node": ">=24"
|