@staff0rd/assist 0.652.0 → 0.653.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 -0
- package/claude/advice/assist-global.md +6 -0
- package/claude/advice/backlog-ids.md +6 -0
- package/claude/advice/backlog-prs.md +6 -0
- package/claude/advice/code-comments.md +6 -0
- package/claude/advice/drafting-messages.md +6 -0
- package/claude/advice/editing-files.md +6 -0
- package/claude/advice/jira-context.md +6 -0
- package/claude/advice/jira-smart-links.md +6 -0
- package/claude/advice/markdown.md +6 -0
- package/claude/settings.json +4 -1
- package/dist/commands/sessions/web/bundle.js +1 -1
- package/dist/index.js +675 -535
- 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.653.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -5081,9 +5081,148 @@ function registerActivity(program2) {
|
|
|
5081
5081
|
).action(activity);
|
|
5082
5082
|
}
|
|
5083
5083
|
|
|
5084
|
+
// src/commands/advise/adviceContextFor.ts
|
|
5085
|
+
function adviceContextFor(cwd) {
|
|
5086
|
+
return {
|
|
5087
|
+
config: loadConfigFrom(cwd),
|
|
5088
|
+
rootDir: findConfigUp(cwd)?.rootDir ?? cwd
|
|
5089
|
+
};
|
|
5090
|
+
}
|
|
5091
|
+
|
|
5092
|
+
// src/commands/advise/loadAdviceFragments.ts
|
|
5093
|
+
import { readdirSync as readdirSync2, readFileSync as readFileSync14 } from "fs";
|
|
5094
|
+
import { basename as basename4, join as join13 } from "path";
|
|
5095
|
+
|
|
5096
|
+
// src/commands/advise/adviceDir.ts
|
|
5097
|
+
import { existsSync as existsSync18 } from "fs";
|
|
5098
|
+
import { dirname as dirname13, join as join12 } from "path";
|
|
5099
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
5100
|
+
function adviceDir() {
|
|
5101
|
+
let current = dirname13(fileURLToPath3(import.meta.url));
|
|
5102
|
+
while (current !== dirname13(current)) {
|
|
5103
|
+
const candidate = join12(current, "claude", "advice");
|
|
5104
|
+
if (existsSync18(candidate)) return candidate;
|
|
5105
|
+
current = dirname13(current);
|
|
5106
|
+
}
|
|
5107
|
+
throw new Error("Could not locate the shipped claude/advice directory");
|
|
5108
|
+
}
|
|
5109
|
+
|
|
5110
|
+
// src/commands/advise/parseAdviceFragment.ts
|
|
5111
|
+
import { parse as parseYaml2 } from "yaml";
|
|
5112
|
+
var frontmatter = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/;
|
|
5113
|
+
function parseAdviceFragment(name, content) {
|
|
5114
|
+
const match = frontmatter.exec(content);
|
|
5115
|
+
if (!match) throw new Error(`Advice fragment ${name} has no frontmatter`);
|
|
5116
|
+
const meta = parseYaml2(match[1]) ?? {};
|
|
5117
|
+
const title = meta.title;
|
|
5118
|
+
const when = meta.when;
|
|
5119
|
+
if (typeof title !== "string" || typeof when !== "string")
|
|
5120
|
+
throw new Error(
|
|
5121
|
+
`Advice fragment ${name} needs a title and a when condition`
|
|
5122
|
+
);
|
|
5123
|
+
return {
|
|
5124
|
+
name,
|
|
5125
|
+
title,
|
|
5126
|
+
when,
|
|
5127
|
+
body: content.slice(match[0].length).trim()
|
|
5128
|
+
};
|
|
5129
|
+
}
|
|
5130
|
+
|
|
5131
|
+
// src/commands/advise/loadAdviceFragments.ts
|
|
5132
|
+
function loadAdviceFragments(dir = adviceDir()) {
|
|
5133
|
+
return readdirSync2(dir).filter((file) => file.endsWith(".md")).sort().map(
|
|
5134
|
+
(file) => parseAdviceFragment(
|
|
5135
|
+
basename4(file, ".md"),
|
|
5136
|
+
readFileSync14(join13(dir, file), "utf8")
|
|
5137
|
+
)
|
|
5138
|
+
);
|
|
5139
|
+
}
|
|
5140
|
+
|
|
5141
|
+
// src/commands/advise/adviceConditions.ts
|
|
5142
|
+
var adviceConditions = {
|
|
5143
|
+
always: {
|
|
5144
|
+
whenMet: "always included",
|
|
5145
|
+
whenUnmet: "always included",
|
|
5146
|
+
matches: () => true
|
|
5147
|
+
},
|
|
5148
|
+
jira: {
|
|
5149
|
+
whenMet: "jira is configured",
|
|
5150
|
+
whenUnmet: "jira is not configured",
|
|
5151
|
+
matches: ({ config }) => config.jira !== void 0
|
|
5152
|
+
}
|
|
5153
|
+
};
|
|
5154
|
+
|
|
5155
|
+
// src/commands/advise/selectAdvice.ts
|
|
5156
|
+
function selectAdvice(fragments, context) {
|
|
5157
|
+
return fragments.map((fragment) => {
|
|
5158
|
+
const condition = adviceConditions[fragment.when];
|
|
5159
|
+
if (!condition)
|
|
5160
|
+
return {
|
|
5161
|
+
fragment,
|
|
5162
|
+
included: false,
|
|
5163
|
+
reason: `unknown condition "${fragment.when}"`
|
|
5164
|
+
};
|
|
5165
|
+
const included = condition.matches(context);
|
|
5166
|
+
return {
|
|
5167
|
+
fragment,
|
|
5168
|
+
included,
|
|
5169
|
+
reason: included ? condition.whenMet : condition.whenUnmet
|
|
5170
|
+
};
|
|
5171
|
+
});
|
|
5172
|
+
}
|
|
5173
|
+
|
|
5174
|
+
// src/commands/advise/composeAdvice.ts
|
|
5175
|
+
var heading = "# Instructions for this repo (composed by assist)";
|
|
5176
|
+
function composeAdvice(context, fragments = loadAdviceFragments()) {
|
|
5177
|
+
const sections = selectAdvice(fragments, context).filter((decision) => decision.included).map(({ fragment }) => `## ${fragment.title}
|
|
5178
|
+
|
|
5179
|
+
${fragment.body}`);
|
|
5180
|
+
if (sections.length === 0) return "";
|
|
5181
|
+
return [heading, ...sections].join("\n\n");
|
|
5182
|
+
}
|
|
5183
|
+
|
|
5184
|
+
// src/commands/advise/advise.ts
|
|
5185
|
+
async function hookCwd(options2) {
|
|
5186
|
+
const read3 = options2.stdin ?? (process.stdin.isTTY ? void 0 : readStdin);
|
|
5187
|
+
if (!read3) return void 0;
|
|
5188
|
+
try {
|
|
5189
|
+
const raw = await read3();
|
|
5190
|
+
if (!raw.trim()) return void 0;
|
|
5191
|
+
return JSON.parse(raw).cwd;
|
|
5192
|
+
} catch {
|
|
5193
|
+
return void 0;
|
|
5194
|
+
}
|
|
5195
|
+
}
|
|
5196
|
+
async function advise(options2 = {}) {
|
|
5197
|
+
const fallback = options2.cwdFallback ?? process.cwd();
|
|
5198
|
+
const cwd = options2.hook ? await hookCwd(options2) ?? fallback : fallback;
|
|
5199
|
+
const markdown = composeAdvice(adviceContextFor(cwd));
|
|
5200
|
+
if (!markdown) return "";
|
|
5201
|
+
const output = options2.hook ? JSON.stringify({
|
|
5202
|
+
hookSpecificOutput: {
|
|
5203
|
+
hookEventName: "SessionStart",
|
|
5204
|
+
additionalContext: markdown
|
|
5205
|
+
}
|
|
5206
|
+
}) : markdown;
|
|
5207
|
+
console.log(output);
|
|
5208
|
+
return output;
|
|
5209
|
+
}
|
|
5210
|
+
|
|
5211
|
+
// src/commands/registerAdvise.ts
|
|
5212
|
+
function registerAdvise(program2) {
|
|
5213
|
+
program2.command("advise").description(
|
|
5214
|
+
"Print the advice fragments that apply to this repo, composed from config and repo facts"
|
|
5215
|
+
).option(
|
|
5216
|
+
"--hook",
|
|
5217
|
+
"emit the advice as SessionStart hook JSON (additionalContext)"
|
|
5218
|
+
).action(async (options2) => {
|
|
5219
|
+
await advise({ hook: options2.hook });
|
|
5220
|
+
});
|
|
5221
|
+
}
|
|
5222
|
+
|
|
5084
5223
|
// src/commands/registerBackup.ts
|
|
5085
5224
|
import { mkdir as mkdir2, stat } from "fs/promises";
|
|
5086
|
-
import { join as
|
|
5225
|
+
import { join as join15, resolve as resolve7 } from "path";
|
|
5087
5226
|
import chalk31 from "chalk";
|
|
5088
5227
|
|
|
5089
5228
|
// src/shared/db/getDb.ts
|
|
@@ -5717,7 +5856,7 @@ function expandTilde2(value) {
|
|
|
5717
5856
|
|
|
5718
5857
|
// src/commands/backup/scheduleBackup.ts
|
|
5719
5858
|
import { mkdir } from "fs/promises";
|
|
5720
|
-
import { join as
|
|
5859
|
+
import { join as join14 } from "path";
|
|
5721
5860
|
import chalk29 from "chalk";
|
|
5722
5861
|
|
|
5723
5862
|
// src/commands/backup/readCrontab.ts
|
|
@@ -5859,7 +5998,7 @@ async function scheduleBackup({
|
|
|
5859
5998
|
const cronExpr = durationToCron(every);
|
|
5860
5999
|
const dir = expandTilde2(loadConfig().backup.dir);
|
|
5861
6000
|
await mkdir(dir, { recursive: true });
|
|
5862
|
-
const logPath2 =
|
|
6001
|
+
const logPath2 = join14(dir, "cron.log");
|
|
5863
6002
|
const cronLine = `${cronExpr} ${resolveAssistCommand()} backup >> ${logPath2} 2>&1`;
|
|
5864
6003
|
writeCrontab(upsertScheduleBlock(readCrontab(), every, cronLine));
|
|
5865
6004
|
console.error(
|
|
@@ -6038,7 +6177,7 @@ async function backup({ out }) {
|
|
|
6038
6177
|
await mkdir2(dir, { recursive: true });
|
|
6039
6178
|
const start3 = Date.now();
|
|
6040
6179
|
const timestamp6 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
6041
|
-
const filePath = resolve7(
|
|
6180
|
+
const filePath = resolve7(join15(dir, `backup-${timestamp6}.dump`));
|
|
6042
6181
|
await exportBacklog(filePath);
|
|
6043
6182
|
const { size } = await stat(filePath);
|
|
6044
6183
|
const durationMs = Date.now() - start3;
|
|
@@ -6139,19 +6278,19 @@ function parseItemId(input) {
|
|
|
6139
6278
|
|
|
6140
6279
|
// src/commands/backlog/acquireLock.ts
|
|
6141
6280
|
import {
|
|
6142
|
-
existsSync as
|
|
6281
|
+
existsSync as existsSync19,
|
|
6143
6282
|
mkdirSync as mkdirSync4,
|
|
6144
|
-
readFileSync as
|
|
6283
|
+
readFileSync as readFileSync15,
|
|
6145
6284
|
unlinkSync as unlinkSync2,
|
|
6146
6285
|
writeFileSync as writeFileSync14
|
|
6147
6286
|
} from "fs";
|
|
6148
6287
|
import { homedir as homedir5 } from "os";
|
|
6149
|
-
import { join as
|
|
6288
|
+
import { join as join16 } from "path";
|
|
6150
6289
|
function getLocksDir() {
|
|
6151
|
-
return
|
|
6290
|
+
return join16(homedir5(), ".assist", "locks");
|
|
6152
6291
|
}
|
|
6153
6292
|
function getLockPath(itemId2) {
|
|
6154
|
-
return
|
|
6293
|
+
return join16(getLocksDir(), `lock-${itemId2}.json`);
|
|
6155
6294
|
}
|
|
6156
6295
|
function isProcessAlive(pid) {
|
|
6157
6296
|
try {
|
|
@@ -6163,9 +6302,9 @@ function isProcessAlive(pid) {
|
|
|
6163
6302
|
}
|
|
6164
6303
|
function foreignLockHolder(itemId2) {
|
|
6165
6304
|
const lockPath = getLockPath(itemId2);
|
|
6166
|
-
if (!
|
|
6305
|
+
if (!existsSync19(lockPath)) return null;
|
|
6167
6306
|
try {
|
|
6168
|
-
const lock2 = JSON.parse(
|
|
6307
|
+
const lock2 = JSON.parse(readFileSync15(lockPath, "utf8"));
|
|
6169
6308
|
if (typeof lock2.pid !== "number" || lock2.pid === process.pid) return null;
|
|
6170
6309
|
if (!isProcessAlive(lock2.pid)) return null;
|
|
6171
6310
|
return { pid: lock2.pid, timestamp: lock2.timestamp };
|
|
@@ -6276,7 +6415,7 @@ import chalk45 from "chalk";
|
|
|
6276
6415
|
|
|
6277
6416
|
// src/commands/sessions/daemon/ensureHooksSettings.ts
|
|
6278
6417
|
import { mkdirSync as mkdirSync5, writeFileSync as writeFileSync15 } from "fs";
|
|
6279
|
-
import { dirname as
|
|
6418
|
+
import { dirname as dirname14 } from "path";
|
|
6280
6419
|
var SET_STATUS = "assist sessions set-status";
|
|
6281
6420
|
function running(source) {
|
|
6282
6421
|
return `${SET_STATUS} running --source ${source}`;
|
|
@@ -6308,7 +6447,7 @@ var hooksSettings = {
|
|
|
6308
6447
|
};
|
|
6309
6448
|
function ensureHooksSettings() {
|
|
6310
6449
|
const path91 = daemonPaths.hooksSettings;
|
|
6311
|
-
mkdirSync5(
|
|
6450
|
+
mkdirSync5(dirname14(path91), { recursive: true });
|
|
6312
6451
|
writeFileSync15(path91, JSON.stringify(hooksSettings, null, 2));
|
|
6313
6452
|
return path91;
|
|
6314
6453
|
}
|
|
@@ -6363,7 +6502,7 @@ function buildArgs(prompt, options2) {
|
|
|
6363
6502
|
|
|
6364
6503
|
// src/commands/backlog/ensureStoryBranch.ts
|
|
6365
6504
|
import { execSync as execSync21 } from "child_process";
|
|
6366
|
-
import { basename as
|
|
6505
|
+
import { basename as basename5 } from "path";
|
|
6367
6506
|
|
|
6368
6507
|
// src/commands/branch/createBranch.ts
|
|
6369
6508
|
import { execSync as execSync20 } from "child_process";
|
|
@@ -6698,7 +6837,7 @@ function worktreeBranchInPlay() {
|
|
|
6698
6837
|
const tree = linkedWorktree(process.cwd());
|
|
6699
6838
|
if (!tree) return null;
|
|
6700
6839
|
const head = currentBranch();
|
|
6701
|
-
return head ===
|
|
6840
|
+
return head === basename5(tree.root) ? head : null;
|
|
6702
6841
|
}
|
|
6703
6842
|
function currentBranch() {
|
|
6704
6843
|
try {
|
|
@@ -6721,19 +6860,19 @@ function message(error) {
|
|
|
6721
6860
|
import chalk37 from "chalk";
|
|
6722
6861
|
|
|
6723
6862
|
// src/commands/backlog/migrateLocalBacklog.ts
|
|
6724
|
-
import { existsSync as
|
|
6725
|
-
import { join as
|
|
6863
|
+
import { existsSync as existsSync21 } from "fs";
|
|
6864
|
+
import { join as join18 } from "path";
|
|
6726
6865
|
import chalk36 from "chalk";
|
|
6727
6866
|
|
|
6728
6867
|
// src/commands/backlog/backupLocalBacklogFiles.ts
|
|
6729
|
-
import { existsSync as
|
|
6730
|
-
import { join as
|
|
6868
|
+
import { existsSync as existsSync20, renameSync } from "fs";
|
|
6869
|
+
import { join as join17 } from "path";
|
|
6731
6870
|
var LOCAL_FILES = ["backlog.jsonl", "backlog.db"];
|
|
6732
6871
|
function backupLocalBacklogFiles(dir) {
|
|
6733
6872
|
const moved = [];
|
|
6734
6873
|
for (const name of LOCAL_FILES) {
|
|
6735
|
-
const path91 =
|
|
6736
|
-
if (
|
|
6874
|
+
const path91 = join17(dir, ".assist", name);
|
|
6875
|
+
if (existsSync20(path91)) {
|
|
6737
6876
|
renameSync(path91, `${path91}.bak`);
|
|
6738
6877
|
moved.push(`${name} \u2192 ${name}.bak`);
|
|
6739
6878
|
}
|
|
@@ -7125,7 +7264,7 @@ async function loadAllItems(orm, origin) {
|
|
|
7125
7264
|
}
|
|
7126
7265
|
|
|
7127
7266
|
// src/commands/backlog/parseBacklogJsonl.ts
|
|
7128
|
-
import { readFileSync as
|
|
7267
|
+
import { readFileSync as readFileSync16 } from "fs";
|
|
7129
7268
|
|
|
7130
7269
|
// src/commands/backlog/types.ts
|
|
7131
7270
|
import { z as z4 } from "zod";
|
|
@@ -7219,14 +7358,14 @@ var backlogFileSchema = z4.array(backlogItemSchema);
|
|
|
7219
7358
|
|
|
7220
7359
|
// src/commands/backlog/parseBacklogJsonl.ts
|
|
7221
7360
|
function parseBacklogJsonl(path91) {
|
|
7222
|
-
const content =
|
|
7361
|
+
const content = readFileSync16(path91, "utf8").trim();
|
|
7223
7362
|
if (content.length === 0) return [];
|
|
7224
7363
|
return content.split("\n").map((line) => line.trim()).filter(Boolean).map((line) => backlogItemSchema.parse(JSON.parse(line)));
|
|
7225
7364
|
}
|
|
7226
7365
|
|
|
7227
7366
|
// src/commands/backlog/migrateLocalBacklog.ts
|
|
7228
7367
|
function jsonlPath(dir) {
|
|
7229
|
-
return
|
|
7368
|
+
return join18(dir, ".assist", "backlog.jsonl");
|
|
7230
7369
|
}
|
|
7231
7370
|
async function verifyImport(orm, origin, items2, imported) {
|
|
7232
7371
|
const reloaded = await loadAllItems(orm, origin);
|
|
@@ -7242,7 +7381,7 @@ async function verifyImport(orm, origin, items2, imported) {
|
|
|
7242
7381
|
}
|
|
7243
7382
|
}
|
|
7244
7383
|
async function migrateLocalBacklog(orm, dir, origin) {
|
|
7245
|
-
if (!
|
|
7384
|
+
if (!existsSync21(jsonlPath(dir))) return;
|
|
7246
7385
|
const existing = (await loadAllItems(orm, origin)).length;
|
|
7247
7386
|
if (existing > 0) {
|
|
7248
7387
|
const moved2 = backupLocalBacklogFiles(dir);
|
|
@@ -7281,20 +7420,20 @@ async function deleteItem(orm, id) {
|
|
|
7281
7420
|
}
|
|
7282
7421
|
|
|
7283
7422
|
// src/commands/backlog/findBacklogUp.ts
|
|
7284
|
-
import { existsSync as
|
|
7285
|
-
import { dirname as
|
|
7423
|
+
import { existsSync as existsSync22 } from "fs";
|
|
7424
|
+
import { dirname as dirname15, join as join19 } from "path";
|
|
7286
7425
|
var BACKLOG_MARKERS = [
|
|
7287
|
-
|
|
7288
|
-
|
|
7426
|
+
join19(".assist", "backlog.db"),
|
|
7427
|
+
join19(".assist", "backlog.jsonl"),
|
|
7289
7428
|
"assist.backlog.yml"
|
|
7290
7429
|
];
|
|
7291
7430
|
function findBacklogUp(startDir) {
|
|
7292
7431
|
let current = startDir;
|
|
7293
|
-
while (current !==
|
|
7294
|
-
if (BACKLOG_MARKERS.some((marker2) =>
|
|
7432
|
+
while (current !== dirname15(current)) {
|
|
7433
|
+
if (BACKLOG_MARKERS.some((marker2) => existsSync22(join19(current, marker2)))) {
|
|
7295
7434
|
return current;
|
|
7296
7435
|
}
|
|
7297
|
-
current =
|
|
7436
|
+
current = dirname15(current);
|
|
7298
7437
|
}
|
|
7299
7438
|
return null;
|
|
7300
7439
|
}
|
|
@@ -7545,14 +7684,14 @@ function reportDuplicateRun(itemId2, holder) {
|
|
|
7545
7684
|
}
|
|
7546
7685
|
|
|
7547
7686
|
// src/commands/backlog/consumePause.ts
|
|
7548
|
-
import { existsSync as
|
|
7687
|
+
import { existsSync as existsSync23, mkdirSync as mkdirSync6, unlinkSync as unlinkSync3, writeFileSync as writeFileSync16 } from "fs";
|
|
7549
7688
|
import { homedir as homedir6 } from "os";
|
|
7550
|
-
import { join as
|
|
7689
|
+
import { join as join20 } from "path";
|
|
7551
7690
|
function getControlsDir() {
|
|
7552
|
-
return
|
|
7691
|
+
return join20(homedir6(), ".assist", "controls");
|
|
7553
7692
|
}
|
|
7554
7693
|
function getPausePath(itemId2) {
|
|
7555
|
-
return
|
|
7694
|
+
return join20(getControlsDir(), `pause-${itemId2}.json`);
|
|
7556
7695
|
}
|
|
7557
7696
|
function requestPause(itemId2) {
|
|
7558
7697
|
mkdirSync6(getControlsDir(), { recursive: true });
|
|
@@ -7562,7 +7701,7 @@ function requestPause(itemId2) {
|
|
|
7562
7701
|
);
|
|
7563
7702
|
}
|
|
7564
7703
|
function isPausePending(itemId2) {
|
|
7565
|
-
return
|
|
7704
|
+
return existsSync23(getPausePath(itemId2));
|
|
7566
7705
|
}
|
|
7567
7706
|
function clearPause(itemId2) {
|
|
7568
7707
|
try {
|
|
@@ -7572,7 +7711,7 @@ function clearPause(itemId2) {
|
|
|
7572
7711
|
}
|
|
7573
7712
|
function consumePause(itemId2) {
|
|
7574
7713
|
const pausePath = getPausePath(itemId2);
|
|
7575
|
-
if (!
|
|
7714
|
+
if (!existsSync23(pausePath)) return false;
|
|
7576
7715
|
try {
|
|
7577
7716
|
unlinkSync3(pausePath);
|
|
7578
7717
|
} catch {
|
|
@@ -8003,42 +8142,42 @@ function spawnHarness(harness, prompt, options2 = {}) {
|
|
|
8003
8142
|
}
|
|
8004
8143
|
|
|
8005
8144
|
// src/commands/backlog/watchForMarker.ts
|
|
8006
|
-
import { existsSync as
|
|
8145
|
+
import { existsSync as existsSync26, unwatchFile, watchFile } from "fs";
|
|
8007
8146
|
|
|
8008
8147
|
// src/commands/backlog/readSignal.ts
|
|
8009
|
-
import { existsSync as
|
|
8148
|
+
import { existsSync as existsSync25, readFileSync as readFileSync18 } from "fs";
|
|
8010
8149
|
|
|
8011
8150
|
// src/commands/backlog/writeSignal.ts
|
|
8012
8151
|
import { mkdirSync as mkdirSync8, writeFileSync as writeFileSync18 } from "fs";
|
|
8013
8152
|
import { homedir as homedir9 } from "os";
|
|
8014
|
-
import { dirname as
|
|
8153
|
+
import { dirname as dirname17, join as join23 } from "path";
|
|
8015
8154
|
import chalk41 from "chalk";
|
|
8016
8155
|
|
|
8017
8156
|
// src/commands/backlog/recordSignalOwner.ts
|
|
8018
8157
|
import {
|
|
8019
|
-
existsSync as
|
|
8158
|
+
existsSync as existsSync24,
|
|
8020
8159
|
mkdirSync as mkdirSync7,
|
|
8021
|
-
readFileSync as
|
|
8160
|
+
readFileSync as readFileSync17,
|
|
8022
8161
|
rmSync,
|
|
8023
8162
|
writeFileSync as writeFileSync17
|
|
8024
8163
|
} from "fs";
|
|
8025
8164
|
import { homedir as homedir8 } from "os";
|
|
8026
|
-
import { dirname as
|
|
8165
|
+
import { dirname as dirname16, join as join22 } from "path";
|
|
8027
8166
|
function getOwnerPath(itemId2) {
|
|
8028
|
-
return
|
|
8167
|
+
return join22(homedir8(), ".assist", "signals", `owner-${itemId2}.json`);
|
|
8029
8168
|
}
|
|
8030
8169
|
function recordSignalOwner(itemId2) {
|
|
8031
8170
|
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
8032
8171
|
if (!sessionId) return;
|
|
8033
8172
|
const path91 = getOwnerPath(itemId2);
|
|
8034
|
-
mkdirSync7(
|
|
8173
|
+
mkdirSync7(dirname16(path91), { recursive: true });
|
|
8035
8174
|
writeFileSync17(path91, JSON.stringify({ sessionId }));
|
|
8036
8175
|
}
|
|
8037
8176
|
function readSignalOwner(itemId2) {
|
|
8038
8177
|
const path91 = getOwnerPath(itemId2);
|
|
8039
|
-
if (!
|
|
8178
|
+
if (!existsSync24(path91)) return void 0;
|
|
8040
8179
|
try {
|
|
8041
|
-
const parsed = JSON.parse(
|
|
8180
|
+
const parsed = JSON.parse(readFileSync17(path91, "utf8"));
|
|
8042
8181
|
return parsed.sessionId;
|
|
8043
8182
|
} catch {
|
|
8044
8183
|
return void 0;
|
|
@@ -8055,7 +8194,7 @@ function clearSignalOwner(itemId2) {
|
|
|
8055
8194
|
// src/commands/backlog/writeSignal.ts
|
|
8056
8195
|
function getSignalPath(sessionId = process.env.ASSIST_SESSION_ID) {
|
|
8057
8196
|
if (!sessionId) return void 0;
|
|
8058
|
-
return
|
|
8197
|
+
return join23(homedir9(), ".assist", "signals", `signal-${sessionId}.json`);
|
|
8059
8198
|
}
|
|
8060
8199
|
function resolveSignalTarget(event, data) {
|
|
8061
8200
|
const caller = process.env.ASSIST_SESSION_ID;
|
|
@@ -8087,16 +8226,16 @@ function writeSignal(event, data) {
|
|
|
8087
8226
|
const path91 = getSignalPath(target);
|
|
8088
8227
|
if (!path91) return;
|
|
8089
8228
|
const signal = { event, sessionId: target, ...data };
|
|
8090
|
-
mkdirSync8(
|
|
8229
|
+
mkdirSync8(dirname17(path91), { recursive: true });
|
|
8091
8230
|
writeFileSync18(path91, JSON.stringify(signal));
|
|
8092
8231
|
}
|
|
8093
8232
|
|
|
8094
8233
|
// src/commands/backlog/readSignal.ts
|
|
8095
8234
|
function readSignal() {
|
|
8096
8235
|
const path91 = getSignalPath();
|
|
8097
|
-
if (!path91 || !
|
|
8236
|
+
if (!path91 || !existsSync25(path91)) return void 0;
|
|
8098
8237
|
try {
|
|
8099
|
-
return JSON.parse(
|
|
8238
|
+
return JSON.parse(readFileSync18(path91, "utf8"));
|
|
8100
8239
|
} catch {
|
|
8101
8240
|
return void 0;
|
|
8102
8241
|
}
|
|
@@ -8108,7 +8247,7 @@ function watchForMarker(child, options2) {
|
|
|
8108
8247
|
const statusPath = getSignalPath();
|
|
8109
8248
|
if (!statusPath) return { killedOnMarker: () => killed };
|
|
8110
8249
|
watchFile(statusPath, { interval: 1e3 }, () => {
|
|
8111
|
-
if (!
|
|
8250
|
+
if (!existsSync26(statusPath)) return;
|
|
8112
8251
|
const signal = readSignal();
|
|
8113
8252
|
if (!signal) return;
|
|
8114
8253
|
if (signal.event === "done" && !options2?.actOnDone) return;
|
|
@@ -8160,7 +8299,7 @@ function launchPhaseSession(item, phaseNumber, phase, phaseLabel2, claudeSession
|
|
|
8160
8299
|
}
|
|
8161
8300
|
|
|
8162
8301
|
// src/commands/backlog/resolvePhaseResult.ts
|
|
8163
|
-
import { existsSync as
|
|
8302
|
+
import { existsSync as existsSync27, unlinkSync as unlinkSync4 } from "fs";
|
|
8164
8303
|
import chalk42 from "chalk";
|
|
8165
8304
|
|
|
8166
8305
|
// src/commands/backlog/handleIncompletePhase.ts
|
|
@@ -8182,7 +8321,7 @@ async function handleIncompletePhase() {
|
|
|
8182
8321
|
// src/commands/backlog/resolvePhaseResult.ts
|
|
8183
8322
|
function cleanupSignal() {
|
|
8184
8323
|
const statusPath = getSignalPath();
|
|
8185
|
-
if (statusPath &&
|
|
8324
|
+
if (statusPath && existsSync27(statusPath)) {
|
|
8186
8325
|
unlinkSync4(statusPath);
|
|
8187
8326
|
}
|
|
8188
8327
|
}
|
|
@@ -8193,7 +8332,7 @@ async function isTerminalStatus(itemId2) {
|
|
|
8193
8332
|
}
|
|
8194
8333
|
async function resolvePhaseResult(phaseIndex, itemId2) {
|
|
8195
8334
|
const signalPath = getSignalPath();
|
|
8196
|
-
if (!signalPath || !
|
|
8335
|
+
if (!signalPath || !existsSync27(signalPath)) {
|
|
8197
8336
|
if (await isTerminalStatus(itemId2)) return { kind: "abort" };
|
|
8198
8337
|
const action = await handleIncompletePhase();
|
|
8199
8338
|
if (action === "abort") return { kind: "abort" };
|
|
@@ -8272,9 +8411,9 @@ async function persistPhaseSessionId(itemId2, phaseIdx, claudeSessionId) {
|
|
|
8272
8411
|
}
|
|
8273
8412
|
|
|
8274
8413
|
// src/shared/emitActivity.ts
|
|
8275
|
-
import { mkdirSync as mkdirSync9, readFileSync as
|
|
8414
|
+
import { mkdirSync as mkdirSync9, readFileSync as readFileSync19, rmSync as rmSync2, writeFileSync as writeFileSync19 } from "fs";
|
|
8276
8415
|
import { homedir as homedir10 } from "os";
|
|
8277
|
-
import { dirname as
|
|
8416
|
+
import { dirname as dirname18, join as join24 } from "path";
|
|
8278
8417
|
import { z as z5 } from "zod";
|
|
8279
8418
|
var activitySchema = z5.object({
|
|
8280
8419
|
kind: z5.enum(["command", "backlog"]),
|
|
@@ -8289,18 +8428,18 @@ var activitySchema = z5.object({
|
|
|
8289
8428
|
startedAt: z5.number()
|
|
8290
8429
|
});
|
|
8291
8430
|
function activityPath(sessionId) {
|
|
8292
|
-
return
|
|
8431
|
+
return join24(homedir10(), ".assist", "activity", `activity-${sessionId}.json`);
|
|
8293
8432
|
}
|
|
8294
8433
|
function emitActivity(activity2) {
|
|
8295
8434
|
const sessionId = process.env.ASSIST_ACTIVITY_ID;
|
|
8296
8435
|
if (!sessionId) return;
|
|
8297
8436
|
const path91 = activityPath(sessionId);
|
|
8298
|
-
mkdirSync9(
|
|
8437
|
+
mkdirSync9(dirname18(path91), { recursive: true });
|
|
8299
8438
|
writeFileSync19(path91, JSON.stringify({ ...activity2, startedAt: Date.now() }));
|
|
8300
8439
|
}
|
|
8301
8440
|
function readActivity(path91) {
|
|
8302
8441
|
try {
|
|
8303
|
-
return JSON.parse(
|
|
8442
|
+
return JSON.parse(readFileSync19(path91, "utf8"));
|
|
8304
8443
|
} catch {
|
|
8305
8444
|
return void 0;
|
|
8306
8445
|
}
|
|
@@ -8311,7 +8450,7 @@ function reconcileActivity(sessionId, activity2) {
|
|
|
8311
8450
|
return;
|
|
8312
8451
|
}
|
|
8313
8452
|
const path91 = activityPath(sessionId);
|
|
8314
|
-
mkdirSync9(
|
|
8453
|
+
mkdirSync9(dirname18(path91), { recursive: true });
|
|
8315
8454
|
writeFileSync19(path91, JSON.stringify(activity2));
|
|
8316
8455
|
}
|
|
8317
8456
|
function removeActivity(sessionId) {
|
|
@@ -8370,13 +8509,13 @@ import * as fs16 from "fs";
|
|
|
8370
8509
|
import * as path25 from "path";
|
|
8371
8510
|
|
|
8372
8511
|
// src/commands/sessions/shared/codex/codexSessionsDir.ts
|
|
8373
|
-
import { existsSync as
|
|
8512
|
+
import { existsSync as existsSync28 } from "fs";
|
|
8374
8513
|
import * as path24 from "path";
|
|
8375
8514
|
function codexSessionsDir() {
|
|
8376
8515
|
return path24.join(harnesses.codex.homeDir, "sessions");
|
|
8377
8516
|
}
|
|
8378
8517
|
function hasCodexSessions() {
|
|
8379
|
-
return
|
|
8518
|
+
return existsSync28(codexSessionsDir());
|
|
8380
8519
|
}
|
|
8381
8520
|
|
|
8382
8521
|
// src/commands/sessions/shared/codex/discoverCodexRolloutPaths.ts
|
|
@@ -9406,10 +9545,10 @@ import { WebSocketServer } from "ws";
|
|
|
9406
9545
|
|
|
9407
9546
|
// src/shared/getInstallDir.ts
|
|
9408
9547
|
import { execSync as execSync24 } from "child_process";
|
|
9409
|
-
import { dirname as
|
|
9410
|
-
import { fileURLToPath as
|
|
9411
|
-
var __filename2 =
|
|
9412
|
-
var __dirname3 =
|
|
9548
|
+
import { dirname as dirname20, resolve as resolve8 } from "path";
|
|
9549
|
+
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
9550
|
+
var __filename2 = fileURLToPath4(import.meta.url);
|
|
9551
|
+
var __dirname3 = dirname20(__filename2);
|
|
9413
9552
|
function getInstallDir() {
|
|
9414
9553
|
return resolve8(__dirname3, "..");
|
|
9415
9554
|
}
|
|
@@ -9652,7 +9791,7 @@ function originForCwd(cwd) {
|
|
|
9652
9791
|
}
|
|
9653
9792
|
|
|
9654
9793
|
// src/commands/sessions/daemon/repoDirExists.ts
|
|
9655
|
-
import { existsSync as
|
|
9794
|
+
import { existsSync as existsSync29 } from "fs";
|
|
9656
9795
|
|
|
9657
9796
|
// src/commands/sessions/web/windowsCwdToWslPath.ts
|
|
9658
9797
|
function windowsCwdToWslPath(cwd) {
|
|
@@ -9670,7 +9809,7 @@ function toGitCwd(cwd) {
|
|
|
9670
9809
|
|
|
9671
9810
|
// src/commands/sessions/daemon/repoDirExists.ts
|
|
9672
9811
|
function repoDirExists(cwd) {
|
|
9673
|
-
return
|
|
9812
|
+
return existsSync29(toGitCwd(cwd));
|
|
9674
9813
|
}
|
|
9675
9814
|
|
|
9676
9815
|
// src/commands/sessions/daemon/worktree/git.ts
|
|
@@ -9767,20 +9906,20 @@ function gitCommonDir(cwd) {
|
|
|
9767
9906
|
}
|
|
9768
9907
|
|
|
9769
9908
|
// src/shared/loadJson.ts
|
|
9770
|
-
import { existsSync as
|
|
9909
|
+
import { existsSync as existsSync30, mkdirSync as mkdirSync11, readFileSync as readFileSync20, writeFileSync as writeFileSync20 } from "fs";
|
|
9771
9910
|
import { homedir as homedir12 } from "os";
|
|
9772
|
-
import { join as
|
|
9911
|
+
import { join as join28 } from "path";
|
|
9773
9912
|
function getStoreDir() {
|
|
9774
|
-
return process.env.ASSIST_STORE_DIR ||
|
|
9913
|
+
return process.env.ASSIST_STORE_DIR || join28(homedir12(), ".assist");
|
|
9775
9914
|
}
|
|
9776
9915
|
function getStorePath(filename) {
|
|
9777
|
-
return
|
|
9916
|
+
return join28(getStoreDir(), filename);
|
|
9778
9917
|
}
|
|
9779
9918
|
function loadJson(filename) {
|
|
9780
9919
|
const path91 = getStorePath(filename);
|
|
9781
|
-
if (
|
|
9920
|
+
if (existsSync30(path91)) {
|
|
9782
9921
|
try {
|
|
9783
|
-
return JSON.parse(
|
|
9922
|
+
return JSON.parse(readFileSync20(path91, "utf8"));
|
|
9784
9923
|
} catch {
|
|
9785
9924
|
return {};
|
|
9786
9925
|
}
|
|
@@ -9789,7 +9928,7 @@ function loadJson(filename) {
|
|
|
9789
9928
|
}
|
|
9790
9929
|
function saveJson(filename, data) {
|
|
9791
9930
|
const dir = getStoreDir();
|
|
9792
|
-
if (!
|
|
9931
|
+
if (!existsSync30(dir)) {
|
|
9793
9932
|
mkdirSync11(dir, { recursive: true });
|
|
9794
9933
|
}
|
|
9795
9934
|
writeFileSync20(getStorePath(filename), JSON.stringify(data, null, 2));
|
|
@@ -9853,16 +9992,16 @@ function hostedGroup(cwd, origin, clone) {
|
|
|
9853
9992
|
|
|
9854
9993
|
// src/shared/createBundleHandler.ts
|
|
9855
9994
|
import { createHash } from "crypto";
|
|
9856
|
-
import { readFileSync as
|
|
9857
|
-
import { dirname as
|
|
9858
|
-
import { fileURLToPath as
|
|
9995
|
+
import { readFileSync as readFileSync21, statSync as statSync3 } from "fs";
|
|
9996
|
+
import { dirname as dirname21, join as join29 } from "path";
|
|
9997
|
+
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
9859
9998
|
function createBundleHandler(importMetaUrl, bundlePath, contentType = "application/javascript") {
|
|
9860
|
-
const file =
|
|
9999
|
+
const file = join29(dirname21(fileURLToPath5(importMetaUrl)), bundlePath);
|
|
9861
10000
|
let cache5;
|
|
9862
10001
|
return (req, res) => {
|
|
9863
10002
|
const mtimeMs = statSync3(file).mtimeMs;
|
|
9864
10003
|
if (cache5?.mtimeMs !== mtimeMs) {
|
|
9865
|
-
const body =
|
|
10004
|
+
const body = readFileSync21(file, "utf8");
|
|
9866
10005
|
const etag = `"${createHash("sha256").update(body).digest("hex").slice(0, 16)}"`;
|
|
9867
10006
|
cache5 = { body, etag, mtimeMs };
|
|
9868
10007
|
}
|
|
@@ -9992,15 +10131,15 @@ async function loadItemSummaries(orm, origin) {
|
|
|
9992
10131
|
}
|
|
9993
10132
|
|
|
9994
10133
|
// src/commands/backlog/resolveRepoLocation.ts
|
|
9995
|
-
import { existsSync as
|
|
10134
|
+
import { existsSync as existsSync31 } from "fs";
|
|
9996
10135
|
|
|
9997
10136
|
// src/commands/backlog/cloneTargetDir.ts
|
|
9998
|
-
import { join as
|
|
10137
|
+
import { join as join30, resolve as resolve9 } from "path";
|
|
9999
10138
|
function cloneTargetDir(origin, baseDir) {
|
|
10000
10139
|
if (origin.startsWith("local:")) return null;
|
|
10001
10140
|
const repoName = origin.split("/").filter(Boolean).pop();
|
|
10002
10141
|
if (!repoName) return null;
|
|
10003
|
-
return resolve9(
|
|
10142
|
+
return resolve9(join30(baseDir, repoName));
|
|
10004
10143
|
}
|
|
10005
10144
|
|
|
10006
10145
|
// src/commands/backlog/resolveRepoLocation.ts
|
|
@@ -10008,7 +10147,7 @@ function resolveRepoLocation(origin, knownCwd, baseDir) {
|
|
|
10008
10147
|
if (knownCwd) return { cwd: knownCwd };
|
|
10009
10148
|
const target = cloneTargetDir(origin, baseDir);
|
|
10010
10149
|
if (!target) return {};
|
|
10011
|
-
if (
|
|
10150
|
+
if (existsSync31(target) && getCurrentOrigin(target) === origin)
|
|
10012
10151
|
return { cwd: target };
|
|
10013
10152
|
return { cloneTarget: target };
|
|
10014
10153
|
}
|
|
@@ -10849,7 +10988,7 @@ async function getBackups(_req, res) {
|
|
|
10849
10988
|
}
|
|
10850
10989
|
|
|
10851
10990
|
// src/shared/globalConfigTargetFor.ts
|
|
10852
|
-
import { existsSync as
|
|
10991
|
+
import { existsSync as existsSync32 } from "fs";
|
|
10853
10992
|
import { posix as posix2 } from "path";
|
|
10854
10993
|
|
|
10855
10994
|
// src/shared/windowsHomeFromWsl.ts
|
|
@@ -10870,7 +11009,7 @@ function globalConfigTargetFor(cwd) {
|
|
|
10870
11009
|
ok: false,
|
|
10871
11010
|
error: `${cwd} runs on the Windows host, whose ~/.assist.yml cannot be located because sessions.windowsProjectsRoot is unset. Set it with: assist config set sessions.windowsProjectsRoot /mnt/c/Users/<you>/.claude/projects`
|
|
10872
11011
|
};
|
|
10873
|
-
if (!
|
|
11012
|
+
if (!existsSync32(winHome))
|
|
10874
11013
|
return {
|
|
10875
11014
|
ok: false,
|
|
10876
11015
|
error: `${cwd} runs on the Windows host, whose home ${winHome} is not reachable from here. Check that the Windows drive is mounted and sessions.windowsProjectsRoot points at it.`
|
|
@@ -11214,20 +11353,20 @@ function handleServerRuns(req, res) {
|
|
|
11214
11353
|
|
|
11215
11354
|
// src/commands/sessions/web/getReviewSynthesis.ts
|
|
11216
11355
|
import { execFile as execFile4 } from "child_process";
|
|
11217
|
-
import { readFileSync as
|
|
11356
|
+
import { readFileSync as readFileSync22 } from "fs";
|
|
11218
11357
|
import { homedir as homedir13 } from "os";
|
|
11219
|
-
import { basename as
|
|
11358
|
+
import { basename as basename11, join as join32 } from "path";
|
|
11220
11359
|
import { promisify as promisify3 } from "util";
|
|
11221
11360
|
|
|
11222
11361
|
// src/commands/sessions/web/findSynthesisForBranch.ts
|
|
11223
|
-
import { existsSync as
|
|
11224
|
-
import { basename as
|
|
11362
|
+
import { existsSync as existsSync33, readdirSync as readdirSync3, statSync as statSync4 } from "fs";
|
|
11363
|
+
import { basename as basename10, dirname as dirname22, join as join31 } from "path";
|
|
11225
11364
|
function findSynthesisForBranch(repoReviewsDir, branch2) {
|
|
11226
|
-
const branchKeyPath =
|
|
11227
|
-
const parent =
|
|
11228
|
-
const branchPrefix =
|
|
11229
|
-
if (!
|
|
11230
|
-
const synthesisFiles =
|
|
11365
|
+
const branchKeyPath = join31(repoReviewsDir, `${branch2}-`);
|
|
11366
|
+
const parent = dirname22(branchKeyPath);
|
|
11367
|
+
const branchPrefix = basename10(branchKeyPath);
|
|
11368
|
+
if (!existsSync33(parent)) return null;
|
|
11369
|
+
const synthesisFiles = readdirSync3(parent).filter((name) => name.startsWith(branchPrefix)).map((name) => join31(parent, name, "synthesis.md")).filter((path91) => existsSync33(path91)).map((path91) => ({ path: path91, mtime: statSync4(path91).mtimeMs })).sort((a, b) => b.mtime - a.mtime);
|
|
11231
11370
|
return synthesisFiles[0]?.path ?? null;
|
|
11232
11371
|
}
|
|
11233
11372
|
|
|
@@ -11245,11 +11384,11 @@ async function resolveSynthesisPath(cwd) {
|
|
|
11245
11384
|
runGit2(cwd, ["rev-parse", "--show-toplevel"]),
|
|
11246
11385
|
runGit2(cwd, ["rev-parse", "--abbrev-ref", "HEAD"])
|
|
11247
11386
|
]);
|
|
11248
|
-
const repoReviewsDir =
|
|
11387
|
+
const repoReviewsDir = join32(
|
|
11249
11388
|
homedir13(),
|
|
11250
11389
|
".assist",
|
|
11251
11390
|
"reviews",
|
|
11252
|
-
|
|
11391
|
+
basename11(repoRoot2)
|
|
11253
11392
|
);
|
|
11254
11393
|
return findSynthesisForBranch(repoReviewsDir, branch2);
|
|
11255
11394
|
}
|
|
@@ -11262,7 +11401,7 @@ async function getReviewSynthesis(req, res) {
|
|
|
11262
11401
|
respondJson(res, 404, { error: "No synthesis found" });
|
|
11263
11402
|
return;
|
|
11264
11403
|
}
|
|
11265
|
-
respondJson(res, 200, { synthesis:
|
|
11404
|
+
respondJson(res, 200, { synthesis: readFileSync22(path91, "utf8") });
|
|
11266
11405
|
} catch {
|
|
11267
11406
|
respondJson(res, 404, { error: "No synthesis found" });
|
|
11268
11407
|
}
|
|
@@ -11485,8 +11624,8 @@ function subsequenceScore(text18, query) {
|
|
|
11485
11624
|
function scoreFilePath(path91, query) {
|
|
11486
11625
|
const needle = query.trim().toLowerCase();
|
|
11487
11626
|
if (!needle) return 0;
|
|
11488
|
-
const
|
|
11489
|
-
const inBasename = subsequenceScore(
|
|
11627
|
+
const basename29 = path91.slice(path91.lastIndexOf("/") + 1);
|
|
11628
|
+
const inBasename = subsequenceScore(basename29, needle);
|
|
11490
11629
|
if (inBasename !== null) return BASENAME_WEIGHT + inBasename;
|
|
11491
11630
|
return subsequenceScore(path91, needle);
|
|
11492
11631
|
}
|
|
@@ -11658,7 +11797,7 @@ async function listNewsItems(_req, res) {
|
|
|
11658
11797
|
import path33 from "path";
|
|
11659
11798
|
|
|
11660
11799
|
// src/commands/rules/readScopedRules.ts
|
|
11661
|
-
import { existsSync as
|
|
11800
|
+
import { existsSync as existsSync35, readFileSync as readFileSync23 } from "fs";
|
|
11662
11801
|
import path32 from "path";
|
|
11663
11802
|
|
|
11664
11803
|
// src/commands/rules/rulesSectionRange.ts
|
|
@@ -11707,11 +11846,11 @@ function parseRulesSection(content) {
|
|
|
11707
11846
|
}
|
|
11708
11847
|
|
|
11709
11848
|
// src/commands/rules/scopeDirectory.ts
|
|
11710
|
-
import { existsSync as
|
|
11849
|
+
import { existsSync as existsSync34, statSync as statSync5 } from "fs";
|
|
11711
11850
|
import path31 from "path";
|
|
11712
11851
|
function scopeDirectory(target) {
|
|
11713
11852
|
const resolved = path31.resolve(target);
|
|
11714
|
-
return
|
|
11853
|
+
return existsSync34(resolved) && statSync5(resolved).isDirectory() ? resolved : path31.dirname(resolved);
|
|
11715
11854
|
}
|
|
11716
11855
|
|
|
11717
11856
|
// src/commands/rules/readScopedRules.ts
|
|
@@ -11722,7 +11861,7 @@ function scopedClaudeFiles(target) {
|
|
|
11722
11861
|
let current = startDir;
|
|
11723
11862
|
while (true) {
|
|
11724
11863
|
const candidate = path32.join(current, "CLAUDE.md");
|
|
11725
|
-
if (
|
|
11864
|
+
if (existsSync35(candidate)) files.push(candidate);
|
|
11726
11865
|
if (current === root || current === path32.dirname(current)) break;
|
|
11727
11866
|
current = path32.dirname(current);
|
|
11728
11867
|
}
|
|
@@ -11730,7 +11869,7 @@ function scopedClaudeFiles(target) {
|
|
|
11730
11869
|
}
|
|
11731
11870
|
function readScopedRules(target) {
|
|
11732
11871
|
return scopedClaudeFiles(target).flatMap(
|
|
11733
|
-
(source) => parseRulesSection(
|
|
11872
|
+
(source) => parseRulesSection(readFileSync23(source, "utf8")).map((rule) => ({
|
|
11734
11873
|
...rule,
|
|
11735
11874
|
source
|
|
11736
11875
|
}))
|
|
@@ -13023,7 +13162,7 @@ function uploadSizeLimit(contentType) {
|
|
|
13023
13162
|
// src/commands/sessions/web/writeTempImage.ts
|
|
13024
13163
|
import { mkdtemp, writeFile as writeFile2 } from "fs/promises";
|
|
13025
13164
|
import { tmpdir } from "os";
|
|
13026
|
-
import { extname, join as
|
|
13165
|
+
import { extname, join as join33 } from "path";
|
|
13027
13166
|
var EXT_BY_MIME = {
|
|
13028
13167
|
"image/png": "png",
|
|
13029
13168
|
"image/jpeg": "jpg",
|
|
@@ -13054,8 +13193,8 @@ function safeBaseName(name) {
|
|
|
13054
13193
|
return base.replace(/^-+|-+$/g, "").slice(0, 60) || "screenshot";
|
|
13055
13194
|
}
|
|
13056
13195
|
async function writeTempImage(name, contentType, body) {
|
|
13057
|
-
const dir = await mkdtemp(
|
|
13058
|
-
const filePath =
|
|
13196
|
+
const dir = await mkdtemp(join33(tmpdir(), "assist-pr-img-"));
|
|
13197
|
+
const filePath = join33(
|
|
13059
13198
|
dir,
|
|
13060
13199
|
`${safeBaseName(name)}.${pickExtension(name, contentType)}`
|
|
13061
13200
|
);
|
|
@@ -13106,17 +13245,17 @@ import { readFile as readFile2, stat as stat3, writeFile as writeFile3 } from "f
|
|
|
13106
13245
|
|
|
13107
13246
|
// src/commands/sessions/web/formatWithOxfmt.ts
|
|
13108
13247
|
import { execFile as execFile8 } from "child_process";
|
|
13109
|
-
import { existsSync as
|
|
13110
|
-
import { dirname as
|
|
13248
|
+
import { existsSync as existsSync36 } from "fs";
|
|
13249
|
+
import { dirname as dirname23, join as join34 } from "path";
|
|
13111
13250
|
import { promisify as promisify8 } from "util";
|
|
13112
13251
|
var execFileAsync7 = promisify8(execFile8);
|
|
13113
13252
|
var TIMEOUT_MS = 15e3;
|
|
13114
13253
|
function findOxfmtScript(root) {
|
|
13115
13254
|
let dir = root;
|
|
13116
13255
|
for (; ; ) {
|
|
13117
|
-
const candidate =
|
|
13118
|
-
if (
|
|
13119
|
-
const parent =
|
|
13256
|
+
const candidate = join34(dir, "node_modules", "oxfmt", "bin", "oxfmt");
|
|
13257
|
+
if (existsSync36(candidate)) return candidate;
|
|
13258
|
+
const parent = dirname23(dir);
|
|
13120
13259
|
if (parent === dir) return void 0;
|
|
13121
13260
|
dir = parent;
|
|
13122
13261
|
}
|
|
@@ -13186,7 +13325,7 @@ async function writeFileContent(req, res) {
|
|
|
13186
13325
|
|
|
13187
13326
|
// src/commands/sessions/web/createCssHandler.ts
|
|
13188
13327
|
import { createHash as createHash2 } from "crypto";
|
|
13189
|
-
import { readFileSync as
|
|
13328
|
+
import { readFileSync as readFileSync24 } from "fs";
|
|
13190
13329
|
import { createRequire as createRequire2 } from "module";
|
|
13191
13330
|
var require3 = createRequire2(import.meta.url);
|
|
13192
13331
|
function createCssHandler(packageEntry) {
|
|
@@ -13194,7 +13333,7 @@ function createCssHandler(packageEntry) {
|
|
|
13194
13333
|
return (req, res) => {
|
|
13195
13334
|
if (!cache5) {
|
|
13196
13335
|
const resolved = require3.resolve(packageEntry);
|
|
13197
|
-
const body =
|
|
13336
|
+
const body = readFileSync24(resolved, "utf8");
|
|
13198
13337
|
const etag = `"${createHash2("sha256").update(body).digest("hex").slice(0, 16)}"`;
|
|
13199
13338
|
cache5 = { body, etag };
|
|
13200
13339
|
}
|
|
@@ -14007,7 +14146,7 @@ function registerAssociateJiraCommand(cmd) {
|
|
|
14007
14146
|
|
|
14008
14147
|
// src/commands/backlog/cloneRepo.ts
|
|
14009
14148
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
14010
|
-
import { existsSync as
|
|
14149
|
+
import { existsSync as existsSync38 } from "fs";
|
|
14011
14150
|
import { mkdir as mkdir3 } from "fs/promises";
|
|
14012
14151
|
import chalk69 from "chalk";
|
|
14013
14152
|
|
|
@@ -14043,7 +14182,7 @@ async function cloneRepo(originRaw) {
|
|
|
14043
14182
|
if (!target) {
|
|
14044
14183
|
return fail2(`Could not derive a repository name from "${origin}".`);
|
|
14045
14184
|
}
|
|
14046
|
-
if (
|
|
14185
|
+
if (existsSync38(target)) {
|
|
14047
14186
|
return fail2(`Clone target already exists: ${target}`);
|
|
14048
14187
|
}
|
|
14049
14188
|
await mkdir3(baseDir, { recursive: true });
|
|
@@ -14595,9 +14734,9 @@ function ensureRemoteOrigin() {
|
|
|
14595
14734
|
|
|
14596
14735
|
// src/commands/backlog/add/shared.ts
|
|
14597
14736
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
14598
|
-
import { mkdtempSync, readFileSync as
|
|
14737
|
+
import { mkdtempSync, readFileSync as readFileSync25, unlinkSync as unlinkSync6, writeFileSync as writeFileSync21 } from "fs";
|
|
14599
14738
|
import { tmpdir as tmpdir2 } from "os";
|
|
14600
|
-
import { join as
|
|
14739
|
+
import { join as join38 } from "path";
|
|
14601
14740
|
import enquirer6 from "enquirer";
|
|
14602
14741
|
async function promptType() {
|
|
14603
14742
|
const { type } = await enquirer6.prompt({
|
|
@@ -14637,15 +14776,15 @@ async function promptDescription() {
|
|
|
14637
14776
|
}
|
|
14638
14777
|
function openEditor() {
|
|
14639
14778
|
const editor = process.env.EDITOR || process.env.VISUAL || "vi";
|
|
14640
|
-
const dir = mkdtempSync(
|
|
14641
|
-
const filePath =
|
|
14779
|
+
const dir = mkdtempSync(join38(tmpdir2(), "assist-"));
|
|
14780
|
+
const filePath = join38(dir, "description.md");
|
|
14642
14781
|
writeFileSync21(filePath, "");
|
|
14643
14782
|
const result = spawnSync3(editor, [filePath], { stdio: "inherit" });
|
|
14644
14783
|
if (result.status !== 0) {
|
|
14645
14784
|
unlinkSync6(filePath);
|
|
14646
14785
|
return void 0;
|
|
14647
14786
|
}
|
|
14648
|
-
const content =
|
|
14787
|
+
const content = readFileSync25(filePath, "utf8").trim();
|
|
14649
14788
|
unlinkSync6(filePath);
|
|
14650
14789
|
return content || void 0;
|
|
14651
14790
|
}
|
|
@@ -14821,7 +14960,7 @@ async function list2(options2) {
|
|
|
14821
14960
|
import chalk82 from "chalk";
|
|
14822
14961
|
|
|
14823
14962
|
// src/commands/backlog/readJsonPayload.ts
|
|
14824
|
-
import { readFileSync as
|
|
14963
|
+
import { readFileSync as readFileSync26 } from "fs";
|
|
14825
14964
|
import chalk80 from "chalk";
|
|
14826
14965
|
function fail3(message3) {
|
|
14827
14966
|
console.error(chalk80.red(message3));
|
|
@@ -14833,7 +14972,7 @@ function describe(error) {
|
|
|
14833
14972
|
async function readSource(source) {
|
|
14834
14973
|
try {
|
|
14835
14974
|
if (source === "-") return (await readStdinBuffer()).toString("utf8");
|
|
14836
|
-
return
|
|
14975
|
+
return readFileSync26(source, "utf8");
|
|
14837
14976
|
} catch (error) {
|
|
14838
14977
|
return fail3(
|
|
14839
14978
|
`Cannot read the payload from ${source === "-" ? "stdin" : source}: ${describe(error)}`
|
|
@@ -16660,7 +16799,7 @@ function registerBranch(program2) {
|
|
|
16660
16799
|
}
|
|
16661
16800
|
|
|
16662
16801
|
// src/commands/cliHook/index.ts
|
|
16663
|
-
import { basename as
|
|
16802
|
+
import { basename as basename13 } from "path";
|
|
16664
16803
|
|
|
16665
16804
|
// src/shared/splitCompound.ts
|
|
16666
16805
|
import { parse } from "shell-quote";
|
|
@@ -17226,17 +17365,17 @@ function extractGraphqlQuery(args) {
|
|
|
17226
17365
|
}
|
|
17227
17366
|
|
|
17228
17367
|
// src/shared/loadCliReads.ts
|
|
17229
|
-
import { existsSync as
|
|
17230
|
-
import { dirname as
|
|
17231
|
-
import { fileURLToPath as
|
|
17232
|
-
var __filename3 =
|
|
17233
|
-
var __dirname4 =
|
|
17368
|
+
import { existsSync as existsSync39, readFileSync as readFileSync27, writeFileSync as writeFileSync22 } from "fs";
|
|
17369
|
+
import { dirname as dirname24, resolve as resolve12 } from "path";
|
|
17370
|
+
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
17371
|
+
var __filename3 = fileURLToPath6(import.meta.url);
|
|
17372
|
+
var __dirname4 = dirname24(__filename3);
|
|
17234
17373
|
function packageRoot() {
|
|
17235
17374
|
return __dirname4;
|
|
17236
17375
|
}
|
|
17237
17376
|
function readLines(path91) {
|
|
17238
|
-
if (!
|
|
17239
|
-
return
|
|
17377
|
+
if (!existsSync39(path91)) return [];
|
|
17378
|
+
return readFileSync27(path91, "utf8").split("\n").filter((line) => line.trim() !== "");
|
|
17240
17379
|
}
|
|
17241
17380
|
var cachedReads;
|
|
17242
17381
|
var cachedWrites;
|
|
@@ -17282,14 +17421,14 @@ function findCliWrite(command) {
|
|
|
17282
17421
|
}
|
|
17283
17422
|
|
|
17284
17423
|
// src/shared/readSettingsPerms.ts
|
|
17285
|
-
import { existsSync as
|
|
17424
|
+
import { existsSync as existsSync40, readFileSync as readFileSync28 } from "fs";
|
|
17286
17425
|
import { homedir as homedir15 } from "os";
|
|
17287
|
-
import { join as
|
|
17426
|
+
import { join as join39 } from "path";
|
|
17288
17427
|
function readSettingsPerms(key) {
|
|
17289
17428
|
const paths = [
|
|
17290
|
-
|
|
17291
|
-
|
|
17292
|
-
|
|
17429
|
+
join39(homedir15(), ".claude", "settings.json"),
|
|
17430
|
+
join39(process.cwd(), ".claude", "settings.json"),
|
|
17431
|
+
join39(process.cwd(), ".claude", "settings.local.json")
|
|
17293
17432
|
];
|
|
17294
17433
|
const entries = [];
|
|
17295
17434
|
for (const p of paths) {
|
|
@@ -17298,9 +17437,9 @@ function readSettingsPerms(key) {
|
|
|
17298
17437
|
return entries;
|
|
17299
17438
|
}
|
|
17300
17439
|
function readPermissionArray(filePath, key) {
|
|
17301
|
-
if (!
|
|
17440
|
+
if (!existsSync40(filePath)) return [];
|
|
17302
17441
|
try {
|
|
17303
|
-
const data = JSON.parse(
|
|
17442
|
+
const data = JSON.parse(readFileSync28(filePath, "utf8"));
|
|
17304
17443
|
const arr = data?.permissions?.[key];
|
|
17305
17444
|
return Array.isArray(arr) ? arr.filter((e) => typeof e === "string") : [];
|
|
17306
17445
|
} catch {
|
|
@@ -17505,11 +17644,11 @@ function decideCommand(toolName, rawCommand) {
|
|
|
17505
17644
|
// src/commands/cliHook/logDeniedToolCall.ts
|
|
17506
17645
|
import { mkdirSync as mkdirSync12 } from "fs";
|
|
17507
17646
|
import { homedir as homedir16 } from "os";
|
|
17508
|
-
import { join as
|
|
17647
|
+
import { join as join40 } from "path";
|
|
17509
17648
|
import Database from "better-sqlite3";
|
|
17510
17649
|
var _db;
|
|
17511
17650
|
function getDbDir() {
|
|
17512
|
-
return
|
|
17651
|
+
return join40(homedir16(), ".assist");
|
|
17513
17652
|
}
|
|
17514
17653
|
function initSchema(db) {
|
|
17515
17654
|
db.exec(`
|
|
@@ -17528,7 +17667,7 @@ function openPromptsDb(dir) {
|
|
|
17528
17667
|
if (_db) return _db;
|
|
17529
17668
|
const dbDir = dir ?? getDbDir();
|
|
17530
17669
|
mkdirSync12(dbDir, { recursive: true });
|
|
17531
|
-
const db = new Database(
|
|
17670
|
+
const db = new Database(join40(dbDir, "assist.db"));
|
|
17532
17671
|
db.pragma("journal_mode = WAL");
|
|
17533
17672
|
initSchema(db);
|
|
17534
17673
|
_db = db;
|
|
@@ -17599,7 +17738,7 @@ async function cliHook() {
|
|
|
17599
17738
|
logDeniedToolCall({
|
|
17600
17739
|
tool: input.toolName,
|
|
17601
17740
|
command: input.command,
|
|
17602
|
-
repo:
|
|
17741
|
+
repo: basename13(process.cwd()),
|
|
17603
17742
|
sessionId: process.env.CLAUDE_SESSION_ID,
|
|
17604
17743
|
denyReason: decision.permissionDecisionReason
|
|
17605
17744
|
});
|
|
@@ -17647,9 +17786,9 @@ ${reasons.join("\n")}`);
|
|
|
17647
17786
|
}
|
|
17648
17787
|
|
|
17649
17788
|
// src/commands/permitCliReads/index.ts
|
|
17650
|
-
import { existsSync as
|
|
17789
|
+
import { existsSync as existsSync41, mkdirSync as mkdirSync13, readFileSync as readFileSync29, writeFileSync as writeFileSync23 } from "fs";
|
|
17651
17790
|
import { homedir as homedir17 } from "os";
|
|
17652
|
-
import { join as
|
|
17791
|
+
import { join as join41 } from "path";
|
|
17653
17792
|
|
|
17654
17793
|
// src/commands/permitCliReads/assertCliExists.ts
|
|
17655
17794
|
function assertCliExists(cli) {
|
|
@@ -17912,15 +18051,15 @@ function updateSettings(cli, commands) {
|
|
|
17912
18051
|
// src/commands/permitCliReads/index.ts
|
|
17913
18052
|
function logPath(cli) {
|
|
17914
18053
|
const safeName = cli.replace(/\s+/g, "-");
|
|
17915
|
-
return
|
|
18054
|
+
return join41(homedir17(), ".assist", `cli-discover-${safeName}.log`);
|
|
17916
18055
|
}
|
|
17917
18056
|
function readCache(cli) {
|
|
17918
18057
|
const path91 = logPath(cli);
|
|
17919
|
-
if (!
|
|
17920
|
-
return
|
|
18058
|
+
if (!existsSync41(path91)) return void 0;
|
|
18059
|
+
return readFileSync29(path91, "utf8");
|
|
17921
18060
|
}
|
|
17922
18061
|
function writeCache(cli, output) {
|
|
17923
|
-
const dir =
|
|
18062
|
+
const dir = join41(homedir17(), ".assist");
|
|
17924
18063
|
mkdirSync13(dir, { recursive: true });
|
|
17925
18064
|
writeFileSync23(logPath(cli), output);
|
|
17926
18065
|
}
|
|
@@ -18051,33 +18190,33 @@ function registerCliHook(program2) {
|
|
|
18051
18190
|
}
|
|
18052
18191
|
|
|
18053
18192
|
// src/commands/codeComment/codeCommentConfirm.ts
|
|
18054
|
-
import { existsSync as
|
|
18193
|
+
import { existsSync as existsSync43, readFileSync as readFileSync31, unlinkSync as unlinkSync8, writeFileSync as writeFileSync24 } from "fs";
|
|
18055
18194
|
import chalk121 from "chalk";
|
|
18056
18195
|
|
|
18057
18196
|
// src/commands/codeComment/getRestrictedDir.ts
|
|
18058
18197
|
import { homedir as homedir18 } from "os";
|
|
18059
|
-
import { join as
|
|
18198
|
+
import { join as join42 } from "path";
|
|
18060
18199
|
function getRestrictedDir() {
|
|
18061
|
-
return
|
|
18200
|
+
return join42(homedir18(), ".assist", "restricted");
|
|
18062
18201
|
}
|
|
18063
18202
|
function getPinStatePath(pin) {
|
|
18064
|
-
return
|
|
18203
|
+
return join42(getRestrictedDir(), `code-comment-${pin}.json`);
|
|
18065
18204
|
}
|
|
18066
18205
|
|
|
18067
18206
|
// src/commands/codeComment/sweepRestrictedDir.ts
|
|
18068
|
-
import { readdirSync as
|
|
18069
|
-
import { join as
|
|
18207
|
+
import { readdirSync as readdirSync6, statSync as statSync7, unlinkSync as unlinkSync7 } from "fs";
|
|
18208
|
+
import { join as join43 } from "path";
|
|
18070
18209
|
var STALE_AFTER_MS = 30 * 60 * 1e3;
|
|
18071
18210
|
function sweepRestrictedDir(dir = getRestrictedDir()) {
|
|
18072
18211
|
let entries;
|
|
18073
18212
|
try {
|
|
18074
|
-
entries =
|
|
18213
|
+
entries = readdirSync6(dir);
|
|
18075
18214
|
} catch {
|
|
18076
18215
|
return;
|
|
18077
18216
|
}
|
|
18078
18217
|
const cutoff = Date.now() - STALE_AFTER_MS;
|
|
18079
18218
|
for (const entry of entries) {
|
|
18080
|
-
const path91 =
|
|
18219
|
+
const path91 = join43(dir, entry);
|
|
18081
18220
|
try {
|
|
18082
18221
|
if (statSync7(path91).mtimeMs < cutoff) unlinkSync7(path91);
|
|
18083
18222
|
} catch {
|
|
@@ -18087,12 +18226,12 @@ function sweepRestrictedDir(dir = getRestrictedDir()) {
|
|
|
18087
18226
|
}
|
|
18088
18227
|
|
|
18089
18228
|
// src/commands/codeComment/readPinState.ts
|
|
18090
|
-
import { existsSync as
|
|
18229
|
+
import { existsSync as existsSync42, readFileSync as readFileSync30 } from "fs";
|
|
18091
18230
|
function readPinState(pin) {
|
|
18092
18231
|
const path91 = getPinStatePath(pin);
|
|
18093
|
-
if (!
|
|
18232
|
+
if (!existsSync42(path91)) return void 0;
|
|
18094
18233
|
try {
|
|
18095
|
-
const state = JSON.parse(
|
|
18234
|
+
const state = JSON.parse(readFileSync30(path91, "utf8"));
|
|
18096
18235
|
if (state.pin !== pin) return void 0;
|
|
18097
18236
|
return state;
|
|
18098
18237
|
} catch {
|
|
@@ -18109,12 +18248,12 @@ function codeCommentConfirm(pin) {
|
|
|
18109
18248
|
process.exitCode = 1;
|
|
18110
18249
|
return;
|
|
18111
18250
|
}
|
|
18112
|
-
if (!
|
|
18251
|
+
if (!existsSync43(state.file)) {
|
|
18113
18252
|
console.error(chalk121.red(`Target file no longer exists: ${state.file}`));
|
|
18114
18253
|
process.exitCode = 1;
|
|
18115
18254
|
return;
|
|
18116
18255
|
}
|
|
18117
|
-
const original =
|
|
18256
|
+
const original = readFileSync31(state.file, "utf8");
|
|
18118
18257
|
const lines2 = original.split("\n");
|
|
18119
18258
|
const index3 = state.line - 1;
|
|
18120
18259
|
if (index3 > lines2.length) {
|
|
@@ -19619,19 +19758,19 @@ import { cp } from "fs/promises";
|
|
|
19619
19758
|
import chalk139 from "chalk";
|
|
19620
19759
|
|
|
19621
19760
|
// src/commands/criteriaExtension/criteriaExtensionDir.ts
|
|
19622
|
-
import { existsSync as
|
|
19623
|
-
import { dirname as
|
|
19624
|
-
import { fileURLToPath as
|
|
19625
|
-
var moduleDir =
|
|
19761
|
+
import { existsSync as existsSync44 } from "fs";
|
|
19762
|
+
import { dirname as dirname25, join as join44 } from "path";
|
|
19763
|
+
import { fileURLToPath as fileURLToPath7 } from "url";
|
|
19764
|
+
var moduleDir = dirname25(fileURLToPath7(import.meta.url));
|
|
19626
19765
|
function criteriaExtensionDir() {
|
|
19627
|
-
const bundled =
|
|
19766
|
+
const bundled = join44(
|
|
19628
19767
|
moduleDir,
|
|
19629
19768
|
"commands",
|
|
19630
19769
|
"criteriaExtension",
|
|
19631
19770
|
"criteria-extension"
|
|
19632
19771
|
);
|
|
19633
|
-
if (
|
|
19634
|
-
return
|
|
19772
|
+
if (existsSync44(bundled)) return bundled;
|
|
19773
|
+
return join44(moduleDir, "..", "..", "..", "criteria-extension");
|
|
19635
19774
|
}
|
|
19636
19775
|
|
|
19637
19776
|
// src/commands/criteriaExtension/criteriaExtension.ts
|
|
@@ -19660,28 +19799,28 @@ async function criteriaExtension() {
|
|
|
19660
19799
|
// src/commands/criteriaExtension/signCriteriaExtension.ts
|
|
19661
19800
|
import { rm as rm3 } from "fs/promises";
|
|
19662
19801
|
import { homedir as homedir19, tmpdir as tmpdir4 } from "os";
|
|
19663
|
-
import { join as
|
|
19802
|
+
import { join as join49 } from "path";
|
|
19664
19803
|
import chalk141 from "chalk";
|
|
19665
19804
|
|
|
19666
19805
|
// src/commands/criteriaExtension/copySignedXpi.ts
|
|
19667
19806
|
import { copyFile } from "fs/promises";
|
|
19668
|
-
import { join as
|
|
19807
|
+
import { join as join45 } from "path";
|
|
19669
19808
|
var SIGNED_XPI_NAME = "criteria-extension.xpi";
|
|
19670
19809
|
async function copySignedXpi(xpi, dir) {
|
|
19671
|
-
const fixed2 =
|
|
19810
|
+
const fixed2 = join45(dir, SIGNED_XPI_NAME);
|
|
19672
19811
|
if (fixed2 === xpi) return fixed2;
|
|
19673
19812
|
await copyFile(xpi, fixed2);
|
|
19674
19813
|
return fixed2;
|
|
19675
19814
|
}
|
|
19676
19815
|
|
|
19677
19816
|
// src/commands/criteriaExtension/findSignedXpi.ts
|
|
19678
|
-
import { existsSync as
|
|
19817
|
+
import { existsSync as existsSync45 } from "fs";
|
|
19679
19818
|
import { readdir } from "fs/promises";
|
|
19680
|
-
import { join as
|
|
19819
|
+
import { join as join46 } from "path";
|
|
19681
19820
|
async function findSignedXpi(dir) {
|
|
19682
|
-
if (!
|
|
19821
|
+
if (!existsSync45(dir)) return null;
|
|
19683
19822
|
const name = (await readdir(dir)).find((entry) => entry.endsWith(".xpi"));
|
|
19684
|
-
return name ?
|
|
19823
|
+
return name ? join46(dir, name) : null;
|
|
19685
19824
|
}
|
|
19686
19825
|
|
|
19687
19826
|
// src/commands/criteriaExtension/signedAddonInstallPath.ts
|
|
@@ -19703,11 +19842,11 @@ async function signedAddonInstallPath(xpi) {
|
|
|
19703
19842
|
}
|
|
19704
19843
|
|
|
19705
19844
|
// src/commands/criteriaExtension/signPreflightProblem.ts
|
|
19706
|
-
import { existsSync as
|
|
19707
|
-
import { join as
|
|
19845
|
+
import { existsSync as existsSync46 } from "fs";
|
|
19846
|
+
import { join as join47 } from "path";
|
|
19708
19847
|
var KEY_URL = "https://addons.mozilla.org/en-US/developers/addon/api/key/";
|
|
19709
19848
|
function signPreflightProblem(source) {
|
|
19710
|
-
if (!
|
|
19849
|
+
if (!existsSync46(join47(source, "content.js")))
|
|
19711
19850
|
return {
|
|
19712
19851
|
message: `no content.js in ${source}`,
|
|
19713
19852
|
hint: "run npm run build to bundle the content script"
|
|
@@ -19722,7 +19861,7 @@ function signPreflightProblem(source) {
|
|
|
19722
19861
|
|
|
19723
19862
|
// src/commands/criteriaExtension/stageCriteriaExtension.ts
|
|
19724
19863
|
import { cp as cp3, mkdir as mkdir4, readFile as readFile4, rm as rm2, writeFile as writeFile4 } from "fs/promises";
|
|
19725
|
-
import { join as
|
|
19864
|
+
import { join as join48 } from "path";
|
|
19726
19865
|
|
|
19727
19866
|
// src/commands/criteriaExtension/stampManifestVersion.ts
|
|
19728
19867
|
function stampManifestVersion(manifest, version2) {
|
|
@@ -19736,7 +19875,7 @@ async function stageCriteriaExtension(source, staging, version2) {
|
|
|
19736
19875
|
await rm2(staging, { recursive: true, force: true });
|
|
19737
19876
|
await mkdir4(staging, { recursive: true });
|
|
19738
19877
|
await cp3(source, staging, { recursive: true });
|
|
19739
|
-
const manifest =
|
|
19878
|
+
const manifest = join48(staging, "manifest.json");
|
|
19740
19879
|
const stamped = stampManifestVersion(
|
|
19741
19880
|
await readFile4(manifest, "utf8"),
|
|
19742
19881
|
version2
|
|
@@ -19745,8 +19884,8 @@ async function stageCriteriaExtension(source, staging, version2) {
|
|
|
19745
19884
|
}
|
|
19746
19885
|
|
|
19747
19886
|
// src/commands/criteriaExtension/signCriteriaExtension.ts
|
|
19748
|
-
var ARTIFACTS_DIR =
|
|
19749
|
-
var STAGING_DIR =
|
|
19887
|
+
var ARTIFACTS_DIR = join49(homedir19(), ".assist", "criteria-extension");
|
|
19888
|
+
var STAGING_DIR = join49(tmpdir4(), "assist-criteria-extension");
|
|
19750
19889
|
async function signCriteriaExtension() {
|
|
19751
19890
|
const source = criteriaExtensionDir();
|
|
19752
19891
|
const problem = signPreflightProblem(source);
|
|
@@ -19869,21 +20008,21 @@ import { unlinkSync as unlinkSync9, writeFileSync as writeFileSync26 } from "fs"
|
|
|
19869
20008
|
import chalk143 from "chalk";
|
|
19870
20009
|
|
|
19871
20010
|
// src/commands/dbMigration/getMigrationPinPath.ts
|
|
19872
|
-
import { join as
|
|
20011
|
+
import { join as join50 } from "path";
|
|
19873
20012
|
function getMigrationPinPath(pin) {
|
|
19874
|
-
return
|
|
20013
|
+
return join50(getRestrictedDir(), `db-migration-pin-${pin}.json`);
|
|
19875
20014
|
}
|
|
19876
20015
|
function getMigrationApprovalPath(migrationId) {
|
|
19877
|
-
return
|
|
20016
|
+
return join50(getRestrictedDir(), `db-migration-approval-${migrationId}.json`);
|
|
19878
20017
|
}
|
|
19879
20018
|
|
|
19880
20019
|
// src/commands/dbMigration/readMigrationPinState.ts
|
|
19881
|
-
import { existsSync as
|
|
20020
|
+
import { existsSync as existsSync47, readFileSync as readFileSync32 } from "fs";
|
|
19882
20021
|
function readMigrationPinState(pin) {
|
|
19883
20022
|
const path91 = getMigrationPinPath(pin);
|
|
19884
|
-
if (!
|
|
20023
|
+
if (!existsSync47(path91)) return void 0;
|
|
19885
20024
|
try {
|
|
19886
|
-
const state = JSON.parse(
|
|
20025
|
+
const state = JSON.parse(readFileSync32(path91, "utf8"));
|
|
19887
20026
|
if (state.pin !== pin) return void 0;
|
|
19888
20027
|
if (!Number.isInteger(state.migrationId)) return void 0;
|
|
19889
20028
|
return state;
|
|
@@ -19970,7 +20109,7 @@ function registerDbMigration(parent) {
|
|
|
19970
20109
|
}
|
|
19971
20110
|
|
|
19972
20111
|
// src/commands/deploy/redirect.ts
|
|
19973
|
-
import { existsSync as
|
|
20112
|
+
import { existsSync as existsSync48, readFileSync as readFileSync33, writeFileSync as writeFileSync28 } from "fs";
|
|
19974
20113
|
import chalk145 from "chalk";
|
|
19975
20114
|
var TRAILING_SLASH_SCRIPT = ` <script>
|
|
19976
20115
|
if (!window.location.pathname.endsWith('/')) {
|
|
@@ -19979,11 +20118,11 @@ var TRAILING_SLASH_SCRIPT = ` <script>
|
|
|
19979
20118
|
</script>`;
|
|
19980
20119
|
function redirect() {
|
|
19981
20120
|
const indexPath = "index.html";
|
|
19982
|
-
if (!
|
|
20121
|
+
if (!existsSync48(indexPath)) {
|
|
19983
20122
|
console.log(chalk145.yellow("No index.html found"));
|
|
19984
20123
|
return;
|
|
19985
20124
|
}
|
|
19986
|
-
const content =
|
|
20125
|
+
const content = readFileSync33(indexPath, "utf8");
|
|
19987
20126
|
if (content.includes("window.location.pathname.endsWith('/')")) {
|
|
19988
20127
|
console.log(chalk145.dim("Trailing slash script already present"));
|
|
19989
20128
|
return;
|
|
@@ -20008,14 +20147,14 @@ function registerDeploy(program2) {
|
|
|
20008
20147
|
|
|
20009
20148
|
// src/commands/devlog/list/index.ts
|
|
20010
20149
|
import { execFileSync as execFileSync3 } from "child_process";
|
|
20011
|
-
import { basename as
|
|
20150
|
+
import { basename as basename15 } from "path";
|
|
20012
20151
|
|
|
20013
20152
|
// src/commands/devlog/loadBlogSkipDays.ts
|
|
20014
20153
|
import { homedir as homedir20 } from "os";
|
|
20015
|
-
import { join as
|
|
20016
|
-
var BLOG_REPO_ROOT =
|
|
20154
|
+
import { join as join51 } from "path";
|
|
20155
|
+
var BLOG_REPO_ROOT = join51(homedir20(), "git/blog");
|
|
20017
20156
|
function loadBlogSkipDays(repoName) {
|
|
20018
|
-
const config = loadRawYaml(
|
|
20157
|
+
const config = loadRawYaml(join51(BLOG_REPO_ROOT, "assist.yml"));
|
|
20019
20158
|
const devlog = config.devlog;
|
|
20020
20159
|
const skip2 = devlog?.skip;
|
|
20021
20160
|
return new Set(skip2?.[repoName]);
|
|
@@ -20026,17 +20165,17 @@ import { execSync as execSync37 } from "child_process";
|
|
|
20026
20165
|
import chalk146 from "chalk";
|
|
20027
20166
|
|
|
20028
20167
|
// src/shared/getRepoName.ts
|
|
20029
|
-
import { existsSync as
|
|
20030
|
-
import { basename as
|
|
20168
|
+
import { existsSync as existsSync49, readFileSync as readFileSync34 } from "fs";
|
|
20169
|
+
import { basename as basename14, join as join52 } from "path";
|
|
20031
20170
|
function getRepoName() {
|
|
20032
20171
|
const config = loadConfig();
|
|
20033
20172
|
if (config.devlog?.name) {
|
|
20034
20173
|
return config.devlog.name;
|
|
20035
20174
|
}
|
|
20036
|
-
const packageJsonPath =
|
|
20037
|
-
if (
|
|
20175
|
+
const packageJsonPath = join52(process.cwd(), "package.json");
|
|
20176
|
+
if (existsSync49(packageJsonPath)) {
|
|
20038
20177
|
try {
|
|
20039
|
-
const content =
|
|
20178
|
+
const content = readFileSync34(packageJsonPath, "utf8");
|
|
20040
20179
|
const pkg = JSON.parse(content);
|
|
20041
20180
|
if (pkg.name) {
|
|
20042
20181
|
return pkg.name;
|
|
@@ -20044,41 +20183,41 @@ function getRepoName() {
|
|
|
20044
20183
|
} catch {
|
|
20045
20184
|
}
|
|
20046
20185
|
}
|
|
20047
|
-
return
|
|
20186
|
+
return basename14(process.cwd());
|
|
20048
20187
|
}
|
|
20049
20188
|
|
|
20050
20189
|
// src/commands/devlog/loadDevlogEntries.ts
|
|
20051
|
-
import { readdirSync as
|
|
20052
|
-
import { join as
|
|
20053
|
-
var DEVLOG_DIR =
|
|
20190
|
+
import { readdirSync as readdirSync7, readFileSync as readFileSync35 } from "fs";
|
|
20191
|
+
import { join as join53 } from "path";
|
|
20192
|
+
var DEVLOG_DIR = join53(BLOG_REPO_ROOT, "src/content/devlog");
|
|
20054
20193
|
function extractFrontmatter(content) {
|
|
20055
20194
|
const fm = content.match(/^---\n([\s\S]*?)\n---/);
|
|
20056
20195
|
return fm?.[1] ?? null;
|
|
20057
20196
|
}
|
|
20058
|
-
function matchField(
|
|
20059
|
-
return
|
|
20197
|
+
function matchField(frontmatter2, pattern2) {
|
|
20198
|
+
return frontmatter2.match(pattern2)?.[1]?.trim() ?? null;
|
|
20060
20199
|
}
|
|
20061
20200
|
function parseFrontmatter(content, filename) {
|
|
20062
|
-
const
|
|
20063
|
-
if (!
|
|
20064
|
-
const date = matchField(
|
|
20065
|
-
const tagsRaw = matchField(
|
|
20201
|
+
const frontmatter2 = extractFrontmatter(content);
|
|
20202
|
+
if (!frontmatter2) return null;
|
|
20203
|
+
const date = matchField(frontmatter2, /date:\s*"?(\d{4}-\d{2}-\d{2})"?/);
|
|
20204
|
+
const tagsRaw = matchField(frontmatter2, /tags:\s*\[([^\]]*)\]/);
|
|
20066
20205
|
if (!date || !tagsRaw) return null;
|
|
20067
20206
|
const repoTag = tagsRaw.split(",")[0]?.trim();
|
|
20068
20207
|
if (!repoTag) return null;
|
|
20069
20208
|
return {
|
|
20070
20209
|
date,
|
|
20071
20210
|
repoTag,
|
|
20072
|
-
version: matchField(
|
|
20073
|
-
title: matchField(
|
|
20211
|
+
version: matchField(frontmatter2, /version:\s*(.+)/),
|
|
20212
|
+
title: matchField(frontmatter2, /title:\s*(.+)/),
|
|
20074
20213
|
filename
|
|
20075
20214
|
};
|
|
20076
20215
|
}
|
|
20077
20216
|
function readDevlogFiles(callback) {
|
|
20078
20217
|
try {
|
|
20079
|
-
const files =
|
|
20218
|
+
const files = readdirSync7(DEVLOG_DIR).filter((f) => f.endsWith(".md"));
|
|
20080
20219
|
for (const file of files) {
|
|
20081
|
-
const content =
|
|
20220
|
+
const content = readFileSync35(join53(DEVLOG_DIR, file), "utf8");
|
|
20082
20221
|
const parsed = parseFrontmatter(content, file);
|
|
20083
20222
|
if (parsed) callback(parsed);
|
|
20084
20223
|
}
|
|
@@ -20180,7 +20319,7 @@ function list3(options2) {
|
|
|
20180
20319
|
const config = loadConfig();
|
|
20181
20320
|
const days = options2.days ?? 30;
|
|
20182
20321
|
const ignore3 = options2.ignore ?? config.devlog?.ignore ?? [];
|
|
20183
|
-
const repoName =
|
|
20322
|
+
const repoName = basename15(process.cwd());
|
|
20184
20323
|
const skipDays = loadBlogSkipDays(repoName);
|
|
20185
20324
|
const devlogEntries = loadDevlogEntries(repoName);
|
|
20186
20325
|
const args = ["log"];
|
|
@@ -20466,11 +20605,11 @@ function repos(options2) {
|
|
|
20466
20605
|
|
|
20467
20606
|
// src/commands/devlog/skip.ts
|
|
20468
20607
|
import { writeFileSync as writeFileSync29 } from "fs";
|
|
20469
|
-
import { join as
|
|
20608
|
+
import { join as join54 } from "path";
|
|
20470
20609
|
import chalk151 from "chalk";
|
|
20471
20610
|
import { stringify as stringifyYaml3 } from "yaml";
|
|
20472
20611
|
function getBlogConfigPath() {
|
|
20473
|
-
return
|
|
20612
|
+
return join54(BLOG_REPO_ROOT, "assist.yml");
|
|
20474
20613
|
}
|
|
20475
20614
|
function skip(date) {
|
|
20476
20615
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(date)) {
|
|
@@ -20531,20 +20670,20 @@ function registerDevlog(program2) {
|
|
|
20531
20670
|
}
|
|
20532
20671
|
|
|
20533
20672
|
// src/commands/dotnet/checkBuildLocks.ts
|
|
20534
|
-
import { closeSync as closeSync3, openSync as openSync3, readdirSync as
|
|
20535
|
-
import { join as
|
|
20673
|
+
import { closeSync as closeSync3, openSync as openSync3, readdirSync as readdirSync8 } from "fs";
|
|
20674
|
+
import { join as join55 } from "path";
|
|
20536
20675
|
import chalk153 from "chalk";
|
|
20537
20676
|
var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git", "packages"]);
|
|
20538
20677
|
function isLockedDll(debugDir) {
|
|
20539
20678
|
let files;
|
|
20540
20679
|
try {
|
|
20541
|
-
files =
|
|
20680
|
+
files = readdirSync8(debugDir, { recursive: true });
|
|
20542
20681
|
} catch {
|
|
20543
20682
|
return null;
|
|
20544
20683
|
}
|
|
20545
20684
|
for (const file of files) {
|
|
20546
20685
|
if (!file.toLowerCase().endsWith(".dll")) continue;
|
|
20547
|
-
const dllPath =
|
|
20686
|
+
const dllPath = join55(debugDir, file);
|
|
20548
20687
|
try {
|
|
20549
20688
|
const fd = openSync3(dllPath, "r+");
|
|
20550
20689
|
closeSync3(fd);
|
|
@@ -20557,18 +20696,18 @@ function isLockedDll(debugDir) {
|
|
|
20557
20696
|
function findFirstLockedDll(dir) {
|
|
20558
20697
|
let entries;
|
|
20559
20698
|
try {
|
|
20560
|
-
entries =
|
|
20699
|
+
entries = readdirSync8(dir);
|
|
20561
20700
|
} catch {
|
|
20562
20701
|
return null;
|
|
20563
20702
|
}
|
|
20564
20703
|
if (entries.includes("bin")) {
|
|
20565
|
-
const locked = isLockedDll(
|
|
20704
|
+
const locked = isLockedDll(join55(dir, "bin", "Debug"));
|
|
20566
20705
|
if (locked) return locked;
|
|
20567
20706
|
}
|
|
20568
20707
|
for (const entry of entries) {
|
|
20569
20708
|
if (SKIP_DIRS.has(entry) || entry === "bin" || entry.startsWith("."))
|
|
20570
20709
|
continue;
|
|
20571
|
-
const found = findFirstLockedDll(
|
|
20710
|
+
const found = findFirstLockedDll(join55(dir, entry));
|
|
20572
20711
|
if (found) return found;
|
|
20573
20712
|
}
|
|
20574
20713
|
return null;
|
|
@@ -20591,11 +20730,11 @@ async function checkBuildLocksCommand() {
|
|
|
20591
20730
|
}
|
|
20592
20731
|
|
|
20593
20732
|
// src/commands/dotnet/buildTree.ts
|
|
20594
|
-
import { readFileSync as
|
|
20733
|
+
import { readFileSync as readFileSync36 } from "fs";
|
|
20595
20734
|
import path41 from "path";
|
|
20596
20735
|
var PROJECT_REF_RE = /<ProjectReference\s+Include="([^"]+)"/g;
|
|
20597
20736
|
function getProjectRefs(csprojPath) {
|
|
20598
|
-
const content =
|
|
20737
|
+
const content = readFileSync36(csprojPath, "utf8");
|
|
20599
20738
|
const refs = [];
|
|
20600
20739
|
for (const match of content.matchAll(PROJECT_REF_RE)) {
|
|
20601
20740
|
refs.push(match[1].replace(/\\/g, "/"));
|
|
@@ -20612,7 +20751,7 @@ function buildTree(csprojPath, repoRoot2, visited = /* @__PURE__ */ new Set()) {
|
|
|
20612
20751
|
for (const ref of getProjectRefs(abs)) {
|
|
20613
20752
|
const childAbs = path41.resolve(dir, ref);
|
|
20614
20753
|
try {
|
|
20615
|
-
|
|
20754
|
+
readFileSync36(childAbs);
|
|
20616
20755
|
node.children.push(buildTree(childAbs, repoRoot2, visited));
|
|
20617
20756
|
} catch {
|
|
20618
20757
|
node.children.push({
|
|
@@ -20637,14 +20776,14 @@ function collectAllDeps(node) {
|
|
|
20637
20776
|
}
|
|
20638
20777
|
|
|
20639
20778
|
// src/commands/dotnet/findContainingSolutions.ts
|
|
20640
|
-
import { readdirSync as
|
|
20779
|
+
import { readdirSync as readdirSync9, readFileSync as readFileSync37, statSync as statSync8 } from "fs";
|
|
20641
20780
|
import path42 from "path";
|
|
20642
20781
|
function findSlnFiles(dir, maxDepth, depth = 0) {
|
|
20643
20782
|
if (depth > maxDepth) return [];
|
|
20644
20783
|
const results = [];
|
|
20645
20784
|
let entries;
|
|
20646
20785
|
try {
|
|
20647
|
-
entries =
|
|
20786
|
+
entries = readdirSync9(dir);
|
|
20648
20787
|
} catch {
|
|
20649
20788
|
return results;
|
|
20650
20789
|
}
|
|
@@ -20672,7 +20811,7 @@ function findContainingSolutions(csprojPath, repoRoot2) {
|
|
|
20672
20811
|
const pattern2 = new RegExp(`[\\\\"/]${escapeRegex(csprojBasename)}"`);
|
|
20673
20812
|
for (const sln of slnFiles) {
|
|
20674
20813
|
try {
|
|
20675
|
-
const content =
|
|
20814
|
+
const content = readFileSync37(sln, "utf8");
|
|
20676
20815
|
if (pattern2.test(content)) {
|
|
20677
20816
|
matches.push(path42.relative(repoRoot2, sln));
|
|
20678
20817
|
}
|
|
@@ -20736,12 +20875,12 @@ function printJson(tree, totalCount, solutions) {
|
|
|
20736
20875
|
}
|
|
20737
20876
|
|
|
20738
20877
|
// src/commands/dotnet/resolveCsproj.ts
|
|
20739
|
-
import { existsSync as
|
|
20878
|
+
import { existsSync as existsSync50 } from "fs";
|
|
20740
20879
|
import path43 from "path";
|
|
20741
20880
|
import chalk155 from "chalk";
|
|
20742
20881
|
function resolveCsproj(csprojPath) {
|
|
20743
20882
|
const resolved = path43.resolve(csprojPath);
|
|
20744
|
-
if (!
|
|
20883
|
+
if (!existsSync50(resolved)) {
|
|
20745
20884
|
console.error(chalk155.red(`File not found: ${resolved}`));
|
|
20746
20885
|
process.exit(1);
|
|
20747
20886
|
}
|
|
@@ -20909,17 +21048,17 @@ function filterIssues(issues, all, cliOnly, cliSuppress) {
|
|
|
20909
21048
|
}
|
|
20910
21049
|
|
|
20911
21050
|
// src/commands/dotnet/resolveSolution.ts
|
|
20912
|
-
import { existsSync as
|
|
21051
|
+
import { existsSync as existsSync51 } from "fs";
|
|
20913
21052
|
import path44 from "path";
|
|
20914
21053
|
import chalk159 from "chalk";
|
|
20915
21054
|
|
|
20916
21055
|
// src/commands/dotnet/findSolution.ts
|
|
20917
|
-
import { readdirSync as
|
|
20918
|
-
import { dirname as
|
|
21056
|
+
import { readdirSync as readdirSync10 } from "fs";
|
|
21057
|
+
import { dirname as dirname26, join as join56 } from "path";
|
|
20919
21058
|
import chalk158 from "chalk";
|
|
20920
21059
|
function findSlnInDir(dir) {
|
|
20921
21060
|
try {
|
|
20922
|
-
return
|
|
21061
|
+
return readdirSync10(dir).filter((f) => f.endsWith(".sln")).map((f) => join56(dir, f));
|
|
20923
21062
|
} catch {
|
|
20924
21063
|
return [];
|
|
20925
21064
|
}
|
|
@@ -20940,7 +21079,7 @@ function findSolution() {
|
|
|
20940
21079
|
process.exit(1);
|
|
20941
21080
|
}
|
|
20942
21081
|
if (current === ceiling) break;
|
|
20943
|
-
current =
|
|
21082
|
+
current = dirname26(current);
|
|
20944
21083
|
}
|
|
20945
21084
|
console.error(chalk158.red("No .sln file found between cwd and repo root"));
|
|
20946
21085
|
process.exit(1);
|
|
@@ -20950,7 +21089,7 @@ function findSolution() {
|
|
|
20950
21089
|
function resolveSolution(sln) {
|
|
20951
21090
|
if (sln) {
|
|
20952
21091
|
const resolved = path44.resolve(sln);
|
|
20953
|
-
if (!
|
|
21092
|
+
if (!existsSync51(resolved)) {
|
|
20954
21093
|
console.error(chalk159.red(`Solution file not found: ${resolved}`));
|
|
20955
21094
|
process.exit(1);
|
|
20956
21095
|
}
|
|
@@ -20990,7 +21129,7 @@ function parseInspectReport(json) {
|
|
|
20990
21129
|
|
|
20991
21130
|
// src/commands/dotnet/runInspectCode.ts
|
|
20992
21131
|
import { execSync as execSync41 } from "child_process";
|
|
20993
|
-
import { existsSync as
|
|
21132
|
+
import { existsSync as existsSync52, readFileSync as readFileSync38, unlinkSync as unlinkSync10 } from "fs";
|
|
20994
21133
|
import { tmpdir as tmpdir5 } from "os";
|
|
20995
21134
|
import path45 from "path";
|
|
20996
21135
|
import chalk160 from "chalk";
|
|
@@ -21021,11 +21160,11 @@ function runInspectCode(slnPath, include, swea) {
|
|
|
21021
21160
|
console.error(chalk160.red("jb inspectcode failed"));
|
|
21022
21161
|
process.exit(1);
|
|
21023
21162
|
}
|
|
21024
|
-
if (!
|
|
21163
|
+
if (!existsSync52(reportPath)) {
|
|
21025
21164
|
console.error(chalk160.red("Report file not generated"));
|
|
21026
21165
|
process.exit(1);
|
|
21027
21166
|
}
|
|
21028
|
-
const xml =
|
|
21167
|
+
const xml = readFileSync38(reportPath, "utf8");
|
|
21029
21168
|
unlinkSync10(reportPath);
|
|
21030
21169
|
return xml;
|
|
21031
21170
|
}
|
|
@@ -21310,11 +21449,11 @@ function decideCommentGuard(input, existingContent) {
|
|
|
21310
21449
|
}
|
|
21311
21450
|
|
|
21312
21451
|
// src/commands/dbMigration/consumeMigrationApproval.ts
|
|
21313
|
-
import { existsSync as
|
|
21452
|
+
import { existsSync as existsSync53, unlinkSync as unlinkSync11 } from "fs";
|
|
21314
21453
|
function consumeMigrationApproval(migrationId) {
|
|
21315
21454
|
sweepRestrictedDir();
|
|
21316
21455
|
const path91 = getMigrationApprovalPath(migrationId);
|
|
21317
|
-
if (!
|
|
21456
|
+
if (!existsSync53(path91)) return false;
|
|
21318
21457
|
try {
|
|
21319
21458
|
unlinkSync11(path91);
|
|
21320
21459
|
return true;
|
|
@@ -21434,7 +21573,7 @@ function aggregateCommitters(authorLists) {
|
|
|
21434
21573
|
import { spawnSync as spawnSync4 } from "child_process";
|
|
21435
21574
|
import { unlinkSync as unlinkSync12, writeFileSync as writeFileSync30 } from "fs";
|
|
21436
21575
|
import { tmpdir as tmpdir6 } from "os";
|
|
21437
|
-
import { join as
|
|
21576
|
+
import { join as join57 } from "path";
|
|
21438
21577
|
|
|
21439
21578
|
// src/shared/throwOnGraphqlErrors.ts
|
|
21440
21579
|
function throwOnGraphqlErrors(stdout) {
|
|
@@ -21463,7 +21602,7 @@ function buildArgs2(queryFile, vars) {
|
|
|
21463
21602
|
return args;
|
|
21464
21603
|
}
|
|
21465
21604
|
function runGhGraphql(mutation, vars) {
|
|
21466
|
-
const queryFile =
|
|
21605
|
+
const queryFile = join57(tmpdir6(), `gh-query-${Date.now()}.graphql`);
|
|
21467
21606
|
writeFileSync30(queryFile, mutation);
|
|
21468
21607
|
try {
|
|
21469
21608
|
const result = spawnSync4("gh", buildArgs2(queryFile, vars), {
|
|
@@ -22845,28 +22984,28 @@ function fetchIssue2(number, repo) {
|
|
|
22845
22984
|
}
|
|
22846
22985
|
|
|
22847
22986
|
// src/commands/github/issue/resumeIssueBody.ts
|
|
22848
|
-
import { existsSync as
|
|
22987
|
+
import { existsSync as existsSync54, readFileSync as readFileSync39 } from "fs";
|
|
22849
22988
|
|
|
22850
22989
|
// src/commands/github/issue/issueWorkingFile.ts
|
|
22851
|
-
import { join as
|
|
22990
|
+
import { join as join58 } from "path";
|
|
22852
22991
|
function issueWorkingFile(slug, number) {
|
|
22853
22992
|
const [owner = "unknown", repo = "unknown"] = slug.split("/");
|
|
22854
|
-
const dir =
|
|
22993
|
+
const dir = join58(getStoreDir(), "github-issues", owner, repo);
|
|
22855
22994
|
return {
|
|
22856
22995
|
dir,
|
|
22857
|
-
bodyPath:
|
|
22858
|
-
metaPath:
|
|
22996
|
+
bodyPath: join58(dir, `${number}.md`),
|
|
22997
|
+
metaPath: join58(dir, `${number}.json`)
|
|
22859
22998
|
};
|
|
22860
22999
|
}
|
|
22861
23000
|
|
|
22862
23001
|
// src/commands/github/issue/resumeIssueBody.ts
|
|
22863
23002
|
function resumeIssueBody(slug, number, updatedAt) {
|
|
22864
23003
|
const { bodyPath, metaPath } = issueWorkingFile(slug, number);
|
|
22865
|
-
if (!
|
|
23004
|
+
if (!existsSync54(bodyPath) || !existsSync54(metaPath)) return void 0;
|
|
22866
23005
|
try {
|
|
22867
|
-
const meta = JSON.parse(
|
|
23006
|
+
const meta = JSON.parse(readFileSync39(metaPath, "utf8"));
|
|
22868
23007
|
if (meta.updatedAt !== updatedAt) return void 0;
|
|
22869
|
-
return
|
|
23008
|
+
return readFileSync39(bodyPath, "utf8");
|
|
22870
23009
|
} catch {
|
|
22871
23010
|
return void 0;
|
|
22872
23011
|
}
|
|
@@ -23122,24 +23261,24 @@ async function countPendingHandovers(orm, origin) {
|
|
|
23122
23261
|
|
|
23123
23262
|
// src/commands/handover/migrateDiskHandovers.ts
|
|
23124
23263
|
import {
|
|
23125
|
-
existsSync as
|
|
23126
|
-
readdirSync as
|
|
23127
|
-
readFileSync as
|
|
23264
|
+
existsSync as existsSync55,
|
|
23265
|
+
readdirSync as readdirSync11,
|
|
23266
|
+
readFileSync as readFileSync40,
|
|
23128
23267
|
rmSync as rmSync3,
|
|
23129
23268
|
statSync as statSync9
|
|
23130
23269
|
} from "fs";
|
|
23131
|
-
import { basename as
|
|
23270
|
+
import { basename as basename16, join as join61 } from "path";
|
|
23132
23271
|
|
|
23133
23272
|
// src/commands/handover/getHandoverPath.ts
|
|
23134
|
-
import { join as
|
|
23273
|
+
import { join as join59 } from "path";
|
|
23135
23274
|
function getHandoverPath(cwd = process.cwd()) {
|
|
23136
|
-
return
|
|
23275
|
+
return join59(cwd, ".assist", "HANDOVER.md");
|
|
23137
23276
|
}
|
|
23138
23277
|
|
|
23139
23278
|
// src/commands/handover/getHandoversDir.ts
|
|
23140
|
-
import { join as
|
|
23279
|
+
import { join as join60 } from "path";
|
|
23141
23280
|
function getHandoversDir(cwd = process.cwd()) {
|
|
23142
|
-
return
|
|
23281
|
+
return join60(cwd, ".assist", "handovers");
|
|
23143
23282
|
}
|
|
23144
23283
|
|
|
23145
23284
|
// src/commands/handover/parseArchiveTimestamp.ts
|
|
@@ -23177,17 +23316,17 @@ function summariseHandoverContent(content) {
|
|
|
23177
23316
|
|
|
23178
23317
|
// src/commands/handover/migrateDiskHandovers.ts
|
|
23179
23318
|
function collectMarkdown(dir) {
|
|
23180
|
-
if (!
|
|
23319
|
+
if (!existsSync55(dir)) return [];
|
|
23181
23320
|
const out = [];
|
|
23182
|
-
for (const entry of
|
|
23183
|
-
const full =
|
|
23321
|
+
for (const entry of readdirSync11(dir, { withFileTypes: true })) {
|
|
23322
|
+
const full = join61(dir, entry.name);
|
|
23184
23323
|
if (entry.isDirectory()) out.push(...collectMarkdown(full));
|
|
23185
23324
|
else if (entry.isFile() && entry.name.endsWith(".md")) out.push(full);
|
|
23186
23325
|
}
|
|
23187
23326
|
return out;
|
|
23188
23327
|
}
|
|
23189
23328
|
async function migrateFile(orm, origin, file, createdAt) {
|
|
23190
|
-
const content =
|
|
23329
|
+
const content = readFileSync40(file, "utf8");
|
|
23191
23330
|
await saveHandover(orm, {
|
|
23192
23331
|
origin,
|
|
23193
23332
|
summary: summariseHandoverContent(content),
|
|
@@ -23199,12 +23338,12 @@ async function migrateFile(orm, origin, file, createdAt) {
|
|
|
23199
23338
|
async function migrateDiskHandovers(orm, origin, cwd = process.cwd()) {
|
|
23200
23339
|
let migrated = 0;
|
|
23201
23340
|
for (const file of collectMarkdown(getHandoversDir(cwd))) {
|
|
23202
|
-
const createdAt = parseArchiveTimestamp(
|
|
23341
|
+
const createdAt = parseArchiveTimestamp(basename16(file)) ?? statSync9(file).mtime;
|
|
23203
23342
|
await migrateFile(orm, origin, file, createdAt);
|
|
23204
23343
|
migrated++;
|
|
23205
23344
|
}
|
|
23206
23345
|
const handoverPath = getHandoverPath(cwd);
|
|
23207
|
-
if (
|
|
23346
|
+
if (existsSync55(handoverPath)) {
|
|
23208
23347
|
await migrateFile(orm, origin, handoverPath, statSync9(handoverPath).mtime);
|
|
23209
23348
|
migrated++;
|
|
23210
23349
|
}
|
|
@@ -23561,18 +23700,18 @@ function canonicalTreePath(path91) {
|
|
|
23561
23700
|
}
|
|
23562
23701
|
|
|
23563
23702
|
// src/commands/sessions/daemon/worktree/createWorktree.ts
|
|
23564
|
-
import { existsSync as
|
|
23565
|
-
import { basename as
|
|
23703
|
+
import { existsSync as existsSync56 } from "fs";
|
|
23704
|
+
import { basename as basename18, dirname as dirname27 } from "path";
|
|
23566
23705
|
|
|
23567
23706
|
// src/commands/sessions/daemon/worktree/planAllocation.ts
|
|
23568
|
-
import { basename as
|
|
23707
|
+
import { basename as basename17, join as join62 } from "path";
|
|
23569
23708
|
function planAllocation(clone, boundTreeRoots2) {
|
|
23570
23709
|
return boundTreeRoots2.has(clone) ? "spill" : "primary";
|
|
23571
23710
|
}
|
|
23572
23711
|
function nextWorktreePath(clone, base, isTaken) {
|
|
23573
|
-
const name =
|
|
23712
|
+
const name = basename17(clone);
|
|
23574
23713
|
for (let n = 2; n < 1e3; n++) {
|
|
23575
|
-
const candidate =
|
|
23714
|
+
const candidate = join62(base, `${name}-${n}`);
|
|
23576
23715
|
if (!isTaken(candidate)) return candidate;
|
|
23577
23716
|
}
|
|
23578
23717
|
throw new Error(`no free worktree suffix for ${clone}`);
|
|
@@ -23605,10 +23744,10 @@ function cloneHead(clone) {
|
|
|
23605
23744
|
|
|
23606
23745
|
// src/commands/sessions/daemon/worktree/createWorktree.ts
|
|
23607
23746
|
function createWorktree(clone, strategy, boundTreeRoots2, preferredPath) {
|
|
23608
|
-
const base = strategy.root ? expandTilde2(strategy.root) :
|
|
23747
|
+
const base = strategy.root ? expandTilde2(strategy.root) : dirname27(clone);
|
|
23609
23748
|
const registered = new Set(listWorktreePaths(clone));
|
|
23610
23749
|
const branches = new Set(listLocalBranches(clone));
|
|
23611
|
-
const isTaken = (candidate) => registered.has(candidate) ||
|
|
23750
|
+
const isTaken = (candidate) => registered.has(candidate) || existsSync56(candidate) || boundTreeRoots2.has(candidate) || branches.has(basename18(candidate));
|
|
23612
23751
|
const path91 = preferredPath && !isTaken(preferredPath) ? preferredPath : nextWorktreePath(clone, base, isTaken);
|
|
23613
23752
|
const start3 = worktreeStartPoint(clone, strategy.trunk);
|
|
23614
23753
|
gitSync(clone, [
|
|
@@ -23616,13 +23755,13 @@ function createWorktree(clone, strategy, boundTreeRoots2, preferredPath) {
|
|
|
23616
23755
|
"add",
|
|
23617
23756
|
start3.track ? "--track" : "--no-track",
|
|
23618
23757
|
"-b",
|
|
23619
|
-
|
|
23758
|
+
basename18(path91),
|
|
23620
23759
|
path91,
|
|
23621
23760
|
start3.ref
|
|
23622
23761
|
]);
|
|
23623
23762
|
recordWorktree(path91, clone, getCurrentOrigin(clone));
|
|
23624
23763
|
daemonLog(
|
|
23625
|
-
start3.track ? `worktree allocated ${path91} (branch ${
|
|
23764
|
+
start3.track ? `worktree allocated ${path91} (branch ${basename18(path91)} tracking ${start3.ref}) for clone ${clone}` : `worktree allocated ${path91} (branch ${basename18(path91)} off ${start3.ref}, no mainline tracking) for clone ${clone}`
|
|
23626
23765
|
);
|
|
23627
23766
|
return path91;
|
|
23628
23767
|
}
|
|
@@ -23634,7 +23773,7 @@ function keptInTree(cwd, reason4) {
|
|
|
23634
23773
|
}
|
|
23635
23774
|
|
|
23636
23775
|
// src/commands/sessions/daemon/worktree/treeDurability.ts
|
|
23637
|
-
import { existsSync as
|
|
23776
|
+
import { existsSync as existsSync57 } from "fs";
|
|
23638
23777
|
var treeIsGone = { durable: true, gone: true };
|
|
23639
23778
|
function treeDurability(state) {
|
|
23640
23779
|
if (state.dirty) return { durable: false, reason: "uncommitted changes" };
|
|
@@ -23665,14 +23804,14 @@ function* durabilityProbes() {
|
|
|
23665
23804
|
});
|
|
23666
23805
|
}
|
|
23667
23806
|
async function checkDurability(cwd) {
|
|
23668
|
-
if (!
|
|
23807
|
+
if (!existsSync57(cwd)) return treeIsGone;
|
|
23669
23808
|
const probes = durabilityProbes();
|
|
23670
23809
|
let step2 = probes.next();
|
|
23671
23810
|
while (!step2.done) step2 = probes.next(await gitResult(cwd, step2.value));
|
|
23672
23811
|
return step2.value;
|
|
23673
23812
|
}
|
|
23674
23813
|
function checkDurabilitySync(cwd) {
|
|
23675
|
-
if (!
|
|
23814
|
+
if (!existsSync57(cwd)) return treeIsGone;
|
|
23676
23815
|
const probes = durabilityProbes();
|
|
23677
23816
|
let step2 = probes.next();
|
|
23678
23817
|
while (!step2.done) step2 = probes.next(gitSyncResult(cwd, step2.value));
|
|
@@ -23917,20 +24056,20 @@ function persistedTreeRoots() {
|
|
|
23917
24056
|
}
|
|
23918
24057
|
|
|
23919
24058
|
// src/commands/sessions/daemon/worktree/seedWorktree.ts
|
|
23920
|
-
import { copyFileSync, existsSync as
|
|
23921
|
-
import { dirname as
|
|
24059
|
+
import { copyFileSync, existsSync as existsSync59, mkdirSync as mkdirSync17 } from "fs";
|
|
24060
|
+
import { dirname as dirname28, join as join64 } from "path";
|
|
23922
24061
|
|
|
23923
24062
|
// src/commands/sessions/daemon/worktree/runInstall.ts
|
|
23924
24063
|
import { spawn as spawn5 } from "child_process";
|
|
23925
24064
|
|
|
23926
24065
|
// src/commands/sessions/daemon/worktree/resolveInstallCommand.ts
|
|
23927
|
-
import { existsSync as
|
|
23928
|
-
import { join as
|
|
24066
|
+
import { existsSync as existsSync58 } from "fs";
|
|
24067
|
+
import { join as join63 } from "path";
|
|
23929
24068
|
function detectInstallCommand(repoRoot2) {
|
|
23930
|
-
if (!
|
|
23931
|
-
if (
|
|
23932
|
-
if (
|
|
23933
|
-
if (
|
|
24069
|
+
if (!existsSync58(join63(repoRoot2, "package.json"))) return null;
|
|
24070
|
+
if (existsSync58(join63(repoRoot2, "pnpm-lock.yaml"))) return "pnpm install";
|
|
24071
|
+
if (existsSync58(join63(repoRoot2, "yarn.lock"))) return "yarn install";
|
|
24072
|
+
if (existsSync58(join63(repoRoot2, "bun.lockb"))) return "bun install";
|
|
23934
24073
|
return "npm install";
|
|
23935
24074
|
}
|
|
23936
24075
|
function resolveInstallCommand(repoRoot2, install) {
|
|
@@ -24042,11 +24181,11 @@ function seedWorktree(worktreePath, clone, onSeeded = () => {
|
|
|
24042
24181
|
}
|
|
24043
24182
|
function copyConfigFiles(worktreePath, clone, copy) {
|
|
24044
24183
|
for (const rel of copy) {
|
|
24045
|
-
const src =
|
|
24046
|
-
if (!
|
|
24047
|
-
const dest =
|
|
24184
|
+
const src = join64(clone, rel);
|
|
24185
|
+
if (!existsSync59(src)) continue;
|
|
24186
|
+
const dest = join64(worktreePath, rel);
|
|
24048
24187
|
try {
|
|
24049
|
-
mkdirSync17(
|
|
24188
|
+
mkdirSync17(dirname28(dest), { recursive: true });
|
|
24050
24189
|
copyFileSync(src, dest);
|
|
24051
24190
|
daemonLog(`worktree ${worktreePath} seeded ${rel}`);
|
|
24052
24191
|
} catch (error) {
|
|
@@ -24349,13 +24488,13 @@ function registerLitellm(program2) {
|
|
|
24349
24488
|
}
|
|
24350
24489
|
|
|
24351
24490
|
// src/commands/mermaid/index.ts
|
|
24352
|
-
import { mkdirSync as mkdirSync18, readdirSync as
|
|
24491
|
+
import { mkdirSync as mkdirSync18, readdirSync as readdirSync12 } from "fs";
|
|
24353
24492
|
import { resolve as resolve16 } from "path";
|
|
24354
24493
|
import chalk175 from "chalk";
|
|
24355
24494
|
|
|
24356
24495
|
// src/commands/mermaid/exportFile.ts
|
|
24357
|
-
import { readFileSync as
|
|
24358
|
-
import { basename as
|
|
24496
|
+
import { readFileSync as readFileSync41, writeFileSync as writeFileSync32 } from "fs";
|
|
24497
|
+
import { basename as basename19, extname as extname2, resolve as resolve15 } from "path";
|
|
24359
24498
|
import chalk174 from "chalk";
|
|
24360
24499
|
|
|
24361
24500
|
// src/commands/mermaid/renderBlock.ts
|
|
@@ -24380,9 +24519,9 @@ async function renderBlock(krokiUrl, source) {
|
|
|
24380
24519
|
|
|
24381
24520
|
// src/commands/mermaid/exportFile.ts
|
|
24382
24521
|
async function exportFile(file, outDir, krokiUrl, onlyIndex) {
|
|
24383
|
-
const content =
|
|
24522
|
+
const content = readFileSync41(file, "utf8");
|
|
24384
24523
|
const blocks = extractMermaidBlocks(content);
|
|
24385
|
-
const stem =
|
|
24524
|
+
const stem = basename19(file, extname2(file));
|
|
24386
24525
|
if (onlyIndex !== void 0) {
|
|
24387
24526
|
if (onlyIndex < 1 || onlyIndex > blocks.length) {
|
|
24388
24527
|
console.error(
|
|
@@ -24431,7 +24570,7 @@ async function mermaidExport(file, options2 = {}) {
|
|
|
24431
24570
|
process.exit(1);
|
|
24432
24571
|
}
|
|
24433
24572
|
}
|
|
24434
|
-
const files = file ? [file] :
|
|
24573
|
+
const files = file ? [file] : readdirSync12(process.cwd()).filter((name) => name.toLowerCase().endsWith(".md")).sort();
|
|
24435
24574
|
if (files.length === 0) {
|
|
24436
24575
|
console.log(chalk175.gray("No markdown files found in current directory."));
|
|
24437
24576
|
return;
|
|
@@ -24514,7 +24653,7 @@ import { stringify as stringify2 } from "yaml";
|
|
|
24514
24653
|
|
|
24515
24654
|
// src/commands/miro/writeExtract.ts
|
|
24516
24655
|
import { mkdirSync as mkdirSync19, writeFileSync as writeFileSync33 } from "fs";
|
|
24517
|
-
import { dirname as
|
|
24656
|
+
import { dirname as dirname29 } from "path";
|
|
24518
24657
|
import { stringify } from "yaml";
|
|
24519
24658
|
function headerLines(header) {
|
|
24520
24659
|
const { rect } = header;
|
|
@@ -24527,7 +24666,7 @@ function headerLines(header) {
|
|
|
24527
24666
|
];
|
|
24528
24667
|
}
|
|
24529
24668
|
function writeExtract(file, header, texts) {
|
|
24530
|
-
mkdirSync19(
|
|
24669
|
+
mkdirSync19(dirname29(file), { recursive: true });
|
|
24531
24670
|
writeFileSync33(file, `${headerLines(header).join("\n")}
|
|
24532
24671
|
${stringify(texts)}`);
|
|
24533
24672
|
}
|
|
@@ -24592,14 +24731,14 @@ function applyIgnore(texts, ignore3) {
|
|
|
24592
24731
|
}
|
|
24593
24732
|
|
|
24594
24733
|
// src/commands/miro/readIgnoreList.ts
|
|
24595
|
-
import { existsSync as
|
|
24734
|
+
import { existsSync as existsSync60, readFileSync as readFileSync42 } from "fs";
|
|
24596
24735
|
import { parse as parse2 } from "yaml";
|
|
24597
24736
|
function readIgnoreList(file) {
|
|
24598
|
-
if (!
|
|
24737
|
+
if (!existsSync60(file))
|
|
24599
24738
|
throw new MiroExtractError(
|
|
24600
24739
|
`No ignore file at ${file}. Write a YAML list of the box texts to drop, or omit --ignore.`
|
|
24601
24740
|
);
|
|
24602
|
-
const parsed = parse2(
|
|
24741
|
+
const parsed = parse2(readFileSync42(file, "utf8"));
|
|
24603
24742
|
if (parsed === null || parsed === void 0) return [];
|
|
24604
24743
|
if (!Array.isArray(parsed) || parsed.some((entry) => typeof entry !== "string"))
|
|
24605
24744
|
throw new MiroExtractError(
|
|
@@ -24781,7 +24920,7 @@ async function pickAnchors(sessionId, items2) {
|
|
|
24781
24920
|
}
|
|
24782
24921
|
|
|
24783
24922
|
// src/commands/miro/readMiroItems.ts
|
|
24784
|
-
import { readFileSync as
|
|
24923
|
+
import { readFileSync as readFileSync43 } from "fs";
|
|
24785
24924
|
function tryParse(text18) {
|
|
24786
24925
|
try {
|
|
24787
24926
|
return JSON.parse(text18);
|
|
@@ -24810,7 +24949,7 @@ function parsePages(raw, file) {
|
|
|
24810
24949
|
return Array.isArray(parsed) ? parsed.map(toPage) : [toPage(parsed)];
|
|
24811
24950
|
}
|
|
24812
24951
|
function readMiroItems(file) {
|
|
24813
|
-
const items2 = parsePages(
|
|
24952
|
+
const items2 = parsePages(readFileSync43(file, "utf8"), file).flatMap(
|
|
24814
24953
|
(page) => page.data ?? []
|
|
24815
24954
|
);
|
|
24816
24955
|
if (items2.length === 0)
|
|
@@ -25000,7 +25139,7 @@ function registerMiro(program2) {
|
|
|
25000
25139
|
// src/commands/netcap/netcap.ts
|
|
25001
25140
|
import { mkdir as mkdir5 } from "fs/promises";
|
|
25002
25141
|
import { createServer as createServer2 } from "http";
|
|
25003
|
-
import { dirname as
|
|
25142
|
+
import { dirname as dirname31 } from "path";
|
|
25004
25143
|
import chalk179 from "chalk";
|
|
25005
25144
|
|
|
25006
25145
|
// src/commands/netcap/corsHeaders.ts
|
|
@@ -25079,15 +25218,15 @@ function createNetcapHandler(options2) {
|
|
|
25079
25218
|
// src/commands/netcap/prepareExtensionForLoad.ts
|
|
25080
25219
|
import { cp as cp4, readFile as readFile5, writeFile as writeFile5 } from "fs/promises";
|
|
25081
25220
|
import { networkInterfaces } from "os";
|
|
25082
|
-
import { join as
|
|
25221
|
+
import { join as join66 } from "path";
|
|
25083
25222
|
import chalk178 from "chalk";
|
|
25084
25223
|
|
|
25085
25224
|
// src/commands/netcap/netcapExtensionDir.ts
|
|
25086
|
-
import { dirname as
|
|
25087
|
-
import { fileURLToPath as
|
|
25088
|
-
var moduleDir2 =
|
|
25225
|
+
import { dirname as dirname30, join as join65 } from "path";
|
|
25226
|
+
import { fileURLToPath as fileURLToPath8 } from "url";
|
|
25227
|
+
var moduleDir2 = dirname30(fileURLToPath8(import.meta.url));
|
|
25089
25228
|
function netcapExtensionDir() {
|
|
25090
|
-
return
|
|
25229
|
+
return join65(moduleDir2, "commands", "netcap", "netcap-extension");
|
|
25091
25230
|
}
|
|
25092
25231
|
|
|
25093
25232
|
// src/commands/netcap/prepareExtensionForLoad.ts
|
|
@@ -25102,7 +25241,7 @@ function lanIPv4() {
|
|
|
25102
25241
|
return void 0;
|
|
25103
25242
|
}
|
|
25104
25243
|
async function configureBackground(dir, host, port, filter) {
|
|
25105
|
-
const file =
|
|
25244
|
+
const file = join66(dir, "background.js");
|
|
25106
25245
|
const source = await readFile5(file, "utf8");
|
|
25107
25246
|
await writeFile5(
|
|
25108
25247
|
file,
|
|
@@ -25142,20 +25281,20 @@ async function prepareExtensionForLoad(port, filter = "") {
|
|
|
25142
25281
|
}
|
|
25143
25282
|
|
|
25144
25283
|
// src/commands/netcap/resolveNetcapOutPath.ts
|
|
25145
|
-
import { isAbsolute as isAbsolute4, join as
|
|
25284
|
+
import { isAbsolute as isAbsolute4, join as join68, resolve as resolve18 } from "path";
|
|
25146
25285
|
|
|
25147
25286
|
// src/commands/netcap/defaultCapturePath.ts
|
|
25148
25287
|
import { homedir as homedir21 } from "os";
|
|
25149
|
-
import { join as
|
|
25288
|
+
import { join as join67 } from "path";
|
|
25150
25289
|
function defaultCapturePath() {
|
|
25151
|
-
return
|
|
25290
|
+
return join67(homedir21(), ".assist", "netcap", "capture.jsonl");
|
|
25152
25291
|
}
|
|
25153
25292
|
|
|
25154
25293
|
// src/commands/netcap/resolveNetcapOutPath.ts
|
|
25155
25294
|
function resolveNetcapOutPath(out) {
|
|
25156
25295
|
if (!out) return defaultCapturePath();
|
|
25157
25296
|
const dir = isAbsolute4(out) ? out : resolve18(process.cwd(), out);
|
|
25158
|
-
return
|
|
25297
|
+
return join68(dir, "capture.jsonl");
|
|
25159
25298
|
}
|
|
25160
25299
|
|
|
25161
25300
|
// src/commands/netcap/netcap.ts
|
|
@@ -25163,7 +25302,7 @@ async function netcap(options2) {
|
|
|
25163
25302
|
const port = Number(options2.port);
|
|
25164
25303
|
const outPath = resolveNetcapOutPath(options2.out);
|
|
25165
25304
|
const filter = options2.filter ?? "";
|
|
25166
|
-
await mkdir5(
|
|
25305
|
+
await mkdir5(dirname31(outPath), { recursive: true });
|
|
25167
25306
|
const extensionPath = await prepareExtensionForLoad(port, filter);
|
|
25168
25307
|
let count8 = 0;
|
|
25169
25308
|
const handler = createNetcapHandler({
|
|
@@ -25202,11 +25341,11 @@ netcap stopped \u2014 captured ${count8} ${count8 === 1 ? "entry" : "entries"} t
|
|
|
25202
25341
|
|
|
25203
25342
|
// src/commands/netcap/netcapExtract.ts
|
|
25204
25343
|
import { writeFileSync as writeFileSync34 } from "fs";
|
|
25205
|
-
import { join as
|
|
25344
|
+
import { join as join69 } from "path";
|
|
25206
25345
|
import chalk180 from "chalk";
|
|
25207
25346
|
|
|
25208
25347
|
// src/commands/netcap/extractPostsFromCapture.ts
|
|
25209
|
-
import { readFileSync as
|
|
25348
|
+
import { readFileSync as readFileSync44 } from "fs";
|
|
25210
25349
|
|
|
25211
25350
|
// src/commands/netcap/parseRscRows.ts
|
|
25212
25351
|
var isRscRef = (v) => typeof v === "string" && /^\$[0-9a-fL@]/.test(v);
|
|
@@ -25602,7 +25741,7 @@ function extractVoyagerPosts(body) {
|
|
|
25602
25741
|
|
|
25603
25742
|
// src/commands/netcap/extractPostsFromCapture.ts
|
|
25604
25743
|
function captureEntries(captureFile) {
|
|
25605
|
-
const lines2 =
|
|
25744
|
+
const lines2 = readFileSync44(captureFile, "utf8").split("\n").filter(Boolean);
|
|
25606
25745
|
const entries = [];
|
|
25607
25746
|
for (const line of lines2) {
|
|
25608
25747
|
let entry;
|
|
@@ -25647,7 +25786,7 @@ function extractPostsFromCapture(captureFile) {
|
|
|
25647
25786
|
function netcapExtract(file) {
|
|
25648
25787
|
const captureFile = file ?? defaultCapturePath();
|
|
25649
25788
|
const posts = extractPostsFromCapture(captureFile);
|
|
25650
|
-
const outFile =
|
|
25789
|
+
const outFile = join69(captureFile, "..", "posts.json");
|
|
25651
25790
|
writeFileSync34(outFile, `${JSON.stringify(posts, null, 2)}
|
|
25652
25791
|
`);
|
|
25653
25792
|
console.log(
|
|
@@ -25967,11 +26106,11 @@ function extractResolves(content) {
|
|
|
25967
26106
|
}
|
|
25968
26107
|
function editPrBody(body, sections) {
|
|
25969
26108
|
const parsed = parsePrBody(body);
|
|
25970
|
-
const find = (
|
|
25971
|
-
const upsert = (
|
|
25972
|
-
const existing = find(
|
|
26109
|
+
const find = (heading2) => parsed.find((s) => s.heading.toLowerCase() === heading2.toLowerCase());
|
|
26110
|
+
const upsert = (heading2, content) => {
|
|
26111
|
+
const existing = find(heading2);
|
|
25973
26112
|
if (existing) existing.content = content;
|
|
25974
|
-
else parsed.push({ heading, content });
|
|
26113
|
+
else parsed.push({ heading: heading2, content });
|
|
25975
26114
|
};
|
|
25976
26115
|
if (sections.what !== void 0) upsert("What", sections.what);
|
|
25977
26116
|
const hasResolves = (sections.resolves?.length ?? 0) > 0;
|
|
@@ -26012,10 +26151,10 @@ function splitParagraphs(body) {
|
|
|
26012
26151
|
}
|
|
26013
26152
|
};
|
|
26014
26153
|
for (const line of body.split("\n")) {
|
|
26015
|
-
const
|
|
26016
|
-
if (
|
|
26154
|
+
const heading2 = line.match(/^#{1,6}\s+(.*)$/);
|
|
26155
|
+
if (heading2) {
|
|
26017
26156
|
flush();
|
|
26018
|
-
section3 =
|
|
26157
|
+
section3 = heading2[1].trim();
|
|
26019
26158
|
} else if (line.trim() === "") {
|
|
26020
26159
|
flush();
|
|
26021
26160
|
} else {
|
|
@@ -26090,17 +26229,17 @@ import { execSync as execSync46 } from "child_process";
|
|
|
26090
26229
|
import { execSync as execSync45 } from "child_process";
|
|
26091
26230
|
import { unlinkSync as unlinkSync14, writeFileSync as writeFileSync35 } from "fs";
|
|
26092
26231
|
import { tmpdir as tmpdir7 } from "os";
|
|
26093
|
-
import { join as
|
|
26232
|
+
import { join as join71 } from "path";
|
|
26094
26233
|
|
|
26095
26234
|
// src/commands/prs/loadCommentsCache.ts
|
|
26096
|
-
import { existsSync as
|
|
26235
|
+
import { existsSync as existsSync61, readFileSync as readFileSync45, unlinkSync as unlinkSync13 } from "fs";
|
|
26097
26236
|
import { parse as parse3 } from "yaml";
|
|
26098
26237
|
|
|
26099
26238
|
// src/commands/prs/commentsCachePath.ts
|
|
26100
26239
|
import { homedir as homedir22 } from "os";
|
|
26101
|
-
import { join as
|
|
26240
|
+
import { join as join70 } from "path";
|
|
26102
26241
|
function commentsCachePath(org, repo, prNumber) {
|
|
26103
|
-
return
|
|
26242
|
+
return join70(
|
|
26104
26243
|
homedir22(),
|
|
26105
26244
|
".assist",
|
|
26106
26245
|
"pr-comments",
|
|
@@ -26113,15 +26252,15 @@ function commentsCachePath(org, repo, prNumber) {
|
|
|
26113
26252
|
// src/commands/prs/loadCommentsCache.ts
|
|
26114
26253
|
function loadCommentsCache(org, repo, prNumber) {
|
|
26115
26254
|
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
26116
|
-
if (!
|
|
26255
|
+
if (!existsSync61(cachePath)) {
|
|
26117
26256
|
return null;
|
|
26118
26257
|
}
|
|
26119
|
-
const content =
|
|
26258
|
+
const content = readFileSync45(cachePath, "utf8");
|
|
26120
26259
|
return parse3(content);
|
|
26121
26260
|
}
|
|
26122
26261
|
function deleteCommentsCache(org, repo, prNumber) {
|
|
26123
26262
|
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
26124
|
-
if (
|
|
26263
|
+
if (existsSync61(cachePath)) {
|
|
26125
26264
|
unlinkSync13(cachePath);
|
|
26126
26265
|
console.log("No more unresolved line comments. Cache dropped.");
|
|
26127
26266
|
}
|
|
@@ -26149,7 +26288,7 @@ function replyToComment(org, repo, prNumber, commentId, message3) {
|
|
|
26149
26288
|
// src/commands/prs/resolveCommentWithReply.ts
|
|
26150
26289
|
function resolveThread(threadId) {
|
|
26151
26290
|
const mutation = `mutation($threadId: ID!) { resolveReviewThread(input: {threadId: $threadId}) { thread { isResolved } } }`;
|
|
26152
|
-
const queryFile =
|
|
26291
|
+
const queryFile = join71(tmpdir7(), `gh-mutation-${Date.now()}.graphql`);
|
|
26153
26292
|
writeFileSync35(queryFile, mutation);
|
|
26154
26293
|
try {
|
|
26155
26294
|
execSync45(
|
|
@@ -26234,10 +26373,10 @@ function fixed(commentId, sha) {
|
|
|
26234
26373
|
import { execSync as execSync47 } from "child_process";
|
|
26235
26374
|
import { unlinkSync as unlinkSync15, writeFileSync as writeFileSync36 } from "fs";
|
|
26236
26375
|
import { tmpdir as tmpdir8 } from "os";
|
|
26237
|
-
import { join as
|
|
26376
|
+
import { join as join72 } from "path";
|
|
26238
26377
|
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 } } } } } } }`;
|
|
26239
26378
|
function fetchThreadIds(org, repo, prNumber) {
|
|
26240
|
-
const queryFile =
|
|
26379
|
+
const queryFile = join72(tmpdir8(), `gh-query-${Date.now()}.graphql`);
|
|
26241
26380
|
writeFileSync36(queryFile, THREAD_QUERY);
|
|
26242
26381
|
try {
|
|
26243
26382
|
const result = execSync47(
|
|
@@ -26307,30 +26446,30 @@ function fetchLineComments(org, repo, prNumber, threadInfo) {
|
|
|
26307
26446
|
|
|
26308
26447
|
// src/commands/prs/listComments/updateCommentsCache.ts
|
|
26309
26448
|
import { mkdirSync as mkdirSync20, writeFileSync as writeFileSync37 } from "fs";
|
|
26310
|
-
import { dirname as
|
|
26449
|
+
import { dirname as dirname32 } from "path";
|
|
26311
26450
|
import { stringify as stringify3 } from "yaml";
|
|
26312
26451
|
|
|
26313
26452
|
// src/commands/prs/removeStaleCommentsCaches.ts
|
|
26314
|
-
import { readdirSync as
|
|
26315
|
-
import { join as
|
|
26453
|
+
import { readdirSync as readdirSync13, unlinkSync as unlinkSync16 } from "fs";
|
|
26454
|
+
import { join as join73 } from "path";
|
|
26316
26455
|
var STALE_PATTERN = /^pr-\d+-comments\.yaml$/;
|
|
26317
26456
|
function removeStaleCommentsCaches(cwd = process.cwd()) {
|
|
26318
|
-
const dir =
|
|
26457
|
+
const dir = join73(cwd, ".assist");
|
|
26319
26458
|
let entries;
|
|
26320
26459
|
try {
|
|
26321
|
-
entries =
|
|
26460
|
+
entries = readdirSync13(dir);
|
|
26322
26461
|
} catch {
|
|
26323
26462
|
return;
|
|
26324
26463
|
}
|
|
26325
26464
|
for (const entry of entries.filter((e) => STALE_PATTERN.test(e))) {
|
|
26326
|
-
unlinkSync16(
|
|
26465
|
+
unlinkSync16(join73(dir, entry));
|
|
26327
26466
|
}
|
|
26328
26467
|
}
|
|
26329
26468
|
|
|
26330
26469
|
// src/commands/prs/listComments/updateCommentsCache.ts
|
|
26331
26470
|
function writeCommentsCache(org, repo, prNumber, comments3) {
|
|
26332
26471
|
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
26333
|
-
mkdirSync20(
|
|
26472
|
+
mkdirSync20(dirname32(cachePath), { recursive: true });
|
|
26334
26473
|
const cacheData = {
|
|
26335
26474
|
prNumber,
|
|
26336
26475
|
fetchedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -27288,7 +27427,7 @@ function registerPrsRaise(prsCommand) {
|
|
|
27288
27427
|
}
|
|
27289
27428
|
|
|
27290
27429
|
// src/commands/readTime/readTime.ts
|
|
27291
|
-
import { readFileSync as
|
|
27430
|
+
import { readFileSync as readFileSync46 } from "fs";
|
|
27292
27431
|
|
|
27293
27432
|
// src/commands/readTime/countReadingWords.ts
|
|
27294
27433
|
var FENCE_PATTERN = /^\s*(```|~~~)/;
|
|
@@ -27449,7 +27588,7 @@ async function loadBody(target) {
|
|
|
27449
27588
|
}
|
|
27450
27589
|
function readDraftFile(path91) {
|
|
27451
27590
|
try {
|
|
27452
|
-
return
|
|
27591
|
+
return readFileSync46(path91, "utf8");
|
|
27453
27592
|
} catch {
|
|
27454
27593
|
console.error(`Error: Could not read \`${path91}\`.`);
|
|
27455
27594
|
console.error(
|
|
@@ -29290,8 +29429,8 @@ function findRootParent(file, importedBy, visited) {
|
|
|
29290
29429
|
function clusterFiles(graph) {
|
|
29291
29430
|
const clusters = /* @__PURE__ */ new Map();
|
|
29292
29431
|
for (const file of graph.files) {
|
|
29293
|
-
const
|
|
29294
|
-
if (
|
|
29432
|
+
const basename29 = path62.basename(file, path62.extname(file));
|
|
29433
|
+
if (basename29 === "index") continue;
|
|
29295
29434
|
const importers = graph.importedBy.get(file);
|
|
29296
29435
|
if (!importers || importers.size !== 1) continue;
|
|
29297
29436
|
const parent = [...importers][0];
|
|
@@ -29715,21 +29854,21 @@ ${annotateDiffWithLineNumbers(context.diff.trimEnd())}
|
|
|
29715
29854
|
|
|
29716
29855
|
// src/commands/review/buildReviewPaths.ts
|
|
29717
29856
|
import { homedir as homedir23 } from "os";
|
|
29718
|
-
import { basename as
|
|
29857
|
+
import { basename as basename20, join as join74 } from "path";
|
|
29719
29858
|
function buildReviewPaths(repoRoot2, key) {
|
|
29720
|
-
const reviewDir =
|
|
29859
|
+
const reviewDir = join74(
|
|
29721
29860
|
homedir23(),
|
|
29722
29861
|
".assist",
|
|
29723
29862
|
"reviews",
|
|
29724
|
-
|
|
29863
|
+
basename20(repoRoot2),
|
|
29725
29864
|
key
|
|
29726
29865
|
);
|
|
29727
29866
|
return {
|
|
29728
29867
|
reviewDir,
|
|
29729
|
-
requestPath:
|
|
29730
|
-
claudePath:
|
|
29731
|
-
codexPath:
|
|
29732
|
-
synthesisPath:
|
|
29868
|
+
requestPath: join74(reviewDir, "request.md"),
|
|
29869
|
+
claudePath: join74(reviewDir, "claude.md"),
|
|
29870
|
+
codexPath: join74(reviewDir, "codex.md"),
|
|
29871
|
+
synthesisPath: join74(reviewDir, "synthesis.md")
|
|
29733
29872
|
};
|
|
29734
29873
|
}
|
|
29735
29874
|
|
|
@@ -29871,7 +30010,7 @@ function gatherContext() {
|
|
|
29871
30010
|
}
|
|
29872
30011
|
|
|
29873
30012
|
// src/commands/review/postReviewToPr.ts
|
|
29874
|
-
import { readFileSync as
|
|
30013
|
+
import { readFileSync as readFileSync47 } from "fs";
|
|
29875
30014
|
|
|
29876
30015
|
// src/commands/review/carriedUnanchoredFindings.ts
|
|
29877
30016
|
function carriedUnanchoredFindings(unanchored) {
|
|
@@ -30322,7 +30461,7 @@ async function confirmPost(prNumber, work, options2) {
|
|
|
30322
30461
|
return promptConfirm(`Post ${work} to PR #${prNumber}?`, false);
|
|
30323
30462
|
}
|
|
30324
30463
|
async function postFindingsToPr(prInfo, synthesisPath, options2) {
|
|
30325
|
-
const markdown =
|
|
30464
|
+
const markdown = readFileSync47(synthesisPath, "utf8");
|
|
30326
30465
|
const { inDiff, unanchored } = selectPostableFindings(markdown, prInfo);
|
|
30327
30466
|
const carried = carriedUnanchoredFindings(unanchored);
|
|
30328
30467
|
if (inDiff.length === 0 && carried.length === 0) return NOTHING_POSTED;
|
|
@@ -30458,10 +30597,10 @@ async function handlePostSynthesis(synthesisPath, prInfo, options2) {
|
|
|
30458
30597
|
}
|
|
30459
30598
|
|
|
30460
30599
|
// src/commands/review/prepareReviewDir.ts
|
|
30461
|
-
import { existsSync as
|
|
30600
|
+
import { existsSync as existsSync62, mkdirSync as mkdirSync21, unlinkSync as unlinkSync17, writeFileSync as writeFileSync38 } from "fs";
|
|
30462
30601
|
function clearReviewFiles(paths) {
|
|
30463
30602
|
for (const path91 of [paths.claudePath, paths.codexPath, paths.synthesisPath]) {
|
|
30464
|
-
if (
|
|
30603
|
+
if (existsSync62(path91)) unlinkSync17(path91);
|
|
30465
30604
|
}
|
|
30466
30605
|
}
|
|
30467
30606
|
function prepareReviewDir(paths, requestBody, force) {
|
|
@@ -30523,7 +30662,7 @@ import { format } from "util";
|
|
|
30523
30662
|
|
|
30524
30663
|
// src/commands/review/createReviewLogSink.ts
|
|
30525
30664
|
import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync22 } from "fs";
|
|
30526
|
-
import { join as
|
|
30665
|
+
import { join as join75 } from "path";
|
|
30527
30666
|
|
|
30528
30667
|
// src/shared/stripAnsi.ts
|
|
30529
30668
|
var ANSI = new RegExp(
|
|
@@ -30551,7 +30690,7 @@ function createReviewLogSink() {
|
|
|
30551
30690
|
},
|
|
30552
30691
|
attach(reviewDir) {
|
|
30553
30692
|
mkdirSync22(reviewDir, { recursive: true });
|
|
30554
|
-
logPath2 =
|
|
30693
|
+
logPath2 = join75(reviewDir, LOG_FILE);
|
|
30555
30694
|
const lines2 = [
|
|
30556
30695
|
"",
|
|
30557
30696
|
`=== ${(/* @__PURE__ */ new Date()).toISOString()} ===`,
|
|
@@ -30765,7 +30904,7 @@ function printReviewerFailures(results) {
|
|
|
30765
30904
|
}
|
|
30766
30905
|
|
|
30767
30906
|
// src/commands/review/runAndSynthesise.ts
|
|
30768
|
-
import { existsSync as
|
|
30907
|
+
import { existsSync as existsSync64, unlinkSync as unlinkSync19 } from "fs";
|
|
30769
30908
|
|
|
30770
30909
|
// src/commands/review/buildReviewerStdin.ts
|
|
30771
30910
|
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.
|
|
@@ -31232,7 +31371,7 @@ function buildCodexModelArgs() {
|
|
|
31232
31371
|
}
|
|
31233
31372
|
|
|
31234
31373
|
// src/commands/review/runCodexReviewer.ts
|
|
31235
|
-
import { existsSync as
|
|
31374
|
+
import { existsSync as existsSync63, unlinkSync as unlinkSync18 } from "fs";
|
|
31236
31375
|
|
|
31237
31376
|
// src/commands/review/parseCodexEvent.ts
|
|
31238
31377
|
function isItemStarted(value) {
|
|
@@ -31287,7 +31426,7 @@ async function runCodexReviewer(spec) {
|
|
|
31287
31426
|
reportReviewerToolUse(spec.name, event, spinner, override.model);
|
|
31288
31427
|
}
|
|
31289
31428
|
});
|
|
31290
|
-
if (result.exitCode !== 0 &&
|
|
31429
|
+
if (result.exitCode !== 0 && existsSync63(spec.outputPath)) {
|
|
31291
31430
|
unlinkSync18(spec.outputPath);
|
|
31292
31431
|
}
|
|
31293
31432
|
return finaliseReviewerRun(
|
|
@@ -31342,7 +31481,7 @@ async function runReviewers(reviewDir, claudePath, codexPath, stdinPrompt, optio
|
|
|
31342
31481
|
}
|
|
31343
31482
|
|
|
31344
31483
|
// src/commands/review/synthesise.ts
|
|
31345
|
-
import { readFileSync as
|
|
31484
|
+
import { readFileSync as readFileSync48 } from "fs";
|
|
31346
31485
|
|
|
31347
31486
|
// src/commands/review/buildSynthesisStdin.ts
|
|
31348
31487
|
var SYNTHESIS_PROMPT = `You are consolidating two independent code reviews of the same change. The original review request is in request.md. The two reviews are in claude.md and codex.md in the current working directory.
|
|
@@ -31407,7 +31546,7 @@ Files:
|
|
|
31407
31546
|
|
|
31408
31547
|
// src/commands/review/synthesise.ts
|
|
31409
31548
|
function printSummary2(synthesisPath) {
|
|
31410
|
-
const markdown =
|
|
31549
|
+
const markdown = readFileSync48(synthesisPath, "utf8");
|
|
31411
31550
|
console.log("");
|
|
31412
31551
|
console.log(buildReviewSummary(markdown));
|
|
31413
31552
|
console.log("");
|
|
@@ -31455,7 +31594,7 @@ async function runAndSynthesise(args) {
|
|
|
31455
31594
|
console.error("Both reviewers failed; skipping synthesis.");
|
|
31456
31595
|
return { ok: false, failures };
|
|
31457
31596
|
}
|
|
31458
|
-
if (anyFresh &&
|
|
31597
|
+
if (anyFresh && existsSync64(paths.synthesisPath)) {
|
|
31459
31598
|
unlinkSync19(paths.synthesisPath);
|
|
31460
31599
|
}
|
|
31461
31600
|
const synthesisResult = await synthesise(paths, { multi });
|
|
@@ -31648,7 +31787,7 @@ function registerReview(program2) {
|
|
|
31648
31787
|
}
|
|
31649
31788
|
|
|
31650
31789
|
// src/commands/rules/addRule.ts
|
|
31651
|
-
import { existsSync as
|
|
31790
|
+
import { existsSync as existsSync67, readFileSync as readFileSync52, writeFileSync as writeFileSync41 } from "fs";
|
|
31652
31791
|
import path72 from "path";
|
|
31653
31792
|
import chalk211 from "chalk";
|
|
31654
31793
|
|
|
@@ -31673,15 +31812,15 @@ function insertRuleBullet(content, rule) {
|
|
|
31673
31812
|
}
|
|
31674
31813
|
|
|
31675
31814
|
// src/commands/rules/nextRuleCode.ts
|
|
31676
|
-
import { readFileSync as
|
|
31815
|
+
import { readFileSync as readFileSync49 } from "fs";
|
|
31677
31816
|
|
|
31678
31817
|
// src/commands/rules/findClaudeFiles.ts
|
|
31679
|
-
import { readdirSync as
|
|
31818
|
+
import { readdirSync as readdirSync14 } from "fs";
|
|
31680
31819
|
import path68 from "path";
|
|
31681
31820
|
var SKIP_DIRECTORIES = /* @__PURE__ */ new Set(["node_modules", "dist", "build", "coverage"]);
|
|
31682
31821
|
function findClaudeFiles(dir) {
|
|
31683
31822
|
const results = [];
|
|
31684
|
-
for (const entry of
|
|
31823
|
+
for (const entry of readdirSync14(dir, { withFileTypes: true })) {
|
|
31685
31824
|
if (entry.isDirectory()) {
|
|
31686
31825
|
if (entry.name.startsWith(".") || SKIP_DIRECTORIES.has(entry.name))
|
|
31687
31826
|
continue;
|
|
@@ -31697,7 +31836,7 @@ function findClaudeFiles(dir) {
|
|
|
31697
31836
|
var CODE_PREFIX = "R";
|
|
31698
31837
|
function nextRuleCode(root) {
|
|
31699
31838
|
const numbers = findClaudeFiles(root).flatMap(
|
|
31700
|
-
(file) => parseRulesSection(
|
|
31839
|
+
(file) => parseRulesSection(readFileSync49(file, "utf8")).map(
|
|
31701
31840
|
(rule) => Number(/(\d+)\s*$/.exec(rule.code)?.[1] ?? 0)
|
|
31702
31841
|
)
|
|
31703
31842
|
);
|
|
@@ -31705,7 +31844,7 @@ function nextRuleCode(root) {
|
|
|
31705
31844
|
}
|
|
31706
31845
|
|
|
31707
31846
|
// src/commands/rules/resolveRuleScope.ts
|
|
31708
|
-
import { existsSync as
|
|
31847
|
+
import { existsSync as existsSync65 } from "fs";
|
|
31709
31848
|
import path69 from "path";
|
|
31710
31849
|
function resolveRuleScope(target) {
|
|
31711
31850
|
const resolved = path69.resolve(target);
|
|
@@ -31715,7 +31854,7 @@ function resolveRuleScope(target) {
|
|
|
31715
31854
|
let current = startDir;
|
|
31716
31855
|
while (true) {
|
|
31717
31856
|
const candidate = path69.join(current, "CLAUDE.md");
|
|
31718
|
-
if (
|
|
31857
|
+
if (existsSync65(candidate)) return candidate;
|
|
31719
31858
|
if (current === root || current === path69.dirname(current)) break;
|
|
31720
31859
|
current = path69.dirname(current);
|
|
31721
31860
|
}
|
|
@@ -31723,15 +31862,15 @@ function resolveRuleScope(target) {
|
|
|
31723
31862
|
}
|
|
31724
31863
|
|
|
31725
31864
|
// src/commands/rules/updateScopedRulesIndex.ts
|
|
31726
|
-
import { existsSync as
|
|
31865
|
+
import { existsSync as existsSync66, readFileSync as readFileSync51, writeFileSync as writeFileSync40 } from "fs";
|
|
31727
31866
|
import path71 from "path";
|
|
31728
31867
|
|
|
31729
31868
|
// src/commands/rules/scopedRuleDirectories.ts
|
|
31730
|
-
import { readFileSync as
|
|
31869
|
+
import { readFileSync as readFileSync50 } from "fs";
|
|
31731
31870
|
import path70 from "path";
|
|
31732
31871
|
function scopedRuleDirectories(root) {
|
|
31733
31872
|
return findClaudeFiles(root).filter(
|
|
31734
|
-
(file) => path70.dirname(file) !== root && parseRulesSection(
|
|
31873
|
+
(file) => path70.dirname(file) !== root && parseRulesSection(readFileSync50(file, "utf8")).length > 0
|
|
31735
31874
|
).map(
|
|
31736
31875
|
(file) => `${path70.relative(root, path70.dirname(file)).split(path70.sep).join("/")}/`
|
|
31737
31876
|
).sort();
|
|
@@ -31773,7 +31912,7 @@ function upsertScopedRulesPointer(content, directories) {
|
|
|
31773
31912
|
function updateScopedRulesIndex(root) {
|
|
31774
31913
|
const directories = scopedRuleDirectories(root);
|
|
31775
31914
|
const rootFile = path71.join(root, "CLAUDE.md");
|
|
31776
|
-
const before =
|
|
31915
|
+
const before = existsSync66(rootFile) ? readFileSync51(rootFile, "utf8") : "";
|
|
31777
31916
|
const after = upsertScopedRulesPointer(before, directories);
|
|
31778
31917
|
if (after !== before) writeFileSync40(rootFile, after);
|
|
31779
31918
|
return directories;
|
|
@@ -31781,7 +31920,7 @@ function updateScopedRulesIndex(root) {
|
|
|
31781
31920
|
|
|
31782
31921
|
// src/commands/rules/addRule.ts
|
|
31783
31922
|
function read2(file) {
|
|
31784
|
-
return
|
|
31923
|
+
return existsSync67(file) ? readFileSync52(file, "utf8") : "";
|
|
31785
31924
|
}
|
|
31786
31925
|
function addRule(text18, options2) {
|
|
31787
31926
|
const rule = text18.trim();
|
|
@@ -32264,11 +32403,11 @@ async function reviewProposedSlackMessage(target, body, workingPath) {
|
|
|
32264
32403
|
}
|
|
32265
32404
|
|
|
32266
32405
|
// src/commands/slack/slackWorkingFile.ts
|
|
32267
|
-
import { join as
|
|
32406
|
+
import { join as join76 } from "path";
|
|
32268
32407
|
function slackWorkingFile(channel) {
|
|
32269
32408
|
const slug = channel.replace(/^[#@]/, "").toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "channel";
|
|
32270
|
-
const dir =
|
|
32271
|
-
return { dir, bodyPath:
|
|
32409
|
+
const dir = join76(getStoreDir(), "slack");
|
|
32410
|
+
return { dir, bodyPath: join76(dir, `${slug}.md`) };
|
|
32272
32411
|
}
|
|
32273
32412
|
|
|
32274
32413
|
// src/commands/slack/postSlackMessage.ts
|
|
@@ -32595,7 +32734,7 @@ function registerSql(program2) {
|
|
|
32595
32734
|
import * as fs48 from "fs";
|
|
32596
32735
|
import * as os5 from "os";
|
|
32597
32736
|
import * as path85 from "path";
|
|
32598
|
-
import { fileURLToPath as
|
|
32737
|
+
import { fileURLToPath as fileURLToPath9 } from "url";
|
|
32599
32738
|
|
|
32600
32739
|
// src/commands/sync/pruneCommands.ts
|
|
32601
32740
|
import * as path76 from "path";
|
|
@@ -32801,9 +32940,9 @@ function quoteYaml(value) {
|
|
|
32801
32940
|
}
|
|
32802
32941
|
function commandToSkill(name, content) {
|
|
32803
32942
|
const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?/);
|
|
32804
|
-
const
|
|
32943
|
+
const frontmatter2 = match ? match[1] : "";
|
|
32805
32944
|
const body = match ? content.slice(match[0].length) : content;
|
|
32806
|
-
const descriptionMatch =
|
|
32945
|
+
const descriptionMatch = frontmatter2.match(/^description:\s*(.*)$/m);
|
|
32807
32946
|
const description = descriptionMatch ? descriptionMatch[1].trim().replace(/^["']|["']$/g, "") : name;
|
|
32808
32947
|
const header = `---
|
|
32809
32948
|
name: ${name}
|
|
@@ -32886,11 +33025,11 @@ function unquote2(value) {
|
|
|
32886
33025
|
}
|
|
32887
33026
|
function commandToPrompt(name, content) {
|
|
32888
33027
|
const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?/);
|
|
32889
|
-
const
|
|
33028
|
+
const frontmatter2 = match ? match[1] : "";
|
|
32890
33029
|
const body = match ? content.slice(match[0].length) : content;
|
|
32891
|
-
const descriptionMatch =
|
|
33030
|
+
const descriptionMatch = frontmatter2.match(/^description:\s*(.*)$/m);
|
|
32892
33031
|
const description = descriptionMatch ? unquote2(descriptionMatch[1]) : name;
|
|
32893
|
-
const argsMatch =
|
|
33032
|
+
const argsMatch = frontmatter2.match(/^allowed_args:\s*(.*)$/m);
|
|
32894
33033
|
const argumentHint = argsMatch ? unquote2(argsMatch[1]) : void 0;
|
|
32895
33034
|
const header = [
|
|
32896
33035
|
"---",
|
|
@@ -32967,7 +33106,7 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
32967
33106
|
}
|
|
32968
33107
|
|
|
32969
33108
|
// src/commands/sync.ts
|
|
32970
|
-
var __filename4 =
|
|
33109
|
+
var __filename4 = fileURLToPath9(import.meta.url);
|
|
32971
33110
|
var __dirname5 = path85.dirname(__filename4);
|
|
32972
33111
|
async function sync(options2) {
|
|
32973
33112
|
const config = loadConfig();
|
|
@@ -33024,7 +33163,7 @@ function registerSync(program2) {
|
|
|
33024
33163
|
}
|
|
33025
33164
|
|
|
33026
33165
|
// src/commands/transcript/clean.ts
|
|
33027
|
-
import { existsSync as
|
|
33166
|
+
import { existsSync as existsSync72 } from "fs";
|
|
33028
33167
|
|
|
33029
33168
|
// src/commands/transcript/convert/formatTimestamp.ts
|
|
33030
33169
|
function pad(value, width) {
|
|
@@ -33274,9 +33413,9 @@ function formatVttPassages(passages, notes = [], { sourceMarks = true } = {}) {
|
|
|
33274
33413
|
}
|
|
33275
33414
|
|
|
33276
33415
|
// src/commands/transcript/convert/readCleanedCues.ts
|
|
33277
|
-
import { readFileSync as
|
|
33416
|
+
import { readFileSync as readFileSync57 } from "fs";
|
|
33278
33417
|
function readCleanedCues(inputPath) {
|
|
33279
|
-
return deduplicateCues(parseVtt(
|
|
33418
|
+
return deduplicateCues(parseVtt(readFileSync57(inputPath, "utf8")));
|
|
33280
33419
|
}
|
|
33281
33420
|
|
|
33282
33421
|
// src/commands/transcript/clean.ts
|
|
@@ -33302,7 +33441,7 @@ function clean(file, options2 = {}) {
|
|
|
33302
33441
|
);
|
|
33303
33442
|
process.exit(1);
|
|
33304
33443
|
}
|
|
33305
|
-
if (!
|
|
33444
|
+
if (!existsSync72(file)) {
|
|
33306
33445
|
console.error(`Error: VTT file not found: ${file}`);
|
|
33307
33446
|
process.exit(1);
|
|
33308
33447
|
}
|
|
@@ -33385,21 +33524,21 @@ async function configure() {
|
|
|
33385
33524
|
}
|
|
33386
33525
|
|
|
33387
33526
|
// src/commands/transcript/list.ts
|
|
33388
|
-
import { existsSync as
|
|
33389
|
-
import { join as
|
|
33527
|
+
import { existsSync as existsSync73, readdirSync as readdirSync21, statSync as statSync11 } from "fs";
|
|
33528
|
+
import { join as join87 } from "path";
|
|
33390
33529
|
function list4() {
|
|
33391
33530
|
const { vttDir } = getTranscriptConfig();
|
|
33392
|
-
if (!
|
|
33393
|
-
for (const entry of
|
|
33531
|
+
if (!existsSync73(vttDir)) return;
|
|
33532
|
+
for (const entry of readdirSync21(vttDir)) {
|
|
33394
33533
|
if (!entry.endsWith(".vtt")) continue;
|
|
33395
|
-
if (statSync11(
|
|
33534
|
+
if (statSync11(join87(vttDir, entry)).isDirectory()) continue;
|
|
33396
33535
|
console.log(entry);
|
|
33397
33536
|
}
|
|
33398
33537
|
}
|
|
33399
33538
|
|
|
33400
33539
|
// src/commands/transcript/move.ts
|
|
33401
|
-
import { existsSync as
|
|
33402
|
-
import { basename as
|
|
33540
|
+
import { existsSync as existsSync74, mkdirSync as mkdirSync29, renameSync as renameSync2, writeFileSync as writeFileSync46 } from "fs";
|
|
33541
|
+
import { basename as basename23, join as join88 } from "path";
|
|
33403
33542
|
|
|
33404
33543
|
// src/commands/transcript/convertVttToMarkdown.ts
|
|
33405
33544
|
function convertVttToMarkdown(inputPath) {
|
|
@@ -33409,9 +33548,9 @@ function convertVttToMarkdown(inputPath) {
|
|
|
33409
33548
|
// src/commands/transcript/move.ts
|
|
33410
33549
|
var DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
|
|
33411
33550
|
function archiveRawVtt(vttDir, sourcePath, filename) {
|
|
33412
|
-
const processedDir =
|
|
33551
|
+
const processedDir = join88(vttDir, "processed");
|
|
33413
33552
|
mkdirSync29(processedDir, { recursive: true });
|
|
33414
|
-
renameSync2(sourcePath,
|
|
33553
|
+
renameSync2(sourcePath, join88(processedDir, filename));
|
|
33415
33554
|
}
|
|
33416
33555
|
function move(file, options2) {
|
|
33417
33556
|
const { date, client } = options2;
|
|
@@ -33420,27 +33559,27 @@ function move(file, options2) {
|
|
|
33420
33559
|
process.exit(1);
|
|
33421
33560
|
}
|
|
33422
33561
|
const { vttDir, transcriptsDir, summaryDir } = getTranscriptConfig();
|
|
33423
|
-
const filename =
|
|
33424
|
-
const sourcePath =
|
|
33425
|
-
if (!
|
|
33562
|
+
const filename = basename23(file);
|
|
33563
|
+
const sourcePath = join88(vttDir, filename);
|
|
33564
|
+
if (!existsSync74(sourcePath)) {
|
|
33426
33565
|
console.error(`Error: VTT file not found: ${sourcePath}`);
|
|
33427
33566
|
process.exit(1);
|
|
33428
33567
|
}
|
|
33429
|
-
const base =
|
|
33568
|
+
const base = basename23(filename, ".vtt").replace(/ Transcription$/, "");
|
|
33430
33569
|
const outputName = `${date} ${base}.md`;
|
|
33431
|
-
const formattedDir =
|
|
33570
|
+
const formattedDir = join88(transcriptsDir, client);
|
|
33432
33571
|
mkdirSync29(formattedDir, { recursive: true });
|
|
33433
|
-
const formattedPath =
|
|
33572
|
+
const formattedPath = join88(formattedDir, outputName);
|
|
33434
33573
|
writeFileSync46(formattedPath, convertVttToMarkdown(sourcePath), "utf8");
|
|
33435
33574
|
archiveRawVtt(vttDir, sourcePath, filename);
|
|
33436
|
-
const summaryPath =
|
|
33575
|
+
const summaryPath = join88(summaryDir, client, outputName);
|
|
33437
33576
|
console.log(`Formatted transcript: ${formattedPath}`);
|
|
33438
33577
|
console.log(`Summary target: ${summaryPath}`);
|
|
33439
33578
|
}
|
|
33440
33579
|
|
|
33441
33580
|
// src/commands/transcript/merge.ts
|
|
33442
|
-
import { existsSync as
|
|
33443
|
-
import { basename as
|
|
33581
|
+
import { existsSync as existsSync75, writeFileSync as writeFileSync47 } from "fs";
|
|
33582
|
+
import { basename as basename24 } from "path";
|
|
33444
33583
|
|
|
33445
33584
|
// src/commands/transcript/failTranscript.ts
|
|
33446
33585
|
function failTranscript(message3) {
|
|
@@ -33583,10 +33722,10 @@ function widenAudience(passages) {
|
|
|
33583
33722
|
|
|
33584
33723
|
// src/commands/transcript/merge.ts
|
|
33585
33724
|
function readSource2(file) {
|
|
33586
|
-
if (!
|
|
33725
|
+
if (!existsSync75(file)) failTranscript(`VTT file not found: ${file}`);
|
|
33587
33726
|
const cues = readCleanedCues(file);
|
|
33588
33727
|
if (cues.length === 0) failTranscript(`no cues found in: ${file}`);
|
|
33589
|
-
return { path: file, name:
|
|
33728
|
+
return { path: file, name: basename24(file), cues };
|
|
33590
33729
|
}
|
|
33591
33730
|
function wholePassages(sources) {
|
|
33592
33731
|
return sources.map((source) => ({
|
|
@@ -33747,50 +33886,50 @@ function registerVerify(program2) {
|
|
|
33747
33886
|
|
|
33748
33887
|
// src/commands/voice/devices.ts
|
|
33749
33888
|
import { spawnSync as spawnSync9 } from "child_process";
|
|
33750
|
-
import { join as
|
|
33889
|
+
import { join as join90 } from "path";
|
|
33751
33890
|
|
|
33752
33891
|
// src/commands/voice/shared.ts
|
|
33753
33892
|
import { homedir as homedir25 } from "os";
|
|
33754
|
-
import { dirname as
|
|
33755
|
-
import { fileURLToPath as
|
|
33756
|
-
var __dirname6 =
|
|
33757
|
-
var VOICE_DIR =
|
|
33893
|
+
import { dirname as dirname37, join as join89 } from "path";
|
|
33894
|
+
import { fileURLToPath as fileURLToPath10 } from "url";
|
|
33895
|
+
var __dirname6 = dirname37(fileURLToPath10(import.meta.url));
|
|
33896
|
+
var VOICE_DIR = join89(homedir25(), ".assist", "voice");
|
|
33758
33897
|
var voicePaths = {
|
|
33759
33898
|
dir: VOICE_DIR,
|
|
33760
|
-
pid:
|
|
33761
|
-
log:
|
|
33762
|
-
venv:
|
|
33763
|
-
lock:
|
|
33899
|
+
pid: join89(VOICE_DIR, "voice.pid"),
|
|
33900
|
+
log: join89(VOICE_DIR, "voice.log"),
|
|
33901
|
+
venv: join89(VOICE_DIR, ".venv"),
|
|
33902
|
+
lock: join89(VOICE_DIR, "voice.lock")
|
|
33764
33903
|
};
|
|
33765
33904
|
function getPythonDir() {
|
|
33766
|
-
return
|
|
33905
|
+
return join89(__dirname6, "commands", "voice", "python");
|
|
33767
33906
|
}
|
|
33768
33907
|
function getVenvPython() {
|
|
33769
|
-
return process.platform === "win32" ?
|
|
33908
|
+
return process.platform === "win32" ? join89(voicePaths.venv, "Scripts", "python.exe") : join89(voicePaths.venv, "bin", "python");
|
|
33770
33909
|
}
|
|
33771
33910
|
function getLockDir() {
|
|
33772
33911
|
const config = loadConfig();
|
|
33773
33912
|
return config.voice?.lockDir ?? VOICE_DIR;
|
|
33774
33913
|
}
|
|
33775
33914
|
function getLockFile() {
|
|
33776
|
-
return
|
|
33915
|
+
return join89(getLockDir(), "voice.lock");
|
|
33777
33916
|
}
|
|
33778
33917
|
|
|
33779
33918
|
// src/commands/voice/devices.ts
|
|
33780
33919
|
function devices() {
|
|
33781
|
-
const script =
|
|
33920
|
+
const script = join90(getPythonDir(), "list_devices.py");
|
|
33782
33921
|
spawnSync9(getVenvPython(), [script], { stdio: "inherit" });
|
|
33783
33922
|
}
|
|
33784
33923
|
|
|
33785
33924
|
// src/commands/voice/logs.ts
|
|
33786
|
-
import { existsSync as
|
|
33925
|
+
import { existsSync as existsSync76, readFileSync as readFileSync58 } from "fs";
|
|
33787
33926
|
function logs(options2) {
|
|
33788
|
-
if (!
|
|
33927
|
+
if (!existsSync76(voicePaths.log)) {
|
|
33789
33928
|
console.log("No voice log file found");
|
|
33790
33929
|
return;
|
|
33791
33930
|
}
|
|
33792
33931
|
const count8 = Number.parseInt(options2.lines ?? "150", 10);
|
|
33793
|
-
const content =
|
|
33932
|
+
const content = readFileSync58(voicePaths.log, "utf8").trim();
|
|
33794
33933
|
if (!content) {
|
|
33795
33934
|
console.log("Voice log is empty");
|
|
33796
33935
|
return;
|
|
@@ -33813,12 +33952,12 @@ function logs(options2) {
|
|
|
33813
33952
|
// src/commands/voice/setup.ts
|
|
33814
33953
|
import { spawnSync as spawnSync10 } from "child_process";
|
|
33815
33954
|
import { mkdirSync as mkdirSync31 } from "fs";
|
|
33816
|
-
import { join as
|
|
33955
|
+
import { join as join92 } from "path";
|
|
33817
33956
|
|
|
33818
33957
|
// src/commands/voice/checkLockFile.ts
|
|
33819
33958
|
import { execSync as execSync60 } from "child_process";
|
|
33820
|
-
import { existsSync as
|
|
33821
|
-
import { join as
|
|
33959
|
+
import { existsSync as existsSync77, mkdirSync as mkdirSync30, readFileSync as readFileSync59, writeFileSync as writeFileSync48 } from "fs";
|
|
33960
|
+
import { join as join91 } from "path";
|
|
33822
33961
|
function isProcessAlive2(pid) {
|
|
33823
33962
|
try {
|
|
33824
33963
|
process.kill(pid, 0);
|
|
@@ -33829,9 +33968,9 @@ function isProcessAlive2(pid) {
|
|
|
33829
33968
|
}
|
|
33830
33969
|
function checkLockFile() {
|
|
33831
33970
|
const lockFile = getLockFile();
|
|
33832
|
-
if (!
|
|
33971
|
+
if (!existsSync77(lockFile)) return;
|
|
33833
33972
|
try {
|
|
33834
|
-
const lock2 = JSON.parse(
|
|
33973
|
+
const lock2 = JSON.parse(readFileSync59(lockFile, "utf8"));
|
|
33835
33974
|
if (lock2.pid && isProcessAlive2(lock2.pid)) {
|
|
33836
33975
|
console.error(
|
|
33837
33976
|
`Voice daemon already running (PID ${lock2.pid}, env: ${lock2.env}). Stop it first with: assist voice stop`
|
|
@@ -33842,7 +33981,7 @@ function checkLockFile() {
|
|
|
33842
33981
|
}
|
|
33843
33982
|
}
|
|
33844
33983
|
function bootstrapVenv() {
|
|
33845
|
-
if (
|
|
33984
|
+
if (existsSync77(getVenvPython())) return;
|
|
33846
33985
|
console.log("Setting up Python environment...");
|
|
33847
33986
|
const pythonDir = getPythonDir();
|
|
33848
33987
|
execSync60(
|
|
@@ -33855,7 +33994,7 @@ function bootstrapVenv() {
|
|
|
33855
33994
|
}
|
|
33856
33995
|
function writeLockFile(pid) {
|
|
33857
33996
|
const lockFile = getLockFile();
|
|
33858
|
-
mkdirSync30(
|
|
33997
|
+
mkdirSync30(join91(lockFile, ".."), { recursive: true });
|
|
33859
33998
|
writeFileSync48(
|
|
33860
33999
|
lockFile,
|
|
33861
34000
|
JSON.stringify({
|
|
@@ -33871,7 +34010,7 @@ function setup() {
|
|
|
33871
34010
|
mkdirSync31(voicePaths.dir, { recursive: true });
|
|
33872
34011
|
bootstrapVenv();
|
|
33873
34012
|
console.log("\nDownloading models...\n");
|
|
33874
|
-
const script =
|
|
34013
|
+
const script = join92(getPythonDir(), "setup_models.py");
|
|
33875
34014
|
const result = spawnSync10(getVenvPython(), [script], {
|
|
33876
34015
|
stdio: "inherit",
|
|
33877
34016
|
env: { ...process.env, VOICE_LOG_FILE: voicePaths.log }
|
|
@@ -33885,7 +34024,7 @@ function setup() {
|
|
|
33885
34024
|
// src/commands/voice/start.ts
|
|
33886
34025
|
import { spawn as spawn8 } from "child_process";
|
|
33887
34026
|
import { mkdirSync as mkdirSync32, writeFileSync as writeFileSync49 } from "fs";
|
|
33888
|
-
import { join as
|
|
34027
|
+
import { join as join93 } from "path";
|
|
33889
34028
|
|
|
33890
34029
|
// src/commands/voice/buildDaemonEnv.ts
|
|
33891
34030
|
function buildDaemonEnv(options2) {
|
|
@@ -33923,7 +34062,7 @@ function start2(options2) {
|
|
|
33923
34062
|
bootstrapVenv();
|
|
33924
34063
|
const debug = options2.debug || options2.foreground || process.platform === "win32";
|
|
33925
34064
|
const env = buildDaemonEnv({ debug });
|
|
33926
|
-
const script =
|
|
34065
|
+
const script = join93(getPythonDir(), "voice_daemon.py");
|
|
33927
34066
|
const python = getVenvPython();
|
|
33928
34067
|
if (options2.foreground) {
|
|
33929
34068
|
spawnForeground(python, script, env);
|
|
@@ -33933,7 +34072,7 @@ function start2(options2) {
|
|
|
33933
34072
|
}
|
|
33934
34073
|
|
|
33935
34074
|
// src/commands/voice/status.ts
|
|
33936
|
-
import { existsSync as
|
|
34075
|
+
import { existsSync as existsSync78, readFileSync as readFileSync60 } from "fs";
|
|
33937
34076
|
function isProcessAlive3(pid) {
|
|
33938
34077
|
try {
|
|
33939
34078
|
process.kill(pid, 0);
|
|
@@ -33943,16 +34082,16 @@ function isProcessAlive3(pid) {
|
|
|
33943
34082
|
}
|
|
33944
34083
|
}
|
|
33945
34084
|
function readRecentLogs(count8) {
|
|
33946
|
-
if (!
|
|
33947
|
-
const lines2 =
|
|
34085
|
+
if (!existsSync78(voicePaths.log)) return [];
|
|
34086
|
+
const lines2 = readFileSync60(voicePaths.log, "utf8").trim().split("\n");
|
|
33948
34087
|
return lines2.slice(-count8);
|
|
33949
34088
|
}
|
|
33950
34089
|
function status2() {
|
|
33951
|
-
if (!
|
|
34090
|
+
if (!existsSync78(voicePaths.pid)) {
|
|
33952
34091
|
console.log("Voice daemon: not running (no PID file)");
|
|
33953
34092
|
return;
|
|
33954
34093
|
}
|
|
33955
|
-
const pid = Number.parseInt(
|
|
34094
|
+
const pid = Number.parseInt(readFileSync60(voicePaths.pid, "utf8").trim(), 10);
|
|
33956
34095
|
const alive = isProcessAlive3(pid);
|
|
33957
34096
|
console.log(`Voice daemon: ${alive ? "running" : "dead"} (PID ${pid})`);
|
|
33958
34097
|
const recent = readRecentLogs(5);
|
|
@@ -33971,13 +34110,13 @@ function status2() {
|
|
|
33971
34110
|
}
|
|
33972
34111
|
|
|
33973
34112
|
// src/commands/voice/stop.ts
|
|
33974
|
-
import { existsSync as
|
|
34113
|
+
import { existsSync as existsSync79, readFileSync as readFileSync61, unlinkSync as unlinkSync20 } from "fs";
|
|
33975
34114
|
function stop2() {
|
|
33976
|
-
if (!
|
|
34115
|
+
if (!existsSync79(voicePaths.pid)) {
|
|
33977
34116
|
console.log("Voice daemon is not running (no PID file)");
|
|
33978
34117
|
return;
|
|
33979
34118
|
}
|
|
33980
|
-
const pid = Number.parseInt(
|
|
34119
|
+
const pid = Number.parseInt(readFileSync61(voicePaths.pid, "utf8").trim(), 10);
|
|
33981
34120
|
try {
|
|
33982
34121
|
process.kill(pid, "SIGTERM");
|
|
33983
34122
|
console.log(`Sent SIGTERM to voice daemon (PID ${pid})`);
|
|
@@ -33990,7 +34129,7 @@ function stop2() {
|
|
|
33990
34129
|
}
|
|
33991
34130
|
try {
|
|
33992
34131
|
const lockFile = getLockFile();
|
|
33993
|
-
if (
|
|
34132
|
+
if (existsSync79(lockFile)) unlinkSync20(lockFile);
|
|
33994
34133
|
} catch {
|
|
33995
34134
|
}
|
|
33996
34135
|
console.log("Voice daemon stopped");
|
|
@@ -34054,11 +34193,11 @@ function changedPaths(from, cwd) {
|
|
|
34054
34193
|
}
|
|
34055
34194
|
|
|
34056
34195
|
// src/commands/watch/readBuiltVersion.ts
|
|
34057
|
-
import { join as
|
|
34196
|
+
import { join as join94 } from "path";
|
|
34058
34197
|
function readBuiltVersion(cwd) {
|
|
34059
34198
|
try {
|
|
34060
34199
|
const root = runGit3(["rev-parse", "--show-toplevel"], cwd);
|
|
34061
|
-
return readPackageJson(
|
|
34200
|
+
return readPackageJson(join94(root, "package.json")).version ?? "unknown";
|
|
34062
34201
|
} catch {
|
|
34063
34202
|
return "unknown";
|
|
34064
34203
|
}
|
|
@@ -34395,7 +34534,7 @@ function resolveParams(params, cliArgs) {
|
|
|
34395
34534
|
}
|
|
34396
34535
|
|
|
34397
34536
|
// src/commands/run/resolveRunCwd.ts
|
|
34398
|
-
import { existsSync as
|
|
34537
|
+
import { existsSync as existsSync80 } from "fs";
|
|
34399
34538
|
import { resolve as resolve19 } from "path";
|
|
34400
34539
|
var MissingRunCwdError = class extends Error {
|
|
34401
34540
|
constructor(runName, cwd) {
|
|
@@ -34408,25 +34547,25 @@ var MissingRunCwdError = class extends Error {
|
|
|
34408
34547
|
function resolveRunCwd(config, baseDir = runConfigBaseDir()) {
|
|
34409
34548
|
if (!config.cwd) return void 0;
|
|
34410
34549
|
const cwd = resolve19(baseDir, config.cwd);
|
|
34411
|
-
if (!
|
|
34550
|
+
if (!existsSync80(cwd)) throw new MissingRunCwdError(config.name, cwd);
|
|
34412
34551
|
return cwd;
|
|
34413
34552
|
}
|
|
34414
34553
|
|
|
34415
34554
|
// src/commands/run/runCommandToCompletion.ts
|
|
34416
34555
|
import { spawn as spawn9 } from "child_process";
|
|
34417
|
-
import { existsSync as
|
|
34556
|
+
import { existsSync as existsSync82 } from "fs";
|
|
34418
34557
|
|
|
34419
34558
|
// src/commands/run/resolveCommand.ts
|
|
34420
34559
|
import { execFileSync as execFileSync18 } from "child_process";
|
|
34421
|
-
import { existsSync as
|
|
34422
|
-
import { dirname as
|
|
34560
|
+
import { existsSync as existsSync81 } from "fs";
|
|
34561
|
+
import { dirname as dirname38, join as join95, resolve as resolve20 } from "path";
|
|
34423
34562
|
function resolveCommand2(command) {
|
|
34424
34563
|
if (process.platform !== "win32" || command !== "bash") return command;
|
|
34425
34564
|
try {
|
|
34426
34565
|
const gitPath = execFileSync18("where", ["git"], { encoding: "utf8" }).trim().split("\r\n")[0];
|
|
34427
|
-
const gitRoot = resolve20(
|
|
34428
|
-
const gitBash =
|
|
34429
|
-
if (
|
|
34566
|
+
const gitRoot = resolve20(dirname38(gitPath), "..");
|
|
34567
|
+
const gitBash = join95(gitRoot, "bin", "bash.exe");
|
|
34568
|
+
if (existsSync81(gitBash)) return gitBash;
|
|
34430
34569
|
} catch {
|
|
34431
34570
|
return command;
|
|
34432
34571
|
}
|
|
@@ -34436,7 +34575,7 @@ function resolveCommand2(command) {
|
|
|
34436
34575
|
// src/commands/run/runCommandToCompletion.ts
|
|
34437
34576
|
function runCommandToCompletion(command, args, env, cwd, quiet) {
|
|
34438
34577
|
return new Promise((resolveResult) => {
|
|
34439
|
-
if (cwd && !
|
|
34578
|
+
if (cwd && !existsSync82(cwd)) {
|
|
34440
34579
|
resolveResult({
|
|
34441
34580
|
kind: "failed",
|
|
34442
34581
|
message: `Failed to execute command: cwd ${cwd} does not exist`
|
|
@@ -34852,17 +34991,17 @@ async function auth() {
|
|
|
34852
34991
|
|
|
34853
34992
|
// src/commands/roam/postRoamActivity.ts
|
|
34854
34993
|
import { execFileSync as execFileSync20 } from "child_process";
|
|
34855
|
-
import { readdirSync as
|
|
34856
|
-
import { join as
|
|
34994
|
+
import { readdirSync as readdirSync22, readFileSync as readFileSync62, statSync as statSync12 } from "fs";
|
|
34995
|
+
import { join as join96 } from "path";
|
|
34857
34996
|
function findPortFile(roamDir) {
|
|
34858
34997
|
let entries;
|
|
34859
34998
|
try {
|
|
34860
|
-
entries =
|
|
34999
|
+
entries = readdirSync22(roamDir);
|
|
34861
35000
|
} catch {
|
|
34862
35001
|
return void 0;
|
|
34863
35002
|
}
|
|
34864
35003
|
const candidates = entries.filter((name) => /^roam-local-api(-[^.]+)?\.port$/.test(name)).map((name) => {
|
|
34865
|
-
const path91 =
|
|
35004
|
+
const path91 = join96(roamDir, name);
|
|
34866
35005
|
try {
|
|
34867
35006
|
return { path: path91, mtimeMs: statSync12(path91).mtimeMs };
|
|
34868
35007
|
} catch {
|
|
@@ -34879,11 +35018,11 @@ var PID_BY_APP = {
|
|
|
34879
35018
|
function postRoamActivity(app, event) {
|
|
34880
35019
|
const appData = process.env.APPDATA;
|
|
34881
35020
|
if (!appData) return;
|
|
34882
|
-
const portFile = findPortFile(
|
|
35021
|
+
const portFile = findPortFile(join96(appData, "Roam"));
|
|
34883
35022
|
if (!portFile) return;
|
|
34884
35023
|
let port;
|
|
34885
35024
|
try {
|
|
34886
|
-
port =
|
|
35025
|
+
port = readFileSync62(portFile, "utf8").trim();
|
|
34887
35026
|
} catch {
|
|
34888
35027
|
return;
|
|
34889
35028
|
}
|
|
@@ -35015,7 +35154,7 @@ async function run3(name, args) {
|
|
|
35015
35154
|
|
|
35016
35155
|
// src/commands/run/add.ts
|
|
35017
35156
|
import { mkdirSync as mkdirSync33, writeFileSync as writeFileSync50 } from "fs";
|
|
35018
|
-
import { join as
|
|
35157
|
+
import { join as join97 } from "path";
|
|
35019
35158
|
|
|
35020
35159
|
// src/commands/run/extractOption.ts
|
|
35021
35160
|
function extractOption(args, flag) {
|
|
@@ -35076,7 +35215,7 @@ function saveNewRunConfig(name, command, args, cwd) {
|
|
|
35076
35215
|
saveConfig(config);
|
|
35077
35216
|
}
|
|
35078
35217
|
function createCommandFile(name) {
|
|
35079
|
-
const dir =
|
|
35218
|
+
const dir = join97(".claude", "commands");
|
|
35080
35219
|
mkdirSync33(dir, { recursive: true });
|
|
35081
35220
|
const content = `---
|
|
35082
35221
|
description: Run ${name}
|
|
@@ -35084,7 +35223,7 @@ description: Run ${name}
|
|
|
35084
35223
|
|
|
35085
35224
|
Run \`assist run ${name} $ARGUMENTS 2>&1\`.
|
|
35086
35225
|
`;
|
|
35087
|
-
const filePath =
|
|
35226
|
+
const filePath = join97(dir, `${name}.md`);
|
|
35088
35227
|
writeFileSync50(filePath, content);
|
|
35089
35228
|
console.log(`Created command file: ${filePath}`);
|
|
35090
35229
|
}
|
|
@@ -35140,8 +35279,8 @@ function link2() {
|
|
|
35140
35279
|
}
|
|
35141
35280
|
|
|
35142
35281
|
// src/commands/run/remove.ts
|
|
35143
|
-
import { existsSync as
|
|
35144
|
-
import { join as
|
|
35282
|
+
import { existsSync as existsSync83, unlinkSync as unlinkSync21 } from "fs";
|
|
35283
|
+
import { join as join98 } from "path";
|
|
35145
35284
|
function findRemoveIndex() {
|
|
35146
35285
|
const idx = process.argv.indexOf("remove");
|
|
35147
35286
|
if (idx === -1 || idx + 1 >= process.argv.length) return -1;
|
|
@@ -35156,8 +35295,8 @@ function parseRemoveName() {
|
|
|
35156
35295
|
return process.argv[idx + 1];
|
|
35157
35296
|
}
|
|
35158
35297
|
function deleteCommandFile(name) {
|
|
35159
|
-
const filePath =
|
|
35160
|
-
if (
|
|
35298
|
+
const filePath = join98(".claude", "commands", `${name}.md`);
|
|
35299
|
+
if (existsSync83(filePath)) {
|
|
35161
35300
|
unlinkSync21(filePath);
|
|
35162
35301
|
console.log(`Deleted command file: ${filePath}`);
|
|
35163
35302
|
}
|
|
@@ -35202,9 +35341,9 @@ function registerRun(program2) {
|
|
|
35202
35341
|
|
|
35203
35342
|
// src/commands/screenshot/index.ts
|
|
35204
35343
|
import { execSync as execSync62 } from "child_process";
|
|
35205
|
-
import { existsSync as
|
|
35344
|
+
import { existsSync as existsSync84, mkdirSync as mkdirSync34, unlinkSync as unlinkSync22, writeFileSync as writeFileSync51 } from "fs";
|
|
35206
35345
|
import { tmpdir as tmpdir9 } from "os";
|
|
35207
|
-
import { join as
|
|
35346
|
+
import { join as join99, resolve as resolve21 } from "path";
|
|
35208
35347
|
import chalk229 from "chalk";
|
|
35209
35348
|
|
|
35210
35349
|
// src/commands/screenshot/captureWindowPs1.ts
|
|
@@ -35334,14 +35473,14 @@ Write-Output $OutputPath
|
|
|
35334
35473
|
|
|
35335
35474
|
// src/commands/screenshot/index.ts
|
|
35336
35475
|
function buildOutputPath(outputDir, processName) {
|
|
35337
|
-
if (!
|
|
35476
|
+
if (!existsSync84(outputDir)) {
|
|
35338
35477
|
mkdirSync34(outputDir, { recursive: true });
|
|
35339
35478
|
}
|
|
35340
35479
|
const timestamp6 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
35341
35480
|
return resolve21(outputDir, `${processName}-${timestamp6}.png`);
|
|
35342
35481
|
}
|
|
35343
35482
|
function runPowerShellScript(processName, outputPath) {
|
|
35344
|
-
const scriptPath =
|
|
35483
|
+
const scriptPath = join99(tmpdir9(), `assist-screenshot-${Date.now()}.ps1`);
|
|
35345
35484
|
writeFileSync51(scriptPath, captureWindowPs1, "utf8");
|
|
35346
35485
|
try {
|
|
35347
35486
|
execSync62(
|
|
@@ -35418,11 +35557,11 @@ function applyLine(result, pending, line) {
|
|
|
35418
35557
|
}
|
|
35419
35558
|
|
|
35420
35559
|
// src/commands/sessions/daemon/readDaemonPidFile.ts
|
|
35421
|
-
import { readFileSync as
|
|
35560
|
+
import { readFileSync as readFileSync63 } from "fs";
|
|
35422
35561
|
function readDaemonPidFile() {
|
|
35423
35562
|
try {
|
|
35424
35563
|
const pid = Number.parseInt(
|
|
35425
|
-
|
|
35564
|
+
readFileSync63(daemonPaths.pid, "utf8").trim(),
|
|
35426
35565
|
10
|
|
35427
35566
|
);
|
|
35428
35567
|
return Number.isInteger(pid) ? pid : void 0;
|
|
@@ -35685,12 +35824,12 @@ function toSessionRunInfo({
|
|
|
35685
35824
|
}
|
|
35686
35825
|
|
|
35687
35826
|
// src/commands/sessions/daemon/worktree/joinRefusal.ts
|
|
35688
|
-
import { existsSync as
|
|
35827
|
+
import { existsSync as existsSync85 } from "fs";
|
|
35689
35828
|
function joinRefusal(session) {
|
|
35690
35829
|
if (session.commandType === "run") return "a server run has no agent stream";
|
|
35691
35830
|
if (session.closing === true) return "the session is closing";
|
|
35692
35831
|
if (!session.cwd) return "the session has no working directory";
|
|
35693
|
-
if (!
|
|
35832
|
+
if (!existsSync85(session.cwd))
|
|
35694
35833
|
return "the session's workspace no longer exists";
|
|
35695
35834
|
return void 0;
|
|
35696
35835
|
}
|
|
@@ -35854,11 +35993,11 @@ function sessionBase(id, status3) {
|
|
|
35854
35993
|
}
|
|
35855
35994
|
|
|
35856
35995
|
// src/commands/sessions/daemon/spawnPty.ts
|
|
35857
|
-
import { existsSync as
|
|
35996
|
+
import { existsSync as existsSync87 } from "fs";
|
|
35858
35997
|
import * as pty from "node-pty";
|
|
35859
35998
|
|
|
35860
35999
|
// src/commands/sessions/daemon/ensureSpawnHelperExecutable.ts
|
|
35861
|
-
import { chmodSync, existsSync as
|
|
36000
|
+
import { chmodSync, existsSync as existsSync86, statSync as statSync13 } from "fs";
|
|
35862
36001
|
import { createRequire as createRequire3 } from "module";
|
|
35863
36002
|
import path86 from "path";
|
|
35864
36003
|
var require4 = createRequire3(import.meta.url);
|
|
@@ -35873,7 +36012,7 @@ function ensureSpawnHelperExecutable() {
|
|
|
35873
36012
|
`${process.platform}-${process.arch}`,
|
|
35874
36013
|
"spawn-helper"
|
|
35875
36014
|
);
|
|
35876
|
-
if (!
|
|
36015
|
+
if (!existsSync86(helper)) return;
|
|
35877
36016
|
const mode = statSync13(helper).mode;
|
|
35878
36017
|
if ((mode & 73) === 0) chmodSync(helper, mode | 493);
|
|
35879
36018
|
}
|
|
@@ -35909,7 +36048,7 @@ function spawnPty(args, cwd, sessionId, extraEnv) {
|
|
|
35909
36048
|
});
|
|
35910
36049
|
}
|
|
35911
36050
|
function refuseMissingCwd(cwd, sessionId) {
|
|
35912
|
-
if (!cwd ||
|
|
36051
|
+
if (!cwd || existsSync87(cwd)) return;
|
|
35913
36052
|
daemonLog(
|
|
35914
36053
|
`${sessionId ? `session ${sessionId}` : "pty"} not spawned: working directory ${cwd} no longer exists`
|
|
35915
36054
|
);
|
|
@@ -35989,8 +36128,8 @@ function serverRunMeta(runName, cwd) {
|
|
|
35989
36128
|
// src/commands/sessions/daemon/readDesignSystemPrompt.ts
|
|
35990
36129
|
import * as fs49 from "fs";
|
|
35991
36130
|
import * as path87 from "path";
|
|
35992
|
-
import { fileURLToPath as
|
|
35993
|
-
var __filename5 =
|
|
36131
|
+
import { fileURLToPath as fileURLToPath11 } from "url";
|
|
36132
|
+
var __filename5 = fileURLToPath11(import.meta.url);
|
|
35994
36133
|
var __dirname7 = path87.dirname(__filename5);
|
|
35995
36134
|
function readDesignSystemPrompt() {
|
|
35996
36135
|
const promptPath = path87.join(
|
|
@@ -36091,17 +36230,17 @@ function setStatus2(session, newStatus) {
|
|
|
36091
36230
|
}
|
|
36092
36231
|
|
|
36093
36232
|
// src/commands/sessions/daemon/worktree/reapWorktree.ts
|
|
36094
|
-
import { existsSync as
|
|
36095
|
-
import { basename as
|
|
36233
|
+
import { existsSync as existsSync89 } from "fs";
|
|
36234
|
+
import { basename as basename25 } from "path";
|
|
36096
36235
|
|
|
36097
36236
|
// src/commands/sessions/daemon/worktree/deleteStrandedTree.ts
|
|
36098
|
-
import { existsSync as
|
|
36099
|
-
import { join as
|
|
36237
|
+
import { existsSync as existsSync88 } from "fs";
|
|
36238
|
+
import { join as join102 } from "path";
|
|
36100
36239
|
|
|
36101
36240
|
// src/commands/sessions/daemon/worktree/deleteTreeDirectly.ts
|
|
36102
36241
|
import { statSync as statSync14 } from "fs";
|
|
36103
36242
|
import { rm as rm4 } from "fs/promises";
|
|
36104
|
-
import { join as
|
|
36243
|
+
import { join as join101 } from "path";
|
|
36105
36244
|
async function deleteTreeDirectly(clone, worktreePath, why) {
|
|
36106
36245
|
if (holdsAGitDirectoryRatherThanALink(worktreePath)) {
|
|
36107
36246
|
const refusal = "it is a clone of its own, not a linked worktree";
|
|
@@ -36129,7 +36268,7 @@ async function deleteTreeDirectly(clone, worktreePath, why) {
|
|
|
36129
36268
|
return { removed: true };
|
|
36130
36269
|
}
|
|
36131
36270
|
function holdsAGitDirectoryRatherThanALink(worktreePath) {
|
|
36132
|
-
return statSync14(
|
|
36271
|
+
return statSync14(join101(worktreePath, ".git"), {
|
|
36133
36272
|
throwIfNoEntry: false
|
|
36134
36273
|
})?.isDirectory() === true;
|
|
36135
36274
|
}
|
|
@@ -36165,7 +36304,7 @@ async function deleteStrandedTree(clone, worktreePath, cause) {
|
|
|
36165
36304
|
);
|
|
36166
36305
|
}
|
|
36167
36306
|
function strandedReason(worktreePath, cause) {
|
|
36168
|
-
if (!
|
|
36307
|
+
if (!existsSync88(join102(worktreePath, ".git")))
|
|
36169
36308
|
return "its .git link is already gone";
|
|
36170
36309
|
if (/not a working tree|not a git repository/i.test(reason2(cause)))
|
|
36171
36310
|
return "git no longer recognises it as a working tree";
|
|
@@ -36217,7 +36356,7 @@ function reason3(error) {
|
|
|
36217
36356
|
|
|
36218
36357
|
// src/commands/sessions/daemon/worktree/reapWorktree.ts
|
|
36219
36358
|
async function reapWorktree(worktreePath, force = false) {
|
|
36220
|
-
if (!
|
|
36359
|
+
if (!existsSync89(worktreePath)) {
|
|
36221
36360
|
forgetWorktree(worktreePath);
|
|
36222
36361
|
daemonLog(
|
|
36223
36362
|
`worktree ${worktreePath} already gone; its record was forgotten`
|
|
@@ -36235,14 +36374,14 @@ async function reapWorktree(worktreePath, force = false) {
|
|
|
36235
36374
|
const clone = owningClone(worktreePath);
|
|
36236
36375
|
const removal = await removeTree(clone, worktreePath, force);
|
|
36237
36376
|
if (!removal.removed) return removal;
|
|
36238
|
-
await deleteWorktreeBranch(clone,
|
|
36377
|
+
await deleteWorktreeBranch(clone, basename25(worktreePath));
|
|
36239
36378
|
forgetWorktree(worktreePath);
|
|
36240
36379
|
daemonLog(`worktree ${worktreePath} reaped${force ? " (forced)" : ""}`);
|
|
36241
36380
|
return removal;
|
|
36242
36381
|
}
|
|
36243
36382
|
function owningClone(worktreePath) {
|
|
36244
36383
|
const recorded = worktreeAttributionIncludingReaped(worktreePath)?.clone;
|
|
36245
|
-
if (recorded &&
|
|
36384
|
+
if (recorded && existsSync89(recorded)) return recorded;
|
|
36246
36385
|
const detected = mainWorktree(worktreePath);
|
|
36247
36386
|
if (detected) return detected;
|
|
36248
36387
|
daemonLog(
|
|
@@ -36373,12 +36512,12 @@ function closeGateApplies(sessions, session) {
|
|
|
36373
36512
|
}
|
|
36374
36513
|
|
|
36375
36514
|
// src/commands/sessions/daemon/worktree/watchGitState.ts
|
|
36376
|
-
import { existsSync as
|
|
36515
|
+
import { existsSync as existsSync90, watch } from "fs";
|
|
36377
36516
|
var DEBOUNCE_MS = 500;
|
|
36378
36517
|
var POLL_MS = 3e4;
|
|
36379
36518
|
function watchGitState(cwd, onChange) {
|
|
36380
36519
|
const common = gitCommonDir(cwd);
|
|
36381
|
-
if (!common || !
|
|
36520
|
+
if (!common || !existsSync90(common)) return void 0;
|
|
36382
36521
|
const watchers = [
|
|
36383
36522
|
watchGitDir(common, onChange),
|
|
36384
36523
|
pollGitState(cwd, onChange)
|
|
@@ -36869,10 +37008,10 @@ function emitSessionOutput(session, clients, data) {
|
|
|
36869
37008
|
}
|
|
36870
37009
|
|
|
36871
37010
|
// src/commands/sessions/daemon/exitReason.ts
|
|
36872
|
-
import { existsSync as
|
|
37011
|
+
import { existsSync as existsSync91 } from "fs";
|
|
36873
37012
|
import { resolve as resolve22 } from "path";
|
|
36874
37013
|
function exitDetail(session) {
|
|
36875
|
-
if (session.cwd && !
|
|
37014
|
+
if (session.cwd && !existsSync91(session.cwd))
|
|
36876
37015
|
return `working directory ${session.cwd} no longer exists`;
|
|
36877
37016
|
return missingRunConfigCwd(session);
|
|
36878
37017
|
}
|
|
@@ -36886,7 +37025,7 @@ function missingRunConfigCwd(session) {
|
|
|
36886
37025
|
const config = resolveRunConfig(session.runName, dir);
|
|
36887
37026
|
if (!config?.cwd) return void 0;
|
|
36888
37027
|
const configured = resolve22(runConfigBaseDirFrom(dir), config.cwd);
|
|
36889
|
-
if (
|
|
37028
|
+
if (existsSync91(configured)) return void 0;
|
|
36890
37029
|
return `run config "${config.name}": cwd ${configured} does not exist`;
|
|
36891
37030
|
}
|
|
36892
37031
|
|
|
@@ -36923,8 +37062,8 @@ function handleFailedResume(session, exitCode, onStatusChange) {
|
|
|
36923
37062
|
}
|
|
36924
37063
|
|
|
36925
37064
|
// src/commands/sessions/daemon/watchActivity.ts
|
|
36926
|
-
import { existsSync as
|
|
36927
|
-
import { dirname as
|
|
37065
|
+
import { existsSync as existsSync92, mkdirSync as mkdirSync35, watch as watch2 } from "fs";
|
|
37066
|
+
import { dirname as dirname40 } from "path";
|
|
36928
37067
|
|
|
36929
37068
|
// src/commands/sessions/daemon/applyActivityToSession.ts
|
|
36930
37069
|
function applyActivityToSession(session, activity2) {
|
|
@@ -36986,7 +37125,7 @@ var DEBOUNCE_MS2 = 50;
|
|
|
36986
37125
|
function watchActivity(session, notify2, onClaudeSessionId) {
|
|
36987
37126
|
if (session.commandType !== "assist" || !session.cwd) return;
|
|
36988
37127
|
const path91 = activityPath(session.id);
|
|
36989
|
-
const dir =
|
|
37128
|
+
const dir = dirname40(path91);
|
|
36990
37129
|
try {
|
|
36991
37130
|
mkdirSync35(dir, { recursive: true });
|
|
36992
37131
|
} catch {
|
|
@@ -37009,7 +37148,7 @@ function watchActivity(session, notify2, onClaudeSessionId) {
|
|
|
37009
37148
|
if (timer) clearTimeout(timer);
|
|
37010
37149
|
timer = setTimeout(read3, DEBOUNCE_MS2);
|
|
37011
37150
|
});
|
|
37012
|
-
if (
|
|
37151
|
+
if (existsSync92(path91)) read3();
|
|
37013
37152
|
}
|
|
37014
37153
|
function refreshActivity(session) {
|
|
37015
37154
|
if (session.commandType !== "assist" || !session.cwd) return;
|
|
@@ -38732,8 +38871,8 @@ function rearmStoppedSessions(sessions, notify2) {
|
|
|
38732
38871
|
}
|
|
38733
38872
|
|
|
38734
38873
|
// src/commands/sessions/daemon/worktree/reconcileWorktreesOnRestore.ts
|
|
38735
|
-
import { existsSync as
|
|
38736
|
-
import { basename as
|
|
38874
|
+
import { existsSync as existsSync95 } from "fs";
|
|
38875
|
+
import { basename as basename27 } from "path";
|
|
38737
38876
|
|
|
38738
38877
|
// src/commands/sessions/daemon/worktree/accountedTrees.ts
|
|
38739
38878
|
function accountedTrees(sessions) {
|
|
@@ -38787,9 +38926,9 @@ function bindResumedWorktree(session, cwd, notify2) {
|
|
|
38787
38926
|
}
|
|
38788
38927
|
|
|
38789
38928
|
// src/commands/sessions/daemon/worktree/reclaimVanishedWorktrees.ts
|
|
38790
|
-
import { existsSync as
|
|
38929
|
+
import { existsSync as existsSync94 } from "fs";
|
|
38791
38930
|
async function reclaimVanishedWorktrees(clone, paths) {
|
|
38792
|
-
if (!
|
|
38931
|
+
if (!existsSync94(clone)) {
|
|
38793
38932
|
for (const { path: path91 } of paths) forgetWorktree(path91);
|
|
38794
38933
|
daemonLog(
|
|
38795
38934
|
`clone ${clone} is gone; forgot ${paths.length} worktree record(s) it owned`
|
|
@@ -38875,7 +39014,7 @@ function capped(lines2) {
|
|
|
38875
39014
|
}
|
|
38876
39015
|
|
|
38877
39016
|
// src/commands/sessions/daemon/worktree/resurfaceOrphanedWorktree.ts
|
|
38878
|
-
import { basename as
|
|
39017
|
+
import { basename as basename26 } from "path";
|
|
38879
39018
|
function resurfaceOrphanedWorktree(sessions, spawnWith, recovered, notify2) {
|
|
38880
39019
|
const { orphan, reason: reason4, held } = recovered;
|
|
38881
39020
|
let id;
|
|
@@ -38898,7 +39037,7 @@ function orphanedSession(id, recovered) {
|
|
|
38898
39037
|
const { orphan, reason: reason4, held } = recovered;
|
|
38899
39038
|
return {
|
|
38900
39039
|
...sessionBase(id, "stopped"),
|
|
38901
|
-
name: `recovered ${
|
|
39040
|
+
name: `recovered ${basename26(orphan.path)}`,
|
|
38902
39041
|
subtitle: `${held.summary} in ${orphan.path}`,
|
|
38903
39042
|
commandType: "claude",
|
|
38904
39043
|
pty: null,
|
|
@@ -38955,11 +39094,11 @@ async function recoverOrphanedWorktrees(sessions, spawnWith, notify2) {
|
|
|
38955
39094
|
);
|
|
38956
39095
|
continue;
|
|
38957
39096
|
}
|
|
38958
|
-
if (!
|
|
39097
|
+
if (!existsSync95(path91)) {
|
|
38959
39098
|
logVanishedTree(sessions, path91);
|
|
38960
39099
|
vanished.set(clone, [
|
|
38961
39100
|
...vanished.get(clone) ?? [],
|
|
38962
|
-
{ path: path91, branch:
|
|
39101
|
+
{ path: path91, branch: basename27(path91) }
|
|
38963
39102
|
]);
|
|
38964
39103
|
continue;
|
|
38965
39104
|
}
|
|
@@ -39600,14 +39739,14 @@ async function defaultConnect() {
|
|
|
39600
39739
|
}
|
|
39601
39740
|
|
|
39602
39741
|
// src/commands/sessions/daemon/hasPersistedWindowsSessions.ts
|
|
39603
|
-
import { existsSync as
|
|
39742
|
+
import { existsSync as existsSync96, readFileSync as readFileSync65 } from "fs";
|
|
39604
39743
|
import { posix as posix3 } from "path";
|
|
39605
39744
|
function hasPersistedWindowsSessions() {
|
|
39606
39745
|
const sessionsFile = windowsSessionsFileFromWsl();
|
|
39607
39746
|
if (!sessionsFile) return false;
|
|
39608
39747
|
try {
|
|
39609
|
-
if (!
|
|
39610
|
-
const data = JSON.parse(
|
|
39748
|
+
if (!existsSync96(sessionsFile)) return false;
|
|
39749
|
+
const data = JSON.parse(readFileSync65(sessionsFile, "utf8"));
|
|
39611
39750
|
return Array.isArray(data) && data.length > 0;
|
|
39612
39751
|
} catch (error) {
|
|
39613
39752
|
const message3 = error instanceof Error ? error.message : String(error);
|
|
@@ -40341,7 +40480,7 @@ function setAutoAdvance(sessions, id, enabled) {
|
|
|
40341
40480
|
}
|
|
40342
40481
|
|
|
40343
40482
|
// src/commands/sessions/daemon/worktree/resumeInTree.ts
|
|
40344
|
-
import { existsSync as
|
|
40483
|
+
import { existsSync as existsSync99 } from "fs";
|
|
40345
40484
|
|
|
40346
40485
|
// src/commands/sessions/daemon/resumeSession.ts
|
|
40347
40486
|
function resumeSession(id, sessionId, cwd, name, holdPty, harness) {
|
|
@@ -40372,11 +40511,11 @@ function resumeSession(id, sessionId, cwd, name, holdPty, harness) {
|
|
|
40372
40511
|
}
|
|
40373
40512
|
|
|
40374
40513
|
// src/commands/sessions/daemon/worktree/resumeInReplacementTree.ts
|
|
40375
|
-
import { existsSync as
|
|
40514
|
+
import { existsSync as existsSync98 } from "fs";
|
|
40376
40515
|
|
|
40377
40516
|
// src/commands/sessions/daemon/worktree/carryTranscriptToTree.ts
|
|
40378
|
-
import { copyFileSync as copyFileSync7, existsSync as
|
|
40379
|
-
import { join as
|
|
40517
|
+
import { copyFileSync as copyFileSync7, existsSync as existsSync97, mkdirSync as mkdirSync37 } from "fs";
|
|
40518
|
+
import { join as join104 } from "path";
|
|
40380
40519
|
function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
40381
40520
|
const dir = projectDirForCwd(toCwd);
|
|
40382
40521
|
if (dir === projectDirForCwd(fromCwd)) {
|
|
@@ -40385,8 +40524,8 @@ function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
|
40385
40524
|
);
|
|
40386
40525
|
return;
|
|
40387
40526
|
}
|
|
40388
|
-
const dest =
|
|
40389
|
-
if (
|
|
40527
|
+
const dest = join104(dir, `${claudeSessionId}.jsonl`);
|
|
40528
|
+
if (existsSync97(dest)) {
|
|
40390
40529
|
daemonLog(`transcript ${claudeSessionId} already present in ${dir}`);
|
|
40391
40530
|
return;
|
|
40392
40531
|
}
|
|
@@ -40437,7 +40576,7 @@ function resumeInReplacementTree(ctx, claudeSessionId, missingCwd, name, harness
|
|
|
40437
40576
|
}
|
|
40438
40577
|
function cloneForReapedTree(missingCwd) {
|
|
40439
40578
|
const clone = worktreeAttributionIncludingReaped(missingCwd)?.clone;
|
|
40440
|
-
if (!clone || !
|
|
40579
|
+
if (!clone || !existsSync98(clone))
|
|
40441
40580
|
throw new Error(
|
|
40442
40581
|
`working directory no longer exists and no clone is recorded to re-allocate from: ${missingCwd}`
|
|
40443
40582
|
);
|
|
@@ -40446,7 +40585,7 @@ function cloneForReapedTree(missingCwd) {
|
|
|
40446
40585
|
|
|
40447
40586
|
// src/commands/sessions/daemon/worktree/resumeInTree.ts
|
|
40448
40587
|
function resumeInTree(ctx, sessionId, cwd, name, harness) {
|
|
40449
|
-
if (!
|
|
40588
|
+
if (!existsSync99(cwd))
|
|
40450
40589
|
return resumeInReplacementTree(ctx, sessionId, cwd, name, harness);
|
|
40451
40590
|
const id = ctx.spawnWith(
|
|
40452
40591
|
(sid) => resumeSession(sid, sessionId, cwd, name, void 0, harness)
|
|
@@ -41032,7 +41171,7 @@ function handleConnection(socket, manager) {
|
|
|
41032
41171
|
import { unlinkSync as unlinkSync23, writeFileSync as writeFileSync52 } from "fs";
|
|
41033
41172
|
|
|
41034
41173
|
// src/commands/sessions/daemon/startPidFileWatchdog.ts
|
|
41035
|
-
import { readFileSync as
|
|
41174
|
+
import { readFileSync as readFileSync66 } from "fs";
|
|
41036
41175
|
var WATCHDOG_INTERVAL_MS = 5e3;
|
|
41037
41176
|
function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
|
|
41038
41177
|
const timer = setInterval(() => {
|
|
@@ -41043,7 +41182,7 @@ function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
|
|
|
41043
41182
|
}
|
|
41044
41183
|
function ownsPidFile() {
|
|
41045
41184
|
try {
|
|
41046
|
-
return
|
|
41185
|
+
return readFileSync66(daemonPaths.pid, "utf8").trim() === String(process.pid);
|
|
41047
41186
|
} catch {
|
|
41048
41187
|
return false;
|
|
41049
41188
|
}
|
|
@@ -41536,10 +41675,10 @@ function buildLimitsSegment(rateLimits) {
|
|
|
41536
41675
|
}
|
|
41537
41676
|
|
|
41538
41677
|
// src/commands/readGitBranch.ts
|
|
41539
|
-
import { readFileSync as
|
|
41540
|
-
import { isAbsolute as isAbsolute5, join as
|
|
41678
|
+
import { readFileSync as readFileSync68, statSync as statSync16 } from "fs";
|
|
41679
|
+
import { isAbsolute as isAbsolute5, join as join105, resolve as resolve23 } from "path";
|
|
41541
41680
|
function resolveGitDir(cwd) {
|
|
41542
|
-
const dotGit =
|
|
41681
|
+
const dotGit = join105(cwd, ".git");
|
|
41543
41682
|
let stat4;
|
|
41544
41683
|
try {
|
|
41545
41684
|
stat4 = statSync16(dotGit);
|
|
@@ -41551,7 +41690,7 @@ function resolveGitDir(cwd) {
|
|
|
41551
41690
|
}
|
|
41552
41691
|
let contents;
|
|
41553
41692
|
try {
|
|
41554
|
-
contents =
|
|
41693
|
+
contents = readFileSync68(dotGit, "utf8");
|
|
41555
41694
|
} catch {
|
|
41556
41695
|
return null;
|
|
41557
41696
|
}
|
|
@@ -41569,7 +41708,7 @@ function readGitBranch(cwd) {
|
|
|
41569
41708
|
}
|
|
41570
41709
|
let head;
|
|
41571
41710
|
try {
|
|
41572
|
-
head =
|
|
41711
|
+
head = readFileSync68(join105(gitDir, "HEAD"), "utf8");
|
|
41573
41712
|
} catch {
|
|
41574
41713
|
return null;
|
|
41575
41714
|
}
|
|
@@ -41727,6 +41866,7 @@ program.command("coverage").description("Print global statement coverage percent
|
|
|
41727
41866
|
var screenshotCommand = program.command("screenshot").description("Capture a screenshot of a running application window").argument("<process>", "Name of the running process (e.g. notepad, code)").action(screenshot);
|
|
41728
41867
|
configHelp(screenshotCommand, rootConfigHelp.screenshot);
|
|
41729
41868
|
registerActivity(program);
|
|
41869
|
+
registerAdvise(program);
|
|
41730
41870
|
registerBackup(program);
|
|
41731
41871
|
registerDb(program);
|
|
41732
41872
|
registerDbMigration(program);
|