@mrclrchtr/supi-debug 11.2.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 +5 -0
- package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-core/src/child-web-tools.ts +110 -0
- package/node_modules/@mrclrchtr/supi-core/src/session.ts +11 -0
- package/package.json +3 -2
- package/prompts/supi-tooling-retro.md +20 -17
- package/src/tool/debug/input.ts +2 -3
- package/src/tool/debug/render.ts +8 -6
package/CHANGELOG.md
ADDED
|
@@ -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.
|
|
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.
|
|
38
|
+
"@mrclrchtr/supi-core": "11.3.0"
|
|
38
39
|
},
|
|
39
40
|
"bundledDependencies": [
|
|
40
41
|
"@mrclrchtr/supi-core"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
---
|
|
2
|
-
description:
|
|
2
|
+
description: Find evidence-grounded tooling improvements from the preceding task
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
Produce a compact retrospective of the task immediately preceding this prompt.
|
|
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
7
|
## Scope and evidence
|
|
8
8
|
|
|
@@ -10,14 +10,14 @@ Produce a compact retrospective of the task immediately preceding this prompt. A
|
|
|
10
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
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.
|
|
12
12
|
|
|
13
|
-
For each finding, give a brief evidence anchor:
|
|
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.
|
|
14
14
|
|
|
15
15
|
Use these evidence labels:
|
|
16
16
|
- `[observed]`: directly supported by the visible transcript or verification result.
|
|
17
17
|
- `[inferred]`: a plausible interpretation or missed benefit, not demonstrated.
|
|
18
18
|
- `[unknown]`: an unresolved cause, ownership, or measurement; not a standalone finding.
|
|
19
19
|
|
|
20
|
-
Separate
|
|
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.
|
|
21
21
|
|
|
22
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.
|
|
23
23
|
|
|
@@ -25,31 +25,34 @@ Rate each finding's impact on this task as `high`, `medium`, or `low`, based on
|
|
|
25
25
|
|
|
26
26
|
Consider each category, but report each finding once:
|
|
27
27
|
- **Help:** What a used surface enabled, including useful guidance or context—not just a list of calls.
|
|
28
|
-
- **
|
|
29
|
-
- **
|
|
30
|
-
- **
|
|
31
|
-
- **
|
|
32
|
-
|
|
33
|
-
|
|
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.
|
|
34
34
|
|
|
35
35
|
## Report
|
|
36
36
|
|
|
37
|
-
Use the structure below, within 600 words; shorter when evidence is sparse. Prioritize consequential findings rather than filling categories
|
|
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.
|
|
38
38
|
|
|
39
39
|
## SuPi Tooling Retrospective
|
|
40
40
|
|
|
41
41
|
**Task**: <one sentence, including actual completion status>
|
|
42
42
|
|
|
43
|
-
**Verdict**: <overall contribution and
|
|
43
|
+
**Verdict**: <overall contribution and highest-leverage tooling opportunity, or no tooling change warranted>
|
|
44
44
|
|
|
45
45
|
### What helped
|
|
46
46
|
- `[observed · impact: high|medium|low]` **`<surface>`** — <concrete contribution; evidence anchor>.
|
|
47
47
|
|
|
48
|
-
###
|
|
49
|
-
- `[observed|inferred · impact: high|medium|low]` **`<surface>`** — <
|
|
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.>
|
|
50
|
+
|
|
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.`
|
|
50
53
|
|
|
51
|
-
###
|
|
52
|
-
|
|
54
|
+
### Agent lessons
|
|
55
|
+
<At most two task-specific execution lessons, separate from tooling improvements. Omit when there are none.>
|
|
53
56
|
|
|
54
57
|
### Evidence limits
|
|
55
|
-
<
|
|
58
|
+
<State only limits that materially affect the findings or proposals; omit inventories of unassessed internals. Distinguish incomplete evidence from an uneventful observed task.>
|
package/src/tool/debug/input.ts
CHANGED
|
@@ -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
|
|
7
|
+
/** Shared level vocabulary, narrowed to the registry contract. */
|
|
9
8
|
export const debugLevelSchema = Type.Unsafe<DebugLevel>(
|
|
10
|
-
|
|
9
|
+
Type.Enum(["debug", "info", "warning", "error"], { type: "string" }),
|
|
11
10
|
);
|
package/src/tool/debug/render.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/** Transcript renderers for the debug tool. */
|
|
2
2
|
|
|
3
|
-
import
|
|
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
|
|