@mrclrchtr/supi-debug 11.1.0 → 11.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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## [11.3.0]
4
+
5
+ - Added package-specific release notes for SuPi Debug event capture and inspection.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-core",
3
- "version": "11.1.0",
3
+ "version": "11.3.0",
4
4
  "description": "Shared settings, configuration, reporting, and session infrastructure",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -0,0 +1,110 @@
1
+ // Session-provided Web tools for SuPi child sessions (Agent Runs and Reviewer Sessions).
2
+ //
3
+ // The loaded supi-web extension answers a synchronous request on the parent event bus.
4
+ // Consumers never depend on supi-web; when it is absent or provides no tools, the
5
+ // request returns undefined and the child simply lacks Web tools.
6
+
7
+ import type { ExtensionAPI, ExtensionFactory } from "@earendil-works/pi-coding-agent";
8
+
9
+ /** Web tools that child sessions may receive when the containing session provides them. */
10
+ export const CHILD_WEB_TOOL_NAMES = [
11
+ "web_fetch_md",
12
+ "web_search",
13
+ "web_docs_search",
14
+ "web_docs_fetch",
15
+ ] as const;
16
+
17
+ /** One session-provided Web tool name. */
18
+ export type ChildWebToolName = (typeof CHILD_WEB_TOOL_NAMES)[number];
19
+
20
+ /**
21
+ * Web tools currently callable in the containing session plus a child-only extension
22
+ * factory that registers them. The factory must not capture the parent session; it may
23
+ * capture plain data such as the containing session's configuration directory.
24
+ */
25
+ export interface ChildWebToolProvision {
26
+ readonly toolNames: readonly ChildWebToolName[];
27
+ /** Register the requested subset of `toolNames` in a child session. */
28
+ readonly createFactory: (toolNames: readonly ChildWebToolName[]) => ExtensionFactory;
29
+ }
30
+
31
+ /** Plain containing-session data supplied with a child Web tool request. */
32
+ export interface ChildWebToolsRequestContext {
33
+ /**
34
+ * Working directory whose SuPi configuration governs Web settings such as Firecrawl.
35
+ * Children with a different cwd (for example a frozen Review Workspace) keep this policy.
36
+ */
37
+ readonly configCwd: string;
38
+ }
39
+
40
+ type EventBusLike = Pick<ExtensionAPI["events"], "on" | "emit">;
41
+
42
+ const REQUEST_CHANNEL = "supi:child-web-tools:request";
43
+ const RESPONSE_CHANNEL = "supi:child-web-tools:response";
44
+
45
+ interface ChildWebToolsRequest extends ChildWebToolsRequestContext {
46
+ readonly requestId: string;
47
+ }
48
+
49
+ interface ChildWebToolsResponse {
50
+ readonly requestId: string;
51
+ readonly provision: ChildWebToolProvision;
52
+ }
53
+
54
+ let nextRequestId = 0;
55
+
56
+ /**
57
+ * Answer child Web tool requests on the parent event bus. The callback must be synchronous
58
+ * because Pi's event bus does not await listeners. Returns an unsubscribe function.
59
+ */
60
+ export function provideChildWebTools(
61
+ events: EventBusLike,
62
+ resolve: (context: ChildWebToolsRequestContext) => ChildWebToolProvision | undefined,
63
+ ): () => void {
64
+ return events.on(REQUEST_CHANNEL, (data) => {
65
+ const request = data as Partial<ChildWebToolsRequest> | undefined;
66
+ if (typeof request?.requestId !== "string" || typeof request.configCwd !== "string") return;
67
+ const { requestId, configCwd } = request;
68
+ const provision = resolve({ configCwd });
69
+ if (!provision || provision.toolNames.length === 0) return;
70
+ events.emit(RESPONSE_CHANNEL, { requestId, provision } satisfies ChildWebToolsResponse);
71
+ });
72
+ }
73
+
74
+ /** Capture the Web tools the containing session currently provides, if any. */
75
+ export function requestChildWebTools(
76
+ events: EventBusLike,
77
+ context: ChildWebToolsRequestContext,
78
+ ): ChildWebToolProvision | undefined {
79
+ const requestId = `child-web-${process.pid}-${++nextRequestId}`;
80
+ let provision: ChildWebToolProvision | undefined;
81
+ const unsubscribe = events.on(RESPONSE_CHANNEL, (data) => {
82
+ const response = data as Partial<ChildWebToolsResponse> | undefined;
83
+ if (response?.requestId === requestId && response.provision) provision = response.provision;
84
+ });
85
+ try {
86
+ events.emit(REQUEST_CHANNEL, { requestId, ...context } satisfies ChildWebToolsRequest);
87
+ } finally {
88
+ unsubscribe();
89
+ }
90
+ return provision;
91
+ }
92
+
93
+ /**
94
+ * Return the Web tools callable in a session under Pi's exposure rules: active `direct`
95
+ * tools, plus registered `codemode` and `deferred` tools. `model-only` and `hidden`
96
+ * tools are not callable.
97
+ */
98
+ export function callableChildWebToolNames(
99
+ pi: Pick<ExtensionAPI, "getAllTools" | "getActiveTools">,
100
+ ): ChildWebToolName[] {
101
+ const active = new Set(pi.getActiveTools());
102
+ const exposures = new Map(
103
+ pi.getAllTools().map((tool) => [tool.name, tool.exposure ?? "direct"] as const),
104
+ );
105
+ return CHILD_WEB_TOOL_NAMES.filter((name) => {
106
+ const exposure = exposures.get(name);
107
+ if (exposure === "direct") return active.has(name);
108
+ return exposure === "codemode" || exposure === "deferred";
109
+ });
110
+ }
@@ -1,5 +1,16 @@
1
1
  // supi-core session domain — session utilities and registries.
