pi-supernova 0.10.1 → 0.11.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.
Files changed (81) hide show
  1. package/README.md +376 -221
  2. package/docs/CHANGELOG.md +107 -5
  3. package/docs/TOKEN_COSTS.md +149 -324
  4. package/index.js +40 -11
  5. package/package.json +4 -3
  6. package/src/adapters/bash.js +40 -10
  7. package/src/adapters/edit.js +77 -23
  8. package/src/adapters/errors.js +4 -0
  9. package/src/adapters/index.js +1 -0
  10. package/src/adapters/list.js +6 -3
  11. package/src/adapters/read-focus.js +6 -0
  12. package/src/adapters/read-image.js +17 -9
  13. package/src/adapters/read-indexed.js +72 -0
  14. package/src/adapters/read-text.js +19 -2
  15. package/src/adapters/read.js +57 -13
  16. package/src/adapters/refs.js +17 -7
  17. package/src/adapters/write.js +14 -21
  18. package/src/bridge/host-bridge.js +152 -39
  19. package/src/bridge/invoke.js +3 -1
  20. package/src/bridge/tool-registry.js +132 -16
  21. package/src/context/evidence-graph.js +1 -0
  22. package/src/context/evidence-rank.js +1 -0
  23. package/src/context/evidence.js +4 -2
  24. package/src/context/fuzzy.js +31 -8
  25. package/src/context/outline.js +33 -9
  26. package/src/context/query.js +7 -2
  27. package/src/context/repo-index.js +8 -3
  28. package/src/context/search-files.js +20 -0
  29. package/src/context/search.js +25 -10
  30. package/src/context/snap-search.js +28 -6
  31. package/src/context/snap.js +8 -3
  32. package/src/context/source-entry.js +64 -28
  33. package/src/context/spans.js +1 -0
  34. package/src/contract/bash.js +16 -7
  35. package/src/contract/edit.js +26 -7
  36. package/src/contract/program.js +2 -1
  37. package/src/contract/read.js +46 -46
  38. package/src/fs/background.js +10 -2
  39. package/src/fs/check.js +844 -46
  40. package/src/fs/commit.js +89 -15
  41. package/src/fs/diff.js +12 -9
  42. package/src/fs/directory.js +14 -4
  43. package/src/fs/file-io.js +28 -7
  44. package/src/fs/glob.js +93 -11
  45. package/src/fs/json-read.js +3 -2
  46. package/src/fs/json-size.js +2 -1
  47. package/src/fs/lines.js +49 -2
  48. package/src/fs/patch.js +26 -10
  49. package/src/fs/process-tree.js +19 -1
  50. package/src/fs/read-window.js +36 -20
  51. package/src/fs/source-window.js +5 -10
  52. package/src/fs/text-ops.js +39 -19
  53. package/src/fs/vfs.js +296 -41
  54. package/src/fs/workspace.js +24 -6
  55. package/src/output/bottleneck.js +50 -25
  56. package/src/output/final.js +20 -0
  57. package/src/output/format.js +97 -36
  58. package/src/output/outcome.js +25 -9
  59. package/src/runtime/batch-input.js +17 -3
  60. package/src/runtime/guest-api.js +32 -7
  61. package/src/runtime/guest-worker.js +22 -4
  62. package/src/runtime/parallel.js +9 -49
  63. package/src/runtime/program-batch.js +53 -28
  64. package/src/runtime/program-file.js +2 -1
  65. package/src/runtime/program.js +94 -41
  66. package/src/runtime/reference.js +10 -9
  67. package/src/runtime/runtime.js +86 -17
  68. package/src/runtime/worker-pool.js +10 -1
  69. package/src/shared/decode.js +9 -8
  70. package/src/shared/image-worker.js +7 -0
  71. package/src/shared/image.js +58 -15
  72. package/src/shared/png.js +18 -0
  73. package/src/shared/result.js +30 -9
  74. package/src/shared/syntax-context.js +7 -1
  75. package/src/shared/utf8.js +11 -13
  76. package/src/ui/host-render.js +4 -0
  77. package/src/ui/omp-frame.js +2 -0
  78. package/src/ui/progress.js +2 -1
  79. package/src/ui/render-measure.js +11 -0
  80. package/src/ui/render.js +92 -31
  81. package/src/ui/trace.js +8 -5
