openmerit 0.1.10 → 0.1.12
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.
- package/CHANGELOG.md +13 -0
- package/README.md +20 -53
- package/dist/pi/scout-extension.mjs +177 -0
- package/dist/pi/src/index.d.ts +6 -32
- package/dist/pi/src/index.js +49 -787
- package/dist/terminal/scout-update.json +1 -1
- package/dist/terminal/src/install.mjs +102 -166
- package/dist/terminal/src/scout-credentials.d.ts +12 -0
- package/dist/terminal/src/scout-credentials.js +41 -0
- package/dist/terminal/src/scout-credentials.ts +44 -0
- package/dist/terminal/src/scout-instructions.d.ts +5 -0
- package/dist/terminal/src/scout-instructions.js +103 -0
- package/dist/terminal/src/scout-instructions.ts +106 -0
- package/dist/terminal/src/scout-pi.d.ts +44 -0
- package/dist/terminal/src/scout-pi.js +84 -0
- package/dist/terminal/src/scout-pi.ts +76 -0
- package/dist/terminal/src/telemetry.mjs +2 -2
- package/dist/terminal/src/updates.js +2 -1
- package/dist/terminal/src/updates.ts +2 -1
- package/docs/adapter-guide.md +2 -0
- package/docs/architecture.md +7 -5
- package/docs/automation.md +2 -0
- package/docs/budgets.md +2 -0
- package/docs/commands.md +3 -1
- package/docs/demo.md +1 -1
- package/docs/first-trial.md +2 -0
- package/docs/getting-started.md +19 -44
- package/docs/index.md +10 -6
- package/docs/inference-terminal.md +1 -1
- package/docs/lifecycle.md +2 -0
- package/docs/operations.md +2 -0
- package/docs/pi-extension.md +32 -28
- package/docs/roadmap.md +6 -5
- package/docs/scout-data-policy.md +22 -64
- package/docs/scout.md +137 -19
- package/docs/security.md +8 -2
- package/docs/testing.md +2 -0
- package/docs/troubleshooting.md +23 -28
- package/docs/ux-reference.md +1 -1
- package/package.json +11 -7
- package/dist/pi/src/scheduler.d.ts +0 -11
- package/dist/pi/src/scheduler.js +0 -137
- package/dist/pi/src/wakeup.d.ts +0 -2
- package/dist/pi/src/wakeup.js +0 -108
- package/docs/memo.md +0 -126
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.12 — 2026-11-03
|
|
4
|
+
|
|
5
|
+
- 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.
|
|
6
|
+
- 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.
|
|
7
|
+
- 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.
|
|
8
|
+
- 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.
|
|
9
|
+
|
|
10
|
+
## 0.1.11 — 2026-11-01
|
|
11
|
+
|
|
12
|
+
- Refresh packaged Scout guides and include the Saga articles maintained in Markdown.
|
|
13
|
+
- Recognize the Claude Code instruction updater when invoked through a symbolic link, so linked hook entry points run their update checks.
|
|
14
|
+
- Preserve the existing CLI, Claude Code instruction-update contract, Pi integration and public exports. Scout, Saga and homepage source changes require separate website deployments; this npm release does not publish them.
|
|
15
|
+
|
|
3
16
|
## 0.1.10 — 2026-10-26
|
|
4
17
|
|
|
5
18
|
- Add default-on Claude Code background checks for compatible Scout skill/startup-rule updates, with daily checks, 15-minute failure backoff, non-blocking failure notices with the “update openmerit” fallback, manual `openmerit update`, persistent opt-out and a natural-language update instruction.
|
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
|
|
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
|
|
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 and reusable core coordinator support explicit evaluation workflows.
|
|
6
6
|
|
|
7
7
|
## Open the terminal
|
|
8
8
|
|
|
@@ -14,7 +14,7 @@ cd /path/to/your/application
|
|
|
14
14
|
openmerit dash
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
|
|
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
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).
|
|
20
20
|
|
|
@@ -22,63 +22,38 @@ Explore the [hosted sample](https://dash.openmerit.ai/) or [before/after dashboa
|
|
|
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
|
|
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
|
-
##
|
|
27
|
+
## Connect Scout to Pi
|
|
28
28
|
|
|
29
|
-
|
|
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
|
-
|
|
35
|
-
pi list
|
|
32
|
+
npx -y openmerit@latest install --client pi --scope user
|
|
36
33
|
```
|
|
37
34
|
|
|
38
|
-
|
|
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.
|
|
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.
|
|
43
36
|
|
|
44
|
-
|
|
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()`.
|
|
45
38
|
|
|
46
|
-
|
|
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`.
|
|
47
40
|
|
|
48
|
-
|
|
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.
|
|
41
|
+
## Evaluate application changes
|
|
56
42
|
|
|
57
|
-
|
|
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.
|
|
58
44
|
|
|
59
|
-
|
|
60
|
-
|
|
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.
|
|
45
|
+
The core coordinator remains available for custom harnesses: task profiles, controlled experiments, baseline and frontier validation, evidence contracts, budgets, approvals and rollback requests. The harness performs the work and supplies evidence; core validation does not establish that external measurements are truthful. The older Pi lifecycle walkthroughs are retained as historical/core references, not supported commands in the new Scout adapter.
|
|
70
46
|
|
|
71
47
|
## Documentation
|
|
72
48
|
|
|
73
|
-
The [documentation overview](docs/index.md) links
|
|
49
|
+
The [documentation overview](docs/index.md) links current guides and historical references. The website at [openmerit.ai/docs](https://openmerit.ai/docs/) is deployed separately from the package and this checkout.
|
|
74
50
|
|
|
75
|
-
- [
|
|
76
|
-
- [
|
|
77
|
-
- [
|
|
78
|
-
- [Commands](docs/commands.md), [operations](docs/operations.md), and [troubleshooting](docs/troubleshooting.md)
|
|
51
|
+
- [Getting started](docs/getting-started.md) and [troubleshooting](docs/troubleshooting.md)
|
|
52
|
+
- [Scout](docs/scout.md) and [Pi adapter](docs/pi-extension.md)
|
|
53
|
+
- [Inference Terminal](docs/inference-terminal.md) and [agent evaluations](docs/agent-evaluations.md)
|
|
79
54
|
- [Security and data handling](docs/security.md)
|
|
80
|
-
- [Architecture](docs/architecture.md), [
|
|
81
|
-
- [
|
|
55
|
+
- [Architecture](docs/architecture.md), [adapter development](docs/adapter-guide.md), and [Pareto specification](docs/pareto-spec.md)
|
|
56
|
+
- [Testing](docs/testing.md) and [current limitations](docs/roadmap.md)
|
|
82
57
|
|
|
83
58
|
## Development
|
|
84
59
|
|
|
@@ -88,14 +63,6 @@ npm run verify
|
|
|
88
63
|
npm run dash -- /path/to/application
|
|
89
64
|
```
|
|
90
65
|
|
|
91
|
-
|
|
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`.
|
|
66
|
+
`packages/terminal` contains the CLI, collectors, hosted sample, and browser interface. `packages/protocol` and `packages/core` provide evaluation contracts and coordination; `packages/pi` supplies only the native Scout adapter. The package exports `openmerit/core`, `openmerit/protocol`, and `openmerit/pi`. 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
67
|
|
|
101
68
|
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,177 @@
|
|
|
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
|
+
If Scout is unavailable, fails or has no suitable evidence/candidate, disclose the
|
|
50
|
+
gap and pause the model decision; do not fall back to a remembered or SDK-default
|
|
51
|
+
model. You may continue work that does not commit to a model.
|
|
52
|
+
|
|
53
|
+
Do not consult Scout for unrelated edits, normal inference calls using an unchanged
|
|
54
|
+
approved model, or this coding agent's own model. Do not reselect approved models
|
|
55
|
+
unless the task introduces or changes a model decision.
|
|
56
|
+
|
|
57
|
+
When the user says "update openmerit", run
|
|
58
|
+
\`npx -y openmerit@latest update --scope user\` (use \`--scope project\` if this
|
|
59
|
+
rule is in the project's .claude/rules directory). Report the result, including
|
|
60
|
+
any conflict or manual-upgrade requirement. Do not delete edited files, bypass
|
|
61
|
+
permissions or rerun login automatically. A new session loads updated instructions.
|
|
62
|
+
`;
|
|
63
|
+
var skill = `---
|
|
64
|
+
name: openmerit-scout
|
|
65
|
+
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.
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
# OpenMerit \xB7 Scout
|
|
69
|
+
|
|
70
|
+
Before introducing, recommending, replacing or configuring an application
|
|
71
|
+
inference model, call the \`scout_models\` tool on the \`openmerit\` MCP server.
|
|
72
|
+
This applies even when the user never mentions models or Scout. Downloading local
|
|
73
|
+
weights, using a pretrained browser model or accepting an SDK default is a model
|
|
74
|
+
decision: consult Scout before model-specific code, installs or downloads.
|
|
75
|
+
Preserve the user's explicit model choice; assess it rather than silently replacing
|
|
76
|
+
it. Leave unchanged, approved application selections in place.
|
|
77
|
+
|
|
78
|
+
## Project policy
|
|
79
|
+
|
|
80
|
+
Read \`.openmerit/scout.json\` before searching. If it is absent, ask once whether this
|
|
81
|
+
project uses **existing-only** (only endpoints it can already reach) or
|
|
82
|
+
**existing-first** (prefer them, ask before searching the whole catalogue), and
|
|
83
|
+
which public catalogue endpoint IDs it can access. Save the answer:
|
|
84
|
+
|
|
85
|
+
\`\`\`sh
|
|
86
|
+
npx -y openmerit@latest project --policy existing-only --endpoint-id <id> ...
|
|
87
|
+
\`\`\`
|
|
88
|
+
|
|
89
|
+
Never infer access from a model name, SDK or environment-variable name. Never
|
|
90
|
+
record credentials, private URLs, prompts or customer data. An empty inventory
|
|
91
|
+
is not permission to search all models.
|
|
92
|
+
|
|
93
|
+
## Searching
|
|
94
|
+
|
|
95
|
+
Call \`scout_models\` with a non-confidential task description and
|
|
96
|
+
\`endpointIds\` set to the saved inventory, including \`[]\` when empty.
|
|
97
|
+
Existing-only never broadens. For existing-first, if no existing candidate fits,
|
|
98
|
+
explain the gap and ask before a separate search without \`endpointIds\`. Send
|
|
99
|
+
only task requirements, never source files, secrets or real customer records.
|
|
100
|
+
|
|
101
|
+
Compare model AND endpoint, evidence, reference cost/time, unknowns and
|
|
102
|
+
warnings. For multiple tasks read \`tasks[].slots[0].recommendations\`; the
|
|
103
|
+
top-level list is empty. Prefer the cheapest usable option the quality evidence
|
|
104
|
+
supports, without claiming benchmarks prove application accuracy. Use the
|
|
105
|
+
returned provider model ID and the project's actual SDK and protocol.
|
|
106
|
+
|
|
107
|
+
## Boundaries
|
|
108
|
+
|
|
109
|
+
Ask before adding providers or credentials, spending, deploying or external
|
|
110
|
+
writes. Report recommendation, endpoint connectivity and application checks as
|
|
111
|
+
separate results, each only after it succeeds. Do not switch this coding agent's
|
|
112
|
+
own model.
|
|
113
|
+
|
|
114
|
+
If Scout fails or has no suitable candidate/evidence for the required deployment,
|
|
115
|
+
say so and pause the model decision; do not substitute a remembered recommendation
|
|
116
|
+
or SDK default. Continue only model-independent work. Local/browser models are not
|
|
117
|
+
exempt when the catalogue lacks coverage. If it reports that the device key is missing,
|
|
118
|
+
expired or revoked, run \`npx -y openmerit@latest login\` and then
|
|
119
|
+
\`npx -y openmerit@latest install\` again. Never ask the user to paste a key.
|
|
120
|
+
`;
|
|
121
|
+
function scoutRule(client) {
|
|
122
|
+
if (client === "claude-code") return rule;
|
|
123
|
+
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");
|
|
124
|
+
}
|
|
125
|
+
function scoutSkill(client) {
|
|
126
|
+
if (client === "claude-code") return skill;
|
|
127
|
+
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.");
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// packages/pi/src/index.ts
|
|
131
|
+
function configuredCredentialsPath() {
|
|
132
|
+
const config = new URL("./openmerit-scout.json", import.meta.url);
|
|
133
|
+
let value;
|
|
134
|
+
try {
|
|
135
|
+
if (statSync(config).size > 16384) throw new Error("Invalid Scout connection config");
|
|
136
|
+
value = JSON.parse(readFileSync2(config, "utf8"));
|
|
137
|
+
} catch (error) {
|
|
138
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
139
|
+
return credentialsPath("pi", "user", process.cwd());
|
|
140
|
+
}
|
|
141
|
+
throw new Error("Invalid Scout connection config");
|
|
142
|
+
}
|
|
143
|
+
if (!value || typeof value !== "object" || !("credentialsPath" in value) || typeof value.credentialsPath !== "string" || !value.credentialsPath.trim()) {
|
|
144
|
+
throw new Error("Invalid Scout connection config");
|
|
145
|
+
}
|
|
146
|
+
return value.credentialsPath;
|
|
147
|
+
}
|
|
148
|
+
function createScoutPiExtension(options = {}) {
|
|
149
|
+
return (pi) => {
|
|
150
|
+
pi.on("session_start", (_event, ctx) => {
|
|
151
|
+
try {
|
|
152
|
+
const credentials = readCredentials(options.credentialsPath ?? configuredCredentialsPath());
|
|
153
|
+
if (!credentials) throw new Error("Scout credentials missing");
|
|
154
|
+
pi.registerMcpServer("openmerit", {
|
|
155
|
+
type: "http",
|
|
156
|
+
url: `${credentials.server}/scout/mcp`,
|
|
157
|
+
headers: { ...credentials.headers, Authorization: `Bearer ${credentials.key}` },
|
|
158
|
+
exposure: "direct"
|
|
159
|
+
});
|
|
160
|
+
} catch {
|
|
161
|
+
ctx.ui.notify(
|
|
162
|
+
"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().",
|
|
163
|
+
"warning"
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
pi.on("before_agent_start", (event) => {
|
|
168
|
+
event.systemPromptOptions.sections.openmerit_scout_rule = scoutRule("pi");
|
|
169
|
+
event.systemPromptOptions.sections.openmerit_scout_skill = scoutSkill("pi");
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
var index_default = createScoutPiExtension();
|
|
174
|
+
export {
|
|
175
|
+
createScoutPiExtension,
|
|
176
|
+
index_default as default
|
|
177
|
+
};
|
package/dist/pi/src/index.d.ts
CHANGED
|
@@ -1,32 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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;
|