@staff0rd/assist 0.683.0 → 0.684.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 +3 -2
- package/allowed.cli-reads +1 -0
- package/dist/allowed.cli-reads +1 -0
- package/dist/commands/sessions/web/bundle.js +1 -1
- package/dist/index.js +359 -226
- 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.684.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -3066,7 +3066,7 @@ var refactorConfigHelp = [
|
|
|
3066
3066
|
var releasesConfigHelp = [
|
|
3067
3067
|
{
|
|
3068
3068
|
key: "releases.streams",
|
|
3069
|
-
setter: "assist releases
|
|
3069
|
+
setter: "assist releases configure <owner/repo>",
|
|
3070
3070
|
note: "promotion streams the /releases page draws; each names a repo, its release workflow, its nodes and the edges between them"
|
|
3071
3071
|
}
|
|
3072
3072
|
];
|
|
@@ -17529,6 +17529,12 @@ function appliesFixStructure(command) {
|
|
|
17529
17529
|
return APPLY_RE.test(command);
|
|
17530
17530
|
}
|
|
17531
17531
|
|
|
17532
|
+
// src/shared/configuresReleases.ts
|
|
17533
|
+
var CONFIGURE_RE = /^assist\s+releases\s+configure\b/;
|
|
17534
|
+
function configuresReleases(command) {
|
|
17535
|
+
return CONFIGURE_RE.test(command);
|
|
17536
|
+
}
|
|
17537
|
+
|
|
17532
17538
|
// src/shared/isGhApiRead.ts
|
|
17533
17539
|
var READ_METHODS = /* @__PURE__ */ new Set(["GET", "HEAD"]);
|
|
17534
17540
|
var BODY_FLAGS2 = /* @__PURE__ */ new Set(["-f", "-F", "--field", "--raw-field", "--input"]);
|
|
@@ -17716,6 +17722,7 @@ function isApprovedRead(command, toolName = "Bash") {
|
|
|
17716
17722
|
const cdRead = isCdToReadAllowedDir(command);
|
|
17717
17723
|
if (cdRead) return cdRead;
|
|
17718
17724
|
if (appliesFixStructure(command)) return void 0;
|
|
17725
|
+
if (configuresReleases(command)) return void 0;
|
|
17719
17726
|
const matchedRead = findCliRead(command);
|
|
17720
17727
|
if (matchedRead) return `Read-only CLI command: ${matchedRead}`;
|
|
17721
17728
|
const matchedWrite = findCliWrite(command);
|
|
@@ -28744,24 +28751,147 @@ function registerRavendb(program2) {
|
|
|
28744
28751
|
configHelp(cmd, ravendbConfigHelp);
|
|
28745
28752
|
}
|
|
28746
28753
|
|
|
28747
|
-
// src/commands/releases/
|
|
28754
|
+
// src/commands/releases/releasesConfigure.ts
|
|
28755
|
+
import chalk198 from "chalk";
|
|
28756
|
+
|
|
28757
|
+
// src/commands/releases/buildConfigurePrompt.ts
|
|
28758
|
+
var SCHEMA_EXAMPLE = `releases:
|
|
28759
|
+
streams:
|
|
28760
|
+
- name: Web App
|
|
28761
|
+
repo: owner/name
|
|
28762
|
+
workflow: release.yml
|
|
28763
|
+
nodes:
|
|
28764
|
+
- { id: build, kind: build }
|
|
28765
|
+
- { id: dev, environment: dev }
|
|
28766
|
+
- { id: promote, kind: gate }
|
|
28767
|
+
- { id: uk-prod, environment: UK Production, label: uk-prod }
|
|
28768
|
+
edges:
|
|
28769
|
+
- [build, dev]
|
|
28770
|
+
- [dev, promote]
|
|
28771
|
+
- [promote, uk-prod]`;
|
|
28772
|
+
function buildConfigurePrompt(repo) {
|
|
28773
|
+
return `Derive the release promotion topology of ${repo} and write it into assist's config under \`releases.streams\`.
|
|
28774
|
+
|
|
28775
|
+
## Read the workflows from GitHub
|
|
28776
|
+
|
|
28777
|
+
Do not assume ${repo} is checked out here.
|
|
28778
|
+
|
|
28779
|
+
- \`gh api repos/${repo}/contents/.github/workflows --jq '.[].name'\` lists the workflow files.
|
|
28780
|
+
- \`gh api repos/${repo}/contents/.github/workflows/<file> --jq .content | base64 -d\` reads one.
|
|
28781
|
+
- A job with \`uses: <owner>/<name>/.github/workflows/<file>@<ref>\` calls a reusable workflow. Read that file too, from the repo and ref it names, and keep following \`uses:\` to any depth \u2014 a deploy three levels down is still a node in the graph.
|
|
28782
|
+
|
|
28783
|
+
## Derive
|
|
28784
|
+
|
|
28785
|
+
- **Streams** \u2014 one per release pipeline. A repo releasing two apps has two streams, whether they share a workflow or not. Name each after the thing released, not after the workflow file. \`workflow\` is the file name of the workflow the promotion runs under, the top-level one, not the reusable ones it calls.
|
|
28786
|
+
- **Nodes** \u2014 one per step worth drawing:
|
|
28787
|
+
- a job that deploys to a GitHub environment: \`{ id: <short-id>, environment: <name> }\`
|
|
28788
|
+
- a job that builds or packages and deploys nothing: \`{ id: <short-id>, kind: build }\`
|
|
28789
|
+
- a job or environment approval that only gates promotion: \`{ id: <short-id>, kind: gate }\`
|
|
28790
|
+
- \`label\` overrides the text drawn on the node; set it only where \`id\` reads badly.
|
|
28791
|
+
- **Environment names** must be the names GitHub knows, spelled as the repo's environments spell them \u2014 live state is read from the repo's deployments against them. Where a reusable workflow takes the name as an input, follow the input back to its value at the call site rather than recording the input's name. \`gh api repos/${repo}/environments --jq '.environments[].name'\` is the check.
|
|
28792
|
+
- **Edges** \u2014 \`[from, to]\` for each \`needs:\` relation between the nodes you kept, flattened across reusable-workflow boundaries: where a job needs a \`uses:\` job, the edge runs to or from the inner job that actually neighbours it. Fan-in (several nodes into one gate) and fan-out (one node into several) are both expected and must both survive the flattening.
|
|
28793
|
+
|
|
28794
|
+
## Confirm before writing
|
|
28795
|
+
|
|
28796
|
+
Ask rather than guess: which jobs deserve a node, how jobs split into streams, what to call a stream, and any environment name that is computed rather than written literally. Show the graph you intend to write \u2014 nodes and edges \u2014 and let me correct it before anything is written.
|
|
28797
|
+
|
|
28798
|
+
## Write
|
|
28799
|
+
|
|
28800
|
+
Put the block in the assist config of the repo you are running in (\`.claude/assist.yml\` or \`assist.yml\`), or in \`~/.assist.yml\` for one that should follow me everywhere. Ask which if there is any doubt. Keep streams already declared for other repos, and replace the ones whose \`repo\` is \`${repo}\`.
|
|
28801
|
+
|
|
28802
|
+
${SCHEMA_EXAMPLE}
|
|
28803
|
+
|
|
28804
|
+
Then run \`assist releases list\` to confirm assist reads the block back as you meant it, and exit. Do not run \`assist releases configure\`.`;
|
|
28805
|
+
}
|
|
28806
|
+
|
|
28807
|
+
// src/commands/releases/readRepoStreams.ts
|
|
28808
|
+
import { ZodError } from "zod";
|
|
28809
|
+
function readRepoStreams(repo) {
|
|
28810
|
+
try {
|
|
28811
|
+
const streams = loadConfig().releases?.streams ?? [];
|
|
28812
|
+
const wanted = repo.toLowerCase();
|
|
28813
|
+
return { streams: streams.filter((s) => s.repo.toLowerCase() === wanted) };
|
|
28814
|
+
} catch (error) {
|
|
28815
|
+
return { error: describeConfigError(error) };
|
|
28816
|
+
}
|
|
28817
|
+
}
|
|
28818
|
+
function describeConfigError(error) {
|
|
28819
|
+
if (error instanceof ZodError)
|
|
28820
|
+
return error.issues.map((issue) => ` ${issue.path.join(".")}: ${issue.message}`).join("\n");
|
|
28821
|
+
return error instanceof Error ? error.message : String(error);
|
|
28822
|
+
}
|
|
28823
|
+
|
|
28824
|
+
// src/commands/releases/reportDerivedStreams.ts
|
|
28748
28825
|
import chalk197 from "chalk";
|
|
28826
|
+
function printDerived(stream) {
|
|
28827
|
+
const environments = stream.nodes.flatMap((n) => n.environment ?? []);
|
|
28828
|
+
const steps = stream.nodes.filter((n) => !n.environment);
|
|
28829
|
+
console.log(
|
|
28830
|
+
`${chalk197.bold(stream.name)} ${chalk197.dim(`${stream.repo} \xB7 ${stream.workflow}`)}`
|
|
28831
|
+
);
|
|
28832
|
+
console.log(
|
|
28833
|
+
` environments: ${environments.join(", ") || chalk197.dim("none")}`
|
|
28834
|
+
);
|
|
28835
|
+
if (steps.length > 0)
|
|
28836
|
+
console.log(
|
|
28837
|
+
` steps: ${steps.map((n) => `${n.id} [${n.kind ?? "step"}]`).join(", ")}`
|
|
28838
|
+
);
|
|
28839
|
+
const edges = stream.edges.map(([from, to]) => `${from} \u2192 ${to}`);
|
|
28840
|
+
console.log(` edges: ${edges.join(", ") || chalk197.dim("none")}`);
|
|
28841
|
+
}
|
|
28842
|
+
function reportDerivedStreams(repo, before) {
|
|
28843
|
+
const after = readRepoStreams(repo);
|
|
28844
|
+
if ("error" in after) {
|
|
28845
|
+
console.error(
|
|
28846
|
+
chalk197.red(`releases.streams does not validate:
|
|
28847
|
+
${after.error}`)
|
|
28848
|
+
);
|
|
28849
|
+
process.exitCode = 1;
|
|
28850
|
+
return;
|
|
28851
|
+
}
|
|
28852
|
+
if (after.streams.length === 0) {
|
|
28853
|
+
console.log(chalk197.yellow(`No stream is declared for ${repo}.`));
|
|
28854
|
+
return;
|
|
28855
|
+
}
|
|
28856
|
+
if (JSON.stringify(after.streams) === JSON.stringify(before))
|
|
28857
|
+
console.log(chalk197.dim(`releases.streams for ${repo} is unchanged.`));
|
|
28858
|
+
for (const stream of after.streams) printDerived(stream);
|
|
28859
|
+
}
|
|
28860
|
+
|
|
28861
|
+
// src/commands/releases/releasesConfigure.ts
|
|
28862
|
+
var REPO_RE = /^[^/\s]+\/[^/\s]+$/;
|
|
28863
|
+
async function releasesConfigure(repo) {
|
|
28864
|
+
if (!REPO_RE.test(repo)) {
|
|
28865
|
+
console.error(chalk198.red(`Expected <owner/repo>, got '${repo}'.`));
|
|
28866
|
+
process.exitCode = 1;
|
|
28867
|
+
return;
|
|
28868
|
+
}
|
|
28869
|
+
const before = readRepoStreams(repo);
|
|
28870
|
+
const { done: done2 } = spawnClaude(buildConfigurePrompt(repo), {
|
|
28871
|
+
allowEdits: true
|
|
28872
|
+
});
|
|
28873
|
+
await done2;
|
|
28874
|
+
reportDerivedStreams(repo, "streams" in before ? before.streams : []);
|
|
28875
|
+
}
|
|
28876
|
+
|
|
28877
|
+
// src/commands/releases/releasesList.ts
|
|
28878
|
+
import chalk199 from "chalk";
|
|
28749
28879
|
function describeNode(node) {
|
|
28750
28880
|
if (node.environment) return `${node.id} \u2192 ${node.environment}`;
|
|
28751
28881
|
return `${node.id} (${node.kind ?? "step"})`;
|
|
28752
28882
|
}
|
|
28753
28883
|
function printStream(stream) {
|
|
28754
|
-
console.log(`${
|
|
28755
|
-
console.log(
|
|
28884
|
+
console.log(`${chalk199.bold(stream.name)} ${chalk199.dim(stream.repo)}`);
|
|
28885
|
+
console.log(chalk199.dim(` workflow: ${stream.workflow}`));
|
|
28756
28886
|
for (const node of stream.nodes) console.log(` ${describeNode(node)}`);
|
|
28757
28887
|
for (const [from, to] of stream.edges)
|
|
28758
|
-
console.log(
|
|
28888
|
+
console.log(chalk199.dim(` ${from} \u2192 ${to}`));
|
|
28759
28889
|
}
|
|
28760
28890
|
function releasesList() {
|
|
28761
28891
|
const streams = loadConfig().releases?.streams ?? [];
|
|
28762
28892
|
if (streams.length === 0) {
|
|
28763
28893
|
console.log(
|
|
28764
|
-
|
|
28894
|
+
chalk199.dim("No release streams configured under releases.streams.")
|
|
28765
28895
|
);
|
|
28766
28896
|
return;
|
|
28767
28897
|
}
|
|
@@ -28774,9 +28904,12 @@ function registerReleases(parent) {
|
|
|
28774
28904
|
configHelp(
|
|
28775
28905
|
releasesCommand,
|
|
28776
28906
|
releasesConfigHelp,
|
|
28777
|
-
"Streams are declared by hand in assist.yml and rendered by the /releases page of the sessions dashboard."
|
|
28907
|
+
"Streams are declared by 'assist releases configure <owner/repo>' or by hand in assist.yml, and rendered by the /releases page of the sessions dashboard."
|
|
28778
28908
|
);
|
|
28779
28909
|
releasesCommand.command("list").description("List the declared release streams, their nodes and edges").action(releasesList);
|
|
28910
|
+
releasesCommand.command("configure <owner/repo>").description(
|
|
28911
|
+
"Derive a repo's promotion topology with Claude and write it to releases.streams"
|
|
28912
|
+
).action(releasesConfigure);
|
|
28780
28913
|
}
|
|
28781
28914
|
|
|
28782
28915
|
// src/commands/coverage.ts
|
|
@@ -28796,7 +28929,7 @@ function coverage() {
|
|
|
28796
28929
|
|
|
28797
28930
|
// src/commands/lint/lint/runFileNameCheck.ts
|
|
28798
28931
|
import path45 from "path";
|
|
28799
|
-
import
|
|
28932
|
+
import chalk201 from "chalk";
|
|
28800
28933
|
|
|
28801
28934
|
// src/commands/lint/lint/checkFileNames.ts
|
|
28802
28935
|
import fs25 from "fs";
|
|
@@ -28876,7 +29009,7 @@ function checkFileNames() {
|
|
|
28876
29009
|
}
|
|
28877
29010
|
|
|
28878
29011
|
// src/commands/lint/lint/fixFileNameViolations.ts
|
|
28879
|
-
import
|
|
29012
|
+
import chalk200 from "chalk";
|
|
28880
29013
|
|
|
28881
29014
|
// src/commands/lint/lint/applyMoves.ts
|
|
28882
29015
|
import fs26 from "fs";
|
|
@@ -28961,25 +29094,25 @@ function fixFileNameViolations(moves) {
|
|
|
28961
29094
|
const start3 = performance.now();
|
|
28962
29095
|
const project = createLintProject();
|
|
28963
29096
|
const cwd = process.cwd();
|
|
28964
|
-
applyMoves(project, moves, cwd, (line) => console.log(
|
|
29097
|
+
applyMoves(project, moves, cwd, (line) => console.log(chalk200.green(line)));
|
|
28965
29098
|
const ms = (performance.now() - start3).toFixed(0);
|
|
28966
|
-
console.log(
|
|
29099
|
+
console.log(chalk200.dim(` Done in ${ms}ms`));
|
|
28967
29100
|
}
|
|
28968
29101
|
|
|
28969
29102
|
// src/commands/lint/lint/runFileNameCheck.ts
|
|
28970
29103
|
function reportViolations(violations) {
|
|
28971
|
-
console.error(
|
|
29104
|
+
console.error(chalk201.red("\nFile name check failed:\n"));
|
|
28972
29105
|
console.error(
|
|
28973
|
-
|
|
29106
|
+
chalk201.red(
|
|
28974
29107
|
" Files without classes or React components should not start with a capital letter.\n"
|
|
28975
29108
|
)
|
|
28976
29109
|
);
|
|
28977
29110
|
for (const violation of violations) {
|
|
28978
|
-
console.error(
|
|
28979
|
-
console.error(
|
|
29111
|
+
console.error(chalk201.red(` ${violation.filePath}`));
|
|
29112
|
+
console.error(chalk201.gray(` Rename to: ${violation.suggestedName}
|
|
28980
29113
|
`));
|
|
28981
29114
|
}
|
|
28982
|
-
console.error(
|
|
29115
|
+
console.error(chalk201.dim(" Run with -f to auto-fix.\n"));
|
|
28983
29116
|
}
|
|
28984
29117
|
function runFileNameCheck(fix = false) {
|
|
28985
29118
|
const violations = checkFileNames();
|
|
@@ -29008,17 +29141,17 @@ function runFileNameCheck(fix = false) {
|
|
|
29008
29141
|
import fs28 from "fs";
|
|
29009
29142
|
|
|
29010
29143
|
// src/commands/lint/shared.ts
|
|
29011
|
-
import
|
|
29144
|
+
import chalk202 from "chalk";
|
|
29012
29145
|
function reportViolations2(violations, checkName2, errorMessage2, successMessage) {
|
|
29013
29146
|
if (violations.length > 0) {
|
|
29014
|
-
console.error(
|
|
29147
|
+
console.error(chalk202.red(`
|
|
29015
29148
|
${checkName2} failed:
|
|
29016
29149
|
`));
|
|
29017
|
-
console.error(
|
|
29150
|
+
console.error(chalk202.red(` ${errorMessage2}
|
|
29018
29151
|
`));
|
|
29019
29152
|
for (const violation of violations) {
|
|
29020
|
-
console.error(
|
|
29021
|
-
console.error(
|
|
29153
|
+
console.error(chalk202.red(` ${violation.filePath}:${violation.line}`));
|
|
29154
|
+
console.error(chalk202.gray(` ${violation.content}
|
|
29022
29155
|
`));
|
|
29023
29156
|
}
|
|
29024
29157
|
return false;
|
|
@@ -29149,7 +29282,7 @@ import { execSync as execSync57 } from "child_process";
|
|
|
29149
29282
|
import { existsSync as existsSync63, mkdirSync as mkdirSync21, unlinkSync as unlinkSync17, writeFileSync as writeFileSync38 } from "fs";
|
|
29150
29283
|
import { tmpdir as tmpdir9 } from "os";
|
|
29151
29284
|
import { join as join75, resolve as resolve19 } from "path";
|
|
29152
|
-
import
|
|
29285
|
+
import chalk203 from "chalk";
|
|
29153
29286
|
|
|
29154
29287
|
// src/commands/screenshot/captureWindowPs1.ts
|
|
29155
29288
|
var captureWindowPs1 = `
|
|
@@ -29300,19 +29433,19 @@ function screenshot(processName) {
|
|
|
29300
29433
|
const config = loadConfig();
|
|
29301
29434
|
const outputDir = resolve19(config.screenshot.outputDir);
|
|
29302
29435
|
const outputPath = buildOutputPath(outputDir, processName);
|
|
29303
|
-
console.log(
|
|
29436
|
+
console.log(chalk203.gray(`Capturing window for process "${processName}" ...`));
|
|
29304
29437
|
try {
|
|
29305
29438
|
runPowerShellScript(processName, outputPath);
|
|
29306
|
-
console.log(
|
|
29439
|
+
console.log(chalk203.green(`Screenshot saved: ${outputPath}`));
|
|
29307
29440
|
} catch (error) {
|
|
29308
29441
|
const msg = error instanceof Error ? error.message : String(error);
|
|
29309
|
-
console.error(
|
|
29442
|
+
console.error(chalk203.red(`Failed to capture screenshot: ${msg}`));
|
|
29310
29443
|
process.exit(1);
|
|
29311
29444
|
}
|
|
29312
29445
|
}
|
|
29313
29446
|
|
|
29314
29447
|
// src/commands/statusLine.ts
|
|
29315
|
-
import
|
|
29448
|
+
import chalk205 from "chalk";
|
|
29316
29449
|
|
|
29317
29450
|
// src/shared/contextLevel.ts
|
|
29318
29451
|
function contextLevel(pct) {
|
|
@@ -29322,7 +29455,7 @@ function contextLevel(pct) {
|
|
|
29322
29455
|
}
|
|
29323
29456
|
|
|
29324
29457
|
// src/commands/buildLimitsSegment.ts
|
|
29325
|
-
import
|
|
29458
|
+
import chalk204 from "chalk";
|
|
29326
29459
|
|
|
29327
29460
|
// src/shared/rateLimitLevel.ts
|
|
29328
29461
|
var FIVE_HOUR_SECONDS = 5 * 3600;
|
|
@@ -29360,9 +29493,9 @@ function rateLimitLevel(pct, resetsAt, windowSeconds, now) {
|
|
|
29360
29493
|
|
|
29361
29494
|
// src/commands/buildLimitsSegment.ts
|
|
29362
29495
|
var LEVEL_COLOR = {
|
|
29363
|
-
ok:
|
|
29364
|
-
warn:
|
|
29365
|
-
over:
|
|
29496
|
+
ok: chalk204.green,
|
|
29497
|
+
warn: chalk204.yellow,
|
|
29498
|
+
over: chalk204.red
|
|
29366
29499
|
};
|
|
29367
29500
|
function formatLimit(pct, resetsAt, windowSeconds, fallbackLabel, now) {
|
|
29368
29501
|
const level = rateLimitLevel(pct, resetsAt, windowSeconds, now);
|
|
@@ -29458,7 +29591,7 @@ async function relayUsage(claudeSessionId, transcriptPath2, usedPct) {
|
|
|
29458
29591
|
}
|
|
29459
29592
|
|
|
29460
29593
|
// src/commands/statusLine.ts
|
|
29461
|
-
|
|
29594
|
+
chalk205.level = 3;
|
|
29462
29595
|
function formatNumber(num) {
|
|
29463
29596
|
return num.toLocaleString("en-US");
|
|
29464
29597
|
}
|
|
@@ -29466,9 +29599,9 @@ function colorizePercent(pct) {
|
|
|
29466
29599
|
const label2 = `${Math.round(pct)}%`;
|
|
29467
29600
|
switch (contextLevel(pct)) {
|
|
29468
29601
|
case "red":
|
|
29469
|
-
return
|
|
29602
|
+
return chalk205.red(label2);
|
|
29470
29603
|
case "yellow":
|
|
29471
|
-
return
|
|
29604
|
+
return chalk205.yellow(label2);
|
|
29472
29605
|
default:
|
|
29473
29606
|
return label2;
|
|
29474
29607
|
}
|
|
@@ -29481,7 +29614,7 @@ async function statusLine() {
|
|
|
29481
29614
|
const usedPct = data.context_window.used_percentage ?? 0;
|
|
29482
29615
|
const dir = data.workspace?.current_dir ?? data.cwd;
|
|
29483
29616
|
const branch2 = dir ? readGitBranch(toGitCwd(dir)) : null;
|
|
29484
|
-
const branchSegment = branch2 ? `\u{1F33F}\uFE0F ${
|
|
29617
|
+
const branchSegment = branch2 ? `\u{1F33F}\uFE0F ${chalk205.cyan(branch2)} | ` : "";
|
|
29485
29618
|
console.log(
|
|
29486
29619
|
`${branchSegment}${model} | Tokens - ${formatNumber(totalIn)} \u2191 : ${formatNumber(totalOut)} \u2193 | Context - ${colorizePercent(usedPct)}${buildLimitsSegment(data.rate_limits)}`
|
|
29487
29620
|
);
|
|
@@ -29584,7 +29717,7 @@ import { spawn as spawn6 } from "child_process";
|
|
|
29584
29717
|
import * as path47 from "path";
|
|
29585
29718
|
|
|
29586
29719
|
// src/commands/refactor/logViolations.ts
|
|
29587
|
-
import
|
|
29720
|
+
import chalk206 from "chalk";
|
|
29588
29721
|
var DEFAULT_MAX_LINES2 = 100;
|
|
29589
29722
|
function logViolations(violations, maxLines = DEFAULT_MAX_LINES2) {
|
|
29590
29723
|
if (violations.length === 0) {
|
|
@@ -29593,43 +29726,43 @@ function logViolations(violations, maxLines = DEFAULT_MAX_LINES2) {
|
|
|
29593
29726
|
}
|
|
29594
29727
|
return;
|
|
29595
29728
|
}
|
|
29596
|
-
console.error(
|
|
29729
|
+
console.error(chalk206.red(`
|
|
29597
29730
|
Refactor check failed:
|
|
29598
29731
|
`));
|
|
29599
|
-
console.error(
|
|
29732
|
+
console.error(chalk206.red(` The following files exceed ${maxLines} lines:
|
|
29600
29733
|
`));
|
|
29601
29734
|
for (const violation of violations) {
|
|
29602
|
-
console.error(
|
|
29735
|
+
console.error(chalk206.red(` ${violation.file} (${violation.lines} lines)`));
|
|
29603
29736
|
}
|
|
29604
29737
|
console.error(
|
|
29605
|
-
|
|
29738
|
+
chalk206.yellow(
|
|
29606
29739
|
`
|
|
29607
29740
|
Each file needs to be sensibly refactored, or if there is no sensible
|
|
29608
29741
|
way to refactor it, ignore it with:
|
|
29609
29742
|
`
|
|
29610
29743
|
)
|
|
29611
29744
|
);
|
|
29612
|
-
console.error(
|
|
29745
|
+
console.error(chalk206.gray(` assist refactor ignore <file>
|
|
29613
29746
|
`));
|
|
29614
29747
|
if (process.env.CLAUDECODE) {
|
|
29615
|
-
console.error(
|
|
29748
|
+
console.error(chalk206.cyan(`
|
|
29616
29749
|
## Extracting Code to New Files
|
|
29617
29750
|
`));
|
|
29618
29751
|
console.error(
|
|
29619
|
-
|
|
29752
|
+
chalk206.cyan(
|
|
29620
29753
|
` When extracting logic from one file to another, consider where the extracted code belongs:
|
|
29621
29754
|
`
|
|
29622
29755
|
)
|
|
29623
29756
|
);
|
|
29624
29757
|
console.error(
|
|
29625
|
-
|
|
29758
|
+
chalk206.cyan(
|
|
29626
29759
|
` 1. Keep related logic together: If the extracted code is tightly coupled to the
|
|
29627
29760
|
original file's domain, create a new folder containing both the original and extracted files.
|
|
29628
29761
|
`
|
|
29629
29762
|
)
|
|
29630
29763
|
);
|
|
29631
29764
|
console.error(
|
|
29632
|
-
|
|
29765
|
+
chalk206.cyan(
|
|
29633
29766
|
` 2. Share common utilities: If the extracted code can be reused across multiple
|
|
29634
29767
|
domains, move it to a common/shared folder.
|
|
29635
29768
|
`
|
|
@@ -29785,7 +29918,7 @@ async function check(pattern2, options2) {
|
|
|
29785
29918
|
|
|
29786
29919
|
// src/commands/refactor/extract/index.ts
|
|
29787
29920
|
import path55 from "path";
|
|
29788
|
-
import
|
|
29921
|
+
import chalk209 from "chalk";
|
|
29789
29922
|
|
|
29790
29923
|
// src/commands/refactor/extract/applyExtraction.ts
|
|
29791
29924
|
import { SyntaxKind as SyntaxKind4 } from "ts-morph";
|
|
@@ -30384,23 +30517,23 @@ function buildPlan2(functionName, sourceFile, sourcePath, destPath, project) {
|
|
|
30384
30517
|
|
|
30385
30518
|
// src/commands/refactor/extract/displayPlan.ts
|
|
30386
30519
|
import path51 from "path";
|
|
30387
|
-
import
|
|
30520
|
+
import chalk207 from "chalk";
|
|
30388
30521
|
function section(title) {
|
|
30389
30522
|
return `
|
|
30390
|
-
${
|
|
30523
|
+
${chalk207.cyan(title)}`;
|
|
30391
30524
|
}
|
|
30392
30525
|
function displayImporters(plan2, cwd) {
|
|
30393
30526
|
if (plan2.importersToUpdate.length === 0) return;
|
|
30394
30527
|
console.log(section("Update importers:"));
|
|
30395
30528
|
for (const imp of plan2.importersToUpdate) {
|
|
30396
30529
|
const rel = path51.relative(cwd, imp.file.getFilePath());
|
|
30397
|
-
console.log(` ${
|
|
30530
|
+
console.log(` ${chalk207.dim(rel)}: \u2192 import from "${imp.relPath}"`);
|
|
30398
30531
|
}
|
|
30399
30532
|
}
|
|
30400
30533
|
function displayPlan(functionName, relDest, plan2, cwd) {
|
|
30401
|
-
console.log(
|
|
30534
|
+
console.log(chalk207.bold(`Extract: ${functionName} \u2192 ${relDest}
|
|
30402
30535
|
`));
|
|
30403
|
-
console.log(` ${
|
|
30536
|
+
console.log(` ${chalk207.cyan("Functions to move:")}`);
|
|
30404
30537
|
for (const name of plan2.extractedNames) {
|
|
30405
30538
|
console.log(` ${name}`);
|
|
30406
30539
|
}
|
|
@@ -30434,7 +30567,7 @@ function displayPlan(functionName, relDest, plan2, cwd) {
|
|
|
30434
30567
|
|
|
30435
30568
|
// src/commands/refactor/extract/loadProjectFile.ts
|
|
30436
30569
|
import path54 from "path";
|
|
30437
|
-
import
|
|
30570
|
+
import chalk208 from "chalk";
|
|
30438
30571
|
import { Project as Project4 } from "ts-morph";
|
|
30439
30572
|
|
|
30440
30573
|
// src/commands/refactor/extract/findTsConfig.ts
|
|
@@ -30526,7 +30659,7 @@ function loadProjectFile(file) {
|
|
|
30526
30659
|
});
|
|
30527
30660
|
const sourceFile = project.getSourceFile(sourcePath);
|
|
30528
30661
|
if (!sourceFile) {
|
|
30529
|
-
console.log(
|
|
30662
|
+
console.log(chalk208.red(`File not found in project: ${file}`));
|
|
30530
30663
|
process.exit(1);
|
|
30531
30664
|
}
|
|
30532
30665
|
return { project, sourceFile };
|
|
@@ -30549,19 +30682,19 @@ async function extract(file, functionName, destination, options2 = {}) {
|
|
|
30549
30682
|
displayPlan(functionName, relDest, plan2, cwd);
|
|
30550
30683
|
if (options2.apply) {
|
|
30551
30684
|
await applyExtraction(functionName, sourceFile, destPath, plan2, project);
|
|
30552
|
-
console.log(
|
|
30685
|
+
console.log(chalk209.green("\nExtraction complete"));
|
|
30553
30686
|
} else {
|
|
30554
|
-
console.log(
|
|
30687
|
+
console.log(chalk209.dim("\nDry run. Use --apply to execute."));
|
|
30555
30688
|
}
|
|
30556
30689
|
}
|
|
30557
30690
|
|
|
30558
30691
|
// src/commands/refactor/ignore.ts
|
|
30559
30692
|
import fs34 from "fs";
|
|
30560
|
-
import
|
|
30693
|
+
import chalk210 from "chalk";
|
|
30561
30694
|
var REFACTOR_YML_PATH2 = "refactor.yml";
|
|
30562
30695
|
function ignore2(file) {
|
|
30563
30696
|
if (!fs34.existsSync(file)) {
|
|
30564
|
-
console.error(
|
|
30697
|
+
console.error(chalk210.red(`Error: File does not exist: ${file}`));
|
|
30565
30698
|
process.exit(1);
|
|
30566
30699
|
}
|
|
30567
30700
|
const content = fs34.readFileSync(file, "utf8");
|
|
@@ -30577,7 +30710,7 @@ function ignore2(file) {
|
|
|
30577
30710
|
fs34.writeFileSync(REFACTOR_YML_PATH2, entry);
|
|
30578
30711
|
}
|
|
30579
30712
|
console.log(
|
|
30580
|
-
|
|
30713
|
+
chalk210.green(
|
|
30581
30714
|
`Added ${file} to refactor ignore list (max ${maxLines} lines)`
|
|
30582
30715
|
)
|
|
30583
30716
|
);
|
|
@@ -30586,12 +30719,12 @@ function ignore2(file) {
|
|
|
30586
30719
|
// src/commands/refactor/rename/index.ts
|
|
30587
30720
|
import fs37 from "fs";
|
|
30588
30721
|
import path60 from "path";
|
|
30589
|
-
import
|
|
30722
|
+
import chalk213 from "chalk";
|
|
30590
30723
|
|
|
30591
30724
|
// src/commands/refactor/rename/applyRename.ts
|
|
30592
30725
|
import fs36 from "fs";
|
|
30593
30726
|
import path57 from "path";
|
|
30594
|
-
import
|
|
30727
|
+
import chalk211 from "chalk";
|
|
30595
30728
|
|
|
30596
30729
|
// src/commands/refactor/restructure/computeRewrites/index.ts
|
|
30597
30730
|
import path56 from "path";
|
|
@@ -30696,13 +30829,13 @@ function applyRename(rewrites, sourcePath, destPath, cwd) {
|
|
|
30696
30829
|
const updatedContents = applyRewrites(rewrites);
|
|
30697
30830
|
for (const [file, content] of updatedContents) {
|
|
30698
30831
|
fs36.writeFileSync(file, content, "utf8");
|
|
30699
|
-
console.log(
|
|
30832
|
+
console.log(chalk211.cyan(` Updated imports in ${path57.relative(cwd, file)}`));
|
|
30700
30833
|
}
|
|
30701
30834
|
const destDir = path57.dirname(destPath);
|
|
30702
30835
|
if (!fs36.existsSync(destDir)) fs36.mkdirSync(destDir, { recursive: true });
|
|
30703
30836
|
fs36.renameSync(sourcePath, destPath);
|
|
30704
30837
|
console.log(
|
|
30705
|
-
|
|
30838
|
+
chalk211.white(
|
|
30706
30839
|
` Moved ${path57.relative(cwd, sourcePath)} \u2192 ${path57.relative(cwd, destPath)}`
|
|
30707
30840
|
)
|
|
30708
30841
|
);
|
|
@@ -30789,16 +30922,16 @@ function computeRenameRewrites(sourcePath, destPath) {
|
|
|
30789
30922
|
|
|
30790
30923
|
// src/commands/refactor/rename/printRenamePreview.ts
|
|
30791
30924
|
import path59 from "path";
|
|
30792
|
-
import
|
|
30925
|
+
import chalk212 from "chalk";
|
|
30793
30926
|
function printRenamePreview(rewrites, cwd) {
|
|
30794
30927
|
for (const rewrite of rewrites) {
|
|
30795
30928
|
console.log(
|
|
30796
|
-
|
|
30929
|
+
chalk212.dim(
|
|
30797
30930
|
` ${path59.relative(cwd, rewrite.file)}: ${rewrite.oldSpecifier} \u2192 ${rewrite.newSpecifier}`
|
|
30798
30931
|
)
|
|
30799
30932
|
);
|
|
30800
30933
|
}
|
|
30801
|
-
console.log(
|
|
30934
|
+
console.log(chalk212.dim("Dry run. Use --apply to execute."));
|
|
30802
30935
|
}
|
|
30803
30936
|
|
|
30804
30937
|
// src/commands/refactor/rename/index.ts
|
|
@@ -30809,20 +30942,20 @@ async function rename(source, destination, options2 = {}) {
|
|
|
30809
30942
|
const relSource = path60.relative(cwd, sourcePath);
|
|
30810
30943
|
const relDest = path60.relative(cwd, destPath);
|
|
30811
30944
|
if (!fs37.existsSync(sourcePath)) {
|
|
30812
|
-
console.log(
|
|
30945
|
+
console.log(chalk213.red(`File not found: ${source}`));
|
|
30813
30946
|
process.exit(1);
|
|
30814
30947
|
}
|
|
30815
30948
|
if (destPath !== sourcePath && fs37.existsSync(destPath)) {
|
|
30816
|
-
console.log(
|
|
30949
|
+
console.log(chalk213.red(`Destination already exists: ${destination}`));
|
|
30817
30950
|
process.exit(1);
|
|
30818
30951
|
}
|
|
30819
|
-
console.log(
|
|
30820
|
-
console.log(
|
|
30821
|
-
console.log(
|
|
30952
|
+
console.log(chalk213.bold(`Rename: ${relSource} \u2192 ${relDest}`));
|
|
30953
|
+
console.log(chalk213.dim("Loading project..."));
|
|
30954
|
+
console.log(chalk213.dim("Scanning imports across the project..."));
|
|
30822
30955
|
const rewrites = computeRenameRewrites(sourcePath, destPath);
|
|
30823
30956
|
const affectedFiles = new Set(rewrites.map((r) => r.file)).size;
|
|
30824
30957
|
console.log(
|
|
30825
|
-
|
|
30958
|
+
chalk213.dim(
|
|
30826
30959
|
`${rewrites.length} import path(s) to update across ${affectedFiles} file(s)`
|
|
30827
30960
|
)
|
|
30828
30961
|
);
|
|
@@ -30831,11 +30964,11 @@ async function rename(source, destination, options2 = {}) {
|
|
|
30831
30964
|
return;
|
|
30832
30965
|
}
|
|
30833
30966
|
applyRename(rewrites, sourcePath, destPath, cwd);
|
|
30834
|
-
console.log(
|
|
30967
|
+
console.log(chalk213.green("Done"));
|
|
30835
30968
|
}
|
|
30836
30969
|
|
|
30837
30970
|
// src/commands/refactor/renameSymbol/index.ts
|
|
30838
|
-
import
|
|
30971
|
+
import chalk214 from "chalk";
|
|
30839
30972
|
|
|
30840
30973
|
// src/commands/refactor/renameSymbol/findSymbol.ts
|
|
30841
30974
|
import { SyntaxKind as SyntaxKind15 } from "ts-morph";
|
|
@@ -30881,33 +31014,33 @@ async function renameSymbol(file, oldName, newName, options2 = {}) {
|
|
|
30881
31014
|
const { project, sourceFile } = loadProjectFile(file);
|
|
30882
31015
|
const symbol = findSymbol(sourceFile, oldName);
|
|
30883
31016
|
if (!symbol) {
|
|
30884
|
-
console.log(
|
|
31017
|
+
console.log(chalk214.red(`Symbol "${oldName}" not found in ${file}`));
|
|
30885
31018
|
process.exit(1);
|
|
30886
31019
|
}
|
|
30887
31020
|
const grouped = groupReferences(symbol, cwd);
|
|
30888
31021
|
const totalRefs = [...grouped.values()].reduce((s, l) => s + l.length, 0);
|
|
30889
31022
|
console.log(
|
|
30890
|
-
|
|
31023
|
+
chalk214.bold(`Rename: ${oldName} \u2192 ${newName} (${totalRefs} references)
|
|
30891
31024
|
`)
|
|
30892
31025
|
);
|
|
30893
31026
|
for (const [refFile, lines2] of grouped) {
|
|
30894
31027
|
console.log(
|
|
30895
|
-
` ${
|
|
31028
|
+
` ${chalk214.dim(refFile)}: lines ${chalk214.cyan(lines2.join(", "))}`
|
|
30896
31029
|
);
|
|
30897
31030
|
}
|
|
30898
31031
|
if (options2.apply) {
|
|
30899
31032
|
symbol.rename(newName);
|
|
30900
31033
|
await project.save();
|
|
30901
|
-
console.log(
|
|
31034
|
+
console.log(chalk214.green(`
|
|
30902
31035
|
Renamed ${oldName} \u2192 ${newName}`));
|
|
30903
31036
|
} else {
|
|
30904
|
-
console.log(
|
|
31037
|
+
console.log(chalk214.dim("\nDry run. Use --apply to execute."));
|
|
30905
31038
|
}
|
|
30906
31039
|
}
|
|
30907
31040
|
|
|
30908
31041
|
// src/commands/refactor/restructure/index.ts
|
|
30909
31042
|
import path68 from "path";
|
|
30910
|
-
import
|
|
31043
|
+
import chalk217 from "chalk";
|
|
30911
31044
|
|
|
30912
31045
|
// src/commands/refactor/restructure/clusterDirectories.ts
|
|
30913
31046
|
import path62 from "path";
|
|
@@ -30986,50 +31119,50 @@ function clusterFiles(graph) {
|
|
|
30986
31119
|
|
|
30987
31120
|
// src/commands/refactor/restructure/displayPlan.ts
|
|
30988
31121
|
import path64 from "path";
|
|
30989
|
-
import
|
|
31122
|
+
import chalk215 from "chalk";
|
|
30990
31123
|
function relPath(filePath) {
|
|
30991
31124
|
return path64.relative(process.cwd(), filePath);
|
|
30992
31125
|
}
|
|
30993
31126
|
function displayMoves(plan2) {
|
|
30994
31127
|
if (plan2.moves.length === 0) return;
|
|
30995
|
-
console.log(
|
|
31128
|
+
console.log(chalk215.bold("\nFile moves:"));
|
|
30996
31129
|
for (const move2 of plan2.moves) {
|
|
30997
31130
|
console.log(
|
|
30998
|
-
` ${
|
|
31131
|
+
` ${chalk215.red(relPath(move2.from))} \u2192 ${chalk215.green(relPath(move2.to))}`
|
|
30999
31132
|
);
|
|
31000
|
-
console.log(
|
|
31133
|
+
console.log(chalk215.dim(` ${move2.reason}`));
|
|
31001
31134
|
}
|
|
31002
31135
|
}
|
|
31003
31136
|
function displayRewrites(rewrites) {
|
|
31004
31137
|
if (rewrites.length === 0) return;
|
|
31005
31138
|
const affectedFiles = new Set(rewrites.map((r) => r.file));
|
|
31006
|
-
console.log(
|
|
31139
|
+
console.log(chalk215.bold(`
|
|
31007
31140
|
Import rewrites (${affectedFiles.size} files):`));
|
|
31008
31141
|
for (const file of affectedFiles) {
|
|
31009
|
-
console.log(` ${
|
|
31142
|
+
console.log(` ${chalk215.cyan(relPath(file))}:`);
|
|
31010
31143
|
for (const { oldSpecifier, newSpecifier } of rewrites.filter(
|
|
31011
31144
|
(r) => r.file === file
|
|
31012
31145
|
)) {
|
|
31013
31146
|
console.log(
|
|
31014
|
-
` ${
|
|
31147
|
+
` ${chalk215.red(`"${oldSpecifier}"`)} \u2192 ${chalk215.green(`"${newSpecifier}"`)}`
|
|
31015
31148
|
);
|
|
31016
31149
|
}
|
|
31017
31150
|
}
|
|
31018
31151
|
}
|
|
31019
31152
|
function displayPlan2(plan2) {
|
|
31020
31153
|
if (plan2.warnings.length > 0) {
|
|
31021
|
-
console.log(
|
|
31022
|
-
for (const w of plan2.warnings) console.log(
|
|
31154
|
+
console.log(chalk215.yellow("\nWarnings:"));
|
|
31155
|
+
for (const w of plan2.warnings) console.log(chalk215.yellow(` ${w}`));
|
|
31023
31156
|
}
|
|
31024
31157
|
if (plan2.newDirectories.length > 0) {
|
|
31025
|
-
console.log(
|
|
31158
|
+
console.log(chalk215.bold("\nNew directories:"));
|
|
31026
31159
|
for (const dir of plan2.newDirectories)
|
|
31027
|
-
console.log(
|
|
31160
|
+
console.log(chalk215.green(` ${dir}/`));
|
|
31028
31161
|
}
|
|
31029
31162
|
displayMoves(plan2);
|
|
31030
31163
|
displayRewrites(plan2.rewrites);
|
|
31031
31164
|
console.log(
|
|
31032
|
-
|
|
31165
|
+
chalk215.dim(
|
|
31033
31166
|
`
|
|
31034
31167
|
Summary: ${plan2.moves.length} file(s) moved, ${plan2.rewrites.length} imports rewritten`
|
|
31035
31168
|
)
|
|
@@ -31039,18 +31172,18 @@ Summary: ${plan2.moves.length} file(s) moved, ${plan2.rewrites.length} imports r
|
|
|
31039
31172
|
// src/commands/refactor/restructure/executePlan.ts
|
|
31040
31173
|
import fs38 from "fs";
|
|
31041
31174
|
import path65 from "path";
|
|
31042
|
-
import
|
|
31175
|
+
import chalk216 from "chalk";
|
|
31043
31176
|
function executePlan(plan2) {
|
|
31044
31177
|
const updatedContents = applyRewrites(plan2.rewrites);
|
|
31045
31178
|
for (const [file, content] of updatedContents) {
|
|
31046
31179
|
fs38.writeFileSync(file, content, "utf8");
|
|
31047
31180
|
console.log(
|
|
31048
|
-
|
|
31181
|
+
chalk216.cyan(` Rewrote imports in ${path65.relative(process.cwd(), file)}`)
|
|
31049
31182
|
);
|
|
31050
31183
|
}
|
|
31051
31184
|
for (const dir of plan2.newDirectories) {
|
|
31052
31185
|
fs38.mkdirSync(dir, { recursive: true });
|
|
31053
|
-
console.log(
|
|
31186
|
+
console.log(chalk216.green(` Created ${path65.relative(process.cwd(), dir)}/`));
|
|
31054
31187
|
}
|
|
31055
31188
|
for (const move2 of plan2.moves) {
|
|
31056
31189
|
const targetDir = path65.dirname(move2.to);
|
|
@@ -31059,7 +31192,7 @@ function executePlan(plan2) {
|
|
|
31059
31192
|
}
|
|
31060
31193
|
fs38.renameSync(move2.from, move2.to);
|
|
31061
31194
|
console.log(
|
|
31062
|
-
|
|
31195
|
+
chalk216.white(
|
|
31063
31196
|
` Moved ${path65.relative(process.cwd(), move2.from)} \u2192 ${path65.relative(process.cwd(), move2.to)}`
|
|
31064
31197
|
)
|
|
31065
31198
|
);
|
|
@@ -31074,7 +31207,7 @@ function removeEmptyDirectories(dirs) {
|
|
|
31074
31207
|
if (entries.length === 0) {
|
|
31075
31208
|
fs38.rmdirSync(dir);
|
|
31076
31209
|
console.log(
|
|
31077
|
-
|
|
31210
|
+
chalk216.dim(
|
|
31078
31211
|
` Removed empty directory ${path65.relative(process.cwd(), dir)}`
|
|
31079
31212
|
)
|
|
31080
31213
|
);
|
|
@@ -31207,22 +31340,22 @@ async function restructure(pattern2, options2 = {}) {
|
|
|
31207
31340
|
const targetPattern = pattern2 ?? "src";
|
|
31208
31341
|
const files = findSourceFiles(targetPattern);
|
|
31209
31342
|
if (files.length === 0) {
|
|
31210
|
-
console.log(
|
|
31343
|
+
console.log(chalk217.yellow("No files found matching pattern"));
|
|
31211
31344
|
return;
|
|
31212
31345
|
}
|
|
31213
31346
|
const tsConfigPath = findTsConfig(path68.resolve(files[0]));
|
|
31214
31347
|
const plan2 = buildPlan3(files, tsConfigPath);
|
|
31215
31348
|
if (plan2.moves.length === 0) {
|
|
31216
|
-
console.log(
|
|
31349
|
+
console.log(chalk217.green("No restructuring needed"));
|
|
31217
31350
|
return;
|
|
31218
31351
|
}
|
|
31219
31352
|
displayPlan2(plan2);
|
|
31220
31353
|
if (options2.apply) {
|
|
31221
|
-
console.log(
|
|
31354
|
+
console.log(chalk217.bold("\nApplying changes..."));
|
|
31222
31355
|
executePlan(plan2);
|
|
31223
|
-
console.log(
|
|
31356
|
+
console.log(chalk217.green("\nRestructuring complete"));
|
|
31224
31357
|
} else {
|
|
31225
|
-
console.log(
|
|
31358
|
+
console.log(chalk217.dim("\nDry run. Use --apply to execute."));
|
|
31226
31359
|
}
|
|
31227
31360
|
}
|
|
31228
31361
|
|
|
@@ -31276,7 +31409,7 @@ async function checkoutOnlySession(number) {
|
|
|
31276
31409
|
}
|
|
31277
31410
|
|
|
31278
31411
|
// src/commands/review/highLevel/configureHighLevelReview.ts
|
|
31279
|
-
import
|
|
31412
|
+
import chalk221 from "chalk";
|
|
31280
31413
|
|
|
31281
31414
|
// src/commands/config/promptConfigScope.ts
|
|
31282
31415
|
import Enquirer3 from "enquirer";
|
|
@@ -31302,7 +31435,7 @@ async function promptConfigScope() {
|
|
|
31302
31435
|
}
|
|
31303
31436
|
|
|
31304
31437
|
// src/commands/config/resolveConfigKeyAnswer.ts
|
|
31305
|
-
import
|
|
31438
|
+
import chalk218 from "chalk";
|
|
31306
31439
|
async function resolveConfigKeyAnswer(question, supplied) {
|
|
31307
31440
|
if (supplied !== void 0) return coerceSupplied(question.key, supplied);
|
|
31308
31441
|
for (; ; ) {
|
|
@@ -31310,7 +31443,7 @@ async function resolveConfigKeyAnswer(question, supplied) {
|
|
|
31310
31443
|
if (answer === "") return void 0;
|
|
31311
31444
|
const coercion = coerceCliConfigValue(question.key, answer);
|
|
31312
31445
|
if (coercion.ok) return coercion.value;
|
|
31313
|
-
console.error(
|
|
31446
|
+
console.error(chalk218.red(coercion.error));
|
|
31314
31447
|
}
|
|
31315
31448
|
}
|
|
31316
31449
|
function coerceSupplied(key, supplied) {
|
|
@@ -31412,7 +31545,7 @@ function suggestGlobs(current, proposed) {
|
|
|
31412
31545
|
}
|
|
31413
31546
|
|
|
31414
31547
|
// src/commands/review/highLevel/parseConfigureAnswers.ts
|
|
31415
|
-
import
|
|
31548
|
+
import chalk219 from "chalk";
|
|
31416
31549
|
function parseConfigureAnswers(answers) {
|
|
31417
31550
|
const known = Object.values(highLevelConfigKeys);
|
|
31418
31551
|
const parsed = {};
|
|
@@ -31430,13 +31563,13 @@ function answersCoverEveryKey(answers) {
|
|
|
31430
31563
|
return Object.values(highLevelConfigKeys).every((key) => key in answers);
|
|
31431
31564
|
}
|
|
31432
31565
|
function exitWith(message3) {
|
|
31433
|
-
console.error(
|
|
31566
|
+
console.error(chalk219.red(`Error: ${message3}.`));
|
|
31434
31567
|
process.exit(1);
|
|
31435
31568
|
}
|
|
31436
31569
|
|
|
31437
31570
|
// src/commands/review/highLevel/proposeHighLevelGlobs.ts
|
|
31438
31571
|
import { execFileSync as execFileSync19 } from "child_process";
|
|
31439
|
-
import
|
|
31572
|
+
import chalk220 from "chalk";
|
|
31440
31573
|
|
|
31441
31574
|
// src/commands/review/highLevel/buildGlobProposalPrompt.ts
|
|
31442
31575
|
function buildGlobProposalPrompt(tree) {
|
|
@@ -31529,12 +31662,12 @@ function proposeHighLevelGlobs(cwd = process.cwd()) {
|
|
|
31529
31662
|
const tree = summariseRepoTree(cwd);
|
|
31530
31663
|
if (tree === "") return NOTHING_PROPOSED;
|
|
31531
31664
|
console.log(
|
|
31532
|
-
|
|
31665
|
+
chalk220.dim("Asking Claude to propose globs from the repo's own tree...")
|
|
31533
31666
|
);
|
|
31534
31667
|
const output = askClaude(buildGlobProposalPrompt(tree), cwd);
|
|
31535
31668
|
if (output === void 0) {
|
|
31536
31669
|
console.log(
|
|
31537
|
-
|
|
31670
|
+
chalk220.yellow(
|
|
31538
31671
|
"Claude proposed nothing; answer each key from its current value."
|
|
31539
31672
|
)
|
|
31540
31673
|
);
|
|
@@ -31590,25 +31723,25 @@ function asConfigKeyScope(value) {
|
|
|
31590
31723
|
function reportConfigured(result) {
|
|
31591
31724
|
for (const write of result.written)
|
|
31592
31725
|
console.log(
|
|
31593
|
-
|
|
31726
|
+
chalk221.green(`Set ${write.key} = ${JSON.stringify(write.value)}`)
|
|
31594
31727
|
);
|
|
31595
|
-
for (const key of result.skipped) console.log(
|
|
31596
|
-
console.log(
|
|
31728
|
+
for (const key of result.skipped) console.log(chalk221.dim(`Left ${key} unset`));
|
|
31729
|
+
console.log(chalk221.dim(`Written to ${result.target}`));
|
|
31597
31730
|
}
|
|
31598
31731
|
|
|
31599
31732
|
// src/commands/review/highLevel/announceSavedReview.ts
|
|
31600
|
-
import
|
|
31733
|
+
import chalk222 from "chalk";
|
|
31601
31734
|
function announceSavedReview(subject, force) {
|
|
31602
31735
|
const head = subject.headSha.slice(0, 7);
|
|
31603
31736
|
if (subject.saved)
|
|
31604
31737
|
console.log(
|
|
31605
|
-
|
|
31738
|
+
chalk222.dim(
|
|
31606
31739
|
`Reopening the review saved for ${head} at ${subject.saved.reviewedAt} (${subject.saved.verdict}); pass --force to start fresh.`
|
|
31607
31740
|
)
|
|
31608
31741
|
);
|
|
31609
31742
|
else if (force)
|
|
31610
31743
|
console.log(
|
|
31611
|
-
|
|
31744
|
+
chalk222.dim(
|
|
31612
31745
|
`Discarding any review saved for ${head} and starting fresh (--force).`
|
|
31613
31746
|
)
|
|
31614
31747
|
);
|
|
@@ -32147,55 +32280,55 @@ async function openHighLevelOverlay(sessionId, subject) {
|
|
|
32147
32280
|
}
|
|
32148
32281
|
|
|
32149
32282
|
// src/commands/review/highLevel/printHighLevelChecklist.ts
|
|
32150
|
-
import
|
|
32283
|
+
import chalk226 from "chalk";
|
|
32151
32284
|
|
|
32152
32285
|
// src/commands/review/highLevel/formatCriticalDiffs.ts
|
|
32153
|
-
import
|
|
32286
|
+
import chalk223 from "chalk";
|
|
32154
32287
|
var PATCH_LINE_COLOURS = {
|
|
32155
|
-
"+":
|
|
32156
|
-
"-":
|
|
32157
|
-
"@":
|
|
32288
|
+
"+": chalk223.green,
|
|
32289
|
+
"-": chalk223.red,
|
|
32290
|
+
"@": chalk223.cyan
|
|
32158
32291
|
};
|
|
32159
32292
|
function formatPatch(patch2) {
|
|
32160
32293
|
return patch2.split("\n").map(
|
|
32161
|
-
(line) => ` ${(PATCH_LINE_COLOURS[line[0] ?? ""] ??
|
|
32294
|
+
(line) => ` ${(PATCH_LINE_COLOURS[line[0] ?? ""] ?? chalk223.dim)(line)}`
|
|
32162
32295
|
);
|
|
32163
32296
|
}
|
|
32164
32297
|
function formatDiff(diff3) {
|
|
32165
32298
|
return [
|
|
32166
32299
|
"",
|
|
32167
|
-
` ${
|
|
32168
|
-
...diff3.patch === null ? [` ${
|
|
32300
|
+
` ${chalk223.bold(diff3.path)} ${chalk223.dim(`(${diff3.status})`)} ${chalk223.green(`+${diff3.additions}`)} ${chalk223.red(`-${diff3.deletions}`)}`,
|
|
32301
|
+
...diff3.patch === null ? [` ${chalk223.dim(`no diff available; see ${diff3.diffUrl}`)}`] : formatPatch(diff3.patch)
|
|
32169
32302
|
];
|
|
32170
32303
|
}
|
|
32171
32304
|
function formatCriticalDiffs(diffs, criticalPaths) {
|
|
32172
32305
|
if (criticalPaths.length === 0)
|
|
32173
|
-
return `${
|
|
32174
|
-
${
|
|
32306
|
+
return `${chalk223.bold.underline("Critical diffs")}
|
|
32307
|
+
${chalk223.dim("review.highLevel.criticalPaths is unset, so no diffs are shown")}`;
|
|
32175
32308
|
if (diffs.length === 0)
|
|
32176
|
-
return `${
|
|
32177
|
-
${
|
|
32309
|
+
return `${chalk223.bold.underline("Critical diffs")}
|
|
32310
|
+
${chalk223.dim(`no changed file matches ${criticalPaths.join(", ")}`)}`;
|
|
32178
32311
|
return [
|
|
32179
|
-
|
|
32312
|
+
chalk223.bold.underline("Critical diffs"),
|
|
32180
32313
|
...diffs.flatMap(formatDiff)
|
|
32181
32314
|
].join("\n");
|
|
32182
32315
|
}
|
|
32183
32316
|
|
|
32184
32317
|
// src/commands/review/highLevel/formatHighLevelChecklist.ts
|
|
32185
|
-
import
|
|
32318
|
+
import chalk224 from "chalk";
|
|
32186
32319
|
var MARKERS = {
|
|
32187
|
-
pass: () =>
|
|
32188
|
-
fail: () =>
|
|
32189
|
-
manual: () =>
|
|
32320
|
+
pass: () => chalk224.green("\u2714"),
|
|
32321
|
+
fail: () => chalk224.red("\u2718"),
|
|
32322
|
+
manual: () => chalk224.yellow("\u25A1")
|
|
32190
32323
|
};
|
|
32191
32324
|
function formatCheck(check2) {
|
|
32192
|
-
const title = check2.status === "fail" ?
|
|
32325
|
+
const title = check2.status === "fail" ? chalk224.red(check2.title) : chalk224.bold(check2.title);
|
|
32193
32326
|
return ` ${MARKERS[check2.status]()} ${title}
|
|
32194
|
-
${
|
|
32327
|
+
${chalk224.dim(check2.reason)}`;
|
|
32195
32328
|
}
|
|
32196
32329
|
function formatGroup(heading2, checks2) {
|
|
32197
32330
|
if (checks2.length === 0) return [];
|
|
32198
|
-
return ["",
|
|
32331
|
+
return ["", chalk224.bold.underline(heading2), ...checks2.map(formatCheck)];
|
|
32199
32332
|
}
|
|
32200
32333
|
function formatHighLevelChecklist(checks2) {
|
|
32201
32334
|
const deterministic = checks2.filter(
|
|
@@ -32204,7 +32337,7 @@ function formatHighLevelChecklist(checks2) {
|
|
|
32204
32337
|
const failed2 = deterministic.filter(
|
|
32205
32338
|
(check2) => check2.status === "fail"
|
|
32206
32339
|
).length;
|
|
32207
|
-
const summary = failed2 === 0 ?
|
|
32340
|
+
const summary = failed2 === 0 ? chalk224.green(`All ${deterministic.length} deterministic checks pass`) : chalk224.red(
|
|
32208
32341
|
`${failed2} of ${deterministic.length} deterministic checks fail`
|
|
32209
32342
|
);
|
|
32210
32343
|
return [
|
|
@@ -32219,30 +32352,30 @@ function formatHighLevelChecklist(checks2) {
|
|
|
32219
32352
|
}
|
|
32220
32353
|
|
|
32221
32354
|
// src/commands/review/highLevel/formatHighLevelStructure.ts
|
|
32222
|
-
import
|
|
32355
|
+
import chalk225 from "chalk";
|
|
32223
32356
|
var STATUS_MARKERS = {
|
|
32224
|
-
added: () =>
|
|
32225
|
-
removed: () =>
|
|
32226
|
-
modified: () =>
|
|
32357
|
+
added: () => chalk225.green("A"),
|
|
32358
|
+
removed: () => chalk225.red("D"),
|
|
32359
|
+
modified: () => chalk225.yellow("M")
|
|
32227
32360
|
};
|
|
32228
32361
|
function counts(additions, deletions) {
|
|
32229
|
-
return `${
|
|
32362
|
+
return `${chalk225.green(`+${additions}`)} ${chalk225.red(`-${deletions}`)}`;
|
|
32230
32363
|
}
|
|
32231
32364
|
function formatNode(node, indent3) {
|
|
32232
32365
|
if (node.kind === "file")
|
|
32233
32366
|
return [
|
|
32234
|
-
`${indent3}${STATUS_MARKERS[node.status]()} ${node.name} ${
|
|
32367
|
+
`${indent3}${STATUS_MARKERS[node.status]()} ${node.name} ${chalk225.dim(counts(node.additions, node.deletions))}`
|
|
32235
32368
|
];
|
|
32236
32369
|
const dir = node;
|
|
32237
32370
|
return [
|
|
32238
|
-
`${indent3}${
|
|
32371
|
+
`${indent3}${chalk225.bold(`${dir.name}/`)} ${chalk225.dim(counts(dir.additions, dir.deletions))}`,
|
|
32239
32372
|
...dir.children.flatMap((child) => formatNode(child, `${indent3} `))
|
|
32240
32373
|
];
|
|
32241
32374
|
}
|
|
32242
32375
|
function formatHighLevelStructure(structure) {
|
|
32243
32376
|
const summary = `${structure.added} added \xB7 ${structure.removed} deleted \xB7 ${structure.modified} modified \xB7 ${counts(structure.additions, structure.deletions)}`;
|
|
32244
32377
|
return [
|
|
32245
|
-
|
|
32378
|
+
chalk225.bold.underline("Structure"),
|
|
32246
32379
|
` ${summary}`,
|
|
32247
32380
|
...structure.tree.flatMap((node) => formatNode(node, " "))
|
|
32248
32381
|
].join("\n");
|
|
@@ -32251,8 +32384,8 @@ function formatHighLevelStructure(structure) {
|
|
|
32251
32384
|
// src/commands/review/highLevel/printHighLevelChecklist.ts
|
|
32252
32385
|
function printHighLevelChecklist(subject) {
|
|
32253
32386
|
console.log(
|
|
32254
|
-
|
|
32255
|
-
|
|
32387
|
+
chalk226.bold(`High-level review of ${subject.repo}#${subject.prNumber}`),
|
|
32388
|
+
chalk226.dim(
|
|
32256
32389
|
`\xB7 ${highLevelChangedFileCount(subject.structure)} changed files`
|
|
32257
32390
|
)
|
|
32258
32391
|
);
|
|
@@ -32264,12 +32397,12 @@ function printHighLevelChecklist(subject) {
|
|
|
32264
32397
|
formatCriticalDiffs(subject.criticalDiffs, subject.criticalPaths)
|
|
32265
32398
|
);
|
|
32266
32399
|
console.log(
|
|
32267
|
-
|
|
32400
|
+
chalk226.dim(
|
|
32268
32401
|
"\nManual items are for the reviewer to judge; see docs/high-level-review.md."
|
|
32269
32402
|
)
|
|
32270
32403
|
);
|
|
32271
32404
|
console.log(
|
|
32272
|
-
|
|
32405
|
+
chalk226.dim(
|
|
32273
32406
|
"Run this inside an assist session to step through the checklist in the web overlay."
|
|
32274
32407
|
)
|
|
32275
32408
|
);
|
|
@@ -32903,18 +33036,18 @@ function partitionFindingsByDiff(findings, index3) {
|
|
|
32903
33036
|
}
|
|
32904
33037
|
|
|
32905
33038
|
// src/commands/review/warnOutOfDiff.ts
|
|
32906
|
-
import
|
|
33039
|
+
import chalk227 from "chalk";
|
|
32907
33040
|
function warnOutOfDiff(outOfDiff) {
|
|
32908
33041
|
if (outOfDiff.length === 0) return;
|
|
32909
33042
|
console.warn(
|
|
32910
|
-
|
|
33043
|
+
chalk227.yellow(
|
|
32911
33044
|
`Moved ${outOfDiff.length} finding(s) whose lines fall outside the PR diff into the review body (GitHub cannot anchor a comment on these):`
|
|
32912
33045
|
)
|
|
32913
33046
|
);
|
|
32914
33047
|
for (const finding of outOfDiff) {
|
|
32915
33048
|
const range = finding.startLine !== void 0 ? `${finding.startLine}-${finding.line}` : `${finding.line}`;
|
|
32916
33049
|
console.warn(
|
|
32917
|
-
` ${
|
|
33050
|
+
` ${chalk227.yellow("\xB7")} ${finding.title} ${chalk227.dim(
|
|
32918
33051
|
`(${finding.file}:${range})`
|
|
32919
33052
|
)}`
|
|
32920
33053
|
);
|
|
@@ -32938,18 +33071,18 @@ function selectInDiffFindings(lineBound, prDiff) {
|
|
|
32938
33071
|
}
|
|
32939
33072
|
|
|
32940
33073
|
// src/commands/review/warnUnlocated.ts
|
|
32941
|
-
import
|
|
33074
|
+
import chalk228 from "chalk";
|
|
32942
33075
|
function warnUnlocated(unlocated) {
|
|
32943
33076
|
if (unlocated.length === 0) return;
|
|
32944
33077
|
console.warn(
|
|
32945
|
-
|
|
33078
|
+
chalk228.yellow(
|
|
32946
33079
|
`Moved ${unlocated.length} finding(s) without a parseable file:line into the review body:`
|
|
32947
33080
|
)
|
|
32948
33081
|
);
|
|
32949
33082
|
for (const finding of unlocated) {
|
|
32950
|
-
const where = finding.location ||
|
|
33083
|
+
const where = finding.location || chalk228.dim("missing");
|
|
32951
33084
|
console.warn(
|
|
32952
|
-
` ${
|
|
33085
|
+
` ${chalk228.yellow("\xB7")} ${finding.title} ${chalk228.dim(`(${where})`)}`
|
|
32953
33086
|
);
|
|
32954
33087
|
}
|
|
32955
33088
|
}
|
|
@@ -34416,7 +34549,7 @@ function registerReview(program2) {
|
|
|
34416
34549
|
// src/commands/rules/addRule.ts
|
|
34417
34550
|
import { existsSync as existsSync70, readFileSync as readFileSync54, writeFileSync as writeFileSync43 } from "fs";
|
|
34418
34551
|
import path73 from "path";
|
|
34419
|
-
import
|
|
34552
|
+
import chalk229 from "chalk";
|
|
34420
34553
|
|
|
34421
34554
|
// src/commands/rules/insertRuleBullet.ts
|
|
34422
34555
|
function ruleBullet({ code, title, text: text18 }) {
|
|
@@ -34552,7 +34685,7 @@ function read2(file) {
|
|
|
34552
34685
|
function addRule(text18, options2) {
|
|
34553
34686
|
const rule = text18.trim();
|
|
34554
34687
|
if (rule === "") {
|
|
34555
|
-
console.error(
|
|
34688
|
+
console.error(chalk229.red("Rule text is required"));
|
|
34556
34689
|
process.exitCode = 1;
|
|
34557
34690
|
return;
|
|
34558
34691
|
}
|
|
@@ -34570,13 +34703,13 @@ function addRule(text18, options2) {
|
|
|
34570
34703
|
);
|
|
34571
34704
|
updateScopedRulesIndex(root);
|
|
34572
34705
|
console.log(
|
|
34573
|
-
`Added ${
|
|
34706
|
+
`Added ${chalk229.cyan(code)} to ${path73.relative(process.cwd(), target) || target}`
|
|
34574
34707
|
);
|
|
34575
34708
|
}
|
|
34576
34709
|
|
|
34577
34710
|
// src/commands/rules/indexRules.ts
|
|
34578
34711
|
import path74 from "path";
|
|
34579
|
-
import
|
|
34712
|
+
import chalk230 from "chalk";
|
|
34580
34713
|
function indexRules() {
|
|
34581
34714
|
const startDir = scopeDirectory(process.cwd());
|
|
34582
34715
|
const root = findRepoRoot(startDir) ?? startDir;
|
|
@@ -34584,24 +34717,24 @@ function indexRules() {
|
|
|
34584
34717
|
const rootFile = path74.relative(process.cwd(), path74.join(root, "CLAUDE.md"));
|
|
34585
34718
|
if (directories.length === 0) {
|
|
34586
34719
|
console.log(
|
|
34587
|
-
|
|
34720
|
+
chalk230.gray(`No directories carry their own \`## Rules\` under ${root}`)
|
|
34588
34721
|
);
|
|
34589
34722
|
return;
|
|
34590
34723
|
}
|
|
34591
34724
|
console.log(`Recorded in ${rootFile || "CLAUDE.md"}`);
|
|
34592
34725
|
for (const directory of directories)
|
|
34593
|
-
console.log(` ${
|
|
34726
|
+
console.log(` ${chalk230.cyan(directory)}`);
|
|
34594
34727
|
}
|
|
34595
34728
|
|
|
34596
34729
|
// src/commands/rules/listRules.ts
|
|
34597
34730
|
import path75 from "path";
|
|
34598
|
-
import
|
|
34731
|
+
import chalk231 from "chalk";
|
|
34599
34732
|
function listRules(target, options2 = {}) {
|
|
34600
34733
|
const resolved = path75.resolve(target ?? process.cwd());
|
|
34601
34734
|
const rules3 = readScopedRules(resolved);
|
|
34602
34735
|
if (rules3.length === 0) {
|
|
34603
34736
|
const label2 = path75.relative(process.cwd(), resolved) || ".";
|
|
34604
|
-
console.log(
|
|
34737
|
+
console.log(chalk231.gray(`No rules in scope for ${label2}`));
|
|
34605
34738
|
return;
|
|
34606
34739
|
}
|
|
34607
34740
|
const base = findRepoRoot(scopeDirectory(resolved));
|
|
@@ -34611,14 +34744,14 @@ function listRules(target, options2 = {}) {
|
|
|
34611
34744
|
if (rule.source !== shown) {
|
|
34612
34745
|
shown = rule.source;
|
|
34613
34746
|
console.log(
|
|
34614
|
-
|
|
34747
|
+
chalk231.dim(base ? path75.relative(base, rule.source) : rule.source)
|
|
34615
34748
|
);
|
|
34616
34749
|
}
|
|
34617
34750
|
console.log(
|
|
34618
|
-
` ${
|
|
34751
|
+
` ${chalk231.cyan(rule.code.padEnd(width))} ${rule.title ?? rule.text}`
|
|
34619
34752
|
);
|
|
34620
34753
|
if (options2.full && rule.title)
|
|
34621
|
-
console.log(` ${" ".repeat(width)} ${
|
|
34754
|
+
console.log(` ${" ".repeat(width)} ${chalk231.dim(rule.text)}`);
|
|
34622
34755
|
}
|
|
34623
34756
|
}
|
|
34624
34757
|
|
|
@@ -34647,7 +34780,7 @@ function registerRules(program2) {
|
|
|
34647
34780
|
}
|
|
34648
34781
|
|
|
34649
34782
|
// src/commands/seq/seqAuth.ts
|
|
34650
|
-
import
|
|
34783
|
+
import chalk233 from "chalk";
|
|
34651
34784
|
|
|
34652
34785
|
// src/commands/seq/loadConnections.ts
|
|
34653
34786
|
function loadConnections2() {
|
|
@@ -34676,10 +34809,10 @@ function setDefaultConnection(name) {
|
|
|
34676
34809
|
}
|
|
34677
34810
|
|
|
34678
34811
|
// src/shared/assertUniqueName.ts
|
|
34679
|
-
import
|
|
34812
|
+
import chalk232 from "chalk";
|
|
34680
34813
|
function assertUniqueName(existingNames, name) {
|
|
34681
34814
|
if (existingNames.includes(name)) {
|
|
34682
|
-
console.error(
|
|
34815
|
+
console.error(chalk232.red(`Connection "${name}" already exists.`));
|
|
34683
34816
|
process.exit(1);
|
|
34684
34817
|
}
|
|
34685
34818
|
}
|
|
@@ -34697,16 +34830,16 @@ async function promptConnection2(existingNames) {
|
|
|
34697
34830
|
var seqAuth = createConnectionAuth({
|
|
34698
34831
|
load: loadConnections2,
|
|
34699
34832
|
save: saveConnections2,
|
|
34700
|
-
format: (c) => `${
|
|
34833
|
+
format: (c) => `${chalk233.bold(c.name)} ${c.url}`,
|
|
34701
34834
|
promptNew: promptConnection2,
|
|
34702
34835
|
onFirst: (c) => setDefaultConnection(c.name)
|
|
34703
34836
|
});
|
|
34704
34837
|
|
|
34705
34838
|
// src/commands/seq/seqQuery.ts
|
|
34706
|
-
import
|
|
34839
|
+
import chalk237 from "chalk";
|
|
34707
34840
|
|
|
34708
34841
|
// src/commands/seq/fetchSeq.ts
|
|
34709
|
-
import
|
|
34842
|
+
import chalk234 from "chalk";
|
|
34710
34843
|
async function fetchSeq(conn, path91, params) {
|
|
34711
34844
|
const url = `${conn.url}${path91}?${params}`;
|
|
34712
34845
|
const response = await fetch(url, {
|
|
@@ -34717,7 +34850,7 @@ async function fetchSeq(conn, path91, params) {
|
|
|
34717
34850
|
});
|
|
34718
34851
|
if (!response.ok) {
|
|
34719
34852
|
const body = await response.text();
|
|
34720
|
-
console.error(
|
|
34853
|
+
console.error(chalk234.red(`Seq returned ${response.status}: ${body}`));
|
|
34721
34854
|
process.exit(1);
|
|
34722
34855
|
}
|
|
34723
34856
|
return response;
|
|
@@ -34776,23 +34909,23 @@ async function fetchSeqEvents(conn, params) {
|
|
|
34776
34909
|
}
|
|
34777
34910
|
|
|
34778
34911
|
// src/commands/seq/formatEvent.ts
|
|
34779
|
-
import
|
|
34912
|
+
import chalk235 from "chalk";
|
|
34780
34913
|
function levelColor(level) {
|
|
34781
34914
|
switch (level) {
|
|
34782
34915
|
case "Fatal":
|
|
34783
|
-
return
|
|
34916
|
+
return chalk235.bgRed.white;
|
|
34784
34917
|
case "Error":
|
|
34785
|
-
return
|
|
34918
|
+
return chalk235.red;
|
|
34786
34919
|
case "Warning":
|
|
34787
|
-
return
|
|
34920
|
+
return chalk235.yellow;
|
|
34788
34921
|
case "Information":
|
|
34789
|
-
return
|
|
34922
|
+
return chalk235.cyan;
|
|
34790
34923
|
case "Debug":
|
|
34791
|
-
return
|
|
34924
|
+
return chalk235.gray;
|
|
34792
34925
|
case "Verbose":
|
|
34793
|
-
return
|
|
34926
|
+
return chalk235.dim;
|
|
34794
34927
|
default:
|
|
34795
|
-
return
|
|
34928
|
+
return chalk235.white;
|
|
34796
34929
|
}
|
|
34797
34930
|
}
|
|
34798
34931
|
function levelAbbrev(level) {
|
|
@@ -34833,12 +34966,12 @@ function formatTimestamp(iso) {
|
|
|
34833
34966
|
function formatEvent(event) {
|
|
34834
34967
|
const color = levelColor(event.Level);
|
|
34835
34968
|
const abbrev = levelAbbrev(event.Level);
|
|
34836
|
-
const ts8 =
|
|
34969
|
+
const ts8 = chalk235.dim(formatTimestamp(event.Timestamp));
|
|
34837
34970
|
const msg = renderMessage(event);
|
|
34838
34971
|
const lines2 = [`${ts8} ${color(`[${abbrev}]`)} ${msg}`];
|
|
34839
34972
|
if (event.Exception) {
|
|
34840
34973
|
for (const line of event.Exception.split("\n")) {
|
|
34841
|
-
lines2.push(
|
|
34974
|
+
lines2.push(chalk235.red(` ${line}`));
|
|
34842
34975
|
}
|
|
34843
34976
|
}
|
|
34844
34977
|
return lines2.join("\n");
|
|
@@ -34871,11 +35004,11 @@ function rejectTimestampFilter(filter) {
|
|
|
34871
35004
|
}
|
|
34872
35005
|
|
|
34873
35006
|
// src/shared/resolveNamedConnection.ts
|
|
34874
|
-
import
|
|
35007
|
+
import chalk236 from "chalk";
|
|
34875
35008
|
function resolveNamedConnection(connections, requested, defaultName, kind, authCommand) {
|
|
34876
35009
|
if (connections.length === 0) {
|
|
34877
35010
|
console.error(
|
|
34878
|
-
|
|
35011
|
+
chalk236.red(
|
|
34879
35012
|
`No ${kind} connections configured. Run '${authCommand}' first.`
|
|
34880
35013
|
)
|
|
34881
35014
|
);
|
|
@@ -34884,7 +35017,7 @@ function resolveNamedConnection(connections, requested, defaultName, kind, authC
|
|
|
34884
35017
|
const target = requested ?? defaultName ?? connections[0].name;
|
|
34885
35018
|
const connection = connections.find((c) => c.name === target);
|
|
34886
35019
|
if (!connection) {
|
|
34887
|
-
console.error(
|
|
35020
|
+
console.error(chalk236.red(`${kind} connection "${target}" not found.`));
|
|
34888
35021
|
process.exit(1);
|
|
34889
35022
|
}
|
|
34890
35023
|
return connection;
|
|
@@ -34913,7 +35046,7 @@ async function seqQuery(filter, options2) {
|
|
|
34913
35046
|
new URLSearchParams({ filter, count: String(count8) })
|
|
34914
35047
|
);
|
|
34915
35048
|
if (events.length === 0) {
|
|
34916
|
-
console.log(
|
|
35049
|
+
console.log(chalk237.yellow("No events found."));
|
|
34917
35050
|
return;
|
|
34918
35051
|
}
|
|
34919
35052
|
if (options2.json) {
|
|
@@ -34924,11 +35057,11 @@ async function seqQuery(filter, options2) {
|
|
|
34924
35057
|
for (const event of chronological) {
|
|
34925
35058
|
console.log(formatEvent(event));
|
|
34926
35059
|
}
|
|
34927
|
-
console.log(
|
|
35060
|
+
console.log(chalk237.dim(`
|
|
34928
35061
|
${events.length} events`));
|
|
34929
35062
|
if (events.length >= count8) {
|
|
34930
35063
|
console.log(
|
|
34931
|
-
|
|
35064
|
+
chalk237.yellow(
|
|
34932
35065
|
`Results limited to ${count8}. Use --count to retrieve more.`
|
|
34933
35066
|
)
|
|
34934
35067
|
);
|
|
@@ -34936,10 +35069,10 @@ ${events.length} events`));
|
|
|
34936
35069
|
}
|
|
34937
35070
|
|
|
34938
35071
|
// src/shared/setNamedDefaultConnection.ts
|
|
34939
|
-
import
|
|
35072
|
+
import chalk238 from "chalk";
|
|
34940
35073
|
function setNamedDefaultConnection(connections, name, setDefault, kind) {
|
|
34941
35074
|
if (!connections.find((c) => c.name === name)) {
|
|
34942
|
-
console.error(
|
|
35075
|
+
console.error(chalk238.red(`Connection "${name}" not found.`));
|
|
34943
35076
|
process.exit(1);
|
|
34944
35077
|
}
|
|
34945
35078
|
setDefault(name);
|
|
@@ -35160,7 +35293,7 @@ function registerSlack(program2) {
|
|
|
35160
35293
|
}
|
|
35161
35294
|
|
|
35162
35295
|
// src/commands/sql/sqlAuth.ts
|
|
35163
|
-
import
|
|
35296
|
+
import chalk240 from "chalk";
|
|
35164
35297
|
|
|
35165
35298
|
// src/commands/sql/loadConnections.ts
|
|
35166
35299
|
function loadConnections3() {
|
|
@@ -35189,7 +35322,7 @@ function setDefaultConnection2(name) {
|
|
|
35189
35322
|
}
|
|
35190
35323
|
|
|
35191
35324
|
// src/commands/sql/promptConnection.ts
|
|
35192
|
-
import
|
|
35325
|
+
import chalk239 from "chalk";
|
|
35193
35326
|
async function promptConnection3(existingNames) {
|
|
35194
35327
|
const name = await promptInput("name", "Connection name:", "default");
|
|
35195
35328
|
assertUniqueName(existingNames, name);
|
|
@@ -35197,7 +35330,7 @@ async function promptConnection3(existingNames) {
|
|
|
35197
35330
|
const portStr = await promptInput("port", "Port:", "1433");
|
|
35198
35331
|
const port = Number.parseInt(portStr, 10);
|
|
35199
35332
|
if (!Number.isFinite(port)) {
|
|
35200
|
-
console.error(
|
|
35333
|
+
console.error(chalk239.red(`Invalid port "${portStr}".`));
|
|
35201
35334
|
process.exit(1);
|
|
35202
35335
|
}
|
|
35203
35336
|
const user = await promptInput("user", "User:");
|
|
@@ -35210,13 +35343,13 @@ async function promptConnection3(existingNames) {
|
|
|
35210
35343
|
var sqlAuth = createConnectionAuth({
|
|
35211
35344
|
load: loadConnections3,
|
|
35212
35345
|
save: saveConnections3,
|
|
35213
|
-
format: (c) => `${
|
|
35346
|
+
format: (c) => `${chalk240.bold(c.name)} ${c.server}:${c.port}/${c.database} (${c.user})`,
|
|
35214
35347
|
promptNew: promptConnection3,
|
|
35215
35348
|
onFirst: (c) => setDefaultConnection2(c.name)
|
|
35216
35349
|
});
|
|
35217
35350
|
|
|
35218
35351
|
// src/commands/sql/printTable.ts
|
|
35219
|
-
import
|
|
35352
|
+
import chalk241 from "chalk";
|
|
35220
35353
|
function formatCell(value) {
|
|
35221
35354
|
if (value === null || value === void 0) return "";
|
|
35222
35355
|
if (value instanceof Date) return value.toISOString();
|
|
@@ -35225,7 +35358,7 @@ function formatCell(value) {
|
|
|
35225
35358
|
}
|
|
35226
35359
|
function printTable(rows) {
|
|
35227
35360
|
if (rows.length === 0) {
|
|
35228
|
-
console.log(
|
|
35361
|
+
console.log(chalk241.yellow("(no rows)"));
|
|
35229
35362
|
return;
|
|
35230
35363
|
}
|
|
35231
35364
|
const columns = Object.keys(rows[0]);
|
|
@@ -35233,13 +35366,13 @@ function printTable(rows) {
|
|
|
35233
35366
|
(col) => Math.max(col.length, ...rows.map((r) => formatCell(r[col]).length))
|
|
35234
35367
|
);
|
|
35235
35368
|
const header = columns.map((c, i) => c.padEnd(widths[i])).join(" ");
|
|
35236
|
-
console.log(
|
|
35237
|
-
console.log(
|
|
35369
|
+
console.log(chalk241.dim(header));
|
|
35370
|
+
console.log(chalk241.dim("-".repeat(header.length)));
|
|
35238
35371
|
for (const row of rows) {
|
|
35239
35372
|
const line = columns.map((c, i) => formatCell(row[c]).padEnd(widths[i])).join(" ");
|
|
35240
35373
|
console.log(line);
|
|
35241
35374
|
}
|
|
35242
|
-
console.log(
|
|
35375
|
+
console.log(chalk241.dim(`
|
|
35243
35376
|
${rows.length} row${rows.length === 1 ? "" : "s"}`));
|
|
35244
35377
|
}
|
|
35245
35378
|
|
|
@@ -35299,7 +35432,7 @@ async function sqlColumns(table, connectionName) {
|
|
|
35299
35432
|
}
|
|
35300
35433
|
|
|
35301
35434
|
// src/commands/sql/sqlMutate.ts
|
|
35302
|
-
import
|
|
35435
|
+
import chalk242 from "chalk";
|
|
35303
35436
|
|
|
35304
35437
|
// src/commands/sql/isMutation.ts
|
|
35305
35438
|
var MUTATION_KEYWORDS = [
|
|
@@ -35333,7 +35466,7 @@ function isMutation(sql29) {
|
|
|
35333
35466
|
async function sqlMutate(query2, connectionName) {
|
|
35334
35467
|
if (!isMutation(query2)) {
|
|
35335
35468
|
console.error(
|
|
35336
|
-
|
|
35469
|
+
chalk242.red(
|
|
35337
35470
|
"assist sql mutate refuses non-mutating statements. Use `assist sql query` instead."
|
|
35338
35471
|
)
|
|
35339
35472
|
);
|
|
@@ -35343,18 +35476,18 @@ async function sqlMutate(query2, connectionName) {
|
|
|
35343
35476
|
const pool = await sqlConnect(conn);
|
|
35344
35477
|
try {
|
|
35345
35478
|
const result = await pool.request().query(query2);
|
|
35346
|
-
console.log(
|
|
35479
|
+
console.log(chalk242.dim(`${result.rowsAffected.join(", ")} row(s) affected`));
|
|
35347
35480
|
} finally {
|
|
35348
35481
|
await pool.close();
|
|
35349
35482
|
}
|
|
35350
35483
|
}
|
|
35351
35484
|
|
|
35352
35485
|
// src/commands/sql/sqlQuery.ts
|
|
35353
|
-
import
|
|
35486
|
+
import chalk243 from "chalk";
|
|
35354
35487
|
async function sqlQuery(query2, connectionName) {
|
|
35355
35488
|
if (isMutation(query2)) {
|
|
35356
35489
|
console.error(
|
|
35357
|
-
|
|
35490
|
+
chalk243.red(
|
|
35358
35491
|
"assist sql query refuses mutating statements. Use `assist sql mutate` instead."
|
|
35359
35492
|
)
|
|
35360
35493
|
);
|
|
@@ -35369,7 +35502,7 @@ async function sqlQuery(query2, connectionName) {
|
|
|
35369
35502
|
printTable(rows);
|
|
35370
35503
|
} else {
|
|
35371
35504
|
console.log(
|
|
35372
|
-
|
|
35505
|
+
chalk243.dim(`${result.rowsAffected.join(", ")} row(s) affected`)
|
|
35373
35506
|
);
|
|
35374
35507
|
}
|
|
35375
35508
|
} finally {
|
|
@@ -35743,7 +35876,7 @@ function syncPi(claudeDir, options2) {
|
|
|
35743
35876
|
// src/commands/sync/syncSettings.ts
|
|
35744
35877
|
import * as fs48 from "fs";
|
|
35745
35878
|
import * as path85 from "path";
|
|
35746
|
-
import
|
|
35879
|
+
import chalk244 from "chalk";
|
|
35747
35880
|
async function syncSettings(claudeDir, targetBase, options2) {
|
|
35748
35881
|
const source = path85.join(claudeDir, "settings.json");
|
|
35749
35882
|
const target = path85.join(targetBase, "settings.json");
|
|
@@ -35762,7 +35895,7 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
35762
35895
|
if (mergedContent !== normalizedTarget) {
|
|
35763
35896
|
if (!options2?.yes) {
|
|
35764
35897
|
console.log(
|
|
35765
|
-
|
|
35898
|
+
chalk244.yellow(
|
|
35766
35899
|
"\n\u26A0\uFE0F Warning: settings.json differs from existing file"
|
|
35767
35900
|
)
|
|
35768
35901
|
);
|
|
@@ -35770,7 +35903,7 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
35770
35903
|
printDiff(targetContent, mergedContent);
|
|
35771
35904
|
printAutoConfirmHint();
|
|
35772
35905
|
const confirm = await promptConfirm(
|
|
35773
|
-
|
|
35906
|
+
chalk244.red("Overwrite existing settings.json?"),
|
|
35774
35907
|
false
|
|
35775
35908
|
);
|
|
35776
35909
|
if (!confirm) {
|
|
@@ -37512,7 +37645,7 @@ function registerWatch(program2) {
|
|
|
37512
37645
|
|
|
37513
37646
|
// src/commands/roam/auth.ts
|
|
37514
37647
|
import { randomBytes } from "crypto";
|
|
37515
|
-
import
|
|
37648
|
+
import chalk245 from "chalk";
|
|
37516
37649
|
|
|
37517
37650
|
// src/commands/roam/waitForCallback.ts
|
|
37518
37651
|
import { createServer as createServer3 } from "http";
|
|
@@ -37643,13 +37776,13 @@ async function auth() {
|
|
|
37643
37776
|
saveGlobalConfig(config);
|
|
37644
37777
|
const state = randomBytes(16).toString("hex");
|
|
37645
37778
|
console.log(
|
|
37646
|
-
|
|
37779
|
+
chalk245.yellow("\nEnsure this Redirect URI is set in your Roam OAuth app:")
|
|
37647
37780
|
);
|
|
37648
|
-
console.log(
|
|
37649
|
-
console.log(
|
|
37650
|
-
console.log(
|
|
37781
|
+
console.log(chalk245.white("http://localhost:14523/callback\n"));
|
|
37782
|
+
console.log(chalk245.blue("Opening browser for authorization..."));
|
|
37783
|
+
console.log(chalk245.dim("Waiting for authorization callback..."));
|
|
37651
37784
|
const { code, redirectUri } = await authorizeInBrowser(clientId, state);
|
|
37652
|
-
console.log(
|
|
37785
|
+
console.log(chalk245.dim("Exchanging code for tokens..."));
|
|
37653
37786
|
const tokens = await exchangeToken({
|
|
37654
37787
|
code,
|
|
37655
37788
|
clientId,
|
|
@@ -37665,7 +37798,7 @@ async function auth() {
|
|
|
37665
37798
|
};
|
|
37666
37799
|
saveGlobalConfig(config);
|
|
37667
37800
|
console.log(
|
|
37668
|
-
|
|
37801
|
+
chalk245.green("Roam credentials and tokens saved to ~/.assist.yml")
|
|
37669
37802
|
);
|
|
37670
37803
|
}
|
|
37671
37804
|
|
|
@@ -43995,7 +44128,7 @@ async function renameSession(title) {
|
|
|
43995
44128
|
|
|
43996
44129
|
// src/commands/sessions/summarise/index.ts
|
|
43997
44130
|
import * as fs57 from "fs";
|
|
43998
|
-
import
|
|
44131
|
+
import chalk246 from "chalk";
|
|
43999
44132
|
|
|
44000
44133
|
// src/commands/sessions/summarise/shared.ts
|
|
44001
44134
|
import * as fs56 from "fs";
|
|
@@ -44054,22 +44187,22 @@ ${firstMessage}`);
|
|
|
44054
44187
|
async function summarise2(options2) {
|
|
44055
44188
|
const files = await discoverSessionFiles();
|
|
44056
44189
|
if (files.length === 0) {
|
|
44057
|
-
console.log(
|
|
44190
|
+
console.log(chalk246.yellow("No sessions found."));
|
|
44058
44191
|
return;
|
|
44059
44192
|
}
|
|
44060
44193
|
const toProcess = selectCandidates(files, options2);
|
|
44061
44194
|
if (toProcess.length === 0) {
|
|
44062
|
-
console.log(
|
|
44195
|
+
console.log(chalk246.green("All sessions already summarised."));
|
|
44063
44196
|
return;
|
|
44064
44197
|
}
|
|
44065
44198
|
console.log(
|
|
44066
|
-
|
|
44199
|
+
chalk246.cyan(
|
|
44067
44200
|
`Summarising ${toProcess.length} session(s) (${files.length} total)\u2026`
|
|
44068
44201
|
)
|
|
44069
44202
|
);
|
|
44070
44203
|
const { succeeded, failed: failed2 } = processSessions(toProcess);
|
|
44071
44204
|
console.log(
|
|
44072
|
-
|
|
44205
|
+
chalk246.green(`Done: ${succeeded} summarised`) + (failed2 > 0 ? chalk246.yellow(`, ${failed2} skipped`) : "")
|
|
44073
44206
|
);
|
|
44074
44207
|
}
|
|
44075
44208
|
function selectCandidates(files, options2) {
|
|
@@ -44089,16 +44222,16 @@ function processSessions(files) {
|
|
|
44089
44222
|
let failed2 = 0;
|
|
44090
44223
|
for (let i = 0; i < files.length; i++) {
|
|
44091
44224
|
const file = files[i];
|
|
44092
|
-
process.stdout.write(
|
|
44225
|
+
process.stdout.write(chalk246.dim(` [${i + 1}/${files.length}] `));
|
|
44093
44226
|
const summary = summariseSession(file);
|
|
44094
44227
|
if (summary) {
|
|
44095
44228
|
writeSummary(file, summary);
|
|
44096
44229
|
succeeded++;
|
|
44097
|
-
process.stdout.write(`${
|
|
44230
|
+
process.stdout.write(`${chalk246.green("\u2713")} ${summary}
|
|
44098
44231
|
`);
|
|
44099
44232
|
} else {
|
|
44100
44233
|
failed2++;
|
|
44101
|
-
process.stdout.write(` ${
|
|
44234
|
+
process.stdout.write(` ${chalk246.yellow("skip")}
|
|
44102
44235
|
`);
|
|
44103
44236
|
}
|
|
44104
44237
|
}
|
|
@@ -44125,10 +44258,10 @@ function registerSessions(program2) {
|
|
|
44125
44258
|
}
|
|
44126
44259
|
|
|
44127
44260
|
// src/reportCliError.ts
|
|
44128
|
-
import
|
|
44261
|
+
import chalk247 from "chalk";
|
|
44129
44262
|
function reportCliError(error) {
|
|
44130
44263
|
if (error instanceof InvalidItemIdError || error instanceof AmbiguousRepoConfigError || error instanceof UnknownRepoConfigError || error instanceof MissingRunCwdError || error instanceof MiroExtractError) {
|
|
44131
|
-
console.error(
|
|
44264
|
+
console.error(chalk247.red(error.message));
|
|
44132
44265
|
} else {
|
|
44133
44266
|
console.error(error);
|
|
44134
44267
|
}
|