@hiai-gg/hiai-opencode 0.1.9 → 0.2.1
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 +0 -19
- package/AGENTS.md +218 -58
- package/ARCHITECTURE.md +9 -11
- package/LICENSE.md +4 -3
- package/README.md +76 -143
- package/assets/cli/hiai-opencode.mjs +141 -90
- package/config/.logs/subtask2.log +2 -0
- package/config/.mcp.json +45 -0
- package/config/.opencode/palace/knowledge_graph.sqlite3 +0 -0
- package/config/.opencode/palace/knowledge_graph.sqlite3-shm +0 -0
- package/config/.opencode/palace/knowledge_graph.sqlite3-wal +0 -0
- package/config/hiai-opencode.schema.json +176 -62
- package/dist/agents/builtin-agents/{guard-agent.d.ts → manager-agent.d.ts} +1 -1
- package/dist/agents/dynamic-agent-policy-sections.d.ts +2 -0
- package/dist/agents/{guard → manager}/agent.d.ts +7 -7
- package/dist/agents/manager/default-prompt-sections.d.ts +5 -0
- package/dist/agents/manager/default.d.ts +2 -0
- package/dist/agents/manager/index.d.ts +2 -0
- package/dist/agents/{guard → manager}/prompt-section-builder.d.ts +1 -1
- package/dist/agents/{guard → manager}/shared-prompt.d.ts +2 -2
- package/dist/agents/prompt-library/index.d.ts +0 -1
- package/dist/agents/strategist/behavioral-summary.d.ts +1 -1
- package/dist/agents/strategist/high-accuracy-mode.d.ts +1 -1
- package/dist/agents/strategist/identity-constraints.d.ts +1 -1
- package/dist/agents/strategist/index.d.ts +1 -1
- package/dist/agents/strategist/interview-mode.d.ts +1 -1
- package/dist/agents/strategist/plan-generation.d.ts +1 -1
- package/dist/agents/strategist/plan-template.d.ts +1 -1
- package/dist/agents/strategist/system-prompt.d.ts +3 -3
- package/dist/agents/types.d.ts +2 -2
- package/dist/agents/writer.d.ts +7 -0
- package/dist/config/index.d.ts +4 -6
- package/dist/config/platform-schema.d.ts +64 -56
- package/dist/config/schema/agent-names.d.ts +9 -10
- package/dist/config/schema/agent-overrides.d.ts +2 -258
- package/dist/config/schema/browser-automation.d.ts +0 -4
- package/dist/config/schema/{oh-my-opencode-config.d.ts → hiai-opencode-config.d.ts} +2 -261
- package/dist/config/schema/hooks.d.ts +1 -1
- package/dist/config/schema/index.d.ts +2 -2
- package/dist/config/types.d.ts +7 -5
- package/dist/create-hooks.d.ts +3 -0
- package/dist/features/background-agent/error-classifier.d.ts +1 -0
- package/dist/features/boulder-state/constants.d.ts +4 -1
- package/dist/features/boulder-state/storage.d.ts +94 -0
- package/dist/features/boulder-state/types.d.ts +18 -1
- package/dist/features/builtin-commands/templates/doctor.d.ts +1 -1
- package/dist/features/builtin-commands/templates/refactor.d.ts +1 -1
- package/dist/features/builtin-commands/templates/start-work.d.ts +1 -1
- package/dist/features/builtin-skills/skills/{playwright.d.ts → agent-browser.d.ts} +0 -1
- package/dist/features/builtin-skills/skills/index.d.ts +1 -2
- package/dist/hooks/critic-plans-only/agent-matcher.d.ts +1 -0
- package/dist/hooks/critic-plans-only/constants.d.ts +6 -0
- package/dist/hooks/critic-plans-only/hook.d.ts +11 -0
- package/dist/hooks/critic-plans-only/index.d.ts +3 -0
- package/dist/hooks/critic-plans-only/path-policy.d.ts +1 -0
- package/dist/hooks/index.d.ts +2 -1
- package/dist/hooks/json-error-recovery/hook.d.ts +1 -1
- package/dist/hooks/manager/hook-name.d.ts +1 -0
- package/dist/hooks/{guard → manager}/resolve-active-boulder-session.d.ts +5 -0
- package/dist/hooks/{guard → manager}/system-reminder-templates.d.ts +2 -2
- package/dist/hooks/mempalace-auto-save/constants.d.ts +1 -0
- package/dist/hooks/mempalace-auto-save/handler.d.ts +13 -0
- package/dist/hooks/mempalace-auto-save/index.d.ts +15 -0
- package/dist/hooks/mempalace-auto-save/types.d.ts +16 -0
- package/dist/hooks/start-work/context-info-builder.d.ts +2 -0
- package/dist/hooks/start-work/worktree-block.d.ts +2 -1
- package/dist/hooks/start-work/worktree-detector.d.ts +45 -0
- package/dist/hooks/strategist-md-only/agent-resolution.d.ts +1 -1
- package/dist/hooks/strategist-md-only/constants.d.ts +8 -2
- package/dist/index.js +1385 -2003
- package/dist/internals/plugins/pty/pty/tools/list.d.ts +2 -5
- package/dist/mcp/registry.d.ts +1 -1
- package/dist/mcp/types.d.ts +0 -4
- package/dist/plugin/hooks/create-continuation-hooks.d.ts +4 -0
- package/dist/plugin/tool-registry.d.ts +4 -2
- package/dist/plugin-handlers/agent-priority-order.d.ts +2 -2
- package/dist/shared/agent-display-names.d.ts +2 -2
- package/dist/shared/system-directive.d.ts +2 -2
- package/dist/tools/agent-browser/constants.d.ts +16 -0
- package/dist/tools/agent-browser/index.d.ts +4 -0
- package/dist/tools/agent-browser/integration.d.ts +2 -0
- package/dist/tools/agent-browser/tools.d.ts +2 -0
- package/dist/tools/agent-browser/types.d.ts +80 -0
- package/dist/tools/call-hiai-agent/background-agent-executor.d.ts +5 -0
- package/dist/tools/{call-omo-agent → call-hiai-agent}/background-executor.d.ts +2 -2
- package/dist/tools/call-hiai-agent/constants.d.ts +3 -0
- package/dist/tools/{call-omo-agent → call-hiai-agent}/index.d.ts +1 -1
- package/dist/tools/{call-omo-agent → call-hiai-agent}/session-creator.d.ts +2 -2
- package/dist/tools/{call-omo-agent → call-hiai-agent}/subagent-session-creator.d.ts +2 -2
- package/dist/tools/{call-omo-agent → call-hiai-agent}/sync-executor.d.ts +2 -2
- package/dist/tools/{call-omo-agent → call-hiai-agent}/tools.d.ts +1 -1
- package/dist/tools/{call-omo-agent → call-hiai-agent}/types.d.ts +2 -2
- package/dist/tools/delegate-task/constants.d.ts +1 -1
- package/dist/tools/delegate-task/sub-agent.d.ts +1 -1
- package/dist/tools/index.d.ts +2 -1
- package/dist/tools/task/todo-sync.d.ts +1 -1
- package/docs/HOOKS.md +126 -0
- package/docs/HOOK_TIMINGS.md +58 -0
- package/docs/PERMISSIONS.md +84 -0
- package/docs/quickstart.md +60 -0
- package/hiai-opencode.json +10 -22
- package/package.json +14 -12
- package/skills/firecrawl-cli/SKILL.md +314 -0
- package/skills/firecrawl-cli/rules/install.md +98 -0
- package/assets/mcp/playwright.mjs +0 -83
- package/assets/mcp/rag.mjs +0 -236
- package/dist/agents/brainstormer.d.ts +0 -7
- package/dist/agents/guard/default-prompt-sections.d.ts +0 -6
- package/dist/agents/guard/default.d.ts +0 -2
- package/dist/agents/guard/index.d.ts +0 -2
- package/dist/agents/platform-manager.d.ts +0 -7
- package/dist/agents/prompt-library/platform.d.ts +0 -1
- package/dist/features/builtin-skills/skills/playwright-cli.d.ts +0 -10
- package/dist/hooks/guard/hook-name.d.ts +0 -1
- package/dist/tools/call-omo-agent/background-agent-executor.d.ts +0 -5
- package/dist/tools/call-omo-agent/constants.d.ts +0 -3
- /package/dist/hooks/{guard → manager}/background-launch-session-tracking.d.ts +0 -0
- /package/dist/hooks/{guard → manager}/bob-path.d.ts +0 -0
- /package/dist/hooks/{guard → manager}/boulder-continuation-injector.d.ts +0 -0
- /package/dist/hooks/{guard → manager}/boulder-session-lineage.d.ts +0 -0
- /package/dist/hooks/{guard → manager}/event-handler.d.ts +0 -0
- /package/dist/hooks/{guard → manager}/final-wave-approval-gate.d.ts +0 -0
- /package/dist/hooks/{guard → manager}/final-wave-plan-state.d.ts +0 -0
- /package/dist/hooks/{guard → manager}/guard-hook.d.ts +0 -0
- /package/dist/hooks/{guard → manager}/idle-event.d.ts +0 -0
- /package/dist/hooks/{guard → manager}/index.d.ts +0 -0
- /package/dist/hooks/{guard → manager}/is-abort-error.d.ts +0 -0
- /package/dist/hooks/{guard → manager}/recent-model-resolver.d.ts +0 -0
- /package/dist/hooks/{guard → manager}/session-last-agent.d.ts +0 -0
- /package/dist/hooks/{guard → manager}/subagent-session-id.d.ts +0 -0
- /package/dist/hooks/{guard → manager}/task-context.d.ts +0 -0
- /package/dist/hooks/{guard → manager}/tool-execute-after.d.ts +0 -0
- /package/dist/hooks/{guard → manager}/tool-execute-before.d.ts +0 -0
- /package/dist/hooks/{guard → manager}/types.d.ts +0 -0
- /package/dist/hooks/{guard → manager}/verification-reminders.d.ts +0 -0
- /package/dist/hooks/{guard → manager}/write-edit-tool-policy.d.ts +0 -0
- /package/dist/tools/{call-omo-agent → call-hiai-agent}/agent-resolver.d.ts +0 -0
- /package/dist/tools/{call-omo-agent → call-hiai-agent}/completion-poller.d.ts +0 -0
- /package/dist/tools/{call-omo-agent → call-hiai-agent}/message-dir.d.ts +0 -0
- /package/dist/tools/{call-omo-agent → call-hiai-agent}/message-processor.d.ts +0 -0
- /package/dist/tools/{call-omo-agent → call-hiai-agent}/message-storage-directory.d.ts +0 -0
- /package/dist/tools/{call-omo-agent → call-hiai-agent}/tool-context-with-metadata.d.ts +0 -0
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
args: {};
|
|
4
|
-
execute(args: Record<string, never>, context: import("@opencode-ai/plugin").ToolContext): Promise<string>;
|
|
5
|
-
};
|
|
1
|
+
import { type ToolDefinition } from '@opencode-ai/plugin';
|
|
2
|
+
export declare const ptyList: ToolDefinition;
|
package/dist/mcp/registry.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { McpServerConfig } from "../config/types.js";
|
|
2
|
-
export type HiaiMcpName = "
|
|
2
|
+
export type HiaiMcpName = "stitch" | "sequential-thinking" | "context7" | "mempalace" | "grep_app";
|
|
3
3
|
export type HiaiMcpInstallKind = "bundled" | "npm" | "python" | "remote" | "user-service";
|
|
4
4
|
export interface HiaiMcpRegistryEntry {
|
|
5
5
|
name: HiaiMcpName;
|
package/dist/mcp/types.d.ts
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const McpNameSchema: z.ZodEnum<{
|
|
3
|
-
websearch: "websearch";
|
|
4
3
|
stitch: "stitch";
|
|
5
|
-
firecrawl: "firecrawl";
|
|
6
4
|
context7: "context7";
|
|
7
|
-
playwright: "playwright";
|
|
8
5
|
"sequential-thinking": "sequential-thinking";
|
|
9
|
-
rag: "rag";
|
|
10
6
|
mempalace: "mempalace";
|
|
11
7
|
grep_app: "grep_app";
|
|
12
8
|
}>;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { HookName, HiaiOpenCodeConfig } from "../../config";
|
|
2
2
|
import type { BackgroundManager } from "../../features/background-agent";
|
|
3
3
|
import type { PluginContext } from "../types";
|
|
4
|
+
import type { SkillMcpManager } from "../../features/skill-mcp-manager";
|
|
4
5
|
import { createTodoContinuationEnforcer, createBackgroundNotificationHook, createStopContinuationGuardHook, createCompactionContextInjector, createCompactionTodoPreserverHook, createGuardHook, type RalphLoopHook } from "../../hooks";
|
|
5
6
|
import { createUnstableAgentBabysitter } from "../unstable-agent-babysitter";
|
|
7
|
+
import { createMemPalaceAutoSave } from "../../hooks/mempalace-auto-save";
|
|
6
8
|
export type ContinuationHooks = {
|
|
7
9
|
stopContinuationGuard: ReturnType<typeof createStopContinuationGuardHook> | null;
|
|
8
10
|
compactionContextInjector: ReturnType<typeof createCompactionContextInjector> | null;
|
|
@@ -11,6 +13,7 @@ export type ContinuationHooks = {
|
|
|
11
13
|
unstableAgentBabysitter: ReturnType<typeof createUnstableAgentBabysitter> | null;
|
|
12
14
|
backgroundNotificationHook: ReturnType<typeof createBackgroundNotificationHook> | null;
|
|
13
15
|
guardHook: ReturnType<typeof createGuardHook> | null;
|
|
16
|
+
mempalaceAutoSave: ReturnType<typeof createMemPalaceAutoSave> | null;
|
|
14
17
|
};
|
|
15
18
|
type SessionRecovery = {
|
|
16
19
|
setOnAbortCallback: (callback: (sessionID: string) => void) => void;
|
|
@@ -22,6 +25,7 @@ export declare function createContinuationHooks(args: {
|
|
|
22
25
|
isHookEnabled: (hookName: HookName) => boolean;
|
|
23
26
|
safeHookEnabled: boolean;
|
|
24
27
|
backgroundManager: BackgroundManager;
|
|
28
|
+
skillMcpManager: SkillMcpManager;
|
|
25
29
|
sessionRecovery: SessionRecovery;
|
|
26
30
|
ralphLoop?: RalphLoopHook | null;
|
|
27
31
|
}): ContinuationHooks;
|
|
@@ -2,13 +2,13 @@ import type { AvailableCategory } from "../agents/dynamic-agent-prompt-builder";
|
|
|
2
2
|
import type { HiaiOpenCodeConfig } from "../config";
|
|
3
3
|
import type { McpServerConfig } from "../config/types";
|
|
4
4
|
import type { PluginContext, ToolsRecord } from "./types";
|
|
5
|
-
import { builtinTools, createBackgroundTools,
|
|
5
|
+
import { builtinTools, createBackgroundTools, createCallHiaiAgent, createLookAt, createSkillMcpTool, createSkillTool, createGrepTools, createGlobTools, createAstGrepTools, createSessionManagerTools, createDelegateTask, discoverCommandsSync, interactive_bash, createTaskCreateTool, createTaskGetTool, createTaskList, createTaskUpdateTool, createHashlineEditTool, createAgentBrowserTool, createAgentBrowserIntegrationTool } from "../tools";
|
|
6
6
|
import type { Managers } from "../create-managers";
|
|
7
7
|
import type { SkillContext } from "./skill-context";
|
|
8
8
|
type ToolRegistryFactories = {
|
|
9
9
|
builtinTools: typeof builtinTools;
|
|
10
10
|
createBackgroundTools: typeof createBackgroundTools;
|
|
11
|
-
|
|
11
|
+
createCallHiaiAgent: typeof createCallHiaiAgent;
|
|
12
12
|
createLookAt: typeof createLookAt;
|
|
13
13
|
createSkillMcpTool: typeof createSkillMcpTool;
|
|
14
14
|
createSkillTool: typeof createSkillTool;
|
|
@@ -24,6 +24,8 @@ type ToolRegistryFactories = {
|
|
|
24
24
|
createTaskList: typeof createTaskList;
|
|
25
25
|
createTaskUpdateTool: typeof createTaskUpdateTool;
|
|
26
26
|
createHashlineEditTool: typeof createHashlineEditTool;
|
|
27
|
+
createAgentBrowserTool: typeof createAgentBrowserTool;
|
|
28
|
+
createAgentBrowserIntegrationTool: typeof createAgentBrowserIntegrationTool;
|
|
27
29
|
};
|
|
28
30
|
export type ToolRegistryResult = {
|
|
29
31
|
filteredTools: ToolsRecord;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* CRITICAL: This is the ONLY source of truth for core agent ordering.
|
|
3
|
-
* The order is: bob → coder → strategist →
|
|
3
|
+
* The order is: bob → coder → strategist → manager
|
|
4
4
|
*
|
|
5
5
|
* DO NOT CHANGE THIS ORDER. Any PR attempting to modify this order
|
|
6
6
|
* or introduce alternative ordering mechanisms (ZWSP prefixes, sort
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
*
|
|
9
9
|
* See: src/plugin-handlers/AGENTS.md for architectural context.
|
|
10
10
|
*/
|
|
11
|
-
export declare const CANONICAL_CORE_AGENT_ORDER: readonly ["bob", "coder", "strategist", "
|
|
11
|
+
export declare const CANONICAL_CORE_AGENT_ORDER: readonly ["bob", "coder", "strategist", "manager"];
|
|
12
12
|
export declare function reorderAgentsByPriority(agents: Record<string, unknown>): Record<string, unknown>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Agent config keys to display names mapping.
|
|
3
|
-
* Config keys are lowercase (e.g., "bob", "
|
|
3
|
+
* Config keys are lowercase (e.g., "bob", "manager").
|
|
4
4
|
* Display names include suffixes for UI/logs (e.g., "Bob - Ultraworker").
|
|
5
5
|
*
|
|
6
6
|
* IMPORTANT: Display names MUST NOT contain parentheses or other characters
|
|
@@ -25,7 +25,7 @@ export declare function getAgentDisplayName(configKey: string): string;
|
|
|
25
25
|
export declare function getAgentListDisplayName(configKey: string): string;
|
|
26
26
|
/**
|
|
27
27
|
* Resolve an agent name (display name or config key) to its lowercase config key.
|
|
28
|
-
* "
|
|
28
|
+
* "Manager" -> "manager", "Guard" -> "manager", "guard" -> "manager"
|
|
29
29
|
*/
|
|
30
30
|
export declare function getAgentConfigKey(agentName: string): string;
|
|
31
31
|
/**
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Format: [SYSTEM DIRECTIVE: OH-MY-OPENCODE - {TYPE}]
|
|
6
6
|
*/
|
|
7
|
-
export declare const SYSTEM_DIRECTIVE_PREFIX = "[SYSTEM DIRECTIVE:
|
|
7
|
+
export declare const SYSTEM_DIRECTIVE_PREFIX = "[SYSTEM DIRECTIVE: HIAI-OPENCODE";
|
|
8
8
|
/**
|
|
9
9
|
* Creates a system directive header with the given type.
|
|
10
10
|
* @param type - The directive type (e.g., "TODO CONTINUATION", "RALPH LOOP")
|
|
@@ -40,6 +40,6 @@ export declare const SystemDirectiveTypes: {
|
|
|
40
40
|
readonly SINGLE_TASK_ONLY: "SINGLE TASK ONLY";
|
|
41
41
|
readonly COMPACTION_CONTEXT: "COMPACTION CONTEXT";
|
|
42
42
|
readonly CONTEXT_WINDOW_MONITOR: "CONTEXT WINDOW MONITOR";
|
|
43
|
-
readonly
|
|
43
|
+
readonly STRATEGIST_READ_ONLY: "STRATEGIST READ-ONLY";
|
|
44
44
|
};
|
|
45
45
|
export type SystemDirectiveType = (typeof SystemDirectiveTypes)[keyof typeof SystemDirectiveTypes];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* agent-browser tool descriptions and examples
|
|
3
|
+
* Follows the pattern from playwright-cli/constants.ts
|
|
4
|
+
*/
|
|
5
|
+
export declare const AGENT_BROWSER_DESCRIPTION = "agent-browser is a native Rust CLI for browser automation by Vercel Labs.\nIt replaces playwright-cli with a built-in daemon, snapshot-based @eN refs, and 15+ commands.\n\nInstall: npm install -g agent-browser && agent-browser install\n\nKey Commands:\n- open <url> Navigate to a URL\n- snapshot Capture DOM as JSON with @eN element refs\n- click <target> Click element by @eN ref or CSS selector\n- fill <target> <text> Fill form fields\n- type <target> <text> Type text (optionally slowly character-by-character)\n- screenshot Capture screenshot (PNG/JPEG)\n- eval <code> Execute JavaScript in browser context\n- wait <condition> Wait: ms number, --load networkidle, --text \"abc\", --url \"**/path\"\n- close Close current tab (or --all for entire browser)\n- console Read browser console messages\n- select <target> <val> Select dropdown option\n- hover <target> Hover over element\n- press <key> Press keyboard key (Enter, Tab, Control+a, etc.)\n- upload <target> <files> Upload files to file input\n- batch <commands> Run array of commands in sequence\n\nSnapshot-Ref Pattern:\nUse \"snapshot\" to get @eN refs (e.g., @e2, @e5) for deterministic element targeting.\nRefs are stable across page loads \u2014 prefer @eN over CSS selectors when available.\n\nDaemon Behavior:\nagent-browser runs as a daemon \u2014 browser state persists between commands.\nThis enables multi-step workflows without reinitializing the browser each time.\n\nTrigger Phrases:\n\"browser\", \"navigate\", \"screenshot\", \"click\", \"fill form\", \"web page\", \"automate browser\",\n\"take screenshot\", \"fill out the form\", \"log into\", \"scrape\", \"test the website\", \"automate\"";
|
|
6
|
+
export type AgentBrowserDescription = typeof AGENT_BROWSER_DESCRIPTION;
|
|
7
|
+
export declare const AGENT_BROWSER_INSTALL_EXAMPLES: Array<{
|
|
8
|
+
tool: string;
|
|
9
|
+
args: Record<string, unknown>;
|
|
10
|
+
}>;
|
|
11
|
+
export type AgentBrowserInstallExamples = typeof AGENT_BROWSER_INSTALL_EXAMPLES;
|
|
12
|
+
export declare const AGENT_BROWSER_EXAMPLES: Array<{
|
|
13
|
+
tool: string;
|
|
14
|
+
args: Record<string, unknown>;
|
|
15
|
+
}>;
|
|
16
|
+
export type AgentBrowserExamples = typeof AGENT_BROWSER_EXAMPLES;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const AgentBrowserNavigateArgs: z.ZodObject<{
|
|
3
|
+
url: z.ZodString;
|
|
4
|
+
}, z.core.$strip>;
|
|
5
|
+
export type AgentBrowserNavigateArgs = z.infer<typeof AgentBrowserNavigateArgs>;
|
|
6
|
+
export declare const AgentBrowserSnapshotArgs: z.ZodObject<{
|
|
7
|
+
interactive: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
8
|
+
compact: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
9
|
+
selector: z.ZodOptional<z.ZodString>;
|
|
10
|
+
depth: z.ZodOptional<z.ZodNumber>;
|
|
11
|
+
json: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
12
|
+
}, z.core.$strip>;
|
|
13
|
+
export type AgentBrowserSnapshotArgs = z.infer<typeof AgentBrowserSnapshotArgs>;
|
|
14
|
+
export declare const AgentBrowserClickArgs: z.ZodObject<{
|
|
15
|
+
target: z.ZodString;
|
|
16
|
+
button: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
|
|
17
|
+
middle: "middle";
|
|
18
|
+
left: "left";
|
|
19
|
+
right: "right";
|
|
20
|
+
}>>>;
|
|
21
|
+
newTab: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
22
|
+
}, z.core.$strip>;
|
|
23
|
+
export type AgentBrowserClickArgs = z.infer<typeof AgentBrowserClickArgs>;
|
|
24
|
+
export declare const AgentBrowserFillArgs: z.ZodObject<{
|
|
25
|
+
target: z.ZodString;
|
|
26
|
+
text: z.ZodString;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
export type AgentBrowserFillArgs = z.infer<typeof AgentBrowserFillArgs>;
|
|
29
|
+
export declare const AgentBrowserTypeArgs: z.ZodObject<{
|
|
30
|
+
target: z.ZodString;
|
|
31
|
+
text: z.ZodString;
|
|
32
|
+
slowly: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
33
|
+
}, z.core.$strip>;
|
|
34
|
+
export type AgentBrowserTypeArgs = z.infer<typeof AgentBrowserTypeArgs>;
|
|
35
|
+
export declare const AgentBrowserScreenshotArgs: z.ZodObject<{
|
|
36
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
37
|
+
fullPage: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
38
|
+
annotate: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
39
|
+
}, z.core.$strip>;
|
|
40
|
+
export type AgentBrowserScreenshotArgs = z.infer<typeof AgentBrowserScreenshotArgs>;
|
|
41
|
+
export declare const AgentBrowserEvalArgs: z.ZodObject<{
|
|
42
|
+
code: z.ZodString;
|
|
43
|
+
}, z.core.$strip>;
|
|
44
|
+
export type AgentBrowserEvalArgs = z.infer<typeof AgentBrowserEvalArgs>;
|
|
45
|
+
export declare const AgentBrowserWaitArgs: z.ZodObject<{
|
|
46
|
+
condition: z.ZodString;
|
|
47
|
+
}, z.core.$strip>;
|
|
48
|
+
export type AgentBrowserWaitArgs = z.infer<typeof AgentBrowserWaitArgs>;
|
|
49
|
+
export declare const AgentBrowserCloseArgs: z.ZodObject<{
|
|
50
|
+
all: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
51
|
+
}, z.core.$strip>;
|
|
52
|
+
export type AgentBrowserCloseArgs = z.infer<typeof AgentBrowserCloseArgs>;
|
|
53
|
+
export declare const AgentBrowserConsoleArgs: z.ZodObject<{
|
|
54
|
+
json: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
55
|
+
clear: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
56
|
+
}, z.core.$strip>;
|
|
57
|
+
export type AgentBrowserConsoleArgs = z.infer<typeof AgentBrowserConsoleArgs>;
|
|
58
|
+
export declare const AgentBrowserSelectArgs: z.ZodObject<{
|
|
59
|
+
target: z.ZodString;
|
|
60
|
+
value: z.ZodString;
|
|
61
|
+
}, z.core.$strip>;
|
|
62
|
+
export type AgentBrowserSelectArgs = z.infer<typeof AgentBrowserSelectArgs>;
|
|
63
|
+
export declare const AgentBrowserHoverArgs: z.ZodObject<{
|
|
64
|
+
target: z.ZodString;
|
|
65
|
+
}, z.core.$strip>;
|
|
66
|
+
export type AgentBrowserHoverArgs = z.infer<typeof AgentBrowserHoverArgs>;
|
|
67
|
+
export declare const AgentBrowserPressArgs: z.ZodObject<{
|
|
68
|
+
key: z.ZodString;
|
|
69
|
+
}, z.core.$strip>;
|
|
70
|
+
export type AgentBrowserPressArgs = z.infer<typeof AgentBrowserPressArgs>;
|
|
71
|
+
export declare const AgentBrowserUploadArgs: z.ZodObject<{
|
|
72
|
+
target: z.ZodString;
|
|
73
|
+
files: z.ZodArray<z.ZodString>;
|
|
74
|
+
}, z.core.$strip>;
|
|
75
|
+
export type AgentBrowserUploadArgs = z.infer<typeof AgentBrowserUploadArgs>;
|
|
76
|
+
export declare const AgentBrowserBatchArgs: z.ZodObject<{
|
|
77
|
+
commands: z.ZodArray<z.ZodString>;
|
|
78
|
+
bail: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
79
|
+
}, z.core.$strip>;
|
|
80
|
+
export type AgentBrowserBatchArgs = z.infer<typeof AgentBrowserBatchArgs>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { BackgroundManager } from "../../features/background-agent";
|
|
2
|
+
import type { PluginInput } from "@opencode-ai/plugin";
|
|
3
|
+
import type { CallHiaiAgentArgs } from "./types";
|
|
4
|
+
import type { ToolContextWithMetadata } from "./tool-context-with-metadata";
|
|
5
|
+
export declare function executeBackgroundAgent(args: CallHiaiAgentArgs, toolContext: ToolContextWithMetadata, manager: BackgroundManager, client: PluginInput["client"]): Promise<string>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CallHiaiAgentArgs } from "./types";
|
|
2
2
|
import type { BackgroundManager } from "../../features/background-agent";
|
|
3
3
|
import type { PluginInput } from "@opencode-ai/plugin";
|
|
4
4
|
import type { DelegatedModelConfig } from "../../shared/model-resolution-types";
|
|
5
5
|
import type { FallbackEntry } from "../../shared/model-requirements";
|
|
6
|
-
export declare function executeBackground(args:
|
|
6
|
+
export declare function executeBackground(args: CallHiaiAgentArgs, toolContext: {
|
|
7
7
|
sessionID: string;
|
|
8
8
|
messageID: string;
|
|
9
9
|
agent: string;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const PRIMARY_ALLOWED_AGENTS: readonly ["researcher", "strategist", "coder", "critic", "designer", "writer", "multimodal"];
|
|
2
|
+
export declare const ALLOWED_AGENTS: readonly ["researcher", "strategist", "coder", "critic", "designer", "writer", "multimodal"];
|
|
3
|
+
export declare const CALL_HIAI_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.";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CallHiaiAgentArgs } from "./types";
|
|
2
2
|
import type { PluginInput } from "@opencode-ai/plugin";
|
|
3
|
-
export declare function createOrGetSession(args:
|
|
3
|
+
export declare function createOrGetSession(args: CallHiaiAgentArgs, toolContext: {
|
|
4
4
|
sessionID: string;
|
|
5
5
|
messageID: string;
|
|
6
6
|
agent: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PluginInput } from "@opencode-ai/plugin";
|
|
2
|
-
import type {
|
|
2
|
+
import type { CallHiaiAgentArgs } from "./types";
|
|
3
3
|
import type { ToolContextWithMetadata } from "./tool-context-with-metadata";
|
|
4
|
-
export declare function resolveOrCreateSessionId(ctx: PluginInput, args:
|
|
4
|
+
export declare function resolveOrCreateSessionId(ctx: PluginInput, args: CallHiaiAgentArgs, toolContext: ToolContextWithMetadata): Promise<{
|
|
5
5
|
ok: true;
|
|
6
6
|
sessionID: string;
|
|
7
7
|
} | {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CallHiaiAgentArgs } from "./types";
|
|
2
2
|
import type { PluginInput } from "@opencode-ai/plugin";
|
|
3
3
|
import { clearSessionFallbackChain, setSessionFallbackChain } from "../../hooks/model-fallback/hook";
|
|
4
4
|
import type { DelegatedModelConfig } from "../../shared/model-resolution-types";
|
|
@@ -17,7 +17,7 @@ type SpawnReservation = {
|
|
|
17
17
|
commit: () => number;
|
|
18
18
|
rollback: () => void;
|
|
19
19
|
};
|
|
20
|
-
export declare function executeSync(args:
|
|
20
|
+
export declare function executeSync(args: CallHiaiAgentArgs, toolContext: {
|
|
21
21
|
sessionID: string;
|
|
22
22
|
messageID: string;
|
|
23
23
|
agent: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type PluginInput, type ToolDefinition } from "@opencode-ai/plugin";
|
|
2
2
|
import type { BackgroundManager } from "../../features/background-agent";
|
|
3
3
|
import type { CategoriesConfig, AgentOverrides } from "../../config/schema";
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function createCallHiaiAgent(ctx: PluginInput, backgroundManager: BackgroundManager, disabledAgents?: string[], agentOverrides?: AgentOverrides, userCategories?: CategoriesConfig): ToolDefinition;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { ALLOWED_AGENTS } from "./constants";
|
|
2
2
|
export type AllowedAgentType = (typeof ALLOWED_AGENTS)[number];
|
|
3
|
-
export interface
|
|
3
|
+
export interface CallHiaiAgentArgs {
|
|
4
4
|
description: string;
|
|
5
5
|
prompt: string;
|
|
6
6
|
subagent_type: string;
|
|
7
7
|
run_in_background: boolean;
|
|
8
8
|
session_id?: string;
|
|
9
9
|
}
|
|
10
|
-
export interface
|
|
10
|
+
export interface CallHiaiAgentSyncResult {
|
|
11
11
|
title: string;
|
|
12
12
|
metadata: {
|
|
13
13
|
summary?: Array<{
|
|
@@ -6,7 +6,7 @@ export { CATEGORY_DESCRIPTIONS, CATEGORY_PROMPT_APPENDS, DEFAULT_CATEGORIES, } f
|
|
|
6
6
|
* then summarize user requirements and clarify uncertainties before proceeding.
|
|
7
7
|
* Also MANDATES dependency graphs, parallel execution analysis, and category+skill recommendations.
|
|
8
8
|
*/
|
|
9
|
-
export declare const PLAN_AGENT_SYSTEM_PREPEND_STATIC_BEFORE_SKILLS = "<system>\nBEFORE you begin planning, you MUST first understand the user's request deeply.\n\nMANDATORY CONTEXT GATHERING PROTOCOL:\n1. Launch background agents to gather context:\n -
|
|
9
|
+
export declare const PLAN_AGENT_SYSTEM_PREPEND_STATIC_BEFORE_SKILLS = "<system>\nBEFORE you begin planning, you MUST first understand the user's request deeply.\n\nMANDATORY CONTEXT GATHERING PROTOCOL:\n1. Launch background agents to gather context:\n - call_hiai_agent(description=\"Explore codebase patterns\", subagent_type=\"researcher\", run_in_background=true, prompt=\"<search for relevant patterns, files, and implementations in the codebase related to user's request>\")\n - call_hiai_agent(description=\"Research documentation\", subagent_type=\"researcher\", run_in_background=true, prompt=\"<search for external documentation, examples, and best practices related to user's request>\")\n\n2. After gathering context, ALWAYS present:\n - **User Request Summary**: Concise restatement of what the user is asking for\n - **Uncertainties**: List of unclear points, ambiguities, or assumptions you're making\n - **Clarifying Questions**: Specific questions to resolve the uncertainties\n\n3. ITERATE until ALL requirements are crystal clear:\n - Do NOT proceed to planning until you have 100% clarity\n - Ask the user to confirm your understanding\n - Resolve every ambiguity before generating the work plan\n\nREMEMBER: Vague requirements lead to failed implementations. Take the time to understand thoroughly.\n</system>\n\n<CRITICAL_REQUIREMENT_DEPENDENCY_PARALLEL_EXECUTION_CATEGORY_SKILLS>\n#####################################################################\n# #\n# \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2557 #\n# \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557 #\n# \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551 \u2588\u2588\u2551 #\n# \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u255D \u2588\u2588\u2551\u2584\u2584 \u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557\u2588\u2588\u2554\u2550\u2550\u255D \u2588\u2588\u2551 \u2588\u2588\u2551 #\n# \u2588\u2588\uFFFD\uFFFD \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D #\n# \u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2580\u2580\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u255D \u255A\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D\u255A\u2550\u2550\u2550\u2550\u2550\u255D #\n# #\n#####################################################################\n\nYOU MUST INCLUDE THE FOLLOWING SECTIONS IN YOUR PLAN OUTPUT.\nTHIS IS NON-NEGOTIABLE. FAILURE TO INCLUDE THESE SECTIONS = INCOMPLETE PLAN.\n\n\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\n\u2588 SECTION 1: TASK DEPENDENCY GRAPH (MANDATORY) \u2588\n\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\n\nYOU MUST ANALYZE AND DOCUMENT TASK DEPENDENCIES.\n\nFor EVERY task in your plan, you MUST specify:\n- Which tasks it DEPENDS ON (blockers)\n- Which tasks DEPEND ON IT (dependents)\n- The REASON for each dependency\n\nExample format:\n```\n## Task Dependency Graph\n\n| Task | Depends On | Reason |\n|------|------------|--------|\n| Task 1 | None | Starting point, no prerequisites |\n| Task 2 | Task 1 | Requires output/artifact from Task 1 |\n| Task 3 | Task 1 | Uses same foundation established in Task 1 |\n| Task 4 | Task 2, Task 3 | Integrates results from both tasks |\n```\n\nWHY THIS MATTERS:\n- Executors need to know execution ORDER\n- Prevents blocked work from starting prematurely\n- Identifies critical path for project timeline\n\n\n\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\n\u2588 SECTION 2: PARALLEL EXECUTION GRAPH (MANDATORY) \u2588\n\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\n\nYOU MUST IDENTIFY WHICH TASKS CAN RUN IN PARALLEL.\n\nAnalyze your dependency graph and group tasks into PARALLEL EXECUTION WAVES:\n\nExample format:\n```\n## Parallel Execution Graph\n\nWave 1 (Start immediately):\n\u251C\u2500\u2500 Task 1: [description] (no dependencies)\n\u2514\u2500\u2500 Task 5: [description] (no dependencies)\n\nWave 2 (After Wave 1 completes):\n\u251C\u2500\u2500 Task 2: [description] (depends: Task 1)\n\u251C\u2500\u2500 Task 3: [description] (depends: Task 1)\n\u2514\u2500\u2500 Task 6: [description] (depends: Task 5)\n\nWave 3 (After Wave 2 completes):\n\u2514\u2500\u2500 Task 4: [description] (depends: Task 2, Task 3)\n\nCritical Path: Task 1 \u2192 Task 2 \u2192 Task 4\nEstimated Parallel Speedup: 40% faster than sequential\n```\n\nWHY THIS MATTERS:\n- MASSIVE time savings through parallelization\n- Executors can dispatch multiple agents simultaneously\n- Identifies bottlenecks in the execution plan\n\n\n\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\n\u2588 SECTION 3: CATEGORY + SKILLS RECOMMENDATIONS (MANDATORY) \u2588\n\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\n\nFOR EVERY TASK, YOU MUST RECOMMEND:\n1. Which CATEGORY to use for delegation\n2. Which SKILLS to load for the delegated agent\n3. Which EXECUTOR contour is expected from that category:\n - quick/writing/unspecified-low -> coder (fast bounded execution)\n - deep/ultrabrain/visual-engineering/artistry/unspecified-high -> coder (deep execution)\n - use subagent_type=\"critic\" explicitly for review-gate passes\n";
|
|
10
10
|
export declare const PLAN_AGENT_SYSTEM_PREPEND_STATIC_AFTER_SKILLS = "### REQUIRED OUTPUT FORMAT\n\nFor EACH task, include a recommendation block:\n\n```\n### Task N: [Task Title]\n\n**Delegation Recommendation:**\n- Category: `[category-name]` - [reason for choice]\n- Skills: [`skill-1`, `skill-2`] - [reason each skill is needed]\n\n**Skills Evaluation:**\n- INCLUDED `skill-name`: [reason]\n- OMITTED `other-skill`: [reason domain doesn't overlap]\n```\n\nWHY THIS MATTERS:\n- Category determines the MODEL used for execution\n- Skills inject SPECIALIZED KNOWLEDGE into the executor\n- Missing a relevant skill = suboptimal execution\n- Wrong category = wrong model = poor results\n\n\n\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\n\u2588 RESPONSE FORMAT SPECIFICATION (MANDATORY) \u2588\n\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\n\nYOUR PLAN OUTPUT MUST FOLLOW THIS EXACT STRUCTURE:\n\n```markdown\n# [Plan Title]\n\n## Context\n[User request summary, interview findings, research results]\n\n## Task Dependency Graph\n[Dependency table - see Section 1]\n\n## Parallel Execution Graph \n[Wave structure - see Section 2]\n\n## Tasks\n\n### Task 1: [Title]\n**Description**: [What to do]\n**Delegation Recommendation**:\n- Category: `[category]` - [reason]\n- Skills: [`skill-1`] - [reason]\n**Skills Evaluation**: [\u2705 included / \u274C omitted with reasons]\n**Depends On**: [Task IDs or \"None\"]\n**Acceptance Criteria**: [Verifiable conditions]\n\n### Task 2: [Title]\n[Same structure...]\n\n## Commit Strategy\n[How to commit changes atomically]\n\n## Success Criteria\n[Final verification steps]\n```\n\n#####################################################################\n# #\n# FAILURE TO INCLUDE THESE SECTIONS = PLAN WILL BE REJECTED #\n# BY MOMUS REVIEW. DO NOT SKIP. DO NOT ABBREVIATE. #\n# #\n#####################################################################\n</CRITICAL_REQUIREMENT_DEPENDENCY_PARALLEL_EXECUTION_CATEGORY_SKILLS>\n\n<FINAL_OUTPUT_FOR_CALLER>\n\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\n\u2588 SECTION 4: ACTIONABLE TODO LIST FOR CALLER (MANDATORY) \u2588\n\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\n\nYOU MUST END YOUR RESPONSE WITH THIS SECTION.\n\n```markdown\n## TODO List (ADD THESE)\n\n> CALLER: Add these TODOs using TodoWrite/TaskCreate and execute by wave.\n\n### Wave 1 (Start Immediately - No Dependencies)\n\n- [ ] **1. [Task Title]**\n - What: [Clear implementation steps]\n - Depends: None\n - Blocks: [Tasks that depend on this]\n - Category: `category-name`\n - Skills: [`skill-1`, `skill-2`]\n - QA: [How to verify completion - specific command or check]\n\n- [ ] **N. [Task Title]**\n - What: [Steps]\n - Depends: None\n - Blocks: [...]\n - Category: `category-name`\n - Skills: [`skill-1`]\n - QA: [Verification]\n\n### Wave 2 (After Wave 1 Completes)\n\n- [ ] **2. [Task Title]**\n - What: [Steps]\n - Depends: 1\n - Blocks: [4]\n - Category: `category-name`\n - Skills: [`skill-1`]\n - QA: [Verification]\n\n[Continue for all waves...]\n\n## Execution Instructions\n\n1. **Wave 1**: Fire these tasks IN PARALLEL (no dependencies)\n ```\n task(category=\"...\", load_skills=[...], run_in_background=false, prompt=\"Task 1: ...\")\n task(category=\"...\", load_skills=[...], run_in_background=false, prompt=\"Task N: ...\")\n ```\n\n2. **Wave 2**: After Wave 1 completes, fire next wave IN PARALLEL\n ```\n task(category=\"...\", load_skills=[...], run_in_background=false, prompt=\"Task 2: ...\")\n ```\n\n3. Continue until all waves complete\n\n4. Final QA: Verify all tasks pass their QA criteria\n```\n\nWHY THIS FORMAT IS MANDATORY:\n- Caller can directly copy TODO items\n- Wave grouping enables parallel execution\n- Each task has clear task parameters\n- QA criteria ensure verifiable completion\n</FINAL_OUTPUT_FOR_CALLER>\n\n";
|
|
11
11
|
export declare function buildPlanAgentSkillsSection(categories?: AvailableCategory[], skills?: AvailableSkill[]): string;
|
|
12
12
|
export declare function buildPlanAgentSystemPrepend(categories?: AvailableCategory[], skills?: AvailableSkill[]): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const SUB_AGENT_CONFIG_KEY = "sub";
|
|
2
2
|
export declare const CODER_AGENT_CONFIG_KEY = "coder";
|
|
3
3
|
export declare const CRITIC_AGENT_CONFIG_KEY = "critic";
|
|
4
|
-
export declare const CANONICAL_DELEGATE_AGENT_KEYS: readonly ["bob", "
|
|
4
|
+
export declare const CANONICAL_DELEGATE_AGENT_KEYS: readonly ["bob", "manager", "strategist", "critic", "coder", "sub", "researcher", "multimodal", "designer", "writer", "agent-skills"];
|
|
5
5
|
type CanonicalDelegateAgentKey = (typeof CANONICAL_DELEGATE_AGENT_KEYS)[number];
|
|
6
6
|
export type { CanonicalDelegateAgentKey };
|
|
7
7
|
export declare function resolveCanonicalDelegateAgentKey(agentName: string): string;
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -12,10 +12,11 @@ export { createSkillMcpTool } from "./skill-mcp";
|
|
|
12
12
|
import type { PluginInput, ToolDefinition } from "@opencode-ai/plugin";
|
|
13
13
|
import type { BackgroundManager } from "../features/background-agent";
|
|
14
14
|
type OpencodeClient = PluginInput["client"];
|
|
15
|
-
export {
|
|
15
|
+
export { createCallHiaiAgent } from "./call-hiai-agent";
|
|
16
16
|
export { createLookAt } from "./look-at";
|
|
17
17
|
export { createDelegateTask } from "./delegate-task";
|
|
18
18
|
export { createTaskCreateTool, createTaskGetTool, createTaskList, createTaskUpdateTool, } from "./task";
|
|
19
19
|
export { createHashlineEditTool } from "./hashline-edit";
|
|
20
|
+
export { createAgentBrowserTool, createAgentBrowserIntegrationTool } from "./agent-browser";
|
|
20
21
|
export declare function createBackgroundTools(manager: BackgroundManager, client: OpencodeClient): Record<string, ToolDefinition>;
|
|
21
22
|
export declare const builtinTools: Record<string, ToolDefinition>;
|
package/docs/HOOKS.md
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# Hooks Reference
|
|
2
|
+
|
|
3
|
+
**Generated:** 2026-04-26
|
|
4
|
+
|
|
5
|
+
This document catalogs all ~51 hooks used by hiai-opencode for OpenCode plugin integration.
|
|
6
|
+
|
|
7
|
+
## Hook Architecture
|
|
8
|
+
|
|
9
|
+
Hooks are composed in five tiers:
|
|
10
|
+
- **Session hooks**: 21 hooks handling session lifecycle and state
|
|
11
|
+
- **Tool guard hooks**: 15 hooks enforcing pre/post tool execution policies
|
|
12
|
+
- **Transform hooks**: 5 hooks modifying messages and prompts
|
|
13
|
+
- **Continuation hooks**: 8 hooks for multi-turn continuation logic
|
|
14
|
+
- **Skill hooks**: 2 hooks for skill-related functionality
|
|
15
|
+
|
|
16
|
+
## Session Hooks (`create-session-hooks.ts`)
|
|
17
|
+
|
|
18
|
+
| Hook Name | Trigger | Purpose | Side Effects |
|
|
19
|
+
|-----------|---------|---------|--------------|
|
|
20
|
+
| `session.created` | Session created | Initialize session state, model cache | Sets session agent, model state |
|
|
21
|
+
| `session.deleted` | Session deleted | Cleanup session resources | Clears session cache, removes temp files |
|
|
22
|
+
| `session.idle` | Session becomes idle | Advance return chains, loop iterations | Processes deferred returns, triggers loops |
|
|
23
|
+
| `session.error` | Session error | Log error, attempt recovery | Records error state, triggers fallback |
|
|
24
|
+
| `chat.message` | Chat message received | First-message variant gate, keyword detection | Sets session variant, triggers keywords |
|
|
25
|
+
| `chat.params` | Chat parameters resolved | Anthropic effort level, think mode | Applies effort/temperature settings |
|
|
26
|
+
| `chat.headers` | Chat headers built | Copilot x-initiator header injection | Adds authentication headers |
|
|
27
|
+
| `ralphLoop` | Ultrawork mode | Ralph loop continuation enforcement | Tracks task progress, continues work |
|
|
28
|
+
| `todoContinuationEnforcer` | TODO tool used | Enforces todo continuation via system directive | Injects continuation reminders |
|
|
29
|
+
| `sessionRecovery` | Session recovery triggered | Recovery from context exhaustion | Stores/resotres session state |
|
|
30
|
+
| `preemptiveCompaction` | Token limit approaching | Preemptive context reduction | Compresses context before limit |
|
|
31
|
+
| `ultraworkVariantAvailability` | Ultrawork mode check | Determines if ultrawork available | Flags session for ultrawork |
|
|
32
|
+
| `ultraworDBModelOverride` | Ultrawork DB access | Database-level model override | Overrides model from DB |
|
|
33
|
+
| `ultraworkModelOverride` | Ultrawork enabled | Runtime model override for ultrawork | Applies model changes |
|
|
34
|
+
| `noBobGpt` | Bob agent GPT check | Blocks GPT for Bob agent | Modifies model selection |
|
|
35
|
+
| `noCoderNonGpt` | Coder non-GPT check | Blocks non-GPT for coder | Modifies model selection |
|
|
36
|
+
| `nonInteractiveEnv` | Environment check | Detects non-interactive environment | Sets environment flags |
|
|
37
|
+
| `agentUsageReminder` | Agent action | Reminds about agent usage policies | Logs agent usage |
|
|
38
|
+
| `sessionTodoStatus` | Session todo update | Tracks TODO task status across session | Updates todo state |
|
|
39
|
+
| `writeExistingFileGuard` | Write tool on existing file | Prevents overwrite of existing files | Guards file writes |
|
|
40
|
+
| `webfetchRedirectGuard` | Webfetch redirect | Blocks redirects to untrusted domains | Validates redirect URLs |
|
|
41
|
+
| `sessionStatusNormalizer` | Session status check | Normalizes status across OpenCode versions | Standardizes status |
|
|
42
|
+
|
|
43
|
+
## Tool Guard Hooks (`create-tool-guard-hooks.ts`)
|
|
44
|
+
|
|
45
|
+
| Hook Name | Trigger | Purpose | Side Effects |
|
|
46
|
+
|-----------|---------|---------|--------------|
|
|
47
|
+
| `tool.execute.before` | Tool execution starts | Pre-tool guards, file guard, label truncator | Injects rules, validates paths |
|
|
48
|
+
| `tool.execute.after` | Tool execution completes | Post-tool processing, output truncation | Truncates output, logs metadata |
|
|
49
|
+
| `toolPairValidator` | Tool pair execution | Validates sequential tool pairs | Blocks invalid sequences |
|
|
50
|
+
| `toolOutputTruncator` | Tool output generated | Truncates large tool outputs | Limits output size |
|
|
51
|
+
| `preemptiveCompactionNoTextTail` | Compaction without text tail | Prevents text tail removal during compaction | Preserves text tail |
|
|
52
|
+
| `preemptiveCompactionDegradationMonitor` | Compaction degradation | Monitors quality degradation during compaction | Tracks degradation metrics |
|
|
53
|
+
| `modelFallback` | Model unavailable | Attempts fallback chain on model failure | Switches to fallback model |
|
|
54
|
+
| `modelFallbackChatMessage` | Chat message with fallback | Handles chat message fallback | Retries with fallback |
|
|
55
|
+
| `thinkMode` | Think mode enabled | Manages thinking block behavior | Validates thinking usage |
|
|
56
|
+
| `thinkingBlockValidator` | Thinking block detected | Validates thinking block content | Checks block validity |
|
|
57
|
+
| `unstableAgentBabysitter` | Unstable agent detected | Tracks unstable agent behavior | Monitors agent stability |
|
|
58
|
+
| `toolExecuteBeforeGuard` | Pre-execution guard | Additional pre-tool validation | Validates tool call |
|
|
59
|
+
| `toolExecuteAfterGuard` | Post-execution guard | Additional post-tool validation | Reviews tool output |
|
|
60
|
+
| `availableCategories` | Category build | Builds category list for agent prompts | Generates category metadata |
|
|
61
|
+
|
|
62
|
+
## Transform Hooks (`create-transform-hooks.ts`)
|
|
63
|
+
|
|
64
|
+
| Hook Name | Trigger | Purpose | Side Effects |
|
|
65
|
+
|-----------|---------|---------|--------------|
|
|
66
|
+
| `experimental.chat.messages.transform` | Message transform | Context injection, thinking block validation | Modifies message content |
|
|
67
|
+
| `session.compacting` | Session compaction | Context + TODO preservation | Preserves context during compaction |
|
|
68
|
+
| `experimental.session.compacting` | Session compaction | Alternative compaction hook | Handles session compaction |
|
|
69
|
+
| `compactionContextInjector` | Context during compaction | Injects context during compaction | Adds context data |
|
|
70
|
+
| `compactionTodoPreserver` | TODO during compaction | Preserves TODO state during compaction | Saves todo state |
|
|
71
|
+
|
|
72
|
+
## Skill Hooks (`create-skill-hooks.ts`)
|
|
73
|
+
|
|
74
|
+
| Hook Name | Trigger | Purpose | Side Effects |
|
|
75
|
+
|-----------|---------|---------|--------------|
|
|
76
|
+
| `skill.context` | Skill context requested | Builds skill context for tools | Generates skill metadata |
|
|
77
|
+
| `agentUsageReminder` | Agent action | Reminds about skill usage | Logs skill usage |
|
|
78
|
+
|
|
79
|
+
## Hook Configuration
|
|
80
|
+
|
|
81
|
+
Hooks can be disabled via `hiai-opencode.json`:
|
|
82
|
+
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"hooks": {
|
|
86
|
+
"disabled": [
|
|
87
|
+
"preemptiveCompaction",
|
|
88
|
+
"modelFallback"
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Hook Timing (when `HIAI_HOOK_TIMINGS=1`)
|
|
95
|
+
|
|
96
|
+
Enable hook timing measurement by setting the environment variable:
|
|
97
|
+
```
|
|
98
|
+
HIAI_HOOK_TIMINGS=1 opencode ...
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Timings are written to `OPENCODE_LOG` with format: `hook:<name>:<duration_ms>`
|
|
102
|
+
|
|
103
|
+
## Key Hook Dependencies
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
session.created
|
|
107
|
+
└── session.idle
|
|
108
|
+
└── sessionRecovery
|
|
109
|
+
└── session.deleted
|
|
110
|
+
|
|
111
|
+
tool.execute.before
|
|
112
|
+
└── tool.execute.after
|
|
113
|
+
└── toolOutputTruncator
|
|
114
|
+
|
|
115
|
+
chat.message
|
|
116
|
+
├── keywordDetector
|
|
117
|
+
│ └── ralphLoop
|
|
118
|
+
│ └── todoContinuationEnforcer
|
|
119
|
+
└── chat.params
|
|
120
|
+
└── thinkMode
|
|
121
|
+
|
|
122
|
+
experimental.chat.messages.transform
|
|
123
|
+
└── session.compacting
|
|
124
|
+
├── compactionContextInjector
|
|
125
|
+
└── compactionTodoPreserver
|
|
126
|
+
```
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Hook Timings Reference
|
|
2
|
+
|
|
3
|
+
**Generated:** 2026-04-26
|
|
4
|
+
|
|
5
|
+
## HIAI_HOOK_TIMINGS Flag
|
|
6
|
+
|
|
7
|
+
When `HIAI_HOOK_TIMINGS=1` is set in the environment, hiai-opencode writes hook timing data to `hiai-hook-timings-<timestamp>.log` in the project directory.
|
|
8
|
+
|
|
9
|
+
## How It Works
|
|
10
|
+
|
|
11
|
+
1. Set `HIAI_HOOK_TIMINGS=1` before starting OpenCode
|
|
12
|
+
2. The plugin wraps each hook with a timing measurement
|
|
13
|
+
3. After each hook execution, timing data is appended to the log file
|
|
14
|
+
4. Log entries include: hook name, duration in ms, timestamp, session ID
|
|
15
|
+
|
|
16
|
+
## Log Format
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
[YYYY-MM-DD HH:MM:SS.mmm] hook=<hookName> duration=<ms>ms session=<sessionID>
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Enabling/Disabling
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# Enable
|
|
26
|
+
HIAI_HOOK_TIMINGS=1 opencode
|
|
27
|
+
|
|
28
|
+
# Disable (unset the variable)
|
|
29
|
+
unset HIAI_HOOK_TIMINGS
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Analyzing Timings
|
|
33
|
+
|
|
34
|
+
The timing log helps identify:
|
|
35
|
+
- Slow hooks consuming LLM latency budget
|
|
36
|
+
- Hooks with high variance in execution time
|
|
37
|
+
- Session startup bottlenecks
|
|
38
|
+
|
|
39
|
+
## Hook Categories
|
|
40
|
+
|
|
41
|
+
| Category | Count | Notes |
|
|
42
|
+
|----------|-------|-------|
|
|
43
|
+
| Session hooks | 21 | Core lifecycle hooks |
|
|
44
|
+
| Tool guard hooks | 15 | Pre/post tool execution |
|
|
45
|
+
| Transform hooks | 5 | Message/prompt modification |
|
|
46
|
+
| Continuation hooks | 8 | Multi-turn continuation logic |
|
|
47
|
+
| Skill hooks | 2 | Skill-related hooks |
|
|
48
|
+
|
|
49
|
+
## Typical Timings (reference)
|
|
50
|
+
|
|
51
|
+
| Hook Type | Expected Duration |
|
|
52
|
+
|-----------|------------------|
|
|
53
|
+
| Simple session hooks | < 1ms |
|
|
54
|
+
| Tool guard hooks | 1-5ms |
|
|
55
|
+
| Transform hooks | 2-10ms |
|
|
56
|
+
| Continuation hooks | 5-20ms |
|
|
57
|
+
|
|
58
|
+
High durations (>50ms) indicate a potential optimization target.
|