@hiai-gg/hiai-opencode 0.1.5 → 0.1.7

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.
Files changed (180) hide show
  1. package/.env.example +21 -8
  2. package/AGENTS.md +60 -6
  3. package/ARCHITECTURE.md +6 -3
  4. package/LICENSE.md +0 -1
  5. package/README.md +113 -33
  6. package/assets/cli/hiai-opencode.mjs +668 -7
  7. package/assets/mcp/mempalace.mjs +159 -25
  8. package/config/hiai-opencode.schema.json +29 -3
  9. package/dist/agents/agent-skills.d.ts +7 -0
  10. package/dist/agents/bob/default.d.ts +1 -0
  11. package/dist/agents/bob/gemini.d.ts +1 -0
  12. package/dist/agents/bob/gpt-pro.d.ts +1 -0
  13. package/dist/agents/brainstormer.d.ts +7 -0
  14. package/dist/agents/coder/gpt-codex.d.ts +1 -1
  15. package/dist/agents/coder/gpt-pro.d.ts +1 -0
  16. package/dist/agents/coder/gpt.d.ts +2 -1
  17. package/dist/agents/designer.d.ts +7 -0
  18. package/dist/agents/dynamic-agent-core-sections.d.ts +4 -1
  19. package/dist/agents/dynamic-agent-prompt-builder.d.ts +1 -1
  20. package/dist/agents/strategist/gemini.d.ts +1 -0
  21. package/dist/agents/strategist/gpt.d.ts +1 -0
  22. package/dist/agents/types.d.ts +3 -1
  23. package/dist/config/index.d.ts +0 -1
  24. package/dist/config/platform-schema.d.ts +34 -6
  25. package/dist/config/schema/commands.d.ts +1 -0
  26. package/dist/config/schema/hooks.d.ts +0 -2
  27. package/dist/config/schema/index.d.ts +0 -2
  28. package/dist/config/schema/oh-my-opencode-config.d.ts +1 -9
  29. package/dist/config/types.d.ts +4 -4
  30. package/dist/create-hooks.d.ts +0 -2
  31. package/dist/features/builtin-commands/templates/doctor.d.ts +1 -0
  32. package/dist/features/builtin-commands/types.d.ts +1 -1
  33. package/dist/features/builtin-skills/skills/hiai-opencode-setup.d.ts +2 -0
  34. package/dist/features/builtin-skills/skills/index.d.ts +2 -0
  35. package/dist/features/builtin-skills/skills/website-copywriting.d.ts +2 -0
  36. package/dist/hooks/agent-usage-reminder/constants.d.ts +1 -1
  37. package/dist/hooks/index.d.ts +0 -2
  38. package/dist/hooks/keyword-detector/ultrawork/default.d.ts +1 -1
  39. package/dist/hooks/keyword-detector/ultrawork/gemini.d.ts +1 -1
  40. package/dist/hooks/keyword-detector/ultrawork/gpt.d.ts +1 -1
  41. package/dist/hooks/keyword-detector/ultrawork/planner.d.ts +1 -1
  42. package/dist/index.js +7719 -153698
  43. package/dist/mcp/index.d.ts +0 -1
  44. package/dist/mcp/registry.d.ts +1 -1
  45. package/dist/plugin/hooks/create-core-hooks.d.ts +0 -2
  46. package/dist/plugin/hooks/create-session-hooks.d.ts +1 -3
  47. package/dist/plugin/startup-diagnostics.d.ts +1 -0
  48. package/dist/shared/logger.d.ts +2 -0
  49. package/dist/shared/mcp-static-export.d.ts +22 -0
  50. package/dist/shared/mode-routing.d.ts +6 -0
  51. package/dist/tools/ast-grep/constants.d.ts +1 -1
  52. package/dist/tools/ast-grep/environment-check.d.ts +1 -5
  53. package/dist/tools/ast-grep/language-support.d.ts +0 -1
  54. package/dist/tools/ast-grep/types.d.ts +1 -2
  55. package/dist/tools/delegate-task/git-categories.d.ts +2 -0
  56. package/dist/tools/delegate-task/sub-agent.d.ts +2 -0
  57. package/dist/tools/skill-mcp/constants.d.ts +1 -1
  58. package/hiai-opencode.json +50 -19
  59. package/package.json +10 -5
  60. package/src/agents/agent-skills.ts +70 -0
  61. package/src/agents/bob/default.ts +7 -1
  62. package/src/agents/bob/gemini.ts +1 -0
  63. package/src/agents/bob/gpt-pro.ts +3 -1
  64. package/src/agents/bob.ts +3 -0
  65. package/src/agents/brainstormer.ts +72 -0
  66. package/src/agents/builtin-agents.ts +59 -3
  67. package/src/agents/coder/gpt-codex.ts +5 -3
  68. package/src/agents/coder/gpt-pro.ts +4 -2
  69. package/src/agents/coder/gpt.ts +3 -1
  70. package/src/agents/critic/agent.ts +1 -0
  71. package/src/agents/designer.ts +70 -0
  72. package/src/agents/dynamic-agent-category-skills-guide.ts +6 -0
  73. package/src/agents/dynamic-agent-core-sections.ts +36 -0
  74. package/src/agents/dynamic-agent-prompt-builder.ts +1 -0
  75. package/src/agents/guard/default.ts +1 -0
  76. package/src/agents/guard/gemini.ts +1 -0
  77. package/src/agents/guard/gpt.ts +1 -0
  78. package/src/agents/platform-manager.ts +17 -1
  79. package/src/agents/prompt-library/platform.ts +34 -0
  80. package/src/agents/researcher.ts +1 -0
  81. package/src/agents/strategist/gemini.ts +1 -0
  82. package/src/agents/strategist/gpt.ts +1 -0
  83. package/src/agents/types.ts +4 -1
  84. package/src/agents/ui.ts +1 -0
  85. package/src/config/defaults.ts +45 -13
  86. package/src/config/index.ts +0 -1
  87. package/src/config/model-slots-and-export.test.ts +73 -0
  88. package/src/config/platform-schema.ts +3 -3
  89. package/src/config/schema/commands.ts +1 -0
  90. package/src/config/schema/hooks.ts +0 -2
  91. package/src/config/schema/index.ts +0 -2
  92. package/src/config/schema/oh-my-opencode-config.ts +0 -5
  93. package/src/config/types.ts +4 -4
  94. package/src/features/builtin-commands/commands.ts +7 -0
  95. package/src/features/builtin-commands/templates/doctor.ts +43 -0
  96. package/src/features/builtin-commands/types.ts +1 -1
  97. package/src/features/builtin-skills/skills/hiai-opencode-setup.ts +69 -0
  98. package/src/features/builtin-skills/skills/index.ts +2 -0
  99. package/src/features/builtin-skills/skills/website-copywriting.ts +41 -0
  100. package/src/features/builtin-skills/skills.test.ts +8 -0
  101. package/src/features/builtin-skills/skills.ts +12 -1
  102. package/src/features/skill-mcp-manager/AGENTS.md +1 -1
  103. package/src/hooks/agent-usage-reminder/constants.ts +4 -4
  104. package/src/hooks/index.ts +0 -2
  105. package/src/hooks/keyword-detector/ultrawork/default.ts +18 -18
  106. package/src/hooks/keyword-detector/ultrawork/gemini.ts +21 -21
  107. package/src/hooks/keyword-detector/ultrawork/gpt.ts +6 -8
  108. package/src/hooks/keyword-detector/ultrawork/planner.ts +5 -5
  109. package/src/index.ts +8 -78
  110. package/src/internals/plugins/subtask2/commands/manifest.ts +2 -6
  111. package/src/internals/plugins/subtask2/hooks/command-hooks.ts +2 -2
  112. package/src/internals/plugins/subtask2/hooks/message-hooks.ts +1 -1
  113. package/src/internals/plugins/subtask2/parsing/parallel.ts +13 -10
  114. package/src/mcp/index.ts +0 -1
  115. package/src/mcp/registry.ts +27 -0
  116. package/src/plugin/chat-message.ts +0 -2
  117. package/src/plugin/hooks/create-session-hooks.ts +0 -17
  118. package/src/plugin/startup-diagnostics.ts +27 -0
  119. package/src/plugin-handlers/agent-config-handler.ts +3 -2
  120. package/src/plugin-handlers/mcp-config-handler.test.ts +63 -0
  121. package/src/plugin-handlers/mcp-config-handler.ts +29 -14
  122. package/src/plugin-handlers/strategist-agent-config-builder.ts +1 -1
  123. package/src/shared/agent-display-names.test.ts +9 -0
  124. package/src/shared/agent-display-names.ts +5 -0
  125. package/src/shared/log-legacy-plugin-startup-warning.ts +6 -8
  126. package/src/shared/logger.ts +8 -0
  127. package/src/shared/mcp-static-export.ts +119 -0
  128. package/src/shared/migration/agent-names.ts +8 -0
  129. package/src/shared/migration/hook-names.ts +1 -1
  130. package/src/shared/mode-routing.test.ts +88 -0
  131. package/src/shared/mode-routing.ts +30 -0
  132. package/src/shared/startup-diagnostics.ts +6 -7
  133. package/src/tools/ast-grep/constants.ts +1 -1
  134. package/src/tools/ast-grep/environment-check.ts +2 -32
  135. package/src/tools/ast-grep/language-support.ts +0 -3
  136. package/src/tools/ast-grep/types.ts +1 -2
  137. package/src/tools/call-omo-agent/tools.ts +11 -4
  138. package/src/tools/delegate-task/anthropic-categories.ts +3 -3
  139. package/src/tools/delegate-task/builtin-categories.ts +2 -0
  140. package/src/tools/delegate-task/categories.test.ts +87 -0
  141. package/src/tools/delegate-task/category-resolver.ts +8 -9
  142. package/src/tools/delegate-task/git-categories.ts +30 -0
  143. package/src/tools/delegate-task/model-string-parser.test.ts +90 -0
  144. package/src/tools/delegate-task/openai-categories.ts +26 -22
  145. package/src/tools/delegate-task/sub-agent.ts +10 -0
  146. package/src/tools/delegate-task/subagent-discovery.test.ts +123 -0
  147. package/src/tools/delegate-task/subagent-resolver.ts +18 -1
  148. package/src/tools/skill-mcp/constants.ts +1 -1
  149. package/src/tools/skill-mcp/tools.test.ts +44 -0
  150. package/dist/ast-grep-napi.win32-x64-msvc-67c0y8nc.node +0 -0
  151. package/dist/config/loader.test.d.ts +0 -1
  152. package/dist/config/models.d.ts +0 -13
  153. package/dist/config/schema/websearch.d.ts +0 -13
  154. package/dist/hooks/no-bob-gpt/hook.d.ts +0 -16
  155. package/dist/hooks/no-bob-gpt/index.d.ts +0 -1
  156. package/dist/hooks/no-coder-non-gpt/hook.d.ts +0 -20
  157. package/dist/hooks/no-coder-non-gpt/index.d.ts +0 -1
  158. package/dist/internals/plugins/websearch-cited/google.d.ts +0 -38
  159. package/dist/internals/plugins/websearch-cited/index.d.ts +0 -17
  160. package/dist/internals/plugins/websearch-cited/openai.d.ts +0 -9
  161. package/dist/internals/plugins/websearch-cited/openrouter.d.ts +0 -2
  162. package/dist/internals/plugins/websearch-cited/types.d.ts +0 -5
  163. package/dist/mcp/grep-app.d.ts +0 -6
  164. package/dist/mcp/omo-mcp-index.d.ts +0 -10
  165. package/dist/mcp/websearch.d.ts +0 -11
  166. package/src/config/schema/websearch.ts +0 -15
  167. package/src/hooks/no-bob-gpt/hook.ts +0 -56
  168. package/src/hooks/no-bob-gpt/index.ts +0 -1
  169. package/src/hooks/no-coder-non-gpt/hook.ts +0 -67
  170. package/src/hooks/no-coder-non-gpt/index.ts +0 -1
  171. package/src/internals/plugins/websearch-cited/LICENSE +0 -214
  172. package/src/internals/plugins/websearch-cited/codex_prompt.txt +0 -79
  173. package/src/internals/plugins/websearch-cited/google.ts +0 -749
  174. package/src/internals/plugins/websearch-cited/index.ts +0 -306
  175. package/src/internals/plugins/websearch-cited/openai.ts +0 -407
  176. package/src/internals/plugins/websearch-cited/openrouter.ts +0 -190
  177. package/src/internals/plugins/websearch-cited/types.ts +0 -7
  178. package/src/mcp/grep-app.ts +0 -6
  179. package/src/mcp/omo-mcp-index.ts +0 -30
  180. package/src/mcp/websearch.ts +0 -44
