Files
oh-my-pi/packages/coding-agent/src/tools/review.ts
T
can1357 5ff277349c refactor(coding-agent): consolidated tool surface onto xd:// devices and hub
- Added the `xd://` virtual device protocol (`internal-urls/xd-protocol.ts`, `tools/xdev.ts`): tools declaring `loadMode: "discoverable"` are unmounted from the request tools array and driven via `read xd://` (list/docs+schema) and `write xd://<tool>` (execute), gated by the `tools.xdev` setting (default on) and inlined into the system prompt.
- Merged the `irc`, `job`, and `launch` tools into a single `hub` tool (`tools/hub/`, `async/job-manager.ts`): messaging keeps `send`/`inbox`/`list`, job control maps to `wait`/`cancel`/`jobs`, process supervision keeps `start`/`logs`/`stop`/`restart`/`describe` with `ps`, and the unified `wait` races background jobs against peer messages; SDK `IrcTool`/`JobTool`/`LaunchTool` are replaced by `HubTool`.
- Removed the hidden `resolve` tool in favor of the `xd://resolve`/`xd://reject`/`xd://propose` resolution devices, auto-including `write` whenever a deferrable tool or plan mode is present.
- Removed the BM25 tool-discovery system: the `search_tool_bm25` tool, the `tool-discovery` module, the `tools.discoveryMode`/`mcp.discoveryMode`/`mcp.discoveryDefaultServers`/`tools.essentialOverride` settings, per-tool MCP selection, and the `mcp_tool_selection` message type.
- Unified tool presentation on `ToolLoadMode` (`essential`|`discoverable`), replacing the custom-tool `xdev?: boolean` opt-out; custom, extension, MCP, RPC host, image-generation, and TTS tools now default to `discoverable`, and added a `satisfies` predicate to `SoftToolRequirement`.
- Removed the standalone `ssh` command tool and `ssh/ssh-executor` (the `ssh://` read/write/search protocol stays), and made `--tools` address hidden built-ins.
- Updated collab-web to render `xd://` dispatches and `hub` op families, dropped the `search_tool_bm25`/`ssh`/`report-finding` renderers, refreshed tool docs and prompts, and migrated the affected tests and changelogs.
2026-07-15 15:16:29 +02:00

104 lines
3.4 KiB
TypeScript

/**
* Review-finding shapes and priority helpers.
*
* The `report_finding` tool was removed; reviewers now record findings through
* incremental `yield` sections (`type: ["findings"]`). These parsers and
* priority-display helpers back the reviewer render path in `task/render.ts`.
*/
// ─────────────────────────────────────────────────────────────────────────────
import { isRecord } from "@oh-my-pi/pi-utils";
import type { ThemeColor } from "../modes/theme/theme";
export type FindingPriority = "P0" | "P1" | "P2" | "P3";
export interface FindingPriorityInfo {
ord: 0 | 1 | 2 | 3;
symbol: "status.error" | "status.warning" | "status.info";
color: ThemeColor;
}
const PRIORITY_INFO: Record<FindingPriority, FindingPriorityInfo> = {
P0: { ord: 0, symbol: "status.error", color: "error" },
P1: { ord: 1, symbol: "status.warning", color: "warning" },
P2: { ord: 2, symbol: "status.warning", color: "muted" },
P3: { ord: 3, symbol: "status.info", color: "accent" },
};
export const PRIORITY_LABELS: FindingPriority[] = ["P0", "P1", "P2", "P3"];
export function isFindingPriority(value: unknown): value is FindingPriority {
return value === "P0" || value === "P1" || value === "P2" || value === "P3";
}
export function getPriorityInfo(priority: FindingPriority): FindingPriorityInfo {
return PRIORITY_INFO[priority] ?? { ord: 3, symbol: "status.info", color: "muted" };
}
interface FindingDetails {
title: string;
body: string;
priority: FindingPriority;
confidence: number;
file_path: string;
line_start: number;
line_end: number;
}
function normalizeFindingPriority(value: unknown): FindingPriority | undefined {
if (isFindingPriority(value)) return value;
if (value === 0) return "P0";
if (value === 1) return "P1";
if (value === 2) return "P2";
if (value === 3) return "P3";
return undefined;
}
export function parseFindingDetails(value: unknown): FindingDetails | undefined {
if (!isRecord(value)) return undefined;
const title = typeof value.title === "string" ? value.title : undefined;
const body = typeof value.body === "string" ? value.body : undefined;
const priority = normalizeFindingPriority(value.priority);
const confidence =
typeof value.confidence === "number" &&
Number.isFinite(value.confidence) &&
value.confidence >= 0 &&
value.confidence <= 1
? value.confidence
: undefined;
const filePath = typeof value.file_path === "string" && value.file_path.length > 0 ? value.file_path : undefined;
const lineStart =
typeof value.line_start === "number" && Number.isFinite(value.line_start) ? value.line_start : undefined;
const lineEnd = typeof value.line_end === "number" && Number.isFinite(value.line_end) ? value.line_end : undefined;
if (
title === undefined ||
body === undefined ||
priority === undefined ||
confidence === undefined ||
filePath === undefined ||
lineStart === undefined ||
lineEnd === undefined
) {
return undefined;
}
return {
title,
body,
priority,
confidence,
file_path: filePath,
line_start: lineStart,
line_end: lineEnd,
};
}
/** SubmitReviewDetails - used for rendering review results from yield tool */
export interface SubmitReviewDetails {
overall_correctness: "correct" | "incorrect";
explanation: string;
confidence: number;
}
// Re-export the finding shape for the reviewer render path.
export type { FindingDetails };