@mrclrchtr/supi-code-intelligence 11.3.0 → 12.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.
Files changed (132) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/README.md +15 -9
  3. package/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  4. package/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +3 -1
  5. package/node_modules/@mrclrchtr/supi-code-runtime/src/declaration-level.ts +34 -0
  6. package/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +64 -28
  7. package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  8. package/node_modules/@mrclrchtr/supi-lsp/README.md +22 -17
  9. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  10. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +3 -1
  11. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/declaration-level.ts +34 -0
  12. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +64 -28
  13. package/node_modules/@mrclrchtr/supi-lsp/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  14. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/classes/range.js +2 -2
  15. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/constants.js +30 -0
  16. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/internal/trim-comparator-whitespace.js +438 -0
  17. package/node_modules/@mrclrchtr/supi-lsp/node_modules/semver/package.json +1 -1
  18. package/node_modules/@mrclrchtr/supi-lsp/package.json +3 -3
  19. package/node_modules/@mrclrchtr/supi-lsp/src/api.ts +2 -2
  20. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostic-capabilities.ts +13 -3
  21. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-diagnostics.ts +25 -9
  22. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-document-sync.ts +7 -5
  23. package/node_modules/@mrclrchtr/supi-lsp/src/client/client-edit-capture.ts +258 -0
  24. package/node_modules/@mrclrchtr/supi-lsp/src/client/client.ts +64 -11
  25. package/node_modules/@mrclrchtr/supi-lsp/src/config/capabilities.ts +8 -0
  26. package/node_modules/@mrclrchtr/supi-lsp/src/config/operation-support.ts +48 -79
  27. package/node_modules/@mrclrchtr/supi-lsp/src/config/tsconfig-scope.ts +10 -0
  28. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager-typescript-coverage.ts +118 -0
  29. package/node_modules/@mrclrchtr/supi-lsp/src/manager/manager.ts +67 -3
  30. package/node_modules/@mrclrchtr/supi-lsp/src/manager/typescript-file-local.ts +87 -0
  31. package/node_modules/@mrclrchtr/supi-lsp/src/provider/lsp-refactor-provider.ts +21 -35
  32. package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-command-capture.ts +139 -0
  33. package/node_modules/@mrclrchtr/supi-lsp/src/provider/refactor-planning.ts +202 -47
  34. package/node_modules/@mrclrchtr/supi-lsp/src/provider/semantic-symbol-mapper.ts +22 -17
  35. package/node_modules/@mrclrchtr/supi-lsp/src/session/route-boundary.ts +26 -0
  36. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-registry.ts +106 -16
  37. package/node_modules/@mrclrchtr/supi-lsp/src/session/runtime-rename.ts +3 -0
  38. package/node_modules/@mrclrchtr/supi-lsp/src/session/workspace-lsp-runtime.ts +22 -1
  39. package/node_modules/@mrclrchtr/supi-tree-sitter/README.md +1 -1
  40. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/package.json +1 -1
  41. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/api.ts +3 -1
  42. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/declaration-level.ts +34 -0
  43. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-code-runtime/src/types.ts +64 -28
  44. package/node_modules/@mrclrchtr/supi-tree-sitter/node_modules/@mrclrchtr/supi-core/package.json +1 -1
  45. package/node_modules/@mrclrchtr/supi-tree-sitter/package.json +3 -3
  46. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm +0 -0
  47. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/tsx/tree-sitter-tsx.wasm.json +5 -1
  48. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm +0 -0
  49. package/node_modules/@mrclrchtr/supi-tree-sitter/resources/grammars/typescript/tree-sitter-typescript.wasm.json +5 -1
  50. package/node_modules/@mrclrchtr/supi-tree-sitter/src/coordinates.ts +16 -2
  51. package/node_modules/@mrclrchtr/supi-tree-sitter/src/session/structural-worker-client.ts +3 -2
  52. package/node_modules/@mrclrchtr/supi-tree-sitter/src/syntax-errors.ts +2 -0
  53. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-range.ts +94 -0
  54. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/call-sites.ts +26 -6
  55. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/callees.ts +6 -3
  56. package/node_modules/@mrclrchtr/supi-tree-sitter/src/tool/exports.ts +13 -4
  57. package/node_modules/@mrclrchtr/supi-tree-sitter/src/worker/runtime.ts +1 -9
  58. package/package.json +5 -5
  59. package/src/analysis/health/server-status.ts +41 -12
  60. package/src/analysis/helpers.ts +0 -7
  61. package/src/analysis/relations/implementations.ts +5 -0
  62. package/src/analysis/relations/references.ts +5 -0
  63. package/src/analysis/target/anchored-structural.ts +4 -1
  64. package/src/analysis/target/file-merge.ts +162 -0
  65. package/src/analysis/target/file-outline-omissions.ts +146 -0
  66. package/src/analysis/target/file-refinement.ts +7 -7
  67. package/src/analysis/target/file.ts +44 -156
  68. package/src/analysis/target/symbol.ts +5 -1
  69. package/src/analysis/target/types.ts +32 -6
  70. package/src/api.ts +1 -1
  71. package/src/app/app.ts +9 -3
  72. package/src/session/find-types.ts +8 -4
  73. package/src/session/find-workflow.ts +11 -16
  74. package/src/session/graph/collect.ts +2 -0
  75. package/src/session/graph-types.ts +3 -1
  76. package/src/session/graph-workflow.ts +5 -4
  77. package/src/session/input/health-refactor.ts +48 -34
  78. package/src/session/input/workflows.ts +45 -46
  79. package/src/session/inspect/file-point.ts +2 -2
  80. package/src/session/inspect-types.ts +1 -1
  81. package/src/session/inspect-workflow.ts +3 -3
  82. package/src/session/orientation/workspace-context.ts +3 -0
  83. package/src/session/orientation-workflow.ts +6 -3
  84. package/src/session/refactor-file-actions.ts +122 -0
  85. package/src/session/refactor-plan-pipeline.ts +152 -0
  86. package/src/session/refactor-plans.ts +18 -15
  87. package/src/session/refactor-types.ts +24 -12
  88. package/src/session/refactor-workflow.ts +70 -244
  89. package/src/session/session.ts +87 -12
  90. package/src/session/target-workflow.ts +23 -21
  91. package/src/tool/code_find/execute.ts +6 -7
  92. package/src/tool/code_find/spec.ts +9 -16
  93. package/src/tool/code_find/tui.ts +12 -6
  94. package/src/tool/code_graph/section.ts +4 -0
  95. package/src/tool/code_graph/spec.ts +6 -0
  96. package/src/tool/code_health/spec.ts +6 -0
  97. package/src/tool/code_health/structured-schema.ts +4 -4
  98. package/src/tool/code_health/structured.ts +15 -17
  99. package/src/tool/code_inspect/execute.ts +1 -1
  100. package/src/tool/code_inspect/markdown.ts +33 -6
  101. package/src/tool/code_inspect/result.ts +1 -1
  102. package/src/tool/code_inspect/spec.ts +14 -6
  103. package/src/tool/code_inspect/structured.ts +2 -2
  104. package/src/tool/code_inspect/tui.ts +2 -2
  105. package/src/tool/code_orientation/directory-navigation.ts +20 -31
  106. package/src/tool/code_orientation/spec.ts +8 -0
  107. package/src/tool/code_orientation/workspace-output.ts +40 -13
  108. package/src/tool/code_orientation/workspace-sections.ts +45 -2
  109. package/src/tool/code_refactor_apply/result.ts +2 -1
  110. package/src/tool/code_refactor_apply/spec.ts +7 -0
  111. package/src/tool/code_refactor_plan/execute.ts +0 -2
  112. package/src/tool/code_refactor_plan/result.ts +23 -13
  113. package/src/tool/code_refactor_plan/spec.ts +8 -2
  114. package/src/tool/code_refactor_plan/structured.ts +59 -12
  115. package/src/tool/code_refactor_plan/tui.ts +14 -17
  116. package/src/tool/code_resolve/guidance.ts +1 -1
  117. package/src/tool/code_resolve/markdown.ts +121 -34
  118. package/src/tool/code_resolve/result.ts +18 -15
  119. package/src/tool/code_resolve/spec.ts +6 -0
  120. package/src/tool/code_resolve/structured.ts +43 -10
  121. package/src/tool/namespace.ts +14 -0
  122. package/src/tool/refactor-markdown.ts +55 -15
  123. package/src/tool/register.ts +3 -0
  124. package/src/tool/result/model-budget.ts +2 -2
  125. package/src/tool/result/refactor-preview.ts +118 -0
  126. package/src/tool/result/refactor-unavailable.ts +16 -0
  127. package/src/tool/result/refactor.ts +8 -2
  128. package/src/tool/result/types.ts +13 -10
  129. package/src/tool/schemas.ts +63 -20
  130. package/src/tool/specs.ts +3 -0
  131. package/src/ui/status-overlay.ts +1 -1
  132. package/src/ui/tui/common.ts +10 -10
@@ -5,6 +5,7 @@ import { toDisplayPath } from "../../analysis/search/paths.ts";
5
5
  import type { RefactorPlan } from "../../session/refactor-plans.ts";
6
6
  import { assembledNextQueries, assembleToolResult, type ToolResultAssembly } from "./assembly.ts";
7
7
  import { createToolDisplaySection } from "./display.ts";
8
+ import { previewEditCount } from "./refactor-preview.ts";
8
9
  import type { SearchDetails, ToolDisplaySection } from "./types.ts";
9
10
 
10
11
  export interface RefactorPlanAssemblyData {
@@ -45,7 +46,7 @@ export function assembleRefactorPlanDetails(
45
46
  const edits = createEvidenceList({
46
47
  key: "refactor.edits",
47
48
  items: [...plan.edits.edits],
48
- maxResults,
49
+ maxResults: previewEditCount(plan.edits.edits, maxResults),
49
50
  });
50
51
  const evidenceSource = plan.evidenceSource ?? "semantic";
51
52
  const provenance = [
@@ -67,7 +68,12 @@ export function assembleRefactorPlanDetails(
67
68
  },
68
69
  ],
69
70
  evidenceLists: [edits.metadata],
70
- nextQueries: [`Use code_refactor_apply with planId: "${plan.id}" to apply this refactor`],
71
+ nextQueries: [
72
+ `Use code_refactor_apply with planId: "${plan.id}" to apply this refactor`,
73
+ ...(plan.operation === "code_action"
74
+ ? ["After applying, use rename_symbol to rename any server-generated names"]
75
+ : []),
76
+ ],
71
77
  candidateCount: edits.metadata.totalCount ?? edits.metadata.shownCount,
72
78
  confidence: evidenceSource,
73
79
  provenance,
@@ -9,6 +9,7 @@ import type {
9
9
  StructuredMatch,
10
10
  StructuredScanSummary,
11
11
  } from "../../analysis/search/pattern.ts";
12
+ import type { FileOutlineNotListed } from "../../analysis/target/types.ts";
12
13
  import type {
13
14
  HealthDiagnosticObservation,
14
15
  HealthRefreshState,
@@ -123,20 +124,22 @@ export type { DisambiguationCandidateData as DisambiguationCandidate } from "../
123
124
  export interface ResolveDetails {
124
125
  resultKind:
125
126
  | "resolved"
126
- | "target-group"
127
+ | "file-outline"
127
128
  | "disambiguation"
128
129
  | "kind-mismatch"
129
130
  | "invalid-input"
130
131
  | "unavailable";
131
- /** Workspace-relative source file for a file-derived Target group. */
132
- groupFile?: string;
133
- /** Providers that successfully enumerated a file-derived Target group. */
134
- groupDiscoveryProvenance?: readonly TargetProviderProvenance[];
135
- /** Complete-group declarations whose providers could not establish nesting. */
136
- groupUnknownNestingCount?: number;
137
- /** Provider recovery that makes this target group incomplete. */
138
- groupPartialReason?: string | null;
139
- groupErrorRanges?: readonly SourceRange[];
132
+ /** Workspace-relative source file of a File outline. */
133
+ outlineFile?: string;
134
+ /** Providers that successfully enumerated the File outline's file. */
135
+ outlineDiscoveryProvenance?: readonly TargetProviderProvenance[];
136
+ /** Outline declarations whose provider reported no enclosing declaration. */
137
+ outlineUnknownLevelCount?: number;
138
+ /** Provider recovery that makes this File outline incomplete. */
139
+ outlinePartialReason?: string | null;
140
+ outlineErrorRanges?: readonly SourceRange[];
141
+ /** Discovered declarations left out of the File outline, with exact counts. */
142
+ outlineNotListed?: FileOutlineNotListed;
140
143
  /** Strict provider kind that produced a near-match result. */
141
144
  requestedKind?: TargetSymbolKind;
142
145
  confidence: ConfidenceMode;
@@ -4,11 +4,12 @@ import {
4
4
  type PublicRefactorOperationName,
5
5
  } from "../session/refactor-types.ts";
6
6
  import { TARGET_SYMBOL_KINDS } from "../session/target-input.ts";
7
+ import { CODE_FIND_AST_KINDS } from "./code_find/ast-kinds.ts";
7
8
 
8
9
  export const ScopeParam = Type.String({
9
10
  description: "Workspace-relative file or directory scope.",
10
11
  });
11
- export const FindScopeParam = Type.Array(
12
+ export const FindScopesParam = Type.Array(
12
13
  Type.String({ description: "Workspace-relative search scope." }),
13
14
  {
14
15
  description: "One or more workspace-relative search scopes.",
@@ -20,11 +21,6 @@ export const QueryParam = Type.String({
20
21
  description: "Human or code reference to resolve or search for.",
21
22
  minLength: 1,
22
23
  });
23
- export const FindQueryParam = Type.String({
24
- description:
25
- "AST mode: name or import module-specifier substring. Semantic mode: workspace-symbol query.",
26
- minLength: 1,
27
- });
28
24
  const LineParam = Type.Integer({ description: "1-based line.", minimum: 1 });
29
25
  const CharacterParam = Type.Integer({
30
26
  description: "1-based UTF-16 column.",
@@ -74,6 +70,29 @@ function exactOneSelector(properties: Record<string, TSchema>, description: stri
74
70
  });
75
71
  }
76
72
 
73
+ export const FindSearchParam = exactOneSelector(
74
+ {
75
+ ast: Type.Object(
76
+ {
77
+ kind: Type.Enum(CODE_FIND_AST_KINDS, {
78
+ type: "string",
79
+ description: "AST structure kind.",
80
+ }),
81
+ query: Type.String({
82
+ description: "Name or import module-specifier substring.",
83
+ minLength: 1,
84
+ }),
85
+ },
86
+ { additionalProperties: false, description: "Structural search over syntax trees." },
87
+ ),
88
+ semantic: Type.Object(
89
+ { query: Type.String({ description: "Workspace-symbol query.", minLength: 1 }) },
90
+ { additionalProperties: false, description: "Language-server workspace-symbol search." },
91
+ ),
92
+ },
93
+ "Exactly one search mode.",
94
+ );
95
+
77
96
  export const ResolveTargetParam = exactOneSelector(
78
97
  {
79
98
  anchor: SourcePointParam,
@@ -112,7 +131,7 @@ export const OrientationFocusParam = exactOneSelector(
112
131
  "Exactly one Orientation focus.",
113
132
  );
114
133
 
115
- export const RefactorTargetParam = exactOneSelector(
134
+ const RefactorTargetParam = exactOneSelector(
116
135
  {
117
136
  handle: Type.String({ description: "Target handle from a previous code tool result." }),
118
137
  anchor: SourcePointParam,
@@ -131,28 +150,52 @@ const RangeParam = Type.Object(
131
150
  { additionalProperties: false },
132
151
  ),
133
152
  },
134
- { additionalProperties: false },
153
+ {
154
+ additionalProperties: false,
155
+ description: "Source range; end is exclusive. Equal start and end mark a cursor position.",
156
+ },
135
157
  );
136
158
 
137
159
  const NewNameParam = Type.String({ description: "New symbol name.", minLength: 1 });
160
+ const ActionTitleParam = Type.String({
161
+ description:
162
+ "Exact action title from a previous ambiguous result; selects one of several matching actions.",
163
+ minLength: 1,
164
+ });
138
165
 
139
166
  const RefactorOperationProperties = {
140
- rename_symbol: Type.Object({ newName: NewNameParam }, { additionalProperties: false }),
141
- extract_function: Type.Object(
142
- { newName: NewNameParam, range: RangeParam },
143
- { additionalProperties: false },
144
- ),
145
- extract_variable: Type.Object(
146
- { newName: NewNameParam, range: RangeParam },
147
- { additionalProperties: false },
167
+ rename_symbol: Type.Object(
168
+ { target: RefactorTargetParam, newName: NewNameParam },
169
+ { additionalProperties: false, description: "Rename one symbol across the workspace." },
148
170
  ),
149
- update_imports: Type.Object({}, { additionalProperties: false }),
150
- delete_dead_code: Type.Object(
151
- {},
171
+ code_action: Type.Object(
172
+ {
173
+ file: FileParam,
174
+ range: RangeParam,
175
+ kind: Type.String({
176
+ description:
177
+ 'CodeActionKind prefix under "refactor", such as "refactor.extract" or "refactor.inline". Sub-kinds match.',
178
+ pattern: "^refactor(\\..+)?$",
179
+ }),
180
+ title: Type.Optional(ActionTitleParam),
181
+ },
152
182
  {
153
183
  additionalProperties: false,
154
- description: "Remove server-supported unused code; support may be limited to unused imports.",
184
+ description:
185
+ "Server refactor action for one range. Generated names (e.g. extracted variables) appear in the preview; rename them afterwards with rename_symbol.",
186
+ },
187
+ ),
188
+ source_action: Type.Object(
189
+ {
190
+ file: FileParam,
191
+ kind: Type.String({
192
+ description:
193
+ 'CodeActionKind prefix under "source", such as "source.organizeImports" or "source.fixAll". Sub-kinds match.',
194
+ pattern: "^source(\\..+)?$",
195
+ }),
196
+ title: Type.Optional(ActionTitleParam),
155
197
  },
198
+ { additionalProperties: false, description: "Server source action for one whole file." },
156
199
  ),
157
200
  } satisfies Record<PublicRefactorOperationName, TSchema>;
158
201
 
package/src/tool/specs.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { ToolAnnotations } from "@earendil-works/pi-coding-agent";
1
2
  import type { Component } from "@earendil-works/pi-tui";
2
3
  import type { TSchema } from "typebox";
3
4
  import type {
@@ -27,6 +28,8 @@ export type CodeToolRendererFn = (...args: any[]) => Component;
27
28
  export interface CodeIntelligenceToolDefinitionSpec {
28
29
  name: CodeIntelligenceToolName;
29
30
  label: string;
31
+ /** Audited behavior hints for permission extensions (MCP tool-annotation semantics). */
32
+ annotations: ToolAnnotations;
30
33
  parameters: TSchema;
31
34
  /** Machine-readable success and recoverable-input outcomes for programmatic callers. */
32
35
  outputSchema?: TSchema;
@@ -618,7 +618,7 @@ export class CiStatusDialog {
618
618
  text(
619
619
  t.fg(
620
620
  "dim",
621
- ` ${operation}: server ${support.server}; SuPi ${support.supi}${support.reason ? ` — ${support.reason}` : ""}`,
621
+ ` ${operation}: server ${support.server}; SuPi ${support.supi}${support.kinds?.length ? `; kinds ${support.kinds.join(", ")}` : ""}${support.anyKind ? "; may return any kind" : ""}${support.reason ? ` — ${support.reason}` : ""}`,
622
622
  ),
623
623
  );
624
624
  }
@@ -310,13 +310,13 @@ export function buildSimpleCompact(data: Record<string, unknown> | undefined, th
310
310
  const confidence = typeof data.confidence === "string" ? data.confidence : "";
311
311
  const dot = theme.fg("dim", "·");
312
312
  const segments = badges.map((badge) => theme.fg("success", theme.bold(badge)));
313
- const unknownNestingCount = data.groupUnknownNestingCount;
313
+ const unknownLevelCount = data.outlineUnknownLevelCount;
314
314
  if (
315
- typeof unknownNestingCount === "number" &&
316
- Number.isInteger(unknownNestingCount) &&
317
- unknownNestingCount > 0
315
+ typeof unknownLevelCount === "number" &&
316
+ Number.isInteger(unknownLevelCount) &&
317
+ unknownLevelCount > 0
318
318
  ) {
319
- segments.push(theme.fg("warning", `${unknownNestingCount} hierarchy unknown`));
319
+ segments.push(theme.fg("warning", `${unknownLevelCount} position unknown`));
320
320
  }
321
321
  if (confidence) {
322
322
  segments.push(`${theme.fg("dim", "confidence")} ${theme.fg("muted", confidence)}`);
@@ -349,13 +349,13 @@ function structuredDetailLines(data: Record<string, unknown>): string[] {
349
349
 
350
350
  lines.push(...inspectSectionStatusLines(data.sections));
351
351
 
352
- const unknownNestingCount = data.groupUnknownNestingCount;
352
+ const unknownLevelCount = data.outlineUnknownLevelCount;
353
353
  if (
354
- typeof unknownNestingCount === "number" &&
355
- Number.isInteger(unknownNestingCount) &&
356
- unknownNestingCount > 0
354
+ typeof unknownLevelCount === "number" &&
355
+ Number.isInteger(unknownLevelCount) &&
356
+ unknownLevelCount > 0
357
357
  ) {
358
- lines.push(`hierarchy unknown: ${unknownNestingCount}`);
358
+ lines.push(`position unknown: ${unknownLevelCount}`);
359
359
  }
360
360
 
361
361
  const checkNext = data.checkNext;