@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
package/src/tool/register.ts
CHANGED
|
@@ -1,73 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { tmpdir } from "node:os";
|
|
3
|
-
import { join } from "node:path";
|
|
1
|
+
import { createHmac, randomBytes } from "node:crypto";
|
|
4
2
|
import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
5
|
-
import
|
|
3
|
+
import { recordDebugEvent, startDebugTimer } from "@mrclrchtr/supi-core/debug";
|
|
4
|
+
import { truncateIdentity } from "@mrclrchtr/supi-lsp/debug-telemetry";
|
|
6
5
|
import type { WorkspaceCodeIntelligenceSession } from "../session/session.ts";
|
|
7
|
-
import { renderFindCall, renderFindResult } from "./find/tui.ts";
|
|
8
|
-
import { renderGraphCall, renderGraphResult } from "./graph/tui.ts";
|
|
9
6
|
import {
|
|
10
7
|
CODE_INTELLIGENCE_TOOL_PROMPT_SURFACES,
|
|
11
8
|
type CodeIntelligenceToolPromptSurfaceMap,
|
|
12
9
|
} from "./guidance.ts";
|
|
13
|
-
import {
|
|
14
|
-
import { truncateToolContent } from "./infra/truncate.ts";
|
|
15
|
-
import { renderInspectCall, renderInspectResult } from "./inspect/tui.ts";
|
|
16
|
-
import { renderOrientationCall, renderOrientationResult } from "./orientation/tui.ts";
|
|
17
|
-
import { renderRefactorApplyCall, renderRefactorApplyResult } from "./refactor-apply/tui.ts";
|
|
18
|
-
import { renderRefactorPlanCall, renderRefactorPlanResult } from "./refactor-plan/tui.ts";
|
|
19
|
-
import { renderResolveCall, renderResolveResult } from "./resolve/tui.ts";
|
|
10
|
+
import { boundCodeToolResult } from "./infra/truncate.ts";
|
|
20
11
|
import { CODE_INTELLIGENCE_TOOL_SPECS, type CodeIntelligenceToolDefinitionSpec } from "./specs.ts";
|
|
21
12
|
|
|
22
|
-
const TOOL_OUTPUT_CONTRACT =
|
|
23
|
-
" Output over 2000 lines or 50KB is truncated, with full Markdown saved to a temporary file.";
|
|
24
|
-
|
|
25
|
-
interface ToolRenderer {
|
|
26
|
-
// biome-ignore lint/suspicious/noExplicitAny: pi render call/result signatures vary per tool; spread into pi.registerTool where concrete typing handles variance
|
|
27
|
-
renderCall?: (...args: any[]) => Component;
|
|
28
|
-
// biome-ignore lint/suspicious/noExplicitAny: same variance reason as renderCall
|
|
29
|
-
renderResult?: (...args: any[]) => Component;
|
|
30
|
-
renderShell?: "self";
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function getToolRenderer(name: string): ToolRenderer {
|
|
34
|
-
switch (name) {
|
|
35
|
-
case "code_graph":
|
|
36
|
-
return {
|
|
37
|
-
renderCall: renderGraphCall,
|
|
38
|
-
renderResult: renderGraphResult,
|
|
39
|
-
};
|
|
40
|
-
case "code_health":
|
|
41
|
-
return {
|
|
42
|
-
renderCall: renderHealthCall,
|
|
43
|
-
renderResult: renderHealthResult,
|
|
44
|
-
};
|
|
45
|
-
case "code_orientation":
|
|
46
|
-
return {
|
|
47
|
-
renderCall: renderOrientationCall,
|
|
48
|
-
renderResult: renderOrientationResult,
|
|
49
|
-
};
|
|
50
|
-
case "code_resolve":
|
|
51
|
-
return { renderCall: renderResolveCall, renderResult: renderResolveResult };
|
|
52
|
-
case "code_inspect":
|
|
53
|
-
return { renderCall: renderInspectCall, renderResult: renderInspectResult };
|
|
54
|
-
case "code_find":
|
|
55
|
-
return { renderCall: renderFindCall, renderResult: renderFindResult };
|
|
56
|
-
case "code_refactor_plan":
|
|
57
|
-
return {
|
|
58
|
-
renderCall: renderRefactorPlanCall,
|
|
59
|
-
renderResult: renderRefactorPlanResult,
|
|
60
|
-
};
|
|
61
|
-
case "code_refactor_apply":
|
|
62
|
-
return {
|
|
63
|
-
renderCall: renderRefactorApplyCall,
|
|
64
|
-
renderResult: renderRefactorApplyResult,
|
|
65
|
-
};
|
|
66
|
-
default:
|
|
67
|
-
return {};
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
13
|
/**
|
|
72
14
|
* Register the focused code-intelligence tool surface from shared specs.
|
|
73
15
|
*
|
|
@@ -76,6 +18,65 @@ function getToolRenderer(name: string): ToolRenderer {
|
|
|
76
18
|
*/
|
|
77
19
|
const registeredPis = new WeakSet<object>();
|
|
78
20
|
|
|
21
|
+
type CodeOperationOutcome = "completed" | "failed" | "canceled";
|
|
22
|
+
|
|
23
|
+
function createDebugOperationId(secret: Buffer, toolCallId: string): string {
|
|
24
|
+
const digest = createHmac("sha256", secret).update(toolCallId).digest().subarray(0, 16);
|
|
25
|
+
return `op-${digest.toString("base64url")}`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function recordCodeOperationBoundary(
|
|
29
|
+
category: "code-operation.start" | "code-operation.finish",
|
|
30
|
+
operationId: string,
|
|
31
|
+
tool: string,
|
|
32
|
+
options: { cwd: string; outcome?: CodeOperationOutcome },
|
|
33
|
+
): void {
|
|
34
|
+
recordDebugEvent({
|
|
35
|
+
operationId,
|
|
36
|
+
source: "code-intelligence",
|
|
37
|
+
level: "debug",
|
|
38
|
+
category,
|
|
39
|
+
message:
|
|
40
|
+
category === "code-operation.start" ? "Code operation started" : "Code operation finished",
|
|
41
|
+
cwd: truncateIdentity(options.cwd),
|
|
42
|
+
data: options.outcome ? { tool, outcome: options.outcome } : { tool },
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function recordCodeWorkflowTiming(
|
|
47
|
+
timer: ReturnType<typeof startDebugTimer>,
|
|
48
|
+
operationId: string,
|
|
49
|
+
tool: string,
|
|
50
|
+
options: { cwd: string; outcome: CodeOperationOutcome },
|
|
51
|
+
): void {
|
|
52
|
+
timer.finish(
|
|
53
|
+
{
|
|
54
|
+
operationId,
|
|
55
|
+
source: "code-intelligence",
|
|
56
|
+
level: "debug",
|
|
57
|
+
category: "workflow.timing",
|
|
58
|
+
message: "Code workflow finished",
|
|
59
|
+
cwd: truncateIdentity(options.cwd),
|
|
60
|
+
data: { tool, outcome: options.outcome },
|
|
61
|
+
},
|
|
62
|
+
"workflow",
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function terminalCodeOperationOutcome(
|
|
67
|
+
error: unknown,
|
|
68
|
+
signal: AbortSignal | undefined,
|
|
69
|
+
): CodeOperationOutcome {
|
|
70
|
+
if (signal?.aborted) return "canceled";
|
|
71
|
+
if (
|
|
72
|
+
error instanceof Error &&
|
|
73
|
+
(error.name === "AbortError" || error.name === "CodeRequestDeadlineError")
|
|
74
|
+
) {
|
|
75
|
+
return "canceled";
|
|
76
|
+
}
|
|
77
|
+
return "failed";
|
|
78
|
+
}
|
|
79
|
+
|
|
79
80
|
export function registerCodeIntelligenceTools(
|
|
80
81
|
pi: ExtensionAPI,
|
|
81
82
|
getOrCreateSession: (cwd: string) => WorkspaceCodeIntelligenceSession,
|
|
@@ -89,46 +90,62 @@ export function registerCodeIntelligenceTools(
|
|
|
89
90
|
// ponytail: WeakSet on pi identity; getAllTools() is not callable during load.
|
|
90
91
|
if (registeredPis.has(pi)) return;
|
|
91
92
|
registeredPis.add(pi);
|
|
93
|
+
const operationSecret = randomBytes(32);
|
|
92
94
|
|
|
93
95
|
for (const spec of specs) {
|
|
94
96
|
const surface = promptSurfaces[spec.name];
|
|
95
97
|
pi.registerTool({
|
|
96
98
|
name: spec.name,
|
|
97
99
|
label: spec.label,
|
|
98
|
-
description: surface.description
|
|
100
|
+
description: surface.description,
|
|
99
101
|
promptSnippet: surface.promptSnippet,
|
|
100
102
|
promptGuidelines: surface.promptGuidelines,
|
|
101
103
|
parameters: spec.parameters,
|
|
102
104
|
// biome-ignore lint/complexity/useMaxParams: pi ToolDefinition.execute signature
|
|
103
|
-
execute: async (
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
execute: async (toolCallId, params, signal, onUpdate, ctx: ExtensionContext) => {
|
|
106
|
+
const operationId = createDebugOperationId(operationSecret, toolCallId);
|
|
107
|
+
const workflowTimer = startDebugTimer();
|
|
108
|
+
recordCodeOperationBoundary("code-operation.start", operationId, spec.name, {
|
|
107
109
|
cwd: ctx.cwd,
|
|
108
|
-
signal,
|
|
109
|
-
onUpdate,
|
|
110
|
-
session,
|
|
111
|
-
});
|
|
112
|
-
const { text, truncated } = truncateToolContent(content, {
|
|
113
|
-
maxLines: spec.maxLines,
|
|
114
|
-
maxBytes: spec.maxBytes,
|
|
115
110
|
});
|
|
116
|
-
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
111
|
+
try {
|
|
112
|
+
const session = getOrCreateSession(ctx.cwd);
|
|
113
|
+
session.setProjectTrusted(ctx.isProjectTrusted());
|
|
114
|
+
const { content, details } = await spec.run(params, {
|
|
115
|
+
cwd: ctx.cwd,
|
|
116
|
+
operationId,
|
|
117
|
+
signal,
|
|
118
|
+
onUpdate,
|
|
119
|
+
session,
|
|
120
|
+
});
|
|
121
|
+
recordCodeWorkflowTiming(workflowTimer, operationId, spec.name, {
|
|
122
|
+
cwd: ctx.cwd,
|
|
123
|
+
outcome: "completed",
|
|
124
|
+
});
|
|
125
|
+
recordCodeOperationBoundary("code-operation.finish", operationId, spec.name, {
|
|
126
|
+
cwd: ctx.cwd,
|
|
127
|
+
outcome: "completed",
|
|
128
|
+
});
|
|
129
|
+
return boundCodeToolResult(content, details, {
|
|
130
|
+
toolName: spec.name,
|
|
131
|
+
maxLines: spec.maxLines,
|
|
132
|
+
maxBytes: spec.maxBytes,
|
|
133
|
+
});
|
|
134
|
+
} catch (error) {
|
|
135
|
+
const outcome = terminalCodeOperationOutcome(error, signal);
|
|
136
|
+
recordCodeWorkflowTiming(workflowTimer, operationId, spec.name, {
|
|
137
|
+
cwd: ctx.cwd,
|
|
138
|
+
outcome,
|
|
139
|
+
});
|
|
140
|
+
recordCodeOperationBoundary("code-operation.finish", operationId, spec.name, {
|
|
141
|
+
cwd: ctx.cwd,
|
|
142
|
+
outcome,
|
|
143
|
+
});
|
|
144
|
+
throw error;
|
|
125
145
|
}
|
|
126
|
-
return {
|
|
127
|
-
content: [{ type: "text" as const, text }],
|
|
128
|
-
details,
|
|
129
|
-
};
|
|
130
146
|
},
|
|
131
|
-
|
|
147
|
+
renderCall: spec.renderCall,
|
|
148
|
+
renderResult: spec.renderResult,
|
|
132
149
|
});
|
|
133
150
|
}
|
|
134
151
|
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import type { ToolDisplaySection } from "./types.ts";
|
|
2
|
+
|
|
3
|
+
/** Maximum number of rows shown for one expanded TUI section. */
|
|
4
|
+
export const MAX_TUI_DISPLAY_ITEMS = 20;
|
|
5
|
+
|
|
6
|
+
/** Maximum visible characters kept in one structured TUI row. */
|
|
7
|
+
export const MAX_TUI_DISPLAY_LINE_LENGTH = 240;
|
|
8
|
+
|
|
9
|
+
/** Inputs for one bounded structured TUI section. */
|
|
10
|
+
export interface ToolDisplaySectionInput<T> {
|
|
11
|
+
key: string;
|
|
12
|
+
title: string;
|
|
13
|
+
items: readonly T[];
|
|
14
|
+
format: (item: T) => string;
|
|
15
|
+
totalCount?: number | null;
|
|
16
|
+
omittedCount?: number | null;
|
|
17
|
+
partialReason?: string | null;
|
|
18
|
+
maxItems?: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Build a bounded, serializable TUI section from collected facts. */
|
|
22
|
+
export function createToolDisplaySection<T>(input: ToolDisplaySectionInput<T>): ToolDisplaySection {
|
|
23
|
+
const maxItems = Math.max(0, input.maxItems ?? MAX_TUI_DISPLAY_ITEMS);
|
|
24
|
+
const items = input.items.slice(0, maxItems);
|
|
25
|
+
const lines = items.map((item) => truncateDisplayText(input.format(item)));
|
|
26
|
+
const displayOmittedCount = Math.max(0, input.items.length - items.length);
|
|
27
|
+
let totalCount: number | null;
|
|
28
|
+
if (input.totalCount === undefined) totalCount = input.items.length;
|
|
29
|
+
else totalCount = input.totalCount;
|
|
30
|
+
const omittedCount =
|
|
31
|
+
totalCount === null
|
|
32
|
+
? input.omittedCount === null || input.omittedCount === undefined
|
|
33
|
+
? displayOmittedCount || null
|
|
34
|
+
: input.omittedCount + displayOmittedCount
|
|
35
|
+
: Math.max(0, totalCount - lines.length);
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
key: input.key,
|
|
39
|
+
title: input.title,
|
|
40
|
+
lines,
|
|
41
|
+
shownCount: lines.length,
|
|
42
|
+
totalCount,
|
|
43
|
+
omittedCount,
|
|
44
|
+
partialReason: input.partialReason ?? null,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Keep structured TUI rows readable without parsing or emitting Markdown. */
|
|
49
|
+
export function truncateDisplayText(
|
|
50
|
+
value: string,
|
|
51
|
+
maxLength = MAX_TUI_DISPLAY_LINE_LENGTH,
|
|
52
|
+
): string {
|
|
53
|
+
const limit = Math.max(1, maxLength);
|
|
54
|
+
return value
|
|
55
|
+
.split("\n")
|
|
56
|
+
.map((line) => {
|
|
57
|
+
if (line.length <= limit) return line;
|
|
58
|
+
return `${line.slice(0, Math.max(0, limit - 1))}…`;
|
|
59
|
+
})
|
|
60
|
+
.join("\n");
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Read valid structured TUI sections from persisted tool details. */
|
|
64
|
+
export function readToolDisplaySections(value: unknown): ToolDisplaySection[] {
|
|
65
|
+
if (!Array.isArray(value)) return [];
|
|
66
|
+
return value.flatMap((entry) => {
|
|
67
|
+
if (typeof entry !== "object" || entry === null || Array.isArray(entry)) return [];
|
|
68
|
+
const record = entry as Record<string, unknown>;
|
|
69
|
+
if (
|
|
70
|
+
typeof record.key !== "string" ||
|
|
71
|
+
typeof record.title !== "string" ||
|
|
72
|
+
!Array.isArray(record.lines) ||
|
|
73
|
+
!record.lines.every((line) => typeof line === "string") ||
|
|
74
|
+
!isCount(record.shownCount) ||
|
|
75
|
+
!isNullableCount(record.totalCount) ||
|
|
76
|
+
!isNullableCount(record.omittedCount) ||
|
|
77
|
+
!isNullableString(record.partialReason)
|
|
78
|
+
) {
|
|
79
|
+
return [];
|
|
80
|
+
}
|
|
81
|
+
return [
|
|
82
|
+
{
|
|
83
|
+
key: record.key,
|
|
84
|
+
title: record.title,
|
|
85
|
+
lines: record.lines
|
|
86
|
+
.slice(0, MAX_TUI_DISPLAY_ITEMS)
|
|
87
|
+
.map((line) => truncateDisplayText(line)),
|
|
88
|
+
shownCount: record.shownCount,
|
|
89
|
+
totalCount: record.totalCount,
|
|
90
|
+
omittedCount: record.omittedCount,
|
|
91
|
+
partialReason: record.partialReason,
|
|
92
|
+
},
|
|
93
|
+
];
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function isCount(value: unknown): value is number {
|
|
98
|
+
return typeof value === "number" && Number.isInteger(value) && value >= 0;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function isNullableCount(value: unknown): value is number | null {
|
|
102
|
+
return value === null || isCount(value);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function isNullableString(value: unknown): value is string | null {
|
|
106
|
+
return value === null || typeof value === "string";
|
|
107
|
+
}
|
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
* Tool-result error assembly factories for code-intelligence tool executors.
|
|
3
|
-
*
|
|
4
|
-
* Every factory returns a complete {@link CodeIntelResult} (content + typed
|
|
5
|
-
* details) so executors never need to inline the `{ content, details }`
|
|
6
|
-
* wrapper. Returned tool errors are result assembly concerns; whole-tool
|
|
7
|
-
* capability failures may still throw so PI marks the tool call as failed.
|
|
8
|
-
*/
|
|
1
|
+
import type { CodeIntelResult, ToolDisplaySection } from "../../types/index.ts";
|
|
9
2
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
// ── Error-result factories ──────────────────────────────────────────
|
|
13
|
-
|
|
14
|
-
/** Full error result for search-family tools (code_find, code_graph, code_refactor_plan). */
|
|
3
|
+
/** Full error result for search-family tools. */
|
|
15
4
|
export function searchErrorResult(
|
|
16
5
|
content: string,
|
|
17
|
-
opts?: {
|
|
6
|
+
opts?: {
|
|
7
|
+
scope?: string | null;
|
|
8
|
+
nextQueries?: string[];
|
|
9
|
+
message?: string;
|
|
10
|
+
displaySections?: readonly ToolDisplaySection[];
|
|
11
|
+
},
|
|
18
12
|
): CodeIntelResult {
|
|
19
13
|
return {
|
|
20
14
|
content,
|
|
@@ -27,14 +21,17 @@ export function searchErrorResult(
|
|
|
27
21
|
omittedCount: 0,
|
|
28
22
|
nextQueries: opts?.nextQueries ?? [],
|
|
29
23
|
},
|
|
24
|
+
status: "invalid-input",
|
|
25
|
+
...(opts?.message ? { message: opts.message } : {}),
|
|
26
|
+
...(opts?.displaySections ? { displaySections: opts.displaySections } : {}),
|
|
30
27
|
},
|
|
31
28
|
};
|
|
32
29
|
}
|
|
33
30
|
|
|
34
|
-
/** Full error result for code_orientation
|
|
31
|
+
/** Full error result for code_orientation. */
|
|
35
32
|
export function contextErrorResult(
|
|
36
33
|
content: string,
|
|
37
|
-
opts?: { nextQueries?: string[] },
|
|
34
|
+
opts?: { nextQueries?: string[]; message?: string },
|
|
38
35
|
): CodeIntelResult {
|
|
39
36
|
return {
|
|
40
37
|
content,
|
|
@@ -49,6 +46,8 @@ export function contextErrorResult(
|
|
|
49
46
|
omittedCount: 0,
|
|
50
47
|
nextQueries: opts?.nextQueries ?? [],
|
|
51
48
|
},
|
|
49
|
+
status: "invalid-input",
|
|
50
|
+
...(opts?.message ? { message: opts.message } : {}),
|
|
52
51
|
},
|
|
53
52
|
};
|
|
54
53
|
}
|
|
@@ -56,7 +55,7 @@ export function contextErrorResult(
|
|
|
56
55
|
/** Full error result for code_inspect. */
|
|
57
56
|
export function inspectErrorResult(
|
|
58
57
|
content: string,
|
|
59
|
-
opts?: { focusTarget?: string; nextQueries?: string[] },
|
|
58
|
+
opts?: { focusTarget?: string; nextQueries?: string[]; message?: string },
|
|
60
59
|
): CodeIntelResult {
|
|
61
60
|
return {
|
|
62
61
|
content,
|
|
@@ -69,6 +68,8 @@ export function inspectErrorResult(
|
|
|
69
68
|
sections: [],
|
|
70
69
|
nextQueries: opts?.nextQueries ?? [],
|
|
71
70
|
},
|
|
71
|
+
status: "invalid-input",
|
|
72
|
+
...(opts?.message ? { message: opts.message } : {}),
|
|
72
73
|
},
|
|
73
74
|
};
|
|
74
75
|
}
|
|
@@ -100,6 +101,8 @@ export function healthErrorResult(content: string, reason?: string): CodeIntelRe
|
|
|
100
101
|
diagnosticFileCount: 0,
|
|
101
102
|
serverCount: 0,
|
|
102
103
|
},
|
|
104
|
+
status: "invalid-input",
|
|
105
|
+
message: reason ?? content,
|
|
103
106
|
},
|
|
104
107
|
};
|
|
105
108
|
}
|
|
@@ -3,7 +3,8 @@ import { createEvidenceList, type EvidenceList } from "../../analysis/evidence.t
|
|
|
3
3
|
import type { ApplyResult } from "../../analysis/refactor/apply.ts";
|
|
4
4
|
import type { RefactorPlan } from "../../session/refactor-plans.ts";
|
|
5
5
|
import { assembledNextQueries, assembleToolResult, type ToolResultAssembly } from "./assembly.ts";
|
|
6
|
-
import
|
|
6
|
+
import { createToolDisplaySection } from "./display.ts";
|
|
7
|
+
import type { SearchDetails, ToolDisplaySection } from "./types.ts";
|
|
7
8
|
|
|
8
9
|
export interface RefactorPlanAssemblyData {
|
|
9
10
|
readonly plan: Readonly<RefactorPlan>;
|
|
@@ -14,6 +15,7 @@ export interface RefactorPlanAssemblyData {
|
|
|
14
15
|
export interface RefactorPlanResultAssembly {
|
|
15
16
|
readonly assembled: ToolResultAssembly<RefactorPlanAssemblyData>;
|
|
16
17
|
readonly details: SearchDetails;
|
|
18
|
+
readonly displaySections: readonly ToolDisplaySection[];
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
export interface RefactorApplyAssemblyData {
|
|
@@ -24,6 +26,13 @@ export interface RefactorApplyAssemblyData {
|
|
|
24
26
|
export interface RefactorApplyResultAssembly {
|
|
25
27
|
readonly assembled: ToolResultAssembly<RefactorApplyAssemblyData>;
|
|
26
28
|
readonly details: SearchDetails;
|
|
29
|
+
readonly displaySections: readonly ToolDisplaySection[];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function formatEdit(edit: FileEdit): string {
|
|
33
|
+
const range = edit.range;
|
|
34
|
+
const replacement = edit.newText.replace(/\n/g, " ↵ ");
|
|
35
|
+
return `${edit.file} L${range.start.line + 1}:${range.start.character + 1} → L${range.end.line + 1}:${range.end.character + 1}: ${replacement}`;
|
|
27
36
|
}
|
|
28
37
|
|
|
29
38
|
/** Assemble a bounded refactor plan and all facts needed by its renderers. */
|
|
@@ -59,6 +68,17 @@ export function assembleRefactorPlanDetails(
|
|
|
59
68
|
|
|
60
69
|
return {
|
|
61
70
|
assembled,
|
|
71
|
+
displaySections: [
|
|
72
|
+
createToolDisplaySection({
|
|
73
|
+
key: "refactor.edits",
|
|
74
|
+
title: "Proposed edits",
|
|
75
|
+
items: edits.items,
|
|
76
|
+
totalCount: edits.metadata.totalCount,
|
|
77
|
+
omittedCount: edits.metadata.omittedCount,
|
|
78
|
+
partialReason: edits.metadata.partialReason,
|
|
79
|
+
format: formatEdit,
|
|
80
|
+
}),
|
|
81
|
+
],
|
|
62
82
|
details: {
|
|
63
83
|
confidence: assembled.confidence,
|
|
64
84
|
scope: null,
|
|
@@ -89,17 +109,28 @@ export function assembleRefactorApplyDetails(
|
|
|
89
109
|
provenance,
|
|
90
110
|
},
|
|
91
111
|
],
|
|
92
|
-
nextQueries:
|
|
93
|
-
applyResult.kind === "applied"
|
|
94
|
-
? ["Use code_health to check for new issues after the refactor"]
|
|
95
|
-
: [],
|
|
112
|
+
nextQueries: [],
|
|
96
113
|
candidateCount,
|
|
97
114
|
confidence: applyResult.kind === "applied" ? "semantic" : "unavailable",
|
|
98
115
|
provenance,
|
|
99
116
|
});
|
|
100
117
|
|
|
118
|
+
const changedFiles = [...new Set(plan.edits.edits.map((edit) => edit.file))];
|
|
119
|
+
|
|
101
120
|
return {
|
|
102
121
|
assembled,
|
|
122
|
+
displaySections:
|
|
123
|
+
applyResult.kind === "applied"
|
|
124
|
+
? [
|
|
125
|
+
createToolDisplaySection({
|
|
126
|
+
key: "refactor.changedFiles",
|
|
127
|
+
title: "Changed files",
|
|
128
|
+
items: changedFiles,
|
|
129
|
+
totalCount: changedFiles.length,
|
|
130
|
+
format: (file) => file,
|
|
131
|
+
}),
|
|
132
|
+
]
|
|
133
|
+
: [],
|
|
103
134
|
details: {
|
|
104
135
|
confidence: assembled.confidence,
|
|
105
136
|
scope: null,
|
|
@@ -107,9 +138,7 @@ export function assembleRefactorApplyDetails(
|
|
|
107
138
|
omittedCount: assembled.totals.omittedCount,
|
|
108
139
|
evidenceLists: [...assembled.evidenceLists],
|
|
109
140
|
nextQueries: assembledNextQueries(assembled),
|
|
110
|
-
...(applyResult.kind === "applied"
|
|
111
|
-
? { changedFiles: [...new Set(plan.edits.edits.map((edit) => edit.file))] }
|
|
112
|
-
: {}),
|
|
141
|
+
...(applyResult.kind === "applied" ? { changedFiles } : {}),
|
|
113
142
|
},
|
|
114
143
|
};
|
|
115
144
|
}
|
package/src/tool/result/types.ts
CHANGED
|
@@ -19,6 +19,26 @@ import type {
|
|
|
19
19
|
} from "../../session/target-store.ts";
|
|
20
20
|
import type { ResultProvenance } from "./assembly.ts";
|
|
21
21
|
|
|
22
|
+
/** Final state for a public tool result. */
|
|
23
|
+
export type ToolResultStatus = "completed" | "invalid-input" | "disambiguation" | "unavailable";
|
|
24
|
+
|
|
25
|
+
/** Truncation state for model-facing tool content. */
|
|
26
|
+
export interface ToolOutputTruncationDetails {
|
|
27
|
+
truncated: boolean;
|
|
28
|
+
fullOutputPath?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Bounded, structured rows for the expanded TUI body. */
|
|
32
|
+
export interface ToolDisplaySection {
|
|
33
|
+
key: string;
|
|
34
|
+
title: string;
|
|
35
|
+
lines: readonly string[];
|
|
36
|
+
shownCount: number;
|
|
37
|
+
totalCount: number | null;
|
|
38
|
+
omittedCount: number | null;
|
|
39
|
+
partialReason: string | null;
|
|
40
|
+
}
|
|
41
|
+
|
|
22
42
|
// ── Anchored coordinate resolution metadata ───────────────────────────
|
|
23
43
|
|
|
24
44
|
/**
|