@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
@@ -0,0 +1,199 @@
1
+ /**
2
+ * User-pinned instructions.
3
+ *
4
+ * The problem: CLAUDE.md arrives in message 0, and by the time a long tool loop
5
+ * has run, position 0 reads as background rather than instruction. The harness
6
+ * itself works around this for its own rules by re-emitting `<system-reminder>`
7
+ * at the TAIL, where the model reads it last, immediately before generating.
8
+ * A pin buys that slot for the user's rules.
9
+ *
10
+ * Syntax is one line, one pin, wherever the user can type:
11
+ *
12
+ * @inkling pin be concise, no walls of text
13
+ * @inkling unpin
14
+ *
15
+ * The line is identical in a rules file (durable) and in a chat turn (session-only),
16
+ * so a session pin that works is made permanent by pasting it into the file. What
17
+ * differs is only WHERE it was found, which is enough to classify it:
18
+ *
19
+ * - inside the leading `<system-reminder>` run of message 0 → 'file'
20
+ * - anywhere in the system prompt → 'file'
21
+ * - in a user's typed text → 'session'
22
+ * - in any later `<system-reminder>` (inlined `@`-mention) → 'session'
23
+ *
24
+ * Two file locations because harnesses disagree on where a rules file goes.
25
+ * Claude Code inlines CLAUDE.md into message 0 behind a `<system-reminder>`
26
+ * envelope; OpenCode puts AGENTS.md in the system prompt with no wrapper and no
27
+ * label. Scanning only the first shape is what made #155 a no-op under OpenCode.
28
+ * Both are a file the user can edit, so both earn the durable tier.
29
+ *
30
+ * State is re-derived from the transcript on every request — no store, no session
31
+ * id (the Messages API has none), and rewinding the conversation rewinds the pins.
32
+ * This works even though we strip the commands from the outbound copy: inkling only
33
+ * rewrites the request going upstream, so the client's own transcript keeps
34
+ * re-sending them verbatim every turn.
35
+ */
36
+ import type { Message, SystemField } from './types.js';
37
+ /** Opening marker of a synthesized pin confirmation. We generate these, so the
38
+ * match is on bytes we control, not a heuristic that could eat a real reply. */
39
+ /** Prefix on every synthesized reply, and the whole test for recognizing one on
40
+ * the way back in. Shares the `@inkling` namespace with the commands so there is
41
+ * one token to learn and one to match, and unlike `·` it survives any encoding
42
+ * or copy/paste the transcript is put through. */
43
+ export declare const PIN_REPLY_MARK = "@fiche ";
44
+ /**
45
+ * Which tier a pin lives in. `'file'`, not `'claude.md'`: the same tier holds
46
+ * whatever the harness inlined, which is CLAUDE.md under Claude Code and
47
+ * AGENTS.md under OpenCode. Provider adapters normalize their wire shape before
48
+ * calling the same folder, so source and removal semantics stay identical.
49
+ *
50
+ * The tier is named for the origin because the origin is what answers the two
51
+ * questions a user has: why `unpin` refuses, and what to edit instead.
52
+ */
53
+ export type PinSource = 'file' | 'session';
54
+ /** Which command the live turn ended with — it decides what the reply lists. */
55
+ export type PinVerb = 'pin' | 'unpin';
56
+ export interface Pin {
57
+ text: string;
58
+ source: PinSource;
59
+ /**
60
+ * Absolute path of the file this line came from, when the harness named it in
61
+ * the envelope. Carried per pin, not per tier, because one leading run can
62
+ * inline several files and a header that says `CLAUDE.md` over a line that
63
+ * came from `AGENTS.md` sends the user to edit the wrong file.
64
+ */
65
+ path?: string;
66
+ }
67
+ /**
68
+ * Fold every pin command in the transcript, oldest to newest.
69
+ *
70
+ * @inkling unpin 2 remove the pin listed as 2
71
+ * @inkling unpin use tabs remove by text (exact, else prefix)
72
+ * @inkling unpin all clear every session pin
73
+ * @inkling unpin NOT destructive — prints the list
74
+ *
75
+ * Bare `unpin` used to clear everything and then print what survived, which read
76
+ * as a menu and destroyed the thing the user was still deciding about. Removal now
77
+ * requires naming a target; the bare form is a query.
78
+ *
79
+ * Every form clears SESSION pins only. Clearing CLAUDE.md pins too would mean an
80
+ * `unpin` typed forty turns ago silently disables the project's rules for the
81
+ * rest of the session with nothing on screen to explain why; to drop a durable
82
+ * pin you delete its line from the file, where the change is visible.
83
+ */
84
+ export declare function foldPins(messages: Message[], system?: SystemField): Pin[];
85
+ /**
86
+ * Remove pin commands and their synthesized confirmations from the OUTBOUND copy.
87
+ * The client keeps its own transcript, so nothing is lost: the next request still
88
+ * arrives with every command intact and foldPins re-derives the same state.
89
+ *
90
+ * A command-only turn is dropped together with the confirmation that answered it —
91
+ * never one alone, or the user/assistant roles stop alternating. A mixed turn keeps
92
+ * its prose and loses only the command lines, so the model is not distracted by
93
+ * configuration in the middle of a request it has to act on.
94
+ */
95
+ export declare function stripPinCommands(messages: Message[]): Message[];
96
+ /**
97
+ * Remove pin commands from the system prompt. Returns `undefined` when nothing
98
+ * changed, so the caller can leave the original object identity alone.
99
+ *
100
+ * Same move as stripFromMessage, including the `cache_control` handoff: system
101
+ * blocks carry the breakpoint that ends the cacheable prefix (extractSystemText
102
+ * keys on it), so a block emptied by stripping must pass its marker forward
103
+ * rather than take the boundary with it.
104
+ *
105
+ * Stripping here does rewrite bytes inside the cached prefix. That is the cost
106
+ * the message path already pays for CLAUDE.md: one cache create on the turn the
107
+ * strip first applies, then a stable prefix, because the rewrite is a pure
108
+ * function of the input and the client keeps re-sending the same source lines.
109
+ */
110
+ export declare function stripPinCommandsFromSystem(sys: SystemField | undefined): SystemField | undefined;
111
+ export declare function pinBlockText(pins: Pin[]): string;
112
+ /**
113
+ * True when appendPinBlock has somewhere to land.
114
+ *
115
+ * Pins are MOVED, not copied, so the strip and the append are one operation: an
116
+ * assistant prefill as the final message (nothing may follow it) or a final user
117
+ * turn with content we cannot push onto means the block has no home, and
118
+ * stripping anyway would delete the user's rules from the request entirely.
119
+ */
120
+ export declare function canAppendPinBlock(messages: Message[]): boolean;
121
+ /** Append the pin block to the final user message. Returns chars added. */
122
+ export declare function appendPinBlock(messages: Message[], pins: Pin[]): number;
123
+ export declare function pinReplyText(pins: Pin[], verb?: PinVerb): string;
124
+ /**
125
+ * True when the live turn is nothing but pin commands, so the proxy can answer it
126
+ * without spending an upstream call. Deliberately narrow: a turn carrying any real
127
+ * prose, or a tool_result (a tool loop that must not be hijacked mid-flight), is
128
+ * forwarded normally with the command lines merely stripped.
129
+ */
130
+ export declare function isPinOnlyRequest(messages: Message[] | undefined): boolean;
131
+ /**
132
+ * Answer a bare pin turn locally, or undefined to forward normally.
133
+ *
134
+ * Fails open on anything unexpected — a malformed body is the upstream's problem
135
+ * to report, not ours to swallow, and a parse quirk must never cost the user a
136
+ * turn that had real work in it.
137
+ */
138
+ export declare function pinCommandResponse(bodyIn: Uint8Array): {
139
+ body: string;
140
+ contentType: string;
141
+ } | undefined;
142
+ /** A local `/v1/messages` response carrying `text`, matching the client's
143
+ * streaming preference. Zero usage: nothing was billed, and reporting otherwise
144
+ * would corrupt the dashboard's token accounting. */
145
+ export declare function synthesizeReply(text: string, model: string, stream: boolean): {
146
+ body: string;
147
+ contentType: string;
148
+ };
149
+ /** Which OpenAI wire schema the reply has to imitate. */
150
+ export type OpenAIPinWire = 'chat' | 'responses';
151
+ type OpenAIPinRequest = {
152
+ instructions?: unknown;
153
+ input?: unknown;
154
+ messages?: unknown;
155
+ };
156
+ /** Move OpenAI-wire pin commands to the latest user input, using the same
157
+ * trailing system-reminder block as the Messages transformer. */
158
+ export declare function relocateOpenAIPins(req: OpenAIPinRequest): number;
159
+ type GooglePinPart = {
160
+ text?: unknown;
161
+ thought?: unknown;
162
+ [key: string]: unknown;
163
+ };
164
+ type GooglePinContent = {
165
+ role?: string;
166
+ parts?: GooglePinPart[];
167
+ [key: string]: unknown;
168
+ };
169
+ type GooglePinRequest = {
170
+ systemInstruction?: {
171
+ parts?: GooglePinPart[];
172
+ [key: string]: unknown;
173
+ };
174
+ contents?: GooglePinContent[];
175
+ };
176
+ /** Gemini-wire equivalent of relocateOpenAIPins. */
177
+ export declare function relocateGooglePins(req: GooglePinRequest): number;
178
+ /** `pinCommandResponse` for the OpenAI routes. Codex talks Responses and other
179
+ * clients talk Chat Completions, so the same command has to be answered in
180
+ * whichever schema the caller used. */
181
+ export declare function pinCommandResponseOpenAI(bodyIn: Uint8Array, wire: OpenAIPinWire): {
182
+ body: string;
183
+ contentType: string;
184
+ } | undefined;
185
+ /** Local `/v1/chat/completions` reply carrying `text`. Zero usage: nothing was
186
+ * billed, and reporting otherwise would corrupt the dashboard's accounting. */
187
+ export declare function synthesizeChatReply(text: string, model: string, stream: boolean): {
188
+ body: string;
189
+ contentType: string;
190
+ };
191
+ /** Local `/v1/responses` reply carrying `text`, in the event order the Responses
192
+ * API emits: clients read the final item from `response.completed`, but Codex
193
+ * renders the streamed deltas, so both have to be present. */
194
+ export declare function synthesizeResponsesReply(text: string, model: string, stream: boolean): {
195
+ body: string;
196
+ contentType: string;
197
+ };
198
+ export {};
199
+ //# sourceMappingURL=pin.d.ts.map