prismalens 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/README.md +29 -13
  2. package/dist/bin/prismalens.js +39 -50
  3. package/dist/chunk-2Z7QZSIS.js +20 -0
  4. package/dist/chunk-5BT3XQOG.js +2990 -0
  5. package/dist/chunk-6N4PHBII.js +30 -0
  6. package/dist/chunk-CTKCK7QT.js +387 -0
  7. package/dist/chunk-CVSS5JPC.js +130 -0
  8. package/dist/chunk-HPE5CTO4.js +22 -0
  9. package/dist/chunk-PTBCAI34.js +34 -0
  10. package/dist/chunk-PVQVFRIV.js +452 -0
  11. package/dist/chunk-QDK5PAI3.js +155 -0
  12. package/dist/chunk-SSEIMBQ2.js +204 -0
  13. package/dist/chunk-TGP6QTFO.js +156 -0
  14. package/dist/chunk-V6M6ISKI.js +161 -0
  15. package/dist/chunk-XH6DIKTA.js +83 -0
  16. package/dist/src/cli/auth.js +112 -101
  17. package/dist/src/cli/doctor.js +184 -187
  18. package/dist/src/cli/flags.js +6 -29
  19. package/dist/src/cli/grouping.js +16 -227
  20. package/dist/src/cli/init.js +58 -52
  21. package/dist/src/cli/investigate.js +23 -465
  22. package/dist/src/cli/listen.js +550 -286
  23. package/dist/src/cli/report.js +70 -67
  24. package/dist/src/cli/serve.js +260 -30
  25. package/dist/src/cli/status.js +87 -86
  26. package/package.json +16 -7
  27. package/dist/bin/prismalens.d.ts +0 -3
  28. package/dist/bin/prismalens.d.ts.map +0 -1
  29. package/dist/bin/prismalens.js.map +0 -1
  30. package/dist/src/cli/auth.d.ts +0 -3
  31. package/dist/src/cli/auth.d.ts.map +0 -1
  32. package/dist/src/cli/auth.js.map +0 -1
  33. package/dist/src/cli/doctor.d.ts +0 -18
  34. package/dist/src/cli/doctor.d.ts.map +0 -1
  35. package/dist/src/cli/doctor.js.map +0 -1
  36. package/dist/src/cli/flags.d.ts +0 -2
  37. package/dist/src/cli/flags.d.ts.map +0 -1
  38. package/dist/src/cli/flags.js.map +0 -1
  39. package/dist/src/cli/grouping.d.ts +0 -18
  40. package/dist/src/cli/grouping.d.ts.map +0 -1
  41. package/dist/src/cli/grouping.js.map +0 -1
  42. package/dist/src/cli/init.d.ts +0 -3
  43. package/dist/src/cli/init.d.ts.map +0 -1
  44. package/dist/src/cli/init.js.map +0 -1
  45. package/dist/src/cli/investigate.d.ts +0 -115
  46. package/dist/src/cli/investigate.d.ts.map +0 -1
  47. package/dist/src/cli/investigate.js.map +0 -1
  48. package/dist/src/cli/listen.d.ts +0 -56
  49. package/dist/src/cli/listen.d.ts.map +0 -1
  50. package/dist/src/cli/listen.js.map +0 -1
  51. package/dist/src/cli/report.d.ts +0 -24
  52. package/dist/src/cli/report.d.ts.map +0 -1
  53. package/dist/src/cli/report.js.map +0 -1
  54. package/dist/src/cli/serve.d.ts +0 -3
  55. package/dist/src/cli/serve.d.ts.map +0 -1
  56. package/dist/src/cli/serve.js.map +0 -1
  57. package/dist/src/cli/status.d.ts +0 -19
  58. package/dist/src/cli/status.d.ts.map +0 -1
  59. package/dist/src/cli/status.js.map +0 -1
  60. package/dist/src/config/loader.d.ts +0 -22
  61. package/dist/src/config/loader.d.ts.map +0 -1
  62. package/dist/src/config/loader.js +0 -193
  63. package/dist/src/config/loader.js.map +0 -1
  64. package/dist/src/config/schema.d.ts +0 -463
  65. package/dist/src/config/schema.d.ts.map +0 -1
  66. package/dist/src/config/schema.js +0 -217
  67. package/dist/src/config/schema.js.map +0 -1
  68. package/dist/src/core/caps.d.ts +0 -36
  69. package/dist/src/core/caps.d.ts.map +0 -1
  70. package/dist/src/core/caps.js +0 -36
  71. package/dist/src/core/caps.js.map +0 -1
  72. package/dist/src/core/db.d.ts +0 -3
  73. package/dist/src/core/db.d.ts.map +0 -1
  74. package/dist/src/core/db.js +0 -105
  75. package/dist/src/core/db.js.map +0 -1
  76. package/dist/src/core/detect-repo.d.ts +0 -4
  77. package/dist/src/core/detect-repo.d.ts.map +0 -1
  78. package/dist/src/core/detect-repo.js +0 -28
  79. package/dist/src/core/detect-repo.js.map +0 -1
  80. package/dist/src/core/file-session-store.d.ts +0 -10
  81. package/dist/src/core/file-session-store.d.ts.map +0 -1
  82. package/dist/src/core/file-session-store.js +0 -34
  83. package/dist/src/core/file-session-store.js.map +0 -1
  84. package/dist/src/core/parse-stdin.d.ts +0 -2
  85. package/dist/src/core/parse-stdin.d.ts.map +0 -1
  86. package/dist/src/core/parse-stdin.js +0 -21
  87. package/dist/src/core/parse-stdin.js.map +0 -1
  88. package/dist/src/core/run-investigation.d.ts +0 -54
  89. package/dist/src/core/run-investigation.d.ts.map +0 -1
  90. package/dist/src/core/run-investigation.js +0 -200
  91. package/dist/src/core/run-investigation.js.map +0 -1
  92. package/dist/src/core/session.d.ts +0 -63
  93. package/dist/src/core/session.d.ts.map +0 -1
  94. package/dist/src/core/session.js +0 -45
  95. package/dist/src/core/session.js.map +0 -1
  96. package/dist/src/core/slack-notify.d.ts +0 -9
  97. package/dist/src/core/slack-notify.d.ts.map +0 -1
  98. package/dist/src/core/slack-notify.js +0 -57
  99. package/dist/src/core/slack-notify.js.map +0 -1
  100. package/dist/src/core/sqlite-session-store.d.ts +0 -39
  101. package/dist/src/core/sqlite-session-store.d.ts.map +0 -1
  102. package/dist/src/core/sqlite-session-store.js +0 -239
  103. package/dist/src/core/sqlite-session-store.js.map +0 -1
  104. package/dist/src/http/server.d.ts +0 -31
  105. package/dist/src/http/server.d.ts.map +0 -1
  106. package/dist/src/http/server.js +0 -164
  107. package/dist/src/http/server.js.map +0 -1
  108. package/dist/src/jsonrpc/server.d.ts +0 -15
  109. package/dist/src/jsonrpc/server.d.ts.map +0 -1
  110. package/dist/src/jsonrpc/server.js +0 -244
  111. package/dist/src/jsonrpc/server.js.map +0 -1
  112. package/dist/src/jsonrpc/types.d.ts +0 -12
  113. package/dist/src/jsonrpc/types.d.ts.map +0 -1
  114. package/dist/src/jsonrpc/types.js +0 -4
  115. package/dist/src/jsonrpc/types.js.map +0 -1
  116. package/dist/src/version.d.ts +0 -8
  117. package/dist/src/version.d.ts.map +0 -1
  118. package/dist/src/version.js +0 -27
  119. package/dist/src/version.js.map +0 -1
