@staff0rd/assist 0.927.1 → 0.929.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/claude/commands/review-pr-comments.md +3 -3
- package/dist/commands/extension/extension/content.js +1 -1
- package/dist/commands/extension/extension/manifest.json +1 -1
- package/dist/commands/extension/extension/updates.json +2 -2
- package/dist/commands/sessions/web/bundle.js +1 -1
- package/dist/index.js +598 -398
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Command } from "commander";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@staff0rd/assist",
|
|
9
|
-
version: "0.
|
|
9
|
+
version: "0.929.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -1554,15 +1554,15 @@ async function ensureTailscaleServe(port, deps2 = {}) {
|
|
|
1554
1554
|
if (!enabled()) return "skipped, sessions.tailscaleServe is false";
|
|
1555
1555
|
const current = await runningStatus(status2);
|
|
1556
1556
|
if (typeof current === "string") return current;
|
|
1557
|
-
for (let
|
|
1557
|
+
for (let attempt2 = 1; ; attempt2++) {
|
|
1558
1558
|
const plan2 = planServe(current, await serveStatus(), port, httpsPort(port));
|
|
1559
1559
|
if (plan2.alreadyServing) return `${plan2.url} already serves ${plan2.target}`;
|
|
1560
1560
|
try {
|
|
1561
1561
|
await serve(plan2.args);
|
|
1562
1562
|
return `serving ${plan2.target} at ${plan2.url}`;
|
|
1563
1563
|
} catch (error) {
|
|
1564
|
-
if (
|
|
1565
|
-
await sleep2(
|
|
1564
|
+
if (attempt2 >= SERVE_WRITE_ATTEMPTS) throw error;
|
|
1565
|
+
await sleep2(attempt2 * 500 + Math.random() * 500);
|
|
1566
1566
|
}
|
|
1567
1567
|
}
|
|
1568
1568
|
}
|
|
@@ -5170,6 +5170,17 @@ async function launchFromGithub(req, res, plan2, launch) {
|
|
|
5170
5170
|
}
|
|
5171
5171
|
}
|
|
5172
5172
|
|
|
5173
|
+
// src/shared/azureDevops/isAzureDevopsUrl.ts
|
|
5174
|
+
function isAzureDevopsUrl(url) {
|
|
5175
|
+
let host;
|
|
5176
|
+
try {
|
|
5177
|
+
host = new URL(url).hostname.toLowerCase();
|
|
5178
|
+
} catch {
|
|
5179
|
+
return false;
|
|
5180
|
+
}
|
|
5181
|
+
return host === "dev.azure.com" || host.endsWith(".visualstudio.com");
|
|
5182
|
+
}
|
|
5183
|
+
|
|
5173
5184
|
// src/shared/azureDevops/decodeUrlPart.ts
|
|
5174
5185
|
function decodeUrlPart(part) {
|
|
5175
5186
|
try {
|
|
@@ -5220,7 +5231,12 @@ var prActions = [
|
|
|
5220
5231
|
];
|
|
5221
5232
|
|
|
5222
5233
|
// src/shared/azureDevops/azureDevopsPrActions.ts
|
|
5223
|
-
var SUPPORTED = /* @__PURE__ */ new Set([
|
|
5234
|
+
var SUPPORTED = /* @__PURE__ */ new Set([
|
|
5235
|
+
"Checkout",
|
|
5236
|
+
"Address Comments",
|
|
5237
|
+
"Address Comments (batch)",
|
|
5238
|
+
"Address Comments (auto)"
|
|
5239
|
+
]);
|
|
5224
5240
|
var azureDevopsPrActions = prActions.filter(
|
|
5225
5241
|
({ label: label2 }) => SUPPORTED.has(label2)
|
|
5226
5242
|
);
|
|
@@ -5233,6 +5249,11 @@ function isAllowedAzureDevopsPrArgs(args) {
|
|
|
5233
5249
|
);
|
|
5234
5250
|
}
|
|
5235
5251
|
|
|
5252
|
+
// src/commands/prs/azureDevops/azureDevopsRepoUrl.ts
|
|
5253
|
+
function azureDevopsRepoUrl({ org, project, repo }) {
|
|
5254
|
+
return `https://dev.azure.com/${encodeURIComponent(org)}/${encodeURIComponent(project)}/_git/${encodeURIComponent(repo)}`;
|
|
5255
|
+
}
|
|
5256
|
+
|
|
5236
5257
|
// src/commands/sessions/web/fromGithub/findAzureDevopsClone.ts
|
|
5237
5258
|
import { existsSync as existsSync13, readdirSync as readdirSync2 } from "fs";
|
|
5238
5259
|
import { join as join18 } from "path";
|
|
@@ -5281,7 +5302,7 @@ function planAzureDevopsReview(pr, args, baseDir) {
|
|
|
5281
5302
|
return {
|
|
5282
5303
|
ok: false,
|
|
5283
5304
|
status: 404,
|
|
5284
|
-
error: `${pr.org}/${pr.project}/${pr.repo} is not cloned under ${baseDir}`
|
|
5305
|
+
error: `${pr.org}/${pr.project}/${pr.repo} is not cloned under ${baseDir}; clone ${azureDevopsRepoUrl(pr)} there and retry`
|
|
5285
5306
|
};
|
|
5286
5307
|
return { ok: true, cwd, assistArgs: [...args, pr.id] };
|
|
5287
5308
|
}
|
|
@@ -5399,8 +5420,16 @@ function planGithubReview(body, baseDir) {
|
|
|
5399
5420
|
// src/commands/sessions/web/fromGithub/planPrReview.ts
|
|
5400
5421
|
function planPrReview(body, baseDir) {
|
|
5401
5422
|
const { url, args } = body ?? {};
|
|
5402
|
-
const
|
|
5403
|
-
|
|
5423
|
+
const trimmed = typeof url === "string" ? url.trim() : "";
|
|
5424
|
+
const azurePr = parseAzureDevopsPrUrl(trimmed);
|
|
5425
|
+
if (azurePr) return planAzureDevopsReview(azurePr, args, baseDir);
|
|
5426
|
+
if (isAzureDevopsUrl(trimmed))
|
|
5427
|
+
return {
|
|
5428
|
+
ok: false,
|
|
5429
|
+
status: 400,
|
|
5430
|
+
error: `Not an Azure DevOps PR URL: ${trimmed} (expected https://dev.azure.com/<org>/<project>/_git/<repo>/pullrequest/<id>)`
|
|
5431
|
+
};
|
|
5432
|
+
return planGithubReview(body, baseDir);
|
|
5404
5433
|
}
|
|
5405
5434
|
|
|
5406
5435
|
// src/commands/sessions/web/fromGithub/reviewFromGithub.ts
|
|
@@ -17072,12 +17101,12 @@ function buildPayload(sessionId, status2, source, claudeSessionId) {
|
|
|
17072
17101
|
return payload;
|
|
17073
17102
|
}
|
|
17074
17103
|
async function deliver(sessionId, status2, payload, attempts) {
|
|
17075
|
-
for (let
|
|
17104
|
+
for (let attempt2 = 1; attempt2 <= attempts; attempt2++) {
|
|
17076
17105
|
try {
|
|
17077
17106
|
await sendToDaemonAwaitAck(payload);
|
|
17078
17107
|
return;
|
|
17079
17108
|
} catch (error) {
|
|
17080
|
-
if (
|
|
17109
|
+
if (attempt2 < attempts) {
|
|
17081
17110
|
await sleep(RETRY_DELAY_MS2);
|
|
17082
17111
|
continue;
|
|
17083
17112
|
}
|
|
@@ -19590,129 +19619,39 @@ function stripEnvPrefix(parts) {
|
|
|
19590
19619
|
return i > 0 ? parts.slice(i) : parts;
|
|
19591
19620
|
}
|
|
19592
19621
|
|
|
19593
|
-
// src/shared/extractGhApiMethod.ts
|
|
19594
|
-
function extractGhApiMethod(args) {
|
|
19595
|
-
for (let i = 0; i < args.length; i++) {
|
|
19596
|
-
const arg = args[i];
|
|
19597
|
-
if (arg.startsWith("--method=")) return arg.slice("--method=".length);
|
|
19598
|
-
if (arg.startsWith("-X=")) return arg.slice("-X=".length);
|
|
19599
|
-
if (arg.startsWith("-X") && arg.length > 2) return arg.slice(2);
|
|
19600
|
-
if ((arg === "--method" || arg === "-X") && i + 1 < args.length) {
|
|
19601
|
-
return args[i + 1];
|
|
19602
|
-
}
|
|
19603
|
-
}
|
|
19604
|
-
return void 0;
|
|
19605
|
-
}
|
|
19606
|
-
|
|
19607
|
-
// src/shared/tokenize.ts
|
|
19608
|
-
function tokenize(command) {
|
|
19609
|
-
const tokens = [];
|
|
19610
|
-
let current = "";
|
|
19611
|
-
let inSingle = false;
|
|
19612
|
-
let inDouble = false;
|
|
19613
|
-
for (let i = 0; i < command.length; i++) {
|
|
19614
|
-
const ch = command[i];
|
|
19615
|
-
if (ch === "'" && !inDouble) {
|
|
19616
|
-
inSingle = !inSingle;
|
|
19617
|
-
current += ch;
|
|
19618
|
-
} else if (ch === '"' && !inSingle) {
|
|
19619
|
-
inDouble = !inDouble;
|
|
19620
|
-
current += ch;
|
|
19621
|
-
} else if (ch === "\\" && inDouble && i + 1 < command.length) {
|
|
19622
|
-
current += ch + command[++i];
|
|
19623
|
-
} else if (/\s/.test(ch) && !inSingle && !inDouble) {
|
|
19624
|
-
if (current) {
|
|
19625
|
-
tokens.push(current);
|
|
19626
|
-
current = "";
|
|
19627
|
-
}
|
|
19628
|
-
} else {
|
|
19629
|
-
current += ch;
|
|
19630
|
-
}
|
|
19631
|
-
}
|
|
19632
|
-
if (current) tokens.push(current);
|
|
19633
|
-
return tokens;
|
|
19634
|
-
}
|
|
19635
|
-
|
|
19636
19622
|
// src/commands/cliHook/isGhGraphqlIssueMutation.ts
|
|
19637
19623
|
import { readFileSync as readFileSync27 } from "fs";
|
|
19638
19624
|
var ISSUE_MUTATION = /\bmutation\b[\s\S]*(?:issue|comment|label|assign|reaction|milestone)/i;
|
|
19639
|
-
var
|
|
19640
|
-
function isGhGraphqlIssueMutation(
|
|
19641
|
-
if (!
|
|
19642
|
-
|
|
19643
|
-
|
|
19625
|
+
var FILE_REFERENCE = /(?:=@|--input[\s=]+)["']?([^\s"';&|)]+)/g;
|
|
19626
|
+
function isGhGraphqlIssueMutation(command) {
|
|
19627
|
+
if (!command.includes("graphql")) return false;
|
|
19628
|
+
if (ISSUE_MUTATION.test(command)) return true;
|
|
19629
|
+
return [...command.matchAll(FILE_REFERENCE)].some(
|
|
19630
|
+
(m) => ISSUE_MUTATION.test(readOrEmpty(m[1]))
|
|
19644
19631
|
);
|
|
19645
19632
|
}
|
|
19646
|
-
function
|
|
19647
|
-
const sources = [];
|
|
19648
|
-
for (let i = 0; i < args.length; i++) {
|
|
19649
|
-
const value = flagValue(args, i);
|
|
19650
|
-
if (value === void 0) continue;
|
|
19651
|
-
if (args[i] === "--input") sources.push(`@${value}`);
|
|
19652
|
-
const query = /^query=([\s\S]*)$/.exec(value);
|
|
19653
|
-
if (query) sources.push(query[1]);
|
|
19654
|
-
}
|
|
19655
|
-
return sources;
|
|
19656
|
-
}
|
|
19657
|
-
function flagValue(args, i) {
|
|
19658
|
-
const arg = args[i];
|
|
19659
|
-
if (arg === "--input") return unquote(args[i + 1] ?? "");
|
|
19660
|
-
for (const flag of FIELD_FLAGS) {
|
|
19661
|
-
if (arg === flag) return unquote(args[i + 1] ?? "");
|
|
19662
|
-
if (arg.startsWith(`${flag}=`)) return unquote(arg.slice(flag.length + 1));
|
|
19663
|
-
if (flag.length === 2 && arg.length > 2 && arg.startsWith(flag))
|
|
19664
|
-
return unquote(arg.slice(2));
|
|
19665
|
-
}
|
|
19666
|
-
return void 0;
|
|
19667
|
-
}
|
|
19668
|
-
function readSourceOrCommandText(source, command) {
|
|
19669
|
-
if (!source.startsWith("@")) return source;
|
|
19670
|
-
const path108 = source.slice(1);
|
|
19671
|
-
if (path108 === "-") return command;
|
|
19633
|
+
function readOrEmpty(path108) {
|
|
19672
19634
|
try {
|
|
19673
19635
|
return readFileSync27(path108, "utf8");
|
|
19674
19636
|
} catch {
|
|
19675
|
-
return
|
|
19637
|
+
return "";
|
|
19676
19638
|
}
|
|
19677
19639
|
}
|
|
19678
|
-
function unquote(value) {
|
|
19679
|
-
return value.replace(/['"]/g, "");
|
|
19680
|
-
}
|
|
19681
19640
|
|
|
19682
19641
|
// src/commands/cliHook/isGhIssueApiWrite.ts
|
|
19683
19642
|
var WRITE_METHODS = /* @__PURE__ */ new Set(["POST", "PATCH", "PUT", "DELETE"]);
|
|
19684
|
-
var
|
|
19685
|
-
var
|
|
19686
|
-
var ISSUE_ENDPOINT = /
|
|
19643
|
+
var METHOD = /(?:-X|--method)[\s=]*["']?([A-Za-z]+)/g;
|
|
19644
|
+
var BODY_FLAG = /\s(?:-[fF]|--field|--raw-field|--input)/;
|
|
19645
|
+
var ISSUE_ENDPOINT = /repos\/[^/\s"'`]+\/[^/\s"'`]+\/issues(?:$|[/?\s"'`)])/;
|
|
19687
19646
|
function isGhIssueApiWrite(command) {
|
|
19688
|
-
|
|
19689
|
-
|
|
19690
|
-
|
|
19691
|
-
const args = argsUntilNextCommand(tokens.slice(i + 2));
|
|
19692
|
-
if (targetsIssueEndpoint(args) && isWrite(args)) return true;
|
|
19693
|
-
if (isGhGraphqlIssueMutation(args, command)) return true;
|
|
19694
|
-
}
|
|
19695
|
-
return false;
|
|
19696
|
-
}
|
|
19697
|
-
function argsUntilNextCommand(tokens) {
|
|
19698
|
-
const end = tokens.findIndex((token) => COMMAND_OPERATORS.has(token));
|
|
19699
|
-
return end === -1 ? tokens : tokens.slice(0, end);
|
|
19700
|
-
}
|
|
19701
|
-
function targetsIssueEndpoint(args) {
|
|
19702
|
-
return args.some((arg) => ISSUE_ENDPOINT.test(arg));
|
|
19703
|
-
}
|
|
19704
|
-
function isWrite(args) {
|
|
19705
|
-
const method = extractGhApiMethod(args);
|
|
19706
|
-
if (method) return WRITE_METHODS.has(unquote2(method).toUpperCase());
|
|
19707
|
-
return args.some(isBodyFlag);
|
|
19708
|
-
}
|
|
19709
|
-
function isBodyFlag(arg) {
|
|
19710
|
-
return BODY_FLAGS.some(
|
|
19711
|
-
(flag) => arg === flag || arg.startsWith(`${flag}=`) || flag.length === 2 && arg.length > 2 && arg.startsWith(flag)
|
|
19712
|
-
);
|
|
19647
|
+
if (!/gh\s+api/.test(command)) return false;
|
|
19648
|
+
if (ISSUE_ENDPOINT.test(command) && isWrite(command)) return true;
|
|
19649
|
+
return isGhGraphqlIssueMutation(command);
|
|
19713
19650
|
}
|
|
19714
|
-
function
|
|
19715
|
-
|
|
19651
|
+
function isWrite(command) {
|
|
19652
|
+
const methods = [...command.matchAll(METHOD)].map((m) => m[1].toUpperCase());
|
|
19653
|
+
if (methods.length > 0) return methods.some((m) => WRITE_METHODS.has(m));
|
|
19654
|
+
return BODY_FLAG.test(command);
|
|
19716
19655
|
}
|
|
19717
19656
|
|
|
19718
19657
|
// src/commands/cliHook/builtinDenyRules.ts
|
|
@@ -19750,30 +19689,18 @@ var PATTERN_DENIES = [
|
|
|
19750
19689
|
var GH_ISSUE_API_MESSAGE = "Do not write to GitHub issues with 'gh api' (REST issue endpoints or GraphQL issue mutations) \u2014 it bypasses the content validation and the approval pane that every outward-facing issue write goes through. Use 'assist github issue create --title <title> --body <body>' to open an issue, 'assist github issue edit <number>' to rework one's body, 'assist github issue comment <number> --body <body>' to post a comment, or 'assist github issue edit-comment <comment-id> --body <body>' to amend a comment that is already posted. Each validates the content and gates it on the user's approval before anything reaches GitHub; run the command's --help for how to compose it.";
|
|
19751
19690
|
var BRANCH_CREATION_MESSAGE = "Do not create branches with raw git. Use the /branch command, or 'assist branch <slug> [--jira <KEY>]' \u2014 it branches off the fresh remote default and enforces the team naming convention.";
|
|
19752
19691
|
var CLOSE_WITH_COMMENT_MESSAGE = "Do not post a comment through 'gh issue close', 'gh issue reopen' or 'gh pr close' with --comment/-c \u2014 it goes to GitHub without the approval pane. Post the comment first with 'assist github issue comment <number> --body <body> [-R <owner>/<repo>]', which validates it and gates it on the user's approval, then run the same close/reopen without --comment.";
|
|
19753
|
-
var CLOSE_WITH_COMMENT_REGEX = /
|
|
19754
|
-
var COMMAND_BOUNDARY = String.raw`(?<=(?:^|[;&|(\n])\s*)`;
|
|
19692
|
+
var CLOSE_WITH_COMMENT_REGEX = /gh (?:issue (?:close|reopen)|pr close)[^;&|]*? (?:--comment|-c)/;
|
|
19755
19693
|
var BRANCH_CREATION_REGEXES = [
|
|
19756
|
-
|
|
19757
|
-
|
|
19758
|
-
)
|
|
19759
|
-
new RegExp(
|
|
19760
|
-
COMMAND_BOUNDARY + String.raw`git\s+switch\s+(?:-[cC]|--create)(?=\s|$)`
|
|
19761
|
-
),
|
|
19762
|
-
new RegExp(COMMAND_BOUNDARY + String.raw`git\s+branch\s+(?!-)\S`)
|
|
19694
|
+
/git (?:checkout|co) -[bB]/,
|
|
19695
|
+
/git switch (?:-[cC]|--create)/,
|
|
19696
|
+
/git branch [^-\s;&|)]/
|
|
19763
19697
|
];
|
|
19764
|
-
function anywhereTokenSequenceRegex(pattern2) {
|
|
19765
|
-
const tokens = pattern2.trim().split(/\s+/).map((token) => token.replace(/[.*+?^${}()|[\]\\]/g, String.raw`\$&`)).join(String.raw`\s+`);
|
|
19766
|
-
return new RegExp(`(?<=^|\\s)${tokens}(?=\\s|$)`);
|
|
19767
|
-
}
|
|
19768
19698
|
var builtinDenyRules = [
|
|
19769
|
-
...PATTERN_DENIES.map((rule) => {
|
|
19770
|
-
|
|
19771
|
-
|
|
19772
|
-
|
|
19773
|
-
|
|
19774
|
-
enabled: rule.enabled
|
|
19775
|
-
};
|
|
19776
|
-
}),
|
|
19699
|
+
...PATTERN_DENIES.map((rule) => ({
|
|
19700
|
+
message: rule.message,
|
|
19701
|
+
matches: (text17) => text17.includes(rule.pattern),
|
|
19702
|
+
enabled: rule.enabled
|
|
19703
|
+
})),
|
|
19777
19704
|
...BRANCH_CREATION_REGEXES.map((regex) => ({
|
|
19778
19705
|
message: BRANCH_CREATION_MESSAGE,
|
|
19779
19706
|
matches: (text17) => regex.test(text17)
|
|
@@ -19788,61 +19715,14 @@ var builtinDenyRules = [
|
|
|
19788
19715
|
}
|
|
19789
19716
|
];
|
|
19790
19717
|
|
|
19791
|
-
// src/commands/cliHook/extractNestedCommands.ts
|
|
19792
|
-
function extractNestedCommands(command) {
|
|
19793
|
-
const bodies = [];
|
|
19794
|
-
scanUnquoted(command, 0, (i, inDouble) => {
|
|
19795
|
-
const opener = openerLength(command, i, inDouble);
|
|
19796
|
-
if (opener === void 0) return void 0;
|
|
19797
|
-
const start2 = i + opener;
|
|
19798
|
-
const end = command[i] === "`" ? findClosingBacktick(command, start2) : findClosingParen(command, start2);
|
|
19799
|
-
const body = command.slice(start2, end);
|
|
19800
|
-
bodies.push(body, ...extractNestedCommands(body));
|
|
19801
|
-
return end;
|
|
19802
|
-
});
|
|
19803
|
-
return bodies;
|
|
19804
|
-
}
|
|
19805
|
-
function openerLength(command, i, inDouble) {
|
|
19806
|
-
if (command[i] === "$" && command[i + 1] === "(") return 2;
|
|
19807
|
-
if (command[i] === "`") return 1;
|
|
19808
|
-
if (command[i] === "(" && !inDouble) return 1;
|
|
19809
|
-
return void 0;
|
|
19810
|
-
}
|
|
19811
|
-
function findClosingBacktick(command, start2) {
|
|
19812
|
-
const end = command.indexOf("`", start2);
|
|
19813
|
-
return end === -1 ? command.length : end;
|
|
19814
|
-
}
|
|
19815
|
-
function findClosingParen(command, start2) {
|
|
19816
|
-
let depth = 1;
|
|
19817
|
-
let close = command.length;
|
|
19818
|
-
scanUnquoted(command, start2, (i, inDouble) => {
|
|
19819
|
-
if (inDouble) return void 0;
|
|
19820
|
-
if (command[i] === "(") depth++;
|
|
19821
|
-
else if (command[i] === ")" && --depth === 0) {
|
|
19822
|
-
close = i;
|
|
19823
|
-
return command.length;
|
|
19824
|
-
}
|
|
19825
|
-
return void 0;
|
|
19826
|
-
});
|
|
19827
|
-
return close;
|
|
19828
|
-
}
|
|
19829
|
-
function scanUnquoted(command, start2, visit2) {
|
|
19830
|
-
let inSingle = false;
|
|
19831
|
-
let inDouble = false;
|
|
19832
|
-
for (let i = start2; i < command.length; i++) {
|
|
19833
|
-
const ch = command[i];
|
|
19834
|
-
if (ch === "\\" && !inSingle) i++;
|
|
19835
|
-
else if (ch === "'" && !inDouble) inSingle = !inSingle;
|
|
19836
|
-
else if (ch === '"' && !inSingle) inDouble = !inDouble;
|
|
19837
|
-
else if (!inSingle) i = visit2(i, inDouble) ?? i;
|
|
19838
|
-
}
|
|
19839
|
-
}
|
|
19840
|
-
|
|
19841
19718
|
// src/commands/cliHook/findBuiltinDeny.ts
|
|
19719
|
+
function normaliseWhitespace(text17) {
|
|
19720
|
+
return text17.replace(/\\\n/g, " ").replace(/\s+/g, " ");
|
|
19721
|
+
}
|
|
19842
19722
|
function matchBuiltinDeny(text17) {
|
|
19843
|
-
const
|
|
19723
|
+
const normalised = normaliseWhitespace(text17);
|
|
19844
19724
|
return builtinDenyRules.find(
|
|
19845
|
-
(rule) =>
|
|
19725
|
+
(rule) => rule.matches(normalised) && (rule.enabled?.() ?? true)
|
|
19846
19726
|
);
|
|
19847
19727
|
}
|
|
19848
19728
|
function toDecision(rule) {
|
|
@@ -20001,10 +19881,53 @@ function configuresReleases(command) {
|
|
|
20001
19881
|
return CONFIGURE_RE.test(command);
|
|
20002
19882
|
}
|
|
20003
19883
|
|
|
19884
|
+
// src/shared/tokenize.ts
|
|
19885
|
+
function tokenize(command) {
|
|
19886
|
+
const tokens = [];
|
|
19887
|
+
let current = "";
|
|
19888
|
+
let inSingle = false;
|
|
19889
|
+
let inDouble = false;
|
|
19890
|
+
for (let i = 0; i < command.length; i++) {
|
|
19891
|
+
const ch = command[i];
|
|
19892
|
+
if (ch === "'" && !inDouble) {
|
|
19893
|
+
inSingle = !inSingle;
|
|
19894
|
+
current += ch;
|
|
19895
|
+
} else if (ch === '"' && !inSingle) {
|
|
19896
|
+
inDouble = !inDouble;
|
|
19897
|
+
current += ch;
|
|
19898
|
+
} else if (ch === "\\" && inDouble && i + 1 < command.length) {
|
|
19899
|
+
current += ch + command[++i];
|
|
19900
|
+
} else if (/\s/.test(ch) && !inSingle && !inDouble) {
|
|
19901
|
+
if (current) {
|
|
19902
|
+
tokens.push(current);
|
|
19903
|
+
current = "";
|
|
19904
|
+
}
|
|
19905
|
+
} else {
|
|
19906
|
+
current += ch;
|
|
19907
|
+
}
|
|
19908
|
+
}
|
|
19909
|
+
if (current) tokens.push(current);
|
|
19910
|
+
return tokens;
|
|
19911
|
+
}
|
|
19912
|
+
|
|
19913
|
+
// src/shared/extractGhApiMethod.ts
|
|
19914
|
+
function extractGhApiMethod(args) {
|
|
19915
|
+
for (let i = 0; i < args.length; i++) {
|
|
19916
|
+
const arg = args[i];
|
|
19917
|
+
if (arg.startsWith("--method=")) return arg.slice("--method=".length);
|
|
19918
|
+
if (arg.startsWith("-X=")) return arg.slice("-X=".length);
|
|
19919
|
+
if (arg.startsWith("-X") && arg.length > 2) return arg.slice(2);
|
|
19920
|
+
if ((arg === "--method" || arg === "-X") && i + 1 < args.length) {
|
|
19921
|
+
return args[i + 1];
|
|
19922
|
+
}
|
|
19923
|
+
}
|
|
19924
|
+
return void 0;
|
|
19925
|
+
}
|
|
19926
|
+
|
|
20004
19927
|
// src/shared/isGhApiRead.ts
|
|
20005
19928
|
var READ_METHODS = /* @__PURE__ */ new Set(["GET", "HEAD"]);
|
|
20006
|
-
var
|
|
20007
|
-
var
|
|
19929
|
+
var BODY_FLAGS = /* @__PURE__ */ new Set(["-f", "-F", "--field", "--raw-field", "--input"]);
|
|
19930
|
+
var FIELD_FLAGS = /* @__PURE__ */ new Set(["-f", "--field", "-F"]);
|
|
20008
19931
|
function isGhApiRead(command) {
|
|
20009
19932
|
const tokens = tokenize(command);
|
|
20010
19933
|
if (tokens.length < 2 || tokens[0] !== "gh" || tokens[1] !== "api") {
|
|
@@ -20016,7 +19939,7 @@ function isGhApiRead(command) {
|
|
|
20016
19939
|
}
|
|
20017
19940
|
const method = extractGhApiMethod(args);
|
|
20018
19941
|
if (method) return READ_METHODS.has(method.toUpperCase());
|
|
20019
|
-
if (args.some((t) =>
|
|
19942
|
+
if (args.some((t) => BODY_FLAGS.has(t))) return false;
|
|
20020
19943
|
return true;
|
|
20021
19944
|
}
|
|
20022
19945
|
function isGraphqlRead(args) {
|
|
@@ -20031,7 +19954,7 @@ function isGraphqlRead(args) {
|
|
|
20031
19954
|
}
|
|
20032
19955
|
function extractGraphqlQuery(args) {
|
|
20033
19956
|
for (let i = 0; i < args.length; i++) {
|
|
20034
|
-
if (
|
|
19957
|
+
if (FIELD_FLAGS.has(args[i]) && i + 1 < args.length) {
|
|
20035
19958
|
const match = args[i + 1].match(/^query=(.*)/s);
|
|
20036
19959
|
if (match) return match[1];
|
|
20037
19960
|
}
|
|
@@ -20319,9 +20242,11 @@ function resolvePermission(toolName, parts) {
|
|
|
20319
20242
|
|
|
20320
20243
|
// src/commands/cliHook/decideCommand.ts
|
|
20321
20244
|
function decideCommand(toolName, rawCommand) {
|
|
20245
|
+
const builtinDeny = findBuiltinDenyRaw(rawCommand);
|
|
20246
|
+
if (builtinDeny) return builtinDeny;
|
|
20322
20247
|
const result = splitCompound(rawCommand);
|
|
20323
20248
|
if (result.ok) return resolvePermission(toolName, result.parts);
|
|
20324
|
-
return findRestrictedPathDenyRaw(rawCommand) ??
|
|
20249
|
+
return findRestrictedPathDenyRaw(rawCommand) ?? findTruncatedReadDenyRaw(rawCommand) ?? findDeny(toolName, [rawCommand]);
|
|
20325
20250
|
}
|
|
20326
20251
|
|
|
20327
20252
|
// src/commands/cliHook/logDeniedToolCall.ts
|
|
@@ -20442,10 +20367,10 @@ function reportDeny(toolName, parts) {
|
|
|
20442
20367
|
}
|
|
20443
20368
|
function cliHookCheck(command, toolName = "Bash") {
|
|
20444
20369
|
const trimmed = command.trim();
|
|
20370
|
+
if (reportDecision(findBuiltinDenyRaw(trimmed))) return;
|
|
20445
20371
|
const result = splitCompound(trimmed);
|
|
20446
20372
|
if (!result.ok) {
|
|
20447
20373
|
if (reportDecision(findRestrictedPathDenyRaw(trimmed))) return;
|
|
20448
|
-
if (reportDecision(findBuiltinDenyRaw(trimmed))) return;
|
|
20449
20374
|
if (reportDecision(findTruncatedReadDenyRaw(trimmed))) return;
|
|
20450
20375
|
if (reportDeny(toolName, [trimmed])) return;
|
|
20451
20376
|
console.log(`not approved (${result.error})`);
|
|
@@ -28004,6 +27929,31 @@ import chalk171 from "chalk";
|
|
|
28004
27929
|
|
|
28005
27930
|
// src/commands/review/azCliProblem.ts
|
|
28006
27931
|
import { execFileSync as execFileSync18 } from "child_process";
|
|
27932
|
+
|
|
27933
|
+
// src/commands/review/azFailureProblem.ts
|
|
27934
|
+
var azProblems = {
|
|
27935
|
+
missing: "Azure CLI (az) not found; install it (https://aka.ms/azure-cli) and run az login.",
|
|
27936
|
+
extension: "The azure-devops az extension is not installed; run az extension add --name azure-devops.",
|
|
27937
|
+
login: "az is not logged in; run az login."
|
|
27938
|
+
};
|
|
27939
|
+
var EXTENSION_PATTERNS = [
|
|
27940
|
+
/requires the extension azure-devops/i,
|
|
27941
|
+
/'(?:repos|devops)' is misspelled or not recognized/i,
|
|
27942
|
+
/'(?:repos|devops)' is not in the 'az' command group/i
|
|
27943
|
+
];
|
|
27944
|
+
var LOGIN_PATTERNS = [/\baz login\b/i, /you need to run the login command/i];
|
|
27945
|
+
function azFailureProblem(error) {
|
|
27946
|
+
if (error?.code === "ENOENT")
|
|
27947
|
+
return azProblems.missing;
|
|
27948
|
+
const stderr = error?.stderr?.toString() ?? "";
|
|
27949
|
+
if (EXTENSION_PATTERNS.some((pattern2) => pattern2.test(stderr)))
|
|
27950
|
+
return azProblems.extension;
|
|
27951
|
+
if (LOGIN_PATTERNS.some((pattern2) => pattern2.test(stderr)))
|
|
27952
|
+
return azProblems.login;
|
|
27953
|
+
return null;
|
|
27954
|
+
}
|
|
27955
|
+
|
|
27956
|
+
// src/commands/review/azCliProblem.ts
|
|
28007
27957
|
function runAz(args) {
|
|
28008
27958
|
try {
|
|
28009
27959
|
execFileSync18("az", args, { stdio: "ignore" });
|
|
@@ -28012,13 +27962,13 @@ function runAz(args) {
|
|
|
28012
27962
|
return error.code === "ENOENT" ? "missing" : "failed";
|
|
28013
27963
|
}
|
|
28014
27964
|
}
|
|
28015
|
-
function azCliProblem() {
|
|
28016
|
-
|
|
28017
|
-
|
|
27965
|
+
function azCliProblem(error) {
|
|
27966
|
+
const fromFailure = error === void 0 ? null : azFailureProblem(error);
|
|
27967
|
+
if (fromFailure) return fromFailure;
|
|
27968
|
+
if (runAz(["version"]) === "missing") return azProblems.missing;
|
|
28018
27969
|
if (runAz(["extension", "show", "--name", "azure-devops"]) !== "ok")
|
|
28019
|
-
return
|
|
28020
|
-
if (runAz(["account", "show"]) !== "ok")
|
|
28021
|
-
return "az is not logged in; run az login.";
|
|
27970
|
+
return azProblems.extension;
|
|
27971
|
+
if (runAz(["account", "show"]) !== "ok") return azProblems.login;
|
|
28022
27972
|
return null;
|
|
28023
27973
|
}
|
|
28024
27974
|
|
|
@@ -29993,11 +29943,260 @@ function commentsCachePath(org, repo, prNumber) {
|
|
|
29993
29943
|
);
|
|
29994
29944
|
}
|
|
29995
29945
|
|
|
29996
|
-
// src/commands/prs/
|
|
29946
|
+
// src/commands/prs/listComments/updateCommentsCache.ts
|
|
29947
|
+
import { mkdirSync as mkdirSync22, writeFileSync as writeFileSync36 } from "fs";
|
|
29948
|
+
import { dirname as dirname36 } from "path";
|
|
29949
|
+
import { stringify as stringify3 } from "yaml";
|
|
29950
|
+
|
|
29951
|
+
// src/commands/prs/loadCommentsCache.ts
|
|
29952
|
+
import { existsSync as existsSync64, readFileSync as readFileSync45, unlinkSync as unlinkSync13 } from "fs";
|
|
29953
|
+
import { parse as parse3 } from "yaml";
|
|
29954
|
+
function loadCommentsCache(org, repo, prNumber) {
|
|
29955
|
+
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
29956
|
+
if (!existsSync64(cachePath)) {
|
|
29957
|
+
return null;
|
|
29958
|
+
}
|
|
29959
|
+
const content = readFileSync45(cachePath, "utf8");
|
|
29960
|
+
return parse3(content);
|
|
29961
|
+
}
|
|
29962
|
+
function deleteCommentsCache(org, repo, prNumber) {
|
|
29963
|
+
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
29964
|
+
if (existsSync64(cachePath)) {
|
|
29965
|
+
unlinkSync13(cachePath);
|
|
29966
|
+
console.log("No more unresolved line comments. Cache dropped.");
|
|
29967
|
+
}
|
|
29968
|
+
}
|
|
29969
|
+
|
|
29970
|
+
// src/commands/prs/removeStaleCommentsCaches.ts
|
|
29971
|
+
import { readdirSync as readdirSync13, unlinkSync as unlinkSync14 } from "fs";
|
|
29972
|
+
import { join as join80 } from "path";
|
|
29973
|
+
var STALE_PATTERN = /^pr-\d+-comments\.yaml$/;
|
|
29974
|
+
function removeStaleCommentsCaches(cwd = process.cwd()) {
|
|
29975
|
+
const dir = join80(cwd, ".assist");
|
|
29976
|
+
let entries;
|
|
29977
|
+
try {
|
|
29978
|
+
entries = readdirSync13(dir);
|
|
29979
|
+
} catch {
|
|
29980
|
+
return;
|
|
29981
|
+
}
|
|
29982
|
+
for (const entry of entries.filter((e) => STALE_PATTERN.test(e))) {
|
|
29983
|
+
unlinkSync14(join80(dir, entry));
|
|
29984
|
+
}
|
|
29985
|
+
}
|
|
29986
|
+
|
|
29987
|
+
// src/commands/prs/listComments/updateCommentsCache.ts
|
|
29988
|
+
function writeCommentsCache(org, repo, prNumber, comments3) {
|
|
29989
|
+
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
29990
|
+
mkdirSync22(dirname36(cachePath), { recursive: true });
|
|
29991
|
+
const cacheData = {
|
|
29992
|
+
prNumber,
|
|
29993
|
+
fetchedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
29994
|
+
comments: comments3
|
|
29995
|
+
};
|
|
29996
|
+
writeFileSync36(cachePath, stringify3(cacheData));
|
|
29997
|
+
}
|
|
29998
|
+
function updateCommentsCache(org, repo, prNumber, comments3) {
|
|
29999
|
+
removeStaleCommentsCaches();
|
|
30000
|
+
if (comments3.some((c) => c.type === "line")) {
|
|
30001
|
+
writeCommentsCache(org, repo, prNumber, comments3);
|
|
30002
|
+
} else {
|
|
30003
|
+
deleteCommentsCache(org, repo, prNumber);
|
|
30004
|
+
}
|
|
30005
|
+
}
|
|
30006
|
+
|
|
30007
|
+
// src/commands/prs/azureDevops/azureDevopsCacheRepo.ts
|
|
30008
|
+
function azureDevopsCacheRepo({ org, project, repo }) {
|
|
30009
|
+
return { org, repo: `${project}/${repo}` };
|
|
30010
|
+
}
|
|
30011
|
+
|
|
30012
|
+
// src/commands/prs/azureDevops/azureDevopsThreadRequests.ts
|
|
30013
|
+
function prRoute(pr) {
|
|
30014
|
+
return {
|
|
30015
|
+
project: pr.project,
|
|
30016
|
+
repositoryId: pr.repo,
|
|
30017
|
+
pullRequestId: pr.prId
|
|
30018
|
+
};
|
|
30019
|
+
}
|
|
30020
|
+
var azureDevopsThreadRequests = {
|
|
30021
|
+
list(pr) {
|
|
30022
|
+
return {
|
|
30023
|
+
org: pr.org,
|
|
30024
|
+
resource: "pullRequestThreads",
|
|
30025
|
+
routeParameters: prRoute(pr)
|
|
30026
|
+
};
|
|
30027
|
+
},
|
|
30028
|
+
reply(pr, threadId, content) {
|
|
30029
|
+
return {
|
|
30030
|
+
org: pr.org,
|
|
30031
|
+
resource: "pullRequestThreadComments",
|
|
30032
|
+
routeParameters: { ...prRoute(pr), threadId },
|
|
30033
|
+
method: "POST",
|
|
30034
|
+
body: { content, commentType: 1 }
|
|
30035
|
+
};
|
|
30036
|
+
},
|
|
30037
|
+
status(pr, threadId, status2) {
|
|
30038
|
+
return {
|
|
30039
|
+
org: pr.org,
|
|
30040
|
+
resource: "pullRequestThreads",
|
|
30041
|
+
routeParameters: { ...prRoute(pr), threadId },
|
|
30042
|
+
method: "PATCH",
|
|
30043
|
+
body: { status: status2 }
|
|
30044
|
+
};
|
|
30045
|
+
}
|
|
30046
|
+
};
|
|
30047
|
+
|
|
30048
|
+
// src/commands/prs/azureDevops/currentAzureDevopsPr.ts
|
|
29997
30049
|
import { execFileSync as execFileSync20 } from "child_process";
|
|
30050
|
+
function findPrForBranch(repo, branch2) {
|
|
30051
|
+
const stdout = execFileSync20(
|
|
30052
|
+
"az",
|
|
30053
|
+
[
|
|
30054
|
+
"repos",
|
|
30055
|
+
"pr",
|
|
30056
|
+
"list",
|
|
30057
|
+
"--source-branch",
|
|
30058
|
+
branch2,
|
|
30059
|
+
"--status",
|
|
30060
|
+
"active",
|
|
30061
|
+
"--org",
|
|
30062
|
+
`https://dev.azure.com/${repo.org}`,
|
|
30063
|
+
"--project",
|
|
30064
|
+
repo.project,
|
|
30065
|
+
"--repository",
|
|
30066
|
+
repo.repo,
|
|
30067
|
+
"--query",
|
|
30068
|
+
"[0].pullRequestId",
|
|
30069
|
+
"--only-show-errors",
|
|
30070
|
+
"-o",
|
|
30071
|
+
"tsv"
|
|
30072
|
+
],
|
|
30073
|
+
{ encoding: "utf8", stdio: ["ignore", "pipe", "pipe"], windowsHide: true }
|
|
30074
|
+
);
|
|
30075
|
+
return Number.parseInt(stdout.trim(), 10);
|
|
30076
|
+
}
|
|
30077
|
+
function currentAzureDevopsPr(repo) {
|
|
30078
|
+
const prId = getPinnedPr() ?? findPrForBranch(repo, getCurrentBranch2());
|
|
30079
|
+
if (Number.isNaN(prId)) {
|
|
30080
|
+
console.error("Error: No pull request found for the current branch.");
|
|
30081
|
+
process.exit(1);
|
|
30082
|
+
}
|
|
30083
|
+
return { ...repo, prId };
|
|
30084
|
+
}
|
|
30085
|
+
|
|
30086
|
+
// src/commands/prs/azureDevops/failAzureDevops.ts
|
|
30087
|
+
function errorOutput(error) {
|
|
30088
|
+
const stderr = error.stderr?.toString();
|
|
30089
|
+
if (stderr?.trim()) return stderr.trim();
|
|
30090
|
+
return error instanceof Error ? error.message : String(error);
|
|
30091
|
+
}
|
|
30092
|
+
function failAzureDevops(error) {
|
|
30093
|
+
console.error(`Error: ${azCliProblem(error) ?? errorOutput(error)}`);
|
|
30094
|
+
process.exit(1);
|
|
30095
|
+
}
|
|
30096
|
+
|
|
30097
|
+
// src/commands/prs/azureDevops/invokeAzDevops.ts
|
|
30098
|
+
import { execFileSync as execFileSync21 } from "child_process";
|
|
30099
|
+
import { mkdtempSync as mkdtempSync2, rmSync as rmSync6, writeFileSync as writeFileSync37 } from "fs";
|
|
30100
|
+
import { tmpdir as tmpdir6 } from "os";
|
|
30101
|
+
import { join as join81 } from "path";
|
|
30102
|
+
function azDevopsInvokeArgs(request, inFile) {
|
|
30103
|
+
return [
|
|
30104
|
+
"devops",
|
|
30105
|
+
"invoke",
|
|
30106
|
+
"--area",
|
|
30107
|
+
"git",
|
|
30108
|
+
"--resource",
|
|
30109
|
+
request.resource,
|
|
30110
|
+
"--route-parameters",
|
|
30111
|
+
...Object.entries(request.routeParameters).map(
|
|
30112
|
+
([key, value]) => `${key}=${value}`
|
|
30113
|
+
),
|
|
30114
|
+
"--org",
|
|
30115
|
+
`https://dev.azure.com/${request.org}`,
|
|
30116
|
+
"--api-version",
|
|
30117
|
+
"7.1",
|
|
30118
|
+
"--http-method",
|
|
30119
|
+
request.method ?? "GET",
|
|
30120
|
+
...inFile ? ["--in-file", inFile] : [],
|
|
30121
|
+
"--only-show-errors",
|
|
30122
|
+
"-o",
|
|
30123
|
+
"json"
|
|
30124
|
+
];
|
|
30125
|
+
}
|
|
30126
|
+
function runAz2(args) {
|
|
30127
|
+
const stdout = execFileSync21("az", args, {
|
|
30128
|
+
encoding: "utf8",
|
|
30129
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
30130
|
+
windowsHide: true
|
|
30131
|
+
});
|
|
30132
|
+
return stdout.trim() ? JSON.parse(stdout) : null;
|
|
30133
|
+
}
|
|
30134
|
+
function invokeAzDevops(request) {
|
|
30135
|
+
if (request.body === void 0) return runAz2(azDevopsInvokeArgs(request));
|
|
30136
|
+
const dir = mkdtempSync2(join81(tmpdir6(), "assist-az-"));
|
|
30137
|
+
const inFile = join81(dir, "body.json");
|
|
30138
|
+
try {
|
|
30139
|
+
writeFileSync37(inFile, JSON.stringify(request.body));
|
|
30140
|
+
return runAz2(azDevopsInvokeArgs(request, inFile));
|
|
30141
|
+
} finally {
|
|
30142
|
+
rmSync6(dir, { recursive: true, force: true });
|
|
30143
|
+
}
|
|
30144
|
+
}
|
|
30145
|
+
|
|
30146
|
+
// src/commands/prs/azureDevops/mapAzureDevopsThreads.ts
|
|
30147
|
+
var OPEN_STATUSES = /* @__PURE__ */ new Set(["active", "pending", "unknown"]);
|
|
30148
|
+
function isResolved(status2) {
|
|
30149
|
+
return status2 !== void 0 && !OPEN_STATUSES.has(status2);
|
|
30150
|
+
}
|
|
30151
|
+
function threadLine(thread) {
|
|
30152
|
+
const context = thread.threadContext;
|
|
30153
|
+
return context?.rightFileStart?.line ?? context?.leftFileStart?.line ?? null;
|
|
30154
|
+
}
|
|
30155
|
+
function threadPath(thread) {
|
|
30156
|
+
return thread.threadContext?.filePath?.replace(/^[/]/, "") ?? "";
|
|
30157
|
+
}
|
|
30158
|
+
function mapAzureDevopsThreads(threads, prUrl) {
|
|
30159
|
+
return threads.filter((thread) => !thread.isDeleted).flatMap(
|
|
30160
|
+
(thread) => (thread.comments ?? []).filter((c) => !c.isDeleted && c.commentType !== "system" && c.content).map(
|
|
30161
|
+
(c) => ({
|
|
30162
|
+
type: "line",
|
|
30163
|
+
id: thread.id,
|
|
30164
|
+
threadId: String(thread.id),
|
|
30165
|
+
user: c.author?.displayName ?? c.author?.uniqueName ?? "unknown",
|
|
30166
|
+
path: threadPath(thread),
|
|
30167
|
+
line: threadLine(thread),
|
|
30168
|
+
body: c.content ?? "",
|
|
30169
|
+
diff_hunk: "",
|
|
30170
|
+
html_url: `${prUrl}?discussionId=${thread.id}`,
|
|
30171
|
+
resolved: isResolved(thread.status)
|
|
30172
|
+
})
|
|
30173
|
+
)
|
|
30174
|
+
);
|
|
30175
|
+
}
|
|
30176
|
+
|
|
30177
|
+
// src/commands/prs/azureDevops/listAzureDevopsComments.ts
|
|
30178
|
+
function listAzureDevopsComments(repo) {
|
|
30179
|
+
try {
|
|
30180
|
+
const pr = currentAzureDevopsPr(repo);
|
|
30181
|
+
const response = invokeAzDevops(azureDevopsThreadRequests.list(pr));
|
|
30182
|
+
const comments3 = mapAzureDevopsThreads(
|
|
30183
|
+
response?.value ?? [],
|
|
30184
|
+
`${azureDevopsRepoUrl(pr)}/pullrequest/${pr.prId}`
|
|
30185
|
+
);
|
|
30186
|
+
const { org, repo: cacheRepo } = azureDevopsCacheRepo(pr);
|
|
30187
|
+
updateCommentsCache(org, cacheRepo, pr.prId, comments3);
|
|
30188
|
+
const cachePath = comments3.length > 0 ? commentsCachePath(org, cacheRepo, pr.prId) : null;
|
|
30189
|
+
return { comments: comments3, cachePath };
|
|
30190
|
+
} catch (error) {
|
|
30191
|
+
failAzureDevops(error);
|
|
30192
|
+
}
|
|
30193
|
+
}
|
|
30194
|
+
|
|
30195
|
+
// src/commands/prs/fetchThreadIds.ts
|
|
30196
|
+
import { execFileSync as execFileSync22 } from "child_process";
|
|
29998
30197
|
var THREAD_QUERY = `query($owner: String!, $repo: String!, $prNumber: Int!) { repository(owner: $owner, name: $repo) { pullRequest(number: $prNumber) { reviewThreads(first: 100) { nodes { id isResolved comments(first: 100) { nodes { databaseId } } } } } } }`;
|
|
29999
30198
|
function fetchThreadIds(org, repo, prNumber) {
|
|
30000
|
-
const result =
|
|
30199
|
+
const result = execFileSync22(
|
|
30001
30200
|
"gh",
|
|
30002
30201
|
[
|
|
30003
30202
|
"api",
|
|
@@ -30071,67 +30270,6 @@ function fetchLineComments(org, repo, prNumber, threadInfo) {
|
|
|
30071
30270
|
);
|
|
30072
30271
|
}
|
|
30073
30272
|
|
|
30074
|
-
// src/commands/prs/listComments/updateCommentsCache.ts
|
|
30075
|
-
import { mkdirSync as mkdirSync22, writeFileSync as writeFileSync36 } from "fs";
|
|
30076
|
-
import { dirname as dirname36 } from "path";
|
|
30077
|
-
import { stringify as stringify3 } from "yaml";
|
|
30078
|
-
|
|
30079
|
-
// src/commands/prs/loadCommentsCache.ts
|
|
30080
|
-
import { existsSync as existsSync64, readFileSync as readFileSync45, unlinkSync as unlinkSync13 } from "fs";
|
|
30081
|
-
import { parse as parse3 } from "yaml";
|
|
30082
|
-
function loadCommentsCache(org, repo, prNumber) {
|
|
30083
|
-
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
30084
|
-
if (!existsSync64(cachePath)) {
|
|
30085
|
-
return null;
|
|
30086
|
-
}
|
|
30087
|
-
const content = readFileSync45(cachePath, "utf8");
|
|
30088
|
-
return parse3(content);
|
|
30089
|
-
}
|
|
30090
|
-
function deleteCommentsCache(org, repo, prNumber) {
|
|
30091
|
-
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
30092
|
-
if (existsSync64(cachePath)) {
|
|
30093
|
-
unlinkSync13(cachePath);
|
|
30094
|
-
console.log("No more unresolved line comments. Cache dropped.");
|
|
30095
|
-
}
|
|
30096
|
-
}
|
|
30097
|
-
|
|
30098
|
-
// src/commands/prs/removeStaleCommentsCaches.ts
|
|
30099
|
-
import { readdirSync as readdirSync13, unlinkSync as unlinkSync14 } from "fs";
|
|
30100
|
-
import { join as join80 } from "path";
|
|
30101
|
-
var STALE_PATTERN = /^pr-\d+-comments\.yaml$/;
|
|
30102
|
-
function removeStaleCommentsCaches(cwd = process.cwd()) {
|
|
30103
|
-
const dir = join80(cwd, ".assist");
|
|
30104
|
-
let entries;
|
|
30105
|
-
try {
|
|
30106
|
-
entries = readdirSync13(dir);
|
|
30107
|
-
} catch {
|
|
30108
|
-
return;
|
|
30109
|
-
}
|
|
30110
|
-
for (const entry of entries.filter((e) => STALE_PATTERN.test(e))) {
|
|
30111
|
-
unlinkSync14(join80(dir, entry));
|
|
30112
|
-
}
|
|
30113
|
-
}
|
|
30114
|
-
|
|
30115
|
-
// src/commands/prs/listComments/updateCommentsCache.ts
|
|
30116
|
-
function writeCommentsCache(org, repo, prNumber, comments3) {
|
|
30117
|
-
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
30118
|
-
mkdirSync22(dirname36(cachePath), { recursive: true });
|
|
30119
|
-
const cacheData = {
|
|
30120
|
-
prNumber,
|
|
30121
|
-
fetchedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
30122
|
-
comments: comments3
|
|
30123
|
-
};
|
|
30124
|
-
writeFileSync36(cachePath, stringify3(cacheData));
|
|
30125
|
-
}
|
|
30126
|
-
function updateCommentsCache(org, repo, prNumber, comments3) {
|
|
30127
|
-
removeStaleCommentsCaches();
|
|
30128
|
-
if (comments3.some((c) => c.type === "line")) {
|
|
30129
|
-
writeCommentsCache(org, repo, prNumber, comments3);
|
|
30130
|
-
} else {
|
|
30131
|
-
deleteCommentsCache(org, repo, prNumber);
|
|
30132
|
-
}
|
|
30133
|
-
}
|
|
30134
|
-
|
|
30135
30273
|
// src/commands/prs/isNotFound.ts
|
|
30136
30274
|
function isNotFound(error) {
|
|
30137
30275
|
if (error instanceof Error) {
|
|
@@ -30154,6 +30292,8 @@ function handleKnownErrors(error) {
|
|
|
30154
30292
|
return null;
|
|
30155
30293
|
}
|
|
30156
30294
|
async function listComments() {
|
|
30295
|
+
const azure = azureDevopsRemote(process.cwd());
|
|
30296
|
+
if (azure) return listAzureDevopsComments(azure);
|
|
30157
30297
|
try {
|
|
30158
30298
|
const prNumber = getCurrentPrNumber();
|
|
30159
30299
|
const { org, repo } = getRepoInfo();
|
|
@@ -30211,6 +30351,7 @@ function commentStyle() {
|
|
|
30211
30351
|
|
|
30212
30352
|
// src/commands/prs/listComments/groupThreads.ts
|
|
30213
30353
|
function threadLocation(comment3) {
|
|
30354
|
+
if (!comment3.path) return "the PR";
|
|
30214
30355
|
return comment3.line ? `${comment3.path}:${comment3.line}` : comment3.path;
|
|
30215
30356
|
}
|
|
30216
30357
|
function groupThreads(comments3) {
|
|
@@ -30335,8 +30476,32 @@ function printComments2(result) {
|
|
|
30335
30476
|
// src/commands/prs/fixed.ts
|
|
30336
30477
|
import { execSync as execSync41 } from "child_process";
|
|
30337
30478
|
|
|
30338
|
-
// src/commands/prs/
|
|
30339
|
-
import { execFileSync as
|
|
30479
|
+
// src/commands/prs/threadTarget.ts
|
|
30480
|
+
import { execFileSync as execFileSync23 } from "child_process";
|
|
30481
|
+
|
|
30482
|
+
// src/commands/prs/azureDevops/azureDevopsThreadActions.ts
|
|
30483
|
+
function attempt(run4) {
|
|
30484
|
+
try {
|
|
30485
|
+
return run4();
|
|
30486
|
+
} catch (error) {
|
|
30487
|
+
failAzureDevops(error);
|
|
30488
|
+
}
|
|
30489
|
+
}
|
|
30490
|
+
var azureDevopsThreadActions = {
|
|
30491
|
+
currentPr(repo) {
|
|
30492
|
+
return attempt(() => currentAzureDevopsPr(repo));
|
|
30493
|
+
},
|
|
30494
|
+
reply(pr, threadId, content) {
|
|
30495
|
+
attempt(
|
|
30496
|
+
() => invokeAzDevops(azureDevopsThreadRequests.reply(pr, threadId, content))
|
|
30497
|
+
);
|
|
30498
|
+
},
|
|
30499
|
+
setStatus(pr, threadId, status2) {
|
|
30500
|
+
attempt(
|
|
30501
|
+
() => invokeAzDevops(azureDevopsThreadRequests.status(pr, threadId, status2))
|
|
30502
|
+
);
|
|
30503
|
+
}
|
|
30504
|
+
};
|
|
30340
30505
|
|
|
30341
30506
|
// src/commands/prs/replyToComment.ts
|
|
30342
30507
|
import { spawnSync as spawnSync7 } from "child_process";
|
|
@@ -30357,15 +30522,40 @@ function replyToComment(org, repo, prNumber, commentId, message3) {
|
|
|
30357
30522
|
if (result.status !== 0) throw new Error(result.stderr || result.stdout);
|
|
30358
30523
|
}
|
|
30359
30524
|
|
|
30360
|
-
// src/commands/prs/
|
|
30525
|
+
// src/commands/prs/threadTarget.ts
|
|
30361
30526
|
function resolveThread(threadId) {
|
|
30362
30527
|
const mutation = `mutation($threadId: ID!) { resolveReviewThread(input: {threadId: $threadId}) { thread { isResolved } } }`;
|
|
30363
|
-
|
|
30528
|
+
execFileSync23(
|
|
30364
30529
|
"gh",
|
|
30365
30530
|
["api", "graphql", "-f", `query=${mutation}`, "-f", `threadId=${threadId}`],
|
|
30366
30531
|
{ stdio: ["inherit", "pipe", "inherit"] }
|
|
30367
30532
|
);
|
|
30368
30533
|
}
|
|
30534
|
+
function githubTarget() {
|
|
30535
|
+
const prNumber = getCurrentPrNumber();
|
|
30536
|
+
const { org, repo } = getRepoInfo();
|
|
30537
|
+
return {
|
|
30538
|
+
org,
|
|
30539
|
+
repo,
|
|
30540
|
+
prNumber,
|
|
30541
|
+
reply: (comment3, message3) => replyToComment(org, repo, prNumber, comment3.id, message3),
|
|
30542
|
+
resolve: (comment3) => resolveThread(comment3.threadId)
|
|
30543
|
+
};
|
|
30544
|
+
}
|
|
30545
|
+
function threadTarget(status2) {
|
|
30546
|
+
const azure = azureDevopsRemote(process.cwd());
|
|
30547
|
+
if (!azure) return githubTarget();
|
|
30548
|
+
const pr = azureDevopsThreadActions.currentPr(azure);
|
|
30549
|
+
const threadId = (comment3) => Number(comment3.threadId);
|
|
30550
|
+
return {
|
|
30551
|
+
...azureDevopsCacheRepo(pr),
|
|
30552
|
+
prNumber: pr.prId,
|
|
30553
|
+
reply: (comment3, message3) => azureDevopsThreadActions.reply(pr, threadId(comment3), message3),
|
|
30554
|
+
resolve: (comment3) => azureDevopsThreadActions.setStatus(pr, threadId(comment3), status2)
|
|
30555
|
+
};
|
|
30556
|
+
}
|
|
30557
|
+
|
|
30558
|
+
// src/commands/prs/resolveCommentWithReply.ts
|
|
30369
30559
|
function requireCache(org, repo, prNumber) {
|
|
30370
30560
|
const cache7 = loadCommentsCache(org, repo, prNumber);
|
|
30371
30561
|
if (!cache7) {
|
|
@@ -30389,22 +30579,21 @@ function requireLineComment(cache7, commentId) {
|
|
|
30389
30579
|
}
|
|
30390
30580
|
return comment3;
|
|
30391
30581
|
}
|
|
30392
|
-
function cleanupCacheIfDone(cache7, org, repo, prNumber, commentId) {
|
|
30582
|
+
function cleanupCacheIfDone(cache7, { org, repo, prNumber }, commentId) {
|
|
30393
30583
|
const hasRemaining = cache7.comments.some(
|
|
30394
30584
|
(c) => c.type === "line" && c.id !== commentId
|
|
30395
30585
|
);
|
|
30396
30586
|
if (!hasRemaining) deleteCommentsCache(org, repo, prNumber);
|
|
30397
30587
|
}
|
|
30398
|
-
function resolveCommentWithReply(commentId, message3) {
|
|
30399
|
-
const
|
|
30400
|
-
const
|
|
30401
|
-
const cache7 = requireCache(org, repo, prNumber);
|
|
30588
|
+
function resolveCommentWithReply(commentId, message3, status2) {
|
|
30589
|
+
const target = threadTarget(status2);
|
|
30590
|
+
const cache7 = requireCache(target.org, target.repo, target.prNumber);
|
|
30402
30591
|
const comment3 = requireLineComment(cache7, commentId);
|
|
30403
|
-
|
|
30592
|
+
target.reply(comment3, message3);
|
|
30404
30593
|
console.log("Reply posted successfully.");
|
|
30405
|
-
|
|
30594
|
+
target.resolve(comment3);
|
|
30406
30595
|
console.log("Thread resolved successfully.");
|
|
30407
|
-
cleanupCacheIfDone(cache7,
|
|
30596
|
+
cleanupCacheIfDone(cache7, target, commentId);
|
|
30408
30597
|
}
|
|
30409
30598
|
|
|
30410
30599
|
// src/commands/prs/fixed.ts
|
|
@@ -30418,14 +30607,18 @@ function verifySha(sha) {
|
|
|
30418
30607
|
process.exit(1);
|
|
30419
30608
|
}
|
|
30420
30609
|
}
|
|
30610
|
+
function repoUrl() {
|
|
30611
|
+
const azure = azureDevopsRemote(process.cwd());
|
|
30612
|
+
if (azure) return azureDevopsRepoUrl(azure);
|
|
30613
|
+
const { org, repo } = getRepoInfo();
|
|
30614
|
+
return `https://github.com/${org}/${repo}`;
|
|
30615
|
+
}
|
|
30421
30616
|
function fixed(commentId, sha) {
|
|
30422
30617
|
try {
|
|
30423
30618
|
const fullSha = verifySha(sha);
|
|
30424
|
-
const
|
|
30425
|
-
const repoUrl = `https://github.com/${org}/${repo}`;
|
|
30426
|
-
const message3 = `Fixed in [${fullSha}](${repoUrl}/commit/${fullSha})`;
|
|
30619
|
+
const message3 = `Fixed in [${fullSha}](${repoUrl()}/commit/${fullSha})`;
|
|
30427
30620
|
pushCommit(loadConfig().worktree?.trunk === true);
|
|
30428
|
-
resolveCommentWithReply(commentId, message3);
|
|
30621
|
+
resolveCommentWithReply(commentId, message3, "fixed");
|
|
30429
30622
|
} catch (error) {
|
|
30430
30623
|
if (isGhNotInstalled(error)) {
|
|
30431
30624
|
console.error("Error: GitHub CLI (gh) is not installed.");
|
|
@@ -30447,6 +30640,13 @@ function validateBody2(body) {
|
|
|
30447
30640
|
async function reply(commentId, body) {
|
|
30448
30641
|
validateBody2(body);
|
|
30449
30642
|
await reviewProposedPrComment(`Reply to comment #${commentId}`, body, null);
|
|
30643
|
+
const azure = azureDevopsRemote(process.cwd());
|
|
30644
|
+
if (azure) {
|
|
30645
|
+
const pr = azureDevopsThreadActions.currentPr(azure);
|
|
30646
|
+
azureDevopsThreadActions.reply(pr, commentId, body);
|
|
30647
|
+
console.log("Reply posted successfully.");
|
|
30648
|
+
return;
|
|
30649
|
+
}
|
|
30450
30650
|
try {
|
|
30451
30651
|
const prNumber = getCurrentPrNumber();
|
|
30452
30652
|
const { org, repo } = getRepoInfo();
|
|
@@ -30472,7 +30672,7 @@ function validateReason(reason4) {
|
|
|
30472
30672
|
}
|
|
30473
30673
|
}
|
|
30474
30674
|
function validateShaReferences(reason4) {
|
|
30475
|
-
const commitLinkPattern = /\[[0-9a-f]{7}\]\(https:\/\/github\.com\/[^/]+\/[^/]+\/commit\/([0-9a-f]{40})\)/gi;
|
|
30675
|
+
const commitLinkPattern = /\[[0-9a-f]{7}\]\(https:\/\/(?:github\.com\/[^/]+\/[^/]+|dev\.azure\.com\/[^/]+\/[^/]+\/_git\/[^/]+)\/commit\/([0-9a-f]{40})\)/gi;
|
|
30476
30676
|
const shas = Array.from(reason4.matchAll(commitLinkPattern), (m) => m[1]);
|
|
30477
30677
|
if (shas.length === 0) {
|
|
30478
30678
|
return;
|
|
@@ -30501,7 +30701,7 @@ async function wontfix(commentId, reason4) {
|
|
|
30501
30701
|
null
|
|
30502
30702
|
);
|
|
30503
30703
|
try {
|
|
30504
|
-
resolveCommentWithReply(commentId, reason4);
|
|
30704
|
+
resolveCommentWithReply(commentId, reason4, "wontFix");
|
|
30505
30705
|
} catch (error) {
|
|
30506
30706
|
if (isGhNotInstalled(error)) {
|
|
30507
30707
|
console.error("Error: GitHub CLI (gh) is not installed.");
|
|
@@ -30965,7 +31165,7 @@ function buildValidatedBody(options2, usage) {
|
|
|
30965
31165
|
}
|
|
30966
31166
|
|
|
30967
31167
|
// src/commands/prs/placePr.ts
|
|
30968
|
-
import { execFileSync as
|
|
31168
|
+
import { execFileSync as execFileSync24 } from "child_process";
|
|
30969
31169
|
|
|
30970
31170
|
// src/commands/prs/buildCreateArgs.ts
|
|
30971
31171
|
function buildCreateArgs(title, body, options2, attachments = []) {
|
|
@@ -31051,7 +31251,7 @@ function buildEditArgs(number, title, body, attachments = []) {
|
|
|
31051
31251
|
// src/commands/prs/placePr.ts
|
|
31052
31252
|
function hasUpstream2() {
|
|
31053
31253
|
try {
|
|
31054
|
-
|
|
31254
|
+
execFileSync24(
|
|
31055
31255
|
"git",
|
|
31056
31256
|
["rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{u}"],
|
|
31057
31257
|
{ stdio: "pipe" }
|
|
@@ -31063,7 +31263,7 @@ function hasUpstream2() {
|
|
|
31063
31263
|
}
|
|
31064
31264
|
function ensureBranchPushed() {
|
|
31065
31265
|
const args = hasUpstream2() ? ["push"] : ["push", "--set-upstream", "origin", "HEAD"];
|
|
31066
|
-
|
|
31266
|
+
execFileSync24("git", args, { stdio: "inherit" });
|
|
31067
31267
|
}
|
|
31068
31268
|
async function placePr(prNumber, title, body, options2, attachments = []) {
|
|
31069
31269
|
const args = prNumber !== null ? buildEditArgs(prNumber, title, body, attachments) : buildCreateArgs(title, body, options2, attachments);
|
|
@@ -31134,10 +31334,10 @@ function warn(reason4) {
|
|
|
31134
31334
|
}
|
|
31135
31335
|
|
|
31136
31336
|
// src/commands/prs/enableAutoMerge.ts
|
|
31137
|
-
import { execFileSync as
|
|
31337
|
+
import { execFileSync as execFileSync25 } from "child_process";
|
|
31138
31338
|
function enableAutoMerge() {
|
|
31139
31339
|
try {
|
|
31140
|
-
|
|
31340
|
+
execFileSync25(
|
|
31141
31341
|
"gh",
|
|
31142
31342
|
["pr", "merge", getCurrentBranch2(), "--auto", "--squash"],
|
|
31143
31343
|
{ stdio: "inherit" }
|
|
@@ -31395,10 +31595,10 @@ function prsSlackChannel() {
|
|
|
31395
31595
|
}
|
|
31396
31596
|
|
|
31397
31597
|
// src/commands/prs/status/fetchReviewThreads.ts
|
|
31398
|
-
import { execFileSync as
|
|
31598
|
+
import { execFileSync as execFileSync26 } from "child_process";
|
|
31399
31599
|
var THREAD_QUERY2 = `query($owner: String!, $repo: String!, $prNumber: Int!) { repository(owner: $owner, name: $repo) { pullRequest(number: $prNumber) { reviewThreads(first: 100) { nodes { isResolved } } } } }`;
|
|
31400
31600
|
function fetchReviewThreads(org, repo, prNumber) {
|
|
31401
|
-
const output =
|
|
31601
|
+
const output = execFileSync26(
|
|
31402
31602
|
"gh",
|
|
31403
31603
|
[
|
|
31404
31604
|
"api",
|
|
@@ -32955,9 +33155,9 @@ async function notify() {
|
|
|
32955
33155
|
|
|
32956
33156
|
// src/commands/screenshot.ts
|
|
32957
33157
|
import { execSync as execSync49 } from "child_process";
|
|
32958
|
-
import { existsSync as existsSync65, mkdirSync as mkdirSync23, unlinkSync as unlinkSync15, writeFileSync as
|
|
32959
|
-
import { tmpdir as
|
|
32960
|
-
import { join as
|
|
33158
|
+
import { existsSync as existsSync65, mkdirSync as mkdirSync23, unlinkSync as unlinkSync15, writeFileSync as writeFileSync38 } from "fs";
|
|
33159
|
+
import { tmpdir as tmpdir7 } from "os";
|
|
33160
|
+
import { join as join82, resolve as resolve24 } from "path";
|
|
32961
33161
|
import chalk208 from "chalk";
|
|
32962
33162
|
|
|
32963
33163
|
// src/commands/screenshot/captureWindowPs1.ts
|
|
@@ -33094,8 +33294,8 @@ function buildOutputPath(outputDir, processName) {
|
|
|
33094
33294
|
return resolve24(outputDir, `${processName}-${timestamp6}.png`);
|
|
33095
33295
|
}
|
|
33096
33296
|
function runPowerShellScript(processName, outputPath) {
|
|
33097
|
-
const scriptPath =
|
|
33098
|
-
|
|
33297
|
+
const scriptPath = join82(tmpdir7(), `assist-screenshot-${Date.now()}.ps1`);
|
|
33298
|
+
writeFileSync38(scriptPath, captureWindowPs1, "utf8");
|
|
33099
33299
|
try {
|
|
33100
33300
|
execSync49(
|
|
33101
33301
|
`powershell -NoProfile -ExecutionPolicy Bypass -File "${scriptPath}" -ProcessName "${processName}" -OutputPath "${outputPath}"`,
|
|
@@ -33209,9 +33409,9 @@ function buildLimitsSegment(rateLimits) {
|
|
|
33209
33409
|
|
|
33210
33410
|
// src/commands/readGitBranch.ts
|
|
33211
33411
|
import { readFileSync as readFileSync48, statSync as statSync10 } from "fs";
|
|
33212
|
-
import { isAbsolute as isAbsolute6, join as
|
|
33412
|
+
import { isAbsolute as isAbsolute6, join as join83, resolve as resolve25 } from "path";
|
|
33213
33413
|
function resolveGitDir(cwd) {
|
|
33214
|
-
const dotGit =
|
|
33414
|
+
const dotGit = join83(cwd, ".git");
|
|
33215
33415
|
let stat5;
|
|
33216
33416
|
try {
|
|
33217
33417
|
stat5 = statSync10(dotGit);
|
|
@@ -33241,7 +33441,7 @@ function readGitBranch(cwd) {
|
|
|
33241
33441
|
}
|
|
33242
33442
|
let head;
|
|
33243
33443
|
try {
|
|
33244
|
-
head = readFileSync48(
|
|
33444
|
+
head = readFileSync48(join83(gitDir, "HEAD"), "utf8");
|
|
33245
33445
|
} catch {
|
|
33246
33446
|
return null;
|
|
33247
33447
|
}
|
|
@@ -35717,7 +35917,7 @@ function exitWith(message3) {
|
|
|
35717
35917
|
}
|
|
35718
35918
|
|
|
35719
35919
|
// src/commands/review/highLevel/proposeHighLevelGlobs.ts
|
|
35720
|
-
import { execFileSync as
|
|
35920
|
+
import { execFileSync as execFileSync28 } from "child_process";
|
|
35721
35921
|
import chalk232 from "chalk";
|
|
35722
35922
|
|
|
35723
35923
|
// src/commands/review/highLevel/buildGlobProposalPrompt.ts
|
|
@@ -35766,7 +35966,7 @@ function readGlobs(value) {
|
|
|
35766
35966
|
}
|
|
35767
35967
|
|
|
35768
35968
|
// src/commands/review/highLevel/summariseRepoTree.ts
|
|
35769
|
-
import { execFileSync as
|
|
35969
|
+
import { execFileSync as execFileSync27 } from "child_process";
|
|
35770
35970
|
import { dirname as dirname38, extname as extname6 } from "path";
|
|
35771
35971
|
var MAX_DIRECTORIES = 200;
|
|
35772
35972
|
var MAX_EXTENSIONS_PER_DIRECTORY = 6;
|
|
@@ -35782,7 +35982,7 @@ function summariseRepoTree(cwd = process.cwd()) {
|
|
|
35782
35982
|
}
|
|
35783
35983
|
function listTrackedFiles(cwd) {
|
|
35784
35984
|
try {
|
|
35785
|
-
return
|
|
35985
|
+
return execFileSync27("git", ["ls-files"], {
|
|
35786
35986
|
cwd,
|
|
35787
35987
|
encoding: "utf8",
|
|
35788
35988
|
maxBuffer: 64 * 1024 * 1024
|
|
@@ -35827,7 +36027,7 @@ function proposeHighLevelGlobs(cwd = process.cwd()) {
|
|
|
35827
36027
|
}
|
|
35828
36028
|
function askClaude(prompt, cwd) {
|
|
35829
36029
|
try {
|
|
35830
|
-
return
|
|
36030
|
+
return execFileSync28("claude", ["-p", "--model", "sonnet", prompt], {
|
|
35831
36031
|
cwd,
|
|
35832
36032
|
encoding: "utf8",
|
|
35833
36033
|
timeout: 12e4,
|
|
@@ -36421,11 +36621,11 @@ function evaluateHighLevelChecks(subject) {
|
|
|
36421
36621
|
}
|
|
36422
36622
|
|
|
36423
36623
|
// src/commands/review/highLevel/fetchFileAtSha.ts
|
|
36424
|
-
import { execFileSync as
|
|
36624
|
+
import { execFileSync as execFileSync29 } from "child_process";
|
|
36425
36625
|
function fetchFileAtSha(repo, sha, path108) {
|
|
36426
36626
|
const encodedPath = path108.split("/").map(encodeURIComponent).join("/");
|
|
36427
36627
|
try {
|
|
36428
|
-
return
|
|
36628
|
+
return execFileSync29(
|
|
36429
36629
|
"gh",
|
|
36430
36630
|
[
|
|
36431
36631
|
"api",
|
|
@@ -36447,7 +36647,7 @@ function fetchFileAtSha(repo, sha, path108) {
|
|
|
36447
36647
|
}
|
|
36448
36648
|
|
|
36449
36649
|
// src/commands/review/highLevel/fetchHighLevelFiles.ts
|
|
36450
|
-
import { execFileSync as
|
|
36650
|
+
import { execFileSync as execFileSync30 } from "child_process";
|
|
36451
36651
|
import { createHash as createHash4 } from "crypto";
|
|
36452
36652
|
var JQ = ".[] | {filename,status,additions,deletions,patch} | @json";
|
|
36453
36653
|
function toStatus(status2) {
|
|
@@ -36460,7 +36660,7 @@ function diffUrl(repo, prNumber, path108) {
|
|
|
36460
36660
|
return `https://github.com/${repo}/pull/${prNumber}/files#diff-${anchor}`;
|
|
36461
36661
|
}
|
|
36462
36662
|
function fetchHighLevelFiles(prNumber, repo) {
|
|
36463
|
-
const out =
|
|
36663
|
+
const out = execFileSync30(
|
|
36464
36664
|
"gh",
|
|
36465
36665
|
["api", `repos/${repo}/pulls/${prNumber}/files`, "--paginate", "--jq", JQ],
|
|
36466
36666
|
{ encoding: "utf8", maxBuffer: 64 * 1024 * 1024 }
|
|
@@ -36489,7 +36689,7 @@ function sleepSync(ms) {
|
|
|
36489
36689
|
}
|
|
36490
36690
|
function waitForMergeable(initial, refetch, delayMs = DELAY_MS) {
|
|
36491
36691
|
let mergeable = initial;
|
|
36492
|
-
for (let
|
|
36692
|
+
for (let attempt2 = 1; mergeable === "UNKNOWN" && attempt2 < MAX_ATTEMPTS; attempt2++) {
|
|
36493
36693
|
sleepSync(delayMs);
|
|
36494
36694
|
mergeable = refetch();
|
|
36495
36695
|
}
|
|
@@ -36527,12 +36727,12 @@ function fetchHighLevelPr(prNumber, repo) {
|
|
|
36527
36727
|
}
|
|
36528
36728
|
|
|
36529
36729
|
// src/commands/review/highLevel/highLevelReviewPath.ts
|
|
36530
|
-
import { join as
|
|
36730
|
+
import { join as join84 } from "path";
|
|
36531
36731
|
function slug(value) {
|
|
36532
36732
|
return value.replace(/[^\w.-]+/g, "-");
|
|
36533
36733
|
}
|
|
36534
36734
|
function highLevelReviewPath(repo, headRef, headSha) {
|
|
36535
|
-
return
|
|
36735
|
+
return join84(
|
|
36536
36736
|
getStoreDir(),
|
|
36537
36737
|
"high-level-reviews",
|
|
36538
36738
|
slug(repo),
|
|
@@ -36698,17 +36898,17 @@ function buildHighLevelRecord(subject, decision) {
|
|
|
36698
36898
|
}
|
|
36699
36899
|
|
|
36700
36900
|
// src/commands/review/highLevel/clearHighLevelDraft.ts
|
|
36701
|
-
import { rmSync as
|
|
36901
|
+
import { rmSync as rmSync7 } from "fs";
|
|
36702
36902
|
function clearHighLevelDraft(repo, headRef, headSha) {
|
|
36703
|
-
|
|
36903
|
+
rmSync7(highLevelDraftPath(repo, headRef, headSha), { force: true });
|
|
36704
36904
|
}
|
|
36705
36905
|
|
|
36706
36906
|
// src/commands/review/highLevel/writeJsonFile.ts
|
|
36707
|
-
import { mkdirSync as mkdirSync24, writeFileSync as
|
|
36907
|
+
import { mkdirSync as mkdirSync24, writeFileSync as writeFileSync39 } from "fs";
|
|
36708
36908
|
import { dirname as dirname39 } from "path";
|
|
36709
36909
|
function writeJsonFile(path108, data) {
|
|
36710
36910
|
mkdirSync24(dirname39(path108), { recursive: true });
|
|
36711
|
-
|
|
36911
|
+
writeFileSync39(path108, `${JSON.stringify(data, null, 2)}
|
|
36712
36912
|
`);
|
|
36713
36913
|
return path108;
|
|
36714
36914
|
}
|
|
@@ -37691,7 +37891,7 @@ import { format as format2 } from "util";
|
|
|
37691
37891
|
|
|
37692
37892
|
// src/commands/review/createReviewLogSink.ts
|
|
37693
37893
|
import { appendFileSync as appendFileSync4, mkdirSync as mkdirSync25 } from "fs";
|
|
37694
|
-
import { join as
|
|
37894
|
+
import { join as join85 } from "path";
|
|
37695
37895
|
var LOG_FILE = "review.log";
|
|
37696
37896
|
function createReviewLogSink() {
|
|
37697
37897
|
let logPath2;
|
|
@@ -37708,7 +37908,7 @@ function createReviewLogSink() {
|
|
|
37708
37908
|
},
|
|
37709
37909
|
attach(reviewDir) {
|
|
37710
37910
|
mkdirSync25(reviewDir, { recursive: true });
|
|
37711
|
-
logPath2 =
|
|
37911
|
+
logPath2 = join85(reviewDir, LOG_FILE);
|
|
37712
37912
|
const lines2 = [
|
|
37713
37913
|
"",
|
|
37714
37914
|
`=== ${(/* @__PURE__ */ new Date()).toISOString()} ===`,
|
|
@@ -37958,7 +38158,7 @@ function buildCodexModelArgs() {
|
|
|
37958
38158
|
}
|
|
37959
38159
|
|
|
37960
38160
|
// src/commands/review/runClaudeReviewer.ts
|
|
37961
|
-
import { writeFileSync as
|
|
38161
|
+
import { writeFileSync as writeFileSync40 } from "fs";
|
|
37962
38162
|
|
|
37963
38163
|
// src/commands/review/formatToolSummary.ts
|
|
37964
38164
|
function truncate2(value, max = 80) {
|
|
@@ -38397,7 +38597,7 @@ async function runClaudeReviewer(spec) {
|
|
|
38397
38597
|
onLine
|
|
38398
38598
|
});
|
|
38399
38599
|
if (result.exitCode === 0 && state.finalText)
|
|
38400
|
-
|
|
38600
|
+
writeFileSync40(spec.outputPath, state.finalText);
|
|
38401
38601
|
const finalised = finaliseReviewerRun(
|
|
38402
38602
|
{ ...spec, command, model: override?.model },
|
|
38403
38603
|
spinner,
|
|
@@ -38923,9 +39123,9 @@ ${annotateDiffWithLineNumbers(context.diff.trimEnd())}
|
|
|
38923
39123
|
|
|
38924
39124
|
// src/commands/review/buildReviewPaths.ts
|
|
38925
39125
|
import { homedir as homedir25 } from "os";
|
|
38926
|
-
import { basename as basename24, join as
|
|
39126
|
+
import { basename as basename24, join as join86 } from "path";
|
|
38927
39127
|
function buildReviewPaths(repoRoot2, key) {
|
|
38928
|
-
const reviewDir =
|
|
39128
|
+
const reviewDir = join86(
|
|
38929
39129
|
homedir25(),
|
|
38930
39130
|
".assist",
|
|
38931
39131
|
"reviews",
|
|
@@ -38934,10 +39134,10 @@ function buildReviewPaths(repoRoot2, key) {
|
|
|
38934
39134
|
);
|
|
38935
39135
|
return {
|
|
38936
39136
|
reviewDir,
|
|
38937
|
-
requestPath:
|
|
38938
|
-
claudePath:
|
|
38939
|
-
codexPath:
|
|
38940
|
-
synthesisPath:
|
|
39137
|
+
requestPath: join86(reviewDir, "request.md"),
|
|
39138
|
+
claudePath: join86(reviewDir, "claude.md"),
|
|
39139
|
+
codexPath: join86(reviewDir, "codex.md"),
|
|
39140
|
+
synthesisPath: join86(reviewDir, "synthesis.md")
|
|
38941
39141
|
};
|
|
38942
39142
|
}
|
|
38943
39143
|
|
|
@@ -38975,7 +39175,7 @@ function fetchExistingComments() {
|
|
|
38975
39175
|
}
|
|
38976
39176
|
|
|
38977
39177
|
// src/commands/review/prepareReviewDir.ts
|
|
38978
|
-
import { existsSync as existsSync69, mkdirSync as mkdirSync26, unlinkSync as unlinkSync18, writeFileSync as
|
|
39178
|
+
import { existsSync as existsSync69, mkdirSync as mkdirSync26, unlinkSync as unlinkSync18, writeFileSync as writeFileSync41 } from "fs";
|
|
38979
39179
|
function clearReviewFiles(paths) {
|
|
38980
39180
|
for (const path108 of [paths.claudePath, paths.codexPath, paths.synthesisPath]) {
|
|
38981
39181
|
if (existsSync69(path108)) unlinkSync18(path108);
|
|
@@ -38984,7 +39184,7 @@ function clearReviewFiles(paths) {
|
|
|
38984
39184
|
function prepareReviewDir(paths, requestBody, force) {
|
|
38985
39185
|
mkdirSync26(paths.reviewDir, { recursive: true });
|
|
38986
39186
|
if (force) clearReviewFiles(paths);
|
|
38987
|
-
|
|
39187
|
+
writeFileSync41(paths.requestPath, requestBody);
|
|
38988
39188
|
}
|
|
38989
39189
|
|
|
38990
39190
|
// src/commands/review/setupReviewDir.ts
|
|
@@ -39632,7 +39832,7 @@ function registerReview(program) {
|
|
|
39632
39832
|
}
|
|
39633
39833
|
|
|
39634
39834
|
// src/commands/rules/addRule.ts
|
|
39635
|
-
import { existsSync as existsSync72, readFileSync as readFileSync56, writeFileSync as
|
|
39835
|
+
import { existsSync as existsSync72, readFileSync as readFileSync56, writeFileSync as writeFileSync43 } from "fs";
|
|
39636
39836
|
import path87 from "path";
|
|
39637
39837
|
import chalk242 from "chalk";
|
|
39638
39838
|
|
|
@@ -39707,7 +39907,7 @@ function resolveRuleScope(target) {
|
|
|
39707
39907
|
}
|
|
39708
39908
|
|
|
39709
39909
|
// src/commands/rules/updateScopedRulesIndex.ts
|
|
39710
|
-
import { existsSync as existsSync71, readFileSync as readFileSync55, writeFileSync as
|
|
39910
|
+
import { existsSync as existsSync71, readFileSync as readFileSync55, writeFileSync as writeFileSync42 } from "fs";
|
|
39711
39911
|
import path86 from "path";
|
|
39712
39912
|
|
|
39713
39913
|
// src/commands/rules/scopedRuleDirectories.ts
|
|
@@ -39759,7 +39959,7 @@ function updateScopedRulesIndex(root2) {
|
|
|
39759
39959
|
const rootFile = path86.join(root2, "CLAUDE.md");
|
|
39760
39960
|
const before = existsSync71(rootFile) ? readFileSync55(rootFile, "utf8") : "";
|
|
39761
39961
|
const after = upsertScopedRulesPointer(before, directories);
|
|
39762
|
-
if (after !== before)
|
|
39962
|
+
if (after !== before) writeFileSync42(rootFile, after);
|
|
39763
39963
|
return directories;
|
|
39764
39964
|
}
|
|
39765
39965
|
|
|
@@ -39778,7 +39978,7 @@ function addRule(text17, options2) {
|
|
|
39778
39978
|
const targetDir = path87.dirname(target);
|
|
39779
39979
|
const root2 = findRepoRoot(targetDir) ?? targetDir;
|
|
39780
39980
|
const code = nextRuleCode(root2);
|
|
39781
|
-
|
|
39981
|
+
writeFileSync43(
|
|
39782
39982
|
target,
|
|
39783
39983
|
insertRuleBullet(read2(target), {
|
|
39784
39984
|
code,
|
|
@@ -40309,10 +40509,10 @@ function parseSlackThreadRef(value) {
|
|
|
40309
40509
|
}
|
|
40310
40510
|
|
|
40311
40511
|
// src/commands/slack/postSlackMessage.ts
|
|
40312
|
-
import { mkdirSync as mkdirSync28, writeFileSync as
|
|
40512
|
+
import { mkdirSync as mkdirSync28, writeFileSync as writeFileSync45 } from "fs";
|
|
40313
40513
|
|
|
40314
40514
|
// src/commands/slack/previewSlackThreadParts.ts
|
|
40315
|
-
import { mkdirSync as mkdirSync27, writeFileSync as
|
|
40515
|
+
import { mkdirSync as mkdirSync27, writeFileSync as writeFileSync44 } from "fs";
|
|
40316
40516
|
|
|
40317
40517
|
// src/commands/slack/readSlackParts.ts
|
|
40318
40518
|
import { readFileSync as readFileSync57 } from "fs";
|
|
@@ -40358,12 +40558,12 @@ async function reviewProposedSlackMessage(target, body, workingPath) {
|
|
|
40358
40558
|
}
|
|
40359
40559
|
|
|
40360
40560
|
// src/commands/slack/slackWorkingFile.ts
|
|
40361
|
-
import { join as
|
|
40561
|
+
import { join as join87 } from "path";
|
|
40362
40562
|
function slackWorkingFile(channel, partIndex) {
|
|
40363
40563
|
const slug2 = channel.replace(/^[#@]/, "").toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "channel";
|
|
40364
|
-
const dir =
|
|
40564
|
+
const dir = join87(getStoreDir(), "slack");
|
|
40365
40565
|
const name = partIndex === void 0 ? slug2 : `${slug2}-${partIndex}`;
|
|
40366
|
-
return { dir, bodyPath:
|
|
40566
|
+
return { dir, bodyPath: join87(dir, `${name}.md`) };
|
|
40367
40567
|
}
|
|
40368
40568
|
|
|
40369
40569
|
// src/commands/slack/previewSlackThreadParts.ts
|
|
@@ -40378,7 +40578,7 @@ async function previewSlackThreadParts({
|
|
|
40378
40578
|
mkdirSync27(dir, { recursive: true });
|
|
40379
40579
|
const paths = bodies.map((body, index2) => {
|
|
40380
40580
|
const { bodyPath } = slackWorkingFile(channel, index2 + 1);
|
|
40381
|
-
|
|
40581
|
+
writeFileSync44(bodyPath, `${body}
|
|
40382
40582
|
`);
|
|
40383
40583
|
return bodyPath;
|
|
40384
40584
|
});
|
|
@@ -40430,7 +40630,7 @@ async function postSlackMessage(channelArg, options2) {
|
|
|
40430
40630
|
}
|
|
40431
40631
|
const { dir, bodyPath } = slackWorkingFile(channel);
|
|
40432
40632
|
mkdirSync28(dir, { recursive: true });
|
|
40433
|
-
|
|
40633
|
+
writeFileSync45(bodyPath, `${body}
|
|
40434
40634
|
`);
|
|
40435
40635
|
await reviewProposedSlackMessage({ channel, threadTs }, body, bodyPath);
|
|
40436
40636
|
console.log(`Approved for ${target}. The body to post is at:`);
|
|
@@ -41049,7 +41249,7 @@ function syncPiHooks(sourceDir) {
|
|
|
41049
41249
|
}
|
|
41050
41250
|
|
|
41051
41251
|
// src/commands/sync/syncPi.ts
|
|
41052
|
-
function
|
|
41252
|
+
function unquote(value) {
|
|
41053
41253
|
return value.trim().replace(/^["']|["']$/g, "");
|
|
41054
41254
|
}
|
|
41055
41255
|
function commandToPrompt(name, content) {
|
|
@@ -41057,7 +41257,7 @@ function commandToPrompt(name, content) {
|
|
|
41057
41257
|
const { frontmatter: frontmatter2, body } = split;
|
|
41058
41258
|
const description = split.description ?? name;
|
|
41059
41259
|
const argsMatch = frontmatter2.match(/^allowed_args:\s*(.*)$/m);
|
|
41060
|
-
const argumentHint = argsMatch ?
|
|
41260
|
+
const argumentHint = argsMatch ? unquote(argsMatch[1]) : void 0;
|
|
41061
41261
|
const header = [
|
|
41062
41262
|
"---",
|
|
41063
41263
|
`description: ${description}`,
|
|
@@ -41546,20 +41746,20 @@ async function configure() {
|
|
|
41546
41746
|
|
|
41547
41747
|
// src/commands/transcript/list.ts
|
|
41548
41748
|
import { existsSync as existsSync78, readdirSync as readdirSync21, statSync as statSync12 } from "fs";
|
|
41549
|
-
import { join as
|
|
41749
|
+
import { join as join99 } from "path";
|
|
41550
41750
|
function list4() {
|
|
41551
41751
|
const { vttDir } = getTranscriptConfig();
|
|
41552
41752
|
if (!existsSync78(vttDir)) return;
|
|
41553
41753
|
for (const entry of readdirSync21(vttDir)) {
|
|
41554
41754
|
if (!entry.endsWith(".vtt")) continue;
|
|
41555
|
-
if (statSync12(
|
|
41755
|
+
if (statSync12(join99(vttDir, entry)).isDirectory()) continue;
|
|
41556
41756
|
console.log(entry);
|
|
41557
41757
|
}
|
|
41558
41758
|
}
|
|
41559
41759
|
|
|
41560
41760
|
// src/commands/transcript/move.ts
|
|
41561
|
-
import { existsSync as existsSync79, mkdirSync as mkdirSync34, renameSync as renameSync4, writeFileSync as
|
|
41562
|
-
import { basename as basename27, join as
|
|
41761
|
+
import { existsSync as existsSync79, mkdirSync as mkdirSync34, renameSync as renameSync4, writeFileSync as writeFileSync50 } from "fs";
|
|
41762
|
+
import { basename as basename27, join as join100 } from "path";
|
|
41563
41763
|
|
|
41564
41764
|
// src/commands/transcript/convertVttToMarkdown.ts
|
|
41565
41765
|
function convertVttToMarkdown(inputPath) {
|
|
@@ -41569,9 +41769,9 @@ function convertVttToMarkdown(inputPath) {
|
|
|
41569
41769
|
// src/commands/transcript/move.ts
|
|
41570
41770
|
var DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
|
|
41571
41771
|
function archiveRawVtt(vttDir, sourcePath, filename) {
|
|
41572
|
-
const processedDir =
|
|
41772
|
+
const processedDir = join100(vttDir, "processed");
|
|
41573
41773
|
mkdirSync34(processedDir, { recursive: true });
|
|
41574
|
-
renameSync4(sourcePath,
|
|
41774
|
+
renameSync4(sourcePath, join100(processedDir, filename));
|
|
41575
41775
|
}
|
|
41576
41776
|
function move(file, options2) {
|
|
41577
41777
|
const { date, client } = options2;
|
|
@@ -41581,25 +41781,25 @@ function move(file, options2) {
|
|
|
41581
41781
|
}
|
|
41582
41782
|
const { vttDir, transcriptsDir, summaryDir } = getTranscriptConfig();
|
|
41583
41783
|
const filename = basename27(file);
|
|
41584
|
-
const sourcePath =
|
|
41784
|
+
const sourcePath = join100(vttDir, filename);
|
|
41585
41785
|
if (!existsSync79(sourcePath)) {
|
|
41586
41786
|
console.error(`Error: VTT file not found: ${sourcePath}`);
|
|
41587
41787
|
process.exit(1);
|
|
41588
41788
|
}
|
|
41589
41789
|
const base = basename27(filename, ".vtt").replace(/ Transcription$/, "");
|
|
41590
41790
|
const outputName = `${date} ${base}.md`;
|
|
41591
|
-
const formattedDir =
|
|
41791
|
+
const formattedDir = join100(transcriptsDir, client);
|
|
41592
41792
|
mkdirSync34(formattedDir, { recursive: true });
|
|
41593
|
-
const formattedPath =
|
|
41594
|
-
|
|
41793
|
+
const formattedPath = join100(formattedDir, outputName);
|
|
41794
|
+
writeFileSync50(formattedPath, convertVttToMarkdown(sourcePath), "utf8");
|
|
41595
41795
|
archiveRawVtt(vttDir, sourcePath, filename);
|
|
41596
|
-
const summaryPath =
|
|
41796
|
+
const summaryPath = join100(summaryDir, client, outputName);
|
|
41597
41797
|
console.log(`Formatted transcript: ${formattedPath}`);
|
|
41598
41798
|
console.log(`Summary target: ${summaryPath}`);
|
|
41599
41799
|
}
|
|
41600
41800
|
|
|
41601
41801
|
// src/commands/transcript/merge.ts
|
|
41602
|
-
import { existsSync as existsSync80, writeFileSync as
|
|
41802
|
+
import { existsSync as existsSync80, writeFileSync as writeFileSync51 } from "fs";
|
|
41603
41803
|
import { basename as basename28 } from "path";
|
|
41604
41804
|
|
|
41605
41805
|
// src/commands/transcript/failTranscript.ts
|
|
@@ -41776,7 +41976,7 @@ async function merge(files, options2 = {}) {
|
|
|
41776
41976
|
console.log(document);
|
|
41777
41977
|
return;
|
|
41778
41978
|
}
|
|
41779
|
-
|
|
41979
|
+
writeFileSync51(options2.out, `${document}
|
|
41780
41980
|
`, "utf8");
|
|
41781
41981
|
console.log(`Merged transcript: ${options2.out}`);
|
|
41782
41982
|
}
|
|
@@ -42289,13 +42489,13 @@ Total: ${violations.length} forbidden string(s).`);
|
|
|
42289
42489
|
}
|
|
42290
42490
|
|
|
42291
42491
|
// src/commands/verify/hardcodedColors.ts
|
|
42292
|
-
import { execFileSync as
|
|
42492
|
+
import { execFileSync as execFileSync31 } from "child_process";
|
|
42293
42493
|
import { minimatch as minimatch11 } from "minimatch";
|
|
42294
42494
|
var pattern = "0x[0-9a-fA-F]{6}|#[0-9a-fA-F]{3,6}";
|
|
42295
42495
|
function hardcodedColors() {
|
|
42296
42496
|
const ignoreGlobs = loadConfig().hardcodedColors?.ignore ?? [];
|
|
42297
42497
|
try {
|
|
42298
|
-
const output =
|
|
42498
|
+
const output = execFileSync31("grep", ["-rEnH", "-f", "-", "src/"], {
|
|
42299
42499
|
encoding: "utf8",
|
|
42300
42500
|
input: `${pattern}
|
|
42301
42501
|
`
|
|
@@ -43078,11 +43278,11 @@ ${buildWatchReport(from)}`);
|
|
|
43078
43278
|
}
|
|
43079
43279
|
|
|
43080
43280
|
// src/commands/watch/consumeMarker.ts
|
|
43081
|
-
import { existsSync as existsSync83, rmSync as
|
|
43281
|
+
import { existsSync as existsSync83, rmSync as rmSync11 } from "fs";
|
|
43082
43282
|
function consumeMarker(path108) {
|
|
43083
43283
|
try {
|
|
43084
43284
|
if (!existsSync83(path108)) return false;
|
|
43085
|
-
|
|
43285
|
+
rmSync11(path108);
|
|
43086
43286
|
return true;
|
|
43087
43287
|
} catch {
|
|
43088
43288
|
return false;
|
|
@@ -43259,10 +43459,10 @@ function registerWatchWait(watchCommand) {
|
|
|
43259
43459
|
}
|
|
43260
43460
|
|
|
43261
43461
|
// src/commands/watch/simulateDivergence.ts
|
|
43262
|
-
import { writeFileSync as
|
|
43462
|
+
import { writeFileSync as writeFileSync52 } from "fs";
|
|
43263
43463
|
function simulateDivergence() {
|
|
43264
43464
|
try {
|
|
43265
|
-
|
|
43465
|
+
writeFileSync52(simulatedDivergencePath(), "");
|
|
43266
43466
|
console.log(
|
|
43267
43467
|
`the next assist watch wait poll in ${runGit3(["rev-parse", "--show-toplevel"])} will exit 3 as a simulated divergence`
|
|
43268
43468
|
);
|
|
@@ -43514,9 +43714,9 @@ async function auth() {
|
|
|
43514
43714
|
}
|
|
43515
43715
|
|
|
43516
43716
|
// src/commands/roam/postRoamActivity.ts
|
|
43517
|
-
import { execFileSync as
|
|
43717
|
+
import { execFileSync as execFileSync32 } from "child_process";
|
|
43518
43718
|
import { readdirSync as readdirSync23, readFileSync as readFileSync65, statSync as statSync13 } from "fs";
|
|
43519
|
-
import { join as
|
|
43719
|
+
import { join as join101 } from "path";
|
|
43520
43720
|
function findPortFile(roamDir) {
|
|
43521
43721
|
let entries;
|
|
43522
43722
|
try {
|
|
@@ -43525,7 +43725,7 @@ function findPortFile(roamDir) {
|
|
|
43525
43725
|
return void 0;
|
|
43526
43726
|
}
|
|
43527
43727
|
const candidates = entries.filter((name) => /^roam-local-api(-[^.]+)?\.port$/.test(name)).map((name) => {
|
|
43528
|
-
const path108 =
|
|
43728
|
+
const path108 = join101(roamDir, name);
|
|
43529
43729
|
try {
|
|
43530
43730
|
return { path: path108, mtimeMs: statSync13(path108).mtimeMs };
|
|
43531
43731
|
} catch {
|
|
@@ -43542,7 +43742,7 @@ var PID_BY_APP = {
|
|
|
43542
43742
|
function postRoamActivity(app, event) {
|
|
43543
43743
|
const appData = process.env.APPDATA;
|
|
43544
43744
|
if (!appData) return;
|
|
43545
|
-
const portFile = findPortFile(
|
|
43745
|
+
const portFile = findPortFile(join101(appData, "Roam"));
|
|
43546
43746
|
if (!portFile) return;
|
|
43547
43747
|
let port;
|
|
43548
43748
|
try {
|
|
@@ -43553,7 +43753,7 @@ function postRoamActivity(app, event) {
|
|
|
43553
43753
|
const pid = PID_BY_APP[app] ?? 99999;
|
|
43554
43754
|
const url = `http://127.0.0.1:${port}/api/v1/activity/${app}/${event}?pid=${pid}`;
|
|
43555
43755
|
try {
|
|
43556
|
-
|
|
43756
|
+
execFileSync32("curl", ["-sf", "--max-time", "0.2", "-X", "POST", url], {
|
|
43557
43757
|
stdio: "ignore"
|
|
43558
43758
|
});
|
|
43559
43759
|
} catch {
|
|
@@ -43727,8 +43927,8 @@ function link2() {
|
|
|
43727
43927
|
}
|
|
43728
43928
|
|
|
43729
43929
|
// src/commands/run/add.ts
|
|
43730
|
-
import { mkdirSync as mkdirSync35, writeFileSync as
|
|
43731
|
-
import { join as
|
|
43930
|
+
import { mkdirSync as mkdirSync35, writeFileSync as writeFileSync53 } from "fs";
|
|
43931
|
+
import { join as join102 } from "path";
|
|
43732
43932
|
|
|
43733
43933
|
// src/commands/run/editRepoRunList.ts
|
|
43734
43934
|
async function editRepoRunList(repoName, cwd, edit2) {
|
|
@@ -43899,7 +44099,7 @@ function saveProjectRunConfig(entry) {
|
|
|
43899
44099
|
saveConfig(config);
|
|
43900
44100
|
}
|
|
43901
44101
|
function createCommandFile(name) {
|
|
43902
|
-
const dir =
|
|
44102
|
+
const dir = join102(".claude", "commands");
|
|
43903
44103
|
mkdirSync35(dir, { recursive: true });
|
|
43904
44104
|
const content = `---
|
|
43905
44105
|
description: Run ${name}
|
|
@@ -43907,8 +44107,8 @@ description: Run ${name}
|
|
|
43907
44107
|
|
|
43908
44108
|
Run \`assist run ${name} $ARGUMENTS 2>&1\`.
|
|
43909
44109
|
`;
|
|
43910
|
-
const filePath =
|
|
43911
|
-
|
|
44110
|
+
const filePath = join102(dir, `${name}.md`);
|
|
44111
|
+
writeFileSync53(filePath, content);
|
|
43912
44112
|
console.log(`Created command file: ${filePath}`);
|
|
43913
44113
|
}
|
|
43914
44114
|
async function add4() {
|
|
@@ -44013,7 +44213,7 @@ function registerRunAdd(runCommand) {
|
|
|
44013
44213
|
|
|
44014
44214
|
// src/commands/run/remove.ts
|
|
44015
44215
|
import { existsSync as existsSync84, unlinkSync as unlinkSync19 } from "fs";
|
|
44016
|
-
import { join as
|
|
44216
|
+
import { join as join103 } from "path";
|
|
44017
44217
|
|
|
44018
44218
|
// src/commands/run/removeRepoRunConfig.ts
|
|
44019
44219
|
function isNamed(entry, name) {
|
|
@@ -44031,7 +44231,7 @@ function removeRepoRunConfig(name, repoName, cwd = process.cwd()) {
|
|
|
44031
44231
|
|
|
44032
44232
|
// src/commands/run/remove.ts
|
|
44033
44233
|
function deleteCommandFile(name) {
|
|
44034
|
-
const filePath =
|
|
44234
|
+
const filePath = join103(".claude", "commands", `${name}.md`);
|
|
44035
44235
|
if (existsSync84(filePath)) {
|
|
44036
44236
|
unlinkSync19(filePath);
|
|
44037
44237
|
console.log(`Deleted command file: ${filePath}`);
|
|
@@ -44101,11 +44301,11 @@ function formatLink(link3) {
|
|
|
44101
44301
|
}
|
|
44102
44302
|
|
|
44103
44303
|
// src/commands/sessions/daemon/listDaemonPids.ts
|
|
44104
|
-
import { execFileSync as
|
|
44304
|
+
import { execFileSync as execFileSync33 } from "child_process";
|
|
44105
44305
|
function listDaemonPids() {
|
|
44106
44306
|
if (process.platform === "win32") return [];
|
|
44107
44307
|
try {
|
|
44108
|
-
const out =
|
|
44308
|
+
const out = execFileSync33("ps", ["-eo", "pid=,args="], {
|
|
44109
44309
|
encoding: "utf8"
|
|
44110
44310
|
});
|
|
44111
44311
|
return out.split("\n").filter((line) => line.includes("assist") && / daemon run\b/.test(line)).map((line) => Number.parseInt(line.trim(), 10)).filter((pid) => Number.isInteger(pid));
|
|
@@ -44567,7 +44767,7 @@ function broadcastSessions(sessions, clients, linkedSessions = [], active) {
|
|
|
44567
44767
|
|
|
44568
44768
|
// src/commands/sessions/daemon/findServerParents.ts
|
|
44569
44769
|
import { existsSync as existsSync86 } from "fs";
|
|
44570
|
-
import { join as
|
|
44770
|
+
import { join as join104, resolve as resolve29 } from "path";
|
|
44571
44771
|
function isLive(session) {
|
|
44572
44772
|
return !!session.pty && session.status !== "done" && session.status !== "error";
|
|
44573
44773
|
}
|
|
@@ -44576,7 +44776,7 @@ function isLiveAgent(session) {
|
|
|
44576
44776
|
}
|
|
44577
44777
|
function serverRunDirs(sessions, file) {
|
|
44578
44778
|
return new Set(
|
|
44579
|
-
sessions.filter((s) => s.server && s.cwd && isLive(s)).map((s) => resolve29(s.cwd)).filter((dir) => existsSync86(
|
|
44779
|
+
sessions.filter((s) => s.server && s.cwd && isLive(s)).map((s) => resolve29(s.cwd)).filter((dir) => existsSync86(join104(dir, file)))
|
|
44580
44780
|
);
|
|
44581
44781
|
}
|
|
44582
44782
|
function findServerParents(sessions, file) {
|
|
@@ -44794,7 +44994,7 @@ function sendResizeSnapshot(s, send) {
|
|
|
44794
44994
|
}
|
|
44795
44995
|
|
|
44796
44996
|
// src/commands/sessions/daemon/viewerSize.ts
|
|
44797
|
-
import { readFileSync as readFileSync67, writeFileSync as
|
|
44997
|
+
import { readFileSync as readFileSync67, writeFileSync as writeFileSync54 } from "fs";
|
|
44798
44998
|
var DEFAULT_SIZE = { cols: 120, rows: 30 };
|
|
44799
44999
|
var remembered;
|
|
44800
45000
|
function rememberViewerSize(cols, rows) {
|
|
@@ -44802,7 +45002,7 @@ function rememberViewerSize(cols, rows) {
|
|
|
44802
45002
|
if (remembered?.cols === cols && remembered.rows === rows) return;
|
|
44803
45003
|
remembered = { cols, rows };
|
|
44804
45004
|
try {
|
|
44805
|
-
|
|
45005
|
+
writeFileSync54(daemonPaths.viewerSize, JSON.stringify(remembered));
|
|
44806
45006
|
} catch (error) {
|
|
44807
45007
|
daemonLog(
|
|
44808
45008
|
`viewer size ${cols}x${rows} not saved: ${error instanceof Error ? error.message : String(error)}`
|
|
@@ -45437,13 +45637,13 @@ function createRunSession(id, { runName, runArgs, cwd, meta }) {
|
|
|
45437
45637
|
}
|
|
45438
45638
|
|
|
45439
45639
|
// src/commands/sessions/daemon/autoUpdate/autoUpdateControl.ts
|
|
45440
|
-
import { existsSync as existsSync90, rmSync as
|
|
45640
|
+
import { existsSync as existsSync90, rmSync as rmSync12, writeFileSync as writeFileSync55 } from "fs";
|
|
45441
45641
|
var paused;
|
|
45442
45642
|
var wake;
|
|
45443
45643
|
function persist2(value) {
|
|
45444
45644
|
try {
|
|
45445
|
-
if (value)
|
|
45446
|
-
else
|
|
45645
|
+
if (value) writeFileSync55(daemonPaths.autoUpdatePaused, "");
|
|
45646
|
+
else rmSync12(daemonPaths.autoUpdatePaused, { force: true });
|
|
45447
45647
|
} catch {
|
|
45448
45648
|
}
|
|
45449
45649
|
}
|
|
@@ -45567,7 +45767,7 @@ async function runAutoUpdateLoop(deps2, maxLaps = Number.POSITIVE_INFINITY) {
|
|
|
45567
45767
|
}
|
|
45568
45768
|
|
|
45569
45769
|
// src/commands/sessions/daemon/autoUpdate/trimWatcherLog.ts
|
|
45570
|
-
import { readFileSync as readFileSync69, writeFileSync as
|
|
45770
|
+
import { readFileSync as readFileSync69, writeFileSync as writeFileSync56 } from "fs";
|
|
45571
45771
|
var KEEP_TAIL = 256 * 1024;
|
|
45572
45772
|
var MAX_LOG_SIZE = 4 * 1024 * 1024;
|
|
45573
45773
|
function trimWatcherLog(cwd) {
|
|
@@ -45579,7 +45779,7 @@ function trimWatcherLog(cwd) {
|
|
|
45579
45779
|
return;
|
|
45580
45780
|
}
|
|
45581
45781
|
if (log2.length <= MAX_LOG_SIZE) return;
|
|
45582
|
-
|
|
45782
|
+
writeFileSync56(path108, log2.slice(-KEEP_TAIL));
|
|
45583
45783
|
daemonLog(`auto-update: log ${path108} trimmed to its last ${KEEP_TAIL} chars`);
|
|
45584
45784
|
}
|
|
45585
45785
|
|
|
@@ -45829,12 +46029,12 @@ function noteAutoUpdate(installDir, text17) {
|
|
|
45829
46029
|
|
|
45830
46030
|
// src/commands/sessions/daemon/autoUpdate/runUpdateLap.ts
|
|
45831
46031
|
import { spawn as spawn11 } from "child_process";
|
|
45832
|
-
import { rmSync as
|
|
46032
|
+
import { rmSync as rmSync13 } from "fs";
|
|
45833
46033
|
function clearLapSignals(cwd) {
|
|
45834
46034
|
const control = watchControlPaths(cwd);
|
|
45835
46035
|
if (!control) return;
|
|
45836
46036
|
for (const path108 of [control.check, control.stop])
|
|
45837
|
-
|
|
46037
|
+
rmSync13(path108, { force: true });
|
|
45838
46038
|
}
|
|
45839
46039
|
function runUpdateLap(cwd, onOutput) {
|
|
45840
46040
|
clearLapSignals(cwd);
|
|
@@ -45943,12 +46143,12 @@ import { basename as basename30 } from "path";
|
|
|
45943
46143
|
|
|
45944
46144
|
// src/commands/sessions/daemon/worktree/deleteStrandedTree.ts
|
|
45945
46145
|
import { existsSync as existsSync92 } from "fs";
|
|
45946
|
-
import { join as
|
|
46146
|
+
import { join as join108 } from "path";
|
|
45947
46147
|
|
|
45948
46148
|
// src/commands/sessions/daemon/worktree/deleteTreeDirectly.ts
|
|
45949
46149
|
import { statSync as statSync15 } from "fs";
|
|
45950
46150
|
import { rm as rm3 } from "fs/promises";
|
|
45951
|
-
import { join as
|
|
46151
|
+
import { join as join107 } from "path";
|
|
45952
46152
|
async function deleteTreeDirectly(clone, worktreePath, why) {
|
|
45953
46153
|
if (holdsAGitDirectoryRatherThanALink(worktreePath)) {
|
|
45954
46154
|
const refusal = "it is a clone of its own, not a linked worktree";
|
|
@@ -45976,7 +46176,7 @@ async function deleteTreeDirectly(clone, worktreePath, why) {
|
|
|
45976
46176
|
return { removed: true };
|
|
45977
46177
|
}
|
|
45978
46178
|
function holdsAGitDirectoryRatherThanALink(worktreePath) {
|
|
45979
|
-
return statSync15(
|
|
46179
|
+
return statSync15(join107(worktreePath, ".git"), {
|
|
45980
46180
|
throwIfNoEntry: false
|
|
45981
46181
|
})?.isDirectory() === true;
|
|
45982
46182
|
}
|
|
@@ -46012,7 +46212,7 @@ async function deleteStrandedTree(clone, worktreePath, cause) {
|
|
|
46012
46212
|
);
|
|
46013
46213
|
}
|
|
46014
46214
|
function strandedReason(worktreePath, cause) {
|
|
46015
|
-
if (!existsSync92(
|
|
46215
|
+
if (!existsSync92(join108(worktreePath, ".git")))
|
|
46016
46216
|
return "its .git link is already gone";
|
|
46017
46217
|
if (/not a working tree|not a git repository/i.test(reason2(cause)))
|
|
46018
46218
|
return "git no longer recognises it as a working tree";
|
|
@@ -48386,7 +48586,7 @@ function releaseClient(client, clients, prPreview, verify) {
|
|
|
48386
48586
|
}
|
|
48387
48587
|
|
|
48388
48588
|
// src/commands/sessions/daemon/findPortHolderPid.ts
|
|
48389
|
-
import { execFileSync as
|
|
48589
|
+
import { execFileSync as execFileSync34 } from "child_process";
|
|
48390
48590
|
var PROBE_TIMEOUT_MS = 3e3;
|
|
48391
48591
|
function findPortHolderPid(port) {
|
|
48392
48592
|
try {
|
|
@@ -48396,7 +48596,7 @@ function findPortHolderPid(port) {
|
|
|
48396
48596
|
}
|
|
48397
48597
|
}
|
|
48398
48598
|
function probe(command, args) {
|
|
48399
|
-
return
|
|
48599
|
+
return execFileSync34(command, args, {
|
|
48400
48600
|
encoding: "utf8",
|
|
48401
48601
|
timeout: PROBE_TIMEOUT_MS,
|
|
48402
48602
|
stdio: ["ignore", "pipe", "ignore"]
|
|
@@ -48583,10 +48783,10 @@ function deferralNotice(persisted, cap2) {
|
|
|
48583
48783
|
|
|
48584
48784
|
// src/commands/sessions/daemon/worktree/underTempRoot.ts
|
|
48585
48785
|
import { realpathSync as realpathSync3 } from "fs";
|
|
48586
|
-
import { tmpdir as
|
|
48786
|
+
import { tmpdir as tmpdir8 } from "os";
|
|
48587
48787
|
import { sep as sep5 } from "path";
|
|
48588
48788
|
function tempRoots() {
|
|
48589
|
-
const raw =
|
|
48789
|
+
const raw = tmpdir8();
|
|
48590
48790
|
const roots = /* @__PURE__ */ new Set([raw]);
|
|
48591
48791
|
try {
|
|
48592
48792
|
roots.add(realpathSync3(raw));
|
|
@@ -50402,7 +50602,7 @@ import { existsSync as existsSync100 } from "fs";
|
|
|
50402
50602
|
|
|
50403
50603
|
// src/commands/sessions/daemon/worktree/carryTranscriptToTree.ts
|
|
50404
50604
|
import { copyFileSync as copyFileSync4, existsSync as existsSync99, mkdirSync as mkdirSync39 } from "fs";
|
|
50405
|
-
import { join as
|
|
50605
|
+
import { join as join109 } from "path";
|
|
50406
50606
|
function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
50407
50607
|
const dir = projectDirForCwd(toCwd);
|
|
50408
50608
|
if (dir === projectDirForCwd(fromCwd)) {
|
|
@@ -50411,7 +50611,7 @@ function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
|
50411
50611
|
);
|
|
50412
50612
|
return;
|
|
50413
50613
|
}
|
|
50414
|
-
const dest =
|
|
50614
|
+
const dest = join109(dir, `${claudeSessionId}.jsonl`);
|
|
50415
50615
|
if (existsSync99(dest)) {
|
|
50416
50616
|
daemonLog(`transcript ${claudeSessionId} already present in ${dir}`);
|
|
50417
50617
|
return;
|
|
@@ -50725,10 +50925,10 @@ function autoUpdateReply() {
|
|
|
50725
50925
|
}
|
|
50726
50926
|
|
|
50727
50927
|
// src/commands/sessions/daemon/autoUpdate/applyAutoUpdateAction.ts
|
|
50728
|
-
import { rmSync as
|
|
50928
|
+
import { rmSync as rmSync14, writeFileSync as writeFileSync57 } from "fs";
|
|
50729
50929
|
function signalLap(installDir, marker2) {
|
|
50730
50930
|
const control = watchControlPaths(installDir);
|
|
50731
|
-
if (control)
|
|
50931
|
+
if (control) writeFileSync57(control[marker2], "");
|
|
50732
50932
|
}
|
|
50733
50933
|
function applyAutoUpdateAction(action) {
|
|
50734
50934
|
const installDir = getInstallDir();
|
|
@@ -50736,7 +50936,7 @@ function applyAutoUpdateAction(action) {
|
|
|
50736
50936
|
if (action === "resume") {
|
|
50737
50937
|
if (!autoUpdateControl.paused()) return void 0;
|
|
50738
50938
|
const control = watchControlPaths(installDir);
|
|
50739
|
-
if (control)
|
|
50939
|
+
if (control) rmSync14(control.stop, { force: true });
|
|
50740
50940
|
autoUpdateControl.setPaused(false);
|
|
50741
50941
|
noteAutoUpdate(installDir, "resumed from Updates");
|
|
50742
50942
|
return void 0;
|
|
@@ -51660,7 +51860,7 @@ function handleConnection(socket, manager) {
|
|
|
51660
51860
|
}
|
|
51661
51861
|
|
|
51662
51862
|
// src/commands/sessions/daemon/onListening.ts
|
|
51663
|
-
import { unlinkSync as unlinkSync20, writeFileSync as
|
|
51863
|
+
import { unlinkSync as unlinkSync20, writeFileSync as writeFileSync58 } from "fs";
|
|
51664
51864
|
|
|
51665
51865
|
// src/commands/sessions/daemon/startPidFileWatchdog.ts
|
|
51666
51866
|
import { readFileSync as readFileSync70 } from "fs";
|
|
@@ -51682,7 +51882,7 @@ function ownsPidFile() {
|
|
|
51682
51882
|
|
|
51683
51883
|
// src/commands/sessions/daemon/onListening.ts
|
|
51684
51884
|
function onListening(manager, checkAutoExit) {
|
|
51685
|
-
|
|
51885
|
+
writeFileSync58(daemonPaths.pid, String(process.pid));
|
|
51686
51886
|
startPidFileWatchdog(() => {
|
|
51687
51887
|
daemonLog("lost daemon.pid ownership; shutting down sessions and exiting");
|
|
51688
51888
|
void manager.flushActiveMs().finally(() => {
|