package/docs/CHANGELOG.md CHANGED
@@ -1,5 +1,107 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.11.0
4
+
5
+ ### Changed
6
+
7
+ - Window and image reads close their file handles before waiting for transaction
8
+ recovery, allowing Windows to restore backups. Bounded Windows sharing-violation
9
+ retries revalidate publication and recovery targets before replacing them.
10
+ Windows loaded-byte baselines
11
+ and final publication also verify content when timestamps alias a rewrite.
12
+ Overlong Windows edit paths receive the same bounded recovery guidance as
13
+ Unix paths.
14
+ - Missing optional TypeBox no longer changes the public JSON schema or its
15
+ serialized standing-definition cost. Explicit nested program-entry validation
16
+ remains unchanged; clean-install token gates use the same schema as hosts.
17
+ - Image decoder error events no longer release the raster queue before child
18
+ close or disarm its watchdog. Repeated errors remain handled and preserve
19
+ the first diagnostic; failed spawns/decodes never seed the validation cache.
20
+ - Indexed source locators accept canonical spellings of workspace aliases while
21
+ retaining logical editable paths and both lexical/canonical scope admission.
22
+ - C++ quick checks recognize prefixed/custom-delimited raw strings rather than
23
+ reporting valid multiline literals as unterminated ordinary strings. C++
24
+ edit receipts no longer search for the type keyword `auto` as a declaration;
25
+ JavaScript bindings named `auto` keep their reference hints. Checks remain
26
+ structural heuristics, not compiler validation.
27
+ - Background output snapshots align UTF-16 boundaries to complete code points
28
+ and disclose skipped partial characters through outputStart/truncated.
29
+ - Contention stress accepts concurrent-read conflicts as well as write conflicts
30
+ while verifying every committed increment. Idle-host tests now allow startup
31
+ separately from the unchanged 1.5-second initialized-host exit deadline.
32
+ - Dense newline statistics use an adaptive character scan after the bounded
33
+ preview is complete, returning to native searches when text becomes sparse.
34
+ Read/write receipts retain identical counts, previews and EOF semantics. No
35
+ persistent cache or full-file line array is introduced.
36
+ - Overlong edit/patch targets now report bounded path/view recovery guidance
37
+ instead of echoing source text accidentally used as a filename. Edit mismatch
38
+ previews no longer claim whitespace drift when a later line differs. Exact
39
+ matching, ambiguity rejection, workspace boundaries and rollback are unchanged.
40
+ - Session-derived fixes keep owned foreground shell output complete inside the
41
+ guest up to a 2 Mi UTF-16-character capture ceiling; model previews remain
42
+ bounded and larger capture fails with file-redirection guidance. Positional
43
+ write options now honor append/explicit replacement instead of silently
44
+ dropping flags. JSON projection accepts literal hyphenated own-property keys
45
+ without evaluating expressions or traversing prototypes. Nova presentation,
46
+ edit/CAS guards, permissions and deadlines are unchanged.
47
+ - Read storage accounting charges scalar strings during the container walk instead
48
+ of retaining them for a second pass. Typed values, alias handling and aggregate
49
+ selection limits are unchanged; over-budget reads still roll back staged work.
50
+ - Repeated result repaints reuse one bounded, uncolored layout per Nova card.
51
+ Theme changes still repaint colors; content changes and resizing rebuild layout.
52
+ - Compact Nova TUI cards keep the latest calls in place through completion,
53
+ preview the latest change and bound collapsed diagnostics. Successful call
54
+ cards retain their original compact default: returned source/JSON appears
55
+ only on expansion; JavaScript-only runs still show their short result.
56
+ Progress updates coalesce at 32 ms; large displayed values are bounded before
57
+ layout and printable ASCII wraps in bulk. Expanded detail, Unicode column
58
+ safety and complete machine-facing values remain available under their
59
+ existing execution budgets. No Pi or dependency changes are required.
60
+ - File-local focused text reads without declarations no longer wait for workspace
61
+ caller discovery. Their output and empty-about fallback remain unchanged;
62
+ declaration outlines still include caller hints.
63
+ - Focused outlines collect caller hints for all expanded declarations in one
64
+ workspace scan, preserving per-name references and rendered output without
65
+ adding persistent caches.
66
+ - Successful subprocess completion wakes on output-pipe closure instead of waiting
67
+ for a cleanup polling interval. Source searches and background terminals retain
68
+ the existing process-group ownership, escalation and deadline checks. No Pi
69
+ modifications, runtime dependency changes or public API changes are required.
70
+ - Overlay keys, conflict signatures and commit destinations share canonical
71
+ filesystem identity. Logical paths remain in receipts and diagnostics. Missing
72
+ paths resolve through the nearest existing ancestor. Observed logical-to-physical
73
+ bindings reject retargeted aliases. Identity reuse is call-local; commits resolve
74
+ destinations afresh. `CausalVfs` still has no body cache: every read hits disk
75
+ or its overlay.
76
+ - Successful native `edit`/`write` steps publish before returning. Later read
77
+ errors, failed shells, invalid returned images or uncaught JavaScript do not
78
+ undo those saved steps. `edit(async () => { ... })` remains an explicit atomic
79
+ filesystem checkpoint. A single `edit({path,edits:[...]})` replacement set is
80
+ still one atomic step. Independent sequential and parallel `programs` continue
81
+ after ordinary errors; shared budgets, cancellation and uncertain filesystem
82
+ outcomes stop queued work. Failed programs expose `details.savedPaths` and
83
+ `error.supernovaResult`. Batch results expose zero-based `failedPrograms`,
84
+ `notRunPrograms` and `programIndex`. Dependent JavaScript still stops at an
85
+ uncaught exception; there is no automatic resumption or replay.
86
+
87
+ ## [0.10.2] - 2026-09-24
88
+
89
+ ### Changed
90
+
91
+ - Results print the `mutations:` line only when it informs: files committed or
92
+ rolled back, an uncertain filesystem outcome, or (failures only) shell side
93
+ effects that survive the rollback. Five days of sessions carried it on 2,207
94
+ of 2,467 results, 1,928 of them all-zero (~240k characters).
95
+
96
+ ### Fixed
97
+
98
+ - Redeclaring or shadowing `read`/`edit`/`write`/`bash` (e.g.
99
+ `const read = await read(...)`) now says the name is a supernova command,
100
+ instead of a misleading `data` hint or a bare TDZ error. The `data` hint
101
+ appears only when `data` itself was redeclared.
102
+ - `supernova(...)` called inside a program says to call the commands directly.
103
+ - Empty `oldText` says how to insert: anchor on adjacent existing text.
104
+
3
105
  ## [0.10.1] - 2026-09-23
