@illuminis/comprism 0.1.2 → 0.1.4

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 (131) hide show
  1. package/README.md +98 -36
  2. package/out/agent/command.d.ts +75 -4
  3. package/out/agent/command.js +220 -25
  4. package/out/agent/render.d.ts +17 -2
  5. package/out/agent/render.js +157 -14
  6. package/out/agent/session.d.ts +141 -2
  7. package/out/agent/session.js +735 -149
  8. package/out/commands/agents.d.ts +2 -0
  9. package/out/commands/agents.js +79 -0
  10. package/out/commands/ask.d.ts +1 -1
  11. package/out/commands/ask.js +78 -11
  12. package/out/commands/commands-thin.js +79 -17
  13. package/out/commands/config.d.ts +1 -0
  14. package/out/commands/config.js +138 -0
  15. package/out/commands/cost.d.ts +1 -0
  16. package/out/commands/cost.js +167 -0
  17. package/out/commands/hooks.d.ts +1 -0
  18. package/out/commands/hooks.js +83 -0
  19. package/out/commands/install.d.ts +44 -1
  20. package/out/commands/install.js +198 -4
  21. package/out/commands/instructions.d.ts +1 -0
  22. package/out/commands/instructions.js +113 -0
  23. package/out/commands/integrations.d.ts +3 -0
  24. package/out/commands/integrations.js +215 -0
  25. package/out/commands/jobs.d.ts +5 -0
  26. package/out/commands/jobs.js +157 -0
  27. package/out/commands/login.js +188 -36
  28. package/out/commands/memory.d.ts +3 -0
  29. package/out/commands/memory.js +113 -0
  30. package/out/commands/permissions.d.ts +1 -0
  31. package/out/commands/permissions.js +94 -0
  32. package/out/commands/plugins.d.ts +4 -0
  33. package/out/commands/plugins.js +192 -0
  34. package/out/commands/privacy.d.ts +1 -0
  35. package/out/commands/privacy.js +57 -0
  36. package/out/commands/providerKey.d.ts +32 -0
  37. package/out/commands/providerKey.js +108 -0
  38. package/out/commands/repl.d.ts +8 -1
  39. package/out/commands/repl.js +1207 -118
  40. package/out/commands/report.d.ts +39 -0
  41. package/out/commands/report.js +115 -0
  42. package/out/commands/review.d.ts +5 -0
  43. package/out/commands/review.js +223 -0
  44. package/out/commands/sessions.d.ts +23 -0
  45. package/out/commands/sessions.js +115 -0
  46. package/out/commands/settings.d.ts +3 -1
  47. package/out/commands/settings.js +18 -16
  48. package/out/commands/skills.d.ts +21 -0
  49. package/out/commands/skills.js +207 -0
  50. package/out/commands/unattended.d.ts +7 -0
  51. package/out/commands/unattended.js +351 -0
  52. package/out/commands/update.d.ts +1 -0
  53. package/out/commands/update.js +123 -0
  54. package/out/commands/worktrees.d.ts +5 -0
  55. package/out/commands/worktrees.js +186 -0
  56. package/out/executor/browser.d.ts +14 -0
  57. package/out/executor/browser.js +270 -0
  58. package/out/executor/diagnostics.d.ts +2 -0
  59. package/out/executor/diagnostics.js +181 -0
  60. package/out/executor/files.js +270 -40
  61. package/out/executor/git.js +42 -29
  62. package/out/executor/hooks.d.ts +42 -58
  63. package/out/executor/hooks.js +89 -182
  64. package/out/executor/index.d.ts +21 -5
  65. package/out/executor/index.js +160 -14
  66. package/out/executor/paths.d.ts +6 -1
  67. package/out/executor/paths.js +34 -6
  68. package/out/executor/sandbox.d.ts +40 -0
  69. package/out/executor/sandbox.js +299 -0
  70. package/out/executor/shell.d.ts +49 -4
  71. package/out/executor/shell.js +302 -56
  72. package/out/executor/toolservers.d.ts +20 -0
  73. package/out/executor/toolservers.js +189 -0
  74. package/out/executor/worktree.d.ts +9 -0
  75. package/out/executor/worktree.js +119 -0
  76. package/out/graph/read-python.js +2 -1
  77. package/out/lib/attach.d.ts +56 -12
  78. package/out/lib/attach.js +230 -63
  79. package/out/lib/clipboard.d.ts +23 -0
  80. package/out/lib/clipboard.js +182 -0
  81. package/out/lib/commandlist.d.ts +20 -0
  82. package/out/lib/commandlist.js +58 -0
  83. package/out/lib/decision.d.ts +22 -0
  84. package/out/lib/decision.js +50 -0
  85. package/out/lib/fingerprint.d.ts +25 -0
  86. package/out/lib/fingerprint.js +58 -0
  87. package/out/lib/gateway.d.ts +186 -2
  88. package/out/lib/gateway.js +59 -4
  89. package/out/lib/history.d.ts +24 -0
  90. package/out/lib/history.js +137 -0
  91. package/out/lib/ide.d.ts +19 -0
  92. package/out/lib/ide.js +131 -0
  93. package/out/lib/keyboard.d.ts +95 -0
  94. package/out/lib/keyboard.js +383 -0
  95. package/out/lib/machine.d.ts +21 -0
  96. package/out/lib/machine.js +91 -0
  97. package/out/lib/notify.d.ts +4 -0
  98. package/out/lib/notify.js +52 -0
  99. package/out/lib/output.d.ts +48 -0
  100. package/out/lib/output.js +108 -0
  101. package/out/lib/project-ops.d.ts +19 -0
  102. package/out/lib/project-ops.js +146 -0
  103. package/out/lib/project.d.ts +28 -0
  104. package/out/lib/project.js +114 -0
  105. package/out/lib/prompt.js +15 -2
  106. package/out/lib/queue.d.ts +13 -0
  107. package/out/lib/queue.js +116 -0
  108. package/out/lib/readiness.d.ts +19 -0
  109. package/out/lib/readiness.js +170 -1
  110. package/out/lib/self.d.ts +23 -0
  111. package/out/lib/self.js +124 -0
  112. package/out/lib/sessions.d.ts +19 -0
  113. package/out/lib/sessions.js +221 -0
  114. package/out/lib/stdin.d.ts +32 -0
  115. package/out/lib/stdin.js +117 -0
  116. package/out/lib/store.d.ts +40 -0
  117. package/out/lib/store.js +138 -0
  118. package/out/lib/sync.d.ts +18 -0
  119. package/out/lib/sync.js +81 -0
  120. package/out/lib/ui.d.ts +2 -4
  121. package/out/lib/ui.js +31 -25
  122. package/out/lib/voice.js +24 -0
  123. package/out/postinstall.js +42 -14
  124. package/out/providers/anthropic.d.ts +22 -0
  125. package/out/providers/anthropic.js +80 -0
  126. package/out/providers/index.d.ts +8 -0
  127. package/out/providers/index.js +83 -0
  128. package/out/providers/openai.d.ts +11 -0
  129. package/out/providers/openai.js +57 -0
  130. package/out/thin.js +609 -21
  131. package/package.json +9 -49
