@mrclrchtr/supi-review 4.1.0 → 4.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.
Files changed (55) hide show
  1. package/node_modules/@mrclrchtr/supi-code-intelligence/README.md +4 -2
  2. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  3. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-code-runtime/package.json +2 -2
  4. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  5. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  6. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +2 -2
  7. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  8. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/package.json +3 -3
  9. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/utils.ts +2 -2
  10. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/README.md +5 -5
  11. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  12. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +2 -2
  13. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  14. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/package.json +3 -3
  15. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/src/language.ts +2 -1
  16. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/src/operation-support.ts +19 -0
  17. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/src/syntax-node.ts +1 -0
  18. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/outline-c-family.ts +230 -0
  19. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/outline-html-sql.ts +186 -0
  20. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/outline-jvm.ts +311 -0
  21. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/outline-polyglot.ts +218 -0
  22. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/outline-scripting.ts +307 -0
  23. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/outline.ts +9 -5
  24. package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/src/types.ts +6 -2
  25. package/node_modules/@mrclrchtr/supi-code-intelligence/package.json +5 -5
  26. package/node_modules/@mrclrchtr/supi-code-intelligence/src/analysis/search/pattern.ts +2 -2
  27. package/node_modules/@mrclrchtr/supi-code-intelligence/src/analysis/target/symbol.ts +5 -2
  28. package/node_modules/@mrclrchtr/supi-code-intelligence/src/extension.ts +5 -1
  29. package/node_modules/@mrclrchtr/supi-code-intelligence/src/session/orientation/collect.ts +134 -180
  30. package/node_modules/@mrclrchtr/supi-code-intelligence/src/session/orientation/context-sections.ts +14 -48
  31. package/node_modules/@mrclrchtr/supi-code-intelligence/src/session/orientation-types.ts +14 -4
  32. package/node_modules/@mrclrchtr/supi-code-intelligence/src/session/orientation-workflow.ts +20 -48
  33. package/node_modules/@mrclrchtr/supi-code-intelligence/src/substrate/lsp/lifecycle.ts +55 -3
  34. package/node_modules/@mrclrchtr/supi-code-intelligence/src/substrate/lsp/state.ts +6 -0
  35. package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/graph/execute.ts +1 -1
  36. package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/graph/markdown.ts +222 -0
  37. package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/orientation/markdown.ts +66 -11
  38. package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/register.ts +10 -0
  39. package/node_modules/@mrclrchtr/supi-code-intelligence/src/ui/footer.ts +33 -8
  40. package/node_modules/@mrclrchtr/supi-code-intelligence/src/ui/markdown/overview-data.ts +3 -15
  41. package/node_modules/@mrclrchtr/supi-code-intelligence/src/ui/markdown/overview.ts +4 -10
  42. package/node_modules/@mrclrchtr/supi-code-intelligence/src/ui/markdown/types.ts +0 -1
  43. package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  44. package/package.json +4 -5
  45. package/src/tool/child-session-runner.ts +38 -33
  46. package/src/tool/planner-runner.ts +1 -24
  47. package/src/tool/review-execution.ts +1 -1
  48. package/src/tool/review-runner.ts +6 -37
  49. package/src/tool/review-workflow.ts +1 -1
  50. package/src/types.ts +17 -17
  51. package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/graph/calls-md.ts +0 -41
  52. package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/graph/implementations-md.ts +0 -57
  53. package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/graph/markdown-base.ts +0 -88
  54. package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/graph/provider-location-md.ts +0 -9
  55. package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/graph/references-md.ts +0 -41
@@ -10,11 +10,6 @@ import type {
10
10
  } from "../../analysis/architecture/model.ts";
11
11
  import type { OverviewData, OverviewModule } from "./types.ts";
12
12
 
13
- /** Maximum number of modules shown in the overview. */
14
- const MAX_MODULES = 8;
15
- /** Maximum characters per module description before truncation. */
16
- const MAX_DESCRIPTION_LENGTH = 60;
17
-
18
13
  /** Grammar ID to short language tag for the overview. */
