thoth-agents 0.1.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/LICENSE +21 -0
- package/README.md +339 -0
- package/dist/agents/deep.d.ts +2 -0
- package/dist/agents/designer.d.ts +2 -0
- package/dist/agents/explorer.d.ts +2 -0
- package/dist/agents/index.d.ts +8 -0
- package/dist/agents/librarian.d.ts +2 -0
- package/dist/agents/oracle.d.ts +2 -0
- package/dist/agents/orchestrator.d.ts +15 -0
- package/dist/agents/prompt-dialects.d.ts +28 -0
- package/dist/agents/prompt-sections.d.ts +47 -0
- package/dist/agents/prompt-utils.d.ts +25 -0
- package/dist/agents/quick.d.ts +2 -0
- package/dist/cli/codex-config-io.d.ts +31 -0
- package/dist/cli/codex-install.d.ts +41 -0
- package/dist/cli/codex-paths.d.ts +29 -0
- package/dist/cli/config-io.d.ts +22 -0
- package/dist/cli/config-manager.d.ts +4 -0
- package/dist/cli/custom-skills.d.ts +48 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.js +4579 -0
- package/dist/cli/install.d.ts +3 -0
- package/dist/cli/model-key-normalization.d.ts +1 -0
- package/dist/cli/paths.d.ts +21 -0
- package/dist/cli/providers.d.ts +120 -0
- package/dist/cli/skill-manifest.d.ts +32 -0
- package/dist/cli/skills.d.ts +26 -0
- package/dist/cli/system.d.ts +6 -0
- package/dist/cli/types.d.ts +58 -0
- package/dist/config/constants.d.ts +17 -0
- package/dist/config/index.d.ts +5 -0
- package/dist/config/loader.d.ts +33 -0
- package/dist/config/schema.d.ts +279 -0
- package/dist/config/utils.d.ts +10 -0
- package/dist/delegation/project-id.d.ts +10 -0
- package/dist/delegation/types.d.ts +39 -0
- package/dist/harness/adapters/codex-surfaces.d.ts +219 -0
- package/dist/harness/adapters/codex.d.ts +8 -0
- package/dist/harness/adapters/opencode.d.ts +10 -0
- package/dist/harness/codex-plugin-paths.d.ts +1 -0
- package/dist/harness/core/agent-pack.d.ts +88 -0
- package/dist/harness/core/memory-governance.d.ts +33 -0
- package/dist/harness/core/sdd.d.ts +100 -0
- package/dist/harness/core/skills.d.ts +183 -0
- package/dist/harness/generate-codex-plugin.d.ts +9 -0
- package/dist/harness/registry.d.ts +6 -0
- package/dist/harness/types.d.ts +85 -0
- package/dist/harness/writers/codex-plugin-package.d.ts +26 -0
- package/dist/harness/writers/codex-toml.d.ts +10 -0
- package/dist/harness/writers/skill-layout.d.ts +15 -0
- package/dist/hooks/auto-update-checker/cache.d.ts +7 -0
- package/dist/hooks/auto-update-checker/checker.d.ts +28 -0
- package/dist/hooks/auto-update-checker/constants.d.ts +11 -0
- package/dist/hooks/auto-update-checker/index.d.ts +18 -0
- package/dist/hooks/auto-update-checker/types.d.ts +23 -0
- package/dist/hooks/chat-headers.d.ts +16 -0
- package/dist/hooks/delegate-task-retry/guidance.d.ts +2 -0
- package/dist/hooks/delegate-task-retry/hook.d.ts +8 -0
- package/dist/hooks/delegate-task-retry/index.d.ts +4 -0
- package/dist/hooks/delegate-task-retry/patterns.d.ts +11 -0
- package/dist/hooks/foreground-fallback/index.d.ts +73 -0
- package/dist/hooks/index.d.ts +10 -0
- package/dist/hooks/json-error-recovery/hook.d.ts +18 -0
- package/dist/hooks/json-error-recovery/index.d.ts +1 -0
- package/dist/hooks/phase-reminder/index.d.ts +26 -0
- package/dist/hooks/post-read-nudge/index.d.ts +18 -0
- package/dist/hooks/skill-sync.d.ts +10 -0
- package/dist/hooks/thoth-mem/index.d.ts +46 -0
- package/dist/hooks/thoth-mem/protocol.d.ts +7 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +6509 -0
- package/dist/mcp/context7.d.ts +7 -0
- package/dist/mcp/exa.d.ts +6 -0
- package/dist/mcp/grep-app.d.ts +7 -0
- package/dist/mcp/index.d.ts +7 -0
- package/dist/mcp/thoth.d.ts +3 -0
- package/dist/mcp/types.d.ts +12 -0
- package/dist/sdd/artifact-governance/artifact-loader.d.ts +55 -0
- package/dist/sdd/artifact-governance/index.d.ts +6 -0
- package/dist/sdd/artifact-governance/tasks-validator.d.ts +17 -0
- package/dist/sdd/artifact-governance/types.d.ts +52 -0
- package/dist/thoth/client.d.ts +14 -0
- package/dist/thoth/index.d.ts +2 -0
- package/dist/tools/ast-grep/cli.d.ts +15 -0
- package/dist/tools/ast-grep/constants.d.ts +25 -0
- package/dist/tools/ast-grep/downloader.d.ts +5 -0
- package/dist/tools/ast-grep/index.d.ts +10 -0
- package/dist/tools/ast-grep/tools.d.ts +3 -0
- package/dist/tools/ast-grep/types.d.ts +30 -0
- package/dist/tools/ast-grep/utils.d.ts +4 -0
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/lsp/client.d.ts +42 -0
- package/dist/tools/lsp/config-store.d.ts +29 -0
- package/dist/tools/lsp/config.d.ts +4 -0
- package/dist/tools/lsp/constants.d.ts +25 -0
- package/dist/tools/lsp/index.d.ts +4 -0
- package/dist/tools/lsp/tools.d.ts +5 -0
- package/dist/tools/lsp/types.d.ts +35 -0
- package/dist/tools/lsp/utils.d.ts +34 -0
- package/dist/utils/agent-variant.d.ts +47 -0
- package/dist/utils/env.d.ts +1 -0
- package/dist/utils/file-io.d.ts +3 -0
- package/dist/utils/frontmatter-yaml.d.ts +4 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/internal-initiator.d.ts +6 -0
- package/dist/utils/logger.d.ts +1 -0
- package/dist/utils/polling.d.ts +21 -0
- package/dist/utils/subprocess.d.ts +24 -0
- package/dist/utils/tmux-session-manager.d.ts +63 -0
- package/dist/utils/tmux.d.ts +32 -0
- package/dist/utils/zip-extractor.d.ts +1 -0
- package/package.json +81 -0
- package/src/skills/_shared/openspec-convention.md +131 -0
- package/src/skills/_shared/persistence-contract.md +162 -0
- package/src/skills/_shared/thoth-mem-convention.md +124 -0
- package/src/skills/executing-plans/SKILL.md +245 -0
- package/src/skills/plan-reviewer/SKILL.md +115 -0
- package/src/skills/requirements-interview/SKILL.md +212 -0
- package/src/skills/sdd-apply/SKILL.md +89 -0
- package/src/skills/sdd-archive/SKILL.md +87 -0
- package/src/skills/sdd-design/SKILL.md +92 -0
- package/src/skills/sdd-init/SKILL.md +148 -0
- package/src/skills/sdd-propose/SKILL.md +89 -0
- package/src/skills/sdd-spec/SKILL.md +93 -0
- package/src/skills/sdd-tasks/SKILL.md +142 -0
- package/src/skills/sdd-verify/SKILL.md +99 -0
- package/src/skills/thoth-mem-agents/SKILL.md +355 -0
- package/thoth-agents.schema.json +470 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { RemoteMcpConfig } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Context7 - official documentation lookup for libraries
|
|
4
|
+
* @see https://context7.com
|
|
5
|
+
*/
|
|
6
|
+
export declare const CONTEXT7_MCP_URL = "https://mcp.context7.com/mcp";
|
|
7
|
+
export declare const context7: RemoteMcpConfig;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ThothConfig } from '../config';
|
|
2
|
+
import type { McpConfig } from './types';
|
|
3
|
+
export type { LocalMcpConfig, McpConfig, RemoteMcpConfig } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Creates MCP configurations, excluding disabled ones
|
|
6
|
+
*/
|
|
7
|
+
export declare function createBuiltinMcps(disabledMcps?: readonly string[], thothConfig?: ThothConfig): Record<string, McpConfig>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type RemoteMcpConfig = {
|
|
2
|
+
type: 'remote';
|
|
3
|
+
url: string;
|
|
4
|
+
headers?: Record<string, string>;
|
|
5
|
+
oauth?: false;
|
|
6
|
+
};
|
|
7
|
+
export type LocalMcpConfig = {
|
|
8
|
+
type: 'local';
|
|
9
|
+
command: string[];
|
|
10
|
+
environment?: Record<string, string>;
|
|
11
|
+
};
|
|
12
|
+
export type McpConfig = RemoteMcpConfig | LocalMcpConfig;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type ArtifactGovernanceMode, type ArtifactGovernanceResult } from './types';
|
|
2
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
3
|
+
export type ArtifactSnapshotSource = 'prompt' | 'thoth-mem' | 'openspec';
|
|
4
|
+
export interface ArtifactSnapshotInput {
|
|
5
|
+
content: string;
|
|
6
|
+
location?: string;
|
|
7
|
+
updatedAt?: string;
|
|
8
|
+
observationId?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface ArtifactSnapshot extends ArtifactSnapshotInput {
|
|
11
|
+
source: ArtifactSnapshotSource;
|
|
12
|
+
}
|
|
13
|
+
export interface ArtifactLoaderRequest {
|
|
14
|
+
mode: ArtifactGovernanceMode;
|
|
15
|
+
changeName: string;
|
|
16
|
+
artifact: string;
|
|
17
|
+
promptSnapshot?: ArtifactSnapshotInput;
|
|
18
|
+
workspaceRoot?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface ArtifactLoaderDescriptor {
|
|
21
|
+
changeName: string;
|
|
22
|
+
artifact: string;
|
|
23
|
+
topicKey: string;
|
|
24
|
+
openspecPath: string;
|
|
25
|
+
}
|
|
26
|
+
export interface ArtifactLoaderDependencies {
|
|
27
|
+
readThothArtifact?: (descriptor: ArtifactLoaderDescriptor) => MaybePromise<ArtifactSnapshotInput | null>;
|
|
28
|
+
readOpenspecArtifact?: (descriptor: ArtifactLoaderDescriptor) => MaybePromise<ArtifactSnapshotInput | null>;
|
|
29
|
+
}
|
|
30
|
+
export interface ArtifactComparisonMetadata {
|
|
31
|
+
status: 'not-applicable' | 'single-source' | 'match' | 'diverged';
|
|
32
|
+
sourceOfTruth: ArtifactSnapshotSource | null;
|
|
33
|
+
recoverable: boolean;
|
|
34
|
+
missingSources: readonly ArtifactSnapshotSource[];
|
|
35
|
+
metadata: Readonly<{
|
|
36
|
+
comparedSources: readonly ArtifactSnapshotSource[];
|
|
37
|
+
matched?: boolean;
|
|
38
|
+
thothLength?: number;
|
|
39
|
+
openspecLength?: number;
|
|
40
|
+
}>;
|
|
41
|
+
}
|
|
42
|
+
export interface ArtifactLoaderResult extends ArtifactGovernanceResult {
|
|
43
|
+
snapshot: ArtifactSnapshot | null;
|
|
44
|
+
descriptor: ArtifactLoaderDescriptor;
|
|
45
|
+
comparison: ArtifactComparisonMetadata;
|
|
46
|
+
sources: Readonly<{
|
|
47
|
+
prompt: ArtifactSnapshot | null;
|
|
48
|
+
thothMem: ArtifactSnapshot | null;
|
|
49
|
+
openspec: ArtifactSnapshot | null;
|
|
50
|
+
}>;
|
|
51
|
+
}
|
|
52
|
+
export declare function getArtifactTopicKey(changeName: string, artifact: string): string;
|
|
53
|
+
export declare function getArtifactOpenSpecPath(changeName: string, artifact: string): string;
|
|
54
|
+
export declare function loadArtifactSnapshot(request: ArtifactLoaderRequest, dependencies?: ArtifactLoaderDependencies): Promise<ArtifactLoaderResult>;
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { ArtifactComparisonMetadata, ArtifactLoaderDependencies, ArtifactLoaderDescriptor, ArtifactLoaderRequest, ArtifactLoaderResult, ArtifactSnapshot, ArtifactSnapshotInput, ArtifactSnapshotSource, } from './artifact-loader';
|
|
2
|
+
export { getArtifactOpenSpecPath, getArtifactTopicKey, loadArtifactSnapshot, } from './artifact-loader';
|
|
3
|
+
export type { ValidateTasksArtifactPersistence, ValidateTasksArtifactRequest, } from './tasks-validator';
|
|
4
|
+
export { validateTasksArtifact } from './tasks-validator';
|
|
5
|
+
export type { ArtifactGovernanceEnforcementMode, ArtifactGovernanceFinding, ArtifactGovernanceMetadataValue, ArtifactGovernanceMode, ArtifactGovernanceReport, ArtifactGovernanceResult, ArtifactGovernanceSeverity, ArtifactGovernanceSummary, CreateArtifactGovernanceReportOptions, CreateArtifactGovernanceResultOptions, } from './types';
|
|
6
|
+
export { ARTIFACT_GOVERNANCE_ENFORCEMENT_MODES, ARTIFACT_GOVERNANCE_MODES, ARTIFACT_GOVERNANCE_SEVERITIES, createArtifactGovernanceReport, createArtifactGovernanceResult, getHighestArtifactGovernanceSeverity, isArtifactGovernanceSeverity, summarizeArtifactGovernanceFindings, } from './types';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ArtifactComparisonMetadata, ArtifactSnapshot } from './artifact-loader';
|
|
2
|
+
import { type ArtifactGovernanceMode, type ArtifactGovernanceResult } from './types';
|
|
3
|
+
export interface ValidateTasksArtifactRequest {
|
|
4
|
+
mode: ArtifactGovernanceMode;
|
|
5
|
+
content: string;
|
|
6
|
+
path?: string;
|
|
7
|
+
persistence?: ValidateTasksArtifactPersistence;
|
|
8
|
+
}
|
|
9
|
+
export interface ValidateTasksArtifactPersistence {
|
|
10
|
+
comparison: ArtifactComparisonMetadata;
|
|
11
|
+
sources: Readonly<{
|
|
12
|
+
prompt: ArtifactSnapshot | null;
|
|
13
|
+
thothMem: ArtifactSnapshot | null;
|
|
14
|
+
openspec: ArtifactSnapshot | null;
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
17
|
+
export declare function validateTasksArtifact(request: ValidateTasksArtifactRequest): ArtifactGovernanceResult;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export declare const ARTIFACT_GOVERNANCE_SEVERITIES: readonly ["error", "warning", "info"];
|
|
2
|
+
export type ArtifactGovernanceSeverity = (typeof ARTIFACT_GOVERNANCE_SEVERITIES)[number];
|
|
3
|
+
export declare const ARTIFACT_GOVERNANCE_MODES: readonly ["none", "thoth-mem", "openspec", "hybrid"];
|
|
4
|
+
export type ArtifactGovernanceMode = (typeof ARTIFACT_GOVERNANCE_MODES)[number];
|
|
5
|
+
export declare const ARTIFACT_GOVERNANCE_ENFORCEMENT_MODES: readonly ["report-only"];
|
|
6
|
+
export type ArtifactGovernanceEnforcementMode = (typeof ARTIFACT_GOVERNANCE_ENFORCEMENT_MODES)[number];
|
|
7
|
+
export type ArtifactGovernanceMetadataValue = string | number | boolean | null;
|
|
8
|
+
export interface ArtifactGovernanceFinding {
|
|
9
|
+
code: string;
|
|
10
|
+
severity: ArtifactGovernanceSeverity;
|
|
11
|
+
message: string;
|
|
12
|
+
path?: string;
|
|
13
|
+
line?: number;
|
|
14
|
+
column?: number;
|
|
15
|
+
detail?: string;
|
|
16
|
+
source?: string;
|
|
17
|
+
metadata?: Readonly<Record<string, ArtifactGovernanceMetadataValue>>;
|
|
18
|
+
}
|
|
19
|
+
export interface ArtifactGovernanceSummary {
|
|
20
|
+
total: number;
|
|
21
|
+
errorCount: number;
|
|
22
|
+
warningCount: number;
|
|
23
|
+
infoCount: number;
|
|
24
|
+
highestSeverity: ArtifactGovernanceSeverity | null;
|
|
25
|
+
}
|
|
26
|
+
export interface ArtifactGovernanceReport {
|
|
27
|
+
mode: ArtifactGovernanceMode;
|
|
28
|
+
enforcementMode: ArtifactGovernanceEnforcementMode;
|
|
29
|
+
findings: readonly ArtifactGovernanceFinding[];
|
|
30
|
+
summary: ArtifactGovernanceSummary;
|
|
31
|
+
valid: boolean;
|
|
32
|
+
shouldBlock: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface ArtifactGovernanceResult extends ArtifactGovernanceReport {
|
|
35
|
+
validator: string;
|
|
36
|
+
artifact: string;
|
|
37
|
+
report: ArtifactGovernanceReport;
|
|
38
|
+
}
|
|
39
|
+
export interface CreateArtifactGovernanceReportOptions {
|
|
40
|
+
mode?: ArtifactGovernanceMode;
|
|
41
|
+
enforcementMode?: ArtifactGovernanceEnforcementMode;
|
|
42
|
+
findings?: readonly ArtifactGovernanceFinding[];
|
|
43
|
+
}
|
|
44
|
+
export interface CreateArtifactGovernanceResultOptions extends CreateArtifactGovernanceReportOptions {
|
|
45
|
+
validator: string;
|
|
46
|
+
artifact: string;
|
|
47
|
+
}
|
|
48
|
+
export declare function isArtifactGovernanceSeverity(value: string): value is ArtifactGovernanceSeverity;
|
|
49
|
+
export declare function getHighestArtifactGovernanceSeverity(findings: readonly ArtifactGovernanceFinding[]): ArtifactGovernanceSeverity | null;
|
|
50
|
+
export declare function summarizeArtifactGovernanceFindings(findings: readonly ArtifactGovernanceFinding[]): ArtifactGovernanceSummary;
|
|
51
|
+
export declare function createArtifactGovernanceReport(options?: CreateArtifactGovernanceReportOptions): ArtifactGovernanceReport;
|
|
52
|
+
export declare function createArtifactGovernanceResult(options: CreateArtifactGovernanceResultOptions): ArtifactGovernanceResult;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface CreateThothClientOptions {
|
|
2
|
+
project: string;
|
|
3
|
+
directory?: string;
|
|
4
|
+
httpPort?: number;
|
|
5
|
+
timeoutMs?: number;
|
|
6
|
+
enabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface ThothClient {
|
|
9
|
+
readonly enabled: boolean;
|
|
10
|
+
memContext(sessionId?: string, limit?: number): Promise<string | null>;
|
|
11
|
+
memSessionStart(sessionId: string): Promise<boolean>;
|
|
12
|
+
memSavePrompt(sessionId: string, content: string): Promise<boolean>;
|
|
13
|
+
}
|
|
14
|
+
export declare function createThothClient(options: CreateThothClientOptions): ThothClient;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CliLanguage, SgResult } from './types';
|
|
2
|
+
export interface RunOptions {
|
|
3
|
+
pattern: string;
|
|
4
|
+
lang: CliLanguage;
|
|
5
|
+
paths?: string[];
|
|
6
|
+
globs?: string[];
|
|
7
|
+
rewrite?: string;
|
|
8
|
+
context?: number;
|
|
9
|
+
updateAll?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare function getAstGrepPath(): Promise<string | null>;
|
|
12
|
+
export declare function startBackgroundInit(): void;
|
|
13
|
+
export declare function runSg(options: RunOptions): Promise<SgResult>;
|
|
14
|
+
export declare function isCliAvailable(): boolean;
|
|
15
|
+
export declare function ensureCliAvailable(): Promise<boolean>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CLI_LANGUAGES } from './types';
|
|
2
|
+
export declare function findSgCliPathSync(): string | null;
|
|
3
|
+
export declare function getSgCliPath(): string;
|
|
4
|
+
export declare function setSgCliPath(path: string): void;
|
|
5
|
+
export { CLI_LANGUAGES };
|
|
6
|
+
export declare const DEFAULT_TIMEOUT_MS = 300000;
|
|
7
|
+
export declare const DEFAULT_MAX_OUTPUT_BYTES: number;
|
|
8
|
+
export declare const DEFAULT_MAX_MATCHES = 500;
|
|
9
|
+
export declare const LANG_EXTENSIONS: Record<string, string[]>;
|
|
10
|
+
export interface EnvironmentCheckResult {
|
|
11
|
+
cli: {
|
|
12
|
+
available: boolean;
|
|
13
|
+
path: string;
|
|
14
|
+
error?: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Check if ast-grep CLI is available.
|
|
19
|
+
* Call this at startup to provide early feedback about missing dependencies.
|
|
20
|
+
*/
|
|
21
|
+
export declare function checkEnvironment(): EnvironmentCheckResult;
|
|
22
|
+
/**
|
|
23
|
+
* Format environment check result as user-friendly message.
|
|
24
|
+
*/
|
|
25
|
+
export declare function formatEnvironmentCheck(result: EnvironmentCheckResult): string;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function getCacheDir(): string;
|
|
2
|
+
export declare function getBinaryName(): string;
|
|
3
|
+
export declare function getCachedBinaryPath(): string | null;
|
|
4
|
+
export declare function downloadAstGrep(version?: string): Promise<string | null>;
|
|
5
|
+
export declare function ensureAstGrepBinary(): Promise<string | null>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ToolDefinition } from '@opencode-ai/plugin';
|
|
2
|
+
import { ast_grep_replace, ast_grep_search } from './tools';
|
|
3
|
+
export declare const builtinTools: Record<string, ToolDefinition>;
|
|
4
|
+
export { ast_grep_search, ast_grep_replace };
|
|
5
|
+
export { ensureCliAvailable, getAstGrepPath, isCliAvailable, startBackgroundInit, } from './cli';
|
|
6
|
+
export type { EnvironmentCheckResult } from './constants';
|
|
7
|
+
export { checkEnvironment, formatEnvironmentCheck } from './constants';
|
|
8
|
+
export { ensureAstGrepBinary, getCacheDir, getCachedBinaryPath, } from './downloader';
|
|
9
|
+
export type { CliLanguage, CliMatch, SgResult } from './types';
|
|
10
|
+
export { CLI_LANGUAGES } from './types';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export declare const CLI_LANGUAGES: readonly ["bash", "c", "cpp", "csharp", "css", "elixir", "go", "haskell", "html", "java", "javascript", "json", "kotlin", "lua", "nix", "php", "python", "ruby", "rust", "scala", "solidity", "swift", "typescript", "tsx", "yaml"];
|
|
2
|
+
export type CliLanguage = (typeof CLI_LANGUAGES)[number];
|
|
3
|
+
export interface CliMatch {
|
|
4
|
+
file: string;
|
|
5
|
+
range: {
|
|
6
|
+
byteOffset: {
|
|
7
|
+
start: number;
|
|
8
|
+
end: number;
|
|
9
|
+
};
|
|
10
|
+
start: {
|
|
11
|
+
line: number;
|
|
12
|
+
column: number;
|
|
13
|
+
};
|
|
14
|
+
end: {
|
|
15
|
+
line: number;
|
|
16
|
+
column: number;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
lines: string;
|
|
20
|
+
text: string;
|
|
21
|
+
replacement?: string;
|
|
22
|
+
language: string;
|
|
23
|
+
}
|
|
24
|
+
export interface SgResult {
|
|
25
|
+
matches: CliMatch[];
|
|
26
|
+
totalMatches: number;
|
|
27
|
+
truncated: boolean;
|
|
28
|
+
truncatedReason?: 'timeout' | 'max_output_bytes' | 'max_matches';
|
|
29
|
+
error?: string;
|
|
30
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CliLanguage, SgResult } from './types';
|
|
2
|
+
export declare function formatSearchResult(result: SgResult): string;
|
|
3
|
+
export declare function formatReplaceResult(result: SgResult, isDryRun: boolean): string;
|
|
4
|
+
export declare function getEmptyResultHint(pattern: string, lang: CliLanguage): string | null;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Diagnostic, ResolvedServer } from './types';
|
|
2
|
+
declare class LSPServerManager {
|
|
3
|
+
private static instance;
|
|
4
|
+
private clients;
|
|
5
|
+
private cleanupInterval;
|
|
6
|
+
private readonly IDLE_TIMEOUT;
|
|
7
|
+
private constructor();
|
|
8
|
+
private registerProcessCleanup;
|
|
9
|
+
static getInstance(): LSPServerManager;
|
|
10
|
+
private getKey;
|
|
11
|
+
private startCleanupTimer;
|
|
12
|
+
private cleanupIdleClients;
|
|
13
|
+
getClient(root: string, server: ResolvedServer): Promise<LSPClient>;
|
|
14
|
+
releaseClient(root: string, serverId: string): void;
|
|
15
|
+
isServerInitializing(root: string, serverId: string): boolean;
|
|
16
|
+
stopAll(): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
export declare const lspManager: LSPServerManager;
|
|
19
|
+
export declare class LSPClient {
|
|
20
|
+
private root;
|
|
21
|
+
private server;
|
|
22
|
+
private proc;
|
|
23
|
+
private connection;
|
|
24
|
+
private openedFiles;
|
|
25
|
+
private stderrBuffer;
|
|
26
|
+
private processExited;
|
|
27
|
+
private diagnosticsStore;
|
|
28
|
+
constructor(root: string, server: ResolvedServer);
|
|
29
|
+
start(): Promise<void>;
|
|
30
|
+
private startStderrReading;
|
|
31
|
+
initialize(): Promise<void>;
|
|
32
|
+
openFile(filePath: string): Promise<void>;
|
|
33
|
+
definition(filePath: string, line: number, character: number): Promise<unknown>;
|
|
34
|
+
references(filePath: string, line: number, character: number, includeDeclaration?: boolean): Promise<unknown>;
|
|
35
|
+
diagnostics(filePath: string): Promise<{
|
|
36
|
+
items: Diagnostic[];
|
|
37
|
+
}>;
|
|
38
|
+
rename(filePath: string, line: number, character: number, newName: string): Promise<unknown>;
|
|
39
|
+
isAlive(): boolean;
|
|
40
|
+
stop(): Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User-provided LSP server config (from opencode.json lsp section).
|
|
3
|
+
* Fields are optional because user config may not include all properties.
|
|
4
|
+
*/
|
|
5
|
+
export interface UserLspConfig {
|
|
6
|
+
id: string;
|
|
7
|
+
command?: string[];
|
|
8
|
+
extensions?: string[];
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
env?: Record<string, string>;
|
|
11
|
+
initialization?: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Set the user's lsp config from opencode.json.
|
|
15
|
+
* Called during plugin initialization.
|
|
16
|
+
*/
|
|
17
|
+
export declare function setUserLspConfig(config: Record<string, unknown> | undefined): void;
|
|
18
|
+
/**
|
|
19
|
+
* Get the user's lsp config for a specific server ID.
|
|
20
|
+
*/
|
|
21
|
+
export declare function getUserLspConfig(serverId: string): UserLspConfig | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Get all user-configured lsp servers.
|
|
24
|
+
*/
|
|
25
|
+
export declare function getAllUserLspConfigs(): Map<string, UserLspConfig>;
|
|
26
|
+
/**
|
|
27
|
+
* Check if user has configured any lsp servers.
|
|
28
|
+
*/
|
|
29
|
+
export declare function hasUserLspConfig(): boolean;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { LSPServerConfig, RootFunction } from './types';
|
|
2
|
+
export declare const SYMBOL_KIND_MAP: Record<number, string>;
|
|
3
|
+
export declare const SEVERITY_MAP: Record<number, string>;
|
|
4
|
+
export declare const DEFAULT_MAX_REFERENCES = 200;
|
|
5
|
+
export declare const DEFAULT_MAX_DIAGNOSTICS = 200;
|
|
6
|
+
export declare const LOCK_FILE_PATTERNS: string[];
|
|
7
|
+
/**
|
|
8
|
+
* NearestRoot helper - mirrors OpenCode core's NearestRoot function.
|
|
9
|
+
* Creates a RootFunction that walks up directories looking for root markers.
|
|
10
|
+
*/
|
|
11
|
+
export declare function NearestRoot(includePatterns: string[], excludePatterns?: string[]): RootFunction;
|
|
12
|
+
/**
|
|
13
|
+
* Built-in LSP servers - mirrors OpenCode core LSPServer namespace.
|
|
14
|
+
* User configuration from opencode.json lsp section takes precedence and is
|
|
15
|
+
* merged on top of these: user settings override command/extensions/env, while
|
|
16
|
+
* root patterns are always preserved from built-in. Servers can be removed by
|
|
17
|
+
* setting `"disabled": true` in the user config.
|
|
18
|
+
*/
|
|
19
|
+
export declare const BUILTIN_SERVERS: Record<string, Omit<LSPServerConfig, 'id'>>;
|
|
20
|
+
export declare const LSP_INSTALL_HINTS: Record<string, string>;
|
|
21
|
+
/**
|
|
22
|
+
* Maps file extensions to LSP language IDs.
|
|
23
|
+
* Mirrors OpenCode core's LANGUAGE_EXTENSIONS constant.
|
|
24
|
+
*/
|
|
25
|
+
export declare const LANGUAGE_EXTENSIONS: Record<string, string>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { lspManager } from './client';
|
|
2
|
+
export { getUserLspConfig, setUserLspConfig } from './config-store';
|
|
3
|
+
export { lsp_diagnostics, lsp_find_references, lsp_goto_definition, lsp_rename, } from './tools';
|
|
4
|
+
export type { Diagnostic, Location, LSPServerConfig, ResolvedServer, WorkspaceEdit, } from './types';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ToolDefinition } from '@opencode-ai/plugin/tool';
|
|
2
|
+
export declare const lsp_goto_definition: ToolDefinition;
|
|
3
|
+
export declare const lsp_find_references: ToolDefinition;
|
|
4
|
+
export declare const lsp_diagnostics: ToolDefinition;
|
|
5
|
+
export declare const lsp_rename: ToolDefinition;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { CreateFile, DeleteFile, Diagnostic, DocumentSymbol, Location, LocationLink, Position, Range, RenameFile, SymbolInformation as SymbolInfo, TextDocumentEdit, TextDocumentIdentifier, TextEdit, VersionedTextDocumentIdentifier, WorkspaceEdit } from 'vscode-languageserver-protocol';
|
|
2
|
+
/**
|
|
3
|
+
* Root function type - mirrors OpenCode core's RootFunction.
|
|
4
|
+
* Returns the project root directory for a given file, or undefined if not applicable.
|
|
5
|
+
*/
|
|
6
|
+
export type RootFunction = (file: string) => string | undefined;
|
|
7
|
+
export interface LSPServerConfig {
|
|
8
|
+
id: string;
|
|
9
|
+
command: string[];
|
|
10
|
+
extensions: string[];
|
|
11
|
+
root?: RootFunction;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
env?: Record<string, string>;
|
|
14
|
+
initialization?: Record<string, unknown>;
|
|
15
|
+
}
|
|
16
|
+
export interface ResolvedServer {
|
|
17
|
+
id: string;
|
|
18
|
+
command: string[];
|
|
19
|
+
extensions: string[];
|
|
20
|
+
root?: RootFunction;
|
|
21
|
+
env?: Record<string, string>;
|
|
22
|
+
initialization?: Record<string, unknown>;
|
|
23
|
+
}
|
|
24
|
+
export type ServerLookupResult = {
|
|
25
|
+
status: 'found';
|
|
26
|
+
server: ResolvedServer;
|
|
27
|
+
} | {
|
|
28
|
+
status: 'not_configured';
|
|
29
|
+
extension: string;
|
|
30
|
+
} | {
|
|
31
|
+
status: 'not_installed';
|
|
32
|
+
server: ResolvedServer;
|
|
33
|
+
installHint: string;
|
|
34
|
+
};
|
|
35
|
+
export type { Position, Range, Location, LocationLink, Diagnostic, TextDocumentIdentifier, VersionedTextDocumentIdentifier, TextEdit, TextDocumentEdit, CreateFile, RenameFile, DeleteFile, WorkspaceEdit, SymbolInfo, DocumentSymbol, };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { LSPClient } from './client';
|
|
2
|
+
import type { Diagnostic, Location, LocationLink, ResolvedServer, ServerLookupResult, WorkspaceEdit } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Find the project root for a specific LSP server using its root function.
|
|
5
|
+
* Mirrors OpenCode core's RootFunction approach.
|
|
6
|
+
*
|
|
7
|
+
* @param filePath - The file to find the root for
|
|
8
|
+
* @param server - The LSP server config with root function
|
|
9
|
+
* @returns The project root directory, or file's directory if no root function
|
|
10
|
+
*/
|
|
11
|
+
export declare function findServerProjectRoot(filePath: string, server: ResolvedServer): string;
|
|
12
|
+
/**
|
|
13
|
+
* Legacy function for backward compatibility.
|
|
14
|
+
* @deprecated Use findServerProjectRoot with server-specific patterns instead.
|
|
15
|
+
*/
|
|
16
|
+
export declare function findWorkspaceRoot(filePath: string): string;
|
|
17
|
+
export declare function uriToPath(uri: string): string;
|
|
18
|
+
export declare function formatServerLookupError(result: Exclude<ServerLookupResult, {
|
|
19
|
+
status: 'found';
|
|
20
|
+
}>): string;
|
|
21
|
+
export declare function withLspClient<T>(filePath: string, fn: (client: LSPClient) => Promise<T>): Promise<T>;
|
|
22
|
+
export declare function formatLocation(loc: Location | LocationLink): string;
|
|
23
|
+
export declare function formatSymbolKind(kind: number): string;
|
|
24
|
+
export declare function formatSeverity(severity: number | undefined): string;
|
|
25
|
+
export declare function formatDiagnostic(diag: Diagnostic): string;
|
|
26
|
+
export declare function filterDiagnosticsBySeverity(diagnostics: Diagnostic[], severityFilter?: 'error' | 'warning' | 'information' | 'hint' | 'all'): Diagnostic[];
|
|
27
|
+
export interface ApplyResult {
|
|
28
|
+
success: boolean;
|
|
29
|
+
filesModified: string[];
|
|
30
|
+
totalEdits: number;
|
|
31
|
+
errors: string[];
|
|
32
|
+
}
|
|
33
|
+
export declare function applyWorkspaceEdit(edit: WorkspaceEdit | null): ApplyResult;
|
|
34
|
+
export declare function formatApplyResult(result: ApplyResult): string;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { PluginConfig } from '../config';
|
|
2
|
+
/**
|
|
3
|
+
* Normalizes an agent name by trimming whitespace and removing the optional @ prefix.
|
|
4
|
+
*
|
|
5
|
+
* @param agentName - The agent name to normalize (e.g., "@oracle" or "oracle")
|
|
6
|
+
* @returns The normalized agent name without @ prefix and trimmed of whitespace
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* normalizeAgentName("@oracle") // returns "oracle"
|
|
10
|
+
* normalizeAgentName(" explore ") // returns "explore"
|
|
11
|
+
*/
|
|
12
|
+
export declare function normalizeAgentName(agentName: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* Resolves the variant configuration for a specific agent.
|
|
15
|
+
*
|
|
16
|
+
* Looks up the agent's variant in the plugin configuration. Returns undefined if:
|
|
17
|
+
* - No config is provided
|
|
18
|
+
* - The agent has no variant configured
|
|
19
|
+
* - The variant is not a string
|
|
20
|
+
* - The variant is empty or whitespace-only
|
|
21
|
+
*
|
|
22
|
+
* @param config - The plugin configuration object
|
|
23
|
+
* @param agentName - The name of the agent (with or without @ prefix)
|
|
24
|
+
* @returns The trimmed variant string, or undefined if no valid variant is found
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* resolveAgentVariant(config, "@oracle") // returns "high" if configured
|
|
28
|
+
*/
|
|
29
|
+
export declare function resolveAgentVariant(config: PluginConfig | undefined, agentName: string): string | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Applies a variant to a request body if the body doesn't already have one.
|
|
32
|
+
*
|
|
33
|
+
* This function will NOT override an existing variant in the body. If no variant
|
|
34
|
+
* is provided or the body already has a variant, the original body is returned.
|
|
35
|
+
*
|
|
36
|
+
* @template T - The type of the body object, must have an optional variant property
|
|
37
|
+
* @param variant - The variant string to apply (or undefined)
|
|
38
|
+
* @param body - The request body object
|
|
39
|
+
* @returns The body with the variant applied (new object) or the original body unchanged
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* applyAgentVariant("high", { agent: "oracle" }) // returns { agent: "oracle", variant: "high" }
|
|
43
|
+
* applyAgentVariant("high", { agent: "oracle", variant: "low" }) // returns original body with variant: "low"
|
|
44
|
+
*/
|
|
45
|
+
export declare function applyAgentVariant<T extends {
|
|
46
|
+
variant?: string;
|
|
47
|
+
}>(variant: string | undefined, body: T): T;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getEnv(name: string): string | undefined;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function writeTextFile(filePath: string, contents: string | ArrayBuffer): Promise<void>;
|
|
2
|
+
export declare function readTextFile(filePath: string): Promise<string>;
|
|
3
|
+
export declare function readTextFilePrefix(filePath: string, maxBytes: number): Promise<string>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const LITE_INTERNAL_INITIATOR_MARKER = "<!-- LITE_INTERNAL_INITIATOR -->";
|
|
2
|
+
export declare function createInternalAgentTextPart(text: string): {
|
|
3
|
+
type: 'text';
|
|
4
|
+
text: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function hasInternalInitiatorMarker(part: unknown): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function log(message: string, data?: unknown): void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface PollOptions {
|
|
2
|
+
pollInterval?: number;
|
|
3
|
+
maxPollTime?: number;
|
|
4
|
+
stableThreshold?: number;
|
|
5
|
+
signal?: AbortSignal;
|
|
6
|
+
}
|
|
7
|
+
export interface PollResult<T> {
|
|
8
|
+
success: boolean;
|
|
9
|
+
data?: T;
|
|
10
|
+
timedOut?: boolean;
|
|
11
|
+
aborted?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Generic polling utility that waits for a condition to be met.
|
|
15
|
+
* Returns when the condition is satisfied or timeout/abort occurs.
|
|
16
|
+
*/
|
|
17
|
+
export declare function pollUntilStable<T>(fetchFn: () => Promise<T>, isStable: (current: T, previous: T | null, stableCount: number) => boolean, opts?: PollOptions): Promise<PollResult<T>>;
|
|
18
|
+
/**
|
|
19
|
+
* Simple delay utility
|
|
20
|
+
*/
|
|
21
|
+
export declare function delay(ms: number): Promise<void>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
type SpawnOptions = {
|
|
2
|
+
cwd?: string;
|
|
3
|
+
env?: Record<string, string | undefined>;
|
|
4
|
+
stdin?: 'pipe' | 'ignore';
|
|
5
|
+
stdout?: 'pipe' | 'ignore';
|
|
6
|
+
stderr?: 'pipe' | 'ignore';
|
|
7
|
+
};
|
|
8
|
+
export type ManagedSubprocess = {
|
|
9
|
+
stdin: {
|
|
10
|
+
write(chunk: Uint8Array | string): unknown;
|
|
11
|
+
end(): unknown;
|
|
12
|
+
};
|
|
13
|
+
stdout: ReadableStream<Uint8Array>;
|
|
14
|
+
stderr: ReadableStream<Uint8Array>;
|
|
15
|
+
exited: Promise<number>;
|
|
16
|
+
exitCode: number | null;
|
|
17
|
+
kill(): void;
|
|
18
|
+
};
|
|
19
|
+
export type ManagedSpawnSyncResult = {
|
|
20
|
+
exitCode: number | null;
|
|
21
|
+
};
|
|
22
|
+
export declare function spawn(command: string[], options?: SpawnOptions): ManagedSubprocess;
|
|
23
|
+
export declare function spawnSync(command: string[], options?: SpawnOptions): ManagedSpawnSyncResult;
|
|
24
|
+
export {};
|