package/README.md CHANGED
@@ -4,26 +4,91 @@ The half of CompletionPrism that runs on your machine. It sits between the tool
4
4
  you already use and the AI provider, records what finishing your work actually
5
5
  cost, and changes nothing about what your tool does.
6
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
+
7
26
  ```bash
8
- npm install && npm run build
27
+ comprism login
28
+ ```
9
29
 
10
- export ANTHROPIC_API_KEY=... # or OPENAI_API_KEY
11
- node out/cli.js setup
12
- node out/cli.js session
13
- node out/cli.js report
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
14
48
  ```
15
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
+
16
84
  ## The coding agent
17
85
 
18
- `comprism agent` is a coding agent in your terminal. It reads your project,
19
- changes files, runs commands, runs your tests, and shows you every change before
20
- it makes it.
86
+ `comprism work` reads your project, changes files, runs commands, runs your
87
+ tests, and shows you every change before it makes it.
21
88
 
22
89
  ```bash
23
- npm install -g @illuminis/comprism
24
- comprism login # once, per machine
25
90
  cd ~/your-project
26
- comprism agent "the tests are failing, work out why and fix it"
91
+ comprism work "the tests are failing, work out why and fix it"
27
92
  ```
28
93
 
29
94
  **What makes it different from the others.** Every step is routed to whichever
@@ -63,7 +128,7 @@ production. Those are yours to do.
63
128
  ### Before you let it change anything
64
129
 
65
130
  ```bash