4
106
 
5
107
  ### Fixed
@@ -215,7 +317,7 @@
215
317
 
216
318
  - Guest worker links on hosts without `module.registerHooks` (Bun, Node <22.15):
217
319
  `node:module` is now a namespace import with runtime feature detection, so the
218
- `register` fallback — and hosts with neither hook mechanism — no longer fail at
320
+ `register` fallback -- and hosts with neither hook mechanism -- no longer fail at
219
321
  module-eval time. Previously every program failed before its first command with
220
322
  "Export named 'registerHooks' not found", e.g. under OMP/Bun.
221
323
 
@@ -521,7 +623,7 @@
521
623
 
522
624
  ### Removed
523
625
 
524
- - Dead code (−638 lines net): the static `extractOperationsFromCode` source-regex preview (the live trace superseded it), `SafeText`/`fitOutputLines`/`wrapPlainToWidth` (the call slot is always empty), `shutdownGuestWorkers`, `decode.js` helpers nobody imported, `vfs.clear`, the `tools` alias for `nova`, unused bridge methods (`hasExecutor`, `clearVfsCache`, `isMutating`), `test/verify-width-crash.mjs`, and unused status-header knobs (`spinnerFrame`, `iconOverride`).
626
+ - Dead code (-638 lines net): the static `extractOperationsFromCode` source-regex preview (the live trace superseded it), `SafeText`/`fitOutputLines`/`wrapPlainToWidth` (the call slot is always empty), `shutdownGuestWorkers`, `decode.js` helpers nobody imported, `vfs.clear`, the `tools` alias for `nova`, unused bridge methods (`hasExecutor`, `clearVfsCache`, `isMutating`), `test/verify-width-crash.mjs`, and unused status-header knobs (`spinnerFrame`, `iconOverride`).
525
627
  - `edit` no longer accepts a unified diff (`patch`/`oldText` starting with `@@`); `apply_patch` / `patch()` is the one way to apply a diff.
526
628
  - `nova.surface`/`nova.snap` host-side unwrapping and their dedicated RPC methods: both route through `nova.call` and the guest unwraps once.
527
629
 
@@ -538,12 +640,12 @@
538
640
 
539
641
  ### Added
540
642
 
