@staff0rd/assist 0.669.0 → 0.671.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 +3 -2
- package/claude/commands/slack-post.md +27 -14
- package/dist/commands/sessions/web/bundle.js +1 -1
- package/dist/index.js +137 -65
- 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.671.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -33611,43 +33611,103 @@ function parseSlackThreadRef(value) {
|
|
|
33611
33611
|
}
|
|
33612
33612
|
|
|
33613
33613
|
// src/commands/slack/postSlackMessage.ts
|
|
33614
|
+
import { mkdirSync as mkdirSync25, writeFileSync as writeFileSync44 } from "fs";
|
|
33615
|
+
|
|
33616
|
+
// src/commands/slack/previewSlackThreadParts.ts
|
|
33614
33617
|
import { mkdirSync as mkdirSync24, writeFileSync as writeFileSync43 } from "fs";
|
|
33615
33618
|
|
|
33619
|
+
// src/commands/slack/readSlackParts.ts
|
|
33620
|
+
import { readFileSync as readFileSync53 } from "fs";
|
|
33621
|
+
function readSlackParts(files) {
|
|
33622
|
+
return files.map((file) => {
|
|
33623
|
+
let contents;
|
|
33624
|
+
try {
|
|
33625
|
+
contents = readFileSync53(file, "utf8");
|
|
33626
|
+
} catch {
|
|
33627
|
+
console.error(`Error: Part file not found: ${file}`);
|
|
33628
|
+
process.exit(1);
|
|
33629
|
+
}
|
|
33630
|
+
const body = contents.trim();
|
|
33631
|
+
if (body.length === 0) {
|
|
33632
|
+
console.error(`Error: Part file is empty: ${file}`);
|
|
33633
|
+
process.exit(1);
|
|
33634
|
+
}
|
|
33635
|
+
return body;
|
|
33636
|
+
});
|
|
33637
|
+
}
|
|
33638
|
+
|
|
33616
33639
|
// src/commands/slack/reviewProposedSlackMessage.ts
|
|
33617
33640
|
import { randomUUID as randomUUID18 } from "crypto";
|
|
33618
33641
|
async function reviewProposedSlackMessage(target, body, workingPath) {
|
|
33619
33642
|
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
33620
33643
|
if (process.env.ASSIST_SESSION !== "1" || !sessionId) return;
|
|
33621
|
-
const { channel, threadTs } = target;
|
|
33644
|
+
const { channel, threadTs, part } = target;
|
|
33645
|
+
const destination = threadTs ? `Reply in ${channel} thread ${threadTs}` : `Post to ${channel}`;
|
|
33622
33646
|
await awaitPreviewApproval(
|
|
33623
|
-
"Slack message preview",
|
|
33647
|
+
part ? `Slack message ${part.index} of ${part.total}` : "Slack message preview",
|
|
33624
33648
|
{
|
|
33625
33649
|
sessionId,
|
|
33626
33650
|
requestId: randomUUID18(),
|
|
33627
|
-
title:
|
|
33651
|
+
title: part ? `${destination} (${part.index}/${part.total})` : destination,
|
|
33628
33652
|
body,
|
|
33629
33653
|
prNumber: null,
|
|
33630
33654
|
kind: "slack-post"
|
|
33631
33655
|
},
|
|
33632
33656
|
{
|
|
33633
|
-
rejectionAdvice: `Nothing was posted to ${channel}. The previewed markdown is at ${workingPath}: revise that file in place and re-run this command to preview the revision.`
|
|
33657
|
+
rejectionAdvice: part ? `Nothing was posted to ${channel} and no part of this thread was handed back. The previewed markdown for part ${part.index} of ${part.total} is at ${workingPath}: revise that file in place, then re-run the whole batch with it in place of part ${part.index} to preview again from part 1.` : `Nothing was posted to ${channel}. The previewed markdown is at ${workingPath}: revise that file in place and re-run this command to preview the revision.`
|
|
33634
33658
|
}
|
|
33635
33659
|
);
|
|
33636
33660
|
}
|
|
33637
33661
|
|
|
33638
33662
|
// src/commands/slack/slackWorkingFile.ts
|
|
33639
33663
|
import { join as join78 } from "path";
|
|
33640
|
-
function slackWorkingFile(channel) {
|
|
33664
|
+
function slackWorkingFile(channel, partIndex) {
|
|
33641
33665
|
const slug2 = channel.replace(/^[#@]/, "").toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "channel";
|
|
33642
33666
|
const dir = join78(getStoreDir(), "slack");
|
|
33643
|
-
|
|
33667
|
+
const name = partIndex === void 0 ? slug2 : `${slug2}-${partIndex}`;
|
|
33668
|
+
return { dir, bodyPath: join78(dir, `${name}.md`) };
|
|
33669
|
+
}
|
|
33670
|
+
|
|
33671
|
+
// src/commands/slack/previewSlackThreadParts.ts
|
|
33672
|
+
async function previewSlackThreadParts({
|
|
33673
|
+
channel,
|
|
33674
|
+
threadTs,
|
|
33675
|
+
target,
|
|
33676
|
+
partFiles
|
|
33677
|
+
}) {
|
|
33678
|
+
const bodies = readSlackParts(partFiles);
|
|
33679
|
+
const { dir } = slackWorkingFile(channel);
|
|
33680
|
+
mkdirSync24(dir, { recursive: true });
|
|
33681
|
+
const paths = bodies.map((body, index3) => {
|
|
33682
|
+
const { bodyPath } = slackWorkingFile(channel, index3 + 1);
|
|
33683
|
+
writeFileSync43(bodyPath, `${body}
|
|
33684
|
+
`);
|
|
33685
|
+
return bodyPath;
|
|
33686
|
+
});
|
|
33687
|
+
for (const [index3, body] of bodies.entries()) {
|
|
33688
|
+
await reviewProposedSlackMessage(
|
|
33689
|
+
{ channel, threadTs, part: { index: index3 + 1, total: bodies.length } },
|
|
33690
|
+
body,
|
|
33691
|
+
paths[index3]
|
|
33692
|
+
);
|
|
33693
|
+
}
|
|
33694
|
+
console.log(
|
|
33695
|
+
`Approved for ${target}. The ${bodies.length} bodies to post, in thread order, are at:`
|
|
33696
|
+
);
|
|
33697
|
+
paths.forEach(
|
|
33698
|
+
(path91, index3) => console.log(`${index3 + 1}/${paths.length} ${path91}`)
|
|
33699
|
+
);
|
|
33700
|
+
console.log(
|
|
33701
|
+
threadTs ? `Post every part as a reply with thread_ts ${threadTs}.` : `Post 1/${paths.length} to ${channel}, then the rest with the thread_ts it returns.`
|
|
33702
|
+
);
|
|
33644
33703
|
}
|
|
33645
33704
|
|
|
33646
33705
|
// src/commands/slack/postSlackMessage.ts
|
|
33647
|
-
var USAGE7 = "Usage: assist slack post [channel] --body <body|->";
|
|
33706
|
+
var USAGE7 = "Usage: assist slack post [channel] --body <body|-> | --parts <file>...";
|
|
33648
33707
|
async function postSlackMessage(channelArg, options2) {
|
|
33649
33708
|
const channel = (channelArg ?? loadConfig().slack?.channel ?? "").trim();
|
|
33650
33709
|
const body = options2.body?.trim();
|
|
33710
|
+
const partFiles = options2.parts ?? [];
|
|
33651
33711
|
if (!channel) {
|
|
33652
33712
|
console.error(
|
|
33653
33713
|
'No channel given and slack.channel is not set. Pass one, or set a default with: assist config set slack.channel "#general"'
|
|
@@ -33655,17 +33715,26 @@ async function postSlackMessage(channelArg, options2) {
|
|
|
33655
33715
|
console.error(USAGE7);
|
|
33656
33716
|
process.exit(1);
|
|
33657
33717
|
}
|
|
33658
|
-
if (
|
|
33718
|
+
if (body && partFiles.length > 0) {
|
|
33719
|
+
console.error("Error: --parts cannot be combined with --body.");
|
|
33659
33720
|
console.error(USAGE7);
|
|
33660
33721
|
process.exit(1);
|
|
33661
33722
|
}
|
|
33662
33723
|
const threadTs = options2.thread;
|
|
33724
|
+
const target = threadTs ? `${channel} (thread_ts ${threadTs})` : channel;
|
|
33725
|
+
if (partFiles.length > 0) {
|
|
33726
|
+
await previewSlackThreadParts({ channel, threadTs, target, partFiles });
|
|
33727
|
+
return;
|
|
33728
|
+
}
|
|
33729
|
+
if (!body) {
|
|
33730
|
+
console.error(USAGE7);
|
|
33731
|
+
process.exit(1);
|
|
33732
|
+
}
|
|
33663
33733
|
const { dir, bodyPath } = slackWorkingFile(channel);
|
|
33664
|
-
|
|
33665
|
-
|
|
33734
|
+
mkdirSync25(dir, { recursive: true });
|
|
33735
|
+
writeFileSync44(bodyPath, `${body}
|
|
33666
33736
|
`);
|
|
33667
33737
|
await reviewProposedSlackMessage({ channel, threadTs }, body, bodyPath);
|
|
33668
|
-
const target = threadTs ? `${channel} (thread_ts ${threadTs})` : channel;
|
|
33669
33738
|
console.log(`Approved for ${target}. The body to post is at:`);
|
|
33670
33739
|
console.log(bodyPath);
|
|
33671
33740
|
}
|
|
@@ -33674,14 +33743,17 @@ async function postSlackMessage(channelArg, options2) {
|
|
|
33674
33743
|
function registerSlack(program2) {
|
|
33675
33744
|
const slackCommand = program2.command("slack").description("Slack utilities");
|
|
33676
33745
|
const postCommand = slackCommand.command("post [channel]").description(
|
|
33677
|
-
"Preview a markdown message bound for a Slack channel (body of - reads it from stdin)"
|
|
33746
|
+
"Preview a markdown message, or a thread of them with --parts, bound for a Slack channel (body of - reads it from stdin)"
|
|
33678
33747
|
).option("--body <body>", "Message body (- reads it from stdin)").option(
|
|
33748
|
+
"--parts <files...>",
|
|
33749
|
+
"Files holding the messages of one thread, in thread order (not with --body)"
|
|
33750
|
+
).option(
|
|
33679
33751
|
"--thread <ts-or-permalink>",
|
|
33680
33752
|
"Reply in this thread: a message ts (1712345678.123456) or a Slack archives permalink",
|
|
33681
33753
|
parseSlackThreadRef
|
|
33682
33754
|
).addHelpText(
|
|
33683
33755
|
"after",
|
|
33684
|
-
"\nThe command does not post: Slack is reachable only over MCP, so it previews the message and hands the approved body back for /slack-post to send.\nIn an assist web session the body is previewed for approve/reject first (with inline comments). On approval the body is written to a working file under ~/.assist/slack/ and its path printed on the last line, preceded by the resolved thread_ts when --thread was given. On rejection nothing is handed back: the command exits non-zero with the reason and any inline comments, leaving the previewed markdown in the working file to revise in place.\nOutside a web session there is no preview and the body passes straight through.\nslack_send_message accepts standard markdown as it is \u2014 bold, italic, code, blockquotes, lists, links, code blocks, tables and headers \u2014 capped at 5000 characters."
|
|
33756
|
+
"\nThe command does not post: Slack is reachable only over MCP, so it previews the message and hands the approved body back for /slack-post to send.\nIn an assist web session the body is previewed for approve/reject first (with inline comments). On approval the body is written to a working file under ~/.assist/slack/ and its path printed on the last line, preceded by the resolved thread_ts when --thread was given. On rejection nothing is handed back: the command exits non-zero with the reason and any inline comments, leaving the previewed markdown in the working file to revise in place.\n--parts takes the files holding one thread's messages in thread order, each getting its own working file (channel-1.md, channel-2.md, \u2026) and its own preview pane titled with its position in the batch (2/3). The panes pop in sequence and no path is printed until every part is approved, at which point each path prints prefixed with its position (1/3) under a line naming the target, followed by how to thread them: without --thread part 1 opens the thread and the rest carry the thread_ts it returns, with --thread every part is a reply under the resolved thread_ts. The first rejection halts the batch and exits non-zero naming that part's position, reason, inline comments and working file, with no path handed back. A missing or empty part file, or --parts with --body, is an error before any pane opens.\nOutside a web session there is no preview and the body passes straight through.\nslack_send_message accepts standard markdown as it is \u2014 bold, italic, code, blockquotes, lists, links, code blocks, tables and headers \u2014 capped at 5000 characters."
|
|
33685
33757
|
).action(
|
|
33686
33758
|
async (channel, options2) => {
|
|
33687
33759
|
await postSlackMessage(channel, {
|
|
@@ -34626,9 +34698,9 @@ function formatVttPassages(passages, notes = [], { sourceMarks = true } = {}) {
|
|
|
34626
34698
|
}
|
|
34627
34699
|
|
|
34628
34700
|
// src/commands/transcript/convert/readCleanedCues.ts
|
|
34629
|
-
import { readFileSync as
|
|
34701
|
+
import { readFileSync as readFileSync57 } from "fs";
|
|
34630
34702
|
function readCleanedCues(inputPath) {
|
|
34631
|
-
return deduplicateCues(parseVtt(
|
|
34703
|
+
return deduplicateCues(parseVtt(readFileSync57(inputPath, "utf8")));
|
|
34632
34704
|
}
|
|
34633
34705
|
|
|
34634
34706
|
// src/commands/transcript/clean.ts
|
|
@@ -34750,7 +34822,7 @@ function list4() {
|
|
|
34750
34822
|
}
|
|
34751
34823
|
|
|
34752
34824
|
// src/commands/transcript/move.ts
|
|
34753
|
-
import { existsSync as existsSync75, mkdirSync as
|
|
34825
|
+
import { existsSync as existsSync75, mkdirSync as mkdirSync31, renameSync as renameSync2, writeFileSync as writeFileSync48 } from "fs";
|
|
34754
34826
|
import { basename as basename23, join as join90 } from "path";
|
|
34755
34827
|
|
|
34756
34828
|
// src/commands/transcript/convertVttToMarkdown.ts
|
|
@@ -34762,7 +34834,7 @@ function convertVttToMarkdown(inputPath) {
|
|
|
34762
34834
|
var DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
|
|
34763
34835
|
function archiveRawVtt(vttDir, sourcePath, filename) {
|
|
34764
34836
|
const processedDir = join90(vttDir, "processed");
|
|
34765
|
-
|
|
34837
|
+
mkdirSync31(processedDir, { recursive: true });
|
|
34766
34838
|
renameSync2(sourcePath, join90(processedDir, filename));
|
|
34767
34839
|
}
|
|
34768
34840
|
function move(file, options2) {
|
|
@@ -34781,9 +34853,9 @@ function move(file, options2) {
|
|
|
34781
34853
|
const base = basename23(filename, ".vtt").replace(/ Transcription$/, "");
|
|
34782
34854
|
const outputName = `${date} ${base}.md`;
|
|
34783
34855
|
const formattedDir = join90(transcriptsDir, client);
|
|
34784
|
-
|
|
34856
|
+
mkdirSync31(formattedDir, { recursive: true });
|
|
34785
34857
|
const formattedPath = join90(formattedDir, outputName);
|
|
34786
|
-
|
|
34858
|
+
writeFileSync48(formattedPath, convertVttToMarkdown(sourcePath), "utf8");
|
|
34787
34859
|
archiveRawVtt(vttDir, sourcePath, filename);
|
|
34788
34860
|
const summaryPath = join90(summaryDir, client, outputName);
|
|
34789
34861
|
console.log(`Formatted transcript: ${formattedPath}`);
|
|
@@ -34791,7 +34863,7 @@ function move(file, options2) {
|
|
|
34791
34863
|
}
|
|
34792
34864
|
|
|
34793
34865
|
// src/commands/transcript/merge.ts
|
|
34794
|
-
import { existsSync as existsSync76, writeFileSync as
|
|
34866
|
+
import { existsSync as existsSync76, writeFileSync as writeFileSync49 } from "fs";
|
|
34795
34867
|
import { basename as basename24 } from "path";
|
|
34796
34868
|
|
|
34797
34869
|
// src/commands/transcript/failTranscript.ts
|
|
@@ -34968,7 +35040,7 @@ async function merge(files, options2 = {}) {
|
|
|
34968
35040
|
console.log(document);
|
|
34969
35041
|
return;
|
|
34970
35042
|
}
|
|
34971
|
-
|
|
35043
|
+
writeFileSync49(options2.out, `${document}
|
|
34972
35044
|
`, "utf8");
|
|
34973
35045
|
console.log(`Merged transcript: ${options2.out}`);
|
|
34974
35046
|
}
|
|
@@ -35140,14 +35212,14 @@ function devices() {
|
|
|
35140
35212
|
}
|
|
35141
35213
|
|
|
35142
35214
|
// src/commands/voice/logs.ts
|
|
35143
|
-
import { existsSync as existsSync77, readFileSync as
|
|
35215
|
+
import { existsSync as existsSync77, readFileSync as readFileSync58 } from "fs";
|
|
35144
35216
|
function logs(options2) {
|
|
35145
35217
|
if (!existsSync77(voicePaths.log)) {
|
|
35146
35218
|
console.log("No voice log file found");
|
|
35147
35219
|
return;
|
|
35148
35220
|
}
|
|
35149
35221
|
const count8 = Number.parseInt(options2.lines ?? "150", 10);
|
|
35150
|
-
const content =
|
|
35222
|
+
const content = readFileSync58(voicePaths.log, "utf8").trim();
|
|
35151
35223
|
if (!content) {
|
|
35152
35224
|
console.log("Voice log is empty");
|
|
35153
35225
|
return;
|
|
@@ -35169,12 +35241,12 @@ function logs(options2) {
|
|
|
35169
35241
|
|
|
35170
35242
|
// src/commands/voice/setup.ts
|
|
35171
35243
|
import { spawnSync as spawnSync10 } from "child_process";
|
|
35172
|
-
import { mkdirSync as
|
|
35244
|
+
import { mkdirSync as mkdirSync33 } from "fs";
|
|
35173
35245
|
import { join as join94 } from "path";
|
|
35174
35246
|
|
|
35175
35247
|
// src/commands/voice/checkLockFile.ts
|
|
35176
35248
|
import { execSync as execSync63 } from "child_process";
|
|
35177
|
-
import { existsSync as existsSync78, mkdirSync as
|
|
35249
|
+
import { existsSync as existsSync78, mkdirSync as mkdirSync32, readFileSync as readFileSync59, writeFileSync as writeFileSync50 } from "fs";
|
|
35178
35250
|
import { join as join93 } from "path";
|
|
35179
35251
|
function isProcessAlive2(pid) {
|
|
35180
35252
|
try {
|
|
@@ -35188,7 +35260,7 @@ function checkLockFile() {
|
|
|
35188
35260
|
const lockFile = getLockFile();
|
|
35189
35261
|
if (!existsSync78(lockFile)) return;
|
|
35190
35262
|
try {
|
|
35191
|
-
const lock2 = JSON.parse(
|
|
35263
|
+
const lock2 = JSON.parse(readFileSync59(lockFile, "utf8"));
|
|
35192
35264
|
if (lock2.pid && isProcessAlive2(lock2.pid)) {
|
|
35193
35265
|
console.error(
|
|
35194
35266
|
`Voice daemon already running (PID ${lock2.pid}, env: ${lock2.env}). Stop it first with: assist voice stop`
|
|
@@ -35212,8 +35284,8 @@ function bootstrapVenv() {
|
|
|
35212
35284
|
}
|
|
35213
35285
|
function writeLockFile(pid) {
|
|
35214
35286
|
const lockFile = getLockFile();
|
|
35215
|
-
|
|
35216
|
-
|
|
35287
|
+
mkdirSync32(join93(lockFile, ".."), { recursive: true });
|
|
35288
|
+
writeFileSync50(
|
|
35217
35289
|
lockFile,
|
|
35218
35290
|
JSON.stringify({
|
|
35219
35291
|
pid,
|
|
@@ -35225,7 +35297,7 @@ function writeLockFile(pid) {
|
|
|
35225
35297
|
|
|
35226
35298
|
// src/commands/voice/setup.ts
|
|
35227
35299
|
function setup() {
|
|
35228
|
-
|
|
35300
|
+
mkdirSync33(voicePaths.dir, { recursive: true });
|
|
35229
35301
|
bootstrapVenv();
|
|
35230
35302
|
console.log("\nDownloading models...\n");
|
|
35231
35303
|
const script = join94(getPythonDir(), "setup_models.py");
|
|
@@ -35241,7 +35313,7 @@ function setup() {
|
|
|
35241
35313
|
|
|
35242
35314
|
// src/commands/voice/start.ts
|
|
35243
35315
|
import { spawn as spawn8 } from "child_process";
|
|
35244
|
-
import { mkdirSync as
|
|
35316
|
+
import { mkdirSync as mkdirSync34, writeFileSync as writeFileSync51 } from "fs";
|
|
35245
35317
|
import { join as join95 } from "path";
|
|
35246
35318
|
|
|
35247
35319
|
// src/commands/voice/buildDaemonEnv.ts
|
|
@@ -35270,12 +35342,12 @@ function spawnBackground(python, script, env) {
|
|
|
35270
35342
|
console.error("Failed to start voice daemon");
|
|
35271
35343
|
process.exit(1);
|
|
35272
35344
|
}
|
|
35273
|
-
|
|
35345
|
+
writeFileSync51(voicePaths.pid, String(pid));
|
|
35274
35346
|
writeLockFile(pid);
|
|
35275
35347
|
console.log(`Voice daemon started (PID ${pid})`);
|
|
35276
35348
|
}
|
|
35277
35349
|
function start2(options2) {
|
|
35278
|
-
|
|
35350
|
+
mkdirSync34(voicePaths.dir, { recursive: true });
|
|
35279
35351
|
checkLockFile();
|
|
35280
35352
|
bootstrapVenv();
|
|
35281
35353
|
const debug = options2.debug || options2.foreground || process.platform === "win32";
|
|
@@ -35290,7 +35362,7 @@ function start2(options2) {
|
|
|
35290
35362
|
}
|
|
35291
35363
|
|
|
35292
35364
|
// src/commands/voice/status.ts
|
|
35293
|
-
import { existsSync as existsSync79, readFileSync as
|
|
35365
|
+
import { existsSync as existsSync79, readFileSync as readFileSync60 } from "fs";
|
|
35294
35366
|
function isProcessAlive3(pid) {
|
|
35295
35367
|
try {
|
|
35296
35368
|
process.kill(pid, 0);
|
|
@@ -35301,7 +35373,7 @@ function isProcessAlive3(pid) {
|
|
|
35301
35373
|
}
|
|
35302
35374
|
function readRecentLogs(count8) {
|
|
35303
35375
|
if (!existsSync79(voicePaths.log)) return [];
|
|
35304
|
-
const lines2 =
|
|
35376
|
+
const lines2 = readFileSync60(voicePaths.log, "utf8").trim().split("\n");
|
|
35305
35377
|
return lines2.slice(-count8);
|
|
35306
35378
|
}
|
|
35307
35379
|
function status2() {
|
|
@@ -35309,7 +35381,7 @@ function status2() {
|
|
|
35309
35381
|
console.log("Voice daemon: not running (no PID file)");
|
|
35310
35382
|
return;
|
|
35311
35383
|
}
|
|
35312
|
-
const pid = Number.parseInt(
|
|
35384
|
+
const pid = Number.parseInt(readFileSync60(voicePaths.pid, "utf8").trim(), 10);
|
|
35313
35385
|
const alive = isProcessAlive3(pid);
|
|
35314
35386
|
console.log(`Voice daemon: ${alive ? "running" : "dead"} (PID ${pid})`);
|
|
35315
35387
|
const recent = readRecentLogs(5);
|
|
@@ -35328,13 +35400,13 @@ function status2() {
|
|
|
35328
35400
|
}
|
|
35329
35401
|
|
|
35330
35402
|
// src/commands/voice/stop.ts
|
|
35331
|
-
import { existsSync as existsSync80, readFileSync as
|
|
35403
|
+
import { existsSync as existsSync80, readFileSync as readFileSync61, unlinkSync as unlinkSync20 } from "fs";
|
|
35332
35404
|
function stop2() {
|
|
35333
35405
|
if (!existsSync80(voicePaths.pid)) {
|
|
35334
35406
|
console.log("Voice daemon is not running (no PID file)");
|
|
35335
35407
|
return;
|
|
35336
35408
|
}
|
|
35337
|
-
const pid = Number.parseInt(
|
|
35409
|
+
const pid = Number.parseInt(readFileSync61(voicePaths.pid, "utf8").trim(), 10);
|
|
35338
35410
|
try {
|
|
35339
35411
|
process.kill(pid, "SIGTERM");
|
|
35340
35412
|
console.log(`Sent SIGTERM to voice daemon (PID ${pid})`);
|
|
@@ -36205,7 +36277,7 @@ async function auth() {
|
|
|
36205
36277
|
|
|
36206
36278
|
// src/commands/roam/postRoamActivity.ts
|
|
36207
36279
|
import { execFileSync as execFileSync21 } from "child_process";
|
|
36208
|
-
import { readdirSync as readdirSync22, readFileSync as
|
|
36280
|
+
import { readdirSync as readdirSync22, readFileSync as readFileSync62, statSync as statSync12 } from "fs";
|
|
36209
36281
|
import { join as join98 } from "path";
|
|
36210
36282
|
function findPortFile(roamDir) {
|
|
36211
36283
|
let entries;
|
|
@@ -36236,7 +36308,7 @@ function postRoamActivity(app, event) {
|
|
|
36236
36308
|
if (!portFile) return;
|
|
36237
36309
|
let port;
|
|
36238
36310
|
try {
|
|
36239
|
-
port =
|
|
36311
|
+
port = readFileSync62(portFile, "utf8").trim();
|
|
36240
36312
|
} catch {
|
|
36241
36313
|
return;
|
|
36242
36314
|
}
|
|
@@ -36367,7 +36439,7 @@ async function run3(name, args) {
|
|
|
36367
36439
|
}
|
|
36368
36440
|
|
|
36369
36441
|
// src/commands/run/add.ts
|
|
36370
|
-
import { mkdirSync as
|
|
36442
|
+
import { mkdirSync as mkdirSync35, writeFileSync as writeFileSync52 } from "fs";
|
|
36371
36443
|
import { join as join99 } from "path";
|
|
36372
36444
|
|
|
36373
36445
|
// src/commands/run/extractOption.ts
|
|
@@ -36430,7 +36502,7 @@ function saveNewRunConfig(name, command, args, cwd) {
|
|
|
36430
36502
|
}
|
|
36431
36503
|
function createCommandFile(name) {
|
|
36432
36504
|
const dir = join99(".claude", "commands");
|
|
36433
|
-
|
|
36505
|
+
mkdirSync35(dir, { recursive: true });
|
|
36434
36506
|
const content = `---
|
|
36435
36507
|
description: Run ${name}
|
|
36436
36508
|
---
|
|
@@ -36438,7 +36510,7 @@ description: Run ${name}
|
|
|
36438
36510
|
Run \`assist run ${name} $ARGUMENTS 2>&1\`.
|
|
36439
36511
|
`;
|
|
36440
36512
|
const filePath = join99(dir, `${name}.md`);
|
|
36441
|
-
|
|
36513
|
+
writeFileSync52(filePath, content);
|
|
36442
36514
|
console.log(`Created command file: ${filePath}`);
|
|
36443
36515
|
}
|
|
36444
36516
|
function add3() {
|
|
@@ -36555,7 +36627,7 @@ function registerRun(program2) {
|
|
|
36555
36627
|
|
|
36556
36628
|
// src/commands/screenshot/index.ts
|
|
36557
36629
|
import { execSync as execSync65 } from "child_process";
|
|
36558
|
-
import { existsSync as existsSync85, mkdirSync as
|
|
36630
|
+
import { existsSync as existsSync85, mkdirSync as mkdirSync36, unlinkSync as unlinkSync22, writeFileSync as writeFileSync53 } from "fs";
|
|
36559
36631
|
import { tmpdir as tmpdir9 } from "os";
|
|
36560
36632
|
import { join as join101, resolve as resolve21 } from "path";
|
|
36561
36633
|
import chalk233 from "chalk";
|
|
@@ -36688,14 +36760,14 @@ Write-Output $OutputPath
|
|
|
36688
36760
|
// src/commands/screenshot/index.ts
|
|
36689
36761
|
function buildOutputPath(outputDir, processName) {
|
|
36690
36762
|
if (!existsSync85(outputDir)) {
|
|
36691
|
-
|
|
36763
|
+
mkdirSync36(outputDir, { recursive: true });
|
|
36692
36764
|
}
|
|
36693
36765
|
const timestamp6 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
36694
36766
|
return resolve21(outputDir, `${processName}-${timestamp6}.png`);
|
|
36695
36767
|
}
|
|
36696
36768
|
function runPowerShellScript(processName, outputPath) {
|
|
36697
36769
|
const scriptPath = join101(tmpdir9(), `assist-screenshot-${Date.now()}.ps1`);
|
|
36698
|
-
|
|
36770
|
+
writeFileSync53(scriptPath, captureWindowPs1, "utf8");
|
|
36699
36771
|
try {
|
|
36700
36772
|
execSync65(
|
|
36701
36773
|
`powershell -NoProfile -ExecutionPolicy Bypass -File "${scriptPath}" -ProcessName "${processName}" -OutputPath "${outputPath}"`,
|
|
@@ -36771,11 +36843,11 @@ function applyLine(result, pending, line) {
|
|
|
36771
36843
|
}
|
|
36772
36844
|
|
|
36773
36845
|
// src/commands/sessions/daemon/readDaemonPidFile.ts
|
|
36774
|
-
import { readFileSync as
|
|
36846
|
+
import { readFileSync as readFileSync63 } from "fs";
|
|
36775
36847
|
function readDaemonPidFile() {
|
|
36776
36848
|
try {
|
|
36777
36849
|
const pid = Number.parseInt(
|
|
36778
|
-
|
|
36850
|
+
readFileSync63(daemonPaths.pid, "utf8").trim(),
|
|
36779
36851
|
10
|
|
36780
36852
|
);
|
|
36781
36853
|
return Number.isInteger(pid) ? pid : void 0;
|
|
@@ -36928,7 +37000,7 @@ function requestDrain(socket, lines2) {
|
|
|
36928
37000
|
}
|
|
36929
37001
|
|
|
36930
37002
|
// src/commands/sessions/daemon/runDaemon.ts
|
|
36931
|
-
import { mkdirSync as
|
|
37003
|
+
import { mkdirSync as mkdirSync40 } from "fs";
|
|
36932
37004
|
|
|
36933
37005
|
// src/commands/sessions/daemon/createAutoExit.ts
|
|
36934
37006
|
var DEFAULT_GRACE_MS = 6e4;
|
|
@@ -38280,7 +38352,7 @@ function handleFailedResume(session, exitCode, onStatusChange) {
|
|
|
38280
38352
|
}
|
|
38281
38353
|
|
|
38282
38354
|
// src/commands/sessions/daemon/watchActivity.ts
|
|
38283
|
-
import { existsSync as existsSync93, mkdirSync as
|
|
38355
|
+
import { existsSync as existsSync93, mkdirSync as mkdirSync37, watch as watch2 } from "fs";
|
|
38284
38356
|
import { dirname as dirname41 } from "path";
|
|
38285
38357
|
|
|
38286
38358
|
// src/commands/sessions/daemon/applyActivityToSession.ts
|
|
@@ -38345,7 +38417,7 @@ function watchActivity(session, notify2, onClaudeSessionId) {
|
|
|
38345
38417
|
const path91 = activityPath(session.id);
|
|
38346
38418
|
const dir = dirname41(path91);
|
|
38347
38419
|
try {
|
|
38348
|
-
|
|
38420
|
+
mkdirSync37(dir, { recursive: true });
|
|
38349
38421
|
} catch {
|
|
38350
38422
|
return;
|
|
38351
38423
|
}
|
|
@@ -38548,10 +38620,10 @@ function headContainsSessionId(filePath, claudeSessionId) {
|
|
|
38548
38620
|
}
|
|
38549
38621
|
|
|
38550
38622
|
// src/commands/sessions/daemon/ensureProjectDirExists.ts
|
|
38551
|
-
import { mkdirSync as
|
|
38623
|
+
import { mkdirSync as mkdirSync38 } from "fs";
|
|
38552
38624
|
function ensureProjectDirExists(dir, sessionId) {
|
|
38553
38625
|
try {
|
|
38554
|
-
|
|
38626
|
+
mkdirSync38(dir, { recursive: true });
|
|
38555
38627
|
return true;
|
|
38556
38628
|
} catch (error) {
|
|
38557
38629
|
daemonLog(
|
|
@@ -40956,14 +41028,14 @@ async function defaultConnect() {
|
|
|
40956
41028
|
}
|
|
40957
41029
|
|
|
40958
41030
|
// src/commands/sessions/daemon/hasPersistedWindowsSessions.ts
|
|
40959
|
-
import { existsSync as existsSync97, readFileSync as
|
|
41031
|
+
import { existsSync as existsSync97, readFileSync as readFileSync65 } from "fs";
|
|
40960
41032
|
import { posix as posix3 } from "path";
|
|
40961
41033
|
function hasPersistedWindowsSessions() {
|
|
40962
41034
|
const sessionsFile = windowsSessionsFileFromWsl();
|
|
40963
41035
|
if (!sessionsFile) return false;
|
|
40964
41036
|
try {
|
|
40965
41037
|
if (!existsSync97(sessionsFile)) return false;
|
|
40966
|
-
const data = JSON.parse(
|
|
41038
|
+
const data = JSON.parse(readFileSync65(sessionsFile, "utf8"));
|
|
40967
41039
|
return Array.isArray(data) && data.length > 0;
|
|
40968
41040
|
} catch (error) {
|
|
40969
41041
|
const message3 = error instanceof Error ? error.message : String(error);
|
|
@@ -41731,7 +41803,7 @@ function resumeSession(id, sessionId, cwd, name, holdPty, harness) {
|
|
|
41731
41803
|
import { existsSync as existsSync99 } from "fs";
|
|
41732
41804
|
|
|
41733
41805
|
// src/commands/sessions/daemon/worktree/carryTranscriptToTree.ts
|
|
41734
|
-
import { copyFileSync as copyFileSync5, existsSync as existsSync98, mkdirSync as
|
|
41806
|
+
import { copyFileSync as copyFileSync5, existsSync as existsSync98, mkdirSync as mkdirSync39 } from "fs";
|
|
41735
41807
|
import { join as join106 } from "path";
|
|
41736
41808
|
function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
41737
41809
|
const dir = projectDirForCwd(toCwd);
|
|
@@ -41754,7 +41826,7 @@ function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
|
41754
41826
|
return;
|
|
41755
41827
|
}
|
|
41756
41828
|
try {
|
|
41757
|
-
|
|
41829
|
+
mkdirSync39(dir, { recursive: true });
|
|
41758
41830
|
copyFileSync5(source, dest);
|
|
41759
41831
|
daemonLog(
|
|
41760
41832
|
`transcript ${source} copied to ${dest} so ${toCwd} can resume it`
|
|
@@ -42385,10 +42457,10 @@ function handleConnection(socket, manager) {
|
|
|
42385
42457
|
}
|
|
42386
42458
|
|
|
42387
42459
|
// src/commands/sessions/daemon/onListening.ts
|
|
42388
|
-
import { unlinkSync as unlinkSync23, writeFileSync as
|
|
42460
|
+
import { unlinkSync as unlinkSync23, writeFileSync as writeFileSync54 } from "fs";
|
|
42389
42461
|
|
|
42390
42462
|
// src/commands/sessions/daemon/startPidFileWatchdog.ts
|
|
42391
|
-
import { readFileSync as
|
|
42463
|
+
import { readFileSync as readFileSync66 } from "fs";
|
|
42392
42464
|
var WATCHDOG_INTERVAL_MS = 5e3;
|
|
42393
42465
|
function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
|
|
42394
42466
|
const timer = setInterval(() => {
|
|
@@ -42399,7 +42471,7 @@ function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
|
|
|
42399
42471
|
}
|
|
42400
42472
|
function ownsPidFile() {
|
|
42401
42473
|
try {
|
|
42402
|
-
return
|
|
42474
|
+
return readFileSync66(daemonPaths.pid, "utf8").trim() === String(process.pid);
|
|
42403
42475
|
} catch {
|
|
42404
42476
|
return false;
|
|
42405
42477
|
}
|
|
@@ -42407,7 +42479,7 @@ function ownsPidFile() {
|
|
|
42407
42479
|
|
|
42408
42480
|
// src/commands/sessions/daemon/onListening.ts
|
|
42409
42481
|
function onListening(manager, checkAutoExit) {
|
|
42410
|
-
|
|
42482
|
+
writeFileSync54(daemonPaths.pid, String(process.pid));
|
|
42411
42483
|
startPidFileWatchdog(() => {
|
|
42412
42484
|
daemonLog("lost daemon.pid ownership; shutting down sessions and exiting");
|
|
42413
42485
|
void manager.flushActiveMs().finally(() => {
|
|
@@ -42594,7 +42666,7 @@ async function recoverFromAddrInUse(server, manager, checkAutoExit) {
|
|
|
42594
42666
|
|
|
42595
42667
|
// src/commands/sessions/daemon/runDaemon.ts
|
|
42596
42668
|
async function runDaemon() {
|
|
42597
|
-
|
|
42669
|
+
mkdirSync40(daemonPaths.dir, { recursive: true });
|
|
42598
42670
|
daemonLog(
|
|
42599
42671
|
`starting (reason: ${process.env.ASSIST_DAEMON_SPAWN_REASON ?? "manual"})`
|
|
42600
42672
|
);
|
|
@@ -42892,7 +42964,7 @@ function buildLimitsSegment(rateLimits) {
|
|
|
42892
42964
|
}
|
|
42893
42965
|
|
|
42894
42966
|
// src/commands/readGitBranch.ts
|
|
42895
|
-
import { readFileSync as
|
|
42967
|
+
import { readFileSync as readFileSync68, statSync as statSync16 } from "fs";
|
|
42896
42968
|
import { isAbsolute as isAbsolute5, join as join107, resolve as resolve23 } from "path";
|
|
42897
42969
|
function resolveGitDir(cwd) {
|
|
42898
42970
|
const dotGit = join107(cwd, ".git");
|
|
@@ -42907,7 +42979,7 @@ function resolveGitDir(cwd) {
|
|
|
42907
42979
|
}
|
|
42908
42980
|
let contents;
|
|
42909
42981
|
try {
|
|
42910
|
-
contents =
|
|
42982
|
+
contents = readFileSync68(dotGit, "utf8");
|
|
42911
42983
|
} catch {
|
|
42912
42984
|
return null;
|
|
42913
42985
|
}
|
|
@@ -42925,7 +42997,7 @@ function readGitBranch(cwd) {
|
|
|
42925
42997
|
}
|
|
42926
42998
|
let head;
|
|
42927
42999
|
try {
|
|
42928
|
-
head =
|
|
43000
|
+
head = readFileSync68(join107(gitDir, "HEAD"), "utf8");
|
|
42929
43001
|
} catch {
|
|
42930
43002
|
return null;
|
|
42931
43003
|
}
|