2
2
 
3
+ export type {
4
+ ChildWebToolName,
5
+ ChildWebToolProvision,
6
+ ChildWebToolsRequestContext,
7
+ } from "./child-web-tools.ts";
8
+ export {
9
+ CHILD_WEB_TOOL_NAMES,
10
+ callableChildWebToolNames,
11
+ provideChildWebTools,
12
+ requestChildWebTools,
13
+ } from "./child-web-tools.ts";
3
14
  export { createRegistry, createSessionStateRegistry } from "./registry-utils.ts";
4
15
  export type {
5
16
  SessionCapabilitySkill,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-debug",
3
- "version": "11.1.0",
3
+ "version": "11.3.0",
4
4
  "description": "Capture and inspect SuPi debug events",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -27,6 +27,7 @@
27
27
  ],
28
28
  "type": "module",
29
29
  "files": [
30
+ "CHANGELOG.md",
30
31
  "src/**/*.ts",
31
32
  "prompts",
32
33
  "skills/**/SKILL.md",
@@ -34,7 +35,7 @@
34
35
  "README.md"
35
36
  ],
36
37
  "dependencies": {
37
- "@mrclrchtr/supi-core": "11.1.0"
38
+ "@mrclrchtr/supi-core": "11.3.0"
38
39
  },
