@staff0rd/assist 0.407.0 → 0.408.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/sessions/web/bundle.js +1 -1
- package/dist/index.js +490 -419
- 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.408.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -142,10 +142,10 @@ import { stringify as stringifyYaml } from "yaml";
|
|
|
142
142
|
// src/shared/loadRawYaml.ts
|
|
143
143
|
import { existsSync, readFileSync } from "fs";
|
|
144
144
|
import { parse as parseYaml } from "yaml";
|
|
145
|
-
function loadRawYaml(
|
|
146
|
-
if (!existsSync(
|
|
145
|
+
function loadRawYaml(path69) {
|
|
146
|
+
if (!existsSync(path69)) return {};
|
|
147
147
|
try {
|
|
148
|
-
const content = readFileSync(
|
|
148
|
+
const content = readFileSync(path69, "utf8");
|
|
149
149
|
return parseYaml(content) || {};
|
|
150
150
|
} catch {
|
|
151
151
|
return {};
|
|
@@ -1436,8 +1436,8 @@ function findUnmergedPaths() {
|
|
|
1436
1436
|
}
|
|
1437
1437
|
const found = /* @__PURE__ */ new Set();
|
|
1438
1438
|
for (const line of output.split("\n")) {
|
|
1439
|
-
const
|
|
1440
|
-
if (
|
|
1439
|
+
const path69 = line.split(" ")[1];
|
|
1440
|
+
if (path69) found.add(path69.trim());
|
|
1441
1441
|
}
|
|
1442
1442
|
return [...found];
|
|
1443
1443
|
}
|
|
@@ -1536,8 +1536,8 @@ function getPreferredRemoteRepo(cwd) {
|
|
|
1536
1536
|
function gitRefUrl(kind, ref, cwd) {
|
|
1537
1537
|
const repo = getPreferredRemoteRepo(cwd);
|
|
1538
1538
|
if (!repo) return void 0;
|
|
1539
|
-
const
|
|
1540
|
-
return `https://github.com/${repo.org}/${repo.repo}/${
|
|
1539
|
+
const path69 = kind === "branch" ? "tree" : "commit";
|
|
1540
|
+
return `https://github.com/${repo.org}/${repo.repo}/${path69}/${ref}`;
|
|
1541
1541
|
}
|
|
1542
1542
|
|
|
1543
1543
|
// src/commands/commit/collectCommitRefs.ts
|
|
@@ -3404,9 +3404,9 @@ import { existsSync as existsSync12, readFileSync as readFileSync9 } from "fs";
|
|
|
3404
3404
|
|
|
3405
3405
|
// src/commands/verify/forbiddenStrings/findForbiddenStrings.ts
|
|
3406
3406
|
import { minimatch as minimatch2 } from "minimatch";
|
|
3407
|
-
function resolveStringsAtPath(data,
|
|
3407
|
+
function resolveStringsAtPath(data, path69) {
|
|
3408
3408
|
let current = data;
|
|
3409
|
-
for (const segment of
|
|
3409
|
+
for (const segment of path69.split(".")) {
|
|
3410
3410
|
if (current === null || typeof current !== "object") return [];
|
|
3411
3411
|
current = current[segment];
|
|
3412
3412
|
}
|
|
@@ -3419,10 +3419,10 @@ function resolveStringsAtPath(data, path67) {
|
|
|
3419
3419
|
}
|
|
3420
3420
|
function findRuleViolations(data, rule) {
|
|
3421
3421
|
const violations = [];
|
|
3422
|
-
for (const
|
|
3423
|
-
for (const value of resolveStringsAtPath(data,
|
|
3422
|
+
for (const path69 of rule.paths) {
|
|
3423
|
+
for (const value of resolveStringsAtPath(data, path69)) {
|
|
3424
3424
|
if (minimatch2(value, rule.disallowed))
|
|
3425
|
-
violations.push({ file: rule.file, path:
|
|
3425
|
+
violations.push({ file: rule.file, path: path69, value });
|
|
3426
3426
|
}
|
|
3427
3427
|
}
|
|
3428
3428
|
return violations;
|
|
@@ -3461,8 +3461,8 @@ function forbiddenStrings() {
|
|
|
3461
3461
|
process.exit(0);
|
|
3462
3462
|
}
|
|
3463
3463
|
console.log("Forbidden strings found:\n");
|
|
3464
|
-
for (const { file, path:
|
|
3465
|
-
console.log(` ${file} ${
|
|
3464
|
+
for (const { file, path: path69, value } of violations) {
|
|
3465
|
+
console.log(` ${file} ${path69}: ${value}`);
|
|
3466
3466
|
}
|
|
3467
3467
|
console.log(`
|
|
3468
3468
|
Total: ${violations.length} forbidden string(s).`);
|
|
@@ -3754,15 +3754,15 @@ function readBaselineMigrations(repoRelativeDir, ref) {
|
|
|
3754
3754
|
} catch {
|
|
3755
3755
|
return baseline;
|
|
3756
3756
|
}
|
|
3757
|
-
const paths = listing.split("\n").map((line) => line.trim()).filter(Boolean).filter((
|
|
3758
|
-
for (const
|
|
3757
|
+
const paths = listing.split("\n").map((line) => line.trim()).filter(Boolean).filter((path69) => MIGRATION_FILE3.test(basename(path69)));
|
|
3758
|
+
for (const path69 of paths) {
|
|
3759
3759
|
try {
|
|
3760
|
-
const content = execSync12(`git show "${ref}:${
|
|
3760
|
+
const content = execSync12(`git show "${ref}:${path69}"`, {
|
|
3761
3761
|
encoding: "utf8",
|
|
3762
3762
|
maxBuffer: 16 * 1024 * 1024,
|
|
3763
3763
|
stdio: ["pipe", "pipe", "pipe"]
|
|
3764
3764
|
});
|
|
3765
|
-
baseline.set(basename(
|
|
3765
|
+
baseline.set(basename(path69), content);
|
|
3766
3766
|
} catch {
|
|
3767
3767
|
}
|
|
3768
3768
|
}
|
|
@@ -5127,10 +5127,10 @@ var hooksSettings = {
|
|
|
5127
5127
|
}
|
|
5128
5128
|
};
|
|
5129
5129
|
function ensureHooksSettings() {
|
|
5130
|
-
const
|
|
5131
|
-
mkdirSync5(dirname12(
|
|
5132
|
-
writeFileSync15(
|
|
5133
|
-
return
|
|
5130
|
+
const path69 = daemonPaths.hooksSettings;
|
|
5131
|
+
mkdirSync5(dirname12(path69), { recursive: true });
|
|
5132
|
+
writeFileSync15(path69, JSON.stringify(hooksSettings, null, 2));
|
|
5133
|
+
return path69;
|
|
5134
5134
|
}
|
|
5135
5135
|
|
|
5136
5136
|
// src/shared/spawnInherit.ts
|
|
@@ -5395,9 +5395,9 @@ var LOCAL_FILES = ["backlog.jsonl", "backlog.db"];
|
|
|
5395
5395
|
function backupLocalBacklogFiles(dir) {
|
|
5396
5396
|
const moved = [];
|
|
5397
5397
|
for (const name of LOCAL_FILES) {
|
|
5398
|
-
const
|
|
5399
|
-
if (existsSync18(
|
|
5400
|
-
renameSync(
|
|
5398
|
+
const path69 = join15(dir, ".assist", name);
|
|
5399
|
+
if (existsSync18(path69)) {
|
|
5400
|
+
renameSync(path69, `${path69}.bak`);
|
|
5401
5401
|
moved.push(`${name} \u2192 ${name}.bak`);
|
|
5402
5402
|
}
|
|
5403
5403
|
}
|
|
@@ -5869,8 +5869,8 @@ var backlogItemSchema = z3.strictObject({
|
|
|
5869
5869
|
var backlogFileSchema = z3.array(backlogItemSchema);
|
|
5870
5870
|
|
|
5871
5871
|
// src/commands/backlog/parseBacklogJsonl.ts
|
|
5872
|
-
function parseBacklogJsonl(
|
|
5873
|
-
const content = readFileSync14(
|
|
5872
|
+
function parseBacklogJsonl(path69) {
|
|
5873
|
+
const content = readFileSync14(path69, "utf8").trim();
|
|
5874
5874
|
if (content.length === 0) return [];
|
|
5875
5875
|
return content.split("\n").map((line) => line.trim()).filter(Boolean).map((line) => backlogItemSchema.parse(JSON.parse(line)));
|
|
5876
5876
|
}
|
|
@@ -5952,8 +5952,8 @@ function findBacklogUp(startDir) {
|
|
|
5952
5952
|
|
|
5953
5953
|
// src/commands/backlog/getCurrentOrigin.ts
|
|
5954
5954
|
import { execFileSync } from "child_process";
|
|
5955
|
-
function stripLeadingSlashes(
|
|
5956
|
-
return
|
|
5955
|
+
function stripLeadingSlashes(path69) {
|
|
5956
|
+
return path69.replace(/^\/+/, "");
|
|
5957
5957
|
}
|
|
5958
5958
|
function normalizeOrigin(raw) {
|
|
5959
5959
|
const trimmed = raw.trim().replace(/\.git$/i, "").replace(/\/+$/, "");
|
|
@@ -6493,24 +6493,24 @@ function getOwnerPath(itemId2) {
|
|
|
6493
6493
|
function recordSignalOwner(itemId2) {
|
|
6494
6494
|
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
6495
6495
|
if (!sessionId) return;
|
|
6496
|
-
const
|
|
6497
|
-
mkdirSync7(dirname14(
|
|
6498
|
-
writeFileSync17(
|
|
6496
|
+
const path69 = getOwnerPath(itemId2);
|
|
6497
|
+
mkdirSync7(dirname14(path69), { recursive: true });
|
|
6498
|
+
writeFileSync17(path69, JSON.stringify({ sessionId }));
|
|
6499
6499
|
}
|
|
6500
6500
|
function readSignalOwner(itemId2) {
|
|
6501
|
-
const
|
|
6502
|
-
if (!existsSync21(
|
|
6501
|
+
const path69 = getOwnerPath(itemId2);
|
|
6502
|
+
if (!existsSync21(path69)) return void 0;
|
|
6503
6503
|
try {
|
|
6504
|
-
const parsed = JSON.parse(readFileSync15(
|
|
6504
|
+
const parsed = JSON.parse(readFileSync15(path69, "utf8"));
|
|
6505
6505
|
return parsed.sessionId;
|
|
6506
6506
|
} catch {
|
|
6507
6507
|
return void 0;
|
|
6508
6508
|
}
|
|
6509
6509
|
}
|
|
6510
6510
|
function clearSignalOwner(itemId2) {
|
|
6511
|
-
const
|
|
6511
|
+
const path69 = getOwnerPath(itemId2);
|
|
6512
6512
|
try {
|
|
6513
|
-
rmSync(
|
|
6513
|
+
rmSync(path69);
|
|
6514
6514
|
} catch {
|
|
6515
6515
|
}
|
|
6516
6516
|
}
|
|
@@ -6547,19 +6547,19 @@ function resolveSignalTarget(event, data) {
|
|
|
6547
6547
|
function writeSignal(event, data) {
|
|
6548
6548
|
const target = resolveSignalTarget(event, data);
|
|
6549
6549
|
if (!target) return;
|
|
6550
|
-
const
|
|
6551
|
-
if (!
|
|
6550
|
+
const path69 = getSignalPath(target);
|
|
6551
|
+
if (!path69) return;
|
|
6552
6552
|
const signal = { event, sessionId: target, ...data };
|
|
6553
|
-
mkdirSync8(dirname15(
|
|
6554
|
-
writeFileSync18(
|
|
6553
|
+
mkdirSync8(dirname15(path69), { recursive: true });
|
|
6554
|
+
writeFileSync18(path69, JSON.stringify(signal));
|
|
6555
6555
|
}
|
|
6556
6556
|
|
|
6557
6557
|
// src/commands/backlog/readSignal.ts
|
|
6558
6558
|
function readSignal() {
|
|
6559
|
-
const
|
|
6560
|
-
if (!
|
|
6559
|
+
const path69 = getSignalPath();
|
|
6560
|
+
if (!path69 || !existsSync22(path69)) return void 0;
|
|
6561
6561
|
try {
|
|
6562
|
-
return JSON.parse(readFileSync16(
|
|
6562
|
+
return JSON.parse(readFileSync16(path69, "utf8"));
|
|
6563
6563
|
} catch {
|
|
6564
6564
|
return void 0;
|
|
6565
6565
|
}
|
|
@@ -6692,13 +6692,13 @@ function activityPath(sessionId) {
|
|
|
6692
6692
|
function emitActivity(activity2) {
|
|
6693
6693
|
const sessionId = process.env.ASSIST_ACTIVITY_ID;
|
|
6694
6694
|
if (!sessionId) return;
|
|
6695
|
-
const
|
|
6696
|
-
mkdirSync9(dirname16(
|
|
6697
|
-
writeFileSync19(
|
|
6695
|
+
const path69 = activityPath(sessionId);
|
|
6696
|
+
mkdirSync9(dirname16(path69), { recursive: true });
|
|
6697
|
+
writeFileSync19(path69, JSON.stringify({ ...activity2, startedAt: Date.now() }));
|
|
6698
6698
|
}
|
|
6699
|
-
function readActivity(
|
|
6699
|
+
function readActivity(path69) {
|
|
6700
6700
|
try {
|
|
6701
|
-
return JSON.parse(readFileSync17(
|
|
6701
|
+
return JSON.parse(readFileSync17(path69, "utf8"));
|
|
6702
6702
|
} catch {
|
|
6703
6703
|
return void 0;
|
|
6704
6704
|
}
|
|
@@ -6708,9 +6708,9 @@ function reconcileActivity(sessionId, activity2) {
|
|
|
6708
6708
|
removeActivity(sessionId);
|
|
6709
6709
|
return;
|
|
6710
6710
|
}
|
|
6711
|
-
const
|
|
6712
|
-
mkdirSync9(dirname16(
|
|
6713
|
-
writeFileSync19(
|
|
6711
|
+
const path69 = activityPath(sessionId);
|
|
6712
|
+
mkdirSync9(dirname16(path69), { recursive: true });
|
|
6713
|
+
writeFileSync19(path69, JSON.stringify(activity2));
|
|
6714
6714
|
}
|
|
6715
6715
|
function removeActivity(sessionId) {
|
|
6716
6716
|
try {
|
|
@@ -7949,8 +7949,8 @@ async function loadItemSummaries(orm, origin) {
|
|
|
7949
7949
|
// src/commands/backlog/originDisplayName.ts
|
|
7950
7950
|
function originDisplayName(origin) {
|
|
7951
7951
|
if (origin.startsWith("local:")) {
|
|
7952
|
-
const
|
|
7953
|
-
const segments =
|
|
7952
|
+
const path69 = origin.slice("local:".length).replace(/\/+$/, "");
|
|
7953
|
+
const segments = path69.split("/").filter(Boolean);
|
|
7954
7954
|
return segments[segments.length - 1] ?? origin;
|
|
7955
7955
|
}
|
|
7956
7956
|
const firstSlash = origin.indexOf("/");
|
|
@@ -8354,7 +8354,7 @@ function findSynthesisForBranch(repoReviewsDir, branch2) {
|
|
|
8354
8354
|
const parent = dirname20(branchKeyPath);
|
|
8355
8355
|
const branchPrefix = basename5(branchKeyPath);
|
|
8356
8356
|
if (!existsSync25(parent)) return null;
|
|
8357
|
-
const synthesisFiles = readdirSync2(parent).filter((name) => name.startsWith(branchPrefix)).map((name) => join23(parent, name, "synthesis.md")).filter((
|
|
8357
|
+
const synthesisFiles = readdirSync2(parent).filter((name) => name.startsWith(branchPrefix)).map((name) => join23(parent, name, "synthesis.md")).filter((path69) => existsSync25(path69)).map((path69) => ({ path: path69, mtime: statSync2(path69).mtimeMs })).sort((a, b) => b.mtime - a.mtime);
|
|
8358
8358
|
return synthesisFiles[0]?.path ?? null;
|
|
8359
8359
|
}
|
|
8360
8360
|
|
|
@@ -8408,12 +8408,12 @@ async function getReviewSynthesis(req, res) {
|
|
|
8408
8408
|
const cwd = getCwdParam(req, res);
|
|
8409
8409
|
if (!cwd) return;
|
|
8410
8410
|
try {
|
|
8411
|
-
const
|
|
8412
|
-
if (!
|
|
8411
|
+
const path69 = await resolveSynthesisPath(cwd);
|
|
8412
|
+
if (!path69) {
|
|
8413
8413
|
respondJson(res, 404, { error: "No synthesis found" });
|
|
8414
8414
|
return;
|
|
8415
8415
|
}
|
|
8416
|
-
respondJson(res, 200, { synthesis: readFileSync19(
|
|
8416
|
+
respondJson(res, 200, { synthesis: readFileSync19(path69, "utf8") });
|
|
8417
8417
|
} catch {
|
|
8418
8418
|
respondJson(res, 404, { error: "No synthesis found" });
|
|
8419
8419
|
}
|
|
@@ -8560,10 +8560,10 @@ function getStorePath(filename) {
|
|
|
8560
8560
|
return join26(getStoreDir(), filename);
|
|
8561
8561
|
}
|
|
8562
8562
|
function loadJson(filename) {
|
|
8563
|
-
const
|
|
8564
|
-
if (existsSync26(
|
|
8563
|
+
const path69 = getStorePath(filename);
|
|
8564
|
+
if (existsSync26(path69)) {
|
|
8565
8565
|
try {
|
|
8566
|
-
return JSON.parse(readFileSync20(
|
|
8566
|
+
return JSON.parse(readFileSync20(path69, "utf8"));
|
|
8567
8567
|
} catch {
|
|
8568
8568
|
return {};
|
|
8569
8569
|
}
|
|
@@ -11914,9 +11914,9 @@ var __dirname4 = dirname21(__filename3);
|
|
|
11914
11914
|
function packageRoot() {
|
|
11915
11915
|
return __dirname4;
|
|
11916
11916
|
}
|
|
11917
|
-
function readLines(
|
|
11918
|
-
if (!existsSync27(
|
|
11919
|
-
return readFileSync23(
|
|
11917
|
+
function readLines(path69) {
|
|
11918
|
+
if (!existsSync27(path69)) return [];
|
|
11919
|
+
return readFileSync23(path69, "utf8").split("\n").filter((line) => line.trim() !== "");
|
|
11920
11920
|
}
|
|
11921
11921
|
var cachedReads;
|
|
11922
11922
|
var cachedWrites;
|
|
@@ -12408,14 +12408,14 @@ function showProgress(p, label2) {
|
|
|
12408
12408
|
const pct = Math.round(p.done / p.total * 100);
|
|
12409
12409
|
process.stderr.write(`\r\x1B[K[${pct}%] Scanning ${label2}...`);
|
|
12410
12410
|
}
|
|
12411
|
-
async function resolveCommand(cli,
|
|
12412
|
-
showProgress(p,
|
|
12413
|
-
const subHelp = await runHelp([cli, ...
|
|
12411
|
+
async function resolveCommand(cli, path69, description, depth, p) {
|
|
12412
|
+
showProgress(p, path69.join(" "));
|
|
12413
|
+
const subHelp = await runHelp([cli, ...path69]);
|
|
12414
12414
|
if (!subHelp || !hasSubcommands(subHelp)) {
|
|
12415
|
-
return [{ path:
|
|
12415
|
+
return [{ path: path69, description }];
|
|
12416
12416
|
}
|
|
12417
|
-
const children = await discoverAt(cli,
|
|
12418
|
-
return children.length > 0 ? children : [{ path:
|
|
12417
|
+
const children = await discoverAt(cli, path69, depth + 1, p);
|
|
12418
|
+
return children.length > 0 ? children : [{ path: path69, description }];
|
|
12419
12419
|
}
|
|
12420
12420
|
async function discoverAt(cli, parentPath, depth, p) {
|
|
12421
12421
|
if (depth > SAFETY_DEPTH) return [];
|
|
@@ -12563,9 +12563,9 @@ function logPath(cli) {
|
|
|
12563
12563
|
return join30(homedir16(), ".assist", `cli-discover-${safeName}.log`);
|
|
12564
12564
|
}
|
|
12565
12565
|
function readCache(cli) {
|
|
12566
|
-
const
|
|
12567
|
-
if (!existsSync29(
|
|
12568
|
-
return readFileSync25(
|
|
12566
|
+
const path69 = logPath(cli);
|
|
12567
|
+
if (!existsSync29(path69)) return void 0;
|
|
12568
|
+
return readFileSync25(path69, "utf8");
|
|
12569
12569
|
}
|
|
12570
12570
|
function writeCache(cli, output) {
|
|
12571
12571
|
const dir = join30(homedir16(), ".assist");
|
|
@@ -12737,9 +12737,9 @@ function sweepRestrictedDir(dir = getRestrictedDir()) {
|
|
|
12737
12737
|
}
|
|
12738
12738
|
const cutoff = Date.now() - STALE_AFTER_MS;
|
|
12739
12739
|
for (const entry of entries) {
|
|
12740
|
-
const
|
|
12740
|
+
const path69 = join32(dir, entry);
|
|
12741
12741
|
try {
|
|
12742
|
-
if (statSync3(
|
|
12742
|
+
if (statSync3(path69).mtimeMs < cutoff) unlinkSync7(path69);
|
|
12743
12743
|
} catch {
|
|
12744
12744
|
continue;
|
|
12745
12745
|
}
|
|
@@ -12749,10 +12749,10 @@ function sweepRestrictedDir(dir = getRestrictedDir()) {
|
|
|
12749
12749
|
// src/commands/codeComment/readPinState.ts
|
|
12750
12750
|
import { existsSync as existsSync30, readFileSync as readFileSync26 } from "fs";
|
|
12751
12751
|
function readPinState(pin) {
|
|
12752
|
-
const
|
|
12753
|
-
if (!existsSync30(
|
|
12752
|
+
const path69 = getPinStatePath(pin);
|
|
12753
|
+
if (!existsSync30(path69)) return void 0;
|
|
12754
12754
|
try {
|
|
12755
|
-
const state = JSON.parse(readFileSync26(
|
|
12755
|
+
const state = JSON.parse(readFileSync26(path69, "utf8"));
|
|
12756
12756
|
if (state.pin !== pin) return void 0;
|
|
12757
12757
|
return state;
|
|
12758
12758
|
} catch {
|
|
@@ -13301,8 +13301,73 @@ Analyzed ${results.length} functions across ${files.length} files`
|
|
|
13301
13301
|
});
|
|
13302
13302
|
}
|
|
13303
13303
|
|
|
13304
|
+
// src/commands/complexity/maintainability/aggregateResults.ts
|
|
13305
|
+
function aggregateResults(fileMetrics) {
|
|
13306
|
+
const results = [];
|
|
13307
|
+
for (const [file, metrics] of fileMetrics) {
|
|
13308
|
+
if (metrics.functions.length === 0) continue;
|
|
13309
|
+
const avgMaintainability = metrics.functions.reduce((a, b) => a + b, 0) / metrics.functions.length;
|
|
13310
|
+
const minMaintainability = Math.min(...metrics.functions);
|
|
13311
|
+
results.push({
|
|
13312
|
+
file,
|
|
13313
|
+
avgMaintainability,
|
|
13314
|
+
minMaintainability,
|
|
13315
|
+
override: metrics.override,
|
|
13316
|
+
largestFunction: metrics.largestFunction
|
|
13317
|
+
});
|
|
13318
|
+
}
|
|
13319
|
+
results.sort((a, b) => a.minMaintainability - b.minMaintainability);
|
|
13320
|
+
return results;
|
|
13321
|
+
}
|
|
13322
|
+
|
|
13323
|
+
// src/commands/complexity/maintainability/collectFileMetrics.ts
|
|
13324
|
+
import fs21 from "fs";
|
|
13325
|
+
|
|
13326
|
+
// src/commands/complexity/maintainability/calculateMaintainabilityIndex.ts
|
|
13327
|
+
function calculateMaintainabilityIndex(halsteadVolume, cyclomaticComplexity, sloc2) {
|
|
13328
|
+
if (halsteadVolume === 0 || sloc2 === 0) {
|
|
13329
|
+
return 100;
|
|
13330
|
+
}
|
|
13331
|
+
const mi = 171 - 5.2 * Math.log(halsteadVolume) - 0.23 * cyclomaticComplexity - 16.2 * Math.log(sloc2);
|
|
13332
|
+
return Math.max(0, Math.min(100, mi));
|
|
13333
|
+
}
|
|
13334
|
+
|
|
13335
|
+
// src/commands/complexity/maintainability/collectFileMetrics.ts
|
|
13336
|
+
function collectFileMetrics(files) {
|
|
13337
|
+
const fileMetrics = /* @__PURE__ */ new Map();
|
|
13338
|
+
for (const file of files) {
|
|
13339
|
+
const content = fs21.readFileSync(file, "utf8");
|
|
13340
|
+
fileMetrics.set(file, {
|
|
13341
|
+
sloc: countSloc(content),
|
|
13342
|
+
functions: [],
|
|
13343
|
+
override: parseMaintainabilityOverride(content),
|
|
13344
|
+
largestFunction: "",
|
|
13345
|
+
largestFunctionSize: -1
|
|
13346
|
+
});
|
|
13347
|
+
}
|
|
13348
|
+
forEachFunction(files, (file, name, node) => {
|
|
13349
|
+
const metrics = fileMetrics.get(file);
|
|
13350
|
+
if (metrics) {
|
|
13351
|
+
const complexity = calculateCyclomaticComplexity(node);
|
|
13352
|
+
const halstead2 = calculateHalstead(node);
|
|
13353
|
+
const mi = calculateMaintainabilityIndex(
|
|
13354
|
+
halstead2.volume,
|
|
13355
|
+
complexity,
|
|
13356
|
+
metrics.sloc
|
|
13357
|
+
);
|
|
13358
|
+
metrics.functions.push(mi);
|
|
13359
|
+
const size = node.end - node.pos;
|
|
13360
|
+
if (size > metrics.largestFunctionSize) {
|
|
13361
|
+
metrics.largestFunctionSize = size;
|
|
13362
|
+
metrics.largestFunction = name;
|
|
13363
|
+
}
|
|
13364
|
+
}
|
|
13365
|
+
});
|
|
13366
|
+
return fileMetrics;
|
|
13367
|
+
}
|
|
13368
|
+
|
|
13304
13369
|
// src/commands/complexity/maintainability/displayMaintainabilityResults.ts
|
|
13305
|
-
import
|
|
13370
|
+
import chalk118 from "chalk";
|
|
13306
13371
|
|
|
13307
13372
|
// src/commands/complexity/maintainability/formatResultLine.ts
|
|
13308
13373
|
import chalk115 from "chalk";
|
|
@@ -13313,28 +13378,101 @@ function formatResultLine(entry, failing) {
|
|
|
13313
13378
|
return `${name} \u2192 avg: ${chalk115.cyan(avgMaintainability.toFixed(1))}, min: ${chalk115.yellow(minMaintainability.toFixed(1))}${suffix}`;
|
|
13314
13379
|
}
|
|
13315
13380
|
|
|
13381
|
+
// src/commands/complexity/maintainability/getMaintainabilityGitState.ts
|
|
13382
|
+
import { execSync as execSync32 } from "child_process";
|
|
13383
|
+
import path28 from "path";
|
|
13384
|
+
function git2(command) {
|
|
13385
|
+
return execSync32(command, { encoding: "utf8" });
|
|
13386
|
+
}
|
|
13387
|
+
function toAbsolute(root, repoRelative) {
|
|
13388
|
+
return path28.resolve(root, repoRelative);
|
|
13389
|
+
}
|
|
13390
|
+
function collectShrunkFiles(root) {
|
|
13391
|
+
const shrunk = /* @__PURE__ */ new Set();
|
|
13392
|
+
const numstat = git2("git diff --numstat HEAD").trim();
|
|
13393
|
+
if (numstat === "") return shrunk;
|
|
13394
|
+
for (const line of numstat.split("\n")) {
|
|
13395
|
+
const [addedRaw, removedRaw, ...rest] = line.split(" ");
|
|
13396
|
+
const file = rest.join(" ");
|
|
13397
|
+
const added = Number.parseInt(addedRaw, 10);
|
|
13398
|
+
const removed = Number.parseInt(removedRaw, 10);
|
|
13399
|
+
if (Number.isNaN(added) || Number.isNaN(removed)) continue;
|
|
13400
|
+
if (removed > added) shrunk.add(toAbsolute(root, file));
|
|
13401
|
+
}
|
|
13402
|
+
return shrunk;
|
|
13403
|
+
}
|
|
13404
|
+
function hasNewSourceFile() {
|
|
13405
|
+
const status3 = git2("git status --porcelain --untracked-files=all").trim();
|
|
13406
|
+
if (status3 === "") return false;
|
|
13407
|
+
for (const line of status3.split("\n")) {
|
|
13408
|
+
const code = line.slice(0, 2);
|
|
13409
|
+
const file = line.slice(3);
|
|
13410
|
+
const isNew = code.includes("A") || code.includes("?");
|
|
13411
|
+
if (isNew && (file.endsWith(".ts") || file.endsWith(".tsx"))) return true;
|
|
13412
|
+
}
|
|
13413
|
+
return false;
|
|
13414
|
+
}
|
|
13415
|
+
function getMaintainabilityGitState() {
|
|
13416
|
+
try {
|
|
13417
|
+
const root = git2("git rev-parse --show-toplevel").trim();
|
|
13418
|
+
return {
|
|
13419
|
+
shrunkFiles: collectShrunkFiles(root),
|
|
13420
|
+
newFileCreated: hasNewSourceFile()
|
|
13421
|
+
};
|
|
13422
|
+
} catch {
|
|
13423
|
+
return { shrunkFiles: /* @__PURE__ */ new Set(), newFileCreated: false };
|
|
13424
|
+
}
|
|
13425
|
+
}
|
|
13426
|
+
|
|
13316
13427
|
// src/commands/complexity/maintainability/printMaintainabilityFailure.ts
|
|
13428
|
+
import path29 from "path";
|
|
13317
13429
|
import chalk116 from "chalk";
|
|
13318
|
-
function
|
|
13319
|
-
|
|
13430
|
+
function suggestDestination(file, functionName) {
|
|
13431
|
+
return path29.join(path29.dirname(file), `${functionName}.ts`);
|
|
13432
|
+
}
|
|
13433
|
+
function remediationLine(entry) {
|
|
13434
|
+
const { file, largestFunction } = entry;
|
|
13435
|
+
if (largestFunction === "" || largestFunction.startsWith("<"))
|
|
13436
|
+
return ` Move the largest responsibility out of ${chalk116.bold(file)} into a new file with 'assist refactor extract'.`;
|
|
13437
|
+
const dest = suggestDestination(file, largestFunction);
|
|
13438
|
+
const command = `assist refactor extract ${file} ${largestFunction} ${dest} --apply`;
|
|
13439
|
+
return ` ${chalk116.bold(file)} \u2192 extract '${largestFunction}' to a new file:
|
|
13440
|
+
${chalk116.cyan(command)}`;
|
|
13441
|
+
}
|
|
13442
|
+
function cheatLine(entry, gitState) {
|
|
13443
|
+
const shrank = gitState.shrunkFiles.has(path29.resolve(entry.file));
|
|
13444
|
+
if (!shrank || gitState.newFileCreated) return "";
|
|
13445
|
+
return `
|
|
13446
|
+
${chalk116.red("\u2717 You shrank existing lines in this file without creating a new file. That cannot clear the gate \u2014 extract a responsibility to a new file.")}`;
|
|
13447
|
+
}
|
|
13448
|
+
function printMaintainabilityFailure(failing, gitState) {
|
|
13449
|
+
const blocks = failing.map((entry) => `${remediationLine(entry)}${cheatLine(entry, gitState)}`).join("\n");
|
|
13320
13450
|
console.error(
|
|
13321
13451
|
chalk116.red(
|
|
13322
13452
|
`
|
|
13323
|
-
Fail: ${
|
|
13453
|
+
Fail: ${failing.length} file(s) below threshold \u2192 extract a responsibility to a new file.
|
|
13324
13454
|
|
|
13325
|
-
|
|
13455
|
+
${blocks}
|
|
13326
13456
|
|
|
13327
|
-
|
|
13457
|
+
${chalk116.bold("Diagnose and fix one file at a time.")} Only a new file (Write) or 'assist refactor extract' clears this gate \u2014 editing the existing lines does not.`
|
|
13328
13458
|
)
|
|
13329
13459
|
);
|
|
13330
13460
|
}
|
|
13331
13461
|
|
|
13462
|
+
// src/commands/complexity/maintainability/printMaintainabilityFormula.ts
|
|
13463
|
+
import chalk117 from "chalk";
|
|
13464
|
+
var MI_FORMULA = "171 - 5.2*ln(HalsteadVolume) - 0.23*CyclomaticComplexity - 16.2*ln(SLOC), clamped 0-100";
|
|
13465
|
+
function printMaintainabilityFormula() {
|
|
13466
|
+
console.log(chalk117.dim(MI_FORMULA));
|
|
13467
|
+
}
|
|
13468
|
+
|
|
13332
13469
|
// src/commands/complexity/maintainability/displayMaintainabilityResults.ts
|
|
13333
|
-
function displayMaintainabilityResults(results, threshold) {
|
|
13470
|
+
function displayMaintainabilityResults(results, threshold, gitState = getMaintainabilityGitState()) {
|
|
13334
13471
|
const gating = threshold !== void 0 || results.some((r) => r.override !== void 0);
|
|
13335
13472
|
if (!gating) {
|
|
13473
|
+
printMaintainabilityFormula();
|
|
13336
13474
|
for (const entry of results) console.log(formatResultLine(entry, false));
|
|
13337
|
-
console.log(
|
|
13475
|
+
console.log(chalk118.dim(`
|
|
13338
13476
|
Analyzed ${results.length} files`));
|
|
13339
13477
|
return;
|
|
13340
13478
|
}
|
|
@@ -13343,90 +13481,23 @@ Analyzed ${results.length} files`));
|
|
|
13343
13481
|
return limit !== void 0 && r.minMaintainability < limit;
|
|
13344
13482
|
});
|
|
13345
13483
|
if (failing.length === 0) {
|
|
13346
|
-
console.log(
|
|
13347
|
-
} else {
|
|
13348
|
-
for (const entry of failing) console.log(formatResultLine(entry, true));
|
|
13484
|
+
console.log(chalk118.green("All files pass maintainability threshold"));
|
|
13349
13485
|
}
|
|
13350
13486
|
const passingOverrides = results.filter(
|
|
13351
13487
|
(r) => r.override !== void 0 && !failing.includes(r)
|
|
13352
13488
|
);
|
|
13353
13489
|
for (const entry of passingOverrides)
|
|
13354
13490
|
console.log(formatResultLine(entry, false));
|
|
13355
|
-
console.log(
|
|
13491
|
+
console.log(chalk118.dim(`
|
|
13356
13492
|
Analyzed ${results.length} files`));
|
|
13357
13493
|
if (failing.length > 0) {
|
|
13358
|
-
printMaintainabilityFailure(failing
|
|
13494
|
+
printMaintainabilityFailure(failing, gitState);
|
|
13359
13495
|
process.exit(1);
|
|
13360
13496
|
}
|
|
13361
13497
|
}
|
|
13362
13498
|
|
|
13363
|
-
// src/commands/complexity/maintainability/printMaintainabilityFormula.ts
|
|
13364
|
-
import chalk118 from "chalk";
|
|
13365
|
-
var MI_FORMULA = "171 - 5.2*ln(HalsteadVolume) - 0.23*CyclomaticComplexity - 16.2*ln(SLOC), clamped 0-100";
|
|
13366
|
-
function printMaintainabilityFormula() {
|
|
13367
|
-
console.log(chalk118.dim(MI_FORMULA));
|
|
13368
|
-
}
|
|
13369
|
-
|
|
13370
|
-
// src/commands/complexity/maintainability/collectFileMetrics.ts
|
|
13371
|
-
import fs21 from "fs";
|
|
13372
|
-
|
|
13373
|
-
// src/commands/complexity/maintainability/calculateMaintainabilityIndex.ts
|
|
13374
|
-
function calculateMaintainabilityIndex(halsteadVolume, cyclomaticComplexity, sloc2) {
|
|
13375
|
-
if (halsteadVolume === 0 || sloc2 === 0) {
|
|
13376
|
-
return 100;
|
|
13377
|
-
}
|
|
13378
|
-
const mi = 171 - 5.2 * Math.log(halsteadVolume) - 0.23 * cyclomaticComplexity - 16.2 * Math.log(sloc2);
|
|
13379
|
-
return Math.max(0, Math.min(100, mi));
|
|
13380
|
-
}
|
|
13381
|
-
|
|
13382
|
-
// src/commands/complexity/maintainability/collectFileMetrics.ts
|
|
13383
|
-
function collectFileMetrics(files) {
|
|
13384
|
-
const fileMetrics = /* @__PURE__ */ new Map();
|
|
13385
|
-
for (const file of files) {
|
|
13386
|
-
const content = fs21.readFileSync(file, "utf8");
|
|
13387
|
-
fileMetrics.set(file, {
|
|
13388
|
-
sloc: countSloc(content),
|
|
13389
|
-
functions: [],
|
|
13390
|
-
override: parseMaintainabilityOverride(content)
|
|
13391
|
-
});
|
|
13392
|
-
}
|
|
13393
|
-
forEachFunction(files, (file, _name, node) => {
|
|
13394
|
-
const metrics = fileMetrics.get(file);
|
|
13395
|
-
if (metrics) {
|
|
13396
|
-
const complexity = calculateCyclomaticComplexity(node);
|
|
13397
|
-
const halstead2 = calculateHalstead(node);
|
|
13398
|
-
const mi = calculateMaintainabilityIndex(
|
|
13399
|
-
halstead2.volume,
|
|
13400
|
-
complexity,
|
|
13401
|
-
metrics.sloc
|
|
13402
|
-
);
|
|
13403
|
-
metrics.functions.push(mi);
|
|
13404
|
-
}
|
|
13405
|
-
});
|
|
13406
|
-
return fileMetrics;
|
|
13407
|
-
}
|
|
13408
|
-
|
|
13409
|
-
// src/commands/complexity/maintainability/aggregateResults.ts
|
|
13410
|
-
function aggregateResults(fileMetrics) {
|
|
13411
|
-
const results = [];
|
|
13412
|
-
for (const [file, metrics] of fileMetrics) {
|
|
13413
|
-
if (metrics.functions.length === 0) continue;
|
|
13414
|
-
const avgMaintainability = metrics.functions.reduce((a, b) => a + b, 0) / metrics.functions.length;
|
|
13415
|
-
const minMaintainability = Math.min(...metrics.functions);
|
|
13416
|
-
results.push({
|
|
13417
|
-
file,
|
|
13418
|
-
avgMaintainability,
|
|
13419
|
-
minMaintainability,
|
|
13420
|
-
override: metrics.override
|
|
13421
|
-
});
|
|
13422
|
-
}
|
|
13423
|
-
results.sort((a, b) => a.minMaintainability - b.minMaintainability);
|
|
13424
|
-
return results;
|
|
13425
|
-
}
|
|
13426
|
-
|
|
13427
13499
|
// src/commands/complexity/maintainability/index.ts
|
|
13428
13500
|
async function maintainability(pattern2 = "**/*.ts", options2 = {}) {
|
|
13429
|
-
printMaintainabilityFormula();
|
|
13430
13501
|
withSourceFiles(
|
|
13431
13502
|
pattern2,
|
|
13432
13503
|
(files) => {
|
|
@@ -13577,8 +13648,8 @@ function stepIntoNested(container, key, nextKey) {
|
|
|
13577
13648
|
}
|
|
13578
13649
|
return ensureObject(container, resolved);
|
|
13579
13650
|
}
|
|
13580
|
-
function setNestedValue(obj,
|
|
13581
|
-
const keys =
|
|
13651
|
+
function setNestedValue(obj, path69, value) {
|
|
13652
|
+
const keys = path69.split(".");
|
|
13582
13653
|
const result = { ...obj };
|
|
13583
13654
|
let current = result;
|
|
13584
13655
|
for (let i = 0; i < keys.length - 1; i++) {
|
|
@@ -13658,9 +13729,9 @@ function isTraversable(value) {
|
|
|
13658
13729
|
function stepInto(current, key) {
|
|
13659
13730
|
return isTraversable(current) ? current[key] : void 0;
|
|
13660
13731
|
}
|
|
13661
|
-
function getNestedValue(obj,
|
|
13732
|
+
function getNestedValue(obj, path69) {
|
|
13662
13733
|
let current = obj;
|
|
13663
|
-
for (const key of
|
|
13734
|
+
for (const key of path69.split(".")) current = stepInto(current, key);
|
|
13664
13735
|
return current;
|
|
13665
13736
|
}
|
|
13666
13737
|
|
|
@@ -13776,10 +13847,10 @@ function getMigrationApprovalPath(migrationId) {
|
|
|
13776
13847
|
// src/commands/dbMigration/readMigrationPinState.ts
|
|
13777
13848
|
import { existsSync as existsSync32, readFileSync as readFileSync28 } from "fs";
|
|
13778
13849
|
function readMigrationPinState(pin) {
|
|
13779
|
-
const
|
|
13780
|
-
if (!existsSync32(
|
|
13850
|
+
const path69 = getMigrationPinPath(pin);
|
|
13851
|
+
if (!existsSync32(path69)) return void 0;
|
|
13781
13852
|
try {
|
|
13782
|
-
const state = JSON.parse(readFileSync28(
|
|
13853
|
+
const state = JSON.parse(readFileSync28(path69, "utf8"));
|
|
13783
13854
|
if (state.pin !== pin) return void 0;
|
|
13784
13855
|
if (!Number.isInteger(state.migrationId)) return void 0;
|
|
13785
13856
|
return state;
|
|
@@ -13918,7 +13989,7 @@ function loadBlogSkipDays(repoName) {
|
|
|
13918
13989
|
}
|
|
13919
13990
|
|
|
13920
13991
|
// src/commands/devlog/shared.ts
|
|
13921
|
-
import { execSync as
|
|
13992
|
+
import { execSync as execSync33 } from "child_process";
|
|
13922
13993
|
import chalk127 from "chalk";
|
|
13923
13994
|
|
|
13924
13995
|
// src/shared/getRepoName.ts
|
|
@@ -14010,7 +14081,7 @@ function loadAllDevlogLatestDates() {
|
|
|
14010
14081
|
// src/commands/devlog/shared.ts
|
|
14011
14082
|
function getCommitFiles(hash) {
|
|
14012
14083
|
try {
|
|
14013
|
-
const output =
|
|
14084
|
+
const output = execSync33(`git show --name-only --format="" ${hash}`, {
|
|
14014
14085
|
encoding: "utf8"
|
|
14015
14086
|
});
|
|
14016
14087
|
return output.trim().split("\n").filter(Boolean);
|
|
@@ -14106,11 +14177,11 @@ function list3(options2) {
|
|
|
14106
14177
|
}
|
|
14107
14178
|
|
|
14108
14179
|
// src/commands/devlog/getLastVersionInfo.ts
|
|
14109
|
-
import { execFileSync as execFileSync3, execSync as
|
|
14180
|
+
import { execFileSync as execFileSync3, execSync as execSync34 } from "child_process";
|
|
14110
14181
|
import semver from "semver";
|
|
14111
14182
|
function getVersionAtCommit(hash) {
|
|
14112
14183
|
try {
|
|
14113
|
-
const content =
|
|
14184
|
+
const content = execSync34(`git show ${hash}:package.json`, {
|
|
14114
14185
|
encoding: "utf8"
|
|
14115
14186
|
});
|
|
14116
14187
|
const pkg = JSON.parse(content);
|
|
@@ -14283,7 +14354,7 @@ function next2(options2) {
|
|
|
14283
14354
|
}
|
|
14284
14355
|
|
|
14285
14356
|
// src/commands/devlog/repos/index.ts
|
|
14286
|
-
import { execSync as
|
|
14357
|
+
import { execSync as execSync35 } from "child_process";
|
|
14287
14358
|
|
|
14288
14359
|
// src/commands/devlog/repos/printReposTable.ts
|
|
14289
14360
|
import chalk131 from "chalk";
|
|
@@ -14318,7 +14389,7 @@ function getStatus(lastPush, lastDevlog) {
|
|
|
14318
14389
|
return lastDevlog < lastPush ? "outdated" : "ok";
|
|
14319
14390
|
}
|
|
14320
14391
|
function fetchRepos(days, all) {
|
|
14321
|
-
const json =
|
|
14392
|
+
const json = execSync35(
|
|
14322
14393
|
"gh repo list staff0rd --json name,pushedAt,isArchived --limit 200",
|
|
14323
14394
|
{ encoding: "utf8" }
|
|
14324
14395
|
);
|
|
@@ -14452,14 +14523,14 @@ import chalk134 from "chalk";
|
|
|
14452
14523
|
|
|
14453
14524
|
// src/shared/findRepoRoot.ts
|
|
14454
14525
|
import { existsSync as existsSync35 } from "fs";
|
|
14455
|
-
import
|
|
14526
|
+
import path30 from "path";
|
|
14456
14527
|
function findRepoRoot(dir) {
|
|
14457
14528
|
let current = dir;
|
|
14458
|
-
while (current !==
|
|
14459
|
-
if (existsSync35(
|
|
14529
|
+
while (current !== path30.dirname(current)) {
|
|
14530
|
+
if (existsSync35(path30.join(current, ".git"))) {
|
|
14460
14531
|
return current;
|
|
14461
14532
|
}
|
|
14462
|
-
current =
|
|
14533
|
+
current = path30.dirname(current);
|
|
14463
14534
|
}
|
|
14464
14535
|
return null;
|
|
14465
14536
|
}
|
|
@@ -14523,7 +14594,7 @@ async function checkBuildLocksCommand() {
|
|
|
14523
14594
|
|
|
14524
14595
|
// src/commands/dotnet/buildTree.ts
|
|
14525
14596
|
import { readFileSync as readFileSync32 } from "fs";
|
|
14526
|
-
import
|
|
14597
|
+
import path31 from "path";
|
|
14527
14598
|
var PROJECT_REF_RE = /<ProjectReference\s+Include="([^"]+)"/g;
|
|
14528
14599
|
function getProjectRefs(csprojPath) {
|
|
14529
14600
|
const content = readFileSync32(csprojPath, "utf8");
|
|
@@ -14534,14 +14605,14 @@ function getProjectRefs(csprojPath) {
|
|
|
14534
14605
|
return refs;
|
|
14535
14606
|
}
|
|
14536
14607
|
function buildTree(csprojPath, repoRoot, visited = /* @__PURE__ */ new Set()) {
|
|
14537
|
-
const abs =
|
|
14538
|
-
const rel =
|
|
14608
|
+
const abs = path31.resolve(csprojPath);
|
|
14609
|
+
const rel = path31.relative(repoRoot, abs);
|
|
14539
14610
|
const node = { path: abs, relativePath: rel, children: [] };
|
|
14540
14611
|
if (visited.has(abs)) return node;
|
|
14541
14612
|
visited.add(abs);
|
|
14542
|
-
const dir =
|
|
14613
|
+
const dir = path31.dirname(abs);
|
|
14543
14614
|
for (const ref of getProjectRefs(abs)) {
|
|
14544
|
-
const childAbs =
|
|
14615
|
+
const childAbs = path31.resolve(dir, ref);
|
|
14545
14616
|
try {
|
|
14546
14617
|
readFileSync32(childAbs);
|
|
14547
14618
|
node.children.push(buildTree(childAbs, repoRoot, visited));
|
|
@@ -14569,7 +14640,7 @@ function collectAllDeps(node) {
|
|
|
14569
14640
|
|
|
14570
14641
|
// src/commands/dotnet/findContainingSolutions.ts
|
|
14571
14642
|
import { readdirSync as readdirSync6, readFileSync as readFileSync33, statSync as statSync4 } from "fs";
|
|
14572
|
-
import
|
|
14643
|
+
import path32 from "path";
|
|
14573
14644
|
function findSlnFiles(dir, maxDepth, depth = 0) {
|
|
14574
14645
|
if (depth > maxDepth) return [];
|
|
14575
14646
|
const results = [];
|
|
@@ -14582,7 +14653,7 @@ function findSlnFiles(dir, maxDepth, depth = 0) {
|
|
|
14582
14653
|
for (const entry of entries) {
|
|
14583
14654
|
if (entry.startsWith(".") || entry === "node_modules" || entry === "packages")
|
|
14584
14655
|
continue;
|
|
14585
|
-
const full =
|
|
14656
|
+
const full = path32.join(dir, entry);
|
|
14586
14657
|
try {
|
|
14587
14658
|
const stat2 = statSync4(full);
|
|
14588
14659
|
if (stat2.isFile() && entry.endsWith(".sln")) {
|
|
@@ -14596,8 +14667,8 @@ function findSlnFiles(dir, maxDepth, depth = 0) {
|
|
|
14596
14667
|
return results;
|
|
14597
14668
|
}
|
|
14598
14669
|
function findContainingSolutions(csprojPath, repoRoot) {
|
|
14599
|
-
const csprojAbs =
|
|
14600
|
-
const csprojBasename =
|
|
14670
|
+
const csprojAbs = path32.resolve(csprojPath);
|
|
14671
|
+
const csprojBasename = path32.basename(csprojAbs);
|
|
14601
14672
|
const slnFiles = findSlnFiles(repoRoot, 3);
|
|
14602
14673
|
const matches = [];
|
|
14603
14674
|
const pattern2 = new RegExp(`[\\\\"/]${escapeRegex(csprojBasename)}"`);
|
|
@@ -14605,7 +14676,7 @@ function findContainingSolutions(csprojPath, repoRoot) {
|
|
|
14605
14676
|
try {
|
|
14606
14677
|
const content = readFileSync33(sln, "utf8");
|
|
14607
14678
|
if (pattern2.test(content)) {
|
|
14608
|
-
matches.push(
|
|
14679
|
+
matches.push(path32.relative(repoRoot, sln));
|
|
14609
14680
|
}
|
|
14610
14681
|
} catch {
|
|
14611
14682
|
}
|
|
@@ -14668,15 +14739,15 @@ function printJson(tree, totalCount, solutions) {
|
|
|
14668
14739
|
|
|
14669
14740
|
// src/commands/dotnet/resolveCsproj.ts
|
|
14670
14741
|
import { existsSync as existsSync36 } from "fs";
|
|
14671
|
-
import
|
|
14742
|
+
import path33 from "path";
|
|
14672
14743
|
import chalk136 from "chalk";
|
|
14673
14744
|
function resolveCsproj(csprojPath) {
|
|
14674
|
-
const resolved =
|
|
14745
|
+
const resolved = path33.resolve(csprojPath);
|
|
14675
14746
|
if (!existsSync36(resolved)) {
|
|
14676
14747
|
console.error(chalk136.red(`File not found: ${resolved}`));
|
|
14677
14748
|
process.exit(1);
|
|
14678
14749
|
}
|
|
14679
|
-
const repoRoot = findRepoRoot(
|
|
14750
|
+
const repoRoot = findRepoRoot(path33.dirname(resolved));
|
|
14680
14751
|
if (!repoRoot) {
|
|
14681
14752
|
console.error(chalk136.red("Could not find git repository root"));
|
|
14682
14753
|
process.exit(1);
|
|
@@ -14698,7 +14769,7 @@ async function deps(csprojPath, options2) {
|
|
|
14698
14769
|
}
|
|
14699
14770
|
|
|
14700
14771
|
// src/commands/dotnet/getChangedCsFiles.ts
|
|
14701
|
-
import { execSync as
|
|
14772
|
+
import { execSync as execSync36 } from "child_process";
|
|
14702
14773
|
var SCOPE_ALL = "all";
|
|
14703
14774
|
var SCOPE_BASE = "base:";
|
|
14704
14775
|
var SCOPE_COMMIT = "commit:";
|
|
@@ -14722,7 +14793,7 @@ function getChangedCsFiles(scope) {
|
|
|
14722
14793
|
} else {
|
|
14723
14794
|
cmd = "git diff --name-only HEAD";
|
|
14724
14795
|
}
|
|
14725
|
-
const output =
|
|
14796
|
+
const output = execSync36(cmd, { encoding: "utf8" }).trim();
|
|
14726
14797
|
if (output === "") return [];
|
|
14727
14798
|
return output.split("\n").filter((f) => f.toLowerCase().endsWith(".cs"));
|
|
14728
14799
|
}
|
|
@@ -14841,7 +14912,7 @@ function filterIssues(issues, all, cliOnly, cliSuppress) {
|
|
|
14841
14912
|
|
|
14842
14913
|
// src/commands/dotnet/resolveSolution.ts
|
|
14843
14914
|
import { existsSync as existsSync37 } from "fs";
|
|
14844
|
-
import
|
|
14915
|
+
import path34 from "path";
|
|
14845
14916
|
import chalk140 from "chalk";
|
|
14846
14917
|
|
|
14847
14918
|
// src/commands/dotnet/findSolution.ts
|
|
@@ -14880,7 +14951,7 @@ function findSolution() {
|
|
|
14880
14951
|
// src/commands/dotnet/resolveSolution.ts
|
|
14881
14952
|
function resolveSolution(sln) {
|
|
14882
14953
|
if (sln) {
|
|
14883
|
-
const resolved =
|
|
14954
|
+
const resolved = path34.resolve(sln);
|
|
14884
14955
|
if (!existsSync37(resolved)) {
|
|
14885
14956
|
console.error(chalk140.red(`Solution file not found: ${resolved}`));
|
|
14886
14957
|
process.exit(1);
|
|
@@ -14920,14 +14991,14 @@ function parseInspectReport(json) {
|
|
|
14920
14991
|
}
|
|
14921
14992
|
|
|
14922
14993
|
// src/commands/dotnet/runInspectCode.ts
|
|
14923
|
-
import { execSync as
|
|
14994
|
+
import { execSync as execSync37 } from "child_process";
|
|
14924
14995
|
import { existsSync as existsSync38, readFileSync as readFileSync34, unlinkSync as unlinkSync10 } from "fs";
|
|
14925
14996
|
import { tmpdir as tmpdir3 } from "os";
|
|
14926
|
-
import
|
|
14997
|
+
import path35 from "path";
|
|
14927
14998
|
import chalk141 from "chalk";
|
|
14928
14999
|
function assertJbInstalled() {
|
|
14929
15000
|
try {
|
|
14930
|
-
|
|
15001
|
+
execSync37("jb inspectcode --version", { stdio: "pipe" });
|
|
14931
15002
|
} catch {
|
|
14932
15003
|
console.error(chalk141.red("jb is not installed. Install with:"));
|
|
14933
15004
|
console.error(
|
|
@@ -14937,11 +15008,11 @@ function assertJbInstalled() {
|
|
|
14937
15008
|
}
|
|
14938
15009
|
}
|
|
14939
15010
|
function runInspectCode(slnPath, include, swea) {
|
|
14940
|
-
const reportPath =
|
|
15011
|
+
const reportPath = path35.join(tmpdir3(), `inspect-${Date.now()}.xml`);
|
|
14941
15012
|
const includeFlag = include ? ` --include="${include}"` : "";
|
|
14942
15013
|
const sweaFlag = swea ? " --swea" : "";
|
|
14943
15014
|
try {
|
|
14944
|
-
|
|
15015
|
+
execSync37(
|
|
14945
15016
|
`jb inspectcode "${slnPath}" -o="${reportPath}"${includeFlag}${sweaFlag} --verbosity=OFF`,
|
|
14946
15017
|
{ stdio: "pipe" }
|
|
14947
15018
|
);
|
|
@@ -14962,7 +15033,7 @@ function runInspectCode(slnPath, include, swea) {
|
|
|
14962
15033
|
}
|
|
14963
15034
|
|
|
14964
15035
|
// src/commands/dotnet/runRoslynInspect.ts
|
|
14965
|
-
import { execSync as
|
|
15036
|
+
import { execSync as execSync38 } from "child_process";
|
|
14966
15037
|
import chalk142 from "chalk";
|
|
14967
15038
|
function resolveMsbuildPath() {
|
|
14968
15039
|
const { run: run4 } = loadConfig();
|
|
@@ -14973,7 +15044,7 @@ function resolveMsbuildPath() {
|
|
|
14973
15044
|
function assertMsbuildInstalled() {
|
|
14974
15045
|
const msbuild = resolveMsbuildPath();
|
|
14975
15046
|
try {
|
|
14976
|
-
|
|
15047
|
+
execSync38(`"${msbuild}" -version`, { stdio: "pipe" });
|
|
14977
15048
|
} catch {
|
|
14978
15049
|
console.error(chalk142.red(`msbuild not found at: ${msbuild}`));
|
|
14979
15050
|
console.error(
|
|
@@ -14999,7 +15070,7 @@ function runRoslynInspect(slnPath) {
|
|
|
14999
15070
|
const msbuild = resolveMsbuildPath();
|
|
15000
15071
|
let output;
|
|
15001
15072
|
try {
|
|
15002
|
-
output =
|
|
15073
|
+
output = execSync38(
|
|
15003
15074
|
`"${msbuild}" "${slnPath}" -t:Build -v:minimal -maxcpucount -p:EnforceCodeStyleInBuild=true -p:RunAnalyzersDuringBuild=true 2>&1`,
|
|
15004
15075
|
{ encoding: "utf8", stdio: "pipe", maxBuffer: 50 * 1024 * 1024 }
|
|
15005
15076
|
);
|
|
@@ -15218,10 +15289,10 @@ function decideCommentGuard(input, existingContent) {
|
|
|
15218
15289
|
import { existsSync as existsSync39, unlinkSync as unlinkSync11 } from "fs";
|
|
15219
15290
|
function consumeMigrationApproval(migrationId) {
|
|
15220
15291
|
sweepRestrictedDir();
|
|
15221
|
-
const
|
|
15222
|
-
if (!existsSync39(
|
|
15292
|
+
const path69 = getMigrationApprovalPath(migrationId);
|
|
15293
|
+
if (!existsSync39(path69)) return false;
|
|
15223
15294
|
try {
|
|
15224
|
-
unlinkSync11(
|
|
15295
|
+
unlinkSync11(path69);
|
|
15225
15296
|
return true;
|
|
15226
15297
|
} catch {
|
|
15227
15298
|
return false;
|
|
@@ -15846,7 +15917,7 @@ function acceptanceCriteria(issueKey) {
|
|
|
15846
15917
|
}
|
|
15847
15918
|
|
|
15848
15919
|
// src/commands/jira/jiraAuth.ts
|
|
15849
|
-
import { execSync as
|
|
15920
|
+
import { execSync as execSync39 } from "child_process";
|
|
15850
15921
|
|
|
15851
15922
|
// src/shared/promptInput.ts
|
|
15852
15923
|
import Enquirer from "enquirer";
|
|
@@ -15881,7 +15952,7 @@ async function jiraAuth() {
|
|
|
15881
15952
|
console.error("All fields are required.");
|
|
15882
15953
|
process.exit(1);
|
|
15883
15954
|
}
|
|
15884
|
-
|
|
15955
|
+
execSync39(`acli jira auth login --site ${site} --email "${email}" --token`, {
|
|
15885
15956
|
encoding: "utf8",
|
|
15886
15957
|
input: token,
|
|
15887
15958
|
stdio: ["pipe", "inherit", "inherit"]
|
|
@@ -16395,9 +16466,9 @@ function parseRscRows(flight) {
|
|
|
16395
16466
|
}
|
|
16396
16467
|
function makeRscResolver(rows) {
|
|
16397
16468
|
return (ref) => {
|
|
16398
|
-
const [id, ...
|
|
16469
|
+
const [id, ...path69] = ref.slice(1).replace(/^[L@]/, "").split(":");
|
|
16399
16470
|
let v = rows[id];
|
|
16400
|
-
for (const key of
|
|
16471
|
+
for (const key of path69) {
|
|
16401
16472
|
if (v == null || typeof v !== "object") return void 0;
|
|
16402
16473
|
v = v[key];
|
|
16403
16474
|
}
|
|
@@ -16966,7 +17037,7 @@ function registerPrompts(program2) {
|
|
|
16966
17037
|
}
|
|
16967
17038
|
|
|
16968
17039
|
// src/commands/prs/shared.ts
|
|
16969
|
-
import { execSync as
|
|
17040
|
+
import { execSync as execSync40 } from "child_process";
|
|
16970
17041
|
function isGhNotInstalled(error) {
|
|
16971
17042
|
if (error instanceof Error) {
|
|
16972
17043
|
const msg = error.message.toLowerCase();
|
|
@@ -16984,12 +17055,12 @@ function getRepoInfo() {
|
|
|
16984
17055
|
const preferred = getPreferredRemoteRepo();
|
|
16985
17056
|
if (preferred) return preferred;
|
|
16986
17057
|
const repoInfo = JSON.parse(
|
|
16987
|
-
|
|
17058
|
+
execSync40("gh repo view --json owner,name", { encoding: "utf8" })
|
|
16988
17059
|
);
|
|
16989
17060
|
return { org: repoInfo.owner.login, repo: repoInfo.name };
|
|
16990
17061
|
}
|
|
16991
17062
|
function getCurrentBranch2() {
|
|
16992
|
-
return
|
|
17063
|
+
return execSync40("git rev-parse --abbrev-ref HEAD", {
|
|
16993
17064
|
encoding: "utf8"
|
|
16994
17065
|
}).trim();
|
|
16995
17066
|
}
|
|
@@ -16997,7 +17068,7 @@ function viewCurrentPr(fields) {
|
|
|
16997
17068
|
const { org, repo } = getRepoInfo();
|
|
16998
17069
|
const branch2 = getCurrentBranch2();
|
|
16999
17070
|
return JSON.parse(
|
|
17000
|
-
|
|
17071
|
+
execSync40(`gh pr view ${branch2} --json ${fields} -R ${org}/${repo}`, {
|
|
17001
17072
|
encoding: "utf8"
|
|
17002
17073
|
})
|
|
17003
17074
|
);
|
|
@@ -17081,15 +17152,15 @@ function postComment(vars) {
|
|
|
17081
17152
|
const stdout = startLine === void 0 ? runGhGraphql(MUTATION_SINGLE, base) : runGhGraphql(MUTATION_MULTI, { ...base, startLine });
|
|
17082
17153
|
assertThreadCreated(stdout);
|
|
17083
17154
|
}
|
|
17084
|
-
function comment2(
|
|
17155
|
+
function comment2(path69, line, body, startLine) {
|
|
17085
17156
|
validateBody(body);
|
|
17086
17157
|
validateLine(line);
|
|
17087
17158
|
if (startLine !== void 0) validateLine(startLine);
|
|
17088
17159
|
try {
|
|
17089
17160
|
const prId = getCurrentPrNodeId();
|
|
17090
|
-
postComment({ prId, body, path:
|
|
17161
|
+
postComment({ prId, body, path: path69, line, startLine });
|
|
17091
17162
|
const range = startLine !== void 0 ? `${startLine}-${line}` : `${line}`;
|
|
17092
|
-
console.log(`Added review comment on ${
|
|
17163
|
+
console.log(`Added review comment on ${path69}:${range}`);
|
|
17093
17164
|
} catch (error) {
|
|
17094
17165
|
if (isGhNotInstalled(error)) {
|
|
17095
17166
|
console.error("Error: GitHub CLI (gh) is not installed.");
|
|
@@ -17299,10 +17370,10 @@ function edit(options2) {
|
|
|
17299
17370
|
}
|
|
17300
17371
|
|
|
17301
17372
|
// src/commands/prs/fixed.ts
|
|
17302
|
-
import { execSync as
|
|
17373
|
+
import { execSync as execSync43 } from "child_process";
|
|
17303
17374
|
|
|
17304
17375
|
// src/commands/prs/resolveCommentWithReply.ts
|
|
17305
|
-
import { execSync as
|
|
17376
|
+
import { execSync as execSync42 } from "child_process";
|
|
17306
17377
|
import { unlinkSync as unlinkSync14, writeFileSync as writeFileSync33 } from "fs";
|
|
17307
17378
|
import { tmpdir as tmpdir5 } from "os";
|
|
17308
17379
|
import { join as join50 } from "path";
|
|
@@ -17331,9 +17402,9 @@ function deleteCommentsCache(prNumber) {
|
|
|
17331
17402
|
}
|
|
17332
17403
|
|
|
17333
17404
|
// src/commands/prs/replyToComment.ts
|
|
17334
|
-
import { execSync as
|
|
17405
|
+
import { execSync as execSync41 } from "child_process";
|
|
17335
17406
|
function replyToComment(org, repo, prNumber, commentId, message) {
|
|
17336
|
-
|
|
17407
|
+
execSync41(
|
|
17337
17408
|
`gh api repos/${org}/${repo}/pulls/${prNumber}/comments -f body="${message.replace(/"/g, String.raw`\"`)}" -F in_reply_to=${commentId}`,
|
|
17338
17409
|
{ stdio: ["inherit", "pipe", "inherit"] }
|
|
17339
17410
|
);
|
|
@@ -17345,7 +17416,7 @@ function resolveThread(threadId) {
|
|
|
17345
17416
|
const queryFile = join50(tmpdir5(), `gh-mutation-${Date.now()}.graphql`);
|
|
17346
17417
|
writeFileSync33(queryFile, mutation);
|
|
17347
17418
|
try {
|
|
17348
|
-
|
|
17419
|
+
execSync42(
|
|
17349
17420
|
`gh api graphql -F query=@${queryFile} -f threadId="${threadId}"`,
|
|
17350
17421
|
{ stdio: ["inherit", "pipe", "inherit"] }
|
|
17351
17422
|
);
|
|
@@ -17397,7 +17468,7 @@ function resolveCommentWithReply(commentId, message) {
|
|
|
17397
17468
|
// src/commands/prs/fixed.ts
|
|
17398
17469
|
function verifySha(sha) {
|
|
17399
17470
|
try {
|
|
17400
|
-
return
|
|
17471
|
+
return execSync43(`git rev-parse --verify ${sha}`, {
|
|
17401
17472
|
encoding: "utf8"
|
|
17402
17473
|
}).trim();
|
|
17403
17474
|
} catch {
|
|
@@ -17411,7 +17482,7 @@ function fixed(commentId, sha) {
|
|
|
17411
17482
|
const { org, repo } = getRepoInfo();
|
|
17412
17483
|
const repoUrl = `https://github.com/${org}/${repo}`;
|
|
17413
17484
|
const message = `Fixed in [${fullSha}](${repoUrl}/commit/${fullSha})`;
|
|
17414
|
-
|
|
17485
|
+
execSync43("git push", { stdio: "inherit" });
|
|
17415
17486
|
resolveCommentWithReply(commentId, message);
|
|
17416
17487
|
} catch (error) {
|
|
17417
17488
|
if (isGhNotInstalled(error)) {
|
|
@@ -17429,7 +17500,7 @@ import { join as join52 } from "path";
|
|
|
17429
17500
|
import { stringify } from "yaml";
|
|
17430
17501
|
|
|
17431
17502
|
// src/commands/prs/fetchThreadIds.ts
|
|
17432
|
-
import { execSync as
|
|
17503
|
+
import { execSync as execSync44 } from "child_process";
|
|
17433
17504
|
import { unlinkSync as unlinkSync15, writeFileSync as writeFileSync34 } from "fs";
|
|
17434
17505
|
import { tmpdir as tmpdir6 } from "os";
|
|
17435
17506
|
import { join as join51 } from "path";
|
|
@@ -17438,7 +17509,7 @@ function fetchThreadIds(org, repo, prNumber) {
|
|
|
17438
17509
|
const queryFile = join51(tmpdir6(), `gh-query-${Date.now()}.graphql`);
|
|
17439
17510
|
writeFileSync34(queryFile, THREAD_QUERY);
|
|
17440
17511
|
try {
|
|
17441
|
-
const result =
|
|
17512
|
+
const result = execSync44(
|
|
17442
17513
|
`gh api graphql -F query=@${queryFile} -F owner="${org}" -F repo="${repo}" -F prNumber=${prNumber}`,
|
|
17443
17514
|
{ encoding: "utf8" }
|
|
17444
17515
|
);
|
|
@@ -17460,9 +17531,9 @@ function fetchThreadIds(org, repo, prNumber) {
|
|
|
17460
17531
|
}
|
|
17461
17532
|
|
|
17462
17533
|
// src/commands/prs/listComments/fetchReviewComments.ts
|
|
17463
|
-
import { execSync as
|
|
17534
|
+
import { execSync as execSync45 } from "child_process";
|
|
17464
17535
|
function fetchJson(endpoint) {
|
|
17465
|
-
const result =
|
|
17536
|
+
const result = execSync45(`gh api --paginate ${endpoint}`, {
|
|
17466
17537
|
encoding: "utf8"
|
|
17467
17538
|
});
|
|
17468
17539
|
if (!result.trim()) return [];
|
|
@@ -17601,7 +17672,7 @@ async function listComments() {
|
|
|
17601
17672
|
}
|
|
17602
17673
|
|
|
17603
17674
|
// src/commands/prs/prs/index.ts
|
|
17604
|
-
import { execSync as
|
|
17675
|
+
import { execSync as execSync46 } from "child_process";
|
|
17605
17676
|
|
|
17606
17677
|
// src/commands/prs/prs/displayPaginated/index.ts
|
|
17607
17678
|
import enquirer9 from "enquirer";
|
|
@@ -17708,7 +17779,7 @@ async function prs(options2) {
|
|
|
17708
17779
|
const state = options2.open ? "open" : options2.closed ? "closed" : "all";
|
|
17709
17780
|
try {
|
|
17710
17781
|
const { org, repo } = getRepoInfo();
|
|
17711
|
-
const result =
|
|
17782
|
+
const result = execSync46(
|
|
17712
17783
|
`gh pr list --state ${state} --json number,title,url,author,createdAt,mergedAt,closedAt,state,changedFiles --limit 100 -R ${org}/${repo}`,
|
|
17713
17784
|
{ encoding: "utf8" }
|
|
17714
17785
|
);
|
|
@@ -17763,16 +17834,16 @@ function buildCreateArgs(title, body, options2) {
|
|
|
17763
17834
|
}
|
|
17764
17835
|
|
|
17765
17836
|
// src/commands/prs/readSessionPrRef.ts
|
|
17766
|
-
import { execSync as
|
|
17837
|
+
import { execSync as execSync47 } from "child_process";
|
|
17767
17838
|
function readSessionPrRef() {
|
|
17768
17839
|
try {
|
|
17769
|
-
const branch2 =
|
|
17840
|
+
const branch2 = execSync47("git rev-parse --abbrev-ref HEAD", {
|
|
17770
17841
|
encoding: "utf8",
|
|
17771
17842
|
stdio: ["pipe", "pipe", "pipe"]
|
|
17772
17843
|
}).trim();
|
|
17773
17844
|
if (!branch2 || branch2 === "HEAD") return null;
|
|
17774
17845
|
const pr = JSON.parse(
|
|
17775
|
-
|
|
17846
|
+
execSync47(`gh pr view ${branch2} --json number,title,url,state`, {
|
|
17776
17847
|
encoding: "utf8",
|
|
17777
17848
|
stdio: ["pipe", "pipe", "pipe"]
|
|
17778
17849
|
})
|
|
@@ -17850,7 +17921,7 @@ function reply(commentId, body) {
|
|
|
17850
17921
|
}
|
|
17851
17922
|
|
|
17852
17923
|
// src/commands/prs/wontfix.ts
|
|
17853
|
-
import { execSync as
|
|
17924
|
+
import { execSync as execSync48 } from "child_process";
|
|
17854
17925
|
function validateReason(reason) {
|
|
17855
17926
|
const lowerReason = reason.toLowerCase();
|
|
17856
17927
|
if (lowerReason.includes("claude") || lowerReason.includes("opus")) {
|
|
@@ -17867,7 +17938,7 @@ function validateShaReferences(reason) {
|
|
|
17867
17938
|
const invalidShas = [];
|
|
17868
17939
|
for (const sha of shas) {
|
|
17869
17940
|
try {
|
|
17870
|
-
|
|
17941
|
+
execSync48(`git cat-file -t ${sha}`, { stdio: "pipe" });
|
|
17871
17942
|
} catch {
|
|
17872
17943
|
invalidShas.push(sha);
|
|
17873
17944
|
}
|
|
@@ -17968,8 +18039,8 @@ function registerPrs(program2) {
|
|
|
17968
18039
|
prsCommand.command("reply <comment-id> <body>").description("Reply to a comment thread without resolving it").action((commentId, body) => {
|
|
17969
18040
|
reply(Number.parseInt(commentId, 10), body);
|
|
17970
18041
|
});
|
|
17971
|
-
prsCommand.command("comment <path> <line> <body>").description("Add a line comment to the pending review").action((
|
|
17972
|
-
comment2(
|
|
18042
|
+
prsCommand.command("comment <path> <line> <body>").description("Add a line comment to the pending review").action((path69, line, body) => {
|
|
18043
|
+
comment2(path69, Number.parseInt(line, 10), body);
|
|
17973
18044
|
});
|
|
17974
18045
|
configHelp(prsCommand, prsConfigHelp);
|
|
17975
18046
|
}
|
|
@@ -18044,10 +18115,10 @@ import chalk161 from "chalk";
|
|
|
18044
18115
|
import Enquirer2 from "enquirer";
|
|
18045
18116
|
|
|
18046
18117
|
// src/commands/ravendb/searchItems.ts
|
|
18047
|
-
import { execSync as
|
|
18118
|
+
import { execSync as execSync49 } from "child_process";
|
|
18048
18119
|
import chalk160 from "chalk";
|
|
18049
18120
|
function opExec(args) {
|
|
18050
|
-
return
|
|
18121
|
+
return execSync49(`op ${args}`, {
|
|
18051
18122
|
encoding: "utf8",
|
|
18052
18123
|
stdio: ["pipe", "pipe", "pipe"]
|
|
18053
18124
|
}).trim();
|
|
@@ -18199,7 +18270,7 @@ ${errorText}`
|
|
|
18199
18270
|
}
|
|
18200
18271
|
|
|
18201
18272
|
// src/commands/ravendb/resolveOpSecret.ts
|
|
18202
|
-
import { execSync as
|
|
18273
|
+
import { execSync as execSync50 } from "child_process";
|
|
18203
18274
|
import chalk165 from "chalk";
|
|
18204
18275
|
function resolveOpSecret(reference) {
|
|
18205
18276
|
if (!reference.startsWith("op://")) {
|
|
@@ -18207,7 +18278,7 @@ function resolveOpSecret(reference) {
|
|
|
18207
18278
|
process.exit(1);
|
|
18208
18279
|
}
|
|
18209
18280
|
try {
|
|
18210
|
-
return
|
|
18281
|
+
return execSync50(`op read "${reference}"`, {
|
|
18211
18282
|
encoding: "utf8",
|
|
18212
18283
|
stdio: ["pipe", "pipe", "pipe"]
|
|
18213
18284
|
}).trim();
|
|
@@ -18222,10 +18293,10 @@ function resolveOpSecret(reference) {
|
|
|
18222
18293
|
}
|
|
18223
18294
|
|
|
18224
18295
|
// src/commands/ravendb/ravenFetch.ts
|
|
18225
|
-
async function ravenFetch(connection,
|
|
18296
|
+
async function ravenFetch(connection, path69) {
|
|
18226
18297
|
const apiKey = resolveOpSecret(connection.apiKeyRef);
|
|
18227
18298
|
let accessToken = await getAccessToken(apiKey);
|
|
18228
|
-
const url = `${connection.url}${
|
|
18299
|
+
const url = `${connection.url}${path69}`;
|
|
18229
18300
|
const headers = {
|
|
18230
18301
|
Authorization: `Bearer ${accessToken}`,
|
|
18231
18302
|
"Content-Type": "application/json"
|
|
@@ -18329,16 +18400,16 @@ import chalk169 from "chalk";
|
|
|
18329
18400
|
// src/commands/ravendb/buildQueryPath.ts
|
|
18330
18401
|
function buildQueryPath(opts) {
|
|
18331
18402
|
const db = encodeURIComponent(opts.db);
|
|
18332
|
-
let
|
|
18403
|
+
let path69;
|
|
18333
18404
|
if (opts.collection) {
|
|
18334
|
-
|
|
18405
|
+
path69 = `/databases/${db}/indexes/dynamic/${encodeURIComponent(opts.collection)}?start=${opts.start}&pageSize=${opts.pageSize}&sort=${encodeURIComponent(opts.sort)}`;
|
|
18335
18406
|
} else {
|
|
18336
|
-
|
|
18407
|
+
path69 = `/databases/${db}/queries?start=${opts.start}&pageSize=${opts.pageSize}`;
|
|
18337
18408
|
}
|
|
18338
18409
|
if (opts.query) {
|
|
18339
|
-
|
|
18410
|
+
path69 += `&query=${encodeURIComponent(opts.query)}`;
|
|
18340
18411
|
}
|
|
18341
|
-
return
|
|
18412
|
+
return path69;
|
|
18342
18413
|
}
|
|
18343
18414
|
|
|
18344
18415
|
// src/commands/ravendb/fetchAllPages.ts
|
|
@@ -18347,7 +18418,7 @@ async function fetchAllPages(connection, opts) {
|
|
|
18347
18418
|
let start3 = 0;
|
|
18348
18419
|
while (true) {
|
|
18349
18420
|
const effectivePageSize = opts.limit !== void 0 ? Math.min(opts.pageSize, opts.limit - allResults.length) : opts.pageSize;
|
|
18350
|
-
const
|
|
18421
|
+
const path69 = buildQueryPath({
|
|
18351
18422
|
db: connection.database,
|
|
18352
18423
|
collection: opts.collection,
|
|
18353
18424
|
start: start3,
|
|
@@ -18355,7 +18426,7 @@ async function fetchAllPages(connection, opts) {
|
|
|
18355
18426
|
sort: opts.sort,
|
|
18356
18427
|
query: opts.query
|
|
18357
18428
|
});
|
|
18358
|
-
const data = await ravenFetch(connection,
|
|
18429
|
+
const data = await ravenFetch(connection, path69);
|
|
18359
18430
|
const results = data.Results ?? [];
|
|
18360
18431
|
const totalResults = data.TotalResults ?? 0;
|
|
18361
18432
|
if (results.length === 0) break;
|
|
@@ -18413,7 +18484,7 @@ function registerRavendb(program2) {
|
|
|
18413
18484
|
|
|
18414
18485
|
// src/commands/refactor/check/index.ts
|
|
18415
18486
|
import { spawn as spawn5 } from "child_process";
|
|
18416
|
-
import * as
|
|
18487
|
+
import * as path36 from "path";
|
|
18417
18488
|
|
|
18418
18489
|
// src/commands/refactor/logViolations.ts
|
|
18419
18490
|
import chalk171 from "chalk";
|
|
@@ -18471,7 +18542,7 @@ Refactor check failed:
|
|
|
18471
18542
|
}
|
|
18472
18543
|
|
|
18473
18544
|
// src/commands/refactor/check/getViolations/index.ts
|
|
18474
|
-
import { execSync as
|
|
18545
|
+
import { execSync as execSync51 } from "child_process";
|
|
18475
18546
|
import fs25 from "fs";
|
|
18476
18547
|
import { minimatch as minimatch6 } from "minimatch";
|
|
18477
18548
|
|
|
@@ -18521,7 +18592,7 @@ function getGitFiles(options2) {
|
|
|
18521
18592
|
}
|
|
18522
18593
|
const files = /* @__PURE__ */ new Set();
|
|
18523
18594
|
if (options2.staged || options2.modified) {
|
|
18524
|
-
const staged =
|
|
18595
|
+
const staged = execSync51("git diff --cached --name-only", {
|
|
18525
18596
|
encoding: "utf8"
|
|
18526
18597
|
});
|
|
18527
18598
|
for (const file of staged.trim().split("\n").filter(Boolean)) {
|
|
@@ -18529,7 +18600,7 @@ function getGitFiles(options2) {
|
|
|
18529
18600
|
}
|
|
18530
18601
|
}
|
|
18531
18602
|
if (options2.unstaged || options2.modified) {
|
|
18532
|
-
const unstaged =
|
|
18603
|
+
const unstaged = execSync51("git diff --name-only", { encoding: "utf8" });
|
|
18533
18604
|
for (const file of unstaged.trim().split("\n").filter(Boolean)) {
|
|
18534
18605
|
files.add(file);
|
|
18535
18606
|
}
|
|
@@ -18590,7 +18661,7 @@ ${failed2.length} verify script(s) failed:`);
|
|
|
18590
18661
|
async function runVerifyQuietly() {
|
|
18591
18662
|
const result = findPackageJsonWithVerifyScripts(process.cwd());
|
|
18592
18663
|
if (!result) return true;
|
|
18593
|
-
const packageDir =
|
|
18664
|
+
const packageDir = path36.dirname(result.packageJsonPath);
|
|
18594
18665
|
const results = await Promise.all(
|
|
18595
18666
|
result.verifyScripts.map((script) => runScript(script, packageDir))
|
|
18596
18667
|
);
|
|
@@ -18616,7 +18687,7 @@ async function check(pattern2, options2) {
|
|
|
18616
18687
|
}
|
|
18617
18688
|
|
|
18618
18689
|
// src/commands/refactor/extract/index.ts
|
|
18619
|
-
import
|
|
18690
|
+
import path43 from "path";
|
|
18620
18691
|
import chalk174 from "chalk";
|
|
18621
18692
|
|
|
18622
18693
|
// src/commands/refactor/extract/applyExtraction.ts
|
|
@@ -19093,9 +19164,9 @@ function buildDestinationContent(functionTexts, imports, sourceRelativePath, sou
|
|
|
19093
19164
|
}
|
|
19094
19165
|
|
|
19095
19166
|
// src/commands/refactor/extract/getRelativeImportPath.ts
|
|
19096
|
-
import
|
|
19167
|
+
import path37 from "path";
|
|
19097
19168
|
function getRelativeImportPath(from, to) {
|
|
19098
|
-
let rel =
|
|
19169
|
+
let rel = path37.relative(path37.dirname(from), to).replace(/\.tsx?$/, "").replace(/\\/g, "/");
|
|
19099
19170
|
if (!rel.startsWith(".")) rel = `./${rel}`;
|
|
19100
19171
|
return rel;
|
|
19101
19172
|
}
|
|
@@ -19119,9 +19190,9 @@ function findImporters(functionName, sourceFile, destPath, project) {
|
|
|
19119
19190
|
}
|
|
19120
19191
|
|
|
19121
19192
|
// src/commands/refactor/extract/resolveBarrel.ts
|
|
19122
|
-
import
|
|
19193
|
+
import path38 from "path";
|
|
19123
19194
|
function resolveBarrel(functionName, sourcePath, destPath, project) {
|
|
19124
|
-
const indexPath =
|
|
19195
|
+
const indexPath = path38.join(path38.dirname(destPath), "index.ts");
|
|
19125
19196
|
const barrel = project.getSourceFile(indexPath);
|
|
19126
19197
|
if (!barrel) return { barrel: void 0, barrelRelPath: "" };
|
|
19127
19198
|
const sourceRelFromBarrel = getRelativeImportPath(indexPath, sourcePath);
|
|
@@ -19139,15 +19210,15 @@ function resolveBarrel(functionName, sourcePath, destPath, project) {
|
|
|
19139
19210
|
}
|
|
19140
19211
|
|
|
19141
19212
|
// src/commands/refactor/extract/rewriteImportPaths.ts
|
|
19142
|
-
import
|
|
19213
|
+
import path39 from "path";
|
|
19143
19214
|
function rewriteImportPaths(imports, sourcePath, destPath) {
|
|
19144
|
-
const sourceDir =
|
|
19145
|
-
const destDir =
|
|
19215
|
+
const sourceDir = path39.dirname(sourcePath);
|
|
19216
|
+
const destDir = path39.dirname(destPath);
|
|
19146
19217
|
return imports.map((imp) => {
|
|
19147
19218
|
if (!imp.moduleSpecifier.startsWith(".")) return imp;
|
|
19148
|
-
const absolute =
|
|
19149
|
-
let rel =
|
|
19150
|
-
if (rel === "") rel = `../${
|
|
19219
|
+
const absolute = path39.resolve(sourceDir, imp.moduleSpecifier);
|
|
19220
|
+
let rel = path39.relative(destDir, absolute).replace(/\\/g, "/");
|
|
19221
|
+
if (rel === "") rel = `../${path39.basename(absolute)}`;
|
|
19151
19222
|
else if (!rel.startsWith(".")) rel = `./${rel}`;
|
|
19152
19223
|
return { ...imp, moduleSpecifier: rel };
|
|
19153
19224
|
});
|
|
@@ -19215,7 +19286,7 @@ function buildPlan2(functionName, sourceFile, sourcePath, destPath, project) {
|
|
|
19215
19286
|
}
|
|
19216
19287
|
|
|
19217
19288
|
// src/commands/refactor/extract/displayPlan.ts
|
|
19218
|
-
import
|
|
19289
|
+
import path40 from "path";
|
|
19219
19290
|
import chalk172 from "chalk";
|
|
19220
19291
|
function section2(title) {
|
|
19221
19292
|
return `
|
|
@@ -19225,7 +19296,7 @@ function displayImporters(plan2, cwd) {
|
|
|
19225
19296
|
if (plan2.importersToUpdate.length === 0) return;
|
|
19226
19297
|
console.log(section2("Update importers:"));
|
|
19227
19298
|
for (const imp of plan2.importersToUpdate) {
|
|
19228
|
-
const rel =
|
|
19299
|
+
const rel = path40.relative(cwd, imp.file.getFilePath());
|
|
19229
19300
|
console.log(` ${chalk172.dim(rel)}: \u2192 import from "${imp.relPath}"`);
|
|
19230
19301
|
}
|
|
19231
19302
|
}
|
|
@@ -19265,16 +19336,16 @@ function displayPlan(functionName, relDest, plan2, cwd) {
|
|
|
19265
19336
|
}
|
|
19266
19337
|
|
|
19267
19338
|
// src/commands/refactor/extract/loadProjectFile.ts
|
|
19268
|
-
import
|
|
19339
|
+
import path42 from "path";
|
|
19269
19340
|
import chalk173 from "chalk";
|
|
19270
19341
|
import { Project as Project4 } from "ts-morph";
|
|
19271
19342
|
|
|
19272
19343
|
// src/commands/refactor/extract/findTsConfig.ts
|
|
19273
19344
|
import fs26 from "fs";
|
|
19274
|
-
import
|
|
19345
|
+
import path41 from "path";
|
|
19275
19346
|
import { Project as Project3 } from "ts-morph";
|
|
19276
19347
|
function findTsConfig(sourcePath) {
|
|
19277
|
-
const rootConfig =
|
|
19348
|
+
const rootConfig = path41.resolve("tsconfig.json");
|
|
19278
19349
|
if (!fs26.existsSync(rootConfig)) return rootConfig;
|
|
19279
19350
|
const tried = /* @__PURE__ */ new Set();
|
|
19280
19351
|
const candidates = [rootConfig, ...readReferences(rootConfig)];
|
|
@@ -19283,7 +19354,7 @@ function findTsConfig(sourcePath) {
|
|
|
19283
19354
|
tried.add(candidate);
|
|
19284
19355
|
if (projectIncludes(candidate, sourcePath)) return candidate;
|
|
19285
19356
|
}
|
|
19286
|
-
const siblings = fs26.readdirSync(
|
|
19357
|
+
const siblings = fs26.readdirSync(path41.dirname(rootConfig)).filter((f) => /^tsconfig.*\.json$/.test(f)).map((f) => path41.resolve(path41.dirname(rootConfig), f));
|
|
19287
19358
|
for (const sibling of siblings) {
|
|
19288
19359
|
if (tried.has(sibling)) continue;
|
|
19289
19360
|
tried.add(sibling);
|
|
@@ -19302,10 +19373,10 @@ function readReferences(configPath) {
|
|
|
19302
19373
|
return [];
|
|
19303
19374
|
}
|
|
19304
19375
|
if (!parsed.references?.length) return [];
|
|
19305
|
-
const cwd =
|
|
19376
|
+
const cwd = path41.dirname(configPath);
|
|
19306
19377
|
return parsed.references.map((ref) => {
|
|
19307
|
-
const refPath =
|
|
19308
|
-
return fs26.statSync(refPath, { throwIfNoEntry: false })?.isDirectory() ?
|
|
19378
|
+
const refPath = path41.resolve(cwd, ref.path);
|
|
19379
|
+
return fs26.statSync(refPath, { throwIfNoEntry: false })?.isDirectory() ? path41.join(refPath, "tsconfig.json") : refPath;
|
|
19309
19380
|
}).filter((p) => fs26.existsSync(p));
|
|
19310
19381
|
}
|
|
19311
19382
|
function projectIncludes(configPath, sourcePath) {
|
|
@@ -19319,7 +19390,7 @@ function projectIncludes(configPath, sourcePath) {
|
|
|
19319
19390
|
|
|
19320
19391
|
// src/commands/refactor/extract/loadProjectFile.ts
|
|
19321
19392
|
function loadProjectFile(file) {
|
|
19322
|
-
const sourcePath =
|
|
19393
|
+
const sourcePath = path42.resolve(file);
|
|
19323
19394
|
const tsConfigPath = findTsConfig(sourcePath);
|
|
19324
19395
|
const project = new Project4({
|
|
19325
19396
|
tsConfigFilePath: tsConfigPath
|
|
@@ -19334,10 +19405,10 @@ function loadProjectFile(file) {
|
|
|
19334
19405
|
|
|
19335
19406
|
// src/commands/refactor/extract/index.ts
|
|
19336
19407
|
async function extract(file, functionName, destination, options2 = {}) {
|
|
19337
|
-
const sourcePath =
|
|
19338
|
-
const destPath =
|
|
19408
|
+
const sourcePath = path43.resolve(file);
|
|
19409
|
+
const destPath = path43.resolve(destination);
|
|
19339
19410
|
const cwd = process.cwd();
|
|
19340
|
-
const relDest =
|
|
19411
|
+
const relDest = path43.relative(cwd, destPath);
|
|
19341
19412
|
const { project, sourceFile } = loadProjectFile(file);
|
|
19342
19413
|
const plan2 = buildPlan2(
|
|
19343
19414
|
functionName,
|
|
@@ -19385,16 +19456,16 @@ function ignore2(file) {
|
|
|
19385
19456
|
|
|
19386
19457
|
// src/commands/refactor/rename/index.ts
|
|
19387
19458
|
import fs30 from "fs";
|
|
19388
|
-
import
|
|
19459
|
+
import path48 from "path";
|
|
19389
19460
|
import chalk178 from "chalk";
|
|
19390
19461
|
|
|
19391
19462
|
// src/commands/refactor/rename/applyRename.ts
|
|
19392
19463
|
import fs29 from "fs";
|
|
19393
|
-
import
|
|
19464
|
+
import path45 from "path";
|
|
19394
19465
|
import chalk176 from "chalk";
|
|
19395
19466
|
|
|
19396
19467
|
// src/commands/refactor/restructure/computeRewrites/index.ts
|
|
19397
|
-
import
|
|
19468
|
+
import path44 from "path";
|
|
19398
19469
|
|
|
19399
19470
|
// src/commands/refactor/restructure/computeRewrites/applyRewrites.ts
|
|
19400
19471
|
import fs28 from "fs";
|
|
@@ -19448,7 +19519,7 @@ function normalizeSpecifier(rel) {
|
|
|
19448
19519
|
);
|
|
19449
19520
|
}
|
|
19450
19521
|
function computeSpecifier(fromFile, toFile) {
|
|
19451
|
-
return normalizeSpecifier(
|
|
19522
|
+
return normalizeSpecifier(path44.relative(path44.dirname(fromFile), toFile));
|
|
19452
19523
|
}
|
|
19453
19524
|
function isAffected(edge, moveMap) {
|
|
19454
19525
|
return moveMap.has(edge.target) || moveMap.has(edge.source);
|
|
@@ -19496,20 +19567,20 @@ function applyRename(rewrites, sourcePath, destPath, cwd) {
|
|
|
19496
19567
|
const updatedContents = applyRewrites(rewrites);
|
|
19497
19568
|
for (const [file, content] of updatedContents) {
|
|
19498
19569
|
fs29.writeFileSync(file, content, "utf8");
|
|
19499
|
-
console.log(chalk176.cyan(` Updated imports in ${
|
|
19570
|
+
console.log(chalk176.cyan(` Updated imports in ${path45.relative(cwd, file)}`));
|
|
19500
19571
|
}
|
|
19501
|
-
const destDir =
|
|
19572
|
+
const destDir = path45.dirname(destPath);
|
|
19502
19573
|
if (!fs29.existsSync(destDir)) fs29.mkdirSync(destDir, { recursive: true });
|
|
19503
19574
|
fs29.renameSync(sourcePath, destPath);
|
|
19504
19575
|
console.log(
|
|
19505
19576
|
chalk176.white(
|
|
19506
|
-
` Moved ${
|
|
19577
|
+
` Moved ${path45.relative(cwd, sourcePath)} \u2192 ${path45.relative(cwd, destPath)}`
|
|
19507
19578
|
)
|
|
19508
19579
|
);
|
|
19509
19580
|
}
|
|
19510
19581
|
|
|
19511
19582
|
// src/commands/refactor/restructure/buildImportGraph/index.ts
|
|
19512
|
-
import
|
|
19583
|
+
import path46 from "path";
|
|
19513
19584
|
import ts7 from "typescript";
|
|
19514
19585
|
|
|
19515
19586
|
// src/commands/refactor/restructure/buildImportGraph/getImportSpecifiers.ts
|
|
@@ -19536,7 +19607,7 @@ function loadParsedConfig(tsConfigPath) {
|
|
|
19536
19607
|
return ts7.parseJsonConfigFileContent(
|
|
19537
19608
|
configFile.config,
|
|
19538
19609
|
ts7.sys,
|
|
19539
|
-
|
|
19610
|
+
path46.dirname(tsConfigPath)
|
|
19540
19611
|
);
|
|
19541
19612
|
}
|
|
19542
19613
|
function addToSetMap(map, key, value) {
|
|
@@ -19552,7 +19623,7 @@ function resolveImport(specifier, filePath, options2) {
|
|
|
19552
19623
|
const resolved = ts7.resolveModuleName(specifier, filePath, options2, ts7.sys);
|
|
19553
19624
|
const resolvedPath = resolved.resolvedModule?.resolvedFileName;
|
|
19554
19625
|
if (!resolvedPath || resolvedPath.includes("node_modules")) return null;
|
|
19555
|
-
return
|
|
19626
|
+
return path46.resolve(resolvedPath);
|
|
19556
19627
|
}
|
|
19557
19628
|
function buildImportGraph(candidateFiles, tsConfigPath) {
|
|
19558
19629
|
const parsed = loadParsedConfig(tsConfigPath);
|
|
@@ -19561,7 +19632,7 @@ function buildImportGraph(candidateFiles, tsConfigPath) {
|
|
|
19561
19632
|
const importedBy = /* @__PURE__ */ new Map();
|
|
19562
19633
|
const imports = /* @__PURE__ */ new Map();
|
|
19563
19634
|
for (const sourceFile of program2.getSourceFiles()) {
|
|
19564
|
-
const filePath =
|
|
19635
|
+
const filePath = path46.resolve(sourceFile.fileName);
|
|
19565
19636
|
if (filePath.includes("node_modules")) continue;
|
|
19566
19637
|
for (const specifier of getImportSpecifiers(sourceFile)) {
|
|
19567
19638
|
const absTarget = resolveImport(specifier, filePath, parsed.options);
|
|
@@ -19588,13 +19659,13 @@ function computeRenameRewrites(sourcePath, destPath) {
|
|
|
19588
19659
|
}
|
|
19589
19660
|
|
|
19590
19661
|
// src/commands/refactor/rename/printRenamePreview.ts
|
|
19591
|
-
import
|
|
19662
|
+
import path47 from "path";
|
|
19592
19663
|
import chalk177 from "chalk";
|
|
19593
19664
|
function printRenamePreview(rewrites, cwd) {
|
|
19594
19665
|
for (const rewrite of rewrites) {
|
|
19595
19666
|
console.log(
|
|
19596
19667
|
chalk177.dim(
|
|
19597
|
-
` ${
|
|
19668
|
+
` ${path47.relative(cwd, rewrite.file)}: ${rewrite.oldSpecifier} \u2192 ${rewrite.newSpecifier}`
|
|
19598
19669
|
)
|
|
19599
19670
|
);
|
|
19600
19671
|
}
|
|
@@ -19603,11 +19674,11 @@ function printRenamePreview(rewrites, cwd) {
|
|
|
19603
19674
|
|
|
19604
19675
|
// src/commands/refactor/rename/index.ts
|
|
19605
19676
|
async function rename(source, destination, options2 = {}) {
|
|
19606
|
-
const sourcePath =
|
|
19607
|
-
const destPath =
|
|
19677
|
+
const sourcePath = path48.resolve(source);
|
|
19678
|
+
const destPath = path48.resolve(destination);
|
|
19608
19679
|
const cwd = process.cwd();
|
|
19609
|
-
const relSource =
|
|
19610
|
-
const relDest =
|
|
19680
|
+
const relSource = path48.relative(cwd, sourcePath);
|
|
19681
|
+
const relDest = path48.relative(cwd, destPath);
|
|
19611
19682
|
if (!fs30.existsSync(sourcePath)) {
|
|
19612
19683
|
console.log(chalk178.red(`File not found: ${source}`));
|
|
19613
19684
|
process.exit(1);
|
|
@@ -19662,12 +19733,12 @@ function findSymbol(sourceFile, symbolName) {
|
|
|
19662
19733
|
}
|
|
19663
19734
|
|
|
19664
19735
|
// src/commands/refactor/renameSymbol/groupReferences.ts
|
|
19665
|
-
import
|
|
19736
|
+
import path49 from "path";
|
|
19666
19737
|
function groupReferences(symbol, cwd) {
|
|
19667
19738
|
const refs = symbol.findReferencesAsNodes();
|
|
19668
19739
|
const grouped = /* @__PURE__ */ new Map();
|
|
19669
19740
|
for (const ref of refs) {
|
|
19670
|
-
const refFile =
|
|
19741
|
+
const refFile = path49.relative(cwd, ref.getSourceFile().getFilePath());
|
|
19671
19742
|
const lines = grouped.get(refFile) ?? [];
|
|
19672
19743
|
if (!grouped.has(refFile)) grouped.set(refFile, lines);
|
|
19673
19744
|
lines.push(ref.getStartLineNumber());
|
|
@@ -19706,16 +19777,16 @@ Renamed ${oldName} \u2192 ${newName}`));
|
|
|
19706
19777
|
}
|
|
19707
19778
|
|
|
19708
19779
|
// src/commands/refactor/restructure/index.ts
|
|
19709
|
-
import
|
|
19780
|
+
import path56 from "path";
|
|
19710
19781
|
import chalk182 from "chalk";
|
|
19711
19782
|
|
|
19712
19783
|
// src/commands/refactor/restructure/clusterDirectories.ts
|
|
19713
|
-
import
|
|
19784
|
+
import path50 from "path";
|
|
19714
19785
|
function clusterDirectories(graph) {
|
|
19715
19786
|
const dirImportedBy = /* @__PURE__ */ new Map();
|
|
19716
19787
|
for (const edge of graph.edges) {
|
|
19717
|
-
const sourceDir =
|
|
19718
|
-
const targetDir =
|
|
19788
|
+
const sourceDir = path50.dirname(edge.source);
|
|
19789
|
+
const targetDir = path50.dirname(edge.target);
|
|
19719
19790
|
if (sourceDir === targetDir) continue;
|
|
19720
19791
|
if (!graph.files.has(edge.target)) continue;
|
|
19721
19792
|
const existing = dirImportedBy.get(targetDir) ?? /* @__PURE__ */ new Set();
|
|
@@ -19743,20 +19814,20 @@ function clusterDirectories(graph) {
|
|
|
19743
19814
|
return clusters;
|
|
19744
19815
|
}
|
|
19745
19816
|
function isAncestor(ancestor, descendant) {
|
|
19746
|
-
const rel =
|
|
19817
|
+
const rel = path50.relative(ancestor, descendant);
|
|
19747
19818
|
return !rel.startsWith("..") && rel !== "";
|
|
19748
19819
|
}
|
|
19749
19820
|
|
|
19750
19821
|
// src/commands/refactor/restructure/clusterFiles.ts
|
|
19751
|
-
import
|
|
19822
|
+
import path51 from "path";
|
|
19752
19823
|
function findRootParent(file, importedBy, visited) {
|
|
19753
19824
|
const importers = importedBy.get(file);
|
|
19754
19825
|
if (!importers || importers.size !== 1) return file;
|
|
19755
19826
|
const parent = [...importers][0];
|
|
19756
|
-
const parentDir =
|
|
19757
|
-
const fileDir =
|
|
19827
|
+
const parentDir = path51.dirname(parent);
|
|
19828
|
+
const fileDir = path51.dirname(file);
|
|
19758
19829
|
if (parentDir !== fileDir) return file;
|
|
19759
|
-
if (
|
|
19830
|
+
if (path51.basename(parent, path51.extname(parent)) === "index") return file;
|
|
19760
19831
|
if (visited.has(parent)) return file;
|
|
19761
19832
|
visited.add(parent);
|
|
19762
19833
|
return findRootParent(parent, importedBy, visited);
|
|
@@ -19764,16 +19835,16 @@ function findRootParent(file, importedBy, visited) {
|
|
|
19764
19835
|
function clusterFiles(graph) {
|
|
19765
19836
|
const clusters = /* @__PURE__ */ new Map();
|
|
19766
19837
|
for (const file of graph.files) {
|
|
19767
|
-
const basename14 =
|
|
19838
|
+
const basename14 = path51.basename(file, path51.extname(file));
|
|
19768
19839
|
if (basename14 === "index") continue;
|
|
19769
19840
|
const importers = graph.importedBy.get(file);
|
|
19770
19841
|
if (!importers || importers.size !== 1) continue;
|
|
19771
19842
|
const parent = [...importers][0];
|
|
19772
19843
|
if (!graph.files.has(parent)) continue;
|
|
19773
|
-
const parentDir =
|
|
19774
|
-
const fileDir =
|
|
19844
|
+
const parentDir = path51.dirname(parent);
|
|
19845
|
+
const fileDir = path51.dirname(file);
|
|
19775
19846
|
if (parentDir !== fileDir) continue;
|
|
19776
|
-
const parentBasename =
|
|
19847
|
+
const parentBasename = path51.basename(parent, path51.extname(parent));
|
|
19777
19848
|
if (parentBasename === "index") continue;
|
|
19778
19849
|
const root = findRootParent(parent, graph.importedBy, /* @__PURE__ */ new Set([file]));
|
|
19779
19850
|
if (!root || root === file) continue;
|
|
@@ -19785,10 +19856,10 @@ function clusterFiles(graph) {
|
|
|
19785
19856
|
}
|
|
19786
19857
|
|
|
19787
19858
|
// src/commands/refactor/restructure/displayPlan.ts
|
|
19788
|
-
import
|
|
19859
|
+
import path52 from "path";
|
|
19789
19860
|
import chalk180 from "chalk";
|
|
19790
19861
|
function relPath(filePath) {
|
|
19791
|
-
return
|
|
19862
|
+
return path52.relative(process.cwd(), filePath);
|
|
19792
19863
|
}
|
|
19793
19864
|
function displayMoves(plan2) {
|
|
19794
19865
|
if (plan2.moves.length === 0) return;
|
|
@@ -19838,33 +19909,33 @@ Summary: ${plan2.moves.length} file(s) moved, ${plan2.rewrites.length} imports r
|
|
|
19838
19909
|
|
|
19839
19910
|
// src/commands/refactor/restructure/executePlan.ts
|
|
19840
19911
|
import fs31 from "fs";
|
|
19841
|
-
import
|
|
19912
|
+
import path53 from "path";
|
|
19842
19913
|
import chalk181 from "chalk";
|
|
19843
19914
|
function executePlan(plan2) {
|
|
19844
19915
|
const updatedContents = applyRewrites(plan2.rewrites);
|
|
19845
19916
|
for (const [file, content] of updatedContents) {
|
|
19846
19917
|
fs31.writeFileSync(file, content, "utf8");
|
|
19847
19918
|
console.log(
|
|
19848
|
-
chalk181.cyan(` Rewrote imports in ${
|
|
19919
|
+
chalk181.cyan(` Rewrote imports in ${path53.relative(process.cwd(), file)}`)
|
|
19849
19920
|
);
|
|
19850
19921
|
}
|
|
19851
19922
|
for (const dir of plan2.newDirectories) {
|
|
19852
19923
|
fs31.mkdirSync(dir, { recursive: true });
|
|
19853
|
-
console.log(chalk181.green(` Created ${
|
|
19924
|
+
console.log(chalk181.green(` Created ${path53.relative(process.cwd(), dir)}/`));
|
|
19854
19925
|
}
|
|
19855
19926
|
for (const move2 of plan2.moves) {
|
|
19856
|
-
const targetDir =
|
|
19927
|
+
const targetDir = path53.dirname(move2.to);
|
|
19857
19928
|
if (!fs31.existsSync(targetDir)) {
|
|
19858
19929
|
fs31.mkdirSync(targetDir, { recursive: true });
|
|
19859
19930
|
}
|
|
19860
19931
|
fs31.renameSync(move2.from, move2.to);
|
|
19861
19932
|
console.log(
|
|
19862
19933
|
chalk181.white(
|
|
19863
|
-
` Moved ${
|
|
19934
|
+
` Moved ${path53.relative(process.cwd(), move2.from)} \u2192 ${path53.relative(process.cwd(), move2.to)}`
|
|
19864
19935
|
)
|
|
19865
19936
|
);
|
|
19866
19937
|
}
|
|
19867
|
-
removeEmptyDirectories(plan2.moves.map((m) =>
|
|
19938
|
+
removeEmptyDirectories(plan2.moves.map((m) => path53.dirname(m.from)));
|
|
19868
19939
|
}
|
|
19869
19940
|
function removeEmptyDirectories(dirs) {
|
|
19870
19941
|
const unique = [...new Set(dirs)];
|
|
@@ -19875,7 +19946,7 @@ function removeEmptyDirectories(dirs) {
|
|
|
19875
19946
|
fs31.rmdirSync(dir);
|
|
19876
19947
|
console.log(
|
|
19877
19948
|
chalk181.dim(
|
|
19878
|
-
` Removed empty directory ${
|
|
19949
|
+
` Removed empty directory ${path53.relative(process.cwd(), dir)}`
|
|
19879
19950
|
)
|
|
19880
19951
|
);
|
|
19881
19952
|
}
|
|
@@ -19883,7 +19954,7 @@ function removeEmptyDirectories(dirs) {
|
|
|
19883
19954
|
}
|
|
19884
19955
|
|
|
19885
19956
|
// src/commands/refactor/restructure/planFileMoves/index.ts
|
|
19886
|
-
import
|
|
19957
|
+
import path55 from "path";
|
|
19887
19958
|
|
|
19888
19959
|
// src/commands/refactor/restructure/planFileMoves/shared.ts
|
|
19889
19960
|
import fs32 from "fs";
|
|
@@ -19898,9 +19969,9 @@ function checkDirConflict(result, label2, dir) {
|
|
|
19898
19969
|
|
|
19899
19970
|
// src/commands/refactor/restructure/planFileMoves/planDirectoryMoves.ts
|
|
19900
19971
|
import fs33 from "fs";
|
|
19901
|
-
import
|
|
19972
|
+
import path54 from "path";
|
|
19902
19973
|
function collectEntry(results, dir, entry) {
|
|
19903
|
-
const full =
|
|
19974
|
+
const full = path54.join(dir, entry.name);
|
|
19904
19975
|
const items2 = entry.isDirectory() ? listFilesRecursive(full) : [full];
|
|
19905
19976
|
results.push(...items2);
|
|
19906
19977
|
}
|
|
@@ -19914,15 +19985,15 @@ function listFilesRecursive(dir) {
|
|
|
19914
19985
|
}
|
|
19915
19986
|
function addDirectoryFileMoves(moves, childDir, newLocation, reason) {
|
|
19916
19987
|
for (const file of listFilesRecursive(childDir)) {
|
|
19917
|
-
const rel =
|
|
19918
|
-
moves.push({ from: file, to:
|
|
19988
|
+
const rel = path54.relative(childDir, file);
|
|
19989
|
+
moves.push({ from: file, to: path54.join(newLocation, rel), reason });
|
|
19919
19990
|
}
|
|
19920
19991
|
}
|
|
19921
19992
|
function resolveChildDest(parentDir, childDir) {
|
|
19922
|
-
return
|
|
19993
|
+
return path54.join(parentDir, path54.basename(childDir));
|
|
19923
19994
|
}
|
|
19924
19995
|
function childMoveReason(parentDir) {
|
|
19925
|
-
return `Directory only imported from ${
|
|
19996
|
+
return `Directory only imported from ${path54.basename(parentDir)}/`;
|
|
19926
19997
|
}
|
|
19927
19998
|
function registerDirectoryMove(result, childDir, dest, parentDir) {
|
|
19928
19999
|
result.directories.push(dest);
|
|
@@ -19947,7 +20018,7 @@ function planDirectoryMoves(clusters) {
|
|
|
19947
20018
|
|
|
19948
20019
|
// src/commands/refactor/restructure/planFileMoves/index.ts
|
|
19949
20020
|
function childMoveData(child, newDir, parentBase) {
|
|
19950
|
-
const to =
|
|
20021
|
+
const to = path55.join(newDir, path55.basename(child));
|
|
19951
20022
|
return { from: child, to, reason: `Only imported by ${parentBase}` };
|
|
19952
20023
|
}
|
|
19953
20024
|
function addChildMoves(moves, children, newDir, parentBase) {
|
|
@@ -19955,15 +20026,15 @@ function addChildMoves(moves, children, newDir, parentBase) {
|
|
|
19955
20026
|
moves.push(childMoveData(child, newDir, parentBase));
|
|
19956
20027
|
}
|
|
19957
20028
|
function getBaseName(filePath) {
|
|
19958
|
-
return
|
|
20029
|
+
return path55.basename(filePath, path55.extname(filePath));
|
|
19959
20030
|
}
|
|
19960
20031
|
function resolveClusterDir(parent) {
|
|
19961
|
-
return
|
|
20032
|
+
return path55.join(path55.dirname(parent), getBaseName(parent));
|
|
19962
20033
|
}
|
|
19963
20034
|
function createParentMove(parent, newDir) {
|
|
19964
20035
|
return {
|
|
19965
20036
|
from: parent,
|
|
19966
|
-
to:
|
|
20037
|
+
to: path55.join(newDir, `index${path55.extname(parent)}`),
|
|
19967
20038
|
reason: `Main module of new ${getBaseName(parent)}/ directory`
|
|
19968
20039
|
};
|
|
19969
20040
|
}
|
|
@@ -19987,7 +20058,7 @@ function planFileMoves(clusters) {
|
|
|
19987
20058
|
|
|
19988
20059
|
// src/commands/refactor/restructure/index.ts
|
|
19989
20060
|
function buildPlan3(candidateFiles, tsConfigPath) {
|
|
19990
|
-
const candidates = new Set(candidateFiles.map((f) =>
|
|
20061
|
+
const candidates = new Set(candidateFiles.map((f) => path56.resolve(f)));
|
|
19991
20062
|
const graph = buildImportGraph(candidates, tsConfigPath);
|
|
19992
20063
|
const allProjectFiles = /* @__PURE__ */ new Set([
|
|
19993
20064
|
...graph.importedBy.keys(),
|
|
@@ -20010,7 +20081,7 @@ async function restructure(pattern2, options2 = {}) {
|
|
|
20010
20081
|
console.log(chalk182.yellow("No files found matching pattern"));
|
|
20011
20082
|
return;
|
|
20012
20083
|
}
|
|
20013
|
-
const tsConfigPath =
|
|
20084
|
+
const tsConfigPath = path56.resolve("tsconfig.json");
|
|
20014
20085
|
const plan2 = buildPlan3(files, tsConfigPath);
|
|
20015
20086
|
if (plan2.moves.length === 0) {
|
|
20016
20087
|
console.log(chalk182.green("No restructuring needed"));
|
|
@@ -20207,9 +20278,9 @@ function buildReviewPaths(repoRoot, key) {
|
|
|
20207
20278
|
}
|
|
20208
20279
|
|
|
20209
20280
|
// src/commands/review/fetchExistingComments.ts
|
|
20210
|
-
import { execSync as
|
|
20281
|
+
import { execSync as execSync52 } from "child_process";
|
|
20211
20282
|
function fetchRawComments(org, repo, prNumber) {
|
|
20212
|
-
const out =
|
|
20283
|
+
const out = execSync52(
|
|
20213
20284
|
`gh api --paginate repos/${org}/${repo}/pulls/${prNumber}/comments`,
|
|
20214
20285
|
{ encoding: "utf8", maxBuffer: 64 * 1024 * 1024 }
|
|
20215
20286
|
);
|
|
@@ -20240,14 +20311,14 @@ function fetchExistingComments() {
|
|
|
20240
20311
|
}
|
|
20241
20312
|
|
|
20242
20313
|
// src/commands/review/gatherContext.ts
|
|
20243
|
-
import { execSync as
|
|
20314
|
+
import { execSync as execSync55 } from "child_process";
|
|
20244
20315
|
|
|
20245
20316
|
// src/commands/review/fetchPrDiff.ts
|
|
20246
|
-
import { execSync as
|
|
20317
|
+
import { execSync as execSync53 } from "child_process";
|
|
20247
20318
|
function fetchPrDiff(prNumber, baseSha, headSha) {
|
|
20248
20319
|
const { org, repo } = getRepoInfo();
|
|
20249
20320
|
try {
|
|
20250
|
-
return
|
|
20321
|
+
return execSync53(`gh pr diff ${prNumber} -R ${org}/${repo}`, {
|
|
20251
20322
|
encoding: "utf8",
|
|
20252
20323
|
maxBuffer: 256 * 1024 * 1024,
|
|
20253
20324
|
stdio: ["ignore", "pipe", "pipe"]
|
|
@@ -20262,19 +20333,19 @@ function isDiffTooLarge(error) {
|
|
|
20262
20333
|
}
|
|
20263
20334
|
function fetchDiffViaGit(baseSha, headSha) {
|
|
20264
20335
|
try {
|
|
20265
|
-
|
|
20336
|
+
execSync53(`git fetch origin ${baseSha} ${headSha}`, { stdio: "ignore" });
|
|
20266
20337
|
} catch {
|
|
20267
20338
|
}
|
|
20268
|
-
return
|
|
20339
|
+
return execSync53(`git diff ${baseSha}...${headSha}`, {
|
|
20269
20340
|
encoding: "utf8",
|
|
20270
20341
|
maxBuffer: 256 * 1024 * 1024
|
|
20271
20342
|
});
|
|
20272
20343
|
}
|
|
20273
20344
|
|
|
20274
20345
|
// src/commands/review/fetchPrDiffInfo.ts
|
|
20275
|
-
import { execSync as
|
|
20346
|
+
import { execSync as execSync54 } from "child_process";
|
|
20276
20347
|
function getCurrentBranch3() {
|
|
20277
|
-
return
|
|
20348
|
+
return execSync54("git rev-parse --abbrev-ref HEAD", {
|
|
20278
20349
|
encoding: "utf8"
|
|
20279
20350
|
}).trim();
|
|
20280
20351
|
}
|
|
@@ -20282,7 +20353,7 @@ function fetchPrDiffInfo() {
|
|
|
20282
20353
|
const { org, repo } = getRepoInfo();
|
|
20283
20354
|
const branch2 = getCurrentBranch3();
|
|
20284
20355
|
const fields = "number,baseRefName,baseRefOid,headRefName,headRefOid";
|
|
20285
|
-
const raw =
|
|
20356
|
+
const raw = execSync54(
|
|
20286
20357
|
`gh pr list --state open --head ${branch2} --json ${fields} -R ${org}/${repo}`,
|
|
20287
20358
|
{
|
|
20288
20359
|
encoding: "utf8",
|
|
@@ -20307,7 +20378,7 @@ function fetchPrDiffInfo() {
|
|
|
20307
20378
|
}
|
|
20308
20379
|
function fetchPrChangedFiles(prNumber) {
|
|
20309
20380
|
const { org, repo } = getRepoInfo();
|
|
20310
|
-
const out =
|
|
20381
|
+
const out = execSync54(
|
|
20311
20382
|
`gh api repos/${org}/${repo}/pulls/${prNumber}/files --paginate --jq ".[].filename"`,
|
|
20312
20383
|
{
|
|
20313
20384
|
encoding: "utf8",
|
|
@@ -20319,11 +20390,11 @@ function fetchPrChangedFiles(prNumber) {
|
|
|
20319
20390
|
|
|
20320
20391
|
// src/commands/review/gatherContext.ts
|
|
20321
20392
|
function gatherContext() {
|
|
20322
|
-
const branch2 =
|
|
20393
|
+
const branch2 = execSync55("git rev-parse --abbrev-ref HEAD", {
|
|
20323
20394
|
encoding: "utf8"
|
|
20324
20395
|
}).trim();
|
|
20325
|
-
const sha =
|
|
20326
|
-
const shortSha =
|
|
20396
|
+
const sha = execSync55("git rev-parse HEAD", { encoding: "utf8" }).trim();
|
|
20397
|
+
const shortSha = execSync55("git rev-parse --short=7 HEAD", {
|
|
20327
20398
|
encoding: "utf8"
|
|
20328
20399
|
}).trim();
|
|
20329
20400
|
const prInfo = fetchPrDiffInfo();
|
|
@@ -20743,8 +20814,8 @@ async function handlePostSynthesis(synthesisPath, options2) {
|
|
|
20743
20814
|
// src/commands/review/prepareReviewDir.ts
|
|
20744
20815
|
import { existsSync as existsSync43, mkdirSync as mkdirSync18, unlinkSync as unlinkSync16, writeFileSync as writeFileSync36 } from "fs";
|
|
20745
20816
|
function clearReviewFiles(paths) {
|
|
20746
|
-
for (const
|
|
20747
|
-
if (existsSync43(
|
|
20817
|
+
for (const path69 of [paths.claudePath, paths.codexPath, paths.synthesisPath]) {
|
|
20818
|
+
if (existsSync43(path69)) unlinkSync16(path69);
|
|
20748
20819
|
}
|
|
20749
20820
|
}
|
|
20750
20821
|
function prepareReviewDir(paths, requestBody, force) {
|
|
@@ -21892,8 +21963,8 @@ import chalk190 from "chalk";
|
|
|
21892
21963
|
|
|
21893
21964
|
// src/commands/seq/fetchSeq.ts
|
|
21894
21965
|
import chalk187 from "chalk";
|
|
21895
|
-
async function fetchSeq(conn,
|
|
21896
|
-
const url = `${conn.url}${
|
|
21966
|
+
async function fetchSeq(conn, path69, params) {
|
|
21967
|
+
const url = `${conn.url}${path69}?${params}`;
|
|
21897
21968
|
const response = await fetch(url, {
|
|
21898
21969
|
headers: {
|
|
21899
21970
|
Accept: "application/json",
|
|
@@ -22973,7 +23044,7 @@ import { mkdirSync as mkdirSync21 } from "fs";
|
|
|
22973
23044
|
import { join as join59 } from "path";
|
|
22974
23045
|
|
|
22975
23046
|
// src/commands/voice/checkLockFile.ts
|
|
22976
|
-
import { execSync as
|
|
23047
|
+
import { execSync as execSync56 } from "child_process";
|
|
22977
23048
|
import { existsSync as existsSync49, mkdirSync as mkdirSync20, readFileSync as readFileSync43, writeFileSync as writeFileSync39 } from "fs";
|
|
22978
23049
|
import { join as join58 } from "path";
|
|
22979
23050
|
function isProcessAlive2(pid) {
|
|
@@ -23002,7 +23073,7 @@ function bootstrapVenv() {
|
|
|
23002
23073
|
if (existsSync49(getVenvPython())) return;
|
|
23003
23074
|
console.log("Setting up Python environment...");
|
|
23004
23075
|
const pythonDir = getPythonDir();
|
|
23005
|
-
|
|
23076
|
+
execSync56(
|
|
23006
23077
|
`uv sync --project "${pythonDir}" --extra runtime --no-install-project`,
|
|
23007
23078
|
{
|
|
23008
23079
|
stdio: "inherit",
|
|
@@ -23380,9 +23451,9 @@ function findPortFile(roamDir) {
|
|
|
23380
23451
|
return void 0;
|
|
23381
23452
|
}
|
|
23382
23453
|
const candidates = entries.filter((name) => /^roam-local-api(-[^.]+)?\.port$/.test(name)).map((name) => {
|
|
23383
|
-
const
|
|
23454
|
+
const path69 = join61(roamDir, name);
|
|
23384
23455
|
try {
|
|
23385
|
-
return { path:
|
|
23456
|
+
return { path: path69, mtimeMs: statSync8(path69).mtimeMs };
|
|
23386
23457
|
} catch {
|
|
23387
23458
|
return void 0;
|
|
23388
23459
|
}
|
|
@@ -23598,11 +23669,11 @@ function resolveParams(params, cliArgs) {
|
|
|
23598
23669
|
}
|
|
23599
23670
|
|
|
23600
23671
|
// src/commands/run/runPreCommands.ts
|
|
23601
|
-
import { execSync as
|
|
23672
|
+
import { execSync as execSync57 } from "child_process";
|
|
23602
23673
|
function runPreCommands(pre, cwd) {
|
|
23603
23674
|
for (const cmd of pre) {
|
|
23604
23675
|
try {
|
|
23605
|
-
|
|
23676
|
+
execSync57(cmd, { stdio: "inherit", cwd });
|
|
23606
23677
|
} catch (error) {
|
|
23607
23678
|
const code = error && typeof error === "object" && "status" in error ? error.status : 1;
|
|
23608
23679
|
process.exit(code);
|
|
@@ -23801,11 +23872,11 @@ function findLinkIndex() {
|
|
|
23801
23872
|
function parseLinkArgs() {
|
|
23802
23873
|
const idx = findLinkIndex();
|
|
23803
23874
|
if (idx === -1) return null;
|
|
23804
|
-
const
|
|
23875
|
+
const path69 = process.argv[idx + 1];
|
|
23805
23876
|
const rest = process.argv.slice(idx + 2);
|
|
23806
23877
|
const { value: prefix2 } = extractOption(rest, "--prefix");
|
|
23807
23878
|
if (!prefix2) return null;
|
|
23808
|
-
return { path:
|
|
23879
|
+
return { path: path69, prefix: prefix2 };
|
|
23809
23880
|
}
|
|
23810
23881
|
function hasDuplicateLink(runList, linkPath) {
|
|
23811
23882
|
return runList.some(
|
|
@@ -23903,7 +23974,7 @@ function registerRun(program2) {
|
|
|
23903
23974
|
}
|
|
23904
23975
|
|
|
23905
23976
|
// src/commands/screenshot/index.ts
|
|
23906
|
-
import { execSync as
|
|
23977
|
+
import { execSync as execSync58 } from "child_process";
|
|
23907
23978
|
import { existsSync as existsSync54, mkdirSync as mkdirSync24, unlinkSync as unlinkSync21, writeFileSync as writeFileSync42 } from "fs";
|
|
23908
23979
|
import { tmpdir as tmpdir7 } from "os";
|
|
23909
23980
|
import { join as join65, resolve as resolve15 } from "path";
|
|
@@ -24046,7 +24117,7 @@ function runPowerShellScript(processName, outputPath) {
|
|
|
24046
24117
|
const scriptPath = join65(tmpdir7(), `assist-screenshot-${Date.now()}.ps1`);
|
|
24047
24118
|
writeFileSync42(scriptPath, captureWindowPs1, "utf8");
|
|
24048
24119
|
try {
|
|
24049
|
-
|
|
24120
|
+
execSync58(
|
|
24050
24121
|
`powershell -NoProfile -ExecutionPolicy Bypass -File "${scriptPath}" -ProcessName "${processName}" -OutputPath "${outputPath}"`,
|
|
24051
24122
|
{ stdio: ["ignore", "pipe", "pipe"], encoding: "utf8" }
|
|
24052
24123
|
);
|
|
@@ -24521,14 +24592,14 @@ import * as pty from "node-pty";
|
|
|
24521
24592
|
// src/commands/sessions/daemon/ensureSpawnHelperExecutable.ts
|
|
24522
24593
|
import { chmodSync, existsSync as existsSync55, statSync as statSync9 } from "fs";
|
|
24523
24594
|
import { createRequire as createRequire3 } from "module";
|
|
24524
|
-
import
|
|
24595
|
+
import path57 from "path";
|
|
24525
24596
|
var require4 = createRequire3(import.meta.url);
|
|
24526
24597
|
var ensured = false;
|
|
24527
24598
|
function ensureSpawnHelperExecutable() {
|
|
24528
24599
|
if (ensured || process.platform !== "darwin") return;
|
|
24529
24600
|
ensured = true;
|
|
24530
|
-
const ptyRoot =
|
|
24531
|
-
const helper =
|
|
24601
|
+
const ptyRoot = path57.join(path57.dirname(require4.resolve("node-pty")), "..");
|
|
24602
|
+
const helper = path57.join(
|
|
24532
24603
|
ptyRoot,
|
|
24533
24604
|
"prebuilds",
|
|
24534
24605
|
`${process.platform}-${process.arch}`,
|
|
@@ -24590,12 +24661,12 @@ import { randomUUID as randomUUID4 } from "crypto";
|
|
|
24590
24661
|
|
|
24591
24662
|
// src/commands/sessions/daemon/readDesignSystemPrompt.ts
|
|
24592
24663
|
import * as fs34 from "fs";
|
|
24593
|
-
import * as
|
|
24664
|
+
import * as path58 from "path";
|
|
24594
24665
|
import { fileURLToPath as fileURLToPath8 } from "url";
|
|
24595
24666
|
var __filename4 = fileURLToPath8(import.meta.url);
|
|
24596
|
-
var __dirname6 =
|
|
24667
|
+
var __dirname6 = path58.dirname(__filename4);
|
|
24597
24668
|
function readDesignSystemPrompt() {
|
|
24598
|
-
const promptPath =
|
|
24669
|
+
const promptPath = path58.join(__dirname6, "..", "claude", "system-prompt.md");
|
|
24599
24670
|
return fs34.readFileSync(promptPath, "utf8");
|
|
24600
24671
|
}
|
|
24601
24672
|
|
|
@@ -25132,8 +25203,8 @@ async function seedRunningMsFromUsage(session, notify2) {
|
|
|
25132
25203
|
var DEBOUNCE_MS = 50;
|
|
25133
25204
|
function watchActivity(session, notify2) {
|
|
25134
25205
|
if (session.commandType !== "assist" || !session.cwd) return;
|
|
25135
|
-
const
|
|
25136
|
-
const dir = dirname29(
|
|
25206
|
+
const path69 = activityPath(session.id);
|
|
25207
|
+
const dir = dirname29(path69);
|
|
25137
25208
|
try {
|
|
25138
25209
|
mkdirSync25(dir, { recursive: true });
|
|
25139
25210
|
} catch {
|
|
@@ -25143,7 +25214,7 @@ function watchActivity(session, notify2) {
|
|
|
25143
25214
|
let timer = null;
|
|
25144
25215
|
const read = () => {
|
|
25145
25216
|
timer = null;
|
|
25146
|
-
const activity2 = readActivity(
|
|
25217
|
+
const activity2 = readActivity(path69);
|
|
25147
25218
|
if (!activity2) return;
|
|
25148
25219
|
session.activity = activity2;
|
|
25149
25220
|
if (activity2.claudeSessionId)
|
|
@@ -25153,11 +25224,11 @@ function watchActivity(session, notify2) {
|
|
|
25153
25224
|
notify2();
|
|
25154
25225
|
};
|
|
25155
25226
|
session.activityWatcher = watch(dir, (_event, filename) => {
|
|
25156
|
-
if (filename && !
|
|
25227
|
+
if (filename && !path69.endsWith(filename)) return;
|
|
25157
25228
|
if (timer) clearTimeout(timer);
|
|
25158
25229
|
timer = setTimeout(read, DEBOUNCE_MS);
|
|
25159
25230
|
});
|
|
25160
|
-
if (existsSync56(
|
|
25231
|
+
if (existsSync56(path69)) read();
|
|
25161
25232
|
}
|
|
25162
25233
|
function refreshActivity(session) {
|
|
25163
25234
|
if (session.commandType !== "assist" || !session.cwd) return;
|
|
@@ -27209,16 +27280,16 @@ async function statusLine() {
|
|
|
27209
27280
|
// src/commands/sync.ts
|
|
27210
27281
|
import * as fs45 from "fs";
|
|
27211
27282
|
import * as os4 from "os";
|
|
27212
|
-
import * as
|
|
27283
|
+
import * as path67 from "path";
|
|
27213
27284
|
import { fileURLToPath as fileURLToPath9 } from "url";
|
|
27214
27285
|
|
|
27215
27286
|
// src/commands/sync/syncClaudeMd.ts
|
|
27216
27287
|
import * as fs39 from "fs";
|
|
27217
|
-
import * as
|
|
27288
|
+
import * as path59 from "path";
|
|
27218
27289
|
import chalk202 from "chalk";
|
|
27219
27290
|
async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
27220
|
-
const source =
|
|
27221
|
-
const target =
|
|
27291
|
+
const source = path59.join(claudeDir, "CLAUDE.md");
|
|
27292
|
+
const target = path59.join(targetBase, "CLAUDE.md");
|
|
27222
27293
|
const sourceContent = fs39.readFileSync(source, "utf8");
|
|
27223
27294
|
if (fs39.existsSync(target)) {
|
|
27224
27295
|
const targetContent = fs39.readFileSync(target, "utf8");
|
|
@@ -27243,33 +27314,33 @@ async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
|
27243
27314
|
}
|
|
27244
27315
|
|
|
27245
27316
|
// src/commands/sync/syncCodex.ts
|
|
27246
|
-
import * as
|
|
27317
|
+
import * as path62 from "path";
|
|
27247
27318
|
|
|
27248
27319
|
// src/commands/sync/installHarnessCommands.ts
|
|
27249
27320
|
import * as fs40 from "fs";
|
|
27250
|
-
import * as
|
|
27321
|
+
import * as path60 from "path";
|
|
27251
27322
|
function installHarnessCommands(claudeDir, harness, transform) {
|
|
27252
|
-
const commandsSource =
|
|
27323
|
+
const commandsSource = path60.join(claudeDir, "commands");
|
|
27253
27324
|
const files = fs40.readdirSync(commandsSource);
|
|
27254
27325
|
let synced = 0;
|
|
27255
27326
|
for (const file of files) {
|
|
27256
27327
|
if (!file.endsWith(".md")) continue;
|
|
27257
27328
|
const name = file.replace(/\.md$/, "");
|
|
27258
|
-
const content = fs40.readFileSync(
|
|
27259
|
-
const target =
|
|
27260
|
-
fs40.mkdirSync(
|
|
27329
|
+
const content = fs40.readFileSync(path60.join(commandsSource, file), "utf8");
|
|
27330
|
+
const target = path60.join(harness.homeDir, harness.sync.commandDest(name));
|
|
27331
|
+
fs40.mkdirSync(path60.dirname(target), { recursive: true });
|
|
27261
27332
|
fs40.writeFileSync(target, transform(name, content));
|
|
27262
27333
|
synced++;
|
|
27263
27334
|
}
|
|
27264
|
-
const agentsTarget =
|
|
27265
|
-
fs40.mkdirSync(
|
|
27266
|
-
fs40.copyFileSync(
|
|
27335
|
+
const agentsTarget = path60.join(harness.homeDir, harness.sync.agentsFile);
|
|
27336
|
+
fs40.mkdirSync(path60.dirname(agentsTarget), { recursive: true });
|
|
27337
|
+
fs40.copyFileSync(path60.join(claudeDir, "CLAUDE.md"), agentsTarget);
|
|
27267
27338
|
return { total: files.length, synced };
|
|
27268
27339
|
}
|
|
27269
27340
|
|
|
27270
27341
|
// src/commands/sync/syncCodexHooks.ts
|
|
27271
27342
|
import * as fs41 from "fs";
|
|
27272
|
-
import * as
|
|
27343
|
+
import * as path61 from "path";
|
|
27273
27344
|
var BEGIN = "# >>> assist codex hooks (managed) \u2014 do not edit >>>";
|
|
27274
27345
|
var END = "# <<< assist codex hooks (managed) <<<";
|
|
27275
27346
|
function upsertManagedBlock(existing, body) {
|
|
@@ -27300,9 +27371,9 @@ ${rest}
|
|
|
27300
27371
|
}
|
|
27301
27372
|
function syncCodexHooks(sourcePath) {
|
|
27302
27373
|
const body = fs41.readFileSync(sourcePath, "utf8");
|
|
27303
|
-
const configPath =
|
|
27374
|
+
const configPath = path61.join(harnesses.codex.homeDir, "config.toml");
|
|
27304
27375
|
const existing = fs41.existsSync(configPath) ? fs41.readFileSync(configPath, "utf8") : "";
|
|
27305
|
-
fs41.mkdirSync(
|
|
27376
|
+
fs41.mkdirSync(path61.dirname(configPath), { recursive: true });
|
|
27306
27377
|
fs41.writeFileSync(configPath, upsertManagedBlock(existing, body));
|
|
27307
27378
|
console.log(
|
|
27308
27379
|
"Registered assist codex-hook in ~/.codex/config.toml (PreToolUse, PermissionRequest)"
|
|
@@ -27334,7 +27405,7 @@ function syncCodex(claudeDir) {
|
|
|
27334
27405
|
harnesses.codex,
|
|
27335
27406
|
commandToSkill
|
|
27336
27407
|
);
|
|
27337
|
-
syncCodexHooks(
|
|
27408
|
+
syncCodexHooks(path62.join(claudeDir, "..", "codex", "config.toml"));
|
|
27338
27409
|
console.log(
|
|
27339
27410
|
`Synced ${total} skill(s) to ~/.codex/skills and CLAUDE.md to ~/.codex/AGENTS.md`
|
|
27340
27411
|
);
|
|
@@ -27342,33 +27413,33 @@ function syncCodex(claudeDir) {
|
|
|
27342
27413
|
|
|
27343
27414
|
// src/commands/sync/syncDesign.ts
|
|
27344
27415
|
import * as fs42 from "fs";
|
|
27345
|
-
import * as
|
|
27416
|
+
import * as path63 from "path";
|
|
27346
27417
|
function syncDesign(claudeDir, targetBase) {
|
|
27347
|
-
const systemPromptSource =
|
|
27348
|
-
const systemPromptTarget =
|
|
27418
|
+
const systemPromptSource = path63.join(claudeDir, "system-prompt.md");
|
|
27419
|
+
const systemPromptTarget = path63.join(targetBase, "system-prompt.md");
|
|
27349
27420
|
fs42.copyFileSync(systemPromptSource, systemPromptTarget);
|
|
27350
27421
|
console.log("Copied system-prompt.md to ~/.claude/system-prompt.md");
|
|
27351
|
-
const skillsSource =
|
|
27352
|
-
const skillsTarget =
|
|
27422
|
+
const skillsSource = path63.join(claudeDir, "skills");
|
|
27423
|
+
const skillsTarget = path63.join(targetBase, "skills");
|
|
27353
27424
|
fs42.mkdirSync(skillsTarget, { recursive: true });
|
|
27354
27425
|
const files = fs42.readdirSync(skillsSource);
|
|
27355
27426
|
for (const file of files) {
|
|
27356
27427
|
fs42.copyFileSync(
|
|
27357
|
-
|
|
27358
|
-
|
|
27428
|
+
path63.join(skillsSource, file),
|
|
27429
|
+
path63.join(skillsTarget, file)
|
|
27359
27430
|
);
|
|
27360
27431
|
}
|
|
27361
27432
|
console.log(`Synced ${files.length} design skill(s) to ~/.claude/skills`);
|
|
27362
27433
|
}
|
|
27363
27434
|
|
|
27364
27435
|
// src/commands/sync/syncPi.ts
|
|
27365
|
-
import * as
|
|
27436
|
+
import * as path65 from "path";
|
|
27366
27437
|
|
|
27367
27438
|
// src/commands/sync/syncPiHooks.ts
|
|
27368
27439
|
import * as fs43 from "fs";
|
|
27369
|
-
import * as
|
|
27440
|
+
import * as path64 from "path";
|
|
27370
27441
|
function piExtensionsDir() {
|
|
27371
|
-
return
|
|
27442
|
+
return path64.join(harnesses.pi.homeDir, "extensions");
|
|
27372
27443
|
}
|
|
27373
27444
|
function syncPiHooks(sourceDir) {
|
|
27374
27445
|
const target = piExtensionsDir();
|
|
@@ -27376,8 +27447,8 @@ function syncPiHooks(sourceDir) {
|
|
|
27376
27447
|
const files = fs43.readdirSync(sourceDir).filter((f) => f.endsWith(".ts"));
|
|
27377
27448
|
for (const file of files) {
|
|
27378
27449
|
fs43.copyFileSync(
|
|
27379
|
-
|
|
27380
|
-
|
|
27450
|
+
path64.join(sourceDir, file),
|
|
27451
|
+
path64.join(target, `assist-${file}`)
|
|
27381
27452
|
);
|
|
27382
27453
|
}
|
|
27383
27454
|
console.log(
|
|
@@ -27414,7 +27485,7 @@ function syncPi(claudeDir) {
|
|
|
27414
27485
|
harnesses.pi,
|
|
27415
27486
|
commandToPrompt
|
|
27416
27487
|
);
|
|
27417
|
-
syncPiHooks(
|
|
27488
|
+
syncPiHooks(path65.join(claudeDir, "..", "pi"));
|
|
27418
27489
|
console.log(
|
|
27419
27490
|
`Synced ${synced} prompt(s) to ~/.pi/agent/prompts and CLAUDE.md to ~/.pi/agent/AGENTS.md`
|
|
27420
27491
|
);
|
|
@@ -27422,11 +27493,11 @@ function syncPi(claudeDir) {
|
|
|
27422
27493
|
|
|
27423
27494
|
// src/commands/sync/syncSettings.ts
|
|
27424
27495
|
import * as fs44 from "fs";
|
|
27425
|
-
import * as
|
|
27496
|
+
import * as path66 from "path";
|
|
27426
27497
|
import chalk203 from "chalk";
|
|
27427
27498
|
async function syncSettings(claudeDir, targetBase, options2) {
|
|
27428
|
-
const source =
|
|
27429
|
-
const target =
|
|
27499
|
+
const source = path66.join(claudeDir, "settings.json");
|
|
27500
|
+
const target = path66.join(targetBase, "settings.json");
|
|
27430
27501
|
const sourceContent = fs44.readFileSync(source, "utf8");
|
|
27431
27502
|
const sourceSettings = JSON.parse(sourceContent);
|
|
27432
27503
|
const targetExists = fs44.existsSync(target);
|
|
@@ -27465,12 +27536,12 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
27465
27536
|
|
|
27466
27537
|
// src/commands/sync.ts
|
|
27467
27538
|
var __filename5 = fileURLToPath9(import.meta.url);
|
|
27468
|
-
var __dirname7 =
|
|
27539
|
+
var __dirname7 = path67.dirname(__filename5);
|
|
27469
27540
|
async function sync(options2) {
|
|
27470
27541
|
const config = loadConfig();
|
|
27471
27542
|
const yes = options2?.yes ?? config.sync.autoConfirm;
|
|
27472
|
-
const claudeDir =
|
|
27473
|
-
const targetBase =
|
|
27543
|
+
const claudeDir = path67.join(__dirname7, "..", "claude");
|
|
27544
|
+
const targetBase = path67.join(os4.homedir(), ".claude");
|
|
27474
27545
|
syncCommands(claudeDir, targetBase);
|
|
27475
27546
|
syncDesign(claudeDir, targetBase);
|
|
27476
27547
|
await syncSettings(claudeDir, targetBase, { yes });
|
|
@@ -27479,20 +27550,20 @@ async function sync(options2) {
|
|
|
27479
27550
|
syncPi(claudeDir);
|
|
27480
27551
|
}
|
|
27481
27552
|
function syncCommands(claudeDir, targetBase) {
|
|
27482
|
-
const sourceDir =
|
|
27483
|
-
const targetDir =
|
|
27553
|
+
const sourceDir = path67.join(claudeDir, "commands");
|
|
27554
|
+
const targetDir = path67.join(targetBase, "commands");
|
|
27484
27555
|
fs45.mkdirSync(targetDir, { recursive: true });
|
|
27485
27556
|
const files = fs45.readdirSync(sourceDir);
|
|
27486
27557
|
for (const file of files) {
|
|
27487
|
-
fs45.copyFileSync(
|
|
27558
|
+
fs45.copyFileSync(path67.join(sourceDir, file), path67.join(targetDir, file));
|
|
27488
27559
|
console.log(`Copied ${file} to ${targetDir}`);
|
|
27489
27560
|
}
|
|
27490
27561
|
console.log(`Synced ${files.length} command(s) to ~/.claude/commands`);
|
|
27491
27562
|
}
|
|
27492
27563
|
|
|
27493
27564
|
// src/commands/update.ts
|
|
27494
|
-
import { execSync as
|
|
27495
|
-
import * as
|
|
27565
|
+
import { execSync as execSync59 } from "child_process";
|
|
27566
|
+
import * as path68 from "path";
|
|
27496
27567
|
|
|
27497
27568
|
// src/commands/restartDaemonAfterUpdate.ts
|
|
27498
27569
|
async function restartDaemonAfterUpdate() {
|
|
@@ -27511,12 +27582,12 @@ async function restartDaemonAfterUpdate() {
|
|
|
27511
27582
|
// src/commands/update.ts
|
|
27512
27583
|
function isGlobalNpmInstall(dir) {
|
|
27513
27584
|
try {
|
|
27514
|
-
const resolved =
|
|
27515
|
-
if (resolved.split(
|
|
27585
|
+
const resolved = path68.resolve(dir);
|
|
27586
|
+
if (resolved.split(path68.sep).includes("node_modules")) {
|
|
27516
27587
|
return true;
|
|
27517
27588
|
}
|
|
27518
|
-
const globalPrefix =
|
|
27519
|
-
return resolved.toLowerCase().startsWith(
|
|
27589
|
+
const globalPrefix = execSync59("npm prefix -g", { stdio: "pipe" }).toString().trim();
|
|
27590
|
+
return resolved.toLowerCase().startsWith(path68.resolve(globalPrefix).toLowerCase());
|
|
27520
27591
|
} catch {
|
|
27521
27592
|
return false;
|
|
27522
27593
|
}
|
|
@@ -27526,18 +27597,18 @@ async function update2() {
|
|
|
27526
27597
|
console.log(`Assist is installed at: ${installDir}`);
|
|
27527
27598
|
if (isGitRepo(installDir)) {
|
|
27528
27599
|
console.log("Detected git repo installation, pulling latest...");
|
|
27529
|
-
|
|
27600
|
+
execSync59("git pull", { cwd: installDir, stdio: "inherit" });
|
|
27530
27601
|
console.log("Installing dependencies...");
|
|
27531
|
-
|
|
27602
|
+
execSync59("npm i", { cwd: installDir, stdio: "inherit" });
|
|
27532
27603
|
console.log("Building...");
|
|
27533
|
-
|
|
27604
|
+
execSync59("npm run build", { cwd: installDir, stdio: "inherit" });
|
|
27534
27605
|
console.log("Syncing commands...");
|
|
27535
|
-
|
|
27606
|
+
execSync59("assist sync", { stdio: "inherit" });
|
|
27536
27607
|
} else if (isGlobalNpmInstall(installDir)) {
|
|
27537
27608
|
console.log("Detected global npm installation, updating...");
|
|
27538
|
-
|
|
27609
|
+
execSync59("npm i -g @staff0rd/assist@latest", { stdio: "inherit" });
|
|
27539
27610
|
console.log("Syncing commands...");
|
|
27540
|
-
|
|
27611
|
+
execSync59("assist sync", { stdio: "inherit" });
|
|
27541
27612
|
} else {
|
|
27542
27613
|
console.error(
|
|
27543
27614
|
"Could not determine installation method. Expected a git repo or global npm install."
|