@hiai-gg/hiai-opencode 0.1.8 → 0.2.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.
Files changed (139) hide show
  1. package/.env.example +0 -19
  2. package/AGENTS.md +214 -54
  3. package/ARCHITECTURE.md +9 -11
  4. package/LICENSE.md +4 -3
  5. package/README.md +95 -95
  6. package/assets/cli/hiai-opencode.mjs +137 -86
  7. package/config/.logs/subtask2.log +2 -0
  8. package/config/.mcp.json +45 -0
  9. package/config/.opencode/palace/knowledge_graph.sqlite3 +0 -0
  10. package/config/.opencode/palace/knowledge_graph.sqlite3-shm +0 -0
  11. package/config/.opencode/palace/knowledge_graph.sqlite3-wal +0 -0
  12. package/config/hiai-opencode.schema.json +176 -62
  13. package/dist/agents/builtin-agents/{guard-agent.d.ts → manager-agent.d.ts} +1 -1
  14. package/dist/agents/dynamic-agent-policy-sections.d.ts +2 -0
  15. package/dist/agents/{guard → manager}/agent.d.ts +7 -7
  16. package/dist/agents/manager/default-prompt-sections.d.ts +5 -0
  17. package/dist/agents/manager/default.d.ts +2 -0
  18. package/dist/agents/manager/index.d.ts +2 -0
  19. package/dist/agents/{guard → manager}/prompt-section-builder.d.ts +1 -1
  20. package/dist/agents/{guard → manager}/shared-prompt.d.ts +2 -2
  21. package/dist/agents/prompt-library/index.d.ts +0 -1
  22. package/dist/agents/strategist/behavioral-summary.d.ts +1 -1
  23. package/dist/agents/strategist/high-accuracy-mode.d.ts +1 -1
  24. package/dist/agents/strategist/identity-constraints.d.ts +1 -1
  25. package/dist/agents/strategist/index.d.ts +1 -1
  26. package/dist/agents/strategist/interview-mode.d.ts +1 -1
  27. package/dist/agents/strategist/plan-generation.d.ts +1 -1
  28. package/dist/agents/strategist/plan-template.d.ts +1 -1
  29. package/dist/agents/strategist/system-prompt.d.ts +3 -3
  30. package/dist/agents/types.d.ts +2 -2
  31. package/dist/agents/writer.d.ts +7 -0
  32. package/dist/config/index.d.ts +4 -6
  33. package/dist/config/platform-schema.d.ts +64 -56
  34. package/dist/config/schema/agent-names.d.ts +9 -10
  35. package/dist/config/schema/agent-overrides.d.ts +2 -258
  36. package/dist/config/schema/browser-automation.d.ts +0 -4
  37. package/dist/config/schema/{oh-my-opencode-config.d.ts → hiai-opencode-config.d.ts} +4 -261
  38. package/dist/config/schema/hooks.d.ts +1 -1
  39. package/dist/config/schema/index.d.ts +2 -2
  40. package/dist/config/schema/ralph-loop.d.ts +2 -0
  41. package/dist/config/types.d.ts +7 -5
  42. package/dist/create-hooks.d.ts +3 -0
  43. package/dist/features/boulder-state/constants.d.ts +1 -1
  44. package/dist/features/boulder-state/types.d.ts +1 -1
  45. package/dist/features/builtin-commands/templates/refactor.d.ts +1 -1
  46. package/dist/features/builtin-skills/skills/{playwright.d.ts → agent-browser.d.ts} +0 -1
  47. package/dist/features/builtin-skills/skills/index.d.ts +1 -2
  48. package/dist/hooks/critic-plans-only/agent-matcher.d.ts +1 -0
  49. package/dist/hooks/critic-plans-only/constants.d.ts +6 -0
  50. package/dist/hooks/critic-plans-only/hook.d.ts +11 -0
  51. package/dist/hooks/critic-plans-only/index.d.ts +3 -0
  52. package/dist/hooks/critic-plans-only/path-policy.d.ts +1 -0
  53. package/dist/hooks/index.d.ts +2 -1
  54. package/dist/hooks/json-error-recovery/hook.d.ts +1 -1
  55. package/dist/hooks/manager/hook-name.d.ts +1 -0
  56. package/dist/hooks/{guard → manager}/system-reminder-templates.d.ts +2 -2
  57. package/dist/hooks/mempalace-auto-save/constants.d.ts +1 -0
  58. package/dist/hooks/mempalace-auto-save/handler.d.ts +13 -0
  59. package/dist/hooks/mempalace-auto-save/index.d.ts +15 -0
  60. package/dist/hooks/mempalace-auto-save/types.d.ts +16 -0
  61. package/dist/hooks/strategist-md-only/constants.d.ts +2 -2
  62. package/dist/hooks/todo-continuation-enforcer/auto-loop.d.ts +23 -0
  63. package/dist/hooks/todo-continuation-enforcer/handler.d.ts +5 -0
  64. package/dist/hooks/todo-continuation-enforcer/idle-event.d.ts +5 -0
  65. package/dist/hooks/todo-continuation-enforcer/types.d.ts +18 -0
  66. package/dist/index.js +1359 -1952
  67. package/dist/internals/plugins/pty/pty/tools/list.d.ts +2 -5
  68. package/dist/mcp/registry.d.ts +1 -1
  69. package/dist/mcp/types.d.ts +0 -4
  70. package/dist/plugin/hooks/create-continuation-hooks.d.ts +6 -1
  71. package/dist/plugin/tool-registry.d.ts +4 -2
  72. package/dist/plugin-handlers/agent-priority-order.d.ts +2 -2
  73. package/dist/shared/agent-display-names.d.ts +2 -2
  74. package/dist/shared/system-directive.d.ts +2 -2
  75. package/dist/tools/agent-browser/constants.d.ts +16 -0
  76. package/dist/tools/agent-browser/index.d.ts +4 -0
  77. package/dist/tools/agent-browser/integration.d.ts +2 -0
  78. package/dist/tools/agent-browser/tools.d.ts +2 -0
  79. package/dist/tools/agent-browser/types.d.ts +80 -0
  80. package/dist/tools/call-hiai-agent/background-agent-executor.d.ts +5 -0
  81. package/dist/tools/{call-omo-agent → call-hiai-agent}/background-executor.d.ts +2 -2
  82. package/dist/tools/call-hiai-agent/constants.d.ts +3 -0
  83. package/dist/tools/{call-omo-agent → call-hiai-agent}/index.d.ts +1 -1
  84. package/dist/tools/{call-omo-agent → call-hiai-agent}/session-creator.d.ts +2 -2
  85. package/dist/tools/{call-omo-agent → call-hiai-agent}/subagent-session-creator.d.ts +2 -2
  86. package/dist/tools/{call-omo-agent → call-hiai-agent}/sync-executor.d.ts +2 -2
  87. package/dist/tools/{call-omo-agent → call-hiai-agent}/tools.d.ts +1 -1
  88. package/dist/tools/{call-omo-agent → call-hiai-agent}/types.d.ts +2 -2
  89. package/dist/tools/delegate-task/constants.d.ts +1 -1
  90. package/dist/tools/delegate-task/sub-agent.d.ts +1 -1
  91. package/dist/tools/index.d.ts +2 -1
  92. package/dist/tools/task/todo-sync.d.ts +1 -1
  93. package/docs/HOOKS.md +126 -0
  94. package/docs/HOOK_TIMINGS.md +58 -0
  95. package/docs/PERMISSIONS.md +84 -0
  96. package/docs/quickstart.md +60 -0
  97. package/hiai-opencode.json +14 -22
  98. package/package.json +13 -11
  99. package/skills/firecrawl-cli/SKILL.md +314 -0
  100. package/skills/firecrawl-cli/rules/install.md +98 -0
  101. package/assets/mcp/playwright.mjs +0 -83
  102. package/assets/mcp/rag.mjs +0 -236
  103. package/dist/agents/brainstormer.d.ts +0 -7
  104. package/dist/agents/guard/default-prompt-sections.d.ts +0 -6
  105. package/dist/agents/guard/default.d.ts +0 -2
  106. package/dist/agents/guard/index.d.ts +0 -2
  107. package/dist/agents/platform-manager.d.ts +0 -7
  108. package/dist/agents/prompt-library/platform.d.ts +0 -1
  109. package/dist/features/builtin-skills/skills/playwright-cli.d.ts +0 -10
  110. package/dist/hooks/guard/hook-name.d.ts +0 -1
  111. package/dist/tools/call-omo-agent/background-agent-executor.d.ts +0 -5
  112. package/dist/tools/call-omo-agent/constants.d.ts +0 -3
  113. /package/dist/hooks/{guard → manager}/background-launch-session-tracking.d.ts +0 -0
  114. /package/dist/hooks/{guard → manager}/bob-path.d.ts +0 -0
  115. /package/dist/hooks/{guard → manager}/boulder-continuation-injector.d.ts +0 -0
  116. /package/dist/hooks/{guard → manager}/boulder-session-lineage.d.ts +0 -0
  117. /package/dist/hooks/{guard → manager}/event-handler.d.ts +0 -0
  118. /package/dist/hooks/{guard → manager}/final-wave-approval-gate.d.ts +0 -0
  119. /package/dist/hooks/{guard → manager}/final-wave-plan-state.d.ts +0 -0
  120. /package/dist/hooks/{guard → manager}/guard-hook.d.ts +0 -0
  121. /package/dist/hooks/{guard → manager}/idle-event.d.ts +0 -0
  122. /package/dist/hooks/{guard → manager}/index.d.ts +0 -0
  123. /package/dist/hooks/{guard → manager}/is-abort-error.d.ts +0 -0
  124. /package/dist/hooks/{guard → manager}/recent-model-resolver.d.ts +0 -0
  125. /package/dist/hooks/{guard → manager}/resolve-active-boulder-session.d.ts +0 -0
  126. /package/dist/hooks/{guard → manager}/session-last-agent.d.ts +0 -0
  127. /package/dist/hooks/{guard → manager}/subagent-session-id.d.ts +0 -0
  128. /package/dist/hooks/{guard → manager}/task-context.d.ts +0 -0
  129. /package/dist/hooks/{guard → manager}/tool-execute-after.d.ts +0 -0
  130. /package/dist/hooks/{guard → manager}/tool-execute-before.d.ts +0 -0
  131. /package/dist/hooks/{guard → manager}/types.d.ts +0 -0
  132. /package/dist/hooks/{guard → manager}/verification-reminders.d.ts +0 -0
  133. /package/dist/hooks/{guard → manager}/write-edit-tool-policy.d.ts +0 -0
  134. /package/dist/tools/{call-omo-agent → call-hiai-agent}/agent-resolver.d.ts +0 -0
  135. /package/dist/tools/{call-omo-agent → call-hiai-agent}/completion-poller.d.ts +0 -0
  136. /package/dist/tools/{call-omo-agent → call-hiai-agent}/message-dir.d.ts +0 -0
  137. /package/dist/tools/{call-omo-agent → call-hiai-agent}/message-processor.d.ts +0 -0
  138. /package/dist/tools/{call-omo-agent → call-hiai-agent}/message-storage-directory.d.ts +0 -0
  139. /package/dist/tools/{call-omo-agent → call-hiai-agent}/tool-context-with-metadata.d.ts +0 -0
