openmerit 0.1.11 → 0.2.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 (72) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +20 -56
  3. package/dist/pi/scout-extension.mjs +190 -0
  4. package/dist/pi/src/index.d.ts +6 -32
  5. package/dist/pi/src/index.js +49 -787
  6. package/dist/terminal/public/app.js +37 -37
  7. package/dist/terminal/public/styles.css +0 -125
  8. package/dist/terminal/scout-update.json +1 -1
  9. package/dist/terminal/src/cli.mjs +2 -0
  10. package/dist/terminal/src/install.mjs +103 -166
  11. package/dist/terminal/src/scout-credentials.d.ts +12 -0
  12. package/dist/terminal/src/scout-credentials.js +41 -0
  13. package/dist/terminal/src/scout-credentials.ts +44 -0
  14. package/dist/terminal/src/scout-instructions.d.ts +5 -0
  15. package/dist/terminal/src/scout-instructions.js +116 -0
  16. package/dist/terminal/src/scout-instructions.ts +119 -0
  17. package/dist/terminal/src/scout-pi.d.ts +44 -0
  18. package/dist/terminal/src/scout-pi.js +84 -0
  19. package/dist/terminal/src/scout-pi.ts +76 -0
  20. package/dist/terminal/src/scout.d.ts +77 -0
  21. package/dist/terminal/src/scout.js +181 -0
  22. package/dist/terminal/src/scout.ts +164 -0
  23. package/dist/terminal/src/server.mjs +1 -1
  24. package/dist/terminal/src/telemetry.mjs +2 -2
  25. package/docs/commands.md +3 -77
  26. package/docs/getting-started.md +20 -45
  27. package/docs/index.md +9 -14
  28. package/docs/inference-terminal.md +2 -63
  29. package/docs/pi-extension.md +32 -28
  30. package/docs/roadmap.md +6 -18
  31. package/docs/scout.md +39 -255
  32. package/docs/security.md +8 -14
  33. package/docs/testing.md +8 -34
  34. package/docs/troubleshooting.md +23 -28
  35. package/package.json +6 -27
  36. package/dist/core/src/index.d.ts +0 -101
  37. package/dist/core/src/index.js +0 -1649
  38. package/dist/core/src/store.d.ts +0 -35
  39. package/dist/core/src/store.js +0 -102
  40. package/dist/pi/src/scheduler.d.ts +0 -11
  41. package/dist/pi/src/scheduler.js +0 -137
  42. package/dist/pi/src/wakeup.d.ts +0 -2
  43. package/dist/pi/src/wakeup.js +0 -108
  44. package/dist/protocol/src/index.d.ts +0 -484
  45. package/dist/protocol/src/index.js +0 -47
  46. package/dist/protocol/src/schemas.d.ts +0 -576
  47. package/dist/protocol/src/schemas.js +0 -280
  48. package/dist/terminal/public/brands/vllm.ico +0 -0
  49. package/dist/terminal/public/flow.css +0 -1
  50. package/dist/terminal/public/flow.js +0 -770
  51. package/dist/terminal/src/demo-policy.mjs +0 -205
  52. package/dist/terminal/src/enterprise-sample.mjs +0 -151
  53. package/docs/adapter-guide.md +0 -189
  54. package/docs/architecture.md +0 -59
  55. package/docs/automation.md +0 -74
  56. package/docs/budgets.md +0 -37
  57. package/docs/demo-backfill.md +0 -31
  58. package/docs/demo-fieldkit.md +0 -49
  59. package/docs/demo-placement.md +0 -32
  60. package/docs/demo-spam.md +0 -17
  61. package/docs/demo-support.md +0 -44
  62. package/docs/demo.md +0 -74
  63. package/docs/first-trial.md +0 -60
  64. package/docs/interactive-demo.md +0 -118
  65. package/docs/lifecycle.md +0 -30
  66. package/docs/metrics-and-evidence.md +0 -48
  67. package/docs/operations.md +0 -38
  68. package/docs/pareto-spec.md +0 -76
  69. package/docs/saga/a-steadier-compass.md +0 -25
  70. package/docs/saga/defining-a-task-for-ai.md +0 -154
  71. package/docs/saga/the-benchmark-is-not-the-job.md +0 -33
  72. package/docs/ux-reference.md +0 -32
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.0 — 2026-11-04
4
+
5
+ - Add `openmerit scout`, a conversation with Scout from the terminal: clarifying questions answered with `--brief` or `--skip`, then up to five models per task, cheapest first among models that reach Scout's quality bar. When you ask for the fastest or newest model, the output names that order and shows each model's time per task or release date. It uses this device's Claude Code or Pi key and limits new conversations to the endpoint IDs in `.openmerit/scout.json`.
6
+ - The installed Scout instructions for Claude Code and Pi tell the agent to relay Scout's questions to the user and to read `tasks[].models`. This needs the matching hosted Scout release, whose `scout_models` MCP tool now runs the Scout agent.
7
+ - **Breaking:** remove the `openmerit`, `openmerit/core` and `openmerit/protocol` package exports, along with the evaluation coordinator, harness protocol, Pareto conformance rules and the repository's `npm run demo` sandbox. The package keeps `openmerit/pi` and the `openmerit` command: `openmerit dash`, `openmerit scout`, Scout setup commands and `openmerit eval`.
8
+ - Remove the hosted Inference Terminal sample at `dash.openmerit.ai`, its `/demo` before/after comparison and the opt-in `?map=flow` map experiment. The local terminal, including its fictional sample (`--demo`), is unchanged.
9
+ - Remove the retired demo guides and the guides that documented only the coordinator: architecture, adapter development, Pareto specification, first trial, metrics and evidence, comparisons and swaps, automatic checks, budgets and permissions, and project files and logs.
10
+
11
+ ## 0.1.12 — 2026-11-03
12
+
13
+ - Replace the obsolete Pi 0.87 evaluation adapter with native Scout support for Pi 1.5.0. Share browser device approval, private client/scope/project credentials, installer lifecycle and Scout instructions with Claude Code; keep Pi's native MCP, tools, model, permissions and session ownership intact.
14
+ - Add targeted Pi setup, status, diagnostics, login, logout and removal, preserving edited files and independent credentials. Install a self-contained automatically discovered extension; updates require an explicit installer rerun and a new session. No legacy evaluation commands, scheduler, LaunchAgent or auto-update hooks remain in the Pi adapter.
15
+ - Add the logo-first Add to Pi action below Claude Code, with copy-only setup and a clipboard-denied fallback. Scout serving and npm publication remain separate releases.
16
+ - Keep the standalone evaluation CLI and core coordinator; move the prepared demo transport out of the removed Pi adapter and declare its Pi runtime dependency explicitly.
17
+
3
18
  ## 0.1.11 — 2026-11-01
