@staff0rd/assist 0.370.1 → 0.372.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 +1 -1
- package/claude/commands/strip-comments.md +3 -1
- package/dist/commands/sessions/web/bundle.js +86 -86
- package/dist/index.js +358 -279
- 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.372.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -138,10 +138,10 @@ import { stringify as stringifyYaml } from "yaml";
|
|
|
138
138
|
// src/shared/loadRawYaml.ts
|
|
139
139
|
import { existsSync, readFileSync } from "fs";
|
|
140
140
|
import { parse as parseYaml } from "yaml";
|
|
141
|
-
function loadRawYaml(
|
|
142
|
-
if (!existsSync(
|
|
141
|
+
function loadRawYaml(path58) {
|
|
142
|
+
if (!existsSync(path58)) return {};
|
|
143
143
|
try {
|
|
144
|
-
const content = readFileSync(
|
|
144
|
+
const content = readFileSync(path58, "utf8");
|
|
145
145
|
return parseYaml(content) || {};
|
|
146
146
|
} catch {
|
|
147
147
|
return {};
|
|
@@ -1150,8 +1150,8 @@ function getPreferredRemoteRepo(cwd) {
|
|
|
1150
1150
|
function gitRefUrl(kind, ref, cwd) {
|
|
1151
1151
|
const repo = getPreferredRemoteRepo(cwd);
|
|
1152
1152
|
if (!repo) return void 0;
|
|
1153
|
-
const
|
|
1154
|
-
return `https://github.com/${repo.org}/${repo.repo}/${
|
|
1153
|
+
const path58 = kind === "branch" ? "tree" : "commit";
|
|
1154
|
+
return `https://github.com/${repo.org}/${repo.repo}/${path58}/${ref}`;
|
|
1155
1155
|
}
|
|
1156
1156
|
|
|
1157
1157
|
// src/commands/commit/collectCommitRefs.ts
|
|
@@ -2521,8 +2521,8 @@ import fs14 from "fs";
|
|
|
2521
2521
|
import { minimatch } from "minimatch";
|
|
2522
2522
|
import { Project as Project2 } from "ts-morph";
|
|
2523
2523
|
|
|
2524
|
-
// src/
|
|
2525
|
-
import
|
|
2524
|
+
// src/shared/isHashCommentFile.ts
|
|
2525
|
+
import path18 from "path";
|
|
2526
2526
|
|
|
2527
2527
|
// src/shared/isYamlFile.ts
|
|
2528
2528
|
var YAML_EXTENSIONS = [".yml", ".yaml"];
|
|
@@ -2531,6 +2531,54 @@ function isYamlFile(filePath) {
|
|
|
2531
2531
|
return YAML_EXTENSIONS.some((ext) => filePath.endsWith(ext));
|
|
2532
2532
|
}
|
|
2533
2533
|
|
|
2534
|
+
// src/shared/isHashCommentFile.ts
|
|
2535
|
+
function isShellFile(filePath) {
|
|
2536
|
+
if (!filePath) return false;
|
|
2537
|
+
return filePath.endsWith(".sh");
|
|
2538
|
+
}
|
|
2539
|
+
function isDockerfile(filePath) {
|
|
2540
|
+
if (!filePath) return false;
|
|
2541
|
+
const base = path18.basename(filePath);
|
|
2542
|
+
return base === "Dockerfile" || base.startsWith("Dockerfile.") || base.endsWith(".dockerfile");
|
|
2543
|
+
}
|
|
2544
|
+
function isEnvFile(filePath) {
|
|
2545
|
+
if (!filePath) return false;
|
|
2546
|
+
const base = path18.basename(filePath);
|
|
2547
|
+
return base === ".env" || base.endsWith(".env") || base.startsWith(".env.");
|
|
2548
|
+
}
|
|
2549
|
+
function isHashCommentFile(filePath) {
|
|
2550
|
+
return isYamlFile(filePath) || isDockerfile(filePath) || isEnvFile(filePath) || isShellFile(filePath);
|
|
2551
|
+
}
|
|
2552
|
+
|
|
2553
|
+
// src/commands/verify/blockComments/collectFileComments.ts
|
|
2554
|
+
import fs13 from "fs";
|
|
2555
|
+
|
|
2556
|
+
// src/commands/verify/blockComments/collectHashComments.ts
|
|
2557
|
+
function blankNonNewline(text9) {
|
|
2558
|
+
return text9.replace(/[^\n]/g, " ");
|
|
2559
|
+
}
|
|
2560
|
+
function isHeaderLine(line) {
|
|
2561
|
+
const trimmed = line.trim();
|
|
2562
|
+
return trimmed === "" || trimmed.startsWith("#");
|
|
2563
|
+
}
|
|
2564
|
+
function collectHashComments(content, options2) {
|
|
2565
|
+
const lines = content.split("\n");
|
|
2566
|
+
let start3 = 0;
|
|
2567
|
+
if (options2.skipHeader) {
|
|
2568
|
+
while (start3 < lines.length && isHeaderLine(lines[start3])) start3++;
|
|
2569
|
+
}
|
|
2570
|
+
const comments3 = [];
|
|
2571
|
+
for (let i = start3; i < lines.length; i++) {
|
|
2572
|
+
const work = lines[i].replace(
|
|
2573
|
+
/"(?:[^"\\]|\\.)*"|'(?:[^']|'')*'/g,
|
|
2574
|
+
blankNonNewline
|
|
2575
|
+
);
|
|
2576
|
+
const match = work.match(/(?:^|\s)(#.*)/);
|
|
2577
|
+
if (match) comments3.push({ line: i + 1, text: match[1] });
|
|
2578
|
+
}
|
|
2579
|
+
return comments3;
|
|
2580
|
+
}
|
|
2581
|
+
|
|
2534
2582
|
// src/commands/verify/blockComments/collectComments.ts
|
|
2535
2583
|
function collectComments(sourceFile) {
|
|
2536
2584
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -2551,18 +2599,6 @@ function collectComments(sourceFile) {
|
|
|
2551
2599
|
return comments3;
|
|
2552
2600
|
}
|
|
2553
2601
|
|
|
2554
|
-
// src/commands/verify/blockComments/collectYamlComments.ts
|
|
2555
|
-
import { Lexer } from "yaml";
|
|
2556
|
-
function collectYamlComments(content) {
|
|
2557
|
-
const comments3 = [];
|
|
2558
|
-
let line = 1;
|
|
2559
|
-
for (const token of new Lexer().lex(content)) {
|
|
2560
|
-
if (token.startsWith("#")) comments3.push({ line, text: token });
|
|
2561
|
-
for (const char of token) if (char === "\n") line++;
|
|
2562
|
-
}
|
|
2563
|
-
return comments3;
|
|
2564
|
-
}
|
|
2565
|
-
|
|
2566
2602
|
// src/commands/complexity/maintainability/parseMaintainabilityOverride.ts
|
|
2567
2603
|
var MAINTAINABILITY_OVERRIDE_MARKER = "assist-maintainability-override";
|
|
2568
2604
|
var OVERRIDE_MARKER = /^\s*\/\/\s*assist-maintainability-override:?\s*(-?\d+)\s*$/;
|
|
@@ -2601,21 +2637,12 @@ function isCommentExempt(text9) {
|
|
|
2601
2637
|
return MACHINE_DIRECTIVES.some((d) => lower.includes(d));
|
|
2602
2638
|
}
|
|
2603
2639
|
|
|
2604
|
-
// src/commands/verify/blockComments/
|
|
2640
|
+
// src/commands/verify/blockComments/collectSourceFindings.ts
|
|
2605
2641
|
function toSingleLine(text9) {
|
|
2606
2642
|
return text9.replace(/\s+/g, " ").trim();
|
|
2607
2643
|
}
|
|
2608
|
-
function
|
|
2644
|
+
function collectSourceFindings(file, lines, project) {
|
|
2609
2645
|
const findings = [];
|
|
2610
|
-
if (isYamlFile(file)) {
|
|
2611
|
-
for (const { line, text: text9 } of collectYamlComments(
|
|
2612
|
-
fs13.readFileSync(file, "utf8")
|
|
2613
|
-
)) {
|
|
2614
|
-
if (lines.has(line))
|
|
2615
|
-
findings.push({ file, line, text: toSingleLine(text9) });
|
|
2616
|
-
}
|
|
2617
|
-
return findings;
|
|
2618
|
-
}
|
|
2619
2646
|
const sourceFile = project.addSourceFileAtPath(file);
|
|
2620
2647
|
for (const { pos, text: text9 } of collectComments(sourceFile)) {
|
|
2621
2648
|
const { line } = sourceFile.getLineAndColumnAtPos(pos);
|
|
@@ -2626,6 +2653,42 @@ function collectFileComments(file, lines, project) {
|
|
|
2626
2653
|
return findings;
|
|
2627
2654
|
}
|
|
2628
2655
|
|
|
2656
|
+
// src/commands/verify/blockComments/collectYamlComments.ts
|
|
2657
|
+
import { Lexer } from "yaml";
|
|
2658
|
+
function collectYamlComments(content) {
|
|
2659
|
+
const comments3 = [];
|
|
2660
|
+
let line = 1;
|
|
2661
|
+
for (const token of new Lexer().lex(content)) {
|
|
2662
|
+
if (token.startsWith("#")) comments3.push({ line, text: token });
|
|
2663
|
+
for (const char of token) if (char === "\n") line++;
|
|
2664
|
+
}
|
|
2665
|
+
return comments3;
|
|
2666
|
+
}
|
|
2667
|
+
|
|
2668
|
+
// src/commands/verify/blockComments/collectFileComments.ts
|
|
2669
|
+
function toFindings(file, lines, raw, exempt) {
|
|
2670
|
+
const findings = [];
|
|
2671
|
+
for (const { line, text: text9 } of raw) {
|
|
2672
|
+
if (!lines.has(line)) continue;
|
|
2673
|
+
if (exempt && isCommentExempt(text9)) continue;
|
|
2674
|
+
findings.push({ file, line, text: text9.replace(/\s+/g, " ").trim() });
|
|
2675
|
+
}
|
|
2676
|
+
return findings;
|
|
2677
|
+
}
|
|
2678
|
+
function collectFileComments(file, lines, project) {
|
|
2679
|
+
const read = () => fs13.readFileSync(file, "utf8");
|
|
2680
|
+
if (isYamlFile(file))
|
|
2681
|
+
return toFindings(file, lines, collectYamlComments(read()), false);
|
|
2682
|
+
if (isDockerfile(file) || isEnvFile(file) || isShellFile(file))
|
|
2683
|
+
return toFindings(
|
|
2684
|
+
file,
|
|
2685
|
+
lines,
|
|
2686
|
+
collectHashComments(read(), { skipHeader: isShellFile(file) }),
|
|
2687
|
+
true
|
|
2688
|
+
);
|
|
2689
|
+
return collectSourceFindings(file, lines, project);
|
|
2690
|
+
}
|
|
2691
|
+
|
|
2629
2692
|
// src/commands/verify/blockComments/parseDiffAddedLines.ts
|
|
2630
2693
|
var FILE_HEADER = /^\+\+\+ (?:b\/)?(.+)$/;
|
|
2631
2694
|
var HUNK_HEADER = /^@@ -\d+(?:,\d+)? \+(\d+)(?:,\d+)? @@/;
|
|
@@ -2673,7 +2736,8 @@ var SCANNED_EXTENSIONS = [
|
|
|
2673
2736
|
".yaml"
|
|
2674
2737
|
];
|
|
2675
2738
|
function shouldScan(file, ignoreGlobs) {
|
|
2676
|
-
if (!SCANNED_EXTENSIONS.some((ext) => file.endsWith(ext))
|
|
2739
|
+
if (!SCANNED_EXTENSIONS.some((ext) => file.endsWith(ext)) && !isHashCommentFile(file))
|
|
2740
|
+
return false;
|
|
2677
2741
|
if (ignoreGlobs.some((glob) => minimatch(file, glob))) return false;
|
|
2678
2742
|
return fs14.existsSync(file);
|
|
2679
2743
|
}
|
|
@@ -2721,9 +2785,9 @@ import { existsSync as existsSync12, readFileSync as readFileSync9 } from "fs";
|
|
|
2721
2785
|
|
|
2722
2786
|
// src/commands/verify/forbiddenStrings/findForbiddenStrings.ts
|
|
2723
2787
|
import { minimatch as minimatch2 } from "minimatch";
|
|
2724
|
-
function resolveStringsAtPath(data,
|
|
2788
|
+
function resolveStringsAtPath(data, path58) {
|
|
2725
2789
|
let current = data;
|
|
2726
|
-
for (const segment of
|
|
2790
|
+
for (const segment of path58.split(".")) {
|
|
2727
2791
|
if (current === null || typeof current !== "object") return [];
|
|
2728
2792
|
current = current[segment];
|
|
2729
2793
|
}
|
|
@@ -2736,10 +2800,10 @@ function resolveStringsAtPath(data, path57) {
|
|
|
2736
2800
|
}
|
|
2737
2801
|
function findRuleViolations(data, rule) {
|
|
2738
2802
|
const violations = [];
|
|
2739
|
-
for (const
|
|
2740
|
-
for (const value of resolveStringsAtPath(data,
|
|
2803
|
+
for (const path58 of rule.paths) {
|
|
2804
|
+
for (const value of resolveStringsAtPath(data, path58)) {
|
|
2741
2805
|
if (minimatch2(value, rule.disallowed))
|
|
2742
|
-
violations.push({ file: rule.file, path:
|
|
2806
|
+
violations.push({ file: rule.file, path: path58, value });
|
|
2743
2807
|
}
|
|
2744
2808
|
}
|
|
2745
2809
|
return violations;
|
|
@@ -2778,8 +2842,8 @@ function forbiddenStrings() {
|
|
|
2778
2842
|
process.exit(0);
|
|
2779
2843
|
}
|
|
2780
2844
|
console.log("Forbidden strings found:\n");
|
|
2781
|
-
for (const { file, path:
|
|
2782
|
-
console.log(` ${file} ${
|
|
2845
|
+
for (const { file, path: path58, value } of violations) {
|
|
2846
|
+
console.log(` ${file} ${path58}: ${value}`);
|
|
2783
2847
|
}
|
|
2784
2848
|
console.log(`
|
|
2785
2849
|
Total: ${violations.length} forbidden string(s).`);
|
|
@@ -2834,7 +2898,7 @@ Total: ${lines.length} hardcoded color(s)`);
|
|
|
2834
2898
|
}
|
|
2835
2899
|
|
|
2836
2900
|
// src/commands/verify/run/resolveEntries.ts
|
|
2837
|
-
import * as
|
|
2901
|
+
import * as path19 from "path";
|
|
2838
2902
|
|
|
2839
2903
|
// src/shared/resolveRunConfigs.ts
|
|
2840
2904
|
import { dirname as dirname9, relative, resolve as resolve3 } from "path";
|
|
@@ -2944,7 +3008,7 @@ function getRunEntries() {
|
|
|
2944
3008
|
return configs.filter((r) => r.name.startsWith("verify:")).map((r) => ({
|
|
2945
3009
|
name: r.name,
|
|
2946
3010
|
fullCommand: buildFullCommand(r.command, r.args),
|
|
2947
|
-
cwd: r.cwd ?
|
|
3011
|
+
cwd: r.cwd ? path19.resolve(getConfigDir(), r.cwd) : void 0,
|
|
2948
3012
|
env: r.env,
|
|
2949
3013
|
filter: r.filter,
|
|
2950
3014
|
quiet: r.quiet
|
|
@@ -2953,7 +3017,7 @@ function getRunEntries() {
|
|
|
2953
3017
|
function getPackageJsonEntries() {
|
|
2954
3018
|
const result = findPackageJsonWithVerifyScripts(process.cwd());
|
|
2955
3019
|
if (!result) return [];
|
|
2956
|
-
const cwd =
|
|
3020
|
+
const cwd = path19.dirname(result.packageJsonPath);
|
|
2957
3021
|
return result.verifyScripts.map((script) => ({
|
|
2958
3022
|
name: script,
|
|
2959
3023
|
fullCommand: `npm run ${script}`,
|
|
@@ -3472,11 +3536,11 @@ function detectPlatform() {
|
|
|
3472
3536
|
import { spawn as spawn2 } from "child_process";
|
|
3473
3537
|
import fs15 from "fs";
|
|
3474
3538
|
import { createRequire } from "module";
|
|
3475
|
-
import
|
|
3539
|
+
import path20 from "path";
|
|
3476
3540
|
var require2 = createRequire(import.meta.url);
|
|
3477
3541
|
function getSnoreToastPath() {
|
|
3478
|
-
const notifierPath =
|
|
3479
|
-
return
|
|
3542
|
+
const notifierPath = path20.dirname(require2.resolve("node-notifier"));
|
|
3543
|
+
return path20.join(notifierPath, "vendor", "snoreToast", "snoretoast-x64.exe");
|
|
3480
3544
|
}
|
|
3481
3545
|
function showWindowsNotificationFromWsl(options2) {
|
|
3482
3546
|
const { title, message, sound } = options2;
|
|
@@ -4237,10 +4301,10 @@ var hooksSettings = {
|
|
|
4237
4301
|
}
|
|
4238
4302
|
};
|
|
4239
4303
|
function ensureHooksSettings() {
|
|
4240
|
-
const
|
|
4241
|
-
mkdirSync5(dirname12(
|
|
4242
|
-
writeFileSync15(
|
|
4243
|
-
return
|
|
4304
|
+
const path58 = daemonPaths.hooksSettings;
|
|
4305
|
+
mkdirSync5(dirname12(path58), { recursive: true });
|
|
4306
|
+
writeFileSync15(path58, JSON.stringify(hooksSettings, null, 2));
|
|
4307
|
+
return path58;
|
|
4244
4308
|
}
|
|
4245
4309
|
|
|
4246
4310
|
// src/shared/spawnClaude.ts
|
|
@@ -4429,9 +4493,9 @@ var LOCAL_FILES = ["backlog.jsonl", "backlog.db"];
|
|
|
4429
4493
|
function backupLocalBacklogFiles(dir) {
|
|
4430
4494
|
const moved = [];
|
|
4431
4495
|
for (const name of LOCAL_FILES) {
|
|
4432
|
-
const
|
|
4433
|
-
if (existsSync18(
|
|
4434
|
-
renameSync(
|
|
4496
|
+
const path58 = join15(dir, ".assist", name);
|
|
4497
|
+
if (existsSync18(path58)) {
|
|
4498
|
+
renameSync(path58, `${path58}.bak`);
|
|
4435
4499
|
moved.push(`${name} \u2192 ${name}.bak`);
|
|
4436
4500
|
}
|
|
4437
4501
|
}
|
|
@@ -4845,8 +4909,8 @@ var backlogItemSchema = z3.strictObject({
|
|
|
4845
4909
|
var backlogFileSchema = z3.array(backlogItemSchema);
|
|
4846
4910
|
|
|
4847
4911
|
// src/commands/backlog/parseBacklogJsonl.ts
|
|
4848
|
-
function parseBacklogJsonl(
|
|
4849
|
-
const content = readFileSync13(
|
|
4912
|
+
function parseBacklogJsonl(path58) {
|
|
4913
|
+
const content = readFileSync13(path58, "utf8").trim();
|
|
4850
4914
|
if (content.length === 0) return [];
|
|
4851
4915
|
return content.split("\n").map((line) => line.trim()).filter(Boolean).map((line) => backlogItemSchema.parse(JSON.parse(line)));
|
|
4852
4916
|
}
|
|
@@ -4928,8 +4992,8 @@ function findBacklogUp(startDir) {
|
|
|
4928
4992
|
|
|
4929
4993
|
// src/commands/backlog/getCurrentOrigin.ts
|
|
4930
4994
|
import { execFileSync } from "child_process";
|
|
4931
|
-
function stripLeadingSlashes(
|
|
4932
|
-
return
|
|
4995
|
+
function stripLeadingSlashes(path58) {
|
|
4996
|
+
return path58.replace(/^\/+/, "");
|
|
4933
4997
|
}
|
|
4934
4998
|
function normalizeOrigin(raw) {
|
|
4935
4999
|
const trimmed = raw.trim().replace(/\.git$/i, "").replace(/\/+$/, "");
|
|
@@ -5361,13 +5425,13 @@ function activityPath(sessionId) {
|
|
|
5361
5425
|
function emitActivity(activity2) {
|
|
5362
5426
|
const sessionId = process.env.ASSIST_ACTIVITY_ID;
|
|
5363
5427
|
if (!sessionId) return;
|
|
5364
|
-
const
|
|
5365
|
-
mkdirSync7(dirname14(
|
|
5366
|
-
writeFileSync17(
|
|
5428
|
+
const path58 = activityPath(sessionId);
|
|
5429
|
+
mkdirSync7(dirname14(path58), { recursive: true });
|
|
5430
|
+
writeFileSync17(path58, JSON.stringify({ ...activity2, startedAt: Date.now() }));
|
|
5367
5431
|
}
|
|
5368
|
-
function readActivity(
|
|
5432
|
+
function readActivity(path58) {
|
|
5369
5433
|
try {
|
|
5370
|
-
return JSON.parse(readFileSync14(
|
|
5434
|
+
return JSON.parse(readFileSync14(path58, "utf8"));
|
|
5371
5435
|
} catch {
|
|
5372
5436
|
return void 0;
|
|
5373
5437
|
}
|
|
@@ -5377,9 +5441,9 @@ function reconcileActivity(sessionId, activity2) {
|
|
|
5377
5441
|
removeActivity(sessionId);
|
|
5378
5442
|
return;
|
|
5379
5443
|
}
|
|
5380
|
-
const
|
|
5381
|
-
mkdirSync7(dirname14(
|
|
5382
|
-
writeFileSync17(
|
|
5444
|
+
const path58 = activityPath(sessionId);
|
|
5445
|
+
mkdirSync7(dirname14(path58), { recursive: true });
|
|
5446
|
+
writeFileSync17(path58, JSON.stringify(activity2));
|
|
5383
5447
|
}
|
|
5384
5448
|
function removeActivity(sessionId) {
|
|
5385
5449
|
try {
|
|
@@ -5435,20 +5499,20 @@ function getSignalPath() {
|
|
|
5435
5499
|
return join19(homedir8(), ".assist", "signals", `signal-${sessionId}.json`);
|
|
5436
5500
|
}
|
|
5437
5501
|
function writeSignal(event, data) {
|
|
5438
|
-
const
|
|
5439
|
-
if (!
|
|
5502
|
+
const path58 = getSignalPath();
|
|
5503
|
+
if (!path58) return;
|
|
5440
5504
|
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
5441
5505
|
const signal = { event, ...sessionId && { sessionId }, ...data };
|
|
5442
|
-
mkdirSync8(dirname15(
|
|
5443
|
-
writeFileSync18(
|
|
5506
|
+
mkdirSync8(dirname15(path58), { recursive: true });
|
|
5507
|
+
writeFileSync18(path58, JSON.stringify(signal));
|
|
5444
5508
|
}
|
|
5445
5509
|
|
|
5446
5510
|
// src/commands/backlog/readSignal.ts
|
|
5447
5511
|
function readSignal() {
|
|
5448
|
-
const
|
|
5449
|
-
if (!
|
|
5512
|
+
const path58 = getSignalPath();
|
|
5513
|
+
if (!path58 || !existsSync21(path58)) return void 0;
|
|
5450
5514
|
try {
|
|
5451
|
-
return JSON.parse(readFileSync15(
|
|
5515
|
+
return JSON.parse(readFileSync15(path58, "utf8"));
|
|
5452
5516
|
} catch {
|
|
5453
5517
|
return void 0;
|
|
5454
5518
|
}
|
|
@@ -6382,8 +6446,8 @@ async function getBacklogExists(req, res) {
|
|
|
6382
6446
|
// src/commands/backlog/originDisplayName.ts
|
|
6383
6447
|
function originDisplayName(origin) {
|
|
6384
6448
|
if (origin.startsWith("local:")) {
|
|
6385
|
-
const
|
|
6386
|
-
const segments =
|
|
6449
|
+
const path58 = origin.slice("local:".length).replace(/\/+$/, "");
|
|
6450
|
+
const segments = path58.split("/").filter(Boolean);
|
|
6387
6451
|
return segments[segments.length - 1] ?? origin;
|
|
6388
6452
|
}
|
|
6389
6453
|
const firstSlash = origin.indexOf("/");
|
|
@@ -6771,7 +6835,7 @@ function findSynthesisForBranch(repoReviewsDir, branch2) {
|
|
|
6771
6835
|
const parent = dirname18(branchKeyPath);
|
|
6772
6836
|
const branchPrefix = basename2(branchKeyPath);
|
|
6773
6837
|
if (!existsSync24(parent)) return null;
|
|
6774
|
-
const synthesisFiles = readdirSync(parent).filter((name) => name.startsWith(branchPrefix)).map((name) => join21(parent, name, "synthesis.md")).filter((
|
|
6838
|
+
const synthesisFiles = readdirSync(parent).filter((name) => name.startsWith(branchPrefix)).map((name) => join21(parent, name, "synthesis.md")).filter((path58) => existsSync24(path58)).map((path58) => ({ path: path58, mtime: statSync2(path58).mtimeMs })).sort((a, b) => b.mtime - a.mtime);
|
|
6775
6839
|
return synthesisFiles[0]?.path ?? null;
|
|
6776
6840
|
}
|
|
6777
6841
|
|
|
@@ -6820,12 +6884,12 @@ async function getReviewSynthesis(req, res) {
|
|
|
6820
6884
|
const cwd = getCwdParam(req, res);
|
|
6821
6885
|
if (!cwd) return;
|
|
6822
6886
|
try {
|
|
6823
|
-
const
|
|
6824
|
-
if (!
|
|
6887
|
+
const path58 = await resolveSynthesisPath(cwd);
|
|
6888
|
+
if (!path58) {
|
|
6825
6889
|
respondJson(res, 404, { error: "No synthesis found" });
|
|
6826
6890
|
return;
|
|
6827
6891
|
}
|
|
6828
|
-
respondJson(res, 200, { synthesis: readFileSync17(
|
|
6892
|
+
respondJson(res, 200, { synthesis: readFileSync17(path58, "utf8") });
|
|
6829
6893
|
} catch {
|
|
6830
6894
|
respondJson(res, 404, { error: "No synthesis found" });
|
|
6831
6895
|
}
|
|
@@ -6903,10 +6967,10 @@ function getStorePath(filename) {
|
|
|
6903
6967
|
return join23(getStoreDir(), filename);
|
|
6904
6968
|
}
|
|
6905
6969
|
function loadJson(filename) {
|
|
6906
|
-
const
|
|
6907
|
-
if (existsSync25(
|
|
6970
|
+
const path58 = getStorePath(filename);
|
|
6971
|
+
if (existsSync25(path58)) {
|
|
6908
6972
|
try {
|
|
6909
|
-
return JSON.parse(readFileSync18(
|
|
6973
|
+
return JSON.parse(readFileSync18(path58, "utf8"));
|
|
6910
6974
|
} catch {
|
|
6911
6975
|
return {};
|
|
6912
6976
|
}
|
|
@@ -10037,9 +10101,9 @@ var __dirname4 = dirname19(__filename3);
|
|
|
10037
10101
|
function packageRoot() {
|
|
10038
10102
|
return __dirname4;
|
|
10039
10103
|
}
|
|
10040
|
-
function readLines(
|
|
10041
|
-
if (!existsSync26(
|
|
10042
|
-
return readFileSync21(
|
|
10104
|
+
function readLines(path58) {
|
|
10105
|
+
if (!existsSync26(path58)) return [];
|
|
10106
|
+
return readFileSync21(path58, "utf8").split("\n").filter((line) => line.trim() !== "");
|
|
10043
10107
|
}
|
|
10044
10108
|
var cachedReads;
|
|
10045
10109
|
var cachedWrites;
|
|
@@ -10504,14 +10568,14 @@ function showProgress(p, label2) {
|
|
|
10504
10568
|
const pct = Math.round(p.done / p.total * 100);
|
|
10505
10569
|
process.stderr.write(`\r\x1B[K[${pct}%] Scanning ${label2}...`);
|
|
10506
10570
|
}
|
|
10507
|
-
async function resolveCommand(cli,
|
|
10508
|
-
showProgress(p,
|
|
10509
|
-
const subHelp = await runHelp([cli, ...
|
|
10571
|
+
async function resolveCommand(cli, path58, description, depth, p) {
|
|
10572
|
+
showProgress(p, path58.join(" "));
|
|
10573
|
+
const subHelp = await runHelp([cli, ...path58]);
|
|
10510
10574
|
if (!subHelp || !hasSubcommands(subHelp)) {
|
|
10511
|
-
return [{ path:
|
|
10575
|
+
return [{ path: path58, description }];
|
|
10512
10576
|
}
|
|
10513
|
-
const children = await discoverAt(cli,
|
|
10514
|
-
return children.length > 0 ? children : [{ path:
|
|
10577
|
+
const children = await discoverAt(cli, path58, depth + 1, p);
|
|
10578
|
+
return children.length > 0 ? children : [{ path: path58, description }];
|
|
10515
10579
|
}
|
|
10516
10580
|
async function discoverAt(cli, parentPath, depth, p) {
|
|
10517
10581
|
if (depth > SAFETY_DEPTH) return [];
|
|
@@ -10659,9 +10723,9 @@ function logPath(cli) {
|
|
|
10659
10723
|
return join27(homedir13(), ".assist", `cli-discover-${safeName}.log`);
|
|
10660
10724
|
}
|
|
10661
10725
|
function readCache(cli) {
|
|
10662
|
-
const
|
|
10663
|
-
if (!existsSync28(
|
|
10664
|
-
return readFileSync23(
|
|
10726
|
+
const path58 = logPath(cli);
|
|
10727
|
+
if (!existsSync28(path58)) return void 0;
|
|
10728
|
+
return readFileSync23(path58, "utf8");
|
|
10665
10729
|
}
|
|
10666
10730
|
function writeCache(cli, output) {
|
|
10667
10731
|
const dir = join27(homedir13(), ".assist");
|
|
@@ -10819,9 +10883,9 @@ function sweepRestrictedDir(dir = getRestrictedDir()) {
|
|
|
10819
10883
|
}
|
|
10820
10884
|
const cutoff = Date.now() - STALE_AFTER_MS;
|
|
10821
10885
|
for (const entry of entries) {
|
|
10822
|
-
const
|
|
10886
|
+
const path58 = join29(dir, entry);
|
|
10823
10887
|
try {
|
|
10824
|
-
if (statSync3(
|
|
10888
|
+
if (statSync3(path58).mtimeMs < cutoff) unlinkSync7(path58);
|
|
10825
10889
|
} catch {
|
|
10826
10890
|
continue;
|
|
10827
10891
|
}
|
|
@@ -10831,10 +10895,10 @@ function sweepRestrictedDir(dir = getRestrictedDir()) {
|
|
|
10831
10895
|
// src/commands/codeComment/readPinState.ts
|
|
10832
10896
|
import { existsSync as existsSync29, readFileSync as readFileSync24 } from "fs";
|
|
10833
10897
|
function readPinState(pin) {
|
|
10834
|
-
const
|
|
10835
|
-
if (!existsSync29(
|
|
10898
|
+
const path58 = getPinStatePath(pin);
|
|
10899
|
+
if (!existsSync29(path58)) return void 0;
|
|
10836
10900
|
try {
|
|
10837
|
-
const state = JSON.parse(readFileSync24(
|
|
10901
|
+
const state = JSON.parse(readFileSync24(path58, "utf8"));
|
|
10838
10902
|
if (state.pin !== pin) return void 0;
|
|
10839
10903
|
return state;
|
|
10840
10904
|
} catch {
|
|
@@ -10868,7 +10932,7 @@ function codeCommentConfirm(pin) {
|
|
|
10868
10932
|
process.exitCode = 1;
|
|
10869
10933
|
return;
|
|
10870
10934
|
}
|
|
10871
|
-
const marker =
|
|
10935
|
+
const marker = isHashCommentFile(state.file) ? "#" : "//";
|
|
10872
10936
|
const indentSource = lines[index3] ?? "";
|
|
10873
10937
|
const indent2 = indentSource.match(/^\s*/)?.[0] ?? "";
|
|
10874
10938
|
lines.splice(index3, 0, `${indent2}${marker} ${state.text}`);
|
|
@@ -10886,15 +10950,15 @@ import chalk108 from "chalk";
|
|
|
10886
10950
|
|
|
10887
10951
|
// src/commands/codeComment/validateCommentText.ts
|
|
10888
10952
|
var MAX_COMMENT_LENGTH = 50;
|
|
10889
|
-
function validateCommentText(raw,
|
|
10890
|
-
const text9 =
|
|
10953
|
+
function validateCommentText(raw, isHash = false) {
|
|
10954
|
+
const text9 = isHash ? raw.replace(/^#\s?/, "") : raw.replace(/^\/\/\s?/, "");
|
|
10891
10955
|
if (/[\r\n]/.test(text9)) {
|
|
10892
10956
|
return {
|
|
10893
10957
|
ok: false,
|
|
10894
10958
|
reason: "Comment must be a single line \u2014 multi-line comments are not allowed."
|
|
10895
10959
|
};
|
|
10896
10960
|
}
|
|
10897
|
-
if (!
|
|
10961
|
+
if (!isHash && (text9.includes("/*") || text9.includes("*/"))) {
|
|
10898
10962
|
return {
|
|
10899
10963
|
ok: false,
|
|
10900
10964
|
reason: "Block comments (/* */) are not allowed \u2014 only single-line // comments."
|
|
@@ -10937,8 +11001,9 @@ function codeCommentSet(file, line, text9) {
|
|
|
10937
11001
|
process.exitCode = 1;
|
|
10938
11002
|
return;
|
|
10939
11003
|
}
|
|
10940
|
-
const
|
|
10941
|
-
const
|
|
11004
|
+
const hash = isHashCommentFile(file);
|
|
11005
|
+
const marker = hash ? "#" : "//";
|
|
11006
|
+
const validation = validateCommentText(text9, hash);
|
|
10942
11007
|
if (!validation.ok) {
|
|
10943
11008
|
console.error(chalk108.red(`Refused: ${validation.reason}`));
|
|
10944
11009
|
console.error(chalk108.red("No pin issued."));
|
|
@@ -10990,13 +11055,13 @@ import chalk110 from "chalk";
|
|
|
10990
11055
|
|
|
10991
11056
|
// src/commands/complexity/shared/index.ts
|
|
10992
11057
|
import fs17 from "fs";
|
|
10993
|
-
import
|
|
11058
|
+
import path22 from "path";
|
|
10994
11059
|
import chalk109 from "chalk";
|
|
10995
11060
|
import ts5 from "typescript";
|
|
10996
11061
|
|
|
10997
11062
|
// src/commands/complexity/findSourceFiles.ts
|
|
10998
11063
|
import fs16 from "fs";
|
|
10999
|
-
import
|
|
11064
|
+
import path21 from "path";
|
|
11000
11065
|
import { minimatch as minimatch5 } from "minimatch";
|
|
11001
11066
|
function applyIgnoreGlobs(files, extraIgnore = []) {
|
|
11002
11067
|
const { complexity } = loadConfig();
|
|
@@ -11010,7 +11075,7 @@ function walk(dir, results) {
|
|
|
11010
11075
|
const extensions = [".ts", ".tsx"];
|
|
11011
11076
|
const entries = fs16.readdirSync(dir, { withFileTypes: true });
|
|
11012
11077
|
for (const entry of entries) {
|
|
11013
|
-
const fullPath =
|
|
11078
|
+
const fullPath = path21.join(dir, entry.name);
|
|
11014
11079
|
if (entry.isDirectory()) {
|
|
11015
11080
|
if (entry.name !== "node_modules" && entry.name !== ".git") {
|
|
11016
11081
|
walk(fullPath, results);
|
|
@@ -11232,7 +11297,7 @@ function countSloc(content) {
|
|
|
11232
11297
|
function createSourceFromFile(filePath) {
|
|
11233
11298
|
const content = fs17.readFileSync(filePath, "utf8");
|
|
11234
11299
|
return ts5.createSourceFile(
|
|
11235
|
-
|
|
11300
|
+
path22.basename(filePath),
|
|
11236
11301
|
content,
|
|
11237
11302
|
ts5.ScriptTarget.Latest,
|
|
11238
11303
|
true,
|
|
@@ -11589,8 +11654,8 @@ function stepIntoNested(container, key, nextKey) {
|
|
|
11589
11654
|
}
|
|
11590
11655
|
return ensureObject(container, resolved);
|
|
11591
11656
|
}
|
|
11592
|
-
function setNestedValue(obj,
|
|
11593
|
-
const keys =
|
|
11657
|
+
function setNestedValue(obj, path58, value) {
|
|
11658
|
+
const keys = path58.split(".");
|
|
11594
11659
|
const result = { ...obj };
|
|
11595
11660
|
let current = result;
|
|
11596
11661
|
for (let i = 0; i < keys.length - 1; i++) {
|
|
@@ -11670,9 +11735,9 @@ function isTraversable(value) {
|
|
|
11670
11735
|
function stepInto(current, key) {
|
|
11671
11736
|
return isTraversable(current) ? current[key] : void 0;
|
|
11672
11737
|
}
|
|
11673
|
-
function getNestedValue(obj,
|
|
11738
|
+
function getNestedValue(obj, path58) {
|
|
11674
11739
|
let current = obj;
|
|
11675
|
-
for (const key of
|
|
11740
|
+
for (const key of path58.split(".")) current = stepInto(current, key);
|
|
11676
11741
|
return current;
|
|
11677
11742
|
}
|
|
11678
11743
|
|
|
@@ -12272,14 +12337,14 @@ import chalk128 from "chalk";
|
|
|
12272
12337
|
|
|
12273
12338
|
// src/shared/findRepoRoot.ts
|
|
12274
12339
|
import { existsSync as existsSync33 } from "fs";
|
|
12275
|
-
import
|
|
12340
|
+
import path23 from "path";
|
|
12276
12341
|
function findRepoRoot(dir) {
|
|
12277
12342
|
let current = dir;
|
|
12278
|
-
while (current !==
|
|
12279
|
-
if (existsSync33(
|
|
12343
|
+
while (current !== path23.dirname(current)) {
|
|
12344
|
+
if (existsSync33(path23.join(current, ".git"))) {
|
|
12280
12345
|
return current;
|
|
12281
12346
|
}
|
|
12282
|
-
current =
|
|
12347
|
+
current = path23.dirname(current);
|
|
12283
12348
|
}
|
|
12284
12349
|
return null;
|
|
12285
12350
|
}
|
|
@@ -12343,7 +12408,7 @@ async function checkBuildLocksCommand() {
|
|
|
12343
12408
|
|
|
12344
12409
|
// src/commands/dotnet/buildTree.ts
|
|
12345
12410
|
import { readFileSync as readFileSync29 } from "fs";
|
|
12346
|
-
import
|
|
12411
|
+
import path24 from "path";
|
|
12347
12412
|
var PROJECT_REF_RE = /<ProjectReference\s+Include="([^"]+)"/g;
|
|
12348
12413
|
function getProjectRefs(csprojPath) {
|
|
12349
12414
|
const content = readFileSync29(csprojPath, "utf8");
|
|
@@ -12354,14 +12419,14 @@ function getProjectRefs(csprojPath) {
|
|
|
12354
12419
|
return refs;
|
|
12355
12420
|
}
|
|
12356
12421
|
function buildTree(csprojPath, repoRoot, visited = /* @__PURE__ */ new Set()) {
|
|
12357
|
-
const abs =
|
|
12358
|
-
const rel =
|
|
12422
|
+
const abs = path24.resolve(csprojPath);
|
|
12423
|
+
const rel = path24.relative(repoRoot, abs);
|
|
12359
12424
|
const node = { path: abs, relativePath: rel, children: [] };
|
|
12360
12425
|
if (visited.has(abs)) return node;
|
|
12361
12426
|
visited.add(abs);
|
|
12362
|
-
const dir =
|
|
12427
|
+
const dir = path24.dirname(abs);
|
|
12363
12428
|
for (const ref of getProjectRefs(abs)) {
|
|
12364
|
-
const childAbs =
|
|
12429
|
+
const childAbs = path24.resolve(dir, ref);
|
|
12365
12430
|
try {
|
|
12366
12431
|
readFileSync29(childAbs);
|
|
12367
12432
|
node.children.push(buildTree(childAbs, repoRoot, visited));
|
|
@@ -12389,7 +12454,7 @@ function collectAllDeps(node) {
|
|
|
12389
12454
|
|
|
12390
12455
|
// src/commands/dotnet/findContainingSolutions.ts
|
|
12391
12456
|
import { readdirSync as readdirSync5, readFileSync as readFileSync30, statSync as statSync4 } from "fs";
|
|
12392
|
-
import
|
|
12457
|
+
import path25 from "path";
|
|
12393
12458
|
function findSlnFiles(dir, maxDepth, depth = 0) {
|
|
12394
12459
|
if (depth > maxDepth) return [];
|
|
12395
12460
|
const results = [];
|
|
@@ -12402,7 +12467,7 @@ function findSlnFiles(dir, maxDepth, depth = 0) {
|
|
|
12402
12467
|
for (const entry of entries) {
|
|
12403
12468
|
if (entry.startsWith(".") || entry === "node_modules" || entry === "packages")
|
|
12404
12469
|
continue;
|
|
12405
|
-
const full =
|
|
12470
|
+
const full = path25.join(dir, entry);
|
|
12406
12471
|
try {
|
|
12407
12472
|
const stat2 = statSync4(full);
|
|
12408
12473
|
if (stat2.isFile() && entry.endsWith(".sln")) {
|
|
@@ -12416,8 +12481,8 @@ function findSlnFiles(dir, maxDepth, depth = 0) {
|
|
|
12416
12481
|
return results;
|
|
12417
12482
|
}
|
|
12418
12483
|
function findContainingSolutions(csprojPath, repoRoot) {
|
|
12419
|
-
const csprojAbs =
|
|
12420
|
-
const csprojBasename =
|
|
12484
|
+
const csprojAbs = path25.resolve(csprojPath);
|
|
12485
|
+
const csprojBasename = path25.basename(csprojAbs);
|
|
12421
12486
|
const slnFiles = findSlnFiles(repoRoot, 3);
|
|
12422
12487
|
const matches = [];
|
|
12423
12488
|
const pattern2 = new RegExp(`[\\\\"/]${escapeRegex(csprojBasename)}"`);
|
|
@@ -12425,7 +12490,7 @@ function findContainingSolutions(csprojPath, repoRoot) {
|
|
|
12425
12490
|
try {
|
|
12426
12491
|
const content = readFileSync30(sln, "utf8");
|
|
12427
12492
|
if (pattern2.test(content)) {
|
|
12428
|
-
matches.push(
|
|
12493
|
+
matches.push(path25.relative(repoRoot, sln));
|
|
12429
12494
|
}
|
|
12430
12495
|
} catch {
|
|
12431
12496
|
}
|
|
@@ -12488,15 +12553,15 @@ function printJson(tree, totalCount, solutions) {
|
|
|
12488
12553
|
|
|
12489
12554
|
// src/commands/dotnet/resolveCsproj.ts
|
|
12490
12555
|
import { existsSync as existsSync34 } from "fs";
|
|
12491
|
-
import
|
|
12556
|
+
import path26 from "path";
|
|
12492
12557
|
import chalk130 from "chalk";
|
|
12493
12558
|
function resolveCsproj(csprojPath) {
|
|
12494
|
-
const resolved =
|
|
12559
|
+
const resolved = path26.resolve(csprojPath);
|
|
12495
12560
|
if (!existsSync34(resolved)) {
|
|
12496
12561
|
console.error(chalk130.red(`File not found: ${resolved}`));
|
|
12497
12562
|
process.exit(1);
|
|
12498
12563
|
}
|
|
12499
|
-
const repoRoot = findRepoRoot(
|
|
12564
|
+
const repoRoot = findRepoRoot(path26.dirname(resolved));
|
|
12500
12565
|
if (!repoRoot) {
|
|
12501
12566
|
console.error(chalk130.red("Could not find git repository root"));
|
|
12502
12567
|
process.exit(1);
|
|
@@ -12661,7 +12726,7 @@ function filterIssues(issues, all, cliOnly, cliSuppress) {
|
|
|
12661
12726
|
|
|
12662
12727
|
// src/commands/dotnet/resolveSolution.ts
|
|
12663
12728
|
import { existsSync as existsSync35 } from "fs";
|
|
12664
|
-
import
|
|
12729
|
+
import path27 from "path";
|
|
12665
12730
|
import chalk134 from "chalk";
|
|
12666
12731
|
|
|
12667
12732
|
// src/commands/dotnet/findSolution.ts
|
|
@@ -12700,7 +12765,7 @@ function findSolution() {
|
|
|
12700
12765
|
// src/commands/dotnet/resolveSolution.ts
|
|
12701
12766
|
function resolveSolution(sln) {
|
|
12702
12767
|
if (sln) {
|
|
12703
|
-
const resolved =
|
|
12768
|
+
const resolved = path27.resolve(sln);
|
|
12704
12769
|
if (!existsSync35(resolved)) {
|
|
12705
12770
|
console.error(chalk134.red(`Solution file not found: ${resolved}`));
|
|
12706
12771
|
process.exit(1);
|
|
@@ -12743,7 +12808,7 @@ function parseInspectReport(json) {
|
|
|
12743
12808
|
import { execSync as execSync31 } from "child_process";
|
|
12744
12809
|
import { existsSync as existsSync36, readFileSync as readFileSync31, unlinkSync as unlinkSync9 } from "fs";
|
|
12745
12810
|
import { tmpdir as tmpdir3 } from "os";
|
|
12746
|
-
import
|
|
12811
|
+
import path28 from "path";
|
|
12747
12812
|
import chalk135 from "chalk";
|
|
12748
12813
|
function assertJbInstalled() {
|
|
12749
12814
|
try {
|
|
@@ -12757,7 +12822,7 @@ function assertJbInstalled() {
|
|
|
12757
12822
|
}
|
|
12758
12823
|
}
|
|
12759
12824
|
function runInspectCode(slnPath, include, swea) {
|
|
12760
|
-
const reportPath =
|
|
12825
|
+
const reportPath = path28.join(tmpdir3(), `inspect-${Date.now()}.xml`);
|
|
12761
12826
|
const includeFlag = include ? ` --include="${include}"` : "";
|
|
12762
12827
|
const sweaFlag = swea ? " --swea" : "";
|
|
12763
12828
|
try {
|
|
@@ -12908,18 +12973,18 @@ function isSourceFile(filePath) {
|
|
|
12908
12973
|
if (!filePath) return false;
|
|
12909
12974
|
return SOURCE_EXTENSIONS.some((ext) => filePath.endsWith(ext));
|
|
12910
12975
|
}
|
|
12911
|
-
function
|
|
12976
|
+
function blankNonNewline2(text9) {
|
|
12912
12977
|
return text9.replace(/[^\n]/g, " ");
|
|
12913
12978
|
}
|
|
12914
12979
|
function extractComments(text9) {
|
|
12915
12980
|
const comments3 = [];
|
|
12916
12981
|
let work = text9.replace(
|
|
12917
12982
|
/"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|`(?:[^`\\]|\\.)*`/g,
|
|
12918
|
-
|
|
12983
|
+
blankNonNewline2
|
|
12919
12984
|
);
|
|
12920
12985
|
work = work.replace(/\/\*[\s\S]*?\*\//g, (match) => {
|
|
12921
12986
|
comments3.push(match);
|
|
12922
|
-
return
|
|
12987
|
+
return blankNonNewline2(match);
|
|
12923
12988
|
});
|
|
12924
12989
|
for (const match of work.matchAll(/\/\/.*/g)) {
|
|
12925
12990
|
comments3.push(match[0]);
|
|
@@ -12928,13 +12993,13 @@ function extractComments(text9) {
|
|
|
12928
12993
|
}
|
|
12929
12994
|
|
|
12930
12995
|
// src/commands/editHook/extractYamlComments.ts
|
|
12931
|
-
function
|
|
12996
|
+
function blankNonNewline3(text9) {
|
|
12932
12997
|
return text9.replace(/[^\n]/g, " ");
|
|
12933
12998
|
}
|
|
12934
12999
|
function extractYamlComments(text9) {
|
|
12935
13000
|
const work = text9.replace(
|
|
12936
13001
|
/"(?:[^"\\]|\\.)*"|'(?:[^']|'')*'/g,
|
|
12937
|
-
|
|
13002
|
+
blankNonNewline3
|
|
12938
13003
|
);
|
|
12939
13004
|
const comments3 = [];
|
|
12940
13005
|
for (const match of work.matchAll(/(?:^|\s)(#.*)/gm)) {
|
|
@@ -12943,6 +13008,20 @@ function extractYamlComments(text9) {
|
|
|
12943
13008
|
return comments3.map((comment3) => comment3.replace(/\s+/g, " ").trim()).filter((comment3) => comment3.length > 0);
|
|
12944
13009
|
}
|
|
12945
13010
|
|
|
13011
|
+
// src/commands/editHook/extractShellComments.ts
|
|
13012
|
+
function isHeaderLine2(line) {
|
|
13013
|
+
const trimmed = line.trim();
|
|
13014
|
+
return trimmed === "" || trimmed.startsWith("#");
|
|
13015
|
+
}
|
|
13016
|
+
function extractShellComments(text9) {
|
|
13017
|
+
const lines = text9.split("\n");
|
|
13018
|
+
let firstCodeLine = 0;
|
|
13019
|
+
while (firstCodeLine < lines.length && isHeaderLine2(lines[firstCodeLine])) {
|
|
13020
|
+
firstCodeLine++;
|
|
13021
|
+
}
|
|
13022
|
+
return extractYamlComments(lines.slice(firstCodeLine).join("\n"));
|
|
13023
|
+
}
|
|
13024
|
+
|
|
12946
13025
|
// src/commands/editHook/introducedComments.ts
|
|
12947
13026
|
function introducedComments(added, removed) {
|
|
12948
13027
|
const counts = /* @__PURE__ */ new Map();
|
|
@@ -13000,15 +13079,15 @@ function partitionStrings(input, existingContent) {
|
|
|
13000
13079
|
}
|
|
13001
13080
|
function decideCommentGuard(input, existingContent) {
|
|
13002
13081
|
const filePath = input.tool_input.file_path;
|
|
13003
|
-
const
|
|
13004
|
-
if (!isSourceFile(filePath) && !
|
|
13005
|
-
const extract2 =
|
|
13082
|
+
const hash = isHashCommentFile(filePath);
|
|
13083
|
+
if (!isSourceFile(filePath) && !hash) return void 0;
|
|
13084
|
+
const extract2 = hash ? isShellFile(filePath) ? extractShellComments : extractYamlComments : extractComments;
|
|
13006
13085
|
const { added, removed } = partitionStrings(input, existingContent);
|
|
13007
13086
|
const introduced = introducedComments(
|
|
13008
13087
|
added.flatMap(extract2),
|
|
13009
13088
|
removed.flatMap(extract2)
|
|
13010
13089
|
);
|
|
13011
|
-
return introduced.length > 0 ? denyReason(
|
|
13090
|
+
return introduced.length > 0 ? denyReason(hash ? "#" : "//") : void 0;
|
|
13012
13091
|
}
|
|
13013
13092
|
|
|
13014
13093
|
// src/commands/editHook/decideOverrideGuard.ts
|
|
@@ -14111,9 +14190,9 @@ function parseRscRows(flight) {
|
|
|
14111
14190
|
}
|
|
14112
14191
|
function makeRscResolver(rows) {
|
|
14113
14192
|
return (ref) => {
|
|
14114
|
-
const [id2, ...
|
|
14193
|
+
const [id2, ...path58] = ref.slice(1).replace(/^[L@]/, "").split(":");
|
|
14115
14194
|
let v = rows[id2];
|
|
14116
|
-
for (const key of
|
|
14195
|
+
for (const key of path58) {
|
|
14117
14196
|
if (v == null || typeof v !== "object") return void 0;
|
|
14118
14197
|
v = v[key];
|
|
14119
14198
|
}
|
|
@@ -14760,15 +14839,15 @@ function postComment(vars) {
|
|
|
14760
14839
|
const stdout = startLine === void 0 ? runGhGraphql(MUTATION_SINGLE, base) : runGhGraphql(MUTATION_MULTI, { ...base, startLine });
|
|
14761
14840
|
assertThreadCreated(stdout);
|
|
14762
14841
|
}
|
|
14763
|
-
function comment2(
|
|
14842
|
+
function comment2(path58, line, body, startLine) {
|
|
14764
14843
|
validateBody(body);
|
|
14765
14844
|
validateLine(line);
|
|
14766
14845
|
if (startLine !== void 0) validateLine(startLine);
|
|
14767
14846
|
try {
|
|
14768
14847
|
const prId = getCurrentPrNodeId();
|
|
14769
|
-
postComment({ prId, body, path:
|
|
14848
|
+
postComment({ prId, body, path: path58, line, startLine });
|
|
14770
14849
|
const range = startLine !== void 0 ? `${startLine}-${line}` : `${line}`;
|
|
14771
|
-
console.log(`Added review comment on ${
|
|
14850
|
+
console.log(`Added review comment on ${path58}:${range}`);
|
|
14772
14851
|
} catch (error) {
|
|
14773
14852
|
if (isGhNotInstalled(error)) {
|
|
14774
14853
|
console.error("Error: GitHub CLI (gh) is not installed.");
|
|
@@ -15620,8 +15699,8 @@ function registerPrs(program2) {
|
|
|
15620
15699
|
prsCommand.command("reply <comment-id> <body>").description("Reply to a comment thread without resolving it").action((commentId, body) => {
|
|
15621
15700
|
reply(Number.parseInt(commentId, 10), body);
|
|
15622
15701
|
});
|
|
15623
|
-
prsCommand.command("comment <path> <line> <body>").description("Add a line comment to the pending review").action((
|
|
15624
|
-
comment2(
|
|
15702
|
+
prsCommand.command("comment <path> <line> <body>").description("Add a line comment to the pending review").action((path58, line, body) => {
|
|
15703
|
+
comment2(path58, Number.parseInt(line, 10), body);
|
|
15625
15704
|
});
|
|
15626
15705
|
}
|
|
15627
15706
|
|
|
@@ -15873,10 +15952,10 @@ function resolveOpSecret(reference) {
|
|
|
15873
15952
|
}
|
|
15874
15953
|
|
|
15875
15954
|
// src/commands/ravendb/ravenFetch.ts
|
|
15876
|
-
async function ravenFetch(connection,
|
|
15955
|
+
async function ravenFetch(connection, path58) {
|
|
15877
15956
|
const apiKey = resolveOpSecret(connection.apiKeyRef);
|
|
15878
15957
|
let accessToken = await getAccessToken(apiKey);
|
|
15879
|
-
const url = `${connection.url}${
|
|
15958
|
+
const url = `${connection.url}${path58}`;
|
|
15880
15959
|
const headers = {
|
|
15881
15960
|
Authorization: `Bearer ${accessToken}`,
|
|
15882
15961
|
"Content-Type": "application/json"
|
|
@@ -15966,16 +16045,16 @@ import chalk163 from "chalk";
|
|
|
15966
16045
|
// src/commands/ravendb/buildQueryPath.ts
|
|
15967
16046
|
function buildQueryPath(opts) {
|
|
15968
16047
|
const db = encodeURIComponent(opts.db);
|
|
15969
|
-
let
|
|
16048
|
+
let path58;
|
|
15970
16049
|
if (opts.collection) {
|
|
15971
|
-
|
|
16050
|
+
path58 = `/databases/${db}/indexes/dynamic/${encodeURIComponent(opts.collection)}?start=${opts.start}&pageSize=${opts.pageSize}&sort=${encodeURIComponent(opts.sort)}`;
|
|
15972
16051
|
} else {
|
|
15973
|
-
|
|
16052
|
+
path58 = `/databases/${db}/queries?start=${opts.start}&pageSize=${opts.pageSize}`;
|
|
15974
16053
|
}
|
|
15975
16054
|
if (opts.query) {
|
|
15976
|
-
|
|
16055
|
+
path58 += `&query=${encodeURIComponent(opts.query)}`;
|
|
15977
16056
|
}
|
|
15978
|
-
return
|
|
16057
|
+
return path58;
|
|
15979
16058
|
}
|
|
15980
16059
|
|
|
15981
16060
|
// src/commands/ravendb/fetchAllPages.ts
|
|
@@ -15984,7 +16063,7 @@ async function fetchAllPages(connection, opts) {
|
|
|
15984
16063
|
let start3 = 0;
|
|
15985
16064
|
while (true) {
|
|
15986
16065
|
const effectivePageSize = opts.limit !== void 0 ? Math.min(opts.pageSize, opts.limit - allResults.length) : opts.pageSize;
|
|
15987
|
-
const
|
|
16066
|
+
const path58 = buildQueryPath({
|
|
15988
16067
|
db: connection.database,
|
|
15989
16068
|
collection: opts.collection,
|
|
15990
16069
|
start: start3,
|
|
@@ -15992,7 +16071,7 @@ async function fetchAllPages(connection, opts) {
|
|
|
15992
16071
|
sort: opts.sort,
|
|
15993
16072
|
query: opts.query
|
|
15994
16073
|
});
|
|
15995
|
-
const data = await ravenFetch(connection,
|
|
16074
|
+
const data = await ravenFetch(connection, path58);
|
|
15996
16075
|
const results = data.Results ?? [];
|
|
15997
16076
|
const totalResults = data.TotalResults ?? 0;
|
|
15998
16077
|
if (results.length === 0) break;
|
|
@@ -16049,7 +16128,7 @@ function registerRavendb(program2) {
|
|
|
16049
16128
|
|
|
16050
16129
|
// src/commands/refactor/check/index.ts
|
|
16051
16130
|
import { spawn as spawn5 } from "child_process";
|
|
16052
|
-
import * as
|
|
16131
|
+
import * as path29 from "path";
|
|
16053
16132
|
|
|
16054
16133
|
// src/commands/refactor/logViolations.ts
|
|
16055
16134
|
import chalk165 from "chalk";
|
|
@@ -16226,7 +16305,7 @@ ${failed2.length} verify script(s) failed:`);
|
|
|
16226
16305
|
async function runVerifyQuietly() {
|
|
16227
16306
|
const result = findPackageJsonWithVerifyScripts(process.cwd());
|
|
16228
16307
|
if (!result) return true;
|
|
16229
|
-
const packageDir =
|
|
16308
|
+
const packageDir = path29.dirname(result.packageJsonPath);
|
|
16230
16309
|
const results = await Promise.all(
|
|
16231
16310
|
result.verifyScripts.map((script) => runScript(script, packageDir))
|
|
16232
16311
|
);
|
|
@@ -16252,7 +16331,7 @@ async function check(pattern2, options2) {
|
|
|
16252
16331
|
}
|
|
16253
16332
|
|
|
16254
16333
|
// src/commands/refactor/extract/index.ts
|
|
16255
|
-
import
|
|
16334
|
+
import path36 from "path";
|
|
16256
16335
|
import chalk168 from "chalk";
|
|
16257
16336
|
|
|
16258
16337
|
// src/commands/refactor/extract/applyExtraction.ts
|
|
@@ -16705,9 +16784,9 @@ function buildDestinationContent(functionTexts, imports, sourceRelativePath, sou
|
|
|
16705
16784
|
}
|
|
16706
16785
|
|
|
16707
16786
|
// src/commands/refactor/extract/getRelativeImportPath.ts
|
|
16708
|
-
import
|
|
16787
|
+
import path30 from "path";
|
|
16709
16788
|
function getRelativeImportPath(from, to) {
|
|
16710
|
-
let rel =
|
|
16789
|
+
let rel = path30.relative(path30.dirname(from), to).replace(/\.tsx?$/, "").replace(/\\/g, "/");
|
|
16711
16790
|
if (!rel.startsWith(".")) rel = `./${rel}`;
|
|
16712
16791
|
return rel;
|
|
16713
16792
|
}
|
|
@@ -16731,9 +16810,9 @@ function findImporters(functionName, sourceFile, destPath, project) {
|
|
|
16731
16810
|
}
|
|
16732
16811
|
|
|
16733
16812
|
// src/commands/refactor/extract/resolveBarrel.ts
|
|
16734
|
-
import
|
|
16813
|
+
import path31 from "path";
|
|
16735
16814
|
function resolveBarrel(functionName, sourcePath, destPath, project) {
|
|
16736
|
-
const indexPath =
|
|
16815
|
+
const indexPath = path31.join(path31.dirname(destPath), "index.ts");
|
|
16737
16816
|
const barrel = project.getSourceFile(indexPath);
|
|
16738
16817
|
if (!barrel) return { barrel: void 0, barrelRelPath: "" };
|
|
16739
16818
|
const sourceRelFromBarrel = getRelativeImportPath(indexPath, sourcePath);
|
|
@@ -16751,15 +16830,15 @@ function resolveBarrel(functionName, sourcePath, destPath, project) {
|
|
|
16751
16830
|
}
|
|
16752
16831
|
|
|
16753
16832
|
// src/commands/refactor/extract/rewriteImportPaths.ts
|
|
16754
|
-
import
|
|
16833
|
+
import path32 from "path";
|
|
16755
16834
|
function rewriteImportPaths(imports, sourcePath, destPath) {
|
|
16756
|
-
const sourceDir =
|
|
16757
|
-
const destDir =
|
|
16835
|
+
const sourceDir = path32.dirname(sourcePath);
|
|
16836
|
+
const destDir = path32.dirname(destPath);
|
|
16758
16837
|
return imports.map((imp) => {
|
|
16759
16838
|
if (!imp.moduleSpecifier.startsWith(".")) return imp;
|
|
16760
|
-
const absolute =
|
|
16761
|
-
let rel =
|
|
16762
|
-
if (rel === "") rel = `../${
|
|
16839
|
+
const absolute = path32.resolve(sourceDir, imp.moduleSpecifier);
|
|
16840
|
+
let rel = path32.relative(destDir, absolute).replace(/\\/g, "/");
|
|
16841
|
+
if (rel === "") rel = `../${path32.basename(absolute)}`;
|
|
16763
16842
|
else if (!rel.startsWith(".")) rel = `./${rel}`;
|
|
16764
16843
|
return { ...imp, moduleSpecifier: rel };
|
|
16765
16844
|
});
|
|
@@ -16827,7 +16906,7 @@ function buildPlan2(functionName, sourceFile, sourcePath, destPath, project) {
|
|
|
16827
16906
|
}
|
|
16828
16907
|
|
|
16829
16908
|
// src/commands/refactor/extract/displayPlan.ts
|
|
16830
|
-
import
|
|
16909
|
+
import path33 from "path";
|
|
16831
16910
|
import chalk166 from "chalk";
|
|
16832
16911
|
function section(title) {
|
|
16833
16912
|
return `
|
|
@@ -16837,7 +16916,7 @@ function displayImporters(plan2, cwd) {
|
|
|
16837
16916
|
if (plan2.importersToUpdate.length === 0) return;
|
|
16838
16917
|
console.log(section("Update importers:"));
|
|
16839
16918
|
for (const imp of plan2.importersToUpdate) {
|
|
16840
|
-
const rel =
|
|
16919
|
+
const rel = path33.relative(cwd, imp.file.getFilePath());
|
|
16841
16920
|
console.log(` ${chalk166.dim(rel)}: \u2192 import from "${imp.relPath}"`);
|
|
16842
16921
|
}
|
|
16843
16922
|
}
|
|
@@ -16877,16 +16956,16 @@ function displayPlan(functionName, relDest, plan2, cwd) {
|
|
|
16877
16956
|
}
|
|
16878
16957
|
|
|
16879
16958
|
// src/commands/refactor/extract/loadProjectFile.ts
|
|
16880
|
-
import
|
|
16959
|
+
import path35 from "path";
|
|
16881
16960
|
import chalk167 from "chalk";
|
|
16882
16961
|
import { Project as Project4 } from "ts-morph";
|
|
16883
16962
|
|
|
16884
16963
|
// src/commands/refactor/extract/findTsConfig.ts
|
|
16885
16964
|
import fs23 from "fs";
|
|
16886
|
-
import
|
|
16965
|
+
import path34 from "path";
|
|
16887
16966
|
import { Project as Project3 } from "ts-morph";
|
|
16888
16967
|
function findTsConfig(sourcePath) {
|
|
16889
|
-
const rootConfig =
|
|
16968
|
+
const rootConfig = path34.resolve("tsconfig.json");
|
|
16890
16969
|
if (!fs23.existsSync(rootConfig)) return rootConfig;
|
|
16891
16970
|
const tried = /* @__PURE__ */ new Set();
|
|
16892
16971
|
const candidates = [rootConfig, ...readReferences(rootConfig)];
|
|
@@ -16895,7 +16974,7 @@ function findTsConfig(sourcePath) {
|
|
|
16895
16974
|
tried.add(candidate);
|
|
16896
16975
|
if (projectIncludes(candidate, sourcePath)) return candidate;
|
|
16897
16976
|
}
|
|
16898
|
-
const siblings = fs23.readdirSync(
|
|
16977
|
+
const siblings = fs23.readdirSync(path34.dirname(rootConfig)).filter((f) => /^tsconfig.*\.json$/.test(f)).map((f) => path34.resolve(path34.dirname(rootConfig), f));
|
|
16899
16978
|
for (const sibling of siblings) {
|
|
16900
16979
|
if (tried.has(sibling)) continue;
|
|
16901
16980
|
tried.add(sibling);
|
|
@@ -16914,10 +16993,10 @@ function readReferences(configPath) {
|
|
|
16914
16993
|
return [];
|
|
16915
16994
|
}
|
|
16916
16995
|
if (!parsed.references?.length) return [];
|
|
16917
|
-
const cwd =
|
|
16996
|
+
const cwd = path34.dirname(configPath);
|
|
16918
16997
|
return parsed.references.map((ref) => {
|
|
16919
|
-
const refPath =
|
|
16920
|
-
return fs23.statSync(refPath, { throwIfNoEntry: false })?.isDirectory() ?
|
|
16998
|
+
const refPath = path34.resolve(cwd, ref.path);
|
|
16999
|
+
return fs23.statSync(refPath, { throwIfNoEntry: false })?.isDirectory() ? path34.join(refPath, "tsconfig.json") : refPath;
|
|
16921
17000
|
}).filter((p) => fs23.existsSync(p));
|
|
16922
17001
|
}
|
|
16923
17002
|
function projectIncludes(configPath, sourcePath) {
|
|
@@ -16931,7 +17010,7 @@ function projectIncludes(configPath, sourcePath) {
|
|
|
16931
17010
|
|
|
16932
17011
|
// src/commands/refactor/extract/loadProjectFile.ts
|
|
16933
17012
|
function loadProjectFile(file) {
|
|
16934
|
-
const sourcePath =
|
|
17013
|
+
const sourcePath = path35.resolve(file);
|
|
16935
17014
|
const tsConfigPath = findTsConfig(sourcePath);
|
|
16936
17015
|
const project = new Project4({
|
|
16937
17016
|
tsConfigFilePath: tsConfigPath
|
|
@@ -16946,10 +17025,10 @@ function loadProjectFile(file) {
|
|
|
16946
17025
|
|
|
16947
17026
|
// src/commands/refactor/extract/index.ts
|
|
16948
17027
|
async function extract(file, functionName, destination, options2 = {}) {
|
|
16949
|
-
const sourcePath =
|
|
16950
|
-
const destPath =
|
|
17028
|
+
const sourcePath = path36.resolve(file);
|
|
17029
|
+
const destPath = path36.resolve(destination);
|
|
16951
17030
|
const cwd = process.cwd();
|
|
16952
|
-
const relDest =
|
|
17031
|
+
const relDest = path36.relative(cwd, destPath);
|
|
16953
17032
|
const { project, sourceFile } = loadProjectFile(file);
|
|
16954
17033
|
const plan2 = buildPlan2(
|
|
16955
17034
|
functionName,
|
|
@@ -16997,16 +17076,16 @@ function ignore2(file) {
|
|
|
16997
17076
|
|
|
16998
17077
|
// src/commands/refactor/rename/index.ts
|
|
16999
17078
|
import fs27 from "fs";
|
|
17000
|
-
import
|
|
17079
|
+
import path41 from "path";
|
|
17001
17080
|
import chalk172 from "chalk";
|
|
17002
17081
|
|
|
17003
17082
|
// src/commands/refactor/rename/applyRename.ts
|
|
17004
17083
|
import fs26 from "fs";
|
|
17005
|
-
import
|
|
17084
|
+
import path38 from "path";
|
|
17006
17085
|
import chalk170 from "chalk";
|
|
17007
17086
|
|
|
17008
17087
|
// src/commands/refactor/restructure/computeRewrites/index.ts
|
|
17009
|
-
import
|
|
17088
|
+
import path37 from "path";
|
|
17010
17089
|
|
|
17011
17090
|
// src/commands/refactor/restructure/computeRewrites/applyRewrites.ts
|
|
17012
17091
|
import fs25 from "fs";
|
|
@@ -17060,7 +17139,7 @@ function normalizeSpecifier(rel) {
|
|
|
17060
17139
|
);
|
|
17061
17140
|
}
|
|
17062
17141
|
function computeSpecifier(fromFile, toFile) {
|
|
17063
|
-
return normalizeSpecifier(
|
|
17142
|
+
return normalizeSpecifier(path37.relative(path37.dirname(fromFile), toFile));
|
|
17064
17143
|
}
|
|
17065
17144
|
function isAffected(edge, moveMap) {
|
|
17066
17145
|
return moveMap.has(edge.target) || moveMap.has(edge.source);
|
|
@@ -17108,20 +17187,20 @@ function applyRename(rewrites, sourcePath, destPath, cwd) {
|
|
|
17108
17187
|
const updatedContents = applyRewrites(rewrites);
|
|
17109
17188
|
for (const [file, content] of updatedContents) {
|
|
17110
17189
|
fs26.writeFileSync(file, content, "utf8");
|
|
17111
|
-
console.log(chalk170.cyan(` Updated imports in ${
|
|
17190
|
+
console.log(chalk170.cyan(` Updated imports in ${path38.relative(cwd, file)}`));
|
|
17112
17191
|
}
|
|
17113
|
-
const destDir =
|
|
17192
|
+
const destDir = path38.dirname(destPath);
|
|
17114
17193
|
if (!fs26.existsSync(destDir)) fs26.mkdirSync(destDir, { recursive: true });
|
|
17115
17194
|
fs26.renameSync(sourcePath, destPath);
|
|
17116
17195
|
console.log(
|
|
17117
17196
|
chalk170.white(
|
|
17118
|
-
` Moved ${
|
|
17197
|
+
` Moved ${path38.relative(cwd, sourcePath)} \u2192 ${path38.relative(cwd, destPath)}`
|
|
17119
17198
|
)
|
|
17120
17199
|
);
|
|
17121
17200
|
}
|
|
17122
17201
|
|
|
17123
17202
|
// src/commands/refactor/restructure/buildImportGraph/index.ts
|
|
17124
|
-
import
|
|
17203
|
+
import path39 from "path";
|
|
17125
17204
|
import ts7 from "typescript";
|
|
17126
17205
|
|
|
17127
17206
|
// src/commands/refactor/restructure/buildImportGraph/getImportSpecifiers.ts
|
|
@@ -17148,7 +17227,7 @@ function loadParsedConfig(tsConfigPath) {
|
|
|
17148
17227
|
return ts7.parseJsonConfigFileContent(
|
|
17149
17228
|
configFile.config,
|
|
17150
17229
|
ts7.sys,
|
|
17151
|
-
|
|
17230
|
+
path39.dirname(tsConfigPath)
|
|
17152
17231
|
);
|
|
17153
17232
|
}
|
|
17154
17233
|
function addToSetMap(map, key, value) {
|
|
@@ -17164,7 +17243,7 @@ function resolveImport(specifier, filePath, options2) {
|
|
|
17164
17243
|
const resolved = ts7.resolveModuleName(specifier, filePath, options2, ts7.sys);
|
|
17165
17244
|
const resolvedPath = resolved.resolvedModule?.resolvedFileName;
|
|
17166
17245
|
if (!resolvedPath || resolvedPath.includes("node_modules")) return null;
|
|
17167
|
-
return
|
|
17246
|
+
return path39.resolve(resolvedPath);
|
|
17168
17247
|
}
|
|
17169
17248
|
function buildImportGraph(candidateFiles, tsConfigPath) {
|
|
17170
17249
|
const parsed = loadParsedConfig(tsConfigPath);
|
|
@@ -17173,7 +17252,7 @@ function buildImportGraph(candidateFiles, tsConfigPath) {
|
|
|
17173
17252
|
const importedBy = /* @__PURE__ */ new Map();
|
|
17174
17253
|
const imports = /* @__PURE__ */ new Map();
|
|
17175
17254
|
for (const sourceFile of program2.getSourceFiles()) {
|
|
17176
|
-
const filePath =
|
|
17255
|
+
const filePath = path39.resolve(sourceFile.fileName);
|
|
17177
17256
|
if (filePath.includes("node_modules")) continue;
|
|
17178
17257
|
for (const specifier of getImportSpecifiers(sourceFile)) {
|
|
17179
17258
|
const absTarget = resolveImport(specifier, filePath, parsed.options);
|
|
@@ -17200,13 +17279,13 @@ function computeRenameRewrites(sourcePath, destPath) {
|
|
|
17200
17279
|
}
|
|
17201
17280
|
|
|
17202
17281
|
// src/commands/refactor/rename/printRenamePreview.ts
|
|
17203
|
-
import
|
|
17282
|
+
import path40 from "path";
|
|
17204
17283
|
import chalk171 from "chalk";
|
|
17205
17284
|
function printRenamePreview(rewrites, cwd) {
|
|
17206
17285
|
for (const rewrite of rewrites) {
|
|
17207
17286
|
console.log(
|
|
17208
17287
|
chalk171.dim(
|
|
17209
|
-
` ${
|
|
17288
|
+
` ${path40.relative(cwd, rewrite.file)}: ${rewrite.oldSpecifier} \u2192 ${rewrite.newSpecifier}`
|
|
17210
17289
|
)
|
|
17211
17290
|
);
|
|
17212
17291
|
}
|
|
@@ -17215,11 +17294,11 @@ function printRenamePreview(rewrites, cwd) {
|
|
|
17215
17294
|
|
|
17216
17295
|
// src/commands/refactor/rename/index.ts
|
|
17217
17296
|
async function rename(source, destination, options2 = {}) {
|
|
17218
|
-
const sourcePath =
|
|
17219
|
-
const destPath =
|
|
17297
|
+
const sourcePath = path41.resolve(source);
|
|
17298
|
+
const destPath = path41.resolve(destination);
|
|
17220
17299
|
const cwd = process.cwd();
|
|
17221
|
-
const relSource =
|
|
17222
|
-
const relDest =
|
|
17300
|
+
const relSource = path41.relative(cwd, sourcePath);
|
|
17301
|
+
const relDest = path41.relative(cwd, destPath);
|
|
17223
17302
|
if (!fs27.existsSync(sourcePath)) {
|
|
17224
17303
|
console.log(chalk172.red(`File not found: ${source}`));
|
|
17225
17304
|
process.exit(1);
|
|
@@ -17274,12 +17353,12 @@ function findSymbol(sourceFile, symbolName) {
|
|
|
17274
17353
|
}
|
|
17275
17354
|
|
|
17276
17355
|
// src/commands/refactor/renameSymbol/groupReferences.ts
|
|
17277
|
-
import
|
|
17356
|
+
import path42 from "path";
|
|
17278
17357
|
function groupReferences(symbol, cwd) {
|
|
17279
17358
|
const refs = symbol.findReferencesAsNodes();
|
|
17280
17359
|
const grouped = /* @__PURE__ */ new Map();
|
|
17281
17360
|
for (const ref of refs) {
|
|
17282
|
-
const refFile =
|
|
17361
|
+
const refFile = path42.relative(cwd, ref.getSourceFile().getFilePath());
|
|
17283
17362
|
const lines = grouped.get(refFile) ?? [];
|
|
17284
17363
|
if (!grouped.has(refFile)) grouped.set(refFile, lines);
|
|
17285
17364
|
lines.push(ref.getStartLineNumber());
|
|
@@ -17318,16 +17397,16 @@ Renamed ${oldName} \u2192 ${newName}`));
|
|
|
17318
17397
|
}
|
|
17319
17398
|
|
|
17320
17399
|
// src/commands/refactor/restructure/index.ts
|
|
17321
|
-
import
|
|
17400
|
+
import path49 from "path";
|
|
17322
17401
|
import chalk176 from "chalk";
|
|
17323
17402
|
|
|
17324
17403
|
// src/commands/refactor/restructure/clusterDirectories.ts
|
|
17325
|
-
import
|
|
17404
|
+
import path43 from "path";
|
|
17326
17405
|
function clusterDirectories(graph) {
|
|
17327
17406
|
const dirImportedBy = /* @__PURE__ */ new Map();
|
|
17328
17407
|
for (const edge of graph.edges) {
|
|
17329
|
-
const sourceDir =
|
|
17330
|
-
const targetDir =
|
|
17408
|
+
const sourceDir = path43.dirname(edge.source);
|
|
17409
|
+
const targetDir = path43.dirname(edge.target);
|
|
17331
17410
|
if (sourceDir === targetDir) continue;
|
|
17332
17411
|
if (!graph.files.has(edge.target)) continue;
|
|
17333
17412
|
const existing = dirImportedBy.get(targetDir) ?? /* @__PURE__ */ new Set();
|
|
@@ -17355,20 +17434,20 @@ function clusterDirectories(graph) {
|
|
|
17355
17434
|
return clusters;
|
|
17356
17435
|
}
|
|
17357
17436
|
function isAncestor(ancestor, descendant) {
|
|
17358
|
-
const rel =
|
|
17437
|
+
const rel = path43.relative(ancestor, descendant);
|
|
17359
17438
|
return !rel.startsWith("..") && rel !== "";
|
|
17360
17439
|
}
|
|
17361
17440
|
|
|
17362
17441
|
// src/commands/refactor/restructure/clusterFiles.ts
|
|
17363
|
-
import
|
|
17442
|
+
import path44 from "path";
|
|
17364
17443
|
function findRootParent(file, importedBy, visited) {
|
|
17365
17444
|
const importers = importedBy.get(file);
|
|
17366
17445
|
if (!importers || importers.size !== 1) return file;
|
|
17367
17446
|
const parent = [...importers][0];
|
|
17368
|
-
const parentDir =
|
|
17369
|
-
const fileDir =
|
|
17447
|
+
const parentDir = path44.dirname(parent);
|
|
17448
|
+
const fileDir = path44.dirname(file);
|
|
17370
17449
|
if (parentDir !== fileDir) return file;
|
|
17371
|
-
if (
|
|
17450
|
+
if (path44.basename(parent, path44.extname(parent)) === "index") return file;
|
|
17372
17451
|
if (visited.has(parent)) return file;
|
|
17373
17452
|
visited.add(parent);
|
|
17374
17453
|
return findRootParent(parent, importedBy, visited);
|
|
@@ -17376,16 +17455,16 @@ function findRootParent(file, importedBy, visited) {
|
|
|
17376
17455
|
function clusterFiles(graph) {
|
|
17377
17456
|
const clusters = /* @__PURE__ */ new Map();
|
|
17378
17457
|
for (const file of graph.files) {
|
|
17379
|
-
const basename13 =
|
|
17458
|
+
const basename13 = path44.basename(file, path44.extname(file));
|
|
17380
17459
|
if (basename13 === "index") continue;
|
|
17381
17460
|
const importers = graph.importedBy.get(file);
|
|
17382
17461
|
if (!importers || importers.size !== 1) continue;
|
|
17383
17462
|
const parent = [...importers][0];
|
|
17384
17463
|
if (!graph.files.has(parent)) continue;
|
|
17385
|
-
const parentDir =
|
|
17386
|
-
const fileDir =
|
|
17464
|
+
const parentDir = path44.dirname(parent);
|
|
17465
|
+
const fileDir = path44.dirname(file);
|
|
17387
17466
|
if (parentDir !== fileDir) continue;
|
|
17388
|
-
const parentBasename =
|
|
17467
|
+
const parentBasename = path44.basename(parent, path44.extname(parent));
|
|
17389
17468
|
if (parentBasename === "index") continue;
|
|
17390
17469
|
const root = findRootParent(parent, graph.importedBy, /* @__PURE__ */ new Set([file]));
|
|
17391
17470
|
if (!root || root === file) continue;
|
|
@@ -17397,10 +17476,10 @@ function clusterFiles(graph) {
|
|
|
17397
17476
|
}
|
|
17398
17477
|
|
|
17399
17478
|
// src/commands/refactor/restructure/displayPlan.ts
|
|
17400
|
-
import
|
|
17479
|
+
import path45 from "path";
|
|
17401
17480
|
import chalk174 from "chalk";
|
|
17402
17481
|
function relPath(filePath) {
|
|
17403
|
-
return
|
|
17482
|
+
return path45.relative(process.cwd(), filePath);
|
|
17404
17483
|
}
|
|
17405
17484
|
function displayMoves(plan2) {
|
|
17406
17485
|
if (plan2.moves.length === 0) return;
|
|
@@ -17450,33 +17529,33 @@ Summary: ${plan2.moves.length} file(s) moved, ${plan2.rewrites.length} imports r
|
|
|
17450
17529
|
|
|
17451
17530
|
// src/commands/refactor/restructure/executePlan.ts
|
|
17452
17531
|
import fs28 from "fs";
|
|
17453
|
-
import
|
|
17532
|
+
import path46 from "path";
|
|
17454
17533
|
import chalk175 from "chalk";
|
|
17455
17534
|
function executePlan(plan2) {
|
|
17456
17535
|
const updatedContents = applyRewrites(plan2.rewrites);
|
|
17457
17536
|
for (const [file, content] of updatedContents) {
|
|
17458
17537
|
fs28.writeFileSync(file, content, "utf8");
|
|
17459
17538
|
console.log(
|
|
17460
|
-
chalk175.cyan(` Rewrote imports in ${
|
|
17539
|
+
chalk175.cyan(` Rewrote imports in ${path46.relative(process.cwd(), file)}`)
|
|
17461
17540
|
);
|
|
17462
17541
|
}
|
|
17463
17542
|
for (const dir of plan2.newDirectories) {
|
|
17464
17543
|
fs28.mkdirSync(dir, { recursive: true });
|
|
17465
|
-
console.log(chalk175.green(` Created ${
|
|
17544
|
+
console.log(chalk175.green(` Created ${path46.relative(process.cwd(), dir)}/`));
|
|
17466
17545
|
}
|
|
17467
17546
|
for (const move2 of plan2.moves) {
|
|
17468
|
-
const targetDir =
|
|
17547
|
+
const targetDir = path46.dirname(move2.to);
|
|
17469
17548
|
if (!fs28.existsSync(targetDir)) {
|
|
17470
17549
|
fs28.mkdirSync(targetDir, { recursive: true });
|
|
17471
17550
|
}
|
|
17472
17551
|
fs28.renameSync(move2.from, move2.to);
|
|
17473
17552
|
console.log(
|
|
17474
17553
|
chalk175.white(
|
|
17475
|
-
` Moved ${
|
|
17554
|
+
` Moved ${path46.relative(process.cwd(), move2.from)} \u2192 ${path46.relative(process.cwd(), move2.to)}`
|
|
17476
17555
|
)
|
|
17477
17556
|
);
|
|
17478
17557
|
}
|
|
17479
|
-
removeEmptyDirectories(plan2.moves.map((m) =>
|
|
17558
|
+
removeEmptyDirectories(plan2.moves.map((m) => path46.dirname(m.from)));
|
|
17480
17559
|
}
|
|
17481
17560
|
function removeEmptyDirectories(dirs) {
|
|
17482
17561
|
const unique = [...new Set(dirs)];
|
|
@@ -17487,7 +17566,7 @@ function removeEmptyDirectories(dirs) {
|
|
|
17487
17566
|
fs28.rmdirSync(dir);
|
|
17488
17567
|
console.log(
|
|
17489
17568
|
chalk175.dim(
|
|
17490
|
-
` Removed empty directory ${
|
|
17569
|
+
` Removed empty directory ${path46.relative(process.cwd(), dir)}`
|
|
17491
17570
|
)
|
|
17492
17571
|
);
|
|
17493
17572
|
}
|
|
@@ -17495,7 +17574,7 @@ function removeEmptyDirectories(dirs) {
|
|
|
17495
17574
|
}
|
|
17496
17575
|
|
|
17497
17576
|
// src/commands/refactor/restructure/planFileMoves/index.ts
|
|
17498
|
-
import
|
|
17577
|
+
import path48 from "path";
|
|
17499
17578
|
|
|
17500
17579
|
// src/commands/refactor/restructure/planFileMoves/shared.ts
|
|
17501
17580
|
import fs29 from "fs";
|
|
@@ -17510,9 +17589,9 @@ function checkDirConflict(result, label2, dir) {
|
|
|
17510
17589
|
|
|
17511
17590
|
// src/commands/refactor/restructure/planFileMoves/planDirectoryMoves.ts
|
|
17512
17591
|
import fs30 from "fs";
|
|
17513
|
-
import
|
|
17592
|
+
import path47 from "path";
|
|
17514
17593
|
function collectEntry(results, dir, entry) {
|
|
17515
|
-
const full =
|
|
17594
|
+
const full = path47.join(dir, entry.name);
|
|
17516
17595
|
const items2 = entry.isDirectory() ? listFilesRecursive(full) : [full];
|
|
17517
17596
|
results.push(...items2);
|
|
17518
17597
|
}
|
|
@@ -17526,15 +17605,15 @@ function listFilesRecursive(dir) {
|
|
|
17526
17605
|
}
|
|
17527
17606
|
function addDirectoryFileMoves(moves, childDir, newLocation, reason) {
|
|
17528
17607
|
for (const file of listFilesRecursive(childDir)) {
|
|
17529
|
-
const rel =
|
|
17530
|
-
moves.push({ from: file, to:
|
|
17608
|
+
const rel = path47.relative(childDir, file);
|
|
17609
|
+
moves.push({ from: file, to: path47.join(newLocation, rel), reason });
|
|
17531
17610
|
}
|
|
17532
17611
|
}
|
|
17533
17612
|
function resolveChildDest(parentDir, childDir) {
|
|
17534
|
-
return
|
|
17613
|
+
return path47.join(parentDir, path47.basename(childDir));
|
|
17535
17614
|
}
|
|
17536
17615
|
function childMoveReason(parentDir) {
|
|
17537
|
-
return `Directory only imported from ${
|
|
17616
|
+
return `Directory only imported from ${path47.basename(parentDir)}/`;
|
|
17538
17617
|
}
|
|
17539
17618
|
function registerDirectoryMove(result, childDir, dest, parentDir) {
|
|
17540
17619
|
result.directories.push(dest);
|
|
@@ -17559,7 +17638,7 @@ function planDirectoryMoves(clusters) {
|
|
|
17559
17638
|
|
|
17560
17639
|
// src/commands/refactor/restructure/planFileMoves/index.ts
|
|
17561
17640
|
function childMoveData(child, newDir, parentBase) {
|
|
17562
|
-
const to =
|
|
17641
|
+
const to = path48.join(newDir, path48.basename(child));
|
|
17563
17642
|
return { from: child, to, reason: `Only imported by ${parentBase}` };
|
|
17564
17643
|
}
|
|
17565
17644
|
function addChildMoves(moves, children, newDir, parentBase) {
|
|
@@ -17567,15 +17646,15 @@ function addChildMoves(moves, children, newDir, parentBase) {
|
|
|
17567
17646
|
moves.push(childMoveData(child, newDir, parentBase));
|
|
17568
17647
|
}
|
|
17569
17648
|
function getBaseName(filePath) {
|
|
17570
|
-
return
|
|
17649
|
+
return path48.basename(filePath, path48.extname(filePath));
|
|
17571
17650
|
}
|
|
17572
17651
|
function resolveClusterDir(parent) {
|
|
17573
|
-
return
|
|
17652
|
+
return path48.join(path48.dirname(parent), getBaseName(parent));
|
|
17574
17653
|
}
|
|
17575
17654
|
function createParentMove(parent, newDir) {
|
|
17576
17655
|
return {
|
|
17577
17656
|
from: parent,
|
|
17578
|
-
to:
|
|
17657
|
+
to: path48.join(newDir, `index${path48.extname(parent)}`),
|
|
17579
17658
|
reason: `Main module of new ${getBaseName(parent)}/ directory`
|
|
17580
17659
|
};
|
|
17581
17660
|
}
|
|
@@ -17599,7 +17678,7 @@ function planFileMoves(clusters) {
|
|
|
17599
17678
|
|
|
17600
17679
|
// src/commands/refactor/restructure/index.ts
|
|
17601
17680
|
function buildPlan3(candidateFiles, tsConfigPath) {
|
|
17602
|
-
const candidates = new Set(candidateFiles.map((f) =>
|
|
17681
|
+
const candidates = new Set(candidateFiles.map((f) => path49.resolve(f)));
|
|
17603
17682
|
const graph = buildImportGraph(candidates, tsConfigPath);
|
|
17604
17683
|
const allProjectFiles = /* @__PURE__ */ new Set([
|
|
17605
17684
|
...graph.importedBy.keys(),
|
|
@@ -17622,7 +17701,7 @@ async function restructure(pattern2, options2 = {}) {
|
|
|
17622
17701
|
console.log(chalk176.yellow("No files found matching pattern"));
|
|
17623
17702
|
return;
|
|
17624
17703
|
}
|
|
17625
|
-
const tsConfigPath =
|
|
17704
|
+
const tsConfigPath = path49.resolve("tsconfig.json");
|
|
17626
17705
|
const plan2 = buildPlan3(files, tsConfigPath);
|
|
17627
17706
|
if (plan2.moves.length === 0) {
|
|
17628
17707
|
console.log(chalk176.green("No restructuring needed"));
|
|
@@ -18345,8 +18424,8 @@ async function handlePostSynthesis(synthesisPath, options2) {
|
|
|
18345
18424
|
// src/commands/review/prepareReviewDir.ts
|
|
18346
18425
|
import { existsSync as existsSync40, mkdirSync as mkdirSync16, unlinkSync as unlinkSync14, writeFileSync as writeFileSync33 } from "fs";
|
|
18347
18426
|
function clearReviewFiles(paths) {
|
|
18348
|
-
for (const
|
|
18349
|
-
if (existsSync40(
|
|
18427
|
+
for (const path58 of [paths.claudePath, paths.codexPath, paths.synthesisPath]) {
|
|
18428
|
+
if (existsSync40(path58)) unlinkSync14(path58);
|
|
18350
18429
|
}
|
|
18351
18430
|
}
|
|
18352
18431
|
function prepareReviewDir(paths, requestBody, force) {
|
|
@@ -19480,8 +19559,8 @@ import chalk184 from "chalk";
|
|
|
19480
19559
|
|
|
19481
19560
|
// src/commands/seq/fetchSeq.ts
|
|
19482
19561
|
import chalk181 from "chalk";
|
|
19483
|
-
async function fetchSeq(conn,
|
|
19484
|
-
const url = `${conn.url}${
|
|
19562
|
+
async function fetchSeq(conn, path58, params) {
|
|
19563
|
+
const url = `${conn.url}${path58}?${params}`;
|
|
19485
19564
|
const response = await fetch(url, {
|
|
19486
19565
|
headers: {
|
|
19487
19566
|
Accept: "application/json",
|
|
@@ -20835,9 +20914,9 @@ function findPortFile(roamDir) {
|
|
|
20835
20914
|
return void 0;
|
|
20836
20915
|
}
|
|
20837
20916
|
const candidates = entries.filter((name) => /^roam-local-api(-[^.]+)?\.port$/.test(name)).map((name) => {
|
|
20838
|
-
const
|
|
20917
|
+
const path58 = join57(roamDir, name);
|
|
20839
20918
|
try {
|
|
20840
|
-
return { path:
|
|
20919
|
+
return { path: path58, mtimeMs: statSync8(path58).mtimeMs };
|
|
20841
20920
|
} catch {
|
|
20842
20921
|
return void 0;
|
|
20843
20922
|
}
|
|
@@ -21180,11 +21259,11 @@ function findLinkIndex() {
|
|
|
21180
21259
|
function parseLinkArgs() {
|
|
21181
21260
|
const idx = findLinkIndex();
|
|
21182
21261
|
if (idx === -1) return null;
|
|
21183
|
-
const
|
|
21262
|
+
const path58 = process.argv[idx + 1];
|
|
21184
21263
|
const rest = process.argv.slice(idx + 2);
|
|
21185
21264
|
const { value: prefix2 } = extractOption(rest, "--prefix");
|
|
21186
21265
|
if (!prefix2) return null;
|
|
21187
|
-
return { path:
|
|
21266
|
+
return { path: path58, prefix: prefix2 };
|
|
21188
21267
|
}
|
|
21189
21268
|
function hasDuplicateLink(runList, linkPath) {
|
|
21190
21269
|
return runList.some(
|
|
@@ -21854,14 +21933,14 @@ import * as pty from "node-pty";
|
|
|
21854
21933
|
// src/commands/sessions/daemon/ensureSpawnHelperExecutable.ts
|
|
21855
21934
|
import { chmodSync, existsSync as existsSync52, statSync as statSync9 } from "fs";
|
|
21856
21935
|
import { createRequire as createRequire3 } from "module";
|
|
21857
|
-
import
|
|
21936
|
+
import path50 from "path";
|
|
21858
21937
|
var require4 = createRequire3(import.meta.url);
|
|
21859
21938
|
var ensured = false;
|
|
21860
21939
|
function ensureSpawnHelperExecutable() {
|
|
21861
21940
|
if (ensured || process.platform !== "darwin") return;
|
|
21862
21941
|
ensured = true;
|
|
21863
|
-
const ptyRoot =
|
|
21864
|
-
const helper =
|
|
21942
|
+
const ptyRoot = path50.join(path50.dirname(require4.resolve("node-pty")), "..");
|
|
21943
|
+
const helper = path50.join(
|
|
21865
21944
|
ptyRoot,
|
|
21866
21945
|
"prebuilds",
|
|
21867
21946
|
`${process.platform}-${process.arch}`,
|
|
@@ -22276,8 +22355,8 @@ async function seedRunningMsFromUsage(session, notify2) {
|
|
|
22276
22355
|
var DEBOUNCE_MS = 50;
|
|
22277
22356
|
function watchActivity(session, notify2) {
|
|
22278
22357
|
if (session.commandType !== "assist" || !session.cwd) return;
|
|
22279
|
-
const
|
|
22280
|
-
const dir = dirname26(
|
|
22358
|
+
const path58 = activityPath(session.id);
|
|
22359
|
+
const dir = dirname26(path58);
|
|
22281
22360
|
try {
|
|
22282
22361
|
mkdirSync23(dir, { recursive: true });
|
|
22283
22362
|
} catch {
|
|
@@ -22287,7 +22366,7 @@ function watchActivity(session, notify2) {
|
|
|
22287
22366
|
let timer = null;
|
|
22288
22367
|
const read = () => {
|
|
22289
22368
|
timer = null;
|
|
22290
|
-
const activity2 = readActivity(
|
|
22369
|
+
const activity2 = readActivity(path58);
|
|
22291
22370
|
if (!activity2) return;
|
|
22292
22371
|
session.activity = activity2;
|
|
22293
22372
|
if (activity2.claudeSessionId)
|
|
@@ -22297,11 +22376,11 @@ function watchActivity(session, notify2) {
|
|
|
22297
22376
|
notify2();
|
|
22298
22377
|
};
|
|
22299
22378
|
session.activityWatcher = watch(dir, (_event, filename) => {
|
|
22300
|
-
if (filename && !
|
|
22379
|
+
if (filename && !path58.endsWith(filename)) return;
|
|
22301
22380
|
if (timer) clearTimeout(timer);
|
|
22302
22381
|
timer = setTimeout(read, DEBOUNCE_MS);
|
|
22303
22382
|
});
|
|
22304
|
-
if (existsSync53(
|
|
22383
|
+
if (existsSync53(path58)) read();
|
|
22305
22384
|
}
|
|
22306
22385
|
function refreshActivity(session) {
|
|
22307
22386
|
if (session.commandType !== "assist" || !session.cwd) return;
|
|
@@ -23523,11 +23602,11 @@ import { createInterface as createInterface9 } from "readline";
|
|
|
23523
23602
|
// src/commands/sessions/shared/discoverSessions.ts
|
|
23524
23603
|
import * as fs32 from "fs";
|
|
23525
23604
|
import * as os from "os";
|
|
23526
|
-
import * as
|
|
23605
|
+
import * as path52 from "path";
|
|
23527
23606
|
|
|
23528
23607
|
// src/commands/sessions/shared/parseSessionFile.ts
|
|
23529
23608
|
import * as fs31 from "fs";
|
|
23530
|
-
import * as
|
|
23609
|
+
import * as path51 from "path";
|
|
23531
23610
|
|
|
23532
23611
|
// src/commands/sessions/shared/deriveHistoryFields.ts
|
|
23533
23612
|
var KNOWN = [
|
|
@@ -23650,10 +23729,10 @@ async function readHeadLines(handle) {
|
|
|
23650
23729
|
}
|
|
23651
23730
|
function deriveProject(cwd, filePath, origin) {
|
|
23652
23731
|
if (!cwd) return dirNameToProject(filePath);
|
|
23653
|
-
return origin === "windows" ?
|
|
23732
|
+
return origin === "windows" ? path51.win32.basename(cwd) : path51.basename(cwd);
|
|
23654
23733
|
}
|
|
23655
23734
|
function dirNameToProject(filePath) {
|
|
23656
|
-
const dirName =
|
|
23735
|
+
const dirName = path51.basename(path51.dirname(filePath));
|
|
23657
23736
|
const parts = dirName.split("--");
|
|
23658
23737
|
return parts[parts.length - 1].replace(/-/g, "/");
|
|
23659
23738
|
}
|
|
@@ -23661,7 +23740,7 @@ function dirNameToProject(filePath) {
|
|
|
23661
23740
|
// src/commands/sessions/shared/discoverSessions.ts
|
|
23662
23741
|
function sessionRoots() {
|
|
23663
23742
|
const roots = [
|
|
23664
|
-
{ dir:
|
|
23743
|
+
{ dir: path52.join(os.homedir(), ".claude", "projects"), origin: "wsl" }
|
|
23665
23744
|
];
|
|
23666
23745
|
const windowsRoot = loadConfig().sessions?.windowsProjectsRoot;
|
|
23667
23746
|
if (windowsRoot) roots.push({ dir: windowsRoot, origin: "windows" });
|
|
@@ -23679,7 +23758,7 @@ async function discoverSessionJsonlPaths() {
|
|
|
23679
23758
|
}
|
|
23680
23759
|
await Promise.all(
|
|
23681
23760
|
projectDirs.map(async (dirName) => {
|
|
23682
|
-
const dirPath =
|
|
23761
|
+
const dirPath = path52.join(dir, dirName);
|
|
23683
23762
|
let entries;
|
|
23684
23763
|
try {
|
|
23685
23764
|
entries = await fs32.promises.readdir(dirPath);
|
|
@@ -23688,7 +23767,7 @@ async function discoverSessionJsonlPaths() {
|
|
|
23688
23767
|
}
|
|
23689
23768
|
for (const file of entries) {
|
|
23690
23769
|
if (file.endsWith(".jsonl"))
|
|
23691
|
-
results.push({ path:
|
|
23770
|
+
results.push({ path: path52.join(dirPath, file), origin });
|
|
23692
23771
|
}
|
|
23693
23772
|
})
|
|
23694
23773
|
);
|
|
@@ -23763,11 +23842,11 @@ function cleanUserText(value) {
|
|
|
23763
23842
|
}
|
|
23764
23843
|
|
|
23765
23844
|
// src/commands/sessions/shared/findSessionJsonlPath.ts
|
|
23766
|
-
import * as
|
|
23845
|
+
import * as path53 from "path";
|
|
23767
23846
|
async function findSessionJsonlPath(sessionId) {
|
|
23768
23847
|
const paths = await discoverSessionJsonlPaths();
|
|
23769
23848
|
const direct = paths.find(
|
|
23770
|
-
(p) =>
|
|
23849
|
+
(p) => path53.basename(p.path, ".jsonl") === sessionId
|
|
23771
23850
|
);
|
|
23772
23851
|
if (direct) return direct.path;
|
|
23773
23852
|
for (const p of paths) {
|
|
@@ -24461,16 +24540,16 @@ async function statusLine() {
|
|
|
24461
24540
|
// src/commands/sync.ts
|
|
24462
24541
|
import * as fs39 from "fs";
|
|
24463
24542
|
import * as os2 from "os";
|
|
24464
|
-
import * as
|
|
24543
|
+
import * as path56 from "path";
|
|
24465
24544
|
import { fileURLToPath as fileURLToPath7 } from "url";
|
|
24466
24545
|
|
|
24467
24546
|
// src/commands/sync/syncClaudeMd.ts
|
|
24468
24547
|
import * as fs37 from "fs";
|
|
24469
|
-
import * as
|
|
24548
|
+
import * as path54 from "path";
|
|
24470
24549
|
import chalk196 from "chalk";
|
|
24471
24550
|
async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
24472
|
-
const source =
|
|
24473
|
-
const target =
|
|
24551
|
+
const source = path54.join(claudeDir, "CLAUDE.md");
|
|
24552
|
+
const target = path54.join(targetBase, "CLAUDE.md");
|
|
24474
24553
|
const sourceContent = fs37.readFileSync(source, "utf8");
|
|
24475
24554
|
if (fs37.existsSync(target)) {
|
|
24476
24555
|
const targetContent = fs37.readFileSync(target, "utf8");
|
|
@@ -24496,11 +24575,11 @@ async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
|
24496
24575
|
|
|
24497
24576
|
// src/commands/sync/syncSettings.ts
|
|
24498
24577
|
import * as fs38 from "fs";
|
|
24499
|
-
import * as
|
|
24578
|
+
import * as path55 from "path";
|
|
24500
24579
|
import chalk197 from "chalk";
|
|
24501
24580
|
async function syncSettings(claudeDir, targetBase, options2) {
|
|
24502
|
-
const source =
|
|
24503
|
-
const target =
|
|
24581
|
+
const source = path55.join(claudeDir, "settings.json");
|
|
24582
|
+
const target = path55.join(targetBase, "settings.json");
|
|
24504
24583
|
const sourceContent = fs38.readFileSync(source, "utf8");
|
|
24505
24584
|
const sourceSettings = JSON.parse(sourceContent);
|
|
24506
24585
|
const targetExists = fs38.existsSync(target);
|
|
@@ -24539,23 +24618,23 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
24539
24618
|
|
|
24540
24619
|
// src/commands/sync.ts
|
|
24541
24620
|
var __filename4 = fileURLToPath7(import.meta.url);
|
|
24542
|
-
var __dirname6 =
|
|
24621
|
+
var __dirname6 = path56.dirname(__filename4);
|
|
24543
24622
|
async function sync(options2) {
|
|
24544
24623
|
const config = loadConfig();
|
|
24545
24624
|
const yes = options2?.yes ?? config.sync.autoConfirm;
|
|
24546
|
-
const claudeDir =
|
|
24547
|
-
const targetBase =
|
|
24625
|
+
const claudeDir = path56.join(__dirname6, "..", "claude");
|
|
24626
|
+
const targetBase = path56.join(os2.homedir(), ".claude");
|
|
24548
24627
|
syncCommands(claudeDir, targetBase);
|
|
24549
24628
|
await syncSettings(claudeDir, targetBase, { yes });
|
|
24550
24629
|
await syncClaudeMd(claudeDir, targetBase, { yes });
|
|
24551
24630
|
}
|
|
24552
24631
|
function syncCommands(claudeDir, targetBase) {
|
|
24553
|
-
const sourceDir =
|
|
24554
|
-
const targetDir =
|
|
24632
|
+
const sourceDir = path56.join(claudeDir, "commands");
|
|
24633
|
+
const targetDir = path56.join(targetBase, "commands");
|
|
24555
24634
|
fs39.mkdirSync(targetDir, { recursive: true });
|
|
24556
24635
|
const files = fs39.readdirSync(sourceDir);
|
|
24557
24636
|
for (const file of files) {
|
|
24558
|
-
fs39.copyFileSync(
|
|
24637
|
+
fs39.copyFileSync(path56.join(sourceDir, file), path56.join(targetDir, file));
|
|
24559
24638
|
console.log(`Copied ${file} to ${targetDir}`);
|
|
24560
24639
|
}
|
|
24561
24640
|
console.log(`Synced ${files.length} command(s) to ~/.claude/commands`);
|
|
@@ -24563,7 +24642,7 @@ function syncCommands(claudeDir, targetBase) {
|
|
|
24563
24642
|
|
|
24564
24643
|
// src/commands/update.ts
|
|
24565
24644
|
import { execSync as execSync55 } from "child_process";
|
|
24566
|
-
import * as
|
|
24645
|
+
import * as path57 from "path";
|
|
24567
24646
|
|
|
24568
24647
|
// src/commands/restartDaemonAfterUpdate.ts
|
|
24569
24648
|
async function restartDaemonAfterUpdate() {
|
|
@@ -24582,12 +24661,12 @@ async function restartDaemonAfterUpdate() {
|
|
|
24582
24661
|
// src/commands/update.ts
|
|
24583
24662
|
function isGlobalNpmInstall(dir) {
|
|
24584
24663
|
try {
|
|
24585
|
-
const resolved =
|
|
24586
|
-
if (resolved.split(
|
|
24664
|
+
const resolved = path57.resolve(dir);
|
|
24665
|
+
if (resolved.split(path57.sep).includes("node_modules")) {
|
|
24587
24666
|
return true;
|
|
24588
24667
|
}
|
|
24589
24668
|
const globalPrefix = execSync55("npm prefix -g", { stdio: "pipe" }).toString().trim();
|
|
24590
|
-
return resolved.toLowerCase().startsWith(
|
|
24669
|
+
return resolved.toLowerCase().startsWith(path57.resolve(globalPrefix).toLowerCase());
|
|
24591
24670
|
} catch {
|
|
24592
24671
|
return false;
|
|
24593
24672
|
}
|