@staff0rd/assist 0.982.0 → 0.983.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/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.983.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -21423,19 +21423,27 @@ ${questionsJson}`
|
|
|
21423
21423
|
|
|
21424
21424
|
// src/commands/backlog/isDocsPath.ts
|
|
21425
21425
|
import { relative as relative6, resolve as resolve18 } from "path";
|
|
21426
|
-
var
|
|
21427
|
-
var
|
|
21426
|
+
var LOCKED_DOCS_DIRS = ["docs/src/content/docs/", "docs/public/screenshots/"];
|
|
21427
|
+
var DOCS_LOCK_REASON = `Docs pages and screenshots (${LOCKED_DOCS_DIRS.join(", ")}) are locked during development: they are updated by the Refresh docs backlog item after stories ship, not during development. Leave them untouched and carry on with the phase.`;
|
|
21428
|
+
var SEP = String.raw`[/\\]`;
|
|
21429
|
+
var LOCKED_DIR_PATTERN = String.raw`docs${SEP}(?:src${SEP}content${SEP}docs|public${SEP}screenshots)(?:${SEP}|(?![\w.-]))`;
|
|
21430
|
+
var RELATIVE_DOCS = new RegExp(
|
|
21431
|
+
String.raw`(?:^|[\s'"=(<>|;&:])(?:\.${SEP})?${LOCKED_DIR_PATTERN}`
|
|
21432
|
+
);
|
|
21428
21433
|
function escapeRegExp(value) {
|
|
21429
21434
|
return value.replace(/[.*+?^${}()|[\]\\]/g, String.raw`\$&`);
|
|
21430
21435
|
}
|
|
21436
|
+
function isLockedDocsRelativePath(rel) {
|
|
21437
|
+
const normalized = `${rel.replace(/\\/g, "/")}/`;
|
|
21438
|
+
return LOCKED_DOCS_DIRS.some((dir) => normalized.startsWith(dir));
|
|
21439
|
+
}
|
|
21431
21440
|
function isDocsPath(filePath, root2 = getProjectRoot()) {
|
|
21432
|
-
|
|
21433
|
-
return rel.startsWith("docs/");
|
|
21441
|
+
return isLockedDocsRelativePath(relative6(root2, resolve18(root2, filePath)));
|
|
21434
21442
|
}
|
|
21435
21443
|
function mentionsDocsPath(command, root2 = getProjectRoot()) {
|
|
21436
21444
|
if (RELATIVE_DOCS.test(command)) return true;
|
|
21437
|
-
const absolute2 = `${root2.replace(/\\/g, "/")}
|
|
21438
|
-
return new RegExp(
|
|
21445
|
+
const absolute2 = `${escapeRegExp(root2.replace(/\\/g, "/"))}/${LOCKED_DIR_PATTERN}`;
|
|
21446
|
+
return new RegExp(absolute2).test(command.replace(/\\/g, "/"));
|
|
21439
21447
|
}
|
|
21440
21448
|
|
|
21441
21449
|
// src/commands/cliHook/findDocsPathDeny.ts
|
|
@@ -22656,7 +22664,7 @@ function findStagedDocs() {
|
|
|
22656
22664
|
return execSync28("git diff --cached --name-only --relative", {
|
|
22657
22665
|
cwd: getProjectRoot(),
|
|
22658
22666
|
encoding: "utf8"
|
|
22659
|
-
}).split("\n").filter(
|
|
22667
|
+
}).split("\n").filter(isLockedDocsRelativePath);
|
|
22660
22668
|
}
|
|
22661
22669
|
async function refuseLockedDocs() {
|
|
22662
22670
|
const staged = findStagedDocs();
|
|
@@ -22666,7 +22674,7 @@ async function refuseLockedDocs() {
|
|
|
22666
22674
|
);
|
|
22667
22675
|
console.error(DOCS_LOCK_REASON);
|
|
22668
22676
|
console.error(
|
|
22669
|
-
|
|
22677
|
+
`Unstage them with \`git restore --staged ${staged.join(" ")}\`, then re-run the commit. Nothing was committed or pushed.`
|
|
22670
22678
|
);
|
|
22671
22679
|
process.exit(1);
|
|
22672
22680
|
}
|
|
@@ -35382,20 +35390,7 @@ function screenshot(processName) {
|
|
|
35382
35390
|
}
|
|
35383
35391
|
|
|
35384
35392
|
// src/commands/statusLine.ts
|
|
35385
|
-
import
|
|
35386
|
-
|
|
35387
|
-
// src/shared/contextLevel.ts
|
|
35388
|
-
var THRESHOLDS = {
|
|
35389
|
-
claude: { red: 30, yellow: 20 },
|
|
35390
|
-
codex: { red: 75, yellow: 50 },
|
|
35391
|
-
pi: { red: 30, yellow: 20 }
|
|
35392
|
-
};
|
|
35393
|
-
function contextLevel(pct, harness) {
|
|
35394
|
-
const { red, yellow } = THRESHOLDS[resolveHarness(harness)];
|
|
35395
|
-
if (pct >= red) return "red";
|
|
35396
|
-
if (pct >= yellow) return "yellow";
|
|
35397
|
-
return "dim";
|
|
35398
|
-
}
|
|
35393
|
+
import chalk223 from "chalk";
|
|
35399
35394
|
|
|
35400
35395
|
// src/commands/buildLimitsSegment.ts
|
|
35401
35396
|
import chalk221 from "chalk";
|
|
@@ -35533,11 +35528,23 @@ async function relayUsage(claudeSessionId, transcriptPath2, usedPct) {
|
|
|
35533
35528
|
}
|
|
35534
35529
|
}
|
|
35535
35530
|
|
|
35536
|
-
// src/commands/
|
|
35537
|
-
chalk222
|
|
35538
|
-
|
|
35539
|
-
|
|
35531
|
+
// src/commands/colorizePercent.ts
|
|
35532
|
+
import chalk222 from "chalk";
|
|
35533
|
+
|
|
35534
|
+
// src/shared/contextLevel.ts
|
|
35535
|
+
var THRESHOLDS = {
|
|
35536
|
+
claude: { red: 30, yellow: 20 },
|
|
35537
|
+
codex: { red: 75, yellow: 50 },
|
|
35538
|
+
pi: { red: 30, yellow: 20 }
|
|
35539
|
+
};
|
|
35540
|
+
function contextLevel(pct, harness) {
|
|
35541
|
+
const { red, yellow } = THRESHOLDS[resolveHarness(harness)];
|
|
35542
|
+
if (pct >= red) return "red";
|
|
35543
|
+
if (pct >= yellow) return "yellow";
|
|
35544
|
+
return "dim";
|
|
35540
35545
|
}
|
|
35546
|
+
|
|
35547
|
+
// src/commands/colorizePercent.ts
|
|
35541
35548
|
function colorizePercent(pct) {
|
|
35542
35549
|
const label = `${Math.round(pct)}%`;
|
|
35543
35550
|
switch (contextLevel(pct)) {
|
|
@@ -35549,6 +35556,12 @@ function colorizePercent(pct) {
|
|
|
35549
35556
|
return label;
|
|
35550
35557
|
}
|
|
35551
35558
|
}
|
|
35559
|
+
|
|
35560
|
+
// src/commands/statusLine.ts
|
|
35561
|
+
chalk223.level = 3;
|
|
35562
|
+
function formatNumber(num) {
|
|
35563
|
+
return num.toLocaleString("en-US");
|
|
35564
|
+
}
|
|
35552
35565
|
async function statusLine() {
|
|
35553
35566
|
const inputData = await readStdin();
|
|
35554
35567
|
const data = JSON.parse(inputData);
|
|
@@ -35557,9 +35570,10 @@ async function statusLine() {
|
|
|
35557
35570
|
const usedPct = data.context_window.used_percentage ?? 0;
|
|
35558
35571
|
const dir = data.workspace?.current_dir ?? data.cwd;
|
|
35559
35572
|
const branch2 = dir ? readGitBranch(dir) : null;
|
|
35560
|
-
const branchSegment = branch2 ? `\u{1F33F}\uFE0F ${
|
|
35573
|
+
const branchSegment = branch2 ? `\u{1F33F}\uFE0F ${chalk223.cyan(branch2)} | ` : "";
|
|
35574
|
+
const limitsSegment = process.env.ASSIST_SESSION === "1" ? "" : buildLimitsSegment(data.rate_limits);
|
|
35561
35575
|
console.log(
|
|
35562
|
-
`${branchSegment}${model} | Tokens - ${formatNumber(totalIn)} \u2191 : ${formatNumber(totalOut)} \u2193 | Context - ${colorizePercent(usedPct)}${
|
|
35576
|
+
`${branchSegment}${model} | Tokens - ${formatNumber(totalIn)} \u2191 : ${formatNumber(totalOut)} \u2193 | Context - ${colorizePercent(usedPct)}${limitsSegment}`
|
|
35563
35577
|
);
|
|
35564
35578
|
await relayRateLimits(data.rate_limits);
|
|
35565
35579
|
await relayUsage(
|
|
@@ -35664,7 +35678,7 @@ import { spawn as spawn7 } from "child_process";
|
|
|
35664
35678
|
import * as path48 from "path";
|
|
35665
35679
|
|
|
35666
35680
|
// src/commands/refactor/logViolations.ts
|
|
35667
|
-
import
|
|
35681
|
+
import chalk224 from "chalk";
|
|
35668
35682
|
var DEFAULT_MAX_LINES2 = 100;
|
|
35669
35683
|
function logViolations(violations, maxLines = DEFAULT_MAX_LINES2) {
|
|
35670
35684
|
if (violations.length === 0) {
|
|
@@ -35673,43 +35687,43 @@ function logViolations(violations, maxLines = DEFAULT_MAX_LINES2) {
|
|
|
35673
35687
|
}
|
|
35674
35688
|
return;
|
|
35675
35689
|
}
|
|
35676
|
-
console.error(
|
|
35690
|
+
console.error(chalk224.red(`
|
|
35677
35691
|
Refactor check failed:
|
|
35678
35692
|
`));
|
|
35679
|
-
console.error(
|
|
35693
|
+
console.error(chalk224.red(` The following files exceed ${maxLines} lines:
|
|
35680
35694
|
`));
|
|
35681
35695
|
for (const violation of violations) {
|
|
35682
|
-
console.error(
|
|
35696
|
+
console.error(chalk224.red(` ${violation.file} (${violation.lines} lines)`));
|
|
35683
35697
|
}
|
|
35684
35698
|
console.error(
|
|
35685
|
-
|
|
35699
|
+
chalk224.yellow(
|
|
35686
35700
|
`
|
|
35687
35701
|
Each file needs to be sensibly refactored, or if there is no sensible
|
|
35688
35702
|
way to refactor it, ignore it with:
|
|
35689
35703
|
`
|
|
35690
35704
|
)
|
|
35691
35705
|
);
|
|
35692
|
-
console.error(
|
|
35706
|
+
console.error(chalk224.gray(` assist refactor ignore <file>
|
|
35693
35707
|
`));
|
|
35694
35708
|
if (process.env.CLAUDECODE) {
|
|
35695
|
-
console.error(
|
|
35709
|
+
console.error(chalk224.cyan(`
|
|
35696
35710
|
## Extracting Code to New Files
|
|
35697
35711
|
`));
|
|
35698
35712
|
console.error(
|
|
35699
|
-
|
|
35713
|
+
chalk224.cyan(
|
|
35700
35714
|
` When extracting logic from one file to another, consider where the extracted code belongs:
|
|
35701
35715
|
`
|
|
35702
35716
|
)
|
|
35703
35717
|
);
|
|
35704
35718
|
console.error(
|
|
35705
|
-
|
|
35719
|
+
chalk224.cyan(
|
|
35706
35720
|
` 1. Keep related logic together: If the extracted code is tightly coupled to the
|
|
35707
35721
|
original file's domain, create a new folder containing both the original and extracted files.
|
|
35708
35722
|
`
|
|
35709
35723
|
)
|
|
35710
35724
|
);
|
|
35711
35725
|
console.error(
|
|
35712
|
-
|
|
35726
|
+
chalk224.cyan(
|
|
35713
35727
|
` 2. Share common utilities: If the extracted code can be reused across multiple
|
|
35714
35728
|
domains, move it to a common/shared folder.
|
|
35715
35729
|
`
|
|
@@ -35865,7 +35879,7 @@ async function check(pattern2, options2) {
|
|
|
35865
35879
|
|
|
35866
35880
|
// src/commands/refactor/extract.ts
|
|
35867
35881
|
import path56 from "path";
|
|
35868
|
-
import
|
|
35882
|
+
import chalk227 from "chalk";
|
|
35869
35883
|
|
|
35870
35884
|
// src/commands/refactor/extract/applyExtraction.ts
|
|
35871
35885
|
import { SyntaxKind as SyntaxKind8 } from "ts-morph";
|
|
@@ -36473,23 +36487,23 @@ function buildPlan2(functionName, sourceFile, sourcePath, destPath, project) {
|
|
|
36473
36487
|
|
|
36474
36488
|
// src/commands/refactor/extract/displayPlan.ts
|
|
36475
36489
|
import path52 from "path";
|
|
36476
|
-
import
|
|
36490
|
+
import chalk225 from "chalk";
|
|
36477
36491
|
function section(title) {
|
|
36478
36492
|
return `
|
|
36479
|
-
${
|
|
36493
|
+
${chalk225.cyan(title)}`;
|
|
36480
36494
|
}
|
|
36481
36495
|
function displayImporters(plan2, cwd) {
|
|
36482
36496
|
if (plan2.importersToUpdate.length === 0) return;
|
|
36483
36497
|
console.log(section("Update importers:"));
|
|
36484
36498
|
for (const imp of plan2.importersToUpdate) {
|
|
36485
36499
|
const rel = path52.relative(cwd, imp.file.getFilePath());
|
|
36486
|
-
console.log(` ${
|
|
36500
|
+
console.log(` ${chalk225.dim(rel)}: \u2192 import from "${imp.relPath}"`);
|
|
36487
36501
|
}
|
|
36488
36502
|
}
|
|
36489
36503
|
function displayPlan(functionName, relDest, plan2, cwd) {
|
|
36490
|
-
console.log(
|
|
36504
|
+
console.log(chalk225.bold(`Extract: ${functionName} \u2192 ${relDest}
|
|
36491
36505
|
`));
|
|
36492
|
-
console.log(` ${
|
|
36506
|
+
console.log(` ${chalk225.cyan("Functions to move:")}`);
|
|
36493
36507
|
for (const name of plan2.extractedNames) {
|
|
36494
36508
|
console.log(` ${name}`);
|
|
36495
36509
|
}
|
|
@@ -36523,7 +36537,7 @@ function displayPlan(functionName, relDest, plan2, cwd) {
|
|
|
36523
36537
|
|
|
36524
36538
|
// src/commands/refactor/extract/loadProjectFile.ts
|
|
36525
36539
|
import path55 from "path";
|
|
36526
|
-
import
|
|
36540
|
+
import chalk226 from "chalk";
|
|
36527
36541
|
import { Project as Project4 } from "ts-morph";
|
|
36528
36542
|
|
|
36529
36543
|
// src/commands/refactor/extract/findTsConfig.ts
|
|
@@ -36615,7 +36629,7 @@ function loadProjectFile(file) {
|
|
|
36615
36629
|
});
|
|
36616
36630
|
const sourceFile = project.getSourceFile(sourcePath);
|
|
36617
36631
|
if (!sourceFile) {
|
|
36618
|
-
console.log(
|
|
36632
|
+
console.log(chalk226.red(`File not found in project: ${file}`));
|
|
36619
36633
|
process.exit(1);
|
|
36620
36634
|
}
|
|
36621
36635
|
return { project, sourceFile };
|
|
@@ -36638,19 +36652,19 @@ async function extract(file, functionName, destination, options2 = {}) {
|
|
|
36638
36652
|
displayPlan(functionName, relDest, plan2, cwd);
|
|
36639
36653
|
if (options2.apply) {
|
|
36640
36654
|
await applyExtraction(functionName, sourceFile, destPath, plan2, project);
|
|
36641
|
-
console.log(
|
|
36655
|
+
console.log(chalk227.green("\nExtraction complete"));
|
|
36642
36656
|
} else {
|
|
36643
|
-
console.log(
|
|
36657
|
+
console.log(chalk227.dim("\nDry run. Use --apply to execute."));
|
|
36644
36658
|
}
|
|
36645
36659
|
}
|
|
36646
36660
|
|
|
36647
36661
|
// src/commands/refactor/ignore.ts
|
|
36648
36662
|
import fs33 from "fs";
|
|
36649
|
-
import
|
|
36663
|
+
import chalk228 from "chalk";
|
|
36650
36664
|
var REFACTOR_YML_PATH2 = "refactor.yml";
|
|
36651
36665
|
function ignore2(file) {
|
|
36652
36666
|
if (!fs33.existsSync(file)) {
|
|
36653
|
-
console.error(
|
|
36667
|
+
console.error(chalk228.red(`Error: File does not exist: ${file}`));
|
|
36654
36668
|
process.exit(1);
|
|
36655
36669
|
}
|
|
36656
36670
|
const content = fs33.readFileSync(file, "utf8");
|
|
@@ -36666,7 +36680,7 @@ function ignore2(file) {
|
|
|
36666
36680
|
fs33.writeFileSync(REFACTOR_YML_PATH2, entry);
|
|
36667
36681
|
}
|
|
36668
36682
|
console.log(
|
|
36669
|
-
|
|
36683
|
+
chalk228.green(
|
|
36670
36684
|
`Added ${file} to refactor ignore list (max ${maxLines} lines)`
|
|
36671
36685
|
)
|
|
36672
36686
|
);
|
|
@@ -36675,12 +36689,12 @@ function ignore2(file) {
|
|
|
36675
36689
|
// src/commands/refactor/rename.ts
|
|
36676
36690
|
import fs36 from "fs";
|
|
36677
36691
|
import path62 from "path";
|
|
36678
|
-
import
|
|
36692
|
+
import chalk231 from "chalk";
|
|
36679
36693
|
|
|
36680
36694
|
// src/commands/refactor/rename/applyRename.ts
|
|
36681
36695
|
import fs35 from "fs";
|
|
36682
36696
|
import path58 from "path";
|
|
36683
|
-
import
|
|
36697
|
+
import chalk229 from "chalk";
|
|
36684
36698
|
|
|
36685
36699
|
// src/commands/refactor/restructure/computeRewrites.ts
|
|
36686
36700
|
import path57 from "path";
|
|
@@ -36786,13 +36800,13 @@ function applyRename(rewrites, sourcePath, destPath, cwd) {
|
|
|
36786
36800
|
const updatedContents = applyRewrites(rewrites);
|
|
36787
36801
|
for (const [file, content] of updatedContents) {
|
|
36788
36802
|
fs35.writeFileSync(file, content, "utf8");
|
|
36789
|
-
console.log(
|
|
36803
|
+
console.log(chalk229.cyan(` Updated imports in ${path58.relative(cwd, file)}`));
|
|
36790
36804
|
}
|
|
36791
36805
|
const destDir = path58.dirname(destPath);
|
|
36792
36806
|
if (!fs35.existsSync(destDir)) fs35.mkdirSync(destDir, { recursive: true });
|
|
36793
36807
|
fs35.renameSync(sourcePath, destPath);
|
|
36794
36808
|
console.log(
|
|
36795
|
-
|
|
36809
|
+
chalk229.white(
|
|
36796
36810
|
` Moved ${path58.relative(cwd, sourcePath)} \u2192 ${path58.relative(cwd, destPath)}`
|
|
36797
36811
|
)
|
|
36798
36812
|
);
|
|
@@ -36942,16 +36956,16 @@ function computeRenameRewrites(sourcePath, destPath) {
|
|
|
36942
36956
|
|
|
36943
36957
|
// src/commands/refactor/rename/printRenamePreview.ts
|
|
36944
36958
|
import path61 from "path";
|
|
36945
|
-
import
|
|
36959
|
+
import chalk230 from "chalk";
|
|
36946
36960
|
function printRenamePreview(rewrites, cwd) {
|
|
36947
36961
|
for (const rewrite of rewrites) {
|
|
36948
36962
|
console.log(
|
|
36949
|
-
|
|
36963
|
+
chalk230.dim(
|
|
36950
36964
|
` ${path61.relative(cwd, rewrite.file)}: ${rewrite.oldSpecifier} \u2192 ${rewrite.newSpecifier}`
|
|
36951
36965
|
)
|
|
36952
36966
|
);
|
|
36953
36967
|
}
|
|
36954
|
-
console.log(
|
|
36968
|
+
console.log(chalk230.dim("Dry run. Use --apply to execute."));
|
|
36955
36969
|
}
|
|
36956
36970
|
|
|
36957
36971
|
// src/commands/refactor/rename.ts
|
|
@@ -36962,20 +36976,20 @@ async function rename(source, destination, options2 = {}) {
|
|
|
36962
36976
|
const relSource = path62.relative(cwd, sourcePath);
|
|
36963
36977
|
const relDest = path62.relative(cwd, destPath);
|
|
36964
36978
|
if (!fs36.existsSync(sourcePath)) {
|
|
36965
|
-
console.log(
|
|
36979
|
+
console.log(chalk231.red(`File not found: ${source}`));
|
|
36966
36980
|
process.exit(1);
|
|
36967
36981
|
}
|
|
36968
36982
|
if (destPath !== sourcePath && fs36.existsSync(destPath)) {
|
|
36969
|
-
console.log(
|
|
36983
|
+
console.log(chalk231.red(`Destination already exists: ${destination}`));
|
|
36970
36984
|
process.exit(1);
|
|
36971
36985
|
}
|
|
36972
|
-
console.log(
|
|
36973
|
-
console.log(
|
|
36974
|
-
console.log(
|
|
36986
|
+
console.log(chalk231.bold(`Rename: ${relSource} \u2192 ${relDest}`));
|
|
36987
|
+
console.log(chalk231.dim("Loading project..."));
|
|
36988
|
+
console.log(chalk231.dim("Scanning imports across the project..."));
|
|
36975
36989
|
const rewrites = computeRenameRewrites(sourcePath, destPath);
|
|
36976
36990
|
const affectedFiles = new Set(rewrites.map((r) => r.file)).size;
|
|
36977
36991
|
console.log(
|
|
36978
|
-
|
|
36992
|
+
chalk231.dim(
|
|
36979
36993
|
`${rewrites.length} import path(s) to update across ${affectedFiles} file(s)`
|
|
36980
36994
|
)
|
|
36981
36995
|
);
|
|
@@ -36984,11 +36998,11 @@ async function rename(source, destination, options2 = {}) {
|
|
|
36984
36998
|
return;
|
|
36985
36999
|
}
|
|
36986
37000
|
applyRename(rewrites, sourcePath, destPath, cwd);
|
|
36987
|
-
console.log(
|
|
37001
|
+
console.log(chalk231.green("Done"));
|
|
36988
37002
|
}
|
|
36989
37003
|
|
|
36990
37004
|
// src/commands/refactor/renameSymbol.ts
|
|
36991
|
-
import
|
|
37005
|
+
import chalk232 from "chalk";
|
|
36992
37006
|
|
|
36993
37007
|
// src/commands/refactor/renameSymbol/findSymbol.ts
|
|
36994
37008
|
import { SyntaxKind as SyntaxKind19 } from "ts-morph";
|
|
@@ -37034,34 +37048,34 @@ async function renameSymbol(file, oldName, newName, options2 = {}) {
|
|
|
37034
37048
|
const { project, sourceFile } = loadProjectFile(file);
|
|
37035
37049
|
const symbol = findSymbol(sourceFile, oldName);
|
|
37036
37050
|
if (!symbol) {
|
|
37037
|
-
console.log(
|
|
37051
|
+
console.log(chalk232.red(`Symbol "${oldName}" not found in ${file}`));
|
|
37038
37052
|
process.exit(1);
|
|
37039
37053
|
}
|
|
37040
37054
|
const grouped = groupReferences(symbol, cwd);
|
|
37041
37055
|
const totalRefs = [...grouped.values()].reduce((s, l) => s + l.length, 0);
|
|
37042
37056
|
console.log(
|
|
37043
|
-
|
|
37057
|
+
chalk232.bold(`Rename: ${oldName} \u2192 ${newName} (${totalRefs} references)
|
|
37044
37058
|
`)
|
|
37045
37059
|
);
|
|
37046
37060
|
for (const [refFile, lines2] of grouped) {
|
|
37047
37061
|
console.log(
|
|
37048
|
-
` ${
|
|
37062
|
+
` ${chalk232.dim(refFile)}: lines ${chalk232.cyan(lines2.join(", "))}`
|
|
37049
37063
|
);
|
|
37050
37064
|
}
|
|
37051
37065
|
if (options2.apply) {
|
|
37052
37066
|
symbol.rename(newName);
|
|
37053
37067
|
await project.save();
|
|
37054
|
-
console.log(
|
|
37068
|
+
console.log(chalk232.green(`
|
|
37055
37069
|
Renamed ${oldName} \u2192 ${newName}`));
|
|
37056
37070
|
} else {
|
|
37057
|
-
console.log(
|
|
37071
|
+
console.log(chalk232.dim("\nDry run. Use --apply to execute."));
|
|
37058
37072
|
}
|
|
37059
37073
|
}
|
|
37060
37074
|
|
|
37061
37075
|
// src/commands/refactor/restructure.ts
|
|
37062
37076
|
import fs38 from "fs";
|
|
37063
37077
|
import path83 from "path";
|
|
37064
|
-
import
|
|
37078
|
+
import chalk242 from "chalk";
|
|
37065
37079
|
|
|
37066
37080
|
// src/commands/refactor/restructure/buildPlan.ts
|
|
37067
37081
|
import path73 from "path";
|
|
@@ -37398,7 +37412,7 @@ function buildPlan3(scopeRoot, files, ignored = [], pinnedModules = []) {
|
|
|
37398
37412
|
}
|
|
37399
37413
|
|
|
37400
37414
|
// src/commands/refactor/restructure/checkPlan.ts
|
|
37401
|
-
import
|
|
37415
|
+
import chalk237 from "chalk";
|
|
37402
37416
|
|
|
37403
37417
|
// src/commands/refactor/restructure/applyCommand.ts
|
|
37404
37418
|
import path74 from "path";
|
|
@@ -37409,13 +37423,13 @@ function applyCommand(scopeRoot) {
|
|
|
37409
37423
|
|
|
37410
37424
|
// src/commands/refactor/restructure/displayDrift.ts
|
|
37411
37425
|
import path75 from "path";
|
|
37412
|
-
import
|
|
37426
|
+
import chalk233 from "chalk";
|
|
37413
37427
|
var shownMoves = 20;
|
|
37414
37428
|
function displayDrift(plan2, listMoves) {
|
|
37415
37429
|
const rel = (file) => path75.relative(process.cwd(), file);
|
|
37416
37430
|
if (plan2.moves.length > 0) {
|
|
37417
37431
|
console.log(
|
|
37418
|
-
|
|
37432
|
+
chalk233.red(
|
|
37419
37433
|
`${plan2.moves.length} file(s) drift from the plan${listMoves ? ":" : "."}`
|
|
37420
37434
|
)
|
|
37421
37435
|
);
|
|
@@ -37423,17 +37437,17 @@ function displayDrift(plan2, listMoves) {
|
|
|
37423
37437
|
for (const move2 of plan2.moves.slice(0, shownMoves))
|
|
37424
37438
|
console.log(` ${rel(move2.from)} \u2192 ${rel(move2.to)}`);
|
|
37425
37439
|
if (plan2.moves.length > shownMoves)
|
|
37426
|
-
console.log(
|
|
37440
|
+
console.log(chalk233.dim(` \u2026and ${plan2.moves.length - shownMoves} more`));
|
|
37427
37441
|
}
|
|
37428
37442
|
}
|
|
37429
|
-
for (const error of plan2.errors) console.log(
|
|
37443
|
+
for (const error of plan2.errors) console.log(chalk233.red(error));
|
|
37430
37444
|
}
|
|
37431
37445
|
|
|
37432
37446
|
// src/commands/refactor/restructure/displayLayoutLimits.ts
|
|
37433
|
-
import
|
|
37447
|
+
import chalk236 from "chalk";
|
|
37434
37448
|
|
|
37435
37449
|
// src/commands/refactor/restructure/displayDeepChains.ts
|
|
37436
|
-
import
|
|
37450
|
+
import chalk234 from "chalk";
|
|
37437
37451
|
var shownChains = 10;
|
|
37438
37452
|
function formatChain(chain2) {
|
|
37439
37453
|
const folders = chain2.folders.map((f) => `${f.name} (${f.files})`).join(" > ");
|
|
@@ -37443,28 +37457,28 @@ function displayDeepChains(chains, maxDepth) {
|
|
|
37443
37457
|
if (chains.length === 0) return;
|
|
37444
37458
|
const tooDeep = chains.reduce((sum3, c) => sum3 + c.tooDeep, 0);
|
|
37445
37459
|
console.log(
|
|
37446
|
-
|
|
37460
|
+
chalk234.red(
|
|
37447
37461
|
`
|
|
37448
37462
|
Plan exceeds restructure.maxDepth ${maxDepth}: ${tooDeep} file(s) deeper.`
|
|
37449
37463
|
)
|
|
37450
37464
|
);
|
|
37451
37465
|
console.log(
|
|
37452
|
-
|
|
37466
|
+
chalk234.bold(
|
|
37453
37467
|
"Deep chains, as folder (files beneath), most files too deep first:"
|
|
37454
37468
|
)
|
|
37455
37469
|
);
|
|
37456
37470
|
for (const chain2 of chains.slice(0, shownChains))
|
|
37457
37471
|
console.log(formatChain(chain2));
|
|
37458
37472
|
if (chains.length > shownChains)
|
|
37459
|
-
console.log(
|
|
37473
|
+
console.log(chalk234.dim(` \u2026and ${chains.length - shownChains} more`));
|
|
37460
37474
|
}
|
|
37461
37475
|
|
|
37462
37476
|
// src/commands/refactor/restructure/displayLongPaths.ts
|
|
37463
|
-
import
|
|
37477
|
+
import chalk235 from "chalk";
|
|
37464
37478
|
function displayLongPaths(longPaths, maxPathLength) {
|
|
37465
37479
|
if (longPaths.length === 0) return;
|
|
37466
37480
|
console.log(
|
|
37467
|
-
|
|
37481
|
+
chalk235.red(
|
|
37468
37482
|
`
|
|
37469
37483
|
Plan exceeds restructure.maxPathLength ${maxPathLength}: ${longPaths.length} repo-relative path(s) longer.`
|
|
37470
37484
|
)
|
|
@@ -37492,7 +37506,7 @@ function displayLayoutLimits(limits, apply) {
|
|
|
37492
37506
|
displayDeepChains(limits.chains, limits.maxDepth);
|
|
37493
37507
|
displayLongPaths(limits.longPaths, limits.maxPathLength);
|
|
37494
37508
|
console.log("");
|
|
37495
|
-
for (const line of pinSteps(apply)) console.log(
|
|
37509
|
+
for (const line of pinSteps(apply)) console.log(chalk236.yellow(line));
|
|
37496
37510
|
}
|
|
37497
37511
|
|
|
37498
37512
|
// src/commands/refactor/restructure/checkPlan.ts
|
|
@@ -37504,14 +37518,14 @@ function checkPlan(plan2, limits) {
|
|
|
37504
37518
|
if (exceeds || plan2.errors.length > 0) process.exit(1);
|
|
37505
37519
|
if (plan2.moves.length > 0) {
|
|
37506
37520
|
console.log(
|
|
37507
|
-
|
|
37521
|
+
chalk237.yellow(
|
|
37508
37522
|
`
|
|
37509
37523
|
Run \`${apply}\` to move the files and rewrite their imports.`
|
|
37510
37524
|
)
|
|
37511
37525
|
);
|
|
37512
37526
|
process.exit(1);
|
|
37513
37527
|
}
|
|
37514
|
-
console.log(
|
|
37528
|
+
console.log(chalk237.green("Layout matches the restructure plan"));
|
|
37515
37529
|
}
|
|
37516
37530
|
|
|
37517
37531
|
// src/commands/refactor/restructure/findDeepChains.ts
|
|
@@ -37581,15 +37595,15 @@ function partitionIgnored(files) {
|
|
|
37581
37595
|
}
|
|
37582
37596
|
|
|
37583
37597
|
// src/commands/refactor/restructure/runPlan.ts
|
|
37584
|
-
import
|
|
37598
|
+
import chalk241 from "chalk";
|
|
37585
37599
|
|
|
37586
37600
|
// src/commands/refactor/restructure/applyPlan.ts
|
|
37587
|
-
import
|
|
37601
|
+
import chalk239 from "chalk";
|
|
37588
37602
|
|
|
37589
37603
|
// src/commands/refactor/restructure/executePlan.ts
|
|
37590
37604
|
import fs37 from "fs";
|
|
37591
37605
|
import path79 from "path";
|
|
37592
|
-
import
|
|
37606
|
+
import chalk238 from "chalk";
|
|
37593
37607
|
function relPath(file) {
|
|
37594
37608
|
return path79.relative(process.cwd(), file);
|
|
37595
37609
|
}
|
|
@@ -37606,14 +37620,14 @@ function moveFiles(moves) {
|
|
|
37606
37620
|
fs37.mkdirSync(path79.dirname(move2.to), { recursive: true });
|
|
37607
37621
|
fs37.renameSync(staging, move2.to);
|
|
37608
37622
|
console.log(
|
|
37609
|
-
|
|
37623
|
+
chalk238.white(` Moved ${relPath(move2.from)} \u2192 ${relPath(move2.to)}`)
|
|
37610
37624
|
);
|
|
37611
37625
|
}
|
|
37612
37626
|
}
|
|
37613
37627
|
function removeIfEmpty(dir) {
|
|
37614
37628
|
if (!fs37.existsSync(dir) || fs37.readdirSync(dir).length > 0) return false;
|
|
37615
37629
|
fs37.rmdirSync(dir);
|
|
37616
|
-
console.log(
|
|
37630
|
+
console.log(chalk238.dim(` Removed empty directory ${relPath(dir)}`));
|
|
37617
37631
|
return true;
|
|
37618
37632
|
}
|
|
37619
37633
|
function removeEmptyDirectories(dirs, scopeRoot) {
|
|
@@ -37626,7 +37640,7 @@ function removeEmptyDirectories(dirs, scopeRoot) {
|
|
|
37626
37640
|
function executePlan(plan2) {
|
|
37627
37641
|
for (const [file, content] of applyRewrites(plan2.rewrites)) {
|
|
37628
37642
|
fs37.writeFileSync(file, content, "utf8");
|
|
37629
|
-
console.log(
|
|
37643
|
+
console.log(chalk238.cyan(` Rewrote imports in ${relPath(file)}`));
|
|
37630
37644
|
}
|
|
37631
37645
|
moveFiles(plan2.moves);
|
|
37632
37646
|
removeEmptyDirectories(
|
|
@@ -37638,17 +37652,17 @@ function executePlan(plan2) {
|
|
|
37638
37652
|
// src/commands/refactor/restructure/applyPlan.ts
|
|
37639
37653
|
function applyPlan(plan2) {
|
|
37640
37654
|
if (plan2.errors.length > 0) {
|
|
37641
|
-
console.log(
|
|
37655
|
+
console.log(chalk239.red("\nResolve the errors above before applying."));
|
|
37642
37656
|
process.exit(1);
|
|
37643
37657
|
}
|
|
37644
|
-
console.log(
|
|
37658
|
+
console.log(chalk239.bold("\nApplying changes..."));
|
|
37645
37659
|
executePlan(plan2);
|
|
37646
|
-
console.log(
|
|
37660
|
+
console.log(chalk239.green("\nRestructuring complete"));
|
|
37647
37661
|
}
|
|
37648
37662
|
|
|
37649
37663
|
// src/commands/refactor/restructure/displayPlan.ts
|
|
37650
37664
|
import path82 from "path";
|
|
37651
|
-
import
|
|
37665
|
+
import chalk240 from "chalk";
|
|
37652
37666
|
|
|
37653
37667
|
// src/commands/refactor/restructure/computeDepthStats.ts
|
|
37654
37668
|
import path80 from "path";
|
|
@@ -37699,17 +37713,17 @@ function relPath2(filePath) {
|
|
|
37699
37713
|
}
|
|
37700
37714
|
function displayMoves(plan2) {
|
|
37701
37715
|
if (plan2.moves.length === 0) return;
|
|
37702
|
-
console.log(
|
|
37716
|
+
console.log(chalk240.bold("\nFile moves:"));
|
|
37703
37717
|
for (const move2 of plan2.moves) {
|
|
37704
37718
|
console.log(
|
|
37705
|
-
` ${
|
|
37719
|
+
` ${chalk240.red(relPath2(move2.from))} \u2192 ${chalk240.green(relPath2(move2.to))}`
|
|
37706
37720
|
);
|
|
37707
|
-
console.log(
|
|
37721
|
+
console.log(chalk240.dim(` ${move2.reason}`));
|
|
37708
37722
|
}
|
|
37709
37723
|
}
|
|
37710
37724
|
function displayTree(plan2) {
|
|
37711
37725
|
console.log(
|
|
37712
|
-
|
|
37726
|
+
chalk240.bold(`
|
|
37713
37727
|
Resulting tree (${relPath2(plan2.scopeRoot) || "."}/):`)
|
|
37714
37728
|
);
|
|
37715
37729
|
for (const line of formatTree(plan2.targets.values(), plan2.scopeRoot))
|
|
@@ -37720,15 +37734,15 @@ function displayDepthStats(plan2) {
|
|
|
37720
37734
|
plan2.targets.values(),
|
|
37721
37735
|
plan2.scopeRoot
|
|
37722
37736
|
);
|
|
37723
|
-
console.log(
|
|
37737
|
+
console.log(chalk240.bold(`
|
|
37724
37738
|
Depth (max ${max}):`));
|
|
37725
37739
|
for (const depth of [...distribution.keys()].sort((a, b) => a - b))
|
|
37726
37740
|
console.log(` ${depth}: ${distribution.get(depth)} file(s)`);
|
|
37727
37741
|
}
|
|
37728
37742
|
function displayErrors(errors) {
|
|
37729
37743
|
if (errors.length === 0) return;
|
|
37730
|
-
console.log(
|
|
37731
|
-
for (const error of errors) console.log(
|
|
37744
|
+
console.log(chalk240.red("\nErrors:"));
|
|
37745
|
+
for (const error of errors) console.log(chalk240.red(` ${error}`));
|
|
37732
37746
|
}
|
|
37733
37747
|
function displayPlan2(plan2) {
|
|
37734
37748
|
displayMoves(plan2);
|
|
@@ -37737,7 +37751,7 @@ function displayPlan2(plan2) {
|
|
|
37737
37751
|
displayErrors(plan2.errors);
|
|
37738
37752
|
const rewrittenFiles = new Set(plan2.rewrites.map((r) => r.file)).size;
|
|
37739
37753
|
console.log(
|
|
37740
|
-
|
|
37754
|
+
chalk240.dim(
|
|
37741
37755
|
`
|
|
37742
37756
|
Summary: ${plan2.moves.length} file(s) moved, ${plan2.rewrites.length} imports rewritten across ${rewrittenFiles} file(s), ${plan2.errors.length} error(s)`
|
|
37743
37757
|
)
|
|
@@ -37749,11 +37763,11 @@ function runPlan(plan2, limits, apply) {
|
|
|
37749
37763
|
displayPlan2(plan2);
|
|
37750
37764
|
displayLayoutLimits(limits, applyCommand(plan2.scopeRoot));
|
|
37751
37765
|
if (plan2.moves.length === 0 && plan2.errors.length === 0) {
|
|
37752
|
-
console.log(
|
|
37766
|
+
console.log(chalk241.green("No restructuring needed"));
|
|
37753
37767
|
return;
|
|
37754
37768
|
}
|
|
37755
37769
|
if (!apply) {
|
|
37756
|
-
console.log(
|
|
37770
|
+
console.log(chalk241.dim("\nDry run. Use --apply to execute."));
|
|
37757
37771
|
return;
|
|
37758
37772
|
}
|
|
37759
37773
|
applyPlan(plan2);
|
|
@@ -37763,14 +37777,14 @@ function runPlan(plan2, limits, apply) {
|
|
|
37763
37777
|
async function restructure(root2, options2 = {}) {
|
|
37764
37778
|
const scopeRoot = path83.resolve(root2 ?? "src");
|
|
37765
37779
|
if (!fs38.existsSync(scopeRoot) || !fs38.statSync(scopeRoot).isDirectory()) {
|
|
37766
|
-
console.log(
|
|
37780
|
+
console.log(chalk242.red(`Not a directory: ${root2 ?? "src"}`));
|
|
37767
37781
|
process.exit(1);
|
|
37768
37782
|
}
|
|
37769
37783
|
const found = [];
|
|
37770
37784
|
walkSourceFiles(scopeRoot, found);
|
|
37771
37785
|
const { scoped, ignored } = partitionIgnored(found);
|
|
37772
37786
|
if (scoped.length === 0) {
|
|
37773
|
-
console.log(
|
|
37787
|
+
console.log(chalk242.yellow("No files found under root"));
|
|
37774
37788
|
return;
|
|
37775
37789
|
}
|
|
37776
37790
|
const {
|
|
@@ -37841,7 +37855,7 @@ async function checkoutPrSession(number, prompt = "") {
|
|
|
37841
37855
|
}
|
|
37842
37856
|
|
|
37843
37857
|
// src/commands/review/highLevel/configureHighLevelReview.ts
|
|
37844
|
-
import
|
|
37858
|
+
import chalk246 from "chalk";
|
|
37845
37859
|
|
|
37846
37860
|
// src/commands/config/promptConfigScope.ts
|
|
37847
37861
|
import Enquirer3 from "enquirer";
|
|
@@ -37867,7 +37881,7 @@ async function promptConfigScope() {
|
|
|
37867
37881
|
}
|
|
37868
37882
|
|
|
37869
37883
|
// src/commands/config/resolveConfigKeyAnswer.ts
|
|
37870
|
-
import
|
|
37884
|
+
import chalk243 from "chalk";
|
|
37871
37885
|
async function resolveConfigKeyAnswer(question, supplied) {
|
|
37872
37886
|
if (supplied !== void 0) return coerceSupplied(question.key, supplied);
|
|
37873
37887
|
for (; ; ) {
|
|
@@ -37875,7 +37889,7 @@ async function resolveConfigKeyAnswer(question, supplied) {
|
|
|
37875
37889
|
if (answer === "") return void 0;
|
|
37876
37890
|
const coercion = coerceCliConfigValue(question.key, answer);
|
|
37877
37891
|
if (coercion.ok) return coercion.value;
|
|
37878
|
-
console.error(
|
|
37892
|
+
console.error(chalk243.red(coercion.error));
|
|
37879
37893
|
}
|
|
37880
37894
|
}
|
|
37881
37895
|
function coerceSupplied(key, supplied) {
|
|
@@ -37955,7 +37969,7 @@ function suggestGlobs(current, proposed) {
|
|
|
37955
37969
|
}
|
|
37956
37970
|
|
|
37957
37971
|
// src/commands/review/highLevel/parseConfigureAnswers.ts
|
|
37958
|
-
import
|
|
37972
|
+
import chalk244 from "chalk";
|
|
37959
37973
|
function parseConfigureAnswers(answers) {
|
|
37960
37974
|
const known = Object.values(highLevelConfigKeys);
|
|
37961
37975
|
const parsed = {};
|
|
@@ -37973,13 +37987,13 @@ function answersCoverEveryKey(answers) {
|
|
|
37973
37987
|
return Object.values(highLevelConfigKeys).every((key) => key in answers);
|
|
37974
37988
|
}
|
|
37975
37989
|
function exitWith(message3) {
|
|
37976
|
-
console.error(
|
|
37990
|
+
console.error(chalk244.red(`Error: ${message3}.`));
|
|
37977
37991
|
process.exit(1);
|
|
37978
37992
|
}
|
|
37979
37993
|
|
|
37980
37994
|
// src/commands/review/highLevel/proposeHighLevelGlobs.ts
|
|
37981
37995
|
import { execFileSync as execFileSync27 } from "child_process";
|
|
37982
|
-
import
|
|
37996
|
+
import chalk245 from "chalk";
|
|
37983
37997
|
|
|
37984
37998
|
// src/commands/review/highLevel/buildGlobProposalPrompt.ts
|
|
37985
37999
|
function buildGlobProposalPrompt(tree) {
|
|
@@ -38073,12 +38087,12 @@ function proposeHighLevelGlobs(cwd = process.cwd()) {
|
|
|
38073
38087
|
const tree = summariseRepoTree(cwd);
|
|
38074
38088
|
if (tree === "") return NOTHING_PROPOSED;
|
|
38075
38089
|
console.log(
|
|
38076
|
-
|
|
38090
|
+
chalk245.dim("Asking Claude to propose globs from the repo's own tree...")
|
|
38077
38091
|
);
|
|
38078
38092
|
const output = askClaude(buildGlobProposalPrompt(tree), cwd);
|
|
38079
38093
|
if (output === void 0) {
|
|
38080
38094
|
console.log(
|
|
38081
|
-
|
|
38095
|
+
chalk245.yellow(
|
|
38082
38096
|
"Claude proposed nothing; answer each key from its current value."
|
|
38083
38097
|
)
|
|
38084
38098
|
);
|
|
@@ -38138,14 +38152,14 @@ async function configureHighLevelReview(options2 = {}) {
|
|
|
38138
38152
|
function reportConfigured(result) {
|
|
38139
38153
|
for (const write of result.written)
|
|
38140
38154
|
console.log(
|
|
38141
|
-
|
|
38155
|
+
chalk246.green(`Set ${write.key} = ${JSON.stringify(write.value)}`)
|
|
38142
38156
|
);
|
|
38143
|
-
for (const key of result.skipped) console.log(
|
|
38144
|
-
console.log(
|
|
38157
|
+
for (const key of result.skipped) console.log(chalk246.dim(`Left ${key} unset`));
|
|
38158
|
+
console.log(chalk246.dim(`Written to ${result.target}`));
|
|
38145
38159
|
}
|
|
38146
38160
|
|
|
38147
38161
|
// src/commands/review/highLevel/announceSavedReview.ts
|
|
38148
|
-
import
|
|
38162
|
+
import chalk247 from "chalk";
|
|
38149
38163
|
function savedMessage(subject) {
|
|
38150
38164
|
const head = subject.headSha.slice(0, 7);
|
|
38151
38165
|
if (subject.draft)
|
|
@@ -38156,10 +38170,10 @@ function savedMessage(subject) {
|
|
|
38156
38170
|
}
|
|
38157
38171
|
function announceSavedReview(subject, force) {
|
|
38158
38172
|
const message3 = savedMessage(subject);
|
|
38159
|
-
if (message3) console.log(
|
|
38173
|
+
if (message3) console.log(chalk247.dim(message3));
|
|
38160
38174
|
else if (force)
|
|
38161
38175
|
console.log(
|
|
38162
|
-
|
|
38176
|
+
chalk247.dim(
|
|
38163
38177
|
`Discarding any review saved for ${subject.headSha.slice(0, 7)} and starting fresh (--force).`
|
|
38164
38178
|
)
|
|
38165
38179
|
);
|
|
@@ -39300,55 +39314,55 @@ async function openHighLevelOverlay(sessionId, subject) {
|
|
|
39300
39314
|
}
|
|
39301
39315
|
|
|
39302
39316
|
// src/commands/review/highLevel/printHighLevelChecklist.ts
|
|
39303
|
-
import
|
|
39317
|
+
import chalk252 from "chalk";
|
|
39304
39318
|
|
|
39305
39319
|
// src/commands/review/highLevel/formatCriticalDiffs.ts
|
|
39306
|
-
import
|
|
39320
|
+
import chalk248 from "chalk";
|
|
39307
39321
|
var PATCH_LINE_COLOURS = {
|
|
39308
|
-
"+":
|
|
39309
|
-
"-":
|
|
39310
|
-
"@":
|
|
39322
|
+
"+": chalk248.green,
|
|
39323
|
+
"-": chalk248.red,
|
|
39324
|
+
"@": chalk248.cyan
|
|
39311
39325
|
};
|
|
39312
39326
|
function formatPatch(patch2) {
|
|
39313
39327
|
return patch2.split("\n").map(
|
|
39314
|
-
(line) => ` ${(PATCH_LINE_COLOURS[line[0] ?? ""] ??
|
|
39328
|
+
(line) => ` ${(PATCH_LINE_COLOURS[line[0] ?? ""] ?? chalk248.dim)(line)}`
|
|
39315
39329
|
);
|
|
39316
39330
|
}
|
|
39317
39331
|
function formatDiff(diff3) {
|
|
39318
39332
|
return [
|
|
39319
39333
|
"",
|
|
39320
|
-
` ${
|
|
39321
|
-
...diff3.patch === null ? [` ${
|
|
39334
|
+
` ${chalk248.bold(diff3.path)} ${chalk248.dim(`(${diff3.status})`)} ${chalk248.green(`+${diff3.additions}`)} ${chalk248.red(`-${diff3.deletions}`)}`,
|
|
39335
|
+
...diff3.patch === null ? [` ${chalk248.dim(`no diff available; see ${diff3.diffUrl}`)}`] : formatPatch(diff3.patch)
|
|
39322
39336
|
];
|
|
39323
39337
|
}
|
|
39324
39338
|
function formatCriticalDiffs(diffs, criticalPaths) {
|
|
39325
39339
|
if (criticalPaths.length === 0)
|
|
39326
|
-
return `${
|
|
39327
|
-
${
|
|
39340
|
+
return `${chalk248.bold.underline("Critical diffs")}
|
|
39341
|
+
${chalk248.dim("review.highLevel.criticalPaths is empty, so no diffs are shown")}`;
|
|
39328
39342
|
if (diffs.length === 0)
|
|
39329
|
-
return `${
|
|
39330
|
-
${
|
|
39343
|
+
return `${chalk248.bold.underline("Critical diffs")}
|
|
39344
|
+
${chalk248.dim(`no changed file matches ${criticalPaths.join(", ")}`)}`;
|
|
39331
39345
|
return [
|
|
39332
|
-
|
|
39346
|
+
chalk248.bold.underline("Critical diffs"),
|
|
39333
39347
|
...diffs.flatMap(formatDiff)
|
|
39334
39348
|
].join("\n");
|
|
39335
39349
|
}
|
|
39336
39350
|
|
|
39337
39351
|
// src/commands/review/highLevel/formatHighLevelChecklist.ts
|
|
39338
|
-
import
|
|
39352
|
+
import chalk249 from "chalk";
|
|
39339
39353
|
var MARKERS = {
|
|
39340
|
-
pass: () =>
|
|
39341
|
-
fail: () =>
|
|
39342
|
-
manual: () =>
|
|
39354
|
+
pass: () => chalk249.green("\u2714"),
|
|
39355
|
+
fail: () => chalk249.red("\u2718"),
|
|
39356
|
+
manual: () => chalk249.yellow("\u25A1")
|
|
39343
39357
|
};
|
|
39344
39358
|
function formatCheck(check2) {
|
|
39345
|
-
const title = check2.status === "fail" ?
|
|
39359
|
+
const title = check2.status === "fail" ? chalk249.red(check2.title) : chalk249.bold(check2.title);
|
|
39346
39360
|
return ` ${MARKERS[check2.status]()} ${title}
|
|
39347
|
-
${
|
|
39361
|
+
${chalk249.dim(check2.reason)}`;
|
|
39348
39362
|
}
|
|
39349
39363
|
function formatGroup(heading2, checks2) {
|
|
39350
39364
|
if (checks2.length === 0) return [];
|
|
39351
|
-
return ["",
|
|
39365
|
+
return ["", chalk249.bold.underline(heading2), ...checks2.map(formatCheck)];
|
|
39352
39366
|
}
|
|
39353
39367
|
function formatHighLevelChecklist(checks2) {
|
|
39354
39368
|
const deterministic = checks2.filter(
|
|
@@ -39357,7 +39371,7 @@ function formatHighLevelChecklist(checks2) {
|
|
|
39357
39371
|
const failed3 = deterministic.filter(
|
|
39358
39372
|
(check2) => check2.status === "fail"
|
|
39359
39373
|
).length;
|
|
39360
|
-
const summary = failed3 === 0 ?
|
|
39374
|
+
const summary = failed3 === 0 ? chalk249.green(`All ${deterministic.length} deterministic checks pass`) : chalk249.red(
|
|
39361
39375
|
`${failed3} of ${deterministic.length} deterministic checks fail`
|
|
39362
39376
|
);
|
|
39363
39377
|
return [
|
|
@@ -39372,37 +39386,37 @@ function formatHighLevelChecklist(checks2) {
|
|
|
39372
39386
|
}
|
|
39373
39387
|
|
|
39374
39388
|
// src/commands/review/highLevel/formatHighLevelStructure.ts
|
|
39375
|
-
import
|
|
39389
|
+
import chalk250 from "chalk";
|
|
39376
39390
|
var STATUS_MARKERS = {
|
|
39377
|
-
added: () =>
|
|
39378
|
-
removed: () =>
|
|
39379
|
-
modified: () =>
|
|
39391
|
+
added: () => chalk250.green("A"),
|
|
39392
|
+
removed: () => chalk250.red("D"),
|
|
39393
|
+
modified: () => chalk250.yellow("M")
|
|
39380
39394
|
};
|
|
39381
39395
|
function counts(additions, deletions) {
|
|
39382
|
-
return `${
|
|
39396
|
+
return `${chalk250.green(`+${additions}`)} ${chalk250.red(`-${deletions}`)}`;
|
|
39383
39397
|
}
|
|
39384
39398
|
function formatNode(node, indent4) {
|
|
39385
39399
|
if (node.kind === "file")
|
|
39386
39400
|
return [
|
|
39387
|
-
`${indent4}${STATUS_MARKERS[node.status]()} ${node.name} ${
|
|
39401
|
+
`${indent4}${STATUS_MARKERS[node.status]()} ${node.name} ${chalk250.dim(counts(node.additions, node.deletions))}`
|
|
39388
39402
|
];
|
|
39389
39403
|
const dir = node;
|
|
39390
39404
|
return [
|
|
39391
|
-
`${indent4}${
|
|
39405
|
+
`${indent4}${chalk250.bold(`${dir.name}/`)} ${chalk250.dim(counts(dir.additions, dir.deletions))}`,
|
|
39392
39406
|
...dir.children.flatMap((child) => formatNode(child, `${indent4} `))
|
|
39393
39407
|
];
|
|
39394
39408
|
}
|
|
39395
39409
|
function formatHighLevelStructure(structure) {
|
|
39396
39410
|
const summary = `${structure.added} added \xB7 ${structure.removed} deleted \xB7 ${structure.modified} modified \xB7 ${counts(structure.additions, structure.deletions)}`;
|
|
39397
39411
|
return [
|
|
39398
|
-
|
|
39412
|
+
chalk250.bold.underline("Structure"),
|
|
39399
39413
|
` ${summary}`,
|
|
39400
39414
|
...structure.tree.flatMap((node) => formatNode(node, " "))
|
|
39401
39415
|
].join("\n");
|
|
39402
39416
|
}
|
|
39403
39417
|
|
|
39404
39418
|
// src/commands/review/highLevel/formatHighLevelTests.ts
|
|
39405
|
-
import
|
|
39419
|
+
import chalk251 from "chalk";
|
|
39406
39420
|
function changeMarker(change) {
|
|
39407
39421
|
if (change === "added") return "A";
|
|
39408
39422
|
if (change === "modified") return "M";
|
|
@@ -39411,22 +39425,22 @@ function changeMarker(change) {
|
|
|
39411
39425
|
function formatNode2(node, depth) {
|
|
39412
39426
|
const indent4 = " ".repeat(depth + 2);
|
|
39413
39427
|
if (node.kind === "it")
|
|
39414
|
-
return [`${indent4}${
|
|
39428
|
+
return [`${indent4}${chalk251.dim(changeMarker(node.change))} ${node.name}`];
|
|
39415
39429
|
return [
|
|
39416
|
-
`${indent4}${
|
|
39430
|
+
`${indent4}${chalk251.bold(node.name)}`,
|
|
39417
39431
|
...node.children.flatMap((child) => formatNode2(child, depth + 1))
|
|
39418
39432
|
];
|
|
39419
39433
|
}
|
|
39420
39434
|
function formatHighLevelTests(files, testPaths) {
|
|
39421
|
-
const heading2 =
|
|
39435
|
+
const heading2 = chalk251.bold.underline("Changed tests");
|
|
39422
39436
|
if (files.length === 0)
|
|
39423
39437
|
return `${heading2}
|
|
39424
|
-
${
|
|
39438
|
+
${chalk251.dim(`no changed test in files matching ${testPaths.join(", ")}`)}`;
|
|
39425
39439
|
return [
|
|
39426
39440
|
heading2,
|
|
39427
39441
|
...files.flatMap((file) => [
|
|
39428
39442
|
"",
|
|
39429
|
-
` ${
|
|
39443
|
+
` ${chalk251.bold(file.path)} ${chalk251.dim(`(${file.status})`)}`,
|
|
39430
39444
|
...file.tests.flatMap((node) => formatNode2(node, 0))
|
|
39431
39445
|
])
|
|
39432
39446
|
].join("\n");
|
|
@@ -39440,10 +39454,10 @@ function highLevelChangedFileCount(structure) {
|
|
|
39440
39454
|
// src/commands/review/highLevel/printHighLevelChecklist.ts
|
|
39441
39455
|
function printHighLevelChecklist(subject) {
|
|
39442
39456
|
console.log(
|
|
39443
|
-
|
|
39457
|
+
chalk252.bold(
|
|
39444
39458
|
`High-level review of ${subject.repo}#${subject.prNumber} \u2014 ${subject.title}`
|
|
39445
39459
|
),
|
|
39446
|
-
|
|
39460
|
+
chalk252.dim(
|
|
39447
39461
|
`\xB7 ${highLevelChangedFileCount(subject.structure)} changed files`
|
|
39448
39462
|
)
|
|
39449
39463
|
);
|
|
@@ -39457,12 +39471,12 @@ function printHighLevelChecklist(subject) {
|
|
|
39457
39471
|
console.log("");
|
|
39458
39472
|
console.log(formatHighLevelTests(subject.tests, subject.testPaths));
|
|
39459
39473
|
console.log(
|
|
39460
|
-
|
|
39474
|
+
chalk252.dim(
|
|
39461
39475
|
"\nManual items are for the reviewer to judge; see docs/high-level-review.md."
|
|
39462
39476
|
)
|
|
39463
39477
|
);
|
|
39464
39478
|
console.log(
|
|
39465
|
-
|
|
39479
|
+
chalk252.dim(
|
|
39466
39480
|
"Run this inside an assist session to step through the checklist in the web overlay."
|
|
39467
39481
|
)
|
|
39468
39482
|
);
|
|
@@ -39748,18 +39762,18 @@ function partitionFindingsByDiff(findings, index2) {
|
|
|
39748
39762
|
}
|
|
39749
39763
|
|
|
39750
39764
|
// src/commands/review/warnOutOfDiff.ts
|
|
39751
|
-
import
|
|
39765
|
+
import chalk253 from "chalk";
|
|
39752
39766
|
function warnOutOfDiff(outOfDiff) {
|
|
39753
39767
|
if (outOfDiff.length === 0) return;
|
|
39754
39768
|
console.warn(
|
|
39755
|
-
|
|
39769
|
+
chalk253.yellow(
|
|
39756
39770
|
`Moved ${outOfDiff.length} finding(s) whose lines fall outside the PR diff into the review body (GitHub cannot anchor a comment on these):`
|
|
39757
39771
|
)
|
|
39758
39772
|
);
|
|
39759
39773
|
for (const finding of outOfDiff) {
|
|
39760
39774
|
const range = finding.startLine !== void 0 ? `${finding.startLine}-${finding.line}` : `${finding.line}`;
|
|
39761
39775
|
console.warn(
|
|
39762
|
-
` ${
|
|
39776
|
+
` ${chalk253.yellow("\xB7")} ${finding.title} ${chalk253.dim(
|
|
39763
39777
|
`(${finding.file}:${range})`
|
|
39764
39778
|
)}`
|
|
39765
39779
|
);
|
|
@@ -39786,18 +39800,18 @@ function selectInDiffFindings(lineBound, prDiff) {
|
|
|
39786
39800
|
}
|
|
39787
39801
|
|
|
39788
39802
|
// src/commands/review/warnUnlocated.ts
|
|
39789
|
-
import
|
|
39803
|
+
import chalk254 from "chalk";
|
|
39790
39804
|
function warnUnlocated(unlocated) {
|
|
39791
39805
|
if (unlocated.length === 0) return;
|
|
39792
39806
|
console.warn(
|
|
39793
|
-
|
|
39807
|
+
chalk254.yellow(
|
|
39794
39808
|
`Moved ${unlocated.length} finding(s) without a parseable file:line into the review body:`
|
|
39795
39809
|
)
|
|
39796
39810
|
);
|
|
39797
39811
|
for (const finding of unlocated) {
|
|
39798
|
-
const where = finding.location ||
|
|
39812
|
+
const where = finding.location || chalk254.dim("missing");
|
|
39799
39813
|
console.warn(
|
|
39800
|
-
` ${
|
|
39814
|
+
` ${chalk254.yellow("\xB7")} ${finding.title} ${chalk254.dim(`(${where})`)}`
|
|
39801
39815
|
);
|
|
39802
39816
|
}
|
|
39803
39817
|
}
|
|
@@ -41942,7 +41956,7 @@ function registerReview(program) {
|
|
|
41942
41956
|
|
|
41943
41957
|
// src/commands/rules/indexRules.ts
|
|
41944
41958
|
import path87 from "path";
|
|
41945
|
-
import
|
|
41959
|
+
import chalk255 from "chalk";
|
|
41946
41960
|
|
|
41947
41961
|
// src/commands/rules/updateScopedRulesIndex.ts
|
|
41948
41962
|
import { existsSync as existsSync70, readFileSync as readFileSync55, writeFileSync as writeFileSync43 } from "fs";
|
|
@@ -42029,24 +42043,24 @@ function indexRules() {
|
|
|
42029
42043
|
const rootFile = path87.relative(process.cwd(), path87.join(root2, "CLAUDE.md"));
|
|
42030
42044
|
if (directories.length === 0) {
|
|
42031
42045
|
console.log(
|
|
42032
|
-
|
|
42046
|
+
chalk255.gray(`No directories carry their own \`## Rules\` under ${root2}`)
|
|
42033
42047
|
);
|
|
42034
42048
|
return;
|
|
42035
42049
|
}
|
|
42036
42050
|
console.log(`Recorded in ${rootFile || "CLAUDE.md"}`);
|
|
42037
42051
|
for (const directory of directories)
|
|
42038
|
-
console.log(` ${
|
|
42052
|
+
console.log(` ${chalk255.cyan(directory)}`);
|
|
42039
42053
|
}
|
|
42040
42054
|
|
|
42041
42055
|
// src/commands/rules/listRules.ts
|
|
42042
42056
|
import path88 from "path";
|
|
42043
|
-
import
|
|
42057
|
+
import chalk256 from "chalk";
|
|
42044
42058
|
function listRules(target, options2 = {}) {
|
|
42045
42059
|
const resolved = path88.resolve(target ?? process.cwd());
|
|
42046
42060
|
const rules2 = readScopedRules(resolved);
|
|
42047
42061
|
if (rules2.length === 0) {
|
|
42048
42062
|
const label = path88.relative(process.cwd(), resolved) || ".";
|
|
42049
|
-
console.log(
|
|
42063
|
+
console.log(chalk256.gray(`No rules in scope for ${label}`));
|
|
42050
42064
|
return;
|
|
42051
42065
|
}
|
|
42052
42066
|
const base = findRepoRoot(scopeDirectory(resolved));
|
|
@@ -42056,21 +42070,21 @@ function listRules(target, options2 = {}) {
|
|
|
42056
42070
|
if (rule.source !== shown) {
|
|
42057
42071
|
shown = rule.source;
|
|
42058
42072
|
console.log(
|
|
42059
|
-
|
|
42073
|
+
chalk256.dim(base ? path88.relative(base, rule.source) : rule.source)
|
|
42060
42074
|
);
|
|
42061
42075
|
}
|
|
42062
42076
|
console.log(
|
|
42063
|
-
` ${
|
|
42077
|
+
` ${chalk256.cyan(rule.code.padEnd(width2))} ${rule.title ?? rule.text}`
|
|
42064
42078
|
);
|
|
42065
42079
|
if (options2.full && rule.title)
|
|
42066
|
-
console.log(` ${" ".repeat(width2)} ${
|
|
42080
|
+
console.log(` ${" ".repeat(width2)} ${chalk256.dim(rule.text)}`);
|
|
42067
42081
|
}
|
|
42068
42082
|
}
|
|
42069
42083
|
|
|
42070
42084
|
// src/commands/rules/addRule.ts
|
|
42071
42085
|
import { existsSync as existsSync72, readFileSync as readFileSync57, writeFileSync as writeFileSync44 } from "fs";
|
|
42072
42086
|
import path90 from "path";
|
|
42073
|
-
import
|
|
42087
|
+
import chalk257 from "chalk";
|
|
42074
42088
|
|
|
42075
42089
|
// src/commands/rules/insertRuleBullet.ts
|
|
42076
42090
|
function ruleBullet({ code, title, text: text18 }) {
|
|
@@ -42129,7 +42143,7 @@ function read2(file) {
|
|
|
42129
42143
|
function addRule(text18, options2) {
|
|
42130
42144
|
const rule = text18.trim();
|
|
42131
42145
|
if (rule === "") {
|
|
42132
|
-
console.error(
|
|
42146
|
+
console.error(chalk257.red("Rule text is required"));
|
|
42133
42147
|
process.exitCode = 1;
|
|
42134
42148
|
return;
|
|
42135
42149
|
}
|
|
@@ -42147,14 +42161,14 @@ function addRule(text18, options2) {
|
|
|
42147
42161
|
);
|
|
42148
42162
|
updateScopedRulesIndex(root2);
|
|
42149
42163
|
console.log(
|
|
42150
|
-
`Added ${
|
|
42164
|
+
`Added ${chalk257.cyan(code)} to ${path90.relative(process.cwd(), target) || target}`
|
|
42151
42165
|
);
|
|
42152
42166
|
}
|
|
42153
42167
|
|
|
42154
42168
|
// src/commands/rules/addUserRule.ts
|
|
42155
|
-
import
|
|
42169
|
+
import chalk258 from "chalk";
|
|
42156
42170
|
function fail8(message3) {
|
|
42157
|
-
console.error(
|
|
42171
|
+
console.error(chalk258.red(message3));
|
|
42158
42172
|
process.exitCode = 1;
|
|
42159
42173
|
}
|
|
42160
42174
|
function asRules(value) {
|
|
@@ -42173,7 +42187,7 @@ async function addToUserDb(rule) {
|
|
|
42173
42187
|
rule
|
|
42174
42188
|
]);
|
|
42175
42189
|
if (!result.ok) return fail8(result.errors.join("\n"));
|
|
42176
|
-
console.log(`Added ${
|
|
42190
|
+
console.log(`Added ${chalk258.cyan(rule.title)} to advice.rules in user (db)`);
|
|
42177
42191
|
}
|
|
42178
42192
|
function addToUserNode(rule, globalConfigPath) {
|
|
42179
42193
|
const advice = loadGlobalConfigRaw(globalConfigPath).advice;
|
|
@@ -42186,7 +42200,7 @@ function addToUserNode(rule, globalConfigPath) {
|
|
|
42186
42200
|
);
|
|
42187
42201
|
if (!result.ok) return fail8(result.errors.join("\n"));
|
|
42188
42202
|
console.log(
|
|
42189
|
-
`Added ${
|
|
42203
|
+
`Added ${chalk258.cyan(rule.title)} to advice.rules in user (node) (${globalConfigFileLabel(globalConfigPath)})`
|
|
42190
42204
|
);
|
|
42191
42205
|
}
|
|
42192
42206
|
async function addUserRule(text18, options2, globalConfigPath = getGlobalConfigPath()) {
|
|
@@ -42241,7 +42255,7 @@ function registerRules(program) {
|
|
|
42241
42255
|
}
|
|
42242
42256
|
|
|
42243
42257
|
// src/commands/seq/seqAuth.ts
|
|
42244
|
-
import
|
|
42258
|
+
import chalk260 from "chalk";
|
|
42245
42259
|
|
|
42246
42260
|
// src/commands/seq/loadConnections.ts
|
|
42247
42261
|
function loadConnections2() {
|
|
@@ -42270,10 +42284,10 @@ function setDefaultConnection(name) {
|
|
|
42270
42284
|
}
|
|
42271
42285
|
|
|
42272
42286
|
// src/shared/assertUniqueName.ts
|
|
42273
|
-
import
|
|
42287
|
+
import chalk259 from "chalk";
|
|
42274
42288
|
function assertUniqueName(existingNames, name) {
|
|
42275
42289
|
if (existingNames.includes(name)) {
|
|
42276
|
-
console.error(
|
|
42290
|
+
console.error(chalk259.red(`Connection "${name}" already exists.`));
|
|
42277
42291
|
process.exit(1);
|
|
42278
42292
|
}
|
|
42279
42293
|
}
|
|
@@ -42291,16 +42305,16 @@ async function promptConnection2(existingNames) {
|
|
|
42291
42305
|
var seqAuth = createConnectionAuth({
|
|
42292
42306
|
load: loadConnections2,
|
|
42293
42307
|
save: saveConnections2,
|
|
42294
|
-
format: (c) => `${
|
|
42308
|
+
format: (c) => `${chalk260.bold(c.name)} ${c.url}`,
|
|
42295
42309
|
promptNew: promptConnection2,
|
|
42296
42310
|
onFirst: (c) => setDefaultConnection(c.name)
|
|
42297
42311
|
});
|
|
42298
42312
|
|
|
42299
42313
|
// src/commands/seq/seqQuery.ts
|
|
42300
|
-
import
|
|
42314
|
+
import chalk264 from "chalk";
|
|
42301
42315
|
|
|
42302
42316
|
// src/commands/seq/fetchSeq.ts
|
|
42303
|
-
import
|
|
42317
|
+
import chalk261 from "chalk";
|
|
42304
42318
|
async function fetchSeq(conn, path109, params) {
|
|
42305
42319
|
const url = `${conn.url}${path109}?${params}`;
|
|
42306
42320
|
const response = await fetch(url, {
|
|
@@ -42311,7 +42325,7 @@ async function fetchSeq(conn, path109, params) {
|
|
|
42311
42325
|
});
|
|
42312
42326
|
if (!response.ok) {
|
|
42313
42327
|
const body = await response.text();
|
|
42314
|
-
console.error(
|
|
42328
|
+
console.error(chalk261.red(`Seq returned ${response.status}: ${body}`));
|
|
42315
42329
|
process.exit(1);
|
|
42316
42330
|
}
|
|
42317
42331
|
return response;
|
|
@@ -42370,23 +42384,23 @@ async function fetchSeqEvents(conn, params) {
|
|
|
42370
42384
|
}
|
|
42371
42385
|
|
|
42372
42386
|
// src/commands/seq/formatEvent.ts
|
|
42373
|
-
import
|
|
42387
|
+
import chalk262 from "chalk";
|
|
42374
42388
|
function levelColor(level) {
|
|
42375
42389
|
switch (level) {
|
|
42376
42390
|
case "Fatal":
|
|
42377
|
-
return
|
|
42391
|
+
return chalk262.bgRed.white;
|
|
42378
42392
|
case "Error":
|
|
42379
|
-
return
|
|
42393
|
+
return chalk262.red;
|
|
42380
42394
|
case "Warning":
|
|
42381
|
-
return
|
|
42395
|
+
return chalk262.yellow;
|
|
42382
42396
|
case "Information":
|
|
42383
|
-
return
|
|
42397
|
+
return chalk262.cyan;
|
|
42384
42398
|
case "Debug":
|
|
42385
|
-
return
|
|
42399
|
+
return chalk262.gray;
|
|
42386
42400
|
case "Verbose":
|
|
42387
|
-
return
|
|
42401
|
+
return chalk262.dim;
|
|
42388
42402
|
default:
|
|
42389
|
-
return
|
|
42403
|
+
return chalk262.white;
|
|
42390
42404
|
}
|
|
42391
42405
|
}
|
|
42392
42406
|
function levelAbbrev(level) {
|
|
@@ -42427,12 +42441,12 @@ function formatTimestamp(iso) {
|
|
|
42427
42441
|
function formatEvent(event) {
|
|
42428
42442
|
const color = levelColor(event.Level);
|
|
42429
42443
|
const abbrev = levelAbbrev(event.Level);
|
|
42430
|
-
const ts10 =
|
|
42444
|
+
const ts10 = chalk262.dim(formatTimestamp(event.Timestamp));
|
|
42431
42445
|
const msg = renderMessage(event);
|
|
42432
42446
|
const lines2 = [`${ts10} ${color(`[${abbrev}]`)} ${msg}`];
|
|
42433
42447
|
if (event.Exception) {
|
|
42434
42448
|
for (const line of event.Exception.split("\n")) {
|
|
42435
|
-
lines2.push(
|
|
42449
|
+
lines2.push(chalk262.red(` ${line}`));
|
|
42436
42450
|
}
|
|
42437
42451
|
}
|
|
42438
42452
|
return lines2.join("\n");
|
|
@@ -42465,11 +42479,11 @@ function rejectTimestampFilter(filter) {
|
|
|
42465
42479
|
}
|
|
42466
42480
|
|
|
42467
42481
|
// src/shared/resolveNamedConnection.ts
|
|
42468
|
-
import
|
|
42482
|
+
import chalk263 from "chalk";
|
|
42469
42483
|
function resolveNamedConnection(connections, requested, defaultName, kind, authCommand) {
|
|
42470
42484
|
if (connections.length === 0) {
|
|
42471
42485
|
console.error(
|
|
42472
|
-
|
|
42486
|
+
chalk263.red(
|
|
42473
42487
|
`No ${kind} connections configured. Run '${authCommand}' first.`
|
|
42474
42488
|
)
|
|
42475
42489
|
);
|
|
@@ -42478,7 +42492,7 @@ function resolveNamedConnection(connections, requested, defaultName, kind, authC
|
|
|
42478
42492
|
const target = requested ?? defaultName ?? connections[0].name;
|
|
42479
42493
|
const connection = connections.find((c) => c.name === target);
|
|
42480
42494
|
if (!connection) {
|
|
42481
|
-
console.error(
|
|
42495
|
+
console.error(chalk263.red(`${kind} connection "${target}" not found.`));
|
|
42482
42496
|
process.exit(1);
|
|
42483
42497
|
}
|
|
42484
42498
|
return connection;
|
|
@@ -42507,7 +42521,7 @@ async function seqQuery(filter, options2) {
|
|
|
42507
42521
|
new URLSearchParams({ filter, count: String(count10) })
|
|
42508
42522
|
);
|
|
42509
42523
|
if (events.length === 0) {
|
|
42510
|
-
console.log(
|
|
42524
|
+
console.log(chalk264.yellow("No events found."));
|
|
42511
42525
|
return;
|
|
42512
42526
|
}
|
|
42513
42527
|
if (options2.json) {
|
|
@@ -42518,11 +42532,11 @@ async function seqQuery(filter, options2) {
|
|
|
42518
42532
|
for (const event of chronological) {
|
|
42519
42533
|
console.log(formatEvent(event));
|
|
42520
42534
|
}
|
|
42521
|
-
console.log(
|
|
42535
|
+
console.log(chalk264.dim(`
|
|
42522
42536
|
${events.length} events`));
|
|
42523
42537
|
if (events.length >= count10) {
|
|
42524
42538
|
console.log(
|
|
42525
|
-
|
|
42539
|
+
chalk264.yellow(
|
|
42526
42540
|
`Results limited to ${count10}. Use --count to retrieve more.`
|
|
42527
42541
|
)
|
|
42528
42542
|
);
|
|
@@ -42530,10 +42544,10 @@ ${events.length} events`));
|
|
|
42530
42544
|
}
|
|
42531
42545
|
|
|
42532
42546
|
// src/shared/setNamedDefaultConnection.ts
|
|
42533
|
-
import
|
|
42547
|
+
import chalk265 from "chalk";
|
|
42534
42548
|
function setNamedDefaultConnection(connections, name, setDefault, kind) {
|
|
42535
42549
|
if (!connections.find((c) => c.name === name)) {
|
|
42536
|
-
console.error(
|
|
42550
|
+
console.error(chalk265.red(`Connection "${name}" not found.`));
|
|
42537
42551
|
process.exit(1);
|
|
42538
42552
|
}
|
|
42539
42553
|
setDefault(name);
|
|
@@ -42835,7 +42849,7 @@ function registerSlack(program) {
|
|
|
42835
42849
|
}
|
|
42836
42850
|
|
|
42837
42851
|
// src/commands/sql/sqlAuth.ts
|
|
42838
|
-
import
|
|
42852
|
+
import chalk267 from "chalk";
|
|
42839
42853
|
|
|
42840
42854
|
// src/commands/sql/loadConnections.ts
|
|
42841
42855
|
function loadConnections3() {
|
|
@@ -42864,7 +42878,7 @@ function setDefaultConnection2(name) {
|
|
|
42864
42878
|
}
|
|
42865
42879
|
|
|
42866
42880
|
// src/commands/sql/promptConnection.ts
|
|
42867
|
-
import
|
|
42881
|
+
import chalk266 from "chalk";
|
|
42868
42882
|
async function promptConnection3(existingNames) {
|
|
42869
42883
|
const name = await promptInput("name", "Connection name:", "default");
|
|
42870
42884
|
assertUniqueName(existingNames, name);
|
|
@@ -42872,7 +42886,7 @@ async function promptConnection3(existingNames) {
|
|
|
42872
42886
|
const portStr = await promptInput("port", "Port:", "1433");
|
|
42873
42887
|
const port = Number.parseInt(portStr, 10);
|
|
42874
42888
|
if (!Number.isFinite(port)) {
|
|
42875
|
-
console.error(
|
|
42889
|
+
console.error(chalk266.red(`Invalid port "${portStr}".`));
|
|
42876
42890
|
process.exit(1);
|
|
42877
42891
|
}
|
|
42878
42892
|
const user = await promptInput("user", "User:");
|
|
@@ -42885,13 +42899,13 @@ async function promptConnection3(existingNames) {
|
|
|
42885
42899
|
var sqlAuth = createConnectionAuth({
|
|
42886
42900
|
load: loadConnections3,
|
|
42887
42901
|
save: saveConnections3,
|
|
42888
|
-
format: (c) => `${
|
|
42902
|
+
format: (c) => `${chalk267.bold(c.name)} ${c.server}:${c.port}/${c.database} (${c.user})`,
|
|
42889
42903
|
promptNew: promptConnection3,
|
|
42890
42904
|
onFirst: (c) => setDefaultConnection2(c.name)
|
|
42891
42905
|
});
|
|
42892
42906
|
|
|
42893
42907
|
// src/commands/sql/printTable.ts
|
|
42894
|
-
import
|
|
42908
|
+
import chalk268 from "chalk";
|
|
42895
42909
|
function formatCell(value) {
|
|
42896
42910
|
if (value === null || value === void 0) return "";
|
|
42897
42911
|
if (value instanceof Date) return value.toISOString();
|
|
@@ -42900,7 +42914,7 @@ function formatCell(value) {
|
|
|
42900
42914
|
}
|
|
42901
42915
|
function printTable(rows) {
|
|
42902
42916
|
if (rows.length === 0) {
|
|
42903
|
-
console.log(
|
|
42917
|
+
console.log(chalk268.yellow("(no rows)"));
|
|
42904
42918
|
return;
|
|
42905
42919
|
}
|
|
42906
42920
|
const columns = Object.keys(rows[0]);
|
|
@@ -42908,13 +42922,13 @@ function printTable(rows) {
|
|
|
42908
42922
|
(col) => Math.max(col.length, ...rows.map((r) => formatCell(r[col]).length))
|
|
42909
42923
|
);
|
|
42910
42924
|
const header = columns.map((c, i) => c.padEnd(widths[i])).join(" ");
|
|
42911
|
-
console.log(
|
|
42912
|
-
console.log(
|
|
42925
|
+
console.log(chalk268.dim(header));
|
|
42926
|
+
console.log(chalk268.dim("-".repeat(header.length)));
|
|
42913
42927
|
for (const row3 of rows) {
|
|
42914
42928
|
const line = columns.map((c, i) => formatCell(row3[c]).padEnd(widths[i])).join(" ");
|
|
42915
42929
|
console.log(line);
|
|
42916
42930
|
}
|
|
42917
|
-
console.log(
|
|
42931
|
+
console.log(chalk268.dim(`
|
|
42918
42932
|
${rows.length} row${rows.length === 1 ? "" : "s"}`));
|
|
42919
42933
|
}
|
|
42920
42934
|
|
|
@@ -42974,7 +42988,7 @@ async function sqlColumns(table, connectionName) {
|
|
|
42974
42988
|
}
|
|
42975
42989
|
|
|
42976
42990
|
// src/commands/sql/sqlMutate.ts
|
|
42977
|
-
import
|
|
42991
|
+
import chalk269 from "chalk";
|
|
42978
42992
|
|
|
42979
42993
|
// src/commands/sql/isMutation.ts
|
|
42980
42994
|
var MUTATION_KEYWORDS = [
|
|
@@ -43008,7 +43022,7 @@ function isMutation(sql30) {
|
|
|
43008
43022
|
async function sqlMutate(query, connectionName) {
|
|
43009
43023
|
if (!isMutation(query)) {
|
|
43010
43024
|
console.error(
|
|
43011
|
-
|
|
43025
|
+
chalk269.red(
|
|
43012
43026
|
"assist sql mutate refuses non-mutating statements. Use `assist sql query` instead."
|
|
43013
43027
|
)
|
|
43014
43028
|
);
|
|
@@ -43018,18 +43032,18 @@ async function sqlMutate(query, connectionName) {
|
|
|
43018
43032
|
const pool = await sqlConnect(conn);
|
|
43019
43033
|
try {
|
|
43020
43034
|
const result = await pool.request().query(query);
|
|
43021
|
-
console.log(
|
|
43035
|
+
console.log(chalk269.dim(`${result.rowsAffected.join(", ")} row(s) affected`));
|
|
43022
43036
|
} finally {
|
|
43023
43037
|
await pool.close();
|
|
43024
43038
|
}
|
|
43025
43039
|
}
|
|
43026
43040
|
|
|
43027
43041
|
// src/commands/sql/sqlQuery.ts
|
|
43028
|
-
import
|
|
43042
|
+
import chalk270 from "chalk";
|
|
43029
43043
|
async function sqlQuery(query, connectionName) {
|
|
43030
43044
|
if (isMutation(query)) {
|
|
43031
43045
|
console.error(
|
|
43032
|
-
|
|
43046
|
+
chalk270.red(
|
|
43033
43047
|
"assist sql query refuses mutating statements. Use `assist sql mutate` instead."
|
|
43034
43048
|
)
|
|
43035
43049
|
);
|
|
@@ -43044,7 +43058,7 @@ async function sqlQuery(query, connectionName) {
|
|
|
43044
43058
|
printTable(rows);
|
|
43045
43059
|
} else {
|
|
43046
43060
|
console.log(
|
|
43047
|
-
|
|
43061
|
+
chalk270.dim(`${result.rowsAffected.join(", ")} row(s) affected`)
|
|
43048
43062
|
);
|
|
43049
43063
|
}
|
|
43050
43064
|
} finally {
|
|
@@ -43459,7 +43473,7 @@ function syncPi(claudeDir, options2) {
|
|
|
43459
43473
|
// src/commands/sync/syncSettings.ts
|
|
43460
43474
|
import * as fs47 from "fs";
|
|
43461
43475
|
import * as path101 from "path";
|
|
43462
|
-
import
|
|
43476
|
+
import chalk271 from "chalk";
|
|
43463
43477
|
async function syncSettings(claudeDir, targetBase, options2) {
|
|
43464
43478
|
const source = path101.join(claudeDir, "settings.json");
|
|
43465
43479
|
const target = path101.join(targetBase, "settings.json");
|
|
@@ -43478,7 +43492,7 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
43478
43492
|
if (mergedContent !== normalizedTarget) {
|
|
43479
43493
|
if (!options2?.yes) {
|
|
43480
43494
|
console.log(
|
|
43481
|
-
|
|
43495
|
+
chalk271.yellow(
|
|
43482
43496
|
"\n\u26A0\uFE0F Warning: settings.json differs from existing file"
|
|
43483
43497
|
)
|
|
43484
43498
|
);
|
|
@@ -43486,7 +43500,7 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
43486
43500
|
printDiff(targetContent, mergedContent);
|
|
43487
43501
|
printAutoConfirmHint();
|
|
43488
43502
|
const confirm = await promptConfirm(
|
|
43489
|
-
|
|
43503
|
+
chalk271.red("Overwrite existing settings.json?"),
|
|
43490
43504
|
false
|
|
43491
43505
|
);
|
|
43492
43506
|
if (!confirm) {
|
|
@@ -46328,18 +46342,18 @@ function registerRun(program) {
|
|
|
46328
46342
|
}
|
|
46329
46343
|
|
|
46330
46344
|
// src/commands/sessions/nodes/formatLink.ts
|
|
46331
|
-
import
|
|
46345
|
+
import chalk272 from "chalk";
|
|
46332
46346
|
var STATE_COLOURS = {
|
|
46333
|
-
connected:
|
|
46334
|
-
connecting:
|
|
46335
|
-
disconnected:
|
|
46336
|
-
"version-blocked":
|
|
46347
|
+
connected: chalk272.green,
|
|
46348
|
+
connecting: chalk272.yellow,
|
|
46349
|
+
disconnected: chalk272.red,
|
|
46350
|
+
"version-blocked": chalk272.red
|
|
46337
46351
|
};
|
|
46338
46352
|
function formatLink(link3) {
|
|
46339
|
-
const colour = STATE_COLOURS[link3.state] ??
|
|
46353
|
+
const colour = STATE_COLOURS[link3.state] ?? chalk272.white;
|
|
46340
46354
|
const peer = link3.peerVersion ? ` peer ${link3.peerVersion}` : "";
|
|
46341
46355
|
const error = link3.error ? `
|
|
46342
|
-
${
|
|
46356
|
+
${chalk272.dim(`last error${link3.errorAt ? ` ${link3.errorAt}` : ""}: ${link3.error}`)}` : "";
|
|
46343
46357
|
return ` ${link3.name} ${colour(link3.state)} ${link3.url}${peer}${error}`;
|
|
46344
46358
|
}
|
|
46345
46359
|
|
|
@@ -54341,7 +54355,7 @@ async function closeSession() {
|
|
|
54341
54355
|
}
|
|
54342
54356
|
|
|
54343
54357
|
// src/commands/sessions/nodes/listNodes.ts
|
|
54344
|
-
import
|
|
54358
|
+
import chalk273 from "chalk";
|
|
54345
54359
|
async function nodesReport() {
|
|
54346
54360
|
const live = await queryNodes();
|
|
54347
54361
|
if (live)
|
|
@@ -54358,10 +54372,10 @@ async function listNodes(options2) {
|
|
|
54358
54372
|
console.log(JSON.stringify(report, null, 2));
|
|
54359
54373
|
return;
|
|
54360
54374
|
}
|
|
54361
|
-
console.log(`${report.local} ${
|
|
54375
|
+
console.log(`${report.local} ${chalk273.dim("(this node)")}`);
|
|
54362
54376
|
if (!report.daemonRunning)
|
|
54363
|
-
console.log(
|
|
54364
|
-
if (report.links.length === 0) console.log(
|
|
54377
|
+
console.log(chalk273.dim(" daemon not running; showing configured links"));
|
|
54378
|
+
if (report.links.length === 0) console.log(chalk273.dim(" no links"));
|
|
54365
54379
|
for (const link3 of report.links) console.log(formatLink(link3));
|
|
54366
54380
|
}
|
|
54367
54381
|
|
|
@@ -54383,7 +54397,7 @@ async function findUnlinkedWindowsNode(health2, platform = detectPlatform()) {
|
|
|
54383
54397
|
}
|
|
54384
54398
|
|
|
54385
54399
|
// src/commands/sessions/nodes/printReport.ts
|
|
54386
|
-
import
|
|
54400
|
+
import chalk274 from "chalk";
|
|
54387
54401
|
function printReport(report) {
|
|
54388
54402
|
if (report.links.length === 0) {
|
|
54389
54403
|
console.log(`${report.local} has no links`);
|
|
@@ -54397,11 +54411,11 @@ function printReport(report) {
|
|
|
54397
54411
|
for (const diagnosis of report.links) printDiagnosis(diagnosis);
|
|
54398
54412
|
}
|
|
54399
54413
|
function printDiagnosis(diagnosis) {
|
|
54400
|
-
console.log(`${
|
|
54414
|
+
console.log(`${chalk274.bold(diagnosis.name)} ${chalk274.dim(diagnosis.url)}`);
|
|
54401
54415
|
for (const hop of diagnosis.hops) {
|
|
54402
|
-
const mark = hop.ok ?
|
|
54416
|
+
const mark = hop.ok ? chalk274.green("\u2713") : chalk274.red("\u2717");
|
|
54403
54417
|
console.log(` ${mark} ${hop.hop.padEnd(9)} ${hop.detail ?? hop.error}`);
|
|
54404
|
-
if (hop.remediation) console.log(` ${
|
|
54418
|
+
if (hop.remediation) console.log(` ${chalk274.yellow(hop.remediation)}`);
|
|
54405
54419
|
}
|
|
54406
54420
|
}
|
|
54407
54421
|
|
|
@@ -54473,14 +54487,14 @@ function registerDiagnoseCommands(nodes, calledBy4) {
|
|
|
54473
54487
|
}
|
|
54474
54488
|
|
|
54475
54489
|
// src/commands/sessions/nodes/linkNode.ts
|
|
54476
|
-
import
|
|
54490
|
+
import chalk277 from "chalk";
|
|
54477
54491
|
|
|
54478
54492
|
// src/commands/sessions/nodes/notifyDaemonLinks.ts
|
|
54479
|
-
import
|
|
54493
|
+
import chalk275 from "chalk";
|
|
54480
54494
|
async function notifyDaemonLinks() {
|
|
54481
54495
|
if (!await isDaemonRunning()) {
|
|
54482
54496
|
console.log(
|
|
54483
|
-
|
|
54497
|
+
chalk275.yellow(
|
|
54484
54498
|
"The sessions daemon is not running; it loads the links when it starts."
|
|
54485
54499
|
)
|
|
54486
54500
|
);
|
|
@@ -54488,11 +54502,11 @@ async function notifyDaemonLinks() {
|
|
|
54488
54502
|
}
|
|
54489
54503
|
try {
|
|
54490
54504
|
await sendToDaemonAwaitAck({ type: "reload-links" });
|
|
54491
|
-
console.log(
|
|
54505
|
+
console.log(chalk275.dim("The sessions daemon reloaded its links."));
|
|
54492
54506
|
} catch (error) {
|
|
54493
54507
|
const message3 = error instanceof Error ? error.message : String(error);
|
|
54494
54508
|
console.log(
|
|
54495
|
-
|
|
54509
|
+
chalk275.yellow(
|
|
54496
54510
|
`Could not notify the sessions daemon (${message3}); run \`assist daemon restart\` to apply the change.`
|
|
54497
54511
|
)
|
|
54498
54512
|
);
|
|
@@ -54500,7 +54514,7 @@ async function notifyDaemonLinks() {
|
|
|
54500
54514
|
}
|
|
54501
54515
|
|
|
54502
54516
|
// src/commands/sessions/nodes/readLinks.ts
|
|
54503
|
-
import
|
|
54517
|
+
import chalk276 from "chalk";
|
|
54504
54518
|
|
|
54505
54519
|
// src/commands/sessions/nodes/writeLinks.ts
|
|
54506
54520
|
async function writeLinks(links2) {
|
|
@@ -54523,7 +54537,7 @@ async function readLinks() {
|
|
|
54523
54537
|
await writeLinks(links2);
|
|
54524
54538
|
const dropped = stored.filter((link3) => !link3.url).map((link3) => link3.name);
|
|
54525
54539
|
console.log(
|
|
54526
|
-
|
|
54540
|
+
chalk276.yellow(`Removed ${dropped.join(", ")}: ${SSH_LINK_RETIRED}`)
|
|
54527
54541
|
);
|
|
54528
54542
|
return links2;
|
|
54529
54543
|
}
|
|
@@ -54579,7 +54593,7 @@ async function linkNode(name, url, options2) {
|
|
|
54579
54593
|
throw new Error(`${name} is this node; link to a different node`);
|
|
54580
54594
|
const link3 = await buildLink(name, url, options2);
|
|
54581
54595
|
await writeLinks([...others, link3]);
|
|
54582
|
-
console.log(
|
|
54596
|
+
console.log(chalk277.green(`Linked ${name} (${link3.url})`));
|
|
54583
54597
|
await notifyDaemonLinks();
|
|
54584
54598
|
}
|
|
54585
54599
|
|
|
@@ -54762,16 +54776,16 @@ function registerPeerActionCommands(nodes, calledBy4) {
|
|
|
54762
54776
|
}
|
|
54763
54777
|
|
|
54764
54778
|
// src/commands/sessions/nodes/unlinkNode.ts
|
|
54765
|
-
import
|
|
54779
|
+
import chalk278 from "chalk";
|
|
54766
54780
|
async function unlinkNode(name) {
|
|
54767
54781
|
const links2 = await readLinks();
|
|
54768
54782
|
const remaining = links2.filter((link3) => link3.name !== name);
|
|
54769
54783
|
if (remaining.length === links2.length) {
|
|
54770
|
-
console.log(
|
|
54784
|
+
console.log(chalk278.yellow(`No link named ${name}`));
|
|
54771
54785
|
return;
|
|
54772
54786
|
}
|
|
54773
54787
|
await writeLinks(remaining);
|
|
54774
|
-
console.log(
|
|
54788
|
+
console.log(chalk278.green(`Unlinked ${name}`));
|
|
54775
54789
|
await notifyDaemonLinks();
|
|
54776
54790
|
}
|
|
54777
54791
|
|
|
@@ -55008,10 +55022,10 @@ function createProgram() {
|
|
|
55008
55022
|
}
|
|
55009
55023
|
|
|
55010
55024
|
// src/reportCliError.ts
|
|
55011
|
-
import
|
|
55025
|
+
import chalk279 from "chalk";
|
|
55012
55026
|
function reportCliError(error) {
|
|
55013
55027
|
if (error instanceof InvalidItemIdError || error instanceof AmbiguousRepoConfigError || error instanceof UnknownRepoConfigError || error instanceof MissingRunCwdError || error instanceof MiroExtractError || error instanceof MissingDatabaseUrlError) {
|
|
55014
|
-
console.error(
|
|
55028
|
+
console.error(chalk279.red(error.message));
|
|
55015
55029
|
} else {
|
|
55016
55030
|
console.error(error);
|
|
55017
55031
|
}
|