ushman-ledger 1.2.0 → 1.2.1

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.
Files changed (44) hide show
  1. package/README.md +57 -5
  2. package/dist/builders.d.ts +1 -2
  3. package/dist/builders.d.ts.map +1 -1
  4. package/dist/cli.d.ts.map +1 -1
  5. package/dist/cli.js +156 -53
  6. package/dist/doctor.d.ts.map +1 -1
  7. package/dist/doctor.js +1 -1
  8. package/dist/handle.d.ts +27 -7
  9. package/dist/handle.d.ts.map +1 -1
  10. package/dist/handle.js +96 -20
  11. package/dist/index.d.ts +4 -3
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +2 -1
  14. package/dist/list.d.ts +1 -1
  15. package/dist/list.d.ts.map +1 -1
  16. package/dist/list.js +7 -5
  17. package/dist/note.d.ts +7 -0
  18. package/dist/note.d.ts.map +1 -1
  19. package/dist/note.js +6 -0
  20. package/dist/patch-resolver.d.ts +12 -0
  21. package/dist/patch-resolver.d.ts.map +1 -1
  22. package/dist/patch-resolver.js +12 -0
  23. package/dist/read-index.d.ts.map +1 -1
  24. package/dist/record.d.ts.map +1 -1
  25. package/dist/record.js +1 -2
  26. package/dist/render/migration-log.d.ts +8 -1
  27. package/dist/render/migration-log.d.ts.map +1 -1
  28. package/dist/render/migration-log.js +40 -33
  29. package/dist/render/retro.d.ts.map +1 -1
  30. package/dist/render/retro.js +1 -7
  31. package/dist/render/workspace-narrative.d.ts +7 -1
  32. package/dist/render/workspace-narrative.d.ts.map +1 -1
  33. package/dist/render/workspace-narrative.js +114 -46
  34. package/dist/schema/entry-read.d.ts.map +1 -1
  35. package/dist/schema/entry-read.js +1 -1
  36. package/dist/schema/entry-write.d.ts.map +1 -1
  37. package/dist/schema/entry-write.js +1 -1
  38. package/dist/schema/entry.d.ts.map +1 -1
  39. package/dist/storage/filesystem.d.ts +7 -0
  40. package/dist/storage/filesystem.d.ts.map +1 -1
  41. package/dist/storage/filesystem.js +80 -5
  42. package/dist/version.d.ts +1 -1
  43. package/dist/version.js +1 -1
  44. package/package.json +2 -2
package/dist/handle.js CHANGED
@@ -13,28 +13,58 @@ import { renderMigrationLogMarkdown } from "./render/migration-log.js";
13
13
  import { renderRetroMarkdown } from "./render/retro.js";
14
14
  import { renderTimelineHtml } from "./render/timeline-html.js";
15
15
  import { renderWorkspaceNarrativeMarkdown } from "./render/workspace-narrative.js";
