@staff0rd/assist 0.676.0 → 0.677.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/dist/commands/sessions/web/bundle.js +435 -434
- package/dist/index.js +621 -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.677.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.`
|
|
@@ -19861,7 +19861,7 @@ async function sloc(pattern2 = "**/*.ts", options2 = {}) {
|
|
|
19861
19861
|
const color = exceedsThreshold ? chalk132.red : chalk132.white;
|
|
19862
19862
|
console.log(`${color(file)} \u2192 ${chalk132.cyan(lines2)} lines`);
|
|
19863
19863
|
}
|
|
19864
|
-
const total = results.reduce((
|
|
19864
|
+
const total = results.reduce((sum3, r) => sum3 + r.lines, 0);
|
|
19865
19865
|
console.log(
|
|
19866
19866
|
chalk132.dim(`
|
|
19867
19867
|
Total: ${total} lines across ${files.length} files`)
|
|
@@ -21711,14 +21711,14 @@ import fs29 from "fs";
|
|
|
21711
21711
|
|
|
21712
21712
|
// src/commands/editHook/introducedComments.ts
|
|
21713
21713
|
function introducedComments(added, removed) {
|
|
21714
|
-
const
|
|
21714
|
+
const counts2 = /* @__PURE__ */ new Map();
|
|
21715
21715
|
for (const comment3 of removed) {
|
|
21716
|
-
|
|
21716
|
+
counts2.set(comment3, (counts2.get(comment3) ?? 0) + 1);
|
|
21717
21717
|
}
|
|
21718
21718
|
const candidates = [];
|
|
21719
21719
|
for (const comment3 of added) {
|
|
21720
|
-
const remaining =
|
|
21721
|
-
if (remaining > 0)
|
|
21720
|
+
const remaining = counts2.get(comment3) ?? 0;
|
|
21721
|
+
if (remaining > 0) counts2.set(comment3, remaining - 1);
|
|
21722
21722
|
else candidates.push(comment3);
|
|
21723
21723
|
}
|
|
21724
21724
|
const removedWords = new Set(removed.flatMap(commentWords));
|
|
@@ -22073,7 +22073,7 @@ function fetchOrgRepoCommitCounts(org, since) {
|
|
|
22073
22073
|
// src/commands/github/fetchRepoCommitAuthors.ts
|
|
22074
22074
|
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
22075
|
function fetchRepoCommitAuthors(org, repo, since) {
|
|
22076
|
-
const
|
|
22076
|
+
const counts2 = /* @__PURE__ */ new Map();
|
|
22077
22077
|
let cursor;
|
|
22078
22078
|
for (; ; ) {
|
|
22079
22079
|
const vars = { org, repo, since };
|
|
@@ -22085,12 +22085,12 @@ function fetchRepoCommitAuthors(org, repo, since) {
|
|
|
22085
22085
|
if (!history) break;
|
|
22086
22086
|
for (const node of history.nodes) {
|
|
22087
22087
|
const author = node.author?.user?.login ?? node.author?.name ?? "unknown";
|
|
22088
|
-
|
|
22088
|
+
counts2.set(author, (counts2.get(author) ?? 0) + 1);
|
|
22089
22089
|
}
|
|
22090
22090
|
if (!history.pageInfo.hasNextPage) break;
|
|
22091
22091
|
cursor = history.pageInfo.endCursor ?? void 0;
|
|
22092
22092
|
}
|
|
22093
|
-
return [...
|
|
22093
|
+
return [...counts2].map(([author, commitCount]) => ({ author, commitCount })).sort((a, b) => b.commitCount - a.commitCount);
|
|
22094
22094
|
}
|
|
22095
22095
|
|
|
22096
22096
|
// src/commands/github/printCountTable.ts
|
|
@@ -30290,8 +30290,8 @@ function findRootParent(file, importedBy, visited) {
|
|
|
30290
30290
|
function clusterFiles(graph) {
|
|
30291
30291
|
const clusters = /* @__PURE__ */ new Map();
|
|
30292
30292
|
for (const file of graph.files) {
|
|
30293
|
-
const
|
|
30294
|
-
if (
|
|
30293
|
+
const basename30 = path62.basename(file, path62.extname(file));
|
|
30294
|
+
if (basename30 === "index") continue;
|
|
30295
30295
|
const importers = graph.importedBy.get(file);
|
|
30296
30296
|
if (!importers || importers.size !== 1) continue;
|
|
30297
30297
|
const parent = [...importers][0];
|
|
@@ -30601,50 +30601,109 @@ async function checkoutOnlySession(number) {
|
|
|
30601
30601
|
await done2;
|
|
30602
30602
|
}
|
|
30603
30603
|
|
|
30604
|
-
// src/commands/review/
|
|
30605
|
-
import
|
|
30606
|
-
function
|
|
30607
|
-
|
|
30608
|
-
|
|
30609
|
-
|
|
30604
|
+
// src/commands/review/highLevel/announceSavedReview.ts
|
|
30605
|
+
import chalk212 from "chalk";
|
|
30606
|
+
function announceSavedReview(subject, force) {
|
|
30607
|
+
const head = subject.headSha.slice(0, 7);
|
|
30608
|
+
if (subject.saved)
|
|
30609
|
+
console.log(
|
|
30610
|
+
chalk212.dim(
|
|
30611
|
+
`Reopening the review saved for ${head} at ${subject.saved.reviewedAt} (${subject.saved.verdict}); pass --force to start fresh.`
|
|
30612
|
+
)
|
|
30613
|
+
);
|
|
30614
|
+
else if (force)
|
|
30615
|
+
console.log(
|
|
30616
|
+
chalk212.dim(
|
|
30617
|
+
`Discarding any review saved for ${head} and starting fresh (--force).`
|
|
30618
|
+
)
|
|
30619
|
+
);
|
|
30610
30620
|
}
|
|
30611
|
-
|
|
30612
|
-
|
|
30613
|
-
|
|
30614
|
-
|
|
30615
|
-
|
|
30616
|
-
|
|
30617
|
-
|
|
30618
|
-
|
|
30619
|
-
|
|
30620
|
-
|
|
30621
|
+
|
|
30622
|
+
// src/commands/review/highLevel/groupFilesByDirectory.ts
|
|
30623
|
+
var emptyDirectoryGroup = () => ({
|
|
30624
|
+
dirs: /* @__PURE__ */ new Map(),
|
|
30625
|
+
files: []
|
|
30626
|
+
});
|
|
30627
|
+
function place(root, file) {
|
|
30628
|
+
const segments = file.path.split("/").filter(Boolean);
|
|
30629
|
+
segments.pop();
|
|
30630
|
+
let at2 = root;
|
|
30631
|
+
for (const segment of segments) {
|
|
30632
|
+
const next3 = at2.dirs.get(segment) ?? emptyDirectoryGroup();
|
|
30633
|
+
at2.dirs.set(segment, next3);
|
|
30634
|
+
at2 = next3;
|
|
30635
|
+
}
|
|
30636
|
+
at2.files.push(file);
|
|
30637
|
+
}
|
|
30638
|
+
function groupFilesByDirectory(files) {
|
|
30639
|
+
const root = emptyDirectoryGroup();
|
|
30640
|
+
for (const file of files) place(root, file);
|
|
30641
|
+
return root;
|
|
30642
|
+
}
|
|
30643
|
+
|
|
30644
|
+
// src/commands/review/highLevel/buildHighLevelTree.ts
|
|
30645
|
+
function basename20(path91) {
|
|
30646
|
+
return path91.slice(path91.lastIndexOf("/") + 1);
|
|
30647
|
+
}
|
|
30648
|
+
function sum(nodes, key) {
|
|
30649
|
+
return nodes.reduce((total, node) => total + node[key], 0);
|
|
30650
|
+
}
|
|
30651
|
+
function byName(a, b) {
|
|
30652
|
+
return a.name.localeCompare(b.name);
|
|
30653
|
+
}
|
|
30654
|
+
function nodesOf(at2, prefix2) {
|
|
30655
|
+
const dirs = [...at2.dirs].map(
|
|
30656
|
+
([name, child]) => collapsedDirNode(name, child, prefix2)
|
|
30657
|
+
);
|
|
30658
|
+
const files = at2.files.map(
|
|
30659
|
+
(file) => ({
|
|
30660
|
+
kind: "file",
|
|
30661
|
+
name: basename20(file.path),
|
|
30662
|
+
...file
|
|
30663
|
+
})
|
|
30621
30664
|
);
|
|
30622
|
-
|
|
30623
|
-
|
|
30624
|
-
|
|
30625
|
-
|
|
30626
|
-
|
|
30627
|
-
|
|
30628
|
-
|
|
30665
|
+
return [...dirs.sort(byName), ...files.sort(byName)];
|
|
30666
|
+
}
|
|
30667
|
+
function collapsedDirNode(name, at2, prefix2) {
|
|
30668
|
+
let label2 = name;
|
|
30669
|
+
let path91 = prefix2 ? `${prefix2}/${name}` : name;
|
|
30670
|
+
let node = at2;
|
|
30671
|
+
while (node.files.length === 0 && node.dirs.size === 1) {
|
|
30672
|
+
const [childName, child] = [...node.dirs][0];
|
|
30673
|
+
label2 = `${label2}/${childName}`;
|
|
30674
|
+
path91 = `${path91}/${childName}`;
|
|
30675
|
+
node = child;
|
|
30629
30676
|
}
|
|
30677
|
+
const children = nodesOf(node, path91);
|
|
30630
30678
|
return {
|
|
30631
|
-
|
|
30632
|
-
|
|
30633
|
-
|
|
30634
|
-
|
|
30635
|
-
|
|
30679
|
+
kind: "dir",
|
|
30680
|
+
name: label2,
|
|
30681
|
+
path: path91,
|
|
30682
|
+
additions: sum(children, "additions"),
|
|
30683
|
+
deletions: sum(children, "deletions"),
|
|
30684
|
+
children
|
|
30636
30685
|
};
|
|
30637
30686
|
}
|
|
30638
|
-
function
|
|
30639
|
-
|
|
30640
|
-
|
|
30641
|
-
|
|
30642
|
-
|
|
30643
|
-
|
|
30644
|
-
|
|
30645
|
-
|
|
30646
|
-
|
|
30647
|
-
return
|
|
30687
|
+
function buildHighLevelTree(files) {
|
|
30688
|
+
return nodesOf(groupFilesByDirectory(files), "");
|
|
30689
|
+
}
|
|
30690
|
+
|
|
30691
|
+
// src/commands/review/highLevel/buildHighLevelStructure.ts
|
|
30692
|
+
function sum2(files, key) {
|
|
30693
|
+
return files.reduce((total, file) => total + file[key], 0);
|
|
30694
|
+
}
|
|
30695
|
+
function countOf(files, status3) {
|
|
30696
|
+
return files.filter((file) => file.status === status3).length;
|
|
30697
|
+
}
|
|
30698
|
+
function buildHighLevelStructure(files) {
|
|
30699
|
+
return {
|
|
30700
|
+
tree: buildHighLevelTree(files),
|
|
30701
|
+
added: countOf(files, "added"),
|
|
30702
|
+
removed: countOf(files, "removed"),
|
|
30703
|
+
modified: countOf(files, "modified"),
|
|
30704
|
+
additions: sum2(files, "additions"),
|
|
30705
|
+
deletions: sum2(files, "deletions")
|
|
30706
|
+
};
|
|
30648
30707
|
}
|
|
30649
30708
|
|
|
30650
30709
|
// src/commands/review/highLevel/checkDescriptionLinksIssue.ts
|
|
@@ -30808,6 +30867,37 @@ function evaluateHighLevelChecks(subject) {
|
|
|
30808
30867
|
});
|
|
30809
30868
|
}
|
|
30810
30869
|
|
|
30870
|
+
// src/commands/review/highLevel/fetchHighLevelFiles.ts
|
|
30871
|
+
import { execSync as execSync58 } from "child_process";
|
|
30872
|
+
import { createHash as createHash3 } from "crypto";
|
|
30873
|
+
var JQ = ".[] | {filename,status,additions,deletions,patch} | @json";
|
|
30874
|
+
function toStatus(status3) {
|
|
30875
|
+
if (status3 === "added") return "added";
|
|
30876
|
+
if (status3 === "removed") return "removed";
|
|
30877
|
+
return "modified";
|
|
30878
|
+
}
|
|
30879
|
+
function diffUrl(repo, prNumber, path91) {
|
|
30880
|
+
const anchor = createHash3("sha256").update(path91).digest("hex");
|
|
30881
|
+
return `https://github.com/${repo}/pull/${prNumber}/files#diff-${anchor}`;
|
|
30882
|
+
}
|
|
30883
|
+
function fetchHighLevelFiles(prNumber, repo) {
|
|
30884
|
+
const out = execSync58(
|
|
30885
|
+
`gh api repos/${repo}/pulls/${prNumber}/files --paginate --jq '${JQ}'`,
|
|
30886
|
+
{ encoding: "utf8", maxBuffer: 64 * 1024 * 1024 }
|
|
30887
|
+
);
|
|
30888
|
+
return out.trim().split("\n").filter(Boolean).map((line) => {
|
|
30889
|
+
const file = JSON.parse(line);
|
|
30890
|
+
return {
|
|
30891
|
+
path: file.filename,
|
|
30892
|
+
status: toStatus(file.status),
|
|
30893
|
+
additions: file.additions,
|
|
30894
|
+
deletions: file.deletions,
|
|
30895
|
+
diffUrl: diffUrl(repo, prNumber, file.filename),
|
|
30896
|
+
...file.patch ? { patch: file.patch } : {}
|
|
30897
|
+
};
|
|
30898
|
+
});
|
|
30899
|
+
}
|
|
30900
|
+
|
|
30811
30901
|
// src/commands/review/highLevel/fetchHighLevelPr.ts
|
|
30812
30902
|
import { execSync as execSync59 } from "child_process";
|
|
30813
30903
|
function fetchHighLevelPr(prNumber, repo) {
|
|
@@ -30823,6 +30913,84 @@ function fetchHighLevelPr(prNumber, repo) {
|
|
|
30823
30913
|
};
|
|
30824
30914
|
}
|
|
30825
30915
|
|
|
30916
|
+
// src/commands/review/highLevel/loadHighLevelReview.ts
|
|
30917
|
+
import { existsSync as existsSync63, readFileSync as readFileSync47 } from "fs";
|
|
30918
|
+
|
|
30919
|
+
// src/commands/review/highLevel/highLevelReviewPath.ts
|
|
30920
|
+
import { join as join75 } from "path";
|
|
30921
|
+
function slug(value) {
|
|
30922
|
+
return value.replace(/[^\w.-]+/g, "-");
|
|
30923
|
+
}
|
|
30924
|
+
function highLevelReviewPath(repo, headRef, headSha) {
|
|
30925
|
+
return join75(
|
|
30926
|
+
getStoreDir(),
|
|
30927
|
+
"high-level-reviews",
|
|
30928
|
+
slug(repo),
|
|
30929
|
+
`${slug(headRef)}-${headSha}.json`
|
|
30930
|
+
);
|
|
30931
|
+
}
|
|
30932
|
+
|
|
30933
|
+
// src/commands/review/highLevel/loadHighLevelReview.ts
|
|
30934
|
+
function loadHighLevelReview(repo, headRef, headSha) {
|
|
30935
|
+
const path91 = highLevelReviewPath(repo, headRef, headSha);
|
|
30936
|
+
if (!existsSync63(path91)) return void 0;
|
|
30937
|
+
try {
|
|
30938
|
+
return JSON.parse(readFileSync47(path91, "utf8"));
|
|
30939
|
+
} catch {
|
|
30940
|
+
return void 0;
|
|
30941
|
+
}
|
|
30942
|
+
}
|
|
30943
|
+
|
|
30944
|
+
// src/commands/review/highLevel/resolveHighLevelConfig.ts
|
|
30945
|
+
var DEFAULT_DESCRIPTION_WORD_CAP = 300;
|
|
30946
|
+
function resolveHighLevelConfig(config) {
|
|
30947
|
+
const highLevel = config.review?.highLevel;
|
|
30948
|
+
return {
|
|
30949
|
+
criticalPaths: highLevel?.criticalPaths ?? [],
|
|
30950
|
+
uiPaths: highLevel?.uiPaths ?? [],
|
|
30951
|
+
descriptionWordCap: highLevel?.descriptionWordCap ?? DEFAULT_DESCRIPTION_WORD_CAP
|
|
30952
|
+
};
|
|
30953
|
+
}
|
|
30954
|
+
|
|
30955
|
+
// src/commands/review/highLevel/selectCriticalDiffs.ts
|
|
30956
|
+
import { minimatch as minimatch8 } from "minimatch";
|
|
30957
|
+
function selectCriticalDiffs(files, criticalPaths) {
|
|
30958
|
+
if (criticalPaths.length === 0) return [];
|
|
30959
|
+
return files.filter((file) => criticalPaths.some((glob) => minimatch8(file.path, glob))).map(({ path: path91, status: status3, additions, deletions, diffUrl: diffUrl2, patch: patch2 }) => ({
|
|
30960
|
+
path: path91,
|
|
30961
|
+
status: status3,
|
|
30962
|
+
additions,
|
|
30963
|
+
deletions,
|
|
30964
|
+
diffUrl: diffUrl2,
|
|
30965
|
+
patch: patch2 ?? null
|
|
30966
|
+
}));
|
|
30967
|
+
}
|
|
30968
|
+
|
|
30969
|
+
// src/commands/review/highLevel/gatherHighLevelSubject.ts
|
|
30970
|
+
function gatherHighLevelSubject(prNumber, force) {
|
|
30971
|
+
const { org, repo } = getRepoInfo();
|
|
30972
|
+
const slug2 = `${org}/${repo}`;
|
|
30973
|
+
const pr = fetchHighLevelPr(prNumber, { org, repo });
|
|
30974
|
+
const files = fetchHighLevelFiles(prNumber, slug2);
|
|
30975
|
+
const config = resolveHighLevelConfig(loadConfig());
|
|
30976
|
+
const saved = force ? void 0 : loadHighLevelReview(slug2, pr.headRef, pr.headSha);
|
|
30977
|
+
return {
|
|
30978
|
+
repo: slug2,
|
|
30979
|
+
prNumber,
|
|
30980
|
+
headRef: pr.headRef,
|
|
30981
|
+
headSha: pr.headSha,
|
|
30982
|
+
checks: evaluateHighLevelChecks({
|
|
30983
|
+
body: pr.body,
|
|
30984
|
+
changedFiles: files.map((file) => file.path),
|
|
30985
|
+
config
|
|
30986
|
+
}),
|
|
30987
|
+
structure: buildHighLevelStructure(files),
|
|
30988
|
+
criticalDiffs: selectCriticalDiffs(files, config.criticalPaths),
|
|
30989
|
+
criticalPaths: config.criticalPaths,
|
|
30990
|
+
...saved ? { saved } : {}
|
|
30991
|
+
};
|
|
30992
|
+
}
|
|
30993
|
+
|
|
30826
30994
|
// src/commands/review/highLevel/openHighLevelOverlay.ts
|
|
30827
30995
|
import { randomUUID as randomUUID17 } from "crypto";
|
|
30828
30996
|
|
|
@@ -30841,34 +31009,26 @@ function toItem2(check2, decision) {
|
|
|
30841
31009
|
};
|
|
30842
31010
|
}
|
|
30843
31011
|
function buildHighLevelRecord(subject, decision) {
|
|
30844
|
-
const { checks: checks2,
|
|
31012
|
+
const { checks: checks2, repo, prNumber, headRef, headSha } = subject;
|
|
30845
31013
|
return {
|
|
30846
|
-
|
|
31014
|
+
repo,
|
|
31015
|
+
prNumber,
|
|
31016
|
+
headRef,
|
|
31017
|
+
headSha,
|
|
30847
31018
|
verdict: decision.decision === "approve" ? "approve" : "request-changes",
|
|
30848
31019
|
reviewedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
30849
31020
|
items: checks2.map((check2) => toItem2(check2, decision))
|
|
30850
31021
|
};
|
|
30851
31022
|
}
|
|
30852
31023
|
|
|
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
|
-
);
|
|
31024
|
+
// src/commands/review/highLevel/highLevelChangedFileCount.ts
|
|
31025
|
+
function highLevelChangedFileCount(structure) {
|
|
31026
|
+
return structure.added + structure.removed + structure.modified;
|
|
30869
31027
|
}
|
|
30870
31028
|
|
|
30871
31029
|
// src/commands/review/highLevel/saveHighLevelReview.ts
|
|
31030
|
+
import { mkdirSync as mkdirSync21, writeFileSync as writeFileSync38 } from "fs";
|
|
31031
|
+
import { dirname as dirname34 } from "path";
|
|
30872
31032
|
function saveHighLevelReview(record) {
|
|
30873
31033
|
const path91 = highLevelReviewPath(record.repo, record.headRef, record.headSha);
|
|
30874
31034
|
mkdirSync21(dirname34(path91), { recursive: true });
|
|
@@ -30878,6 +31038,28 @@ function saveHighLevelReview(record) {
|
|
|
30878
31038
|
}
|
|
30879
31039
|
|
|
30880
31040
|
// src/commands/review/highLevel/openHighLevelOverlay.ts
|
|
31041
|
+
function payloadOf(subject) {
|
|
31042
|
+
const { checks: checks2, structure, criticalDiffs, criticalPaths, saved } = subject;
|
|
31043
|
+
return {
|
|
31044
|
+
checks: checks2,
|
|
31045
|
+
structure,
|
|
31046
|
+
criticalDiffs,
|
|
31047
|
+
criticalPaths,
|
|
31048
|
+
...saved ? { saved } : {}
|
|
31049
|
+
};
|
|
31050
|
+
}
|
|
31051
|
+
function metadataOf(subject) {
|
|
31052
|
+
return [
|
|
31053
|
+
{ label: "Branch", value: subject.headRef },
|
|
31054
|
+
{ label: "Head", value: subject.headSha.slice(0, 7) },
|
|
31055
|
+
{
|
|
31056
|
+
label: "Changed files",
|
|
31057
|
+
value: String(highLevelChangedFileCount(subject.structure))
|
|
31058
|
+
},
|
|
31059
|
+
{ label: "Critical files", value: String(subject.criticalDiffs.length) },
|
|
31060
|
+
...subject.saved ? [{ label: "Reopened from", value: subject.saved.reviewedAt }] : []
|
|
31061
|
+
];
|
|
31062
|
+
}
|
|
30881
31063
|
async function openHighLevelOverlay(sessionId, subject) {
|
|
30882
31064
|
const decision = await awaitPreviewApproval(
|
|
30883
31065
|
"High-level review",
|
|
@@ -30885,14 +31067,10 @@ async function openHighLevelOverlay(sessionId, subject) {
|
|
|
30885
31067
|
sessionId,
|
|
30886
31068
|
requestId: randomUUID17(),
|
|
30887
31069
|
title: `High-level review of ${subject.repo}#${subject.prNumber}`,
|
|
30888
|
-
body: JSON.stringify(subject
|
|
31070
|
+
body: JSON.stringify(payloadOf(subject)),
|
|
30889
31071
|
prNumber: subject.prNumber,
|
|
30890
31072
|
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
|
-
]
|
|
31073
|
+
metadata: metadataOf(subject)
|
|
30896
31074
|
},
|
|
30897
31075
|
{ rejectIsOutcome: true }
|
|
30898
31076
|
);
|
|
@@ -30905,23 +31083,55 @@ async function openHighLevelOverlay(sessionId, subject) {
|
|
|
30905
31083
|
}
|
|
30906
31084
|
|
|
30907
31085
|
// src/commands/review/highLevel/printHighLevelChecklist.ts
|
|
31086
|
+
import chalk216 from "chalk";
|
|
31087
|
+
|
|
31088
|
+
// src/commands/review/highLevel/formatCriticalDiffs.ts
|
|
30908
31089
|
import chalk213 from "chalk";
|
|
31090
|
+
var PATCH_LINE_COLOURS = {
|
|
31091
|
+
"+": chalk213.green,
|
|
31092
|
+
"-": chalk213.red,
|
|
31093
|
+
"@": chalk213.cyan
|
|
31094
|
+
};
|
|
31095
|
+
function formatPatch(patch2) {
|
|
31096
|
+
return patch2.split("\n").map(
|
|
31097
|
+
(line) => ` ${(PATCH_LINE_COLOURS[line[0] ?? ""] ?? chalk213.dim)(line)}`
|
|
31098
|
+
);
|
|
31099
|
+
}
|
|
31100
|
+
function formatDiff(diff3) {
|
|
31101
|
+
return [
|
|
31102
|
+
"",
|
|
31103
|
+
` ${chalk213.bold(diff3.path)} ${chalk213.dim(`(${diff3.status})`)} ${chalk213.green(`+${diff3.additions}`)} ${chalk213.red(`-${diff3.deletions}`)}`,
|
|
31104
|
+
...diff3.patch === null ? [` ${chalk213.dim(`no diff available; see ${diff3.diffUrl}`)}`] : formatPatch(diff3.patch)
|
|
31105
|
+
];
|
|
31106
|
+
}
|
|
31107
|
+
function formatCriticalDiffs(diffs, criticalPaths) {
|
|
31108
|
+
if (criticalPaths.length === 0)
|
|
31109
|
+
return `${chalk213.bold.underline("Critical diffs")}
|
|
31110
|
+
${chalk213.dim("review.highLevel.criticalPaths is unset, so no diffs are shown")}`;
|
|
31111
|
+
if (diffs.length === 0)
|
|
31112
|
+
return `${chalk213.bold.underline("Critical diffs")}
|
|
31113
|
+
${chalk213.dim(`no changed file matches ${criticalPaths.join(", ")}`)}`;
|
|
31114
|
+
return [
|
|
31115
|
+
chalk213.bold.underline("Critical diffs"),
|
|
31116
|
+
...diffs.flatMap(formatDiff)
|
|
31117
|
+
].join("\n");
|
|
31118
|
+
}
|
|
30909
31119
|
|
|
30910
31120
|
// src/commands/review/highLevel/formatHighLevelChecklist.ts
|
|
30911
|
-
import
|
|
31121
|
+
import chalk214 from "chalk";
|
|
30912
31122
|
var MARKERS = {
|
|
30913
|
-
pass: () =>
|
|
30914
|
-
fail: () =>
|
|
30915
|
-
manual: () =>
|
|
31123
|
+
pass: () => chalk214.green("\u2714"),
|
|
31124
|
+
fail: () => chalk214.red("\u2718"),
|
|
31125
|
+
manual: () => chalk214.yellow("\u25A1")
|
|
30916
31126
|
};
|
|
30917
31127
|
function formatCheck(check2) {
|
|
30918
|
-
const title = check2.status === "fail" ?
|
|
31128
|
+
const title = check2.status === "fail" ? chalk214.red(check2.title) : chalk214.bold(check2.title);
|
|
30919
31129
|
return ` ${MARKERS[check2.status]()} ${title}
|
|
30920
|
-
${
|
|
31130
|
+
${chalk214.dim(check2.reason)}`;
|
|
30921
31131
|
}
|
|
30922
31132
|
function formatGroup(heading2, checks2) {
|
|
30923
31133
|
if (checks2.length === 0) return [];
|
|
30924
|
-
return ["",
|
|
31134
|
+
return ["", chalk214.bold.underline(heading2), ...checks2.map(formatCheck)];
|
|
30925
31135
|
}
|
|
30926
31136
|
function formatHighLevelChecklist(checks2) {
|
|
30927
31137
|
const deterministic = checks2.filter(
|
|
@@ -30930,7 +31140,7 @@ function formatHighLevelChecklist(checks2) {
|
|
|
30930
31140
|
const failed2 = deterministic.filter(
|
|
30931
31141
|
(check2) => check2.status === "fail"
|
|
30932
31142
|
).length;
|
|
30933
|
-
const summary = failed2 === 0 ?
|
|
31143
|
+
const summary = failed2 === 0 ? chalk214.green(`All ${deterministic.length} deterministic checks pass`) : chalk214.red(
|
|
30934
31144
|
`${failed2} of ${deterministic.length} deterministic checks fail`
|
|
30935
31145
|
);
|
|
30936
31146
|
return [
|
|
@@ -30944,36 +31154,63 @@ function formatHighLevelChecklist(checks2) {
|
|
|
30944
31154
|
].join("\n");
|
|
30945
31155
|
}
|
|
30946
31156
|
|
|
31157
|
+
// src/commands/review/highLevel/formatHighLevelStructure.ts
|
|
31158
|
+
import chalk215 from "chalk";
|
|
31159
|
+
var STATUS_MARKERS = {
|
|
31160
|
+
added: () => chalk215.green("A"),
|
|
31161
|
+
removed: () => chalk215.red("D"),
|
|
31162
|
+
modified: () => chalk215.yellow("M")
|
|
31163
|
+
};
|
|
31164
|
+
function counts(additions, deletions) {
|
|
31165
|
+
return `${chalk215.green(`+${additions}`)} ${chalk215.red(`-${deletions}`)}`;
|
|
31166
|
+
}
|
|
31167
|
+
function formatNode(node, indent3) {
|
|
31168
|
+
if (node.kind === "file")
|
|
31169
|
+
return [
|
|
31170
|
+
`${indent3}${STATUS_MARKERS[node.status]()} ${node.name} ${chalk215.dim(counts(node.additions, node.deletions))}`
|
|
31171
|
+
];
|
|
31172
|
+
const dir = node;
|
|
31173
|
+
return [
|
|
31174
|
+
`${indent3}${chalk215.bold(`${dir.name}/`)} ${chalk215.dim(counts(dir.additions, dir.deletions))}`,
|
|
31175
|
+
...dir.children.flatMap((child) => formatNode(child, `${indent3} `))
|
|
31176
|
+
];
|
|
31177
|
+
}
|
|
31178
|
+
function formatHighLevelStructure(structure) {
|
|
31179
|
+
const summary = `${structure.added} added \xB7 ${structure.removed} deleted \xB7 ${structure.modified} modified \xB7 ${counts(structure.additions, structure.deletions)}`;
|
|
31180
|
+
return [
|
|
31181
|
+
chalk215.bold.underline("Structure"),
|
|
31182
|
+
` ${summary}`,
|
|
31183
|
+
...structure.tree.flatMap((node) => formatNode(node, " "))
|
|
31184
|
+
].join("\n");
|
|
31185
|
+
}
|
|
31186
|
+
|
|
30947
31187
|
// src/commands/review/highLevel/printHighLevelChecklist.ts
|
|
30948
31188
|
function printHighLevelChecklist(subject) {
|
|
30949
31189
|
console.log(
|
|
30950
|
-
|
|
30951
|
-
|
|
31190
|
+
chalk216.bold(`High-level review of ${subject.repo}#${subject.prNumber}`),
|
|
31191
|
+
chalk216.dim(
|
|
31192
|
+
`\xB7 ${highLevelChangedFileCount(subject.structure)} changed files`
|
|
31193
|
+
)
|
|
30952
31194
|
);
|
|
30953
31195
|
console.log(formatHighLevelChecklist(subject.checks));
|
|
31196
|
+
console.log("");
|
|
31197
|
+
console.log(formatHighLevelStructure(subject.structure));
|
|
31198
|
+
console.log("");
|
|
31199
|
+
console.log(
|
|
31200
|
+
formatCriticalDiffs(subject.criticalDiffs, subject.criticalPaths)
|
|
31201
|
+
);
|
|
30954
31202
|
console.log(
|
|
30955
|
-
|
|
31203
|
+
chalk216.dim(
|
|
30956
31204
|
"\nManual items are for the reviewer to judge; see docs/high-level-review.md."
|
|
30957
31205
|
)
|
|
30958
31206
|
);
|
|
30959
31207
|
console.log(
|
|
30960
|
-
|
|
31208
|
+
chalk216.dim(
|
|
30961
31209
|
"Run this inside an assist session to step through the checklist in the web overlay."
|
|
30962
31210
|
)
|
|
30963
31211
|
);
|
|
30964
31212
|
}
|
|
30965
31213
|
|
|
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
31214
|
// src/commands/review/highLevel/runHighLevelReview.ts
|
|
30978
31215
|
function resolvePrNumber2(number) {
|
|
30979
31216
|
if (number === void 0) return getCurrentPrNumber();
|
|
@@ -30984,26 +31221,10 @@ function resolvePrNumber2(number) {
|
|
|
30984
31221
|
}
|
|
30985
31222
|
return parsed;
|
|
30986
31223
|
}
|
|
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);
|
|
31224
|
+
async function runHighLevelReview(number, options2 = {}) {
|
|
31225
|
+
const force = options2.force === true;
|
|
31226
|
+
const subject = gatherHighLevelSubject(resolvePrNumber2(number), force);
|
|
31227
|
+
announceSavedReview(subject, force);
|
|
31007
31228
|
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
31008
31229
|
if (process.env.ASSIST_SESSION !== "1" || !sessionId)
|
|
31009
31230
|
return printHighLevelChecklist(subject);
|
|
@@ -31124,13 +31345,13 @@ ${annotateDiffWithLineNumbers(context.diff.trimEnd())}
|
|
|
31124
31345
|
|
|
31125
31346
|
// src/commands/review/buildReviewPaths.ts
|
|
31126
31347
|
import { homedir as homedir23 } from "os";
|
|
31127
|
-
import { basename as
|
|
31348
|
+
import { basename as basename21, join as join76 } from "path";
|
|
31128
31349
|
function buildReviewPaths(repoRoot2, key) {
|
|
31129
31350
|
const reviewDir = join76(
|
|
31130
31351
|
homedir23(),
|
|
31131
31352
|
".assist",
|
|
31132
31353
|
"reviews",
|
|
31133
|
-
|
|
31354
|
+
basename21(repoRoot2),
|
|
31134
31355
|
key
|
|
31135
31356
|
);
|
|
31136
31357
|
return {
|
|
@@ -31176,7 +31397,7 @@ function fetchExistingComments() {
|
|
|
31176
31397
|
}
|
|
31177
31398
|
|
|
31178
31399
|
// src/commands/review/gatherContext.ts
|
|
31179
|
-
import { execSync as
|
|
31400
|
+
import { execSync as execSync63 } from "child_process";
|
|
31180
31401
|
|
|
31181
31402
|
// src/commands/review/fetchPrDiff.ts
|
|
31182
31403
|
import { execSync as execSync61 } from "child_process";
|
|
@@ -31207,13 +31428,59 @@ function fetchDiffViaGit(baseSha, headSha) {
|
|
|
31207
31428
|
});
|
|
31208
31429
|
}
|
|
31209
31430
|
|
|
31431
|
+
// src/commands/review/fetchPrDiffInfo.ts
|
|
31432
|
+
import { execSync as execSync62 } from "child_process";
|
|
31433
|
+
function getCurrentBranch3() {
|
|
31434
|
+
return execSync62("git rev-parse --abbrev-ref HEAD", {
|
|
31435
|
+
encoding: "utf8"
|
|
31436
|
+
}).trim();
|
|
31437
|
+
}
|
|
31438
|
+
function fetchPrDiffInfo() {
|
|
31439
|
+
const { org, repo } = getRepoInfo();
|
|
31440
|
+
const branch2 = getCurrentBranch3();
|
|
31441
|
+
const fields = "number,baseRefName,baseRefOid,headRefName,headRefOid";
|
|
31442
|
+
const raw = execSync62(
|
|
31443
|
+
`gh pr list --state open --head ${branch2} --json ${fields} -R ${org}/${repo}`,
|
|
31444
|
+
{
|
|
31445
|
+
encoding: "utf8",
|
|
31446
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
31447
|
+
}
|
|
31448
|
+
);
|
|
31449
|
+
const parsed = JSON.parse(raw);
|
|
31450
|
+
const pr = parsed[0];
|
|
31451
|
+
if (!pr) {
|
|
31452
|
+
console.error(
|
|
31453
|
+
`Error: No open pull request found for branch \`${branch2}\`. Open a PR for this branch before running \`assist review\`.`
|
|
31454
|
+
);
|
|
31455
|
+
process.exit(1);
|
|
31456
|
+
}
|
|
31457
|
+
return {
|
|
31458
|
+
prNumber: pr.number,
|
|
31459
|
+
baseRef: pr.baseRefName,
|
|
31460
|
+
baseSha: pr.baseRefOid,
|
|
31461
|
+
headRef: pr.headRefName,
|
|
31462
|
+
headSha: pr.headRefOid
|
|
31463
|
+
};
|
|
31464
|
+
}
|
|
31465
|
+
function fetchPrChangedFiles(prNumber) {
|
|
31466
|
+
const { org, repo } = getRepoInfo();
|
|
31467
|
+
const out = execSync62(
|
|
31468
|
+
`gh api repos/${org}/${repo}/pulls/${prNumber}/files --paginate --jq ".[].filename"`,
|
|
31469
|
+
{
|
|
31470
|
+
encoding: "utf8",
|
|
31471
|
+
maxBuffer: 64 * 1024 * 1024
|
|
31472
|
+
}
|
|
31473
|
+
);
|
|
31474
|
+
return out.trim().split("\n").filter(Boolean);
|
|
31475
|
+
}
|
|
31476
|
+
|
|
31210
31477
|
// src/commands/review/gatherContext.ts
|
|
31211
31478
|
function gatherContext() {
|
|
31212
|
-
const branch2 =
|
|
31479
|
+
const branch2 = execSync63("git rev-parse --abbrev-ref HEAD", {
|
|
31213
31480
|
encoding: "utf8"
|
|
31214
31481
|
}).trim();
|
|
31215
|
-
const sha =
|
|
31216
|
-
const shortSha =
|
|
31482
|
+
const sha = execSync63("git rev-parse HEAD", { encoding: "utf8" }).trim();
|
|
31483
|
+
const shortSha = execSync63("git rev-parse --short=7 HEAD", {
|
|
31217
31484
|
encoding: "utf8"
|
|
31218
31485
|
}).trim();
|
|
31219
31486
|
const prInfo = fetchPrDiffInfo();
|
|
@@ -31234,7 +31501,7 @@ function gatherContext() {
|
|
|
31234
31501
|
}
|
|
31235
31502
|
|
|
31236
31503
|
// src/commands/review/postReviewToPr.ts
|
|
31237
|
-
import { readFileSync as
|
|
31504
|
+
import { readFileSync as readFileSync48 } from "fs";
|
|
31238
31505
|
|
|
31239
31506
|
// src/commands/review/carriedUnanchoredFindings.ts
|
|
31240
31507
|
function carriedUnanchoredFindings(unanchored) {
|
|
@@ -31572,18 +31839,18 @@ function partitionFindingsByDiff(findings, index3) {
|
|
|
31572
31839
|
}
|
|
31573
31840
|
|
|
31574
31841
|
// src/commands/review/warnOutOfDiff.ts
|
|
31575
|
-
import
|
|
31842
|
+
import chalk217 from "chalk";
|
|
31576
31843
|
function warnOutOfDiff(outOfDiff) {
|
|
31577
31844
|
if (outOfDiff.length === 0) return;
|
|
31578
31845
|
console.warn(
|
|
31579
|
-
|
|
31846
|
+
chalk217.yellow(
|
|
31580
31847
|
`Moved ${outOfDiff.length} finding(s) whose lines fall outside the PR diff into the review body (GitHub cannot anchor a comment on these):`
|
|
31581
31848
|
)
|
|
31582
31849
|
);
|
|
31583
31850
|
for (const finding of outOfDiff) {
|
|
31584
31851
|
const range = finding.startLine !== void 0 ? `${finding.startLine}-${finding.line}` : `${finding.line}`;
|
|
31585
31852
|
console.warn(
|
|
31586
|
-
` ${
|
|
31853
|
+
` ${chalk217.yellow("\xB7")} ${finding.title} ${chalk217.dim(
|
|
31587
31854
|
`(${finding.file}:${range})`
|
|
31588
31855
|
)}`
|
|
31589
31856
|
);
|
|
@@ -31607,18 +31874,18 @@ function selectInDiffFindings(lineBound, prDiff) {
|
|
|
31607
31874
|
}
|
|
31608
31875
|
|
|
31609
31876
|
// src/commands/review/warnUnlocated.ts
|
|
31610
|
-
import
|
|
31877
|
+
import chalk218 from "chalk";
|
|
31611
31878
|
function warnUnlocated(unlocated) {
|
|
31612
31879
|
if (unlocated.length === 0) return;
|
|
31613
31880
|
console.warn(
|
|
31614
|
-
|
|
31881
|
+
chalk218.yellow(
|
|
31615
31882
|
`Moved ${unlocated.length} finding(s) without a parseable file:line into the review body:`
|
|
31616
31883
|
)
|
|
31617
31884
|
);
|
|
31618
31885
|
for (const finding of unlocated) {
|
|
31619
|
-
const where = finding.location ||
|
|
31886
|
+
const where = finding.location || chalk218.dim("missing");
|
|
31620
31887
|
console.warn(
|
|
31621
|
-
` ${
|
|
31888
|
+
` ${chalk218.yellow("\xB7")} ${finding.title} ${chalk218.dim(`(${where})`)}`
|
|
31622
31889
|
);
|
|
31623
31890
|
}
|
|
31624
31891
|
}
|
|
@@ -31685,7 +31952,7 @@ async function confirmPost(prNumber, work, options2) {
|
|
|
31685
31952
|
return promptConfirm(`Post ${work} to PR #${prNumber}?`, false);
|
|
31686
31953
|
}
|
|
31687
31954
|
async function postFindingsToPr(prInfo, synthesisPath, options2) {
|
|
31688
|
-
const markdown =
|
|
31955
|
+
const markdown = readFileSync48(synthesisPath, "utf8");
|
|
31689
31956
|
const { inDiff, unanchored } = selectPostableFindings(markdown, prInfo);
|
|
31690
31957
|
const carried = carriedUnanchoredFindings(unanchored);
|
|
31691
31958
|
if (inDiff.length === 0 && carried.length === 0) return NOTHING_POSTED;
|
|
@@ -31821,10 +32088,10 @@ async function handlePostSynthesis(synthesisPath, prInfo, options2) {
|
|
|
31821
32088
|
}
|
|
31822
32089
|
|
|
31823
32090
|
// src/commands/review/prepareReviewDir.ts
|
|
31824
|
-
import { existsSync as
|
|
32091
|
+
import { existsSync as existsSync64, mkdirSync as mkdirSync22, unlinkSync as unlinkSync17, writeFileSync as writeFileSync39 } from "fs";
|
|
31825
32092
|
function clearReviewFiles(paths) {
|
|
31826
32093
|
for (const path91 of [paths.claudePath, paths.codexPath, paths.synthesisPath]) {
|
|
31827
|
-
if (
|
|
32094
|
+
if (existsSync64(path91)) unlinkSync17(path91);
|
|
31828
32095
|
}
|
|
31829
32096
|
}
|
|
31830
32097
|
function prepareReviewDir(paths, requestBody, force) {
|
|
@@ -32128,7 +32395,7 @@ function printReviewerFailures(results) {
|
|
|
32128
32395
|
}
|
|
32129
32396
|
|
|
32130
32397
|
// src/commands/review/runAndSynthesise.ts
|
|
32131
|
-
import { existsSync as
|
|
32398
|
+
import { existsSync as existsSync66, unlinkSync as unlinkSync19 } from "fs";
|
|
32132
32399
|
|
|
32133
32400
|
// src/commands/review/buildReviewerStdin.ts
|
|
32134
32401
|
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 +32862,7 @@ function buildCodexModelArgs() {
|
|
|
32595
32862
|
}
|
|
32596
32863
|
|
|
32597
32864
|
// src/commands/review/runCodexReviewer.ts
|
|
32598
|
-
import { existsSync as
|
|
32865
|
+
import { existsSync as existsSync65, unlinkSync as unlinkSync18 } from "fs";
|
|
32599
32866
|
|
|
32600
32867
|
// src/commands/review/parseCodexEvent.ts
|
|
32601
32868
|
function isItemStarted(value) {
|
|
@@ -32650,7 +32917,7 @@ async function runCodexReviewer(spec) {
|
|
|
32650
32917
|
reportReviewerToolUse(spec.name, event, spinner, override.model);
|
|
32651
32918
|
}
|
|
32652
32919
|
});
|
|
32653
|
-
if (result.exitCode !== 0 &&
|
|
32920
|
+
if (result.exitCode !== 0 && existsSync65(spec.outputPath)) {
|
|
32654
32921
|
unlinkSync18(spec.outputPath);
|
|
32655
32922
|
}
|
|
32656
32923
|
return finaliseReviewerRun(
|
|
@@ -32705,7 +32972,7 @@ async function runReviewers(reviewDir, claudePath, codexPath, stdinPrompt, optio
|
|
|
32705
32972
|
}
|
|
32706
32973
|
|
|
32707
32974
|
// src/commands/review/synthesise.ts
|
|
32708
|
-
import { readFileSync as
|
|
32975
|
+
import { readFileSync as readFileSync49 } from "fs";
|
|
32709
32976
|
|
|
32710
32977
|
// src/commands/review/buildSynthesisStdin.ts
|
|
32711
32978
|
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 +33037,7 @@ Files:
|
|
|
32770
33037
|
|
|
32771
33038
|
// src/commands/review/synthesise.ts
|
|
32772
33039
|
function printSummary2(synthesisPath) {
|
|
32773
|
-
const markdown =
|
|
33040
|
+
const markdown = readFileSync49(synthesisPath, "utf8");
|
|
32774
33041
|
console.log("");
|
|
32775
33042
|
console.log(buildReviewSummary(markdown));
|
|
32776
33043
|
console.log("");
|
|
@@ -32818,7 +33085,7 @@ async function runAndSynthesise(args) {
|
|
|
32818
33085
|
console.error("Both reviewers failed; skipping synthesis.");
|
|
32819
33086
|
return { ok: false, failures };
|
|
32820
33087
|
}
|
|
32821
|
-
if (anyFresh &&
|
|
33088
|
+
if (anyFresh && existsSync66(paths.synthesisPath)) {
|
|
32822
33089
|
unlinkSync19(paths.synthesisPath);
|
|
32823
33090
|
}
|
|
32824
33091
|
const synthesisResult = await synthesise(paths, { multi });
|
|
@@ -32971,9 +33238,10 @@ async function review(options2 = {}) {
|
|
|
32971
33238
|
return checkoutOnlySession(options2.number);
|
|
32972
33239
|
emitActivity({ kind: "command", name: "review" });
|
|
32973
33240
|
if (!options2.number)
|
|
32974
|
-
return options2.highLevel ? runHighLevelReview(void 0) : reviewPr(invokedIn, options2);
|
|
33241
|
+
return options2.highLevel ? runHighLevelReview(void 0, { force: options2.force }) : reviewPr(invokedIn, options2);
|
|
32975
33242
|
await checkoutPr(options2.number);
|
|
32976
|
-
if (options2.highLevel)
|
|
33243
|
+
if (options2.highLevel)
|
|
33244
|
+
return runHighLevelReview(options2.number, { force: options2.force });
|
|
32977
33245
|
return reviewPr(resolveRepoRoot(), options2);
|
|
32978
33246
|
}
|
|
32979
33247
|
|
|
@@ -32992,7 +33260,7 @@ function registerReview(program2) {
|
|
|
32992
33260
|
"Default the submit prompt to yes (or auto-submit with --no-prompt)"
|
|
32993
33261
|
).option(
|
|
32994
33262
|
"--force",
|
|
32995
|
-
"Clear cached claude.md / codex.md / synthesis.md and re-run all phases"
|
|
33263
|
+
"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
33264
|
).option(
|
|
32997
33265
|
"--refine",
|
|
32998
33266
|
"After synthesis, launch an interactive Claude session to walk through findings instead of posting"
|
|
@@ -33007,7 +33275,7 @@ function registerReview(program2) {
|
|
|
33007
33275
|
"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
33276
|
).option(
|
|
33009
33277
|
"--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"
|
|
33278
|
+
"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
33279
|
).option(
|
|
33012
33280
|
"--address-comments",
|
|
33013
33281
|
"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 +33296,9 @@ function registerReview(program2) {
|
|
|
33028
33296
|
}
|
|
33029
33297
|
|
|
33030
33298
|
// src/commands/rules/addRule.ts
|
|
33031
|
-
import { existsSync as
|
|
33299
|
+
import { existsSync as existsSync69, readFileSync as readFileSync53, writeFileSync as writeFileSync42 } from "fs";
|
|
33032
33300
|
import path72 from "path";
|
|
33033
|
-
import
|
|
33301
|
+
import chalk219 from "chalk";
|
|
33034
33302
|
|
|
33035
33303
|
// src/commands/rules/insertRuleBullet.ts
|
|
33036
33304
|
function ruleBullet({ code, title, text: text18 }) {
|
|
@@ -33053,7 +33321,7 @@ function insertRuleBullet(content, rule) {
|
|
|
33053
33321
|
}
|
|
33054
33322
|
|
|
33055
33323
|
// src/commands/rules/nextRuleCode.ts
|
|
33056
|
-
import { readFileSync as
|
|
33324
|
+
import { readFileSync as readFileSync50 } from "fs";
|
|
33057
33325
|
|
|
33058
33326
|
// src/commands/rules/findClaudeFiles.ts
|
|
33059
33327
|
import { readdirSync as readdirSync14 } from "fs";
|
|
@@ -33077,7 +33345,7 @@ function findClaudeFiles(dir) {
|
|
|
33077
33345
|
var CODE_PREFIX = "R";
|
|
33078
33346
|
function nextRuleCode(root) {
|
|
33079
33347
|
const numbers = findClaudeFiles(root).flatMap(
|
|
33080
|
-
(file) => parseRulesSection(
|
|
33348
|
+
(file) => parseRulesSection(readFileSync50(file, "utf8")).map(
|
|
33081
33349
|
(rule) => Number(/(\d+)\s*$/.exec(rule.code)?.[1] ?? 0)
|
|
33082
33350
|
)
|
|
33083
33351
|
);
|
|
@@ -33085,7 +33353,7 @@ function nextRuleCode(root) {
|
|
|
33085
33353
|
}
|
|
33086
33354
|
|
|
33087
33355
|
// src/commands/rules/resolveRuleScope.ts
|
|
33088
|
-
import { existsSync as
|
|
33356
|
+
import { existsSync as existsSync67 } from "fs";
|
|
33089
33357
|
import path69 from "path";
|
|
33090
33358
|
function resolveRuleScope(target) {
|
|
33091
33359
|
const resolved = path69.resolve(target);
|
|
@@ -33095,7 +33363,7 @@ function resolveRuleScope(target) {
|
|
|
33095
33363
|
let current = startDir;
|
|
33096
33364
|
while (true) {
|
|
33097
33365
|
const candidate = path69.join(current, "CLAUDE.md");
|
|
33098
|
-
if (
|
|
33366
|
+
if (existsSync67(candidate)) return candidate;
|
|
33099
33367
|
if (current === root || current === path69.dirname(current)) break;
|
|
33100
33368
|
current = path69.dirname(current);
|
|
33101
33369
|
}
|
|
@@ -33103,15 +33371,15 @@ function resolveRuleScope(target) {
|
|
|
33103
33371
|
}
|
|
33104
33372
|
|
|
33105
33373
|
// src/commands/rules/updateScopedRulesIndex.ts
|
|
33106
|
-
import { existsSync as
|
|
33374
|
+
import { existsSync as existsSync68, readFileSync as readFileSync52, writeFileSync as writeFileSync41 } from "fs";
|
|
33107
33375
|
import path71 from "path";
|
|
33108
33376
|
|
|
33109
33377
|
// src/commands/rules/scopedRuleDirectories.ts
|
|
33110
|
-
import { readFileSync as
|
|
33378
|
+
import { readFileSync as readFileSync51 } from "fs";
|
|
33111
33379
|
import path70 from "path";
|
|
33112
33380
|
function scopedRuleDirectories(root) {
|
|
33113
33381
|
return findClaudeFiles(root).filter(
|
|
33114
|
-
(file) => path70.dirname(file) !== root && parseRulesSection(
|
|
33382
|
+
(file) => path70.dirname(file) !== root && parseRulesSection(readFileSync51(file, "utf8")).length > 0
|
|
33115
33383
|
).map(
|
|
33116
33384
|
(file) => `${path70.relative(root, path70.dirname(file)).split(path70.sep).join("/")}/`
|
|
33117
33385
|
).sort();
|
|
@@ -33153,7 +33421,7 @@ function upsertScopedRulesPointer(content, directories) {
|
|
|
33153
33421
|
function updateScopedRulesIndex(root) {
|
|
33154
33422
|
const directories = scopedRuleDirectories(root);
|
|
33155
33423
|
const rootFile = path71.join(root, "CLAUDE.md");
|
|
33156
|
-
const before =
|
|
33424
|
+
const before = existsSync68(rootFile) ? readFileSync52(rootFile, "utf8") : "";
|
|
33157
33425
|
const after = upsertScopedRulesPointer(before, directories);
|
|
33158
33426
|
if (after !== before) writeFileSync41(rootFile, after);
|
|
33159
33427
|
return directories;
|
|
@@ -33161,12 +33429,12 @@ function updateScopedRulesIndex(root) {
|
|
|
33161
33429
|
|
|
33162
33430
|
// src/commands/rules/addRule.ts
|
|
33163
33431
|
function read2(file) {
|
|
33164
|
-
return
|
|
33432
|
+
return existsSync69(file) ? readFileSync53(file, "utf8") : "";
|
|
33165
33433
|
}
|
|
33166
33434
|
function addRule(text18, options2) {
|
|
33167
33435
|
const rule = text18.trim();
|
|
33168
33436
|
if (rule === "") {
|
|
33169
|
-
console.error(
|
|
33437
|
+
console.error(chalk219.red("Rule text is required"));
|
|
33170
33438
|
process.exitCode = 1;
|
|
33171
33439
|
return;
|
|
33172
33440
|
}
|
|
@@ -33184,13 +33452,13 @@ function addRule(text18, options2) {
|
|
|
33184
33452
|
);
|
|
33185
33453
|
updateScopedRulesIndex(root);
|
|
33186
33454
|
console.log(
|
|
33187
|
-
`Added ${
|
|
33455
|
+
`Added ${chalk219.cyan(code)} to ${path72.relative(process.cwd(), target) || target}`
|
|
33188
33456
|
);
|
|
33189
33457
|
}
|
|
33190
33458
|
|
|
33191
33459
|
// src/commands/rules/indexRules.ts
|
|
33192
33460
|
import path73 from "path";
|
|
33193
|
-
import
|
|
33461
|
+
import chalk220 from "chalk";
|
|
33194
33462
|
function indexRules() {
|
|
33195
33463
|
const startDir = scopeDirectory(process.cwd());
|
|
33196
33464
|
const root = findRepoRoot(startDir) ?? startDir;
|
|
@@ -33198,24 +33466,24 @@ function indexRules() {
|
|
|
33198
33466
|
const rootFile = path73.relative(process.cwd(), path73.join(root, "CLAUDE.md"));
|
|
33199
33467
|
if (directories.length === 0) {
|
|
33200
33468
|
console.log(
|
|
33201
|
-
|
|
33469
|
+
chalk220.gray(`No directories carry their own \`## Rules\` under ${root}`)
|
|
33202
33470
|
);
|
|
33203
33471
|
return;
|
|
33204
33472
|
}
|
|
33205
33473
|
console.log(`Recorded in ${rootFile || "CLAUDE.md"}`);
|
|
33206
33474
|
for (const directory of directories)
|
|
33207
|
-
console.log(` ${
|
|
33475
|
+
console.log(` ${chalk220.cyan(directory)}`);
|
|
33208
33476
|
}
|
|
33209
33477
|
|
|
33210
33478
|
// src/commands/rules/listRules.ts
|
|
33211
33479
|
import path74 from "path";
|
|
33212
|
-
import
|
|
33480
|
+
import chalk221 from "chalk";
|
|
33213
33481
|
function listRules(target, options2 = {}) {
|
|
33214
33482
|
const resolved = path74.resolve(target ?? process.cwd());
|
|
33215
33483
|
const rules3 = readScopedRules(resolved);
|
|
33216
33484
|
if (rules3.length === 0) {
|
|
33217
33485
|
const label2 = path74.relative(process.cwd(), resolved) || ".";
|
|
33218
|
-
console.log(
|
|
33486
|
+
console.log(chalk221.gray(`No rules in scope for ${label2}`));
|
|
33219
33487
|
return;
|
|
33220
33488
|
}
|
|
33221
33489
|
const base = findRepoRoot(scopeDirectory(resolved));
|
|
@@ -33225,14 +33493,14 @@ function listRules(target, options2 = {}) {
|
|
|
33225
33493
|
if (rule.source !== shown) {
|
|
33226
33494
|
shown = rule.source;
|
|
33227
33495
|
console.log(
|
|
33228
|
-
|
|
33496
|
+
chalk221.dim(base ? path74.relative(base, rule.source) : rule.source)
|
|
33229
33497
|
);
|
|
33230
33498
|
}
|
|
33231
33499
|
console.log(
|
|
33232
|
-
` ${
|
|
33500
|
+
` ${chalk221.cyan(rule.code.padEnd(width))} ${rule.title ?? rule.text}`
|
|
33233
33501
|
);
|
|
33234
33502
|
if (options2.full && rule.title)
|
|
33235
|
-
console.log(` ${" ".repeat(width)} ${
|
|
33503
|
+
console.log(` ${" ".repeat(width)} ${chalk221.dim(rule.text)}`);
|
|
33236
33504
|
}
|
|
33237
33505
|
}
|
|
33238
33506
|
|
|
@@ -33261,7 +33529,7 @@ function registerRules(program2) {
|
|
|
33261
33529
|
}
|
|
33262
33530
|
|
|
33263
33531
|
// src/commands/seq/seqAuth.ts
|
|
33264
|
-
import
|
|
33532
|
+
import chalk223 from "chalk";
|
|
33265
33533
|
|
|
33266
33534
|
// src/commands/seq/loadConnections.ts
|
|
33267
33535
|
function loadConnections2() {
|
|
@@ -33290,10 +33558,10 @@ function setDefaultConnection(name) {
|
|
|
33290
33558
|
}
|
|
33291
33559
|
|
|
33292
33560
|
// src/shared/assertUniqueName.ts
|
|
33293
|
-
import
|
|
33561
|
+
import chalk222 from "chalk";
|
|
33294
33562
|
function assertUniqueName(existingNames, name) {
|
|
33295
33563
|
if (existingNames.includes(name)) {
|
|
33296
|
-
console.error(
|
|
33564
|
+
console.error(chalk222.red(`Connection "${name}" already exists.`));
|
|
33297
33565
|
process.exit(1);
|
|
33298
33566
|
}
|
|
33299
33567
|
}
|
|
@@ -33311,16 +33579,16 @@ async function promptConnection2(existingNames) {
|
|
|
33311
33579
|
var seqAuth = createConnectionAuth({
|
|
33312
33580
|
load: loadConnections2,
|
|
33313
33581
|
save: saveConnections2,
|
|
33314
|
-
format: (c) => `${
|
|
33582
|
+
format: (c) => `${chalk223.bold(c.name)} ${c.url}`,
|
|
33315
33583
|
promptNew: promptConnection2,
|
|
33316
33584
|
onFirst: (c) => setDefaultConnection(c.name)
|
|
33317
33585
|
});
|
|
33318
33586
|
|
|
33319
33587
|
// src/commands/seq/seqQuery.ts
|
|
33320
|
-
import
|
|
33588
|
+
import chalk227 from "chalk";
|
|
33321
33589
|
|
|
33322
33590
|
// src/commands/seq/fetchSeq.ts
|
|
33323
|
-
import
|
|
33591
|
+
import chalk224 from "chalk";
|
|
33324
33592
|
async function fetchSeq(conn, path91, params) {
|
|
33325
33593
|
const url = `${conn.url}${path91}?${params}`;
|
|
33326
33594
|
const response = await fetch(url, {
|
|
@@ -33331,7 +33599,7 @@ async function fetchSeq(conn, path91, params) {
|
|
|
33331
33599
|
});
|
|
33332
33600
|
if (!response.ok) {
|
|
33333
33601
|
const body = await response.text();
|
|
33334
|
-
console.error(
|
|
33602
|
+
console.error(chalk224.red(`Seq returned ${response.status}: ${body}`));
|
|
33335
33603
|
process.exit(1);
|
|
33336
33604
|
}
|
|
33337
33605
|
return response;
|
|
@@ -33390,23 +33658,23 @@ async function fetchSeqEvents(conn, params) {
|
|
|
33390
33658
|
}
|
|
33391
33659
|
|
|
33392
33660
|
// src/commands/seq/formatEvent.ts
|
|
33393
|
-
import
|
|
33661
|
+
import chalk225 from "chalk";
|
|
33394
33662
|
function levelColor(level) {
|
|
33395
33663
|
switch (level) {
|
|
33396
33664
|
case "Fatal":
|
|
33397
|
-
return
|
|
33665
|
+
return chalk225.bgRed.white;
|
|
33398
33666
|
case "Error":
|
|
33399
|
-
return
|
|
33667
|
+
return chalk225.red;
|
|
33400
33668
|
case "Warning":
|
|
33401
|
-
return
|
|
33669
|
+
return chalk225.yellow;
|
|
33402
33670
|
case "Information":
|
|
33403
|
-
return
|
|
33671
|
+
return chalk225.cyan;
|
|
33404
33672
|
case "Debug":
|
|
33405
|
-
return
|
|
33673
|
+
return chalk225.gray;
|
|
33406
33674
|
case "Verbose":
|
|
33407
|
-
return
|
|
33675
|
+
return chalk225.dim;
|
|
33408
33676
|
default:
|
|
33409
|
-
return
|
|
33677
|
+
return chalk225.white;
|
|
33410
33678
|
}
|
|
33411
33679
|
}
|
|
33412
33680
|
function levelAbbrev(level) {
|
|
@@ -33447,12 +33715,12 @@ function formatTimestamp(iso) {
|
|
|
33447
33715
|
function formatEvent(event) {
|
|
33448
33716
|
const color = levelColor(event.Level);
|
|
33449
33717
|
const abbrev = levelAbbrev(event.Level);
|
|
33450
|
-
const ts8 =
|
|
33718
|
+
const ts8 = chalk225.dim(formatTimestamp(event.Timestamp));
|
|
33451
33719
|
const msg = renderMessage(event);
|
|
33452
33720
|
const lines2 = [`${ts8} ${color(`[${abbrev}]`)} ${msg}`];
|
|
33453
33721
|
if (event.Exception) {
|
|
33454
33722
|
for (const line of event.Exception.split("\n")) {
|
|
33455
|
-
lines2.push(
|
|
33723
|
+
lines2.push(chalk225.red(` ${line}`));
|
|
33456
33724
|
}
|
|
33457
33725
|
}
|
|
33458
33726
|
return lines2.join("\n");
|
|
@@ -33485,11 +33753,11 @@ function rejectTimestampFilter(filter) {
|
|
|
33485
33753
|
}
|
|
33486
33754
|
|
|
33487
33755
|
// src/shared/resolveNamedConnection.ts
|
|
33488
|
-
import
|
|
33756
|
+
import chalk226 from "chalk";
|
|
33489
33757
|
function resolveNamedConnection(connections, requested, defaultName, kind, authCommand) {
|
|
33490
33758
|
if (connections.length === 0) {
|
|
33491
33759
|
console.error(
|
|
33492
|
-
|
|
33760
|
+
chalk226.red(
|
|
33493
33761
|
`No ${kind} connections configured. Run '${authCommand}' first.`
|
|
33494
33762
|
)
|
|
33495
33763
|
);
|
|
@@ -33498,7 +33766,7 @@ function resolveNamedConnection(connections, requested, defaultName, kind, authC
|
|
|
33498
33766
|
const target = requested ?? defaultName ?? connections[0].name;
|
|
33499
33767
|
const connection = connections.find((c) => c.name === target);
|
|
33500
33768
|
if (!connection) {
|
|
33501
|
-
console.error(
|
|
33769
|
+
console.error(chalk226.red(`${kind} connection "${target}" not found.`));
|
|
33502
33770
|
process.exit(1);
|
|
33503
33771
|
}
|
|
33504
33772
|
return connection;
|
|
@@ -33527,7 +33795,7 @@ async function seqQuery(filter, options2) {
|
|
|
33527
33795
|
new URLSearchParams({ filter, count: String(count8) })
|
|
33528
33796
|
);
|
|
33529
33797
|
if (events.length === 0) {
|
|
33530
|
-
console.log(
|
|
33798
|
+
console.log(chalk227.yellow("No events found."));
|
|
33531
33799
|
return;
|
|
33532
33800
|
}
|
|
33533
33801
|
if (options2.json) {
|
|
@@ -33538,11 +33806,11 @@ async function seqQuery(filter, options2) {
|
|
|
33538
33806
|
for (const event of chronological) {
|
|
33539
33807
|
console.log(formatEvent(event));
|
|
33540
33808
|
}
|
|
33541
|
-
console.log(
|
|
33809
|
+
console.log(chalk227.dim(`
|
|
33542
33810
|
${events.length} events`));
|
|
33543
33811
|
if (events.length >= count8) {
|
|
33544
33812
|
console.log(
|
|
33545
|
-
|
|
33813
|
+
chalk227.yellow(
|
|
33546
33814
|
`Results limited to ${count8}. Use --count to retrieve more.`
|
|
33547
33815
|
)
|
|
33548
33816
|
);
|
|
@@ -33550,10 +33818,10 @@ ${events.length} events`));
|
|
|
33550
33818
|
}
|
|
33551
33819
|
|
|
33552
33820
|
// src/shared/setNamedDefaultConnection.ts
|
|
33553
|
-
import
|
|
33821
|
+
import chalk228 from "chalk";
|
|
33554
33822
|
function setNamedDefaultConnection(connections, name, setDefault, kind) {
|
|
33555
33823
|
if (!connections.find((c) => c.name === name)) {
|
|
33556
|
-
console.error(
|
|
33824
|
+
console.error(chalk228.red(`Connection "${name}" not found.`));
|
|
33557
33825
|
process.exit(1);
|
|
33558
33826
|
}
|
|
33559
33827
|
setDefault(name);
|
|
@@ -33625,12 +33893,12 @@ import { mkdirSync as mkdirSync25, writeFileSync as writeFileSync44 } from "fs";
|
|
|
33625
33893
|
import { mkdirSync as mkdirSync24, writeFileSync as writeFileSync43 } from "fs";
|
|
33626
33894
|
|
|
33627
33895
|
// src/commands/slack/readSlackParts.ts
|
|
33628
|
-
import { readFileSync as
|
|
33896
|
+
import { readFileSync as readFileSync54 } from "fs";
|
|
33629
33897
|
function readSlackParts(files) {
|
|
33630
33898
|
return files.map((file) => {
|
|
33631
33899
|
let contents;
|
|
33632
33900
|
try {
|
|
33633
|
-
contents =
|
|
33901
|
+
contents = readFileSync54(file, "utf8");
|
|
33634
33902
|
} catch {
|
|
33635
33903
|
console.error(`Error: Part file not found: ${file}`);
|
|
33636
33904
|
process.exit(1);
|
|
@@ -33774,7 +34042,7 @@ function registerSlack(program2) {
|
|
|
33774
34042
|
}
|
|
33775
34043
|
|
|
33776
34044
|
// src/commands/sql/sqlAuth.ts
|
|
33777
|
-
import
|
|
34045
|
+
import chalk230 from "chalk";
|
|
33778
34046
|
|
|
33779
34047
|
// src/commands/sql/loadConnections.ts
|
|
33780
34048
|
function loadConnections3() {
|
|
@@ -33803,7 +34071,7 @@ function setDefaultConnection2(name) {
|
|
|
33803
34071
|
}
|
|
33804
34072
|
|
|
33805
34073
|
// src/commands/sql/promptConnection.ts
|
|
33806
|
-
import
|
|
34074
|
+
import chalk229 from "chalk";
|
|
33807
34075
|
async function promptConnection3(existingNames) {
|
|
33808
34076
|
const name = await promptInput("name", "Connection name:", "default");
|
|
33809
34077
|
assertUniqueName(existingNames, name);
|
|
@@ -33811,7 +34079,7 @@ async function promptConnection3(existingNames) {
|
|
|
33811
34079
|
const portStr = await promptInput("port", "Port:", "1433");
|
|
33812
34080
|
const port = Number.parseInt(portStr, 10);
|
|
33813
34081
|
if (!Number.isFinite(port)) {
|
|
33814
|
-
console.error(
|
|
34082
|
+
console.error(chalk229.red(`Invalid port "${portStr}".`));
|
|
33815
34083
|
process.exit(1);
|
|
33816
34084
|
}
|
|
33817
34085
|
const user = await promptInput("user", "User:");
|
|
@@ -33824,13 +34092,13 @@ async function promptConnection3(existingNames) {
|
|
|
33824
34092
|
var sqlAuth = createConnectionAuth({
|
|
33825
34093
|
load: loadConnections3,
|
|
33826
34094
|
save: saveConnections3,
|
|
33827
|
-
format: (c) => `${
|
|
34095
|
+
format: (c) => `${chalk230.bold(c.name)} ${c.server}:${c.port}/${c.database} (${c.user})`,
|
|
33828
34096
|
promptNew: promptConnection3,
|
|
33829
34097
|
onFirst: (c) => setDefaultConnection2(c.name)
|
|
33830
34098
|
});
|
|
33831
34099
|
|
|
33832
34100
|
// src/commands/sql/printTable.ts
|
|
33833
|
-
import
|
|
34101
|
+
import chalk231 from "chalk";
|
|
33834
34102
|
function formatCell(value) {
|
|
33835
34103
|
if (value === null || value === void 0) return "";
|
|
33836
34104
|
if (value instanceof Date) return value.toISOString();
|
|
@@ -33839,7 +34107,7 @@ function formatCell(value) {
|
|
|
33839
34107
|
}
|
|
33840
34108
|
function printTable(rows) {
|
|
33841
34109
|
if (rows.length === 0) {
|
|
33842
|
-
console.log(
|
|
34110
|
+
console.log(chalk231.yellow("(no rows)"));
|
|
33843
34111
|
return;
|
|
33844
34112
|
}
|
|
33845
34113
|
const columns = Object.keys(rows[0]);
|
|
@@ -33847,13 +34115,13 @@ function printTable(rows) {
|
|
|
33847
34115
|
(col) => Math.max(col.length, ...rows.map((r) => formatCell(r[col]).length))
|
|
33848
34116
|
);
|
|
33849
34117
|
const header = columns.map((c, i) => c.padEnd(widths[i])).join(" ");
|
|
33850
|
-
console.log(
|
|
33851
|
-
console.log(
|
|
34118
|
+
console.log(chalk231.dim(header));
|
|
34119
|
+
console.log(chalk231.dim("-".repeat(header.length)));
|
|
33852
34120
|
for (const row of rows) {
|
|
33853
34121
|
const line = columns.map((c, i) => formatCell(row[c]).padEnd(widths[i])).join(" ");
|
|
33854
34122
|
console.log(line);
|
|
33855
34123
|
}
|
|
33856
|
-
console.log(
|
|
34124
|
+
console.log(chalk231.dim(`
|
|
33857
34125
|
${rows.length} row${rows.length === 1 ? "" : "s"}`));
|
|
33858
34126
|
}
|
|
33859
34127
|
|
|
@@ -33913,7 +34181,7 @@ async function sqlColumns(table, connectionName) {
|
|
|
33913
34181
|
}
|
|
33914
34182
|
|
|
33915
34183
|
// src/commands/sql/sqlMutate.ts
|
|
33916
|
-
import
|
|
34184
|
+
import chalk232 from "chalk";
|
|
33917
34185
|
|
|
33918
34186
|
// src/commands/sql/isMutation.ts
|
|
33919
34187
|
var MUTATION_KEYWORDS = [
|
|
@@ -33947,7 +34215,7 @@ function isMutation(sql29) {
|
|
|
33947
34215
|
async function sqlMutate(query, connectionName) {
|
|
33948
34216
|
if (!isMutation(query)) {
|
|
33949
34217
|
console.error(
|
|
33950
|
-
|
|
34218
|
+
chalk232.red(
|
|
33951
34219
|
"assist sql mutate refuses non-mutating statements. Use `assist sql query` instead."
|
|
33952
34220
|
)
|
|
33953
34221
|
);
|
|
@@ -33957,18 +34225,18 @@ async function sqlMutate(query, connectionName) {
|
|
|
33957
34225
|
const pool = await sqlConnect(conn);
|
|
33958
34226
|
try {
|
|
33959
34227
|
const result = await pool.request().query(query);
|
|
33960
|
-
console.log(
|
|
34228
|
+
console.log(chalk232.dim(`${result.rowsAffected.join(", ")} row(s) affected`));
|
|
33961
34229
|
} finally {
|
|
33962
34230
|
await pool.close();
|
|
33963
34231
|
}
|
|
33964
34232
|
}
|
|
33965
34233
|
|
|
33966
34234
|
// src/commands/sql/sqlQuery.ts
|
|
33967
|
-
import
|
|
34235
|
+
import chalk233 from "chalk";
|
|
33968
34236
|
async function sqlQuery(query, connectionName) {
|
|
33969
34237
|
if (isMutation(query)) {
|
|
33970
34238
|
console.error(
|
|
33971
|
-
|
|
34239
|
+
chalk233.red(
|
|
33972
34240
|
"assist sql query refuses mutating statements. Use `assist sql mutate` instead."
|
|
33973
34241
|
)
|
|
33974
34242
|
);
|
|
@@ -33983,7 +34251,7 @@ async function sqlQuery(query, connectionName) {
|
|
|
33983
34251
|
printTable(rows);
|
|
33984
34252
|
} else {
|
|
33985
34253
|
console.log(
|
|
33986
|
-
|
|
34254
|
+
chalk233.dim(`${result.rowsAffected.join(", ")} row(s) affected`)
|
|
33987
34255
|
);
|
|
33988
34256
|
}
|
|
33989
34257
|
} finally {
|
|
@@ -34357,7 +34625,7 @@ function syncPi(claudeDir, options2) {
|
|
|
34357
34625
|
// src/commands/sync/syncSettings.ts
|
|
34358
34626
|
import * as fs48 from "fs";
|
|
34359
34627
|
import * as path84 from "path";
|
|
34360
|
-
import
|
|
34628
|
+
import chalk234 from "chalk";
|
|
34361
34629
|
async function syncSettings(claudeDir, targetBase, options2) {
|
|
34362
34630
|
const source = path84.join(claudeDir, "settings.json");
|
|
34363
34631
|
const target = path84.join(targetBase, "settings.json");
|
|
@@ -34376,7 +34644,7 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
34376
34644
|
if (mergedContent !== normalizedTarget) {
|
|
34377
34645
|
if (!options2?.yes) {
|
|
34378
34646
|
console.log(
|
|
34379
|
-
|
|
34647
|
+
chalk234.yellow(
|
|
34380
34648
|
"\n\u26A0\uFE0F Warning: settings.json differs from existing file"
|
|
34381
34649
|
)
|
|
34382
34650
|
);
|
|
@@ -34384,7 +34652,7 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
34384
34652
|
printDiff(targetContent, mergedContent);
|
|
34385
34653
|
printAutoConfirmHint();
|
|
34386
34654
|
const confirm = await promptConfirm(
|
|
34387
|
-
|
|
34655
|
+
chalk234.red("Overwrite existing settings.json?"),
|
|
34388
34656
|
false
|
|
34389
34657
|
);
|
|
34390
34658
|
if (!confirm) {
|
|
@@ -34456,7 +34724,7 @@ function registerSync(program2) {
|
|
|
34456
34724
|
}
|
|
34457
34725
|
|
|
34458
34726
|
// src/commands/transcript/clean.ts
|
|
34459
|
-
import { existsSync as
|
|
34727
|
+
import { existsSync as existsSync74 } from "fs";
|
|
34460
34728
|
|
|
34461
34729
|
// src/commands/transcript/convert/formatTimestamp.ts
|
|
34462
34730
|
function pad(value, width) {
|
|
@@ -34706,9 +34974,9 @@ function formatVttPassages(passages, notes = [], { sourceMarks = true } = {}) {
|
|
|
34706
34974
|
}
|
|
34707
34975
|
|
|
34708
34976
|
// src/commands/transcript/convert/readCleanedCues.ts
|
|
34709
|
-
import { readFileSync as
|
|
34977
|
+
import { readFileSync as readFileSync58 } from "fs";
|
|
34710
34978
|
function readCleanedCues(inputPath) {
|
|
34711
|
-
return deduplicateCues(parseVtt(
|
|
34979
|
+
return deduplicateCues(parseVtt(readFileSync58(inputPath, "utf8")));
|
|
34712
34980
|
}
|
|
34713
34981
|
|
|
34714
34982
|
// src/commands/transcript/clean.ts
|
|
@@ -34734,7 +35002,7 @@ function clean(file, options2 = {}) {
|
|
|
34734
35002
|
);
|
|
34735
35003
|
process.exit(1);
|
|
34736
35004
|
}
|
|
34737
|
-
if (!
|
|
35005
|
+
if (!existsSync74(file)) {
|
|
34738
35006
|
console.error(`Error: VTT file not found: ${file}`);
|
|
34739
35007
|
process.exit(1);
|
|
34740
35008
|
}
|
|
@@ -34817,11 +35085,11 @@ async function configure() {
|
|
|
34817
35085
|
}
|
|
34818
35086
|
|
|
34819
35087
|
// src/commands/transcript/list.ts
|
|
34820
|
-
import { existsSync as
|
|
35088
|
+
import { existsSync as existsSync75, readdirSync as readdirSync21, statSync as statSync11 } from "fs";
|
|
34821
35089
|
import { join as join89 } from "path";
|
|
34822
35090
|
function list4() {
|
|
34823
35091
|
const { vttDir } = getTranscriptConfig();
|
|
34824
|
-
if (!
|
|
35092
|
+
if (!existsSync75(vttDir)) return;
|
|
34825
35093
|
for (const entry of readdirSync21(vttDir)) {
|
|
34826
35094
|
if (!entry.endsWith(".vtt")) continue;
|
|
34827
35095
|
if (statSync11(join89(vttDir, entry)).isDirectory()) continue;
|
|
@@ -34830,8 +35098,8 @@ function list4() {
|
|
|
34830
35098
|
}
|
|
34831
35099
|
|
|
34832
35100
|
// src/commands/transcript/move.ts
|
|
34833
|
-
import { existsSync as
|
|
34834
|
-
import { basename as
|
|
35101
|
+
import { existsSync as existsSync76, mkdirSync as mkdirSync31, renameSync as renameSync2, writeFileSync as writeFileSync48 } from "fs";
|
|
35102
|
+
import { basename as basename24, join as join90 } from "path";
|
|
34835
35103
|
|
|
34836
35104
|
// src/commands/transcript/convertVttToMarkdown.ts
|
|
34837
35105
|
function convertVttToMarkdown(inputPath) {
|
|
@@ -34852,13 +35120,13 @@ function move(file, options2) {
|
|
|
34852
35120
|
process.exit(1);
|
|
34853
35121
|
}
|
|
34854
35122
|
const { vttDir, transcriptsDir, summaryDir } = getTranscriptConfig();
|
|
34855
|
-
const filename =
|
|
35123
|
+
const filename = basename24(file);
|
|
34856
35124
|
const sourcePath = join90(vttDir, filename);
|
|
34857
|
-
if (!
|
|
35125
|
+
if (!existsSync76(sourcePath)) {
|
|
34858
35126
|
console.error(`Error: VTT file not found: ${sourcePath}`);
|
|
34859
35127
|
process.exit(1);
|
|
34860
35128
|
}
|
|
34861
|
-
const base =
|
|
35129
|
+
const base = basename24(filename, ".vtt").replace(/ Transcription$/, "");
|
|
34862
35130
|
const outputName = `${date} ${base}.md`;
|
|
34863
35131
|
const formattedDir = join90(transcriptsDir, client);
|
|
34864
35132
|
mkdirSync31(formattedDir, { recursive: true });
|
|
@@ -34871,8 +35139,8 @@ function move(file, options2) {
|
|
|
34871
35139
|
}
|
|
34872
35140
|
|
|
34873
35141
|
// src/commands/transcript/merge.ts
|
|
34874
|
-
import { existsSync as
|
|
34875
|
-
import { basename as
|
|
35142
|
+
import { existsSync as existsSync77, writeFileSync as writeFileSync49 } from "fs";
|
|
35143
|
+
import { basename as basename25 } from "path";
|
|
34876
35144
|
|
|
34877
35145
|
// src/commands/transcript/failTranscript.ts
|
|
34878
35146
|
function failTranscript(message3) {
|
|
@@ -35015,10 +35283,10 @@ function widenAudience(passages) {
|
|
|
35015
35283
|
|
|
35016
35284
|
// src/commands/transcript/merge.ts
|
|
35017
35285
|
function readSource2(file) {
|
|
35018
|
-
if (!
|
|
35286
|
+
if (!existsSync77(file)) failTranscript(`VTT file not found: ${file}`);
|
|
35019
35287
|
const cues = readCleanedCues(file);
|
|
35020
35288
|
if (cues.length === 0) failTranscript(`no cues found in: ${file}`);
|
|
35021
|
-
return { path: file, name:
|
|
35289
|
+
return { path: file, name: basename25(file), cues };
|
|
35022
35290
|
}
|
|
35023
35291
|
function wholePassages(sources) {
|
|
35024
35292
|
return sources.map((source) => ({
|
|
@@ -35220,14 +35488,14 @@ function devices() {
|
|
|
35220
35488
|
}
|
|
35221
35489
|
|
|
35222
35490
|
// src/commands/voice/logs.ts
|
|
35223
|
-
import { existsSync as
|
|
35491
|
+
import { existsSync as existsSync78, readFileSync as readFileSync59 } from "fs";
|
|
35224
35492
|
function logs(options2) {
|
|
35225
|
-
if (!
|
|
35493
|
+
if (!existsSync78(voicePaths.log)) {
|
|
35226
35494
|
console.log("No voice log file found");
|
|
35227
35495
|
return;
|
|
35228
35496
|
}
|
|
35229
35497
|
const count8 = Number.parseInt(options2.lines ?? "150", 10);
|
|
35230
|
-
const content =
|
|
35498
|
+
const content = readFileSync59(voicePaths.log, "utf8").trim();
|
|
35231
35499
|
if (!content) {
|
|
35232
35500
|
console.log("Voice log is empty");
|
|
35233
35501
|
return;
|
|
@@ -35253,8 +35521,8 @@ import { mkdirSync as mkdirSync33 } from "fs";
|
|
|
35253
35521
|
import { join as join94 } from "path";
|
|
35254
35522
|
|
|
35255
35523
|
// src/commands/voice/checkLockFile.ts
|
|
35256
|
-
import { execSync as
|
|
35257
|
-
import { existsSync as
|
|
35524
|
+
import { execSync as execSync64 } from "child_process";
|
|
35525
|
+
import { existsSync as existsSync79, mkdirSync as mkdirSync32, readFileSync as readFileSync60, writeFileSync as writeFileSync50 } from "fs";
|
|
35258
35526
|
import { join as join93 } from "path";
|
|
35259
35527
|
function isProcessAlive2(pid) {
|
|
35260
35528
|
try {
|
|
@@ -35266,9 +35534,9 @@ function isProcessAlive2(pid) {
|
|
|
35266
35534
|
}
|
|
35267
35535
|
function checkLockFile() {
|
|
35268
35536
|
const lockFile = getLockFile();
|
|
35269
|
-
if (!
|
|
35537
|
+
if (!existsSync79(lockFile)) return;
|
|
35270
35538
|
try {
|
|
35271
|
-
const lock2 = JSON.parse(
|
|
35539
|
+
const lock2 = JSON.parse(readFileSync60(lockFile, "utf8"));
|
|
35272
35540
|
if (lock2.pid && isProcessAlive2(lock2.pid)) {
|
|
35273
35541
|
console.error(
|
|
35274
35542
|
`Voice daemon already running (PID ${lock2.pid}, env: ${lock2.env}). Stop it first with: assist voice stop`
|
|
@@ -35279,10 +35547,10 @@ function checkLockFile() {
|
|
|
35279
35547
|
}
|
|
35280
35548
|
}
|
|
35281
35549
|
function bootstrapVenv() {
|
|
35282
|
-
if (
|
|
35550
|
+
if (existsSync79(getVenvPython())) return;
|
|
35283
35551
|
console.log("Setting up Python environment...");
|
|
35284
35552
|
const pythonDir = getPythonDir();
|
|
35285
|
-
|
|
35553
|
+
execSync64(
|
|
35286
35554
|
`uv sync --project "${pythonDir}" --extra runtime --no-install-project`,
|
|
35287
35555
|
{
|
|
35288
35556
|
stdio: "inherit",
|
|
@@ -35370,7 +35638,7 @@ function start2(options2) {
|
|
|
35370
35638
|
}
|
|
35371
35639
|
|
|
35372
35640
|
// src/commands/voice/status.ts
|
|
35373
|
-
import { existsSync as
|
|
35641
|
+
import { existsSync as existsSync80, readFileSync as readFileSync61 } from "fs";
|
|
35374
35642
|
function isProcessAlive3(pid) {
|
|
35375
35643
|
try {
|
|
35376
35644
|
process.kill(pid, 0);
|
|
@@ -35380,16 +35648,16 @@ function isProcessAlive3(pid) {
|
|
|
35380
35648
|
}
|
|
35381
35649
|
}
|
|
35382
35650
|
function readRecentLogs(count8) {
|
|
35383
|
-
if (!
|
|
35384
|
-
const lines2 =
|
|
35651
|
+
if (!existsSync80(voicePaths.log)) return [];
|
|
35652
|
+
const lines2 = readFileSync61(voicePaths.log, "utf8").trim().split("\n");
|
|
35385
35653
|
return lines2.slice(-count8);
|
|
35386
35654
|
}
|
|
35387
35655
|
function status2() {
|
|
35388
|
-
if (!
|
|
35656
|
+
if (!existsSync80(voicePaths.pid)) {
|
|
35389
35657
|
console.log("Voice daemon: not running (no PID file)");
|
|
35390
35658
|
return;
|
|
35391
35659
|
}
|
|
35392
|
-
const pid = Number.parseInt(
|
|
35660
|
+
const pid = Number.parseInt(readFileSync61(voicePaths.pid, "utf8").trim(), 10);
|
|
35393
35661
|
const alive = isProcessAlive3(pid);
|
|
35394
35662
|
console.log(`Voice daemon: ${alive ? "running" : "dead"} (PID ${pid})`);
|
|
35395
35663
|
const recent = readRecentLogs(5);
|
|
@@ -35408,13 +35676,13 @@ function status2() {
|
|
|
35408
35676
|
}
|
|
35409
35677
|
|
|
35410
35678
|
// src/commands/voice/stop.ts
|
|
35411
|
-
import { existsSync as
|
|
35679
|
+
import { existsSync as existsSync81, readFileSync as readFileSync62, unlinkSync as unlinkSync20 } from "fs";
|
|
35412
35680
|
function stop2() {
|
|
35413
|
-
if (!
|
|
35681
|
+
if (!existsSync81(voicePaths.pid)) {
|
|
35414
35682
|
console.log("Voice daemon is not running (no PID file)");
|
|
35415
35683
|
return;
|
|
35416
35684
|
}
|
|
35417
|
-
const pid = Number.parseInt(
|
|
35685
|
+
const pid = Number.parseInt(readFileSync62(voicePaths.pid, "utf8").trim(), 10);
|
|
35418
35686
|
try {
|
|
35419
35687
|
process.kill(pid, "SIGTERM");
|
|
35420
35688
|
console.log(`Sent SIGTERM to voice daemon (PID ${pid})`);
|
|
@@ -35427,7 +35695,7 @@ function stop2() {
|
|
|
35427
35695
|
}
|
|
35428
35696
|
try {
|
|
35429
35697
|
const lockFile = getLockFile();
|
|
35430
|
-
if (
|
|
35698
|
+
if (existsSync81(lockFile)) unlinkSync20(lockFile);
|
|
35431
35699
|
} catch {
|
|
35432
35700
|
}
|
|
35433
35701
|
console.log("Voice daemon stopped");
|
|
@@ -35828,7 +36096,7 @@ function resolveParams(params, cliArgs) {
|
|
|
35828
36096
|
}
|
|
35829
36097
|
|
|
35830
36098
|
// src/commands/run/resolveRunCwd.ts
|
|
35831
|
-
import { existsSync as
|
|
36099
|
+
import { existsSync as existsSync82 } from "fs";
|
|
35832
36100
|
import { resolve as resolve19 } from "path";
|
|
35833
36101
|
var MissingRunCwdError = class extends Error {
|
|
35834
36102
|
constructor(runName, cwd) {
|
|
@@ -35841,17 +36109,17 @@ var MissingRunCwdError = class extends Error {
|
|
|
35841
36109
|
function resolveRunCwd(config, baseDir = runConfigBaseDir()) {
|
|
35842
36110
|
if (!config.cwd) return void 0;
|
|
35843
36111
|
const cwd = resolve19(baseDir, config.cwd);
|
|
35844
|
-
if (!
|
|
36112
|
+
if (!existsSync82(cwd)) throw new MissingRunCwdError(config.name, cwd);
|
|
35845
36113
|
return cwd;
|
|
35846
36114
|
}
|
|
35847
36115
|
|
|
35848
36116
|
// src/commands/run/runCommandToCompletion.ts
|
|
35849
36117
|
import { spawn as spawn9 } from "child_process";
|
|
35850
|
-
import { existsSync as
|
|
36118
|
+
import { existsSync as existsSync84 } from "fs";
|
|
35851
36119
|
|
|
35852
36120
|
// src/commands/run/resolveCommand.ts
|
|
35853
36121
|
import { execFileSync as execFileSync19 } from "child_process";
|
|
35854
|
-
import { existsSync as
|
|
36122
|
+
import { existsSync as existsSync83 } from "fs";
|
|
35855
36123
|
import { dirname as dirname39, join as join97, resolve as resolve20 } from "path";
|
|
35856
36124
|
function resolveCommand2(command) {
|
|
35857
36125
|
if (process.platform !== "win32" || command !== "bash") return command;
|
|
@@ -35859,7 +36127,7 @@ function resolveCommand2(command) {
|
|
|
35859
36127
|
const gitPath = execFileSync19("where", ["git"], { encoding: "utf8" }).trim().split("\r\n")[0];
|
|
35860
36128
|
const gitRoot = resolve20(dirname39(gitPath), "..");
|
|
35861
36129
|
const gitBash = join97(gitRoot, "bin", "bash.exe");
|
|
35862
|
-
if (
|
|
36130
|
+
if (existsSync83(gitBash)) return gitBash;
|
|
35863
36131
|
} catch {
|
|
35864
36132
|
return command;
|
|
35865
36133
|
}
|
|
@@ -35869,7 +36137,7 @@ function resolveCommand2(command) {
|
|
|
35869
36137
|
// src/commands/run/runCommandToCompletion.ts
|
|
35870
36138
|
function runCommandToCompletion(command, args, env, cwd, quiet) {
|
|
35871
36139
|
return new Promise((resolveResult) => {
|
|
35872
|
-
if (cwd && !
|
|
36140
|
+
if (cwd && !existsSync84(cwd)) {
|
|
35873
36141
|
resolveResult({
|
|
35874
36142
|
kind: "failed",
|
|
35875
36143
|
message: `Failed to execute command: cwd ${cwd} does not exist`
|
|
@@ -35903,11 +36171,11 @@ function runCommandToCompletion(command, args, env, cwd, quiet) {
|
|
|
35903
36171
|
}
|
|
35904
36172
|
|
|
35905
36173
|
// src/commands/run/runPreCommands.ts
|
|
35906
|
-
import { execSync as
|
|
36174
|
+
import { execSync as execSync65 } from "child_process";
|
|
35907
36175
|
function runPreCommands(pre, cwd) {
|
|
35908
36176
|
for (const cmd of pre) {
|
|
35909
36177
|
try {
|
|
35910
|
-
|
|
36178
|
+
execSync65(cmd, { stdio: "inherit", cwd });
|
|
35911
36179
|
} catch (error) {
|
|
35912
36180
|
const code = error && typeof error === "object" && "status" in error ? error.status : 1;
|
|
35913
36181
|
process.exit(code);
|
|
@@ -36126,7 +36394,7 @@ function registerWatch(program2) {
|
|
|
36126
36394
|
|
|
36127
36395
|
// src/commands/roam/auth.ts
|
|
36128
36396
|
import { randomBytes } from "crypto";
|
|
36129
|
-
import
|
|
36397
|
+
import chalk235 from "chalk";
|
|
36130
36398
|
|
|
36131
36399
|
// src/commands/roam/waitForCallback.ts
|
|
36132
36400
|
import { createServer as createServer3 } from "http";
|
|
@@ -36257,13 +36525,13 @@ async function auth() {
|
|
|
36257
36525
|
saveGlobalConfig(config);
|
|
36258
36526
|
const state = randomBytes(16).toString("hex");
|
|
36259
36527
|
console.log(
|
|
36260
|
-
|
|
36528
|
+
chalk235.yellow("\nEnsure this Redirect URI is set in your Roam OAuth app:")
|
|
36261
36529
|
);
|
|
36262
|
-
console.log(
|
|
36263
|
-
console.log(
|
|
36264
|
-
console.log(
|
|
36530
|
+
console.log(chalk235.white("http://localhost:14523/callback\n"));
|
|
36531
|
+
console.log(chalk235.blue("Opening browser for authorization..."));
|
|
36532
|
+
console.log(chalk235.dim("Waiting for authorization callback..."));
|
|
36265
36533
|
const { code, redirectUri } = await authorizeInBrowser(clientId, state);
|
|
36266
|
-
console.log(
|
|
36534
|
+
console.log(chalk235.dim("Exchanging code for tokens..."));
|
|
36267
36535
|
const tokens = await exchangeToken({
|
|
36268
36536
|
code,
|
|
36269
36537
|
clientId,
|
|
@@ -36279,13 +36547,13 @@ async function auth() {
|
|
|
36279
36547
|
};
|
|
36280
36548
|
saveGlobalConfig(config);
|
|
36281
36549
|
console.log(
|
|
36282
|
-
|
|
36550
|
+
chalk235.green("Roam credentials and tokens saved to ~/.assist.yml")
|
|
36283
36551
|
);
|
|
36284
36552
|
}
|
|
36285
36553
|
|
|
36286
36554
|
// src/commands/roam/postRoamActivity.ts
|
|
36287
36555
|
import { execFileSync as execFileSync21 } from "child_process";
|
|
36288
|
-
import { readdirSync as readdirSync22, readFileSync as
|
|
36556
|
+
import { readdirSync as readdirSync22, readFileSync as readFileSync63, statSync as statSync12 } from "fs";
|
|
36289
36557
|
import { join as join98 } from "path";
|
|
36290
36558
|
function findPortFile(roamDir) {
|
|
36291
36559
|
let entries;
|
|
@@ -36316,7 +36584,7 @@ function postRoamActivity(app, event) {
|
|
|
36316
36584
|
if (!portFile) return;
|
|
36317
36585
|
let port;
|
|
36318
36586
|
try {
|
|
36319
|
-
port =
|
|
36587
|
+
port = readFileSync63(portFile, "utf8").trim();
|
|
36320
36588
|
} catch {
|
|
36321
36589
|
return;
|
|
36322
36590
|
}
|
|
@@ -36573,7 +36841,7 @@ function link2() {
|
|
|
36573
36841
|
}
|
|
36574
36842
|
|
|
36575
36843
|
// src/commands/run/remove.ts
|
|
36576
|
-
import { existsSync as
|
|
36844
|
+
import { existsSync as existsSync85, unlinkSync as unlinkSync21 } from "fs";
|
|
36577
36845
|
import { join as join100 } from "path";
|
|
36578
36846
|
function findRemoveIndex() {
|
|
36579
36847
|
const idx = process.argv.indexOf("remove");
|
|
@@ -36590,7 +36858,7 @@ function parseRemoveName() {
|
|
|
36590
36858
|
}
|
|
36591
36859
|
function deleteCommandFile(name) {
|
|
36592
36860
|
const filePath = join100(".claude", "commands", `${name}.md`);
|
|
36593
|
-
if (
|
|
36861
|
+
if (existsSync85(filePath)) {
|
|
36594
36862
|
unlinkSync21(filePath);
|
|
36595
36863
|
console.log(`Deleted command file: ${filePath}`);
|
|
36596
36864
|
}
|
|
@@ -36634,11 +36902,11 @@ function registerRun(program2) {
|
|
|
36634
36902
|
}
|
|
36635
36903
|
|
|
36636
36904
|
// src/commands/screenshot/index.ts
|
|
36637
|
-
import { execSync as
|
|
36638
|
-
import { existsSync as
|
|
36905
|
+
import { execSync as execSync66 } from "child_process";
|
|
36906
|
+
import { existsSync as existsSync86, mkdirSync as mkdirSync36, unlinkSync as unlinkSync22, writeFileSync as writeFileSync53 } from "fs";
|
|
36639
36907
|
import { tmpdir as tmpdir9 } from "os";
|
|
36640
36908
|
import { join as join101, resolve as resolve21 } from "path";
|
|
36641
|
-
import
|
|
36909
|
+
import chalk236 from "chalk";
|
|
36642
36910
|
|
|
36643
36911
|
// src/commands/screenshot/captureWindowPs1.ts
|
|
36644
36912
|
var captureWindowPs1 = `
|
|
@@ -36767,7 +37035,7 @@ Write-Output $OutputPath
|
|
|
36767
37035
|
|
|
36768
37036
|
// src/commands/screenshot/index.ts
|
|
36769
37037
|
function buildOutputPath(outputDir, processName) {
|
|
36770
|
-
if (!
|
|
37038
|
+
if (!existsSync86(outputDir)) {
|
|
36771
37039
|
mkdirSync36(outputDir, { recursive: true });
|
|
36772
37040
|
}
|
|
36773
37041
|
const timestamp6 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
@@ -36777,7 +37045,7 @@ function runPowerShellScript(processName, outputPath) {
|
|
|
36777
37045
|
const scriptPath = join101(tmpdir9(), `assist-screenshot-${Date.now()}.ps1`);
|
|
36778
37046
|
writeFileSync53(scriptPath, captureWindowPs1, "utf8");
|
|
36779
37047
|
try {
|
|
36780
|
-
|
|
37048
|
+
execSync66(
|
|
36781
37049
|
`powershell -NoProfile -ExecutionPolicy Bypass -File "${scriptPath}" -ProcessName "${processName}" -OutputPath "${outputPath}"`,
|
|
36782
37050
|
{ stdio: ["ignore", "pipe", "pipe"], encoding: "utf8" }
|
|
36783
37051
|
);
|
|
@@ -36789,13 +37057,13 @@ function screenshot(processName) {
|
|
|
36789
37057
|
const config = loadConfig();
|
|
36790
37058
|
const outputDir = resolve21(config.screenshot.outputDir);
|
|
36791
37059
|
const outputPath = buildOutputPath(outputDir, processName);
|
|
36792
|
-
console.log(
|
|
37060
|
+
console.log(chalk236.gray(`Capturing window for process "${processName}" ...`));
|
|
36793
37061
|
try {
|
|
36794
37062
|
runPowerShellScript(processName, outputPath);
|
|
36795
|
-
console.log(
|
|
37063
|
+
console.log(chalk236.green(`Screenshot saved: ${outputPath}`));
|
|
36796
37064
|
} catch (error) {
|
|
36797
37065
|
const msg = error instanceof Error ? error.message : String(error);
|
|
36798
|
-
console.error(
|
|
37066
|
+
console.error(chalk236.red(`Failed to capture screenshot: ${msg}`));
|
|
36799
37067
|
process.exit(1);
|
|
36800
37068
|
}
|
|
36801
37069
|
}
|
|
@@ -36851,11 +37119,11 @@ function applyLine(result, pending, line) {
|
|
|
36851
37119
|
}
|
|
36852
37120
|
|
|
36853
37121
|
// src/commands/sessions/daemon/readDaemonPidFile.ts
|
|
36854
|
-
import { readFileSync as
|
|
37122
|
+
import { readFileSync as readFileSync64 } from "fs";
|
|
36855
37123
|
function readDaemonPidFile() {
|
|
36856
37124
|
try {
|
|
36857
37125
|
const pid = Number.parseInt(
|
|
36858
|
-
|
|
37126
|
+
readFileSync64(daemonPaths.pid, "utf8").trim(),
|
|
36859
37127
|
10
|
|
36860
37128
|
);
|
|
36861
37129
|
return Number.isInteger(pid) ? pid : void 0;
|
|
@@ -37118,12 +37386,12 @@ function toSessionRunInfo({
|
|
|
37118
37386
|
}
|
|
37119
37387
|
|
|
37120
37388
|
// src/commands/sessions/daemon/worktree/joinRefusal.ts
|
|
37121
|
-
import { existsSync as
|
|
37389
|
+
import { existsSync as existsSync87 } from "fs";
|
|
37122
37390
|
function joinRefusal(session) {
|
|
37123
37391
|
if (session.commandType === "run") return "a server run has no agent stream";
|
|
37124
37392
|
if (session.closing === true) return "the session is closing";
|
|
37125
37393
|
if (!session.cwd) return "the session has no working directory";
|
|
37126
|
-
if (!
|
|
37394
|
+
if (!existsSync87(session.cwd))
|
|
37127
37395
|
return "the session's workspace no longer exists";
|
|
37128
37396
|
return void 0;
|
|
37129
37397
|
}
|
|
@@ -37287,11 +37555,11 @@ function sessionBase(id, status3) {
|
|
|
37287
37555
|
}
|
|
37288
37556
|
|
|
37289
37557
|
// src/commands/sessions/daemon/spawnPty.ts
|
|
37290
|
-
import { existsSync as
|
|
37558
|
+
import { existsSync as existsSync89 } from "fs";
|
|
37291
37559
|
import * as pty from "node-pty";
|
|
37292
37560
|
|
|
37293
37561
|
// src/commands/sessions/daemon/ensureSpawnHelperExecutable.ts
|
|
37294
|
-
import { chmodSync, existsSync as
|
|
37562
|
+
import { chmodSync, existsSync as existsSync88, statSync as statSync13 } from "fs";
|
|
37295
37563
|
import { createRequire as createRequire3 } from "module";
|
|
37296
37564
|
import path86 from "path";
|
|
37297
37565
|
var require4 = createRequire3(import.meta.url);
|
|
@@ -37306,7 +37574,7 @@ function ensureSpawnHelperExecutable() {
|
|
|
37306
37574
|
`${process.platform}-${process.arch}`,
|
|
37307
37575
|
"spawn-helper"
|
|
37308
37576
|
);
|
|
37309
|
-
if (!
|
|
37577
|
+
if (!existsSync88(helper)) return;
|
|
37310
37578
|
const mode = statSync13(helper).mode;
|
|
37311
37579
|
if ((mode & 73) === 0) chmodSync(helper, mode | 493);
|
|
37312
37580
|
}
|
|
@@ -37342,7 +37610,7 @@ function spawnPty(args, cwd, sessionId, extraEnv) {
|
|
|
37342
37610
|
});
|
|
37343
37611
|
}
|
|
37344
37612
|
function refuseMissingCwd(cwd, sessionId) {
|
|
37345
|
-
if (!cwd ||
|
|
37613
|
+
if (!cwd || existsSync89(cwd)) return;
|
|
37346
37614
|
daemonLog(
|
|
37347
37615
|
`${sessionId ? `session ${sessionId}` : "pty"} not spawned: working directory ${cwd} no longer exists`
|
|
37348
37616
|
);
|
|
@@ -37531,11 +37799,11 @@ function setStatus2(session, newStatus) {
|
|
|
37531
37799
|
}
|
|
37532
37800
|
|
|
37533
37801
|
// src/commands/sessions/daemon/worktree/reapWorktree.ts
|
|
37534
|
-
import { existsSync as
|
|
37535
|
-
import { basename as
|
|
37802
|
+
import { existsSync as existsSync91 } from "fs";
|
|
37803
|
+
import { basename as basename26 } from "path";
|
|
37536
37804
|
|
|
37537
37805
|
// src/commands/sessions/daemon/worktree/deleteStrandedTree.ts
|
|
37538
|
-
import { existsSync as
|
|
37806
|
+
import { existsSync as existsSync90 } from "fs";
|
|
37539
37807
|
import { join as join104 } from "path";
|
|
37540
37808
|
|
|
37541
37809
|
// src/commands/sessions/daemon/worktree/deleteTreeDirectly.ts
|
|
@@ -37605,7 +37873,7 @@ async function deleteStrandedTree(clone, worktreePath, cause) {
|
|
|
37605
37873
|
);
|
|
37606
37874
|
}
|
|
37607
37875
|
function strandedReason(worktreePath, cause) {
|
|
37608
|
-
if (!
|
|
37876
|
+
if (!existsSync90(join104(worktreePath, ".git")))
|
|
37609
37877
|
return "its .git link is already gone";
|
|
37610
37878
|
if (/not a working tree|not a git repository/i.test(reason2(cause)))
|
|
37611
37879
|
return "git no longer recognises it as a working tree";
|
|
@@ -37657,7 +37925,7 @@ function reason3(error) {
|
|
|
37657
37925
|
|
|
37658
37926
|
// src/commands/sessions/daemon/worktree/reapWorktree.ts
|
|
37659
37927
|
async function reapWorktree(worktreePath, force = false) {
|
|
37660
|
-
if (!
|
|
37928
|
+
if (!existsSync91(worktreePath)) {
|
|
37661
37929
|
forgetWorktree(worktreePath);
|
|
37662
37930
|
daemonLog(
|
|
37663
37931
|
`worktree ${worktreePath} already gone; its record was forgotten`
|
|
@@ -37675,14 +37943,14 @@ async function reapWorktree(worktreePath, force = false) {
|
|
|
37675
37943
|
const clone = owningClone(worktreePath);
|
|
37676
37944
|
const removal = await removeTree(clone, worktreePath, force);
|
|
37677
37945
|
if (!removal.removed) return removal;
|
|
37678
|
-
await deleteWorktreeBranch(clone,
|
|
37946
|
+
await deleteWorktreeBranch(clone, basename26(worktreePath));
|
|
37679
37947
|
forgetWorktree(worktreePath);
|
|
37680
37948
|
daemonLog(`worktree ${worktreePath} reaped${force ? " (forced)" : ""}`);
|
|
37681
37949
|
return removal;
|
|
37682
37950
|
}
|
|
37683
37951
|
function owningClone(worktreePath) {
|
|
37684
37952
|
const recorded = worktreeAttributionIncludingReaped(worktreePath)?.clone;
|
|
37685
|
-
if (recorded &&
|
|
37953
|
+
if (recorded && existsSync91(recorded)) return recorded;
|
|
37686
37954
|
const detected = mainWorktree(worktreePath);
|
|
37687
37955
|
if (detected) return detected;
|
|
37688
37956
|
daemonLog(
|
|
@@ -37813,12 +38081,12 @@ function closeGateApplies(sessions, session) {
|
|
|
37813
38081
|
}
|
|
37814
38082
|
|
|
37815
38083
|
// src/commands/sessions/daemon/worktree/watchGitState.ts
|
|
37816
|
-
import { existsSync as
|
|
38084
|
+
import { existsSync as existsSync92, watch } from "fs";
|
|
37817
38085
|
var DEBOUNCE_MS = 500;
|
|
37818
38086
|
var POLL_MS = 3e4;
|
|
37819
38087
|
function watchGitState(cwd, onChange) {
|
|
37820
38088
|
const common = gitCommonDir(cwd);
|
|
37821
|
-
if (!common || !
|
|
38089
|
+
if (!common || !existsSync92(common)) return void 0;
|
|
37822
38090
|
const watchers = [
|
|
37823
38091
|
watchGitDir(common, onChange),
|
|
37824
38092
|
pollGitState(cwd, onChange)
|
|
@@ -38313,10 +38581,10 @@ function emitSessionOutput(session, clients, data) {
|
|
|
38313
38581
|
}
|
|
38314
38582
|
|
|
38315
38583
|
// src/commands/sessions/daemon/exitReason.ts
|
|
38316
|
-
import { existsSync as
|
|
38584
|
+
import { existsSync as existsSync93 } from "fs";
|
|
38317
38585
|
import { resolve as resolve22 } from "path";
|
|
38318
38586
|
function exitDetail(session) {
|
|
38319
|
-
if (session.cwd && !
|
|
38587
|
+
if (session.cwd && !existsSync93(session.cwd))
|
|
38320
38588
|
return `working directory ${session.cwd} no longer exists`;
|
|
38321
38589
|
return missingRunConfigCwd(session);
|
|
38322
38590
|
}
|
|
@@ -38330,7 +38598,7 @@ function missingRunConfigCwd(session) {
|
|
|
38330
38598
|
const config = resolveRunConfig(session.runName, dir);
|
|
38331
38599
|
if (!config?.cwd) return void 0;
|
|
38332
38600
|
const configured = resolve22(runConfigBaseDirFrom(dir), config.cwd);
|
|
38333
|
-
if (
|
|
38601
|
+
if (existsSync93(configured)) return void 0;
|
|
38334
38602
|
return `run config "${config.name}": cwd ${configured} does not exist`;
|
|
38335
38603
|
}
|
|
38336
38604
|
|
|
@@ -38367,7 +38635,7 @@ function handleFailedResume(session, exitCode, onStatusChange) {
|
|
|
38367
38635
|
}
|
|
38368
38636
|
|
|
38369
38637
|
// src/commands/sessions/daemon/watchActivity.ts
|
|
38370
|
-
import { existsSync as
|
|
38638
|
+
import { existsSync as existsSync94, mkdirSync as mkdirSync37, watch as watch2 } from "fs";
|
|
38371
38639
|
import { dirname as dirname41 } from "path";
|
|
38372
38640
|
|
|
38373
38641
|
// src/commands/sessions/daemon/applyActivityToSession.ts
|
|
@@ -38453,7 +38721,7 @@ function watchActivity(session, notify2, onClaudeSessionId) {
|
|
|
38453
38721
|
if (timer) clearTimeout(timer);
|
|
38454
38722
|
timer = setTimeout(read3, DEBOUNCE_MS2);
|
|
38455
38723
|
});
|
|
38456
|
-
if (
|
|
38724
|
+
if (existsSync94(path91)) read3();
|
|
38457
38725
|
}
|
|
38458
38726
|
function refreshActivity(session) {
|
|
38459
38727
|
if (session.commandType !== "assist" || !session.cwd) return;
|
|
@@ -40176,8 +40444,8 @@ function rearmStoppedSessions(sessions, notify2) {
|
|
|
40176
40444
|
}
|
|
40177
40445
|
|
|
40178
40446
|
// src/commands/sessions/daemon/worktree/reconcileWorktreesOnRestore.ts
|
|
40179
|
-
import { existsSync as
|
|
40180
|
-
import { basename as
|
|
40447
|
+
import { existsSync as existsSync97 } from "fs";
|
|
40448
|
+
import { basename as basename28 } from "path";
|
|
40181
40449
|
|
|
40182
40450
|
// src/commands/sessions/daemon/worktree/accountedTrees.ts
|
|
40183
40451
|
function accountedTrees(sessions) {
|
|
@@ -40231,9 +40499,9 @@ function bindResumedWorktree(session, cwd, notify2) {
|
|
|
40231
40499
|
}
|
|
40232
40500
|
|
|
40233
40501
|
// src/commands/sessions/daemon/worktree/reclaimVanishedWorktrees.ts
|
|
40234
|
-
import { existsSync as
|
|
40502
|
+
import { existsSync as existsSync96 } from "fs";
|
|
40235
40503
|
async function reclaimVanishedWorktrees(clone, paths) {
|
|
40236
|
-
if (!
|
|
40504
|
+
if (!existsSync96(clone)) {
|
|
40237
40505
|
for (const { path: path91 } of paths) forgetWorktree(path91);
|
|
40238
40506
|
daemonLog(
|
|
40239
40507
|
`clone ${clone} is gone; forgot ${paths.length} worktree record(s) it owned`
|
|
@@ -40319,7 +40587,7 @@ function capped(lines2) {
|
|
|
40319
40587
|
}
|
|
40320
40588
|
|
|
40321
40589
|
// src/commands/sessions/daemon/worktree/resurfaceOrphanedWorktree.ts
|
|
40322
|
-
import { basename as
|
|
40590
|
+
import { basename as basename27 } from "path";
|
|
40323
40591
|
function resurfaceOrphanedWorktree(sessions, spawnWith, recovered, notify2) {
|
|
40324
40592
|
const { orphan, reason: reason4, held } = recovered;
|
|
40325
40593
|
let id;
|
|
@@ -40342,7 +40610,7 @@ function orphanedSession(id, recovered) {
|
|
|
40342
40610
|
const { orphan, reason: reason4, held } = recovered;
|
|
40343
40611
|
return {
|
|
40344
40612
|
...sessionBase(id, "stopped"),
|
|
40345
|
-
name: `recovered ${
|
|
40613
|
+
name: `recovered ${basename27(orphan.path)}`,
|
|
40346
40614
|
subtitle: `${held.summary} in ${orphan.path}`,
|
|
40347
40615
|
commandType: "claude",
|
|
40348
40616
|
pty: null,
|
|
@@ -40399,11 +40667,11 @@ async function recoverOrphanedWorktrees(sessions, spawnWith, notify2) {
|
|
|
40399
40667
|
);
|
|
40400
40668
|
continue;
|
|
40401
40669
|
}
|
|
40402
|
-
if (!
|
|
40670
|
+
if (!existsSync97(path91)) {
|
|
40403
40671
|
logVanishedTree(sessions, path91);
|
|
40404
40672
|
vanished.set(clone, [
|
|
40405
40673
|
...vanished.get(clone) ?? [],
|
|
40406
|
-
{ path: path91, branch:
|
|
40674
|
+
{ path: path91, branch: basename28(path91) }
|
|
40407
40675
|
]);
|
|
40408
40676
|
continue;
|
|
40409
40677
|
}
|
|
@@ -41051,14 +41319,14 @@ async function defaultConnect() {
|
|
|
41051
41319
|
}
|
|
41052
41320
|
|
|
41053
41321
|
// src/commands/sessions/daemon/hasPersistedWindowsSessions.ts
|
|
41054
|
-
import { existsSync as
|
|
41322
|
+
import { existsSync as existsSync98, readFileSync as readFileSync66 } from "fs";
|
|
41055
41323
|
import { posix as posix3 } from "path";
|
|
41056
41324
|
function hasPersistedWindowsSessions() {
|
|
41057
41325
|
const sessionsFile = windowsSessionsFileFromWsl();
|
|
41058
41326
|
if (!sessionsFile) return false;
|
|
41059
41327
|
try {
|
|
41060
|
-
if (!
|
|
41061
|
-
const data = JSON.parse(
|
|
41328
|
+
if (!existsSync98(sessionsFile)) return false;
|
|
41329
|
+
const data = JSON.parse(readFileSync66(sessionsFile, "utf8"));
|
|
41062
41330
|
return Array.isArray(data) && data.length > 0;
|
|
41063
41331
|
} catch (error) {
|
|
41064
41332
|
const message3 = error instanceof Error ? error.message : String(error);
|
|
@@ -41792,7 +42060,7 @@ function setAutoAdvance(sessions, id, enabled) {
|
|
|
41792
42060
|
}
|
|
41793
42061
|
|
|
41794
42062
|
// src/commands/sessions/daemon/worktree/resumeInTree.ts
|
|
41795
|
-
import { existsSync as
|
|
42063
|
+
import { existsSync as existsSync101 } from "fs";
|
|
41796
42064
|
|
|
41797
42065
|
// src/commands/sessions/daemon/resumeSession.ts
|
|
41798
42066
|
function resumeSession(id, sessionId, cwd, name, holdPty, harness) {
|
|
@@ -41823,10 +42091,10 @@ function resumeSession(id, sessionId, cwd, name, holdPty, harness) {
|
|
|
41823
42091
|
}
|
|
41824
42092
|
|
|
41825
42093
|
// src/commands/sessions/daemon/worktree/resumeInReplacementTree.ts
|
|
41826
|
-
import { existsSync as
|
|
42094
|
+
import { existsSync as existsSync100 } from "fs";
|
|
41827
42095
|
|
|
41828
42096
|
// src/commands/sessions/daemon/worktree/carryTranscriptToTree.ts
|
|
41829
|
-
import { copyFileSync as copyFileSync5, existsSync as
|
|
42097
|
+
import { copyFileSync as copyFileSync5, existsSync as existsSync99, mkdirSync as mkdirSync39 } from "fs";
|
|
41830
42098
|
import { join as join106 } from "path";
|
|
41831
42099
|
function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
41832
42100
|
const dir = projectDirForCwd(toCwd);
|
|
@@ -41837,7 +42105,7 @@ function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
|
41837
42105
|
return;
|
|
41838
42106
|
}
|
|
41839
42107
|
const dest = join106(dir, `${claudeSessionId}.jsonl`);
|
|
41840
|
-
if (
|
|
42108
|
+
if (existsSync99(dest)) {
|
|
41841
42109
|
daemonLog(`transcript ${claudeSessionId} already present in ${dir}`);
|
|
41842
42110
|
return;
|
|
41843
42111
|
}
|
|
@@ -41888,7 +42156,7 @@ function resumeInReplacementTree(ctx, claudeSessionId, missingCwd, name, harness
|
|
|
41888
42156
|
}
|
|
41889
42157
|
function cloneForReapedTree(missingCwd) {
|
|
41890
42158
|
const clone = worktreeAttributionIncludingReaped(missingCwd)?.clone;
|
|
41891
|
-
if (!clone || !
|
|
42159
|
+
if (!clone || !existsSync100(clone))
|
|
41892
42160
|
throw new Error(
|
|
41893
42161
|
`working directory no longer exists and no clone is recorded to re-allocate from: ${missingCwd}`
|
|
41894
42162
|
);
|
|
@@ -41897,7 +42165,7 @@ function cloneForReapedTree(missingCwd) {
|
|
|
41897
42165
|
|
|
41898
42166
|
// src/commands/sessions/daemon/worktree/resumeInTree.ts
|
|
41899
42167
|
function resumeInTree(ctx, sessionId, cwd, name, harness) {
|
|
41900
|
-
if (!
|
|
42168
|
+
if (!existsSync101(cwd))
|
|
41901
42169
|
return resumeInReplacementTree(ctx, sessionId, cwd, name, harness);
|
|
41902
42170
|
const id = ctx.spawnWith(
|
|
41903
42171
|
(sid) => resumeSession(sid, sessionId, cwd, name, void 0, harness)
|
|
@@ -42483,7 +42751,7 @@ function handleConnection(socket, manager) {
|
|
|
42483
42751
|
import { unlinkSync as unlinkSync23, writeFileSync as writeFileSync54 } from "fs";
|
|
42484
42752
|
|
|
42485
42753
|
// src/commands/sessions/daemon/startPidFileWatchdog.ts
|
|
42486
|
-
import { readFileSync as
|
|
42754
|
+
import { readFileSync as readFileSync67 } from "fs";
|
|
42487
42755
|
var WATCHDOG_INTERVAL_MS = 5e3;
|
|
42488
42756
|
function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
|
|
42489
42757
|
const timer = setInterval(() => {
|
|
@@ -42494,7 +42762,7 @@ function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
|
|
|
42494
42762
|
}
|
|
42495
42763
|
function ownsPidFile() {
|
|
42496
42764
|
try {
|
|
42497
|
-
return
|
|
42765
|
+
return readFileSync67(daemonPaths.pid, "utf8").trim() === String(process.pid);
|
|
42498
42766
|
} catch {
|
|
42499
42767
|
return false;
|
|
42500
42768
|
}
|
|
@@ -42776,7 +43044,7 @@ async function renameSession(title) {
|
|
|
42776
43044
|
|
|
42777
43045
|
// src/commands/sessions/summarise/index.ts
|
|
42778
43046
|
import * as fs57 from "fs";
|
|
42779
|
-
import
|
|
43047
|
+
import chalk237 from "chalk";
|
|
42780
43048
|
|
|
42781
43049
|
// src/commands/sessions/summarise/shared.ts
|
|
42782
43050
|
import * as fs56 from "fs";
|
|
@@ -42835,22 +43103,22 @@ ${firstMessage}`);
|
|
|
42835
43103
|
async function summarise2(options2) {
|
|
42836
43104
|
const files = await discoverSessionFiles();
|
|
42837
43105
|
if (files.length === 0) {
|
|
42838
|
-
console.log(
|
|
43106
|
+
console.log(chalk237.yellow("No sessions found."));
|
|
42839
43107
|
return;
|
|
42840
43108
|
}
|
|
42841
43109
|
const toProcess = selectCandidates(files, options2);
|
|
42842
43110
|
if (toProcess.length === 0) {
|
|
42843
|
-
console.log(
|
|
43111
|
+
console.log(chalk237.green("All sessions already summarised."));
|
|
42844
43112
|
return;
|
|
42845
43113
|
}
|
|
42846
43114
|
console.log(
|
|
42847
|
-
|
|
43115
|
+
chalk237.cyan(
|
|
42848
43116
|
`Summarising ${toProcess.length} session(s) (${files.length} total)\u2026`
|
|
42849
43117
|
)
|
|
42850
43118
|
);
|
|
42851
43119
|
const { succeeded, failed: failed2 } = processSessions(toProcess);
|
|
42852
43120
|
console.log(
|
|
42853
|
-
|
|
43121
|
+
chalk237.green(`Done: ${succeeded} summarised`) + (failed2 > 0 ? chalk237.yellow(`, ${failed2} skipped`) : "")
|
|
42854
43122
|
);
|
|
42855
43123
|
}
|
|
42856
43124
|
function selectCandidates(files, options2) {
|
|
@@ -42870,16 +43138,16 @@ function processSessions(files) {
|
|
|
42870
43138
|
let failed2 = 0;
|
|
42871
43139
|
for (let i = 0; i < files.length; i++) {
|
|
42872
43140
|
const file = files[i];
|
|
42873
|
-
process.stdout.write(
|
|
43141
|
+
process.stdout.write(chalk237.dim(` [${i + 1}/${files.length}] `));
|
|
42874
43142
|
const summary = summariseSession(file);
|
|
42875
43143
|
if (summary) {
|
|
42876
43144
|
writeSummary(file, summary);
|
|
42877
43145
|
succeeded++;
|
|
42878
|
-
process.stdout.write(`${
|
|
43146
|
+
process.stdout.write(`${chalk237.green("\u2713")} ${summary}
|
|
42879
43147
|
`);
|
|
42880
43148
|
} else {
|
|
42881
43149
|
failed2++;
|
|
42882
|
-
process.stdout.write(` ${
|
|
43150
|
+
process.stdout.write(` ${chalk237.yellow("skip")}
|
|
42883
43151
|
`);
|
|
42884
43152
|
}
|
|
42885
43153
|
}
|
|
@@ -42906,7 +43174,7 @@ function registerSessions(program2) {
|
|
|
42906
43174
|
}
|
|
42907
43175
|
|
|
42908
43176
|
// src/commands/statusLine.ts
|
|
42909
|
-
import
|
|
43177
|
+
import chalk239 from "chalk";
|
|
42910
43178
|
|
|
42911
43179
|
// src/shared/contextLevel.ts
|
|
42912
43180
|
function contextLevel(pct) {
|
|
@@ -42916,7 +43184,7 @@ function contextLevel(pct) {
|
|
|
42916
43184
|
}
|
|
42917
43185
|
|
|
42918
43186
|
// src/commands/buildLimitsSegment.ts
|
|
42919
|
-
import
|
|
43187
|
+
import chalk238 from "chalk";
|
|
42920
43188
|
|
|
42921
43189
|
// src/shared/rateLimitLevel.ts
|
|
42922
43190
|
var FIVE_HOUR_SECONDS = 5 * 3600;
|
|
@@ -42954,9 +43222,9 @@ function rateLimitLevel(pct, resetsAt, windowSeconds, now) {
|
|
|
42954
43222
|
|
|
42955
43223
|
// src/commands/buildLimitsSegment.ts
|
|
42956
43224
|
var LEVEL_COLOR = {
|
|
42957
|
-
ok:
|
|
42958
|
-
warn:
|
|
42959
|
-
over:
|
|
43225
|
+
ok: chalk238.green,
|
|
43226
|
+
warn: chalk238.yellow,
|
|
43227
|
+
over: chalk238.red
|
|
42960
43228
|
};
|
|
42961
43229
|
function formatLimit(pct, resetsAt, windowSeconds, fallbackLabel, now) {
|
|
42962
43230
|
const level = rateLimitLevel(pct, resetsAt, windowSeconds, now);
|
|
@@ -42987,7 +43255,7 @@ function buildLimitsSegment(rateLimits) {
|
|
|
42987
43255
|
}
|
|
42988
43256
|
|
|
42989
43257
|
// src/commands/readGitBranch.ts
|
|
42990
|
-
import { readFileSync as
|
|
43258
|
+
import { readFileSync as readFileSync69, statSync as statSync16 } from "fs";
|
|
42991
43259
|
import { isAbsolute as isAbsolute5, join as join107, resolve as resolve23 } from "path";
|
|
42992
43260
|
function resolveGitDir(cwd) {
|
|
42993
43261
|
const dotGit = join107(cwd, ".git");
|
|
@@ -43002,7 +43270,7 @@ function resolveGitDir(cwd) {
|
|
|
43002
43270
|
}
|
|
43003
43271
|
let contents;
|
|
43004
43272
|
try {
|
|
43005
|
-
contents =
|
|
43273
|
+
contents = readFileSync69(dotGit, "utf8");
|
|
43006
43274
|
} catch {
|
|
43007
43275
|
return null;
|
|
43008
43276
|
}
|
|
@@ -43020,7 +43288,7 @@ function readGitBranch(cwd) {
|
|
|
43020
43288
|
}
|
|
43021
43289
|
let head;
|
|
43022
43290
|
try {
|
|
43023
|
-
head =
|
|
43291
|
+
head = readFileSync69(join107(gitDir, "HEAD"), "utf8");
|
|
43024
43292
|
} catch {
|
|
43025
43293
|
return null;
|
|
43026
43294
|
}
|
|
@@ -43052,7 +43320,7 @@ async function relayUsage(claudeSessionId, transcriptPath2, usedPct) {
|
|
|
43052
43320
|
}
|
|
43053
43321
|
|
|
43054
43322
|
// src/commands/statusLine.ts
|
|
43055
|
-
|
|
43323
|
+
chalk239.level = 3;
|
|
43056
43324
|
function formatNumber(num) {
|
|
43057
43325
|
return num.toLocaleString("en-US");
|
|
43058
43326
|
}
|
|
@@ -43060,9 +43328,9 @@ function colorizePercent(pct) {
|
|
|
43060
43328
|
const label2 = `${Math.round(pct)}%`;
|
|
43061
43329
|
switch (contextLevel(pct)) {
|
|
43062
43330
|
case "red":
|
|
43063
|
-
return
|
|
43331
|
+
return chalk239.red(label2);
|
|
43064
43332
|
case "yellow":
|
|
43065
|
-
return
|
|
43333
|
+
return chalk239.yellow(label2);
|
|
43066
43334
|
default:
|
|
43067
43335
|
return label2;
|
|
43068
43336
|
}
|
|
@@ -43075,7 +43343,7 @@ async function statusLine() {
|
|
|
43075
43343
|
const usedPct = data.context_window.used_percentage ?? 0;
|
|
43076
43344
|
const dir = data.workspace?.current_dir ?? data.cwd;
|
|
43077
43345
|
const branch2 = dir ? readGitBranch(toGitCwd(dir)) : null;
|
|
43078
|
-
const branchSegment = branch2 ? `\u{1F33F}\uFE0F ${
|
|
43346
|
+
const branchSegment = branch2 ? `\u{1F33F}\uFE0F ${chalk239.cyan(branch2)} | ` : "";
|
|
43079
43347
|
console.log(
|
|
43080
43348
|
`${branchSegment}${model} | Tokens - ${formatNumber(totalIn)} \u2191 : ${formatNumber(totalOut)} \u2193 | Context - ${colorizePercent(usedPct)}${buildLimitsSegment(data.rate_limits)}`
|
|
43081
43349
|
);
|
|
@@ -43088,7 +43356,7 @@ async function statusLine() {
|
|
|
43088
43356
|
}
|
|
43089
43357
|
|
|
43090
43358
|
// src/commands/update.ts
|
|
43091
|
-
import { execSync as
|
|
43359
|
+
import { execSync as execSync67 } from "child_process";
|
|
43092
43360
|
import * as path90 from "path";
|
|
43093
43361
|
|
|
43094
43362
|
// src/commands/restartDaemonAfterUpdate.ts
|
|
@@ -43112,7 +43380,7 @@ function isGlobalNpmInstall(dir) {
|
|
|
43112
43380
|
if (resolved.split(path90.sep).includes("node_modules")) {
|
|
43113
43381
|
return true;
|
|
43114
43382
|
}
|
|
43115
|
-
const globalPrefix =
|
|
43383
|
+
const globalPrefix = execSync67("npm prefix -g", { stdio: "pipe" }).toString().trim();
|
|
43116
43384
|
return resolved.toLowerCase().startsWith(path90.resolve(globalPrefix).toLowerCase());
|
|
43117
43385
|
} catch {
|
|
43118
43386
|
return false;
|
|
@@ -43123,18 +43391,18 @@ async function update2() {
|
|
|
43123
43391
|
console.log(`Assist is installed at: ${installDir}`);
|
|
43124
43392
|
if (isGitRepo(installDir)) {
|
|
43125
43393
|
console.log("Detected git repo installation, pulling latest...");
|
|
43126
|
-
|
|
43394
|
+
execSync67("git pull", { cwd: installDir, stdio: "inherit" });
|
|
43127
43395
|
console.log("Installing dependencies...");
|
|
43128
|
-
|
|
43396
|
+
execSync67("npm i", { cwd: installDir, stdio: "inherit" });
|
|
43129
43397
|
console.log("Building...");
|
|
43130
|
-
|
|
43398
|
+
execSync67("npm run build", { cwd: installDir, stdio: "inherit" });
|
|
43131
43399
|
console.log("Syncing commands...");
|
|
43132
|
-
|
|
43400
|
+
execSync67("assist sync", { stdio: "inherit" });
|
|
43133
43401
|
} else if (isGlobalNpmInstall(installDir)) {
|
|
43134
43402
|
console.log("Detected global npm installation, updating...");
|
|
43135
|
-
|
|
43403
|
+
execSync67("npm i -g @staff0rd/assist@latest", { stdio: "inherit" });
|
|
43136
43404
|
console.log("Syncing commands...");
|
|
43137
|
-
|
|
43405
|
+
execSync67("assist sync", { stdio: "inherit" });
|
|
43138
43406
|
} else {
|
|
43139
43407
|
console.error(
|
|
43140
43408
|
"Could not determine installation method. Expected a git repo or global npm install."
|
|
@@ -43145,10 +43413,10 @@ async function update2() {
|
|
|
43145
43413
|
}
|
|
43146
43414
|
|
|
43147
43415
|
// src/reportCliError.ts
|
|
43148
|
-
import
|
|
43416
|
+
import chalk240 from "chalk";
|
|
43149
43417
|
function reportCliError(error) {
|
|
43150
43418
|
if (error instanceof InvalidItemIdError || error instanceof AmbiguousRepoConfigError || error instanceof UnknownRepoConfigError || error instanceof MissingRunCwdError || error instanceof MiroExtractError) {
|
|
43151
|
-
console.error(
|
|
43419
|
+
console.error(chalk240.red(error.message));
|
|
43152
43420
|
} else {
|
|
43153
43421
|
console.error(error);
|
|
43154
43422
|
}
|