@@ -1,190 +0,0 @@
1
- import type { Auth as ProviderAuth } from "@opencode-ai/sdk";
2
- import type { GetAuth, WebsearchClient } from "./types.ts";
3
-
4
- type OpenRouterPluginWeb = {
5
- id: "web";
6
- search_prompt: string;
7
- };
8
-
9
- type OpenRouterResponsesRequest = {
10
- model: string;
11
- input: string;
12
- plugins: OpenRouterPluginWeb[];
13
- store: false;
14
- stream: false;
15
- };
16
-
17
- type OpenRouterUrlCitationAnnotation = {
18
- type?: "url_citation";
19
- url?: string;
20
- title?: string;
21
- start_index?: number;
22
- end_index?: number;
23
- };
24
-
25
- type OpenRouterResponsesTextContent = {
26
- type?: "output_text";
27
- text?: string;
28
- annotations?: OpenRouterUrlCitationAnnotation[];
29
- };
30
-
31
- type OpenRouterResponsesMessage = {
32
- type?: "message";
33
- role?: string;
34
- content?: OpenRouterResponsesTextContent[];
35
- };
36
-
37
- type OpenRouterResponsesBody = {
38
- output_text?: string;
39
- output?: OpenRouterResponsesMessage[];
40
- };
41
-
42
- const OPENROUTER_RESPONSES_ENDPOINT = "https://openrouter.ai/api/v1/responses";
43
-
44
- function buildWebSearchUserPrompt(query: string): string {
45
- const normalized = query.trim();
46
- return `perform web search on "${normalized}". Return results with inline citations (**only** source index like [1], no URL in the answer) and end with a Sources list of URLs.`;
47
- }
48
-
49
- function getApiKey(auth: ProviderAuth): string {
50
- if (auth.type !== "api") {
51
- throw new Error("OpenRouter only supports API key authentication");
52
- }
53
-
54
- const key = auth.key.trim();
55
- if (!key) {
56
- throw new Error("Missing OpenRouter API key");
57
- }
58
- return key;
59
- }
60
-
61
- function extractOutputText(payload: unknown): string | undefined {
62
- if (!payload || typeof payload !== "object") {
63
- return undefined;
64
- }
65
-
66
- const root = payload as OpenRouterResponsesBody;
67
-
68
- const direct = root.output_text;
69
- if (typeof direct === "string" && direct.trim() !== "") {
70
- return direct;
71
- }
72
-
73
- const output = root.output;
74
- if (!Array.isArray(output) || output.length === 0) {
75
- return undefined;
76
- }
77
-
78
- let combined = "";
79
-
80
- for (const item of output) {
81
- if (item.type !== "message") {
82
- continue;
83
- }
84
-
85
- const content = item.content;
86
- if (!Array.isArray(content)) {
87
- continue;
88
- }
89
-
90
- for (const part of content) {
91
- if (part.type !== "output_text") {
92
- continue;
93
- }
94
-
95
- const text = part.text;
96
- if (typeof text === "string") {
97
- combined += text;
98
- }
99
- }
100
- }
101
-
102
- return combined || undefined;
103
- }
104
-
105
- async function runOpenRouterWebSearch(options: {
106
- model: string;
107
- query: string;
108
- abortSignal: AbortSignal;
109
- auth: ProviderAuth;
110
- }): Promise<string> {
111
- const normalizedModel = options.model.trim();
112
- if (!normalizedModel) {
113
- throw new Error("Invalid OpenRouter web search model");
114
- }
115
-
116
- const normalizedQuery = options.query.trim();
117
- if (!normalizedQuery) {
118
- throw new Error("Query must not be empty");
119
- }
120
-
121
- const apiKey = getApiKey(options.auth);
122
-
123
- const body: OpenRouterResponsesRequest = {
124
- model: normalizedModel,
125
- input: buildWebSearchUserPrompt(normalizedQuery),
126
- plugins: [
127
- {
128
- id: "web",
129
- search_prompt: buildWebSearchUserPrompt(normalizedQuery),
130
- },
131
- ],
132
- store: false,
133
- stream: false,
134
- };
135
-
136
- const response = await fetch(OPENROUTER_RESPONSES_ENDPOINT, {
137
- method: "POST",
138
- headers: {
139
- Authorization: `Bearer ${apiKey}`,
140
- "Content-Type": "application/json",
141
- },
142
- body: JSON.stringify(body),
143
- signal: options.abortSignal,
144
- });
145
-
146
- if (!response.ok) {
147
- const text = await response.text().catch(() => "");
148
- const details = text.trim() !== "" ? ` | responseBody=${text}` : "";
149
- throw new Error(
150
- `status=${response.status} | url=${OPENROUTER_RESPONSES_ENDPOINT} | requestBody=${JSON.stringify(body)}${details}`
151
- );
152
- }
153
-
154
- const payload: unknown = await response.json();
155
- const outputText = extractOutputText(payload);
156
-
157
- if (!outputText || !outputText.trim()) {
158
- return `Web search completed for "${normalizedQuery}", but no results were returned.`;
159
- }
160
-
161
- return outputText;
162
- }
163
-
164
- export function createOpenRouterWebsearchClient(model: string): WebsearchClient {
165
- const normalizedModel = model.trim();
166
- if (!normalizedModel) {
167
- throw new Error("Invalid OpenRouter web search model");
168
- }
169
-
170
- return {
171
- async search(query, abortSignal, getAuth: GetAuth) {
172
- const normalizedQuery = query.trim();
173
- if (!normalizedQuery) {
174
- throw new Error("Query must not be empty");
175
- }
176
-
177
- const auth = await getAuth();
178
- if (!auth) {
179
- throw new Error('Missing auth for provider "openrouter"');
180
- }
181
-
182
- return runOpenRouterWebSearch({
183
- model: normalizedModel,
184
- query: normalizedQuery,
185
- abortSignal,
186
- auth,
187
- });
188
- },
189
- };
190
- }
@@ -1,7 +0,0 @@
1
- import type { Auth as ProviderAuth } from "@opencode-ai/sdk";
2
-
3
- export type GetAuth = () => Promise<ProviderAuth | undefined>;
4
-
5
- export interface WebsearchClient {
6
- search(query: string, abortSignal: AbortSignal, getAuth: GetAuth): Promise<string>;
7
- }
@@ -1,6 +0,0 @@
1
- export const grep_app = {
2
- type: "remote" as const,
3
- url: "https://mcp.grep.app",
4
- enabled: true,
5
- oauth: false as const,
6
- }
@@ -1,30 +0,0 @@
1
- import { createWebsearchConfig } from "./websearch"
2
- import { grep_app } from "./grep-app"
3
- import type { HiaiOpenCodeConfig } from "../config/schema"
4
-
5
- export { McpNameSchema, type McpName } from "./types"
6
-
7
- type RemoteMcpConfig = {
8
- type: "remote"
9
- url: string
10
- enabled: boolean
11
- headers?: Record<string, string>
12
- oauth?: false
13
- }
14
-
15
- export function createBuiltinMcps(disabledMcps: string[] = [], config?: HiaiOpenCodeConfig) {
16
- const mcps: Record<string, RemoteMcpConfig> = {}
17
-
18
- if (!disabledMcps.includes("websearch")) {
19
- const websearchConfig = createWebsearchConfig(config?.websearch)
20
- if (websearchConfig) {
21
- mcps.websearch = websearchConfig
22
- }
23
- }
24
-
25
- if (!disabledMcps.includes("grep_app")) {
26
- mcps.grep_app = grep_app
27
- }
28
-
29
- return mcps
30
- }
@@ -1,44 +0,0 @@
1
- import type { WebsearchConfig } from "../config/schema"
2
- import { log } from "../shared/logger"
3
-
4
- type RemoteMcpConfig = {
5
- type: "remote"
6
- url: string
7
- enabled: boolean
8
- headers?: Record<string, string>
9
- oauth?: false
10
- }
11
-
12
- export function createWebsearchConfig(config?: WebsearchConfig): RemoteMcpConfig | undefined {
13
- const provider = config?.provider || "exa"
14
-
15
- if (provider === "tavily") {
16
- const tavilyKey = process.env.TAVILY_API_KEY
17
- if (!tavilyKey) {
18
- log("[websearch] Tavily API key not found, skipping websearch MCP")
19
- return undefined
20
- }
21
-
22
- return {
23
- type: "remote" as const,
24
- url: "https://mcp.tavily.com/mcp/",
25
- enabled: true,
26
- headers: {
27
- Authorization: `Bearer ${tavilyKey}`,
28
- },
29
- oauth: false as const,
30
- }
31
- }
32
-
33
- return {
34
- type: "remote" as const,
35
- url: process.env.EXA_API_KEY
36
- ? `https://mcp.exa.ai/mcp?tools=web_search_exa&exaApiKey=${encodeURIComponent(process.env.EXA_API_KEY)}`
37
- : "https://mcp.exa.ai/mcp?tools=web_search_exa",
38
- enabled: true,
39
- ...(process.env.EXA_API_KEY ? { headers: { "x-api-key": process.env.EXA_API_KEY } } : {}),
40
- oauth: false as const,
41
- }
42
- }
43
-
44
- export const websearch = createWebsearchConfig()