16
- import { resolveLedgerPaths, writeAtomicTextFile } from "./storage/filesystem.js";
17
- const renderEntries = async ({ filter, target, workspaceRoot, }) => {
18
- const { manifest, readIndex } = await loadLedgerState(workspaceRoot);
16
+ import { createAtomicTextFileWriter, resolveLedgerPaths, writeAtomicTextFile } from "./storage/filesystem.js";
17
+ const createEntryIteratorFactory = ({ filter, state, workspaceRoot, }) => {
18
+ return (entryOptions = {}) => iterateEntriesFromManifest(workspaceRoot, state.manifest, state.readIndex, {
19
+ kind: entryOptions.kind,
20
+ limit: filter.limit,
21
+ phase: filter.phase,
22
+ since: filter.since,
23
+ }, entryOptions.direction);
24
+ };
25
+ const collectRenderedText = async (emit) => {
26
+ const chunks = [];
27
+ await emit((chunk) => {
28
+ chunks.push(chunk);
29
+ });
30
+ return chunks.join('');
31
+ };
32
+ const emitRenderedTarget = async ({ createEntries, manifest, target, write, workspaceName, }) => {
19
33
  switch (target) {
20
34
  case 'dependency-graph':
21
- return renderDependencyGraph(iterateEntriesFromManifest(workspaceRoot, manifest, readIndex, filter));
35
+ await write(await renderDependencyGraph(createEntries()));
36
+ return;
22
37
  case 'jsonl':
23
- return renderJsonl(iterateEntriesFromManifest(workspaceRoot, manifest, readIndex, filter));
38
+ await write(await renderJsonl(createEntries()));
39
+ return;
24
40
  case 'migration-log-md':
25
- return renderMigrationLogMarkdown(iterateEntriesFromManifest(workspaceRoot, manifest, readIndex, filter));
41
+ await renderMigrationLogMarkdown({
42
+ entries: createEntries({
43
+ direction: 'desc',
44
+ kind: 'change-log',
45
+ }),
46
+ write,
47
+ });
48
+ return;
26
49
  case 'timeline-html':
27
- return renderTimelineHtml(iterateEntriesFromManifest(workspaceRoot, manifest, readIndex, filter));
50
+ await write(await renderTimelineHtml(createEntries()));
51
+ return;
28
52
  case 'retro':
29
- return renderRetroMarkdown({
30
- entries: iterateEntriesFromManifest(workspaceRoot, manifest, readIndex, filter),
53
+ await write(await renderRetroMarkdown({
54
+ entries: createEntries(),
31
55
  manifest,
32
- });
56
+ }));
57
+ return;
33
58
  case 'workspace-narrative-md':
34
- return renderWorkspaceNarrativeMarkdown({
35
- entries: iterateEntriesFromManifest(workspaceRoot, manifest, readIndex, filter),
36
- workspaceName: path.basename(workspaceRoot),
59
+ await renderWorkspaceNarrativeMarkdown({
60
+ entries: createEntries({
61
+ direction: 'desc',
62
+ kind: 'note',
63
+ }),
64
+ workspaceName,
65
+ write,
37
66
  });
67
+ return;
38
68
  }
39
69
  };
40
70
  const resolveRenderOutputPath = (workspaceRoot, target) => {
@@ -52,6 +82,7 @@ const resolveRenderOutputPath = (workspaceRoot, target) => {
52
82
  return null;
53
83
  }
54
84
  };
85
+ /** Open a workspace ledger handle after reconciling any pending crash-recovery state. */
55
86
  export const openLedger = async (workspaceRoot) => {
56
87
  await readLabManifestMin(workspaceRoot);
57
88
  await prepareLedgerState(workspaceRoot);
@@ -69,21 +100,66 @@ export const openLedger = async (workspaceRoot) => {
69
100
  return { id: result.id };
70
101
  },
71
102
  render: async (options) => {
72
- const content = await renderEntries({
73
- filter: {
74
- limit: options.limit,
75
- phase: options.phase,
76
- since: options.since,
77
- },
78
- target: options.to,
103
+ const state = await loadLedgerState(workspaceRoot);
104
+ const createEntries = createEntryIteratorFactory({
105
+ filter: options,
106
+ state,
79
107
  workspaceRoot,
80
108
  });
109
+ const content = await collectRenderedText((write) => emitRenderedTarget({
110
+ createEntries,
111
+ manifest: state.manifest,
112
+ target: options.to,
113
+ workspaceName: path.basename(workspaceRoot),
114
+ write,
115
+ }));
81
116
  const outputPath = options.out ?? resolveRenderOutputPath(workspaceRoot, options.to);
82
117
  if (outputPath) {
83
118
  await writeAtomicTextFile(outputPath, `${content}${content.endsWith('\n') ? '' : '\n'}`);
84
119
  }
85
120
  return content;
86
121
  },
122
+ renderTo: async (options) => {
123
+ const state = await loadLedgerState(workspaceRoot);
124
+ const createEntries = createEntryIteratorFactory({
125
+ filter: options,
126
+ state,
127
+ workspaceRoot,
128
+ });
129
+ const outputPath = options.out ?? resolveRenderOutputPath(workspaceRoot, options.to);
130
+ const atomicWriter = outputPath ? await createAtomicTextFileWriter(outputPath) : null;
131
+ const writer = options.write;
132
+ let hasWrittenContent = false;
133
+ let endsWithNewline = false;
134
+ if (!atomicWriter && !writer) {
135
+ throw new Error(`Render target ${options.to} requires either a writer callback or an output path.`);
136
+ }
137
+ try {
138
+ await emitRenderedTarget({
139
+ createEntries,
140
+ manifest: state.manifest,
141
+ target: options.to,
142
+ workspaceName: path.basename(workspaceRoot),
143
+ write: async (chunk) => {
144
+ if (chunk.length > 0) {
145
+ hasWrittenContent = true;
146
+ endsWithNewline = chunk.endsWith('\n');
147
+ }
148
+ await writer?.(chunk);
149
+ await atomicWriter?.write(chunk);
150
+ },
151
+ });
152
+ if (!hasWrittenContent || !endsWithNewline) {
153
+ await writer?.('\n');
154
+ await atomicWriter?.write('\n');
155
+ }
156
+ await atomicWriter?.close();
157
+ }
158
+ catch (error) {
159
+ await atomicWriter?.abort();
160
+ throw error;
161
+ }
162
+ },
87
163
  show: async (entryId) => {
88
164
  const { manifest } = await loadLedgerState(workspaceRoot);
89
165
  if (!manifest.entryLocations[entryId]) {
package/dist/index.d.ts CHANGED
@@ -1,10 +1,11 @@
1
- export { buildChangeLogRecord, buildCorrectionRecord, buildOperatorDecisionRecord, buildStripDecisionRevertedRecord, buildValidatorResultRecord, } from './builders.ts';
1
+ export { type BuildRecordInput, buildChangeLogRecord, buildCorrectionRecord, buildOperatorDecisionRecord, buildStripDecisionRevertedRecord, buildValidatorResultRecord, } from './builders.ts';
2
2
  export { runLedgerCli } from './cli.ts';
3
3
  export { type CoverageReport, computeCoverage } from './coverage.ts';
4
- export { type LedgerHandle, type RenderTarget, openLedger } from './handle.ts';
4
+ export { type LedgerHandle, type LedgerRenderOptions, type LedgerRenderToOptions, openLedger, type RenderTarget, type RenderWriter, } from './handle.ts';
5
5
  export type { LedgerFilter } from './list.ts';
6
6
  export { appendCleanupWaveNote, appendDecompositionWaveNote, appendNote, appendOpenIssueNote, appendSemanticCleanupSummaryNote, appendVerifiedFlowNote, type NoteBody, } from './note.ts';
7
- export { type AgentPatchDiff, AgentPatchDiffSchema, AgentPatchEntrySchema, AgentPatchRecordSchema, type ChangeLogEntry, ChangeLogEntrySchema, type ChangeLogFileChange, ChangeLogFileChangeSchema, type ChangeLogParityStatus, ChangeLogParityStatusSchema, type ChangeLogRecord, ChangeLogRecordSchema, type ChangeLogSmokeResult, ChangeLogSmokeResultSchema, type ChangeLogSubkind, ChangeLogSubkindSchema, CorrectionEntrySchema, CorrectionRecordSchema, EmitterSchema, type LedgerEntry, LedgerEntrySchema, type LedgerKind, LedgerLinksSchema, type LedgerLinks, type LedgerPhase, LedgerPhaseSchema, type LedgerRecord, LedgerRecordSchema, type NoteEntry, NoteEntrySchema, type OperatorDecisionAction, OperatorDecisionActionSchema, OperatorDecisionEntrySchema, type OperatorDecisionPayload, OperatorDecisionPayloadSchema, OperatorDecisionRecordSchema, OperatorPatchEntrySchema, OperatorPatchRecordSchema, parseLedgerEntry, parseLedgerRecord, RuntimeEventEntrySchema, StripDecisionRevertedEntrySchema, type StripDecisionRevertedPayload, StripDecisionRevertedPayloadSchema, StripDecisionRevertedRecordSchema, ToolInvocationEntrySchema, ToolInvocationRecordSchema, ValidatorResultEntrySchema, ValidatorResultRecordSchema, } from './schema/entry.ts';
7
+ export { deriveFilesChangedFromPatch } from './patch-resolver.ts';
8
+ export { type AgentPatchDiff, AgentPatchDiffSchema, AgentPatchEntrySchema, AgentPatchRecordSchema, type ChangeLogEntry, ChangeLogEntrySchema, type ChangeLogFileChange, ChangeLogFileChangeSchema, type ChangeLogParityStatus, ChangeLogParityStatusSchema, type ChangeLogRecord, ChangeLogRecordSchema, type ChangeLogSmokeResult, ChangeLogSmokeResultSchema, type ChangeLogSubkind, ChangeLogSubkindSchema, CorrectionEntrySchema, CorrectionRecordSchema, EmitterSchema, type LedgerEntry, LedgerEntrySchema, type LedgerKind, type LedgerLinks, LedgerLinksSchema, type LedgerPhase, LedgerPhaseSchema, type LedgerRecord, LedgerRecordSchema, type NoteEntry, NoteEntrySchema, type OperatorDecisionAction, OperatorDecisionActionSchema, OperatorDecisionEntrySchema, type OperatorDecisionPayload, OperatorDecisionPayloadSchema, OperatorDecisionRecordSchema, OperatorPatchEntrySchema, OperatorPatchRecordSchema, parseLedgerEntry, parseLedgerRecord, RuntimeEventEntrySchema, StripDecisionRevertedEntrySchema, type StripDecisionRevertedPayload, StripDecisionRevertedPayloadSchema, StripDecisionRevertedRecordSchema, ToolInvocationEntrySchema, ToolInvocationRecordSchema, ValidatorResultEntrySchema, ValidatorResultRecordSchema, } from './schema/entry.ts';
8
9
  export { type NoteSubkind, NoteSubkindSchema } from './schema/note.ts';
9
10
  export { resolveLedgerPaths } from './storage/filesystem.ts';
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,oBAAoB,EACpB,qBAAqB,EACrB,2BAA2B,EAC3B,gCAAgC,EAChC,0BAA0B,GAC7B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,KAAK,cAAc,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC/E,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EACH,qBAAqB,E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ACjC,kCAAkC,EAClC,iCAAiC,EACjC,yBAAyB,EACzB,0BAA0B,EAC1B,0BAA0B,EAC1B,2BAA2B,GAC9B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,KAAK,WAAW,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC"}
package/dist/index.js CHANGED
@@ -1,8 +1,9 @@
1
1
  export { buildChangeLogRecord, buildCorrectionRecord, buildOperatorDecisionRecord, buildStripDecisionRevertedRecord, buildValidatorResultRecord, } from "./builders.js";
2
2
  export { runLedgerCli } from "./cli.js";
3
3
  export { computeCoverage } from "./coverage.js";
4
- export { openLedger } from "./handle.js";
4
+ export { openLedger, } from "./handle.js";
5
5
  export { appendCleanupWaveNote, appendDecompositionWaveNote, appendNote, appendOpenIssueNote, appendSemanticCleanupSummaryNote, appendVerifiedFlowNote, } from "./note.js";
6
+ export { deriveFilesChangedFromPatch } from "./patch-resolver.js";
6
7
  export { AgentPatchDiffSchema, AgentPatchEntrySchema, AgentPatchRecordSchema, ChangeLogEntrySchema, ChangeLogFileChangeSchema, ChangeLogParityStatusSchema, ChangeLogRecordSchema, ChangeLogSmokeResultSchema, ChangeLogSubkindSchema, CorrectionEntrySchema, CorrectionRecordSchema, EmitterSchema, LedgerEntrySchema, LedgerLinksSchema, LedgerPhaseSchema, LedgerRecordSchema, NoteEntrySchema, OperatorDecisionActionSchema, OperatorDecisionEntrySchema, OperatorDecisionPayloadSchema, OperatorDecisionRecordSchema, OperatorPatchEntrySchema, OperatorPatchRecordSchema, parseLedgerEntry, parseLedgerRecord, RuntimeEventEntrySchema, StripDecisionRevertedEntrySchema, StripDecisionRevertedPayloadSchema, StripDecisionRevertedRecordSchema, ToolInvocationEntrySchema, ToolInvocationRecordSchema, ValidatorResultEntrySchema, ValidatorResultRecordSchema, } from "./schema/entry.js";
7
8
  export { NoteSubkindSchema } from "./schema/note.js";
8
9
  export { resolveLedgerPaths } from "./storage/filesystem.js";
package/dist/list.d.ts CHANGED
@@ -377,7 +377,7 @@ export declare const readManifestEntryBatch: ({ allowMissing, entryLocations, wo
377
377
  sequence: number;
378
378
  };
379
379
  })[]>;
380
- export declare const iterateEntriesFromManifest: (workspaceRoot: string, manifest: LedgerManifest, readIndex: LedgerReadIndex, filter?: LedgerFilter) => AsyncIterable<LedgerEntry>;
380
+ export declare const iterateEntriesFromManifest: (workspaceRoot: string, manifest: LedgerManifest, readIndex: LedgerReadIndex, filter?: LedgerFilter, direction?: "asc" | "desc") => AsyncIterable<LedgerEntry>;
381
381
  export declare const listEntries: (workspaceRoot: string, filter?: LedgerFilter) => AsyncIterable<LedgerEntry>;
382
382
  export declare const readAllEntries: (workspaceRoot: string, filter?: LedgerFilter) => Promise<LedgerEntry[]>;
383
383
  //# sourceMappingURL=list.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../src/list.ts"],"names":[],"mappings":"AACA,OAAO,EACH,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAG7B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,KAAK,WAAW,EAAoB,MAAM,mBAAmB,CAAC;AAC1G,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG3D,MAAM,MAAM,YAAY,GAAG;IACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAmDF,eAAO,MAAM,wBAAwB,GACjC,UAAU,cAAc,EACxB,WAAW,eAAe,EAC1B,QAAQ,YAAY,EACpB,YAAW,KAAK,GAAG,MAAc,4BAgBpC,CAAC;AAgCF,eAAO,M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B,CAAC;AAEF,eAAO,MAAM,WAAW,GACpB,eAAe,MAAM,EACrB,SAAQ,YAAiB,KAC1B,aAAa,CAAC,WAAW,CAG3B,CAAC;AAEF,eAAO,MAAM,cAAc,GAAU,eAAe,MAAM,EAAE,SAAQ,YAAiB,KAAG,OAAO,CAAC,WAAW,EAAE,CAM5G,CAAC"}
package/dist/list.js CHANGED
@@ -77,7 +77,7 @@ export const readManifestEntryBatch = async ({ allowMissing = false, entryLocati
77
77
  location,
78
78
  workspaceRoot,
79
79
  }));
80
- const collectLimitedEntries = async ({ filter, manifest, readIndex, workspaceRoot, }) => {
80
+ const collectLimitedEntries = async ({ direction, filter, manifest, readIndex, workspaceRoot, }) => {
81
81
  const collectedEntries = [];
82
82
  const orderedEntries = getOrderedEntryLocations(manifest, readIndex, filter, 'desc');
83
83
  const limit = filter.limit ?? 0;
@@ -99,17 +99,19 @@ const collectLimitedEntries = async ({ filter, manifest, readIndex, workspaceRoo
99
99
  }
100
100
  }
101
101
  }
102
- collectedEntries.reverse();
102
+ if (direction === 'asc') {
103
+ collectedEntries.reverse();
104
+ }
103
105
  return collectedEntries;
104
106
  };
105
- export const iterateEntriesFromManifest = async function* (workspaceRoot, manifest, readIndex, filter = {}) {
107
+ export const iterateEntriesFromManifest = async function* (workspaceRoot, manifest, readIndex, filter = {}, direction = 'asc') {
106
108
  if (filter.limit) {
107
- for (const entry of await collectLimitedEntries({ filter, manifest, readIndex, workspaceRoot })) {
109
+ for (const entry of await collectLimitedEntries({ direction, filter, manifest, readIndex, workspaceRoot })) {
108
110
  yield entry;
109
111
  }
110
112
  return;
111
113
  }
112
- const orderedEntries = getOrderedEntryLocations(manifest, readIndex, filter);
114
+ const orderedEntries = getOrderedEntryLocations(manifest, readIndex, filter, direction);
113
115
  for (let index = 0; index < orderedEntries.length; index += ENTRY_READ_BATCH_SIZE) {
114
116
  const batch = orderedEntries.slice(index, index + ENTRY_READ_BATCH_SIZE);
115
117
  const resolvedEntries = await readManifestEntryBatch({
package/dist/note.d.ts CHANGED
@@ -1,31 +1,38 @@
1
1
  import { appendRecord } from './record.ts';
2
2
  import type { LedgerPhase } from './schema/entry.ts';
3
3
  import type { NoteSubkind } from './schema/note.ts';
4
+ /** Input shared by the narrative and note helper wrappers. */
4
5
  export type NoteBody = {
5
6
  readonly body: string;
6
7
  readonly phase: LedgerPhase;
7
8
  readonly summary: string;
8
9
  };
10
+ /** Append a typed note entry using the library emitter metadata. */
9
11
  export declare const appendNote: (workspaceRoot: string, subkind: NoteSubkind, noteBody: NoteBody) => Promise<{
10
12
  entry: Awaited<ReturnType<typeof appendRecord>>["entry"];
11
13
  id: string;
12
14
  }>;
15
+ /** Append a `cleanup-wave` narrative note. */
13
16
  export declare const appendCleanupWaveNote: (workspaceRoot: string, noteBody: NoteBody) => Promise<{
14
17
  entry: Awaited<ReturnType<typeof appendRecord>>["entry"];
15
18
  id: string;
16
19
  }>;
20
+ /** Append a `verified-flow` narrative note. */
17
21
  export declare const appendVerifiedFlowNote: (workspaceRoot: string, noteBody: NoteBody) => Promise<{
18
22
  entry: Awaited<ReturnType<typeof appendRecord>>["entry"];
19
23
  id: string;
20
24
  }>;
25
+ /** Append an `open-issue` narrative note. */
21
26
  export declare const appendOpenIssueNote: (workspaceRoot: string, noteBody: NoteBody) => Promise<{
22
27
  entry: Awaited<ReturnType<typeof appendRecord>>["entry"];
23
28
  id: string;
24
29
  }>;
30
+ /** Append a `decomposition-wave` narrative note. */
25
31
  export declare const appendDecompositionWaveNote: (workspaceRoot: string, noteBody: NoteBody) => Promise<{
26
32
  entry: Awaited<ReturnType<typeof appendRecord>>["entry"];
27
33
  id: string;
28
34
  }>;
35
+ /** Append the current `semantic-cleanup-summary` note for workspace narrative rendering. */
29
36
  export declare const appendSemanticCleanupSummaryNote: (workspaceRoot: string, noteBody: NoteBody) => Promise<{
30
37
  entry: Awaited<ReturnType<typeof appendRecord>>["entry"];
31
38
  id: string;
@@ -1 +1 @@
1
- {"version":3,"file":"note.d.ts","sourceR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AAC;AAEzD,6CAA6C;AAC7C,eAAO,MAAM,mBAAmB,GAAI,eAAe,MAAM,EAAE,UAAU,QAAQ;WAvBzD,OAAO,CAAC,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC;QAAM,MAAM;EAwB5B,CAAC;AAEtD,oDAAoD;AACpD,eAAO,MAAM,2BAA2B,GAAI,eAAe,MAAM,EAAE,UAAU,QAAQ;WA3BjE,OAAO,CAAC,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC;QAAM,MAAM;EA4BpB,CAAC;AAE9D,4FAA4F;AAC5F,eAAO,MAAM,gCAAgC,GAAI,eAAe,MAAM,EAAE,UAAU,QAAQ;WA/BtE,OAAO,CAAC,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC;QAAM,MAAM;EAgCd,CAAC"}
package/dist/note.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { appendRecord } from "./record.js";
2
2
  import { LEDGER_LIBRARY_VERSION } from "./version.js";
3
+ /** Append a typed note entry using the library emitter metadata. */
3
4
  export const appendNote = async (workspaceRoot, subkind, noteBody) => {
4
5
  return appendRecord(workspaceRoot, {
5
6
  body: noteBody.body,
@@ -13,8 +14,13 @@ export const appendNote = async (workspaceRoot, subkind, noteBody) => {
13
14
  summary: noteBody.summary,
14
15
  });
15
16
  };
17
+ /** Append a `cleanup-wave` narrative note. */
16
18
  export const appendCleanupWaveNote = (workspaceRoot, noteBody) => appendNote(workspaceRoot, 'cleanup-wave', noteBody);
19
+ /** Append a `verified-flow` narrative note. */
17
20
  export const appendVerifiedFlowNote = (workspaceRoot, noteBody) => appendNote(workspaceRoot, 'verified-flow', noteBody);
21
+ /** Append an `open-issue` narrative note. */
18
22
  export const appendOpenIssueNote = (workspaceRoot, noteBody) => appendNote(workspaceRoot, 'open-issue', noteBody);
23
+ /** Append a `decomposition-wave` narrative note. */
19
24
  export const appendDecompositionWaveNote = (workspaceRoot, noteBody) => appendNote(workspaceRoot, 'decomposition-wave', noteBody);
25
+ /** Append the current `semantic-cleanup-summary` note for workspace narrative rendering. */
20
26
  export const appendSemanticCleanupSummaryNote = (workspaceRoot, noteBody) => appendNote(workspaceRoot, 'semantic-cleanup-summary', noteBody);
@@ -14,6 +14,18 @@ type ResolvedOperatorPatchRecord = Omit<OperatorPatchRecord, 'diffPath' | 'diffT
14
14
  readonly links: LedgerLinks;
15
15
  };
16
16
  export type ResolvedPatchRecord = ResolvedAgentPatchRecord | ResolvedOperatorPatchRecord;
17
+ /**
18
+ * Derive `change-log.filesChanged` metadata from a git-style unified diff.
19
+ *
20
+ * Example:
21
+ * `deriveFilesChangedFromPatch(await readFile('/tmp/change.patch', 'utf8'))`
22
+ *
23
+ * Known limits:
24
+ * - Requires `diff --git` headers to identify file boundaries.
25
+ * - Counts only textual hunk `+` and `-` lines, so binary or mode-only diffs can yield zero line counts.
26
+ * - Uses the post-image path when available and rejects diff blocks that cannot be mapped to a normalized
27
+ * workspace-relative path.
28
+ */
17
29
  export declare const deriveFilesChangedFromPatch: (patchText: string) => ChangeLogFileChange[];
18
30
  export declare function resolvePatchRecord(args: {
19
31
  readonly record: AgentPatchRecord;
@@ -1 +1 @@
1
- {"version":3,"file":"patch-resolver.d.ts","sourceRoot":"","sources":["../src/patch-resolver.ts"],"names":[],"mappings":"AAIA,OAAO,EACH,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACxB,KAAK,WAAW,EAChB,KAAK,YAAY,EAEpB,MAAM,mBAAmB,CAAC;AAI3B,KAAK,gBAAgB,GAAG,OAAO,CAAC,YAAY,EAAE;IAAE,IAAI,EAAE,aAAa,CAAA;CAAE,CAAC,CAAC;AACvE,KAAK,mBAAmB,GAAG,OAAO,CAAC,YAAY,EAAE;IAAE,IAAI,EAAE,gBAAgB,CAAA;CAAE,CAAC,CAAC;AAQ7E,KAAK,wBAAwB,GAAG,IAAI,CAAC,gBAAgB,EAAE,UAAU,GAAG,UAAU,GAAG,OAA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gBAAgB,EAAE,UAAU,GAAG,UAAU,GAAG,OAAO,CAAC,GAAG;IACxF,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;CAC/B,CAAC;AACF,KAAK,2BAA2B,GAAG,IAAI,CAAC,mBAAmB,EAAE,UAAU,GAAG,UAAU,GAAG,OAAO,CAAC,GAAG;IAC9F,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,wBAAwB,GAAG,2BAA2B,CAAC;AAqKzF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,2BAA2B,GAAI,WAAW,MAAM,KAAG,mBAAmB,EAuClF,CAAC;AAmBF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACrC,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAClC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAClC,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AACtC,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACrC,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAC;IACrC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAClC,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAC"}
@@ -124,6 +124,18 @@ const resolvePatchSource = async ({ record, workspaceRoot, }) => {
124
124
  }
125
125
  throw new Error(`${record.kind} records require diff, diffPath, or diffText.`);
126
126
  };
127
+ /**
128
+ * Derive `change-log.filesChanged` metadata from a git-style unified diff.
129
+ *
130
+ * Example:
131
+ * `deriveFilesChangedFromPatch(await readFile('/tmp/change.patch', 'utf8'))`
132
+ *
133
+ * Known limits:
134
+ * - Requires `diff --git` headers to identify file boundaries.
135
+ * - Counts only textual hunk `+` and `-` lines, so binary or mode-only diffs can yield zero line counts.
136
+ * - Uses the post-image path when available and rejects diff blocks that cannot be mapped to a normalized
137
+ * workspace-relative path.
138
+ */
127
139
  export const deriveFilesChangedFromPatch = (patchText) => {
128
140
  const filesChanged = [];
129
141
  let current;
@@ -1 +1 @@
1
- {"version":3,"file":"read-index.d.ts","sourceRoot":"","sources":["../src/read-index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAC;AAG7B,OAAO,EAAgB,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,KAAK,WAAW,EAAoB,MAAM,mBAAmB,CAAC;AACxH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAO3D,QAAA,MAAM,oBAAoB;;;;aAIxB,CAAC;AAEH,QAAA,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sDAiB1B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAC1E,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,oBAAoB,CAAC,CAAC;AACxE,MAAM,MAAM,qBAAqB,GAAG,SAAS,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,WAAW,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AA0HhG,eAAO,MAAM,0BAA0B,GAAU,eAAe,MAAM,EAAE,UAAU,cAAc;;;;;;;;;;;EAuB/F,CAAC;AAYF,eAAO,MAAM,kBAAkB,GAAI,OAAO,eAAe,EAAE,UAAU,cAAc,YAG1C,CAAC;AAE1C,eAAO,MAAM,aAAa,GAAU,eAAe,MAAM,KAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAWzF,CAAC;AAEF,eAAO,MAAM,aAAa,GAAU,eAAe,MAAM,EAAE,WAAW,eAAe,kBAGpF,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAU,eAAe,MAAM,EAAE,UAAU,cAAc;;;;;;;;;;;EAiB7F,CA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AQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,OAAO,EAAE;QAAE,KAAK,EAAE,WAAW,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChF,QAAQ,CAAC,uBAAuB,CAAC,EAAE,CAAC,OAAO,EAAE;QAAE,KAAK,EAAE,WAAW,CAAC;QAAC,iBAAiB,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACjH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC,OAAO,EAAE;QAAE,KAAK,EAAE,WAAW,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACpF,CAAC;AAOF,eAAO,MAAM,wBAAwB,GAAI,eAAe,MAAM,EAAE,OAAO,qBAAqB,GAAG,IAAI,SAOlG,CAAC;AA0EF,eAAO,MAAM,YAAY,GACrB,eAAe,MAAM,EACrB,OAAO,OAAO,KACf,OAAO,CAAC;IAAE,KAAK,EAAE,WAAW,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE,CAsF5C,CAAC;AAEF,eAAO,MAAM,aAAa,GACtB,eAAe,MAAM,EACrB,UAAU,cAAc,EACxB,SAAS,MAAM,KAChB,OAAO,CAAC,WAAW,CASrB,CAAC"}
package/dist/record.js CHANGED
@@ -3,11 +3,10 @@ import path from 'node:path';
3
3
  import * as v from 'valibot';
4
4
  import { sha256Hex, stableStringify } from "./json.js";
5
5
  import { updateManifestForEntry } from "./manifest-update.js";
6
- import { LedgerSchemaVersion } from "./schema/entry.js";
7
6
  import { resolvePatchRecord } from "./patch-resolver.js";
8
7
  import { appendEntryToReadIndex, saveReadIndex } from "./read-index.js";
9
8
  import { reconcileLedgerStateUnderLock, removePendingCommit, writePendingCommit } from "./recovery.js";
10
- import { LedgerEntrySchema, parseLedgerEntry, parseLedgerRecord, } from "./schema/entry.js";
9
+ import { LedgerEntrySchema, LedgerSchemaVersion, parseLedgerEntry, parseLedgerRecord, } from "./schema/entry.js";
11
10
  import { ensureLedgerDirectories, readManifest, resolveLedgerPaths, saveManifest, writeEntryFile, } from "./storage/filesystem.js";
12
11
  import { acquireLock } from "./storage/lock.js";
13
12
  const appendRecordTestHooks = new Map();
@@ -1,3 +1,10 @@
1
1
  import type { LedgerEntry } from '../schema/entry.ts';
2
- export declare const renderMigrationLogMarkdown: (entries: AsyncIterable<LedgerEntry>) => Promise<string>;
2
+ export declare const writeMigrationLogMarkdown: ({ entries, write, }: {
3
+ readonly entries: AsyncIterable<LedgerEntry>;
4
+ readonly write: (chunk: string) => Promise<void> | void;
5
+ }) => Promise<void>;
6
+ export declare const renderMigrationLogMarkdown: ({ entries, write, }: {
7
+ readonly entries: AsyncIterable<LedgerEntry>;
8
+ readonly write?: (chunk: string) => Promise<void> | void;
9
+ }) => Promise<string>;
3
10
  //# sourceMappingURL=migration-log.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"migration-log.d.ts","sourceRoot":"","sources":["../../src/render/migration-log.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAuC,WAAW,EAAE,MAAM,oBAAoB,CAAC;AA2C3F,eAAO,MAAM,0BAA0B,GAAU,SAAS,aAAa,CAAC,WAAW,CAAC,KAAG,OAAO,CAAC,MAAM,CAwCpG,CAAC"}
1
+ {"version":3,"file":"migration-log.d.ts","sourceRoot":"","sources":["../../src/render/migration-log.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAuC,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAmE3F,eAAO,MAAM,yBAAyB,GAAU,qBAG7C;IACC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IAC7C,QAAQ,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAC3D,kBAaA,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAU,qBAG9C;IACC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IAC7C,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAC5D,KAAG,OAAO,CAAC,MAAM,CASjB,CAAC"}
@@ -32,41 +32,48 @@ const renderSmokeLine = (entry) => {
32
32
  return '**Smoke result**: Not recorded.';
33
33
  };
34
34
  const isChangeLogEntry = (entry) => entry.kind === 'change-log';
35
- export const renderMigrationLogMarkdown = async (entries) => {
36
- const changeLogEntries = [];
35
+ const renderChangeLogSection = (entry) => [
36
+ `## ${entry.ts} - ${entry.summary}`,
37
+ '',
38
+ `**Type**: ${entry.subkind}`,
39
+ '',
40
+ '**Files changed**:',
41
+ renderFilesChanged(entry.filesChanged),
42
+ '',
43
+ renderOptionalLine('Hypothesis', entry.hypothesis),
44
+ '',
45
+ '**Commands run**:',
46
+ toCodeBlock(entry.commandsRun),
47
+ '',
48
+ renderSmokeLine(entry),
49
+ '',
50
+ renderOptionalLine('Parity status', entry.parityStatus),
51
+ '',
52
+ renderOptionalLine('Rollback plan', entry.rollbackPlan),
53
+ '',
54
+ '---',
55
+ '',
56
+ ].join('\n');
57
+ export const writeMigrationLogMarkdown = async ({ entries, write, }) => {
58
+ await write('# Ushman Ledger Migration Log\n\n');
59
+ let hasEntries = false;
37
60
  for await (const entry of entries) {
38
- if (isChangeLogEntry(entry)) {
39
- changeLogEntries.push(entry);
61
+ if (!isChangeLogEntry(entry)) {
62
+ continue;
40
63
  }
64
+ hasEntries = true;
65
+ await write(renderChangeLogSection(entry));
41
66
  }
42
- changeLogEntries.reverse();
43
- if (changeLogEntries.length === 0) {
44
- return ['# Ushman Ledger Migration Log', '', 'No change-log entries recorded.'].join('\n');
67
+ if (!hasEntries) {
68
+ await write('No change-log entries recorded.');
45
69
  }
46
- return [
47
- '# Ushman Ledger Migration Log',
48
- '',
49
- ...changeLogEntries.flatMap((entry) => [
50
- `## ${entry.ts} - ${entry.summary}`,
51
- '',
52
- `**Type**: ${entry.subkind}`,
53
- '',
54
- '**Files changed**:',
55
- renderFilesChanged(entry.filesChanged),
56
- '',
57
- renderOptionalLine('Hypothesis', entry.hypothesis),
58
- '',
59
- '**Commands run**:',
60
- toCodeBlock(entry.commandsRun),
61
- '',
62
- renderSmokeLine(entry),
63
- '',
64
- renderOptionalLine('Parity status', entry.parityStatus),
65
- '',
66
- renderOptionalLine('Rollback plan', entry.rollbackPlan),
67
- '',
68
- '---',
69
- '',
70
- ]),
71
- ].join('\n');
70
+ };
71
+ export const renderMigrationLogMarkdown = async ({ entries, write, }) => {
72
+ const chunks = [];
73
+ const resolvedWriter = write ??
74
+ ((chunk) => {
75
+ chunks.push(chunk);
76
+ });
77
+ await writeMigrationLogMarkdown({ entries, write: resolvedWriter });
78
+ return chunks.join('');
72
79
  };
@@ -1 +1 @@
1
- {"version":3,"file":"retro.d.ts","sourceRoot":"","sources":["../../src/render/retro.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAgItD,eAAO,MAAM,mBAAmB,GAAU,wBAGvC;IACC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IAC7C,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC9B,KAAG,OAAO,CAAC,MAAM,CAgDjB,CAAC"}
1
+ {"version":3,"file":"retro.d.ts","sourceRoot":"","sources":["../../src/render/retro.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AA4HtD,eAAO,MAAM,mBAAmB,GAAU,wBAGvC;IACC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IAC7C,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC9B,KAAG,OAAO,CAAC,MAAM,CAgDjB,CAAC"}
@@ -21,13 +21,7 @@ const isRetroNote = (entry) => entry.kind === 'note' && entry.subkind === 'retro
21
21
  const isOperatorNote = (entry) => entry.kind === 'note' && entry.subkind === 'operator';
22
22
  const isDedicatedNarrativeEntry = (entry) => entry.kind === 'change-log' ||
23
23
  (entry.kind === 'note' &&
24
- [
25
- 'cleanup-wave',
26
- 'verified-flow',
27
- 'open-issue',
28
- 'decomposition-wave',
29
- 'semantic-cleanup-summary',
30
- ].includes(entry.subkind));
24
+ ['cleanup-wave', 'verified-flow', 'open-issue', 'decomposition-wave', 'semantic-cleanup-summary'].includes(entry.subkind));
31
25
  const resolveRenderedAt = (entryCount, lastEntryTimestamp, manifest) => {
32
26
  if (entryCount > 0) {
33
27
  return lastEntryTimestamp ?? 'n/a';
@@ -1,6 +1,12 @@
1
1
  import type { LedgerEntry } from '../schema/entry.ts';
2
- export declare const renderWorkspaceNarrativeMarkdown: ({ entries, workspaceName, }: {
2
+ export declare const writeWorkspaceNarrativeMarkdown: ({ entries, workspaceName, write, }: {
3
3
  readonly entries: AsyncIterable<LedgerEntry>;
4
4
  readonly workspaceName: string;
5
+ readonly write: (chunk: string) => Promise<void> | void;
6
+ }) => Promise<void>;
7
+ export declare const renderWorkspaceNarrativeMarkdown: ({ entries, workspaceName, write, }: {
8
+ readonly entries: AsyncIterable<LedgerEntry>;
9
+ readonly workspaceName: string;
10
+ readonly write?: (chunk: string) => Promise<void> | void;
5
11
  }) => Promise<string>;
6
12
  //# sourceMappingURL=workspace-narrative.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"workspace-narrative.d.ts","sourceRoot":"","sources":["../../src/render/workspace-narrative.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAa,MAAM,oBAAoB,CAAC;AAsCjE,eAAO,MAAM,gCAAgC,GAAU,6BAGpD;IACC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IAC7C,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAClC,KAAG,OAAO,CAAC,MAAM,CA+CjB,CAAC"}
1
+ {"version":3,"file":"workspace-narrative.d.ts","sourceRoot":"","sources":["../../src/render/workspace-narrative.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAa,MAAM,oBAAoB,CAAC;AAuIjE,eAAO,MAAM,+BAA+B,GAAU,oCAInD;IACC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IAC7C,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAC3D,kBA+BA,CAAC;AAEF,eAAO,MAAM,gCAAgC,GAAU,oCAIpD;IACC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IAC7C,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAC5D,KAAG,OAAO,CAAC,MAAM,CAajB,CAAC"}