package/README.md CHANGED
@@ -162,7 +162,7 @@ Preflight checklist that gates a run. Prints pass/fail per check; exits non-zero
162
162
  a signed-in `~/.claude/.credentials.json`. Doctor reports which layer supplied
163
163
  the credential (`source: env | file | stored | none`). (Performs a live
164
164
  provider model ping by default, while `--no-ping` skips it.)
165
- - **SOFT — workspace writable:** `workspace.base_dir` can be created/written.
165
+ - **SOFT — workspace writable:** `workspace.dir` can be created/written.
166
166
 
167
167
  ### `init`
168
168
 
@@ -233,7 +233,19 @@ stdout).
233
233
  ```
234
234
 
235
235
  **`investigate`** — `params`: `{ alert?: FiringAlert, query?: string, repo?: string,
236
- harness?: string, model?: string, config?: string }`.
236
+ harness?: string, model?: string, config?: string, service?: string, mode?: string,
237
+ dangerouslySkipPermissions?: boolean, sandbox?: string, maxTurns?: number }`.
238
+
239
+ CLI-parity params (each falls back to config when absent):
240
+
241
+ - `sandbox` — the isolation boundary (ADR-0020), the CLI's `--sandbox`: one of
242
+ `auto` | `process` | `srt` | `e2b`. Absent ⇒ `agent.sandbox` from config. A
243
+ supplied value that is not a known mode (or a mode the resolved harness cannot
244
+ honour, e.g. `srt` on a non-ACP harness) is a `-32602` error — never a silent
245
+ fall-back to the cooperative floor.
246
+ - `maxTurns` — per-run turn ceiling, the CLI's `--max-turns`: a positive integer.
247
+ A supplied zero, negative, fractional, or non-numeric value is a `-32602` error —
248
+ never a silently-removed cap.
237
249
 
238
250
  Streams a **notification per canonical event** (including the terminal `report`
239
251
  event), then **resolves the request** with `{ runId, report }`:
