@staff0rd/assist 0.303.0 → 0.305.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/index.js +255 -197
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -250,6 +250,7 @@ The first backlog command in a repository that still has a local `.assist/backlo
|
|
|
250
250
|
- `assist sessions` - Start the web dashboard (same as `sessions web`)
|
|
251
251
|
- `assist sessions web [-p, --port <number>] [--no-open]` - Start the web dashboard with Sessions, Backlog and News tabs, xterm.js terminals with clickable http(s) links (default port 3100); `--no-open` skips opening a browser on startup; press Ctrl+R in the foreground terminal for an in-terminal restart menu (Restart daemon, Restart webserver, Restart both); Restart webserver re-execs the foreground process (passing `--no-open` so no browser pops on restart) so the connected browser auto-reconnects
|
|
252
252
|
- `assist sessions summarise [-f, --force] [-n, --limit <count>]` - Generate one-line summaries for unsummarised Claude sessions (force re-generates all; limit caps how many to process)
|
|
253
|
+
- `assist sessions set-status <status>` - Report the current session's status (`running`/`waiting`) to the sessions daemon; reads the session id from `$ASSIST_SESSION_ID` and is invoked by the Claude Code hooks the daemon wires into each session (exits silently when run outside a daemon session)
|
|
253
254
|
- `assist daemon run` - Run the sessions daemon in the foreground (normally auto-spawned detached by `assist sessions`)
|
|
254
255
|
- `assist daemon status` - Show sessions daemon status, live sessions, and any stray daemon processes or stolen socket
|
|
255
256
|
- `assist daemon stop` - Stop the sessions daemon; running claude sessions resume on next start
|
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.305.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -1138,9 +1138,9 @@ function getSetupHandlers(hasVite, hasTypescript, hasOpenColor) {
|
|
|
1138
1138
|
}
|
|
1139
1139
|
|
|
1140
1140
|
// src/commands/verify/init/index.ts
|
|
1141
|
-
async function runSelectedSetups(selected, packageJsonPath, writer,
|
|
1141
|
+
async function runSelectedSetups(selected, packageJsonPath, writer, handlers) {
|
|
1142
1142
|
for (const choice of selected) {
|
|
1143
|
-
await
|
|
1143
|
+
await handlers[choice]?.(packageJsonPath, writer);
|
|
1144
1144
|
}
|
|
1145
1145
|
console.log(chalk16.green(`
|
|
1146
1146
|
Added ${selected.length} verify script(s):`));
|
|
@@ -1171,12 +1171,12 @@ async function init2(options2 = {}) {
|
|
|
1171
1171
|
const selected = await promptForScripts(getAvailableOptions(setup2));
|
|
1172
1172
|
if (!selected) return;
|
|
1173
1173
|
const writer = options2.packageJson ? (name, cmd, opts) => setupVerifyScript(packageJsonPath, name, cmd, opts) : setupVerifyRunEntry;
|
|
1174
|
-
const
|
|
1174
|
+
const handlers = getSetupHandlers(
|
|
1175
1175
|
setup2.hasVite,
|
|
1176
1176
|
setup2.hasTypescript,
|
|
1177
1177
|
setup2.hasOpenColor
|
|
1178
1178
|
);
|
|
1179
|
-
await runSelectedSetups(selected, packageJsonPath, writer,
|
|
1179
|
+
await runSelectedSetups(selected, packageJsonPath, writer, handlers);
|
|
1180
1180
|
}
|
|
1181
1181
|
|
|
1182
1182
|
// src/commands/vscode/init/index.ts
|
|
@@ -1339,14 +1339,14 @@ function applySelections(selected, setup2) {
|
|
|
1339
1339
|
removeVscodeFromGitignore();
|
|
1340
1340
|
ensureVscodeFolder();
|
|
1341
1341
|
const launchType = setup2.hasVite ? "vite" : "tsup";
|
|
1342
|
-
const
|
|
1342
|
+
const handlers = {
|
|
1343
1343
|
launch: () => createLaunchJson(launchType),
|
|
1344
1344
|
settings: () => {
|
|
1345
1345
|
createSettingsJson();
|
|
1346
1346
|
createExtensionsJson();
|
|
1347
1347
|
}
|
|
1348
1348
|
};
|
|
1349
|
-
for (const choice of selected)
|
|
1349
|
+
for (const choice of selected) handlers[choice]?.();
|
|
1350
1350
|
}
|
|
1351
1351
|
async function promptForOptions(options2) {
|
|
1352
1352
|
console.log(chalk20.bold("Available VS Code configurations to add:\n"));
|
|
@@ -2879,13 +2879,57 @@ import chalk37 from "chalk";
|
|
|
2879
2879
|
|
|
2880
2880
|
// src/shared/spawnClaude.ts
|
|
2881
2881
|
import { spawn as spawn3 } from "child_process";
|
|
2882
|
+
|
|
2883
|
+
// src/commands/sessions/daemon/ensureHooksSettings.ts
|
|
2884
|
+
import { mkdirSync as mkdirSync5, writeFileSync as writeFileSync14 } from "fs";
|
|
2885
|
+
import { dirname as dirname12 } from "path";
|
|
2886
|
+
|
|
2887
|
+
// src/commands/sessions/daemon/daemonPaths.ts
|
|
2888
|
+
import { homedir as homedir4 } from "os";
|
|
2889
|
+
import { join as join11 } from "path";
|
|
2890
|
+
var DAEMON_DIR = join11(homedir4(), ".assist", "daemon");
|
|
2891
|
+
var daemonPaths = {
|
|
2892
|
+
dir: DAEMON_DIR,
|
|
2893
|
+
socket: process.platform === "win32" ? String.raw`\\.\pipe\assist-sessions-daemon` : join11(DAEMON_DIR, "daemon.sock"),
|
|
2894
|
+
log: join11(DAEMON_DIR, "daemon.log"),
|
|
2895
|
+
pid: join11(DAEMON_DIR, "daemon.pid"),
|
|
2896
|
+
spawnLock: join11(DAEMON_DIR, "spawn.lock"),
|
|
2897
|
+
hooksSettings: join11(DAEMON_DIR, "hooks-settings.json")
|
|
2898
|
+
};
|
|
2899
|
+
|
|
2900
|
+
// src/commands/sessions/daemon/ensureHooksSettings.ts
|
|
2901
|
+
var RUNNING = "assist sessions set-status running";
|
|
2902
|
+
var WAITING = "assist sessions set-status waiting";
|
|
2903
|
+
function on(command) {
|
|
2904
|
+
return [{ hooks: [{ type: "command", command }] }];
|
|
2905
|
+
}
|
|
2906
|
+
var hooksSettings = {
|
|
2907
|
+
hooks: {
|
|
2908
|
+
UserPromptSubmit: on(RUNNING),
|
|
2909
|
+
PreToolUse: on(RUNNING),
|
|
2910
|
+
Stop: on(WAITING),
|
|
2911
|
+
Notification: on(WAITING)
|
|
2912
|
+
}
|
|
2913
|
+
};
|
|
2914
|
+
function ensureHooksSettings() {
|
|
2915
|
+
const path58 = daemonPaths.hooksSettings;
|
|
2916
|
+
mkdirSync5(dirname12(path58), { recursive: true });
|
|
2917
|
+
writeFileSync14(path58, JSON.stringify(hooksSettings, null, 2));
|
|
2918
|
+
return path58;
|
|
2919
|
+
}
|
|
2920
|
+
|
|
2921
|
+
// src/shared/spawnClaude.ts
|
|
2882
2922
|
function withoutResumeSession(options2) {
|
|
2883
2923
|
if (!options2?.resumeSessionId) return options2;
|
|
2884
2924
|
const { resumeSessionId: _resumeSessionId, ...rest } = options2;
|
|
2885
2925
|
return rest;
|
|
2886
2926
|
}
|
|
2887
2927
|
function spawnClaude(prompt, options2 = {}) {
|
|
2888
|
-
const args =
|
|
2928
|
+
const args = [
|
|
2929
|
+
"--settings",
|
|
2930
|
+
ensureHooksSettings(),
|
|
2931
|
+
...buildArgs(prompt, options2)
|
|
2932
|
+
];
|
|
2889
2933
|
const permissionMode = options2.permissionMode ?? (options2.allowEdits ? "auto" : void 0);
|
|
2890
2934
|
if (permissionMode) {
|
|
2891
2935
|
args.push("--permission-mode", permissionMode);
|
|
@@ -2920,17 +2964,17 @@ import chalk32 from "chalk";
|
|
|
2920
2964
|
|
|
2921
2965
|
// src/commands/backlog/migrateLocalBacklog.ts
|
|
2922
2966
|
import { existsSync as existsSync16 } from "fs";
|
|
2923
|
-
import { join as
|
|
2967
|
+
import { join as join13 } from "path";
|
|
2924
2968
|
import chalk30 from "chalk";
|
|
2925
2969
|
|
|
2926
2970
|
// src/commands/backlog/backupLocalBacklogFiles.ts
|
|
2927
2971
|
import { existsSync as existsSync15, renameSync } from "fs";
|
|
2928
|
-
import { join as
|
|
2972
|
+
import { join as join12 } from "path";
|
|
2929
2973
|
var LOCAL_FILES = ["backlog.jsonl", "backlog.db"];
|
|
2930
2974
|
function backupLocalBacklogFiles(dir) {
|
|
2931
2975
|
const moved = [];
|
|
2932
2976
|
for (const name of LOCAL_FILES) {
|
|
2933
|
-
const path58 =
|
|
2977
|
+
const path58 = join12(dir, ".assist", name);
|
|
2934
2978
|
if (existsSync15(path58)) {
|
|
2935
2979
|
renameSync(path58, `${path58}.bak`);
|
|
2936
2980
|
moved.push(`${name} \u2192 ${name}.bak`);
|
|
@@ -3357,7 +3401,7 @@ function parseBacklogJsonl(path58) {
|
|
|
3357
3401
|
|
|
3358
3402
|
// src/commands/backlog/migrateLocalBacklog.ts
|
|
3359
3403
|
function jsonlPath(dir) {
|
|
3360
|
-
return
|
|
3404
|
+
return join13(dir, ".assist", "backlog.jsonl");
|
|
3361
3405
|
}
|
|
3362
3406
|
async function verifyImport(orm, origin, items2, imported) {
|
|
3363
3407
|
const reloaded = await loadAllItems(orm, origin);
|
|
@@ -3611,19 +3655,19 @@ async function deleteItem(orm, id2) {
|
|
|
3611
3655
|
|
|
3612
3656
|
// src/commands/backlog/findBacklogUp.ts
|
|
3613
3657
|
import { existsSync as existsSync17 } from "fs";
|
|
3614
|
-
import { dirname as
|
|
3658
|
+
import { dirname as dirname13, join as join14 } from "path";
|
|
3615
3659
|
var BACKLOG_MARKERS = [
|
|
3616
|
-
|
|
3617
|
-
|
|
3660
|
+
join14(".assist", "backlog.db"),
|
|
3661
|
+
join14(".assist", "backlog.jsonl"),
|
|
3618
3662
|
"assist.backlog.yml"
|
|
3619
3663
|
];
|
|
3620
3664
|
function findBacklogUp(startDir) {
|
|
3621
3665
|
let current = startDir;
|
|
3622
|
-
while (current !==
|
|
3623
|
-
if (BACKLOG_MARKERS.some((marker) => existsSync17(
|
|
3666
|
+
while (current !== dirname13(current)) {
|
|
3667
|
+
if (BACKLOG_MARKERS.some((marker) => existsSync17(join14(current, marker)))) {
|
|
3624
3668
|
return current;
|
|
3625
3669
|
}
|
|
3626
|
-
current =
|
|
3670
|
+
current = dirname13(current);
|
|
3627
3671
|
}
|
|
3628
3672
|
return null;
|
|
3629
3673
|
}
|
|
@@ -3841,18 +3885,18 @@ async function prepareRun(id2) {
|
|
|
3841
3885
|
}
|
|
3842
3886
|
|
|
3843
3887
|
// src/commands/backlog/consumePause.ts
|
|
3844
|
-
import { existsSync as existsSync18, mkdirSync as
|
|
3845
|
-
import { homedir as
|
|
3846
|
-
import { join as
|
|
3888
|
+
import { existsSync as existsSync18, mkdirSync as mkdirSync6, unlinkSync as unlinkSync3, writeFileSync as writeFileSync15 } from "fs";
|
|
3889
|
+
import { homedir as homedir5 } from "os";
|
|
3890
|
+
import { join as join15 } from "path";
|
|
3847
3891
|
function getControlsDir() {
|
|
3848
|
-
return
|
|
3892
|
+
return join15(homedir5(), ".assist", "controls");
|
|
3849
3893
|
}
|
|
3850
3894
|
function getPausePath(itemId) {
|
|
3851
|
-
return
|
|
3895
|
+
return join15(getControlsDir(), `pause-${itemId}.json`);
|
|
3852
3896
|
}
|
|
3853
3897
|
function requestPause(itemId) {
|
|
3854
|
-
|
|
3855
|
-
|
|
3898
|
+
mkdirSync6(getControlsDir(), { recursive: true });
|
|
3899
|
+
writeFileSync15(
|
|
3856
3900
|
getPausePath(itemId),
|
|
3857
3901
|
JSON.stringify({ timestamp: (/* @__PURE__ */ new Date()).toISOString() })
|
|
3858
3902
|
);
|
|
@@ -3894,9 +3938,9 @@ Failed to launch Claude for ${context}: ${message}`)
|
|
|
3894
3938
|
}
|
|
3895
3939
|
|
|
3896
3940
|
// src/shared/emitActivity.ts
|
|
3897
|
-
import { mkdirSync as
|
|
3898
|
-
import { homedir as
|
|
3899
|
-
import { dirname as
|
|
3941
|
+
import { mkdirSync as mkdirSync7, readFileSync as readFileSync13, rmSync as rmSync2, writeFileSync as writeFileSync16 } from "fs";
|
|
3942
|
+
import { homedir as homedir6 } from "os";
|
|
3943
|
+
import { dirname as dirname14, join as join16 } from "path";
|
|
3900
3944
|
import { z as z4 } from "zod";
|
|
3901
3945
|
var activitySchema = z4.object({
|
|
3902
3946
|
kind: z4.enum(["command", "backlog"]),
|
|
@@ -3909,14 +3953,14 @@ var activitySchema = z4.object({
|
|
|
3909
3953
|
startedAt: z4.number()
|
|
3910
3954
|
});
|
|
3911
3955
|
function activityPath(sessionId) {
|
|
3912
|
-
return
|
|
3956
|
+
return join16(homedir6(), ".assist", "activity", `activity-${sessionId}.json`);
|
|
3913
3957
|
}
|
|
3914
3958
|
function emitActivity(activity2) {
|
|
3915
3959
|
const sessionId = process.env.ASSIST_ACTIVITY_ID;
|
|
3916
3960
|
if (!sessionId) return;
|
|
3917
3961
|
const path58 = activityPath(sessionId);
|
|
3918
|
-
|
|
3919
|
-
|
|
3962
|
+
mkdirSync7(dirname14(path58), { recursive: true });
|
|
3963
|
+
writeFileSync16(path58, JSON.stringify({ ...activity2, startedAt: Date.now() }));
|
|
3920
3964
|
}
|
|
3921
3965
|
function readActivity(path58) {
|
|
3922
3966
|
try {
|
|
@@ -3925,6 +3969,15 @@ function readActivity(path58) {
|
|
|
3925
3969
|
return void 0;
|
|
3926
3970
|
}
|
|
3927
3971
|
}
|
|
3972
|
+
function reconcileActivity(sessionId, activity2) {
|
|
3973
|
+
if (!activity2) {
|
|
3974
|
+
removeActivity(sessionId);
|
|
3975
|
+
return;
|
|
3976
|
+
}
|
|
3977
|
+
const path58 = activityPath(sessionId);
|
|
3978
|
+
mkdirSync7(dirname14(path58), { recursive: true });
|
|
3979
|
+
writeFileSync16(path58, JSON.stringify(activity2));
|
|
3980
|
+
}
|
|
3928
3981
|
function removeActivity(sessionId) {
|
|
3929
3982
|
try {
|
|
3930
3983
|
rmSync2(activityPath(sessionId));
|
|
@@ -4065,17 +4118,17 @@ async function handleIncompletePhase() {
|
|
|
4065
4118
|
import { existsSync as existsSync19, readFileSync as readFileSync14 } from "fs";
|
|
4066
4119
|
|
|
4067
4120
|
// src/commands/backlog/writeSignal.ts
|
|
4068
|
-
import { writeFileSync as
|
|
4069
|
-
import { join as
|
|
4121
|
+
import { writeFileSync as writeFileSync17 } from "fs";
|
|
4122
|
+
import { join as join17 } from "path";
|
|
4070
4123
|
function getSignalPath() {
|
|
4071
4124
|
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
4072
4125
|
const filename = sessionId ? `.assist-signal-${sessionId}.json` : ".assist-signal.json";
|
|
4073
|
-
return
|
|
4126
|
+
return join17(getBacklogDir(), filename);
|
|
4074
4127
|
}
|
|
4075
4128
|
function writeSignal(event, data) {
|
|
4076
4129
|
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
4077
4130
|
const signal = { event, ...sessionId && { sessionId }, ...data };
|
|
4078
|
-
|
|
4131
|
+
writeFileSync17(getSignalPath(), JSON.stringify(signal));
|
|
4079
4132
|
}
|
|
4080
4133
|
|
|
4081
4134
|
// src/commands/backlog/readSignal.ts
|
|
@@ -4543,10 +4596,10 @@ import { WebSocketServer } from "ws";
|
|
|
4543
4596
|
|
|
4544
4597
|
// src/shared/getInstallDir.ts
|
|
4545
4598
|
import { execSync as execSync18 } from "child_process";
|
|
4546
|
-
import { dirname as
|
|
4599
|
+
import { dirname as dirname15, resolve as resolve6 } from "path";
|
|
4547
4600
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
4548
4601
|
var __filename2 = fileURLToPath2(import.meta.url);
|
|
4549
|
-
var __dirname3 =
|
|
4602
|
+
var __dirname3 = dirname15(__filename2);
|
|
4550
4603
|
function getInstallDir() {
|
|
4551
4604
|
return resolve6(__dirname3, "..");
|
|
4552
4605
|
}
|
|
@@ -4689,7 +4742,7 @@ function startWebServer(label2, port, handler, initialPath, open = true) {
|
|
|
4689
4742
|
import { spawn as spawn4 } from "child_process";
|
|
4690
4743
|
import {
|
|
4691
4744
|
closeSync,
|
|
4692
|
-
mkdirSync as
|
|
4745
|
+
mkdirSync as mkdirSync8,
|
|
4693
4746
|
openSync,
|
|
4694
4747
|
statSync,
|
|
4695
4748
|
unlinkSync as unlinkSync5,
|
|
@@ -4698,20 +4751,6 @@ import {
|
|
|
4698
4751
|
|
|
4699
4752
|
// src/commands/sessions/daemon/connectToDaemon.ts
|
|
4700
4753
|
import * as net from "net";
|
|
4701
|
-
|
|
4702
|
-
// src/commands/sessions/daemon/daemonPaths.ts
|
|
4703
|
-
import { homedir as homedir6 } from "os";
|
|
4704
|
-
import { join as join17 } from "path";
|
|
4705
|
-
var DAEMON_DIR = join17(homedir6(), ".assist", "daemon");
|
|
4706
|
-
var daemonPaths = {
|
|
4707
|
-
dir: DAEMON_DIR,
|
|
4708
|
-
socket: process.platform === "win32" ? String.raw`\\.\pipe\assist-sessions-daemon` : join17(DAEMON_DIR, "daemon.sock"),
|
|
4709
|
-
log: join17(DAEMON_DIR, "daemon.log"),
|
|
4710
|
-
pid: join17(DAEMON_DIR, "daemon.pid"),
|
|
4711
|
-
spawnLock: join17(DAEMON_DIR, "spawn.lock")
|
|
4712
|
-
};
|
|
4713
|
-
|
|
4714
|
-
// src/commands/sessions/daemon/connectToDaemon.ts
|
|
4715
4754
|
function connectToDaemon() {
|
|
4716
4755
|
return new Promise((resolve16, reject) => {
|
|
4717
4756
|
const socket = net.connect(daemonPaths.socket);
|
|
@@ -4734,7 +4773,7 @@ var RETRY_DELAY_MS = 200;
|
|
|
4734
4773
|
var STALE_LOCK_MS = SPAWN_TIMEOUT_MS + 5e3;
|
|
4735
4774
|
async function ensureDaemonRunning(reason = "unspecified") {
|
|
4736
4775
|
if (await isDaemonRunning()) return;
|
|
4737
|
-
|
|
4776
|
+
mkdirSync8(daemonPaths.dir, { recursive: true });
|
|
4738
4777
|
const holdsLock = acquireSpawnLock();
|
|
4739
4778
|
if (holdsLock) spawnDaemon(reason);
|
|
4740
4779
|
try {
|
|
@@ -4806,10 +4845,10 @@ import { createRequire as createRequire2 } from "module";
|
|
|
4806
4845
|
// src/shared/createBundleHandler.ts
|
|
4807
4846
|
import { createHash } from "crypto";
|
|
4808
4847
|
import { readFileSync as readFileSync15 } from "fs";
|
|
4809
|
-
import { dirname as
|
|
4848
|
+
import { dirname as dirname16, join as join18 } from "path";
|
|
4810
4849
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
4811
4850
|
function createBundleHandler(importMetaUrl, bundlePath) {
|
|
4812
|
-
const dir =
|
|
4851
|
+
const dir = dirname16(fileURLToPath3(importMetaUrl));
|
|
4813
4852
|
let cache;
|
|
4814
4853
|
return (req, res) => {
|
|
4815
4854
|
if (!cache) {
|
|
@@ -6353,7 +6392,7 @@ import chalk56 from "chalk";
|
|
|
6353
6392
|
|
|
6354
6393
|
// src/commands/backlog/add/shared.ts
|
|
6355
6394
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
6356
|
-
import { mkdtempSync, readFileSync as readFileSync17, unlinkSync as unlinkSync6, writeFileSync as
|
|
6395
|
+
import { mkdtempSync, readFileSync as readFileSync17, unlinkSync as unlinkSync6, writeFileSync as writeFileSync18 } from "fs";
|
|
6357
6396
|
import { tmpdir } from "os";
|
|
6358
6397
|
import { join as join19 } from "path";
|
|
6359
6398
|
import enquirer6 from "enquirer";
|
|
@@ -6397,7 +6436,7 @@ function openEditor() {
|
|
|
6397
6436
|
const editor = process.env.EDITOR || process.env.VISUAL || "vi";
|
|
6398
6437
|
const dir = mkdtempSync(join19(tmpdir(), "assist-"));
|
|
6399
6438
|
const filePath = join19(dir, "description.md");
|
|
6400
|
-
|
|
6439
|
+
writeFileSync18(filePath, "");
|
|
6401
6440
|
const result = spawnSync2(editor, [filePath], { stdio: "inherit" });
|
|
6402
6441
|
if (result.status !== 0) {
|
|
6403
6442
|
unlinkSync6(filePath);
|
|
@@ -7742,7 +7781,7 @@ function findBuiltinDenyRaw(rawCommand) {
|
|
|
7742
7781
|
}
|
|
7743
7782
|
|
|
7744
7783
|
// src/commands/cliHook/logDeniedToolCall.ts
|
|
7745
|
-
import { mkdirSync as
|
|
7784
|
+
import { mkdirSync as mkdirSync9 } from "fs";
|
|
7746
7785
|
import { homedir as homedir7 } from "os";
|
|
7747
7786
|
import { join as join20 } from "path";
|
|
7748
7787
|
import Database from "better-sqlite3";
|
|
@@ -7766,7 +7805,7 @@ function initSchema(db) {
|
|
|
7766
7805
|
function openPromptsDb(dir) {
|
|
7767
7806
|
if (_db) return _db;
|
|
7768
7807
|
const dbDir = dir ?? getDbDir();
|
|
7769
|
-
|
|
7808
|
+
mkdirSync9(dbDir, { recursive: true });
|
|
7770
7809
|
const db = new Database(join20(dbDir, "assist.db"));
|
|
7771
7810
|
db.pragma("journal_mode = WAL");
|
|
7772
7811
|
initSchema(db);
|
|
@@ -7869,11 +7908,11 @@ function extractGraphqlQuery(args) {
|
|
|
7869
7908
|
}
|
|
7870
7909
|
|
|
7871
7910
|
// src/shared/loadCliReads.ts
|
|
7872
|
-
import { existsSync as existsSync22, readFileSync as readFileSync18, writeFileSync as
|
|
7873
|
-
import { dirname as
|
|
7911
|
+
import { existsSync as existsSync22, readFileSync as readFileSync18, writeFileSync as writeFileSync19 } from "fs";
|
|
7912
|
+
import { dirname as dirname17, resolve as resolve7 } from "path";
|
|
7874
7913
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
7875
7914
|
var __filename3 = fileURLToPath4(import.meta.url);
|
|
7876
|
-
var __dirname4 =
|
|
7915
|
+
var __dirname4 = dirname17(__filename3);
|
|
7877
7916
|
function packageRoot() {
|
|
7878
7917
|
return __dirname4;
|
|
7879
7918
|
}
|
|
@@ -7899,7 +7938,7 @@ function loadCliReads() {
|
|
|
7899
7938
|
return getCliReadsLines();
|
|
7900
7939
|
}
|
|
7901
7940
|
function saveCliReads(commands) {
|
|
7902
|
-
|
|
7941
|
+
writeFileSync19(
|
|
7903
7942
|
resolve7(packageRoot(), "allowed.cli-reads"),
|
|
7904
7943
|
`${commands.join("\n")}
|
|
7905
7944
|
`
|
|
@@ -8205,7 +8244,7 @@ ${reasons.join("\n")}`);
|
|
|
8205
8244
|
}
|
|
8206
8245
|
|
|
8207
8246
|
// src/commands/permitCliReads/index.ts
|
|
8208
|
-
import { existsSync as existsSync24, mkdirSync as
|
|
8247
|
+
import { existsSync as existsSync24, mkdirSync as mkdirSync10, readFileSync as readFileSync20, writeFileSync as writeFileSync20 } from "fs";
|
|
8209
8248
|
import { homedir as homedir9 } from "os";
|
|
8210
8249
|
import { join as join22 } from "path";
|
|
8211
8250
|
|
|
@@ -8505,8 +8544,8 @@ function readCache(cli) {
|
|
|
8505
8544
|
}
|
|
8506
8545
|
function writeCache(cli, output) {
|
|
8507
8546
|
const dir = join22(homedir9(), ".assist");
|
|
8508
|
-
|
|
8509
|
-
|
|
8547
|
+
mkdirSync10(dir, { recursive: true });
|
|
8548
|
+
writeFileSync20(logPath(cli), output);
|
|
8510
8549
|
}
|
|
8511
8550
|
async function permitCliReads(cli, options2 = { noCache: false }) {
|
|
8512
8551
|
if (!cli) {
|
|
@@ -9313,7 +9352,7 @@ function registerConfig(program2) {
|
|
|
9313
9352
|
}
|
|
9314
9353
|
|
|
9315
9354
|
// src/commands/deploy/redirect.ts
|
|
9316
|
-
import { existsSync as existsSync25, readFileSync as readFileSync21, writeFileSync as
|
|
9355
|
+
import { existsSync as existsSync25, readFileSync as readFileSync21, writeFileSync as writeFileSync21 } from "fs";
|
|
9317
9356
|
import chalk96 from "chalk";
|
|
9318
9357
|
var TRAILING_SLASH_SCRIPT = ` <script>
|
|
9319
9358
|
if (!window.location.pathname.endsWith('/')) {
|
|
@@ -9338,7 +9377,7 @@ function redirect() {
|
|
|
9338
9377
|
}
|
|
9339
9378
|
const newContent = `${content.slice(0, headCloseIndex) + TRAILING_SLASH_SCRIPT}
|
|
9340
9379
|
${content.slice(headCloseIndex)}`;
|
|
9341
|
-
|
|
9380
|
+
writeFileSync21(indexPath, newContent);
|
|
9342
9381
|
console.log(chalk96.green("Added trailing slash redirect to index.html"));
|
|
9343
9382
|
}
|
|
9344
9383
|
|
|
@@ -9808,7 +9847,7 @@ function repos(options2) {
|
|
|
9808
9847
|
}
|
|
9809
9848
|
|
|
9810
9849
|
// src/commands/devlog/skip.ts
|
|
9811
|
-
import { writeFileSync as
|
|
9850
|
+
import { writeFileSync as writeFileSync22 } from "fs";
|
|
9812
9851
|
import { join as join26 } from "path";
|
|
9813
9852
|
import chalk102 from "chalk";
|
|
9814
9853
|
import { stringify as stringifyYaml3 } from "yaml";
|
|
@@ -9837,7 +9876,7 @@ function skip(date) {
|
|
|
9837
9876
|
skip2[repoName] = skipDays;
|
|
9838
9877
|
devlog.skip = skip2;
|
|
9839
9878
|
config.devlog = devlog;
|
|
9840
|
-
|
|
9879
|
+
writeFileSync22(configPath, stringifyYaml3(config, { lineWidth: 0 }));
|
|
9841
9880
|
console.log(chalk102.green(`Added ${date} to skip list for ${repoName}`));
|
|
9842
9881
|
}
|
|
9843
9882
|
|
|
@@ -10273,7 +10312,7 @@ import chalk110 from "chalk";
|
|
|
10273
10312
|
|
|
10274
10313
|
// src/commands/dotnet/findSolution.ts
|
|
10275
10314
|
import { readdirSync as readdirSync4 } from "fs";
|
|
10276
|
-
import { dirname as
|
|
10315
|
+
import { dirname as dirname18, join as join28 } from "path";
|
|
10277
10316
|
import chalk109 from "chalk";
|
|
10278
10317
|
function findSlnInDir(dir) {
|
|
10279
10318
|
try {
|
|
@@ -10298,7 +10337,7 @@ function findSolution() {
|
|
|
10298
10337
|
process.exit(1);
|
|
10299
10338
|
}
|
|
10300
10339
|
if (current === ceiling) break;
|
|
10301
|
-
current =
|
|
10340
|
+
current = dirname18(current);
|
|
10302
10341
|
}
|
|
10303
10342
|
console.error(chalk109.red("No .sln file found between cwd and repo root"));
|
|
10304
10343
|
process.exit(1);
|
|
@@ -10510,7 +10549,7 @@ function aggregateCommitters(authorLists) {
|
|
|
10510
10549
|
|
|
10511
10550
|
// src/shared/runGhGraphql.ts
|
|
10512
10551
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
10513
|
-
import { unlinkSync as unlinkSync8, writeFileSync as
|
|
10552
|
+
import { unlinkSync as unlinkSync8, writeFileSync as writeFileSync23 } from "fs";
|
|
10514
10553
|
import { tmpdir as tmpdir4 } from "os";
|
|
10515
10554
|
import { join as join29 } from "path";
|
|
10516
10555
|
function buildArgs2(queryFile, vars) {
|
|
@@ -10538,7 +10577,7 @@ function throwOnGraphqlErrors(stdout) {
|
|
|
10538
10577
|
}
|
|
10539
10578
|
function runGhGraphql(mutation, vars) {
|
|
10540
10579
|
const queryFile = join29(tmpdir4(), `gh-query-${Date.now()}.graphql`);
|
|
10541
|
-
|
|
10580
|
+
writeFileSync23(queryFile, mutation);
|
|
10542
10581
|
try {
|
|
10543
10582
|
const result = spawnSync3("gh", buildArgs2(queryFile, vars), {
|
|
10544
10583
|
encoding: "utf8"
|
|
@@ -11051,7 +11090,7 @@ function acceptanceCriteria(issueKey) {
|
|
|
11051
11090
|
import { execSync as execSync29 } from "child_process";
|
|
11052
11091
|
|
|
11053
11092
|
// src/shared/loadJson.ts
|
|
11054
|
-
import { existsSync as existsSync32, mkdirSync as
|
|
11093
|
+
import { existsSync as existsSync32, mkdirSync as mkdirSync11, readFileSync as readFileSync28, writeFileSync as writeFileSync24 } from "fs";
|
|
11055
11094
|
import { homedir as homedir11 } from "os";
|
|
11056
11095
|
import { join as join33 } from "path";
|
|
11057
11096
|
function getStoreDir() {
|
|
@@ -11074,9 +11113,9 @@ function loadJson(filename) {
|
|
|
11074
11113
|
function saveJson(filename, data) {
|
|
11075
11114
|
const dir = getStoreDir();
|
|
11076
11115
|
if (!existsSync32(dir)) {
|
|
11077
|
-
|
|
11116
|
+
mkdirSync11(dir, { recursive: true });
|
|
11078
11117
|
}
|
|
11079
|
-
|
|
11118
|
+
writeFileSync24(getStorePath(filename), JSON.stringify(data, null, 2));
|
|
11080
11119
|
}
|
|
11081
11120
|
|
|
11082
11121
|
// src/shared/promptInput.ts
|
|
@@ -11211,12 +11250,12 @@ function registerList(program2) {
|
|
|
11211
11250
|
}
|
|
11212
11251
|
|
|
11213
11252
|
// src/commands/mermaid/index.ts
|
|
11214
|
-
import { mkdirSync as
|
|
11253
|
+
import { mkdirSync as mkdirSync12, readdirSync as readdirSync6 } from "fs";
|
|
11215
11254
|
import { resolve as resolve10 } from "path";
|
|
11216
11255
|
import chalk122 from "chalk";
|
|
11217
11256
|
|
|
11218
11257
|
// src/commands/mermaid/exportFile.ts
|
|
11219
|
-
import { readFileSync as readFileSync29, writeFileSync as
|
|
11258
|
+
import { readFileSync as readFileSync29, writeFileSync as writeFileSync25 } from "fs";
|
|
11220
11259
|
import { basename as basename6, extname, resolve as resolve9 } from "path";
|
|
11221
11260
|
import chalk121 from "chalk";
|
|
11222
11261
|
|
|
@@ -11267,7 +11306,7 @@ async function exportFile(file, outDir, krokiUrl, onlyIndex) {
|
|
|
11267
11306
|
if (onlyIndex !== void 0 && idx !== onlyIndex) continue;
|
|
11268
11307
|
const outPath = resolve9(outDir, `${stem}-${idx}.svg`);
|
|
11269
11308
|
const svg = await renderBlock(krokiUrl, source);
|
|
11270
|
-
|
|
11309
|
+
writeFileSync25(outPath, svg, "utf8");
|
|
11271
11310
|
console.log(chalk121.green(` \u2192 ${outPath}`));
|
|
11272
11311
|
}
|
|
11273
11312
|
}
|
|
@@ -11280,7 +11319,7 @@ function extractMermaidBlocks(markdown) {
|
|
|
11280
11319
|
async function mermaidExport(file, options2 = {}) {
|
|
11281
11320
|
const { mermaid } = loadConfig();
|
|
11282
11321
|
const outDir = resolve10(process.cwd(), options2.out ?? ".");
|
|
11283
|
-
|
|
11322
|
+
mkdirSync12(outDir, { recursive: true });
|
|
11284
11323
|
if (options2.index !== void 0) {
|
|
11285
11324
|
if (!Number.isInteger(options2.index) || options2.index < 1) {
|
|
11286
11325
|
console.error(
|
|
@@ -11726,7 +11765,7 @@ import { execSync as execSync33 } from "child_process";
|
|
|
11726
11765
|
|
|
11727
11766
|
// src/commands/prs/resolveCommentWithReply.ts
|
|
11728
11767
|
import { execSync as execSync32 } from "child_process";
|
|
11729
|
-
import { unlinkSync as unlinkSync10, writeFileSync as
|
|
11768
|
+
import { unlinkSync as unlinkSync10, writeFileSync as writeFileSync26 } from "fs";
|
|
11730
11769
|
import { tmpdir as tmpdir5 } from "os";
|
|
11731
11770
|
import { join as join35 } from "path";
|
|
11732
11771
|
|
|
@@ -11763,7 +11802,7 @@ function replyToComment(org, repo, prNumber, commentId, message) {
|
|
|
11763
11802
|
function resolveThread(threadId) {
|
|
11764
11803
|
const mutation = `mutation($threadId: ID!) { resolveReviewThread(input: {threadId: $threadId}) { thread { isResolved } } }`;
|
|
11765
11804
|
const queryFile = join35(tmpdir5(), `gh-mutation-${Date.now()}.graphql`);
|
|
11766
|
-
|
|
11805
|
+
writeFileSync26(queryFile, mutation);
|
|
11767
11806
|
try {
|
|
11768
11807
|
execSync32(
|
|
11769
11808
|
`gh api graphql -F query=@${queryFile} -f threadId="${threadId}"`,
|
|
@@ -11844,19 +11883,19 @@ function fixed(commentId, sha) {
|
|
|
11844
11883
|
}
|
|
11845
11884
|
|
|
11846
11885
|
// src/commands/prs/listComments/index.ts
|
|
11847
|
-
import { existsSync as existsSync34, mkdirSync as
|
|
11886
|
+
import { existsSync as existsSync34, mkdirSync as mkdirSync13, writeFileSync as writeFileSync28 } from "fs";
|
|
11848
11887
|
import { join as join37 } from "path";
|
|
11849
11888
|
import { stringify } from "yaml";
|
|
11850
11889
|
|
|
11851
11890
|
// src/commands/prs/fetchThreadIds.ts
|
|
11852
11891
|
import { execSync as execSync34 } from "child_process";
|
|
11853
|
-
import { unlinkSync as unlinkSync11, writeFileSync as
|
|
11892
|
+
import { unlinkSync as unlinkSync11, writeFileSync as writeFileSync27 } from "fs";
|
|
11854
11893
|
import { tmpdir as tmpdir6 } from "os";
|
|
11855
11894
|
import { join as join36 } from "path";
|
|
11856
11895
|
var THREAD_QUERY = `query($owner: String!, $repo: String!, $prNumber: Int!) { repository(owner: $owner, name: $repo) { pullRequest(number: $prNumber) { reviewThreads(first: 100) { nodes { id isResolved comments(first: 100) { nodes { databaseId } } } } } } }`;
|
|
11857
11896
|
function fetchThreadIds(org, repo, prNumber) {
|
|
11858
11897
|
const queryFile = join36(tmpdir6(), `gh-query-${Date.now()}.graphql`);
|
|
11859
|
-
|
|
11898
|
+
writeFileSync27(queryFile, THREAD_QUERY);
|
|
11860
11899
|
try {
|
|
11861
11900
|
const result = execSync34(
|
|
11862
11901
|
`gh api graphql -F query=@${queryFile} -F owner="${org}" -F repo="${repo}" -F prNumber=${prNumber}`,
|
|
@@ -11971,7 +12010,7 @@ function printComments2(result) {
|
|
|
11971
12010
|
function writeCommentsCache(prNumber, comments3) {
|
|
11972
12011
|
const assistDir = join37(process.cwd(), ".assist");
|
|
11973
12012
|
if (!existsSync34(assistDir)) {
|
|
11974
|
-
|
|
12013
|
+
mkdirSync13(assistDir, { recursive: true });
|
|
11975
12014
|
}
|
|
11976
12015
|
const cacheData = {
|
|
11977
12016
|
prNumber,
|
|
@@ -11979,7 +12018,7 @@ function writeCommentsCache(prNumber, comments3) {
|
|
|
11979
12018
|
comments: comments3
|
|
11980
12019
|
};
|
|
11981
12020
|
const cachePath = join37(assistDir, `pr-${prNumber}-comments.yaml`);
|
|
11982
|
-
|
|
12021
|
+
writeFileSync28(cachePath, stringify(cacheData));
|
|
11983
12022
|
}
|
|
11984
12023
|
function handleKnownErrors(error) {
|
|
11985
12024
|
if (isGhNotInstalled(error)) {
|
|
@@ -15038,16 +15077,16 @@ async function handlePostSynthesis(synthesisPath, options2) {
|
|
|
15038
15077
|
}
|
|
15039
15078
|
|
|
15040
15079
|
// src/commands/review/prepareReviewDir.ts
|
|
15041
|
-
import { existsSync as existsSync35, mkdirSync as
|
|
15080
|
+
import { existsSync as existsSync35, mkdirSync as mkdirSync14, unlinkSync as unlinkSync12, writeFileSync as writeFileSync29 } from "fs";
|
|
15042
15081
|
function clearReviewFiles(paths) {
|
|
15043
15082
|
for (const path58 of [paths.claudePath, paths.codexPath, paths.synthesisPath]) {
|
|
15044
15083
|
if (existsSync35(path58)) unlinkSync12(path58);
|
|
15045
15084
|
}
|
|
15046
15085
|
}
|
|
15047
15086
|
function prepareReviewDir(paths, requestBody, force) {
|
|
15048
|
-
|
|
15087
|
+
mkdirSync14(paths.reviewDir, { recursive: true });
|
|
15049
15088
|
if (force) clearReviewFiles(paths);
|
|
15050
|
-
|
|
15089
|
+
writeFileSync29(paths.requestPath, requestBody);
|
|
15051
15090
|
}
|
|
15052
15091
|
|
|
15053
15092
|
// src/commands/review/runApplySession.ts
|
|
@@ -15392,7 +15431,7 @@ The review request is at: ${requestPath}
|
|
|
15392
15431
|
}
|
|
15393
15432
|
|
|
15394
15433
|
// src/commands/review/runClaudeReviewer.ts
|
|
15395
|
-
import { writeFileSync as
|
|
15434
|
+
import { writeFileSync as writeFileSync30 } from "fs";
|
|
15396
15435
|
|
|
15397
15436
|
// src/commands/review/finaliseReviewerSpinner.ts
|
|
15398
15437
|
var SUMMARY_MAX_LEN = 80;
|
|
@@ -15728,7 +15767,7 @@ async function runClaudeReviewer(spec) {
|
|
|
15728
15767
|
}
|
|
15729
15768
|
});
|
|
15730
15769
|
if (result.exitCode === 0 && finalText)
|
|
15731
|
-
|
|
15770
|
+
writeFileSync30(spec.outputPath, finalText);
|
|
15732
15771
|
return finaliseReviewerRun({ ...spec, command }, spinner, result);
|
|
15733
15772
|
}
|
|
15734
15773
|
|
|
@@ -16839,7 +16878,7 @@ async function configure() {
|
|
|
16839
16878
|
import { existsSync as existsSync40 } from "fs";
|
|
16840
16879
|
|
|
16841
16880
|
// src/commands/transcript/format/fixInvalidDatePrefixes/index.ts
|
|
16842
|
-
import { dirname as
|
|
16881
|
+
import { dirname as dirname20, join as join41 } from "path";
|
|
16843
16882
|
|
|
16844
16883
|
// src/commands/transcript/format/fixInvalidDatePrefixes/promptForDateFix.ts
|
|
16845
16884
|
import { renameSync as renameSync2 } from "fs";
|
|
@@ -16889,11 +16928,11 @@ async function fixInvalidDatePrefixes(vttFiles) {
|
|
|
16889
16928
|
for (let i = 0; i < vttFiles.length; i++) {
|
|
16890
16929
|
const vttFile = vttFiles[i];
|
|
16891
16930
|
if (!isValidDatePrefix(vttFile.filename)) {
|
|
16892
|
-
const vttFileDir =
|
|
16931
|
+
const vttFileDir = dirname20(vttFile.absolutePath);
|
|
16893
16932
|
const newFilename = await promptForDateFix(vttFile.filename, vttFileDir);
|
|
16894
16933
|
if (newFilename) {
|
|
16895
16934
|
const newRelativePath = join41(
|
|
16896
|
-
|
|
16935
|
+
dirname20(vttFile.relativePath),
|
|
16897
16936
|
newFilename
|
|
16898
16937
|
);
|
|
16899
16938
|
vttFiles[i] = {
|
|
@@ -16910,8 +16949,8 @@ async function fixInvalidDatePrefixes(vttFiles) {
|
|
|
16910
16949
|
}
|
|
16911
16950
|
|
|
16912
16951
|
// src/commands/transcript/format/processVttFile/index.ts
|
|
16913
|
-
import { existsSync as existsSync39, mkdirSync as
|
|
16914
|
-
import { basename as basename9, dirname as
|
|
16952
|
+
import { existsSync as existsSync39, mkdirSync as mkdirSync15, readFileSync as readFileSync33, writeFileSync as writeFileSync31 } from "fs";
|
|
16953
|
+
import { basename as basename9, dirname as dirname21, join as join42 } from "path";
|
|
16915
16954
|
|
|
16916
16955
|
// src/commands/transcript/cleanText.ts
|
|
16917
16956
|
function cleanText(text5) {
|
|
@@ -17125,7 +17164,7 @@ function resolveOutputDir(relativeDir, transcriptsDir) {
|
|
|
17125
17164
|
}
|
|
17126
17165
|
function buildOutputPaths(vttFile, transcriptsDir) {
|
|
17127
17166
|
const mdFile = toMdFilename(vttFile.filename);
|
|
17128
|
-
const relativeDir =
|
|
17167
|
+
const relativeDir = dirname21(vttFile.relativePath);
|
|
17129
17168
|
const outputDir = resolveOutputDir(relativeDir, transcriptsDir);
|
|
17130
17169
|
const outputPath = join42(outputDir, mdFile);
|
|
17131
17170
|
return { outputDir, outputPath, mdFile, relativeDir };
|
|
@@ -17136,7 +17175,7 @@ function logSkipped(relativeDir, mdFile) {
|
|
|
17136
17175
|
}
|
|
17137
17176
|
function ensureDirectory(dir, label2) {
|
|
17138
17177
|
if (!existsSync39(dir)) {
|
|
17139
|
-
|
|
17178
|
+
mkdirSync15(dir, { recursive: true });
|
|
17140
17179
|
console.log(`Created ${label2}: ${dir}`);
|
|
17141
17180
|
}
|
|
17142
17181
|
}
|
|
@@ -17161,7 +17200,7 @@ function readAndParseCues(inputPath) {
|
|
|
17161
17200
|
return processCues(readFileSync33(inputPath, "utf8"));
|
|
17162
17201
|
}
|
|
17163
17202
|
function writeFormatted(outputPath, content) {
|
|
17164
|
-
|
|
17203
|
+
writeFileSync31(outputPath, content, "utf8");
|
|
17165
17204
|
console.log(`Written: ${outputPath}`);
|
|
17166
17205
|
}
|
|
17167
17206
|
function convertVttToMarkdown(inputPath, outputPath) {
|
|
@@ -17230,17 +17269,17 @@ async function format() {
|
|
|
17230
17269
|
|
|
17231
17270
|
// src/commands/transcript/summarise/index.ts
|
|
17232
17271
|
import { existsSync as existsSync42 } from "fs";
|
|
17233
|
-
import { basename as basename10, dirname as
|
|
17272
|
+
import { basename as basename10, dirname as dirname23, join as join44, relative as relative3 } from "path";
|
|
17234
17273
|
|
|
17235
17274
|
// src/commands/transcript/summarise/processStagedFile/index.ts
|
|
17236
17275
|
import {
|
|
17237
17276
|
existsSync as existsSync41,
|
|
17238
|
-
mkdirSync as
|
|
17277
|
+
mkdirSync as mkdirSync16,
|
|
17239
17278
|
readFileSync as readFileSync34,
|
|
17240
17279
|
renameSync as renameSync3,
|
|
17241
17280
|
rmSync as rmSync4
|
|
17242
17281
|
} from "fs";
|
|
17243
|
-
import { dirname as
|
|
17282
|
+
import { dirname as dirname22, join as join43 } from "path";
|
|
17244
17283
|
|
|
17245
17284
|
// src/commands/transcript/summarise/processStagedFile/validateStagedContent.ts
|
|
17246
17285
|
import chalk165 from "chalk";
|
|
@@ -17294,9 +17333,9 @@ function processStagedFile() {
|
|
|
17294
17333
|
process.exit(1);
|
|
17295
17334
|
}
|
|
17296
17335
|
const destPath = join43(summaryDir, matchingTranscript.relativePath);
|
|
17297
|
-
const destDir =
|
|
17336
|
+
const destDir = dirname22(destPath);
|
|
17298
17337
|
if (!existsSync41(destDir)) {
|
|
17299
|
-
|
|
17338
|
+
mkdirSync16(destDir, { recursive: true });
|
|
17300
17339
|
}
|
|
17301
17340
|
renameSync3(stagedFile.absolutePath, destPath);
|
|
17302
17341
|
const remaining = findMdFilesRecursive(STAGING_DIR);
|
|
@@ -17308,7 +17347,7 @@ function processStagedFile() {
|
|
|
17308
17347
|
|
|
17309
17348
|
// src/commands/transcript/summarise/index.ts
|
|
17310
17349
|
function buildRelativeKey(relativePath, baseName) {
|
|
17311
|
-
const relDir =
|
|
17350
|
+
const relDir = dirname23(relativePath);
|
|
17312
17351
|
return relDir === "." ? baseName : join44(relDir, baseName);
|
|
17313
17352
|
}
|
|
17314
17353
|
function buildSummaryIndex(summaryDir) {
|
|
@@ -17344,7 +17383,7 @@ function summarise2() {
|
|
|
17344
17383
|
const next3 = missing[0];
|
|
17345
17384
|
const outputFilename = `${getTranscriptBaseName(next3.filename)}.md`;
|
|
17346
17385
|
const outputPath = join44(STAGING_DIR, outputFilename);
|
|
17347
|
-
const summaryFileDir = join44(summaryDir,
|
|
17386
|
+
const summaryFileDir = join44(summaryDir, dirname23(next3.relativePath));
|
|
17348
17387
|
const relativeTranscriptPath = encodeURI(
|
|
17349
17388
|
relative3(summaryFileDir, next3.absolutePath).replace(/\\/g, "/")
|
|
17350
17389
|
);
|
|
@@ -17398,9 +17437,9 @@ import { join as join46 } from "path";
|
|
|
17398
17437
|
|
|
17399
17438
|
// src/commands/voice/shared.ts
|
|
17400
17439
|
import { homedir as homedir13 } from "os";
|
|
17401
|
-
import { dirname as
|
|
17440
|
+
import { dirname as dirname24, join as join45 } from "path";
|
|
17402
17441
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
17403
|
-
var __dirname5 =
|
|
17442
|
+
var __dirname5 = dirname24(fileURLToPath5(import.meta.url));
|
|
17404
17443
|
var VOICE_DIR = join45(homedir13(), ".assist", "voice");
|
|
17405
17444
|
var voicePaths = {
|
|
17406
17445
|
dir: VOICE_DIR,
|
|
@@ -17459,12 +17498,12 @@ function logs(options2) {
|
|
|
17459
17498
|
|
|
17460
17499
|
// src/commands/voice/setup.ts
|
|
17461
17500
|
import { spawnSync as spawnSync6 } from "child_process";
|
|
17462
|
-
import { mkdirSync as
|
|
17501
|
+
import { mkdirSync as mkdirSync18 } from "fs";
|
|
17463
17502
|
import { join as join48 } from "path";
|
|
17464
17503
|
|
|
17465
17504
|
// src/commands/voice/checkLockFile.ts
|
|
17466
17505
|
import { execSync as execSync46 } from "child_process";
|
|
17467
|
-
import { existsSync as existsSync44, mkdirSync as
|
|
17506
|
+
import { existsSync as existsSync44, mkdirSync as mkdirSync17, readFileSync as readFileSync36, writeFileSync as writeFileSync32 } from "fs";
|
|
17468
17507
|
import { join as join47 } from "path";
|
|
17469
17508
|
function isProcessAlive2(pid) {
|
|
17470
17509
|
try {
|
|
@@ -17502,8 +17541,8 @@ function bootstrapVenv() {
|
|
|
17502
17541
|
}
|
|
17503
17542
|
function writeLockFile(pid) {
|
|
17504
17543
|
const lockFile = getLockFile();
|
|
17505
|
-
|
|
17506
|
-
|
|
17544
|
+
mkdirSync17(join47(lockFile, ".."), { recursive: true });
|
|
17545
|
+
writeFileSync32(
|
|
17507
17546
|
lockFile,
|
|
17508
17547
|
JSON.stringify({
|
|
17509
17548
|
pid,
|
|
@@ -17515,7 +17554,7 @@ function writeLockFile(pid) {
|
|
|
17515
17554
|
|
|
17516
17555
|
// src/commands/voice/setup.ts
|
|
17517
17556
|
function setup() {
|
|
17518
|
-
|
|
17557
|
+
mkdirSync18(voicePaths.dir, { recursive: true });
|
|
17519
17558
|
bootstrapVenv();
|
|
17520
17559
|
console.log("\nDownloading models...\n");
|
|
17521
17560
|
const script = join48(getPythonDir(), "setup_models.py");
|
|
@@ -17531,7 +17570,7 @@ function setup() {
|
|
|
17531
17570
|
|
|
17532
17571
|
// src/commands/voice/start.ts
|
|
17533
17572
|
import { spawn as spawn7 } from "child_process";
|
|
17534
|
-
import { mkdirSync as
|
|
17573
|
+
import { mkdirSync as mkdirSync19, writeFileSync as writeFileSync33 } from "fs";
|
|
17535
17574
|
import { join as join49 } from "path";
|
|
17536
17575
|
|
|
17537
17576
|
// src/commands/voice/buildDaemonEnv.ts
|
|
@@ -17560,12 +17599,12 @@ function spawnBackground(python, script, env) {
|
|
|
17560
17599
|
console.error("Failed to start voice daemon");
|
|
17561
17600
|
process.exit(1);
|
|
17562
17601
|
}
|
|
17563
|
-
|
|
17602
|
+
writeFileSync33(voicePaths.pid, String(pid));
|
|
17564
17603
|
writeLockFile(pid);
|
|
17565
17604
|
console.log(`Voice daemon started (PID ${pid})`);
|
|
17566
17605
|
}
|
|
17567
17606
|
function start2(options2) {
|
|
17568
|
-
|
|
17607
|
+
mkdirSync19(voicePaths.dir, { recursive: true });
|
|
17569
17608
|
checkLockFile();
|
|
17570
17609
|
bootstrapVenv();
|
|
17571
17610
|
const debug = options2.debug || options2.foreground || process.platform === "win32";
|
|
@@ -17984,12 +18023,12 @@ function runPreCommands(pre, cwd) {
|
|
|
17984
18023
|
// src/commands/run/spawnRunCommand.ts
|
|
17985
18024
|
import { execFileSync as execFileSync8, spawn as spawn8 } from "child_process";
|
|
17986
18025
|
import { existsSync as existsSync47 } from "fs";
|
|
17987
|
-
import { dirname as
|
|
18026
|
+
import { dirname as dirname25, join as join51, resolve as resolve11 } from "path";
|
|
17988
18027
|
function resolveCommand2(command) {
|
|
17989
18028
|
if (process.platform !== "win32" || command !== "bash") return command;
|
|
17990
18029
|
try {
|
|
17991
18030
|
const gitPath = execFileSync8("where", ["git"], { encoding: "utf8" }).trim().split("\r\n")[0];
|
|
17992
|
-
const gitRoot = resolve11(
|
|
18031
|
+
const gitRoot = resolve11(dirname25(gitPath), "..");
|
|
17993
18032
|
const gitBash = join51(gitRoot, "bin", "bash.exe");
|
|
17994
18033
|
if (existsSync47(gitBash)) return gitBash;
|
|
17995
18034
|
} catch {
|
|
@@ -18076,7 +18115,7 @@ async function run3(name, args) {
|
|
|
18076
18115
|
}
|
|
18077
18116
|
|
|
18078
18117
|
// src/commands/run/add.ts
|
|
18079
|
-
import { mkdirSync as
|
|
18118
|
+
import { mkdirSync as mkdirSync20, writeFileSync as writeFileSync34 } from "fs";
|
|
18080
18119
|
import { join as join52 } from "path";
|
|
18081
18120
|
|
|
18082
18121
|
// src/commands/run/extractOption.ts
|
|
@@ -18139,7 +18178,7 @@ function saveNewRunConfig(name, command, args, cwd) {
|
|
|
18139
18178
|
}
|
|
18140
18179
|
function createCommandFile(name) {
|
|
18141
18180
|
const dir = join52(".claude", "commands");
|
|
18142
|
-
|
|
18181
|
+
mkdirSync20(dir, { recursive: true });
|
|
18143
18182
|
const content = `---
|
|
18144
18183
|
description: Run ${name}
|
|
18145
18184
|
---
|
|
@@ -18147,7 +18186,7 @@ description: Run ${name}
|
|
|
18147
18186
|
Run \`assist run ${name} $ARGUMENTS 2>&1\`.
|
|
18148
18187
|
`;
|
|
18149
18188
|
const filePath = join52(dir, `${name}.md`);
|
|
18150
|
-
|
|
18189
|
+
writeFileSync34(filePath, content);
|
|
18151
18190
|
console.log(`Created command file: ${filePath}`);
|
|
18152
18191
|
}
|
|
18153
18192
|
function add3() {
|
|
@@ -18258,7 +18297,7 @@ function registerRun(program2) {
|
|
|
18258
18297
|
|
|
18259
18298
|
// src/commands/screenshot/index.ts
|
|
18260
18299
|
import { execSync as execSync48 } from "child_process";
|
|
18261
|
-
import { existsSync as existsSync49, mkdirSync as
|
|
18300
|
+
import { existsSync as existsSync49, mkdirSync as mkdirSync21, unlinkSync as unlinkSync17, writeFileSync as writeFileSync35 } from "fs";
|
|
18262
18301
|
import { tmpdir as tmpdir7 } from "os";
|
|
18263
18302
|
import { join as join54, resolve as resolve13 } from "path";
|
|
18264
18303
|
import chalk167 from "chalk";
|
|
@@ -18391,14 +18430,14 @@ Write-Output $OutputPath
|
|
|
18391
18430
|
// src/commands/screenshot/index.ts
|
|
18392
18431
|
function buildOutputPath(outputDir, processName) {
|
|
18393
18432
|
if (!existsSync49(outputDir)) {
|
|
18394
|
-
|
|
18433
|
+
mkdirSync21(outputDir, { recursive: true });
|
|
18395
18434
|
}
|
|
18396
18435
|
const timestamp2 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
18397
18436
|
return resolve13(outputDir, `${processName}-${timestamp2}.png`);
|
|
18398
18437
|
}
|
|
18399
18438
|
function runPowerShellScript(processName, outputPath) {
|
|
18400
18439
|
const scriptPath = join54(tmpdir7(), `assist-screenshot-${Date.now()}.ps1`);
|
|
18401
|
-
|
|
18440
|
+
writeFileSync35(scriptPath, captureWindowPs1, "utf8");
|
|
18402
18441
|
try {
|
|
18403
18442
|
execSync48(
|
|
18404
18443
|
`powershell -NoProfile -ExecutionPolicy Bypass -File "${scriptPath}" -ProcessName "${processName}" -OutputPath "${outputPath}"`,
|
|
@@ -18527,7 +18566,7 @@ function reportStrays(pids) {
|
|
|
18527
18566
|
}
|
|
18528
18567
|
|
|
18529
18568
|
// src/commands/sessions/daemon/runDaemon.ts
|
|
18530
|
-
import { mkdirSync as
|
|
18569
|
+
import { mkdirSync as mkdirSync23 } from "fs";
|
|
18531
18570
|
|
|
18532
18571
|
// src/commands/sessions/daemon/createAutoExit.ts
|
|
18533
18572
|
var DEFAULT_GRACE_MS = 6e4;
|
|
@@ -18797,8 +18836,6 @@ function createAssistSession(id2, assistArgs, cwd) {
|
|
|
18797
18836
|
startedAt: Date.now(),
|
|
18798
18837
|
pty: spawnPty(["assist", ...assistArgs], cwd, id2),
|
|
18799
18838
|
scrollback: "",
|
|
18800
|
-
idleTimer: null,
|
|
18801
|
-
lastResizeAt: 0,
|
|
18802
18839
|
assistArgs,
|
|
18803
18840
|
cwd
|
|
18804
18841
|
};
|
|
@@ -18806,12 +18843,15 @@ function createAssistSession(id2, assistArgs, cwd) {
|
|
|
18806
18843
|
|
|
18807
18844
|
// src/commands/sessions/daemon/spawnClaude.ts
|
|
18808
18845
|
function spawnClaude2(opts = {}) {
|
|
18809
|
-
return spawnPty(buildArgs3(opts), opts.cwd);
|
|
18846
|
+
return spawnPty(buildArgs3(opts), opts.cwd, opts.sessionId);
|
|
18810
18847
|
}
|
|
18811
18848
|
function buildArgs3(opts) {
|
|
18812
|
-
|
|
18813
|
-
if (opts.
|
|
18814
|
-
|
|
18849
|
+
const base = ["claude", "--settings", ensureHooksSettings()];
|
|
18850
|
+
if (opts.resumeSessionId) {
|
|
18851
|
+
return opts.prompt ? [...base, "--resume", opts.resumeSessionId, opts.prompt] : [...base, "--resume", opts.resumeSessionId];
|
|
18852
|
+
}
|
|
18853
|
+
if (opts.prompt) return [...base, opts.prompt];
|
|
18854
|
+
return base;
|
|
18815
18855
|
}
|
|
18816
18856
|
|
|
18817
18857
|
// src/commands/sessions/daemon/spawnRun.ts
|
|
@@ -18827,10 +18867,8 @@ function createSession(id2, prompt, cwd) {
|
|
|
18827
18867
|
commandType: "claude",
|
|
18828
18868
|
status: "running",
|
|
18829
18869
|
startedAt: Date.now(),
|
|
18830
|
-
pty: spawnClaude2({ prompt, cwd }),
|
|
18870
|
+
pty: spawnClaude2({ prompt, cwd, sessionId: id2 }),
|
|
18831
18871
|
scrollback: "",
|
|
18832
|
-
idleTimer: null,
|
|
18833
|
-
lastResizeAt: 0,
|
|
18834
18872
|
cwd
|
|
18835
18873
|
};
|
|
18836
18874
|
}
|
|
@@ -18843,8 +18881,6 @@ function createRunSession(id2, runName, runArgs, cwd) {
|
|
|
18843
18881
|
startedAt: Date.now(),
|
|
18844
18882
|
pty: spawnRun({ name: runName, args: runArgs, cwd }),
|
|
18845
18883
|
scrollback: "",
|
|
18846
|
-
idleTimer: null,
|
|
18847
|
-
lastResizeAt: 0,
|
|
18848
18884
|
runName,
|
|
18849
18885
|
runArgs,
|
|
18850
18886
|
cwd
|
|
@@ -18888,6 +18924,8 @@ function shouldAutoRun(session, exitCode) {
|
|
|
18888
18924
|
|
|
18889
18925
|
// src/commands/sessions/daemon/applyStatusChange.ts
|
|
18890
18926
|
function applyStatusChange(session, status2, exitCode, dismiss, notify2, reuseForRun) {
|
|
18927
|
+
if (session.status === status2) return;
|
|
18928
|
+
daemonLog(`session ${session.id} status: ${session.status} -> ${status2}`);
|
|
18891
18929
|
session.status = status2;
|
|
18892
18930
|
if (shouldAutoRun(session, exitCode) && session.activity?.itemId != null) {
|
|
18893
18931
|
reuseForRun(session, session.activity.itemId);
|
|
@@ -18910,8 +18948,6 @@ function restoreBase(id2, persisted) {
|
|
|
18910
18948
|
name: persisted.name,
|
|
18911
18949
|
commandType: persisted.commandType,
|
|
18912
18950
|
scrollback: "",
|
|
18913
|
-
idleTimer: null,
|
|
18914
|
-
lastResizeAt: 0,
|
|
18915
18951
|
cwd: persisted.cwd,
|
|
18916
18952
|
assistArgs: persisted.assistArgs
|
|
18917
18953
|
};
|
|
@@ -18960,7 +18996,9 @@ function restoreSession(id2, persisted) {
|
|
|
18960
18996
|
if (persisted.commandType !== "run" && persisted.claudeSessionId) {
|
|
18961
18997
|
const pty2 = spawnClaude2({
|
|
18962
18998
|
resumeSessionId: persisted.claudeSessionId,
|
|
18963
|
-
|
|
18999
|
+
prompt: buildResumePrompt(),
|
|
19000
|
+
cwd: persisted.cwd,
|
|
19001
|
+
sessionId: id2
|
|
18964
19002
|
});
|
|
18965
19003
|
return runningSession(base, persisted, pty2);
|
|
18966
19004
|
}
|
|
@@ -19007,6 +19045,14 @@ function logRestoreError(name, error) {
|
|
|
19007
19045
|
return reason;
|
|
19008
19046
|
}
|
|
19009
19047
|
|
|
19048
|
+
// src/commands/sessions/daemon/restoreAll.ts
|
|
19049
|
+
function restoreAll(spawn12, sessions) {
|
|
19050
|
+
return loadPersistedSessions().map((persisted) => {
|
|
19051
|
+
restoreOne(persisted, spawn12, sessions);
|
|
19052
|
+
return persisted.name;
|
|
19053
|
+
});
|
|
19054
|
+
}
|
|
19055
|
+
|
|
19010
19056
|
// src/commands/sessions/daemon/resumeSession.ts
|
|
19011
19057
|
function resumeSession(id2, sessionId, cwd, name) {
|
|
19012
19058
|
return {
|
|
@@ -19015,40 +19061,26 @@ function resumeSession(id2, sessionId, cwd, name) {
|
|
|
19015
19061
|
commandType: "claude",
|
|
19016
19062
|
status: "running",
|
|
19017
19063
|
startedAt: Date.now(),
|
|
19018
|
-
pty: spawnClaude2({ resumeSessionId: sessionId, cwd }),
|
|
19064
|
+
pty: spawnClaude2({ resumeSessionId: sessionId, cwd, sessionId: id2 }),
|
|
19019
19065
|
scrollback: "",
|
|
19020
|
-
idleTimer: null,
|
|
19021
|
-
lastResizeAt: 0,
|
|
19022
19066
|
cwd
|
|
19023
19067
|
};
|
|
19024
19068
|
}
|
|
19025
19069
|
|
|
19026
|
-
// src/commands/sessions/daemon/scheduleIdle.ts
|
|
19027
|
-
var IDLE_MS = 3e3;
|
|
19028
|
-
function scheduleIdle(session, onIdle) {
|
|
19029
|
-
if (session.idleTimer) clearTimeout(session.idleTimer);
|
|
19030
|
-
if (session.status === "done") return;
|
|
19031
|
-
session.idleTimer = setTimeout(() => {
|
|
19032
|
-
if (session.status === "running") onIdle();
|
|
19033
|
-
}, IDLE_MS);
|
|
19034
|
-
}
|
|
19035
|
-
function clearIdle(session) {
|
|
19036
|
-
if (session.idleTimer) clearTimeout(session.idleTimer);
|
|
19037
|
-
}
|
|
19038
|
-
|
|
19039
19070
|
// src/commands/sessions/daemon/watchActivity.ts
|
|
19040
|
-
import { existsSync as existsSync51, mkdirSync as
|
|
19041
|
-
import { dirname as
|
|
19071
|
+
import { existsSync as existsSync51, mkdirSync as mkdirSync22, watch } from "fs";
|
|
19072
|
+
import { dirname as dirname26 } from "path";
|
|
19042
19073
|
var DEBOUNCE_MS = 50;
|
|
19043
19074
|
function watchActivity(session, notify2) {
|
|
19044
19075
|
if (session.commandType !== "assist" || !session.cwd) return;
|
|
19045
19076
|
const path58 = activityPath(session.id);
|
|
19046
|
-
const dir =
|
|
19077
|
+
const dir = dirname26(path58);
|
|
19047
19078
|
try {
|
|
19048
|
-
|
|
19079
|
+
mkdirSync22(dir, { recursive: true });
|
|
19049
19080
|
} catch {
|
|
19050
19081
|
return;
|
|
19051
19082
|
}
|
|
19083
|
+
if (session.restored) reconcileActivity(session.id, session.activity);
|
|
19052
19084
|
let timer = null;
|
|
19053
19085
|
const read = () => {
|
|
19054
19086
|
timer = null;
|
|
@@ -19077,7 +19109,6 @@ function refreshActivity(session) {
|
|
|
19077
19109
|
|
|
19078
19110
|
// src/commands/sessions/daemon/wirePtyEvents.ts
|
|
19079
19111
|
var MAX_SCROLLBACK = 256 * 1024;
|
|
19080
|
-
var RESIZE_GRACE_MS = 500;
|
|
19081
19112
|
function appendScrollback(session, data) {
|
|
19082
19113
|
session.scrollback += data;
|
|
19083
19114
|
if (session.scrollback.length > MAX_SCROLLBACK) {
|
|
@@ -19088,15 +19119,9 @@ function wirePtyEvents(session, clients, onStatusChange) {
|
|
|
19088
19119
|
if (!session.pty) return;
|
|
19089
19120
|
session.pty.onData((data) => {
|
|
19090
19121
|
appendScrollback(session, data);
|
|
19091
|
-
const isRedraw = Date.now() - session.lastResizeAt < RESIZE_GRACE_MS;
|
|
19092
|
-
if (!isRedraw && session.status !== "running")
|
|
19093
|
-
onStatusChange(session, "running");
|
|
19094
|
-
if (!isRedraw)
|
|
19095
|
-
scheduleIdle(session, () => onStatusChange(session, "waiting"));
|
|
19096
19122
|
broadcast(clients, { type: "output", sessionId: session.id, data });
|
|
19097
19123
|
});
|
|
19098
19124
|
session.pty.onExit(({ exitCode }) => {
|
|
19099
|
-
clearIdle(session);
|
|
19100
19125
|
refreshActivity(session);
|
|
19101
19126
|
const failedResume = session.restored === true && exitCode !== 0 && session.scrollback.length === 0;
|
|
19102
19127
|
if (failedResume) {
|
|
@@ -19107,7 +19132,6 @@ function wirePtyEvents(session, clients, onStatusChange) {
|
|
|
19107
19132
|
}
|
|
19108
19133
|
onStatusChange(session, failedResume ? "error" : "done", exitCode);
|
|
19109
19134
|
});
|
|
19110
|
-
scheduleIdle(session, () => onStatusChange(session, "waiting"));
|
|
19111
19135
|
}
|
|
19112
19136
|
|
|
19113
19137
|
// src/commands/sessions/daemon/retrySession.ts
|
|
@@ -19115,7 +19139,6 @@ function retrySession(session, clients, onStatusChange) {
|
|
|
19115
19139
|
const respawn = respawnThunk(session);
|
|
19116
19140
|
if (!respawn) return false;
|
|
19117
19141
|
if (session.status !== "done") session.pty?.kill();
|
|
19118
|
-
clearIdle(session);
|
|
19119
19142
|
session.scrollback = "";
|
|
19120
19143
|
session.status = "running";
|
|
19121
19144
|
session.startedAt = Date.now();
|
|
@@ -19138,7 +19161,6 @@ function respawnThunk(session) {
|
|
|
19138
19161
|
function reuseSessionForRun(session, itemId, clients, onStatusChange) {
|
|
19139
19162
|
const assistArgs = ["backlog", "run", String(itemId)];
|
|
19140
19163
|
if (session.status !== "done") session.pty?.kill();
|
|
19141
|
-
clearIdle(session);
|
|
19142
19164
|
session.assistArgs = assistArgs;
|
|
19143
19165
|
session.name = `assist ${assistArgs.join(" ")}`;
|
|
19144
19166
|
session.commandType = "assist";
|
|
@@ -19152,7 +19174,6 @@ function reuseSessionForRun(session, itemId, clients, onStatusChange) {
|
|
|
19152
19174
|
// src/commands/sessions/daemon/shutdownSessions.ts
|
|
19153
19175
|
function shutdownSessions(sessions) {
|
|
19154
19176
|
for (const session of sessions.values()) {
|
|
19155
|
-
clearIdle(session);
|
|
19156
19177
|
if (session.status !== "done") session.pty?.kill();
|
|
19157
19178
|
}
|
|
19158
19179
|
}
|
|
@@ -19946,10 +19967,7 @@ function writeToSession(sessions, id2, data) {
|
|
|
19946
19967
|
}
|
|
19947
19968
|
function resizeSession(sessions, id2, cols, rows) {
|
|
19948
19969
|
const s = sessions.get(id2);
|
|
19949
|
-
if (s && s.status !== "done")
|
|
19950
|
-
s.lastResizeAt = Date.now();
|
|
19951
|
-
s.pty?.resize(cols, rows);
|
|
19952
|
-
}
|
|
19970
|
+
if (s && s.status !== "done") s.pty?.resize(cols, rows);
|
|
19953
19971
|
}
|
|
19954
19972
|
function setAutoRun(sessions, id2, enabled) {
|
|
19955
19973
|
const s = sessions.get(id2);
|
|
@@ -19972,7 +19990,6 @@ function dismissSession(sessions, id2) {
|
|
|
19972
19990
|
const s = sessions.get(id2);
|
|
19973
19991
|
if (!s) return false;
|
|
19974
19992
|
if (s.status !== "done") s.pty?.kill();
|
|
19975
|
-
clearIdle(s);
|
|
19976
19993
|
s.activityWatcher?.close();
|
|
19977
19994
|
removeActivity(s.id);
|
|
19978
19995
|
if (s.activity?.itemId != null) releaseLock(s.activity.itemId);
|
|
@@ -20008,10 +20025,7 @@ var SessionManager = class {
|
|
|
20008
20025
|
shutdownSessions(this.sessions);
|
|
20009
20026
|
}
|
|
20010
20027
|
restore() {
|
|
20011
|
-
return
|
|
20012
|
-
restoreOne(persisted, this.spawnWith, this.sessions);
|
|
20013
|
-
return persisted.name;
|
|
20014
|
-
});
|
|
20028
|
+
return restoreAll(this.spawnWith, this.sessions);
|
|
20015
20029
|
}
|
|
20016
20030
|
add(session) {
|
|
20017
20031
|
this.wire(session);
|
|
@@ -20061,6 +20075,10 @@ var SessionManager = class {
|
|
|
20061
20075
|
setAutoAdvance(id2, enabled) {
|
|
20062
20076
|
if (setAutoAdvance(this.sessions, id2, enabled)) this.notify();
|
|
20063
20077
|
}
|
|
20078
|
+
setStatus(id2, status2) {
|
|
20079
|
+
const session = this.sessions.get(id2);
|
|
20080
|
+
if (session) this.onStatusChange(session, status2);
|
|
20081
|
+
}
|
|
20064
20082
|
listSessions = () => {
|
|
20065
20083
|
const local = [...this.sessions.values()].map(toSessionInfo);
|
|
20066
20084
|
return local.concat(this.windowsProxy.sessions());
|
|
@@ -20171,7 +20189,7 @@ function safeParse2(line) {
|
|
|
20171
20189
|
}
|
|
20172
20190
|
}
|
|
20173
20191
|
|
|
20174
|
-
// src/commands/sessions/daemon/
|
|
20192
|
+
// src/commands/sessions/daemon/messageHandlers.ts
|
|
20175
20193
|
function creator(isNew, spawn12) {
|
|
20176
20194
|
return (client, m, d) => {
|
|
20177
20195
|
if (m.windowsProxy.route(client, d)) return;
|
|
@@ -20199,7 +20217,7 @@ function routed(local) {
|
|
|
20199
20217
|
if (!m.windowsProxy.route(client, d)) local(client, m, d);
|
|
20200
20218
|
};
|
|
20201
20219
|
}
|
|
20202
|
-
var
|
|
20220
|
+
var messageHandlers = {
|
|
20203
20221
|
ping: (client) => sendTo(client, { type: "pong", pid: process.pid }),
|
|
20204
20222
|
hello: (client) => sendTo(client, buildHello()),
|
|
20205
20223
|
create: creator(
|
|
@@ -20247,10 +20265,15 @@ var handlers = {
|
|
|
20247
20265
|
"set-autoadvance": routed(
|
|
20248
20266
|
(_client, m, d) => m.setAutoAdvance(d.sessionId, d.enabled)
|
|
20249
20267
|
),
|
|
20250
|
-
"set-active": (_client, m, d) => m.active.set(d.cwd, d.sessionId)
|
|
20268
|
+
"set-active": (_client, m, d) => m.active.set(d.cwd, d.sessionId),
|
|
20269
|
+
"set-status": routed(
|
|
20270
|
+
(_client, m, d) => m.setStatus(d.sessionId, d.status)
|
|
20271
|
+
)
|
|
20251
20272
|
};
|
|
20273
|
+
|
|
20274
|
+
// src/commands/sessions/daemon/dispatchMessage.ts
|
|
20252
20275
|
function dispatchMessage(client, manager, data) {
|
|
20253
|
-
|
|
20276
|
+
messageHandlers[data.type]?.(client, manager, data);
|
|
20254
20277
|
}
|
|
20255
20278
|
|
|
20256
20279
|
// src/commands/sessions/daemon/handleConnection.ts
|
|
@@ -20288,7 +20311,7 @@ function handleConnection(socket, manager) {
|
|
|
20288
20311
|
}
|
|
20289
20312
|
|
|
20290
20313
|
// src/commands/sessions/daemon/onListening.ts
|
|
20291
|
-
import { unlinkSync as unlinkSync18, writeFileSync as
|
|
20314
|
+
import { unlinkSync as unlinkSync18, writeFileSync as writeFileSync36 } from "fs";
|
|
20292
20315
|
|
|
20293
20316
|
// src/commands/sessions/daemon/startPidFileWatchdog.ts
|
|
20294
20317
|
import { readFileSync as readFileSync41 } from "fs";
|
|
@@ -20310,7 +20333,7 @@ function ownsPidFile() {
|
|
|
20310
20333
|
|
|
20311
20334
|
// src/commands/sessions/daemon/onListening.ts
|
|
20312
20335
|
function onListening(manager, checkAutoExit) {
|
|
20313
|
-
|
|
20336
|
+
writeFileSync36(daemonPaths.pid, String(process.pid));
|
|
20314
20337
|
startPidFileWatchdog(() => {
|
|
20315
20338
|
daemonLog("lost daemon.pid ownership; shutting down sessions and exiting");
|
|
20316
20339
|
manager.shutdown();
|
|
@@ -20385,7 +20408,7 @@ async function recoverFromAddrInUse(server, manager, checkAutoExit) {
|
|
|
20385
20408
|
|
|
20386
20409
|
// src/commands/sessions/daemon/runDaemon.ts
|
|
20387
20410
|
async function runDaemon() {
|
|
20388
|
-
|
|
20411
|
+
mkdirSync23(daemonPaths.dir, { recursive: true });
|
|
20389
20412
|
daemonLog(
|
|
20390
20413
|
`starting (reason: ${process.env.ASSIST_DAEMON_SPAWN_REASON ?? "manual"})`
|
|
20391
20414
|
);
|
|
@@ -20418,6 +20441,29 @@ function registerDaemon(program2) {
|
|
|
20418
20441
|
).action(restartDaemon);
|
|
20419
20442
|
}
|
|
20420
20443
|
|
|
20444
|
+
// src/commands/sessions/daemon/sendToDaemon.ts
|
|
20445
|
+
async function sendToDaemon(message) {
|
|
20446
|
+
const socket = await connectToDaemon();
|
|
20447
|
+
const timer = setTimeout(() => socket.destroy(), 500);
|
|
20448
|
+
socket.on("error", () => {
|
|
20449
|
+
});
|
|
20450
|
+
socket.write(`${JSON.stringify(message)}
|
|
20451
|
+
`, () => {
|
|
20452
|
+
clearTimeout(timer);
|
|
20453
|
+
socket.end();
|
|
20454
|
+
});
|
|
20455
|
+
}
|
|
20456
|
+
|
|
20457
|
+
// src/commands/sessions/setSessionStatus.ts
|
|
20458
|
+
async function setSessionStatus(status2) {
|
|
20459
|
+
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
20460
|
+
if (!sessionId) return;
|
|
20461
|
+
try {
|
|
20462
|
+
await sendToDaemon({ type: "set-status", sessionId, status: status2 });
|
|
20463
|
+
} catch {
|
|
20464
|
+
}
|
|
20465
|
+
}
|
|
20466
|
+
|
|
20421
20467
|
// src/commands/sessions/summarise/index.ts
|
|
20422
20468
|
import * as fs35 from "fs";
|
|
20423
20469
|
import chalk168 from "chalk";
|
|
@@ -20630,6 +20676,9 @@ function registerSessions(program2) {
|
|
|
20630
20676
|
const cmd = program2.command("sessions").description("Web dashboard for Claude Code sessions").option("--no-open", "Do not open a browser on startup").action((options2) => web({ port: "3100", open: options2.open }));
|
|
20631
20677
|
cmd.command("web").description("Start the sessions web dashboard").option("-p, --port <number>", "Port to listen on", "3100").option("--no-open", "Do not open a browser on startup").action(web);
|
|
20632
20678
|
cmd.command("summarise").description("Generate one-line summaries for Claude sessions").option("-f, --force", "Re-generate all summaries, even existing ones").option("-n, --limit <count>", "Maximum number of sessions to summarise").action(summarise3);
|
|
20679
|
+
cmd.command("set-status <status>").description(
|
|
20680
|
+
"Report the current session's status to the sessions daemon (used by Claude Code hooks)"
|
|
20681
|
+
).action(setSessionStatus);
|
|
20633
20682
|
}
|
|
20634
20683
|
|
|
20635
20684
|
// src/commands/statusLine.ts
|
|
@@ -20703,15 +20752,7 @@ function buildLimitsSegment(rateLimits) {
|
|
|
20703
20752
|
async function relayRateLimits(rateLimits) {
|
|
20704
20753
|
if (!rateLimits) return;
|
|
20705
20754
|
try {
|
|
20706
|
-
|
|
20707
|
-
const timer = setTimeout(() => socket.destroy(), 500);
|
|
20708
|
-
socket.on("error", () => {
|
|
20709
|
-
});
|
|
20710
|
-
socket.write(`${JSON.stringify({ type: "limits", rateLimits })}
|
|
20711
|
-
`, () => {
|
|
20712
|
-
clearTimeout(timer);
|
|
20713
|
-
socket.end();
|
|
20714
|
-
});
|
|
20755
|
+
await sendToDaemon({ type: "limits", rateLimits });
|
|
20715
20756
|
} catch {
|
|
20716
20757
|
}
|
|
20717
20758
|
}
|
|
@@ -20842,6 +20883,22 @@ function syncCommands(claudeDir, targetBase) {
|
|
|
20842
20883
|
// src/commands/update.ts
|
|
20843
20884
|
import { execSync as execSync49 } from "child_process";
|
|
20844
20885
|
import * as path57 from "path";
|
|
20886
|
+
|
|
20887
|
+
// src/commands/restartDaemonAfterUpdate.ts
|
|
20888
|
+
async function restartDaemonAfterUpdate() {
|
|
20889
|
+
if (!await isDaemonRunning()) return;
|
|
20890
|
+
console.log("Restarting sessions daemon to load the new build...");
|
|
20891
|
+
try {
|
|
20892
|
+
await restartDaemon();
|
|
20893
|
+
} catch (error) {
|
|
20894
|
+
console.error(
|
|
20895
|
+
`Failed to restart sessions daemon: ${error instanceof Error ? error.message : String(error)}`
|
|
20896
|
+
);
|
|
20897
|
+
process.exit(1);
|
|
20898
|
+
}
|
|
20899
|
+
}
|
|
20900
|
+
|
|
20901
|
+
// src/commands/update.ts
|
|
20845
20902
|
function isGlobalNpmInstall(dir) {
|
|
20846
20903
|
try {
|
|
20847
20904
|
const resolved = path57.resolve(dir);
|
|
@@ -20877,6 +20934,7 @@ async function update2() {
|
|
|
20877
20934
|
);
|
|
20878
20935
|
process.exit(1);
|
|
20879
20936
|
}
|
|
20937
|
+
await restartDaemonAfterUpdate();
|
|
20880
20938
|
}
|
|
20881
20939
|
|
|
20882
20940
|
// src/index.ts
|