@staff0rd/assist 0.1015.1 → 0.1015.2

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 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.1015.1",
9
+ version: "0.1015.2",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -911,6 +911,7 @@ var adviceFragmentTitles = {
911
911
  "code-comments": "Commenting code",
912
912
  "drafting-messages": "Drafting messages to send on the user's behalf",
913
913
  "editing-files": "Editing files",
914
+ "fixing-commands": "Fixing command and skill misbehaviour",
914
915
  "filename-convention": "Naming files after their export",
915
916
  "jira-context": "Fetching Jira context",
916
917
  "jira-smart-links": "Editing Jira issues with Smart Links",
@@ -930,6 +931,7 @@ var adviceFragmentNames = [
930
931
  "code-comments",
931
932
  "drafting-messages",
932
933
  "editing-files",
934
+ "fixing-commands",
933
935
  "filename-convention",
934
936
  "jira-context",
935
937
  "jira-smart-links",
@@ -31186,8 +31188,8 @@ function resolveExtractPath(value, cwd) {
31186
31188
  function storedExtractPath(value, cwd) {
31187
31189
  if (value === void 0) return void 0;
31188
31190
  const absolute2 = resolve22(cwd, value);
31189
- const within = relative7(extractRoot(cwd), absolute2);
31190
- return within.startsWith("..") ? absolute2 : within;
31191
+ const within2 = relative7(extractRoot(cwd), absolute2);
31192
+ return within2.startsWith("..") ? absolute2 : within2;
31191
31193
  }
31192
31194
 
31193
31195
  // src/commands/miro/extractToSave.ts
@@ -43346,6 +43348,112 @@ function parseReply(line) {
43346
43348
  }
43347
43349
  }
43348
43350
 
43351
+ // src/commands/show/refuseSessionFiles.ts
43352
+ import { homedir as homedir28 } from "os";
43353
+
43354
+ // src/commands/show/findShownSessionFiles.ts
43355
+ var NOT_AFTER = String.raw`(?![\w\-/]|\.\w)`;
43356
+ var NOT_BEFORE_RELATIVE = String.raw`(?<=^|[^\w.\-/~]|(?:^|[^\w.\-/~])\./)`;
43357
+ function normalise(path109) {
43358
+ return path109.replaceAll("\\", "/").replace(/\/+$/, "");
43359
+ }
43360
+ function escapeRegExp2(text18) {
43361
+ return text18.replace(/[.*+?^${}()|[\]\\]/g, String.raw`\$&`);
43362
+ }
43363
+ function within(path109, dir) {
43364
+ return dir && path109.startsWith(`${dir}/`) ? path109.slice(dir.length + 1) : void 0;
43365
+ }
43366
+ function referencePatterns(path109, { home, cwd }) {
43367
+ const file = normalise(path109);
43368
+ const forms = [escapeRegExp2(file)];
43369
+ const drive = /^\/mnt\/([a-z])\/(.+)$/i.exec(file);
43370
+ if (drive)
43371
+ forms.push(
43372
+ `(?:${drive[1]}|${drive[1].toUpperCase()}):/${escapeRegExp2(drive[2])}`
43373
+ );
43374
+ const underHome = within(file, normalise(home));
43375
+ if (underHome) forms.push(`~/${escapeRegExp2(underHome)}`);
43376
+ const patterns = forms.map((form) => new RegExp(`${form}${NOT_AFTER}`));
43377
+ const relative8 = within(file, normalise(cwd));
43378
+ if (relative8)
43379
+ patterns.push(
43380
+ new RegExp(`${NOT_BEFORE_RELATIVE}${escapeRegExp2(relative8)}${NOT_AFTER}`)
43381
+ );
43382
+ return patterns;
43383
+ }
43384
+ function findShownSessionFiles(body, writtenPaths, locations) {
43385
+ const text18 = body.replaceAll("\\", "/");
43386
+ return writtenPaths.filter(
43387
+ (path109) => referencePatterns(path109, locations).some((pattern2) => pattern2.test(text18))
43388
+ );
43389
+ }
43390
+
43391
+ // src/commands/show/sessionWrittenPaths.ts
43392
+ import { readFileSync as readFileSync60 } from "fs";
43393
+
43394
+ // src/commands/sessions/shared/asRecord.ts
43395
+ function asRecord(value) {
43396
+ return value && typeof value === "object" ? value : null;
43397
+ }
43398
+
43399
+ // src/commands/sessions/shared/writtenFilePaths.ts
43400
+ var WRITE_TOOLS2 = /* @__PURE__ */ new Set(["Write", "Edit", "MultiEdit", "NotebookEdit"]);
43401
+ function writtenFilePaths(entry) {
43402
+ if (entry.type !== "assistant") return [];
43403
+ const content = asRecord(entry.message)?.content;
43404
+ if (!Array.isArray(content)) return [];
43405
+ const paths = [];
43406
+ for (const block of content) {
43407
+ const b = asRecord(block);
43408
+ if (b?.type !== "tool_use" || !WRITE_TOOLS2.has(String(b.name))) continue;
43409
+ const input = asRecord(b.input);
43410
+ const path109 = input?.file_path ?? input?.notebook_path;
43411
+ if (typeof path109 === "string") paths.push(path109);
43412
+ }
43413
+ return paths;
43414
+ }
43415
+
43416
+ // src/commands/show/sessionWrittenPaths.ts
43417
+ function sessionWrittenPaths(transcriptPath2) {
43418
+ let text18;
43419
+ try {
43420
+ text18 = readFileSync60(transcriptPath2, "utf8");
43421
+ } catch {
43422
+ return [];
43423
+ }
43424
+ const paths = /* @__PURE__ */ new Set();
43425
+ for (const line of text18.split("\n")) {
43426
+ if (!line.includes('"tool_use"')) continue;
43427
+ try {
43428
+ for (const path109 of writtenFilePaths(JSON.parse(line))) paths.add(path109);
43429
+ } catch {
43430
+ }
43431
+ }
43432
+ return [...paths];
43433
+ }
43434
+
43435
+ // src/commands/show/refuseSessionFiles.ts
43436
+ function refuseSessionFiles(body) {
43437
+ const claudeSessionId = process.env.CLAUDE_CODE_SESSION_ID;
43438
+ if (!claudeSessionId) return;
43439
+ const transcript = resolveSessionTranscript(claudeSessionId);
43440
+ if (!transcript) return;
43441
+ const shown = findShownSessionFiles(
43442
+ body,
43443
+ sessionWrittenPaths(transcript.path),
43444
+ { home: homedir28(), cwd: process.cwd() }
43445
+ );
43446
+ if (shown.length === 0) return;
43447
+ console.error(
43448
+ [
43449
+ "Error: refusing to show files this session created or edited; the user already sees them in the session's diff:",
43450
+ ...shown.map((path109) => ` ${path109}`),
43451
+ "Remove them (and any label or folder entry that exists only for them) and re-run, or skip the show if nothing is left."
43452
+ ].join("\n")
43453
+ );
43454
+ process.exit(1);
43455
+ }
43456
+
43349
43457
  // src/commands/show.ts
43350
43458
  async function show3(options2) {
43351
43459
  const body = await readBodyArgument(options2.body);
@@ -43353,6 +43461,7 @@ async function show3(options2) {
43353
43461
  console.error("Error: --body is empty; there is nothing to show.");
43354
43462
  process.exit(1);
43355
43463
  }
43464
+ refuseSessionFiles(body);
43356
43465
  const sessionId = process.env.ASSIST_SESSION_ID;
43357
43466
  if (process.env.ASSIST_SESSION !== "1" || !sessionId) {
43358
43467
  console.log(body);
@@ -43427,12 +43536,12 @@ import { mkdirSync as mkdirSync31, writeFileSync as writeFileSync48 } from "fs";
43427
43536
  import { mkdirSync as mkdirSync30, writeFileSync as writeFileSync47 } from "fs";
43428
43537
 
43429
43538
  // src/commands/slack/readSlackParts.ts
43430
- import { readFileSync as readFileSync60 } from "fs";
43539
+ import { readFileSync as readFileSync61 } from "fs";
43431
43540
  function readSlackParts(files) {
43432
43541
  return files.map((file) => {
43433
43542
  let contents;
43434
43543
  try {
43435
- contents = readFileSync60(file, "utf8");
43544
+ contents = readFileSync61(file, "utf8");
43436
43545
  } catch {
43437
43546
  console.error(`Error: Part file not found: ${file}`);
43438
43547
  process.exit(1);
@@ -44546,9 +44655,9 @@ function formatVttPassages(passages, notes = [], { sourceMarks = true } = {}) {
44546
44655
  }
44547
44656
 
44548
44657
  // src/commands/transcript/convert/readCleanedCues.ts
44549
- import { readFileSync as readFileSync65 } from "fs";
44658
+ import { readFileSync as readFileSync66 } from "fs";
44550
44659
  function readCleanedCues(inputPath) {
44551
- return deduplicateCues(parseVtt(readFileSync65(inputPath, "utf8")));
44660
+ return deduplicateCues(parseVtt(readFileSync66(inputPath, "utf8")));
44552
44661
  }
44553
44662
 
44554
44663
  // src/commands/transcript/clean.ts
@@ -45328,7 +45437,7 @@ function configKeys2() {
45328
45437
  }
45329
45438
 
45330
45439
  // src/commands/verify/forbiddenStrings.ts
45331
- import { existsSync as existsSync82, readFileSync as readFileSync66 } from "fs";
45440
+ import { existsSync as existsSync82, readFileSync as readFileSync67 } from "fs";
45332
45441
 
45333
45442
  // src/commands/verify/forbiddenStrings/findForbiddenStrings.ts
45334
45443
  import { minimatch as minimatch10 } from "minimatch";
@@ -45375,7 +45484,7 @@ function forbiddenStrings() {
45375
45484
  }
45376
45485
  let parsed;
45377
45486
  try {
45378
- parsed = JSON.parse(readFileSync66(file, "utf8"));
45487
+ parsed = JSON.parse(readFileSync67(file, "utf8"));
45379
45488
  } catch (error) {
45380
45489
  console.log(`Could not parse ${file}: ${error.message}`);
45381
45490
  process.exit(1);
@@ -45447,7 +45556,7 @@ Total: ${lines2.length} hardcoded color(s)`);
45447
45556
  }
45448
45557
 
45449
45558
  // src/commands/verify/migrations.ts
45450
- import { readFileSync as readFileSync67 } from "fs";
45559
+ import { readFileSync as readFileSync68 } from "fs";
45451
45560
  import path104 from "path";
45452
45561
 
45453
45562
  // src/commands/verify/migrations/checkAppendOnly.ts
@@ -45612,7 +45721,7 @@ function migrations2() {
45612
45721
  if (ref) {
45613
45722
  const baseline = readBaselineMigrations(REPO_RELATIVE_DIR, ref);
45614
45723
  const current = new Map(
45615
- files.map((file) => [file, readFileSync67(path104.join(dir, file), "utf8")])
45724
+ files.map((file) => [file, readFileSync68(path104.join(dir, file), "utf8")])
45616
45725
  );
45617
45726
  for (const finding of checkAppendOnly(baseline, current)) {
45618
45727
  problems.push(
@@ -46533,7 +46642,7 @@ function registerWatch(program) {
46533
46642
 
46534
46643
  // src/commands/roam/postRoamActivity.ts
46535
46644
  import { execFileSync as execFileSync30 } from "child_process";
46536
- import { readdirSync as readdirSync24, readFileSync as readFileSync68, statSync as statSync13 } from "fs";
46645
+ import { readdirSync as readdirSync24, readFileSync as readFileSync69, statSync as statSync13 } from "fs";
46537
46646
  import { join as join105 } from "path";
46538
46647
  function findPortFile(roamDir) {
46539
46648
  let entries;
@@ -46564,7 +46673,7 @@ function postRoamActivity(app, event) {
46564
46673
  if (!portFile) return;
46565
46674
  let port;
46566
46675
  try {
46567
- port = readFileSync68(portFile, "utf8").trim();
46676
+ port = readFileSync69(portFile, "utf8").trim();
46568
46677
  } catch {
46569
46678
  return;
46570
46679
  }
@@ -47185,11 +47294,11 @@ function applyLine(result, pending, line) {
47185
47294
  }
47186
47295
 
47187
47296
  // src/commands/sessions/daemon/readDaemonPidFile.ts
47188
- import { readFileSync as readFileSync69 } from "fs";
47297
+ import { readFileSync as readFileSync70 } from "fs";
47189
47298
  function readDaemonPidFile() {
47190
47299
  try {
47191
47300
  const pid = Number.parseInt(
47192
- readFileSync69(daemonPaths.pid, "utf8").trim(),
47301
+ readFileSync70(daemonPaths.pid, "utf8").trim(),
47193
47302
  10
47194
47303
  );
47195
47304
  return Number.isInteger(pid) ? pid : void 0;
@@ -47874,31 +47983,7 @@ function findServerParents(sessions, file) {
47874
47983
 
47875
47984
  // src/commands/sessions/daemon/lastWriteTimes.ts
47876
47985
  import { readFile as readFile9 } from "fs/promises";
47877
-
47878
- // src/commands/sessions/shared/asRecord.ts
47879
- function asRecord(value) {
47880
- return value && typeof value === "object" ? value : null;
47881
- }
47882
-
47883
- // src/commands/sessions/shared/writtenFilePaths.ts
47884
- var WRITE_TOOLS2 = /* @__PURE__ */ new Set(["Write", "Edit", "MultiEdit", "NotebookEdit"]);
47885
- function writtenFilePaths(entry) {
47886
- if (entry.type !== "assistant") return [];
47887
- const content = asRecord(entry.message)?.content;
47888
- if (!Array.isArray(content)) return [];
47889
- const paths = [];
47890
- for (const block of content) {
47891
- const b = asRecord(block);
47892
- if (b?.type !== "tool_use" || !WRITE_TOOLS2.has(String(b.name))) continue;
47893
- const input = asRecord(b.input);
47894
- const path109 = input?.file_path ?? input?.notebook_path;
47895
- if (typeof path109 === "string") paths.push(path109);
47896
- }
47897
- return paths;
47898
- }
47899
-
47900
- // src/commands/sessions/daemon/lastWriteTimes.ts
47901
- function normalise(path109) {
47986
+ function normalise2(path109) {
47902
47987
  return path109.replaceAll("\\", "/");
47903
47988
  }
47904
47989
  function latest(current, at2) {
@@ -47917,7 +48002,7 @@ async function lastWriteTimes(transcriptPath2, target) {
47917
48002
  }
47918
48003
  const at2 = Date.parse(String(entry.timestamp));
47919
48004
  if (Number.isNaN(at2)) continue;
47920
- for (const path109 of writtenFilePaths(entry).map(normalise)) {
48005
+ for (const path109 of writtenFilePaths(entry).map(normalise2)) {
47921
48006
  if (path109.endsWith(`/${target.file}`))
47922
48007
  result.file = latest(result.file, at2);
47923
48008
  if (path109.includes(`/${target.within}`))
@@ -48081,7 +48166,7 @@ function sendResizeSnapshot(s, send) {
48081
48166
  }
48082
48167
 
48083
48168
  // src/commands/sessions/daemon/viewerSize.ts
48084
- import { readFileSync as readFileSync70, writeFileSync as writeFileSync58 } from "fs";
48169
+ import { readFileSync as readFileSync71, writeFileSync as writeFileSync58 } from "fs";
48085
48170
  var DEFAULT_SIZE = { cols: 120, rows: 30 };
48086
48171
  var remembered;
48087
48172
  function rememberViewerSize(cols, rows) {
@@ -48103,7 +48188,7 @@ function viewerSize() {
48103
48188
  function readSavedSize() {
48104
48189
  try {
48105
48190
  const { cols, rows } = JSON.parse(
48106
- readFileSync70(daemonPaths.viewerSize, "utf8")
48191
+ readFileSync71(daemonPaths.viewerSize, "utf8")
48107
48192
  );
48108
48193
  if (typeof cols === "number" && typeof rows === "number" && cols > 0)
48109
48194
  return { cols, rows };
@@ -48991,14 +49076,14 @@ async function runAutoUpdateLoop(deps2, maxLaps = Number.POSITIVE_INFINITY) {
48991
49076
  }
48992
49077
 
48993
49078
  // src/commands/sessions/daemon/autoUpdate/trimWatcherLog.ts
48994
- import { readFileSync as readFileSync72, writeFileSync as writeFileSync60 } from "fs";
49079
+ import { readFileSync as readFileSync73, writeFileSync as writeFileSync60 } from "fs";
48995
49080
  var KEEP_TAIL = 256 * 1024;
48996
49081
  var MAX_LOG_SIZE = 4 * 1024 * 1024;
48997
49082
  function trimWatcherLog(cwd) {
48998
49083
  const path109 = watcherLogPath(cwd);
48999
49084
  let log2;
49000
49085
  try {
49001
- log2 = readFileSync72(path109, "utf8");
49086
+ log2 = readFileSync73(path109, "utf8");
49002
49087
  } catch {
49003
49088
  return;
49004
49089
  }
@@ -54505,7 +54590,7 @@ function claudeMessages(line) {
54505
54590
  }
54506
54591
 
54507
54592
  // src/commands/sessions/daemon/historySearch/findTranscriptMatch.ts
54508
- function escapeRegExp2(text18) {
54593
+ function escapeRegExp3(text18) {
54509
54594
  return text18.replace(/[.*+?^${}()|[\]\\]/g, String.raw`\$&`);
54510
54595
  }
54511
54596
  function encodesVerbatimInJson(query) {
@@ -54524,7 +54609,7 @@ function matchTexts(texts, pattern2) {
54524
54609
  return null;
54525
54610
  }
54526
54611
  function queryPattern(query) {
54527
- return new RegExp(escapeRegExp2(query), "i");
54612
+ return new RegExp(escapeRegExp3(query), "i");
54528
54613
  }
54529
54614
  async function findTranscriptMatch(filePath, harness, query) {
54530
54615
  const pattern2 = queryPattern(query);
@@ -55416,7 +55501,7 @@ function handleConnection(socket, manager) {
55416
55501
  import { unlinkSync as unlinkSync22, writeFileSync as writeFileSync62 } from "fs";
55417
55502
 
55418
55503
  // src/commands/sessions/daemon/startPidFileWatchdog.ts
55419
- import { readFileSync as readFileSync73 } from "fs";
55504
+ import { readFileSync as readFileSync74 } from "fs";
55420
55505
  var WATCHDOG_INTERVAL_MS = 5e3;
55421
55506
  function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
55422
55507
  const timer = setInterval(() => {
@@ -55427,7 +55512,7 @@ function startPidFileWatchdog(onLost, intervalMs = WATCHDOG_INTERVAL_MS) {
55427
55512
  }
55428
55513
  function ownsPidFile() {
55429
55514
  try {
55430
- return readFileSync73(daemonPaths.pid, "utf8").trim() === String(process.pid);
55515
+ return readFileSync74(daemonPaths.pid, "utf8").trim() === String(process.pid);
55431
55516
  } catch {
55432
55517
  return false;
55433
55518
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.1015.1",
3
+ "version": "0.1015.2",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {