@hiai-gg/hiai-opencode 0.1.2 → 0.1.3

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.
@@ -0,0 +1,14 @@
1
+ import type { McpServerConfig } from "../config/types.js";
2
+ export type HiaiMcpName = "playwright" | "stitch" | "sequential-thinking" | "firecrawl" | "rag" | "context7" | "mempalace";
3
+ export type HiaiMcpInstallKind = "bundled" | "npm" | "python" | "remote" | "user-service";
4
+ export interface HiaiMcpRegistryEntry {
5
+ name: HiaiMcpName;
6
+ enabledByDefault: boolean;
7
+ install: HiaiMcpInstallKind;
8
+ requiredEnv?: string[];
9
+ optionalEnv?: string[];
10
+ config: McpServerConfig;
11
+ }
12
+ export declare const HIAI_MCP_REGISTRY: Record<HiaiMcpName, HiaiMcpRegistryEntry>;
13
+ export declare function createDefaultMcpConfig(): Record<HiaiMcpName, McpServerConfig>;
14
+ export declare function getKnownMcpNames(): HiaiMcpName[];
@@ -1,7 +1,13 @@
1
1
  import { z } from "zod";
2
2
  export declare const McpNameSchema: z.ZodEnum<{
3
3
  websearch: "websearch";
4
+ stitch: "stitch";
5
+ firecrawl: "firecrawl";
6
+ playwright: "playwright";
7
+ "sequential-thinking": "sequential-thinking";
8
+ rag: "rag";
4
9
  context7: "context7";
10
+ mempalace: "mempalace";
5
11
  grep_app: "grep_app";
6
12
  }>;
7
13
  export type McpName = z.infer<typeof McpNameSchema>;
