@staff0rd/assist 0.516.2 → 0.518.0
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 +403 -403
- package/dist/index.js +416 -318
- 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.
|
|
9
|
+
version: "0.518.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -10274,32 +10274,46 @@ async function diffScopes(req, res) {
|
|
|
10274
10274
|
|
|
10275
10275
|
// src/commands/sessions/web/fileContent.ts
|
|
10276
10276
|
import { readFile, stat as stat2 } from "fs/promises";
|
|
10277
|
+
|
|
10278
|
+
// src/commands/sessions/web/resolveWithinCwd.ts
|
|
10277
10279
|
import { isAbsolute as isAbsolute2, relative as relative2, resolve as resolve10 } from "path";
|
|
10278
|
-
|
|
10280
|
+
function repoRoot(cwd) {
|
|
10281
|
+
return resolve10(toGitCwd(cwd));
|
|
10282
|
+
}
|
|
10279
10283
|
function resolveWithinCwd(cwd, path71) {
|
|
10280
|
-
const root =
|
|
10284
|
+
const root = repoRoot(cwd);
|
|
10281
10285
|
const target = resolve10(root, path71);
|
|
10282
10286
|
const rel = relative2(root, target);
|
|
10283
10287
|
if (rel === "" || rel.startsWith("..") || isAbsolute2(rel)) return null;
|
|
10284
10288
|
return target;
|
|
10285
10289
|
}
|
|
10286
|
-
|
|
10290
|
+
|
|
10291
|
+
// src/commands/sessions/web/getFileTarget.ts
|
|
10292
|
+
function getFileTarget(req, res) {
|
|
10287
10293
|
const cwd = getCwdParam(req, res);
|
|
10288
|
-
if (!cwd) return;
|
|
10294
|
+
if (!cwd) return null;
|
|
10289
10295
|
const path71 = new URL(req.url ?? "/", "http://localhost").searchParams.get(
|
|
10290
10296
|
"path"
|
|
10291
10297
|
);
|
|
10292
10298
|
if (!path71) {
|
|
10293
10299
|
respondJson(res, 400, { error: "Missing path" });
|
|
10294
|
-
return;
|
|
10300
|
+
return null;
|
|
10295
10301
|
}
|
|
10296
10302
|
const target = resolveWithinCwd(cwd, path71);
|
|
10297
10303
|
if (!target) {
|
|
10298
10304
|
respondJson(res, 400, { error: "Path outside cwd" });
|
|
10299
|
-
return;
|
|
10305
|
+
return null;
|
|
10300
10306
|
}
|
|
10307
|
+
return { cwd, target };
|
|
10308
|
+
}
|
|
10309
|
+
|
|
10310
|
+
// src/commands/sessions/web/fileContent.ts
|
|
10311
|
+
var MAX_FILE_BYTES = 2 * 1024 * 1024;
|
|
10312
|
+
async function fileContent(req, res) {
|
|
10313
|
+
const resolved = getFileTarget(req, res);
|
|
10314
|
+
if (!resolved) return;
|
|
10301
10315
|
try {
|
|
10302
|
-
const info = await stat2(target);
|
|
10316
|
+
const info = await stat2(resolved.target);
|
|
10303
10317
|
if (!info.isFile()) {
|
|
10304
10318
|
respondJson(res, 404, { error: "File not found" });
|
|
10305
10319
|
return;
|
|
@@ -10308,7 +10322,7 @@ async function fileContent(req, res) {
|
|
|
10308
10322
|
respondJson(res, 413, { error: "File too large" });
|
|
10309
10323
|
return;
|
|
10310
10324
|
}
|
|
10311
|
-
respondJson(res, 200, { content: await readFile(target, "utf8") });
|
|
10325
|
+
respondJson(res, 200, { content: await readFile(resolved.target, "utf8") });
|
|
10312
10326
|
} catch {
|
|
10313
10327
|
respondJson(res, 404, { error: "File not found" });
|
|
10314
10328
|
}
|
|
@@ -10647,7 +10661,7 @@ function runGit(cwd, args) {
|
|
|
10647
10661
|
}).then((r) => r.stdout.trim());
|
|
10648
10662
|
}
|
|
10649
10663
|
async function resolveSynthesisPath(cwd) {
|
|
10650
|
-
const [
|
|
10664
|
+
const [repoRoot2, branch2] = await Promise.all([
|
|
10651
10665
|
runGit(cwd, ["rev-parse", "--show-toplevel"]),
|
|
10652
10666
|
runGit(cwd, ["rev-parse", "--abbrev-ref", "HEAD"])
|
|
10653
10667
|
]);
|
|
@@ -10655,7 +10669,7 @@ async function resolveSynthesisPath(cwd) {
|
|
|
10655
10669
|
homedir13(),
|
|
10656
10670
|
".assist",
|
|
10657
10671
|
"reviews",
|
|
10658
|
-
basename8(
|
|
10672
|
+
basename8(repoRoot2)
|
|
10659
10673
|
);
|
|
10660
10674
|
return findSynthesisForBranch(repoReviewsDir, branch2);
|
|
10661
10675
|
}
|
|
@@ -12063,6 +12077,65 @@ async function uploadPrImage(req, res) {
|
|
|
12063
12077
|
}
|
|
12064
12078
|
}
|
|
12065
12079
|
|
|
12080
|
+
// src/commands/sessions/web/writeFileContent.ts
|
|
12081
|
+
import { readFile as readFile2, writeFile as writeFile3 } from "fs/promises";
|
|
12082
|
+
|
|
12083
|
+
// src/commands/sessions/web/formatWithOxfmt.ts
|
|
12084
|
+
import { execFile as execFile8 } from "child_process";
|
|
12085
|
+
import { existsSync as existsSync30 } from "fs";
|
|
12086
|
+
import { dirname as dirname22, join as join30 } from "path";
|
|
12087
|
+
import { promisify as promisify8 } from "util";
|
|
12088
|
+
var execFileAsync7 = promisify8(execFile8);
|
|
12089
|
+
var TIMEOUT_MS = 15e3;
|
|
12090
|
+
function findOxfmtScript(root) {
|
|
12091
|
+
let dir = root;
|
|
12092
|
+
for (; ; ) {
|
|
12093
|
+
const candidate = join30(dir, "node_modules", "oxfmt", "bin", "oxfmt");
|
|
12094
|
+
if (existsSync30(candidate)) return candidate;
|
|
12095
|
+
const parent = dirname22(dir);
|
|
12096
|
+
if (parent === dir) return void 0;
|
|
12097
|
+
dir = parent;
|
|
12098
|
+
}
|
|
12099
|
+
}
|
|
12100
|
+
async function formatWithOxfmt(target, root) {
|
|
12101
|
+
const script = findOxfmtScript(root);
|
|
12102
|
+
if (!script) return;
|
|
12103
|
+
await execFileAsync7(process.execPath, [script, target], {
|
|
12104
|
+
cwd: root,
|
|
12105
|
+
windowsHide: true,
|
|
12106
|
+
timeout: TIMEOUT_MS
|
|
12107
|
+
}).catch(() => {
|
|
12108
|
+
});
|
|
12109
|
+
}
|
|
12110
|
+
|
|
12111
|
+
// src/commands/sessions/web/writeFileContent.ts
|
|
12112
|
+
async function writeFileContent(req, res) {
|
|
12113
|
+
const resolved = getFileTarget(req, res);
|
|
12114
|
+
if (!resolved) return;
|
|
12115
|
+
let body;
|
|
12116
|
+
try {
|
|
12117
|
+
body = await readJsonBody(req);
|
|
12118
|
+
} catch {
|
|
12119
|
+
respondJson(res, 400, { error: "Invalid JSON body" });
|
|
12120
|
+
return;
|
|
12121
|
+
}
|
|
12122
|
+
if (typeof body.content !== "string") {
|
|
12123
|
+
respondJson(res, 400, { error: "Missing content" });
|
|
12124
|
+
return;
|
|
12125
|
+
}
|
|
12126
|
+
try {
|
|
12127
|
+
await writeFile3(resolved.target, body.content, "utf8");
|
|
12128
|
+
await formatWithOxfmt(resolved.target, repoRoot(resolved.cwd));
|
|
12129
|
+
respondJson(res, 200, {
|
|
12130
|
+
content: await readFile2(resolved.target, "utf8")
|
|
12131
|
+
});
|
|
12132
|
+
} catch (error) {
|
|
12133
|
+
respondJson(res, 500, {
|
|
12134
|
+
error: error instanceof Error ? error.message : "Failed to write file"
|
|
12135
|
+
});
|
|
12136
|
+
}
|
|
12137
|
+
}
|
|
12138
|
+
|
|
12066
12139
|
// src/commands/sessions/web/createCssHandler.ts
|
|
12067
12140
|
import { createHash as createHash2 } from "crypto";
|
|
12068
12141
|
import { readFileSync as readFileSync22 } from "fs";
|
|
@@ -12125,6 +12198,7 @@ var routes2 = {
|
|
|
12125
12198
|
"GET /api/diff": diff2,
|
|
12126
12199
|
"GET /api/diff-scopes": diffScopes,
|
|
12127
12200
|
"GET /api/file": fileContent,
|
|
12201
|
+
"POST /api/file": writeFileContent,
|
|
12128
12202
|
"GET /api/files": listFiles,
|
|
12129
12203
|
"GET /api/jira-site": jiraSite,
|
|
12130
12204
|
"GET /api/harness": harnessCapabilities,
|
|
@@ -12755,7 +12829,7 @@ function registerAssociateJiraCommand(cmd) {
|
|
|
12755
12829
|
|
|
12756
12830
|
// src/commands/backlog/cloneRepo.ts
|
|
12757
12831
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
12758
|
-
import { existsSync as
|
|
12832
|
+
import { existsSync as existsSync31 } from "fs";
|
|
12759
12833
|
import { mkdir as mkdir3 } from "fs/promises";
|
|
12760
12834
|
import chalk69 from "chalk";
|
|
12761
12835
|
|
|
@@ -12791,7 +12865,7 @@ async function cloneRepo(originRaw) {
|
|
|
12791
12865
|
if (!target) {
|
|
12792
12866
|
return fail2(`Could not derive a repository name from "${origin}".`);
|
|
12793
12867
|
}
|
|
12794
|
-
if (
|
|
12868
|
+
if (existsSync31(target)) {
|
|
12795
12869
|
return fail2(`Clone target already exists: ${target}`);
|
|
12796
12870
|
}
|
|
12797
12871
|
await mkdir3(baseDir, { recursive: true });
|
|
@@ -12902,7 +12976,7 @@ function registerExportCommand(cmd) {
|
|
|
12902
12976
|
}
|
|
12903
12977
|
|
|
12904
12978
|
// src/commands/backlog/import/index.ts
|
|
12905
|
-
import { readFile as
|
|
12979
|
+
import { readFile as readFile3 } from "fs/promises";
|
|
12906
12980
|
import chalk74 from "chalk";
|
|
12907
12981
|
|
|
12908
12982
|
// src/commands/backlog/dump/countCopyRows.ts
|
|
@@ -13079,7 +13153,7 @@ async function restore(client, parsed) {
|
|
|
13079
13153
|
|
|
13080
13154
|
// src/commands/backlog/import/index.ts
|
|
13081
13155
|
async function importBacklog(file, options2 = {}) {
|
|
13082
|
-
const raw = file ? await
|
|
13156
|
+
const raw = file ? await readFile3(file) : await readStdinBuffer();
|
|
13083
13157
|
const parsed = parseDump(raw);
|
|
13084
13158
|
validateDump(parsed);
|
|
13085
13159
|
const { tables } = parsed.header;
|
|
@@ -13216,7 +13290,7 @@ function ensureRemoteOrigin() {
|
|
|
13216
13290
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
13217
13291
|
import { mkdtempSync, readFileSync as readFileSync23, unlinkSync as unlinkSync6, writeFileSync as writeFileSync21 } from "fs";
|
|
13218
13292
|
import { tmpdir as tmpdir2 } from "os";
|
|
13219
|
-
import { join as
|
|
13293
|
+
import { join as join31 } from "path";
|
|
13220
13294
|
import enquirer6 from "enquirer";
|
|
13221
13295
|
async function promptType() {
|
|
13222
13296
|
const { type } = await enquirer6.prompt({
|
|
@@ -13256,8 +13330,8 @@ async function promptDescription() {
|
|
|
13256
13330
|
}
|
|
13257
13331
|
function openEditor() {
|
|
13258
13332
|
const editor = process.env.EDITOR || process.env.VISUAL || "vi";
|
|
13259
|
-
const dir = mkdtempSync(
|
|
13260
|
-
const filePath =
|
|
13333
|
+
const dir = mkdtempSync(join31(tmpdir2(), "assist-"));
|
|
13334
|
+
const filePath = join31(dir, "description.md");
|
|
13261
13335
|
writeFileSync21(filePath, "");
|
|
13262
13336
|
const result = spawnSync3(editor, [filePath], { stdio: "inherit" });
|
|
13263
13337
|
if (result.status !== 0) {
|
|
@@ -15731,16 +15805,16 @@ function extractGraphqlQuery(args) {
|
|
|
15731
15805
|
}
|
|
15732
15806
|
|
|
15733
15807
|
// src/shared/loadCliReads.ts
|
|
15734
|
-
import { existsSync as
|
|
15735
|
-
import { dirname as
|
|
15808
|
+
import { existsSync as existsSync32, readFileSync as readFileSync25, writeFileSync as writeFileSync22 } from "fs";
|
|
15809
|
+
import { dirname as dirname23, resolve as resolve12 } from "path";
|
|
15736
15810
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
15737
15811
|
var __filename3 = fileURLToPath5(import.meta.url);
|
|
15738
|
-
var __dirname4 =
|
|
15812
|
+
var __dirname4 = dirname23(__filename3);
|
|
15739
15813
|
function packageRoot() {
|
|
15740
15814
|
return __dirname4;
|
|
15741
15815
|
}
|
|
15742
15816
|
function readLines(path71) {
|
|
15743
|
-
if (!
|
|
15817
|
+
if (!existsSync32(path71)) return [];
|
|
15744
15818
|
return readFileSync25(path71, "utf8").split("\n").filter((line) => line.trim() !== "");
|
|
15745
15819
|
}
|
|
15746
15820
|
var cachedReads;
|
|
@@ -15787,14 +15861,14 @@ function findCliWrite(command) {
|
|
|
15787
15861
|
}
|
|
15788
15862
|
|
|
15789
15863
|
// src/shared/readSettingsPerms.ts
|
|
15790
|
-
import { existsSync as
|
|
15864
|
+
import { existsSync as existsSync33, readFileSync as readFileSync26 } from "fs";
|
|
15791
15865
|
import { homedir as homedir14 } from "os";
|
|
15792
|
-
import { join as
|
|
15866
|
+
import { join as join32 } from "path";
|
|
15793
15867
|
function readSettingsPerms(key) {
|
|
15794
15868
|
const paths = [
|
|
15795
|
-
|
|
15796
|
-
|
|
15797
|
-
|
|
15869
|
+
join32(homedir14(), ".claude", "settings.json"),
|
|
15870
|
+
join32(process.cwd(), ".claude", "settings.json"),
|
|
15871
|
+
join32(process.cwd(), ".claude", "settings.local.json")
|
|
15798
15872
|
];
|
|
15799
15873
|
const entries = [];
|
|
15800
15874
|
for (const p of paths) {
|
|
@@ -15803,7 +15877,7 @@ function readSettingsPerms(key) {
|
|
|
15803
15877
|
return entries;
|
|
15804
15878
|
}
|
|
15805
15879
|
function readPermissionArray(filePath, key) {
|
|
15806
|
-
if (!
|
|
15880
|
+
if (!existsSync33(filePath)) return [];
|
|
15807
15881
|
try {
|
|
15808
15882
|
const data = JSON.parse(readFileSync26(filePath, "utf8"));
|
|
15809
15883
|
const arr = data?.permissions?.[key];
|
|
@@ -16003,11 +16077,11 @@ function decideCommand(toolName, rawCommand) {
|
|
|
16003
16077
|
// src/commands/cliHook/logDeniedToolCall.ts
|
|
16004
16078
|
import { mkdirSync as mkdirSync12 } from "fs";
|
|
16005
16079
|
import { homedir as homedir15 } from "os";
|
|
16006
|
-
import { join as
|
|
16080
|
+
import { join as join33 } from "path";
|
|
16007
16081
|
import Database from "better-sqlite3";
|
|
16008
16082
|
var _db;
|
|
16009
16083
|
function getDbDir() {
|
|
16010
|
-
return
|
|
16084
|
+
return join33(homedir15(), ".assist");
|
|
16011
16085
|
}
|
|
16012
16086
|
function initSchema(db) {
|
|
16013
16087
|
db.exec(`
|
|
@@ -16026,7 +16100,7 @@ function openPromptsDb(dir) {
|
|
|
16026
16100
|
if (_db) return _db;
|
|
16027
16101
|
const dbDir = dir ?? getDbDir();
|
|
16028
16102
|
mkdirSync12(dbDir, { recursive: true });
|
|
16029
|
-
const db = new Database(
|
|
16103
|
+
const db = new Database(join33(dbDir, "assist.db"));
|
|
16030
16104
|
db.pragma("journal_mode = WAL");
|
|
16031
16105
|
initSchema(db);
|
|
16032
16106
|
_db = db;
|
|
@@ -16122,9 +16196,9 @@ ${reasons.join("\n")}`);
|
|
|
16122
16196
|
}
|
|
16123
16197
|
|
|
16124
16198
|
// src/commands/permitCliReads/index.ts
|
|
16125
|
-
import { existsSync as
|
|
16199
|
+
import { existsSync as existsSync34, mkdirSync as mkdirSync13, readFileSync as readFileSync27, writeFileSync as writeFileSync23 } from "fs";
|
|
16126
16200
|
import { homedir as homedir16 } from "os";
|
|
16127
|
-
import { join as
|
|
16201
|
+
import { join as join34 } from "path";
|
|
16128
16202
|
|
|
16129
16203
|
// src/commands/permitCliReads/assertCliExists.ts
|
|
16130
16204
|
function assertCliExists(cli) {
|
|
@@ -16387,15 +16461,15 @@ function updateSettings(cli, commands) {
|
|
|
16387
16461
|
// src/commands/permitCliReads/index.ts
|
|
16388
16462
|
function logPath(cli) {
|
|
16389
16463
|
const safeName = cli.replace(/\s+/g, "-");
|
|
16390
|
-
return
|
|
16464
|
+
return join34(homedir16(), ".assist", `cli-discover-${safeName}.log`);
|
|
16391
16465
|
}
|
|
16392
16466
|
function readCache(cli) {
|
|
16393
16467
|
const path71 = logPath(cli);
|
|
16394
|
-
if (!
|
|
16468
|
+
if (!existsSync34(path71)) return void 0;
|
|
16395
16469
|
return readFileSync27(path71, "utf8");
|
|
16396
16470
|
}
|
|
16397
16471
|
function writeCache(cli, output) {
|
|
16398
|
-
const dir =
|
|
16472
|
+
const dir = join34(homedir16(), ".assist");
|
|
16399
16473
|
mkdirSync13(dir, { recursive: true });
|
|
16400
16474
|
writeFileSync23(logPath(cli), output);
|
|
16401
16475
|
}
|
|
@@ -16526,22 +16600,22 @@ function registerCliHook(program2) {
|
|
|
16526
16600
|
}
|
|
16527
16601
|
|
|
16528
16602
|
// src/commands/codeComment/codeCommentConfirm.ts
|
|
16529
|
-
import { existsSync as
|
|
16603
|
+
import { existsSync as existsSync36, readFileSync as readFileSync29, unlinkSync as unlinkSync8, writeFileSync as writeFileSync24 } from "fs";
|
|
16530
16604
|
import chalk121 from "chalk";
|
|
16531
16605
|
|
|
16532
16606
|
// src/commands/codeComment/getRestrictedDir.ts
|
|
16533
16607
|
import { homedir as homedir17 } from "os";
|
|
16534
|
-
import { join as
|
|
16608
|
+
import { join as join35 } from "path";
|
|
16535
16609
|
function getRestrictedDir() {
|
|
16536
|
-
return
|
|
16610
|
+
return join35(homedir17(), ".assist", "restricted");
|
|
16537
16611
|
}
|
|
16538
16612
|
function getPinStatePath(pin) {
|
|
16539
|
-
return
|
|
16613
|
+
return join35(getRestrictedDir(), `code-comment-${pin}.json`);
|
|
16540
16614
|
}
|
|
16541
16615
|
|
|
16542
16616
|
// src/commands/codeComment/sweepRestrictedDir.ts
|
|
16543
16617
|
import { readdirSync as readdirSync3, statSync as statSync5, unlinkSync as unlinkSync7 } from "fs";
|
|
16544
|
-
import { join as
|
|
16618
|
+
import { join as join36 } from "path";
|
|
16545
16619
|
var STALE_AFTER_MS = 30 * 60 * 1e3;
|
|
16546
16620
|
function sweepRestrictedDir(dir = getRestrictedDir()) {
|
|
16547
16621
|
let entries;
|
|
@@ -16552,7 +16626,7 @@ function sweepRestrictedDir(dir = getRestrictedDir()) {
|
|
|
16552
16626
|
}
|
|
16553
16627
|
const cutoff = Date.now() - STALE_AFTER_MS;
|
|
16554
16628
|
for (const entry of entries) {
|
|
16555
|
-
const path71 =
|
|
16629
|
+
const path71 = join36(dir, entry);
|
|
16556
16630
|
try {
|
|
16557
16631
|
if (statSync5(path71).mtimeMs < cutoff) unlinkSync7(path71);
|
|
16558
16632
|
} catch {
|
|
@@ -16562,10 +16636,10 @@ function sweepRestrictedDir(dir = getRestrictedDir()) {
|
|
|
16562
16636
|
}
|
|
16563
16637
|
|
|
16564
16638
|
// src/commands/codeComment/readPinState.ts
|
|
16565
|
-
import { existsSync as
|
|
16639
|
+
import { existsSync as existsSync35, readFileSync as readFileSync28 } from "fs";
|
|
16566
16640
|
function readPinState(pin) {
|
|
16567
16641
|
const path71 = getPinStatePath(pin);
|
|
16568
|
-
if (!
|
|
16642
|
+
if (!existsSync35(path71)) return void 0;
|
|
16569
16643
|
try {
|
|
16570
16644
|
const state = JSON.parse(readFileSync28(path71, "utf8"));
|
|
16571
16645
|
if (state.pin !== pin) return void 0;
|
|
@@ -16584,7 +16658,7 @@ function codeCommentConfirm(pin) {
|
|
|
16584
16658
|
process.exitCode = 1;
|
|
16585
16659
|
return;
|
|
16586
16660
|
}
|
|
16587
|
-
if (!
|
|
16661
|
+
if (!existsSync36(state.file)) {
|
|
16588
16662
|
console.error(chalk121.red(`Target file no longer exists: ${state.file}`));
|
|
16589
16663
|
process.exitCode = 1;
|
|
16590
16664
|
return;
|
|
@@ -17641,19 +17715,19 @@ import { unlinkSync as unlinkSync9, writeFileSync as writeFileSync26 } from "fs"
|
|
|
17641
17715
|
import chalk137 from "chalk";
|
|
17642
17716
|
|
|
17643
17717
|
// src/commands/dbMigration/getMigrationPinPath.ts
|
|
17644
|
-
import { join as
|
|
17718
|
+
import { join as join37 } from "path";
|
|
17645
17719
|
function getMigrationPinPath(pin) {
|
|
17646
|
-
return
|
|
17720
|
+
return join37(getRestrictedDir(), `db-migration-pin-${pin}.json`);
|
|
17647
17721
|
}
|
|
17648
17722
|
function getMigrationApprovalPath(migrationId) {
|
|
17649
|
-
return
|
|
17723
|
+
return join37(getRestrictedDir(), `db-migration-approval-${migrationId}.json`);
|
|
17650
17724
|
}
|
|
17651
17725
|
|
|
17652
17726
|
// src/commands/dbMigration/readMigrationPinState.ts
|
|
17653
|
-
import { existsSync as
|
|
17727
|
+
import { existsSync as existsSync37, readFileSync as readFileSync30 } from "fs";
|
|
17654
17728
|
function readMigrationPinState(pin) {
|
|
17655
17729
|
const path71 = getMigrationPinPath(pin);
|
|
17656
|
-
if (!
|
|
17730
|
+
if (!existsSync37(path71)) return void 0;
|
|
17657
17731
|
try {
|
|
17658
17732
|
const state = JSON.parse(readFileSync30(path71, "utf8"));
|
|
17659
17733
|
if (state.pin !== pin) return void 0;
|
|
@@ -17742,7 +17816,7 @@ function registerDbMigration(parent) {
|
|
|
17742
17816
|
}
|
|
17743
17817
|
|
|
17744
17818
|
// src/commands/deploy/redirect.ts
|
|
17745
|
-
import { existsSync as
|
|
17819
|
+
import { existsSync as existsSync38, readFileSync as readFileSync31, writeFileSync as writeFileSync28 } from "fs";
|
|
17746
17820
|
import chalk139 from "chalk";
|
|
17747
17821
|
var TRAILING_SLASH_SCRIPT = ` <script>
|
|
17748
17822
|
if (!window.location.pathname.endsWith('/')) {
|
|
@@ -17751,7 +17825,7 @@ var TRAILING_SLASH_SCRIPT = ` <script>
|
|
|
17751
17825
|
</script>`;
|
|
17752
17826
|
function redirect() {
|
|
17753
17827
|
const indexPath = "index.html";
|
|
17754
|
-
if (!
|
|
17828
|
+
if (!existsSync38(indexPath)) {
|
|
17755
17829
|
console.log(chalk139.yellow("No index.html found"));
|
|
17756
17830
|
return;
|
|
17757
17831
|
}
|
|
@@ -17784,10 +17858,10 @@ import { basename as basename11 } from "path";
|
|
|
17784
17858
|
|
|
17785
17859
|
// src/commands/devlog/loadBlogSkipDays.ts
|
|
17786
17860
|
import { homedir as homedir18 } from "os";
|
|
17787
|
-
import { join as
|
|
17788
|
-
var BLOG_REPO_ROOT =
|
|
17861
|
+
import { join as join38 } from "path";
|
|
17862
|
+
var BLOG_REPO_ROOT = join38(homedir18(), "git/blog");
|
|
17789
17863
|
function loadBlogSkipDays(repoName) {
|
|
17790
|
-
const config = loadRawYaml(
|
|
17864
|
+
const config = loadRawYaml(join38(BLOG_REPO_ROOT, "assist.yml"));
|
|
17791
17865
|
const devlog = config.devlog;
|
|
17792
17866
|
const skip2 = devlog?.skip;
|
|
17793
17867
|
return new Set(skip2?.[repoName]);
|
|
@@ -17798,15 +17872,15 @@ import { execSync as execSync36 } from "child_process";
|
|
|
17798
17872
|
import chalk140 from "chalk";
|
|
17799
17873
|
|
|
17800
17874
|
// src/shared/getRepoName.ts
|
|
17801
|
-
import { existsSync as
|
|
17802
|
-
import { basename as basename10, join as
|
|
17875
|
+
import { existsSync as existsSync39, readFileSync as readFileSync32 } from "fs";
|
|
17876
|
+
import { basename as basename10, join as join39 } from "path";
|
|
17803
17877
|
function getRepoName() {
|
|
17804
17878
|
const config = loadConfig();
|
|
17805
17879
|
if (config.devlog?.name) {
|
|
17806
17880
|
return config.devlog.name;
|
|
17807
17881
|
}
|
|
17808
|
-
const packageJsonPath =
|
|
17809
|
-
if (
|
|
17882
|
+
const packageJsonPath = join39(process.cwd(), "package.json");
|
|
17883
|
+
if (existsSync39(packageJsonPath)) {
|
|
17810
17884
|
try {
|
|
17811
17885
|
const content = readFileSync32(packageJsonPath, "utf8");
|
|
17812
17886
|
const pkg = JSON.parse(content);
|
|
@@ -17821,8 +17895,8 @@ function getRepoName() {
|
|
|
17821
17895
|
|
|
17822
17896
|
// src/commands/devlog/loadDevlogEntries.ts
|
|
17823
17897
|
import { readdirSync as readdirSync4, readFileSync as readFileSync33 } from "fs";
|
|
17824
|
-
import { join as
|
|
17825
|
-
var DEVLOG_DIR =
|
|
17898
|
+
import { join as join40 } from "path";
|
|
17899
|
+
var DEVLOG_DIR = join40(BLOG_REPO_ROOT, "src/content/devlog");
|
|
17826
17900
|
function extractFrontmatter(content) {
|
|
17827
17901
|
const fm = content.match(/^---\n([\s\S]*?)\n---/);
|
|
17828
17902
|
return fm?.[1] ?? null;
|
|
@@ -17850,7 +17924,7 @@ function readDevlogFiles(callback) {
|
|
|
17850
17924
|
try {
|
|
17851
17925
|
const files = readdirSync4(DEVLOG_DIR).filter((f) => f.endsWith(".md"));
|
|
17852
17926
|
for (const file of files) {
|
|
17853
|
-
const content = readFileSync33(
|
|
17927
|
+
const content = readFileSync33(join40(DEVLOG_DIR, file), "utf8");
|
|
17854
17928
|
const parsed = parseFrontmatter(content, file);
|
|
17855
17929
|
if (parsed) callback(parsed);
|
|
17856
17930
|
}
|
|
@@ -18238,11 +18312,11 @@ function repos(options2) {
|
|
|
18238
18312
|
|
|
18239
18313
|
// src/commands/devlog/skip.ts
|
|
18240
18314
|
import { writeFileSync as writeFileSync29 } from "fs";
|
|
18241
|
-
import { join as
|
|
18315
|
+
import { join as join41 } from "path";
|
|
18242
18316
|
import chalk145 from "chalk";
|
|
18243
18317
|
import { stringify as stringifyYaml3 } from "yaml";
|
|
18244
18318
|
function getBlogConfigPath() {
|
|
18245
|
-
return
|
|
18319
|
+
return join41(BLOG_REPO_ROOT, "assist.yml");
|
|
18246
18320
|
}
|
|
18247
18321
|
function skip(date) {
|
|
18248
18322
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(date)) {
|
|
@@ -18304,7 +18378,7 @@ function registerDevlog(program2) {
|
|
|
18304
18378
|
|
|
18305
18379
|
// src/commands/dotnet/checkBuildLocks.ts
|
|
18306
18380
|
import { closeSync as closeSync3, openSync as openSync3, readdirSync as readdirSync5 } from "fs";
|
|
18307
|
-
import { join as
|
|
18381
|
+
import { join as join42 } from "path";
|
|
18308
18382
|
import chalk147 from "chalk";
|
|
18309
18383
|
var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git", "packages"]);
|
|
18310
18384
|
function isLockedDll(debugDir) {
|
|
@@ -18316,7 +18390,7 @@ function isLockedDll(debugDir) {
|
|
|
18316
18390
|
}
|
|
18317
18391
|
for (const file of files) {
|
|
18318
18392
|
if (!file.toLowerCase().endsWith(".dll")) continue;
|
|
18319
|
-
const dllPath =
|
|
18393
|
+
const dllPath = join42(debugDir, file);
|
|
18320
18394
|
try {
|
|
18321
18395
|
const fd = openSync3(dllPath, "r+");
|
|
18322
18396
|
closeSync3(fd);
|
|
@@ -18334,13 +18408,13 @@ function findFirstLockedDll(dir) {
|
|
|
18334
18408
|
return null;
|
|
18335
18409
|
}
|
|
18336
18410
|
if (entries.includes("bin")) {
|
|
18337
|
-
const locked = isLockedDll(
|
|
18411
|
+
const locked = isLockedDll(join42(dir, "bin", "Debug"));
|
|
18338
18412
|
if (locked) return locked;
|
|
18339
18413
|
}
|
|
18340
18414
|
for (const entry of entries) {
|
|
18341
18415
|
if (SKIP_DIRS.has(entry) || entry === "bin" || entry.startsWith("."))
|
|
18342
18416
|
continue;
|
|
18343
|
-
const found = findFirstLockedDll(
|
|
18417
|
+
const found = findFirstLockedDll(join42(dir, entry));
|
|
18344
18418
|
if (found) return found;
|
|
18345
18419
|
}
|
|
18346
18420
|
return null;
|
|
@@ -18374,9 +18448,9 @@ function getProjectRefs(csprojPath) {
|
|
|
18374
18448
|
}
|
|
18375
18449
|
return refs;
|
|
18376
18450
|
}
|
|
18377
|
-
function buildTree(csprojPath,
|
|
18451
|
+
function buildTree(csprojPath, repoRoot2, visited = /* @__PURE__ */ new Set()) {
|
|
18378
18452
|
const abs = path31.resolve(csprojPath);
|
|
18379
|
-
const rel = path31.relative(
|
|
18453
|
+
const rel = path31.relative(repoRoot2, abs);
|
|
18380
18454
|
const node = { path: abs, relativePath: rel, children: [] };
|
|
18381
18455
|
if (visited.has(abs)) return node;
|
|
18382
18456
|
visited.add(abs);
|
|
@@ -18385,7 +18459,7 @@ function buildTree(csprojPath, repoRoot, visited = /* @__PURE__ */ new Set()) {
|
|
|
18385
18459
|
const childAbs = path31.resolve(dir, ref);
|
|
18386
18460
|
try {
|
|
18387
18461
|
readFileSync34(childAbs);
|
|
18388
|
-
node.children.push(buildTree(childAbs,
|
|
18462
|
+
node.children.push(buildTree(childAbs, repoRoot2, visited));
|
|
18389
18463
|
} catch {
|
|
18390
18464
|
node.children.push({
|
|
18391
18465
|
path: childAbs,
|
|
@@ -18436,17 +18510,17 @@ function findSlnFiles(dir, maxDepth, depth = 0) {
|
|
|
18436
18510
|
}
|
|
18437
18511
|
return results;
|
|
18438
18512
|
}
|
|
18439
|
-
function findContainingSolutions(csprojPath,
|
|
18513
|
+
function findContainingSolutions(csprojPath, repoRoot2) {
|
|
18440
18514
|
const csprojAbs = path32.resolve(csprojPath);
|
|
18441
18515
|
const csprojBasename = path32.basename(csprojAbs);
|
|
18442
|
-
const slnFiles = findSlnFiles(
|
|
18516
|
+
const slnFiles = findSlnFiles(repoRoot2, 3);
|
|
18443
18517
|
const matches = [];
|
|
18444
18518
|
const pattern2 = new RegExp(`[\\\\"/]${escapeRegex(csprojBasename)}"`);
|
|
18445
18519
|
for (const sln of slnFiles) {
|
|
18446
18520
|
try {
|
|
18447
18521
|
const content = readFileSync35(sln, "utf8");
|
|
18448
18522
|
if (pattern2.test(content)) {
|
|
18449
|
-
matches.push(path32.relative(
|
|
18523
|
+
matches.push(path32.relative(repoRoot2, sln));
|
|
18450
18524
|
}
|
|
18451
18525
|
} catch {
|
|
18452
18526
|
}
|
|
@@ -18508,29 +18582,29 @@ function printJson(tree, totalCount, solutions) {
|
|
|
18508
18582
|
}
|
|
18509
18583
|
|
|
18510
18584
|
// src/commands/dotnet/resolveCsproj.ts
|
|
18511
|
-
import { existsSync as
|
|
18585
|
+
import { existsSync as existsSync40 } from "fs";
|
|
18512
18586
|
import path33 from "path";
|
|
18513
18587
|
import chalk149 from "chalk";
|
|
18514
18588
|
function resolveCsproj(csprojPath) {
|
|
18515
18589
|
const resolved = path33.resolve(csprojPath);
|
|
18516
|
-
if (!
|
|
18590
|
+
if (!existsSync40(resolved)) {
|
|
18517
18591
|
console.error(chalk149.red(`File not found: ${resolved}`));
|
|
18518
18592
|
process.exit(1);
|
|
18519
18593
|
}
|
|
18520
|
-
const
|
|
18521
|
-
if (!
|
|
18594
|
+
const repoRoot2 = findRepoRoot(path33.dirname(resolved));
|
|
18595
|
+
if (!repoRoot2) {
|
|
18522
18596
|
console.error(chalk149.red("Could not find git repository root"));
|
|
18523
18597
|
process.exit(1);
|
|
18524
18598
|
}
|
|
18525
|
-
return { resolved, repoRoot };
|
|
18599
|
+
return { resolved, repoRoot: repoRoot2 };
|
|
18526
18600
|
}
|
|
18527
18601
|
|
|
18528
18602
|
// src/commands/dotnet/deps.ts
|
|
18529
18603
|
async function deps(csprojPath, options2) {
|
|
18530
|
-
const { resolved, repoRoot } = resolveCsproj(csprojPath);
|
|
18531
|
-
const tree = buildTree(resolved,
|
|
18604
|
+
const { resolved, repoRoot: repoRoot2 } = resolveCsproj(csprojPath);
|
|
18605
|
+
const tree = buildTree(resolved, repoRoot2);
|
|
18532
18606
|
const totalCount = collectAllDeps(tree).size + 1;
|
|
18533
|
-
const solutions = findContainingSolutions(resolved,
|
|
18607
|
+
const solutions = findContainingSolutions(resolved, repoRoot2);
|
|
18534
18608
|
if (options2.json) {
|
|
18535
18609
|
printJson(tree, totalCount, solutions);
|
|
18536
18610
|
} else {
|
|
@@ -18571,8 +18645,8 @@ function getChangedCsFiles(scope) {
|
|
|
18571
18645
|
// src/commands/dotnet/inSln.ts
|
|
18572
18646
|
import chalk150 from "chalk";
|
|
18573
18647
|
async function inSln(csprojPath) {
|
|
18574
|
-
const { resolved, repoRoot } = resolveCsproj(csprojPath);
|
|
18575
|
-
const solutions = findContainingSolutions(resolved,
|
|
18648
|
+
const { resolved, repoRoot: repoRoot2 } = resolveCsproj(csprojPath);
|
|
18649
|
+
const solutions = findContainingSolutions(resolved, repoRoot2);
|
|
18576
18650
|
if (solutions.length === 0) {
|
|
18577
18651
|
console.log(chalk150.yellow("Not found in any .sln file"));
|
|
18578
18652
|
process.exit(1);
|
|
@@ -18681,24 +18755,24 @@ function filterIssues(issues, all, cliOnly, cliSuppress) {
|
|
|
18681
18755
|
}
|
|
18682
18756
|
|
|
18683
18757
|
// src/commands/dotnet/resolveSolution.ts
|
|
18684
|
-
import { existsSync as
|
|
18758
|
+
import { existsSync as existsSync41 } from "fs";
|
|
18685
18759
|
import path34 from "path";
|
|
18686
18760
|
import chalk153 from "chalk";
|
|
18687
18761
|
|
|
18688
18762
|
// src/commands/dotnet/findSolution.ts
|
|
18689
18763
|
import { readdirSync as readdirSync7 } from "fs";
|
|
18690
|
-
import { dirname as
|
|
18764
|
+
import { dirname as dirname24, join as join43 } from "path";
|
|
18691
18765
|
import chalk152 from "chalk";
|
|
18692
18766
|
function findSlnInDir(dir) {
|
|
18693
18767
|
try {
|
|
18694
|
-
return readdirSync7(dir).filter((f) => f.endsWith(".sln")).map((f) =>
|
|
18768
|
+
return readdirSync7(dir).filter((f) => f.endsWith(".sln")).map((f) => join43(dir, f));
|
|
18695
18769
|
} catch {
|
|
18696
18770
|
return [];
|
|
18697
18771
|
}
|
|
18698
18772
|
}
|
|
18699
18773
|
function findSolution() {
|
|
18700
|
-
const
|
|
18701
|
-
const ceiling =
|
|
18774
|
+
const repoRoot2 = findRepoRoot(process.cwd());
|
|
18775
|
+
const ceiling = repoRoot2 ?? process.cwd();
|
|
18702
18776
|
let current = process.cwd();
|
|
18703
18777
|
while (true) {
|
|
18704
18778
|
const slnFiles = findSlnInDir(current);
|
|
@@ -18712,7 +18786,7 @@ function findSolution() {
|
|
|
18712
18786
|
process.exit(1);
|
|
18713
18787
|
}
|
|
18714
18788
|
if (current === ceiling) break;
|
|
18715
|
-
current =
|
|
18789
|
+
current = dirname24(current);
|
|
18716
18790
|
}
|
|
18717
18791
|
console.error(chalk152.red("No .sln file found between cwd and repo root"));
|
|
18718
18792
|
process.exit(1);
|
|
@@ -18722,7 +18796,7 @@ function findSolution() {
|
|
|
18722
18796
|
function resolveSolution(sln) {
|
|
18723
18797
|
if (sln) {
|
|
18724
18798
|
const resolved = path34.resolve(sln);
|
|
18725
|
-
if (!
|
|
18799
|
+
if (!existsSync41(resolved)) {
|
|
18726
18800
|
console.error(chalk153.red(`Solution file not found: ${resolved}`));
|
|
18727
18801
|
process.exit(1);
|
|
18728
18802
|
}
|
|
@@ -18762,7 +18836,7 @@ function parseInspectReport(json) {
|
|
|
18762
18836
|
|
|
18763
18837
|
// src/commands/dotnet/runInspectCode.ts
|
|
18764
18838
|
import { execSync as execSync40 } from "child_process";
|
|
18765
|
-
import { existsSync as
|
|
18839
|
+
import { existsSync as existsSync42, readFileSync as readFileSync36, unlinkSync as unlinkSync10 } from "fs";
|
|
18766
18840
|
import { tmpdir as tmpdir4 } from "os";
|
|
18767
18841
|
import path35 from "path";
|
|
18768
18842
|
import chalk154 from "chalk";
|
|
@@ -18793,7 +18867,7 @@ function runInspectCode(slnPath, include, swea) {
|
|
|
18793
18867
|
console.error(chalk154.red("jb inspectcode failed"));
|
|
18794
18868
|
process.exit(1);
|
|
18795
18869
|
}
|
|
18796
|
-
if (!
|
|
18870
|
+
if (!existsSync42(reportPath)) {
|
|
18797
18871
|
console.error(chalk154.red("Report file not generated"));
|
|
18798
18872
|
process.exit(1);
|
|
18799
18873
|
}
|
|
@@ -19050,11 +19124,11 @@ function decideCommentGuard(input, existingContent) {
|
|
|
19050
19124
|
}
|
|
19051
19125
|
|
|
19052
19126
|
// src/commands/dbMigration/consumeMigrationApproval.ts
|
|
19053
|
-
import { existsSync as
|
|
19127
|
+
import { existsSync as existsSync43, unlinkSync as unlinkSync11 } from "fs";
|
|
19054
19128
|
function consumeMigrationApproval(migrationId) {
|
|
19055
19129
|
sweepRestrictedDir();
|
|
19056
19130
|
const path71 = getMigrationApprovalPath(migrationId);
|
|
19057
|
-
if (!
|
|
19131
|
+
if (!existsSync43(path71)) return false;
|
|
19058
19132
|
try {
|
|
19059
19133
|
unlinkSync11(path71);
|
|
19060
19134
|
return true;
|
|
@@ -19174,7 +19248,7 @@ function aggregateCommitters(authorLists) {
|
|
|
19174
19248
|
import { spawnSync as spawnSync4 } from "child_process";
|
|
19175
19249
|
import { unlinkSync as unlinkSync12, writeFileSync as writeFileSync30 } from "fs";
|
|
19176
19250
|
import { tmpdir as tmpdir5 } from "os";
|
|
19177
|
-
import { join as
|
|
19251
|
+
import { join as join44 } from "path";
|
|
19178
19252
|
function buildArgs2(queryFile, vars) {
|
|
19179
19253
|
const args = ["api", "graphql", "-F", `query=@${queryFile}`];
|
|
19180
19254
|
for (const [key, value] of Object.entries(vars)) {
|
|
@@ -19199,7 +19273,7 @@ function throwOnGraphqlErrors(stdout) {
|
|
|
19199
19273
|
throw new Error(messages || "GraphQL request returned errors");
|
|
19200
19274
|
}
|
|
19201
19275
|
function runGhGraphql(mutation, vars) {
|
|
19202
|
-
const queryFile =
|
|
19276
|
+
const queryFile = join44(tmpdir5(), `gh-query-${Date.now()}.graphql`);
|
|
19203
19277
|
writeFileSync30(queryFile, mutation);
|
|
19204
19278
|
try {
|
|
19205
19279
|
const result = spawnSync4("gh", buildArgs2(queryFile, vars), {
|
|
@@ -19387,24 +19461,24 @@ async function countPendingHandovers(orm, origin) {
|
|
|
19387
19461
|
|
|
19388
19462
|
// src/commands/handover/migrateDiskHandovers.ts
|
|
19389
19463
|
import {
|
|
19390
|
-
existsSync as
|
|
19464
|
+
existsSync as existsSync44,
|
|
19391
19465
|
readdirSync as readdirSync8,
|
|
19392
19466
|
readFileSync as readFileSync37,
|
|
19393
19467
|
rmSync as rmSync3,
|
|
19394
19468
|
statSync as statSync7
|
|
19395
19469
|
} from "fs";
|
|
19396
|
-
import { basename as basename12, join as
|
|
19470
|
+
import { basename as basename12, join as join47 } from "path";
|
|
19397
19471
|
|
|
19398
19472
|
// src/commands/handover/getHandoverPath.ts
|
|
19399
|
-
import { join as
|
|
19473
|
+
import { join as join45 } from "path";
|
|
19400
19474
|
function getHandoverPath(cwd = process.cwd()) {
|
|
19401
|
-
return
|
|
19475
|
+
return join45(cwd, ".assist", "HANDOVER.md");
|
|
19402
19476
|
}
|
|
19403
19477
|
|
|
19404
19478
|
// src/commands/handover/getHandoversDir.ts
|
|
19405
|
-
import { join as
|
|
19479
|
+
import { join as join46 } from "path";
|
|
19406
19480
|
function getHandoversDir(cwd = process.cwd()) {
|
|
19407
|
-
return
|
|
19481
|
+
return join46(cwd, ".assist", "handovers");
|
|
19408
19482
|
}
|
|
19409
19483
|
|
|
19410
19484
|
// src/commands/handover/parseArchiveTimestamp.ts
|
|
@@ -19442,10 +19516,10 @@ function summariseHandoverContent(content) {
|
|
|
19442
19516
|
|
|
19443
19517
|
// src/commands/handover/migrateDiskHandovers.ts
|
|
19444
19518
|
function collectMarkdown(dir) {
|
|
19445
|
-
if (!
|
|
19519
|
+
if (!existsSync44(dir)) return [];
|
|
19446
19520
|
const out = [];
|
|
19447
19521
|
for (const entry of readdirSync8(dir, { withFileTypes: true })) {
|
|
19448
|
-
const full =
|
|
19522
|
+
const full = join47(dir, entry.name);
|
|
19449
19523
|
if (entry.isDirectory()) out.push(...collectMarkdown(full));
|
|
19450
19524
|
else if (entry.isFile() && entry.name.endsWith(".md")) out.push(full);
|
|
19451
19525
|
}
|
|
@@ -19469,7 +19543,7 @@ async function migrateDiskHandovers(orm, origin, cwd = process.cwd()) {
|
|
|
19469
19543
|
migrated++;
|
|
19470
19544
|
}
|
|
19471
19545
|
const handoverPath = getHandoverPath(cwd);
|
|
19472
|
-
if (
|
|
19546
|
+
if (existsSync44(handoverPath)) {
|
|
19473
19547
|
await migrateFile(orm, origin, handoverPath, statSync7(handoverPath).mtime);
|
|
19474
19548
|
migrated++;
|
|
19475
19549
|
}
|
|
@@ -19815,18 +19889,18 @@ function recentDaemonLogLines() {
|
|
|
19815
19889
|
}
|
|
19816
19890
|
|
|
19817
19891
|
// src/commands/sessions/daemon/worktree/createWorktree.ts
|
|
19818
|
-
import { existsSync as
|
|
19819
|
-
import { basename as basename14, dirname as
|
|
19892
|
+
import { existsSync as existsSync45 } from "fs";
|
|
19893
|
+
import { basename as basename14, dirname as dirname25 } from "path";
|
|
19820
19894
|
|
|
19821
19895
|
// src/commands/sessions/daemon/worktree/planAllocation.ts
|
|
19822
|
-
import { basename as basename13, join as
|
|
19896
|
+
import { basename as basename13, join as join48 } from "path";
|
|
19823
19897
|
function planAllocation(clone, boundTreeRoots2) {
|
|
19824
19898
|
return boundTreeRoots2.has(clone) ? "spill" : "primary";
|
|
19825
19899
|
}
|
|
19826
19900
|
function nextWorktreePath(clone, base, isTaken) {
|
|
19827
19901
|
const name = basename13(clone);
|
|
19828
19902
|
for (let n = 2; n < 1e3; n++) {
|
|
19829
|
-
const candidate =
|
|
19903
|
+
const candidate = join48(base, `${name}-${n}`);
|
|
19830
19904
|
if (!isTaken(candidate)) return candidate;
|
|
19831
19905
|
}
|
|
19832
19906
|
throw new Error(`no free worktree suffix for ${clone}`);
|
|
@@ -19859,13 +19933,13 @@ function cloneHead(clone) {
|
|
|
19859
19933
|
|
|
19860
19934
|
// src/commands/sessions/daemon/worktree/createWorktree.ts
|
|
19861
19935
|
function createWorktree(clone, strategy, boundTreeRoots2) {
|
|
19862
|
-
const base = strategy.root ? expandTilde2(strategy.root) :
|
|
19936
|
+
const base = strategy.root ? expandTilde2(strategy.root) : dirname25(clone);
|
|
19863
19937
|
const registered = new Set(listWorktreePaths(clone));
|
|
19864
19938
|
const branches = new Set(listLocalBranches(clone));
|
|
19865
19939
|
const path71 = nextWorktreePath(
|
|
19866
19940
|
clone,
|
|
19867
19941
|
base,
|
|
19868
|
-
(candidate) => registered.has(candidate) ||
|
|
19942
|
+
(candidate) => registered.has(candidate) || existsSync45(candidate) || boundTreeRoots2.has(candidate) || branches.has(basename14(candidate))
|
|
19869
19943
|
);
|
|
19870
19944
|
const start3 = worktreeStartPoint(clone, strategy.trunk);
|
|
19871
19945
|
gitSync(clone, [
|
|
@@ -19885,7 +19959,7 @@ function createWorktree(clone, strategy, boundTreeRoots2) {
|
|
|
19885
19959
|
}
|
|
19886
19960
|
|
|
19887
19961
|
// src/commands/sessions/daemon/worktree/treeDurability.ts
|
|
19888
|
-
import { existsSync as
|
|
19962
|
+
import { existsSync as existsSync46 } from "fs";
|
|
19889
19963
|
var treeIsGone = { durable: true, gone: true };
|
|
19890
19964
|
function treeDurability(state) {
|
|
19891
19965
|
if (state.dirty) return { durable: false, reason: "uncommitted changes" };
|
|
@@ -19916,14 +19990,14 @@ function* durabilityProbes() {
|
|
|
19916
19990
|
});
|
|
19917
19991
|
}
|
|
19918
19992
|
async function checkDurability(cwd) {
|
|
19919
|
-
if (!
|
|
19993
|
+
if (!existsSync46(cwd)) return treeIsGone;
|
|
19920
19994
|
const probes = durabilityProbes();
|
|
19921
19995
|
let step2 = probes.next();
|
|
19922
19996
|
while (!step2.done) step2 = probes.next(await gitResult(cwd, step2.value));
|
|
19923
19997
|
return step2.value;
|
|
19924
19998
|
}
|
|
19925
19999
|
function checkDurabilitySync(cwd) {
|
|
19926
|
-
if (!
|
|
20000
|
+
if (!existsSync46(cwd)) return treeIsGone;
|
|
19927
20001
|
const probes = durabilityProbes();
|
|
19928
20002
|
let step2 = probes.next();
|
|
19929
20003
|
while (!step2.done) step2 = probes.next(gitSyncResult(cwd, step2.value));
|
|
@@ -19973,11 +20047,11 @@ function allocateTree(requestedCwd, boundTreeRoots2, options2 = {}) {
|
|
|
19973
20047
|
if (!requestedCwd)
|
|
19974
20048
|
return { cwd: requestedCwd, kind: "primary", created: false };
|
|
19975
20049
|
if (options2.inPlace === true) return keptInPlace(requestedCwd);
|
|
19976
|
-
const
|
|
19977
|
-
const cfg = worktreeConfigFor(
|
|
20050
|
+
const repoRoot2 = findRepoRoot(requestedCwd) ?? requestedCwd;
|
|
20051
|
+
const cfg = worktreeConfigFor(repoRoot2);
|
|
19978
20052
|
if (!cfg.enabled)
|
|
19979
20053
|
return { cwd: requestedCwd, kind: "primary", created: false };
|
|
19980
|
-
const clone = mainWorktree(
|
|
20054
|
+
const clone = mainWorktree(repoRoot2) ?? repoRoot2;
|
|
19981
20055
|
const reuse = { ...options2, includeDrafts: cfg.includeDrafts };
|
|
19982
20056
|
if (mustLeaveTrunk(cfg.trunk, options2))
|
|
19983
20057
|
daemonLog(
|
|
@@ -20133,30 +20207,30 @@ function persistedTreeRoots() {
|
|
|
20133
20207
|
}
|
|
20134
20208
|
|
|
20135
20209
|
// src/commands/sessions/daemon/worktree/seedWorktree.ts
|
|
20136
|
-
import { copyFileSync, existsSync as
|
|
20137
|
-
import { dirname as
|
|
20210
|
+
import { copyFileSync, existsSync as existsSync48, mkdirSync as mkdirSync16 } from "fs";
|
|
20211
|
+
import { dirname as dirname26, join as join50 } from "path";
|
|
20138
20212
|
|
|
20139
20213
|
// src/commands/sessions/daemon/worktree/runInstall.ts
|
|
20140
20214
|
import { spawn as spawn5 } from "child_process";
|
|
20141
20215
|
|
|
20142
20216
|
// src/commands/sessions/daemon/worktree/resolveInstallCommand.ts
|
|
20143
|
-
import { existsSync as
|
|
20144
|
-
import { join as
|
|
20145
|
-
function detectInstallCommand(
|
|
20146
|
-
if (!
|
|
20147
|
-
if (
|
|
20148
|
-
if (
|
|
20149
|
-
if (
|
|
20217
|
+
import { existsSync as existsSync47 } from "fs";
|
|
20218
|
+
import { join as join49 } from "path";
|
|
20219
|
+
function detectInstallCommand(repoRoot2) {
|
|
20220
|
+
if (!existsSync47(join49(repoRoot2, "package.json"))) return null;
|
|
20221
|
+
if (existsSync47(join49(repoRoot2, "pnpm-lock.yaml"))) return "pnpm install";
|
|
20222
|
+
if (existsSync47(join49(repoRoot2, "yarn.lock"))) return "yarn install";
|
|
20223
|
+
if (existsSync47(join49(repoRoot2, "bun.lockb"))) return "bun install";
|
|
20150
20224
|
return "npm install";
|
|
20151
20225
|
}
|
|
20152
|
-
function resolveInstallCommand(
|
|
20226
|
+
function resolveInstallCommand(repoRoot2, install) {
|
|
20153
20227
|
if (install === false) return null;
|
|
20154
20228
|
if (typeof install === "string") return install;
|
|
20155
|
-
return detectInstallCommand(
|
|
20229
|
+
return detectInstallCommand(repoRoot2);
|
|
20156
20230
|
}
|
|
20157
20231
|
|
|
20158
20232
|
// src/commands/sessions/daemon/worktree/stopInstall.ts
|
|
20159
|
-
import { execFile as
|
|
20233
|
+
import { execFile as execFile9 } from "child_process";
|
|
20160
20234
|
var running2 = /* @__PURE__ */ new Map();
|
|
20161
20235
|
function trackInstall(worktreePath, child) {
|
|
20162
20236
|
running2.set(worktreePath, child);
|
|
@@ -20175,7 +20249,7 @@ function stopInstall(worktreePath) {
|
|
|
20175
20249
|
}
|
|
20176
20250
|
function killTree(pid) {
|
|
20177
20251
|
if (process.platform === "win32") {
|
|
20178
|
-
|
|
20252
|
+
execFile9(
|
|
20179
20253
|
"taskkill",
|
|
20180
20254
|
["/T", "/F", "/PID", String(pid)],
|
|
20181
20255
|
{ windowsHide: true },
|
|
@@ -20258,11 +20332,11 @@ function seedWorktree(worktreePath, clone, onSeeded = () => {
|
|
|
20258
20332
|
}
|
|
20259
20333
|
function copyConfigFiles(worktreePath, clone, copy) {
|
|
20260
20334
|
for (const rel of copy) {
|
|
20261
|
-
const src =
|
|
20262
|
-
if (!
|
|
20263
|
-
const dest =
|
|
20335
|
+
const src = join50(clone, rel);
|
|
20336
|
+
if (!existsSync48(src)) continue;
|
|
20337
|
+
const dest = join50(worktreePath, rel);
|
|
20264
20338
|
try {
|
|
20265
|
-
mkdirSync16(
|
|
20339
|
+
mkdirSync16(dirname26(dest), { recursive: true });
|
|
20266
20340
|
copyFileSync(src, dest);
|
|
20267
20341
|
daemonLog(`worktree ${worktreePath} seeded ${rel}`);
|
|
20268
20342
|
} catch (error) {
|
|
@@ -20555,7 +20629,7 @@ function registerMermaid(program2) {
|
|
|
20555
20629
|
// src/commands/netcap/netcap.ts
|
|
20556
20630
|
import { mkdir as mkdir4 } from "fs/promises";
|
|
20557
20631
|
import { createServer as createServer2 } from "http";
|
|
20558
|
-
import { dirname as
|
|
20632
|
+
import { dirname as dirname28 } from "path";
|
|
20559
20633
|
import chalk166 from "chalk";
|
|
20560
20634
|
|
|
20561
20635
|
// src/commands/netcap/corsHeaders.ts
|
|
@@ -20632,17 +20706,17 @@ function createNetcapHandler(options2) {
|
|
|
20632
20706
|
}
|
|
20633
20707
|
|
|
20634
20708
|
// src/commands/netcap/prepareExtensionForLoad.ts
|
|
20635
|
-
import { cp, readFile as
|
|
20709
|
+
import { cp, readFile as readFile4, writeFile as writeFile4 } from "fs/promises";
|
|
20636
20710
|
import { networkInterfaces } from "os";
|
|
20637
|
-
import { join as
|
|
20711
|
+
import { join as join52 } from "path";
|
|
20638
20712
|
import chalk165 from "chalk";
|
|
20639
20713
|
|
|
20640
20714
|
// src/commands/netcap/netcapExtensionDir.ts
|
|
20641
|
-
import { dirname as
|
|
20715
|
+
import { dirname as dirname27, join as join51 } from "path";
|
|
20642
20716
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
20643
|
-
var moduleDir =
|
|
20717
|
+
var moduleDir = dirname27(fileURLToPath6(import.meta.url));
|
|
20644
20718
|
function netcapExtensionDir() {
|
|
20645
|
-
return
|
|
20719
|
+
return join51(moduleDir, "commands", "netcap", "netcap-extension");
|
|
20646
20720
|
}
|
|
20647
20721
|
|
|
20648
20722
|
// src/commands/netcap/prepareExtensionForLoad.ts
|
|
@@ -20657,9 +20731,9 @@ function lanIPv4() {
|
|
|
20657
20731
|
return void 0;
|
|
20658
20732
|
}
|
|
20659
20733
|
async function configureBackground(dir, host, port, filter) {
|
|
20660
|
-
const file =
|
|
20661
|
-
const source = await
|
|
20662
|
-
await
|
|
20734
|
+
const file = join52(dir, "background.js");
|
|
20735
|
+
const source = await readFile4(file, "utf8");
|
|
20736
|
+
await writeFile4(
|
|
20663
20737
|
file,
|
|
20664
20738
|
source.replace(
|
|
20665
20739
|
/const RECEIVER = "[^"]*";/,
|
|
@@ -20697,20 +20771,20 @@ async function prepareExtensionForLoad(port, filter = "") {
|
|
|
20697
20771
|
}
|
|
20698
20772
|
|
|
20699
20773
|
// src/commands/netcap/resolveNetcapOutPath.ts
|
|
20700
|
-
import { isAbsolute as isAbsolute3, join as
|
|
20774
|
+
import { isAbsolute as isAbsolute3, join as join54, resolve as resolve16 } from "path";
|
|
20701
20775
|
|
|
20702
20776
|
// src/commands/netcap/defaultCapturePath.ts
|
|
20703
20777
|
import { homedir as homedir19 } from "os";
|
|
20704
|
-
import { join as
|
|
20778
|
+
import { join as join53 } from "path";
|
|
20705
20779
|
function defaultCapturePath() {
|
|
20706
|
-
return
|
|
20780
|
+
return join53(homedir19(), ".assist", "netcap", "capture.jsonl");
|
|
20707
20781
|
}
|
|
20708
20782
|
|
|
20709
20783
|
// src/commands/netcap/resolveNetcapOutPath.ts
|
|
20710
20784
|
function resolveNetcapOutPath(out) {
|
|
20711
20785
|
if (!out) return defaultCapturePath();
|
|
20712
20786
|
const dir = isAbsolute3(out) ? out : resolve16(process.cwd(), out);
|
|
20713
|
-
return
|
|
20787
|
+
return join54(dir, "capture.jsonl");
|
|
20714
20788
|
}
|
|
20715
20789
|
|
|
20716
20790
|
// src/commands/netcap/netcap.ts
|
|
@@ -20718,7 +20792,7 @@ async function netcap(options2) {
|
|
|
20718
20792
|
const port = Number(options2.port);
|
|
20719
20793
|
const outPath = resolveNetcapOutPath(options2.out);
|
|
20720
20794
|
const filter = options2.filter ?? "";
|
|
20721
|
-
await mkdir4(
|
|
20795
|
+
await mkdir4(dirname28(outPath), { recursive: true });
|
|
20722
20796
|
const extensionPath = await prepareExtensionForLoad(port, filter);
|
|
20723
20797
|
let count8 = 0;
|
|
20724
20798
|
const handler = createNetcapHandler({
|
|
@@ -20757,7 +20831,7 @@ netcap stopped \u2014 captured ${count8} ${count8 === 1 ? "entry" : "entries"} t
|
|
|
20757
20831
|
|
|
20758
20832
|
// src/commands/netcap/netcapExtract.ts
|
|
20759
20833
|
import { writeFileSync as writeFileSync32 } from "fs";
|
|
20760
|
-
import { join as
|
|
20834
|
+
import { join as join55 } from "path";
|
|
20761
20835
|
import chalk167 from "chalk";
|
|
20762
20836
|
|
|
20763
20837
|
// src/commands/netcap/extractPostsFromCapture.ts
|
|
@@ -21202,7 +21276,7 @@ function extractPostsFromCapture(captureFile) {
|
|
|
21202
21276
|
function netcapExtract(file) {
|
|
21203
21277
|
const captureFile = file ?? defaultCapturePath();
|
|
21204
21278
|
const posts = extractPostsFromCapture(captureFile);
|
|
21205
|
-
const outFile =
|
|
21279
|
+
const outFile = join55(captureFile, "..", "posts.json");
|
|
21206
21280
|
writeFileSync32(outFile, `${JSON.stringify(posts, null, 2)}
|
|
21207
21281
|
`);
|
|
21208
21282
|
console.log(
|
|
@@ -21403,7 +21477,9 @@ function getCurrentPrNumber() {
|
|
|
21403
21477
|
}
|
|
21404
21478
|
function getCurrentPr() {
|
|
21405
21479
|
try {
|
|
21406
|
-
return viewCurrentPr(
|
|
21480
|
+
return viewCurrentPr(
|
|
21481
|
+
"number,title,body"
|
|
21482
|
+
);
|
|
21407
21483
|
} catch (error) {
|
|
21408
21484
|
if (error instanceof Error && error.message.includes("no pull requests")) {
|
|
21409
21485
|
console.error("Error: No pull request found for the current branch.");
|
|
@@ -21489,7 +21565,30 @@ function comment2(path71, line, body, startLine) {
|
|
|
21489
21565
|
}
|
|
21490
21566
|
|
|
21491
21567
|
// src/commands/prs/edit.ts
|
|
21568
|
+
import { randomUUID as randomUUID7 } from "crypto";
|
|
21569
|
+
|
|
21570
|
+
// src/commands/prs/appendScreenshots.ts
|
|
21571
|
+
function appendScreenshots(body, screenshots) {
|
|
21572
|
+
if (screenshots.length === 0) return body;
|
|
21573
|
+
return `${body}
|
|
21574
|
+
|
|
21575
|
+
## Screenshots
|
|
21576
|
+
|
|
21577
|
+
${screenshots.join("\n\n")}`;
|
|
21578
|
+
}
|
|
21579
|
+
|
|
21580
|
+
// src/commands/prs/applyEdit.ts
|
|
21492
21581
|
import { execFileSync as execFileSync8 } from "child_process";
|
|
21582
|
+
function applyEdit(number, title, body) {
|
|
21583
|
+
const args = ["pr", "edit", String(number)];
|
|
21584
|
+
if (title) args.push("--title", title);
|
|
21585
|
+
args.push("--body", body);
|
|
21586
|
+
try {
|
|
21587
|
+
execFileSync8("gh", args, { stdio: "inherit" });
|
|
21588
|
+
} catch {
|
|
21589
|
+
process.exit(1);
|
|
21590
|
+
}
|
|
21591
|
+
}
|
|
21493
21592
|
|
|
21494
21593
|
// src/commands/prs/buildPrBody.ts
|
|
21495
21594
|
function jiraBrowseUrl(key) {
|
|
@@ -21664,7 +21763,7 @@ function validatePrContent(title, body) {
|
|
|
21664
21763
|
}
|
|
21665
21764
|
|
|
21666
21765
|
// src/commands/prs/edit.ts
|
|
21667
|
-
function edit(options2) {
|
|
21766
|
+
async function edit(options2) {
|
|
21668
21767
|
const hasResolves = (options2.resolves?.length ?? 0) > 0;
|
|
21669
21768
|
const hasSection = options2.what !== void 0 || options2.why !== void 0 || options2.how !== void 0 || hasResolves;
|
|
21670
21769
|
if (!options2.title && !hasSection) {
|
|
@@ -21673,17 +21772,26 @@ function edit(options2) {
|
|
|
21673
21772
|
);
|
|
21674
21773
|
process.exit(1);
|
|
21675
21774
|
}
|
|
21676
|
-
const { number, body } = getCurrentPr();
|
|
21775
|
+
const { number, title, body } = getCurrentPr();
|
|
21677
21776
|
const newBody = editPrBody(body, options2);
|
|
21678
21777
|
validatePrContent(options2.title ?? "", newBody);
|
|
21679
|
-
const
|
|
21680
|
-
if (
|
|
21681
|
-
|
|
21682
|
-
|
|
21683
|
-
|
|
21684
|
-
|
|
21685
|
-
|
|
21778
|
+
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
21779
|
+
if (process.env.ASSIST_SESSION === "1" && sessionId) {
|
|
21780
|
+
const decision = await awaitPreviewApproval("PR preview", {
|
|
21781
|
+
sessionId,
|
|
21782
|
+
requestId: randomUUID7(),
|
|
21783
|
+
title: options2.title ?? title,
|
|
21784
|
+
body: newBody,
|
|
21785
|
+
prNumber: number
|
|
21786
|
+
});
|
|
21787
|
+
applyEdit(
|
|
21788
|
+
number,
|
|
21789
|
+
options2.title,
|
|
21790
|
+
appendScreenshots(newBody, decision.screenshots ?? [])
|
|
21791
|
+
);
|
|
21792
|
+
return;
|
|
21686
21793
|
}
|
|
21794
|
+
applyEdit(number, options2.title, newBody);
|
|
21687
21795
|
}
|
|
21688
21796
|
|
|
21689
21797
|
// src/commands/prs/fixed.ts
|
|
@@ -21693,17 +21801,17 @@ import { execSync as execSync46 } from "child_process";
|
|
|
21693
21801
|
import { execSync as execSync45 } from "child_process";
|
|
21694
21802
|
import { unlinkSync as unlinkSync14, writeFileSync as writeFileSync33 } from "fs";
|
|
21695
21803
|
import { tmpdir as tmpdir6 } from "os";
|
|
21696
|
-
import { join as
|
|
21804
|
+
import { join as join57 } from "path";
|
|
21697
21805
|
|
|
21698
21806
|
// src/commands/prs/loadCommentsCache.ts
|
|
21699
|
-
import { existsSync as
|
|
21807
|
+
import { existsSync as existsSync49, readFileSync as readFileSync40, unlinkSync as unlinkSync13 } from "fs";
|
|
21700
21808
|
import { parse as parse2 } from "yaml";
|
|
21701
21809
|
|
|
21702
21810
|
// src/commands/prs/commentsCachePath.ts
|
|
21703
21811
|
import { homedir as homedir20 } from "os";
|
|
21704
|
-
import { join as
|
|
21812
|
+
import { join as join56 } from "path";
|
|
21705
21813
|
function commentsCachePath(org, repo, prNumber) {
|
|
21706
|
-
return
|
|
21814
|
+
return join56(
|
|
21707
21815
|
homedir20(),
|
|
21708
21816
|
".assist",
|
|
21709
21817
|
"pr-comments",
|
|
@@ -21716,7 +21824,7 @@ function commentsCachePath(org, repo, prNumber) {
|
|
|
21716
21824
|
// src/commands/prs/loadCommentsCache.ts
|
|
21717
21825
|
function loadCommentsCache(org, repo, prNumber) {
|
|
21718
21826
|
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
21719
|
-
if (!
|
|
21827
|
+
if (!existsSync49(cachePath)) {
|
|
21720
21828
|
return null;
|
|
21721
21829
|
}
|
|
21722
21830
|
const content = readFileSync40(cachePath, "utf8");
|
|
@@ -21724,7 +21832,7 @@ function loadCommentsCache(org, repo, prNumber) {
|
|
|
21724
21832
|
}
|
|
21725
21833
|
function deleteCommentsCache(org, repo, prNumber) {
|
|
21726
21834
|
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
21727
|
-
if (
|
|
21835
|
+
if (existsSync49(cachePath)) {
|
|
21728
21836
|
unlinkSync13(cachePath);
|
|
21729
21837
|
console.log("No more unresolved line comments. Cache dropped.");
|
|
21730
21838
|
}
|
|
@@ -21742,7 +21850,7 @@ function replyToComment(org, repo, prNumber, commentId, message3) {
|
|
|
21742
21850
|
// src/commands/prs/resolveCommentWithReply.ts
|
|
21743
21851
|
function resolveThread(threadId) {
|
|
21744
21852
|
const mutation = `mutation($threadId: ID!) { resolveReviewThread(input: {threadId: $threadId}) { thread { isResolved } } }`;
|
|
21745
|
-
const queryFile =
|
|
21853
|
+
const queryFile = join57(tmpdir6(), `gh-mutation-${Date.now()}.graphql`);
|
|
21746
21854
|
writeFileSync33(queryFile, mutation);
|
|
21747
21855
|
try {
|
|
21748
21856
|
execSync45(
|
|
@@ -21827,10 +21935,10 @@ function fixed(commentId, sha) {
|
|
|
21827
21935
|
import { execSync as execSync47 } from "child_process";
|
|
21828
21936
|
import { unlinkSync as unlinkSync15, writeFileSync as writeFileSync34 } from "fs";
|
|
21829
21937
|
import { tmpdir as tmpdir7 } from "os";
|
|
21830
|
-
import { join as
|
|
21938
|
+
import { join as join58 } from "path";
|
|
21831
21939
|
var THREAD_QUERY = `query($owner: String!, $repo: String!, $prNumber: Int!) { repository(owner: $owner, name: $repo) { pullRequest(number: $prNumber) { reviewThreads(first: 100) { nodes { id isResolved comments(first: 100) { nodes { databaseId } } } } } } }`;
|
|
21832
21940
|
function fetchThreadIds(org, repo, prNumber) {
|
|
21833
|
-
const queryFile =
|
|
21941
|
+
const queryFile = join58(tmpdir7(), `gh-query-${Date.now()}.graphql`);
|
|
21834
21942
|
writeFileSync34(queryFile, THREAD_QUERY);
|
|
21835
21943
|
try {
|
|
21836
21944
|
const result = execSync47(
|
|
@@ -21900,15 +22008,15 @@ function fetchLineComments(org, repo, prNumber, threadInfo) {
|
|
|
21900
22008
|
|
|
21901
22009
|
// src/commands/prs/listComments/updateCommentsCache.ts
|
|
21902
22010
|
import { mkdirSync as mkdirSync18, writeFileSync as writeFileSync35 } from "fs";
|
|
21903
|
-
import { dirname as
|
|
22011
|
+
import { dirname as dirname29 } from "path";
|
|
21904
22012
|
import { stringify } from "yaml";
|
|
21905
22013
|
|
|
21906
22014
|
// src/commands/prs/removeStaleCommentsCaches.ts
|
|
21907
22015
|
import { readdirSync as readdirSync10, unlinkSync as unlinkSync16 } from "fs";
|
|
21908
|
-
import { join as
|
|
22016
|
+
import { join as join59 } from "path";
|
|
21909
22017
|
var STALE_PATTERN = /^pr-\d+-comments\.yaml$/;
|
|
21910
22018
|
function removeStaleCommentsCaches(cwd = process.cwd()) {
|
|
21911
|
-
const dir =
|
|
22019
|
+
const dir = join59(cwd, ".assist");
|
|
21912
22020
|
let entries;
|
|
21913
22021
|
try {
|
|
21914
22022
|
entries = readdirSync10(dir);
|
|
@@ -21916,14 +22024,14 @@ function removeStaleCommentsCaches(cwd = process.cwd()) {
|
|
|
21916
22024
|
return;
|
|
21917
22025
|
}
|
|
21918
22026
|
for (const entry of entries.filter((e) => STALE_PATTERN.test(e))) {
|
|
21919
|
-
unlinkSync16(
|
|
22027
|
+
unlinkSync16(join59(dir, entry));
|
|
21920
22028
|
}
|
|
21921
22029
|
}
|
|
21922
22030
|
|
|
21923
22031
|
// src/commands/prs/listComments/updateCommentsCache.ts
|
|
21924
22032
|
function writeCommentsCache(org, repo, prNumber, comments3) {
|
|
21925
22033
|
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
21926
|
-
mkdirSync18(
|
|
22034
|
+
mkdirSync18(dirname29(cachePath), { recursive: true });
|
|
21927
22035
|
const cacheData = {
|
|
21928
22036
|
prNumber,
|
|
21929
22037
|
fetchedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -22257,17 +22365,7 @@ async function placePr(prNumber, title, body, options2) {
|
|
|
22257
22365
|
}
|
|
22258
22366
|
|
|
22259
22367
|
// src/commands/prs/previewAndPlace.ts
|
|
22260
|
-
import { randomUUID as
|
|
22261
|
-
|
|
22262
|
-
// src/commands/prs/appendScreenshots.ts
|
|
22263
|
-
function appendScreenshots(body, screenshots) {
|
|
22264
|
-
if (screenshots.length === 0) return body;
|
|
22265
|
-
return `${body}
|
|
22266
|
-
|
|
22267
|
-
## Screenshots
|
|
22268
|
-
|
|
22269
|
-
${screenshots.join("\n\n")}`;
|
|
22270
|
-
}
|
|
22368
|
+
import { randomUUID as randomUUID8 } from "crypto";
|
|
22271
22369
|
|
|
22272
22370
|
// src/commands/sessions/shared/requestSession.ts
|
|
22273
22371
|
function parseIncoming(line, type) {
|
|
@@ -22400,7 +22498,7 @@ function warn(reason4) {
|
|
|
22400
22498
|
async function previewAndPlace(args) {
|
|
22401
22499
|
const decision = await awaitPreviewApproval("PR preview", {
|
|
22402
22500
|
sessionId: args.sessionId,
|
|
22403
|
-
requestId:
|
|
22501
|
+
requestId: randomUUID8(),
|
|
22404
22502
|
title: args.title,
|
|
22405
22503
|
body: args.body,
|
|
22406
22504
|
prNumber: args.prNumber
|
|
@@ -24886,21 +24984,21 @@ ${annotateDiffWithLineNumbers(context.diff.trimEnd())}
|
|
|
24886
24984
|
|
|
24887
24985
|
// src/commands/review/buildReviewPaths.ts
|
|
24888
24986
|
import { homedir as homedir21 } from "os";
|
|
24889
|
-
import { basename as basename16, join as
|
|
24890
|
-
function buildReviewPaths(
|
|
24891
|
-
const reviewDir =
|
|
24987
|
+
import { basename as basename16, join as join60 } from "path";
|
|
24988
|
+
function buildReviewPaths(repoRoot2, key) {
|
|
24989
|
+
const reviewDir = join60(
|
|
24892
24990
|
homedir21(),
|
|
24893
24991
|
".assist",
|
|
24894
24992
|
"reviews",
|
|
24895
|
-
basename16(
|
|
24993
|
+
basename16(repoRoot2),
|
|
24896
24994
|
key
|
|
24897
24995
|
);
|
|
24898
24996
|
return {
|
|
24899
24997
|
reviewDir,
|
|
24900
|
-
requestPath:
|
|
24901
|
-
claudePath:
|
|
24902
|
-
codexPath:
|
|
24903
|
-
synthesisPath:
|
|
24998
|
+
requestPath: join60(reviewDir, "request.md"),
|
|
24999
|
+
claudePath: join60(reviewDir, "claude.md"),
|
|
25000
|
+
codexPath: join60(reviewDir, "codex.md"),
|
|
25001
|
+
synthesisPath: join60(reviewDir, "synthesis.md")
|
|
24904
25002
|
};
|
|
24905
25003
|
}
|
|
24906
25004
|
|
|
@@ -25557,10 +25655,10 @@ async function handlePostSynthesis(synthesisPath, prInfo, options2) {
|
|
|
25557
25655
|
}
|
|
25558
25656
|
|
|
25559
25657
|
// src/commands/review/prepareReviewDir.ts
|
|
25560
|
-
import { existsSync as
|
|
25658
|
+
import { existsSync as existsSync50, mkdirSync as mkdirSync19, unlinkSync as unlinkSync17, writeFileSync as writeFileSync36 } from "fs";
|
|
25561
25659
|
function clearReviewFiles(paths) {
|
|
25562
25660
|
for (const path71 of [paths.claudePath, paths.codexPath, paths.synthesisPath]) {
|
|
25563
|
-
if (
|
|
25661
|
+
if (existsSync50(path71)) unlinkSync17(path71);
|
|
25564
25662
|
}
|
|
25565
25663
|
}
|
|
25566
25664
|
function prepareReviewDir(paths, requestBody, force) {
|
|
@@ -25787,7 +25885,7 @@ function printReviewerFailures(results) {
|
|
|
25787
25885
|
}
|
|
25788
25886
|
|
|
25789
25887
|
// src/commands/review/runAndSynthesise.ts
|
|
25790
|
-
import { existsSync as
|
|
25888
|
+
import { existsSync as existsSync52, unlinkSync as unlinkSync19 } from "fs";
|
|
25791
25889
|
|
|
25792
25890
|
// src/commands/review/buildReviewerStdin.ts
|
|
25793
25891
|
var REVIEW_PROMPT = `You are acting as a reviewer for a proposed code change made by another engineer. The full review request \u2014 branch, base, changed files, and unified diff \u2014 is in the request file whose absolute path is given below.
|
|
@@ -26207,7 +26305,7 @@ function resolveClaude(args) {
|
|
|
26207
26305
|
}
|
|
26208
26306
|
|
|
26209
26307
|
// src/commands/review/runCodexReviewer.ts
|
|
26210
|
-
import { existsSync as
|
|
26308
|
+
import { existsSync as existsSync51, unlinkSync as unlinkSync18 } from "fs";
|
|
26211
26309
|
|
|
26212
26310
|
// src/commands/review/parseCodexEvent.ts
|
|
26213
26311
|
function isItemStarted(value) {
|
|
@@ -26259,7 +26357,7 @@ async function runCodexReviewer(spec) {
|
|
|
26259
26357
|
reportReviewerToolUse(spec.name, event, spinner);
|
|
26260
26358
|
}
|
|
26261
26359
|
});
|
|
26262
|
-
if (result.exitCode !== 0 &&
|
|
26360
|
+
if (result.exitCode !== 0 && existsSync51(spec.outputPath)) {
|
|
26263
26361
|
unlinkSync18(spec.outputPath);
|
|
26264
26362
|
}
|
|
26265
26363
|
return finaliseReviewerRun({ ...spec, command }, spinner, result);
|
|
@@ -26405,7 +26503,7 @@ async function runAndSynthesise(args) {
|
|
|
26405
26503
|
console.error("Both reviewers failed; skipping synthesis.");
|
|
26406
26504
|
return { ok: false, failures };
|
|
26407
26505
|
}
|
|
26408
|
-
if (anyFresh &&
|
|
26506
|
+
if (anyFresh && existsSync52(paths.synthesisPath)) {
|
|
26409
26507
|
unlinkSync19(paths.synthesisPath);
|
|
26410
26508
|
}
|
|
26411
26509
|
const synthesisResult = await synthesise(paths, { multi });
|
|
@@ -26471,9 +26569,9 @@ function gatherChangedContext() {
|
|
|
26471
26569
|
);
|
|
26472
26570
|
process.exit(1);
|
|
26473
26571
|
}
|
|
26474
|
-
function setupReviewDir(
|
|
26572
|
+
function setupReviewDir(repoRoot2, context, force) {
|
|
26475
26573
|
const paths = buildReviewPaths(
|
|
26476
|
-
|
|
26574
|
+
repoRoot2,
|
|
26477
26575
|
`${context.branch}-${context.shortSha}`
|
|
26478
26576
|
);
|
|
26479
26577
|
const priorComments = fetchExistingComments();
|
|
@@ -26493,9 +26591,9 @@ function runPostSynthesis(synthesisPath, prInfo, options2) {
|
|
|
26493
26591
|
announce: options2.announce ?? false
|
|
26494
26592
|
});
|
|
26495
26593
|
}
|
|
26496
|
-
async function reviewPr(
|
|
26594
|
+
async function reviewPr(repoRoot2, options2) {
|
|
26497
26595
|
const context = gatherChangedContext();
|
|
26498
|
-
const paths = setupReviewDir(
|
|
26596
|
+
const paths = setupReviewDir(repoRoot2, context, options2.force ?? false);
|
|
26499
26597
|
const synthesisOk = await runReviewPipeline(paths, {
|
|
26500
26598
|
verbose: options2.verbose ?? false
|
|
26501
26599
|
});
|
|
@@ -26506,8 +26604,8 @@ async function reviewPr(repoRoot, options2) {
|
|
|
26506
26604
|
|
|
26507
26605
|
// src/commands/review/review.ts
|
|
26508
26606
|
function resolveRepoRoot() {
|
|
26509
|
-
const
|
|
26510
|
-
if (
|
|
26607
|
+
const repoRoot2 = findRepoRoot(process.cwd());
|
|
26608
|
+
if (repoRoot2) return repoRoot2;
|
|
26511
26609
|
console.error("Error: not inside a git repository.");
|
|
26512
26610
|
process.exit(1);
|
|
26513
26611
|
}
|
|
@@ -27253,27 +27351,27 @@ async function configure() {
|
|
|
27253
27351
|
}
|
|
27254
27352
|
|
|
27255
27353
|
// src/commands/transcript/list.ts
|
|
27256
|
-
import { existsSync as
|
|
27257
|
-
import { join as
|
|
27354
|
+
import { existsSync as existsSync53, readdirSync as readdirSync11, statSync as statSync9 } from "fs";
|
|
27355
|
+
import { join as join61 } from "path";
|
|
27258
27356
|
function list4() {
|
|
27259
27357
|
const { vttDir } = getTranscriptConfig();
|
|
27260
|
-
if (!
|
|
27358
|
+
if (!existsSync53(vttDir)) return;
|
|
27261
27359
|
for (const entry of readdirSync11(vttDir)) {
|
|
27262
27360
|
if (!entry.endsWith(".vtt")) continue;
|
|
27263
|
-
if (statSync9(
|
|
27361
|
+
if (statSync9(join61(vttDir, entry)).isDirectory()) continue;
|
|
27264
27362
|
console.log(entry);
|
|
27265
27363
|
}
|
|
27266
27364
|
}
|
|
27267
27365
|
|
|
27268
27366
|
// src/commands/transcript/move.ts
|
|
27269
27367
|
import {
|
|
27270
|
-
existsSync as
|
|
27368
|
+
existsSync as existsSync54,
|
|
27271
27369
|
mkdirSync as mkdirSync20,
|
|
27272
27370
|
readFileSync as readFileSync43,
|
|
27273
27371
|
renameSync as renameSync2,
|
|
27274
27372
|
writeFileSync as writeFileSync38
|
|
27275
27373
|
} from "fs";
|
|
27276
|
-
import { basename as basename17, join as
|
|
27374
|
+
import { basename as basename17, join as join62 } from "path";
|
|
27277
27375
|
|
|
27278
27376
|
// src/commands/transcript/cleanText.ts
|
|
27279
27377
|
function cleanText(text17) {
|
|
@@ -27486,9 +27584,9 @@ function convertVttToMarkdown(inputPath) {
|
|
|
27486
27584
|
return formatChatLog(messages);
|
|
27487
27585
|
}
|
|
27488
27586
|
function archiveRawVtt(vttDir, sourcePath, filename) {
|
|
27489
|
-
const processedDir =
|
|
27587
|
+
const processedDir = join62(vttDir, "processed");
|
|
27490
27588
|
mkdirSync20(processedDir, { recursive: true });
|
|
27491
|
-
renameSync2(sourcePath,
|
|
27589
|
+
renameSync2(sourcePath, join62(processedDir, filename));
|
|
27492
27590
|
}
|
|
27493
27591
|
function move(file, options2) {
|
|
27494
27592
|
const { date, client } = options2;
|
|
@@ -27498,19 +27596,19 @@ function move(file, options2) {
|
|
|
27498
27596
|
}
|
|
27499
27597
|
const { vttDir, transcriptsDir, summaryDir } = getTranscriptConfig();
|
|
27500
27598
|
const filename = basename17(file);
|
|
27501
|
-
const sourcePath =
|
|
27502
|
-
if (!
|
|
27599
|
+
const sourcePath = join62(vttDir, filename);
|
|
27600
|
+
if (!existsSync54(sourcePath)) {
|
|
27503
27601
|
console.error(`Error: VTT file not found: ${sourcePath}`);
|
|
27504
27602
|
process.exit(1);
|
|
27505
27603
|
}
|
|
27506
27604
|
const base = basename17(filename, ".vtt").replace(/ Transcription$/, "");
|
|
27507
27605
|
const outputName = `${date} ${base}.md`;
|
|
27508
|
-
const formattedDir =
|
|
27606
|
+
const formattedDir = join62(transcriptsDir, client);
|
|
27509
27607
|
mkdirSync20(formattedDir, { recursive: true });
|
|
27510
|
-
const formattedPath =
|
|
27608
|
+
const formattedPath = join62(formattedDir, outputName);
|
|
27511
27609
|
writeFileSync38(formattedPath, convertVttToMarkdown(sourcePath), "utf8");
|
|
27512
27610
|
archiveRawVtt(vttDir, sourcePath, filename);
|
|
27513
|
-
const summaryPath =
|
|
27611
|
+
const summaryPath = join62(summaryDir, client, outputName);
|
|
27514
27612
|
console.log(`Formatted transcript: ${formattedPath}`);
|
|
27515
27613
|
console.log(`Summary target: ${summaryPath}`);
|
|
27516
27614
|
}
|
|
@@ -27592,45 +27690,45 @@ function registerVerify(program2) {
|
|
|
27592
27690
|
|
|
27593
27691
|
// src/commands/voice/devices.ts
|
|
27594
27692
|
import { spawnSync as spawnSync6 } from "child_process";
|
|
27595
|
-
import { join as
|
|
27693
|
+
import { join as join64 } from "path";
|
|
27596
27694
|
|
|
27597
27695
|
// src/commands/voice/shared.ts
|
|
27598
27696
|
import { homedir as homedir22 } from "os";
|
|
27599
|
-
import { dirname as
|
|
27697
|
+
import { dirname as dirname31, join as join63 } from "path";
|
|
27600
27698
|
import { fileURLToPath as fileURLToPath7 } from "url";
|
|
27601
|
-
var __dirname5 =
|
|
27602
|
-
var VOICE_DIR =
|
|
27699
|
+
var __dirname5 = dirname31(fileURLToPath7(import.meta.url));
|
|
27700
|
+
var VOICE_DIR = join63(homedir22(), ".assist", "voice");
|
|
27603
27701
|
var voicePaths = {
|
|
27604
27702
|
dir: VOICE_DIR,
|
|
27605
|
-
pid:
|
|
27606
|
-
log:
|
|
27607
|
-
venv:
|
|
27608
|
-
lock:
|
|
27703
|
+
pid: join63(VOICE_DIR, "voice.pid"),
|
|
27704
|
+
log: join63(VOICE_DIR, "voice.log"),
|
|
27705
|
+
venv: join63(VOICE_DIR, ".venv"),
|
|
27706
|
+
lock: join63(VOICE_DIR, "voice.lock")
|
|
27609
27707
|
};
|
|
27610
27708
|
function getPythonDir() {
|
|
27611
|
-
return
|
|
27709
|
+
return join63(__dirname5, "commands", "voice", "python");
|
|
27612
27710
|
}
|
|
27613
27711
|
function getVenvPython() {
|
|
27614
|
-
return process.platform === "win32" ?
|
|
27712
|
+
return process.platform === "win32" ? join63(voicePaths.venv, "Scripts", "python.exe") : join63(voicePaths.venv, "bin", "python");
|
|
27615
27713
|
}
|
|
27616
27714
|
function getLockDir() {
|
|
27617
27715
|
const config = loadConfig();
|
|
27618
27716
|
return config.voice?.lockDir ?? VOICE_DIR;
|
|
27619
27717
|
}
|
|
27620
27718
|
function getLockFile() {
|
|
27621
|
-
return
|
|
27719
|
+
return join63(getLockDir(), "voice.lock");
|
|
27622
27720
|
}
|
|
27623
27721
|
|
|
27624
27722
|
// src/commands/voice/devices.ts
|
|
27625
27723
|
function devices() {
|
|
27626
|
-
const script =
|
|
27724
|
+
const script = join64(getPythonDir(), "list_devices.py");
|
|
27627
27725
|
spawnSync6(getVenvPython(), [script], { stdio: "inherit" });
|
|
27628
27726
|
}
|
|
27629
27727
|
|
|
27630
27728
|
// src/commands/voice/logs.ts
|
|
27631
|
-
import { existsSync as
|
|
27729
|
+
import { existsSync as existsSync55, readFileSync as readFileSync44 } from "fs";
|
|
27632
27730
|
function logs(options2) {
|
|
27633
|
-
if (!
|
|
27731
|
+
if (!existsSync55(voicePaths.log)) {
|
|
27634
27732
|
console.log("No voice log file found");
|
|
27635
27733
|
return;
|
|
27636
27734
|
}
|
|
@@ -27658,12 +27756,12 @@ function logs(options2) {
|
|
|
27658
27756
|
// src/commands/voice/setup.ts
|
|
27659
27757
|
import { spawnSync as spawnSync7 } from "child_process";
|
|
27660
27758
|
import { mkdirSync as mkdirSync22 } from "fs";
|
|
27661
|
-
import { join as
|
|
27759
|
+
import { join as join66 } from "path";
|
|
27662
27760
|
|
|
27663
27761
|
// src/commands/voice/checkLockFile.ts
|
|
27664
27762
|
import { execSync as execSync59 } from "child_process";
|
|
27665
|
-
import { existsSync as
|
|
27666
|
-
import { join as
|
|
27763
|
+
import { existsSync as existsSync56, mkdirSync as mkdirSync21, readFileSync as readFileSync45, writeFileSync as writeFileSync39 } from "fs";
|
|
27764
|
+
import { join as join65 } from "path";
|
|
27667
27765
|
function isProcessAlive2(pid) {
|
|
27668
27766
|
try {
|
|
27669
27767
|
process.kill(pid, 0);
|
|
@@ -27674,7 +27772,7 @@ function isProcessAlive2(pid) {
|
|
|
27674
27772
|
}
|
|
27675
27773
|
function checkLockFile() {
|
|
27676
27774
|
const lockFile = getLockFile();
|
|
27677
|
-
if (!
|
|
27775
|
+
if (!existsSync56(lockFile)) return;
|
|
27678
27776
|
try {
|
|
27679
27777
|
const lock2 = JSON.parse(readFileSync45(lockFile, "utf8"));
|
|
27680
27778
|
if (lock2.pid && isProcessAlive2(lock2.pid)) {
|
|
@@ -27687,7 +27785,7 @@ function checkLockFile() {
|
|
|
27687
27785
|
}
|
|
27688
27786
|
}
|
|
27689
27787
|
function bootstrapVenv() {
|
|
27690
|
-
if (
|
|
27788
|
+
if (existsSync56(getVenvPython())) return;
|
|
27691
27789
|
console.log("Setting up Python environment...");
|
|
27692
27790
|
const pythonDir = getPythonDir();
|
|
27693
27791
|
execSync59(
|
|
@@ -27700,7 +27798,7 @@ function bootstrapVenv() {
|
|
|
27700
27798
|
}
|
|
27701
27799
|
function writeLockFile(pid) {
|
|
27702
27800
|
const lockFile = getLockFile();
|
|
27703
|
-
mkdirSync21(
|
|
27801
|
+
mkdirSync21(join65(lockFile, ".."), { recursive: true });
|
|
27704
27802
|
writeFileSync39(
|
|
27705
27803
|
lockFile,
|
|
27706
27804
|
JSON.stringify({
|
|
@@ -27716,7 +27814,7 @@ function setup() {
|
|
|
27716
27814
|
mkdirSync22(voicePaths.dir, { recursive: true });
|
|
27717
27815
|
bootstrapVenv();
|
|
27718
27816
|
console.log("\nDownloading models...\n");
|
|
27719
|
-
const script =
|
|
27817
|
+
const script = join66(getPythonDir(), "setup_models.py");
|
|
27720
27818
|
const result = spawnSync7(getVenvPython(), [script], {
|
|
27721
27819
|
stdio: "inherit",
|
|
27722
27820
|
env: { ...process.env, VOICE_LOG_FILE: voicePaths.log }
|
|
@@ -27730,7 +27828,7 @@ function setup() {
|
|
|
27730
27828
|
// src/commands/voice/start.ts
|
|
27731
27829
|
import { spawn as spawn8 } from "child_process";
|
|
27732
27830
|
import { mkdirSync as mkdirSync23, writeFileSync as writeFileSync40 } from "fs";
|
|
27733
|
-
import { join as
|
|
27831
|
+
import { join as join67 } from "path";
|
|
27734
27832
|
|
|
27735
27833
|
// src/commands/voice/buildDaemonEnv.ts
|
|
27736
27834
|
function buildDaemonEnv(options2) {
|
|
@@ -27768,7 +27866,7 @@ function start2(options2) {
|
|
|
27768
27866
|
bootstrapVenv();
|
|
27769
27867
|
const debug = options2.debug || options2.foreground || process.platform === "win32";
|
|
27770
27868
|
const env = buildDaemonEnv({ debug });
|
|
27771
|
-
const script =
|
|
27869
|
+
const script = join67(getPythonDir(), "voice_daemon.py");
|
|
27772
27870
|
const python = getVenvPython();
|
|
27773
27871
|
if (options2.foreground) {
|
|
27774
27872
|
spawnForeground(python, script, env);
|
|
@@ -27778,7 +27876,7 @@ function start2(options2) {
|
|
|
27778
27876
|
}
|
|
27779
27877
|
|
|
27780
27878
|
// src/commands/voice/status.ts
|
|
27781
|
-
import { existsSync as
|
|
27879
|
+
import { existsSync as existsSync57, readFileSync as readFileSync46 } from "fs";
|
|
27782
27880
|
function isProcessAlive3(pid) {
|
|
27783
27881
|
try {
|
|
27784
27882
|
process.kill(pid, 0);
|
|
@@ -27788,12 +27886,12 @@ function isProcessAlive3(pid) {
|
|
|
27788
27886
|
}
|
|
27789
27887
|
}
|
|
27790
27888
|
function readRecentLogs(count8) {
|
|
27791
|
-
if (!
|
|
27889
|
+
if (!existsSync57(voicePaths.log)) return [];
|
|
27792
27890
|
const lines2 = readFileSync46(voicePaths.log, "utf8").trim().split("\n");
|
|
27793
27891
|
return lines2.slice(-count8);
|
|
27794
27892
|
}
|
|
27795
27893
|
function status2() {
|
|
27796
|
-
if (!
|
|
27894
|
+
if (!existsSync57(voicePaths.pid)) {
|
|
27797
27895
|
console.log("Voice daemon: not running (no PID file)");
|
|
27798
27896
|
return;
|
|
27799
27897
|
}
|
|
@@ -27816,9 +27914,9 @@ function status2() {
|
|
|
27816
27914
|
}
|
|
27817
27915
|
|
|
27818
27916
|
// src/commands/voice/stop.ts
|
|
27819
|
-
import { existsSync as
|
|
27917
|
+
import { existsSync as existsSync58, readFileSync as readFileSync47, unlinkSync as unlinkSync20 } from "fs";
|
|
27820
27918
|
function stop2() {
|
|
27821
|
-
if (!
|
|
27919
|
+
if (!existsSync58(voicePaths.pid)) {
|
|
27822
27920
|
console.log("Voice daemon is not running (no PID file)");
|
|
27823
27921
|
return;
|
|
27824
27922
|
}
|
|
@@ -27835,7 +27933,7 @@ function stop2() {
|
|
|
27835
27933
|
}
|
|
27836
27934
|
try {
|
|
27837
27935
|
const lockFile = getLockFile();
|
|
27838
|
-
if (
|
|
27936
|
+
if (existsSync58(lockFile)) unlinkSync20(lockFile);
|
|
27839
27937
|
} catch {
|
|
27840
27938
|
}
|
|
27841
27939
|
console.log("Voice daemon stopped");
|
|
@@ -27854,7 +27952,7 @@ function registerVoice(program2) {
|
|
|
27854
27952
|
}
|
|
27855
27953
|
|
|
27856
27954
|
// src/commands/watch/readBuiltVersion.ts
|
|
27857
|
-
import { join as
|
|
27955
|
+
import { join as join68 } from "path";
|
|
27858
27956
|
|
|
27859
27957
|
// src/commands/watch/resolveUpstream.ts
|
|
27860
27958
|
import { execFileSync as execFileSync10 } from "child_process";
|
|
@@ -27900,7 +27998,7 @@ function resolveUpstream(cwd) {
|
|
|
27900
27998
|
function readBuiltVersion(cwd) {
|
|
27901
27999
|
try {
|
|
27902
28000
|
const root = runGit2(["rev-parse", "--show-toplevel"], cwd);
|
|
27903
|
-
return readPackageJson(
|
|
28001
|
+
return readPackageJson(join68(root, "package.json")).version ?? "unknown";
|
|
27904
28002
|
} catch {
|
|
27905
28003
|
return "unknown";
|
|
27906
28004
|
}
|
|
@@ -28198,7 +28296,7 @@ function resolveParams(params, cliArgs) {
|
|
|
28198
28296
|
}
|
|
28199
28297
|
|
|
28200
28298
|
// src/commands/run/resolveRunCwd.ts
|
|
28201
|
-
import { existsSync as
|
|
28299
|
+
import { existsSync as existsSync59 } from "fs";
|
|
28202
28300
|
import { resolve as resolve17 } from "path";
|
|
28203
28301
|
var MissingRunCwdError = class extends Error {
|
|
28204
28302
|
constructor(runName, cwd) {
|
|
@@ -28211,25 +28309,25 @@ var MissingRunCwdError = class extends Error {
|
|
|
28211
28309
|
function resolveRunCwd(config, baseDir = runConfigBaseDir()) {
|
|
28212
28310
|
if (!config.cwd) return void 0;
|
|
28213
28311
|
const cwd = resolve17(baseDir, config.cwd);
|
|
28214
|
-
if (!
|
|
28312
|
+
if (!existsSync59(cwd)) throw new MissingRunCwdError(config.name, cwd);
|
|
28215
28313
|
return cwd;
|
|
28216
28314
|
}
|
|
28217
28315
|
|
|
28218
28316
|
// src/commands/run/runCommandToCompletion.ts
|
|
28219
28317
|
import { spawn as spawn9 } from "child_process";
|
|
28220
|
-
import { existsSync as
|
|
28318
|
+
import { existsSync as existsSync61 } from "fs";
|
|
28221
28319
|
|
|
28222
28320
|
// src/commands/run/resolveCommand.ts
|
|
28223
28321
|
import { execFileSync as execFileSync11 } from "child_process";
|
|
28224
|
-
import { existsSync as
|
|
28225
|
-
import { dirname as
|
|
28322
|
+
import { existsSync as existsSync60 } from "fs";
|
|
28323
|
+
import { dirname as dirname32, join as join69, resolve as resolve18 } from "path";
|
|
28226
28324
|
function resolveCommand2(command) {
|
|
28227
28325
|
if (process.platform !== "win32" || command !== "bash") return command;
|
|
28228
28326
|
try {
|
|
28229
28327
|
const gitPath = execFileSync11("where", ["git"], { encoding: "utf8" }).trim().split("\r\n")[0];
|
|
28230
|
-
const gitRoot = resolve18(
|
|
28231
|
-
const gitBash =
|
|
28232
|
-
if (
|
|
28328
|
+
const gitRoot = resolve18(dirname32(gitPath), "..");
|
|
28329
|
+
const gitBash = join69(gitRoot, "bin", "bash.exe");
|
|
28330
|
+
if (existsSync60(gitBash)) return gitBash;
|
|
28233
28331
|
} catch {
|
|
28234
28332
|
return command;
|
|
28235
28333
|
}
|
|
@@ -28239,7 +28337,7 @@ function resolveCommand2(command) {
|
|
|
28239
28337
|
// src/commands/run/runCommandToCompletion.ts
|
|
28240
28338
|
function runCommandToCompletion(command, args, env, cwd, quiet) {
|
|
28241
28339
|
return new Promise((resolveResult) => {
|
|
28242
|
-
if (cwd && !
|
|
28340
|
+
if (cwd && !existsSync61(cwd)) {
|
|
28243
28341
|
resolveResult({
|
|
28244
28342
|
kind: "failed",
|
|
28245
28343
|
message: `Failed to execute command: cwd ${cwd} does not exist`
|
|
@@ -28629,7 +28727,7 @@ async function auth() {
|
|
|
28629
28727
|
// src/commands/roam/postRoamActivity.ts
|
|
28630
28728
|
import { execFileSync as execFileSync13 } from "child_process";
|
|
28631
28729
|
import { readdirSync as readdirSync12, readFileSync as readFileSync48, statSync as statSync10 } from "fs";
|
|
28632
|
-
import { join as
|
|
28730
|
+
import { join as join70 } from "path";
|
|
28633
28731
|
function findPortFile(roamDir) {
|
|
28634
28732
|
let entries;
|
|
28635
28733
|
try {
|
|
@@ -28638,7 +28736,7 @@ function findPortFile(roamDir) {
|
|
|
28638
28736
|
return void 0;
|
|
28639
28737
|
}
|
|
28640
28738
|
const candidates = entries.filter((name) => /^roam-local-api(-[^.]+)?\.port$/.test(name)).map((name) => {
|
|
28641
|
-
const path71 =
|
|
28739
|
+
const path71 = join70(roamDir, name);
|
|
28642
28740
|
try {
|
|
28643
28741
|
return { path: path71, mtimeMs: statSync10(path71).mtimeMs };
|
|
28644
28742
|
} catch {
|
|
@@ -28650,7 +28748,7 @@ function findPortFile(roamDir) {
|
|
|
28650
28748
|
function postRoamActivity(app, event) {
|
|
28651
28749
|
const appData = process.env.APPDATA;
|
|
28652
28750
|
if (!appData) return;
|
|
28653
|
-
const portFile = findPortFile(
|
|
28751
|
+
const portFile = findPortFile(join70(appData, "Roam"));
|
|
28654
28752
|
if (!portFile) return;
|
|
28655
28753
|
let port;
|
|
28656
28754
|
try {
|
|
@@ -28783,7 +28881,7 @@ async function run3(name, args) {
|
|
|
28783
28881
|
|
|
28784
28882
|
// src/commands/run/add.ts
|
|
28785
28883
|
import { mkdirSync as mkdirSync24, writeFileSync as writeFileSync41 } from "fs";
|
|
28786
|
-
import { join as
|
|
28884
|
+
import { join as join71 } from "path";
|
|
28787
28885
|
|
|
28788
28886
|
// src/commands/run/extractOption.ts
|
|
28789
28887
|
function extractOption(args, flag) {
|
|
@@ -28844,7 +28942,7 @@ function saveNewRunConfig(name, command, args, cwd) {
|
|
|
28844
28942
|
saveConfig(config);
|
|
28845
28943
|
}
|
|
28846
28944
|
function createCommandFile(name) {
|
|
28847
|
-
const dir =
|
|
28945
|
+
const dir = join71(".claude", "commands");
|
|
28848
28946
|
mkdirSync24(dir, { recursive: true });
|
|
28849
28947
|
const content = `---
|
|
28850
28948
|
description: Run ${name}
|
|
@@ -28852,7 +28950,7 @@ description: Run ${name}
|
|
|
28852
28950
|
|
|
28853
28951
|
Run \`assist run ${name} $ARGUMENTS 2>&1\`.
|
|
28854
28952
|
`;
|
|
28855
|
-
const filePath =
|
|
28953
|
+
const filePath = join71(dir, `${name}.md`);
|
|
28856
28954
|
writeFileSync41(filePath, content);
|
|
28857
28955
|
console.log(`Created command file: ${filePath}`);
|
|
28858
28956
|
}
|
|
@@ -28908,8 +29006,8 @@ function link2() {
|
|
|
28908
29006
|
}
|
|
28909
29007
|
|
|
28910
29008
|
// src/commands/run/remove.ts
|
|
28911
|
-
import { existsSync as
|
|
28912
|
-
import { join as
|
|
29009
|
+
import { existsSync as existsSync62, unlinkSync as unlinkSync21 } from "fs";
|
|
29010
|
+
import { join as join72 } from "path";
|
|
28913
29011
|
function findRemoveIndex() {
|
|
28914
29012
|
const idx = process.argv.indexOf("remove");
|
|
28915
29013
|
if (idx === -1 || idx + 1 >= process.argv.length) return -1;
|
|
@@ -28924,8 +29022,8 @@ function parseRemoveName() {
|
|
|
28924
29022
|
return process.argv[idx + 1];
|
|
28925
29023
|
}
|
|
28926
29024
|
function deleteCommandFile(name) {
|
|
28927
|
-
const filePath =
|
|
28928
|
-
if (
|
|
29025
|
+
const filePath = join72(".claude", "commands", `${name}.md`);
|
|
29026
|
+
if (existsSync62(filePath)) {
|
|
28929
29027
|
unlinkSync21(filePath);
|
|
28930
29028
|
console.log(`Deleted command file: ${filePath}`);
|
|
28931
29029
|
}
|
|
@@ -28970,9 +29068,9 @@ function registerRun(program2) {
|
|
|
28970
29068
|
|
|
28971
29069
|
// src/commands/screenshot/index.ts
|
|
28972
29070
|
import { execSync as execSync61 } from "child_process";
|
|
28973
|
-
import { existsSync as
|
|
29071
|
+
import { existsSync as existsSync63, mkdirSync as mkdirSync25, unlinkSync as unlinkSync22, writeFileSync as writeFileSync42 } from "fs";
|
|
28974
29072
|
import { tmpdir as tmpdir8 } from "os";
|
|
28975
|
-
import { join as
|
|
29073
|
+
import { join as join73, resolve as resolve19 } from "path";
|
|
28976
29074
|
import chalk211 from "chalk";
|
|
28977
29075
|
|
|
28978
29076
|
// src/commands/screenshot/captureWindowPs1.ts
|
|
@@ -29102,14 +29200,14 @@ Write-Output $OutputPath
|
|
|
29102
29200
|
|
|
29103
29201
|
// src/commands/screenshot/index.ts
|
|
29104
29202
|
function buildOutputPath(outputDir, processName) {
|
|
29105
|
-
if (!
|
|
29203
|
+
if (!existsSync63(outputDir)) {
|
|
29106
29204
|
mkdirSync25(outputDir, { recursive: true });
|
|
29107
29205
|
}
|
|
29108
29206
|
const timestamp6 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
29109
29207
|
return resolve19(outputDir, `${processName}-${timestamp6}.png`);
|
|
29110
29208
|
}
|
|
29111
29209
|
function runPowerShellScript(processName, outputPath) {
|
|
29112
|
-
const scriptPath =
|
|
29210
|
+
const scriptPath = join73(tmpdir8(), `assist-screenshot-${Date.now()}.ps1`);
|
|
29113
29211
|
writeFileSync42(scriptPath, captureWindowPs1, "utf8");
|
|
29114
29212
|
try {
|
|
29115
29213
|
execSync61(
|
|
@@ -29555,7 +29653,7 @@ var ClientHub = class extends Set {
|
|
|
29555
29653
|
};
|
|
29556
29654
|
|
|
29557
29655
|
// src/commands/sessions/daemon/createSession.ts
|
|
29558
|
-
import { randomUUID as
|
|
29656
|
+
import { randomUUID as randomUUID9 } from "crypto";
|
|
29559
29657
|
|
|
29560
29658
|
// src/commands/sessions/daemon/resolveRunConfig.ts
|
|
29561
29659
|
function resolveRunConfig(name, cwd) {
|
|
@@ -29591,11 +29689,11 @@ function readDesignSystemPrompt() {
|
|
|
29591
29689
|
}
|
|
29592
29690
|
|
|
29593
29691
|
// src/commands/sessions/daemon/spawnPty.ts
|
|
29594
|
-
import { existsSync as
|
|
29692
|
+
import { existsSync as existsSync65 } from "fs";
|
|
29595
29693
|
import * as pty from "node-pty";
|
|
29596
29694
|
|
|
29597
29695
|
// src/commands/sessions/daemon/ensureSpawnHelperExecutable.ts
|
|
29598
|
-
import { chmodSync, existsSync as
|
|
29696
|
+
import { chmodSync, existsSync as existsSync64, statSync as statSync11 } from "fs";
|
|
29599
29697
|
import { createRequire as createRequire3 } from "module";
|
|
29600
29698
|
import path59 from "path";
|
|
29601
29699
|
var require4 = createRequire3(import.meta.url);
|
|
@@ -29610,7 +29708,7 @@ function ensureSpawnHelperExecutable() {
|
|
|
29610
29708
|
`${process.platform}-${process.arch}`,
|
|
29611
29709
|
"spawn-helper"
|
|
29612
29710
|
);
|
|
29613
|
-
if (!
|
|
29711
|
+
if (!existsSync64(helper)) return;
|
|
29614
29712
|
const mode = statSync11(helper).mode;
|
|
29615
29713
|
if ((mode & 73) === 0) chmodSync(helper, mode | 493);
|
|
29616
29714
|
}
|
|
@@ -29646,7 +29744,7 @@ function spawnPty(args, cwd, sessionId, extraEnv) {
|
|
|
29646
29744
|
});
|
|
29647
29745
|
}
|
|
29648
29746
|
function refuseMissingCwd(cwd, sessionId) {
|
|
29649
|
-
if (!cwd ||
|
|
29747
|
+
if (!cwd || existsSync65(cwd)) return;
|
|
29650
29748
|
daemonLog(
|
|
29651
29749
|
`${sessionId ? `session ${sessionId}` : "pty"} not spawned: working directory ${cwd} no longer exists`
|
|
29652
29750
|
);
|
|
@@ -29711,7 +29809,7 @@ function sessionBase(id, status3) {
|
|
|
29711
29809
|
// src/commands/sessions/daemon/createSession.ts
|
|
29712
29810
|
function createSession(id, prompt, cwd, design, harness, holdPty) {
|
|
29713
29811
|
if (harness === "pi") return createPiSession(id, prompt, cwd, holdPty);
|
|
29714
|
-
const claudeSessionId =
|
|
29812
|
+
const claudeSessionId = randomUUID9();
|
|
29715
29813
|
return {
|
|
29716
29814
|
...sessionBase(id, prompt ? "running" : "waiting"),
|
|
29717
29815
|
name: `Session ${id}`,
|
|
@@ -29769,17 +29867,17 @@ function setStatus2(session, newStatus) {
|
|
|
29769
29867
|
}
|
|
29770
29868
|
|
|
29771
29869
|
// src/commands/sessions/daemon/worktree/reapWorktree.ts
|
|
29772
|
-
import { existsSync as
|
|
29870
|
+
import { existsSync as existsSync67 } from "fs";
|
|
29773
29871
|
import { basename as basename18 } from "path";
|
|
29774
29872
|
|
|
29775
29873
|
// src/commands/sessions/daemon/worktree/deleteStrandedTree.ts
|
|
29776
|
-
import { existsSync as
|
|
29777
|
-
import { join as
|
|
29874
|
+
import { existsSync as existsSync66 } from "fs";
|
|
29875
|
+
import { join as join76 } from "path";
|
|
29778
29876
|
|
|
29779
29877
|
// src/commands/sessions/daemon/worktree/deleteTreeDirectly.ts
|
|
29780
29878
|
import { statSync as statSync12 } from "fs";
|
|
29781
29879
|
import { rm as rm2 } from "fs/promises";
|
|
29782
|
-
import { join as
|
|
29880
|
+
import { join as join75 } from "path";
|
|
29783
29881
|
async function deleteTreeDirectly(clone, worktreePath, why) {
|
|
29784
29882
|
if (holdsAGitDirectoryRatherThanALink(worktreePath)) {
|
|
29785
29883
|
const refusal = "it is a clone of its own, not a linked worktree";
|
|
@@ -29807,7 +29905,7 @@ async function deleteTreeDirectly(clone, worktreePath, why) {
|
|
|
29807
29905
|
return { removed: true };
|
|
29808
29906
|
}
|
|
29809
29907
|
function holdsAGitDirectoryRatherThanALink(worktreePath) {
|
|
29810
|
-
return statSync12(
|
|
29908
|
+
return statSync12(join75(worktreePath, ".git"), {
|
|
29811
29909
|
throwIfNoEntry: false
|
|
29812
29910
|
})?.isDirectory() === true;
|
|
29813
29911
|
}
|
|
@@ -29843,7 +29941,7 @@ async function deleteStrandedTree(clone, worktreePath, cause) {
|
|
|
29843
29941
|
);
|
|
29844
29942
|
}
|
|
29845
29943
|
function strandedReason(worktreePath, cause) {
|
|
29846
|
-
if (!
|
|
29944
|
+
if (!existsSync66(join76(worktreePath, ".git")))
|
|
29847
29945
|
return "its .git link is already gone";
|
|
29848
29946
|
if (/not a working tree|not a git repository/i.test(reason2(cause)))
|
|
29849
29947
|
return "git no longer recognises it as a working tree";
|
|
@@ -29895,7 +29993,7 @@ function reason3(error) {
|
|
|
29895
29993
|
|
|
29896
29994
|
// src/commands/sessions/daemon/worktree/reapWorktree.ts
|
|
29897
29995
|
async function reapWorktree(worktreePath, force = false) {
|
|
29898
|
-
if (!
|
|
29996
|
+
if (!existsSync67(worktreePath)) {
|
|
29899
29997
|
forgetWorktree(worktreePath);
|
|
29900
29998
|
daemonLog(
|
|
29901
29999
|
`worktree ${worktreePath} already gone; its record was forgotten`
|
|
@@ -29920,7 +30018,7 @@ async function reapWorktree(worktreePath, force = false) {
|
|
|
29920
30018
|
}
|
|
29921
30019
|
function owningClone(worktreePath) {
|
|
29922
30020
|
const recorded = worktreeAttributionIncludingReaped(worktreePath)?.clone;
|
|
29923
|
-
if (recorded &&
|
|
30021
|
+
if (recorded && existsSync67(recorded)) return recorded;
|
|
29924
30022
|
const detected = mainWorktree(worktreePath);
|
|
29925
30023
|
if (detected) return detected;
|
|
29926
30024
|
daemonLog(
|
|
@@ -30048,12 +30146,12 @@ function closeGateApplies(sessions, session) {
|
|
|
30048
30146
|
}
|
|
30049
30147
|
|
|
30050
30148
|
// src/commands/sessions/daemon/worktree/watchGitState.ts
|
|
30051
|
-
import { existsSync as
|
|
30149
|
+
import { existsSync as existsSync68, watch } from "fs";
|
|
30052
30150
|
var DEBOUNCE_MS = 500;
|
|
30053
30151
|
var POLL_MS = 3e4;
|
|
30054
30152
|
function watchGitState(cwd, onChange) {
|
|
30055
30153
|
const common = gitCommonDir(cwd);
|
|
30056
|
-
if (!common || !
|
|
30154
|
+
if (!common || !existsSync68(common)) return void 0;
|
|
30057
30155
|
const watchers = [
|
|
30058
30156
|
watchGitDir(common, onChange),
|
|
30059
30157
|
pollGitState(cwd, onChange)
|
|
@@ -30412,13 +30510,13 @@ function isBacklogItemId(text17) {
|
|
|
30412
30510
|
}
|
|
30413
30511
|
|
|
30414
30512
|
// src/commands/sessions/daemon/generateSessionTitle.ts
|
|
30415
|
-
import { execFile as
|
|
30416
|
-
import { promisify as
|
|
30417
|
-
var
|
|
30513
|
+
import { execFile as execFile10 } from "child_process";
|
|
30514
|
+
import { promisify as promisify9 } from "util";
|
|
30515
|
+
var execFileAsync8 = promisify9(execFile10);
|
|
30418
30516
|
var SESSION_TITLE_MAX_LENGTH = 48;
|
|
30419
30517
|
async function generateSessionTitle(prompt) {
|
|
30420
30518
|
try {
|
|
30421
|
-
const { stdout } = await
|
|
30519
|
+
const { stdout } = await execFileAsync8(
|
|
30422
30520
|
"claude",
|
|
30423
30521
|
["-p", "--model", "haiku", buildPrompt4(prompt)],
|
|
30424
30522
|
{ encoding: "utf8", windowsHide: true, timeout: 3e4 }
|
|
@@ -30497,10 +30595,10 @@ function emitSessionOutput(session, clients, data) {
|
|
|
30497
30595
|
}
|
|
30498
30596
|
|
|
30499
30597
|
// src/commands/sessions/daemon/exitReason.ts
|
|
30500
|
-
import { existsSync as
|
|
30598
|
+
import { existsSync as existsSync69 } from "fs";
|
|
30501
30599
|
import { resolve as resolve20 } from "path";
|
|
30502
30600
|
function exitDetail(session) {
|
|
30503
|
-
if (session.cwd && !
|
|
30601
|
+
if (session.cwd && !existsSync69(session.cwd))
|
|
30504
30602
|
return `working directory ${session.cwd} no longer exists`;
|
|
30505
30603
|
return missingRunConfigCwd(session);
|
|
30506
30604
|
}
|
|
@@ -30514,7 +30612,7 @@ function missingRunConfigCwd(session) {
|
|
|
30514
30612
|
const config = resolveRunConfig(session.runName, dir);
|
|
30515
30613
|
if (!config?.cwd) return void 0;
|
|
30516
30614
|
const configured = resolve20(runConfigBaseDirFrom(dir), config.cwd);
|
|
30517
|
-
if (
|
|
30615
|
+
if (existsSync69(configured)) return void 0;
|
|
30518
30616
|
return `run config "${config.name}": cwd ${configured} does not exist`;
|
|
30519
30617
|
}
|
|
30520
30618
|
|
|
@@ -30531,8 +30629,8 @@ function handleFailedResume(session, exitCode, onStatusChange) {
|
|
|
30531
30629
|
}
|
|
30532
30630
|
|
|
30533
30631
|
// src/commands/sessions/daemon/watchActivity.ts
|
|
30534
|
-
import { existsSync as
|
|
30535
|
-
import { dirname as
|
|
30632
|
+
import { existsSync as existsSync70, mkdirSync as mkdirSync26, watch as watch2 } from "fs";
|
|
30633
|
+
import { dirname as dirname34 } from "path";
|
|
30536
30634
|
|
|
30537
30635
|
// src/commands/sessions/daemon/applyReviewPause.ts
|
|
30538
30636
|
function applyReviewPause(session, activity2) {
|
|
@@ -30586,7 +30684,7 @@ var DEBOUNCE_MS2 = 50;
|
|
|
30586
30684
|
function watchActivity(session, notify2, onClaudeSessionId) {
|
|
30587
30685
|
if (session.commandType !== "assist" || !session.cwd) return;
|
|
30588
30686
|
const path71 = activityPath(session.id);
|
|
30589
|
-
const dir =
|
|
30687
|
+
const dir = dirname34(path71);
|
|
30590
30688
|
try {
|
|
30591
30689
|
mkdirSync26(dir, { recursive: true });
|
|
30592
30690
|
} catch {
|
|
@@ -30612,7 +30710,7 @@ function watchActivity(session, notify2, onClaudeSessionId) {
|
|
|
30612
30710
|
if (timer) clearTimeout(timer);
|
|
30613
30711
|
timer = setTimeout(read, DEBOUNCE_MS2);
|
|
30614
30712
|
});
|
|
30615
|
-
if (
|
|
30713
|
+
if (existsSync70(path71)) read();
|
|
30616
30714
|
}
|
|
30617
30715
|
function refreshActivity(session) {
|
|
30618
30716
|
if (session.commandType !== "assist" || !session.cwd) return;
|
|
@@ -31526,7 +31624,7 @@ function respawnSession(session, respawn, status3, clients, onStatusChange) {
|
|
|
31526
31624
|
}
|
|
31527
31625
|
|
|
31528
31626
|
// src/commands/sessions/daemon/respawnPlan.ts
|
|
31529
|
-
import { randomUUID as
|
|
31627
|
+
import { randomUUID as randomUUID10 } from "crypto";
|
|
31530
31628
|
|
|
31531
31629
|
// src/commands/sessions/daemon/assistResumeArgs.ts
|
|
31532
31630
|
function assistResumeArgs(session) {
|
|
@@ -31567,7 +31665,7 @@ function respawnPlan(session) {
|
|
|
31567
31665
|
return null;
|
|
31568
31666
|
}
|
|
31569
31667
|
function freshClaudePlan(session, prompt, cwd) {
|
|
31570
|
-
const claudeSessionId =
|
|
31668
|
+
const claudeSessionId = randomUUID10();
|
|
31571
31669
|
return {
|
|
31572
31670
|
spawn: () => {
|
|
31573
31671
|
session.claudeSessionId = claudeSessionId;
|
|
@@ -31938,7 +32036,7 @@ function rearmStoppedSessions(sessions, notify2) {
|
|
|
31938
32036
|
}
|
|
31939
32037
|
|
|
31940
32038
|
// src/commands/sessions/daemon/worktree/reconcileWorktreesOnRestore.ts
|
|
31941
|
-
import { existsSync as
|
|
32039
|
+
import { existsSync as existsSync73 } from "fs";
|
|
31942
32040
|
import { basename as basename20 } from "path";
|
|
31943
32041
|
|
|
31944
32042
|
// src/commands/sessions/daemon/worktree/accountedTrees.ts
|
|
@@ -31960,10 +32058,10 @@ function accountedTrees(sessions) {
|
|
|
31960
32058
|
|
|
31961
32059
|
// src/commands/sessions/daemon/worktree/detectExistingWorktree.ts
|
|
31962
32060
|
function detectExistingWorktree(cwd) {
|
|
31963
|
-
const
|
|
31964
|
-
if (!worktreeConfigFor(
|
|
31965
|
-
const clone = mainWorktree(
|
|
31966
|
-
if (clone && clone !==
|
|
32061
|
+
const repoRoot2 = findRepoRoot(cwd) ?? cwd;
|
|
32062
|
+
if (!worktreeConfigFor(repoRoot2).enabled) return void 0;
|
|
32063
|
+
const clone = mainWorktree(repoRoot2);
|
|
32064
|
+
if (clone && clone !== repoRoot2) return { path: repoRoot2, clone };
|
|
31967
32065
|
return void 0;
|
|
31968
32066
|
}
|
|
31969
32067
|
|
|
@@ -32028,9 +32126,9 @@ function capped(lines2) {
|
|
|
32028
32126
|
}
|
|
32029
32127
|
|
|
32030
32128
|
// src/commands/sessions/daemon/worktree/reclaimVanishedWorktrees.ts
|
|
32031
|
-
import { existsSync as
|
|
32129
|
+
import { existsSync as existsSync72 } from "fs";
|
|
32032
32130
|
async function reclaimVanishedWorktrees(clone, paths) {
|
|
32033
|
-
if (!
|
|
32131
|
+
if (!existsSync72(clone)) {
|
|
32034
32132
|
for (const { path: path71 } of paths) forgetWorktree(path71);
|
|
32035
32133
|
daemonLog(
|
|
32036
32134
|
`clone ${clone} is gone; forgot ${paths.length} worktree record(s) it owned`
|
|
@@ -32137,7 +32235,7 @@ async function recoverOrphanedWorktrees(sessions, spawnWith, notify2) {
|
|
|
32137
32235
|
const accounted = accountedTrees(sessions);
|
|
32138
32236
|
const vanished = /* @__PURE__ */ new Map();
|
|
32139
32237
|
for (const { path: path71, clone } of readWorktreeRegistry()) {
|
|
32140
|
-
if (!
|
|
32238
|
+
if (!existsSync73(path71)) {
|
|
32141
32239
|
logVanishedTree(sessions, path71);
|
|
32142
32240
|
vanished.set(clone, [
|
|
32143
32241
|
...vanished.get(clone) ?? [],
|
|
@@ -32602,13 +32700,13 @@ async function defaultConnect() {
|
|
|
32602
32700
|
}
|
|
32603
32701
|
|
|
32604
32702
|
// src/commands/sessions/daemon/hasPersistedWindowsSessions.ts
|
|
32605
|
-
import { existsSync as
|
|
32703
|
+
import { existsSync as existsSync74, readFileSync as readFileSync51 } from "fs";
|
|
32606
32704
|
import { posix } from "path";
|
|
32607
32705
|
function hasPersistedWindowsSessions() {
|
|
32608
32706
|
const sessionsFile = windowsSessionsFileFromWsl();
|
|
32609
32707
|
if (!sessionsFile) return false;
|
|
32610
32708
|
try {
|
|
32611
|
-
if (!
|
|
32709
|
+
if (!existsSync74(sessionsFile)) return false;
|
|
32612
32710
|
const data = JSON.parse(readFileSync51(sessionsFile, "utf8"));
|
|
32613
32711
|
return Array.isArray(data) && data.length > 0;
|
|
32614
32712
|
} catch (error) {
|
|
@@ -33583,9 +33681,9 @@ function safeParse2(line) {
|
|
|
33583
33681
|
}
|
|
33584
33682
|
|
|
33585
33683
|
// src/commands/sessions/daemon/repoDirExists.ts
|
|
33586
|
-
import { existsSync as
|
|
33684
|
+
import { existsSync as existsSync75 } from "fs";
|
|
33587
33685
|
function repoDirExists(cwd) {
|
|
33588
|
-
return
|
|
33686
|
+
return existsSync75(toGitCwd(cwd));
|
|
33589
33687
|
}
|
|
33590
33688
|
|
|
33591
33689
|
// src/commands/sessions/daemon/withRepoGroups.ts
|
|
@@ -34145,9 +34243,9 @@ function buildLimitsSegment(rateLimits) {
|
|
|
34145
34243
|
|
|
34146
34244
|
// src/commands/readGitBranch.ts
|
|
34147
34245
|
import { readFileSync as readFileSync54, statSync as statSync14 } from "fs";
|
|
34148
|
-
import { isAbsolute as isAbsolute4, join as
|
|
34246
|
+
import { isAbsolute as isAbsolute4, join as join78, resolve as resolve21 } from "path";
|
|
34149
34247
|
function resolveGitDir(cwd) {
|
|
34150
|
-
const dotGit =
|
|
34248
|
+
const dotGit = join78(cwd, ".git");
|
|
34151
34249
|
let stat3;
|
|
34152
34250
|
try {
|
|
34153
34251
|
stat3 = statSync14(dotGit);
|
|
@@ -34177,7 +34275,7 @@ function readGitBranch(cwd) {
|
|
|
34177
34275
|
}
|
|
34178
34276
|
let head;
|
|
34179
34277
|
try {
|
|
34180
|
-
head = readFileSync54(
|
|
34278
|
+
head = readFileSync54(join78(gitDir, "HEAD"), "utf8");
|
|
34181
34279
|
} catch {
|
|
34182
34280
|
return null;
|
|
34183
34281
|
}
|