@illuminis/comprism 0.1.8 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. package/out/{graph → build/machine/codemap}/read-python.js +2 -2
  2. package/out/{executor → build/machine/executor}/diagnostics.js +1 -1
  3. package/out/{executor → build/machine/executor}/hooks.js +1 -1
  4. package/out/{executor → build/machine/executor}/sandbox.js +1 -1
  5. package/out/build/machine/line/index.js +339 -0
  6. package/out/{commands/privacy.js → build/machine/runtime/home.js} +10 -19
  7. package/out/build/machine/runtime/needs.js +89 -0
  8. package/out/{lib → build/machine/runtime}/self.js +25 -3
  9. package/out/build/machine/terminal/jobs.js +67 -0
  10. package/out/build/machine/terminal/sign-in.js +212 -0
  11. package/out/build/machine/terminal/steps.js +460 -0
  12. package/out/build/machine/terminal/voice.js +136 -0
  13. package/out/build/machine/voice/record.js +286 -0
  14. package/out/cli-start.js +130 -0
  15. package/out/machine/line/index.js +339 -0
  16. package/out/machine/runtime/self.js +22 -0
  17. package/out/machine/terminal/clipboard.js +182 -0
  18. package/out/machine/terminal/jobs.js +67 -0
  19. package/out/machine/terminal/sign-in.js +212 -0
  20. package/out/machine/terminal/steps.js +460 -0
  21. package/out/machine/terminal/voice.js +136 -0
  22. package/out/machine/voice/record.js +79 -1
  23. package/out/native/dictate +0 -0
  24. package/out/server.generated.js +6 -0
  25. package/package.json +8 -40
  26. package/README.md +0 -343
  27. package/out/agent/command.d.ts +0 -157
  28. package/out/agent/command.js +0 -454
  29. package/out/agent/render.d.ts +0 -169
  30. package/out/agent/render.js +0 -689
  31. package/out/agent/session.d.ts +0 -334
  32. package/out/agent/session.js +0 -1232
  33. package/out/commands/agents.d.ts +0 -2
  34. package/out/commands/agents.js +0 -79
  35. package/out/commands/ask.d.ts +0 -1
  36. package/out/commands/ask.js +0 -222
  37. package/out/commands/codemap.d.ts +0 -2
  38. package/out/commands/codemap.js +0 -151
  39. package/out/commands/commands-thin.d.ts +0 -39
  40. package/out/commands/commands-thin.js +0 -244
  41. package/out/commands/config.d.ts +0 -1
  42. package/out/commands/config.js +0 -138
  43. package/out/commands/cost.d.ts +0 -1
  44. package/out/commands/cost.js +0 -167
  45. package/out/commands/decisionEngine.d.ts +0 -1
  46. package/out/commands/decisionEngine.js +0 -66
  47. package/out/commands/hooks.d.ts +0 -1
  48. package/out/commands/hooks.js +0 -83
  49. package/out/commands/install.d.ts +0 -206
  50. package/out/commands/install.js +0 -738
  51. package/out/commands/instructions.d.ts +0 -1
  52. package/out/commands/instructions.js +0 -113
  53. package/out/commands/integrations.d.ts +0 -3
  54. package/out/commands/integrations.js +0 -215
  55. package/out/commands/jobs.d.ts +0 -5
  56. package/out/commands/jobs.js +0 -157
  57. package/out/commands/keys.d.ts +0 -55
  58. package/out/commands/keys.js +0 -344
  59. package/out/commands/login.d.ts +0 -9
  60. package/out/commands/login.js +0 -606
  61. package/out/commands/memory.d.ts +0 -3
  62. package/out/commands/memory.js +0 -113
  63. package/out/commands/permissions.d.ts +0 -1
  64. package/out/commands/permissions.js +0 -94
  65. package/out/commands/plugins.d.ts +0 -4
  66. package/out/commands/plugins.js +0 -192
  67. package/out/commands/privacy.d.ts +0 -1
  68. package/out/commands/providerKey.d.ts +0 -32
  69. package/out/commands/providerKey.js +0 -108
  70. package/out/commands/repl.d.ts +0 -12
  71. package/out/commands/repl.js +0 -2303
  72. package/out/commands/report.d.ts +0 -39
  73. package/out/commands/report.js +0 -115
  74. package/out/commands/review.d.ts +0 -5
  75. package/out/commands/review.js +0 -223
  76. package/out/commands/sessions.d.ts +0 -23
  77. package/out/commands/sessions.js +0 -115
  78. package/out/commands/settings.d.ts +0 -23
  79. package/out/commands/settings.js +0 -153
  80. package/out/commands/skills.d.ts +0 -21
  81. package/out/commands/skills.js +0 -207
  82. package/out/commands/unattended.d.ts +0 -7
  83. package/out/commands/unattended.js +0 -351
  84. package/out/commands/update.d.ts +0 -1
  85. package/out/commands/update.js +0 -123
  86. package/out/commands/welcome.d.ts +0 -25
  87. package/out/commands/welcome.js +0 -223
  88. package/out/commands/worktrees.d.ts +0 -5
  89. package/out/commands/worktrees.js +0 -186
  90. package/out/executor/browser.d.ts +0 -14
  91. package/out/executor/diagnostics.d.ts +0 -2
  92. package/out/executor/documents.d.ts +0 -40
  93. package/out/executor/files.d.ts +0 -2
  94. package/out/executor/git.d.ts +0 -48
  95. package/out/executor/hooks.d.ts +0 -51
  96. package/out/executor/index.d.ts +0 -45
  97. package/out/executor/notebook.d.ts +0 -2
  98. package/out/executor/paths.d.ts +0 -20
  99. package/out/executor/sandbox.d.ts +0 -40
  100. package/out/executor/shell.d.ts +0 -86
  101. package/out/executor/toolservers.d.ts +0 -20
  102. package/out/executor/worktree.d.ts +0 -9
  103. package/out/graph/build.d.ts +0 -45
  104. package/out/graph/facts.d.ts +0 -47
  105. package/out/graph/files.d.ts +0 -45
  106. package/out/graph/read-locales.d.ts +0 -29
  107. package/out/graph/read-python.d.ts +0 -11
  108. package/out/graph/read-typescript.d.ts +0 -16
  109. package/out/graph/sync.d.ts +0 -66
  110. package/out/graph/sync.js +0 -242
  111. package/out/lib/attach.d.ts +0 -106
  112. package/out/lib/attach.js +0 -396
  113. package/out/lib/clipboard.d.ts +0 -23
  114. package/out/lib/commandlist.d.ts +0 -20
  115. package/out/lib/commandlist.js +0 -58
  116. package/out/lib/config.d.ts +0 -94
  117. package/out/lib/config.js +0 -197
  118. package/out/lib/connection.d.ts +0 -73
  119. package/out/lib/connection.js +0 -188
  120. package/out/lib/decision.d.ts +0 -22
  121. package/out/lib/decision.js +0 -50
  122. package/out/lib/fingerprint.d.ts +0 -25
  123. package/out/lib/fingerprint.js +0 -58
  124. package/out/lib/gateway.d.ts +0 -427
  125. package/out/lib/gateway.js +0 -226
  126. package/out/lib/history.d.ts +0 -24
  127. package/out/lib/history.js +0 -137
  128. package/out/lib/ide.d.ts +0 -19
  129. package/out/lib/ide.js +0 -131
  130. package/out/lib/keyboard.d.ts +0 -98
  131. package/out/lib/keyboard.js +0 -390
  132. package/out/lib/lastlogin.d.ts +0 -14
  133. package/out/lib/lastlogin.js +0 -105
  134. package/out/lib/machine.d.ts +0 -21
  135. package/out/lib/machine.js +0 -91
  136. package/out/lib/notify.d.ts +0 -4
  137. package/out/lib/notify.js +0 -52
  138. package/out/lib/output.d.ts +0 -48
  139. package/out/lib/output.js +0 -108
  140. package/out/lib/picker.d.ts +0 -1
  141. package/out/lib/picker.js +0 -158
  142. package/out/lib/project-ops.d.ts +0 -19
  143. package/out/lib/project-ops.js +0 -146
  144. package/out/lib/project.d.ts +0 -28
  145. package/out/lib/prompt.d.ts +0 -37
  146. package/out/lib/prompt.js +0 -142
  147. package/out/lib/queue.d.ts +0 -13
  148. package/out/lib/queue.js +0 -116
  149. package/out/lib/readiness.d.ts +0 -22
  150. package/out/lib/readiness.js +0 -207
  151. package/out/lib/self.d.ts +0 -23
  152. package/out/lib/servicecommand.d.ts +0 -14
  153. package/out/lib/servicecommand.js +0 -74
  154. package/out/lib/sessions.d.ts +0 -19
  155. package/out/lib/sessions.js +0 -221
  156. package/out/lib/startcache.d.ts +0 -13
  157. package/out/lib/startcache.js +0 -78
  158. package/out/lib/stdin.d.ts +0 -32
  159. package/out/lib/stdin.js +0 -117
  160. package/out/lib/store.d.ts +0 -40
  161. package/out/lib/store.js +0 -138
  162. package/out/lib/sync.d.ts +0 -18
  163. package/out/lib/sync.js +0 -81
  164. package/out/lib/types.d.ts +0 -417
  165. package/out/lib/types.js +0 -21
  166. package/out/lib/ui.d.ts +0 -123
  167. package/out/lib/ui.js +0 -299
  168. package/out/lib/version.d.ts +0 -23
  169. package/out/lib/version.js +0 -46
  170. package/out/lib/voice.d.ts +0 -49
  171. package/out/lib/voice.js +0 -236
  172. package/out/lib/words.d.ts +0 -20
  173. package/out/lib/words.js +0 -27
  174. package/out/machine/codemap/build.d.ts +0 -45
  175. package/out/machine/codemap/facts.d.ts +0 -47
  176. package/out/machine/codemap/files.d.ts +0 -45
  177. package/out/machine/codemap/read-locales.d.ts +0 -29
  178. package/out/machine/codemap/read-python.d.ts +0 -11
  179. package/out/machine/codemap/read-typescript.d.ts +0 -16
  180. package/out/machine/executor/browser.d.ts +0 -14
  181. package/out/machine/executor/diagnostics.d.ts +0 -2
  182. package/out/machine/executor/documents.d.ts +0 -40
  183. package/out/machine/executor/files.d.ts +0 -2
  184. package/out/machine/executor/git.d.ts +0 -48
  185. package/out/machine/executor/hooks.d.ts +0 -51
  186. package/out/machine/executor/index.d.ts +0 -45
  187. package/out/machine/executor/notebook.d.ts +0 -2
  188. package/out/machine/executor/paths.d.ts +0 -20
  189. package/out/machine/executor/sandbox.d.ts +0 -40
  190. package/out/machine/executor/shell.d.ts +0 -86
  191. package/out/machine/executor/toolservers.d.ts +0 -20
  192. package/out/machine/executor/worktree.d.ts +0 -9
  193. package/out/machine/folder/project.d.ts +0 -28
  194. package/out/machine/runtime/home.d.ts +0 -2
  195. package/out/machine/runtime/needs.d.ts +0 -30
  196. package/out/machine/runtime/self.d.ts +0 -23
  197. package/out/machine/voice/record.d.ts +0 -38
  198. package/out/postinstall.d.ts +0 -2
  199. package/out/postinstall.js +0 -120
  200. package/out/providers/anthropic.d.ts +0 -22
  201. package/out/providers/anthropic.js +0 -80
  202. package/out/providers/index.d.ts +0 -8
  203. package/out/providers/index.js +0 -84
  204. package/out/providers/openai.d.ts +0 -11
  205. package/out/providers/openai.js +0 -57
  206. package/out/thin.d.ts +0 -2
  207. package/out/thin.js +0 -855
  208. package/scripts/read_python.py +0 -270
  209. /package/out/{graph → build/machine/codemap}/build.js +0 -0
  210. /package/out/{graph → build/machine/codemap}/facts.js +0 -0
  211. /package/out/{graph → build/machine/codemap}/files.js +0 -0
  212. /package/out/{graph → build/machine/codemap}/read-locales.js +0 -0
  213. /package/out/{graph → build/machine/codemap}/read-typescript.js +0 -0
  214. /package/out/{executor → build/machine/executor}/browser.js +0 -0
  215. /package/out/{executor → build/machine/executor}/documents.js +0 -0
  216. /package/out/{executor → build/machine/executor}/files.js +0 -0
  217. /package/out/{executor → build/machine/executor}/git.js +0 -0
  218. /package/out/{executor → build/machine/executor}/index.js +0 -0
  219. /package/out/{executor → build/machine/executor}/notebook.js +0 -0
  220. /package/out/{executor → build/machine/executor}/paths.js +0 -0
  221. /package/out/{executor → build/machine/executor}/shell.js +0 -0
  222. /package/out/{executor → build/machine/executor}/toolservers.js +0 -0
  223. /package/out/{executor → build/machine/executor}/worktree.js +0 -0
  224. /package/out/{lib → build/machine/folder}/project.js +0 -0
  225. /package/out/{lib → build/machine/terminal}/clipboard.js +0 -0
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.liveStart = liveStart;
4
+ exports.liveState = liveState;
5
+ exports.liveStop = liveStop;
6
+ exports.recordMissing = recordMissing;
7
+ exports.recordStart = recordStart;
8
+ exports.recordStop = recordStop;
9
+ exports.recordDiscard = recordDiscard;
10
+ /**
11
+ * Listening on this computer's microphone, on the server's order.
12
+ *
13
+ * Live words: the microphone is streamed to the service's live words address
14
+ * as it is heard, and the words come back as the service recognizes them; the
15
+ * terminal asks for the level and the words so far and draws them. Recording:
16
+ * a plain recording the server writes down when the person presses Enter.
17
+ * Every recording is deleted straight after; nothing is kept.
18
+ */
19
+ const node_crypto_1 = require("node:crypto");
20
+ const record_1 = require("../voice/record");
21
+ const lives = new Map();
22
+ const recordings = new Map();
23
+ /** Start live words: `{server, key}`; null id when it cannot stream here. */
24
+ function liveStart(server, key, listen = '') {
25
+ if ((0, record_1.missing)() || typeof WebSocket === 'undefined')
26
+ return { id: null };
27
+ const address = new URL(server);
28
+ address.protocol = address.protocol === 'https:' ? 'wss:' : 'ws:';
29
+ address.pathname = '/api/v1/front-door/prism_attachments/live';
30
+ const socket = new WebSocket(address.toString());
31
+ socket.binaryType = 'arraybuffer';
32
+ const held = [];
33
+ let ready = false;
34
+ let settle = null;
35
+ const live = { level: 0, words: '', why: '', socket, stop: async () => undefined,
36
+ ended: new Promise((resolve) => { settle = resolve; }) };
37
+ socket.onopen = () => socket.send(JSON.stringify({ type: 'start', token: key, ...(listen ? { listen } : {}) }));
38
+ socket.onerror = () => { live.why = live.why || 'The service could not be reached for live words.'; settle?.(); };
39
+ socket.onclose = () => settle?.();
40
+ socket.onmessage = (event) => {
41
+ let frame;
42
+ try {
43
+ frame = JSON.parse(String(event.data));
44
+ }
45
+ catch {
46
+ return;
47
+ }
48
+ if (frame.type === 'ready') {
49
+ ready = true;
50
+ for (const chunk of held.splice(0))
51
+ socket.send(chunk);
52
+ }
53
+ else if (frame.type === 'words' || frame.type === 'done') {
54
+ live.words = frame.text ?? live.words;
55
+ if (frame.type === 'done')
56
+ settle?.();
57
+ }
58
+ else if (frame.type === 'error') {
59
+ live.why = frame.message ?? 'The words could not be written.';
60
+ settle?.();
61
+ }
62
+ };
63
+ try {
64
+ const recording = (0, record_1.startLive)((chunk) => {
65
+ let peak = 0;
66
+ for (let i = 0; i + 1 < chunk.length; i += 2)
67
+ peak = Math.max(peak, Math.abs(chunk.readInt16LE(i)));
68
+ live.level = Math.min(1, peak / 16000);
69
+ if (socket.readyState !== WebSocket.OPEN)
70
+ return;
71
+ if (ready)
72
+ socket.send(chunk);
73
+ else
74
+ held.push(chunk);
75
+ });
76
+ live.stop = () => recording.stop();
77
+ }
78
+ catch (err) {
79
+ try {
80
+ socket.close();
81
+ }
82
+ catch { /* gone */ }
83
+ live.why = err.message;
84
+ }
85
+ const id = (0, node_crypto_1.randomUUID)();
86
+ lives.set(id, live);
87
+ return { id };
88
+ }
89
+ /** The level, the words so far and any problem: `{id}`. */
90
+ function liveState(id) {
91
+ const live = lives.get(id);
92
+ return live ? { level: live.level, words: live.words, problem: live.why }
93
+ : { level: 0, words: '', problem: 'not listening' };
94
+ }
95
+ /** Stop live words and get the final words, or null when it could not listen: `{id}`. */
96
+ async function liveStop(id) {
97
+ const live = lives.get(id);
98
+ if (!live)
99
+ return { text: null, problem: 'not listening' };
100
+ lives.delete(id);
101
+ await live.stop();
102
+ try {
103
+ live.socket.send(JSON.stringify({ type: 'stop' }));
104
+ }
105
+ catch { /* closed */ }
106
+ await Promise.race([live.ended, new Promise((r) => setTimeout(r, 6000).unref())]);
107
+ try {
108
+ live.socket.close();
109
+ }
110
+ catch { /* gone */ }
111
+ return { text: live.why && !live.words ? null : live.words.trim(), problem: live.why };
112
+ }
113
+ /** Why recording cannot work here, or null. */
114
+ function recordMissing() {
115
+ return { why: (0, record_1.missing)() };
116
+ }
117
+ /** Start a plain recording: `{}`; its id and file. */
118
+ function recordStart() {
119
+ const rec = (0, record_1.start)();
120
+ const id = (0, node_crypto_1.randomUUID)();
121
+ recordings.set(id, rec);
122
+ return { id, file: rec.file, by: rec.by };
123
+ }
124
+ /** Stop a recording and hand back its file: `{id}`. */
125
+ async function recordStop(id) {
126
+ const rec = recordings.get(id);
127
+ recordings.delete(id);
128
+ if (!rec)
129
+ return { file: '', bytes: 0 };
130
+ return rec.stop();
131
+ }
132
+ /** Delete a recording and its folder: `{file}`. */
133
+ function recordDiscard(file) {
134
+ (0, record_1.discard)(file);
135
+ return { removed: true };
136
+ }
@@ -33,10 +33,13 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.LIVE_RATE = void 0;
37
+ exports.builtInReader = builtInReader;
36
38
  exports.recorder = recorder;
