@staff0rd/assist 0.668.0 → 0.670.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 +4 -2
- package/dist/commands/sessions/web/bundle.js +1 -1
- package/dist/index.js +313 -103
- 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.670.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -651,7 +651,7 @@ var DEFAULT_BACKUP_DIR = "~/.assist/backups";
|
|
|
651
651
|
var DEFAULT_CLONE_DIR = "~/git";
|
|
652
652
|
var assistConfigShape = {
|
|
653
653
|
advice: z3.strictObject({
|
|
654
|
-
|
|
654
|
+
sections: z3.partialRecord(z3.enum(adviceFragmentNames), z3.boolean()).default({}),
|
|
655
655
|
extra: z3.string().optional(),
|
|
656
656
|
verify: z3.string().optional()
|
|
657
657
|
}).optional(),
|
|
@@ -2869,7 +2869,7 @@ function configHelp(command, entries, preamble) {
|
|
|
2869
2869
|
|
|
2870
2870
|
// src/shared/configEnumDescriptions.ts
|
|
2871
2871
|
var byKey = {
|
|
2872
|
-
"advice.
|
|
2872
|
+
"advice.sections": adviceFragmentTitles
|
|
2873
2873
|
};
|
|
2874
2874
|
function configEnumDescriptions(key) {
|
|
2875
2875
|
return byKey[key];
|
|
@@ -3112,9 +3112,9 @@ function enumerateConfigLeafKeys(schema2) {
|
|
|
3112
3112
|
// src/commands/advise/adviceConfigHelp.ts
|
|
3113
3113
|
var adviceConfigHelp = [
|
|
3114
3114
|
{
|
|
3115
|
-
key: "advice.
|
|
3116
|
-
setter: "assist config set advice.
|
|
3117
|
-
note: "force a
|
|
3115
|
+
key: "advice.sections",
|
|
3116
|
+
setter: "assist config set advice.sections.verify false",
|
|
3117
|
+
note: "force a section on (true) or off (false) whatever its condition says; 'assist advise --explain' lists every name"
|
|
3118
3118
|
},
|
|
3119
3119
|
{
|
|
3120
3120
|
key: "advice.extra",
|
|
@@ -5375,13 +5375,13 @@ var adviceConditions = {
|
|
|
5375
5375
|
|
|
5376
5376
|
// src/commands/advise/selectAdvice.ts
|
|
5377
5377
|
function decide(fragment, context) {
|
|
5378
|
-
const
|
|
5379
|
-
const override =
|
|
5378
|
+
const sections = context.config.advice?.sections ?? {};
|
|
5379
|
+
const override = sections[fragment.name];
|
|
5380
5380
|
if (override !== void 0)
|
|
5381
5381
|
return {
|
|
5382
5382
|
fragment,
|
|
5383
5383
|
included: override,
|
|
5384
|
-
reason: `advice.
|
|
5384
|
+
reason: `advice.sections.${fragment.name} is ${override}`
|
|
5385
5385
|
};
|
|
5386
5386
|
const condition = adviceConditions[fragment.when];
|
|
5387
5387
|
if (!condition)
|
|
@@ -23654,6 +23654,148 @@ function registerEditIssueComment(issueCommand) {
|
|
|
23654
23654
|
);
|
|
23655
23655
|
}
|
|
23656
23656
|
|
|
23657
|
+
// src/commands/github/issue/assignIssueToSelf.ts
|
|
23658
|
+
import { execFileSync as execFileSync12 } from "child_process";
|
|
23659
|
+
function assignIssueToSelf(number, repo) {
|
|
23660
|
+
const args = [
|
|
23661
|
+
"issue",
|
|
23662
|
+
"edit",
|
|
23663
|
+
String(number),
|
|
23664
|
+
"--repo",
|
|
23665
|
+
repo,
|
|
23666
|
+
"--add-assignee",
|
|
23667
|
+
"@me"
|
|
23668
|
+
];
|
|
23669
|
+
try {
|
|
23670
|
+
execFileSync12("gh", args, { stdio: ["ignore", "ignore", "inherit"] });
|
|
23671
|
+
} catch {
|
|
23672
|
+
process.exit(1);
|
|
23673
|
+
}
|
|
23674
|
+
}
|
|
23675
|
+
|
|
23676
|
+
// src/commands/github/issue/toIssueProjectItem.ts
|
|
23677
|
+
function toIssueProjectItem(node) {
|
|
23678
|
+
const project = node?.project;
|
|
23679
|
+
if (!node?.id || !project?.id) return void 0;
|
|
23680
|
+
return {
|
|
23681
|
+
itemId: node.id,
|
|
23682
|
+
projectId: project.id,
|
|
23683
|
+
projectNumber: project.number ?? 0,
|
|
23684
|
+
projectTitle: project.title ?? String(project.number ?? ""),
|
|
23685
|
+
statusField: project.field?.id ? { id: project.field.id, options: project.field.options ?? [] } : void 0
|
|
23686
|
+
};
|
|
23687
|
+
}
|
|
23688
|
+
|
|
23689
|
+
// src/commands/github/issue/parseIssueProjectItems.ts
|
|
23690
|
+
function parseIssueProjectItems(raw, label2) {
|
|
23691
|
+
const issue = JSON.parse(raw).data?.repository?.issue;
|
|
23692
|
+
if (!issue?.id) throw new Error(`No issue ${label2} could be read`);
|
|
23693
|
+
const items2 = (issue.projectItems?.nodes ?? []).map(toIssueProjectItem).filter((item) => item !== void 0);
|
|
23694
|
+
return { issueId: issue.id, items: items2 };
|
|
23695
|
+
}
|
|
23696
|
+
|
|
23697
|
+
// src/commands/github/issue/fetchIssueProjectItems.ts
|
|
23698
|
+
var QUERY6 = `query($owner: String!, $repo: String!, $number: Int!) {
|
|
23699
|
+
repository(owner: $owner, name: $repo) {
|
|
23700
|
+
issue(number: $number) {
|
|
23701
|
+
id
|
|
23702
|
+
projectItems(first: 20) {
|
|
23703
|
+
nodes {
|
|
23704
|
+
id
|
|
23705
|
+
project {
|
|
23706
|
+
id
|
|
23707
|
+
number
|
|
23708
|
+
title
|
|
23709
|
+
field(name: "Status") {
|
|
23710
|
+
... on ProjectV2SingleSelectField { id options { id name } }
|
|
23711
|
+
}
|
|
23712
|
+
}
|
|
23713
|
+
}
|
|
23714
|
+
}
|
|
23715
|
+
}
|
|
23716
|
+
}
|
|
23717
|
+
}`;
|
|
23718
|
+
function fetchIssueProjectItems(target) {
|
|
23719
|
+
return parseIssueProjectItems(
|
|
23720
|
+
runGhGraphqlJson(QUERY6, target),
|
|
23721
|
+
`${target.owner}/${target.repo}#${target.number}`
|
|
23722
|
+
);
|
|
23723
|
+
}
|
|
23724
|
+
|
|
23725
|
+
// src/commands/github/issue/moveIssueToInProgress.ts
|
|
23726
|
+
var IN_PROGRESS = "in progress";
|
|
23727
|
+
function boardName(item) {
|
|
23728
|
+
return `project ${item.projectNumber} (${item.projectTitle})`;
|
|
23729
|
+
}
|
|
23730
|
+
function moveItem(item) {
|
|
23731
|
+
const statusField = item.statusField;
|
|
23732
|
+
if (!statusField) {
|
|
23733
|
+
console.log(`${boardName(item)} has no Status field, so it was not moved`);
|
|
23734
|
+
return;
|
|
23735
|
+
}
|
|
23736
|
+
const option = statusField.options.find(
|
|
23737
|
+
(candidate) => candidate.name.toLowerCase() === IN_PROGRESS
|
|
23738
|
+
);
|
|
23739
|
+
if (!option) {
|
|
23740
|
+
const names = statusField.options.map((candidate) => candidate.name);
|
|
23741
|
+
console.log(
|
|
23742
|
+
`The Status field on ${boardName(item)} has no In Progress option, so it was not moved. It offers ${names.join(", ") || "no options"}`
|
|
23743
|
+
);
|
|
23744
|
+
return;
|
|
23745
|
+
}
|
|
23746
|
+
setProjectItemStatus({
|
|
23747
|
+
projectId: item.projectId,
|
|
23748
|
+
itemId: item.itemId,
|
|
23749
|
+
fieldId: statusField.id,
|
|
23750
|
+
optionId: option.id
|
|
23751
|
+
});
|
|
23752
|
+
console.log(`Set ${boardName(item)} to ${option.name}`);
|
|
23753
|
+
}
|
|
23754
|
+
function moveIssueToInProgress(target) {
|
|
23755
|
+
try {
|
|
23756
|
+
assertProjectScope();
|
|
23757
|
+
} catch (error) {
|
|
23758
|
+
console.log(error instanceof Error ? error.message : String(error));
|
|
23759
|
+
return;
|
|
23760
|
+
}
|
|
23761
|
+
const { items: items2 } = fetchIssueProjectItems(target);
|
|
23762
|
+
if (items2.length === 0) {
|
|
23763
|
+
console.log(
|
|
23764
|
+
`${target.owner}/${target.repo}#${target.number} is on no project board, so there was nothing to move`
|
|
23765
|
+
);
|
|
23766
|
+
return;
|
|
23767
|
+
}
|
|
23768
|
+
for (const item of items2) moveItem(item);
|
|
23769
|
+
}
|
|
23770
|
+
|
|
23771
|
+
// src/commands/github/issue/startIssue.ts
|
|
23772
|
+
var USAGE5 = "Usage: assist github issue started <number> [-R <owner>/<repo>]";
|
|
23773
|
+
function startIssue(numberArg, options2) {
|
|
23774
|
+
const number = Number.parseInt(numberArg, 10);
|
|
23775
|
+
if (!Number.isInteger(number) || number <= 0) {
|
|
23776
|
+
console.error(USAGE5);
|
|
23777
|
+
process.exit(1);
|
|
23778
|
+
}
|
|
23779
|
+
const { owner, repo } = resolveIssueRepoTarget(options2.repo);
|
|
23780
|
+
const slug2 = `${owner}/${repo}`;
|
|
23781
|
+
assignIssueToSelf(number, slug2);
|
|
23782
|
+
console.log(`Assigned ${slug2}#${number} to you`);
|
|
23783
|
+
moveIssueToInProgress({ owner, repo, number });
|
|
23784
|
+
}
|
|
23785
|
+
|
|
23786
|
+
// src/commands/github/issue/registerStartIssue.ts
|
|
23787
|
+
function registerStartIssue(issueCommand) {
|
|
23788
|
+
issueCommand.command("started <number>").description(
|
|
23789
|
+
"Assign a GitHub issue to yourself and move its project boards to In Progress"
|
|
23790
|
+
).option(
|
|
23791
|
+
"-R, --repo <owner/repo>",
|
|
23792
|
+
"Target repository (defaults to the current repo)"
|
|
23793
|
+
).addHelpText(
|
|
23794
|
+
"after",
|
|
23795
|
+
"\nThe boards are discovered from the issue itself: every ProjectV2 item the issue sits on whose Status field offers an In Progress option (matched case-insensitively) is moved.\nThe assignment is applied first and is never blocked by the board work \u2014 an issue on no board, a Status field with no In Progress option, and a gh token without the project scope are each reported and exit 0.\nThe project scope is needed to read or move a board: gh auth refresh -h github.com -s project"
|
|
23796
|
+
).action(startIssue);
|
|
23797
|
+
}
|
|
23798
|
+
|
|
23657
23799
|
// src/commands/registerGithubIssue.ts
|
|
23658
23800
|
function registerGithubIssue(githubCommand) {
|
|
23659
23801
|
const issueCommand = githubCommand.command("issue").description("GitHub issue utilities");
|
|
@@ -23661,6 +23803,7 @@ function registerGithubIssue(githubCommand) {
|
|
|
23661
23803
|
registerEditIssue(issueCommand);
|
|
23662
23804
|
registerCommentIssue(issueCommand);
|
|
23663
23805
|
registerEditIssueComment(issueCommand);
|
|
23806
|
+
registerStartIssue(issueCommand);
|
|
23664
23807
|
registerFixStructure(issueCommand);
|
|
23665
23808
|
}
|
|
23666
23809
|
|
|
@@ -24089,7 +24232,7 @@ function registerRefineLaunch(program2, resumeFlag) {
|
|
|
24089
24232
|
import { randomUUID as randomUUID10 } from "crypto";
|
|
24090
24233
|
|
|
24091
24234
|
// src/commands/review/checkoutPr.ts
|
|
24092
|
-
import { execFileSync as
|
|
24235
|
+
import { execFileSync as execFileSync14 } from "child_process";
|
|
24093
24236
|
import chalk171 from "chalk";
|
|
24094
24237
|
|
|
24095
24238
|
// src/commands/sessions/daemon/daemonLog.ts
|
|
@@ -24651,10 +24794,10 @@ async function moveToPrCheckoutTree() {
|
|
|
24651
24794
|
}
|
|
24652
24795
|
|
|
24653
24796
|
// src/commands/review/prHeadBranch.ts
|
|
24654
|
-
import { execFileSync as
|
|
24797
|
+
import { execFileSync as execFileSync13 } from "child_process";
|
|
24655
24798
|
function prHeadBranch(number) {
|
|
24656
24799
|
try {
|
|
24657
|
-
const out =
|
|
24800
|
+
const out = execFileSync13(
|
|
24658
24801
|
"gh",
|
|
24659
24802
|
["pr", "view", number, "--json", "headRefName", "-q", ".headRefName"],
|
|
24660
24803
|
{ encoding: "utf8", stdio: ["ignore", "pipe", "pipe"] }
|
|
@@ -24702,7 +24845,7 @@ async function checkoutPr(number) {
|
|
|
24702
24845
|
if (headRef && moveToExistingCheckout(number, headRef)) return;
|
|
24703
24846
|
await moveToPrCheckoutTree();
|
|
24704
24847
|
try {
|
|
24705
|
-
|
|
24848
|
+
execFileSync14("gh", ["pr", "checkout", number], { stdio: "inherit" });
|
|
24706
24849
|
} catch {
|
|
24707
24850
|
console.error(chalk171.red(`gh pr checkout ${number} failed; aborting.`));
|
|
24708
24851
|
process.exit(1);
|
|
@@ -26442,13 +26585,13 @@ async function comment2(path91, line, body, options2 = {}) {
|
|
|
26442
26585
|
import { randomUUID as randomUUID14 } from "crypto";
|
|
26443
26586
|
|
|
26444
26587
|
// src/commands/prs/applyEdit.ts
|
|
26445
|
-
import { execFileSync as
|
|
26588
|
+
import { execFileSync as execFileSync15 } from "child_process";
|
|
26446
26589
|
function applyEdit(number, title, body) {
|
|
26447
26590
|
const args = ["pr", "edit", String(number)];
|
|
26448
26591
|
if (title) args.push("--title", title);
|
|
26449
26592
|
args.push("--body", body);
|
|
26450
26593
|
try {
|
|
26451
|
-
|
|
26594
|
+
execFileSync15("gh", args, { stdio: "inherit" });
|
|
26452
26595
|
} catch {
|
|
26453
26596
|
process.exit(1);
|
|
26454
26597
|
}
|
|
@@ -27252,7 +27395,7 @@ function buildValidatedBody(options2, usage) {
|
|
|
27252
27395
|
}
|
|
27253
27396
|
|
|
27254
27397
|
// src/commands/prs/placePr.ts
|
|
27255
|
-
import { execFileSync as
|
|
27398
|
+
import { execFileSync as execFileSync16 } from "child_process";
|
|
27256
27399
|
|
|
27257
27400
|
// src/commands/prs/buildCreateArgs.ts
|
|
27258
27401
|
function buildEditArgs(number, title, body) {
|
|
@@ -27319,7 +27462,7 @@ async function recordPrActivity() {
|
|
|
27319
27462
|
// src/commands/prs/placePr.ts
|
|
27320
27463
|
function hasUpstream2() {
|
|
27321
27464
|
try {
|
|
27322
|
-
|
|
27465
|
+
execFileSync16(
|
|
27323
27466
|
"git",
|
|
27324
27467
|
["rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{u}"],
|
|
27325
27468
|
{ stdio: "pipe" }
|
|
@@ -27331,13 +27474,13 @@ function hasUpstream2() {
|
|
|
27331
27474
|
}
|
|
27332
27475
|
function ensureBranchPushed() {
|
|
27333
27476
|
const args = hasUpstream2() ? ["push"] : ["push", "--set-upstream", "origin", "HEAD"];
|
|
27334
|
-
|
|
27477
|
+
execFileSync16("git", args, { stdio: "inherit" });
|
|
27335
27478
|
}
|
|
27336
27479
|
async function placePr(prNumber, title, body, options2) {
|
|
27337
27480
|
const args = prNumber !== null ? buildEditArgs(prNumber, title, body) : buildCreateArgs(title, body, options2);
|
|
27338
27481
|
try {
|
|
27339
27482
|
if (prNumber === null && !options2.head) ensureBranchPushed();
|
|
27340
|
-
|
|
27483
|
+
execFileSync16("gh", args, { stdio: "inherit" });
|
|
27341
27484
|
} catch {
|
|
27342
27485
|
process.exit(1);
|
|
27343
27486
|
}
|
|
@@ -27477,10 +27620,10 @@ function warn(reason4) {
|
|
|
27477
27620
|
}
|
|
27478
27621
|
|
|
27479
27622
|
// src/commands/prs/enableAutoMerge.ts
|
|
27480
|
-
import { execFileSync as
|
|
27623
|
+
import { execFileSync as execFileSync17 } from "child_process";
|
|
27481
27624
|
function enableAutoMerge() {
|
|
27482
27625
|
try {
|
|
27483
|
-
|
|
27626
|
+
execFileSync17(
|
|
27484
27627
|
"gh",
|
|
27485
27628
|
["pr", "merge", getCurrentBranch2(), "--auto", "--squash"],
|
|
27486
27629
|
{ stdio: "inherit" }
|
|
@@ -27517,9 +27660,9 @@ function resolveDraftState(options2, command) {
|
|
|
27517
27660
|
}
|
|
27518
27661
|
|
|
27519
27662
|
// src/commands/prs/raise.ts
|
|
27520
|
-
var
|
|
27663
|
+
var USAGE6 = "Usage: assist prs raise --title <title> --what <what> --why <why> [--how <how>] [--resolves <key>] [--force]";
|
|
27521
27664
|
async function raise(options2, command) {
|
|
27522
|
-
const { title, body } = buildValidatedBody(options2,
|
|
27665
|
+
const { title, body } = buildValidatedBody(options2, USAGE6);
|
|
27523
27666
|
const resolved = { ...options2, draft: resolveDraftState(options2, command) };
|
|
27524
27667
|
const existing = findCurrentPrNumber();
|
|
27525
27668
|
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
@@ -33468,61 +33611,125 @@ function parseSlackThreadRef(value) {
|
|
|
33468
33611
|
}
|
|
33469
33612
|
|
|
33470
33613
|
// src/commands/slack/postSlackMessage.ts
|
|
33614
|
+
import { mkdirSync as mkdirSync25, writeFileSync as writeFileSync44 } from "fs";
|
|
33615
|
+
|
|
33616
|
+
// src/commands/slack/previewSlackThreadParts.ts
|
|
33471
33617
|
import { mkdirSync as mkdirSync24, writeFileSync as writeFileSync43 } from "fs";
|
|
33472
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
|
+
|
|
33473
33639
|
// src/commands/slack/reviewProposedSlackMessage.ts
|
|
33474
33640
|
import { randomUUID as randomUUID18 } from "crypto";
|
|
33475
33641
|
async function reviewProposedSlackMessage(target, body, workingPath) {
|
|
33476
33642
|
const sessionId = process.env.ASSIST_SESSION_ID;
|
|
33477
33643
|
if (process.env.ASSIST_SESSION !== "1" || !sessionId) return;
|
|
33478
|
-
const { channel, threadTs } = target;
|
|
33644
|
+
const { channel, threadTs, part } = target;
|
|
33645
|
+
const destination = threadTs ? `Reply in ${channel} thread ${threadTs}` : `Post to ${channel}`;
|
|
33479
33646
|
await awaitPreviewApproval(
|
|
33480
|
-
"Slack message preview",
|
|
33647
|
+
part ? `Slack message ${part.index} of ${part.total}` : "Slack message preview",
|
|
33481
33648
|
{
|
|
33482
33649
|
sessionId,
|
|
33483
33650
|
requestId: randomUUID18(),
|
|
33484
|
-
title:
|
|
33651
|
+
title: part ? `${destination} (${part.index}/${part.total})` : destination,
|
|
33485
33652
|
body,
|
|
33486
33653
|
prNumber: null,
|
|
33487
33654
|
kind: "slack-post"
|
|
33488
33655
|
},
|
|
33489
33656
|
{
|
|
33490
|
-
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.`
|
|
33491
33658
|
}
|
|
33492
33659
|
);
|
|
33493
33660
|
}
|
|
33494
33661
|
|
|
33495
33662
|
// src/commands/slack/slackWorkingFile.ts
|
|
33496
33663
|
import { join as join78 } from "path";
|
|
33497
|
-
function slackWorkingFile(channel) {
|
|
33664
|
+
function slackWorkingFile(channel, partIndex) {
|
|
33498
33665
|
const slug2 = channel.replace(/^[#@]/, "").toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "channel";
|
|
33499
33666
|
const dir = join78(getStoreDir(), "slack");
|
|
33500
|
-
|
|
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
|
+
for (const path91 of paths) console.log(path91);
|
|
33501
33698
|
}
|
|
33502
33699
|
|
|
33503
33700
|
// src/commands/slack/postSlackMessage.ts
|
|
33504
|
-
var
|
|
33701
|
+
var USAGE7 = "Usage: assist slack post [channel] --body <body|-> | --parts <file>...";
|
|
33505
33702
|
async function postSlackMessage(channelArg, options2) {
|
|
33506
33703
|
const channel = (channelArg ?? loadConfig().slack?.channel ?? "").trim();
|
|
33507
33704
|
const body = options2.body?.trim();
|
|
33705
|
+
const partFiles = options2.parts ?? [];
|
|
33508
33706
|
if (!channel) {
|
|
33509
33707
|
console.error(
|
|
33510
33708
|
'No channel given and slack.channel is not set. Pass one, or set a default with: assist config set slack.channel "#general"'
|
|
33511
33709
|
);
|
|
33512
|
-
console.error(
|
|
33710
|
+
console.error(USAGE7);
|
|
33513
33711
|
process.exit(1);
|
|
33514
33712
|
}
|
|
33515
|
-
if (
|
|
33516
|
-
console.error(
|
|
33713
|
+
if (body && partFiles.length > 0) {
|
|
33714
|
+
console.error("Error: --parts cannot be combined with --body.");
|
|
33715
|
+
console.error(USAGE7);
|
|
33517
33716
|
process.exit(1);
|
|
33518
33717
|
}
|
|
33519
33718
|
const threadTs = options2.thread;
|
|
33719
|
+
const target = threadTs ? `${channel} (thread_ts ${threadTs})` : channel;
|
|
33720
|
+
if (partFiles.length > 0) {
|
|
33721
|
+
await previewSlackThreadParts({ channel, threadTs, target, partFiles });
|
|
33722
|
+
return;
|
|
33723
|
+
}
|
|
33724
|
+
if (!body) {
|
|
33725
|
+
console.error(USAGE7);
|
|
33726
|
+
process.exit(1);
|
|
33727
|
+
}
|
|
33520
33728
|
const { dir, bodyPath } = slackWorkingFile(channel);
|
|
33521
|
-
|
|
33522
|
-
|
|
33729
|
+
mkdirSync25(dir, { recursive: true });
|
|
33730
|
+
writeFileSync44(bodyPath, `${body}
|
|
33523
33731
|
`);
|
|
33524
33732
|
await reviewProposedSlackMessage({ channel, threadTs }, body, bodyPath);
|
|
33525
|
-
const target = threadTs ? `${channel} (thread_ts ${threadTs})` : channel;
|
|
33526
33733
|
console.log(`Approved for ${target}. The body to post is at:`);
|
|
33527
33734
|
console.log(bodyPath);
|
|
33528
33735
|
}
|
|
@@ -33531,14 +33738,17 @@ async function postSlackMessage(channelArg, options2) {
|
|
|
33531
33738
|
function registerSlack(program2) {
|
|
33532
33739
|
const slackCommand = program2.command("slack").description("Slack utilities");
|
|
33533
33740
|
const postCommand = slackCommand.command("post [channel]").description(
|
|
33534
|
-
"Preview a markdown message bound for a Slack channel (body of - reads it from stdin)"
|
|
33741
|
+
"Preview a markdown message, or a thread of them with --parts, bound for a Slack channel (body of - reads it from stdin)"
|
|
33535
33742
|
).option("--body <body>", "Message body (- reads it from stdin)").option(
|
|
33743
|
+
"--parts <files...>",
|
|
33744
|
+
"Files holding the messages of one thread, in thread order (not with --body)"
|
|
33745
|
+
).option(
|
|
33536
33746
|
"--thread <ts-or-permalink>",
|
|
33537
33747
|
"Reply in this thread: a message ts (1712345678.123456) or a Slack archives permalink",
|
|
33538
33748
|
parseSlackThreadRef
|
|
33539
33749
|
).addHelpText(
|
|
33540
33750
|
"after",
|
|
33541
|
-
"\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."
|
|
33751
|
+
"\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; 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."
|
|
33542
33752
|
).action(
|
|
33543
33753
|
async (channel, options2) => {
|
|
33544
33754
|
await postSlackMessage(channel, {
|
|
@@ -34483,9 +34693,9 @@ function formatVttPassages(passages, notes = [], { sourceMarks = true } = {}) {
|
|
|
34483
34693
|
}
|
|
34484
34694
|
|
|
34485
34695
|
// src/commands/transcript/convert/readCleanedCues.ts
|
|
34486
|
-
import { readFileSync as
|
|
34696
|
+
import { readFileSync as readFileSync57 } from "fs";
|
|
34487
34697
|
function readCleanedCues(inputPath) {
|
|
34488
|
-
return deduplicateCues(parseVtt(
|
|
34698
|
+
return deduplicateCues(parseVtt(readFileSync57(inputPath, "utf8")));
|
|
34489
34699
|
}
|
|
34490
34700
|
|
|
34491
34701
|
// src/commands/transcript/clean.ts
|
|
@@ -34607,7 +34817,7 @@ function list4() {
|
|
|
34607
34817
|
}
|
|
34608
34818
|
|
|
34609
34819
|
// src/commands/transcript/move.ts
|
|
34610
|
-
import { existsSync as existsSync75, mkdirSync as
|
|
34820
|
+
import { existsSync as existsSync75, mkdirSync as mkdirSync31, renameSync as renameSync2, writeFileSync as writeFileSync48 } from "fs";
|
|
34611
34821
|
import { basename as basename23, join as join90 } from "path";
|
|
34612
34822
|
|
|
34613
34823
|
// src/commands/transcript/convertVttToMarkdown.ts
|
|
@@ -34619,7 +34829,7 @@ function convertVttToMarkdown(inputPath) {
|
|
|
34619
34829
|
var DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
|
|
34620
34830
|
function archiveRawVtt(vttDir, sourcePath, filename) {
|
|
34621
34831
|
const processedDir = join90(vttDir, "processed");
|
|
34622
|
-
|
|
34832
|
+
mkdirSync31(processedDir, { recursive: true });
|
|
34623
34833
|
renameSync2(sourcePath, join90(processedDir, filename));
|
|
34624
34834
|
}
|
|
34625
34835
|
function move(file, options2) {
|
|
@@ -34638,9 +34848,9 @@ function move(file, options2) {
|
|
|
34638
34848
|
const base = basename23(filename, ".vtt").replace(/ Transcription$/, "");
|
|
34639
34849
|
const outputName = `${date} ${base}.md`;
|
|
34640
34850
|
const formattedDir = join90(transcriptsDir, client);
|
|
34641
|
-
|
|
34851
|
+
mkdirSync31(formattedDir, { recursive: true });
|
|
34642
34852
|
const formattedPath = join90(formattedDir, outputName);
|
|
34643
|
-
|
|
34853
|
+
writeFileSync48(formattedPath, convertVttToMarkdown(sourcePath), "utf8");
|
|
34644
34854
|
archiveRawVtt(vttDir, sourcePath, filename);
|
|
34645
34855
|
const summaryPath = join90(summaryDir, client, outputName);
|
|
34646
34856
|
console.log(`Formatted transcript: ${formattedPath}`);
|
|
@@ -34648,7 +34858,7 @@ function move(file, options2) {
|
|
|
34648
34858
|
}
|
|
34649
34859
|
|
|
34650
34860
|
// src/commands/transcript/merge.ts
|
|
34651
|
-
import { existsSync as existsSync76, writeFileSync as
|
|
34861
|
+
import { existsSync as existsSync76, writeFileSync as writeFileSync49 } from "fs";
|
|
34652
34862
|
import { basename as basename24 } from "path";
|
|
34653
34863
|
|
|
34654
34864
|
// src/commands/transcript/failTranscript.ts
|
|
@@ -34825,7 +35035,7 @@ async function merge(files, options2 = {}) {
|
|
|
34825
35035
|
console.log(document);
|
|
34826
35036
|
return;
|
|
34827
35037
|
}
|
|
34828
|
-
|
|
35038
|
+
writeFileSync49(options2.out, `${document}
|
|
34829
35039
|
`, "utf8");
|
|
34830
35040
|
console.log(`Merged transcript: ${options2.out}`);
|
|
34831
35041
|
}
|
|
@@ -34997,14 +35207,14 @@ function devices() {
|
|
|
34997
35207
|
}
|
|
34998
35208
|
|
|
34999
35209
|
// src/commands/voice/logs.ts
|
|
35000
|
-
import { existsSync as existsSync77, readFileSync as
|
|
35210
|
+
import { existsSync as existsSync77, readFileSync as readFileSync58 } from "fs";
|
|
35001
35211
|
function logs(options2) {
|
|
35002
35212
|
if (!existsSync77(voicePaths.log)) {
|
|
35003
35213
|
console.log("No voice log file found");
|
|
35004
35214
|
return;
|
|
35005
35215
|
}
|
|
35006
35216
|
const count8 = Number.parseInt(options2.lines ?? "150", 10);
|
|
35007
|
-
const content =
|
|
35217
|
+
const content = readFileSync58(voicePaths.log, "utf8").trim();
|
|
35008
35218
|
if (!content) {
|
|
35009
35219
|
console.log("Voice log is empty");
|
|
35010
35220
|
return;
|
|
@@ -35026,12 +35236,12 @@ function logs(options2) {
|
|
|
35026
35236
|
|
|
35027
35237
|
// src/commands/voice/setup.ts
|
|
35028
35238
|
import { spawnSync as spawnSync10 } from "child_process";
|
|
35029
|
-
import { mkdirSync as
|
|
35239
|
+
import { mkdirSync as mkdirSync33 } from "fs";
|
|
35030
35240
|
import { join as join94 } from "path";
|
|
35031
35241
|
|
|
35032
35242
|
// src/commands/voice/checkLockFile.ts
|
|
35033
35243
|
import { execSync as execSync63 } from "child_process";
|
|
35034
|
-
import { existsSync as existsSync78, mkdirSync as
|
|
35244
|
+
import { existsSync as existsSync78, mkdirSync as mkdirSync32, readFileSync as readFileSync59, writeFileSync as writeFileSync50 } from "fs";
|
|
35035
35245
|
import { join as join93 } from "path";
|
|
35036
35246
|
function isProcessAlive2(pid) {
|
|
35037
35247
|
try {
|
|
@@ -35045,7 +35255,7 @@ function checkLockFile() {
|
|
|
35045
35255
|
const lockFile = getLockFile();
|
|
35046
35256
|
if (!existsSync78(lockFile)) return;
|
|
35047
35257
|
try {
|
|
35048
|
-
const lock2 = JSON.parse(
|
|
35258
|
+
const lock2 = JSON.parse(readFileSync59(lockFile, "utf8"));
|
|
35049
35259
|
if (lock2.pid && isProcessAlive2(lock2.pid)) {
|
|
35050
35260
|
console.error(
|
|
35051
35261
|
`Voice daemon already running (PID ${lock2.pid}, env: ${lock2.env}). Stop it first with: assist voice stop`
|
|
@@ -35069,8 +35279,8 @@ function bootstrapVenv() {
|
|
|
35069
35279
|
}
|
|
35070
35280
|
function writeLockFile(pid) {
|
|
35071
35281
|
const lockFile = getLockFile();
|
|
35072
|
-
|
|
35073
|
-
|
|
35282
|
+
mkdirSync32(join93(lockFile, ".."), { recursive: true });
|
|
35283
|
+
writeFileSync50(
|
|
35074
35284
|
lockFile,
|
|
35075
35285
|
JSON.stringify({
|
|
35076
35286
|
pid,
|
|
@@ -35082,7 +35292,7 @@ function writeLockFile(pid) {
|
|
|
35082
35292
|
|
|
35083
35293
|
// src/commands/voice/setup.ts
|
|
35084
35294
|
function setup() {
|
|
35085
|
-
|
|
35295
|
+
mkdirSync33(voicePaths.dir, { recursive: true });
|
|
35086
35296
|
bootstrapVenv();
|
|
35087
35297
|
console.log("\nDownloading models...\n");
|
|
35088
35298
|
const script = join94(getPythonDir(), "setup_models.py");
|
|
@@ -35098,7 +35308,7 @@ function setup() {
|
|
|
35098
35308
|
|
|
35099
35309
|
// src/commands/voice/start.ts
|
|
35100
35310
|
import { spawn as spawn8 } from "child_process";
|
|
35101
|
-
import { mkdirSync as
|
|
35311
|
+
import { mkdirSync as mkdirSync34, writeFileSync as writeFileSync51 } from "fs";
|
|
35102
35312
|
import { join as join95 } from "path";
|
|
35103
35313
|
|
|
35104
35314
|
// src/commands/voice/buildDaemonEnv.ts
|
|
@@ -35127,12 +35337,12 @@ function spawnBackground(python, script, env) {
|
|
|
35127
35337
|
console.error("Failed to start voice daemon");
|
|
35128
35338
|
process.exit(1);
|
|
35129
35339
|
}
|
|
35130
|
-
|
|
35340
|
+
writeFileSync51(voicePaths.pid, String(pid));
|
|
35131
35341
|
writeLockFile(pid);
|
|
35132
35342
|
console.log(`Voice daemon started (PID ${pid})`);
|
|
35133
35343
|
}
|
|
35134
35344
|
function start2(options2) {
|
|
35135
|
-
|
|
35345
|
+
mkdirSync34(voicePaths.dir, { recursive: true });
|
|
35136
35346
|
checkLockFile();
|
|
35137
35347
|
bootstrapVenv();
|
|
35138
35348
|
const debug = options2.debug || options2.foreground || process.platform === "win32";
|
|
@@ -35147,7 +35357,7 @@ function start2(options2) {
|
|
|
35147
35357
|
}
|
|
35148
35358
|
|
|
35149
35359
|
// src/commands/voice/status.ts
|
|
35150
|
-
import { existsSync as existsSync79, readFileSync as
|
|
35360
|
+
import { existsSync as existsSync79, readFileSync as readFileSync60 } from "fs";
|
|
35151
35361
|
function isProcessAlive3(pid) {
|
|
35152
35362
|
try {
|
|
35153
35363
|
process.kill(pid, 0);
|
|
@@ -35158,7 +35368,7 @@ function isProcessAlive3(pid) {
|
|
|
35158
35368
|
}
|
|
35159
35369
|
function readRecentLogs(count8) {
|
|
35160
35370
|
if (!existsSync79(voicePaths.log)) return [];
|
|
35161
|
-
const lines2 =
|
|
35371
|
+
const lines2 = readFileSync60(voicePaths.log, "utf8").trim().split("\n");
|
|
35162
35372
|
return lines2.slice(-count8);
|
|
35163
35373
|
}
|
|
35164
35374
|
function status2() {
|
|
@@ -35166,7 +35376,7 @@ function status2() {
|
|
|
35166
35376
|
console.log("Voice daemon: not running (no PID file)");
|
|
35167
35377
|
return;
|
|
35168
35378
|
}
|
|
35169
|
-
const pid = Number.parseInt(
|
|
35379
|
+
const pid = Number.parseInt(readFileSync60(voicePaths.pid, "utf8").trim(), 10);
|
|
35170
35380
|
const alive = isProcessAlive3(pid);
|
|
35171
35381
|
console.log(`Voice daemon: ${alive ? "running" : "dead"} (PID ${pid})`);
|
|
35172
35382
|
const recent = readRecentLogs(5);
|
|
@@ -35185,13 +35395,13 @@ function status2() {
|
|
|
35185
35395
|
}
|
|
35186
35396
|
|
|
35187
35397
|
// src/commands/voice/stop.ts
|
|
35188
|
-
import { existsSync as existsSync80, readFileSync as
|
|
35398
|
+
import { existsSync as existsSync80, readFileSync as readFileSync61, unlinkSync as unlinkSync20 } from "fs";
|
|
35189
35399
|
function stop2() {
|
|
35190
35400
|
if (!existsSync80(voicePaths.pid)) {
|
|
35191
35401
|
console.log("Voice daemon is not running (no PID file)");
|
|
35192
35402
|
return;
|
|
35193
35403
|
}
|
|
35194
|
-
const pid = Number.parseInt(
|
|
35404
|
+
const pid = Number.parseInt(readFileSync61(voicePaths.pid, "utf8").trim(), 10);
|
|
35195
35405
|
try {
|
|
35196
35406
|
process.kill(pid, "SIGTERM");
|
|
35197
35407
|
console.log(`Sent SIGTERM to voice daemon (PID ${pid})`);
|
|
@@ -35223,9 +35433,9 @@ function registerVoice(program2) {
|
|
|
35223
35433
|
}
|
|
35224
35434
|
|
|
35225
35435
|
// src/commands/watch/resolveUpstream.ts
|
|
35226
|
-
import { execFileSync as
|
|
35436
|
+
import { execFileSync as execFileSync18 } from "child_process";
|
|
35227
35437
|
function runGit3(args, cwd) {
|
|
35228
|
-
return
|
|
35438
|
+
return execFileSync18("git", args, {
|
|
35229
35439
|
encoding: "utf8",
|
|
35230
35440
|
stdio: ["pipe", "pipe", "pipe"],
|
|
35231
35441
|
cwd
|
|
@@ -35627,13 +35837,13 @@ import { spawn as spawn9 } from "child_process";
|
|
|
35627
35837
|
import { existsSync as existsSync83 } from "fs";
|
|
35628
35838
|
|
|
35629
35839
|
// src/commands/run/resolveCommand.ts
|
|
35630
|
-
import { execFileSync as
|
|
35840
|
+
import { execFileSync as execFileSync19 } from "child_process";
|
|
35631
35841
|
import { existsSync as existsSync82 } from "fs";
|
|
35632
35842
|
import { dirname as dirname39, join as join97, resolve as resolve20 } from "path";
|
|
35633
35843
|
function resolveCommand2(command) {
|
|
35634
35844
|
if (process.platform !== "win32" || command !== "bash") return command;
|
|
35635
35845
|
try {
|
|
35636
|
-
const gitPath =
|
|
35846
|
+
const gitPath = execFileSync19("where", ["git"], { encoding: "utf8" }).trim().split("\r\n")[0];
|
|
35637
35847
|
const gitRoot = resolve20(dirname39(gitPath), "..");
|
|
35638
35848
|
const gitBash = join97(gitRoot, "bin", "bash.exe");
|
|
35639
35849
|
if (existsSync82(gitBash)) return gitBash;
|
|
@@ -35755,11 +35965,11 @@ async function reportSyncOrExit() {
|
|
|
35755
35965
|
}
|
|
35756
35966
|
|
|
35757
35967
|
// src/commands/watch/fetchQuietly.ts
|
|
35758
|
-
import { execFileSync as
|
|
35968
|
+
import { execFileSync as execFileSync20 } from "child_process";
|
|
35759
35969
|
var MIN_FETCH_TIMEOUT_MS = 6e4;
|
|
35760
35970
|
function fetchQuietly(cwd, intervalMs) {
|
|
35761
35971
|
try {
|
|
35762
|
-
|
|
35972
|
+
execFileSync20("git", ["fetch", "--quiet"], {
|
|
35763
35973
|
stdio: ["pipe", "pipe", "pipe"],
|
|
35764
35974
|
cwd,
|
|
35765
35975
|
timeout: Math.max(intervalMs, MIN_FETCH_TIMEOUT_MS)
|
|
@@ -36061,8 +36271,8 @@ async function auth() {
|
|
|
36061
36271
|
}
|
|
36062
36272
|
|
|
36063
36273
|
// src/commands/roam/postRoamActivity.ts
|
|
36064
|
-
import { execFileSync as
|
|
36065
|
-
import { readdirSync as readdirSync22, readFileSync as
|
|
36274
|
+
import { execFileSync as execFileSync21 } from "child_process";
|
|
36275
|
+
import { readdirSync as readdirSync22, readFileSync as readFileSync62, statSync as statSync12 } from "fs";
|
|
36066
36276
|
import { join as join98 } from "path";
|
|
36067
36277
|
function findPortFile(roamDir) {
|
|
36068
36278
|
let entries;
|
|
@@ -36093,14 +36303,14 @@ function postRoamActivity(app, event) {
|
|
|
36093
36303
|
if (!portFile) return;
|
|
36094
36304
|
let port;
|
|
36095
36305
|
try {
|
|
36096
|
-
port =
|
|
36306
|
+
port = readFileSync62(portFile, "utf8").trim();
|
|
36097
36307
|
} catch {
|
|
36098
36308
|
return;
|
|
36099
36309
|
}
|
|
36100
36310
|
const pid = PID_BY_APP[app] ?? 99999;
|
|
36101
36311
|
const url = `http://127.0.0.1:${port}/api/v1/activity/${app}/${event}?pid=${pid}`;
|
|
36102
36312
|
try {
|
|
36103
|
-
|
|
36313
|
+
execFileSync21("curl", ["-sf", "--max-time", "0.2", "-X", "POST", url], {
|
|
36104
36314
|
stdio: "ignore"
|
|
36105
36315
|
});
|
|
36106
36316
|
} catch {
|
|
@@ -36224,7 +36434,7 @@ async function run3(name, args) {
|
|
|
36224
36434
|
}
|
|
36225
36435
|
|
|
36226
36436
|
// src/commands/run/add.ts
|
|
36227
|
-
import { mkdirSync as
|
|
36437
|
+
import { mkdirSync as mkdirSync35, writeFileSync as writeFileSync52 } from "fs";
|
|
36228
36438
|
import { join as join99 } from "path";
|
|
36229
36439
|
|
|
36230
36440
|
// src/commands/run/extractOption.ts
|
|
@@ -36287,7 +36497,7 @@ function saveNewRunConfig(name, command, args, cwd) {
|
|
|
36287
36497
|
}
|
|
36288
36498
|
function createCommandFile(name) {
|
|
36289
36499
|
const dir = join99(".claude", "commands");
|
|
36290
|
-
|
|
36500
|
+
mkdirSync35(dir, { recursive: true });
|
|
36291
36501
|
const content = `---
|
|
36292
36502
|
description: Run ${name}
|
|
36293
36503
|
---
|
|
@@ -36295,7 +36505,7 @@ description: Run ${name}
|
|
|
36295
36505
|
Run \`assist run ${name} $ARGUMENTS 2>&1\`.
|
|
36296
36506
|
`;
|
|
36297
36507
|
const filePath = join99(dir, `${name}.md`);
|
|
36298
|
-
|
|
36508
|
+
writeFileSync52(filePath, content);
|
|
36299
36509
|
console.log(`Created command file: ${filePath}`);
|
|
36300
36510
|
}
|
|
36301
36511
|
function add3() {
|
|
@@ -36412,7 +36622,7 @@ function registerRun(program2) {
|
|
|
36412
36622
|
|
|
36413
36623
|
// src/commands/screenshot/index.ts
|
|
36414
36624
|
import { execSync as execSync65 } from "child_process";
|
|
36415
|
-
import { existsSync as existsSync85, mkdirSync as
|
|
36625
|
+
import { existsSync as existsSync85, mkdirSync as mkdirSync36, unlinkSync as unlinkSync22, writeFileSync as writeFileSync53 } from "fs";
|
|
36416
36626
|
import { tmpdir as tmpdir9 } from "os";
|
|
36417
36627
|
import { join as join101, resolve as resolve21 } from "path";
|
|
36418
36628
|
import chalk233 from "chalk";
|
|
@@ -36545,14 +36755,14 @@ Write-Output $OutputPath
|
|
|
36545
36755
|
// src/commands/screenshot/index.ts
|
|
36546
36756
|
function buildOutputPath(outputDir, processName) {
|
|
36547
36757
|
if (!existsSync85(outputDir)) {
|
|
36548
|
-
|
|
36758
|
+
mkdirSync36(outputDir, { recursive: true });
|
|
36549
36759
|
}
|
|
36550
36760
|
const timestamp6 = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
36551
36761
|
return resolve21(outputDir, `${processName}-${timestamp6}.png`);
|
|
36552
36762
|
}
|
|
36553
36763
|
function runPowerShellScript(processName, outputPath) {
|
|
36554
36764
|
const scriptPath = join101(tmpdir9(), `assist-screenshot-${Date.now()}.ps1`);
|
|
36555
|
-
|
|
36765
|
+
writeFileSync53(scriptPath, captureWindowPs1, "utf8");
|
|
36556
36766
|
try {
|
|
36557
36767
|
execSync65(
|
|
36558
36768
|
`powershell -NoProfile -ExecutionPolicy Bypass -File "${scriptPath}" -ProcessName "${processName}" -OutputPath "${outputPath}"`,
|
|
@@ -36578,11 +36788,11 @@ function screenshot(processName) {
|
|
|
36578
36788
|
}
|
|
36579
36789
|
|
|
36580
36790
|
// src/commands/sessions/daemon/listDaemonPids.ts
|
|
36581
|
-
import { execFileSync as
|
|
36791
|
+
import { execFileSync as execFileSync22 } from "child_process";
|
|
36582
36792
|
function listDaemonPids() {
|
|
36583
36793
|
if (process.platform === "win32") return [];
|
|
36584
36794
|
try {
|
|
36585
|
-
const out =
|
|
36795
|
+
const out = execFileSync22("ps", ["-eo", "pid=,args="], {
|
|
36586
36796
|
encoding: "utf8"
|
|
36587
36797
|
});
|
|
36588
36798
|
return out.split("\n").filter((line) => line.includes("assist") && / daemon run\b/.test(line)).map((line) => Number.parseInt(line.trim(), 10)).filter((pid) => Number.isInteger(pid));
|
|
@@ -36628,11 +36838,11 @@ function applyLine(result, pending, line) {
|
|
|
36628
36838
|
}
|
|
36629
36839
|
|
|
36630
36840
|
// src/commands/sessions/daemon/readDaemonPidFile.ts
|
|
36631
|
-
import { readFileSync as
|
|
36841
|
+
import { readFileSync as readFileSync63 } from "fs";
|
|
36632
36842
|
function readDaemonPidFile() {
|
|
36633
36843
|
try {
|
|
36634
36844
|
const pid = Number.parseInt(
|
|
36635
|
-
|
|
36845
|
+
readFileSync63(daemonPaths.pid, "utf8").trim(),
|
|
36636
36846
|
10
|
|
36637
36847
|
);
|
|
36638
36848
|
return Number.isInteger(pid) ? pid : void 0;
|
|
@@ -36785,7 +36995,7 @@ function requestDrain(socket, lines2) {
|
|
|
36785
36995
|
}
|
|
36786
36996
|
|
|
36787
36997
|
// src/commands/sessions/daemon/runDaemon.ts
|
|
36788
|
-
import { mkdirSync as
|
|
36998
|
+
import { mkdirSync as mkdirSync40 } from "fs";
|
|
36789
36999
|
|
|
36790
37000
|
// src/commands/sessions/daemon/createAutoExit.ts
|
|
36791
37001
|
var DEFAULT_GRACE_MS = 6e4;
|
|
@@ -38137,7 +38347,7 @@ function handleFailedResume(session, exitCode, onStatusChange) {
|
|
|
38137
38347
|
}
|
|
38138
38348
|
|
|
38139
38349
|
// src/commands/sessions/daemon/watchActivity.ts
|
|
38140
|
-
import { existsSync as existsSync93, mkdirSync as
|
|
38350
|
+
import { existsSync as existsSync93, mkdirSync as mkdirSync37, watch as watch2 } from "fs";
|
|
38141
38351
|
import { dirname as dirname41 } from "path";
|
|
38142
38352
|
|
|
38143
38353
|
// src/commands/sessions/daemon/applyActivityToSession.ts
|
|
@@ -38202,7 +38412,7 @@ function watchActivity(session, notify2, onClaudeSessionId) {
|
|
|
38202
38412
|
const path91 = activityPath(session.id);
|
|
38203
38413
|
const dir = dirname41(path91);
|
|
38204
38414
|
try {
|
|
38205
|
-
|
|
38415
|
+
mkdirSync37(dir, { recursive: true });
|
|
38206
38416
|
} catch {
|
|
38207
38417
|
return;
|
|
38208
38418
|
}
|
|
@@ -38405,10 +38615,10 @@ function headContainsSessionId(filePath, claudeSessionId) {
|
|
|
38405
38615
|
}
|
|
38406
38616
|
|
|
38407
38617
|
// src/commands/sessions/daemon/ensureProjectDirExists.ts
|
|
38408
|
-
import { mkdirSync as
|
|
38618
|
+
import { mkdirSync as mkdirSync38 } from "fs";
|
|
38409
38619
|
function ensureProjectDirExists(dir, sessionId) {
|
|
38410
38620
|
try {
|
|
38411
|
-
|
|
38621
|
+
mkdirSync38(dir, { recursive: true });
|
|
38412
38622
|
return true;
|
|
38413
38623
|
} catch (error) {
|
|
38414
38624
|
daemonLog(
|
|
@@ -40813,14 +41023,14 @@ async function defaultConnect() {
|
|
|
40813
41023
|
}
|
|
40814
41024
|
|
|
40815
41025
|
// src/commands/sessions/daemon/hasPersistedWindowsSessions.ts
|
|
40816
|
-
import { existsSync as existsSync97, readFileSync as
|
|
41026
|
+
import { existsSync as existsSync97, readFileSync as readFileSync65 } from "fs";
|
|
40817
41027
|
import { posix as posix3 } from "path";
|
|
40818
41028
|
function hasPersistedWindowsSessions() {
|
|
40819
41029
|
const sessionsFile = windowsSessionsFileFromWsl();
|
|
40820
41030
|
if (!sessionsFile) return false;
|
|
40821
41031
|
try {
|
|
40822
41032
|
if (!existsSync97(sessionsFile)) return false;
|
|
40823
|
-
const data = JSON.parse(
|
|
41033
|
+
const data = JSON.parse(readFileSync65(sessionsFile, "utf8"));
|
|
40824
41034
|
return Array.isArray(data) && data.length > 0;
|
|
40825
41035
|
} catch (error) {
|
|
40826
41036
|
const message3 = error instanceof Error ? error.message : String(error);
|
|
@@ -41588,7 +41798,7 @@ function resumeSession(id, sessionId, cwd, name, holdPty, harness) {
|
|
|
41588
41798
|
import { existsSync as existsSync99 } from "fs";
|
|
41589
41799
|
|
|
41590
41800
|
// src/commands/sessions/daemon/worktree/carryTranscriptToTree.ts
|
|
41591
|
-
import { copyFileSync as copyFileSync5, existsSync as existsSync98, mkdirSync as
|
|
41801
|
+
import { copyFileSync as copyFileSync5, existsSync as existsSync98, mkdirSync as mkdirSync39 } from "fs";
|
|
41592
41802
|
import { join as join106 } from "path";
|
|
41593
41803
|
function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
41594
41804
|
const dir = projectDirForCwd(toCwd);
|
|
@@ -41611,7 +41821,7 @@ function carryTranscriptToTree(claudeSessionId, fromCwd, toCwd) {
|
|
|
41611
41821
|
return;
|
|
41612
41822
|
}
|
|
41613
41823
|
try {
|
|
41614
|
-
|
|
41824
|
+
mkdirSync39(dir, { recursive: true });
|
|
41615
41825
|
copyFileSync5(source, dest);
|
|
41616
41826
|
daemonLog(
|
|
41617
41827
|
`transcript ${source} copied to ${dest} so ${toCwd} can resume it`
|
|
@@ -42242,10 +42452,10 @@ function handleConnection(socket, manager) {
|
|
|
42242
42452
|
}
|
|
42243
42453
|
|
|
42244
42454
|
// src/commands/sessions/daemon/onListening.ts
|
|
42245
|
-
import { unlinkSync as unlinkSync23, writeFileSync as
|
|
42455
|
+
import { unlinkSync as unlinkSync23, writeFileSync as writeFileSync54 } from "fs";
|
|
42246
42456
|
|
|
42247
42457
|
// src/commands/sessions/daemon/startPidFileWatchdog.ts
|
|
42248
|
-
import { readFileSync as
|
|
42458
|
+
import { readFileSync as readFileSync66 } from "fs";
|
|
42249
42459
|
var WATCHDOG_INTERVAL_MS = 5e3;
|
|
42250
42460
|
function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
|
|
42251
42461
|
const timer = setInterval(() => {
|
|
@@ -42256,7 +42466,7 @@ function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
|
|
|
42256
42466
|
}
|
|
42257
42467
|
function ownsPidFile() {
|
|
42258
42468
|
try {
|
|
42259
|
-
return
|
|
42469
|
+
return readFileSync66(daemonPaths.pid, "utf8").trim() === String(process.pid);
|
|
42260
42470
|
} catch {
|
|
42261
42471
|
return false;
|
|
42262
42472
|
}
|
|
@@ -42264,7 +42474,7 @@ function ownsPidFile() {
|
|
|
42264
42474
|
|
|
42265
42475
|
// src/commands/sessions/daemon/onListening.ts
|
|
42266
42476
|
function onListening(manager, checkAutoExit) {
|
|
42267
|
-
|
|
42477
|
+
writeFileSync54(daemonPaths.pid, String(process.pid));
|
|
42268
42478
|
startPidFileWatchdog(() => {
|
|
42269
42479
|
daemonLog("lost daemon.pid ownership; shutting down sessions and exiting");
|
|
42270
42480
|
void manager.flushActiveMs().finally(() => {
|
|
@@ -42305,7 +42515,7 @@ function cleanupOwnedFiles() {
|
|
|
42305
42515
|
import * as net3 from "net";
|
|
42306
42516
|
|
|
42307
42517
|
// src/commands/sessions/daemon/findPortHolderPid.ts
|
|
42308
|
-
import { execFileSync as
|
|
42518
|
+
import { execFileSync as execFileSync23 } from "child_process";
|
|
42309
42519
|
var PROBE_TIMEOUT_MS = 3e3;
|
|
42310
42520
|
function findPortHolderPid(port) {
|
|
42311
42521
|
try {
|
|
@@ -42315,7 +42525,7 @@ function findPortHolderPid(port) {
|
|
|
42315
42525
|
}
|
|
42316
42526
|
}
|
|
42317
42527
|
function probe(command, args) {
|
|
42318
|
-
return
|
|
42528
|
+
return execFileSync23(command, args, {
|
|
42319
42529
|
encoding: "utf8",
|
|
42320
42530
|
timeout: PROBE_TIMEOUT_MS,
|
|
42321
42531
|
stdio: ["ignore", "pipe", "ignore"]
|
|
@@ -42451,7 +42661,7 @@ async function recoverFromAddrInUse(server, manager, checkAutoExit) {
|
|
|
42451
42661
|
|
|
42452
42662
|
// src/commands/sessions/daemon/runDaemon.ts
|
|
42453
42663
|
async function runDaemon() {
|
|
42454
|
-
|
|
42664
|
+
mkdirSync40(daemonPaths.dir, { recursive: true });
|
|
42455
42665
|
daemonLog(
|
|
42456
42666
|
`starting (reason: ${process.env.ASSIST_DAEMON_SPAWN_REASON ?? "manual"})`
|
|
42457
42667
|
);
|
|
@@ -42554,7 +42764,7 @@ function summaryPathFor(jsonlPath2) {
|
|
|
42554
42764
|
}
|
|
42555
42765
|
|
|
42556
42766
|
// src/commands/sessions/summarise/summariseSession.ts
|
|
42557
|
-
import { execFileSync as
|
|
42767
|
+
import { execFileSync as execFileSync24 } from "child_process";
|
|
42558
42768
|
function summariseSession(jsonlPath2) {
|
|
42559
42769
|
const firstMessage = extractFirstUserMessage(jsonlPath2);
|
|
42560
42770
|
const backlogIds = scanSessionBacklogRefs(jsonlPath2);
|
|
@@ -42563,7 +42773,7 @@ function summariseSession(jsonlPath2) {
|
|
|
42563
42773
|
}
|
|
42564
42774
|
const prompt = buildPrompt6(firstMessage, backlogIds);
|
|
42565
42775
|
try {
|
|
42566
|
-
const output =
|
|
42776
|
+
const output = execFileSync24("claude", ["-p", "--model", "haiku", prompt], {
|
|
42567
42777
|
encoding: "utf8",
|
|
42568
42778
|
timeout: 3e4,
|
|
42569
42779
|
stdio: ["ignore", "pipe", "ignore"]
|
|
@@ -42749,7 +42959,7 @@ function buildLimitsSegment(rateLimits) {
|
|
|
42749
42959
|
}
|
|
42750
42960
|
|
|
42751
42961
|
// src/commands/readGitBranch.ts
|
|
42752
|
-
import { readFileSync as
|
|
42962
|
+
import { readFileSync as readFileSync68, statSync as statSync16 } from "fs";
|
|
42753
42963
|
import { isAbsolute as isAbsolute5, join as join107, resolve as resolve23 } from "path";
|
|
42754
42964
|
function resolveGitDir(cwd) {
|
|
42755
42965
|
const dotGit = join107(cwd, ".git");
|
|
@@ -42764,7 +42974,7 @@ function resolveGitDir(cwd) {
|
|
|
42764
42974
|
}
|
|
42765
42975
|
let contents;
|
|
42766
42976
|
try {
|
|
42767
|
-
contents =
|
|
42977
|
+
contents = readFileSync68(dotGit, "utf8");
|
|
42768
42978
|
} catch {
|
|
42769
42979
|
return null;
|
|
42770
42980
|
}
|
|
@@ -42782,7 +42992,7 @@ function readGitBranch(cwd) {
|
|
|
42782
42992
|
}
|
|
42783
42993
|
let head;
|
|
42784
42994
|
try {
|
|
42785
|
-
head =
|
|
42995
|
+
head = readFileSync68(join107(gitDir, "HEAD"), "utf8");
|
|
42786
42996
|
} catch {
|
|
42787
42997
|
return null;
|
|
42788
42998
|
}
|