pi-lean-host 0.2.1 → 0.3.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.
@@ -31,12 +31,9 @@ import {
31
31
  resolveSecretQueryParams,
32
32
  scrubSecretValues,
33
33
  } from "../core/auth.js";
34
- import {
35
- listDomains,
36
- listNames,
37
- provisionedDomainsSuffix,
38
- } from "../core/secrets-store.js";
34
+ import { listDomains, listNames } from "../core/secrets-store.js";
39
35
  import { findGuidesByDomain } from "../core/guide-store.js";
36
+ import { GUIDE_SCHEMA_VERSION } from "../core/api-guide-types.js";
40
37
  import { isApiLearnEnabled } from "../core/api-toggle.js";
41
38
  import { appendFooter, contentText } from "./utils.js";
42
39
 
@@ -74,6 +71,9 @@ export interface ProbeResult {
74
71
  raw: string;
75
72
  /** Human note (auth-required, 404, version-prefix hit, non-JSON, …). */
76
73
  note?: string;
74
+ /** True when the caller didn't pass scaffold: true and no guide claims the
75
+ * domain yet — the authoring loop should surface the skeleton option. */
76
+ scaffoldNudge?: boolean;
77
77
  }
78
78
 
79
79
  export interface ProbeOptions {
@@ -87,6 +87,7 @@ export interface ProbeOptions {
87
87
  * Values resolve from the secrets store and never enter the transcript.
88
88
  */
89
89
  auth?: {
90
+ /** Maps header name → secret name, same direction as the guide schema. */
90
91
  secretRefs?: Record<string, string>;
91
92
  secretQueryRefs?: Record<string, string>;
92
93
  /**
@@ -96,8 +97,15 @@ export interface ProbeOptions {
96
97
  */
97
98
  headerPrefixes?: Record<string, string>;
98
99
  };
99
- /** Domain for secrets-store lookups; defaults to apiHost's hostname. */
100
+ /** Domain for secrets-store lookups; defaults to apiHost's hostname (or its provisioned parent domain). */
100
101
  domain?: string;
102
+ /**
103
+ * Emit a full recipe skeleton (frontmatter + auth + operations) when no
104
+ * guide exists for the domain; auto-degrades to a single op block + merge
105
+ * note when one or more guides already claim the domain. Opt-in —
106
+ * without it the output is today's op-block-only draft.
107
+ */
108
+ scaffold?: boolean;
101
109
  }
102
110
 
103
111
  // ═══════════════════════════════════════════════════════════════════
@@ -224,6 +232,9 @@ interface ProbeAuthCtx {
224
232
  secretQueryParamNames: Set<string>;
225
233
  secretValues: string[];
226
234
  missingNames: string[];
235
+ /** headerPrefixes declared but no secretRefs to apply them to — the
236
+ * prefixes would be silently dropped. Surfaced as a note, not an error. */
237
+ misconfiguredPrefixes: boolean;
227
238
  }
228
239
 
229
240
  /**
@@ -237,6 +248,16 @@ function resolveProbeAuth(
237
248
  auth: NonNullable<ProbeOptions["auth"]> | undefined,
238
249
  domain: string,
239
250
  ): ProbeAuthCtx {
251
+ // Computed before the hasRefs check so the flag survives both paths: a
252
+ // headerPrefixes-only block (hasRefs false → early return) and a
253
+ // secretQueryRefs block with prefixes but no secretRefs (hasRefs true →
254
+ // normal path, where resolveSecretHeaders would silently drop the
255
+ // prefixes). Query secrets never take prefixes, so secretQueryRefs is
256
+ // deliberately excluded from the flag.
257
+ const misconfiguredPrefixes =
258
+ !!auth &&
259
+ Object.keys(auth.headerPrefixes ?? {}).length > 0 &&
260
+ Object.keys(auth.secretRefs ?? {}).length === 0;
240
261
  const hasRefs =
241
262
  !!auth &&
242
263
  (Object.keys(auth.secretRefs ?? {}).length > 0 ||
@@ -250,6 +271,7 @@ function resolveProbeAuth(
250
271
  secretQueryParamNames: new Set(),
251
272
  secretValues: [],
252
273
  missingNames: [],
274
+ misconfiguredPrefixes,
253
275
  };
254
276
  }
255
277
  const headerRes = resolveSecretHeaders(
@@ -286,16 +308,43 @@ function resolveProbeAuth(
286
308
  ...queryRes.absentRequired,
287
309
  ...queryRes.absentOptional,
288
310
  ],
311
+ misconfiguredPrefixes,
289
312
  };
290
313
  }
291
314
 
292
- /** First missing secret name as a one-line note (names only, never values). */
315
+ /** Root-cause note for a headerPrefixes-only auth block (no secretRefs to
316
+ * apply the prefixes to). `:`/`;` internal separators keep the combined
317
+ * error note from stacking three ` — ` joins when it composes with the
318
+ * 401/403 wording. */
319
+ const MISCONFIGURED_PREFIXES_NOTE =
320
+ "headerPrefixes ignored: no secretRefs to apply them to; put the secret name in auth.secretRefs";
321
+
322
+ /** First missing secret name as a one-line note (names only, never values).
323
+ * Prescriptive: names the other provisioned domains and tells the author to
324
+ * pass `domain:` — the probe's domain is inferred from apiHost, so a miss is
325
+ * usually a domain-mismatch, not a missing secret. */
293
326
  function missNote(authCtx: ProbeAuthCtx, domain: string): string {
294
327
  if (authCtx.missingNames.length === 0) return "";
295
- return (
296
- `secret "${authCtx.missingNames[0]}" not found in store for domain "${domain}"` +
297
- provisionedDomainsSuffix(domain)
298
- );
328
+ const others = listDomains().filter((d) => d !== domain);
329
+ const tail =
330
+ others.length > 0
331
+ ? ` — provisioned domains: ${others.join(", ")}; pass domain: <one> to use its secret`
332
+ : "";
333
+ return `secret "${authCtx.missingNames[0]}" not found in store for domain "${domain}"${tail}`;
334
+ }
335
+
336
+ /** Resolve the secrets-store domain for a probe: the apiHost hostname when it
337
+ * is itself provisioned, else the longest provisioned parent domain
338
+ * (pro-api.coinmarketcap.com → coinmarketcap.com), else the hostname as-is.
339
+ * ponytail: parent-suffix match against the store, not a public-suffix list —
340
+ * no dep, and the store is the source of truth for where secrets live. */
341
+ export function resolveProbeStoreDomain(hostname: string): string {
342
+ const domains = listDomains();
343
+ if (domains.includes(hostname)) return hostname;
344
+ const parent = domains
345
+ .filter((d) => hostname.endsWith(`.${d}`))
346
+ .sort((a, b) => b.length - a.length)[0];
347
+ return parent ?? hostname;
299
348
  }
300
349
 
301
350
  /** Hostname of an apiHost URL (falls back to the raw string). */
@@ -326,7 +375,7 @@ export async function probe(
326
375
  ): Promise<ProbeResult> {
327
376
  const accept = opts.accept ?? "application/json";
328
377
  const walkVersions = opts.walkVersions ?? true;
329
- const domain = opts.domain ?? hostnameOf(apiHost);
378
+ const domain = opts.domain ?? resolveProbeStoreDomain(hostnameOf(apiHost));
330
379
  const authCtx = resolveProbeAuth(opts.auth, domain);
331
380
 
332
381
  // Base case only carries the apiHost version prefix; a walk-hit draft
@@ -339,6 +388,7 @@ export async function probe(
339
388
  authCtx,
340
389
  domain,
341
390
  versionPrefixOf(apiHost),
391
+ opts,
342
392
  );
343
393
  if (base.status !== 404 || !walkVersions || /^\/v\d+\//.test(path)) {
344
394
  return base;
@@ -353,7 +403,7 @@ export async function probe(
353
403
  return base;
354
404
  }
355
405
  const hit = await walkBackward(
356
- { apiHost, path, params, accept, authCtx, domain },
406
+ { apiHost, path, params, accept, authCtx, domain, opts },
357
407
  Number(stated),
358
408
  );
359
409
  return hit ?? base;
@@ -378,6 +428,7 @@ async function walkBackward(
378
428
  accept: string;
379
429
  authCtx: ProbeAuthCtx;
380
430
  domain: string;
431
+ opts: ProbeOptions;
381
432
  },
382
433
  start: number,
383
434
  ): Promise<ProbeResult | null> {
@@ -392,6 +443,7 @@ async function walkBackward(
392
443
  ctx.authCtx,
393
444
  ctx.domain,
394
445
  `/v${k}`,
446
+ ctx.opts,
395
447
  );
396
448
  if (tried.status !== 404) {
397
449
  // A walk hit may itself have redirected (e.g. /v2 301→ /v3); the
@@ -431,6 +483,7 @@ async function fetchOne(
431
483
  authCtx: ProbeAuthCtx,
432
484
  domain: string,
433
485
  prefix = "",
486
+ opts: ProbeOptions = {},
434
487
  ): Promise<ProbeResult> {
435
488
  // Inject secret query params below the agent-supplied params map, then
436
489
  // redact the surfaced URL so the real key never reaches the transcript.
@@ -460,16 +513,26 @@ async function fetchOne(
460
513
  const is401 = res.status === 401 || res.status === 403;
461
514
  const miss = missNote(authCtx, domain);
462
515
  let note: string;
463
- if (authCtx.hasAuthBlock) {
464
- // Auth block present → never the stale auth:none text; report the
465
- // store miss (or a bare requires-auth hint when nothing was missing).
466
- note = `${res.status}${is401 ? " — requires authentication?" : ""}${miss ? ` ${miss}` : ""}`;
516
+ if (!authCtx.hasAuthBlock) {
517
+ // No auth injected — a 401/403 means the endpoint is gated and the
518
+ // probe sent nothing. Pre-guide authoring tool: no guide in scope,
519
+ // so no stale "(guide is auth:none)" wording.
520
+ note = is401
521
+ ? `${res.status} — endpoint requires auth; configure auth injection (auth.secretRefs)`
522
+ : `${res.status}`;
523
+ } else if (miss) {
524
+ // Auth injected but a required secret was missing — the miss names it.
525
+ note = `${res.status}${is401 ? " — auth rejected;" : ""} ${miss}`;
467
526
  } else {
468
- // No auth block → the existing auth:none wording.
527
+ // Auth injected, nothing missing — rejection means the credentials
528
+ // were wrong (header name / secret value), not the endpoint.
469
529
  note = is401
470
- ? `${res.status} — requires authentication? (guide is auth:none)`
530
+ ? `${res.status} — auth injected but rejected; verify header name and secret value`
471
531
  : `${res.status}`;
472
532
  }
533
+ if (authCtx.misconfiguredPrefixes) {
534
+ note += ` — ${MISCONFIGURED_PREFIXES_NOTE}`;
535
+ }
473
536
  return {
474
537
  url,
475
538
  finalUrl,
@@ -501,15 +564,31 @@ async function fetchOne(
501
564
 
502
565
  const shape = summarize(data);
503
566
  const miss = missNote(authCtx, domain);
567
+ let draft = emitDraft(path, params, shape, prefix);
568
+ let note: string | undefined = miss;
569
+ if (opts.scaffold && draft) {
570
+ const sc = emitScaffold({ apiHost, domain, draft, auth: opts.auth });
571
+ draft = sc.draft;
572
+ if (sc.note) note = [note, sc.note].filter(Boolean).join(" — ");
573
+ }
574
+ if (authCtx.misconfiguredPrefixes) {
575
+ note = [note, MISCONFIGURED_PREFIXES_NOTE].filter(Boolean).join(" — ");
576
+ }
577
+ // Targeted scaffold nudge: only when the caller didn't pass
578
+ // scaffold: true AND no guide claims the domain yet — authors who already
579
+ // used the skeleton (or who have a guide) see no noise.
580
+ const scaffoldNudge =
581
+ opts.scaffold !== true && findGuidesByDomain(domain).length === 0;
504
582
  return {
505
583
  url,
506
584
  finalUrl,
507
585
  status: res.status,
508
586
  ok: true,
509
587
  shape,
510
- draft: emitDraft(path, params, shape, prefix),
588
+ draft,
511
589
  raw,
512
- ...(miss ? { note: miss } : {}),
590
+ ...(note ? { note } : {}),
591
+ ...(scaffoldNudge ? { scaffoldNudge } : {}),
513
592
  };
514
593
  }
515
594
 
@@ -571,23 +650,33 @@ export function emitDraft(
571
650
  lines.push(
572
651
  " # unverified — pagination params are guessed from response keys; confirm the API accepts them",
573
652
  );
574
- const style =
575
- shape.paginationMarkers.includes("page") ||
576
- shape.paginationMarkers.includes("per_page")
577
- ? "page"
578
- : "offset-limit";
579
- const pageParam = style === "page" ? "page" : "offset";
580
- const pageSizeParam = style === "page" ? "per_page" : "limit";
653
+ const markers = shape.paginationMarkers;
654
+ const isPageStyle = markers.includes("page") || markers.includes("per_page");
655
+ const style = isPageStyle ? "page" : "offset-limit";
656
+ // `start` marker ⇒ 1-based row offset (CMC, GBIF) — emit base: 1 so the
657
+ // first page starts at 1, not the 0 default. `offset` ⇒ 0-based, no base.
658
+ let pageParam: string;
659
+ if (isPageStyle) pageParam = "page";
660
+ else if (markers.includes("start")) pageParam = "start";
661
+ else pageParam = "offset";
662
+ const pageSizeParam = isPageStyle ? "per_page" : "limit";
663
+ if (style === "offset-limit") {
664
+ lines.push(
665
+ " # offset-limit advances the page param by pageSize each page (row-offset semantics); base seeds the start (1 for `start` params, 0 for `offset`)",
666
+ );
667
+ }
581
668
  lines.push(" pagination:");
582
669
  lines.push(` style: ${style}`);
583
670
  lines.push(` itemsPath: ${shape.suggestedItemsPath}`);
584
671
  lines.push(` pageParam: ${pageParam}`);
585
672
  lines.push(` pageSizeParam: ${pageSizeParam}`);
586
673
  lines.push(" pageSize: 30");
674
+ if (pageParam === "start") lines.push(" base: 1");
587
675
  }
588
676
  if (shape.suggestedVia === "restGet" && shape.suggestedItemsPath !== "") {
589
677
  lines.push(
590
- " # array response with no pagination markers — if the API documents paging, prefer paginate; otherwise use restGet.",
678
+ " # array response with no pagination markers — if the API documents paging, prefer paginate:",
679
+ " # offset-limit advances the page param by pageSize each page (use base: 1 for 1-based `start` APIs like CMC); page increments the page param by 1.",
591
680
  );
592
681
  }
593
682
  if (queryParamKeys.length > 0) {
@@ -614,6 +703,112 @@ function suggestName(path: string): string {
614
703
  .replace(/[^a-zA-Z0-9]/g, "");
615
704
  }
616
705
 
706
+ // ═══════════════════════════════════════════════════════════════════
707
+ // Scaffold emission — full skeleton vs op-block + merge note
708
+ // ═══════════════════════════════════════════════════════════════════
709
+
710
+ /**
711
+ * Translate the probe's auth-injection params into a `kind: static-key` auth
712
+ * block (probe auth shape matches the guide schema).
713
+ * `requires` = the union of secret names referenced by the refs. Returns
714
+ * undefined when no injection refs are declared (auth: none default).
715
+ */
716
+ function emitAuthBlock(
717
+ auth: NonNullable<ProbeOptions["auth"]> | undefined,
718
+ ): string | undefined {
719
+ const refs = auth?.secretRefs ?? {};
720
+ const queryRefs = auth?.secretQueryRefs ?? {};
721
+ const prefixes = auth?.headerPrefixes ?? {};
722
+ const names = [
723
+ ...new Set([...Object.values(refs), ...Object.values(queryRefs)]),
724
+ ];
725
+ if (names.length === 0) return undefined;
726
+ const lines = [
727
+ "auth:",
728
+ " kind: static-key",
729
+ ` requires: [${names.join(", ")}]`,
730
+ ];
731
+ if (Object.keys(refs).length > 0) {
732
+ lines.push(" secretRefs:");
733
+ for (const [header, secret] of Object.entries(refs))
734
+ lines.push(` ${header}: ${secret}`);
735
+ }
736
+ if (Object.keys(queryRefs).length > 0) {
737
+ lines.push(" secretQueryRefs:");
738
+ for (const [param, secret] of Object.entries(queryRefs))
739
+ lines.push(` ${param}: ${secret}`);
740
+ }
741
+ if (Object.keys(prefixes).length > 0) {
742
+ lines.push(" headerPrefixes:");
743
+ for (const [header, prefix] of Object.entries(prefixes))
744
+ lines.push(` ${header}: "${prefix}"`);
745
+ }
746
+ return lines.join("\n");
747
+ }
748
+
749
+ /**
750
+ * Full recipe skeleton (bootstrap): frontmatter + auth + the probe's op
751
+ * block. `schemaVersion` literal matches what api-learn stamps on save, so a
752
+ * scaffolded guide is detection-ready the moment it's saved. Pagination stays
753
+ * op-level only (a single probe justifies one op's pagination, never a
754
+ * top-level default).
755
+ */
756
+ function emitScaffoldSkeleton(opts: {
757
+ apiHost: string;
758
+ domain: string;
759
+ draft: string;
760
+ auth: ProbeOptions["auth"];
761
+ }): string {
762
+ const lines = [
763
+ "---",
764
+ "kind: api",
765
+ `domains: [${opts.domain}]`,
766
+ `apiHost: ${opts.apiHost}`,
767
+ "responseShape:",
768
+ " format: json",
769
+ "gatherAllMax: 1000",
770
+ `schemaVersion: ${GUIDE_SCHEMA_VERSION}`,
771
+ ];
772
+ const authBlock = emitAuthBlock(opts.auth);
773
+ if (authBlock) lines.push("", authBlock);
774
+ // Op-level hint for the new constraint field — commented so a fresh
775
+ // scaffold surfaces the mechanism (mirrors placeholderSkeleton).
776
+ lines.push(
777
+ "",
778
+ "# requiresAnyOf: [id, slug, code] # at least one of these params must be supplied",
779
+ "operations:",
780
+ opts.draft,
781
+ "---",
782
+ "",
783
+ );
784
+ return lines.join("\n");
785
+ }
786
+
787
+ /**
788
+ * Scaffold decision, driven by findGuidesByDomain(domain): 0 guides →
789
+ * full skeleton (bootstrap); 1 guide → op block + merge note naming the one
790
+ * dirName; N guides → op block + merge note listing every candidate dirName
791
+ * (the merge-target choice defers to api-learn's selector). Returns the
792
+ * paste-able draft + an optional human merge note.
793
+ */
794
+ function emitScaffold(opts: {
795
+ apiHost: string;
796
+ domain: string;
797
+ draft: string;
798
+ auth: ProbeOptions["auth"];
799
+ }): { draft: string; note?: string } {
800
+ const matches = findGuidesByDomain(opts.domain);
801
+ if (matches.length === 0) {
802
+ return { draft: emitScaffoldSkeleton(opts) };
803
+ }
804
+ const dirs = matches.map((m) => m.dirName);
805
+ const note =
806
+ matches.length === 1
807
+ ? `scaffold: guide already exists — merge into \`${dirs[0]}\``
808
+ : `scaffold: ${matches.length} guides already exist — merge into one of: ${dirs.join(", ")}`;
809
+ return { draft: opts.draft, note };
810
+ }
811
+
617
812
  // ═══════════════════════════════════════════════════════════════════
618
813
  // Tool definition
619
814
  // ═══════════════════════════════════════════════════════════════════
@@ -637,7 +832,10 @@ export const apiProbeTool = defineTool({
637
832
  "version — then probe that version explicitly. Do not default the version from " +
638
833
  "memory: a stale version that still returns 200 is not detected as old (the " +
639
834
  "backward walk only fires on 404). The probe recovers an over-claimed version " +
640
- "but cannot detect a stale-but-working one.",
835
+ "but cannot detect a stale-but-working one. " +
836
+ "Pass scaffold: true to emit a full recipe skeleton (frontmatter + auth + " +
837
+ "operations) when no guide exists for the domain; it auto-degrades to a single " +
838
+ "op block + merge note when one or more guides already claim the domain.",
641
839
 
642
840
  parameters: Type.Object({
643
841
  apiHost: Type.Optional(
@@ -669,6 +867,14 @@ export const apiProbeTool = defineTool({
669
867
  "On 404, walk the apiHost version backward (vN→v1) to find the highest live version. Default true.",
670
868
  }),
671
869
  ),
870
+ scaffold: Type.Optional(
871
+ Type.Boolean({
872
+ description:
873
+ "Emit a full recipe skeleton (frontmatter + auth + operations) when no guide exists for the domain; " +
874
+ "auto-degrades to a single op block + merge note when one or more guides already claim the domain. " +
875
+ "Opt-in — without it the output is today's op-block-only draft.",
876
+ }),
877
+ ),
672
878
  auth: Type.Optional(
673
879
  Type.Object(
674
880
  {
@@ -678,8 +884,10 @@ export const apiProbeTool = defineTool({
678
884
  },
679
885
  {
680
886
  description:
681
- "Store-backed auth injection for probing auth-gated endpoints (authoring loop). Injection fields only — values resolve from the secrets store and never enter the transcript; a store miss fetches unauthenticated and reports the miss in the note.",
887
+ "Store-backed auth injection for probing auth-gated endpoints (authoring loop). Accepts only secretRefs, secretQueryRefs, and headerPrefixes. Values resolve from the secrets store and never enter the transcript; a store miss fetches unauthenticated and reports the miss in the note.",
682
888
  // Tight: unknown keys (e.g. a stray `domain`) are rejected before execute runs.
889
+ // The description above names the allowed fields explicitly — keep it in
890
+ // sync when adding/renaming a field here, or the prose lies to agents.
683
891
  additionalProperties: false,
684
892
  },
685
893
  ),
@@ -687,7 +895,7 @@ export const apiProbeTool = defineTool({
687
895
  domain: Type.Optional(
688
896
  Type.String({
689
897
  description:
690
- "Domain for secrets-store lookups; defaults to apiHost's hostname.",
898
+ "Domain for secrets-store lookups; defaults to apiHost's hostname (or its provisioned parent domain).",
691
899
  }),
692
900
  ),
693
901
  listSecrets: Type.Optional(
@@ -703,18 +911,21 @@ export const apiProbeTool = defineTool({
703
911
  }),
704
912
 
705
913
  async execute(_toolCallId, params, _signal, _onUpdate, _ctx) {
706
- const { apiHost, path, walkVersions, auth, domain, listSecrets } = params as {
707
- apiHost?: string;
708
- path?: string;
709
- params?: Record<string, unknown>;
710
- walkVersions?: boolean;
711
- auth?: {
712
- secretRefs?: Record<string, string>;
713
- secretQueryRefs?: Record<string, string>;
914
+ const { apiHost, path, walkVersions, auth, domain, listSecrets, scaffold } =
915
+ params as {
916
+ apiHost?: string;
917
+ path?: string;
918
+ params?: Record<string, unknown>;
919
+ walkVersions?: boolean;
920
+ auth?: {
921
+ secretRefs?: Record<string, string>;
922
+ secretQueryRefs?: Record<string, string>;
923
+ headerPrefixes?: Record<string, string>;
924
+ };
925
+ domain?: string;
926
+ listSecrets?: boolean;
927
+ scaffold?: boolean;
714
928
  };
715
- domain?: string;
716
- listSecrets?: boolean;
717
- };
718
929
  const userParams = (params as Record<string, unknown>)["params"] as
719
930
  | Record<string, unknown>
720
931
  | undefined;
@@ -740,7 +951,9 @@ export const apiProbeTool = defineTool({
740
951
  const unscoped = domain ? undefined : unscopedStoreDomains();
741
952
  const blocks: string[] = [];
742
953
  if (unscoped !== undefined) blocks.push(formatUnscopedDomains(unscoped));
743
- const target = domain ?? (apiHost ? hostnameOf(apiHost) : undefined);
954
+ const target =
955
+ domain ??
956
+ (apiHost ? resolveProbeStoreDomain(hostnameOf(apiHost)) : undefined);
744
957
  if (target !== undefined) {
745
958
  const secrets = listDomainSecrets(target);
746
959
  blocks.push(formatSecretsResult(secrets));
@@ -782,6 +995,7 @@ export const apiProbeTool = defineTool({
782
995
  ...(walkVersions === undefined ? {} : { walkVersions }),
783
996
  ...(auth ? { auth } : {}),
784
997
  ...(domain ? { domain } : {}),
998
+ ...(scaffold === undefined ? {} : { scaffold }),
785
999
  });
786
1000
  return {
787
1001
  content: [{ type: "text", text: formatProbeResult(result) }],
@@ -815,6 +1029,7 @@ export const apiProbeTool = defineTool({
815
1029
  const parts: string[] = [theme.fg("toolTitle", theme.bold("api-probe "))];
816
1030
  if (args.apiHost) parts.push(theme.fg("accent", `"${args.apiHost}"`));
817
1031
  if (args.path) parts.push(theme.fg("dim", `› ${args.path}`));
1032
+ if (args.scaffold) parts.push(theme.fg("dim", "· scaffold"));
818
1033
  return new Text(parts.join(" "), 0, 0);
819
1034
  },
820
1035
 
@@ -914,7 +1129,13 @@ export function formatProbeResult(r: ProbeResult): string {
914
1129
  lines.push(r.raw);
915
1130
  }
916
1131
  lines.push("");
917
- lines.push(` ${DOCS_NUDGE.join("\n ")}`);
1132
+ const footer = [...DOCS_NUDGE];
1133
+ if (r.scaffoldNudge) {
1134
+ footer.push(
1135
+ "No guide for this domain yet — pass scaffold: true to emit a full recipe skeleton.",
1136
+ );
1137
+ }
1138
+ lines.push(` ${footer.join("\n ")}`);
918
1139
  return lines.join("\n");
919
1140
  }
920
1141