@@ -263,7 +275,7 @@ concurrently and interleave their notifications — each notification carries it
263
275
  | `-32700` | Parse error (invalid JSON on a line). |
264
276
  | `-32600` | Invalid request (not a well-formed JSON-RPC 2.0 request). |
265
277
  | `-32601` | Method not found. |
266
- | `-32602` | Invalid params (includes `resolveInvestigation` input errors — e.g. no alert/query, unknown or unbuilt harness). |
278
+ | `-32602` | Invalid params (includes an invalid `sandbox` mode or `maxTurns` value, and `resolveInvestigation` input errors — e.g. no alert/query, unknown or unbuilt harness). |
267
279
  | `-32603` | Internal error (mid-stream failure; `data` carries `{ runId }`). |
268
280
  | `-32000` | No evidence — the harness branch failed and produced no report (`data` carries `{ runId }`). |
269
281
 
@@ -292,7 +304,8 @@ var is an error).
292
304
  # Tier-2 harness backend the supervisor rents (ADR-0008).
293
305
  agent:
294
306
  default: deepagents # deepagents | claude-code | codex
295
- # model: openai:gpt-oss:120b # provider-prefixed; omit to let the harness default
307
+ # model: gpt-oss:120b # bare id — the harness applies its own provider
308
+ # prefix; omit to let the harness default
296
309
  sandbox: auto # auto | process | srt — isolation boundary (ADR-0020).
297
310
  # auto (default): srt (enforced OS boundary) WHEN its
298
311
  # egress bridge is healthy (a self-check catches WSL
@@ -301,13 +314,13 @@ agent:
301
314
 
302
315
  # Read-only telemetry + app endpoints the harness may query.
303
316
  telemetry:
304
- prometheusUrl: http://localhost:9090
305
- alertmanagerUrl: http://localhost:9093
306
- apiUrl: http://localhost:3000
317
+ prometheus_url: http://localhost:9090
318
+ alertmanager_url: http://localhost:9093
319
+ api_url: http://localhost:3000
307
320
 
308
321
  # Where runs, events, and reports are stored.
309
322
  workspace:
310
- base_dir: ~/.prismalens
323
+ dir: ~/.prismalens
311
324
 
312
325
  # Per-harness native passthrough (ADR-0017) — untyped, forwarded straight to the
313
326
  # rented harness. For `deepagents` (the npm `deepagents-acp` binary, driven over
