@staff0rd/assist 0.676.0 → 0.678.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 +2 -2
- package/claude/settings.json +1 -1
- package/dist/commands/sessions/web/bundle.js +435 -434
- package/dist/index.js +625 -353
- 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.678.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -5270,7 +5270,7 @@ async function activity(options2) {
|
|
|
5270
5270
|
console.log("Not enough data points to chart.");
|
|
5271
5271
|
return;
|
|
5272
5272
|
}
|
|
5273
|
-
const total = data.reduce((
|
|
5273
|
+
const total = data.reduce((sum3, d) => sum3 + d.count, 0);
|
|
5274
5274
|
const activeDays = data.filter((d) => d.count > 0).length;
|
|
5275
5275
|
console.log(`${total} commits across ${activeDays} active days.`);
|
|
5276
5276
|
const weekly = /* @__PURE__ */ new Map();
|
|
@@ -6347,16 +6347,16 @@ async function copyTableOut(client, table) {
|
|
|
6347
6347
|
|
|
6348
6348
|
// src/commands/backlog/dump/groupColumns.ts
|
|
6349
6349
|
function groupColumns(rows) {
|
|
6350
|
-
const
|
|
6350
|
+
const byName2 = /* @__PURE__ */ new Map();
|
|
6351
6351
|
for (const { table_name, quoted_table, quoted_column } of rows) {
|
|
6352
|
-
let entry =
|
|
6352
|
+
let entry = byName2.get(table_name);
|
|
6353
6353
|
if (!entry) {
|
|
6354
6354
|
entry = { raw: table_name, table: { name: quoted_table, columns: [] } };
|
|
6355
|
-
|
|
6355
|
+
byName2.set(table_name, entry);
|
|
6356
6356
|
}
|
|
6357
6357
|
entry.table.columns.push(quoted_column);
|
|
6358
6358
|
}
|
|
6359
|
-
return [...
|
|
6359
|
+
return [...byName2.values()];
|
|
6360
6360
|
}
|
|
6361
6361
|
|
|
6362
6362
|
// src/commands/backlog/dump/orderDumpTables.ts
|
|
@@ -11856,9 +11856,9 @@ async function groupedCounts(cwd, groups) {
|
|
|
11856
11856
|
(group) => execGit(cwd, ["diff", "--name-status", group.base, "--", ...group.paths])
|
|
11857
11857
|
)
|
|
11858
11858
|
);
|
|
11859
|
-
const
|
|
11860
|
-
|
|
11861
|
-
return
|
|
11859
|
+
const counts2 = parseDiffNameStatus(outputs.join(""));
|
|
11860
|
+
counts2.new.push(...await untrackedPaths(cwd));
|
|
11861
|
+
return counts2;
|
|
11862
11862
|
}
|
|
11863
11863
|
|
|
11864
11864
|
// src/commands/sessions/web/parseGitStatus.ts
|
|
@@ -11911,12 +11911,12 @@ async function gitStatus(req, res) {
|
|
|
11911
11911
|
respondJson(res, 200, { ...await workingTreeCounts(cwd), ...branch2 });
|
|
11912
11912
|
return;
|
|
11913
11913
|
}
|
|
11914
|
-
const [
|
|
11914
|
+
const [counts2, uncommitted] = await Promise.all([
|
|
11915
11915
|
groupedCounts(cwd, changeSet.groups),
|
|
11916
11916
|
workingTreeCounts(cwd)
|
|
11917
11917
|
]);
|
|
11918
11918
|
respondJson(res, 200, {
|
|
11919
|
-
...
|
|
11919
|
+
...counts2,
|
|
11920
11920
|
...branch2,
|
|
11921
11921
|
uncommitted,
|
|
11922
11922
|
hasCommits: changeSet.commits.length > 0
|
|
@@ -11975,8 +11975,8 @@ function subsequenceScore(text18, query) {
|
|
|
11975
11975
|
function scoreFilePath(path91, query) {
|
|
11976
11976
|
const needle = query.trim().toLowerCase();
|
|
11977
11977
|
if (!needle) return 0;
|
|
11978
|
-
const
|
|
11979
|
-
const inBasename = subsequenceScore(
|
|
11978
|
+
const basename30 = path91.slice(path91.lastIndexOf("/") + 1);
|
|
11979
|
+
const inBasename = subsequenceScore(basename30, needle);
|
|
11980
11980
|
if (inBasename !== null) return BASENAME_WEIGHT + inBasename;
|
|
11981
11981
|
return subsequenceScore(path91, needle);
|
|
11982
11982
|
}
|
|
@@ -15033,7 +15033,7 @@ async function importBacklog(file, options2 = {}) {
|
|
|
15033
15033
|
return;
|
|
15034
15034
|
}
|
|
15035
15035
|
await restore(client, parsed);
|
|
15036
|
-
const total = incoming.reduce((
|
|
15036
|
+
const total = incoming.reduce((sum3, n) => sum3 + n, 0);
|
|
15037
15037
|
console.error(
|
|
15038
15038
|
chalk75.green(
|
|
15039
15039
|
`Imported backlog: ${total} rows restored across ${tables.length} tables.`
|
|
@@ -17559,6 +17559,10 @@ var BUILTIN_DENIES = [
|
|
|
17559
17559
|
{
|
|
17560
17560
|
pattern: "git commit",
|
|
17561
17561
|
message: `Do not run 'git commit' directly. Use 'assist commit "<message>"' instead.`
|
|
17562
|
+
},
|
|
17563
|
+
{
|
|
17564
|
+
pattern: "npm run",
|
|
17565
|
+
message: "Do not run 'npm run' directly. Use 'assist run <name>' for a configured command, or 'assist verify' / 'assist build'. If this repo genuinely needs npm run, set cliHook.blockNpmRun to false in its assist.yml."
|
|
17562
17566
|
}
|
|
17563
17567
|
];
|
|
17564
17568
|
var GH_ISSUE_API_MESSAGE = "Do not write to GitHub issue endpoints with 'gh api' \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.";
|
|
@@ -19861,7 +19865,7 @@ async function sloc(pattern2 = "**/*.ts", options2 = {}) {
|
|
|
19861
19865
|
const color = exceedsThreshold ? chalk132.red : chalk132.white;
|
|
19862
19866
|
console.log(`${color(file)} \u2192 ${chalk132.cyan(lines2)} lines`);
|
|
19863
19867
|
}
|
|
19864
|
-
const total = results.reduce((
|
|
19868
|
+
const total = results.reduce((sum3, r) => sum3 + r.lines, 0);
|
|
19865
19869
|
console.log(
|
|
19866
19870
|
chalk132.dim(`
|
|
19867
19871
|
Total: ${total} lines across ${files.length} files`)
|
|
@@ -21711,14 +21715,14 @@ import fs29 from "fs";
|
|
|
21711
21715
|
|
|
21712
21716
|
// src/commands/editHook/introducedComments.ts
|
|
21713
21717
|
function introducedComments(added, removed) {
|
|
21714
|
-
const
|
|
21718
|
+
const counts2 = /* @__PURE__ */ new Map();
|
|
21715
21719
|
for (const comment3 of removed) {
|
|
21716
|
-
|
|
21720
|
+
counts2.set(comment3, (counts2.get(comment3) ?? 0) + 1);
|
|
21717
21721
|
}
|
|
21718
21722
|
const candidates = [];
|
|
21719
21723
|
for (const comment3 of added) {
|
|
21720
|
-
const remaining =
|
|
21721
|
-
if (remaining > 0)
|
|
21724
|
+
const remaining = counts2.get(comment3) ?? 0;
|
|
21725
|
+
if (remaining > 0) counts2.set(comment3, remaining - 1);
|
|
21722
21726
|
else candidates.push(comment3);
|
|
21723
21727
|
}
|
|
21724
21728
|
const removedWords = new Set(removed.flatMap(commentWords));
|
|
@@ -22073,7 +22077,7 @@ function fetchOrgRepoCommitCounts(org, since) {
|
|
|
22073
22077
|
// src/commands/github/fetchRepoCommitAuthors.ts
|
|
22074
22078
|
var HISTORY_QUERY = `query($org: String!, $repo: String!, $since: GitTimestamp!, $cursor: String) { repository(owner: $org, name: $repo) { defaultBranchRef { target { ... on Commit { history(since: $since, first: 100, after: $cursor) { pageInfo { hasNextPage endCursor } nodes { author { user { login } name } } } } } } } }`;
|
|
22075
22079
|
function fetchRepoCommitAuthors(org, repo, since) {
|
|
22076
|
-
const
|
|
22080
|
+
const counts2 = /* @__PURE__ */ new Map();
|
|
22077
22081
|
let cursor;
|
|
22078
22082
|
for (; ; ) {
|
|
22079
22083
|
const vars = { org, repo, since };
|
|
@@ -22085,12 +22089,12 @@ function fetchRepoCommitAuthors(org, repo, since) {
|
|
|
22085
22089
|
if (!history) break;
|
|
22086
22090
|
for (const node of history.nodes) {
|
|
22087
22091
|
const author = node.author?.user?.login ?? node.author?.name ?? "unknown";
|
|
22088
|
-
|
|
22092
|
+
counts2.set(author, (counts2.get(author) ?? 0) + 1);
|
|
22089
22093
|
}
|
|
22090
22094
|
if (!history.pageInfo.hasNextPage) break;
|
|
22091
22095
|
cursor = history.pageInfo.endCursor ?? void 0;
|
|
22092
22096
|
}
|
|
22093
|
-
return [...
|
|
22097
|
+
return [...counts2].map(([author, commitCount]) => ({ author, commitCount })).sort((a, b) => b.commitCount - a.commitCount);
|
|
22094
22098
|
}
|
|
22095
22099
|
|
|
22096
22100
|
// src/commands/github/printCountTable.ts
|
|
@@ -30290,8 +30294,8 @@ function findRootParent(file, importedBy, visited) {
|
|
|
30290
30294
|
function clusterFiles(graph) {
|
|
30291
30295
|
const clusters = /* @__PURE__ */ new Map();
|
|
30292
30296
|
for (const file of graph.files) {
|
|
30293
|
-
const
|
|
30294
|
-
if (
|
|
30297
|
+
const basename30 = path62.basename(file, path62.extname(file));
|
|
30298
|
+
if (basename30 === "index") continue;
|
|
30295
30299
|
const importers = graph.importedBy.get(file);
|
|
30296
30300
|
if (!importers || importers.size !== 1) continue;
|
|
30297
30301
|
const parent = [...importers][0];
|
|
@@ -30601,50 +30605,109 @@ async function checkoutOnlySession(number) {
|
|
|
30601
30605
|
await done2;
|
|
30602
30606
|
}
|
|
30603
30607
|
|
|
30604
|
-
// src/commands/review/
|
|
30605
|
-
import
|
|
30606
|
-
function
|
|
30607
|
-
|
|
30608
|
-
|
|
30609
|
-
|
|
30608
|
+
// src/commands/review/highLevel/announceSavedReview.ts
|
|
30609
|
+
import chalk212 from "chalk";
|
|
30610
|
+
function announceSavedReview(subject, force) {
|
|
30611
|
+
const head = subject.headSha.slice(0, 7);
|
|
30612
|
+
if (subject.saved)
|
|
30613
|
+
console.log(
|
|
30614
|
+
chalk212.dim(
|
|
30615
|
+
`Reopening the review saved for ${head} at ${subject.saved.reviewedAt} (${subject.saved.verdict}); pass --force to start fresh.`
|
|
30616
|
+
)
|
|
30617
|
+
);
|
|
30618
|
+
else if (force)
|
|
30619
|
+
console.log(
|
|
30620
|
+
chalk212.dim(
|
|
30621
|
+
`Discarding any review saved for ${head} and starting fresh (--force).`
|
|
30622
|
+
)
|
|
30623
|
+
);
|
|
30610
30624
|
}
|
|
30611
|
-
|
|
30612
|
-
|
|
30613
|
-
|
|
30614
|
-
|
|
30615
|
-
|
|
30616
|
-
|
|
30617
|
-
|
|
30618
|
-
|
|
30619
|
-
|
|
30620
|
-
|
|
30625
|
+
|
|
30626
|
+
// src/commands/review/highLevel/groupFilesByDirectory.ts
|
|
30627
|
+
var emptyDirectoryGroup = () => ({
|
|
30628
|
+
dirs: /* @__PURE__ */ new Map(),
|
|
30629
|
+
files: []
|
|
30630
|
+
});
|
|
30631
|
+
function place(root, file) {
|
|
30632
|
+
const segments = file.path.split("/").filter(Boolean);
|
|
30633
|
+
segments.pop();
|
|
30634
|
+
let at2 = root;
|
|
30635
|
+
for (const segment of segments) {
|
|
30636
|
+
const next3 = at2.dirs.get(segment) ?? emptyDirectoryGroup();
|
|
30637
|
+
at2.dirs.set(segment, next3);
|
|
30638
|
+
at2 = next3;
|
|
30639
|
+
}
|
|
30640
|
+
at2.files.push(file);
|
|
30641
|
+
}
|
|
30642
|
+
function groupFilesByDirectory(files) {
|
|
30643
|
+
const root = emptyDirectoryGroup();
|
|
30644
|
+
for (const file of files) place(root, file);
|
|
30645
|
+
return root;
|
|
30646
|
+
}
|
|
30647
|
+
|
|
30648
|
+
// src/commands/review/highLevel/buildHighLevelTree.ts
|
|
30649
|
+
function basename20(path91) {
|
|
30650
|
+
return path91.slice(path91.lastIndexOf("/") + 1);
|
|
30651
|
+
}
|
|
30652
|
+
function sum(nodes, key) {
|
|
30653
|
+
return nodes.reduce((total, node) => total + node[key], 0);
|
|
30654
|
+
}
|
|
30655
|
+
function byName(a, b) {
|
|
30656
|
+
return a.name.localeCompare(b.name);
|
|
30657
|
+
}
|
|
30658
|
+
function nodesOf(at2, prefix2) {
|
|
30659
|
+
const dirs = [...at2.dirs].map(
|
|
30660
|
+
([name, child]) => collapsedDirNode(name, child, prefix2)
|
|
30661
|
+
);
|
|
30662
|
+
const files = at2.files.map(
|
|
30663
|
+
(file) => ({
|
|
30664
|
+
kind: "file",
|
|
30665
|
+
name: basename20(file.path),
|
|
30666
|
+
...file
|
|
30667
|
+
})
|
|
30621
30668
|
);
|
|
30622
|
-
|
|
30623
|
-
|
|
30624
|
-
|
|
30625
|
-
|
|
30626
|
-
|
|
30627
|
-
|
|
30628
|
-
|
|
30669
|
+
return [...dirs.sort(byName), ...files.sort(byName)];
|
|
30670
|
+
}
|
|
30671
|
+
function collapsedDirNode(name, at2, prefix2) {
|
|
30672
|
+
let label2 = name;
|
|
30673
|
+
let path91 = prefix2 ? `${prefix2}/${name}` : name;
|
|
30674
|
+
let node = at2;
|
|
30675
|
+
while (node.files.length === 0 && node.dirs.size === 1) {
|
|
30676
|
+
const [childName, child] = [...node.dirs][0];
|
|
30677
|
+
label2 = `${label2}/${childName}`;
|
|
30678
|
+
path91 = `${path91}/${childName}`;
|
|
30679
|
+
node = child;
|
|
30629
30680
|
}
|
|
30681
|
+
const children = nodesOf(node, path91);
|
|
30630
30682
|
return {
|
|
30631
|
-
|
|
30632
|
-
|
|
30633
|
-
|
|
30634
|
-
|
|
30635
|
-
|
|
30683
|
+
kind: "dir",
|
|
30684
|
+
name: label2,
|
|
30685
|
+
path: path91,
|
|
30686
|
+
additions: sum(children, "additions"),
|
|
30687
|
+
deletions: sum(children, "deletions"),
|
|
30688
|
+
children
|
|
30636
30689
|
};
|
|
30637
30690
|
}
|
|
30638
|
-
function
|
|
30639
|
-
|
|
30640
|
-
|
|
30641
|
-
|
|
30642
|
-
|
|
30643
|
-
|
|
30644
|
-
|
|
30645
|
-
|
|
30646
|
-
|
|
30647
|
-
return
|
|
30691
|
+
function buildHighLevelTree(files) {
|
|
30692
|
+
return nodesOf(groupFilesByDirectory(files), "");
|
|
30693
|
+
}
|
|
30694
|
+
|
|
30695
|
+
// src/commands/review/highLevel/buildHighLevelStructure.ts
|
|
30696
|
+
function sum2(files, key) {
|
|
30697
|
+
return files.reduce((total, file) => total + file[key], 0);
|
|
30698
|
+
}
|
|
30699
|
+
function countOf(files, status3) {
|
|
30700
|
+
return files.filter((file) => file.status === status3).length;
|
|
30701
|
+
}
|
|
30702
|
+
function buildHighLevelStructure(files) {
|
|
30703
|
+
return {
|
|
30704
|
+
tree: buildHighLevelTree(files),
|
|
30705
|
+
added: countOf(files, "added"),
|
|
30706
|
+
removed: countOf(files, "removed"),
|
|
30707
|
+
modified: countOf(files, "modified"),
|
|
30708
|
+
additions: sum2(files, "additions"),
|
|
30709
|
+
deletions: sum2(files, "deletions")
|
|
30710
|
+
};
|
|
30648
30711
|
}
|
|
30649
30712
|
|
|
30650
30713
|
// src/commands/review/highLevel/checkDescriptionLinksIssue.ts
|
|
@@ -30808,6 +30871,37 @@ function evaluateHighLevelChecks(subject) {
|
|
|
30808
30871
|
});
|
|
30809
30872
|
}
|
|
30810
30873
|
|
|
30874
|
+
// src/commands/review/highLevel/fetchHighLevelFiles.ts
|
|
30875
|
+
import { execSync as execSync58 } from "child_process";
|
|
30876
|
+
import { createHash as createHash3 } from "crypto";
|
|
30877
|
+
var JQ = ".[] | {filename,status,additions,deletions,patch} | @json";
|
|
30878
|
+
function toStatus(status3) {
|
|
30879
|
+
if (status3 === "added") return "added";
|
|
30880
|
+
if (status3 === "removed") return "removed";
|
|
30881
|
+
return "modified";
|
|
30882
|
+
}
|
|
30883
|
+
function diffUrl(repo, prNumber, path91) {
|
|
30884
|
+
const anchor = createHash3("sha256").update(path91).digest("hex");
|
|
30885
|
+
return `https://github.com/${repo}/pull/${prNumber}/files#diff-${anchor}`;
|
|
30886
|
+
}
|
|
30887
|
+
function fetchHighLevelFiles(prNumber, repo) {
|
|
30888
|
+
const out = execSync58(
|
|
30889
|
+
`gh api repos/${repo}/pulls/${prNumber}/files --paginate --jq '${JQ}'`,
|
|
30890
|
+
{ encoding: "utf8", maxBuffer: 64 * 1024 * 1024 }
|
|
30891
|
+
);
|
|
30892
|
+
return out.trim().split("\n").filter(Boolean).map((line) => {
|
|
30893
|
+
const file = JSON.parse(line);
|
|
30894
|
+
return {
|
|
30895
|
+
path: file.filename,
|
|
30896
|
+
status: toStatus(file.status),
|
|
30897
|
+
additions: file.additions,
|
|
30898
|
+
deletions: file.deletions,
|
|
30899
|
+
diffUrl: diffUrl(repo, prNumber, file.filename),
|
|
30900
|
+
...file.patch ? { patch: file.patch } : {}
|
|
30901
|
+
};
|
|
30902
|
+
});
|
|
30903
|
+
}
|
|
30904
|
+
|
|
30811
30905
|
// src/commands/review/highLevel/fetchHighLevelPr.ts
|
|
30812
30906
|
import { execSync as execSync59 } from "child_process";
|
|
30813
30907
|
function fetchHighLevelPr(prNumber, repo) {
|
|
@@ -30823,6 +30917,84 @@ function fetchHighLevelPr(prNumber, repo) {
|
|
|
30823
30917
|
};
|
|
30824
30918
|
}
|
|
30825
30919
|
|
|
30920
|
+
// src/commands/review/highLevel/loadHighLevelReview.ts
|
|
30921
|
+
import { existsSync as existsSync63, readFileSync as readFileSync47 } from "fs";
|
|
30922
|
+
|
|
30923
|
+
// src/commands/review/highLevel/highLevelReviewPath.ts
|
|
30924
|
+
import { join as join75 } from "path";
|
|
30925
|
+
function slug(value) {
|
|
30926
|
+
return value.replace(/[^\w.-]+/g, "-");
|
|
30927
|
+
}
|
|
30928
|
+
function highLevelReviewPath(repo, headRef, headSha) {
|
|
30929
|
+
return join75(
|
|
30930
|
+
getStoreDir(),
|
|
30931
|
+
"high-level-reviews",
|
|
30932
|
+
slug(repo),
|
|
30933
|
+
`${slug(headRef)}-${headSha}.json`
|
|
30934
|
+
);
|
|
30935
|
+
}
|
|
30936
|
+
|
|
30937
|
+
// src/commands/review/highLevel/loadHighLevelReview.ts
|
|
30938
|
+
function loadHighLevelReview(repo, headRef, headSha) {
|
|
30939
|
+
const path91 = highLevelReviewPath(repo, headRef, headSha);
|
|
30940
|
+
if (!existsSync63(path91)) return void 0;
|
|
30941
|
+
try {
|
|
30942
|
+
return JSON.parse(readFileSync47(path91, "utf8"));
|
|
30943
|
+
} catch {
|
|
30944
|
+
return void 0;
|
|
30945
|
+
}
|
|
30946
|
+
}
|
|
30947
|
+
|
|
30948
|
+
// src/commands/review/highLevel/resolveHighLevelConfig.ts
|
|
30949
|
+
var DEFAULT_DESCRIPTION_WORD_CAP = 300;
|
|
30950
|
+
function resolveHighLevelConfig(config) {
|
|
30951
|
+
const highLevel = config.review?.highLevel;
|
|
30952
|
+
return {
|
|
30953
|
+
criticalPaths: highLevel?.criticalPaths ?? [],
|
|
30954
|
+
uiPaths: highLevel?.uiPaths ?? [],
|
|
30955
|
+
descriptionWordCap: highLevel?.descriptionWordCap ?? DEFAULT_DESCRIPTION_WORD_CAP
|
|
30956
|
+
};
|
|
30957
|
+
}
|
|
30958
|
+
|
|
30959
|
+
// src/commands/review/highLevel/selectCriticalDiffs.ts
|
|
30960
|
+
import { minimatch as minimatch8 } from "minimatch";
|
|
30961
|
+
function selectCriticalDiffs(files, criticalPaths) {
|
|
30962
|
+
if (criticalPaths.length === 0) return [];
|
|
30963
|
+
return files.filter((file) => criticalPaths.some((glob) => minimatch8(file.path, glob))).map(({ path: path91, status: status3, additions, deletions, diffUrl: diffUrl2, patch: patch2 }) => ({
|
|
30964
|
+
path: path91,
|
|
30965
|
+
status: status3,
|
|
30966
|
+
additions,
|
|
30967
|
+
deletions,
|
|
30968
|
+
diffUrl: diffUrl2,
|
|
30969
|
+
patch: patch2 ?? null
|
|
30970
|
+
}));
|
|
30971
|
+
}
|
|
30972
|
+
|
|
30973
|
+
// src/commands/review/highLevel/gatherHighLevelSubject.ts
|
|
30974
|
+
function gatherHighLevelSubject(prNumber, force) {
|
|
30975
|
+
const { org, repo } = getRepoInfo();
|
|
30976
|
+
const slug2 = `${org}/${repo}`;
|
|
30977
|
+
const pr = fetchHighLevelPr(prNumber, { org, repo });
|
|
30978
|
+
const files = fetchHighLevelFiles(prNumber, slug2);
|
|
30979
|
+
const config = resolveHighLevelConfig(loadConfig());
|
|
30980
|
+
const saved = force ? void 0 : loadHighLevelReview(slug2, pr.headRef, pr.headSha);
|
|
30981
|
+
return {
|
|
30982
|
+
repo: slug2,
|
|
30983
|
+
prNumber,
|
|
30984
|
+
headRef: pr.headRef,
|
|
30985
|
+
headSha: pr.headSha,
|
|
30986
|
+
checks: evaluateHighLevelChecks({
|
|
30987
|
+
body: pr.body,
|
|
30988
|
+
changedFiles: files.map((file) => file.path),
|
|
30989
|
+
config
|
|
30990
|
+
}),
|
|
30991
|
+
structure: buildHighLevelStructure(files),
|
|
30992
|
+
criticalDiffs: selectCriticalDiffs(files, config.criticalPaths),
|
|
30993
|
+
criticalPaths: config.criticalPaths,
|
|
30994
|
+
...saved ? { saved } : {}
|
|
30995
|
+
};
|
|
30996
|
+
}
|
|
30997
|
+
|
|
30826
30998
|
// src/commands/review/highLevel/openHighLevelOverlay.ts
|
|
30827
30999
|
import { randomUUID as randomUUID17 } from "crypto";
|
|
30828
31000
|
|
|
@@ -30841,34 +31013,26 @@ function toItem2(check2, decision) {
|
|
|
30841
31013
|
};
|
|
30842
31014
|
}
|
|
30843
31015
|
function buildHighLevelRecord(subject, decision) {
|
|
30844
|
-
const { checks: checks2,
|
|
31016
|
+
const { checks: checks2, repo, prNumber, headRef, headSha } = subject;
|
|
30845
31017
|
return {
|
|
30846
|
-
|
|
31018
|
+
repo,
|
|
31019
|
+
prNumber,
|
|
31020
|
+
headRef,
|
|
31021
|
+
headSha,
|
|
30847
31022
|
verdict: decision.decision === "approve" ? "approve" : "request-changes",
|
|
30848
31023
|
reviewedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
30849
31024
|
items: checks2.map((check2) => toItem2(check2, decision))
|
|
30850
31025
|
};
|
|
30851
31026
|
}
|
|
30852
31027
|
|
|
30853
|
-
// src/commands/review/highLevel/
|
|
30854
|
-
|
|
30855
|
-
|
|
30856
|
-
|
|
30857
|
-
// src/commands/review/highLevel/highLevelReviewPath.ts
|
|
30858
|
-
import { join as join75 } from "path";
|
|
30859
|
-
function slug(value) {
|
|
30860
|
-
return value.replace(/[^\w.-]+/g, "-");
|
|
30861
|
-
}
|
|
30862
|
-
function highLevelReviewPath(repo, headRef, headSha) {
|
|
30863
|
-
return join75(
|
|
30864
|
-
getStoreDir(),
|
|
30865
|
-
"high-level-reviews",
|
|
30866
|
-
slug(repo),
|
|
30867
|
-
`${slug(headRef)}-${headSha}.json`
|
|
30868
|
-
);
|
|
31028
|
+
// src/commands/review/highLevel/highLevelChangedFileCount.ts
|
|
31029
|
+
function highLevelChangedFileCount(structure) {
|
|
31030
|
+
return structure.added + structure.removed + structure.modified;
|
|
30869
31031
|
}
|
|
30870
31032
|
|
|
30871
31033
|
// src/commands/review/highLevel/saveHighLevelReview.ts
|
|
31034
|
+
import { mkdirSync as mkdirSync21, writeFileSync as writeFileSync38 } from "fs";
|
|
31035
|
+
import { dirname as dirname34 } from "path";
|
|
30872
31036
|
function saveHighLevelReview(record) {
|
|
30873
31037
|
const path91 = highLevelReviewPath(record.repo, record.headRef, record.headSha);
|
|
30874
31038
|
mkdirSync21(dirname34(path91), { recursive: true });
|
|
@@ -30878,6 +31042,28 @@ function saveHighLevelReview(record) {
|
|
|
30878
31042
|
}
|
|
30879
31043
|
|
|
30880
31044
|
// src/commands/review/highLevel/openHighLevelOverlay.ts
|
|
31045
|
+
function payloadOf(subject) {
|
|
31046
|
+
const { checks: checks2, structure, criticalDiffs, criticalPaths, saved } = subject;
|
|
31047
|
+
return {
|
|
31048
|
+
checks: checks2,
|
|
31049
|
+
structure,
|
|
31050
|
+
criticalDiffs,
|
|
31051
|
+
criticalPaths,
|
|
31052
|
+
...saved ? { saved } : {}
|
|
31053
|
+
};
|
|
31054
|
+
}
|
|
31055
|
+
function metadataOf(subject) {
|
|
31056
|
+
return [
|
|
31057
|
+
{ label: "Branch", value: subject.headRef },
|
|
31058
|
+
{ label: "Head", value: subject.headSha.slice(0, 7) },
|
|
31059
|
+
{
|
|
31060
|
+
label: "Changed files",
|
|
31061
|
+
value: String(highLevelChangedFileCount(subject.structure))
|
|
31062
|
+
},
|
|
31063
|
+
{ label: "Critical files", value: String(subject.criticalDiffs.length) },
|
|
31064
|
+
...subject.saved ? [{ label: "Reopened from", value: subject.saved.reviewedAt }] : []
|
|
31065
|
+
];
|
|
31066
|
+
}
|
|
30881
31067
|
async function openHighLevelOverlay(sessionId, subject) {
|
|
30882
31068
|
const decision = await awaitPreviewApproval(
|
|
30883
31069
|
"High-level review",
|
|
@@ -30885,14 +31071,10 @@ async function openHighLevelOverlay(sessionId, subject) {
|
|
|
30885
31071
|
sessionId,
|
|
30886
31072
|
requestId: randomUUID17(),
|
|
30887
31073
|
title: `High-level review of ${subject.repo}#${subject.prNumber}`,
|
|
30888
|
-
body: JSON.stringify(subject
|
|
31074
|
+
body: JSON.stringify(payloadOf(subject)),
|
|
30889
31075
|
prNumber: subject.prNumber,
|
|
30890
31076
|
kind: "high-level-review",
|
|
30891
|
-
metadata:
|
|
30892
|
-
{ label: "Branch", value: subject.headRef },
|
|
30893
|
-
{ label: "Head", value: subject.headSha.slice(0, 7) },
|
|
30894
|
-
{ label: "Changed files", value: String(subject.changedFileCount) }
|
|
30895
|
-
]
|
|
31077
|
+
metadata: metadataOf(subject)
|
|
30896
31078
|
},
|
|
30897
31079
|
{ rejectIsOutcome: true }
|
|
30898
31080
|
);
|
|
@@ -30905,23 +31087,55 @@ async function openHighLevelOverlay(sessionId, subject) {
|
|
|
30905
31087
|
}
|
|
30906
31088
|
|
|
30907
31089
|
// src/commands/review/highLevel/printHighLevelChecklist.ts
|
|
31090
|
+
import chalk216 from "chalk";
|
|
31091
|
+
|
|
31092
|
+
// src/commands/review/highLevel/formatCriticalDiffs.ts
|
|
30908
31093
|
import chalk213 from "chalk";
|
|
31094
|
+
var PATCH_LINE_COLOURS = {
|
|
31095
|
+
"+": chalk213.green,
|
|
31096
|
+
"-": chalk213.red,
|
|
31097
|
+
"@": chalk213.cyan
|
|
31098
|
+
};
|
|
31099
|
+
function formatPatch(patch2) {
|
|
31100
|
+
return patch2.split("\n").map(
|
|
31101
|
+
(line) => ` ${(PATCH_LINE_COLOURS[line[0] ?? ""] ?? chalk213.dim)(line)}`
|
|
31102
|
+
);
|
|
31103
|
+
}
|
|
31104
|
+
function formatDiff(diff3) {
|
|
31105
|
+
return [
|
|
31106
|
+
"",
|
|
31107
|
+
` ${chalk213.bold(diff3.path)} ${chalk213.dim(`(${diff3.status})`)} ${chalk213.green(`+${diff3.additions}`)} ${chalk213.red(`-${diff3.deletions}`)}`,
|
|
31108
|
+
...diff3.patch === null ? [` ${chalk213.dim(`no diff available; see ${diff3.diffUrl}`)}`] : formatPatch(diff3.patch)
|
|
31109
|
+
];
|
|
31110
|
+
}
|
|
31111
|
+
function formatCriticalDiffs(diffs, criticalPaths) {
|
|
31112
|
+
if (criticalPaths.length === 0)
|
|
31113
|
+
return `${chalk213.bold.underline("Critical diffs")}
|
|
31114
|
+
${chalk213.dim("review.highLevel.criticalPaths is unset, so no diffs are shown")}`;
|
|
31115
|
+
if (diffs.length === 0)
|
|
31116
|
+
return `${chalk213.bold.underline("Critical diffs")}
|
|
31117
|
+
${chalk213.dim(`no changed file matches ${criticalPaths.join(", ")}`)}`;
|
|
31118
|
+
return [
|
|
31119
|
+
chalk213.bold.underline("Critical diffs"),
|
|
31120
|
+
...diffs.flatMap(formatDiff)
|
|
31121
|
+
].join("\n");
|
|
31122
|
+
}
|
|
30909
31123
|
|
|
30910
31124
|
// src/commands/review/highLevel/formatHighLevelChecklist.ts
|
|
30911
|
-
import
|
|
31125
|
+
import chalk214 from "chalk";
|
|
30912
31126
|
var MARKERS = {
|
|
30913
|
-
pass: () =>
|
|
30914
|
-
fail: () =>
|
|
30915
|
-
manual: () =>
|
|
31127
|
+
pass: () => chalk214.green("\u2714"),
|
|
31128
|
+
fail: () => chalk214.red("\u2718"),
|
|
31129
|
+
manual: () => chalk214.yellow("\u25A1")
|
|
30916
31130
|
};
|
|
30917
31131
|
function formatCheck(check2) {
|
|
30918
|
-
const title = check2.status === "fail" ?
|
|
31132
|
+
const title = check2.status === "fail" ? chalk214.red(check2.title) : chalk214.bold(check2.title);
|
|
30919
31133
|
return ` ${MARKERS[check2.status]()} ${title}
|
|
30920
|
-
${
|
|
31134
|
+
${chalk214.dim(check2.reason)}`;
|
|
30921
31135
|
}
|
|
30922
31136
|
function formatGroup(heading2, checks2) {
|
|
30923
31137
|
if (checks2.length === 0) return [];
|
|
30924
|
-
return ["",
|
|
31138
|
+
return ["", chalk214.bold.underline(heading2), ...checks2.map(formatCheck)];
|
|
30925
31139
|
}
|
|
30926
31140
|
function formatHighLevelChecklist(checks2) {
|
|
30927
31141
|
const deterministic = checks2.filter(
|
|
@@ -30930,7 +31144,7 @@ function formatHighLevelChecklist(checks2) {
|
|
|
30930
31144
|
const failed2 = deterministic.filter(
|
|
30931
31145
|
(check2) => check2.status === "fail"
|
|
30932
31146
|
).length;
|
|
30933
|
-
const summary = failed2 === 0 ?
|
|
31147
|
+
const summary = failed2 === 0 ? chalk214.green(`All ${deterministic.length} deterministic checks pass`) : chalk214.red(
|
|
30934
31148
|
`${failed2} of ${deterministic.length} deterministic checks fail`
|
|
30935
31149
|
);
|
|
30936
31150
|
return [
|
|
@@ -30944,36 +31158,63 @@ function formatHighLevelChecklist(checks2) {
|
|
|
30944
31158
|
].join("\n");
|
|
30945
31159
|
}
|
|
30946
31160
|
|
|
31161
|
+
// src/commands/review/highLevel/formatHighLevelStructure.ts
|
|
31162
|
+
import chalk215 from "chalk";
|
|
31163
|
+
var STATUS_MARKERS = {
|
|
31164
|
+
added: () => chalk215.green("A"),
|
|
31165
|
+
removed: () => chalk215.red("D"),
|
|
31166
|
+
modified: () => chalk215.yellow("M")
|
|
31167
|
+
};
|
|
31168
|
+
function counts(additions, deletions) {
|
|
31169
|
+
return `${chalk215.green(`+${additions}`)} ${chalk215.red(`-${deletions}`)}`;
|
|
31170
|
+
}
|
|
31171
|
+
function formatNode(node, indent3) {
|
|
31172
|
+
if (node.kind === "file")
|
|
31173
|
+
return [
|
|
31174
|
+
`${indent3}${STATUS_MARKERS[node.status]()} ${node.name} ${chalk215.dim(counts(node.additions, node.deletions))}`
|
|
31175
|
+
];
|
|
31176
|
+
const dir = node;
|
|
31177
|
+
return [
|
|
31178
|
+
`${indent3}${chalk215.bold(`${dir.name}/`)} ${chalk215.dim(counts(dir.additions, dir.deletions))}`,
|
|
31179
|
+
...dir.children.flatMap((child) => formatNode(child, `${indent3} `))
|
|
31180
|
+
];
|
|
31181
|
+
}
|
|
31182
|
+
function formatHighLevelStructure(structure) {
|
|
31183
|
+
const summary = `${structure.added} added \xB7 ${structure.removed} deleted \xB7 ${structure.modified} modified \xB7 ${counts(structure.additions, structure.deletions)}`;
|
|
31184
|
+
return [
|
|
31185
|
+
chalk215.bold.underline("Structure"),
|
|
31186
|
+
` ${summary}`,
|
|
31187
|
+
...structure.tree.flatMap((node) => formatNode(node, " "))
|
|
31188
|
+
].join("\n");
|
|
31189
|
+
}
|
|
31190
|
+
|
|
30947
31191
|
// src/commands/review/highLevel/printHighLevelChecklist.ts
|
|
30948
31192
|
function printHighLevelChecklist(subject) {
|
|
30949
31193
|
console.log(
|
|
30950
|
-
|
|
30951
|
-
|
|
31194
|
+
chalk216.bold(`High-level review of ${subject.repo}#${subject.prNumber}`),
|
|
31195
|
+
chalk216.dim(
|
|
31196
|
+
`\xB7 ${highLevelChangedFileCount(subject.structure)} changed files`
|
|
31197
|
+
)
|
|
30952
31198
|
);
|
|
30953
31199
|
console.log(formatHighLevelChecklist(subject.checks));
|
|
31200
|
+
console.log("");
|
|
31201
|
+
console.log(formatHighLevelStructure(subject.structure));
|
|
31202
|
+
console.log("");
|
|
30954
31203
|
console.log(
|
|
30955
|
-
|
|
31204
|
+
formatCriticalDiffs(subject.criticalDiffs, subject.criticalPaths)
|
|
31205
|
+
);
|
|
31206
|
+
console.log(
|
|
31207
|
+
chalk216.dim(
|
|
30956
31208
|
"\nManual items are for the reviewer to judge; see docs/high-level-review.md."
|
|
30957
31209
|
)
|
|
30958
31210
|
);
|
|
30959
31211
|
console.log(
|
|
30960
|
-
|
|
31212
|
+
chalk216.dim(
|
|
30961
31213
|
"Run this inside an assist session to step through the checklist in the web overlay."
|
|
30962
31214
|
)
|
|
30963
31215
|
);
|
|
30964
31216
|
}
|
|
30965
31217
|
|
|
30966
|
-
// src/commands/review/highLevel/resolveHighLevelConfig.ts
|
|
30967
|
-
var DEFAULT_DESCRIPTION_WORD_CAP = 300;
|
|
30968
|
-
function resolveHighLevelConfig(config) {
|
|
30969
|
-
const highLevel = config.review?.highLevel;
|
|
30970
|
-
return {
|
|
30971
|
-
criticalPaths: highLevel?.criticalPaths ?? [],
|
|
30972
|
-
uiPaths: highLevel?.uiPaths ?? [],
|
|
30973
|
-
descriptionWordCap: highLevel?.descriptionWordCap ?? DEFAULT_DESCRIPTION_WORD_CAP
|
|
30974
|
-
};
|
|
30975
|
-
}
|
|
30976
|
-
|
|
30977
31218
|
// src/commands/review/highLevel/runHighLevelReview.ts
|
|
30978
31219
|
function resolvePrNumber2(number) {
|
|
30979
31220
|
if (number === void 0) return getCurrentPrNumber();
|
|
@@ -30984,26 +31225,10 @@ function resolvePrNumber2(number) {
|
|
|
30984
31225
|
}
|
|
30985
31226
|
return parsed;
|
|
30986
31227
|
}
|
|
30987
|
-
function
|
|
30988
|
-
const
|
|
30989
|
-
const
|
|
30990
|
-
|
|
30991
|
-
const changedFiles2 = fetchPrChangedFiles(prNumber);
|
|
30992
|
-
return {
|
|
30993
|
-
repo: `${org}/${repo}`,
|
|
30994
|
-
prNumber,
|
|
30995
|
-
headRef: pr.headRef,
|
|
30996
|
-
headSha: pr.headSha,
|
|
30997
|
-
changedFileCount: changedFiles2.length,
|
|
30998
|
-
checks: evaluateHighLevelChecks({
|
|
30999
|
-
body: pr.body,
|
|
31000
|
-
changedFiles: changedFiles2,
|
|
31001
|
-
config: resolveHighLevelConfig(loadConfig())
|
|
31002
|
-
})
|
|
31003
|
-
};
|
|
31004
|
-
}
|
|
31005
|
-
async function runHighLevelReview(number) {
|
|
31006
|
-
const subject = gather(number);
|
|
31228
|
+
async function runHighLevelReview(number, options2 = {}) {
|
|
31229
|
+
const force = options2.force === true;
|
|
31230
|
+
const subject = gatherHighLevelSubject(resolvePrNumber2(number), force);
|
|
31231
|
+
announceSavedReview(subject, force);
|
|
31007
31232
|
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
31008
31233
|
if (process.env.ASSIST_SESSION !== "1" || !sessionId)
|
|
31009
31234
|
return printHighLevelChecklist(subject);
|
|
@@ -31124,13 +31349,13 @@ ${annotateDiffWithLineNumbers(context.diff.trimEnd())}
|
|
|
31124
31349
|
|
|
31125
31350
|
// src/commands/review/buildReviewPaths.ts
|
|
31126
31351
|
import { homedir as homedir23 } from "os";
|
|
31127
|
-
import { basename as
|
|
31352
|
+
import { basename as basename21, join as join76 } from "path";
|
|
31128
31353
|
function buildReviewPaths(repoRoot2, key) {
|
|
31129
31354
|
const reviewDir = join76(
|
|
31130
31355
|
homedir23(),
|
|
31131
31356
|
".assist",
|
|
31132
31357
|
"reviews",
|
|
31133
|
-
|
|
31358
|
+
basename21(repoRoot2),
|
|
31134
31359
|
key
|
|
31135
31360
|
);
|
|
31136
31361
|
return {
|
|
@@ -31176,7 +31401,7 @@ function fetchExistingComments() {
|
|
|
31176
31401
|
}
|
|
31177
31402
|
|
|
31178
31403
|
// src/commands/review/gatherContext.ts
|
|
31179
|
-
import { execSync as
|
|
31404
|
+
import { execSync as execSync63 } from "child_process";
|
|
31180
31405
|
|
|
31181
31406
|
// src/commands/review/fetchPrDiff.ts
|
|
31182
31407
|
import { execSync as execSync61 } from "child_process";
|
|
@@ -31207,13 +31432,59 @@ function fetchDiffViaGit(baseSha, headSha) {
|
|
|
31207
31432
|
});
|
|
31208
31433
|
}
|
|
31209
31434
|
|
|
31435
|
+
// src/commands/review/fetchPrDiffInfo.ts
|
|
31436
|
+
import { execSync as execSync62 } from "child_process";
|
|
31437
|
+
function getCurrentBranch3() {
|
|
31438
|
+
return execSync62("git rev-parse --abbrev-ref HEAD", {
|
|
31439
|
+
encoding: "utf8"
|
|
31440
|
+
}).trim();
|
|
31441
|
+
}
|
|
31442
|
+
function fetchPrDiffInfo() {
|
|
31443
|
+
const { org, repo } = getRepoInfo();
|
|
31444
|
+
const branch2 = getCurrentBranch3();
|
|
31445
|
+
const fields = "number,baseRefName,baseRefOid,headRefName,headRefOid";
|
|
31446
|
+
const raw = execSync62(
|
|
31447
|
+
`gh pr list --state open --head ${branch2} --json ${fields} -R ${org}/${repo}`,
|
|
31448
|
+
{
|
|
31449
|
+
encoding: "utf8",
|
|
31450
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
31451
|
+
}
|
|
31452
|
+
);
|
|
31453
|
+
const parsed = JSON.parse(raw);
|
|
31454
|
+
const pr = parsed[0];
|
|
31455
|
+
if (!pr) {
|
|
31456
|
+
console.error(
|
|
31457
|
+
`Error: No open pull request found for branch \`${branch2}\`. Open a PR for this branch before running \`assist review\`.`
|
|
31458
|
+
);
|
|
31459
|
+
process.exit(1);
|
|
31460
|
+
}
|
|
31461
|
+
return {
|
|
31462
|
+
prNumber: pr.number,
|
|
31463
|
+
baseRef: pr.baseRefName,
|
|
31464
|
+
baseSha: pr.baseRefOid,
|
|
31465
|
+
headRef: pr.headRefName,
|
|
31466
|
+
headSha: pr.headRefOid
|
|
31467
|
+
};
|
|
31468
|
+
}
|
|
31469
|
+
function fetchPrChangedFiles(prNumber) {
|
|
31470
|
+
const { org, repo } = getRepoInfo();
|
|
31471
|
+
const out = execSync62(
|
|
31472
|
+
`gh api repos/${org}/${repo}/pulls/${prNumber}/files --paginate --jq ".[].filename"`,
|
|
31473
|
+
{
|
|
31474
|
+
encoding: "utf8",
|
|
31475
|
+
maxBuffer: 64 * 1024 * 1024
|
|
31476
|
+
}
|
|
31477
|
+
);
|
|
31478
|
+
return out.trim().split("\n").filter(Boolean);
|
|
31479
|
+
}
|
|
31480
|
+
|
|
31210
31481
|
// src/commands/review/gatherContext.ts
|
|
31211
31482
|
function gatherContext() {
|
|
31212
|
-
const branch2 =
|
|
31483
|
+
const branch2 = execSync63("git rev-parse --abbrev-ref HEAD", {
|
|
31213
31484
|
encoding: "utf8"
|
|
31214
31485
|
}).trim();
|
|
31215
|
-
const sha =
|
|
31216
|
-
const shortSha =
|
|
31486
|
+
const sha = execSync63("git rev-parse HEAD", { encoding: "utf8" }).trim();
|
|
31487
|
+
const shortSha = execSync63("git rev-parse --short=7 HEAD", {
|
|
31217
31488
|
encoding: "utf8"
|
|
31218
31489
|
}).trim();
|
|
31219
31490
|
const prInfo = fetchPrDiffInfo();
|
|
@@ -31234,7 +31505,7 @@ function gatherContext() {
|
|
|
31234
31505
|
}
|
|
31235
31506
|
|
|
31236
31507
|
// src/commands/review/postReviewToPr.ts
|
|
31237
|
-
import { readFileSync as
|
|
31508
|
+
import { readFileSync as readFileSync48 } from "fs";
|
|
31238
31509
|
|
|
31239
31510
|
// src/commands/review/carriedUnanchoredFindings.ts
|
|
31240
31511
|
function carriedUnanchoredFindings(unanchored) {
|
|
@@ -31572,18 +31843,18 @@ function partitionFindingsByDiff(findings, index3) {
|
|
|
31572
31843
|
}
|
|
31573
31844
|
|
|
31574
31845
|
// src/commands/review/warnOutOfDiff.ts
|
|
31575
|
-
import
|
|
31846
|
+
import chalk217 from "chalk";
|
|
31576
31847
|
function warnOutOfDiff(outOfDiff) {
|
|
31577
31848
|
if (outOfDiff.length === 0) return;
|
|
31578
31849
|
console.warn(
|
|
31579
|
-
|
|
31850
|
+
chalk217.yellow(
|
|
31580
31851
|
`Moved ${outOfDiff.length} finding(s) whose lines fall outside the PR diff into the review body (GitHub cannot anchor a comment on these):`
|
|
31581
31852
|
)
|
|
31582
31853
|
);
|
|
31583
31854
|
for (const finding of outOfDiff) {
|
|
31584
31855
|
const range = finding.startLine !== void 0 ? `${finding.startLine}-${finding.line}` : `${finding.line}`;
|
|
31585
31856
|
console.warn(
|
|
31586
|
-
` ${
|
|
31857
|
+
` ${chalk217.yellow("\xB7")} ${finding.title} ${chalk217.dim(
|
|
31587
31858
|
`(${finding.file}:${range})`
|
|
31588
31859
|
)}`
|
|
31589
31860
|
);
|
|
@@ -31607,18 +31878,18 @@ function selectInDiffFindings(lineBound, prDiff) {
|
|
|
31607
31878
|
}
|
|
31608
31879
|
|
|
31609
31880
|
// src/commands/review/warnUnlocated.ts
|
|
31610
|
-
import
|
|
31881
|
+
import chalk218 from "chalk";
|
|
31611
31882
|
function warnUnlocated(unlocated) {
|
|
31612
31883
|
if (unlocated.length === 0) return;
|
|
31613
31884
|
console.warn(
|
|
31614
|
-
|
|
31885
|
+
chalk218.yellow(
|
|
31615
31886
|
`Moved ${unlocated.length} finding(s) without a parseable file:line into the review body:`
|
|
31616
31887
|
)
|
|
31617
31888
|
);
|
|
31618
31889
|
for (const finding of unlocated) {
|
|
31619
|
-
const where = finding.location ||
|
|
31890
|
+
const where = finding.location || chalk218.dim("missing");
|
|
31620
31891
|
console.warn(
|
|
31621
|
-
` ${
|
|
31892
|
+
` ${chalk218.yellow("\xB7")} ${finding.title} ${chalk218.dim(`(${where})`)}`
|
|
31622
31893
|
);
|
|
31623
31894
|
}
|
|
31624
31895
|
}
|
|
@@ -31685,7 +31956,7 @@ async function confirmPost(prNumber, work, options2) {
|
|
|
31685
31956
|
return promptConfirm(`Post ${work} to PR #${prNumber}?`, false);
|
|
31686
31957
|
}
|
|
31687
31958
|
async function postFindingsToPr(prInfo, synthesisPath, options2) {
|
|
31688
|
-
const markdown =
|
|
31959
|
+
const markdown = readFileSync48(synthesisPath, "utf8");
|
|
31689
31960
|
const { inDiff, unanchored } = selectPostableFindings(markdown, prInfo);
|
|
31690
31961
|
const carried = carriedUnanchoredFindings(unanchored);
|
|
31691
31962
|
if (inDiff.length === 0 && carried.length === 0) return NOTHING_POSTED;
|
|
@@ -31821,10 +32092,10 @@ async function handlePostSynthesis(synthesisPath, prInfo, options2) {
|
|
|
31821
32092
|
}
|
|
31822
32093
|
|
|
31823
32094
|
// src/commands/review/prepareReviewDir.ts
|
|
31824
|
-
import { existsSync as
|
|
32095
|
+
import { existsSync as existsSync64, mkdirSync as mkdirSync22, unlinkSync as unlinkSync17, writeFileSync as writeFileSync39 } from "fs";
|
|
31825
32096
|
function clearReviewFiles(paths) {
|
|
31826
32097
|
for (const path91 of [paths.claudePath, paths.codexPath, paths.synthesisPath]) {
|
|
31827
|
-
if (
|
|
32098
|
+
if (existsSync64(path91)) unlinkSync17(path91);
|
|
31828
32099
|
}
|
|
31829
32100
|
}
|
|
31830
32101
|
function prepareReviewDir(paths, requestBody, force) {
|
|
@@ -32128,7 +32399,7 @@ function printReviewerFailures(results) {
|
|
|
32128
32399
|
}
|
|
32129
32400
|
|
|
32130
32401
|
// src/commands/review/runAndSynthesise.ts
|
|
32131
|
-
import { existsSync as
|
|
32402
|
+
import { existsSync as existsSync66, unlinkSync as unlinkSync19 } from "fs";
|
|
32132
32403
|
|
|
32133
32404
|
// src/commands/review/buildReviewerStdin.ts
|
|
32134
32405
|
var REVIEW_PROMPT = `You are acting as a reviewer for a proposed code change made by another engineer. The full review request \u2014 branch, base, changed files, and unified diff \u2014 is in the request file whose absolute path is given below.
|
|
@@ -32595,7 +32866,7 @@ function buildCodexModelArgs() {
|
|
|
32595
32866
|
}
|
|
32596
32867
|
|
|
32597
32868
|
// src/commands/review/runCodexReviewer.ts
|
|
32598
|
-
import { existsSync as
|
|
32869
|
+
import { existsSync as existsSync65, unlinkSync as unlinkSync18 } from "fs";
|
|
32599
32870
|
|
|
32600
32871
|
// src/commands/review/parseCodexEvent.ts
|
|
32601
32872
|
function isItemStarted(value) {
|
|
@@ -32650,7 +32921,7 @@ async function runCodexReviewer(spec) {
|
|
|
32650
32921
|
reportReviewerToolUse(spec.name, event, spinner, override.model);
|
|
32651
32922
|
}
|
|
32652
32923
|
});
|
|
32653
|
-
if (result.exitCode !== 0 &&
|
|
32924
|
+
if (result.exitCode !== 0 && existsSync65(spec.outputPath)) {
|
|
32654
32925
|
unlinkSync18(spec.outputPath);
|
|
32655
32926
|
}
|
|
32656
32927
|
return finaliseReviewerRun(
|
|
@@ -32705,7 +32976,7 @@ async function runReviewers(reviewDir, claudePath, codexPath, stdinPrompt, optio
|
|
|
32705
32976
|
}
|
|
32706
32977
|
|
|
32707
32978
|
// src/commands/review/synthesise.ts
|
|
32708
|
-
import { readFileSync as
|
|
32979
|
+
import { readFileSync as readFileSync49 } from "fs";
|
|
32709
32980
|
|
|
32710
32981
|
// src/commands/review/buildSynthesisStdin.ts
|
|
32711
32982
|
var SYNTHESIS_PROMPT = `You are consolidating two independent code reviews of the same change. The original review request is in request.md. The two reviews are in claude.md and codex.md in the current working directory.
|
|
@@ -32770,7 +33041,7 @@ Files:
|
|
|
32770
33041
|
|
|
32771
33042
|
// src/commands/review/synthesise.ts
|
|
32772
33043
|
function printSummary2(synthesisPath) {
|
|
32773
|
-
const markdown =
|
|
33044
|
+
const markdown = readFileSync49(synthesisPath, "utf8");
|
|
32774
33045
|
console.log("");
|
|
32775
33046
|
console.log(buildReviewSummary(markdown));
|
|
32776
33047
|
console.log("");
|
|
@@ -32818,7 +33089,7 @@ async function runAndSynthesise(args) {
|
|
|
32818
33089
|
console.error("Both reviewers failed; skipping synthesis.");
|
|
32819
33090
|
return { ok: false, failures };
|
|
32820
33091
|
}
|
|
32821
|
-
if (anyFresh &&
|
|
33092
|
+
if (anyFresh && existsSync66(paths.synthesisPath)) {
|
|
32822
33093
|
unlinkSync19(paths.synthesisPath);
|
|
32823
33094
|
}
|
|
32824
33095
|
const synthesisResult = await synthesise(paths, { multi });
|
|
@@ -32971,9 +33242,10 @@ async function review(options2 = {}) {
|
|
|
32971
33242
|
return checkoutOnlySession(options2.number);
|
|
32972
33243
|
emitActivity({ kind: "command", name: "review" });
|
|
32973
33244
|
if (!options2.number)
|
|
32974
|
-
return options2.highLevel ? runHighLevelReview(void 0) : reviewPr(invokedIn, options2);
|
|
33245
|
+
return options2.highLevel ? runHighLevelReview(void 0, { force: options2.force }) : reviewPr(invokedIn, options2);
|
|
32975
33246
|
await checkoutPr(options2.number);
|
|
32976
|
-
if (options2.highLevel)
|
|
33247
|
+
if (options2.highLevel)
|
|
33248
|
+
return runHighLevelReview(options2.number, { force: options2.force });
|
|
32977
33249
|
return reviewPr(resolveRepoRoot(), options2);
|
|
32978
33250
|
}
|
|
32979
33251
|
|
|
@@ -32992,7 +33264,7 @@ function registerReview(program2) {
|
|
|
32992
33264
|
"Default the submit prompt to yes (or auto-submit with --no-prompt)"
|
|
32993
33265
|
).option(
|
|
32994
33266
|
"--force",
|
|
32995
|
-
"Clear cached claude.md / codex.md / synthesis.md and re-run all phases"
|
|
33267
|
+
"Clear cached claude.md / codex.md / synthesis.md and re-run all phases; with --high-level, discard the review saved for this head SHA and start fresh"
|
|
32996
33268
|
).option(
|
|
32997
33269
|
"--refine",
|
|
32998
33270
|
"After synthesis, launch an interactive Claude session to walk through findings instead of posting"
|
|
@@ -33007,7 +33279,7 @@ function registerReview(program2) {
|
|
|
33007
33279
|
"Check the PR out and start an idle interactive Claude session in the checkout tree instead of reviewing; requires a PR number and cannot be combined with --refine, --apply, --backlog or --submit"
|
|
33008
33280
|
).option(
|
|
33009
33281
|
"--high-level",
|
|
33010
|
-
"Skip the LLM review; check the PR branch out and step through the high-level review checklist in the web UI preview pane, writing the verdict, per-item state and comments to ~/.assist/high-level-reviews/. Nothing is posted to GitHub; cannot be combined with --refine, --apply, --backlog, --submit or --checkout-only"
|
|
33282
|
+
"Skip the LLM review; check the PR branch out and step through the high-level review checklist in the web UI preview pane, backed by the changed-file tree and the diffs of review.highLevel.criticalPaths, writing the verdict, per-item state and comments to ~/.assist/high-level-reviews/. A review already saved for the same head SHA is reopened unless --force is passed. Nothing is posted to GitHub; cannot be combined with --refine, --apply, --backlog, --submit or --checkout-only"
|
|
33011
33283
|
).option(
|
|
33012
33284
|
"--address-comments",
|
|
33013
33285
|
"After posting and submitting the review, start an Address Comments session (assist review-pr-comments <n>) for the PR; no-op when nothing was posted or the review was not submitted, and only inside an assist session"
|
|
@@ -33028,9 +33300,9 @@ function registerReview(program2) {
|
|
|
33028
33300
|
}
|
|
33029
33301
|
|
|
33030
33302
|
// src/commands/rules/addRule.ts
|
|
33031
|
-
import { existsSync as
|
|
33303
|
+
import { existsSync as existsSync69, readFileSync as readFileSync53, writeFileSync as writeFileSync42 } from "fs";
|
|
33032
33304
|
import path72 from "path";
|
|
33033
|
-
import
|
|
33305
|
+
import chalk219 from "chalk";
|
|
33034
33306
|
|
|
33035
33307
|
// src/commands/rules/insertRuleBullet.ts
|
|
33036
33308
|
function ruleBullet({ code, title, text: text18 }) {
|
|
@@ -33053,7 +33325,7 @@ function insertRuleBullet(content, rule) {
|
|
|
33053
33325
|
}
|
|
33054
33326
|
|
|
33055
33327
|
// src/commands/rules/nextRuleCode.ts
|
|
33056
|
-
import { readFileSync as
|
|
33328
|
+
import { readFileSync as readFileSync50 } from "fs";
|
|
33057
33329
|
|
|
33058
33330
|
// src/commands/rules/findClaudeFiles.ts
|
|
33059
33331
|
import { readdirSync as readdirSync14 } from "fs";
|
|
@@ -33077,7 +33349,7 @@ function findClaudeFiles(dir) {
|
|
|
33077
33349
|
var CODE_PREFIX = "R";
|
|
33078
33350
|
function nextRuleCode(root) {
|
|
33079
33351
|
const numbers = findClaudeFiles(root).flatMap(
|
|
33080
|
-
(file) => parseRulesSection(
|
|
33352
|
+
(file) => parseRulesSection(readFileSync50(file, "utf8")).map(
|
|
33081
33353
|
(rule) => Number(/(\d+)\s*$/.exec(rule.code)?.[1] ?? 0)
|
|
33082
33354
|
)
|
|
33083
33355
|
);
|
|
@@ -33085,7 +33357,7 @@ function nextRuleCode(root) {
|
|
|
33085
33357
|
}
|
|
33086
33358
|
|
|
33087
33359
|
// src/commands/rules/resolveRuleScope.ts
|
|
33088
|
-
import { existsSync as
|
|
33360
|
+
import { existsSync as existsSync67 } from "fs";
|
|
33089
33361
|
import path69 from "path";
|
|
33090
33362
|
function resolveRuleScope(target) {
|
|
33091
33363
|
const resolved = path69.resolve(target);
|
|
@@ -33095,7 +33367,7 @@ function resolveRuleScope(target) {
|
|
|
33095
33367
|
let current = startDir;
|
|
33096
33368
|
while (true) {
|
|
33097
33369
|
const candidate = path69.join(current, "CLAUDE.md");
|
|
33098
|
-
if (
|
|
33370
|
+
if (existsSync67(candidate)) return candidate;
|
|
33099
33371
|
if (current === root || current === path69.dirname(current)) break;
|
|
33100
33372
|
current = path69.dirname(current);
|
|
33101
33373
|
}
|
|
@@ -33103,15 +33375,15 @@ function resolveRuleScope(target) {
|
|
|
33103
33375
|
}
|
|
33104
33376
|
|
|
33105
33377
|
// src/commands/rules/updateScopedRulesIndex.ts
|
|
33106
|
-
import { existsSync as
|
|
33378
|
+
import { existsSync as existsSync68, readFileSync as readFileSync52, writeFileSync as writeFileSync41 } from "fs";
|
|
33107
33379
|
import path71 from "path";
|
|
33108
33380
|
|
|
33109
33381
|
// src/commands/rules/scopedRuleDirectories.ts
|
|
33110
|
-
import { readFileSync as
|
|
33382
|
+
import { readFileSync as readFileSync51 } from "fs";
|
|
33111
33383
|
import path70 from "path";
|
|
33112
33384
|
function scopedRuleDirectories(root) {
|
|
33113
33385
|
return findClaudeFiles(root).filter(
|
|
33114
|
-
(file) => path70.dirname(file) !== root && parseRulesSection(
|
|
33386
|
+
(file) => path70.dirname(file) !== root && parseRulesSection(readFileSync51(file, "utf8")).length > 0
|
|
33115
33387
|
).map(
|
|
33116
33388
|
(file) => `${path70.relative(root, path70.dirname(file)).split(path70.sep).join("/")}/`
|
|
33117
33389
|
).sort();
|
|
@@ -33153,7 +33425,7 @@ function upsertScopedRulesPointer(content, directories) {
|
|
|
33153
33425
|
function updateScopedRulesIndex(root) {
|
|
33154
33426
|
const directories = scopedRuleDirectories(root);
|
|
33155
33427
|
const rootFile = path71.join(root, "CLAUDE.md");
|
|
33156
|
-
const before =
|
|
33428
|
+
const before = existsSync68(rootFile) ? readFileSync52(rootFile, "utf8") : "";
|
|
33157
33429
|
const after = upsertScopedRulesPointer(before, directories);
|
|
33158
33430
|
if (after !== before) writeFileSync41(rootFile, after);
|
|
33159
33431
|
return directories;
|
|
@@ -33161,12 +33433,12 @@ function updateScopedRulesIndex(root) {
|
|
|
33161
33433
|
|
|
33162
33434
|
// src/commands/rules/addRule.ts
|
|
33163
33435
|
function read2(file) {
|
|
33164
|
-
return
|
|
33436
|
+
return existsSync69(file) ? readFileSync53(file, "utf8") : "";
|
|
33165
33437
|
}
|
|
33166
33438
|
function addRule(text18, options2) {
|
|
33167
33439
|
const rule = text18.trim();
|
|
33168
33440
|
if (rule === "") {
|
|
33169
|
-
console.error(
|
|
33441
|
+
console.error(chalk219.red("Rule text is required"));
|
|
33170
33442
|
process.exitCode = 1;
|
|
33171
33443
|
return;
|
|
33172
33444
|
}
|
|
@@ -33184,13 +33456,13 @@ function addRule(text18, options2) {
|
|
|
33184
33456
|
);
|
|
33185
33457
|
updateScopedRulesIndex(root);
|
|
33186
33458
|
console.log(
|
|
33187
|
-
`Added ${
|
|
33459
|
+
`Added ${chalk219.cyan(code)} to ${path72.relative(process.cwd(), target) || target}`
|
|
33188
33460
|
);
|
|
33189
33461
|
}
|
|
33190
33462
|
|
|
33191
33463
|
// src/commands/rules/indexRules.ts
|
|
33192
33464
|
import path73 from "path";
|
|
33193
|
-
import
|
|
33465
|
+
import chalk220 from "chalk";
|
|
33194
33466
|
function indexRules() {
|
|
33195
33467
|
const startDir = scopeDirectory(process.cwd());
|
|
33196
33468
|
const root = findRepoRoot(startDir) ?? startDir;
|
|
@@ -33198,24 +33470,24 @@ function indexRules() {
|
|
|
33198
33470
|
const rootFile = path73.relative(process.cwd(), path73.join(root, "CLAUDE.md"));
|
|
33199
33471
|
if (directories.length === 0) {
|
|
33200
33472
|
console.log(
|
|
33201
|
-
|
|
33473
|
+
chalk220.gray(`No directories carry their own \`## Rules\` under ${root}`)
|
|
33202
33474
|
);
|
|
33203
33475
|
return;
|
|
33204
33476
|
}
|
|
33205
33477
|
console.log(`Recorded in ${rootFile || "CLAUDE.md"}`);
|
|
33206
33478
|
for (const directory of directories)
|
|
33207
|
-
console.log(` ${
|
|
33479
|
+
console.log(` ${chalk220.cyan(directory)}`);
|
|
33208
33480
|
}
|
|
33209
33481
|
|
|
33210
33482
|
// src/commands/rules/listRules.ts
|
|
33211
33483
|
import path74 from "path";
|
|
33212
|
-
import
|
|
33484
|
+
import chalk221 from "chalk";
|
|
33213
33485
|
function listRules(target, options2 = {}) {
|
|
33214
33486
|
const resolved = path74.resolve(target ?? process.cwd());
|
|
33215
33487
|
const rules3 = readScopedRules(resolved);
|
|
33216
33488
|
if (rules3.length === 0) {
|
|
33217
33489
|
const label2 = path74.relative(process.cwd(), resolved) || ".";
|
|
33218
|
-
console.log(
|
|
33490
|
+
console.log(chalk221.gray(`No rules in scope for ${label2}`));
|
|
33219
33491
|
return;
|
|
33220
33492
|
}
|
|
33221
33493
|
const base = findRepoRoot(scopeDirectory(resolved));
|
|
@@ -33225,14 +33497,14 @@ function listRules(target, options2 = {}) {
|
|
|
33225
33497
|
if (rule.source !== shown) {
|
|
33226
33498
|
shown = rule.source;
|
|
33227
33499
|
console.log(
|
|
33228
|
-
|
|
33500
|
+
chalk221.dim(base ? path74.relative(base, rule.source) : rule.source)
|
|
33229
33501
|
);
|
|
33230
33502
|
}
|
|
33231
33503
|
console.log(
|
|
33232
|
-
` ${
|
|
33504
|
+
` ${chalk221.cyan(rule.code.padEnd(width))} ${rule.title ?? rule.text}`
|
|
33233
33505
|
);
|
|
33234
33506
|
if (options2.full && rule.title)
|
|
33235
|
-
console.log(` ${" ".repeat(width)} ${
|
|
33507
|
+
console.log(` ${" ".repeat(width)} ${chalk221.dim(rule.text)}`);
|
|
33236
33508
|
}
|
|
33237
33509
|
}
|
|
33238
33510
|
|
|
@@ -33261,7 +33533,7 @@ function registerRules(program2) {
|
|
|
33261
33533
|
}
|
|
33262
33534
|
|
|
33263
33535
|
// src/commands/seq/seqAuth.ts
|
|
33264
|
-
import
|
|
33536
|
+
import chalk223 from "chalk";
|
|
33265
33537
|
|
|
33266
33538
|
// src/commands/seq/loadConnections.ts
|
|
33267
33539
|
function loadConnections2() {
|
|
@@ -33290,10 +33562,10 @@ function setDefaultConnection(name) {
|
|
|
33290
33562
|
}
|
|
33291
33563
|
|
|
33292
33564
|
// src/shared/assertUniqueName.ts
|
|
33293
|
-
import
|
|
33565
|
+
import chalk222 from "chalk";
|
|
33294
33566
|
function assertUniqueName(existingNames, name) {
|
|
33295
33567
|
if (existingNames.includes(name)) {
|
|
33296
|
-
console.error(
|
|
33568
|
+
console.error(chalk222.red(`Connection "${name}" already exists.`));
|
|
33297
33569
|
process.exit(1);
|
|
33298
33570
|
}
|
|
33299
33571
|
}
|
|
@@ -33311,16 +33583,16 @@ async function promptConnection2(existingNames) {
|
|
|
33311
33583
|
var seqAuth = createConnectionAuth({
|
|
33312
33584
|
load: loadConnections2,
|
|
33313
33585
|
save: saveConnections2,
|
|
33314
|
-
format: (c) => `${
|
|
33586
|
+
format: (c) => `${chalk223.bold(c.name)} ${c.url}`,
|
|
33315
33587
|
promptNew: promptConnection2,
|
|
33316
33588
|
onFirst: (c) => setDefaultConnection(c.name)
|
|
33317
33589
|
});
|
|
33318
33590
|
|
|
33319
33591
|
// src/commands/seq/seqQuery.ts
|
|
33320
|
-
import
|
|
33592
|
+
import chalk227 from "chalk";
|
|
33321
33593
|
|
|
33322
33594
|
// src/commands/seq/fetchSeq.ts
|
|
33323
|
-
import
|
|
33595
|
+
import chalk224 from "chalk";
|
|
33324
33596
|
async function fetchSeq(conn, path91, params) {
|
|
33325
33597
|
const url = `${conn.url}${path91}?${params}`;
|
|
33326
33598
|
const response = await fetch(url, {
|
|
@@ -33331,7 +33603,7 @@ async function fetchSeq(conn, path91, params) {
|
|
|
33331
33603
|
});
|
|
33332
33604
|
if (!response.ok) {
|
|
33333
33605
|
const body = await response.text();
|
|
33334
|
-
console.error(
|
|
33606
|
+
console.error(chalk224.red(`Seq returned ${response.status}: ${body}`));
|
|
33335
33607
|
process.exit(1);
|
|
33336
33608
|
}
|
|
33337
33609
|
return response;
|
|
@@ -33390,23 +33662,23 @@ async function fetchSeqEvents(conn, params) {
|
|
|
33390
33662
|
}
|
|
33391
33663
|
|
|
33392
33664
|
// src/commands/seq/formatEvent.ts
|
|
33393
|
-
import
|
|
33665
|
+
import chalk225 from "chalk";
|
|
33394
33666
|
function levelColor(level) {
|
|
33395
33667
|
switch (level) {
|
|
33396
33668
|
case "Fatal":
|
|
33397
|
-
return
|
|
33669
|
+
return chalk225.bgRed.white;
|
|
33398
33670
|
case "Error":
|
|
33399
|
-
return
|
|
33671
|
+
return chalk225.red;
|
|
33400
33672
|
case "Warning":
|
|
33401
|
-
return
|
|
33673
|
+
return chalk225.yellow;
|
|
33402
33674
|
case "Information":
|
|
33403
|
-
return
|
|
33675
|
+
return chalk225.cyan;
|
|
33404
33676
|
case "Debug":
|
|
33405
|
-
return
|
|
33677
|
+
return chalk225.gray;
|
|
33406
33678
|
case "Verbose":
|
|
33407
|
-
return
|
|
33679
|
+
return chalk225.dim;
|
|
33408
33680
|
default:
|
|
33409
|
-
return
|
|
33681
|
+
return chalk225.white;
|
|
33410
33682
|
}
|
|
33411
33683
|
}
|
|
33412
33684
|
function levelAbbrev(level) {
|
|
@@ -33447,12 +33719,12 @@ function formatTimestamp(iso) {
|
|
|
33447
33719
|
function formatEvent(event) {
|
|
33448
33720
|
const color = levelColor(event.Level);
|
|
33449
33721
|
const abbrev = levelAbbrev(event.Level);
|
|
33450
|
-
const ts8 =
|
|
33722
|
+
const ts8 = chalk225.dim(formatTimestamp(event.Timestamp));
|
|
33451
33723
|
const msg = renderMessage(event);
|
|
33452
33724
|
const lines2 = [`${ts8} ${color(`[${abbrev}]`)} ${msg}`];
|
|
33453
33725
|
if (event.Exception) {
|
|
33454
33726
|
for (const line of event.Exception.split("\n")) {
|
|
33455
|
-
lines2.push(
|
|
33727
|
+
lines2.push(chalk225.red(` ${line}`));
|
|
33456
33728
|
}
|
|
33457
33729
|
}
|
|
33458
33730
|
return lines2.join("\n");
|
|
@@ -33485,11 +33757,11 @@ function rejectTimestampFilter(filter) {
|
|
|
33485
33757
|
}
|
|
33486
33758
|
|
|
33487
33759
|
// src/shared/resolveNamedConnection.ts
|
|
33488
|
-
import
|
|
33760
|
+
import chalk226 from "chalk";
|
|
33489
33761
|
function resolveNamedConnection(connections, requested, defaultName, kind, authCommand) {
|
|
33490
33762
|
if (connections.length === 0) {
|
|
33491
33763
|
console.error(
|
|
33492
|
-
|
|
33764
|
+
chalk226.red(
|
|
33493
33765
|
`No ${kind} connections configured. Run '${authCommand}' first.`
|
|
33494
33766
|
)
|
|
33495
33767
|
);
|
|
@@ -33498,7 +33770,7 @@ function resolveNamedConnection(connections, requested, defaultName, kind, authC
|
|
|
33498
33770
|
const target = requested ?? defaultName ?? connections[0].name;
|
|
33499
33771
|
const connection = connections.find((c) => c.name === target);
|
|
33500
33772
|
if (!connection) {
|
|
33501
|
-
console.error(
|
|
33773
|
+
console.error(chalk226.red(`${kind} connection "${target}" not found.`));
|
|
33502
33774
|
process.exit(1);
|
|
33503
33775
|
}
|
|
33504
33776
|
return connection;
|
|
@@ -33527,7 +33799,7 @@ async function seqQuery(filter, options2) {
|
|
|
33527
33799
|
new URLSearchParams({ filter, count: String(count8) })
|
|
33528
33800
|
);
|
|
33529
33801
|
if (events.length === 0) {
|
|
33530
|
-
console.log(
|
|
33802
|
+
console.log(chalk227.yellow("No events found."));
|
|
33531
33803
|
return;
|
|
33532
33804
|
}
|
|
33533
33805
|
if (options2.json) {
|
|
@@ -33538,11 +33810,11 @@ async function seqQuery(filter, options2) {
|
|
|
33538
33810
|
for (const event of chronological) {
|
|
33539
33811
|
console.log(formatEvent(event));
|
|
33540
33812
|
}
|
|
33541
|
-
console.log(
|
|
33813
|
+
console.log(chalk227.dim(`
|
|
33542
33814
|
${events.length} events`));
|
|
33543
33815
|
if (events.length >= count8) {
|
|
33544
33816
|
console.log(
|
|
33545
|
-
|
|
33817
|
+
chalk227.yellow(
|
|
33546
33818
|
`Results limited to ${count8}. Use --count to retrieve more.`
|
|
33547
33819
|
)
|
|
33548
33820
|
);
|
|
@@ -33550,10 +33822,10 @@ ${events.length} events`));
|
|
|
33550
33822
|
}
|
|
33551
33823
|
|
|
33552
33824
|
// src/shared/setNamedDefaultConnection.ts
|
|
33553
|
-
import
|
|
33825
|
+
import chalk228 from "chalk";
|
|
33554
33826
|
function setNamedDefaultConnection(connections, name, setDefault, kind) {
|
|
33555
33827
|
if (!connections.find((c) => c.name === name)) {
|
|
33556
|
-
console.error(
|
|
33828
|
+
console.error(chalk228.red(`Connection "${name}" not found.`));
|
|
33557
33829
|
process.exit(1);
|
|
33558
33830
|
}
|
|
33559
33831
|
setDefault(name);
|
|
@@ -33625,12 +33897,12 @@ import { mkdirSync as mkdirSync25, writeFileSync as writeFileSync44 } from "fs";
|
|
|
33625
33897
|
import { mkdirSync as mkdirSync24, writeFileSync as writeFileSync43 } from "fs";
|
|
33626
33898
|
|
|
33627
33899
|
// src/commands/slack/readSlackParts.ts
|
|
33628
|
-
import { readFileSync as
|
|
33900
|
+
import { readFileSync as readFileSync54 } from "fs";
|
|
33629
33901
|
function readSlackParts(files) {
|
|
33630
33902
|
return files.map((file) => {
|
|
33631
33903
|
let contents;
|
|
33632
33904
|
try {
|
|
33633
|
-
contents =
|
|
33905
|
+
contents = readFileSync54(file, "utf8");
|
|
33634
33906
|
} catch {
|
|
33635
33907
|
console.error(`Error: Part file not found: ${file}`);
|
|
33636
33908
|
process.exit(1);
|
|
@@ -33774,7 +34046,7 @@ function registerSlack(program2) {
|
|
|
33774
34046
|
}
|
|
33775
34047
|
|
|
33776
34048
|
// src/commands/sql/sqlAuth.ts
|
|
33777
|
-
import
|
|
34049
|
+
import chalk230 from "chalk";
|
|
33778
34050
|
|
|
33779
34051
|
// src/commands/sql/loadConnections.ts
|
|
33780
34052
|
function loadConnections3() {
|
|
@@ -33803,7 +34075,7 @@ function setDefaultConnection2(name) {
|
|
|
33803
34075
|
}
|
|
33804
34076
|
|
|
33805
34077
|
// src/commands/sql/promptConnection.ts
|
|
33806
|
-
import
|
|
34078
|
+
import chalk229 from "chalk";
|
|
33807
34079
|
async function promptConnection3(existingNames) {
|
|
33808
34080
|
const name = await promptInput("name", "Connection name:", "default");
|
|
33809
34081
|
assertUniqueName(existingNames, name);
|
|
@@ -33811,7 +34083,7 @@ async function promptConnection3(existingNames) {
|
|
|
33811
34083
|
const portStr = await promptInput("port", "Port:", "1433");
|
|
33812
34084
|
const port = Number.parseInt(portStr, 10);
|
|
33813
34085
|
if (!Number.isFinite(port)) {
|
|
33814
|
-
console.error(
|
|
34086
|
+
console.error(chalk229.red(`Invalid port "${portStr}".`));
|
|
33815
34087
|
process.exit(1);
|
|
33816
34088
|
}
|
|
33817
34089
|
const user = await promptInput("user", "User:");
|
|
@@ -33824,13 +34096,13 @@ async function promptConnection3(existingNames) {
|
|
|
33824
34096
|
var sqlAuth = createConnectionAuth({
|
|
33825
34097
|
load: loadConnections3,
|
|
33826
34098
|
save: saveConnections3,
|
|
33827
|
-
format: (c) => `${
|
|
34099
|
+
format: (c) => `${chalk230.bold(c.name)} ${c.server}:${c.port}/${c.database} (${c.user})`,
|
|
33828
34100
|
promptNew: promptConnection3,
|
|
33829
34101
|
onFirst: (c) => setDefaultConnection2(c.name)
|
|
33830
34102
|
});
|
|
33831
34103
|
|
|
33832
34104
|
// src/commands/sql/printTable.ts
|
|
33833
|
-
import
|
|
34105
|
+
import chalk231 from "chalk";
|
|
33834
34106
|
function formatCell(value) {
|
|
33835
34107
|
if (value === null || value === void 0) return "";
|
|
33836
34108
|
if (value instanceof Date) return value.toISOString();
|
|
@@ -33839,7 +34111,7 @@ function formatCell(value) {
|
|
|
33839
34111
|
}
|
|
33840
34112
|
function printTable(rows) {
|
|
33841
34113
|
if (rows.length === 0) {
|
|
33842
|
-
console.log(
|
|
34114
|
+
console.log(chalk231.yellow("(no rows)"));
|
|
33843
34115
|
return;
|
|
33844
34116
|
}
|
|
33845
34117
|
const columns = Object.keys(rows[0]);
|
|
@@ -33847,13 +34119,13 @@ function printTable(rows) {
|
|
|
33847
34119
|
(col) => Math.max(col.length, ...rows.map((r) => formatCell(r[col]).length))
|
|
33848
34120
|
);
|
|
33849
34121
|
const header = columns.map((c, i) => c.padEnd(widths[i])).join(" ");
|
|
33850
|
-
console.log(
|
|
33851
|
-
console.log(
|
|
34122
|
+
console.log(chalk231.dim(header));
|
|
34123
|
+
console.log(chalk231.dim("-".repeat(header.length)));
|
|
33852
34124
|
for (const row of rows) {
|
|
33853
34125
|
const line = columns.map((c, i) => formatCell(row[c]).padEnd(widths[i])).join(" ");
|
|
33854
34126
|
console.log(line);
|
|
33855
34127
|
}
|
|
33856
|
-
console.log(
|
|
34128
|
+
console.log(chalk231.dim(`
|
|
33857
34129
|
${rows.length} row${rows.length === 1 ? "" : "s"}`));
|
|
33858
34130
|
}
|
|
33859
34131
|
|
|
@@ -33913,7 +34185,7 @@ async function sqlColumns(table, connectionName) {
|
|
|
33913
34185
|
}
|
|
33914
34186
|
|
|
33915
34187
|
// src/commands/sql/sqlMutate.ts
|
|
33916
|
-
import
|
|
34188
|
+
import chalk232 from "chalk";
|
|
33917
34189
|
|
|
33918
34190
|
// src/commands/sql/isMutation.ts
|
|
33919
34191
|
var MUTATION_KEYWORDS = [
|
|
@@ -33947,7 +34219,7 @@ function isMutation(sql29) {
|
|
|
33947
34219
|
async function sqlMutate(query, connectionName) {
|
|
33948
34220
|
if (!isMutation(query)) {
|
|
33949
34221
|
console.error(
|
|
33950
|
-
|
|
34222
|
+
chalk232.red(
|
|
33951
34223
|
"assist sql mutate refuses non-mutating statements. Use `assist sql query` instead."
|
|
33952
34224
|
)
|
|
33953
34225
|
);
|
|
@@ -33957,18 +34229,18 @@ async function sqlMutate(query, connectionName) {
|
|
|
33957
34229
|
const pool = await sqlConnect(conn);
|
|
33958
34230
|
try {
|
|
33959
34231
|
const result = await pool.request().query(query);
|
|
33960
|
-
console.log(
|
|
34232
|
+
console.log(chalk232.dim(`${result.rowsAffected.join(", ")} row(s) affected`));
|
|
33961
34233
|
} finally {
|
|
33962
34234
|
await pool.close();
|
|
33963
34235
|
}
|
|
33964
34236
|
}
|
|
33965
34237
|
|
|
33966
34238
|
// src/commands/sql/sqlQuery.ts
|
|
33967
|
-
import
|
|
34239
|
+
import chalk233 from "chalk";
|
|
33968
34240
|
async function sqlQuery(query, connectionName) {
|
|
33969
34241
|
if (isMutation(query)) {
|
|
33970
34242
|
console.error(
|
|
33971
|
-
|
|
34243
|
+
chalk233.red(
|
|
33972
34244
|
"assist sql query refuses mutating statements. Use `assist sql mutate` instead."
|
|
33973
34245
|
)
|
|
33974
34246
|
);
|
|
@@ -33983,7 +34255,7 @@ async function sqlQuery(query, connectionName) {
|
|
|
33983
34255
|
printTable(rows);
|
|
33984
34256
|
} else {
|
|
33985
34257
|
console.log(
|
|
33986
|
-
|
|
34258
|
+
chalk233.dim(`${result.rowsAffected.join(", ")} row(s) affected`)
|
|
33987
34259
|
);
|
|
33988
34260
|
}
|
|
33989
34261
|
} finally {
|
|
@@ -34357,7 +34629,7 @@ function syncPi(claudeDir, options2) {
|
|
|
34357
34629
|
// src/commands/sync/syncSettings.ts
|
|
34358
34630
|
import * as fs48 from "fs";
|
|
34359
34631
|
import * as path84 from "path";
|
|
34360
|
-
import
|
|
34632
|
+
import chalk234 from "chalk";
|
|
34361
34633
|
async function syncSettings(claudeDir, targetBase, options2) {
|
|
34362
34634
|
const source = path84.join(claudeDir, "settings.json");
|
|
34363
34635
|
const target = path84.join(targetBase, "settings.json");
|
|
@@ -34376,7 +34648,7 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
34376
34648
|
if (mergedContent !== normalizedTarget) {
|
|
34377
34649
|
if (!options2?.yes) {
|
|
34378
34650
|
console.log(
|
|
34379
|
-
|
|
34651
|
+
chalk234.yellow(
|
|
34380
34652
|
"\n\u26A0\uFE0F Warning: settings.json differs from existing file"
|
|
34381
34653
|
)
|
|
34382
34654
|
);
|
|
@@ -34384,7 +34656,7 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
34384
34656
|
printDiff(targetContent, mergedContent);
|
|
34385
34657
|
printAutoConfirmHint();
|
|
34386
34658
|
const confirm = await promptConfirm(
|
|
34387
|
-
|
|
34659
|
+
chalk234.red("Overwrite existing settings.json?"),
|
|
34388
34660
|
false
|
|
34389
34661
|
);
|
|
34390
34662
|
if (!confirm) {
|
|
@@ -34456,7 +34728,7 @@ function registerSync(program2) {
|
|
|
34456
34728
|
}
|
|
34457
34729
|
|
|
34458
34730
|
// src/commands/transcript/clean.ts
|
|
34459
|
-
import { existsSync as
|
|
34731
|
+
import { existsSync as existsSync74 } from "fs";
|
|
34460
34732
|
|
|
34461
34733
|
// src/commands/transcript/convert/formatTimestamp.ts
|
|
34462
34734
|
function pad(value, width) {
|
|
@@ -34706,9 +34978,9 @@ function formatVttPassages(passages, notes = [], { sourceMarks = true } = {}) {
|
|
|
34706
34978
|
}
|
|
34707
34979
|
|
|
34708
34980
|
// src/commands/transcript/convert/readCleanedCues.ts
|
|
34709
|
-
import { readFileSync as
|
|
34981
|
+
import { readFileSync as readFileSync58 } from "fs";
|
|
34710
34982
|
function readCleanedCues(inputPath) {
|
|
34711
|
-
return deduplicateCues(parseVtt(
|
|
34983
|
+
return deduplicateCues(parseVtt(readFileSync58(inputPath, "utf8")));
|
|
34712
34984
|
}
|
|
34713
34985
|
|
|
34714
34986
|
// src/commands/transcript/clean.ts
|
|
@@ -34734,7 +35006,7 @@ function clean(file, options2 = {}) {
|
|
|
34734
35006
|
);
|
|
34735
35007
|
process.exit(1);
|
|
34736
35008
|
}
|
|
34737
|
-
if (!
|
|
35009
|
+
if (!existsSync74(file)) {
|
|
34738
35010
|
console.error(`Error: VTT file not found: ${file}`);
|
|
34739
35011
|
process.exit(1);
|
|
34740
35012
|
}
|
|
@@ -34817,11 +35089,11 @@ async function configure() {
|
|
|
34817
35089
|
}
|
|
34818
35090
|
|
|
34819
35091
|
// src/commands/transcript/list.ts
|
|
34820
|
-
import { existsSync as
|
|
35092
|
+
import { existsSync as existsSync75, readdirSync as readdirSync21, statSync as statSync11 } from "fs";
|
|
34821
35093
|
import { join as join89 } from "path";
|
|
34822
35094
|
function list4() {
|
|
34823
35095
|
const { vttDir } = getTranscriptConfig();
|
|
34824
|
-
if (!
|
|
35096
|
+
if (!existsSync75(vttDir)) return;
|
|
34825
35097
|
for (const entry of readdirSync21(vttDir)) {
|
|
34826
35098
|
if (!entry.endsWith(".vtt")) continue;
|
|
34827
35099
|
if (statSync11(join89(vttDir, entry)).isDirectory()) continue;
|
|
@@ -34830,8 +35102,8 @@ function list4() {
|
|
|
34830
35102
|
}
|
|
34831
35103
|
|
|
34832
35104
|
// src/commands/transcript/move.ts
|
|
34833
|
-
import { existsSync as
|
|
34834
|
-
import { basename as
|
|
35105
|
+
import { existsSync as existsSync76, mkdirSync as mkdirSync31, renameSync as renameSync2, writeFileSync as writeFileSync48 } from "fs";
|
|
35106
|
+
import { basename as basename24, join as join90 } from "path";
|
|
34835
35107
|
|
|
34836
35108
|
// src/commands/transcript/convertVttToMarkdown.ts
|
|
34837
35109
|
function convertVttToMarkdown(inputPath) {
|
|
@@ -34852,13 +35124,13 @@ function move(file, options2) {
|
|
|
34852
35124
|
process.exit(1);
|
|
34853
35125
|
}
|
|
34854
35126
|
const { vttDir, transcriptsDir, summaryDir } = getTranscriptConfig();
|
|
34855
|
-
const filename =
|
|
35127
|
+
const filename = basename24(file);
|
|
34856
35128
|
const sourcePath = join90(vttDir, filename);
|
|
34857
|
-
if (!
|
|
35129
|
+
if (!existsSync76(sourcePath)) {
|
|
34858
35130
|
console.error(`Error: VTT file not found: ${sourcePath}`);
|
|
34859
35131
|
process.exit(1);
|
|
34860
35132
|
}
|
|
34861
|
-
const base =
|
|
35133
|
+
const base = basename24(filename, ".vtt").replace(/ Transcription$/, "");
|
|
34862
35134
|
const outputName = `${date} ${base}.md`;
|
|
34863
35135
|
const formattedDir = join90(transcriptsDir, client);
|
|
34864
35136
|
mkdirSync31(formattedDir, { recursive: true });
|
|
@@ -34871,8 +35143,8 @@ function move(file, options2) {
|
|
|
34871
35143
|
}
|
|
34872
35144
|
|
|
34873
35145
|
// src/commands/transcript/merge.ts
|
|
34874
|
-
import { existsSync as
|
|
34875
|
-
import { basename as
|
|
35146
|
+
import { existsSync as existsSync77, writeFileSync as writeFileSync49 } from "fs";
|
|
35147
|
+
import { basename as basename25 } from "path";
|
|
34876
35148
|
|
|
34877
35149
|
// src/commands/transcript/failTranscript.ts
|
|
34878
35150
|
function failTranscript(message3) {
|
|
@@ -35015,10 +35287,10 @@ function widenAudience(passages) {
|
|
|
35015
35287
|
|
|
35016
35288
|
// src/commands/transcript/merge.ts
|
|
35017
35289
|
function readSource2(file) {
|
|
35018
|
-
if (!
|
|
35290
|
+
if (!existsSync77(file)) failTranscript(`VTT file not found: ${file}`);
|
|
35019
35291
|
const cues = readCleanedCues(file);
|
|
35020
35292
|
if (cues.length === 0) failTranscript(`no cues found in: ${file}`);
|
|
35021
|
-
return { path: file, name:
|
|
35293
|
+
return { path: file, name: basename25(file), cues };
|
|
35022
35294
|
}
|
|
35023
35295
|
function wholePassages(sources) {
|
|
35024
35296
|
return sources.map((source) => ({
|
|
@@ -35220,14 +35492,14 @@ function devices() {
|
|
|
35220
35492
|
}
|
|
35221
35493
|
|
|
35222
35494
|
// src/commands/voice/logs.ts
|
|
35223
|
-
import { existsSync as
|
|
35495
|
+
import { existsSync as existsSync78, readFileSync as readFileSync59 } from "fs";
|
|
35224
35496
|
function logs(options2) {
|
|
35225
|
-
if (!
|
|
35497
|
+
if (!existsSync78(voicePaths.log)) {
|
|
35226
35498
|
console.log("No voice log file found");
|
|
35227
35499
|
return;
|
|
35228
35500
|
}
|
|
35229
35501
|
const count8 = Number.parseInt(options2.lines ?? "150", 10);
|
|
35230
|
-
const content =
|
|
35502
|
+
const content = readFileSync59(voicePaths.log, "utf8").trim();
|
|
35231
35503
|
if (!content) {
|
|
35232
35504
|
console.log("Voice log is empty");
|
|
35233
35505
|
return;
|
|
@@ -35253,8 +35525,8 @@ import { mkdirSync as mkdirSync33 } from "fs";
|
|
|
35253
35525
|
import { join as join94 } from "path";
|
|
35254
35526
|
|
|
35255
35527
|
// src/commands/voice/checkLockFile.ts
|
|
35256
|
-
import { execSync as
|
|
35257
|
-
import { existsSync as
|
|
35528
|
+
import { execSync as execSync64 } from "child_process";
|
|
35529
|
+
import { existsSync as existsSync79, mkdirSync as mkdirSync32, readFileSync as readFileSync60, writeFileSync as writeFileSync50 } from "fs";
|
|
35258
35530
|
import { join as join93 } from "path";
|
|
35259
35531
|
function isProcessAlive2(pid) {
|
|
35260
35532
|
try {
|
|
@@ -35266,9 +35538,9 @@ function isProcessAlive2(pid) {
|
|
|
35266
35538
|
}
|
|
35267
35539
|
function checkLockFile() {
|
|
35268
35540
|
const lockFile = getLockFile();
|
|
35269
|
-
if (!
|
|
35541
|
+
if (!existsSync79(lockFile)) return;
|
|
35270
35542
|
try {
|
|
35271
|
-
const lock2 = JSON.parse(
|
|
35543
|
+
const lock2 = JSON.parse(readFileSync60(lockFile, "utf8"));
|
|
35272
35544
|
if (lock2.pid && isProcessAlive2(lock2.pid)) {
|
|
35273
35545
|
console.error(
|
|
35274
35546
|
`Voice daemon already running (PID ${lock2.pid}, env: ${lock2.env}). Stop it first with: assist voice stop`
|
|
@@ -35279,10 +35551,10 @@ function checkLockFile() {
|
|
|
35279
35551
|
}
|
|
35280
35552
|
}
|
|
35281
35553
|
function bootstrapVenv() {
|
|
35282
|
-
if (
|
|
35554
|
+
if (existsSync79(getVenvPython())) return;
|
|
35283
35555
|
console.log("Setting up Python environment...");
|
|
35284
35556
|
const pythonDir = getPythonDir();
|
|
35285
|
-
|
|
35557
|
+
execSync64(
|
|
35286
35558
|
`uv sync --project "${pythonDir}" --extra runtime --no-install-project`,
|
|
35287
35559
|
{
|
|
35288
35560
|
stdio: "inherit",
|
|
@@ -35370,7 +35642,7 @@ function start2(options2) {
|
|
|
35370
35642
|
}
|
|
35371
35643
|
|
|
35372
35644
|
// src/commands/voice/status.ts
|
|
35373
|
-
import { existsSync as
|
|
35645
|
+
import { existsSync as existsSync80, readFileSync as readFileSync61 } from "fs";
|
|
35374
35646
|
function isProcessAlive3(pid) {
|
|
35375
35647
|
try {
|
|
35376
35648
|
process.kill(pid, 0);
|
|
@@ -35380,16 +35652,16 @@ function isProcessAlive3(pid) {
|
|
|
35380
35652
|
}
|
|
35381
35653
|
}
|
|
35382
35654
|
function readRecentLogs(count8) {
|
|
35383
|
-
if (!
|
|
35384
|
-
const lines2 =
|
|
35655
|
+
if (!existsSync80(voicePaths.log)) return [];
|
|
35656
|
+
const lines2 = readFileSync61(voicePaths.log, "utf8").trim().split("\n");
|
|
35385
35657
|
return lines2.slice(-count8);
|
|
35386
35658
|
}
|
|
35387
35659
|
function status2() {
|
|
35388
|
-
if (!
|
|
35660
|
+
if (!existsSync80(voicePaths.pid)) {
|
|
35389
35661
|
console.log("Voice daemon: not running (no PID file)");
|
|
35390
35662
|
return;
|
|
35391
35663
|
}
|
|
35392
|
-
const pid = Number.parseInt(
|
|
35664
|
+
const pid = Number.parseInt(readFileSync61(voicePaths.pid, "utf8").trim(), 10);
|
|
35393
35665
|
const alive = isProcessAlive3(pid);
|
|
35394
35666
|
console.log(`Voice daemon: ${alive ? "running" : "dead"} (PID ${pid})`);
|
|
35395
35667
|
const recent = readRecentLogs(5);
|
|
@@ -35408,13 +35680,13 @@ function status2() {
|
|
|
35408
35680
|
}
|
|
35409
35681
|
|
|
35410
35682
|
// src/commands/voice/stop.ts
|
|
35411
|
-
import { existsSync as
|
|
35683
|
+
import { existsSync as existsSync81, readFileSync as readFileSync62, unlinkSync as unlinkSync20 } from "fs";
|
|
35412
35684
|
function stop2() {
|
|
35413
|
-
if (!
|
|
35685
|
+
if (!existsSync81(voicePaths.pid)) {
|
|
35414
35686
|
console.log("Voice daemon is not running (no PID file)");
|
|
35415
35687
|
return;
|
|
35416
35688
|
}
|
|
35417
|
-
const pid = Number.parseInt(
|
|
35689
|
+
const pid = Number.parseInt(readFileSync62(voicePaths.pid, "utf8").trim(), 10);
|
|
35418
35690
|
try {
|
|
35419
35691
|
process.kill(pid, "SIGTERM");
|
|
35420
35692
|
console.log(`Sent SIGTERM to voice daemon (PID ${pid})`);
|
|
@@ -35427,7 +35699,7 @@ function stop2() {
|
|
|
35427
35699
|
}
|
|
35428
35700
|
try {
|
|
35429
35701
|
const lockFile = getLockFile();
|
|
35430
|
-
if (
|
|
35702
|
+
if (existsSync81(lockFile)) unlinkSync20(lockFile);
|
|
35431
35703
|
} catch {
|
|
35432
35704
|
}
|
|
35433
35705
|
console.log("Voice daemon stopped");
|
|
@@ -35828,7 +36100,7 @@ function resolveParams(params, cliArgs) {
|
|
|
35828
36100
|
}
|
|
35829
36101
|
|
|
35830
36102
|
// src/commands/run/resolveRunCwd.ts
|
|
35831
|
-
import { existsSync as
|
|
36103
|
+
import { existsSync as existsSync82 } from "fs";
|
|
35832
36104
|
import { resolve as resolve19 } from "path";
|
|
35833
36105
|
var MissingRunCwdError = class extends Error {
|
|
35834
36106
|
constructor(runName, cwd) {
|
|
@@ -35841,17 +36113,17 @@ var MissingRunCwdError = class extends Error {
|
|
|
35841
36113
|
function resolveRunCwd(config, baseDir = runConfigBaseDir()) {
|
|
35842
36114
|
if (!config.cwd) return void 0;
|
|
35843
36115
|
const cwd = resolve19(baseDir, config.cwd);
|
|
35844
|
-
if (!
|
|
36116
|
+
if (!existsSync82(cwd)) throw new MissingRunCwdError(config.name, cwd);
|
|
35845
36117
|
return cwd;
|
|
35846
36118
|
}
|
|
35847
36119
|
|
|
35848
36120
|
// src/commands/run/runCommandToCompletion.ts
|
|
35849
36121
|
import { spawn as spawn9 } from "child_process";
|
|
35850
|
-
import { existsSync as
|
|
36122
|
+
import { existsSync as existsSync84 } from "fs";
|
|
35851
36123
|
|
|
35852
36124
|
// src/commands/run/resolveCommand.ts
|
|
35853
36125
|
import { execFileSync as execFileSync19 } from "child_process";
|
|
35854
|
-
import { existsSync as
|
|
36126
|
+
import { existsSync as existsSync83 } from "fs";
|
|
35855
36127
|
import { dirname as dirname39, join as join97, resolve as resolve20 } from "path";
|
|
35856
36128
|
function resolveCommand2(command) {
|
|
35857
36129
|
if (process.platform !== "win32" || command !== "bash") return command;
|
|
@@ -35859,7 +36131,7 @@ function resolveCommand2(command) {
|
|
|
35859
36131
|
const gitPath = execFileSync19("where", ["git"], { encoding: "utf8" }).trim().split("\r\n")[0];
|
|
35860
36132
|
const gitRoot = resolve20(dirname39(gitPath), "..");
|
|
35861
36133
|
const gitBash = join97(gitRoot, "bin", "bash.exe");
|
|
35862
|
-
if (
|
|
36134
|
+
if (existsSync83(gitBash)) return gitBash;
|
|
35863
36135
|
} catch {
|
|
35864
36136
|
return command;
|
|
35865
36137
|
}
|
|
@@ -35869,7 +36141,7 @@ function resolveCommand2(command) {
|
|
|
35869
36141
|
// src/commands/run/runCommandToCompletion.ts
|
|
35870
36142
|
function runCommandToCompletion(command, args, env, cwd, quiet) {
|
|
35871
36143
|
return new Promise((resolveResult) => {
|
|
35872
|
-
if (cwd && !
|
|
36144
|
+
if (cwd && !existsSync84(cwd)) {
|
|
35873
36145
|
resolveResult({
|
|
35874
36146
|
kind: "failed",
|
|
35875
36147
|
message: `Failed to execute command: cwd ${cwd} does not exist`
|
|
@@ -35903,11 +36175,11 @@ function runCommandToCompletion(command, args, env, cwd, quiet) {
|
|
|
35903
36175
|
}
|
|
35904
36176
|
|
|
35905
36177
|
// src/commands/run/runPreCommands.ts
|
|
35906
|
-
import { execSync as
|
|
36178
|
+
import { execSync as execSync65 } from "child_process";
|
|
35907
36179
|
function runPreCommands(pre, cwd) {
|
|
35908
36180
|
for (const cmd of pre) {
|
|
35909
36181
|
try {
|
|
35910
|
-
|
|
36182
|
+
execSync65(cmd, { stdio: "inherit", cwd });
|
|
35911
36183
|
} catch (error) {
|
|
35912
36184
|
const code = error && typeof error === "object" && "status" in error ? error.status : 1;
|
|
35913
36185
|
process.exit(code);
|
|
@@ -36126,7 +36398,7 @@ function registerWatch(program2) {
|
|
|
36126
36398
|
|
|
36127
36399
|
// src/commands/roam/auth.ts
|
|
36128
36400
|
import { randomBytes } from "crypto";
|
|
36129
|
-
import
|
|
36401
|
+
import chalk235 from "chalk";
|
|
36130
36402
|
|
|
36131
36403
|
// src/commands/roam/waitForCallback.ts
|
|
36132
36404
|
import { createServer as createServer3 } from "http";
|
|
@@ -36257,13 +36529,13 @@ async function auth() {
|
|
|
36257
36529
|
saveGlobalConfig(config);
|
|
36258
36530
|
const state = randomBytes(16).toString("hex");
|
|
36259
36531
|
console.log(
|
|
36260
|
-
|
|
36532
|
+
chalk235.yellow("\nEnsure this Redirect URI is set in your Roam OAuth app:")
|
|
36261
36533
|
);
|
|
36262
|
-
console.log(
|
|
36263
|
-
console.log(
|
|
36264
|
-
console.log(
|
|
36534
|
+
console.log(chalk235.white("http://localhost:14523/callback\n"));
|
|
36535
|
+
console.log(chalk235.blue("Opening browser for authorization..."));
|
|
36536
|
+
console.log(chalk235.dim("Waiting for authorization callback..."));
|
|
36265
36537
|
const { code, redirectUri } = await authorizeInBrowser(clientId, state);
|
|
36266
|
-
console.log(
|
|
36538
|
+
console.log(chalk235.dim("Exchanging code for tokens..."));
|
|
36267
36539
|
const tokens = await exchangeToken({
|
|
36268
36540
|
code,
|
|
36269
36541
|
clientId,
|
|
@@ -36279,13 +36551,13 @@ async function auth() {
|
|
|
36279
36551
|
};
|
|
36280
36552
|
saveGlobalConfig(config);
|
|
36281
36553
|
console.log(
|
|
36282
|
-
|
|
36554
|
+
chalk235.green("Roam credentials and tokens saved to ~/.assist.yml")
|
|
36283
36555
|
);
|
|
36284
36556
|
}
|
|
36285
36557
|
|
|
36286
36558
|
// src/commands/roam/postRoamActivity.ts
|
|
36287
36559
|
import { execFileSync as execFileSync21 } from "child_process";
|
|
36288
|
-
import { readdirSync as readdirSync22, readFileSync as
|
|
36560
|
+
import { readdirSync as readdirSync22, readFileSync as readFileSync63, statSync as statSync12 } from "fs";
|
|
36289
36561
|
import { join as join98 } from "path";
|
|
36290
36562
|
function findPortFile(roamDir) {
|
|
36291
36563
|
let entries;
|
|
@@ -36316,7 +36588,7 @@ function postRoamActivity(app, event) {
|
|
|
36316
36588
|
if (!portFile) return;
|
|
36317
36589
|
let port;
|
|
36318
36590
|
try {
|
|
36319
|
-
port =
|
|
36591
|
+
port = readFileSync63(portFile, "utf8").trim();
|
|
36320
36592
|
} catch {
|
|
36321
36593
|
return;
|
|
36322
36594
|
}
|
|
@@ -36573,7 +36845,7 @@ function link2() {
|
|
|
36573
36845
|
}
|
|
36574
36846
|
|
|
36575
36847
|
// src/commands/run/remove.ts
|
|
36576
|
-
import { existsSync as
|
|
36848
|
+
import { existsSync as existsSync85, unlinkSync as unlinkSync21 } from "fs";
|
|
36577
36849
|
import { join as join100 } from "path";
|
|
36578
36850
|
function findRemoveIndex() {
|
|
36579
36851
|
const idx = process.argv.indexOf("remove");
|
|
@@ -36590,7 +36862,7 @@ function parseRemoveName() {
|
|
|
36590
36862
|
}
|
|
36591
36863
|
function deleteCommandFile(name) {
|
|
36592
36864
|
const filePath = join100(".claude", "commands", `${name}.md`);
|
|
36593
|
-
if (
|
|
36865
|
+
if (existsSync85(filePath)) {
|
|
36594
36866
|
unlinkSync21(filePath);
|
|
36595
36867
|
console.log(`Deleted command file: ${filePath}`);
|
|
36596
36868
|
}
|
|
@@ -36634,11 +36906,11 @@ function registerRun(program2) {
|
|
|
36634
36906
|
}
|
|
36635
36907
|
|
|
36636
36908
|
// src/commands/screenshot/index.ts
|
|
36637
|
-
import { execSync as
|
|
36638
|
-
import { existsSync as
|
|
36909
|
+
import { execSync as execSync66 } from "child_process";
|
|
36910
|
+
import { existsSync as existsSync86, mkdirSync as mkdirSync36, unlinkSync as unlinkSync22, writeFileSync as writeFileSync53 } from "fs";
|
|
36639
36911
|
import { tmpdir as tmpdir9 } from "os";
|
|
36640
36912
|
import { join as join101, resolve as resolve21 } from "path";
|
|
36641
|
-
import
|
|
36913
|
+
import chalk236 from "chalk";
|
|
36642
36914
|
|
|
36643
36915
|
// src/commands/screenshot/captureWindowPs1.ts
|
|
36644
36916
|
var captureWindowPs1 = `
|
|
@@ -36767,7 +37039,7 @@ Write-Output $OutputPath
|
|
|
36767
37039
|
|
|
36768
37040
|
// src/commands/screenshot/index.ts
|
|
36769
37041
|
function buildOutputPath(outputDir, processName) {
|
|
36770
|
-
if (!
|
|
37042
|
+
if (!existsSync86(outputDir)) {
|
|
36771
37043
|
mkdirSync36(outputDir, { recursive: true });
|
|
36772
37044
|
}
|
|
36773
37045
|
const timestamp6 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
@@ -36777,7 +37049,7 @@ function runPowerShellScript(processName, outputPath) {
|
|
|
36777
37049
|
const scriptPath = join101(tmpdir9(), `assist-screenshot-${Date.now()}.ps1`);
|
|
36778
37050
|
writeFileSync53(scriptPath, captureWindowPs1, "utf8");
|
|
36779
37051
|
try {
|
|
36780
|
-
|
|
37052
|
+
execSync66(
|
|
36781
37053
|
`powershell -NoProfile -ExecutionPolicy Bypass -File "${scriptPath}" -ProcessName "${processName}" -OutputPath "${outputPath}"`,
|
|
36782
37054
|
{ stdio: ["ignore", "pipe", "pipe"], encoding: "utf8" }
|
|
36783
37055
|
);
|
|
@@ -36789,13 +37061,13 @@ function screenshot(processName) {
|
|
|
36789
37061
|
const config = loadConfig();
|
|
36790
37062
|
const outputDir = resolve21(config.screenshot.outputDir);
|
|
36791
37063
|
const outputPath = buildOutputPath(outputDir, processName);
|
|
36792
|
-
console.log(
|
|
37064
|
+
console.log(chalk236.gray(`Capturing window for process "${processName}" ...`));
|
|
36793
37065
|
try {
|
|
36794
37066
|
runPowerShellScript(processName, outputPath);
|
|
36795
|
-
console.log(
|
|
37067
|
+
console.log(chalk236.green(`Screenshot saved: ${outputPath}`));
|
|
36796
37068
|
} catch (error) {
|
|
36797
37069
|
const msg = error instanceof Error ? error.message : String(error);
|
|
36798
|
-
console.error(
|
|
37070
|
+
console.error(chalk236.red(`Failed to capture screenshot: ${msg}`));
|
|
36799
37071
|
process.exit(1);
|
|
36800
37072
|
}
|
|
36801
37073
|
}
|
|
@@ -36851,11 +37123,11 @@ function applyLine(result, pending, line) {
|
|
|
36851
37123
|
}
|
|
36852
37124
|
|
|
36853
37125
|
// src/commands/sessions/daemon/readDaemonPidFile.ts
|
|
36854
|
-
import { readFileSync as
|
|
37126
|
+
import { readFileSync as readFileSync64 } from "fs";
|
|
36855
37127
|
function readDaemonPidFile() {
|
|
36856
37128
|
try {
|
|
36857
37129
|
const pid = Number.parseInt(
|
|
36858
|
-
|
|
37130
|
+
readFileSync64(daemonPaths.pid, "utf8").trim(),
|
|
36859
37131
|
10
|
|
36860
37132
|
);
|
|
36861
37133
|
return Number.isInteger(pid) ? pid : void 0;
|
|
@@ -37118,12 +37390,12 @@ function toSessionRunInfo({
|
|
|
37118
37390
|
}
|
|
37119
37391
|
|
|
37120
37392
|
// src/commands/sessions/daemon/worktree/joinRefusal.ts
|
|
37121
|
-
import { existsSync as
|
|
37393
|
+
import { existsSync as existsSync87 } from "fs";
|
|
37122
37394
|
function joinRefusal(session) {
|
|
37123
37395
|
if (session.commandType === "run") return "a server run has no agent stream";
|
|
37124
37396
|
if (session.closing === true) return "the session is closing";
|
|
37125
37397
|
if (!session.cwd) return "the session has no working directory";
|
|
37126
|
-
if (!
|
|
37398
|
+
if (!existsSync87(session.cwd))
|
|
37127
37399
|
return "the session's workspace no longer exists";
|
|
37128
37400
|
return void 0;
|
|
37129
37401
|
}
|
|
@@ -37287,11 +37559,11 @@ function sessionBase(id, status3) {
|
|
|
37287
37559
|
}
|
|
37288
37560
|
|
|
37289
37561
|
// src/commands/sessions/daemon/spawnPty.ts
|
|
37290
|
-
import { existsSync as
|
|
37562
|
+
import { existsSync as existsSync89 } from "fs";
|
|
37291
37563
|
import * as pty from "node-pty";
|
|
37292
37564
|
|
|
37293
37565
|
// src/commands/sessions/daemon/ensureSpawnHelperExecutable.ts
|
|
37294
|
-
import { chmodSync, existsSync as
|
|
37566
|
+
import { chmodSync, existsSync as existsSync88, statSync as statSync13 } from "fs";
|
|
37295
37567
|
import { createRequire as createRequire3 } from "module";
|
|
37296
37568
|
import path86 from "path";
|
|
37297
37569
|
var require4 = createRequire3(import.meta.url);
|
|
@@ -37306,7 +37578,7 @@ function ensureSpawnHelperExecutable() {
|
|
|
37306
37578
|
`${process.platform}-${process.arch}`,
|
|
37307
37579
|
"spawn-helper"
|
|
37308
37580
|
);
|
|
37309
|
-
if (!
|
|
37581
|
+
if (!existsSync88(helper)) return;
|
|
37310
37582
|
const mode = statSync13(helper).mode;
|
|
37311
37583
|
if ((mode & 73) === 0) chmodSync(helper, mode | 493);
|
|
37312
37584
|
}
|
|
@@ -37342,7 +37614,7 @@ function spawnPty(args, cwd, sessionId, extraEnv) {
|
|
|
37342
37614
|
});
|
|
37343
37615
|
}
|
|
37344
37616
|
function refuseMissingCwd(cwd, sessionId) {
|
|
37345
|
-
if (!cwd ||
|
|
37617
|
+
if (!cwd || existsSync89(cwd)) return;
|
|
37346
37618
|
daemonLog(
|
|
37347
37619
|
`${sessionId ? `session ${sessionId}` : "pty"} not spawned: working directory ${cwd} no longer exists`
|
|
37348
37620
|
);
|
|
@@ -37531,11 +37803,11 @@ function setStatus2(session, newStatus) {
|
|
|
37531
37803
|
}
|
|
37532
37804
|
|
|
37533
37805
|
// src/commands/sessions/daemon/worktree/reapWorktree.ts
|
|
37534
|
-
import { existsSync as
|
|
37535
|
-
import { basename as
|
|
37806
|
+
import { existsSync as existsSync91 } from "fs";
|
|
37807
|
+
import { basename as basename26 } from "path";
|
|
37536
37808
|
|
|
37537
37809
|
// src/commands/sessions/daemon/worktree/deleteStrandedTree.ts
|
|
37538
|
-
import { existsSync as
|
|
37810
|
+
import { existsSync as existsSync90 } from "fs";
|
|
37539
37811
|
import { join as join104 } from "path";
|
|
37540
37812
|
|
|
37541
37813
|
// src/commands/sessions/daemon/worktree/deleteTreeDirectly.ts
|
|
@@ -37605,7 +37877,7 @@ async function deleteStrandedTree(clone, worktreePath, cause) {
|
|
|
37605
37877
|
);
|
|
37606
37878
|
}
|
|
37607
37879
|
function strandedReason(worktreePath, cause) {
|
|
37608
|
-
if (!
|
|
37880
|
+
if (!existsSync90(join104(worktreePath, ".git")))
|
|
37609
37881
|
return "its .git link is already gone";
|
|
37610
37882
|
if (/not a working tree|not a git repository/i.test(reason2(cause)))
|
|
37611
37883
|
return "git no longer recognises it as a working tree";
|
|
@@ -37657,7 +37929,7 @@ function reason3(error) {
|
|
|
37657
37929
|
|
|
37658
37930
|
// src/commands/sessions/daemon/worktree/reapWorktree.ts
|
|
37659
37931
|
async function reapWorktree(worktreePath, force = false) {
|
|
37660
|
-
if (!
|
|
37932
|
+
if (!existsSync91(worktreePath)) {
|
|
37661
37933
|
forgetWorktree(worktreePath);
|
|
37662
37934
|
daemonLog(
|
|
37663
37935
|
`worktree ${worktreePath} already gone; its record was forgotten`
|
|
@@ -37675,14 +37947,14 @@ async function reapWorktree(worktreePath, force = false) {
|
|
|
37675
37947
|
const clone = owningClone(worktreePath);
|
|
37676
37948
|
const removal = await removeTree(clone, worktreePath, force);
|
|
37677
37949
|
if (!removal.removed) return removal;
|
|
37678
|
-
await deleteWorktreeBranch(clone,
|
|
37950
|
+
await deleteWorktreeBranch(clone, basename26(worktreePath));
|
|
37679
37951
|
forgetWorktree(worktreePath);
|
|
37680
37952
|
daemonLog(`worktree ${worktreePath} reaped${force ? " (forced)" : ""}`);
|
|
37681
37953
|
return removal;
|
|
37682
37954
|
}
|
|
37683
37955
|
function owningClone(worktreePath) {
|
|
37684
37956
|
const recorded = worktreeAttributionIncludingReaped(worktreePath)?.clone;
|
|
37685
|
-
if (recorded &&
|
|
37957
|
+
if (recorded && existsSync91(recorded)) return recorded;
|
|
37686
37958
|
const detected = mainWorktree(worktreePath);
|
|
37687
37959
|
if (detected) return detected;
|
|
37688
37960
|
daemonLog(
|
|
@@ -37813,12 +38085,12 @@ function closeGateApplies(sessions, session) {
|
|
|
37813
38085
|
}
|
|
37814
38086
|
|
|
37815
38087
|
// src/commands/sessions/daemon/worktree/watchGitState.ts
|
|
37816
|
-
import { existsSync as
|
|
38088
|
+
import { existsSync as existsSync92, watch } from "fs";
|
|
37817
38089
|
var DEBOUNCE_MS = 500;
|
|
37818
38090
|
var POLL_MS = 3e4;
|
|
37819
38091
|
function watchGitState(cwd, onChange) {
|
|
37820
38092
|
const common = gitCommonDir(cwd);
|
|
37821
|
-
if (!common || !
|
|
38093
|
+
if (!common || !existsSync92(common)) return void 0;
|
|
37822
38094
|
const watchers = [
|
|
37823
38095
|
watchGitDir(common, onChange),
|
|
37824
38096
|
pollGitState(cwd, onChange)
|
|
@@ -38313,10 +38585,10 @@ function emitSessionOutput(session, clients, data) {
|
|
|
38313
38585
|
}
|
|
38314
38586
|
|
|
38315
38587
|
// src/commands/sessions/daemon/exitReason.ts
|
|
38316
|
-
import { existsSync as
|
|
38588
|
+
import { existsSync as existsSync93 } from "fs";
|
|
38317
38589
|
import { resolve as resolve22 } from "path";
|
|
38318
38590
|
function exitDetail(session) {
|
|
38319
|
-
if (session.cwd && !
|
|
38591
|
+
if (session.cwd && !existsSync93(session.cwd))
|
|
38320
38592
|
return `working directory ${session.cwd} no longer exists`;
|
|
38321
38593
|
return missingRunConfigCwd(session);
|
|
38322
38594
|
}
|
|
@@ -38330,7 +38602,7 @@ function missingRunConfigCwd(session) {
|
|
|
38330
38602
|
const config = resolveRunConfig(session.runName, dir);
|
|
38331
38603
|
if (!config?.cwd) return void 0;
|
|
38332
38604
|
const configured = resolve22(runConfigBaseDirFrom(dir), config.cwd);
|
|
38333
|
-
if (
|
|
38605
|
+
if (existsSync93(configured)) return void 0;
|
|
38334
38606
|
return `run config "${config.name}": cwd ${configured} does not exist`;
|
|
38335
38607
|
}
|
|
38336
38608
|
|
|
@@ -38367,7 +38639,7 @@ function handleFailedResume(session, exitCode, onStatusChange) {
|
|
|
38367
38639
|
}
|
|
38368
38640
|
|
|
38369
38641
|
// src/commands/sessions/daemon/watchActivity.ts
|
|
38370
|
-
import { existsSync as
|
|
38642
|
+
import { existsSync as existsSync94, mkdirSync as mkdirSync37, watch as watch2 } from "fs";
|
|
38371
38643
|
import { dirname as dirname41 } from "path";
|
|
38372
38644
|
|
|
38373
38645
|
// src/commands/sessions/daemon/applyActivityToSession.ts
|
|
@@ -38453,7 +38725,7 @@ function watchActivity(session, notify2, onClaudeSessionId) {
|
|
|
38453
38725
|
if (timer) clearTimeout(timer);
|
|
38454
38726
|
timer = setTimeout(read3, DEBOUNCE_MS2);
|
|
38455
38727
|
});
|
|
38456
|
-
if (
|
|
38728
|
+
if (existsSync94(path91)) read3();
|
|
38457
38729
|
}
|
|
38458
38730
|
function refreshActivity(session) {
|
|
38459
38731
|
if (session.commandType !== "assist" || !session.cwd) return;
|
|
@@ -40176,8 +40448,8 @@ function rearmStoppedSessions(sessions, notify2) {
|
|
|
40176
40448
|
}
|
|
40177
40449
|
|
|
40178
40450
|
// src/commands/sessions/daemon/worktree/reconcileWorktreesOnRestore.ts
|
|
40179
|
-
import { existsSync as
|
|
40180
|
-
import { basename as
|
|
40451
|
+
import { existsSync as existsSync97 } from "fs";
|
|
40452
|
+
import { basename as basename28 } from "path";
|
|
40181
40453
|
|
|
40182
40454
|
// src/commands/sessions/daemon/worktree/accountedTrees.ts
|
|
40183
40455
|
function accountedTrees(sessions) {
|
|
@@ -40231,9 +40503,9 @@ function bindResumedWorktree(session, cwd, notify2) {
|
|
|
40231
40503
|
}
|
|
40232
40504
|
|
|
40233
40505
|
// src/commands/sessions/daemon/worktree/reclaimVanishedWorktrees.ts
|
|
40234
|
-
import { existsSync as
|
|
40506
|
+
import { existsSync as existsSync96 } from "fs";
|
|
40235
40507
|
async function reclaimVanishedWorktrees(clone, paths) {
|
|
40236
|
-
if (!
|
|
40508
|
+
if (!existsSync96(clone)) {
|
|
40237
40509
|
for (const { path: path91 } of paths) forgetWorktree(path91);
|
|
40238
40510
|
daemonLog(
|
|
40239
40511
|
`clone ${clone} is gone; forgot ${paths.length} worktree record(s) it owned`
|
|
@@ -40319,7 +40591,7 @@ function capped(lines2) {
|
|
|
40319
40591
|
}
|
|
40320
40592
|
|
|
40321
40593
|
// src/commands/sessions/daemon/worktree/resurfaceOrphanedWorktree.ts
|
|
40322
|
-
import { basename as
|
|
40594
|
+
import { basename as basename27 } from "path";
|
|
40323
40595
|
function resurfaceOrphanedWorktree(sessions, spawnWith, recovered, notify2) {
|
|
40324
40596
|
const { orphan, reason: reason4, held } = recovered;
|
|
40325
40597
|
let id;
|
|
@@ -40342,7 +40614,7 @@ function orphanedSession(id, recovered) {
|
|
|
40342
40614
|
const { orphan, reason: reason4, held } = recovered;
|
|
40343
40615
|
return {
|
|
40344
40616
|
...sessionBase(id, "stopped"),
|
|
40345
|
-
name: `recovered ${
|
|
40617
|
+
name: `recovered ${basename27(orphan.path)}`,
|
|
40346
40618
|
subtitle: `${held.summary} in ${orphan.path}`,
|
|
40347
40619
|
commandType: "claude",
|
|
40348
40620
|
pty: null,
|
|
@@ -40399,11 +40671,11 @@ async function recoverOrphanedWorktrees(sessions, spawnWith, notify2) {
|
|
|
40399
40671
|
);
|
|
40400
40672
|
continue;
|
|
40401
40673
|
}
|
|
40402
|
-
if (!
|
|
40674
|
+
if (!existsSync97(path91)) {
|
|
40403
40675
|
logVanishedTree(sessions, path91);
|
|
40404
40676
|
vanished.set(clone, [
|
|
40405
40677
|
...vanished.get(clone) ?? [],
|
|
40406
|
-
{ path: path91, branch:
|
|
40678
|
+
{ path: path91, branch: basename28(path91) }
|
|
40407
40679
|
]);
|
|
40408
40680
|
continue;
|
|
40409
40681
|
}
|
|
@@ -41051,14 +41323,14 @@ async function defaultConnect() {
|
|
|
41051
41323
|
}
|
|
41052
41324
|
|
|
41053
41325
|
// src/commands/sessions/daemon/hasPersistedWindowsSessions.ts
|
|
41054
|
-
import { existsSync as
|
|
41326
|
+
import { existsSync as existsSync98, readFileSync as readFileSync66 } from "fs";
|
|
41055
41327
|
import { posix as posix3 } from "path";
|
|
41056
41328
|
function hasPersistedWindowsSessions() {
|
|
41057
41329
|
const sessionsFile = windowsSessionsFileFromWsl();
|
|
41058
41330
|
if (!sessionsFile) return false;
|
|
41059
41331
|
try {
|
|
41060
|
-
if (!
|
|
41061
|
-
const data = JSON.parse(
|
|
41332
|
+
if (!existsSync98(sessionsFile)) return false;
|
|
41333
|
+
const data = JSON.parse(readFileSync66(sessionsFile, "utf8"));
|
|
41062
41334
|
return Array.isArray(data) && data.length > 0;
|
|
41063
41335
|
} catch (error) {
|
|
41064
41336
|
const message3 = error instanceof Error ? error.message : String(error);
|
|
@@ -41792,7 +42064,7 @@ function setAutoAdvance(sessions, id, enabled) {
|
|
|
41792
42064
|
}
|
|
41793
42065
|
|
|
41794
42066
|
// src/commands/sessions/daemon/worktree/resumeInTree.ts
|
|
41795
|
-
import { existsSync as
|
|
42067
|
+
import { existsSync as existsSync101 } from "fs";
|
|
41796
42068
|
|
|
41797
42069
|
// src/commands/sessions/daemon/resumeSession.ts
|
|
41798
42070
|
function resumeSession(id, sessionId, cwd, name, holdPty, harness) {
|
|
@@ -41823,10 +42095,10 @@ function resumeSession(id, sessionId, cwd, name, holdPty, harness) {
|
|
|
41823
42095
|
}
|
|
41824
42096
|
|
|
41825
42097
|
// src/commands/sessions/daemon/worktree/resumeInReplacementTree.ts
|
|
41826
|
-
import { existsSync as
|
|
42098
|
+
import { existsSync as existsSync100 } from "fs";
|
|
41827
42099
|
|
|
41828
42100
|
// src/commands/sessions/daemon/worktree/carryTranscriptToTree.ts
|
|
41829
|
-
import { copyFileSync as copyFileSync5, existsSync as
|
|
42101
|
+
import { copyFileSync as copyFileSync5, existsSync as existsSync99, mkdirSync as mkdirSync39 } from "fs";
|
|
41830
42102
|
import { join as join106 } from "path";
|
|
41831
42103
|
function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
41832
42104
|
const dir = projectDirForCwd(toCwd);
|
|
@@ -41837,7 +42109,7 @@ function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
|
41837
42109
|
return;
|
|
41838
42110
|
}
|
|
41839
42111
|
const dest = join106(dir, `${claudeSessionId}.jsonl`);
|
|
41840
|
-
if (
|
|
42112
|
+
if (existsSync99(dest)) {
|
|
41841
42113
|
daemonLog(`transcript ${claudeSessionId} already present in ${dir}`);
|
|
41842
42114
|
return;
|
|
41843
42115
|
}
|
|
@@ -41888,7 +42160,7 @@ function resumeInReplacementTree(ctx, claudeSessionId, missingCwd, name, harness
|
|
|
41888
42160
|
}
|
|
41889
42161
|
function cloneForReapedTree(missingCwd) {
|
|
41890
42162
|
const clone = worktreeAttributionIncludingReaped(missingCwd)?.clone;
|
|
41891
|
-
if (!clone || !
|
|
42163
|
+
if (!clone || !existsSync100(clone))
|
|
41892
42164
|
throw new Error(
|
|
41893
42165
|
`working directory no longer exists and no clone is recorded to re-allocate from: ${missingCwd}`
|
|
41894
42166
|
);
|
|
@@ -41897,7 +42169,7 @@ function cloneForReapedTree(missingCwd) {
|
|
|
41897
42169
|
|
|
41898
42170
|
// src/commands/sessions/daemon/worktree/resumeInTree.ts
|
|
41899
42171
|
function resumeInTree(ctx, sessionId, cwd, name, harness) {
|
|
41900
|
-
if (!
|
|
42172
|
+
if (!existsSync101(cwd))
|
|
41901
42173
|
return resumeInReplacementTree(ctx, sessionId, cwd, name, harness);
|
|
41902
42174
|
const id = ctx.spawnWith(
|
|
41903
42175
|
(sid) => resumeSession(sid, sessionId, cwd, name, void 0, harness)
|
|
@@ -42483,7 +42755,7 @@ function handleConnection(socket, manager) {
|
|
|
42483
42755
|
import { unlinkSync as unlinkSync23, writeFileSync as writeFileSync54 } from "fs";
|
|
42484
42756
|
|
|
42485
42757
|
// src/commands/sessions/daemon/startPidFileWatchdog.ts
|
|
42486
|
-
import { readFileSync as
|
|
42758
|
+
import { readFileSync as readFileSync67 } from "fs";
|
|
42487
42759
|
var WATCHDOG_INTERVAL_MS = 5e3;
|
|
42488
42760
|
function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
|
|
42489
42761
|
const timer = setInterval(() => {
|
|
@@ -42494,7 +42766,7 @@ function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
|
|
|
42494
42766
|
}
|
|
42495
42767
|
function ownsPidFile() {
|
|
42496
42768
|
try {
|
|
42497
|
-
return
|
|
42769
|
+
return readFileSync67(daemonPaths.pid, "utf8").trim() === String(process.pid);
|
|
42498
42770
|
} catch {
|
|
42499
42771
|
return false;
|
|
42500
42772
|
}
|
|
@@ -42776,7 +43048,7 @@ async function renameSession(title) {
|
|
|
42776
43048
|
|
|
42777
43049
|
// src/commands/sessions/summarise/index.ts
|
|
42778
43050
|
import * as fs57 from "fs";
|
|
42779
|
-
import
|
|
43051
|
+
import chalk237 from "chalk";
|
|
42780
43052
|
|
|
42781
43053
|
// src/commands/sessions/summarise/shared.ts
|
|
42782
43054
|
import * as fs56 from "fs";
|
|
@@ -42835,22 +43107,22 @@ ${firstMessage}`);
|
|
|
42835
43107
|
async function summarise2(options2) {
|
|
42836
43108
|
const files = await discoverSessionFiles();
|
|
42837
43109
|
if (files.length === 0) {
|
|
42838
|
-
console.log(
|
|
43110
|
+
console.log(chalk237.yellow("No sessions found."));
|
|
42839
43111
|
return;
|
|
42840
43112
|
}
|
|
42841
43113
|
const toProcess = selectCandidates(files, options2);
|
|
42842
43114
|
if (toProcess.length === 0) {
|
|
42843
|
-
console.log(
|
|
43115
|
+
console.log(chalk237.green("All sessions already summarised."));
|
|
42844
43116
|
return;
|
|
42845
43117
|
}
|
|
42846
43118
|
console.log(
|
|
42847
|
-
|
|
43119
|
+
chalk237.cyan(
|
|
42848
43120
|
`Summarising ${toProcess.length} session(s) (${files.length} total)\u2026`
|
|
42849
43121
|
)
|
|
42850
43122
|
);
|
|
42851
43123
|
const { succeeded, failed: failed2 } = processSessions(toProcess);
|
|
42852
43124
|
console.log(
|
|
42853
|
-
|
|
43125
|
+
chalk237.green(`Done: ${succeeded} summarised`) + (failed2 > 0 ? chalk237.yellow(`, ${failed2} skipped`) : "")
|
|
42854
43126
|
);
|
|
42855
43127
|
}
|
|
42856
43128
|
function selectCandidates(files, options2) {
|
|
@@ -42870,16 +43142,16 @@ function processSessions(files) {
|
|
|
42870
43142
|
let failed2 = 0;
|
|
42871
43143
|
for (let i = 0; i < files.length; i++) {
|
|
42872
43144
|
const file = files[i];
|
|
42873
|
-
process.stdout.write(
|
|
43145
|
+
process.stdout.write(chalk237.dim(` [${i + 1}/${files.length}] `));
|
|
42874
43146
|
const summary = summariseSession(file);
|
|
42875
43147
|
if (summary) {
|
|
42876
43148
|
writeSummary(file, summary);
|
|
42877
43149
|
succeeded++;
|
|
42878
|
-
process.stdout.write(`${
|
|
43150
|
+
process.stdout.write(`${chalk237.green("\u2713")} ${summary}
|
|
42879
43151
|
`);
|
|
42880
43152
|
} else {
|
|
42881
43153
|
failed2++;
|
|
42882
|
-
process.stdout.write(` ${
|
|
43154
|
+
process.stdout.write(` ${chalk237.yellow("skip")}
|
|
42883
43155
|
`);
|
|
42884
43156
|
}
|
|
42885
43157
|
}
|
|
@@ -42906,7 +43178,7 @@ function registerSessions(program2) {
|
|
|
42906
43178
|
}
|
|
42907
43179
|
|
|
42908
43180
|
// src/commands/statusLine.ts
|
|
42909
|
-
import
|
|
43181
|
+
import chalk239 from "chalk";
|
|
42910
43182
|
|
|
42911
43183
|
// src/shared/contextLevel.ts
|
|
42912
43184
|
function contextLevel(pct) {
|
|
@@ -42916,7 +43188,7 @@ function contextLevel(pct) {
|
|
|
42916
43188
|
}
|
|
42917
43189
|
|
|
42918
43190
|
// src/commands/buildLimitsSegment.ts
|
|
42919
|
-
import
|
|
43191
|
+
import chalk238 from "chalk";
|
|
42920
43192
|
|
|
42921
43193
|
// src/shared/rateLimitLevel.ts
|
|
42922
43194
|
var FIVE_HOUR_SECONDS = 5 * 3600;
|
|
@@ -42954,9 +43226,9 @@ function rateLimitLevel(pct, resetsAt, windowSeconds, now) {
|
|
|
42954
43226
|
|
|
42955
43227
|
// src/commands/buildLimitsSegment.ts
|
|
42956
43228
|
var LEVEL_COLOR = {
|
|
42957
|
-
ok:
|
|
42958
|
-
warn:
|
|
42959
|
-
over:
|
|
43229
|
+
ok: chalk238.green,
|
|
43230
|
+
warn: chalk238.yellow,
|
|
43231
|
+
over: chalk238.red
|
|
42960
43232
|
};
|
|
42961
43233
|
function formatLimit(pct, resetsAt, windowSeconds, fallbackLabel, now) {
|
|
42962
43234
|
const level = rateLimitLevel(pct, resetsAt, windowSeconds, now);
|
|
@@ -42987,7 +43259,7 @@ function buildLimitsSegment(rateLimits) {
|
|
|
42987
43259
|
}
|
|
42988
43260
|
|
|
42989
43261
|
// src/commands/readGitBranch.ts
|
|
42990
|
-
import { readFileSync as
|
|
43262
|
+
import { readFileSync as readFileSync69, statSync as statSync16 } from "fs";
|
|
42991
43263
|
import { isAbsolute as isAbsolute5, join as join107, resolve as resolve23 } from "path";
|
|
42992
43264
|
function resolveGitDir(cwd) {
|
|
42993
43265
|
const dotGit = join107(cwd, ".git");
|
|
@@ -43002,7 +43274,7 @@ function resolveGitDir(cwd) {
|
|
|
43002
43274
|
}
|
|
43003
43275
|
let contents;
|
|
43004
43276
|
try {
|
|
43005
|
-
contents =
|
|
43277
|
+
contents = readFileSync69(dotGit, "utf8");
|
|
43006
43278
|
} catch {
|
|
43007
43279
|
return null;
|
|
43008
43280
|
}
|
|
@@ -43020,7 +43292,7 @@ function readGitBranch(cwd) {
|
|
|
43020
43292
|
}
|
|
43021
43293
|
let head;
|
|
43022
43294
|
try {
|
|
43023
|
-
head =
|
|
43295
|
+
head = readFileSync69(join107(gitDir, "HEAD"), "utf8");
|
|
43024
43296
|
} catch {
|
|
43025
43297
|
return null;
|
|
43026
43298
|
}
|
|
@@ -43052,7 +43324,7 @@ async function relayUsage(claudeSessionId, transcriptPath2, usedPct) {
|
|
|
43052
43324
|
}
|
|
43053
43325
|
|
|
43054
43326
|
// src/commands/statusLine.ts
|
|
43055
|
-
|
|
43327
|
+
chalk239.level = 3;
|
|
43056
43328
|
function formatNumber(num) {
|
|
43057
43329
|
return num.toLocaleString("en-US");
|
|
43058
43330
|
}
|
|
@@ -43060,9 +43332,9 @@ function colorizePercent(pct) {
|
|
|
43060
43332
|
const label2 = `${Math.round(pct)}%`;
|
|
43061
43333
|
switch (contextLevel(pct)) {
|
|
43062
43334
|
case "red":
|
|
43063
|
-
return
|
|
43335
|
+
return chalk239.red(label2);
|
|
43064
43336
|
case "yellow":
|
|
43065
|
-
return
|
|
43337
|
+
return chalk239.yellow(label2);
|
|
43066
43338
|
default:
|
|
43067
43339
|
return label2;
|
|
43068
43340
|
}
|
|
@@ -43075,7 +43347,7 @@ async function statusLine() {
|
|
|
43075
43347
|
const usedPct = data.context_window.used_percentage ?? 0;
|
|
43076
43348
|
const dir = data.workspace?.current_dir ?? data.cwd;
|
|
43077
43349
|
const branch2 = dir ? readGitBranch(toGitCwd(dir)) : null;
|
|
43078
|
-
const branchSegment = branch2 ? `\u{1F33F}\uFE0F ${
|
|
43350
|
+
const branchSegment = branch2 ? `\u{1F33F}\uFE0F ${chalk239.cyan(branch2)} | ` : "";
|
|
43079
43351
|
console.log(
|
|
43080
43352
|
`${branchSegment}${model} | Tokens - ${formatNumber(totalIn)} \u2191 : ${formatNumber(totalOut)} \u2193 | Context - ${colorizePercent(usedPct)}${buildLimitsSegment(data.rate_limits)}`
|
|
43081
43353
|
);
|
|
@@ -43088,7 +43360,7 @@ async function statusLine() {
|
|
|
43088
43360
|
}
|
|
43089
43361
|
|
|
43090
43362
|
// src/commands/update.ts
|
|
43091
|
-
import { execSync as
|
|
43363
|
+
import { execSync as execSync67 } from "child_process";
|
|
43092
43364
|
import * as path90 from "path";
|
|
43093
43365
|
|
|
43094
43366
|
// src/commands/restartDaemonAfterUpdate.ts
|
|
@@ -43112,7 +43384,7 @@ function isGlobalNpmInstall(dir) {
|
|
|
43112
43384
|
if (resolved.split(path90.sep).includes("node_modules")) {
|
|
43113
43385
|
return true;
|
|
43114
43386
|
}
|
|
43115
|
-
const globalPrefix =
|
|
43387
|
+
const globalPrefix = execSync67("npm prefix -g", { stdio: "pipe" }).toString().trim();
|
|
43116
43388
|
return resolved.toLowerCase().startsWith(path90.resolve(globalPrefix).toLowerCase());
|
|
43117
43389
|
} catch {
|
|
43118
43390
|
return false;
|
|
@@ -43123,18 +43395,18 @@ async function update2() {
|
|
|
43123
43395
|
console.log(`Assist is installed at: ${installDir}`);
|
|
43124
43396
|
if (isGitRepo(installDir)) {
|
|
43125
43397
|
console.log("Detected git repo installation, pulling latest...");
|
|
43126
|
-
|
|
43398
|
+
execSync67("git pull", { cwd: installDir, stdio: "inherit" });
|
|
43127
43399
|
console.log("Installing dependencies...");
|
|
43128
|
-
|
|
43400
|
+
execSync67("npm i", { cwd: installDir, stdio: "inherit" });
|
|
43129
43401
|
console.log("Building...");
|
|
43130
|
-
|
|
43402
|
+
execSync67("npm run build", { cwd: installDir, stdio: "inherit" });
|
|
43131
43403
|
console.log("Syncing commands...");
|
|
43132
|
-
|
|
43404
|
+
execSync67("assist sync", { stdio: "inherit" });
|
|
43133
43405
|
} else if (isGlobalNpmInstall(installDir)) {
|
|
43134
43406
|
console.log("Detected global npm installation, updating...");
|
|
43135
|
-
|
|
43407
|
+
execSync67("npm i -g @staff0rd/assist@latest", { stdio: "inherit" });
|
|
43136
43408
|
console.log("Syncing commands...");
|
|
43137
|
-
|
|
43409
|
+
execSync67("assist sync", { stdio: "inherit" });
|
|
43138
43410
|
} else {
|
|
43139
43411
|
console.error(
|
|
43140
43412
|
"Could not determine installation method. Expected a git repo or global npm install."
|
|
@@ -43145,10 +43417,10 @@ async function update2() {
|
|
|
43145
43417
|
}
|
|
43146
43418
|
|
|
43147
43419
|
// src/reportCliError.ts
|
|
43148
|
-
import
|
|
43420
|
+
import chalk240 from "chalk";
|
|
43149
43421
|
function reportCliError(error) {
|
|
43150
43422
|
if (error instanceof InvalidItemIdError || error instanceof AmbiguousRepoConfigError || error instanceof UnknownRepoConfigError || error instanceof MissingRunCwdError || error instanceof MiroExtractError) {
|
|
43151
|
-
console.error(
|
|
43423
|
+
console.error(chalk240.red(error.message));
|
|
43152
43424
|
} else {
|
|
43153
43425
|
console.error(error);
|
|
43154
43426
|
}
|