66
- comprism agent --plan "rename the parser module and update every caller"
131
+ comprism work --plan "rename the parser module and update every caller"
67
132
  ```
68
133
 
69
134
  It reads what it needs, tells you what it would do, and changes nothing. The
@@ -85,7 +150,7 @@ ran a command, the undo says so plainly rather than claiming to have reversed it
85
150
  ### Carrying on tomorrow
86
151
 
87
152
  ```bash
88
- comprism agent --resume <job-id> "also add a test for the empty case"
153
+ comprism work --resume <job-id> "also add a test for the empty case"
89
154
  ```
90
155
 
91
156
  It continues the conversation rather than starting a new one, so it already knows
@@ -94,7 +159,7 @@ what it read and decided.
94
159
  ### In a script, or in continuous integration
95
160
 
96
161
  ```bash
97
- comprism agent --yes --mode auto_edit "run the linter and fix what it reports"
162
+ comprism work --yes --mode auto_edit "run the linter and fix what it reports"
98
163
  echo $? # 0 if it finished, non-zero if it did not
99
164
  ```
100
165
 
@@ -108,8 +173,8 @@ By default, whichever finishes each step for least. Pin one when you want to
108
173
  decide yourself:
109
174
 
110
175
  ```bash
111
- comprism agent --model gpt-5 "..." # or any model your account can reach
112
- comprism agent --max-spend 2.00 "..." # stop here rather than running on
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
113
178
  ```
114
179
 
115
180
  Four providers are wired: Anthropic, OpenAI, Google and xAI. Which ones you can
@@ -117,19 +182,20 @@ reach depends on the keys on your account.
117
182
 
118
183
  ### Requirements
119
184
 
120
- Node 22 or newer, and a workspace you have signed in to with `comprism login`.
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.
121
187
 
122
188
  ---
123
189
 
124
190
  ## Instrument a tool you already use
125
191
 
126
- ```bash
127
- node out/cli.js proxy
128
- export ANTHROPIC_BASE_URL=http://127.0.0.1:8787
129
- ```
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.
130
195
 
131
196
  Requests are forwarded to the provider byte for byte. Your key is forwarded,
132
- never read or stored. Unset the variable and we are gone, with nothing to undo.
197
+ never read or stored. `comprism uninstall` takes the line back out and every
198
+ tool goes straight to its provider again.
133
199
 
134
200
  ## Whose Anthropic account pays
135
201
 
@@ -138,7 +204,7 @@ surface can carry a credential.
138
204
 
139
205
  | How you work | Where the key comes from | Stored anywhere? |
140
206
  |---|---|---|
141
- | `comprism session`, `comprism proxy`, or an IDE pointed at your workspace | this machine, per request | no |
207
+ | `comprism`, the interception the install configured, or an IDE pointed at your workspace | this machine, per request | no |
142
208
  | The developer API and the SDKs | the `X-Anthropic-Key` header, per request | no |
143
209
  | Claude Desktop and claude.ai | your workspace's own stored key | yes, encrypted, and only this one |
144
210
 
@@ -148,16 +214,14 @@ answering those prompts at all means the workspace holding a key. A workspace
148
214
  that holds none gets its connector answers refused - never billed to illuminis.
149
215
 
150
216
  ```bash
