@staff0rd/assist 0.242.0 → 0.242.1
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 +49 -49
- package/dist/index.js +290 -259
- 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.242.
|
|
9
|
+
version: "0.242.1",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -115,10 +115,10 @@ import { stringify as stringifyYaml } from "yaml";
|
|
|
115
115
|
// src/shared/loadRawYaml.ts
|
|
116
116
|
import { existsSync, readFileSync } from "fs";
|
|
117
117
|
import { parse as parseYaml } from "yaml";
|
|
118
|
-
function loadRawYaml(
|
|
119
|
-
if (!existsSync(
|
|
118
|
+
function loadRawYaml(path53) {
|
|
119
|
+
if (!existsSync(path53)) return {};
|
|
120
120
|
try {
|
|
121
|
-
const content = readFileSync(
|
|
121
|
+
const content = readFileSync(path53, "utf-8");
|
|
122
122
|
return parseYaml(content) || {};
|
|
123
123
|
} catch {
|
|
124
124
|
return {};
|
|
@@ -2754,9 +2754,9 @@ var LOCAL_FILES = ["backlog.jsonl", "backlog.db"];
|
|
|
2754
2754
|
function backupLocalBacklogFiles(dir) {
|
|
2755
2755
|
const moved = [];
|
|
2756
2756
|
for (const name of LOCAL_FILES) {
|
|
2757
|
-
const
|
|
2758
|
-
if (existsSync14(
|
|
2759
|
-
renameSync(
|
|
2757
|
+
const path53 = join10(dir, ".assist", name);
|
|
2758
|
+
if (existsSync14(path53)) {
|
|
2759
|
+
renameSync(path53, `${path53}.bak`);
|
|
2760
2760
|
moved.push(`${name} \u2192 ${name}.bak`);
|
|
2761
2761
|
}
|
|
2762
2762
|
}
|
|
@@ -3045,8 +3045,8 @@ var backlogItemSchema = z3.strictObject({
|
|
|
3045
3045
|
var backlogFileSchema = z3.array(backlogItemSchema);
|
|
3046
3046
|
|
|
3047
3047
|
// src/commands/backlog/parseBacklogJsonl.ts
|
|
3048
|
-
function parseBacklogJsonl(
|
|
3049
|
-
const content = readFileSync9(
|
|
3048
|
+
function parseBacklogJsonl(path53) {
|
|
3049
|
+
const content = readFileSync9(path53, "utf-8").trim();
|
|
3050
3050
|
if (content.length === 0) return [];
|
|
3051
3051
|
return content.split("\n").map((line) => line.trim()).filter(Boolean).map((line) => backlogItemSchema.parse(JSON.parse(line)));
|
|
3052
3052
|
}
|
|
@@ -3121,8 +3121,8 @@ function findBacklogUp(startDir) {
|
|
|
3121
3121
|
|
|
3122
3122
|
// src/commands/backlog/getCurrentOrigin.ts
|
|
3123
3123
|
import { execSync as execSync17 } from "child_process";
|
|
3124
|
-
function stripLeadingSlashes(
|
|
3125
|
-
return
|
|
3124
|
+
function stripLeadingSlashes(path53) {
|
|
3125
|
+
return path53.replace(/^\/+/, "");
|
|
3126
3126
|
}
|
|
3127
3127
|
function normalizeOrigin(raw) {
|
|
3128
3128
|
const trimmed = raw.trim().replace(/\.git$/i, "").replace(/\/+$/, "");
|
|
@@ -3587,10 +3587,10 @@ function writeSignal(event, data) {
|
|
|
3587
3587
|
|
|
3588
3588
|
// src/commands/backlog/readSignal.ts
|
|
3589
3589
|
function readSignal() {
|
|
3590
|
-
const
|
|
3591
|
-
if (!existsSync18(
|
|
3590
|
+
const path53 = getSignalPath();
|
|
3591
|
+
if (!existsSync18(path53)) return void 0;
|
|
3592
3592
|
try {
|
|
3593
|
-
return JSON.parse(readFileSync11(
|
|
3593
|
+
return JSON.parse(readFileSync11(path53, "utf-8"));
|
|
3594
3594
|
} catch {
|
|
3595
3595
|
return void 0;
|
|
3596
3596
|
}
|
|
@@ -4474,6 +4474,17 @@ function dispatchMessage(ws, manager, data) {
|
|
|
4474
4474
|
handlers[data.type]?.(ws, manager, data);
|
|
4475
4475
|
}
|
|
4476
4476
|
|
|
4477
|
+
// src/commands/sessions/web/wsBroadcast.ts
|
|
4478
|
+
function wsSend(ws, msg) {
|
|
4479
|
+
if (ws.readyState === ws.OPEN) ws.send(JSON.stringify(msg));
|
|
4480
|
+
}
|
|
4481
|
+
function wsBroadcast(clients, msg) {
|
|
4482
|
+
const json = JSON.stringify(msg);
|
|
4483
|
+
for (const ws of clients) {
|
|
4484
|
+
if (ws.readyState === ws.OPEN) ws.send(json);
|
|
4485
|
+
}
|
|
4486
|
+
}
|
|
4487
|
+
|
|
4477
4488
|
// src/commands/sessions/web/handleSocket.ts
|
|
4478
4489
|
function handleSocket(ws, manager) {
|
|
4479
4490
|
manager.addClient(ws);
|
|
@@ -4484,7 +4495,14 @@ function handleSocket(ws, manager) {
|
|
|
4484
4495
|
} catch {
|
|
4485
4496
|
return;
|
|
4486
4497
|
}
|
|
4487
|
-
|
|
4498
|
+
try {
|
|
4499
|
+
dispatchMessage(ws, manager, data);
|
|
4500
|
+
} catch (e) {
|
|
4501
|
+
wsSend(ws, {
|
|
4502
|
+
type: "error",
|
|
4503
|
+
message: `${data.type} failed: ${e instanceof Error ? e.message : String(e)}`
|
|
4504
|
+
});
|
|
4505
|
+
}
|
|
4488
4506
|
});
|
|
4489
4507
|
ws.on("close", () => {
|
|
4490
4508
|
manager.removeClient(ws);
|
|
@@ -4521,7 +4539,31 @@ function repoPrefix(cwd) {
|
|
|
4521
4539
|
|
|
4522
4540
|
// src/commands/sessions/web/spawnPty.ts
|
|
4523
4541
|
import * as pty from "node-pty";
|
|
4542
|
+
|
|
4543
|
+
// src/commands/sessions/web/ensureSpawnHelperExecutable.ts
|
|
4544
|
+
import { chmodSync, existsSync as existsSync21, statSync } from "fs";
|
|
4545
|
+
import { createRequire as createRequire3 } from "module";
|
|
4546
|
+
import path19 from "path";
|
|
4547
|
+
var require4 = createRequire3(import.meta.url);
|
|
4548
|
+
var ensured = false;
|
|
4549
|
+
function ensureSpawnHelperExecutable() {
|
|
4550
|
+
if (ensured || process.platform !== "darwin") return;
|
|
4551
|
+
ensured = true;
|
|
4552
|
+
const ptyRoot = path19.join(path19.dirname(require4.resolve("node-pty")), "..");
|
|
4553
|
+
const helper = path19.join(
|
|
4554
|
+
ptyRoot,
|
|
4555
|
+
"prebuilds",
|
|
4556
|
+
`${process.platform}-${process.arch}`,
|
|
4557
|
+
"spawn-helper"
|
|
4558
|
+
);
|
|
4559
|
+
if (!existsSync21(helper)) return;
|
|
4560
|
+
const mode = statSync(helper).mode;
|
|
4561
|
+
if ((mode & 73) === 0) chmodSync(helper, mode | 493);
|
|
4562
|
+
}
|
|
4563
|
+
|
|
4564
|
+
// src/commands/sessions/web/spawnPty.ts
|
|
4524
4565
|
function spawnPty(args, cwd) {
|
|
4566
|
+
ensureSpawnHelperExecutable();
|
|
4525
4567
|
const shell = process.platform === "win32" ? "cmd.exe" : process.env.SHELL ?? "bash";
|
|
4526
4568
|
const shellArgs = process.platform === "win32" ? ["/c", ...args] : ["-c", `exec ${args.map(shellEscape).join(" ")}`];
|
|
4527
4569
|
return pty.spawn(shell, shellArgs, {
|
|
@@ -4614,11 +4656,11 @@ function resumeSession(id, sessionId, cwd, name) {
|
|
|
4614
4656
|
// src/commands/sessions/web/discoverSessions.ts
|
|
4615
4657
|
import * as fs12 from "fs";
|
|
4616
4658
|
import * as os from "os";
|
|
4617
|
-
import * as
|
|
4659
|
+
import * as path21 from "path";
|
|
4618
4660
|
|
|
4619
4661
|
// src/commands/sessions/web/parseSessionFile.ts
|
|
4620
4662
|
import * as fs11 from "fs";
|
|
4621
|
-
import * as
|
|
4663
|
+
import * as path20 from "path";
|
|
4622
4664
|
|
|
4623
4665
|
// src/commands/sessions/web/extractSessionMeta.ts
|
|
4624
4666
|
function extractSessionMeta(lines) {
|
|
@@ -4664,7 +4706,7 @@ async function parseSessionFile(filePath) {
|
|
|
4664
4706
|
const meta = extractSessionMeta(lines);
|
|
4665
4707
|
if (!meta.sessionId) return null;
|
|
4666
4708
|
const timestamp = meta.timestamp || (await fs11.promises.stat(filePath)).mtime.toISOString();
|
|
4667
|
-
const project = meta.cwd ?
|
|
4709
|
+
const project = meta.cwd ? path20.basename(meta.cwd) : dirNameToProject(filePath);
|
|
4668
4710
|
return {
|
|
4669
4711
|
sessionId: meta.sessionId,
|
|
4670
4712
|
name: meta.name || `Session ${meta.sessionId.slice(0, 8)}`,
|
|
@@ -4679,14 +4721,14 @@ async function parseSessionFile(filePath) {
|
|
|
4679
4721
|
}
|
|
4680
4722
|
}
|
|
4681
4723
|
function dirNameToProject(filePath) {
|
|
4682
|
-
const dirName =
|
|
4724
|
+
const dirName = path20.basename(path20.dirname(filePath));
|
|
4683
4725
|
const parts = dirName.split("--");
|
|
4684
4726
|
return parts[parts.length - 1].replace(/-/g, "/");
|
|
4685
4727
|
}
|
|
4686
4728
|
|
|
4687
4729
|
// src/commands/sessions/web/discoverSessions.ts
|
|
4688
4730
|
async function discoverSessionJsonlPaths() {
|
|
4689
|
-
const projectsDir =
|
|
4731
|
+
const projectsDir = path21.join(os.homedir(), ".claude", "projects");
|
|
4690
4732
|
let projectDirs;
|
|
4691
4733
|
try {
|
|
4692
4734
|
projectDirs = await fs12.promises.readdir(projectsDir);
|
|
@@ -4696,7 +4738,7 @@ async function discoverSessionJsonlPaths() {
|
|
|
4696
4738
|
const paths = [];
|
|
4697
4739
|
await Promise.all(
|
|
4698
4740
|
projectDirs.map(async (dirName) => {
|
|
4699
|
-
const dirPath =
|
|
4741
|
+
const dirPath = path21.join(projectsDir, dirName);
|
|
4700
4742
|
let entries;
|
|
4701
4743
|
try {
|
|
4702
4744
|
entries = await fs12.promises.readdir(dirPath);
|
|
@@ -4705,7 +4747,7 @@ async function discoverSessionJsonlPaths() {
|
|
|
4705
4747
|
}
|
|
4706
4748
|
const jsonlFiles = entries.filter((e) => e.endsWith(".jsonl"));
|
|
4707
4749
|
for (const file of jsonlFiles) {
|
|
4708
|
-
paths.push(
|
|
4750
|
+
paths.push(path21.join(dirPath, file));
|
|
4709
4751
|
}
|
|
4710
4752
|
})
|
|
4711
4753
|
);
|
|
@@ -4726,17 +4768,6 @@ async function discoverSessions() {
|
|
|
4726
4768
|
return sessions;
|
|
4727
4769
|
}
|
|
4728
4770
|
|
|
4729
|
-
// src/commands/sessions/web/wsBroadcast.ts
|
|
4730
|
-
function wsSend(ws, msg) {
|
|
4731
|
-
if (ws.readyState === ws.OPEN) ws.send(JSON.stringify(msg));
|
|
4732
|
-
}
|
|
4733
|
-
function wsBroadcast(clients, msg) {
|
|
4734
|
-
const json = JSON.stringify(msg);
|
|
4735
|
-
for (const ws of clients) {
|
|
4736
|
-
if (ws.readyState === ws.OPEN) ws.send(json);
|
|
4737
|
-
}
|
|
4738
|
-
}
|
|
4739
|
-
|
|
4740
4771
|
// src/commands/sessions/web/replayScrollback.ts
|
|
4741
4772
|
function replayScrollback(sessions, ws) {
|
|
4742
4773
|
for (const s of sessions.values()) {
|
|
@@ -5559,8 +5590,8 @@ import chalk57 from "chalk";
|
|
|
5559
5590
|
// src/commands/backlog/originDisplayName.ts
|
|
5560
5591
|
function originDisplayName(origin) {
|
|
5561
5592
|
if (origin.startsWith("local:")) {
|
|
5562
|
-
const
|
|
5563
|
-
const segments =
|
|
5593
|
+
const path53 = origin.slice("local:".length).replace(/\/+$/, "");
|
|
5594
|
+
const segments = path53.split("/").filter(Boolean);
|
|
5564
5595
|
return segments[segments.length - 1] ?? origin;
|
|
5565
5596
|
}
|
|
5566
5597
|
const firstSlash = origin.indexOf("/");
|
|
@@ -6668,7 +6699,7 @@ function extractGraphqlQuery(args) {
|
|
|
6668
6699
|
}
|
|
6669
6700
|
|
|
6670
6701
|
// src/shared/loadCliReads.ts
|
|
6671
|
-
import { existsSync as
|
|
6702
|
+
import { existsSync as existsSync22, readFileSync as readFileSync15, writeFileSync as writeFileSync14 } from "fs";
|
|
6672
6703
|
import { dirname as dirname17, resolve as resolve7 } from "path";
|
|
6673
6704
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
6674
6705
|
var __filename3 = fileURLToPath5(import.meta.url);
|
|
@@ -6676,9 +6707,9 @@ var __dirname5 = dirname17(__filename3);
|
|
|
6676
6707
|
function packageRoot() {
|
|
6677
6708
|
return __dirname5;
|
|
6678
6709
|
}
|
|
6679
|
-
function readLines(
|
|
6680
|
-
if (!
|
|
6681
|
-
return readFileSync15(
|
|
6710
|
+
function readLines(path53) {
|
|
6711
|
+
if (!existsSync22(path53)) return [];
|
|
6712
|
+
return readFileSync15(path53, "utf-8").split("\n").filter((line) => line.trim() !== "");
|
|
6682
6713
|
}
|
|
6683
6714
|
var cachedReads;
|
|
6684
6715
|
var cachedWrites;
|
|
@@ -6724,7 +6755,7 @@ function findCliWrite(command) {
|
|
|
6724
6755
|
}
|
|
6725
6756
|
|
|
6726
6757
|
// src/shared/readSettingsPerms.ts
|
|
6727
|
-
import { existsSync as
|
|
6758
|
+
import { existsSync as existsSync23, readFileSync as readFileSync16 } from "fs";
|
|
6728
6759
|
import { homedir as homedir5 } from "os";
|
|
6729
6760
|
import { join as join19 } from "path";
|
|
6730
6761
|
function readSettingsPerms(key) {
|
|
@@ -6740,7 +6771,7 @@ function readSettingsPerms(key) {
|
|
|
6740
6771
|
return entries;
|
|
6741
6772
|
}
|
|
6742
6773
|
function readPermissionArray(filePath, key) {
|
|
6743
|
-
if (!
|
|
6774
|
+
if (!existsSync23(filePath)) return [];
|
|
6744
6775
|
try {
|
|
6745
6776
|
const data = JSON.parse(readFileSync16(filePath, "utf-8"));
|
|
6746
6777
|
const arr = data?.permissions?.[key];
|
|
@@ -7022,7 +7053,7 @@ ${reasons.join("\n")}`);
|
|
|
7022
7053
|
}
|
|
7023
7054
|
|
|
7024
7055
|
// src/commands/permitCliReads/index.ts
|
|
7025
|
-
import { existsSync as
|
|
7056
|
+
import { existsSync as existsSync24, mkdirSync as mkdirSync5, readFileSync as readFileSync17, writeFileSync as writeFileSync15 } from "fs";
|
|
7026
7057
|
import { homedir as homedir6 } from "os";
|
|
7027
7058
|
import { join as join20 } from "path";
|
|
7028
7059
|
|
|
@@ -7161,14 +7192,14 @@ function showProgress(p, label2) {
|
|
|
7161
7192
|
const pct = Math.round(p.done / p.total * 100);
|
|
7162
7193
|
process.stderr.write(`\r\x1B[K[${pct}%] Scanning ${label2}...`);
|
|
7163
7194
|
}
|
|
7164
|
-
async function resolveCommand(cli,
|
|
7165
|
-
showProgress(p,
|
|
7166
|
-
const subHelp = await runHelp([cli, ...
|
|
7195
|
+
async function resolveCommand(cli, path53, description, depth, p) {
|
|
7196
|
+
showProgress(p, path53.join(" "));
|
|
7197
|
+
const subHelp = await runHelp([cli, ...path53]);
|
|
7167
7198
|
if (!subHelp || !hasSubcommands(subHelp)) {
|
|
7168
|
-
return [{ path:
|
|
7199
|
+
return [{ path: path53, description }];
|
|
7169
7200
|
}
|
|
7170
|
-
const children = await discoverAt(cli,
|
|
7171
|
-
return children.length > 0 ? children : [{ path:
|
|
7201
|
+
const children = await discoverAt(cli, path53, depth + 1, p);
|
|
7202
|
+
return children.length > 0 ? children : [{ path: path53, description }];
|
|
7172
7203
|
}
|
|
7173
7204
|
async function discoverAt(cli, parentPath, depth, p) {
|
|
7174
7205
|
if (depth > SAFETY_DEPTH) return [];
|
|
@@ -7316,9 +7347,9 @@ function logPath(cli) {
|
|
|
7316
7347
|
return join20(homedir6(), ".assist", `cli-discover-${safeName}.log`);
|
|
7317
7348
|
}
|
|
7318
7349
|
function readCache(cli) {
|
|
7319
|
-
const
|
|
7320
|
-
if (!
|
|
7321
|
-
return readFileSync17(
|
|
7350
|
+
const path53 = logPath(cli);
|
|
7351
|
+
if (!existsSync24(path53)) return void 0;
|
|
7352
|
+
return readFileSync17(path53, "utf-8");
|
|
7322
7353
|
}
|
|
7323
7354
|
function writeCache(cli, output) {
|
|
7324
7355
|
const dir = join20(homedir6(), ".assist");
|
|
@@ -7457,13 +7488,13 @@ import chalk80 from "chalk";
|
|
|
7457
7488
|
|
|
7458
7489
|
// src/commands/complexity/shared/index.ts
|
|
7459
7490
|
import fs14 from "fs";
|
|
7460
|
-
import
|
|
7491
|
+
import path23 from "path";
|
|
7461
7492
|
import chalk79 from "chalk";
|
|
7462
7493
|
import ts5 from "typescript";
|
|
7463
7494
|
|
|
7464
7495
|
// src/commands/complexity/findSourceFiles.ts
|
|
7465
7496
|
import fs13 from "fs";
|
|
7466
|
-
import
|
|
7497
|
+
import path22 from "path";
|
|
7467
7498
|
import { minimatch as minimatch3 } from "minimatch";
|
|
7468
7499
|
function applyIgnoreGlobs(files) {
|
|
7469
7500
|
const { complexity } = loadConfig();
|
|
@@ -7478,7 +7509,7 @@ function walk(dir, results) {
|
|
|
7478
7509
|
const extensions = [".ts", ".tsx"];
|
|
7479
7510
|
const entries = fs13.readdirSync(dir, { withFileTypes: true });
|
|
7480
7511
|
for (const entry of entries) {
|
|
7481
|
-
const fullPath =
|
|
7512
|
+
const fullPath = path22.join(dir, entry.name);
|
|
7482
7513
|
if (entry.isDirectory()) {
|
|
7483
7514
|
if (entry.name !== "node_modules" && entry.name !== ".git") {
|
|
7484
7515
|
walk(fullPath, results);
|
|
@@ -7694,7 +7725,7 @@ function countSloc(content) {
|
|
|
7694
7725
|
function createSourceFromFile(filePath) {
|
|
7695
7726
|
const content = fs14.readFileSync(filePath, "utf-8");
|
|
7696
7727
|
return ts5.createSourceFile(
|
|
7697
|
-
|
|
7728
|
+
path23.basename(filePath),
|
|
7698
7729
|
content,
|
|
7699
7730
|
ts5.ScriptTarget.Latest,
|
|
7700
7731
|
true,
|
|
@@ -7983,8 +8014,8 @@ function stepIntoNested(container, key, nextKey) {
|
|
|
7983
8014
|
}
|
|
7984
8015
|
return ensureObject(container, resolved);
|
|
7985
8016
|
}
|
|
7986
|
-
function setNestedValue(obj,
|
|
7987
|
-
const keys =
|
|
8017
|
+
function setNestedValue(obj, path53, value) {
|
|
8018
|
+
const keys = path53.split(".");
|
|
7988
8019
|
const result = { ...obj };
|
|
7989
8020
|
let current = result;
|
|
7990
8021
|
for (let i = 0; i < keys.length - 1; i++) {
|
|
@@ -8064,9 +8095,9 @@ function isTraversable(value) {
|
|
|
8064
8095
|
function stepInto(current, key) {
|
|
8065
8096
|
return isTraversable(current) ? current[key] : void 0;
|
|
8066
8097
|
}
|
|
8067
|
-
function getNestedValue(obj,
|
|
8098
|
+
function getNestedValue(obj, path53) {
|
|
8068
8099
|
let current = obj;
|
|
8069
|
-
for (const key of
|
|
8100
|
+
for (const key of path53.split(".")) current = stepInto(current, key);
|
|
8070
8101
|
return current;
|
|
8071
8102
|
}
|
|
8072
8103
|
|
|
@@ -8100,7 +8131,7 @@ function registerConfig(program2) {
|
|
|
8100
8131
|
}
|
|
8101
8132
|
|
|
8102
8133
|
// src/commands/deploy/redirect.ts
|
|
8103
|
-
import { existsSync as
|
|
8134
|
+
import { existsSync as existsSync25, readFileSync as readFileSync18, writeFileSync as writeFileSync16 } from "fs";
|
|
8104
8135
|
import chalk87 from "chalk";
|
|
8105
8136
|
var TRAILING_SLASH_SCRIPT = ` <script>
|
|
8106
8137
|
if (!window.location.pathname.endsWith('/')) {
|
|
@@ -8109,7 +8140,7 @@ var TRAILING_SLASH_SCRIPT = ` <script>
|
|
|
8109
8140
|
</script>`;
|
|
8110
8141
|
function redirect() {
|
|
8111
8142
|
const indexPath = "index.html";
|
|
8112
|
-
if (!
|
|
8143
|
+
if (!existsSync25(indexPath)) {
|
|
8113
8144
|
console.log(chalk87.yellow("No index.html found"));
|
|
8114
8145
|
return;
|
|
8115
8146
|
}
|
|
@@ -8155,7 +8186,7 @@ import { execSync as execSync20 } from "child_process";
|
|
|
8155
8186
|
import chalk88 from "chalk";
|
|
8156
8187
|
|
|
8157
8188
|
// src/shared/getRepoName.ts
|
|
8158
|
-
import { existsSync as
|
|
8189
|
+
import { existsSync as existsSync26, readFileSync as readFileSync19 } from "fs";
|
|
8159
8190
|
import { basename as basename5, join as join22 } from "path";
|
|
8160
8191
|
function getRepoName() {
|
|
8161
8192
|
const config = loadConfig();
|
|
@@ -8163,7 +8194,7 @@ function getRepoName() {
|
|
|
8163
8194
|
return config.devlog.name;
|
|
8164
8195
|
}
|
|
8165
8196
|
const packageJsonPath = join22(process.cwd(), "package.json");
|
|
8166
|
-
if (
|
|
8197
|
+
if (existsSync26(packageJsonPath)) {
|
|
8167
8198
|
try {
|
|
8168
8199
|
const content = readFileSync19(packageJsonPath, "utf-8");
|
|
8169
8200
|
const pkg = JSON.parse(content);
|
|
@@ -8664,15 +8695,15 @@ import { join as join25 } from "path";
|
|
|
8664
8695
|
import chalk95 from "chalk";
|
|
8665
8696
|
|
|
8666
8697
|
// src/shared/findRepoRoot.ts
|
|
8667
|
-
import { existsSync as
|
|
8668
|
-
import
|
|
8698
|
+
import { existsSync as existsSync27 } from "fs";
|
|
8699
|
+
import path24 from "path";
|
|
8669
8700
|
function findRepoRoot(dir) {
|
|
8670
8701
|
let current = dir;
|
|
8671
|
-
while (current !==
|
|
8672
|
-
if (
|
|
8702
|
+
while (current !== path24.dirname(current)) {
|
|
8703
|
+
if (existsSync27(path24.join(current, ".git"))) {
|
|
8673
8704
|
return current;
|
|
8674
8705
|
}
|
|
8675
|
-
current =
|
|
8706
|
+
current = path24.dirname(current);
|
|
8676
8707
|
}
|
|
8677
8708
|
return null;
|
|
8678
8709
|
}
|
|
@@ -8736,7 +8767,7 @@ async function checkBuildLocksCommand() {
|
|
|
8736
8767
|
|
|
8737
8768
|
// src/commands/dotnet/buildTree.ts
|
|
8738
8769
|
import { readFileSync as readFileSync21 } from "fs";
|
|
8739
|
-
import
|
|
8770
|
+
import path25 from "path";
|
|
8740
8771
|
var PROJECT_REF_RE = /<ProjectReference\s+Include="([^"]+)"/g;
|
|
8741
8772
|
function getProjectRefs(csprojPath) {
|
|
8742
8773
|
const content = readFileSync21(csprojPath, "utf-8");
|
|
@@ -8747,14 +8778,14 @@ function getProjectRefs(csprojPath) {
|
|
|
8747
8778
|
return refs;
|
|
8748
8779
|
}
|
|
8749
8780
|
function buildTree(csprojPath, repoRoot, visited = /* @__PURE__ */ new Set()) {
|
|
8750
|
-
const abs =
|
|
8751
|
-
const rel =
|
|
8781
|
+
const abs = path25.resolve(csprojPath);
|
|
8782
|
+
const rel = path25.relative(repoRoot, abs);
|
|
8752
8783
|
const node = { path: abs, relativePath: rel, children: [] };
|
|
8753
8784
|
if (visited.has(abs)) return node;
|
|
8754
8785
|
visited.add(abs);
|
|
8755
|
-
const dir =
|
|
8786
|
+
const dir = path25.dirname(abs);
|
|
8756
8787
|
for (const ref of getProjectRefs(abs)) {
|
|
8757
|
-
const childAbs =
|
|
8788
|
+
const childAbs = path25.resolve(dir, ref);
|
|
8758
8789
|
try {
|
|
8759
8790
|
readFileSync21(childAbs);
|
|
8760
8791
|
node.children.push(buildTree(childAbs, repoRoot, visited));
|
|
@@ -8781,8 +8812,8 @@ function collectAllDeps(node) {
|
|
|
8781
8812
|
}
|
|
8782
8813
|
|
|
8783
8814
|
// src/commands/dotnet/findContainingSolutions.ts
|
|
8784
|
-
import { readdirSync as readdirSync3, readFileSync as readFileSync22, statSync } from "fs";
|
|
8785
|
-
import
|
|
8815
|
+
import { readdirSync as readdirSync3, readFileSync as readFileSync22, statSync as statSync2 } from "fs";
|
|
8816
|
+
import path26 from "path";
|
|
8786
8817
|
function findSlnFiles(dir, maxDepth, depth = 0) {
|
|
8787
8818
|
if (depth > maxDepth) return [];
|
|
8788
8819
|
const results = [];
|
|
@@ -8795,9 +8826,9 @@ function findSlnFiles(dir, maxDepth, depth = 0) {
|
|
|
8795
8826
|
for (const entry of entries) {
|
|
8796
8827
|
if (entry.startsWith(".") || entry === "node_modules" || entry === "packages")
|
|
8797
8828
|
continue;
|
|
8798
|
-
const full =
|
|
8829
|
+
const full = path26.join(dir, entry);
|
|
8799
8830
|
try {
|
|
8800
|
-
const stat =
|
|
8831
|
+
const stat = statSync2(full);
|
|
8801
8832
|
if (stat.isFile() && entry.endsWith(".sln")) {
|
|
8802
8833
|
results.push(full);
|
|
8803
8834
|
} else if (stat.isDirectory()) {
|
|
@@ -8809,8 +8840,8 @@ function findSlnFiles(dir, maxDepth, depth = 0) {
|
|
|
8809
8840
|
return results;
|
|
8810
8841
|
}
|
|
8811
8842
|
function findContainingSolutions(csprojPath, repoRoot) {
|
|
8812
|
-
const csprojAbs =
|
|
8813
|
-
const csprojBasename =
|
|
8843
|
+
const csprojAbs = path26.resolve(csprojPath);
|
|
8844
|
+
const csprojBasename = path26.basename(csprojAbs);
|
|
8814
8845
|
const slnFiles = findSlnFiles(repoRoot, 3);
|
|
8815
8846
|
const matches = [];
|
|
8816
8847
|
const pattern2 = new RegExp(`[\\\\"/]${escapeRegex(csprojBasename)}"`);
|
|
@@ -8818,7 +8849,7 @@ function findContainingSolutions(csprojPath, repoRoot) {
|
|
|
8818
8849
|
try {
|
|
8819
8850
|
const content = readFileSync22(sln, "utf-8");
|
|
8820
8851
|
if (pattern2.test(content)) {
|
|
8821
|
-
matches.push(
|
|
8852
|
+
matches.push(path26.relative(repoRoot, sln));
|
|
8822
8853
|
}
|
|
8823
8854
|
} catch {
|
|
8824
8855
|
}
|
|
@@ -8880,16 +8911,16 @@ function printJson(tree, totalCount, solutions) {
|
|
|
8880
8911
|
}
|
|
8881
8912
|
|
|
8882
8913
|
// src/commands/dotnet/resolveCsproj.ts
|
|
8883
|
-
import { existsSync as
|
|
8884
|
-
import
|
|
8914
|
+
import { existsSync as existsSync28 } from "fs";
|
|
8915
|
+
import path27 from "path";
|
|
8885
8916
|
import chalk97 from "chalk";
|
|
8886
8917
|
function resolveCsproj(csprojPath) {
|
|
8887
|
-
const resolved =
|
|
8888
|
-
if (!
|
|
8918
|
+
const resolved = path27.resolve(csprojPath);
|
|
8919
|
+
if (!existsSync28(resolved)) {
|
|
8889
8920
|
console.error(chalk97.red(`File not found: ${resolved}`));
|
|
8890
8921
|
process.exit(1);
|
|
8891
8922
|
}
|
|
8892
|
-
const repoRoot = findRepoRoot(
|
|
8923
|
+
const repoRoot = findRepoRoot(path27.dirname(resolved));
|
|
8893
8924
|
if (!repoRoot) {
|
|
8894
8925
|
console.error(chalk97.red("Could not find git repository root"));
|
|
8895
8926
|
process.exit(1);
|
|
@@ -9053,8 +9084,8 @@ function filterIssues(issues, all, cliOnly, cliSuppress) {
|
|
|
9053
9084
|
}
|
|
9054
9085
|
|
|
9055
9086
|
// src/commands/dotnet/resolveSolution.ts
|
|
9056
|
-
import { existsSync as
|
|
9057
|
-
import
|
|
9087
|
+
import { existsSync as existsSync29 } from "fs";
|
|
9088
|
+
import path28 from "path";
|
|
9058
9089
|
import chalk101 from "chalk";
|
|
9059
9090
|
|
|
9060
9091
|
// src/commands/dotnet/findSolution.ts
|
|
@@ -9093,8 +9124,8 @@ function findSolution() {
|
|
|
9093
9124
|
// src/commands/dotnet/resolveSolution.ts
|
|
9094
9125
|
function resolveSolution(sln) {
|
|
9095
9126
|
if (sln) {
|
|
9096
|
-
const resolved =
|
|
9097
|
-
if (!
|
|
9127
|
+
const resolved = path28.resolve(sln);
|
|
9128
|
+
if (!existsSync29(resolved)) {
|
|
9098
9129
|
console.error(chalk101.red(`Solution file not found: ${resolved}`));
|
|
9099
9130
|
process.exit(1);
|
|
9100
9131
|
}
|
|
@@ -9134,9 +9165,9 @@ function parseInspectReport(json) {
|
|
|
9134
9165
|
|
|
9135
9166
|
// src/commands/dotnet/runInspectCode.ts
|
|
9136
9167
|
import { execSync as execSync24 } from "child_process";
|
|
9137
|
-
import { existsSync as
|
|
9168
|
+
import { existsSync as existsSync30, readFileSync as readFileSync23, unlinkSync as unlinkSync5 } from "fs";
|
|
9138
9169
|
import { tmpdir as tmpdir3 } from "os";
|
|
9139
|
-
import
|
|
9170
|
+
import path29 from "path";
|
|
9140
9171
|
import chalk102 from "chalk";
|
|
9141
9172
|
function assertJbInstalled() {
|
|
9142
9173
|
try {
|
|
@@ -9150,7 +9181,7 @@ function assertJbInstalled() {
|
|
|
9150
9181
|
}
|
|
9151
9182
|
}
|
|
9152
9183
|
function runInspectCode(slnPath, include, swea) {
|
|
9153
|
-
const reportPath =
|
|
9184
|
+
const reportPath = path29.join(tmpdir3(), `inspect-${Date.now()}.xml`);
|
|
9154
9185
|
const includeFlag = include ? ` --include="${include}"` : "";
|
|
9155
9186
|
const sweaFlag = swea ? " --swea" : "";
|
|
9156
9187
|
try {
|
|
@@ -9165,7 +9196,7 @@ function runInspectCode(slnPath, include, swea) {
|
|
|
9165
9196
|
console.error(chalk102.red("jb inspectcode failed"));
|
|
9166
9197
|
process.exit(1);
|
|
9167
9198
|
}
|
|
9168
|
-
if (!
|
|
9199
|
+
if (!existsSync30(reportPath)) {
|
|
9169
9200
|
console.error(chalk102.red("Report file not generated"));
|
|
9170
9201
|
process.exit(1);
|
|
9171
9202
|
}
|
|
@@ -9486,7 +9517,7 @@ function registerGithub(program2) {
|
|
|
9486
9517
|
}
|
|
9487
9518
|
|
|
9488
9519
|
// src/commands/handover/archive.ts
|
|
9489
|
-
import { existsSync as
|
|
9520
|
+
import { existsSync as existsSync31, mkdirSync as mkdirSync6, renameSync as renameSync2 } from "fs";
|
|
9490
9521
|
import { join as join29 } from "path";
|
|
9491
9522
|
|
|
9492
9523
|
// src/commands/handover/formatArchiveTimestamp.ts
|
|
@@ -9515,14 +9546,14 @@ function buildArchiveFilename(timestamp, suffix) {
|
|
|
9515
9546
|
}
|
|
9516
9547
|
function resolveCollisionPath(archiveDir, timestamp, suffix) {
|
|
9517
9548
|
const initial = join29(archiveDir, buildArchiveFilename(timestamp, suffix));
|
|
9518
|
-
if (!
|
|
9549
|
+
if (!existsSync31(initial)) return initial;
|
|
9519
9550
|
for (let i = 1; i <= MAX_COLLISION_SUFFIX; i++) {
|
|
9520
9551
|
const collisionSuffix = suffix ? `${suffix}-${i}` : `${i}`;
|
|
9521
9552
|
const candidate = join29(
|
|
9522
9553
|
archiveDir,
|
|
9523
9554
|
buildArchiveFilename(timestamp, collisionSuffix)
|
|
9524
9555
|
);
|
|
9525
|
-
if (!
|
|
9556
|
+
if (!existsSync31(candidate)) return candidate;
|
|
9526
9557
|
}
|
|
9527
9558
|
throw new Error(
|
|
9528
9559
|
`Exhausted collision suffixes (1-${MAX_COLLISION_SUFFIX}) for ${timestamp}`
|
|
@@ -9531,7 +9562,7 @@ function resolveCollisionPath(archiveDir, timestamp, suffix) {
|
|
|
9531
9562
|
function archive(options2 = {}) {
|
|
9532
9563
|
const cwd = options2.cwd ?? process.cwd();
|
|
9533
9564
|
const handoverPath = getHandoverPath(cwd);
|
|
9534
|
-
if (!
|
|
9565
|
+
if (!existsSync31(handoverPath)) return void 0;
|
|
9535
9566
|
const archiveDir = getHandoverArchiveDir(cwd);
|
|
9536
9567
|
mkdirSync6(archiveDir, { recursive: true });
|
|
9537
9568
|
const timestamp = formatArchiveTimestamp(options2.now);
|
|
@@ -9545,7 +9576,7 @@ function archive(options2 = {}) {
|
|
|
9545
9576
|
}
|
|
9546
9577
|
|
|
9547
9578
|
// src/commands/handover/load.ts
|
|
9548
|
-
import { existsSync as
|
|
9579
|
+
import { existsSync as existsSync32, readFileSync as readFileSync25 } from "fs";
|
|
9549
9580
|
|
|
9550
9581
|
// src/commands/handover/parseLoadInput.ts
|
|
9551
9582
|
async function parseLoadInput(stdin) {
|
|
@@ -9660,7 +9691,7 @@ function normaliseOutput(raw) {
|
|
|
9660
9691
|
// src/commands/handover/load.ts
|
|
9661
9692
|
function loadFromHandover(cwd) {
|
|
9662
9693
|
const handoverPath = getHandoverPath(cwd);
|
|
9663
|
-
if (!
|
|
9694
|
+
if (!existsSync32(handoverPath)) return void 0;
|
|
9664
9695
|
const content = readFileSync25(handoverPath, "utf-8");
|
|
9665
9696
|
archive({ cwd });
|
|
9666
9697
|
return {
|
|
@@ -9828,7 +9859,7 @@ function acceptanceCriteria(issueKey) {
|
|
|
9828
9859
|
import { execSync as execSync27 } from "child_process";
|
|
9829
9860
|
|
|
9830
9861
|
// src/shared/loadJson.ts
|
|
9831
|
-
import { existsSync as
|
|
9862
|
+
import { existsSync as existsSync33, mkdirSync as mkdirSync7, readFileSync as readFileSync26, writeFileSync as writeFileSync19 } from "fs";
|
|
9832
9863
|
import { homedir as homedir8 } from "os";
|
|
9833
9864
|
import { join as join30 } from "path";
|
|
9834
9865
|
function getStoreDir() {
|
|
@@ -9838,10 +9869,10 @@ function getStorePath(filename) {
|
|
|
9838
9869
|
return join30(getStoreDir(), filename);
|
|
9839
9870
|
}
|
|
9840
9871
|
function loadJson(filename) {
|
|
9841
|
-
const
|
|
9842
|
-
if (
|
|
9872
|
+
const path53 = getStorePath(filename);
|
|
9873
|
+
if (existsSync33(path53)) {
|
|
9843
9874
|
try {
|
|
9844
|
-
return JSON.parse(readFileSync26(
|
|
9875
|
+
return JSON.parse(readFileSync26(path53, "utf-8"));
|
|
9845
9876
|
} catch {
|
|
9846
9877
|
return {};
|
|
9847
9878
|
}
|
|
@@ -9850,7 +9881,7 @@ function loadJson(filename) {
|
|
|
9850
9881
|
}
|
|
9851
9882
|
function saveJson(filename, data) {
|
|
9852
9883
|
const dir = getStoreDir();
|
|
9853
|
-
if (!
|
|
9884
|
+
if (!existsSync33(dir)) {
|
|
9854
9885
|
mkdirSync7(dir, { recursive: true });
|
|
9855
9886
|
}
|
|
9856
9887
|
writeFileSync19(getStorePath(filename), JSON.stringify(data, null, 2));
|
|
@@ -10517,15 +10548,15 @@ function postComment(vars) {
|
|
|
10517
10548
|
}
|
|
10518
10549
|
runGhGraphql(MUTATION_MULTI, { ...base, startLine });
|
|
10519
10550
|
}
|
|
10520
|
-
function comment2(
|
|
10551
|
+
function comment2(path53, line, body, startLine) {
|
|
10521
10552
|
validateBody(body);
|
|
10522
10553
|
validateLine(line);
|
|
10523
10554
|
if (startLine !== void 0) validateLine(startLine);
|
|
10524
10555
|
try {
|
|
10525
10556
|
const prId = getCurrentPrNodeId();
|
|
10526
|
-
postComment({ prId, body, path:
|
|
10557
|
+
postComment({ prId, body, path: path53, line, startLine });
|
|
10527
10558
|
const range = startLine !== void 0 ? `${startLine}-${line}` : `${line}`;
|
|
10528
|
-
console.log(`Added review comment on ${
|
|
10559
|
+
console.log(`Added review comment on ${path53}:${range}`);
|
|
10529
10560
|
} catch (error) {
|
|
10530
10561
|
if (isGhNotInstalled(error)) {
|
|
10531
10562
|
console.error("Error: GitHub CLI (gh) is not installed.");
|
|
@@ -10608,7 +10639,7 @@ import { tmpdir as tmpdir5 } from "os";
|
|
|
10608
10639
|
import { join as join32 } from "path";
|
|
10609
10640
|
|
|
10610
10641
|
// src/commands/prs/loadCommentsCache.ts
|
|
10611
|
-
import { existsSync as
|
|
10642
|
+
import { existsSync as existsSync34, readFileSync as readFileSync28, unlinkSync as unlinkSync7 } from "fs";
|
|
10612
10643
|
import { join as join31 } from "path";
|
|
10613
10644
|
import { parse as parse2 } from "yaml";
|
|
10614
10645
|
function getCachePath(prNumber) {
|
|
@@ -10616,7 +10647,7 @@ function getCachePath(prNumber) {
|
|
|
10616
10647
|
}
|
|
10617
10648
|
function loadCommentsCache(prNumber) {
|
|
10618
10649
|
const cachePath = getCachePath(prNumber);
|
|
10619
|
-
if (!
|
|
10650
|
+
if (!existsSync34(cachePath)) {
|
|
10620
10651
|
return null;
|
|
10621
10652
|
}
|
|
10622
10653
|
const content = readFileSync28(cachePath, "utf-8");
|
|
@@ -10624,7 +10655,7 @@ function loadCommentsCache(prNumber) {
|
|
|
10624
10655
|
}
|
|
10625
10656
|
function deleteCommentsCache(prNumber) {
|
|
10626
10657
|
const cachePath = getCachePath(prNumber);
|
|
10627
|
-
if (
|
|
10658
|
+
if (existsSync34(cachePath)) {
|
|
10628
10659
|
unlinkSync7(cachePath);
|
|
10629
10660
|
console.log("No more unresolved line comments. Cache dropped.");
|
|
10630
10661
|
}
|
|
@@ -10721,7 +10752,7 @@ function fixed(commentId, sha) {
|
|
|
10721
10752
|
}
|
|
10722
10753
|
|
|
10723
10754
|
// src/commands/prs/listComments/index.ts
|
|
10724
|
-
import { existsSync as
|
|
10755
|
+
import { existsSync as existsSync35, mkdirSync as mkdirSync9, writeFileSync as writeFileSync23 } from "fs";
|
|
10725
10756
|
import { join as join34 } from "path";
|
|
10726
10757
|
import { stringify } from "yaml";
|
|
10727
10758
|
|
|
@@ -10847,7 +10878,7 @@ function printComments2(result) {
|
|
|
10847
10878
|
// src/commands/prs/listComments/index.ts
|
|
10848
10879
|
function writeCommentsCache(prNumber, comments3) {
|
|
10849
10880
|
const assistDir = join34(process.cwd(), ".assist");
|
|
10850
|
-
if (!
|
|
10881
|
+
if (!existsSync35(assistDir)) {
|
|
10851
10882
|
mkdirSync9(assistDir, { recursive: true });
|
|
10852
10883
|
}
|
|
10853
10884
|
const cacheData = {
|
|
@@ -11105,8 +11136,8 @@ function registerPrs(program2) {
|
|
|
11105
11136
|
prsCommand.command("wontfix <comment-id> <reason>").description("Reply with reason and resolve thread").action((commentId, reason) => {
|
|
11106
11137
|
wontfix(Number.parseInt(commentId, 10), reason);
|
|
11107
11138
|
});
|
|
11108
|
-
prsCommand.command("comment <path> <line> <body>").description("Add a line comment to the pending review").action((
|
|
11109
|
-
comment2(
|
|
11139
|
+
prsCommand.command("comment <path> <line> <body>").description("Add a line comment to the pending review").action((path53, line, body) => {
|
|
11140
|
+
comment2(path53, Number.parseInt(line, 10), body);
|
|
11110
11141
|
});
|
|
11111
11142
|
}
|
|
11112
11143
|
|
|
@@ -11358,10 +11389,10 @@ function resolveOpSecret(reference) {
|
|
|
11358
11389
|
}
|
|
11359
11390
|
|
|
11360
11391
|
// src/commands/ravendb/ravenFetch.ts
|
|
11361
|
-
async function ravenFetch(connection,
|
|
11392
|
+
async function ravenFetch(connection, path53) {
|
|
11362
11393
|
const apiKey = resolveOpSecret(connection.apiKeyRef);
|
|
11363
11394
|
let accessToken = await getAccessToken(apiKey);
|
|
11364
|
-
const url = `${connection.url}${
|
|
11395
|
+
const url = `${connection.url}${path53}`;
|
|
11365
11396
|
const headers = {
|
|
11366
11397
|
Authorization: `Bearer ${accessToken}`,
|
|
11367
11398
|
"Content-Type": "application/json"
|
|
@@ -11451,16 +11482,16 @@ import chalk129 from "chalk";
|
|
|
11451
11482
|
// src/commands/ravendb/buildQueryPath.ts
|
|
11452
11483
|
function buildQueryPath(opts) {
|
|
11453
11484
|
const db = encodeURIComponent(opts.db);
|
|
11454
|
-
let
|
|
11485
|
+
let path53;
|
|
11455
11486
|
if (opts.collection) {
|
|
11456
|
-
|
|
11487
|
+
path53 = `/databases/${db}/indexes/dynamic/${encodeURIComponent(opts.collection)}?start=${opts.start}&pageSize=${opts.pageSize}&sort=${encodeURIComponent(opts.sort)}`;
|
|
11457
11488
|
} else {
|
|
11458
|
-
|
|
11489
|
+
path53 = `/databases/${db}/queries?start=${opts.start}&pageSize=${opts.pageSize}`;
|
|
11459
11490
|
}
|
|
11460
11491
|
if (opts.query) {
|
|
11461
|
-
|
|
11492
|
+
path53 += `&query=${encodeURIComponent(opts.query)}`;
|
|
11462
11493
|
}
|
|
11463
|
-
return
|
|
11494
|
+
return path53;
|
|
11464
11495
|
}
|
|
11465
11496
|
|
|
11466
11497
|
// src/commands/ravendb/fetchAllPages.ts
|
|
@@ -11469,7 +11500,7 @@ async function fetchAllPages(connection, opts) {
|
|
|
11469
11500
|
let start3 = 0;
|
|
11470
11501
|
while (true) {
|
|
11471
11502
|
const effectivePageSize = opts.limit !== void 0 ? Math.min(opts.pageSize, opts.limit - allResults.length) : opts.pageSize;
|
|
11472
|
-
const
|
|
11503
|
+
const path53 = buildQueryPath({
|
|
11473
11504
|
db: connection.database,
|
|
11474
11505
|
collection: opts.collection,
|
|
11475
11506
|
start: start3,
|
|
@@ -11477,7 +11508,7 @@ async function fetchAllPages(connection, opts) {
|
|
|
11477
11508
|
sort: opts.sort,
|
|
11478
11509
|
query: opts.query
|
|
11479
11510
|
});
|
|
11480
|
-
const data = await ravenFetch(connection,
|
|
11511
|
+
const data = await ravenFetch(connection, path53);
|
|
11481
11512
|
const results = data.Results ?? [];
|
|
11482
11513
|
const totalResults = data.TotalResults ?? 0;
|
|
11483
11514
|
if (results.length === 0) break;
|
|
@@ -11534,7 +11565,7 @@ function registerRavendb(program2) {
|
|
|
11534
11565
|
|
|
11535
11566
|
// src/commands/refactor/check/index.ts
|
|
11536
11567
|
import { spawn as spawn5 } from "child_process";
|
|
11537
|
-
import * as
|
|
11568
|
+
import * as path30 from "path";
|
|
11538
11569
|
|
|
11539
11570
|
// src/commands/refactor/logViolations.ts
|
|
11540
11571
|
import chalk131 from "chalk";
|
|
@@ -11711,7 +11742,7 @@ ${failed2.length} verify script(s) failed:`);
|
|
|
11711
11742
|
async function runVerifyQuietly() {
|
|
11712
11743
|
const result = findPackageJsonWithVerifyScripts(process.cwd());
|
|
11713
11744
|
if (!result) return true;
|
|
11714
|
-
const packageDir =
|
|
11745
|
+
const packageDir = path30.dirname(result.packageJsonPath);
|
|
11715
11746
|
const results = await Promise.all(
|
|
11716
11747
|
result.verifyScripts.map((script) => runScript(script, packageDir))
|
|
11717
11748
|
);
|
|
@@ -11737,7 +11768,7 @@ async function check(pattern2, options2) {
|
|
|
11737
11768
|
}
|
|
11738
11769
|
|
|
11739
11770
|
// src/commands/refactor/extract/index.ts
|
|
11740
|
-
import
|
|
11771
|
+
import path37 from "path";
|
|
11741
11772
|
import chalk134 from "chalk";
|
|
11742
11773
|
|
|
11743
11774
|
// src/commands/refactor/extract/applyExtraction.ts
|
|
@@ -12190,9 +12221,9 @@ function buildDestinationContent(functionTexts, imports, sourceRelativePath, sou
|
|
|
12190
12221
|
}
|
|
12191
12222
|
|
|
12192
12223
|
// src/commands/refactor/extract/getRelativeImportPath.ts
|
|
12193
|
-
import
|
|
12224
|
+
import path31 from "path";
|
|
12194
12225
|
function getRelativeImportPath(from, to) {
|
|
12195
|
-
let rel =
|
|
12226
|
+
let rel = path31.relative(path31.dirname(from), to).replace(/\.tsx?$/, "").replace(/\\/g, "/");
|
|
12196
12227
|
if (!rel.startsWith(".")) rel = `./${rel}`;
|
|
12197
12228
|
return rel;
|
|
12198
12229
|
}
|
|
@@ -12216,9 +12247,9 @@ function findImporters(functionName, sourceFile, destPath, project) {
|
|
|
12216
12247
|
}
|
|
12217
12248
|
|
|
12218
12249
|
// src/commands/refactor/extract/resolveBarrel.ts
|
|
12219
|
-
import
|
|
12250
|
+
import path32 from "path";
|
|
12220
12251
|
function resolveBarrel(functionName, sourcePath, destPath, project) {
|
|
12221
|
-
const indexPath =
|
|
12252
|
+
const indexPath = path32.join(path32.dirname(destPath), "index.ts");
|
|
12222
12253
|
const barrel = project.getSourceFile(indexPath);
|
|
12223
12254
|
if (!barrel) return { barrel: void 0, barrelRelPath: "" };
|
|
12224
12255
|
const sourceRelFromBarrel = getRelativeImportPath(indexPath, sourcePath);
|
|
@@ -12236,15 +12267,15 @@ function resolveBarrel(functionName, sourcePath, destPath, project) {
|
|
|
12236
12267
|
}
|
|
12237
12268
|
|
|
12238
12269
|
// src/commands/refactor/extract/rewriteImportPaths.ts
|
|
12239
|
-
import
|
|
12270
|
+
import path33 from "path";
|
|
12240
12271
|
function rewriteImportPaths(imports, sourcePath, destPath) {
|
|
12241
|
-
const sourceDir =
|
|
12242
|
-
const destDir =
|
|
12272
|
+
const sourceDir = path33.dirname(sourcePath);
|
|
12273
|
+
const destDir = path33.dirname(destPath);
|
|
12243
12274
|
return imports.map((imp) => {
|
|
12244
12275
|
if (!imp.moduleSpecifier.startsWith(".")) return imp;
|
|
12245
|
-
const absolute =
|
|
12246
|
-
let rel =
|
|
12247
|
-
if (rel === "") rel = `../${
|
|
12276
|
+
const absolute = path33.resolve(sourceDir, imp.moduleSpecifier);
|
|
12277
|
+
let rel = path33.relative(destDir, absolute).replace(/\\/g, "/");
|
|
12278
|
+
if (rel === "") rel = `../${path33.basename(absolute)}`;
|
|
12248
12279
|
else if (!rel.startsWith(".")) rel = `./${rel}`;
|
|
12249
12280
|
return { ...imp, moduleSpecifier: rel };
|
|
12250
12281
|
});
|
|
@@ -12312,7 +12343,7 @@ function buildPlan2(functionName, sourceFile, sourcePath, destPath, project) {
|
|
|
12312
12343
|
}
|
|
12313
12344
|
|
|
12314
12345
|
// src/commands/refactor/extract/displayPlan.ts
|
|
12315
|
-
import
|
|
12346
|
+
import path34 from "path";
|
|
12316
12347
|
import chalk132 from "chalk";
|
|
12317
12348
|
function section(title) {
|
|
12318
12349
|
return `
|
|
@@ -12322,7 +12353,7 @@ function displayImporters(plan2, cwd) {
|
|
|
12322
12353
|
if (plan2.importersToUpdate.length === 0) return;
|
|
12323
12354
|
console.log(section("Update importers:"));
|
|
12324
12355
|
for (const imp of plan2.importersToUpdate) {
|
|
12325
|
-
const rel =
|
|
12356
|
+
const rel = path34.relative(cwd, imp.file.getFilePath());
|
|
12326
12357
|
console.log(` ${chalk132.dim(rel)}: \u2192 import from "${imp.relPath}"`);
|
|
12327
12358
|
}
|
|
12328
12359
|
}
|
|
@@ -12362,16 +12393,16 @@ function displayPlan(functionName, relDest, plan2, cwd) {
|
|
|
12362
12393
|
}
|
|
12363
12394
|
|
|
12364
12395
|
// src/commands/refactor/extract/loadProjectFile.ts
|
|
12365
|
-
import
|
|
12396
|
+
import path36 from "path";
|
|
12366
12397
|
import chalk133 from "chalk";
|
|
12367
12398
|
import { Project as Project3 } from "ts-morph";
|
|
12368
12399
|
|
|
12369
12400
|
// src/commands/refactor/extract/findTsConfig.ts
|
|
12370
12401
|
import fs20 from "fs";
|
|
12371
|
-
import
|
|
12402
|
+
import path35 from "path";
|
|
12372
12403
|
import { Project as Project2 } from "ts-morph";
|
|
12373
12404
|
function findTsConfig(sourcePath) {
|
|
12374
|
-
const rootConfig =
|
|
12405
|
+
const rootConfig = path35.resolve("tsconfig.json");
|
|
12375
12406
|
if (!fs20.existsSync(rootConfig)) return rootConfig;
|
|
12376
12407
|
const tried = /* @__PURE__ */ new Set();
|
|
12377
12408
|
const candidates = [rootConfig, ...readReferences(rootConfig)];
|
|
@@ -12380,7 +12411,7 @@ function findTsConfig(sourcePath) {
|
|
|
12380
12411
|
tried.add(candidate);
|
|
12381
12412
|
if (projectIncludes(candidate, sourcePath)) return candidate;
|
|
12382
12413
|
}
|
|
12383
|
-
const siblings = fs20.readdirSync(
|
|
12414
|
+
const siblings = fs20.readdirSync(path35.dirname(rootConfig)).filter((f) => /^tsconfig.*\.json$/.test(f)).map((f) => path35.resolve(path35.dirname(rootConfig), f));
|
|
12384
12415
|
for (const sibling of siblings) {
|
|
12385
12416
|
if (tried.has(sibling)) continue;
|
|
12386
12417
|
tried.add(sibling);
|
|
@@ -12399,10 +12430,10 @@ function readReferences(configPath) {
|
|
|
12399
12430
|
return [];
|
|
12400
12431
|
}
|
|
12401
12432
|
if (!parsed.references?.length) return [];
|
|
12402
|
-
const cwd =
|
|
12433
|
+
const cwd = path35.dirname(configPath);
|
|
12403
12434
|
return parsed.references.map((ref) => {
|
|
12404
|
-
const refPath =
|
|
12405
|
-
return fs20.statSync(refPath, { throwIfNoEntry: false })?.isDirectory() ?
|
|
12435
|
+
const refPath = path35.resolve(cwd, ref.path);
|
|
12436
|
+
return fs20.statSync(refPath, { throwIfNoEntry: false })?.isDirectory() ? path35.join(refPath, "tsconfig.json") : refPath;
|
|
12406
12437
|
}).filter((p) => fs20.existsSync(p));
|
|
12407
12438
|
}
|
|
12408
12439
|
function projectIncludes(configPath, sourcePath) {
|
|
@@ -12416,7 +12447,7 @@ function projectIncludes(configPath, sourcePath) {
|
|
|
12416
12447
|
|
|
12417
12448
|
// src/commands/refactor/extract/loadProjectFile.ts
|
|
12418
12449
|
function loadProjectFile(file) {
|
|
12419
|
-
const sourcePath =
|
|
12450
|
+
const sourcePath = path36.resolve(file);
|
|
12420
12451
|
const tsConfigPath = findTsConfig(sourcePath);
|
|
12421
12452
|
const project = new Project3({
|
|
12422
12453
|
tsConfigFilePath: tsConfigPath
|
|
@@ -12431,10 +12462,10 @@ function loadProjectFile(file) {
|
|
|
12431
12462
|
|
|
12432
12463
|
// src/commands/refactor/extract/index.ts
|
|
12433
12464
|
async function extract(file, functionName, destination, options2 = {}) {
|
|
12434
|
-
const sourcePath =
|
|
12435
|
-
const destPath =
|
|
12465
|
+
const sourcePath = path37.resolve(file);
|
|
12466
|
+
const destPath = path37.resolve(destination);
|
|
12436
12467
|
const cwd = process.cwd();
|
|
12437
|
-
const relDest =
|
|
12468
|
+
const relDest = path37.relative(cwd, destPath);
|
|
12438
12469
|
const { project, sourceFile } = loadProjectFile(file);
|
|
12439
12470
|
const plan2 = buildPlan2(
|
|
12440
12471
|
functionName,
|
|
@@ -12481,13 +12512,13 @@ function ignore(file) {
|
|
|
12481
12512
|
}
|
|
12482
12513
|
|
|
12483
12514
|
// src/commands/refactor/rename/index.ts
|
|
12484
|
-
import
|
|
12515
|
+
import path38 from "path";
|
|
12485
12516
|
import chalk136 from "chalk";
|
|
12486
12517
|
async function rename(source, destination, options2 = {}) {
|
|
12487
|
-
const destPath =
|
|
12518
|
+
const destPath = path38.resolve(destination);
|
|
12488
12519
|
const cwd = process.cwd();
|
|
12489
|
-
const relSource =
|
|
12490
|
-
const relDest =
|
|
12520
|
+
const relSource = path38.relative(cwd, path38.resolve(source));
|
|
12521
|
+
const relDest = path38.relative(cwd, destPath);
|
|
12491
12522
|
const { project, sourceFile } = loadProjectFile(source);
|
|
12492
12523
|
console.log(chalk136.bold(`Rename: ${relSource} \u2192 ${relDest}`));
|
|
12493
12524
|
if (options2.apply) {
|
|
@@ -12527,12 +12558,12 @@ function findSymbol(sourceFile, symbolName) {
|
|
|
12527
12558
|
}
|
|
12528
12559
|
|
|
12529
12560
|
// src/commands/refactor/renameSymbol/groupReferences.ts
|
|
12530
|
-
import
|
|
12561
|
+
import path39 from "path";
|
|
12531
12562
|
function groupReferences(symbol, cwd) {
|
|
12532
12563
|
const refs = symbol.findReferencesAsNodes();
|
|
12533
12564
|
const grouped = /* @__PURE__ */ new Map();
|
|
12534
12565
|
for (const ref of refs) {
|
|
12535
|
-
const refFile =
|
|
12566
|
+
const refFile = path39.relative(cwd, ref.getSourceFile().getFilePath());
|
|
12536
12567
|
const lines = grouped.get(refFile) ?? [];
|
|
12537
12568
|
if (!grouped.has(refFile)) grouped.set(refFile, lines);
|
|
12538
12569
|
lines.push(ref.getStartLineNumber());
|
|
@@ -12571,11 +12602,11 @@ Renamed ${oldName} \u2192 ${newName}`));
|
|
|
12571
12602
|
}
|
|
12572
12603
|
|
|
12573
12604
|
// src/commands/refactor/restructure/index.ts
|
|
12574
|
-
import
|
|
12605
|
+
import path48 from "path";
|
|
12575
12606
|
import chalk140 from "chalk";
|
|
12576
12607
|
|
|
12577
12608
|
// src/commands/refactor/restructure/buildImportGraph/index.ts
|
|
12578
|
-
import
|
|
12609
|
+
import path40 from "path";
|
|
12579
12610
|
import ts7 from "typescript";
|
|
12580
12611
|
|
|
12581
12612
|
// src/commands/refactor/restructure/buildImportGraph/getImportSpecifiers.ts
|
|
@@ -12602,7 +12633,7 @@ function loadParsedConfig(tsConfigPath) {
|
|
|
12602
12633
|
return ts7.parseJsonConfigFileContent(
|
|
12603
12634
|
configFile.config,
|
|
12604
12635
|
ts7.sys,
|
|
12605
|
-
|
|
12636
|
+
path40.dirname(tsConfigPath)
|
|
12606
12637
|
);
|
|
12607
12638
|
}
|
|
12608
12639
|
function addToSetMap(map, key, value) {
|
|
@@ -12618,7 +12649,7 @@ function resolveImport(specifier, filePath, options2) {
|
|
|
12618
12649
|
const resolved = ts7.resolveModuleName(specifier, filePath, options2, ts7.sys);
|
|
12619
12650
|
const resolvedPath = resolved.resolvedModule?.resolvedFileName;
|
|
12620
12651
|
if (!resolvedPath || resolvedPath.includes("node_modules")) return null;
|
|
12621
|
-
return
|
|
12652
|
+
return path40.resolve(resolvedPath);
|
|
12622
12653
|
}
|
|
12623
12654
|
function buildImportGraph(candidateFiles, tsConfigPath) {
|
|
12624
12655
|
const parsed = loadParsedConfig(tsConfigPath);
|
|
@@ -12627,7 +12658,7 @@ function buildImportGraph(candidateFiles, tsConfigPath) {
|
|
|
12627
12658
|
const importedBy = /* @__PURE__ */ new Map();
|
|
12628
12659
|
const imports = /* @__PURE__ */ new Map();
|
|
12629
12660
|
for (const sourceFile of program2.getSourceFiles()) {
|
|
12630
|
-
const filePath =
|
|
12661
|
+
const filePath = path40.resolve(sourceFile.fileName);
|
|
12631
12662
|
if (filePath.includes("node_modules")) continue;
|
|
12632
12663
|
for (const specifier of getImportSpecifiers(sourceFile)) {
|
|
12633
12664
|
const absTarget = resolveImport(specifier, filePath, parsed.options);
|
|
@@ -12641,12 +12672,12 @@ function buildImportGraph(candidateFiles, tsConfigPath) {
|
|
|
12641
12672
|
}
|
|
12642
12673
|
|
|
12643
12674
|
// src/commands/refactor/restructure/clusterDirectories.ts
|
|
12644
|
-
import
|
|
12675
|
+
import path41 from "path";
|
|
12645
12676
|
function clusterDirectories(graph) {
|
|
12646
12677
|
const dirImportedBy = /* @__PURE__ */ new Map();
|
|
12647
12678
|
for (const edge of graph.edges) {
|
|
12648
|
-
const sourceDir =
|
|
12649
|
-
const targetDir =
|
|
12679
|
+
const sourceDir = path41.dirname(edge.source);
|
|
12680
|
+
const targetDir = path41.dirname(edge.target);
|
|
12650
12681
|
if (sourceDir === targetDir) continue;
|
|
12651
12682
|
if (!graph.files.has(edge.target)) continue;
|
|
12652
12683
|
const existing = dirImportedBy.get(targetDir) ?? /* @__PURE__ */ new Set();
|
|
@@ -12674,20 +12705,20 @@ function clusterDirectories(graph) {
|
|
|
12674
12705
|
return clusters;
|
|
12675
12706
|
}
|
|
12676
12707
|
function isAncestor(ancestor, descendant) {
|
|
12677
|
-
const rel =
|
|
12708
|
+
const rel = path41.relative(ancestor, descendant);
|
|
12678
12709
|
return !rel.startsWith("..") && rel !== "";
|
|
12679
12710
|
}
|
|
12680
12711
|
|
|
12681
12712
|
// src/commands/refactor/restructure/clusterFiles.ts
|
|
12682
|
-
import
|
|
12713
|
+
import path42 from "path";
|
|
12683
12714
|
function findRootParent(file, importedBy, visited) {
|
|
12684
12715
|
const importers = importedBy.get(file);
|
|
12685
12716
|
if (!importers || importers.size !== 1) return file;
|
|
12686
12717
|
const parent = [...importers][0];
|
|
12687
|
-
const parentDir =
|
|
12688
|
-
const fileDir =
|
|
12718
|
+
const parentDir = path42.dirname(parent);
|
|
12719
|
+
const fileDir = path42.dirname(file);
|
|
12689
12720
|
if (parentDir !== fileDir) return file;
|
|
12690
|
-
if (
|
|
12721
|
+
if (path42.basename(parent, path42.extname(parent)) === "index") return file;
|
|
12691
12722
|
if (visited.has(parent)) return file;
|
|
12692
12723
|
visited.add(parent);
|
|
12693
12724
|
return findRootParent(parent, importedBy, visited);
|
|
@@ -12695,16 +12726,16 @@ function findRootParent(file, importedBy, visited) {
|
|
|
12695
12726
|
function clusterFiles(graph) {
|
|
12696
12727
|
const clusters = /* @__PURE__ */ new Map();
|
|
12697
12728
|
for (const file of graph.files) {
|
|
12698
|
-
const basename11 =
|
|
12729
|
+
const basename11 = path42.basename(file, path42.extname(file));
|
|
12699
12730
|
if (basename11 === "index") continue;
|
|
12700
12731
|
const importers = graph.importedBy.get(file);
|
|
12701
12732
|
if (!importers || importers.size !== 1) continue;
|
|
12702
12733
|
const parent = [...importers][0];
|
|
12703
12734
|
if (!graph.files.has(parent)) continue;
|
|
12704
|
-
const parentDir =
|
|
12705
|
-
const fileDir =
|
|
12735
|
+
const parentDir = path42.dirname(parent);
|
|
12736
|
+
const fileDir = path42.dirname(file);
|
|
12706
12737
|
if (parentDir !== fileDir) continue;
|
|
12707
|
-
const parentBasename =
|
|
12738
|
+
const parentBasename = path42.basename(parent, path42.extname(parent));
|
|
12708
12739
|
if (parentBasename === "index") continue;
|
|
12709
12740
|
const root = findRootParent(parent, graph.importedBy, /* @__PURE__ */ new Set([file]));
|
|
12710
12741
|
if (!root || root === file) continue;
|
|
@@ -12716,7 +12747,7 @@ function clusterFiles(graph) {
|
|
|
12716
12747
|
}
|
|
12717
12748
|
|
|
12718
12749
|
// src/commands/refactor/restructure/computeRewrites/index.ts
|
|
12719
|
-
import
|
|
12750
|
+
import path43 from "path";
|
|
12720
12751
|
|
|
12721
12752
|
// src/commands/refactor/restructure/computeRewrites/applyRewrites.ts
|
|
12722
12753
|
import fs22 from "fs";
|
|
@@ -12770,7 +12801,7 @@ function normalizeSpecifier(rel) {
|
|
|
12770
12801
|
);
|
|
12771
12802
|
}
|
|
12772
12803
|
function computeSpecifier(fromFile, toFile) {
|
|
12773
|
-
return normalizeSpecifier(
|
|
12804
|
+
return normalizeSpecifier(path43.relative(path43.dirname(fromFile), toFile));
|
|
12774
12805
|
}
|
|
12775
12806
|
function isAffected(edge, moveMap) {
|
|
12776
12807
|
return moveMap.has(edge.target) || moveMap.has(edge.source);
|
|
@@ -12814,10 +12845,10 @@ function computeRewrites(moves, edges, allProjectFiles) {
|
|
|
12814
12845
|
}
|
|
12815
12846
|
|
|
12816
12847
|
// src/commands/refactor/restructure/displayPlan.ts
|
|
12817
|
-
import
|
|
12848
|
+
import path44 from "path";
|
|
12818
12849
|
import chalk138 from "chalk";
|
|
12819
12850
|
function relPath(filePath) {
|
|
12820
|
-
return
|
|
12851
|
+
return path44.relative(process.cwd(), filePath);
|
|
12821
12852
|
}
|
|
12822
12853
|
function displayMoves(plan2) {
|
|
12823
12854
|
if (plan2.moves.length === 0) return;
|
|
@@ -12867,33 +12898,33 @@ Summary: ${plan2.moves.length} file(s) moved, ${plan2.rewrites.length} imports r
|
|
|
12867
12898
|
|
|
12868
12899
|
// src/commands/refactor/restructure/executePlan.ts
|
|
12869
12900
|
import fs23 from "fs";
|
|
12870
|
-
import
|
|
12901
|
+
import path45 from "path";
|
|
12871
12902
|
import chalk139 from "chalk";
|
|
12872
12903
|
function executePlan(plan2) {
|
|
12873
12904
|
const updatedContents = applyRewrites(plan2.rewrites);
|
|
12874
12905
|
for (const [file, content] of updatedContents) {
|
|
12875
12906
|
fs23.writeFileSync(file, content, "utf-8");
|
|
12876
12907
|
console.log(
|
|
12877
|
-
chalk139.cyan(` Rewrote imports in ${
|
|
12908
|
+
chalk139.cyan(` Rewrote imports in ${path45.relative(process.cwd(), file)}`)
|
|
12878
12909
|
);
|
|
12879
12910
|
}
|
|
12880
12911
|
for (const dir of plan2.newDirectories) {
|
|
12881
12912
|
fs23.mkdirSync(dir, { recursive: true });
|
|
12882
|
-
console.log(chalk139.green(` Created ${
|
|
12913
|
+
console.log(chalk139.green(` Created ${path45.relative(process.cwd(), dir)}/`));
|
|
12883
12914
|
}
|
|
12884
12915
|
for (const move of plan2.moves) {
|
|
12885
|
-
const targetDir =
|
|
12916
|
+
const targetDir = path45.dirname(move.to);
|
|
12886
12917
|
if (!fs23.existsSync(targetDir)) {
|
|
12887
12918
|
fs23.mkdirSync(targetDir, { recursive: true });
|
|
12888
12919
|
}
|
|
12889
12920
|
fs23.renameSync(move.from, move.to);
|
|
12890
12921
|
console.log(
|
|
12891
12922
|
chalk139.white(
|
|
12892
|
-
` Moved ${
|
|
12923
|
+
` Moved ${path45.relative(process.cwd(), move.from)} \u2192 ${path45.relative(process.cwd(), move.to)}`
|
|
12893
12924
|
)
|
|
12894
12925
|
);
|
|
12895
12926
|
}
|
|
12896
|
-
removeEmptyDirectories(plan2.moves.map((m) =>
|
|
12927
|
+
removeEmptyDirectories(plan2.moves.map((m) => path45.dirname(m.from)));
|
|
12897
12928
|
}
|
|
12898
12929
|
function removeEmptyDirectories(dirs) {
|
|
12899
12930
|
const unique = [...new Set(dirs)];
|
|
@@ -12904,7 +12935,7 @@ function removeEmptyDirectories(dirs) {
|
|
|
12904
12935
|
fs23.rmdirSync(dir);
|
|
12905
12936
|
console.log(
|
|
12906
12937
|
chalk139.dim(
|
|
12907
|
-
` Removed empty directory ${
|
|
12938
|
+
` Removed empty directory ${path45.relative(process.cwd(), dir)}`
|
|
12908
12939
|
)
|
|
12909
12940
|
);
|
|
12910
12941
|
}
|
|
@@ -12912,7 +12943,7 @@ function removeEmptyDirectories(dirs) {
|
|
|
12912
12943
|
}
|
|
12913
12944
|
|
|
12914
12945
|
// src/commands/refactor/restructure/planFileMoves/index.ts
|
|
12915
|
-
import
|
|
12946
|
+
import path47 from "path";
|
|
12916
12947
|
|
|
12917
12948
|
// src/commands/refactor/restructure/planFileMoves/shared.ts
|
|
12918
12949
|
import fs24 from "fs";
|
|
@@ -12927,9 +12958,9 @@ function checkDirConflict(result, label2, dir) {
|
|
|
12927
12958
|
|
|
12928
12959
|
// src/commands/refactor/restructure/planFileMoves/planDirectoryMoves.ts
|
|
12929
12960
|
import fs25 from "fs";
|
|
12930
|
-
import
|
|
12961
|
+
import path46 from "path";
|
|
12931
12962
|
function collectEntry(results, dir, entry) {
|
|
12932
|
-
const full =
|
|
12963
|
+
const full = path46.join(dir, entry.name);
|
|
12933
12964
|
const items2 = entry.isDirectory() ? listFilesRecursive(full) : [full];
|
|
12934
12965
|
results.push(...items2);
|
|
12935
12966
|
}
|
|
@@ -12943,15 +12974,15 @@ function listFilesRecursive(dir) {
|
|
|
12943
12974
|
}
|
|
12944
12975
|
function addDirectoryFileMoves(moves, childDir, newLocation, reason) {
|
|
12945
12976
|
for (const file of listFilesRecursive(childDir)) {
|
|
12946
|
-
const rel =
|
|
12947
|
-
moves.push({ from: file, to:
|
|
12977
|
+
const rel = path46.relative(childDir, file);
|
|
12978
|
+
moves.push({ from: file, to: path46.join(newLocation, rel), reason });
|
|
12948
12979
|
}
|
|
12949
12980
|
}
|
|
12950
12981
|
function resolveChildDest(parentDir, childDir) {
|
|
12951
|
-
return
|
|
12982
|
+
return path46.join(parentDir, path46.basename(childDir));
|
|
12952
12983
|
}
|
|
12953
12984
|
function childMoveReason(parentDir) {
|
|
12954
|
-
return `Directory only imported from ${
|
|
12985
|
+
return `Directory only imported from ${path46.basename(parentDir)}/`;
|
|
12955
12986
|
}
|
|
12956
12987
|
function registerDirectoryMove(result, childDir, dest, parentDir) {
|
|
12957
12988
|
result.directories.push(dest);
|
|
@@ -12976,7 +13007,7 @@ function planDirectoryMoves(clusters) {
|
|
|
12976
13007
|
|
|
12977
13008
|
// src/commands/refactor/restructure/planFileMoves/index.ts
|
|
12978
13009
|
function childMoveData(child, newDir, parentBase) {
|
|
12979
|
-
const to =
|
|
13010
|
+
const to = path47.join(newDir, path47.basename(child));
|
|
12980
13011
|
return { from: child, to, reason: `Only imported by ${parentBase}` };
|
|
12981
13012
|
}
|
|
12982
13013
|
function addChildMoves(moves, children, newDir, parentBase) {
|
|
@@ -12984,15 +13015,15 @@ function addChildMoves(moves, children, newDir, parentBase) {
|
|
|
12984
13015
|
moves.push(childMoveData(child, newDir, parentBase));
|
|
12985
13016
|
}
|
|
12986
13017
|
function getBaseName(filePath) {
|
|
12987
|
-
return
|
|
13018
|
+
return path47.basename(filePath, path47.extname(filePath));
|
|
12988
13019
|
}
|
|
12989
13020
|
function resolveClusterDir(parent) {
|
|
12990
|
-
return
|
|
13021
|
+
return path47.join(path47.dirname(parent), getBaseName(parent));
|
|
12991
13022
|
}
|
|
12992
13023
|
function createParentMove(parent, newDir) {
|
|
12993
13024
|
return {
|
|
12994
13025
|
from: parent,
|
|
12995
|
-
to:
|
|
13026
|
+
to: path47.join(newDir, `index${path47.extname(parent)}`),
|
|
12996
13027
|
reason: `Main module of new ${getBaseName(parent)}/ directory`
|
|
12997
13028
|
};
|
|
12998
13029
|
}
|
|
@@ -13016,7 +13047,7 @@ function planFileMoves(clusters) {
|
|
|
13016
13047
|
|
|
13017
13048
|
// src/commands/refactor/restructure/index.ts
|
|
13018
13049
|
function buildPlan3(candidateFiles, tsConfigPath) {
|
|
13019
|
-
const candidates = new Set(candidateFiles.map((f) =>
|
|
13050
|
+
const candidates = new Set(candidateFiles.map((f) => path48.resolve(f)));
|
|
13020
13051
|
const graph = buildImportGraph(candidates, tsConfigPath);
|
|
13021
13052
|
const allProjectFiles = /* @__PURE__ */ new Set([
|
|
13022
13053
|
...graph.importedBy.keys(),
|
|
@@ -13039,7 +13070,7 @@ async function restructure(pattern2, options2 = {}) {
|
|
|
13039
13070
|
console.log(chalk140.yellow("No files found matching pattern"));
|
|
13040
13071
|
return;
|
|
13041
13072
|
}
|
|
13042
|
-
const tsConfigPath =
|
|
13073
|
+
const tsConfigPath = path48.resolve("tsconfig.json");
|
|
13043
13074
|
const plan2 = buildPlan3(files, tsConfigPath);
|
|
13044
13075
|
if (plan2.moves.length === 0) {
|
|
13045
13076
|
console.log(chalk140.green("No restructuring needed"));
|
|
@@ -13631,10 +13662,10 @@ async function handlePostSynthesis(synthesisPath, options2) {
|
|
|
13631
13662
|
}
|
|
13632
13663
|
|
|
13633
13664
|
// src/commands/review/prepareReviewDir.ts
|
|
13634
|
-
import { existsSync as
|
|
13665
|
+
import { existsSync as existsSync36, mkdirSync as mkdirSync10, unlinkSync as unlinkSync10, writeFileSync as writeFileSync24 } from "fs";
|
|
13635
13666
|
function clearReviewFiles(paths) {
|
|
13636
|
-
for (const
|
|
13637
|
-
if (
|
|
13667
|
+
for (const path53 of [paths.claudePath, paths.codexPath, paths.synthesisPath]) {
|
|
13668
|
+
if (existsSync36(path53)) unlinkSync10(path53);
|
|
13638
13669
|
}
|
|
13639
13670
|
}
|
|
13640
13671
|
function prepareReviewDir(paths, requestBody, force) {
|
|
@@ -13702,11 +13733,11 @@ async function runBacklogSession(synthesisPath) {
|
|
|
13702
13733
|
}
|
|
13703
13734
|
|
|
13704
13735
|
// src/commands/review/cachedReviewerResult.ts
|
|
13705
|
-
import { statSync as
|
|
13736
|
+
import { statSync as statSync3 } from "fs";
|
|
13706
13737
|
function cachedReviewerResult(name, outputPath) {
|
|
13707
13738
|
let size;
|
|
13708
13739
|
try {
|
|
13709
|
-
size =
|
|
13740
|
+
size = statSync3(outputPath).size;
|
|
13710
13741
|
} catch {
|
|
13711
13742
|
return null;
|
|
13712
13743
|
}
|
|
@@ -13919,7 +13950,7 @@ function printReviewerFailures(results) {
|
|
|
13919
13950
|
}
|
|
13920
13951
|
|
|
13921
13952
|
// src/commands/review/runAndSynthesise.ts
|
|
13922
|
-
import { existsSync as
|
|
13953
|
+
import { existsSync as existsSync38, unlinkSync as unlinkSync12 } from "fs";
|
|
13923
13954
|
|
|
13924
13955
|
// src/commands/review/buildReviewerStdin.ts
|
|
13925
13956
|
var REVIEW_PROMPT = `You are acting as a reviewer for a proposed code change made by another engineer. The full review request \u2014 branch, base, changed files, and unified diff \u2014 is in request.md in the current working directory.
|
|
@@ -14337,7 +14368,7 @@ function resolveClaude(args) {
|
|
|
14337
14368
|
}
|
|
14338
14369
|
|
|
14339
14370
|
// src/commands/review/runCodexReviewer.ts
|
|
14340
|
-
import { existsSync as
|
|
14371
|
+
import { existsSync as existsSync37, unlinkSync as unlinkSync11 } from "fs";
|
|
14341
14372
|
|
|
14342
14373
|
// src/commands/review/parseCodexEvent.ts
|
|
14343
14374
|
function isItemStarted(value) {
|
|
@@ -14391,7 +14422,7 @@ async function runCodexReviewer(spec) {
|
|
|
14391
14422
|
reportReviewerToolUse(spec.name, event, spinner);
|
|
14392
14423
|
}
|
|
14393
14424
|
});
|
|
14394
|
-
if (result.exitCode !== 0 &&
|
|
14425
|
+
if (result.exitCode !== 0 && existsSync37(spec.outputPath)) {
|
|
14395
14426
|
unlinkSync11(spec.outputPath);
|
|
14396
14427
|
}
|
|
14397
14428
|
return finaliseReviewerRun({ ...spec, command }, spinner, result);
|
|
@@ -14539,7 +14570,7 @@ async function runAndSynthesise(args) {
|
|
|
14539
14570
|
console.error("Both reviewers failed; skipping synthesis.");
|
|
14540
14571
|
return { ok: false, failures };
|
|
14541
14572
|
}
|
|
14542
|
-
if (anyFresh &&
|
|
14573
|
+
if (anyFresh && existsSync38(paths.synthesisPath)) {
|
|
14543
14574
|
unlinkSync12(paths.synthesisPath);
|
|
14544
14575
|
}
|
|
14545
14576
|
const synthesisResult = await synthesise(paths, { multi });
|
|
@@ -14769,8 +14800,8 @@ import chalk147 from "chalk";
|
|
|
14769
14800
|
|
|
14770
14801
|
// src/commands/seq/fetchSeq.ts
|
|
14771
14802
|
import chalk144 from "chalk";
|
|
14772
|
-
async function fetchSeq(conn,
|
|
14773
|
-
const url = `${conn.url}${
|
|
14803
|
+
async function fetchSeq(conn, path53, params) {
|
|
14804
|
+
const url = `${conn.url}${path53}?${params}`;
|
|
14774
14805
|
const response = await fetch(url, {
|
|
14775
14806
|
headers: {
|
|
14776
14807
|
Accept: "application/json",
|
|
@@ -15310,7 +15341,7 @@ function registerSql(program2) {
|
|
|
15310
15341
|
}
|
|
15311
15342
|
|
|
15312
15343
|
// src/commands/transcript/shared.ts
|
|
15313
|
-
import { existsSync as
|
|
15344
|
+
import { existsSync as existsSync39, readdirSync as readdirSync6, statSync as statSync4 } from "fs";
|
|
15314
15345
|
import { basename as basename8, join as join36, relative as relative2 } from "path";
|
|
15315
15346
|
import * as readline2 from "readline";
|
|
15316
15347
|
var DATE_PREFIX_REGEX = /^\d{4}-\d{2}-\d{2}/;
|
|
@@ -15326,11 +15357,11 @@ function isValidDatePrefix(filename) {
|
|
|
15326
15357
|
return DATE_PREFIX_REGEX.test(filename);
|
|
15327
15358
|
}
|
|
15328
15359
|
function collectFiles(dir, extension) {
|
|
15329
|
-
if (!
|
|
15360
|
+
if (!existsSync39(dir)) return [];
|
|
15330
15361
|
const results = [];
|
|
15331
15362
|
for (const entry of readdirSync6(dir)) {
|
|
15332
15363
|
const fullPath = join36(dir, entry);
|
|
15333
|
-
if (
|
|
15364
|
+
if (statSync4(fullPath).isDirectory()) {
|
|
15334
15365
|
results.push(...collectFiles(fullPath, extension));
|
|
15335
15366
|
} else if (entry.endsWith(extension)) {
|
|
15336
15367
|
results.push(fullPath);
|
|
@@ -15423,7 +15454,7 @@ async function configure() {
|
|
|
15423
15454
|
}
|
|
15424
15455
|
|
|
15425
15456
|
// src/commands/transcript/format/index.ts
|
|
15426
|
-
import { existsSync as
|
|
15457
|
+
import { existsSync as existsSync41 } from "fs";
|
|
15427
15458
|
|
|
15428
15459
|
// src/commands/transcript/format/fixInvalidDatePrefixes/index.ts
|
|
15429
15460
|
import { dirname as dirname20, join as join38 } from "path";
|
|
@@ -15497,7 +15528,7 @@ async function fixInvalidDatePrefixes(vttFiles) {
|
|
|
15497
15528
|
}
|
|
15498
15529
|
|
|
15499
15530
|
// src/commands/transcript/format/processVttFile/index.ts
|
|
15500
|
-
import { existsSync as
|
|
15531
|
+
import { existsSync as existsSync40, mkdirSync as mkdirSync11, readFileSync as readFileSync31, writeFileSync as writeFileSync26 } from "fs";
|
|
15501
15532
|
import { basename as basename9, dirname as dirname21, join as join39 } from "path";
|
|
15502
15533
|
|
|
15503
15534
|
// src/commands/transcript/cleanText.ts
|
|
@@ -15722,7 +15753,7 @@ function logSkipped(relativeDir, mdFile) {
|
|
|
15722
15753
|
return "skipped";
|
|
15723
15754
|
}
|
|
15724
15755
|
function ensureDirectory(dir, label2) {
|
|
15725
|
-
if (!
|
|
15756
|
+
if (!existsSync40(dir)) {
|
|
15726
15757
|
mkdirSync11(dir, { recursive: true });
|
|
15727
15758
|
console.log(`Created ${label2}: ${dir}`);
|
|
15728
15759
|
}
|
|
@@ -15758,7 +15789,7 @@ function convertVttToMarkdown(inputPath, outputPath) {
|
|
|
15758
15789
|
logReduction(cues.length, chatMessages.length);
|
|
15759
15790
|
}
|
|
15760
15791
|
function tryProcessVtt(vttFile, paths) {
|
|
15761
|
-
if (
|
|
15792
|
+
if (existsSync40(paths.outputPath))
|
|
15762
15793
|
return logSkipped(paths.relativeDir, paths.mdFile);
|
|
15763
15794
|
convertVttToMarkdown(vttFile.absolutePath, paths.outputPath);
|
|
15764
15795
|
return "processed";
|
|
@@ -15784,7 +15815,7 @@ function processAllFiles(vttFiles, transcriptsDir) {
|
|
|
15784
15815
|
logSummary(counts);
|
|
15785
15816
|
}
|
|
15786
15817
|
function requireVttDir(vttDir) {
|
|
15787
|
-
if (!
|
|
15818
|
+
if (!existsSync41(vttDir)) {
|
|
15788
15819
|
console.error(`VTT directory not found: ${vttDir}`);
|
|
15789
15820
|
process.exit(1);
|
|
15790
15821
|
}
|
|
@@ -15816,12 +15847,12 @@ async function format() {
|
|
|
15816
15847
|
}
|
|
15817
15848
|
|
|
15818
15849
|
// src/commands/transcript/summarise/index.ts
|
|
15819
|
-
import { existsSync as
|
|
15850
|
+
import { existsSync as existsSync43 } from "fs";
|
|
15820
15851
|
import { basename as basename10, dirname as dirname23, join as join41, relative as relative3 } from "path";
|
|
15821
15852
|
|
|
15822
15853
|
// src/commands/transcript/summarise/processStagedFile/index.ts
|
|
15823
15854
|
import {
|
|
15824
|
-
existsSync as
|
|
15855
|
+
existsSync as existsSync42,
|
|
15825
15856
|
mkdirSync as mkdirSync12,
|
|
15826
15857
|
readFileSync as readFileSync32,
|
|
15827
15858
|
renameSync as renameSync4,
|
|
@@ -15858,7 +15889,7 @@ function validateStagedContent(filename, content) {
|
|
|
15858
15889
|
// src/commands/transcript/summarise/processStagedFile/index.ts
|
|
15859
15890
|
var STAGING_DIR = join40(process.cwd(), ".assist", "transcript");
|
|
15860
15891
|
function processStagedFile() {
|
|
15861
|
-
if (!
|
|
15892
|
+
if (!existsSync42(STAGING_DIR)) {
|
|
15862
15893
|
return false;
|
|
15863
15894
|
}
|
|
15864
15895
|
const stagedFiles = findMdFilesRecursive(STAGING_DIR);
|
|
@@ -15882,7 +15913,7 @@ function processStagedFile() {
|
|
|
15882
15913
|
}
|
|
15883
15914
|
const destPath = join40(summaryDir, matchingTranscript.relativePath);
|
|
15884
15915
|
const destDir = dirname22(destPath);
|
|
15885
|
-
if (!
|
|
15916
|
+
if (!existsSync42(destDir)) {
|
|
15886
15917
|
mkdirSync12(destDir, { recursive: true });
|
|
15887
15918
|
}
|
|
15888
15919
|
renameSync4(stagedFile.absolutePath, destPath);
|
|
@@ -15909,7 +15940,7 @@ function buildSummaryIndex(summaryDir) {
|
|
|
15909
15940
|
function summarise3() {
|
|
15910
15941
|
processStagedFile();
|
|
15911
15942
|
const { transcriptsDir, summaryDir } = getTranscriptConfig();
|
|
15912
|
-
if (!
|
|
15943
|
+
if (!existsSync43(transcriptsDir)) {
|
|
15913
15944
|
console.log("No transcripts directory found.");
|
|
15914
15945
|
return;
|
|
15915
15946
|
}
|
|
@@ -16016,9 +16047,9 @@ function devices() {
|
|
|
16016
16047
|
}
|
|
16017
16048
|
|
|
16018
16049
|
// src/commands/voice/logs.ts
|
|
16019
|
-
import { existsSync as
|
|
16050
|
+
import { existsSync as existsSync44, readFileSync as readFileSync33 } from "fs";
|
|
16020
16051
|
function logs(options2) {
|
|
16021
|
-
if (!
|
|
16052
|
+
if (!existsSync44(voicePaths.log)) {
|
|
16022
16053
|
console.log("No voice log file found");
|
|
16023
16054
|
return;
|
|
16024
16055
|
}
|
|
@@ -16050,7 +16081,7 @@ import { join as join45 } from "path";
|
|
|
16050
16081
|
|
|
16051
16082
|
// src/commands/voice/checkLockFile.ts
|
|
16052
16083
|
import { execSync as execSync44 } from "child_process";
|
|
16053
|
-
import { existsSync as
|
|
16084
|
+
import { existsSync as existsSync45, mkdirSync as mkdirSync13, readFileSync as readFileSync34, writeFileSync as writeFileSync27 } from "fs";
|
|
16054
16085
|
import { join as join44 } from "path";
|
|
16055
16086
|
function isProcessAlive2(pid) {
|
|
16056
16087
|
try {
|
|
@@ -16062,7 +16093,7 @@ function isProcessAlive2(pid) {
|
|
|
16062
16093
|
}
|
|
16063
16094
|
function checkLockFile() {
|
|
16064
16095
|
const lockFile = getLockFile();
|
|
16065
|
-
if (!
|
|
16096
|
+
if (!existsSync45(lockFile)) return;
|
|
16066
16097
|
try {
|
|
16067
16098
|
const lock = JSON.parse(readFileSync34(lockFile, "utf-8"));
|
|
16068
16099
|
if (lock.pid && isProcessAlive2(lock.pid)) {
|
|
@@ -16075,7 +16106,7 @@ function checkLockFile() {
|
|
|
16075
16106
|
}
|
|
16076
16107
|
}
|
|
16077
16108
|
function bootstrapVenv() {
|
|
16078
|
-
if (
|
|
16109
|
+
if (existsSync45(getVenvPython())) return;
|
|
16079
16110
|
console.log("Setting up Python environment...");
|
|
16080
16111
|
const pythonDir = getPythonDir();
|
|
16081
16112
|
execSync44(
|
|
@@ -16166,7 +16197,7 @@ function start2(options2) {
|
|
|
16166
16197
|
}
|
|
16167
16198
|
|
|
16168
16199
|
// src/commands/voice/status.ts
|
|
16169
|
-
import { existsSync as
|
|
16200
|
+
import { existsSync as existsSync46, readFileSync as readFileSync35 } from "fs";
|
|
16170
16201
|
function isProcessAlive3(pid) {
|
|
16171
16202
|
try {
|
|
16172
16203
|
process.kill(pid, 0);
|
|
@@ -16176,12 +16207,12 @@ function isProcessAlive3(pid) {
|
|
|
16176
16207
|
}
|
|
16177
16208
|
}
|
|
16178
16209
|
function readRecentLogs(count6) {
|
|
16179
|
-
if (!
|
|
16210
|
+
if (!existsSync46(voicePaths.log)) return [];
|
|
16180
16211
|
const lines = readFileSync35(voicePaths.log, "utf-8").trim().split("\n");
|
|
16181
16212
|
return lines.slice(-count6);
|
|
16182
16213
|
}
|
|
16183
16214
|
function status() {
|
|
16184
|
-
if (!
|
|
16215
|
+
if (!existsSync46(voicePaths.pid)) {
|
|
16185
16216
|
console.log("Voice daemon: not running (no PID file)");
|
|
16186
16217
|
return;
|
|
16187
16218
|
}
|
|
@@ -16204,9 +16235,9 @@ function status() {
|
|
|
16204
16235
|
}
|
|
16205
16236
|
|
|
16206
16237
|
// src/commands/voice/stop.ts
|
|
16207
|
-
import { existsSync as
|
|
16238
|
+
import { existsSync as existsSync47, readFileSync as readFileSync36, unlinkSync as unlinkSync13 } from "fs";
|
|
16208
16239
|
function stop2() {
|
|
16209
|
-
if (!
|
|
16240
|
+
if (!existsSync47(voicePaths.pid)) {
|
|
16210
16241
|
console.log("Voice daemon is not running (no PID file)");
|
|
16211
16242
|
return;
|
|
16212
16243
|
}
|
|
@@ -16223,7 +16254,7 @@ function stop2() {
|
|
|
16223
16254
|
}
|
|
16224
16255
|
try {
|
|
16225
16256
|
const lockFile = getLockFile();
|
|
16226
|
-
if (
|
|
16257
|
+
if (existsSync47(lockFile)) unlinkSync13(lockFile);
|
|
16227
16258
|
} catch {
|
|
16228
16259
|
}
|
|
16229
16260
|
console.log("Voice daemon stopped");
|
|
@@ -16445,7 +16476,7 @@ async function auth() {
|
|
|
16445
16476
|
|
|
16446
16477
|
// src/commands/roam/postRoamActivity.ts
|
|
16447
16478
|
import { execFileSync as execFileSync7 } from "child_process";
|
|
16448
|
-
import { readdirSync as readdirSync7, readFileSync as readFileSync37, statSync as
|
|
16479
|
+
import { readdirSync as readdirSync7, readFileSync as readFileSync37, statSync as statSync5 } from "fs";
|
|
16449
16480
|
import { join as join47 } from "path";
|
|
16450
16481
|
function findPortFile(roamDir) {
|
|
16451
16482
|
let entries;
|
|
@@ -16455,9 +16486,9 @@ function findPortFile(roamDir) {
|
|
|
16455
16486
|
return void 0;
|
|
16456
16487
|
}
|
|
16457
16488
|
const candidates = entries.filter((name) => /^roam-local-api(-[^.]+)?\.port$/.test(name)).map((name) => {
|
|
16458
|
-
const
|
|
16489
|
+
const path53 = join47(roamDir, name);
|
|
16459
16490
|
try {
|
|
16460
|
-
return { path:
|
|
16491
|
+
return { path: path53, mtimeMs: statSync5(path53).mtimeMs };
|
|
16461
16492
|
} catch {
|
|
16462
16493
|
return void 0;
|
|
16463
16494
|
}
|
|
@@ -16605,7 +16636,7 @@ function runPreCommands(pre, cwd) {
|
|
|
16605
16636
|
|
|
16606
16637
|
// src/commands/run/spawnRunCommand.ts
|
|
16607
16638
|
import { execFileSync as execFileSync8, spawn as spawn8 } from "child_process";
|
|
16608
|
-
import { existsSync as
|
|
16639
|
+
import { existsSync as existsSync48 } from "fs";
|
|
16609
16640
|
import { dirname as dirname25, join as join48, resolve as resolve11 } from "path";
|
|
16610
16641
|
function resolveCommand2(command) {
|
|
16611
16642
|
if (process.platform !== "win32" || command !== "bash") return command;
|
|
@@ -16613,7 +16644,7 @@ function resolveCommand2(command) {
|
|
|
16613
16644
|
const gitPath = execFileSync8("where", ["git"], { encoding: "utf8" }).trim().split("\r\n")[0];
|
|
16614
16645
|
const gitRoot = resolve11(dirname25(gitPath), "..");
|
|
16615
16646
|
const gitBash = join48(gitRoot, "bin", "bash.exe");
|
|
16616
|
-
if (
|
|
16647
|
+
if (existsSync48(gitBash)) return gitBash;
|
|
16617
16648
|
} catch {
|
|
16618
16649
|
}
|
|
16619
16650
|
return command;
|
|
@@ -16774,11 +16805,11 @@ function findLinkIndex() {
|
|
|
16774
16805
|
function parseLinkArgs() {
|
|
16775
16806
|
const idx = findLinkIndex();
|
|
16776
16807
|
if (idx === -1) return null;
|
|
16777
|
-
const
|
|
16808
|
+
const path53 = process.argv[idx + 1];
|
|
16778
16809
|
const rest = process.argv.slice(idx + 2);
|
|
16779
16810
|
const { value: prefix2 } = extractOption(rest, "--prefix");
|
|
16780
16811
|
if (!prefix2) return null;
|
|
16781
|
-
return { path:
|
|
16812
|
+
return { path: path53, prefix: prefix2 };
|
|
16782
16813
|
}
|
|
16783
16814
|
function hasDuplicateLink(runList, linkPath) {
|
|
16784
16815
|
return runList.some(
|
|
@@ -16806,7 +16837,7 @@ function link2() {
|
|
|
16806
16837
|
}
|
|
16807
16838
|
|
|
16808
16839
|
// src/commands/run/remove.ts
|
|
16809
|
-
import { existsSync as
|
|
16840
|
+
import { existsSync as existsSync49, unlinkSync as unlinkSync14 } from "fs";
|
|
16810
16841
|
import { join as join50 } from "path";
|
|
16811
16842
|
function findRemoveIndex() {
|
|
16812
16843
|
const idx = process.argv.indexOf("remove");
|
|
@@ -16823,7 +16854,7 @@ function parseRemoveName() {
|
|
|
16823
16854
|
}
|
|
16824
16855
|
function deleteCommandFile(name) {
|
|
16825
16856
|
const filePath = join50(".claude", "commands", `${name}.md`);
|
|
16826
|
-
if (
|
|
16857
|
+
if (existsSync49(filePath)) {
|
|
16827
16858
|
unlinkSync14(filePath);
|
|
16828
16859
|
console.log(`Deleted command file: ${filePath}`);
|
|
16829
16860
|
}
|
|
@@ -16859,7 +16890,7 @@ function registerRun(program2) {
|
|
|
16859
16890
|
|
|
16860
16891
|
// src/commands/screenshot/index.ts
|
|
16861
16892
|
import { execSync as execSync47 } from "child_process";
|
|
16862
|
-
import { existsSync as
|
|
16893
|
+
import { existsSync as existsSync50, mkdirSync as mkdirSync17, unlinkSync as unlinkSync15, writeFileSync as writeFileSync30 } from "fs";
|
|
16863
16894
|
import { tmpdir as tmpdir7 } from "os";
|
|
16864
16895
|
import { join as join51, resolve as resolve13 } from "path";
|
|
16865
16896
|
import chalk156 from "chalk";
|
|
@@ -16991,7 +17022,7 @@ Write-Output $OutputPath
|
|
|
16991
17022
|
|
|
16992
17023
|
// src/commands/screenshot/index.ts
|
|
16993
17024
|
function buildOutputPath(outputDir, processName) {
|
|
16994
|
-
if (!
|
|
17025
|
+
if (!existsSync50(outputDir)) {
|
|
16995
17026
|
mkdirSync17(outputDir, { recursive: true });
|
|
16996
17027
|
}
|
|
16997
17028
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
@@ -17291,16 +17322,16 @@ async function statusLine() {
|
|
|
17291
17322
|
// src/commands/sync.ts
|
|
17292
17323
|
import * as fs31 from "fs";
|
|
17293
17324
|
import * as os2 from "os";
|
|
17294
|
-
import * as
|
|
17325
|
+
import * as path51 from "path";
|
|
17295
17326
|
import { fileURLToPath as fileURLToPath7 } from "url";
|
|
17296
17327
|
|
|
17297
17328
|
// src/commands/sync/syncClaudeMd.ts
|
|
17298
17329
|
import * as fs29 from "fs";
|
|
17299
|
-
import * as
|
|
17330
|
+
import * as path49 from "path";
|
|
17300
17331
|
import chalk160 from "chalk";
|
|
17301
17332
|
async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
17302
|
-
const source =
|
|
17303
|
-
const target =
|
|
17333
|
+
const source = path49.join(claudeDir, "CLAUDE.md");
|
|
17334
|
+
const target = path49.join(targetBase, "CLAUDE.md");
|
|
17304
17335
|
const sourceContent = fs29.readFileSync(source, "utf-8");
|
|
17305
17336
|
if (fs29.existsSync(target)) {
|
|
17306
17337
|
const targetContent = fs29.readFileSync(target, "utf-8");
|
|
@@ -17326,11 +17357,11 @@ async function syncClaudeMd(claudeDir, targetBase, options2) {
|
|
|
17326
17357
|
|
|
17327
17358
|
// src/commands/sync/syncSettings.ts
|
|
17328
17359
|
import * as fs30 from "fs";
|
|
17329
|
-
import * as
|
|
17360
|
+
import * as path50 from "path";
|
|
17330
17361
|
import chalk161 from "chalk";
|
|
17331
17362
|
async function syncSettings(claudeDir, targetBase, options2) {
|
|
17332
|
-
const source =
|
|
17333
|
-
const target =
|
|
17363
|
+
const source = path50.join(claudeDir, "settings.json");
|
|
17364
|
+
const target = path50.join(targetBase, "settings.json");
|
|
17334
17365
|
const sourceContent = fs30.readFileSync(source, "utf-8");
|
|
17335
17366
|
const mergedContent = JSON.stringify(JSON.parse(sourceContent), null, " ");
|
|
17336
17367
|
if (fs30.existsSync(target)) {
|
|
@@ -17366,23 +17397,23 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
17366
17397
|
|
|
17367
17398
|
// src/commands/sync.ts
|
|
17368
17399
|
var __filename4 = fileURLToPath7(import.meta.url);
|
|
17369
|
-
var __dirname7 =
|
|
17400
|
+
var __dirname7 = path51.dirname(__filename4);
|
|
17370
17401
|
async function sync(options2) {
|
|
17371
17402
|
const config = loadConfig();
|
|
17372
17403
|
const yes = options2?.yes ?? config.sync.autoConfirm;
|
|
17373
|
-
const claudeDir =
|
|
17374
|
-
const targetBase =
|
|
17404
|
+
const claudeDir = path51.join(__dirname7, "..", "claude");
|
|
17405
|
+
const targetBase = path51.join(os2.homedir(), ".claude");
|
|
17375
17406
|
syncCommands(claudeDir, targetBase);
|
|
17376
17407
|
await syncSettings(claudeDir, targetBase, { yes });
|
|
17377
17408
|
await syncClaudeMd(claudeDir, targetBase, { yes });
|
|
17378
17409
|
}
|
|
17379
17410
|
function syncCommands(claudeDir, targetBase) {
|
|
17380
|
-
const sourceDir =
|
|
17381
|
-
const targetDir =
|
|
17411
|
+
const sourceDir = path51.join(claudeDir, "commands");
|
|
17412
|
+
const targetDir = path51.join(targetBase, "commands");
|
|
17382
17413
|
fs31.mkdirSync(targetDir, { recursive: true });
|
|
17383
17414
|
const files = fs31.readdirSync(sourceDir);
|
|
17384
17415
|
for (const file of files) {
|
|
17385
|
-
fs31.copyFileSync(
|
|
17416
|
+
fs31.copyFileSync(path51.join(sourceDir, file), path51.join(targetDir, file));
|
|
17386
17417
|
console.log(`Copied ${file} to ${targetDir}`);
|
|
17387
17418
|
}
|
|
17388
17419
|
console.log(`Synced ${files.length} command(s) to ~/.claude/commands`);
|
|
@@ -17390,15 +17421,15 @@ function syncCommands(claudeDir, targetBase) {
|
|
|
17390
17421
|
|
|
17391
17422
|
// src/commands/update.ts
|
|
17392
17423
|
import { execSync as execSync48 } from "child_process";
|
|
17393
|
-
import * as
|
|
17424
|
+
import * as path52 from "path";
|
|
17394
17425
|
function isGlobalNpmInstall(dir) {
|
|
17395
17426
|
try {
|
|
17396
|
-
const resolved =
|
|
17397
|
-
if (resolved.split(
|
|
17427
|
+
const resolved = path52.resolve(dir);
|
|
17428
|
+
if (resolved.split(path52.sep).includes("node_modules")) {
|
|
17398
17429
|
return true;
|
|
17399
17430
|
}
|
|
17400
17431
|
const globalPrefix = execSync48("npm prefix -g", { stdio: "pipe" }).toString().trim();
|
|
17401
|
-
return resolved.toLowerCase().startsWith(
|
|
17432
|
+
return resolved.toLowerCase().startsWith(path52.resolve(globalPrefix).toLowerCase());
|
|
17402
17433
|
} catch {
|
|
17403
17434
|
return false;
|
|
17404
17435
|
}
|