@staff0rd/assist 0.408.1 → 0.408.2
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 +348 -316
- 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.408.
|
|
9
|
+
version: "0.408.2",
|
|
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(path70) {
|
|
146
|
+
if (!existsSync(path70)) return {};
|
|
147
147
|
try {
|
|
148
|
-
const content = readFileSync(
|
|
148
|
+
const content = readFileSync(path70, "utf8");
|
|
149
149
|
return parseYaml(content) || {};
|
|
150
150
|
} catch {
|
|
151
151
|
return {};
|
|
@@ -1437,8 +1437,8 @@ function findUnmergedPaths() {
|
|
|
1437
1437
|
}
|
|
1438
1438
|
const found = /* @__PURE__ */ new Set();
|
|
1439
1439
|
for (const line of output.split("\n")) {
|
|
1440
|
-
const
|
|
1441
|
-
if (
|
|
1440
|
+
const path70 = line.split(" ")[1];
|
|
1441
|
+
if (path70) found.add(path70.trim());
|
|
1442
1442
|
}
|
|
1443
1443
|
return [...found];
|
|
1444
1444
|
}
|
|
@@ -1537,8 +1537,8 @@ function getPreferredRemoteRepo(cwd) {
|
|
|
1537
1537
|
function gitRefUrl(kind, ref, cwd) {
|
|
1538
1538
|
const repo = getPreferredRemoteRepo(cwd);
|
|
1539
1539
|
if (!repo) return void 0;
|
|
1540
|
-
const
|
|
1541
|
-
return `https://github.com/${repo.org}/${repo.repo}/${
|
|
1540
|
+
const path70 = kind === "branch" ? "tree" : "commit";
|
|
1541
|
+
return `https://github.com/${repo.org}/${repo.repo}/${path70}/${ref}`;
|
|
1542
1542
|
}
|
|
1543
1543
|
|
|
1544
1544
|
// src/commands/commit/collectCommitRefs.ts
|
|
@@ -3405,9 +3405,9 @@ import { existsSync as existsSync12, readFileSync as readFileSync9 } from "fs";
|
|
|
3405
3405
|
|
|
3406
3406
|
// src/commands/verify/forbiddenStrings/findForbiddenStrings.ts
|
|
3407
3407
|
import { minimatch as minimatch2 } from "minimatch";
|
|
3408
|
-
function resolveStringsAtPath(data,
|
|
3408
|
+
function resolveStringsAtPath(data, path70) {
|
|
3409
3409
|
let current = data;
|
|
3410
|
-
for (const segment of
|
|
3410
|
+
for (const segment of path70.split(".")) {
|
|
3411
3411
|
if (current === null || typeof current !== "object") return [];
|
|
3412
3412
|
current = current[segment];
|
|
3413
3413
|
}
|
|
@@ -3420,10 +3420,10 @@ function resolveStringsAtPath(data, path69) {
|
|
|
3420
3420
|
}
|
|
3421
3421
|
function findRuleViolations(data, rule) {
|
|
3422
3422
|
const violations = [];
|
|
3423
|
-
for (const
|
|
3424
|
-
for (const value of resolveStringsAtPath(data,
|
|
3423
|
+
for (const path70 of rule.paths) {
|
|
3424
|
+
for (const value of resolveStringsAtPath(data, path70)) {
|
|
3425
3425
|
if (minimatch2(value, rule.disallowed))
|
|
3426
|
-
violations.push({ file: rule.file, path:
|
|
3426
|
+
violations.push({ file: rule.file, path: path70, value });
|
|
3427
3427
|
}
|
|
3428
3428
|
}
|
|
3429
3429
|
return violations;
|
|
@@ -3462,8 +3462,8 @@ function forbiddenStrings() {
|
|
|
3462
3462
|
process.exit(0);
|
|
3463
3463
|
}
|
|
3464
3464
|
console.log("Forbidden strings found:\n");
|
|
3465
|
-
for (const { file, path:
|
|
3466
|
-
console.log(` ${file} ${
|
|
3465
|
+
for (const { file, path: path70, value } of violations) {
|
|
3466
|
+
console.log(` ${file} ${path70}: ${value}`);
|
|
3467
3467
|
}
|
|
3468
3468
|
console.log(`
|
|
3469
3469
|
Total: ${violations.length} forbidden string(s).`);
|
|
@@ -3755,15 +3755,15 @@ function readBaselineMigrations(repoRelativeDir, ref) {
|
|
|
3755
3755
|
} catch {
|
|
3756
3756
|
return baseline;
|
|
3757
3757
|
}
|
|
3758
|
-
const paths = listing.split("\n").map((line) => line.trim()).filter(Boolean).filter((
|
|
3759
|
-
for (const
|
|
3758
|
+
const paths = listing.split("\n").map((line) => line.trim()).filter(Boolean).filter((path70) => MIGRATION_FILE3.test(basename(path70)));
|
|
3759
|
+
for (const path70 of paths) {
|
|
3760
3760
|
try {
|
|
3761
|
-
const content = execSync12(`git show "${ref}:${
|
|
3761
|
+
const content = execSync12(`git show "${ref}:${path70}"`, {
|
|
3762
3762
|
encoding: "utf8",
|
|
3763
3763
|
maxBuffer: 16 * 1024 * 1024,
|
|
3764
3764
|
stdio: ["pipe", "pipe", "pipe"]
|
|
3765
3765
|
});
|
|
3766
|
-
baseline.set(basename(
|
|
3766
|
+
baseline.set(basename(path70), content);
|
|
3767
3767
|
} catch {
|
|
3768
3768
|
}
|
|
3769
3769
|
}
|
|
@@ -5128,10 +5128,10 @@ var hooksSettings = {
|
|
|
5128
5128
|
}
|
|
5129
5129
|
};
|
|
5130
5130
|
function ensureHooksSettings() {
|
|
5131
|
-
const
|
|
5132
|
-
mkdirSync5(dirname12(
|
|
5133
|
-
writeFileSync15(
|
|
5134
|
-
return
|
|
5131
|
+
const path70 = daemonPaths.hooksSettings;
|
|
5132
|
+
mkdirSync5(dirname12(path70), { recursive: true });
|
|
5133
|
+
writeFileSync15(path70, JSON.stringify(hooksSettings, null, 2));
|
|
5134
|
+
return path70;
|
|
5135
5135
|
}
|
|
5136
5136
|
|
|
5137
5137
|
// src/shared/spawnInherit.ts
|
|
@@ -5396,9 +5396,9 @@ var LOCAL_FILES = ["backlog.jsonl", "backlog.db"];
|
|
|
5396
5396
|
function backupLocalBacklogFiles(dir) {
|
|
5397
5397
|
const moved = [];
|
|
5398
5398
|
for (const name of LOCAL_FILES) {
|
|
5399
|
-
const
|
|
5400
|
-
if (existsSync18(
|
|
5401
|
-
renameSync(
|
|
5399
|
+
const path70 = join15(dir, ".assist", name);
|
|
5400
|
+
if (existsSync18(path70)) {
|
|
5401
|
+
renameSync(path70, `${path70}.bak`);
|
|
5402
5402
|
moved.push(`${name} \u2192 ${name}.bak`);
|
|
5403
5403
|
}
|
|
5404
5404
|
}
|
|
@@ -5870,8 +5870,8 @@ var backlogItemSchema = z3.strictObject({
|
|
|
5870
5870
|
var backlogFileSchema = z3.array(backlogItemSchema);
|
|
5871
5871
|
|
|
5872
5872
|
// src/commands/backlog/parseBacklogJsonl.ts
|
|
5873
|
-
function parseBacklogJsonl(
|
|
5874
|
-
const content = readFileSync14(
|
|
5873
|
+
function parseBacklogJsonl(path70) {
|
|
5874
|
+
const content = readFileSync14(path70, "utf8").trim();
|
|
5875
5875
|
if (content.length === 0) return [];
|
|
5876
5876
|
return content.split("\n").map((line) => line.trim()).filter(Boolean).map((line) => backlogItemSchema.parse(JSON.parse(line)));
|
|
5877
5877
|
}
|
|
@@ -5953,8 +5953,8 @@ function findBacklogUp(startDir) {
|
|
|
5953
5953
|
|
|
5954
5954
|
// src/commands/backlog/getCurrentOrigin.ts
|
|
5955
5955
|
import { execFileSync } from "child_process";
|
|
5956
|
-
function stripLeadingSlashes(
|
|
5957
|
-
return
|
|
5956
|
+
function stripLeadingSlashes(path70) {
|
|
5957
|
+
return path70.replace(/^\/+/, "");
|
|
5958
5958
|
}
|
|
5959
5959
|
function normalizeOrigin(raw) {
|
|
5960
5960
|
const trimmed = raw.trim().replace(/\.git$/i, "").replace(/\/+$/, "");
|
|
@@ -6494,24 +6494,24 @@ function getOwnerPath(itemId2) {
|
|
|
6494
6494
|
function recordSignalOwner(itemId2) {
|
|
6495
6495
|
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
6496
6496
|
if (!sessionId) return;
|
|
6497
|
-
const
|
|
6498
|
-
mkdirSync7(dirname14(
|
|
6499
|
-
writeFileSync17(
|
|
6497
|
+
const path70 = getOwnerPath(itemId2);
|
|
6498
|
+
mkdirSync7(dirname14(path70), { recursive: true });
|
|
6499
|
+
writeFileSync17(path70, JSON.stringify({ sessionId }));
|
|
6500
6500
|
}
|
|
6501
6501
|
function readSignalOwner(itemId2) {
|
|
6502
|
-
const
|
|
6503
|
-
if (!existsSync21(
|
|
6502
|
+
const path70 = getOwnerPath(itemId2);
|
|
6503
|
+
if (!existsSync21(path70)) return void 0;
|
|
6504
6504
|
try {
|
|
6505
|
-
const parsed = JSON.parse(readFileSync15(
|
|
6505
|
+
const parsed = JSON.parse(readFileSync15(path70, "utf8"));
|
|
6506
6506
|
return parsed.sessionId;
|
|
6507
6507
|
} catch {
|
|
6508
6508
|
return void 0;
|
|
6509
6509
|
}
|
|
6510
6510
|
}
|
|
6511
6511
|
function clearSignalOwner(itemId2) {
|
|
6512
|
-
const
|
|
6512
|
+
const path70 = getOwnerPath(itemId2);
|
|
6513
6513
|
try {
|
|
6514
|
-
rmSync(
|
|
6514
|
+
rmSync(path70);
|
|
6515
6515
|
} catch {
|
|
6516
6516
|
}
|
|
6517
6517
|
}
|
|
@@ -6548,19 +6548,19 @@ function resolveSignalTarget(event, data) {
|
|
|
6548
6548
|
function writeSignal(event, data) {
|
|
6549
6549
|
const target = resolveSignalTarget(event, data);
|
|
6550
6550
|
if (!target) return;
|
|
6551
|
-
const
|
|
6552
|
-
if (!
|
|
6551
|
+
const path70 = getSignalPath(target);
|
|
6552
|
+
if (!path70) return;
|
|
6553
6553
|
const signal = { event, sessionId: target, ...data };
|
|
6554
|
-
mkdirSync8(dirname15(
|
|
6555
|
-
writeFileSync18(
|
|
6554
|
+
mkdirSync8(dirname15(path70), { recursive: true });
|
|
6555
|
+
writeFileSync18(path70, JSON.stringify(signal));
|
|
6556
6556
|
}
|
|
6557
6557
|
|
|
6558
6558
|
// src/commands/backlog/readSignal.ts
|
|
6559
6559
|
function readSignal() {
|
|
6560
|
-
const
|
|
6561
|
-
if (!
|
|
6560
|
+
const path70 = getSignalPath();
|
|
6561
|
+
if (!path70 || !existsSync22(path70)) return void 0;
|
|
6562
6562
|
try {
|
|
6563
|
-
return JSON.parse(readFileSync16(
|
|
6563
|
+
return JSON.parse(readFileSync16(path70, "utf8"));
|
|
6564
6564
|
} catch {
|
|
6565
6565
|
return void 0;
|
|
6566
6566
|
}
|
|
@@ -6693,13 +6693,13 @@ function activityPath(sessionId) {
|
|
|
6693
6693
|
function emitActivity(activity2) {
|
|
6694
6694
|
const sessionId = process.env.ASSIST_ACTIVITY_ID;
|
|
6695
6695
|
if (!sessionId) return;
|
|
6696
|
-
const
|
|
6697
|
-
mkdirSync9(dirname16(
|
|
6698
|
-
writeFileSync19(
|
|
6696
|
+
const path70 = activityPath(sessionId);
|
|
6697
|
+
mkdirSync9(dirname16(path70), { recursive: true });
|
|
6698
|
+
writeFileSync19(path70, JSON.stringify({ ...activity2, startedAt: Date.now() }));
|
|
6699
6699
|
}
|
|
6700
|
-
function readActivity(
|
|
6700
|
+
function readActivity(path70) {
|
|
6701
6701
|
try {
|
|
6702
|
-
return JSON.parse(readFileSync17(
|
|
6702
|
+
return JSON.parse(readFileSync17(path70, "utf8"));
|
|
6703
6703
|
} catch {
|
|
6704
6704
|
return void 0;
|
|
6705
6705
|
}
|
|
@@ -6709,9 +6709,9 @@ function reconcileActivity(sessionId, activity2) {
|
|
|
6709
6709
|
removeActivity(sessionId);
|
|
6710
6710
|
return;
|
|
6711
6711
|
}
|
|
6712
|
-
const
|
|
6713
|
-
mkdirSync9(dirname16(
|
|
6714
|
-
writeFileSync19(
|
|
6712
|
+
const path70 = activityPath(sessionId);
|
|
6713
|
+
mkdirSync9(dirname16(path70), { recursive: true });
|
|
6714
|
+
writeFileSync19(path70, JSON.stringify(activity2));
|
|
6715
6715
|
}
|
|
6716
6716
|
function removeActivity(sessionId) {
|
|
6717
6717
|
try {
|
|
@@ -7950,8 +7950,8 @@ async function loadItemSummaries(orm, origin) {
|
|
|
7950
7950
|
// src/commands/backlog/originDisplayName.ts
|
|
7951
7951
|
function originDisplayName(origin) {
|
|
7952
7952
|
if (origin.startsWith("local:")) {
|
|
7953
|
-
const
|
|
7954
|
-
const segments =
|
|
7953
|
+
const path70 = origin.slice("local:".length).replace(/\/+$/, "");
|
|
7954
|
+
const segments = path70.split("/").filter(Boolean);
|
|
7955
7955
|
return segments[segments.length - 1] ?? origin;
|
|
7956
7956
|
}
|
|
7957
7957
|
const firstSlash = origin.indexOf("/");
|
|
@@ -8355,7 +8355,7 @@ function findSynthesisForBranch(repoReviewsDir, branch2) {
|
|
|
8355
8355
|
const parent = dirname20(branchKeyPath);
|
|
8356
8356
|
const branchPrefix = basename5(branchKeyPath);
|
|
8357
8357
|
if (!existsSync25(parent)) return null;
|
|
8358
|
-
const synthesisFiles = readdirSync2(parent).filter((name) => name.startsWith(branchPrefix)).map((name) => join23(parent, name, "synthesis.md")).filter((
|
|
8358
|
+
const synthesisFiles = readdirSync2(parent).filter((name) => name.startsWith(branchPrefix)).map((name) => join23(parent, name, "synthesis.md")).filter((path70) => existsSync25(path70)).map((path70) => ({ path: path70, mtime: statSync2(path70).mtimeMs })).sort((a, b) => b.mtime - a.mtime);
|
|
8359
8359
|
return synthesisFiles[0]?.path ?? null;
|
|
8360
8360
|
}
|
|
8361
8361
|
|
|
@@ -8409,12 +8409,12 @@ async function getReviewSynthesis(req, res) {
|
|
|
8409
8409
|
const cwd = getCwdParam(req, res);
|
|
8410
8410
|
if (!cwd) return;
|
|
8411
8411
|
try {
|
|
8412
|
-
const
|
|
8413
|
-
if (!
|
|
8412
|
+
const path70 = await resolveSynthesisPath(cwd);
|
|
8413
|
+
if (!path70) {
|
|
8414
8414
|
respondJson(res, 404, { error: "No synthesis found" });
|
|
8415
8415
|
return;
|
|
8416
8416
|
}
|
|
8417
|
-
respondJson(res, 200, { synthesis: readFileSync19(
|
|
8417
|
+
respondJson(res, 200, { synthesis: readFileSync19(path70, "utf8") });
|
|
8418
8418
|
} catch {
|
|
8419
8419
|
respondJson(res, 404, { error: "No synthesis found" });
|
|
8420
8420
|
}
|
|
@@ -8561,10 +8561,10 @@ function getStorePath(filename) {
|
|
|
8561
8561
|
return join26(getStoreDir(), filename);
|
|
8562
8562
|
}
|
|
8563
8563
|
function loadJson(filename) {
|
|
8564
|
-
const
|
|
8565
|
-
if (existsSync26(
|
|
8564
|
+
const path70 = getStorePath(filename);
|
|
8565
|
+
if (existsSync26(path70)) {
|
|
8566
8566
|
try {
|
|
8567
|
-
return JSON.parse(readFileSync20(
|
|
8567
|
+
return JSON.parse(readFileSync20(path70, "utf8"));
|
|
8568
8568
|
} catch {
|
|
8569
8569
|
return {};
|
|
8570
8570
|
}
|
|
@@ -11915,9 +11915,9 @@ var __dirname4 = dirname21(__filename3);
|
|
|
11915
11915
|
function packageRoot() {
|
|
11916
11916
|
return __dirname4;
|
|
11917
11917
|
}
|
|
11918
|
-
function readLines(
|
|
11919
|
-
if (!existsSync27(
|
|
11920
|
-
return readFileSync23(
|
|
11918
|
+
function readLines(path70) {
|
|
11919
|
+
if (!existsSync27(path70)) return [];
|
|
11920
|
+
return readFileSync23(path70, "utf8").split("\n").filter((line) => line.trim() !== "");
|
|
11921
11921
|
}
|
|
11922
11922
|
var cachedReads;
|
|
11923
11923
|
var cachedWrites;
|
|
@@ -12409,14 +12409,14 @@ function showProgress(p, label2) {
|
|
|
12409
12409
|
const pct = Math.round(p.done / p.total * 100);
|
|
12410
12410
|
process.stderr.write(`\r\x1B[K[${pct}%] Scanning ${label2}...`);
|
|
12411
12411
|
}
|
|
12412
|
-
async function resolveCommand(cli,
|
|
12413
|
-
showProgress(p,
|
|
12414
|
-
const subHelp = await runHelp([cli, ...
|
|
12412
|
+
async function resolveCommand(cli, path70, description, depth, p) {
|
|
12413
|
+
showProgress(p, path70.join(" "));
|
|
12414
|
+
const subHelp = await runHelp([cli, ...path70]);
|
|
12415
12415
|
if (!subHelp || !hasSubcommands(subHelp)) {
|
|
12416
|
-
return [{ path:
|
|
12416
|
+
return [{ path: path70, description }];
|
|
12417
12417
|
}
|
|
12418
|
-
const children = await discoverAt(cli,
|
|
12419
|
-
return children.length > 0 ? children : [{ path:
|
|
12418
|
+
const children = await discoverAt(cli, path70, depth + 1, p);
|
|
12419
|
+
return children.length > 0 ? children : [{ path: path70, description }];
|
|
12420
12420
|
}
|
|
12421
12421
|
async function discoverAt(cli, parentPath, depth, p) {
|
|
12422
12422
|
if (depth > SAFETY_DEPTH) return [];
|
|
@@ -12564,9 +12564,9 @@ function logPath(cli) {
|
|
|
12564
12564
|
return join30(homedir16(), ".assist", `cli-discover-${safeName}.log`);
|
|
12565
12565
|
}
|
|
12566
12566
|
function readCache(cli) {
|
|
12567
|
-
const
|
|
12568
|
-
if (!existsSync29(
|
|
12569
|
-
return readFileSync25(
|
|
12567
|
+
const path70 = logPath(cli);
|
|
12568
|
+
if (!existsSync29(path70)) return void 0;
|
|
12569
|
+
return readFileSync25(path70, "utf8");
|
|
12570
12570
|
}
|
|
12571
12571
|
function writeCache(cli, output) {
|
|
12572
12572
|
const dir = join30(homedir16(), ".assist");
|
|
@@ -12738,9 +12738,9 @@ function sweepRestrictedDir(dir = getRestrictedDir()) {
|
|
|
12738
12738
|
}
|
|
12739
12739
|
const cutoff = Date.now() - STALE_AFTER_MS;
|
|
12740
12740
|
for (const entry of entries) {
|
|
12741
|
-
const
|
|
12741
|
+
const path70 = join32(dir, entry);
|
|
12742
12742
|
try {
|
|
12743
|
-
if (statSync3(
|
|
12743
|
+
if (statSync3(path70).mtimeMs < cutoff) unlinkSync7(path70);
|
|
12744
12744
|
} catch {
|
|
12745
12745
|
continue;
|
|
12746
12746
|
}
|
|
@@ -12750,10 +12750,10 @@ function sweepRestrictedDir(dir = getRestrictedDir()) {
|
|
|
12750
12750
|
// src/commands/codeComment/readPinState.ts
|
|
12751
12751
|
import { existsSync as existsSync30, readFileSync as readFileSync26 } from "fs";
|
|
12752
12752
|
function readPinState(pin) {
|
|
12753
|
-
const
|
|
12754
|
-
if (!existsSync30(
|
|
12753
|
+
const path70 = getPinStatePath(pin);
|
|
12754
|
+
if (!existsSync30(path70)) return void 0;
|
|
12755
12755
|
try {
|
|
12756
|
-
const state = JSON.parse(readFileSync26(
|
|
12756
|
+
const state = JSON.parse(readFileSync26(path70, "utf8"));
|
|
12757
12757
|
if (state.pin !== pin) return void 0;
|
|
12758
12758
|
return state;
|
|
12759
12759
|
} catch {
|
|
@@ -13649,8 +13649,8 @@ function stepIntoNested(container, key, nextKey) {
|
|
|
13649
13649
|
}
|
|
13650
13650
|
return ensureObject(container, resolved);
|
|
13651
13651
|
}
|
|
13652
|
-
function setNestedValue(obj,
|
|
13653
|
-
const keys =
|
|
13652
|
+
function setNestedValue(obj, path70, value) {
|
|
13653
|
+
const keys = path70.split(".");
|
|
13654
13654
|
const result = { ...obj };
|
|
13655
13655
|
let current = result;
|
|
13656
13656
|
for (let i = 0; i < keys.length - 1; i++) {
|
|
@@ -13730,9 +13730,9 @@ function isTraversable(value) {
|
|
|
13730
13730
|
function stepInto(current, key) {
|
|
13731
13731
|
return isTraversable(current) ? current[key] : void 0;
|
|
13732
13732
|
}
|
|
13733
|
-
function getNestedValue(obj,
|
|
13733
|
+
function getNestedValue(obj, path70) {
|
|
13734
13734
|
let current = obj;
|
|
13735
|
-
for (const key of
|
|
13735
|
+
for (const key of path70.split(".")) current = stepInto(current, key);
|
|
13736
13736
|
return current;
|
|
13737
13737
|
}
|
|
13738
13738
|
|
|
@@ -13848,10 +13848,10 @@ function getMigrationApprovalPath(migrationId) {
|
|
|
13848
13848
|
// src/commands/dbMigration/readMigrationPinState.ts
|
|
13849
13849
|
import { existsSync as existsSync32, readFileSync as readFileSync28 } from "fs";
|
|
13850
13850
|
function readMigrationPinState(pin) {
|
|
13851
|
-
const
|
|
13852
|
-
if (!existsSync32(
|
|
13851
|
+
const path70 = getMigrationPinPath(pin);
|
|
13852
|
+
if (!existsSync32(path70)) return void 0;
|
|
13853
13853
|
try {
|
|
13854
|
-
const state = JSON.parse(readFileSync28(
|
|
13854
|
+
const state = JSON.parse(readFileSync28(path70, "utf8"));
|
|
13855
13855
|
if (state.pin !== pin) return void 0;
|
|
13856
13856
|
if (!Number.isInteger(state.migrationId)) return void 0;
|
|
13857
13857
|
return state;
|
|
@@ -15290,10 +15290,10 @@ function decideCommentGuard(input, existingContent) {
|
|
|
15290
15290
|
import { existsSync as existsSync39, unlinkSync as unlinkSync11 } from "fs";
|
|
15291
15291
|
function consumeMigrationApproval(migrationId) {
|
|
15292
15292
|
sweepRestrictedDir();
|
|
15293
|
-
const
|
|
15294
|
-
if (!existsSync39(
|
|
15293
|
+
const path70 = getMigrationApprovalPath(migrationId);
|
|
15294
|
+
if (!existsSync39(path70)) return false;
|
|
15295
15295
|
try {
|
|
15296
|
-
unlinkSync11(
|
|
15296
|
+
unlinkSync11(path70);
|
|
15297
15297
|
return true;
|
|
15298
15298
|
} catch {
|
|
15299
15299
|
return false;
|
|
@@ -16467,9 +16467,9 @@ function parseRscRows(flight) {
|
|
|
16467
16467
|
}
|
|
16468
16468
|
function makeRscResolver(rows) {
|
|
16469
16469
|
return (ref) => {
|
|
16470
|
-
const [id, ...
|
|
16470
|
+
const [id, ...path70] = ref.slice(1).replace(/^[L@]/, "").split(":");
|
|
16471
16471
|
let v = rows[id];
|
|
16472
|
-
for (const key of
|
|
16472
|
+
for (const key of path70) {
|
|
16473
16473
|
if (v == null || typeof v !== "object") return void 0;
|
|
16474
16474
|
v = v[key];
|
|
16475
16475
|
}
|
|
@@ -17153,15 +17153,15 @@ function postComment(vars) {
|
|
|
17153
17153
|
const stdout = startLine === void 0 ? runGhGraphql(MUTATION_SINGLE, base) : runGhGraphql(MUTATION_MULTI, { ...base, startLine });
|
|
17154
17154
|
assertThreadCreated(stdout);
|
|
17155
17155
|
}
|
|
17156
|
-
function comment2(
|
|
17156
|
+
function comment2(path70, line, body, startLine) {
|
|
17157
17157
|
validateBody(body);
|
|
17158
17158
|
validateLine(line);
|
|
17159
17159
|
if (startLine !== void 0) validateLine(startLine);
|
|
17160
17160
|
try {
|
|
17161
17161
|
const prId = getCurrentPrNodeId();
|
|
17162
|
-
postComment({ prId, body, path:
|
|
17162
|
+
postComment({ prId, body, path: path70, line, startLine });
|
|
17163
17163
|
const range = startLine !== void 0 ? `${startLine}-${line}` : `${line}`;
|
|
17164
|
-
console.log(`Added review comment on ${
|
|
17164
|
+
console.log(`Added review comment on ${path70}:${range}`);
|
|
17165
17165
|
} catch (error) {
|
|
17166
17166
|
if (isGhNotInstalled(error)) {
|
|
17167
17167
|
console.error("Error: GitHub CLI (gh) is not installed.");
|
|
@@ -18040,8 +18040,8 @@ function registerPrs(program2) {
|
|
|
18040
18040
|
prsCommand.command("reply <comment-id> <body>").description("Reply to a comment thread without resolving it").action((commentId, body) => {
|
|
18041
18041
|
reply(Number.parseInt(commentId, 10), body);
|
|
18042
18042
|
});
|
|
18043
|
-
prsCommand.command("comment <path> <line> <body>").description("Add a line comment to the pending review").action((
|
|
18044
|
-
comment2(
|
|
18043
|
+
prsCommand.command("comment <path> <line> <body>").description("Add a line comment to the pending review").action((path70, line, body) => {
|
|
18044
|
+
comment2(path70, Number.parseInt(line, 10), body);
|
|
18045
18045
|
});
|
|
18046
18046
|
configHelp(prsCommand, prsConfigHelp);
|
|
18047
18047
|
}
|
|
@@ -18294,10 +18294,10 @@ function resolveOpSecret(reference) {
|
|
|
18294
18294
|
}
|
|
18295
18295
|
|
|
18296
18296
|
// src/commands/ravendb/ravenFetch.ts
|
|
18297
|
-
async function ravenFetch(connection,
|
|
18297
|
+
async function ravenFetch(connection, path70) {
|
|
18298
18298
|
const apiKey = resolveOpSecret(connection.apiKeyRef);
|
|
18299
18299
|
let accessToken = await getAccessToken(apiKey);
|
|
18300
|
-
const url = `${connection.url}${
|
|
18300
|
+
const url = `${connection.url}${path70}`;
|
|
18301
18301
|
const headers = {
|
|
18302
18302
|
Authorization: `Bearer ${accessToken}`,
|
|
18303
18303
|
"Content-Type": "application/json"
|
|
@@ -18401,16 +18401,16 @@ import chalk169 from "chalk";
|
|
|
18401
18401
|
// src/commands/ravendb/buildQueryPath.ts
|
|
18402
18402
|
function buildQueryPath(opts) {
|
|
18403
18403
|
const db = encodeURIComponent(opts.db);
|
|
18404
|
-
let
|
|
18404
|
+
let path70;
|
|
18405
18405
|
if (opts.collection) {
|
|
18406
|
-
|
|
18406
|
+
path70 = `/databases/${db}/indexes/dynamic/${encodeURIComponent(opts.collection)}?start=${opts.start}&pageSize=${opts.pageSize}&sort=${encodeURIComponent(opts.sort)}`;
|
|
18407
18407
|
} else {
|
|
18408
|
-
|
|
18408
|
+
path70 = `/databases/${db}/queries?start=${opts.start}&pageSize=${opts.pageSize}`;
|
|
18409
18409
|
}
|
|
18410
18410
|
if (opts.query) {
|
|
18411
|
-
|
|
18411
|
+
path70 += `&query=${encodeURIComponent(opts.query)}`;
|
|
18412
18412
|
}
|
|
18413
|
-
return
|
|
18413
|
+
return path70;
|
|
18414
18414
|
}
|
|
18415
18415
|
|
|
18416
18416
|
// src/commands/ravendb/fetchAllPages.ts
|
|
@@ -18419,7 +18419,7 @@ async function fetchAllPages(connection, opts) {
|
|
|
18419
18419
|
let start3 = 0;
|
|
18420
18420
|
while (true) {
|
|
18421
18421
|
const effectivePageSize = opts.limit !== void 0 ? Math.min(opts.pageSize, opts.limit - allResults.length) : opts.pageSize;
|
|
18422
|
-
const
|
|
18422
|
+
const path70 = buildQueryPath({
|
|
18423
18423
|
db: connection.database,
|
|
18424
18424
|
collection: opts.collection,
|
|
18425
18425
|
start: start3,
|
|
@@ -18427,7 +18427,7 @@ async function fetchAllPages(connection, opts) {
|
|
|
18427
18427
|
sort: opts.sort,
|
|
18428
18428
|
query: opts.query
|
|
18429
18429
|
});
|
|
18430
|
-
const data = await ravenFetch(connection,
|
|
18430
|
+
const data = await ravenFetch(connection, path70);
|
|
18431
18431
|
const results = data.Results ?? [];
|
|
18432
18432
|
const totalResults = data.TotalResults ?? 0;
|
|
18433
18433
|
if (results.length === 0) break;
|
|
@@ -18688,7 +18688,7 @@ async function check(pattern2, options2) {
|
|
|
18688
18688
|
}
|
|
18689
18689
|
|
|
18690
18690
|
// src/commands/refactor/extract/index.ts
|
|
18691
|
-
import
|
|
18691
|
+
import path44 from "path";
|
|
18692
18692
|
import chalk174 from "chalk";
|
|
18693
18693
|
|
|
18694
18694
|
// src/commands/refactor/extract/applyExtraction.ts
|
|
@@ -19337,35 +19337,75 @@ function displayPlan(functionName, relDest, plan2, cwd) {
|
|
|
19337
19337
|
}
|
|
19338
19338
|
|
|
19339
19339
|
// src/commands/refactor/extract/loadProjectFile.ts
|
|
19340
|
-
import
|
|
19340
|
+
import path43 from "path";
|
|
19341
19341
|
import chalk173 from "chalk";
|
|
19342
19342
|
import { Project as Project4 } from "ts-morph";
|
|
19343
19343
|
|
|
19344
19344
|
// src/commands/refactor/extract/findTsConfig.ts
|
|
19345
|
+
import fs27 from "fs";
|
|
19346
|
+
import path42 from "path";
|
|
19347
|
+
|
|
19348
|
+
// src/commands/refactor/extract/findEnclosingTsConfig.ts
|
|
19345
19349
|
import fs26 from "fs";
|
|
19346
19350
|
import path41 from "path";
|
|
19351
|
+
|
|
19352
|
+
// src/commands/refactor/extract/projectIncludesFile.ts
|
|
19347
19353
|
import { Project as Project3 } from "ts-morph";
|
|
19354
|
+
function projectIncludesFile(configPath, sourcePath) {
|
|
19355
|
+
try {
|
|
19356
|
+
const project = new Project3({ tsConfigFilePath: configPath });
|
|
19357
|
+
return !!project.getSourceFile(sourcePath);
|
|
19358
|
+
} catch {
|
|
19359
|
+
return false;
|
|
19360
|
+
}
|
|
19361
|
+
}
|
|
19362
|
+
|
|
19363
|
+
// src/commands/refactor/extract/findEnclosingTsConfig.ts
|
|
19364
|
+
function findEnclosingTsConfig(sourcePath, rootDir, tried) {
|
|
19365
|
+
let dir = path41.dirname(sourcePath);
|
|
19366
|
+
while (dir.startsWith(rootDir + path41.sep) && dir !== rootDir) {
|
|
19367
|
+
const nested = path41.join(dir, "tsconfig.json");
|
|
19368
|
+
if (!tried.has(nested)) {
|
|
19369
|
+
tried.add(nested);
|
|
19370
|
+
if (fs26.existsSync(nested) && projectIncludesFile(nested, sourcePath)) {
|
|
19371
|
+
return nested;
|
|
19372
|
+
}
|
|
19373
|
+
}
|
|
19374
|
+
const parent = path41.dirname(dir);
|
|
19375
|
+
if (parent === dir) break;
|
|
19376
|
+
dir = parent;
|
|
19377
|
+
}
|
|
19378
|
+
return void 0;
|
|
19379
|
+
}
|
|
19380
|
+
|
|
19381
|
+
// src/commands/refactor/extract/findTsConfig.ts
|
|
19348
19382
|
function findTsConfig(sourcePath) {
|
|
19349
|
-
const rootConfig =
|
|
19350
|
-
if (!
|
|
19383
|
+
const rootConfig = path42.resolve("tsconfig.json");
|
|
19384
|
+
if (!fs27.existsSync(rootConfig)) return rootConfig;
|
|
19351
19385
|
const tried = /* @__PURE__ */ new Set();
|
|
19352
19386
|
const candidates = [rootConfig, ...readReferences(rootConfig)];
|
|
19353
19387
|
for (const candidate of candidates) {
|
|
19354
19388
|
if (tried.has(candidate)) continue;
|
|
19355
19389
|
tried.add(candidate);
|
|
19356
|
-
if (
|
|
19390
|
+
if (projectIncludesFile(candidate, sourcePath)) return candidate;
|
|
19357
19391
|
}
|
|
19358
|
-
const siblings =
|
|
19392
|
+
const siblings = fs27.readdirSync(path42.dirname(rootConfig)).filter((f) => /^tsconfig.*\.json$/.test(f)).map((f) => path42.resolve(path42.dirname(rootConfig), f));
|
|
19359
19393
|
for (const sibling of siblings) {
|
|
19360
19394
|
if (tried.has(sibling)) continue;
|
|
19361
19395
|
tried.add(sibling);
|
|
19362
|
-
if (
|
|
19396
|
+
if (projectIncludesFile(sibling, sourcePath)) return sibling;
|
|
19363
19397
|
}
|
|
19398
|
+
const nested = findEnclosingTsConfig(
|
|
19399
|
+
sourcePath,
|
|
19400
|
+
path42.dirname(rootConfig),
|
|
19401
|
+
tried
|
|
19402
|
+
);
|
|
19403
|
+
if (nested) return nested;
|
|
19364
19404
|
return rootConfig;
|
|
19365
19405
|
}
|
|
19366
19406
|
function readReferences(configPath) {
|
|
19367
|
-
if (!
|
|
19368
|
-
const raw =
|
|
19407
|
+
if (!fs27.existsSync(configPath)) return [];
|
|
19408
|
+
const raw = fs27.readFileSync(configPath, "utf8");
|
|
19369
19409
|
const stripped = raw.replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "");
|
|
19370
19410
|
let parsed;
|
|
19371
19411
|
try {
|
|
@@ -19374,24 +19414,16 @@ function readReferences(configPath) {
|
|
|
19374
19414
|
return [];
|
|
19375
19415
|
}
|
|
19376
19416
|
if (!parsed.references?.length) return [];
|
|
19377
|
-
const cwd =
|
|
19417
|
+
const cwd = path42.dirname(configPath);
|
|
19378
19418
|
return parsed.references.map((ref) => {
|
|
19379
|
-
const refPath =
|
|
19380
|
-
return
|
|
19381
|
-
}).filter((p) =>
|
|
19382
|
-
}
|
|
19383
|
-
function projectIncludes(configPath, sourcePath) {
|
|
19384
|
-
try {
|
|
19385
|
-
const project = new Project3({ tsConfigFilePath: configPath });
|
|
19386
|
-
return !!project.getSourceFile(sourcePath);
|
|
19387
|
-
} catch {
|
|
19388
|
-
return false;
|
|
19389
|
-
}
|
|
19419
|
+
const refPath = path42.resolve(cwd, ref.path);
|
|
19420
|
+
return fs27.statSync(refPath, { throwIfNoEntry: false })?.isDirectory() ? path42.join(refPath, "tsconfig.json") : refPath;
|
|
19421
|
+
}).filter((p) => fs27.existsSync(p));
|
|
19390
19422
|
}
|
|
19391
19423
|
|
|
19392
19424
|
// src/commands/refactor/extract/loadProjectFile.ts
|
|
19393
19425
|
function loadProjectFile(file) {
|
|
19394
|
-
const sourcePath =
|
|
19426
|
+
const sourcePath = path43.resolve(file);
|
|
19395
19427
|
const tsConfigPath = findTsConfig(sourcePath);
|
|
19396
19428
|
const project = new Project4({
|
|
19397
19429
|
tsConfigFilePath: tsConfigPath
|
|
@@ -19406,10 +19438,10 @@ function loadProjectFile(file) {
|
|
|
19406
19438
|
|
|
19407
19439
|
// src/commands/refactor/extract/index.ts
|
|
19408
19440
|
async function extract(file, functionName, destination, options2 = {}) {
|
|
19409
|
-
const sourcePath =
|
|
19410
|
-
const destPath =
|
|
19441
|
+
const sourcePath = path44.resolve(file);
|
|
19442
|
+
const destPath = path44.resolve(destination);
|
|
19411
19443
|
const cwd = process.cwd();
|
|
19412
|
-
const relDest =
|
|
19444
|
+
const relDest = path44.relative(cwd, destPath);
|
|
19413
19445
|
const { project, sourceFile } = loadProjectFile(file);
|
|
19414
19446
|
const plan2 = buildPlan2(
|
|
19415
19447
|
functionName,
|
|
@@ -19428,25 +19460,25 @@ async function extract(file, functionName, destination, options2 = {}) {
|
|
|
19428
19460
|
}
|
|
19429
19461
|
|
|
19430
19462
|
// src/commands/refactor/ignore.ts
|
|
19431
|
-
import
|
|
19463
|
+
import fs28 from "fs";
|
|
19432
19464
|
import chalk175 from "chalk";
|
|
19433
19465
|
var REFACTOR_YML_PATH2 = "refactor.yml";
|
|
19434
19466
|
function ignore2(file) {
|
|
19435
|
-
if (!
|
|
19467
|
+
if (!fs28.existsSync(file)) {
|
|
19436
19468
|
console.error(chalk175.red(`Error: File does not exist: ${file}`));
|
|
19437
19469
|
process.exit(1);
|
|
19438
19470
|
}
|
|
19439
|
-
const content =
|
|
19471
|
+
const content = fs28.readFileSync(file, "utf8");
|
|
19440
19472
|
const lineCount = content.split("\n").length;
|
|
19441
19473
|
const maxLines = lineCount + 10;
|
|
19442
19474
|
const entry = `- file: ${file}
|
|
19443
19475
|
maxLines: ${maxLines}
|
|
19444
19476
|
`;
|
|
19445
|
-
if (
|
|
19446
|
-
const existing =
|
|
19447
|
-
|
|
19477
|
+
if (fs28.existsSync(REFACTOR_YML_PATH2)) {
|
|
19478
|
+
const existing = fs28.readFileSync(REFACTOR_YML_PATH2, "utf8");
|
|
19479
|
+
fs28.writeFileSync(REFACTOR_YML_PATH2, existing + entry);
|
|
19448
19480
|
} else {
|
|
19449
|
-
|
|
19481
|
+
fs28.writeFileSync(REFACTOR_YML_PATH2, entry);
|
|
19450
19482
|
}
|
|
19451
19483
|
console.log(
|
|
19452
19484
|
chalk175.green(
|
|
@@ -19456,20 +19488,20 @@ function ignore2(file) {
|
|
|
19456
19488
|
}
|
|
19457
19489
|
|
|
19458
19490
|
// src/commands/refactor/rename/index.ts
|
|
19459
|
-
import
|
|
19460
|
-
import
|
|
19491
|
+
import fs31 from "fs";
|
|
19492
|
+
import path49 from "path";
|
|
19461
19493
|
import chalk178 from "chalk";
|
|
19462
19494
|
|
|
19463
19495
|
// src/commands/refactor/rename/applyRename.ts
|
|
19464
|
-
import
|
|
19465
|
-
import
|
|
19496
|
+
import fs30 from "fs";
|
|
19497
|
+
import path46 from "path";
|
|
19466
19498
|
import chalk176 from "chalk";
|
|
19467
19499
|
|
|
19468
19500
|
// src/commands/refactor/restructure/computeRewrites/index.ts
|
|
19469
|
-
import
|
|
19501
|
+
import path45 from "path";
|
|
19470
19502
|
|
|
19471
19503
|
// src/commands/refactor/restructure/computeRewrites/applyRewrites.ts
|
|
19472
|
-
import
|
|
19504
|
+
import fs29 from "fs";
|
|
19473
19505
|
function getOrCreateList(map, key) {
|
|
19474
19506
|
const list5 = map.get(key) ?? [];
|
|
19475
19507
|
if (!map.has(key)) map.set(key, list5);
|
|
@@ -19488,7 +19520,7 @@ function rewriteSpecifier(content, oldSpecifier, newSpecifier) {
|
|
|
19488
19520
|
return content.replace(pattern2, `$1${newSpecifier}$2`);
|
|
19489
19521
|
}
|
|
19490
19522
|
function applyFileRewrites(file, fileRewrites) {
|
|
19491
|
-
let content =
|
|
19523
|
+
let content = fs29.readFileSync(file, "utf8");
|
|
19492
19524
|
for (const { oldSpecifier, newSpecifier } of fileRewrites) {
|
|
19493
19525
|
content = rewriteSpecifier(content, oldSpecifier, newSpecifier);
|
|
19494
19526
|
}
|
|
@@ -19520,7 +19552,7 @@ function normalizeSpecifier(rel) {
|
|
|
19520
19552
|
);
|
|
19521
19553
|
}
|
|
19522
19554
|
function computeSpecifier(fromFile, toFile) {
|
|
19523
|
-
return normalizeSpecifier(
|
|
19555
|
+
return normalizeSpecifier(path45.relative(path45.dirname(fromFile), toFile));
|
|
19524
19556
|
}
|
|
19525
19557
|
function isAffected(edge, moveMap) {
|
|
19526
19558
|
return moveMap.has(edge.target) || moveMap.has(edge.source);
|
|
@@ -19567,21 +19599,21 @@ function computeRewrites(moves, edges, allProjectFiles) {
|
|
|
19567
19599
|
function applyRename(rewrites, sourcePath, destPath, cwd) {
|
|
19568
19600
|
const updatedContents = applyRewrites(rewrites);
|
|
19569
19601
|
for (const [file, content] of updatedContents) {
|
|
19570
|
-
|
|
19571
|
-
console.log(chalk176.cyan(` Updated imports in ${
|
|
19602
|
+
fs30.writeFileSync(file, content, "utf8");
|
|
19603
|
+
console.log(chalk176.cyan(` Updated imports in ${path46.relative(cwd, file)}`));
|
|
19572
19604
|
}
|
|
19573
|
-
const destDir =
|
|
19574
|
-
if (!
|
|
19575
|
-
|
|
19605
|
+
const destDir = path46.dirname(destPath);
|
|
19606
|
+
if (!fs30.existsSync(destDir)) fs30.mkdirSync(destDir, { recursive: true });
|
|
19607
|
+
fs30.renameSync(sourcePath, destPath);
|
|
19576
19608
|
console.log(
|
|
19577
19609
|
chalk176.white(
|
|
19578
|
-
` Moved ${
|
|
19610
|
+
` Moved ${path46.relative(cwd, sourcePath)} \u2192 ${path46.relative(cwd, destPath)}`
|
|
19579
19611
|
)
|
|
19580
19612
|
);
|
|
19581
19613
|
}
|
|
19582
19614
|
|
|
19583
19615
|
// src/commands/refactor/restructure/buildImportGraph/index.ts
|
|
19584
|
-
import
|
|
19616
|
+
import path47 from "path";
|
|
19585
19617
|
import ts7 from "typescript";
|
|
19586
19618
|
|
|
19587
19619
|
// src/commands/refactor/restructure/buildImportGraph/getImportSpecifiers.ts
|
|
@@ -19608,7 +19640,7 @@ function loadParsedConfig(tsConfigPath) {
|
|
|
19608
19640
|
return ts7.parseJsonConfigFileContent(
|
|
19609
19641
|
configFile.config,
|
|
19610
19642
|
ts7.sys,
|
|
19611
|
-
|
|
19643
|
+
path47.dirname(tsConfigPath)
|
|
19612
19644
|
);
|
|
19613
19645
|
}
|
|
19614
19646
|
function addToSetMap(map, key, value) {
|
|
@@ -19624,7 +19656,7 @@ function resolveImport(specifier, filePath, options2) {
|
|
|
19624
19656
|
const resolved = ts7.resolveModuleName(specifier, filePath, options2, ts7.sys);
|
|
19625
19657
|
const resolvedPath = resolved.resolvedModule?.resolvedFileName;
|
|
19626
19658
|
if (!resolvedPath || resolvedPath.includes("node_modules")) return null;
|
|
19627
|
-
return
|
|
19659
|
+
return path47.resolve(resolvedPath);
|
|
19628
19660
|
}
|
|
19629
19661
|
function buildImportGraph(candidateFiles, tsConfigPath) {
|
|
19630
19662
|
const parsed = loadParsedConfig(tsConfigPath);
|
|
@@ -19633,7 +19665,7 @@ function buildImportGraph(candidateFiles, tsConfigPath) {
|
|
|
19633
19665
|
const importedBy = /* @__PURE__ */ new Map();
|
|
19634
19666
|
const imports = /* @__PURE__ */ new Map();
|
|
19635
19667
|
for (const sourceFile of program2.getSourceFiles()) {
|
|
19636
|
-
const filePath =
|
|
19668
|
+
const filePath = path47.resolve(sourceFile.fileName);
|
|
19637
19669
|
if (filePath.includes("node_modules")) continue;
|
|
19638
19670
|
for (const specifier of getImportSpecifiers(sourceFile)) {
|
|
19639
19671
|
const absTarget = resolveImport(specifier, filePath, parsed.options);
|
|
@@ -19660,13 +19692,13 @@ function computeRenameRewrites(sourcePath, destPath) {
|
|
|
19660
19692
|
}
|
|
19661
19693
|
|
|
19662
19694
|
// src/commands/refactor/rename/printRenamePreview.ts
|
|
19663
|
-
import
|
|
19695
|
+
import path48 from "path";
|
|
19664
19696
|
import chalk177 from "chalk";
|
|
19665
19697
|
function printRenamePreview(rewrites, cwd) {
|
|
19666
19698
|
for (const rewrite of rewrites) {
|
|
19667
19699
|
console.log(
|
|
19668
19700
|
chalk177.dim(
|
|
19669
|
-
` ${
|
|
19701
|
+
` ${path48.relative(cwd, rewrite.file)}: ${rewrite.oldSpecifier} \u2192 ${rewrite.newSpecifier}`
|
|
19670
19702
|
)
|
|
19671
19703
|
);
|
|
19672
19704
|
}
|
|
@@ -19675,16 +19707,16 @@ function printRenamePreview(rewrites, cwd) {
|
|
|
19675
19707
|
|
|
19676
19708
|
// src/commands/refactor/rename/index.ts
|
|
19677
19709
|
async function rename(source, destination, options2 = {}) {
|
|
19678
|
-
const sourcePath =
|
|
19679
|
-
const destPath =
|
|
19710
|
+
const sourcePath = path49.resolve(source);
|
|
19711
|
+
const destPath = path49.resolve(destination);
|
|
19680
19712
|
const cwd = process.cwd();
|
|
19681
|
-
const relSource =
|
|
19682
|
-
const relDest =
|
|
19683
|
-
if (!
|
|
19713
|
+
const relSource = path49.relative(cwd, sourcePath);
|
|
19714
|
+
const relDest = path49.relative(cwd, destPath);
|
|
19715
|
+
if (!fs31.existsSync(sourcePath)) {
|
|
19684
19716
|
console.log(chalk178.red(`File not found: ${source}`));
|
|
19685
19717
|
process.exit(1);
|
|
19686
19718
|
}
|
|
19687
|
-
if (destPath !== sourcePath &&
|
|
19719
|
+
if (destPath !== sourcePath && fs31.existsSync(destPath)) {
|
|
19688
19720
|
console.log(chalk178.red(`Destination already exists: ${destination}`));
|
|
19689
19721
|
process.exit(1);
|
|
19690
19722
|
}
|
|
@@ -19734,12 +19766,12 @@ function findSymbol(sourceFile, symbolName) {
|
|
|
19734
19766
|
}
|
|
19735
19767
|
|
|
19736
19768
|
// src/commands/refactor/renameSymbol/groupReferences.ts
|
|
19737
|
-
import
|
|
19769
|
+
import path50 from "path";
|
|
19738
19770
|
function groupReferences(symbol, cwd) {
|
|
19739
19771
|
const refs = symbol.findReferencesAsNodes();
|
|
19740
19772
|
const grouped = /* @__PURE__ */ new Map();
|
|
19741
19773
|
for (const ref of refs) {
|
|
19742
|
-
const refFile =
|
|
19774
|
+
const refFile = path50.relative(cwd, ref.getSourceFile().getFilePath());
|
|
19743
19775
|
const lines = grouped.get(refFile) ?? [];
|
|
19744
19776
|
if (!grouped.has(refFile)) grouped.set(refFile, lines);
|
|
19745
19777
|
lines.push(ref.getStartLineNumber());
|
|
@@ -19778,16 +19810,16 @@ Renamed ${oldName} \u2192 ${newName}`));
|
|
|
19778
19810
|
}
|
|
19779
19811
|
|
|
19780
19812
|
// src/commands/refactor/restructure/index.ts
|
|
19781
|
-
import
|
|
19813
|
+
import path57 from "path";
|
|
19782
19814
|
import chalk182 from "chalk";
|
|
19783
19815
|
|
|
19784
19816
|
// src/commands/refactor/restructure/clusterDirectories.ts
|
|
19785
|
-
import
|
|
19817
|
+
import path51 from "path";
|
|
19786
19818
|
function clusterDirectories(graph) {
|
|
19787
19819
|
const dirImportedBy = /* @__PURE__ */ new Map();
|
|
19788
19820
|
for (const edge of graph.edges) {
|
|
19789
|
-
const sourceDir =
|
|
19790
|
-
const targetDir =
|
|
19821
|
+
const sourceDir = path51.dirname(edge.source);
|
|
19822
|
+
const targetDir = path51.dirname(edge.target);
|
|
19791
19823
|
if (sourceDir === targetDir) continue;
|
|
19792
19824
|
if (!graph.files.has(edge.target)) continue;
|
|
19793
19825
|
const existing = dirImportedBy.get(targetDir) ?? /* @__PURE__ */ new Set();
|
|
@@ -19815,20 +19847,20 @@ function clusterDirectories(graph) {
|
|
|
19815
19847
|
return clusters;
|
|
19816
19848
|
}
|
|
19817
19849
|
function isAncestor(ancestor, descendant) {
|
|
19818
|
-
const rel =
|
|
19850
|
+
const rel = path51.relative(ancestor, descendant);
|
|
19819
19851
|
return !rel.startsWith("..") && rel !== "";
|
|
19820
19852
|
}
|
|
19821
19853
|
|
|
19822
19854
|
// src/commands/refactor/restructure/clusterFiles.ts
|
|
19823
|
-
import
|
|
19855
|
+
import path52 from "path";
|
|
19824
19856
|
function findRootParent(file, importedBy, visited) {
|
|
19825
19857
|
const importers = importedBy.get(file);
|
|
19826
19858
|
if (!importers || importers.size !== 1) return file;
|
|
19827
19859
|
const parent = [...importers][0];
|
|
19828
|
-
const parentDir =
|
|
19829
|
-
const fileDir =
|
|
19860
|
+
const parentDir = path52.dirname(parent);
|
|
19861
|
+
const fileDir = path52.dirname(file);
|
|
19830
19862
|
if (parentDir !== fileDir) return file;
|
|
19831
|
-
if (
|
|
19863
|
+
if (path52.basename(parent, path52.extname(parent)) === "index") return file;
|
|
19832
19864
|
if (visited.has(parent)) return file;
|
|
19833
19865
|
visited.add(parent);
|
|
19834
19866
|
return findRootParent(parent, importedBy, visited);
|
|
@@ -19836,16 +19868,16 @@ function findRootParent(file, importedBy, visited) {
|
|
|
19836
19868
|
function clusterFiles(graph) {
|
|
19837
19869
|
const clusters = /* @__PURE__ */ new Map();
|
|
19838
19870
|
for (const file of graph.files) {
|
|
19839
|
-
const basename14 =
|
|
19871
|
+
const basename14 = path52.basename(file, path52.extname(file));
|
|
19840
19872
|
if (basename14 === "index") continue;
|
|
19841
19873
|
const importers = graph.importedBy.get(file);
|
|
19842
19874
|
if (!importers || importers.size !== 1) continue;
|
|
19843
19875
|
const parent = [...importers][0];
|
|
19844
19876
|
if (!graph.files.has(parent)) continue;
|
|
19845
|
-
const parentDir =
|
|
19846
|
-
const fileDir =
|
|
19877
|
+
const parentDir = path52.dirname(parent);
|
|
19878
|
+
const fileDir = path52.dirname(file);
|
|
19847
19879
|
if (parentDir !== fileDir) continue;
|
|
19848
|
-
const parentBasename =
|
|
19880
|
+
const parentBasename = path52.basename(parent, path52.extname(parent));
|
|
19849
19881
|
if (parentBasename === "index") continue;
|
|
19850
19882
|
const root = findRootParent(parent, graph.importedBy, /* @__PURE__ */ new Set([file]));
|
|
19851
19883
|
if (!root || root === file) continue;
|
|
@@ -19857,10 +19889,10 @@ function clusterFiles(graph) {
|
|
|
19857
19889
|
}
|
|
19858
19890
|
|
|
19859
19891
|
// src/commands/refactor/restructure/displayPlan.ts
|
|
19860
|
-
import
|
|
19892
|
+
import path53 from "path";
|
|
19861
19893
|
import chalk180 from "chalk";
|
|
19862
19894
|
function relPath(filePath) {
|
|
19863
|
-
return
|
|
19895
|
+
return path53.relative(process.cwd(), filePath);
|
|
19864
19896
|
}
|
|
19865
19897
|
function displayMoves(plan2) {
|
|
19866
19898
|
if (plan2.moves.length === 0) return;
|
|
@@ -19909,45 +19941,45 @@ Summary: ${plan2.moves.length} file(s) moved, ${plan2.rewrites.length} imports r
|
|
|
19909
19941
|
}
|
|
19910
19942
|
|
|
19911
19943
|
// src/commands/refactor/restructure/executePlan.ts
|
|
19912
|
-
import
|
|
19913
|
-
import
|
|
19944
|
+
import fs32 from "fs";
|
|
19945
|
+
import path54 from "path";
|
|
19914
19946
|
import chalk181 from "chalk";
|
|
19915
19947
|
function executePlan(plan2) {
|
|
19916
19948
|
const updatedContents = applyRewrites(plan2.rewrites);
|
|
19917
19949
|
for (const [file, content] of updatedContents) {
|
|
19918
|
-
|
|
19950
|
+
fs32.writeFileSync(file, content, "utf8");
|
|
19919
19951
|
console.log(
|
|
19920
|
-
chalk181.cyan(` Rewrote imports in ${
|
|
19952
|
+
chalk181.cyan(` Rewrote imports in ${path54.relative(process.cwd(), file)}`)
|
|
19921
19953
|
);
|
|
19922
19954
|
}
|
|
19923
19955
|
for (const dir of plan2.newDirectories) {
|
|
19924
|
-
|
|
19925
|
-
console.log(chalk181.green(` Created ${
|
|
19956
|
+
fs32.mkdirSync(dir, { recursive: true });
|
|
19957
|
+
console.log(chalk181.green(` Created ${path54.relative(process.cwd(), dir)}/`));
|
|
19926
19958
|
}
|
|
19927
19959
|
for (const move2 of plan2.moves) {
|
|
19928
|
-
const targetDir =
|
|
19929
|
-
if (!
|
|
19930
|
-
|
|
19960
|
+
const targetDir = path54.dirname(move2.to);
|
|
19961
|
+
if (!fs32.existsSync(targetDir)) {
|
|
19962
|
+
fs32.mkdirSync(targetDir, { recursive: true });
|
|
19931
19963
|
}
|
|
19932
|
-
|
|
19964
|
+
fs32.renameSync(move2.from, move2.to);
|
|
19933
19965
|
console.log(
|
|
19934
19966
|
chalk181.white(
|
|
19935
|
-
` Moved ${
|
|
19967
|
+
` Moved ${path54.relative(process.cwd(), move2.from)} \u2192 ${path54.relative(process.cwd(), move2.to)}`
|
|
19936
19968
|
)
|
|
19937
19969
|
);
|
|
19938
19970
|
}
|
|
19939
|
-
removeEmptyDirectories(plan2.moves.map((m) =>
|
|
19971
|
+
removeEmptyDirectories(plan2.moves.map((m) => path54.dirname(m.from)));
|
|
19940
19972
|
}
|
|
19941
19973
|
function removeEmptyDirectories(dirs) {
|
|
19942
19974
|
const unique = [...new Set(dirs)];
|
|
19943
19975
|
for (const dir of unique) {
|
|
19944
|
-
if (!
|
|
19945
|
-
const entries =
|
|
19976
|
+
if (!fs32.existsSync(dir)) continue;
|
|
19977
|
+
const entries = fs32.readdirSync(dir);
|
|
19946
19978
|
if (entries.length === 0) {
|
|
19947
|
-
|
|
19979
|
+
fs32.rmdirSync(dir);
|
|
19948
19980
|
console.log(
|
|
19949
19981
|
chalk181.dim(
|
|
19950
|
-
` Removed empty directory ${
|
|
19982
|
+
` Removed empty directory ${path54.relative(process.cwd(), dir)}`
|
|
19951
19983
|
)
|
|
19952
19984
|
);
|
|
19953
19985
|
}
|
|
@@ -19955,46 +19987,46 @@ function removeEmptyDirectories(dirs) {
|
|
|
19955
19987
|
}
|
|
19956
19988
|
|
|
19957
19989
|
// src/commands/refactor/restructure/planFileMoves/index.ts
|
|
19958
|
-
import
|
|
19990
|
+
import path56 from "path";
|
|
19959
19991
|
|
|
19960
19992
|
// src/commands/refactor/restructure/planFileMoves/shared.ts
|
|
19961
|
-
import
|
|
19993
|
+
import fs33 from "fs";
|
|
19962
19994
|
function emptyResult() {
|
|
19963
19995
|
return { moves: [], directories: [], warnings: [] };
|
|
19964
19996
|
}
|
|
19965
19997
|
function checkDirConflict(result, label2, dir) {
|
|
19966
|
-
if (!
|
|
19998
|
+
if (!fs33.existsSync(dir)) return false;
|
|
19967
19999
|
result.warnings.push(`Skipping ${label2}: directory ${dir} already exists`);
|
|
19968
20000
|
return true;
|
|
19969
20001
|
}
|
|
19970
20002
|
|
|
19971
20003
|
// src/commands/refactor/restructure/planFileMoves/planDirectoryMoves.ts
|
|
19972
|
-
import
|
|
19973
|
-
import
|
|
20004
|
+
import fs34 from "fs";
|
|
20005
|
+
import path55 from "path";
|
|
19974
20006
|
function collectEntry(results, dir, entry) {
|
|
19975
|
-
const full =
|
|
20007
|
+
const full = path55.join(dir, entry.name);
|
|
19976
20008
|
const items2 = entry.isDirectory() ? listFilesRecursive(full) : [full];
|
|
19977
20009
|
results.push(...items2);
|
|
19978
20010
|
}
|
|
19979
20011
|
function listFilesRecursive(dir) {
|
|
19980
|
-
if (!
|
|
20012
|
+
if (!fs34.existsSync(dir)) return [];
|
|
19981
20013
|
const results = [];
|
|
19982
|
-
for (const entry of
|
|
20014
|
+
for (const entry of fs34.readdirSync(dir, { withFileTypes: true })) {
|
|
19983
20015
|
collectEntry(results, dir, entry);
|
|
19984
20016
|
}
|
|
19985
20017
|
return results;
|
|
19986
20018
|
}
|
|
19987
20019
|
function addDirectoryFileMoves(moves, childDir, newLocation, reason) {
|
|
19988
20020
|
for (const file of listFilesRecursive(childDir)) {
|
|
19989
|
-
const rel =
|
|
19990
|
-
moves.push({ from: file, to:
|
|
20021
|
+
const rel = path55.relative(childDir, file);
|
|
20022
|
+
moves.push({ from: file, to: path55.join(newLocation, rel), reason });
|
|
19991
20023
|
}
|
|
19992
20024
|
}
|
|
19993
20025
|
function resolveChildDest(parentDir, childDir) {
|
|
19994
|
-
return
|
|
20026
|
+
return path55.join(parentDir, path55.basename(childDir));
|
|
19995
20027
|
}
|
|
19996
20028
|
function childMoveReason(parentDir) {
|
|
19997
|
-
return `Directory only imported from ${
|
|
20029
|
+
return `Directory only imported from ${path55.basename(parentDir)}/`;
|
|
19998
20030
|
}
|
|
19999
20031
|
function registerDirectoryMove(result, childDir, dest, parentDir) {
|
|
20000
20032
|
result.directories.push(dest);
|
|
@@ -20019,7 +20051,7 @@ function planDirectoryMoves(clusters) {
|
|
|
20019
20051
|
|
|
20020
20052
|
// src/commands/refactor/restructure/planFileMoves/index.ts
|
|
20021
20053
|
function childMoveData(child, newDir, parentBase) {
|
|
20022
|
-
const to =
|
|
20054
|
+
const to = path56.join(newDir, path56.basename(child));
|
|
20023
20055
|
return { from: child, to, reason: `Only imported by ${parentBase}` };
|
|
20024
20056
|
}
|
|
20025
20057
|
function addChildMoves(moves, children, newDir, parentBase) {
|
|
@@ -20027,15 +20059,15 @@ function addChildMoves(moves, children, newDir, parentBase) {
|
|
|
20027
20059
|
moves.push(childMoveData(child, newDir, parentBase));
|
|
20028
20060
|
}
|
|
20029
20061
|
function getBaseName(filePath) {
|
|
20030
|
-
return
|
|
20062
|
+
return path56.basename(filePath, path56.extname(filePath));
|
|
20031
20063
|
}
|
|
20032
20064
|
function resolveClusterDir(parent) {
|
|
20033
|
-
return
|
|
20065
|
+
return path56.join(path56.dirname(parent), getBaseName(parent));
|
|
20034
20066
|
}
|
|
20035
20067
|
function createParentMove(parent, newDir) {
|
|
20036
20068
|
return {
|
|
20037
20069
|
from: parent,
|
|
20038
|
-
to:
|
|
20070
|
+
to: path56.join(newDir, `index${path56.extname(parent)}`),
|
|
20039
20071
|
reason: `Main module of new ${getBaseName(parent)}/ directory`
|
|
20040
20072
|
};
|
|
20041
20073
|
}
|
|
@@ -20059,7 +20091,7 @@ function planFileMoves(clusters) {
|
|
|
20059
20091
|
|
|
20060
20092
|
// src/commands/refactor/restructure/index.ts
|
|
20061
20093
|
function buildPlan3(candidateFiles, tsConfigPath) {
|
|
20062
|
-
const candidates = new Set(candidateFiles.map((f) =>
|
|
20094
|
+
const candidates = new Set(candidateFiles.map((f) => path57.resolve(f)));
|
|
20063
20095
|
const graph = buildImportGraph(candidates, tsConfigPath);
|
|
20064
20096
|
const allProjectFiles = /* @__PURE__ */ new Set([
|
|
20065
20097
|
...graph.importedBy.keys(),
|
|
@@ -20082,7 +20114,7 @@ async function restructure(pattern2, options2 = {}) {
|
|
|
20082
20114
|
console.log(chalk182.yellow("No files found matching pattern"));
|
|
20083
20115
|
return;
|
|
20084
20116
|
}
|
|
20085
|
-
const tsConfigPath =
|
|
20117
|
+
const tsConfigPath = findTsConfig(path57.resolve(files[0]));
|
|
20086
20118
|
const plan2 = buildPlan3(files, tsConfigPath);
|
|
20087
20119
|
if (plan2.moves.length === 0) {
|
|
20088
20120
|
console.log(chalk182.green("No restructuring needed"));
|
|
@@ -20815,8 +20847,8 @@ async function handlePostSynthesis(synthesisPath, options2) {
|
|
|
20815
20847
|
// src/commands/review/prepareReviewDir.ts
|
|
20816
20848
|
import { existsSync as existsSync43, mkdirSync as mkdirSync18, unlinkSync as unlinkSync16, writeFileSync as writeFileSync36 } from "fs";
|
|
20817
20849
|
function clearReviewFiles(paths) {
|
|
20818
|
-
for (const
|
|
20819
|
-
if (existsSync43(
|
|
20850
|
+
for (const path70 of [paths.claudePath, paths.codexPath, paths.synthesisPath]) {
|
|
20851
|
+
if (existsSync43(path70)) unlinkSync16(path70);
|
|
20820
20852
|
}
|
|
20821
20853
|
}
|
|
20822
20854
|
function prepareReviewDir(paths, requestBody, force) {
|
|
@@ -21964,8 +21996,8 @@ import chalk190 from "chalk";
|
|
|
21964
21996
|
|
|
21965
21997
|
// src/commands/seq/fetchSeq.ts
|
|
21966
21998
|
import chalk187 from "chalk";
|
|
21967
|
-
async function fetchSeq(conn,
|
|
21968
|
-
const url = `${conn.url}${
|
|
21999
|
+
async function fetchSeq(conn, path70, params) {
|
|
22000
|
+
const url = `${conn.url}${path70}?${params}`;
|
|
21969
22001
|
const response = await fetch(url, {
|
|
21970
22002
|
headers: {
|
|
21971
22003
|
Accept: "application/json",
|
|
@@ -23452,9 +23484,9 @@ function findPortFile(roamDir) {
|
|
|
23452
23484
|
return void 0;
|
|
23453
23485
|
}
|
|
23454
23486
|
const candidates = entries.filter((name) => /^roam-local-api(-[^.]+)?\.port$/.test(name)).map((name) => {
|
|
23455
|
-
const
|
|
23487
|
+
const path70 = join61(roamDir, name);
|
|
23456
23488
|
try {
|
|
23457
|
-
return { path:
|
|
23489
|
+
return { path: path70, mtimeMs: statSync8(path70).mtimeMs };
|
|
23458
23490
|
} catch {
|
|
23459
23491
|
return void 0;
|
|
23460
23492
|
}
|
|
@@ -23873,11 +23905,11 @@ function findLinkIndex() {
|
|
|
23873
23905
|
function parseLinkArgs() {
|
|
23874
23906
|
const idx = findLinkIndex();
|
|
23875
23907
|
if (idx === -1) return null;
|
|
23876
|
-
const
|
|
23908
|
+
const path70 = process.argv[idx + 1];
|
|
23877
23909
|
const rest = process.argv.slice(idx + 2);
|
|
23878
23910
|
const { value: prefix2 } = extractOption(rest, "--prefix");
|
|
23879
23911
|
if (!prefix2) return null;
|
|
23880
|
-
return { path:
|
|
23912
|
+
return { path: path70, prefix: prefix2 };
|
|
23881
23913
|
}
|
|
23882
23914
|
function hasDuplicateLink(runList, linkPath) {
|
|
23883
23915
|
return runList.some(
|
|
@@ -24593,14 +24625,14 @@ import * as pty from "node-pty";
|
|
|
24593
24625
|
// src/commands/sessions/daemon/ensureSpawnHelperExecutable.ts
|
|
24594
24626
|
import { chmodSync, existsSync as existsSync55, statSync as statSync9 } from "fs";
|
|
24595
24627
|
import { createRequire as createRequire3 } from "module";
|
|
24596
|
-
import
|
|
24628
|
+
import path58 from "path";
|
|
24597
24629
|
var require4 = createRequire3(import.meta.url);
|
|
24598
24630
|
var ensured = false;
|
|
24599
24631
|
function ensureSpawnHelperExecutable() {
|
|
24600
24632
|
if (ensured || process.platform !== "darwin") return;
|
|
24601
24633
|
ensured = true;
|
|
24602
|
-
const ptyRoot =
|
|
24603
|
-
const helper =
|
|
24634
|
+
const ptyRoot = path58.join(path58.dirname(require4.resolve("node-pty")), "..");
|
|
24635
|
+
const helper = path58.join(
|
|
24604
24636
|
ptyRoot,
|
|
24605
24637
|
"prebuilds",
|
|
24606
24638
|
`${process.platform}-${process.arch}`,
|
|
@@ -24661,14 +24693,14 @@ function createAssistSession(id, assistArgs, cwd, meta) {
|
|
|
24661
24693
|
import { randomUUID as randomUUID4 } from "crypto";
|
|
24662
24694
|
|
|
24663
24695
|
// src/commands/sessions/daemon/readDesignSystemPrompt.ts
|
|
24664
|
-
import * as
|
|
24665
|
-
import * as
|
|
24696
|
+
import * as fs35 from "fs";
|
|
24697
|
+
import * as path59 from "path";
|
|
24666
24698
|
import { fileURLToPath as fileURLToPath8 } from "url";
|
|
24667
24699
|
var __filename4 = fileURLToPath8(import.meta.url);
|
|
24668
|
-
var __dirname6 =
|
|
24700
|
+
var __dirname6 = path59.dirname(__filename4);
|
|
24669
24701
|
function readDesignSystemPrompt() {
|
|
24670
|
-
const promptPath =
|
|
24671
|
-
return
|
|
24702
|
+
const promptPath = path59.join(__dirname6, "..", "claude", "system-prompt.md");
|
|
24703
|
+
return fs35.readFileSync(promptPath, "utf8");
|
|
24672
24704
|
}
|
|
24673
24705
|
|
|
24674
24706
|
// src/commands/sessions/daemon/spawnClaude.ts
|
|
@@ -25047,7 +25079,7 @@ async function recordWindowTokens(db, window, resetsAt, tokensUp, tokensDown) {
|
|
|
25047
25079
|
}
|
|
25048
25080
|
|
|
25049
25081
|
// src/commands/sessions/shared/transcriptUsage.ts
|
|
25050
|
-
import * as
|
|
25082
|
+
import * as fs36 from "fs";
|
|
25051
25083
|
function transcriptUsage(lines) {
|
|
25052
25084
|
const byId = /* @__PURE__ */ new Map();
|
|
25053
25085
|
for (const line of lines) {
|
|
@@ -25071,7 +25103,7 @@ function transcriptUsage(lines) {
|
|
|
25071
25103
|
return [...byId.values()];
|
|
25072
25104
|
}
|
|
25073
25105
|
async function readTranscriptUsage(transcriptPath) {
|
|
25074
|
-
const content = await
|
|
25106
|
+
const content = await fs36.promises.readFile(transcriptPath, "utf8");
|
|
25075
25107
|
return transcriptUsage(content.split("\n"));
|
|
25076
25108
|
}
|
|
25077
25109
|
|
|
@@ -25204,8 +25236,8 @@ async function seedRunningMsFromUsage(session, notify2) {
|
|
|
25204
25236
|
var DEBOUNCE_MS = 50;
|
|
25205
25237
|
function watchActivity(session, notify2) {
|
|
25206
25238
|
if (session.commandType !== "assist" || !session.cwd) return;
|
|
25207
|
-
const
|
|
25208
|
-
const dir = dirname29(
|
|
25239
|
+
const path70 = activityPath(session.id);
|
|
25240
|
+
const dir = dirname29(path70);
|
|
25209
25241
|
try {
|
|
25210
25242
|
mkdirSync25(dir, { recursive: true });
|
|
25211
25243
|
} catch {
|
|
@@ -25215,7 +25247,7 @@ function watchActivity(session, notify2) {
|
|
|
25215
25247
|
let timer = null;
|
|
25216
25248
|
const read = () => {
|
|
25217
25249
|
timer = null;
|
|
25218
|
-
const activity2 = readActivity(
|
|
25250
|
+
const activity2 = readActivity(path70);
|
|
25219
25251
|
if (!activity2) return;
|
|
25220
25252
|
session.activity = activity2;
|
|
25221
25253
|
if (activity2.claudeSessionId)
|
|
@@ -25225,11 +25257,11 @@ function watchActivity(session, notify2) {
|
|
|
25225
25257
|
notify2();
|
|
25226
25258
|
};
|
|
25227
25259
|
session.activityWatcher = watch(dir, (_event, filename) => {
|
|
25228
|
-
if (filename && !
|
|
25260
|
+
if (filename && !path70.endsWith(filename)) return;
|
|
25229
25261
|
if (timer) clearTimeout(timer);
|
|
25230
25262
|
timer = setTimeout(read, DEBOUNCE_MS);
|
|
25231
25263
|
});
|
|
25232
|
-
if (existsSync56(
|
|
25264
|
+
if (existsSync56(path70)) read();
|
|
25233
25265
|
}
|
|
25234
25266
|
function refreshActivity(session) {
|
|
25235
25267
|
if (session.commandType !== "assist" || !session.cwd) return;
|
|
@@ -26560,7 +26592,7 @@ import * as net3 from "net";
|
|
|
26560
26592
|
import { createInterface as createInterface9 } from "readline";
|
|
26561
26593
|
|
|
26562
26594
|
// src/commands/sessions/shared/parseTranscript.ts
|
|
26563
|
-
import * as
|
|
26595
|
+
import * as fs37 from "fs";
|
|
26564
26596
|
|
|
26565
26597
|
// src/commands/sessions/shared/toolTarget.ts
|
|
26566
26598
|
function toolTarget(input) {
|
|
@@ -26612,7 +26644,7 @@ async function parseTranscript(sessionId) {
|
|
|
26612
26644
|
const filePath = await findSessionJsonlPath(sessionId);
|
|
26613
26645
|
if (!filePath) return [];
|
|
26614
26646
|
try {
|
|
26615
|
-
const raw = await
|
|
26647
|
+
const raw = await fs37.promises.readFile(filePath, "utf8");
|
|
26616
26648
|
return parseTranscriptLines(raw.split("\n"));
|
|
26617
26649
|
} catch {
|
|
26618
26650
|
return [];
|
|
@@ -26941,17 +26973,17 @@ function registerDaemon(program2) {
|
|
|
26941
26973
|
}
|
|
26942
26974
|
|
|
26943
26975
|
// src/commands/sessions/summarise/index.ts
|
|
26944
|
-
import * as
|
|
26976
|
+
import * as fs39 from "fs";
|
|
26945
26977
|
import chalk199 from "chalk";
|
|
26946
26978
|
|
|
26947
26979
|
// src/commands/sessions/summarise/shared.ts
|
|
26948
|
-
import * as
|
|
26980
|
+
import * as fs38 from "fs";
|
|
26949
26981
|
function writeSummary(jsonlPath2, summary) {
|
|
26950
|
-
|
|
26982
|
+
fs38.writeFileSync(summaryPathFor(jsonlPath2), `${summary.trim()}
|
|
26951
26983
|
`, "utf8");
|
|
26952
26984
|
}
|
|
26953
26985
|
function hasSummary(jsonlPath2) {
|
|
26954
|
-
return
|
|
26986
|
+
return fs38.existsSync(summaryPathFor(jsonlPath2));
|
|
26955
26987
|
}
|
|
26956
26988
|
function summaryPathFor(jsonlPath2) {
|
|
26957
26989
|
return jsonlPath2.replace(/\.jsonl$/, ".summary");
|
|
@@ -27038,7 +27070,7 @@ function selectCandidates(files, options2) {
|
|
|
27038
27070
|
const candidates = options2.force ? files : files.filter((f) => !hasSummary(f));
|
|
27039
27071
|
candidates.sort((a, b) => {
|
|
27040
27072
|
try {
|
|
27041
|
-
return
|
|
27073
|
+
return fs39.statSync(b).mtimeMs - fs39.statSync(a).mtimeMs;
|
|
27042
27074
|
} catch {
|
|
27043
27075
|
return 0;
|
|
27044
27076
|
}
|
|
@@ -27279,21 +27311,21 @@ async function statusLine() {
|
|
|
27279
27311
|
}
|
|
27280
27312
|
|
|
27281
27313
|
// src/commands/sync.ts
|
|
27282
|
-
import * as
|
|
27314
|
+
import * as fs46 from "fs";
|
|
27283
27315
|
import * as os4 from "os";
|
|
27284
|
-
import * as
|
|
27316
|
+
import * as path68 from "path";
|
|
27285
27317
|
import { fileURLToPath as fileURLToPath9 } from "url";
|
|
27286
27318
|
|
|
27287
27319
|
// src/commands/sync/syncClaudeMd.ts
|
|
27288
|
-
import * as
|
|
27289
|
-
import * as
|
|
27320
|
+
import * as fs40 from "fs";
|
|
27321
|
+
import * as path60 from "path";
|
|
27290
27322
|
import chalk202 from "chalk";
|
|
27291
27323
|
async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
27292
|
-
const source =
|
|
27293
|
-
const target =
|
|
27294
|
-
const sourceContent =
|
|
27295
|
-
if (
|
|
27296
|
-
const targetContent =
|
|
27324
|
+
const source = path60.join(claudeDir, "CLAUDE.md");
|
|
27325
|
+
const target = path60.join(targetBase, "CLAUDE.md");
|
|
27326
|
+
const sourceContent = fs40.readFileSync(source, "utf8");
|
|
27327
|
+
if (fs40.existsSync(target)) {
|
|
27328
|
+
const targetContent = fs40.readFileSync(target, "utf8");
|
|
27297
27329
|
if (sourceContent !== targetContent) {
|
|
27298
27330
|
console.log(
|
|
27299
27331
|
chalk202.yellow("\n\u26A0\uFE0F Warning: CLAUDE.md differs from existing file")
|
|
@@ -27310,38 +27342,38 @@ async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
|
27310
27342
|
}
|
|
27311
27343
|
}
|
|
27312
27344
|
}
|
|
27313
|
-
|
|
27345
|
+
fs40.copyFileSync(source, target);
|
|
27314
27346
|
console.log("Copied CLAUDE.md to ~/.claude/CLAUDE.md");
|
|
27315
27347
|
}
|
|
27316
27348
|
|
|
27317
27349
|
// src/commands/sync/syncCodex.ts
|
|
27318
|
-
import * as
|
|
27350
|
+
import * as path63 from "path";
|
|
27319
27351
|
|
|
27320
27352
|
// src/commands/sync/installHarnessCommands.ts
|
|
27321
|
-
import * as
|
|
27322
|
-
import * as
|
|
27353
|
+
import * as fs41 from "fs";
|
|
27354
|
+
import * as path61 from "path";
|
|
27323
27355
|
function installHarnessCommands(claudeDir, harness, transform) {
|
|
27324
|
-
const commandsSource =
|
|
27325
|
-
const files =
|
|
27356
|
+
const commandsSource = path61.join(claudeDir, "commands");
|
|
27357
|
+
const files = fs41.readdirSync(commandsSource);
|
|
27326
27358
|
let synced = 0;
|
|
27327
27359
|
for (const file of files) {
|
|
27328
27360
|
if (!file.endsWith(".md")) continue;
|
|
27329
27361
|
const name = file.replace(/\.md$/, "");
|
|
27330
|
-
const content =
|
|
27331
|
-
const target =
|
|
27332
|
-
|
|
27333
|
-
|
|
27362
|
+
const content = fs41.readFileSync(path61.join(commandsSource, file), "utf8");
|
|
27363
|
+
const target = path61.join(harness.homeDir, harness.sync.commandDest(name));
|
|
27364
|
+
fs41.mkdirSync(path61.dirname(target), { recursive: true });
|
|
27365
|
+
fs41.writeFileSync(target, transform(name, content));
|
|
27334
27366
|
synced++;
|
|
27335
27367
|
}
|
|
27336
|
-
const agentsTarget =
|
|
27337
|
-
|
|
27338
|
-
|
|
27368
|
+
const agentsTarget = path61.join(harness.homeDir, harness.sync.agentsFile);
|
|
27369
|
+
fs41.mkdirSync(path61.dirname(agentsTarget), { recursive: true });
|
|
27370
|
+
fs41.copyFileSync(path61.join(claudeDir, "CLAUDE.md"), agentsTarget);
|
|
27339
27371
|
return { total: files.length, synced };
|
|
27340
27372
|
}
|
|
27341
27373
|
|
|
27342
27374
|
// src/commands/sync/syncCodexHooks.ts
|
|
27343
|
-
import * as
|
|
27344
|
-
import * as
|
|
27375
|
+
import * as fs42 from "fs";
|
|
27376
|
+
import * as path62 from "path";
|
|
27345
27377
|
var BEGIN = "# >>> assist codex hooks (managed) \u2014 do not edit >>>";
|
|
27346
27378
|
var END = "# <<< assist codex hooks (managed) <<<";
|
|
27347
27379
|
function upsertManagedBlock(existing, body) {
|
|
@@ -27371,11 +27403,11 @@ ${rest}
|
|
|
27371
27403
|
`;
|
|
27372
27404
|
}
|
|
27373
27405
|
function syncCodexHooks(sourcePath) {
|
|
27374
|
-
const body =
|
|
27375
|
-
const configPath =
|
|
27376
|
-
const existing =
|
|
27377
|
-
|
|
27378
|
-
|
|
27406
|
+
const body = fs42.readFileSync(sourcePath, "utf8");
|
|
27407
|
+
const configPath = path62.join(harnesses.codex.homeDir, "config.toml");
|
|
27408
|
+
const existing = fs42.existsSync(configPath) ? fs42.readFileSync(configPath, "utf8") : "";
|
|
27409
|
+
fs42.mkdirSync(path62.dirname(configPath), { recursive: true });
|
|
27410
|
+
fs42.writeFileSync(configPath, upsertManagedBlock(existing, body));
|
|
27379
27411
|
console.log(
|
|
27380
27412
|
"Registered assist codex-hook in ~/.codex/config.toml (PreToolUse, PermissionRequest)"
|
|
27381
27413
|
);
|
|
@@ -27406,50 +27438,50 @@ function syncCodex(claudeDir) {
|
|
|
27406
27438
|
harnesses.codex,
|
|
27407
27439
|
commandToSkill
|
|
27408
27440
|
);
|
|
27409
|
-
syncCodexHooks(
|
|
27441
|
+
syncCodexHooks(path63.join(claudeDir, "..", "codex", "config.toml"));
|
|
27410
27442
|
console.log(
|
|
27411
27443
|
`Synced ${total} skill(s) to ~/.codex/skills and CLAUDE.md to ~/.codex/AGENTS.md`
|
|
27412
27444
|
);
|
|
27413
27445
|
}
|
|
27414
27446
|
|
|
27415
27447
|
// src/commands/sync/syncDesign.ts
|
|
27416
|
-
import * as
|
|
27417
|
-
import * as
|
|
27448
|
+
import * as fs43 from "fs";
|
|
27449
|
+
import * as path64 from "path";
|
|
27418
27450
|
function syncDesign(claudeDir, targetBase) {
|
|
27419
|
-
const systemPromptSource =
|
|
27420
|
-
const systemPromptTarget =
|
|
27421
|
-
|
|
27451
|
+
const systemPromptSource = path64.join(claudeDir, "system-prompt.md");
|
|
27452
|
+
const systemPromptTarget = path64.join(targetBase, "system-prompt.md");
|
|
27453
|
+
fs43.copyFileSync(systemPromptSource, systemPromptTarget);
|
|
27422
27454
|
console.log("Copied system-prompt.md to ~/.claude/system-prompt.md");
|
|
27423
|
-
const skillsSource =
|
|
27424
|
-
const skillsTarget =
|
|
27425
|
-
|
|
27426
|
-
const files =
|
|
27455
|
+
const skillsSource = path64.join(claudeDir, "skills");
|
|
27456
|
+
const skillsTarget = path64.join(targetBase, "skills");
|
|
27457
|
+
fs43.mkdirSync(skillsTarget, { recursive: true });
|
|
27458
|
+
const files = fs43.readdirSync(skillsSource);
|
|
27427
27459
|
for (const file of files) {
|
|
27428
|
-
|
|
27429
|
-
|
|
27430
|
-
|
|
27460
|
+
fs43.copyFileSync(
|
|
27461
|
+
path64.join(skillsSource, file),
|
|
27462
|
+
path64.join(skillsTarget, file)
|
|
27431
27463
|
);
|
|
27432
27464
|
}
|
|
27433
27465
|
console.log(`Synced ${files.length} design skill(s) to ~/.claude/skills`);
|
|
27434
27466
|
}
|
|
27435
27467
|
|
|
27436
27468
|
// src/commands/sync/syncPi.ts
|
|
27437
|
-
import * as
|
|
27469
|
+
import * as path66 from "path";
|
|
27438
27470
|
|
|
27439
27471
|
// src/commands/sync/syncPiHooks.ts
|
|
27440
|
-
import * as
|
|
27441
|
-
import * as
|
|
27472
|
+
import * as fs44 from "fs";
|
|
27473
|
+
import * as path65 from "path";
|
|
27442
27474
|
function piExtensionsDir() {
|
|
27443
|
-
return
|
|
27475
|
+
return path65.join(harnesses.pi.homeDir, "extensions");
|
|
27444
27476
|
}
|
|
27445
27477
|
function syncPiHooks(sourceDir) {
|
|
27446
27478
|
const target = piExtensionsDir();
|
|
27447
|
-
|
|
27448
|
-
const files =
|
|
27479
|
+
fs44.mkdirSync(target, { recursive: true });
|
|
27480
|
+
const files = fs44.readdirSync(sourceDir).filter((f) => f.endsWith(".ts"));
|
|
27449
27481
|
for (const file of files) {
|
|
27450
|
-
|
|
27451
|
-
|
|
27452
|
-
|
|
27482
|
+
fs44.copyFileSync(
|
|
27483
|
+
path65.join(sourceDir, file),
|
|
27484
|
+
path65.join(target, `assist-${file}`)
|
|
27453
27485
|
);
|
|
27454
27486
|
}
|
|
27455
27487
|
console.log(
|
|
@@ -27486,23 +27518,23 @@ function syncPi(claudeDir) {
|
|
|
27486
27518
|
harnesses.pi,
|
|
27487
27519
|
commandToPrompt
|
|
27488
27520
|
);
|
|
27489
|
-
syncPiHooks(
|
|
27521
|
+
syncPiHooks(path66.join(claudeDir, "..", "pi"));
|
|
27490
27522
|
console.log(
|
|
27491
27523
|
`Synced ${synced} prompt(s) to ~/.pi/agent/prompts and CLAUDE.md to ~/.pi/agent/AGENTS.md`
|
|
27492
27524
|
);
|
|
27493
27525
|
}
|
|
27494
27526
|
|
|
27495
27527
|
// src/commands/sync/syncSettings.ts
|
|
27496
|
-
import * as
|
|
27497
|
-
import * as
|
|
27528
|
+
import * as fs45 from "fs";
|
|
27529
|
+
import * as path67 from "path";
|
|
27498
27530
|
import chalk203 from "chalk";
|
|
27499
27531
|
async function syncSettings(claudeDir, targetBase, options2) {
|
|
27500
|
-
const source =
|
|
27501
|
-
const target =
|
|
27502
|
-
const sourceContent =
|
|
27532
|
+
const source = path67.join(claudeDir, "settings.json");
|
|
27533
|
+
const target = path67.join(targetBase, "settings.json");
|
|
27534
|
+
const sourceContent = fs45.readFileSync(source, "utf8");
|
|
27503
27535
|
const sourceSettings = JSON.parse(sourceContent);
|
|
27504
|
-
const targetExists =
|
|
27505
|
-
const targetContent = targetExists ?
|
|
27536
|
+
const targetExists = fs45.existsSync(target);
|
|
27537
|
+
const targetContent = targetExists ? fs45.readFileSync(target, "utf8") : "";
|
|
27506
27538
|
const preservedUserSettings = targetExists ? JSON.parse(targetContent) : {};
|
|
27507
27539
|
const mergedContent = JSON.stringify(
|
|
27508
27540
|
{ ...preservedUserSettings, ...sourceSettings },
|
|
@@ -27531,18 +27563,18 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
27531
27563
|
}
|
|
27532
27564
|
}
|
|
27533
27565
|
}
|
|
27534
|
-
|
|
27566
|
+
fs45.writeFileSync(target, mergedContent);
|
|
27535
27567
|
console.log("Copied settings.json to ~/.claude/settings.json");
|
|
27536
27568
|
}
|
|
27537
27569
|
|
|
27538
27570
|
// src/commands/sync.ts
|
|
27539
27571
|
var __filename5 = fileURLToPath9(import.meta.url);
|
|
27540
|
-
var __dirname7 =
|
|
27572
|
+
var __dirname7 = path68.dirname(__filename5);
|
|
27541
27573
|
async function sync(options2) {
|
|
27542
27574
|
const config = loadConfig();
|
|
27543
27575
|
const yes = options2?.yes ?? config.sync.autoConfirm;
|
|
27544
|
-
const claudeDir =
|
|
27545
|
-
const targetBase =
|
|
27576
|
+
const claudeDir = path68.join(__dirname7, "..", "claude");
|
|
27577
|
+
const targetBase = path68.join(os4.homedir(), ".claude");
|
|
27546
27578
|
syncCommands(claudeDir, targetBase);
|
|
27547
27579
|
syncDesign(claudeDir, targetBase);
|
|
27548
27580
|
await syncSettings(claudeDir, targetBase, { yes });
|
|
@@ -27551,12 +27583,12 @@ async function sync(options2) {
|
|
|
27551
27583
|
syncPi(claudeDir);
|
|
27552
27584
|
}
|
|
27553
27585
|
function syncCommands(claudeDir, targetBase) {
|
|
27554
|
-
const sourceDir =
|
|
27555
|
-
const targetDir =
|
|
27556
|
-
|
|
27557
|
-
const files =
|
|
27586
|
+
const sourceDir = path68.join(claudeDir, "commands");
|
|
27587
|
+
const targetDir = path68.join(targetBase, "commands");
|
|
27588
|
+
fs46.mkdirSync(targetDir, { recursive: true });
|
|
27589
|
+
const files = fs46.readdirSync(sourceDir);
|
|
27558
27590
|
for (const file of files) {
|
|
27559
|
-
|
|
27591
|
+
fs46.copyFileSync(path68.join(sourceDir, file), path68.join(targetDir, file));
|
|
27560
27592
|
console.log(`Copied ${file} to ${targetDir}`);
|
|
27561
27593
|
}
|
|
27562
27594
|
console.log(`Synced ${files.length} command(s) to ~/.claude/commands`);
|
|
@@ -27564,7 +27596,7 @@ function syncCommands(claudeDir, targetBase) {
|
|
|
27564
27596
|
|
|
27565
27597
|
// src/commands/update.ts
|
|
27566
27598
|
import { execSync as execSync59 } from "child_process";
|
|
27567
|
-
import * as
|
|
27599
|
+
import * as path69 from "path";
|
|
27568
27600
|
|
|
27569
27601
|
// src/commands/restartDaemonAfterUpdate.ts
|
|
27570
27602
|
async function restartDaemonAfterUpdate() {
|
|
@@ -27583,12 +27615,12 @@ async function restartDaemonAfterUpdate() {
|
|
|
27583
27615
|
// src/commands/update.ts
|
|
27584
27616
|
function isGlobalNpmInstall(dir) {
|
|
27585
27617
|
try {
|
|
27586
|
-
const resolved =
|
|
27587
|
-
if (resolved.split(
|
|
27618
|
+
const resolved = path69.resolve(dir);
|
|
27619
|
+
if (resolved.split(path69.sep).includes("node_modules")) {
|
|
27588
27620
|
return true;
|
|
27589
27621
|
}
|
|
27590
27622
|
const globalPrefix = execSync59("npm prefix -g", { stdio: "pipe" }).toString().trim();
|
|
27591
|
-
return resolved.toLowerCase().startsWith(
|
|
27623
|
+
return resolved.toLowerCase().startsWith(path69.resolve(globalPrefix).toLowerCase());
|
|
27592
27624
|
} catch {
|
|
27593
27625
|
return false;
|
|
27594
27626
|
}
|