@@ -321,10 +334,13 @@ harnesses:
321
334
  ```
322
335
 
323
336
  Notes:
324
- - `agent.model` in config is a **provider-prefixed** id (e.g. `openai:gpt-oss:120b`).
325
- The `--model` flag passes a **bare** id (e.g. `gpt-oss:120b`); for `deepagents` the
326
- CLI prefixes it with `openai:`.
327
- - `telemetry.*` defaults to host-local URLs when unset.
337
+ - `agent.model` sets the **Tier-2 harness** model only (a bare id, e.g. `gpt-oss:120b`;
338
+ each harness applies its own provider prefix). `--model` overrides it.
339
+ - `synth.model` sets the **Tier-1 reduce** (report-synthesis) model — a separate call
340
+ to a separate provider (ADR-0013/0016). `agent.model` never feeds it, so a harness on
341
+ one provider (e.g. `claude-code`) can't misroute the reduce call to another (ollama).
342
+ - `telemetry.*` keys are snake_case (`prometheus_url`, `alertmanager_url`, `api_url`)
343
+ and default to host-local URLs when unset.
328
344
  - There is currently no `agent.timeout_ms`, `budget.*`, or `logging.*` config —
329
345
  an overall per-run wall-clock budget and a Tier-1 reduce token/retry budget are
330
346
  planned alongside the Phase B.1 Sandbox port's resource limits (ADR-0020), not
@@ -341,7 +357,7 @@ The resolution precedence for any credential is: **env** (`PROVIDER_API_KEY`)
341
357
  - `pl auth list` — view saved providers.
342
358
  - `pl auth logout <provider>` — remove a saved credential.
343
359
 
344
- Stored credentials live in `auth.json` inside the app-data dir (`~/.prismalens` by default, honors `PRISMALENS_USER_FOLDER`), enforced to mode `0600`.
360
+ Stored credentials live in `auth.json` inside the app-data dir (`~/.prismalens` by default, honors `PRISMALENS_WORKSPACE_DIR`), enforced to mode `0600`.
345
361
 
346
362
  - **Tier-1 reduce + the `deepagents` harness** use an OpenAI-compatible endpoint:
347
363
  - `OLLAMA_API_KEY` or `OPENAI_API_KEY` (the API key),
@@ -1,59 +1,48 @@
1
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
- */
2
+ import {
3
+ cliVersion
4
+ } from "../chunk-HPE5CTO4.js";
5
+
6
+ // bin/prismalens.ts
9
7
  import { defineCommand, runMain, showUsage } from "citty";
10
8
  import consola from "consola";
11
- import { cliVersion } from "../src/version.js";
12
- // The AI SDK's one-time "AI SDK Warning System" banner prints via console.info
13
- // (STDOUT) mid-run — noise in the live timeline and corruption in piped JSON.
14
- // Off for the whole CLI; real per-warning notices still reach stderr via
15
- // process.emitWarning.
16
9
  globalThis.AI_SDK_LOG_WARNINGS = false;
17
- const originalEmit = process.emit;
10
+ var originalEmit = process.emit;
18
11
  process.emit = ((name, ...args) => {
19
- if (name === "warning" &&
20
- args[0]?.name === "ExperimentalWarning" &&
21
- args[0]?.message?.includes("SQLite")) {
22
- return false;
23
- }
24
- return originalEmit.apply(process, [name, ...args]);
12
+ if (name === "warning" && args[0]?.name === "ExperimentalWarning" && args[0]?.message?.includes("SQLite")) {
13
+ return false;
14
+ }
15
+ return originalEmit.apply(process, [name, ...args]);
25
16
  });
26
- /** Lazily import a command body's default export from src/cli. */
27
- const lazy = (name) => () => import(`../src/cli/${name}.js`).then((m) => m.default);
28
- const main = defineCommand({
29
- meta: {
30
- name: "prismalens",
31
- version: cliVersion(),
32
- description: "PrismaLens investigation engine CLI — drives the two-tier engine (ADR-0008/0010).",
33
- },
34
- subCommands: {
35
- investigate: lazy("investigate"),
36
- listen: lazy("listen"),
37
- serve: lazy("serve"),
38
- doctor: lazy("doctor"),
39
- init: lazy("init"),
40
- status: lazy("status"),
41
- report: lazy("report"),
42
- auth: lazy("auth"),
43
- },
17
+ var lazy = (name) => () => {
18
+ const modulePath = `../src/cli/${name}.js`;
19
+ return import(modulePath).then((m) => m.default);
20
+ };
21
+ var main = defineCommand({
22
+ meta: {
23
+ name: "prismalens",
24
+ version: cliVersion(),
25
+ description: "PrismaLens investigation engine CLI \u2014 drives the two-tier engine (ADR-0008/0010)."
26
+ },
27
+ subCommands: {
28
+ investigate: lazy("investigate"),
29
+ listen: lazy("listen"),
30
+ serve: lazy("serve"),
31
+ doctor: lazy("doctor"),
32
+ init: lazy("init"),
33
+ status: lazy("status"),
34
+ report: lazy("report"),
35
+ auth: lazy("auth")
36
+ }
44
37
  });
45
38
  runMain(main, {
46
- showUsage: async (cmd, parent) => {
47
- const rawArgs = process.argv.slice(2);
48
- if (rawArgs.includes("--help") ||
49
- rawArgs.includes("-h") ||
50
- rawArgs.length === 0) {
51
- await showUsage(cmd, parent);
52
- }
53
- else {
54
- const cmdName = `pl${rawArgs[0] && !rawArgs[0].startsWith("-") ? ` ${rawArgs[0]}` : ""}`;
55
- consola.info(`See \`${cmdName} --help\` for usage.`);
56
- }
57
- },
39
+ showUsage: async (cmd, parent) => {
40
+ const rawArgs = process.argv.slice(2);
41
+ if (rawArgs.includes("--help") || rawArgs.includes("-h") || rawArgs.length === 0) {
42
+ await showUsage(cmd, parent);
43
+ } else {
44
+ const cmdName = `pl${rawArgs[0] && !rawArgs[0].startsWith("-") ? ` ${rawArgs[0]}` : ""}`;
45
+ consola.info(`Run \`${cmdName} --help\` for usage.`);
46
+ }
47
+ }
58
48
  });
59
- //# sourceMappingURL=prismalens.js.map
@@ -0,0 +1,20 @@
1
+ // ../@prismalens/config/dist/utils/app-data.js
2
+ import { mkdirSync } from "node:fs";
3
+ import { homedir } from "node:os";
4
+ import { join } from "node:path";
5
+ function getAppDataDir() {
6
+ if (process.env.PRISMALENS_WORKSPACE_DIR) {
7
+ return process.env.PRISMALENS_WORKSPACE_DIR;
8
+ }
9
+ return join(homedir(), ".prismalens");
10
+ }
11
+ function ensureAppDataDir() {
12
+ const appDataDir = getAppDataDir();
13
+ mkdirSync(appDataDir, { recursive: true, mode: 493 });
14
+ return appDataDir;
15
+ }
16
+
17
+ export {
18
+ getAppDataDir,
19
+ ensureAppDataDir
20
+ };