19
14
  const GRAMMAR_LANGUAGE_TAGS: Record<string, string> = {
20
15
  javascript: "js",
@@ -44,14 +39,13 @@ export function buildOverviewData(model: ArchitectureModel): OverviewData | null
44
39
  const sorted = [...model.modules].sort((left, right) =>
45
40
  left.relativePath.localeCompare(right.relativePath),
46
41
  );
47
- const modules = sorted.slice(0, MAX_MODULES).map((module) => overviewModule(module, model));
48
- const detectedLanguages = detectModuleLanguages(sorted.slice(0, MAX_MODULES));
42
+ const modules = sorted.map((module) => overviewModule(module, model));
43
+ const detectedLanguages = detectModuleLanguages(sorted);
49
44
 
50
45
  return {
51
46
  projectName: model.name,
52
47
  projectDescription: model.description,
53
48
  modules,
54
- omittedModuleCount: Math.max(0, model.modules.length - MAX_MODULES),
55
49
  detectedLanguages: detectedLanguages.length > 0 ? detectedLanguages : null,
56
50
  };
57
51
  }
@@ -61,7 +55,7 @@ function overviewModule(module: ModuleInfo, model: ArchitectureModel): OverviewM
61
55
  return {
62
56
  name,
63
57
  shortName: module.name?.replace(/^@[^/]+\//, "") ?? module.relativePath,
64
- description: truncateDescription(module.description),
58
+ description: module.description,
65
59
  declaredDependencies: model.edges
66
60
  .filter((edge) => edge.from === module.name)
67
61
  .map((edge) => edge.to),
@@ -99,12 +93,6 @@ function isRecord(value: unknown): value is Record<string, unknown> {
99
93
  return typeof value === "object" && value !== null && !Array.isArray(value);
100
94
  }
101
95
 
102
- function truncateDescription(description: string | null): string | null {
103
- if (!description) return null;
104
- if (description.length <= MAX_DESCRIPTION_LENGTH) return description;
105
- return `${description.slice(0, MAX_DESCRIPTION_LENGTH - 1)}…`;
106
- }
107
-
108
96
  /**
109
97
  * Detect languages present in the first two levels of each module directory.
110
98
  *
@@ -7,8 +7,8 @@ import type { OverviewData } from "./types.ts";
7
7
  const OVERVIEW_TOKEN_BUDGET = 600;
8
8
 
9
9
  /**
10
- * Render the compact architecture overview for first-turn session injection.
11
- * Targets at most 600 estimated tokens; logs a supi_debug warning when exceeded.
10
+ * Render the complete manifest-derived architecture overview for first-turn injection.
11
+ * Output is never truncated; callers may warn when it exceeds the soft token budget.
12
12
  */
13
13
  // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: module-edge overview rendering with multiple formatting paths is clearer as one function
14
14
  export function renderOverview(data: OverviewData): string {
@@ -40,19 +40,13 @@ export function renderOverview(data: OverviewData): string {
40
40
  `- **${mod.shortName}**${entrypointSuffix}${mod.description ? ` — ${mod.description}` : ""}`,
41
41
  );
42
42
  } else {
43
- const depNames = deps.slice(0, 4).map((d) => d.replace(/^@[^/]+\//, ""));
44
- const depStr = depNames.join(", ");
45
- const suffix = deps.length > 4 ? ` +${deps.length - 4} more` : "";
43
+ const depNames = deps.map((dependency) => dependency.replace(/^@[^/]+\//, ""));
46
44
  lines.push(
47
- `- **${mod.shortName}** → ${depStr}${suffix}${entrypointSuffix}${mod.description ? ` — ${mod.description}` : ""}`,
45
+ `- **${mod.shortName}** → ${depNames.join(", ")}${entrypointSuffix}${mod.description ? ` — ${mod.description}` : ""}`,
48
46
  );
49
47
  }
50
48
  }
51
49
 
52
- if (data.omittedModuleCount > 0) {
53
- lines.push(`- _+${data.omittedModuleCount} more modules omitted_`);
54
- }
55
-
56
50
  lines.push("");
57
51
 
58
52
  if (data.detectedLanguages && data.detectedLanguages.length > 0) {
@@ -22,7 +22,6 @@ export interface OverviewData {
22
22
  projectName: string | null;
23
23
  projectDescription: string | null;
24
24
  modules: OverviewModule[];
25
- omittedModuleCount: number;
26
25
  /** Detected source languages (e.g. ["ts", "js", "py"]). */
27
26
  detectedLanguages: string[] | null;
28
27
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-core",
3
- "version": "4.1.0",
3
+ "version": "4.3.0",
4
4
  "description": "SuPi core — shared infrastructure for SuPi extensions (XML context tags, config system)",
5
5
  "license": "MIT",
6
6
  "repository": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrclrchtr/supi-review",
3
- "version": "4.1.0",
3
+ "version": "4.3.0",
4
4
  "description": "SuPi Review extension — caller-defined Inspection-only review tasks for users and agents",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -31,8 +31,8 @@
31
31
  "README.md"
32
32
  ],
33
33
  "dependencies": {
34
- "@mrclrchtr/supi-core": "4.1.0",
35
- "@mrclrchtr/supi-code-intelligence": "4.1.0"
34
+ "@mrclrchtr/supi-code-intelligence": "4.3.0",
35
+ "@mrclrchtr/supi-core": "4.3.0"
36
36
  },
37
37
  "bundledDependencies": [
38
38
  "@mrclrchtr/supi-code-intelligence",
@@ -60,8 +60,7 @@
60
60
  },
61
61
  "pi": {
62
62
  "extensions": [
63
- "./src/extension.ts",
64
- "node_modules/@mrclrchtr/supi-code-intelligence/src/extension.ts"
63
+ "./src/extension.ts"
65
64
  ],
66
65
  "image": "https://raw.githubusercontent.com/mrclrchtr/supi/main/screenshots/supi-review-3.png"
67
66
  },
@@ -8,7 +8,7 @@ import {
8
8
  SessionManager,
9
9
  type ToolDefinition,
10
10
  } from "@earendil-works/pi-coding-agent";
11
- import type { ChildFailureDiagnostics, ReviewProgress } from "../types.ts";
11
+ import type { ChildRunOutcome, ReviewProgress } from "../types.ts";
12
12
  import { createIsolatedChildResources } from "./child-resource-loader.ts";
13
13
  import { buildProgressTokens } from "./runner-helpers.ts";
14
14
  import { runWithLifecycle } from "./session-lifecycle.ts";
@@ -16,7 +16,7 @@ import { runWithLifecycle } from "./session-lifecycle.ts";
16
16
  const CHILD_RUNTIME_SHUTDOWN_GRACE_MS = 2_000;
17
17
 
18
18
  /** Configuration for one isolated child run — resource loading, session, and lifecycle. */
19
- export interface IsolatedRunConfig<THolder, TResult> {
19
+ export interface IsolatedRunConfig<T> {
20
20
  cwd: string;
21
21
  protocolPrompt: string;
22
22
  // biome-ignore lint/suspicious/noExplicitAny: Model<any> is Pi's canonical type
@@ -27,23 +27,10 @@ export interface IsolatedRunConfig<THolder, TResult> {
27
27
  signal?: AbortSignal;
28
28
  tools: string[];
29
29
  customTools: ToolDefinition[];
30
- holder: { value?: THolder };
30
+ holder: { value?: T };
31
31
  headlessInspection?: boolean;
32
32
  projectTrusted?: boolean;
33
33
  onSessionCreated?: (session: AgentSession) => void;
34
- successResult: (value: THolder, usage?: Usage) => TResult;
35
- canceledResult: (diagnostics: ChildFailureDiagnostics, usage?: Usage) => TResult;
36
- failedResult: (
37
- failureCode: "prompt-rejected" | "missing-structured-output" | "unexpected-runner-failure",
38
- diagnostics: ChildFailureDiagnostics,
39
- usage?: Usage,
40
- ) => TResult;
41
- timeoutResult: (
42
- timeoutMs: number,
43
- diagnostics: ChildFailureDiagnostics,
44
- usage?: Usage,
45
- ) => TResult;
46
- sessionFailedResult: TResult;
47
34
  onProgress?: (progress: ReviewProgress) => void;
48
35
  }
49
36
 
@@ -57,14 +44,19 @@ async function disposeRuntime(runtime: AgentSessionRuntime): Promise<void> {
57
44
  ]);
58
45
  }
59
46
 
47
+ /** Spread helper: include `usage` only when present (honors exact optional properties). */
48
+ function usageFields(usage: Usage | undefined): { usage?: Usage } {
49
+ return usage ? { usage } : {};
50
+ }
51
+
60
52
  /**
61
53
  * Shared orchestration for isolated child sessions: resource loading,
62
54
  * AgentSession runtime lifecycle, and lifecycle wiring so Planner and reviewer
63
55
  * runners share one pattern rather than duplicating it.
64
56
  */
65
- export async function runIsolatedChild<THolder, TResult>(
66
- config: IsolatedRunConfig<THolder, TResult>,
67
- ): Promise<TResult> {
57
+ export async function runIsolatedChild<T>(
58
+ config: IsolatedRunConfig<T>,
59
+ ): Promise<ChildRunOutcome<T>> {
68
60
  const agentDir = process.env.PI_CODING_AGENT_DIR || getAgentDir();
69
61
  const { loader, settingsManager } = createIsolatedChildResources(
70
62
  config.cwd,
@@ -111,7 +103,7 @@ export async function runIsolatedChild<THolder, TResult>(
111
103
  const activeRuntime = runtime;
112
104
  await activeRuntime.session.bindExtensions({ mode: "print" });
113
105
  config.onSessionCreated?.(activeRuntime.session);
114
- return await runWithLifecycle({
106
+ return await runWithLifecycle<ChildRunOutcome<T>>({
115
107
  session: activeRuntime.session,
116
108
  dispose: () => {
117
109
  runtimeDisposal ??= disposeRuntime(activeRuntime);
@@ -131,23 +123,36 @@ export async function runIsolatedChild<THolder, TResult>(
131
123
  config.onProgress?.({ ...ctx.progress });
132
124
  }
133
125
  if (event.type !== "agent_settled") return;
134
- const result = config.holder.value
135
- ? config.successResult(config.holder.value, ctx.getUsage())
136
- : config.failedResult(
137
- "missing-structured-output",
138
- ctx.getFailureDiagnostics(),
139
- ctx.getUsage(),
140
- );
126
+ const result: ChildRunOutcome<T> = config.holder.value
127
+ ? { kind: "success", value: config.holder.value, ...usageFields(ctx.getUsage()) }
128
+ : {
129
+ kind: "failed",
130
+ failureCode: "missing-structured-output",
131
+ diagnostics: ctx.getFailureDiagnostics(),
132
+ ...usageFields(ctx.getUsage()),
133
+ };
141
134
  ctx.resolve(ctx.cleanup(result));
142
135
  },
143
- canceledResult: (ctx) => config.canceledResult(ctx.getFailureDiagnostics(), ctx.getUsage()),
144
- failedResult: (failureCode, ctx) =>
145
- config.failedResult(failureCode, ctx.getFailureDiagnostics(), ctx.getUsage()),
146
- timeoutResult: (timeoutMs, ctx) =>
147
- config.timeoutResult(timeoutMs, ctx.getFailureDiagnostics(), ctx.getUsage()),
136
+ canceledResult: (ctx) => ({
137
+ kind: "canceled",
138
+ diagnostics: ctx.getFailureDiagnostics(),
139
+ ...usageFields(ctx.getUsage()),
140
+ }),
141
+ failedResult: (failureCode, ctx) => ({
142
+ kind: "failed",
143
+ failureCode,
144
+ diagnostics: ctx.getFailureDiagnostics(),
145
+ ...usageFields(ctx.getUsage()),
146
+ }),
147
+ timeoutResult: (timeoutMs, ctx) => ({
148
+ kind: "timeout",
149
+ timeoutMs,
150
+ diagnostics: ctx.getFailureDiagnostics(),
151
+ ...usageFields(ctx.getUsage()),
152
+ }),
148
153
  });
149
154
  } catch {
150
- return config.sessionFailedResult;
155
+ return { kind: "failed", failureCode: "session-creation-failed" };
151
156
  } finally {
152
157
  if (runtime) {
153
158
  runtimeDisposal ??= disposeRuntime(runtime);
@@ -51,7 +51,7 @@ export async function runPlanner(invocation: PlannerInvocation): Promise<Planner
51
51
  };
52
52
  },
53
53
  });
54
- return runIsolatedChild<PlannerDraft, PlannerRunResult>({
54
+ return runIsolatedChild<PlannerDraft>({
55
55
  cwd: invocation.cwd,
56
56
  protocolPrompt: buildPlannerSystemPrompt(),
57
57
  model: invocation.model,
@@ -62,29 +62,6 @@ export async function runPlanner(invocation: PlannerInvocation): Promise<Planner
62
62
  tools: [submit.name],
63
63
  customTools: [submit],
64
64
  holder,
65
- successResult: (draft, usage) => ({
66
- kind: "success",
67
- draft,
68
- ...(usage ? { usage } : {}),
69
- }),
70
- canceledResult: (diagnostics, usage) => ({
71
- kind: "canceled",
72
- diagnostics,
73
- ...(usage ? { usage } : {}),
74
- }),
75
- failedResult: (failureCode, diagnostics, usage) => ({
76
- kind: "failed",
77
- failureCode,
78
- diagnostics,
79
- ...(usage ? { usage } : {}),
80
- }),
81
- timeoutResult: (timeoutMs, diagnostics, usage) => ({
82
- kind: "timeout",
83
- timeoutMs,
84
- diagnostics,
85
- ...(usage ? { usage } : {}),
86
- }),
87
- sessionFailedResult: { kind: "failed", failureCode: "session-creation-failed" },
88
65
  onProgress: invocation.onProgress,
89
66
  });
90
67
  }
@@ -52,7 +52,7 @@ function toTaskResult(
52
52
  ...(result.audit ? { audit: result.audit } : {}),
53
53
  };
54
54
  if (result.kind === "success") {
55
- const normalized = normalizeReviewSubmission(result.submission);
55
+ const normalized = normalizeReviewSubmission(result.value);
56
56
  return {
57
57
  status: "completed",
58
58
  ...identity,
@@ -38,12 +38,11 @@ export async function runReviewer(invocation: ReviewerInvocation): Promise<Revie
38
38
  const warnings: ReviewerCapabilityWarning[] = [];
39
39
  const protocolPrompt = buildReviewerSystemPrompt(invocation.dependencyBootstrapConfigured);
40
40
  const thinkingLevel = clampThinkingLevel(invocation.model.model, "max");
41
- const withWarnings = () => (warnings.length > 0 ? { capabilityWarnings: warnings } : {});
42
41
  let session: AgentSession | undefined;
43
42
  let trace: ReviewAuditTraceCollector | undefined;
44
43
  let unsubscribe: (() => void) | undefined;
45
44
 
46
- const result = await runIsolatedChild<ReviewSubmission, ReviewerRunResult>({
45
+ const outcome = await runIsolatedChild<ReviewSubmission>({
47
46
  cwd: invocation.cwd,
48
47
  protocolPrompt,
49
48
  model: invocation.model.model,
@@ -69,44 +68,14 @@ export async function runReviewer(invocation: ReviewerInvocation): Promise<Revie
69
68
  "Headless Code Intelligence was unavailable; this reviewer continued with read, bash, and grep inspection.",
70
69
  });
71
70
  },
72
- successResult: (submission, usage) => ({
73
- kind: "success",
74
- submission,
75
- modelId: invocation.model.canonicalId,
76
- ...(usage ? { usage } : {}),
77
- ...withWarnings(),
78
- }),
79
- canceledResult: (diagnostics, usage) => ({
80
- kind: "canceled",
81
- modelId: invocation.model.canonicalId,
82
- diagnostics,
83
- ...(usage ? { usage } : {}),
84
- ...withWarnings(),
85
- }),
86
- failedResult: (failureCode, diagnostics, usage) => ({
87
- kind: "failed",
88
- failureCode,
89
- modelId: invocation.model.canonicalId,
90
- diagnostics,
91
- ...(usage ? { usage } : {}),
92
- ...withWarnings(),
93
- }),
94
- timeoutResult: (timeoutMs, diagnostics, usage) => ({
95
- kind: "timeout",
96
- timeoutMs,
97
- modelId: invocation.model.canonicalId,
98
- diagnostics,
99
- ...(usage ? { usage } : {}),
100
- ...withWarnings(),
101
- }),
102
- sessionFailedResult: {
103
- kind: "failed",
104
- failureCode: "session-creation-failed",
105
- modelId: invocation.model.canonicalId,
106
- },
107
71
  onProgress: invocation.onProgress,
108
72
  });
109
73
  unsubscribe?.();
74
+ const result: ReviewerRunResult = {
75
+ ...outcome,
76
+ modelId: invocation.model.canonicalId,
77
+ ...(warnings.length > 0 ? { capabilityWarnings: warnings } : {}),
78
+ };
110
79
  if (!invocation.audit || !session || !trace) return result;
111
80
 
112
81
  try {
@@ -153,7 +153,7 @@ async function preparePlanner(
153
153
  };
154
154
  if (result.kind === "canceled") return { canceled: result, ...identity };
155
155
  if (result.kind === "success") {
156
- return { draft: normalizeReviewInput(result.draft), ...identity };
156
+ return { draft: normalizeReviewInput(result.value), ...identity };
157
157
  }
158
158
  return { failure: result, ...identity };
159
159
  }
package/src/types.ts CHANGED
@@ -181,6 +181,20 @@ export type ChildFailedResult =
181
181
  diagnostics: ChildFailureDiagnostics;
182
182
  };
183
183
 
184
+ /**
185
+ * Typed result of running one isolated child session (planner or reviewer).
186
+ *
187
+ * Substrate-level: it carries the structured `value` on success, aggregate
188
+ * `usage`, and bounded failure diagnostics — but no modelId, capability
189
+ * warnings, or audit. Adapters attach those domain facts. `session-creation-failed`
190
+ * stays a diagnostics-free `failed` via {@link ChildFailedResult}.
191
+ */
192
+ export type ChildRunOutcome<T> =
193
+ | { kind: "success"; value: T; usage?: Usage }
194
+ | ({ kind: "failed"; usage?: Usage } & ChildFailedResult)
195
+ | { kind: "canceled"; diagnostics: ChildFailureDiagnostics; usage?: Usage }
196
+ | { kind: "timeout"; timeoutMs: number; diagnostics: ChildFailureDiagnostics; usage?: Usage };
197
+
184
198
  export interface ReviewProgress {
185
199
  turns: number;
186
200
  toolUses: number;
@@ -202,11 +216,7 @@ export interface PlannerInvocation {
202
216
  onProgress?: (progress: ReviewProgress) => void;
203
217
  }
204
218
 
205
- export type PlannerRunResult =
206
- | { kind: "success"; draft: PlannerDraft; usage?: Usage }
207
- | ({ kind: "failed"; usage?: Usage } & ChildFailedResult)
208
- | { kind: "canceled"; diagnostics: ChildFailureDiagnostics; usage?: Usage }
209
- | { kind: "timeout"; timeoutMs: number; diagnostics: ChildFailureDiagnostics; usage?: Usage };
219
+ export type PlannerRunResult = ChildRunOutcome<PlannerDraft>;
210
220
 
211
221
  /** Parent-facing execution provenance for an unavailable Reviewer Extension Set capability. */
212
222
  export interface ReviewerCapabilityWarning {
@@ -233,18 +243,8 @@ export interface ReviewerInvocation {
233
243
  onProgress?: (progress: ReviewProgress) => void;
234
244
  }
235
245
 
236
- export type ReviewerRunResult = (
237
- | { kind: "success"; submission: ReviewSubmission; modelId: string; usage?: Usage }
238
- | ({ kind: "failed"; modelId: string; usage?: Usage } & ChildFailedResult)
239
- | { kind: "canceled"; modelId: string; diagnostics: ChildFailureDiagnostics; usage?: Usage }
240
- | {
241
- kind: "timeout";
242
- timeoutMs: number;
243
- modelId: string;
244
- diagnostics: ChildFailureDiagnostics;
245
- usage?: Usage;
246
- }
247
- ) & {
246
+ export type ReviewerRunResult = ChildRunOutcome<ReviewSubmission> & {
247
+ modelId: string;
248
248
  capabilityWarnings?: ReviewerCapabilityWarning[];
249
249
  audit?: ReviewAuditReference;
250
250
  };
@@ -1,41 +0,0 @@
1
- /** Calls markdown renderer — renders assembled structural-call evidence. */
2
-
3
- import {
4
- type EvidenceList,
5
- type EvidenceListMetadata,
6
- renderEvidenceListMetadataDisclosure,
7
- } from "../../analysis/evidence.ts";
8
- import type { CallEntry, CalleeScope } from "../../analysis/relations/types.ts";
9
-
10
- export function renderCallsResult(
11
- enclosingScope: CalleeScope,
12
- calls: EvidenceList<CallEntry>,
13
- relPath: string,
14
- depth: "direct" | "deep" = "direct",
15
- ): { content: string; evidenceList: EvidenceListMetadata } {
16
- const lines: string[] = [];
17
- const depthLabel = depth === "deep" ? "Deep structural calls" : "Direct structural calls";
18
- const depthNote =
19
- depth === "deep"
20
- ? "_Deep: includes calls from nested function/method/callback scopes within the enclosing scope._"
21
- : "_Structural only: call expressions are reported by source shape, not symbol identity; calls inside nested function/method/callback scopes are excluded from this enclosing scope._";
22
- const total = calls.metadata.totalCount ?? calls.metadata.shownCount;
23
-
24
- lines.push(`# ${depthLabel} from \`${enclosingScope.name}\``, "");
25
- lines.push(
26
- `**${total} ${depth === "deep" ? "" : "direct "}structural call${total === 1 ? "" : "s"}** from enclosing scope \`${enclosingScope.name}\` (${formatScopeRange(enclosingScope)}) in \`${relPath}\``,
27
- "",
28
- depthNote,
29
- "",
30
- );
31
-
32
- for (const call of calls.items) lines.push(`- \`${call.name}\` (L${call.line})`);
33
- const disclosure = renderEvidenceListMetadataDisclosure(calls.metadata);
34
- if (disclosure) lines.push(disclosure);
35
- return { content: lines.join("\n"), evidenceList: calls.metadata };
36
- }
37
-
38
- function formatScopeRange(scope: CalleeScope): string {
39
- if (scope.startLine === scope.endLine) return `L${scope.startLine}`;
40
- return `L${scope.startLine}–L${scope.endLine}`;
41
- }
@@ -1,57 +0,0 @@
1
- /** Implementations markdown renderer over assembled semantic evidence. */
2
-
3
- import {
4
- type EvidenceList,
5
- type EvidenceListMetadata,
6
- renderEvidenceListMetadataDisclosure,
7
- } from "../../analysis/evidence.ts";
8
- import { compactLineRanges } from "../../analysis/references/semantic-refs.ts";
9
- import type { ImplementationEntry } from "../../analysis/relations/types.ts";
10
- import { toDisplayPath } from "../../analysis/search/paths.ts";
11
- import { renderInvalidProviderLocations } from "./provider-location-md.ts";
12
-
13
- function groupByFile(impls: readonly ImplementationEntry[], cwd: string): Map<string, number[]> {
14
- const byFile = new Map<string, number[]>();
15
- for (const impl of impls) {
16
- const displayPath = toDisplayPath(cwd, impl.file);
17
- const group = byFile.get(displayPath) ?? [];
18
- group.push(impl.line);
19
- byFile.set(displayPath, group);
20
- }
21
- return byFile;
22
- }
23
-
24
- export function renderImplementationsResult(options: {
25
- implementations: EvidenceList<ImplementationEntry>;
26
- externalCount: number;
27
- cwd: string;
28
- targetName?: string;
29
- }): { content: string; evidenceList: EvidenceListMetadata } {
30
- const lines: string[] = [
31
- options.targetName
32
- ? `# Implementations of \`${options.targetName}\` (semantic)`
33
- : "# Implementations (semantic)",
34
- "",
35
- ];
36
- const total =
37
- options.implementations.metadata.totalCount ?? options.implementations.metadata.shownCount;
38
- if (total > 0) {
39
- lines.push(`**${total} implementation${total === 1 ? "" : "s"}** in the project`, "");
40
- for (const [file, locations] of groupByFile(options.implementations.items, options.cwd)) {
41
- lines.push(`### ${file}`, `- ${compactLineRanges(locations)}`, "");
42
- }
43
- const disclosure = renderEvidenceListMetadataDisclosure(options.implementations.metadata);
44
- if (disclosure) lines.push(disclosure);
45
- }
46
-
47
- if (options.externalCount > 0) {
48
- lines.push(
49
- `_+${options.externalCount} external location${options.externalCount === 1 ? "" : "s"} (outside this project)_`,
50
- "",
51
- );
52
- }
53
- const invalidDisclosure = renderInvalidProviderLocations(options.implementations.metadata);
54
- if (invalidDisclosure) lines.push(invalidDisclosure, "");
55
-
56
- return { content: lines.join("\n"), evidenceList: options.implementations.metadata };
57
- }
@@ -1,88 +0,0 @@
1
- /** Markdown adapter for assembled code_graph evidence. */
2
-
3
- import { renderReadNextSection } from "../../analysis/read-next.ts";
4
- import type { GraphResultAssembly } from "../result/graph.ts";
5
- import { renderCallsResult } from "./calls-md.ts";
6
- import { renderImplementationsResult } from "./implementations-md.ts";
7
- import { renderReferencesResult } from "./references-md.ts";
8
-
9
- /** Render an assembled graph result. */
10
- export function renderGraphResult(assembly: GraphResultAssembly): string {
11
- const lines = [
12
- `# Graph of \`${assembly.displayName}\``,
13
- "",
14
- `_File: \`${assembly.resolvedDisplayFile}\`_`,
15
- "",
16
- ];
17
-
18
- const available = assembly.sections.filter((section) => section.kind === "ok");
19
- if (available.length > 0) {
20
- lines.push(
21
- available
22
- .map(
23
- (section) =>
24
- `**${section.rel}**: ${sectionCount(section)} result${sectionCount(section) === 1 ? "" : "s"}`,
25
- )
26
- .join(" | "),
27
- "",
28
- );
29
- }
30
-
31
- const unavailable = assembly.sections.filter((section) => section.kind === "unavailable");
32
- if (unavailable.length > 0) {
33
- lines.push(
34
- `_Unavailable: ${unavailable.map((section) => `\`${section.rel}\``).join(", ")}_`,
35
- "",
36
- );
37
- }
38
-
39
- for (const section of assembly.sections) {
40
- if (section.kind === "unavailable") {
41
- lines.push(`**${section.rel}**: ${section.message}`, "");
42
- continue;
43
- }
44
-
45
- switch (section.rel) {
46
- case "references": {
47
- const rendered = renderReferencesResult({
48
- symbolName: assembly.displayName,
49
- references: section.evidence,
50
- externalCount: section.data.externalCount,
51
- confidence: section.data.confidence,
52
- cwd: assembly.cwd,
53
- });
54
- lines.push(rendered.content, "");
55
- break;
56
- }
57
- case "callees": {
58
- const rendered = renderCallsResult(
59
- section.data.enclosingScope,
60
- section.evidence,
61
- assembly.resolvedDisplayFile,
62
- section.data.depth,
63
- );
64
- lines.push(rendered.content, "");
65
- break;
66
- }
67
- case "implements": {
68
- const rendered = renderImplementationsResult({
69
- implementations: section.evidence,
70
- externalCount: section.data.externalCount,
71
- cwd: assembly.cwd,
72
- targetName: assembly.displayName,
73
- });
74
- lines.push(rendered.content, "");
75
- break;
76
- }
77
- }
78
- }
79
-
80
- lines.push(...renderReadNextSection(available.flatMap((section) => section.readNext)));
81
- return lines.join("\n");
82
- }
83
-
84
- function sectionCount(
85
- section: Extract<GraphResultAssembly["sections"][number], { kind: "ok" }>,
86
- ): number {
87
- return section.evidence.metadata.totalCount ?? section.evidence.metadata.shownCount;
88
- }
@@ -1,9 +0,0 @@
1
- import type { EvidenceListMetadata } from "../../analysis/evidence.ts";
2
-
3
- /** Render an explicit disclosure for unusable semantic-provider locations. */
4
- export function renderInvalidProviderLocations(metadata: EvidenceListMetadata): string | null {
5
- const count = metadata.invalidLocationCount ?? 0;
6
- if (count <= 0 || metadata.partialReason === null) return null;
7
- const noun = count === 1 ? "location" : "locations";
8
- return `_${count} invalid provider ${noun} omitted (${metadata.partialReason})_`;
9
- }