@mrclrchtr/supi-code-intelligence 4.10.0 → 6.0.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/README.md +4 -3
- package/node_modules/@mrclrchtr/supi-code-runtime/README.md +2 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +9 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +53 -13
- package/node_modules/@mrclrchtr/supi-code-runtime/src/request-control.ts +47 -0
- package/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +13 -1
- package/node_modules/@mrclrchtr/supi-core/README.md +2 -0
- package/node_modules/@mrclrchtr/supi-core/package.json +2 -2
- package/node_modules/@mrclrchtr/supi-core/src/api.ts +1 -1
- package/node_modules/@mrclrchtr/supi-core/src/config/config.ts +31 -0
- package/node_modules/@mrclrchtr/supi-core/src/config.ts +2 -0
- package/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +19 -6
- package/node_modules/@mrclrchtr/supi-core/src/debug.ts +9 -0
- package/node_modules/@mrclrchtr/supi-core/src/index.ts +1 -1
- package/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +3 -0
- package/node_modules/@mrclrchtr/supi-lsp/README.md +111 -5
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/README.md +2 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +9 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +53 -13
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/request-control.ts +47 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +13 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/README.md +2 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +2 -2
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/api.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/config/config.ts +31 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/config.ts +2 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +19 -6
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/debug.ts +9 -0
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/index.ts +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +3 -0
- package/node_modules/@mrclrchtr/supi-lsp/package.json +7 -6
- package/node_modules/@mrclrchtr/supi-lsp/src/api.ts +22 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-cache.ts +245 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-capabilities.ts +78 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-collection.ts +171 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-evidence.ts +413 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-host.ts +15 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-publication.ts +214 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-pull.ts +62 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-refresh.ts +690 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-request.ts +9 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-timing.ts +97 -16
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-waiters.ts +206 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +448 -298
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-document-state.ts +70 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-document-sync.ts +231 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client-file-state.ts +25 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +529 -119
- package/node_modules/@mrclrchtr/supi-lsp/src/client/transport.ts +161 -33
- package/node_modules/@mrclrchtr/supi-lsp/src/config/capabilities.ts +12 -3
- package/node_modules/@mrclrchtr/supi-lsp/src/config/config.ts +5 -5
- package/node_modules/@mrclrchtr/supi-lsp/src/config/defaults.json +1 -1
- package/node_modules/@mrclrchtr/supi-lsp/src/config/server-config.ts +3 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-extends.ts +68 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-path.ts +8 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-scope.ts +176 -24
- package/node_modules/@mrclrchtr/supi-lsp/src/debug-telemetry.ts +45 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/evidence.ts +42 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/diagnostics/workspace-sentinels.ts +46 -10
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-client-state.ts +79 -9
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-diagnostics.ts +17 -7
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-recovery.ts +350 -26
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-workspace-symbol.ts +5 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +586 -96
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-refactor-provider.ts +130 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-semantic-provider.ts +45 -329
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-planning.ts +57 -120
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-edit-normalizer.ts +320 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-symbol-mapper.ts +207 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/readiness.ts +72 -2
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-controller.ts +151 -26
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-diagnostic-surface.ts +42 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-diagnostics.ts +92 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +165 -118
- package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-transition-debug.ts +49 -0
- package/node_modules/@mrclrchtr/supi-lsp/src/session/workspace-lsp-runtime.ts +102 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +17 -7
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/README.md +2 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +9 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/capability/types.ts +53 -13
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/request-control.ts +47 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +13 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/README.md +2 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +2 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/api.ts +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/config/config.ts +31 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/config.ts +2 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug-registry.ts +19 -6
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/debug.ts +9 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/index.ts +1 -1
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/src/settings/settings-registry.ts +3 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/LICENSE +21 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/README.md +258 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/dist/babel.cjs +257 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/dist/jiti.cjs +1 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-cli.mjs +34 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-hooks.mjs +124 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-native.mjs +121 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-register.d.mts +1 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-register.mjs +4 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti-static.mjs +23 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti.cjs +30 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti.d.cts +8 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti.d.mts +8 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/jiti.mjs +29 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/lib/types.d.ts +420 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/jiti/package.json +146 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +6 -3
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/api.ts +0 -9
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/index.ts +0 -8
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/provider/tree-sitter-provider.ts +16 -12
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/runtime-controller.ts +65 -87
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/session.ts +47 -95
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-timing.ts +147 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-client-lifecycle.ts +39 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-client.ts +561 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-message-size.ts +24 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-protocol.ts +452 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-sites.ts +4 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/callees.ts +12 -4
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/exports.ts +4 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/imports.ts +4 -2
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/node-at.ts +5 -3
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/types.ts +33 -12
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/blocking-test-bootstrap.mjs +34 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/bootstrap.mjs +8 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/parsed-file-store-helpers.ts +23 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/parsed-file-store.ts +400 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/request-control.ts +48 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/runtime-parser-helpers.ts +24 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/runtime-query-helpers.ts +43 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/runtime.ts +421 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/service.ts +116 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/worker-main.ts +201 -0
- package/package.json +5 -5
- package/src/analysis/health/diagnostics.ts +221 -77
- package/src/analysis/health/file-scope.ts +184 -0
- package/src/analysis/health/recovery.ts +14 -3
- package/src/analysis/provider.ts +58 -0
- package/src/analysis/readiness.ts +34 -9
- package/src/analysis/refactor/apply.ts +45 -1
- package/src/analysis/refactor/mutation-authority.ts +143 -0
- package/src/analysis/relations/callees.ts +9 -1
- package/src/analysis/relations/types.ts +5 -2
- package/src/analysis/search/ast-scan-timing.ts +9 -2
- package/src/analysis/search/ast-scan.ts +5 -2
- package/src/analysis/search/deadline.ts +2 -2
- package/src/analysis/search/pattern-analysis.ts +54 -33
- package/src/analysis/search/pattern.ts +18 -3
- package/src/analysis/target/anchored.ts +20 -11
- package/src/analysis/target/file.ts +18 -11
- package/src/analysis/target/identity.ts +19 -3
- package/src/analysis/target/symbol.ts +36 -15
- package/src/api.ts +4 -0
- package/src/config.ts +35 -1
- package/src/diagnostics/evidence.ts +51 -0
- package/src/extension.ts +57 -14
- package/src/overview/overview-data.ts +9 -2
- package/src/overview/overview.ts +49 -30
- package/src/overview/types.ts +2 -0
- package/src/session/capability-adapter.ts +12 -3
- package/src/session/find-types.ts +2 -2
- package/src/session/find-workflow.ts +20 -9
- package/src/session/graph/collect.ts +18 -2
- package/src/session/graph-workflow.ts +19 -12
- package/src/session/health-refresh.ts +175 -0
- package/src/session/health-types.ts +43 -15
- package/src/session/health-workflow.ts +69 -54
- package/src/session/input/workflows.ts +2 -2
- package/src/session/inspect/collect.ts +20 -3
- package/src/session/inspect-workflow.ts +12 -6
- package/src/session/orientation/collect.ts +12 -3
- package/src/session/orientation/context-facts.ts +3 -1
- package/src/session/orientation/context-sections.ts +20 -7
- package/src/session/orientation/gather.ts +17 -11
- package/src/session/orientation-types.ts +4 -1
- package/src/session/orientation-workflow.ts +23 -10
- package/src/session/refactor-plans.ts +2 -0
- package/src/session/refactor-workflow.ts +61 -15
- package/src/session/session.ts +29 -2
- package/src/session/target-workflow.ts +54 -23
- package/src/session/workflow-control.ts +7 -3
- package/src/substrate/lsp/lifecycle.ts +26 -46
- package/src/substrate/lsp/maintenance.ts +284 -28
- package/src/substrate/lsp/recovery.ts +11 -5
- package/src/substrate/lsp/state.ts +2 -2
- package/src/substrate/workspace-provider-host.ts +25 -3
- package/src/tool/{find → code_find}/execute.ts +2 -16
- package/src/tool/code_find/guidance.ts +8 -0
- package/src/tool/{find → code_find}/render.ts +21 -4
- package/src/tool/{result/find.ts → code_find/result.ts} +78 -9
- package/src/tool/code_find/spec.ts +37 -0
- package/src/tool/code_find/tui.ts +41 -0
- package/src/tool/code_graph/execute.ts +24 -0
- package/src/tool/code_graph/guidance.ts +6 -0
- package/src/tool/{graph → code_graph}/markdown.ts +1 -1
- package/src/tool/{result/graph.ts → code_graph/result.ts} +111 -3
- package/src/tool/code_graph/spec.ts +39 -0
- package/src/tool/code_graph/tui.ts +117 -0
- package/src/tool/{health → code_health}/execute.ts +2 -13
- package/src/tool/code_health/guidance.ts +8 -0
- package/src/tool/{health → code_health}/markdown.ts +119 -27
- package/src/tool/code_health/refresh-status.ts +105 -0
- package/src/tool/{result/health.ts → code_health/result.ts} +80 -3
- package/src/tool/code_health/spec.ts +41 -0
- package/src/tool/{health → code_health}/tui.ts +95 -98
- package/src/tool/{inspect → code_inspect}/execute.ts +2 -16
- package/src/tool/code_inspect/guidance.ts +6 -0
- package/src/tool/{inspect → code_inspect}/markdown.ts +1 -1
- package/src/tool/{result/inspect.ts → code_inspect/result.ts} +143 -2
- package/src/tool/code_inspect/spec.ts +25 -0
- package/src/tool/code_inspect/tui.ts +44 -0
- package/src/tool/code_orientation/execute.ts +25 -0
- package/src/tool/code_orientation/guidance.ts +9 -0
- package/src/tool/{orientation → code_orientation}/markdown.ts +1 -1
- package/src/tool/code_orientation/result.ts +248 -0
- package/src/tool/code_orientation/spec.ts +25 -0
- package/src/tool/{orientation → code_orientation}/tui.ts +51 -35
- package/src/tool/code_refactor_apply/execute.ts +17 -0
- package/src/tool/code_refactor_apply/guidance.ts +5 -0
- package/src/tool/{refactor-apply/execute.ts → code_refactor_apply/result.ts} +8 -11
- package/src/tool/code_refactor_apply/spec.ts +26 -0
- package/src/tool/code_refactor_apply/tui.ts +73 -0
- package/src/tool/code_refactor_plan/execute.ts +27 -0
- package/src/tool/code_refactor_plan/guidance.ts +8 -0
- package/src/tool/{refactor-plan/execute.ts → code_refactor_plan/result.ts} +13 -22
- package/src/tool/code_refactor_plan/spec.ts +25 -0
- package/src/tool/code_refactor_plan/tui.ts +54 -0
- package/src/tool/code_resolve/execute.ts +19 -0
- package/src/tool/code_resolve/guidance.ts +8 -0
- package/src/tool/{resolve → code_resolve}/markdown.ts +1 -1
- package/src/tool/{result/resolve.ts → code_resolve/result.ts} +79 -29
- package/src/tool/code_resolve/spec.ts +25 -0
- package/src/tool/code_resolve/tui.ts +60 -0
- package/src/tool/guidance.ts +71 -52
- package/src/tool/infra/truncate.ts +40 -0
- package/src/tool/infra/workflow-control.ts +8 -0
- package/src/tool/{refactor-plan/markdown.ts → refactor-markdown.ts} +4 -7
- package/src/tool/register.ts +105 -88
- package/src/tool/result/display.ts +107 -0
- package/src/tool/result/errors.ts +20 -17
- package/src/tool/result/refactor.ts +37 -8
- package/src/tool/result/types.ts +20 -0
- package/src/tool/schemas.ts +26 -157
- package/src/tool/specs.ts +40 -126
- package/src/types/execution.ts +18 -5
- package/src/types/index.ts +8 -1
- package/src/ui/status-command.ts +5 -3
- package/src/ui/status-overlay.ts +4 -0
- package/src/ui/tui/common.ts +108 -10
- package/src/ui/tui/display.ts +48 -0
- package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/runtime.ts +0 -351
- package/src/tool/find/tui.ts +0 -39
- package/src/tool/graph/execute.ts +0 -62
- package/src/tool/graph/tui.ts +0 -104
- package/src/tool/inspect/tui.ts +0 -36
- package/src/tool/orientation/execute.ts +0 -62
- package/src/tool/refactor-apply/tui.ts +0 -55
- package/src/tool/refactor-plan/tui.ts +0 -41
- package/src/tool/resolve/execute.ts +0 -36
- package/src/tool/resolve/tui.ts +0 -42
- package/src/tool/result/orientation.ts +0 -132
- /package/src/tool/{find → code_find}/ast-kinds.ts +0 -0
- /package/src/tool/{find → code_find}/markdown.ts +0 -0
- /package/src/tool/{find → code_find}/modes.ts +0 -0
- /package/src/tool/{health → code_health}/semantic-state.ts +0 -0
|
@@ -10,14 +10,16 @@ import {
|
|
|
10
10
|
assembleToolResult,
|
|
11
11
|
type ResultProvenance,
|
|
12
12
|
type ToolResultAssembly,
|
|
13
|
-
} from "
|
|
14
|
-
import
|
|
13
|
+
} from "../result/assembly.ts";
|
|
14
|
+
import { createToolDisplaySection } from "../result/display.ts";
|
|
15
|
+
import type { SearchDetails, ToolDisplaySection } from "../result/types.ts";
|
|
15
16
|
|
|
16
17
|
/** Presentation-neutral assembled find result. */
|
|
17
18
|
export interface FindResultAssembly {
|
|
18
19
|
outcome: Extract<FindWorkflowOutcome, { kind: "completed" }>;
|
|
19
20
|
assembled: ToolResultAssembly<Extract<FindWorkflowOutcome, { kind: "completed" }>["data"]>;
|
|
20
21
|
details: SearchDetails;
|
|
22
|
+
displaySections: readonly ToolDisplaySection[];
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
/** Assemble one completed code-aware search outcome before presentation. */
|
|
@@ -26,13 +28,7 @@ export function assembleFindWorkflowResult(
|
|
|
26
28
|
): FindResultAssembly {
|
|
27
29
|
const evidence = createFindEvidence(outcome);
|
|
28
30
|
const confidence: ConfidenceMode = outcome.data.kind === "semantic" ? "semantic" : "structural";
|
|
29
|
-
const nextQueries =
|
|
30
|
-
outcome.data.kind === "ast" && outcome.data.astKind === "call"
|
|
31
|
-
? [
|
|
32
|
-
"Use code_graph references on a resolved target for symbol-identity relationships",
|
|
33
|
-
"Use PI grep for literal or regex source matches when it is active",
|
|
34
|
-
]
|
|
35
|
-
: ["Change mode only when you need a different code-aware evidence substrate"];
|
|
31
|
+
const nextQueries = findNextQueries(outcome);
|
|
36
32
|
const provenance = findProvenance(outcome.data.kind);
|
|
37
33
|
const assembled = assembleToolResult({
|
|
38
34
|
data: outcome.data,
|
|
@@ -53,9 +49,22 @@ export function assembleFindWorkflowResult(
|
|
|
53
49
|
provenance,
|
|
54
50
|
});
|
|
55
51
|
|
|
52
|
+
const displaySections = [
|
|
53
|
+
createToolDisplaySection({
|
|
54
|
+
key: `find.${outcome.data.kind}`,
|
|
55
|
+
title: outcome.data.kind === "semantic" ? "Symbols" : "Matches",
|
|
56
|
+
items: findItems(outcome.data),
|
|
57
|
+
totalCount: evidence.metadata.totalCount,
|
|
58
|
+
omittedCount: evidence.metadata.omittedCount,
|
|
59
|
+
partialReason: evidence.metadata.partialReason,
|
|
60
|
+
format: (item) => formatFindDisplayItem(outcome.data.kind, item),
|
|
61
|
+
}),
|
|
62
|
+
];
|
|
63
|
+
|
|
56
64
|
return {
|
|
57
65
|
outcome,
|
|
58
66
|
assembled,
|
|
67
|
+
displaySections,
|
|
59
68
|
details: {
|
|
60
69
|
confidence,
|
|
61
70
|
scope: outcome.scopeLabel === "." ? null : outcome.scopeLabel,
|
|
@@ -68,6 +77,15 @@ export function assembleFindWorkflowResult(
|
|
|
68
77
|
};
|
|
69
78
|
}
|
|
70
79
|
|
|
80
|
+
function findNextQueries(outcome: Extract<FindWorkflowOutcome, { kind: "completed" }>): string[] {
|
|
81
|
+
if (outcome.data.kind === "semantic" && outcome.data.symbols.length === 0) {
|
|
82
|
+
return [
|
|
83
|
+
"If you know the file, use code_resolve with a file selector to enumerate document declarations",
|
|
84
|
+
];
|
|
85
|
+
}
|
|
86
|
+
return [];
|
|
87
|
+
}
|
|
88
|
+
|
|
71
89
|
function createFindEvidence(outcome: Extract<FindWorkflowOutcome, { kind: "completed" }>): {
|
|
72
90
|
total: number;
|
|
73
91
|
metadata: EvidenceListMetadata;
|
|
@@ -106,6 +124,25 @@ function findItems(
|
|
|
106
124
|
return data.kind === "semantic" ? data.symbols : data.result.matches;
|
|
107
125
|
}
|
|
108
126
|
|
|
127
|
+
function formatFindDisplayItem(kind: "semantic" | "ast", item: unknown): string {
|
|
128
|
+
if (kind === "ast") {
|
|
129
|
+
const match = item as { name: string; kind: string; file: string; line: number };
|
|
130
|
+
return `${match.name} (${match.kind}) — ${match.file}:L${match.line}`;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const symbol = item as {
|
|
134
|
+
name: string;
|
|
135
|
+
kind: string;
|
|
136
|
+
file: string;
|
|
137
|
+
container?: string | null;
|
|
138
|
+
nameAnchor?: { line: number };
|
|
139
|
+
declarationAnchor: { line: number };
|
|
140
|
+
};
|
|
141
|
+
const container = symbol.container ? ` in ${symbol.container}` : "";
|
|
142
|
+
const anchor = symbol.nameAnchor ?? symbol.declarationAnchor;
|
|
143
|
+
return `${symbol.name} [${symbol.kind}]${container} — ${symbol.file}:L${anchor.line}`;
|
|
144
|
+
}
|
|
145
|
+
|
|
109
146
|
function findProvenance(
|
|
110
147
|
kind: Extract<FindWorkflowOutcome, { kind: "completed" }>["data"]["kind"],
|
|
111
148
|
): ResultProvenance[] {
|
|
@@ -113,3 +150,35 @@ function findProvenance(
|
|
|
113
150
|
? [{ source: "semantic", capability: "workspace-symbol" }]
|
|
114
151
|
: [{ source: "structural", capability: "tree-sitter" }];
|
|
115
152
|
}
|
|
153
|
+
|
|
154
|
+
import type { CodeIntelResult, CodeIntelToolExecCtx } from "../../types/index.ts";
|
|
155
|
+
import { searchErrorResult } from "../result/errors.ts";
|
|
156
|
+
import { renderFindResult } from "./render.ts";
|
|
157
|
+
|
|
158
|
+
type FindOutcome = Awaited<ReturnType<CodeIntelToolExecCtx["session"]["find"]>>;
|
|
159
|
+
|
|
160
|
+
/** Assemble the final model-visible code_find result for one workflow outcome. */
|
|
161
|
+
export function finishFindResult(
|
|
162
|
+
outcome: FindOutcome,
|
|
163
|
+
scope: readonly string[] | undefined,
|
|
164
|
+
): CodeIntelResult {
|
|
165
|
+
if (outcome.kind === "unavailable") throw new Error(outcome.reason);
|
|
166
|
+
if (outcome.kind === "invalid-input") {
|
|
167
|
+
return searchErrorResult(`**Error:** ${outcome.message}`, {
|
|
168
|
+
scope: Array.isArray(scope) ? scope.join(", ") : null,
|
|
169
|
+
nextQueries: ["Fix the search input and retry"],
|
|
170
|
+
message: outcome.message,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const assembly = assembleFindWorkflowResult(outcome);
|
|
175
|
+
return {
|
|
176
|
+
content: renderFindResult(assembly),
|
|
177
|
+
details: {
|
|
178
|
+
type: "search",
|
|
179
|
+
data: assembly.details,
|
|
180
|
+
status: "completed",
|
|
181
|
+
displaySections: assembly.displaySections,
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { StringEnum } from "@earendil-works/pi-ai";
|
|
2
|
+
import { Type } from "typebox";
|
|
3
|
+
import type { CodeIntelToolExecCtx } from "../../types/index.ts";
|
|
4
|
+
import { FindScopeParam, MaxResultsParam, QueryParam } from "../schemas.ts";
|
|
5
|
+
import { CODE_FIND_AST_KINDS } from "./ast-kinds.ts";
|
|
6
|
+
import { executeFindTool } from "./execute.ts";
|
|
7
|
+
import { CODE_FIND_MODES } from "./modes.ts";
|
|
8
|
+
import { renderFindCall, renderFindResult } from "./tui.ts";
|
|
9
|
+
|
|
10
|
+
export const CODE_FIND_TOOL_NAME = "code_find";
|
|
11
|
+
export const CODE_FIND_TOOL_LABEL = "Code Find";
|
|
12
|
+
|
|
13
|
+
/** Canonical provider-facing metadata for the code_find tool. */
|
|
14
|
+
export const codeFindSpec = {
|
|
15
|
+
name: CODE_FIND_TOOL_NAME,
|
|
16
|
+
label: CODE_FIND_TOOL_LABEL,
|
|
17
|
+
parameters: Type.Object(
|
|
18
|
+
{
|
|
19
|
+
query: QueryParam,
|
|
20
|
+
scope: Type.Optional(FindScopeParam),
|
|
21
|
+
mode: StringEnum(CODE_FIND_MODES, {
|
|
22
|
+
description: 'Required code-aware search mode. mode:"ast" requires `kind`.',
|
|
23
|
+
}),
|
|
24
|
+
kind: Type.Optional(
|
|
25
|
+
StringEnum(CODE_FIND_AST_KINDS, {
|
|
26
|
+
description: 'AST kind for mode:"ast".',
|
|
27
|
+
}),
|
|
28
|
+
),
|
|
29
|
+
maxResults: Type.Optional(MaxResultsParam),
|
|
30
|
+
},
|
|
31
|
+
{ additionalProperties: false },
|
|
32
|
+
),
|
|
33
|
+
run: (params: unknown, ctx: CodeIntelToolExecCtx) =>
|
|
34
|
+
executeFindTool(params as Parameters<typeof executeFindTool>[0], ctx),
|
|
35
|
+
renderCall: renderFindCall,
|
|
36
|
+
renderResult: renderFindResult,
|
|
37
|
+
} as const;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** TUI renderer for code_find. */
|
|
2
|
+
import type { Theme } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
import { Text } from "@earendil-works/pi-tui";
|
|
4
|
+
import {
|
|
5
|
+
formatCallValue,
|
|
6
|
+
type ResultOptios,
|
|
7
|
+
renderSimpleResult,
|
|
8
|
+
type ToolRendererContext,
|
|
9
|
+
type ToolResult,
|
|
10
|
+
} from "../../ui/tui/common.ts";
|
|
11
|
+
import type { CodeFindToolParams } from "./execute.ts";
|
|
12
|
+
|
|
13
|
+
/** Render the compact code_find call header. */
|
|
14
|
+
export function renderFindCall(
|
|
15
|
+
args: unknown,
|
|
16
|
+
theme: Theme,
|
|
17
|
+
_context: ToolRendererContext | undefined,
|
|
18
|
+
): Text {
|
|
19
|
+
const params = (args ?? {}) as Partial<CodeFindToolParams>;
|
|
20
|
+
const mode = formatCallValue(params.mode, 20) ?? "mode?";
|
|
21
|
+
|
|
22
|
+
let content = theme.fg("toolTitle", "code_find");
|
|
23
|
+
const query = formatCallValue(params.query);
|
|
24
|
+
if (query) content += ` ${theme.fg("accent", JSON.stringify(query))}`;
|
|
25
|
+
content += ` ${theme.fg("muted", mode)}`;
|
|
26
|
+
|
|
27
|
+
const kind = formatCallValue(params.kind, 30);
|
|
28
|
+
if (kind) content += theme.fg("dim", ` [${kind}]`);
|
|
29
|
+
|
|
30
|
+
return new Text(content, 0, 0);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Render code_find progress, status, and structured result details. */
|
|
34
|
+
export function renderFindResult(
|
|
35
|
+
result: ToolResult,
|
|
36
|
+
options: ResultOptios,
|
|
37
|
+
theme: Theme,
|
|
38
|
+
context: ToolRendererContext | undefined,
|
|
39
|
+
): ReturnType<typeof renderSimpleResult> {
|
|
40
|
+
return renderSimpleResult(result, options, theme, "Searching…", context);
|
|
41
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** Thin Pi adapter for the session-owned code_graph workflow. */
|
|
2
|
+
|
|
3
|
+
import type { GraphWorkflowInput, RequestedGraphRelation } from "../../session/graph-types.ts";
|
|
4
|
+
import type { GraphTargetInput } from "../../session/target-input.ts";
|
|
5
|
+
import type { CodeIntelResult, CodeIntelToolExecCtx } from "../../types/index.ts";
|
|
6
|
+
import { toWorkflowControl } from "../infra/workflow-control.ts";
|
|
7
|
+
import { finishGraphResult } from "./result.ts";
|
|
8
|
+
|
|
9
|
+
export type GraphRelation = RequestedGraphRelation;
|
|
10
|
+
|
|
11
|
+
export interface CodeGraphToolParams {
|
|
12
|
+
target: GraphTargetInput;
|
|
13
|
+
relations?: GraphRelation[];
|
|
14
|
+
calleeDepth?: "direct" | "deep";
|
|
15
|
+
maxResults?: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export async function executeGraphTool(
|
|
19
|
+
params: CodeGraphToolParams,
|
|
20
|
+
ctx: CodeIntelToolExecCtx,
|
|
21
|
+
): Promise<CodeIntelResult> {
|
|
22
|
+
const outcome = await ctx.session.graph(params as GraphWorkflowInput, toWorkflowControl(ctx));
|
|
23
|
+
return finishGraphResult(outcome, ctx.cwd);
|
|
24
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export const toolDescription =
|
|
2
|
+
"Collect references, structural callees, and implementations for one target. Callees match source shape, not symbol identity.";
|
|
3
|
+
|
|
4
|
+
export const promptSnippet = "provider-backed and structural relation evidence";
|
|
5
|
+
|
|
6
|
+
export const promptGuidelines: string[] = [];
|
|
@@ -17,7 +17,7 @@ import type {
|
|
|
17
17
|
ReferenceEntry,
|
|
18
18
|
} from "../../analysis/relations/types.ts";
|
|
19
19
|
import { toDisplayPath } from "../../analysis/search/paths.ts";
|
|
20
|
-
import type { GraphResultAssembly } from "
|
|
20
|
+
import type { GraphResultAssembly } from "./result.ts";
|
|
21
21
|
|
|
22
22
|
/** Render an assembled graph result. */
|
|
23
23
|
export function renderGraphResult(assembly: GraphResultAssembly): string {
|
|
@@ -6,14 +6,16 @@ import type {
|
|
|
6
6
|
ImplementationEntry,
|
|
7
7
|
ReferenceEntry,
|
|
8
8
|
} from "../../analysis/relations/types.ts";
|
|
9
|
+
import { toDisplayPath } from "../../analysis/search/paths.ts";
|
|
9
10
|
import type { GraphSection } from "../../session/graph-types.ts";
|
|
10
11
|
import {
|
|
11
12
|
assembledNextQueries,
|
|
12
13
|
assembleToolResult,
|
|
13
14
|
type ResultProvenance,
|
|
14
15
|
type ToolResultAssembly,
|
|
15
|
-
} from "
|
|
16
|
-
import
|
|
16
|
+
} from "../result/assembly.ts";
|
|
17
|
+
import { createToolDisplaySection } from "../result/display.ts";
|
|
18
|
+
import type { SearchDetails, ToolDisplaySection } from "../result/types.ts";
|
|
17
19
|
|
|
18
20
|
export type { GraphRelationKind, GraphSection } from "../../session/graph-types.ts";
|
|
19
21
|
|
|
@@ -39,6 +41,7 @@ export interface GraphResultAssembly {
|
|
|
39
41
|
cwd: string;
|
|
40
42
|
assembled: ToolResultAssembly<{ readonly sections: readonly AssembledGraphSection[] }>;
|
|
41
43
|
details: SearchDetails;
|
|
44
|
+
displaySections: readonly ToolDisplaySection[];
|
|
42
45
|
}
|
|
43
46
|
|
|
44
47
|
/** Assemble graph evidence once before either presentation adapter consumes it. */
|
|
@@ -70,19 +73,22 @@ export function assembleGraphResult(input: {
|
|
|
70
73
|
provenance: section.kind === "ok" ? graphProvenance([section]) : [],
|
|
71
74
|
})),
|
|
72
75
|
evidenceLists,
|
|
73
|
-
nextQueries: [
|
|
76
|
+
nextQueries: [],
|
|
74
77
|
readNext: sections.flatMap((section) => (section.kind === "ok" ? section.readNext : [])),
|
|
75
78
|
candidateCount,
|
|
76
79
|
confidence,
|
|
77
80
|
provenance,
|
|
78
81
|
});
|
|
79
82
|
|
|
83
|
+
const displaySections = sections.map((section) => graphDisplaySection(section, input.cwd));
|
|
84
|
+
|
|
80
85
|
return {
|
|
81
86
|
displayName: input.displayName,
|
|
82
87
|
sections,
|
|
83
88
|
resolvedDisplayFile: input.resolvedDisplayFile,
|
|
84
89
|
cwd: input.cwd,
|
|
85
90
|
assembled,
|
|
91
|
+
displaySections,
|
|
86
92
|
details: {
|
|
87
93
|
confidence,
|
|
88
94
|
scope: null,
|
|
@@ -94,6 +100,43 @@ export function assembleGraphResult(input: {
|
|
|
94
100
|
};
|
|
95
101
|
}
|
|
96
102
|
|
|
103
|
+
function graphDisplaySection(section: AssembledGraphSection, cwd: string): ToolDisplaySection {
|
|
104
|
+
if (section.kind === "unavailable") {
|
|
105
|
+
return createToolDisplaySection({
|
|
106
|
+
key: `graph.${section.rel}`,
|
|
107
|
+
title: section.rel,
|
|
108
|
+
items: [section.message],
|
|
109
|
+
format: (message) => `Unavailable — ${message}`,
|
|
110
|
+
totalCount: 1,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return createToolDisplaySection({
|
|
115
|
+
key: `graph.${section.rel}`,
|
|
116
|
+
title: section.rel,
|
|
117
|
+
items: section.evidence.items as readonly unknown[],
|
|
118
|
+
totalCount: section.evidence.metadata.totalCount,
|
|
119
|
+
omittedCount: section.evidence.metadata.omittedCount,
|
|
120
|
+
partialReason: section.evidence.metadata.partialReason,
|
|
121
|
+
format: (item) => formatGraphDisplayItem(section.rel, item, cwd),
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function formatGraphDisplayItem(
|
|
126
|
+
relation: "references" | "callees" | "implements",
|
|
127
|
+
item: unknown,
|
|
128
|
+
cwd: string,
|
|
129
|
+
): string {
|
|
130
|
+
if (relation === "callees") {
|
|
131
|
+
const call = item as { name: string; file: string; line: number };
|
|
132
|
+
return `${call.name} — ${toDisplayPath(cwd, call.file)}:L${call.line}`;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const location = item as { name: string | null; file: string; line: number; character: number };
|
|
136
|
+
const name = location.name ? `${location.name} — ` : "";
|
|
137
|
+
return `${name}${toDisplayPath(cwd, location.file)}:L${location.line}:${location.character}`;
|
|
138
|
+
}
|
|
139
|
+
|
|
97
140
|
function assembleGraphSection(section: GraphSection, maxResults: number): AssembledGraphSection {
|
|
98
141
|
if (section.kind === "unavailable") return section;
|
|
99
142
|
switch (section.rel) {
|
|
@@ -190,3 +233,68 @@ function graphConfidence(sections: readonly AssembledGraphSection[]): Confidence
|
|
|
190
233
|
);
|
|
191
234
|
return hasSemantic ? "semantic" : hasStructural ? "structural" : "unavailable";
|
|
192
235
|
}
|
|
236
|
+
|
|
237
|
+
import type { CodeIntelResult, CodeIntelToolExecCtx } from "../../types/index.ts";
|
|
238
|
+
import { searchErrorResult } from "../result/errors.ts";
|
|
239
|
+
import { renderGraphResult } from "./markdown.ts";
|
|
240
|
+
|
|
241
|
+
type GraphOutcome = Awaited<ReturnType<CodeIntelToolExecCtx["session"]["graph"]>>;
|
|
242
|
+
|
|
243
|
+
/** Assemble the final model-visible code_graph result for one workflow outcome. */
|
|
244
|
+
export function finishGraphResult(outcome: GraphOutcome, cwd: string): CodeIntelResult {
|
|
245
|
+
if (outcome.kind === "unavailable") throw new Error(outcome.reason);
|
|
246
|
+
if (outcome.kind === "invalid-input") {
|
|
247
|
+
return searchErrorResult(`**Error:** ${outcome.message}`, { message: outcome.message });
|
|
248
|
+
}
|
|
249
|
+
if (outcome.kind === "disambiguation" || outcome.kind === "kind-mismatch") {
|
|
250
|
+
const lines = [
|
|
251
|
+
outcome.kind === "kind-mismatch"
|
|
252
|
+
? `**No target matched provider kind \`${outcome.requestedKind}\`. Near matches:**`
|
|
253
|
+
: "**Target is ambiguous. Choose one candidate handle:**",
|
|
254
|
+
"",
|
|
255
|
+
];
|
|
256
|
+
for (const candidate of outcome.candidates) {
|
|
257
|
+
lines.push(
|
|
258
|
+
`- \`${candidate.targetId}\` — ${candidate.name} (\`${candidate.kind ?? "unknown"}\`) at ${candidate.file}:${candidate.line}:${candidate.character}`,
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
if (outcome.kind === "kind-mismatch") {
|
|
262
|
+
lines.push(
|
|
263
|
+
"",
|
|
264
|
+
"Retry without `symbolKind`, use an observed provider kind, or choose a handle.",
|
|
265
|
+
);
|
|
266
|
+
}
|
|
267
|
+
return searchErrorResult(lines.join("\n"), {
|
|
268
|
+
message:
|
|
269
|
+
outcome.kind === "kind-mismatch"
|
|
270
|
+
? `No target matched provider kind ${outcome.requestedKind}.`
|
|
271
|
+
: "The target is ambiguous.",
|
|
272
|
+
displaySections: [
|
|
273
|
+
createToolDisplaySection({
|
|
274
|
+
key: "graph.candidates",
|
|
275
|
+
title: "Candidates",
|
|
276
|
+
items: outcome.candidates,
|
|
277
|
+
format: (candidate) =>
|
|
278
|
+
`${candidate.targetId} — ${candidate.name} (${candidate.kind ?? "unknown"}) at ${candidate.file}:${candidate.line}:${candidate.character}`,
|
|
279
|
+
}),
|
|
280
|
+
],
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const assembly = assembleGraphResult({
|
|
285
|
+
displayName: outcome.displayName,
|
|
286
|
+
sections: outcome.sections,
|
|
287
|
+
resolvedDisplayFile: outcome.resolvedDisplayFile,
|
|
288
|
+
maxResults: outcome.maxResults,
|
|
289
|
+
cwd,
|
|
290
|
+
});
|
|
291
|
+
return {
|
|
292
|
+
content: renderGraphResult(assembly),
|
|
293
|
+
details: {
|
|
294
|
+
type: "search",
|
|
295
|
+
data: assembly.details,
|
|
296
|
+
status: "completed",
|
|
297
|
+
displaySections: assembly.displaySections,
|
|
298
|
+
},
|
|
299
|
+
};
|
|
300
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { StringEnum } from "@earendil-works/pi-ai";
|
|
2
|
+
import { Type } from "typebox";
|
|
3
|
+
import type { CodeIntelToolExecCtx } from "../../types/index.ts";
|
|
4
|
+
import { GraphTargetParam, MaxResultsParam } from "../schemas.ts";
|
|
5
|
+
import { executeGraphTool } from "./execute.ts";
|
|
6
|
+
import { renderGraphCall, renderGraphResult } from "./tui.ts";
|
|
7
|
+
|
|
8
|
+
export const CODE_GRAPH_TOOL_NAME = "code_graph";
|
|
9
|
+
export const CODE_GRAPH_TOOL_LABEL = "Code Graph";
|
|
10
|
+
|
|
11
|
+
/** Canonical provider-facing metadata for the code_graph tool. */
|
|
12
|
+
export const codeGraphSpec = {
|
|
13
|
+
name: CODE_GRAPH_TOOL_NAME,
|
|
14
|
+
label: CODE_GRAPH_TOOL_LABEL,
|
|
15
|
+
parameters: Type.Object(
|
|
16
|
+
{
|
|
17
|
+
target: GraphTargetParam,
|
|
18
|
+
relations: Type.Optional(
|
|
19
|
+
Type.Array(StringEnum(["all", "references", "callees", "implements"]), {
|
|
20
|
+
description:
|
|
21
|
+
'Requested relations; defaults to ["references"]. "all" must be the only item.',
|
|
22
|
+
minItems: 1,
|
|
23
|
+
uniqueItems: true,
|
|
24
|
+
}),
|
|
25
|
+
),
|
|
26
|
+
maxResults: Type.Optional(MaxResultsParam),
|
|
27
|
+
calleeDepth: Type.Optional(
|
|
28
|
+
StringEnum(["direct", "deep"], {
|
|
29
|
+
description: "direct excludes nested scopes; deep includes them.",
|
|
30
|
+
}),
|
|
31
|
+
),
|
|
32
|
+
},
|
|
33
|
+
{ additionalProperties: false },
|
|
34
|
+
),
|
|
35
|
+
run: (params: unknown, ctx: CodeIntelToolExecCtx) =>
|
|
36
|
+
executeGraphTool(params as Parameters<typeof executeGraphTool>[0], ctx),
|
|
37
|
+
renderCall: renderGraphCall,
|
|
38
|
+
renderResult: renderGraphResult,
|
|
39
|
+
} as const;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/** TUI renderer for code_graph. */
|
|
2
|
+
import type { Theme } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
import { Container, Spacer, Text } from "@earendil-works/pi-tui";
|
|
4
|
+
import {
|
|
5
|
+
buildSimpleCompact,
|
|
6
|
+
buildSimpleHeader,
|
|
7
|
+
type EvidenceEntry,
|
|
8
|
+
formatCallPath,
|
|
9
|
+
formatCallValue,
|
|
10
|
+
type ResultOptios,
|
|
11
|
+
renderDomainError,
|
|
12
|
+
renderDomainResult,
|
|
13
|
+
renderEvidenceLines,
|
|
14
|
+
renderExecutionError,
|
|
15
|
+
renderMarkdownDetail,
|
|
16
|
+
renderPartial,
|
|
17
|
+
renderStructuredDetailBody,
|
|
18
|
+
renderToolDisplaySections,
|
|
19
|
+
renderTruncationDisclosure,
|
|
20
|
+
type ToolRendererContext,
|
|
21
|
+
type ToolResult,
|
|
22
|
+
} from "../../ui/tui/common.ts";
|
|
23
|
+
import type { CodeGraphToolParams, GraphRelation } from "./execute.ts";
|
|
24
|
+
|
|
25
|
+
/** Render the compact code_graph call header. */
|
|
26
|
+
export function renderGraphCall(
|
|
27
|
+
args: unknown,
|
|
28
|
+
theme: Theme,
|
|
29
|
+
_context: ToolRendererContext | undefined,
|
|
30
|
+
): Text {
|
|
31
|
+
const params = (args ?? {}) as Partial<CodeGraphToolParams>;
|
|
32
|
+
const relations: GraphRelation[] = Array.isArray(params.relations)
|
|
33
|
+
? (params.relations as GraphRelation[])
|
|
34
|
+
: ["references"];
|
|
35
|
+
const relationLabel = formatRelations(relations);
|
|
36
|
+
|
|
37
|
+
let content = theme.fg("toolTitle", "code_graph");
|
|
38
|
+
if (relationLabel) content += ` ${theme.fg("accent", relationLabel)}`;
|
|
39
|
+
|
|
40
|
+
const target = formatTarget(params.target);
|
|
41
|
+
if (target) content += ` ${theme.fg("muted", target)}`;
|
|
42
|
+
|
|
43
|
+
return new Text(content, 0, 0);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Render code_graph progress, status, and structured result details. */
|
|
47
|
+
export function renderGraphResult(
|
|
48
|
+
result: ToolResult,
|
|
49
|
+
options: ResultOptios,
|
|
50
|
+
theme: Theme,
|
|
51
|
+
context: ToolRendererContext | undefined,
|
|
52
|
+
): Container | Text {
|
|
53
|
+
if (options.isPartial) return renderPartial("Collecting relations…", theme);
|
|
54
|
+
|
|
55
|
+
const details =
|
|
56
|
+
result.details?.type === "search" ? (result.details.data as Record<string, unknown>) : null;
|
|
57
|
+
const executionError = renderExecutionError(context, "code_graph failed", theme);
|
|
58
|
+
if (executionError) return executionError;
|
|
59
|
+
const domainError = renderDomainError(result, theme);
|
|
60
|
+
if (domainError) return renderDomainResult(result, options, theme, domainError);
|
|
61
|
+
|
|
62
|
+
if (!options.expanded) {
|
|
63
|
+
const compact = buildSimpleCompact(details ?? undefined, theme);
|
|
64
|
+
const truncation = renderTruncationDisclosure(result, theme);
|
|
65
|
+
if (!truncation) return compact;
|
|
66
|
+
const container = new Container();
|
|
67
|
+
container.addChild(compact);
|
|
68
|
+
container.addChild(new Spacer(1));
|
|
69
|
+
container.addChild(truncation);
|
|
70
|
+
return container;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const container = new Container();
|
|
74
|
+
const header = buildSimpleHeader(details ?? undefined, theme);
|
|
75
|
+
if (header) container.addChild(header);
|
|
76
|
+
|
|
77
|
+
const evidenceLists = details?.evidenceLists as EvidenceEntry[] | undefined;
|
|
78
|
+
if (evidenceLists && evidenceLists.length > 0) {
|
|
79
|
+
container.addChild(new Spacer(1));
|
|
80
|
+
renderEvidenceLines(container, evidenceLists, theme);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
renderToolDisplaySections(container, result.details?.displaySections, theme);
|
|
84
|
+
renderStructuredDetailBody(container, details ?? undefined, theme);
|
|
85
|
+
const truncation = renderTruncationDisclosure(result, theme);
|
|
86
|
+
if (truncation) {
|
|
87
|
+
container.addChild(new Spacer(1));
|
|
88
|
+
container.addChild(truncation);
|
|
89
|
+
}
|
|
90
|
+
renderMarkdownDetail(container, result, theme);
|
|
91
|
+
return container;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function formatRelations(relations: readonly GraphRelation[]): string {
|
|
95
|
+
if (relations.length === 0) return "";
|
|
96
|
+
if (relations.length === 1) return `→ ${relations[0]}`;
|
|
97
|
+
if (relations.length <= 3) return `→ ${relations.join(", ")}`;
|
|
98
|
+
return `→ ${relations.slice(0, 2).join(", ")} +${relations.length - 2}`;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function formatTarget(target: unknown): string {
|
|
102
|
+
if (!target || typeof target !== "object") return "";
|
|
103
|
+
const record = target as Record<string, unknown>;
|
|
104
|
+
|
|
105
|
+
if (record.symbol && typeof record.symbol === "object") {
|
|
106
|
+
const query = formatCallValue((record.symbol as Record<string, unknown>).query);
|
|
107
|
+
return query ? `of ${query}` : "";
|
|
108
|
+
}
|
|
109
|
+
if (record.anchor && typeof record.anchor === "object") {
|
|
110
|
+
const anchor = record.anchor as Record<string, unknown>;
|
|
111
|
+
const file = formatCallPath(anchor.file);
|
|
112
|
+
const line = typeof anchor.line === "number" ? `:${anchor.line}` : "";
|
|
113
|
+
return file ? `at ${file}${line}` : "";
|
|
114
|
+
}
|
|
115
|
+
const handle = formatCallValue(record.handle);
|
|
116
|
+
return handle ? `of ${handle}` : "";
|
|
117
|
+
}
|
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
import type { HealthSection, HealthWorkflowInput } from "../../session/health-types.ts";
|
|
4
4
|
import type { CodeIntelResult, CodeIntelToolExecCtx } from "../../types/index.ts";
|
|
5
5
|
import { toWorkflowControl } from "../infra/workflow-control.ts";
|
|
6
|
-
import {
|
|
7
|
-
import { assembleHealthResult } from "../result/health.ts";
|
|
8
|
-
import { renderHealthResult } from "./markdown.ts";
|
|
6
|
+
import { finishHealthResult } from "./result.ts";
|
|
9
7
|
|
|
10
8
|
export interface CodeHealthToolParams {
|
|
11
9
|
scope?: string;
|
|
@@ -19,14 +17,5 @@ export async function executeHealthTool(
|
|
|
19
17
|
ctx: CodeIntelToolExecCtx,
|
|
20
18
|
): Promise<CodeIntelResult> {
|
|
21
19
|
const outcome = await ctx.session.health(params as HealthWorkflowInput, toWorkflowControl(ctx));
|
|
22
|
-
|
|
23
|
-
if (outcome.kind === "invalid-input") {
|
|
24
|
-
return healthErrorResult(`**Error:** ${outcome.message}`, "invalid input");
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const assembly = assembleHealthResult(outcome.data);
|
|
28
|
-
return {
|
|
29
|
-
content: renderHealthResult(assembly, ctx.cwd),
|
|
30
|
-
details: { type: "health", data: assembly.details },
|
|
31
|
-
};
|
|
20
|
+
return finishHealthResult(outcome, ctx.cwd);
|
|
32
21
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const toolDescription =
|
|
2
|
+
"Report live diagnostics as observations, language-server status, and final semantic health state. Tracked-file snapshots do not prove workspace completeness; server inventory is workspace-wide.";
|
|
3
|
+
|
|
4
|
+
export const promptSnippet = "live workspace health observations";
|
|
5
|
+
|
|
6
|
+
export const promptGuidelines = [
|
|
7
|
+
"Use code_health with refresh:true before relying on potentially stale diagnostics.",
|
|
8
|
+
];
|