@staff0rd/assist 0.722.1 → 0.722.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/commands/sessions/web/bundle.js +1 -1
- package/dist/index.js +452 -488
- 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.722.
|
|
9
|
+
version: "0.722.3",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -296,8 +296,8 @@ function getRemoteOriginUrl(cwd) {
|
|
|
296
296
|
}
|
|
297
297
|
|
|
298
298
|
// src/commands/backlog/getCurrentOrigin.ts
|
|
299
|
-
function stripLeadingSlashes(
|
|
300
|
-
return
|
|
299
|
+
function stripLeadingSlashes(path106) {
|
|
300
|
+
return path106.replace(/^\/+/, "");
|
|
301
301
|
}
|
|
302
302
|
function normalizeOrigin(raw) {
|
|
303
303
|
const trimmed = raw.trim().replace(/\.git$/i, "").replace(/\/+$/, "");
|
|
@@ -347,9 +347,9 @@ function findGitLink(dir) {
|
|
|
347
347
|
}
|
|
348
348
|
return null;
|
|
349
349
|
}
|
|
350
|
-
function isFile(
|
|
350
|
+
function isFile(path106) {
|
|
351
351
|
try {
|
|
352
|
-
return statSync(
|
|
352
|
+
return statSync(path106).isFile();
|
|
353
353
|
} catch {
|
|
354
354
|
return false;
|
|
355
355
|
}
|
|
@@ -368,9 +368,9 @@ function linkedGitDirParent(gitDir) {
|
|
|
368
368
|
const match = /^(.*)[/\\]worktrees[/\\][^/\\]+[/\\]?$/.exec(gitDir);
|
|
369
369
|
return match ? match[1] : null;
|
|
370
370
|
}
|
|
371
|
-
function readTrimmed(
|
|
371
|
+
function readTrimmed(path106) {
|
|
372
372
|
try {
|
|
373
|
-
const content = readFileSync2(
|
|
373
|
+
const content = readFileSync2(path106, "utf8").trim();
|
|
374
374
|
return content === "" ? null : content;
|
|
375
375
|
} catch {
|
|
376
376
|
return null;
|
|
@@ -383,10 +383,10 @@ function absolute(target, from) {
|
|
|
383
383
|
// src/shared/loadRawYaml.ts
|
|
384
384
|
import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
|
|
385
385
|
import { parse as parseYaml } from "yaml";
|
|
386
|
-
function loadRawYaml(
|
|
387
|
-
if (!existsSync3(
|
|
386
|
+
function loadRawYaml(path106) {
|
|
387
|
+
if (!existsSync3(path106)) return {};
|
|
388
388
|
try {
|
|
389
|
-
const content = readFileSync3(
|
|
389
|
+
const content = readFileSync3(path106, "utf8");
|
|
390
390
|
return parseYaml(content) || {};
|
|
391
391
|
} catch {
|
|
392
392
|
return {};
|
|
@@ -458,8 +458,8 @@ function mergeRawConfigs(globalRaw, projectRaw) {
|
|
|
458
458
|
// src/commands/backlog/originDisplayName.ts
|
|
459
459
|
function originDisplayName(origin) {
|
|
460
460
|
if (origin.startsWith("local:")) {
|
|
461
|
-
const
|
|
462
|
-
const segments =
|
|
461
|
+
const path106 = origin.slice("local:".length).replace(/\/+$/, "");
|
|
462
|
+
const segments = path106.split("/").filter(Boolean);
|
|
463
463
|
return segments[segments.length - 1] ?? origin;
|
|
464
464
|
}
|
|
465
465
|
const firstSlash = origin.indexOf("/");
|
|
@@ -698,9 +698,7 @@ var assistConfigShape = {
|
|
|
698
698
|
restructure: z3.strictObject({
|
|
699
699
|
ignore: z3.array(z3.string()).default([]),
|
|
700
700
|
pin: z3.array(z3.string()).default([]),
|
|
701
|
-
maxDepth: z3.number().int().positive().default(10)
|
|
702
|
-
maxFolderPercent: z3.number().positive().max(100).default(15),
|
|
703
|
-
maxFolderFiles: z3.number().int().positive().default(150)
|
|
701
|
+
maxDepth: z3.number().int().positive().default(10)
|
|
704
702
|
}).optional(),
|
|
705
703
|
jira: z3.strictObject({
|
|
706
704
|
acField: z3.string().default("customfield_11937")
|
|
@@ -4322,8 +4320,8 @@ function getPreferredRemoteRepo(cwd) {
|
|
|
4322
4320
|
function gitRefUrl(kind, ref, cwd) {
|
|
4323
4321
|
const repo = getPreferredRemoteRepo(cwd);
|
|
4324
4322
|
if (!repo) return void 0;
|
|
4325
|
-
const
|
|
4326
|
-
return `https://github.com/${repo.org}/${repo.repo}/${
|
|
4323
|
+
const path106 = kind === "branch" ? "tree" : "commit";
|
|
4324
|
+
return `https://github.com/${repo.org}/${repo.repo}/${path106}/${ref}`;
|
|
4327
4325
|
}
|
|
4328
4326
|
|
|
4329
4327
|
// src/commands/sessions/shared/resolveSessionTranscript.ts
|
|
@@ -4484,9 +4482,9 @@ var LOCAL_FILES = ["backlog.jsonl", "backlog.db"];
|
|
|
4484
4482
|
function backupLocalBacklogFiles(dir) {
|
|
4485
4483
|
const moved = [];
|
|
4486
4484
|
for (const name of LOCAL_FILES) {
|
|
4487
|
-
const
|
|
4488
|
-
if (existsSync20(
|
|
4489
|
-
renameSync(
|
|
4485
|
+
const path106 = join19(dir, ".assist", name);
|
|
4486
|
+
if (existsSync20(path106)) {
|
|
4487
|
+
renameSync(path106, `${path106}.bak`);
|
|
4490
4488
|
moved.push(`${name} \u2192 ${name}.bak`);
|
|
4491
4489
|
}
|
|
4492
4490
|
}
|
|
@@ -4970,8 +4968,8 @@ var backlogItemSchema = z4.strictObject({
|
|
|
4970
4968
|
var backlogFileSchema = z4.array(backlogItemSchema);
|
|
4971
4969
|
|
|
4972
4970
|
// src/commands/backlog/parseBacklogJsonl.ts
|
|
4973
|
-
function parseBacklogJsonl(
|
|
4974
|
-
const content = readFileSync13(
|
|
4971
|
+
function parseBacklogJsonl(path106) {
|
|
4972
|
+
const content = readFileSync13(path106, "utf8").trim();
|
|
4975
4973
|
if (content.length === 0) return [];
|
|
4976
4974
|
return content.split("\n").map((line) => line.trim()).filter(Boolean).map((line) => backlogItemSchema.parse(JSON.parse(line)));
|
|
4977
4975
|
}
|
|
@@ -5517,9 +5515,9 @@ function originToSshUrl(origin) {
|
|
|
5517
5515
|
const firstSlash = origin.indexOf("/");
|
|
5518
5516
|
if (firstSlash <= 0) return null;
|
|
5519
5517
|
const host = origin.slice(0, firstSlash);
|
|
5520
|
-
const
|
|
5521
|
-
if (!
|
|
5522
|
-
return `git@${host}:${
|
|
5518
|
+
const path106 = origin.slice(firstSlash + 1);
|
|
5519
|
+
if (!path106) return null;
|
|
5520
|
+
return `git@${host}:${path106}.git`;
|
|
5523
5521
|
}
|
|
5524
5522
|
|
|
5525
5523
|
// src/commands/backlog/cloneRepo.ts
|
|
@@ -7157,10 +7155,10 @@ var hooksSettings = {
|
|
|
7157
7155
|
}
|
|
7158
7156
|
};
|
|
7159
7157
|
function ensureHooksSettings() {
|
|
7160
|
-
const
|
|
7161
|
-
mkdirSync5(dirname15(
|
|
7162
|
-
writeFileSync16(
|
|
7163
|
-
return
|
|
7158
|
+
const path106 = daemonPaths.hooksSettings;
|
|
7159
|
+
mkdirSync5(dirname15(path106), { recursive: true });
|
|
7160
|
+
writeFileSync16(path106, JSON.stringify(hooksSettings, null, 2));
|
|
7161
|
+
return path106;
|
|
7164
7162
|
}
|
|
7165
7163
|
|
|
7166
7164
|
// src/shared/spawnInherit.ts
|
|
@@ -7916,24 +7914,24 @@ function getOwnerPath(itemId2) {
|
|
|
7916
7914
|
function recordSignalOwner(itemId2) {
|
|
7917
7915
|
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
7918
7916
|
if (!sessionId) return;
|
|
7919
|
-
const
|
|
7920
|
-
mkdirSync7(dirname16(
|
|
7921
|
-
writeFileSync18(
|
|
7917
|
+
const path106 = getOwnerPath(itemId2);
|
|
7918
|
+
mkdirSync7(dirname16(path106), { recursive: true });
|
|
7919
|
+
writeFileSync18(path106, JSON.stringify({ sessionId }));
|
|
7922
7920
|
}
|
|
7923
7921
|
function readSignalOwner(itemId2) {
|
|
7924
|
-
const
|
|
7925
|
-
if (!existsSync26(
|
|
7922
|
+
const path106 = getOwnerPath(itemId2);
|
|
7923
|
+
if (!existsSync26(path106)) return void 0;
|
|
7926
7924
|
try {
|
|
7927
|
-
const parsed = JSON.parse(readFileSync17(
|
|
7925
|
+
const parsed = JSON.parse(readFileSync17(path106, "utf8"));
|
|
7928
7926
|
return parsed.sessionId;
|
|
7929
7927
|
} catch {
|
|
7930
7928
|
return void 0;
|
|
7931
7929
|
}
|
|
7932
7930
|
}
|
|
7933
7931
|
function clearSignalOwner(itemId2) {
|
|
7934
|
-
const
|
|
7932
|
+
const path106 = getOwnerPath(itemId2);
|
|
7935
7933
|
try {
|
|
7936
|
-
rmSync(
|
|
7934
|
+
rmSync(path106);
|
|
7937
7935
|
} catch {
|
|
7938
7936
|
}
|
|
7939
7937
|
}
|
|
@@ -7970,19 +7968,19 @@ function resolveSignalTarget(event, data) {
|
|
|
7970
7968
|
function writeSignal(event, data) {
|
|
7971
7969
|
const target = resolveSignalTarget(event, data);
|
|
7972
7970
|
if (!target) return;
|
|
7973
|
-
const
|
|
7974
|
-
if (!
|
|
7971
|
+
const path106 = getSignalPath(target);
|
|
7972
|
+
if (!path106) return;
|
|
7975
7973
|
const signal = { event, sessionId: target, ...data };
|
|
7976
|
-
mkdirSync8(dirname17(
|
|
7977
|
-
writeFileSync19(
|
|
7974
|
+
mkdirSync8(dirname17(path106), { recursive: true });
|
|
7975
|
+
writeFileSync19(path106, JSON.stringify(signal));
|
|
7978
7976
|
}
|
|
7979
7977
|
|
|
7980
7978
|
// src/commands/backlog/readSignal.ts
|
|
7981
7979
|
function readSignal() {
|
|
7982
|
-
const
|
|
7983
|
-
if (!
|
|
7980
|
+
const path106 = getSignalPath();
|
|
7981
|
+
if (!path106 || !existsSync27(path106)) return void 0;
|
|
7984
7982
|
try {
|
|
7985
|
-
return JSON.parse(readFileSync18(
|
|
7983
|
+
return JSON.parse(readFileSync18(path106, "utf8"));
|
|
7986
7984
|
} catch {
|
|
7987
7985
|
return void 0;
|
|
7988
7986
|
}
|
|
@@ -8180,13 +8178,13 @@ function activityPath(sessionId) {
|
|
|
8180
8178
|
function emitActivity(activity2) {
|
|
8181
8179
|
const sessionId = process.env.ASSIST_ACTIVITY_ID;
|
|
8182
8180
|
if (!sessionId) return;
|
|
8183
|
-
const
|
|
8184
|
-
mkdirSync9(dirname18(
|
|
8185
|
-
writeFileSync20(
|
|
8181
|
+
const path106 = activityPath(sessionId);
|
|
8182
|
+
mkdirSync9(dirname18(path106), { recursive: true });
|
|
8183
|
+
writeFileSync20(path106, JSON.stringify({ ...activity2, startedAt: Date.now() }));
|
|
8186
8184
|
}
|
|
8187
|
-
function readActivity(
|
|
8185
|
+
function readActivity(path106) {
|
|
8188
8186
|
try {
|
|
8189
|
-
return JSON.parse(readFileSync19(
|
|
8187
|
+
return JSON.parse(readFileSync19(path106, "utf8"));
|
|
8190
8188
|
} catch {
|
|
8191
8189
|
return void 0;
|
|
8192
8190
|
}
|
|
@@ -8196,9 +8194,9 @@ function reconcileActivity(sessionId, activity2) {
|
|
|
8196
8194
|
removeActivity(sessionId);
|
|
8197
8195
|
return;
|
|
8198
8196
|
}
|
|
8199
|
-
const
|
|
8200
|
-
mkdirSync9(dirname18(
|
|
8201
|
-
writeFileSync20(
|
|
8197
|
+
const path106 = activityPath(sessionId);
|
|
8198
|
+
mkdirSync9(dirname18(path106), { recursive: true });
|
|
8199
|
+
writeFileSync20(path106, JSON.stringify(activity2));
|
|
8202
8200
|
}
|
|
8203
8201
|
function removeActivity(sessionId) {
|
|
8204
8202
|
try {
|
|
@@ -10823,10 +10821,10 @@ function getStorePath(filename) {
|
|
|
10823
10821
|
return join34(getStoreDir(), filename);
|
|
10824
10822
|
}
|
|
10825
10823
|
function loadJson(filename) {
|
|
10826
|
-
const
|
|
10827
|
-
if (existsSync32(
|
|
10824
|
+
const path106 = getStorePath(filename);
|
|
10825
|
+
if (existsSync32(path106)) {
|
|
10828
10826
|
try {
|
|
10829
|
-
return JSON.parse(readFileSync20(
|
|
10827
|
+
return JSON.parse(readFileSync20(path106, "utf8"));
|
|
10830
10828
|
} catch {
|
|
10831
10829
|
return {};
|
|
10832
10830
|
}
|
|
@@ -10845,22 +10843,22 @@ function saveJson(filename, data) {
|
|
|
10845
10843
|
var REGISTRY_FILE = "worktrees.json";
|
|
10846
10844
|
function readWorktreeRegistry() {
|
|
10847
10845
|
const data = loadJson(REGISTRY_FILE);
|
|
10848
|
-
return Object.entries(data).filter(([, record]) => !record.reaped).map(([
|
|
10846
|
+
return Object.entries(data).filter(([, record]) => !record.reaped).map(([path106, record]) => ({ path: path106, ...record }));
|
|
10849
10847
|
}
|
|
10850
|
-
function worktreeAttributionIncludingReaped(
|
|
10851
|
-
const record = loadJson(REGISTRY_FILE)[
|
|
10848
|
+
function worktreeAttributionIncludingReaped(path106) {
|
|
10849
|
+
const record = loadJson(REGISTRY_FILE)[path106];
|
|
10852
10850
|
return record ? { clone: record.clone, origin: record.origin } : void 0;
|
|
10853
10851
|
}
|
|
10854
|
-
function recordWorktree(
|
|
10852
|
+
function recordWorktree(path106, clone, origin) {
|
|
10855
10853
|
const data = loadJson(REGISTRY_FILE);
|
|
10856
|
-
data[
|
|
10854
|
+
data[path106] = { clone, origin };
|
|
10857
10855
|
saveJson(REGISTRY_FILE, data);
|
|
10858
10856
|
}
|
|
10859
|
-
function forgetWorktree(
|
|
10857
|
+
function forgetWorktree(path106) {
|
|
10860
10858
|
const data = loadJson(REGISTRY_FILE);
|
|
10861
|
-
const record = data[
|
|
10859
|
+
const record = data[path106];
|
|
10862
10860
|
if (!record || record.reaped) return;
|
|
10863
|
-
data[
|
|
10861
|
+
data[path106] = { ...record, reaped: true };
|
|
10864
10862
|
saveJson(REGISTRY_FILE, data);
|
|
10865
10863
|
}
|
|
10866
10864
|
|
|
@@ -11470,10 +11468,10 @@ function completeLines(text18, windowIsPartial) {
|
|
|
11470
11468
|
if (windowIsPartial) all.shift();
|
|
11471
11469
|
return all;
|
|
11472
11470
|
}
|
|
11473
|
-
function readLogTail(
|
|
11471
|
+
function readLogTail(path106, lines2) {
|
|
11474
11472
|
let fd;
|
|
11475
11473
|
try {
|
|
11476
|
-
fd = openSync4(
|
|
11474
|
+
fd = openSync4(path106, "r");
|
|
11477
11475
|
} catch {
|
|
11478
11476
|
return [];
|
|
11479
11477
|
}
|
|
@@ -11738,8 +11736,8 @@ async function loadCommittedPaths(cwd, sessionId) {
|
|
|
11738
11736
|
for (const commit2 of commits2) {
|
|
11739
11737
|
const resolved = await resolveCommit(cwd, commit2.sha);
|
|
11740
11738
|
if (!resolved) continue;
|
|
11741
|
-
for (const
|
|
11742
|
-
if (!bases.has(
|
|
11739
|
+
for (const path106 of resolved.paths) {
|
|
11740
|
+
if (!bases.has(path106)) bases.set(path106, resolved.base);
|
|
11743
11741
|
}
|
|
11744
11742
|
}
|
|
11745
11743
|
return { commits: commits2, bases };
|
|
@@ -11757,16 +11755,16 @@ async function itemChangeSet(cwd, sessionId) {
|
|
|
11757
11755
|
}
|
|
11758
11756
|
function groupByBase(bases) {
|
|
11759
11757
|
const groups = /* @__PURE__ */ new Map();
|
|
11760
|
-
for (const [
|
|
11758
|
+
for (const [path106, base] of bases) {
|
|
11761
11759
|
const paths = groups.get(base);
|
|
11762
|
-
if (paths) paths.push(
|
|
11763
|
-
else groups.set(base, [
|
|
11760
|
+
if (paths) paths.push(path106);
|
|
11761
|
+
else groups.set(base, [path106]);
|
|
11764
11762
|
}
|
|
11765
11763
|
return [...groups].map(([base, paths]) => ({ base, paths: paths.sort() }));
|
|
11766
11764
|
}
|
|
11767
11765
|
async function dirtyPaths(cwd, bases) {
|
|
11768
11766
|
const output = await execGit(cwd, ["diff", "--name-only", "HEAD"]);
|
|
11769
|
-
return output.split("\n").filter((
|
|
11767
|
+
return output.split("\n").filter((path106) => path106 && !bases.has(path106)).sort();
|
|
11770
11768
|
}
|
|
11771
11769
|
|
|
11772
11770
|
// src/commands/sessions/web/scopedDiff.ts
|
|
@@ -11775,8 +11773,8 @@ async function scopedDiff(cwd, session, scope) {
|
|
|
11775
11773
|
if (scope.kind === "commit") return commitDiff(cwd, scope.sha);
|
|
11776
11774
|
return await trackedScopeDiff(cwd, session, scope) + await untrackedDiff(cwd);
|
|
11777
11775
|
}
|
|
11778
|
-
async function untrackedFileDiff(cwd,
|
|
11779
|
-
return execGit(cwd, ["diff", "--no-index", "--", "/dev/null",
|
|
11776
|
+
async function untrackedFileDiff(cwd, path106) {
|
|
11777
|
+
return execGit(cwd, ["diff", "--no-index", "--", "/dev/null", path106], {
|
|
11780
11778
|
maxBuffer: MAX_DIFF_BYTES,
|
|
11781
11779
|
allowFailure: true
|
|
11782
11780
|
});
|
|
@@ -11789,7 +11787,7 @@ async function untrackedDiff(cwd) {
|
|
|
11789
11787
|
]);
|
|
11790
11788
|
const paths = list5.split("\n").filter(Boolean);
|
|
11791
11789
|
const diffs = await Promise.all(
|
|
11792
|
-
paths.map((
|
|
11790
|
+
paths.map((path106) => untrackedFileDiff(cwd, path106))
|
|
11793
11791
|
);
|
|
11794
11792
|
return diffs.join("");
|
|
11795
11793
|
}
|
|
@@ -11882,9 +11880,9 @@ import { isAbsolute as isAbsolute2, relative as relative2, resolve as resolve10
|
|
|
11882
11880
|
function repoRoot(cwd) {
|
|
11883
11881
|
return resolve10(cwd);
|
|
11884
11882
|
}
|
|
11885
|
-
function resolveWithinCwd(cwd,
|
|
11883
|
+
function resolveWithinCwd(cwd, path106) {
|
|
11886
11884
|
const root2 = repoRoot(cwd);
|
|
11887
|
-
const target = resolve10(root2,
|
|
11885
|
+
const target = resolve10(root2, path106);
|
|
11888
11886
|
const rel = relative2(root2, target);
|
|
11889
11887
|
if (rel === "" || rel.startsWith("..") || isAbsolute2(rel)) return null;
|
|
11890
11888
|
return target;
|
|
@@ -11894,14 +11892,14 @@ function resolveWithinCwd(cwd, path107) {
|
|
|
11894
11892
|
function getFileTarget(req, res) {
|
|
11895
11893
|
const cwd = getCwdParam(req, res);
|
|
11896
11894
|
if (!cwd) return null;
|
|
11897
|
-
const
|
|
11895
|
+
const path106 = new URL(req.url ?? "/", "http://localhost").searchParams.get(
|
|
11898
11896
|
"path"
|
|
11899
11897
|
);
|
|
11900
|
-
if (!
|
|
11898
|
+
if (!path106) {
|
|
11901
11899
|
respondJson(res, 400, { error: "Missing path" });
|
|
11902
11900
|
return null;
|
|
11903
11901
|
}
|
|
11904
|
-
const target = resolveWithinCwd(cwd,
|
|
11902
|
+
const target = resolveWithinCwd(cwd, path106);
|
|
11905
11903
|
if (!target) {
|
|
11906
11904
|
respondJson(res, 400, { error: "Path outside cwd" });
|
|
11907
11905
|
return null;
|
|
@@ -11960,9 +11958,9 @@ function segmentText(segment) {
|
|
|
11960
11958
|
if (segment.kind === "index") return `[${segment.index}]`;
|
|
11961
11959
|
return "[]";
|
|
11962
11960
|
}
|
|
11963
|
-
function formatConfigPath(
|
|
11961
|
+
function formatConfigPath(path106) {
|
|
11964
11962
|
let text18 = "";
|
|
11965
|
-
for (const segment of
|
|
11963
|
+
for (const segment of path106) {
|
|
11966
11964
|
const dotted = segment.kind === "key" || segment.kind === "entry";
|
|
11967
11965
|
const rendered = segmentText(segment);
|
|
11968
11966
|
text18 += dotted && text18 ? `.${rendered}` : rendered;
|
|
@@ -12123,11 +12121,11 @@ function enumValues(node) {
|
|
|
12123
12121
|
function opaqueConfigNode(inner, base) {
|
|
12124
12122
|
return { ...base, kind: "other", type: leafTypeOf(inner) };
|
|
12125
12123
|
}
|
|
12126
|
-
function build(node,
|
|
12124
|
+
function build(node, path106) {
|
|
12127
12125
|
const { inner, defaultValue, optional } = unwrapSchemaNode(node);
|
|
12128
12126
|
const secret = isSecretSchemaNode(node) || isSecretSchemaNode(inner);
|
|
12129
12127
|
const base = {
|
|
12130
|
-
path:
|
|
12128
|
+
path: path106,
|
|
12131
12129
|
...optional ? { optional: true } : {},
|
|
12132
12130
|
...defaultValue === void 0 ? {} : { defaultValue },
|
|
12133
12131
|
...secret ? { secret: true } : {}
|
|
@@ -12183,11 +12181,11 @@ function describeConfigLeaves(schema2) {
|
|
|
12183
12181
|
|
|
12184
12182
|
// src/commands/config/globalConfigFileLabel.ts
|
|
12185
12183
|
var WINDOWS_MOUNT_PREFIX = "/mnt/";
|
|
12186
|
-
function globalConfigFileLabel(
|
|
12187
|
-
if (
|
|
12188
|
-
if (
|
|
12189
|
-
return `${
|
|
12190
|
-
return
|
|
12184
|
+
function globalConfigFileLabel(path106) {
|
|
12185
|
+
if (path106 === getGlobalConfigPath()) return "~/.assist.yml";
|
|
12186
|
+
if (path106.startsWith(WINDOWS_MOUNT_PREFIX))
|
|
12187
|
+
return `${path106} on the Windows host`;
|
|
12188
|
+
return path106;
|
|
12191
12189
|
}
|
|
12192
12190
|
|
|
12193
12191
|
// src/commands/config/readRawConfigLayers.ts
|
|
@@ -12244,35 +12242,35 @@ function isPlainRecord(value) {
|
|
|
12244
12242
|
}
|
|
12245
12243
|
|
|
12246
12244
|
// src/shared/mapConfigSecrets.ts
|
|
12247
|
-
function mapChildren(value,
|
|
12245
|
+
function mapChildren(value, path106, childNode, map) {
|
|
12248
12246
|
if (!isPlainRecord(value)) return value;
|
|
12249
12247
|
return Object.fromEntries(
|
|
12250
12248
|
Object.entries(value).map(([name, child]) => [
|
|
12251
12249
|
name,
|
|
12252
|
-
walk(child, [...
|
|
12250
|
+
walk(child, [...path106, name], childNode(name), map)
|
|
12253
12251
|
])
|
|
12254
12252
|
);
|
|
12255
12253
|
}
|
|
12256
|
-
function mapItems(value,
|
|
12254
|
+
function mapItems(value, path106, item, map) {
|
|
12257
12255
|
if (!Array.isArray(value)) return value;
|
|
12258
|
-
return value.map((entry, index3) => walk(entry, [...
|
|
12256
|
+
return value.map((entry, index3) => walk(entry, [...path106, index3], item, map));
|
|
12259
12257
|
}
|
|
12260
|
-
function walk(value,
|
|
12258
|
+
function walk(value, path106, node, map) {
|
|
12261
12259
|
if (!node || value === void 0 || value === null) return value;
|
|
12262
|
-
if (node.secret) return map(value,
|
|
12260
|
+
if (node.secret) return map(value, path106);
|
|
12263
12261
|
switch (node.kind) {
|
|
12264
12262
|
case "object":
|
|
12265
12263
|
case "unionOfObjects":
|
|
12266
12264
|
return mapChildren(
|
|
12267
12265
|
value,
|
|
12268
|
-
|
|
12266
|
+
path106,
|
|
12269
12267
|
(name) => configNodeField(node, name),
|
|
12270
12268
|
map
|
|
12271
12269
|
);
|
|
12272
12270
|
case "objectList":
|
|
12273
|
-
return mapItems(value,
|
|
12271
|
+
return mapItems(value, path106, node.item, map);
|
|
12274
12272
|
case "record":
|
|
12275
|
-
return mapChildren(value,
|
|
12273
|
+
return mapChildren(value, path106, () => node.value, map);
|
|
12276
12274
|
default:
|
|
12277
12275
|
return value;
|
|
12278
12276
|
}
|
|
@@ -12297,9 +12295,9 @@ function isTraversable(value) {
|
|
|
12297
12295
|
function stepInto(current, key) {
|
|
12298
12296
|
return isTraversable(current) ? current[key] : void 0;
|
|
12299
12297
|
}
|
|
12300
|
-
function getNestedValue(obj,
|
|
12298
|
+
function getNestedValue(obj, path106) {
|
|
12301
12299
|
let current = obj;
|
|
12302
|
-
for (const key of
|
|
12300
|
+
for (const key of path106.split(".")) current = stepInto(current, key);
|
|
12303
12301
|
return current;
|
|
12304
12302
|
}
|
|
12305
12303
|
|
|
@@ -12349,9 +12347,9 @@ function step(node, segment) {
|
|
|
12349
12347
|
return void 0;
|
|
12350
12348
|
}
|
|
12351
12349
|
}
|
|
12352
|
-
function findConfigNode(root2,
|
|
12350
|
+
function findConfigNode(root2, path106) {
|
|
12353
12351
|
let current = root2;
|
|
12354
|
-
for (const segment of
|
|
12352
|
+
for (const segment of path106) {
|
|
12355
12353
|
if (!current) return void 0;
|
|
12356
12354
|
current = step(current, segment);
|
|
12357
12355
|
}
|
|
@@ -12368,34 +12366,34 @@ function nameSegment(name) {
|
|
|
12368
12366
|
return name === RECORD_ENTRY_TOKEN ? { kind: "entry" } : { kind: "key", name };
|
|
12369
12367
|
}
|
|
12370
12368
|
function parseConfigPath(text18) {
|
|
12371
|
-
const
|
|
12369
|
+
const path106 = [];
|
|
12372
12370
|
let at2 = 0;
|
|
12373
12371
|
while (at2 < text18.length) {
|
|
12374
12372
|
if (text18[at2] === "[") {
|
|
12375
12373
|
const close = text18.indexOf("]", at2);
|
|
12376
12374
|
const segment = close === -1 ? void 0 : bracketSegment(text18.slice(at2 + 1, close));
|
|
12377
12375
|
if (!segment) return void 0;
|
|
12378
|
-
|
|
12376
|
+
path106.push(segment);
|
|
12379
12377
|
at2 = close + 1;
|
|
12380
12378
|
continue;
|
|
12381
12379
|
}
|
|
12382
12380
|
if (text18[at2] === ".") {
|
|
12383
|
-
if (
|
|
12381
|
+
if (path106.length === 0) return void 0;
|
|
12384
12382
|
at2 += 1;
|
|
12385
12383
|
}
|
|
12386
12384
|
const start3 = at2;
|
|
12387
12385
|
while (at2 < text18.length && text18[at2] !== "." && text18[at2] !== "[") at2 += 1;
|
|
12388
12386
|
const name = text18.slice(start3, at2);
|
|
12389
12387
|
if (!name) return void 0;
|
|
12390
|
-
|
|
12388
|
+
path106.push(nameSegment(name));
|
|
12391
12389
|
}
|
|
12392
|
-
return
|
|
12390
|
+
return path106;
|
|
12393
12391
|
}
|
|
12394
12392
|
|
|
12395
12393
|
// src/commands/config/configEntryNode.ts
|
|
12396
12394
|
function configEntryNode(root2, key) {
|
|
12397
|
-
const
|
|
12398
|
-
return
|
|
12395
|
+
const path106 = parseConfigPath(key);
|
|
12396
|
+
return path106 ? findConfigNode(root2, path106) : void 0;
|
|
12399
12397
|
}
|
|
12400
12398
|
|
|
12401
12399
|
// src/commands/backlog/harnessConfigHelp.ts
|
|
@@ -12620,7 +12618,7 @@ var refactorConfigHelp = [
|
|
|
12620
12618
|
{
|
|
12621
12619
|
key: "restructure.ignore",
|
|
12622
12620
|
setter: 'assist config set restructure.ignore "src/generated/**"',
|
|
12623
|
-
note: "globs (relative to cwd) of files restructure never moves; they are
|
|
12621
|
+
note: "globs (relative to cwd) of files restructure never moves; files they import are placed beside them"
|
|
12624
12622
|
},
|
|
12625
12623
|
{
|
|
12626
12624
|
key: "restructure.pin",
|
|
@@ -12631,16 +12629,6 @@ var refactorConfigHelp = [
|
|
|
12631
12629
|
key: "restructure.maxDepth",
|
|
12632
12630
|
setter: "assist config set restructure.maxDepth 10",
|
|
12633
12631
|
note: "deepest folder level the plan may place a file at (default 10); deeper plans list their deep chains with pin guidance, and --check fails"
|
|
12634
|
-
},
|
|
12635
|
-
{
|
|
12636
|
-
key: "restructure.maxFolderPercent",
|
|
12637
|
-
setter: "assist config set restructure.maxFolderPercent 15",
|
|
12638
|
-
note: "most files any folder except the root may hold, as a percentage of all files under the root (default 15, never below 20, capped by restructure.maxFolderFiles); larger folders are listed with pin guidance, and --check fails"
|
|
12639
|
-
},
|
|
12640
|
-
{
|
|
12641
|
-
key: "restructure.maxFolderFiles",
|
|
12642
|
-
setter: "assist config set restructure.maxFolderFiles 150",
|
|
12643
|
-
note: "cap on the restructure.maxFolderPercent folder limit (default 150)"
|
|
12644
12632
|
}
|
|
12645
12633
|
];
|
|
12646
12634
|
|
|
@@ -13149,7 +13137,7 @@ function findSynthesisForBranch(repoReviewsDir, branch2) {
|
|
|
13149
13137
|
const parent = dirname22(branchKeyPath);
|
|
13150
13138
|
const branchPrefix = basename10(branchKeyPath);
|
|
13151
13139
|
if (!existsSync34(parent)) return null;
|
|
13152
|
-
const synthesisFiles = readdirSync4(parent).filter((name) => name.startsWith(branchPrefix)).map((name) => join36(parent, name, "synthesis.md")).filter((
|
|
13140
|
+
const synthesisFiles = readdirSync4(parent).filter((name) => name.startsWith(branchPrefix)).map((name) => join36(parent, name, "synthesis.md")).filter((path106) => existsSync34(path106)).map((path106) => ({ path: path106, mtime: statSync5(path106).mtimeMs })).sort((a, b) => b.mtime - a.mtime);
|
|
13153
13141
|
return synthesisFiles[0]?.path ?? null;
|
|
13154
13142
|
}
|
|
13155
13143
|
|
|
@@ -13179,12 +13167,12 @@ async function getReviewSynthesis(req, res) {
|
|
|
13179
13167
|
const cwd = getCwdParam(req, res);
|
|
13180
13168
|
if (!cwd) return;
|
|
13181
13169
|
try {
|
|
13182
|
-
const
|
|
13183
|
-
if (!
|
|
13170
|
+
const path106 = await resolveSynthesisPath(cwd);
|
|
13171
|
+
if (!path106) {
|
|
13184
13172
|
respondJson(res, 404, { error: "No synthesis found" });
|
|
13185
13173
|
return;
|
|
13186
13174
|
}
|
|
13187
|
-
respondJson(res, 200, { synthesis: readFileSync22(
|
|
13175
|
+
respondJson(res, 200, { synthesis: readFileSync22(path106, "utf8") });
|
|
13188
13176
|
} catch {
|
|
13189
13177
|
respondJson(res, 404, { error: "No synthesis found" });
|
|
13190
13178
|
}
|
|
@@ -13267,8 +13255,8 @@ function parseDiffNameStatus(output) {
|
|
|
13267
13255
|
if (!status3 || fields.length < 2) continue;
|
|
13268
13256
|
const category = categorize(status3[0]);
|
|
13269
13257
|
if (!category) continue;
|
|
13270
|
-
const
|
|
13271
|
-
if (
|
|
13258
|
+
const path106 = fields[fields.length - 1];
|
|
13259
|
+
if (path106) result[category].push(path106);
|
|
13272
13260
|
}
|
|
13273
13261
|
return result;
|
|
13274
13262
|
}
|
|
@@ -13478,21 +13466,21 @@ function subsequenceScore(text18, query) {
|
|
|
13478
13466
|
}
|
|
13479
13467
|
return score - Math.min(text18.length, MAX_LENGTH_PENALTY);
|
|
13480
13468
|
}
|
|
13481
|
-
function scoreFilePath(
|
|
13469
|
+
function scoreFilePath(path106, query) {
|
|
13482
13470
|
const needle = query.trim().toLowerCase();
|
|
13483
13471
|
if (!needle) return 0;
|
|
13484
|
-
const basename31 =
|
|
13472
|
+
const basename31 = path106.slice(path106.lastIndexOf("/") + 1);
|
|
13485
13473
|
const inBasename = subsequenceScore(basename31, needle);
|
|
13486
13474
|
if (inBasename !== null) return BASENAME_WEIGHT + inBasename;
|
|
13487
|
-
return subsequenceScore(
|
|
13475
|
+
return subsequenceScore(path106, needle);
|
|
13488
13476
|
}
|
|
13489
13477
|
|
|
13490
13478
|
// src/commands/sessions/web/rankFilePaths.ts
|
|
13491
13479
|
function rankFilePaths(paths, query, limit) {
|
|
13492
13480
|
const scored = [];
|
|
13493
|
-
for (const
|
|
13494
|
-
const score = scoreFilePath(
|
|
13495
|
-
if (score !== null) scored.push({ path:
|
|
13481
|
+
for (const path106 of paths) {
|
|
13482
|
+
const score = scoreFilePath(path106, query);
|
|
13483
|
+
if (score !== null) scored.push({ path: path106, score });
|
|
13496
13484
|
}
|
|
13497
13485
|
scored.sort((a, b) => b.score - a.score || a.path.localeCompare(b.path));
|
|
13498
13486
|
return scored.slice(0, limit).map((entry) => entry.path);
|
|
@@ -14202,11 +14190,11 @@ function logLinkedRequest(req, res) {
|
|
|
14202
14190
|
const started = Date.now();
|
|
14203
14191
|
const from = req.headers[LINKED_FROM_HEADER2];
|
|
14204
14192
|
const trace = req.headers[TRACE_HEADER] ?? "none";
|
|
14205
|
-
const
|
|
14193
|
+
const path106 = new URL(req.url ?? "/", "http://localhost").pathname;
|
|
14206
14194
|
res.once("finish", () => {
|
|
14207
|
-
if (isQuietPoll(
|
|
14195
|
+
if (isQuietPoll(path106, res.statusCode)) return;
|
|
14208
14196
|
console.log(
|
|
14209
|
-
`link-from ${from} http: ${req.method} ${
|
|
14197
|
+
`link-from ${from} http: ${req.method} ${path106} trace=${trace} -> ${res.statusCode} (${Date.now() - started}ms)`
|
|
14210
14198
|
);
|
|
14211
14199
|
});
|
|
14212
14200
|
}
|
|
@@ -14594,8 +14582,8 @@ async function liveDeployments(cwd, repo, environments) {
|
|
|
14594
14582
|
|
|
14595
14583
|
// src/commands/sessions/web/releases/latestRun.ts
|
|
14596
14584
|
async function latestRun(cwd, repo, workflow) {
|
|
14597
|
-
const
|
|
14598
|
-
const response = await ghJson(cwd, ["api",
|
|
14585
|
+
const path106 = `repos/${repo}/actions/workflows/${encodeURIComponent(workflow)}/runs?per_page=1&exclude_pull_requests=true`;
|
|
14586
|
+
const response = await ghJson(cwd, ["api", path106]);
|
|
14599
14587
|
const run4 = response.workflow_runs?.[0];
|
|
14600
14588
|
if (!run4) return null;
|
|
14601
14589
|
return {
|
|
@@ -14876,38 +14864,38 @@ async function performRestart(target, deps2 = {}) {
|
|
|
14876
14864
|
import { relative as relative3 } from "path";
|
|
14877
14865
|
|
|
14878
14866
|
// src/commands/sessions/web/revertPathChanges.ts
|
|
14879
|
-
async function isTracked(cwd,
|
|
14867
|
+
async function isTracked(cwd, path106) {
|
|
14880
14868
|
try {
|
|
14881
|
-
await execGit(cwd, ["ls-files", "--error-unmatch", "--",
|
|
14869
|
+
await execGit(cwd, ["ls-files", "--error-unmatch", "--", path106]);
|
|
14882
14870
|
return true;
|
|
14883
14871
|
} catch {
|
|
14884
14872
|
return false;
|
|
14885
14873
|
}
|
|
14886
14874
|
}
|
|
14887
|
-
async function isInHead(cwd,
|
|
14888
|
-
const listing = await execGit(cwd, ["ls-tree", "HEAD", "--",
|
|
14875
|
+
async function isInHead(cwd, path106) {
|
|
14876
|
+
const listing = await execGit(cwd, ["ls-tree", "HEAD", "--", path106]);
|
|
14889
14877
|
return listing.trim().length > 0;
|
|
14890
14878
|
}
|
|
14891
|
-
async function revertPathChanges(cwd,
|
|
14892
|
-
if (!await isTracked(cwd,
|
|
14893
|
-
await execGit(cwd, ["clean", "-f", "--",
|
|
14879
|
+
async function revertPathChanges(cwd, path106) {
|
|
14880
|
+
if (!await isTracked(cwd, path106)) {
|
|
14881
|
+
await execGit(cwd, ["clean", "-f", "--", path106]);
|
|
14894
14882
|
return;
|
|
14895
14883
|
}
|
|
14896
|
-
if (await isInHead(cwd,
|
|
14897
|
-
await execGit(cwd, ["checkout", "HEAD", "--",
|
|
14884
|
+
if (await isInHead(cwd, path106)) {
|
|
14885
|
+
await execGit(cwd, ["checkout", "HEAD", "--", path106]);
|
|
14898
14886
|
return;
|
|
14899
14887
|
}
|
|
14900
|
-
await execGit(cwd, ["rm", "-f", "--",
|
|
14888
|
+
await execGit(cwd, ["rm", "-f", "--", path106]);
|
|
14901
14889
|
}
|
|
14902
14890
|
|
|
14903
14891
|
// src/commands/sessions/web/revertDiffFile.ts
|
|
14904
14892
|
async function revertDiffFile(req, res) {
|
|
14905
14893
|
const resolved = getFileTarget(req, res);
|
|
14906
14894
|
if (!resolved) return;
|
|
14907
|
-
const
|
|
14895
|
+
const path106 = relative3(repoRoot(resolved.cwd), resolved.target);
|
|
14908
14896
|
try {
|
|
14909
|
-
await revertPathChanges(resolved.cwd,
|
|
14910
|
-
respondJson(res, 200, { reverted:
|
|
14897
|
+
await revertPathChanges(resolved.cwd, path106);
|
|
14898
|
+
respondJson(res, 200, { reverted: path106 });
|
|
14911
14899
|
} catch (error) {
|
|
14912
14900
|
respondJson(res, 500, {
|
|
14913
14901
|
error: error instanceof Error ? error.message : "Failed to revert file"
|
|
@@ -15012,7 +15000,7 @@ async function readJsonBody(req) {
|
|
|
15012
15000
|
function requestedPaths(body) {
|
|
15013
15001
|
const paths = body.paths;
|
|
15014
15002
|
if (!Array.isArray(paths)) return null;
|
|
15015
|
-
if (paths.some((
|
|
15003
|
+
if (paths.some((path106) => typeof path106 !== "string")) return null;
|
|
15016
15004
|
return paths;
|
|
15017
15005
|
}
|
|
15018
15006
|
async function revertDiffPaths(req, res) {
|
|
@@ -15032,10 +15020,10 @@ async function revertDiffPaths(req, res) {
|
|
|
15032
15020
|
const root2 = repoRoot(cwd);
|
|
15033
15021
|
const reverted = [];
|
|
15034
15022
|
const failed3 = [];
|
|
15035
|
-
for (const
|
|
15036
|
-
const target = resolveWithinCwd(cwd,
|
|
15023
|
+
for (const path106 of paths) {
|
|
15024
|
+
const target = resolveWithinCwd(cwd, path106);
|
|
15037
15025
|
if (!target) {
|
|
15038
|
-
failed3.push({ path:
|
|
15026
|
+
failed3.push({ path: path106, error: "Path outside cwd" });
|
|
15039
15027
|
continue;
|
|
15040
15028
|
}
|
|
15041
15029
|
const relativePath = relative4(root2, target);
|
|
@@ -15134,11 +15122,11 @@ function coerceStructuredConfigValue(key, raw) {
|
|
|
15134
15122
|
};
|
|
15135
15123
|
}
|
|
15136
15124
|
function formatIssue(key, issue) {
|
|
15137
|
-
const
|
|
15125
|
+
const path106 = formatConfigPath([
|
|
15138
15126
|
{ kind: "key", name: key },
|
|
15139
15127
|
...issue.path.map(toSegment)
|
|
15140
15128
|
]);
|
|
15141
|
-
return `${
|
|
15129
|
+
return `${path106}: ${issue.message}`;
|
|
15142
15130
|
}
|
|
15143
15131
|
function toSegment(part) {
|
|
15144
15132
|
return typeof part === "number" ? { kind: "index", index: part } : { kind: "key", name: String(part) };
|
|
@@ -15233,9 +15221,9 @@ function coerceUnion(key, raw, types) {
|
|
|
15233
15221
|
}
|
|
15234
15222
|
|
|
15235
15223
|
// src/shared/valueAtConfigPath.ts
|
|
15236
|
-
function valueAtConfigPath(value,
|
|
15224
|
+
function valueAtConfigPath(value, path106) {
|
|
15237
15225
|
let current = value;
|
|
15238
|
-
for (const key of
|
|
15226
|
+
for (const key of path106) {
|
|
15239
15227
|
if (typeof key === "number") {
|
|
15240
15228
|
if (!Array.isArray(current)) return void 0;
|
|
15241
15229
|
current = current[key];
|
|
@@ -15252,7 +15240,7 @@ function restoreConfigSecrets(value, stored, node) {
|
|
|
15252
15240
|
return mapConfigSecrets(
|
|
15253
15241
|
value,
|
|
15254
15242
|
node,
|
|
15255
|
-
(secret,
|
|
15243
|
+
(secret, path106) => isRedactedSecret(secret) ? valueAtConfigPath(stored, path106) : secret
|
|
15256
15244
|
);
|
|
15257
15245
|
}
|
|
15258
15246
|
|
|
@@ -15301,8 +15289,8 @@ function stepIntoNested(container, key, nextKey) {
|
|
|
15301
15289
|
}
|
|
15302
15290
|
return ensureObject(container, resolved);
|
|
15303
15291
|
}
|
|
15304
|
-
function setNestedValue(obj,
|
|
15305
|
-
const keys =
|
|
15292
|
+
function setNestedValue(obj, path106, value) {
|
|
15293
|
+
const keys = path106.split(".");
|
|
15306
15294
|
const result = { ...obj };
|
|
15307
15295
|
let current = result;
|
|
15308
15296
|
for (let i = 0; i < keys.length - 1; i++) {
|
|
@@ -15329,8 +15317,8 @@ function formatIssue2(issue, key) {
|
|
|
15329
15317
|
return issue.keys.map(
|
|
15330
15318
|
(unrecognized) => `${[...issue.path, unrecognized].join(".")}: Unrecognized key`
|
|
15331
15319
|
);
|
|
15332
|
-
const
|
|
15333
|
-
return [`${
|
|
15320
|
+
const path106 = issue.path.length > 0 ? issue.path.join(".") : key;
|
|
15321
|
+
return [`${path106}: ${issue.message}`];
|
|
15334
15322
|
}
|
|
15335
15323
|
|
|
15336
15324
|
// src/commands/config/applyConfigSet.ts
|
|
@@ -15572,8 +15560,8 @@ function removeAt(container, keys) {
|
|
|
15572
15560
|
}
|
|
15573
15561
|
return removeFromChild(container, key, rest);
|
|
15574
15562
|
}
|
|
15575
|
-
function unsetNestedValue(obj,
|
|
15576
|
-
const { container, removed } = removeAt(obj,
|
|
15563
|
+
function unsetNestedValue(obj, path106) {
|
|
15564
|
+
const { container, removed } = removeAt(obj, path106.split("."));
|
|
15577
15565
|
return { config: container, removed };
|
|
15578
15566
|
}
|
|
15579
15567
|
|
|
@@ -17062,13 +17050,13 @@ function findBuiltinDenyRaw(rawCommand) {
|
|
|
17062
17050
|
|
|
17063
17051
|
// src/commands/cliHook/findRestrictedPathDeny.ts
|
|
17064
17052
|
var RESTRICTED_PATHS = [".assist/restricted"];
|
|
17065
|
-
function restrictedPathRegex(
|
|
17066
|
-
const pattern2 =
|
|
17053
|
+
function restrictedPathRegex(path106) {
|
|
17054
|
+
const pattern2 = path106.split("/").map((segment) => segment.replace(/[.*+?^${}()|[\]\\]/g, String.raw`\$&`)).join(String.raw`[/\\]`);
|
|
17067
17055
|
return new RegExp(pattern2);
|
|
17068
17056
|
}
|
|
17069
|
-
var RESTRICTED_PATH_RULES = RESTRICTED_PATHS.map((
|
|
17070
|
-
path:
|
|
17071
|
-
regex: restrictedPathRegex(
|
|
17057
|
+
var RESTRICTED_PATH_RULES = RESTRICTED_PATHS.map((path106) => ({
|
|
17058
|
+
path: path106,
|
|
17059
|
+
regex: restrictedPathRegex(path106)
|
|
17072
17060
|
}));
|
|
17073
17061
|
function findRestrictedPathDenyRaw(rawCommand) {
|
|
17074
17062
|
const rule = RESTRICTED_PATH_RULES.find(
|
|
@@ -17245,9 +17233,9 @@ var __dirname4 = dirname25(__filename3);
|
|
|
17245
17233
|
function packageRoot() {
|
|
17246
17234
|
return __dirname4;
|
|
17247
17235
|
}
|
|
17248
|
-
function readLines(
|
|
17249
|
-
if (!existsSync40(
|
|
17250
|
-
return readFileSync25(
|
|
17236
|
+
function readLines(path106) {
|
|
17237
|
+
if (!existsSync40(path106)) return [];
|
|
17238
|
+
return readFileSync25(path106, "utf8").split("\n").filter((line) => line.trim() !== "");
|
|
17251
17239
|
}
|
|
17252
17240
|
var cachedReads;
|
|
17253
17241
|
var cachedWrites;
|
|
@@ -17779,14 +17767,14 @@ function showProgress(p, label2) {
|
|
|
17779
17767
|
const pct = Math.round(p.done / p.total * 100);
|
|
17780
17768
|
process.stderr.write(`\r\x1B[K[${pct}%] Scanning ${label2}...`);
|
|
17781
17769
|
}
|
|
17782
|
-
async function resolveCommand2(cli,
|
|
17783
|
-
showProgress(p,
|
|
17784
|
-
const subHelp = await runHelp([cli, ...
|
|
17770
|
+
async function resolveCommand2(cli, path106, description, depth, p) {
|
|
17771
|
+
showProgress(p, path106.join(" "));
|
|
17772
|
+
const subHelp = await runHelp([cli, ...path106]);
|
|
17785
17773
|
if (!subHelp || !hasSubcommands(subHelp)) {
|
|
17786
|
-
return [{ path:
|
|
17774
|
+
return [{ path: path106, description }];
|
|
17787
17775
|
}
|
|
17788
|
-
const children = await discoverAt(cli,
|
|
17789
|
-
return children.length > 0 ? children : [{ path:
|
|
17776
|
+
const children = await discoverAt(cli, path106, depth + 1, p);
|
|
17777
|
+
return children.length > 0 ? children : [{ path: path106, description }];
|
|
17790
17778
|
}
|
|
17791
17779
|
async function discoverAt(cli, parentPath, depth, p) {
|
|
17792
17780
|
if (depth > SAFETY_DEPTH) return [];
|
|
@@ -17934,9 +17922,9 @@ function logPath(cli) {
|
|
|
17934
17922
|
return join43(homedir17(), ".assist", `cli-discover-${safeName}.log`);
|
|
17935
17923
|
}
|
|
17936
17924
|
function readCache(cli) {
|
|
17937
|
-
const
|
|
17938
|
-
if (!existsSync42(
|
|
17939
|
-
return readFileSync27(
|
|
17925
|
+
const path106 = logPath(cli);
|
|
17926
|
+
if (!existsSync42(path106)) return void 0;
|
|
17927
|
+
return readFileSync27(path106, "utf8");
|
|
17940
17928
|
}
|
|
17941
17929
|
function writeCache(cli, output) {
|
|
17942
17930
|
const dir = join43(homedir17(), ".assist");
|
|
@@ -18125,9 +18113,9 @@ function sweepRestrictedDir(dir = getRestrictedDir()) {
|
|
|
18125
18113
|
}
|
|
18126
18114
|
const cutoff = Date.now() - STALE_AFTER_MS;
|
|
18127
18115
|
for (const entry of entries) {
|
|
18128
|
-
const
|
|
18116
|
+
const path106 = join45(dir, entry);
|
|
18129
18117
|
try {
|
|
18130
|
-
if (statSync7(
|
|
18118
|
+
if (statSync7(path106).mtimeMs < cutoff) unlinkSync7(path106);
|
|
18131
18119
|
} catch {
|
|
18132
18120
|
continue;
|
|
18133
18121
|
}
|
|
@@ -18137,10 +18125,10 @@ function sweepRestrictedDir(dir = getRestrictedDir()) {
|
|
|
18137
18125
|
// src/commands/codeComment/readPinState.ts
|
|
18138
18126
|
import { existsSync as existsSync43, readFileSync as readFileSync28 } from "fs";
|
|
18139
18127
|
function readPinState(pin2) {
|
|
18140
|
-
const
|
|
18141
|
-
if (!existsSync43(
|
|
18128
|
+
const path106 = getPinStatePath(pin2);
|
|
18129
|
+
if (!existsSync43(path106)) return void 0;
|
|
18142
18130
|
try {
|
|
18143
|
-
const state = JSON.parse(readFileSync28(
|
|
18131
|
+
const state = JSON.parse(readFileSync28(path106, "utf8"));
|
|
18144
18132
|
if (state.pin !== pin2) return void 0;
|
|
18145
18133
|
return state;
|
|
18146
18134
|
} catch {
|
|
@@ -18561,8 +18549,8 @@ function findUnmergedPaths() {
|
|
|
18561
18549
|
}
|
|
18562
18550
|
const found = /* @__PURE__ */ new Set();
|
|
18563
18551
|
for (const line of output.split("\n")) {
|
|
18564
|
-
const
|
|
18565
|
-
if (
|
|
18552
|
+
const path106 = line.split(" ")[1];
|
|
18553
|
+
if (path106) found.add(path106.trim());
|
|
18566
18554
|
}
|
|
18567
18555
|
return [...found];
|
|
18568
18556
|
}
|
|
@@ -19809,11 +19797,11 @@ async function loadPath(source) {
|
|
|
19809
19797
|
}
|
|
19810
19798
|
}
|
|
19811
19799
|
async function criteriaExtension() {
|
|
19812
|
-
const
|
|
19800
|
+
const path106 = await loadPath(criteriaExtensionDir());
|
|
19813
19801
|
console.log(
|
|
19814
19802
|
chalk137.bold("acceptance criteria outliner \u2014 GitHub browser extension")
|
|
19815
19803
|
);
|
|
19816
|
-
console.log(chalk137.dim(`load the unpacked extension from ${
|
|
19804
|
+
console.log(chalk137.dim(`load the unpacked extension from ${path106}`));
|
|
19817
19805
|
}
|
|
19818
19806
|
|
|
19819
19807
|
// src/commands/criteriaExtension/signCriteriaExtension.ts
|
|
@@ -19938,10 +19926,10 @@ async function signCriteriaExtension() {
|
|
|
19938
19926
|
process.exitCode = 1;
|
|
19939
19927
|
return;
|
|
19940
19928
|
}
|
|
19941
|
-
const
|
|
19929
|
+
const path106 = await signedAddonInstallPath(
|
|
19942
19930
|
await copySignedXpi(xpi, ARTIFACTS_DIR)
|
|
19943
19931
|
);
|
|
19944
|
-
console.log(chalk139.dim(`install the signed add-on from ${
|
|
19932
|
+
console.log(chalk139.dim(`install the signed add-on from ${path106}`));
|
|
19945
19933
|
}
|
|
19946
19934
|
|
|
19947
19935
|
// src/commands/registerCriteriaExtension.ts
|
|
@@ -20039,10 +20027,10 @@ function getMigrationApprovalPath(migrationId) {
|
|
|
20039
20027
|
// src/commands/dbMigration/readMigrationPinState.ts
|
|
20040
20028
|
import { existsSync as existsSync48, readFileSync as readFileSync30 } from "fs";
|
|
20041
20029
|
function readMigrationPinState(pin2) {
|
|
20042
|
-
const
|
|
20043
|
-
if (!existsSync48(
|
|
20030
|
+
const path106 = getMigrationPinPath(pin2);
|
|
20031
|
+
if (!existsSync48(path106)) return void 0;
|
|
20044
20032
|
try {
|
|
20045
|
-
const state = JSON.parse(readFileSync30(
|
|
20033
|
+
const state = JSON.parse(readFileSync30(path106, "utf8"));
|
|
20046
20034
|
if (state.pin !== pin2) return void 0;
|
|
20047
20035
|
if (!Number.isInteger(state.migrationId)) return void 0;
|
|
20048
20036
|
return state;
|
|
@@ -21952,10 +21940,10 @@ function decideCommentGuard(input, existingContent) {
|
|
|
21952
21940
|
import { existsSync as existsSync54, unlinkSync as unlinkSync11 } from "fs";
|
|
21953
21941
|
function consumeMigrationApproval(migrationId) {
|
|
21954
21942
|
sweepRestrictedDir();
|
|
21955
|
-
const
|
|
21956
|
-
if (!existsSync54(
|
|
21943
|
+
const path106 = getMigrationApprovalPath(migrationId);
|
|
21944
|
+
if (!existsSync54(path106)) return false;
|
|
21957
21945
|
try {
|
|
21958
|
-
unlinkSync11(
|
|
21946
|
+
unlinkSync11(path106);
|
|
21959
21947
|
return true;
|
|
21960
21948
|
} catch {
|
|
21961
21949
|
return false;
|
|
@@ -24359,11 +24347,11 @@ function recentDaemonLogLines(includeRelayed = true) {
|
|
|
24359
24347
|
// src/commands/sessions/daemon/worktree/canonicalTreePath.ts
|
|
24360
24348
|
import { realpathSync as realpathSync2 } from "fs";
|
|
24361
24349
|
import { resolve as resolve15 } from "path";
|
|
24362
|
-
function canonicalTreePath(
|
|
24350
|
+
function canonicalTreePath(path106) {
|
|
24363
24351
|
try {
|
|
24364
|
-
return realpathSync2(
|
|
24352
|
+
return realpathSync2(path106);
|
|
24365
24353
|
} catch {
|
|
24366
|
-
return resolve15(
|
|
24354
|
+
return resolve15(path106);
|
|
24367
24355
|
}
|
|
24368
24356
|
}
|
|
24369
24357
|
|
|
@@ -24416,22 +24404,22 @@ function createWorktree(clone, strategy, boundTreeRoots2, preferredPath) {
|
|
|
24416
24404
|
const registered = new Set(listWorktreePaths(clone));
|
|
24417
24405
|
const branches = new Set(listLocalBranches(clone));
|
|
24418
24406
|
const isTaken = (candidate) => registered.has(candidate) || existsSync57(candidate) || boundTreeRoots2.has(candidate) || branches.has(basename17(candidate));
|
|
24419
|
-
const
|
|
24407
|
+
const path106 = preferredPath && !isTaken(preferredPath) ? preferredPath : nextWorktreePath(clone, base, isTaken);
|
|
24420
24408
|
const start3 = worktreeStartPoint(clone, strategy.trunk);
|
|
24421
24409
|
gitSync(clone, [
|
|
24422
24410
|
"worktree",
|
|
24423
24411
|
"add",
|
|
24424
24412
|
start3.track ? "--track" : "--no-track",
|
|
24425
24413
|
"-b",
|
|
24426
|
-
basename17(
|
|
24427
|
-
|
|
24414
|
+
basename17(path106),
|
|
24415
|
+
path106,
|
|
24428
24416
|
start3.ref
|
|
24429
24417
|
]);
|
|
24430
|
-
recordWorktree(
|
|
24418
|
+
recordWorktree(path106, clone, getCurrentOrigin(clone));
|
|
24431
24419
|
daemonLog(
|
|
24432
|
-
start3.track ? `worktree allocated ${
|
|
24420
|
+
start3.track ? `worktree allocated ${path106} (branch ${basename17(path106)} tracking ${start3.ref}) for clone ${clone}` : `worktree allocated ${path106} (branch ${basename17(path106)} off ${start3.ref}, no mainline tracking) for clone ${clone}`
|
|
24433
24421
|
);
|
|
24434
|
-
return
|
|
24422
|
+
return path106;
|
|
24435
24423
|
}
|
|
24436
24424
|
|
|
24437
24425
|
// src/commands/sessions/daemon/worktree/keptInTree.ts
|
|
@@ -24572,13 +24560,13 @@ function allocateTree(requestedCwd, boundTreeRoots2, options2 = {}) {
|
|
|
24572
24560
|
if (forcedSpill) daemonLog(forcedSpill);
|
|
24573
24561
|
else if (reusesClone(clone, boundTreeRoots2, reuse))
|
|
24574
24562
|
return { cwd: clone, kind: "primary", created: false, clone };
|
|
24575
|
-
const
|
|
24563
|
+
const path106 = createWorktree(
|
|
24576
24564
|
clone,
|
|
24577
24565
|
{ root: cfg.root, trunk: cfg.trunk },
|
|
24578
24566
|
boundTreeRoots2,
|
|
24579
24567
|
options2.replacesTree
|
|
24580
24568
|
);
|
|
24581
|
-
return { cwd:
|
|
24569
|
+
return { cwd: path106, kind: "worktree", created: true, clone };
|
|
24582
24570
|
}
|
|
24583
24571
|
|
|
24584
24572
|
// src/commands/sessions/daemon/describePersistedSession.ts
|
|
@@ -24928,13 +24916,13 @@ function worktreeHoldingBranch(cwd, branch2) {
|
|
|
24928
24916
|
const listing = gitSyncOrNull(cwd, ["worktree", "list", "--porcelain"]);
|
|
24929
24917
|
if (!listing) return null;
|
|
24930
24918
|
const here = gitSyncOrNull(cwd, ["rev-parse", "--show-toplevel"]);
|
|
24931
|
-
let
|
|
24919
|
+
let path106 = null;
|
|
24932
24920
|
for (const line of listing.split("\n")) {
|
|
24933
24921
|
const trimmed = line.trim();
|
|
24934
24922
|
if (trimmed.startsWith("worktree "))
|
|
24935
|
-
|
|
24923
|
+
path106 = trimmed.slice("worktree ".length).trim();
|
|
24936
24924
|
else if (trimmed === `branch refs/heads/${branch2}`)
|
|
24937
|
-
return
|
|
24925
|
+
return path106 && path106 !== here ? path106 : null;
|
|
24938
24926
|
}
|
|
24939
24927
|
return null;
|
|
24940
24928
|
}
|
|
@@ -26038,9 +26026,9 @@ function parseRscRows(flight) {
|
|
|
26038
26026
|
}
|
|
26039
26027
|
function makeRscResolver(rows) {
|
|
26040
26028
|
return (ref) => {
|
|
26041
|
-
const [id, ...
|
|
26029
|
+
const [id, ...path106] = ref.slice(1).replace(/^[L@]/, "").split(":");
|
|
26042
26030
|
let v = rows[id];
|
|
26043
|
-
for (const key of
|
|
26031
|
+
for (const key of path106) {
|
|
26044
26032
|
if (v == null || typeof v !== "object") return void 0;
|
|
26045
26033
|
v = v[key];
|
|
26046
26034
|
}
|
|
@@ -26791,18 +26779,18 @@ function validateLine(line) {
|
|
|
26791
26779
|
process.exit(1);
|
|
26792
26780
|
}
|
|
26793
26781
|
}
|
|
26794
|
-
async function comment2(
|
|
26782
|
+
async function comment2(path106, line, body, options2 = {}) {
|
|
26795
26783
|
const { startLine, skipPreview } = options2;
|
|
26796
26784
|
validateBody(body);
|
|
26797
26785
|
validateLine(line);
|
|
26798
26786
|
if (startLine !== void 0) validateLine(startLine);
|
|
26799
26787
|
const range = startLine !== void 0 ? `${startLine}-${line}` : `${line}`;
|
|
26800
26788
|
if (!skipPreview)
|
|
26801
|
-
await reviewProposedPrComment(`Comment on ${
|
|
26789
|
+
await reviewProposedPrComment(`Comment on ${path106}:${range}`, body, null);
|
|
26802
26790
|
try {
|
|
26803
26791
|
const prId = getCurrentPrNodeId();
|
|
26804
|
-
postReviewComment({ prId, body, path:
|
|
26805
|
-
console.log(`Added review comment on ${
|
|
26792
|
+
postReviewComment({ prId, body, path: path106, line, startLine });
|
|
26793
|
+
console.log(`Added review comment on ${path106}:${range}`);
|
|
26806
26794
|
} catch (error) {
|
|
26807
26795
|
if (isGhNotInstalled(error)) {
|
|
26808
26796
|
console.error("Error: GitHub CLI (gh) is not installed.");
|
|
@@ -27371,9 +27359,9 @@ function registerPrsComments(prsCommand) {
|
|
|
27371
27359
|
});
|
|
27372
27360
|
prsCommand.command("comment <path> <line> <body>").description(
|
|
27373
27361
|
"Add a line comment to the pending review (body of - reads it from stdin)"
|
|
27374
|
-
).action(async (
|
|
27362
|
+
).action(async (path106, line, body) => {
|
|
27375
27363
|
await comment2(
|
|
27376
|
-
|
|
27364
|
+
path106,
|
|
27377
27365
|
Number.parseInt(line, 10),
|
|
27378
27366
|
await readBodyArgument(body)
|
|
27379
27367
|
);
|
|
@@ -28594,11 +28582,11 @@ async function loadBody(target) {
|
|
|
28594
28582
|
if (target.kind === "file") return readDraftFile(target.path);
|
|
28595
28583
|
return fetchPrBody(target.number, target.repo);
|
|
28596
28584
|
}
|
|
28597
|
-
function readDraftFile(
|
|
28585
|
+
function readDraftFile(path106) {
|
|
28598
28586
|
try {
|
|
28599
|
-
return readFileSync44(
|
|
28587
|
+
return readFileSync44(path106, "utf8");
|
|
28600
28588
|
} catch {
|
|
28601
|
-
console.error(`Error: Could not read \`${
|
|
28589
|
+
console.error(`Error: Could not read \`${path106}\`.`);
|
|
28602
28590
|
console.error(
|
|
28603
28591
|
"Pass a pull request number, a GitHub pull request URL, - for stdin, or a path to a file."
|
|
28604
28592
|
);
|
|
@@ -28878,10 +28866,10 @@ function resolveOpSecret(reference) {
|
|
|
28878
28866
|
}
|
|
28879
28867
|
|
|
28880
28868
|
// src/commands/ravendb/ravenFetch.ts
|
|
28881
|
-
async function ravenFetch(connection,
|
|
28869
|
+
async function ravenFetch(connection, path106) {
|
|
28882
28870
|
const apiKey = resolveOpSecret(connection.apiKeyRef);
|
|
28883
28871
|
let accessToken = await getAccessToken(apiKey);
|
|
28884
|
-
const url = `${connection.url}${
|
|
28872
|
+
const url = `${connection.url}${path106}`;
|
|
28885
28873
|
const headers = {
|
|
28886
28874
|
Authorization: `Bearer ${accessToken}`,
|
|
28887
28875
|
"Content-Type": "application/json"
|
|
@@ -28971,16 +28959,16 @@ import chalk195 from "chalk";
|
|
|
28971
28959
|
// src/commands/ravendb/buildQueryPath.ts
|
|
28972
28960
|
function buildQueryPath(opts) {
|
|
28973
28961
|
const db = encodeURIComponent(opts.db);
|
|
28974
|
-
let
|
|
28962
|
+
let path106;
|
|
28975
28963
|
if (opts.collection) {
|
|
28976
|
-
|
|
28964
|
+
path106 = `/databases/${db}/indexes/dynamic/${encodeURIComponent(opts.collection)}?start=${opts.start}&pageSize=${opts.pageSize}&sort=${encodeURIComponent(opts.sort)}`;
|
|
28977
28965
|
} else {
|
|
28978
|
-
|
|
28966
|
+
path106 = `/databases/${db}/queries?start=${opts.start}&pageSize=${opts.pageSize}`;
|
|
28979
28967
|
}
|
|
28980
28968
|
if (opts.query) {
|
|
28981
|
-
|
|
28969
|
+
path106 += `&query=${encodeURIComponent(opts.query)}`;
|
|
28982
28970
|
}
|
|
28983
|
-
return
|
|
28971
|
+
return path106;
|
|
28984
28972
|
}
|
|
28985
28973
|
|
|
28986
28974
|
// src/commands/ravendb/fetchAllPages.ts
|
|
@@ -28989,7 +28977,7 @@ async function fetchAllPages(connection, opts) {
|
|
|
28989
28977
|
let start3 = 0;
|
|
28990
28978
|
while (true) {
|
|
28991
28979
|
const effectivePageSize = opts.limit !== void 0 ? Math.min(opts.pageSize, opts.limit - allResults.length) : opts.pageSize;
|
|
28992
|
-
const
|
|
28980
|
+
const path106 = buildQueryPath({
|
|
28993
28981
|
db: connection.database,
|
|
28994
28982
|
collection: opts.collection,
|
|
28995
28983
|
start: start3,
|
|
@@ -28997,7 +28985,7 @@ async function fetchAllPages(connection, opts) {
|
|
|
28997
28985
|
sort: opts.sort,
|
|
28998
28986
|
query: opts.query
|
|
28999
28987
|
});
|
|
29000
|
-
const data = await ravenFetch(connection,
|
|
28988
|
+
const data = await ravenFetch(connection, path106);
|
|
29001
28989
|
const results = data.Results ?? [];
|
|
29002
28990
|
const totalResults = data.TotalResults ?? 0;
|
|
29003
28991
|
if (results.length === 0) break;
|
|
@@ -31511,7 +31499,7 @@ Renamed ${oldName} \u2192 ${newName}`));
|
|
|
31511
31499
|
|
|
31512
31500
|
// src/commands/refactor/restructure.ts
|
|
31513
31501
|
import fs38 from "fs";
|
|
31514
|
-
import
|
|
31502
|
+
import path80 from "path";
|
|
31515
31503
|
import chalk223 from "chalk";
|
|
31516
31504
|
|
|
31517
31505
|
// src/commands/refactor/restructure/buildPlan.ts
|
|
@@ -31570,15 +31558,24 @@ function anchorTest(file, index3) {
|
|
|
31570
31558
|
"test of"
|
|
31571
31559
|
);
|
|
31572
31560
|
}
|
|
31561
|
+
function anchorImporters(importers, fixed2) {
|
|
31562
|
+
const all = [...importers, ...fixed2];
|
|
31563
|
+
const prefix2 = all.length === 1 ? "imported only by" : "shared by";
|
|
31564
|
+
const anchoring = anchored(all, "child", prefix2);
|
|
31565
|
+
const fixedSet = new Set(fixed2);
|
|
31566
|
+
return {
|
|
31567
|
+
...anchoring,
|
|
31568
|
+
anchors: anchoring.anchors.map(
|
|
31569
|
+
(a) => fixedSet.has(a.file) ? { ...a, mode: "fixed" } : a
|
|
31570
|
+
)
|
|
31571
|
+
};
|
|
31572
|
+
}
|
|
31573
31573
|
function anchorModule(file, index3) {
|
|
31574
31574
|
if (index3.external.has(file)) return root("imported from outside scope");
|
|
31575
31575
|
const importers = sorted(index3.importers.get(file));
|
|
31576
|
-
|
|
31577
|
-
|
|
31578
|
-
|
|
31579
|
-
"child",
|
|
31580
|
-
importers.length === 1 ? "imported only by" : "shared by"
|
|
31581
|
-
);
|
|
31576
|
+
const fixed2 = sorted(index3.fixedImporters.get(file));
|
|
31577
|
+
if (importers.length + fixed2.length > 0)
|
|
31578
|
+
return anchorImporters(importers, fixed2);
|
|
31582
31579
|
const tests = sorted(index3.testImporters.get(file));
|
|
31583
31580
|
if (tests.length > 0) return anchored(tests, "sibling", "used only by tests");
|
|
31584
31581
|
return root("no importers in scope");
|
|
@@ -31613,16 +31610,21 @@ function add3(map, key, value) {
|
|
|
31613
31610
|
set.add(value);
|
|
31614
31611
|
map.set(key, set);
|
|
31615
31612
|
}
|
|
31616
|
-
function indexEdges(scope, edges) {
|
|
31613
|
+
function indexEdges(scope, edges, fixed2) {
|
|
31617
31614
|
const index3 = {
|
|
31618
31615
|
importers: /* @__PURE__ */ new Map(),
|
|
31619
31616
|
testImporters: /* @__PURE__ */ new Map(),
|
|
31617
|
+
fixedImporters: /* @__PURE__ */ new Map(),
|
|
31620
31618
|
imports: /* @__PURE__ */ new Map(),
|
|
31621
31619
|
external: /* @__PURE__ */ new Set()
|
|
31622
31620
|
};
|
|
31623
31621
|
for (const { source, target } of edges) {
|
|
31624
31622
|
if (!scope.has(target) || source === target) continue;
|
|
31625
31623
|
const test = isTestFile(source);
|
|
31624
|
+
if (fixed2.has(source)) {
|
|
31625
|
+
if (!test) add3(index3.fixedImporters, target, source);
|
|
31626
|
+
continue;
|
|
31627
|
+
}
|
|
31626
31628
|
if (!scope.has(source)) {
|
|
31627
31629
|
if (!test) index3.external.add(target);
|
|
31628
31630
|
continue;
|
|
@@ -31664,6 +31666,7 @@ function lowestCommonAncestor(dirs) {
|
|
|
31664
31666
|
|
|
31665
31667
|
// src/commands/refactor/restructure/planRestructure/componentDir.ts
|
|
31666
31668
|
function anchorFolder(anchor, dirs) {
|
|
31669
|
+
if (anchor.mode === "fixed") return path68.dirname(anchor.file);
|
|
31667
31670
|
const dir = dirs.get(anchor.file);
|
|
31668
31671
|
return anchor.mode === "child" ? path68.join(dir, moduleStem(anchor.file)) : dir;
|
|
31669
31672
|
}
|
|
@@ -31743,7 +31746,8 @@ function findStronglyConnectedComponents(nodes, successors) {
|
|
|
31743
31746
|
|
|
31744
31747
|
// src/commands/refactor/restructure/planRestructure/placeComponents.ts
|
|
31745
31748
|
function isPinFolderOwner(anchoring) {
|
|
31746
|
-
|
|
31749
|
+
const onlyFixed = anchoring.anchors.length > 0 && anchoring.anchors.every((a) => a.mode === "fixed");
|
|
31750
|
+
return anchoring.root || anchoring.pinned === true || onlyFixed;
|
|
31747
31751
|
}
|
|
31748
31752
|
function componentReason(file, component, base) {
|
|
31749
31753
|
if (component.length === 1) return base;
|
|
@@ -31751,7 +31755,7 @@ function componentReason(file, component, base) {
|
|
|
31751
31755
|
return `${base}; cycle with ${others.join(", ")}`;
|
|
31752
31756
|
}
|
|
31753
31757
|
function placeComponents(files, anchorings, scopeRoot) {
|
|
31754
|
-
const successors = (file) => anchorings.get(file).anchors.map((a) => a.file);
|
|
31758
|
+
const successors = (file) => anchorings.get(file).anchors.filter((a) => a.mode !== "fixed").map((a) => a.file);
|
|
31755
31759
|
const layout = { scopeRoot, dirs: /* @__PURE__ */ new Map(), pinFolders: /* @__PURE__ */ new Set() };
|
|
31756
31760
|
const placements = /* @__PURE__ */ new Map();
|
|
31757
31761
|
for (const component of findStronglyConnectedComponents(files, successors)) {
|
|
@@ -31774,7 +31778,11 @@ function placeComponents(files, anchorings, scopeRoot) {
|
|
|
31774
31778
|
function planRestructure(input) {
|
|
31775
31779
|
const scopeRoot = path70.resolve(input.scopeRoot);
|
|
31776
31780
|
const files = [...new Set(input.files)].sort();
|
|
31777
|
-
const index3 = indexEdges(
|
|
31781
|
+
const index3 = indexEdges(
|
|
31782
|
+
new Set(files),
|
|
31783
|
+
input.edges,
|
|
31784
|
+
new Set(input.fixedFiles)
|
|
31785
|
+
);
|
|
31778
31786
|
const anchorings = collectAnchors(files, index3, new Set(input.pinnedModules));
|
|
31779
31787
|
const placements = placeComponents(files, anchorings, scopeRoot);
|
|
31780
31788
|
const targets = /* @__PURE__ */ new Map();
|
|
@@ -31811,7 +31819,8 @@ function buildPlan3(scopeRoot, files, ignored = [], pinnedModules = []) {
|
|
|
31811
31819
|
scopeRoot,
|
|
31812
31820
|
files,
|
|
31813
31821
|
edges: graph.edges.filter((e) => !e.mock),
|
|
31814
|
-
pinnedModules
|
|
31822
|
+
pinnedModules,
|
|
31823
|
+
fixedFiles: ignored
|
|
31815
31824
|
});
|
|
31816
31825
|
const allProjectFiles = /* @__PURE__ */ new Set([
|
|
31817
31826
|
...graph.importedBy.keys(),
|
|
@@ -31892,33 +31901,20 @@ Plan exceeds restructure.maxDepth ${maxDepth}: ${tooDeep} file(s) deeper.`
|
|
|
31892
31901
|
// src/commands/refactor/restructure/displayLayoutLimits.ts
|
|
31893
31902
|
function pinSteps(apply) {
|
|
31894
31903
|
return [
|
|
31895
|
-
"
|
|
31896
|
-
"1.
|
|
31904
|
+
"Pin feature modules until this check passes:",
|
|
31905
|
+
"1. On each chain, pick the highest module that is a feature boundary: a route, view, page, panel, dialog or card. Never a hook, utility, style file or helper.",
|
|
31897
31906
|
"2. Add it to restructure.pin in assist.yml yourself (basename without extension). One pin at a time: one feature pin often fixes several chains.",
|
|
31898
|
-
"3.
|
|
31899
|
-
"4.
|
|
31900
|
-
"5. If a chain has no sensible feature boundary, or every pin that fixes the depth pushes a folder over the limit, stop and report it.",
|
|
31907
|
+
"3. Re-run this command. Repeat until the plan is within the limit.",
|
|
31908
|
+
"4. If a chain has no sensible feature boundary, stop and report that chain.",
|
|
31901
31909
|
`Then run \`${apply}\`.`
|
|
31902
31910
|
];
|
|
31903
31911
|
}
|
|
31904
|
-
function displayLargeFolders(folders, limit) {
|
|
31905
|
-
if (folders.length === 0) return;
|
|
31906
|
-
console.log(
|
|
31907
|
-
chalk217.red(
|
|
31908
|
-
`
|
|
31909
|
-
Plan puts more than ${limit} file(s) in ${folders.length} folder(s) (restructure.maxFolderPercent of all files, capped at restructure.maxFolderFiles):`
|
|
31910
|
-
)
|
|
31911
|
-
);
|
|
31912
|
-
for (const { folder, files } of folders)
|
|
31913
|
-
console.log(` ${folder}/ ${files} file(s)`);
|
|
31914
|
-
}
|
|
31915
31912
|
function exceedsLayoutLimits(limits) {
|
|
31916
|
-
return limits.chains.length > 0
|
|
31913
|
+
return limits.chains.length > 0;
|
|
31917
31914
|
}
|
|
31918
31915
|
function displayLayoutLimits(limits, apply) {
|
|
31919
31916
|
if (!exceedsLayoutLimits(limits)) return;
|
|
31920
31917
|
displayDeepChains(limits.chains, limits.maxDepth);
|
|
31921
|
-
displayLargeFolders(limits.largeFolders, limits.folderLimit);
|
|
31922
31918
|
console.log("");
|
|
31923
31919
|
for (const line of pinSteps(apply)) console.log(chalk217.yellow(line));
|
|
31924
31920
|
}
|
|
@@ -31980,43 +31976,20 @@ function findDeepChains(targets, scopeRoot, maxDepth) {
|
|
|
31980
31976
|
return [...chains.entries()].sort(([ka, a], [kb, b]) => b.tooDeep - a.tooDeep || ka.localeCompare(kb)).map(([, chain2]) => chain2);
|
|
31981
31977
|
}
|
|
31982
31978
|
|
|
31983
|
-
// src/commands/refactor/restructure/findLargeFolders.ts
|
|
31984
|
-
import path75 from "path";
|
|
31985
|
-
function findLargeFolders(targets, scopeRoot, limit) {
|
|
31986
|
-
const counts2 = /* @__PURE__ */ new Map();
|
|
31987
|
-
for (const target of targets) {
|
|
31988
|
-
const folder = path75.relative(scopeRoot, path75.dirname(target));
|
|
31989
|
-
if (folder !== "") counts2.set(folder, (counts2.get(folder) ?? 0) + 1);
|
|
31990
|
-
}
|
|
31991
|
-
return [...counts2].filter(([, files]) => files > limit).sort(([a, fa], [b, fb]) => fb - fa || a.localeCompare(b)).map(([folder, files]) => ({
|
|
31992
|
-
folder: folder.split(path75.sep).join("/"),
|
|
31993
|
-
files
|
|
31994
|
-
}));
|
|
31995
|
-
}
|
|
31996
|
-
|
|
31997
31979
|
// src/commands/refactor/restructure/checkLayoutLimits.ts
|
|
31998
|
-
|
|
31999
|
-
function checkLayoutLimits(plan2, settings) {
|
|
32000
|
-
const targets = [...plan2.targets.values()];
|
|
32001
|
-
const share = Math.ceil(targets.length * settings.maxFolderPercent / 100);
|
|
32002
|
-
const folderLimit = Math.min(
|
|
32003
|
-
Math.max(share, minFolderLimit),
|
|
32004
|
-
settings.maxFolderFiles
|
|
32005
|
-
);
|
|
31980
|
+
function checkLayoutLimits(plan2, maxDepth) {
|
|
32006
31981
|
return {
|
|
32007
|
-
maxDepth
|
|
32008
|
-
chains: findDeepChains(targets, plan2.scopeRoot,
|
|
32009
|
-
folderLimit,
|
|
32010
|
-
largeFolders: findLargeFolders(targets, plan2.scopeRoot, folderLimit)
|
|
31982
|
+
maxDepth,
|
|
31983
|
+
chains: findDeepChains(plan2.targets.values(), plan2.scopeRoot, maxDepth)
|
|
32011
31984
|
};
|
|
32012
31985
|
}
|
|
32013
31986
|
|
|
32014
31987
|
// src/commands/refactor/restructure/partitionIgnored.ts
|
|
32015
|
-
import
|
|
31988
|
+
import path75 from "path";
|
|
32016
31989
|
import { minimatch as minimatch4 } from "minimatch";
|
|
32017
31990
|
function partitionIgnored(files) {
|
|
32018
31991
|
const globs = loadConfig().restructure?.ignore ?? [];
|
|
32019
|
-
const isIgnored = (file) => globs.some((glob) => minimatch4(
|
|
31992
|
+
const isIgnored = (file) => globs.some((glob) => minimatch4(path75.relative(process.cwd(), file), glob));
|
|
32020
31993
|
return {
|
|
32021
31994
|
scoped: files.filter((f) => !isIgnored(f)),
|
|
32022
31995
|
ignored: files.filter(isIgnored)
|
|
@@ -32031,10 +32004,10 @@ import chalk220 from "chalk";
|
|
|
32031
32004
|
|
|
32032
32005
|
// src/commands/refactor/restructure/executePlan.ts
|
|
32033
32006
|
import fs37 from "fs";
|
|
32034
|
-
import
|
|
32007
|
+
import path76 from "path";
|
|
32035
32008
|
import chalk219 from "chalk";
|
|
32036
32009
|
function relPath(file) {
|
|
32037
|
-
return
|
|
32010
|
+
return path76.relative(process.cwd(), file);
|
|
32038
32011
|
}
|
|
32039
32012
|
function stagingPath(move2, index3) {
|
|
32040
32013
|
return `${move2.from}.restructure-${process.pid}-${index3}`;
|
|
@@ -32046,7 +32019,7 @@ function moveFiles(moves) {
|
|
|
32046
32019
|
return { move: move2, staging };
|
|
32047
32020
|
});
|
|
32048
32021
|
for (const { move: move2, staging } of staged) {
|
|
32049
|
-
fs37.mkdirSync(
|
|
32022
|
+
fs37.mkdirSync(path76.dirname(move2.to), { recursive: true });
|
|
32050
32023
|
fs37.renameSync(staging, move2.to);
|
|
32051
32024
|
console.log(
|
|
32052
32025
|
chalk219.white(` Moved ${relPath(move2.from)} \u2192 ${relPath(move2.to)}`)
|
|
@@ -32062,8 +32035,8 @@ function removeIfEmpty(dir) {
|
|
|
32062
32035
|
function removeEmptyDirectories(dirs, scopeRoot) {
|
|
32063
32036
|
const deepestFirst = [...new Set(dirs)].sort((a, b) => b.length - a.length);
|
|
32064
32037
|
for (let dir of deepestFirst) {
|
|
32065
|
-
while (dir.startsWith(`${scopeRoot}${
|
|
32066
|
-
dir =
|
|
32038
|
+
while (dir.startsWith(`${scopeRoot}${path76.sep}`) && removeIfEmpty(dir))
|
|
32039
|
+
dir = path76.dirname(dir);
|
|
32067
32040
|
}
|
|
32068
32041
|
}
|
|
32069
32042
|
function executePlan(plan2) {
|
|
@@ -32073,7 +32046,7 @@ function executePlan(plan2) {
|
|
|
32073
32046
|
}
|
|
32074
32047
|
moveFiles(plan2.moves);
|
|
32075
32048
|
removeEmptyDirectories(
|
|
32076
|
-
plan2.moves.map((m) =>
|
|
32049
|
+
plan2.moves.map((m) => path76.dirname(m.from)),
|
|
32077
32050
|
plan2.scopeRoot
|
|
32078
32051
|
);
|
|
32079
32052
|
}
|
|
@@ -32090,17 +32063,17 @@ function applyPlan(plan2) {
|
|
|
32090
32063
|
}
|
|
32091
32064
|
|
|
32092
32065
|
// src/commands/refactor/restructure/displayPlan.ts
|
|
32093
|
-
import
|
|
32066
|
+
import path79 from "path";
|
|
32094
32067
|
import chalk221 from "chalk";
|
|
32095
32068
|
|
|
32096
32069
|
// src/commands/refactor/restructure/computeDepthStats.ts
|
|
32097
|
-
import
|
|
32070
|
+
import path77 from "path";
|
|
32098
32071
|
function computeDepthStats(targets, scopeRoot) {
|
|
32099
32072
|
const distribution = /* @__PURE__ */ new Map();
|
|
32100
32073
|
let max = 0;
|
|
32101
32074
|
for (const target of targets) {
|
|
32102
|
-
const dir =
|
|
32103
|
-
const depth = dir === "" ? 0 : dir.split(
|
|
32075
|
+
const dir = path77.relative(scopeRoot, path77.dirname(target));
|
|
32076
|
+
const depth = dir === "" ? 0 : dir.split(path77.sep).length;
|
|
32104
32077
|
distribution.set(depth, (distribution.get(depth) ?? 0) + 1);
|
|
32105
32078
|
max = Math.max(max, depth);
|
|
32106
32079
|
}
|
|
@@ -32108,7 +32081,7 @@ function computeDepthStats(targets, scopeRoot) {
|
|
|
32108
32081
|
}
|
|
32109
32082
|
|
|
32110
32083
|
// src/commands/refactor/restructure/formatTree.ts
|
|
32111
|
-
import
|
|
32084
|
+
import path78 from "path";
|
|
32112
32085
|
function insert(root2, parts) {
|
|
32113
32086
|
let node = root2;
|
|
32114
32087
|
for (const part of parts) {
|
|
@@ -32130,7 +32103,7 @@ function render(node, indent3, lines2) {
|
|
|
32130
32103
|
function formatTree(files, scopeRoot) {
|
|
32131
32104
|
const root2 = /* @__PURE__ */ new Map();
|
|
32132
32105
|
for (const file of files)
|
|
32133
|
-
insert(root2,
|
|
32106
|
+
insert(root2, path78.relative(scopeRoot, file).split(path78.sep));
|
|
32134
32107
|
const lines2 = [];
|
|
32135
32108
|
render(root2, "", lines2);
|
|
32136
32109
|
return lines2;
|
|
@@ -32138,7 +32111,7 @@ function formatTree(files, scopeRoot) {
|
|
|
32138
32111
|
|
|
32139
32112
|
// src/commands/refactor/restructure/displayPlan.ts
|
|
32140
32113
|
function relPath2(filePath) {
|
|
32141
|
-
return
|
|
32114
|
+
return path79.relative(process.cwd(), filePath);
|
|
32142
32115
|
}
|
|
32143
32116
|
function displayMoves(plan2) {
|
|
32144
32117
|
if (plan2.moves.length === 0) return;
|
|
@@ -32204,7 +32177,7 @@ function runPlan(plan2, limits, apply) {
|
|
|
32204
32177
|
|
|
32205
32178
|
// src/commands/refactor/restructure.ts
|
|
32206
32179
|
async function restructure(root2, options2 = {}) {
|
|
32207
|
-
const scopeRoot =
|
|
32180
|
+
const scopeRoot = path80.resolve(root2 ?? "src");
|
|
32208
32181
|
if (!fs38.existsSync(scopeRoot) || !fs38.statSync(scopeRoot).isDirectory()) {
|
|
32209
32182
|
console.log(chalk223.red(`Not a directory: ${root2 ?? "src"}`));
|
|
32210
32183
|
process.exit(1);
|
|
@@ -32216,18 +32189,9 @@ async function restructure(root2, options2 = {}) {
|
|
|
32216
32189
|
console.log(chalk223.yellow("No files found under root"));
|
|
32217
32190
|
return;
|
|
32218
32191
|
}
|
|
32219
|
-
const {
|
|
32220
|
-
pin: pin2 = [],
|
|
32221
|
-
maxDepth = 10,
|
|
32222
|
-
maxFolderPercent = 15,
|
|
32223
|
-
maxFolderFiles = 150
|
|
32224
|
-
} = loadConfig().restructure ?? {};
|
|
32192
|
+
const { pin: pin2 = [], maxDepth = 10 } = loadConfig().restructure ?? {};
|
|
32225
32193
|
const plan2 = buildPlan3(scopeRoot, scoped, ignored, pin2);
|
|
32226
|
-
const limits = checkLayoutLimits(plan2,
|
|
32227
|
-
maxDepth,
|
|
32228
|
-
maxFolderPercent,
|
|
32229
|
-
maxFolderFiles
|
|
32230
|
-
});
|
|
32194
|
+
const limits = checkLayoutLimits(plan2, maxDepth);
|
|
32231
32195
|
if (options2.check) return checkPlan(plan2, limits);
|
|
32232
32196
|
runPlan(plan2, limits, options2.apply === true);
|
|
32233
32197
|
}
|
|
@@ -32604,8 +32568,8 @@ function groupFilesByDirectory(files) {
|
|
|
32604
32568
|
}
|
|
32605
32569
|
|
|
32606
32570
|
// src/commands/review/highLevel/buildHighLevelTree.ts
|
|
32607
|
-
function basename19(
|
|
32608
|
-
return
|
|
32571
|
+
function basename19(path106) {
|
|
32572
|
+
return path106.slice(path106.lastIndexOf("/") + 1);
|
|
32609
32573
|
}
|
|
32610
32574
|
function sum(nodes, key) {
|
|
32611
32575
|
return nodes.reduce((total, node) => total + node[key], 0);
|
|
@@ -32628,19 +32592,19 @@ function nodesOf(at2, prefix2) {
|
|
|
32628
32592
|
}
|
|
32629
32593
|
function collapsedDirNode(name, at2, prefix2) {
|
|
32630
32594
|
let label2 = name;
|
|
32631
|
-
let
|
|
32595
|
+
let path106 = prefix2 ? `${prefix2}/${name}` : name;
|
|
32632
32596
|
let node = at2;
|
|
32633
32597
|
while (node.files.length === 0 && node.dirs.size === 1) {
|
|
32634
32598
|
const [childName, child] = [...node.dirs][0];
|
|
32635
32599
|
label2 = `${label2}/${childName}`;
|
|
32636
|
-
|
|
32600
|
+
path106 = `${path106}/${childName}`;
|
|
32637
32601
|
node = child;
|
|
32638
32602
|
}
|
|
32639
|
-
const children = nodesOf(node,
|
|
32603
|
+
const children = nodesOf(node, path106);
|
|
32640
32604
|
return {
|
|
32641
32605
|
kind: "dir",
|
|
32642
32606
|
name: label2,
|
|
32643
|
-
path:
|
|
32607
|
+
path: path106,
|
|
32644
32608
|
additions: sum(children, "additions"),
|
|
32645
32609
|
deletions: sum(children, "deletions"),
|
|
32646
32610
|
children
|
|
@@ -32898,8 +32862,8 @@ function toStatus(status3) {
|
|
|
32898
32862
|
if (status3 === "removed") return "removed";
|
|
32899
32863
|
return "modified";
|
|
32900
32864
|
}
|
|
32901
|
-
function diffUrl(repo, prNumber,
|
|
32902
|
-
const anchor = createHash3("sha256").update(
|
|
32865
|
+
function diffUrl(repo, prNumber, path106) {
|
|
32866
|
+
const anchor = createHash3("sha256").update(path106).digest("hex");
|
|
32903
32867
|
return `https://github.com/${repo}/pull/${prNumber}/files#diff-${anchor}`;
|
|
32904
32868
|
}
|
|
32905
32869
|
function fetchHighLevelFiles(prNumber, repo) {
|
|
@@ -32955,10 +32919,10 @@ function highLevelReviewPath(repo, headRef, headSha) {
|
|
|
32955
32919
|
|
|
32956
32920
|
// src/commands/review/highLevel/loadHighLevelReview.ts
|
|
32957
32921
|
function loadHighLevelReview(repo, headRef, headSha) {
|
|
32958
|
-
const
|
|
32959
|
-
if (!existsSync64(
|
|
32922
|
+
const path106 = highLevelReviewPath(repo, headRef, headSha);
|
|
32923
|
+
if (!existsSync64(path106)) return void 0;
|
|
32960
32924
|
try {
|
|
32961
|
-
return JSON.parse(readFileSync47(
|
|
32925
|
+
return JSON.parse(readFileSync47(path106, "utf8"));
|
|
32962
32926
|
} catch {
|
|
32963
32927
|
return void 0;
|
|
32964
32928
|
}
|
|
@@ -32969,8 +32933,8 @@ import { minimatch as minimatch7 } from "minimatch";
|
|
|
32969
32933
|
function selectCriticalDiffs(files, criticalPaths) {
|
|
32970
32934
|
if (criticalPaths.length === 0) return [];
|
|
32971
32935
|
return files.filter((file) => criticalPaths.some((glob) => minimatch7(file.path, glob))).map(
|
|
32972
|
-
({ path:
|
|
32973
|
-
path:
|
|
32936
|
+
({ path: path106, status: status3, additions, deletions, diffUrl: diffUrl2, patch: patch2, truncated }) => ({
|
|
32937
|
+
path: path106,
|
|
32974
32938
|
status: status3,
|
|
32975
32939
|
additions,
|
|
32976
32940
|
deletions,
|
|
@@ -33085,11 +33049,11 @@ function highLevelPreviewPayload(subject) {
|
|
|
33085
33049
|
import { mkdirSync as mkdirSync22, writeFileSync as writeFileSync39 } from "fs";
|
|
33086
33050
|
import { dirname as dirname36 } from "path";
|
|
33087
33051
|
function saveHighLevelReview(record) {
|
|
33088
|
-
const
|
|
33089
|
-
mkdirSync22(dirname36(
|
|
33090
|
-
writeFileSync39(
|
|
33052
|
+
const path106 = highLevelReviewPath(record.repo, record.headRef, record.headSha);
|
|
33053
|
+
mkdirSync22(dirname36(path106), { recursive: true });
|
|
33054
|
+
writeFileSync39(path106, `${JSON.stringify(record, null, 2)}
|
|
33091
33055
|
`);
|
|
33092
|
-
return
|
|
33056
|
+
return path106;
|
|
33093
33057
|
}
|
|
33094
33058
|
|
|
33095
33059
|
// src/commands/review/highLevel/openHighLevelOverlay.ts
|
|
@@ -33108,9 +33072,9 @@ async function openHighLevelOverlay(sessionId, subject) {
|
|
|
33108
33072
|
{ rejectIsOutcome: true }
|
|
33109
33073
|
);
|
|
33110
33074
|
const record = buildHighLevelRecord(subject, decision);
|
|
33111
|
-
const
|
|
33075
|
+
const path106 = saveHighLevelReview(record);
|
|
33112
33076
|
console.log(`Verdict: ${record.verdict}`);
|
|
33113
|
-
console.log(`Saved ${
|
|
33077
|
+
console.log(`Saved ${path106}`);
|
|
33114
33078
|
console.log("Nothing was posted to GitHub.");
|
|
33115
33079
|
return record;
|
|
33116
33080
|
}
|
|
@@ -34125,8 +34089,8 @@ async function handlePostSynthesis(synthesisPath, prInfo, options2) {
|
|
|
34125
34089
|
// src/commands/review/prepareReviewDir.ts
|
|
34126
34090
|
import { existsSync as existsSync65, mkdirSync as mkdirSync23, unlinkSync as unlinkSync18, writeFileSync as writeFileSync40 } from "fs";
|
|
34127
34091
|
function clearReviewFiles(paths) {
|
|
34128
|
-
for (const
|
|
34129
|
-
if (existsSync65(
|
|
34092
|
+
for (const path106 of [paths.claudePath, paths.codexPath, paths.synthesisPath]) {
|
|
34093
|
+
if (existsSync65(path106)) unlinkSync18(path106);
|
|
34130
34094
|
}
|
|
34131
34095
|
}
|
|
34132
34096
|
function prepareReviewDir(paths, requestBody, force) {
|
|
@@ -35364,7 +35328,7 @@ function registerReview(program2) {
|
|
|
35364
35328
|
|
|
35365
35329
|
// src/commands/rules/addRule.ts
|
|
35366
35330
|
import { existsSync as existsSync70, readFileSync as readFileSync53, writeFileSync as writeFileSync43 } from "fs";
|
|
35367
|
-
import
|
|
35331
|
+
import path85 from "path";
|
|
35368
35332
|
import chalk235 from "chalk";
|
|
35369
35333
|
|
|
35370
35334
|
// src/commands/rules/insertRuleBullet.ts
|
|
@@ -35392,7 +35356,7 @@ import { readFileSync as readFileSync50 } from "fs";
|
|
|
35392
35356
|
|
|
35393
35357
|
// src/commands/rules/findClaudeFiles.ts
|
|
35394
35358
|
import { readdirSync as readdirSync13 } from "fs";
|
|
35395
|
-
import
|
|
35359
|
+
import path81 from "path";
|
|
35396
35360
|
var SKIP_DIRECTORIES = /* @__PURE__ */ new Set(["node_modules", "dist", "build", "coverage"]);
|
|
35397
35361
|
function findClaudeFiles(dir) {
|
|
35398
35362
|
const results = [];
|
|
@@ -35400,9 +35364,9 @@ function findClaudeFiles(dir) {
|
|
|
35400
35364
|
if (entry.isDirectory()) {
|
|
35401
35365
|
if (entry.name.startsWith(".") || SKIP_DIRECTORIES.has(entry.name))
|
|
35402
35366
|
continue;
|
|
35403
|
-
results.push(...findClaudeFiles(
|
|
35367
|
+
results.push(...findClaudeFiles(path81.join(dir, entry.name)));
|
|
35404
35368
|
} else if (entry.name === "CLAUDE.md") {
|
|
35405
|
-
results.push(
|
|
35369
|
+
results.push(path81.join(dir, entry.name));
|
|
35406
35370
|
}
|
|
35407
35371
|
}
|
|
35408
35372
|
return results;
|
|
@@ -35421,34 +35385,34 @@ function nextRuleCode(root2) {
|
|
|
35421
35385
|
|
|
35422
35386
|
// src/commands/rules/resolveRuleScope.ts
|
|
35423
35387
|
import { existsSync as existsSync68 } from "fs";
|
|
35424
|
-
import
|
|
35388
|
+
import path82 from "path";
|
|
35425
35389
|
function resolveRuleScope(target) {
|
|
35426
|
-
const resolved =
|
|
35427
|
-
if (
|
|
35390
|
+
const resolved = path82.resolve(target);
|
|
35391
|
+
if (path82.basename(resolved) === "CLAUDE.md") return resolved;
|
|
35428
35392
|
const startDir = scopeDirectory(resolved);
|
|
35429
35393
|
const root2 = findRepoRoot(startDir) ?? startDir;
|
|
35430
35394
|
let current = startDir;
|
|
35431
35395
|
while (true) {
|
|
35432
|
-
const candidate =
|
|
35396
|
+
const candidate = path82.join(current, "CLAUDE.md");
|
|
35433
35397
|
if (existsSync68(candidate)) return candidate;
|
|
35434
|
-
if (current === root2 || current ===
|
|
35435
|
-
current =
|
|
35398
|
+
if (current === root2 || current === path82.dirname(current)) break;
|
|
35399
|
+
current = path82.dirname(current);
|
|
35436
35400
|
}
|
|
35437
|
-
return
|
|
35401
|
+
return path82.join(root2, "CLAUDE.md");
|
|
35438
35402
|
}
|
|
35439
35403
|
|
|
35440
35404
|
// src/commands/rules/updateScopedRulesIndex.ts
|
|
35441
35405
|
import { existsSync as existsSync69, readFileSync as readFileSync52, writeFileSync as writeFileSync42 } from "fs";
|
|
35442
|
-
import
|
|
35406
|
+
import path84 from "path";
|
|
35443
35407
|
|
|
35444
35408
|
// src/commands/rules/scopedRuleDirectories.ts
|
|
35445
35409
|
import { readFileSync as readFileSync51 } from "fs";
|
|
35446
|
-
import
|
|
35410
|
+
import path83 from "path";
|
|
35447
35411
|
function scopedRuleDirectories(root2) {
|
|
35448
35412
|
return findClaudeFiles(root2).filter(
|
|
35449
|
-
(file) =>
|
|
35413
|
+
(file) => path83.dirname(file) !== root2 && parseRulesSection(readFileSync51(file, "utf8")).length > 0
|
|
35450
35414
|
).map(
|
|
35451
|
-
(file) => `${
|
|
35415
|
+
(file) => `${path83.relative(root2, path83.dirname(file)).split(path83.sep).join("/")}/`
|
|
35452
35416
|
).sort();
|
|
35453
35417
|
}
|
|
35454
35418
|
|
|
@@ -35487,7 +35451,7 @@ function upsertScopedRulesPointer(content, directories) {
|
|
|
35487
35451
|
// src/commands/rules/updateScopedRulesIndex.ts
|
|
35488
35452
|
function updateScopedRulesIndex(root2) {
|
|
35489
35453
|
const directories = scopedRuleDirectories(root2);
|
|
35490
|
-
const rootFile =
|
|
35454
|
+
const rootFile = path84.join(root2, "CLAUDE.md");
|
|
35491
35455
|
const before = existsSync69(rootFile) ? readFileSync52(rootFile, "utf8") : "";
|
|
35492
35456
|
const after = upsertScopedRulesPointer(before, directories);
|
|
35493
35457
|
if (after !== before) writeFileSync42(rootFile, after);
|
|
@@ -35506,7 +35470,7 @@ function addRule(text18, options2) {
|
|
|
35506
35470
|
return;
|
|
35507
35471
|
}
|
|
35508
35472
|
const target = resolveRuleScope(options2.scope ?? process.cwd());
|
|
35509
|
-
const targetDir =
|
|
35473
|
+
const targetDir = path85.dirname(target);
|
|
35510
35474
|
const root2 = findRepoRoot(targetDir) ?? targetDir;
|
|
35511
35475
|
const code = nextRuleCode(root2);
|
|
35512
35476
|
writeFileSync43(
|
|
@@ -35519,18 +35483,18 @@ function addRule(text18, options2) {
|
|
|
35519
35483
|
);
|
|
35520
35484
|
updateScopedRulesIndex(root2);
|
|
35521
35485
|
console.log(
|
|
35522
|
-
`Added ${chalk235.cyan(code)} to ${
|
|
35486
|
+
`Added ${chalk235.cyan(code)} to ${path85.relative(process.cwd(), target) || target}`
|
|
35523
35487
|
);
|
|
35524
35488
|
}
|
|
35525
35489
|
|
|
35526
35490
|
// src/commands/rules/indexRules.ts
|
|
35527
|
-
import
|
|
35491
|
+
import path86 from "path";
|
|
35528
35492
|
import chalk236 from "chalk";
|
|
35529
35493
|
function indexRules() {
|
|
35530
35494
|
const startDir = scopeDirectory(process.cwd());
|
|
35531
35495
|
const root2 = findRepoRoot(startDir) ?? startDir;
|
|
35532
35496
|
const directories = updateScopedRulesIndex(root2);
|
|
35533
|
-
const rootFile =
|
|
35497
|
+
const rootFile = path86.relative(process.cwd(), path86.join(root2, "CLAUDE.md"));
|
|
35534
35498
|
if (directories.length === 0) {
|
|
35535
35499
|
console.log(
|
|
35536
35500
|
chalk236.gray(`No directories carry their own \`## Rules\` under ${root2}`)
|
|
@@ -35543,13 +35507,13 @@ function indexRules() {
|
|
|
35543
35507
|
}
|
|
35544
35508
|
|
|
35545
35509
|
// src/commands/rules/listRules.ts
|
|
35546
|
-
import
|
|
35510
|
+
import path87 from "path";
|
|
35547
35511
|
import chalk237 from "chalk";
|
|
35548
35512
|
function listRules(target, options2 = {}) {
|
|
35549
|
-
const resolved =
|
|
35513
|
+
const resolved = path87.resolve(target ?? process.cwd());
|
|
35550
35514
|
const rules3 = readScopedRules(resolved);
|
|
35551
35515
|
if (rules3.length === 0) {
|
|
35552
|
-
const label2 =
|
|
35516
|
+
const label2 = path87.relative(process.cwd(), resolved) || ".";
|
|
35553
35517
|
console.log(chalk237.gray(`No rules in scope for ${label2}`));
|
|
35554
35518
|
return;
|
|
35555
35519
|
}
|
|
@@ -35560,7 +35524,7 @@ function listRules(target, options2 = {}) {
|
|
|
35560
35524
|
if (rule.source !== shown) {
|
|
35561
35525
|
shown = rule.source;
|
|
35562
35526
|
console.log(
|
|
35563
|
-
chalk237.dim(base ?
|
|
35527
|
+
chalk237.dim(base ? path87.relative(base, rule.source) : rule.source)
|
|
35564
35528
|
);
|
|
35565
35529
|
}
|
|
35566
35530
|
console.log(
|
|
@@ -35656,8 +35620,8 @@ import chalk243 from "chalk";
|
|
|
35656
35620
|
|
|
35657
35621
|
// src/commands/seq/fetchSeq.ts
|
|
35658
35622
|
import chalk240 from "chalk";
|
|
35659
|
-
async function fetchSeq(conn,
|
|
35660
|
-
const url = `${conn.url}${
|
|
35623
|
+
async function fetchSeq(conn, path106, params) {
|
|
35624
|
+
const url = `${conn.url}${path106}?${params}`;
|
|
35661
35625
|
const response = await fetch(url, {
|
|
35662
35626
|
headers: {
|
|
35663
35627
|
Accept: "application/json",
|
|
@@ -36038,7 +36002,7 @@ async function previewSlackThreadParts({
|
|
|
36038
36002
|
`Approved for ${target}. The ${bodies.length} bodies to post, in thread order, are at:`
|
|
36039
36003
|
);
|
|
36040
36004
|
paths.forEach(
|
|
36041
|
-
(
|
|
36005
|
+
(path106, index3) => console.log(`${index3 + 1}/${paths.length} ${path106}`)
|
|
36042
36006
|
);
|
|
36043
36007
|
console.log(
|
|
36044
36008
|
threadTs ? `Post every part as a reply with thread_ts ${threadTs}.` : `Post 1/${paths.length} to ${channel}, then the rest with the thread_ts it returns.`
|
|
@@ -36380,15 +36344,15 @@ function registerSql(program2) {
|
|
|
36380
36344
|
|
|
36381
36345
|
// src/commands/sync.ts
|
|
36382
36346
|
import * as os5 from "os";
|
|
36383
|
-
import * as
|
|
36347
|
+
import * as path99 from "path";
|
|
36384
36348
|
import { fileURLToPath as fileURLToPath8 } from "url";
|
|
36385
36349
|
|
|
36386
36350
|
// src/commands/sync/pruneCommands.ts
|
|
36387
|
-
import * as
|
|
36351
|
+
import * as path89 from "path";
|
|
36388
36352
|
|
|
36389
36353
|
// src/commands/sync/pruneTarget.ts
|
|
36390
36354
|
import * as fs39 from "fs";
|
|
36391
|
-
import * as
|
|
36355
|
+
import * as path88 from "path";
|
|
36392
36356
|
function pruneTarget(targetDir, keepNames, shape, options2) {
|
|
36393
36357
|
const result = {
|
|
36394
36358
|
orphans: [],
|
|
@@ -36406,7 +36370,7 @@ function pruneTarget(targetDir, keepNames, shape, options2) {
|
|
|
36406
36370
|
}
|
|
36407
36371
|
if (keep.has(name)) continue;
|
|
36408
36372
|
result.orphans.push(entry.name);
|
|
36409
|
-
const entryPath =
|
|
36373
|
+
const entryPath = path88.join(targetDir, entry.name);
|
|
36410
36374
|
const reason4 = shape.blockedBy?.(entryPath);
|
|
36411
36375
|
if (reason4) {
|
|
36412
36376
|
result.skipped.push({ name: entry.name, reason: reason4 });
|
|
@@ -36426,7 +36390,7 @@ function pruneCommands(targetDir, commandNames, options2) {
|
|
|
36426
36390
|
targetDir,
|
|
36427
36391
|
commandNames,
|
|
36428
36392
|
{
|
|
36429
|
-
nameOf: (entry) => entry.isFile() && entry.name.endsWith(".md") ?
|
|
36393
|
+
nameOf: (entry) => entry.isFile() && entry.name.endsWith(".md") ? path89.basename(entry.name, ".md") : void 0
|
|
36430
36394
|
},
|
|
36431
36395
|
options2
|
|
36432
36396
|
);
|
|
@@ -36461,16 +36425,16 @@ function reportPrune(label2, result, force) {
|
|
|
36461
36425
|
|
|
36462
36426
|
// src/commands/sync/syncClaudeCommands.ts
|
|
36463
36427
|
import * as fs43 from "fs";
|
|
36464
|
-
import * as
|
|
36428
|
+
import * as path93 from "path";
|
|
36465
36429
|
|
|
36466
36430
|
// src/commands/sync/syncCodex.ts
|
|
36467
|
-
import * as
|
|
36431
|
+
import * as path92 from "path";
|
|
36468
36432
|
|
|
36469
36433
|
// src/commands/sync/installHarnessCommands.ts
|
|
36470
36434
|
import * as fs40 from "fs";
|
|
36471
|
-
import * as
|
|
36435
|
+
import * as path90 from "path";
|
|
36472
36436
|
function installHarnessCommands(claudeDir, harness, transform) {
|
|
36473
|
-
const commandsSource =
|
|
36437
|
+
const commandsSource = path90.join(claudeDir, "commands");
|
|
36474
36438
|
const files = fs40.readdirSync(commandsSource);
|
|
36475
36439
|
const names = [];
|
|
36476
36440
|
let synced = 0;
|
|
@@ -36478,9 +36442,9 @@ function installHarnessCommands(claudeDir, harness, transform) {
|
|
|
36478
36442
|
if (!file.endsWith(".md")) continue;
|
|
36479
36443
|
const name = file.replace(/\.md$/, "");
|
|
36480
36444
|
names.push(name);
|
|
36481
|
-
const content = fs40.readFileSync(
|
|
36482
|
-
const target =
|
|
36483
|
-
fs40.mkdirSync(
|
|
36445
|
+
const content = fs40.readFileSync(path90.join(commandsSource, file), "utf8");
|
|
36446
|
+
const target = path90.join(harness.homeDir, harness.sync.commandDest(name));
|
|
36447
|
+
fs40.mkdirSync(path90.dirname(target), { recursive: true });
|
|
36484
36448
|
fs40.writeFileSync(target, transform(name, content));
|
|
36485
36449
|
synced++;
|
|
36486
36450
|
}
|
|
@@ -36509,7 +36473,7 @@ function unexpectedContent(skillDir) {
|
|
|
36509
36473
|
|
|
36510
36474
|
// src/commands/sync/syncCodexHooks.ts
|
|
36511
36475
|
import * as fs42 from "fs";
|
|
36512
|
-
import * as
|
|
36476
|
+
import * as path91 from "path";
|
|
36513
36477
|
var BEGIN = "# >>> assist codex hooks (managed) \u2014 do not edit >>>";
|
|
36514
36478
|
var END = "# <<< assist codex hooks (managed) <<<";
|
|
36515
36479
|
function upsertManagedBlock(existing, body) {
|
|
@@ -36540,9 +36504,9 @@ ${rest}
|
|
|
36540
36504
|
}
|
|
36541
36505
|
function syncCodexHooks(sourcePath) {
|
|
36542
36506
|
const body = fs42.readFileSync(sourcePath, "utf8");
|
|
36543
|
-
const configPath =
|
|
36507
|
+
const configPath = path91.join(harnesses.codex.homeDir, "config.toml");
|
|
36544
36508
|
const existing = fs42.existsSync(configPath) ? fs42.readFileSync(configPath, "utf8") : "";
|
|
36545
|
-
fs42.mkdirSync(
|
|
36509
|
+
fs42.mkdirSync(path91.dirname(configPath), { recursive: true });
|
|
36546
36510
|
fs42.writeFileSync(configPath, upsertManagedBlock(existing, body));
|
|
36547
36511
|
console.log(
|
|
36548
36512
|
"Registered assist codex-hook in ~/.codex/config.toml (SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, PermissionRequest, Stop)"
|
|
@@ -36574,13 +36538,13 @@ function syncCodex(claudeDir, options2) {
|
|
|
36574
36538
|
harnesses.codex,
|
|
36575
36539
|
commandToSkill
|
|
36576
36540
|
);
|
|
36577
|
-
syncCodexHooks(
|
|
36541
|
+
syncCodexHooks(path92.join(claudeDir, "..", "codex", "config.toml"));
|
|
36578
36542
|
console.log(`Synced ${total} skill(s) to ~/.codex/skills`);
|
|
36579
36543
|
if (!options2?.prune) return;
|
|
36580
36544
|
const force = options2.force ?? false;
|
|
36581
36545
|
reportPrune(
|
|
36582
36546
|
"~/.codex/skills",
|
|
36583
|
-
pruneSkills(
|
|
36547
|
+
pruneSkills(path92.join(harnesses.codex.homeDir, "skills"), names, { force }),
|
|
36584
36548
|
force
|
|
36585
36549
|
);
|
|
36586
36550
|
}
|
|
@@ -36595,30 +36559,30 @@ function replaceFileWithoutFollowingSymlink(file, content) {
|
|
|
36595
36559
|
fs43.writeFileSync(file, content);
|
|
36596
36560
|
}
|
|
36597
36561
|
function writeSkill(targetBase, name, content) {
|
|
36598
|
-
const skillDir =
|
|
36562
|
+
const skillDir = path93.join(targetBase, "skills", name);
|
|
36599
36563
|
fs43.mkdirSync(skillDir, { recursive: true });
|
|
36600
36564
|
replaceFileWithoutFollowingSymlink(
|
|
36601
|
-
|
|
36565
|
+
path93.join(skillDir, "SKILL.md"),
|
|
36602
36566
|
commandToSkill(name, content)
|
|
36603
36567
|
);
|
|
36604
|
-
fs43.rmSync(
|
|
36568
|
+
fs43.rmSync(path93.join(targetBase, "commands", `${name}.md`), { force: true });
|
|
36605
36569
|
console.log(`Wrote ${name} as a skill to ${skillDir}`);
|
|
36606
36570
|
}
|
|
36607
36571
|
function syncClaudeCommands(claudeDir, targetBase) {
|
|
36608
|
-
const sourceDir =
|
|
36609
|
-
const targetDir =
|
|
36572
|
+
const sourceDir = path93.join(claudeDir, "commands");
|
|
36573
|
+
const targetDir = path93.join(targetBase, "commands");
|
|
36610
36574
|
fs43.mkdirSync(targetDir, { recursive: true });
|
|
36611
36575
|
const files = fs43.readdirSync(sourceDir);
|
|
36612
36576
|
for (const file of files) {
|
|
36613
|
-
const source =
|
|
36577
|
+
const source = path93.join(sourceDir, file);
|
|
36614
36578
|
if (file.endsWith(".md")) {
|
|
36615
36579
|
const content = fs43.readFileSync(source, "utf8");
|
|
36616
36580
|
if (isSkillFlagged(content)) {
|
|
36617
|
-
writeSkill(targetBase,
|
|
36581
|
+
writeSkill(targetBase, path93.basename(file, ".md"), content);
|
|
36618
36582
|
continue;
|
|
36619
36583
|
}
|
|
36620
36584
|
}
|
|
36621
|
-
fs43.copyFileSync(source,
|
|
36585
|
+
fs43.copyFileSync(source, path93.join(targetDir, file));
|
|
36622
36586
|
console.log(`Copied ${file} to ${targetDir}`);
|
|
36623
36587
|
}
|
|
36624
36588
|
console.log(`Synced ${files.length} command(s) to ~/.claude`);
|
|
@@ -36627,11 +36591,11 @@ function syncClaudeCommands(claudeDir, targetBase) {
|
|
|
36627
36591
|
|
|
36628
36592
|
// src/commands/sync/reportRetiredAgentsFiles.ts
|
|
36629
36593
|
import * as fs44 from "fs";
|
|
36630
|
-
import * as
|
|
36594
|
+
import * as path94 from "path";
|
|
36631
36595
|
var retired = [
|
|
36632
|
-
|
|
36633
|
-
|
|
36634
|
-
|
|
36596
|
+
path94.join(harnesses.claude.homeDir, "CLAUDE.md"),
|
|
36597
|
+
path94.join(harnesses.codex.homeDir, "AGENTS.md"),
|
|
36598
|
+
path94.join(harnesses.pi.homeDir, "AGENTS.md")
|
|
36635
36599
|
];
|
|
36636
36600
|
function reportRetiredAgentsFiles() {
|
|
36637
36601
|
const leftovers = retired.filter((file) => fs44.existsSync(file));
|
|
@@ -36647,35 +36611,35 @@ function reportRetiredAgentsFiles() {
|
|
|
36647
36611
|
|
|
36648
36612
|
// src/commands/sync/syncDesign.ts
|
|
36649
36613
|
import * as fs45 from "fs";
|
|
36650
|
-
import * as
|
|
36614
|
+
import * as path95 from "path";
|
|
36651
36615
|
function syncDesign(claudeDir, targetBase) {
|
|
36652
|
-
const systemPromptSource =
|
|
36653
|
-
const systemPromptTarget =
|
|
36616
|
+
const systemPromptSource = path95.join(claudeDir, "design-system-prompt.md");
|
|
36617
|
+
const systemPromptTarget = path95.join(targetBase, "design-system-prompt.md");
|
|
36654
36618
|
fs45.copyFileSync(systemPromptSource, systemPromptTarget);
|
|
36655
36619
|
console.log(
|
|
36656
36620
|
"Copied design-system-prompt.md to ~/.claude/design-system-prompt.md"
|
|
36657
36621
|
);
|
|
36658
|
-
const skillsSource =
|
|
36659
|
-
const skillsTarget =
|
|
36622
|
+
const skillsSource = path95.join(claudeDir, "skills");
|
|
36623
|
+
const skillsTarget = path95.join(targetBase, "skills");
|
|
36660
36624
|
fs45.mkdirSync(skillsTarget, { recursive: true });
|
|
36661
36625
|
const files = fs45.readdirSync(skillsSource);
|
|
36662
36626
|
for (const file of files) {
|
|
36663
36627
|
fs45.copyFileSync(
|
|
36664
|
-
|
|
36665
|
-
|
|
36628
|
+
path95.join(skillsSource, file),
|
|
36629
|
+
path95.join(skillsTarget, file)
|
|
36666
36630
|
);
|
|
36667
36631
|
}
|
|
36668
36632
|
console.log(`Synced ${files.length} design skill(s) to ~/.claude/skills`);
|
|
36669
36633
|
}
|
|
36670
36634
|
|
|
36671
36635
|
// src/commands/sync/syncPi.ts
|
|
36672
|
-
import * as
|
|
36636
|
+
import * as path97 from "path";
|
|
36673
36637
|
|
|
36674
36638
|
// src/commands/sync/syncPiHooks.ts
|
|
36675
36639
|
import * as fs46 from "fs";
|
|
36676
|
-
import * as
|
|
36640
|
+
import * as path96 from "path";
|
|
36677
36641
|
function piExtensionsDir() {
|
|
36678
|
-
return
|
|
36642
|
+
return path96.join(harnesses.pi.homeDir, "extensions");
|
|
36679
36643
|
}
|
|
36680
36644
|
function syncPiHooks(sourceDir) {
|
|
36681
36645
|
const target = piExtensionsDir();
|
|
@@ -36683,8 +36647,8 @@ function syncPiHooks(sourceDir) {
|
|
|
36683
36647
|
const files = fs46.readdirSync(sourceDir).filter((f) => f.endsWith(".ts"));
|
|
36684
36648
|
for (const file of files) {
|
|
36685
36649
|
fs46.copyFileSync(
|
|
36686
|
-
|
|
36687
|
-
|
|
36650
|
+
path96.join(sourceDir, file),
|
|
36651
|
+
path96.join(target, `assist-${file}`)
|
|
36688
36652
|
);
|
|
36689
36653
|
}
|
|
36690
36654
|
console.log(
|
|
@@ -36721,24 +36685,24 @@ function syncPi(claudeDir, options2) {
|
|
|
36721
36685
|
harnesses.pi,
|
|
36722
36686
|
commandToPrompt
|
|
36723
36687
|
);
|
|
36724
|
-
syncPiHooks(
|
|
36688
|
+
syncPiHooks(path97.join(claudeDir, "..", "pi"));
|
|
36725
36689
|
console.log(`Synced ${synced} prompt(s) to ~/.pi/agent/prompts`);
|
|
36726
36690
|
if (!options2?.prune) return;
|
|
36727
36691
|
const force = options2.force ?? false;
|
|
36728
36692
|
reportPrune(
|
|
36729
36693
|
"~/.pi/agent/prompts",
|
|
36730
|
-
pruneCommands(
|
|
36694
|
+
pruneCommands(path97.join(harnesses.pi.homeDir, "prompts"), names, { force }),
|
|
36731
36695
|
force
|
|
36732
36696
|
);
|
|
36733
36697
|
}
|
|
36734
36698
|
|
|
36735
36699
|
// src/commands/sync/syncSettings.ts
|
|
36736
36700
|
import * as fs47 from "fs";
|
|
36737
|
-
import * as
|
|
36701
|
+
import * as path98 from "path";
|
|
36738
36702
|
import chalk250 from "chalk";
|
|
36739
36703
|
async function syncSettings(claudeDir, targetBase, options2) {
|
|
36740
|
-
const source =
|
|
36741
|
-
const target =
|
|
36704
|
+
const source = path98.join(claudeDir, "settings.json");
|
|
36705
|
+
const target = path98.join(targetBase, "settings.json");
|
|
36742
36706
|
const sourceContent = fs47.readFileSync(source, "utf8");
|
|
36743
36707
|
const sourceSettings = JSON.parse(sourceContent);
|
|
36744
36708
|
const targetExists = fs47.existsSync(target);
|
|
@@ -36778,13 +36742,13 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
36778
36742
|
|
|
36779
36743
|
// src/commands/sync.ts
|
|
36780
36744
|
var __filename4 = fileURLToPath8(import.meta.url);
|
|
36781
|
-
var __dirname5 =
|
|
36745
|
+
var __dirname5 = path99.dirname(__filename4);
|
|
36782
36746
|
async function sync(options2) {
|
|
36783
36747
|
const config = loadConfig();
|
|
36784
36748
|
const yes = options2?.yes ?? config.sync.autoConfirm;
|
|
36785
36749
|
const prune = { prune: options2?.prune, force: options2?.force };
|
|
36786
|
-
const claudeDir =
|
|
36787
|
-
const targetBase =
|
|
36750
|
+
const claudeDir = path99.join(__dirname5, "..", "claude");
|
|
36751
|
+
const targetBase = path99.join(os5.homedir(), ".claude");
|
|
36788
36752
|
const commandFiles = syncClaudeCommands(claudeDir, targetBase);
|
|
36789
36753
|
syncDesign(claudeDir, targetBase);
|
|
36790
36754
|
await syncSettings(claudeDir, targetBase, { yes });
|
|
@@ -36792,11 +36756,11 @@ async function sync(options2) {
|
|
|
36792
36756
|
syncPi(claudeDir, prune);
|
|
36793
36757
|
reportRetiredAgentsFiles();
|
|
36794
36758
|
if (!options2?.prune) return;
|
|
36795
|
-
const commandNames = commandFiles.filter((file) => file.endsWith(".md")).map((file) =>
|
|
36759
|
+
const commandNames = commandFiles.filter((file) => file.endsWith(".md")).map((file) => path99.basename(file, ".md"));
|
|
36796
36760
|
const force = options2.force ?? false;
|
|
36797
36761
|
reportPrune(
|
|
36798
36762
|
"~/.claude/commands",
|
|
36799
|
-
pruneCommands(
|
|
36763
|
+
pruneCommands(path99.join(targetBase, "commands"), commandNames, { force }),
|
|
36800
36764
|
force
|
|
36801
36765
|
);
|
|
36802
36766
|
}
|
|
@@ -37852,9 +37816,9 @@ import { existsSync as existsSync79, readFileSync as readFileSync60 } from "fs";
|
|
|
37852
37816
|
|
|
37853
37817
|
// src/commands/verify/forbiddenStrings/findForbiddenStrings.ts
|
|
37854
37818
|
import { minimatch as minimatch9 } from "minimatch";
|
|
37855
|
-
function resolveStringsAtPath(data,
|
|
37819
|
+
function resolveStringsAtPath(data, path106) {
|
|
37856
37820
|
let current = data;
|
|
37857
|
-
for (const segment of
|
|
37821
|
+
for (const segment of path106.split(".")) {
|
|
37858
37822
|
if (current === null || typeof current !== "object") return [];
|
|
37859
37823
|
current = current[segment];
|
|
37860
37824
|
}
|
|
@@ -37867,10 +37831,10 @@ function resolveStringsAtPath(data, path107) {
|
|
|
37867
37831
|
}
|
|
37868
37832
|
function findRuleViolations(data, rule) {
|
|
37869
37833
|
const violations = [];
|
|
37870
|
-
for (const
|
|
37871
|
-
for (const value of resolveStringsAtPath(data,
|
|
37834
|
+
for (const path106 of rule.paths) {
|
|
37835
|
+
for (const value of resolveStringsAtPath(data, path106)) {
|
|
37872
37836
|
if (minimatch9(value, rule.disallowed))
|
|
37873
|
-
violations.push({ file: rule.file, path:
|
|
37837
|
+
violations.push({ file: rule.file, path: path106, value });
|
|
37874
37838
|
}
|
|
37875
37839
|
}
|
|
37876
37840
|
return violations;
|
|
@@ -37909,8 +37873,8 @@ function forbiddenStrings() {
|
|
|
37909
37873
|
process.exit(0);
|
|
37910
37874
|
}
|
|
37911
37875
|
console.log("Forbidden strings found:\n");
|
|
37912
|
-
for (const { file, path:
|
|
37913
|
-
console.log(` ${file} ${
|
|
37876
|
+
for (const { file, path: path106, value } of violations) {
|
|
37877
|
+
console.log(` ${file} ${path106}: ${value}`);
|
|
37914
37878
|
}
|
|
37915
37879
|
console.log(`
|
|
37916
37880
|
Total: ${violations.length} forbidden string(s).`);
|
|
@@ -37966,7 +37930,7 @@ Total: ${lines2.length} hardcoded color(s)`);
|
|
|
37966
37930
|
|
|
37967
37931
|
// src/commands/verify/migrations.ts
|
|
37968
37932
|
import { readFileSync as readFileSync61 } from "fs";
|
|
37969
|
-
import
|
|
37933
|
+
import path101 from "path";
|
|
37970
37934
|
|
|
37971
37935
|
// src/commands/verify/migrations/checkAppendOnly.ts
|
|
37972
37936
|
function checkAppendOnly(baseline, current) {
|
|
@@ -38058,15 +38022,15 @@ function readBaselineMigrations(repoRelativeDir, ref) {
|
|
|
38058
38022
|
} catch {
|
|
38059
38023
|
return baseline;
|
|
38060
38024
|
}
|
|
38061
|
-
const paths = listing.split("\n").map((line) => line.trim()).filter(Boolean).filter((
|
|
38062
|
-
for (const
|
|
38025
|
+
const paths = listing.split("\n").map((line) => line.trim()).filter(Boolean).filter((path106) => MIGRATION_FILE3.test(basename26(path106)));
|
|
38026
|
+
for (const path106 of paths) {
|
|
38063
38027
|
try {
|
|
38064
|
-
const content = execSync63(`git show "${ref}:${
|
|
38028
|
+
const content = execSync63(`git show "${ref}:${path106}"`, {
|
|
38065
38029
|
encoding: "utf8",
|
|
38066
38030
|
maxBuffer: 16 * 1024 * 1024,
|
|
38067
38031
|
stdio: ["pipe", "pipe", "pipe"]
|
|
38068
38032
|
});
|
|
38069
|
-
baseline.set(basename26(
|
|
38033
|
+
baseline.set(basename26(path106), content);
|
|
38070
38034
|
} catch {
|
|
38071
38035
|
}
|
|
38072
38036
|
}
|
|
@@ -38105,11 +38069,11 @@ function resolveBaselineRef() {
|
|
|
38105
38069
|
}
|
|
38106
38070
|
|
|
38107
38071
|
// src/commands/verify/migrations/migrationsDir.ts
|
|
38108
|
-
import
|
|
38072
|
+
import path100 from "path";
|
|
38109
38073
|
import { fileURLToPath as fileURLToPath9 } from "url";
|
|
38110
38074
|
function migrationsDir() {
|
|
38111
|
-
return
|
|
38112
|
-
|
|
38075
|
+
return path100.resolve(
|
|
38076
|
+
path100.dirname(fileURLToPath9(import.meta.url)),
|
|
38113
38077
|
"../../../shared/db/migrations"
|
|
38114
38078
|
);
|
|
38115
38079
|
}
|
|
@@ -38130,7 +38094,7 @@ function migrations2() {
|
|
|
38130
38094
|
if (ref) {
|
|
38131
38095
|
const baseline = readBaselineMigrations(REPO_RELATIVE_DIR, ref);
|
|
38132
38096
|
const current = new Map(
|
|
38133
|
-
files.map((file) => [file, readFileSync61(
|
|
38097
|
+
files.map((file) => [file, readFileSync61(path101.join(dir, file), "utf8")])
|
|
38134
38098
|
);
|
|
38135
38099
|
for (const finding of checkAppendOnly(baseline, current)) {
|
|
38136
38100
|
problems.push(
|
|
@@ -38635,11 +38599,11 @@ var webUiPrefix = "src/commands/sessions/web/ui/";
|
|
|
38635
38599
|
var sessionsPrefix = "src/commands/sessions/";
|
|
38636
38600
|
var rules = [
|
|
38637
38601
|
{
|
|
38638
|
-
matches: (
|
|
38602
|
+
matches: (path106) => path106.startsWith(webUiPrefix),
|
|
38639
38603
|
advice: "restart the web server, then hard-reload the browser tab"
|
|
38640
38604
|
},
|
|
38641
38605
|
{
|
|
38642
|
-
matches: (
|
|
38606
|
+
matches: (path106) => path106.startsWith(sessionsPrefix) && !path106.startsWith(webUiPrefix),
|
|
38643
38607
|
advice: "restart the daemon"
|
|
38644
38608
|
}
|
|
38645
38609
|
];
|
|
@@ -38650,27 +38614,27 @@ function restartAdvice(paths) {
|
|
|
38650
38614
|
// src/commands/watch/syncAdvice.ts
|
|
38651
38615
|
var rules2 = [
|
|
38652
38616
|
{
|
|
38653
|
-
matches: (
|
|
38617
|
+
matches: (path106) => path106.startsWith("claude/commands/"),
|
|
38654
38618
|
reason: "claude/commands changed"
|
|
38655
38619
|
},
|
|
38656
38620
|
{
|
|
38657
|
-
matches: (
|
|
38621
|
+
matches: (path106) => path106.startsWith("claude/skills/"),
|
|
38658
38622
|
reason: "claude/skills changed"
|
|
38659
38623
|
},
|
|
38660
38624
|
{
|
|
38661
|
-
matches: (
|
|
38625
|
+
matches: (path106) => path106 === "claude/settings.json",
|
|
38662
38626
|
reason: "claude/settings.json changed"
|
|
38663
38627
|
},
|
|
38664
38628
|
{
|
|
38665
|
-
matches: (
|
|
38629
|
+
matches: (path106) => path106 === "claude/design-system-prompt.md",
|
|
38666
38630
|
reason: "claude/design-system-prompt.md changed"
|
|
38667
38631
|
},
|
|
38668
38632
|
{
|
|
38669
|
-
matches: (
|
|
38633
|
+
matches: (path106) => path106.startsWith("codex/"),
|
|
38670
38634
|
reason: "codex sources changed"
|
|
38671
38635
|
},
|
|
38672
38636
|
{
|
|
38673
|
-
matches: (
|
|
38637
|
+
matches: (path106) => path106.startsWith("pi/"),
|
|
38674
38638
|
reason: "pi sources changed"
|
|
38675
38639
|
}
|
|
38676
38640
|
];
|
|
@@ -39321,9 +39285,9 @@ function findPortFile(roamDir) {
|
|
|
39321
39285
|
return void 0;
|
|
39322
39286
|
}
|
|
39323
39287
|
const candidates = entries.filter((name) => /^roam-local-api(-[^.]+)?\.port$/.test(name)).map((name) => {
|
|
39324
|
-
const
|
|
39288
|
+
const path106 = join101(roamDir, name);
|
|
39325
39289
|
try {
|
|
39326
|
-
return { path:
|
|
39290
|
+
return { path: path106, mtimeMs: statSync13(path106).mtimeMs };
|
|
39327
39291
|
} catch {
|
|
39328
39292
|
return void 0;
|
|
39329
39293
|
}
|
|
@@ -39567,11 +39531,11 @@ function findLinkIndex() {
|
|
|
39567
39531
|
function parseLinkArgs() {
|
|
39568
39532
|
const idx = findLinkIndex();
|
|
39569
39533
|
if (idx === -1) return null;
|
|
39570
|
-
const
|
|
39534
|
+
const path106 = process.argv[idx + 1];
|
|
39571
39535
|
const rest = process.argv.slice(idx + 2);
|
|
39572
39536
|
const { value: prefix2 } = extractOption(rest, "--prefix");
|
|
39573
39537
|
if (!prefix2) return null;
|
|
39574
|
-
return { path:
|
|
39538
|
+
return { path: path106, prefix: prefix2 };
|
|
39575
39539
|
}
|
|
39576
39540
|
function hasDuplicateLink(runList, linkPath) {
|
|
39577
39541
|
return runList.some(
|
|
@@ -40216,14 +40180,14 @@ import * as pty from "node-pty";
|
|
|
40216
40180
|
// src/commands/sessions/daemon/ensureSpawnHelperExecutable.ts
|
|
40217
40181
|
import { chmodSync, existsSync as existsSync87, statSync as statSync14 } from "fs";
|
|
40218
40182
|
import { createRequire as createRequire3 } from "module";
|
|
40219
|
-
import
|
|
40183
|
+
import path102 from "path";
|
|
40220
40184
|
var require4 = createRequire3(import.meta.url);
|
|
40221
40185
|
var ensured = false;
|
|
40222
40186
|
function ensureSpawnHelperExecutable() {
|
|
40223
40187
|
if (ensured || process.platform !== "darwin") return;
|
|
40224
40188
|
ensured = true;
|
|
40225
|
-
const ptyRoot =
|
|
40226
|
-
const helper =
|
|
40189
|
+
const ptyRoot = path102.join(path102.dirname(require4.resolve("node-pty")), "..");
|
|
40190
|
+
const helper = path102.join(
|
|
40227
40191
|
ptyRoot,
|
|
40228
40192
|
"prebuilds",
|
|
40229
40193
|
`${process.platform}-${process.arch}`,
|
|
@@ -40354,12 +40318,12 @@ function serverRunMeta(runName, cwd) {
|
|
|
40354
40318
|
|
|
40355
40319
|
// src/commands/sessions/daemon/readDesignSystemPrompt.ts
|
|
40356
40320
|
import * as fs50 from "fs";
|
|
40357
|
-
import * as
|
|
40321
|
+
import * as path103 from "path";
|
|
40358
40322
|
import { fileURLToPath as fileURLToPath11 } from "url";
|
|
40359
40323
|
var __filename5 = fileURLToPath11(import.meta.url);
|
|
40360
|
-
var __dirname7 =
|
|
40324
|
+
var __dirname7 = path103.dirname(__filename5);
|
|
40361
40325
|
function readDesignSystemPrompt() {
|
|
40362
|
-
const promptPath =
|
|
40326
|
+
const promptPath = path103.join(
|
|
40363
40327
|
__dirname7,
|
|
40364
40328
|
"..",
|
|
40365
40329
|
"claude",
|
|
@@ -41393,8 +41357,8 @@ async function seedRunningMsFromUsage(session, notify2) {
|
|
|
41393
41357
|
var DEBOUNCE_MS2 = 50;
|
|
41394
41358
|
function watchActivity(session, notify2, onClaudeSessionId) {
|
|
41395
41359
|
if (session.commandType !== "assist" || !session.cwd) return;
|
|
41396
|
-
const
|
|
41397
|
-
const dir = dirname42(
|
|
41360
|
+
const path106 = activityPath(session.id);
|
|
41361
|
+
const dir = dirname42(path106);
|
|
41398
41362
|
try {
|
|
41399
41363
|
mkdirSync37(dir, { recursive: true });
|
|
41400
41364
|
} catch {
|
|
@@ -41404,7 +41368,7 @@ function watchActivity(session, notify2, onClaudeSessionId) {
|
|
|
41404
41368
|
let timer = null;
|
|
41405
41369
|
const read3 = () => {
|
|
41406
41370
|
timer = null;
|
|
41407
|
-
const activity2 = readActivity(
|
|
41371
|
+
const activity2 = readActivity(path106);
|
|
41408
41372
|
if (!activity2) return;
|
|
41409
41373
|
applyActivityToSession(session, activity2);
|
|
41410
41374
|
if (activity2.claudeSessionId) onClaudeSessionId?.(session);
|
|
@@ -41413,11 +41377,11 @@ function watchActivity(session, notify2, onClaudeSessionId) {
|
|
|
41413
41377
|
notify2();
|
|
41414
41378
|
};
|
|
41415
41379
|
session.activityWatcher = watch2(dir, (_event, filename) => {
|
|
41416
|
-
if (filename && !
|
|
41380
|
+
if (filename && !path106.endsWith(filename)) return;
|
|
41417
41381
|
if (timer) clearTimeout(timer);
|
|
41418
41382
|
timer = setTimeout(read3, DEBOUNCE_MS2);
|
|
41419
41383
|
});
|
|
41420
|
-
if (existsSync93(
|
|
41384
|
+
if (existsSync93(path106)) read3();
|
|
41421
41385
|
}
|
|
41422
41386
|
function refreshActivity(session) {
|
|
41423
41387
|
if (session.commandType !== "assist" || !session.cwd) return;
|
|
@@ -41560,12 +41524,12 @@ import { watch as watch3 } from "fs";
|
|
|
41560
41524
|
|
|
41561
41525
|
// src/commands/sessions/shared/findTranscriptPathSync.ts
|
|
41562
41526
|
import * as fs52 from "fs";
|
|
41563
|
-
import * as
|
|
41527
|
+
import * as path104 from "path";
|
|
41564
41528
|
function projectDirForCwd(cwd) {
|
|
41565
|
-
return
|
|
41529
|
+
return path104.join(claudeProjectsRoot(), projectSlug(cwd));
|
|
41566
41530
|
}
|
|
41567
41531
|
function transcriptPathFor(cwd, claudeSessionId) {
|
|
41568
|
-
return
|
|
41532
|
+
return path104.join(projectDirForCwd(cwd), `${claudeSessionId}.jsonl`);
|
|
41569
41533
|
}
|
|
41570
41534
|
function findTranscriptPathSync(cwd, claudeSessionId) {
|
|
41571
41535
|
const direct = transcriptPathFor(cwd, claudeSessionId);
|
|
@@ -41579,8 +41543,8 @@ function findTranscriptPathSync(cwd, claudeSessionId) {
|
|
|
41579
41543
|
}
|
|
41580
41544
|
for (const file of files) {
|
|
41581
41545
|
if (!file.endsWith(".jsonl")) continue;
|
|
41582
|
-
if (headContainsSessionId(
|
|
41583
|
-
return
|
|
41546
|
+
if (headContainsSessionId(path104.join(dir, file), claudeSessionId))
|
|
41547
|
+
return path104.join(dir, file);
|
|
41584
41548
|
}
|
|
41585
41549
|
return null;
|
|
41586
41550
|
}
|
|
@@ -42780,9 +42744,9 @@ function tempRoots() {
|
|
|
42780
42744
|
}
|
|
42781
42745
|
return [...roots];
|
|
42782
42746
|
}
|
|
42783
|
-
function underTempRoot(
|
|
42747
|
+
function underTempRoot(path106) {
|
|
42784
42748
|
return tempRoots().some(
|
|
42785
|
-
(root2) =>
|
|
42749
|
+
(root2) => path106.startsWith(root2.endsWith(sep3) ? root2 : root2 + sep3)
|
|
42786
42750
|
);
|
|
42787
42751
|
}
|
|
42788
42752
|
|
|
@@ -43268,15 +43232,15 @@ function bindResumedWorktree(session, cwd, notify2) {
|
|
|
43268
43232
|
import { existsSync as existsSync95 } from "fs";
|
|
43269
43233
|
async function reclaimVanishedWorktrees(clone, paths) {
|
|
43270
43234
|
if (!existsSync95(clone)) {
|
|
43271
|
-
for (const { path:
|
|
43235
|
+
for (const { path: path106 } of paths) forgetWorktree(path106);
|
|
43272
43236
|
daemonLog(
|
|
43273
43237
|
`clone ${clone} is gone; forgot ${paths.length} worktree record(s) it owned`
|
|
43274
43238
|
);
|
|
43275
43239
|
return;
|
|
43276
43240
|
}
|
|
43277
43241
|
await pruneBookkeeping2(clone);
|
|
43278
|
-
for (const { path:
|
|
43279
|
-
if (await reclaimBranch(clone, branch2)) forgetWorktree(
|
|
43242
|
+
for (const { path: path106, branch: branch2 } of paths)
|
|
43243
|
+
if (await reclaimBranch(clone, branch2)) forgetWorktree(path106);
|
|
43280
43244
|
}
|
|
43281
43245
|
async function pruneBookkeeping2(clone) {
|
|
43282
43246
|
try {
|
|
@@ -43303,37 +43267,37 @@ async function reclaimBranch(clone, branch2) {
|
|
|
43303
43267
|
}
|
|
43304
43268
|
|
|
43305
43269
|
// src/commands/sessions/daemon/worktree/logVanishedTree.ts
|
|
43306
|
-
function logVanishedTree(sessions,
|
|
43270
|
+
function logVanishedTree(sessions, path106) {
|
|
43307
43271
|
const claimants = [...sessions.values()].filter(
|
|
43308
|
-
(s) => s.cwd ===
|
|
43272
|
+
(s) => s.cwd === path106 || s.worktree?.path === path106
|
|
43309
43273
|
);
|
|
43310
43274
|
if (claimants.length === 0) {
|
|
43311
|
-
daemonLog(`worktree ${
|
|
43275
|
+
daemonLog(`worktree ${path106} gone from disk and unclaimed; reclaiming it`);
|
|
43312
43276
|
return;
|
|
43313
43277
|
}
|
|
43314
43278
|
for (const s of claimants)
|
|
43315
43279
|
daemonLog(
|
|
43316
|
-
`session ${s.id} ("${s.name}") claims worktree ${
|
|
43280
|
+
`session ${s.id} ("${s.name}") claims worktree ${path106}, which is gone from disk; reclaiming it`
|
|
43317
43281
|
);
|
|
43318
43282
|
}
|
|
43319
43283
|
|
|
43320
43284
|
// src/commands/sessions/daemon/worktree/describeHeldWork.ts
|
|
43321
43285
|
var MAX_ITEMS = 20;
|
|
43322
|
-
async function describeHeldWork(
|
|
43323
|
-
if (reason4.startsWith("uncommitted")) return await changedFiles(
|
|
43324
|
-
if (reason4.startsWith("unpushed")) return await unpushedCommits(
|
|
43286
|
+
async function describeHeldWork(path106, reason4) {
|
|
43287
|
+
if (reason4.startsWith("uncommitted")) return await changedFiles(path106);
|
|
43288
|
+
if (reason4.startsWith("unpushed")) return await unpushedCommits(path106, reason4);
|
|
43325
43289
|
return { summary: reason4, items: [] };
|
|
43326
43290
|
}
|
|
43327
|
-
async function changedFiles(
|
|
43328
|
-
const status3 = await gitResult(
|
|
43291
|
+
async function changedFiles(path106) {
|
|
43292
|
+
const status3 = await gitResult(path106, ["status", "--porcelain"]);
|
|
43329
43293
|
const lines2 = status3.ok ? nonEmptyLines(status3.out) : [];
|
|
43330
43294
|
return {
|
|
43331
43295
|
summary: `${lines2.length} uncommitted ${lines2.length === 1 ? "file" : "files"}`,
|
|
43332
43296
|
items: capped2(lines2)
|
|
43333
43297
|
};
|
|
43334
43298
|
}
|
|
43335
|
-
async function unpushedCommits(
|
|
43336
|
-
const log2 = await gitResult(
|
|
43299
|
+
async function unpushedCommits(path106, reason4) {
|
|
43300
|
+
const log2 = await gitResult(path106, ["log", "--oneline", "@{upstream}..HEAD"]);
|
|
43337
43301
|
if (!log2.ok) return { summary: reason4, items: [] };
|
|
43338
43302
|
const lines2 = nonEmptyLines(log2.out);
|
|
43339
43303
|
return {
|
|
@@ -43425,24 +43389,24 @@ function reconcileWorktreesOnRestore(sessions, spawnWith, notify2) {
|
|
|
43425
43389
|
async function recoverOrphanedWorktrees(sessions, spawnWith, notify2) {
|
|
43426
43390
|
const accounted = accountedTrees(sessions);
|
|
43427
43391
|
const vanished = /* @__PURE__ */ new Map();
|
|
43428
|
-
for (const { path:
|
|
43429
|
-
if (underTempRoot(
|
|
43430
|
-
forgetWorktree(
|
|
43392
|
+
for (const { path: path106, clone } of readWorktreeRegistry()) {
|
|
43393
|
+
if (underTempRoot(path106)) {
|
|
43394
|
+
forgetWorktree(path106);
|
|
43431
43395
|
daemonLog(
|
|
43432
|
-
`worktree ${
|
|
43396
|
+
`worktree ${path106} lies outside any project root; pruned from the registry rather than recovered`
|
|
43433
43397
|
);
|
|
43434
43398
|
continue;
|
|
43435
43399
|
}
|
|
43436
|
-
if (!existsSync96(
|
|
43437
|
-
logVanishedTree(sessions,
|
|
43400
|
+
if (!existsSync96(path106)) {
|
|
43401
|
+
logVanishedTree(sessions, path106);
|
|
43438
43402
|
vanished.set(clone, [
|
|
43439
43403
|
...vanished.get(clone) ?? [],
|
|
43440
|
-
{ path:
|
|
43404
|
+
{ path: path106, branch: basename29(path106) }
|
|
43441
43405
|
]);
|
|
43442
43406
|
continue;
|
|
43443
43407
|
}
|
|
43444
|
-
if (accounted.has(
|
|
43445
|
-
await recoverOrphan(sessions, spawnWith, { path:
|
|
43408
|
+
if (accounted.has(path106)) continue;
|
|
43409
|
+
await recoverOrphan(sessions, spawnWith, { path: path106, clone }, notify2);
|
|
43446
43410
|
}
|
|
43447
43411
|
for (const [clone, paths] of vanished)
|
|
43448
43412
|
await reclaimVanishedWorktrees(clone, paths);
|
|
@@ -45520,12 +45484,12 @@ function handleSetStatus(client, m, d) {
|
|
|
45520
45484
|
import * as fs56 from "fs";
|
|
45521
45485
|
|
|
45522
45486
|
// src/commands/sessions/shared/codex/findCodexRolloutPath.ts
|
|
45523
|
-
import * as
|
|
45487
|
+
import * as path105 from "path";
|
|
45524
45488
|
async function findCodexRolloutPath(sessionId) {
|
|
45525
45489
|
if (!sessionId) return null;
|
|
45526
45490
|
const paths = await discoverCodexRolloutPaths();
|
|
45527
45491
|
const suffix = `-${sessionId}.jsonl`;
|
|
45528
|
-
return paths.find((file) =>
|
|
45492
|
+
return paths.find((file) => path105.basename(file).endsWith(suffix)) ?? null;
|
|
45529
45493
|
}
|
|
45530
45494
|
|
|
45531
45495
|
// src/commands/sessions/shared/codex/codexToolTarget.ts
|
|
@@ -46108,13 +46072,13 @@ function describePeerError(error) {
|
|
|
46108
46072
|
const cause = error.cause;
|
|
46109
46073
|
return cause instanceof Error ? `${error.message}: ${describePeerError(cause)}` : error.message;
|
|
46110
46074
|
}
|
|
46111
|
-
async function fetchPeerJson(baseUrl,
|
|
46112
|
-
const res = await fetch(new URL(
|
|
46075
|
+
async function fetchPeerJson(baseUrl, path106, timeoutMs = PEER_TIMEOUT_MS) {
|
|
46076
|
+
const res = await fetch(new URL(path106, baseUrl), {
|
|
46113
46077
|
signal: AbortSignal.timeout(timeoutMs)
|
|
46114
46078
|
});
|
|
46115
46079
|
if (!res.ok)
|
|
46116
46080
|
throw Object.assign(
|
|
46117
|
-
new Error(`GET ${
|
|
46081
|
+
new Error(`GET ${path106} returned ${res.status} ${res.statusText}`),
|
|
46118
46082
|
{ status: res.status }
|
|
46119
46083
|
);
|
|
46120
46084
|
return await res.json();
|