39
40
  "bundledDependencies": [
40
41
  "@mrclrchtr/supi-core"
@@ -1,77 +1,58 @@
1
1
  ---
2
- description: Retrospect on SuPi tooling used during the completed task
2
+ description: Find evidence-grounded tooling improvements from the preceding task
3
3
  ---
4
4
 
5
- Produce a compact, evidence-based retrospective of the task that just ended. Evaluate the SuPi surfaces that were available and relevant: tools, skills, prompts, extensions, injected context or guidance, documentation, settings, and human-only TUI commands. Do not evaluate the entire suite in the abstract. Do not evaluate pi-core behavior.
5
+ Produce a compact retrospective of the task immediately preceding this prompt. Extract reusable improvements to relevant tools, skills, prompts, extensions, injected guidance, docs, settings, and human-only TUI commands. Assess what helped, what got in the way, and what could make the next similar task easier—even when no tool failed. Focus on tooling and workflow fit, not the project's code or a general grade of the agent's performance.
6
6
 
7
- ## Evidence rules
7
+ ## Scope and evidence
8
8
 
9
- - Reconstruct the retrospective from this session only. Do not invent tool calls, outcomes, failures, token costs, or user impact.
10
- - You may query the `debug` tool to verify event-level claims. You may query `cache_forensics` when it is available to verify cache-related claims. Use such queries only for verification, and keep them few. Do not perform any other tool calls or follow-up investigation. Stop after you write the retrospective.
11
- - Tag every claim as `[observed]`, `[inferred]`, or `[unknown]`. An observed claim is supported by the transcript, a tool result, or an evidence query. An inferred claim is plausible but untested.
12
- - Rate the impact of each surfaced item as `high`, `medium`, or `low`. The impact is the degree to which the item changed the task outcome or its cost.
13
- - Use the exact surface name that appears in the session. Do not treat an available but unused tool as evidence of failure.
14
- - If no SuPi surface was used or relevant, say so explicitly. Do not build a wishlist. List only task-specific, plausible missed help.
9
+ 1. Identify the preceding task and its actual completion status from the visible session. If no task is identifiable, state that limit and stop. Keep unrelated tasks and this retrospective's own verification outside the assessment.
10
+ 2. Use the task transcript as the primary evidence. If verification would materially change a finding or recommendation, make at most two narrowly filtered `debug` calls against the live session, using sanitized data only. Use only events attributable to this task. A retained buffer can omit earlier events; empty or incomplete results do not establish that nothing failed. If verification is unavailable, disclose the limit and proceed.
11
+ 3. Make no other tool calls or follow-up investigation. Historical scans, delegation, file edits, issue creation, settings changes, and continuing the task are outside this retrospective. Stop after the report.
15
12
 
16
- ## Evaluate
13
+ For each finding, give a brief evidence anchor: the smallest distinguishing input and observed result (for example, query/scope and completeness reason), a retry, a user correction, or a specific instruction/context excerpt. Use exact surface names from the session. Treat tool-reported limits as observations; mark their underlying cause `[unknown]` where unresolved. Keep excerpts minimal and omit secrets or unnecessary identifying details.
17
14
 
18
- - SuPi surfaces that were actually used: what they enabled, where they fell short, and any failure or friction.
19
- - Failed or mis-parameterized tool calls: SuPi surface calls that failed or were rejected for wrong, missing, or invalid parameters, including calls corrected on retry. Name the cause: agent misuse, ambiguous tool description, missing guidance (promptSnippet or promptGuidelines), a schema gap, or a tool bug.
20
- - Recognized problems or bugs: concrete defects in SuPi surfaces, such as crashes, wrong output, failed calls for valid usage, regressions, inconsistent behavior, or guidance that led to a wrong action. Do not report defects in the project's own code.
21
- - Missed opportunities: a relevant unused tool (for example a supi-code-intelligence tool) or context source, and why it was missed. Name the cause: discoverability, guidance, timing, capability, or not applicable.
22
- - Missing pieces: a concrete utility, capability, documentation page, example, or output improvement that would have changed this task.
23
- - Noise: redundant instructions, repeated advice without added value, stale or irrelevant context, excessive output, unnecessary long paths, poor timing, or misleading guidance. Do not criticize necessary context without naming the avoidable cost.
24
- - Keep SuPi or tooling recommendations separate from general code or project recommendations.
15
+ Use these evidence labels:
16
+ - `[observed]`: directly supported by the visible transcript or verification result.
17
+ - `[inferred]`: a plausible interpretation or missed benefit, not demonstrated.
18
+ - `[unknown]`: an unresolved cause, ownership, or measurement; not a standalone finding.
25
19
 
26
- ## Output rules
20
+ Separate observed outcomes from suspected causes. Distinguish SuPi-owned surfaces, upstream Pi/provider behavior, project-local guidance, and agent behavior; mark unresolved ownership or cause `[unknown]`. Keep upstream behavior and project-code defects out of SuPi bug claims. Judge fault separately from improvement potential: agent error can still expose a useful interface or workflow change.
27
21
 
28
- - Keep the result under about 600 words and specific to this task.
29
- - Open with a one-line overall verdict on SuPi tooling for this task.
30
- - Give each item a confidence tag and an impact rating. `None identified` lines need neither.
31
- - Prefer concrete evidence and observed friction over generic praise or a feature wishlist.
32
- - If a section has no supported item, write `None identified` and briefly explain the evidence limit.
33
- - Include at most three recommendations. Each must name a changeable surface (tool, prompt, skill, docs, guidance, or feature), the proposed change, and the expected benefit. Recommended changes may target tool descriptions, parameter schemas, or guidance, especially when they address the Failed or mis-parameterized tool calls listed above. Do not recommend "use the tool more" unless discoverability is the identified cause.
34
- - Do not edit files, open issues, update OpenSpec artifacts, or take any other follow-up action.
22
+ Rate each finding's impact on this task as `high`, `medium`, or `low`, based on the demonstrated effect or explicitly inferred benefit. Report time, token, cache, or cost figures only when measured in the task evidence; describe unmeasured costs qualitatively. Claims about recurring problems or suite-wide reliability require evidence beyond this retrospective's scope.
35
23
 
36
- ## Required output
24
+ ## Assessment checklist
37
25
 
38
- ## SuPi Tooling Retrospective
26
+ Consider each category, but report each finding once:
27
+ - **Help:** What a used surface enabled, including useful guidance or context—not just a list of calls.
28
+ - **Failures, retries, and defects:** Include rejected or mis-parameterized calls even when corrected on retry. Name the parameter or error, task effect, and eventual outcome. Distinguish misuse, guidance/schema gaps, and suspected tool defects; keep uncertain causes explicit.
29
+ - **Guidance and workflow fit:** Assess visible descriptions, parameter explanations, `promptSnippet`, `promptGuidelines`, result guidance, and skill instructions at the decision point. Look for ambiguity, poorly timed guidance, and workflow assumptions that did not fit this task. Distinguish missing or unhelpful guidance from clear guidance the agent did not follow.
30
+ - **Missed opportunities and missing pieces:** Look for workarounds, repetitive manual steps, missing capabilities, and output improvements that could have helped. For an unused surface, establish its availability and relevance; non-use alone is not a gap. Ground ideas in a specific task moment, not a suite-wide wishlist.
31
+ - **Context efficiency:** Identify oversized, redundant, stale, or poorly timed context. Distinguish recurring metadata/injections from results and on-demand reads; mark uncertain placement `[unknown]`. For deletion proposals, quote the overlap and name retained guidance that preserves tool selection, valid arguments, and safety. Account for mandatory reading: a required read is not agent waste, but its routing or packaging may be an improvement candidate.
32
+
33
+ For consequential friction, consider a concrete tooling or guidance change as well as an agent lesson. A proposal needs an evidence anchor and a plausible mechanism; root-cause proof or demonstrated recurrence is not required to suggest an experiment. Repeating an existing instruction belongs under agent lessons; an interface, timing, or workflow change needs its own rationale.
39
34
 
40
- **Task completed**: <1–2 sentence summary>
35
+ ## Report
41
36
 
42
- **Verdict**: <one line: the overall state of SuPi tooling for this task and its biggest lever>
37
+ Use the structure below, within 600 words; shorter when evidence is sparse. Prioritize consequential findings rather than filling categories or a recommendation quota. Use evidence labels to express uncertainty; add prose caveats only when they change the proposed action. Omit empty sections. If no SuPi surface was used or relevant, say so explicitly and omit unsupported findings and recommendations.
43
38
 
44
- ### Tools used
45
- - `[observed · impact: high|medium|low]` **`<surface>`** — concrete help, friction, or failure.
46
- - If none: `None identified — no SuPi surface materially participated in this task.`
39
+ ## SuPi Tooling Retrospective
47
40
 
48
- ### Failed or mis-parameterized tool calls
49
- - `[observed|inferred · impact: high|medium|low]` **`<surface>`** — the call, the invalid or missing parameter, the outcome, and the cause: agent misuse, ambiguous description, missing guidance, schema gap, or tool bug. Include near misses: a call rejected once and corrected on retry is stronger evidence than a clean pass.
50
- - If none: `None identified — every SuPi call used valid parameters.`
41
+ **Task**: <one sentence, including actual completion status>
51
42
 
52
- ### Recognized problems or bugs
53
- - `[observed|inferred · impact: high|medium|low]` **`<surface>`** — the concrete defect (crash, wrong behavior, regression, inconsistency) and how it affected the task. Do not repeat ordinary friction that belongs under Tools used, and do not repeat parameter-caused call failures that belong under Failed or mis-parameterized tool calls.
54
- - If none: `None identified — no defect surfaced in this task.`
43
+ **Verdict**: <overall contribution and highest-leverage tooling opportunity, or no tooling change warranted>
55
44
 
56
- ### Missed opportunities
57
- - `[inferred · impact: high|medium|low]` **`<surface>`** — task-specific help it might have provided. Name the cause: discoverability, guidance, timing, capability, or not applicable.
58
- - If none: `None identified — do not infer a gap from non-use alone.`
45
+ ### What helped
46
+ - `[observed · impact: high|medium|low]` **`<surface>`** — <concrete contribution; evidence anchor>.
59
47
 
60
- ### Missing pieces
61
- - `[observed|inferred · impact: high|medium|low]` **`<utility, feature, docs, example, or output change>`** — the concrete gap and how it affected this task.
62
- - If none: `None identified.`
48
+ ### Failures and friction
49
+ - `[observed|inferred · impact: high|medium|low]` **`<surface>`** — <finding; evidence anchor; task effect>. <Cause or ownership, separately labeled if inferred or unknown. Include retry outcomes where visible.>
63
50
 
64
- ### Unhelpful or noisy context
65
- - `[observed|inferred · impact: high|medium|low]` **`<instruction, context, or output>`** — what was unnecessary or costly, and how it could be reduced or better timed.
66
- - If none: `None identified.`
51
+ ### Tooling improvements
52
+ Include at most three prioritized proposals tied to reported findings: **owner / named surface → specific change → expected benefit → validation**. Name the editable surface and changed behavior; use a file path only if known. Mark untested changes and benefits `[inferred]`. Choose one smallest next experiment per proposal, with an observable success criterion. Keep larger alternatives conditional on that result. When evidence is insufficient to choose a change, name the narrow verification that would decide it. Preserve selection, argument validity, and safety in context-reduction proposals. If none emerge, state `No tooling change warranted by the available evidence.`
67
53
 
68
- ### Prioritized recommendations
69
- 1. **`<named surface>`** — <specific change>; <expected benefit>; confidence: <high|medium|low>.
70
- 2. **`<named surface>`** — <specific change>; <expected benefit>; confidence: <high|medium|low>.
71
- 3. **`<named surface>`** — <specific change>; <expected benefit>; confidence: <high|medium|low>.
72
- - Include only supported recommendations. If none are supported, write `None identified`.
54
+ ### Agent lessons
55
+ <At most two task-specific execution lessons, separate from tooling improvements. Omit when there are none.>
73
56
 
74
- ### Confidence / evidence
75
- - Direct evidence: <what the session and any evidence queries demonstrate>
76
- - Inference: <what is plausible but untested>
77
- - Limits: <what the session cannot establish>
57
+ ### Evidence limits
58
+ <State only limits that materially affect the findings or proposals; omit inventories of unassessed internals. Distinguish incomplete evidence from an uneventful observed task.>
@@ -1,11 +1,10 @@
1
- import { StringEnum } from "@earendil-works/pi-ai";
2
1
  import type { DebugLevel } from "@mrclrchtr/supi-core/debug";
3
2
  import { Type } from "typebox";
4
3
 
5
4
  /** Shared Debug Operation ID constraint for filters and returned event identity. */
6
5
  export const debugOperationIdSchema = Type.String({ pattern: "^op-[A-Za-z0-9_-]{21}[AQgw]$" });
7
6
 
8
- /** Shared level vocabulary; StringEnum's string type is narrowed to the registry contract. */
7
+ /** Shared level vocabulary, narrowed to the registry contract. */
9
8
  export const debugLevelSchema = Type.Unsafe<DebugLevel>(
10
- StringEnum(["debug", "info", "warning", "error"]),
9
+ Type.Enum(["debug", "info", "warning", "error"], { type: "string" }),
11
10
  );
@@ -1,6 +1,10 @@
1
1
  /** Transcript renderers for the debug tool. */
2
2
 
3
- import { keyHint, type Theme, type ToolRenderResultOptions } from "@earendil-works/pi-coding-agent";
3
+ import type {
4
+ KeybindingHints,
5
+ Theme,
6
+ ToolRenderResultOptions,
7
+ } from "@earendil-works/pi-coding-agent";
4
8
  import { Text } from "@earendil-works/pi-tui";
5
9
  import { type DebugRenderDetails, readDebugRenderDetails } from "../../render-details.ts";
6
10
  import { renderExpandedReport } from "../../renderer.ts";
@@ -95,14 +99,12 @@ function renderProgress(details: unknown, expanded: boolean, theme: Theme): Text
95
99
  return new Text(theme.fg("warning", expanded ? line : "Reading persisted debug events…"), 0, 0);
96
100
  }
