prismalens 0.0.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 (64) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +5 -0
  3. package/README.md +312 -0
  4. package/dist/bin/prismalens.d.ts +3 -0
  5. package/dist/bin/prismalens.d.ts.map +1 -0
  6. package/dist/bin/prismalens.js +32 -0
  7. package/dist/bin/prismalens.js.map +1 -0
  8. package/dist/src/cli/doctor.d.ts +3 -0
  9. package/dist/src/cli/doctor.d.ts.map +1 -0
  10. package/dist/src/cli/doctor.js +156 -0
  11. package/dist/src/cli/doctor.js.map +1 -0
  12. package/dist/src/cli/init.d.ts +3 -0
  13. package/dist/src/cli/init.d.ts.map +1 -0
  14. package/dist/src/cli/init.js +85 -0
  15. package/dist/src/cli/init.js.map +1 -0
  16. package/dist/src/cli/investigate.d.ts +101 -0
  17. package/dist/src/cli/investigate.d.ts.map +1 -0
  18. package/dist/src/cli/investigate.js +452 -0
  19. package/dist/src/cli/investigate.js.map +1 -0
  20. package/dist/src/cli/serve.d.ts +3 -0
  21. package/dist/src/cli/serve.d.ts.map +1 -0
  22. package/dist/src/cli/serve.js +26 -0
  23. package/dist/src/cli/serve.js.map +1 -0
  24. package/dist/src/config/loader.d.ts +22 -0
  25. package/dist/src/config/loader.d.ts.map +1 -0
  26. package/dist/src/config/loader.js +155 -0
  27. package/dist/src/config/loader.js.map +1 -0
  28. package/dist/src/config/schema.d.ts +336 -0
  29. package/dist/src/config/schema.d.ts.map +1 -0
  30. package/dist/src/config/schema.js +160 -0
  31. package/dist/src/config/schema.js.map +1 -0
  32. package/dist/src/core/detect-repo.d.ts +4 -0
  33. package/dist/src/core/detect-repo.d.ts.map +1 -0
  34. package/dist/src/core/detect-repo.js +28 -0
  35. package/dist/src/core/detect-repo.js.map +1 -0
  36. package/dist/src/core/file-session-store.d.ts +10 -0
  37. package/dist/src/core/file-session-store.d.ts.map +1 -0
  38. package/dist/src/core/file-session-store.js +34 -0
  39. package/dist/src/core/file-session-store.js.map +1 -0
  40. package/dist/src/core/parse-stdin.d.ts +2 -0
  41. package/dist/src/core/parse-stdin.d.ts.map +1 -0
  42. package/dist/src/core/parse-stdin.js +30 -0
  43. package/dist/src/core/parse-stdin.js.map +1 -0
  44. package/dist/src/core/run-investigation.d.ts +42 -0
  45. package/dist/src/core/run-investigation.d.ts.map +1 -0
  46. package/dist/src/core/run-investigation.js +144 -0
  47. package/dist/src/core/run-investigation.js.map +1 -0
  48. package/dist/src/core/session.d.ts +42 -0
  49. package/dist/src/core/session.d.ts.map +1 -0
  50. package/dist/src/core/session.js +168 -0
  51. package/dist/src/core/session.js.map +1 -0
  52. package/dist/src/jsonrpc/server.d.ts +15 -0
  53. package/dist/src/jsonrpc/server.d.ts.map +1 -0
  54. package/dist/src/jsonrpc/server.js +244 -0
  55. package/dist/src/jsonrpc/server.js.map +1 -0
  56. package/dist/src/jsonrpc/types.d.ts +12 -0
  57. package/dist/src/jsonrpc/types.d.ts.map +1 -0
  58. package/dist/src/jsonrpc/types.js +4 -0
  59. package/dist/src/jsonrpc/types.js.map +1 -0
  60. package/dist/src/version.d.ts +8 -0
  61. package/dist/src/version.d.ts.map +1 -0
  62. package/dist/src/version.js +27 -0
  63. package/dist/src/version.js.map +1 -0
  64. package/package.json +61 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Sumit Patel
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,5 @@
1
+ PrismaLens
2
+ Copyright 2026 Sumit Patel
3
+
4
+ This product includes software developed as part of the PrismaLens project
5
+ (https://prismalens.io).
package/README.md ADDED
@@ -0,0 +1,312 @@
1
+ # prismalens
2
+
3
+ The PrismaLens **investigation engine CLI** — the `prismalens` (alias `pl`) binary,
4
+ published on npm as the unscoped [`prismalens`](https://www.npmjs.com/package/prismalens) package.
5
+
6
+ Per **ADR-0010**, the engine *is* a CLI: the desktop app and web API drive it
7
+ rather than embedding it. The CLI is a thin **Tier-1 supervisor** that rents a
8
+ **Tier-2 agent harness** (ADR-0008) to do the read-only legwork, then reduces the
9
+ harness's canonical event stream into an **ordered-evidence report** (ADR-0002 —
10
+ hypotheses ranked most-to-least plausible, with supporting/contradicting
11
+ evidence; no numeric confidence scores).
12
+
13
+ - **Tier-1 (supervisor):** seeds the investigation from a firing alert, drives the
14
+ rented harness live, and synthesizes the final report (the "reduce" step) using
15
+ an OpenAI-compatible model.
16
+ - **Tier-2 (rented harness):** one of
17
+ - `deepagents` — driven over **ACP**,
18
+ - `claude-code` — driven over the **Claude Agent SDK**,
19
+ - `codex` — **stubbed** (not implemented; selecting it throws).
20
+
21
+ The harness investigates **read-only**. Provider credentials are **BYO-key**
22
+ (ADR-0006) and come from the environment — never hard-bound in the CLI.
23
+
24
+ Every run is persisted to a durable workspace under `~/.prismalens/runs/<runId>/`
25
+ (`events.jsonl` + `report.json` + `session.json`), regardless of how it was
26
+ invoked.
27
+
28
+ ---
29
+
30
+ ## Install
31
+
32
+ Requires Node.js >= 22.
33
+
34
+ ```bash
35
+ # one-off, nothing installed globally
36
+ npx prismalens doctor
37
+
38
+ # or install the `prismalens` / `pl` bins globally
39
+ npm install -g prismalens
40
+ ```
41
+
42
+ ## Build from source
43
+
44
+ This package lives in the pnpm + turbo monorepo and is consumed by the rest of the
45
+ platform via `workspace:*`.
46
+
47
+ ```bash
48
+ # from the repo root
49
+ pnpm install
50
+
51
+ # build the CLI and its workspace deps (@prismalens/contracts, @prismalens/engine)
52
+ pnpm build # turbo build (whole monorepo)
53
+ # or just this package + its deps:
54
+ pnpm --filter prismalens... build
55
+ ```
56
+
57
+ The build emits `dist/`, exposing two bin entries (identical):
58
+
59
+ ```
60
+ prismalens -> dist/bin/prismalens.js
61
+ pl -> dist/bin/prismalens.js
62
+ ```
63
+
64
+ For local development you can skip the build and run the TypeScript entry directly:
65
+
66
+ ```bash
67
+ # from packages/cli
68
+ pnpm dev investigate --query "checkout latency spike" # tsx bin/prismalens.ts ...
69
+ ```
70
+
71
+ Run `prismalens doctor` before your first investigation to verify the harness
72
+ binary and an LLM credential are present.
73
+
74
+ ---
75
+
76
+ ## Commands
77
+
78
+ ```
79
+ prismalens <command> [flags] # alias: pl
80
+
81
+ investigate Run a read-only root-cause investigation of a firing alert.
82
+ serve Run the JSON-RPC 2.0 server over stdio (the LIVE channel for apps).
83
+ doctor Preflight-check the investigation environment.
84
+ init Scaffold a prismalens.config.yaml in the current directory.
85
+ ```
86
+
87
+ ### `investigate`
88
+
89
+ Seeds an investigation from a firing alert, rents a Tier-2 harness, streams the
90
+ supervisor live (each canonical event is appended to the run workspace and printed
91
+ as a one-line timeline entry), and renders the ordered-evidence report.
92
+
93
+ The seed alert comes from **one of**:
94
+ - a **`FiringAlert` JSON piped on stdin** (also accepts a webhook/Alertmanager-shaped
95
+ payload — `alertname`/`severity` are pulled from top-level fields, falling back to
96
+ `labels`), or
97
+ - `--query` — a one-line description that is synthesized into a minimal alert.
98
+
99
+ | Flag | Description |
100
+ | --- | --- |
101
+ | `--repo <dir>` | Path to the repository the harness investigates (its cwd). Defaults to the current directory. |
102
+ | `--query, -q <text>` | Synthesize an alert from this one-line description (alternative to piping a `FiringAlert` JSON on stdin). |
103
+ | `--config <path>` | Path to a `prismalens.config.yaml` (skips the upward config search). |
104
+ | `--model <id>` | Override `agent.model` — a bare model id, e.g. `gpt-oss:120b`. |
105
+ | `--harness <name>` | Tier-2 backend: `deepagents` \| `claude-code` \| `codex`. Defaults to `agent.default`. |
106
+ | `--json` | Print the `InvestigationReport` as JSON to stdout (suppresses the human renderer; implies quiet). |
107
+ | `--output <file>` | Also write the `InvestigationReport` JSON to this file. |
108
+ | `--quiet` | Suppress progress + the human renderer (errors still go to stderr). |
109
+
110
+ **Exit codes:** `0` on a synthesized report; `1` on a hard input error, a
111
+ mid-stream failure, or a **no-evidence** run (a branch that gathered nothing and
112
+ errored emits no report — the CLI surfaces the transport failure rather than a
113
+ fabricated RCA).
114
+
115
+ A `FiringAlert` is `{ alertname, severity, labels, annotations, startsAt }`.
116
+
117
+ ### `serve`
118
+
119
+ Runs the JSON-RPC 2.0 server over stdio — the live channel apps drive (see
120
+ [Driven by an app](#mode-2--driven-by-an-app-prismalens-serve)). No flags.
121
+
122
+ ### `doctor`
123
+
124
+ Preflight checklist that gates a run. Prints pass/fail per check; exits non-zero
125
+ **iff a hard check fails**.
126
+
127
+ - **HARD — harness binary on PATH:** `deepagents` → `deepagents-acp`,
128
+ `claude-code` → `claude`, `codex` → `codex` (for the harness from config).
129
+ - **HARD — an LLM credential:** any of `ANTHROPIC_API_KEY` / `OPENAI_API_KEY` /
130
+ `GOOGLE_API_KEY` / `OLLAMA_API_KEY` / `GROQ_API_KEY` / `CUSTOM_LLM_API_KEY`,
131
+ or, for `claude-code`, a signed-in `~/.claude/.credentials.json`.
132
+ - **SOFT — workspace writable:** `workspace.base_dir` can be created/written.
133
+
134
+ ### `init`
135
+
136
+ Scaffolds a commented `prismalens.config.yaml` in the current directory, sourced
137
+ from the schema defaults so it never drifts from what the engine uses.
138
+ Non-interactive: if the file already exists it is left untouched.
139
+
140
+ ---
141
+
142
+ ## Usage modes
143
+
144
+ ### Mode 1 — standalone
145
+
146
+ Run an investigation straight from the terminal. Inputs are resolved from the cwd
147
+ (or `--repo`), stdin/`--query`, and the merged config; the report is rendered to
148
+ the terminal and written to `~/.prismalens/runs/<runId>/`.
149
+
150
+ ```bash
151
+ # Synthesized alert from a one-liner, deepagents harness, investigating ./my-service
152
+ prismalens investigate \
153
+ --repo ./my-service \
154
+ --query "p99 checkout latency tripled after 14:00 UTC" \
155
+ --harness deepagents
156
+
157
+ # Pipe a real FiringAlert (or webhook/Alertmanager-shaped) payload on stdin
158
+ cat alert.json | prismalens investigate --repo ./my-service
159
+
160
+ # Machine-readable report (JSON to stdout) + a copy on disk, no progress chatter
161
+ prismalens investigate -q "OOMKilled in payments pod" --json --output report.json
162
+
163
+ # Pull the currently-firing alert from Alertmanager and investigate it
164
+ curl -s http://localhost:9093/api/v2/alerts?active=true \
165
+ | jq '.[0]' \
166
+ | prismalens investigate --repo ./payments --harness claude-code
167
+ ```
168
+
169
+ Durable record for every run:
170
+
171
+ ```
172
+ ~/.prismalens/
173
+ sessions.json # run index (runId -> SessionRecord)
174
+ runs/<runId>/session.json # per-run metadata mirror
175
+ runs/<runId>/events.jsonl # canonical event stream (one JSON per line)
176
+ runs/<runId>/report.json # the synthesized InvestigationReport
177
+ ```
178
+
179
+ ### Mode 2 — driven by an app (`prismalens serve`)
180
+
181
+ This is the **live channel** for the desktop app and web API — it replaces the old
182
+ `pl` file-watching reporter. The engine streams via `investigateIncidentStream`
183
+ (an async generator); `serve` forwards each canonical event as a notification.
184
+ Validated live against the sreforge `booklogr` incident with **both** harnesses
185
+ (`deepagents` over ACP, `claude-code` over the Agent SDK). The
186
+ `~/.prismalens/runs/<runId>/` workspace remains the durable record.
187
+
188
+ **Protocol:** JSON-RPC 2.0 over **stdio**, **newline-delimited** (one JSON value
189
+ per line in both directions — requests on stdin; responses + notifications on
190
+ stdout).
191
+
192
+ **`initialize`**
193
+
194
+ ```jsonc
195
+ --> {"jsonrpc":"2.0","id":1,"method":"initialize"}
196
+ <-- {"jsonrpc":"2.0","id":1,"result":{
197
+ "protocolVersion": 1,
198
+ "serverInfo": { "name": "prismalens", "version": "0.0.1" }
199
+ }}
200
+ ```
201
+
202
+ **`investigate`** — `params`: `{ alert?: FiringAlert, query?: string, repo?: string,
203
+ harness?: string, model?: string, config?: string }`.
204
+
205
+ Streams a **notification per canonical event** (including the terminal `report`
206
+ event), then **resolves the request** with `{ runId, report }`:
207
+
208
+ ```jsonc
209
+ --> {"jsonrpc":"2.0","id":2,"method":"investigate",
210
+ "params":{"query":"checkout latency spike","repo":"./my-service","harness":"deepagents"}}
211
+
212
+ // zero or more notifications, in order, as the supervisor streams:
213
+ <-- {"jsonrpc":"2.0","method":"investigate/event",
214
+ "params":{"runId":"<uuid>","event":{ /* CanonicalEvent */ }}}
215
+ // ... agent_step, tool_result, branch_done, (error), then the terminal report event ...
216
+
217
+ // finally, the request resolves:
218
+ <-- {"jsonrpc":"2.0","id":2,"result":{"runId":"<uuid>","report":{ /* InvestigationReport */ }}}
219
+ ```
220
+
221
+ `CanonicalEvent.kind` is one of `agent_step` | `tool_result` | `branch_done` |
222
+ `error` | `report`. Requests are fire-and-forget on the wire: multiple may run
223
+ concurrently and interleave their notifications — each notification carries its
224
+ `runId` so a driver can demultiplex.
225
+
226
+ **Error codes:**
227
+
228
+ | Code | Meaning |
229
+ | --- | --- |
230
+ | `-32700` | Parse error (invalid JSON on a line). |
231
+ | `-32600` | Invalid request (not a well-formed JSON-RPC 2.0 request). |
232
+ | `-32601` | Method not found. |
233
+ | `-32602` | Invalid params (includes `resolveInvestigation` input errors — e.g. no alert/query, unknown or unbuilt harness). |
234
+ | `-32603` | Internal error (mid-stream failure; `data` carries `{ runId }`). |
235
+ | `-32000` | No evidence — the harness branch failed and produced no report (`data` carries `{ runId }`). |
236
+
237
+ A malformed or failed request becomes a JSON-RPC error response — the server never
238
+ crashes on bad input.
239
+
240
+ ---
241
+
242
+ ## Configuration
243
+
244
+ `prismalens.config.yaml` (run `prismalens init` to scaffold one). Resolution order,
245
+ later overriding earlier:
246
+
247
+ 1. built-in schema defaults,
248
+ 2. user layer — `config.yaml` in the OS config dir (Linux/WSL:
249
+ `~/.config/prismalens/config.yaml`; macOS/Windows use the platform config dir),
250
+ a good home for BYO-key creds via `${VAR}` interpolation,
251
+ 3. project layer — the explicit `--config` path, else the nearest config file found
252
+ by walking **up** from the cwd,
253
+ 4. CLI flag overrides (e.g. `--model`).
254
+
255
+ `${VAR}` patterns in string values are interpolated from the environment (an unset
256
+ var is an error).
257
+
258
+ ```yaml
259
+ # Tier-2 harness backend the supervisor rents (ADR-0008).
260
+ agent:
261
+ default: deepagents # deepagents | claude-code | codex
262
+ # model: openai:gpt-oss:120b # provider-prefixed; omit to let the harness default
263
+ sandbox: auto # auto | process | srt — isolation boundary (ADR-0020).
264
+ # auto (default): srt (enforced OS boundary) WHEN its
265
+ # egress bridge is healthy (a self-check catches WSL
266
+ # mirrored-networking blackouts), else the cooperative
267
+ # process floor — the degrade is logged, never silent.
268
+
269
+ # Read-only telemetry + app endpoints the harness may query.
270
+ telemetry:
271
+ prometheusUrl: http://localhost:9090
272
+ alertmanagerUrl: http://localhost:9093
273
+ apiUrl: http://localhost:3000
274
+
275
+ # Where runs, events, and reports are stored.
276
+ workspace:
277
+ base_dir: ~/.prismalens
278
+
279
+ # Per-harness native passthrough (ADR-0017) — untyped, forwarded straight to the
280
+ # rented harness. For `deepagents` (the npm `deepagents-acp` binary, driven over
281
+ # ACP), `args` is appended verbatim to the CLI invocation. The binary has no
282
+ # shell-allowlist or sandbox flags — read-only is cooperative until the Sandbox
283
+ # port's enforced providers land (ADR-0020/B.1).
284
+ harnesses:
285
+ deepagents:
286
+ native:
287
+ args: [--memory, ./AGENTS.md]
288
+ ```
289
+
290
+ Notes:
291
+ - `agent.model` in config is a **provider-prefixed** id (e.g. `openai:gpt-oss:120b`).
292
+ The `--model` flag passes a **bare** id (e.g. `gpt-oss:120b`); for `deepagents` the
293
+ CLI prefixes it with `openai:`.
294
+ - `telemetry.*` defaults to host-local URLs when unset.
295
+ - There is currently no `agent.timeout_ms`, `budget.*`, or `logging.*` config —
296
+ an overall per-run wall-clock budget and a Tier-1 reduce token/retry budget are
297
+ planned alongside the Phase B.1 Sandbox port's resource limits (ADR-0020), not
298
+ wired yet.
299
+
300
+ ### BYO-key environment (ADR-0006)
301
+
302
+ Credentials are read from the environment, never stored by the CLI.
303
+
304
+ - **Tier-1 reduce + the `deepagents` harness** use an OpenAI-compatible endpoint:
305
+ - `OLLAMA_API_KEY` or `OPENAI_API_KEY` (the API key),
306
+ - `OLLAMA_BASE_URL` or `OPENAI_BASE_URL` (base URL; defaults to
307
+ `https://ollama.com/v1`).
308
+ - **The `claude-code` harness** uses your signed-in `~/.claude` session, or
309
+ `ANTHROPIC_API_KEY`.
310
+
311
+ If no `OLLAMA_API_KEY` / `OPENAI_API_KEY` is set, the reduce (synthesis) call will
312
+ likely fail — `investigate` warns up front, and `doctor` checks for a credential.
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=prismalens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prismalens.d.ts","sourceRoot":"","sources":["../../bin/prismalens.ts"],"names":[],"mappings":""}
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env node
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ // Copyright 2026 Sumit Patel
4
+ /**
5
+ * `prismalens` / `pl` — the engine CLI (ADR-0010: the engine is a CLI; the desktop
6
+ * app + API drive it). Command bodies live in ../src/cli/* and are loaded lazily so
7
+ * a fast `--help` doesn't pull in the engine. Bodies are implemented separately.
8
+ */
9
+ import { defineCommand, runMain } from "citty";
10
+ import { cliVersion } from "../src/version.js";
11
+ // The AI SDK's one-time "AI SDK Warning System" banner prints via console.info
12
+ // (STDOUT) mid-run — noise in the live timeline and corruption in piped JSON.
13
+ // Off for the whole CLI; real per-warning notices still reach stderr via
14
+ // process.emitWarning.
15
+ globalThis.AI_SDK_LOG_WARNINGS = false;
16
+ /** Lazily import a command body's default export from src/cli. */
17
+ const lazy = (name) => () => import(`../src/cli/${name}.js`).then((m) => m.default);
18
+ const main = defineCommand({
19
+ meta: {
20
+ name: "prismalens",
21
+ version: cliVersion(),
22
+ description: "PrismaLens investigation engine CLI — drives the two-tier engine (ADR-0008/0010).",
23
+ },
24
+ subCommands: {
25
+ investigate: lazy("investigate"),
26
+ serve: lazy("serve"),
27
+ doctor: lazy("doctor"),
28
+ init: lazy("init"),
29
+ },
30
+ });
31
+ runMain(main);
32
+ //# sourceMappingURL=prismalens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prismalens.js","sourceRoot":"","sources":["../../bin/prismalens.ts"],"names":[],"mappings":";AACA,sCAAsC;AACtC,6BAA6B;AAE7B;;;;GAIG;AACH,OAAO,EAAmB,aAAa,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,+EAA+E;AAC/E,8EAA8E;AAC9E,yEAAyE;AACzE,uBAAuB;AACtB,UAAgD,CAAC,mBAAmB,GAAG,KAAK,CAAC;AAE9E,kEAAkE;AAClE,MAAM,IAAI,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,GAAwB,EAAE,CACxD,MAAM,CAAC,cAAc,IAAI,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAqB,CAAC,CAAC;AAEtE,MAAM,IAAI,GAAG,aAAa,CAAC;IAC1B,IAAI,EAAE;QACL,IAAI,EAAE,YAAY;QAClB,OAAO,EAAE,UAAU,EAAE;QACrB,WAAW,EACV,mFAAmF;KACpF;IACD,WAAW,EAAE;QACZ,WAAW,EAAE,IAAI,CAAC,aAAa,CAAC;QAChC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC;QACpB,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC;QACtB,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;KAClB;CACD,CAAC,CAAC;AAEH,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ declare const _default: import("citty").CommandDef<import("citty").ArgsDef>;
2
+ export default _default;
3
+ //# sourceMappingURL=doctor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../../src/cli/doctor.ts"],"names":[],"mappings":";AAoIA,wBA8CG"}