@@ -0,0 +1,98 @@
1
+ ---
2
+ name: firecrawl-cli-installation
3
+ description: |
4
+ Install the Firecrawl CLI and handle authentication errors.
5
+ ---
6
+
7
+ # Firecrawl CLI Installation
8
+
9
+ ## Quick Install
10
+
11
+ ```bash
12
+ npm install -g firecrawl-cli
13
+ ```
14
+
15
+ ## Verify Installation
16
+
17
+ Check if installed and authenticated in one command:
18
+
19
+ ```bash
20
+ firecrawl --version --auth-status
21
+ ```
22
+
23
+ Output will show:
24
+
25
+ - Version number
26
+ - `authenticated: true` or `authenticated: false`
27
+
28
+ ## Authentication
29
+
30
+ The `FIRECRAWL_API_KEY` environment variable is used automatically by the CLI — no additional authentication needed.
31
+
32
+ If you need to authenticate manually (e.g., different environment or user-provided key):
33
+
34
+ ```bash
35
+ firecrawl login --browser
36
+ ```
37
+
38
+ The `--browser` flag automatically opens the browser for authentication without prompting. This is the recommended method for agents. Don't tell users to run the commands themselves - just execute the command and have it prompt them to authenticate in their browser.
39
+
40
+ ## If you fail to authenticate, use the following error handling instructions:
41
+
42
+ If ANY command returns an authentication error after you ran `firecrawl login --browser` (e.g., "not authenticated", "unauthorized", "API key"), use an ask user question tool if available (such as the AskUserQuestion tool in Claude Code):
43
+
44
+ **Question:** "How would you like to authenticate with Firecrawl?"
45
+
46
+ **Options:**
47
+
48
+ 1. **Login with browser (Recommended)** - Opens your browser to authenticate with Firecrawl
49
+ 2. **Enter API key manually** - Paste an existing API key from firecrawl.dev
50
+
51
+ ### If user selects browser login:
52
+
53
+ Run `firecrawl login --browser` to automatically open the browser. Wait for them to confirm authentication, then retry the original command.
54
+
55
+ ### If user selects manual API key:
56
+
57
+ Ask for their API key, then run:
58
+
59
+ ```bash
60
+ firecrawl login --api-key "<their-key>"
61
+ ```
62
+
63
+ Or set the environment variable:
64
+
65
+ ```bash
66
+ export FIRECRAWL_API_KEY="<their-key>"
67
+ ```
68
+
69
+ Tell them to add this export to `~/.zshrc` or `~/.bashrc` for persistence, then retry the original command.
70
+
71
+ ## Troubleshooting
72
+
73
+ ### Command not found
74
+
75
+ If `firecrawl` command is not found after installation:
76
+
77
+ 1. Make sure npm global bin is in PATH
78
+ 2. Try: `npx firecrawl-cli --version`
79
+ 3. Or reinstall: `npm install -g firecrawl-cli`
80
+
81
+ ### Permission errors
82
+
83
+ If you get permission errors during installation:
84
+
85
+ ```bash
86
+ # Option 1: Use sudo (not recommended)
87
+ sudo npm install -g firecrawl-cli
88
+
89
+ # Option 2: Fix npm permissions (recommended)
90
+ mkdir ~/.npm-global
91
+ npm config set prefix '~/.npm-global'
92
+ export PATH=~/.npm-global/bin:$PATH
93
+ # Add the export to your shell profile
94
+ ```
95
+
96
+ ### Specific Instructions for Codex
97
+
98
+ When a user selects to authenticate with a browser, run `firecrawl config --browser` to automatically open the browser for authentication without requiring interactive input.
@@ -1,83 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { mkdirSync } from "node:fs"
4
- import { dirname, join } from "node:path"
5
- import { fileURLToPath } from "node:url"
6
- import { spawn, spawnSync } from "node:child_process"
7
-
8
- function resolveCacheRoot() {
9
- const xdgCache = process.env.XDG_CACHE_HOME?.trim()
10
- if (xdgCache) return xdgCache
11
-
12
- const scriptDir = dirname(fileURLToPath(import.meta.url))
13
- const pluginRoot = join(scriptDir, "..", "..")
14
- return join(pluginRoot, ".runtime-cache")
15
- }
16
-
17
- function runNpx(args, stdio = "inherit") {
18
- const cacheRoot = join(resolveCacheRoot(), "hiai-opencode", "npm")
19
- const tempRoot = join(cacheRoot, "tmp")
20
- mkdirSync(tempRoot, { recursive: true })
21
-
22
- const npxCommand = process.platform === "win32" ? "npx.cmd" : "npx"
23
- return spawnSync(npxCommand, args, {
24
- stdio,
25
- shell: process.platform === "win32",
26
- env: {
27
- ...process.env,
28
- npm_config_cache: cacheRoot,
29
- NPM_CONFIG_CACHE: cacheRoot,
30
- TEMP: tempRoot,
31
- TMP: tempRoot,
32
- },
33
- })
34
- }
35
-
36
- function shouldInstallBrowsers() {
37
- const value = process.env.HIAI_PLAYWRIGHT_INSTALL_BROWSERS?.trim().toLowerCase()
38
- return value === "1" || value === "true" || value === "yes"
39
- }
40
-
41
- if (shouldInstallBrowsers()) {
42
- const result = runNpx(["-y", "playwright@latest", "install", "chromium"])
43
- if (result.status !== 0) {
44
- console.error("[hiai-opencode] playwright browser install failed")
45
- console.error("[hiai-opencode] Try: npx playwright install chromium")
46
- }
47
-
48
- if (process.platform === "linux") {
49
- console.error("[hiai-opencode] Playwright Chromium may also need Linux system libraries.")
50
- console.error("[hiai-opencode] If browser launch fails with libnspr4/libnss3/libgtk errors, run: sudo npx playwright install-deps chromium")
51
- console.error("[hiai-opencode] Without sudo, use an existing browser by adding args in hiai-opencode.json, e.g. --browser chrome")
52
- }
53
- }
54
-
55
- const cacheRoot = join(resolveCacheRoot(), "hiai-opencode", "npm")
56
- const tempRoot = join(cacheRoot, "tmp")
57
- mkdirSync(tempRoot, { recursive: true })
58
-
59
- const npxCommand = process.platform === "win32" ? "npx.cmd" : "npx"
60
- const child = spawn(npxCommand, ["-y", "@playwright/mcp@latest", ...process.argv.slice(2)], {
61
- stdio: "inherit",
62
- shell: process.platform === "win32",
63
- env: {
64
- ...process.env,
65
- npm_config_cache: cacheRoot,
66
- NPM_CONFIG_CACHE: cacheRoot,
67
- TEMP: tempRoot,
68
- TMP: tempRoot,
69
- },
70
- })
71
-
72
- child.on("exit", (code, signal) => {
73
- if (signal) {
74
- process.kill(process.pid, signal)
75
- return
76
- }
77
- process.exit(code ?? 0)
78
- })
79
-
80
- child.on("error", (error) => {
81
- console.error("[hiai-opencode] playwright launcher failed:", error)
82
- process.exit(1)
83
- })
@@ -1,236 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const RAG_URL = process.env.OPENCODE_RAG_URL || "http://localhost:9002/tools/search";
4
- const DEBUG = /^(1|true|yes|on)$/i.test(process.env.OPENCODE_RAG_DEBUG || "");
5
- let transportMode = "framed";
6
- let backendReachable = null;
7
-
8
- function debug(message) {
9
- if (DEBUG) {
10
- process.stderr.write(`[opencode-rag-mcp] ${message}\n`);
11
- }
12
- }
13
-
14
- function writeMessage(payload) {
15
- const raw = JSON.stringify(payload);
16
- if (transportMode === "ndjson") {
17
- process.stdout.write(raw + "\n");
18
- return;
19
- }
20
- const body = Buffer.from(raw, "utf8");
21
- process.stdout.write(`Content-Length: ${body.length}\r\n\r\n`);
22
- process.stdout.write(body);
23
- }
24
-
25
- function success(id, result) {
26
- writeMessage({ jsonrpc: "2.0", id, result });
27
- }
28
-
29
- function error(id, code, message) {
30
- writeMessage({ jsonrpc: "2.0", id, error: { code, message } });
31
- }
32
-
33
- async function checkBackend() {
34
- if (backendReachable !== null) return backendReachable;
35
- try {
36
- const base = RAG_URL.replace(/\/tools\/search\/?$/, "/health");
37
- const controller = new AbortController();
38
- const timer = setTimeout(() => controller.abort(), 3000);
39
- const res = await fetch(base, { signal: controller.signal });
40
- clearTimeout(timer);
41
- backendReachable = res.ok;
42
- } catch {
43
- backendReachable = false;
44
- }
45
- if (!backendReachable) {
46
- debug(`RAG backend unreachable at ${RAG_URL} — tool calls will return graceful errors`);
47
- }
48
- return backendReachable;
49
- }
50
-
51
- async function callRag(arguments_) {
52
- const reachable = await checkBackend();
53
- if (!reachable) {
54
- throw new Error(`RAG backend unreachable at ${RAG_URL}. Ensure the RAG service is running or set OPENCODE_RAG_URL.`);
55
- }
56
-
57
- const payload = {
58
- query: arguments_.query || "",
59
- agent: arguments_.agent || "public",
60
- limit: Number.parseInt(String(arguments_.limit ?? 5), 10),
61
- self_identity: Boolean(arguments_.self_identity),
62
- style_mode: Boolean(arguments_.style_mode),
63
- style_intent: arguments_.style_intent,
64
- include_graph: arguments_.include_graph !== false,
65
- scope: arguments_.scope || "all",
66
- };
67
-
68
- const response = await fetch(RAG_URL, {
69
- method: "POST",
70
- headers: { "Content-Type": "application/json" },
71
- body: JSON.stringify(payload),
72
- });
73
-
74
- const text = await response.text();
75
- if (!response.ok) {
76
- throw new Error(`rag_http_error:${response.status}:${text}`);
77
- }
78
- backendReachable = true;
79
- return JSON.parse(text);
80
- }
81
-
82
- const TOOLS = [
83
- {
84
- name: "search_rag",
85
- description: "Search the local architecture, docs, and GraphRAG knowledge base.",
86
- inputSchema: {
87
- type: "object",
88
- properties: {
89
- query: { type: "string", description: "Search query." },
90
- agent: { type: "string", description: "Agent/persona context.", default: "public" },
91
- limit: { type: "integer", description: "Max number of results.", default: 5 },
92
- self_identity: { type: "boolean", default: false },
93
- style_mode: { type: "boolean", default: false },
94
- style_intent: { type: "string" },
95
- include_graph: { type: "boolean", default: true },
96
- scope: { type: "string", default: "all" },
97
- },
98
- required: ["query"],
99
- },
100
- },
101
- ];
102
-
103
- let buffer = Buffer.alloc(0);
104
- let processing = Promise.resolve();
105
-
106
- async function handleMessage(message) {
107
- const method = message.method;
108
- const id = message.id;
109
- debug(`received method=${JSON.stringify(method)} id=${JSON.stringify(id)}`);
110
-
111
- if (method === "initialize") {
112
- success(id, {
113
- protocolVersion: "2024-11-05",
114
- capabilities: { tools: {} },
115
- serverInfo: { name: "opencode-rag-bridge", version: "1.0.0" },
116
- });
117
- return;
118
- }
119
-
120
- if (method === "notifications/initialized") {
121
- return;
122
- }
123
-
124
- if (method === "ping") {
125
- success(id, {});
126
- return;
127
- }
128
-
129
- if (method === "tools/list") {
130
- success(id, { tools: TOOLS });
131
- return;
132
- }
133
-
134
- if (method === "resources/list") {
135
- success(id, { resources: [] });
136
- return;
137
- }
138
-
139
- if (method === "prompts/list") {
140
- success(id, { prompts: [] });
141
- return;
142
- }
143
-
144
- if (method === "tools/call") {
145
- const params = message.params || {};
146
- if (params.name !== "search_rag") {
147
- error(id, -32602, `unknown tool: ${params.name}`);
148
- return;
149
- }
150
- try {
151
- const result = await callRag(params.arguments || {});
152
- success(id, {
153
- content: [
154
- {
155
- type: "text",
156
- text: JSON.stringify(result, null, 2),
157
- },
158
- ],
159
- });
160
- } catch (err) {
161
- error(id, -32000, String(err instanceof Error ? err.message : err));
162
- }
163
- return;
164
- }
165
-
166
- error(id, -32601, `method not found: ${method}`);
167
- }
168
-
169
- function drainBuffer() {
170
- while (true) {
171
- let headerEnd = buffer.indexOf("\r\n\r\n");
172
- let headerSize = 4;
173
- if (headerEnd === -1) {
174
- headerEnd = buffer.indexOf("\n\n");
175
- headerSize = 2;
176
- }
177
- if (headerEnd === -1) {
178
- // Fallback for clients that send newline-delimited JSON-RPC instead of Content-Length framing.
179
- const lf = buffer.indexOf("\n");
180
- if (lf === -1) return;
181
- const line = buffer.subarray(0, lf).toString("utf8").trim();
182
- buffer = buffer.subarray(lf + 1);
183
- if (!line) continue;
184
- try {
185
- const message = JSON.parse(line);
186
- transportMode = "ndjson";
187
- debug("parsed ndjson frame");
188
- processing = processing
189
- .then(() => handleMessage(message))
190
- .catch((err) => {
191
- debug(`handler error: ${String(err)}`);
192
- });
193
- } catch (err) {
194
- debug(`invalid ndjson: ${String(err)}`);
195
- }
196
- continue;
197
- }
198
- const headerText = buffer.subarray(0, headerEnd).toString("utf8");
199
- const match = headerText.match(/content-length:\s*(\d+)/i);
200
- if (!match) {
201
- buffer = buffer.subarray(headerEnd + headerSize);
202
- continue;
203
- }
204
- const contentLength = Number.parseInt(match[1], 10);
205
- const totalLength = headerEnd + headerSize + contentLength;
206
- if (buffer.length < totalLength) return;
207
- const body = buffer.subarray(headerEnd + headerSize, totalLength).toString("utf8");
208
- buffer = buffer.subarray(totalLength);
209
- let message;
210
- try {
211
- message = JSON.parse(body);
212
- transportMode = "framed";
213
- debug(`parsed content-length frame size=${contentLength}`);
214
- } catch (err) {
215
- debug(`invalid JSON: ${String(err)}`);
216
- continue;
217
- }
218
- processing = processing
219
- .then(() => handleMessage(message))
220
- .catch((err) => {
221
- debug(`handler error: ${String(err)}`);
222
- });
223
- }
224
- }
225
-
226
- debug("server started");
227
- process.stdin.on("data", (chunk) => {
228
- buffer = Buffer.concat([buffer, chunk]);
229
- drainBuffer();
230
- });
231
- process.stdin.on("end", () => {
232
- debug("stdin closed");
233
- processing
234
- .catch(() => {})
235
- .finally(() => process.exit(0));
236
- });
@@ -1,7 +0,0 @@
1
- import type { AgentConfig } from "@opencode-ai/sdk";
2
- import type { AgentPromptMetadata } from "./types";
3
- export declare function createBrainstormerAgent(model: string): AgentConfig;
4
- export declare namespace createBrainstormerAgent {
5
- var mode: "subagent";
6
- }
7
- export declare const brainstormerPromptMetadata: AgentPromptMetadata;
@@ -1,6 +0,0 @@
1
- export declare const DEFAULT_ATLAS_INTRO = "<identity>\nYou are Guard - the Master Orchestrator from HiaiOpenCode.\n\nIn Greek mythology, Guard holds up the celestial heavens. You hold up the entire workflow - coordinating every agent, every task, every verification until completion.\n\nYou are a conductor, not a musician. A general, not a soldier. You DELEGATE, COORDINATE, and VERIFY.\nYou never write code yourself. You orchestrate specialists who do.\n</identity>\n\n<mission>\nComplete ALL tasks in a work plan via `task()` and pass the Final Verification Wave.\nImplementation tasks are the means. Final Wave approval is the goal.\nOne task per delegation. Parallel when independent. Verify everything.\nReject any subagent response that fails the Closure Protocol.\n</mission>";
2
- export declare const DEFAULT_ATLAS_WORKFLOW = "<workflow>\n## Step 0: Register Tracking\n\n```\nTodoWrite([\n { id: \"orchestrate-plan\", content: \"Complete ALL implementation tasks\", status: \"in_progress\", priority: \"high\" },\n { id: \"pass-final-wave\", content: \"Pass Final Verification Wave - ALL reviewers APPROVE\", status: \"pending\", priority: \"high\" }\n])\n```\n\n## Step 1: Analyze Plan\n\n1. Read the todo list file\n2. Parse actionable **top-level** task checkboxes in `## TODOs` and `## Final Verification Wave`\n - Ignore nested checkboxes under Acceptance Criteria, Evidence, Definition of Done, and Final Checklist sections.\n3. Extract parallelizability info from each task\n4. Build parallelization map:\n - Which tasks can run simultaneously?\n - Which have dependencies?\n - Which have file conflicts?\n\nOutput:\n```\nTASK ANALYSIS:\n- Total: [N], Remaining: [M]\n- Parallelizable Groups: [list]\n- Sequential Dependencies: [list]\n```\n\n## Step 2: Initialize Notepad\n\n```bash\nmkdir -p .bob/notepads/{plan-name}\n```\n\nStructure:\n```\n.bob/notepads/{plan-name}/\n learnings.md # Conventions, patterns\n decisions.md # Architectural choices\n issues.md # Problems, gotchas\n problems.md # Unresolved blockers\n```\n\n## Step 3: Execute Tasks\n\n### 3.1 Check Parallelization\nIf tasks can run in parallel:\n- Prepare prompts for ALL parallelizable tasks\n- Invoke multiple `task()` in ONE message\n- Wait for all to complete\n- Verify all, then continue\n\nIf sequential:\n- Process one at a time\n\n### 3.2 Before Each Delegation\n\nRead notepad first\n```\nglob(\".bob/notepads/{plan-name}/*.md\")\nRead(\".bob/notepads/{plan-name}/learnings.md\")\nRead(\".bob/notepads/{plan-name}/issues.md\")\n```\n\nExtract wisdom and include in prompt.\n\n### 3.3 Invoke task()\n\n```typescript\ntask(\n category=\"[category]\",\n load_skills=[\"[relevant-skills]\"],\n run_in_background=false,\n prompt=`[FULL 6-SECTION PROMPT]`\n)\n```\n\n### 3.4 Verify \u2014 Every Single Delegation\n\n**You are the QA gate. Subagents lie. Automated checks alone are NOT enough.**\n\nAfter EVERY delegation, complete ALL of these steps - no shortcuts:\n\n#### A. Closure Protocol Verification\n1. **Check for <CLOSURE> block**: Every final response from a subagent MUST end with a structured <CLOSURE> block containing JSON (reasoning, evidence, readiness).\n2. **Verify Evidence**: Manually verify each link/file/diagnostic claimed in the evidence list.\n3. **Validation Outcome**: If the block is missing, malformed, or claims false evidence 2192 **REJECT IMMEDIATELY** and resume session with corrective feedback.\n\n#### B. Automated Verification\n1. 'lsp_diagnostics(filePath=\".\", extension=\".ts\")' \u2192 ZERO errors across scanned TypeScript files (directory scans are capped at 50 files; not a full-project guarantee)\n2. `bun run build` or `bun run typecheck` \u2192 exit code 0\n3. `bun test` \u2192 ALL tests pass\n\n#### C. Manual Code Review\n\n**This is the step you are most tempted to skip. DO NOT SKIP IT.**\n\n1. `Read` EVERY file the subagent created or modified - no exceptions\n2. For EACH file, check line by line:\n - Does the logic actually implement the task requirement?\n - Are there stubs, TODOs, placeholders, or hardcoded values?\n - Are there logic errors or missing edge cases?\n - Does it follow the existing codebase patterns?\n - Are imports correct and complete?\n3. Cross-reference: compare what subagent CLAIMED vs what the code ACTUALLY does\n4. If anything doesn't match \u2192 resume session and fix immediately\n\n**If you cannot explain what the changed code does, you have not reviewed it.**\n\n#### D. Hands-On QA (if applicable)\n- **Frontend/UI**: Browser - `/playwright`\n- **TUI/CLI**: Interactive - `interactive_bash`\n- **API/Backend**: Real requests - curl\n\n#### E. Check Boulder State Directly\n\nAfter verification, READ the plan file directly - every time, no exceptions:\n```\nRead(\".bob/plans/{plan-name}.md\")\n```\nCount remaining **top-level task** checkboxes. Ignore nested verification/evidence checkboxes. This is your ground truth for what comes next.\n\n**Checklist (ALL must be checked):**\n```\n[ ] Protocol: <CLOSURE> block present and valid\n[ ] Automated: lsp_diagnostics clean, build passes, tests pass\n[ ] Manual: Read EVERY changed file, verified logic matches requirements\n[ ] Cross-check: Subagent claims match actual code\n[ ] Boulder: Read plan file, confirmed current progress\n```\n\n**If verification fails**: Resume the SAME session with the ACTUAL error output:\n```typescript\ntask(\n session_id=\"ses_xyz789\",\n load_skills=[...],\n prompt=\"Verification failed: {actual error}. Fix.\"\n)\n```\n\n### 3.5 Handle Failures (USE RESUME)\n\n**Important: When re-delegating, ALWAYS use `session_id` parameter.**\n\nEvery `task()` output includes a session_id. STORE IT.\n\nIf task fails:\n1. Identify what went wrong\n2. **Resume the SAME session** - subagent has full context already:\n ```typescript\n task(\n session_id=\"ses_xyz789\", // Session from failed task\n load_skills=[...],\n prompt=\"FAILED: {error}. Fix by: {specific instruction}\"\n )\n ```\n3. Maximum 3 retry attempts with the SAME session\n4. If blocked after 3 attempts: Document and continue to independent tasks\n\nWhy session_id is mandatory for failures:\n- Subagent already read all files, knows the context\n- No repeated exploration = 70%+ token savings\n- Subagent knows what approaches already failed\n- Preserves accumulated knowledge from the attempt\n\n**NEVER start fresh on failures** - that's like asking someone to redo work while wiping their memory.\n\n### 3.6 Loop Until Implementation Complete\n\nRepeat Step 3 until all implementation tasks complete. Then proceed to Step 4.\n\n## Step 4: Final Verification Wave\n\nThe plan's Final Wave tasks (F1-F4) are APPROVAL GATES - not regular tasks.\nEach reviewer produces a VERDICT: APPROVE or REJECT.\nFinal-wave reviewers can finish in parallel before you update the plan file, so do NOT rely on raw unchecked-count alone.\n\n1. Execute all Final Wave tasks in parallel\n2. If ANY verdict is REJECT:\n - Fix the issues (delegate via `task()` with `session_id`)\n - Re-run the rejecting reviewer\n - Repeat until ALL verdicts are APPROVE\n3. Mark `pass-final-wave` todo as `completed`\n\n```\nORCHESTRATION COMPLETE - FINAL WAVE PASSED\n\nTODO LIST: [path]\nCOMPLETED: [N/N]\nFINAL WAVE: F1 [APPROVE] | F2 [APPROVE] | F3 [APPROVE] | F4 [APPROVE]\nFILES MODIFIED: [list]\n```\n</workflow>";
3
- export declare const DEFAULT_ATLAS_PARALLEL_EXECUTION = "<parallel_execution>\n## Parallel Execution Rules\n\n**For exploration (researcher)**: ALWAYS background\n```typescript\ntask(subagent_type=\"researcher\", load_skills=[], run_in_background=true, ...)\n```\n\n**For task execution**: NEVER background\n```typescript\ntask(category=\"...\", load_skills=[...], run_in_background=false, ...)\n```\n\n**Parallel task groups**: Invoke multiple in ONE message\n```typescript\n// Tasks 2, 3, 4 are independent - invoke together\ntask(category=\"quick\", load_skills=[], run_in_background=false, prompt=\"Task 2...\")\ntask(category=\"quick\", load_skills=[], run_in_background=false, prompt=\"Task 3...\")\ntask(category=\"quick\", load_skills=[], run_in_background=false, prompt=\"Task 4...\")\n```\n\n**Background management**:\n- Collect results: `background_output(task_id=\"...\")`\n- Before final answer, cancel DISPOSABLE tasks individually: `background_cancel(taskId=\"bg_researcher_xxx\")`\n- **NEVER use `background_cancel(all=true)`** - it kills tasks whose results you haven't collected yet\n</parallel_execution>";
4
- export declare const DEFAULT_ATLAS_VERIFICATION_RULES = "<verification_rules>\n## QA Protocol\n\nYou are the QA gate. Subagents lie. Verify EVERYTHING.\n\nAfter each delegation - both automated AND manual verification are mandatory:\n\n1. **Protocol Check**: Verify <CLOSURE> block exists and evidence correlates with reality.\n2. 'lsp_diagnostics(filePath=\".\", extension=\".ts\")' across scanned TypeScript files \u2192 ZERO errors (directory scans are capped at 50 files; not a full-project guarantee)\n3. Run build command \u2192 exit 0\n4. Run test suite \u2192 ALL pass\n5. **`Read` EVERY changed file line by line** \u2192 logic matches requirements\n6. **Cross-check**: subagent's claims vs actual code - do they match?\n7. **Check boulder state**: Read the plan file directly, count remaining tasks\n\n**Evidence required**:\n- **Protocol**: <CLOSURE> block present and valid.\n- **Code change**: lsp_diagnostics clean + manual Read of every changed file\n- **Build**: Exit code 0\n- **Tests**: All pass\n- **Logic correct**: You read the code and can explain what it does\n- **Boulder state**: Read plan file, confirmed progress\n\n**No evidence = not complete. Skipping manual review = rubber-stamping broken work.**\n</verification_rules>";
5
- export declare const DEFAULT_ATLAS_BOUNDARIES = "<boundaries>\n## What You Do vs Delegate\n\n**YOU DO**:\n- Read files (for context, verification)\n- Run commands (for verification)\n- Use lsp_diagnostics, grep, glob\n- Manage todos\n- Coordinate and verify\n- **EDIT `.bob/plans/*.md` to change `- [ ]` to `- [x]` after verified task completion**\n\n**YOU DELEGATE**:\n- All code writing/editing\n- All bug fixes\n- All test creation\n- All documentation\n- All git operations\n</boundaries>";
6
- export declare const DEFAULT_ATLAS_CRITICAL_RULES = "<critical_overrides>\n## Critical Rules\n\n**NEVER**:\n- Write/edit code yourself - always delegate\n- Trust subagent claims without verification\n- Use run_in_background=true for task execution\n- Send prompts under 30 lines\n- Skip scanned-file lsp_diagnostics after delegation (use 'filePath=\".\", extension=\".ts\"' for TypeScript projects; directory scans are capped at 50 files)\n- Batch multiple tasks in one delegation\n- Start fresh session for failures/follow-ups - use resume instead\n\n**ALWAYS**:\n- Include ALL 6 sections in delegation prompts\n- Read notepad before every delegation\n- Run scanned-file QA after every delegation\n- Pass inherited wisdom to every subagent\n- Parallelize independent tasks\n- Verify with your own tools\n- Store session_id from every delegation output\n- Use session_id for retries, fixes, and follow-ups\n</critical_overrides>";
@@ -1,2 +0,0 @@
1
- export declare const ATLAS_SYSTEM_PROMPT: string;
2
- export declare function getDefaultGuardPrompt(): string;
@@ -1,2 +0,0 @@
1
- export { createGuardAgent, guardPromptMetadata } from "./agent";
2
- export type { GuardPromptSource, OrchestratorContext } from "./agent";
@@ -1,7 +0,0 @@
1
- import type { AgentConfig } from "@opencode-ai/sdk";
2
- import type { AgentPromptMetadata } from "./types";
3
- export declare function createPlatformManagerAgent(model: string): AgentConfig;
4
- export declare namespace createPlatformManagerAgent {
5
- var mode: "subagent";
6
- }
7
- export declare const platformManagerPromptMetadata: AgentPromptMetadata;
@@ -1 +0,0 @@
1
- export declare function buildPlatformManagerPrompt(): string;
@@ -1,10 +0,0 @@
1
- import type { BuiltinSkill } from "../types";
2
- /**
3
- * Playwright CLI skill - token-efficient CLI alternative to the MCP-based playwright skill.
4
- *
5
- * Uses name "playwright" (not "playwright-cli") because agents hardcode "playwright" as the
6
- * canonical browser skill name. The browserProvider config swaps the implementation behind
7
- * the same name: "playwright" gives MCP, "playwright-cli" gives this CLI variant.
8
- * The binary is still called `playwright-cli` (see allowedTools).
9
- */
10
- export declare const playwrightCliSkill: BuiltinSkill;
@@ -1 +0,0 @@
1
- export declare const HOOK_NAME = "guard";
@@ -1,5 +0,0 @@
1
- import type { BackgroundManager } from "../../features/background-agent";
2
- import type { PluginInput } from "@opencode-ai/plugin";
3
- import type { CallOmoAgentArgs } from "./types";
4
- import type { ToolContextWithMetadata } from "./tool-context-with-metadata";
5
- export declare function executeBackgroundAgent(args: CallOmoAgentArgs, toolContext: ToolContextWithMetadata, manager: BackgroundManager, client: PluginInput["client"]): Promise<string>;
@@ -1,3 +0,0 @@
1
- export declare const PRIMARY_ALLOWED_AGENTS: readonly ["researcher", "strategist", "coder", "critic", "designer", "brainstormer", "platform-manager", "multimodal"];
2
- export declare const ALLOWED_AGENTS: readonly ["researcher", "strategist", "coder", "critic", "designer", "brainstormer", "platform-manager", "multimodal"];
3
- export declare const CALL_OMO_AGENT_DESCRIPTION = "Spawn canonical agents or custom agents. run_in_background REQUIRED (true=async with task_id, false=sync).\n\nCanonical built-in agents:\n{primary_agents}\n\nCustom agents registered via user or project agent directories are also supported.\n\nPass `session_id=<id>` to continue previous agent with full context. Nested subagent depth is tracked automatically and blocked past the configured limit. Prompts MUST be in English. Use `background_output` for async results.";
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes