@mrclrchtr/supi-review 4.1.0 → 4.2.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/node_modules/@mrclrchtr/supi-code-intelligence/README.md +4 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-code-runtime/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-code-runtime/package.json +2 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- 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
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +2 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/package.json +3 -3
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-lsp/src/utils.ts +2 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/README.md +5 -5
- 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
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +2 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/package.json +3 -3
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/src/language.ts +2 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/src/operation-support.ts +19 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/src/syntax-node.ts +1 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/outline-c-family.ts +230 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/outline-html-sql.ts +186 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/outline-jvm.ts +311 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/outline-polyglot.ts +218 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/outline-scripting.ts +307 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/outline.ts +9 -5
- package/node_modules/@mrclrchtr/supi-code-intelligence/node_modules/@mrclrchtr/supi-tree-sitter/src/types.ts +6 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/package.json +5 -5
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/analysis/search/pattern.ts +2 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/analysis/target/symbol.ts +5 -2
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/session/orientation/collect.ts +134 -180
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/session/orientation/context-sections.ts +14 -48
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/session/orientation-types.ts +14 -4
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/session/orientation-workflow.ts +20 -48
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/graph/execute.ts +1 -1
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/graph/markdown.ts +222 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/orientation/markdown.ts +66 -11
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/register.ts +10 -0
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/ui/markdown/overview-data.ts +3 -15
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/ui/markdown/overview.ts +4 -10
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/ui/markdown/types.ts +0 -1
- package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/package.json +3 -3
- package/src/tool/child-session-runner.ts +38 -33
- package/src/tool/planner-runner.ts +1 -24
- package/src/tool/review-execution.ts +1 -1
- package/src/tool/review-runner.ts +6 -37
- package/src/tool/review-workflow.ts +1 -1
- package/src/types.ts +17 -17
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/graph/calls-md.ts +0 -41
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/graph/implementations-md.ts +0 -57
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/graph/markdown-base.ts +0 -88
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/graph/provider-location-md.ts +0 -9
- package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/graph/references-md.ts +0 -41
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
SessionManager,
|
|
9
9
|
type ToolDefinition,
|
|
10
10
|
} from "@earendil-works/pi-coding-agent";
|
|
11
|
-
import type {
|
|
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<
|
|
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?:
|
|
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<
|
|
66
|
-
config: IsolatedRunConfig<
|
|
67
|
-
): Promise<
|
|
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.
|
|
136
|
-
:
|
|
137
|
-
"
|
|
138
|
-
|
|
139
|
-
ctx.
|
|
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) =>
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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
|
|
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
|
|
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.
|
|
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
|
|
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.
|
|
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
|
-
|
|
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
|
-
}
|
package/node_modules/@mrclrchtr/supi-code-intelligence/src/tool/graph/provider-location-md.ts
DELETED
|
@@ -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
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/** References markdown renderer over assembled semantic evidence. */
|
|
2
|
-
|
|
3
|
-
import type { EvidenceList, EvidenceListMetadata } from "../../analysis/evidence.ts";
|
|
4
|
-
import { formatAssembledReferenceList } from "../../analysis/references/semantic-refs.ts";
|
|
5
|
-
import type { ReferenceEntry } from "../../analysis/relations/types.ts";
|
|
6
|
-
import { toDisplayPath } from "../../analysis/search/paths.ts";
|
|
7
|
-
import { renderInvalidProviderLocations } from "./provider-location-md.ts";
|
|
8
|
-
|
|
9
|
-
export function renderReferencesResult(options: {
|
|
10
|
-
symbolName: string;
|
|
11
|
-
references: EvidenceList<ReferenceEntry>;
|
|
12
|
-
externalCount: number;
|
|
13
|
-
confidence: string;
|
|
14
|
-
cwd: string;
|
|
15
|
-
}): { content: string; evidenceList: EvidenceListMetadata | null } {
|
|
16
|
-
const total = options.references.metadata.totalCount ?? options.references.metadata.shownCount;
|
|
17
|
-
const lines = [
|
|
18
|
-
`# References of \`${options.symbolName}\``,
|
|
19
|
-
"",
|
|
20
|
-
`**${total} reference${total === 1 ? "" : "s"}** (${options.confidence})`,
|
|
21
|
-
];
|
|
22
|
-
if (options.externalCount > 0) {
|
|
23
|
-
lines.push(
|
|
24
|
-
`_+${options.externalCount} external reference${options.externalCount === 1 ? "" : "s"}_`,
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
const invalidDisclosure = renderInvalidProviderLocations(options.references.metadata);
|
|
28
|
-
if (invalidDisclosure) lines.push(invalidDisclosure);
|
|
29
|
-
lines.push("");
|
|
30
|
-
|
|
31
|
-
const displayEvidence = {
|
|
32
|
-
key: options.references.key,
|
|
33
|
-
items: options.references.items.map((reference) => ({
|
|
34
|
-
file: toDisplayPath(options.cwd, reference.file),
|
|
35
|
-
line: reference.line,
|
|
36
|
-
})),
|
|
37
|
-
metadata: options.references.metadata,
|
|
38
|
-
};
|
|
39
|
-
const evidenceList = formatAssembledReferenceList(lines, displayEvidence);
|
|
40
|
-
return { content: lines.join("\n"), evidenceList };
|
|
41
|
-
}
|