pi-lean-host 0.3.1 → 0.5.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.
@@ -41,26 +41,25 @@ import {
41
41
  invalidateCache,
42
42
  getUserGuidesDir,
43
43
  } from "./guide-store.js";
44
- import {
45
- formatGuideListings,
46
- selectGuideByShortName,
47
- shortNameErrorText,
48
- stampFrontmatterField,
49
- TODAY,
50
- } from "./parse-api-guide.js";
51
- import { pickGuide } from "./guide-picker.js";
44
+ import { stampFrontmatterField, TODAY } from "./parse-api-guide.js";
45
+ import { pickGuideForCommand } from "./guide-picker.js";
52
46
  import {
53
47
  resolveSecretHeaders,
54
48
  resolveSecretQueryParams,
49
+ resolveSecretPathParams,
50
+ missingRequiredSecrets,
51
+ secretPathTokenNames,
55
52
  canonicalStoreDomain,
53
+ hasUsableTokenPath,
56
54
  } from "./auth.js";
55
+ import { readSecret } from "./secrets-store.js";
57
56
  import { resolveOpForExecution, type ResolveOpResult } from "./resolve-op.js";
58
57
  import {
59
58
  HelperError,
60
59
  type RestGetResult,
61
60
  type PaginateResult,
62
61
  } from "./helpers.js";
63
- import type { ApiGuide, Operation } from "./api-guide-types.js";
62
+ import type { Operation } from "./api-guide-types.js";
64
63
 
65
64
  /** Usage + cost note, surfaced by `--help`. */
