@staff0rd/assist 0.1137.0 → 0.1139.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 +461 -461
- package/dist/index.js +713 -635
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { Command } from "commander";
|
|
|
6
6
|
// package.json
|
|
7
7
|
var package_default = {
|
|
8
8
|
name: "@staff0rd/assist",
|
|
9
|
-
version: "0.
|
|
9
|
+
version: "0.1139.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -7144,21 +7144,6 @@ var harnessCapabilityDeclarations = {
|
|
|
7144
7144
|
"Claude (SDK) sessions have no terminal, and these workflows start an assist command that opens the Claude CLI's terminal UI",
|
|
7145
7145
|
"run the workflow with Claude",
|
|
7146
7146
|
"a1560"
|
|
7147
|
-
),
|
|
7148
|
-
"conversation.resume": unsupported(
|
|
7149
|
-
"Claude (SDK) sessions do not resume their conversation yet",
|
|
7150
|
-
"a daemon restart starts a fresh conversation; pick Claude to keep the conversation across restarts",
|
|
7151
|
-
"a1560"
|
|
7152
|
-
),
|
|
7153
|
-
"conversation.relocate": unsupported(
|
|
7154
|
-
"Claude (SDK) sessions do not resume their conversation yet, so it cannot continue in a replacement worktree",
|
|
7155
|
-
"start a fresh session in the replacement worktree; pick Claude to keep the conversation",
|
|
7156
|
-
"a1560"
|
|
7157
|
-
),
|
|
7158
|
-
"usage.rateLimits": unsupported(
|
|
7159
|
-
"assist does not yet record usage and rate-limit events from Claude (SDK) sessions",
|
|
7160
|
-
"Claude (SDK) usage is not shown in the status bar; terminal Claude usage still is",
|
|
7161
|
-
"a1560"
|
|
7162
7147
|
)
|
|
7163
7148
|
},
|
|
7164
7149
|
codex: {
|
|
@@ -7639,6 +7624,85 @@ function resolveClaudeExecutable() {
|
|
|
7639
7624
|
return path128;
|
|
7640
7625
|
}
|
|
7641
7626
|
|
|
7627
|
+
// src/commands/sessions/daemon/sdk/sdkContextUsedPct.ts
|
|
7628
|
+
function sdkContextTokens(usage) {
|
|
7629
|
+
if (!usage) return 0;
|
|
7630
|
+
return (usage.input_tokens ?? 0) + (usage.cache_read_input_tokens ?? 0) + (usage.cache_creation_input_tokens ?? 0);
|
|
7631
|
+
}
|
|
7632
|
+
function sdkContextUsedPct(contextTokens, model, result) {
|
|
7633
|
+
const windows = Object.entries(result.modelUsage ?? {});
|
|
7634
|
+
const contextWindow = model && result.modelUsage?.[model]?.contextWindow || Math.max(0, ...windows.map(([, usage]) => usage.contextWindow ?? 0));
|
|
7635
|
+
if (!contextTokens || !contextWindow) return void 0;
|
|
7636
|
+
return Math.min(100, Math.round(contextTokens / contextWindow * 100));
|
|
7637
|
+
}
|
|
7638
|
+
|
|
7639
|
+
// src/commands/sessions/daemon/sdk/sdkRateLimits.ts
|
|
7640
|
+
var WINDOWS = ["five_hour", "seven_day"];
|
|
7641
|
+
function toWindow(info) {
|
|
7642
|
+
if (typeof info?.utilization !== "number") return void 0;
|
|
7643
|
+
return {
|
|
7644
|
+
used_percentage: Math.round(info.utilization * 100),
|
|
7645
|
+
resets_at: info.resetsAt
|
|
7646
|
+
};
|
|
7647
|
+
}
|
|
7648
|
+
function windowInfo(info, window) {
|
|
7649
|
+
const unified = info.unifiedWindows;
|
|
7650
|
+
if (unified) return unified[window];
|
|
7651
|
+
return info.rateLimitType === window ? info : void 0;
|
|
7652
|
+
}
|
|
7653
|
+
function sdkRateLimits(info) {
|
|
7654
|
+
const limits = {};
|
|
7655
|
+
for (const window of WINDOWS) {
|
|
7656
|
+
const observed = toWindow(windowInfo(info, window));
|
|
7657
|
+
if (observed) limits[window] = observed;
|
|
7658
|
+
}
|
|
7659
|
+
return Object.keys(limits).length ? limits : void 0;
|
|
7660
|
+
}
|
|
7661
|
+
|
|
7662
|
+
// src/commands/sessions/daemon/sdk/sdkUsageSink.ts
|
|
7663
|
+
var sink2;
|
|
7664
|
+
function setSdkUsageSink(next3) {
|
|
7665
|
+
sink2 = next3;
|
|
7666
|
+
}
|
|
7667
|
+
function sdkUsageSink() {
|
|
7668
|
+
return sink2;
|
|
7669
|
+
}
|
|
7670
|
+
|
|
7671
|
+
// src/commands/sessions/daemon/sdk/createSdkUsageObserver.ts
|
|
7672
|
+
function createSdkUsageObserver(label) {
|
|
7673
|
+
let contextTokens = 0;
|
|
7674
|
+
let model;
|
|
7675
|
+
let transcriptPath;
|
|
7676
|
+
const transcriptFor = (claudeSessionId) => {
|
|
7677
|
+
transcriptPath ??= findSessionJsonlPath(claudeSessionId).catch(() => null);
|
|
7678
|
+
return transcriptPath;
|
|
7679
|
+
};
|
|
7680
|
+
return (message4) => {
|
|
7681
|
+
const sink4 = sdkUsageSink();
|
|
7682
|
+
if (message4.type === "rate_limit_event") {
|
|
7683
|
+
const limits = sdkRateLimits(message4.rate_limit_info);
|
|
7684
|
+
if (!limits) return;
|
|
7685
|
+
daemonLog(
|
|
7686
|
+
`${label} sdk rate limits: 5h ${limits.five_hour?.used_percentage ?? "-"}% 7d ${limits.seven_day?.used_percentage ?? "-"}%`
|
|
7687
|
+
);
|
|
7688
|
+
sink4?.limits(limits);
|
|
7689
|
+
} else if (message4.type === "assistant" && message4.parent_tool_use_id === null) {
|
|
7690
|
+
contextTokens = sdkContextTokens(message4.message.usage) || contextTokens;
|
|
7691
|
+
model = message4.message.model ?? model;
|
|
7692
|
+
} else if (message4.type === "result") {
|
|
7693
|
+
const usedPct = sdkContextUsedPct(contextTokens, model, message4);
|
|
7694
|
+
const claudeSessionId = message4.session_id;
|
|
7695
|
+
daemonLog(
|
|
7696
|
+
`${label} sdk usage: claude session ${claudeSessionId} context ${usedPct ?? "-"}%`
|
|
7697
|
+
);
|
|
7698
|
+
if (!sink4) return;
|
|
7699
|
+
void transcriptFor(claudeSessionId).then(
|
|
7700
|
+
(path128) => sink4.usage(claudeSessionId, path128 ?? void 0, usedPct)
|
|
7701
|
+
);
|
|
7702
|
+
}
|
|
7703
|
+
};
|
|
7704
|
+
}
|
|
7705
|
+
|
|
7642
7706
|
// src/commands/sessions/daemon/sdk/logSdkMessage.ts
|
|
7643
7707
|
function logSdkMessage(label, message4) {
|
|
7644
7708
|
if (message4.type === "system" && message4.subtype === "init")
|
|
@@ -7690,9 +7754,11 @@ function sdkTurnStatus(message4) {
|
|
|
7690
7754
|
// src/commands/sessions/daemon/sdk/runSdkQuery.ts
|
|
7691
7755
|
async function runSdkQuery(messages2, sessionId2, control, turn) {
|
|
7692
7756
|
const label = `session ${sessionId2 ?? "?"}`;
|
|
7757
|
+
const observeUsage = createSdkUsageObserver(label);
|
|
7693
7758
|
try {
|
|
7694
7759
|
for await (const message4 of messages2) {
|
|
7695
7760
|
logSdkMessage(label, message4);
|
|
7761
|
+
observeUsage(message4);
|
|
7696
7762
|
const status2 = sdkTurnStatus(message4);
|
|
7697
7763
|
if (status2) turn.setStatus(status2);
|
|
7698
7764
|
if (message4.type === "assistant" && message4.parent_tool_use_id === null)
|
|
@@ -7755,7 +7821,7 @@ function sdkQueryOptions(opts2, executable, abort2, control) {
|
|
|
7755
7821
|
const append = opts2.appendSystemPromptFile ? readFileSync8(opts2.appendSystemPromptFile, "utf8") : void 0;
|
|
7756
7822
|
return {
|
|
7757
7823
|
cwd: opts2.cwd,
|
|
7758
|
-
sessionId: opts2.claudeSessionId,
|
|
7824
|
+
...opts2.resumeId ? { resume: opts2.resumeId } : { sessionId: opts2.claudeSessionId },
|
|
7759
7825
|
permissionMode: "auto",
|
|
7760
7826
|
settings: ensureHooksSettings(),
|
|
7761
7827
|
pathToClaudeCodeExecutable: executable,
|
|
@@ -7778,6 +7844,7 @@ async function startSdkQuery(opts2, abort2, control, turn, prompt) {
|
|
|
7778
7844
|
prompt,
|
|
7779
7845
|
options: sdkQueryOptions(opts2, executable, abort2, control)
|
|
7780
7846
|
});
|
|
7847
|
+
if (opts2.resumeId) awaitResume(label, messages2, control);
|
|
7781
7848
|
control.bind({
|
|
7782
7849
|
send: turn.send,
|
|
7783
7850
|
interrupt: () => turn.interrupt(async () => {
|
|
@@ -7792,6 +7859,17 @@ async function startSdkQuery(opts2, abort2, control, turn, prompt) {
|
|
|
7792
7859
|
control.exit(1);
|
|
7793
7860
|
}
|
|
7794
7861
|
}
|
|
7862
|
+
function awaitResume(label, messages2, control) {
|
|
7863
|
+
messages2.initializationResult().then(
|
|
7864
|
+
() => {
|
|
7865
|
+
daemonLog(`${label} sdk resume complete`);
|
|
7866
|
+
control.emit({ kind: "resumed" });
|
|
7867
|
+
},
|
|
7868
|
+
(error) => daemonLog(
|
|
7869
|
+
`${label} sdk resume did not complete: ${error instanceof Error ? error.message : String(error)}`
|
|
7870
|
+
)
|
|
7871
|
+
);
|
|
7872
|
+
}
|
|
7795
7873
|
|
|
7796
7874
|
// src/commands/sessions/daemon/spawnClaudeSdk.ts
|
|
7797
7875
|
function spawnClaudeSdk(opts2) {
|
|
@@ -7824,6 +7902,7 @@ var claudeSdkAdapter = {
|
|
|
7824
7902
|
interactive: ({
|
|
7825
7903
|
sessionId: sessionId2,
|
|
7826
7904
|
conversationId,
|
|
7905
|
+
resumeId,
|
|
7827
7906
|
prompt,
|
|
7828
7907
|
cwd,
|
|
7829
7908
|
appendSystemPromptFile,
|
|
@@ -7833,6 +7912,7 @@ var claudeSdkAdapter = {
|
|
|
7833
7912
|
cwd,
|
|
7834
7913
|
sessionId: sessionId2,
|
|
7835
7914
|
claudeSessionId: conversationId,
|
|
7915
|
+
resumeId,
|
|
7836
7916
|
appendSystemPromptFile,
|
|
7837
7917
|
model
|
|
7838
7918
|
}),
|
|
@@ -10973,8 +11053,8 @@ var backlogConfigHelp = [
|
|
|
10973
11053
|
var harnessConfigHelp = [
|
|
10974
11054
|
{
|
|
10975
11055
|
key: "harness.engine",
|
|
10976
|
-
setter: "assist config set harness.engine <claude|codex|pi>",
|
|
10977
|
-
note: "default coding harness launched by refine and other flows"
|
|
11056
|
+
setter: "assist config set harness.engine <claude|claude-sdk|codex|pi>",
|
|
11057
|
+
note: "default coding harness launched by refine and other flows; claude-sdk (Claude (SDK)) drives your logged-in claude through the Agent SDK, and signed in with a Claude plan its usage draws from the same plan usage limits as Claude Code (Anthropic's monthly API credits cover the Agent SDK only with an API key)"
|
|
10978
11058
|
},
|
|
10979
11059
|
{
|
|
10980
11060
|
key: "harness.exposeCodexActions",
|
|
@@ -11547,7 +11627,7 @@ var sessionsConfigHelp = [
|
|
|
11547
11627
|
{
|
|
11548
11628
|
key: "sessions.reportLeftovers",
|
|
11549
11629
|
setter: "assist config set sessions.reportLeftovers false --node",
|
|
11550
|
-
note: "default on: on daemon restart, recheck reaped worktree paths that reappeared (e.g. root-owned Docker bind-mount stubs) and list any leftover assist cannot delete
|
|
11630
|
+
note: "default on: on daemon restart, recheck reaped worktree paths that reappeared (e.g. root-owned Docker bind-mount stubs) and list any leftover assist cannot delete, with a combined removal command, in the web node menu and `assist sessions nodes doctor`. Set false to skip both"
|
|
11551
11631
|
},
|
|
11552
11632
|
{
|
|
11553
11633
|
key: "sessions.newSessionMode",
|
|
@@ -16720,6 +16800,126 @@ function newSessionDefaults(req, res) {
|
|
|
16720
16800
|
respondJson(res, 200, { mode: parsed.data, ...resolved2 });
|
|
16721
16801
|
}
|
|
16722
16802
|
|
|
16803
|
+
// src/commands/sessions/daemon/worktree/leftoverContents.ts
|
|
16804
|
+
import { lstatSync, readdirSync as readdirSync10 } from "fs";
|
|
16805
|
+
import { join as join37 } from "path";
|
|
16806
|
+
function leftoverContents(path128) {
|
|
16807
|
+
const contents = { holdsFiles: false, foreignOwned: false };
|
|
16808
|
+
walk2(path128, contents, process.getuid?.());
|
|
16809
|
+
return contents;
|
|
16810
|
+
}
|
|
16811
|
+
function walk2(path128, contents, uid) {
|
|
16812
|
+
const stat5 = lstatSync(path128, { throwIfNoEntry: false });
|
|
16813
|
+
if (!stat5) return;
|
|
16814
|
+
if (uid !== void 0 && stat5.uid !== uid) contents.foreignOwned = true;
|
|
16815
|
+
if (!stat5.isDirectory()) {
|
|
16816
|
+
contents.holdsFiles = true;
|
|
16817
|
+
return;
|
|
16818
|
+
}
|
|
16819
|
+
let entries2;
|
|
16820
|
+
try {
|
|
16821
|
+
entries2 = readdirSync10(path128);
|
|
16822
|
+
} catch {
|
|
16823
|
+
contents.foreignOwned = true;
|
|
16824
|
+
contents.holdsFiles = true;
|
|
16825
|
+
return;
|
|
16826
|
+
}
|
|
16827
|
+
for (const entry of entries2) walk2(join37(path128, entry), contents, uid);
|
|
16828
|
+
}
|
|
16829
|
+
|
|
16830
|
+
// src/commands/sessions/daemon/worktree/leftoverRemovalCommand.ts
|
|
16831
|
+
function leftoverRemovalCommand(leftovers2) {
|
|
16832
|
+
if (leftovers2.length === 0) return null;
|
|
16833
|
+
const sudo = leftovers2.some((l) => leftoverContents(l.path).foreignOwned);
|
|
16834
|
+
return `${sudo ? "sudo " : ""}rm -rf ${leftovers2.map((l) => shellQuote(l.path)).join(" ")}`;
|
|
16835
|
+
}
|
|
16836
|
+
function shellQuote(path128) {
|
|
16837
|
+
return /^[\w@%+=:,./-]+$/.test(path128) ? path128 : `'${path128.replaceAll("'", `'\\''`)}'`;
|
|
16838
|
+
}
|
|
16839
|
+
|
|
16840
|
+
// src/commands/sessions/daemon/worktree/listLeftovers.ts
|
|
16841
|
+
import { existsSync as existsSync31 } from "fs";
|
|
16842
|
+
|
|
16843
|
+
// src/commands/sessions/daemon/worktree/readWorktreeRegistry.ts
|
|
16844
|
+
var REGISTRY_FILE = "worktrees.json";
|
|
16845
|
+
function readWorktreeRegistry() {
|
|
16846
|
+
const data = loadJson(REGISTRY_FILE);
|
|
16847
|
+
return Object.entries(data).filter(([, record3]) => !record3.reaped).map(([path128, { reaped: _reaped, ...record3 }]) => ({ path: path128, ...record3 }));
|
|
16848
|
+
}
|
|
16849
|
+
function readReapedWorktreeRegistry() {
|
|
16850
|
+
const data = loadJson(REGISTRY_FILE);
|
|
16851
|
+
return Object.entries(data).filter(([, record3]) => record3.reaped).map(([path128, { reaped: _reaped, ...record3 }]) => ({ path: path128, ...record3 }));
|
|
16852
|
+
}
|
|
16853
|
+
function worktreeAttributionIncludingReaped(path128) {
|
|
16854
|
+
const record3 = loadJson(REGISTRY_FILE)[path128];
|
|
16855
|
+
return record3 ? { clone: record3.clone, origin: record3.origin } : void 0;
|
|
16856
|
+
}
|
|
16857
|
+
function recordWorktree(path128, clone, origin) {
|
|
16858
|
+
const data = loadJson(REGISTRY_FILE);
|
|
16859
|
+
data[path128] = { clone, origin };
|
|
16860
|
+
saveJson(REGISTRY_FILE, data);
|
|
16861
|
+
}
|
|
16862
|
+
function recordWorktreeHarness(path128, harness) {
|
|
16863
|
+
const data = loadJson(REGISTRY_FILE);
|
|
16864
|
+
const record3 = data[path128];
|
|
16865
|
+
if (!record3 || record3.reaped || record3.harness === harness) return;
|
|
16866
|
+
data[path128] = { ...record3, harness };
|
|
16867
|
+
saveJson(REGISTRY_FILE, data);
|
|
16868
|
+
}
|
|
16869
|
+
function forgetWorktree(path128) {
|
|
16870
|
+
const data = loadJson(REGISTRY_FILE);
|
|
16871
|
+
const record3 = data[path128];
|
|
16872
|
+
if (!record3 || record3.reaped) return;
|
|
16873
|
+
data[path128] = { ...record3, reaped: true };
|
|
16874
|
+
saveJson(REGISTRY_FILE, data);
|
|
16875
|
+
}
|
|
16876
|
+
function markLeftover(path128, reason4) {
|
|
16877
|
+
const data = loadJson(REGISTRY_FILE);
|
|
16878
|
+
const record3 = data[path128];
|
|
16879
|
+
if (!record3) return;
|
|
16880
|
+
data[path128] = { ...record3, reaped: true, leftover: reason4 };
|
|
16881
|
+
saveJson(REGISTRY_FILE, data);
|
|
16882
|
+
}
|
|
16883
|
+
function clearLeftover(path128) {
|
|
16884
|
+
const data = loadJson(REGISTRY_FILE);
|
|
16885
|
+
const record3 = data[path128];
|
|
16886
|
+
if (!record3?.leftover) return;
|
|
16887
|
+
const { leftover: _leftover, ...rest } = record3;
|
|
16888
|
+
data[path128] = rest;
|
|
16889
|
+
saveJson(REGISTRY_FILE, data);
|
|
16890
|
+
}
|
|
16891
|
+
|
|
16892
|
+
// src/commands/sessions/daemon/worktree/listLeftovers.ts
|
|
16893
|
+
function listLeftovers() {
|
|
16894
|
+
const leftovers2 = [];
|
|
16895
|
+
for (const { path: path128, leftover } of readReapedWorktreeRegistry()) {
|
|
16896
|
+
if (!leftover) continue;
|
|
16897
|
+
if (existsSync31(path128)) leftovers2.push({ path: path128, reason: leftover });
|
|
16898
|
+
else clearLeftover(path128);
|
|
16899
|
+
}
|
|
16900
|
+
return leftovers2;
|
|
16901
|
+
}
|
|
16902
|
+
|
|
16903
|
+
// src/commands/sessions/daemon/worktree/reportLeftoversEnabled.ts
|
|
16904
|
+
function reportLeftoversEnabled() {
|
|
16905
|
+
return loadConfig().sessions?.reportLeftovers ?? true;
|
|
16906
|
+
}
|
|
16907
|
+
|
|
16908
|
+
// src/commands/sessions/daemon/worktree/leftoverReport.ts
|
|
16909
|
+
function leftoverReport() {
|
|
16910
|
+
const leftovers2 = reportLeftoversEnabled() ? listLeftovers() : [];
|
|
16911
|
+
return {
|
|
16912
|
+
nodeName: resolveNodeName(),
|
|
16913
|
+
leftovers: leftovers2,
|
|
16914
|
+
command: leftoverRemovalCommand(leftovers2)
|
|
16915
|
+
};
|
|
16916
|
+
}
|
|
16917
|
+
|
|
16918
|
+
// src/commands/sessions/web/leftovers.ts
|
|
16919
|
+
async function leftovers(_req, res) {
|
|
16920
|
+
respondJson(res, 200, leftoverReport());
|
|
16921
|
+
}
|
|
16922
|
+
|
|
16723
16923
|
// src/commands/sessions/nodes/fetchPeerJson.ts
|
|
16724
16924
|
var PEER_TIMEOUT_MS = 3e3;
|
|
16725
16925
|
function peerErrorCode(error) {
|
|
@@ -18542,17 +18742,17 @@ var autoRestartWait = {
|
|
|
18542
18742
|
|
|
18543
18743
|
// src/commands/extension/fetchLatestSignedExtension.ts
|
|
18544
18744
|
import { readFile as readFile2 } from "fs/promises";
|
|
18545
|
-
import { join as
|
|
18745
|
+
import { join as join39 } from "path";
|
|
18546
18746
|
|
|
18547
18747
|
// src/commands/extension/extensionDir.ts
|
|
18548
|
-
import { existsSync as
|
|
18549
|
-
import { dirname as dirname16, join as
|
|
18748
|
+
import { existsSync as existsSync32 } from "fs";
|
|
18749
|
+
import { dirname as dirname16, join as join38 } from "path";
|
|
18550
18750
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
18551
18751
|
var moduleDir = dirname16(fileURLToPath2(import.meta.url));
|
|
18552
18752
|
function extensionDir() {
|
|
18553
|
-
const bundled =
|
|
18554
|
-
if (
|
|
18555
|
-
return
|
|
18753
|
+
const bundled = join38(moduleDir, "commands", "extension", "extension");
|
|
18754
|
+
if (existsSync32(bundled)) return bundled;
|
|
18755
|
+
return join38(moduleDir, "..", "..", "..", "extension");
|
|
18556
18756
|
}
|
|
18557
18757
|
|
|
18558
18758
|
// src/commands/extension/latestUpdate.ts
|
|
@@ -18564,7 +18764,7 @@ function latestUpdate(manifest, updates2) {
|
|
|
18564
18764
|
// src/commands/extension/fetchLatestSignedExtension.ts
|
|
18565
18765
|
async function fetchLatestSignedExtension() {
|
|
18566
18766
|
const manifest = await readFile2(
|
|
18567
|
-
|
|
18767
|
+
join39(extensionDir(), "manifest.json"),
|
|
18568
18768
|
"utf8"
|
|
18569
18769
|
);
|
|
18570
18770
|
const updateUrl = JSON.parse(manifest).browser_specific_settings.gecko.update_url;
|
|
@@ -18591,7 +18791,7 @@ function latestSignedExtension(now = Date.now()) {
|
|
|
18591
18791
|
}
|
|
18592
18792
|
|
|
18593
18793
|
// src/commands/watch/isBuildPending.ts
|
|
18594
|
-
import { existsSync as
|
|
18794
|
+
import { existsSync as existsSync34 } from "fs";
|
|
18595
18795
|
|
|
18596
18796
|
// src/commands/watch/gitMarkerPath.ts
|
|
18597
18797
|
import { resolve as resolve11 } from "path";
|
|
@@ -18608,7 +18808,7 @@ function buildPendingPath(cwd) {
|
|
|
18608
18808
|
}
|
|
18609
18809
|
|
|
18610
18810
|
// src/commands/watch/readBuiltVersion.ts
|
|
18611
|
-
import { join as
|
|
18811
|
+
import { join as join41 } from "path";
|
|
18612
18812
|
|
|
18613
18813
|
// src/shared/readPackageJson.ts
|
|
18614
18814
|
import * as fs18 from "fs";
|
|
@@ -18658,7 +18858,7 @@ function findPackageJsonWithVerifyScripts(startDir) {
|
|
|
18658
18858
|
function readBuiltVersion(cwd) {
|
|
18659
18859
|
try {
|
|
18660
18860
|
const root2 = runGit3(["rev-parse", "--show-toplevel"], cwd);
|
|
18661
|
-
return readPackageJson(
|
|
18861
|
+
return readPackageJson(join41(root2, "package.json")).version ?? "unknown";
|
|
18662
18862
|
} catch {
|
|
18663
18863
|
return "unknown";
|
|
18664
18864
|
}
|
|
@@ -18666,11 +18866,11 @@ function readBuiltVersion(cwd) {
|
|
|
18666
18866
|
|
|
18667
18867
|
// src/commands/watch/readDistVersion.ts
|
|
18668
18868
|
import { readFileSync as readFileSync18 } from "fs";
|
|
18669
|
-
import { join as
|
|
18869
|
+
import { join as join42 } from "path";
|
|
18670
18870
|
function readDistVersion(cwd) {
|
|
18671
18871
|
try {
|
|
18672
18872
|
const root2 = runGit3(["rev-parse", "--show-toplevel"], cwd);
|
|
18673
|
-
return readFileSync18(
|
|
18873
|
+
return readFileSync18(join42(root2, "dist", "built-version"), "utf8").trim();
|
|
18674
18874
|
} catch {
|
|
18675
18875
|
return void 0;
|
|
18676
18876
|
}
|
|
@@ -18685,7 +18885,7 @@ function isDistBehind(cwd) {
|
|
|
18685
18885
|
// src/commands/watch/isBuildPending.ts
|
|
18686
18886
|
function markedPending(cwd) {
|
|
18687
18887
|
try {
|
|
18688
|
-
return
|
|
18888
|
+
return existsSync34(buildPendingPath(cwd));
|
|
18689
18889
|
} catch {
|
|
18690
18890
|
return false;
|
|
18691
18891
|
}
|
|
@@ -18781,7 +18981,7 @@ function stripAnsi(text18) {
|
|
|
18781
18981
|
// src/commands/sessions/daemon/worktree/watcherLogPath.ts
|
|
18782
18982
|
import { createHash } from "crypto";
|
|
18783
18983
|
import { homedir as homedir15 } from "os";
|
|
18784
|
-
import { basename as basename13, join as
|
|
18984
|
+
import { basename as basename13, join as join43 } from "path";
|
|
18785
18985
|
|
|
18786
18986
|
// src/commands/sessions/daemon/worktree/canonicalTreePath.ts
|
|
18787
18987
|
import { realpathSync as realpathSync2 } from "fs";
|
|
@@ -18798,8 +18998,8 @@ function canonicalTreePath(path128) {
|
|
|
18798
18998
|
function watcherLogPath(cwd) {
|
|
18799
18999
|
const clone = canonicalTreePath(cwd);
|
|
18800
19000
|
const key = createHash("sha1").update(clone).digest("hex").slice(0, 8);
|
|
18801
|
-
const dir = process.env.ASSIST_WATCHER_LOG_DIR ??
|
|
18802
|
-
return
|
|
19001
|
+
const dir = process.env.ASSIST_WATCHER_LOG_DIR ?? join43(homedir15(), ".assist", "watchers");
|
|
19002
|
+
return join43(dir, `${basename13(clone) || "root"}-${key}.log`);
|
|
18803
19003
|
}
|
|
18804
19004
|
|
|
18805
19005
|
// src/commands/sessions/web/updates/readUpdateHistory.ts
|
|
@@ -18932,7 +19132,7 @@ async function readRequestBuffer(req, limit) {
|
|
|
18932
19132
|
|
|
18933
19133
|
// src/commands/sessions/web/stageAttachment.ts
|
|
18934
19134
|
import { mkdir, mkdtemp, writeFile } from "fs/promises";
|
|
18935
|
-
import { extname as extname2, join as
|
|
19135
|
+
import { extname as extname2, join as join44 } from "path";
|
|
18936
19136
|
|
|
18937
19137
|
// src/commands/sessions/web/ghAttachableExtensions.ts
|
|
18938
19138
|
var ghAttachableExtensions = /* @__PURE__ */ new Set([
|
|
@@ -18964,9 +19164,9 @@ function safeBaseName(name2) {
|
|
|
18964
19164
|
async function stageAttachment(name2, contentType, body) {
|
|
18965
19165
|
const ext = pickExtension(name2, contentType);
|
|
18966
19166
|
await mkdir(stagedAttachmentsDir, { recursive: true });
|
|
18967
|
-
const dir = await mkdtemp(
|
|
19167
|
+
const dir = await mkdtemp(join44(stagedAttachmentsDir, "upload-"));
|
|
18968
19168
|
const alt = safeBaseName(name2);
|
|
18969
|
-
const filePath =
|
|
19169
|
+
const filePath = join44(dir, `${alt}.${ext}`);
|
|
18970
19170
|
await writeFile(filePath, body);
|
|
18971
19171
|
return { dir, filePath, alt };
|
|
18972
19172
|
}
|
|
@@ -19015,16 +19215,16 @@ import { readFile as readFile3, stat as stat3, writeFile as writeFile2 } from "f
|
|
|
19015
19215
|
|
|
19016
19216
|
// src/commands/sessions/web/formatWithOxfmt.ts
|
|
19017
19217
|
import { execFile as execFile13 } from "child_process";
|
|
19018
|
-
import { existsSync as
|
|
19019
|
-
import { dirname as dirname18, join as
|
|
19218
|
+
import { existsSync as existsSync35 } from "fs";
|
|
19219
|
+
import { dirname as dirname18, join as join45 } from "path";
|
|
19020
19220
|
import { promisify as promisify13 } from "util";
|
|
19021
19221
|
var execFileAsync11 = promisify13(execFile13);
|
|
19022
19222
|
var TIMEOUT_MS2 = 15e3;
|
|
19023
19223
|
function findOxfmtScript(root2) {
|
|
19024
19224
|
let dir = root2;
|
|
19025
19225
|
for (; ; ) {
|
|
19026
|
-
const candidate =
|
|
19027
|
-
if (
|
|
19226
|
+
const candidate = join45(dir, "node_modules", "oxfmt", "bin", "oxfmt");
|
|
19227
|
+
if (existsSync35(candidate)) return candidate;
|
|
19028
19228
|
const parent = dirname18(dir);
|
|
19029
19229
|
if (parent === dir) return void 0;
|
|
19030
19230
|
dir = parent;
|
|
@@ -19096,10 +19296,10 @@ async function writeFileContent(req, res) {
|
|
|
19096
19296
|
// src/shared/createBundleHandler.ts
|
|
19097
19297
|
import { createHash as createHash2 } from "crypto";
|
|
19098
19298
|
import { readFileSync as readFileSync19, statSync as statSync10 } from "fs";
|
|
19099
|
-
import { dirname as dirname19, join as
|
|
19299
|
+
import { dirname as dirname19, join as join46 } from "path";
|
|
19100
19300
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
19101
19301
|
function createBundleHandler(importMetaUrl, bundlePath, contentType = "application/javascript") {
|
|
19102
|
-
const file =
|
|
19302
|
+
const file = join46(dirname19(fileURLToPath3(importMetaUrl)), bundlePath);
|
|
19103
19303
|
let cache7;
|
|
19104
19304
|
return (req, res) => {
|
|
19105
19305
|
const mtimeMs = statSync10(file).mtimeMs;
|
|
@@ -19218,6 +19418,7 @@ var routes2 = {
|
|
|
19218
19418
|
"POST /api/pr-preview/upload-image": uploadPrImage,
|
|
19219
19419
|
"GET /api/pr-preview/image": previewImage,
|
|
19220
19420
|
"POST /api/restart": restartWeb,
|
|
19421
|
+
"GET /api/leftovers": leftovers,
|
|
19221
19422
|
"GET /api/node-doctor": nodeDoctor,
|
|
19222
19423
|
"POST /api/nodes/probe": postNodeProbe,
|
|
19223
19424
|
"POST /api/nodes/link": postNodeLink,
|
|
@@ -19543,8 +19744,8 @@ function scheduleReconnect() {
|
|
|
19543
19744
|
|
|
19544
19745
|
// src/commands/sessions/web/updates/autoRestart/autoRestartAttempts.ts
|
|
19545
19746
|
import { mkdirSync as mkdirSync12, readFileSync as readFileSync21, writeFileSync as writeFileSync10 } from "fs";
|
|
19546
|
-
import { dirname as dirname20, join as
|
|
19547
|
-
var defaultPath =
|
|
19747
|
+
import { dirname as dirname20, join as join47 } from "path";
|
|
19748
|
+
var defaultPath = join47(daemonPaths.dir, "auto-restart-attempts.json");
|
|
19548
19749
|
function read(path128) {
|
|
19549
19750
|
try {
|
|
19550
19751
|
return JSON.parse(readFileSync21(path128, "utf8"));
|
|
@@ -19767,9 +19968,9 @@ function originForCwd(cwd) {
|
|
|
19767
19968
|
}
|
|
19768
19969
|
|
|
19769
19970
|
// src/commands/sessions/daemon/repoDirExists.ts
|
|
19770
|
-
import { existsSync as
|
|
19971
|
+
import { existsSync as existsSync36 } from "fs";
|
|
19771
19972
|
function repoDirExists(cwd) {
|
|
19772
|
-
return
|
|
19973
|
+
return existsSync36(cwd);
|
|
19773
19974
|
}
|
|
19774
19975
|
|
|
19775
19976
|
// src/commands/sessions/daemon/worktree/git.ts
|
|
@@ -19866,55 +20067,6 @@ function gitCommonDir(cwd) {
|
|
|
19866
20067
|
]);
|
|
19867
20068
|
}
|
|
19868
20069
|
|
|
19869
|
-
// src/commands/sessions/daemon/worktree/readWorktreeRegistry.ts
|
|
19870
|
-
var REGISTRY_FILE = "worktrees.json";
|
|
19871
|
-
function readWorktreeRegistry() {
|
|
19872
|
-
const data = loadJson(REGISTRY_FILE);
|
|
19873
|
-
return Object.entries(data).filter(([, record3]) => !record3.reaped).map(([path128, { reaped: _reaped, ...record3 }]) => ({ path: path128, ...record3 }));
|
|
19874
|
-
}
|
|
19875
|
-
function readReapedWorktreeRegistry() {
|
|
19876
|
-
const data = loadJson(REGISTRY_FILE);
|
|
19877
|
-
return Object.entries(data).filter(([, record3]) => record3.reaped).map(([path128, { reaped: _reaped, ...record3 }]) => ({ path: path128, ...record3 }));
|
|
19878
|
-
}
|
|
19879
|
-
function worktreeAttributionIncludingReaped(path128) {
|
|
19880
|
-
const record3 = loadJson(REGISTRY_FILE)[path128];
|
|
19881
|
-
return record3 ? { clone: record3.clone, origin: record3.origin } : void 0;
|
|
19882
|
-
}
|
|
19883
|
-
function recordWorktree(path128, clone, origin) {
|
|
19884
|
-
const data = loadJson(REGISTRY_FILE);
|
|
19885
|
-
data[path128] = { clone, origin };
|
|
19886
|
-
saveJson(REGISTRY_FILE, data);
|
|
19887
|
-
}
|
|
19888
|
-
function recordWorktreeHarness(path128, harness) {
|
|
19889
|
-
const data = loadJson(REGISTRY_FILE);
|
|
19890
|
-
const record3 = data[path128];
|
|
19891
|
-
if (!record3 || record3.reaped || record3.harness === harness) return;
|
|
19892
|
-
data[path128] = { ...record3, harness };
|
|
19893
|
-
saveJson(REGISTRY_FILE, data);
|
|
19894
|
-
}
|
|
19895
|
-
function forgetWorktree(path128) {
|
|
19896
|
-
const data = loadJson(REGISTRY_FILE);
|
|
19897
|
-
const record3 = data[path128];
|
|
19898
|
-
if (!record3 || record3.reaped) return;
|
|
19899
|
-
data[path128] = { ...record3, reaped: true };
|
|
19900
|
-
saveJson(REGISTRY_FILE, data);
|
|
19901
|
-
}
|
|
19902
|
-
function markLeftover(path128, reason4) {
|
|
19903
|
-
const data = loadJson(REGISTRY_FILE);
|
|
19904
|
-
const record3 = data[path128];
|
|
19905
|
-
if (!record3) return;
|
|
19906
|
-
data[path128] = { ...record3, reaped: true, leftover: reason4 };
|
|
19907
|
-
saveJson(REGISTRY_FILE, data);
|
|
19908
|
-
}
|
|
19909
|
-
function clearLeftover(path128) {
|
|
19910
|
-
const data = loadJson(REGISTRY_FILE);
|
|
19911
|
-
const record3 = data[path128];
|
|
19912
|
-
if (!record3?.leftover) return;
|
|
19913
|
-
const { leftover: _leftover, ...rest } = record3;
|
|
19914
|
-
data[path128] = rest;
|
|
19915
|
-
saveJson(REGISTRY_FILE, data);
|
|
19916
|
-
}
|
|
19917
|
-
|
|
19918
20070
|
// src/commands/sessions/daemon/repoGroupForCwd.ts
|
|
19919
20071
|
var cache6 = /* @__PURE__ */ new Map();
|
|
19920
20072
|
function repoGroupForCwd(cwd) {
|
|
@@ -20287,17 +20439,17 @@ import * as path27 from "path";
|
|
|
20287
20439
|
import chalk22 from "chalk";
|
|
20288
20440
|
|
|
20289
20441
|
// src/commands/verify/addToKnipIgnoreBinaries.ts
|
|
20290
|
-
import { existsSync as
|
|
20291
|
-
import { join as
|
|
20442
|
+
import { existsSync as existsSync37, readFileSync as readFileSync22, writeFileSync as writeFileSync12 } from "fs";
|
|
20443
|
+
import { join as join48 } from "path";
|
|
20292
20444
|
import chalk21 from "chalk";
|
|
20293
20445
|
function loadKnipConfig(knipJsonPath) {
|
|
20294
|
-
if (
|
|
20446
|
+
if (existsSync37(knipJsonPath)) {
|
|
20295
20447
|
return JSON.parse(readFileSync22(knipJsonPath, "utf8"));
|
|
20296
20448
|
}
|
|
20297
20449
|
return { $schema: "https://unpkg.com/knip@5/schema.json" };
|
|
20298
20450
|
}
|
|
20299
20451
|
function addToKnipIgnoreBinaries(cwd, binary) {
|
|
20300
|
-
const knipJsonPath =
|
|
20452
|
+
const knipJsonPath = join48(cwd, "knip.json");
|
|
20301
20453
|
try {
|
|
20302
20454
|
const knipConfig = loadKnipConfig(knipJsonPath);
|
|
20303
20455
|
const ignoreBinaries = knipConfig.ignoreBinaries ?? [];
|
|
@@ -20344,7 +20496,7 @@ import * as path29 from "path";
|
|
|
20344
20496
|
import chalk27 from "chalk";
|
|
20345
20497
|
|
|
20346
20498
|
// src/commands/format/init.ts
|
|
20347
|
-
import { existsSync as
|
|
20499
|
+
import { existsSync as existsSync38, readFileSync as readFileSync23, writeFileSync as writeFileSync13 } from "fs";
|
|
20348
20500
|
import chalk25 from "chalk";
|
|
20349
20501
|
|
|
20350
20502
|
// src/utils/printDiff.ts
|
|
@@ -20387,7 +20539,7 @@ async function init() {
|
|
|
20387
20539
|
const newContent = `${JSON.stringify(oxfmtrc_template_default, null, " ")}
|
|
20388
20540
|
`;
|
|
20389
20541
|
const configPath = ".oxfmtrc.json";
|
|
20390
|
-
const oldContent =
|
|
20542
|
+
const oldContent = existsSync38(configPath) ? readFileSync23(configPath, "utf8") : "";
|
|
20391
20543
|
if (oldContent === newContent) {
|
|
20392
20544
|
console.log(".oxfmtrc.json already has the baseline formatter config");
|
|
20393
20545
|
return;
|
|
@@ -20410,15 +20562,15 @@ async function init() {
|
|
|
20410
20562
|
}
|
|
20411
20563
|
|
|
20412
20564
|
// src/commands/lint/init.ts
|
|
20413
|
-
import { existsSync as
|
|
20565
|
+
import { existsSync as existsSync41, readFileSync as readFileSync25, writeFileSync as writeFileSync15 } from "fs";
|
|
20414
20566
|
import chalk26 from "chalk";
|
|
20415
20567
|
|
|
20416
20568
|
// src/shared/removeEslint.ts
|
|
20417
20569
|
import { execSync as execSync7 } from "child_process";
|
|
20418
|
-
import { existsSync as
|
|
20570
|
+
import { existsSync as existsSync40, readFileSync as readFileSync24, writeFileSync as writeFileSync14 } from "fs";
|
|
20419
20571
|
|
|
20420
20572
|
// src/shared/removeEslint/removeEslintConfigFiles.ts
|
|
20421
|
-
import { existsSync as
|
|
20573
|
+
import { existsSync as existsSync39, unlinkSync as unlinkSync3 } from "fs";
|
|
20422
20574
|
var ESLINT_CONFIG_FILES = [
|
|
20423
20575
|
"eslint.config.js",
|
|
20424
20576
|
"eslint.config.mjs",
|
|
@@ -20434,7 +20586,7 @@ var ESLINT_CONFIG_FILES = [
|
|
|
20434
20586
|
function removeEslintConfigFiles() {
|
|
20435
20587
|
let removed = false;
|
|
20436
20588
|
for (const configFile of ESLINT_CONFIG_FILES) {
|
|
20437
|
-
if (
|
|
20589
|
+
if (existsSync39(configFile)) {
|
|
20438
20590
|
unlinkSync3(configFile);
|
|
20439
20591
|
console.log(`Removed ${configFile}`);
|
|
20440
20592
|
removed = true;
|
|
@@ -20456,7 +20608,7 @@ function removeEslint(options2 = {}) {
|
|
|
20456
20608
|
}
|
|
20457
20609
|
function removeEslintFromPackageJson(options2) {
|
|
20458
20610
|
const packageJsonPath = "package.json";
|
|
20459
|
-
if (!
|
|
20611
|
+
if (!existsSync40(packageJsonPath)) {
|
|
20460
20612
|
return false;
|
|
20461
20613
|
}
|
|
20462
20614
|
const packageJson = JSON.parse(readFileSync24(packageJsonPath, "utf8"));
|
|
@@ -20523,7 +20675,7 @@ async function writeOxlintConfig() {
|
|
|
20523
20675
|
const newContent = `${JSON.stringify(oxlintrc_template_default, null, " ")}
|
|
20524
20676
|
`;
|
|
20525
20677
|
const configPath = ".oxlintrc.json";
|
|
20526
|
-
const oldContent =
|
|
20678
|
+
const oldContent = existsSync41(configPath) ? readFileSync25(configPath, "utf8") : "";
|
|
20527
20679
|
if (oldContent === newContent) {
|
|
20528
20680
|
console.log(".oxlintrc.json already has the baseline linter config");
|
|
20529
20681
|
return;
|
|
@@ -21000,7 +21152,7 @@ function printMeasureTable(records, totalMs) {
|
|
|
21000
21152
|
import * as path38 from "path";
|
|
21001
21153
|
|
|
21002
21154
|
// src/shared/shellQuote.ts
|
|
21003
|
-
function
|
|
21155
|
+
function shellQuote2(arg) {
|
|
21004
21156
|
if (/[^a-zA-Z0-9_./:=@%^+,-]/.test(arg)) {
|
|
21005
21157
|
if (process.platform === "win32") {
|
|
21006
21158
|
return `"${arg.replace(/"/g, String.raw`\"`)}"`;
|
|
@@ -21057,7 +21209,7 @@ function selectEntriesForMode(entries2, mode) {
|
|
|
21057
21209
|
|
|
21058
21210
|
// src/commands/verify/run/resolveEntries.ts
|
|
21059
21211
|
function buildFullCommand(command, args) {
|
|
21060
|
-
return [
|
|
21212
|
+
return [shellQuote2(command), ...(args ?? []).map(shellQuote2)].join(" ");
|
|
21061
21213
|
}
|
|
21062
21214
|
function getRunEntries() {
|
|
21063
21215
|
const { run: run5 } = loadConfig();
|
|
@@ -21311,7 +21463,7 @@ async function newCli() {
|
|
|
21311
21463
|
|
|
21312
21464
|
// src/commands/new/registerNew/newProject.ts
|
|
21313
21465
|
import { execSync as execSync14 } from "child_process";
|
|
21314
|
-
import { existsSync as
|
|
21466
|
+
import { existsSync as existsSync46, readFileSync as readFileSync29, writeFileSync as writeFileSync22 } from "fs";
|
|
21315
21467
|
|
|
21316
21468
|
// src/commands/deploy/init.ts
|
|
21317
21469
|
import { execSync as execSync13 } from "child_process";
|
|
@@ -21319,14 +21471,14 @@ import chalk37 from "chalk";
|
|
|
21319
21471
|
import enquirer3 from "enquirer";
|
|
21320
21472
|
|
|
21321
21473
|
// src/commands/deploy/init/updateWorkflow.ts
|
|
21322
|
-
import { existsSync as
|
|
21323
|
-
import { dirname as dirname28, join as
|
|
21474
|
+
import { existsSync as existsSync45, mkdirSync as mkdirSync15, readFileSync as readFileSync28, writeFileSync as writeFileSync21 } from "fs";
|
|
21475
|
+
import { dirname as dirname28, join as join55 } from "path";
|
|
21324
21476
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
21325
21477
|
import chalk36 from "chalk";
|
|
21326
21478
|
var WORKFLOW_PATH = ".github/workflows/build.yml";
|
|
21327
21479
|
var __dirname3 = dirname28(fileURLToPath4(import.meta.url));
|
|
21328
21480
|
function getExistingSiteId() {
|
|
21329
|
-
if (!
|
|
21481
|
+
if (!existsSync45(WORKFLOW_PATH)) {
|
|
21330
21482
|
return null;
|
|
21331
21483
|
}
|
|
21332
21484
|
const content = readFileSync28(WORKFLOW_PATH, "utf8");
|
|
@@ -21334,17 +21486,17 @@ function getExistingSiteId() {
|
|
|
21334
21486
|
return match ? match[1] : null;
|
|
21335
21487
|
}
|
|
21336
21488
|
function getTemplateContent(siteId) {
|
|
21337
|
-
const templatePath =
|
|
21489
|
+
const templatePath = join55(__dirname3, "commands/deploy/build.yml");
|
|
21338
21490
|
const template = readFileSync28(templatePath, "utf8");
|
|
21339
21491
|
return template.replace("{{NETLIFY_SITE_ID}}", siteId);
|
|
21340
21492
|
}
|
|
21341
21493
|
async function updateWorkflow(siteId) {
|
|
21342
21494
|
const newContent = getTemplateContent(siteId);
|
|
21343
21495
|
const workflowDir = ".github/workflows";
|
|
21344
|
-
if (!
|
|
21496
|
+
if (!existsSync45(workflowDir)) {
|
|
21345
21497
|
mkdirSync15(workflowDir, { recursive: true });
|
|
21346
21498
|
}
|
|
21347
|
-
if (
|
|
21499
|
+
if (existsSync45(WORKFLOW_PATH)) {
|
|
21348
21500
|
const oldContent = readFileSync28(WORKFLOW_PATH, "utf8");
|
|
21349
21501
|
if (oldContent === newContent) {
|
|
21350
21502
|
console.log(chalk36.green("build.yml is already up to date"));
|
|
@@ -21439,7 +21591,7 @@ async function newProject() {
|
|
|
21439
21591
|
}
|
|
21440
21592
|
function addViteBaseConfig() {
|
|
21441
21593
|
const viteConfigPath = "vite.config.ts";
|
|
21442
|
-
if (!
|
|
21594
|
+
if (!existsSync46(viteConfigPath)) {
|
|
21443
21595
|
console.log("No vite.config.ts found, skipping base config");
|
|
21444
21596
|
return;
|
|
21445
21597
|
}
|
|
@@ -21642,18 +21794,18 @@ function adviceContextFor(cwd, env = process.env) {
|
|
|
21642
21794
|
}
|
|
21643
21795
|
|
|
21644
21796
|
// src/commands/advise/loadAdviceFragments.ts
|
|
21645
|
-
import { readdirSync as
|
|
21646
|
-
import { basename as basename15, join as
|
|
21797
|
+
import { readdirSync as readdirSync11, readFileSync as readFileSync30 } from "fs";
|
|
21798
|
+
import { basename as basename15, join as join57 } from "path";
|
|
21647
21799
|
|
|
21648
21800
|
// src/commands/advise/adviceDir.ts
|
|
21649
|
-
import { existsSync as
|
|
21650
|
-
import { dirname as dirname29, join as
|
|
21801
|
+
import { existsSync as existsSync47 } from "fs";
|
|
21802
|
+
import { dirname as dirname29, join as join56 } from "path";
|
|
21651
21803
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
21652
21804
|
function adviceDir() {
|
|
21653
21805
|
let current2 = dirname29(fileURLToPath5(import.meta.url));
|
|
21654
21806
|
while (current2 !== dirname29(current2)) {
|
|
21655
|
-
const candidate =
|
|
21656
|
-
if (
|
|
21807
|
+
const candidate = join56(current2, "agent", "advice");
|
|
21808
|
+
if (existsSync47(candidate)) return candidate;
|
|
21657
21809
|
current2 = dirname29(current2);
|
|
21658
21810
|
}
|
|
21659
21811
|
throw new Error("Could not locate the shipped agent/advice directory");
|
|
@@ -21682,10 +21834,10 @@ function parseAdviceFragment(name2, content) {
|
|
|
21682
21834
|
|
|
21683
21835
|
// src/commands/advise/loadAdviceFragments.ts
|
|
21684
21836
|
function loadAdviceFragments(dir = adviceDir()) {
|
|
21685
|
-
return
|
|
21837
|
+
return readdirSync11(dir).filter((file) => file.endsWith(".md")).sort().map(
|
|
21686
21838
|
(file) => parseAdviceFragment(
|
|
21687
21839
|
basename15(file, ".md"),
|
|
21688
|
-
readFileSync30(
|
|
21840
|
+
readFileSync30(join57(dir, file), "utf8")
|
|
21689
21841
|
)
|
|
21690
21842
|
);
|
|
21691
21843
|
}
|
|
@@ -21719,13 +21871,13 @@ function renderAdviceBody(fragment, context) {
|
|
|
21719
21871
|
}
|
|
21720
21872
|
|
|
21721
21873
|
// src/commands/advise/adviceConditions.ts
|
|
21722
|
-
import { existsSync as
|
|
21723
|
-
import { join as
|
|
21874
|
+
import { existsSync as existsSync48 } from "fs";
|
|
21875
|
+
import { join as join58 } from "path";
|
|
21724
21876
|
function repoFile(file, label) {
|
|
21725
21877
|
return {
|
|
21726
21878
|
whenMet: `the repo has ${label}`,
|
|
21727
21879
|
whenUnmet: `the repo has no ${label}`,
|
|
21728
|
-
matches: ({ rootDir }) =>
|
|
21880
|
+
matches: ({ rootDir }) => existsSync48(join58(rootDir, file))
|
|
21729
21881
|
};
|
|
21730
21882
|
}
|
|
21731
21883
|
var adviceConditions = {
|
|
@@ -21751,11 +21903,11 @@ var adviceConditions = {
|
|
|
21751
21903
|
},
|
|
21752
21904
|
typescript: repoFile("tsconfig.json", "a tsconfig.json"),
|
|
21753
21905
|
filenameConvention: repoFile(
|
|
21754
|
-
|
|
21906
|
+
join58("oxlint-rules", "filenameConvention.ts"),
|
|
21755
21907
|
"oxlint-rules/filenameConvention.ts"
|
|
21756
21908
|
),
|
|
21757
21909
|
claudeSettings: repoFile(
|
|
21758
|
-
|
|
21910
|
+
join58("claude", "settings.json"),
|
|
21759
21911
|
"claude/settings.json"
|
|
21760
21912
|
),
|
|
21761
21913
|
verify: {
|
|
@@ -22701,7 +22853,7 @@ function registerAskQuestion(program) {
|
|
|
22701
22853
|
|
|
22702
22854
|
// src/commands/registerBackup.ts
|
|
22703
22855
|
import { mkdir as mkdir3, stat as stat4 } from "fs/promises";
|
|
22704
|
-
import { join as
|
|
22856
|
+
import { join as join60, resolve as resolve16 } from "path";
|
|
22705
22857
|
import chalk42 from "chalk";
|
|
22706
22858
|
|
|
22707
22859
|
// src/shared/db/recordBackup.ts
|
|
@@ -22715,7 +22867,7 @@ async function recordBackup(db, {
|
|
|
22715
22867
|
|
|
22716
22868
|
// src/commands/backup/scheduleBackup.ts
|
|
22717
22869
|
import { mkdir as mkdir2 } from "fs/promises";
|
|
22718
|
-
import { join as
|
|
22870
|
+
import { join as join59 } from "path";
|
|
22719
22871
|
import chalk40 from "chalk";
|
|
22720
22872
|
|
|
22721
22873
|
// src/commands/backup/readCrontab.ts
|
|
@@ -22857,7 +23009,7 @@ async function scheduleBackup({
|
|
|
22857
23009
|
const cronExpr = durationToCron(every);
|
|
22858
23010
|
const dir = expandTilde(loadConfig().backup.dir);
|
|
22859
23011
|
await mkdir2(dir, { recursive: true });
|
|
22860
|
-
const logPath2 =
|
|
23012
|
+
const logPath2 = join59(dir, "cron.log");
|
|
22861
23013
|
const cronLine = `${cronExpr} ${resolveAssistCommand()} backup >> ${logPath2} 2>&1`;
|
|
22862
23014
|
writeCrontab(upsertScheduleBlock(readCrontab(), every, cronLine));
|
|
22863
23015
|
console.error(
|
|
@@ -23036,7 +23188,7 @@ async function backup({ out }) {
|
|
|
23036
23188
|
await mkdir3(dir, { recursive: true });
|
|
23037
23189
|
const start2 = Date.now();
|
|
23038
23190
|
const timestamp9 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
23039
|
-
const filePath = resolve16(
|
|
23191
|
+
const filePath = resolve16(join60(dir, `backup-${timestamp9}.dump`));
|
|
23040
23192
|
await exportBacklog(filePath);
|
|
23041
23193
|
const { size } = await stat4(filePath);
|
|
23042
23194
|
const durationMs = Date.now() - start2;
|
|
@@ -23565,7 +23717,7 @@ function registerAssociateJiraCommand(cmd) {
|
|
|
23565
23717
|
|
|
23566
23718
|
// src/commands/backlog/cloneRepo.ts
|
|
23567
23719
|
import { spawnSync as spawnSync6 } from "child_process";
|
|
23568
|
-
import { existsSync as
|
|
23720
|
+
import { existsSync as existsSync49 } from "fs";
|
|
23569
23721
|
import { mkdir as mkdir4 } from "fs/promises";
|
|
23570
23722
|
import chalk49 from "chalk";
|
|
23571
23723
|
|
|
@@ -23601,7 +23753,7 @@ async function cloneRepo(originRaw) {
|
|
|
23601
23753
|
if (!target) {
|
|
23602
23754
|
return fail3(`Could not derive a repository name from "${origin}".`);
|
|
23603
23755
|
}
|
|
23604
|
-
if (
|
|
23756
|
+
if (existsSync49(target)) {
|
|
23605
23757
|
return fail3(`Clone target already exists: ${target}`);
|
|
23606
23758
|
}
|
|
23607
23759
|
await mkdir4(baseDir, { recursive: true });
|
|
@@ -23947,7 +24099,7 @@ function ensureRemoteOrigin() {
|
|
|
23947
24099
|
import { spawnSync as spawnSync7 } from "child_process";
|
|
23948
24100
|
import { mkdtempSync, readFileSync as readFileSync32, unlinkSync as unlinkSync4, writeFileSync as writeFileSync23 } from "fs";
|
|
23949
24101
|
import { tmpdir as tmpdir2 } from "os";
|
|
23950
|
-
import { join as
|
|
24102
|
+
import { join as join61 } from "path";
|
|
23951
24103
|
import enquirer4 from "enquirer";
|
|
23952
24104
|
async function promptType() {
|
|
23953
24105
|
const { type } = await enquirer4.prompt({
|
|
@@ -23987,8 +24139,8 @@ async function promptDescription() {
|
|
|
23987
24139
|
}
|
|
23988
24140
|
function openEditor() {
|
|
23989
24141
|
const editor = process.env.EDITOR || process.env.VISUAL || "vi";
|
|
23990
|
-
const dir = mkdtempSync(
|
|
23991
|
-
const filePath =
|
|
24142
|
+
const dir = mkdtempSync(join61(tmpdir2(), "assist-"));
|
|
24143
|
+
const filePath = join61(dir, "description.md");
|
|
23992
24144
|
writeFileSync23(filePath, "");
|
|
23993
24145
|
const result = spawnSync7(editor, [filePath], { stdio: "inherit" });
|
|
23994
24146
|
if (result.status !== 0) {
|
|
@@ -24474,9 +24626,9 @@ async function findPredecessor(path128, token, startedAt) {
|
|
|
24474
24626
|
|
|
24475
24627
|
// src/commands/backlog/propose/proposalLedgerPath.ts
|
|
24476
24628
|
import { homedir as homedir16 } from "os";
|
|
24477
|
-
import { join as
|
|
24629
|
+
import { join as join62 } from "path";
|
|
24478
24630
|
function proposalLedgerPath(sessionId2) {
|
|
24479
|
-
return
|
|
24631
|
+
return join62(homedir16(), ".assist", "proposals", `session-${sessionId2}.json`);
|
|
24480
24632
|
}
|
|
24481
24633
|
|
|
24482
24634
|
// src/commands/backlog/propose/trackProposal.ts
|
|
@@ -24837,7 +24989,7 @@ import chalk70 from "chalk";
|
|
|
24837
24989
|
|
|
24838
24990
|
// src/shared/waitForIndexUnlocked.ts
|
|
24839
24991
|
import { execSync as execSync18 } from "child_process";
|
|
24840
|
-
import { existsSync as
|
|
24992
|
+
import { existsSync as existsSync50 } from "fs";
|
|
24841
24993
|
import { resolve as resolve17 } from "path";
|
|
24842
24994
|
var POLL_MS2 = 200;
|
|
24843
24995
|
function indexLockPath() {
|
|
@@ -24858,7 +25010,7 @@ function waitForIndexUnlocked(timeoutMs) {
|
|
|
24858
25010
|
const lock2 = indexLockPath();
|
|
24859
25011
|
if (!lock2) return true;
|
|
24860
25012
|
const deadline = Date.now() + timeoutMs;
|
|
24861
|
-
while (
|
|
25013
|
+
while (existsSync50(lock2)) {
|
|
24862
25014
|
if (Date.now() >= deadline) return false;
|
|
24863
25015
|
sleepSync(POLL_MS2);
|
|
24864
25016
|
}
|
|
@@ -24974,14 +25126,14 @@ function hasLocalChanges() {
|
|
|
24974
25126
|
|
|
24975
25127
|
// src/commands/backlog/acquireLock.ts
|
|
24976
25128
|
import {
|
|
24977
|
-
existsSync as
|
|
25129
|
+
existsSync as existsSync51,
|
|
24978
25130
|
mkdirSync as mkdirSync17,
|
|
24979
25131
|
readFileSync as readFileSync35,
|
|
24980
25132
|
unlinkSync as unlinkSync5,
|
|
24981
25133
|
writeFileSync as writeFileSync25
|
|
24982
25134
|
} from "fs";
|
|
24983
25135
|
import { homedir as homedir17 } from "os";
|
|
24984
|
-
import { join as
|
|
25136
|
+
import { join as join63 } from "path";
|
|
24985
25137
|
|
|
24986
25138
|
// src/commands/backlog/bootedAt.ts
|
|
24987
25139
|
import { uptime } from "os";
|
|
@@ -25017,10 +25169,10 @@ function isStaleLock(pid, timestamp9) {
|
|
|
25017
25169
|
|
|
25018
25170
|
// src/commands/backlog/acquireLock.ts
|
|
25019
25171
|
function getLocksDir() {
|
|
25020
|
-
return
|
|
25172
|
+
return join63(homedir17(), ".assist", "locks");
|
|
25021
25173
|
}
|
|
25022
25174
|
function getLockPath(itemId2) {
|
|
25023
|
-
return
|
|
25175
|
+
return join63(getLocksDir(), `lock-${itemId2}.json`);
|
|
25024
25176
|
}
|
|
25025
25177
|
function isProcessAlive(pid) {
|
|
25026
25178
|
try {
|
|
@@ -25032,7 +25184,7 @@ function isProcessAlive(pid) {
|
|
|
25032
25184
|
}
|
|
25033
25185
|
function foreignLockHolder(itemId2) {
|
|
25034
25186
|
const lockPath = getLockPath(itemId2);
|
|
25035
|
-
if (!
|
|
25187
|
+
if (!existsSync51(lockPath)) return null;
|
|
25036
25188
|
try {
|
|
25037
25189
|
const lock2 = JSON.parse(readFileSync35(lockPath, "utf8"));
|
|
25038
25190
|
if (typeof lock2.pid !== "number" || lock2.pid === process.pid) return null;
|
|
@@ -25160,7 +25312,7 @@ async function createBranch({
|
|
|
25160
25312
|
let baseRef;
|
|
25161
25313
|
if (from) {
|
|
25162
25314
|
try {
|
|
25163
|
-
execSync23(`git rev-parse --verify ${
|
|
25315
|
+
execSync23(`git rev-parse --verify ${shellQuote2(from)}`, {
|
|
25164
25316
|
stdio: ["pipe", "pipe", "pipe"]
|
|
25165
25317
|
});
|
|
25166
25318
|
} catch {
|
|
@@ -25170,7 +25322,7 @@ async function createBranch({
|
|
|
25170
25322
|
} else {
|
|
25171
25323
|
baseRef = `origin/${resolveDefaultBranch(config.branch?.defaultBranch)}`;
|
|
25172
25324
|
}
|
|
25173
|
-
execSync23(`git switch -c ${
|
|
25325
|
+
execSync23(`git switch -c ${shellQuote2(branchName)} ${shellQuote2(baseRef)}`, {
|
|
25174
25326
|
stdio: "inherit"
|
|
25175
25327
|
});
|
|
25176
25328
|
await recordBranchActivity(branchName);
|
|
@@ -25313,7 +25465,7 @@ function adoptRecordedBranch(item, branch2) {
|
|
|
25313
25465
|
} catch {
|
|
25314
25466
|
}
|
|
25315
25467
|
try {
|
|
25316
|
-
execSync24(`git switch ${
|
|
25468
|
+
execSync24(`git switch ${shellQuote2(branch2)}`, { stdio: "pipe" });
|
|
25317
25469
|
log(
|
|
25318
25470
|
item,
|
|
25319
25471
|
`branch ${branch2} already recorded; switched off ${parked} onto it`
|
|
@@ -25491,14 +25643,14 @@ async function resumeDoneConversation({ item, resumeSessionId }, spawnOptions) {
|
|
|
25491
25643
|
}
|
|
25492
25644
|
|
|
25493
25645
|
// src/commands/backlog/consumePause.ts
|
|
25494
|
-
import { existsSync as
|
|
25646
|
+
import { existsSync as existsSync52, mkdirSync as mkdirSync18, unlinkSync as unlinkSync6, writeFileSync as writeFileSync26 } from "fs";
|
|
25495
25647
|
import { homedir as homedir18 } from "os";
|
|
25496
|
-
import { join as
|
|
25648
|
+
import { join as join64 } from "path";
|
|
25497
25649
|
function getControlsDir() {
|
|
25498
|
-
return
|
|
25650
|
+
return join64(homedir18(), ".assist", "controls");
|
|
25499
25651
|
}
|
|
25500
25652
|
function getPausePath(itemId2) {
|
|
25501
|
-
return
|
|
25653
|
+
return join64(getControlsDir(), `pause-${itemId2}.json`);
|
|
25502
25654
|
}
|
|
25503
25655
|
function requestPause(itemId2) {
|
|
25504
25656
|
mkdirSync18(getControlsDir(), { recursive: true });
|
|
@@ -25508,7 +25660,7 @@ function requestPause(itemId2) {
|
|
|
25508
25660
|
);
|
|
25509
25661
|
}
|
|
25510
25662
|
function isPausePending(itemId2) {
|
|
25511
|
-
return
|
|
25663
|
+
return existsSync52(getPausePath(itemId2));
|
|
25512
25664
|
}
|
|
25513
25665
|
function clearPause(itemId2) {
|
|
25514
25666
|
try {
|
|
@@ -25518,7 +25670,7 @@ function clearPause(itemId2) {
|
|
|
25518
25670
|
}
|
|
25519
25671
|
function consumePause(itemId2) {
|
|
25520
25672
|
const pausePath = getPausePath(itemId2);
|
|
25521
|
-
if (!
|
|
25673
|
+
if (!existsSync52(pausePath)) return false;
|
|
25522
25674
|
try {
|
|
25523
25675
|
unlinkSync6(pausePath);
|
|
25524
25676
|
} catch {
|
|
@@ -25639,13 +25791,13 @@ function logHookFired(status2, sessionId2, source) {
|
|
|
25639
25791
|
}
|
|
25640
25792
|
|
|
25641
25793
|
// src/commands/backlog/watchForMarker.ts
|
|
25642
|
-
import { existsSync as
|
|
25794
|
+
import { existsSync as existsSync54, unwatchFile, watchFile } from "fs";
|
|
25643
25795
|
|
|
25644
25796
|
// src/commands/backlog/readSignal.ts
|
|
25645
|
-
import { existsSync as
|
|
25797
|
+
import { existsSync as existsSync53, readFileSync as readFileSync36 } from "fs";
|
|
25646
25798
|
function readSignal() {
|
|
25647
25799
|
const path128 = getSignalPath();
|
|
25648
|
-
if (!path128 || !
|
|
25800
|
+
if (!path128 || !existsSync53(path128)) return void 0;
|
|
25649
25801
|
try {
|
|
25650
25802
|
return JSON.parse(readFileSync36(path128, "utf8"));
|
|
25651
25803
|
} catch {
|
|
@@ -25659,7 +25811,7 @@ function watchForMarker(child2, options2) {
|
|
|
25659
25811
|
const statusPath = getSignalPath();
|
|
25660
25812
|
if (!statusPath) return { killedOnMarker: () => killed };
|
|
25661
25813
|
watchFile(statusPath, { interval: 1e3 }, () => {
|
|
25662
|
-
if (!
|
|
25814
|
+
if (!existsSync54(statusPath)) return;
|
|
25663
25815
|
const signal = readSignal();
|
|
25664
25816
|
if (!signal) return;
|
|
25665
25817
|
if (signal.event === "done" && !options2?.actOnDone) return;
|
|
@@ -25716,7 +25868,7 @@ function launchPhaseSession(item, phaseNumber, phase, phaseLabel2, claudeSession
|
|
|
25716
25868
|
}
|
|
25717
25869
|
|
|
25718
25870
|
// src/commands/backlog/resolvePhaseResult.ts
|
|
25719
|
-
import { existsSync as
|
|
25871
|
+
import { existsSync as existsSync55, unlinkSync as unlinkSync7 } from "fs";
|
|
25720
25872
|
import chalk80 from "chalk";
|
|
25721
25873
|
|
|
25722
25874
|
// src/commands/backlog/handleIncompletePhase.ts
|
|
@@ -25738,7 +25890,7 @@ async function handleIncompletePhase() {
|
|
|
25738
25890
|
// src/commands/backlog/resolvePhaseResult.ts
|
|
25739
25891
|
function cleanupSignal() {
|
|
25740
25892
|
const statusPath = getSignalPath();
|
|
25741
|
-
if (statusPath &&
|
|
25893
|
+
if (statusPath && existsSync55(statusPath)) {
|
|
25742
25894
|
unlinkSync7(statusPath);
|
|
25743
25895
|
}
|
|
25744
25896
|
}
|
|
@@ -25749,7 +25901,7 @@ async function isTerminalStatus(itemId2) {
|
|
|
25749
25901
|
}
|
|
25750
25902
|
async function resolvePhaseResult(phaseIndex, itemId2) {
|
|
25751
25903
|
const signalPath = getSignalPath();
|
|
25752
|
-
if (!signalPath || !
|
|
25904
|
+
if (!signalPath || !existsSync55(signalPath)) {
|
|
25753
25905
|
if (await isTerminalStatus(itemId2)) return { kind: "abort" };
|
|
25754
25906
|
const action = await handleIncompletePhase();
|
|
25755
25907
|
if (action === "abort") return { kind: "abort" };
|
|
@@ -25836,7 +25988,7 @@ async function persistPhaseSessionId(itemId2, phaseIdx, claudeSessionId) {
|
|
|
25836
25988
|
// src/shared/emitActivity.ts
|
|
25837
25989
|
import { mkdirSync as mkdirSync19, readFileSync as readFileSync37, rmSync as rmSync4, writeFileSync as writeFileSync27 } from "fs";
|
|
25838
25990
|
import { homedir as homedir19 } from "os";
|
|
25839
|
-
import { dirname as dirname31, join as
|
|
25991
|
+
import { dirname as dirname31, join as join65 } from "path";
|
|
25840
25992
|
import { z as z19 } from "zod";
|
|
25841
25993
|
var activitySchema = z19.object({
|
|
25842
25994
|
kind: z19.enum(["command", "backlog"]),
|
|
@@ -25854,7 +26006,7 @@ var activitySchema = z19.object({
|
|
|
25854
26006
|
startedAt: z19.number()
|
|
25855
26007
|
});
|
|
25856
26008
|
function activityPath(sessionId2) {
|
|
25857
|
-
return
|
|
26009
|
+
return join65(homedir19(), ".assist", "activity", `activity-${sessionId2}.json`);
|
|
25858
26010
|
}
|
|
25859
26011
|
function emitActivity(activity2) {
|
|
25860
26012
|
const sessionId2 = process.env.ASSIST_ACTIVITY_ID;
|
|
@@ -28613,7 +28765,7 @@ function extractGraphqlQuery(args) {
|
|
|
28613
28765
|
}
|
|
28614
28766
|
|
|
28615
28767
|
// src/shared/loadCliReads.ts
|
|
28616
|
-
import { existsSync as
|
|
28768
|
+
import { existsSync as existsSync56, readFileSync as readFileSync39, writeFileSync as writeFileSync28 } from "fs";
|
|
28617
28769
|
import { dirname as dirname32, resolve as resolve18 } from "path";
|
|
28618
28770
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
28619
28771
|
var __filename3 = fileURLToPath6(import.meta.url);
|
|
@@ -28622,7 +28774,7 @@ function packageRoot() {
|
|
|
28622
28774
|
return __dirname4;
|
|
28623
28775
|
}
|
|
28624
28776
|
function readLines(path128) {
|
|
28625
|
-
if (!
|
|
28777
|
+
if (!existsSync56(path128)) return [];
|
|
28626
28778
|
return readFileSync39(path128, "utf8").split("\n").filter((line) => line.trim() !== "");
|
|
28627
28779
|
}
|
|
28628
28780
|
var cachedReads;
|
|
@@ -28669,14 +28821,14 @@ function findCliWrite(command) {
|
|
|
28669
28821
|
}
|
|
28670
28822
|
|
|
28671
28823
|
// src/shared/readSettingsPerms.ts
|
|
28672
|
-
import { existsSync as
|
|
28824
|
+
import { existsSync as existsSync57, readFileSync as readFileSync40 } from "fs";
|
|
28673
28825
|
import { homedir as homedir20 } from "os";
|
|
28674
|
-
import { join as
|
|
28826
|
+
import { join as join66 } from "path";
|
|
28675
28827
|
function readSettingsPerms(key) {
|
|
28676
28828
|
const paths = [
|
|
28677
|
-
|
|
28678
|
-
|
|
28679
|
-
|
|
28829
|
+
join66(homedir20(), ".claude", "settings.json"),
|
|
28830
|
+
join66(process.cwd(), ".claude", "settings.json"),
|
|
28831
|
+
join66(process.cwd(), ".claude", "settings.local.json")
|
|
28680
28832
|
];
|
|
28681
28833
|
const entries2 = [];
|
|
28682
28834
|
for (const p of paths) {
|
|
@@ -28688,7 +28840,7 @@ function readSettingsPerms(key) {
|
|
|
28688
28840
|
return entries2;
|
|
28689
28841
|
}
|
|
28690
28842
|
function readPermissionArray(filePath, key) {
|
|
28691
|
-
if (!
|
|
28843
|
+
if (!existsSync57(filePath)) return [];
|
|
28692
28844
|
try {
|
|
28693
28845
|
const data = JSON.parse(readFileSync40(filePath, "utf8"));
|
|
28694
28846
|
const arr = data?.permissions?.[key];
|
|
@@ -29042,32 +29194,32 @@ async function decideDocsGuard({
|
|
|
29042
29194
|
}
|
|
29043
29195
|
|
|
29044
29196
|
// src/commands/schema/isSchemaLocked.ts
|
|
29045
|
-
import { existsSync as
|
|
29197
|
+
import { existsSync as existsSync58, readFileSync as readFileSync42 } from "fs";
|
|
29046
29198
|
|
|
29047
29199
|
// src/commands/schema/getSchemaSessionApprovalPath.ts
|
|
29048
|
-
import { join as
|
|
29200
|
+
import { join as join68 } from "path";
|
|
29049
29201
|
|
|
29050
29202
|
// src/commands/codeComment/getRestrictedDir.ts
|
|
29051
29203
|
import { homedir as homedir21 } from "os";
|
|
29052
|
-
import { join as
|
|
29204
|
+
import { join as join67 } from "path";
|
|
29053
29205
|
function getRestrictedDir() {
|
|
29054
|
-
return
|
|
29206
|
+
return join67(homedir21(), ".assist", "restricted");
|
|
29055
29207
|
}
|
|
29056
29208
|
function getPinStatePath(pin2) {
|
|
29057
|
-
return
|
|
29209
|
+
return join67(getRestrictedDir(), `code-comment-${pin2}.json`);
|
|
29058
29210
|
}
|
|
29059
29211
|
|
|
29060
29212
|
// src/commands/schema/getSchemaSessionApprovalPath.ts
|
|
29061
29213
|
var SESSION_ID = /^[\w-]+$/;
|
|
29062
29214
|
function getSchemaSessionApprovalDir() {
|
|
29063
|
-
return
|
|
29215
|
+
return join68(getRestrictedDir(), "schema-sessions");
|
|
29064
29216
|
}
|
|
29065
29217
|
function getSchemaSessionApprovalPath(scope) {
|
|
29066
29218
|
const { harness, conversationId } = scope;
|
|
29067
29219
|
if (!SESSION_ID.test(conversationId) || !SESSION_ID.test(harness))
|
|
29068
29220
|
return void 0;
|
|
29069
29221
|
const name2 = harness === legacyDefaultHarness ? conversationId : `${harness}-${conversationId}`;
|
|
29070
|
-
return
|
|
29222
|
+
return join68(getSchemaSessionApprovalDir(), `${name2}.json`);
|
|
29071
29223
|
}
|
|
29072
29224
|
|
|
29073
29225
|
// src/commands/schema/isSchemaLocked.ts
|
|
@@ -29088,7 +29240,7 @@ function hasSessionApproval(identity) {
|
|
|
29088
29240
|
const { harness, conversationId } = identity;
|
|
29089
29241
|
if (!conversationId) return false;
|
|
29090
29242
|
const path128 = getSchemaSessionApprovalPath({ harness, conversationId });
|
|
29091
|
-
return path128 !== void 0 &&
|
|
29243
|
+
return path128 !== void 0 && existsSync58(path128) && approvalMatches(path128, identity);
|
|
29092
29244
|
}
|
|
29093
29245
|
async function isSchemaLocked(identity = currentExecutionIdentity()) {
|
|
29094
29246
|
if (!identity) return false;
|
|
@@ -29162,11 +29314,11 @@ import { basename as basename17 } from "path";
|
|
|
29162
29314
|
// src/commands/cliHook/logDeniedToolCall.ts
|
|
29163
29315
|
import { mkdirSync as mkdirSync20 } from "fs";
|
|
29164
29316
|
import { homedir as homedir22 } from "os";
|
|
29165
|
-
import { join as
|
|
29317
|
+
import { join as join69 } from "path";
|
|
29166
29318
|
import Database from "better-sqlite3";
|
|
29167
29319
|
var _db;
|
|
29168
29320
|
function getDbDir() {
|
|
29169
|
-
return
|
|
29321
|
+
return join69(homedir22(), ".assist");
|
|
29170
29322
|
}
|
|
29171
29323
|
function initSchema(db) {
|
|
29172
29324
|
db.exec(`
|
|
@@ -29185,7 +29337,7 @@ function openPromptsDb(dir) {
|
|
|
29185
29337
|
if (_db) return _db;
|
|
29186
29338
|
const dbDir = dir ?? getDbDir();
|
|
29187
29339
|
mkdirSync20(dbDir, { recursive: true });
|
|
29188
|
-
const db = new Database(
|
|
29340
|
+
const db = new Database(join69(dbDir, "assist.db"));
|
|
29189
29341
|
db.pragma("journal_mode = WAL");
|
|
29190
29342
|
initSchema(db);
|
|
29191
29343
|
_db = db;
|
|
@@ -29289,9 +29441,9 @@ ${reasons.join("\n")}`);
|
|
|
29289
29441
|
}
|
|
29290
29442
|
|
|
29291
29443
|
// src/commands/permitCliReads.ts
|
|
29292
|
-
import { existsSync as
|
|
29444
|
+
import { existsSync as existsSync59, mkdirSync as mkdirSync21, readFileSync as readFileSync43, writeFileSync as writeFileSync29 } from "fs";
|
|
29293
29445
|
import { homedir as homedir23 } from "os";
|
|
29294
|
-
import { join as
|
|
29446
|
+
import { join as join70 } from "path";
|
|
29295
29447
|
|
|
29296
29448
|
// src/commands/permitCliReads/assertCliExists.ts
|
|
29297
29449
|
function assertCliExists(cli) {
|
|
@@ -29554,15 +29706,15 @@ function updateSettings(cli, commands) {
|
|
|
29554
29706
|
// src/commands/permitCliReads.ts
|
|
29555
29707
|
function logPath(cli) {
|
|
29556
29708
|
const safeName = cli.replace(/\s+/g, "-");
|
|
29557
|
-
return
|
|
29709
|
+
return join70(homedir23(), ".assist", `cli-discover-${safeName}.log`);
|
|
29558
29710
|
}
|
|
29559
29711
|
function readCache(cli) {
|
|
29560
29712
|
const path128 = logPath(cli);
|
|
29561
|
-
if (!
|
|
29713
|
+
if (!existsSync59(path128)) return void 0;
|
|
29562
29714
|
return readFileSync43(path128, "utf8");
|
|
29563
29715
|
}
|
|
29564
29716
|
function writeCache(cli, output) {
|
|
29565
|
-
const dir =
|
|
29717
|
+
const dir = join70(homedir23(), ".assist");
|
|
29566
29718
|
mkdirSync21(dir, { recursive: true });
|
|
29567
29719
|
writeFileSync29(logPath(cli), output);
|
|
29568
29720
|
}
|
|
@@ -29694,7 +29846,7 @@ function registerCliHook(program) {
|
|
|
29694
29846
|
}
|
|
29695
29847
|
|
|
29696
29848
|
// src/commands/codeComment/codeCommentConfirm.ts
|
|
29697
|
-
import { existsSync as
|
|
29849
|
+
import { existsSync as existsSync61, readFileSync as readFileSync45, unlinkSync as unlinkSync9, writeFileSync as writeFileSync30 } from "fs";
|
|
29698
29850
|
import chalk125 from "chalk";
|
|
29699
29851
|
|
|
29700
29852
|
// src/shared/isHashCommentFile.ts
|
|
@@ -29727,19 +29879,19 @@ function isHashCommentFile(filePath) {
|
|
|
29727
29879
|
}
|
|
29728
29880
|
|
|
29729
29881
|
// src/commands/codeComment/sweepRestrictedDir.ts
|
|
29730
|
-
import { readdirSync as
|
|
29731
|
-
import { join as
|
|
29882
|
+
import { readdirSync as readdirSync12, statSync as statSync11, unlinkSync as unlinkSync8 } from "fs";
|
|
29883
|
+
import { join as join71 } from "path";
|
|
29732
29884
|
var STALE_AFTER_MS = 30 * 60 * 1e3;
|
|
29733
29885
|
function sweepRestrictedDir(dir = getRestrictedDir()) {
|
|
29734
29886
|
let entries2;
|
|
29735
29887
|
try {
|
|
29736
|
-
entries2 =
|
|
29888
|
+
entries2 = readdirSync12(dir);
|
|
29737
29889
|
} catch {
|
|
29738
29890
|
return;
|
|
29739
29891
|
}
|
|
29740
29892
|
const cutoff = Date.now() - STALE_AFTER_MS;
|
|
29741
29893
|
for (const entry of entries2) {
|
|
29742
|
-
const path128 =
|
|
29894
|
+
const path128 = join71(dir, entry);
|
|
29743
29895
|
try {
|
|
29744
29896
|
if (statSync11(path128).mtimeMs < cutoff) unlinkSync8(path128);
|
|
29745
29897
|
} catch {
|
|
@@ -29749,10 +29901,10 @@ function sweepRestrictedDir(dir = getRestrictedDir()) {
|
|
|
29749
29901
|
}
|
|
29750
29902
|
|
|
29751
29903
|
// src/commands/codeComment/readPinState.ts
|
|
29752
|
-
import { existsSync as
|
|
29904
|
+
import { existsSync as existsSync60, readFileSync as readFileSync44 } from "fs";
|
|
29753
29905
|
function readPinState(pin2) {
|
|
29754
29906
|
const path128 = getPinStatePath(pin2);
|
|
29755
|
-
if (!
|
|
29907
|
+
if (!existsSync60(path128)) return void 0;
|
|
29756
29908
|
try {
|
|
29757
29909
|
const state = JSON.parse(readFileSync44(path128, "utf8"));
|
|
29758
29910
|
if (state.pin !== pin2) return void 0;
|
|
@@ -29771,7 +29923,7 @@ function codeCommentConfirm(pin2) {
|
|
|
29771
29923
|
process.exitCode = 1;
|
|
29772
29924
|
return;
|
|
29773
29925
|
}
|
|
29774
|
-
if (!
|
|
29926
|
+
if (!existsSync61(state.file)) {
|
|
29775
29927
|
console.error(chalk125.red(`Target file no longer exists: ${state.file}`));
|
|
29776
29928
|
process.exitCode = 1;
|
|
29777
29929
|
return;
|
|
@@ -30465,7 +30617,7 @@ function gitCheckOutput(cmd) {
|
|
|
30465
30617
|
}
|
|
30466
30618
|
function checkCommands(files) {
|
|
30467
30619
|
if (files.length === 0) return ["git diff --cached --check"];
|
|
30468
|
-
const scope = files.map(
|
|
30620
|
+
const scope = files.map(shellQuote2).join(" ");
|
|
30469
30621
|
return [
|
|
30470
30622
|
`git diff --check -- ${scope}`,
|
|
30471
30623
|
`git diff --cached --check -- ${scope}`
|
|
@@ -30647,17 +30799,17 @@ import { execSync as execSync30 } from "child_process";
|
|
|
30647
30799
|
var HEADS_PREFIX = "refs/heads/";
|
|
30648
30800
|
function pushCommit(trunkMode) {
|
|
30649
30801
|
const target = pushTargetForRenamedUpstream(trunkMode);
|
|
30650
|
-
const command = target ? `git push ${target.setUpstream ? "--set-upstream " : ""}${
|
|
30802
|
+
const command = target ? `git push ${target.setUpstream ? "--set-upstream " : ""}${shellQuote2(target.remote)} HEAD:${shellQuote2(target.branch)}` : "git push";
|
|
30651
30803
|
execSync30(command, { stdio: "inherit" });
|
|
30652
30804
|
}
|
|
30653
30805
|
function pushTargetForRenamedUpstream(trunkMode) {
|
|
30654
30806
|
const branch2 = gitOrNull2("git symbolic-ref --short HEAD");
|
|
30655
30807
|
if (!branch2) return null;
|
|
30656
30808
|
const remote = gitOrNull2(
|
|
30657
|
-
`git config --get branch.${
|
|
30809
|
+
`git config --get branch.${shellQuote2(branch2)}.remote`
|
|
30658
30810
|
);
|
|
30659
30811
|
const merge2 = gitOrNull2(
|
|
30660
|
-
`git config --get branch.${
|
|
30812
|
+
`git config --get branch.${shellQuote2(branch2)}.merge`
|
|
30661
30813
|
);
|
|
30662
30814
|
if (!remote || !merge2) return null;
|
|
30663
30815
|
const upstream = merge2.startsWith(HEADS_PREFIX) ? merge2.slice(HEADS_PREFIX.length) : merge2;
|
|
@@ -30752,7 +30904,7 @@ async function refuseLockedSchema() {
|
|
|
30752
30904
|
// src/commands/commit/commitStaged.ts
|
|
30753
30905
|
import { execSync as execSync33 } from "child_process";
|
|
30754
30906
|
function commitStaged(message4) {
|
|
30755
|
-
execSync33(`git commit -m ${
|
|
30907
|
+
execSync33(`git commit -m ${shellQuote2(message4)}`, { stdio: "inherit" });
|
|
30756
30908
|
return execSync33("git rev-parse --short=7 HEAD", {
|
|
30757
30909
|
encoding: "utf8"
|
|
30758
30910
|
}).trim();
|
|
@@ -30761,7 +30913,7 @@ function commitStaged(message4) {
|
|
|
30761
30913
|
// src/commands/commit/stageFiles.ts
|
|
30762
30914
|
import { execSync as execSync34 } from "child_process";
|
|
30763
30915
|
function stageFiles(files) {
|
|
30764
|
-
const escaped = files.map(
|
|
30916
|
+
const escaped = files.map(shellQuote2).join(" ");
|
|
30765
30917
|
execSync34(`git add ${escaped}`, { stdio: "inherit" });
|
|
30766
30918
|
}
|
|
30767
30919
|
|
|
@@ -32306,11 +32458,11 @@ import { dirname as dirname35 } from "path";
|
|
|
32306
32458
|
|
|
32307
32459
|
// src/commands/browser/snapshotPath.ts
|
|
32308
32460
|
import { homedir as homedir24 } from "os";
|
|
32309
|
-
import { join as
|
|
32461
|
+
import { join as join74 } from "path";
|
|
32310
32462
|
function snapshotPath(tabUrl, now) {
|
|
32311
32463
|
const host = new URL(tabUrl).host.replace(/[^\w.-]/g, "-");
|
|
32312
32464
|
const timestamp9 = now.toISOString().replace(/[:.]/g, "-");
|
|
32313
|
-
return
|
|
32465
|
+
return join74(homedir24(), ".assist", "browser", `${host}-${timestamp9}.html`);
|
|
32314
32466
|
}
|
|
32315
32467
|
|
|
32316
32468
|
// src/commands/browser/browserSnapshot.ts
|
|
@@ -32517,28 +32669,28 @@ async function printExtensionUrl() {
|
|
|
32517
32669
|
// src/commands/extension/signExtension.ts
|
|
32518
32670
|
import { rm as rm2 } from "fs/promises";
|
|
32519
32671
|
import { homedir as homedir25, tmpdir as tmpdir4 } from "os";
|
|
32520
|
-
import { join as
|
|
32672
|
+
import { join as join80 } from "path";
|
|
32521
32673
|
import chalk159 from "chalk";
|
|
32522
32674
|
|
|
32523
32675
|
// src/commands/extension/copySignedXpi.ts
|
|
32524
32676
|
import { copyFile } from "fs/promises";
|
|
32525
|
-
import { join as
|
|
32677
|
+
import { join as join75 } from "path";
|
|
32526
32678
|
var SIGNED_XPI_NAME = "assist-extension.xpi";
|
|
32527
32679
|
async function copySignedXpi(xpi, dir) {
|
|
32528
|
-
const fixed2 =
|
|
32680
|
+
const fixed2 = join75(dir, SIGNED_XPI_NAME);
|
|
32529
32681
|
if (fixed2 === xpi) return fixed2;
|
|
32530
32682
|
await copyFile(xpi, fixed2);
|
|
32531
32683
|
return fixed2;
|
|
32532
32684
|
}
|
|
32533
32685
|
|
|
32534
32686
|
// src/commands/extension/findSignedXpi.ts
|
|
32535
|
-
import { existsSync as
|
|
32687
|
+
import { existsSync as existsSync63 } from "fs";
|
|
32536
32688
|
import { readdir } from "fs/promises";
|
|
32537
|
-
import { join as
|
|
32689
|
+
import { join as join76 } from "path";
|
|
32538
32690
|
async function findSignedXpi(dir) {
|
|
32539
|
-
if (!
|
|
32691
|
+
if (!existsSync63(dir)) return null;
|
|
32540
32692
|
const name2 = (await readdir(dir)).find((entry) => entry.endsWith(".xpi"));
|
|
32541
|
-
return name2 ?
|
|
32693
|
+
return name2 ? join76(dir, name2) : null;
|
|
32542
32694
|
}
|
|
32543
32695
|
|
|
32544
32696
|
// src/commands/extension/signedAddonInstallPath.ts
|
|
@@ -32560,11 +32712,11 @@ async function signedAddonInstallPath(xpi) {
|
|
|
32560
32712
|
}
|
|
32561
32713
|
|
|
32562
32714
|
// src/commands/extension/signPreflightProblem.ts
|
|
32563
|
-
import { existsSync as
|
|
32564
|
-
import { join as
|
|
32715
|
+
import { existsSync as existsSync64 } from "fs";
|
|
32716
|
+
import { join as join77 } from "path";
|
|
32565
32717
|
var KEY_URL = "https://addons.mozilla.org/en-US/developers/addon/api/key/";
|
|
32566
32718
|
function signPreflightProblem(source) {
|
|
32567
|
-
if (!
|
|
32719
|
+
if (!existsSync64(join77(source, "content.js")))
|
|
32568
32720
|
return {
|
|
32569
32721
|
message: `no content.js in ${source}`,
|
|
32570
32722
|
hint: "run npm run build to bundle the content script"
|
|
@@ -32579,7 +32731,7 @@ function signPreflightProblem(source) {
|
|
|
32579
32731
|
|
|
32580
32732
|
// src/commands/extension/stageExtension.ts
|
|
32581
32733
|
import { cp as cp3, mkdir as mkdir5, readFile as readFile5, rm, writeFile as writeFile4 } from "fs/promises";
|
|
32582
|
-
import { basename as basename18, join as
|
|
32734
|
+
import { basename as basename18, join as join78 } from "path";
|
|
32583
32735
|
|
|
32584
32736
|
// src/commands/extension/stampManifestVersion.ts
|
|
32585
32737
|
function stampManifestVersion(manifest, version2) {
|
|
@@ -32596,7 +32748,7 @@ async function stageExtension(source, staging, version2) {
|
|
|
32596
32748
|
recursive: true,
|
|
32597
32749
|
filter: (path128) => basename18(path128) !== "updates.json"
|
|
32598
32750
|
});
|
|
32599
|
-
const manifest =
|
|
32751
|
+
const manifest = join78(staging, "manifest.json");
|
|
32600
32752
|
const stamped = stampManifestVersion(
|
|
32601
32753
|
await readFile5(manifest, "utf8"),
|
|
32602
32754
|
version2
|
|
@@ -32606,7 +32758,7 @@ async function stageExtension(source, staging, version2) {
|
|
|
32606
32758
|
|
|
32607
32759
|
// src/commands/extension/writeUpdateManifest.ts
|
|
32608
32760
|
import { readFile as readFile6, writeFile as writeFile5 } from "fs/promises";
|
|
32609
|
-
import { join as
|
|
32761
|
+
import { join as join79 } from "path";
|
|
32610
32762
|
|
|
32611
32763
|
// src/commands/extension/buildUpdateManifest.ts
|
|
32612
32764
|
var RELEASE_DOWNLOAD_URL = "https://github.com/staff0rd/assist/releases/download";
|
|
@@ -32631,17 +32783,17 @@ function buildUpdateManifest(manifest, version2) {
|
|
|
32631
32783
|
// src/commands/extension/writeUpdateManifest.ts
|
|
32632
32784
|
async function writeUpdateManifest(source, dir, version2) {
|
|
32633
32785
|
await writeFile5(
|
|
32634
|
-
|
|
32786
|
+
join79(dir, "updates.json"),
|
|
32635
32787
|
buildUpdateManifest(
|
|
32636
|
-
await readFile6(
|
|
32788
|
+
await readFile6(join79(source, "manifest.json"), "utf8"),
|
|
32637
32789
|
version2
|
|
32638
32790
|
)
|
|
32639
32791
|
);
|
|
32640
32792
|
}
|
|
32641
32793
|
|
|
32642
32794
|
// src/commands/extension/signExtension.ts
|
|
32643
|
-
var ARTIFACTS_DIR =
|
|
32644
|
-
var STAGING_DIR =
|
|
32795
|
+
var ARTIFACTS_DIR = join80(homedir25(), ".assist", "extension");
|
|
32796
|
+
var STAGING_DIR = join80(tmpdir4(), "assist-extension");
|
|
32645
32797
|
async function signExtension() {
|
|
32646
32798
|
const source = extensionDir();
|
|
32647
32799
|
const problem = signPreflightProblem(source);
|
|
@@ -32827,7 +32979,7 @@ function registerDb(program) {
|
|
|
32827
32979
|
}
|
|
32828
32980
|
|
|
32829
32981
|
// src/commands/deploy/redirect.ts
|
|
32830
|
-
import { existsSync as
|
|
32982
|
+
import { existsSync as existsSync65, readFileSync as readFileSync48, writeFileSync as writeFileSync33 } from "fs";
|
|
32831
32983
|
import chalk162 from "chalk";
|
|
32832
32984
|
var TRAILING_SLASH_SCRIPT = ` <script>
|
|
32833
32985
|
if (!window.location.pathname.endsWith('/')) {
|
|
@@ -32836,7 +32988,7 @@ var TRAILING_SLASH_SCRIPT = ` <script>
|
|
|
32836
32988
|
</script>`;
|
|
32837
32989
|
function redirect() {
|
|
32838
32990
|
const indexPath = "index.html";
|
|
32839
|
-
if (!
|
|
32991
|
+
if (!existsSync65(indexPath)) {
|
|
32840
32992
|
console.log(chalk162.yellow("No index.html found"));
|
|
32841
32993
|
return;
|
|
32842
32994
|
}
|
|
@@ -32935,9 +33087,9 @@ import { readFileSync as readFileSync49 } from "fs";
|
|
|
32935
33087
|
import { parse as parseYaml3 } from "yaml";
|
|
32936
33088
|
|
|
32937
33089
|
// src/commands/devlog/devEntryPath.ts
|
|
32938
|
-
import { join as
|
|
33090
|
+
import { join as join81 } from "path";
|
|
32939
33091
|
function devEntryPath(repoName, week, devDir) {
|
|
32940
|
-
return
|
|
33092
|
+
return join81(devDir, repoName, `${week.toLowerCase()}.md`);
|
|
32941
33093
|
}
|
|
32942
33094
|
|
|
32943
33095
|
// src/commands/devlog/loadDevEntry.ts
|
|
@@ -33049,15 +33201,15 @@ function findTargetWeek(weeks, { lastWeek, skip: skip3, today }) {
|
|
|
33049
33201
|
import chalk165 from "chalk";
|
|
33050
33202
|
|
|
33051
33203
|
// src/shared/getRepoName.ts
|
|
33052
|
-
import { existsSync as
|
|
33053
|
-
import { basename as basename19, join as
|
|
33204
|
+
import { existsSync as existsSync66, readFileSync as readFileSync50 } from "fs";
|
|
33205
|
+
import { basename as basename19, join as join82 } from "path";
|
|
33054
33206
|
function getRepoName() {
|
|
33055
33207
|
const config = loadConfig();
|
|
33056
33208
|
if (config.devlog?.name) {
|
|
33057
33209
|
return config.devlog.name;
|
|
33058
33210
|
}
|
|
33059
|
-
const packageJsonPath =
|
|
33060
|
-
if (
|
|
33211
|
+
const packageJsonPath = join82(process.cwd(), "package.json");
|
|
33212
|
+
if (existsSync66(packageJsonPath)) {
|
|
33061
33213
|
try {
|
|
33062
33214
|
const content = readFileSync50(packageJsonPath, "utf8");
|
|
33063
33215
|
const pkg = JSON.parse(content);
|
|
@@ -33134,8 +33286,8 @@ function list2(options2) {
|
|
|
33134
33286
|
}
|
|
33135
33287
|
|
|
33136
33288
|
// src/commands/devlog/loadDevWeeks.ts
|
|
33137
|
-
import { readdirSync as
|
|
33138
|
-
import { join as
|
|
33289
|
+
import { readdirSync as readdirSync13 } from "fs";
|
|
33290
|
+
import { join as join83 } from "path";
|
|
33139
33291
|
var DEV_FILENAME_PATTERN = /^(\d{4})-w(\d{2})\.md$/;
|
|
33140
33292
|
function parseDevWeekFilename(filename) {
|
|
33141
33293
|
const match = filename.match(DEV_FILENAME_PATTERN);
|
|
@@ -33143,13 +33295,13 @@ function parseDevWeekFilename(filename) {
|
|
|
33143
33295
|
}
|
|
33144
33296
|
function readFilenames(dir) {
|
|
33145
33297
|
try {
|
|
33146
|
-
return
|
|
33298
|
+
return readdirSync13(dir);
|
|
33147
33299
|
} catch {
|
|
33148
33300
|
return [];
|
|
33149
33301
|
}
|
|
33150
33302
|
}
|
|
33151
33303
|
function loadDevWeeks(repoName, devDir) {
|
|
33152
|
-
return readFilenames(
|
|
33304
|
+
return readFilenames(join83(devDir, repoName)).map(parseDevWeekFilename).filter((week) => week !== null).sort();
|
|
33153
33305
|
}
|
|
33154
33306
|
|
|
33155
33307
|
// src/commands/devlog/next/displayNextEntry.ts
|
|
@@ -33467,12 +33619,12 @@ async function reviewProposedSlackMessage(target, body, workingPath) {
|
|
|
33467
33619
|
}
|
|
33468
33620
|
|
|
33469
33621
|
// src/commands/slack/slackWorkingFile.ts
|
|
33470
|
-
import { join as
|
|
33622
|
+
import { join as join84 } from "path";
|
|
33471
33623
|
function slackWorkingFile(channel, partIndex) {
|
|
33472
33624
|
const slug2 = channel.replace(/^[#@]/, "").toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "channel";
|
|
33473
|
-
const dir =
|
|
33625
|
+
const dir = join84(getStoreDir(), "slack");
|
|
33474
33626
|
const name2 = partIndex === void 0 ? slug2 : `${slug2}-${partIndex}`;
|
|
33475
|
-
return { dir, bodyPath:
|
|
33627
|
+
return { dir, bodyPath: join84(dir, `${name2}.md`) };
|
|
33476
33628
|
}
|
|
33477
33629
|
|
|
33478
33630
|
// src/commands/slack/previewSlackThreadParts.ts
|
|
@@ -33853,10 +34005,10 @@ function registerDevlogEntryCommands(devlogCommand) {
|
|
|
33853
34005
|
import { execSync as execSync38 } from "child_process";
|
|
33854
34006
|
|
|
33855
34007
|
// src/commands/devlog/loadAllDevLatestWeeks.ts
|
|
33856
|
-
import { readdirSync as
|
|
34008
|
+
import { readdirSync as readdirSync14 } from "fs";
|
|
33857
34009
|
function readRepoDirs(devDir) {
|
|
33858
34010
|
try {
|
|
33859
|
-
return
|
|
34011
|
+
return readdirSync14(devDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
33860
34012
|
} catch {
|
|
33861
34013
|
return [];
|
|
33862
34014
|
}
|
|
@@ -34014,19 +34166,19 @@ async function findPhaseUnlockItem(itemId2, phase) {
|
|
|
34014
34166
|
}
|
|
34015
34167
|
|
|
34016
34168
|
// src/commands/docs/getDocsUnlockPinPath.ts
|
|
34017
|
-
import { join as
|
|
34169
|
+
import { join as join85 } from "path";
|
|
34018
34170
|
function getDocsUnlockPinPath(pin2) {
|
|
34019
|
-
return
|
|
34171
|
+
return join85(getRestrictedDir(), `docs-unlock-pin-${pin2}.json`);
|
|
34020
34172
|
}
|
|
34021
34173
|
|
|
34022
34174
|
// src/commands/docs/readDocsUnlockPinState.ts
|
|
34023
|
-
import { existsSync as
|
|
34175
|
+
import { existsSync as existsSync67, readFileSync as readFileSync54 } from "fs";
|
|
34024
34176
|
function isPositiveInteger(value) {
|
|
34025
34177
|
return Number.isInteger(value) && value > 0;
|
|
34026
34178
|
}
|
|
34027
34179
|
function readDocsUnlockPinState(pin2) {
|
|
34028
34180
|
const path128 = getDocsUnlockPinPath(pin2);
|
|
34029
|
-
if (!
|
|
34181
|
+
if (!existsSync67(path128)) return void 0;
|
|
34030
34182
|
try {
|
|
34031
34183
|
const state = JSON.parse(readFileSync54(path128, "utf8"));
|
|
34032
34184
|
if (state.pin !== pin2) return void 0;
|
|
@@ -34204,13 +34356,13 @@ async function approveSchemaUnlock(state) {
|
|
|
34204
34356
|
}
|
|
34205
34357
|
|
|
34206
34358
|
// src/commands/schema/getSchemaUnlockPinPath.ts
|
|
34207
|
-
import { join as
|
|
34359
|
+
import { join as join86 } from "path";
|
|
34208
34360
|
function getSchemaUnlockPinPath(pin2) {
|
|
34209
|
-
return
|
|
34361
|
+
return join86(getRestrictedDir(), `schema-unlock-pin-${pin2}.json`);
|
|
34210
34362
|
}
|
|
34211
34363
|
|
|
34212
34364
|
// src/commands/schema/readSchemaUnlockPinState.ts
|
|
34213
|
-
import { existsSync as
|
|
34365
|
+
import { existsSync as existsSync68, readFileSync as readFileSync55 } from "fs";
|
|
34214
34366
|
function isPositiveInteger2(value) {
|
|
34215
34367
|
return Number.isInteger(value) && value > 0;
|
|
34216
34368
|
}
|
|
@@ -34235,7 +34387,7 @@ function toState(raw) {
|
|
|
34235
34387
|
}
|
|
34236
34388
|
function readSchemaUnlockPinState(pin2) {
|
|
34237
34389
|
const path128 = getSchemaUnlockPinPath(pin2);
|
|
34238
|
-
if (!
|
|
34390
|
+
if (!existsSync68(path128)) return void 0;
|
|
34239
34391
|
try {
|
|
34240
34392
|
const raw = JSON.parse(readFileSync55(path128, "utf8"));
|
|
34241
34393
|
if (raw.pin !== pin2) return void 0;
|
|
@@ -34364,20 +34516,20 @@ function registerSchema(parent) {
|
|
|
34364
34516
|
}
|
|
34365
34517
|
|
|
34366
34518
|
// src/commands/dotnet/checkBuildLocks.ts
|
|
34367
|
-
import { closeSync as closeSync6, openSync as openSync7, readdirSync as
|
|
34368
|
-
import { join as
|
|
34519
|
+
import { closeSync as closeSync6, openSync as openSync7, readdirSync as readdirSync15 } from "fs";
|
|
34520
|
+
import { join as join87 } from "path";
|
|
34369
34521
|
import chalk182 from "chalk";
|
|
34370
34522
|
var SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", ".git", "packages"]);
|
|
34371
34523
|
function isLockedDll(debugDir) {
|
|
34372
34524
|
let files;
|
|
34373
34525
|
try {
|
|
34374
|
-
files =
|
|
34526
|
+
files = readdirSync15(debugDir, { recursive: true });
|
|
34375
34527
|
} catch {
|
|
34376
34528
|
return null;
|
|
34377
34529
|
}
|
|
34378
34530
|
for (const file of files) {
|
|
34379
34531
|
if (!file.toLowerCase().endsWith(".dll")) continue;
|
|
34380
|
-
const dllPath =
|
|
34532
|
+
const dllPath = join87(debugDir, file);
|
|
34381
34533
|
try {
|
|
34382
34534
|
const fd = openSync7(dllPath, "r+");
|
|
34383
34535
|
closeSync6(fd);
|
|
@@ -34390,18 +34542,18 @@ function isLockedDll(debugDir) {
|
|
|
34390
34542
|
function findFirstLockedDll(dir) {
|
|
34391
34543
|
let entries2;
|
|
34392
34544
|
try {
|
|
34393
|
-
entries2 =
|
|
34545
|
+
entries2 = readdirSync15(dir);
|
|
34394
34546
|
} catch {
|
|
34395
34547
|
return null;
|
|
34396
34548
|
}
|
|
34397
34549
|
if (entries2.includes("bin")) {
|
|
34398
|
-
const locked = isLockedDll(
|
|
34550
|
+
const locked = isLockedDll(join87(dir, "bin", "Debug"));
|
|
34399
34551
|
if (locked) return locked;
|
|
34400
34552
|
}
|
|
34401
34553
|
for (const entry of entries2) {
|
|
34402
34554
|
if (SKIP_DIRS.has(entry) || entry === "bin" || entry.startsWith("."))
|
|
34403
34555
|
continue;
|
|
34404
|
-
const found = findFirstLockedDll(
|
|
34556
|
+
const found = findFirstLockedDll(join87(dir, entry));
|
|
34405
34557
|
if (found) return found;
|
|
34406
34558
|
}
|
|
34407
34559
|
return null;
|
|
@@ -34470,14 +34622,14 @@ function collectAllDeps(node) {
|
|
|
34470
34622
|
}
|
|
34471
34623
|
|
|
34472
34624
|
// src/commands/dotnet/findContainingSolutions.ts
|
|
34473
|
-
import { readdirSync as
|
|
34625
|
+
import { readdirSync as readdirSync16, readFileSync as readFileSync57, statSync as statSync12 } from "fs";
|
|
34474
34626
|
import path49 from "path";
|
|
34475
34627
|
function findSlnFiles(dir, maxDepth, depth = 0) {
|
|
34476
34628
|
if (depth > maxDepth) return [];
|
|
34477
34629
|
const results = [];
|
|
34478
34630
|
let entries2;
|
|
34479
34631
|
try {
|
|
34480
|
-
entries2 =
|
|
34632
|
+
entries2 = readdirSync16(dir);
|
|
34481
34633
|
} catch {
|
|
34482
34634
|
return results;
|
|
34483
34635
|
}
|
|
@@ -34569,12 +34721,12 @@ function printJson(tree, totalCount, solutions) {
|
|
|
34569
34721
|
}
|
|
34570
34722
|
|
|
34571
34723
|
// src/commands/dotnet/resolveCsproj.ts
|
|
34572
|
-
import { existsSync as
|
|
34724
|
+
import { existsSync as existsSync69 } from "fs";
|
|
34573
34725
|
import path50 from "path";
|
|
34574
34726
|
import chalk184 from "chalk";
|
|
34575
34727
|
function resolveCsproj(csprojPath) {
|
|
34576
34728
|
const resolved2 = path50.resolve(csprojPath);
|
|
34577
|
-
if (!
|
|
34729
|
+
if (!existsSync69(resolved2)) {
|
|
34578
34730
|
console.error(chalk184.red(`File not found: ${resolved2}`));
|
|
34579
34731
|
process.exit(1);
|
|
34580
34732
|
}
|
|
@@ -34742,17 +34894,17 @@ function filterIssues(issues, all, cliOnly, cliSuppress) {
|
|
|
34742
34894
|
}
|
|
34743
34895
|
|
|
34744
34896
|
// src/commands/dotnet/resolveSolution.ts
|
|
34745
|
-
import { existsSync as
|
|
34897
|
+
import { existsSync as existsSync70 } from "fs";
|
|
34746
34898
|
import path51 from "path";
|
|
34747
34899
|
import chalk188 from "chalk";
|
|
34748
34900
|
|
|
34749
34901
|
// src/commands/dotnet/findSolution.ts
|
|
34750
|
-
import { readdirSync as
|
|
34751
|
-
import { dirname as dirname37, join as
|
|
34902
|
+
import { readdirSync as readdirSync17 } from "fs";
|
|
34903
|
+
import { dirname as dirname37, join as join88 } from "path";
|
|
34752
34904
|
import chalk187 from "chalk";
|
|
34753
34905
|
function findSlnInDir(dir) {
|
|
34754
34906
|
try {
|
|
34755
|
-
return
|
|
34907
|
+
return readdirSync17(dir).filter((f) => f.endsWith(".sln")).map((f) => join88(dir, f));
|
|
34756
34908
|
} catch {
|
|
34757
34909
|
return [];
|
|
34758
34910
|
}
|
|
@@ -34783,7 +34935,7 @@ function findSolution() {
|
|
|
34783
34935
|
function resolveSolution(sln) {
|
|
34784
34936
|
if (sln) {
|
|
34785
34937
|
const resolved2 = path51.resolve(sln);
|
|
34786
|
-
if (!
|
|
34938
|
+
if (!existsSync70(resolved2)) {
|
|
34787
34939
|
console.error(chalk188.red(`Solution file not found: ${resolved2}`));
|
|
34788
34940
|
process.exit(1);
|
|
34789
34941
|
}
|
|
@@ -34823,7 +34975,7 @@ function parseInspectReport(json) {
|
|
|
34823
34975
|
|
|
34824
34976
|
// src/commands/dotnet/runInspectCode.ts
|
|
34825
34977
|
import { execSync as execSync40 } from "child_process";
|
|
34826
|
-
import { existsSync as
|
|
34978
|
+
import { existsSync as existsSync71, readFileSync as readFileSync58, unlinkSync as unlinkSync13 } from "fs";
|
|
34827
34979
|
import { tmpdir as tmpdir5 } from "os";
|
|
34828
34980
|
import path52 from "path";
|
|
34829
34981
|
import chalk189 from "chalk";
|
|
@@ -34854,7 +35006,7 @@ function runInspectCode(slnPath, include, swea) {
|
|
|
34854
35006
|
console.error(chalk189.red("jb inspectcode failed"));
|
|
34855
35007
|
process.exit(1);
|
|
34856
35008
|
}
|
|
34857
|
-
if (!
|
|
35009
|
+
if (!existsSync71(reportPath)) {
|
|
34858
35010
|
console.error(chalk189.red("Report file not generated"));
|
|
34859
35011
|
process.exit(1);
|
|
34860
35012
|
}
|
|
@@ -35794,7 +35946,7 @@ function aggregateCommitters(authorLists) {
|
|
|
35794
35946
|
import { spawnSync as spawnSync8 } from "child_process";
|
|
35795
35947
|
import { unlinkSync as unlinkSync14, writeFileSync as writeFileSync41 } from "fs";
|
|
35796
35948
|
import { tmpdir as tmpdir6 } from "os";
|
|
35797
|
-
import { join as
|
|
35949
|
+
import { join as join89 } from "path";
|
|
35798
35950
|
function buildArgs3(queryFile, vars) {
|
|
35799
35951
|
const args = ["api", "graphql", "-F", `query=@${queryFile}`];
|
|
35800
35952
|
for (const [key, value] of Object.entries(vars)) {
|
|
@@ -35804,7 +35956,7 @@ function buildArgs3(queryFile, vars) {
|
|
|
35804
35956
|
return args;
|
|
35805
35957
|
}
|
|
35806
35958
|
function runGhGraphql(mutation, vars) {
|
|
35807
|
-
const queryFile =
|
|
35959
|
+
const queryFile = join89(tmpdir6(), `gh-query-${Date.now()}.graphql`);
|
|
35808
35960
|
writeFileSync41(queryFile, mutation);
|
|
35809
35961
|
try {
|
|
35810
35962
|
const result = spawnSync8("gh", buildArgs3(queryFile, vars), {
|
|
@@ -37283,14 +37435,14 @@ function slugFromUrl(url) {
|
|
|
37283
37435
|
import { mkdirSync as mkdirSync30, writeFileSync as writeFileSync42 } from "fs";
|
|
37284
37436
|
|
|
37285
37437
|
// src/commands/github/issue/issueWorkingFile.ts
|
|
37286
|
-
import { join as
|
|
37438
|
+
import { join as join90 } from "path";
|
|
37287
37439
|
function issueWorkingFile(slug2, number) {
|
|
37288
37440
|
const [owner = "unknown", repo = "unknown"] = slug2.split("/");
|
|
37289
|
-
const dir =
|
|
37441
|
+
const dir = join90(getStoreDir(), "github-issues", owner, repo);
|
|
37290
37442
|
return {
|
|
37291
37443
|
dir,
|
|
37292
|
-
bodyPath:
|
|
37293
|
-
metaPath:
|
|
37444
|
+
bodyPath: join90(dir, `${number}.md`),
|
|
37445
|
+
metaPath: join90(dir, `${number}.json`)
|
|
37294
37446
|
};
|
|
37295
37447
|
}
|
|
37296
37448
|
|
|
@@ -37325,10 +37477,10 @@ function fetchIssueToWorkingFile(number, repo) {
|
|
|
37325
37477
|
}
|
|
37326
37478
|
|
|
37327
37479
|
// src/commands/github/issue/resumeIssueBody.ts
|
|
37328
|
-
import { existsSync as
|
|
37480
|
+
import { existsSync as existsSync72, readFileSync as readFileSync59 } from "fs";
|
|
37329
37481
|
function resumeIssueBody(slug2, number, updatedAt) {
|
|
37330
37482
|
const { bodyPath, metaPath } = issueWorkingFile(slug2, number);
|
|
37331
|
-
if (!
|
|
37483
|
+
if (!existsSync72(bodyPath) || !existsSync72(metaPath)) return void 0;
|
|
37332
37484
|
try {
|
|
37333
37485
|
const meta = JSON.parse(readFileSync59(metaPath, "utf8"));
|
|
37334
37486
|
if (meta.updatedAt !== updatedAt) return void 0;
|
|
@@ -38473,15 +38625,15 @@ function clearStalePrBranch(cwd, branch2) {
|
|
|
38473
38625
|
}
|
|
38474
38626
|
|
|
38475
38627
|
// src/commands/sessions/daemon/worktree/createWorktree.ts
|
|
38476
|
-
import { existsSync as
|
|
38628
|
+
import { existsSync as existsSync73 } from "fs";
|
|
38477
38629
|
import { basename as basename22, dirname as dirname39 } from "path";
|
|
38478
38630
|
|
|
38479
38631
|
// src/commands/sessions/daemon/worktree/nextWorktreePath.ts
|
|
38480
|
-
import { basename as basename21, join as
|
|
38632
|
+
import { basename as basename21, join as join91 } from "path";
|
|
38481
38633
|
function nextWorktreePath(clone, base, isTaken) {
|
|
38482
38634
|
const name2 = basename21(clone);
|
|
38483
38635
|
for (let n = 2; n < 1e3; n++) {
|
|
38484
|
-
const candidate =
|
|
38636
|
+
const candidate = join91(base, `${name2}-${n}`);
|
|
38485
38637
|
if (!isTaken(candidate)) return candidate;
|
|
38486
38638
|
}
|
|
38487
38639
|
throw new Error(`no free worktree suffix for ${clone}`);
|
|
@@ -38505,7 +38657,7 @@ function createWorktree(clone, strategy, boundTreeRoots2, preferredPath) {
|
|
|
38505
38657
|
const base = strategy.root ? expandTilde(strategy.root) : dirname39(clone);
|
|
38506
38658
|
const registered = new Set(listWorktreePaths(clone));
|
|
38507
38659
|
const branches = new Set(listLocalBranches(clone));
|
|
38508
|
-
const isTaken = (candidate) => registered.has(candidate) ||
|
|
38660
|
+
const isTaken = (candidate) => registered.has(candidate) || existsSync73(candidate) || boundTreeRoots2.has(candidate) || branches.has(basename22(candidate));
|
|
38509
38661
|
const path128 = preferredPath && !isTaken(preferredPath) ? preferredPath : nextWorktreePath(clone, base, isTaken);
|
|
38510
38662
|
const ready = addWorktree(clone, path128, strategy.trunk);
|
|
38511
38663
|
ready.catch(() => {
|
|
@@ -38722,7 +38874,7 @@ function savePersistedSessions(sessions) {
|
|
|
38722
38874
|
}
|
|
38723
38875
|
function persistLiveSessions(sessions) {
|
|
38724
38876
|
const live = [...sessions.values()].filter(
|
|
38725
|
-
(s) => (s.pty || s.status === "stopped" || s.status === "error" || s.awaitingSeed && s.pendingStart) && s.status !== "done"
|
|
38877
|
+
(s) => (s.pty || s.status === "stopped" || s.status === "error" || s.awaitingSeed && s.pendingStart) && s.status !== "done"
|
|
38726
38878
|
);
|
|
38727
38879
|
savePersistedSessions(live.map(toPersistedSession));
|
|
38728
38880
|
logPersist(live);
|
|
@@ -38747,8 +38899,8 @@ function persistedTreeRoots() {
|
|
|
38747
38899
|
}
|
|
38748
38900
|
|
|
38749
38901
|
// src/commands/sessions/daemon/worktree/seedWorktree.ts
|
|
38750
|
-
import { copyFileSync as copyFileSync3, existsSync as
|
|
38751
|
-
import { dirname as dirname40, join as
|
|
38902
|
+
import { copyFileSync as copyFileSync3, existsSync as existsSync75, mkdirSync as mkdirSync31 } from "fs";
|
|
38903
|
+
import { dirname as dirname40, join as join93 } from "path";
|
|
38752
38904
|
|
|
38753
38905
|
// src/commands/sessions/daemon/worktree/installPaths.ts
|
|
38754
38906
|
import { resolve as resolve22 } from "path";
|
|
@@ -38778,14 +38930,14 @@ function pendingPathAction(enclosing, states2, paths, stopped) {
|
|
|
38778
38930
|
}
|
|
38779
38931
|
|
|
38780
38932
|
// src/commands/sessions/daemon/worktree/detectInstallCommand.ts
|
|
38781
|
-
import { existsSync as
|
|
38782
|
-
import { join as
|
|
38933
|
+
import { existsSync as existsSync74 } from "fs";
|
|
38934
|
+
import { join as join92 } from "path";
|
|
38783
38935
|
function detectInstallCommand(dir) {
|
|
38784
|
-
if (!
|
|
38785
|
-
if (
|
|
38786
|
-
if (
|
|
38787
|
-
if (
|
|
38788
|
-
if (
|
|
38936
|
+
if (!existsSync74(join92(dir, "package.json"))) return null;
|
|
38937
|
+
if (existsSync74(join92(dir, "pnpm-lock.yaml"))) return "pnpm install";
|
|
38938
|
+
if (existsSync74(join92(dir, "yarn.lock"))) return "yarn install";
|
|
38939
|
+
if (existsSync74(join92(dir, "bun.lockb"))) return "bun install";
|
|
38940
|
+
if (existsSync74(join92(dir, "package-lock.json"))) return "npm ci";
|
|
38789
38941
|
return "npm install";
|
|
38790
38942
|
}
|
|
38791
38943
|
|
|
@@ -38977,9 +39129,9 @@ function seedWorktree(worktreePath, clone, onSeeded = () => {
|
|
|
38977
39129
|
}
|
|
38978
39130
|
function copyConfigFiles(worktreePath, clone, copy) {
|
|
38979
39131
|
for (const rel of copy) {
|
|
38980
|
-
const src =
|
|
38981
|
-
if (!
|
|
38982
|
-
const dest =
|
|
39132
|
+
const src = join93(clone, rel);
|
|
39133
|
+
if (!existsSync75(src)) continue;
|
|
39134
|
+
const dest = join93(worktreePath, rel);
|
|
38983
39135
|
try {
|
|
38984
39136
|
mkdirSync31(dirname40(dest), { recursive: true });
|
|
38985
39137
|
copyFileSync3(src, dest);
|
|
@@ -39483,7 +39635,7 @@ function registerLitellm(program) {
|
|
|
39483
39635
|
}
|
|
39484
39636
|
|
|
39485
39637
|
// src/commands/mermaidExport.ts
|
|
39486
|
-
import { mkdirSync as mkdirSync32, readdirSync as
|
|
39638
|
+
import { mkdirSync as mkdirSync32, readdirSync as readdirSync18 } from "fs";
|
|
39487
39639
|
import { resolve as resolve24 } from "path";
|
|
39488
39640
|
import chalk207 from "chalk";
|
|
39489
39641
|
|
|
@@ -39565,7 +39717,7 @@ async function mermaidExport(file, options2 = {}) {
|
|
|
39565
39717
|
process.exit(1);
|
|
39566
39718
|
}
|
|
39567
39719
|
}
|
|
39568
|
-
const files = file ? [file] :
|
|
39720
|
+
const files = file ? [file] : readdirSync18(process.cwd()).filter((name2) => name2.toLowerCase().endsWith(".md")).sort();
|
|
39569
39721
|
if (files.length === 0) {
|
|
39570
39722
|
console.log(chalk207.gray("No markdown files found in current directory."));
|
|
39571
39723
|
return;
|
|
@@ -39726,10 +39878,10 @@ function applyIgnore(texts, ignore3) {
|
|
|
39726
39878
|
}
|
|
39727
39879
|
|
|
39728
39880
|
// src/commands/miro/readIgnoreList.ts
|
|
39729
|
-
import { existsSync as
|
|
39881
|
+
import { existsSync as existsSync76, readFileSync as readFileSync61 } from "fs";
|
|
39730
39882
|
import { parse as parse2 } from "yaml";
|
|
39731
39883
|
function readIgnoreList(file) {
|
|
39732
|
-
if (!
|
|
39884
|
+
if (!existsSync76(file))
|
|
39733
39885
|
throw new MiroExtractError(
|
|
39734
39886
|
`No ignore file at ${file}. Write a YAML list of the box texts to drop, or omit --ignore.`
|
|
39735
39887
|
);
|
|
@@ -40214,15 +40366,15 @@ function createNetcapHandler(options2) {
|
|
|
40214
40366
|
// src/commands/netcap/prepareExtensionForLoad.ts
|
|
40215
40367
|
import { cp as cp4, readFile as readFile7, writeFile as writeFile6 } from "fs/promises";
|
|
40216
40368
|
import { networkInterfaces } from "os";
|
|
40217
|
-
import { join as
|
|
40369
|
+
import { join as join95 } from "path";
|
|
40218
40370
|
import chalk210 from "chalk";
|
|
40219
40371
|
|
|
40220
40372
|
// src/commands/netcap/netcapExtensionDir.ts
|
|
40221
|
-
import { dirname as dirname42, join as
|
|
40373
|
+
import { dirname as dirname42, join as join94 } from "path";
|
|
40222
40374
|
import { fileURLToPath as fileURLToPath8 } from "url";
|
|
40223
40375
|
var moduleDir2 = dirname42(fileURLToPath8(import.meta.url));
|
|
40224
40376
|
function netcapExtensionDir() {
|
|
40225
|
-
return
|
|
40377
|
+
return join94(moduleDir2, "commands", "netcap", "netcap-extension");
|
|
40226
40378
|
}
|
|
40227
40379
|
|
|
40228
40380
|
// src/commands/netcap/prepareExtensionForLoad.ts
|
|
@@ -40237,7 +40389,7 @@ function lanIPv4() {
|
|
|
40237
40389
|
return void 0;
|
|
40238
40390
|
}
|
|
40239
40391
|
async function configureBackground(dir, host, port, filter) {
|
|
40240
|
-
const file =
|
|
40392
|
+
const file = join95(dir, "background.js");
|
|
40241
40393
|
const source = await readFile7(file, "utf8");
|
|
40242
40394
|
await writeFile6(
|
|
40243
40395
|
file,
|
|
@@ -40277,20 +40429,20 @@ async function prepareExtensionForLoad(port, filter = "") {
|
|
|
40277
40429
|
}
|
|
40278
40430
|
|
|
40279
40431
|
// src/commands/netcap/resolveNetcapOutPath.ts
|
|
40280
|
-
import { isAbsolute as isAbsolute6, join as
|
|
40432
|
+
import { isAbsolute as isAbsolute6, join as join97, resolve as resolve26 } from "path";
|
|
40281
40433
|
|
|
40282
40434
|
// src/commands/netcap/defaultCapturePath.ts
|
|
40283
40435
|
import { homedir as homedir26 } from "os";
|
|
40284
|
-
import { join as
|
|
40436
|
+
import { join as join96 } from "path";
|
|
40285
40437
|
function defaultCapturePath() {
|
|
40286
|
-
return
|
|
40438
|
+
return join96(homedir26(), ".assist", "netcap", "capture.jsonl");
|
|
40287
40439
|
}
|
|
40288
40440
|
|
|
40289
40441
|
// src/commands/netcap/resolveNetcapOutPath.ts
|
|
40290
40442
|
function resolveNetcapOutPath(out) {
|
|
40291
40443
|
if (!out) return defaultCapturePath();
|
|
40292
40444
|
const dir = isAbsolute6(out) ? out : resolve26(process.cwd(), out);
|
|
40293
|
-
return
|
|
40445
|
+
return join97(dir, "capture.jsonl");
|
|
40294
40446
|
}
|
|
40295
40447
|
|
|
40296
40448
|
// src/commands/netcap/netcap.ts
|
|
@@ -40337,7 +40489,7 @@ netcap stopped \u2014 captured ${count10} ${count10 === 1 ? "entry" : "entries"}
|
|
|
40337
40489
|
|
|
40338
40490
|
// src/commands/netcap/netcapExtract.ts
|
|
40339
40491
|
import { writeFileSync as writeFileSync45 } from "fs";
|
|
40340
|
-
import { join as
|
|
40492
|
+
import { join as join98 } from "path";
|
|
40341
40493
|
import chalk212 from "chalk";
|
|
40342
40494
|
|
|
40343
40495
|
// src/commands/netcap/extractPostsFromCapture.ts
|
|
@@ -40380,25 +40532,25 @@ function isVisibleText(t) {
|
|
|
40380
40532
|
return /[a-zA-Z]{3,}/.test(t);
|
|
40381
40533
|
}
|
|
40382
40534
|
var isHashtag = (t) => /^#[A-Za-z0-9_]+$/.test(t);
|
|
40383
|
-
function collectRscText(v, resolve36,
|
|
40535
|
+
function collectRscText(v, resolve36, sink4, seen) {
|
|
40384
40536
|
if (v == null) return;
|
|
40385
40537
|
if (typeof v === "string") {
|
|
40386
40538
|
if (isRscRef(v)) {
|
|
40387
40539
|
if (!seen.has(v)) {
|
|
40388
40540
|
seen.add(v);
|
|
40389
|
-
collectRscText(resolve36(v), resolve36,
|
|
40541
|
+
collectRscText(resolve36(v), resolve36, sink4, seen);
|
|
40390
40542
|
}
|
|
40391
|
-
} else if (isHashtag(v))
|
|
40392
|
-
else if (isVisibleText(v))
|
|
40543
|
+
} else if (isHashtag(v)) sink4.hashtags.push(v);
|
|
40544
|
+
else if (isVisibleText(v)) sink4.text.push(v);
|
|
40393
40545
|
return;
|
|
40394
40546
|
}
|
|
40395
40547
|
if (Array.isArray(v)) {
|
|
40396
|
-
for (const x of v) collectRscText(x, resolve36,
|
|
40548
|
+
for (const x of v) collectRscText(x, resolve36, sink4, seen);
|
|
40397
40549
|
return;
|
|
40398
40550
|
}
|
|
40399
40551
|
if (typeof v === "object") {
|
|
40400
40552
|
for (const val of Object.values(v)) {
|
|
40401
|
-
collectRscText(val, resolve36,
|
|
40553
|
+
collectRscText(val, resolve36, sink4, seen);
|
|
40402
40554
|
}
|
|
40403
40555
|
}
|
|
40404
40556
|
}
|
|
@@ -40437,9 +40589,9 @@ function buildMentionMap(rows, resolve36) {
|
|
|
40437
40589
|
if (!url || o.children == null) return;
|
|
40438
40590
|
const slug2 = slugFromProfileUrl(url);
|
|
40439
40591
|
if (!slug2 || map.has(slug2)) return;
|
|
40440
|
-
const
|
|
40441
|
-
collectRscText(o.children, resolve36,
|
|
40442
|
-
const name2 =
|
|
40592
|
+
const sink4 = { text: [], hashtags: [] };
|
|
40593
|
+
collectRscText(o.children, resolve36, sink4, /* @__PURE__ */ new Set());
|
|
40594
|
+
const name2 = sink4.text.join(" ").replace(/\s+/g, " ").trim();
|
|
40443
40595
|
map.set(slug2, name2 ? { slug: slug2, name: name2, url } : { slug: slug2, url });
|
|
40444
40596
|
});
|
|
40445
40597
|
return map;
|
|
@@ -40540,8 +40692,8 @@ function walkPostRow(v, resolve36, raw) {
|
|
|
40540
40692
|
if (a) raw.related.push(a[0]);
|
|
40541
40693
|
}
|
|
40542
40694
|
if (isCommentary(o)) {
|
|
40543
|
-
const
|
|
40544
|
-
collectRscText(o.children, resolve36,
|
|
40695
|
+
const sink4 = { text: raw.text, hashtags: raw.hashtags };
|
|
40696
|
+
collectRscText(o.children, resolve36, sink4, /* @__PURE__ */ new Set());
|
|
40545
40697
|
}
|
|
40546
40698
|
for (const val of Object.values(o)) walkPostRow(val, resolve36, raw);
|
|
40547
40699
|
}
|
|
@@ -40782,7 +40934,7 @@ function extractPostsFromCapture(captureFile) {
|
|
|
40782
40934
|
function netcapExtract(file) {
|
|
40783
40935
|
const captureFile = file ?? defaultCapturePath();
|
|
40784
40936
|
const posts = extractPostsFromCapture(captureFile);
|
|
40785
|
-
const outFile =
|
|
40937
|
+
const outFile = join98(captureFile, "..", "posts.json");
|
|
40786
40938
|
writeFileSync45(outFile, `${JSON.stringify(posts, null, 2)}
|
|
40787
40939
|
`);
|
|
40788
40940
|
console.log(
|
|
@@ -41178,9 +41330,9 @@ async function comment2(path128, line, body, options2 = {}) {
|
|
|
41178
41330
|
|
|
41179
41331
|
// src/commands/prs/commentsCachePath.ts
|
|
41180
41332
|
import { homedir as homedir27 } from "os";
|
|
41181
|
-
import { join as
|
|
41333
|
+
import { join as join99 } from "path";
|
|
41182
41334
|
function commentsCachePath(org, repo, prNumber) {
|
|
41183
|
-
return
|
|
41335
|
+
return join99(
|
|
41184
41336
|
homedir27(),
|
|
41185
41337
|
".assist",
|
|
41186
41338
|
"pr-comments",
|
|
@@ -41196,11 +41348,11 @@ import { dirname as dirname44 } from "path";
|
|
|
41196
41348
|
import { stringify as stringify3 } from "yaml";
|
|
41197
41349
|
|
|
41198
41350
|
// src/commands/prs/loadCommentsCache.ts
|
|
41199
|
-
import { existsSync as
|
|
41351
|
+
import { existsSync as existsSync77, readFileSync as readFileSync64, unlinkSync as unlinkSync15 } from "fs";
|
|
41200
41352
|
import { parse as parse3 } from "yaml";
|
|
41201
41353
|
function loadCommentsCache(org, repo, prNumber) {
|
|
41202
41354
|
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
41203
|
-
if (!
|
|
41355
|
+
if (!existsSync77(cachePath)) {
|
|
41204
41356
|
return null;
|
|
41205
41357
|
}
|
|
41206
41358
|
const content = readFileSync64(cachePath, "utf8");
|
|
@@ -41208,26 +41360,26 @@ function loadCommentsCache(org, repo, prNumber) {
|
|
|
41208
41360
|
}
|
|
41209
41361
|
function deleteCommentsCache(org, repo, prNumber) {
|
|
41210
41362
|
const cachePath = commentsCachePath(org, repo, prNumber);
|
|
41211
|
-
if (
|
|
41363
|
+
if (existsSync77(cachePath)) {
|
|
41212
41364
|
unlinkSync15(cachePath);
|
|
41213
41365
|
console.log("No more unresolved line comments. Cache dropped.");
|
|
41214
41366
|
}
|
|
41215
41367
|
}
|
|
41216
41368
|
|
|
41217
41369
|
// src/commands/prs/removeStaleCommentsCaches.ts
|
|
41218
|
-
import { readdirSync as
|
|
41219
|
-
import { join as
|
|
41370
|
+
import { readdirSync as readdirSync19, unlinkSync as unlinkSync16 } from "fs";
|
|
41371
|
+
import { join as join100 } from "path";
|
|
41220
41372
|
var STALE_PATTERN = /^pr-\d+-comments\.yaml$/;
|
|
41221
41373
|
function removeStaleCommentsCaches(cwd = process.cwd()) {
|
|
41222
|
-
const dir =
|
|
41374
|
+
const dir = join100(cwd, ".assist");
|
|
41223
41375
|
let entries2;
|
|
41224
41376
|
try {
|
|
41225
|
-
entries2 =
|
|
41377
|
+
entries2 = readdirSync19(dir);
|
|
41226
41378
|
} catch {
|
|
41227
41379
|
return;
|
|
41228
41380
|
}
|
|
41229
41381
|
for (const entry of entries2.filter((e) => STALE_PATTERN.test(e))) {
|
|
41230
|
-
unlinkSync16(
|
|
41382
|
+
unlinkSync16(join100(dir, entry));
|
|
41231
41383
|
}
|
|
41232
41384
|
}
|
|
41233
41385
|
|
|
@@ -41345,7 +41497,7 @@ function failAzureDevops(error) {
|
|
|
41345
41497
|
import { execFileSync as execFileSync23 } from "child_process";
|
|
41346
41498
|
import { mkdtempSync as mkdtempSync2, rmSync as rmSync6, writeFileSync as writeFileSync47 } from "fs";
|
|
41347
41499
|
import { tmpdir as tmpdir7 } from "os";
|
|
41348
|
-
import { join as
|
|
41500
|
+
import { join as join101 } from "path";
|
|
41349
41501
|
function azDevopsInvokeArgs(request, inFile) {
|
|
41350
41502
|
return [
|
|
41351
41503
|
"devops",
|
|
@@ -41380,8 +41532,8 @@ function runAz2(args) {
|
|
|
41380
41532
|
}
|
|
41381
41533
|
function invokeAzDevops(request) {
|
|
41382
41534
|
if (request.body === void 0) return runAz2(azDevopsInvokeArgs(request));
|
|
41383
|
-
const dir = mkdtempSync2(
|
|
41384
|
-
const inFile =
|
|
41535
|
+
const dir = mkdtempSync2(join101(tmpdir7(), "assist-az-"));
|
|
41536
|
+
const inFile = join101(dir, "body.json");
|
|
41385
41537
|
try {
|
|
41386
41538
|
writeFileSync47(inFile, JSON.stringify(request.body));
|
|
41387
41539
|
return runAz2(azDevopsInvokeArgs(request, inFile));
|
|
@@ -44511,9 +44663,9 @@ async function notify() {
|
|
|
44511
44663
|
|
|
44512
44664
|
// src/commands/screenshot.ts
|
|
44513
44665
|
import { execSync as execSync54 } from "child_process";
|
|
44514
|
-
import { existsSync as
|
|
44666
|
+
import { existsSync as existsSync78, mkdirSync as mkdirSync35, unlinkSync as unlinkSync17, writeFileSync as writeFileSync48 } from "fs";
|
|
44515
44667
|
import { tmpdir as tmpdir8 } from "os";
|
|
44516
|
-
import { join as
|
|
44668
|
+
import { join as join102, resolve as resolve28 } from "path";
|
|
44517
44669
|
import chalk239 from "chalk";
|
|
44518
44670
|
|
|
44519
44671
|
// src/commands/screenshot/captureWindowPs1.ts
|
|
@@ -44643,14 +44795,14 @@ Write-Output $OutputPath
|
|
|
44643
44795
|
|
|
44644
44796
|
// src/commands/screenshot.ts
|
|
44645
44797
|
function buildOutputPath(outputDir, processName) {
|
|
44646
|
-
if (!
|
|
44798
|
+
if (!existsSync78(outputDir)) {
|
|
44647
44799
|
mkdirSync35(outputDir, { recursive: true });
|
|
44648
44800
|
}
|
|
44649
44801
|
const timestamp9 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
44650
44802
|
return resolve28(outputDir, `${processName}-${timestamp9}.png`);
|
|
44651
44803
|
}
|
|
44652
44804
|
function runPowerShellScript(processName, outputPath) {
|
|
44653
|
-
const scriptPath =
|
|
44805
|
+
const scriptPath = join102(tmpdir8(), `assist-screenshot-${Date.now()}.ps1`);
|
|
44654
44806
|
writeFileSync48(scriptPath, captureWindowPs1, "utf8");
|
|
44655
44807
|
try {
|
|
44656
44808
|
execSync54(
|
|
@@ -44752,9 +44904,9 @@ function buildLimitsSegment(rateLimits) {
|
|
|
44752
44904
|
|
|
44753
44905
|
// src/commands/readGitBranch.ts
|
|
44754
44906
|
import { readFileSync as readFileSync67, statSync as statSync14 } from "fs";
|
|
44755
|
-
import { isAbsolute as isAbsolute7, join as
|
|
44907
|
+
import { isAbsolute as isAbsolute7, join as join103, resolve as resolve29 } from "path";
|
|
44756
44908
|
function resolveGitDir(cwd) {
|
|
44757
|
-
const dotGit =
|
|
44909
|
+
const dotGit = join103(cwd, ".git");
|
|
44758
44910
|
let stat5;
|
|
44759
44911
|
try {
|
|
44760
44912
|
stat5 = statSync14(dotGit);
|
|
@@ -44784,7 +44936,7 @@ function readGitBranch(cwd) {
|
|
|
44784
44936
|
}
|
|
44785
44937
|
let head;
|
|
44786
44938
|
try {
|
|
44787
|
-
head = readFileSync67(
|
|
44939
|
+
head = readFileSync67(join103(gitDir, "HEAD"), "utf8");
|
|
44788
44940
|
} catch {
|
|
44789
44941
|
return null;
|
|
44790
44942
|
}
|
|
@@ -47960,12 +48112,12 @@ function formatSlicingRequest(hunks) {
|
|
|
47960
48112
|
}
|
|
47961
48113
|
|
|
47962
48114
|
// src/commands/review/highLevel/highLevelReviewPath.ts
|
|
47963
|
-
import { join as
|
|
48115
|
+
import { join as join104 } from "path";
|
|
47964
48116
|
function slug(value) {
|
|
47965
48117
|
return value.replace(/[^\w.-]+/g, "-");
|
|
47966
48118
|
}
|
|
47967
48119
|
function highLevelReviewPath(repo, headRef, headSha) {
|
|
47968
|
-
return
|
|
48120
|
+
return join104(
|
|
47969
48121
|
getStoreDir(),
|
|
47970
48122
|
"high-level-reviews",
|
|
47971
48123
|
slug(repo),
|
|
@@ -48017,9 +48169,9 @@ function listHighLevelHunks(files) {
|
|
|
48017
48169
|
}
|
|
48018
48170
|
|
|
48019
48171
|
// src/commands/review/highLevel/readJsonFile.ts
|
|
48020
|
-
import { existsSync as
|
|
48172
|
+
import { existsSync as existsSync79, readFileSync as readFileSync68 } from "fs";
|
|
48021
48173
|
function readJsonFile(path128) {
|
|
48022
|
-
if (!
|
|
48174
|
+
if (!existsSync79(path128)) return void 0;
|
|
48023
48175
|
try {
|
|
48024
48176
|
return JSON.parse(readFileSync68(path128, "utf8"));
|
|
48025
48177
|
} catch {
|
|
@@ -49128,7 +49280,7 @@ import { format } from "util";
|
|
|
49128
49280
|
|
|
49129
49281
|
// src/commands/review/createReviewLogSink.ts
|
|
49130
49282
|
import { appendFileSync as appendFileSync3, mkdirSync as mkdirSync37 } from "fs";
|
|
49131
|
-
import { join as
|
|
49283
|
+
import { join as join105 } from "path";
|
|
49132
49284
|
var LOG_FILE = "review.log";
|
|
49133
49285
|
function createReviewLogSink() {
|
|
49134
49286
|
let logPath2;
|
|
@@ -49145,7 +49297,7 @@ function createReviewLogSink() {
|
|
|
49145
49297
|
},
|
|
49146
49298
|
attach(reviewDir) {
|
|
49147
49299
|
mkdirSync37(reviewDir, { recursive: true });
|
|
49148
|
-
logPath2 =
|
|
49300
|
+
logPath2 = join105(reviewDir, LOG_FILE);
|
|
49149
49301
|
const lines = [
|
|
49150
49302
|
"",
|
|
49151
49303
|
`=== ${(/* @__PURE__ */ new Date()).toISOString()} ===`,
|
|
@@ -49160,13 +49312,13 @@ function createReviewLogSink() {
|
|
|
49160
49312
|
}
|
|
49161
49313
|
|
|
49162
49314
|
// src/commands/review/startReviewLog.ts
|
|
49163
|
-
var
|
|
49315
|
+
var sink3 = createReviewLogSink();
|
|
49164
49316
|
var patched = false;
|
|
49165
49317
|
function appendReviewLog(line) {
|
|
49166
|
-
|
|
49318
|
+
sink3.append(line);
|
|
49167
49319
|
}
|
|
49168
49320
|
function attachReviewLog(reviewDir) {
|
|
49169
|
-
|
|
49321
|
+
sink3.attach(reviewDir);
|
|
49170
49322
|
}
|
|
49171
49323
|
function patch(method) {
|
|
49172
49324
|
const original = console[method].bind(console);
|
|
@@ -49484,7 +49636,7 @@ async function runReviewers(reviewers, context) {
|
|
|
49484
49636
|
}
|
|
49485
49637
|
|
|
49486
49638
|
// src/commands/review/synthesiseAfterReviewers.ts
|
|
49487
|
-
import { existsSync as
|
|
49639
|
+
import { existsSync as existsSync80, unlinkSync as unlinkSync18 } from "fs";
|
|
49488
49640
|
|
|
49489
49641
|
// src/commands/review/synthesise.ts
|
|
49490
49642
|
import { readFileSync as readFileSync70 } from "fs";
|
|
@@ -49718,7 +49870,7 @@ async function synthesise(paths, options2) {
|
|
|
49718
49870
|
// src/commands/review/synthesiseAfterReviewers.ts
|
|
49719
49871
|
async function synthesiseAfterReviewers(input) {
|
|
49720
49872
|
const { paths, failures } = input;
|
|
49721
|
-
if (input.anyFresh &&
|
|
49873
|
+
if (input.anyFresh && existsSync80(paths.synthesisPath)) {
|
|
49722
49874
|
unlinkSync18(paths.synthesisPath);
|
|
49723
49875
|
}
|
|
49724
49876
|
const synthesisResult = await synthesise(paths, { multi: input.multi });
|
|
@@ -49932,9 +50084,9 @@ ${annotateDiffWithLineNumbers(context.diff.trimEnd())}
|
|
|
49932
50084
|
|
|
49933
50085
|
// src/commands/review/buildReviewPaths.ts
|
|
49934
50086
|
import { homedir as homedir28 } from "os";
|
|
49935
|
-
import { basename as basename27, join as
|
|
50087
|
+
import { basename as basename27, join as join106 } from "path";
|
|
49936
50088
|
function buildReviewPaths(repoRoot3, key) {
|
|
49937
|
-
const reviewDir =
|
|
50089
|
+
const reviewDir = join106(
|
|
49938
50090
|
homedir28(),
|
|
49939
50091
|
".assist",
|
|
49940
50092
|
"reviews",
|
|
@@ -49943,10 +50095,10 @@ function buildReviewPaths(repoRoot3, key) {
|
|
|
49943
50095
|
);
|
|
49944
50096
|
return {
|
|
49945
50097
|
reviewDir,
|
|
49946
|
-
requestPath:
|
|
49947
|
-
claudePath:
|
|
49948
|
-
codexPath:
|
|
49949
|
-
synthesisPath:
|
|
50098
|
+
requestPath: join106(reviewDir, "request.md"),
|
|
50099
|
+
claudePath: join106(reviewDir, "claude.md"),
|
|
50100
|
+
codexPath: join106(reviewDir, "codex.md"),
|
|
50101
|
+
synthesisPath: join106(reviewDir, "synthesis.md")
|
|
49950
50102
|
};
|
|
49951
50103
|
}
|
|
49952
50104
|
|
|
@@ -49984,10 +50136,10 @@ function fetchExistingComments() {
|
|
|
49984
50136
|
}
|
|
49985
50137
|
|
|
49986
50138
|
// src/commands/review/prepareReviewDir.ts
|
|
49987
|
-
import { existsSync as
|
|
50139
|
+
import { existsSync as existsSync81, mkdirSync as mkdirSync38, unlinkSync as unlinkSync19, writeFileSync as writeFileSync50 } from "fs";
|
|
49988
50140
|
function clearReviewFiles(paths) {
|
|
49989
50141
|
for (const path128 of [paths.claudePath, paths.codexPath, paths.synthesisPath]) {
|
|
49990
|
-
if (
|
|
50142
|
+
if (existsSync81(path128)) unlinkSync19(path128);
|
|
49991
50143
|
}
|
|
49992
50144
|
}
|
|
49993
50145
|
function prepareReviewDir(paths, requestBody, force) {
|
|
@@ -50893,7 +51045,7 @@ import path101 from "path";
|
|
|
50893
51045
|
import chalk276 from "chalk";
|
|
50894
51046
|
|
|
50895
51047
|
// src/commands/rules/updateScopedRulesIndex.ts
|
|
50896
|
-
import { existsSync as
|
|
51048
|
+
import { existsSync as existsSync82, readFileSync as readFileSync73, writeFileSync as writeFileSync51 } from "fs";
|
|
50897
51049
|
import path100 from "path";
|
|
50898
51050
|
|
|
50899
51051
|
// src/commands/rules/scopedRuleDirectories.ts
|
|
@@ -50901,12 +51053,12 @@ import { readFileSync as readFileSync72 } from "fs";
|
|
|
50901
51053
|
import path99 from "path";
|
|
50902
51054
|
|
|
50903
51055
|
// src/commands/rules/findClaudeFiles.ts
|
|
50904
|
-
import { readdirSync as
|
|
51056
|
+
import { readdirSync as readdirSync20 } from "fs";
|
|
50905
51057
|
import path98 from "path";
|
|
50906
51058
|
var SKIP_DIRECTORIES = /* @__PURE__ */ new Set(["node_modules", "dist", "build", "coverage"]);
|
|
50907
51059
|
function findClaudeFiles(dir) {
|
|
50908
51060
|
const results = [];
|
|
50909
|
-
for (const entry of
|
|
51061
|
+
for (const entry of readdirSync20(dir, { withFileTypes: true })) {
|
|
50910
51062
|
if (entry.isDirectory()) {
|
|
50911
51063
|
if (entry.name.startsWith(".") || SKIP_DIRECTORIES.has(entry.name))
|
|
50912
51064
|
continue;
|
|
@@ -50963,7 +51115,7 @@ function upsertScopedRulesPointer(content, directories) {
|
|
|
50963
51115
|
function updateScopedRulesIndex(root2) {
|
|
50964
51116
|
const directories = scopedRuleDirectories(root2);
|
|
50965
51117
|
const rootFile = path100.join(root2, "CLAUDE.md");
|
|
50966
|
-
const before =
|
|
51118
|
+
const before = existsSync82(rootFile) ? readFileSync73(rootFile, "utf8") : "";
|
|
50967
51119
|
const after = upsertScopedRulesPointer(before, directories);
|
|
50968
51120
|
if (after !== before) writeFileSync51(rootFile, after);
|
|
50969
51121
|
return directories;
|
|
@@ -51016,7 +51168,7 @@ function listRules(target, options2 = {}) {
|
|
|
51016
51168
|
}
|
|
51017
51169
|
|
|
51018
51170
|
// src/commands/rules/addRule.ts
|
|
51019
|
-
import { existsSync as
|
|
51171
|
+
import { existsSync as existsSync84, readFileSync as readFileSync75, writeFileSync as writeFileSync52 } from "fs";
|
|
51020
51172
|
import path104 from "path";
|
|
51021
51173
|
import chalk278 from "chalk";
|
|
51022
51174
|
|
|
@@ -51053,7 +51205,7 @@ function nextRuleCode(root2) {
|
|
|
51053
51205
|
}
|
|
51054
51206
|
|
|
51055
51207
|
// src/commands/rules/resolveRuleScope.ts
|
|
51056
|
-
import { existsSync as
|
|
51208
|
+
import { existsSync as existsSync83 } from "fs";
|
|
51057
51209
|
import path103 from "path";
|
|
51058
51210
|
function resolveRuleScope(target) {
|
|
51059
51211
|
const resolved2 = path103.resolve(target);
|
|
@@ -51063,7 +51215,7 @@ function resolveRuleScope(target) {
|
|
|
51063
51215
|
let current2 = startDir;
|
|
51064
51216
|
while (true) {
|
|
51065
51217
|
const candidate = path103.join(current2, "CLAUDE.md");
|
|
51066
|
-
if (
|
|
51218
|
+
if (existsSync83(candidate)) return candidate;
|
|
51067
51219
|
if (current2 === root2 || current2 === path103.dirname(current2)) break;
|
|
51068
51220
|
current2 = path103.dirname(current2);
|
|
51069
51221
|
}
|
|
@@ -51072,7 +51224,7 @@ function resolveRuleScope(target) {
|
|
|
51072
51224
|
|
|
51073
51225
|
// src/commands/rules/addRule.ts
|
|
51074
51226
|
function read3(file) {
|
|
51075
|
-
return
|
|
51227
|
+
return existsSync84(file) ? readFileSync75(file, "utf8") : "";
|
|
51076
51228
|
}
|
|
51077
51229
|
function addRule(text18, options2) {
|
|
51078
51230
|
const rule = text18.trim();
|
|
@@ -52395,12 +52547,12 @@ var retired = [
|
|
|
52395
52547
|
path114.join(harnesses.pi.homeDir, "AGENTS.md")
|
|
52396
52548
|
];
|
|
52397
52549
|
function reportRetiredAgentsFiles() {
|
|
52398
|
-
const
|
|
52399
|
-
if (
|
|
52550
|
+
const leftovers2 = retired.filter((file) => fs61.existsSync(file));
|
|
52551
|
+
if (leftovers2.length === 0) return;
|
|
52400
52552
|
console.log(
|
|
52401
52553
|
"No longer written by sync \u2014 each harness now composes its own advice at session start:"
|
|
52402
52554
|
);
|
|
52403
|
-
for (const file of
|
|
52555
|
+
for (const file of leftovers2) console.log(` ${file}`);
|
|
52404
52556
|
console.log(
|
|
52405
52557
|
" Delete them, or they keep injecting the retired global instructions."
|
|
52406
52558
|
);
|
|
@@ -52859,7 +53011,7 @@ function registerTestflight(program) {
|
|
|
52859
53011
|
}
|
|
52860
53012
|
|
|
52861
53013
|
// src/commands/transcript/clean.ts
|
|
52862
|
-
import { existsSync as
|
|
53014
|
+
import { existsSync as existsSync93 } from "fs";
|
|
52863
53015
|
|
|
52864
53016
|
// src/commands/transcript/convert/formatTimestamp.ts
|
|
52865
53017
|
function pad2(value, width2) {
|
|
@@ -53137,7 +53289,7 @@ function clean(file, options2 = {}) {
|
|
|
53137
53289
|
);
|
|
53138
53290
|
process.exit(1);
|
|
53139
53291
|
}
|
|
53140
|
-
if (!
|
|
53292
|
+
if (!existsSync93(file)) {
|
|
53141
53293
|
console.error(`Error: VTT file not found: ${file}`);
|
|
53142
53294
|
process.exit(1);
|
|
53143
53295
|
}
|
|
@@ -53220,21 +53372,21 @@ async function configure() {
|
|
|
53220
53372
|
}
|
|
53221
53373
|
|
|
53222
53374
|
// src/commands/transcript/list.ts
|
|
53223
|
-
import { existsSync as
|
|
53224
|
-
import { join as
|
|
53375
|
+
import { existsSync as existsSync94, readdirSync as readdirSync26, statSync as statSync17 } from "fs";
|
|
53376
|
+
import { join as join123 } from "path";
|
|
53225
53377
|
function list5() {
|
|
53226
53378
|
const { vttDir } = getTranscriptConfig();
|
|
53227
|
-
if (!
|
|
53228
|
-
for (const entry of
|
|
53379
|
+
if (!existsSync94(vttDir)) return;
|
|
53380
|
+
for (const entry of readdirSync26(vttDir)) {
|
|
53229
53381
|
if (!entry.endsWith(".vtt")) continue;
|
|
53230
|
-
if (statSync17(
|
|
53382
|
+
if (statSync17(join123(vttDir, entry)).isDirectory()) continue;
|
|
53231
53383
|
console.log(entry);
|
|
53232
53384
|
}
|
|
53233
53385
|
}
|
|
53234
53386
|
|
|
53235
53387
|
// src/commands/transcript/move.ts
|
|
53236
|
-
import { existsSync as
|
|
53237
|
-
import { basename as basename31, join as
|
|
53388
|
+
import { existsSync as existsSync95, mkdirSync as mkdirSync41, renameSync as renameSync5, writeFileSync as writeFileSync56 } from "fs";
|
|
53389
|
+
import { basename as basename31, join as join124 } from "path";
|
|
53238
53390
|
|
|
53239
53391
|
// src/commands/transcript/convertVttToMarkdown.ts
|
|
53240
53392
|
function convertVttToMarkdown(inputPath) {
|
|
@@ -53244,9 +53396,9 @@ function convertVttToMarkdown(inputPath) {
|
|
|
53244
53396
|
// src/commands/transcript/move.ts
|
|
53245
53397
|
var DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
|
|
53246
53398
|
function archiveRawVtt(vttDir, sourcePath, filename) {
|
|
53247
|
-
const processedDir =
|
|
53399
|
+
const processedDir = join124(vttDir, "processed");
|
|
53248
53400
|
mkdirSync41(processedDir, { recursive: true });
|
|
53249
|
-
renameSync5(sourcePath,
|
|
53401
|
+
renameSync5(sourcePath, join124(processedDir, filename));
|
|
53250
53402
|
}
|
|
53251
53403
|
function move(file, options2) {
|
|
53252
53404
|
const { date, client } = options2;
|
|
@@ -53256,25 +53408,25 @@ function move(file, options2) {
|
|
|
53256
53408
|
}
|
|
53257
53409
|
const { vttDir, transcriptsDir, summaryDir } = getTranscriptConfig();
|
|
53258
53410
|
const filename = basename31(file);
|
|
53259
|
-
const sourcePath =
|
|
53260
|
-
if (!
|
|
53411
|
+
const sourcePath = join124(vttDir, filename);
|
|
53412
|
+
if (!existsSync95(sourcePath)) {
|
|
53261
53413
|
console.error(`Error: VTT file not found: ${sourcePath}`);
|
|
53262
53414
|
process.exit(1);
|
|
53263
53415
|
}
|
|
53264
53416
|
const base = basename31(filename, ".vtt").replace(/ Transcription$/, "");
|
|
53265
53417
|
const outputName = `${date} ${base}.md`;
|
|
53266
|
-
const formattedDir =
|
|
53418
|
+
const formattedDir = join124(transcriptsDir, client);
|
|
53267
53419
|
mkdirSync41(formattedDir, { recursive: true });
|
|
53268
|
-
const formattedPath =
|
|
53420
|
+
const formattedPath = join124(formattedDir, outputName);
|
|
53269
53421
|
writeFileSync56(formattedPath, convertVttToMarkdown(sourcePath), "utf8");
|
|
53270
53422
|
archiveRawVtt(vttDir, sourcePath, filename);
|
|
53271
|
-
const summaryPath =
|
|
53423
|
+
const summaryPath = join124(summaryDir, client, outputName);
|
|
53272
53424
|
console.log(`Formatted transcript: ${formattedPath}`);
|
|
53273
53425
|
console.log(`Summary target: ${summaryPath}`);
|
|
53274
53426
|
}
|
|
53275
53427
|
|
|
53276
53428
|
// src/commands/transcript/merge.ts
|
|
53277
|
-
import { existsSync as
|
|
53429
|
+
import { existsSync as existsSync96, writeFileSync as writeFileSync57 } from "fs";
|
|
53278
53430
|
import { basename as basename32 } from "path";
|
|
53279
53431
|
|
|
53280
53432
|
// src/commands/transcript/failTranscript.ts
|
|
@@ -53418,7 +53570,7 @@ function widenAudience(passages) {
|
|
|
53418
53570
|
|
|
53419
53571
|
// src/commands/transcript/merge.ts
|
|
53420
53572
|
function readSource3(file) {
|
|
53421
|
-
if (!
|
|
53573
|
+
if (!existsSync96(file)) failTranscript(`VTT file not found: ${file}`);
|
|
53422
53574
|
const cues = readCleanedCues(file);
|
|
53423
53575
|
if (cues.length === 0) failTranscript(`no cues found in: ${file}`);
|
|
53424
53576
|
return { path: file, name: basename32(file), cues };
|
|
@@ -53890,7 +54042,7 @@ function configKeys2() {
|
|
|
53890
54042
|
}
|
|
53891
54043
|
|
|
53892
54044
|
// src/commands/verify/forbiddenStrings.ts
|
|
53893
|
-
import { existsSync as
|
|
54045
|
+
import { existsSync as existsSync97, readFileSync as readFileSync85 } from "fs";
|
|
53894
54046
|
|
|
53895
54047
|
// src/commands/verify/forbiddenStrings/findForbiddenStrings.ts
|
|
53896
54048
|
import { minimatch as minimatch10 } from "minimatch";
|
|
@@ -53931,7 +54083,7 @@ function forbiddenStrings() {
|
|
|
53931
54083
|
const cache7 = /* @__PURE__ */ new Map();
|
|
53932
54084
|
const readJson2 = (file) => {
|
|
53933
54085
|
if (cache7.has(file)) return cache7.get(file);
|
|
53934
|
-
if (!
|
|
54086
|
+
if (!existsSync97(file)) {
|
|
53935
54087
|
console.log(`Forbidden-strings file not found: ${file}`);
|
|
53936
54088
|
process.exit(1);
|
|
53937
54089
|
}
|
|
@@ -54126,10 +54278,10 @@ function checkSequential(migrations3, files) {
|
|
|
54126
54278
|
}
|
|
54127
54279
|
|
|
54128
54280
|
// src/commands/verify/migrations/listMigrationFiles.ts
|
|
54129
|
-
import { readdirSync as
|
|
54281
|
+
import { readdirSync as readdirSync27 } from "fs";
|
|
54130
54282
|
var MIGRATION_FILE2 = /^migration\d+[A-Za-z0-9]*\.ts$/;
|
|
54131
54283
|
function listMigrationFiles(dir) {
|
|
54132
|
-
return
|
|
54284
|
+
return readdirSync27(dir).filter((file) => MIGRATION_FILE2.test(file));
|
|
54133
54285
|
}
|
|
54134
54286
|
|
|
54135
54287
|
// src/commands/verify/migrations/readBaselineMigrations.ts
|
|
@@ -54412,7 +54564,7 @@ function clearBuildPending() {
|
|
|
54412
54564
|
}
|
|
54413
54565
|
|
|
54414
54566
|
// src/commands/watch/isSyncPending.ts
|
|
54415
|
-
import { existsSync as
|
|
54567
|
+
import { existsSync as existsSync98 } from "fs";
|
|
54416
54568
|
|
|
54417
54569
|
// src/commands/watch/syncPendingPath.ts
|
|
54418
54570
|
function syncPendingPath(cwd) {
|
|
@@ -54422,7 +54574,7 @@ function syncPendingPath(cwd) {
|
|
|
54422
54574
|
// src/commands/watch/isSyncPending.ts
|
|
54423
54575
|
function isSyncPending() {
|
|
54424
54576
|
try {
|
|
54425
|
-
return
|
|
54577
|
+
return existsSync98(syncPendingPath());
|
|
54426
54578
|
} catch {
|
|
54427
54579
|
return false;
|
|
54428
54580
|
}
|
|
@@ -54549,7 +54701,7 @@ function resolveParams(params, cliArgs) {
|
|
|
54549
54701
|
}
|
|
54550
54702
|
|
|
54551
54703
|
// src/commands/run/resolveRunCwd.ts
|
|
54552
|
-
import { existsSync as
|
|
54704
|
+
import { existsSync as existsSync99 } from "fs";
|
|
54553
54705
|
import { resolve as resolve32 } from "path";
|
|
54554
54706
|
var MissingRunCwdError = class extends Error {
|
|
54555
54707
|
constructor(runName, cwd) {
|
|
@@ -54564,7 +54716,7 @@ var MissingRunCwdError = class extends Error {
|
|
|
54564
54716
|
function resolveRunCwd(config, baseDir = runConfigBaseDir()) {
|
|
54565
54717
|
if (!config.cwd) return void 0;
|
|
54566
54718
|
const cwd = resolve32(baseDir, config.cwd);
|
|
54567
|
-
if (!
|
|
54719
|
+
if (!existsSync99(cwd)) throw new MissingRunCwdError(config.name, cwd);
|
|
54568
54720
|
return cwd;
|
|
54569
54721
|
}
|
|
54570
54722
|
|
|
@@ -54899,10 +55051,10 @@ ${buildWatchReport(from)}`);
|
|
|
54899
55051
|
}
|
|
54900
55052
|
|
|
54901
55053
|
// src/commands/watch/consumeMarker.ts
|
|
54902
|
-
import { existsSync as
|
|
55054
|
+
import { existsSync as existsSync100, rmSync as rmSync15 } from "fs";
|
|
54903
55055
|
function consumeMarker(path128) {
|
|
54904
55056
|
try {
|
|
54905
|
-
if (!
|
|
55057
|
+
if (!existsSync100(path128)) return false;
|
|
54906
55058
|
rmSync15(path128);
|
|
54907
55059
|
return true;
|
|
54908
55060
|
} catch {
|
|
@@ -55199,17 +55351,17 @@ function registerWatch(program) {
|
|
|
55199
55351
|
|
|
55200
55352
|
// src/commands/roam/postRoamActivity.ts
|
|
55201
55353
|
import { execFileSync as execFileSync34 } from "child_process";
|
|
55202
|
-
import { readdirSync as
|
|
55203
|
-
import { join as
|
|
55354
|
+
import { readdirSync as readdirSync28, readFileSync as readFileSync87, statSync as statSync18 } from "fs";
|
|
55355
|
+
import { join as join125 } from "path";
|
|
55204
55356
|
function findPortFile(roamDir) {
|
|
55205
55357
|
let entries2;
|
|
55206
55358
|
try {
|
|
55207
|
-
entries2 =
|
|
55359
|
+
entries2 = readdirSync28(roamDir);
|
|
55208
55360
|
} catch {
|
|
55209
55361
|
return void 0;
|
|
55210
55362
|
}
|
|
55211
55363
|
const candidates = entries2.filter((name2) => /^roam-local-api(-[^.]+)?\.port$/.test(name2)).map((name2) => {
|
|
55212
|
-
const path128 =
|
|
55364
|
+
const path128 = join125(roamDir, name2);
|
|
55213
55365
|
try {
|
|
55214
55366
|
return { path: path128, mtimeMs: statSync18(path128).mtimeMs };
|
|
55215
55367
|
} catch {
|
|
@@ -55226,7 +55378,7 @@ var PID_BY_APP = {
|
|
|
55226
55378
|
function postRoamActivity(app, event) {
|
|
55227
55379
|
const appData = process.env.APPDATA;
|
|
55228
55380
|
if (!appData) return;
|
|
55229
|
-
const portFile = findPortFile(
|
|
55381
|
+
const portFile = findPortFile(join125(appData, "Roam"));
|
|
55230
55382
|
if (!portFile) return;
|
|
55231
55383
|
let port;
|
|
55232
55384
|
try {
|
|
@@ -55585,11 +55737,11 @@ function requireParsedArgs() {
|
|
|
55585
55737
|
}
|
|
55586
55738
|
|
|
55587
55739
|
// src/commands/run/runCommandFilePath.ts
|
|
55588
|
-
import { join as
|
|
55740
|
+
import { join as join126 } from "path";
|
|
55589
55741
|
function runCommandFilePath(name2) {
|
|
55590
55742
|
const segments = name2.split(":");
|
|
55591
55743
|
const file = `${segments.pop()}.md`;
|
|
55592
|
-
return
|
|
55744
|
+
return join126(".claude", "commands", ...segments, file);
|
|
55593
55745
|
}
|
|
55594
55746
|
|
|
55595
55747
|
// src/commands/run/add.ts
|
|
@@ -55733,8 +55885,8 @@ function registerRunAdd(runCommand) {
|
|
|
55733
55885
|
}
|
|
55734
55886
|
|
|
55735
55887
|
// src/commands/run/remove.ts
|
|
55736
|
-
import { existsSync as
|
|
55737
|
-
import { dirname as dirname52, join as
|
|
55888
|
+
import { existsSync as existsSync101, readdirSync as readdirSync29, rmdirSync, unlinkSync as unlinkSync20 } from "fs";
|
|
55889
|
+
import { dirname as dirname52, join as join127 } from "path";
|
|
55738
55890
|
|
|
55739
55891
|
// src/commands/run/removeRepoRunConfig.ts
|
|
55740
55892
|
function isNamed(entry, name2) {
|
|
@@ -55752,17 +55904,17 @@ function removeRepoRunConfig(name2, repoName, cwd = process.cwd()) {
|
|
|
55752
55904
|
|
|
55753
55905
|
// src/commands/run/remove.ts
|
|
55754
55906
|
function removeEmptyNamespaceDirs(filePath) {
|
|
55755
|
-
const root2 =
|
|
55907
|
+
const root2 = join127(".claude", "commands");
|
|
55756
55908
|
for (let dir = dirname52(filePath); dir !== root2; dir = dirname52(dir)) {
|
|
55757
|
-
if (!
|
|
55909
|
+
if (!existsSync101(dir) || readdirSync29(dir).length > 0) return;
|
|
55758
55910
|
rmdirSync(dir);
|
|
55759
55911
|
}
|
|
55760
55912
|
}
|
|
55761
55913
|
function deleteCommandFile(name2) {
|
|
55762
55914
|
const filePath = runCommandFilePath(name2);
|
|
55763
|
-
const legacyPath =
|
|
55915
|
+
const legacyPath = join127(".claude", "commands", `${name2}.md`);
|
|
55764
55916
|
for (const path128 of /* @__PURE__ */ new Set([filePath, legacyPath])) {
|
|
55765
|
-
if (
|
|
55917
|
+
if (existsSync101(path128)) {
|
|
55766
55918
|
unlinkSync20(path128);
|
|
55767
55919
|
console.log(`Deleted command file: ${path128}`);
|
|
55768
55920
|
}
|
|
@@ -56367,13 +56519,6 @@ async function refreshRepoConfigCacheOnStart() {
|
|
|
56367
56519
|
}
|
|
56368
56520
|
}
|
|
56369
56521
|
|
|
56370
|
-
// src/commands/sessions/daemon/liveSessionCount.ts
|
|
56371
|
-
function liveSessionCount(sessions) {
|
|
56372
|
-
let count10 = 0;
|
|
56373
|
-
for (const session of sessions.values()) if (!session.leftoverNotice) count10++;
|
|
56374
|
-
return count10;
|
|
56375
|
-
}
|
|
56376
|
-
|
|
56377
56522
|
// src/commands/sessions/daemon/loadActiveSelection.ts
|
|
56378
56523
|
import { z as z26 } from "zod";
|
|
56379
56524
|
var ACTIVE_FILE = "active.json";
|
|
@@ -56497,13 +56642,15 @@ function toSessionViewInfo({
|
|
|
56497
56642
|
pty: pty2,
|
|
56498
56643
|
sdkActivity,
|
|
56499
56644
|
sdkQueued,
|
|
56500
|
-
sdkInterrupting
|
|
56645
|
+
sdkInterrupting,
|
|
56646
|
+
sdkResuming
|
|
56501
56647
|
}) {
|
|
56502
56648
|
return {
|
|
56503
56649
|
sdk: pty2?.sdk ? true : void 0,
|
|
56504
56650
|
sdkActivity,
|
|
56505
56651
|
sdkQueued,
|
|
56506
56652
|
sdkInterrupting,
|
|
56653
|
+
sdkResuming,
|
|
56507
56654
|
transfer,
|
|
56508
56655
|
lastUserMessage,
|
|
56509
56656
|
lastAssistantMessage,
|
|
@@ -56515,12 +56662,12 @@ function toSessionViewInfo({
|
|
|
56515
56662
|
}
|
|
56516
56663
|
|
|
56517
56664
|
// src/commands/sessions/daemon/worktree/joinRefusal.ts
|
|
56518
|
-
import { existsSync as
|
|
56665
|
+
import { existsSync as existsSync102 } from "fs";
|
|
56519
56666
|
function joinRefusal(session) {
|
|
56520
56667
|
if (session.commandType === "run") return "a server run has no agent stream";
|
|
56521
56668
|
if (session.closing === true) return "the session is closing";
|
|
56522
56669
|
if (!session.cwd) return "the session has no working directory";
|
|
56523
|
-
if (!
|
|
56670
|
+
if (!existsSync102(session.cwd))
|
|
56524
56671
|
return "the session's workspace no longer exists";
|
|
56525
56672
|
return void 0;
|
|
56526
56673
|
}
|
|
@@ -56610,8 +56757,8 @@ function broadcastSessions(sessions, clients, linkedSessions = [], active) {
|
|
|
56610
56757
|
}
|
|
56611
56758
|
|
|
56612
56759
|
// src/commands/sessions/daemon/findServerParents.ts
|
|
56613
|
-
import { existsSync as
|
|
56614
|
-
import { join as
|
|
56760
|
+
import { existsSync as existsSync103 } from "fs";
|
|
56761
|
+
import { join as join128, resolve as resolve33 } from "path";
|
|
56615
56762
|
function isLive(session) {
|
|
56616
56763
|
return !!session.pty && session.status !== "done" && session.status !== "error";
|
|
56617
56764
|
}
|
|
@@ -56620,7 +56767,7 @@ function isLiveAgent(session) {
|
|
|
56620
56767
|
}
|
|
56621
56768
|
function serverRunDirs(sessions, file) {
|
|
56622
56769
|
return new Set(
|
|
56623
|
-
sessions.filter((s) => s.server && s.cwd && isLive(s)).map((s) => resolve33(s.cwd)).filter((dir) =>
|
|
56770
|
+
sessions.filter((s) => s.server && s.cwd && isLive(s)).map((s) => resolve33(s.cwd)).filter((dir) => existsSync103(join128(dir, file)))
|
|
56624
56771
|
);
|
|
56625
56772
|
}
|
|
56626
56773
|
function findServerParents(sessions, file) {
|
|
@@ -57289,7 +57436,7 @@ var ClientHub = class extends Set {
|
|
|
57289
57436
|
};
|
|
57290
57437
|
|
|
57291
57438
|
// src/commands/sessions/daemon/autoUpdate/autoUpdateControl.ts
|
|
57292
|
-
import { existsSync as
|
|
57439
|
+
import { existsSync as existsSync104, rmSync as rmSync16, writeFileSync as writeFileSync62 } from "fs";
|
|
57293
57440
|
var paused;
|
|
57294
57441
|
var wake;
|
|
57295
57442
|
var holdReleased = false;
|
|
@@ -57302,7 +57449,7 @@ function persist2(value) {
|
|
|
57302
57449
|
}
|
|
57303
57450
|
var autoUpdateControl = {
|
|
57304
57451
|
paused: () => {
|
|
57305
|
-
paused ??=
|
|
57452
|
+
paused ??= existsSync104(daemonPaths.autoUpdatePaused);
|
|
57306
57453
|
return paused;
|
|
57307
57454
|
},
|
|
57308
57455
|
setPaused: (value) => {
|
|
@@ -57645,13 +57792,13 @@ function bindResumedWorktree(session, cwd, notify2) {
|
|
|
57645
57792
|
}
|
|
57646
57793
|
|
|
57647
57794
|
// src/commands/sessions/daemon/worktree/treeDurability.ts
|
|
57648
|
-
import { existsSync as
|
|
57795
|
+
import { existsSync as existsSync106 } from "fs";
|
|
57649
57796
|
|
|
57650
57797
|
// src/commands/sessions/daemon/worktree/holdsNoCheckout.ts
|
|
57651
|
-
import { existsSync as
|
|
57652
|
-
import { join as
|
|
57798
|
+
import { existsSync as existsSync105 } from "fs";
|
|
57799
|
+
import { join as join130 } from "path";
|
|
57653
57800
|
function holdsNoCheckout(path128) {
|
|
57654
|
-
return
|
|
57801
|
+
return existsSync105(path128) && !existsSync105(join130(path128, ".git"));
|
|
57655
57802
|
}
|
|
57656
57803
|
|
|
57657
57804
|
// src/commands/sessions/daemon/worktree/treeDurability.ts
|
|
@@ -57689,14 +57836,14 @@ function notACheckout(cwd, error) {
|
|
|
57689
57836
|
return holdsNoCheckout(cwd) && /not a git repository/i.test(error);
|
|
57690
57837
|
}
|
|
57691
57838
|
async function checkDurability(cwd) {
|
|
57692
|
-
if (!
|
|
57839
|
+
if (!existsSync106(cwd)) return treeIsGone;
|
|
57693
57840
|
const probes = durabilityProbes(cwd);
|
|
57694
57841
|
let step3 = probes.next();
|
|
57695
57842
|
while (!step3.done) step3 = probes.next(await gitResult(cwd, step3.value));
|
|
57696
57843
|
return step3.value;
|
|
57697
57844
|
}
|
|
57698
57845
|
function checkDurabilitySync(cwd) {
|
|
57699
|
-
if (!
|
|
57846
|
+
if (!existsSync106(cwd)) return treeIsGone;
|
|
57700
57847
|
const probes = durabilityProbes(cwd);
|
|
57701
57848
|
let step3 = probes.next();
|
|
57702
57849
|
while (!step3.done) step3 = probes.next(gitSyncResult(cwd, step3.value));
|
|
@@ -57989,17 +58136,17 @@ function setStatus2(session, newStatus) {
|
|
|
57989
58136
|
}
|
|
57990
58137
|
|
|
57991
58138
|
// src/commands/sessions/daemon/worktree/reapWorktree.ts
|
|
57992
|
-
import { existsSync as
|
|
58139
|
+
import { existsSync as existsSync108 } from "fs";
|
|
57993
58140
|
import { basename as basename34 } from "path";
|
|
57994
58141
|
|
|
57995
58142
|
// src/commands/sessions/daemon/worktree/deleteStrandedTree.ts
|
|
57996
|
-
import { existsSync as
|
|
57997
|
-
import { join as
|
|
58143
|
+
import { existsSync as existsSync107 } from "fs";
|
|
58144
|
+
import { join as join132 } from "path";
|
|
57998
58145
|
|
|
57999
58146
|
// src/commands/sessions/daemon/worktree/deleteTreeDirectly.ts
|
|
58000
58147
|
import { statSync as statSync19 } from "fs";
|
|
58001
58148
|
import { rm as rm3 } from "fs/promises";
|
|
58002
|
-
import { join as
|
|
58149
|
+
import { join as join131 } from "path";
|
|
58003
58150
|
async function deleteTreeDirectly(clone, worktreePath, why) {
|
|
58004
58151
|
if (holdsAGitDirectoryRatherThanALink(worktreePath)) {
|
|
58005
58152
|
const refusal = "it is a clone of its own, not a linked worktree";
|
|
@@ -58028,7 +58175,7 @@ async function deleteTreeDirectly(clone, worktreePath, why) {
|
|
|
58028
58175
|
return { removed: true };
|
|
58029
58176
|
}
|
|
58030
58177
|
function holdsAGitDirectoryRatherThanALink(worktreePath) {
|
|
58031
|
-
return statSync19(
|
|
58178
|
+
return statSync19(join131(worktreePath, ".git"), {
|
|
58032
58179
|
throwIfNoEntry: false
|
|
58033
58180
|
})?.isDirectory() === true;
|
|
58034
58181
|
}
|
|
@@ -58069,7 +58216,7 @@ async function deleteStrandedTree(clone, worktreePath, cause) {
|
|
|
58069
58216
|
);
|
|
58070
58217
|
}
|
|
58071
58218
|
function strandedReason(worktreePath, cause) {
|
|
58072
|
-
if (!
|
|
58219
|
+
if (!existsSync107(join132(worktreePath, ".git")))
|
|
58073
58220
|
return "its .git link is already gone";
|
|
58074
58221
|
if (/not a working tree|not a git repository/i.test(reason2(cause)))
|
|
58075
58222
|
return "git no longer recognises it as a working tree";
|
|
@@ -58121,7 +58268,7 @@ function reason3(error) {
|
|
|
58121
58268
|
|
|
58122
58269
|
// src/commands/sessions/daemon/worktree/reapWorktree.ts
|
|
58123
58270
|
async function reapWorktree(worktreePath, force = false) {
|
|
58124
|
-
if (!
|
|
58271
|
+
if (!existsSync108(worktreePath)) {
|
|
58125
58272
|
forgetWorktree(worktreePath);
|
|
58126
58273
|
daemonLog(
|
|
58127
58274
|
`worktree ${worktreePath} already gone; its record was forgotten`
|
|
@@ -58146,7 +58293,7 @@ async function reapWorktree(worktreePath, force = false) {
|
|
|
58146
58293
|
}
|
|
58147
58294
|
function owningClone(worktreePath) {
|
|
58148
58295
|
const recorded = worktreeAttributionIncludingReaped(worktreePath)?.clone;
|
|
58149
|
-
if (recorded &&
|
|
58296
|
+
if (recorded && existsSync108(recorded)) return recorded;
|
|
58150
58297
|
const detected = mainWorktree(worktreePath);
|
|
58151
58298
|
if (detected) return detected;
|
|
58152
58299
|
daemonLog(
|
|
@@ -58315,7 +58462,7 @@ function closeGateApplies(sessions, session) {
|
|
|
58315
58462
|
}
|
|
58316
58463
|
|
|
58317
58464
|
// src/commands/sessions/daemon/worktree/liveProcessesInTree.ts
|
|
58318
|
-
import { readdirSync as
|
|
58465
|
+
import { readdirSync as readdirSync30, readlinkSync } from "fs";
|
|
58319
58466
|
import { sep as sep6 } from "path";
|
|
58320
58467
|
|
|
58321
58468
|
// src/commands/sessions/daemon/worktree/readProc.ts
|
|
@@ -58338,7 +58485,7 @@ function isCodexAppServer(pid, procRoot = "/proc") {
|
|
|
58338
58485
|
function liveProcessesInTree(treePath, procRoot = "/proc") {
|
|
58339
58486
|
let entries2;
|
|
58340
58487
|
try {
|
|
58341
|
-
entries2 =
|
|
58488
|
+
entries2 = readdirSync30(procRoot);
|
|
58342
58489
|
} catch {
|
|
58343
58490
|
return [];
|
|
58344
58491
|
}
|
|
@@ -58463,12 +58610,12 @@ async function closeBlockReason(sessionId2, tree) {
|
|
|
58463
58610
|
}
|
|
58464
58611
|
|
|
58465
58612
|
// src/commands/sessions/daemon/worktree/watchGitState.ts
|
|
58466
|
-
import { existsSync as
|
|
58613
|
+
import { existsSync as existsSync109, watch } from "fs";
|
|
58467
58614
|
var DEBOUNCE_MS = 500;
|
|
58468
58615
|
var POLL_MS5 = 3e4;
|
|
58469
58616
|
function watchGitState(cwd, onChange) {
|
|
58470
58617
|
const common = gitCommonDir(cwd);
|
|
58471
|
-
if (!common || !
|
|
58618
|
+
if (!common || !existsSync109(common)) return void 0;
|
|
58472
58619
|
const watchers = [
|
|
58473
58620
|
watchGitDir(common, onChange),
|
|
58474
58621
|
pollGitState(cwd, onChange)
|
|
@@ -59232,7 +59379,7 @@ function emitSessionOutput(session, clients, data) {
|
|
|
59232
59379
|
}
|
|
59233
59380
|
|
|
59234
59381
|
// src/commands/sessions/daemon/exitReason.ts
|
|
59235
|
-
import { existsSync as
|
|
59382
|
+
import { existsSync as existsSync110 } from "fs";
|
|
59236
59383
|
import { resolve as resolve35 } from "path";
|
|
59237
59384
|
|
|
59238
59385
|
// src/commands/sessions/daemon/resolveRunConfig.ts
|
|
@@ -59251,7 +59398,7 @@ function resolveRunConfig(name2, cwd) {
|
|
|
59251
59398
|
|
|
59252
59399
|
// src/commands/sessions/daemon/exitReason.ts
|
|
59253
59400
|
function exitDetail(session) {
|
|
59254
|
-
if (session.cwd && !
|
|
59401
|
+
if (session.cwd && !existsSync110(session.cwd))
|
|
59255
59402
|
return `working directory ${session.cwd} no longer exists`;
|
|
59256
59403
|
return missingRunConfigCwd(session);
|
|
59257
59404
|
}
|
|
@@ -59265,7 +59412,7 @@ function missingRunConfigCwd(session) {
|
|
|
59265
59412
|
const config = resolveRunConfig(session.runName, dir);
|
|
59266
59413
|
if (!config?.cwd) return void 0;
|
|
59267
59414
|
const configured = resolve35(runConfigBaseDirFrom(dir), config.cwd);
|
|
59268
|
-
if (
|
|
59415
|
+
if (existsSync110(configured)) return void 0;
|
|
59269
59416
|
return `run config "${config.name}": cwd ${configured} does not exist`;
|
|
59270
59417
|
}
|
|
59271
59418
|
|
|
@@ -59313,7 +59460,7 @@ function handleRefusedRun(session, exitCode, onStatusChange) {
|
|
|
59313
59460
|
}
|
|
59314
59461
|
|
|
59315
59462
|
// src/commands/sessions/daemon/watchActivity.ts
|
|
59316
|
-
import { existsSync as
|
|
59463
|
+
import { existsSync as existsSync111, mkdirSync as mkdirSync44, watch as watch2 } from "fs";
|
|
59317
59464
|
import { dirname as dirname55 } from "path";
|
|
59318
59465
|
|
|
59319
59466
|
// src/commands/sessions/daemon/applyActivityToSession.ts
|
|
@@ -59521,7 +59668,7 @@ function watchActivity(session, notify2, onConversation) {
|
|
|
59521
59668
|
if (timer) clearTimeout(timer);
|
|
59522
59669
|
timer = setTimeout(read4, DEBOUNCE_MS2);
|
|
59523
59670
|
});
|
|
59524
|
-
if (
|
|
59671
|
+
if (existsSync111(path128)) read4();
|
|
59525
59672
|
}
|
|
59526
59673
|
function refreshActivity(session) {
|
|
59527
59674
|
if (session.commandType !== "assist" || !session.cwd) return;
|
|
@@ -59587,6 +59734,9 @@ function applyViewEvent(session, event) {
|
|
|
59587
59734
|
} else if (event.kind === "queued") {
|
|
59588
59735
|
session.sdkQueued = event.texts.length ? event.texts : void 0;
|
|
59589
59736
|
daemonLog(`session ${session.id} sdk queued: ${event.texts.length}`);
|
|
59737
|
+
} else if (event.kind === "resumed") {
|
|
59738
|
+
session.sdkResuming = void 0;
|
|
59739
|
+
daemonLog(`session ${session.id} sdk resumed: composer unlocked`);
|
|
59590
59740
|
} else {
|
|
59591
59741
|
session.sdkInterrupting = event.pending || void 0;
|
|
59592
59742
|
daemonLog(
|
|
@@ -59938,9 +60088,7 @@ function makeSessionSpawner(sessions, clients, counter, onStatusChange, notify2)
|
|
|
59938
60088
|
context
|
|
59939
60089
|
);
|
|
59940
60090
|
return {
|
|
59941
|
-
spawn: register(
|
|
59942
|
-
() => sessionLimits.nextId(liveSessionCount(sessions), counter)
|
|
59943
|
-
),
|
|
60091
|
+
spawn: register(() => sessionLimits.nextId(sessions.size, counter)),
|
|
59944
60092
|
recoveryCard: register(() => sessionLimits.recoveryCardId(counter))
|
|
59945
60093
|
};
|
|
59946
60094
|
}
|
|
@@ -60640,12 +60788,12 @@ function conversationResumeOutcome(session) {
|
|
|
60640
60788
|
}
|
|
60641
60789
|
|
|
60642
60790
|
// src/commands/sessions/daemon/interactiveRespawnPlan.ts
|
|
60643
|
-
function interactiveRespawnPlan(session) {
|
|
60791
|
+
function interactiveRespawnPlan(session, fresh = false) {
|
|
60644
60792
|
const adapter = harnessAdapter(session.harness);
|
|
60645
60793
|
if (!resolveCapability(adapter.capabilities, "conversation.resume").supported)
|
|
60646
60794
|
return null;
|
|
60647
60795
|
const { cwd, initialPrompt } = session;
|
|
60648
|
-
const resumeId = adapter.conversation.findResumable(session);
|
|
60796
|
+
const resumeId = fresh ? void 0 : adapter.conversation.findResumable(session);
|
|
60649
60797
|
if (resumeId)
|
|
60650
60798
|
return {
|
|
60651
60799
|
spawn: () => adapter.interactive({
|
|
@@ -60656,7 +60804,7 @@ function interactiveRespawnPlan(session) {
|
|
|
60656
60804
|
}),
|
|
60657
60805
|
status: "waiting"
|
|
60658
60806
|
};
|
|
60659
|
-
if (!initialPrompt && !cwd) return null;
|
|
60807
|
+
if (!fresh && !initialPrompt && !cwd) return null;
|
|
60660
60808
|
return freshPlan(session, adapter, initialPrompt);
|
|
60661
60809
|
}
|
|
60662
60810
|
function freshPlan(session, adapter, prompt) {
|
|
@@ -60680,17 +60828,21 @@ function freshPlan(session, adapter, prompt) {
|
|
|
60680
60828
|
}
|
|
60681
60829
|
|
|
60682
60830
|
// src/commands/sessions/daemon/respawnPlan.ts
|
|
60683
|
-
function respawnPlan(session) {
|
|
60831
|
+
function respawnPlan(session, fresh = false) {
|
|
60684
60832
|
const { commandType, cwd, assistArgs } = session;
|
|
60685
|
-
if (commandType === "claude") return interactiveRespawnPlan(session);
|
|
60833
|
+
if (commandType === "claude") return interactiveRespawnPlan(session, fresh);
|
|
60686
60834
|
if (commandType === "assist" && assistArgs) {
|
|
60687
|
-
const idle = session.status === "waiting";
|
|
60835
|
+
const idle = !fresh && session.status === "waiting";
|
|
60688
60836
|
let resume;
|
|
60689
60837
|
return {
|
|
60690
60838
|
spawn: () => {
|
|
60691
|
-
|
|
60839
|
+
if (fresh) {
|
|
60840
|
+
session.claudeSessionId = void 0;
|
|
60841
|
+
session.harnessSessionId = void 0;
|
|
60842
|
+
}
|
|
60843
|
+
resume = fresh ? void 0 : conversationResumeOutcome(session);
|
|
60692
60844
|
return spawnPty(
|
|
60693
|
-
assistResumeArgs({ assistArgs, resumeSessionId: resume
|
|
60845
|
+
assistResumeArgs({ assistArgs, resumeSessionId: resume?.id }),
|
|
60694
60846
|
cwd,
|
|
60695
60847
|
session.id,
|
|
60696
60848
|
idle ? { ASSIST_RESUME_IDLE: "1" } : void 0
|
|
@@ -60704,8 +60856,10 @@ function respawnPlan(session) {
|
|
|
60704
60856
|
}
|
|
60705
60857
|
|
|
60706
60858
|
// src/commands/sessions/daemon/restartSession.ts
|
|
60707
|
-
function restartSession(session, clients, onStatusChange) {
|
|
60708
|
-
|
|
60859
|
+
function restartSession(session, clients, onStatusChange, fresh = false) {
|
|
60860
|
+
if (fresh)
|
|
60861
|
+
daemonLog(`session ${session.id} start-over requested: ${session.name}`);
|
|
60862
|
+
const plan2 = respawnPlan(session, fresh);
|
|
60709
60863
|
if (!plan2) return false;
|
|
60710
60864
|
const respawn = () => {
|
|
60711
60865
|
respawnSession(session, plan2.spawn, plan2.status, clients, onStatusChange);
|
|
@@ -60733,7 +60887,7 @@ function restartSession(session, clients, onStatusChange) {
|
|
|
60733
60887
|
}
|
|
60734
60888
|
|
|
60735
60889
|
// src/commands/sessions/daemon/restartManagedSession.ts
|
|
60736
|
-
function restartManagedSession(sessions, id, clients, onStatusChange) {
|
|
60890
|
+
function restartManagedSession(sessions, id, clients, onStatusChange, fresh = false) {
|
|
60737
60891
|
const s = sessions.get(id);
|
|
60738
60892
|
if (!s) {
|
|
60739
60893
|
daemonLog(
|
|
@@ -60745,7 +60899,7 @@ function restartManagedSession(sessions, id, clients, onStatusChange) {
|
|
|
60745
60899
|
};
|
|
60746
60900
|
}
|
|
60747
60901
|
daemonLog(`restart requested: id=${id} status=${s.status} (${s.name})`);
|
|
60748
|
-
if (!restartSession(s, clients, onStatusChange)) {
|
|
60902
|
+
if (!restartSession(s, clients, onStatusChange, fresh)) {
|
|
60749
60903
|
daemonLog(`restart for session ${id} did nothing: no respawn plan`);
|
|
60750
60904
|
return {
|
|
60751
60905
|
ok: false,
|
|
@@ -60756,8 +60910,14 @@ function restartManagedSession(sessions, id, clients, onStatusChange) {
|
|
|
60756
60910
|
}
|
|
60757
60911
|
|
|
60758
60912
|
// src/commands/sessions/daemon/restartAndNotify.ts
|
|
60759
|
-
function restartAndNotify(sessions, id, clients, onStatusChange, notify2) {
|
|
60760
|
-
const result = restartManagedSession(
|
|
60913
|
+
function restartAndNotify(sessions, id, clients, onStatusChange, notify2, fresh = false) {
|
|
60914
|
+
const result = restartManagedSession(
|
|
60915
|
+
sessions,
|
|
60916
|
+
id,
|
|
60917
|
+
clients,
|
|
60918
|
+
onStatusChange,
|
|
60919
|
+
fresh
|
|
60920
|
+
);
|
|
60761
60921
|
if (result.ok) notify2();
|
|
60762
60922
|
return result;
|
|
60763
60923
|
}
|
|
@@ -61280,7 +61440,12 @@ function restoreConversation(adapter, restored, status2) {
|
|
|
61280
61440
|
sessionId: id,
|
|
61281
61441
|
...sessionModeLaunch(adapter, persisted)
|
|
61282
61442
|
});
|
|
61283
|
-
|
|
61443
|
+
const session = plan2.idle ? waitingSession(base, persisted, pty2) : runningSession(base, persisted, pty2);
|
|
61444
|
+
if (!pty2?.sdk) return session;
|
|
61445
|
+
daemonLog(
|
|
61446
|
+
`session ${id} sdk resuming claude session ${resumeId} after daemon restart: composer locked until the resume completes`
|
|
61447
|
+
);
|
|
61448
|
+
return { ...session, sdkResuming: true };
|
|
61284
61449
|
}
|
|
61285
61450
|
|
|
61286
61451
|
// src/commands/sessions/daemon/serverRunMeta.ts
|
|
@@ -61523,9 +61688,9 @@ function accountedTrees(sessions) {
|
|
|
61523
61688
|
}
|
|
61524
61689
|
|
|
61525
61690
|
// src/commands/sessions/daemon/worktree/reclaimVanishedWorktrees.ts
|
|
61526
|
-
import { existsSync as
|
|
61691
|
+
import { existsSync as existsSync112 } from "fs";
|
|
61527
61692
|
async function reclaimVanishedWorktrees(clone, paths) {
|
|
61528
|
-
if (!
|
|
61693
|
+
if (!existsSync112(clone)) {
|
|
61529
61694
|
for (const { path: path128 } of paths) forgetWorktree(path128);
|
|
61530
61695
|
daemonLog(
|
|
61531
61696
|
`clone ${clone} is gone; forgot ${paths.length} worktree record(s) it owned`
|
|
@@ -61659,21 +61824,19 @@ function recoveryNotice({ orphan, held }) {
|
|
|
61659
61824
|
].join("");
|
|
61660
61825
|
}
|
|
61661
61826
|
|
|
61662
|
-
// src/commands/sessions/daemon/worktree/reportLeftoversEnabled.ts
|
|
61663
|
-
function reportLeftoversEnabled() {
|
|
61664
|
-
return loadConfig().sessions?.reportLeftovers ?? true;
|
|
61665
|
-
}
|
|
61666
|
-
|
|
61667
61827
|
// src/commands/sessions/daemon/worktree/recoverOrphan.ts
|
|
61668
61828
|
async function recoverOrphan(sessions, spawnWith, orphan, notify2) {
|
|
61669
61829
|
daemonLog(`worktree ${orphan.path} orphaned across restart; reconciling`);
|
|
61670
61830
|
const durability = await checkDurability(orphan.path);
|
|
61671
61831
|
if (durability.durable) {
|
|
61672
61832
|
const removal = await reapWorktree(orphan.path);
|
|
61673
|
-
if (removal.removed
|
|
61674
|
-
|
|
61675
|
-
|
|
61676
|
-
|
|
61833
|
+
if (!removal.removed && holdsNoCheckout(orphan.path) && reportLeftoversEnabled()) {
|
|
61834
|
+
markLeftover(orphan.path, removal.reason);
|
|
61835
|
+
daemonLog(
|
|
61836
|
+
`worktree ${orphan.path} could not be reaped; recorded as a leftover so restarts stop retrying it`
|
|
61837
|
+
);
|
|
61838
|
+
}
|
|
61839
|
+
return;
|
|
61677
61840
|
}
|
|
61678
61841
|
const held = await describeHeldWork(orphan.path, durability.reason);
|
|
61679
61842
|
resurfaceOrphanedWorktree(
|
|
@@ -61682,61 +61845,24 @@ async function recoverOrphan(sessions, spawnWith, orphan, notify2) {
|
|
|
61682
61845
|
{ orphan, reason: durability.reason, held },
|
|
61683
61846
|
notify2
|
|
61684
61847
|
);
|
|
61685
|
-
return void 0;
|
|
61686
|
-
}
|
|
61687
|
-
|
|
61688
|
-
// src/commands/sessions/daemon/worktree/recheckReapedWorktrees.ts
|
|
61689
|
-
import { existsSync as existsSync112 } from "fs";
|
|
61690
|
-
|
|
61691
|
-
// src/commands/sessions/daemon/worktree/leftoverContents.ts
|
|
61692
|
-
import { lstatSync, readdirSync as readdirSync30 } from "fs";
|
|
61693
|
-
import { join as join132 } from "path";
|
|
61694
|
-
function leftoverContents(path128) {
|
|
61695
|
-
const contents = { holdsFiles: false, foreignOwned: false };
|
|
61696
|
-
walk2(path128, contents, process.getuid?.());
|
|
61697
|
-
return contents;
|
|
61698
|
-
}
|
|
61699
|
-
function walk2(path128, contents, uid) {
|
|
61700
|
-
const stat5 = lstatSync(path128, { throwIfNoEntry: false });
|
|
61701
|
-
if (!stat5) return;
|
|
61702
|
-
if (uid !== void 0 && stat5.uid !== uid) contents.foreignOwned = true;
|
|
61703
|
-
if (!stat5.isDirectory()) {
|
|
61704
|
-
contents.holdsFiles = true;
|
|
61705
|
-
return;
|
|
61706
|
-
}
|
|
61707
|
-
let entries2;
|
|
61708
|
-
try {
|
|
61709
|
-
entries2 = readdirSync30(path128);
|
|
61710
|
-
} catch {
|
|
61711
|
-
contents.foreignOwned = true;
|
|
61712
|
-
contents.holdsFiles = true;
|
|
61713
|
-
return;
|
|
61714
|
-
}
|
|
61715
|
-
for (const entry of entries2) walk2(join132(path128, entry), contents, uid);
|
|
61716
61848
|
}
|
|
61717
61849
|
|
|
61718
61850
|
// src/commands/sessions/daemon/worktree/recheckReapedWorktrees.ts
|
|
61719
61851
|
async function recheckReapedWorktrees(accounted) {
|
|
61720
|
-
const leftovers = [];
|
|
61721
61852
|
for (const record3 of readReapedWorktreeRegistry()) {
|
|
61722
|
-
if (
|
|
61723
|
-
if (record3.
|
|
61724
|
-
if (existsSync112(record3.path))
|
|
61725
|
-
leftovers.push({ path: record3.path, reason: record3.leftover });
|
|
61726
|
-
else clearLeftover(record3.path);
|
|
61727
|
-
continue;
|
|
61728
|
-
}
|
|
61729
|
-
if (!holdsNoCheckout(record3.path)) continue;
|
|
61853
|
+
if (record3.leftover || accounted.has(record3.path)) continue;
|
|
61854
|
+
if (underTempRoot(record3.path) || !holdsNoCheckout(record3.path)) continue;
|
|
61730
61855
|
const reason4 = await clearReappearedTree(record3);
|
|
61731
61856
|
if (!reason4) continue;
|
|
61732
61857
|
markLeftover(record3.path, reason4);
|
|
61733
|
-
|
|
61858
|
+
daemonLog(
|
|
61859
|
+
`worktree ${record3.path} reappeared after reaping and is recorded as a leftover: ${reason4}`
|
|
61860
|
+
);
|
|
61734
61861
|
}
|
|
61735
|
-
return leftovers;
|
|
61736
61862
|
}
|
|
61737
61863
|
async function clearReappearedTree(record3) {
|
|
61738
61864
|
const contents = leftoverContents(record3.path);
|
|
61739
|
-
if (contents.holdsFiles) return reviewFirst(
|
|
61865
|
+
if (contents.holdsFiles) return reviewFirst(contents);
|
|
61740
61866
|
const removal = await deleteTreeDirectly(
|
|
61741
61867
|
record3.clone,
|
|
61742
61868
|
record3.path,
|
|
@@ -61744,96 +61870,8 @@ async function clearReappearedTree(record3) {
|
|
|
61744
61870
|
);
|
|
61745
61871
|
return removal.removed ? null : removal.reason;
|
|
61746
61872
|
}
|
|
61747
|
-
function reviewFirst(
|
|
61748
|
-
|
|
61749
|
-
return `it reappeared after its worktree was reaped and holds files assist will not delete unreviewed; check them, then remove it with \`${command}\``;
|
|
61750
|
-
}
|
|
61751
|
-
|
|
61752
|
-
// src/commands/sessions/daemon/worktree/reportLeftovers.ts
|
|
61753
|
-
import { homedir as homedir32 } from "os";
|
|
61754
|
-
|
|
61755
|
-
// src/commands/sessions/daemon/worktree/noticeContent.ts
|
|
61756
|
-
function noticeContent(leftovers) {
|
|
61757
|
-
const command = removalCommand(leftovers);
|
|
61758
|
-
const count10 = `${leftovers.length} leftover workspace${leftovers.length === 1 ? "" : "s"}`;
|
|
61759
|
-
const message4 = `${count10} could not be deleted; remove ${leftovers.length === 1 ? "it" : "them"} with: ${command}`;
|
|
61760
|
-
return {
|
|
61761
|
-
name: "leftover workspaces",
|
|
61762
|
-
subtitle: message4,
|
|
61763
|
-
error: message4,
|
|
61764
|
-
scrollback: [
|
|
61765
|
-
`\r
|
|
61766
|
-
\x1B[31m${count10} could not be deleted:\x1B[0m\r
|
|
61767
|
-
`,
|
|
61768
|
-
...leftovers.map((l) => `\r
|
|
61769
|
-
${l.path}\r
|
|
61770
|
-
${l.reason}\r
|
|
61771
|
-
`),
|
|
61772
|
-
`\r
|
|
61773
|
-
Remove ${leftovers.length === 1 ? "it" : "them all"} with:\r
|
|
61774
|
-
\r
|
|
61775
|
-
${command}\r
|
|
61776
|
-
`,
|
|
61777
|
-
"\r\nThis notice is rebuilt on each daemon restart and disappears once every path is gone.\r\n"
|
|
61778
|
-
].join("")
|
|
61779
|
-
};
|
|
61780
|
-
}
|
|
61781
|
-
function removalCommand(leftovers) {
|
|
61782
|
-
const sudo = leftovers.some((l) => leftoverContents(l.path).foreignOwned);
|
|
61783
|
-
return `${sudo ? "sudo " : ""}rm -rf ${leftovers.map((l) => shellQuote2(l.path)).join(" ")}`;
|
|
61784
|
-
}
|
|
61785
|
-
function shellQuote2(path128) {
|
|
61786
|
-
return /^[\w@%+=:,./-]+$/.test(path128) ? path128 : `'${path128.replaceAll("'", `'\\''`)}'`;
|
|
61787
|
-
}
|
|
61788
|
-
|
|
61789
|
-
// src/commands/sessions/daemon/worktree/reportLeftovers.ts
|
|
61790
|
-
function reportLeftovers(sessions, spawnNotice, leftovers, notify2) {
|
|
61791
|
-
const existing = [...sessions.values()].find((s) => s.leftoverNotice);
|
|
61792
|
-
if (leftovers.length === 0) {
|
|
61793
|
-
if (!existing) return;
|
|
61794
|
-
sessions.delete(existing.id);
|
|
61795
|
-
daemonLog(
|
|
61796
|
-
`leftover notice ${existing.id} dropped: every listed leftover is gone`
|
|
61797
|
-
);
|
|
61798
|
-
notify2();
|
|
61799
|
-
return;
|
|
61800
|
-
}
|
|
61801
|
-
const content = noticeContent(leftovers);
|
|
61802
|
-
if (existing) {
|
|
61803
|
-
Object.assign(existing, content);
|
|
61804
|
-
daemonLog(
|
|
61805
|
-
`leftover notice ${existing.id} updated: ${leftovers.length} leftover(s)`
|
|
61806
|
-
);
|
|
61807
|
-
notify2();
|
|
61808
|
-
return;
|
|
61809
|
-
}
|
|
61810
|
-
try {
|
|
61811
|
-
const id = spawnNotice((sid) => ({
|
|
61812
|
-
...sessionBase(sid, "error"),
|
|
61813
|
-
...content,
|
|
61814
|
-
commandType: "assist",
|
|
61815
|
-
pty: null,
|
|
61816
|
-
cwd: homedir32(),
|
|
61817
|
-
leftoverNotice: true
|
|
61818
|
-
}));
|
|
61819
|
-
daemonLog(`leftover notice ${id} created: ${leftovers.length} leftover(s)`);
|
|
61820
|
-
} catch (error) {
|
|
61821
|
-
daemonLog(
|
|
61822
|
-
`leftover notice could not be created for ${leftovers.length} leftover(s): ${error instanceof Error ? error.message : String(error)}`
|
|
61823
|
-
);
|
|
61824
|
-
}
|
|
61825
|
-
}
|
|
61826
|
-
|
|
61827
|
-
// src/commands/sessions/daemon/worktree/reportReconciledLeftovers.ts
|
|
61828
|
-
async function reportReconciledLeftovers(sessions, spawnWith, orphanLeftovers, notify2) {
|
|
61829
|
-
if (!reportLeftoversEnabled()) return;
|
|
61830
|
-
const reappeared = await recheckReapedWorktrees(accountedTrees(sessions));
|
|
61831
|
-
reportLeftovers(
|
|
61832
|
-
sessions,
|
|
61833
|
-
spawnWith,
|
|
61834
|
-
[...orphanLeftovers, ...reappeared],
|
|
61835
|
-
notify2
|
|
61836
|
-
);
|
|
61873
|
+
function reviewFirst(contents) {
|
|
61874
|
+
return `it reappeared after its worktree was reaped and holds files${contents.foreignOwned ? " (some not owned by you)" : ""} that assist will not delete unreviewed; check them before removing it`;
|
|
61837
61875
|
}
|
|
61838
61876
|
|
|
61839
61877
|
// src/commands/sessions/daemon/worktree/reconcileWorktreesOnRestore.ts
|
|
@@ -61844,7 +61882,6 @@ function reconcileWorktreesOnRestore(sessions, spawnWith, notify2) {
|
|
|
61844
61882
|
async function recoverOrphanedWorktrees(sessions, spawnWith, notify2) {
|
|
61845
61883
|
const accounted = accountedTrees(sessions);
|
|
61846
61884
|
const vanished = /* @__PURE__ */ new Map();
|
|
61847
|
-
const leftovers = [];
|
|
61848
61885
|
for (const { path: path128, clone, harness } of readWorktreeRegistry()) {
|
|
61849
61886
|
if (underTempRoot(path128)) {
|
|
61850
61887
|
forgetWorktree(path128);
|
|
@@ -61862,17 +61899,12 @@ async function recoverOrphanedWorktrees(sessions, spawnWith, notify2) {
|
|
|
61862
61899
|
continue;
|
|
61863
61900
|
}
|
|
61864
61901
|
if (accounted.has(path128)) continue;
|
|
61865
|
-
|
|
61866
|
-
sessions,
|
|
61867
|
-
spawnWith,
|
|
61868
|
-
{ path: path128, clone, harness },
|
|
61869
|
-
notify2
|
|
61870
|
-
);
|
|
61871
|
-
if (leftover) leftovers.push(leftover);
|
|
61902
|
+
await recoverOrphan(sessions, spawnWith, { path: path128, clone, harness }, notify2);
|
|
61872
61903
|
}
|
|
61873
61904
|
for (const [clone, paths] of vanished)
|
|
61874
61905
|
await reclaimVanishedWorktrees(clone, paths);
|
|
61875
|
-
|
|
61906
|
+
if (reportLeftoversEnabled())
|
|
61907
|
+
await recheckReapedWorktrees(accountedTrees(sessions));
|
|
61876
61908
|
}
|
|
61877
61909
|
|
|
61878
61910
|
// src/commands/sessions/daemon/startHeldInTree.ts
|
|
@@ -63293,7 +63325,7 @@ var SessionManager = class {
|
|
|
63293
63325
|
releaseClient(client, this.clients, this.prPreview, this.verify);
|
|
63294
63326
|
this.onIdleChange?.(this.isIdle());
|
|
63295
63327
|
}
|
|
63296
|
-
isIdle = () =>
|
|
63328
|
+
isIdle = () => this.sessions.size === 0 && this.clients.size === 0;
|
|
63297
63329
|
shutdown() {
|
|
63298
63330
|
this.shuttingDown = true;
|
|
63299
63331
|
shutdownSessions(this.sessions);
|
|
@@ -63361,13 +63393,14 @@ var SessionManager = class {
|
|
|
63361
63393
|
notify: this.notify
|
|
63362
63394
|
});
|
|
63363
63395
|
}
|
|
63364
|
-
restart(id) {
|
|
63396
|
+
restart(id, fresh = false) {
|
|
63365
63397
|
return restartAndNotify(
|
|
63366
63398
|
this.sessions,
|
|
63367
63399
|
id,
|
|
63368
63400
|
this.clients,
|
|
63369
63401
|
this.onStatusChange,
|
|
63370
|
-
this.notify
|
|
63402
|
+
this.notify,
|
|
63403
|
+
fresh
|
|
63371
63404
|
);
|
|
63372
63405
|
}
|
|
63373
63406
|
dismissSession = (id, closeServerRuns = false) => {
|
|
@@ -64310,6 +64343,11 @@ var retryHandlers = {
|
|
|
64310
64343
|
existing: conflict
|
|
64311
64344
|
});
|
|
64312
64345
|
}),
|
|
64346
|
+
"start-over": routed((client, m, d) => {
|
|
64347
|
+
const result = m.restart(d.sessionId, true);
|
|
64348
|
+
if (!result.ok && result.reason)
|
|
64349
|
+
sendTo(client, { type: "error", message: result.reason });
|
|
64350
|
+
}),
|
|
64313
64351
|
restart: routed((client, m, d) => {
|
|
64314
64352
|
const result = m.restart(d.sessionId);
|
|
64315
64353
|
if (!result.ok && result.reason)
|
|
@@ -64963,6 +65001,10 @@ async function runDaemon() {
|
|
|
64963
65001
|
});
|
|
64964
65002
|
const manager = new SessionManager(checkAutoExit);
|
|
64965
65003
|
setDaemonLogSink(manager.clients.emitLog);
|
|
65004
|
+
setSdkUsageSink({
|
|
65005
|
+
limits: (rateLimits) => manager.clients.updateLimits(rateLimits),
|
|
65006
|
+
usage: (claudeSessionId, transcriptPath, usedPct) => manager.recordUsage(claudeSessionId, transcriptPath, usedPct)
|
|
65007
|
+
});
|
|
64966
65008
|
startDaemonLogTrimmer();
|
|
64967
65009
|
pollRepoConfigCache();
|
|
64968
65010
|
void failInterruptedJobRuns();
|
|
@@ -65073,19 +65115,55 @@ function printDiagnosis(diagnosis) {
|
|
|
65073
65115
|
}
|
|
65074
65116
|
}
|
|
65075
65117
|
|
|
65118
|
+
// src/commands/sessions/nodes/collectLeftovers.ts
|
|
65119
|
+
async function collectLeftovers(specs, fetchPeer = (url) => fetchPeerJson(url, "/api/leftovers")) {
|
|
65120
|
+
const peers = await Promise.all(
|
|
65121
|
+
specs.map((spec) => fetchPeer(spec.url).catch(() => void 0))
|
|
65122
|
+
);
|
|
65123
|
+
return [leftoverReport(), ...peers].filter(
|
|
65124
|
+
(r) => r !== void 0 && r.leftovers.length > 0
|
|
65125
|
+
);
|
|
65126
|
+
}
|
|
65127
|
+
|
|
65128
|
+
// src/commands/sessions/nodes/printLeftovers.ts
|
|
65129
|
+
import chalk300 from "chalk";
|
|
65130
|
+
function printLeftovers(reports) {
|
|
65131
|
+
for (const report of reports) {
|
|
65132
|
+
console.log(
|
|
65133
|
+
chalk300.yellow(
|
|
65134
|
+
`${report.nodeName}: ${report.leftovers.length} leftover workspace(s) assist could not delete`
|
|
65135
|
+
)
|
|
65136
|
+
);
|
|
65137
|
+
for (const { path: path128, reason: reason4 } of report.leftovers)
|
|
65138
|
+
console.log(` ${path128}
|
|
65139
|
+
${chalk300.dim(reason4)}`);
|
|
65140
|
+
console.log(
|
|
65141
|
+
` Remove them on ${report.nodeName} with:
|
|
65142
|
+
${report.command}`
|
|
65143
|
+
);
|
|
65144
|
+
}
|
|
65145
|
+
}
|
|
65146
|
+
|
|
65076
65147
|
// src/commands/sessions/nodes/doctorNodes.ts
|
|
65077
65148
|
async function doctorNodes(name2, options2) {
|
|
65078
65149
|
const specs = loadLinkSpecs().filter((spec) => !name2 || spec.name === name2);
|
|
65079
65150
|
if (name2 && specs.length === 0)
|
|
65080
65151
|
throw new Error(`No link named ${name2}; see assist sessions nodes`);
|
|
65081
65152
|
const probes = buildDoctorProbes(await queryNodes());
|
|
65082
|
-
const report = {
|
|
65153
|
+
const report = {
|
|
65154
|
+
local: resolveNodeName(),
|
|
65155
|
+
links: [],
|
|
65156
|
+
leftovers: await collectLeftovers(specs)
|
|
65157
|
+
};
|
|
65083
65158
|
for (const spec of specs) report.links.push(await diagnoseLink(spec, probes));
|
|
65084
65159
|
if (specs.length === 0)
|
|
65085
65160
|
report.suggestion = await findUnlinkedWindowsNode(probes.health);
|
|
65086
65161
|
if (report.links.some((l) => !l.ok)) process.exitCode = 1;
|
|
65087
65162
|
if (options2.json) console.log(JSON.stringify(report, null, 2));
|
|
65088
|
-
else
|
|
65163
|
+
else {
|
|
65164
|
+
printReport(report);
|
|
65165
|
+
printLeftovers(report.leftovers);
|
|
65166
|
+
}
|
|
65089
65167
|
}
|
|
65090
65168
|
|
|
65091
65169
|
// src/commands/sessions/nodes/nodeLogs.ts
|
|
@@ -65141,23 +65219,23 @@ function registerDiagnoseCommands(nodes, calledBy5) {
|
|
|
65141
65219
|
}
|
|
65142
65220
|
|
|
65143
65221
|
// src/commands/sessions/nodes/linkNode.ts
|
|
65144
|
-
import
|
|
65222
|
+
import chalk302 from "chalk";
|
|
65145
65223
|
|
|
65146
65224
|
// src/commands/sessions/nodes/notifyDaemonLinks.ts
|
|
65147
|
-
import
|
|
65225
|
+
import chalk301 from "chalk";
|
|
65148
65226
|
async function notifyDaemonLinks() {
|
|
65149
65227
|
const result = await reloadDaemonLinks();
|
|
65150
65228
|
if (result.kind === "not-running")
|
|
65151
65229
|
console.log(
|
|
65152
|
-
|
|
65230
|
+
chalk301.yellow(
|
|
65153
65231
|
"The sessions daemon is not running; it loads the links when it starts."
|
|
65154
65232
|
)
|
|
65155
65233
|
);
|
|
65156
65234
|
else if (result.kind === "reloaded")
|
|
65157
|
-
console.log(
|
|
65235
|
+
console.log(chalk301.dim("The sessions daemon reloaded its links."));
|
|
65158
65236
|
else
|
|
65159
65237
|
console.log(
|
|
65160
|
-
|
|
65238
|
+
chalk301.yellow(
|
|
65161
65239
|
`Could not notify the sessions daemon (${result.message}); run \`assist daemon restart\` to apply the change.`
|
|
65162
65240
|
)
|
|
65163
65241
|
);
|
|
@@ -65206,7 +65284,7 @@ async function linkNode(name2, url, options2) {
|
|
|
65206
65284
|
throw new Error(`${name2} is this node; link to a different node`);
|
|
65207
65285
|
const link3 = await buildLink(name2, url, options2);
|
|
65208
65286
|
await writeLinks([...others, link3]);
|
|
65209
|
-
console.log(
|
|
65287
|
+
console.log(chalk302.green(`Linked ${name2} (${link3.url})`));
|
|
65210
65288
|
await notifyDaemonLinks();
|
|
65211
65289
|
}
|
|
65212
65290
|
|
|
@@ -65389,16 +65467,16 @@ function registerPeerActionCommands(nodes, calledBy5) {
|
|
|
65389
65467
|
}
|
|
65390
65468
|
|
|
65391
65469
|
// src/commands/sessions/nodes/unlinkNode.ts
|
|
65392
|
-
import
|
|
65470
|
+
import chalk303 from "chalk";
|
|
65393
65471
|
async function unlinkNode(name2) {
|
|
65394
65472
|
const links2 = await readLinks();
|
|
65395
65473
|
const remaining = links2.filter((link3) => link3.name !== name2);
|
|
65396
65474
|
if (remaining.length === links2.length) {
|
|
65397
|
-
console.log(
|
|
65475
|
+
console.log(chalk303.yellow(`No link named ${name2}`));
|
|
65398
65476
|
return;
|
|
65399
65477
|
}
|
|
65400
65478
|
await writeLinks(remaining);
|
|
65401
|
-
console.log(
|
|
65479
|
+
console.log(chalk303.green(`Unlinked ${name2}`));
|
|
65402
65480
|
await notifyDaemonLinks();
|
|
65403
65481
|
}
|
|
65404
65482
|
|
|
@@ -65648,10 +65726,10 @@ function createProgram() {
|
|
|
65648
65726
|
}
|
|
65649
65727
|
|
|
65650
65728
|
// src/reportCliError.ts
|
|
65651
|
-
import
|
|
65729
|
+
import chalk304 from "chalk";
|
|
65652
65730
|
function reportCliError(error) {
|
|
65653
65731
|
if (error instanceof InvalidItemIdError || error instanceof AmbiguousRepoConfigError || error instanceof UnknownRepoConfigError || error instanceof MissingRunCwdError || error instanceof MiroExtractError || error instanceof MissingDatabaseUrlError || error instanceof DatabaseConnectionError) {
|
|
65654
|
-
console.error(
|
|
65732
|
+
console.error(chalk304.red(error.message));
|
|
65655
65733
|
} else {
|
|
65656
65734
|
console.error(error);
|
|
65657
65735
|
}
|