@staff0rd/assist 0.651.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 +686 -538
- 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(
|
|
@@ -25888,17 +26027,25 @@ function applyEdit(number, title, body) {
|
|
|
25888
26027
|
}
|
|
25889
26028
|
}
|
|
25890
26029
|
|
|
25891
|
-
// src/commands/prs/
|
|
26030
|
+
// src/commands/prs/formatResolvesReference.ts
|
|
26031
|
+
var SAME_REPO_PATTERN = /^#\d+$/;
|
|
25892
26032
|
function jiraBrowseUrl(key) {
|
|
25893
26033
|
const { site } = loadJson("jira.json");
|
|
25894
26034
|
return site ? `https://${site}/browse/${key}` : key;
|
|
25895
26035
|
}
|
|
26036
|
+
function formatResolvesReference(value) {
|
|
26037
|
+
const trimmed = value.trim();
|
|
26038
|
+
if (SAME_REPO_PATTERN.test(trimmed)) return trimmed;
|
|
26039
|
+
return normalizeGithubIssue(trimmed) ?? jiraBrowseUrl(value);
|
|
26040
|
+
}
|
|
26041
|
+
|
|
26042
|
+
// src/commands/prs/buildPrBody.ts
|
|
25896
26043
|
function renderWhy(why, resolves) {
|
|
25897
26044
|
if (resolves && resolves.length > 0) {
|
|
25898
|
-
const
|
|
26045
|
+
const refs = resolves.map(formatResolvesReference).join(", ");
|
|
25899
26046
|
return `${why}
|
|
25900
26047
|
|
|
25901
|
-
Resolves ${
|
|
26048
|
+
Resolves ${refs}`;
|
|
25902
26049
|
}
|
|
25903
26050
|
return why;
|
|
25904
26051
|
}
|
|
@@ -25959,11 +26106,11 @@ function extractResolves(content) {
|
|
|
25959
26106
|
}
|
|
25960
26107
|
function editPrBody(body, sections) {
|
|
25961
26108
|
const parsed = parsePrBody(body);
|
|
25962
|
-
const find = (
|
|
25963
|
-
const upsert = (
|
|
25964
|
-
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);
|
|
25965
26112
|
if (existing) existing.content = content;
|
|
25966
|
-
else parsed.push({ heading, content });
|
|
26113
|
+
else parsed.push({ heading: heading2, content });
|
|
25967
26114
|
};
|
|
25968
26115
|
if (sections.what !== void 0) upsert("What", sections.what);
|
|
25969
26116
|
const hasResolves = (sections.resolves?.length ?? 0) > 0;
|
|
@@ -26004,10 +26151,10 @@ function splitParagraphs(body) {
|
|
|
26004
26151
|
}
|
|
26005
26152
|
};
|
|
26006
26153
|
for (const line of body.split("\n")) {
|
|
26007
|
-
const
|
|
26008
|
-
if (
|
|
26154
|
+
const heading2 = line.match(/^#{1,6}\s+(.*)$/);
|
|
26155
|
+
if (heading2) {
|
|
26009
26156
|
flush();
|
|
26010
|
-
section3 =
|
|
26157
|
+
section3 = heading2[1].trim();
|
|
26011
26158
|
} else if (line.trim() === "") {
|
|
26012
26159
|
flush();
|
|
26013
26160
|
} else {
|
|
@@ -26082,17 +26229,17 @@ import { execSync as execSync46 } from "child_process";
|
|
|
26082
26229
|
import { execSync as execSync45 } from "child_process";
|
|
26083
26230
|
import { unlinkSync as unlinkSync14, writeFileSync as writeFileSync35 } from "fs";
|
|
26084
26231
|
import { tmpdir as tmpdir7 } from "os";
|
|
26085
|
-
import { join as
|
|
26232
|
+
import { join as join71 } from "path";
|
|
26086
26233
|
|
|
26087
26234
|
// src/commands/prs/loadCommentsCache.ts
|
|
26088
|
-
import { existsSync as
|
|
26235
|
+
import { existsSync as existsSync61, readFileSync as readFileSync45, unlinkSync as unlinkSync13 } from "fs";
|
|
26089
26236
|
import { parse as parse3 } from "yaml";
|
|
26090
26237
|
|
|
26091
26238
|
// src/commands/prs/commentsCachePath.ts
|
|
26092
26239
|
import { homedir as homedir22 } from "os";
|
|
26093
|
-
import { join as
|
|
26240
|
+
import { join as join70 } from "path";
|
|
26094
26241
|
function commentsCachePath(org, repo, prNumber) {
|
|
26095
|
-
return
|
|
26242
|
+
return join70(
|
|
26096
26243
|
homedir22(),
|
|
26097
26244
|
".assist",
|
|
26098
26245
|
"pr-comments",
|
|
@@ -26105,15 +26252,15 @@ function commentsCachePath(org, repo, prNumber) {
|
|
|
26105
26252
|
// src/commands/prs/loadCommentsCache.ts
|
|
26106
26253
|
function loadCommentsCache(org, repo, prNumber) {
|
|
26107
26254
|
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
26108
|
-
if (!
|
|
26255
|
+
if (!existsSync61(cachePath)) {
|
|
26109
26256
|
return null;
|
|
26110
26257
|
}
|
|
26111
|
-
const content =
|
|
26258
|
+
const content = readFileSync45(cachePath, "utf8");
|
|
26112
26259
|
return parse3(content);
|
|
26113
26260
|
}
|
|
26114
26261
|
function deleteCommentsCache(org, repo, prNumber) {
|
|
26115
26262
|
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
26116
|
-
if (
|
|
26263
|
+
if (existsSync61(cachePath)) {
|
|
26117
26264
|
unlinkSync13(cachePath);
|
|
26118
26265
|
console.log("No more unresolved line comments. Cache dropped.");
|
|
26119
26266
|
}
|
|
@@ -26141,7 +26288,7 @@ function replyToComment(org, repo, prNumber, commentId, message3) {
|
|
|
26141
26288
|
// src/commands/prs/resolveCommentWithReply.ts
|
|
26142
26289
|
function resolveThread(threadId) {
|
|
26143
26290
|
const mutation = `mutation($threadId: ID!) { resolveReviewThread(input: {threadId: $threadId}) { thread { isResolved } } }`;
|
|
26144
|
-
const queryFile =
|
|
26291
|
+
const queryFile = join71(tmpdir7(), `gh-mutation-${Date.now()}.graphql`);
|
|
26145
26292
|
writeFileSync35(queryFile, mutation);
|
|
26146
26293
|
try {
|
|
26147
26294
|
execSync45(
|
|
@@ -26226,10 +26373,10 @@ function fixed(commentId, sha) {
|
|
|
26226
26373
|
import { execSync as execSync47 } from "child_process";
|
|
26227
26374
|
import { unlinkSync as unlinkSync15, writeFileSync as writeFileSync36 } from "fs";
|
|
26228
26375
|
import { tmpdir as tmpdir8 } from "os";
|
|
26229
|
-
import { join as
|
|
26376
|
+
import { join as join72 } from "path";
|
|
26230
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 } } } } } } }`;
|
|
26231
26378
|
function fetchThreadIds(org, repo, prNumber) {
|
|
26232
|
-
const queryFile =
|
|
26379
|
+
const queryFile = join72(tmpdir8(), `gh-query-${Date.now()}.graphql`);
|
|
26233
26380
|
writeFileSync36(queryFile, THREAD_QUERY);
|
|
26234
26381
|
try {
|
|
26235
26382
|
const result = execSync47(
|
|
@@ -26299,30 +26446,30 @@ function fetchLineComments(org, repo, prNumber, threadInfo) {
|
|
|
26299
26446
|
|
|
26300
26447
|
// src/commands/prs/listComments/updateCommentsCache.ts
|
|
26301
26448
|
import { mkdirSync as mkdirSync20, writeFileSync as writeFileSync37 } from "fs";
|
|
26302
|
-
import { dirname as
|
|
26449
|
+
import { dirname as dirname32 } from "path";
|
|
26303
26450
|
import { stringify as stringify3 } from "yaml";
|
|
26304
26451
|
|
|
26305
26452
|
// src/commands/prs/removeStaleCommentsCaches.ts
|
|
26306
|
-
import { readdirSync as
|
|
26307
|
-
import { join as
|
|
26453
|
+
import { readdirSync as readdirSync13, unlinkSync as unlinkSync16 } from "fs";
|
|
26454
|
+
import { join as join73 } from "path";
|
|
26308
26455
|
var STALE_PATTERN = /^pr-\d+-comments\.yaml$/;
|
|
26309
26456
|
function removeStaleCommentsCaches(cwd = process.cwd()) {
|
|
26310
|
-
const dir =
|
|
26457
|
+
const dir = join73(cwd, ".assist");
|
|
26311
26458
|
let entries;
|
|
26312
26459
|
try {
|
|
26313
|
-
entries =
|
|
26460
|
+
entries = readdirSync13(dir);
|
|
26314
26461
|
} catch {
|
|
26315
26462
|
return;
|
|
26316
26463
|
}
|
|
26317
26464
|
for (const entry of entries.filter((e) => STALE_PATTERN.test(e))) {
|
|
26318
|
-
unlinkSync16(
|
|
26465
|
+
unlinkSync16(join73(dir, entry));
|
|
26319
26466
|
}
|
|
26320
26467
|
}
|
|
26321
26468
|
|
|
26322
26469
|
// src/commands/prs/listComments/updateCommentsCache.ts
|
|
26323
26470
|
function writeCommentsCache(org, repo, prNumber, comments3) {
|
|
26324
26471
|
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
26325
|
-
mkdirSync20(
|
|
26472
|
+
mkdirSync20(dirname32(cachePath), { recursive: true });
|
|
26326
26473
|
const cacheData = {
|
|
26327
26474
|
prNumber,
|
|
26328
26475
|
fetchedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -27280,7 +27427,7 @@ function registerPrsRaise(prsCommand) {
|
|
|
27280
27427
|
}
|
|
27281
27428
|
|
|
27282
27429
|
// src/commands/readTime/readTime.ts
|
|
27283
|
-
import { readFileSync as
|
|
27430
|
+
import { readFileSync as readFileSync46 } from "fs";
|
|
27284
27431
|
|
|
27285
27432
|
// src/commands/readTime/countReadingWords.ts
|
|
27286
27433
|
var FENCE_PATTERN = /^\s*(```|~~~)/;
|
|
@@ -27441,7 +27588,7 @@ async function loadBody(target) {
|
|
|
27441
27588
|
}
|
|
27442
27589
|
function readDraftFile(path91) {
|
|
27443
27590
|
try {
|
|
27444
|
-
return
|
|
27591
|
+
return readFileSync46(path91, "utf8");
|
|
27445
27592
|
} catch {
|
|
27446
27593
|
console.error(`Error: Could not read \`${path91}\`.`);
|
|
27447
27594
|
console.error(
|
|
@@ -29282,8 +29429,8 @@ function findRootParent(file, importedBy, visited) {
|
|
|
29282
29429
|
function clusterFiles(graph) {
|
|
29283
29430
|
const clusters = /* @__PURE__ */ new Map();
|
|
29284
29431
|
for (const file of graph.files) {
|
|
29285
|
-
const
|
|
29286
|
-
if (
|
|
29432
|
+
const basename29 = path62.basename(file, path62.extname(file));
|
|
29433
|
+
if (basename29 === "index") continue;
|
|
29287
29434
|
const importers = graph.importedBy.get(file);
|
|
29288
29435
|
if (!importers || importers.size !== 1) continue;
|
|
29289
29436
|
const parent = [...importers][0];
|
|
@@ -29707,21 +29854,21 @@ ${annotateDiffWithLineNumbers(context.diff.trimEnd())}
|
|
|
29707
29854
|
|
|
29708
29855
|
// src/commands/review/buildReviewPaths.ts
|
|
29709
29856
|
import { homedir as homedir23 } from "os";
|
|
29710
|
-
import { basename as
|
|
29857
|
+
import { basename as basename20, join as join74 } from "path";
|
|
29711
29858
|
function buildReviewPaths(repoRoot2, key) {
|
|
29712
|
-
const reviewDir =
|
|
29859
|
+
const reviewDir = join74(
|
|
29713
29860
|
homedir23(),
|
|
29714
29861
|
".assist",
|
|
29715
29862
|
"reviews",
|
|
29716
|
-
|
|
29863
|
+
basename20(repoRoot2),
|
|
29717
29864
|
key
|
|
29718
29865
|
);
|
|
29719
29866
|
return {
|
|
29720
29867
|
reviewDir,
|
|
29721
|
-
requestPath:
|
|
29722
|
-
claudePath:
|
|
29723
|
-
codexPath:
|
|
29724
|
-
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")
|
|
29725
29872
|
};
|
|
29726
29873
|
}
|
|
29727
29874
|
|
|
@@ -29863,7 +30010,7 @@ function gatherContext() {
|
|
|
29863
30010
|
}
|
|
29864
30011
|
|
|
29865
30012
|
// src/commands/review/postReviewToPr.ts
|
|
29866
|
-
import { readFileSync as
|
|
30013
|
+
import { readFileSync as readFileSync47 } from "fs";
|
|
29867
30014
|
|
|
29868
30015
|
// src/commands/review/carriedUnanchoredFindings.ts
|
|
29869
30016
|
function carriedUnanchoredFindings(unanchored) {
|
|
@@ -30314,7 +30461,7 @@ async function confirmPost(prNumber, work, options2) {
|
|
|
30314
30461
|
return promptConfirm(`Post ${work} to PR #${prNumber}?`, false);
|
|
30315
30462
|
}
|
|
30316
30463
|
async function postFindingsToPr(prInfo, synthesisPath, options2) {
|
|
30317
|
-
const markdown =
|
|
30464
|
+
const markdown = readFileSync47(synthesisPath, "utf8");
|
|
30318
30465
|
const { inDiff, unanchored } = selectPostableFindings(markdown, prInfo);
|
|
30319
30466
|
const carried = carriedUnanchoredFindings(unanchored);
|
|
30320
30467
|
if (inDiff.length === 0 && carried.length === 0) return NOTHING_POSTED;
|
|
@@ -30450,10 +30597,10 @@ async function handlePostSynthesis(synthesisPath, prInfo, options2) {
|
|
|
30450
30597
|
}
|
|
30451
30598
|
|
|
30452
30599
|
// src/commands/review/prepareReviewDir.ts
|
|
30453
|
-
import { existsSync as
|
|
30600
|
+
import { existsSync as existsSync62, mkdirSync as mkdirSync21, unlinkSync as unlinkSync17, writeFileSync as writeFileSync38 } from "fs";
|
|
30454
30601
|
function clearReviewFiles(paths) {
|
|
30455
30602
|
for (const path91 of [paths.claudePath, paths.codexPath, paths.synthesisPath]) {
|
|
30456
|
-
if (
|
|
30603
|
+
if (existsSync62(path91)) unlinkSync17(path91);
|
|
30457
30604
|
}
|
|
30458
30605
|
}
|
|
30459
30606
|
function prepareReviewDir(paths, requestBody, force) {
|
|
@@ -30515,7 +30662,7 @@ import { format } from "util";
|
|
|
30515
30662
|
|
|
30516
30663
|
// src/commands/review/createReviewLogSink.ts
|
|
30517
30664
|
import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync22 } from "fs";
|
|
30518
|
-
import { join as
|
|
30665
|
+
import { join as join75 } from "path";
|
|
30519
30666
|
|
|
30520
30667
|
// src/shared/stripAnsi.ts
|
|
30521
30668
|
var ANSI = new RegExp(
|
|
@@ -30543,7 +30690,7 @@ function createReviewLogSink() {
|
|
|
30543
30690
|
},
|
|
30544
30691
|
attach(reviewDir) {
|
|
30545
30692
|
mkdirSync22(reviewDir, { recursive: true });
|
|
30546
|
-
logPath2 =
|
|
30693
|
+
logPath2 = join75(reviewDir, LOG_FILE);
|
|
30547
30694
|
const lines2 = [
|
|
30548
30695
|
"",
|
|
30549
30696
|
`=== ${(/* @__PURE__ */ new Date()).toISOString()} ===`,
|
|
@@ -30757,7 +30904,7 @@ function printReviewerFailures(results) {
|
|
|
30757
30904
|
}
|
|
30758
30905
|
|
|
30759
30906
|
// src/commands/review/runAndSynthesise.ts
|
|
30760
|
-
import { existsSync as
|
|
30907
|
+
import { existsSync as existsSync64, unlinkSync as unlinkSync19 } from "fs";
|
|
30761
30908
|
|
|
30762
30909
|
// src/commands/review/buildReviewerStdin.ts
|
|
30763
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.
|
|
@@ -31224,7 +31371,7 @@ function buildCodexModelArgs() {
|
|
|
31224
31371
|
}
|
|
31225
31372
|
|
|
31226
31373
|
// src/commands/review/runCodexReviewer.ts
|
|
31227
|
-
import { existsSync as
|
|
31374
|
+
import { existsSync as existsSync63, unlinkSync as unlinkSync18 } from "fs";
|
|
31228
31375
|
|
|
31229
31376
|
// src/commands/review/parseCodexEvent.ts
|
|
31230
31377
|
function isItemStarted(value) {
|
|
@@ -31279,7 +31426,7 @@ async function runCodexReviewer(spec) {
|
|
|
31279
31426
|
reportReviewerToolUse(spec.name, event, spinner, override.model);
|
|
31280
31427
|
}
|
|
31281
31428
|
});
|
|
31282
|
-
if (result.exitCode !== 0 &&
|
|
31429
|
+
if (result.exitCode !== 0 && existsSync63(spec.outputPath)) {
|
|
31283
31430
|
unlinkSync18(spec.outputPath);
|
|
31284
31431
|
}
|
|
31285
31432
|
return finaliseReviewerRun(
|
|
@@ -31334,7 +31481,7 @@ async function runReviewers(reviewDir, claudePath, codexPath, stdinPrompt, optio
|
|
|
31334
31481
|
}
|
|
31335
31482
|
|
|
31336
31483
|
// src/commands/review/synthesise.ts
|
|
31337
|
-
import { readFileSync as
|
|
31484
|
+
import { readFileSync as readFileSync48 } from "fs";
|
|
31338
31485
|
|
|
31339
31486
|
// src/commands/review/buildSynthesisStdin.ts
|
|
31340
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.
|
|
@@ -31399,7 +31546,7 @@ Files:
|
|
|
31399
31546
|
|
|
31400
31547
|
// src/commands/review/synthesise.ts
|
|
31401
31548
|
function printSummary2(synthesisPath) {
|
|
31402
|
-
const markdown =
|
|
31549
|
+
const markdown = readFileSync48(synthesisPath, "utf8");
|
|
31403
31550
|
console.log("");
|
|
31404
31551
|
console.log(buildReviewSummary(markdown));
|
|
31405
31552
|
console.log("");
|
|
@@ -31447,7 +31594,7 @@ async function runAndSynthesise(args) {
|
|
|
31447
31594
|
console.error("Both reviewers failed; skipping synthesis.");
|
|
31448
31595
|
return { ok: false, failures };
|
|
31449
31596
|
}
|
|
31450
|
-
if (anyFresh &&
|
|
31597
|
+
if (anyFresh && existsSync64(paths.synthesisPath)) {
|
|
31451
31598
|
unlinkSync19(paths.synthesisPath);
|
|
31452
31599
|
}
|
|
31453
31600
|
const synthesisResult = await synthesise(paths, { multi });
|
|
@@ -31640,7 +31787,7 @@ function registerReview(program2) {
|
|
|
31640
31787
|
}
|
|
31641
31788
|
|
|
31642
31789
|
// src/commands/rules/addRule.ts
|
|
31643
|
-
import { existsSync as
|
|
31790
|
+
import { existsSync as existsSync67, readFileSync as readFileSync52, writeFileSync as writeFileSync41 } from "fs";
|
|
31644
31791
|
import path72 from "path";
|
|
31645
31792
|
import chalk211 from "chalk";
|
|
31646
31793
|
|
|
@@ -31665,15 +31812,15 @@ function insertRuleBullet(content, rule) {
|
|
|
31665
31812
|
}
|
|
31666
31813
|
|
|
31667
31814
|
// src/commands/rules/nextRuleCode.ts
|
|
31668
|
-
import { readFileSync as
|
|
31815
|
+
import { readFileSync as readFileSync49 } from "fs";
|
|
31669
31816
|
|
|
31670
31817
|
// src/commands/rules/findClaudeFiles.ts
|
|
31671
|
-
import { readdirSync as
|
|
31818
|
+
import { readdirSync as readdirSync14 } from "fs";
|
|
31672
31819
|
import path68 from "path";
|
|
31673
31820
|
var SKIP_DIRECTORIES = /* @__PURE__ */ new Set(["node_modules", "dist", "build", "coverage"]);
|
|
31674
31821
|
function findClaudeFiles(dir) {
|
|
31675
31822
|
const results = [];
|
|
31676
|
-
for (const entry of
|
|
31823
|
+
for (const entry of readdirSync14(dir, { withFileTypes: true })) {
|
|
31677
31824
|
if (entry.isDirectory()) {
|
|
31678
31825
|
if (entry.name.startsWith(".") || SKIP_DIRECTORIES.has(entry.name))
|
|
31679
31826
|
continue;
|
|
@@ -31689,7 +31836,7 @@ function findClaudeFiles(dir) {
|
|
|
31689
31836
|
var CODE_PREFIX = "R";
|
|
31690
31837
|
function nextRuleCode(root) {
|
|
31691
31838
|
const numbers = findClaudeFiles(root).flatMap(
|
|
31692
|
-
(file) => parseRulesSection(
|
|
31839
|
+
(file) => parseRulesSection(readFileSync49(file, "utf8")).map(
|
|
31693
31840
|
(rule) => Number(/(\d+)\s*$/.exec(rule.code)?.[1] ?? 0)
|
|
31694
31841
|
)
|
|
31695
31842
|
);
|
|
@@ -31697,7 +31844,7 @@ function nextRuleCode(root) {
|
|
|
31697
31844
|
}
|
|
31698
31845
|
|
|
31699
31846
|
// src/commands/rules/resolveRuleScope.ts
|
|
31700
|
-
import { existsSync as
|
|
31847
|
+
import { existsSync as existsSync65 } from "fs";
|
|
31701
31848
|
import path69 from "path";
|
|
31702
31849
|
function resolveRuleScope(target) {
|
|
31703
31850
|
const resolved = path69.resolve(target);
|
|
@@ -31707,7 +31854,7 @@ function resolveRuleScope(target) {
|
|
|
31707
31854
|
let current = startDir;
|
|
31708
31855
|
while (true) {
|
|
31709
31856
|
const candidate = path69.join(current, "CLAUDE.md");
|
|
31710
|
-
if (
|
|
31857
|
+
if (existsSync65(candidate)) return candidate;
|
|
31711
31858
|
if (current === root || current === path69.dirname(current)) break;
|
|
31712
31859
|
current = path69.dirname(current);
|
|
31713
31860
|
}
|
|
@@ -31715,15 +31862,15 @@ function resolveRuleScope(target) {
|
|
|
31715
31862
|
}
|
|
31716
31863
|
|
|
31717
31864
|
// src/commands/rules/updateScopedRulesIndex.ts
|
|
31718
|
-
import { existsSync as
|
|
31865
|
+
import { existsSync as existsSync66, readFileSync as readFileSync51, writeFileSync as writeFileSync40 } from "fs";
|
|
31719
31866
|
import path71 from "path";
|
|
31720
31867
|
|
|
31721
31868
|
// src/commands/rules/scopedRuleDirectories.ts
|
|
31722
|
-
import { readFileSync as
|
|
31869
|
+
import { readFileSync as readFileSync50 } from "fs";
|
|
31723
31870
|
import path70 from "path";
|
|
31724
31871
|
function scopedRuleDirectories(root) {
|
|
31725
31872
|
return findClaudeFiles(root).filter(
|
|
31726
|
-
(file) => path70.dirname(file) !== root && parseRulesSection(
|
|
31873
|
+
(file) => path70.dirname(file) !== root && parseRulesSection(readFileSync50(file, "utf8")).length > 0
|
|
31727
31874
|
).map(
|
|
31728
31875
|
(file) => `${path70.relative(root, path70.dirname(file)).split(path70.sep).join("/")}/`
|
|
31729
31876
|
).sort();
|
|
@@ -31765,7 +31912,7 @@ function upsertScopedRulesPointer(content, directories) {
|
|
|
31765
31912
|
function updateScopedRulesIndex(root) {
|
|
31766
31913
|
const directories = scopedRuleDirectories(root);
|
|
31767
31914
|
const rootFile = path71.join(root, "CLAUDE.md");
|
|
31768
|
-
const before =
|
|
31915
|
+
const before = existsSync66(rootFile) ? readFileSync51(rootFile, "utf8") : "";
|
|
31769
31916
|
const after = upsertScopedRulesPointer(before, directories);
|
|
31770
31917
|
if (after !== before) writeFileSync40(rootFile, after);
|
|
31771
31918
|
return directories;
|
|
@@ -31773,7 +31920,7 @@ function updateScopedRulesIndex(root) {
|
|
|
31773
31920
|
|
|
31774
31921
|
// src/commands/rules/addRule.ts
|
|
31775
31922
|
function read2(file) {
|
|
31776
|
-
return
|
|
31923
|
+
return existsSync67(file) ? readFileSync52(file, "utf8") : "";
|
|
31777
31924
|
}
|
|
31778
31925
|
function addRule(text18, options2) {
|
|
31779
31926
|
const rule = text18.trim();
|
|
@@ -32256,11 +32403,11 @@ async function reviewProposedSlackMessage(target, body, workingPath) {
|
|
|
32256
32403
|
}
|
|
32257
32404
|
|
|
32258
32405
|
// src/commands/slack/slackWorkingFile.ts
|
|
32259
|
-
import { join as
|
|
32406
|
+
import { join as join76 } from "path";
|
|
32260
32407
|
function slackWorkingFile(channel) {
|
|
32261
32408
|
const slug = channel.replace(/^[#@]/, "").toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "channel";
|
|
32262
|
-
const dir =
|
|
32263
|
-
return { dir, bodyPath:
|
|
32409
|
+
const dir = join76(getStoreDir(), "slack");
|
|
32410
|
+
return { dir, bodyPath: join76(dir, `${slug}.md`) };
|
|
32264
32411
|
}
|
|
32265
32412
|
|
|
32266
32413
|
// src/commands/slack/postSlackMessage.ts
|
|
@@ -32587,7 +32734,7 @@ function registerSql(program2) {
|
|
|
32587
32734
|
import * as fs48 from "fs";
|
|
32588
32735
|
import * as os5 from "os";
|
|
32589
32736
|
import * as path85 from "path";
|
|
32590
|
-
import { fileURLToPath as
|
|
32737
|
+
import { fileURLToPath as fileURLToPath9 } from "url";
|
|
32591
32738
|
|
|
32592
32739
|
// src/commands/sync/pruneCommands.ts
|
|
32593
32740
|
import * as path76 from "path";
|
|
@@ -32793,9 +32940,9 @@ function quoteYaml(value) {
|
|
|
32793
32940
|
}
|
|
32794
32941
|
function commandToSkill(name, content) {
|
|
32795
32942
|
const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?/);
|
|
32796
|
-
const
|
|
32943
|
+
const frontmatter2 = match ? match[1] : "";
|
|
32797
32944
|
const body = match ? content.slice(match[0].length) : content;
|
|
32798
|
-
const descriptionMatch =
|
|
32945
|
+
const descriptionMatch = frontmatter2.match(/^description:\s*(.*)$/m);
|
|
32799
32946
|
const description = descriptionMatch ? descriptionMatch[1].trim().replace(/^["']|["']$/g, "") : name;
|
|
32800
32947
|
const header = `---
|
|
32801
32948
|
name: ${name}
|
|
@@ -32878,11 +33025,11 @@ function unquote2(value) {
|
|
|
32878
33025
|
}
|
|
32879
33026
|
function commandToPrompt(name, content) {
|
|
32880
33027
|
const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?/);
|
|
32881
|
-
const
|
|
33028
|
+
const frontmatter2 = match ? match[1] : "";
|
|
32882
33029
|
const body = match ? content.slice(match[0].length) : content;
|
|
32883
|
-
const descriptionMatch =
|
|
33030
|
+
const descriptionMatch = frontmatter2.match(/^description:\s*(.*)$/m);
|
|
32884
33031
|
const description = descriptionMatch ? unquote2(descriptionMatch[1]) : name;
|
|
32885
|
-
const argsMatch =
|
|
33032
|
+
const argsMatch = frontmatter2.match(/^allowed_args:\s*(.*)$/m);
|
|
32886
33033
|
const argumentHint = argsMatch ? unquote2(argsMatch[1]) : void 0;
|
|
32887
33034
|
const header = [
|
|
32888
33035
|
"---",
|
|
@@ -32959,7 +33106,7 @@ async function syncSettings(claudeDir, targetBase, options2) {
|
|
|
32959
33106
|
}
|
|
32960
33107
|
|
|
32961
33108
|
// src/commands/sync.ts
|
|
32962
|
-
var __filename4 =
|
|
33109
|
+
var __filename4 = fileURLToPath9(import.meta.url);
|
|
32963
33110
|
var __dirname5 = path85.dirname(__filename4);
|
|
32964
33111
|
async function sync(options2) {
|
|
32965
33112
|
const config = loadConfig();
|
|
@@ -33016,7 +33163,7 @@ function registerSync(program2) {
|
|
|
33016
33163
|
}
|
|
33017
33164
|
|
|
33018
33165
|
// src/commands/transcript/clean.ts
|
|
33019
|
-
import { existsSync as
|
|
33166
|
+
import { existsSync as existsSync72 } from "fs";
|
|
33020
33167
|
|
|
33021
33168
|
// src/commands/transcript/convert/formatTimestamp.ts
|
|
33022
33169
|
function pad(value, width) {
|
|
@@ -33266,9 +33413,9 @@ function formatVttPassages(passages, notes = [], { sourceMarks = true } = {}) {
|
|
|
33266
33413
|
}
|
|
33267
33414
|
|
|
33268
33415
|
// src/commands/transcript/convert/readCleanedCues.ts
|
|
33269
|
-
import { readFileSync as
|
|
33416
|
+
import { readFileSync as readFileSync57 } from "fs";
|
|
33270
33417
|
function readCleanedCues(inputPath) {
|
|
33271
|
-
return deduplicateCues(parseVtt(
|
|
33418
|
+
return deduplicateCues(parseVtt(readFileSync57(inputPath, "utf8")));
|
|
33272
33419
|
}
|
|
33273
33420
|
|
|
33274
33421
|
// src/commands/transcript/clean.ts
|
|
@@ -33294,7 +33441,7 @@ function clean(file, options2 = {}) {
|
|
|
33294
33441
|
);
|
|
33295
33442
|
process.exit(1);
|
|
33296
33443
|
}
|
|
33297
|
-
if (!
|
|
33444
|
+
if (!existsSync72(file)) {
|
|
33298
33445
|
console.error(`Error: VTT file not found: ${file}`);
|
|
33299
33446
|
process.exit(1);
|
|
33300
33447
|
}
|
|
@@ -33377,21 +33524,21 @@ async function configure() {
|
|
|
33377
33524
|
}
|
|
33378
33525
|
|
|
33379
33526
|
// src/commands/transcript/list.ts
|
|
33380
|
-
import { existsSync as
|
|
33381
|
-
import { join as
|
|
33527
|
+
import { existsSync as existsSync73, readdirSync as readdirSync21, statSync as statSync11 } from "fs";
|
|
33528
|
+
import { join as join87 } from "path";
|
|
33382
33529
|
function list4() {
|
|
33383
33530
|
const { vttDir } = getTranscriptConfig();
|
|
33384
|
-
if (!
|
|
33385
|
-
for (const entry of
|
|
33531
|
+
if (!existsSync73(vttDir)) return;
|
|
33532
|
+
for (const entry of readdirSync21(vttDir)) {
|
|
33386
33533
|
if (!entry.endsWith(".vtt")) continue;
|
|
33387
|
-
if (statSync11(
|
|
33534
|
+
if (statSync11(join87(vttDir, entry)).isDirectory()) continue;
|
|
33388
33535
|
console.log(entry);
|
|
33389
33536
|
}
|
|
33390
33537
|
}
|
|
33391
33538
|
|
|
33392
33539
|
// src/commands/transcript/move.ts
|
|
33393
|
-
import { existsSync as
|
|
33394
|
-
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";
|
|
33395
33542
|
|
|
33396
33543
|
// src/commands/transcript/convertVttToMarkdown.ts
|
|
33397
33544
|
function convertVttToMarkdown(inputPath) {
|
|
@@ -33401,9 +33548,9 @@ function convertVttToMarkdown(inputPath) {
|
|
|
33401
33548
|
// src/commands/transcript/move.ts
|
|
33402
33549
|
var DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
|
|
33403
33550
|
function archiveRawVtt(vttDir, sourcePath, filename) {
|
|
33404
|
-
const processedDir =
|
|
33551
|
+
const processedDir = join88(vttDir, "processed");
|
|
33405
33552
|
mkdirSync29(processedDir, { recursive: true });
|
|
33406
|
-
renameSync2(sourcePath,
|
|
33553
|
+
renameSync2(sourcePath, join88(processedDir, filename));
|
|
33407
33554
|
}
|
|
33408
33555
|
function move(file, options2) {
|
|
33409
33556
|
const { date, client } = options2;
|
|
@@ -33412,27 +33559,27 @@ function move(file, options2) {
|
|
|
33412
33559
|
process.exit(1);
|
|
33413
33560
|
}
|
|
33414
33561
|
const { vttDir, transcriptsDir, summaryDir } = getTranscriptConfig();
|
|
33415
|
-
const filename =
|
|
33416
|
-
const sourcePath =
|
|
33417
|
-
if (!
|
|
33562
|
+
const filename = basename23(file);
|
|
33563
|
+
const sourcePath = join88(vttDir, filename);
|
|
33564
|
+
if (!existsSync74(sourcePath)) {
|
|
33418
33565
|
console.error(`Error: VTT file not found: ${sourcePath}`);
|
|
33419
33566
|
process.exit(1);
|
|
33420
33567
|
}
|
|
33421
|
-
const base =
|
|
33568
|
+
const base = basename23(filename, ".vtt").replace(/ Transcription$/, "");
|
|
33422
33569
|
const outputName = `${date} ${base}.md`;
|
|
33423
|
-
const formattedDir =
|
|
33570
|
+
const formattedDir = join88(transcriptsDir, client);
|
|
33424
33571
|
mkdirSync29(formattedDir, { recursive: true });
|
|
33425
|
-
const formattedPath =
|
|
33572
|
+
const formattedPath = join88(formattedDir, outputName);
|
|
33426
33573
|
writeFileSync46(formattedPath, convertVttToMarkdown(sourcePath), "utf8");
|
|
33427
33574
|
archiveRawVtt(vttDir, sourcePath, filename);
|
|
33428
|
-
const summaryPath =
|
|
33575
|
+
const summaryPath = join88(summaryDir, client, outputName);
|
|
33429
33576
|
console.log(`Formatted transcript: ${formattedPath}`);
|
|
33430
33577
|
console.log(`Summary target: ${summaryPath}`);
|
|
33431
33578
|
}
|
|
33432
33579
|
|
|
33433
33580
|
// src/commands/transcript/merge.ts
|
|
33434
|
-
import { existsSync as
|
|
33435
|
-
import { basename as
|
|
33581
|
+
import { existsSync as existsSync75, writeFileSync as writeFileSync47 } from "fs";
|
|
33582
|
+
import { basename as basename24 } from "path";
|
|
33436
33583
|
|
|
33437
33584
|
// src/commands/transcript/failTranscript.ts
|
|
33438
33585
|
function failTranscript(message3) {
|
|
@@ -33575,10 +33722,10 @@ function widenAudience(passages) {
|
|
|
33575
33722
|
|
|
33576
33723
|
// src/commands/transcript/merge.ts
|
|
33577
33724
|
function readSource2(file) {
|
|
33578
|
-
if (!
|
|
33725
|
+
if (!existsSync75(file)) failTranscript(`VTT file not found: ${file}`);
|
|
33579
33726
|
const cues = readCleanedCues(file);
|
|
33580
33727
|
if (cues.length === 0) failTranscript(`no cues found in: ${file}`);
|
|
33581
|
-
return { path: file, name:
|
|
33728
|
+
return { path: file, name: basename24(file), cues };
|
|
33582
33729
|
}
|
|
33583
33730
|
function wholePassages(sources) {
|
|
33584
33731
|
return sources.map((source) => ({
|
|
@@ -33739,50 +33886,50 @@ function registerVerify(program2) {
|
|
|
33739
33886
|
|
|
33740
33887
|
// src/commands/voice/devices.ts
|
|
33741
33888
|
import { spawnSync as spawnSync9 } from "child_process";
|
|
33742
|
-
import { join as
|
|
33889
|
+
import { join as join90 } from "path";
|
|
33743
33890
|
|
|
33744
33891
|
// src/commands/voice/shared.ts
|
|
33745
33892
|
import { homedir as homedir25 } from "os";
|
|
33746
|
-
import { dirname as
|
|
33747
|
-
import { fileURLToPath as
|
|
33748
|
-
var __dirname6 =
|
|
33749
|
-
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");
|
|
33750
33897
|
var voicePaths = {
|
|
33751
33898
|
dir: VOICE_DIR,
|
|
33752
|
-
pid:
|
|
33753
|
-
log:
|
|
33754
|
-
venv:
|
|
33755
|
-
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")
|
|
33756
33903
|
};
|
|
33757
33904
|
function getPythonDir() {
|
|
33758
|
-
return
|
|
33905
|
+
return join89(__dirname6, "commands", "voice", "python");
|
|
33759
33906
|
}
|
|
33760
33907
|
function getVenvPython() {
|
|
33761
|
-
return process.platform === "win32" ?
|
|
33908
|
+
return process.platform === "win32" ? join89(voicePaths.venv, "Scripts", "python.exe") : join89(voicePaths.venv, "bin", "python");
|
|
33762
33909
|
}
|
|
33763
33910
|
function getLockDir() {
|
|
33764
33911
|
const config = loadConfig();
|
|
33765
33912
|
return config.voice?.lockDir ?? VOICE_DIR;
|
|
33766
33913
|
}
|
|
33767
33914
|
function getLockFile() {
|
|
33768
|
-
return
|
|
33915
|
+
return join89(getLockDir(), "voice.lock");
|
|
33769
33916
|
}
|
|
33770
33917
|
|
|
33771
33918
|
// src/commands/voice/devices.ts
|
|
33772
33919
|
function devices() {
|
|
33773
|
-
const script =
|
|
33920
|
+
const script = join90(getPythonDir(), "list_devices.py");
|
|
33774
33921
|
spawnSync9(getVenvPython(), [script], { stdio: "inherit" });
|
|
33775
33922
|
}
|
|
33776
33923
|
|
|
33777
33924
|
// src/commands/voice/logs.ts
|
|
33778
|
-
import { existsSync as
|
|
33925
|
+
import { existsSync as existsSync76, readFileSync as readFileSync58 } from "fs";
|
|
33779
33926
|
function logs(options2) {
|
|
33780
|
-
if (!
|
|
33927
|
+
if (!existsSync76(voicePaths.log)) {
|
|
33781
33928
|
console.log("No voice log file found");
|
|
33782
33929
|
return;
|
|
33783
33930
|
}
|
|
33784
33931
|
const count8 = Number.parseInt(options2.lines ?? "150", 10);
|
|
33785
|
-
const content =
|
|
33932
|
+
const content = readFileSync58(voicePaths.log, "utf8").trim();
|
|
33786
33933
|
if (!content) {
|
|
33787
33934
|
console.log("Voice log is empty");
|
|
33788
33935
|
return;
|
|
@@ -33805,12 +33952,12 @@ function logs(options2) {
|
|
|
33805
33952
|
// src/commands/voice/setup.ts
|
|
33806
33953
|
import { spawnSync as spawnSync10 } from "child_process";
|
|
33807
33954
|
import { mkdirSync as mkdirSync31 } from "fs";
|
|
33808
|
-
import { join as
|
|
33955
|
+
import { join as join92 } from "path";
|
|
33809
33956
|
|
|
33810
33957
|
// src/commands/voice/checkLockFile.ts
|
|
33811
33958
|
import { execSync as execSync60 } from "child_process";
|
|
33812
|
-
import { existsSync as
|
|
33813
|
-
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";
|
|
33814
33961
|
function isProcessAlive2(pid) {
|
|
33815
33962
|
try {
|
|
33816
33963
|
process.kill(pid, 0);
|
|
@@ -33821,9 +33968,9 @@ function isProcessAlive2(pid) {
|
|
|
33821
33968
|
}
|
|
33822
33969
|
function checkLockFile() {
|
|
33823
33970
|
const lockFile = getLockFile();
|
|
33824
|
-
if (!
|
|
33971
|
+
if (!existsSync77(lockFile)) return;
|
|
33825
33972
|
try {
|
|
33826
|
-
const lock2 = JSON.parse(
|
|
33973
|
+
const lock2 = JSON.parse(readFileSync59(lockFile, "utf8"));
|
|
33827
33974
|
if (lock2.pid && isProcessAlive2(lock2.pid)) {
|
|
33828
33975
|
console.error(
|
|
33829
33976
|
`Voice daemon already running (PID ${lock2.pid}, env: ${lock2.env}). Stop it first with: assist voice stop`
|
|
@@ -33834,7 +33981,7 @@ function checkLockFile() {
|
|
|
33834
33981
|
}
|
|
33835
33982
|
}
|
|
33836
33983
|
function bootstrapVenv() {
|
|
33837
|
-
if (
|
|
33984
|
+
if (existsSync77(getVenvPython())) return;
|
|
33838
33985
|
console.log("Setting up Python environment...");
|
|
33839
33986
|
const pythonDir = getPythonDir();
|
|
33840
33987
|
execSync60(
|
|
@@ -33847,7 +33994,7 @@ function bootstrapVenv() {
|
|
|
33847
33994
|
}
|
|
33848
33995
|
function writeLockFile(pid) {
|
|
33849
33996
|
const lockFile = getLockFile();
|
|
33850
|
-
mkdirSync30(
|
|
33997
|
+
mkdirSync30(join91(lockFile, ".."), { recursive: true });
|
|
33851
33998
|
writeFileSync48(
|
|
33852
33999
|
lockFile,
|
|
33853
34000
|
JSON.stringify({
|
|
@@ -33863,7 +34010,7 @@ function setup() {
|
|
|
33863
34010
|
mkdirSync31(voicePaths.dir, { recursive: true });
|
|
33864
34011
|
bootstrapVenv();
|
|
33865
34012
|
console.log("\nDownloading models...\n");
|
|
33866
|
-
const script =
|
|
34013
|
+
const script = join92(getPythonDir(), "setup_models.py");
|
|
33867
34014
|
const result = spawnSync10(getVenvPython(), [script], {
|
|
33868
34015
|
stdio: "inherit",
|
|
33869
34016
|
env: { ...process.env, VOICE_LOG_FILE: voicePaths.log }
|
|
@@ -33877,7 +34024,7 @@ function setup() {
|
|
|
33877
34024
|
// src/commands/voice/start.ts
|
|
33878
34025
|
import { spawn as spawn8 } from "child_process";
|
|
33879
34026
|
import { mkdirSync as mkdirSync32, writeFileSync as writeFileSync49 } from "fs";
|
|
33880
|
-
import { join as
|
|
34027
|
+
import { join as join93 } from "path";
|
|
33881
34028
|
|
|
33882
34029
|
// src/commands/voice/buildDaemonEnv.ts
|
|
33883
34030
|
function buildDaemonEnv(options2) {
|
|
@@ -33915,7 +34062,7 @@ function start2(options2) {
|
|
|
33915
34062
|
bootstrapVenv();
|
|
33916
34063
|
const debug = options2.debug || options2.foreground || process.platform === "win32";
|
|
33917
34064
|
const env = buildDaemonEnv({ debug });
|
|
33918
|
-
const script =
|
|
34065
|
+
const script = join93(getPythonDir(), "voice_daemon.py");
|
|
33919
34066
|
const python = getVenvPython();
|
|
33920
34067
|
if (options2.foreground) {
|
|
33921
34068
|
spawnForeground(python, script, env);
|
|
@@ -33925,7 +34072,7 @@ function start2(options2) {
|
|
|
33925
34072
|
}
|
|
33926
34073
|
|
|
33927
34074
|
// src/commands/voice/status.ts
|
|
33928
|
-
import { existsSync as
|
|
34075
|
+
import { existsSync as existsSync78, readFileSync as readFileSync60 } from "fs";
|
|
33929
34076
|
function isProcessAlive3(pid) {
|
|
33930
34077
|
try {
|
|
33931
34078
|
process.kill(pid, 0);
|
|
@@ -33935,16 +34082,16 @@ function isProcessAlive3(pid) {
|
|
|
33935
34082
|
}
|
|
33936
34083
|
}
|
|
33937
34084
|
function readRecentLogs(count8) {
|
|
33938
|
-
if (!
|
|
33939
|
-
const lines2 =
|
|
34085
|
+
if (!existsSync78(voicePaths.log)) return [];
|
|
34086
|
+
const lines2 = readFileSync60(voicePaths.log, "utf8").trim().split("\n");
|
|
33940
34087
|
return lines2.slice(-count8);
|
|
33941
34088
|
}
|
|
33942
34089
|
function status2() {
|
|
33943
|
-
if (!
|
|
34090
|
+
if (!existsSync78(voicePaths.pid)) {
|
|
33944
34091
|
console.log("Voice daemon: not running (no PID file)");
|
|
33945
34092
|
return;
|
|
33946
34093
|
}
|
|
33947
|
-
const pid = Number.parseInt(
|
|
34094
|
+
const pid = Number.parseInt(readFileSync60(voicePaths.pid, "utf8").trim(), 10);
|
|
33948
34095
|
const alive = isProcessAlive3(pid);
|
|
33949
34096
|
console.log(`Voice daemon: ${alive ? "running" : "dead"} (PID ${pid})`);
|
|
33950
34097
|
const recent = readRecentLogs(5);
|
|
@@ -33963,13 +34110,13 @@ function status2() {
|
|
|
33963
34110
|
}
|
|
33964
34111
|
|
|
33965
34112
|
// src/commands/voice/stop.ts
|
|
33966
|
-
import { existsSync as
|
|
34113
|
+
import { existsSync as existsSync79, readFileSync as readFileSync61, unlinkSync as unlinkSync20 } from "fs";
|
|
33967
34114
|
function stop2() {
|
|
33968
|
-
if (!
|
|
34115
|
+
if (!existsSync79(voicePaths.pid)) {
|
|
33969
34116
|
console.log("Voice daemon is not running (no PID file)");
|
|
33970
34117
|
return;
|
|
33971
34118
|
}
|
|
33972
|
-
const pid = Number.parseInt(
|
|
34119
|
+
const pid = Number.parseInt(readFileSync61(voicePaths.pid, "utf8").trim(), 10);
|
|
33973
34120
|
try {
|
|
33974
34121
|
process.kill(pid, "SIGTERM");
|
|
33975
34122
|
console.log(`Sent SIGTERM to voice daemon (PID ${pid})`);
|
|
@@ -33982,7 +34129,7 @@ function stop2() {
|
|
|
33982
34129
|
}
|
|
33983
34130
|
try {
|
|
33984
34131
|
const lockFile = getLockFile();
|
|
33985
|
-
if (
|
|
34132
|
+
if (existsSync79(lockFile)) unlinkSync20(lockFile);
|
|
33986
34133
|
} catch {
|
|
33987
34134
|
}
|
|
33988
34135
|
console.log("Voice daemon stopped");
|
|
@@ -34046,11 +34193,11 @@ function changedPaths(from, cwd) {
|
|
|
34046
34193
|
}
|
|
34047
34194
|
|
|
34048
34195
|
// src/commands/watch/readBuiltVersion.ts
|
|
34049
|
-
import { join as
|
|
34196
|
+
import { join as join94 } from "path";
|
|
34050
34197
|
function readBuiltVersion(cwd) {
|
|
34051
34198
|
try {
|
|
34052
34199
|
const root = runGit3(["rev-parse", "--show-toplevel"], cwd);
|
|
34053
|
-
return readPackageJson(
|
|
34200
|
+
return readPackageJson(join94(root, "package.json")).version ?? "unknown";
|
|
34054
34201
|
} catch {
|
|
34055
34202
|
return "unknown";
|
|
34056
34203
|
}
|
|
@@ -34387,7 +34534,7 @@ function resolveParams(params, cliArgs) {
|
|
|
34387
34534
|
}
|
|
34388
34535
|
|
|
34389
34536
|
// src/commands/run/resolveRunCwd.ts
|
|
34390
|
-
import { existsSync as
|
|
34537
|
+
import { existsSync as existsSync80 } from "fs";
|
|
34391
34538
|
import { resolve as resolve19 } from "path";
|
|
34392
34539
|
var MissingRunCwdError = class extends Error {
|
|
34393
34540
|
constructor(runName, cwd) {
|
|
@@ -34400,25 +34547,25 @@ var MissingRunCwdError = class extends Error {
|
|
|
34400
34547
|
function resolveRunCwd(config, baseDir = runConfigBaseDir()) {
|
|
34401
34548
|
if (!config.cwd) return void 0;
|
|
34402
34549
|
const cwd = resolve19(baseDir, config.cwd);
|
|
34403
|
-
if (!
|
|
34550
|
+
if (!existsSync80(cwd)) throw new MissingRunCwdError(config.name, cwd);
|
|
34404
34551
|
return cwd;
|
|
34405
34552
|
}
|
|
34406
34553
|
|
|
34407
34554
|
// src/commands/run/runCommandToCompletion.ts
|
|
34408
34555
|
import { spawn as spawn9 } from "child_process";
|
|
34409
|
-
import { existsSync as
|
|
34556
|
+
import { existsSync as existsSync82 } from "fs";
|
|
34410
34557
|
|
|
34411
34558
|
// src/commands/run/resolveCommand.ts
|
|
34412
34559
|
import { execFileSync as execFileSync18 } from "child_process";
|
|
34413
|
-
import { existsSync as
|
|
34414
|
-
import { dirname as
|
|
34560
|
+
import { existsSync as existsSync81 } from "fs";
|
|
34561
|
+
import { dirname as dirname38, join as join95, resolve as resolve20 } from "path";
|
|
34415
34562
|
function resolveCommand2(command) {
|
|
34416
34563
|
if (process.platform !== "win32" || command !== "bash") return command;
|
|
34417
34564
|
try {
|
|
34418
34565
|
const gitPath = execFileSync18("where", ["git"], { encoding: "utf8" }).trim().split("\r\n")[0];
|
|
34419
|
-
const gitRoot = resolve20(
|
|
34420
|
-
const gitBash =
|
|
34421
|
-
if (
|
|
34566
|
+
const gitRoot = resolve20(dirname38(gitPath), "..");
|
|
34567
|
+
const gitBash = join95(gitRoot, "bin", "bash.exe");
|
|
34568
|
+
if (existsSync81(gitBash)) return gitBash;
|
|
34422
34569
|
} catch {
|
|
34423
34570
|
return command;
|
|
34424
34571
|
}
|
|
@@ -34428,7 +34575,7 @@ function resolveCommand2(command) {
|
|
|
34428
34575
|
// src/commands/run/runCommandToCompletion.ts
|
|
34429
34576
|
function runCommandToCompletion(command, args, env, cwd, quiet) {
|
|
34430
34577
|
return new Promise((resolveResult) => {
|
|
34431
|
-
if (cwd && !
|
|
34578
|
+
if (cwd && !existsSync82(cwd)) {
|
|
34432
34579
|
resolveResult({
|
|
34433
34580
|
kind: "failed",
|
|
34434
34581
|
message: `Failed to execute command: cwd ${cwd} does not exist`
|
|
@@ -34844,17 +34991,17 @@ async function auth() {
|
|
|
34844
34991
|
|
|
34845
34992
|
// src/commands/roam/postRoamActivity.ts
|
|
34846
34993
|
import { execFileSync as execFileSync20 } from "child_process";
|
|
34847
|
-
import { readdirSync as
|
|
34848
|
-
import { join as
|
|
34994
|
+
import { readdirSync as readdirSync22, readFileSync as readFileSync62, statSync as statSync12 } from "fs";
|
|
34995
|
+
import { join as join96 } from "path";
|
|
34849
34996
|
function findPortFile(roamDir) {
|
|
34850
34997
|
let entries;
|
|
34851
34998
|
try {
|
|
34852
|
-
entries =
|
|
34999
|
+
entries = readdirSync22(roamDir);
|
|
34853
35000
|
} catch {
|
|
34854
35001
|
return void 0;
|
|
34855
35002
|
}
|
|
34856
35003
|
const candidates = entries.filter((name) => /^roam-local-api(-[^.]+)?\.port$/.test(name)).map((name) => {
|
|
34857
|
-
const path91 =
|
|
35004
|
+
const path91 = join96(roamDir, name);
|
|
34858
35005
|
try {
|
|
34859
35006
|
return { path: path91, mtimeMs: statSync12(path91).mtimeMs };
|
|
34860
35007
|
} catch {
|
|
@@ -34871,11 +35018,11 @@ var PID_BY_APP = {
|
|
|
34871
35018
|
function postRoamActivity(app, event) {
|
|
34872
35019
|
const appData = process.env.APPDATA;
|
|
34873
35020
|
if (!appData) return;
|
|
34874
|
-
const portFile = findPortFile(
|
|
35021
|
+
const portFile = findPortFile(join96(appData, "Roam"));
|
|
34875
35022
|
if (!portFile) return;
|
|
34876
35023
|
let port;
|
|
34877
35024
|
try {
|
|
34878
|
-
port =
|
|
35025
|
+
port = readFileSync62(portFile, "utf8").trim();
|
|
34879
35026
|
} catch {
|
|
34880
35027
|
return;
|
|
34881
35028
|
}
|
|
@@ -35007,7 +35154,7 @@ async function run3(name, args) {
|
|
|
35007
35154
|
|
|
35008
35155
|
// src/commands/run/add.ts
|
|
35009
35156
|
import { mkdirSync as mkdirSync33, writeFileSync as writeFileSync50 } from "fs";
|
|
35010
|
-
import { join as
|
|
35157
|
+
import { join as join97 } from "path";
|
|
35011
35158
|
|
|
35012
35159
|
// src/commands/run/extractOption.ts
|
|
35013
35160
|
function extractOption(args, flag) {
|
|
@@ -35068,7 +35215,7 @@ function saveNewRunConfig(name, command, args, cwd) {
|
|
|
35068
35215
|
saveConfig(config);
|
|
35069
35216
|
}
|
|
35070
35217
|
function createCommandFile(name) {
|
|
35071
|
-
const dir =
|
|
35218
|
+
const dir = join97(".claude", "commands");
|
|
35072
35219
|
mkdirSync33(dir, { recursive: true });
|
|
35073
35220
|
const content = `---
|
|
35074
35221
|
description: Run ${name}
|
|
@@ -35076,7 +35223,7 @@ description: Run ${name}
|
|
|
35076
35223
|
|
|
35077
35224
|
Run \`assist run ${name} $ARGUMENTS 2>&1\`.
|
|
35078
35225
|
`;
|
|
35079
|
-
const filePath =
|
|
35226
|
+
const filePath = join97(dir, `${name}.md`);
|
|
35080
35227
|
writeFileSync50(filePath, content);
|
|
35081
35228
|
console.log(`Created command file: ${filePath}`);
|
|
35082
35229
|
}
|
|
@@ -35132,8 +35279,8 @@ function link2() {
|
|
|
35132
35279
|
}
|
|
35133
35280
|
|
|
35134
35281
|
// src/commands/run/remove.ts
|
|
35135
|
-
import { existsSync as
|
|
35136
|
-
import { join as
|
|
35282
|
+
import { existsSync as existsSync83, unlinkSync as unlinkSync21 } from "fs";
|
|
35283
|
+
import { join as join98 } from "path";
|
|
35137
35284
|
function findRemoveIndex() {
|
|
35138
35285
|
const idx = process.argv.indexOf("remove");
|
|
35139
35286
|
if (idx === -1 || idx + 1 >= process.argv.length) return -1;
|
|
@@ -35148,8 +35295,8 @@ function parseRemoveName() {
|
|
|
35148
35295
|
return process.argv[idx + 1];
|
|
35149
35296
|
}
|
|
35150
35297
|
function deleteCommandFile(name) {
|
|
35151
|
-
const filePath =
|
|
35152
|
-
if (
|
|
35298
|
+
const filePath = join98(".claude", "commands", `${name}.md`);
|
|
35299
|
+
if (existsSync83(filePath)) {
|
|
35153
35300
|
unlinkSync21(filePath);
|
|
35154
35301
|
console.log(`Deleted command file: ${filePath}`);
|
|
35155
35302
|
}
|
|
@@ -35194,9 +35341,9 @@ function registerRun(program2) {
|
|
|
35194
35341
|
|
|
35195
35342
|
// src/commands/screenshot/index.ts
|
|
35196
35343
|
import { execSync as execSync62 } from "child_process";
|
|
35197
|
-
import { existsSync as
|
|
35344
|
+
import { existsSync as existsSync84, mkdirSync as mkdirSync34, unlinkSync as unlinkSync22, writeFileSync as writeFileSync51 } from "fs";
|
|
35198
35345
|
import { tmpdir as tmpdir9 } from "os";
|
|
35199
|
-
import { join as
|
|
35346
|
+
import { join as join99, resolve as resolve21 } from "path";
|
|
35200
35347
|
import chalk229 from "chalk";
|
|
35201
35348
|
|
|
35202
35349
|
// src/commands/screenshot/captureWindowPs1.ts
|
|
@@ -35326,14 +35473,14 @@ Write-Output $OutputPath
|
|
|
35326
35473
|
|
|
35327
35474
|
// src/commands/screenshot/index.ts
|
|
35328
35475
|
function buildOutputPath(outputDir, processName) {
|
|
35329
|
-
if (!
|
|
35476
|
+
if (!existsSync84(outputDir)) {
|
|
35330
35477
|
mkdirSync34(outputDir, { recursive: true });
|
|
35331
35478
|
}
|
|
35332
35479
|
const timestamp6 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
35333
35480
|
return resolve21(outputDir, `${processName}-${timestamp6}.png`);
|
|
35334
35481
|
}
|
|
35335
35482
|
function runPowerShellScript(processName, outputPath) {
|
|
35336
|
-
const scriptPath =
|
|
35483
|
+
const scriptPath = join99(tmpdir9(), `assist-screenshot-${Date.now()}.ps1`);
|
|
35337
35484
|
writeFileSync51(scriptPath, captureWindowPs1, "utf8");
|
|
35338
35485
|
try {
|
|
35339
35486
|
execSync62(
|
|
@@ -35410,11 +35557,11 @@ function applyLine(result, pending, line) {
|
|
|
35410
35557
|
}
|
|
35411
35558
|
|
|
35412
35559
|
// src/commands/sessions/daemon/readDaemonPidFile.ts
|
|
35413
|
-
import { readFileSync as
|
|
35560
|
+
import { readFileSync as readFileSync63 } from "fs";
|
|
35414
35561
|
function readDaemonPidFile() {
|
|
35415
35562
|
try {
|
|
35416
35563
|
const pid = Number.parseInt(
|
|
35417
|
-
|
|
35564
|
+
readFileSync63(daemonPaths.pid, "utf8").trim(),
|
|
35418
35565
|
10
|
|
35419
35566
|
);
|
|
35420
35567
|
return Number.isInteger(pid) ? pid : void 0;
|
|
@@ -35677,12 +35824,12 @@ function toSessionRunInfo({
|
|
|
35677
35824
|
}
|
|
35678
35825
|
|
|
35679
35826
|
// src/commands/sessions/daemon/worktree/joinRefusal.ts
|
|
35680
|
-
import { existsSync as
|
|
35827
|
+
import { existsSync as existsSync85 } from "fs";
|
|
35681
35828
|
function joinRefusal(session) {
|
|
35682
35829
|
if (session.commandType === "run") return "a server run has no agent stream";
|
|
35683
35830
|
if (session.closing === true) return "the session is closing";
|
|
35684
35831
|
if (!session.cwd) return "the session has no working directory";
|
|
35685
|
-
if (!
|
|
35832
|
+
if (!existsSync85(session.cwd))
|
|
35686
35833
|
return "the session's workspace no longer exists";
|
|
35687
35834
|
return void 0;
|
|
35688
35835
|
}
|
|
@@ -35846,11 +35993,11 @@ function sessionBase(id, status3) {
|
|
|
35846
35993
|
}
|
|
35847
35994
|
|
|
35848
35995
|
// src/commands/sessions/daemon/spawnPty.ts
|
|
35849
|
-
import { existsSync as
|
|
35996
|
+
import { existsSync as existsSync87 } from "fs";
|
|
35850
35997
|
import * as pty from "node-pty";
|
|
35851
35998
|
|
|
35852
35999
|
// src/commands/sessions/daemon/ensureSpawnHelperExecutable.ts
|
|
35853
|
-
import { chmodSync, existsSync as
|
|
36000
|
+
import { chmodSync, existsSync as existsSync86, statSync as statSync13 } from "fs";
|
|
35854
36001
|
import { createRequire as createRequire3 } from "module";
|
|
35855
36002
|
import path86 from "path";
|
|
35856
36003
|
var require4 = createRequire3(import.meta.url);
|
|
@@ -35865,7 +36012,7 @@ function ensureSpawnHelperExecutable() {
|
|
|
35865
36012
|
`${process.platform}-${process.arch}`,
|
|
35866
36013
|
"spawn-helper"
|
|
35867
36014
|
);
|
|
35868
|
-
if (!
|
|
36015
|
+
if (!existsSync86(helper)) return;
|
|
35869
36016
|
const mode = statSync13(helper).mode;
|
|
35870
36017
|
if ((mode & 73) === 0) chmodSync(helper, mode | 493);
|
|
35871
36018
|
}
|
|
@@ -35901,7 +36048,7 @@ function spawnPty(args, cwd, sessionId, extraEnv) {
|
|
|
35901
36048
|
});
|
|
35902
36049
|
}
|
|
35903
36050
|
function refuseMissingCwd(cwd, sessionId) {
|
|
35904
|
-
if (!cwd ||
|
|
36051
|
+
if (!cwd || existsSync87(cwd)) return;
|
|
35905
36052
|
daemonLog(
|
|
35906
36053
|
`${sessionId ? `session ${sessionId}` : "pty"} not spawned: working directory ${cwd} no longer exists`
|
|
35907
36054
|
);
|
|
@@ -35981,8 +36128,8 @@ function serverRunMeta(runName, cwd) {
|
|
|
35981
36128
|
// src/commands/sessions/daemon/readDesignSystemPrompt.ts
|
|
35982
36129
|
import * as fs49 from "fs";
|
|
35983
36130
|
import * as path87 from "path";
|
|
35984
|
-
import { fileURLToPath as
|
|
35985
|
-
var __filename5 =
|
|
36131
|
+
import { fileURLToPath as fileURLToPath11 } from "url";
|
|
36132
|
+
var __filename5 = fileURLToPath11(import.meta.url);
|
|
35986
36133
|
var __dirname7 = path87.dirname(__filename5);
|
|
35987
36134
|
function readDesignSystemPrompt() {
|
|
35988
36135
|
const promptPath = path87.join(
|
|
@@ -36083,17 +36230,17 @@ function setStatus2(session, newStatus) {
|
|
|
36083
36230
|
}
|
|
36084
36231
|
|
|
36085
36232
|
// src/commands/sessions/daemon/worktree/reapWorktree.ts
|
|
36086
|
-
import { existsSync as
|
|
36087
|
-
import { basename as
|
|
36233
|
+
import { existsSync as existsSync89 } from "fs";
|
|
36234
|
+
import { basename as basename25 } from "path";
|
|
36088
36235
|
|
|
36089
36236
|
// src/commands/sessions/daemon/worktree/deleteStrandedTree.ts
|
|
36090
|
-
import { existsSync as
|
|
36091
|
-
import { join as
|
|
36237
|
+
import { existsSync as existsSync88 } from "fs";
|
|
36238
|
+
import { join as join102 } from "path";
|
|
36092
36239
|
|
|
36093
36240
|
// src/commands/sessions/daemon/worktree/deleteTreeDirectly.ts
|
|
36094
36241
|
import { statSync as statSync14 } from "fs";
|
|
36095
36242
|
import { rm as rm4 } from "fs/promises";
|
|
36096
|
-
import { join as
|
|
36243
|
+
import { join as join101 } from "path";
|
|
36097
36244
|
async function deleteTreeDirectly(clone, worktreePath, why) {
|
|
36098
36245
|
if (holdsAGitDirectoryRatherThanALink(worktreePath)) {
|
|
36099
36246
|
const refusal = "it is a clone of its own, not a linked worktree";
|
|
@@ -36121,7 +36268,7 @@ async function deleteTreeDirectly(clone, worktreePath, why) {
|
|
|
36121
36268
|
return { removed: true };
|
|
36122
36269
|
}
|
|
36123
36270
|
function holdsAGitDirectoryRatherThanALink(worktreePath) {
|
|
36124
|
-
return statSync14(
|
|
36271
|
+
return statSync14(join101(worktreePath, ".git"), {
|
|
36125
36272
|
throwIfNoEntry: false
|
|
36126
36273
|
})?.isDirectory() === true;
|
|
36127
36274
|
}
|
|
@@ -36157,7 +36304,7 @@ async function deleteStrandedTree(clone, worktreePath, cause) {
|
|
|
36157
36304
|
);
|
|
36158
36305
|
}
|
|
36159
36306
|
function strandedReason(worktreePath, cause) {
|
|
36160
|
-
if (!
|
|
36307
|
+
if (!existsSync88(join102(worktreePath, ".git")))
|
|
36161
36308
|
return "its .git link is already gone";
|
|
36162
36309
|
if (/not a working tree|not a git repository/i.test(reason2(cause)))
|
|
36163
36310
|
return "git no longer recognises it as a working tree";
|
|
@@ -36209,7 +36356,7 @@ function reason3(error) {
|
|
|
36209
36356
|
|
|
36210
36357
|
// src/commands/sessions/daemon/worktree/reapWorktree.ts
|
|
36211
36358
|
async function reapWorktree(worktreePath, force = false) {
|
|
36212
|
-
if (!
|
|
36359
|
+
if (!existsSync89(worktreePath)) {
|
|
36213
36360
|
forgetWorktree(worktreePath);
|
|
36214
36361
|
daemonLog(
|
|
36215
36362
|
`worktree ${worktreePath} already gone; its record was forgotten`
|
|
@@ -36227,14 +36374,14 @@ async function reapWorktree(worktreePath, force = false) {
|
|
|
36227
36374
|
const clone = owningClone(worktreePath);
|
|
36228
36375
|
const removal = await removeTree(clone, worktreePath, force);
|
|
36229
36376
|
if (!removal.removed) return removal;
|
|
36230
|
-
await deleteWorktreeBranch(clone,
|
|
36377
|
+
await deleteWorktreeBranch(clone, basename25(worktreePath));
|
|
36231
36378
|
forgetWorktree(worktreePath);
|
|
36232
36379
|
daemonLog(`worktree ${worktreePath} reaped${force ? " (forced)" : ""}`);
|
|
36233
36380
|
return removal;
|
|
36234
36381
|
}
|
|
36235
36382
|
function owningClone(worktreePath) {
|
|
36236
36383
|
const recorded = worktreeAttributionIncludingReaped(worktreePath)?.clone;
|
|
36237
|
-
if (recorded &&
|
|
36384
|
+
if (recorded && existsSync89(recorded)) return recorded;
|
|
36238
36385
|
const detected = mainWorktree(worktreePath);
|
|
36239
36386
|
if (detected) return detected;
|
|
36240
36387
|
daemonLog(
|
|
@@ -36365,12 +36512,12 @@ function closeGateApplies(sessions, session) {
|
|
|
36365
36512
|
}
|
|
36366
36513
|
|
|
36367
36514
|
// src/commands/sessions/daemon/worktree/watchGitState.ts
|
|
36368
|
-
import { existsSync as
|
|
36515
|
+
import { existsSync as existsSync90, watch } from "fs";
|
|
36369
36516
|
var DEBOUNCE_MS = 500;
|
|
36370
36517
|
var POLL_MS = 3e4;
|
|
36371
36518
|
function watchGitState(cwd, onChange) {
|
|
36372
36519
|
const common = gitCommonDir(cwd);
|
|
36373
|
-
if (!common || !
|
|
36520
|
+
if (!common || !existsSync90(common)) return void 0;
|
|
36374
36521
|
const watchers = [
|
|
36375
36522
|
watchGitDir(common, onChange),
|
|
36376
36523
|
pollGitState(cwd, onChange)
|
|
@@ -36861,10 +37008,10 @@ function emitSessionOutput(session, clients, data) {
|
|
|
36861
37008
|
}
|
|
36862
37009
|
|
|
36863
37010
|
// src/commands/sessions/daemon/exitReason.ts
|
|
36864
|
-
import { existsSync as
|
|
37011
|
+
import { existsSync as existsSync91 } from "fs";
|
|
36865
37012
|
import { resolve as resolve22 } from "path";
|
|
36866
37013
|
function exitDetail(session) {
|
|
36867
|
-
if (session.cwd && !
|
|
37014
|
+
if (session.cwd && !existsSync91(session.cwd))
|
|
36868
37015
|
return `working directory ${session.cwd} no longer exists`;
|
|
36869
37016
|
return missingRunConfigCwd(session);
|
|
36870
37017
|
}
|
|
@@ -36878,7 +37025,7 @@ function missingRunConfigCwd(session) {
|
|
|
36878
37025
|
const config = resolveRunConfig(session.runName, dir);
|
|
36879
37026
|
if (!config?.cwd) return void 0;
|
|
36880
37027
|
const configured = resolve22(runConfigBaseDirFrom(dir), config.cwd);
|
|
36881
|
-
if (
|
|
37028
|
+
if (existsSync91(configured)) return void 0;
|
|
36882
37029
|
return `run config "${config.name}": cwd ${configured} does not exist`;
|
|
36883
37030
|
}
|
|
36884
37031
|
|
|
@@ -36915,8 +37062,8 @@ function handleFailedResume(session, exitCode, onStatusChange) {
|
|
|
36915
37062
|
}
|
|
36916
37063
|
|
|
36917
37064
|
// src/commands/sessions/daemon/watchActivity.ts
|
|
36918
|
-
import { existsSync as
|
|
36919
|
-
import { dirname as
|
|
37065
|
+
import { existsSync as existsSync92, mkdirSync as mkdirSync35, watch as watch2 } from "fs";
|
|
37066
|
+
import { dirname as dirname40 } from "path";
|
|
36920
37067
|
|
|
36921
37068
|
// src/commands/sessions/daemon/applyActivityToSession.ts
|
|
36922
37069
|
function applyActivityToSession(session, activity2) {
|
|
@@ -36978,7 +37125,7 @@ var DEBOUNCE_MS2 = 50;
|
|
|
36978
37125
|
function watchActivity(session, notify2, onClaudeSessionId) {
|
|
36979
37126
|
if (session.commandType !== "assist" || !session.cwd) return;
|
|
36980
37127
|
const path91 = activityPath(session.id);
|
|
36981
|
-
const dir =
|
|
37128
|
+
const dir = dirname40(path91);
|
|
36982
37129
|
try {
|
|
36983
37130
|
mkdirSync35(dir, { recursive: true });
|
|
36984
37131
|
} catch {
|
|
@@ -37001,7 +37148,7 @@ function watchActivity(session, notify2, onClaudeSessionId) {
|
|
|
37001
37148
|
if (timer) clearTimeout(timer);
|
|
37002
37149
|
timer = setTimeout(read3, DEBOUNCE_MS2);
|
|
37003
37150
|
});
|
|
37004
|
-
if (
|
|
37151
|
+
if (existsSync92(path91)) read3();
|
|
37005
37152
|
}
|
|
37006
37153
|
function refreshActivity(session) {
|
|
37007
37154
|
if (session.commandType !== "assist" || !session.cwd) return;
|
|
@@ -38724,8 +38871,8 @@ function rearmStoppedSessions(sessions, notify2) {
|
|
|
38724
38871
|
}
|
|
38725
38872
|
|
|
38726
38873
|
// src/commands/sessions/daemon/worktree/reconcileWorktreesOnRestore.ts
|
|
38727
|
-
import { existsSync as
|
|
38728
|
-
import { basename as
|
|
38874
|
+
import { existsSync as existsSync95 } from "fs";
|
|
38875
|
+
import { basename as basename27 } from "path";
|
|
38729
38876
|
|
|
38730
38877
|
// src/commands/sessions/daemon/worktree/accountedTrees.ts
|
|
38731
38878
|
function accountedTrees(sessions) {
|
|
@@ -38779,9 +38926,9 @@ function bindResumedWorktree(session, cwd, notify2) {
|
|
|
38779
38926
|
}
|
|
38780
38927
|
|
|
38781
38928
|
// src/commands/sessions/daemon/worktree/reclaimVanishedWorktrees.ts
|
|
38782
|
-
import { existsSync as
|
|
38929
|
+
import { existsSync as existsSync94 } from "fs";
|
|
38783
38930
|
async function reclaimVanishedWorktrees(clone, paths) {
|
|
38784
|
-
if (!
|
|
38931
|
+
if (!existsSync94(clone)) {
|
|
38785
38932
|
for (const { path: path91 } of paths) forgetWorktree(path91);
|
|
38786
38933
|
daemonLog(
|
|
38787
38934
|
`clone ${clone} is gone; forgot ${paths.length} worktree record(s) it owned`
|
|
@@ -38867,7 +39014,7 @@ function capped(lines2) {
|
|
|
38867
39014
|
}
|
|
38868
39015
|
|
|
38869
39016
|
// src/commands/sessions/daemon/worktree/resurfaceOrphanedWorktree.ts
|
|
38870
|
-
import { basename as
|
|
39017
|
+
import { basename as basename26 } from "path";
|
|
38871
39018
|
function resurfaceOrphanedWorktree(sessions, spawnWith, recovered, notify2) {
|
|
38872
39019
|
const { orphan, reason: reason4, held } = recovered;
|
|
38873
39020
|
let id;
|
|
@@ -38890,7 +39037,7 @@ function orphanedSession(id, recovered) {
|
|
|
38890
39037
|
const { orphan, reason: reason4, held } = recovered;
|
|
38891
39038
|
return {
|
|
38892
39039
|
...sessionBase(id, "stopped"),
|
|
38893
|
-
name: `recovered ${
|
|
39040
|
+
name: `recovered ${basename26(orphan.path)}`,
|
|
38894
39041
|
subtitle: `${held.summary} in ${orphan.path}`,
|
|
38895
39042
|
commandType: "claude",
|
|
38896
39043
|
pty: null,
|
|
@@ -38947,11 +39094,11 @@ async function recoverOrphanedWorktrees(sessions, spawnWith, notify2) {
|
|
|
38947
39094
|
);
|
|
38948
39095
|
continue;
|
|
38949
39096
|
}
|
|
38950
|
-
if (!
|
|
39097
|
+
if (!existsSync95(path91)) {
|
|
38951
39098
|
logVanishedTree(sessions, path91);
|
|
38952
39099
|
vanished.set(clone, [
|
|
38953
39100
|
...vanished.get(clone) ?? [],
|
|
38954
|
-
{ path: path91, branch:
|
|
39101
|
+
{ path: path91, branch: basename27(path91) }
|
|
38955
39102
|
]);
|
|
38956
39103
|
continue;
|
|
38957
39104
|
}
|
|
@@ -39592,14 +39739,14 @@ async function defaultConnect() {
|
|
|
39592
39739
|
}
|
|
39593
39740
|
|
|
39594
39741
|
// src/commands/sessions/daemon/hasPersistedWindowsSessions.ts
|
|
39595
|
-
import { existsSync as
|
|
39742
|
+
import { existsSync as existsSync96, readFileSync as readFileSync65 } from "fs";
|
|
39596
39743
|
import { posix as posix3 } from "path";
|
|
39597
39744
|
function hasPersistedWindowsSessions() {
|
|
39598
39745
|
const sessionsFile = windowsSessionsFileFromWsl();
|
|
39599
39746
|
if (!sessionsFile) return false;
|
|
39600
39747
|
try {
|
|
39601
|
-
if (!
|
|
39602
|
-
const data = JSON.parse(
|
|
39748
|
+
if (!existsSync96(sessionsFile)) return false;
|
|
39749
|
+
const data = JSON.parse(readFileSync65(sessionsFile, "utf8"));
|
|
39603
39750
|
return Array.isArray(data) && data.length > 0;
|
|
39604
39751
|
} catch (error) {
|
|
39605
39752
|
const message3 = error instanceof Error ? error.message : String(error);
|
|
@@ -40333,7 +40480,7 @@ function setAutoAdvance(sessions, id, enabled) {
|
|
|
40333
40480
|
}
|
|
40334
40481
|
|
|
40335
40482
|
// src/commands/sessions/daemon/worktree/resumeInTree.ts
|
|
40336
|
-
import { existsSync as
|
|
40483
|
+
import { existsSync as existsSync99 } from "fs";
|
|
40337
40484
|
|
|
40338
40485
|
// src/commands/sessions/daemon/resumeSession.ts
|
|
40339
40486
|
function resumeSession(id, sessionId, cwd, name, holdPty, harness) {
|
|
@@ -40364,11 +40511,11 @@ function resumeSession(id, sessionId, cwd, name, holdPty, harness) {
|
|
|
40364
40511
|
}
|
|
40365
40512
|
|
|
40366
40513
|
// src/commands/sessions/daemon/worktree/resumeInReplacementTree.ts
|
|
40367
|
-
import { existsSync as
|
|
40514
|
+
import { existsSync as existsSync98 } from "fs";
|
|
40368
40515
|
|
|
40369
40516
|
// src/commands/sessions/daemon/worktree/carryTranscriptToTree.ts
|
|
40370
|
-
import { copyFileSync as copyFileSync7, existsSync as
|
|
40371
|
-
import { join as
|
|
40517
|
+
import { copyFileSync as copyFileSync7, existsSync as existsSync97, mkdirSync as mkdirSync37 } from "fs";
|
|
40518
|
+
import { join as join104 } from "path";
|
|
40372
40519
|
function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
40373
40520
|
const dir = projectDirForCwd(toCwd);
|
|
40374
40521
|
if (dir === projectDirForCwd(fromCwd)) {
|
|
@@ -40377,8 +40524,8 @@ function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
|
40377
40524
|
);
|
|
40378
40525
|
return;
|
|
40379
40526
|
}
|
|
40380
|
-
const dest =
|
|
40381
|
-
if (
|
|
40527
|
+
const dest = join104(dir, `${claudeSessionId}.jsonl`);
|
|
40528
|
+
if (existsSync97(dest)) {
|
|
40382
40529
|
daemonLog(`transcript ${claudeSessionId} already present in ${dir}`);
|
|
40383
40530
|
return;
|
|
40384
40531
|
}
|
|
@@ -40429,7 +40576,7 @@ function resumeInReplacementTree(ctx, claudeSessionId, missingCwd, name, harness
|
|
|
40429
40576
|
}
|
|
40430
40577
|
function cloneForReapedTree(missingCwd) {
|
|
40431
40578
|
const clone = worktreeAttributionIncludingReaped(missingCwd)?.clone;
|
|
40432
|
-
if (!clone || !
|
|
40579
|
+
if (!clone || !existsSync98(clone))
|
|
40433
40580
|
throw new Error(
|
|
40434
40581
|
`working directory no longer exists and no clone is recorded to re-allocate from: ${missingCwd}`
|
|
40435
40582
|
);
|
|
@@ -40438,7 +40585,7 @@ function cloneForReapedTree(missingCwd) {
|
|
|
40438
40585
|
|
|
40439
40586
|
// src/commands/sessions/daemon/worktree/resumeInTree.ts
|
|
40440
40587
|
function resumeInTree(ctx, sessionId, cwd, name, harness) {
|
|
40441
|
-
if (!
|
|
40588
|
+
if (!existsSync99(cwd))
|
|
40442
40589
|
return resumeInReplacementTree(ctx, sessionId, cwd, name, harness);
|
|
40443
40590
|
const id = ctx.spawnWith(
|
|
40444
40591
|
(sid) => resumeSession(sid, sessionId, cwd, name, void 0, harness)
|
|
@@ -41024,7 +41171,7 @@ function handleConnection(socket, manager) {
|
|
|
41024
41171
|
import { unlinkSync as unlinkSync23, writeFileSync as writeFileSync52 } from "fs";
|
|
41025
41172
|
|
|
41026
41173
|
// src/commands/sessions/daemon/startPidFileWatchdog.ts
|
|
41027
|
-
import { readFileSync as
|
|
41174
|
+
import { readFileSync as readFileSync66 } from "fs";
|
|
41028
41175
|
var WATCHDOG_INTERVAL_MS = 5e3;
|
|
41029
41176
|
function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
|
|
41030
41177
|
const timer = setInterval(() => {
|
|
@@ -41035,7 +41182,7 @@ function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
|
|
|
41035
41182
|
}
|
|
41036
41183
|
function ownsPidFile() {
|
|
41037
41184
|
try {
|
|
41038
|
-
return
|
|
41185
|
+
return readFileSync66(daemonPaths.pid, "utf8").trim() === String(process.pid);
|
|
41039
41186
|
} catch {
|
|
41040
41187
|
return false;
|
|
41041
41188
|
}
|
|
@@ -41528,10 +41675,10 @@ function buildLimitsSegment(rateLimits) {
|
|
|
41528
41675
|
}
|
|
41529
41676
|
|
|
41530
41677
|
// src/commands/readGitBranch.ts
|
|
41531
|
-
import { readFileSync as
|
|
41532
|
-
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";
|
|
41533
41680
|
function resolveGitDir(cwd) {
|
|
41534
|
-
const dotGit =
|
|
41681
|
+
const dotGit = join105(cwd, ".git");
|
|
41535
41682
|
let stat4;
|
|
41536
41683
|
try {
|
|
41537
41684
|
stat4 = statSync16(dotGit);
|
|
@@ -41543,7 +41690,7 @@ function resolveGitDir(cwd) {
|
|
|
41543
41690
|
}
|
|
41544
41691
|
let contents;
|
|
41545
41692
|
try {
|
|
41546
|
-
contents =
|
|
41693
|
+
contents = readFileSync68(dotGit, "utf8");
|
|
41547
41694
|
} catch {
|
|
41548
41695
|
return null;
|
|
41549
41696
|
}
|
|
@@ -41561,7 +41708,7 @@ function readGitBranch(cwd) {
|
|
|
41561
41708
|
}
|
|
41562
41709
|
let head;
|
|
41563
41710
|
try {
|
|
41564
|
-
head =
|
|
41711
|
+
head = readFileSync68(join105(gitDir, "HEAD"), "utf8");
|
|
41565
41712
|
} catch {
|
|
41566
41713
|
return null;
|
|
41567
41714
|
}
|
|
@@ -41719,6 +41866,7 @@ program.command("coverage").description("Print global statement coverage percent
|
|
|
41719
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);
|
|
41720
41867
|
configHelp(screenshotCommand, rootConfigHelp.screenshot);
|
|
41721
41868
|
registerActivity(program);
|
|
41869
|
+
registerAdvise(program);
|
|
41722
41870
|
registerBackup(program);
|
|
41723
41871
|
registerDb(program);
|
|
41724
41872
|
registerDbMigration(program);
|