@@ -1,5 +1,5 @@
1
1
  {
2
- "_description": "hiai-opencode user configuration template. Public display names (shown to users): Bob, Coder, Strategist, Guard, Critic, Designer, Researcher, Manager, Brainstormer, Vision. Config keys (used in this file and in code) are: bob, coder, strategist, guard, critic, designer, researcher, manager, brainstormer, vision. Internal-only keys (hidden from normal users): sub, agent-skills. Source defaults: src/config/defaults.ts and src/config/models.ts.",
2
+ "_description": "hiai-opencode user configuration template. Public display names (shown to users): Bob, Coder, Strategist, Guard, Critic, Designer, Researcher, Manager, Brainstormer, Vision. Config keys (used in this file and in code) are: bob, coder, strategist, guard, critic, designer, researcher, manager, brainstormer, vision. Internal-only keys (hidden from normal users): sub, agent-skills. MCP enable/disable lives in the mcp object below; default MCP definitions live in src/mcp/registry.ts. Source model defaults: src/config/defaults.ts and src/config/models.ts.",
3
3
  "$schema": "./config/hiai-opencode.schema.json",
4
4
  "agents": {
5
5
  "bob": { "model": "openrouter/anthropic/claude-3.5-opus" },
@@ -55,4 +55,4 @@
55
55
  "subtask2": {
56
56
  "replace_generic": true
57
57
  }
58
- }
58
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hiai-gg/hiai-opencode",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Unified OpenCode plugin — canonical 12-agent model with bundled skills, MCP integrations, LSP, and permissions in one install.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,25 +1,10 @@
1
1
  /**
2
2
  * Default config values for hiai-opencode
3
3
  */
4
- import { join } from "node:path";
5
4
  import type { HiaiOpencodeConfig } from "./types.js";
6
5
  import { MODEL_PRESETS } from "./models.js";
7
-
8
- function resolveAssetScript(...segments: string[]): string {
9
- return join(import.meta.dirname, "..", "assets", ...segments);
10
- }
11
-
12
- function createNpmPackageCommand(pkg: string, ...args: string[]): string[] {
13
- return ["node", resolveAssetScript("runtime", "npm-package-runner.mjs"), pkg, ...args];
14
- }
15
-
16
- function createUpstreamNpxCommand(pkg: string, ...args: string[]): string[] {
17
- if (process.platform === "win32") {
18
- return ["cmd", "/c", "npx", "-y", pkg, ...args];
19
- }
20
-
21
- return ["npx", "-y", pkg, ...args];
22
- }
6
+ import { createDefaultMcpConfig } from "../mcp/registry.js";
7
+ import { join } from "node:path";
23
8
 
24
9
  export const defaultConfig: HiaiOpencodeConfig = {
25
10
  agents: {
@@ -54,49 +39,7 @@ export const defaultConfig: HiaiOpencodeConfig = {
54
39
  },
55
40
  categoryRequirements: {},
56
41
 
57
- mcp: {
58
- playwright: {
59
- enabled: true,
60
- command: createNpmPackageCommand("@playwright/mcp@latest"),
61
- timeout: 600000,
62
- },
63
- stitch: {
64
- enabled: true,
65
- type: "remote",
66
- url: "https://stitch.googleapis.com/mcp",
67
- headers: { "X-Goog-Api-Key": "{env:STITCH_AI_API_KEY}" },
68
- timeout: 600000,
69
- },
70
- "sequential-thinking": {
71
- enabled: true,
72
- command: createUpstreamNpxCommand("@modelcontextprotocol/server-sequential-thinking"),
73
- timeout: 600000,
74
- },
75
- firecrawl: {
76
- enabled: true,
77
- command: createUpstreamNpxCommand("firecrawl-mcp"),
78
- timeout: 600000,
79
- environment: { FIRECRAWL_API_KEY: "{env:FIRECRAWL_API_KEY}" },
80
- },
81
- rag: {
82
- enabled: true,
83
- type: "remote",
84
- url: "http://localhost:9002",
85
- timeout: 600000,
86
- },
87
- context7: {
88
- enabled: true,
89
- type: "remote",
90
- url: "https://mcp.context7.com/mcp",
91
- headers: { "X-API-KEY": "{env:CONTEXT7_API_KEY}" },
92
- timeout: 600000,
93
- },
94
- mempalace: {
95
- enabled: true,
96
- command: ["node", resolveAssetScript("mcp", "mempalace.mjs"), "--palace", "./.opencode/palace"],
97
- timeout: 600000,
98
- },
99
- },
42
+ mcp: createDefaultMcpConfig(),
100
43
 
101
44
  lsp: {
102
45
  typescript: {
@@ -108,11 +51,11 @@ export const defaultConfig: HiaiOpencodeConfig = {
108
51
  extensions: [".svelte"],
109
52
  },
110
53
  eslint: {
111
- command: createNpmPackageCommand("eslint-lsp", "--stdio"),
54
+ command: ["node", join(import.meta.dirname, "..", "assets", "runtime", "npm-package-runner.mjs"), "eslint-lsp", "--stdio"],
112
55
  extensions: [".js", ".jsx", ".ts", ".tsx", ".mjs", ".cjs", ".svelte"],
113
56
  },
114
57
  bash: {
115
- command: createNpmPackageCommand("bash-language-server", "start"),
58
+ command: ["node", join(import.meta.dirname, "..", "assets", "runtime", "npm-package-runner.mjs"), "bash-language-server", "start"],
116
59
  extensions: [".sh", ".bash"],
117
60
  },
118
61
  pyright: {
@@ -164,7 +164,10 @@ export function loadConfig(projectDir: string): HiaiOpencodeConfig {
164
164
  }
165
165
 
166
166
  export function resolveEnvVars(value: string): string {
167
- return value.replace(/\{env:([^}]+)\}/g, (_, key) => process.env[key] || "");
167
+ return value.replace(/\{env:([^}]+)\}/g, (_, expression) => {
168
+ const [key, fallback] = String(expression).split(":-", 2);
169
+ return process.env[key] || fallback || "";
170
+ });
168
171
  }
169
172
 
170
173
  export function resolveMcpEnv(config: HiaiOpencodeConfig): HiaiOpencodeConfig {
@@ -41,6 +41,7 @@ export const McpServerConfigSchema = z.object({
41
41
  enabled: z.boolean().default(true),
42
42
  type: z.enum(["remote", "local"]).optional(),
43
43
  url: z.string().optional(),
44
+ headers: z.record(z.string(), z.string()).optional(),
44
45
  command: z.array(z.string()).optional(),
45
46
  timeout: z.number().optional(),
46
47
  environment: z.record(z.string(), z.string()).optional(),
package/src/index.ts CHANGED
@@ -56,6 +56,7 @@ function configureBundledBunPtyLibrary(): void {
56
56
  const candidates = [
57
57
  join(import.meta.dirname, "..", "node_modules", "bun-pty", "rust-pty", "target", "release", libraryName),
58
58
  join(import.meta.dirname, "..", "..", "bun-pty", "rust-pty", "target", "release", libraryName),
59
+ join(import.meta.dirname, "..", "..", "..", "bun-pty", "rust-pty", "target", "release", libraryName),
59
60
  ]
60
61
 
61
62
  const resolved = candidates.find((candidate) => existsSync(candidate))
package/src/mcp/index.ts CHANGED
@@ -1,45 +1,12 @@
1
1
  export { createBuiltinMcps } from "./omo-mcp-index"
2
2
  export { McpNameSchema, type McpName, type AnyMcpName } from "./types"
3
3
 
4
- import { existsSync } from "node:fs";
5
- import { join } from "node:path";
6
4
  import type { McpServerConfig } from "../config/types.js";
7
5
  import { resolveEnvVars } from "../config/loader.js";
8
6
 
9
- const ASSETS_DIR = join(import.meta.dirname || __dirname, "..", "assets", "mcp");
10
-
11
- function resolveBundledMcp(name: string): string {
12
- const script = join(ASSETS_DIR, name);
13
- if (existsSync(script)) return script;
14
- return "";
15
- }
16
-
17
7
  export function buildMcpConfig(mcp: Record<string, McpServerConfig>): Record<string, unknown> {
18
8
  const result: Record<string, unknown> = {};
19
9
 
20
- const defaults: Record<string, McpServerConfig> = {
21
- rag: {
22
- enabled: true,
23
- type: "local",
24
- command: ["node", resolveBundledMcp("rag.mjs")].filter(Boolean),
25
- environment: {
26
- OPENCODE_RAG_URL: "http://localhost:9002/tools/search",
27
- },
28
- },
29
- mempalace: {
30
- enabled: true,
31
- type: "local",
32
- command: ["node", resolveBundledMcp("mempalace.mjs"), "--palace", "./.opencode/palace"].filter(Boolean),
33
- timeout: 60000,
34
- },
35
- };
36
-
37
- for (const [name, server] of Object.entries(defaults)) {
38
- if (!(name in mcp) && server.command && server.command.length >= 2) {
39
- mcp[name] = server;
40
- }
41
- }
42
-
43
10
  for (const [name, server] of Object.entries(mcp)) {
44
11
  if (!server.enabled) continue;
45
12
 
@@ -1,5 +1,4 @@
1
1
  import { createWebsearchConfig } from "./websearch"
2
- import { context7 } from "./context7"
3
2
  import { grep_app } from "./grep-app"
4
3
  import type { HiaiOpenCodeConfig } from "../config/schema"
5
4
 
@@ -23,10 +22,6 @@ export function createBuiltinMcps(disabledMcps: string[] = [], config?: HiaiOpen
23
22
  }
24
23
  }
25
24
 
26
- if (!disabledMcps.includes("context7")) {
27
- mcps.context7 = context7
28
- }
29
-
30
25
  if (!disabledMcps.includes("grep_app")) {
31
26
  mcps.grep_app = grep_app
32
27
  }
@@ -0,0 +1,132 @@
1
+ import { join } from "node:path"
2
+ import type { McpServerConfig } from "../config/types.js"
3
+
4
+ export type HiaiMcpName =
5
+ | "playwright"
6
+ | "stitch"
7
+ | "sequential-thinking"
8
+ | "firecrawl"
9
+ | "rag"
10
+ | "context7"
11
+ | "mempalace"
12
+
13
+ export type HiaiMcpInstallKind = "bundled" | "npm" | "python" | "remote" | "user-service"
14
+
15
+ export interface HiaiMcpRegistryEntry {
16
+ name: HiaiMcpName
17
+ enabledByDefault: boolean
18
+ install: HiaiMcpInstallKind
19
+ requiredEnv?: string[]
20
+ optionalEnv?: string[]
21
+ config: McpServerConfig
22
+ }
23
+
24
+ function resolveAssetScript(...segments: string[]): string {
25
+ return join(import.meta.dirname, "..", "assets", ...segments)
26
+ }
27
+
28
+ function createNpmPackageCommand(pkg: string, ...args: string[]): string[] {
29
+ return ["node", resolveAssetScript("runtime", "npm-package-runner.mjs"), pkg, ...args]
30
+ }
31
+
32
+ export const HIAI_MCP_REGISTRY: Record<HiaiMcpName, HiaiMcpRegistryEntry> = {
33
+ playwright: {
34
+ name: "playwright",
35
+ enabledByDefault: true,
36
+ install: "npm",
37
+ optionalEnv: ["HIAI_PLAYWRIGHT_INSTALL_BROWSERS"],
38
+ config: {
39
+ enabled: true,
40
+ command: ["node", resolveAssetScript("mcp", "playwright.mjs")],
41
+ timeout: 600000,
42
+ },
43
+ },
44
+ stitch: {
45
+ name: "stitch",
46
+ enabledByDefault: true,
47
+ install: "remote",
48
+ requiredEnv: ["STITCH_AI_API_KEY"],
49
+ config: {
50
+ enabled: true,
51
+ type: "remote",
52
+ url: "https://stitch.googleapis.com/mcp",
53
+ headers: { "X-Goog-Api-Key": "{env:STITCH_AI_API_KEY}" },
54
+ timeout: 600000,
55
+ },
56
+ },
57
+ "sequential-thinking": {
58
+ name: "sequential-thinking",
59
+ enabledByDefault: true,
60
+ install: "npm",
61
+ config: {
62
+ enabled: true,
63
+ command: createNpmPackageCommand("@modelcontextprotocol/server-sequential-thinking"),
64
+ timeout: 600000,
65
+ },
66
+ },
67
+ firecrawl: {
68
+ name: "firecrawl",
69
+ enabledByDefault: true,
70
+ install: "npm",
71
+ requiredEnv: ["FIRECRAWL_API_KEY"],
72
+ config: {
73
+ enabled: true,
74
+ command: createNpmPackageCommand("firecrawl-mcp"),
75
+ timeout: 600000,
76
+ environment: { FIRECRAWL_API_KEY: "{env:FIRECRAWL_API_KEY}" },
77
+ },
78
+ },
79
+ rag: {
80
+ name: "rag",
81
+ enabledByDefault: true,
82
+ install: "user-service",
83
+ optionalEnv: ["OPENCODE_RAG_URL"],
84
+ config: {
85
+ enabled: true,
86
+ type: "local",
87
+ command: ["node", resolveAssetScript("mcp", "rag.mjs")],
88
+ environment: {
89
+ OPENCODE_RAG_URL: "{env:OPENCODE_RAG_URL:-http://localhost:9002/tools/search}",
90
+ },
91
+ timeout: 600000,
92
+ },
93
+ },
94
+ context7: {
95
+ name: "context7",
96
+ enabledByDefault: true,
97
+ install: "remote",
98
+ optionalEnv: ["CONTEXT7_API_KEY"],
99
+ config: {
100
+ enabled: true,
101
+ type: "remote",
102
+ url: "https://mcp.context7.com/mcp",
103
+ headers: { "X-API-KEY": "{env:CONTEXT7_API_KEY}" },
104
+ timeout: 600000,
105
+ },
106
+ },
107
+ mempalace: {
108
+ name: "mempalace",
109
+ enabledByDefault: true,
110
+ install: "python",
111
+ optionalEnv: ["MEMPALACE_PYTHON", "MEMPALACE_PALACE_PATH", "HIAI_MCP_AUTO_INSTALL"],
112
+ config: {
113
+ enabled: true,
114
+ type: "local",
115
+ command: ["node", resolveAssetScript("mcp", "mempalace.mjs"), "--palace", "./.opencode/palace"],
116
+ timeout: 600000,
117
+ },
118
+ },
119
+ }
120
+
121
+ export function createDefaultMcpConfig(): Record<HiaiMcpName, McpServerConfig> {
122
+ return Object.fromEntries(
123
+ Object.entries(HIAI_MCP_REGISTRY).map(([name, entry]) => [
124
+ name,
125
+ { ...entry.config, enabled: entry.enabledByDefault },
126
+ ]),
127
+ ) as Record<HiaiMcpName, McpServerConfig>
128
+ }
129
+
130
+ export function getKnownMcpNames(): HiaiMcpName[] {
131
+ return Object.keys(HIAI_MCP_REGISTRY) as HiaiMcpName[]
132
+ }
package/src/mcp/types.ts CHANGED
@@ -1,6 +1,16 @@
1
1
  import { z } from "zod"
2
2
 
3
- export const McpNameSchema = z.enum(["websearch", "context7", "grep_app"])
3
+ export const McpNameSchema = z.enum([
4
+ "playwright",
5
+ "stitch",
6
+ "sequential-thinking",
7
+ "firecrawl",
8
+ "rag",
9
+ "context7",
10
+ "mempalace",
11
+ "websearch",
12
+ "grep_app",
13
+ ])
4
14
 
5
15
  export type McpName = z.infer<typeof McpNameSchema>
6
16