@staff0rd/assist 0.1000.1 → 0.1000.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.1000.1",
9
+ version: "0.1000.2",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -3774,9 +3774,13 @@ function docsRefreshAfter() {
3774
3774
  }
3775
3775
 
3776
3776
  // src/commands/backlog/buildDocsRefreshDescription.ts
3777
+ function summaryEntry(summary) {
3778
+ return summary.phase === null ? summary.text : `**Phase ${summary.phase}:** ${summary.text}`;
3779
+ }
3777
3780
  function storyEntry(story) {
3778
3781
  const lines2 = [`### ${formatItemId(story.id)} ${story.name}`, ""];
3779
- lines2.push(story.summary ?? "_No done summary._");
3782
+ if (story.summaries.length === 0) lines2.push("_No done summary._");
3783
+ else lines2.push(story.summaries.map(summaryEntry).join("\n\n"));
3780
3784
  if (story.commits.length > 0)
3781
3785
  lines2.push(
3782
3786
  "",
@@ -3787,7 +3791,7 @@ function storyEntry(story) {
3787
3791
  function buildDocsRefreshDescription(stories) {
3788
3792
  return [
3789
3793
  "Update the docs pages under `docs/src/content/docs/` from what these done stories shipped. Stories leave docs alone during development, so this item owns both the prose (wording, new behaviour on existing pages, removed features) and the `covers` entries that document new commands, skills, config keys and routes.",
3790
- "For detail on a story, run `assist backlog view <id>` (description, acceptance criteria, summaries and activity) and `git show <sha>` on its commits.",
3794
+ "Each story below lists the summary of every phase it completed. A story's later phases are often internal (tests, refactors, pipelines) while earlier phases shipped user-facing UI or commands, so judge a story on all of its phases and commits, never on its last summary alone. Summaries are lossy: run `assist backlog view <id>` (description, acceptance criteria, summaries and activity) and `git show --stat <sha>` then `git show <sha>` on its commits for the full picture.",
3791
3795
  "## Covered stories",
3792
3796
  ...stories.map(storyEntry)
3793
3797
  ].join("\n\n");
@@ -3842,16 +3846,19 @@ async function loadDocsRefreshStories(orm, ids) {
3842
3846
  if (ids.length === 0) return [];
3843
3847
  const [rows, summaries, commits2] = await Promise.all([
3844
3848
  orm.select({ id: items.id, name: items.name }).from(items).where(inArray2(items.id, ids)).orderBy(asc6(items.id)),
3845
- orm.select({ itemId: comments.itemId, text: comments.text }).from(comments).where(and5(inArray2(comments.itemId, ids), eq13(comments.type, "summary"))).orderBy(asc6(comments.id)),
3849
+ orm.select({
3850
+ itemId: comments.itemId,
3851
+ phase: comments.phase,
3852
+ text: comments.text
3853
+ }).from(comments).where(and5(inArray2(comments.itemId, ids), eq13(comments.type, "summary"))).orderBy(asc6(comments.id)),
3846
3854
  orm.select({ itemId: itemGitRefs.itemId, ref: itemGitRefs.ref }).from(itemGitRefs).where(
3847
3855
  and5(inArray2(itemGitRefs.itemId, ids), eq13(itemGitRefs.kind, "commit"))
3848
3856
  ).orderBy(asc6(itemGitRefs.createdAt))
3849
3857
  ]);
3850
- const latestSummary = new Map(summaries.map((s) => [s.itemId, s.text]));
3851
3858
  return rows.map((r) => ({
3852
3859
  id: r.id,
3853
3860
  name: r.name,
3854
- summary: latestSummary.get(r.id),
3861
+ summaries: summaries.filter((s) => s.itemId === r.id).map(({ phase, text: text18 }) => ({ phase, text: text18 })),
3855
3862
  commits: commits2.filter((c) => c.itemId === r.id).map((c) => c.ref)
3856
3863
  }));
3857
3864
  }
@@ -3886,16 +3893,16 @@ async function createDocsRefreshItem(orm, origin, storyIds, coverageCheck = hasD
3886
3893
  0,
3887
3894
  "Refresh docs",
3888
3895
  [
3889
- `Walk each covered story (${storyList}): read it with \`assist backlog view <id>\` and its commits with \`git show <sha>\`, and note what it changed for users`,
3890
- "Skip stories with no user-facing change and leave their pages untouched",
3896
+ `Walk each covered story (${storyList}) one at a time: run \`assist backlog view <id>\` for that story alone and read its full output (if the output is persisted to a file, read the file, not just the preview), then run \`git show --stat <sha>\` on every one of its commits and \`git show <sha>\` on any that touch UI, commands, config or other user-visible code; note everything it changed for users across all of its phases, not just its last summary`,
3897
+ "Skip a story only after inspecting all of its commits and finding no user-facing change (UI screens, notices, counts, commands, flags, config keys, apps); record a one-line reason for each skip, and leave pages untouched for skipped stories",
3891
3898
  "For the rest, update the affected pages under `docs/src/content/docs/` (wording, new behaviour on existing pages, removed features) following the rules in `docs/CLAUDE.md`",
3892
3899
  ...coverageCheck ? [
3893
3900
  "Run `assist run docs:coverage`; while it fails, list the gaps with `assist run docs:coverage --report` and add `covers` entries to the pages that document them (or new pages) until it passes"
3894
3901
  ] : [],
3895
- "Show the docs diff to the user with `assist ask` and wait for their approval before committing; in the body, list each changed page (`git status --porcelain -- docs/src/content/docs/`) as a link to it in the docs preview: `http://localhost:4173/<page>/` for `docs/src/content/docs/<page>.md(x)`, and `http://localhost:4173/` for `index.md(x)`"
3902
+ "Ask the user to review the docs changes with `assist ask` and wait for their approval before committing. Keep the body a concise summary with no raw diff (the user reviews the changes in the docs viewer): list each changed page (`git status --porcelain -- docs/src/content/docs/`) as a link to it in the docs preview (`http://localhost:4173/<page>/` for `docs/src/content/docs/<page>.md(x)`, and `http://localhost:4173/` for `index.md(x)`) with a few words on what changed, then the stories included, then each skipped story with its one-line reason"
3896
3903
  ],
3897
3904
  serializeManualChecks([
3898
- "Review every docs page change in the diff and approve it"
3905
+ "Review every changed docs page in the docs preview and approve it"
3899
3906
  ]),
3900
3907
  void 0
3901
3908
  );
@@ -4690,7 +4697,9 @@ async function diff(req, res) {
4690
4697
  const body = await scopedDiff(cwd, session, scope);
4691
4698
  res.writeHead(200, { "Content-Type": "text/plain; charset=utf-8" });
4692
4699
  res.end(body);
4693
- } catch {
4700
+ } catch (error) {
4701
+ const cause = error instanceof Error ? error.message : String(error);
4702
+ console.error(`GET /api/diff failed for cwd=${cwd}: ${cause}`);
4694
4703
  res.writeHead(500, { "Content-Type": "text/plain; charset=utf-8" });
4695
4704
  res.end("");
4696
4705
  }
@@ -47707,6 +47716,114 @@ function isTerminalResponse(data) {
47707
47716
  return ONLY_RESPONSES.test(data);
47708
47717
  }
47709
47718
 
47719
+ // src/commands/sessions/shared/readTranscriptTail.ts
47720
+ import * as fs51 from "fs";
47721
+ var DEFAULT_MAX_BYTES = 256 * 1024;
47722
+ function parseTailEntries(raw) {
47723
+ const entries = [];
47724
+ for (const line of raw.split("\n")) {
47725
+ const trimmed = line.trim();
47726
+ if (!trimmed) continue;
47727
+ try {
47728
+ const parsed = JSON.parse(trimmed);
47729
+ if (parsed && typeof parsed === "object")
47730
+ entries.push(parsed);
47731
+ } catch {
47732
+ }
47733
+ }
47734
+ return entries;
47735
+ }
47736
+ function dropPartialFirstLine(raw, sliced) {
47737
+ if (!sliced) return raw;
47738
+ const newline = raw.indexOf("\n");
47739
+ return newline === -1 ? "" : raw.slice(newline + 1);
47740
+ }
47741
+ async function readTranscriptTail(filePath, maxBytes = DEFAULT_MAX_BYTES) {
47742
+ let handle;
47743
+ try {
47744
+ handle = await fs51.promises.open(filePath, "r");
47745
+ const { size } = await handle.stat();
47746
+ const start2 = Math.max(0, size - maxBytes);
47747
+ const length = size - start2;
47748
+ if (length === 0) return [];
47749
+ const buf = Buffer.alloc(length);
47750
+ await handle.read(buf, 0, length, start2);
47751
+ return parseTailEntries(
47752
+ dropPartialFirstLine(buf.toString("utf8"), start2 > 0)
47753
+ );
47754
+ } catch {
47755
+ return [];
47756
+ } finally {
47757
+ await handle?.close();
47758
+ }
47759
+ }
47760
+ function readTranscriptTailSync(filePath, maxBytes = DEFAULT_MAX_BYTES) {
47761
+ let fd;
47762
+ try {
47763
+ fd = fs51.openSync(filePath, "r");
47764
+ const { size } = fs51.fstatSync(fd);
47765
+ const start2 = Math.max(0, size - maxBytes);
47766
+ const length = size - start2;
47767
+ if (length === 0) return [];
47768
+ const buf = Buffer.alloc(length);
47769
+ fs51.readSync(fd, buf, 0, length, start2);
47770
+ return parseTailEntries(
47771
+ dropPartialFirstLine(buf.toString("utf8"), start2 > 0)
47772
+ );
47773
+ } catch {
47774
+ return [];
47775
+ } finally {
47776
+ if (fd !== void 0) fs51.closeSync(fd);
47777
+ }
47778
+ }
47779
+
47780
+ // src/commands/sessions/shared/transcriptTailFingerprint.ts
47781
+ var CONVERSATION_TYPES = /* @__PURE__ */ new Set(["user", "assistant"]);
47782
+ function transcriptTailFingerprint(entries) {
47783
+ for (let i = entries.length - 1; i >= 0; i--) {
47784
+ const entry = entries[i];
47785
+ if (entry.isSidechain || entry.isMeta) continue;
47786
+ if (typeof entry.type !== "string" || !CONVERSATION_TYPES.has(entry.type))
47787
+ continue;
47788
+ return typeof entry.uuid === "string" && entry.uuid ? entry.uuid : null;
47789
+ }
47790
+ return null;
47791
+ }
47792
+
47793
+ // src/commands/sessions/daemon/watchSubmitOutcome.ts
47794
+ var SUBMIT_GRACE_MS = 5e3;
47795
+ async function turnStarted(session, fingerprint) {
47796
+ const filePath = await resolveTranscriptPath(session);
47797
+ if (!filePath) return true;
47798
+ const entries = await readTranscriptTail(filePath);
47799
+ return (transcriptTailFingerprint(entries) ?? void 0) !== fingerprint;
47800
+ }
47801
+ function clearPendingSubmit(session) {
47802
+ session.pendingSubmit?.cancel();
47803
+ session.pendingSubmit = void 0;
47804
+ }
47805
+ function watchSubmitOutcome(session, onStatusChange) {
47806
+ clearPendingSubmit(session);
47807
+ const fingerprint = session.transcriptFingerprint;
47808
+ const pending = { fingerprint, cancel: () => {
47809
+ } };
47810
+ const check2 = async () => {
47811
+ if (session.pendingSubmit !== pending) return;
47812
+ session.pendingSubmit = void 0;
47813
+ if (session.status !== "running") return;
47814
+ if (await turnStarted(session, fingerprint)) return;
47815
+ if (session.status !== "running" || session.pendingSubmit) return;
47816
+ daemonLog(
47817
+ `session ${session.id} resumed-prompt submit started no turn -> waiting`
47818
+ );
47819
+ onStatusChange(session, "waiting");
47820
+ };
47821
+ const timer = setTimeout(() => void check2(), SUBMIT_GRACE_MS);
47822
+ timer.unref?.();
47823
+ pending.cancel = () => clearTimeout(timer);
47824
+ session.pendingSubmit = pending;
47825
+ }
47826
+
47710
47827
  // src/commands/sessions/daemon/watchPromptSubmit.ts
47711
47828
  var CARRIAGE_RETURN = "\r";
47712
47829
  function isPromptSubmit(data) {
@@ -47718,6 +47835,7 @@ function watchPromptSubmit(session, data, onStatusChange) {
47718
47835
  if (!isPromptSubmit(data)) return;
47719
47836
  daemonLog(`session ${session.id} resumed-prompt submit -> running`);
47720
47837
  onStatusChange(session, "running");
47838
+ watchSubmitOutcome(session, onStatusChange);
47721
47839
  }
47722
47840
 
47723
47841
  // src/commands/sessions/daemon/writeToSession.ts
@@ -48113,7 +48231,7 @@ function serverRunMeta(runName, cwd) {
48113
48231
  }
48114
48232
 
48115
48233
  // src/commands/sessions/daemon/readDesignSystemPrompt.ts
48116
- import * as fs51 from "fs";
48234
+ import * as fs52 from "fs";
48117
48235
  import * as path107 from "path";
48118
48236
  import { fileURLToPath as fileURLToPath10 } from "url";
48119
48237
  var __filename5 = fileURLToPath10(import.meta.url);
@@ -48125,7 +48243,7 @@ function readDesignSystemPrompt() {
48125
48243
  "claude",
48126
48244
  "design-system-prompt.md"
48127
48245
  );
48128
- return fs51.readFileSync(promptPath, "utf8");
48246
+ return fs52.readFileSync(promptPath, "utf8");
48129
48247
  }
48130
48248
 
48131
48249
  // src/commands/sessions/daemon/spawnClaude.ts
@@ -50022,7 +50140,7 @@ function reportSilentFailure(session, clients) {
50022
50140
  }
50023
50141
 
50024
50142
  // src/commands/sessions/shared/codex/resolveCodexSessionId.ts
50025
- import * as fs52 from "fs";
50143
+ import * as fs53 from "fs";
50026
50144
  var META_LINES = 5;
50027
50145
  async function resolveCodexSessionId(cwd, sinceMs) {
50028
50146
  if (!cwd) return null;
@@ -50051,7 +50169,7 @@ async function startedIn(file, cwd, sinceMs) {
50051
50169
  }
50052
50170
  async function touchedSince(file, sinceMs) {
50053
50171
  try {
50054
- return (await fs52.promises.stat(file)).mtimeMs >= sinceMs;
50172
+ return (await fs53.promises.stat(file)).mtimeMs >= sinceMs;
50055
50173
  } catch {
50056
50174
  return false;
50057
50175
  }
@@ -50216,80 +50334,6 @@ function deriveTranscriptStatus(entries, opts = {}) {
50216
50334
  return "running";
50217
50335
  }
50218
50336
 
50219
- // src/commands/sessions/shared/readTranscriptTail.ts
50220
- import * as fs53 from "fs";
50221
- var DEFAULT_MAX_BYTES = 256 * 1024;
50222
- function parseTailEntries(raw) {
50223
- const entries = [];
50224
- for (const line of raw.split("\n")) {
50225
- const trimmed = line.trim();
50226
- if (!trimmed) continue;
50227
- try {
50228
- const parsed = JSON.parse(trimmed);
50229
- if (parsed && typeof parsed === "object")
50230
- entries.push(parsed);
50231
- } catch {
50232
- }
50233
- }
50234
- return entries;
50235
- }
50236
- function dropPartialFirstLine(raw, sliced) {
50237
- if (!sliced) return raw;
50238
- const newline = raw.indexOf("\n");
50239
- return newline === -1 ? "" : raw.slice(newline + 1);
50240
- }
50241
- async function readTranscriptTail(filePath, maxBytes = DEFAULT_MAX_BYTES) {
50242
- let handle;
50243
- try {
50244
- handle = await fs53.promises.open(filePath, "r");
50245
- const { size } = await handle.stat();
50246
- const start2 = Math.max(0, size - maxBytes);
50247
- const length = size - start2;
50248
- if (length === 0) return [];
50249
- const buf = Buffer.alloc(length);
50250
- await handle.read(buf, 0, length, start2);
50251
- return parseTailEntries(
50252
- dropPartialFirstLine(buf.toString("utf8"), start2 > 0)
50253
- );
50254
- } catch {
50255
- return [];
50256
- } finally {
50257
- await handle?.close();
50258
- }
50259
- }
50260
- function readTranscriptTailSync(filePath, maxBytes = DEFAULT_MAX_BYTES) {
50261
- let fd;
50262
- try {
50263
- fd = fs53.openSync(filePath, "r");
50264
- const { size } = fs53.fstatSync(fd);
50265
- const start2 = Math.max(0, size - maxBytes);
50266
- const length = size - start2;
50267
- if (length === 0) return [];
50268
- const buf = Buffer.alloc(length);
50269
- fs53.readSync(fd, buf, 0, length, start2);
50270
- return parseTailEntries(
50271
- dropPartialFirstLine(buf.toString("utf8"), start2 > 0)
50272
- );
50273
- } catch {
50274
- return [];
50275
- } finally {
50276
- if (fd !== void 0) fs53.closeSync(fd);
50277
- }
50278
- }
50279
-
50280
- // src/commands/sessions/shared/transcriptTailFingerprint.ts
50281
- var CONVERSATION_TYPES = /* @__PURE__ */ new Set(["user", "assistant"]);
50282
- function transcriptTailFingerprint(entries) {
50283
- for (let i = entries.length - 1; i >= 0; i--) {
50284
- const entry = entries[i];
50285
- if (entry.isSidechain || entry.isMeta) continue;
50286
- if (typeof entry.type !== "string" || !CONVERSATION_TYPES.has(entry.type))
50287
- continue;
50288
- return typeof entry.uuid === "string" && entry.uuid ? entry.uuid : null;
50289
- }
50290
- return null;
50291
- }
50292
-
50293
50337
  // src/commands/sessions/shared/extractLastAssistantMessage.ts
50294
50338
  var MAX_LENGTH = 500;
50295
50339
  function extractLastAssistantMessage(entries) {
@@ -50962,6 +51006,7 @@ function applySetStatus(sessions, id, status2, source, onStatusChange, rebind) {
50962
51006
  return;
50963
51007
  }
50964
51008
  rebind?.(session);
51009
+ clearPendingSubmit(session);
50965
51010
  if (opensPrompt(status2, source)) session.permissionActive = true;
50966
51011
  if (status2 === "running" || source === "stop")
50967
51012
  session.permissionActive = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.1000.1",
3
+ "version": "0.1000.2",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {