@mrclrchtr/supi-lsp 1.3.1 → 1.5.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 +58 -39
- package/node_modules/@mrclrchtr/supi-core/README.md +52 -41
- package/node_modules/@mrclrchtr/supi-core/package.json +1 -1
- package/node_modules/@mrclrchtr/supi-core/src/api.ts +15 -13
- package/node_modules/@mrclrchtr/supi-core/src/{config-settings.ts → config/config-settings.ts} +2 -2
- package/node_modules/@mrclrchtr/supi-core/src/{context-provider-registry.ts → context/context-provider-registry.ts} +1 -1
- package/node_modules/@mrclrchtr/supi-core/src/extension.ts +1 -1
- package/node_modules/@mrclrchtr/supi-core/src/index.ts +15 -13
- package/node_modules/@mrclrchtr/supi-core/src/path-utils.ts +40 -0
- package/node_modules/@mrclrchtr/supi-core/src/registry-utils.ts +42 -10
- package/node_modules/@mrclrchtr/supi-core/src/{settings-registry.ts → settings/settings-registry.ts} +1 -1
- package/package.json +3 -2
- package/src/api.ts +16 -3
- package/src/client/client-refresh.ts +1 -1
- package/src/client/client.ts +27 -3
- package/src/client/transport.ts +61 -5
- package/src/config/tsconfig-scope.ts +244 -0
- package/src/{types.ts → config/types.ts} +4 -2
- package/src/coordinates.ts +11 -0
- package/src/diagnostics/diagnostic-augmentation.ts +5 -5
- package/src/diagnostics/diagnostic-context.ts +115 -0
- package/src/diagnostics/diagnostic-display.ts +1 -1
- package/src/diagnostics/diagnostic-summary.ts +3 -2
- package/src/diagnostics/diagnostics.ts +1 -1
- package/src/diagnostics/stale-diagnostics.ts +1 -1
- package/src/diagnostics/suppression-diagnostics.ts +1 -1
- package/src/{workspace-sentinels.ts → diagnostics/workspace-sentinels.ts} +2 -2
- package/src/format.ts +2 -23
- package/src/index.ts +18 -5
- package/src/lsp.ts +72 -120
- package/src/manager/manager-diagnostics.ts +1 -1
- package/src/manager/manager-helpers.ts +4 -2
- package/src/manager/manager-project-info.ts +10 -21
- package/src/manager/manager-workspace-recovery.ts +1 -1
- package/src/manager/manager-workspace-symbol.ts +158 -6
- package/src/manager/manager.ts +202 -43
- package/src/{lsp-state.ts → session/lsp-state.ts} +22 -11
- package/src/{scanner.ts → session/scanner.ts} +3 -3
- package/src/{service-registry.ts → session/service-registry.ts} +109 -33
- package/src/{settings-registration.ts → session/settings-registration.ts} +1 -1
- package/src/session/tree-persist.ts +75 -0
- package/src/summary.ts +1 -1
- package/src/tool/guidance.ts +78 -0
- package/src/tool/names.ts +19 -0
- package/src/{overrides.ts → tool/overrides.ts} +55 -24
- package/src/tool/register-tools.ts +71 -0
- package/src/tool/service-actions.ts +258 -0
- package/src/tool/tool-specs.ts +248 -0
- package/src/{ui.ts → ui/ui.ts} +4 -4
- package/src/utils.ts +5 -23
- package/src/guidance.ts +0 -163
- package/src/search-fallback.ts +0 -98
- package/src/tool-actions.ts +0 -430
- package/src/tree-persist.ts +0 -48
- package/src/tsconfig-scope.ts +0 -156
- /package/node_modules/@mrclrchtr/supi-core/src/{config.ts → config/config.ts} +0 -0
- /package/node_modules/@mrclrchtr/supi-core/src/{context-messages.ts → context/context-messages.ts} +0 -0
- /package/node_modules/@mrclrchtr/supi-core/src/{context-tag.ts → context/context-tag.ts} +0 -0
- /package/node_modules/@mrclrchtr/supi-core/src/{settings-command.ts → settings/settings-command.ts} +0 -0
- /package/node_modules/@mrclrchtr/supi-core/src/{settings-ui.ts → settings/settings-ui.ts} +0 -0
- /package/src/{capabilities.ts → config/capabilities.ts} +0 -0
- /package/src/{config.ts → config/config.ts} +0 -0
- /package/src/{defaults.json → config/defaults.json} +0 -0
- /package/src/{renderer.ts → ui/renderer.ts} +0 -0
package/README.md
CHANGED
|
@@ -1,71 +1,90 @@
|
|
|
1
1
|
# @mrclrchtr/supi-lsp
|
|
2
2
|
|
|
3
|
-
Language Server Protocol
|
|
3
|
+
Adds Language Server Protocol support to the [pi coding agent](https://github.com/earendil-works/pi).
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Install
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
```bash
|
|
8
|
+
pi install npm:@mrclrchtr/supi-lsp
|
|
9
|
+
```
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
For local development:
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
```bash
|
|
14
|
+
pi install ./packages/supi-lsp
|
|
15
|
+
```
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
After editing the source, run `/reload`.
|
|
14
18
|
|
|
15
|
-
|
|
19
|
+
## What you get
|
|
16
20
|
|
|
17
|
-
|
|
21
|
+
After install, pi gets:
|
|
18
22
|
|
|
19
|
-
|
|
23
|
+
- `lsp_lookup` — semantic hover, definition, references, and implementation at a known position
|
|
24
|
+
- `lsp_document_symbols` — semantic declarations for one supported file
|
|
25
|
+
- `lsp_workspace_symbols` — semantic symbol-name lookup across the project
|
|
26
|
+
- `lsp_diagnostics` — current diagnostics for one file or a workspace summary
|
|
27
|
+
- `lsp_refactor` — semantic rename planning and code actions at a known position
|
|
28
|
+
- `lsp_recover` — refresh stale diagnostics after workspace changes
|
|
29
|
+
- `/lsp-status` — inspect detected servers, roots, open files, and diagnostics
|
|
30
|
+
- automatic LSP-aware diagnostic surfacing around edits and agent turns
|
|
20
31
|
|
|
21
|
-
|
|
32
|
+
Coordinates use **1-based** line and character positions.
|
|
22
33
|
|
|
23
|
-
|
|
24
|
-
pi install npm:@mrclrchtr/supi-lsp
|
|
25
|
-
```
|
|
34
|
+
## Automatic behavior
|
|
26
35
|
|
|
27
|
-
|
|
36
|
+
This package does more than register a tool:
|
|
28
37
|
|
|
29
|
-
|
|
38
|
+
- starts detected language servers for the current project
|
|
39
|
+
- rebuilds project-specific prompt guidance based on active servers
|
|
40
|
+
- injects outstanding diagnostics into context before agent turns when issues exist
|
|
41
|
+
- adds inline diagnostics after `write` and `edit` results
|
|
42
|
+
- watches for workspace changes such as `package.json`, lockfile, `tsconfig`, generated types, and source-file edits so recovery can happen when diagnostics go stale
|
|
43
|
+
- warns when configured language-server commands are missing
|
|
30
44
|
|
|
31
|
-
|
|
32
|
-
|--------|----------------------|
|
|
33
|
-
| `hover` | See the type of any symbol |
|
|
34
|
-
| `definition` | Jump to where something is defined |
|
|
35
|
-
| `references` | Find every usage across the project |
|
|
36
|
-
| `diagnostics` | See errors, warnings, and hints |
|
|
37
|
-
| `rename` | Rename across the entire project |
|
|
45
|
+
## Settings
|
|
38
46
|
|
|
39
|
-
|
|
47
|
+
This package registers an **LSP** section in `/supi-settings`.
|
|
40
48
|
|
|
41
|
-
|
|
49
|
+
Available settings:
|
|
42
50
|
|
|
43
|
-
|
|
51
|
+
- `enabled` — turn all LSP behavior on or off
|
|
52
|
+
- `severity` — inline diagnostic threshold: `1` errors, `2` warnings, `3` info, `4` hints
|
|
53
|
+
- `active` — choose which configured language servers are active; empty means all
|
|
54
|
+
- `exclude` — gitignore-style patterns that suppress diagnostics for matching files
|
|
44
55
|
|
|
45
|
-
|
|
46
|
-
- Set diagnostic severity threshold (errors only, or include warnings/hints)
|
|
47
|
-
- Choose which language servers to activate
|
|
48
|
-
- Add file exclusion patterns (gitignore-style globs)
|
|
56
|
+
Config lives in the standard SuPi config files:
|
|
49
57
|
|
|
50
|
-
|
|
58
|
+
- global: `~/.pi/agent/supi/config.json`
|
|
59
|
+
- project: `.pi/supi/config.json`
|
|
51
60
|
|
|
52
61
|
## Package surfaces
|
|
53
62
|
|
|
54
|
-
- `@mrclrchtr/supi-lsp/api` — reusable
|
|
63
|
+
- `@mrclrchtr/supi-lsp/api` — reusable session-scoped LSP service and related types
|
|
55
64
|
- `@mrclrchtr/supi-lsp/extension` — pi extension entrypoint
|
|
56
65
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
## For extension developers
|
|
60
|
-
|
|
61
|
-
This package exports a reusable session-scoped LSP service. Peer extensions can query the same LSP runtime without starting duplicate servers:
|
|
66
|
+
Example:
|
|
62
67
|
|
|
63
68
|
```ts
|
|
64
|
-
import { getSessionLspService,
|
|
69
|
+
import { getSessionLspService, toLspPosition } from "@mrclrchtr/supi-lsp/api";
|
|
65
70
|
|
|
66
71
|
const state = getSessionLspService("/project");
|
|
67
72
|
if (state.kind === "ready") {
|
|
68
|
-
const defs = await state.service.definition("src/index.ts",
|
|
69
|
-
const refs = await state.service.references("src/index.ts", { line: 5, character: 10 });
|
|
73
|
+
const defs = await state.service.definition("src/index.ts", toLspPosition(6, 11));
|
|
70
74
|
}
|
|
71
75
|
```
|
|
76
|
+
|
|
77
|
+
`SessionLspService` methods use raw **0-based LSP positions**. The expert tools (`lsp_lookup`, `lsp_refactor`, etc.) keep the public 1-based coordinate UX.
|
|
78
|
+
|
|
79
|
+
## Source
|
|
80
|
+
|
|
81
|
+
- `src/lsp.ts` — extension wiring, session lifecycle, and `/lsp-status`
|
|
82
|
+
- `src/config/` — server config, defaults, capabilities, and exported LSP protocol types
|
|
83
|
+
- `src/session/` — session state, scanning, settings registration, tree persistence, and shared service registry
|
|
84
|
+
- `src/tool/register-tools.ts` — expert tool registration for the split LSP toolset
|
|
85
|
+
- `src/tool/service-actions.ts` — service-backed tool execution and formatting
|
|
86
|
+
- `src/tool/guidance.ts` / `src/tool/names.ts` — prompt surfaces and stable tool names
|
|
87
|
+
- `src/tool/overrides.ts` — read/write/edit overrides for inline diagnostics
|
|
88
|
+
- `src/ui/` — custom diagnostic message rendering and the status overlay
|
|
89
|
+
- `src/client/`, `src/manager/`, `src/diagnostics/` — runtime engine subsystems
|
|
90
|
+
- `src/api.ts` — reusable developer-facing surface
|
|
@@ -1,65 +1,78 @@
|
|
|
1
1
|
# @mrclrchtr/supi-core
|
|
2
2
|
|
|
3
|
-
Shared infrastructure for SuPi
|
|
3
|
+
Shared infrastructure for SuPi extensions.
|
|
4
|
+
|
|
5
|
+
This package is mainly for extension authors. It gives you a common config system, settings plumbing, context helpers, registries, and a small extension surface that registers `/supi-settings`.
|
|
4
6
|
|
|
5
7
|
## Install
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
### As a dependency for another extension
|
|
8
10
|
|
|
9
11
|
```bash
|
|
10
12
|
pnpm add @mrclrchtr/supi-core
|
|
11
13
|
```
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
`@mrclrchtr/supi-core` now has two explicit surfaces:
|
|
15
|
+
### As a pi package
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
`pi.extensions` still points at the real file path `./src/extension.ts` inside the package. The `/api` and `/extension` paths are consumer-facing package exports, not manifest aliases.
|
|
17
|
+
```bash
|
|
18
|
+
pi install npm:@mrclrchtr/supi-core
|
|
19
|
+
```
|
|
21
20
|
|
|
22
|
-
|
|
21
|
+
Installing it as a pi package adds the minimal `/supi-settings` extension surface.
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
## Package surfaces
|
|
25
24
|
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
- the shared settings registry, overlay UI, and `registerSettingsCommand()` helper
|
|
29
|
-
- XML `<extension-context>` wrapping plus context-message utilities
|
|
30
|
-
- context-provider and debug-event registries reused across SuPi packages
|
|
31
|
-
- project root and path helpers reused by packages such as `supi-lsp`
|
|
25
|
+
- `@mrclrchtr/supi-core/api` — reusable helpers for other packages and extensions
|
|
26
|
+
- `@mrclrchtr/supi-core/extension` — minimal pi extension that registers `/supi-settings`
|
|
32
27
|
|
|
33
|
-
##
|
|
28
|
+
## What you get from the API
|
|
34
29
|
|
|
35
|
-
Config
|
|
30
|
+
### Config helpers
|
|
36
31
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
- `loadSupiConfig()` — merged config with resolution order `defaults <- global <- project`
|
|
33
|
+
- `loadSupiConfigForScope()` — load one scope at a time for settings UIs
|
|
34
|
+
- `writeSupiConfig()` — persist values
|
|
35
|
+
- `removeSupiConfigKey()` — remove a key or override
|
|
40
36
|
|
|
41
37
|
Config file locations:
|
|
42
38
|
|
|
43
39
|
- global: `~/.pi/agent/supi/config.json`
|
|
44
40
|
- project: `.pi/supi/config.json`
|
|
45
41
|
|
|
46
|
-
|
|
42
|
+
### Settings helpers
|
|
43
|
+
|
|
44
|
+
- `registerSettings()` — register an arbitrary settings section
|
|
45
|
+
- `registerConfigSettings()` — register a config-backed settings section with scoped persistence helpers
|
|
46
|
+
- `registerSettingsCommand()` — register `/supi-settings`
|
|
47
|
+
- `openSettingsOverlay()` — open the shared settings UI directly
|
|
48
|
+
- `createInputSubmenu()` — helper for simple text-entry submenus
|
|
49
|
+
|
|
50
|
+
The built-in settings UI supports:
|
|
47
51
|
|
|
48
|
-
-
|
|
49
|
-
-
|
|
50
|
-
-
|
|
51
|
-
- `removeSupiConfigKey()`
|
|
52
|
-
- `registerConfigSettings()`
|
|
52
|
+
- project/global scope toggle
|
|
53
|
+
- grouped extension sections
|
|
54
|
+
- searchable setting lists
|
|
53
55
|
|
|
54
|
-
|
|
56
|
+
### Context helpers
|
|
55
57
|
|
|
56
|
-
- `wrapExtensionContext()`
|
|
58
|
+
- `wrapExtensionContext()` — wrap injected text in SuPi's `<extension-context>` tag
|
|
57
59
|
- `findLastUserMessageIndex()`
|
|
58
60
|
- `getContextToken()`
|
|
61
|
+
- `getPromptContent()`
|
|
59
62
|
- `pruneAndReorderContextMessages()`
|
|
60
|
-
- `
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
- `restorePromptContent()`
|
|
64
|
+
|
|
65
|
+
### Shared registries
|
|
66
|
+
|
|
67
|
+
- context-provider registry for `/supi-context`
|
|
68
|
+
- debug-event registry for producers that want shared debug capture
|
|
69
|
+
- settings registry used by `/supi-settings`
|
|
70
|
+
|
|
71
|
+
### Project and session helpers
|
|
72
|
+
|
|
73
|
+
- project-root detection and directory walking helpers such as `findProjectRoot()` and `walkProject()`
|
|
74
|
+
- active-branch session helper: `getActiveBranchEntries()`
|
|
75
|
+
- terminal helpers such as `formatTitle()`, `signalWaiting()`, and `signalDone()`
|
|
63
76
|
|
|
64
77
|
## Example
|
|
65
78
|
|
|
@@ -80,17 +93,15 @@ registerConfigSettings({
|
|
|
80
93
|
});
|
|
81
94
|
|
|
82
95
|
const message = wrapExtensionContext("my-extension", "hello", {
|
|
83
|
-
turn: 1,
|
|
84
96
|
file: "CLAUDE.md",
|
|
97
|
+
turn: 1,
|
|
85
98
|
});
|
|
86
99
|
```
|
|
87
100
|
|
|
88
|
-
## Requirements
|
|
89
|
-
|
|
90
|
-
- `@earendil-works/pi-coding-agent`
|
|
91
|
-
- `@earendil-works/pi-tui`
|
|
92
|
-
|
|
93
101
|
## Source
|
|
94
102
|
|
|
95
|
-
-
|
|
96
|
-
-
|
|
103
|
+
- `src/api.ts` — exported library surface
|
|
104
|
+
- `src/extension.ts` — minimal `/supi-settings` entrypoint
|
|
105
|
+
- `src/config.ts` — shared config loading and writing
|
|
106
|
+
- `src/config-settings.ts` — config-backed settings registration helper
|
|
107
|
+
- `src/settings-ui.ts` — shared settings overlay
|
|
@@ -2,30 +2,30 @@
|
|
|
2
2
|
// Provides XML context tag wrapping, unified config system, context-message utilities,
|
|
3
3
|
// and settings registry for supi-wide TUI settings.
|
|
4
4
|
|
|
5
|
-
export type { SupiConfigLocation, SupiConfigOptions } from "./config.ts";
|
|
5
|
+
export type { SupiConfigLocation, SupiConfigOptions } from "./config/config.ts";
|
|
6
6
|
export {
|
|
7
7
|
loadSupiConfig,
|
|
8
8
|
loadSupiConfigForScope,
|
|
9
9
|
removeSupiConfigKey,
|
|
10
10
|
writeSupiConfig,
|
|
11
|
-
} from "./config.ts";
|
|
12
|
-
export type { ConfigSettingsHelpers, ConfigSettingsOptions } from "./config-settings.ts";
|
|
13
|
-
export { registerConfigSettings } from "./config-settings.ts";
|
|
14
|
-
export type { ContextMessageLike } from "./context-messages.ts";
|
|
11
|
+
} from "./config/config.ts";
|
|
12
|
+
export type { ConfigSettingsHelpers, ConfigSettingsOptions } from "./config/config-settings.ts";
|
|
13
|
+
export { registerConfigSettings } from "./config/config-settings.ts";
|
|
14
|
+
export type { ContextMessageLike } from "./context/context-messages.ts";
|
|
15
15
|
export {
|
|
16
16
|
findLastUserMessageIndex,
|
|
17
17
|
getContextToken,
|
|
18
18
|
getPromptContent,
|
|
19
19
|
pruneAndReorderContextMessages,
|
|
20
20
|
restorePromptContent,
|
|
21
|
-
} from "./context-messages.ts";
|
|
22
|
-
export type { ContextProvider } from "./context-provider-registry.ts";
|
|
21
|
+
} from "./context/context-messages.ts";
|
|
22
|
+
export type { ContextProvider } from "./context/context-provider-registry.ts";
|
|
23
23
|
export {
|
|
24
24
|
clearRegisteredContextProviders,
|
|
25
25
|
getRegisteredContextProviders,
|
|
26
26
|
registerContextProvider,
|
|
27
|
-
} from "./context-provider-registry.ts";
|
|
28
|
-
export { wrapExtensionContext } from "./context-tag.ts";
|
|
27
|
+
} from "./context/context-provider-registry.ts";
|
|
28
|
+
export { wrapExtensionContext } from "./context/context-tag.ts";
|
|
29
29
|
export type {
|
|
30
30
|
DebugAgentAccess,
|
|
31
31
|
DebugEvent,
|
|
@@ -49,6 +49,7 @@ export {
|
|
|
49
49
|
redactDebugData,
|
|
50
50
|
resetDebugRegistry,
|
|
51
51
|
} from "./debug-registry.ts";
|
|
52
|
+
export { fileToUri, resolveToolPath, stripToolPathPrefix, uriToFile } from "./path-utils.ts";
|
|
52
53
|
export type { KnownRootEntry } from "./project-roots.ts";
|
|
53
54
|
export {
|
|
54
55
|
buildKnownRootsMap,
|
|
@@ -63,15 +64,16 @@ export {
|
|
|
63
64
|
sortRootsBySpecificity,
|
|
64
65
|
walkProject,
|
|
65
66
|
} from "./project-roots.ts";
|
|
67
|
+
export { createRegistry, createSessionStateRegistry } from "./registry-utils.ts";
|
|
66
68
|
export { getActiveBranchEntries } from "./session-utils.ts";
|
|
67
|
-
export { registerSettingsCommand } from "./settings-command.ts";
|
|
68
|
-
export type { SettingsScope, SettingsSection } from "./settings-registry.ts";
|
|
69
|
+
export { registerSettingsCommand } from "./settings/settings-command.ts";
|
|
70
|
+
export type { SettingsScope, SettingsSection } from "./settings/settings-registry.ts";
|
|
69
71
|
export {
|
|
70
72
|
clearRegisteredSettings,
|
|
71
73
|
getRegisteredSettings,
|
|
72
74
|
registerSettings,
|
|
73
|
-
} from "./settings-registry.ts";
|
|
74
|
-
export { createInputSubmenu, openSettingsOverlay } from "./settings-ui.ts";
|
|
75
|
+
} from "./settings/settings-registry.ts";
|
|
76
|
+
export { createInputSubmenu, openSettingsOverlay } from "./settings/settings-ui.ts";
|
|
75
77
|
export type { TitleTarget } from "./terminal.ts";
|
|
76
78
|
export {
|
|
77
79
|
DONE_SYMBOL,
|
package/node_modules/@mrclrchtr/supi-core/src/{config-settings.ts → config/config-settings.ts}
RENAMED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
// Wraps registerSettings() and centralizes selected-scope loading + scoped persistence.
|
|
3
3
|
|
|
4
4
|
import type { SettingItem } from "@earendil-works/pi-tui";
|
|
5
|
+
import type { SettingsScope } from "../settings/settings-registry.ts";
|
|
6
|
+
import { registerSettings } from "../settings/settings-registry.ts";
|
|
5
7
|
import { loadSupiConfigForScope, removeSupiConfigKey, writeSupiConfig } from "./config.ts";
|
|
6
|
-
import type { SettingsScope } from "./settings-registry.ts";
|
|
7
|
-
import { registerSettings } from "./settings-registry.ts";
|
|
8
8
|
|
|
9
9
|
export interface ConfigSettingsHelpers {
|
|
10
10
|
/** Write a key to the selected scope's config section. */
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Extensions declare context data providers via `registerContextProvider()` during their
|
|
4
4
|
// factory function. The `/supi-context` command reads them via `getRegisteredContextProviders()`.
|
|
5
5
|
|
|
6
|
-
import { createRegistry } from "
|
|
6
|
+
import { createRegistry } from "../registry-utils.ts";
|
|
7
7
|
|
|
8
8
|
export interface ContextProvider {
|
|
9
9
|
/** Unique identifier — e.g. "rtk" */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { registerSettingsCommand as default } from "./settings-command.ts";
|
|
1
|
+
export { registerSettingsCommand as default } from "./settings/settings-command.ts";
|
|
@@ -2,30 +2,30 @@
|
|
|
2
2
|
// Provides XML context tag wrapping, unified config system, context-message utilities,
|
|
3
3
|
// and settings registry for supi-wide TUI settings.
|
|
4
4
|
|
|
5
|
-
export type { SupiConfigLocation, SupiConfigOptions } from "./config.ts";
|
|
5
|
+
export type { SupiConfigLocation, SupiConfigOptions } from "./config/config.ts";
|
|
6
6
|
export {
|
|
7
7
|
loadSupiConfig,
|
|
8
8
|
loadSupiConfigForScope,
|
|
9
9
|
removeSupiConfigKey,
|
|
10
10
|
writeSupiConfig,
|
|
11
|
-
} from "./config.ts";
|
|
12
|
-
export type { ConfigSettingsHelpers, ConfigSettingsOptions } from "./config-settings.ts";
|
|
13
|
-
export { registerConfigSettings } from "./config-settings.ts";
|
|
14
|
-
export type { ContextMessageLike } from "./context-messages.ts";
|
|
11
|
+
} from "./config/config.ts";
|
|
12
|
+
export type { ConfigSettingsHelpers, ConfigSettingsOptions } from "./config/config-settings.ts";
|
|
13
|
+
export { registerConfigSettings } from "./config/config-settings.ts";
|
|
14
|
+
export type { ContextMessageLike } from "./context/context-messages.ts";
|
|
15
15
|
export {
|
|
16
16
|
findLastUserMessageIndex,
|
|
17
17
|
getContextToken,
|
|
18
18
|
getPromptContent,
|
|
19
19
|
pruneAndReorderContextMessages,
|
|
20
20
|
restorePromptContent,
|
|
21
|
-
} from "./context-messages.ts";
|
|
22
|
-
export type { ContextProvider } from "./context-provider-registry.ts";
|
|
21
|
+
} from "./context/context-messages.ts";
|
|
22
|
+
export type { ContextProvider } from "./context/context-provider-registry.ts";
|
|
23
23
|
export {
|
|
24
24
|
clearRegisteredContextProviders,
|
|
25
25
|
getRegisteredContextProviders,
|
|
26
26
|
registerContextProvider,
|
|
27
|
-
} from "./context-provider-registry.ts";
|
|
28
|
-
export { wrapExtensionContext } from "./context-tag.ts";
|
|
27
|
+
} from "./context/context-provider-registry.ts";
|
|
28
|
+
export { wrapExtensionContext } from "./context/context-tag.ts";
|
|
29
29
|
export type {
|
|
30
30
|
DebugAgentAccess,
|
|
31
31
|
DebugEvent,
|
|
@@ -49,6 +49,7 @@ export {
|
|
|
49
49
|
redactDebugData,
|
|
50
50
|
resetDebugRegistry,
|
|
51
51
|
} from "./debug-registry.ts";
|
|
52
|
+
export { fileToUri, resolveToolPath, stripToolPathPrefix, uriToFile } from "./path-utils.ts";
|
|
52
53
|
export type { KnownRootEntry } from "./project-roots.ts";
|
|
53
54
|
export {
|
|
54
55
|
buildKnownRootsMap,
|
|
@@ -63,15 +64,16 @@ export {
|
|
|
63
64
|
sortRootsBySpecificity,
|
|
64
65
|
walkProject,
|
|
65
66
|
} from "./project-roots.ts";
|
|
67
|
+
export { createRegistry, createSessionStateRegistry } from "./registry-utils.ts";
|
|
66
68
|
export { getActiveBranchEntries } from "./session-utils.ts";
|
|
67
|
-
export { registerSettingsCommand } from "./settings-command.ts";
|
|
68
|
-
export type { SettingsScope, SettingsSection } from "./settings-registry.ts";
|
|
69
|
+
export { registerSettingsCommand } from "./settings/settings-command.ts";
|
|
70
|
+
export type { SettingsScope, SettingsSection } from "./settings/settings-registry.ts";
|
|
69
71
|
export {
|
|
70
72
|
clearRegisteredSettings,
|
|
71
73
|
getRegisteredSettings,
|
|
72
74
|
registerSettings,
|
|
73
|
-
} from "./settings-registry.ts";
|
|
74
|
-
export { createInputSubmenu, openSettingsOverlay } from "./settings-ui.ts";
|
|
75
|
+
} from "./settings/settings-registry.ts";
|
|
76
|
+
export { createInputSubmenu, openSettingsOverlay } from "./settings/settings-ui.ts";
|
|
75
77
|
export type { TitleTarget } from "./terminal.ts";
|
|
76
78
|
export {
|
|
77
79
|
DONE_SYMBOL,
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as path from "node:path";
|
|
2
|
+
|
|
3
|
+
/** Strip pi's optional leading `@` file-path prefix from a tool input. */
|
|
4
|
+
export function stripToolPathPrefix(target: string): string {
|
|
5
|
+
return target.startsWith("@") ? target.slice(1) : target;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Resolve a tool-style file path from a session cwd.
|
|
10
|
+
*
|
|
11
|
+
* Built-in pi file tools accept a leading `@` prefix in path arguments, so
|
|
12
|
+
* shared SuPi path helpers normalize that prefix before resolving relative
|
|
13
|
+
* paths.
|
|
14
|
+
*/
|
|
15
|
+
export function resolveToolPath(cwd: string, target: string): string {
|
|
16
|
+
return path.resolve(cwd, stripToolPathPrefix(target));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Convert a file path to a file:// URI. */
|
|
20
|
+
export function fileToUri(filePath: string): string {
|
|
21
|
+
const resolved = path.resolve(filePath);
|
|
22
|
+
if (process.platform === "win32") {
|
|
23
|
+
return `file:///${resolved.replace(/\\/g, "/")}`;
|
|
24
|
+
}
|
|
25
|
+
return `file://${resolved}`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Convert a file:// URI to a file path. */
|
|
29
|
+
export function uriToFile(uri: string): string {
|
|
30
|
+
if (!uri.startsWith("file://")) return uri;
|
|
31
|
+
let filePath = decodeURIComponent(uri.slice(7));
|
|
32
|
+
if (
|
|
33
|
+
process.platform === "win32" &&
|
|
34
|
+
filePath.startsWith("/") &&
|
|
35
|
+
/^[A-Za-z]:/.test(filePath.slice(1))
|
|
36
|
+
) {
|
|
37
|
+
filePath = filePath.slice(1);
|
|
38
|
+
}
|
|
39
|
+
return filePath;
|
|
40
|
+
}
|
|
@@ -5,8 +5,20 @@
|
|
|
5
5
|
// Without this, each symlink path gets its own module copy and its own Map,
|
|
6
6
|
// so registrations from one instance are invisible to consumers in another.
|
|
7
7
|
|
|
8
|
+
import * as path from "node:path";
|
|
9
|
+
|
|
8
10
|
const SYMBOL_PREFIX = "@mrclrchtr/supi-core/";
|
|
9
11
|
|
|
12
|
+
function getGlobalRegistryMap<T>(name: string): Map<string, T> {
|
|
13
|
+
const key = Symbol.for(SYMBOL_PREFIX + name);
|
|
14
|
+
let map = (globalThis as Record<symbol, unknown>)[key] as Map<string, T> | undefined;
|
|
15
|
+
if (!map) {
|
|
16
|
+
map = new Map<string, T>();
|
|
17
|
+
(globalThis as Record<symbol, unknown>)[key] = map;
|
|
18
|
+
}
|
|
19
|
+
return map;
|
|
20
|
+
}
|
|
21
|
+
|
|
10
22
|
/**
|
|
11
23
|
* Create a named registry backed by `globalThis` + `Symbol.for`.
|
|
12
24
|
*
|
|
@@ -18,16 +30,7 @@ const SYMBOL_PREFIX = "@mrclrchtr/supi-core/";
|
|
|
18
30
|
* @returns An object with `register`, `getAll`, and `clear` functions.
|
|
19
31
|
*/
|
|
20
32
|
export function createRegistry<T>(name: string) {
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
const getMap = (): Map<string, T> => {
|
|
24
|
-
let map = (globalThis as Record<symbol, unknown>)[key] as Map<string, T> | undefined;
|
|
25
|
-
if (!map) {
|
|
26
|
-
map = new Map<string, T>();
|
|
27
|
-
(globalThis as Record<symbol, unknown>)[key] = map;
|
|
28
|
-
}
|
|
29
|
-
return map;
|
|
30
|
-
};
|
|
33
|
+
const getMap = (): Map<string, T> => getGlobalRegistryMap<T>(name);
|
|
31
34
|
|
|
32
35
|
return {
|
|
33
36
|
/**
|
|
@@ -52,3 +55,32 @@ export function createRegistry<T>(name: string) {
|
|
|
52
55
|
},
|
|
53
56
|
};
|
|
54
57
|
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Create a named session-state registry keyed by normalized cwd.
|
|
61
|
+
*
|
|
62
|
+
* This helper is intended for session-scoped runtime services that should be
|
|
63
|
+
* shared across duplicate jiti module instances while keeping package-specific
|
|
64
|
+
* state unions and convenience wrappers local to the calling package.
|
|
65
|
+
*/
|
|
66
|
+
export function createSessionStateRegistry<TState>(name: string) {
|
|
67
|
+
const getMap = (): Map<string, TState> => getGlobalRegistryMap<TState>(name);
|
|
68
|
+
const normalizeCwd = (cwd: string): string => path.resolve(cwd);
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
/** Get the current state for one session cwd. */
|
|
72
|
+
get: (cwd: string): TState | undefined => {
|
|
73
|
+
return getMap().get(normalizeCwd(cwd));
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
/** Store the current state for one session cwd. */
|
|
77
|
+
set: (cwd: string, state: TState): void => {
|
|
78
|
+
getMap().set(normalizeCwd(cwd), state);
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
/** Clear the current state for one session cwd. */
|
|
82
|
+
clear: (cwd: string): void => {
|
|
83
|
+
getMap().delete(normalizeCwd(cwd));
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
}
|
package/node_modules/@mrclrchtr/supi-core/src/{settings-registry.ts → settings/settings-registry.ts}
RENAMED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// factory function. The generic settings UI reads them via `getRegisteredSettings()`.
|
|
5
5
|
|
|
6
6
|
import type { SettingItem } from "@earendil-works/pi-tui";
|
|
7
|
-
import { createRegistry } from "
|
|
7
|
+
import { createRegistry } from "../registry-utils.ts";
|
|
8
8
|
|
|
9
9
|
export type SettingsScope = "project" | "global";
|
|
10
10
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrclrchtr/supi-lsp",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "SuPi LSP extension — Language Server Protocol integration for pi",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
"!__tests__"
|
|
22
22
|
],
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"
|
|
24
|
+
"typescript": "6.0.3",
|
|
25
|
+
"@mrclrchtr/supi-core": "1.5.0"
|
|
25
26
|
},
|
|
26
27
|
"bundledDependencies": [
|
|
27
28
|
"@mrclrchtr/supi-core"
|
package/src/api.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// Public API surface for the LSP session-scoped service.
|
|
2
2
|
|
|
3
|
-
export type { SessionLspServiceState } from "./service-registry.ts";
|
|
4
|
-
export { getSessionLspService, SessionLspService } from "./service-registry.ts";
|
|
5
3
|
export type {
|
|
4
|
+
CodeAction,
|
|
6
5
|
Diagnostic,
|
|
7
6
|
DocumentSymbol,
|
|
8
7
|
Hover,
|
|
@@ -10,6 +9,20 @@ export type {
|
|
|
10
9
|
LocationLink,
|
|
11
10
|
Position,
|
|
12
11
|
ProjectServerInfo,
|
|
12
|
+
Range,
|
|
13
13
|
SymbolInformation,
|
|
14
|
+
WorkspaceEdit,
|
|
14
15
|
WorkspaceSymbol,
|
|
15
|
-
} from "./types.ts";
|
|
16
|
+
} from "./config/types.ts";
|
|
17
|
+
export { toLspPosition, toOneBasedPosition } from "./coordinates.ts";
|
|
18
|
+
export type {
|
|
19
|
+
OutstandingDiagnosticSummaryEntry,
|
|
20
|
+
RecoverDiagnosticsResult,
|
|
21
|
+
SessionLspServiceState,
|
|
22
|
+
WorkspaceDiagnosticSummaryEntry,
|
|
23
|
+
} from "./session/service-registry.ts";
|
|
24
|
+
export {
|
|
25
|
+
getSessionLspService,
|
|
26
|
+
SessionLspService,
|
|
27
|
+
waitForSessionLspService,
|
|
28
|
+
} from "./session/service-registry.ts";
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Extracted from client.ts to keep file sizes manageable.
|
|
3
3
|
|
|
4
4
|
import { existsSync, readFileSync } from "node:fs";
|
|
5
|
-
import type { DocumentDiagnosticReport, TextDocumentIdentifier } from "../types.ts";
|
|
5
|
+
import type { DocumentDiagnosticReport, TextDocumentIdentifier } from "../config/types.ts";
|
|
6
6
|
import { uriToFile } from "../utils.ts";
|
|
7
7
|
import type { DiagnosticCacheEntry, LspClient } from "./client.ts";
|
|
8
8
|
import type { JsonRpcClient } from "./transport.ts";
|