@oh-my-pi/pi-coding-agent 17.2.10 → 17.2.12
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/CHANGELOG.md +53 -0
- package/dist/{CHANGELOG-rhwzpexa.md → CHANGELOG-k9ghy5sn.md} +53 -0
- package/dist/cli.js +10775 -10762
- package/dist/types/advisor/runtime.d.ts +1 -1
- package/dist/types/capability/mcp.d.ts +11 -0
- package/dist/types/capability/skill.d.ts +6 -0
- package/dist/types/cli/command-help.d.ts +3 -0
- package/dist/types/commands/share.d.ts +25 -0
- package/dist/types/commit/agentic/index.d.ts +3 -1
- package/dist/types/commit/execute.d.ts +32 -0
- package/dist/types/commit/index.d.ts +2 -1
- package/dist/types/commit/pipeline.d.ts +7 -1
- package/dist/types/config/custom-models.d.ts +31 -0
- package/dist/types/config/model-config-values.d.ts +19 -0
- package/dist/types/config/model-patch.d.ts +93 -0
- package/dist/types/config/model-provider-discovery.d.ts +51 -0
- package/dist/types/config/model-registry.d.ts +9 -52
- package/dist/types/config/settings-schema.d.ts +1 -34
- package/dist/types/config/settings.d.ts +5 -3
- package/dist/types/debug/raw-sse-buffer.d.ts +9 -0
- package/dist/types/discovery/agent-plugin-format.d.ts +136 -0
- package/dist/types/discovery/agent-plugins.d.ts +1 -0
- package/dist/types/discovery/contained-path.d.ts +33 -0
- package/dist/types/discovery/index.d.ts +1 -0
- package/dist/types/eval/executor-base.d.ts +8 -2
- package/dist/types/eval/kernel-session-registry.d.ts +60 -0
- package/dist/types/export/share.d.ts +1 -1
- package/dist/types/extensibility/custom-tools/types.d.ts +2 -2
- package/dist/types/extensibility/extensions/loader.d.ts +7 -0
- package/dist/types/extensibility/extensions/types.d.ts +11 -0
- package/dist/types/extensibility/shared-events.d.ts +3 -2
- package/dist/types/extensibility/skills.d.ts +5 -0
- package/dist/types/lsp/diagnostics.d.ts +96 -0
- package/dist/types/lsp/index.d.ts +7 -128
- package/dist/types/lsp/servers.d.ts +72 -0
- package/dist/types/lsp/tool.d.ts +42 -0
- package/dist/types/lsp/workspace-diagnostics.d.ts +12 -0
- package/dist/types/lsp/writethrough.d.ts +33 -0
- package/dist/types/mcp/transports/header-policy.d.ts +46 -0
- package/dist/types/mcp/types.d.ts +15 -0
- package/dist/types/modes/components/agent-hub-projection.d.ts +2 -7
- package/dist/types/modes/components/agent-hub-renderer.d.ts +0 -7
- package/dist/types/modes/components/agent-hub.d.ts +2 -0
- package/dist/types/modes/components/agent-transcript-viewer.d.ts +2 -0
- package/dist/types/modes/components/chat-transcript-builder.d.ts +2 -0
- package/dist/types/modes/components/custom-editor.d.ts +1 -2
- package/dist/types/modes/components/status-line/types.d.ts +2 -0
- package/dist/types/modes/components/tool-execution.d.ts +2 -0
- package/dist/types/modes/theme/color.d.ts +19 -0
- package/dist/types/modes/theme/loader.d.ts +19 -0
- package/dist/types/modes/theme/schema.d.ts +175 -0
- package/dist/types/modes/theme/symbols.d.ts +28 -0
- package/dist/types/modes/theme/theme-class.d.ts +244 -0
- package/dist/types/modes/theme/theme.d.ts +9 -280
- package/dist/types/modes/theme/tui-adapters.d.ts +13 -0
- package/dist/types/modes/utils/transcript-render-helpers.d.ts +3 -2
- package/dist/types/registry/agent-registry.d.ts +1 -3
- package/dist/types/secrets/index.d.ts +26 -2
- package/dist/types/secrets/message-transform.d.ts +40 -0
- package/dist/types/secrets/obfuscator.d.ts +0 -108
- package/dist/types/secrets/placeholder-scan.d.ts +95 -0
- package/dist/types/secrets/placeholder.d.ts +94 -0
- package/dist/types/secrets/replacement.d.ts +82 -0
- package/dist/types/session/agent-session-events.d.ts +2 -2
- package/dist/types/session/agent-session-types.d.ts +6 -0
- package/dist/types/session/agent-session.d.ts +2 -2
- package/dist/types/session/messages.d.ts +1 -0
- package/dist/types/session/prewalk.d.ts +3 -1
- package/dist/types/session/session-handoff.d.ts +3 -3
- package/dist/types/session/session-manager.d.ts +32 -0
- package/dist/types/session/session-provider-boundary.d.ts +1 -1
- package/dist/types/session/session-tools.d.ts +8 -0
- package/dist/types/session/turn-recovery.d.ts +9 -4
- package/dist/types/slash-commands/builtin-collaboration.d.ts +2 -0
- package/dist/types/slash-commands/builtin-completions.d.ts +36 -0
- package/dist/types/slash-commands/builtin-control.d.ts +2 -0
- package/dist/types/slash-commands/builtin-lifecycle.d.ts +3 -0
- package/dist/types/slash-commands/builtin-marketplace.d.ts +11 -0
- package/dist/types/slash-commands/builtin-modes.d.ts +5 -0
- package/dist/types/slash-commands/builtin-registry.d.ts +1 -1
- package/dist/types/slash-commands/builtin-session.d.ts +2 -0
- package/dist/types/task/index.d.ts +2 -0
- package/dist/types/tools/gh-common.d.ts +69 -0
- package/dist/types/tools/gh-pr-checkout.d.ts +84 -0
- package/dist/types/tools/gh-pr-diff.d.ts +102 -0
- package/dist/types/tools/gh-run-watch.d.ts +78 -0
- package/dist/types/tools/gh-search.d.ts +61 -0
- package/dist/types/tools/gh-types.d.ts +340 -0
- package/dist/types/tools/gh-view.d.ts +88 -0
- package/dist/types/tools/gh.d.ts +4 -201
- package/dist/types/tools/read-archive.d.ts +16 -0
- package/dist/types/tools/read-format.d.ts +104 -0
- package/dist/types/tools/read-path-resolution.d.ts +19 -0
- package/dist/types/tools/read-pdf-images.d.ts +12 -0
- package/dist/types/tools/read-renderer.d.ts +24 -0
- package/dist/types/tools/read-selector.d.ts +27 -0
- package/dist/types/tools/read-sqlite.d.ts +16 -0
- package/dist/types/tools/read-summary.d.ts +19 -0
- package/dist/types/tools/read.d.ts +1 -23
- package/dist/types/tools/shell-tokenize.d.ts +18 -1
- package/dist/types/utils/changelog.d.ts +0 -5
- package/package.json +13 -13
- package/scripts/legacy-pi-virtual-module.ts +4 -1
- package/src/advisor/runtime.ts +12 -7
- package/src/capability/mcp.ts +11 -0
- package/src/capability/skill.ts +6 -0
- package/src/cli/command-help.ts +4 -0
- package/src/cli/gallery-cli.ts +1 -1
- package/src/cli-commands.ts +5 -0
- package/src/commands/commit.ts +16 -3
- package/src/commands/share.ts +71 -0
- package/src/commit/agentic/index.ts +39 -21
- package/src/commit/execute.ts +56 -0
- package/src/commit/index.ts +2 -1
- package/src/commit/pipeline.ts +20 -7
- package/src/config/custom-models.ts +188 -0
- package/src/config/model-config-values.ts +128 -0
- package/src/config/model-discovery.ts +1 -1
- package/src/config/model-patch.ts +252 -0
- package/src/config/model-provider-discovery.ts +132 -0
- package/src/config/model-registry.ts +84 -704
- package/src/config/settings-schema.ts +2 -33
- package/src/config/settings.ts +53 -3
- package/src/debug/raw-sse-buffer.ts +20 -0
- package/src/discovery/agent-plugin-format.ts +551 -0
- package/src/discovery/agent-plugins.ts +341 -0
- package/src/discovery/claude-plugins.ts +21 -5
- package/src/discovery/contained-path.ts +75 -0
- package/src/discovery/helpers.ts +23 -9
- package/src/discovery/index.ts +1 -0
- package/src/discovery/omp-plugins.ts +20 -7
- package/src/edit/hashline/diff.ts +5 -1
- package/src/eval/executor-base.ts +39 -6
- package/src/eval/jl/executor.ts +82 -371
- package/src/eval/kernel-session-registry.ts +398 -0
- package/src/eval/py/executor.ts +53 -261
- package/src/eval/rb/executor.ts +36 -279
- package/src/exec/non-interactive-env.ts +1 -0
- package/src/export/share.ts +2 -1
- package/src/extensibility/custom-tools/types.ts +2 -2
- package/src/extensibility/extensions/loader.ts +78 -14
- package/src/extensibility/extensions/runner.ts +6 -0
- package/src/extensibility/extensions/types.ts +12 -0
- package/src/extensibility/plugins/marketplace/manager.ts +2 -1
- package/src/extensibility/shared-events.ts +3 -2
- package/src/extensibility/skills.ts +9 -0
- package/src/internal-urls/skill-protocol.ts +14 -0
- package/src/internal-urls/vault-protocol.ts +2 -2
- package/src/launch/client.ts +11 -1
- package/src/launch/protocol.ts +7 -2
- package/src/lsp/diagnostics.ts +516 -0
- package/src/lsp/index.ts +20 -2819
- package/src/lsp/servers.ts +296 -0
- package/src/lsp/tool.ts +1352 -0
- package/src/lsp/workspace-diagnostics.ts +170 -0
- package/src/lsp/writethrough.ts +561 -0
- package/src/main.ts +3 -2
- package/src/mcp/config.ts +3 -0
- package/src/mcp/manager.ts +12 -9
- package/src/mcp/transports/header-policy.ts +95 -0
- package/src/mcp/transports/http.ts +35 -52
- package/src/mcp/transports/sse.ts +20 -27
- package/src/mcp/types.ts +15 -0
- package/src/modes/acp/acp-agent.ts +15 -4
- package/src/modes/components/agent-dashboard.ts +2 -0
- package/src/modes/components/agent-hub-projection.ts +2 -2
- package/src/modes/components/agent-hub-renderer.ts +3 -7
- package/src/modes/components/agent-hub.ts +5 -0
- package/src/modes/components/agent-transcript-viewer.ts +3 -0
- package/src/modes/components/chat-transcript-builder.ts +3 -0
- package/src/modes/components/custom-editor.ts +0 -9
- package/src/modes/components/status-line/component.ts +1 -0
- package/src/modes/components/status-line/segments.ts +6 -4
- package/src/modes/components/status-line/types.ts +2 -0
- package/src/modes/components/tool-execution.ts +13 -16
- package/src/modes/components/tree-selector.ts +62 -3
- package/src/modes/controllers/command-controller.ts +8 -2
- package/src/modes/controllers/event-controller.ts +15 -15
- package/src/modes/controllers/input-controller.ts +20 -2
- package/src/modes/controllers/selector-controller.ts +1 -0
- package/src/modes/theme/color.ts +133 -0
- package/src/modes/theme/loader.ts +178 -0
- package/src/modes/theme/schema.ts +263 -0
- package/src/modes/theme/symbols.ts +1000 -0
- package/src/modes/theme/theme-class.ts +611 -0
- package/src/modes/theme/theme.ts +27 -2453
- package/src/modes/theme/tui-adapters.ts +279 -0
- package/src/modes/utils/transcript-render-helpers.ts +4 -2
- package/src/modes/utils/ui-helpers.ts +1 -0
- package/src/registry/agent-registry.ts +2 -2
- package/src/sdk.ts +6 -49
- package/src/secrets/index.ts +51 -6
- package/src/secrets/message-transform.ts +287 -0
- package/src/secrets/obfuscator.ts +39 -1303
- package/src/secrets/placeholder-scan.ts +506 -0
- package/src/secrets/placeholder.ts +309 -0
- package/src/secrets/replacement.ts +216 -0
- package/src/session/agent-session-events.ts +2 -2
- package/src/session/agent-session-types.ts +6 -0
- package/src/session/agent-session.ts +146 -21
- package/src/session/indexed-session-storage.ts +7 -2
- package/src/session/messages.ts +1 -0
- package/src/session/prewalk.ts +57 -17
- package/src/session/session-advisors.ts +32 -34
- package/src/session/session-context.ts +3 -5
- package/src/session/session-handoff.ts +39 -16
- package/src/session/session-manager.ts +67 -3
- package/src/session/session-provider-boundary.ts +3 -6
- package/src/session/session-tools.ts +37 -3
- package/src/session/todo-tracker.ts +11 -1
- package/src/session/turn-recovery.ts +115 -84
- package/src/slash-commands/builtin-collaboration.ts +504 -0
- package/src/slash-commands/builtin-completions.ts +291 -0
- package/src/slash-commands/builtin-control.ts +78 -0
- package/src/slash-commands/builtin-lifecycle.ts +506 -0
- package/src/slash-commands/builtin-marketplace.ts +567 -0
- package/src/slash-commands/builtin-modes.ts +518 -0
- package/src/slash-commands/builtin-registry.ts +21 -2996
- package/src/slash-commands/builtin-session.ts +592 -0
- package/src/task/executor.ts +17 -14
- package/src/task/index.ts +21 -6
- package/src/tools/bash-skill-urls.ts +15 -0
- package/src/tools/bash.ts +10 -11
- package/src/tools/debug.ts +1 -1
- package/src/tools/gh-common.ts +288 -0
- package/src/tools/gh-pr-checkout.ts +679 -0
- package/src/tools/gh-pr-diff.ts +473 -0
- package/src/tools/gh-run-watch.ts +1015 -0
- package/src/tools/gh-search.ts +500 -0
- package/src/tools/gh-types.ts +379 -0
- package/src/tools/gh-view.ts +612 -0
- package/src/tools/gh.ts +109 -3821
- package/src/tools/jtd-to-json-schema.ts +123 -21
- package/src/tools/read-archive.ts +209 -0
- package/src/tools/read-format.ts +593 -0
- package/src/tools/read-path-resolution.ts +36 -0
- package/src/tools/read-pdf-images.ts +250 -0
- package/src/tools/read-renderer.ts +289 -0
- package/src/tools/read-selector.ts +84 -0
- package/src/tools/read-sqlite.ts +215 -0
- package/src/tools/read-summary.ts +199 -0
- package/src/tools/read.ts +82 -1824
- package/src/tools/shell-tokenize.ts +99 -1
- package/src/utils/changelog.ts +1 -1
- package/src/utils/title-generator.ts +3 -1
- package/src/web/search/providers/exa.ts +1 -1
- package/src/web/search/providers/zai.ts +12 -3
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** Resolve symlinks and equivalents; `null` when the path is missing or unresolvable. */
|
|
2
|
+
export declare function realpathIfExists(p: string): Promise<string | null>;
|
|
3
|
+
/** Outcome of resolving a fixed package path without reading it. */
|
|
4
|
+
type ContainedPathResolution = {
|
|
5
|
+
status: "missing";
|
|
6
|
+
} | {
|
|
7
|
+
status: "outside";
|
|
8
|
+
} | {
|
|
9
|
+
status: "ok";
|
|
10
|
+
realPath: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Resolve a fixed package path WITHOUT reading it: symlinks and equivalent
|
|
14
|
+
* mechanisms are resolved first, and a path escaping the filesystem-resolved
|
|
15
|
+
* plugin root is rejected before any I/O could consume outside content.
|
|
16
|
+
*/
|
|
17
|
+
export declare function resolveContainedPath(realBase: string, target: string): Promise<ContainedPathResolution>;
|
|
18
|
+
/**
|
|
19
|
+
* Verify a package path stays within the filesystem-resolved plugin root:
|
|
20
|
+
* lexically, and — when the target exists — after resolving symlinks. Unlike
|
|
21
|
+
* {@link resolveContainedPath}, a missing target passes. ONLY for configured
|
|
22
|
+
* paths that are validated but never read or executed at load time (stdio
|
|
23
|
+
* `command`, `cwd` — including `${PLUGIN_DATA}` paths created after
|
|
24
|
+
* validation); access paths MUST use {@link resolveContainedPath} instead,
|
|
25
|
+
* which fails closed on unresolvable targets.
|
|
26
|
+
*/
|
|
27
|
+
export declare function isContainedResolved(realBase: string, target: string): Promise<boolean>;
|
|
28
|
+
/**
|
|
29
|
+
* Sync variant of {@link resolveContainedPath} for synchronous callsites
|
|
30
|
+
* (bash `skill://` expansion).
|
|
31
|
+
*/
|
|
32
|
+
export declare function resolveContainedPathSync(realBase: string, target: string): ContainedPathResolution;
|
|
33
|
+
export {};
|
|
@@ -18,6 +18,7 @@ import "../capability/slash-command.js";
|
|
|
18
18
|
import "../capability/ssh.js";
|
|
19
19
|
import "../capability/system-prompt.js";
|
|
20
20
|
import "../capability/tool.js";
|
|
21
|
+
import "./agent-plugins.js";
|
|
21
22
|
import "./agents-md.js";
|
|
22
23
|
import "./builtin.js";
|
|
23
24
|
import "./builtin-defaults.js";
|
|
@@ -71,7 +71,7 @@ export declare function isTimedOutCancellation(error: unknown, cancelledErrorCla
|
|
|
71
71
|
export declare function waitForPromiseWithCancellation<T>(promise: Promise<T>, options: {
|
|
72
72
|
signal?: AbortSignal;
|
|
73
73
|
deadlineMs?: number;
|
|
74
|
-
}, cancelledErrorClass: CancelledErrorClass): Promise<T>;
|
|
74
|
+
}, cancelledErrorClass: CancelledErrorClass, timedOutResolver?: (error: unknown, signal?: AbortSignal) => boolean): Promise<T>;
|
|
75
75
|
export declare function createCancelledKernelResult(output: string): KernelExecutionResult;
|
|
76
76
|
export declare const MANAGED_KERNEL_ENV_KEYS: readonly ["PI_SESSION_FILE", "PI_ARTIFACTS_DIR", "PI_TOOL_BRIDGE_URL", "PI_TOOL_BRIDGE_TOKEN", "PI_TOOL_BRIDGE_SESSION", "PI_EVAL_LOCAL_ROOTS"];
|
|
77
77
|
interface ManagedKernelEnvOptions {
|
|
@@ -84,8 +84,14 @@ interface ManagedKernelEnvOptions {
|
|
|
84
84
|
};
|
|
85
85
|
localRoots?: Record<string, string>;
|
|
86
86
|
}
|
|
87
|
+
interface ManagedKernelEnvPolicy {
|
|
88
|
+
sparse?: boolean;
|
|
89
|
+
}
|
|
87
90
|
export declare function buildManagedKernelEnvPatch(options: ManagedKernelEnvOptions): Record<string, string | null>;
|
|
88
|
-
export declare function
|
|
91
|
+
export declare function buildManagedKernelEnvPatch(options: ManagedKernelEnvOptions, policy: {
|
|
92
|
+
sparse: true;
|
|
93
|
+
}): Record<string, string | undefined>;
|
|
94
|
+
export declare function buildManagedKernelEnv(options: ManagedKernelEnvOptions, policy?: ManagedKernelEnvPolicy): Record<string, string> | undefined;
|
|
89
95
|
export declare function attachSessionOwner(session: {
|
|
90
96
|
ownerIds: Set<string>;
|
|
91
97
|
hasFallbackOwner: boolean;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { type CancelledErrorClass, type SessionOwners } from "./executor-base.js";
|
|
2
|
+
interface KernelSessionRegistryOptions {
|
|
3
|
+
sessionId?: string;
|
|
4
|
+
kernelOwnerId?: string;
|
|
5
|
+
interpreter?: string;
|
|
6
|
+
reset?: boolean;
|
|
7
|
+
signal?: AbortSignal;
|
|
8
|
+
deadlineMs?: number;
|
|
9
|
+
bridge?: unknown;
|
|
10
|
+
bridgeSessionId?: string;
|
|
11
|
+
}
|
|
12
|
+
interface RegistryKernelShutdownResult {
|
|
13
|
+
confirmed?: boolean;
|
|
14
|
+
}
|
|
15
|
+
interface RegistryKernel {
|
|
16
|
+
isAlive(): boolean;
|
|
17
|
+
shutdown(options?: {
|
|
18
|
+
timeoutMs: number;
|
|
19
|
+
}): Promise<RegistryKernelShutdownResult>;
|
|
20
|
+
}
|
|
21
|
+
export interface KernelSession<TKernel extends RegistryKernel> extends SessionOwners {
|
|
22
|
+
sessionKey: string;
|
|
23
|
+
sessionId: string;
|
|
24
|
+
cwd: string;
|
|
25
|
+
kernel: TKernel;
|
|
26
|
+
}
|
|
27
|
+
export interface KernelSessionRegistryContext<TKernel extends RegistryKernel, TOptions extends KernelSessionRegistryOptions, TSession extends KernelSession<TKernel>> {
|
|
28
|
+
sessions: Map<string, TSession>;
|
|
29
|
+
startKernel: (cwd: string, options: TOptions) => Promise<TKernel>;
|
|
30
|
+
replaceSessionKernel: (session: TSession, cwd: string, options: TOptions) => Promise<TKernel>;
|
|
31
|
+
}
|
|
32
|
+
interface KernelSessionRegistryDescriptor<TKernel extends RegistryKernel, TOptions extends KernelSessionRegistryOptions, TResult, TSession extends KernelSession<TKernel>> {
|
|
33
|
+
languageLabel: string;
|
|
34
|
+
cancelledErrorClass: CancelledErrorClass;
|
|
35
|
+
buildSessionKey: (sessionId: string, cwd: string, interpreter: string | undefined) => string;
|
|
36
|
+
createSession: (session: KernelSession<TKernel>) => TSession;
|
|
37
|
+
startKernel: (cwd: string, options: TOptions) => Promise<TKernel>;
|
|
38
|
+
executeWithKernel: (kernel: TKernel, code: string, options: TOptions) => Promise<TResult>;
|
|
39
|
+
waitForStartup?: (promise: Promise<TSession>, options: TOptions) => Promise<TSession>;
|
|
40
|
+
replaceSessionKernel?: (session: TSession, cwd: string, options: TOptions, context: KernelSessionRegistryContext<TKernel, TOptions, TSession>) => Promise<TKernel>;
|
|
41
|
+
acquireLiveSessionKernel?: (session: TSession, cwd: string, options: TOptions, context: KernelSessionRegistryContext<TKernel, TOptions, TSession>) => Promise<TKernel>;
|
|
42
|
+
invalidateSession?: (session: TSession) => void;
|
|
43
|
+
shutdownSession?: (session: TSession, resetting: boolean) => Promise<RegistryKernelShutdownResult>;
|
|
44
|
+
clearResetsOnDisposeAll?: boolean;
|
|
45
|
+
logBeforeReplacement?: boolean;
|
|
46
|
+
isCancellation?: (error: unknown) => boolean;
|
|
47
|
+
isTimedOutCancellation?: (error: unknown, signal?: AbortSignal) => boolean;
|
|
48
|
+
validateKernel?: (session: TSession, kernel: TKernel) => boolean;
|
|
49
|
+
}
|
|
50
|
+
interface KernelSessionRegistry<TOptions extends KernelSessionRegistryOptions, TResult> {
|
|
51
|
+
disposeAll(): Promise<void>;
|
|
52
|
+
disposeByOwner(ownerId: string): Promise<void>;
|
|
53
|
+
executeOnSession(code: string, cwd: string, options: TOptions): Promise<TResult>;
|
|
54
|
+
}
|
|
55
|
+
export declare function normalizeKernelSessionCwd(cwd: string): string;
|
|
56
|
+
export declare function requireRemainingKernelTimeoutMs(deadlineMs: number | undefined, cancelledErrorClass: CancelledErrorClass): number | undefined;
|
|
57
|
+
export declare function formatSessionTimeoutAnnotation(timeoutMs?: number): string;
|
|
58
|
+
export declare function formatSessionKernelTimeoutAnnotation(timeoutMs: number | undefined, kernelKilled: boolean): string;
|
|
59
|
+
export declare function createKernelSessionRegistry<TKernel extends RegistryKernel, TOptions extends KernelSessionRegistryOptions, TResult, TSession extends KernelSession<TKernel>>(descriptor: KernelSessionRegistryDescriptor<TKernel, TOptions, TResult, TSession>): KernelSessionRegistry<TOptions, TResult>;
|
|
60
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AgentState } from "@oh-my-pi/pi-agent-core";
|
|
2
2
|
import { DEFAULT_SHARE_URL } from "@oh-my-pi/pi-wire";
|
|
3
|
-
import {
|
|
3
|
+
import type { SecretObfuscator } from "../secrets/obfuscator.js";
|
|
4
4
|
import type { SessionManager } from "../session/session-manager.js";
|
|
5
5
|
import { type SessionData } from "./html/index.js";
|
|
6
6
|
export { DEFAULT_SHARE_URL };
|
|
@@ -22,7 +22,7 @@ import type { LocalProtocolOptions } from "../../internal-urls/local-protocol.js
|
|
|
22
22
|
import type { Theme } from "../../modes/theme/theme.js";
|
|
23
23
|
import type { ReadonlySessionManager } from "../../session/session-manager.js";
|
|
24
24
|
import type { TodoItem } from "../../tools/todo.js";
|
|
25
|
-
import type {
|
|
25
|
+
import type { RetryErrorUpdate } from "../shared-events.js";
|
|
26
26
|
/** Alias for clarity */
|
|
27
27
|
export type CustomToolUIContext = HookUIContext;
|
|
28
28
|
export type { ExecOptions, ExecResult } from "../../exec/exec.js";
|
|
@@ -119,7 +119,7 @@ export type CustomToolSessionEvent = {
|
|
|
119
119
|
success: boolean;
|
|
120
120
|
attempt: number;
|
|
121
121
|
finalError?: string;
|
|
122
|
-
|
|
122
|
+
retryErrors?: RetryErrorUpdate[];
|
|
123
123
|
} | {
|
|
124
124
|
reason: "ttsr_triggered";
|
|
125
125
|
rules: Rule[];
|
|
@@ -16,6 +16,8 @@ export declare class ExtensionRuntime implements IExtensionRuntime {
|
|
|
16
16
|
config: ProviderConfig;
|
|
17
17
|
sourceId: string;
|
|
18
18
|
}>;
|
|
19
|
+
registerProvider(name: string, config: ProviderConfig, sourceId: string): void;
|
|
20
|
+
unregisterProvider(name: string): void;
|
|
19
21
|
sendMessage(): void;
|
|
20
22
|
sendUserMessage(): void;
|
|
21
23
|
appendEntry(): void;
|
|
@@ -38,6 +40,11 @@ export declare class ExtensionRuntime implements IExtensionRuntime {
|
|
|
38
40
|
export declare function loadExtensionFromFactory(factory: ExtensionFactory, cwd: string, eventBus: EventBus, runtime: IExtensionRuntime, name?: string): Promise<Extension>;
|
|
39
41
|
/**
|
|
40
42
|
* Load extensions from paths.
|
|
43
|
+
*
|
|
44
|
+
* Module import (the dominant cold-start cost — file I/O plus module
|
|
45
|
+
* evaluation) runs concurrently across extensions; factory binding then runs
|
|
46
|
+
* sequentially in the original path order, so registration semantics
|
|
47
|
+
* (last-wins collisions, shared runtime flag defaults) stay deterministic.
|
|
41
48
|
*/
|
|
42
49
|
export declare function loadExtensions(paths: string[], cwd: string, eventBus?: EventBus): Promise<LoadExtensionsResult>;
|
|
43
50
|
/**
|
|
@@ -918,6 +918,13 @@ export interface ExtensionAPI {
|
|
|
918
918
|
* });
|
|
919
919
|
*/
|
|
920
920
|
registerProvider(name: string, config: ProviderConfig): void;
|
|
921
|
+
/**
|
|
922
|
+
* Unregister a provider previously registered by an extension.
|
|
923
|
+
*
|
|
924
|
+
* Removes extension-provided models and restores overridden built-in models.
|
|
925
|
+
* Has no effect when the provider is not registered.
|
|
926
|
+
*/
|
|
927
|
+
unregisterProvider(name: string): void;
|
|
921
928
|
/** Shared event bus for extension communication. */
|
|
922
929
|
events: EventBus;
|
|
923
930
|
}
|
|
@@ -1042,6 +1049,10 @@ export interface ExtensionRuntimeState {
|
|
|
1042
1049
|
config: ProviderConfig;
|
|
1043
1050
|
sourceId: string;
|
|
1044
1051
|
}>;
|
|
1052
|
+
/** Queue a provider registration until initialization, then apply it immediately. */
|
|
1053
|
+
registerProvider(name: string, config: ProviderConfig, sourceId: string): void;
|
|
1054
|
+
/** Remove a queued or initialized provider registration. */
|
|
1055
|
+
unregisterProvider(name: string, sourceId: string): void;
|
|
1045
1056
|
}
|
|
1046
1057
|
/** Action implementations for ExtensionAPI methods. */
|
|
1047
1058
|
export interface ExtensionActions {
|
|
@@ -200,7 +200,8 @@ export interface AutoRetryStartEvent {
|
|
|
200
200
|
errorMessage: string;
|
|
201
201
|
errorId?: number;
|
|
202
202
|
}
|
|
203
|
-
|
|
203
|
+
/** Persisted retry error whose transcript presentation changed when the retry saga settled. */
|
|
204
|
+
export interface RetryErrorUpdate {
|
|
204
205
|
entryId: string;
|
|
205
206
|
persistenceKey?: string;
|
|
206
207
|
note: string;
|
|
@@ -212,7 +213,7 @@ export interface AutoRetryEndEvent {
|
|
|
212
213
|
success: boolean;
|
|
213
214
|
attempt: number;
|
|
214
215
|
finalError?: string;
|
|
215
|
-
|
|
216
|
+
retryErrors?: RetryErrorUpdate[];
|
|
216
217
|
}
|
|
217
218
|
/** Fired when TTSR rule matching interrupts generation */
|
|
218
219
|
export interface TtsrTriggeredEvent {
|
|
@@ -13,6 +13,11 @@ export interface Skill {
|
|
|
13
13
|
* prompt's `<skills>` listing.
|
|
14
14
|
*/
|
|
15
15
|
hide?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Filesystem-resolved plugin root for Agent Plugin skills (spec §4.1):
|
|
18
|
+
* every `skill://` resource access must realpath-resolve within it.
|
|
19
|
+
*/
|
|
20
|
+
containRoot?: string;
|
|
16
21
|
/** Source metadata for display */
|
|
17
22
|
_source?: SourceMeta;
|
|
18
23
|
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { Diagnostic, Location, LocationLink, LspClient, Position, ServerConfig } from "./types.js";
|
|
2
|
+
export declare const SINGLE_DIAGNOSTICS_WAIT_TIMEOUT_MS = 3000;
|
|
3
|
+
export declare const BATCH_DIAGNOSTICS_WAIT_TIMEOUT_MS = 400;
|
|
4
|
+
/**
|
|
5
|
+
* How long the edit/write writethrough blocks inline waiting for fresh
|
|
6
|
+
* diagnostics before handing slow servers off to the deferred late-injection
|
|
7
|
+
* channel. Keeps the common fast-server case inline while letting an edit
|
|
8
|
+
* return promptly when a server (e.g. a large-monorepo tsserver) is slow to
|
|
9
|
+
* publish fresh diagnostics.
|
|
10
|
+
*/
|
|
11
|
+
export declare const INLINE_DIAGNOSTICS_WAIT_TIMEOUT_MS = 500;
|
|
12
|
+
/**
|
|
13
|
+
* Inner per-server diagnostics wait budget for the background/deferred fetch.
|
|
14
|
+
* Longer than the inline cap (and the old 3s default) so a slow server still
|
|
15
|
+
* delivers late instead of giving up before it ever publishes.
|
|
16
|
+
*/
|
|
17
|
+
export declare const DEFERRED_DIAGNOSTICS_WAIT_TIMEOUT_MS = 12000;
|
|
18
|
+
export declare const MAX_GLOB_DIAGNOSTIC_TARGETS = 20;
|
|
19
|
+
export declare const WORKSPACE_SYMBOL_LIMIT = 200;
|
|
20
|
+
export declare const PROJECT_INDEXED_ACTIONS: ReadonlySet<string>;
|
|
21
|
+
export declare function hasRustWorkspaceAncestor(filePath: string): boolean;
|
|
22
|
+
export declare function limitDiagnosticMessages(messages: string[]): string[];
|
|
23
|
+
export declare const REFERENCE_CONTEXT_LIMIT = 50;
|
|
24
|
+
export declare const REFERENCES_RETRY_COUNT = 2;
|
|
25
|
+
export declare const REFERENCES_RETRY_DELAY_MS = 250;
|
|
26
|
+
export declare function isOnlyQueriedDeclaration(locations: Location[], uri: string, position: Position): boolean;
|
|
27
|
+
export declare function normalizeLocationResult(result: Location | Location[] | LocationLink | LocationLink[] | null): Location[];
|
|
28
|
+
export declare function formatLocationWithContext(location: Location, cwd: string): Promise<string>;
|
|
29
|
+
interface WaitForDiagnosticsOptions {
|
|
30
|
+
timeoutMs?: number;
|
|
31
|
+
signal?: AbortSignal;
|
|
32
|
+
minVersion?: number;
|
|
33
|
+
expectedDocumentVersion?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Quiescence window (ms). typescript-language-server never echoes the document
|
|
36
|
+
* version (issue #983) and emits diagnostics from several sources at different
|
|
37
|
+
* times, so there is no single "complete, version-matched" publish to gate on.
|
|
38
|
+
* When the server does not exact-version-match, accept the latest publish only
|
|
39
|
+
* after no newer one has arrived for this long, letting an in-flight pre-edit
|
|
40
|
+
* publish be superseded by the fresh one.
|
|
41
|
+
*/
|
|
42
|
+
settleMs?: number;
|
|
43
|
+
}
|
|
44
|
+
export declare function waitForDiagnostics(client: LspClient, uri: string, options?: WaitForDiagnosticsOptions): Promise<Diagnostic[]>;
|
|
45
|
+
/** Result from getDiagnosticsForFile */
|
|
46
|
+
export interface FileDiagnosticsResult {
|
|
47
|
+
/** Name of the LSP server used (if available) */
|
|
48
|
+
server?: string;
|
|
49
|
+
/** Formatted diagnostic messages */
|
|
50
|
+
messages: string[];
|
|
51
|
+
/** Summary string (e.g., "2 error(s), 1 warning(s)") */
|
|
52
|
+
summary: string;
|
|
53
|
+
/** Whether there are any errors (severity 1) */
|
|
54
|
+
errored: boolean;
|
|
55
|
+
/** Whether the file was formatted */
|
|
56
|
+
formatter?: FileFormatResult;
|
|
57
|
+
}
|
|
58
|
+
export type ServerVersionMap = Map<string, number>;
|
|
59
|
+
interface GetDiagnosticsForFileOptions {
|
|
60
|
+
signal?: AbortSignal;
|
|
61
|
+
minVersions?: ServerVersionMap;
|
|
62
|
+
expectedDocumentVersions?: ServerVersionMap;
|
|
63
|
+
/** Per-server wait budget (ms). Defaults to {@link SINGLE_DIAGNOSTICS_WAIT_TIMEOUT_MS}. */
|
|
64
|
+
timeoutMs?: number;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Capture current diagnostic versions for all LSP servers.
|
|
68
|
+
* Call this BEFORE syncing content to detect stale diagnostics later.
|
|
69
|
+
*/
|
|
70
|
+
export declare function captureDiagnosticVersions(cwd: string, servers: Array<[string, ServerConfig]>, initTimeoutMs?: number, signal?: AbortSignal): Promise<ServerVersionMap>;
|
|
71
|
+
export declare function captureOpenFileVersions(absolutePath: string, cwd: string, servers: Array<[string, ServerConfig]>, signal?: AbortSignal): Promise<ServerVersionMap>;
|
|
72
|
+
/**
|
|
73
|
+
* Get diagnostics for a file using LSP or custom linter client.
|
|
74
|
+
*
|
|
75
|
+
* @param absolutePath - Absolute path to the file
|
|
76
|
+
* @param cwd - Working directory for LSP config resolution
|
|
77
|
+
* @param servers - Servers to query diagnostics for
|
|
78
|
+
* @param minVersions - Minimum diagnostic versions per server (to detect stale results)
|
|
79
|
+
* @returns Diagnostic results or undefined if no servers
|
|
80
|
+
*/
|
|
81
|
+
export declare function getDiagnosticsForFile(absolutePath: string, cwd: string, servers: Array<[string, ServerConfig]>, options?: GetDiagnosticsForFileOptions): Promise<FileDiagnosticsResult | undefined>;
|
|
82
|
+
export declare enum FileFormatResult {
|
|
83
|
+
UNCHANGED = "unchanged",
|
|
84
|
+
FORMATTED = "formatted"
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Format content using LSP or custom linter client.
|
|
88
|
+
*
|
|
89
|
+
* @param absolutePath - Absolute path (for URI)
|
|
90
|
+
* @param content - Content to format
|
|
91
|
+
* @param cwd - Working directory for LSP config resolution
|
|
92
|
+
* @param servers - Servers to try formatting with
|
|
93
|
+
* @returns Formatted content, or original if no formatter available
|
|
94
|
+
*/
|
|
95
|
+
export declare function formatContent(absolutePath: string, content: string, cwd: string, servers: Array<[string, ServerConfig]>, signal?: AbortSignal): Promise<string>;
|
|
96
|
+
export {};
|
|
@@ -1,130 +1,9 @@
|
|
|
1
|
-
import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback, ToolApprovalDecision } from "@oh-my-pi/pi-agent-core";
|
|
2
|
-
import type { BunFile } from "bun";
|
|
3
|
-
import { type Theme } from "../modes/theme/theme.js";
|
|
4
|
-
import type { ToolSession } from "../tools/index.js";
|
|
5
|
-
import { type LspServerStatus } from "./client.js";
|
|
6
|
-
import { type LspParams, type LspToolDetails, lspSchema } from "./types.js";
|
|
7
1
|
export type { LspServerStatus } from "./client.js";
|
|
2
|
+
export type { FileDiagnosticsResult } from "./diagnostics.js";
|
|
3
|
+
export { FileFormatResult } from "./diagnostics.js";
|
|
4
|
+
export type { LspStartupServerInfo, LspWarmupOptions, LspWarmupResult } from "./servers.js";
|
|
5
|
+
export { discoverStartupLspServers, getLspStatus, LSP_READONLY_ACTIONS, warmupLspServers, } from "./servers.js";
|
|
6
|
+
export { LspTool } from "./tool.js";
|
|
8
7
|
export type { LspToolDetails } from "./types.js";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* Anything not in this set (rename, code_actions with apply, rename_file,
|
|
12
|
-
* reload, raw request, etc.) is classified as write-tier.
|
|
13
|
-
*/
|
|
14
|
-
export declare const LSP_READONLY_ACTIONS: ReadonlySet<string>;
|
|
15
|
-
export interface LspStartupServerInfo {
|
|
16
|
-
name: string;
|
|
17
|
-
status: "connecting" | "ready" | "error" | "available";
|
|
18
|
-
fileTypes: string[];
|
|
19
|
-
error?: string;
|
|
20
|
-
}
|
|
21
|
-
/** Result from warming up LSP servers */
|
|
22
|
-
export interface LspWarmupResult {
|
|
23
|
-
servers: Array<LspStartupServerInfo & {
|
|
24
|
-
status: "ready" | "error";
|
|
25
|
-
}>;
|
|
26
|
-
}
|
|
27
|
-
/** Options for warming up LSP servers */
|
|
28
|
-
export interface LspWarmupOptions {
|
|
29
|
-
/** Called when starting to connect to servers */
|
|
30
|
-
onConnecting?: (serverNames: string[]) => void;
|
|
31
|
-
}
|
|
32
|
-
export declare function discoverStartupLspServers(cwd: string, status?: LspStartupServerInfo["status"]): LspStartupServerInfo[];
|
|
33
|
-
/**
|
|
34
|
-
* Warm up LSP servers for a directory by connecting to all detected servers.
|
|
35
|
-
* This should be called at startup to avoid cold-start delays.
|
|
36
|
-
*
|
|
37
|
-
* @param cwd - Working directory to detect and start servers for
|
|
38
|
-
* @param options - Optional callbacks for progress reporting
|
|
39
|
-
* @returns Status of each server that was started
|
|
40
|
-
*/
|
|
41
|
-
export declare function warmupLspServers(cwd: string, options?: LspWarmupOptions): Promise<LspWarmupResult>;
|
|
42
|
-
/**
|
|
43
|
-
* Get status of currently active LSP servers.
|
|
44
|
-
*/
|
|
45
|
-
export declare function getLspStatus(): LspServerStatus[];
|
|
46
|
-
/** Result from getDiagnosticsForFile */
|
|
47
|
-
export interface FileDiagnosticsResult {
|
|
48
|
-
/** Name of the LSP server used (if available) */
|
|
49
|
-
server?: string;
|
|
50
|
-
/** Formatted diagnostic messages */
|
|
51
|
-
messages: string[];
|
|
52
|
-
/** Summary string (e.g., "2 error(s), 1 warning(s)") */
|
|
53
|
-
summary: string;
|
|
54
|
-
/** Whether there are any errors (severity 1) */
|
|
55
|
-
errored: boolean;
|
|
56
|
-
/** Whether the file was formatted */
|
|
57
|
-
formatter?: FileFormatResult;
|
|
58
|
-
}
|
|
59
|
-
export declare enum FileFormatResult {
|
|
60
|
-
UNCHANGED = "unchanged",
|
|
61
|
-
FORMATTED = "formatted"
|
|
62
|
-
}
|
|
63
|
-
/** Options for creating the LSP writethrough callback */
|
|
64
|
-
export interface WritethroughOptions {
|
|
65
|
-
/** Whether to format the file using LSP after writing */
|
|
66
|
-
enableFormat?: boolean;
|
|
67
|
-
/** Whether to get LSP diagnostics after writing */
|
|
68
|
-
enableDiagnostics?: boolean;
|
|
69
|
-
/** Called when diagnostics arrive after the main timeout. */
|
|
70
|
-
onDeferredDiagnostics?: (diagnostics: FileDiagnosticsResult) => void;
|
|
71
|
-
/** Signal to cancel a pending deferred diagnostics fetch. */
|
|
72
|
-
deferredSignal?: AbortSignal;
|
|
73
|
-
/** Transform diagnostics before surfacing them after a successful fetch. */
|
|
74
|
-
transformDiagnostics?: (absPath: string, result: FileDiagnosticsResult) => FileDiagnosticsResult;
|
|
75
|
-
}
|
|
76
|
-
/** Per-file deferred LSP diagnostics wiring for {@link WritethroughCallback}. */
|
|
77
|
-
export type WritethroughDeferredHandle = {
|
|
78
|
-
onDeferredDiagnostics: (diagnostics: FileDiagnosticsResult) => void;
|
|
79
|
-
signal: AbortSignal;
|
|
80
|
-
finalize: (diagnostics: FileDiagnosticsResult | undefined) => void;
|
|
81
|
-
};
|
|
82
|
-
/** Callback type for the LSP writethrough */
|
|
83
|
-
export type WritethroughCallback = (dst: string, content: string, signal?: AbortSignal, file?: BunFile, batch?: LspWritethroughBatchRequest, getDeferred?: (dst: string) => WritethroughDeferredHandle | undefined) => Promise<FileDiagnosticsResult | undefined>;
|
|
84
|
-
/** No-op writethrough callback */
|
|
85
|
-
export declare function writethroughNoop(dst: string, content: string, _signal?: AbortSignal, file?: BunFile, _batch?: LspWritethroughBatchRequest, _getDeferred?: (dst: string) => WritethroughDeferredHandle | undefined): Promise<FileDiagnosticsResult | undefined>;
|
|
86
|
-
interface LspWritethroughBatchRequest {
|
|
87
|
-
id: string;
|
|
88
|
-
flush: boolean;
|
|
89
|
-
}
|
|
90
|
-
export declare function flushLspWritethroughBatch(id: string, cwd: string, signal?: AbortSignal): Promise<FileDiagnosticsResult | undefined>;
|
|
91
|
-
/** Create a writethrough callback for LSP aware write operations */
|
|
92
|
-
export declare function createLspWritethrough(cwd: string, options?: WritethroughOptions): WritethroughCallback;
|
|
93
|
-
/**
|
|
94
|
-
* LSP tool for language server protocol operations.
|
|
95
|
-
*/
|
|
96
|
-
export declare class LspTool implements AgentTool<typeof lspSchema, LspToolDetails, Theme> {
|
|
97
|
-
private readonly session;
|
|
98
|
-
readonly name = "lsp";
|
|
99
|
-
readonly approval: (args: unknown) => ToolApprovalDecision;
|
|
100
|
-
readonly formatApprovalDetails: (args: unknown) => string[];
|
|
101
|
-
readonly label = "LSP";
|
|
102
|
-
readonly loadMode = "discoverable";
|
|
103
|
-
readonly summary = "Query LSP (language server) for diagnostics, hover info, and references";
|
|
104
|
-
readonly description: string;
|
|
105
|
-
readonly parameters: import("@oh-my-pi/omptype").FluentType<{
|
|
106
|
-
action: "capabilities" | "code_actions" | "definition" | "diagnostics" | "hover" | "implementation" | "references" | "reload" | "rename" | "rename_file" | "request" | "status" | "symbols" | "type_definition";
|
|
107
|
-
apply?: boolean | undefined;
|
|
108
|
-
file?: string | undefined;
|
|
109
|
-
line?: number | undefined;
|
|
110
|
-
new_name?: string | undefined;
|
|
111
|
-
payload?: string | undefined;
|
|
112
|
-
query?: string | undefined;
|
|
113
|
-
symbol?: string | undefined;
|
|
114
|
-
timeout?: number | undefined;
|
|
115
|
-
}, {
|
|
116
|
-
action: "capabilities" | "code_actions" | "definition" | "diagnostics" | "hover" | "implementation" | "references" | "reload" | "rename" | "rename_file" | "request" | "status" | "symbols" | "type_definition";
|
|
117
|
-
apply?: boolean | undefined;
|
|
118
|
-
file?: string | undefined;
|
|
119
|
-
line?: number | undefined;
|
|
120
|
-
new_name?: string | undefined;
|
|
121
|
-
payload?: string | undefined;
|
|
122
|
-
query?: string | undefined;
|
|
123
|
-
symbol?: string | undefined;
|
|
124
|
-
timeout?: number | undefined;
|
|
125
|
-
}>;
|
|
126
|
-
readonly strict = true;
|
|
127
|
-
constructor(session: ToolSession);
|
|
128
|
-
static createIf(session: ToolSession): LspTool | null;
|
|
129
|
-
execute(_toolCallId: string, params: LspParams, signal?: AbortSignal, _onUpdate?: AgentToolUpdateCallback<LspToolDetails>, _context?: AgentToolContext): Promise<AgentToolResult<LspToolDetails>>;
|
|
130
|
-
}
|
|
8
|
+
export type { WritethroughCallback, WritethroughDeferredHandle, WritethroughOptions, } from "./writethrough.js";
|
|
9
|
+
export { createLspWritethrough, flushLspWritethroughBatch, writethroughNoop, } from "./writethrough.js";
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { type LspServerStatus } from "./client.js";
|
|
2
|
+
import { type LspConfig } from "./config.js";
|
|
3
|
+
import type { LspClient, ServerConfig } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* LSP actions that do not mutate the workspace or language-server state.
|
|
6
|
+
* Anything not in this set (rename, code_actions with apply, rename_file,
|
|
7
|
+
* reload, raw request, etc.) is classified as write-tier.
|
|
8
|
+
*/
|
|
9
|
+
export declare const LSP_READONLY_ACTIONS: ReadonlySet<string>;
|
|
10
|
+
export interface LspStartupServerInfo {
|
|
11
|
+
name: string;
|
|
12
|
+
status: "connecting" | "ready" | "error" | "available";
|
|
13
|
+
fileTypes: string[];
|
|
14
|
+
error?: string;
|
|
15
|
+
}
|
|
16
|
+
/** Result from warming up LSP servers */
|
|
17
|
+
export interface LspWarmupResult {
|
|
18
|
+
servers: Array<LspStartupServerInfo & {
|
|
19
|
+
status: "ready" | "error";
|
|
20
|
+
}>;
|
|
21
|
+
}
|
|
22
|
+
/** Options for warming up LSP servers */
|
|
23
|
+
export interface LspWarmupOptions {
|
|
24
|
+
/** Called when starting to connect to servers */
|
|
25
|
+
onConnecting?: (serverNames: string[]) => void;
|
|
26
|
+
}
|
|
27
|
+
export declare function discoverStartupLspServers(cwd: string, status?: LspStartupServerInfo["status"]): LspStartupServerInfo[];
|
|
28
|
+
/**
|
|
29
|
+
* Warm up LSP servers for a directory by connecting to all detected servers.
|
|
30
|
+
* This should be called at startup to avoid cold-start delays.
|
|
31
|
+
*
|
|
32
|
+
* @param cwd - Working directory to detect and start servers for
|
|
33
|
+
* @param options - Optional callbacks for progress reporting
|
|
34
|
+
* @returns Status of each server that was started
|
|
35
|
+
*/
|
|
36
|
+
export declare function warmupLspServers(cwd: string, options?: LspWarmupOptions): Promise<LspWarmupResult>;
|
|
37
|
+
/**
|
|
38
|
+
* Get status of currently active LSP servers.
|
|
39
|
+
*/
|
|
40
|
+
export declare function getLspStatus(): LspServerStatus[];
|
|
41
|
+
/**
|
|
42
|
+
* Sync in-memory file content to all applicable LSP servers.
|
|
43
|
+
* Sends didOpen (if new) or didChange (if already open).
|
|
44
|
+
*
|
|
45
|
+
* @param absolutePath - Absolute path to the file
|
|
46
|
+
* @param content - The new file content
|
|
47
|
+
* @param cwd - Working directory for LSP config resolution
|
|
48
|
+
* @param servers - Servers to sync to
|
|
49
|
+
*/
|
|
50
|
+
export declare function syncFileContent(absolutePath: string, content: string, cwd: string, servers: Array<[string, ServerConfig]>, signal?: AbortSignal, createMissing?: boolean): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Notify all LSP servers that a file was saved.
|
|
53
|
+
* Assumes content was already synced via syncFileContent.
|
|
54
|
+
*
|
|
55
|
+
* @param absolutePath - Absolute path to the file
|
|
56
|
+
* @param cwd - Working directory for LSP config resolution
|
|
57
|
+
* @param servers - Servers to notify
|
|
58
|
+
*/
|
|
59
|
+
export declare function notifyFileSaved(absolutePath: string, cwd: string, servers: Array<[string, ServerConfig]>, signal?: AbortSignal, createMissing?: boolean): Promise<void>;
|
|
60
|
+
export declare const configCache: Map<string, LspConfig>;
|
|
61
|
+
export declare function getConfig(cwd: string): LspConfig;
|
|
62
|
+
export declare function splitServers(servers: Array<[string, ServerConfig]>): {
|
|
63
|
+
lspServers: Array<[string, ServerConfig]>;
|
|
64
|
+
customLinterServers: Array<[string, ServerConfig]>;
|
|
65
|
+
};
|
|
66
|
+
export declare function getLspServers(config: LspConfig): Array<[string, ServerConfig]>;
|
|
67
|
+
export declare function getLspServersForFile(config: LspConfig, filePath: string): Array<[string, ServerConfig]>;
|
|
68
|
+
export declare function getLspServerForFile(config: LspConfig, filePath: string): [string, ServerConfig] | null;
|
|
69
|
+
export declare function isProjectAwareLspServer(serverConfig: ServerConfig): boolean;
|
|
70
|
+
/** True when an LSP error indicates the server doesn't implement the requested method. */
|
|
71
|
+
export declare function isMethodNotFoundError(err: unknown): boolean;
|
|
72
|
+
export declare function reloadServer(client: LspClient, serverName: string, signal?: AbortSignal): Promise<string>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { AgentTool, AgentToolContext, AgentToolResult, AgentToolUpdateCallback, ToolApprovalDecision } from "@oh-my-pi/pi-agent-core";
|
|
2
|
+
import { type Theme } from "../modes/theme/theme.js";
|
|
3
|
+
import type { ToolSession } from "../tools/index.js";
|
|
4
|
+
import { type LspParams, type LspToolDetails, lspSchema } from "./types.js";
|
|
5
|
+
/**
|
|
6
|
+
* LSP tool for language server protocol operations.
|
|
7
|
+
*/
|
|
8
|
+
export declare class LspTool implements AgentTool<typeof lspSchema, LspToolDetails, Theme> {
|
|
9
|
+
private readonly session;
|
|
10
|
+
readonly name = "lsp";
|
|
11
|
+
readonly approval: (args: unknown) => ToolApprovalDecision;
|
|
12
|
+
readonly formatApprovalDetails: (args: unknown) => string[];
|
|
13
|
+
readonly label = "LSP";
|
|
14
|
+
readonly loadMode = "discoverable";
|
|
15
|
+
readonly summary = "Query LSP (language server) for diagnostics, hover info, and references";
|
|
16
|
+
readonly description: string;
|
|
17
|
+
readonly parameters: import("@oh-my-pi/omptype").FluentType<{
|
|
18
|
+
action: "capabilities" | "code_actions" | "definition" | "diagnostics" | "hover" | "implementation" | "references" | "reload" | "rename" | "rename_file" | "request" | "status" | "symbols" | "type_definition";
|
|
19
|
+
apply?: boolean | undefined;
|
|
20
|
+
file?: string | undefined;
|
|
21
|
+
line?: number | undefined;
|
|
22
|
+
new_name?: string | undefined;
|
|
23
|
+
payload?: string | undefined;
|
|
24
|
+
query?: string | undefined;
|
|
25
|
+
symbol?: string | undefined;
|
|
26
|
+
timeout?: number | undefined;
|
|
27
|
+
}, {
|
|
28
|
+
action: "capabilities" | "code_actions" | "definition" | "diagnostics" | "hover" | "implementation" | "references" | "reload" | "rename" | "rename_file" | "request" | "status" | "symbols" | "type_definition";
|
|
29
|
+
apply?: boolean | undefined;
|
|
30
|
+
file?: string | undefined;
|
|
31
|
+
line?: number | undefined;
|
|
32
|
+
new_name?: string | undefined;
|
|
33
|
+
payload?: string | undefined;
|
|
34
|
+
query?: string | undefined;
|
|
35
|
+
symbol?: string | undefined;
|
|
36
|
+
timeout?: number | undefined;
|
|
37
|
+
}>;
|
|
38
|
+
readonly strict = true;
|
|
39
|
+
constructor(session: ToolSession);
|
|
40
|
+
static createIf(session: ToolSession): LspTool | null;
|
|
41
|
+
execute(_toolCallId: string, params: LspParams, signal?: AbortSignal, _onUpdate?: AgentToolUpdateCallback<LspToolDetails>, _context?: AgentToolContext): Promise<AgentToolResult<LspToolDetails>>;
|
|
42
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Project type detection result */
|
|
2
|
+
interface ProjectType {
|
|
3
|
+
type: "rust" | "typescript" | "go" | "python" | "unknown";
|
|
4
|
+
command?: string[];
|
|
5
|
+
description: string;
|
|
6
|
+
}
|
|
7
|
+
/** Run workspace diagnostics command and parse output */
|
|
8
|
+
export declare function runWorkspaceDiagnostics(cwd: string, signal?: AbortSignal): Promise<{
|
|
9
|
+
output: string;
|
|
10
|
+
projectType: ProjectType;
|
|
11
|
+
}>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { BunFile } from "bun";
|
|
2
|
+
import { type FileDiagnosticsResult } from "./diagnostics.js";
|
|
3
|
+
/** Options for creating the LSP writethrough callback */
|
|
4
|
+
export interface WritethroughOptions {
|
|
5
|
+
/** Whether to format the file using LSP after writing */
|
|
6
|
+
enableFormat?: boolean;
|
|
7
|
+
/** Whether to get LSP diagnostics after writing */
|
|
8
|
+
enableDiagnostics?: boolean;
|
|
9
|
+
/** Called when diagnostics arrive after the main timeout. */
|
|
10
|
+
onDeferredDiagnostics?: (diagnostics: FileDiagnosticsResult) => void;
|
|
11
|
+
/** Signal to cancel a pending deferred diagnostics fetch. */
|
|
12
|
+
deferredSignal?: AbortSignal;
|
|
13
|
+
/** Transform diagnostics before surfacing them after a successful fetch. */
|
|
14
|
+
transformDiagnostics?: (absPath: string, result: FileDiagnosticsResult) => FileDiagnosticsResult;
|
|
15
|
+
}
|
|
16
|
+
/** Per-file deferred LSP diagnostics wiring for {@link WritethroughCallback}. */
|
|
17
|
+
export type WritethroughDeferredHandle = {
|
|
18
|
+
onDeferredDiagnostics: (diagnostics: FileDiagnosticsResult) => void;
|
|
19
|
+
signal: AbortSignal;
|
|
20
|
+
finalize: (diagnostics: FileDiagnosticsResult | undefined) => void;
|
|
21
|
+
};
|
|
22
|
+
/** Callback type for the LSP writethrough */
|
|
23
|
+
export type WritethroughCallback = (dst: string, content: string, signal?: AbortSignal, file?: BunFile, batch?: LspWritethroughBatchRequest, getDeferred?: (dst: string) => WritethroughDeferredHandle | undefined) => Promise<FileDiagnosticsResult | undefined>;
|
|
24
|
+
/** No-op writethrough callback */
|
|
25
|
+
export declare function writethroughNoop(dst: string, content: string, _signal?: AbortSignal, file?: BunFile, _batch?: LspWritethroughBatchRequest, _getDeferred?: (dst: string) => WritethroughDeferredHandle | undefined): Promise<FileDiagnosticsResult | undefined>;
|
|
26
|
+
interface LspWritethroughBatchRequest {
|
|
27
|
+
id: string;
|
|
28
|
+
flush: boolean;
|
|
29
|
+
}
|
|
30
|
+
export declare function flushLspWritethroughBatch(id: string, cwd: string, signal?: AbortSignal): Promise<FileDiagnosticsResult | undefined>;
|
|
31
|
+
/** Create a writethrough callback for LSP aware write operations */
|
|
32
|
+
export declare function createLspWritethrough(cwd: string, options?: WritethroughOptions): WritethroughCallback;
|
|
33
|
+
export {};
|