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