@staff0rd/assist 0.267.0 → 0.268.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +133 -156
- 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.268.0",
|
|
10
10
|
type: "module",
|
|
11
11
|
main: "dist/index.js",
|
|
12
12
|
bin: {
|
|
@@ -12810,8 +12810,8 @@ function findRootParent(file, importedBy, visited) {
|
|
|
12810
12810
|
function clusterFiles(graph) {
|
|
12811
12811
|
const clusters = /* @__PURE__ */ new Map();
|
|
12812
12812
|
for (const file of graph.files) {
|
|
12813
|
-
const
|
|
12814
|
-
if (
|
|
12813
|
+
const basename11 = path38.basename(file, path38.extname(file));
|
|
12814
|
+
if (basename11 === "index") continue;
|
|
12815
12815
|
const importers = graph.importedBy.get(file);
|
|
12816
12816
|
if (!importers || importers.size !== 1) continue;
|
|
12817
12817
|
const parent = [...importers][0];
|
|
@@ -13321,9 +13321,16 @@ ${annotateDiffWithLineNumbers(context.diff.trimEnd())}
|
|
|
13321
13321
|
}
|
|
13322
13322
|
|
|
13323
13323
|
// src/commands/review/buildReviewPaths.ts
|
|
13324
|
-
import {
|
|
13324
|
+
import { homedir as homedir11 } from "os";
|
|
13325
|
+
import { basename as basename6, join as join36 } from "path";
|
|
13325
13326
|
function buildReviewPaths(repoRoot, key) {
|
|
13326
|
-
const reviewDir = join36(
|
|
13327
|
+
const reviewDir = join36(
|
|
13328
|
+
homedir11(),
|
|
13329
|
+
".assist",
|
|
13330
|
+
"reviews",
|
|
13331
|
+
basename6(repoRoot),
|
|
13332
|
+
key
|
|
13333
|
+
);
|
|
13327
13334
|
return {
|
|
13328
13335
|
reviewDir,
|
|
13329
13336
|
requestPath: join36(reviewDir, "request.md"),
|
|
@@ -13333,35 +13340,6 @@ function buildReviewPaths(repoRoot, key) {
|
|
|
13333
13340
|
};
|
|
13334
13341
|
}
|
|
13335
13342
|
|
|
13336
|
-
// src/commands/review/ensureReviewsIgnored.ts
|
|
13337
|
-
import {
|
|
13338
|
-
appendFileSync,
|
|
13339
|
-
existsSync as existsSync35,
|
|
13340
|
-
readFileSync as readFileSync30,
|
|
13341
|
-
writeFileSync as writeFileSync25
|
|
13342
|
-
} from "fs";
|
|
13343
|
-
import { join as join37 } from "path";
|
|
13344
|
-
var REVIEWS_ENTRY = ".assist/reviews";
|
|
13345
|
-
function coversReviews(line) {
|
|
13346
|
-
const pattern2 = line.trim().replace(/^\//, "").replace(/\/$/, "");
|
|
13347
|
-
return pattern2 === ".assist" || pattern2 === REVIEWS_ENTRY;
|
|
13348
|
-
}
|
|
13349
|
-
function ensureReviewsIgnored(repoRoot) {
|
|
13350
|
-
const gitignorePath = join37(repoRoot, ".gitignore");
|
|
13351
|
-
if (!existsSync35(gitignorePath)) {
|
|
13352
|
-
writeFileSync25(gitignorePath, `${REVIEWS_ENTRY}
|
|
13353
|
-
`);
|
|
13354
|
-
console.log(`Created .gitignore with ${REVIEWS_ENTRY} entry.`);
|
|
13355
|
-
return;
|
|
13356
|
-
}
|
|
13357
|
-
const content = readFileSync30(gitignorePath, "utf-8");
|
|
13358
|
-
if (content.split("\n").some(coversReviews)) return;
|
|
13359
|
-
const separator = content === "" || content.endsWith("\n") ? "" : "\n";
|
|
13360
|
-
appendFileSync(gitignorePath, `${separator}${REVIEWS_ENTRY}
|
|
13361
|
-
`);
|
|
13362
|
-
console.log(`Added ${REVIEWS_ENTRY} to .gitignore.`);
|
|
13363
|
-
}
|
|
13364
|
-
|
|
13365
13343
|
// src/commands/review/fetchExistingComments.ts
|
|
13366
13344
|
import { execSync as execSync41 } from "child_process";
|
|
13367
13345
|
function fetchRawComments(org, repo, prNumber) {
|
|
@@ -13501,7 +13479,7 @@ function gatherContext() {
|
|
|
13501
13479
|
}
|
|
13502
13480
|
|
|
13503
13481
|
// src/commands/review/postReviewToPr.ts
|
|
13504
|
-
import { readFileSync as
|
|
13482
|
+
import { readFileSync as readFileSync30 } from "fs";
|
|
13505
13483
|
|
|
13506
13484
|
// src/commands/review/parseFindings.ts
|
|
13507
13485
|
var SEVERITIES = ["blocker", "major", "minor", "nit"];
|
|
@@ -13811,7 +13789,7 @@ async function confirmPost(prNumber, count6, options2) {
|
|
|
13811
13789
|
async function postReviewToPr(synthesisPath, options2) {
|
|
13812
13790
|
const prInfo = fetchPrDiffInfo();
|
|
13813
13791
|
const prNumber = prInfo.prNumber;
|
|
13814
|
-
const markdown =
|
|
13792
|
+
const markdown = readFileSync30(synthesisPath, "utf-8");
|
|
13815
13793
|
const findings = parseFindings(markdown);
|
|
13816
13794
|
if (findings.length === 0) {
|
|
13817
13795
|
console.log("Synthesis contains no findings; nothing to post.");
|
|
@@ -13893,16 +13871,16 @@ async function handlePostSynthesis(synthesisPath, options2) {
|
|
|
13893
13871
|
}
|
|
13894
13872
|
|
|
13895
13873
|
// src/commands/review/prepareReviewDir.ts
|
|
13896
|
-
import { existsSync as
|
|
13874
|
+
import { existsSync as existsSync35, mkdirSync as mkdirSync13, unlinkSync as unlinkSync11, writeFileSync as writeFileSync25 } from "fs";
|
|
13897
13875
|
function clearReviewFiles(paths) {
|
|
13898
13876
|
for (const path53 of [paths.claudePath, paths.codexPath, paths.synthesisPath]) {
|
|
13899
|
-
if (
|
|
13877
|
+
if (existsSync35(path53)) unlinkSync11(path53);
|
|
13900
13878
|
}
|
|
13901
13879
|
}
|
|
13902
13880
|
function prepareReviewDir(paths, requestBody, force) {
|
|
13903
13881
|
mkdirSync13(paths.reviewDir, { recursive: true });
|
|
13904
13882
|
if (force) clearReviewFiles(paths);
|
|
13905
|
-
|
|
13883
|
+
writeFileSync25(paths.requestPath, requestBody);
|
|
13906
13884
|
}
|
|
13907
13885
|
|
|
13908
13886
|
// src/commands/review/runApplySession.ts
|
|
@@ -14181,7 +14159,7 @@ function printReviewerFailures(results) {
|
|
|
14181
14159
|
}
|
|
14182
14160
|
|
|
14183
14161
|
// src/commands/review/runAndSynthesise.ts
|
|
14184
|
-
import { existsSync as
|
|
14162
|
+
import { existsSync as existsSync37, unlinkSync as unlinkSync13 } from "fs";
|
|
14185
14163
|
|
|
14186
14164
|
// src/commands/review/buildReviewerStdin.ts
|
|
14187
14165
|
var REVIEW_PROMPT = `You are acting as a reviewer for a proposed code change made by another engineer. The full review request \u2014 branch, base, changed files, and unified diff \u2014 is in request.md in the current working directory.
|
|
@@ -14245,7 +14223,7 @@ The review request is at: ${requestPath}
|
|
|
14245
14223
|
}
|
|
14246
14224
|
|
|
14247
14225
|
// src/commands/review/runClaudeReviewer.ts
|
|
14248
|
-
import { writeFileSync as
|
|
14226
|
+
import { writeFileSync as writeFileSync26 } from "fs";
|
|
14249
14227
|
|
|
14250
14228
|
// src/commands/review/finaliseReviewerSpinner.ts
|
|
14251
14229
|
var SUMMARY_MAX_LEN = 80;
|
|
@@ -14581,7 +14559,7 @@ async function runClaudeReviewer(spec) {
|
|
|
14581
14559
|
}
|
|
14582
14560
|
});
|
|
14583
14561
|
if (result.exitCode === 0 && finalText)
|
|
14584
|
-
|
|
14562
|
+
writeFileSync26(spec.outputPath, finalText);
|
|
14585
14563
|
return finaliseReviewerRun({ ...spec, command }, spinner, result);
|
|
14586
14564
|
}
|
|
14587
14565
|
|
|
@@ -14599,7 +14577,7 @@ function resolveClaude(args) {
|
|
|
14599
14577
|
}
|
|
14600
14578
|
|
|
14601
14579
|
// src/commands/review/runCodexReviewer.ts
|
|
14602
|
-
import { existsSync as
|
|
14580
|
+
import { existsSync as existsSync36, unlinkSync as unlinkSync12 } from "fs";
|
|
14603
14581
|
|
|
14604
14582
|
// src/commands/review/parseCodexEvent.ts
|
|
14605
14583
|
function isItemStarted(value) {
|
|
@@ -14653,7 +14631,7 @@ async function runCodexReviewer(spec) {
|
|
|
14653
14631
|
reportReviewerToolUse(spec.name, event, spinner);
|
|
14654
14632
|
}
|
|
14655
14633
|
});
|
|
14656
|
-
if (result.exitCode !== 0 &&
|
|
14634
|
+
if (result.exitCode !== 0 && existsSync36(spec.outputPath)) {
|
|
14657
14635
|
unlinkSync12(spec.outputPath);
|
|
14658
14636
|
}
|
|
14659
14637
|
return finaliseReviewerRun({ ...spec, command }, spinner, result);
|
|
@@ -14697,7 +14675,7 @@ async function runReviewers(reviewDir, claudePath, codexPath, stdinPrompt, optio
|
|
|
14697
14675
|
}
|
|
14698
14676
|
|
|
14699
14677
|
// src/commands/review/synthesise.ts
|
|
14700
|
-
import { readFileSync as
|
|
14678
|
+
import { readFileSync as readFileSync31 } from "fs";
|
|
14701
14679
|
|
|
14702
14680
|
// src/commands/review/buildSynthesisStdin.ts
|
|
14703
14681
|
var SYNTHESIS_PROMPT = `You are consolidating two independent code reviews of the same change. The original review request is in request.md. The two reviews are in claude.md and codex.md in the current working directory.
|
|
@@ -14753,7 +14731,7 @@ Files:
|
|
|
14753
14731
|
|
|
14754
14732
|
// src/commands/review/synthesise.ts
|
|
14755
14733
|
function printSummary2(synthesisPath) {
|
|
14756
|
-
const markdown =
|
|
14734
|
+
const markdown = readFileSync31(synthesisPath, "utf-8");
|
|
14757
14735
|
console.log("");
|
|
14758
14736
|
console.log(buildReviewSummary(markdown));
|
|
14759
14737
|
console.log("");
|
|
@@ -14801,7 +14779,7 @@ async function runAndSynthesise(args) {
|
|
|
14801
14779
|
console.error("Both reviewers failed; skipping synthesis.");
|
|
14802
14780
|
return { ok: false, failures };
|
|
14803
14781
|
}
|
|
14804
|
-
if (anyFresh &&
|
|
14782
|
+
if (anyFresh && existsSync37(paths.synthesisPath)) {
|
|
14805
14783
|
unlinkSync13(paths.synthesisPath);
|
|
14806
14784
|
}
|
|
14807
14785
|
const synthesisResult = await synthesise(paths, { multi });
|
|
@@ -14895,7 +14873,6 @@ async function runPostSynthesis(synthesisPath, options2) {
|
|
|
14895
14873
|
}
|
|
14896
14874
|
async function reviewPr(repoRoot, options2) {
|
|
14897
14875
|
const context = gatherChangedContext();
|
|
14898
|
-
ensureReviewsIgnored(repoRoot);
|
|
14899
14876
|
const paths = setupReviewDir(repoRoot, context, options2.force ?? false);
|
|
14900
14877
|
const synthesisOk = await runReviewPipeline(paths, {
|
|
14901
14878
|
verbose: options2.verbose ?? false
|
|
@@ -15577,8 +15554,8 @@ function registerSql(program2) {
|
|
|
15577
15554
|
}
|
|
15578
15555
|
|
|
15579
15556
|
// src/commands/transcript/shared.ts
|
|
15580
|
-
import { existsSync as
|
|
15581
|
-
import { basename as
|
|
15557
|
+
import { existsSync as existsSync38, readdirSync as readdirSync6, statSync as statSync4 } from "fs";
|
|
15558
|
+
import { basename as basename7, join as join37, relative as relative2 } from "path";
|
|
15582
15559
|
import * as readline2 from "readline";
|
|
15583
15560
|
var DATE_PREFIX_REGEX = /^\d{4}-\d{2}-\d{2}/;
|
|
15584
15561
|
function getDatePrefix(daysOffset = 0) {
|
|
@@ -15593,10 +15570,10 @@ function isValidDatePrefix(filename) {
|
|
|
15593
15570
|
return DATE_PREFIX_REGEX.test(filename);
|
|
15594
15571
|
}
|
|
15595
15572
|
function collectFiles(dir, extension) {
|
|
15596
|
-
if (!
|
|
15573
|
+
if (!existsSync38(dir)) return [];
|
|
15597
15574
|
const results = [];
|
|
15598
15575
|
for (const entry of readdirSync6(dir)) {
|
|
15599
|
-
const fullPath =
|
|
15576
|
+
const fullPath = join37(dir, entry);
|
|
15600
15577
|
if (statSync4(fullPath).isDirectory()) {
|
|
15601
15578
|
results.push(...collectFiles(fullPath, extension));
|
|
15602
15579
|
} else if (entry.endsWith(extension)) {
|
|
@@ -15609,7 +15586,7 @@ function toFileInfo(baseDir, fullPath) {
|
|
|
15609
15586
|
return {
|
|
15610
15587
|
absolutePath: fullPath,
|
|
15611
15588
|
relativePath: relative2(baseDir, fullPath),
|
|
15612
|
-
filename:
|
|
15589
|
+
filename: basename7(fullPath)
|
|
15613
15590
|
};
|
|
15614
15591
|
}
|
|
15615
15592
|
function findVttFilesRecursive(dir, baseDir = dir) {
|
|
@@ -15619,7 +15596,7 @@ function findMdFilesRecursive(dir, baseDir = dir) {
|
|
|
15619
15596
|
return collectFiles(dir, ".md").map((f) => toFileInfo(baseDir, f));
|
|
15620
15597
|
}
|
|
15621
15598
|
function getTranscriptBaseName(transcriptFile) {
|
|
15622
|
-
return
|
|
15599
|
+
return basename7(transcriptFile, ".md").replace(/ Transcription$/, "");
|
|
15623
15600
|
}
|
|
15624
15601
|
function createReadlineInterface() {
|
|
15625
15602
|
return readline2.createInterface({
|
|
@@ -15690,14 +15667,14 @@ async function configure() {
|
|
|
15690
15667
|
}
|
|
15691
15668
|
|
|
15692
15669
|
// src/commands/transcript/format/index.ts
|
|
15693
|
-
import { existsSync as
|
|
15670
|
+
import { existsSync as existsSync40 } from "fs";
|
|
15694
15671
|
|
|
15695
15672
|
// src/commands/transcript/format/fixInvalidDatePrefixes/index.ts
|
|
15696
|
-
import { dirname as dirname20, join as
|
|
15673
|
+
import { dirname as dirname20, join as join39 } from "path";
|
|
15697
15674
|
|
|
15698
15675
|
// src/commands/transcript/format/fixInvalidDatePrefixes/promptForDateFix.ts
|
|
15699
15676
|
import { renameSync as renameSync3 } from "fs";
|
|
15700
|
-
import { join as
|
|
15677
|
+
import { join as join38 } from "path";
|
|
15701
15678
|
async function resolveDate(rl, choice) {
|
|
15702
15679
|
if (choice === "1") return getDatePrefix(0);
|
|
15703
15680
|
if (choice === "2") return getDatePrefix(-1);
|
|
@@ -15712,7 +15689,7 @@ async function resolveDate(rl, choice) {
|
|
|
15712
15689
|
}
|
|
15713
15690
|
function renameWithPrefix(vttDir, vttFile, prefix2) {
|
|
15714
15691
|
const newFilename = `${prefix2}.${vttFile}`;
|
|
15715
|
-
renameSync3(
|
|
15692
|
+
renameSync3(join38(vttDir, vttFile), join38(vttDir, newFilename));
|
|
15716
15693
|
console.log(`Renamed to: ${newFilename}`);
|
|
15717
15694
|
return newFilename;
|
|
15718
15695
|
}
|
|
@@ -15746,12 +15723,12 @@ async function fixInvalidDatePrefixes(vttFiles) {
|
|
|
15746
15723
|
const vttFileDir = dirname20(vttFile.absolutePath);
|
|
15747
15724
|
const newFilename = await promptForDateFix(vttFile.filename, vttFileDir);
|
|
15748
15725
|
if (newFilename) {
|
|
15749
|
-
const newRelativePath =
|
|
15726
|
+
const newRelativePath = join39(
|
|
15750
15727
|
dirname20(vttFile.relativePath),
|
|
15751
15728
|
newFilename
|
|
15752
15729
|
);
|
|
15753
15730
|
vttFiles[i] = {
|
|
15754
|
-
absolutePath:
|
|
15731
|
+
absolutePath: join39(vttFileDir, newFilename),
|
|
15755
15732
|
relativePath: newRelativePath,
|
|
15756
15733
|
filename: newFilename
|
|
15757
15734
|
};
|
|
@@ -15764,8 +15741,8 @@ async function fixInvalidDatePrefixes(vttFiles) {
|
|
|
15764
15741
|
}
|
|
15765
15742
|
|
|
15766
15743
|
// src/commands/transcript/format/processVttFile/index.ts
|
|
15767
|
-
import { existsSync as
|
|
15768
|
-
import { basename as
|
|
15744
|
+
import { existsSync as existsSync39, mkdirSync as mkdirSync14, readFileSync as readFileSync32, writeFileSync as writeFileSync27 } from "fs";
|
|
15745
|
+
import { basename as basename8, dirname as dirname21, join as join40 } from "path";
|
|
15769
15746
|
|
|
15770
15747
|
// src/commands/transcript/cleanText.ts
|
|
15771
15748
|
function cleanText(text2) {
|
|
@@ -15972,24 +15949,24 @@ function formatChatLog(messages) {
|
|
|
15972
15949
|
|
|
15973
15950
|
// src/commands/transcript/format/processVttFile/index.ts
|
|
15974
15951
|
function toMdFilename(vttFilename) {
|
|
15975
|
-
return `${
|
|
15952
|
+
return `${basename8(vttFilename, ".vtt").replace(/\s*Transcription\s*/g, " ").trim()}.md`;
|
|
15976
15953
|
}
|
|
15977
15954
|
function resolveOutputDir(relativeDir, transcriptsDir) {
|
|
15978
|
-
return relativeDir === "." ? transcriptsDir :
|
|
15955
|
+
return relativeDir === "." ? transcriptsDir : join40(transcriptsDir, relativeDir);
|
|
15979
15956
|
}
|
|
15980
15957
|
function buildOutputPaths(vttFile, transcriptsDir) {
|
|
15981
15958
|
const mdFile = toMdFilename(vttFile.filename);
|
|
15982
15959
|
const relativeDir = dirname21(vttFile.relativePath);
|
|
15983
15960
|
const outputDir = resolveOutputDir(relativeDir, transcriptsDir);
|
|
15984
|
-
const outputPath =
|
|
15961
|
+
const outputPath = join40(outputDir, mdFile);
|
|
15985
15962
|
return { outputDir, outputPath, mdFile, relativeDir };
|
|
15986
15963
|
}
|
|
15987
15964
|
function logSkipped(relativeDir, mdFile) {
|
|
15988
|
-
console.log(`Skipping (already exists): ${
|
|
15965
|
+
console.log(`Skipping (already exists): ${join40(relativeDir, mdFile)}`);
|
|
15989
15966
|
return "skipped";
|
|
15990
15967
|
}
|
|
15991
15968
|
function ensureDirectory(dir, label2) {
|
|
15992
|
-
if (!
|
|
15969
|
+
if (!existsSync39(dir)) {
|
|
15993
15970
|
mkdirSync14(dir, { recursive: true });
|
|
15994
15971
|
console.log(`Created ${label2}: ${dir}`);
|
|
15995
15972
|
}
|
|
@@ -16012,10 +15989,10 @@ function logReduction(cueCount, messageCount) {
|
|
|
16012
15989
|
}
|
|
16013
15990
|
function readAndParseCues(inputPath) {
|
|
16014
15991
|
console.log(`Reading: ${inputPath}`);
|
|
16015
|
-
return processCues(
|
|
15992
|
+
return processCues(readFileSync32(inputPath, "utf-8"));
|
|
16016
15993
|
}
|
|
16017
15994
|
function writeFormatted(outputPath, content) {
|
|
16018
|
-
|
|
15995
|
+
writeFileSync27(outputPath, content, "utf-8");
|
|
16019
15996
|
console.log(`Written: ${outputPath}`);
|
|
16020
15997
|
}
|
|
16021
15998
|
function convertVttToMarkdown(inputPath, outputPath) {
|
|
@@ -16025,7 +16002,7 @@ function convertVttToMarkdown(inputPath, outputPath) {
|
|
|
16025
16002
|
logReduction(cues.length, chatMessages.length);
|
|
16026
16003
|
}
|
|
16027
16004
|
function tryProcessVtt(vttFile, paths) {
|
|
16028
|
-
if (
|
|
16005
|
+
if (existsSync39(paths.outputPath))
|
|
16029
16006
|
return logSkipped(paths.relativeDir, paths.mdFile);
|
|
16030
16007
|
convertVttToMarkdown(vttFile.absolutePath, paths.outputPath);
|
|
16031
16008
|
return "processed";
|
|
@@ -16051,7 +16028,7 @@ function processAllFiles(vttFiles, transcriptsDir) {
|
|
|
16051
16028
|
logSummary(counts);
|
|
16052
16029
|
}
|
|
16053
16030
|
function requireVttDir(vttDir) {
|
|
16054
|
-
if (!
|
|
16031
|
+
if (!existsSync40(vttDir)) {
|
|
16055
16032
|
console.error(`VTT directory not found: ${vttDir}`);
|
|
16056
16033
|
process.exit(1);
|
|
16057
16034
|
}
|
|
@@ -16083,18 +16060,18 @@ async function format() {
|
|
|
16083
16060
|
}
|
|
16084
16061
|
|
|
16085
16062
|
// src/commands/transcript/summarise/index.ts
|
|
16086
|
-
import { existsSync as
|
|
16087
|
-
import { basename as
|
|
16063
|
+
import { existsSync as existsSync42 } from "fs";
|
|
16064
|
+
import { basename as basename9, dirname as dirname23, join as join42, relative as relative3 } from "path";
|
|
16088
16065
|
|
|
16089
16066
|
// src/commands/transcript/summarise/processStagedFile/index.ts
|
|
16090
16067
|
import {
|
|
16091
|
-
existsSync as
|
|
16068
|
+
existsSync as existsSync41,
|
|
16092
16069
|
mkdirSync as mkdirSync15,
|
|
16093
|
-
readFileSync as
|
|
16070
|
+
readFileSync as readFileSync33,
|
|
16094
16071
|
renameSync as renameSync4,
|
|
16095
16072
|
rmSync as rmSync2
|
|
16096
16073
|
} from "fs";
|
|
16097
|
-
import { dirname as dirname22, join as
|
|
16074
|
+
import { dirname as dirname22, join as join41 } from "path";
|
|
16098
16075
|
|
|
16099
16076
|
// src/commands/transcript/summarise/processStagedFile/validateStagedContent.ts
|
|
16100
16077
|
import chalk156 from "chalk";
|
|
@@ -16123,9 +16100,9 @@ function validateStagedContent(filename, content) {
|
|
|
16123
16100
|
}
|
|
16124
16101
|
|
|
16125
16102
|
// src/commands/transcript/summarise/processStagedFile/index.ts
|
|
16126
|
-
var STAGING_DIR =
|
|
16103
|
+
var STAGING_DIR = join41(process.cwd(), ".assist", "transcript");
|
|
16127
16104
|
function processStagedFile() {
|
|
16128
|
-
if (!
|
|
16105
|
+
if (!existsSync41(STAGING_DIR)) {
|
|
16129
16106
|
return false;
|
|
16130
16107
|
}
|
|
16131
16108
|
const stagedFiles = findMdFilesRecursive(STAGING_DIR);
|
|
@@ -16134,7 +16111,7 @@ function processStagedFile() {
|
|
|
16134
16111
|
}
|
|
16135
16112
|
const { transcriptsDir, summaryDir } = getTranscriptConfig();
|
|
16136
16113
|
const stagedFile = stagedFiles[0];
|
|
16137
|
-
const content =
|
|
16114
|
+
const content = readFileSync33(stagedFile.absolutePath, "utf-8");
|
|
16138
16115
|
validateStagedContent(stagedFile.filename, content);
|
|
16139
16116
|
const stagedBaseName = getTranscriptBaseName(stagedFile.filename);
|
|
16140
16117
|
const transcriptFiles = findMdFilesRecursive(transcriptsDir);
|
|
@@ -16147,9 +16124,9 @@ function processStagedFile() {
|
|
|
16147
16124
|
);
|
|
16148
16125
|
process.exit(1);
|
|
16149
16126
|
}
|
|
16150
|
-
const destPath =
|
|
16127
|
+
const destPath = join41(summaryDir, matchingTranscript.relativePath);
|
|
16151
16128
|
const destDir = dirname22(destPath);
|
|
16152
|
-
if (!
|
|
16129
|
+
if (!existsSync41(destDir)) {
|
|
16153
16130
|
mkdirSync15(destDir, { recursive: true });
|
|
16154
16131
|
}
|
|
16155
16132
|
renameSync4(stagedFile.absolutePath, destPath);
|
|
@@ -16163,20 +16140,20 @@ function processStagedFile() {
|
|
|
16163
16140
|
// src/commands/transcript/summarise/index.ts
|
|
16164
16141
|
function buildRelativeKey(relativePath, baseName) {
|
|
16165
16142
|
const relDir = dirname23(relativePath);
|
|
16166
|
-
return relDir === "." ? baseName :
|
|
16143
|
+
return relDir === "." ? baseName : join42(relDir, baseName);
|
|
16167
16144
|
}
|
|
16168
16145
|
function buildSummaryIndex(summaryDir) {
|
|
16169
16146
|
const summaryFiles = findMdFilesRecursive(summaryDir);
|
|
16170
16147
|
return new Set(
|
|
16171
16148
|
summaryFiles.map(
|
|
16172
|
-
(f) => buildRelativeKey(f.relativePath,
|
|
16149
|
+
(f) => buildRelativeKey(f.relativePath, basename9(f.filename, ".md"))
|
|
16173
16150
|
)
|
|
16174
16151
|
);
|
|
16175
16152
|
}
|
|
16176
16153
|
function summarise3() {
|
|
16177
16154
|
processStagedFile();
|
|
16178
16155
|
const { transcriptsDir, summaryDir } = getTranscriptConfig();
|
|
16179
|
-
if (!
|
|
16156
|
+
if (!existsSync42(transcriptsDir)) {
|
|
16180
16157
|
console.log("No transcripts directory found.");
|
|
16181
16158
|
return;
|
|
16182
16159
|
}
|
|
@@ -16197,8 +16174,8 @@ function summarise3() {
|
|
|
16197
16174
|
}
|
|
16198
16175
|
const next3 = missing[0];
|
|
16199
16176
|
const outputFilename = `${getTranscriptBaseName(next3.filename)}.md`;
|
|
16200
|
-
const outputPath =
|
|
16201
|
-
const summaryFileDir =
|
|
16177
|
+
const outputPath = join42(STAGING_DIR, outputFilename);
|
|
16178
|
+
const summaryFileDir = join42(summaryDir, dirname23(next3.relativePath));
|
|
16202
16179
|
const relativeTranscriptPath = encodeURI(
|
|
16203
16180
|
relative3(summaryFileDir, next3.absolutePath).replace(/\\/g, "/")
|
|
16204
16181
|
);
|
|
@@ -16248,50 +16225,50 @@ function registerVerify(program2) {
|
|
|
16248
16225
|
|
|
16249
16226
|
// src/commands/voice/devices.ts
|
|
16250
16227
|
import { spawnSync as spawnSync4 } from "child_process";
|
|
16251
|
-
import { join as
|
|
16228
|
+
import { join as join44 } from "path";
|
|
16252
16229
|
|
|
16253
16230
|
// src/commands/voice/shared.ts
|
|
16254
|
-
import { homedir as
|
|
16255
|
-
import { dirname as dirname24, join as
|
|
16231
|
+
import { homedir as homedir12 } from "os";
|
|
16232
|
+
import { dirname as dirname24, join as join43 } from "path";
|
|
16256
16233
|
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
16257
16234
|
var __dirname6 = dirname24(fileURLToPath6(import.meta.url));
|
|
16258
|
-
var VOICE_DIR =
|
|
16235
|
+
var VOICE_DIR = join43(homedir12(), ".assist", "voice");
|
|
16259
16236
|
var voicePaths = {
|
|
16260
16237
|
dir: VOICE_DIR,
|
|
16261
|
-
pid:
|
|
16262
|
-
log:
|
|
16263
|
-
venv:
|
|
16264
|
-
lock:
|
|
16238
|
+
pid: join43(VOICE_DIR, "voice.pid"),
|
|
16239
|
+
log: join43(VOICE_DIR, "voice.log"),
|
|
16240
|
+
venv: join43(VOICE_DIR, ".venv"),
|
|
16241
|
+
lock: join43(VOICE_DIR, "voice.lock")
|
|
16265
16242
|
};
|
|
16266
16243
|
function getPythonDir() {
|
|
16267
|
-
return
|
|
16244
|
+
return join43(__dirname6, "commands", "voice", "python");
|
|
16268
16245
|
}
|
|
16269
16246
|
function getVenvPython() {
|
|
16270
|
-
return process.platform === "win32" ?
|
|
16247
|
+
return process.platform === "win32" ? join43(voicePaths.venv, "Scripts", "python.exe") : join43(voicePaths.venv, "bin", "python");
|
|
16271
16248
|
}
|
|
16272
16249
|
function getLockDir() {
|
|
16273
16250
|
const config = loadConfig();
|
|
16274
16251
|
return config.voice?.lockDir ?? VOICE_DIR;
|
|
16275
16252
|
}
|
|
16276
16253
|
function getLockFile() {
|
|
16277
|
-
return
|
|
16254
|
+
return join43(getLockDir(), "voice.lock");
|
|
16278
16255
|
}
|
|
16279
16256
|
|
|
16280
16257
|
// src/commands/voice/devices.ts
|
|
16281
16258
|
function devices() {
|
|
16282
|
-
const script =
|
|
16259
|
+
const script = join44(getPythonDir(), "list_devices.py");
|
|
16283
16260
|
spawnSync4(getVenvPython(), [script], { stdio: "inherit" });
|
|
16284
16261
|
}
|
|
16285
16262
|
|
|
16286
16263
|
// src/commands/voice/logs.ts
|
|
16287
|
-
import { existsSync as
|
|
16264
|
+
import { existsSync as existsSync43, readFileSync as readFileSync34 } from "fs";
|
|
16288
16265
|
function logs(options2) {
|
|
16289
|
-
if (!
|
|
16266
|
+
if (!existsSync43(voicePaths.log)) {
|
|
16290
16267
|
console.log("No voice log file found");
|
|
16291
16268
|
return;
|
|
16292
16269
|
}
|
|
16293
16270
|
const count6 = Number.parseInt(options2.lines ?? "150", 10);
|
|
16294
|
-
const content =
|
|
16271
|
+
const content = readFileSync34(voicePaths.log, "utf-8").trim();
|
|
16295
16272
|
if (!content) {
|
|
16296
16273
|
console.log("Voice log is empty");
|
|
16297
16274
|
return;
|
|
@@ -16314,12 +16291,12 @@ function logs(options2) {
|
|
|
16314
16291
|
// src/commands/voice/setup.ts
|
|
16315
16292
|
import { spawnSync as spawnSync5 } from "child_process";
|
|
16316
16293
|
import { mkdirSync as mkdirSync17 } from "fs";
|
|
16317
|
-
import { join as
|
|
16294
|
+
import { join as join46 } from "path";
|
|
16318
16295
|
|
|
16319
16296
|
// src/commands/voice/checkLockFile.ts
|
|
16320
16297
|
import { execSync as execSync45 } from "child_process";
|
|
16321
|
-
import { existsSync as
|
|
16322
|
-
import { join as
|
|
16298
|
+
import { existsSync as existsSync44, mkdirSync as mkdirSync16, readFileSync as readFileSync35, writeFileSync as writeFileSync28 } from "fs";
|
|
16299
|
+
import { join as join45 } from "path";
|
|
16323
16300
|
function isProcessAlive2(pid) {
|
|
16324
16301
|
try {
|
|
16325
16302
|
process.kill(pid, 0);
|
|
@@ -16330,9 +16307,9 @@ function isProcessAlive2(pid) {
|
|
|
16330
16307
|
}
|
|
16331
16308
|
function checkLockFile() {
|
|
16332
16309
|
const lockFile = getLockFile();
|
|
16333
|
-
if (!
|
|
16310
|
+
if (!existsSync44(lockFile)) return;
|
|
16334
16311
|
try {
|
|
16335
|
-
const lock = JSON.parse(
|
|
16312
|
+
const lock = JSON.parse(readFileSync35(lockFile, "utf-8"));
|
|
16336
16313
|
if (lock.pid && isProcessAlive2(lock.pid)) {
|
|
16337
16314
|
console.error(
|
|
16338
16315
|
`Voice daemon already running (PID ${lock.pid}, env: ${lock.env}). Stop it first with: assist voice stop`
|
|
@@ -16343,7 +16320,7 @@ function checkLockFile() {
|
|
|
16343
16320
|
}
|
|
16344
16321
|
}
|
|
16345
16322
|
function bootstrapVenv() {
|
|
16346
|
-
if (
|
|
16323
|
+
if (existsSync44(getVenvPython())) return;
|
|
16347
16324
|
console.log("Setting up Python environment...");
|
|
16348
16325
|
const pythonDir = getPythonDir();
|
|
16349
16326
|
execSync45(
|
|
@@ -16356,8 +16333,8 @@ function bootstrapVenv() {
|
|
|
16356
16333
|
}
|
|
16357
16334
|
function writeLockFile(pid) {
|
|
16358
16335
|
const lockFile = getLockFile();
|
|
16359
|
-
mkdirSync16(
|
|
16360
|
-
|
|
16336
|
+
mkdirSync16(join45(lockFile, ".."), { recursive: true });
|
|
16337
|
+
writeFileSync28(
|
|
16361
16338
|
lockFile,
|
|
16362
16339
|
JSON.stringify({
|
|
16363
16340
|
pid,
|
|
@@ -16372,7 +16349,7 @@ function setup() {
|
|
|
16372
16349
|
mkdirSync17(voicePaths.dir, { recursive: true });
|
|
16373
16350
|
bootstrapVenv();
|
|
16374
16351
|
console.log("\nDownloading models...\n");
|
|
16375
|
-
const script =
|
|
16352
|
+
const script = join46(getPythonDir(), "setup_models.py");
|
|
16376
16353
|
const result = spawnSync5(getVenvPython(), [script], {
|
|
16377
16354
|
stdio: "inherit",
|
|
16378
16355
|
env: { ...process.env, VOICE_LOG_FILE: voicePaths.log }
|
|
@@ -16385,8 +16362,8 @@ function setup() {
|
|
|
16385
16362
|
|
|
16386
16363
|
// src/commands/voice/start.ts
|
|
16387
16364
|
import { spawn as spawn7 } from "child_process";
|
|
16388
|
-
import { mkdirSync as mkdirSync18, writeFileSync as
|
|
16389
|
-
import { join as
|
|
16365
|
+
import { mkdirSync as mkdirSync18, writeFileSync as writeFileSync29 } from "fs";
|
|
16366
|
+
import { join as join47 } from "path";
|
|
16390
16367
|
|
|
16391
16368
|
// src/commands/voice/buildDaemonEnv.ts
|
|
16392
16369
|
function buildDaemonEnv(options2) {
|
|
@@ -16414,7 +16391,7 @@ function spawnBackground(python, script, env) {
|
|
|
16414
16391
|
console.error("Failed to start voice daemon");
|
|
16415
16392
|
process.exit(1);
|
|
16416
16393
|
}
|
|
16417
|
-
|
|
16394
|
+
writeFileSync29(voicePaths.pid, String(pid));
|
|
16418
16395
|
writeLockFile(pid);
|
|
16419
16396
|
console.log(`Voice daemon started (PID ${pid})`);
|
|
16420
16397
|
}
|
|
@@ -16424,7 +16401,7 @@ function start2(options2) {
|
|
|
16424
16401
|
bootstrapVenv();
|
|
16425
16402
|
const debug = options2.debug || options2.foreground || process.platform === "win32";
|
|
16426
16403
|
const env = buildDaemonEnv({ debug });
|
|
16427
|
-
const script =
|
|
16404
|
+
const script = join47(getPythonDir(), "voice_daemon.py");
|
|
16428
16405
|
const python = getVenvPython();
|
|
16429
16406
|
if (options2.foreground) {
|
|
16430
16407
|
spawnForeground(python, script, env);
|
|
@@ -16434,7 +16411,7 @@ function start2(options2) {
|
|
|
16434
16411
|
}
|
|
16435
16412
|
|
|
16436
16413
|
// src/commands/voice/status.ts
|
|
16437
|
-
import { existsSync as
|
|
16414
|
+
import { existsSync as existsSync45, readFileSync as readFileSync36 } from "fs";
|
|
16438
16415
|
function isProcessAlive3(pid) {
|
|
16439
16416
|
try {
|
|
16440
16417
|
process.kill(pid, 0);
|
|
@@ -16444,16 +16421,16 @@ function isProcessAlive3(pid) {
|
|
|
16444
16421
|
}
|
|
16445
16422
|
}
|
|
16446
16423
|
function readRecentLogs(count6) {
|
|
16447
|
-
if (!
|
|
16448
|
-
const lines =
|
|
16424
|
+
if (!existsSync45(voicePaths.log)) return [];
|
|
16425
|
+
const lines = readFileSync36(voicePaths.log, "utf-8").trim().split("\n");
|
|
16449
16426
|
return lines.slice(-count6);
|
|
16450
16427
|
}
|
|
16451
16428
|
function status() {
|
|
16452
|
-
if (!
|
|
16429
|
+
if (!existsSync45(voicePaths.pid)) {
|
|
16453
16430
|
console.log("Voice daemon: not running (no PID file)");
|
|
16454
16431
|
return;
|
|
16455
16432
|
}
|
|
16456
|
-
const pid = Number.parseInt(
|
|
16433
|
+
const pid = Number.parseInt(readFileSync36(voicePaths.pid, "utf-8").trim(), 10);
|
|
16457
16434
|
const alive = isProcessAlive3(pid);
|
|
16458
16435
|
console.log(`Voice daemon: ${alive ? "running" : "dead"} (PID ${pid})`);
|
|
16459
16436
|
const recent = readRecentLogs(5);
|
|
@@ -16472,13 +16449,13 @@ function status() {
|
|
|
16472
16449
|
}
|
|
16473
16450
|
|
|
16474
16451
|
// src/commands/voice/stop.ts
|
|
16475
|
-
import { existsSync as
|
|
16452
|
+
import { existsSync as existsSync46, readFileSync as readFileSync37, unlinkSync as unlinkSync14 } from "fs";
|
|
16476
16453
|
function stop2() {
|
|
16477
|
-
if (!
|
|
16454
|
+
if (!existsSync46(voicePaths.pid)) {
|
|
16478
16455
|
console.log("Voice daemon is not running (no PID file)");
|
|
16479
16456
|
return;
|
|
16480
16457
|
}
|
|
16481
|
-
const pid = Number.parseInt(
|
|
16458
|
+
const pid = Number.parseInt(readFileSync37(voicePaths.pid, "utf-8").trim(), 10);
|
|
16482
16459
|
try {
|
|
16483
16460
|
process.kill(pid, "SIGTERM");
|
|
16484
16461
|
console.log(`Sent SIGTERM to voice daemon (PID ${pid})`);
|
|
@@ -16491,7 +16468,7 @@ function stop2() {
|
|
|
16491
16468
|
}
|
|
16492
16469
|
try {
|
|
16493
16470
|
const lockFile = getLockFile();
|
|
16494
|
-
if (
|
|
16471
|
+
if (existsSync46(lockFile)) unlinkSync14(lockFile);
|
|
16495
16472
|
} catch {
|
|
16496
16473
|
}
|
|
16497
16474
|
console.log("Voice daemon stopped");
|
|
@@ -16713,8 +16690,8 @@ async function auth() {
|
|
|
16713
16690
|
|
|
16714
16691
|
// src/commands/roam/postRoamActivity.ts
|
|
16715
16692
|
import { execFileSync as execFileSync7 } from "child_process";
|
|
16716
|
-
import { readdirSync as readdirSync7, readFileSync as
|
|
16717
|
-
import { join as
|
|
16693
|
+
import { readdirSync as readdirSync7, readFileSync as readFileSync38, statSync as statSync5 } from "fs";
|
|
16694
|
+
import { join as join48 } from "path";
|
|
16718
16695
|
function findPortFile(roamDir) {
|
|
16719
16696
|
let entries;
|
|
16720
16697
|
try {
|
|
@@ -16723,7 +16700,7 @@ function findPortFile(roamDir) {
|
|
|
16723
16700
|
return void 0;
|
|
16724
16701
|
}
|
|
16725
16702
|
const candidates = entries.filter((name) => /^roam-local-api(-[^.]+)?\.port$/.test(name)).map((name) => {
|
|
16726
|
-
const path53 =
|
|
16703
|
+
const path53 = join48(roamDir, name);
|
|
16727
16704
|
try {
|
|
16728
16705
|
return { path: path53, mtimeMs: statSync5(path53).mtimeMs };
|
|
16729
16706
|
} catch {
|
|
@@ -16735,11 +16712,11 @@ function findPortFile(roamDir) {
|
|
|
16735
16712
|
function postRoamActivity(app, event) {
|
|
16736
16713
|
const appData = process.env.APPDATA;
|
|
16737
16714
|
if (!appData) return;
|
|
16738
|
-
const portFile = findPortFile(
|
|
16715
|
+
const portFile = findPortFile(join48(appData, "Roam"));
|
|
16739
16716
|
if (!portFile) return;
|
|
16740
16717
|
let port;
|
|
16741
16718
|
try {
|
|
16742
|
-
port =
|
|
16719
|
+
port = readFileSync38(portFile, "utf-8").trim();
|
|
16743
16720
|
} catch {
|
|
16744
16721
|
return;
|
|
16745
16722
|
}
|
|
@@ -16881,15 +16858,15 @@ function runPreCommands(pre, cwd) {
|
|
|
16881
16858
|
|
|
16882
16859
|
// src/commands/run/spawnRunCommand.ts
|
|
16883
16860
|
import { execFileSync as execFileSync8, spawn as spawn8 } from "child_process";
|
|
16884
|
-
import { existsSync as
|
|
16885
|
-
import { dirname as dirname25, join as
|
|
16861
|
+
import { existsSync as existsSync47 } from "fs";
|
|
16862
|
+
import { dirname as dirname25, join as join49, resolve as resolve11 } from "path";
|
|
16886
16863
|
function resolveCommand2(command) {
|
|
16887
16864
|
if (process.platform !== "win32" || command !== "bash") return command;
|
|
16888
16865
|
try {
|
|
16889
16866
|
const gitPath = execFileSync8("where", ["git"], { encoding: "utf8" }).trim().split("\r\n")[0];
|
|
16890
16867
|
const gitRoot = resolve11(dirname25(gitPath), "..");
|
|
16891
|
-
const gitBash =
|
|
16892
|
-
if (
|
|
16868
|
+
const gitBash = join49(gitRoot, "bin", "bash.exe");
|
|
16869
|
+
if (existsSync47(gitBash)) return gitBash;
|
|
16893
16870
|
} catch {
|
|
16894
16871
|
}
|
|
16895
16872
|
return command;
|
|
@@ -16974,8 +16951,8 @@ async function run3(name, args) {
|
|
|
16974
16951
|
}
|
|
16975
16952
|
|
|
16976
16953
|
// src/commands/run/add.ts
|
|
16977
|
-
import { mkdirSync as mkdirSync19, writeFileSync as
|
|
16978
|
-
import { join as
|
|
16954
|
+
import { mkdirSync as mkdirSync19, writeFileSync as writeFileSync30 } from "fs";
|
|
16955
|
+
import { join as join50 } from "path";
|
|
16979
16956
|
|
|
16980
16957
|
// src/commands/run/extractOption.ts
|
|
16981
16958
|
function extractOption(args, flag) {
|
|
@@ -17036,7 +17013,7 @@ function saveNewRunConfig(name, command, args, cwd) {
|
|
|
17036
17013
|
saveConfig(config);
|
|
17037
17014
|
}
|
|
17038
17015
|
function createCommandFile(name) {
|
|
17039
|
-
const dir =
|
|
17016
|
+
const dir = join50(".claude", "commands");
|
|
17040
17017
|
mkdirSync19(dir, { recursive: true });
|
|
17041
17018
|
const content = `---
|
|
17042
17019
|
description: Run ${name}
|
|
@@ -17044,8 +17021,8 @@ description: Run ${name}
|
|
|
17044
17021
|
|
|
17045
17022
|
Run \`assist run ${name} $ARGUMENTS 2>&1\`.
|
|
17046
17023
|
`;
|
|
17047
|
-
const filePath =
|
|
17048
|
-
|
|
17024
|
+
const filePath = join50(dir, `${name}.md`);
|
|
17025
|
+
writeFileSync30(filePath, content);
|
|
17049
17026
|
console.log(`Created command file: ${filePath}`);
|
|
17050
17027
|
}
|
|
17051
17028
|
function add3() {
|
|
@@ -17100,8 +17077,8 @@ function link2() {
|
|
|
17100
17077
|
}
|
|
17101
17078
|
|
|
17102
17079
|
// src/commands/run/remove.ts
|
|
17103
|
-
import { existsSync as
|
|
17104
|
-
import { join as
|
|
17080
|
+
import { existsSync as existsSync48, unlinkSync as unlinkSync15 } from "fs";
|
|
17081
|
+
import { join as join51 } from "path";
|
|
17105
17082
|
function findRemoveIndex() {
|
|
17106
17083
|
const idx = process.argv.indexOf("remove");
|
|
17107
17084
|
if (idx === -1 || idx + 1 >= process.argv.length) return -1;
|
|
@@ -17116,8 +17093,8 @@ function parseRemoveName() {
|
|
|
17116
17093
|
return process.argv[idx + 1];
|
|
17117
17094
|
}
|
|
17118
17095
|
function deleteCommandFile(name) {
|
|
17119
|
-
const filePath =
|
|
17120
|
-
if (
|
|
17096
|
+
const filePath = join51(".claude", "commands", `${name}.md`);
|
|
17097
|
+
if (existsSync48(filePath)) {
|
|
17121
17098
|
unlinkSync15(filePath);
|
|
17122
17099
|
console.log(`Deleted command file: ${filePath}`);
|
|
17123
17100
|
}
|
|
@@ -17156,9 +17133,9 @@ function registerRun(program2) {
|
|
|
17156
17133
|
|
|
17157
17134
|
// src/commands/screenshot/index.ts
|
|
17158
17135
|
import { execSync as execSync48 } from "child_process";
|
|
17159
|
-
import { existsSync as
|
|
17136
|
+
import { existsSync as existsSync49, mkdirSync as mkdirSync20, unlinkSync as unlinkSync16, writeFileSync as writeFileSync31 } from "fs";
|
|
17160
17137
|
import { tmpdir as tmpdir7 } from "os";
|
|
17161
|
-
import { join as
|
|
17138
|
+
import { join as join52, resolve as resolve13 } from "path";
|
|
17162
17139
|
import chalk158 from "chalk";
|
|
17163
17140
|
|
|
17164
17141
|
// src/commands/screenshot/captureWindowPs1.ts
|
|
@@ -17288,15 +17265,15 @@ Write-Output $OutputPath
|
|
|
17288
17265
|
|
|
17289
17266
|
// src/commands/screenshot/index.ts
|
|
17290
17267
|
function buildOutputPath(outputDir, processName) {
|
|
17291
|
-
if (!
|
|
17268
|
+
if (!existsSync49(outputDir)) {
|
|
17292
17269
|
mkdirSync20(outputDir, { recursive: true });
|
|
17293
17270
|
}
|
|
17294
17271
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
17295
17272
|
return resolve13(outputDir, `${processName}-${timestamp}.png`);
|
|
17296
17273
|
}
|
|
17297
17274
|
function runPowerShellScript(processName, outputPath) {
|
|
17298
|
-
const scriptPath =
|
|
17299
|
-
|
|
17275
|
+
const scriptPath = join52(tmpdir7(), `assist-screenshot-${Date.now()}.ps1`);
|
|
17276
|
+
writeFileSync31(scriptPath, captureWindowPs1, "utf-8");
|
|
17300
17277
|
try {
|
|
17301
17278
|
execSync48(
|
|
17302
17279
|
`powershell -NoProfile -ExecutionPolicy Bypass -File "${scriptPath}" -ProcessName "${processName}" -OutputPath "${outputPath}"`,
|
|
@@ -17372,7 +17349,7 @@ function applyLine(result, pending, line) {
|
|
|
17372
17349
|
}
|
|
17373
17350
|
|
|
17374
17351
|
// src/commands/sessions/daemon/reportStolenSocket.ts
|
|
17375
|
-
import { readFileSync as
|
|
17352
|
+
import { readFileSync as readFileSync39 } from "fs";
|
|
17376
17353
|
function reportStolenSocket(socketPid) {
|
|
17377
17354
|
if (!socketPid) return;
|
|
17378
17355
|
const filePid = readPidFile();
|
|
@@ -17384,7 +17361,7 @@ function reportStolenSocket(socketPid) {
|
|
|
17384
17361
|
function readPidFile() {
|
|
17385
17362
|
try {
|
|
17386
17363
|
const pid = Number.parseInt(
|
|
17387
|
-
|
|
17364
|
+
readFileSync39(daemonPaths.pid, "utf-8").trim(),
|
|
17388
17365
|
10
|
|
17389
17366
|
);
|
|
17390
17367
|
return Number.isInteger(pid) ? pid : void 0;
|
|
@@ -17706,7 +17683,7 @@ function broadcastSessions(sessions, clients) {
|
|
|
17706
17683
|
import * as pty from "node-pty";
|
|
17707
17684
|
|
|
17708
17685
|
// src/commands/sessions/daemon/ensureSpawnHelperExecutable.ts
|
|
17709
|
-
import { chmodSync, existsSync as
|
|
17686
|
+
import { chmodSync, existsSync as existsSync50, statSync as statSync6 } from "fs";
|
|
17710
17687
|
import { createRequire as createRequire3 } from "module";
|
|
17711
17688
|
import path47 from "path";
|
|
17712
17689
|
var require4 = createRequire3(import.meta.url);
|
|
@@ -17721,7 +17698,7 @@ function ensureSpawnHelperExecutable() {
|
|
|
17721
17698
|
`${process.platform}-${process.arch}`,
|
|
17722
17699
|
"spawn-helper"
|
|
17723
17700
|
);
|
|
17724
|
-
if (!
|
|
17701
|
+
if (!existsSync50(helper)) return;
|
|
17725
17702
|
const mode = statSync6(helper).mode;
|
|
17726
17703
|
if ((mode & 73) === 0) chmodSync(helper, mode | 493);
|
|
17727
17704
|
}
|
|
@@ -17948,7 +17925,7 @@ function clearIdle(session) {
|
|
|
17948
17925
|
}
|
|
17949
17926
|
|
|
17950
17927
|
// src/commands/sessions/daemon/watchActivity.ts
|
|
17951
|
-
import { existsSync as
|
|
17928
|
+
import { existsSync as existsSync51, mkdirSync as mkdirSync21, watch } from "fs";
|
|
17952
17929
|
import { dirname as dirname27 } from "path";
|
|
17953
17930
|
var DEBOUNCE_MS = 50;
|
|
17954
17931
|
function watchActivity(session, notify2) {
|
|
@@ -17975,7 +17952,7 @@ function watchActivity(session, notify2) {
|
|
|
17975
17952
|
if (timer) clearTimeout(timer);
|
|
17976
17953
|
timer = setTimeout(read, DEBOUNCE_MS);
|
|
17977
17954
|
});
|
|
17978
|
-
if (
|
|
17955
|
+
if (existsSync51(path53)) read();
|
|
17979
17956
|
}
|
|
17980
17957
|
function refreshActivity(session) {
|
|
17981
17958
|
if (session.commandType !== "assist" || !session.cwd) return;
|
|
@@ -18344,10 +18321,10 @@ function handleConnection(socket, manager) {
|
|
|
18344
18321
|
}
|
|
18345
18322
|
|
|
18346
18323
|
// src/commands/sessions/daemon/onListening.ts
|
|
18347
|
-
import { unlinkSync as unlinkSync17, writeFileSync as
|
|
18324
|
+
import { unlinkSync as unlinkSync17, writeFileSync as writeFileSync32 } from "fs";
|
|
18348
18325
|
|
|
18349
18326
|
// src/commands/sessions/daemon/startPidFileWatchdog.ts
|
|
18350
|
-
import { readFileSync as
|
|
18327
|
+
import { readFileSync as readFileSync40 } from "fs";
|
|
18351
18328
|
var WATCHDOG_INTERVAL_MS = 5e3;
|
|
18352
18329
|
function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
|
|
18353
18330
|
const timer = setInterval(() => {
|
|
@@ -18358,7 +18335,7 @@ function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
|
|
|
18358
18335
|
}
|
|
18359
18336
|
function ownsPidFile() {
|
|
18360
18337
|
try {
|
|
18361
|
-
return
|
|
18338
|
+
return readFileSync40(daemonPaths.pid, "utf-8").trim() === String(process.pid);
|
|
18362
18339
|
} catch {
|
|
18363
18340
|
return false;
|
|
18364
18341
|
}
|
|
@@ -18366,7 +18343,7 @@ function ownsPidFile() {
|
|
|
18366
18343
|
|
|
18367
18344
|
// src/commands/sessions/daemon/onListening.ts
|
|
18368
18345
|
function onListening(manager, checkAutoExit) {
|
|
18369
|
-
|
|
18346
|
+
writeFileSync32(daemonPaths.pid, String(process.pid));
|
|
18370
18347
|
startPidFileWatchdog(() => {
|
|
18371
18348
|
daemonLog("lost daemon.pid ownership; shutting down sessions and exiting");
|
|
18372
18349
|
manager.shutdown();
|