@staff0rd/assist 0.1103.0 → 0.1105.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/dist/built-version +1 -1
- package/dist/commands/sessions/web/bundle.js +162 -162
- package/dist/index.js +758 -633
- package/package.json +1 -1
- package/claude/advice/editing-files.md +0 -6
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.1105.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -481,7 +481,6 @@ var adviceFragmentTitles = {
|
|
|
481
481
|
"backlog-prs": "Backlog items, PRs, and commits",
|
|
482
482
|
"code-comments": "Commenting code",
|
|
483
483
|
"drafting-messages": "Drafting messages to send on the user's behalf",
|
|
484
|
-
"editing-files": "Editing files",
|
|
485
484
|
"fixing-commands": "Fixing command and skill misbehaviour",
|
|
486
485
|
"filename-convention": "Naming files after their export",
|
|
487
486
|
"jira-context": "Fetching Jira context",
|
|
@@ -502,7 +501,6 @@ var adviceFragmentNames = [
|
|
|
502
501
|
"backlog-prs",
|
|
503
502
|
"code-comments",
|
|
504
503
|
"drafting-messages",
|
|
505
|
-
"editing-files",
|
|
506
504
|
"fixing-commands",
|
|
507
505
|
"filename-convention",
|
|
508
506
|
"jira-context",
|
|
@@ -1440,6 +1438,17 @@ function warnYmlRepoOverride(key) {
|
|
|
1440
1438
|
);
|
|
1441
1439
|
}
|
|
1442
1440
|
|
|
1441
|
+
// src/shared/stripLegacyAdviceKeys.ts
|
|
1442
|
+
var LEGACY_ADVICE_SECTIONS = ["editing-files"];
|
|
1443
|
+
function stripLegacyAdviceKeys(advice) {
|
|
1444
|
+
if (!advice || typeof advice !== "object") return advice;
|
|
1445
|
+
const { sections } = advice;
|
|
1446
|
+
if (!sections || typeof sections !== "object") return advice;
|
|
1447
|
+
const rest = { ...sections };
|
|
1448
|
+
for (const key of LEGACY_ADVICE_SECTIONS) delete rest[key];
|
|
1449
|
+
return { ...advice, sections: rest };
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1443
1452
|
// src/shared/stripLegacyReviewKeys.ts
|
|
1444
1453
|
var LEGACY_REVIEW_HIGH_LEVEL_KEYS = ["slices"];
|
|
1445
1454
|
function stripLegacyReviewKeys(review2) {
|
|
@@ -1501,6 +1510,7 @@ function stripLegacyConfigKeys(config) {
|
|
|
1501
1510
|
stripped.news = rest;
|
|
1502
1511
|
}
|
|
1503
1512
|
stripLegacySectionKeys(stripped);
|
|
1513
|
+
if (stripped.advice) stripped.advice = stripLegacyAdviceKeys(stripped.advice);
|
|
1504
1514
|
if (stripped.review) stripped.review = stripLegacyReviewKeys(stripped.review);
|
|
1505
1515
|
return stripped;
|
|
1506
1516
|
}
|
|
@@ -5572,10 +5582,46 @@ function buildSlashCommand(slashCommand, description) {
|
|
|
5572
5582
|
return trimmed ? `/${slashCommand} ${trimmed}` : `/${slashCommand}`;
|
|
5573
5583
|
}
|
|
5574
5584
|
|
|
5585
|
+
// src/shared/harnessAdapters/carryTranscriptToTree.ts
|
|
5586
|
+
import { copyFileSync, existsSync as existsSync16, mkdirSync as mkdirSync4 } from "fs";
|
|
5587
|
+
import { join as join17 } from "path";
|
|
5588
|
+
function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
5589
|
+
const dir = projectDirForCwd(toCwd);
|
|
5590
|
+
if (dir === projectDirForCwd(fromCwd)) {
|
|
5591
|
+
daemonLog(
|
|
5592
|
+
`transcript ${claudeSessionId} already lives in ${dir}: resuming in the original worktree path`
|
|
5593
|
+
);
|
|
5594
|
+
return;
|
|
5595
|
+
}
|
|
5596
|
+
const dest = join17(dir, `${claudeSessionId}.jsonl`);
|
|
5597
|
+
if (existsSync16(dest)) {
|
|
5598
|
+
daemonLog(`transcript ${claudeSessionId} already present in ${dir}`);
|
|
5599
|
+
return;
|
|
5600
|
+
}
|
|
5601
|
+
const source = findTranscriptPathSync(fromCwd, claudeSessionId);
|
|
5602
|
+
if (!source) {
|
|
5603
|
+
daemonLog(
|
|
5604
|
+
`transcript ${claudeSessionId} not found under ${projectDirForCwd(fromCwd)}: resuming in ${toCwd} without it`
|
|
5605
|
+
);
|
|
5606
|
+
return;
|
|
5607
|
+
}
|
|
5608
|
+
try {
|
|
5609
|
+
mkdirSync4(dir, { recursive: true });
|
|
5610
|
+
copyFileSync(source, dest);
|
|
5611
|
+
daemonLog(
|
|
5612
|
+
`transcript ${source} copied to ${dest} so ${toCwd} can resume it`
|
|
5613
|
+
);
|
|
5614
|
+
} catch (error) {
|
|
5615
|
+
daemonLog(
|
|
5616
|
+
`transcript ${claudeSessionId} could not be copied to ${dir}: ${error instanceof Error ? error.message : String(error)}`
|
|
5617
|
+
);
|
|
5618
|
+
}
|
|
5619
|
+
}
|
|
5620
|
+
|
|
5575
5621
|
// src/shared/harnessAdapters/claudeConnectorProbe.ts
|
|
5576
5622
|
import { readFileSync as readFileSync7 } from "fs";
|
|
5577
5623
|
import { homedir as homedir8 } from "os";
|
|
5578
|
-
import { join as
|
|
5624
|
+
import { join as join18 } from "path";
|
|
5579
5625
|
|
|
5580
5626
|
// src/shared/harnessAdapters/unsupported.ts
|
|
5581
5627
|
var supported = { supported: true };
|
|
@@ -5588,7 +5634,7 @@ function knownConnectedConnectors() {
|
|
|
5588
5634
|
const dir = process.env.CLAUDE_CONFIG_DIR ?? homedir8();
|
|
5589
5635
|
try {
|
|
5590
5636
|
const state = JSON.parse(
|
|
5591
|
-
readFileSync7(
|
|
5637
|
+
readFileSync7(join18(dir, ".claude.json"), "utf8")
|
|
5592
5638
|
);
|
|
5593
5639
|
const list7 = state.claudeAiMcpEverConnected;
|
|
5594
5640
|
return Array.isArray(list7) ? list7.filter((name2) => typeof name2 === "string") : void 0;
|
|
@@ -6836,6 +6882,7 @@ var harnessCapabilityDeclarations = {
|
|
|
6836
6882
|
claude: {
|
|
6837
6883
|
"skills.native": supported,
|
|
6838
6884
|
"conversation.resume": supported,
|
|
6885
|
+
"conversation.relocate": supported,
|
|
6839
6886
|
"conversation.preassignId": supported,
|
|
6840
6887
|
"transcript.read": supported,
|
|
6841
6888
|
"oneShot.text": supported,
|
|
@@ -6852,6 +6899,7 @@ var harnessCapabilityDeclarations = {
|
|
|
6852
6899
|
codex: {
|
|
6853
6900
|
"skills.native": supported,
|
|
6854
6901
|
"conversation.resume": supported,
|
|
6902
|
+
"conversation.relocate": supported,
|
|
6855
6903
|
"conversation.preassignId": unsupported(
|
|
6856
6904
|
"Codex assigns its own conversation id when its rollout starts",
|
|
6857
6905
|
"assist binds the Codex conversation id from the rollout after launch"
|
|
@@ -6891,6 +6939,11 @@ var harnessCapabilityDeclarations = {
|
|
|
6891
6939
|
"restart starts a fresh pi conversation; pick Claude or Codex to keep the conversation across restarts",
|
|
6892
6940
|
"a696"
|
|
6893
6941
|
),
|
|
6942
|
+
"conversation.relocate": unsupported(
|
|
6943
|
+
"pi sessions cannot be resumed, so a pi conversation cannot continue in a replacement worktree",
|
|
6944
|
+
"start a fresh session in the replacement worktree; pick Claude or Codex to keep the conversation across worktree replacement",
|
|
6945
|
+
"a696"
|
|
6946
|
+
),
|
|
6894
6947
|
"conversation.preassignId": unsupported(
|
|
6895
6948
|
"pi does not accept a caller-assigned conversation id",
|
|
6896
6949
|
"the session card tracks pi without a conversation id"
|
|
@@ -6954,6 +7007,7 @@ var claudeAdapter = {
|
|
|
6954
7007
|
current: () => process.env.CLAUDE_CODE_SESSION_ID || void 0,
|
|
6955
7008
|
boundId: ({ claudeSessionId }) => claudeSessionId,
|
|
6956
7009
|
toRef: (claudeSessionId, cwd) => ({ cwd, claudeSessionId }),
|
|
7010
|
+
relocate: carryTranscriptToTree,
|
|
6957
7011
|
reader: claudeConversationReader
|
|
6958
7012
|
},
|
|
6959
7013
|
toolOperations: claudeToolOperations,
|
|
@@ -6969,10 +7023,19 @@ var claudeAdapter = {
|
|
|
6969
7023
|
allowEdits: allowEdits ?? true,
|
|
6970
7024
|
resumeSessionId: conversationId
|
|
6971
7025
|
}),
|
|
6972
|
-
interactive: ({
|
|
7026
|
+
interactive: ({
|
|
7027
|
+
sessionId: sessionId2,
|
|
7028
|
+
conversationId,
|
|
7029
|
+
resumeId,
|
|
7030
|
+
prompt,
|
|
7031
|
+
cwd,
|
|
7032
|
+
design,
|
|
7033
|
+
auto
|
|
7034
|
+
}) => spawnClaude({
|
|
6973
7035
|
prompt,
|
|
6974
7036
|
cwd,
|
|
6975
7037
|
sessionId: sessionId2,
|
|
7038
|
+
resumeSessionId: resumeId,
|
|
6976
7039
|
claudeSessionId: conversationId,
|
|
6977
7040
|
design,
|
|
6978
7041
|
auto
|
|
@@ -7091,13 +7154,13 @@ import * as fs4 from "fs";
|
|
|
7091
7154
|
import * as path11 from "path";
|
|
7092
7155
|
|
|
7093
7156
|
// src/commands/sessions/shared/codex/codexSessionsDir.ts
|
|
7094
|
-
import { existsSync as
|
|
7157
|
+
import { existsSync as existsSync17 } from "fs";
|
|
7095
7158
|
import * as path10 from "path";
|
|
7096
7159
|
function codexSessionsDir() {
|
|
7097
7160
|
return path10.join(harnesses.codex.homeDir, "sessions");
|
|
7098
7161
|
}
|
|
7099
7162
|
function hasCodexSessions() {
|
|
7100
|
-
return
|
|
7163
|
+
return existsSync17(codexSessionsDir());
|
|
7101
7164
|
}
|
|
7102
7165
|
|
|
7103
7166
|
// src/commands/sessions/shared/codex/discoverCodexRolloutPaths.ts
|
|
@@ -7241,7 +7304,12 @@ async function readCodexHeadLines(filePath, maxLines = DEFAULT_MAX_LINES) {
|
|
|
7241
7304
|
|
|
7242
7305
|
// src/commands/sessions/shared/codex/resolveCodexSessionId.ts
|
|
7243
7306
|
var META_LINES = 5;
|
|
7244
|
-
async function resolveCodexSessionId(
|
|
7307
|
+
async function resolveCodexSessionId({
|
|
7308
|
+
cwd,
|
|
7309
|
+
launchedAt,
|
|
7310
|
+
sinceMs,
|
|
7311
|
+
claimed
|
|
7312
|
+
}) {
|
|
7245
7313
|
if (!cwd) return null;
|
|
7246
7314
|
const paths = await discoverCodexRolloutPaths();
|
|
7247
7315
|
const touched = await Promise.all(
|
|
@@ -7250,14 +7318,17 @@ async function resolveCodexSessionId(cwd, sinceMs) {
|
|
|
7250
7318
|
const candidates = await Promise.all(
|
|
7251
7319
|
paths.filter((_, index3) => touched[index3]).map((file) => startedIn(file, cwd, sinceMs))
|
|
7252
7320
|
);
|
|
7253
|
-
return
|
|
7321
|
+
return firstUnclaimedRolloutAfterLaunch(
|
|
7322
|
+
candidates.filter(
|
|
7323
|
+
(candidate) => !!candidate && !claimed.has(candidate.sessionId)
|
|
7324
|
+
),
|
|
7325
|
+
launchedAt
|
|
7326
|
+
);
|
|
7254
7327
|
}
|
|
7255
|
-
function
|
|
7256
|
-
|
|
7257
|
-
|
|
7258
|
-
|
|
7259
|
-
best = candidate;
|
|
7260
|
-
return best?.sessionId ?? null;
|
|
7328
|
+
function firstUnclaimedRolloutAfterLaunch(rollouts, launchedAt) {
|
|
7329
|
+
const byStart = [...rollouts].sort((a, b) => a.startedAt - b.startedAt);
|
|
7330
|
+
const afterLaunch = byStart.find((r) => r.startedAt >= launchedAt);
|
|
7331
|
+
return (afterLaunch ?? byStart.at(-1))?.sessionId ?? null;
|
|
7261
7332
|
}
|
|
7262
7333
|
async function startedIn(file, cwd, sinceMs) {
|
|
7263
7334
|
const meta = codexRolloutMeta(await readCodexHeadLines(file, META_LINES));
|
|
@@ -7542,8 +7613,8 @@ var codexConversationReader = {
|
|
|
7542
7613
|
};
|
|
7543
7614
|
|
|
7544
7615
|
// src/shared/readCodexRulePerms.ts
|
|
7545
|
-
import { existsSync as
|
|
7546
|
-
import { join as
|
|
7616
|
+
import { existsSync as existsSync18, readdirSync as readdirSync5, readFileSync as readFileSync8 } from "fs";
|
|
7617
|
+
import { join as join23 } from "path";
|
|
7547
7618
|
|
|
7548
7619
|
// src/shared/readPatternList.ts
|
|
7549
7620
|
function readString(text19, start2) {
|
|
@@ -7621,17 +7692,17 @@ function parseCodexRules(text19) {
|
|
|
7621
7692
|
|
|
7622
7693
|
// src/shared/readCodexRulePerms.ts
|
|
7623
7694
|
function ruleFiles(dir) {
|
|
7624
|
-
if (!
|
|
7695
|
+
if (!existsSync18(dir)) return [];
|
|
7625
7696
|
try {
|
|
7626
|
-
return readdirSync5(dir).filter((name2) => name2.endsWith(".rules")).sort().map((name2) =>
|
|
7697
|
+
return readdirSync5(dir).filter((name2) => name2.endsWith(".rules")).sort().map((name2) => join23(dir, name2));
|
|
7627
7698
|
} catch {
|
|
7628
7699
|
return [];
|
|
7629
7700
|
}
|
|
7630
7701
|
}
|
|
7631
7702
|
function readCodexRulePerms(key) {
|
|
7632
7703
|
const dirs = [
|
|
7633
|
-
|
|
7634
|
-
|
|
7704
|
+
join23(harnesses.codex.homeDir, "rules"),
|
|
7705
|
+
join23(process.cwd(), ".codex", "rules")
|
|
7635
7706
|
];
|
|
7636
7707
|
return dirs.flatMap(ruleFiles).flatMap((file) => {
|
|
7637
7708
|
try {
|
|
@@ -7720,8 +7791,15 @@ async function codexOneShot(prompt, { timeout, effort = "low", cwd }) {
|
|
|
7720
7791
|
return (await run5).stdout;
|
|
7721
7792
|
}
|
|
7722
7793
|
|
|
7794
|
+
// src/shared/harnessAdapters/codexRelocate.ts
|
|
7795
|
+
function codexRelocate(conversationId, fromCwd, toCwd) {
|
|
7796
|
+
daemonLog(
|
|
7797
|
+
`Codex conversation ${conversationId} resumes in ${toCwd} from its rollout, which is stored by id rather than under ${fromCwd}`
|
|
7798
|
+
);
|
|
7799
|
+
}
|
|
7800
|
+
|
|
7723
7801
|
// src/commands/review/runCodexReviewer.ts
|
|
7724
|
-
import { existsSync as
|
|
7802
|
+
import { existsSync as existsSync19, unlinkSync as unlinkSync2 } from "fs";
|
|
7725
7803
|
|
|
7726
7804
|
// src/commands/review/parseCodexUsage.ts
|
|
7727
7805
|
function parseCodexUsage(usage) {
|
|
@@ -7810,7 +7888,7 @@ async function runCodexReviewer(spec) {
|
|
|
7810
7888
|
...override.args.length > 0 ? { env: override.env } : {},
|
|
7811
7889
|
onLine
|
|
7812
7890
|
});
|
|
7813
|
-
if (result.exitCode !== 0 &&
|
|
7891
|
+
if (result.exitCode !== 0 && existsSync19(spec.outputPath)) {
|
|
7814
7892
|
unlinkSync2(spec.outputPath);
|
|
7815
7893
|
}
|
|
7816
7894
|
const finalised = finaliseReviewerRun(
|
|
@@ -7928,6 +8006,7 @@ var codexAdapter = {
|
|
|
7928
8006
|
boundId: ({ harnessSessionId }) => harnessSessionId,
|
|
7929
8007
|
toRef: (harnessSessionId, cwd) => ({ cwd, harnessSessionId }),
|
|
7930
8008
|
discover: resolveCodexSessionId,
|
|
8009
|
+
relocate: codexRelocate,
|
|
7931
8010
|
reader: codexConversationReader
|
|
7932
8011
|
},
|
|
7933
8012
|
toolOperations: codexToolOperations,
|
|
@@ -7939,7 +8018,7 @@ var codexAdapter = {
|
|
|
7939
8018
|
sandbox: sandbox(allowEdits),
|
|
7940
8019
|
resumeSessionId: conversationId
|
|
7941
8020
|
}),
|
|
7942
|
-
interactive: ({ sessionId: sessionId2, prompt, cwd }) => spawnCodex({ prompt, cwd, sessionId: sessionId2 }),
|
|
8021
|
+
interactive: ({ sessionId: sessionId2, resumeId, prompt, cwd }) => spawnCodex({ prompt, cwd, sessionId: sessionId2, resumeSessionId: resumeId }),
|
|
7943
8022
|
oneShot: codexOneShot,
|
|
7944
8023
|
structured: codexStructuredRun,
|
|
7945
8024
|
connectorRun: rejectConnectorRun("Codex"),
|
|
@@ -8026,13 +8105,14 @@ var piAdapter = {
|
|
|
8026
8105
|
locate: () => Promise.resolve(null),
|
|
8027
8106
|
current: () => void 0,
|
|
8028
8107
|
boundId: () => void 0,
|
|
8029
|
-
toRef: (harnessSessionId, cwd) => ({ cwd, harnessSessionId })
|
|
8108
|
+
toRef: (harnessSessionId, cwd) => ({ cwd, harnessSessionId }),
|
|
8109
|
+
relocate: cannotResume
|
|
8030
8110
|
},
|
|
8031
8111
|
toolOperations: piToolOperations,
|
|
8032
8112
|
launchSkill: (skill, args, { cwd }) => spawnPi2(buildSlashCommand(skill, args), { cwd }),
|
|
8033
8113
|
launchPrompt: (prompt, { cwd }) => spawnPi2(prompt, { cwd }),
|
|
8034
8114
|
resume: cannotResume,
|
|
8035
|
-
interactive: ({ sessionId: sessionId2, prompt, cwd }) => spawnPi({ prompt, cwd, sessionId: sessionId2 }),
|
|
8115
|
+
interactive: ({ sessionId: sessionId2, resumeId, prompt, cwd }) => resumeId ? cannotResume() : spawnPi({ prompt, cwd, sessionId: sessionId2 }),
|
|
8036
8116
|
oneShot: noOneShot,
|
|
8037
8117
|
structured: noOneShot,
|
|
8038
8118
|
connectorRun: rejectConnectorRun("pi"),
|
|
@@ -8391,12 +8471,12 @@ async function diffScopes(req, res) {
|
|
|
8391
8471
|
}
|
|
8392
8472
|
|
|
8393
8473
|
// src/commands/sessions/daemon/recordPromptJournal.ts
|
|
8394
|
-
import { appendFileSync as appendFileSync2, mkdirSync as
|
|
8474
|
+
import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync5 } from "fs";
|
|
8395
8475
|
import { dirname as dirname9 } from "path";
|
|
8396
8476
|
function recordPromptJournal(entry) {
|
|
8397
8477
|
const line = JSON.stringify({ at: (/* @__PURE__ */ new Date()).toISOString(), ...entry });
|
|
8398
8478
|
try {
|
|
8399
|
-
|
|
8479
|
+
mkdirSync5(dirname9(daemonPaths.promptJournal), { recursive: true });
|
|
8400
8480
|
appendFileSync2(daemonPaths.promptJournal, `${line}
|
|
8401
8481
|
`);
|
|
8402
8482
|
} catch {
|
|
@@ -8569,11 +8649,11 @@ async function fileContent(req, res) {
|
|
|
8569
8649
|
import { basename as basename7 } from "path";
|
|
8570
8650
|
|
|
8571
8651
|
// src/commands/sessions/web/fromGithub/listClones.ts
|
|
8572
|
-
import { existsSync as
|
|
8573
|
-
import { join as
|
|
8652
|
+
import { existsSync as existsSync20, readdirSync as readdirSync6 } from "fs";
|
|
8653
|
+
import { join as join24 } from "path";
|
|
8574
8654
|
function listClones(baseDir) {
|
|
8575
|
-
if (!
|
|
8576
|
-
return readdirSync6(baseDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) =>
|
|
8655
|
+
if (!existsSync20(baseDir)) return [];
|
|
8656
|
+
return readdirSync6(baseDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => join24(baseDir, entry.name)).filter((dir) => existsSync20(join24(dir, ".git"))).sort();
|
|
8577
8657
|
}
|
|
8578
8658
|
|
|
8579
8659
|
// src/commands/sessions/web/fromGithub/getClones.ts
|
|
@@ -8732,8 +8812,8 @@ function azureDevopsRepoUrl({ org, project, repo }) {
|
|
|
8732
8812
|
}
|
|
8733
8813
|
|
|
8734
8814
|
// src/commands/sessions/web/fromGithub/findAzureDevopsClone.ts
|
|
8735
|
-
import { existsSync as
|
|
8736
|
-
import { join as
|
|
8815
|
+
import { existsSync as existsSync21, readdirSync as readdirSync7 } from "fs";
|
|
8816
|
+
import { join as join25 } from "path";
|
|
8737
8817
|
|
|
8738
8818
|
// src/shared/azureDevops/parseAzureDevopsRemote.ts
|
|
8739
8819
|
var HTTPS_DEV = /^https?:\/\/(?:[^@/]+@)?dev\.azure\.com\/([^/]+)\/([^/]+)\/_git\/([^/]+)$/i;
|
|
@@ -8754,15 +8834,15 @@ function sameAzureDevopsRepo(a, b) {
|
|
|
8754
8834
|
|
|
8755
8835
|
// src/commands/sessions/web/fromGithub/findAzureDevopsClone.ts
|
|
8756
8836
|
function clonesRepo(dir, repo) {
|
|
8757
|
-
if (!
|
|
8837
|
+
if (!existsSync21(join25(dir, ".git"))) return false;
|
|
8758
8838
|
const url = remoteUrl(dir).url;
|
|
8759
8839
|
const remote = url ? parseAzureDevopsRemote(url) : null;
|
|
8760
8840
|
return remote !== null && sameAzureDevopsRepo(remote, repo);
|
|
8761
8841
|
}
|
|
8762
8842
|
function findAzureDevopsClone(repo, baseDir) {
|
|
8763
|
-
if (!
|
|
8764
|
-
const named =
|
|
8765
|
-
const others = readdirSync7(baseDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) =>
|
|
8843
|
+
if (!existsSync21(baseDir)) return void 0;
|
|
8844
|
+
const named = join25(baseDir, repo.repo);
|
|
8845
|
+
const others = readdirSync7(baseDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => join25(baseDir, entry.name)).filter((dir) => dir !== named).sort();
|
|
8766
8846
|
return [named, ...others].find((dir) => clonesRepo(dir, repo));
|
|
8767
8847
|
}
|
|
8768
8848
|
|
|
@@ -10601,14 +10681,14 @@ function assertNoDuplicateRunNames(configs) {
|
|
|
10601
10681
|
}
|
|
10602
10682
|
|
|
10603
10683
|
// src/shared/findLinkedConfigPath.ts
|
|
10604
|
-
import { existsSync as
|
|
10605
|
-
import { join as
|
|
10684
|
+
import { existsSync as existsSync22 } from "fs";
|
|
10685
|
+
import { join as join26, resolve as resolve5 } from "path";
|
|
10606
10686
|
function findLinkedConfigPath(linkPath, fromDir) {
|
|
10607
10687
|
const resolved = resolve5(fromDir, linkPath);
|
|
10608
|
-
const claudePath =
|
|
10609
|
-
if (
|
|
10610
|
-
const rootPath =
|
|
10611
|
-
if (
|
|
10688
|
+
const claudePath = join26(resolved, ".claude", "assist.yml");
|
|
10689
|
+
if (existsSync22(claudePath)) return claudePath;
|
|
10690
|
+
const rootPath = join26(resolved, "assist.yml");
|
|
10691
|
+
if (existsSync22(rootPath)) return rootPath;
|
|
10612
10692
|
throw new Error(`No assist.yml found in linked project: ${resolved}`);
|
|
10613
10693
|
}
|
|
10614
10694
|
|
|
@@ -10698,18 +10778,18 @@ function handleServerRuns(req, res) {
|
|
|
10698
10778
|
import { execFile as execFile6 } from "child_process";
|
|
10699
10779
|
import { readFileSync as readFileSync9 } from "fs";
|
|
10700
10780
|
import { homedir as homedir10 } from "os";
|
|
10701
|
-
import { basename as basename10, join as
|
|
10781
|
+
import { basename as basename10, join as join28 } from "path";
|
|
10702
10782
|
import { promisify as promisify6 } from "util";
|
|
10703
10783
|
|
|
10704
10784
|
// src/commands/sessions/web/findSynthesisForBranch.ts
|
|
10705
|
-
import { existsSync as
|
|
10706
|
-
import { basename as basename9, dirname as dirname11, join as
|
|
10785
|
+
import { existsSync as existsSync23, readdirSync as readdirSync8, statSync as statSync6 } from "fs";
|
|
10786
|
+
import { basename as basename9, dirname as dirname11, join as join27 } from "path";
|
|
10707
10787
|
function findSynthesisForBranch(repoReviewsDir, branch2) {
|
|
10708
|
-
const branchKeyPath =
|
|
10788
|
+
const branchKeyPath = join27(repoReviewsDir, `${branch2}-`);
|
|
10709
10789
|
const parent = dirname11(branchKeyPath);
|
|
10710
10790
|
const branchPrefix = basename9(branchKeyPath);
|
|
10711
|
-
if (!
|
|
10712
|
-
const synthesisFiles = readdirSync8(parent).filter((name2) => name2.startsWith(branchPrefix)).map((name2) =>
|
|
10791
|
+
if (!existsSync23(parent)) return null;
|
|
10792
|
+
const synthesisFiles = readdirSync8(parent).filter((name2) => name2.startsWith(branchPrefix)).map((name2) => join27(parent, name2, "synthesis.md")).filter((path110) => existsSync23(path110)).map((path110) => ({ path: path110, mtime: statSync6(path110).mtimeMs })).sort((a, b) => b.mtime - a.mtime);
|
|
10713
10793
|
return synthesisFiles[0]?.path ?? null;
|
|
10714
10794
|
}
|
|
10715
10795
|
|
|
@@ -10727,7 +10807,7 @@ async function resolveSynthesisPath(cwd) {
|
|
|
10727
10807
|
runGit2(cwd, ["rev-parse", "--show-toplevel"]),
|
|
10728
10808
|
runGit2(cwd, ["rev-parse", "--abbrev-ref", "HEAD"])
|
|
10729
10809
|
]);
|
|
10730
|
-
const repoReviewsDir =
|
|
10810
|
+
const repoReviewsDir = join28(
|
|
10731
10811
|
homedir10(),
|
|
10732
10812
|
".assist",
|
|
10733
10813
|
"reviews",
|
|
@@ -11331,34 +11411,34 @@ function resolveRewindPlan(item) {
|
|
|
11331
11411
|
}
|
|
11332
11412
|
|
|
11333
11413
|
// src/commands/backlog/writeSignal.ts
|
|
11334
|
-
import { mkdirSync as
|
|
11414
|
+
import { mkdirSync as mkdirSync7, writeFileSync as writeFileSync7 } from "fs";
|
|
11335
11415
|
import { homedir as homedir12 } from "os";
|
|
11336
|
-
import { dirname as dirname13, join as
|
|
11416
|
+
import { dirname as dirname13, join as join30 } from "path";
|
|
11337
11417
|
import chalk10 from "chalk";
|
|
11338
11418
|
|
|
11339
11419
|
// src/commands/backlog/recordSignalOwner.ts
|
|
11340
11420
|
import {
|
|
11341
|
-
existsSync as
|
|
11342
|
-
mkdirSync as
|
|
11421
|
+
existsSync as existsSync24,
|
|
11422
|
+
mkdirSync as mkdirSync6,
|
|
11343
11423
|
readFileSync as readFileSync10,
|
|
11344
11424
|
rmSync as rmSync3,
|
|
11345
11425
|
writeFileSync as writeFileSync6
|
|
11346
11426
|
} from "fs";
|
|
11347
11427
|
import { homedir as homedir11 } from "os";
|
|
11348
|
-
import { dirname as dirname12, join as
|
|
11428
|
+
import { dirname as dirname12, join as join29 } from "path";
|
|
11349
11429
|
function getOwnerPath(itemId2) {
|
|
11350
|
-
return
|
|
11430
|
+
return join29(homedir11(), ".assist", "signals", `owner-${itemId2}.json`);
|
|
11351
11431
|
}
|
|
11352
11432
|
function recordSignalOwner(itemId2) {
|
|
11353
11433
|
const sessionId2 = process.env.ASSIST_SESSION_ID;
|
|
11354
11434
|
if (!sessionId2) return;
|
|
11355
11435
|
const path110 = getOwnerPath(itemId2);
|
|
11356
|
-
|
|
11436
|
+
mkdirSync6(dirname12(path110), { recursive: true });
|
|
11357
11437
|
writeFileSync6(path110, JSON.stringify({ sessionId: sessionId2 }));
|
|
11358
11438
|
}
|
|
11359
11439
|
function readSignalOwner(itemId2) {
|
|
11360
11440
|
const path110 = getOwnerPath(itemId2);
|
|
11361
|
-
if (!
|
|
11441
|
+
if (!existsSync24(path110)) return void 0;
|
|
11362
11442
|
try {
|
|
11363
11443
|
const parsed = JSON.parse(readFileSync10(path110, "utf8"));
|
|
11364
11444
|
return parsed.sessionId;
|
|
@@ -11377,7 +11457,7 @@ function clearSignalOwner(itemId2) {
|
|
|
11377
11457
|
// src/commands/backlog/writeSignal.ts
|
|
11378
11458
|
function getSignalPath(sessionId2 = process.env.ASSIST_SESSION_ID) {
|
|
11379
11459
|
if (!sessionId2) return void 0;
|
|
11380
|
-
return
|
|
11460
|
+
return join30(homedir12(), ".assist", "signals", `signal-${sessionId2}.json`);
|
|
11381
11461
|
}
|
|
11382
11462
|
function resolveSignalTarget(event, data) {
|
|
11383
11463
|
const caller = process.env.ASSIST_SESSION_ID;
|
|
@@ -11409,7 +11489,7 @@ function writeSignal(event, data) {
|
|
|
11409
11489
|
const path110 = getSignalPath(target);
|
|
11410
11490
|
if (!path110) return;
|
|
11411
11491
|
const signal = { event, sessionId: target, ...data };
|
|
11412
|
-
|
|
11492
|
+
mkdirSync7(dirname13(path110), { recursive: true });
|
|
11413
11493
|
writeFileSync7(path110, JSON.stringify(signal));
|
|
11414
11494
|
}
|
|
11415
11495
|
|
|
@@ -11882,6 +11962,21 @@ var sessionFeature = {
|
|
|
11882
11962
|
label: "A new session",
|
|
11883
11963
|
requires: [...editEnforcement]
|
|
11884
11964
|
};
|
|
11965
|
+
var conversationResumeFeature = {
|
|
11966
|
+
id: "conversationResume",
|
|
11967
|
+
label: "Resuming a conversation",
|
|
11968
|
+
requires: ["conversation.resume"]
|
|
11969
|
+
};
|
|
11970
|
+
var conversationRecoveryFeature = {
|
|
11971
|
+
id: "conversationRecovery",
|
|
11972
|
+
label: "Resuming a conversation in a replacement worktree",
|
|
11973
|
+
requires: ["conversation.resume", "conversation.relocate"]
|
|
11974
|
+
};
|
|
11975
|
+
var divergenceEscalationFeature = {
|
|
11976
|
+
id: "divergenceEscalation",
|
|
11977
|
+
label: "Divergence escalation",
|
|
11978
|
+
requires: [...editEnforcement]
|
|
11979
|
+
};
|
|
11885
11980
|
var previewQuestionsFeature = {
|
|
11886
11981
|
id: "previewQuestions",
|
|
11887
11982
|
label: "Preview-pane questions",
|
|
@@ -11941,6 +12036,9 @@ var harnessFeatures = [
|
|
|
11941
12036
|
refineFeature,
|
|
11942
12037
|
buildFeature,
|
|
11943
12038
|
sessionFeature,
|
|
12039
|
+
conversationResumeFeature,
|
|
12040
|
+
conversationRecoveryFeature,
|
|
12041
|
+
divergenceEscalationFeature,
|
|
11944
12042
|
branchSlugFeature,
|
|
11945
12043
|
sessionTitleFeature,
|
|
11946
12044
|
messagePreviewsFeature,
|
|
@@ -13277,7 +13375,7 @@ async function nextPickup(req, res) {
|
|
|
13277
13375
|
import path18 from "path";
|
|
13278
13376
|
|
|
13279
13377
|
// src/commands/rules/readScopedRules.ts
|
|
13280
|
-
import { existsSync as
|
|
13378
|
+
import { existsSync as existsSync26, readFileSync as readFileSync11 } from "fs";
|
|
13281
13379
|
import path17 from "path";
|
|
13282
13380
|
|
|
13283
13381
|
// src/commands/rules/rulesSectionRange.ts
|
|
@@ -13326,11 +13424,11 @@ function parseRulesSection(content) {
|
|
|
13326
13424
|
}
|
|
13327
13425
|
|
|
13328
13426
|
// src/commands/rules/scopeDirectory.ts
|
|
13329
|
-
import { existsSync as
|
|
13427
|
+
import { existsSync as existsSync25, statSync as statSync7 } from "fs";
|
|
13330
13428
|
import path16 from "path";
|
|
13331
13429
|
function scopeDirectory(target) {
|
|
13332
13430
|
const resolved = path16.resolve(target);
|
|
13333
|
-
return
|
|
13431
|
+
return existsSync25(resolved) && statSync7(resolved).isDirectory() ? resolved : path16.dirname(resolved);
|
|
13334
13432
|
}
|
|
13335
13433
|
|
|
13336
13434
|
// src/commands/rules/readScopedRules.ts
|
|
@@ -13341,7 +13439,7 @@ function scopedClaudeFiles(target) {
|
|
|
13341
13439
|
let current2 = startDir;
|
|
13342
13440
|
while (true) {
|
|
13343
13441
|
const candidate = path17.join(current2, "CLAUDE.md");
|
|
13344
|
-
if (
|
|
13442
|
+
if (existsSync26(candidate)) files.push(candidate);
|
|
13345
13443
|
if (current2 === root2 || current2 === path17.dirname(current2)) break;
|
|
13346
13444
|
current2 = path17.dirname(current2);
|
|
13347
13445
|
}
|
|
@@ -14695,7 +14793,7 @@ async function revertDiffFile(req, res) {
|
|
|
14695
14793
|
|
|
14696
14794
|
// src/commands/run/runCommandToCompletion.ts
|
|
14697
14795
|
import { spawn as spawn6 } from "child_process";
|
|
14698
|
-
import { existsSync as
|
|
14796
|
+
import { existsSync as existsSync28 } from "fs";
|
|
14699
14797
|
|
|
14700
14798
|
// src/shared/expandEnv.ts
|
|
14701
14799
|
import { homedir as homedir13 } from "os";
|
|
@@ -14710,15 +14808,15 @@ function expandEnv(env) {
|
|
|
14710
14808
|
|
|
14711
14809
|
// src/commands/run/resolveCommand.ts
|
|
14712
14810
|
import { execFileSync as execFileSync4 } from "child_process";
|
|
14713
|
-
import { existsSync as
|
|
14714
|
-
import { dirname as dirname14, join as
|
|
14811
|
+
import { existsSync as existsSync27 } from "fs";
|
|
14812
|
+
import { dirname as dirname14, join as join31, resolve as resolve10 } from "path";
|
|
14715
14813
|
function resolveCommand(command) {
|
|
14716
14814
|
if (process.platform !== "win32" || command !== "bash") return command;
|
|
14717
14815
|
try {
|
|
14718
14816
|
const gitPath = execFileSync4("where", ["git"], { encoding: "utf8" }).trim().split("\r\n")[0];
|
|
14719
14817
|
const gitRoot = resolve10(dirname14(gitPath), "..");
|
|
14720
|
-
const gitBash =
|
|
14721
|
-
if (
|
|
14818
|
+
const gitBash = join31(gitRoot, "bin", "bash.exe");
|
|
14819
|
+
if (existsSync27(gitBash)) return gitBash;
|
|
14722
14820
|
} catch {
|
|
14723
14821
|
return command;
|
|
14724
14822
|
}
|
|
@@ -14728,7 +14826,7 @@ function resolveCommand(command) {
|
|
|
14728
14826
|
// src/commands/run/runCommandToCompletion.ts
|
|
14729
14827
|
function runCommandToCompletion(command, args, env, cwd, quiet) {
|
|
14730
14828
|
return new Promise((resolveResult) => {
|
|
14731
|
-
if (cwd && !
|
|
14829
|
+
if (cwd && !existsSync28(cwd)) {
|
|
14732
14830
|
resolveResult({
|
|
14733
14831
|
kind: "failed",
|
|
14734
14832
|
message: `Failed to execute command: cwd ${cwd} does not exist`
|
|
@@ -15970,11 +16068,11 @@ async function readUserConfig(orm) {
|
|
|
15970
16068
|
}
|
|
15971
16069
|
|
|
15972
16070
|
// src/shared/writeRepoConfigCache.ts
|
|
15973
|
-
import { mkdirSync as
|
|
16071
|
+
import { mkdirSync as mkdirSync8, renameSync as renameSync3, writeFileSync as writeFileSync8 } from "fs";
|
|
15974
16072
|
import { dirname as dirname15 } from "path";
|
|
15975
16073
|
function writeRepoConfigCache(repos2, user = {}) {
|
|
15976
16074
|
const path110 = repoConfigCachePath();
|
|
15977
|
-
|
|
16075
|
+
mkdirSync8(dirname15(path110), { recursive: true });
|
|
15978
16076
|
const cache7 = {
|
|
15979
16077
|
refreshedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
15980
16078
|
repos: repos2,
|
|
@@ -16480,17 +16578,17 @@ var autoRestartWait = {
|
|
|
16480
16578
|
|
|
16481
16579
|
// src/commands/extension/fetchLatestSignedExtension.ts
|
|
16482
16580
|
import { readFile as readFile2 } from "fs/promises";
|
|
16483
|
-
import { join as
|
|
16581
|
+
import { join as join33 } from "path";
|
|
16484
16582
|
|
|
16485
16583
|
// src/commands/extension/extensionDir.ts
|
|
16486
|
-
import { existsSync as
|
|
16487
|
-
import { dirname as dirname16, join as
|
|
16584
|
+
import { existsSync as existsSync29 } from "fs";
|
|
16585
|
+
import { dirname as dirname16, join as join32 } from "path";
|
|
16488
16586
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
16489
16587
|
var moduleDir = dirname16(fileURLToPath3(import.meta.url));
|
|
16490
16588
|
function extensionDir() {
|
|
16491
|
-
const bundled =
|
|
16492
|
-
if (
|
|
16493
|
-
return
|
|
16589
|
+
const bundled = join32(moduleDir, "commands", "extension", "extension");
|
|
16590
|
+
if (existsSync29(bundled)) return bundled;
|
|
16591
|
+
return join32(moduleDir, "..", "..", "..", "extension");
|
|
16494
16592
|
}
|
|
16495
16593
|
|
|
16496
16594
|
// src/commands/extension/latestUpdate.ts
|
|
@@ -16502,7 +16600,7 @@ function latestUpdate(manifest, updates2) {
|
|
|
16502
16600
|
// src/commands/extension/fetchLatestSignedExtension.ts
|
|
16503
16601
|
async function fetchLatestSignedExtension() {
|
|
16504
16602
|
const manifest = await readFile2(
|
|
16505
|
-
|
|
16603
|
+
join33(extensionDir(), "manifest.json"),
|
|
16506
16604
|
"utf8"
|
|
16507
16605
|
);
|
|
16508
16606
|
const updateUrl = JSON.parse(manifest).browser_specific_settings.gecko.update_url;
|
|
@@ -16529,7 +16627,7 @@ function latestSignedExtension(now = Date.now()) {
|
|
|
16529
16627
|
}
|
|
16530
16628
|
|
|
16531
16629
|
// src/commands/watch/isBuildPending.ts
|
|
16532
|
-
import { existsSync as
|
|
16630
|
+
import { existsSync as existsSync31 } from "fs";
|
|
16533
16631
|
|
|
16534
16632
|
// src/commands/watch/gitMarkerPath.ts
|
|
16535
16633
|
import { resolve as resolve11 } from "path";
|
|
@@ -16546,7 +16644,7 @@ function buildPendingPath(cwd) {
|
|
|
16546
16644
|
}
|
|
16547
16645
|
|
|
16548
16646
|
// src/commands/watch/readBuiltVersion.ts
|
|
16549
|
-
import { join as
|
|
16647
|
+
import { join as join35 } from "path";
|
|
16550
16648
|
|
|
16551
16649
|
// src/shared/readPackageJson.ts
|
|
16552
16650
|
import * as fs10 from "fs";
|
|
@@ -16596,7 +16694,7 @@ function findPackageJsonWithVerifyScripts(startDir) {
|
|
|
16596
16694
|
function readBuiltVersion(cwd) {
|
|
16597
16695
|
try {
|
|
16598
16696
|
const root2 = runGit3(["rev-parse", "--show-toplevel"], cwd);
|
|
16599
|
-
return readPackageJson(
|
|
16697
|
+
return readPackageJson(join35(root2, "package.json")).version ?? "unknown";
|
|
16600
16698
|
} catch {
|
|
16601
16699
|
return "unknown";
|
|
16602
16700
|
}
|
|
@@ -16604,11 +16702,11 @@ function readBuiltVersion(cwd) {
|
|
|
16604
16702
|
|
|
16605
16703
|
// src/commands/watch/readDistVersion.ts
|
|
16606
16704
|
import { readFileSync as readFileSync13 } from "fs";
|
|
16607
|
-
import { join as
|
|
16705
|
+
import { join as join36 } from "path";
|
|
16608
16706
|
function readDistVersion(cwd) {
|
|
16609
16707
|
try {
|
|
16610
16708
|
const root2 = runGit3(["rev-parse", "--show-toplevel"], cwd);
|
|
16611
|
-
return readFileSync13(
|
|
16709
|
+
return readFileSync13(join36(root2, "dist", "built-version"), "utf8").trim();
|
|
16612
16710
|
} catch {
|
|
16613
16711
|
return void 0;
|
|
16614
16712
|
}
|
|
@@ -16623,7 +16721,7 @@ function isDistBehind(cwd) {
|
|
|
16623
16721
|
// src/commands/watch/isBuildPending.ts
|
|
16624
16722
|
function markedPending(cwd) {
|
|
16625
16723
|
try {
|
|
16626
|
-
return
|
|
16724
|
+
return existsSync31(buildPendingPath(cwd));
|
|
16627
16725
|
} catch {
|
|
16628
16726
|
return false;
|
|
16629
16727
|
}
|
|
@@ -16719,7 +16817,7 @@ function stripAnsi(text19) {
|
|
|
16719
16817
|
// src/commands/sessions/daemon/worktree/watcherLogPath.ts
|
|
16720
16818
|
import { createHash } from "crypto";
|
|
16721
16819
|
import { homedir as homedir14 } from "os";
|
|
16722
|
-
import { basename as basename13, join as
|
|
16820
|
+
import { basename as basename13, join as join37 } from "path";
|
|
16723
16821
|
|
|
16724
16822
|
// src/commands/sessions/daemon/worktree/canonicalTreePath.ts
|
|
16725
16823
|
import { realpathSync } from "fs";
|
|
@@ -16736,8 +16834,8 @@ function canonicalTreePath(path110) {
|
|
|
16736
16834
|
function watcherLogPath(cwd) {
|
|
16737
16835
|
const clone = canonicalTreePath(cwd);
|
|
16738
16836
|
const key = createHash("sha1").update(clone).digest("hex").slice(0, 8);
|
|
16739
|
-
const dir = process.env.ASSIST_WATCHER_LOG_DIR ??
|
|
16740
|
-
return
|
|
16837
|
+
const dir = process.env.ASSIST_WATCHER_LOG_DIR ?? join37(homedir14(), ".assist", "watchers");
|
|
16838
|
+
return join37(dir, `${basename13(clone) || "root"}-${key}.log`);
|
|
16741
16839
|
}
|
|
16742
16840
|
|
|
16743
16841
|
// src/commands/sessions/web/updates/readUpdateHistory.ts
|
|
@@ -16865,7 +16963,7 @@ async function readRequestBuffer(req, limit) {
|
|
|
16865
16963
|
|
|
16866
16964
|
// src/commands/sessions/web/stageAttachment.ts
|
|
16867
16965
|
import { mkdir, mkdtemp, writeFile } from "fs/promises";
|
|
16868
|
-
import { extname as extname2, join as
|
|
16966
|
+
import { extname as extname2, join as join38 } from "path";
|
|
16869
16967
|
|
|
16870
16968
|
// src/commands/sessions/web/ghAttachableExtensions.ts
|
|
16871
16969
|
var ghAttachableExtensions = /* @__PURE__ */ new Set([
|
|
@@ -16897,9 +16995,9 @@ function safeBaseName(name2) {
|
|
|
16897
16995
|
async function stageAttachment(name2, contentType, body) {
|
|
16898
16996
|
const ext = pickExtension(name2, contentType);
|
|
16899
16997
|
await mkdir(stagedAttachmentsDir, { recursive: true });
|
|
16900
|
-
const dir = await mkdtemp(
|
|
16998
|
+
const dir = await mkdtemp(join38(stagedAttachmentsDir, "upload-"));
|
|
16901
16999
|
const alt = safeBaseName(name2);
|
|
16902
|
-
const filePath =
|
|
17000
|
+
const filePath = join38(dir, `${alt}.${ext}`);
|
|
16903
17001
|
await writeFile(filePath, body);
|
|
16904
17002
|
return { dir, filePath, alt };
|
|
16905
17003
|
}
|
|
@@ -16948,16 +17046,16 @@ import { readFile as readFile3, stat as stat3, writeFile as writeFile2 } from "f
|
|
|
16948
17046
|
|
|
16949
17047
|
// src/commands/sessions/web/formatWithOxfmt.ts
|
|
16950
17048
|
import { execFile as execFile12 } from "child_process";
|
|
16951
|
-
import { existsSync as
|
|
16952
|
-
import { dirname as dirname18, join as
|
|
17049
|
+
import { existsSync as existsSync32 } from "fs";
|
|
17050
|
+
import { dirname as dirname18, join as join39 } from "path";
|
|
16953
17051
|
import { promisify as promisify13 } from "util";
|
|
16954
17052
|
var execFileAsync11 = promisify13(execFile12);
|
|
16955
17053
|
var TIMEOUT_MS = 15e3;
|
|
16956
17054
|
function findOxfmtScript(root2) {
|
|
16957
17055
|
let dir = root2;
|
|
16958
17056
|
for (; ; ) {
|
|
16959
|
-
const candidate =
|
|
16960
|
-
if (
|
|
17057
|
+
const candidate = join39(dir, "node_modules", "oxfmt", "bin", "oxfmt");
|
|
17058
|
+
if (existsSync32(candidate)) return candidate;
|
|
16961
17059
|
const parent = dirname18(dir);
|
|
16962
17060
|
if (parent === dir) return void 0;
|
|
16963
17061
|
dir = parent;
|
|
@@ -17029,10 +17127,10 @@ async function writeFileContent(req, res) {
|
|
|
17029
17127
|
// src/shared/createBundleHandler.ts
|
|
17030
17128
|
import { createHash as createHash2 } from "crypto";
|
|
17031
17129
|
import { readFileSync as readFileSync14, statSync as statSync8 } from "fs";
|
|
17032
|
-
import { dirname as dirname19, join as
|
|
17130
|
+
import { dirname as dirname19, join as join40 } from "path";
|
|
17033
17131
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
17034
17132
|
function createBundleHandler(importMetaUrl, bundlePath, contentType = "application/javascript") {
|
|
17035
|
-
const file =
|
|
17133
|
+
const file = join40(dirname19(fileURLToPath4(importMetaUrl)), bundlePath);
|
|
17036
17134
|
let cache7;
|
|
17037
17135
|
return (req, res) => {
|
|
17038
17136
|
const mtimeMs = statSync8(file).mtimeMs;
|
|
@@ -17468,9 +17566,9 @@ function scheduleReconnect() {
|
|
|
17468
17566
|
}
|
|
17469
17567
|
|
|
17470
17568
|
// src/commands/sessions/web/updates/autoRestart/autoRestartAttempts.ts
|
|
17471
|
-
import { mkdirSync as
|
|
17472
|
-
import { dirname as dirname20, join as
|
|
17473
|
-
var defaultPath =
|
|
17569
|
+
import { mkdirSync as mkdirSync9, readFileSync as readFileSync16, writeFileSync as writeFileSync9 } from "fs";
|
|
17570
|
+
import { dirname as dirname20, join as join41 } from "path";
|
|
17571
|
+
var defaultPath = join41(daemonPaths.dir, "auto-restart-attempts.json");
|
|
17474
17572
|
function read(path110) {
|
|
17475
17573
|
try {
|
|
17476
17574
|
return JSON.parse(readFileSync16(path110, "utf8"));
|
|
@@ -17483,7 +17581,7 @@ function autoRestartAttempts(port, path110 = defaultPath) {
|
|
|
17483
17581
|
return {
|
|
17484
17582
|
get: () => read(path110)[key],
|
|
17485
17583
|
set: (built) => {
|
|
17486
|
-
|
|
17584
|
+
mkdirSync9(dirname20(path110), { recursive: true });
|
|
17487
17585
|
writeFileSync9(
|
|
17488
17586
|
path110,
|
|
17489
17587
|
`${JSON.stringify({ ...read(path110), [key]: built }, null, 2)}
|
|
@@ -17693,9 +17791,9 @@ function originForCwd(cwd) {
|
|
|
17693
17791
|
}
|
|
17694
17792
|
|
|
17695
17793
|
// src/commands/sessions/daemon/repoDirExists.ts
|
|
17696
|
-
import { existsSync as
|
|
17794
|
+
import { existsSync as existsSync33 } from "fs";
|
|
17697
17795
|
function repoDirExists(cwd) {
|
|
17698
|
-
return
|
|
17796
|
+
return existsSync33(cwd);
|
|
17699
17797
|
}
|
|
17700
17798
|
|
|
17701
17799
|
// src/commands/sessions/daemon/worktree/git.ts
|
|
@@ -17796,7 +17894,7 @@ function gitCommonDir(cwd) {
|
|
|
17796
17894
|
var REGISTRY_FILE = "worktrees.json";
|
|
17797
17895
|
function readWorktreeRegistry() {
|
|
17798
17896
|
const data = loadJson(REGISTRY_FILE);
|
|
17799
|
-
return Object.entries(data).filter(([, record3]) => !record3.reaped).map(([path110, record3]) => ({ path: path110, ...record3 }));
|
|
17897
|
+
return Object.entries(data).filter(([, record3]) => !record3.reaped).map(([path110, { reaped: _reaped, ...record3 }]) => ({ path: path110, ...record3 }));
|
|
17800
17898
|
}
|
|
17801
17899
|
function worktreeAttributionIncludingReaped(path110) {
|
|
17802
17900
|
const record3 = loadJson(REGISTRY_FILE)[path110];
|
|
@@ -17807,6 +17905,13 @@ function recordWorktree(path110, clone, origin) {
|
|
|
17807
17905
|
data[path110] = { clone, origin };
|
|
17808
17906
|
saveJson(REGISTRY_FILE, data);
|
|
17809
17907
|
}
|
|
17908
|
+
function recordWorktreeHarness(path110, harness) {
|
|
17909
|
+
const data = loadJson(REGISTRY_FILE);
|
|
17910
|
+
const record3 = data[path110];
|
|
17911
|
+
if (!record3 || record3.reaped || record3.harness === harness) return;
|
|
17912
|
+
data[path110] = { ...record3, harness };
|
|
17913
|
+
saveJson(REGISTRY_FILE, data);
|
|
17914
|
+
}
|
|
17810
17915
|
function forgetWorktree(path110) {
|
|
17811
17916
|
const data = loadJson(REGISTRY_FILE);
|
|
17812
17917
|
const record3 = data[path110];
|
|
@@ -18187,17 +18292,17 @@ import * as path21 from "path";
|
|
|
18187
18292
|
import chalk21 from "chalk";
|
|
18188
18293
|
|
|
18189
18294
|
// src/commands/verify/addToKnipIgnoreBinaries.ts
|
|
18190
|
-
import { existsSync as
|
|
18191
|
-
import { join as
|
|
18295
|
+
import { existsSync as existsSync34, readFileSync as readFileSync17, writeFileSync as writeFileSync11 } from "fs";
|
|
18296
|
+
import { join as join42 } from "path";
|
|
18192
18297
|
import chalk20 from "chalk";
|
|
18193
18298
|
function loadKnipConfig(knipJsonPath) {
|
|
18194
|
-
if (
|
|
18299
|
+
if (existsSync34(knipJsonPath)) {
|
|
18195
18300
|
return JSON.parse(readFileSync17(knipJsonPath, "utf8"));
|
|
18196
18301
|
}
|
|
18197
18302
|
return { $schema: "https://unpkg.com/knip@5/schema.json" };
|
|
18198
18303
|
}
|
|
18199
18304
|
function addToKnipIgnoreBinaries(cwd, binary) {
|
|
18200
|
-
const knipJsonPath =
|
|
18305
|
+
const knipJsonPath = join42(cwd, "knip.json");
|
|
18201
18306
|
try {
|
|
18202
18307
|
const knipConfig = loadKnipConfig(knipJsonPath);
|
|
18203
18308
|
const ignoreBinaries = knipConfig.ignoreBinaries ?? [];
|
|
@@ -18244,7 +18349,7 @@ import * as path23 from "path";
|
|
|
18244
18349
|
import chalk26 from "chalk";
|
|
18245
18350
|
|
|
18246
18351
|
// src/commands/format/init.ts
|
|
18247
|
-
import { existsSync as
|
|
18352
|
+
import { existsSync as existsSync35, readFileSync as readFileSync18, writeFileSync as writeFileSync12 } from "fs";
|
|
18248
18353
|
import chalk24 from "chalk";
|
|
18249
18354
|
|
|
18250
18355
|
// src/utils/printDiff.ts
|
|
@@ -18287,7 +18392,7 @@ async function init() {
|
|
|
18287
18392
|
const newContent = `${JSON.stringify(oxfmtrc_template_default, null, " ")}
|
|
18288
18393
|
`;
|
|
18289
18394
|
const configPath = ".oxfmtrc.json";
|
|
18290
|
-
const oldContent =
|
|
18395
|
+
const oldContent = existsSync35(configPath) ? readFileSync18(configPath, "utf8") : "";
|
|
18291
18396
|
if (oldContent === newContent) {
|
|
18292
18397
|
console.log(".oxfmtrc.json already has the baseline formatter config");
|
|
18293
18398
|
return;
|
|
@@ -18310,15 +18415,15 @@ async function init() {
|
|
|
18310
18415
|
}
|
|
18311
18416
|
|
|
18312
18417
|
// src/commands/lint/init.ts
|
|
18313
|
-
import { existsSync as
|
|
18418
|
+
import { existsSync as existsSync38, readFileSync as readFileSync20, writeFileSync as writeFileSync14 } from "fs";
|
|
18314
18419
|
import chalk25 from "chalk";
|
|
18315
18420
|
|
|
18316
18421
|
// src/shared/removeEslint.ts
|
|
18317
18422
|
import { execSync as execSync7 } from "child_process";
|
|
18318
|
-
import { existsSync as
|
|
18423
|
+
import { existsSync as existsSync37, readFileSync as readFileSync19, writeFileSync as writeFileSync13 } from "fs";
|
|
18319
18424
|
|
|
18320
18425
|
// src/shared/removeEslint/removeEslintConfigFiles.ts
|
|
18321
|
-
import { existsSync as
|
|
18426
|
+
import { existsSync as existsSync36, unlinkSync as unlinkSync3 } from "fs";
|
|
18322
18427
|
var ESLINT_CONFIG_FILES = [
|
|
18323
18428
|
"eslint.config.js",
|
|
18324
18429
|
"eslint.config.mjs",
|
|
@@ -18334,7 +18439,7 @@ var ESLINT_CONFIG_FILES = [
|
|
|
18334
18439
|
function removeEslintConfigFiles() {
|
|
18335
18440
|
let removed = false;
|
|
18336
18441
|
for (const configFile of ESLINT_CONFIG_FILES) {
|
|
18337
|
-
if (
|
|
18442
|
+
if (existsSync36(configFile)) {
|
|
18338
18443
|
unlinkSync3(configFile);
|
|
18339
18444
|
console.log(`Removed ${configFile}`);
|
|
18340
18445
|
removed = true;
|
|
@@ -18356,7 +18461,7 @@ function removeEslint(options2 = {}) {
|
|
|
18356
18461
|
}
|
|
18357
18462
|
function removeEslintFromPackageJson(options2) {
|
|
18358
18463
|
const packageJsonPath = "package.json";
|
|
18359
|
-
if (!
|
|
18464
|
+
if (!existsSync37(packageJsonPath)) {
|
|
18360
18465
|
return false;
|
|
18361
18466
|
}
|
|
18362
18467
|
const packageJson = JSON.parse(readFileSync19(packageJsonPath, "utf8"));
|
|
@@ -18423,7 +18528,7 @@ async function writeOxlintConfig() {
|
|
|
18423
18528
|
const newContent = `${JSON.stringify(oxlintrc_template_default, null, " ")}
|
|
18424
18529
|
`;
|
|
18425
18530
|
const configPath = ".oxlintrc.json";
|
|
18426
|
-
const oldContent =
|
|
18531
|
+
const oldContent = existsSync38(configPath) ? readFileSync20(configPath, "utf8") : "";
|
|
18427
18532
|
if (oldContent === newContent) {
|
|
18428
18533
|
console.log(".oxlintrc.json already has the baseline linter config");
|
|
18429
18534
|
return;
|
|
@@ -19151,7 +19256,7 @@ function initPackageJson(name2) {
|
|
|
19151
19256
|
}
|
|
19152
19257
|
|
|
19153
19258
|
// src/commands/new/registerNew/newCli/writeCliTemplate.ts
|
|
19154
|
-
import { mkdirSync as
|
|
19259
|
+
import { mkdirSync as mkdirSync11, writeFileSync as writeFileSync19 } from "fs";
|
|
19155
19260
|
function writeCliTemplate(name2) {
|
|
19156
19261
|
console.log("Writing tsconfig.json...");
|
|
19157
19262
|
writeFileSync19(
|
|
@@ -19192,7 +19297,7 @@ export default defineConfig({
|
|
|
19192
19297
|
`
|
|
19193
19298
|
);
|
|
19194
19299
|
console.log("Writing src/index.ts...");
|
|
19195
|
-
|
|
19300
|
+
mkdirSync11("src", { recursive: true });
|
|
19196
19301
|
writeFileSync19(
|
|
19197
19302
|
"src/index.ts",
|
|
19198
19303
|
`#!/usr/bin/env node
|
|
@@ -19221,7 +19326,7 @@ async function newCli() {
|
|
|
19221
19326
|
|
|
19222
19327
|
// src/commands/new/registerNew/newProject.ts
|
|
19223
19328
|
import { execSync as execSync14 } from "child_process";
|
|
19224
|
-
import { existsSync as
|
|
19329
|
+
import { existsSync as existsSync43, readFileSync as readFileSync24, writeFileSync as writeFileSync21 } from "fs";
|
|
19225
19330
|
|
|
19226
19331
|
// src/commands/deploy/init.ts
|
|
19227
19332
|
import { execSync as execSync13 } from "child_process";
|
|
@@ -19229,14 +19334,14 @@ import chalk36 from "chalk";
|
|
|
19229
19334
|
import enquirer3 from "enquirer";
|
|
19230
19335
|
|
|
19231
19336
|
// src/commands/deploy/init/updateWorkflow.ts
|
|
19232
|
-
import { existsSync as
|
|
19233
|
-
import { dirname as dirname28, join as
|
|
19337
|
+
import { existsSync as existsSync42, mkdirSync as mkdirSync12, readFileSync as readFileSync23, writeFileSync as writeFileSync20 } from "fs";
|
|
19338
|
+
import { dirname as dirname28, join as join49 } from "path";
|
|
19234
19339
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
19235
19340
|
import chalk35 from "chalk";
|
|
19236
19341
|
var WORKFLOW_PATH = ".github/workflows/build.yml";
|
|
19237
19342
|
var __dirname4 = dirname28(fileURLToPath5(import.meta.url));
|
|
19238
19343
|
function getExistingSiteId() {
|
|
19239
|
-
if (!
|
|
19344
|
+
if (!existsSync42(WORKFLOW_PATH)) {
|
|
19240
19345
|
return null;
|
|
19241
19346
|
}
|
|
19242
19347
|
const content = readFileSync23(WORKFLOW_PATH, "utf8");
|
|
@@ -19244,17 +19349,17 @@ function getExistingSiteId() {
|
|
|
19244
19349
|
return match ? match[1] : null;
|
|
19245
19350
|
}
|
|
19246
19351
|
function getTemplateContent(siteId) {
|
|
19247
|
-
const templatePath =
|
|
19352
|
+
const templatePath = join49(__dirname4, "commands/deploy/build.yml");
|
|
19248
19353
|
const template = readFileSync23(templatePath, "utf8");
|
|
19249
19354
|
return template.replace("{{NETLIFY_SITE_ID}}", siteId);
|
|
19250
19355
|
}
|
|
19251
19356
|
async function updateWorkflow(siteId) {
|
|
19252
19357
|
const newContent = getTemplateContent(siteId);
|
|
19253
19358
|
const workflowDir = ".github/workflows";
|
|
19254
|
-
if (!
|
|
19255
|
-
|
|
19359
|
+
if (!existsSync42(workflowDir)) {
|
|
19360
|
+
mkdirSync12(workflowDir, { recursive: true });
|
|
19256
19361
|
}
|
|
19257
|
-
if (
|
|
19362
|
+
if (existsSync42(WORKFLOW_PATH)) {
|
|
19258
19363
|
const oldContent = readFileSync23(WORKFLOW_PATH, "utf8");
|
|
19259
19364
|
if (oldContent === newContent) {
|
|
19260
19365
|
console.log(chalk35.green("build.yml is already up to date"));
|
|
@@ -19349,7 +19454,7 @@ async function newProject() {
|
|
|
19349
19454
|
}
|
|
19350
19455
|
function addViteBaseConfig() {
|
|
19351
19456
|
const viteConfigPath = "vite.config.ts";
|
|
19352
|
-
if (!
|
|
19457
|
+
if (!existsSync43(viteConfigPath)) {
|
|
19353
19458
|
console.log("No vite.config.ts found, skipping base config");
|
|
19354
19459
|
return;
|
|
19355
19460
|
}
|
|
@@ -19552,17 +19657,17 @@ function adviceContextFor(cwd, env = process.env) {
|
|
|
19552
19657
|
|
|
19553
19658
|
// src/commands/advise/loadAdviceFragments.ts
|
|
19554
19659
|
import { readdirSync as readdirSync9, readFileSync as readFileSync25 } from "fs";
|
|
19555
|
-
import { basename as basename15, join as
|
|
19660
|
+
import { basename as basename15, join as join51 } from "path";
|
|
19556
19661
|
|
|
19557
19662
|
// src/commands/advise/adviceDir.ts
|
|
19558
|
-
import { existsSync as
|
|
19559
|
-
import { dirname as dirname29, join as
|
|
19663
|
+
import { existsSync as existsSync44 } from "fs";
|
|
19664
|
+
import { dirname as dirname29, join as join50 } from "path";
|
|
19560
19665
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
19561
19666
|
function adviceDir() {
|
|
19562
19667
|
let current2 = dirname29(fileURLToPath6(import.meta.url));
|
|
19563
19668
|
while (current2 !== dirname29(current2)) {
|
|
19564
|
-
const candidate =
|
|
19565
|
-
if (
|
|
19669
|
+
const candidate = join50(current2, "claude", "advice");
|
|
19670
|
+
if (existsSync44(candidate)) return candidate;
|
|
19566
19671
|
current2 = dirname29(current2);
|
|
19567
19672
|
}
|
|
19568
19673
|
throw new Error("Could not locate the shipped claude/advice directory");
|
|
@@ -19594,7 +19699,7 @@ function loadAdviceFragments(dir = adviceDir()) {
|
|
|
19594
19699
|
return readdirSync9(dir).filter((file) => file.endsWith(".md")).sort().map(
|
|
19595
19700
|
(file) => parseAdviceFragment(
|
|
19596
19701
|
basename15(file, ".md"),
|
|
19597
|
-
readFileSync25(
|
|
19702
|
+
readFileSync25(join51(dir, file), "utf8")
|
|
19598
19703
|
)
|
|
19599
19704
|
);
|
|
19600
19705
|
}
|
|
@@ -19628,13 +19733,13 @@ function renderAdviceBody(fragment, context) {
|
|
|
19628
19733
|
}
|
|
19629
19734
|
|
|
19630
19735
|
// src/commands/advise/adviceConditions.ts
|
|
19631
|
-
import { existsSync as
|
|
19632
|
-
import { join as
|
|
19736
|
+
import { existsSync as existsSync45 } from "fs";
|
|
19737
|
+
import { join as join52 } from "path";
|
|
19633
19738
|
function repoFile(file, label) {
|
|
19634
19739
|
return {
|
|
19635
19740
|
whenMet: `the repo has ${label}`,
|
|
19636
19741
|
whenUnmet: `the repo has no ${label}`,
|
|
19637
|
-
matches: ({ rootDir }) =>
|
|
19742
|
+
matches: ({ rootDir }) => existsSync45(join52(rootDir, file))
|
|
19638
19743
|
};
|
|
19639
19744
|
}
|
|
19640
19745
|
var adviceConditions = {
|
|
@@ -19660,11 +19765,11 @@ var adviceConditions = {
|
|
|
19660
19765
|
},
|
|
19661
19766
|
typescript: repoFile("tsconfig.json", "a tsconfig.json"),
|
|
19662
19767
|
filenameConvention: repoFile(
|
|
19663
|
-
|
|
19768
|
+
join52("oxlint-rules", "filenameConvention.ts"),
|
|
19664
19769
|
"oxlint-rules/filenameConvention.ts"
|
|
19665
19770
|
),
|
|
19666
19771
|
claudeSettings: repoFile(
|
|
19667
|
-
|
|
19772
|
+
join52("claude", "settings.json"),
|
|
19668
19773
|
"claude/settings.json"
|
|
19669
19774
|
),
|
|
19670
19775
|
verify: {
|
|
@@ -20580,7 +20685,7 @@ function registerAskQuestion(program) {
|
|
|
20580
20685
|
|
|
20581
20686
|
// src/commands/registerBackup.ts
|
|
20582
20687
|
import { mkdir as mkdir3, stat as stat4 } from "fs/promises";
|
|
20583
|
-
import { join as
|
|
20688
|
+
import { join as join54, resolve as resolve16 } from "path";
|
|
20584
20689
|
import chalk41 from "chalk";
|
|
20585
20690
|
|
|
20586
20691
|
// src/shared/db/recordBackup.ts
|
|
@@ -20594,7 +20699,7 @@ async function recordBackup(db, {
|
|
|
20594
20699
|
|
|
20595
20700
|
// src/commands/backup/scheduleBackup.ts
|
|
20596
20701
|
import { mkdir as mkdir2 } from "fs/promises";
|
|
20597
|
-
import { join as
|
|
20702
|
+
import { join as join53 } from "path";
|
|
20598
20703
|
import chalk39 from "chalk";
|
|
20599
20704
|
|
|
20600
20705
|
// src/commands/backup/readCrontab.ts
|
|
@@ -20736,7 +20841,7 @@ async function scheduleBackup({
|
|
|
20736
20841
|
const cronExpr = durationToCron(every);
|
|
20737
20842
|
const dir = expandTilde(loadConfig().backup.dir);
|
|
20738
20843
|
await mkdir2(dir, { recursive: true });
|
|
20739
|
-
const logPath2 =
|
|
20844
|
+
const logPath2 = join53(dir, "cron.log");
|
|
20740
20845
|
const cronLine = `${cronExpr} ${resolveAssistCommand()} backup >> ${logPath2} 2>&1`;
|
|
20741
20846
|
writeCrontab(upsertScheduleBlock(readCrontab(), every, cronLine));
|
|
20742
20847
|
console.error(
|
|
@@ -20915,7 +21020,7 @@ async function backup({ out }) {
|
|
|
20915
21020
|
await mkdir3(dir, { recursive: true });
|
|
20916
21021
|
const start2 = Date.now();
|
|
20917
21022
|
const timestamp9 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
20918
|
-
const filePath = resolve16(
|
|
21023
|
+
const filePath = resolve16(join54(dir, `backup-${timestamp9}.dump`));
|
|
20919
21024
|
await exportBacklog(filePath);
|
|
20920
21025
|
const { size } = await stat4(filePath);
|
|
20921
21026
|
const durationMs = Date.now() - start2;
|
|
@@ -21426,7 +21531,7 @@ function registerAssociateJiraCommand(cmd) {
|
|
|
21426
21531
|
|
|
21427
21532
|
// src/commands/backlog/cloneRepo.ts
|
|
21428
21533
|
import { spawnSync as spawnSync5 } from "child_process";
|
|
21429
|
-
import { existsSync as
|
|
21534
|
+
import { existsSync as existsSync47 } from "fs";
|
|
21430
21535
|
import { mkdir as mkdir4 } from "fs/promises";
|
|
21431
21536
|
import chalk48 from "chalk";
|
|
21432
21537
|
|
|
@@ -21462,7 +21567,7 @@ async function cloneRepo(originRaw) {
|
|
|
21462
21567
|
if (!target) {
|
|
21463
21568
|
return fail3(`Could not derive a repository name from "${origin}".`);
|
|
21464
21569
|
}
|
|
21465
|
-
if (
|
|
21570
|
+
if (existsSync47(target)) {
|
|
21466
21571
|
return fail3(`Clone target already exists: ${target}`);
|
|
21467
21572
|
}
|
|
21468
21573
|
await mkdir4(baseDir, { recursive: true });
|
|
@@ -21808,7 +21913,7 @@ function ensureRemoteOrigin() {
|
|
|
21808
21913
|
import { spawnSync as spawnSync6 } from "child_process";
|
|
21809
21914
|
import { mkdtempSync, readFileSync as readFileSync27, unlinkSync as unlinkSync4, writeFileSync as writeFileSync22 } from "fs";
|
|
21810
21915
|
import { tmpdir as tmpdir2 } from "os";
|
|
21811
|
-
import { join as
|
|
21916
|
+
import { join as join56 } from "path";
|
|
21812
21917
|
import enquirer4 from "enquirer";
|
|
21813
21918
|
async function promptType() {
|
|
21814
21919
|
const { type } = await enquirer4.prompt({
|
|
@@ -21848,8 +21953,8 @@ async function promptDescription() {
|
|
|
21848
21953
|
}
|
|
21849
21954
|
function openEditor() {
|
|
21850
21955
|
const editor = process.env.EDITOR || process.env.VISUAL || "vi";
|
|
21851
|
-
const dir = mkdtempSync(
|
|
21852
|
-
const filePath =
|
|
21956
|
+
const dir = mkdtempSync(join56(tmpdir2(), "assist-"));
|
|
21957
|
+
const filePath = join56(dir, "description.md");
|
|
21853
21958
|
writeFileSync22(filePath, "");
|
|
21854
21959
|
const result = spawnSync6(editor, [filePath], { stdio: "inherit" });
|
|
21855
21960
|
if (result.status !== 0) {
|
|
@@ -22290,7 +22395,7 @@ function startProposedRun(id, startOn) {
|
|
|
22290
22395
|
import { randomUUID as randomUUID10 } from "crypto";
|
|
22291
22396
|
|
|
22292
22397
|
// src/commands/backlog/propose/mutateLedger.ts
|
|
22293
|
-
import { mkdirSync as
|
|
22398
|
+
import { mkdirSync as mkdirSync13, readFileSync as readFileSync28, renameSync as renameSync4, writeFileSync as writeFileSync23 } from "fs";
|
|
22294
22399
|
import { dirname as dirname30 } from "path";
|
|
22295
22400
|
function readLedger(path110) {
|
|
22296
22401
|
try {
|
|
@@ -22303,7 +22408,7 @@ function readLedger(path110) {
|
|
|
22303
22408
|
function mutateLedger(path110, mutate) {
|
|
22304
22409
|
const ledger = readLedger(path110);
|
|
22305
22410
|
mutate(ledger);
|
|
22306
|
-
|
|
22411
|
+
mkdirSync13(dirname30(path110), { recursive: true });
|
|
22307
22412
|
const tmp = `${path110}.${process.pid}.tmp`;
|
|
22308
22413
|
writeFileSync23(tmp, JSON.stringify(ledger));
|
|
22309
22414
|
renameSync4(tmp, path110);
|
|
@@ -22334,9 +22439,9 @@ async function findPredecessor(path110, token, startedAt) {
|
|
|
22334
22439
|
|
|
22335
22440
|
// src/commands/backlog/propose/proposalLedgerPath.ts
|
|
22336
22441
|
import { homedir as homedir15 } from "os";
|
|
22337
|
-
import { join as
|
|
22442
|
+
import { join as join57 } from "path";
|
|
22338
22443
|
function proposalLedgerPath(sessionId2) {
|
|
22339
|
-
return
|
|
22444
|
+
return join57(homedir15(), ".assist", "proposals", `session-${sessionId2}.json`);
|
|
22340
22445
|
}
|
|
22341
22446
|
|
|
22342
22447
|
// src/commands/backlog/propose/trackProposal.ts
|
|
@@ -22692,7 +22797,7 @@ import chalk69 from "chalk";
|
|
|
22692
22797
|
|
|
22693
22798
|
// src/shared/waitForIndexUnlocked.ts
|
|
22694
22799
|
import { execSync as execSync18 } from "child_process";
|
|
22695
|
-
import { existsSync as
|
|
22800
|
+
import { existsSync as existsSync48 } from "fs";
|
|
22696
22801
|
import { resolve as resolve17 } from "path";
|
|
22697
22802
|
var POLL_MS2 = 200;
|
|
22698
22803
|
function indexLockPath() {
|
|
@@ -22713,7 +22818,7 @@ function waitForIndexUnlocked(timeoutMs) {
|
|
|
22713
22818
|
const lock2 = indexLockPath();
|
|
22714
22819
|
if (!lock2) return true;
|
|
22715
22820
|
const deadline = Date.now() + timeoutMs;
|
|
22716
|
-
while (
|
|
22821
|
+
while (existsSync48(lock2)) {
|
|
22717
22822
|
if (Date.now() >= deadline) return false;
|
|
22718
22823
|
sleepSync(POLL_MS2);
|
|
22719
22824
|
}
|
|
@@ -22829,14 +22934,14 @@ function hasLocalChanges() {
|
|
|
22829
22934
|
|
|
22830
22935
|
// src/commands/backlog/acquireLock.ts
|
|
22831
22936
|
import {
|
|
22832
|
-
existsSync as
|
|
22833
|
-
mkdirSync as
|
|
22937
|
+
existsSync as existsSync49,
|
|
22938
|
+
mkdirSync as mkdirSync14,
|
|
22834
22939
|
readFileSync as readFileSync30,
|
|
22835
22940
|
unlinkSync as unlinkSync5,
|
|
22836
22941
|
writeFileSync as writeFileSync24
|
|
22837
22942
|
} from "fs";
|
|
22838
22943
|
import { homedir as homedir16 } from "os";
|
|
22839
|
-
import { join as
|
|
22944
|
+
import { join as join58 } from "path";
|
|
22840
22945
|
|
|
22841
22946
|
// src/commands/backlog/bootedAt.ts
|
|
22842
22947
|
import { uptime } from "os";
|
|
@@ -22872,10 +22977,10 @@ function isStaleLock(pid, timestamp9) {
|
|
|
22872
22977
|
|
|
22873
22978
|
// src/commands/backlog/acquireLock.ts
|
|
22874
22979
|
function getLocksDir() {
|
|
22875
|
-
return
|
|
22980
|
+
return join58(homedir16(), ".assist", "locks");
|
|
22876
22981
|
}
|
|
22877
22982
|
function getLockPath(itemId2) {
|
|
22878
|
-
return
|
|
22983
|
+
return join58(getLocksDir(), `lock-${itemId2}.json`);
|
|
22879
22984
|
}
|
|
22880
22985
|
function isProcessAlive(pid) {
|
|
22881
22986
|
try {
|
|
@@ -22887,7 +22992,7 @@ function isProcessAlive(pid) {
|
|
|
22887
22992
|
}
|
|
22888
22993
|
function foreignLockHolder(itemId2) {
|
|
22889
22994
|
const lockPath = getLockPath(itemId2);
|
|
22890
|
-
if (!
|
|
22995
|
+
if (!existsSync49(lockPath)) return null;
|
|
22891
22996
|
try {
|
|
22892
22997
|
const lock2 = JSON.parse(readFileSync30(lockPath, "utf8"));
|
|
22893
22998
|
if (typeof lock2.pid !== "number" || lock2.pid === process.pid) return null;
|
|
@@ -22902,7 +23007,7 @@ function isLockedByOther(itemId2) {
|
|
|
22902
23007
|
return foreignLockHolder(itemId2) !== null;
|
|
22903
23008
|
}
|
|
22904
23009
|
function acquireLock(itemId2) {
|
|
22905
|
-
|
|
23010
|
+
mkdirSync14(getLocksDir(), { recursive: true });
|
|
22906
23011
|
writeFileSync24(
|
|
22907
23012
|
getLockPath(itemId2),
|
|
22908
23013
|
JSON.stringify({ pid: process.pid, timestamp: (/* @__PURE__ */ new Date()).toISOString() })
|
|
@@ -23333,24 +23438,24 @@ async function resumeDoneConversation({ item, resumeSessionId }, spawnOptions) {
|
|
|
23333
23438
|
}
|
|
23334
23439
|
|
|
23335
23440
|
// src/commands/backlog/consumePause.ts
|
|
23336
|
-
import { existsSync as
|
|
23441
|
+
import { existsSync as existsSync50, mkdirSync as mkdirSync15, unlinkSync as unlinkSync6, writeFileSync as writeFileSync25 } from "fs";
|
|
23337
23442
|
import { homedir as homedir17 } from "os";
|
|
23338
|
-
import { join as
|
|
23443
|
+
import { join as join59 } from "path";
|
|
23339
23444
|
function getControlsDir() {
|
|
23340
|
-
return
|
|
23445
|
+
return join59(homedir17(), ".assist", "controls");
|
|
23341
23446
|
}
|
|
23342
23447
|
function getPausePath(itemId2) {
|
|
23343
|
-
return
|
|
23448
|
+
return join59(getControlsDir(), `pause-${itemId2}.json`);
|
|
23344
23449
|
}
|
|
23345
23450
|
function requestPause(itemId2) {
|
|
23346
|
-
|
|
23451
|
+
mkdirSync15(getControlsDir(), { recursive: true });
|
|
23347
23452
|
writeFileSync25(
|
|
23348
23453
|
getPausePath(itemId2),
|
|
23349
23454
|
JSON.stringify({ timestamp: (/* @__PURE__ */ new Date()).toISOString() })
|
|
23350
23455
|
);
|
|
23351
23456
|
}
|
|
23352
23457
|
function isPausePending(itemId2) {
|
|
23353
|
-
return
|
|
23458
|
+
return existsSync50(getPausePath(itemId2));
|
|
23354
23459
|
}
|
|
23355
23460
|
function clearPause(itemId2) {
|
|
23356
23461
|
try {
|
|
@@ -23360,7 +23465,7 @@ function clearPause(itemId2) {
|
|
|
23360
23465
|
}
|
|
23361
23466
|
function consumePause(itemId2) {
|
|
23362
23467
|
const pausePath = getPausePath(itemId2);
|
|
23363
|
-
if (!
|
|
23468
|
+
if (!existsSync50(pausePath)) return false;
|
|
23364
23469
|
try {
|
|
23365
23470
|
unlinkSync6(pausePath);
|
|
23366
23471
|
} catch {
|
|
@@ -23520,13 +23625,13 @@ function logHookFired(status2, sessionId2, source) {
|
|
|
23520
23625
|
}
|
|
23521
23626
|
|
|
23522
23627
|
// src/commands/backlog/watchForMarker.ts
|
|
23523
|
-
import { existsSync as
|
|
23628
|
+
import { existsSync as existsSync52, unwatchFile, watchFile } from "fs";
|
|
23524
23629
|
|
|
23525
23630
|
// src/commands/backlog/readSignal.ts
|
|
23526
|
-
import { existsSync as
|
|
23631
|
+
import { existsSync as existsSync51, readFileSync as readFileSync31 } from "fs";
|
|
23527
23632
|
function readSignal() {
|
|
23528
23633
|
const path110 = getSignalPath();
|
|
23529
|
-
if (!path110 || !
|
|
23634
|
+
if (!path110 || !existsSync51(path110)) return void 0;
|
|
23530
23635
|
try {
|
|
23531
23636
|
return JSON.parse(readFileSync31(path110, "utf8"));
|
|
23532
23637
|
} catch {
|
|
@@ -23540,7 +23645,7 @@ function watchForMarker(child, options2) {
|
|
|
23540
23645
|
const statusPath = getSignalPath();
|
|
23541
23646
|
if (!statusPath) return { killedOnMarker: () => killed };
|
|
23542
23647
|
watchFile(statusPath, { interval: 1e3 }, () => {
|
|
23543
|
-
if (!
|
|
23648
|
+
if (!existsSync52(statusPath)) return;
|
|
23544
23649
|
const signal = readSignal();
|
|
23545
23650
|
if (!signal) return;
|
|
23546
23651
|
if (signal.event === "done" && !options2?.actOnDone) return;
|
|
@@ -23596,7 +23701,7 @@ function launchPhaseSession(item, phaseNumber, phase, phaseLabel2, claudeSession
|
|
|
23596
23701
|
}
|
|
23597
23702
|
|
|
23598
23703
|
// src/commands/backlog/resolvePhaseResult.ts
|
|
23599
|
-
import { existsSync as
|
|
23704
|
+
import { existsSync as existsSync53, unlinkSync as unlinkSync7 } from "fs";
|
|
23600
23705
|
import chalk78 from "chalk";
|
|
23601
23706
|
|
|
23602
23707
|
// src/commands/backlog/handleIncompletePhase.ts
|
|
@@ -23618,7 +23723,7 @@ async function handleIncompletePhase() {
|
|
|
23618
23723
|
// src/commands/backlog/resolvePhaseResult.ts
|
|
23619
23724
|
function cleanupSignal() {
|
|
23620
23725
|
const statusPath = getSignalPath();
|
|
23621
|
-
if (statusPath &&
|
|
23726
|
+
if (statusPath && existsSync53(statusPath)) {
|
|
23622
23727
|
unlinkSync7(statusPath);
|
|
23623
23728
|
}
|
|
23624
23729
|
}
|
|
@@ -23629,7 +23734,7 @@ async function isTerminalStatus(itemId2) {
|
|
|
23629
23734
|
}
|
|
23630
23735
|
async function resolvePhaseResult(phaseIndex, itemId2) {
|
|
23631
23736
|
const signalPath = getSignalPath();
|
|
23632
|
-
if (!signalPath || !
|
|
23737
|
+
if (!signalPath || !existsSync53(signalPath)) {
|
|
23633
23738
|
if (await isTerminalStatus(itemId2)) return { kind: "abort" };
|
|
23634
23739
|
const action = await handleIncompletePhase();
|
|
23635
23740
|
if (action === "abort") return { kind: "abort" };
|
|
@@ -23714,9 +23819,9 @@ async function persistPhaseSessionId(itemId2, phaseIdx, claudeSessionId) {
|
|
|
23714
23819
|
}
|
|
23715
23820
|
|
|
23716
23821
|
// src/shared/emitActivity.ts
|
|
23717
|
-
import { mkdirSync as
|
|
23822
|
+
import { mkdirSync as mkdirSync16, readFileSync as readFileSync32, rmSync as rmSync4, writeFileSync as writeFileSync26 } from "fs";
|
|
23718
23823
|
import { homedir as homedir18 } from "os";
|
|
23719
|
-
import { dirname as dirname31, join as
|
|
23824
|
+
import { dirname as dirname31, join as join60 } from "path";
|
|
23720
23825
|
import { z as z17 } from "zod";
|
|
23721
23826
|
var activitySchema = z17.object({
|
|
23722
23827
|
kind: z17.enum(["command", "backlog"]),
|
|
@@ -23734,13 +23839,13 @@ var activitySchema = z17.object({
|
|
|
23734
23839
|
startedAt: z17.number()
|
|
23735
23840
|
});
|
|
23736
23841
|
function activityPath(sessionId2) {
|
|
23737
|
-
return
|
|
23842
|
+
return join60(homedir18(), ".assist", "activity", `activity-${sessionId2}.json`);
|
|
23738
23843
|
}
|
|
23739
23844
|
function emitActivity(activity2) {
|
|
23740
23845
|
const sessionId2 = process.env.ASSIST_ACTIVITY_ID;
|
|
23741
23846
|
if (!sessionId2) return;
|
|
23742
23847
|
const path110 = activityPath(sessionId2);
|
|
23743
|
-
|
|
23848
|
+
mkdirSync16(dirname31(path110), { recursive: true });
|
|
23744
23849
|
writeFileSync26(path110, JSON.stringify({ ...activity2, startedAt: Date.now() }));
|
|
23745
23850
|
}
|
|
23746
23851
|
function readActivity(path110) {
|
|
@@ -23756,12 +23861,12 @@ function reconcileActivity(sessionId2, activity2) {
|
|
|
23756
23861
|
return;
|
|
23757
23862
|
}
|
|
23758
23863
|
const path110 = activityPath(sessionId2);
|
|
23759
|
-
|
|
23864
|
+
mkdirSync16(dirname31(path110), { recursive: true });
|
|
23760
23865
|
writeFileSync26(path110, JSON.stringify(activity2));
|
|
23761
23866
|
}
|
|
23762
23867
|
function writeActivityIfAbsent(sessionId2, activity2) {
|
|
23763
23868
|
const path110 = activityPath(sessionId2);
|
|
23764
|
-
|
|
23869
|
+
mkdirSync16(dirname31(path110), { recursive: true });
|
|
23765
23870
|
try {
|
|
23766
23871
|
writeFileSync26(path110, JSON.stringify(activity2), { flag: "wx" });
|
|
23767
23872
|
return true;
|
|
@@ -26449,7 +26554,7 @@ function extractGraphqlQuery(args) {
|
|
|
26449
26554
|
}
|
|
26450
26555
|
|
|
26451
26556
|
// src/shared/loadCliReads.ts
|
|
26452
|
-
import { existsSync as
|
|
26557
|
+
import { existsSync as existsSync54, readFileSync as readFileSync34, writeFileSync as writeFileSync27 } from "fs";
|
|
26453
26558
|
import { dirname as dirname32, resolve as resolve18 } from "path";
|
|
26454
26559
|
import { fileURLToPath as fileURLToPath7 } from "url";
|
|
26455
26560
|
var __filename4 = fileURLToPath7(import.meta.url);
|
|
@@ -26458,7 +26563,7 @@ function packageRoot() {
|
|
|
26458
26563
|
return __dirname5;
|
|
26459
26564
|
}
|
|
26460
26565
|
function readLines(path110) {
|
|
26461
|
-
if (!
|
|
26566
|
+
if (!existsSync54(path110)) return [];
|
|
26462
26567
|
return readFileSync34(path110, "utf8").split("\n").filter((line) => line.trim() !== "");
|
|
26463
26568
|
}
|
|
26464
26569
|
var cachedReads;
|
|
@@ -26505,14 +26610,14 @@ function findCliWrite(command) {
|
|
|
26505
26610
|
}
|
|
26506
26611
|
|
|
26507
26612
|
// src/shared/readSettingsPerms.ts
|
|
26508
|
-
import { existsSync as
|
|
26613
|
+
import { existsSync as existsSync55, readFileSync as readFileSync35 } from "fs";
|
|
26509
26614
|
import { homedir as homedir19 } from "os";
|
|
26510
|
-
import { join as
|
|
26615
|
+
import { join as join61 } from "path";
|
|
26511
26616
|
function readSettingsPerms(key) {
|
|
26512
26617
|
const paths = [
|
|
26513
|
-
|
|
26514
|
-
|
|
26515
|
-
|
|
26618
|
+
join61(homedir19(), ".claude", "settings.json"),
|
|
26619
|
+
join61(process.cwd(), ".claude", "settings.json"),
|
|
26620
|
+
join61(process.cwd(), ".claude", "settings.local.json")
|
|
26516
26621
|
];
|
|
26517
26622
|
const entries = [];
|
|
26518
26623
|
for (const p of paths) {
|
|
@@ -26524,7 +26629,7 @@ function readSettingsPerms(key) {
|
|
|
26524
26629
|
return entries;
|
|
26525
26630
|
}
|
|
26526
26631
|
function readPermissionArray(filePath, key) {
|
|
26527
|
-
if (!
|
|
26632
|
+
if (!existsSync55(filePath)) return [];
|
|
26528
26633
|
try {
|
|
26529
26634
|
const data = JSON.parse(readFileSync35(filePath, "utf8"));
|
|
26530
26635
|
const arr = data?.permissions?.[key];
|
|
@@ -26878,32 +26983,32 @@ async function decideDocsGuard({
|
|
|
26878
26983
|
}
|
|
26879
26984
|
|
|
26880
26985
|
// src/commands/schema/isSchemaLocked.ts
|
|
26881
|
-
import { existsSync as
|
|
26986
|
+
import { existsSync as existsSync56, readFileSync as readFileSync37 } from "fs";
|
|
26882
26987
|
|
|
26883
26988
|
// src/commands/schema/getSchemaSessionApprovalPath.ts
|
|
26884
|
-
import { join as
|
|
26989
|
+
import { join as join63 } from "path";
|
|
26885
26990
|
|
|
26886
26991
|
// src/commands/codeComment/getRestrictedDir.ts
|
|
26887
26992
|
import { homedir as homedir20 } from "os";
|
|
26888
|
-
import { join as
|
|
26993
|
+
import { join as join62 } from "path";
|
|
26889
26994
|
function getRestrictedDir() {
|
|
26890
|
-
return
|
|
26995
|
+
return join62(homedir20(), ".assist", "restricted");
|
|
26891
26996
|
}
|
|
26892
26997
|
function getPinStatePath(pin2) {
|
|
26893
|
-
return
|
|
26998
|
+
return join62(getRestrictedDir(), `code-comment-${pin2}.json`);
|
|
26894
26999
|
}
|
|
26895
27000
|
|
|
26896
27001
|
// src/commands/schema/getSchemaSessionApprovalPath.ts
|
|
26897
27002
|
var SESSION_ID = /^[\w-]+$/;
|
|
26898
27003
|
function getSchemaSessionApprovalDir() {
|
|
26899
|
-
return
|
|
27004
|
+
return join63(getRestrictedDir(), "schema-sessions");
|
|
26900
27005
|
}
|
|
26901
27006
|
function getSchemaSessionApprovalPath(scope) {
|
|
26902
27007
|
const { harness, conversationId } = scope;
|
|
26903
27008
|
if (!SESSION_ID.test(conversationId) || !SESSION_ID.test(harness))
|
|
26904
27009
|
return void 0;
|
|
26905
27010
|
const name2 = harness === legacyDefaultHarness ? conversationId : `${harness}-${conversationId}`;
|
|
26906
|
-
return
|
|
27011
|
+
return join63(getSchemaSessionApprovalDir(), `${name2}.json`);
|
|
26907
27012
|
}
|
|
26908
27013
|
|
|
26909
27014
|
// src/commands/schema/isSchemaLocked.ts
|
|
@@ -26924,7 +27029,7 @@ function hasSessionApproval(identity) {
|
|
|
26924
27029
|
const { harness, conversationId } = identity;
|
|
26925
27030
|
if (!conversationId) return false;
|
|
26926
27031
|
const path110 = getSchemaSessionApprovalPath({ harness, conversationId });
|
|
26927
|
-
return path110 !== void 0 &&
|
|
27032
|
+
return path110 !== void 0 && existsSync56(path110) && approvalMatches(path110, identity);
|
|
26928
27033
|
}
|
|
26929
27034
|
async function isSchemaLocked(identity = currentExecutionIdentity()) {
|
|
26930
27035
|
if (!identity) return false;
|
|
@@ -26996,13 +27101,13 @@ async function decideToolOperations(operations2, identity) {
|
|
|
26996
27101
|
import { basename as basename17 } from "path";
|
|
26997
27102
|
|
|
26998
27103
|
// src/commands/cliHook/logDeniedToolCall.ts
|
|
26999
|
-
import { mkdirSync as
|
|
27104
|
+
import { mkdirSync as mkdirSync17 } from "fs";
|
|
27000
27105
|
import { homedir as homedir21 } from "os";
|
|
27001
|
-
import { join as
|
|
27106
|
+
import { join as join64 } from "path";
|
|
27002
27107
|
import Database from "better-sqlite3";
|
|
27003
27108
|
var _db;
|
|
27004
27109
|
function getDbDir() {
|
|
27005
|
-
return
|
|
27110
|
+
return join64(homedir21(), ".assist");
|
|
27006
27111
|
}
|
|
27007
27112
|
function initSchema(db) {
|
|
27008
27113
|
db.exec(`
|
|
@@ -27020,8 +27125,8 @@ function initSchema(db) {
|
|
|
27020
27125
|
function openPromptsDb(dir) {
|
|
27021
27126
|
if (_db) return _db;
|
|
27022
27127
|
const dbDir = dir ?? getDbDir();
|
|
27023
|
-
|
|
27024
|
-
const db = new Database(
|
|
27128
|
+
mkdirSync17(dbDir, { recursive: true });
|
|
27129
|
+
const db = new Database(join64(dbDir, "assist.db"));
|
|
27025
27130
|
db.pragma("journal_mode = WAL");
|
|
27026
27131
|
initSchema(db);
|
|
27027
27132
|
_db = db;
|
|
@@ -27125,9 +27230,9 @@ ${reasons.join("\n")}`);
|
|
|
27125
27230
|
}
|
|
27126
27231
|
|
|
27127
27232
|
// src/commands/permitCliReads.ts
|
|
27128
|
-
import { existsSync as
|
|
27233
|
+
import { existsSync as existsSync57, mkdirSync as mkdirSync18, readFileSync as readFileSync38, writeFileSync as writeFileSync28 } from "fs";
|
|
27129
27234
|
import { homedir as homedir22 } from "os";
|
|
27130
|
-
import { join as
|
|
27235
|
+
import { join as join65 } from "path";
|
|
27131
27236
|
|
|
27132
27237
|
// src/commands/permitCliReads/assertCliExists.ts
|
|
27133
27238
|
function assertCliExists(cli) {
|
|
@@ -27390,16 +27495,16 @@ function updateSettings(cli, commands) {
|
|
|
27390
27495
|
// src/commands/permitCliReads.ts
|
|
27391
27496
|
function logPath(cli) {
|
|
27392
27497
|
const safeName = cli.replace(/\s+/g, "-");
|
|
27393
|
-
return
|
|
27498
|
+
return join65(homedir22(), ".assist", `cli-discover-${safeName}.log`);
|
|
27394
27499
|
}
|
|
27395
27500
|
function readCache(cli) {
|
|
27396
27501
|
const path110 = logPath(cli);
|
|
27397
|
-
if (!
|
|
27502
|
+
if (!existsSync57(path110)) return void 0;
|
|
27398
27503
|
return readFileSync38(path110, "utf8");
|
|
27399
27504
|
}
|
|
27400
27505
|
function writeCache(cli, output) {
|
|
27401
|
-
const dir =
|
|
27402
|
-
|
|
27506
|
+
const dir = join65(homedir22(), ".assist");
|
|
27507
|
+
mkdirSync18(dir, { recursive: true });
|
|
27403
27508
|
writeFileSync28(logPath(cli), output);
|
|
27404
27509
|
}
|
|
27405
27510
|
async function permitCliReads(cli, options2 = { noCache: false }) {
|
|
@@ -27530,7 +27635,7 @@ function registerCliHook(program) {
|
|
|
27530
27635
|
}
|
|
27531
27636
|
|
|
27532
27637
|
// src/commands/codeComment/codeCommentConfirm.ts
|
|
27533
|
-
import { existsSync as
|
|
27638
|
+
import { existsSync as existsSync59, readFileSync as readFileSync40, unlinkSync as unlinkSync9, writeFileSync as writeFileSync29 } from "fs";
|
|
27534
27639
|
import chalk122 from "chalk";
|
|
27535
27640
|
|
|
27536
27641
|
// src/shared/isHashCommentFile.ts
|
|
@@ -27564,7 +27669,7 @@ function isHashCommentFile(filePath) {
|
|
|
27564
27669
|
|
|
27565
27670
|
// src/commands/codeComment/sweepRestrictedDir.ts
|
|
27566
27671
|
import { readdirSync as readdirSync11, statSync as statSync9, unlinkSync as unlinkSync8 } from "fs";
|
|
27567
|
-
import { join as
|
|
27672
|
+
import { join as join66 } from "path";
|
|
27568
27673
|
var STALE_AFTER_MS = 30 * 60 * 1e3;
|
|
27569
27674
|
function sweepRestrictedDir(dir = getRestrictedDir()) {
|
|
27570
27675
|
let entries;
|
|
@@ -27575,7 +27680,7 @@ function sweepRestrictedDir(dir = getRestrictedDir()) {
|
|
|
27575
27680
|
}
|
|
27576
27681
|
const cutoff = Date.now() - STALE_AFTER_MS;
|
|
27577
27682
|
for (const entry of entries) {
|
|
27578
|
-
const path110 =
|
|
27683
|
+
const path110 = join66(dir, entry);
|
|
27579
27684
|
try {
|
|
27580
27685
|
if (statSync9(path110).mtimeMs < cutoff) unlinkSync8(path110);
|
|
27581
27686
|
} catch {
|
|
@@ -27585,10 +27690,10 @@ function sweepRestrictedDir(dir = getRestrictedDir()) {
|
|
|
27585
27690
|
}
|
|
27586
27691
|
|
|
27587
27692
|
// src/commands/codeComment/readPinState.ts
|
|
27588
|
-
import { existsSync as
|
|
27693
|
+
import { existsSync as existsSync58, readFileSync as readFileSync39 } from "fs";
|
|
27589
27694
|
function readPinState(pin2) {
|
|
27590
27695
|
const path110 = getPinStatePath(pin2);
|
|
27591
|
-
if (!
|
|
27696
|
+
if (!existsSync58(path110)) return void 0;
|
|
27592
27697
|
try {
|
|
27593
27698
|
const state = JSON.parse(readFileSync39(path110, "utf8"));
|
|
27594
27699
|
if (state.pin !== pin2) return void 0;
|
|
@@ -27607,7 +27712,7 @@ function codeCommentConfirm(pin2) {
|
|
|
27607
27712
|
process.exitCode = 1;
|
|
27608
27713
|
return;
|
|
27609
27714
|
}
|
|
27610
|
-
if (!
|
|
27715
|
+
if (!existsSync59(state.file)) {
|
|
27611
27716
|
console.error(chalk122.red(`Target file no longer exists: ${state.file}`));
|
|
27612
27717
|
process.exitCode = 1;
|
|
27613
27718
|
return;
|
|
@@ -27666,7 +27771,7 @@ function validateCommentText(raw, isHash = false) {
|
|
|
27666
27771
|
}
|
|
27667
27772
|
|
|
27668
27773
|
// src/commands/codeComment/issuePin.ts
|
|
27669
|
-
import { mkdirSync as
|
|
27774
|
+
import { mkdirSync as mkdirSync19, writeFileSync as writeFileSync30 } from "fs";
|
|
27670
27775
|
import { randomInt } from "crypto";
|
|
27671
27776
|
|
|
27672
27777
|
// src/commands/notify/deliverPinNotification.ts
|
|
@@ -27751,7 +27856,7 @@ async function deliverPinNotification(notification) {
|
|
|
27751
27856
|
// src/commands/codeComment/issuePin.ts
|
|
27752
27857
|
function issuePin(file, lineNumber, text19) {
|
|
27753
27858
|
const pin2 = generatePin();
|
|
27754
|
-
|
|
27859
|
+
mkdirSync19(getRestrictedDir(), { recursive: true });
|
|
27755
27860
|
sweepRestrictedDir();
|
|
27756
27861
|
writeFileSync30(
|
|
27757
27862
|
getPinStatePath(pin2),
|
|
@@ -29837,16 +29942,16 @@ async function browserRun(options2) {
|
|
|
29837
29942
|
}
|
|
29838
29943
|
|
|
29839
29944
|
// src/commands/browser/browserSnapshot.ts
|
|
29840
|
-
import { mkdirSync as
|
|
29945
|
+
import { mkdirSync as mkdirSync20, writeFileSync as writeFileSync31 } from "fs";
|
|
29841
29946
|
import { dirname as dirname33 } from "path";
|
|
29842
29947
|
|
|
29843
29948
|
// src/commands/browser/snapshotPath.ts
|
|
29844
29949
|
import { homedir as homedir23 } from "os";
|
|
29845
|
-
import { join as
|
|
29950
|
+
import { join as join67 } from "path";
|
|
29846
29951
|
function snapshotPath(tabUrl, now) {
|
|
29847
29952
|
const host = new URL(tabUrl).host.replace(/[^\w.-]/g, "-");
|
|
29848
29953
|
const timestamp9 = now.toISOString().replace(/[:.]/g, "-");
|
|
29849
|
-
return
|
|
29954
|
+
return join67(homedir23(), ".assist", "browser", `${host}-${timestamp9}.html`);
|
|
29850
29955
|
}
|
|
29851
29956
|
|
|
29852
29957
|
// src/commands/browser/browserSnapshot.ts
|
|
@@ -29856,7 +29961,7 @@ async function browserSnapshot(options2) {
|
|
|
29856
29961
|
url: options2.url
|
|
29857
29962
|
});
|
|
29858
29963
|
const path110 = snapshotPath(result.tabUrl, /* @__PURE__ */ new Date());
|
|
29859
|
-
|
|
29964
|
+
mkdirSync20(dirname33(path110), { recursive: true });
|
|
29860
29965
|
writeFileSync31(path110, result.html);
|
|
29861
29966
|
console.log(`snapshot: ${path110}`);
|
|
29862
29967
|
}
|
|
@@ -30053,28 +30158,28 @@ async function printExtensionUrl() {
|
|
|
30053
30158
|
// src/commands/extension/signExtension.ts
|
|
30054
30159
|
import { rm as rm2 } from "fs/promises";
|
|
30055
30160
|
import { homedir as homedir24, tmpdir as tmpdir4 } from "os";
|
|
30056
|
-
import { join as
|
|
30161
|
+
import { join as join73 } from "path";
|
|
30057
30162
|
import chalk156 from "chalk";
|
|
30058
30163
|
|
|
30059
30164
|
// src/commands/extension/copySignedXpi.ts
|
|
30060
30165
|
import { copyFile } from "fs/promises";
|
|
30061
|
-
import { join as
|
|
30166
|
+
import { join as join68 } from "path";
|
|
30062
30167
|
var SIGNED_XPI_NAME = "assist-extension.xpi";
|
|
30063
30168
|
async function copySignedXpi(xpi, dir) {
|
|
30064
|
-
const fixed2 =
|
|
30169
|
+
const fixed2 = join68(dir, SIGNED_XPI_NAME);
|
|
30065
30170
|
if (fixed2 === xpi) return fixed2;
|
|
30066
30171
|
await copyFile(xpi, fixed2);
|
|
30067
30172
|
return fixed2;
|
|
30068
30173
|
}
|
|
30069
30174
|
|
|
30070
30175
|
// src/commands/extension/findSignedXpi.ts
|
|
30071
|
-
import { existsSync as
|
|
30176
|
+
import { existsSync as existsSync60 } from "fs";
|
|
30072
30177
|
import { readdir } from "fs/promises";
|
|
30073
|
-
import { join as
|
|
30178
|
+
import { join as join69 } from "path";
|
|
30074
30179
|
async function findSignedXpi(dir) {
|
|
30075
|
-
if (!
|
|
30180
|
+
if (!existsSync60(dir)) return null;
|
|
30076
30181
|
const name2 = (await readdir(dir)).find((entry) => entry.endsWith(".xpi"));
|
|
30077
|
-
return name2 ?
|
|
30182
|
+
return name2 ? join69(dir, name2) : null;
|
|
30078
30183
|
}
|
|
30079
30184
|
|
|
30080
30185
|
// src/commands/extension/signedAddonInstallPath.ts
|
|
@@ -30096,11 +30201,11 @@ async function signedAddonInstallPath(xpi) {
|
|
|
30096
30201
|
}
|
|
30097
30202
|
|
|
30098
30203
|
// src/commands/extension/signPreflightProblem.ts
|
|
30099
|
-
import { existsSync as
|
|
30100
|
-
import { join as
|
|
30204
|
+
import { existsSync as existsSync61 } from "fs";
|
|
30205
|
+
import { join as join70 } from "path";
|
|
30101
30206
|
var KEY_URL = "https://addons.mozilla.org/en-US/developers/addon/api/key/";
|
|
30102
30207
|
function signPreflightProblem(source) {
|
|
30103
|
-
if (!
|
|
30208
|
+
if (!existsSync61(join70(source, "content.js")))
|
|
30104
30209
|
return {
|
|
30105
30210
|
message: `no content.js in ${source}`,
|
|
30106
30211
|
hint: "run npm run build to bundle the content script"
|
|
@@ -30115,7 +30220,7 @@ function signPreflightProblem(source) {
|
|
|
30115
30220
|
|
|
30116
30221
|
// src/commands/extension/stageExtension.ts
|
|
30117
30222
|
import { cp as cp3, mkdir as mkdir5, readFile as readFile5, rm, writeFile as writeFile4 } from "fs/promises";
|
|
30118
|
-
import { basename as basename18, join as
|
|
30223
|
+
import { basename as basename18, join as join71 } from "path";
|
|
30119
30224
|
|
|
30120
30225
|
// src/commands/extension/stampManifestVersion.ts
|
|
30121
30226
|
function stampManifestVersion(manifest, version2) {
|
|
@@ -30132,7 +30237,7 @@ async function stageExtension(source, staging, version2) {
|
|
|
30132
30237
|
recursive: true,
|
|
30133
30238
|
filter: (path110) => basename18(path110) !== "updates.json"
|
|
30134
30239
|
});
|
|
30135
|
-
const manifest =
|
|
30240
|
+
const manifest = join71(staging, "manifest.json");
|
|
30136
30241
|
const stamped = stampManifestVersion(
|
|
30137
30242
|
await readFile5(manifest, "utf8"),
|
|
30138
30243
|
version2
|
|
@@ -30142,7 +30247,7 @@ async function stageExtension(source, staging, version2) {
|
|
|
30142
30247
|
|
|
30143
30248
|
// src/commands/extension/writeUpdateManifest.ts
|
|
30144
30249
|
import { readFile as readFile6, writeFile as writeFile5 } from "fs/promises";
|
|
30145
|
-
import { join as
|
|
30250
|
+
import { join as join72 } from "path";
|
|
30146
30251
|
|
|
30147
30252
|
// src/commands/extension/buildUpdateManifest.ts
|
|
30148
30253
|
var RELEASE_DOWNLOAD_URL = "https://github.com/staff0rd/assist/releases/download";
|
|
@@ -30167,17 +30272,17 @@ function buildUpdateManifest(manifest, version2) {
|
|
|
30167
30272
|
// src/commands/extension/writeUpdateManifest.ts
|
|
30168
30273
|
async function writeUpdateManifest(source, dir, version2) {
|
|
30169
30274
|
await writeFile5(
|
|
30170
|
-
|
|
30275
|
+
join72(dir, "updates.json"),
|
|
30171
30276
|
buildUpdateManifest(
|
|
30172
|
-
await readFile6(
|
|
30277
|
+
await readFile6(join72(source, "manifest.json"), "utf8"),
|
|
30173
30278
|
version2
|
|
30174
30279
|
)
|
|
30175
30280
|
);
|
|
30176
30281
|
}
|
|
30177
30282
|
|
|
30178
30283
|
// src/commands/extension/signExtension.ts
|
|
30179
|
-
var ARTIFACTS_DIR =
|
|
30180
|
-
var STAGING_DIR =
|
|
30284
|
+
var ARTIFACTS_DIR = join73(homedir24(), ".assist", "extension");
|
|
30285
|
+
var STAGING_DIR = join73(tmpdir4(), "assist-extension");
|
|
30181
30286
|
async function signExtension() {
|
|
30182
30287
|
const source = extensionDir();
|
|
30183
30288
|
const problem = signPreflightProblem(source);
|
|
@@ -30361,7 +30466,7 @@ function registerDb(program) {
|
|
|
30361
30466
|
}
|
|
30362
30467
|
|
|
30363
30468
|
// src/commands/deploy/redirect.ts
|
|
30364
|
-
import { existsSync as
|
|
30469
|
+
import { existsSync as existsSync62, readFileSync as readFileSync42, writeFileSync as writeFileSync32 } from "fs";
|
|
30365
30470
|
import chalk159 from "chalk";
|
|
30366
30471
|
var TRAILING_SLASH_SCRIPT = ` <script>
|
|
30367
30472
|
if (!window.location.pathname.endsWith('/')) {
|
|
@@ -30370,7 +30475,7 @@ var TRAILING_SLASH_SCRIPT = ` <script>
|
|
|
30370
30475
|
</script>`;
|
|
30371
30476
|
function redirect() {
|
|
30372
30477
|
const indexPath = "index.html";
|
|
30373
|
-
if (!
|
|
30478
|
+
if (!existsSync62(indexPath)) {
|
|
30374
30479
|
console.log(chalk159.yellow("No index.html found"));
|
|
30375
30480
|
return;
|
|
30376
30481
|
}
|
|
@@ -30469,9 +30574,9 @@ import { readFileSync as readFileSync43 } from "fs";
|
|
|
30469
30574
|
import { parse as parseYaml3 } from "yaml";
|
|
30470
30575
|
|
|
30471
30576
|
// src/commands/devlog/devEntryPath.ts
|
|
30472
|
-
import { join as
|
|
30577
|
+
import { join as join74 } from "path";
|
|
30473
30578
|
function devEntryPath(repoName, week, devDir) {
|
|
30474
|
-
return
|
|
30579
|
+
return join74(devDir, repoName, `${week.toLowerCase()}.md`);
|
|
30475
30580
|
}
|
|
30476
30581
|
|
|
30477
30582
|
// src/commands/devlog/loadDevEntry.ts
|
|
@@ -30583,15 +30688,15 @@ function findTargetWeek(weeks, { lastWeek, skip: skip3, today }) {
|
|
|
30583
30688
|
import chalk162 from "chalk";
|
|
30584
30689
|
|
|
30585
30690
|
// src/shared/getRepoName.ts
|
|
30586
|
-
import { existsSync as
|
|
30587
|
-
import { basename as basename19, join as
|
|
30691
|
+
import { existsSync as existsSync63, readFileSync as readFileSync44 } from "fs";
|
|
30692
|
+
import { basename as basename19, join as join75 } from "path";
|
|
30588
30693
|
function getRepoName() {
|
|
30589
30694
|
const config = loadConfig();
|
|
30590
30695
|
if (config.devlog?.name) {
|
|
30591
30696
|
return config.devlog.name;
|
|
30592
30697
|
}
|
|
30593
|
-
const packageJsonPath =
|
|
30594
|
-
if (
|
|
30698
|
+
const packageJsonPath = join75(process.cwd(), "package.json");
|
|
30699
|
+
if (existsSync63(packageJsonPath)) {
|
|
30595
30700
|
try {
|
|
30596
30701
|
const content = readFileSync44(packageJsonPath, "utf8");
|
|
30597
30702
|
const pkg = JSON.parse(content);
|
|
@@ -30669,7 +30774,7 @@ function list2(options2) {
|
|
|
30669
30774
|
|
|
30670
30775
|
// src/commands/devlog/loadDevWeeks.ts
|
|
30671
30776
|
import { readdirSync as readdirSync12 } from "fs";
|
|
30672
|
-
import { join as
|
|
30777
|
+
import { join as join76 } from "path";
|
|
30673
30778
|
var DEV_FILENAME_PATTERN = /^(\d{4})-w(\d{2})\.md$/;
|
|
30674
30779
|
function parseDevWeekFilename(filename) {
|
|
30675
30780
|
const match = filename.match(DEV_FILENAME_PATTERN);
|
|
@@ -30683,7 +30788,7 @@ function readFilenames(dir) {
|
|
|
30683
30788
|
}
|
|
30684
30789
|
}
|
|
30685
30790
|
function loadDevWeeks(repoName, devDir) {
|
|
30686
|
-
return readFilenames(
|
|
30791
|
+
return readFilenames(join76(devDir, repoName)).map(parseDevWeekFilename).filter((week) => week !== null).sort();
|
|
30687
30792
|
}
|
|
30688
30793
|
|
|
30689
30794
|
// src/commands/devlog/next/displayNextEntry.ts
|
|
@@ -30948,14 +31053,14 @@ async function skip2(week, cwd = process.cwd()) {
|
|
|
30948
31053
|
}
|
|
30949
31054
|
|
|
30950
31055
|
// src/commands/devlog/slack/slack.ts
|
|
30951
|
-
import { mkdirSync as
|
|
31056
|
+
import { mkdirSync as mkdirSync23, writeFileSync as writeFileSync36 } from "fs";
|
|
30952
31057
|
import chalk168 from "chalk";
|
|
30953
31058
|
|
|
30954
31059
|
// src/commands/slack/postSlackMessage.ts
|
|
30955
|
-
import { mkdirSync as
|
|
31060
|
+
import { mkdirSync as mkdirSync22, writeFileSync as writeFileSync35 } from "fs";
|
|
30956
31061
|
|
|
30957
31062
|
// src/commands/slack/previewSlackThreadParts.ts
|
|
30958
|
-
import { mkdirSync as
|
|
31063
|
+
import { mkdirSync as mkdirSync21, writeFileSync as writeFileSync34 } from "fs";
|
|
30959
31064
|
|
|
30960
31065
|
// src/commands/slack/readSlackParts.ts
|
|
30961
31066
|
import { readFileSync as readFileSync46 } from "fs";
|
|
@@ -31001,12 +31106,12 @@ async function reviewProposedSlackMessage(target, body, workingPath) {
|
|
|
31001
31106
|
}
|
|
31002
31107
|
|
|
31003
31108
|
// src/commands/slack/slackWorkingFile.ts
|
|
31004
|
-
import { join as
|
|
31109
|
+
import { join as join77 } from "path";
|
|
31005
31110
|
function slackWorkingFile(channel, partIndex) {
|
|
31006
31111
|
const slug2 = channel.replace(/^[#@]/, "").toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "channel";
|
|
31007
|
-
const dir =
|
|
31112
|
+
const dir = join77(getStoreDir(), "slack");
|
|
31008
31113
|
const name2 = partIndex === void 0 ? slug2 : `${slug2}-${partIndex}`;
|
|
31009
|
-
return { dir, bodyPath:
|
|
31114
|
+
return { dir, bodyPath: join77(dir, `${name2}.md`) };
|
|
31010
31115
|
}
|
|
31011
31116
|
|
|
31012
31117
|
// src/commands/slack/previewSlackThreadParts.ts
|
|
@@ -31018,7 +31123,7 @@ async function previewSlackThreadParts({
|
|
|
31018
31123
|
}) {
|
|
31019
31124
|
const bodies = readSlackParts(partFiles);
|
|
31020
31125
|
const { dir } = slackWorkingFile(channel);
|
|
31021
|
-
|
|
31126
|
+
mkdirSync21(dir, { recursive: true });
|
|
31022
31127
|
const paths = bodies.map((body, index3) => {
|
|
31023
31128
|
const { bodyPath } = slackWorkingFile(channel, index3 + 1);
|
|
31024
31129
|
writeFileSync34(bodyPath, `${body}
|
|
@@ -31072,7 +31177,7 @@ async function postSlackMessage(channelArg, options2) {
|
|
|
31072
31177
|
process.exit(1);
|
|
31073
31178
|
}
|
|
31074
31179
|
const { dir, bodyPath } = slackWorkingFile(channel);
|
|
31075
|
-
|
|
31180
|
+
mkdirSync22(dir, { recursive: true });
|
|
31076
31181
|
writeFileSync35(bodyPath, `${body}
|
|
31077
31182
|
`);
|
|
31078
31183
|
await reviewProposedSlackMessage({ channel, threadTs }, body, bodyPath);
|
|
@@ -31212,7 +31317,7 @@ function fail8(message4) {
|
|
|
31212
31317
|
process.exit(1);
|
|
31213
31318
|
}
|
|
31214
31319
|
function writeParts(channel, parts2) {
|
|
31215
|
-
|
|
31320
|
+
mkdirSync23(slackWorkingFile(channel).dir, { recursive: true });
|
|
31216
31321
|
return parts2.map((part, index3) => {
|
|
31217
31322
|
const { bodyPath } = slackWorkingFile(channel, index3 + 1);
|
|
31218
31323
|
writeFileSync36(bodyPath, `${part}
|
|
@@ -31256,7 +31361,7 @@ async function slack2(week) {
|
|
|
31256
31361
|
}
|
|
31257
31362
|
|
|
31258
31363
|
// src/commands/devlog/write.ts
|
|
31259
|
-
import { mkdirSync as
|
|
31364
|
+
import { mkdirSync as mkdirSync24, writeFileSync as writeFileSync37 } from "fs";
|
|
31260
31365
|
import { dirname as dirname34 } from "path";
|
|
31261
31366
|
import chalk169 from "chalk";
|
|
31262
31367
|
|
|
@@ -31351,7 +31456,7 @@ async function write() {
|
|
|
31351
31456
|
const devDir = resolveDevDir();
|
|
31352
31457
|
const repoName = getRepoName();
|
|
31353
31458
|
const path110 = devEntryPath(repoName, result.data.week, devDir);
|
|
31354
|
-
|
|
31459
|
+
mkdirSync24(dirname34(path110), { recursive: true });
|
|
31355
31460
|
writeFileSync37(path110, formatDevEntry(repoName, result.data));
|
|
31356
31461
|
console.log(chalk169.green(`Wrote ${path110}`));
|
|
31357
31462
|
}
|
|
@@ -31548,19 +31653,19 @@ async function findPhaseUnlockItem(itemId2, phase) {
|
|
|
31548
31653
|
}
|
|
31549
31654
|
|
|
31550
31655
|
// src/commands/docs/getDocsUnlockPinPath.ts
|
|
31551
|
-
import { join as
|
|
31656
|
+
import { join as join78 } from "path";
|
|
31552
31657
|
function getDocsUnlockPinPath(pin2) {
|
|
31553
|
-
return
|
|
31658
|
+
return join78(getRestrictedDir(), `docs-unlock-pin-${pin2}.json`);
|
|
31554
31659
|
}
|
|
31555
31660
|
|
|
31556
31661
|
// src/commands/docs/readDocsUnlockPinState.ts
|
|
31557
|
-
import { existsSync as
|
|
31662
|
+
import { existsSync as existsSync64, readFileSync as readFileSync48 } from "fs";
|
|
31558
31663
|
function isPositiveInteger(value) {
|
|
31559
31664
|
return Number.isInteger(value) && value > 0;
|
|
31560
31665
|
}
|
|
31561
31666
|
function readDocsUnlockPinState(pin2) {
|
|
31562
31667
|
const path110 = getDocsUnlockPinPath(pin2);
|
|
31563
|
-
if (!
|
|
31668
|
+
if (!existsSync64(path110)) return void 0;
|
|
31564
31669
|
try {
|
|
31565
31670
|
const state = JSON.parse(readFileSync48(path110, "utf8"));
|
|
31566
31671
|
if (state.pin !== pin2) return void 0;
|
|
@@ -31606,7 +31711,7 @@ import chalk174 from "chalk";
|
|
|
31606
31711
|
|
|
31607
31712
|
// src/commands/notify/issueUnlockPin.ts
|
|
31608
31713
|
import { randomInt as randomInt2 } from "crypto";
|
|
31609
|
-
import { mkdirSync as
|
|
31714
|
+
import { mkdirSync as mkdirSync25, unlinkSync as unlinkSync11, writeFileSync as writeFileSync38 } from "fs";
|
|
31610
31715
|
async function issueUnlockPin({
|
|
31611
31716
|
area,
|
|
31612
31717
|
label,
|
|
@@ -31614,7 +31719,7 @@ async function issueUnlockPin({
|
|
|
31614
31719
|
state
|
|
31615
31720
|
}) {
|
|
31616
31721
|
const pin2 = randomInt2(0, 1e3).toString().padStart(3, "0");
|
|
31617
|
-
|
|
31722
|
+
mkdirSync25(getRestrictedDir(), { recursive: true });
|
|
31618
31723
|
sweepRestrictedDir();
|
|
31619
31724
|
const path110 = pinPath(pin2);
|
|
31620
31725
|
writeFileSync38(path110, JSON.stringify({ ...state, pin: pin2 }));
|
|
@@ -31693,7 +31798,7 @@ import { unlinkSync as unlinkSync12 } from "fs";
|
|
|
31693
31798
|
import chalk176 from "chalk";
|
|
31694
31799
|
|
|
31695
31800
|
// src/commands/schema/approveSchemaUnlock.ts
|
|
31696
|
-
import { mkdirSync as
|
|
31801
|
+
import { mkdirSync as mkdirSync26, writeFileSync as writeFileSync39 } from "fs";
|
|
31697
31802
|
import chalk175 from "chalk";
|
|
31698
31803
|
|
|
31699
31804
|
// src/commands/schema/schemaHarnessLabel.ts
|
|
@@ -31724,7 +31829,7 @@ function approveSession({ harness, conversationId }) {
|
|
|
31724
31829
|
const scope = { harness, conversationId };
|
|
31725
31830
|
const path110 = getSchemaSessionApprovalPath(scope);
|
|
31726
31831
|
if (!path110) return;
|
|
31727
|
-
|
|
31832
|
+
mkdirSync26(getSchemaSessionApprovalDir(), { recursive: true });
|
|
31728
31833
|
writeFileSync39(path110, JSON.stringify(scope));
|
|
31729
31834
|
console.log(
|
|
31730
31835
|
chalk175.green(
|
|
@@ -31738,13 +31843,13 @@ async function approveSchemaUnlock(state) {
|
|
|
31738
31843
|
}
|
|
31739
31844
|
|
|
31740
31845
|
// src/commands/schema/getSchemaUnlockPinPath.ts
|
|
31741
|
-
import { join as
|
|
31846
|
+
import { join as join79 } from "path";
|
|
31742
31847
|
function getSchemaUnlockPinPath(pin2) {
|
|
31743
|
-
return
|
|
31848
|
+
return join79(getRestrictedDir(), `schema-unlock-pin-${pin2}.json`);
|
|
31744
31849
|
}
|
|
31745
31850
|
|
|
31746
31851
|
// src/commands/schema/readSchemaUnlockPinState.ts
|
|
31747
|
-
import { existsSync as
|
|
31852
|
+
import { existsSync as existsSync65, readFileSync as readFileSync49 } from "fs";
|
|
31748
31853
|
function isPositiveInteger2(value) {
|
|
31749
31854
|
return Number.isInteger(value) && value > 0;
|
|
31750
31855
|
}
|
|
@@ -31769,7 +31874,7 @@ function toState(raw) {
|
|
|
31769
31874
|
}
|
|
31770
31875
|
function readSchemaUnlockPinState(pin2) {
|
|
31771
31876
|
const path110 = getSchemaUnlockPinPath(pin2);
|
|
31772
|
-
if (!
|
|
31877
|
+
if (!existsSync65(path110)) return void 0;
|
|
31773
31878
|
try {
|
|
31774
31879
|
const raw = JSON.parse(readFileSync49(path110, "utf8"));
|
|
31775
31880
|
if (raw.pin !== pin2) return void 0;
|
|
@@ -31899,7 +32004,7 @@ function registerSchema(parent) {
|
|
|
31899
32004
|
|
|
31900
32005
|
// src/commands/dotnet/checkBuildLocks.ts
|
|
31901
32006
|
import { closeSync as closeSync6, openSync as openSync7, readdirSync as readdirSync14 } from "fs";
|
|
31902
|
-
import { join as
|
|
32007
|
+
import { join as join80 } from "path";
|
|
31903
32008
|
import chalk179 from "chalk";
|
|
31904
32009
|
var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git", "packages"]);
|
|
31905
32010
|
function isLockedDll(debugDir) {
|
|
@@ -31911,7 +32016,7 @@ function isLockedDll(debugDir) {
|
|
|
31911
32016
|
}
|
|
31912
32017
|
for (const file of files) {
|
|
31913
32018
|
if (!file.toLowerCase().endsWith(".dll")) continue;
|
|
31914
|
-
const dllPath =
|
|
32019
|
+
const dllPath = join80(debugDir, file);
|
|
31915
32020
|
try {
|
|
31916
32021
|
const fd = openSync7(dllPath, "r+");
|
|
31917
32022
|
closeSync6(fd);
|
|
@@ -31929,13 +32034,13 @@ function findFirstLockedDll(dir) {
|
|
|
31929
32034
|
return null;
|
|
31930
32035
|
}
|
|
31931
32036
|
if (entries.includes("bin")) {
|
|
31932
|
-
const locked = isLockedDll(
|
|
32037
|
+
const locked = isLockedDll(join80(dir, "bin", "Debug"));
|
|
31933
32038
|
if (locked) return locked;
|
|
31934
32039
|
}
|
|
31935
32040
|
for (const entry of entries) {
|
|
31936
32041
|
if (SKIP_DIRS.has(entry) || entry === "bin" || entry.startsWith("."))
|
|
31937
32042
|
continue;
|
|
31938
|
-
const found = findFirstLockedDll(
|
|
32043
|
+
const found = findFirstLockedDll(join80(dir, entry));
|
|
31939
32044
|
if (found) return found;
|
|
31940
32045
|
}
|
|
31941
32046
|
return null;
|
|
@@ -32103,12 +32208,12 @@ function printJson(tree, totalCount, solutions) {
|
|
|
32103
32208
|
}
|
|
32104
32209
|
|
|
32105
32210
|
// src/commands/dotnet/resolveCsproj.ts
|
|
32106
|
-
import { existsSync as
|
|
32211
|
+
import { existsSync as existsSync66 } from "fs";
|
|
32107
32212
|
import path42 from "path";
|
|
32108
32213
|
import chalk181 from "chalk";
|
|
32109
32214
|
function resolveCsproj(csprojPath) {
|
|
32110
32215
|
const resolved = path42.resolve(csprojPath);
|
|
32111
|
-
if (!
|
|
32216
|
+
if (!existsSync66(resolved)) {
|
|
32112
32217
|
console.error(chalk181.red(`File not found: ${resolved}`));
|
|
32113
32218
|
process.exit(1);
|
|
32114
32219
|
}
|
|
@@ -32276,17 +32381,17 @@ function filterIssues(issues, all, cliOnly, cliSuppress) {
|
|
|
32276
32381
|
}
|
|
32277
32382
|
|
|
32278
32383
|
// src/commands/dotnet/resolveSolution.ts
|
|
32279
|
-
import { existsSync as
|
|
32384
|
+
import { existsSync as existsSync67 } from "fs";
|
|
32280
32385
|
import path43 from "path";
|
|
32281
32386
|
import chalk185 from "chalk";
|
|
32282
32387
|
|
|
32283
32388
|
// src/commands/dotnet/findSolution.ts
|
|
32284
32389
|
import { readdirSync as readdirSync16 } from "fs";
|
|
32285
|
-
import { dirname as dirname35, join as
|
|
32390
|
+
import { dirname as dirname35, join as join81 } from "path";
|
|
32286
32391
|
import chalk184 from "chalk";
|
|
32287
32392
|
function findSlnInDir(dir) {
|
|
32288
32393
|
try {
|
|
32289
|
-
return readdirSync16(dir).filter((f) => f.endsWith(".sln")).map((f) =>
|
|
32394
|
+
return readdirSync16(dir).filter((f) => f.endsWith(".sln")).map((f) => join81(dir, f));
|
|
32290
32395
|
} catch {
|
|
32291
32396
|
return [];
|
|
32292
32397
|
}
|
|
@@ -32317,7 +32422,7 @@ function findSolution() {
|
|
|
32317
32422
|
function resolveSolution(sln) {
|
|
32318
32423
|
if (sln) {
|
|
32319
32424
|
const resolved = path43.resolve(sln);
|
|
32320
|
-
if (!
|
|
32425
|
+
if (!existsSync67(resolved)) {
|
|
32321
32426
|
console.error(chalk185.red(`Solution file not found: ${resolved}`));
|
|
32322
32427
|
process.exit(1);
|
|
32323
32428
|
}
|
|
@@ -32357,7 +32462,7 @@ function parseInspectReport(json) {
|
|
|
32357
32462
|
|
|
32358
32463
|
// src/commands/dotnet/runInspectCode.ts
|
|
32359
32464
|
import { execSync as execSync40 } from "child_process";
|
|
32360
|
-
import { existsSync as
|
|
32465
|
+
import { existsSync as existsSync68, readFileSync as readFileSync52, unlinkSync as unlinkSync13 } from "fs";
|
|
32361
32466
|
import { tmpdir as tmpdir5 } from "os";
|
|
32362
32467
|
import path44 from "path";
|
|
32363
32468
|
import chalk186 from "chalk";
|
|
@@ -32388,7 +32493,7 @@ function runInspectCode(slnPath, include, swea) {
|
|
|
32388
32493
|
console.error(chalk186.red("jb inspectcode failed"));
|
|
32389
32494
|
process.exit(1);
|
|
32390
32495
|
}
|
|
32391
|
-
if (!
|
|
32496
|
+
if (!existsSync68(reportPath)) {
|
|
32392
32497
|
console.error(chalk186.red("Report file not generated"));
|
|
32393
32498
|
process.exit(1);
|
|
32394
32499
|
}
|
|
@@ -33294,7 +33399,7 @@ function aggregateCommitters(authorLists) {
|
|
|
33294
33399
|
import { spawnSync as spawnSync7 } from "child_process";
|
|
33295
33400
|
import { unlinkSync as unlinkSync14, writeFileSync as writeFileSync40 } from "fs";
|
|
33296
33401
|
import { tmpdir as tmpdir6 } from "os";
|
|
33297
|
-
import { join as
|
|
33402
|
+
import { join as join82 } from "path";
|
|
33298
33403
|
function buildArgs3(queryFile, vars) {
|
|
33299
33404
|
const args = ["api", "graphql", "-F", `query=@${queryFile}`];
|
|
33300
33405
|
for (const [key, value] of Object.entries(vars)) {
|
|
@@ -33304,7 +33409,7 @@ function buildArgs3(queryFile, vars) {
|
|
|
33304
33409
|
return args;
|
|
33305
33410
|
}
|
|
33306
33411
|
function runGhGraphql(mutation, vars) {
|
|
33307
|
-
const queryFile =
|
|
33412
|
+
const queryFile = join82(tmpdir6(), `gh-query-${Date.now()}.graphql`);
|
|
33308
33413
|
writeFileSync40(queryFile, mutation);
|
|
33309
33414
|
try {
|
|
33310
33415
|
const result = spawnSync7("gh", buildArgs3(queryFile, vars), {
|
|
@@ -34743,24 +34848,24 @@ function slugFromUrl(url) {
|
|
|
34743
34848
|
}
|
|
34744
34849
|
|
|
34745
34850
|
// src/commands/github/issue/writeIssueWorkingFile.ts
|
|
34746
|
-
import { mkdirSync as
|
|
34851
|
+
import { mkdirSync as mkdirSync27, writeFileSync as writeFileSync41 } from "fs";
|
|
34747
34852
|
|
|
34748
34853
|
// src/commands/github/issue/issueWorkingFile.ts
|
|
34749
|
-
import { join as
|
|
34854
|
+
import { join as join83 } from "path";
|
|
34750
34855
|
function issueWorkingFile(slug2, number) {
|
|
34751
34856
|
const [owner = "unknown", repo = "unknown"] = slug2.split("/");
|
|
34752
|
-
const dir =
|
|
34857
|
+
const dir = join83(getStoreDir(), "github-issues", owner, repo);
|
|
34753
34858
|
return {
|
|
34754
34859
|
dir,
|
|
34755
|
-
bodyPath:
|
|
34756
|
-
metaPath:
|
|
34860
|
+
bodyPath: join83(dir, `${number}.md`),
|
|
34861
|
+
metaPath: join83(dir, `${number}.json`)
|
|
34757
34862
|
};
|
|
34758
34863
|
}
|
|
34759
34864
|
|
|
34760
34865
|
// src/commands/github/issue/writeIssueWorkingFile.ts
|
|
34761
34866
|
function writeIssueWorkingFile(slug2, number, target, updatedAt, body) {
|
|
34762
34867
|
const { dir, bodyPath, metaPath } = issueWorkingFile(slug2, number);
|
|
34763
|
-
|
|
34868
|
+
mkdirSync27(dir, { recursive: true });
|
|
34764
34869
|
writeFileSync41(bodyPath, body);
|
|
34765
34870
|
writeFileSync41(
|
|
34766
34871
|
metaPath,
|
|
@@ -34788,10 +34893,10 @@ function fetchIssueToWorkingFile(number, repo) {
|
|
|
34788
34893
|
}
|
|
34789
34894
|
|
|
34790
34895
|
// src/commands/github/issue/resumeIssueBody.ts
|
|
34791
|
-
import { existsSync as
|
|
34896
|
+
import { existsSync as existsSync69, readFileSync as readFileSync53 } from "fs";
|
|
34792
34897
|
function resumeIssueBody(slug2, number, updatedAt) {
|
|
34793
34898
|
const { bodyPath, metaPath } = issueWorkingFile(slug2, number);
|
|
34794
|
-
if (!
|
|
34899
|
+
if (!existsSync69(bodyPath) || !existsSync69(metaPath)) return void 0;
|
|
34795
34900
|
try {
|
|
34796
34901
|
const meta = JSON.parse(readFileSync53(metaPath, "utf8"));
|
|
34797
34902
|
if (meta.updatedAt !== updatedAt) return void 0;
|
|
@@ -35935,15 +36040,15 @@ function clearStalePrBranch(cwd, branch2) {
|
|
|
35935
36040
|
}
|
|
35936
36041
|
|
|
35937
36042
|
// src/commands/sessions/daemon/worktree/createWorktree.ts
|
|
35938
|
-
import { existsSync as
|
|
36043
|
+
import { existsSync as existsSync70 } from "fs";
|
|
35939
36044
|
import { basename as basename22, dirname as dirname37 } from "path";
|
|
35940
36045
|
|
|
35941
36046
|
// src/commands/sessions/daemon/worktree/nextWorktreePath.ts
|
|
35942
|
-
import { basename as basename21, join as
|
|
36047
|
+
import { basename as basename21, join as join84 } from "path";
|
|
35943
36048
|
function nextWorktreePath(clone, base, isTaken) {
|
|
35944
36049
|
const name2 = basename21(clone);
|
|
35945
36050
|
for (let n = 2; n < 1e3; n++) {
|
|
35946
|
-
const candidate =
|
|
36051
|
+
const candidate = join84(base, `${name2}-${n}`);
|
|
35947
36052
|
if (!isTaken(candidate)) return candidate;
|
|
35948
36053
|
}
|
|
35949
36054
|
throw new Error(`no free worktree suffix for ${clone}`);
|
|
@@ -35967,7 +36072,7 @@ function createWorktree(clone, strategy, boundTreeRoots2, preferredPath) {
|
|
|
35967
36072
|
const base = strategy.root ? expandTilde(strategy.root) : dirname37(clone);
|
|
35968
36073
|
const registered = new Set(listWorktreePaths(clone));
|
|
35969
36074
|
const branches = new Set(listLocalBranches(clone));
|
|
35970
|
-
const isTaken = (candidate) => registered.has(candidate) ||
|
|
36075
|
+
const isTaken = (candidate) => registered.has(candidate) || existsSync70(candidate) || boundTreeRoots2.has(candidate) || branches.has(basename22(candidate));
|
|
35971
36076
|
const path110 = preferredPath && !isTaken(preferredPath) ? preferredPath : nextWorktreePath(clone, base, isTaken);
|
|
35972
36077
|
const ready = addWorktree(clone, path110, strategy.trunk);
|
|
35973
36078
|
ready.catch(() => {
|
|
@@ -36207,8 +36312,8 @@ function persistedTreeRoots() {
|
|
|
36207
36312
|
}
|
|
36208
36313
|
|
|
36209
36314
|
// src/commands/sessions/daemon/worktree/seedWorktree.ts
|
|
36210
|
-
import { copyFileSync, existsSync as
|
|
36211
|
-
import { dirname as dirname38, join as
|
|
36315
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync72, mkdirSync as mkdirSync28 } from "fs";
|
|
36316
|
+
import { dirname as dirname38, join as join86 } from "path";
|
|
36212
36317
|
|
|
36213
36318
|
// src/commands/sessions/daemon/worktree/installPaths.ts
|
|
36214
36319
|
import { resolve as resolve22 } from "path";
|
|
@@ -36238,14 +36343,14 @@ function pendingPathAction(enclosing, states2, paths, stopped) {
|
|
|
36238
36343
|
}
|
|
36239
36344
|
|
|
36240
36345
|
// src/commands/sessions/daemon/worktree/detectInstallCommand.ts
|
|
36241
|
-
import { existsSync as
|
|
36242
|
-
import { join as
|
|
36346
|
+
import { existsSync as existsSync71 } from "fs";
|
|
36347
|
+
import { join as join85 } from "path";
|
|
36243
36348
|
function detectInstallCommand(dir) {
|
|
36244
|
-
if (!
|
|
36245
|
-
if (
|
|
36246
|
-
if (
|
|
36247
|
-
if (
|
|
36248
|
-
if (
|
|
36349
|
+
if (!existsSync71(join85(dir, "package.json"))) return null;
|
|
36350
|
+
if (existsSync71(join85(dir, "pnpm-lock.yaml"))) return "pnpm install";
|
|
36351
|
+
if (existsSync71(join85(dir, "yarn.lock"))) return "yarn install";
|
|
36352
|
+
if (existsSync71(join85(dir, "bun.lockb"))) return "bun install";
|
|
36353
|
+
if (existsSync71(join85(dir, "package-lock.json"))) return "npm ci";
|
|
36249
36354
|
return "npm install";
|
|
36250
36355
|
}
|
|
36251
36356
|
|
|
@@ -36437,12 +36542,12 @@ function seedWorktree(worktreePath, clone, onSeeded = () => {
|
|
|
36437
36542
|
}
|
|
36438
36543
|
function copyConfigFiles(worktreePath, clone, copy) {
|
|
36439
36544
|
for (const rel of copy) {
|
|
36440
|
-
const src =
|
|
36441
|
-
if (!
|
|
36442
|
-
const dest =
|
|
36545
|
+
const src = join86(clone, rel);
|
|
36546
|
+
if (!existsSync72(src)) continue;
|
|
36547
|
+
const dest = join86(worktreePath, rel);
|
|
36443
36548
|
try {
|
|
36444
|
-
|
|
36445
|
-
|
|
36549
|
+
mkdirSync28(dirname38(dest), { recursive: true });
|
|
36550
|
+
copyFileSync2(src, dest);
|
|
36446
36551
|
daemonLog(`worktree ${worktreePath} seeded ${rel}`);
|
|
36447
36552
|
} catch (error) {
|
|
36448
36553
|
daemonLog(
|
|
@@ -36928,7 +37033,7 @@ function registerLitellm(program) {
|
|
|
36928
37033
|
}
|
|
36929
37034
|
|
|
36930
37035
|
// src/commands/mermaidExport.ts
|
|
36931
|
-
import { mkdirSync as
|
|
37036
|
+
import { mkdirSync as mkdirSync29, readdirSync as readdirSync17 } from "fs";
|
|
36932
37037
|
import { resolve as resolve24 } from "path";
|
|
36933
37038
|
import chalk204 from "chalk";
|
|
36934
37039
|
|
|
@@ -36997,7 +37102,7 @@ function extractMermaidBlocks(markdown) {
|
|
|
36997
37102
|
async function mermaidExport(file, options2 = {}) {
|
|
36998
37103
|
const { mermaid } = loadConfig();
|
|
36999
37104
|
const outDir = resolve24(process.cwd(), options2.out ?? ".");
|
|
37000
|
-
|
|
37105
|
+
mkdirSync29(outDir, { recursive: true });
|
|
37001
37106
|
if (options2.index !== void 0) {
|
|
37002
37107
|
if (!Number.isInteger(options2.index) || options2.index < 1) {
|
|
37003
37108
|
console.error(
|
|
@@ -37092,7 +37197,7 @@ function boardSource(raw, anchorId, options2) {
|
|
|
37092
37197
|
import { stringify as stringify2 } from "yaml";
|
|
37093
37198
|
|
|
37094
37199
|
// src/commands/miro/writeExtract.ts
|
|
37095
|
-
import { mkdirSync as
|
|
37200
|
+
import { mkdirSync as mkdirSync30, writeFileSync as writeFileSync43 } from "fs";
|
|
37096
37201
|
import { dirname as dirname39 } from "path";
|
|
37097
37202
|
import { stringify } from "yaml";
|
|
37098
37203
|
function headerLines(header) {
|
|
@@ -37106,7 +37211,7 @@ function headerLines(header) {
|
|
|
37106
37211
|
];
|
|
37107
37212
|
}
|
|
37108
37213
|
function writeExtract(file, header, texts) {
|
|
37109
|
-
|
|
37214
|
+
mkdirSync30(dirname39(file), { recursive: true });
|
|
37110
37215
|
writeFileSync43(file, `${headerLines(header).join("\n")}
|
|
37111
37216
|
${stringify(texts)}`);
|
|
37112
37217
|
}
|
|
@@ -37171,10 +37276,10 @@ function applyIgnore(texts, ignore3) {
|
|
|
37171
37276
|
}
|
|
37172
37277
|
|
|
37173
37278
|
// src/commands/miro/readIgnoreList.ts
|
|
37174
|
-
import { existsSync as
|
|
37279
|
+
import { existsSync as existsSync73, readFileSync as readFileSync55 } from "fs";
|
|
37175
37280
|
import { parse as parse2 } from "yaml";
|
|
37176
37281
|
function readIgnoreList(file) {
|
|
37177
|
-
if (!
|
|
37282
|
+
if (!existsSync73(file))
|
|
37178
37283
|
throw new MiroExtractError(
|
|
37179
37284
|
`No ignore file at ${file}. Write a YAML list of the box texts to drop, or omit --ignore.`
|
|
37180
37285
|
);
|
|
@@ -37659,15 +37764,15 @@ function createNetcapHandler(options2) {
|
|
|
37659
37764
|
// src/commands/netcap/prepareExtensionForLoad.ts
|
|
37660
37765
|
import { cp as cp4, readFile as readFile7, writeFile as writeFile6 } from "fs/promises";
|
|
37661
37766
|
import { networkInterfaces } from "os";
|
|
37662
|
-
import { join as
|
|
37767
|
+
import { join as join88 } from "path";
|
|
37663
37768
|
import chalk207 from "chalk";
|
|
37664
37769
|
|
|
37665
37770
|
// src/commands/netcap/netcapExtensionDir.ts
|
|
37666
|
-
import { dirname as dirname40, join as
|
|
37771
|
+
import { dirname as dirname40, join as join87 } from "path";
|
|
37667
37772
|
import { fileURLToPath as fileURLToPath8 } from "url";
|
|
37668
37773
|
var moduleDir2 = dirname40(fileURLToPath8(import.meta.url));
|
|
37669
37774
|
function netcapExtensionDir() {
|
|
37670
|
-
return
|
|
37775
|
+
return join87(moduleDir2, "commands", "netcap", "netcap-extension");
|
|
37671
37776
|
}
|
|
37672
37777
|
|
|
37673
37778
|
// src/commands/netcap/prepareExtensionForLoad.ts
|
|
@@ -37682,7 +37787,7 @@ function lanIPv4() {
|
|
|
37682
37787
|
return void 0;
|
|
37683
37788
|
}
|
|
37684
37789
|
async function configureBackground(dir, host, port, filter) {
|
|
37685
|
-
const file =
|
|
37790
|
+
const file = join88(dir, "background.js");
|
|
37686
37791
|
const source = await readFile7(file, "utf8");
|
|
37687
37792
|
await writeFile6(
|
|
37688
37793
|
file,
|
|
@@ -37722,20 +37827,20 @@ async function prepareExtensionForLoad(port, filter = "") {
|
|
|
37722
37827
|
}
|
|
37723
37828
|
|
|
37724
37829
|
// src/commands/netcap/resolveNetcapOutPath.ts
|
|
37725
|
-
import { isAbsolute as isAbsolute6, join as
|
|
37830
|
+
import { isAbsolute as isAbsolute6, join as join90, resolve as resolve26 } from "path";
|
|
37726
37831
|
|
|
37727
37832
|
// src/commands/netcap/defaultCapturePath.ts
|
|
37728
37833
|
import { homedir as homedir25 } from "os";
|
|
37729
|
-
import { join as
|
|
37834
|
+
import { join as join89 } from "path";
|
|
37730
37835
|
function defaultCapturePath() {
|
|
37731
|
-
return
|
|
37836
|
+
return join89(homedir25(), ".assist", "netcap", "capture.jsonl");
|
|
37732
37837
|
}
|
|
37733
37838
|
|
|
37734
37839
|
// src/commands/netcap/resolveNetcapOutPath.ts
|
|
37735
37840
|
function resolveNetcapOutPath(out) {
|
|
37736
37841
|
if (!out) return defaultCapturePath();
|
|
37737
37842
|
const dir = isAbsolute6(out) ? out : resolve26(process.cwd(), out);
|
|
37738
|
-
return
|
|
37843
|
+
return join90(dir, "capture.jsonl");
|
|
37739
37844
|
}
|
|
37740
37845
|
|
|
37741
37846
|
// src/commands/netcap/netcap.ts
|
|
@@ -37782,7 +37887,7 @@ netcap stopped \u2014 captured ${count10} ${count10 === 1 ? "entry" : "entries"}
|
|
|
37782
37887
|
|
|
37783
37888
|
// src/commands/netcap/netcapExtract.ts
|
|
37784
37889
|
import { writeFileSync as writeFileSync44 } from "fs";
|
|
37785
|
-
import { join as
|
|
37890
|
+
import { join as join91 } from "path";
|
|
37786
37891
|
import chalk209 from "chalk";
|
|
37787
37892
|
|
|
37788
37893
|
// src/commands/netcap/extractPostsFromCapture.ts
|
|
@@ -38227,7 +38332,7 @@ function extractPostsFromCapture(captureFile) {
|
|
|
38227
38332
|
function netcapExtract(file) {
|
|
38228
38333
|
const captureFile = file ?? defaultCapturePath();
|
|
38229
38334
|
const posts = extractPostsFromCapture(captureFile);
|
|
38230
|
-
const outFile =
|
|
38335
|
+
const outFile = join91(captureFile, "..", "posts.json");
|
|
38231
38336
|
writeFileSync44(outFile, `${JSON.stringify(posts, null, 2)}
|
|
38232
38337
|
`);
|
|
38233
38338
|
console.log(
|
|
@@ -38623,9 +38728,9 @@ async function comment2(path110, line, body, options2 = {}) {
|
|
|
38623
38728
|
|
|
38624
38729
|
// src/commands/prs/commentsCachePath.ts
|
|
38625
38730
|
import { homedir as homedir26 } from "os";
|
|
38626
|
-
import { join as
|
|
38731
|
+
import { join as join92 } from "path";
|
|
38627
38732
|
function commentsCachePath(org, repo, prNumber) {
|
|
38628
|
-
return
|
|
38733
|
+
return join92(
|
|
38629
38734
|
homedir26(),
|
|
38630
38735
|
".assist",
|
|
38631
38736
|
"pr-comments",
|
|
@@ -38636,16 +38741,16 @@ function commentsCachePath(org, repo, prNumber) {
|
|
|
38636
38741
|
}
|
|
38637
38742
|
|
|
38638
38743
|
// src/commands/prs/listComments/updateCommentsCache.ts
|
|
38639
|
-
import { mkdirSync as
|
|
38744
|
+
import { mkdirSync as mkdirSync31, writeFileSync as writeFileSync45 } from "fs";
|
|
38640
38745
|
import { dirname as dirname42 } from "path";
|
|
38641
38746
|
import { stringify as stringify3 } from "yaml";
|
|
38642
38747
|
|
|
38643
38748
|
// src/commands/prs/loadCommentsCache.ts
|
|
38644
|
-
import { existsSync as
|
|
38749
|
+
import { existsSync as existsSync74, readFileSync as readFileSync58, unlinkSync as unlinkSync15 } from "fs";
|
|
38645
38750
|
import { parse as parse3 } from "yaml";
|
|
38646
38751
|
function loadCommentsCache(org, repo, prNumber) {
|
|
38647
38752
|
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
38648
|
-
if (!
|
|
38753
|
+
if (!existsSync74(cachePath)) {
|
|
38649
38754
|
return null;
|
|
38650
38755
|
}
|
|
38651
38756
|
const content = readFileSync58(cachePath, "utf8");
|
|
@@ -38653,7 +38758,7 @@ function loadCommentsCache(org, repo, prNumber) {
|
|
|
38653
38758
|
}
|
|
38654
38759
|
function deleteCommentsCache(org, repo, prNumber) {
|
|
38655
38760
|
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
38656
|
-
if (
|
|
38761
|
+
if (existsSync74(cachePath)) {
|
|
38657
38762
|
unlinkSync15(cachePath);
|
|
38658
38763
|
console.log("No more unresolved line comments. Cache dropped.");
|
|
38659
38764
|
}
|
|
@@ -38661,10 +38766,10 @@ function deleteCommentsCache(org, repo, prNumber) {
|
|
|
38661
38766
|
|
|
38662
38767
|
// src/commands/prs/removeStaleCommentsCaches.ts
|
|
38663
38768
|
import { readdirSync as readdirSync18, unlinkSync as unlinkSync16 } from "fs";
|
|
38664
|
-
import { join as
|
|
38769
|
+
import { join as join93 } from "path";
|
|
38665
38770
|
var STALE_PATTERN = /^pr-\d+-comments\.yaml$/;
|
|
38666
38771
|
function removeStaleCommentsCaches(cwd = process.cwd()) {
|
|
38667
|
-
const dir =
|
|
38772
|
+
const dir = join93(cwd, ".assist");
|
|
38668
38773
|
let entries;
|
|
38669
38774
|
try {
|
|
38670
38775
|
entries = readdirSync18(dir);
|
|
@@ -38672,14 +38777,14 @@ function removeStaleCommentsCaches(cwd = process.cwd()) {
|
|
|
38672
38777
|
return;
|
|
38673
38778
|
}
|
|
38674
38779
|
for (const entry of entries.filter((e) => STALE_PATTERN.test(e))) {
|
|
38675
|
-
unlinkSync16(
|
|
38780
|
+
unlinkSync16(join93(dir, entry));
|
|
38676
38781
|
}
|
|
38677
38782
|
}
|
|
38678
38783
|
|
|
38679
38784
|
// src/commands/prs/listComments/updateCommentsCache.ts
|
|
38680
38785
|
function writeCommentsCache(org, repo, prNumber, comments3) {
|
|
38681
38786
|
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
38682
|
-
|
|
38787
|
+
mkdirSync31(dirname42(cachePath), { recursive: true });
|
|
38683
38788
|
const cacheData = {
|
|
38684
38789
|
prNumber,
|
|
38685
38790
|
fetchedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -38790,7 +38895,7 @@ function failAzureDevops(error) {
|
|
|
38790
38895
|
import { execFileSync as execFileSync20 } from "child_process";
|
|
38791
38896
|
import { mkdtempSync as mkdtempSync2, rmSync as rmSync6, writeFileSync as writeFileSync46 } from "fs";
|
|
38792
38897
|
import { tmpdir as tmpdir7 } from "os";
|
|
38793
|
-
import { join as
|
|
38898
|
+
import { join as join94 } from "path";
|
|
38794
38899
|
function azDevopsInvokeArgs(request, inFile) {
|
|
38795
38900
|
return [
|
|
38796
38901
|
"devops",
|
|
@@ -38825,8 +38930,8 @@ function runAz2(args) {
|
|
|
38825
38930
|
}
|
|
38826
38931
|
function invokeAzDevops(request) {
|
|
38827
38932
|
if (request.body === void 0) return runAz2(azDevopsInvokeArgs(request));
|
|
38828
|
-
const dir = mkdtempSync2(
|
|
38829
|
-
const inFile =
|
|
38933
|
+
const dir = mkdtempSync2(join94(tmpdir7(), "assist-az-"));
|
|
38934
|
+
const inFile = join94(dir, "body.json");
|
|
38830
38935
|
try {
|
|
38831
38936
|
writeFileSync46(inFile, JSON.stringify(request.body));
|
|
38832
38937
|
return runAz2(azDevopsInvokeArgs(request, inFile));
|
|
@@ -41958,9 +42063,9 @@ async function notify() {
|
|
|
41958
42063
|
|
|
41959
42064
|
// src/commands/screenshot.ts
|
|
41960
42065
|
import { execSync as execSync54 } from "child_process";
|
|
41961
|
-
import { existsSync as
|
|
42066
|
+
import { existsSync as existsSync75, mkdirSync as mkdirSync32, unlinkSync as unlinkSync17, writeFileSync as writeFileSync47 } from "fs";
|
|
41962
42067
|
import { tmpdir as tmpdir8 } from "os";
|
|
41963
|
-
import { join as
|
|
42068
|
+
import { join as join95, resolve as resolve28 } from "path";
|
|
41964
42069
|
import chalk236 from "chalk";
|
|
41965
42070
|
|
|
41966
42071
|
// src/commands/screenshot/captureWindowPs1.ts
|
|
@@ -42090,14 +42195,14 @@ Write-Output $OutputPath
|
|
|
42090
42195
|
|
|
42091
42196
|
// src/commands/screenshot.ts
|
|
42092
42197
|
function buildOutputPath(outputDir, processName) {
|
|
42093
|
-
if (!
|
|
42094
|
-
|
|
42198
|
+
if (!existsSync75(outputDir)) {
|
|
42199
|
+
mkdirSync32(outputDir, { recursive: true });
|
|
42095
42200
|
}
|
|
42096
42201
|
const timestamp9 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
42097
42202
|
return resolve28(outputDir, `${processName}-${timestamp9}.png`);
|
|
42098
42203
|
}
|
|
42099
42204
|
function runPowerShellScript(processName, outputPath) {
|
|
42100
|
-
const scriptPath =
|
|
42205
|
+
const scriptPath = join95(tmpdir8(), `assist-screenshot-${Date.now()}.ps1`);
|
|
42101
42206
|
writeFileSync47(scriptPath, captureWindowPs1, "utf8");
|
|
42102
42207
|
try {
|
|
42103
42208
|
execSync54(
|
|
@@ -42199,9 +42304,9 @@ function buildLimitsSegment(rateLimits) {
|
|
|
42199
42304
|
|
|
42200
42305
|
// src/commands/readGitBranch.ts
|
|
42201
42306
|
import { readFileSync as readFileSync61, statSync as statSync12 } from "fs";
|
|
42202
|
-
import { isAbsolute as isAbsolute7, join as
|
|
42307
|
+
import { isAbsolute as isAbsolute7, join as join96, resolve as resolve29 } from "path";
|
|
42203
42308
|
function resolveGitDir(cwd) {
|
|
42204
|
-
const dotGit =
|
|
42309
|
+
const dotGit = join96(cwd, ".git");
|
|
42205
42310
|
let stat5;
|
|
42206
42311
|
try {
|
|
42207
42312
|
stat5 = statSync12(dotGit);
|
|
@@ -42231,7 +42336,7 @@ function readGitBranch(cwd) {
|
|
|
42231
42336
|
}
|
|
42232
42337
|
let head;
|
|
42233
42338
|
try {
|
|
42234
|
-
head = readFileSync61(
|
|
42339
|
+
head = readFileSync61(join96(gitDir, "HEAD"), "utf8");
|
|
42235
42340
|
} catch {
|
|
42236
42341
|
return null;
|
|
42237
42342
|
}
|
|
@@ -45406,12 +45511,12 @@ function formatSlicingRequest(hunks) {
|
|
|
45406
45511
|
}
|
|
45407
45512
|
|
|
45408
45513
|
// src/commands/review/highLevel/highLevelReviewPath.ts
|
|
45409
|
-
import { join as
|
|
45514
|
+
import { join as join97 } from "path";
|
|
45410
45515
|
function slug(value) {
|
|
45411
45516
|
return value.replace(/[^\w.-]+/g, "-");
|
|
45412
45517
|
}
|
|
45413
45518
|
function highLevelReviewPath(repo, headRef, headSha) {
|
|
45414
|
-
return
|
|
45519
|
+
return join97(
|
|
45415
45520
|
getStoreDir(),
|
|
45416
45521
|
"high-level-reviews",
|
|
45417
45522
|
slug(repo),
|
|
@@ -45463,9 +45568,9 @@ function listHighLevelHunks(files) {
|
|
|
45463
45568
|
}
|
|
45464
45569
|
|
|
45465
45570
|
// src/commands/review/highLevel/readJsonFile.ts
|
|
45466
|
-
import { existsSync as
|
|
45571
|
+
import { existsSync as existsSync76, readFileSync as readFileSync62 } from "fs";
|
|
45467
45572
|
function readJsonFile(path110) {
|
|
45468
|
-
if (!
|
|
45573
|
+
if (!existsSync76(path110)) return void 0;
|
|
45469
45574
|
try {
|
|
45470
45575
|
return JSON.parse(readFileSync62(path110, "utf8"));
|
|
45471
45576
|
} catch {
|
|
@@ -45546,10 +45651,10 @@ function resolveHighLevelSlices(raw, hunks) {
|
|
|
45546
45651
|
}
|
|
45547
45652
|
|
|
45548
45653
|
// src/commands/review/highLevel/writeJsonFile.ts
|
|
45549
|
-
import { mkdirSync as
|
|
45654
|
+
import { mkdirSync as mkdirSync33, writeFileSync as writeFileSync48 } from "fs";
|
|
45550
45655
|
import { dirname as dirname45 } from "path";
|
|
45551
45656
|
function writeJsonFile(path110, data) {
|
|
45552
|
-
|
|
45657
|
+
mkdirSync33(dirname45(path110), { recursive: true });
|
|
45553
45658
|
writeFileSync48(path110, `${JSON.stringify(data, null, 2)}
|
|
45554
45659
|
`);
|
|
45555
45660
|
return path110;
|
|
@@ -46573,8 +46678,8 @@ function renderEntry(entry, frame) {
|
|
|
46573
46678
|
import { format } from "util";
|
|
46574
46679
|
|
|
46575
46680
|
// src/commands/review/createReviewLogSink.ts
|
|
46576
|
-
import { appendFileSync as appendFileSync3, mkdirSync as
|
|
46577
|
-
import { join as
|
|
46681
|
+
import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync34 } from "fs";
|
|
46682
|
+
import { join as join98 } from "path";
|
|
46578
46683
|
var LOG_FILE = "review.log";
|
|
46579
46684
|
function createReviewLogSink() {
|
|
46580
46685
|
let logPath2;
|
|
@@ -46590,8 +46695,8 @@ function createReviewLogSink() {
|
|
|
46590
46695
|
`);
|
|
46591
46696
|
},
|
|
46592
46697
|
attach(reviewDir) {
|
|
46593
|
-
|
|
46594
|
-
logPath2 =
|
|
46698
|
+
mkdirSync34(reviewDir, { recursive: true });
|
|
46699
|
+
logPath2 = join98(reviewDir, LOG_FILE);
|
|
46595
46700
|
const lines = [
|
|
46596
46701
|
"",
|
|
46597
46702
|
`=== ${(/* @__PURE__ */ new Date()).toISOString()} ===`,
|
|
@@ -46930,7 +47035,7 @@ async function runReviewers(reviewers, context) {
|
|
|
46930
47035
|
}
|
|
46931
47036
|
|
|
46932
47037
|
// src/commands/review/synthesiseAfterReviewers.ts
|
|
46933
|
-
import { existsSync as
|
|
47038
|
+
import { existsSync as existsSync77, unlinkSync as unlinkSync18 } from "fs";
|
|
46934
47039
|
|
|
46935
47040
|
// src/commands/review/synthesise.ts
|
|
46936
47041
|
import { readFileSync as readFileSync64 } from "fs";
|
|
@@ -47164,7 +47269,7 @@ async function synthesise(paths, options2) {
|
|
|
47164
47269
|
// src/commands/review/synthesiseAfterReviewers.ts
|
|
47165
47270
|
async function synthesiseAfterReviewers(input) {
|
|
47166
47271
|
const { paths, failures } = input;
|
|
47167
|
-
if (input.anyFresh &&
|
|
47272
|
+
if (input.anyFresh && existsSync77(paths.synthesisPath)) {
|
|
47168
47273
|
unlinkSync18(paths.synthesisPath);
|
|
47169
47274
|
}
|
|
47170
47275
|
const synthesisResult = await synthesise(paths, { multi: input.multi });
|
|
@@ -47378,9 +47483,9 @@ ${annotateDiffWithLineNumbers(context.diff.trimEnd())}
|
|
|
47378
47483
|
|
|
47379
47484
|
// src/commands/review/buildReviewPaths.ts
|
|
47380
47485
|
import { homedir as homedir27 } from "os";
|
|
47381
|
-
import { basename as basename27, join as
|
|
47486
|
+
import { basename as basename27, join as join99 } from "path";
|
|
47382
47487
|
function buildReviewPaths(repoRoot2, key) {
|
|
47383
|
-
const reviewDir =
|
|
47488
|
+
const reviewDir = join99(
|
|
47384
47489
|
homedir27(),
|
|
47385
47490
|
".assist",
|
|
47386
47491
|
"reviews",
|
|
@@ -47389,10 +47494,10 @@ function buildReviewPaths(repoRoot2, key) {
|
|
|
47389
47494
|
);
|
|
47390
47495
|
return {
|
|
47391
47496
|
reviewDir,
|
|
47392
|
-
requestPath:
|
|
47393
|
-
claudePath:
|
|
47394
|
-
codexPath:
|
|
47395
|
-
synthesisPath:
|
|
47497
|
+
requestPath: join99(reviewDir, "request.md"),
|
|
47498
|
+
claudePath: join99(reviewDir, "claude.md"),
|
|
47499
|
+
codexPath: join99(reviewDir, "codex.md"),
|
|
47500
|
+
synthesisPath: join99(reviewDir, "synthesis.md")
|
|
47396
47501
|
};
|
|
47397
47502
|
}
|
|
47398
47503
|
|
|
@@ -47430,14 +47535,14 @@ function fetchExistingComments() {
|
|
|
47430
47535
|
}
|
|
47431
47536
|
|
|
47432
47537
|
// src/commands/review/prepareReviewDir.ts
|
|
47433
|
-
import { existsSync as
|
|
47538
|
+
import { existsSync as existsSync78, mkdirSync as mkdirSync35, unlinkSync as unlinkSync19, writeFileSync as writeFileSync49 } from "fs";
|
|
47434
47539
|
function clearReviewFiles(paths) {
|
|
47435
47540
|
for (const path110 of [paths.claudePath, paths.codexPath, paths.synthesisPath]) {
|
|
47436
|
-
if (
|
|
47541
|
+
if (existsSync78(path110)) unlinkSync19(path110);
|
|
47437
47542
|
}
|
|
47438
47543
|
}
|
|
47439
47544
|
function prepareReviewDir(paths, requestBody, force) {
|
|
47440
|
-
|
|
47545
|
+
mkdirSync35(paths.reviewDir, { recursive: true });
|
|
47441
47546
|
if (force) clearReviewFiles(paths);
|
|
47442
47547
|
writeFileSync49(paths.requestPath, requestBody);
|
|
47443
47548
|
}
|
|
@@ -48335,7 +48440,7 @@ import path92 from "path";
|
|
|
48335
48440
|
import chalk273 from "chalk";
|
|
48336
48441
|
|
|
48337
48442
|
// src/commands/rules/updateScopedRulesIndex.ts
|
|
48338
|
-
import { existsSync as
|
|
48443
|
+
import { existsSync as existsSync79, readFileSync as readFileSync67, writeFileSync as writeFileSync50 } from "fs";
|
|
48339
48444
|
import path91 from "path";
|
|
48340
48445
|
|
|
48341
48446
|
// src/commands/rules/scopedRuleDirectories.ts
|
|
@@ -48405,7 +48510,7 @@ function upsertScopedRulesPointer(content, directories) {
|
|
|
48405
48510
|
function updateScopedRulesIndex(root2) {
|
|
48406
48511
|
const directories = scopedRuleDirectories(root2);
|
|
48407
48512
|
const rootFile = path91.join(root2, "CLAUDE.md");
|
|
48408
|
-
const before =
|
|
48513
|
+
const before = existsSync79(rootFile) ? readFileSync67(rootFile, "utf8") : "";
|
|
48409
48514
|
const after = upsertScopedRulesPointer(before, directories);
|
|
48410
48515
|
if (after !== before) writeFileSync50(rootFile, after);
|
|
48411
48516
|
return directories;
|
|
@@ -48458,7 +48563,7 @@ function listRules(target, options2 = {}) {
|
|
|
48458
48563
|
}
|
|
48459
48564
|
|
|
48460
48565
|
// src/commands/rules/addRule.ts
|
|
48461
|
-
import { existsSync as
|
|
48566
|
+
import { existsSync as existsSync81, readFileSync as readFileSync69, writeFileSync as writeFileSync51 } from "fs";
|
|
48462
48567
|
import path95 from "path";
|
|
48463
48568
|
import chalk275 from "chalk";
|
|
48464
48569
|
|
|
@@ -48495,7 +48600,7 @@ function nextRuleCode(root2) {
|
|
|
48495
48600
|
}
|
|
48496
48601
|
|
|
48497
48602
|
// src/commands/rules/resolveRuleScope.ts
|
|
48498
|
-
import { existsSync as
|
|
48603
|
+
import { existsSync as existsSync80 } from "fs";
|
|
48499
48604
|
import path94 from "path";
|
|
48500
48605
|
function resolveRuleScope(target) {
|
|
48501
48606
|
const resolved = path94.resolve(target);
|
|
@@ -48505,7 +48610,7 @@ function resolveRuleScope(target) {
|
|
|
48505
48610
|
let current2 = startDir;
|
|
48506
48611
|
while (true) {
|
|
48507
48612
|
const candidate = path94.join(current2, "CLAUDE.md");
|
|
48508
|
-
if (
|
|
48613
|
+
if (existsSync80(candidate)) return candidate;
|
|
48509
48614
|
if (current2 === root2 || current2 === path94.dirname(current2)) break;
|
|
48510
48615
|
current2 = path94.dirname(current2);
|
|
48511
48616
|
}
|
|
@@ -48514,7 +48619,7 @@ function resolveRuleScope(target) {
|
|
|
48514
48619
|
|
|
48515
48620
|
// src/commands/rules/addRule.ts
|
|
48516
48621
|
function read3(file) {
|
|
48517
|
-
return
|
|
48622
|
+
return existsSync81(file) ? readFileSync69(file, "utf8") : "";
|
|
48518
48623
|
}
|
|
48519
48624
|
function addRule(text19, options2) {
|
|
48520
48625
|
const rule = text19.trim();
|
|
@@ -49949,7 +50054,7 @@ function registerTestflight(program) {
|
|
|
49949
50054
|
}
|
|
49950
50055
|
|
|
49951
50056
|
// src/commands/transcript/clean.ts
|
|
49952
|
-
import { existsSync as
|
|
50057
|
+
import { existsSync as existsSync86 } from "fs";
|
|
49953
50058
|
|
|
49954
50059
|
// src/commands/transcript/convert/formatTimestamp.ts
|
|
49955
50060
|
function pad2(value, width2) {
|
|
@@ -50227,7 +50332,7 @@ function clean(file, options2 = {}) {
|
|
|
50227
50332
|
);
|
|
50228
50333
|
process.exit(1);
|
|
50229
50334
|
}
|
|
50230
|
-
if (!
|
|
50335
|
+
if (!existsSync86(file)) {
|
|
50231
50336
|
console.error(`Error: VTT file not found: ${file}`);
|
|
50232
50337
|
process.exit(1);
|
|
50233
50338
|
}
|
|
@@ -50310,21 +50415,21 @@ async function configure() {
|
|
|
50310
50415
|
}
|
|
50311
50416
|
|
|
50312
50417
|
// src/commands/transcript/list.ts
|
|
50313
|
-
import { existsSync as
|
|
50314
|
-
import { join as
|
|
50418
|
+
import { existsSync as existsSync87, readdirSync as readdirSync26, statSync as statSync14 } from "fs";
|
|
50419
|
+
import { join as join111 } from "path";
|
|
50315
50420
|
function list5() {
|
|
50316
50421
|
const { vttDir } = getTranscriptConfig();
|
|
50317
|
-
if (!
|
|
50422
|
+
if (!existsSync87(vttDir)) return;
|
|
50318
50423
|
for (const entry of readdirSync26(vttDir)) {
|
|
50319
50424
|
if (!entry.endsWith(".vtt")) continue;
|
|
50320
|
-
if (statSync14(
|
|
50425
|
+
if (statSync14(join111(vttDir, entry)).isDirectory()) continue;
|
|
50321
50426
|
console.log(entry);
|
|
50322
50427
|
}
|
|
50323
50428
|
}
|
|
50324
50429
|
|
|
50325
50430
|
// src/commands/transcript/move.ts
|
|
50326
|
-
import { existsSync as
|
|
50327
|
-
import { basename as basename31, join as
|
|
50431
|
+
import { existsSync as existsSync88, mkdirSync as mkdirSync41, renameSync as renameSync5, writeFileSync as writeFileSync56 } from "fs";
|
|
50432
|
+
import { basename as basename31, join as join112 } from "path";
|
|
50328
50433
|
|
|
50329
50434
|
// src/commands/transcript/convertVttToMarkdown.ts
|
|
50330
50435
|
function convertVttToMarkdown(inputPath) {
|
|
@@ -50334,9 +50439,9 @@ function convertVttToMarkdown(inputPath) {
|
|
|
50334
50439
|
// src/commands/transcript/move.ts
|
|
50335
50440
|
var DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
|
|
50336
50441
|
function archiveRawVtt(vttDir, sourcePath, filename) {
|
|
50337
|
-
const processedDir =
|
|
50338
|
-
|
|
50339
|
-
renameSync5(sourcePath,
|
|
50442
|
+
const processedDir = join112(vttDir, "processed");
|
|
50443
|
+
mkdirSync41(processedDir, { recursive: true });
|
|
50444
|
+
renameSync5(sourcePath, join112(processedDir, filename));
|
|
50340
50445
|
}
|
|
50341
50446
|
function move(file, options2) {
|
|
50342
50447
|
const { date, client } = options2;
|
|
@@ -50346,25 +50451,25 @@ function move(file, options2) {
|
|
|
50346
50451
|
}
|
|
50347
50452
|
const { vttDir, transcriptsDir, summaryDir } = getTranscriptConfig();
|
|
50348
50453
|
const filename = basename31(file);
|
|
50349
|
-
const sourcePath =
|
|
50350
|
-
if (!
|
|
50454
|
+
const sourcePath = join112(vttDir, filename);
|
|
50455
|
+
if (!existsSync88(sourcePath)) {
|
|
50351
50456
|
console.error(`Error: VTT file not found: ${sourcePath}`);
|
|
50352
50457
|
process.exit(1);
|
|
50353
50458
|
}
|
|
50354
50459
|
const base = basename31(filename, ".vtt").replace(/ Transcription$/, "");
|
|
50355
50460
|
const outputName = `${date} ${base}.md`;
|
|
50356
|
-
const formattedDir =
|
|
50357
|
-
|
|
50358
|
-
const formattedPath =
|
|
50461
|
+
const formattedDir = join112(transcriptsDir, client);
|
|
50462
|
+
mkdirSync41(formattedDir, { recursive: true });
|
|
50463
|
+
const formattedPath = join112(formattedDir, outputName);
|
|
50359
50464
|
writeFileSync56(formattedPath, convertVttToMarkdown(sourcePath), "utf8");
|
|
50360
50465
|
archiveRawVtt(vttDir, sourcePath, filename);
|
|
50361
|
-
const summaryPath =
|
|
50466
|
+
const summaryPath = join112(summaryDir, client, outputName);
|
|
50362
50467
|
console.log(`Formatted transcript: ${formattedPath}`);
|
|
50363
50468
|
console.log(`Summary target: ${summaryPath}`);
|
|
50364
50469
|
}
|
|
50365
50470
|
|
|
50366
50471
|
// src/commands/transcript/merge.ts
|
|
50367
|
-
import { existsSync as
|
|
50472
|
+
import { existsSync as existsSync89, writeFileSync as writeFileSync57 } from "fs";
|
|
50368
50473
|
import { basename as basename32 } from "path";
|
|
50369
50474
|
|
|
50370
50475
|
// src/commands/transcript/failTranscript.ts
|
|
@@ -50508,7 +50613,7 @@ function widenAudience(passages) {
|
|
|
50508
50613
|
|
|
50509
50614
|
// src/commands/transcript/merge.ts
|
|
50510
50615
|
function readSource3(file) {
|
|
50511
|
-
if (!
|
|
50616
|
+
if (!existsSync89(file)) failTranscript(`VTT file not found: ${file}`);
|
|
50512
50617
|
const cues = readCleanedCues(file);
|
|
50513
50618
|
if (cues.length === 0) failTranscript(`no cues found in: ${file}`);
|
|
50514
50619
|
return { path: file, name: basename32(file), cues };
|
|
@@ -50981,7 +51086,7 @@ function configKeys2() {
|
|
|
50981
51086
|
}
|
|
50982
51087
|
|
|
50983
51088
|
// src/commands/verify/forbiddenStrings.ts
|
|
50984
|
-
import { existsSync as
|
|
51089
|
+
import { existsSync as existsSync90, readFileSync as readFileSync76 } from "fs";
|
|
50985
51090
|
|
|
50986
51091
|
// src/commands/verify/forbiddenStrings/findForbiddenStrings.ts
|
|
50987
51092
|
import { minimatch as minimatch10 } from "minimatch";
|
|
@@ -51022,7 +51127,7 @@ function forbiddenStrings() {
|
|
|
51022
51127
|
const cache7 = /* @__PURE__ */ new Map();
|
|
51023
51128
|
const readJson = (file) => {
|
|
51024
51129
|
if (cache7.has(file)) return cache7.get(file);
|
|
51025
|
-
if (!
|
|
51130
|
+
if (!existsSync90(file)) {
|
|
51026
51131
|
console.log(`Forbidden-strings file not found: ${file}`);
|
|
51027
51132
|
process.exit(1);
|
|
51028
51133
|
}
|
|
@@ -51453,7 +51558,7 @@ function clearBuildPending() {
|
|
|
51453
51558
|
}
|
|
51454
51559
|
|
|
51455
51560
|
// src/commands/watch/isSyncPending.ts
|
|
51456
|
-
import { existsSync as
|
|
51561
|
+
import { existsSync as existsSync91 } from "fs";
|
|
51457
51562
|
|
|
51458
51563
|
// src/commands/watch/syncPendingPath.ts
|
|
51459
51564
|
function syncPendingPath(cwd) {
|
|
@@ -51463,7 +51568,7 @@ function syncPendingPath(cwd) {
|
|
|
51463
51568
|
// src/commands/watch/isSyncPending.ts
|
|
51464
51569
|
function isSyncPending() {
|
|
51465
51570
|
try {
|
|
51466
|
-
return
|
|
51571
|
+
return existsSync91(syncPendingPath());
|
|
51467
51572
|
} catch {
|
|
51468
51573
|
return false;
|
|
51469
51574
|
}
|
|
@@ -51590,7 +51695,7 @@ function resolveParams(params, cliArgs) {
|
|
|
51590
51695
|
}
|
|
51591
51696
|
|
|
51592
51697
|
// src/commands/run/resolveRunCwd.ts
|
|
51593
|
-
import { existsSync as
|
|
51698
|
+
import { existsSync as existsSync92 } from "fs";
|
|
51594
51699
|
import { resolve as resolve31 } from "path";
|
|
51595
51700
|
var MissingRunCwdError = class extends Error {
|
|
51596
51701
|
constructor(runName, cwd) {
|
|
@@ -51605,7 +51710,7 @@ var MissingRunCwdError = class extends Error {
|
|
|
51605
51710
|
function resolveRunCwd(config, baseDir = runConfigBaseDir()) {
|
|
51606
51711
|
if (!config.cwd) return void 0;
|
|
51607
51712
|
const cwd = resolve31(baseDir, config.cwd);
|
|
51608
|
-
if (!
|
|
51713
|
+
if (!existsSync92(cwd)) throw new MissingRunCwdError(config.name, cwd);
|
|
51609
51714
|
return cwd;
|
|
51610
51715
|
}
|
|
51611
51716
|
|
|
@@ -51940,10 +52045,10 @@ ${buildWatchReport(from)}`);
|
|
|
51940
52045
|
}
|
|
51941
52046
|
|
|
51942
52047
|
// src/commands/watch/consumeMarker.ts
|
|
51943
|
-
import { existsSync as
|
|
52048
|
+
import { existsSync as existsSync93, rmSync as rmSync14 } from "fs";
|
|
51944
52049
|
function consumeMarker(path110) {
|
|
51945
52050
|
try {
|
|
51946
|
-
if (!
|
|
52051
|
+
if (!existsSync93(path110)) return false;
|
|
51947
52052
|
rmSync14(path110);
|
|
51948
52053
|
return true;
|
|
51949
52054
|
} catch {
|
|
@@ -52241,7 +52346,7 @@ function registerWatch(program) {
|
|
|
52241
52346
|
// src/commands/roam/postRoamActivity.ts
|
|
52242
52347
|
import { execFileSync as execFileSync31 } from "child_process";
|
|
52243
52348
|
import { readdirSync as readdirSync28, readFileSync as readFileSync78, statSync as statSync15 } from "fs";
|
|
52244
|
-
import { join as
|
|
52349
|
+
import { join as join113 } from "path";
|
|
52245
52350
|
function findPortFile(roamDir) {
|
|
52246
52351
|
let entries;
|
|
52247
52352
|
try {
|
|
@@ -52250,7 +52355,7 @@ function findPortFile(roamDir) {
|
|
|
52250
52355
|
return void 0;
|
|
52251
52356
|
}
|
|
52252
52357
|
const candidates = entries.filter((name2) => /^roam-local-api(-[^.]+)?\.port$/.test(name2)).map((name2) => {
|
|
52253
|
-
const path110 =
|
|
52358
|
+
const path110 = join113(roamDir, name2);
|
|
52254
52359
|
try {
|
|
52255
52360
|
return { path: path110, mtimeMs: statSync15(path110).mtimeMs };
|
|
52256
52361
|
} catch {
|
|
@@ -52267,7 +52372,7 @@ var PID_BY_APP = {
|
|
|
52267
52372
|
function postRoamActivity(app, event) {
|
|
52268
52373
|
const appData = process.env.APPDATA;
|
|
52269
52374
|
if (!appData) return;
|
|
52270
|
-
const portFile = findPortFile(
|
|
52375
|
+
const portFile = findPortFile(join113(appData, "Roam"));
|
|
52271
52376
|
if (!portFile) return;
|
|
52272
52377
|
let port;
|
|
52273
52378
|
try {
|
|
@@ -52450,7 +52555,7 @@ function link2() {
|
|
|
52450
52555
|
}
|
|
52451
52556
|
|
|
52452
52557
|
// src/commands/run/add.ts
|
|
52453
|
-
import { mkdirSync as
|
|
52558
|
+
import { mkdirSync as mkdirSync42, writeFileSync as writeFileSync61 } from "fs";
|
|
52454
52559
|
import { dirname as dirname49 } from "path";
|
|
52455
52560
|
|
|
52456
52561
|
// src/commands/run/editRepoRunList.ts
|
|
@@ -52626,11 +52731,11 @@ function requireParsedArgs() {
|
|
|
52626
52731
|
}
|
|
52627
52732
|
|
|
52628
52733
|
// src/commands/run/runCommandFilePath.ts
|
|
52629
|
-
import { join as
|
|
52734
|
+
import { join as join114 } from "path";
|
|
52630
52735
|
function runCommandFilePath(name2) {
|
|
52631
52736
|
const segments = name2.split(":");
|
|
52632
52737
|
const file = `${segments.pop()}.md`;
|
|
52633
|
-
return
|
|
52738
|
+
return join114(".claude", "commands", ...segments, file);
|
|
52634
52739
|
}
|
|
52635
52740
|
|
|
52636
52741
|
// src/commands/run/add.ts
|
|
@@ -52647,7 +52752,7 @@ function saveProjectRunConfig(entry) {
|
|
|
52647
52752
|
}
|
|
52648
52753
|
function createCommandFile(name2) {
|
|
52649
52754
|
const filePath = runCommandFilePath(name2);
|
|
52650
|
-
|
|
52755
|
+
mkdirSync42(dirname49(filePath), { recursive: true });
|
|
52651
52756
|
const content = `---
|
|
52652
52757
|
description: Run ${name2}
|
|
52653
52758
|
---
|
|
@@ -52774,8 +52879,8 @@ function registerRunAdd(runCommand) {
|
|
|
52774
52879
|
}
|
|
52775
52880
|
|
|
52776
52881
|
// src/commands/run/remove.ts
|
|
52777
|
-
import { existsSync as
|
|
52778
|
-
import { dirname as dirname50, join as
|
|
52882
|
+
import { existsSync as existsSync94, readdirSync as readdirSync29, rmdirSync, unlinkSync as unlinkSync20 } from "fs";
|
|
52883
|
+
import { dirname as dirname50, join as join115 } from "path";
|
|
52779
52884
|
|
|
52780
52885
|
// src/commands/run/removeRepoRunConfig.ts
|
|
52781
52886
|
function isNamed(entry, name2) {
|
|
@@ -52793,17 +52898,17 @@ function removeRepoRunConfig(name2, repoName, cwd = process.cwd()) {
|
|
|
52793
52898
|
|
|
52794
52899
|
// src/commands/run/remove.ts
|
|
52795
52900
|
function removeEmptyNamespaceDirs(filePath) {
|
|
52796
|
-
const root2 =
|
|
52901
|
+
const root2 = join115(".claude", "commands");
|
|
52797
52902
|
for (let dir = dirname50(filePath); dir !== root2; dir = dirname50(dir)) {
|
|
52798
|
-
if (!
|
|
52903
|
+
if (!existsSync94(dir) || readdirSync29(dir).length > 0) return;
|
|
52799
52904
|
rmdirSync(dir);
|
|
52800
52905
|
}
|
|
52801
52906
|
}
|
|
52802
52907
|
function deleteCommandFile(name2) {
|
|
52803
52908
|
const filePath = runCommandFilePath(name2);
|
|
52804
|
-
const legacyPath =
|
|
52909
|
+
const legacyPath = join115(".claude", "commands", `${name2}.md`);
|
|
52805
52910
|
for (const path110 of /* @__PURE__ */ new Set([filePath, legacyPath])) {
|
|
52806
|
-
if (
|
|
52911
|
+
if (existsSync94(path110)) {
|
|
52807
52912
|
unlinkSync20(path110);
|
|
52808
52913
|
console.log(`Deleted command file: ${path110}`);
|
|
52809
52914
|
}
|
|
@@ -53541,12 +53646,12 @@ function toSessionViewInfo({
|
|
|
53541
53646
|
}
|
|
53542
53647
|
|
|
53543
53648
|
// src/commands/sessions/daemon/worktree/joinRefusal.ts
|
|
53544
|
-
import { existsSync as
|
|
53649
|
+
import { existsSync as existsSync95 } from "fs";
|
|
53545
53650
|
function joinRefusal(session) {
|
|
53546
53651
|
if (session.commandType === "run") return "a server run has no agent stream";
|
|
53547
53652
|
if (session.closing === true) return "the session is closing";
|
|
53548
53653
|
if (!session.cwd) return "the session has no working directory";
|
|
53549
|
-
if (!
|
|
53654
|
+
if (!existsSync95(session.cwd))
|
|
53550
53655
|
return "the session's workspace no longer exists";
|
|
53551
53656
|
return void 0;
|
|
53552
53657
|
}
|
|
@@ -53636,8 +53741,8 @@ function broadcastSessions(sessions, clients, linkedSessions = [], active) {
|
|
|
53636
53741
|
}
|
|
53637
53742
|
|
|
53638
53743
|
// src/commands/sessions/daemon/findServerParents.ts
|
|
53639
|
-
import { existsSync as
|
|
53640
|
-
import { join as
|
|
53744
|
+
import { existsSync as existsSync96 } from "fs";
|
|
53745
|
+
import { join as join116, resolve as resolve32 } from "path";
|
|
53641
53746
|
function isLive(session) {
|
|
53642
53747
|
return !!session.pty && session.status !== "done" && session.status !== "error";
|
|
53643
53748
|
}
|
|
@@ -53646,7 +53751,7 @@ function isLiveAgent(session) {
|
|
|
53646
53751
|
}
|
|
53647
53752
|
function serverRunDirs(sessions, file) {
|
|
53648
53753
|
return new Set(
|
|
53649
|
-
sessions.filter((s) => s.server && s.cwd && isLive(s)).map((s) => resolve32(s.cwd)).filter((dir) =>
|
|
53754
|
+
sessions.filter((s) => s.server && s.cwd && isLive(s)).map((s) => resolve32(s.cwd)).filter((dir) => existsSync96(join116(dir, file)))
|
|
53650
53755
|
);
|
|
53651
53756
|
}
|
|
53652
53757
|
function findServerParents(sessions, file) {
|
|
@@ -54376,7 +54481,7 @@ function createRunSession(id, { runName, runArgs, cwd, meta }) {
|
|
|
54376
54481
|
}
|
|
54377
54482
|
|
|
54378
54483
|
// src/commands/sessions/daemon/autoUpdate/autoUpdateControl.ts
|
|
54379
|
-
import { existsSync as
|
|
54484
|
+
import { existsSync as existsSync97, rmSync as rmSync15, writeFileSync as writeFileSync62 } from "fs";
|
|
54380
54485
|
var paused;
|
|
54381
54486
|
var wake;
|
|
54382
54487
|
var holdReleased = false;
|
|
@@ -54389,7 +54494,7 @@ function persist2(value) {
|
|
|
54389
54494
|
}
|
|
54390
54495
|
var autoUpdateControl = {
|
|
54391
54496
|
paused: () => {
|
|
54392
|
-
paused ??=
|
|
54497
|
+
paused ??= existsSync97(daemonPaths.autoUpdatePaused);
|
|
54393
54498
|
return paused;
|
|
54394
54499
|
},
|
|
54395
54500
|
setPaused: (value) => {
|
|
@@ -54488,7 +54593,17 @@ var DIVERGED_EXIT_CODE = 3;
|
|
|
54488
54593
|
async function settleLap(lap, { end, tail }, deps2) {
|
|
54489
54594
|
const how = end.signal ? `killed by ${end.signal}` : `exited ${end.code}`;
|
|
54490
54595
|
if (end.code === DIVERGED_EXIT_CODE) {
|
|
54491
|
-
|
|
54596
|
+
let held;
|
|
54597
|
+
try {
|
|
54598
|
+
held = deps2.escalate(tail);
|
|
54599
|
+
} catch (error) {
|
|
54600
|
+
const reason4 = error instanceof Error ? error.message : String(error);
|
|
54601
|
+
await backOff(
|
|
54602
|
+
`lap ${lap} ${how} (divergence); escalation refused: ${reason4.replaceAll("\n", " ")}`,
|
|
54603
|
+
deps2
|
|
54604
|
+
);
|
|
54605
|
+
return void 0;
|
|
54606
|
+
}
|
|
54492
54607
|
deps2.note(`lap ${lap} ${how} (divergence); escalated to session ${held}`);
|
|
54493
54608
|
return held;
|
|
54494
54609
|
}
|
|
@@ -54546,12 +54661,12 @@ function trimWatcherLog(cwd) {
|
|
|
54546
54661
|
}
|
|
54547
54662
|
|
|
54548
54663
|
// src/commands/sessions/daemon/worktree/appendWatcherLog.ts
|
|
54549
|
-
import { appendFileSync as appendFileSync4, mkdirSync as
|
|
54664
|
+
import { appendFileSync as appendFileSync4, mkdirSync as mkdirSync43 } from "fs";
|
|
54550
54665
|
import { dirname as dirname51 } from "path";
|
|
54551
54666
|
function appendWatcherLog(cwd, data) {
|
|
54552
54667
|
try {
|
|
54553
54668
|
const path110 = watcherLogPath(cwd);
|
|
54554
|
-
|
|
54669
|
+
mkdirSync43(dirname51(path110), { recursive: true });
|
|
54555
54670
|
appendFileSync4(path110, data);
|
|
54556
54671
|
} catch {
|
|
54557
54672
|
}
|
|
@@ -54566,6 +54681,21 @@ function detectExistingWorktree(cwd) {
|
|
|
54566
54681
|
return void 0;
|
|
54567
54682
|
}
|
|
54568
54683
|
|
|
54684
|
+
// src/commands/sessions/daemon/worktree/noteWorktreeHarness.ts
|
|
54685
|
+
function noteWorktreeHarness(session) {
|
|
54686
|
+
const path110 = session.worktree?.path;
|
|
54687
|
+
if (!path110) return;
|
|
54688
|
+
const harness = session.commandType === "claude" ? resolveHarness(session.harness) : session.harness;
|
|
54689
|
+
if (!harness) return;
|
|
54690
|
+
try {
|
|
54691
|
+
recordWorktreeHarness(path110, harness);
|
|
54692
|
+
} catch (error) {
|
|
54693
|
+
daemonLog(
|
|
54694
|
+
`worktree ${path110} harness ${harness} not recorded for session ${session.id}: ${error instanceof Error ? error.message : String(error)}`
|
|
54695
|
+
);
|
|
54696
|
+
}
|
|
54697
|
+
}
|
|
54698
|
+
|
|
54569
54699
|
// src/commands/sessions/daemon/worktree/refuseUnallocatedStart.ts
|
|
54570
54700
|
function refuseUnallocatedStart(session, path110, error, startHeld) {
|
|
54571
54701
|
const reason4 = error instanceof Error ? error.message : String(error);
|
|
@@ -54584,6 +54714,7 @@ function bindNewWorktree(session, alloc, notify2, startHeld = () => {
|
|
|
54584
54714
|
if (alloc.kind !== "worktree" || !alloc.cwd || !alloc.clone || !session)
|
|
54585
54715
|
return;
|
|
54586
54716
|
session.worktree = { path: alloc.cwd, clone: alloc.clone };
|
|
54717
|
+
noteWorktreeHarness(session);
|
|
54587
54718
|
if (alloc.created) {
|
|
54588
54719
|
session.awaitingSeed = true;
|
|
54589
54720
|
const { cwd, clone } = alloc;
|
|
@@ -54624,13 +54755,13 @@ function bindResumedWorktree(session, cwd, notify2) {
|
|
|
54624
54755
|
}
|
|
54625
54756
|
|
|
54626
54757
|
// src/commands/sessions/daemon/worktree/treeDurability.ts
|
|
54627
|
-
import { existsSync as
|
|
54758
|
+
import { existsSync as existsSync99 } from "fs";
|
|
54628
54759
|
|
|
54629
54760
|
// src/commands/sessions/daemon/worktree/holdsNoCheckout.ts
|
|
54630
|
-
import { existsSync as
|
|
54631
|
-
import { join as
|
|
54761
|
+
import { existsSync as existsSync98 } from "fs";
|
|
54762
|
+
import { join as join117 } from "path";
|
|
54632
54763
|
function holdsNoCheckout(path110) {
|
|
54633
|
-
return
|
|
54764
|
+
return existsSync98(path110) && !existsSync98(join117(path110, ".git"));
|
|
54634
54765
|
}
|
|
54635
54766
|
|
|
54636
54767
|
// src/commands/sessions/daemon/worktree/treeDurability.ts
|
|
@@ -54668,14 +54799,14 @@ function notACheckout(cwd, error) {
|
|
|
54668
54799
|
return holdsNoCheckout(cwd) && /not a git repository/i.test(error);
|
|
54669
54800
|
}
|
|
54670
54801
|
async function checkDurability(cwd) {
|
|
54671
|
-
if (!
|
|
54802
|
+
if (!existsSync99(cwd)) return treeIsGone;
|
|
54672
54803
|
const probes = durabilityProbes(cwd);
|
|
54673
54804
|
let step3 = probes.next();
|
|
54674
54805
|
while (!step3.done) step3 = probes.next(await gitResult(cwd, step3.value));
|
|
54675
54806
|
return step3.value;
|
|
54676
54807
|
}
|
|
54677
54808
|
function checkDurabilitySync(cwd) {
|
|
54678
|
-
if (!
|
|
54809
|
+
if (!existsSync99(cwd)) return treeIsGone;
|
|
54679
54810
|
const probes = durabilityProbes(cwd);
|
|
54680
54811
|
let step3 = probes.next();
|
|
54681
54812
|
while (!step3.done) step3 = probes.next(gitSyncResult(cwd, step3.value));
|
|
@@ -54780,18 +54911,27 @@ function escalateDivergence(ctx, cwd, output) {
|
|
|
54780
54911
|
);
|
|
54781
54912
|
return live.id;
|
|
54782
54913
|
}
|
|
54914
|
+
const harness = loadConfigFrom(clone).harness.engine;
|
|
54915
|
+
const adapter = harnessAdapter(harness);
|
|
54916
|
+
const blocker = launchBlocker(adapter, divergenceEscalationFeature);
|
|
54917
|
+
if (blocker) {
|
|
54918
|
+
daemonLog(
|
|
54919
|
+
`auto-update diverged in the clone ${clone}: no escalation spawned, ${blocker.replaceAll("\n", " ")}`
|
|
54920
|
+
);
|
|
54921
|
+
throw new Error(blocker);
|
|
54922
|
+
}
|
|
54783
54923
|
const prompt = divergencePrompt(clone, output);
|
|
54784
54924
|
const id = allocateAndBind(
|
|
54785
54925
|
ctx,
|
|
54786
54926
|
clone,
|
|
54787
54927
|
(sid, resolvedCwd) => ({
|
|
54788
|
-
...createSession(sid, { prompt, cwd: resolvedCwd ?? clone }),
|
|
54928
|
+
...createSession(sid, { prompt, cwd: resolvedCwd ?? clone, harness }),
|
|
54789
54929
|
divergenceEscalation: true
|
|
54790
54930
|
}),
|
|
54791
54931
|
{ inPlace: true }
|
|
54792
54932
|
);
|
|
54793
54933
|
daemonLog(
|
|
54794
|
-
`auto-update diverged in the clone ${clone}: spawned escalation session ${id} to diagnose it`
|
|
54934
|
+
`auto-update diverged in the clone ${clone}: spawned ${adapter.label} escalation session ${id} to diagnose it`
|
|
54795
54935
|
);
|
|
54796
54936
|
return id;
|
|
54797
54937
|
}
|
|
@@ -54959,17 +55099,17 @@ function setStatus2(session, newStatus) {
|
|
|
54959
55099
|
}
|
|
54960
55100
|
|
|
54961
55101
|
// src/commands/sessions/daemon/worktree/reapWorktree.ts
|
|
54962
|
-
import { existsSync as
|
|
55102
|
+
import { existsSync as existsSync101 } from "fs";
|
|
54963
55103
|
import { basename as basename34 } from "path";
|
|
54964
55104
|
|
|
54965
55105
|
// src/commands/sessions/daemon/worktree/deleteStrandedTree.ts
|
|
54966
|
-
import { existsSync as
|
|
54967
|
-
import { join as
|
|
55106
|
+
import { existsSync as existsSync100 } from "fs";
|
|
55107
|
+
import { join as join119 } from "path";
|
|
54968
55108
|
|
|
54969
55109
|
// src/commands/sessions/daemon/worktree/deleteTreeDirectly.ts
|
|
54970
55110
|
import { statSync as statSync16 } from "fs";
|
|
54971
55111
|
import { rm as rm3 } from "fs/promises";
|
|
54972
|
-
import { join as
|
|
55112
|
+
import { join as join118 } from "path";
|
|
54973
55113
|
async function deleteTreeDirectly(clone, worktreePath, why) {
|
|
54974
55114
|
if (holdsAGitDirectoryRatherThanALink(worktreePath)) {
|
|
54975
55115
|
const refusal = "it is a clone of its own, not a linked worktree";
|
|
@@ -54998,7 +55138,7 @@ async function deleteTreeDirectly(clone, worktreePath, why) {
|
|
|
54998
55138
|
return { removed: true };
|
|
54999
55139
|
}
|
|
55000
55140
|
function holdsAGitDirectoryRatherThanALink(worktreePath) {
|
|
55001
|
-
return statSync16(
|
|
55141
|
+
return statSync16(join118(worktreePath, ".git"), {
|
|
55002
55142
|
throwIfNoEntry: false
|
|
55003
55143
|
})?.isDirectory() === true;
|
|
55004
55144
|
}
|
|
@@ -55039,7 +55179,7 @@ async function deleteStrandedTree(clone, worktreePath, cause) {
|
|
|
55039
55179
|
);
|
|
55040
55180
|
}
|
|
55041
55181
|
function strandedReason(worktreePath, cause) {
|
|
55042
|
-
if (!
|
|
55182
|
+
if (!existsSync100(join119(worktreePath, ".git")))
|
|
55043
55183
|
return "its .git link is already gone";
|
|
55044
55184
|
if (/not a working tree|not a git repository/i.test(reason2(cause)))
|
|
55045
55185
|
return "git no longer recognises it as a working tree";
|
|
@@ -55091,7 +55231,7 @@ function reason3(error) {
|
|
|
55091
55231
|
|
|
55092
55232
|
// src/commands/sessions/daemon/worktree/reapWorktree.ts
|
|
55093
55233
|
async function reapWorktree(worktreePath, force = false) {
|
|
55094
|
-
if (!
|
|
55234
|
+
if (!existsSync101(worktreePath)) {
|
|
55095
55235
|
forgetWorktree(worktreePath);
|
|
55096
55236
|
daemonLog(
|
|
55097
55237
|
`worktree ${worktreePath} already gone; its record was forgotten`
|
|
@@ -55116,7 +55256,7 @@ async function reapWorktree(worktreePath, force = false) {
|
|
|
55116
55256
|
}
|
|
55117
55257
|
function owningClone(worktreePath) {
|
|
55118
55258
|
const recorded = worktreeAttributionIncludingReaped(worktreePath)?.clone;
|
|
55119
|
-
if (recorded &&
|
|
55259
|
+
if (recorded && existsSync101(recorded)) return recorded;
|
|
55120
55260
|
const detected = mainWorktree(worktreePath);
|
|
55121
55261
|
if (detected) return detected;
|
|
55122
55262
|
daemonLog(
|
|
@@ -55433,12 +55573,12 @@ async function closeBlockReason(sessionId2, tree) {
|
|
|
55433
55573
|
}
|
|
55434
55574
|
|
|
55435
55575
|
// src/commands/sessions/daemon/worktree/watchGitState.ts
|
|
55436
|
-
import { existsSync as
|
|
55576
|
+
import { existsSync as existsSync102, watch } from "fs";
|
|
55437
55577
|
var DEBOUNCE_MS = 500;
|
|
55438
55578
|
var POLL_MS5 = 3e4;
|
|
55439
55579
|
function watchGitState(cwd, onChange) {
|
|
55440
55580
|
const common = gitCommonDir(cwd);
|
|
55441
|
-
if (!common || !
|
|
55581
|
+
if (!common || !existsSync102(common)) return void 0;
|
|
55442
55582
|
const watchers = [
|
|
55443
55583
|
watchGitDir(common, onChange),
|
|
55444
55584
|
pollGitState(cwd, onChange)
|
|
@@ -56179,10 +56319,10 @@ function emitSessionOutput(session, clients, data) {
|
|
|
56179
56319
|
}
|
|
56180
56320
|
|
|
56181
56321
|
// src/commands/sessions/daemon/exitReason.ts
|
|
56182
|
-
import { existsSync as
|
|
56322
|
+
import { existsSync as existsSync103 } from "fs";
|
|
56183
56323
|
import { resolve as resolve34 } from "path";
|
|
56184
56324
|
function exitDetail(session) {
|
|
56185
|
-
if (session.cwd && !
|
|
56325
|
+
if (session.cwd && !existsSync103(session.cwd))
|
|
56186
56326
|
return `working directory ${session.cwd} no longer exists`;
|
|
56187
56327
|
return missingRunConfigCwd(session);
|
|
56188
56328
|
}
|
|
@@ -56196,7 +56336,7 @@ function missingRunConfigCwd(session) {
|
|
|
56196
56336
|
const config = resolveRunConfig(session.runName, dir);
|
|
56197
56337
|
if (!config?.cwd) return void 0;
|
|
56198
56338
|
const configured = resolve34(runConfigBaseDirFrom(dir), config.cwd);
|
|
56199
|
-
if (
|
|
56339
|
+
if (existsSync103(configured)) return void 0;
|
|
56200
56340
|
return `run config "${config.name}": cwd ${configured} does not exist`;
|
|
56201
56341
|
}
|
|
56202
56342
|
|
|
@@ -56244,17 +56384,36 @@ function handleRefusedRun(session, exitCode, onStatusChange) {
|
|
|
56244
56384
|
}
|
|
56245
56385
|
|
|
56246
56386
|
// src/commands/sessions/daemon/watchActivity.ts
|
|
56247
|
-
import { existsSync as
|
|
56387
|
+
import { existsSync as existsSync104, mkdirSync as mkdirSync44, watch as watch2 } from "fs";
|
|
56248
56388
|
import { dirname as dirname52 } from "path";
|
|
56249
56389
|
|
|
56250
56390
|
// src/commands/sessions/daemon/applyActivityToSession.ts
|
|
56251
56391
|
function applyActivityToSession(session, activity2) {
|
|
56252
56392
|
session.activity = activity2;
|
|
56253
|
-
if (activity2.harness
|
|
56393
|
+
if (activity2.harness && activity2.harness !== session.harness) {
|
|
56394
|
+
session.harness = activity2.harness;
|
|
56395
|
+
noteWorktreeHarness(session);
|
|
56396
|
+
}
|
|
56254
56397
|
if (activity2.claudeSessionId)
|
|
56255
56398
|
session.claudeSessionId = activity2.claudeSessionId;
|
|
56256
56399
|
}
|
|
56257
56400
|
|
|
56401
|
+
// src/commands/sessions/daemon/claimedByOthers.ts
|
|
56402
|
+
var boundBy = /* @__PURE__ */ new Map();
|
|
56403
|
+
function claimedByOthers(session) {
|
|
56404
|
+
const claimed = /* @__PURE__ */ new Set();
|
|
56405
|
+
for (const [conversationId, owner] of boundBy) {
|
|
56406
|
+
if (owner.harnessSessionId !== conversationId)
|
|
56407
|
+
boundBy.delete(conversationId);
|
|
56408
|
+
else if (owner !== session) claimed.add(conversationId);
|
|
56409
|
+
}
|
|
56410
|
+
return claimed;
|
|
56411
|
+
}
|
|
56412
|
+
function claimConversation(session, conversationId) {
|
|
56413
|
+
session.harnessSessionId = conversationId;
|
|
56414
|
+
boundBy.set(conversationId, session);
|
|
56415
|
+
}
|
|
56416
|
+
|
|
56258
56417
|
// src/commands/sessions/daemon/recordBoundPhaseSession.ts
|
|
56259
56418
|
import os6 from "os";
|
|
56260
56419
|
async function recordBoundPhaseSession(session, conversationId) {
|
|
@@ -56280,6 +56439,19 @@ async function recordBoundPhaseSession(session, conversationId) {
|
|
|
56280
56439
|
}
|
|
56281
56440
|
}
|
|
56282
56441
|
|
|
56442
|
+
// src/commands/sessions/daemon/completeBinding.ts
|
|
56443
|
+
function completeBinding(session, bound, notify2, onBound) {
|
|
56444
|
+
const { conversationId, harnessLabel: harnessLabel2 } = bound;
|
|
56445
|
+
claimConversation(session, conversationId);
|
|
56446
|
+
daemonLog(
|
|
56447
|
+
`session ${session.id} bound to ${harnessLabel2} conversation ${conversationId}`
|
|
56448
|
+
);
|
|
56449
|
+
rememberSessionTitle(session);
|
|
56450
|
+
void recordBoundPhaseSession(session, conversationId);
|
|
56451
|
+
onBound?.(session);
|
|
56452
|
+
notify2();
|
|
56453
|
+
}
|
|
56454
|
+
|
|
56283
56455
|
// src/commands/sessions/daemon/bindConversation.ts
|
|
56284
56456
|
var POLL_MS6 = 1e3;
|
|
56285
56457
|
var MAX_ATTEMPTS3 = 120;
|
|
@@ -56293,29 +56465,26 @@ function bindConversation(session, notify2, launchedAt = session.startedAt, onBo
|
|
|
56293
56465
|
const bind = (latestBind.get(session) ?? 0) + 1;
|
|
56294
56466
|
latestBind.set(session, bind);
|
|
56295
56467
|
const superseded = () => !!adapter.conversation.boundId(session) || latestBind.get(session) !== bind;
|
|
56296
|
-
const
|
|
56468
|
+
const sinceMs = launchedAt - START_SLACK_MS;
|
|
56297
56469
|
let attemptsLeft = MAX_ATTEMPTS3;
|
|
56298
56470
|
const schedule = () => setTimeout(() => void poll(), POLL_MS6).unref();
|
|
56299
56471
|
const poll = async () => {
|
|
56300
56472
|
if (superseded()) return;
|
|
56301
|
-
const conversationId = await discover(
|
|
56473
|
+
const conversationId = await discover({
|
|
56474
|
+
cwd,
|
|
56475
|
+
launchedAt,
|
|
56476
|
+
sinceMs,
|
|
56477
|
+
claimed: claimedByOthers(session)
|
|
56478
|
+
});
|
|
56302
56479
|
if (superseded()) return;
|
|
56303
|
-
if (!conversationId) {
|
|
56304
|
-
|
|
56305
|
-
|
|
56306
|
-
|
|
56307
|
-
|
|
56308
|
-
|
|
56309
|
-
|
|
56310
|
-
|
|
56311
|
-
session.harnessSessionId = conversationId;
|
|
56312
|
-
daemonLog(
|
|
56313
|
-
`session ${session.id} bound to ${adapter.label} conversation ${conversationId}`
|
|
56314
|
-
);
|
|
56315
|
-
rememberSessionTitle(session);
|
|
56316
|
-
void recordBoundPhaseSession(session, conversationId);
|
|
56317
|
-
onBound?.(session);
|
|
56318
|
-
notify2();
|
|
56480
|
+
if (conversationId && !claimedByOthers(session).has(conversationId)) {
|
|
56481
|
+
const bound = { conversationId, harnessLabel: adapter.label };
|
|
56482
|
+
completeBinding(session, bound, notify2, onBound);
|
|
56483
|
+
} else if (--attemptsLeft > 0) schedule();
|
|
56484
|
+
else
|
|
56485
|
+
daemonLog(
|
|
56486
|
+
`session ${session.id} found no ${adapter.label} conversation to bind`
|
|
56487
|
+
);
|
|
56319
56488
|
};
|
|
56320
56489
|
schedule();
|
|
56321
56490
|
}
|
|
@@ -56402,7 +56571,7 @@ function watchActivity(session, notify2, onConversation) {
|
|
|
56402
56571
|
const path110 = activityPath(session.id);
|
|
56403
56572
|
const dir = dirname52(path110);
|
|
56404
56573
|
try {
|
|
56405
|
-
|
|
56574
|
+
mkdirSync44(dir, { recursive: true });
|
|
56406
56575
|
} catch {
|
|
56407
56576
|
return;
|
|
56408
56577
|
}
|
|
@@ -56423,7 +56592,7 @@ function watchActivity(session, notify2, onConversation) {
|
|
|
56423
56592
|
if (timer) clearTimeout(timer);
|
|
56424
56593
|
timer = setTimeout(read4, DEBOUNCE_MS2);
|
|
56425
56594
|
});
|
|
56426
|
-
if (
|
|
56595
|
+
if (existsSync104(path110)) read4();
|
|
56427
56596
|
}
|
|
56428
56597
|
function refreshActivity(session) {
|
|
56429
56598
|
if (session.commandType !== "assist" || !session.cwd) return;
|
|
@@ -56506,10 +56675,10 @@ function reportSilentFailure(session, clients) {
|
|
|
56506
56675
|
import { watch as watch3 } from "fs";
|
|
56507
56676
|
|
|
56508
56677
|
// src/commands/sessions/daemon/ensureProjectDirExists.ts
|
|
56509
|
-
import { mkdirSync as
|
|
56678
|
+
import { mkdirSync as mkdirSync45 } from "fs";
|
|
56510
56679
|
function ensureProjectDirExists(dir, sessionId2) {
|
|
56511
56680
|
try {
|
|
56512
|
-
|
|
56681
|
+
mkdirSync45(dir, { recursive: true });
|
|
56513
56682
|
return true;
|
|
56514
56683
|
} catch (error) {
|
|
56515
56684
|
daemonLog(
|
|
@@ -57487,39 +57656,17 @@ function conversationResumeOutcome(session) {
|
|
|
57487
57656
|
};
|
|
57488
57657
|
}
|
|
57489
57658
|
|
|
57490
|
-
// src/shared/harnessResumesConversation.ts
|
|
57491
|
-
function harnessResumesConversation(harness) {
|
|
57492
|
-
return harnessCapability(harness, "conversation.resume").supported;
|
|
57493
|
-
}
|
|
57494
|
-
|
|
57495
|
-
// src/commands/sessions/daemon/codexRespawnPlan.ts
|
|
57496
|
-
function codexRespawnPlan(session) {
|
|
57497
|
-
const { harnessSessionId, cwd, initialPrompt } = session;
|
|
57498
|
-
if (harnessSessionId)
|
|
57499
|
-
return {
|
|
57500
|
-
spawn: () => spawnCodex({
|
|
57501
|
-
resumeSessionId: harnessSessionId,
|
|
57502
|
-
cwd,
|
|
57503
|
-
sessionId: session.id
|
|
57504
|
-
}),
|
|
57505
|
-
status: "waiting"
|
|
57506
|
-
};
|
|
57507
|
-
if (!cwd && !initialPrompt) return null;
|
|
57508
|
-
return {
|
|
57509
|
-
spawn: () => spawnCodex({ prompt: initialPrompt, cwd, sessionId: session.id }),
|
|
57510
|
-
status: initialPrompt ? "running" : "waiting"
|
|
57511
|
-
};
|
|
57512
|
-
}
|
|
57513
|
-
|
|
57514
57659
|
// src/commands/sessions/daemon/interactiveRespawnPlan.ts
|
|
57515
|
-
|
|
57516
|
-
|
|
57517
|
-
|
|
57518
|
-
|
|
57519
|
-
|
|
57660
|
+
function interactiveRespawnPlan(session) {
|
|
57661
|
+
const adapter = harnessAdapter(session.harness);
|
|
57662
|
+
if (!resolveCapability(adapter.capabilities, "conversation.resume").supported)
|
|
57663
|
+
return null;
|
|
57664
|
+
const { cwd, initialPrompt, design, auto } = session;
|
|
57665
|
+
const resumeId = adapter.conversation.findResumable(session);
|
|
57666
|
+
if (resumeId)
|
|
57520
57667
|
return {
|
|
57521
|
-
spawn: () =>
|
|
57522
|
-
|
|
57668
|
+
spawn: () => adapter.interactive({
|
|
57669
|
+
resumeId,
|
|
57523
57670
|
cwd,
|
|
57524
57671
|
sessionId: session.id,
|
|
57525
57672
|
design,
|
|
@@ -57527,21 +57674,22 @@ function interactiveRespawnPlan(session, resumes) {
|
|
|
57527
57674
|
}),
|
|
57528
57675
|
status: "waiting"
|
|
57529
57676
|
};
|
|
57530
|
-
if (initialPrompt) return
|
|
57531
|
-
|
|
57532
|
-
return null;
|
|
57677
|
+
if (!initialPrompt && !cwd) return null;
|
|
57678
|
+
return freshPlan(session, adapter, initialPrompt);
|
|
57533
57679
|
}
|
|
57534
|
-
function
|
|
57535
|
-
const
|
|
57680
|
+
function freshPlan(session, adapter, prompt) {
|
|
57681
|
+
const conversationId = preassignedId(adapter);
|
|
57536
57682
|
return {
|
|
57537
57683
|
spawn: () => {
|
|
57538
|
-
session.claudeSessionId =
|
|
57684
|
+
session.claudeSessionId = void 0;
|
|
57685
|
+
session.harnessSessionId = void 0;
|
|
57686
|
+
Object.assign(session, adapter.activityIdentity(conversationId));
|
|
57539
57687
|
rememberSessionTitle(session);
|
|
57540
|
-
return
|
|
57688
|
+
return adapter.interactive({
|
|
57541
57689
|
prompt,
|
|
57542
|
-
cwd,
|
|
57690
|
+
cwd: session.cwd,
|
|
57543
57691
|
sessionId: session.id,
|
|
57544
|
-
|
|
57692
|
+
conversationId,
|
|
57545
57693
|
design: session.design,
|
|
57546
57694
|
auto: session.auto
|
|
57547
57695
|
});
|
|
@@ -57550,20 +57698,10 @@ function freshClaudePlan(session, prompt, cwd) {
|
|
|
57550
57698
|
};
|
|
57551
57699
|
}
|
|
57552
57700
|
|
|
57553
|
-
// src/commands/sessions/daemon/interactiveHarnessRespawn.ts
|
|
57554
|
-
function interactiveHarnessRespawn(session) {
|
|
57555
|
-
if (resolveHarness(session.harness) === "codex")
|
|
57556
|
-
return codexRespawnPlan(session);
|
|
57557
|
-
return interactiveRespawnPlan(
|
|
57558
|
-
session,
|
|
57559
|
-
harnessResumesConversation(session.harness)
|
|
57560
|
-
);
|
|
57561
|
-
}
|
|
57562
|
-
|
|
57563
57701
|
// src/commands/sessions/daemon/respawnPlan.ts
|
|
57564
57702
|
function respawnPlan(session) {
|
|
57565
57703
|
const { commandType, cwd, assistArgs } = session;
|
|
57566
|
-
if (commandType === "claude") return
|
|
57704
|
+
if (commandType === "claude") return interactiveRespawnPlan(session);
|
|
57567
57705
|
if (commandType === "assist" && assistArgs) {
|
|
57568
57706
|
const idle = session.status === "waiting";
|
|
57569
57707
|
let resume;
|
|
@@ -58120,15 +58258,47 @@ function relaunchWrapperSession(id, persisted, base, status2) {
|
|
|
58120
58258
|
return session;
|
|
58121
58259
|
}
|
|
58122
58260
|
|
|
58123
|
-
// src/
|
|
58124
|
-
function
|
|
58125
|
-
|
|
58261
|
+
// src/shared/harnessResumesConversation.ts
|
|
58262
|
+
function harnessResumesConversation(harness) {
|
|
58263
|
+
return harnessCapability(harness, "conversation.resume").supported;
|
|
58264
|
+
}
|
|
58265
|
+
|
|
58266
|
+
// src/commands/sessions/daemon/relaunchUnwrittenConversation.ts
|
|
58267
|
+
function relaunchUnwrittenConversation(adapter, { id, persisted, base }, plan2) {
|
|
58268
|
+
const conversationId = resolveCapability(
|
|
58269
|
+
adapter.capabilities,
|
|
58270
|
+
"conversation.preassignId"
|
|
58271
|
+
).supported ? adapter.conversation.boundId(persisted) : void 0;
|
|
58272
|
+
const pty2 = adapter.interactive({
|
|
58273
|
+
conversationId,
|
|
58274
|
+
prompt: persisted.initialPrompt,
|
|
58275
|
+
cwd: persisted.cwd,
|
|
58276
|
+
sessionId: id,
|
|
58277
|
+
design: persisted.design,
|
|
58278
|
+
auto: persisted.auto
|
|
58279
|
+
});
|
|
58280
|
+
const idle = persisted.initialPrompt ? false : plan2.idle;
|
|
58281
|
+
return {
|
|
58282
|
+
...idle ? waitingSession(base, persisted, pty2) : runningSession(base, persisted, pty2),
|
|
58283
|
+
claudeSessionId: void 0,
|
|
58284
|
+
harnessSessionId: void 0,
|
|
58285
|
+
...adapter.activityIdentity(conversationId)
|
|
58286
|
+
};
|
|
58287
|
+
}
|
|
58288
|
+
|
|
58289
|
+
// src/commands/sessions/daemon/restoreConversation.ts
|
|
58290
|
+
function restoreConversation(adapter, restored, status2) {
|
|
58291
|
+
const { id, persisted, base } = restored;
|
|
58126
58292
|
const plan2 = restoreResumePlan(persisted, status2);
|
|
58127
|
-
const
|
|
58128
|
-
|
|
58293
|
+
const resumeId = adapter.conversation.findResumable(persisted);
|
|
58294
|
+
if (!resumeId) return relaunchUnwrittenConversation(adapter, restored, plan2);
|
|
58295
|
+
const pty2 = adapter.interactive({
|
|
58296
|
+
resumeId,
|
|
58129
58297
|
prompt: resumePrompt(plan2),
|
|
58130
58298
|
cwd: persisted.cwd,
|
|
58131
|
-
sessionId: id
|
|
58299
|
+
sessionId: id,
|
|
58300
|
+
design: persisted.design,
|
|
58301
|
+
auto: persisted.auto
|
|
58132
58302
|
});
|
|
58133
58303
|
return plan2.idle ? waitingSession(base, persisted, pty2) : runningSession(base, persisted, pty2);
|
|
58134
58304
|
}
|
|
@@ -58174,42 +58344,11 @@ function unresumableReason(harness) {
|
|
|
58174
58344
|
return resume.supported ? `no ${adapter.conversation.idName} was recorded before the daemon stopped, so the conversation cannot be resumed` : `${resume.reason}, so the conversation cannot be restored`;
|
|
58175
58345
|
}
|
|
58176
58346
|
|
|
58177
|
-
// src/commands/sessions/daemon/resumeViaClaude.ts
|
|
58178
|
-
function resumeViaClaude(id, persisted, base, status2) {
|
|
58179
|
-
const mode = { design: persisted.design, auto: persisted.auto };
|
|
58180
|
-
const plan2 = restoreResumePlan(persisted, status2);
|
|
58181
|
-
const resumes = hasTranscriptOnDisk(persisted);
|
|
58182
|
-
const pty2 = spawnClaude(
|
|
58183
|
-
resumes ? {
|
|
58184
|
-
resumeSessionId: persisted.claudeSessionId,
|
|
58185
|
-
prompt: resumePrompt(plan2),
|
|
58186
|
-
cwd: persisted.cwd,
|
|
58187
|
-
sessionId: id,
|
|
58188
|
-
...mode
|
|
58189
|
-
} : {
|
|
58190
|
-
claudeSessionId: persisted.claudeSessionId,
|
|
58191
|
-
prompt: persisted.initialPrompt,
|
|
58192
|
-
cwd: persisted.cwd,
|
|
58193
|
-
sessionId: id,
|
|
58194
|
-
...mode
|
|
58195
|
-
}
|
|
58196
|
-
);
|
|
58197
|
-
const idle = resumes || !persisted.initialPrompt ? plan2.idle : false;
|
|
58198
|
-
return idle ? waitingSession(base, persisted, pty2) : runningSession(base, persisted, pty2);
|
|
58199
|
-
}
|
|
58200
|
-
|
|
58201
58347
|
// src/commands/sessions/daemon/restoreInteractiveSession.ts
|
|
58202
|
-
function isCodex2(harness) {
|
|
58203
|
-
return resolveHarness(harness) === "codex";
|
|
58204
|
-
}
|
|
58205
58348
|
function restoreInteractiveSession(id, persisted, base, status2) {
|
|
58206
|
-
|
|
58207
|
-
|
|
58208
|
-
|
|
58209
|
-
if (persisted.commandType !== "run" && isCodex2(persisted.harness)) {
|
|
58210
|
-
const resumed = restoreCodexSession(id, persisted, base, status2);
|
|
58211
|
-
if (resumed) return resumed;
|
|
58212
|
-
}
|
|
58349
|
+
const adapter = harnessAdapter(persisted.harness);
|
|
58350
|
+
if (persisted.commandType !== "run" && adapter.conversation.boundId(persisted) && harnessResumesConversation(persisted.harness))
|
|
58351
|
+
return restoreConversation(adapter, { id, persisted, base }, status2);
|
|
58213
58352
|
if (persisted.commandType === "claude") {
|
|
58214
58353
|
return unrecoverableClaude(id, persisted);
|
|
58215
58354
|
}
|
|
@@ -58362,7 +58501,7 @@ function rearmStoppedSessions(sessions, notify2) {
|
|
|
58362
58501
|
}
|
|
58363
58502
|
|
|
58364
58503
|
// src/commands/sessions/daemon/worktree/reconcileWorktreesOnRestore.ts
|
|
58365
|
-
import { existsSync as
|
|
58504
|
+
import { existsSync as existsSync106 } from "fs";
|
|
58366
58505
|
import { basename as basename37 } from "path";
|
|
58367
58506
|
|
|
58368
58507
|
// src/commands/sessions/daemon/worktree/accountedTrees.ts
|
|
@@ -58383,9 +58522,9 @@ function accountedTrees(sessions) {
|
|
|
58383
58522
|
}
|
|
58384
58523
|
|
|
58385
58524
|
// src/commands/sessions/daemon/worktree/reclaimVanishedWorktrees.ts
|
|
58386
|
-
import { existsSync as
|
|
58525
|
+
import { existsSync as existsSync105 } from "fs";
|
|
58387
58526
|
async function reclaimVanishedWorktrees(clone, paths) {
|
|
58388
|
-
if (!
|
|
58527
|
+
if (!existsSync105(clone)) {
|
|
58389
58528
|
for (const { path: path110 } of paths) forgetWorktree(path110);
|
|
58390
58529
|
daemonLog(
|
|
58391
58530
|
`clone ${clone} is gone; forgot ${paths.length} worktree record(s) it owned`
|
|
@@ -58484,7 +58623,7 @@ function resurfaceOrphanedWorktree(sessions, spawnWith, recovered, notify2) {
|
|
|
58484
58623
|
return;
|
|
58485
58624
|
}
|
|
58486
58625
|
daemonLog(
|
|
58487
|
-
`orphaned worktree ${orphan.path} resurfaced as stopped session ${id}: ${reason4} (${held.summary})`
|
|
58626
|
+
`orphaned worktree ${orphan.path} resurfaced as stopped ${sessions.get(id)?.harness ?? "unknown-harness"} session ${id}: ${reason4} (${held.summary})`
|
|
58488
58627
|
);
|
|
58489
58628
|
const session = sessions.get(id);
|
|
58490
58629
|
if (session) armStoppedSession(sessions, session, notify2);
|
|
@@ -58497,6 +58636,7 @@ function orphanedSession(id, recovered) {
|
|
|
58497
58636
|
name: `recovered ${basename36(orphan.path)}`,
|
|
58498
58637
|
subtitle: `${held.summary} in ${orphan.path}`,
|
|
58499
58638
|
commandType: "claude",
|
|
58639
|
+
harness: orphan.harness ?? loadConfigFrom(orphan.clone).harness.engine,
|
|
58500
58640
|
pty: null,
|
|
58501
58641
|
cwd: orphan.path,
|
|
58502
58642
|
worktree: { path: orphan.path, clone: orphan.clone },
|
|
@@ -58543,7 +58683,7 @@ function reconcileWorktreesOnRestore(sessions, spawnWith, notify2) {
|
|
|
58543
58683
|
async function recoverOrphanedWorktrees(sessions, spawnWith, notify2) {
|
|
58544
58684
|
const accounted = accountedTrees(sessions);
|
|
58545
58685
|
const vanished = /* @__PURE__ */ new Map();
|
|
58546
|
-
for (const { path: path110, clone } of readWorktreeRegistry()) {
|
|
58686
|
+
for (const { path: path110, clone, harness } of readWorktreeRegistry()) {
|
|
58547
58687
|
if (underTempRoot(path110)) {
|
|
58548
58688
|
forgetWorktree(path110);
|
|
58549
58689
|
daemonLog(
|
|
@@ -58551,7 +58691,7 @@ async function recoverOrphanedWorktrees(sessions, spawnWith, notify2) {
|
|
|
58551
58691
|
);
|
|
58552
58692
|
continue;
|
|
58553
58693
|
}
|
|
58554
|
-
if (!
|
|
58694
|
+
if (!existsSync106(path110)) {
|
|
58555
58695
|
logVanishedTree(sessions, path110);
|
|
58556
58696
|
vanished.set(clone, [
|
|
58557
58697
|
...vanished.get(clone) ?? [],
|
|
@@ -58560,7 +58700,7 @@ async function recoverOrphanedWorktrees(sessions, spawnWith, notify2) {
|
|
|
58560
58700
|
continue;
|
|
58561
58701
|
}
|
|
58562
58702
|
if (accounted.has(path110)) continue;
|
|
58563
|
-
await recoverOrphan(sessions, spawnWith, { path: path110, clone }, notify2);
|
|
58703
|
+
await recoverOrphan(sessions, spawnWith, { path: path110, clone, harness }, notify2);
|
|
58564
58704
|
}
|
|
58565
58705
|
for (const [clone, paths] of vanished)
|
|
58566
58706
|
await reclaimVanishedWorktrees(clone, paths);
|
|
@@ -59702,8 +59842,16 @@ function addAgentToStream(ctx, targetId, request) {
|
|
|
59702
59842
|
);
|
|
59703
59843
|
return joinable;
|
|
59704
59844
|
}
|
|
59845
|
+
const harness = request.harness ?? joinable.session.harness;
|
|
59846
|
+
const blocker = launchBlocker(harnessAdapter(harness), sessionFeature);
|
|
59847
|
+
if (blocker) {
|
|
59848
|
+
daemonLog(
|
|
59849
|
+
`create: cannot add an agent to session ${targetId}: ${blocker.replaceAll("\n", " ")}`
|
|
59850
|
+
);
|
|
59851
|
+
return { reason: blocker };
|
|
59852
|
+
}
|
|
59705
59853
|
return {
|
|
59706
|
-
sessionId: spawnIntoStream(ctx, joinable.session, request)
|
|
59854
|
+
sessionId: spawnIntoStream(ctx, joinable.session, { ...request, harness })
|
|
59707
59855
|
};
|
|
59708
59856
|
}
|
|
59709
59857
|
|
|
@@ -59816,7 +59964,7 @@ import { existsSync as existsSync108 } from "fs";
|
|
|
59816
59964
|
// src/commands/sessions/daemon/resumeSession.ts
|
|
59817
59965
|
function resumeSession(id, sessionId2, cwd, name2, holdPty, harness) {
|
|
59818
59966
|
const startedAt = Date.now();
|
|
59819
|
-
const
|
|
59967
|
+
const adapter = harnessAdapter(harness);
|
|
59820
59968
|
return {
|
|
59821
59969
|
id,
|
|
59822
59970
|
name: name2 ? `${name2.slice(0, 36)} (R)` : `Resume ${sessionId2.slice(0, 8)}`,
|
|
@@ -59828,74 +59976,43 @@ function resumeSession(id, sessionId2, cwd, name2, holdPty, harness) {
|
|
|
59828
59976
|
runningSince: null,
|
|
59829
59977
|
waitingSince: startedAt,
|
|
59830
59978
|
...startOrHoldPty(
|
|
59831
|
-
() =>
|
|
59979
|
+
() => adapter.interactive({ resumeId: sessionId2, cwd, sessionId: id }),
|
|
59832
59980
|
holdPty
|
|
59833
59981
|
),
|
|
59834
59982
|
scrollback: "",
|
|
59835
|
-
cwd,
|
|
59836
59983
|
/* why: bind the card to the conversation it is resuming so a daemon restart
|
|
59837
59984
|
* re-resumes this same transcript, not whichever .jsonl a cwd poller would
|
|
59838
59985
|
* have re-discovered (#413). */
|
|
59839
|
-
|
|
59840
|
-
|
|
59986
|
+
...adapter.conversation.toRef(sessionId2),
|
|
59987
|
+
cwd
|
|
59841
59988
|
};
|
|
59842
59989
|
}
|
|
59843
59990
|
|
|
59844
59991
|
// src/commands/sessions/daemon/worktree/resumeInReplacementTree.ts
|
|
59845
59992
|
import { existsSync as existsSync107 } from "fs";
|
|
59846
|
-
|
|
59847
|
-
|
|
59848
|
-
|
|
59849
|
-
|
|
59850
|
-
function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
59851
|
-
const dir = projectDirForCwd(toCwd);
|
|
59852
|
-
if (dir === projectDirForCwd(fromCwd)) {
|
|
59853
|
-
daemonLog(
|
|
59854
|
-
`transcript ${claudeSessionId} already lives in ${dir}: resuming in the original worktree path`
|
|
59855
|
-
);
|
|
59856
|
-
return;
|
|
59857
|
-
}
|
|
59858
|
-
const dest = join119(dir, `${claudeSessionId}.jsonl`);
|
|
59859
|
-
if (existsSync106(dest)) {
|
|
59860
|
-
daemonLog(`transcript ${claudeSessionId} already present in ${dir}`);
|
|
59861
|
-
return;
|
|
59862
|
-
}
|
|
59863
|
-
const source = findTranscriptPathSync(fromCwd, claudeSessionId);
|
|
59864
|
-
if (!source) {
|
|
59865
|
-
daemonLog(
|
|
59866
|
-
`transcript ${claudeSessionId} not found under ${projectDirForCwd(fromCwd)}: resuming in ${toCwd} without it`
|
|
59867
|
-
);
|
|
59868
|
-
return;
|
|
59869
|
-
}
|
|
59870
|
-
try {
|
|
59871
|
-
mkdirSync45(dir, { recursive: true });
|
|
59872
|
-
copyFileSync4(source, dest);
|
|
59873
|
-
daemonLog(
|
|
59874
|
-
`transcript ${source} copied to ${dest} so ${toCwd} can resume it`
|
|
59875
|
-
);
|
|
59876
|
-
} catch (error) {
|
|
59993
|
+
function resumeInReplacementTree(ctx, conversationId, missingCwd, name2, harness) {
|
|
59994
|
+
const adapter = harnessAdapter(harness);
|
|
59995
|
+
const blocker = launchBlocker(adapter, conversationRecoveryFeature);
|
|
59996
|
+
if (blocker) {
|
|
59877
59997
|
daemonLog(
|
|
59878
|
-
`
|
|
59998
|
+
`resume ${conversationId} refused: its tree ${missingCwd} is gone and ${blocker.replaceAll("\n", " ")}`
|
|
59879
59999
|
);
|
|
60000
|
+
throw new Error(blocker);
|
|
59880
60001
|
}
|
|
59881
|
-
}
|
|
59882
|
-
|
|
59883
|
-
// src/commands/sessions/daemon/worktree/resumeInReplacementTree.ts
|
|
59884
|
-
function resumeInReplacementTree(ctx, claudeSessionId, missingCwd, name2, harness) {
|
|
59885
60002
|
const clone = cloneForReapedTree(missingCwd);
|
|
59886
60003
|
daemonLog(
|
|
59887
|
-
`resuming ${
|
|
60004
|
+
`resuming ${adapter.label} conversation ${conversationId}: its tree ${missingCwd} is gone, allocating from clone ${clone}`
|
|
59888
60005
|
);
|
|
59889
60006
|
return allocateAndBind(
|
|
59890
60007
|
ctx,
|
|
59891
60008
|
clone,
|
|
59892
60009
|
(id, resolvedCwd, holdUntilSeeded) => {
|
|
59893
60010
|
const cwd = resolvedCwd ?? clone;
|
|
59894
|
-
|
|
59895
|
-
daemonLog(`session ${id} resuming ${
|
|
60011
|
+
adapter.conversation.relocate(conversationId, missingCwd, cwd);
|
|
60012
|
+
daemonLog(`session ${id} resuming ${conversationId} in ${cwd}`);
|
|
59896
60013
|
return resumeSession(
|
|
59897
60014
|
id,
|
|
59898
|
-
|
|
60015
|
+
conversationId,
|
|
59899
60016
|
cwd,
|
|
59900
60017
|
name2,
|
|
59901
60018
|
holdUntilSeeded,
|
|
@@ -59918,6 +60035,14 @@ function cloneForReapedTree(missingCwd) {
|
|
|
59918
60035
|
function resumeInTree(ctx, sessionId2, cwd, name2, harness) {
|
|
59919
60036
|
if (!existsSync108(cwd))
|
|
59920
60037
|
return resumeInReplacementTree(ctx, sessionId2, cwd, name2, harness);
|
|
60038
|
+
const blocker = launchBlocker(
|
|
60039
|
+
harnessAdapter(harness),
|
|
60040
|
+
conversationResumeFeature
|
|
60041
|
+
);
|
|
60042
|
+
if (blocker) {
|
|
60043
|
+
daemonLog(`resume ${sessionId2} refused: ${blocker.replaceAll("\n", " ")}`);
|
|
60044
|
+
throw new Error(blocker);
|
|
60045
|
+
}
|
|
59921
60046
|
const id = ctx.spawnWith(
|
|
59922
60047
|
(sid) => resumeSession(sid, sessionId2, cwd, name2, void 0, harness)
|
|
59923
60048
|
);
|
|
@@ -60409,17 +60534,24 @@ function creator(isNew, spawn13) {
|
|
|
60409
60534
|
}
|
|
60410
60535
|
sendTo(client, { type: "created", sessionId: result, isNew, traceId });
|
|
60411
60536
|
};
|
|
60537
|
+
const fail15 = (client, d, error) => {
|
|
60538
|
+
const reason4 = error instanceof Error ? error.message : String(error);
|
|
60539
|
+
daemonLog(`${d.type} failed: ${reason4}`);
|
|
60540
|
+
reply2(client, d, { error: `${d.type} failed: ${reason4}` });
|
|
60541
|
+
};
|
|
60412
60542
|
return (client, m, d) => {
|
|
60413
60543
|
if (m.links.route(client, d)) return;
|
|
60414
|
-
|
|
60544
|
+
let result;
|
|
60545
|
+
try {
|
|
60546
|
+
result = spawn13(m, d);
|
|
60547
|
+
} catch (error) {
|
|
60548
|
+
fail15(client, d, error);
|
|
60549
|
+
return;
|
|
60550
|
+
}
|
|
60415
60551
|
if (result instanceof Promise)
|
|
60416
60552
|
result.then(
|
|
60417
60553
|
(resolved) => reply2(client, d, resolved),
|
|
60418
|
-
(error) =>
|
|
60419
|
-
const reason4 = error instanceof Error ? error.message : String(error);
|
|
60420
|
-
daemonLog(`${d.type} failed: ${reason4}`);
|
|
60421
|
-
reply2(client, d, { error: `${d.type} failed: ${reason4}` });
|
|
60422
|
-
}
|
|
60554
|
+
(error) => fail15(client, d, error)
|
|
60423
60555
|
);
|
|
60424
60556
|
else reply2(client, d, result);
|
|
60425
60557
|
};
|
|
@@ -61295,14 +61427,7 @@ function spawnAssistCreate(m, d) {
|
|
|
61295
61427
|
|
|
61296
61428
|
// src/commands/sessions/daemon/spawnCreate.ts
|
|
61297
61429
|
function sessionBlocker(harness) {
|
|
61298
|
-
|
|
61299
|
-
const resolution = resolveFeature(sessionFeature, adapter);
|
|
61300
|
-
if (resolution.available) return void 0;
|
|
61301
|
-
return formatUnavailable(
|
|
61302
|
-
sessionFeature.label,
|
|
61303
|
-
adapter.label,
|
|
61304
|
-
resolution.reasons
|
|
61305
|
-
);
|
|
61430
|
+
return launchBlocker(harnessAdapter(harness), sessionFeature);
|
|
61306
61431
|
}
|
|
61307
61432
|
function spawnCreate(m, d) {
|
|
61308
61433
|
const design = d.design === true;
|
|
@@ -61313,17 +61438,17 @@ function spawnCreate(m, d) {
|
|
|
61313
61438
|
daemonLog(`create: design session (cwd=${d.cwd ?? ""})`);
|
|
61314
61439
|
if (harness)
|
|
61315
61440
|
daemonLog(`create: ${harness} session (cwd=${d.cwd ?? ""})`);
|
|
61316
|
-
const blocker = sessionBlocker(harness);
|
|
61317
|
-
if (blocker) {
|
|
61318
|
-
daemonLog(`create: refused, ${blocker.replaceAll("\n", " ")}`);
|
|
61319
|
-
return { error: blocker };
|
|
61320
|
-
}
|
|
61321
61441
|
const joinSessionId = design ? void 0 : d.joinSessionId;
|
|
61322
61442
|
if (joinSessionId) {
|
|
61323
61443
|
const joined = m.addAgent(joinSessionId, { prompt, harness, auto });
|
|
61324
61444
|
if ("sessionId" in joined) return joined.sessionId;
|
|
61325
61445
|
return { error: `Can't add an agent: ${joined.reason}.` };
|
|
61326
61446
|
}
|
|
61447
|
+
const blocker = sessionBlocker(harness);
|
|
61448
|
+
if (blocker) {
|
|
61449
|
+
daemonLog(`create: refused, ${blocker.replaceAll("\n", " ")}`);
|
|
61450
|
+
return { error: blocker };
|
|
61451
|
+
}
|
|
61327
61452
|
return m.spawn(
|
|
61328
61453
|
{
|
|
61329
61454
|
prompt,
|