4
19
 
5
20
  - Refresh packaged Scout guides and include the Saga articles maintained in Markdown.
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # OpenMerit
2
2
 
3
- OpenMerit provides a local Inference Terminal for understanding an application's models, services, recorded activity, and compute, plus a Pi integration for evidence-driven model comparisons.
3
+ OpenMerit provides a local Inference Terminal for understanding an application's models, services, recorded activity, and compute, plus Scout guidance for application-model choices.
4
4
 
5
- The terminal reads existing evidence. The Pi integration asks a coding harness to build evaluations, measure candidates, and carry out authorized changes. OpenMerit coordinates that workflow and validates its structured results; the terminal does not route requests, run evaluations, or swap models.
5
+ The terminal reads existing evidence; Scout recommends candidates to evaluate. Neither is a request router or proof of application-quality improvements. A separate standalone evaluation CLI supports explicit evaluation workflows.
6
6
 
7
7
  ## Open the terminal
8
8
 
@@ -14,71 +14,43 @@ cd /path/to/your/application
14
14
  openmerit dash
15
15
  ```
16
16
 
17
- Stable `openmerit@0.1.7` includes the terminal. No Pi installation or provider API key is needed. It opens a browser connected to a read-only loopback service. Supported source/configuration declarations establish inventory; existing application logs or exports supply request history. Prompts, responses, and credentials are not retained. Unsupported or missing evidence remains unknown.
17
+ No Pi installation or provider API key is needed. The terminal opens a browser connected to a read-only loopback service. Supported source/configuration declarations establish inventory; existing application logs or exports supply request history. Prompts, responses, and credentials are not retained by terminal collection. Unsupported or missing evidence remains unknown.
18
18
 
19
- The terminal and hosted dashboard follow the device's light/dark preference without a theme control. CLI and terminal product analytics are off unless explicitly enabled; see [the analytics contract](docs/inference-terminal.md#optional-cli-product-analytics).
19
+ The terminal follows the device's light/dark preference without a theme control. CLI and terminal product analytics are off unless explicitly enabled; see [the analytics contract](docs/inference-terminal.md#optional-cli-product-analytics).
20
20
 
21
- Explore the [hosted sample](https://dash.openmerit.ai/) or [before/after dashboard demo](https://dash.openmerit.ai/demo). Both use fictional data and make no inference calls. See [the terminal guide](docs/inference-terminal.md) for configuration, discovery, diagnostics, history limits, and agent access.
21
+ Run `openmerit dash --demo` to explore a fictional sample workspace. See [the terminal guide](docs/inference-terminal.md) for configuration, discovery, diagnostics, history limits, and agent access.
22
22
 
23
23
  ## Connect Scout to Claude Code
24
24
 
25
- Run `npx -y openmerit@latest install --client claude-code`, then approve the device in your browser. The command installs the MCP server and Scout skill and checks the connection. New Claude Code sessions can consult Scout before choosing application models. Requires the `claude` CLI on PATH; see [setup, project policy and removal](docs/scout.md#connect-a-coding-agent). Installing the npm package alone makes no agent configuration changes.
25
+ Run `npx -y openmerit@latest install --client claude-code`, then approve the device in your browser. The command installs the MCP server and shared Scout guidance and checks the connection. New Claude Code sessions can consult Scout before choosing application models. Requires the `claude` CLI on PATH; see [setup, project policy and removal](docs/scout.md#connect-a-coding-agent). Installing the npm package alone makes no agent configuration changes.
26
26
 
27
- ## Compare models with Pi
27
+ ## Connect Scout to Pi
28
28
 
29
- Stable **npm 0.1.7** provides `openmerit eval` for evaluating Claude Code, Codex and OpenCode with your CLI. Choose model scope and a $10, custom or no-fixed-cap budget, freeze Scout's shortlist, and compare 3–10 fresh attempts after source changes. Budget and sandbox blocks stay separate from task scores; unknown costs stay unknown. Install with `npm install -g openmerit@latest`. See [agent evaluations](docs/agent-evaluations.md) for setup, graders, budgets and availability. Scout's hosted API and MCP service update independently of the npm package. This is separate from the Pi workflow below.
30
-
31
- With Pi 0.87 and a model provider configured:
29
+ OpenMerit **0.1.12** adds a thin Scout adapter for Pi **1.5.0**, replacing the old Pi 0.87 evaluation extension:
32
30
 
33
31
  ```sh