37
39
  exports.missing = missing;
38
40
  exports.start = start;
39
41
  exports.discard = discard;
42
+ exports.startLive = startLive;
40
43
  /**
41
44
  * Recording what a person says, on their own computer, for every client that
42
45
  * offers a microphone: the command line and the editor extension.
@@ -101,6 +104,20 @@ const RECORDERS = [
101
104
  // Linux's own, present on most desktop installs.
102
105
  { name: 'arecord', command: 'arecord', args: (out) => ['-q', '-f', 'S16_LE', '-c', '1', '-r', RATE, out] },
103
106
  ];
107
+ /**
108
+ * The microphone reader that ships inside the package (a Mac program built
109
+ * from native/dictate.swift), so a person installs nothing to speak. It only
110
+ * passes the microphone's sound on; the server does the transcribing.
111
+ */
112
+ function builtInReader() {
113
+ if (process.platform !== 'darwin')
114
+ return null;
115
+ for (const at of [path.join(__dirname, '..', '..', 'native', 'dictate'), path.join(__dirname, '..', 'native', 'dictate')]) {
116
+ if (fs.existsSync(at))
117
+ return at;
118
+ }
119
+ return null;
120
+ }
104
121
  /** The first recording tool this machine has, or null. */
105
122
  function recorder() {
106
123
  return RECORDERS.find((r) => present(r.command)) ?? null;
@@ -113,7 +130,7 @@ function recorder() {
113
130
  * software.
114
131
  */
115
132
  function missing() {
116
- if (recorder())
133
+ if (builtInReader() || recorder())
117
134
  return null;
118
135
  return process.platform === 'darwin'
119
136
  ? 'Speaking needs a recording tool, and macOS does not come with one. '
@@ -206,3 +223,64 @@ function discard(file) {
206
223
  }
207
224
  catch { /* a temp file we could not remove is not worth a word to anybody */ }
208
225
  }
226
+ // ── Live: the microphone as it is heard, for the service's live words ───────
227
+ /** What the live words service takes: 16 bit samples, one channel, this rate. */
228
+ exports.LIVE_RATE = '24000';
229
+ /** The same tools, writing raw samples to their output instead of a file. */
230
+ function liveArgs(tool) {
231
+ // A test's fake microphone: a recording played in at its real speed, as the
232
+ // browser tests do with their fake audio device. Only ffmpeg reads one.
233
+ const fake = process.env.COMPRISM_FAKE_MIC;
234
+ if (fake && tool.name === 'ffmpeg') {
235
+ return ['-loglevel', 'quiet', '-nostdin', '-re', '-stream_loop', '-1', '-i', fake,
236
+ '-af', 'speechnorm=e=25:r=0.0001:l=1', '-ac', '1', '-ar', exports.LIVE_RATE, '-f', 's16le', '-flush_packets', '1', '-'];
237
+ }
238
+ if (tool.name === 'sox')
239
+ return ['-q', '-t', 'raw', '-b', '16', '-e', 'signed', '-c', '1', '-r', exports.LIVE_RATE, '-'];
240
+ if (tool.name === 'arecord')
241
+ return ['-q', '-t', 'raw', '-f', 'S16_LE', '-c', '1', '-r', exports.LIVE_RATE, '-'];
242
+ return [
243
+ '-loglevel', 'quiet', '-nostdin',
244
+ ...(process.platform === 'darwin' ? ['-f', 'avfoundation', '-i', ':default'] : ['-f', 'alsa', '-i', 'default']),
245
+ // A laptop microphone can arrive at a hundredth of speaking volume, too
246
+ // quiet for the transcriber to notice speech. This lifts quiet speech to a
247
+ // normal level as it is heard, without the second of delay other levelers add.
248
+ '-af', 'speechnorm=e=25:r=0.0001:l=1',
249
+ '-ac', '1', '-ar', exports.LIVE_RATE, '-f', 's16le', '-flush_packets', '1', '-',
250
+ ];
251
+ }
252
+ /** Start listening live. Throws when there is nothing to listen with. */
253
+ function startLive(onSound) {
254
+ const reader = builtInReader();
255
+ const tool = reader ? { name: 'built in microphone reader', command: reader, args: () => [] } : recorder();
256
+ if (!tool)
257
+ throw new Error(missing() ?? 'No recording tool.');
258
+ // The built in reader stops when its input closes, so it is given one.
259
+ const child = reader
260
+ ? (0, node_child_process_1.spawn)(reader, ['--raw', exports.LIVE_RATE], { stdio: ['pipe', 'pipe', 'ignore'] })
261
+ : (0, node_child_process_1.spawn)(tool.command, liveArgs(tool), { stdio: ['ignore', 'pipe', 'ignore'] });
262
+ child.stdout?.on('data', (chunk) => onSound(chunk));
263
+ // As with a file: the microphone never outlives the process that opened it.
264
+ const abandon = () => { try {
265
+ child.kill('SIGKILL');
266
+ }
267
+ catch { /* already gone */ } };
268
+ process.once('exit', abandon);
269
+ let stopped = null;
270
+ const stop = () => {
271
+ if (stopped)
272
+ return stopped;
273
+ stopped = new Promise((resolve) => {
274
+ child.once('close', () => resolve());
275
+ try {
276
+ child.kill('SIGINT');
277
+ }
278
+ catch {
279
+ resolve();
280
+ }
281
+ setTimeout(() => { abandon(); resolve(); }, 500).unref();
282
+ }).then(() => { process.off('exit', abandon); });
283
+ return stopped;
284
+ };
285
+ return { by: tool.name, stop };
286
+ }
Binary file
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BUILD_COMMIT = exports.HOME_SERVER = void 0;
4
+ // Written by the build. Do not edit.
5
+ exports.HOME_SERVER = "http://localhost:8009";
6
+ exports.BUILD_COMMIT = "local";
package/package.json CHANGED
@@ -1,64 +1,32 @@
1
1
  {
2
2
  "name": "@illuminis/comprism",
3
- "version": "0.1.8",
4
- "description": "CompletionPrism Companion. Records what finishing a piece of work actually costs - every attempt, and the human time spent noticing and repairing the ones that failed.",
3
+ "version": "2.4.1",
4
+ "description": "CompletionPrism in your terminal. A thin shell: what you type goes to CompletionPrism's front door, and what it answers comes back.",
5
5
  "license": "UNLICENSED",
6
6
  "private": false,
7
- "main": "out/thin.js",
8
- "types": "out/thin.d.ts",
7
+ "main": "out/cli-start.js",
9
8
  "bin": {
10
- "comprism": "out/thin.js"
9
+ "comprism": "out/cli-start.js"
11
10
  },
12
11
  "files": [
13
12
  "out/**/*.js",
14
- "out/**/*.d.ts",
15
13
  "out/native/dictate",
16
- "!out/tests/**",
17
- "!out/internal/**",
18
- "scripts/read_python.py",
19
- "README.md",
20
14
  "LICENSE"
21
15
  ],
22
16
  "engines": {
23
17
  "node": ">=22"
24
18
  },
25
19
  "scripts": {
26
- "build": "node scripts/sync-machine-services.mjs && tsc -p ./ && node scripts/build-native.mjs",
27
- "dev": "node scripts/sync-machine-services.mjs && tsc -w -p ./",
28
- "test": "npm run build && node --test out/**/*.test.js",
29
- "gate": "npm run build && npm test && npm run shipcheck",
30
- "prepublishOnly": "npm run build",
31
- "prepack": "npm run build",
32
- "postinstall": "node out/postinstall.js || true",
33
- "shipcheck": "node scripts/check-no-model-logic.mjs"
20
+ "build": "node scripts/write-server.mjs src/server.generated.ts && node scripts/sync-machine-services.mjs && tsc -p ./ && node scripts/build-native.mjs"
34
21
  },
35
22
  "devDependencies": {
36
- "@types/node": "^20.11.0",
37
- "esbuild": "0.28.2",
38
- "postject": "1.0.0-alpha.6"
23
+ "@types/node": "24.12.2",
24
+ "typescript": "6.0.3"
39
25
  },
40
26
  "publishConfig": {
41
27
  "access": "public",
42
28
  "registry": "https://registry.npmjs.org/"
43
29
  },
44
- "repository": {
45
- "type": "git",
46
- "url": "git+https://github.com/Illuminis-ai/completionprism.git",
47
- "directory": "app/frontend/terminal"
48
- },
49
- "keywords": [
50
- "ai",
51
- "cost",
52
- "observability",
53
- "llm",
54
- "completion"
55
- ],
56
30
  "author": "illuminis.ai LLC",
57
- "homepage": "https://completionprism.illuminis.ai",
58
- "bugs": {
59
- "url": "https://github.com/Illuminis-ai/completionprism/issues"
60
- },
61
- "dependencies": {
62
- "typescript": "^5.4.0"
63
- }
31
+ "homepage": "https://completionprism.illuminis.ai"
64
32
  }
package/README.md DELETED
@@ -1,343 +0,0 @@
1
- # `@illuminis/comprism` - the CompletionPrism Companion
2
-
3
- The half of CompletionPrism that runs on your machine. It sits between the tool
4
- you already use and the AI provider, records what finishing your work actually
5
- cost, and changes nothing about what your tool does.
6
-
7
- ## Install
8
-
9
- Three ways, one tool. Pick the one that suits the machine; each gives you the
10
- same `comprism` command, sign in and settings.
11
-
12
- | Option | Pick it when | Install |
13
- | --- | --- | --- |
14
- | 1. Install script (recommended) | Nothing needs to be on the machine first: no Node, no Python | `curl -fsSL https://yourco.completionprism.com/install.sh \| sh` |
15
- | 2. npm | You already use Node 22 or newer | `npm install -g @illuminis/comprism` |
16
- | 3. Python | You have Python 3.9 or newer and no Node | `pip install comprism-cli` (or `pipx install comprism-cli`) |
17
-
18
- On Windows, the install script is one line in PowerShell:
19
- `irm https://yourco.completionprism.com/install.ps1 | iex`. The address is your
20
- own workspace, the one you sign in to. A company that allows only its own
21
- package sources installs the Python option from the workspace:
22
- `pip install --index-url https://yourco.completionprism.com/pypi/simple/ comprism-cli`.
23
-
24
- Then sign in:
25
-
26
- ```bash
27
- comprism login
28
- ```
29
-
30
- That is the whole install. It configures itself, including the one line it adds
31
- to your shell profile, and it says what it touched. npm hides that message by
32
- default, so add `--foreground-scripts` to the install if you want to read it.
33
- A Python install finishes its setup on the first `comprism login`.
34
-
35
- No API key to export. The keys live in your workspace, and every decision is
36
- made on our servers.
37
-
38
- Sign in from an interactive terminal. `comprism login` and its `connect` alias
39
- exit with status 1 when input is piped or redirected, before asking for credentials
40
- or contacting the service. Sign in first, then run commands from your script.
41
-
42
- ```bash
43
- comprism status # which account and company this machine is signed in to
44
- comprism check # what this machine still needs, and how to add it
45
- comprism install # redo the shell setup, if the install could not
46
- comprism cost # what a session cost, and which factors drove it
47
- comprism uninstall # takes the line back out
48
- ```
49
-
50
- `comprism check` exits with status 1 while setup is unfinished, so a script can
51
- test for it. `comprism --version` prints the installed version. `comprism
52
- update` installs a newer version the same way this one was installed; your sign
53
- in and the single profile line are kept.
54
-
55
- `comprism uninstall` removes the profile line, the generated shell script and
56
- any old Claude Desktop entry of ours; for an install script install it also
57
- removes the program. It leaves your sign in and settings in `~/.comprism` and
58
- says so. Run `comprism logout` first to revoke this machine's key. Then remove
59
- the tool the way it was installed: nothing more for the install script,
60
- `npm uninstall -g @illuminis/comprism` for npm, `pip uninstall comprism-cli`
61
- for Python. Delete `~/.comprism` to remove every trace.
62
-
63
- Automatic shell setup covers zsh and bash on macOS and Linux, and PowerShell on
64
- Windows. The Windows install script also puts the tool on your user PATH, so
65
- Command Prompt finds it too.
66
-
67
- ## Where the money went
68
-
69
- `comprism cost` breaks down a session without leaving the terminal: what it
70
- cost, what it would have cost, and the five factors behind the difference, then
71
- every provider call with its tokens, its price and the decision that chose that
72
- model.
73
-
74
- ```bash
75
- comprism cost # the newest session this workspace recorded
76
- comprism cost srv_69e322469de33b90 # a particular one
77
- cost # inside a session, meaning this one
78
- ```
79
-
80
- The figures come from the same service the portal reads, so the two can never
81
- quote different numbers for one piece of work. A factor nothing measured prints
82
- blank, never zero: a zero in a cost column reads as a measurement.
83
-
84
- ## The coding agent
85
-
86
- `comprism work` reads your project, changes files, runs commands, runs your
87
- tests, and shows you every change before it makes it.
88
-
89
- ```bash
90
- cd ~/your-project
91
- comprism work "the tests are failing, work out why and fix it"
92
- ```
93
-
94
- **What makes it different from the others.** Every step is routed to whichever
95
- model finishes the work for least, and it can change its mind between one step
96
- and the next. The receipt at the end says what the job actually cost.
97
-
98
- ```
99
- /Users/you/your-project 23 actions available
100
- step 1 claude-sonnet-5 $0.02 5.0s
101
- ok run_tests 425ms
102
- step 2 claude-sonnet-5 $0.02 3.0s
103
- ok read_file parser.js
104
- ok edit_file parser.js
105
- step 3 claude-sonnet-5 $0.02 3.3s
106
- ok run_tests 262ms
107
-
108
- Done
109
- 6 steps . 6 actions . $0.14 . tests passed
110
- ```
111
-
112
- ### How much it is allowed to do
113
-
114
- Four settings, and the safe one is the default. Nothing is automatic unless you
115
- choose it.
116
-
117
- | `--mode` | What it may do |
118
- |---|---|
119
- | `read_only` | Look at the project and answer questions. Change nothing |
120
- | `approve_writes` | **The default.** Show you every change before making it |
121
- | `auto_edit` | Change files freely. Ask before running anything |
122
- | `full_auto` | Get on with it. Publishing and installing packages are still confirmed |
123
-
124
- Some things no setting unlocks: force pushing, rewriting history, downloading a
125
- script and running it, anything that touches your credentials, and deploying to
126
- production. Those are yours to do.
127
-
128
- ### Before you let it change anything
129
-
130
- ```bash
131
- comprism work --plan "rename the parser module and update every caller"
132
- ```
133
-
134
- It reads what it needs, tells you what it would do, and changes nothing. The
135
- cheapest moment to disagree with an agent is before it starts.
136
-
137
- ### While it is running
138
-
139
- - **Ctrl+C** stops the job. It does not kill the command line tool, and it does
140
- not leave the job running on the server.
141
- - **Type anything** and it joins the next step, so you can correct course without
142
- starting again.
143
-
144
- ### Taking a job back
145
-
146
- Every change is copied before it is made. Open the job in the portal and undo it,
147
- and the files go back to exactly the bytes they started with. Where a job also
148
- ran a command, the undo says so plainly rather than claiming to have reversed it.
149
-
150
- ### Carrying on tomorrow
151
-
152
- ```bash
153
- comprism work --resume <job-id> "also add a test for the empty case"
154
- ```
155
-
156
- It continues the conversation rather than starting a new one, so it already knows
157
- what it read and decided.
158
-
159
- ### In a script, or in continuous integration
160
-
161
- ```bash
162
- comprism work --yes --mode auto_edit "run the linter and fix what it reports"
163
- echo $? # 0 if it finished, non-zero if it did not
164
- ```
165
-
166
- With no terminal attached nobody can be asked anything, so anything that would
167
- need an approval is **refused** rather than assumed. A script that needs to change
168
- files says so by choosing a mode that allows it.
169
-
170
- ### Which model
171
-
172
- By default, whichever finishes each step for least. Pin one when you want to
173
- decide yourself:
174
-
175
- ```bash
176
- comprism work --model gpt-5 "..." # or any model your account can reach
177
- comprism work --max-spend 2.00 "..." # stop here rather than running on
178
- ```
179
-
180
- Four providers are wired: Anthropic, OpenAI, Google and xAI. Which ones you can
181
- reach depends on the keys on your account.
182
-
183
- ### Requirements
184
-
185
- A workspace you have signed in to with `comprism login`. Node 22 or newer for
186
- the npm option only; the install script and Python options carry their own.
187
-
188
- ---
189
-
190
- ## Instrument a tool you already use
191
-
192
- Nothing to do. The install configured this, by adding one fenced line to your
193
- shell profile that points your existing tools at the recorder. Open a new
194
- terminal and `claude` is already measured.
195
-
196
- Requests are forwarded to the provider byte for byte. Your key is forwarded,
197
- never read or stored. `comprism uninstall` takes the line back out and every
198
- tool goes straight to its provider again.
199
-
200
- ## Whose Anthropic account pays
201
-
202
- Yours, on every surface. How it gets there differs by one thing only: whether the
203
- surface can carry a credential.
204
-
205
- | How you work | Where the key comes from | Stored anywhere? |
206
- |---|---|---|
207
- | `comprism`, the interception the install configured, or an IDE pointed at your workspace | this machine, per request | no |
208
- | The developer API and the SDKs | the `X-Anthropic-Key` header, per request | no |
209
- | Claude Desktop and claude.ai | your workspace's own stored key | yes, encrypted, and only this one |
210
-
211
- The third row is the exception and it is a protocol limit rather than a choice:
212
- an MCP connector reaches the server with no channel for a provider credential, so
213
- answering those prompts at all means the workspace holding a key. A workspace
214
- that holds none gets its connector answers refused - never billed to illuminis.
215
-
216
- ```bash
217
- comprism keys # whose account pays, here and in your workspace
218
- ```
219
-
220
- Sending a key to your workspace, for the connector row above, is deliberate and
221
- it is the one action that puts a provider key anywhere. It goes over TLS to the
222
- workspace you are signed in to, the provider validates it before it is stored,
223
- and nothing is written to disk here either way. An administrator can do the same
224
- in the app, under Policy and Data Controls.
225
-
226
- ## The stats footer
227
-
228
- Through the proxy there is no result object and no widget area: the client
229
- renders the message body and nothing else. So a finished Anthropic answer comes
230
- back with two extra lines under it.
231
-
232
- ```
233
- The GCD of 1071 and 462 is 21.
234
-
235
- ---
236
- **$0.038 saved** vs Claude Opus 5 · *Claude Haiku 4.5 · 12,614 tokens · 0.0s*
237
- ```
238
-
239
- **How it works.** On the way out, the footer is wrapped in an HTML comment pair
240
- (`<!--cp-meta-->` … `<!--/cp-meta-->`) that renders as nothing. On a streamed
241
- response it arrives as one more text content block - `content_block_start`,
242
- `content_block_delta`, `content_block_stop` at the next free index - emitted
243
- after the provider's last block and before the terminating `message_delta`. On a
244
- non-streamed one it is spliced in as a text block after the last existing text
245
- block. Either way the provider's own bytes are forwarded unchanged; the footer is
246
- added, never merged.
247
-
248
- On the way back in, every previously injected footer is cut out of the request by
249
- sentinel before it reaches the provider. So the model never sees one, never
250
- learns to imitate the format, and nobody pays context for the same footer twice.
251
- Stripping is idempotent and runs whether or not injection is switched on.
252
-
253
- **It is never allowed to cost you an answer.** If anything in the footer path
254
- throws, the provider's response passes through completely unmodified and the
255
- failure is logged rather than shown. Nothing is added at all when the turn ends
256
- in a tool call, a refusal, a truncation, an error event, an empty response, or a
257
- model with no published price.
258
-
259
- Switch it off with `"enabled": false` under `footer` in
260
- `~/.comprism/config.json`, which makes the proxy byte faithful in both
261
- directions.
262
-
263
- ### Configuring pricing, the baseline and the template
264
-
265
- Everything lives under `footer` in `~/.comprism/config.json`:
266
-
267
- ```json
268
- {
269
- "footer": {
270
- "enabled": true,
271
- "template": "compact",
272
- "baselineModel": "claude-opus-5",
273
- "pricing": {
274
- "claude-haiku-4-5": { "inPerMTok": 0.8, "outPerMTok": 4.0 }
275
- }
276
- }
277
- }
278
- ```
279
-
280
- `baselineModel` is what the saving is measured against: the one capable model a
281
- company would have mandated for everything. It is named in the footer itself,
282
- because "$0.038 saved" is a claim nobody can check and "$0.038 saved vs Claude
283
- Opus 5" is one they can. When the routed model costs the same or more, no
284
- dollar figure is shown at all - never a negative one.
285
-
286
- `pricing` overrides the published catalog per model, for tenants whose
287
- contracted rate is not list price. `inPerMTok` and `outPerMTok` are required;
288
- `cacheReadPerMTok` and `cacheWritePerMTok` are optional and default to the
289
- provider's published multipliers of the input price (0.1x and 1.25x). A model in
290
- neither the catalog nor this table is unpriced, and an unpriced turn gets no
291
- footer rather than a guessed one.
292
-
293
- `template` is one of:
294
-
295
- | Template | Hero |
296
- |---|---|
297
- | `compact` | this turn's saving, with the baseline named |
298
- | `cumulative` | everything saved since the recorder started, then this turn |
299
- | `detailed` | this turn's saving, plus the in / out / cached token split |
300
-
301
- To add another, extend `renderFooter` in `src/footer.ts` and the `FooterTemplate`
302
- union in `src/types.ts`. Keep it to a divider and one line: the footer exists to
303
- punctuate an answer, not to compete with it.
304
-
305
- ### The known constraint
306
-
307
- The client renders markdown in the message body and offers no other surface, so
308
- that is the whole design space. No panel, no badge, no hover, no color beyond
309
- what bold and italic give. Anything richer belongs in the portal, which is why
310
- the footer stays deliberately small.
311
-
312
- ## What it records, and what it refuses to
313
-
314
- Under `~/.comprism/`, mode 700, append-only:
315
-
316
- | File | One row per |
317
- |---|---|
318
- | `ledger.jsonl` | provider call: model, tokens, cost, latency, finish reason |
319
- | `decisions.jsonl` | decision point: what was known and chosen, **never edited** |
320
- | `sessions.json` | working session: the shape of each turn, not its words |
321
-
322
- Never written, anywhere: your prompts, the responses, or your API keys. A request
323
- is identified by the sha256 of its normalized text and nothing else. Turning text
324
- storage on is an explicit tenant decision; everything here works without it.
325
-
326
- ## The estimator is present and inert
327
-
328
- With no evidence, the estimator returns "no recommendation, insufficient
329
- evidence", records why, and the request proceeds untouched. It never invents a
330
- number. Selection arrives with the model program, through the same interface,
331
- and nothing upstream of it changes.
332
-
333
- ## The gate
334
-
335
- ```bash
336
- npm run gate
337
- ```
338
-
339
- Runs the frozen spec's Phase 1 acceptance list: one ledger row per call, decision
340
- ids resolving, remediation on all three weak conditions, a caller override
341
- dispatching exactly one model, the canaries for request text and keys, ledger
342
- durability under a mid-write kill, and `report` reconciling to the ledger.
343
- Eighteen checks. All of them must pass before anything here is committed.