@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.
Files changed (67) hide show
  1. package/.env.example +14 -8
  2. package/AGENTS.md +14 -5
  3. package/LICENSE.md +0 -1
  4. package/README.md +42 -23
  5. package/assets/cli/hiai-opencode.mjs +590 -7
  6. package/assets/mcp/mempalace.mjs +159 -25
  7. package/config/hiai-opencode.schema.json +13 -2
  8. package/dist/agents/dynamic-agent-core-sections.d.ts +4 -1
  9. package/dist/agents/dynamic-agent-prompt-builder.d.ts +1 -1
  10. package/dist/config/platform-schema.d.ts +2 -6
  11. package/dist/config/schema/commands.d.ts +1 -0
  12. package/dist/config/schema/oh-my-opencode-config.d.ts +1 -3
  13. package/dist/config/types.d.ts +1 -3
  14. package/dist/features/builtin-commands/templates/doctor.d.ts +1 -0
  15. package/dist/features/builtin-commands/types.d.ts +1 -1
  16. package/dist/features/builtin-skills/skills/hiai-opencode-setup.d.ts +2 -0
  17. package/dist/features/builtin-skills/skills/index.d.ts +1 -0
  18. package/dist/index.js +348 -1424
  19. package/dist/shared/mcp-static-export.d.ts +22 -0
  20. package/dist/tools/ast-grep/constants.d.ts +1 -1
  21. package/dist/tools/ast-grep/environment-check.d.ts +1 -5
  22. package/dist/tools/ast-grep/language-support.d.ts +0 -1
  23. package/dist/tools/ast-grep/types.d.ts +1 -2
  24. package/hiai-opencode.json +4 -2
  25. package/package.json +6 -4
  26. package/src/agents/bob/default.ts +6 -1
  27. package/src/agents/bob/gpt-pro.ts +1 -0
  28. package/src/agents/bob.ts +1 -0
  29. package/src/agents/coder/gpt-codex.ts +1 -0
  30. package/src/agents/coder/gpt-pro.ts +1 -0
  31. package/src/agents/coder/gpt.ts +1 -0
  32. package/src/agents/dynamic-agent-core-sections.ts +36 -0
  33. package/src/agents/dynamic-agent-prompt-builder.ts +1 -0
  34. package/src/config/defaults.ts +14 -1
  35. package/src/config/model-slots-and-export.test.ts +55 -0
  36. package/src/config/platform-schema.ts +1 -3
  37. package/src/config/schema/commands.ts +1 -0
  38. package/src/config/schema/oh-my-opencode-config.ts +0 -3
  39. package/src/config/types.ts +1 -3
  40. package/src/features/builtin-commands/commands.ts +7 -0
  41. package/src/features/builtin-commands/templates/doctor.ts +43 -0
  42. package/src/features/builtin-commands/types.ts +1 -1
  43. package/src/features/builtin-skills/skills/hiai-opencode-setup.ts +69 -0
  44. package/src/features/builtin-skills/skills/index.ts +1 -0
  45. package/src/features/builtin-skills/skills.ts +10 -1
  46. package/src/index.ts +3 -75
  47. package/src/shared/mcp-static-export.ts +121 -0
  48. package/src/tools/ast-grep/constants.ts +1 -1
  49. package/src/tools/ast-grep/environment-check.ts +2 -32
  50. package/src/tools/ast-grep/language-support.ts +0 -3
  51. package/src/tools/ast-grep/types.ts +1 -2
  52. package/src/tools/skill-mcp/tools.test.ts +44 -0
  53. package/dist/ast-grep-napi.win32-x64-msvc-67c0y8nc.node +0 -0
  54. package/dist/config/loader.test.d.ts +0 -1
  55. package/dist/config/models.d.ts +0 -13
  56. package/dist/internals/plugins/websearch-cited/google.d.ts +0 -38
  57. package/dist/internals/plugins/websearch-cited/index.d.ts +0 -17
  58. package/dist/internals/plugins/websearch-cited/openai.d.ts +0 -9
  59. package/dist/internals/plugins/websearch-cited/openrouter.d.ts +0 -2
  60. package/dist/internals/plugins/websearch-cited/types.d.ts +0 -5
  61. package/src/internals/plugins/websearch-cited/LICENSE +0 -214
  62. package/src/internals/plugins/websearch-cited/codex_prompt.txt +0 -79
  63. package/src/internals/plugins/websearch-cited/google.ts +0 -749
  64. package/src/internals/plugins/websearch-cited/index.ts +0 -306
  65. package/src/internals/plugins/websearch-cited/openai.ts +0 -407
  66. package/src/internals/plugins/websearch-cited/openrouter.ts +0 -190
  67. package/src/internals/plugins/websearch-cited/types.ts +0 -7
@@ -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
- }