34
- pi install npm:openmerit
35
- pi list
32
+ npx -y openmerit@latest install --client pi --scope user
36
33
  ```
37
34
 
38
- Open the product repository in interactive Pi. An unconfigured project is checked for an application LLM call at session start and after settled build turns. Pi confirms the application target and incumbent model, proposes task-specific metrics and sampling, explains estimated evaluation cost, and requests confirmation of the plan, budget, and permissions. `/openmerit setup` can recover or rerun setup. Pi's own model is never the application target.
39
-
40
- Core checks stored baseline windows against the confirmed requirements. When ready, it asks Pi to discover candidates, run controlled comparisons, and calculate a frontier. Core validates the returned evidence contracts and Pareto conformance. The harness must execute the work and provide honest evidence.
41
-
42
- Model changes normally require approval. Explicit automatic-swap opt-in can allow changes once the configured verified-swap threshold is reached, including a threshold of zero. Post-swap evaluation and conditional rollback depend on the harness performing and reporting them.
43
-
44
- Read [getting started](docs/getting-started.md) and [your first supervised trial](docs/first-trial.md).
45
-
46
- ## Implemented orchestration
35
+ Approve the matching device code in your browser, then start a new Pi session. Scope defaults to `user`; run with `--scope project` from a project's root for project-only setup. Each client/scope installation has its own key; project credentials stay outside the repository. The installed `openmerit-scout.ts` extension references private configuration and uses Pi's native MCP with the shared Scout rule and skill. Pi owns tools, model, permissions and sessions.
47
36
 
48
- - Task profiles with confirmed metrics, sampling plans, constraints, budgets, and permissions.
49
- - Preliminary model research, incumbent identity, durable candidate handoffs, and controlled challenger experiments.
50
- - Deterministic baseline checks and uncertainty-aware frontier validation.
51
- - Versioned result schemas for all ten intents and a reusable harness adapter boundary.
52
- - Challenger-spend accounting, bounded intent admission, approval, verification, and rollback requests.
53
- - Project-local state, redacted audit events, evidence manifests, and optional event exporters.
54
- - Task-count, elapsed-time, catalogue-change, regression, and post-swap signals.
55
- - Durable pause and authorized macOS user LaunchAgents; other platforms require an external scheduler.
37
+ There are no `/openmerit` lifecycle commands, evaluation setup, scheduler, LaunchAgent, or automatic update hooks. To update, explicitly rerun the installer with the same scope. Shell `login`, `logout`, `status`, `remove` and `doctor` support `--client pi --scope user|project`. See [Pi setup and migration](docs/pi-extension.md) for paths, conflicts, old background-job removal, and SDK embedding with `createScoutPiExtension` plus Pi's explicit `createMcpExtension()`.
56
38
 
57
- These implementations have automated coverage. They do not establish application-quality improvements or reliable unattended model changes. See [current limitations](docs/roadmap.md).
39
+ Package publication and website deployment are separate releases. Pi setup requires OpenMerit 0.1.12 or newer; check the resolved package version when using `@latest`.
58
40
 
59
- ## Pi commands
41
+ ## Evaluate application changes
60
42
 
61
- - `/openmerit` or `/openmerit status` — inspect readiness, active work, and lifecycle state.
62
- - `/openmerit setup` — request or recover setup.
63
- - `/openmerit assess` — check stored baseline windows; discover candidates only when ready.
64
- - `/openmerit frontier` — request a harness-calculated comparison for validation.
65
- - `/openmerit approve` — approve the current verified proposal.
66
- - `/openmerit pause` / `/openmerit resume` — persist or clear the automatic-work pause and reconcile authorized scheduling; active work is not cancelled.
67
- - `/openmerit cancel` — record abandonment of an interrupted intent; it does not terminate a provider request.
68
- - `/openmerit logs` — locate local state, audit, and evidence files.
69
- - `/openmerit doctor` — inspect adapter and scheduler diagnostics.
43
+ The standalone `openmerit eval` CLI is unchanged by the Pi replacement. Evaluate Claude Code, Codex and OpenCode with explicit tasks, model scope, budget and graders. Freeze Scout's shortlist and compare fresh repeated attempts after source changes. Budget and sandbox blocks stay separate from task scores; unknown costs stay unknown. See [agent evaluations](docs/agent-evaluations.md) for setup, graders, budgets and availability.
70
44
 
71
45
  ## Documentation
72
46
 
73
- The [documentation overview](docs/index.md) links all current guides. The website at [openmerit.ai/docs](https://openmerit.ai/docs/) is deployed separately from the package and this checkout.
47
+ The [documentation overview](docs/index.md) links the current guides. The website at [openmerit.ai/docs](https://openmerit.ai/docs/) is deployed separately from the package and this checkout.
74
48
 
75
- - [Inference Terminal](docs/inference-terminal.md)
76
- - [Metrics and evidence](docs/metrics-and-evidence.md)
77
- - [Lifecycle](docs/lifecycle.md), [automation](docs/automation.md), and [budgets](docs/budgets.md)
78
- - [Commands](docs/commands.md), [operations](docs/operations.md), and [troubleshooting](docs/troubleshooting.md)
49
+ - [Getting started](docs/getting-started.md) and [troubleshooting](docs/troubleshooting.md)
50
+ - [Scout](docs/scout.md) and [Pi adapter](docs/pi-extension.md)
51
+ - [Inference Terminal](docs/inference-terminal.md) and [agent evaluations](docs/agent-evaluations.md)
79
52
  - [Security and data handling](docs/security.md)
80
- - [Architecture](docs/architecture.md), [Pi adapter](docs/pi-extension.md), and [adapter development](docs/adapter-guide.md)
81
- - [Pareto specification](docs/pareto-spec.md) and [testing](docs/testing.md)
53
+ - [Testing](docs/testing.md) and [current limitations](docs/roadmap.md)
82
54
 
83
55
  ## Development
84
56
 
@@ -88,14 +60,6 @@ npm run verify
88
60
  npm run dash -- /path/to/application
89
61
  ```
90
62
 
91
- For Pi extension development:
92
-
93
- ```sh
94
- ./node_modules/.bin/pi --no-extensions -e ./packages/pi/src/index.ts
95
- ```
96
-
97
- `--no-extensions` avoids registering an installed npm copy alongside the source extension. Credentials belong to the harness or its environment and must never be committed. Jev, if configured, is invoked by the harness; OpenMerit provides no Jev client.
98
-
99
- `packages/terminal` contains the CLI, collectors, hosted sample, and browser interface. `packages/protocol`, `packages/core`, and `packages/pi` provide the protocol, coordinator, and Pi adapter. The package exports `openmerit/core`, `openmerit/protocol`, and `openmerit/pi`.
63
+ `packages/terminal` contains the CLI, collectors and browser interface. `packages/eval` contains the standalone `openmerit eval` runner, and `packages/pi` supplies only the native Scout adapter. The package exports `openmerit/pi` and the `openmerit` command. See the [Pi package README](packages/pi/README.md) for bounded adapter tests. Provider credentials belong to the harness or its environment and must never be committed.
100
64
 
101
65
  Edit documentation in `docs/`, then run `npm run check:docs`. The website is generated from those Markdown files. See [documentation maintenance](docs/site-documentation.md) and the [production-source reconciliation note](docs/site-domain-migration.md) before deployment; a local build does not publish changes.
@@ -0,0 +1,190 @@
1
+ // packages/pi/src/index.ts
2
+ import { readFileSync as readFileSync2, statSync } from "node:fs";
3
+
4
+ // packages/terminal/src/scout-credentials.ts
5
+ import { createHash } from "node:crypto";
6
+ import { readFileSync } from "node:fs";
7
+ import { homedir } from "node:os";
8
+ import { dirname, join, resolve } from "node:path";
9
+ function credentialsPath(client, scope, root) {
10
+ const base = resolve(process.env.OPENMERIT_CONFIG_DIR ?? join(process.env.XDG_CONFIG_HOME ?? join(homedir(), ".config"), "openmerit"));
11
+ if (client === "claude-code" && scope === "user") return join(base, "credentials.json");
12
+ const installation = scope === "project" ? createHash("sha256").update(resolve(root)).digest("hex").slice(0, 24) : "user";
13
+ return join(base, client, installation, "credentials.json");
14
+ }
15
+ function readCredentials(path) {
16
+ let value;
17
+ try {
18
+ value = JSON.parse(readFileSync(path, "utf8"));
19
+ } catch (error) {
20
+ if (error instanceof Error && "code" in error && error.code === "ENOENT") return null;
21
+ throw new Error("Scout credentials could not be read. Run the targeted install command again.");
22
+ }
23
+ if (!value || typeof value !== "object" || !("version" in value) || value.version !== 1 || !("server" in value) || typeof value.server !== "string" || !("key" in value) || typeof value.key !== "string" || !/^om_[A-Za-z0-9_-]{43}$/.test(value.key)) return null;
24
+ const url = new URL(value.server);
25
+ if (url.username || url.password || url.protocol !== "https:" && !(url.protocol === "http:" && ["127.0.0.1", "localhost", "[::1]"].includes(url.hostname))) return null;
26
+ const result = { version: 1, server: value.server.replace(/\/+$/, ""), key: value.key };
27
+ if ("keyId" in value && typeof value.keyId === "string") result.keyId = value.keyId;
28
+ if ("headers" in value && value.headers && typeof value.headers === "object") {
29
+ result.headers = Object.fromEntries(Object.entries(value.headers).filter(([key, v]) => /^X-Scout-[A-Za-z-]+$/.test(key) && typeof v === "string"));
30
+ }
31
+ return result;
32
+ }
33
+
34
+ // packages/terminal/src/scout-instructions.ts
35
+ var rule = `# Application model decisions \xB7 OpenMerit Scout
36
+
37
+ Before choosing, recommending, adding, downloading, replacing or configuring
38
+ ANY application inference model, load the \`openmerit-scout\` skill and consult
39
+ \`scout_models\` on the \`openmerit\` MCP server before committing to a model.
40
+ This applies even when the user only asks you to build a feature, never mentions
41
+ models or Scout, or names a model themselves (assess it; do not silently replace it).
42
+
43
+ A pretrained model, local weights, browser inference, an SDK's default model,
44
+ embeddings, OCR, speech, image classification, detection and segmentation all
45
+ count as model choices, not implementation details. Identify this decision before
46
+ writing model-specific code, installing a model package or downloading weights.
47
+
48
+ Follow the skill's project access policy. If it is missing, ask and save it first.
49
+ Scout may answer with clarifying questions: relay them to the user and continue
50
+ the same Scout conversation with their answers before choosing.
51
+ If Scout is unavailable, fails or has no suitable evidence/candidate, disclose the
52
+ gap and pause the model decision; do not fall back to a remembered or SDK-default
53
+ model. You may continue work that does not commit to a model.
54
+
55
+ Do not consult Scout for unrelated edits, normal inference calls using an unchanged
56
+ approved model, or this coding agent's own model. Do not reselect approved models
57
+ unless the task introduces or changes a model decision.
58
+
59
+ When the user says "update openmerit", run
60
+ \`npx -y openmerit@latest update --scope user\` (use \`--scope project\` if this
61
+ rule is in the project's .claude/rules directory). Report the result, including
62
+ any conflict or manual-upgrade requirement. Do not delete edited files, bypass
63
+ permissions or rerun login automatically. A new session loads updated instructions.
64
+ `;
65
+ var skill = `---
66
+ name: openmerit-scout
67
+ description: Consults OpenMerit Scout before choosing, adding, downloading, replacing or configuring any application inference model, including implicit choices while building features, pretrained browser/local models, SDK defaults, embeddings, OCR, speech, classification, detection, segmentation, LLMs and agents. Not for unrelated edits, ordinary inference calls or this coding agent's own model.
68
+ ---
69
+
70
+ # OpenMerit \xB7 Scout
71
+
72
+ Before introducing, recommending, replacing or configuring an application
73
+ inference model, call the \`scout_models\` tool on the \`openmerit\` MCP server.
74
+ This applies even when the user never mentions models or Scout. Downloading local
75
+ weights, using a pretrained browser model or accepting an SDK default is a model
76
+ decision: consult Scout before model-specific code, installs or downloads.
77
+ Preserve the user's explicit model choice; assess it rather than silently replacing
78
+ it. Leave unchanged, approved application selections in place.
79
+
80
+ ## Project policy
81
+
82
+ Read \`.openmerit/scout.json\` before searching. If it is absent, ask once whether this
83
+ project uses **existing-only** (only endpoints it can already reach) or
84
+ **existing-first** (prefer them, ask before searching the whole catalogue), and
85
+ which public catalogue endpoint IDs it can access. Save the answer:
86
+
87
+ \`\`\`sh
88
+ npx -y openmerit@latest project --policy existing-only --endpoint-id <id> ...
89
+ \`\`\`
90
+
91
+ Never infer access from a model name, SDK or environment-variable name. Never
92
+ record credentials, private URLs, prompts or customer data. An empty inventory
93
+ is not permission to search all models.
94
+
95
+ ## Searching
96
+
97
+ Call \`scout_models\` with a non-confidential task description as \`prompt\` and
98
+ \`endpointIds\` set to the saved inventory, including \`[]\` when empty. Send
99
+ only task requirements, never source files, secrets or real customer records.
100
+ If the MCP tool is unavailable, run
101
+ \`npx -y openmerit@latest scout "<task>" --json\`; it applies the saved inventory.
102
+
103
+ Scout is a conversation with the agent behind openmerit.ai/scout. When
104
+ \`status\` is \`needs_answers\`, fill in what the user or project already states,
105
+ show the user Scout's brief and remaining questions, and wait for their answers.
106
+ Then call again with the returned \`conversationId\` and \`brief\` set to the
107
+ rewritten components, or \`skip: true\` if the user wants Scout to assume. Never
108
+ answer Scout's questions with guesses. Send later refinements to the same
109
+ \`conversationId\`. A call with only a \`conversationId\` reads an interrupted turn.
110
+
111
+ When \`status\` is \`recommended\`, Scout has split the work into \`tasks\`, one
112
+ per model, each with up to five ranked \`models\`; cover every task. Each
113
+ model's \`cost\` names the \`endpointId\` and \`providerModelId\` to call.
114
+ Existing-only never broadens. For existing-first, if no existing candidate fits a
115
+ task, explain the gap and ask before a new conversation without \`endpointIds\`.
116
+ Compare quality evidence, reference cost/time and watch-outs. Prefer the cheapest
117
+ usable option the evidence supports, without claiming benchmarks prove
118
+ application accuracy. Use the project's actual SDK and protocol.
119
+
120
+ ## Boundaries
121
+
122
+ Ask before adding providers or credentials, spending, deploying or external
123
+ writes. Report recommendation, endpoint connectivity and application checks as
124
+ separate results, each only after it succeeds. Do not switch this coding agent's
125
+ own model.
126
+
127
+ If Scout fails or has no suitable candidate/evidence for the required deployment,
128
+ say so and pause the model decision; do not substitute a remembered recommendation
129
+ or SDK default. Continue only model-independent work. Local/browser models are not
130
+ exempt when the catalogue lacks coverage. If it reports that the device key is missing,
131
+ expired or revoked, run \`npx -y openmerit@latest login\` and then
132
+ \`npx -y openmerit@latest install\` again. Never ask the user to paste a key.
133
+ `;
134
+ function scoutRule(client) {
135
+ if (client === "claude-code") return rule;
136
+ return rule.replace("load the `openmerit-scout` skill and consult", "follow the Scout project policy below and consult").replaceAll("`scout_models`", "`mcp__openmerit__scout_models`").replace("Follow the skill's project access policy.", "Follow the project access policy below.").replace("update --scope user", "install --client pi --scope user").replace("rule is in the project's .claude/rules directory", "Pi installation is project-scoped");
137
+ }
138
+ function scoutSkill(client) {
139
+ if (client === "claude-code") return skill;
140
+ return skill.replaceAll("`scout_models`", "`mcp__openmerit__scout_models`").replace("openmerit@latest login", "openmerit@latest login --client pi").replace("openmerit@latest install`", "openmerit@latest install --client pi`").replace("again. Never ask the user to paste a key.", "again, using `--scope project` on both commands for a project-scoped installation. Never ask the user to paste a key.");
141
+ }
142
+
143
+ // packages/pi/src/index.ts
144
+ function configuredCredentialsPath() {
145
+ const config = new URL("./openmerit-scout.json", import.meta.url);
146
+ let value;
147
+ try {
148
+ if (statSync(config).size > 16384) throw new Error("Invalid Scout connection config");
149
+ value = JSON.parse(readFileSync2(config, "utf8"));
150
+ } catch (error) {
151
+ if (error instanceof Error && "code" in error && error.code === "ENOENT") {
152
+ return credentialsPath("pi", "user", process.cwd());
153
+ }
154
+ throw new Error("Invalid Scout connection config");
155
+ }
156
+ if (!value || typeof value !== "object" || !("credentialsPath" in value) || typeof value.credentialsPath !== "string" || !value.credentialsPath.trim()) {
157
+ throw new Error("Invalid Scout connection config");
158
+ }
159
+ return value.credentialsPath;
160
+ }
161
+ function createScoutPiExtension(options = {}) {
162
+ return (pi) => {
163
+ pi.on("session_start", (_event, ctx) => {
164
+ try {
165
+ const credentials = readCredentials(options.credentialsPath ?? configuredCredentialsPath());
166
+ if (!credentials) throw new Error("Scout credentials missing");
167
+ pi.registerMcpServer("openmerit", {
168
+ type: "http",
169
+ url: `${credentials.server}/scout/mcp`,
170
+ headers: { ...credentials.headers, Authorization: `Bearer ${credentials.key}` },
171
+ exposure: "direct"
172
+ });
173
+ } catch {
174
+ ctx.ui.notify(
175
+ "OpenMerit Scout could not load its connection. Run `npx -y openmerit@latest install --client pi --scope user` (use `--scope project` for a project installation), then start a new Pi session. SDK hosts must also load Pi's createMcpExtension().",
176
+ "warning"
177
+ );
178
+ }
179
+ });
180
+ pi.on("before_agent_start", (event) => {
181
+ event.systemPromptOptions.sections.openmerit_scout_rule = scoutRule("pi");
182
+ event.systemPromptOptions.sections.openmerit_scout_skill = scoutSkill("pi");
183
+ });
184
+ };
185
+ }
186
+ var index_default = createScoutPiExtension();
187
+ export {
188
+ createScoutPiExtension,
189
+ index_default as default
190
+ };
@@ -1,32 +1,6 @@
1
- import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
- import { type HarnessDescriptor, type ImprovementStage } from "../../protocol/src/index.ts";
3
- export declare const PI_HARNESS_DESCRIPTOR: HarnessDescriptor;
4
- export interface OpenMeritUiState {
5
- proactiveNudgesPaused: boolean;
6
- applicationTarget: "not_detected" | "detected" | "confirmed";
7
- taskProfile: "not_configured" | "pending" | "configured";
8
- metricReadiness: "not_assessed" | "pending" | "assessed";
9
- evaluationReadiness: "not_assessed" | "pending" | "assessed";
10
- activeIntent: string | null;
11
- nextAssessment: string | null;
12
- lifecycleStage: ImprovementStage | "not_initialized";
13
- incumbentCandidate: string | null;
14
- candidateCount: number;
15
- assessmentCount: number;
16
- evaluationSpend: number;
17
- proposedCandidate: string | null;
18
- }
19
- export declare function createInitialUiState(): OpenMeritUiState;
20
- export declare function renderStatus(state: OpenMeritUiState): string;
21
- export interface DetectedApplicationLlmTarget {
22
- readonly id: string;
23
- readonly kind: "application_llm_call";
24
- readonly name: string;
25
- readonly applicationId: string;
26
- readonly callSites: readonly string[];
27
- readonly routeKey: string;
28
- readonly configuredModelId?: string;
29
- }
30
- /** Bounded, adapter-local detection. It requires an actual application call pattern, not only an SDK dependency. */
31
- export declare function detectApplicationLlmTargets(projectRoot: string): readonly DetectedApplicationLlmTarget[];
32
- export default function openMeritExtension(pi: ExtensionAPI): void;
1
+ import type { ExtensionFactory } from "@earendil-works/pi-coding-agent";
2
+ export declare function createScoutPiExtension(options?: {
3
+ credentialsPath?: string;
4
+ }): ExtensionFactory;
5
+ declare const _default: ExtensionFactory;
6
+ export default _default;