541
- - **Seen-ledger.** The model's context window is treated as memory: a result never re-sends a run of lines (≥6, mostly substantive) that an earlier result in the session already contained. The run collapses to `⋯ N lines same as #12 · path:a–b ⋯`, citing the earlier program and, when the lines came from a file, the exact range, so one `read(path, a, n)` recovers them. Changed lines are never collapsed, so a re-read after an edit is exactly the delta. Lines the current program read with an explicit `offset`/`limit` are pinned and always shown. Programs are numbered (`ok #12 3ms`) to anchor the citations; the window is `seenWindow` programs (default 40) and resets on `session_start`. Not compression: every collapsed line already exists verbatim in the model's context. `/supernova` reports the session's returned vs. not-re-sent tokens.
643
+ - **Seen-ledger.** The model's context window is treated as memory: a result never re-sends a run of lines (≥6, mostly substantive) that an earlier result in the session already contained. The run collapses to `⋯ N lines same as #12 · path:a--b ⋯`, citing the earlier program and, when the lines came from a file, the exact range, so one `read(path, a, n)` recovers them. Changed lines are never collapsed, so a re-read after an edit is exactly the delta. Lines the current program read with an explicit `offset`/`limit` are pinned and always shown. Programs are numbered (`ok #12 3ms`) to anchor the citations; the window is `seenWindow` programs (default 40) and resets on `session_start`. Not compression: every collapsed line already exists verbatim in the model's context. `/supernova` reports the session's returned vs. not-re-sent tokens.
542
644
  - **Edits close the loop.** `edit` returns the post-edit lines with numbers (±2 context, ≤40 lines) so no verification re-read is needed; a quick structural check (`check: unclosed '{' opened at line 1`, JSON parsed exactly; brackets/strings/templates/regex-aware, 0 false positives over 6,100 source files); and `X also referenced in a.js:12, b.js:40` for every declaration the edit changed, so callers are not forgotten.
543
645
  - **Failures carry their source.** A failing `bash` appends `--- source` with ±2 lines around each `path:line` it printed (≤4 sites), so a stack trace or test failure does not cost a read turn.
544
646
  - **Outlines carry relations.** Expanded spans in `read(path, {about})` end with `// used by: a.js:12, b.js:40`.
545
647
 
546
- Measured on a read→edit→verify→edit→verify→outline→outline loop: 20,967 tokens naive vs **3,098** (−85%); the verification re-read costs 49 tokens instead of 1,078.
648
+ Measured on a read→edit→verify→edit→verify→outline→outline loop: 20,967 tokens naive vs **3,098** (-85%); the verification re-read costs 49 tokens instead of 1,078.
547
649
 
548
650
  ### Changed
549
651
 
@@ -574,7 +676,7 @@ Measured on a read→edit→verify→edit→verify→outline→outline loop: 20,
574
676
 
575
677
  ### Added
576
678
 
577
- - `evidence(query, {k?, path?, maxChars?})`: zero-token evidence selection over the codebase after Zero-Mem (arXiv:2607.29377), implemented 1:1 with the paper's non-generative pipeline: declared spans are the context units and identifiers the entities (eq.3), entity–span weights `w(d,e)=c(e,d)/Σc` (eq.4), file→span→line hierarchy (eq.5, eq.11), a deterministic query profile and relational/local route (eq.6–7), lexical entity alignment and one IDF-damped co-occurrence propagation step (eq.8–9), personalized PageRank `π=(1−γ)r+γPᵀπ` over spans (eq.10, γ=0.85, 10 iterations, factored through the entity layer so it is O(nnz)), per-view min-max normalisation and ρ-weighted fusion (eq.12–13, ρ=0.7), closure with definition bridges and in-file neighbours (eq.14), and calibration that filters by boundary/answer type/lexical support and ranks by type compatibility (eq.15). Returns top-K (default 5, per the paper's Top-5 ≈ Top-10 finding) verbatim source spans with path and line provenance under a 6000-char budget. Across 8 understanding questions on this repo the correct span ranks first and the result costs **68% fewer tokens** than reading the files the question spans (43,916 → 14,147). Warm latency 1–4ms.
679
+ - `evidence(query, {k?, path?, maxChars?})`: zero-token evidence selection over the codebase after Zero-Mem (arXiv:2607.29377), implemented 1:1 with the paper's non-generative pipeline: declared spans are the context units and identifiers the entities (eq.3), entity--span weights `w(d,e)=c(e,d)/Σc` (eq.4), file→span→line hierarchy (eq.5, eq.11), a deterministic query profile and relational/local route (eq.6--7), lexical entity alignment and one IDF-damped co-occurrence propagation step (eq.8--9), personalized PageRank `π=(1-γ)r+γPᵀπ` over spans (eq.10, γ=0.85, 10 iterations, factored through the entity layer so it is O(nnz)), per-view min-max normalisation and ρ-weighted fusion (eq.12--13, ρ=0.7), closure with definition bridges and in-file neighbours (eq.14), and calibration that filters by boundary/answer type/lexical support and ranks by type compatibility (eq.15). Returns top-K (default 5, per the paper's Top-5 ≈ Top-10 finding) verbatim source spans with path and line provenance under a 6000-char budget. Across 8 understanding questions on this repo the correct span ranks first and the result costs **68% fewer tokens** than reading the files the question spans (43,916 → 14,147). Warm latency 1--4ms.
578
680
  - Structural surface now records column-0 `const/let/var` bindings, so module-level tables are their own spans (also sharpens `snap`).
579
681
 
580
682
  ### Changed