151
- node out/cli.js key # whose account pays, here and in your workspace
152
- node out/cli.js key push # send this machine's key, for the connector surface
153
- node out/cli.js key clear # take it back out
217
+ comprism keys # whose account pays, here and in your workspace
154
218
  ```
155
219
 
156
- `push` is the one command that deliberately sends a provider key anywhere. It
157
- sends the key this machine already resolves, over TLS, to the workspace you are
158
- signed in to; Anthropic validates it before it is stored; nothing is written to
159
- disk here either way. An administrator can do the same in the app, under Policy
160
- and Data Controls.
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.
161
225
 
162
226
  ## The stats footer
163
227
 
@@ -192,11 +256,9 @@ failure is logged rather than shown. Nothing is added at all when the turn ends
192
256
  in a tool call, a refusal, a truncation, an error event, an empty response, or a
193
257
  model with no published price.
194
258
 
195
- ```bash
196
- node out/cli.js footer # what it is doing now
197
- node out/cli.js footer off # byte-faithful in both directions
198
- node out/cli.js footer on
199
- ```
259
+ Switch it off with `"enabled": false` under `footer` in
260
+ `~/.comprism/config.json`, which makes the proxy byte faithful in both
261
+ directions.
200
262
 
201
263
  ### Configuring pricing, the baseline and the template
202
264
 
@@ -1,6 +1,21 @@
1
1
  import { type JobResult } from "./session";
2
+ import { type OutputChoice } from "../lib/output";
2
3
  export interface AgentArgs {
3
4
  request: string[];
5
+ /** Inside a session: background processes outlive this job and are stopped
6
+ * when the session ends (manual 5.13). */
7
+ keepProcesses?: boolean;
8
+ /** Seconds each command may run before it is stopped (manual 5.12). */
9
+ timeout?: number;
10
+ /** Start from this GitHub issue (manual 5.20). */
11
+ issue?: number;
12
+ /** Lead the team defined under this name (manual 5.27). */
13
+ team?: string;
14
+ /** A review, not a request: the instruction is the service's (manual 5.19). */
15
+ review?: {
16
+ pr?: number;
17
+ post?: boolean;
18
+ };
4
19
  /** Start it and hand the terminal back. See `runDetached` for what this can
5
20
  * and cannot do. */
6
21
  background?: boolean;
@@ -14,6 +29,14 @@ export interface AgentArgs {
14
29
  /** Run `model` and nothing else, whatever the router would prefer. */
15
30
  pin?: boolean;
16
31
  maxSpend?: number;
32
+ /** Stop after this many steps (manual 4.13). */
33
+ maxSteps?: number;
34
+ /** No new step after this many minutes (manual 10.7). */
35
+ maxMinutes?: number;
36
+ /** Reasoning effort: low, medium or high (manual 4.18). */
37
+ effort?: string;
38
+ /** Run commands in the operating system's sandbox (manual 4.12). */
39
+ sandbox?: boolean;
17
40
  /** `--allow "python3 grade.py"`, repeatable. Exact commands, pre approved. */
18
41
  allow?: string[];
19
42
  yes?: boolean;
@@ -31,7 +54,13 @@ export interface AgentArgs {
31
54
  * already said. Not the same as `resume`, which re-enters a job that stopped
32
55
  * part way; this is the ordinary next question in a conversation. */
33
56
  continuesJob?: string;
57
+ /** Which conversation this job belongs to, so the server files it under the
58
+ * session the person is actually in rather than under their whole day. */
59
+ conversationId?: string;
34
60
  cwd?: string;
61
+ /** Other folders the person named with `--add-folder` or `folders add`
62
+ * (manual 2.3). Nothing else ever becomes an allowed folder. */
63
+ addFolders?: string[];
35
64
  /**
36
65
  * Ask the person a yes or no question.
37
66
  *
@@ -44,6 +73,9 @@ export interface AgentArgs {
44
73
  * what the standalone command wants.
45
74
  */
46
75
  confirm?: (question: string) => Promise<boolean>;
76
+ /** A line of text from the same lent keyboard, for the plan question and the
77
+ * agent's questions. Null means Ctrl+C. */
78
+ prompt?: (question: string) => Promise<string | null>;
47
79
  /**
48
80
  * Files already uploaded, to be put in front of this question.
49
81
  *
@@ -52,6 +84,12 @@ export interface AgentArgs {
52
84
  * here would be sending them twice and storing them nowhere useful.
53
85
  */
54
86
  attachments?: string[];
87
+ /** Names of files the person named that could not be attached, so the
88
+ * agent is told rather than left to guess (manual 3.10). */
89
+ leftOut?: string[];
90
+ /** The terminal to ask approval questions at when standard input is a
91
+ * pipe (manual 3.9). Never the pipe itself. */
92
+ keyboard?: NodeJS.ReadableStream | null;
55
93
  /**
56
94
  * Handed a way to stop the job, as soon as there is one to stop.
57
95
  *
@@ -65,10 +103,21 @@ export interface AgentArgs {
65
103
  * to it while it runs. A caller that owns the keyboard needs both, because
66
104
  * a person watching a job go the wrong way at step three should be able to
67
105
  * correct it rather than stop it and start again. */
68
- onStarted?: (controls: {
69
- cancel: () => void;
70
- steer: (text: string) => void;
71
- }) => void;
106
+ onStarted?: (controls: JobControls) => void;
107
+ /** `--output` and `--quiet`, and whether standard output is a terminal
108
+ * (manual 10.2, 10.3). Absent inside a session, which always draws. */
109
+ output?: OutputChoice;
110
+ /** `--schema`: the answer must be JSON of this shape (manual 10.5). */
111
+ answerSchema?: Record<string, unknown>;
112
+ /** A queued job this runner claimed (10.17 to 10.19); the service holds
113
+ * its request, mode and limits. */
114
+ queuedJob?: string;
115
+ /** `--config`: settings read as if they were the project file (10.8). */
116
+ settingsConfig?: Record<string, unknown>;
117
+ /** `--no-personal`: leave out personal settings and instructions (10.8). */
118
+ noPersonal?: boolean;
119
+ /** Start in the full view (manual 6.9), because Ctrl+O was pressed earlier. */
120
+ fullView?: boolean;
72
121
  /**
73
122
  * Told what the job cost, once it has finished.
74
123
  *
@@ -81,6 +130,28 @@ export interface AgentArgs {
81
130
  */
82
131
  onFinished?: (result: JobResult) => void;
83
132
  }
133
+ export declare const MODES: string[];
134
+ /** What a caller holding the keyboard can do to a running job (manual 6.7 to
135
+ * 6.9). Every one of them is a message to the service, which decides. */
136
+ export interface JobControls {
137
+ cancel: () => void;
138
+ steer: (text: string) => void;
139
+ pause: () => void;
140
+ carryOn: (text: string) => void;
141
+ isPaused: () => boolean;
142
+ queue: (clear: boolean) => void;
143
+ setFull: (on: boolean) => void;
144
+ /** Helpers running now, as the service reported them (manual 5.25). */
145
+ helpers: () => Array<{
146
+ id: string;
147
+ question: string;
148
+ agent?: string | null;
149
+ }>;
150
+ /** `stop h2`: the service stops that helper, the rest carry on. */
151
+ stopHelper: (id: string) => void;
152
+ /** The job's id, once the service has issued it. */
153
+ jobId: () => string | undefined;
154
+ }
84
155
  export declare function runAgent(args: AgentArgs): Promise<number>;
85
156
  /** The help text. Written to be read by somebody who has not read anything else. */
86
157
  export declare const AGENT_HELP: string;