@hiai-gg/hiai-opencode 0.1.5 → 0.1.6
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/.env.example +14 -8
- package/AGENTS.md +14 -5
- package/LICENSE.md +0 -1
- package/README.md +42 -23
- package/assets/cli/hiai-opencode.mjs +590 -7
- package/assets/mcp/mempalace.mjs +159 -25
- package/config/hiai-opencode.schema.json +13 -2
- package/dist/agents/dynamic-agent-core-sections.d.ts +4 -1
- package/dist/agents/dynamic-agent-prompt-builder.d.ts +1 -1
- package/dist/config/platform-schema.d.ts +2 -6
- package/dist/config/schema/commands.d.ts +1 -0
- package/dist/config/schema/oh-my-opencode-config.d.ts +1 -3
- package/dist/config/types.d.ts +1 -3
- package/dist/features/builtin-commands/templates/doctor.d.ts +1 -0
- package/dist/features/builtin-commands/types.d.ts +1 -1
- package/dist/features/builtin-skills/skills/hiai-opencode-setup.d.ts +2 -0
- package/dist/features/builtin-skills/skills/index.d.ts +1 -0
- package/dist/index.js +348 -1424
- package/dist/shared/mcp-static-export.d.ts +22 -0
- package/dist/tools/ast-grep/constants.d.ts +1 -1
- package/dist/tools/ast-grep/environment-check.d.ts +1 -5
- package/dist/tools/ast-grep/language-support.d.ts +0 -1
- package/dist/tools/ast-grep/types.d.ts +1 -2
- package/hiai-opencode.json +4 -2
- package/package.json +6 -4
- package/src/agents/bob/default.ts +6 -1
- package/src/agents/bob/gpt-pro.ts +1 -0
- package/src/agents/bob.ts +1 -0
- package/src/agents/coder/gpt-codex.ts +1 -0
- package/src/agents/coder/gpt-pro.ts +1 -0
- package/src/agents/coder/gpt.ts +1 -0
- package/src/agents/dynamic-agent-core-sections.ts +36 -0
- package/src/agents/dynamic-agent-prompt-builder.ts +1 -0
- package/src/config/defaults.ts +14 -1
- package/src/config/model-slots-and-export.test.ts +55 -0
- package/src/config/platform-schema.ts +1 -3
- package/src/config/schema/commands.ts +1 -0
- package/src/config/schema/oh-my-opencode-config.ts +0 -3
- package/src/config/types.ts +1 -3
- package/src/features/builtin-commands/commands.ts +7 -0
- package/src/features/builtin-commands/templates/doctor.ts +43 -0
- package/src/features/builtin-commands/types.ts +1 -1
- package/src/features/builtin-skills/skills/hiai-opencode-setup.ts +69 -0
- package/src/features/builtin-skills/skills/index.ts +1 -0
- package/src/features/builtin-skills/skills.ts +10 -1
- package/src/index.ts +3 -75
- package/src/shared/mcp-static-export.ts +121 -0
- package/src/tools/ast-grep/constants.ts +1 -1
- package/src/tools/ast-grep/environment-check.ts +2 -32
- package/src/tools/ast-grep/language-support.ts +0 -3
- package/src/tools/ast-grep/types.ts +1 -2
- package/src/tools/skill-mcp/tools.test.ts +44 -0
- package/dist/ast-grep-napi.win32-x64-msvc-67c0y8nc.node +0 -0
- package/dist/config/loader.test.d.ts +0 -1
- package/dist/config/models.d.ts +0 -13
- package/dist/internals/plugins/websearch-cited/google.d.ts +0 -38
- package/dist/internals/plugins/websearch-cited/index.d.ts +0 -17
- package/dist/internals/plugins/websearch-cited/openai.d.ts +0 -9
- package/dist/internals/plugins/websearch-cited/openrouter.d.ts +0 -2
- package/dist/internals/plugins/websearch-cited/types.d.ts +0 -5
- package/src/internals/plugins/websearch-cited/LICENSE +0 -214
- package/src/internals/plugins/websearch-cited/codex_prompt.txt +0 -79
- package/src/internals/plugins/websearch-cited/google.ts +0 -749
- package/src/internals/plugins/websearch-cited/index.ts +0 -306
- package/src/internals/plugins/websearch-cited/openai.ts +0 -407
- package/src/internals/plugins/websearch-cited/openrouter.ts +0 -190
- package/src/internals/plugins/websearch-cited/types.ts +0 -7
package/src/index.ts
CHANGED
|
@@ -18,22 +18,15 @@ import { injectServerAuthIntoClient, log } from "./shared"
|
|
|
18
18
|
import { hydratePluginConfigWithPlatformDefaults } from "./shared/runtime-plugin-config"
|
|
19
19
|
import { detectExternalSkillPlugin, getSkillPluginConflictWarning } from "./shared/external-plugin-detector"
|
|
20
20
|
import { PLUGIN_NAME } from "./shared/plugin-identity"
|
|
21
|
+
import { autoExportStaticMcpJson } from "./shared/mcp-static-export"
|
|
21
22
|
import { warnIfListPluginEntry, warnMissingRequiredMcpEnv } from "./shared/startup-diagnostics"
|
|
22
23
|
import { startBackgroundCheck as startTmuxCheck } from "./tools/interactive-bash"
|
|
23
24
|
import { lspManager } from "./tools/lsp/client"
|
|
24
25
|
|
|
25
|
-
import { loadConfig
|
|
26
|
+
import { loadConfig } from "./config/loader"
|
|
26
27
|
import type { HiaiOpencodeConfig } from "./config/types"
|
|
27
28
|
|
|
28
29
|
import { createPlugin as createSubtask2Plugin } from "./internals/plugins/subtask2/core/plugin"
|
|
29
|
-
import WebsearchCitedPlugin, {
|
|
30
|
-
GOOGLE_PROVIDER_ID,
|
|
31
|
-
OPENAI_PROVIDER_ID,
|
|
32
|
-
OPENROUTER_PROVIDER_ID,
|
|
33
|
-
WebsearchCitedGooglePlugin,
|
|
34
|
-
WebsearchCitedOpenAIPlugin
|
|
35
|
-
} from "./internals/plugins/websearch-cited/index"
|
|
36
|
-
import type { WebsearchCitedFallback } from "./internals/plugins/websearch-cited/index"
|
|
37
30
|
import { createBuiltinSkills } from "./features/builtin-skills"
|
|
38
31
|
import {
|
|
39
32
|
materializeBuiltinSkills,
|
|
@@ -42,39 +35,6 @@ import {
|
|
|
42
35
|
|
|
43
36
|
let activePluginDispose: PluginDispose | null = null
|
|
44
37
|
|
|
45
|
-
function createWebsearchFallback(config: HiaiOpencodeConfig): WebsearchCitedFallback | undefined {
|
|
46
|
-
const model = config.agents?.researcher?.model?.trim()
|
|
47
|
-
if (!model) {
|
|
48
|
-
return undefined
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (model.startsWith("openrouter/")) {
|
|
52
|
-
return {
|
|
53
|
-
providerID: OPENROUTER_PROVIDER_ID,
|
|
54
|
-
model: model.slice("openrouter/".length),
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (model.startsWith("openai/")) {
|
|
59
|
-
return {
|
|
60
|
-
providerID: OPENAI_PROVIDER_ID,
|
|
61
|
-
model: model.slice("openai/".length),
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (model.startsWith("google/")) {
|
|
66
|
-
return {
|
|
67
|
-
providerID: GOOGLE_PROVIDER_ID,
|
|
68
|
-
model: model.slice("google/".length),
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return {
|
|
73
|
-
providerID: OPENROUTER_PROVIDER_ID,
|
|
74
|
-
model,
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
38
|
function configureBundledBunPtyLibrary(): void {
|
|
79
39
|
if (process.env.BUN_PTY_LIB?.trim()) {
|
|
80
40
|
return
|
|
@@ -126,6 +86,7 @@ const HiaiOpenCodePlugin: Plugin = async (ctx) => {
|
|
|
126
86
|
pluginConfig,
|
|
127
87
|
platformConfig: internalConfig,
|
|
128
88
|
})
|
|
89
|
+
autoExportStaticMcpJson(ctx.directory, internalConfig)
|
|
129
90
|
|
|
130
91
|
materializeBuiltinSkills(
|
|
131
92
|
createBuiltinSkills({
|
|
@@ -207,10 +168,6 @@ const HiaiOpenCodePlugin: Plugin = async (ctx) => {
|
|
|
207
168
|
} catch (err) {
|
|
208
169
|
console.error("[hiai-opencode] PTYPlugin failed to load:", err);
|
|
209
170
|
}
|
|
210
|
-
const websearchResult = await WebsearchCitedPlugin(ctx, createWebsearchFallback(internalConfig))
|
|
211
|
-
const websearchGoogleResult = await WebsearchCitedGooglePlugin(ctx)
|
|
212
|
-
const websearchOpenAIResult = await WebsearchCitedOpenAIPlugin(ctx)
|
|
213
|
-
|
|
214
171
|
const combinedResult = {
|
|
215
172
|
name: PLUGIN_NAME,
|
|
216
173
|
...pluginInterface,
|
|
@@ -219,7 +176,6 @@ const HiaiOpenCodePlugin: Plugin = async (ctx) => {
|
|
|
219
176
|
tool: {
|
|
220
177
|
...pluginInterface.tool,
|
|
221
178
|
...ptyResult.tool,
|
|
222
|
-
...websearchResult.tool,
|
|
223
179
|
},
|
|
224
180
|
|
|
225
181
|
// Chain hooks: command.execute.before
|
|
@@ -250,7 +206,6 @@ const HiaiOpenCodePlugin: Plugin = async (ctx) => {
|
|
|
250
206
|
config: async (input: any) => {
|
|
251
207
|
await pluginInterface.config?.(input);
|
|
252
208
|
await (subtask2Result as any).config?.(input);
|
|
253
|
-
await (websearchResult as any).config?.(input);
|
|
254
209
|
},
|
|
255
210
|
|
|
256
211
|
// Merge Events
|
|
@@ -260,33 +215,6 @@ const HiaiOpenCodePlugin: Plugin = async (ctx) => {
|
|
|
260
215
|
await (ptyResult as any).event?.(input);
|
|
261
216
|
},
|
|
262
217
|
|
|
263
|
-
// Auth (Consolidated)
|
|
264
|
-
auth: {
|
|
265
|
-
provider: "hiai-opencode",
|
|
266
|
-
methods: [
|
|
267
|
-
{ type: "api" as const, label: "Google Search API key" },
|
|
268
|
-
],
|
|
269
|
-
loader: async (getAuth: any) => {
|
|
270
|
-
const authData = await getAuth();
|
|
271
|
-
const { registerGetAuth, GOOGLE_PROVIDER_ID, OPENAI_PROVIDER_ID, OPENROUTER_PROVIDER_ID } = await import("./internals/plugins/websearch-cited/index");
|
|
272
|
-
|
|
273
|
-
const getConfiguredKey = (configKey?: string) => {
|
|
274
|
-
if (configKey) return resolveEnvVars(configKey);
|
|
275
|
-
return undefined;
|
|
276
|
-
};
|
|
277
|
-
|
|
278
|
-
const googleKey = authData["Google Search API key"] || getConfiguredKey(internalConfig.auth?.googleSearch);
|
|
279
|
-
const openaiKey = getConfiguredKey(internalConfig.auth?.openai);
|
|
280
|
-
const openRouterKey = getConfiguredKey(internalConfig.auth?.openrouter);
|
|
281
|
-
|
|
282
|
-
if (googleKey) registerGetAuth(GOOGLE_PROVIDER_ID, () => Promise.resolve({ type: "api", key: googleKey }));
|
|
283
|
-
if (openaiKey) registerGetAuth(OPENAI_PROVIDER_ID, () => Promise.resolve({ type: "api", key: openaiKey }));
|
|
284
|
-
if (openRouterKey) registerGetAuth(OPENROUTER_PROVIDER_ID, () => Promise.resolve({ type: "api", key: openRouterKey }));
|
|
285
|
-
|
|
286
|
-
return {};
|
|
287
|
-
},
|
|
288
|
-
},
|
|
289
|
-
|
|
290
218
|
"experimental.session.compacting": async (
|
|
291
219
|
_input: { sessionID: string },
|
|
292
220
|
output: { context: string[] },
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs"
|
|
2
|
+
import { dirname, join } from "node:path"
|
|
3
|
+
|
|
4
|
+
import type { HiaiOpencodeConfig, McpServerConfig } from "../config/types"
|
|
5
|
+
import { resolveEnvVars } from "../config/loader"
|
|
6
|
+
import { log } from "./logger"
|
|
7
|
+
|
|
8
|
+
type StaticMcpServer = {
|
|
9
|
+
type?: "http" | "stdio"
|
|
10
|
+
url?: string
|
|
11
|
+
command?: string
|
|
12
|
+
args?: string[]
|
|
13
|
+
env?: Record<string, string>
|
|
14
|
+
headers?: Record<string, string>
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const MCP_EXPORT_MARKER = "hiai-opencode"
|
|
18
|
+
|
|
19
|
+
type StaticMcpJsonPayload = {
|
|
20
|
+
mcpServers: Record<string, StaticMcpServer>
|
|
21
|
+
_meta?: {
|
|
22
|
+
generatedBy: typeof MCP_EXPORT_MARKER
|
|
23
|
+
version: 1
|
|
24
|
+
generatedAt: string
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function toStaticMcpServer(config: McpServerConfig): StaticMcpServer | null {
|
|
29
|
+
if (config.enabled === false) return null
|
|
30
|
+
|
|
31
|
+
if (config.type === "remote") {
|
|
32
|
+
const headers = config.headers
|
|
33
|
+
? Object.fromEntries(Object.entries(config.headers).map(([key, value]) => [key, resolveEnvVars(value)]))
|
|
34
|
+
: undefined
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
type: "http",
|
|
38
|
+
url: config.url,
|
|
39
|
+
...(headers ? { headers } : {}),
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const [command, ...args] = config.command ?? []
|
|
44
|
+
if (!command) return null
|
|
45
|
+
|
|
46
|
+
const env = config.environment
|
|
47
|
+
? Object.fromEntries(Object.entries(config.environment).map(([key, value]) => [key, resolveEnvVars(value)]))
|
|
48
|
+
: undefined
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
command,
|
|
52
|
+
...(args.length > 0 ? { args } : {}),
|
|
53
|
+
...(env ? { env } : {}),
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function buildStaticMcpJson(config: HiaiOpencodeConfig): StaticMcpJsonPayload {
|
|
58
|
+
const mcpServers: Record<string, StaticMcpServer> = {}
|
|
59
|
+
|
|
60
|
+
for (const [name, serverConfig] of Object.entries(config.mcp ?? {})) {
|
|
61
|
+
const converted = toStaticMcpServer(serverConfig)
|
|
62
|
+
if (converted) {
|
|
63
|
+
mcpServers[name] = converted
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
_meta: {
|
|
69
|
+
generatedBy: MCP_EXPORT_MARKER,
|
|
70
|
+
version: 1,
|
|
71
|
+
generatedAt: new Date().toISOString(),
|
|
72
|
+
},
|
|
73
|
+
mcpServers,
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function isManagedStaticMcpFile(path: string): boolean {
|
|
78
|
+
if (!existsSync(path)) return false
|
|
79
|
+
|
|
80
|
+
try {
|
|
81
|
+
const raw = readFileSync(path, "utf-8")
|
|
82
|
+
const parsed = JSON.parse(raw) as StaticMcpJsonPayload
|
|
83
|
+
return parsed?._meta?.generatedBy === MCP_EXPORT_MARKER
|
|
84
|
+
} catch {
|
|
85
|
+
return false
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function autoExportStaticMcpJson(directory: string, config: HiaiOpencodeConfig): void {
|
|
90
|
+
const mode = process.env.HIAI_OPENCODE_AUTO_EXPORT_MCP?.trim().toLowerCase() || "if-missing"
|
|
91
|
+
if (mode === "0" || mode === "false" || mode === "no" || mode === "off") {
|
|
92
|
+
return
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const outputPath = process.env.HIAI_OPENCODE_MCP_EXPORT_PATH?.trim() || join(directory, ".mcp.json")
|
|
96
|
+
if (mode === "if-missing" && existsSync(outputPath)) {
|
|
97
|
+
return
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const isForceMode = mode === "force"
|
|
101
|
+
if (mode === "always" && existsSync(outputPath) && !isManagedStaticMcpFile(outputPath) && !isForceMode) {
|
|
102
|
+
console.warn(
|
|
103
|
+
`[hiai-opencode] WARNING: refusing to overwrite non-managed static MCP config at ${outputPath}. `
|
|
104
|
+
+ "Set HIAI_OPENCODE_AUTO_EXPORT_MCP=force to override.",
|
|
105
|
+
)
|
|
106
|
+
return
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
try {
|
|
110
|
+
mkdirSync(dirname(outputPath), { recursive: true })
|
|
111
|
+
const payload = buildStaticMcpJson(config)
|
|
112
|
+
writeFileSync(outputPath, `${JSON.stringify(payload, null, 2)}\n`)
|
|
113
|
+
log("[hiai-opencode] exported static MCP config", {
|
|
114
|
+
outputPath,
|
|
115
|
+
servers: Object.keys(payload.mcpServers),
|
|
116
|
+
})
|
|
117
|
+
} catch (error) {
|
|
118
|
+
const message = error instanceof Error ? error.message : String(error)
|
|
119
|
+
console.warn(`[hiai-opencode] WARNING: failed to export static MCP config to ${outputPath}: ${message}`)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { EnvironmentCheckResult } from "./environment-check"
|
|
2
2
|
export { checkEnvironment, formatEnvironmentCheck } from "./environment-check"
|
|
3
|
-
export { CLI_LANGUAGES,
|
|
3
|
+
export { CLI_LANGUAGES, LANG_EXTENSIONS } from "./language-support"
|
|
4
4
|
export { DEFAULT_TIMEOUT_MS, DEFAULT_MAX_OUTPUT_BYTES, DEFAULT_MAX_MATCHES } from "./language-support"
|
|
5
5
|
export { findSgCliPathSync, getSgCliPath, setSgCliPath } from "./sg-cli-path"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync } from "fs"
|
|
2
2
|
|
|
3
|
-
import { CLI_LANGUAGES
|
|
3
|
+
import { CLI_LANGUAGES } from "./language-support"
|
|
4
4
|
import { getSgCliPath } from "./sg-cli-path"
|
|
5
5
|
|
|
6
6
|
export interface EnvironmentCheckResult {
|
|
@@ -9,14 +9,10 @@ export interface EnvironmentCheckResult {
|
|
|
9
9
|
path: string
|
|
10
10
|
error?: string
|
|
11
11
|
}
|
|
12
|
-
napi: {
|
|
13
|
-
available: boolean
|
|
14
|
-
error?: string
|
|
15
|
-
}
|
|
16
12
|
}
|
|
17
13
|
|
|
18
14
|
/**
|
|
19
|
-
* Check if ast-grep CLI
|
|
15
|
+
* Check if ast-grep CLI is available.
|
|
20
16
|
* Call this at startup to provide early feedback about missing dependencies.
|
|
21
17
|
*/
|
|
22
18
|
export function checkEnvironment(): EnvironmentCheckResult {
|
|
@@ -26,9 +22,6 @@ export function checkEnvironment(): EnvironmentCheckResult {
|
|
|
26
22
|
available: false,
|
|
27
23
|
path: cliPath ?? "not found",
|
|
28
24
|
},
|
|
29
|
-
napi: {
|
|
30
|
-
available: false,
|
|
31
|
-
},
|
|
32
25
|
}
|
|
33
26
|
|
|
34
27
|
if (cliPath && existsSync(cliPath)) {
|
|
@@ -39,17 +32,6 @@ export function checkEnvironment(): EnvironmentCheckResult {
|
|
|
39
32
|
result.cli.error = `Binary not found: ${cliPath}`
|
|
40
33
|
}
|
|
41
34
|
|
|
42
|
-
// Check NAPI availability
|
|
43
|
-
try {
|
|
44
|
-
require("@ast-grep/napi")
|
|
45
|
-
result.napi.available = true
|
|
46
|
-
} catch (error) {
|
|
47
|
-
result.napi.available = false
|
|
48
|
-
result.napi.error = `@ast-grep/napi not installed: ${
|
|
49
|
-
error instanceof Error ? error.message : String(error)
|
|
50
|
-
}`
|
|
51
|
-
}
|
|
52
|
-
|
|
53
35
|
return result
|
|
54
36
|
}
|
|
55
37
|
|
|
@@ -70,20 +52,8 @@ export function formatEnvironmentCheck(result: EnvironmentCheckResult): string {
|
|
|
70
52
|
lines.push(" Install: bun add -D @ast-grep/cli")
|
|
71
53
|
}
|
|
72
54
|
|
|
73
|
-
// NAPI status
|
|
74
|
-
if (result.napi.available) {
|
|
75
|
-
lines.push("[OK] NAPI: Available")
|
|
76
|
-
} else {
|
|
77
|
-
lines.push("[X] NAPI: Not available")
|
|
78
|
-
if (result.napi.error) {
|
|
79
|
-
lines.push(` Error: ${result.napi.error}`)
|
|
80
|
-
}
|
|
81
|
-
lines.push(" Install: bun add -D @ast-grep/napi")
|
|
82
|
-
}
|
|
83
|
-
|
|
84
55
|
lines.push("")
|
|
85
56
|
lines.push(`CLI supports ${CLI_LANGUAGES.length} languages`)
|
|
86
|
-
lines.push(`NAPI supports ${NAPI_LANGUAGES.length} languages: ${NAPI_LANGUAGES.join(", ")}`)
|
|
87
57
|
|
|
88
58
|
return lines.join("\n")
|
|
89
59
|
}
|
|
@@ -27,9 +27,6 @@ export const CLI_LANGUAGES = [
|
|
|
27
27
|
"yaml",
|
|
28
28
|
] as const
|
|
29
29
|
|
|
30
|
-
// NAPI supported languages (5 total - native bindings)
|
|
31
|
-
export const NAPI_LANGUAGES = ["html", "javascript", "tsx", "css", "typescript"] as const
|
|
32
|
-
|
|
33
30
|
export const DEFAULT_TIMEOUT_MS = 300_000
|
|
34
31
|
export const DEFAULT_MAX_OUTPUT_BYTES = 1 * 1024 * 1024
|
|
35
32
|
export const DEFAULT_MAX_MATCHES = 500
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { CLI_LANGUAGES
|
|
1
|
+
import type { CLI_LANGUAGES } from "./constants"
|
|
2
2
|
|
|
3
3
|
export type CliLanguage = (typeof CLI_LANGUAGES)[number]
|
|
4
|
-
export type NapiLanguage = (typeof NAPI_LANGUAGES)[number]
|
|
5
4
|
|
|
6
5
|
export interface Position {
|
|
7
6
|
line: number
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { expect, test } from "bun:test"
|
|
2
|
+
import type { ToolContext } from "@opencode-ai/plugin/tool"
|
|
3
|
+
|
|
4
|
+
import { createSkillMcpTool } from "./tools"
|
|
5
|
+
|
|
6
|
+
test("skill_mcp falls back to enabled builtin MCP when skill MCP is absent", async () => {
|
|
7
|
+
let callCaptured: { serverName: string; toolName: string } | null = null
|
|
8
|
+
|
|
9
|
+
const toolDef = createSkillMcpTool({
|
|
10
|
+
manager: {
|
|
11
|
+
async callTool(info, _context, toolName) {
|
|
12
|
+
callCaptured = { serverName: info.serverName, toolName }
|
|
13
|
+
return { ok: true }
|
|
14
|
+
},
|
|
15
|
+
async readResource() {
|
|
16
|
+
return { ok: true }
|
|
17
|
+
},
|
|
18
|
+
async getPrompt() {
|
|
19
|
+
return { ok: true }
|
|
20
|
+
},
|
|
21
|
+
} as any,
|
|
22
|
+
getLoadedSkills: () => [],
|
|
23
|
+
getSessionID: () => "session-test",
|
|
24
|
+
builtinMcp: {
|
|
25
|
+
firecrawl: {
|
|
26
|
+
enabled: true,
|
|
27
|
+
type: "local",
|
|
28
|
+
command: ["node", "firecrawl.mjs"],
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const result = await toolDef.execute(
|
|
34
|
+
{
|
|
35
|
+
mcp_name: "firecrawl",
|
|
36
|
+
tool_name: "firecrawl_search",
|
|
37
|
+
arguments: { query: "test" },
|
|
38
|
+
} as any,
|
|
39
|
+
{ sessionID: "session-test" } as ToolContext,
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
expect(callCaptured).toEqual({ serverName: "firecrawl", toolName: "firecrawl_search" })
|
|
43
|
+
expect(result).toContain("\"ok\": true")
|
|
44
|
+
})
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/config/models.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export declare const MODEL_ROLE_GUIDE: readonly ["fast: cheap/default for bounded helpers, researcher-style scans, platform chores", "mid: balanced default for steady execution/review work", "high: stronger general-purpose model for primary implementation and planning", "ultrahigh: highest-cost/high-accuracy slot for hard architecture or critical decisions", "vision: preferred for UI/media/multimodal interpretation and visual work", "reasoning: preferred for deeper multi-step reasoning when latency/cost are acceptable"];
|
|
2
|
-
export declare const PROVIDER_MODEL_RULES: readonly ["openai: use `openai/<model>` for direct OpenAI calls, e.g. `openai/gpt-5` or `openai/o1`", "anthropic: use `anthropic/<model>`, e.g. `anthropic/claude-3.5-sonnet`", "deepseek: use `deepseek/<model>` when connected directly", "glm: use `z-ai/<model>` or the provider id exposed by your gateway/client", "minimax: use `minimax/<model>`", "qwen: use `qwen/<model>`", "ollama: use the native local model id in Ollama config, e.g. `qwen3.5:4b`", "openrouter: use `openrouter/<vendor>/<model>`, e.g. `openrouter/anthropic/claude-3.5-sonnet`", "rule: store fully qualified model ids in config; avoid local aliases like `fast`, `sonnet`, or provider-less ids"];
|
|
3
|
-
export declare const MODEL_PRESETS: {
|
|
4
|
-
readonly fast: "openrouter/google/gemini-2.0-flash";
|
|
5
|
-
readonly mid: "openrouter/anthropic/claude-3.5-sonnet";
|
|
6
|
-
readonly high: "openrouter/anthropic/claude-3.5-opus";
|
|
7
|
-
readonly ultrahigh: "openrouter/openai/gpt-4o";
|
|
8
|
-
readonly vision: "openrouter/google/gemini-2.0-pro-exp-02-05";
|
|
9
|
-
readonly reasoning: "openrouter/openai/o1";
|
|
10
|
-
readonly strategist: "openrouter/z-ai/glm-5.1";
|
|
11
|
-
readonly critic: "openrouter/qwen/qwen2.5-72b-instruct";
|
|
12
|
-
readonly writing: "openrouter/kimi/kimi-latest";
|
|
13
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { WebsearchClient } from "./types.ts";
|
|
2
|
-
type GeminiChunkWeb = {
|
|
3
|
-
title?: string;
|
|
4
|
-
uri?: string;
|
|
5
|
-
};
|
|
6
|
-
type GeminiChunk = {
|
|
7
|
-
web?: GeminiChunkWeb;
|
|
8
|
-
};
|
|
9
|
-
type GeminiSupportSegment = {
|
|
10
|
-
startIndex?: number;
|
|
11
|
-
endIndex?: number;
|
|
12
|
-
};
|
|
13
|
-
type GeminiSupport = {
|
|
14
|
-
segment?: GeminiSupportSegment;
|
|
15
|
-
groundingChunkIndices?: number[];
|
|
16
|
-
};
|
|
17
|
-
type GeminiMetadata = {
|
|
18
|
-
groundingChunks?: GeminiChunk[];
|
|
19
|
-
groundingSupports?: GeminiSupport[];
|
|
20
|
-
};
|
|
21
|
-
type GeminiTextPart = {
|
|
22
|
-
text?: string;
|
|
23
|
-
thought?: unknown;
|
|
24
|
-
};
|
|
25
|
-
type GeminiContent = {
|
|
26
|
-
role?: string;
|
|
27
|
-
parts?: GeminiTextPart[];
|
|
28
|
-
};
|
|
29
|
-
type GeminiCandidate = {
|
|
30
|
-
content?: GeminiContent;
|
|
31
|
-
groundingMetadata?: GeminiMetadata;
|
|
32
|
-
};
|
|
33
|
-
type GeminiGenerateContentResponse = {
|
|
34
|
-
candidates?: GeminiCandidate[];
|
|
35
|
-
};
|
|
36
|
-
export declare function formatWebSearchResponse(response: GeminiGenerateContentResponse, query: string): string;
|
|
37
|
-
export declare function createGoogleWebsearchClient(model: string): WebsearchClient;
|
|
38
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { type Plugin } from "@opencode-ai/plugin";
|
|
2
|
-
import type { GetAuth } from "./types";
|
|
3
|
-
export declare const GOOGLE_PROVIDER_ID = "google";
|
|
4
|
-
export declare const OPENAI_PROVIDER_ID = "openai";
|
|
5
|
-
export declare const OPENROUTER_PROVIDER_ID = "openrouter";
|
|
6
|
-
type SelectedProviderID = typeof GOOGLE_PROVIDER_ID | typeof OPENAI_PROVIDER_ID | typeof OPENROUTER_PROVIDER_ID;
|
|
7
|
-
export declare function registerGetAuth(providerID: string, getAuth: GetAuth): void;
|
|
8
|
-
export declare function resolveGetAuth(providerID: string): GetAuth | undefined;
|
|
9
|
-
type SelectedWebsearchConfig = {
|
|
10
|
-
providerID: SelectedProviderID;
|
|
11
|
-
model: string;
|
|
12
|
-
};
|
|
13
|
-
export type WebsearchCitedFallback = SelectedWebsearchConfig;
|
|
14
|
-
declare const WebsearchCitedPlugin: (_ctx?: unknown, fallback?: WebsearchCitedFallback) => Promise<any>;
|
|
15
|
-
export declare const WebsearchCitedGooglePlugin: Plugin;
|
|
16
|
-
export declare const WebsearchCitedOpenAIPlugin: Plugin;
|
|
17
|
-
export default WebsearchCitedPlugin;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { WebsearchClient } from "./types.ts";
|
|
2
|
-
export type OpenAIWebsearchConfig = {
|
|
3
|
-
reasoningEffort?: string;
|
|
4
|
-
reasoningSummary?: string;
|
|
5
|
-
textVerbosity?: string;
|
|
6
|
-
store?: boolean;
|
|
7
|
-
include?: string[];
|
|
8
|
-
};
|
|
9
|
-
export declare function createOpenAIWebsearchClient(model: string, config: OpenAIWebsearchConfig): WebsearchClient;
|