66
65
  function helpText(): string {
@@ -71,9 +70,12 @@ function helpText(): string {
71
70
  " /api verify <domain> --force stamp verified: today WITHOUT running any ops (human-attested)",
72
71
  " /api verify --help this help",
73
72
  "",
74
- " Ops with unsatisfiable params (a path {token} or required query param with no default)",
75
- " are skipped, not failed. Supply them via a co-located verify.json:",
76
- ` ~/.pi/agent/pi-lean-host/api-guides/<domain>/verify.json`,
73
+ " Ops with unsatisfiable params (a path {token} not store-filled via secretPathRefs, or a",
74
+ " required query param with no default) are skipped, not failed. Scaffold a starter sidecar",
75
+ " with api-scaffold({domain, verify: true})",
76
+ ' (writes to /tmp, with "__FILL_ME__" sentinels for every blocking param), then save via',
77
+ " api-learn({domain, dir}) — the sidecar lives at:",
78
+ ` ~/.pi/agent/pi-lean-host/api-guides/<dirName>/verify.json`,
77
79
  ` { "<opName>": { "<param>": "<value>" } }`,
78
80
  "",
79
81
  " Not free: N live HTTP requests against the target API (GET only — no mutation).",
@@ -122,41 +124,14 @@ export async function handleVerifySubcommand(
122
124
  return;
123
125
  }
124
126
 
125
- let selected: { guide: ApiGuide; dirName: string };
126
- if (matches.length === 1) {
127
- selected = matches[0]!;
128
- } else if (guideSelector) {
129
- const sel = selectGuideByShortName(matches, guideSelector);
130
- if (!sel.ok) {
131
- ctx.ui.notify(
132
- shortNameErrorText(
133
- sel,
134
- domain,
135
- guideSelector,
136
- `Call /api verify ${domain} to see the menu.`,
137
- ),
138
- "warning",
139
- );
140
- return;
141
- }
142
- selected = sel;
143
- } else {
144
- // N guides, no selector → interactive pick (TUI) or the menu
145
- // fallback (headless/RPC/print or cancelled), nothing run yet.
146
- const picked = await pickGuide(ctx, matches);
147
- if (!picked) {
148
- ctx.ui.notify(
149
- [
150
- `${matches.length} API guides for '${domain}':`,
151
- formatGuideListings(matches),
152
- `Call /api verify ${domain} <shortName> to pick one.`,
153
- ].join("\n"),
154
- "info",
155
- );
156
- return;
157
- }
158
- selected = picked;
159
- }
127
+ const selected = await pickGuideForCommand(
128
+ ctx,
129
+ domain,
130
+ guideSelector,
131
+ matches,
132
+ "/api verify",
133
+ );
134
+ if (!selected) return;
160
135
 
161
136
  const { guide, dirName } = selected;
162
137
  const storeDomain = canonicalStoreDomain(guide);
@@ -173,24 +148,54 @@ export async function handleVerifySubcommand(
173
148
  return;
174
149
  }
175
150
 
176
- // Auth precheck (fail-fast): resolve the same secrets api-fetch does. If
177
- // any `requires` secret is unprovisioned, short-circuit with ONE message —
178
- // do not run N ops that all fail identically.
179
- if (guide.auth.kind === "static-key") {
180
- const headerRes = resolveSecretHeaders(guide.auth, storeDomain);
181
- const queryRes = resolveSecretQueryParams(guide.auth, storeDomain);
182
- const missingRequired = [
183
- ...headerRes.absentRequired,
184
- ...queryRes.absentRequired,
185
- ];
186
- if (missingRequired.length > 0) {
187
- ctx.ui.notify(
188
- `🔑 ${guide.shortName} requires a secret not yet provisioned: ` +
189
- `${missingRequired.join(", ")}.\n` +
190
- `Run /api secrets ${storeDomain} to provision it, then re-run /api verify.`,
191
- "warning",
192
- );
193
- return;
151
+ // Auth precheck (fail-fast): resolve the same secrets/token api-fetch does.
152
+ // If a required secret is unprovisioned or no OAuth2 token is mintable,
153
+ // short-circuit with ONE message — do not run N ops that all fail
154
+ // identically.
155
+ switch (guide.auth.kind) {
156
+ case "static-key": {
157
+ const headerRes = resolveSecretHeaders(guide.auth, storeDomain);
158
+ const queryRes = resolveSecretQueryParams(guide.auth, storeDomain);
159
+ const pathRes = resolveSecretPathParams(guide.auth, storeDomain);
160
+ const missingRequired = missingRequiredSecrets(headerRes, queryRes, pathRes);
161
+ if (missingRequired.length > 0) {
162
+ ctx.ui.notify(
163
+ `🔑 ${guide.shortName} requires a secret not yet provisioned: ` +
164
+ `${missingRequired.join(", ")}.\n` +
165
+ `Run /api secrets ${storeDomain} to provision it, then re-run /api verify.`,
166
+ "warning",
167
+ );
168
+ return;
169
+ }
170
+ break;
171
+ }
172
+ case "oauth2": {
173
+ if (!hasUsableTokenPath(guide.auth, storeDomain)) {
174
+ // client_credentials reaching here ⇒ at least one credential secret
175
+ // is unprovisioned (hasUsableTokenPath would have returned true
176
+ // otherwise) — name the missing ones like the static-key arm above.
177
+ const missingCreds = [
178
+ guide.auth.clientId.secret,
179
+ ...(guide.auth.clientSecret ? [guide.auth.clientSecret.secret] : []),
180
+ ].filter((name) => readSecret(storeDomain, name) === null);
181
+ const hint =
182
+ guide.auth.grant === "authorization_code"
183
+ ? `Run /api oauth ${storeDomain} to start the interactive flow`
184
+ : `Provision ${missingCreds.join(", ")} via /api secrets ${storeDomain}, then run /api oauth ${storeDomain}`;
185
+ ctx.ui.notify(
186
+ `🔑 ${guide.shortName} has no usable OAuth2 token for '${storeDomain}'.\n` +
187
+ `${hint}, then re-run /api verify.`,
188
+ "warning",
189
+ );
190
+ return;
191
+ }
192
+ break;
193
+ }
194
+ case "none":
195
+ break;
196
+ default: {
197
+ const _exhaustive: never = guide.auth;
198
+ throw new Error(`Unhandled auth kind: ${_exhaustive}`);
194
199
  }
195
200
  }
196
201
 
@@ -205,6 +210,10 @@ export async function handleVerifySubcommand(
205
210
  }
206
211
  const verifyJson = sidecar && "data" in sidecar ? sidecar.data : {};
207
212
 
213
+ // Path tokens owned by secretPathRefs are store-filled, never
214
+ // caller-supplied — never unsatisfiable.
215
+ const secretPathTokens = secretPathTokenNames(guide.auth);
216
+
208
217
  // ── Fetch loop ──────────────────────────────────────────────
209
218
  const ops = guide.operations;
210
219
  const report: string[] = [];
@@ -213,53 +222,95 @@ export async function handleVerifySubcommand(
213
222
  let skipped = 0;
214
223
 
215
224
  for (const op of ops) {
216
- const supplied = verifyJson[op.name] ?? {};
217
- const missing = unsatisfiableParams(op, supplied);
225
+ // Strip `"__FILL_ME__"` sentinels (from verify.json / api-scaffold) so
226
+ // they never count as supplied params or serialize into the query string.
227
+ const rawSupplied = verifyJson[op.name] ?? {};
228
+ const supplied: Record<string, unknown> = {};
229
+ for (const [k, v] of Object.entries(rawSupplied)) {
230
+ if (v !== "__FILL_ME__") supplied[k] = v;
231
+ }
232
+ const missing = renderForReport(
233
+ unsatisfiable(op, supplied, secretPathTokens),
234
+ );
218
235
  if (missing.length > 0) {
219
236
  skipped++;
220
237
  report.push(
221
- ` ⏭ ${op.name} — skipped: requires agent-supplied params (${missing.join(", ")}) — verify manually via api-fetch`,
238
+ ` ⏭ ${op.name} — skipped: requires agent-supplied params (${missing.join(", ")}) — scaffold via api-scaffold({domain, verify: true}), or verify manually via api-fetch`,
222
239
  );
223
240
  continue;
224
241
  }
225
242
 
226
- let outcome: ResolveOpResult;
227
- try {
228
- outcome = await resolveOpForExecution(guide, op, dirName, {
229
- userParams: supplied,
230
- });
231
- } catch (err) {
232
- failed++;
233
- const msg =
234
- err instanceof HelperError
235
- ? err.message
236
- : err instanceof Error
243
+ // Fan-out: a requiresAnyOf group with >1 supplied member is verified
244
+ // once per member, isolating that member (non-group params carried on
245
+ // every run). Mutually-exclusive peers (id ⊻ symbol) never ride the
246
+ // same request; inclusive-OR filters get per-peer coverage. ≤1 supplied
247
+ // member → today's single run. Sentinels are already stripped above, so
248
+ // a partially-filled file still runs just the real values.
249
+ const group = op.requiresAnyOf ?? [];
250
+ const suppliedMembers = group.filter((m) => supplied[m] !== undefined);
251
+ const runs =
252
+ suppliedMembers.length > 1
253
+ ? suppliedMembers.map((m) => {
254
+ const params = { ...supplied };
255
+ for (const peer of group) {
256
+ if (peer !== m) delete params[peer];
257
+ }
258
+ return { params, tag: m };
259
+ })
260
+ : [{ params: supplied, tag: undefined }];
261
+
262
+ for (const run of runs) {
263
+ let outcome: ResolveOpResult;
264
+ try {
265
+ outcome = await resolveOpForExecution(guide, op, dirName, {
266
+ userParams: run.params,
267
+ // Verify's whole point is a live check — never validate against
268
+ // a cached body. Auth-bearing ops never touch the cache anyway;
269
+ // this is belt-and-braces for no-auth guides.
270
+ fresh: true,
271
+ });
272
+ } catch (err) {
273
+ failed++;
274
+ const msg =
275
+ err instanceof HelperError
237
276
  ? err.message
238
- : String(err);
239
- report.push(` ✗ ${op.name} — ${msg}`);
240
- continue;
241
- }
277
+ : err instanceof Error
278
+ ? err.message
279
+ : String(err);
280
+ report.push(` ✗ ${opTag(op.name, run.tag)} — ${msg}`);
281
+ continue;
282
+ }
242
283
 
243
- if (!outcome.ok) {
244
- if (outcome.reason === "helper_disabled") {
245
- // Session-persistent condition — unverifiable this session, not broken.
246
- skipped++;
284
+ if (!outcome.ok) {
285
+ if (outcome.reason === "helper_disabled") {
286
+ // Session-persistent condition — unverifiable this session, not broken.
287
+ skipped++;
288
+ report.push(
289
+ ` ⏭ ${opTag(op.name, run.tag)} — skipped: local helper disabled this session (${outcome.message})`,
290
+ );
291
+ // Disabled helpers are session-persistent and deterministic — the
292
+ // remaining fan-out runs would skip identically, so stop here.
293
+ break;
294
+ }
295
+ if (outcome.reason === "oauth_token_missing") {
296
+ // Unmintable OAuth2 token — same nudge for every op, so fail once
297
+ // (the auth precheck will fail-fast before the loop).
298
+ failed++;
299
+ report.push(` ✗ ${opTag(op.name, run.tag)} — ${outcome.message}`);
300
+ continue;
301
+ }
302
+ // auth_required_not_provisioned — unreachable after the precheck
303
+ // (auth is per-guide constant); defensive.
304
+ failed++;
247
305
  report.push(
248
- ` ⏭ ${op.name} — skipped: local helper disabled this session (${outcome.message})`,
306
+ ` ✗ ${opTag(op.name, run.tag)} — requires secret not provisioned: ${outcome.missing.join(", ")}`,
249
307
  );
250
308
  continue;
251
309
  }
252
- // auth_required_not_provisioned — unreachable after the precheck
253
- // (auth is per-guide constant); defensive.
254
- failed++;
255
- report.push(
256
- ` ✗ ${op.name} — requires secret not provisioned: ${outcome.missing.join(", ")}`,
257
- );
258
- continue;
259
- }
260
310
 
261
- ran++;
262
- report.push(opLine(outcome, op));
311
+ ran++;
312
+ report.push(opLine(outcome, op, run.tag));
313
+ }
263
314
  }
264
315
 
265
316
  const header = `📡 Verify: ${guide.shortName} (${dirName})`;
@@ -285,7 +336,7 @@ export async function handleVerifySubcommand(
285
336
  summary,
286
337
  ...report,
287
338
  "",
288
- `⚠ NOT stamped — all ops skipped. Supply params via verify.json (${dirName}/verify.json), or verify manually via api-fetch.`,
339
+ `⚠ NOT stamped — all ops skipped. Scaffold a verify.json via api-scaffold({domain: "${domain}", verify: true}), or supply params via ${dirName}/verify.json, or verify manually via api-fetch.`,
289
340
  ].join("\n"),
290
341
  "warning",
291
342
  );
@@ -310,29 +361,44 @@ export async function handleVerifySubcommand(
310
361
  // ═══════════════════════════════════════════════════════════════════
311
362
 
312
363
  /**
313
- * The params an op still needs to run: path `{token}`s (never defaultable —
314
- * they're filled from the params map), `required: true` query params with no
315
- * default, and an unsatisfied `requiresAnyOf` group. Anything the executor
316
- * would throw on before making a request.
364
+ * Why an op can't run yet: a path `{token}` (never defaultable — filled from
365
+ * the params map), a `required: true` query param with no default, or an
366
+ * unsatisfied `requiresAnyOf` group. Anything the executor would throw on
367
+ * before making a request.
368
+ *
369
+ * A `requiresAnyOf` group contributes ONE group-level entry when no member is
370
+ * supplied; group members are governed by the group, not per-param required
371
+ * (the parser bans `required: true` on them), so they're skipped in the
372
+ * per-param loop.
317
373
  *
318
- * A `requiresAnyOf` group contributes ONE group-level reason when no member
319
- * is supplied; group members are governed by the group, not per-param
320
- * required (the parser bans `required: true` on them), so they're skipped
321
- * in the per-param loop.
374
+ * `secretPathTokens`: path-token names owned by the guide's
375
+ * `auth.secretPathRefs` — store-filled, never caller-supplied, so never
376
+ * unsatisfiable. Both call sites (verify-command loop + api-scaffold
377
+ * sentinels) must pass it, or secret-owned tokens get misreported as
378
+ * needing a verify.json sentinel.
322
379
  */
323
- function unsatisfiableParams(
380
+ export type Unsatisfiable =
381
+ | { kind: "path"; param: string }
382
+ | { kind: "group"; members: string[] }
383
+ | { kind: "query"; param: string };
384
+
385
+ /** The params an op still needs to run, as structured entries. */
386
+ export function unsatisfiable(
324
387
  op: Operation,
325
388
  supplied: Record<string, unknown>,
326
- ): string[] {
327
- const missing: string[] = [];
389
+ secretPathTokens?: ReadonlySet<string>,
390
+ ): Unsatisfiable[] {
391
+ const missing: Unsatisfiable[] = [];
328
392
  for (const token of op.pathParams) {
329
- if (supplied[token] === undefined) missing.push(token);
393
+ if (secretPathTokens?.has(token)) continue; // store-filled (secretPathRefs)
394
+ if (supplied[token] === undefined)
395
+ missing.push({ kind: "path", param: token });
330
396
  }
331
397
  const group = op.requiresAnyOf;
332
398
  const groupMember = new Set(group ?? []);
333
399
  if (group && group.length > 0) {
334
400
  const anySupplied = group.some((name) => supplied[name] !== undefined);
335
- if (!anySupplied) missing.push(`one of: ${group.join(", ")}`);
401
+ if (!anySupplied) missing.push({ kind: "group", members: group });
336
402
  }
337
403
  for (const [key, spec] of Object.entries(op.params)) {
338
404
  if (groupMember.has(key)) continue; // governed by the group
@@ -341,14 +407,40 @@ function unsatisfiableParams(
341
407
  spec.default === undefined &&
342
408
  supplied[key] === undefined
343
409
  ) {
344
- missing.push(key);
410
+ missing.push({ kind: "query", param: key });
345
411
  }
346
412
  }
347
413
  return missing;
348
414
  }
349
415
 
416
+ /** Render unsatisfiable entries exactly as the verify report shows them. */
417
+ function renderForReport(items: Unsatisfiable[]): string[] {
418
+ return items.map((item) => {
419
+ switch (item.kind) {
420
+ case "group":
421
+ return `one of: ${item.members.join(", ")}`;
422
+ case "path":
423
+ case "query":
424
+ return item.param;
425
+ }
426
+ });
427
+ }
428
+
429
+ /** Render unsatisfiable entries as one sentinel key per param. */
430
+ export function renderForSentinels(items: Unsatisfiable[]): string[] {
431
+ return items.flatMap((item) => {
432
+ switch (item.kind) {
433
+ case "group":
434
+ return item.members;
435
+ case "path":
436
+ case "query":
437
+ return [item.param];
438
+ }
439
+ });
440
+ }
441
+
350
442
  /** Load the co-located verify.json sidecar, best-effort. */
351
- function loadVerifyJson(
443
+ export function loadVerifyJson(
352
444
  dirName: string,
353
445
  ):
354
446
  | { data: Record<string, Record<string, unknown>> }
@@ -367,22 +459,29 @@ function loadVerifyJson(
367
459
  }
368
460
  }
369
461
 
462
+ /** `name (member)` when a fan-out run is tagged, else `name`. */
463
+ function opTag(name: string, tag?: string): string {
464
+ return tag === undefined ? name : `${name} (${tag})`;
465
+ }
466
+
370
467
  /** One report line for a successful op run. A transform warning is noted but
371
468
  * non-blocking — the HTTP op succeeded, so the op counts as pass. */
372
469
  function opLine(
373
470
  outcome: Extract<ResolveOpResult, { ok: true }>,
374
471
  op: Operation,
472
+ tag?: string,
375
473
  ): string {
474
+ const name = opTag(op.name, tag);
376
475
  if (outcome.via === "restGet") {
377
476
  const r = outcome.result as RestGetResult;
378
477
  const warn =
379
478
  r.transformWarning === undefined
380
479
  ? ""
381
480
  : ` — transform warning: ${r.transformWarning}`;
382
- return ` ✓ ${op.name} — ${op.path} (restGet)${warn}`;
481
+ return ` ✓ ${name} — ${op.path} (restGet)${warn}`;
383
482
  }
384
483
  const r = outcome.result as PaginateResult;
385
- return ` ✓ ${op.name} — ${r.totalFetched} item(s) (paginate)`;
484
+ return ` ✓ ${name} — ${r.totalFetched} item(s) (paginate)`;
386
485
  }
387
486
 
388
487
  /**
@@ -0,0 +1,56 @@
1
+ # Migrating guides to schema v1
2
+
3
+ > Fix for guides rejected with `schemaVersion: 0` (or no `schemaVersion`
4
+ > line). One breaking change: static-key auth went flat → nested.
5
+
6
+ ## Before (v0) → After (v1)
7
+
8
+ ```yaml
9
+ # v0
10
+ auth:
11
+ kind: static-key
12
+ requires: [api_key] # deleted
13
+ optional: [user_key] # deleted
14
+ headerPrefixes:
15
+ Authorization: "Bearer " # deleted
16
+ secretRefs:
17
+ Authorization: api_key
18
+ X-Api-Key: user_key
19
+ ```
20
+
21
+ ```yaml
22
+ # v1
23
+ schemaVersion: 1
24
+ auth:
25
+ kind: static-key
26
+ secretRefs:
27
+ Authorization:
28
+ secret: api_key # store name (was a bare string)
29
+ prefix: "Bearer " # from headerPrefixes
30
+ X-Api-Key:
31
+ secret: user_key
32
+ optional: true # from the optional roster
33
+ ```
34
+
35
+ | v0 | v1 |
36
+ |----|-----|
37
+ | `secretRefs: {<header>: <name>}` | `secretRefs: {<header>: {secret: <name>}}` |
38
+ | `requires: [<name>]` | delete — required is the default |
39
+ | `optional: [<name>]` | `optional: true` on the ref that uses it |
40
+ | `headerPrefixes: {<header>: "<p>"}` | `prefix: "<p>"` on that header's ref |
41
+ | no `schemaVersion` line | add `schemaVersion: 1` |
42
+
43
+ Fix = stamp `schemaVersion: 1`, wrap each flat `secretRefs` value as
44
+ `{secret: <name>}`, merge in `requires`/`optional`/`headerPrefixes`.
45
+
46
+ ## Non-events
47
+
48
+ Additive changes (optional fields, new enum values, relaxed constraints)
49
+ never bump the version. Guides saved via current `api-learn` are stamped
50
+ already.
51
+
52
+ ## Shelf life
53
+
54
+ Stays as long as v0 guides can exist: user-authored local guides
55
+ (`~/.pi/agent/pi-lean-host/api-guides/`) can hit the gate long after it
56
+ ships. Superseded only by a v2 migration doc.
package/index.ts CHANGED
@@ -1,13 +1,15 @@
1
1
  import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
2
 
3
- import {
4
- apiGuideTool,
5
- apiFetchTool,
6
- apiLearnTool,
7
- apiProbeTool,
8
- } from "./tools/index.js";
3
+ import { apiGuideTool } from "./tools/api-guide.js";
4
+ import { apiFetchTool } from "./tools/api-fetch.js";
5
+ import { apiLearnTool } from "./tools/api-learn.js";
6
+ import { apiProbeTool } from "./tools/api-probe.js";
7
+ import { apiScaffoldTool } from "./tools/api-scaffold.js";
8
+ import { apiStoreTool } from "./tools/api-store.js";
9
+ import { oauthMintTool } from "./tools/oauth-mint.js";
9
10
  import initApiToggle from "./core/api-toggle.js";
10
11
  import { registerPortalProjection } from "./core/portal-projection.js";
12
+ import { invalidateCache, loadAllGuides } from "./core/guide-store.js";
11
13
  import { cleanupAllSpill } from "./core/response-spill.js";
12
14
  import { resetToggleModuleState } from "./core/api-toggle.js";
13
15
  import { resetDisabledHelpers } from "./core/local-helpers.js";
@@ -24,6 +26,9 @@ export default function (pi: ExtensionAPI): void {
24
26
  pi.registerTool(apiFetchTool);
25
27
  pi.registerTool(apiLearnTool);
26
28
  pi.registerTool(apiProbeTool);
29
+ pi.registerTool(apiScaffoldTool);
30
+ pi.registerTool(apiStoreTool);
31
+ pi.registerTool(oauthMintTool);
27
32
 
28
33
  // ── Register /api command and session hooks ─────────────────
29
34
  initApiToggle(pi);
@@ -33,8 +38,20 @@ export default function (pi: ExtensionAPI): void {
33
38
  // Runtime feature-detect — no static portal import.
34
39
  registerPortalProjection();
35
40
  // session_start ensures registration even if host loads before portal.
36
- pi.on("session_start", async () => {
41
+ pi.on("session_start", async (_event, ctx) => {
37
42
  registerPortalProjection();
43
+ // Clear the guide-store cache so a folder rename (fixing the divergence
44
+ // check's "mv" instruction) made between sessions is picked up —
45
+ // regardless of whether pi re-evaluates the module or re-calls the entry
46
+ // function with persisted module-level state (the /resume path).
47
+ invalidateCache();
48
+ // Trigger a fresh scan with the UI notify channel so the schema-gate
49
+ // banner + per-guide warnings render through the Text component (wraps
50
+ // long lines, honors newlines) instead of raw console.warn (truncates
51
+ // + merges with the status bar). No-op on a warm cache; every later
52
+ // command/tool call hits the cached scan, so this is the single
53
+ // load-time warning point.
54
+ loadAllGuides(ctx.ui.notify);
38
55
  });
39
56
 
40
57
  // ── Response spill cleanup ─────────────────────────────────
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pi-lean-host",
3
- "version": "0.3.1",
4
- "description": "REST API client for Pi. A YAML file per API covers endpoints and pagination; the agent calls through a fixed executor so an API encoded once is reusable forever, not re-derived each session. It can probe a live endpoint and write the YAML for you, and a TypeScript file alongside can add custom auth or reshape the request and response freely.",
3
+ "version": "0.5.0",
4
+ "description": "Read-only REST API client for Pi. Your agent authors and calls YAML recipes handling the tedious parts: pagination, OAuth2, rate limits, backoff. Credentials live in a local store, injected in code, never in agent context. Churn-free research + retrieval",
5
5
  "keywords": [
6
6
  "pi-package",
7
7
  "pi-extension",
@@ -25,23 +25,28 @@
25
25
  ".": "./index.ts",
26
26
  "./core/helpers.js": "./core/helpers.ts",
27
27
  "./core/parse-api-guide.js": "./core/parse-api-guide.ts",
28
+ "./core/guide-catalog.js": "./core/guide-catalog.ts",
28
29
  "./core/guide-store.js": "./core/guide-store.ts",
29
30
  "./core/local-helpers.js": "./core/local-helpers.ts",
30
31
  "./core/api-guide-types.js": "./core/api-guide-types.ts",
31
32
  "./core/transport.js": "./core/transport.ts",
32
- "./core/auth.js": "./core/auth.ts"
33
+ "./core/auth.js": "./core/auth.ts",
34
+ "./core/resolve-op.js": "./core/resolve-op.ts"
33
35
  },
34
36
  "files": [
35
37
  "index.ts",
36
38
  "LICENSE",
37
39
  "core/ssrf-guard.ts",
40
+ "core/status-hint.ts",
38
41
  "core/guide-loader.ts",
39
42
  "core/api-guide-types.ts",
40
43
  "core/parse-api-guide.ts",
44
+ "core/guide-catalog.ts",
41
45
  "core/guide-store.ts",
42
46
  "core/transport.ts",
43
47
  "core/helpers.ts",
44
48
  "core/path-template.ts",
49
+ "core/fs-0600.ts",
45
50
  "core/local-helpers.ts",
46
51
  "core/helpers-command.ts",
47
52
  "core/api-toggle.ts",
@@ -52,15 +57,22 @@
52
57
  "core/response-spill.ts",
53
58
  "core/resolve-op.ts",
54
59
  "core/guide-picker.ts",
60
+ "core/select-picker.ts",
55
61
  "core/verify-command.ts",
56
62
  "core/delete-command.ts",
57
- "core/verify-ship-manifest.ts",
58
- "tools/index.ts",
63
+ "core/oauth-store.ts",
64
+ "core/oauth-command.ts",
65
+ "core/oauth-flow.ts",
66
+ "core/staging.ts",
59
67
  "tools/api-guide.ts",
60
68
  "tools/api-fetch.ts",
61
69
  "tools/api-learn.ts",
70
+ "tools/api-scaffold.ts",
71
+ "tools/api-store.ts",
72
+ "tools/oauth-mint.ts",
62
73
  "tools/api-probe.ts",
63
74
  "tools/utils.ts",
75
+ "docs/migration-v1.md",
64
76
  "README.md"
65
77
  ],
66
78
  "pi": {
@@ -74,7 +86,7 @@
74
86
  },
75
87
  "dependencies": {
76
88
  "fast-xml-parser": "^5.7.0",
77
- "pi-tool-masking": "^1.2.3",
89
+ "pi-tool-masking": "^1.3.0",
78
90
  "undici": "^8.0.0",
79
91
  "yaml": "^2.7.0"
80
92
  },