@sriinnu/fiche 0.18.0-bootstrap.0 → 0.19.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 (196) hide show
  1. package/CHANGELOG.md +134 -0
  2. package/LICENSE +22 -0
  3. package/NOTICE +13 -0
  4. package/PRIVACY.md +41 -0
  5. package/README.md +289 -0
  6. package/SECURITY.md +53 -0
  7. package/assets/JETBRAINS_MONO_LICENSE.txt +89 -0
  8. package/assets/SPLEEN_LICENSE.txt +24 -0
  9. package/assets/UNIFONT_LICENSE.txt +476 -0
  10. package/assets/fiche-logo-dark.svg +61 -0
  11. package/assets/fiche-logo-light.svg +61 -0
  12. package/assets/fiche-logo.svg +71 -0
  13. package/assets/fiche-mark.svg +48 -0
  14. package/bin/cli.js +7 -0
  15. package/bin/mcp.js +8 -0
  16. package/dist/calibrate.d.ts +30 -0
  17. package/dist/calibrate.js +588 -0
  18. package/dist/core/anthropic-vision.d.ts +28 -0
  19. package/dist/core/anthropic-vision.js +34 -0
  20. package/dist/core/applicability.d.ts +63 -0
  21. package/dist/core/applicability.js +151 -0
  22. package/dist/core/atlas-gray-jbmono10.d.ts +26 -0
  23. package/dist/core/atlas-gray-jbmono10.js +64 -0
  24. package/dist/core/atlas-gray-jbmono12.d.ts +26 -0
  25. package/dist/core/atlas-gray-jbmono12.js +64 -0
  26. package/dist/core/atlas-gray-jbmono14.d.ts +26 -0
  27. package/dist/core/atlas-gray-jbmono14.js +64 -0
  28. package/dist/core/atlas-gray.d.ts +26 -0
  29. package/dist/core/atlas-gray.js +64 -0
  30. package/dist/core/atlas-jbmono10.d.ts +34 -0
  31. package/dist/core/atlas-jbmono10.js +71 -0
  32. package/dist/core/atlas-jbmono12.d.ts +34 -0
  33. package/dist/core/atlas-jbmono12.js +71 -0
  34. package/dist/core/atlas-jbmono14.d.ts +34 -0
  35. package/dist/core/atlas-jbmono14.js +71 -0
  36. package/dist/core/atlas.d.ts +34 -0
  37. package/dist/core/atlas.js +71 -0
  38. package/dist/core/baseline.d.ts +121 -0
  39. package/dist/core/baseline.js +200 -0
  40. package/dist/core/calibration.d.ts +86 -0
  41. package/dist/core/calibration.js +547 -0
  42. package/dist/core/casi-delta.d.ts +63 -0
  43. package/dist/core/casi-delta.js +1271 -0
  44. package/dist/core/claude-model-profiles.d.ts +53 -0
  45. package/dist/core/claude-model-profiles.js +160 -0
  46. package/dist/core/client-tool-round.d.ts +31 -0
  47. package/dist/core/client-tool-round.js +58 -0
  48. package/dist/core/codex-cache.d.ts +20 -0
  49. package/dist/core/codex-cache.js +59 -0
  50. package/dist/core/context-mmu.d.ts +350 -0
  51. package/dist/core/context-mmu.js +3028 -0
  52. package/dist/core/cpt-fit.d.ts +70 -0
  53. package/dist/core/cpt-fit.js +197 -0
  54. package/dist/core/env.d.ts +8 -0
  55. package/dist/core/env.js +15 -0
  56. package/dist/core/export.d.ts +127 -0
  57. package/dist/core/export.js +385 -0
  58. package/dist/core/factsheet.d.ts +77 -0
  59. package/dist/core/factsheet.js +494 -0
  60. package/dist/core/gemini-model-profiles.d.ts +20 -0
  61. package/dist/core/gemini-model-profiles.js +134 -0
  62. package/dist/core/google.d.ts +76 -0
  63. package/dist/core/google.js +1380 -0
  64. package/dist/core/gpt-model-profiles.d.ts +218 -0
  65. package/dist/core/gpt-model-profiles.js +570 -0
  66. package/dist/core/gpt-tokens.d.ts +14 -0
  67. package/dist/core/gpt-tokens.js +165 -0
  68. package/dist/core/history.d.ts +197 -0
  69. package/dist/core/history.js +1003 -0
  70. package/dist/core/index.d.ts +16 -0
  71. package/dist/core/index.js +16 -0
  72. package/dist/core/library.d.ts +80 -0
  73. package/dist/core/library.js +131 -0
  74. package/dist/core/measurement.d.ts +34 -0
  75. package/dist/core/measurement.js +280 -0
  76. package/dist/core/messages-chat-bridge.d.ts +23 -0
  77. package/dist/core/messages-chat-bridge.js +747 -0
  78. package/dist/core/messages-responses-bridge.d.ts +11 -0
  79. package/dist/core/messages-responses-bridge.js +893 -0
  80. package/dist/core/openai-history.d.ts +184 -0
  81. package/dist/core/openai-history.js +1279 -0
  82. package/dist/core/openai-savings.d.ts +57 -0
  83. package/dist/core/openai-savings.js +116 -0
  84. package/dist/core/openai.d.ts +68 -0
  85. package/dist/core/openai.js +2523 -0
  86. package/dist/core/pin.d.ts +199 -0
  87. package/dist/core/pin.js +1353 -0
  88. package/dist/core/png.d.ts +14 -0
  89. package/dist/core/png.js +188 -0
  90. package/dist/core/prefix-tape.d.ts +102 -0
  91. package/dist/core/prefix-tape.js +315 -0
  92. package/dist/core/price-id.d.ts +10 -0
  93. package/dist/core/price-id.js +26 -0
  94. package/dist/core/prices.generated.d.ts +36 -0
  95. package/dist/core/prices.generated.js +369 -0
  96. package/dist/core/pricing.d.ts +134 -0
  97. package/dist/core/pricing.js +335 -0
  98. package/dist/core/profile-base.d.ts +30 -0
  99. package/dist/core/profile-base.js +67 -0
  100. package/dist/core/provider-router.d.ts +51 -0
  101. package/dist/core/provider-router.js +121 -0
  102. package/dist/core/proxy.d.ts +252 -0
  103. package/dist/core/proxy.js +2929 -0
  104. package/dist/core/reader-tier.d.ts +24 -0
  105. package/dist/core/reader-tier.js +118 -0
  106. package/dist/core/render.d.ts +280 -0
  107. package/dist/core/render.js +1302 -0
  108. package/dist/core/request-guard.d.ts +31 -0
  109. package/dist/core/request-guard.js +126 -0
  110. package/dist/core/request-transform.d.ts +43 -0
  111. package/dist/core/request-transform.js +173 -0
  112. package/dist/core/schema-compiler.d.ts +64 -0
  113. package/dist/core/schema-compiler.js +1696 -0
  114. package/dist/core/schema-strip.d.ts +29 -0
  115. package/dist/core/schema-strip.js +173 -0
  116. package/dist/core/session-state.d.ts +219 -0
  117. package/dist/core/session-state.js +929 -0
  118. package/dist/core/stage-plugins.d.ts +45 -0
  119. package/dist/core/stage-plugins.js +205 -0
  120. package/dist/core/text-history.d.ts +74 -0
  121. package/dist/core/text-history.js +612 -0
  122. package/dist/core/text-hygiene.d.ts +160 -0
  123. package/dist/core/text-hygiene.js +2259 -0
  124. package/dist/core/toon.d.ts +29 -0
  125. package/dist/core/toon.js +425 -0
  126. package/dist/core/tracker.d.ts +223 -0
  127. package/dist/core/tracker.js +290 -0
  128. package/dist/core/transform.d.ts +589 -0
  129. package/dist/core/transform.js +3153 -0
  130. package/dist/core/types.d.ts +87 -0
  131. package/dist/core/types.js +8 -0
  132. package/dist/core/upstream-hosts.d.ts +127 -0
  133. package/dist/core/upstream-hosts.js +398 -0
  134. package/dist/core/vision-cost.d.ts +63 -0
  135. package/dist/core/vision-cost.js +137 -0
  136. package/dist/dashboard/fragments.d.ts +87 -0
  137. package/dist/dashboard/fragments.js +1515 -0
  138. package/dist/dashboard/types.d.ts +217 -0
  139. package/dist/dashboard/types.js +3 -0
  140. package/dist/dashboard/vendor.d.ts +3 -0
  141. package/dist/dashboard/vendor.js +6 -0
  142. package/dist/dashboard.d.ts +372 -0
  143. package/dist/dashboard.js +2731 -0
  144. package/dist/export-collect.d.ts +36 -0
  145. package/dist/export-collect.js +59 -0
  146. package/dist/file-tracker.d.ts +42 -0
  147. package/dist/file-tracker.js +234 -0
  148. package/dist/kosha-sync.d.ts +74 -0
  149. package/dist/kosha-sync.js +272 -0
  150. package/dist/launchd-socket.d.ts +22 -0
  151. package/dist/launchd-socket.js +210 -0
  152. package/dist/mcp/cli.d.ts +2 -0
  153. package/dist/mcp/cli.js +55 -0
  154. package/dist/mcp/server.d.ts +48 -0
  155. package/dist/mcp/server.js +987 -0
  156. package/dist/mmu-store.d.ts +31 -0
  157. package/dist/mmu-store.js +179 -0
  158. package/dist/node-fetch.d.ts +22 -0
  159. package/dist/node-fetch.js +489 -0
  160. package/dist/node.d.ts +9 -0
  161. package/dist/node.js +244396 -0
  162. package/dist/request-decoding.d.ts +30 -0
  163. package/dist/request-decoding.js +85 -0
  164. package/dist/sessions.d.ts +179 -0
  165. package/dist/sessions.js +837 -0
  166. package/dist/stats.d.ts +114 -0
  167. package/dist/stats.js +439 -0
  168. package/dist/turn-report.d.ts +65 -0
  169. package/dist/turn-report.js +724 -0
  170. package/dist/warp/app-launch.d.ts +26 -0
  171. package/dist/warp/app-launch.js +155 -0
  172. package/dist/warp/ca.d.ts +74 -0
  173. package/dist/warp/ca.js +416 -0
  174. package/dist/warp/connect.d.ts +42 -0
  175. package/dist/warp/connect.js +686 -0
  176. package/dist/warp/der.d.ts +57 -0
  177. package/dist/warp/der.js +151 -0
  178. package/dist/warp/index.d.ts +79 -0
  179. package/dist/warp/index.js +650 -0
  180. package/dist/warp/resolve.d.ts +12 -0
  181. package/dist/warp/resolve.js +49 -0
  182. package/dist/warp/route.d.ts +71 -0
  183. package/dist/warp/route.js +134 -0
  184. package/dist/worker.d.ts +71 -0
  185. package/dist/worker.js +174 -0
  186. package/docs/SECURITY_MODEL.md +84 -0
  187. package/package.json +115 -3
  188. package/plugins/fiche-companion/README.md +42 -0
  189. package/plugins/fiche-companion/assets/logo.svg +48 -0
  190. package/plugins/fiche-companion/hooks.json +11 -0
  191. package/plugins/fiche-companion/mcp_config.json +8 -0
  192. package/plugins/fiche-companion/plugin.json +18 -0
  193. package/plugins/fiche-companion/scripts/claude-statusline.mjs +35 -0
  194. package/plugins/fiche-companion/scripts/post-invocation.mjs +122 -0
  195. package/plugins/fiche-companion/scripts/resolve-turn-report.mjs +132 -0
  196. package/plugins/fiche-companion/skills/fiche/SKILL.md +61 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,134 @@