97
101
 
98
- /** Render the compact or expanded result for the `debug` tool. */
99
-
100
102
  /** Render the compact or expanded result for the `debug` tool. */
101
103
  export function renderDebugToolResult(
102
104
  result: DebugToolResult,
103
105
  options: ToolRenderResultOptions,
104
106
  theme: Theme,
105
- context: { isError: boolean },
107
+ context: Pick<KeybindingHints, "keyText" | "keyHint"> & { isError: boolean },
106
108
  ): Text {
107
109
  if (options.isPartial) return renderProgress(result.details, options.expanded, theme);
108
110
  if (context.isError) return new Text(theme.fg("error", "debug failed"), 0, 0);
@@ -110,8 +112,8 @@ export function renderDebugToolResult(
110
112
  const details = readDebugRenderDetails(result.details);
111
113
  if (!options.expanded) {
112
114
  let summary = renderToolSummary(details, theme);
113
- if (details.eventCount > 0)
114
- summary += theme.fg("dim", ` ${keyHint("app.tools.expand", "to expand")}`);
115
+ if (details.eventCount > 0 && context.keyText("app.tools.expand"))
116
+ summary += theme.fg("dim", ` ${context.keyHint("app.tools.expand", "to expand")}`);
115
117
  return new Text(summary, 0, 0);
116
118
  }
117
119