@staff0rd/assist 0.722.0 → 0.722.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/commands/sessions/web/bundle.js +1 -1
- package/dist/index.js +419 -474
- 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.2",
|
|
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
|
|
@@ -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, 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
|
|
@@ -31892,33 +31880,20 @@ Plan exceeds restructure.maxDepth ${maxDepth}: ${tooDeep} file(s) deeper.`
|
|
|
31892
31880
|
// src/commands/refactor/restructure/displayLayoutLimits.ts
|
|
31893
31881
|
function pinSteps(apply) {
|
|
31894
31882
|
return [
|
|
31895
|
-
"
|
|
31896
|
-
"1.
|
|
31883
|
+
"Pin feature modules until this check passes:",
|
|
31884
|
+
"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
31885
|
"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.",
|
|
31886
|
+
"3. Re-run this command. Repeat until the plan is within the limit.",
|
|
31887
|
+
"4. If a chain has no sensible feature boundary, stop and report that chain.",
|
|
31901
31888
|
`Then run \`${apply}\`.`
|
|
31902
31889
|
];
|
|
31903
31890
|
}
|
|
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
31891
|
function exceedsLayoutLimits(limits) {
|
|
31916
|
-
return limits.chains.length > 0
|
|
31892
|
+
return limits.chains.length > 0;
|
|
31917
31893
|
}
|
|
31918
31894
|
function displayLayoutLimits(limits, apply) {
|
|
31919
31895
|
if (!exceedsLayoutLimits(limits)) return;
|
|
31920
31896
|
displayDeepChains(limits.chains, limits.maxDepth);
|
|
31921
|
-
displayLargeFolders(limits.largeFolders, limits.folderLimit);
|
|
31922
31897
|
console.log("");
|
|
31923
31898
|
for (const line of pinSteps(apply)) console.log(chalk217.yellow(line));
|
|
31924
31899
|
}
|
|
@@ -31980,41 +31955,20 @@ function findDeepChains(targets, scopeRoot, maxDepth) {
|
|
|
31980
31955
|
return [...chains.entries()].sort(([ka, a], [kb, b]) => b.tooDeep - a.tooDeep || ka.localeCompare(kb)).map(([, chain2]) => chain2);
|
|
31981
31956
|
}
|
|
31982
31957
|
|
|
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
31958
|
// src/commands/refactor/restructure/checkLayoutLimits.ts
|
|
31998
|
-
function checkLayoutLimits(plan2,
|
|
31999
|
-
const targets = [...plan2.targets.values()];
|
|
32000
|
-
const folderLimit = Math.min(
|
|
32001
|
-
Math.ceil(targets.length * settings.maxFolderPercent / 100),
|
|
32002
|
-
settings.maxFolderFiles
|
|
32003
|
-
);
|
|
31959
|
+
function checkLayoutLimits(plan2, maxDepth) {
|
|
32004
31960
|
return {
|
|
32005
|
-
maxDepth
|
|
32006
|
-
chains: findDeepChains(targets, plan2.scopeRoot,
|
|
32007
|
-
folderLimit,
|
|
32008
|
-
largeFolders: findLargeFolders(targets, plan2.scopeRoot, folderLimit)
|
|
31961
|
+
maxDepth,
|
|
31962
|
+
chains: findDeepChains(plan2.targets.values(), plan2.scopeRoot, maxDepth)
|
|
32009
31963
|
};
|
|
32010
31964
|
}
|
|
32011
31965
|
|
|
32012
31966
|
// src/commands/refactor/restructure/partitionIgnored.ts
|
|
32013
|
-
import
|
|
31967
|
+
import path75 from "path";
|
|
32014
31968
|
import { minimatch as minimatch4 } from "minimatch";
|
|
32015
31969
|
function partitionIgnored(files) {
|
|
32016
31970
|
const globs = loadConfig().restructure?.ignore ?? [];
|
|
32017
|
-
const isIgnored = (file) => globs.some((glob) => minimatch4(
|
|
31971
|
+
const isIgnored = (file) => globs.some((glob) => minimatch4(path75.relative(process.cwd(), file), glob));
|
|
32018
31972
|
return {
|
|
32019
31973
|
scoped: files.filter((f) => !isIgnored(f)),
|
|
32020
31974
|
ignored: files.filter(isIgnored)
|
|
@@ -32029,10 +31983,10 @@ import chalk220 from "chalk";
|
|
|
32029
31983
|
|
|
32030
31984
|
// src/commands/refactor/restructure/executePlan.ts
|
|
32031
31985
|
import fs37 from "fs";
|
|
32032
|
-
import
|
|
31986
|
+
import path76 from "path";
|
|
32033
31987
|
import chalk219 from "chalk";
|
|
32034
31988
|
function relPath(file) {
|
|
32035
|
-
return
|
|
31989
|
+
return path76.relative(process.cwd(), file);
|
|
32036
31990
|
}
|
|
32037
31991
|
function stagingPath(move2, index3) {
|
|
32038
31992
|
return `${move2.from}.restructure-${process.pid}-${index3}`;
|
|
@@ -32044,7 +31998,7 @@ function moveFiles(moves) {
|
|
|
32044
31998
|
return { move: move2, staging };
|
|
32045
31999
|
});
|
|
32046
32000
|
for (const { move: move2, staging } of staged) {
|
|
32047
|
-
fs37.mkdirSync(
|
|
32001
|
+
fs37.mkdirSync(path76.dirname(move2.to), { recursive: true });
|
|
32048
32002
|
fs37.renameSync(staging, move2.to);
|
|
32049
32003
|
console.log(
|
|
32050
32004
|
chalk219.white(` Moved ${relPath(move2.from)} \u2192 ${relPath(move2.to)}`)
|
|
@@ -32060,8 +32014,8 @@ function removeIfEmpty(dir) {
|
|
|
32060
32014
|
function removeEmptyDirectories(dirs, scopeRoot) {
|
|
32061
32015
|
const deepestFirst = [...new Set(dirs)].sort((a, b) => b.length - a.length);
|
|
32062
32016
|
for (let dir of deepestFirst) {
|
|
32063
|
-
while (dir.startsWith(`${scopeRoot}${
|
|
32064
|
-
dir =
|
|
32017
|
+
while (dir.startsWith(`${scopeRoot}${path76.sep}`) && removeIfEmpty(dir))
|
|
32018
|
+
dir = path76.dirname(dir);
|
|
32065
32019
|
}
|
|
32066
32020
|
}
|
|
32067
32021
|
function executePlan(plan2) {
|
|
@@ -32071,7 +32025,7 @@ function executePlan(plan2) {
|
|
|
32071
32025
|
}
|
|
32072
32026
|
moveFiles(plan2.moves);
|
|
32073
32027
|
removeEmptyDirectories(
|
|
32074
|
-
plan2.moves.map((m) =>
|
|
32028
|
+
plan2.moves.map((m) => path76.dirname(m.from)),
|
|
32075
32029
|
plan2.scopeRoot
|
|
32076
32030
|
);
|
|
32077
32031
|
}
|
|
@@ -32088,17 +32042,17 @@ function applyPlan(plan2) {
|
|
|
32088
32042
|
}
|
|
32089
32043
|
|
|
32090
32044
|
// src/commands/refactor/restructure/displayPlan.ts
|
|
32091
|
-
import
|
|
32045
|
+
import path79 from "path";
|
|
32092
32046
|
import chalk221 from "chalk";
|
|
32093
32047
|
|
|
32094
32048
|
// src/commands/refactor/restructure/computeDepthStats.ts
|
|
32095
|
-
import
|
|
32049
|
+
import path77 from "path";
|
|
32096
32050
|
function computeDepthStats(targets, scopeRoot) {
|
|
32097
32051
|
const distribution = /* @__PURE__ */ new Map();
|
|
32098
32052
|
let max = 0;
|
|
32099
32053
|
for (const target of targets) {
|
|
32100
|
-
const dir =
|
|
32101
|
-
const depth = dir === "" ? 0 : dir.split(
|
|
32054
|
+
const dir = path77.relative(scopeRoot, path77.dirname(target));
|
|
32055
|
+
const depth = dir === "" ? 0 : dir.split(path77.sep).length;
|
|
32102
32056
|
distribution.set(depth, (distribution.get(depth) ?? 0) + 1);
|
|
32103
32057
|
max = Math.max(max, depth);
|
|
32104
32058
|
}
|
|
@@ -32106,7 +32060,7 @@ function computeDepthStats(targets, scopeRoot) {
|
|
|
32106
32060
|
}
|
|
32107
32061
|
|
|
32108
32062
|
// src/commands/refactor/restructure/formatTree.ts
|
|
32109
|
-
import
|
|
32063
|
+
import path78 from "path";
|
|
32110
32064
|
function insert(root2, parts) {
|
|
32111
32065
|
let node = root2;
|
|
32112
32066
|
for (const part of parts) {
|
|
@@ -32128,7 +32082,7 @@ function render(node, indent3, lines2) {
|
|
|
32128
32082
|
function formatTree(files, scopeRoot) {
|
|
32129
32083
|
const root2 = /* @__PURE__ */ new Map();
|
|
32130
32084
|
for (const file of files)
|
|
32131
|
-
insert(root2,
|
|
32085
|
+
insert(root2, path78.relative(scopeRoot, file).split(path78.sep));
|
|
32132
32086
|
const lines2 = [];
|
|
32133
32087
|
render(root2, "", lines2);
|
|
32134
32088
|
return lines2;
|
|
@@ -32136,7 +32090,7 @@ function formatTree(files, scopeRoot) {
|
|
|
32136
32090
|
|
|
32137
32091
|
// src/commands/refactor/restructure/displayPlan.ts
|
|
32138
32092
|
function relPath2(filePath) {
|
|
32139
|
-
return
|
|
32093
|
+
return path79.relative(process.cwd(), filePath);
|
|
32140
32094
|
}
|
|
32141
32095
|
function displayMoves(plan2) {
|
|
32142
32096
|
if (plan2.moves.length === 0) return;
|
|
@@ -32202,7 +32156,7 @@ function runPlan(plan2, limits, apply) {
|
|
|
32202
32156
|
|
|
32203
32157
|
// src/commands/refactor/restructure.ts
|
|
32204
32158
|
async function restructure(root2, options2 = {}) {
|
|
32205
|
-
const scopeRoot =
|
|
32159
|
+
const scopeRoot = path80.resolve(root2 ?? "src");
|
|
32206
32160
|
if (!fs38.existsSync(scopeRoot) || !fs38.statSync(scopeRoot).isDirectory()) {
|
|
32207
32161
|
console.log(chalk223.red(`Not a directory: ${root2 ?? "src"}`));
|
|
32208
32162
|
process.exit(1);
|
|
@@ -32214,18 +32168,9 @@ async function restructure(root2, options2 = {}) {
|
|
|
32214
32168
|
console.log(chalk223.yellow("No files found under root"));
|
|
32215
32169
|
return;
|
|
32216
32170
|
}
|
|
32217
|
-
const {
|
|
32218
|
-
pin: pin2 = [],
|
|
32219
|
-
maxDepth = 10,
|
|
32220
|
-
maxFolderPercent = 15,
|
|
32221
|
-
maxFolderFiles = 150
|
|
32222
|
-
} = loadConfig().restructure ?? {};
|
|
32171
|
+
const { pin: pin2 = [], maxDepth = 10 } = loadConfig().restructure ?? {};
|
|
32223
32172
|
const plan2 = buildPlan3(scopeRoot, scoped, ignored, pin2);
|
|
32224
|
-
const limits = checkLayoutLimits(plan2,
|
|
32225
|
-
maxDepth,
|
|
32226
|
-
maxFolderPercent,
|
|
32227
|
-
maxFolderFiles
|
|
32228
|
-
});
|
|
32173
|
+
const limits = checkLayoutLimits(plan2, maxDepth);
|
|
32229
32174
|
if (options2.check) return checkPlan(plan2, limits);
|
|
32230
32175
|
runPlan(plan2, limits, options2.apply === true);
|
|
32231
32176
|
}
|
|
@@ -32602,8 +32547,8 @@ function groupFilesByDirectory(files) {
|
|
|
32602
32547
|
}
|
|
32603
32548
|
|
|
32604
32549
|
// src/commands/review/highLevel/buildHighLevelTree.ts
|
|
32605
|
-
function basename19(
|
|
32606
|
-
return
|
|
32550
|
+
function basename19(path106) {
|
|
32551
|
+
return path106.slice(path106.lastIndexOf("/") + 1);
|
|
32607
32552
|
}
|
|
32608
32553
|
function sum(nodes, key) {
|
|
32609
32554
|
return nodes.reduce((total, node) => total + node[key], 0);
|
|
@@ -32626,19 +32571,19 @@ function nodesOf(at2, prefix2) {
|
|
|
32626
32571
|
}
|
|
32627
32572
|
function collapsedDirNode(name, at2, prefix2) {
|
|
32628
32573
|
let label2 = name;
|
|
32629
|
-
let
|
|
32574
|
+
let path106 = prefix2 ? `${prefix2}/${name}` : name;
|
|
32630
32575
|
let node = at2;
|
|
32631
32576
|
while (node.files.length === 0 && node.dirs.size === 1) {
|
|
32632
32577
|
const [childName, child] = [...node.dirs][0];
|
|
32633
32578
|
label2 = `${label2}/${childName}`;
|
|
32634
|
-
|
|
32579
|
+
path106 = `${path106}/${childName}`;
|
|
32635
32580
|
node = child;
|
|
32636
32581
|
}
|
|
32637
|
-
const children = nodesOf(node,
|
|
32582
|
+
const children = nodesOf(node, path106);
|
|
32638
32583
|
return {
|
|
32639
32584
|
kind: "dir",
|
|
32640
32585
|
name: label2,
|
|
32641
|
-
path:
|
|
32586
|
+
path: path106,
|
|
32642
32587
|
additions: sum(children, "additions"),
|
|
32643
32588
|
deletions: sum(children, "deletions"),
|
|
32644
32589
|
children
|
|
@@ -32896,8 +32841,8 @@ function toStatus(status3) {
|
|
|
32896
32841
|
if (status3 === "removed") return "removed";
|
|
32897
32842
|
return "modified";
|
|
32898
32843
|
}
|
|
32899
|
-
function diffUrl(repo, prNumber,
|
|
32900
|
-
const anchor = createHash3("sha256").update(
|
|
32844
|
+
function diffUrl(repo, prNumber, path106) {
|
|
32845
|
+
const anchor = createHash3("sha256").update(path106).digest("hex");
|
|
32901
32846
|
return `https://github.com/${repo}/pull/${prNumber}/files#diff-${anchor}`;
|
|
32902
32847
|
}
|
|
32903
32848
|
function fetchHighLevelFiles(prNumber, repo) {
|
|
@@ -32953,10 +32898,10 @@ function highLevelReviewPath(repo, headRef, headSha) {
|
|
|
32953
32898
|
|
|
32954
32899
|
// src/commands/review/highLevel/loadHighLevelReview.ts
|
|
32955
32900
|
function loadHighLevelReview(repo, headRef, headSha) {
|
|
32956
|
-
const
|
|
32957
|
-
if (!existsSync64(
|
|
32901
|
+
const path106 = highLevelReviewPath(repo, headRef, headSha);
|
|
32902
|
+
if (!existsSync64(path106)) return void 0;
|
|
32958
32903
|
try {
|
|
32959
|
-
return JSON.parse(readFileSync47(
|
|
32904
|
+
return JSON.parse(readFileSync47(path106, "utf8"));
|
|
32960
32905
|
} catch {
|
|
32961
32906
|
return void 0;
|
|
32962
32907
|
}
|
|
@@ -32967,8 +32912,8 @@ import { minimatch as minimatch7 } from "minimatch";
|
|
|
32967
32912
|
function selectCriticalDiffs(files, criticalPaths) {
|
|
32968
32913
|
if (criticalPaths.length === 0) return [];
|
|
32969
32914
|
return files.filter((file) => criticalPaths.some((glob) => minimatch7(file.path, glob))).map(
|
|
32970
|
-
({ path:
|
|
32971
|
-
path:
|
|
32915
|
+
({ path: path106, status: status3, additions, deletions, diffUrl: diffUrl2, patch: patch2, truncated }) => ({
|
|
32916
|
+
path: path106,
|
|
32972
32917
|
status: status3,
|
|
32973
32918
|
additions,
|
|
32974
32919
|
deletions,
|
|
@@ -33083,11 +33028,11 @@ function highLevelPreviewPayload(subject) {
|
|
|
33083
33028
|
import { mkdirSync as mkdirSync22, writeFileSync as writeFileSync39 } from "fs";
|
|
33084
33029
|
import { dirname as dirname36 } from "path";
|
|
33085
33030
|
function saveHighLevelReview(record) {
|
|
33086
|
-
const
|
|
33087
|
-
mkdirSync22(dirname36(
|
|
33088
|
-
writeFileSync39(
|
|
33031
|
+
const path106 = highLevelReviewPath(record.repo, record.headRef, record.headSha);
|
|
33032
|
+
mkdirSync22(dirname36(path106), { recursive: true });
|
|
33033
|
+
writeFileSync39(path106, `${JSON.stringify(record, null, 2)}
|
|
33089
33034
|
`);
|
|
33090
|
-
return
|
|
33035
|
+
return path106;
|
|
33091
33036
|
}
|
|
33092
33037
|
|
|
33093
33038
|
// src/commands/review/highLevel/openHighLevelOverlay.ts
|
|
@@ -33106,9 +33051,9 @@ async function openHighLevelOverlay(sessionId, subject) {
|
|
|
33106
33051
|
{ rejectIsOutcome: true }
|
|
33107
33052
|
);
|
|
33108
33053
|
const record = buildHighLevelRecord(subject, decision);
|
|
33109
|
-
const
|
|
33054
|
+
const path106 = saveHighLevelReview(record);
|
|
33110
33055
|
console.log(`Verdict: ${record.verdict}`);
|
|
33111
|
-
console.log(`Saved ${
|
|
33056
|
+
console.log(`Saved ${path106}`);
|
|
33112
33057
|
console.log("Nothing was posted to GitHub.");
|
|
33113
33058
|
return record;
|
|
33114
33059
|
}
|
|
@@ -34123,8 +34068,8 @@ async function handlePostSynthesis(synthesisPath, prInfo, options2) {
|
|
|
34123
34068
|
// src/commands/review/prepareReviewDir.ts
|
|
34124
34069
|
import { existsSync as existsSync65, mkdirSync as mkdirSync23, unlinkSync as unlinkSync18, writeFileSync as writeFileSync40 } from "fs";
|
|
34125
34070
|
function clearReviewFiles(paths) {
|
|
34126
|
-
for (const
|
|
34127
|
-
if (existsSync65(
|
|
34071
|
+
for (const path106 of [paths.claudePath, paths.codexPath, paths.synthesisPath]) {
|
|
34072
|
+
if (existsSync65(path106)) unlinkSync18(path106);
|
|
34128
34073
|
}
|
|
34129
34074
|
}
|
|
34130
34075
|
function prepareReviewDir(paths, requestBody, force) {
|
|
@@ -35362,7 +35307,7 @@ function registerReview(program2) {
|
|
|
35362
35307
|
|
|
35363
35308
|
// src/commands/rules/addRule.ts
|
|
35364
35309
|
import { existsSync as existsSync70, readFileSync as readFileSync53, writeFileSync as writeFileSync43 } from "fs";
|
|
35365
|
-
import
|
|
35310
|
+
import path85 from "path";
|
|
35366
35311
|
import chalk235 from "chalk";
|
|
35367
35312
|
|
|
35368
35313
|
// src/commands/rules/insertRuleBullet.ts
|
|
@@ -35390,7 +35335,7 @@ import { readFileSync as readFileSync50 } from "fs";
|
|
|
35390
35335
|
|
|
35391
35336
|
// src/commands/rules/findClaudeFiles.ts
|
|
35392
35337
|
import { readdirSync as readdirSync13 } from "fs";
|
|
35393
|
-
import
|
|
35338
|
+
import path81 from "path";
|
|
35394
35339
|
var SKIP_DIRECTORIES = /* @__PURE__ */ new Set(["node_modules", "dist", "build", "coverage"]);
|
|
35395
35340
|
function findClaudeFiles(dir) {
|
|
35396
35341
|
const results = [];
|
|
@@ -35398,9 +35343,9 @@ function findClaudeFiles(dir) {
|
|
|
35398
35343
|
if (entry.isDirectory()) {
|
|
35399
35344
|
if (entry.name.startsWith(".") || SKIP_DIRECTORIES.has(entry.name))
|
|
35400
35345
|
continue;
|
|
35401
|
-
results.push(...findClaudeFiles(
|
|
35346
|
+
results.push(...findClaudeFiles(path81.join(dir, entry.name)));
|
|
35402
35347
|
} else if (entry.name === "CLAUDE.md") {
|
|
35403
|
-
results.push(
|
|
35348
|
+
results.push(path81.join(dir, entry.name));
|
|
35404
35349
|
}
|
|
35405
35350
|
}
|
|
35406
35351
|
return results;
|
|
@@ -35419,34 +35364,34 @@ function nextRuleCode(root2) {
|
|
|
35419
35364
|
|
|
35420
35365
|
// src/commands/rules/resolveRuleScope.ts
|
|
35421
35366
|
import { existsSync as existsSync68 } from "fs";
|
|
35422
|
-
import
|
|
35367
|
+
import path82 from "path";
|
|
35423
35368
|
function resolveRuleScope(target) {
|
|
35424
|
-
const resolved =
|
|
35425
|
-
if (
|
|
35369
|
+
const resolved = path82.resolve(target);
|
|
35370
|
+
if (path82.basename(resolved) === "CLAUDE.md") return resolved;
|
|
35426
35371
|
const startDir = scopeDirectory(resolved);
|
|
35427
35372
|
const root2 = findRepoRoot(startDir) ?? startDir;
|
|
35428
35373
|
let current = startDir;
|
|
35429
35374
|
while (true) {
|
|
35430
|
-
const candidate =
|
|
35375
|
+
const candidate = path82.join(current, "CLAUDE.md");
|
|
35431
35376
|
if (existsSync68(candidate)) return candidate;
|
|
35432
|
-
if (current === root2 || current ===
|
|
35433
|
-
current =
|
|
35377
|
+
if (current === root2 || current === path82.dirname(current)) break;
|
|
35378
|
+
current = path82.dirname(current);
|
|
35434
35379
|
}
|
|
35435
|
-
return
|
|
35380
|
+
return path82.join(root2, "CLAUDE.md");
|
|
35436
35381
|
}
|
|
35437
35382
|
|
|
35438
35383
|
// src/commands/rules/updateScopedRulesIndex.ts
|
|
35439
35384
|
import { existsSync as existsSync69, readFileSync as readFileSync52, writeFileSync as writeFileSync42 } from "fs";
|
|
35440
|
-
import
|
|
35385
|
+
import path84 from "path";
|
|
35441
35386
|
|
|
35442
35387
|
// src/commands/rules/scopedRuleDirectories.ts
|
|
35443
35388
|
import { readFileSync as readFileSync51 } from "fs";
|
|
35444
|
-
import
|
|
35389
|
+
import path83 from "path";
|
|
35445
35390
|
function scopedRuleDirectories(root2) {
|
|
35446
35391
|
return findClaudeFiles(root2).filter(
|
|
35447
|
-
(file) =>
|
|
35392
|
+
(file) => path83.dirname(file) !== root2 && parseRulesSection(readFileSync51(file, "utf8")).length > 0
|
|
35448
35393
|
).map(
|
|
35449
|
-
(file) => `${
|
|
35394
|
+
(file) => `${path83.relative(root2, path83.dirname(file)).split(path83.sep).join("/")}/`
|
|
35450
35395
|
).sort();
|
|
35451
35396
|
}
|
|
35452
35397
|
|
|
@@ -35485,7 +35430,7 @@ function upsertScopedRulesPointer(content, directories) {
|
|
|
35485
35430
|
// src/commands/rules/updateScopedRulesIndex.ts
|
|
35486
35431
|
function updateScopedRulesIndex(root2) {
|
|
35487
35432
|
const directories = scopedRuleDirectories(root2);
|
|
35488
|
-
const rootFile =
|
|
35433
|
+
const rootFile = path84.join(root2, "CLAUDE.md");
|
|
35489
35434
|
const before = existsSync69(rootFile) ? readFileSync52(rootFile, "utf8") : "";
|
|
35490
35435
|
const after = upsertScopedRulesPointer(before, directories);
|
|
35491
35436
|
if (after !== before) writeFileSync42(rootFile, after);
|
|
@@ -35504,7 +35449,7 @@ function addRule(text18, options2) {
|
|
|
35504
35449
|
return;
|
|
35505
35450
|
}
|
|
35506
35451
|
const target = resolveRuleScope(options2.scope ?? process.cwd());
|
|
35507
|
-
const targetDir =
|
|
35452
|
+
const targetDir = path85.dirname(target);
|
|
35508
35453
|
const root2 = findRepoRoot(targetDir) ?? targetDir;
|
|
35509
35454
|
const code = nextRuleCode(root2);
|
|
35510
35455
|
writeFileSync43(
|
|
@@ -35517,18 +35462,18 @@ function addRule(text18, options2) {
|
|
|
35517
35462
|
);
|
|
35518
35463
|
updateScopedRulesIndex(root2);
|
|
35519
35464
|
console.log(
|
|
35520
|
-
`Added ${chalk235.cyan(code)} to ${
|
|
35465
|
+
`Added ${chalk235.cyan(code)} to ${path85.relative(process.cwd(), target) || target}`
|
|
35521
35466
|
);
|
|
35522
35467
|
}
|
|
35523
35468
|
|
|
35524
35469
|
// src/commands/rules/indexRules.ts
|
|
35525
|
-
import
|
|
35470
|
+
import path86 from "path";
|
|
35526
35471
|
import chalk236 from "chalk";
|
|
35527
35472
|
function indexRules() {
|
|
35528
35473
|
const startDir = scopeDirectory(process.cwd());
|
|
35529
35474
|
const root2 = findRepoRoot(startDir) ?? startDir;
|
|
35530
35475
|
const directories = updateScopedRulesIndex(root2);
|
|
35531
|
-
const rootFile =
|
|
35476
|
+
const rootFile = path86.relative(process.cwd(), path86.join(root2, "CLAUDE.md"));
|
|
35532
35477
|
if (directories.length === 0) {
|
|
35533
35478
|
console.log(
|
|
35534
35479
|
chalk236.gray(`No directories carry their own \`## Rules\` under ${root2}`)
|
|
@@ -35541,13 +35486,13 @@ function indexRules() {
|
|
|
35541
35486
|
}
|
|
35542
35487
|
|
|
35543
35488
|
// src/commands/rules/listRules.ts
|
|
35544
|
-
import
|
|
35489
|
+
import path87 from "path";
|
|
35545
35490
|
import chalk237 from "chalk";
|
|
35546
35491
|
function listRules(target, options2 = {}) {
|
|
35547
|
-
const resolved =
|
|
35492
|
+
const resolved = path87.resolve(target ?? process.cwd());
|
|
35548
35493
|
const rules3 = readScopedRules(resolved);
|
|
35549
35494
|
if (rules3.length === 0) {
|
|
35550
|
-
const label2 =
|
|
35495
|
+
const label2 = path87.relative(process.cwd(), resolved) || ".";
|
|
35551
35496
|
console.log(chalk237.gray(`No rules in scope for ${label2}`));
|
|
35552
35497
|
return;
|
|
35553
35498
|
}
|
|
@@ -35558,7 +35503,7 @@ function listRules(target, options2 = {}) {
|
|
|
35558
35503
|
if (rule.source !== shown) {
|
|
35559
35504
|
shown = rule.source;
|
|
35560
35505
|
console.log(
|
|
35561
|
-
chalk237.dim(base ?
|
|
35506
|
+
chalk237.dim(base ? path87.relative(base, rule.source) : rule.source)
|
|
35562
35507
|
);
|
|
35563
35508
|
}
|
|
35564
35509
|
console.log(
|
|
@@ -35654,8 +35599,8 @@ import chalk243 from "chalk";
|
|
|
35654
35599
|
|
|
35655
35600
|
// src/commands/seq/fetchSeq.ts
|
|
35656
35601
|
import chalk240 from "chalk";
|
|
35657
|
-
async function fetchSeq(conn,
|
|
35658
|
-
const url = `${conn.url}${
|
|
35602
|
+
async function fetchSeq(conn, path106, params) {
|
|
35603
|
+
const url = `${conn.url}${path106}?${params}`;
|
|
35659
35604
|
const response = await fetch(url, {
|
|
35660
35605
|
headers: {
|
|
35661
35606
|
Accept: "application/json",
|
|
@@ -36036,7 +35981,7 @@ async function previewSlackThreadParts({
|
|
|
36036
35981
|
`Approved for ${target}. The ${bodies.length} bodies to post, in thread order, are at:`
|
|
36037
35982
|
);
|
|
36038
35983
|
paths.forEach(
|
|
36039
|
-
(
|
|
35984
|
+
(path106, index3) => console.log(`${index3 + 1}/${paths.length} ${path106}`)
|
|
36040
35985
|
);
|
|
36041
35986
|
console.log(
|
|
36042
35987
|
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.`
|
|
@@ -36378,15 +36323,15 @@ function registerSql(program2) {
|
|
|
36378
36323
|
|
|
36379
36324
|
// src/commands/sync.ts
|
|
36380
36325
|
import * as os5 from "os";
|
|
36381
|
-
import * as
|
|
36326
|
+
import * as path99 from "path";
|
|
36382
36327
|
import { fileURLToPath as fileURLToPath8 } from "url";
|
|
36383
36328
|
|
|
36384
36329
|
// src/commands/sync/pruneCommands.ts
|
|
36385
|
-
import * as
|
|
36330
|
+
import * as path89 from "path";
|
|
36386
36331
|
|
|
36387
36332
|
// src/commands/sync/pruneTarget.ts
|
|
36388
36333
|
import * as fs39 from "fs";
|
|
36389
|
-
import * as
|
|
36334
|
+
import * as path88 from "path";
|
|
36390
36335
|
function pruneTarget(targetDir, keepNames, shape, options2) {
|
|
36391
36336
|
const result = {
|
|
36392
36337
|
orphans: [],
|
|
@@ -36404,7 +36349,7 @@ function pruneTarget(targetDir, keepNames, shape, options2) {
|
|
|
36404
36349
|
}
|
|
36405
36350
|
if (keep.has(name)) continue;
|
|
36406
36351
|
result.orphans.push(entry.name);
|
|
36407
|
-
const entryPath =
|
|
36352
|
+
const entryPath = path88.join(targetDir, entry.name);
|
|
36408
36353
|
const reason4 = shape.blockedBy?.(entryPath);
|
|
36409
36354
|
if (reason4) {
|
|
36410
36355
|
result.skipped.push({ name: entry.name, reason: reason4 });
|
|
@@ -36424,7 +36369,7 @@ function pruneCommands(targetDir, commandNames, options2) {
|
|
|
36424
36369
|
targetDir,
|
|
36425
36370
|
commandNames,
|
|
36426
36371
|
{
|
|
36427
|
-
nameOf: (entry) => entry.isFile() && entry.name.endsWith(".md") ?
|
|
36372
|
+
nameOf: (entry) => entry.isFile() && entry.name.endsWith(".md") ? path89.basename(entry.name, ".md") : void 0
|
|
36428
36373
|
},
|
|
36429
36374
|
options2
|
|
36430
36375
|
);
|
|
@@ -36459,16 +36404,16 @@ function reportPrune(label2, result, force) {
|
|
|
36459
36404
|
|
|
36460
36405
|
// src/commands/sync/syncClaudeCommands.ts
|
|
36461
36406
|
import * as fs43 from "fs";
|
|
36462
|
-
import * as
|
|
36407
|
+
import * as path93 from "path";
|
|
36463
36408
|
|
|
36464
36409
|
// src/commands/sync/syncCodex.ts
|
|
36465
|
-
import * as
|
|
36410
|
+
import * as path92 from "path";
|
|
36466
36411
|
|
|
36467
36412
|
// src/commands/sync/installHarnessCommands.ts
|
|
36468
36413
|
import * as fs40 from "fs";
|
|
36469
|
-
import * as
|
|
36414
|
+
import * as path90 from "path";
|
|
36470
36415
|
function installHarnessCommands(claudeDir, harness, transform) {
|
|
36471
|
-
const commandsSource =
|
|
36416
|
+
const commandsSource = path90.join(claudeDir, "commands");
|
|
36472
36417
|
const files = fs40.readdirSync(commandsSource);
|
|
36473
36418
|
const names = [];
|
|
36474
36419
|
let synced = 0;
|
|
@@ -36476,9 +36421,9 @@ function installHarnessCommands(claudeDir, harness, transform) {
|
|
|
36476
36421
|
if (!file.endsWith(".md")) continue;
|
|
36477
36422
|
const name = file.replace(/\.md$/, "");
|
|
36478
36423
|
names.push(name);
|
|
36479
|
-
const content = fs40.readFileSync(
|
|
36480
|
-
const target =
|
|
36481
|
-
fs40.mkdirSync(
|
|
36424
|
+
const content = fs40.readFileSync(path90.join(commandsSource, file), "utf8");
|
|
36425
|
+
const target = path90.join(harness.homeDir, harness.sync.commandDest(name));
|
|
36426
|
+
fs40.mkdirSync(path90.dirname(target), { recursive: true });
|
|
36482
36427
|
fs40.writeFileSync(target, transform(name, content));
|
|
36483
36428
|
synced++;
|
|
36484
36429
|
}
|
|
@@ -36507,7 +36452,7 @@ function unexpectedContent(skillDir) {
|
|
|
36507
36452
|
|
|
36508
36453
|
// src/commands/sync/syncCodexHooks.ts
|
|
36509
36454
|
import * as fs42 from "fs";
|
|
36510
|
-
import * as
|
|
36455
|
+
import * as path91 from "path";
|
|
36511
36456
|
var BEGIN = "# >>> assist codex hooks (managed) \u2014 do not edit >>>";
|
|
36512
36457
|
var END = "# <<< assist codex hooks (managed) <<<";
|
|
36513
36458
|
function upsertManagedBlock(existing, body) {
|
|
@@ -36538,9 +36483,9 @@ ${rest}
|
|
|
36538
36483
|
}
|
|
36539
36484
|
function syncCodexHooks(sourcePath) {
|
|
36540
36485
|
const body = fs42.readFileSync(sourcePath, "utf8");
|
|
36541
|
-
const configPath =
|
|
36486
|
+
const configPath = path91.join(harnesses.codex.homeDir, "config.toml");
|
|
36542
36487
|
const existing = fs42.existsSync(configPath) ? fs42.readFileSync(configPath, "utf8") : "";
|
|
36543
|
-
fs42.mkdirSync(
|
|
36488
|
+
fs42.mkdirSync(path91.dirname(configPath), { recursive: true });
|
|
36544
36489
|
fs42.writeFileSync(configPath, upsertManagedBlock(existing, body));
|
|
36545
36490
|
console.log(
|
|
36546
36491
|
"Registered assist codex-hook in ~/.codex/config.toml (SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, PermissionRequest, Stop)"
|
|
@@ -36572,13 +36517,13 @@ function syncCodex(claudeDir, options2) {
|
|
|
36572
36517
|
harnesses.codex,
|
|
36573
36518
|
commandToSkill
|
|
36574
36519
|
);
|
|
36575
|
-
syncCodexHooks(
|
|
36520
|
+
syncCodexHooks(path92.join(claudeDir, "..", "codex", "config.toml"));
|
|
36576
36521
|
console.log(`Synced ${total} skill(s) to ~/.codex/skills`);
|
|
36577
36522
|
if (!options2?.prune) return;
|
|
36578
36523
|
const force = options2.force ?? false;
|
|
36579
36524
|
reportPrune(
|
|
36580
36525
|
"~/.codex/skills",
|
|
36581
|
-
pruneSkills(
|
|
36526
|
+
pruneSkills(path92.join(harnesses.codex.homeDir, "skills"), names, { force }),
|
|
36582
36527
|
force
|
|
36583
36528
|
);
|
|
36584
36529
|
}
|
|
@@ -36593,30 +36538,30 @@ function replaceFileWithoutFollowingSymlink(file, content) {
|
|
|
36593
36538
|
fs43.writeFileSync(file, content);
|
|
36594
36539
|
}
|
|
36595
36540
|
function writeSkill(targetBase, name, content) {
|
|
36596
|
-
const skillDir =
|
|
36541
|
+
const skillDir = path93.join(targetBase, "skills", name);
|
|
36597
36542
|
fs43.mkdirSync(skillDir, { recursive: true });
|
|
36598
36543
|
replaceFileWithoutFollowingSymlink(
|
|
36599
|
-
|
|
36544
|
+
path93.join(skillDir, "SKILL.md"),
|
|
36600
36545
|
commandToSkill(name, content)
|
|
36601
36546
|
);
|
|
36602
|
-
fs43.rmSync(
|
|
36547
|
+
fs43.rmSync(path93.join(targetBase, "commands", `${name}.md`), { force: true });
|
|
36603
36548
|
console.log(`Wrote ${name} as a skill to ${skillDir}`);
|
|
36604
36549
|
}
|
|
36605
36550
|
function syncClaudeCommands(claudeDir, targetBase) {
|
|
36606
|
-
const sourceDir =
|
|
36607
|
-
const targetDir =
|
|
36551
|
+
const sourceDir = path93.join(claudeDir, "commands");
|
|
36552
|
+
const targetDir = path93.join(targetBase, "commands");
|
|
36608
36553
|
fs43.mkdirSync(targetDir, { recursive: true });
|
|
36609
36554
|
const files = fs43.readdirSync(sourceDir);
|
|
36610
36555
|
for (const file of files) {
|
|
36611
|
-
const source =
|
|
36556
|
+
const source = path93.join(sourceDir, file);
|
|
36612
36557
|
if (file.endsWith(".md")) {
|
|
36613
36558
|
const content = fs43.readFileSync(source, "utf8");
|
|
36614
36559
|
if (isSkillFlagged(content)) {
|
|
36615
|
-
writeSkill(targetBase,
|
|
36560
|
+
writeSkill(targetBase, path93.basename(file, ".md"), content);
|
|
36616
36561
|
continue;
|
|
36617
36562
|
}
|
|
36618
36563
|
}
|
|
36619
|
-
fs43.copyFileSync(source,
|
|
36564
|
+
fs43.copyFileSync(source, path93.join(targetDir, file));
|
|
36620
36565
|
console.log(`Copied ${file} to ${targetDir}`);
|
|
36621
36566
|
}
|
|
36622
36567
|
console.log(`Synced ${files.length} command(s) to ~/.claude`);
|
|
@@ -36625,11 +36570,11 @@ function syncClaudeCommands(claudeDir, targetBase) {
|
|
|
36625
36570
|
|
|
36626
36571
|
// src/commands/sync/reportRetiredAgentsFiles.ts
|
|
36627
36572
|
import * as fs44 from "fs";
|
|
36628
|
-
import * as
|
|
36573
|
+
import * as path94 from "path";
|
|
36629
36574
|
var retired = [
|
|
36630
|
-
|
|
36631
|
-
|
|
36632
|
-
|
|
36575
|
+
path94.join(harnesses.claude.homeDir, "CLAUDE.md"),
|
|
36576
|
+
path94.join(harnesses.codex.homeDir, "AGENTS.md"),
|
|
36577
|
+
path94.join(harnesses.pi.homeDir, "AGENTS.md")
|
|
36633
36578
|
];
|
|
36634
36579
|
function reportRetiredAgentsFiles() {
|
|
36635
36580
|
const leftovers = retired.filter((file) => fs44.existsSync(file));
|
|
@@ -36645,35 +36590,35 @@ function reportRetiredAgentsFiles() {
|
|
|
36645
36590
|
|
|
36646
36591
|
// src/commands/sync/syncDesign.ts
|
|
36647
36592
|
import * as fs45 from "fs";
|
|
36648
|
-
import * as
|
|
36593
|
+
import * as path95 from "path";
|
|
36649
36594
|
function syncDesign(claudeDir, targetBase) {
|
|
36650
|
-
const systemPromptSource =
|
|
36651
|
-
const systemPromptTarget =
|
|
36595
|
+
const systemPromptSource = path95.join(claudeDir, "design-system-prompt.md");
|
|
36596
|
+
const systemPromptTarget = path95.join(targetBase, "design-system-prompt.md");
|
|
36652
36597
|
fs45.copyFileSync(systemPromptSource, systemPromptTarget);
|
|
36653
36598
|
console.log(
|
|
36654
36599
|
"Copied design-system-prompt.md to ~/.claude/design-system-prompt.md"
|
|
36655
36600
|
);
|
|
36656
|
-
const skillsSource =
|
|
36657
|
-
const skillsTarget =
|
|
36601
|
+
const skillsSource = path95.join(claudeDir, "skills");
|
|
36602
|
+
const skillsTarget = path95.join(targetBase, "skills");
|
|
36658
36603
|
fs45.mkdirSync(skillsTarget, { recursive: true });
|
|
36659
36604
|
const files = fs45.readdirSync(skillsSource);
|
|
36660
36605
|
for (const file of files) {
|
|
36661
36606
|
fs45.copyFileSync(
|
|
36662
|
-
|
|
36663
|
-
|
|
36607
|
+
path95.join(skillsSource, file),
|
|
36608
|
+
path95.join(skillsTarget, file)
|
|
36664
36609
|
);
|
|
36665
36610
|
}
|
|
36666
36611
|
console.log(`Synced ${files.length} design skill(s) to ~/.claude/skills`);
|
|
36667
36612
|
}
|
|
36668
36613
|
|
|
36669
36614
|
// src/commands/sync/syncPi.ts
|
|
36670
|
-
import * as
|
|
36615
|
+
import * as path97 from "path";
|
|
36671
36616
|
|
|
36672
36617
|
// src/commands/sync/syncPiHooks.ts
|
|
36673
36618
|
import * as fs46 from "fs";
|
|
36674
|
-
import * as
|
|
36619
|
+
import * as path96 from "path";
|
|
36675
36620
|
function piExtensionsDir() {
|
|
36676
|
-
return
|
|
36621
|
+
return path96.join(harnesses.pi.homeDir, "extensions");
|
|
36677
36622
|
}
|
|
36678
36623
|
function syncPiHooks(sourceDir) {
|
|
36679
36624
|
const target = piExtensionsDir();
|
|
@@ -36681,8 +36626,8 @@ function syncPiHooks(sourceDir) {
|
|
|
36681
36626
|
const files = fs46.readdirSync(sourceDir).filter((f) => f.endsWith(".ts"));
|
|
36682
36627
|
for (const file of files) {
|
|
36683
36628
|
fs46.copyFileSync(
|
|
36684
|
-
|
|
36685
|
-
|
|
36629
|
+
path96.join(sourceDir, file),
|
|
36630
|
+
path96.join(target, `assist-${file}`)
|
|
36686
36631
|
);
|
|
36687
36632
|
}
|
|
36688
36633
|
console.log(
|
|
@@ -36719,24 +36664,24 @@ function syncPi(claudeDir, options2) {
|
|
|
36719
36664
|
harnesses.pi,
|
|
36720
36665
|
commandToPrompt
|
|
36721
36666
|
);
|
|
36722
|
-
syncPiHooks(
|
|
36667
|
+
syncPiHooks(path97.join(claudeDir, "..", "pi"));
|
|
36723
36668
|
console.log(`Synced ${synced} prompt(s) to ~/.pi/agent/prompts`);
|
|
36724
36669
|
if (!options2?.prune) return;
|
|
36725
36670
|
const force = options2.force ?? false;
|
|
36726
36671
|
reportPrune(
|
|
36727
36672
|
"~/.pi/agent/prompts",
|
|
36728
|
-
pruneCommands(
|
|
36673
|
+
pruneCommands(path97.join(harnesses.pi.homeDir, "prompts"), names, { force }),
|
|
36729
36674
|
force
|
|
36730
36675
|
);
|
|
36731
36676
|
}
|
|
36732
36677
|
|
|
36733
36678
|
// src/commands/sync/syncSettings.ts
|
|
36734
36679
|
import * as fs47 from "fs";
|
|
36735
|
-
import * as
|
|
36680
|
+
import * as path98 from "path";
|
|
36736
36681
|
import chalk250 from "chalk";
|
|
36737
36682
|
async function syncSettings(claudeDir, targetBase, options2) {
|
|
36738
|
-
const source =
|
|
36739
|
-
const target =
|
|
36683
|
+
const source = path98.join(claudeDir, "settings.json");
|
|
36684
|
+
const target = path98.join(targetBase, "settings.json");
|
|
36740
36685
|
const sourceContent = fs47.readFileSync(source, "utf8");
|
|
36741
36686
|
const sourceSettings = JSON.parse(sourceContent);
|
|
36742
36687
|
const targetExists = fs47.existsSync(target);
|
|
@@ -36776,13 +36721,13 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
36776
36721
|
|
|
36777
36722
|
// src/commands/sync.ts
|
|
36778
36723
|
var __filename4 = fileURLToPath8(import.meta.url);
|
|
36779
|
-
var __dirname5 =
|
|
36724
|
+
var __dirname5 = path99.dirname(__filename4);
|
|
36780
36725
|
async function sync(options2) {
|
|
36781
36726
|
const config = loadConfig();
|
|
36782
36727
|
const yes = options2?.yes ?? config.sync.autoConfirm;
|
|
36783
36728
|
const prune = { prune: options2?.prune, force: options2?.force };
|
|
36784
|
-
const claudeDir =
|
|
36785
|
-
const targetBase =
|
|
36729
|
+
const claudeDir = path99.join(__dirname5, "..", "claude");
|
|
36730
|
+
const targetBase = path99.join(os5.homedir(), ".claude");
|
|
36786
36731
|
const commandFiles = syncClaudeCommands(claudeDir, targetBase);
|
|
36787
36732
|
syncDesign(claudeDir, targetBase);
|
|
36788
36733
|
await syncSettings(claudeDir, targetBase, { yes });
|
|
@@ -36790,11 +36735,11 @@ async function sync(options2) {
|
|
|
36790
36735
|
syncPi(claudeDir, prune);
|
|
36791
36736
|
reportRetiredAgentsFiles();
|
|
36792
36737
|
if (!options2?.prune) return;
|
|
36793
|
-
const commandNames = commandFiles.filter((file) => file.endsWith(".md")).map((file) =>
|
|
36738
|
+
const commandNames = commandFiles.filter((file) => file.endsWith(".md")).map((file) => path99.basename(file, ".md"));
|
|
36794
36739
|
const force = options2.force ?? false;
|
|
36795
36740
|
reportPrune(
|
|
36796
36741
|
"~/.claude/commands",
|
|
36797
|
-
pruneCommands(
|
|
36742
|
+
pruneCommands(path99.join(targetBase, "commands"), commandNames, { force }),
|
|
36798
36743
|
force
|
|
36799
36744
|
);
|
|
36800
36745
|
}
|
|
@@ -37850,9 +37795,9 @@ import { existsSync as existsSync79, readFileSync as readFileSync60 } from "fs";
|
|
|
37850
37795
|
|
|
37851
37796
|
// src/commands/verify/forbiddenStrings/findForbiddenStrings.ts
|
|
37852
37797
|
import { minimatch as minimatch9 } from "minimatch";
|
|
37853
|
-
function resolveStringsAtPath(data,
|
|
37798
|
+
function resolveStringsAtPath(data, path106) {
|
|
37854
37799
|
let current = data;
|
|
37855
|
-
for (const segment of
|
|
37800
|
+
for (const segment of path106.split(".")) {
|
|
37856
37801
|
if (current === null || typeof current !== "object") return [];
|
|
37857
37802
|
current = current[segment];
|
|
37858
37803
|
}
|
|
@@ -37865,10 +37810,10 @@ function resolveStringsAtPath(data, path107) {
|
|
|
37865
37810
|
}
|
|
37866
37811
|
function findRuleViolations(data, rule) {
|
|
37867
37812
|
const violations = [];
|
|
37868
|
-
for (const
|
|
37869
|
-
for (const value of resolveStringsAtPath(data,
|
|
37813
|
+
for (const path106 of rule.paths) {
|
|
37814
|
+
for (const value of resolveStringsAtPath(data, path106)) {
|
|
37870
37815
|
if (minimatch9(value, rule.disallowed))
|
|
37871
|
-
violations.push({ file: rule.file, path:
|
|
37816
|
+
violations.push({ file: rule.file, path: path106, value });
|
|
37872
37817
|
}
|
|
37873
37818
|
}
|
|
37874
37819
|
return violations;
|
|
@@ -37907,8 +37852,8 @@ function forbiddenStrings() {
|
|
|
37907
37852
|
process.exit(0);
|
|
37908
37853
|
}
|
|
37909
37854
|
console.log("Forbidden strings found:\n");
|
|
37910
|
-
for (const { file, path:
|
|
37911
|
-
console.log(` ${file} ${
|
|
37855
|
+
for (const { file, path: path106, value } of violations) {
|
|
37856
|
+
console.log(` ${file} ${path106}: ${value}`);
|
|
37912
37857
|
}
|
|
37913
37858
|
console.log(`
|
|
37914
37859
|
Total: ${violations.length} forbidden string(s).`);
|
|
@@ -37964,7 +37909,7 @@ Total: ${lines2.length} hardcoded color(s)`);
|
|
|
37964
37909
|
|
|
37965
37910
|
// src/commands/verify/migrations.ts
|
|
37966
37911
|
import { readFileSync as readFileSync61 } from "fs";
|
|
37967
|
-
import
|
|
37912
|
+
import path101 from "path";
|
|
37968
37913
|
|
|
37969
37914
|
// src/commands/verify/migrations/checkAppendOnly.ts
|
|
37970
37915
|
function checkAppendOnly(baseline, current) {
|
|
@@ -38056,15 +38001,15 @@ function readBaselineMigrations(repoRelativeDir, ref) {
|
|
|
38056
38001
|
} catch {
|
|
38057
38002
|
return baseline;
|
|
38058
38003
|
}
|
|
38059
|
-
const paths = listing.split("\n").map((line) => line.trim()).filter(Boolean).filter((
|
|
38060
|
-
for (const
|
|
38004
|
+
const paths = listing.split("\n").map((line) => line.trim()).filter(Boolean).filter((path106) => MIGRATION_FILE3.test(basename26(path106)));
|
|
38005
|
+
for (const path106 of paths) {
|
|
38061
38006
|
try {
|
|
38062
|
-
const content = execSync63(`git show "${ref}:${
|
|
38007
|
+
const content = execSync63(`git show "${ref}:${path106}"`, {
|
|
38063
38008
|
encoding: "utf8",
|
|
38064
38009
|
maxBuffer: 16 * 1024 * 1024,
|
|
38065
38010
|
stdio: ["pipe", "pipe", "pipe"]
|
|
38066
38011
|
});
|
|
38067
|
-
baseline.set(basename26(
|
|
38012
|
+
baseline.set(basename26(path106), content);
|
|
38068
38013
|
} catch {
|
|
38069
38014
|
}
|
|
38070
38015
|
}
|
|
@@ -38103,11 +38048,11 @@ function resolveBaselineRef() {
|
|
|
38103
38048
|
}
|
|
38104
38049
|
|
|
38105
38050
|
// src/commands/verify/migrations/migrationsDir.ts
|
|
38106
|
-
import
|
|
38051
|
+
import path100 from "path";
|
|
38107
38052
|
import { fileURLToPath as fileURLToPath9 } from "url";
|
|
38108
38053
|
function migrationsDir() {
|
|
38109
|
-
return
|
|
38110
|
-
|
|
38054
|
+
return path100.resolve(
|
|
38055
|
+
path100.dirname(fileURLToPath9(import.meta.url)),
|
|
38111
38056
|
"../../../shared/db/migrations"
|
|
38112
38057
|
);
|
|
38113
38058
|
}
|
|
@@ -38128,7 +38073,7 @@ function migrations2() {
|
|
|
38128
38073
|
if (ref) {
|
|
38129
38074
|
const baseline = readBaselineMigrations(REPO_RELATIVE_DIR, ref);
|
|
38130
38075
|
const current = new Map(
|
|
38131
|
-
files.map((file) => [file, readFileSync61(
|
|
38076
|
+
files.map((file) => [file, readFileSync61(path101.join(dir, file), "utf8")])
|
|
38132
38077
|
);
|
|
38133
38078
|
for (const finding of checkAppendOnly(baseline, current)) {
|
|
38134
38079
|
problems.push(
|
|
@@ -38633,11 +38578,11 @@ var webUiPrefix = "src/commands/sessions/web/ui/";
|
|
|
38633
38578
|
var sessionsPrefix = "src/commands/sessions/";
|
|
38634
38579
|
var rules = [
|
|
38635
38580
|
{
|
|
38636
|
-
matches: (
|
|
38581
|
+
matches: (path106) => path106.startsWith(webUiPrefix),
|
|
38637
38582
|
advice: "restart the web server, then hard-reload the browser tab"
|
|
38638
38583
|
},
|
|
38639
38584
|
{
|
|
38640
|
-
matches: (
|
|
38585
|
+
matches: (path106) => path106.startsWith(sessionsPrefix) && !path106.startsWith(webUiPrefix),
|
|
38641
38586
|
advice: "restart the daemon"
|
|
38642
38587
|
}
|
|
38643
38588
|
];
|
|
@@ -38648,27 +38593,27 @@ function restartAdvice(paths) {
|
|
|
38648
38593
|
// src/commands/watch/syncAdvice.ts
|
|
38649
38594
|
var rules2 = [
|
|
38650
38595
|
{
|
|
38651
|
-
matches: (
|
|
38596
|
+
matches: (path106) => path106.startsWith("claude/commands/"),
|
|
38652
38597
|
reason: "claude/commands changed"
|
|
38653
38598
|
},
|
|
38654
38599
|
{
|
|
38655
|
-
matches: (
|
|
38600
|
+
matches: (path106) => path106.startsWith("claude/skills/"),
|
|
38656
38601
|
reason: "claude/skills changed"
|
|
38657
38602
|
},
|
|
38658
38603
|
{
|
|
38659
|
-
matches: (
|
|
38604
|
+
matches: (path106) => path106 === "claude/settings.json",
|
|
38660
38605
|
reason: "claude/settings.json changed"
|
|
38661
38606
|
},
|
|
38662
38607
|
{
|
|
38663
|
-
matches: (
|
|
38608
|
+
matches: (path106) => path106 === "claude/design-system-prompt.md",
|
|
38664
38609
|
reason: "claude/design-system-prompt.md changed"
|
|
38665
38610
|
},
|
|
38666
38611
|
{
|
|
38667
|
-
matches: (
|
|
38612
|
+
matches: (path106) => path106.startsWith("codex/"),
|
|
38668
38613
|
reason: "codex sources changed"
|
|
38669
38614
|
},
|
|
38670
38615
|
{
|
|
38671
|
-
matches: (
|
|
38616
|
+
matches: (path106) => path106.startsWith("pi/"),
|
|
38672
38617
|
reason: "pi sources changed"
|
|
38673
38618
|
}
|
|
38674
38619
|
];
|
|
@@ -39319,9 +39264,9 @@ function findPortFile(roamDir) {
|
|
|
39319
39264
|
return void 0;
|
|
39320
39265
|
}
|
|
39321
39266
|
const candidates = entries.filter((name) => /^roam-local-api(-[^.]+)?\.port$/.test(name)).map((name) => {
|
|
39322
|
-
const
|
|
39267
|
+
const path106 = join101(roamDir, name);
|
|
39323
39268
|
try {
|
|
39324
|
-
return { path:
|
|
39269
|
+
return { path: path106, mtimeMs: statSync13(path106).mtimeMs };
|
|
39325
39270
|
} catch {
|
|
39326
39271
|
return void 0;
|
|
39327
39272
|
}
|
|
@@ -39565,11 +39510,11 @@ function findLinkIndex() {
|
|
|
39565
39510
|
function parseLinkArgs() {
|
|
39566
39511
|
const idx = findLinkIndex();
|
|
39567
39512
|
if (idx === -1) return null;
|
|
39568
|
-
const
|
|
39513
|
+
const path106 = process.argv[idx + 1];
|
|
39569
39514
|
const rest = process.argv.slice(idx + 2);
|
|
39570
39515
|
const { value: prefix2 } = extractOption(rest, "--prefix");
|
|
39571
39516
|
if (!prefix2) return null;
|
|
39572
|
-
return { path:
|
|
39517
|
+
return { path: path106, prefix: prefix2 };
|
|
39573
39518
|
}
|
|
39574
39519
|
function hasDuplicateLink(runList, linkPath) {
|
|
39575
39520
|
return runList.some(
|
|
@@ -40214,14 +40159,14 @@ import * as pty from "node-pty";
|
|
|
40214
40159
|
// src/commands/sessions/daemon/ensureSpawnHelperExecutable.ts
|
|
40215
40160
|
import { chmodSync, existsSync as existsSync87, statSync as statSync14 } from "fs";
|
|
40216
40161
|
import { createRequire as createRequire3 } from "module";
|
|
40217
|
-
import
|
|
40162
|
+
import path102 from "path";
|
|
40218
40163
|
var require4 = createRequire3(import.meta.url);
|
|
40219
40164
|
var ensured = false;
|
|
40220
40165
|
function ensureSpawnHelperExecutable() {
|
|
40221
40166
|
if (ensured || process.platform !== "darwin") return;
|
|
40222
40167
|
ensured = true;
|
|
40223
|
-
const ptyRoot =
|
|
40224
|
-
const helper =
|
|
40168
|
+
const ptyRoot = path102.join(path102.dirname(require4.resolve("node-pty")), "..");
|
|
40169
|
+
const helper = path102.join(
|
|
40225
40170
|
ptyRoot,
|
|
40226
40171
|
"prebuilds",
|
|
40227
40172
|
`${process.platform}-${process.arch}`,
|
|
@@ -40352,12 +40297,12 @@ function serverRunMeta(runName, cwd) {
|
|
|
40352
40297
|
|
|
40353
40298
|
// src/commands/sessions/daemon/readDesignSystemPrompt.ts
|
|
40354
40299
|
import * as fs50 from "fs";
|
|
40355
|
-
import * as
|
|
40300
|
+
import * as path103 from "path";
|
|
40356
40301
|
import { fileURLToPath as fileURLToPath11 } from "url";
|
|
40357
40302
|
var __filename5 = fileURLToPath11(import.meta.url);
|
|
40358
|
-
var __dirname7 =
|
|
40303
|
+
var __dirname7 = path103.dirname(__filename5);
|
|
40359
40304
|
function readDesignSystemPrompt() {
|
|
40360
|
-
const promptPath =
|
|
40305
|
+
const promptPath = path103.join(
|
|
40361
40306
|
__dirname7,
|
|
40362
40307
|
"..",
|
|
40363
40308
|
"claude",
|
|
@@ -41391,8 +41336,8 @@ async function seedRunningMsFromUsage(session, notify2) {
|
|
|
41391
41336
|
var DEBOUNCE_MS2 = 50;
|
|
41392
41337
|
function watchActivity(session, notify2, onClaudeSessionId) {
|
|
41393
41338
|
if (session.commandType !== "assist" || !session.cwd) return;
|
|
41394
|
-
const
|
|
41395
|
-
const dir = dirname42(
|
|
41339
|
+
const path106 = activityPath(session.id);
|
|
41340
|
+
const dir = dirname42(path106);
|
|
41396
41341
|
try {
|
|
41397
41342
|
mkdirSync37(dir, { recursive: true });
|
|
41398
41343
|
} catch {
|
|
@@ -41402,7 +41347,7 @@ function watchActivity(session, notify2, onClaudeSessionId) {
|
|
|
41402
41347
|
let timer = null;
|
|
41403
41348
|
const read3 = () => {
|
|
41404
41349
|
timer = null;
|
|
41405
|
-
const activity2 = readActivity(
|
|
41350
|
+
const activity2 = readActivity(path106);
|
|
41406
41351
|
if (!activity2) return;
|
|
41407
41352
|
applyActivityToSession(session, activity2);
|
|
41408
41353
|
if (activity2.claudeSessionId) onClaudeSessionId?.(session);
|
|
@@ -41411,11 +41356,11 @@ function watchActivity(session, notify2, onClaudeSessionId) {
|
|
|
41411
41356
|
notify2();
|
|
41412
41357
|
};
|
|
41413
41358
|
session.activityWatcher = watch2(dir, (_event, filename) => {
|
|
41414
|
-
if (filename && !
|
|
41359
|
+
if (filename && !path106.endsWith(filename)) return;
|
|
41415
41360
|
if (timer) clearTimeout(timer);
|
|
41416
41361
|
timer = setTimeout(read3, DEBOUNCE_MS2);
|
|
41417
41362
|
});
|
|
41418
|
-
if (existsSync93(
|
|
41363
|
+
if (existsSync93(path106)) read3();
|
|
41419
41364
|
}
|
|
41420
41365
|
function refreshActivity(session) {
|
|
41421
41366
|
if (session.commandType !== "assist" || !session.cwd) return;
|
|
@@ -41558,12 +41503,12 @@ import { watch as watch3 } from "fs";
|
|
|
41558
41503
|
|
|
41559
41504
|
// src/commands/sessions/shared/findTranscriptPathSync.ts
|
|
41560
41505
|
import * as fs52 from "fs";
|
|
41561
|
-
import * as
|
|
41506
|
+
import * as path104 from "path";
|
|
41562
41507
|
function projectDirForCwd(cwd) {
|
|
41563
|
-
return
|
|
41508
|
+
return path104.join(claudeProjectsRoot(), projectSlug(cwd));
|
|
41564
41509
|
}
|
|
41565
41510
|
function transcriptPathFor(cwd, claudeSessionId) {
|
|
41566
|
-
return
|
|
41511
|
+
return path104.join(projectDirForCwd(cwd), `${claudeSessionId}.jsonl`);
|
|
41567
41512
|
}
|
|
41568
41513
|
function findTranscriptPathSync(cwd, claudeSessionId) {
|
|
41569
41514
|
const direct = transcriptPathFor(cwd, claudeSessionId);
|
|
@@ -41577,8 +41522,8 @@ function findTranscriptPathSync(cwd, claudeSessionId) {
|
|
|
41577
41522
|
}
|
|
41578
41523
|
for (const file of files) {
|
|
41579
41524
|
if (!file.endsWith(".jsonl")) continue;
|
|
41580
|
-
if (headContainsSessionId(
|
|
41581
|
-
return
|
|
41525
|
+
if (headContainsSessionId(path104.join(dir, file), claudeSessionId))
|
|
41526
|
+
return path104.join(dir, file);
|
|
41582
41527
|
}
|
|
41583
41528
|
return null;
|
|
41584
41529
|
}
|
|
@@ -42778,9 +42723,9 @@ function tempRoots() {
|
|
|
42778
42723
|
}
|
|
42779
42724
|
return [...roots];
|
|
42780
42725
|
}
|
|
42781
|
-
function underTempRoot(
|
|
42726
|
+
function underTempRoot(path106) {
|
|
42782
42727
|
return tempRoots().some(
|
|
42783
|
-
(root2) =>
|
|
42728
|
+
(root2) => path106.startsWith(root2.endsWith(sep3) ? root2 : root2 + sep3)
|
|
42784
42729
|
);
|
|
42785
42730
|
}
|
|
42786
42731
|
|
|
@@ -43266,15 +43211,15 @@ function bindResumedWorktree(session, cwd, notify2) {
|
|
|
43266
43211
|
import { existsSync as existsSync95 } from "fs";
|
|
43267
43212
|
async function reclaimVanishedWorktrees(clone, paths) {
|
|
43268
43213
|
if (!existsSync95(clone)) {
|
|
43269
|
-
for (const { path:
|
|
43214
|
+
for (const { path: path106 } of paths) forgetWorktree(path106);
|
|
43270
43215
|
daemonLog(
|
|
43271
43216
|
`clone ${clone} is gone; forgot ${paths.length} worktree record(s) it owned`
|
|
43272
43217
|
);
|
|
43273
43218
|
return;
|
|
43274
43219
|
}
|
|
43275
43220
|
await pruneBookkeeping2(clone);
|
|
43276
|
-
for (const { path:
|
|
43277
|
-
if (await reclaimBranch(clone, branch2)) forgetWorktree(
|
|
43221
|
+
for (const { path: path106, branch: branch2 } of paths)
|
|
43222
|
+
if (await reclaimBranch(clone, branch2)) forgetWorktree(path106);
|
|
43278
43223
|
}
|
|
43279
43224
|
async function pruneBookkeeping2(clone) {
|
|
43280
43225
|
try {
|
|
@@ -43301,37 +43246,37 @@ async function reclaimBranch(clone, branch2) {
|
|
|
43301
43246
|
}
|
|
43302
43247
|
|
|
43303
43248
|
// src/commands/sessions/daemon/worktree/logVanishedTree.ts
|
|
43304
|
-
function logVanishedTree(sessions,
|
|
43249
|
+
function logVanishedTree(sessions, path106) {
|
|
43305
43250
|
const claimants = [...sessions.values()].filter(
|
|
43306
|
-
(s) => s.cwd ===
|
|
43251
|
+
(s) => s.cwd === path106 || s.worktree?.path === path106
|
|
43307
43252
|
);
|
|
43308
43253
|
if (claimants.length === 0) {
|
|
43309
|
-
daemonLog(`worktree ${
|
|
43254
|
+
daemonLog(`worktree ${path106} gone from disk and unclaimed; reclaiming it`);
|
|
43310
43255
|
return;
|
|
43311
43256
|
}
|
|
43312
43257
|
for (const s of claimants)
|
|
43313
43258
|
daemonLog(
|
|
43314
|
-
`session ${s.id} ("${s.name}") claims worktree ${
|
|
43259
|
+
`session ${s.id} ("${s.name}") claims worktree ${path106}, which is gone from disk; reclaiming it`
|
|
43315
43260
|
);
|
|
43316
43261
|
}
|
|
43317
43262
|
|
|
43318
43263
|
// src/commands/sessions/daemon/worktree/describeHeldWork.ts
|
|
43319
43264
|
var MAX_ITEMS = 20;
|
|
43320
|
-
async function describeHeldWork(
|
|
43321
|
-
if (reason4.startsWith("uncommitted")) return await changedFiles(
|
|
43322
|
-
if (reason4.startsWith("unpushed")) return await unpushedCommits(
|
|
43265
|
+
async function describeHeldWork(path106, reason4) {
|
|
43266
|
+
if (reason4.startsWith("uncommitted")) return await changedFiles(path106);
|
|
43267
|
+
if (reason4.startsWith("unpushed")) return await unpushedCommits(path106, reason4);
|
|
43323
43268
|
return { summary: reason4, items: [] };
|
|
43324
43269
|
}
|
|
43325
|
-
async function changedFiles(
|
|
43326
|
-
const status3 = await gitResult(
|
|
43270
|
+
async function changedFiles(path106) {
|
|
43271
|
+
const status3 = await gitResult(path106, ["status", "--porcelain"]);
|
|
43327
43272
|
const lines2 = status3.ok ? nonEmptyLines(status3.out) : [];
|
|
43328
43273
|
return {
|
|
43329
43274
|
summary: `${lines2.length} uncommitted ${lines2.length === 1 ? "file" : "files"}`,
|
|
43330
43275
|
items: capped2(lines2)
|
|
43331
43276
|
};
|
|
43332
43277
|
}
|
|
43333
|
-
async function unpushedCommits(
|
|
43334
|
-
const log2 = await gitResult(
|
|
43278
|
+
async function unpushedCommits(path106, reason4) {
|
|
43279
|
+
const log2 = await gitResult(path106, ["log", "--oneline", "@{upstream}..HEAD"]);
|
|
43335
43280
|
if (!log2.ok) return { summary: reason4, items: [] };
|
|
43336
43281
|
const lines2 = nonEmptyLines(log2.out);
|
|
43337
43282
|
return {
|
|
@@ -43423,24 +43368,24 @@ function reconcileWorktreesOnRestore(sessions, spawnWith, notify2) {
|
|
|
43423
43368
|
async function recoverOrphanedWorktrees(sessions, spawnWith, notify2) {
|
|
43424
43369
|
const accounted = accountedTrees(sessions);
|
|
43425
43370
|
const vanished = /* @__PURE__ */ new Map();
|
|
43426
|
-
for (const { path:
|
|
43427
|
-
if (underTempRoot(
|
|
43428
|
-
forgetWorktree(
|
|
43371
|
+
for (const { path: path106, clone } of readWorktreeRegistry()) {
|
|
43372
|
+
if (underTempRoot(path106)) {
|
|
43373
|
+
forgetWorktree(path106);
|
|
43429
43374
|
daemonLog(
|
|
43430
|
-
`worktree ${
|
|
43375
|
+
`worktree ${path106} lies outside any project root; pruned from the registry rather than recovered`
|
|
43431
43376
|
);
|
|
43432
43377
|
continue;
|
|
43433
43378
|
}
|
|
43434
|
-
if (!existsSync96(
|
|
43435
|
-
logVanishedTree(sessions,
|
|
43379
|
+
if (!existsSync96(path106)) {
|
|
43380
|
+
logVanishedTree(sessions, path106);
|
|
43436
43381
|
vanished.set(clone, [
|
|
43437
43382
|
...vanished.get(clone) ?? [],
|
|
43438
|
-
{ path:
|
|
43383
|
+
{ path: path106, branch: basename29(path106) }
|
|
43439
43384
|
]);
|
|
43440
43385
|
continue;
|
|
43441
43386
|
}
|
|
43442
|
-
if (accounted.has(
|
|
43443
|
-
await recoverOrphan(sessions, spawnWith, { path:
|
|
43387
|
+
if (accounted.has(path106)) continue;
|
|
43388
|
+
await recoverOrphan(sessions, spawnWith, { path: path106, clone }, notify2);
|
|
43444
43389
|
}
|
|
43445
43390
|
for (const [clone, paths] of vanished)
|
|
43446
43391
|
await reclaimVanishedWorktrees(clone, paths);
|
|
@@ -45518,12 +45463,12 @@ function handleSetStatus(client, m, d) {
|
|
|
45518
45463
|
import * as fs56 from "fs";
|
|
45519
45464
|
|
|
45520
45465
|
// src/commands/sessions/shared/codex/findCodexRolloutPath.ts
|
|
45521
|
-
import * as
|
|
45466
|
+
import * as path105 from "path";
|
|
45522
45467
|
async function findCodexRolloutPath(sessionId) {
|
|
45523
45468
|
if (!sessionId) return null;
|
|
45524
45469
|
const paths = await discoverCodexRolloutPaths();
|
|
45525
45470
|
const suffix = `-${sessionId}.jsonl`;
|
|
45526
|
-
return paths.find((file) =>
|
|
45471
|
+
return paths.find((file) => path105.basename(file).endsWith(suffix)) ?? null;
|
|
45527
45472
|
}
|
|
45528
45473
|
|
|
45529
45474
|
// src/commands/sessions/shared/codex/codexToolTarget.ts
|
|
@@ -46106,13 +46051,13 @@ function describePeerError(error) {
|
|
|
46106
46051
|
const cause = error.cause;
|
|
46107
46052
|
return cause instanceof Error ? `${error.message}: ${describePeerError(cause)}` : error.message;
|
|
46108
46053
|
}
|
|
46109
|
-
async function fetchPeerJson(baseUrl,
|
|
46110
|
-
const res = await fetch(new URL(
|
|
46054
|
+
async function fetchPeerJson(baseUrl, path106, timeoutMs = PEER_TIMEOUT_MS) {
|
|
46055
|
+
const res = await fetch(new URL(path106, baseUrl), {
|
|
46111
46056
|
signal: AbortSignal.timeout(timeoutMs)
|
|
46112
46057
|
});
|
|
46113
46058
|
if (!res.ok)
|
|
46114
46059
|
throw Object.assign(
|
|
46115
|
-
new Error(`GET ${
|
|
46060
|
+
new Error(`GET ${path106} returned ${res.status} ${res.statusText}`),
|
|
46116
46061
|
{ status: res.status }
|
|
46117
46062
|
);
|
|
46118
46063
|
return await res.json();
|