1
+ # Changelog
2
+
3
+ `@sriinnu/fiche` (`fiche`) follows [Semantic Versioning](https://semver.org/) (pre-1.0: minor =
4
+ features or behaviour changes, patch = fixes). Where the code comes from is in
5
+ the README's Credits section.
6
+
7
+ ## 0.19.0
8
+
9
+ - **P0–P3 Context Compiler & `Context-MMU` Virtual Memory (`src/core/context-mmu.ts`, `prefix-tape.ts`, `text-history.ts`, `schema-compiler.ts`, `casi-delta.ts`)**:
10
+ - **P0 Structural, Hygiene & `PrefixMemoTape`**: XML-Island TSCG separating `6` volatile `VOLATILE_XML_TAGS` before paragraph deduplication (`96` schema / `140` static chars), Merkle Schema DAG (`$defs._fN`) on Anthropic & OpenAI wires (bypassed on Google), single-level JSON-in-JSON unwrapping across `8` wrapper keys with `@fiche-kv` fallback, opt-in `cleanUserPayloads` (`false` default, protecting Turn-1 prompts `>= 4,000` chars), and pure leaf `PrefixMemoTape` (`src/core/prefix-tape.ts`: Stage-2 LRU `1024` / `12 MiB`, session-scoped Unified Prefix Seal Table `512` × `512`, and Merkle prefix-state CASI memo `1024` / `8 MiB` with chronological `deferredBases` flush on misses).
11
+ - **P1 `CASI v2`/`v3` & `calibration.ts`**: Line-number gutter stripping, `Write`/`Edit` `seedBase`, bounded `PREPARED_LINES_CACHE` (`192` LRU entries, `>= 256` chars), recursive Histogram Diff (`histogramAnchors`, `HISTOGRAM_MAX_DEPTH = 16`, `HISTOGRAM_MAX_OCCURRENCES = 64`), LIS shifted-line alignment, `GEAR_TABLE` FastCDC (`8–48` lines), and 4-axis optical auto-calibration CLI (`fiche calibrate <model>`, `HEX >= 0.85`, `CODE >= 0.90`, `NUM >= 0.95`, `GUARD = 1.0`, `<= 512px` cliff height & `tile` width clamps, atomic `0600` `~/.config/fiche/calibrated-models.json`).
12
+ - **P2 `LSM-Context` Prefix-Cache Stability & Horizon Gate**: Strictly 1-block `[item]` sticky epochs (`tail = 2` `L1`, `tail = 6` `L0`) keyed by `(sessionKey, fnv64Hex)`, Horizon-Aware Online Compaction Gate (`computeHorizonPaybackLimit` separating append/rolling `cutoffMsg` frontiers from mid-prefix epochs), FIFO eviction, `2,048`-entry BPE memoization, and cold-cache `L2` repack (`everCacheAlive && !lastCacheAlive`, `justRepacked` cooldown) across all `5` provider cache-read headers.
13
+ - **P3 `Context-MMU`, Context-TLB & Minoux Submodular Pruning**: Deterministic UTF-8 `pg_<12hex>` virtual pages (`512`-page / `16 MiB` session-isolated LRU), Turn-1 `>= 10`-skill catalog linking (`linkSessionSkills`) with `session-state.ts` pin persistence & auto-hydration, `FAIL→PASS` Markovian episode folding anchored at first failure preserving pre-failure reads, Minoux Lazy Greedy Submodular Coverage IDF pruning (`pruneLowDensityBlob` over `POW_HALF`), and per-session Context-TLB (`TLB_DEFAULT_COOLDOWN_TURNS = 3`) + active-turn-only intent window `±15`-line live-tail hydration (`computeTailHydration`, `MAX_DEREF_CHARS = 65_536`).
14
+ - **Hybrid Slab-Optical + Text-MMU Mode (`OpticalMode`) & Google Optical KV-Cache Seal (`src/core/{transform,google,openai}.ts`)**:
15
+ - Added `OpticalMode = 'auto' | 'hybrid' | 'full'` and `resolveOpticalHistoryPolicy()`, auto-selecting `'hybrid'` when `priceMode() === 'kosha' && rates.read <= 0.10 && estPromptTokens < 160_000`: renders Turn-1 static system instructions/tools into an optical PNG slab once while compiling multi-turn tool/observation history via Text + `Context-MMU` (`49.9%` raw / **`38.8%` weighted** saved / **`88.8%` cache hit** across `60` PNGs on `gemini-4-argon` `30`-turn replay vs. `47.0%` raw / `36.2%` weighted on 0-image Text+MMU and `49.0%` raw / `3.0%` weighted across `153` PNGs on Full Optical). Detached mutable `pinnedUserText` onto the trailing live turn in `planGoogleHistory`, disabled `CASI` pointers in Full Optical (`!opticalEnabled`), and exempted live-tail file reads (`read_file` / `view_file`) from optical imaging until sealed into history (`editSafe = true`, `tailRecallVerified = true`).
16
+ - **Security, RAM-Only MMU Default, Zero-Drop Operations & Staged Release Hardening**:
17
+ - Kept Context-MMU strictly in daemon memory by default with opt-in `FICHE_MMU_PERSIST=1` (`O_WRONLY|O_CREAT|O_EXCL|O_NOFOLLOW`, `0600`, `32 MiB` `load()` cap, `24h` idle TTL, and high-confidence secret filtering), added `fiche mmu [stats|pages|page <id>]` CLI and `page_in`/`mmu_stats` MCP tools with loopback daemon HTTP fallback, enforced same-origin `Origin` checks and `no-store` headers across `/api/mmu/*` dashboard routes, and switched `.github/workflows/release.yml` to `npm stage publish --provenance --access public`.
18
+ - **Zero-Drop Atomic Build & Graceful SSE Drain (`scripts/build.mjs`, `src/node.ts`, `src/dashboard.ts`)**: Switched builds to `.dist-staging` + staged version smoke check + atomic `rename()` swap into `dist/`, added `active_requests` on `/api/health`, raised active-stream shutdown drain to `60s` (`FICHE_SHUTDOWN_DRAIN_MS`) while keeping idle shutdowns at `1.5s`, and set `ExitTimeOut: 65` in `fiche service install`.
19
+ - **Upstream Parity & Edge-Case Hardening**: Added rejected `anthropic-beta` retry + failure reason tracking on `countTokensUpstream`, excluded server-side thread continuations (`isThreadContinuation`) from savings rollups, raised loopback buffered cap to `64 MiB` with backpressured streaming passthrough (`oversizedBodyPolicy: 'passthrough'`), enabled Claude Code pure tool-loop history collapse (`separateAdjacentToolPairs` / `FICHE_TRUST_ADJACENT_TOOL_ROUNDS`), isolated sessions via `x-claude-code-session-id` + slash-command boilerplate stripping (`isBoilerplateText`), preserved JSON Schema `dependent*` property containers, rejected flag-shaped `--out`/`--model` args in `fiche export`, exempted live-tail file reads on Google `compressGoogleToolResults` + emitted `systemSha8`, and fixed `src/stats.ts` inclusive `cached_tokens` subtraction.
20
+ - **Node HTTP/1.1 Keep-Alive Fetch, Client-Abort Propagation & Warp Fail-Open (`src/node-fetch.ts`, `src/core/proxy.ts`, `src/node.ts`, `src/warp/`)**: Replaced Node `globalThis.fetch` upstream transport with dedicated HTTP/1.1 `node:http`/`node:https` keep-alive agents in `src/node-fetch.ts` (avoiding Node 26 / undici `8.12.4` HTTP/2 idle-reaper `ClientHttp2Stream` crashes, `sriinnu/fiche#33` / `nodejs/undici#6143`), propagated client disconnect `AbortSignal` into upstream fetches & `count_tokens` probes, cancelled unread/timed-out/tee'd response bodies on every error path, and updated `fiche warp` to bypass wrapping cleanly when the daemon is stopped (`isLocalDaemonReachable`) or fail open directly on mid-session `ECONNREFUSED` (`failOpenOnDivertRefused`).
21
+ - **Zero-Drop Socket Activation & Warp Loopback `NO_PROXY` (`src/launchd-socket.ts`, `src/node.ts`, `src/warp/index.ts`)**: Eliminated daemon restart/respawn `ECONNREFUSED` connection drops (`sriinnu/fiche#34`) via macOS `launchd` `<key>Sockets</key>` (`Listeners`) paired with a lightweight `<launch.h>` exec trampoline (`fiche-launchd-exec`) and standard `LISTEN_FDS`/`LISTEN_PID` fd inheritance (`resolveInheritedListenFd`, also compatible with Linux `systemd`), moved listener binding ahead of session/MMU/replay startup restoration (`readyPromise`-gated handler), separated established idle keep-alive sockets from freshly accepted sockets on shutdown (`closeIdleSockets`), and merged loopback hosts (`localhost,127.0.0.1,::1`) into wrapped `NO_PROXY`/`no_proxy` environments in `fiche warp`.
22
+ - **Multi-Provider Swarm Hardening & Kosha Sync (`src/kosha-sync.ts`, `src/core/{proxy,transform,google,openai,reader-tier,context-mmu,session-state}.ts`, `apps/macos-bar/`)**: Added `fiche models sync-kosha` (dry-run by default; `--apply`, `--all-providers`, `--providers`, `--file`, `--replace`) plus 1-click **Kosha Registry Sync** (`Sync`, `Update & Sync`, and `All 21 providers` toggle) directly in `FicheBar`'s **Models** tab to sync normalized chat model bases from `~/.kosha/registry.json` or `kosha registry export` with `TEXT_ONLY` safety guards for open-weight/third-party families (`qwen`, `llama`, `mistral`, `codestral`, `command-`, `gemma`, `gpt-oss`, etc.); extended provider-neutral session isolation (`x-fiche-session-id` / `x-inkling-session-id` stripped before upstream forwarding) across all 4 wire adapters (`anthropic`, `openai_chat`, `openai_responses`, `google`) and `inFlight` `409` dedupe keys; and added configurable RAM bounds (`mmu_max_pages`, `mmu_max_mb`, `max_sessions` in `~/.config/fiche/config.json` / `FICHE_MMU_MAX_PAGES`, `FICHE_MMU_MAX_MB`, `FICHE_MAX_SESSIONS`). (AWS Bedrock SigV4, GCP Vertex AI regional IAM/ADC, and internal plain-HTTP LiteLLM gateways remain out of scope / not covered in `v0.19.0`.)
23
+ - **Tracks A–F Audit Hardening, Cache Soundness, GPT-6 Savings & Notarized `FicheBar.app` (`v0.19.0` build `5`)**:
24
+ - **Anthropic `1h` cache soundness (Track E)**: Scoped `markCacheDead` / `noteCacheOutcome` per `{ model }`, persisted `sealedStage2SlotKeys` with monotonic `stage2RewritePaybackBlocked` guards, gated `foldMarkovianEpisodes` behind warm `1h` breakpoints (`>= 2,000` saved tokens and payback cap `8`), and filtered partial `thread_continue` baseline probes via `isUsableAnthropicBaselineProbe` across `baseline.ts`, `stats.ts`, `turn-report.ts`, and `dashboard.ts`.
25
+ - **GPT-6 `Sol` / `Astra` / `Terra` / `Luna` savings (Track F)**: Enabled `TSCG` + `skillLinker` inside `hybridTextMmu` (Responses & Chat), lowered default `lsmMinLargeTokens` to `600` with `effectiveWriteRate = 1.0` on auto-cache OpenAI models, added `hybrid_tool_optical` (`>= 2,500` chars, `oai_opt_tr:` seal + live-tail `isFileReadToolName` `editSafe` guard) and `hybrid_user_optical` (`>= 24,000` chars middle optical imaging), and included `'output_text'` extraction in `responsesContentText`.
26
+ - **Codex WebSocket `426` fallback & Developer ID notarization**: `src/warp/connect.ts` returns `426 Upgrade Required` (`websocket_unsupported`) on diverted OpenAI/Codex WebSocket upgrades while keeping unmatched routes spliced; `apps/macos-bar/` (`FicheBar.app` `0.19.0`, build `5`) ships Developer-ID signed and Apple-notarized via `release-macos` in `.github/workflows/release.yml` alongside `scripts/update-homebrew-tap.sh`.
27
+
28
+ ## 0.18.0
29
+
30
+ - **Restart-proof analytics & Tokmeter-style local metrics**: `DashboardState.replay()` restores lifetime, 90-day local-date (`YYYY-MM-DD`), per-model, and active-session accumulators across daemon restarts from `~/.fiche/events.jsonl` and `.1` using a bounded 50-row tail ring buffer, finite numeric validation, and `/fragments/analytics` with interactive 14-day `Tokens`/`USD` bar charts and proportional per-model breakdowns.
31
+ - **Native `FicheBar.app` v0.18.0 (`Agents` tab + live attachment status)**:
32
+ - `Lifetime` / `Today` hero switcher with weighted + raw subtitles, 14-day `DailySavingsChartView` (`Tokens`/`USD` toggle + hover readout), and proportional `By Model` bars.
33
+ - Universal `Agents` tab discovering installed Desktop Apps (`Antigravity`, `Antigravity IDE`, `Cursor`, `Claude`, `Windsurf`, `Zed`, `OpenCode`, `ChatGPT (Codex)`, `Codex`, `Runic`) and Coding CLIs (`claude`, `codex`, `agy`, `gemini`, `opencode`, `cursor-agent`, `amp`, `pi`, `aider`) with live process-tree attachment indicators (`Attached`, `Running direct`, `Stopped`, `N attached` / `N direct`), safe shell RC auto-wrap installer (`~/.zshrc`, `$ZDOTDIR`, `~/.bashrc`), and built-in FAQ.
34
+ - **Core, Warp, Bridge & FileTracker hardening (Carbon Audit Wave 2)**:
35
+ - Fixed `collapseHistory` adaptive post-render image budget enforcement + bounded density re-budget, `userTurnBlocks` profile render options, `FACTSHEET_PAGE_CHARS` export & repeat tally, OpenAI/Google pin relocation guards, `isFileReadToolName` compound namespaces, `CODE_DECL_LINE_RE` ReDoS guard, and `FileTracker` active-rewrite buffering with atomic cleanup.
36
+ - Hardened `fiche warp` CA/TLS (RFC 5280 SKI/AKI/SPKI, SNI validation, per-CONNECT 30s handshake timeout, strict route path normalization, ChatGPT/Codex `app.asar` + Electron proxy flags, and `FICHE_BYPASS=1` shell-wrapper flow) and Responses/Chat bridge `reasoning`/`stop_reason`/fragmented SSE sniffing.
37
+
38
+ ## 0.17.0
39
+
40
+ - Rebranded from `@sriinnu/inkling` to **`@sriinnu/fiche`** (`fiche` and
41
+ `fiche-mcp` commands, `FICHE_*` environment variables, `x-fiche-*` headers,
42
+ `~/.fiche` and `~/.config/fiche/config.json` state paths, `@fiche pin`), with
43
+ full backwards-compatible runtime fallbacks for legacy `INKLING_*`,
44
+ `x-inkling-*`, `~/.inkling`, `~/.config/inkling/config.json`, `@inkling pin`,
45
+ and `@deprecated` `Inkling*` TypeScript SDK aliases.
46
+ - 4-layer deterministic text compiler (`src/core/text-hygiene.ts`,
47
+ `schema-compiler.ts`, `toon.ts`, `text-history.ts`, `casi-delta.ts`) for
48
+ text-tier models and textual blocks:
49
+ `TSCG` schema/static compiler → terminal ANSI/CR/backspace hygiene + bijective
50
+ `@toon` columnar encoding + `Drain` log folding (guarded by
51
+ `isCodeOrDiffProtected` so source reads & diffs stay byte-exact) → `ACDC`
52
+ frozen-epoch digestion → `CASI-Delta` cross-turn line hashing.
53
+ - Optical microfiche rendering (`Spleen 5×8` + `GNU Unifont` fallback, plus
54
+ `JetBrains Mono` 10/12/14px profiles) only for strong/verified vision readers
55
+ (`claude-fable-5`, measured `gemini` vision tiers, opt-in `gpt-5.6-sol` /
56
+ `gpt-6.x-sol` / `grok-*` / `qwen3.8-27b`). Text-only readers (`claude-opus-5-5`,
57
+ `claude-sonnet-5-5`, `claude-haiku-*`, `gpt-6*-astra`,
58
+ `gemini-4-neon/carbon/hydrogen`, `deepseek`, `kimi`, `glm`, `minimax`, `grok`)
59
+ pass through with zero images unless `FICHE_FORCE_IMAGES=1`. Default scope is
60
+ `claude-fable-5,gemini`.
61
+ - Zero-token local receipts & companion plugin: `fiche turn-report`, `fiche stats`,
62
+ downstream `x-fiche-saved-tokens` / `x-fiche-stages` /
63
+ `x-fiche-cliff-saved-usd` headers, `plugins/fiche-companion/` (Antigravity
64
+ `PostInvocation` hook + Claude Code `statusLine`), and interactive browser
65
+ playground & subsite ([fiche.srinivas.dev](https://fiche.srinivas.dev)).
66
+ - Offline proxy-free export (`fiche export` for files/dirs, `--git`, `--diff`,
67
+ `--stdin`) emitting `page-*.png`, `factsheet.txt`, `prompt.txt`, and
68
+ `manifest.json`.
69
+ - PAKT is gone. On real agent traffic it saved about 0.015% of tokens and
70
+ cost CPU time on every request. The old PAKT toggle, the `compress_text` and
71
+ `inspect_savings` MCP tools, and the `@sriinnu/pakt` dependency are removed.
72
+ - ChatGPT Codex (`chatgpt.com`, `/backend-api/codex/responses` and
73
+ `/responses/compact`) no longer receives `prompt_cache_breakpoint`.
74
+ `api.openai.com` still does when the profile asks. `FICHE_GPT_PROFILES`
75
+ `cacheBreakpoints: false` is honoured. The scrub is a text edit of the
76
+ injected object only, so large integers and a tool-schema property named
77
+ `prompt_cache_breakpoint` survive.
78
+ - Fail open: when a transform throws, the request is forwarded as it
79
+ arrived instead of failing with 502. The event row's reason reads
80
+ `transform_error_fail_open: …`. Wire-bridge errors still answer 400/502,
81
+ because the upstream cannot read an unbridged body.
82
+ - The proxy API refuses browser requests from non-loopback pages (403) and
83
+ public-DNS `Host` names other than known provider hosts (421), so a web
84
+ page cannot spend configured keys through cross-site requests or DNS
85
+ rebinding. `FICHE_ALLOWED_HOSTS` adds names; `*` turns the check off.
86
+ - Routing is default-deny. Every `/backend-api/` path goes to the ChatGPT
87
+ upstream. Google `countTokens` and listing paths go to Google. On the stock
88
+ Anthropic upstream, paths outside `/v1/*` and `/api/*` answer 404.
89
+ - Architecture write-up, diagrams, and technical handbook in
90
+ `docs/ARCHITECTURE.md` and `wiki/`.
91
+ - MCP server (`fiche mcp`, also `fiche-mcp`) over stdio and stateless
92
+ Streamable HTTP. Tools: `check_model`, `transform_request`, `health`,
93
+ `stats`. Stdio `Content-Length` frames are counted in UTF-8 bytes, buffers are
94
+ capped at 8 MiB, and HTTP also listens on `::1`. Installs from git with
95
+ `npx --yes --package github:sriinnu/fiche fiche-mcp`; `prepare` builds
96
+ `dist/`. Claude Code plugin and marketplace manifests in `.claude-plugin/`.
97
+ - Text-only reader matching covers `claude-opus-5.5`, Vertex
98
+ `claude-opus-5-5@…`, `x-ai.grok-…`, `gpt-6*-astra`, `deepseek`, `kimi`,
99
+ `glm`, and `minimax` spellings.
100
+ - Follow the agent: a request for a registered compat host (DeepSeek, Kimi,
101
+ z.ai, MiniMax, DashScope, OpenRouter, xAI, plus `FICHE_UPSTREAM_HOSTS`)
102
+ goes to that host with only the agent's own credential. `https` on 443 only,
103
+ no IPs or local names, redirects handled manually. An unfollowed compat
104
+ `Host` gets 421 and is never re-routed to Anthropic. `FICHE_FOLLOW_HOSTS=0`
105
+ turns it off.
106
+ - Codex: only leading system/developer items enter the GPT static slab, user
107
+ messages stay native, and history runs seal at a user message, so late
108
+ images never land high in the cached prefix. WebSocket upgrades get 426 so
109
+ Codex falls back to HTTP. gzip/deflate/br/zstd request bodies are decoded
110
+ with a size limit; a body `fiche` can't decode is never rewritten.
111
+ - Savings accounting: the text baseline's warmth window follows the cache
112
+ tier the session writes (3600 s after a 1h-tier write, else 300 s). The gate
113
+ and the savings math price from one resolver.
114
+ - `FICHE_PRICES=kosha` (opt-in) prices from a build-time table of
115
+ first-party rows in a kosha registry snapshot (`pnpm prices:gen`,
116
+ `pnpm prices:check`). Unpriced models pass through, and dashboard dollars
117
+ use each model's own input price, with unpriced rows counted apart.
118
+ - Logo, README header, and bundled font license notices (`assets/*_LICENSE.txt`
119
+ and Docker `/app/licenses/`).
120
+ - Native macOS **`FicheBar.app`** (`apps/macos-bar/`): Apple HIG redesign with 5
121
+ themes (`Editorial`, `Native`, `Slate`, `Terminal`, `Midnight`),
122
+ `HeroCompressionRatioBar`, weighted-vs-raw savings clarity, 1-click
123
+ third-party model & plugin toggles, Desktop App Proxy launcher, taller
124
+ popover (`540px` scroll budget), and About & Sponsor window.
125
+ - Redesigned loopback web dashboard (`http://127.0.0.1:47821`) with Editorial
126
+ Warm Paper typography, `/fragments/plugins` live panel, and
127
+ `POST /api/plugins { scope: "third-party" }` one-click disable.
128
+ - Universal provider & client coverage: 23-host `COMPAT` upstream registry
129
+ (`src/core/upstream-hosts.ts`), Google `/v1internal:*` text hygiene on
130
+ non-Gemini models, `functionResponse.parts[].text` hygiene, macOS GUI desktop
131
+ app interception (`fiche warp --app <Name|Path>`), and shell integration
132
+ (`fiche shell-init [--wrap]`).
133
+ - Added [PRIVACY.md](./PRIVACY.md), GitHub Sponsor links, and Mermaid
134
+ architecture/sequence diagrams in [wiki/Architecture.md](./wiki/Architecture.md).
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 claude-image-proxy contributors
4
+ Copyright (c) 2026 Srinivas Pendela (Fiche / formerly Inkling fork changes)
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/NOTICE ADDED
@@ -0,0 +1,13 @@
1
+ fiche (formerly inkling)
2
+ =======================
3
+
4
+ Copyright (c) 2026 Srinivas Pendela. MIT license.
5
+
6
+ fiche includes code from pxpipe (https://github.com/teamchong/pxpipe) by
7
+ Steven (https://github.com/teamchong), MIT. Its copyright notice is kept in
8
+ LICENSE.
9
+
10
+ Bundled font licenses (copied to `assets/*_LICENSE.txt` and `/app/licenses/`):
11
+ - JetBrains Mono: SIL Open Font License 1.1 (`assets/JETBRAINS_MONO_LICENSE.txt`)
12
+ - GNU Unifont: SIL Open Font License 1.1 / GPLv2+ with GNU font embedding exception (`assets/UNIFONT_LICENSE.txt`)
13
+ - Spleen: BSD 2-Clause License (`assets/SPLEEN_LICENSE.txt`)
package/PRIVACY.md ADDED
@@ -0,0 +1,41 @@
1
+ # Privacy Policy
2
+
3
+ **`fiche`** (`@sriinnu/fiche`, including the CLI daemon, `fiche-mcp`, the web dashboard, and `FicheBar.app`) is built for **100% local-first execution** with **zero product telemetry, analytics, or tracking**.
4
+
5
+ ---
6
+
7
+ ## 1. Local-Only Data Processing
8
+
9
+ - **Loopback by default**: The proxy daemon (`fiche`) binds strictly to `127.0.0.1:47821` (plus optional `::1` for `fiche-mcp --http`). No usage analytics, crash reports, telemetry beacons, or update pings are sent to the author or any third party.
10
+ - **No stored prompts or request bodies**: Both the proxy and `fiche-mcp` keep prompt payloads and tool outputs strictly in ephemeral request memory. Neither `events.jsonl`, `stats`, nor `health` writes raw prompt text by default. (Opt-in debug capture flags such as `FICHE_DEBUG_CAPTURE_4XX` are disabled by default.)
11
+ - **Upstream forwarding**: When running as a live proxy or `fiche warp` interceptor, requests travel solely between your local coding agent/desktop app, the loopback `fiche` proxy, and your configured AI provider API using your own credentials, untouched.
12
+
13
+ ## 2. What Stays on Your Disk (`~/.fiche` & `~/.config/fiche`)
14
+
15
+ All persisted state stays locally under owner-only POSIX file permissions (`0600` / `0700`):
16
+
17
+ - `~/.fiche/events.jsonl` — Metadata-only accounting rows (timestamp, model name, token counts, weighted savings, dollar estimates, stage tags, latency, and prefix-cache hit ratios). No source code or prompt contents are stored.
18
+ - `~/.fiche/session-state.json` — In-session structural hashes / append-only optical & `LSM-Context` freeze boundaries and Turn-1 skill catalog pins used solely to preserve upstream KV prefix caches across turns.
19
+ - **In-memory `Context-MMU` default (opt-in disk persistence only)**: `ContextPageStore` virtual pages stay strictly in daemon RAM unless you explicitly set `FICHE_MMU_PERSIST=1` (with `FICHE_SESSION_STATE` enabled), which writes `0600` (`O_EXCL | O_NOFOLLOW`) JSON to `~/.fiche/mmu-pages.json` capped at `32 MiB`, `24h` idle TTL, and filtered to skip high-confidence secret patterns (`PEM`, `Bearer`, `sk-*`, GitHub/AWS keys).
20
+ - `~/.config/fiche/calibrated-models.json` — Local 4-axis vision calibration profiles written atomically with `0600` permissions by `fiche calibrate`.
21
+ - `~/.fiche/plugins/` & `~/.config/fiche/config.json` — Your local plugin/skill enablement state and model configuration.
22
+ - `~/.fiche/bin/fiche-launchd-exec` & `~/.fiche/daemon.{out,err}.log` — Compiled local macOS `<launch.h>` socket-activation trampoline (`0755`) and `launchd` process lifecycle logs.
23
+
24
+ You can purge all local state at any time:
25
+
26
+ ```bash
27
+ rm -rf ~/.fiche ~/.config/fiche
28
+ ```
29
+
30
+ ## 3. Offline Export (`fiche export`) & `FicheBar.app`
31
+
32
+ - **`fiche export`** writes rendered `page-*.png`, `factsheet.txt`, `prompt.txt`, and `manifest.json` files strictly to the local output directory you specify, making **zero network requests**.
33
+ - **`FicheBar.app`** communicates exclusively with your local loopback daemon (`http://127.0.0.1:47821`) and `launchctl`. Clicking external links (**GitHub Repository**, **Sponsor**, or **fiche.srinivas.dev**) opens your default browser only on explicit user action.
34
+
35
+ ## 4. Third-Party Upstream Providers & Security Guarantees
36
+
37
+ Prompts and compressed artifacts forwarded upstream are governed by the privacy policy of the LLM provider you configure (Anthropic, OpenAI / ChatGPT Codex, Google Gemini, DeepSeek, Moonshot, Z.AI, xAI, etc.). For threat-model boundaries, loopback `Origin`/`Host` DNS-rebinding guards, and `fiche warp` TLS isolation, see [SECURITY.md](./SECURITY.md) and [docs/SECURITY_MODEL.md](./docs/SECURITY_MODEL.md).
38
+
39
+ ## 5. Contact
40
+
41
+ Questions or privacy disclosures may be filed via [GitHub Security Advisories](https://github.com/sriinnu/fiche/security/advisories/new) or issues on [github.com/sriinnu/fiche](https://github.com/sriinnu/fiche).
package/README.md ADDED
@@ -0,0 +1,289 @@
1
+ <div align="center">
2
+
3
+ <picture>
4
+ <source media="(prefers-color-scheme: dark)" srcset="./assets/fiche-logo-dark.svg">
5
+ <source media="(prefers-color-scheme: light)" srcset="./assets/fiche-logo-light.svg">
6
+ <img alt="fiche — Microfiche for coding agents" src="./assets/fiche-logo-light.svg" width="360">
7
+ </picture>
8
+
9
+ <p>
10
+ <a href="LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/license-MIT-FF6B2B.svg"></a>
11
+ <img alt="Platform: macOS | Linux | Windows | Docker | Workers" src="https://img.shields.io/badge/platform-macOS%20%7C%20Linux%20%7C%20Windows%20%7C%20Docker%20%7C%20Workers-1E293B.svg">
12
+ <img alt="Node 20.19+" src="https://img.shields.io/badge/node-%3E%3D20.19-339933.svg?logo=node.js&logoColor=white">
13
+ <img alt="Core: 0 deps" src="https://img.shields.io/badge/core-0%20node%3A%20deps-0EA5E9.svg">
14
+ <img alt="Warm p50: 1.9-6.7 ms" src="https://img.shields.io/badge/warm%20p50-1.9%E2%80%936.7%20ms-34D399.svg">
15
+ <img alt="MCP: fiche-mcp" src="https://img.shields.io/badge/MCP-fiche--mcp-A855F7.svg">
16
+ <a href="./apps/macos-bar/README.md"><img alt="macOS: FicheBar" src="https://img.shields.io/badge/macOS-FicheBar-111827.svg?logo=apple"></a>
17
+ <a href="https://github.com/sponsors/sriinnu"><img alt="Sponsor on GitHub" src="https://img.shields.io/badge/sponsor-sriinnu-EA4AAA.svg?logo=githubsponsors&logoColor=white"></a>
18
+ <a href="https://fiche.srinivas.dev"><img alt="Website: fiche.srinivas.dev" src="https://img.shields.io/badge/web-fiche.srinivas.dev-0F172A.svg"></a>
19
+ </p>
20
+
21
+ **Microfiche for coding agents — cache-safe hybrid optical & deterministic text context compiler + local proxy.**
22
+
23
+ Cuts **31.4–50.8%** of multi-turn tokens and up to **41.7%** real USD (`34.1–41.7%` across text models; `11.1–27.0%` on Fable/Gemini optical) with **73.8–91.1%** KV prefix-cache hits, **1.85–6.69 ms** warm p50 request latency, and **100% `editSafe`** verbatim source preservation.
24
+
25
+ [30s Quickstart](#30-second-quickstart) · [Website](https://fiche.srinivas.dev) · [Efficiency vs Latency](#token-efficiency-vs-latency) · [FicheBar](#macos-menubar-app-fichebar--ecosystem) · [Architecture](./wiki/Architecture.md) · [Getting Started](./docs/GETTING_STARTED.md) · [Wiki](./wiki/Home.md) · [Support](#support)
26
+
27
+ </div>
28
+
29
+ ---
30
+
31
+ ## Proxy Daemon vs. MCP Server vs. Offline Export
32
+
33
+ | Component | How You Run It | What It Does | Shrinks Live Turns? |
34
+ | :--- | :--- | :--- | :--- |
35
+ | **`fiche` Proxy Daemon** | `fiche` / `fiche service install` / `fiche warp` | Loopback HTTP proxy (`127.0.0.1:47821`) with zero-drop `launchd`/`systemd` socket activation, HTTP/1.1 keep-alive upstream fetch, and `fiche warp` fail-open; compiles live agent context (`P0–P3` + `Context-MMU` & calibrated optical), emits `x-fiche-*` headers, logs `~/.fiche/events.jsonl` | **Yes** |
36
+ | **`fiche-mcp` MCP Server** | `fiche mcp` (stdio on demand) or `--http 47823` | Inspection, virtual-page recall & local stats (`check_model`, `transform_request`, `page_in`, `mmu_stats`, `health`, `stats`) | **No** (dry-run, recall & stats) |
37
+ | **`fiche export`** | `fiche export src/` / `--git` / `--stdin` | Proxy-free generator for `page-*.png` + `factsheet.txt` + `prompt.txt` bundles | Offline bundle |
38
+
39
+ > **Cross-Platform (Not OS-Dependent):**
40
+ > - **Runs everywhere**: `src/core/` (zero `node:` deps), the `fiche` loopback proxy daemon (`LISTEN_FDS`/`LISTEN_PID` `systemd` socket activation supported on Linux), `fiche warp -- <cli>`, `fiche-mcp`, `fiche export`, `fiche calibrate`, `fiche mmu`, `fiche turn-report`, `fiche stats`, and the Web Dashboard (`http://127.0.0.1:47821`) run identically on **macOS, Linux, Windows (native & WSL), Docker (`docker compose up -d`), and Cloudflare Workers**.
41
+ > - **Optional macOS extras only**: [`FicheBar.app`](./apps/macos-bar/README.md) (SwiftUI menubar companion — Linux/Windows use the web dashboard at `:47821`), `fiche service` (`launchd` wrapper with `<key>Sockets</key>` `<launch.h>` socket activation & `65s` graceful SSE drain — use `systemd --user` / Docker on Linux or Task Scheduler / WSL on Windows), and `fiche warp --app <Name>` (macOS `.app` bundle resolver — on Linux/Windows run `fiche warp -- <binary>` directly).
42
+
43
+ ---
44
+
45
+ ## 30-Second Quickstart
46
+
47
+ ```bash
48
+ # 1. Install once (Homebrew CLI + menubar app, or Node >= 20.19 via npm)
49
+ brew install sriinnu/tap/fiche
50
+ brew install --cask sriinnu/tap/fichebar # optional macOS 14+ menubar app (upgrade: brew upgrade)
51
+ # Or directly from npm / GitHub:
52
+ npm install -g @sriinnu/fiche@latest # or github:sriinnu/fiche
53
+
54
+ # 2. Start daemon (or `fiche service install` on macOS for zero-drop launchd socket activation).
55
+ # Zero-config applies default `FICHE_MODELS=claude-fable-5,gemini`;
56
+ # recommended: enable kosha pricing + all coding models (or save in ~/.config/fiche/config.json):
57
+ FICHE_PRICES=kosha FICHE_TEXT_HYGIENE=on \
58
+ FICHE_MODELS="claude-fable-5,gemini,gpt-6-astra,gpt-6.2-astra,claude-opus-5-5,deepseek,kimi,glm,grok" \
59
+ fiche
60
+
61
+ # 3. Connect your coding agent CLI, desktop app, or multi-provider swarm via warp (preserves native auth & fails open if daemon stops)
62
+ fiche warp -- claude # Claude Code (/remote-control & connectors stay intact)
63
+ fiche warp -- codex # OpenAI Codex (or `codex -p fiche` via ~/.codex/config.toml)
64
+ fiche warp --app Cursor # Route macOS desktop GUI apps through local HTTPS CONNECT MITM
65
+ eval "$(fiche shell-init)" # Add fclaude / fcodex / fgemini / fiche-app helpers (or `--wrap`)
66
+
67
+ # Multi-provider orchestrators & swarms (ribhu / opencode / t3code):
68
+ # 1. Opt in on BOTH daemon & client (`fiche warp --all-providers` only injects wrapper env vars;
69
+ # without daemon opt-in, third-party upstream hosts return HTTP 421 `follow_refused`):
70
+ fiche providers enable deepseek kimi glm openrouter xai groq mistral
71
+ # 2. Sync active models from local ~/.kosha/registry.json (after `kosha update`) into ~/.config/fiche/config.json
72
+ fiche models sync-kosha --apply
73
+ fiche warp --all-providers -- ribhu
74
+
75
+ # 4. Calibrate new vision models, inspect Context-MMU pages, or restart with zero drops
76
+ fiche calibrate <model> # 4-axis optical probe saved to ~/.config/fiche/calibrated-models.json
77
+ fiche mmu stats # inspect virtual pages, Markovian folds & tail hydrations (0 LLM tokens)
78
+ fiche service restart # atomic kickstart -k restart with 0 ECONNREFUSED via socket activation
79
+
80
+ # 5. Verify savings (<1 ms CLI rollup from ~/.fiche/events.jsonl, 0 LLM tokens)
81
+ fiche turn-report --color
82
+ ```
83
+
84
+ > **Provider Terms Note:** `fiche warp` runs locally on your own loopback interface using your own session credentials without sharing accounts or bypassing rate limits. Before wrapping a proprietary client such as Google Antigravity (`agy`), review that provider's current Terms of Service on local proxies/wrappers or configure direct base-URL routing (`GOOGLE_GEMINI_BASE_URL=http://127.0.0.1:47821`) where supported.
85
+
86
+ Open `http://127.0.0.1:47821/` in your browser for the live dashboard & PNG crop inspector. Full multi-agent setup lives in the **[Getting Started Guide](./docs/GETTING_STARTED.md)**.
87
+
88
+ ---
89
+
90
+ ## macOS Menubar App (`FicheBar`) & Ecosystem
91
+
92
+ - **[`FicheBar.app`](./apps/macos-bar/README.md)** (`./apps/macos-bar/bundle.sh --install`): native SwiftUI macOS 14+ menubar companion with **5 Apple HIG themes** (`Editorial`, `Native`, `Slate`, `Terminal`, `Midnight`), weighted-vs-raw savings clarity, 1-click **Pause / Resume**, 1-click **Disable all 3rd-party models/plugins**, **Desktop App Proxy (`fiche warp --app`)** launcher, and About / GitHub Sponsor panel.
93
+ - **29 Built-In Upstream Hosts across 21 Providers (`src/core/upstream-hosts.ts`)**: "Follow-the-agent" TLS/base-URL routing across 6 first-party + 23 third-party COMPAT hosts (Anthropic, OpenAI / ChatGPT Codex, Google Gemini & `/v1internal:*` (`Antigravity`), DeepSeek, Moonshot/Kimi, Z.AI/BigModel, MiniMax, DashScope, OpenRouter, xAI, Groq, Together, Fireworks, Cerebras, Mistral, Perplexity, Cohere, SambaNova, GitHub Models, Azure AI, and Vercel AI Gateway). Multi-provider swarms (`fiche warp --all-providers -- ribhu`) route **per request** by `(Host, path, model)` with strict per-provider credential and `sessionKey` isolation, while local LLMs on `localhost` / `127.0.0.1` / `::1` (Ollama, vLLM, LM Studio) bypass proxying automatically via `NO_PROXY` so local models stay untouched.
94
+ - **[Ecosystem Integration](./docs/ECOSYSTEM_INTEGRATION.md)**: works cleanly alongside [kosha-discovery](https://github.com/sriinnu/kosha-discovery) (pricing & cliffs), [tokmeter](https://github.com/sriinnu/tokmeter) (gross ledger + net savings, sharing Claude's `statusLine`), [Runic](https://github.com/sriinnu/Runic) (`runic-mcp-plugin.json`), [llm-bar](https://github.com/sriinnu/llm-bar), [baton](https://github.com/sriinnu/baton) (cross-session briefs), and [omit](https://github.com/sriinnu/omit) (output minimalism).
95
+ - **[Stage Plugins & Skills](./docs/PLUGINS_AND_SKILLS.md)**: extend or toggle pipeline stages via `~/.fiche/plugins/<id>/plugin.json`, `~/.agents/skills/`, and `/api/plugins`.
96
+
97
+ ---
98
+
99
+ ## How It Works
100
+
101
+ 1. **Edit-safety guard (`isCodeOrDiffProtected` & live-tail preservation)**: freezes numbered code reads (`read_file`/`view_file` verbatim in the live tail) and unified diffs verbatim so `Edit` and `apply_patch` anchors stay byte-exact.
102
+ 2. **Tiered reader router (`readerTier`), `OpticalMode` (`hybrid` vs `full`), & 4-axis `fiche calibrate`**: verified dense page readers (`claude-fable-5`, measured `gemini`, opt-in `sol`, plus empirically calibrated models) route between **Hybrid Slab-Optical + Text-MMU** (`opticalMode: 'hybrid'` — auto-selected under low read-discount `kosha` pricing like `0.05×` Gemini 4 Argon: Turn-1 static optical slab + dynamic Text-MMU history, lifting 30-turn weighted savings to **`39.5%`** at **`89.9%`** cache hit across `60` images) and **Full Optical** (`pinnedUserText` moved to trailing live turn on Google wires so `contents[0]` stays immutable, `79.7%` cache hit); text-tier coding models receive **0 images**.
103
+ 3. **P0–P3 context compiler + `Context-MMU` + `PrefixMemoTape`**:
104
+ - **P0**: XML-island `TSCG` + Merkle Schema DAG (`$defs._fN` on Anthropic/OpenAI wires) + single-level JSON-in-JSON unwrapping + bounded **`PrefixMemoTape`** (`src/core/prefix-tape.ts`: Stage-2 LRU, session-scoped Unified Prefix Seal Table, and Merkle prefix-state CASI memo).
105
+ - **P1**: `CASI v2` (`Write`/`Edit` `seedBase`, bounded `PREPARED_LINES_CACHE`, recursive Histogram Diff, LIS alignment, `GEAR_TABLE` FastCDC, disabled automatically when Full Optical is active).
106
+ - **P2**: `LSM-Context` single-block sticky epochs (`L1`/`L0`) with Horizon-Aware Online Compaction Gate (`computeHorizonPaybackLimit`) + cold-cache `L2` repack across all `5` provider cache-read headers.
107
+ - **P3**: `Context-MMU` virtual memory (`pg_<12hex>` RAM-only default LRU, Turn-1 skill linking, `FAIL→PASS` Markovian folding, Minoux Lazy Greedy Submodular IDF pruning, and per-session Context-TLB `±15`-line live-tail hydration).
108
+ 4. **Zero-drop runtime & zero-token local receipts**: `src/node-fetch.ts` HTTP/1.1 keep-alive agents avoid Node 26 / `undici` HTTP/2 idle-reaper crashes (`#33`); `launchd`/`systemd` socket activation + bind-before-restore + `connTrack` `60s` SSE drain prevent restart `ECONNREFUSED`/`ECONNRESET` (`#34`); `fiche warp` bypasses when stopped, fails open mid-session on `ECONNREFUSED`, and sets loopback `NO_PROXY`; and `~/.fiche/events.jsonl`, `fiche turn-report`, `fiche mmu`, `x-fiche-*` headers, and `fiche-mcp` cost **0 LLM tokens**.
109
+
110
+ <details>
111
+ <summary><strong>Preview: 312-column optical microfiche PNG + architecture diagram</strong> (click to expand)</summary>
112
+
113
+ ![Real fiche optical microfiche output packed into a 312-column monochrome PNG page with instruction banner and newline sentinels](docs/assets/example-render.png)
114
+
115
+ ![fiche hybrid optical and deterministic text architecture](docs/architecture/fiche-architecture.svg)
116
+
117
+ </details>
118
+
119
+ ---
120
+
121
+ ## Token Efficiency vs. Latency
122
+
123
+ Measured across 16 models on the 16-turn coding-agent benchmark (`bench/multiturn-all-models.mts` + `bench/latency-p99.mts` → [`bench/results.generated.json`](./bench/results.generated.json); **`editSafe = true` on all 16 models**), alongside the hardened 30-turn `Context-MMU` replay ([`bench/context-mmu-eval.mts`](./bench/context-mmu-eval.mts) → [`bench/mmu-results.generated.json`](./bench/mmu-results.generated.json)):
124
+
125
+ | `v0.19` 30-Turn Replay Arm | Model / Wire | Raw Saved | Weighted Saved (`kosha`) | KV Cache Hit | p50 / Avg ms | EditSafe & Tail Recall |
126
+ | :--- | :--- | ---: | ---: | ---: | ---: | :---: |
127
+ | **`v0.18` Text Compiler** (`lsm/mmu/skillLinker` off) | `gemini-4-argon` (Google) | **32.5%** | **34.0%** | **92.1%** | **11.94 / 11.66 ms** | `true` / `true` |
128
+ | **`P0–P3` Text + `Context-MMU`** (`0` images) | `gemini-4-argon` (Google) | **44.0%** | **36.8%** | **90.1%** | **10.24 / 16.66 ms** | **`true` / `true`** |
129
+ | **`P0–P3` + Optical** (`spleen-5x8`, `153` PNGs) | `gemini-4-argon` (Google) | **49.0%** | **3.0%** | **79.7%** | **4.71 / 11.39 ms** | **`true` / `true`** |
130
+ | **`P0–P3` Hybrid Slab-Optical + Text-MMU** (`60` PNGs) | `gemini-4-argon` (Google) | **46.9%** | **39.5%** | **89.9%** | **9.62 / 15.53 ms** | **`true` / `true`** |
131
+ | **`P0–P3` Text + `Context-MMU`** (`13` stages) | `claude-opus-5-5` (Anthropic) | **48.8%** | **39.8%** | **89.6%** | **18.50 ms avg** | **`true` / `true`** |
132
+ | **`P0–P3` Text + `Context-MMU`** (`13` stages) | `gpt-6-astra` (Responses) | **44.6%** | **33.2%** | **88.3%** | **11.66 ms avg** | **`true` / `true`** |
133
+
134
+ | Engine Mode | Tokens Saved | Real USD Saved (`kosha`) | Prefix Cache Hit | Warm p50 Latency | Best For |
135
+ | :--- | ---: | ---: | ---: | ---: | :--- |
136
+ | **4-Layer Text Compiler** (`TSCG→Drain→TOON→ACDC→CASI`) | **45.3–45.7%** | **34.1–41.7%** (`grok-4.7` top) | **91.1%** | **6.29–6.66 ms** | Daily coding on Astra, Opus 5.5, Grok, DeepSeek, Kimi, GLM, Gemini text |
137
+ | **Optical Microfiche** (PNG + `FactSheet`) | **31.4–50.8%** (`gemini-3.8-flash` top) | **11.1–27.0%** (Fable/Gemini) · `-11.2–-3.5%` (opt-in Sol 16T) | **73.8–89.0%** | **1.99–3.53 ms** | Massive docs/logs & `3.6×–5.1×` context packing on Fable 5 / Gemini |
138
+
139
+ ![Token and cost efficiency vs latency frontier across 16 models](docs/assets/efficiency-vs-latency.png)
140
+
141
+ ![fiche 16-model token and USD savings benchmark](docs/assets/benchmark-16-models.png)
142
+
143
+ ![fiche cold vs warm latency and adversarial guards](docs/assets/latency-profile.png)
144
+
145
+ <details>
146
+ <summary><strong>Full 16-model benchmark table, latency breakdown &amp; context capacity chart</strong> (click to expand)</summary>
147
+
148
+ | Provider | Model | Mode | Tokens Saved | Real USD Saved | Prefix Hit | Avg / Turn |
149
+ | :--- | :--- | :--- | ---: | ---: | ---: | ---: |
150
+ | **xAI** | `grok-4.7` | `TSCG+TOON+ACDC+CASI` | **45.3%** | **41.7%** | 91.1% | 4.1 ms |
151
+ | **z.ai** | `glm-5.3` | `TSCG+TOON+ACDC+CASI` | **45.4%** | **41.1%** | 91.1% | 4.2 ms |
152
+ | **DeepSeek** | `deepseek-v4-pro` | `TSCG+TOON+ACDC+CASI` | **45.4%** | **39.1%** | 91.1% | 5.1 ms |
153
+ | **OpenAI / Codex** | `gpt-6-astra` | `TSCG+TOON+ACDC+CASI` | **45.3%** | **37.8%** | 91.1% | 7.4 ms |
154
+ | **OpenAI / Codex** | `gpt-6.2-astra` | `TSCG+TOON+ACDC+CASI` | **45.3%** | **36.6%** | 91.1% | 3.9 ms |
155
+ | **Anthropic** | `claude-opus-5-5` | `TSCG+TOON+ACDC+CASI` | **45.3%** | **36.6%** | 91.1% | 5.0 ms |
156
+ | **Moonshot** | `kimi-k3` | `TSCG+TOON+ACDC+CASI` | **45.4%** | **35.9%** | 91.1% | 5.0 ms |
157
+ | **Google / AGY** | `gemini-4-carbon` | `TSCG+TOON+ACDC+CASI` | **45.7%** | **34.4%** | 91.1% | 6.5 ms |
158
+ | **Google / AGY** | `gemini-4-hydrogen` | `TSCG+TOON+ACDC+CASI` | **45.7%** | **34.4%** | 91.1% | 5.3 ms |
159
+ | **Google / AGY** | `gemini-3.1-pro-preview` | `TSCG+TOON+ACDC+CASI` | **45.6%** | **34.1%** | 91.1% | 4.3 ms |
160
+ | **Anthropic** | `claude-fable-5-20260609` | `Fable-image+hygiene` | **37.2%** | **27.0%** | 88.8% | 8.9 ms |
161
+ | **Google / AGY** | `gemini-4-argon` | `image+hygiene` | **34.9%** | **22.2%** | 89.0% | 21.8 ms |
162
+ | **Google / AGY** | `gemini-3.8-flash` | `image+hygiene` | **50.8%** | **11.1%** | 73.8% | 14.9 ms |
163
+ | **OpenAI / Codex** | `gpt-5.6-sol` | `14px-Sol-image+hygiene` | **31.4%** | **-3.5%** | 79.2% | 13.6 ms |
164
+ | **OpenAI / Codex** | `gpt-6.2-sol` | `14px-Sol-image+hygiene` | **31.4%** | **-11.2%** | 79.2% | 14.6 ms |
165
+ | **Google / AGY** | `gemini-4-neon` | `TSCG+TOON+ACDC+CASI` | **45.7%** | unpriced | 91.1% | 5.5 ms |
166
+
167
+ | Latency / Guard Workload | Cold | Warm p50 | Warm p95 | Warm p99 |
168
+ | :--- | ---: | ---: | ---: | ---: |
169
+ | 20T Text: `gpt-6-astra` (Responses) | 13.77 ms | **6.29 ms** | 7.81 ms | 9.40 ms |
170
+ | 20T Text: `gemini-4-neon` (Google) | 11.16 ms | **6.66 ms** | 9.43 ms | 28.30 ms |
171
+ | 20T Imaged: `gemini-4-argon` (Google) | 48.02 ms | **1.99 ms** | 2.80 ms | 3.02 ms |
172
+ | 20T Imaged: `claude-fable-5` (Anthropic) | 53.68 ms | **3.13 ms** | 3.75 ms | 4.19 ms |
173
+ | 20T Imaged: `gpt-6.2-sol` (Responses) | 79.37 ms | **3.53 ms** | 5.52 ms | 6.49 ms |
174
+ | 600 KB ACDC epochs (`15×40 KB`) | 59.06 ms | **15.93 ms** | 19.19 ms | 20.97 ms |
175
+ | 50 KB dotted line (`cleanToolOutput`) | 1.52 ms | **1.26 ms** | 1.82 ms | 2.57 ms |
176
+ | 35 KB unclosed `<!--` (`compileStaticText`) | 0.25 ms | **0.27 ms** | 0.50 ms | 0.67 ms |
177
+ | 30 KB unbroken blob (clean + digest + static + toon) | 1.03 ms | **0.90 ms** | 1.55 ms | 2.45 ms |
178
+ | 1.90 MiB `events.jsonl` tail (`readTurnReport`) | 0.79 ms | **0.43 ms** | 1.16 ms | 1.77 ms |
179
+
180
+ ![Characters a frontier context window holds with fiche: Gemini 3.8 Flash 21M (5.1x), Fable 5 18M (4.5x), Opus 5 spaced 14M (3.6x)](docs/assets/context-window-chars.png)
181
+
182
+ Reproduce via [`scripts/gen-fiche-charts.ts`](./scripts/gen-fiche-charts.ts) and [`scripts/gen-context-chart.ts`](./scripts/gen-context-chart.ts) (`pnpm run charts:gen`).
183
+
184
+ </details>
185
+
186
+ ---
187
+
188
+ ## Offline export (no proxy)
189
+
190
+ Need to feed a directory, git branch, or huge log directly into **Cursor**, web chat, or another client **without running the proxy**? Run `fiche export`:
191
+
192
+ ```bash
193
+ fiche export src/ # directory / file targets
194
+ fiche export --git # uncommitted git diff + untracked files
195
+ fiche export --diff HEAD~3 # commit range diff
196
+ cat server.log | fiche export --stdin # pipe logs or transcripts via --stdin
197
+ ```
198
+
199
+ Each invocation writes an isolated folder containing `page-*.png` (reflowed microfiche PNGs), `factsheet.txt` (verbatim paths, SHAs, ports, IDs), `prompt.txt` (paste-ready prompt referencing the pages and factsheet), and `manifest.json`.
200
+
201
+ ---
202
+
203
+ ## Zero-Token Local Stats, Live Pins & Config
204
+
205
+ - **Local Stats & Turn Receipts (`0` LLM tokens)**: `fiche turn-report --color`, `fiche stats`, `GET /api/last-turn.json`, `x-fiche-saved-tokens` / `x-fiche-stages` / `x-fiche-cliff-saved-usd` headers, `plugins/fiche-companion/` (Antigravity `PostInvocation` + Claude `statusLine`), and `fiche-mcp`.
206
+ - **Live Pins (`@fiche pin <rule>`)**: pinned rules stay authoritative at the live turn tail without invalidating prefix caches (`@fiche unpin <n|all>`).
207
+ - **Interactive Browser Playground & Subsite**: zero-backend optical plate viewer & benchmark explorer at **[fiche.srinivas.dev](https://fiche.srinivas.dev)**.
208
+
209
+ | Variable | Default | Description |
210
+ | :--- | :--- | :--- |
211
+ | `FICHE_MODELS` | `claude-fable-5,gemini` | Comma-separated active model bases or `off` |
212
+ | `FICHE_PRICES` | `legacy` | Set `kosha` for calibrated cache & long-context cliff math |
213
+ | `FICHE_TEXT_HYGIENE` | `auto` | `on` / `auto` / `off` for the 4-layer deterministic text engine |
214
+ | `FICHE_CONFIG` | `~/.config/fiche/config.json` | Optional JSON defaults (`providers`, `models`, `custom_hosts`, `mmu_max_pages`, `mmu_max_mb`, `max_sessions`) |
215
+ | `FICHE_MMU_MAX_PAGES` | `512` | Max `Context-MMU` virtual pages in daemon RAM (`[64, 16384]`, or `mmu_max_pages` in `config.json`) |
216
+ | `FICHE_MMU_MAX_MB` | `16` | Max `Context-MMU` RAM budget in MiB (`[4, 256]`, or `mmu_max_mb` in `config.json`) |
217
+ | `FICHE_MAX_SESSIONS` | `512` | Max tracked sessions in RAM (`[64, 8192]`, or `max_sessions` in `config.json`) |
218
+ | `FICHE_MMU_PERSIST` | unset (`off`, RAM-only) | Set `1` (with `FICHE_SESSION_STATE` enabled) to persist non-secret MMU pages (`0600`, `24h` TTL) |
219
+ | `FICHE_SHUTDOWN_DRAIN_MS` | `60000` | Active request shutdown drain window in ms (`ExitTimeOut: 65` in `launchd` plist) |
220
+ | `FICHE_TRUST_ADJACENT_TOOL_ROUNDS` | unset | Collapses pure tool-call turns cleanly behind `CASI`/`Context-MMU` gates when client prompts are strictly append-only |
221
+ | `FICHE_SERVICE_LABEL` | `com.sriinnu.fiche` | Optional override for `launchd` LaunchAgent label |
222
+ | `FICHE_LOG` | `~/.fiche/events.jsonl` | Local JSONL event log path (falls back to `~/.inkling/events.jsonl`) |
223
+ | `FICHE_ALLOWED_HOSTS` | loopback + registered hosts | Extra trusted `Host`/`Origin` names (`*` disables checks) |
224
+
225
+ Example `~/.config/fiche/config.json` for a multi-provider swarm (or run `kosha update && fiche models sync-kosha --apply` to populate `models` automatically):
226
+
227
+ ```json
228
+ {
229
+ "providers": [
230
+ "anthropic",
231
+ "openai",
232
+ "google",
233
+ "deepseek",
234
+ "kimi",
235
+ "glm",
236
+ "openrouter",
237
+ "xai",
238
+ "groq",
239
+ "mistral"
240
+ ],
241
+ "models": [
242
+ "claude-fable-5",
243
+ "claude-opus-5",
244
+ "claude-opus-5-5",
245
+ "gemini",
246
+ "gpt-6-astra",
247
+ "gpt-6.2-astra",
248
+ "gpt-6.1-sol",
249
+ "gpt-6.2-sol",
250
+ "gpt-5.6-sol",
251
+ "deepseek",
252
+ "kimi",
253
+ "glm",
254
+ "grok",
255
+ "qwen",
256
+ "mistral-large",
257
+ "codestral"
258
+ ],
259
+ "custom_hosts": [],
260
+ "mmu_max_pages": 4096,
261
+ "mmu_max_mb": 64,
262
+ "max_sessions": 2048
263
+ }
264
+ ```
265
+
266
+ - **Swarm worker isolation**: Orchestrators (`ribhu`, `opencode`, `t3code`) spawning concurrent workers on identical Turn-1 prompts across Anthropic, OpenAI, or Google should send `x-fiche-session-id: <worker-id>` (stripped before forwarding upstream) so `Context-MMU`, `LSM-Context`, and in-flight `409` dedupe stay isolated per worker.
267
+ - **Scope note (`v0.19.0`)**: Enterprise endpoints outside the 29 built-in HTTPS:443 hosts — AWS Bedrock (SigV4 signing + regional hosts), GCP Vertex AI (regional IAM/ADC endpoints), and internal plain-HTTP / self-signed corporate LiteLLM gateways — are not natively covered yet.
268
+
269
+ **Deep dives:** [Getting Started](./docs/GETTING_STARTED.md) · [Context-MMU Architecture](./docs/CONTEXT_MMU_ARCHITECTURE.md) · [Architecture (Wiki)](./wiki/Architecture.md) · [Architecture (Detailed)](./docs/ARCHITECTURE.md) · [Benchmarks](./docs/BENCHMARKS.md) · [Ecosystem Integration](./docs/ECOSYSTEM_INTEGRATION.md) · [Plugins & Skills](./docs/PLUGINS_AND_SKILLS.md) · [Privacy Policy](./PRIVACY.md) · [Security Model](./docs/SECURITY_MODEL.md) · [Changelog](./CHANGELOG.md) · [Wiki](./wiki/Home.md)
270
+
271
+ ---
272
+
273
+ ## Credits
274
+
275
+ Evolved from `pxpipe` by [Steven / teamchong](https://github.com/teamchong/pxpipe) (MIT; see [NOTICE](./NOTICE)). Bundled font licenses live in `assets/*_LICENSE.txt` and Docker `/app/licenses/`:
276
+ - **JetBrains Mono** — SIL Open Font License 1.1 (`assets/JETBRAINS_MONO_LICENSE.txt`)
277
+ - **GNU Unifont** — SIL Open Font License 1.1 / GPLv2+ with GNU font embedding exception (`assets/UNIFONT_LICENSE.txt`)
278
+ - **Spleen** — BSD 2-Clause License (`assets/SPLEEN_LICENSE.txt`)
279
+
280
+ ## Support
281
+
282
+ `fiche` is free and open source. If it cuts your token bills, consider supporting maintenance:
283
+
284
+ - [GitHub Sponsors](https://github.com/sponsors/sriinnu)
285
+ - [Buy Me a Coffee](https://buymeacoffee.com/sriinnu)
286
+
287
+ ## License
288
+
289
+ [MIT](LICENSE). See [NOTICE](NOTICE) for third-party attributions and [CONTRIBUTING.md](CONTRIBUTING.md) to contribute.
package/SECURITY.md ADDED
@@ -0,0 +1,53 @@
1
+ # Security Policy
2
+
3
+ The MCP server and the proxy do not store request bodies. `health` and
4
+ `stats` return counters and version strings only.
5
+
6
+ ## Supported versions
7
+
8
+ Security fixes are applied to the latest released version of `@sriinnu/fiche` (`fiche`). Users
9
+ should upgrade to the newest release before reporting a problem that may
10
+ already have been fixed.
11
+
12
+ ## Reporting a vulnerability
13
+
14
+ Please do not open a public issue for a suspected vulnerability or include
15
+ secrets, prompts, logs, request bodies, or proof-of-concept exploits in a
16
+ public discussion.
17
+
18
+ Use GitHub's private vulnerability reporting form:
19
+
20
+ https://github.com/sriinnu/fiche/security/advisories/new
21
+
22
+ Include, where possible:
23
+
24
+ - the affected version and runtime (Node or Cloudflare Workers);
25
+ - the deployment configuration needed to reproduce the issue, with secrets
26
+ removed;
27
+ - the security impact and who can trigger it;
28
+ - minimal reproduction steps or a proof of concept; and
29
+ - any suggested mitigation.
30
+
31
+ The maintainers will acknowledge the report, assess its severity, coordinate
32
+ a fix and release, and credit the reporter unless anonymity is requested.
33
+ Please allow time for a patch before publishing details.
34
+
35
+ ## Deployment security
36
+
37
+ fiche handles API credentials and may process confidential prompts and tool
38
+ results. Keep the Node server on its default loopback interface unless it is
39
+ placed behind an authenticated, encrypted reverse proxy. Non-loopback bindings
40
+ expose the proxy API, while dashboard routes remain loopback-only.
41
+
42
+ For Cloudflare Workers deployments that inject provider credentials, configure
43
+ `FICHE_WORKER_SECRET` (legacy `INKLING_WORKER_SECRET` is also honored, with
44
+ `x-fiche-secret` or legacy `x-inkling-secret` headers). The Worker fails closed
45
+ when a provider credential is configured without this shared secret. Do not
46
+ enable `FICHE_DEBUG_CAPTURE_4XX` (or legacy `INKLING_DEBUG_CAPTURE_4XX`) in
47
+ production: captured request bodies can contain prompts and credentials.
48
+
49
+ Local event logs, diagnostic captures, rendered PNG dumps, configuration files, and
50
+ export artifacts are protected with owner-only permissions on POSIX systems.
51
+
52
+ See [docs/SECURITY_MODEL.md](docs/SECURITY_MODEL.md) for trust boundaries,
53
+ assumptions, and operator guidance.