footprintjs 0.2.0 → 0.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 (2) hide show
  1. package/README.md +16 -26
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -69,9 +69,8 @@ No one wrote those trace sentences. Stage functions just read and write scope &m
69
69
 
70
70
  ```typescript
71
71
  import {
72
- FlowChartBuilder, FlowChartExecutor, ScopeFacade,
73
- NarrativeRecorder, CombinedNarrativeBuilder,
74
- } from 'footprint';
72
+ FlowChartBuilder, FlowChartExecutor, ScopeFacade, toScopeFactory,
73
+ } from 'footprintjs';
75
74
 
76
75
  // ── Stage functions: just do the work, no descriptions needed ──────────
77
76
 
@@ -129,27 +128,15 @@ const chart = new FlowChartBuilder()
129
128
  .end()
130
129
  .build();
131
130
 
132
- // ── Instrument scope with NarrativeRecorder ────────────────────────────
133
-
134
- const recorder = new NarrativeRecorder({ id: 'loan', detail: 'full' });
135
-
136
- const scopeFactory = (ctx: any, stageName: string) => {
137
- const scope = new ScopeFacade(ctx, stageName);
138
- scope.attachRecorder(recorder);
139
- return scope;
140
- };
141
-
142
131
  // ── Run and get the narrative ──────────────────────────────────────────
143
132
 
144
- const executor = new FlowChartExecutor(chart, scopeFactory);
133
+ const executor = new FlowChartExecutor(chart, toScopeFactory(ScopeFacade));
145
134
  await executor.run();
146
135
 
147
- const flowNarrative = executor.getNarrative(); // control flow sentences
148
- const combined = new CombinedNarrativeBuilder();
149
- const narrative = combined.build(flowNarrative, recorder); // ← the trace above
136
+ const narrative = executor.getNarrative(); // the trace above
150
137
  ```
151
138
 
152
- The NarrativeRecorder observes every `getValue`/`setValue` call. The ControlFlowNarrativeGenerator captures stage transitions and decisions. CombinedNarrativeBuilder merges both into the trace. No descriptions were written by hand.
139
+ `enableNarrative()` auto-instruments every scope. The executor captures stage transitions, decisions, reads, and writes — then merges them into the combined trace. No descriptions were written by hand.
153
140
 
154
141
  ---
155
142
 
@@ -238,7 +225,7 @@ FootPrint has three moving parts:
238
225
  ### Linear
239
226
 
240
227
  ```typescript
241
- import { flowChart } from 'footprint';
228
+ import { flowChart } from 'footprintjs';
242
229
 
243
230
  flowChart('A', fnA)
244
231
  .addFunction('B', fnB)
@@ -365,7 +352,7 @@ Each stage receives a **scope** — a transactional interface to shared stat
365
352
  Extend `ScopeFacade` with domain-specific getters for type-safe reads:
366
353
 
367
354
  ```typescript
368
- import { ScopeFacade } from 'footprint';
355
+ import { ScopeFacade } from 'footprintjs';
369
356
 
370
357
  class LoanScope extends ScopeFacade {
371
358
  get creditScore(): number {
@@ -403,7 +390,7 @@ const total = scope.getValue('total'); // read
403
390
 
404
391
  ```typescript
405
392
  import { z } from 'zod';
406
- import { defineScopeFromZod } from 'footprint';
393
+ import { defineScopeFromZod } from 'footprintjs';
407
394
 
408
395
  const schema = z.object({
409
396
  creditScore: z.number(),
@@ -424,18 +411,19 @@ Recorders observe scope operations without modifying them. Attach multiple for d
424
411
 
425
412
  ```typescript
426
413
  import {
427
- ScopeFacade, DebugRecorder, MetricRecorder, NarrativeRecorder,
428
- } from 'footprint';
414
+ ScopeFacade, DebugRecorder, MetricRecorder,
415
+ } from 'footprintjs';
429
416
 
430
417
  const scopeFactory = (ctx: any, stageName: string) => {
431
418
  const scope = new ScopeFacade(ctx, stageName);
432
419
  scope.attachRecorder(new DebugRecorder({ verbosity: 'verbose' }));
433
420
  scope.attachRecorder(new MetricRecorder());
434
- scope.attachRecorder(new NarrativeRecorder({ id: 'trace', detail: 'full' }));
435
421
  return scope;
436
422
  };
437
423
  ```
438
424
 
425
+ > **Note:** `NarrativeRecorder` is attached automatically when narrative is enabled via `setEnableNarrative()` or `executor.enableNarrative()`. You only need to attach it manually if you need custom options.
426
+
439
427
  Error isolation is built in: if a recorder throws, the error is routed to `onError` hooks of other recorders, and the scope operation continues normally.
440
428
 
441
429
  ### Custom Recorders
@@ -443,7 +431,7 @@ Error isolation is built in: if a recorder throws, the error is routed to `onErr
443
431
  Implement any subset of six hooks: `onRead`, `onWrite`, `onCommit`, `onError`, `onStageStart`, `onStageEnd`.
444
432
 
445
433
  ```typescript
446
- import { Recorder, WriteEvent } from 'footprint';
434
+ import { Recorder, WriteEvent } from 'footprintjs';
447
435
 
448
436
  class AuditRecorder implements Recorder {
449
437
  readonly id = 'audit';
@@ -591,7 +579,9 @@ An LLM reading this trace can immediately explain: *"The validation failed becau
591
579
  | Method | Description |
592
580
  |--------|-------------|
593
581
  | `run(options?)` | Execute the flowchart. Options: `{ signal?, timeoutMs? }` |
594
- | `getNarrative()` | Control-flow narrative sentences |
582
+ | `getNarrative()` | Combined narrative (flow + data) with ScopeFacade; flow-only otherwise |
583
+ | `getFlowNarrative()` | Flow-only narrative sentences |
584
+ | `getNarrativeEntries()` | Structured `CombinedNarrativeEntry[]` for programmatic use |
595
585
  | `getSnapshot()` | Full execution tree + state |
596
586
  | `getExtractedResults()` | Extractor results map |
597
587
  | `getEnrichedResults()` | Enriched snapshots (scope state, debug info, output) |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "footprintjs",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Turn your whiteboard flowchart into running code — with automatic causal traces for LLM reasoning",
5
5
  "license": "MIT",
6
6
  "author": "Sanjay Krishna Anbalagan",