@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,6 @@
|
|
|
1
1
|
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
2
2
|
export declare function isAbortedSessionError(error: unknown): boolean;
|
|
3
|
+
export declare function isRecoverablePromptInjectionError(error: unknown): boolean;
|
|
3
4
|
export declare function getErrorText(error: unknown): string;
|
|
4
5
|
export declare function extractErrorName(error: unknown): string | undefined;
|
|
5
6
|
export declare function extractErrorMessage(error: unknown): string | undefined;
|
|
@@ -7,4 +7,7 @@ export declare const BOULDER_STATE_PATH = ".bob/boulder.json";
|
|
|
7
7
|
export declare const NOTEPAD_DIR = "notepads";
|
|
8
8
|
export declare const NOTEPAD_BASE_PATH = ".bob/notepads";
|
|
9
9
|
/** Strategist plan directory pattern */
|
|
10
|
-
export declare const
|
|
10
|
+
export declare const STRATEGIST_PLANS_DIR = ".bob/plans";
|
|
11
|
+
export declare const BOULDER_REGISTRY_DIR = ".bob/boulder-registry";
|
|
12
|
+
export declare const WORKTREE_BASE_DIR = ".opencode/worktrees";
|
|
13
|
+
export declare const LEGACY_BOULDER_FILE = "boulder.json";
|
|
@@ -5,7 +5,35 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { BoulderState, PlanProgress, TaskSessionState } from "./types";
|
|
7
7
|
export declare function getBoulderFilePath(directory: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Read boulder state — v2 compatible
|
|
10
|
+
*
|
|
11
|
+
* v2 behavior:
|
|
12
|
+
* 1. Check if registry exists and has entries
|
|
13
|
+
* 2. If exactly ONE plan exists, return that plan's state (single-plan mode)
|
|
14
|
+
* 3. If ZERO plans exist, check for legacy boulder.json (migration needed)
|
|
15
|
+
* 4. If MULTIPLE plans exist, return null (caller must use registry functions)
|
|
16
|
+
*
|
|
17
|
+
* @param directory - Root directory (where .bob/ lives)
|
|
18
|
+
* @returns BoulderState | null
|
|
19
|
+
*
|
|
20
|
+
* @deprecated For multi-plan scenarios, use readBoulderForPlan() directly
|
|
21
|
+
*/
|
|
8
22
|
export declare function readBoulderState(directory: string): BoulderState | null;
|
|
23
|
+
/**
|
|
24
|
+
* Write boulder state — v2 compatible
|
|
25
|
+
*
|
|
26
|
+
* v2 behavior:
|
|
27
|
+
* 1. Ensure registry exists (triggers migration if legacy boulder.json found)
|
|
28
|
+
* 2. Write to registry using state.plan_name
|
|
29
|
+
* 3. If legacy boulder.json exists, migrate it
|
|
30
|
+
*
|
|
31
|
+
* @param directory - Root directory (where .bob/ lives)
|
|
32
|
+
* @param state - BoulderState to write
|
|
33
|
+
* @returns true on success, false on failure
|
|
34
|
+
*
|
|
35
|
+
* @deprecated For multi-plan scenarios, use writeBoulderForPlan() directly
|
|
36
|
+
*/
|
|
9
37
|
export declare function writeBoulderState(directory: string, state: BoulderState): boolean;
|
|
10
38
|
export declare function appendSessionId(directory: string, sessionId: string, origin?: "direct" | "appended"): BoulderState | null;
|
|
11
39
|
export declare function clearBoulderState(directory: string): boolean;
|
|
@@ -42,3 +70,69 @@ export declare function getPlanName(planPath: string): string;
|
|
|
42
70
|
* Create a new boulder state for a plan.
|
|
43
71
|
*/
|
|
44
72
|
export declare function createBoulderState(planPath: string, sessionId: string, agent?: string, worktreePath?: string): BoulderState;
|
|
73
|
+
/**
|
|
74
|
+
* Get the boulder registry directory path
|
|
75
|
+
* @returns `{directory}/.bob/boulder-registry`
|
|
76
|
+
*/
|
|
77
|
+
export declare function getRegistryDir(directory: string): string;
|
|
78
|
+
/**
|
|
79
|
+
* Read boulder state for a specific plan from registry
|
|
80
|
+
* @returns BoulderState | null if not found or invalid
|
|
81
|
+
*/
|
|
82
|
+
export declare function readBoulderForPlan(directory: string, planName: string): BoulderState | null;
|
|
83
|
+
/**
|
|
84
|
+
* Write boulder state for a specific plan atomically
|
|
85
|
+
* Pattern: write to .tmp file, then rename (atomic on POSIX)
|
|
86
|
+
* @returns true on success, false on failure
|
|
87
|
+
*/
|
|
88
|
+
export declare function writeBoulderForPlan(directory: string, planName: string, state: BoulderState): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Delete boulder state for a specific plan from registry
|
|
91
|
+
* @returns true on success, false if file doesn't exist or error
|
|
92
|
+
*/
|
|
93
|
+
export declare function deleteBoulderForPlan(directory: string, planName: string): boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Get list of all active plan names from registry
|
|
96
|
+
* @returns Array of plan names (without .json extension)
|
|
97
|
+
*/
|
|
98
|
+
export declare function getActivePlans(directory: string): string[];
|
|
99
|
+
/**
|
|
100
|
+
* Get count of active plans
|
|
101
|
+
*/
|
|
102
|
+
export declare function getActivePlanCount(directory: string): number;
|
|
103
|
+
/**
|
|
104
|
+
* Find which plan a session ID belongs to
|
|
105
|
+
* Searches all registry files for the session ID
|
|
106
|
+
* @returns Plan name or null if not found
|
|
107
|
+
*/
|
|
108
|
+
export declare function findPlanNameForSession(directory: string, sessionId: string): string | null;
|
|
109
|
+
/**
|
|
110
|
+
* Check if there's a conflicting active plan (not the excluded one)
|
|
111
|
+
* @returns true if another plan exists
|
|
112
|
+
*/
|
|
113
|
+
export declare function hasConflictingPlan(directory: string, excludePlanName: string): boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Migrate v1 boulder.json to v2 registry format
|
|
116
|
+
* Reads old boulder.json, copies to boulder-registry/{plan_name}.json, renames to .bak
|
|
117
|
+
* @returns true on success or if already migrated, false on failure
|
|
118
|
+
*/
|
|
119
|
+
export declare function migrateV1ToV2(directory: string): boolean;
|
|
120
|
+
/**
|
|
121
|
+
* Ensure registry directory exists, trigger migration if v1 found
|
|
122
|
+
*/
|
|
123
|
+
export declare function ensureRegistryExists(directory: string): void;
|
|
124
|
+
/**
|
|
125
|
+
* Complete a plan: sync notepads from worktree, remove worktree, delete boulder from registry
|
|
126
|
+
* @param directory - Root directory (where registry lives)
|
|
127
|
+
* @param planName - Plan name to complete
|
|
128
|
+
* @param worktreePath - Optional worktree path to clean up
|
|
129
|
+
* @returns true on success
|
|
130
|
+
*/
|
|
131
|
+
export declare function completePlan(directory: string, planName: string, worktreePath?: string): boolean;
|
|
132
|
+
/**
|
|
133
|
+
* Sync .bob/ directory from worktree back to root
|
|
134
|
+
* Copies notepads and other boulder state files
|
|
135
|
+
* @param rootDirectory - Main repo root
|
|
136
|
+
* @param worktreePath - Worktree path to sync from
|
|
137
|
+
*/
|
|
138
|
+
export declare function syncBoulderNotepadsFromWorktree(rootDirectory: string, worktreePath: string): void;
|
|
@@ -4,6 +4,23 @@
|
|
|
4
4
|
* Manages the active work plan state for Bob orchestrator.
|
|
5
5
|
* Named after Bob's boulder - the eternal task that must be rolled.
|
|
6
6
|
*/
|
|
7
|
+
/**
|
|
8
|
+
* BoulderState - DO NOT MODIFY
|
|
9
|
+
*
|
|
10
|
+
* This type is used by 10+ consumer files across the codebase.
|
|
11
|
+
* Any changes require updating ALL consumers:
|
|
12
|
+
* - resolve-active-boulder-session.ts
|
|
13
|
+
* - idle-event.ts (lines 54, 162, 205)
|
|
14
|
+
* - boulder-continuation-injector.ts
|
|
15
|
+
* - tool-execute-after.ts
|
|
16
|
+
* - tool-execute-before.ts
|
|
17
|
+
* - agent-resolution.ts
|
|
18
|
+
* - boulder-session-lineage.ts
|
|
19
|
+
* - background-launch-session-tracking.ts
|
|
20
|
+
*
|
|
21
|
+
* For new fields, add to BoulderState interface here AND update all consumers.
|
|
22
|
+
* For registry-specific data, use separate BoulderRegistry type (not this one).
|
|
23
|
+
*/
|
|
7
24
|
export interface BoulderState {
|
|
8
25
|
/** Absolute path to the active plan file */
|
|
9
26
|
active_plan: string;
|
|
@@ -14,7 +31,7 @@ export interface BoulderState {
|
|
|
14
31
|
session_origins?: Record<string, "direct" | "appended">;
|
|
15
32
|
/** Plan name derived from filename */
|
|
16
33
|
plan_name: string;
|
|
17
|
-
/** Agent type to use when resuming (e.g., '
|
|
34
|
+
/** Agent type to use when resuming (e.g., 'manager') */
|
|
18
35
|
agent?: string;
|
|
19
36
|
/** Absolute path to the git worktree root where work happens */
|
|
20
37
|
worktree_path?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const DOCTOR_TEMPLATE = "# Hiai OpenCode Doctor Command\n\n## Purpose\n\nUse /doctor to run the hiai-opencode install/runtime diagnostic and report actionable setup issues.\n\n## Execute\n\nRun:\n\n```bash\nhiai-opencode doctor\n```\n\nIf the binary is not on PATH, try the package-local fallback:\n\n```bash\nnode ./node_modules/@hiai-gg/hiai-opencode/assets/cli/hiai-opencode.mjs doctor\n```\n\n## Report\n\nSummarize:\n\n- config path\n- enabled and disabled MCP servers\n- missing env vars by name only\n- static `.mcp.json` freshness and whether it is managed by hiai-opencode\n- OpenCode Connect visibility for configured model providers\n- OpenCode plugin registration sanity (including `plugin: [\"list\"]` misconfiguration warning)\n- skill materialization status from skill registry\n- agent count and naming summary\n- LSP runtime availability\n- MemPalace python source and selected interpreter (env/config/auto)\n- MCP tool probes (real connect + tools/list) for stdio and basic endpoint probes for remote MCP\n\nRules:\n\n- Do not print API key values.\n- Do not ask for model provider env vars such as OPENROUTER_API_KEY or OPENAI_API_KEY; normal model auth belongs to OpenCode Connect.\n- If `opencode mcp list` is empty but doctor/mcp-status sees servers, explain the runtime-vs-static config distinction and run `hiai-opencode export-mcp .mcp.json` if the user wants static visibility.\n- Do not run package installs unless the user explicitly asks.\n";
|
|
1
|
+
export declare const DOCTOR_TEMPLATE = "# Hiai OpenCode Doctor Command\n\n## Purpose\n\nUse /doctor to run the hiai-opencode install/runtime diagnostic and report actionable setup issues.\n\n## Execute\n\nRun:\n\n```bash\nhiai-opencode doctor\n```\n\nIf the binary is not on PATH, try the package-local fallback:\n\n```bash\nnode ./node_modules/@hiai-gg/hiai-opencode/assets/cli/hiai-opencode.mjs doctor\n```\n\n## Report\n\nSummarize:\n\n- config path\n- enabled and disabled MCP servers\n- missing env vars by name only\n- static `.mcp.json` freshness and whether it is managed by hiai-opencode\n- OpenCode Connect visibility for configured model providers\n- OpenCode plugin registration sanity (including `plugin: [\"list\"]` misconfiguration warning)\n- skill materialization status from skill registry\n- agent count and naming summary\n- LSP runtime availability\n- MemPalace python source and selected interpreter (env/config/auto)\n- MCP tool probes (real connect + tools/list) for stdio and basic endpoint probes for remote MCP\n\nRules:\n\n- Do not print API key values.\n- Do not ask for model provider env vars such as OPENROUTER_API_KEY or OPENAI_API_KEY; normal model auth belongs to OpenCode Connect.\n- If `opencode mcp list` is empty but doctor/mcp-status sees servers, explain the runtime-vs-static config distinction and run `hiai-opencode export-mcp .opencode/.mcp.json` if the user wants static visibility.\n- Do not run package installs unless the user explicitly asks.\n";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const REFACTOR_TEMPLATE = "# Intelligent Refactor Command\n\n## Usage\n```\n/refactor <refactoring-target> [--scope=<file|module|project>] [--strategy=<safe|aggressive>]\n\nArguments:\n refactoring-target: What to refactor. Can be:\n - File path: src/auth/handler.ts\n - Symbol name: \"AuthService class\"\n - Pattern: \"all functions using deprecated API\"\n - Description: \"extract validation logic into separate module\"\n\nOptions:\n --scope: Refactoring scope (default: module)\n - file: Single file only\n - module: Module/directory scope\n - project: Entire codebase\n\n --strategy: Risk tolerance (default: safe)\n - safe: Conservative, maximum test coverage required\n - aggressive: Allow broader changes with adequate coverage\n```\n\n## What This Command Does\n\nPerforms intelligent, deterministic refactoring with full codebase awareness. Unlike blind search-and-replace, this command:\n\n1. **Understands your intent** - Analyzes what you actually want to achieve\n2. **Maps the codebase** - Builds a definitive codemap before touching anything\n3. **Assesses risk** - Evaluates test coverage and determines verification strategy\n4. **Plans meticulously** - Creates a detailed plan with Strategist\n5. **Executes precisely** - Step-by-step refactoring with LSP and AST-grep\n6. **Verifies constantly** - Runs tests after each change to ensure zero regression\n\n---\n\n# PHASE 0: INTENT GATE (MANDATORY FIRST STEP)\n\n**BEFORE ANY ACTION, classify and validate the request.**\n\n## Step 0.1: Parse Request Type\n\n| Signal | Classification | Action |\n|--------|----------------|--------|\n| Specific file/symbol | Explicit | Proceed to codebase analysis |\n| \"Refactor X to Y\" | Clear transformation | Proceed to codebase analysis |\n| \"Improve\", \"Clean up\" | Open-ended | **MUST ask**: \"What specific improvement?\" |\n| Ambiguous scope | Uncertain | **MUST ask**: \"Which modules/files?\" |\n| Missing context | Incomplete | **MUST ask**: \"What's the desired outcome?\" |\n\n## Step 0.2: Validate Understanding\n\nBefore proceeding, confirm:\n- [ ] Target is clearly identified\n- [ ] Desired outcome is understood\n- [ ] Scope is defined (file/module/project)\n- [ ] Success criteria can be articulated\n\n**If ANY of above is unclear, ASK CLARIFYING QUESTION:**\n\n```\nI want to make sure I understand the refactoring goal correctly.\n\n**What I understood**: [interpretation]\n**What I'm unsure about**: [specific ambiguity]\n\nOptions I see:\n1. [Option A] - [implications]\n2. [Option B] - [implications]\n\n**My recommendation**: [suggestion with reasoning]\n\nShould I proceed with [recommendation], or would you prefer differently?\n```\n\n## Step 0.3: Create Initial Todos\n\n**IMMEDIATELY after understanding the request, create todos:**\n\n```\nTodoWrite([\n {\"id\": \"phase-1\", \"content\": \"PHASE 1: Codebase Analysis - launch parallel researcher agents\", \"status\": \"pending\", \"priority\": \"high\"},\n {\"id\": \"phase-2\", \"content\": \"PHASE 2: Build Codemap - map dependencies and impact zones\", \"status\": \"pending\", \"priority\": \"high\"},\n {\"id\": \"phase-3\", \"content\": \"PHASE 3: Test Assessment - analyze test coverage and verification strategy\", \"status\": \"pending\", \"priority\": \"high\"},\n {\"id\": \"phase-4\", \"content\": \"PHASE 4: Plan Generation - invoke Strategist for detailed refactoring plan\", \"status\": \"pending\", \"priority\": \"high\"},\n {\"id\": \"phase-5\", \"content\": \"PHASE 5: Execute Refactoring - step-by-step with continuous verification\", \"status\": \"pending\", \"priority\": \"high\"},\n {\"id\": \"phase-6\", \"content\": \"PHASE 6: Final Verification - full test suite and regression check\", \"status\": \"pending\", \"priority\": \"high\"}\n])\n```\n\n---\n\n# PHASE 1: CODEBASE ANALYSIS (PARALLEL EXPLORATION)\n\n**Mark phase-1 as in_progress.**\n\n## 1.1: Launch Parallel Researcher Agents (BACKGROUND)\n\nFire ALL of these simultaneously using `call_omo_agent`:\n\n```\n// Agent 1: Find the refactoring target\ncall_omo_agent(\n subagent_type=\"researcher\",\n run_in_background=true,\n prompt=\"Find all occurrences and definitions of [TARGET]. \n Report: file paths, line numbers, usage patterns.\"\n)\n\n// Agent 2: Find related code\ncall_omo_agent(\n subagent_type=\"researcher\", \n run_in_background=true,\n prompt=\"Find all code that imports, uses, or depends on [TARGET].\n Report: dependency chains, import graphs.\"\n)\n\n// Agent 3: Find similar patterns\ncall_omo_agent(\n subagent_type=\"researcher\",\n run_in_background=true,\n prompt=\"Find similar code patterns to [TARGET] in the codebase.\n Report: analogous implementations, established conventions.\"\n)\n\n// Agent 4: Find tests\ncall_omo_agent(\n subagent_type=\"researcher\",\n run_in_background=true,\n prompt=\"Find all test files related to [TARGET].\n Report: test file paths, test case names, coverage indicators.\"\n)\n\n// Agent 5: Architecture context\ncall_omo_agent(\n subagent_type=\"researcher\",\n run_in_background=true,\n prompt=\"Find architectural patterns and module organization around [TARGET].\n Report: module boundaries, layer structure, design patterns in use.\"\n)\n```\n\n## 1.2: Direct Tool Exploration (WHILE AGENTS RUN)\n\nWhile background agents are running, use direct tools:\n\n### LSP Tools for Precise Analysis:\n\n```typescript\n// Find definition(s)\nLspGotoDefinition(filePath, line, character) // Where is it defined?\n\n// Find ALL usages across workspace\nLspFindReferences(filePath, line, character, includeDeclaration=true)\n\n// Get file structure\nLspDocumentSymbols(filePath) // Hierarchical outline\nLspWorkspaceSymbols(filePath, query=\"[target_symbol]\") // Search by name\n\n// Get current diagnostics\nlsp_diagnostics(filePath) // Errors, warnings before we start\n```\n\n### AST-Grep for Pattern Analysis:\n\n```typescript\n// Find structural patterns\nast_grep_search(\n pattern=\"function $NAME($$$) { $$$ }\", // or relevant pattern\n lang=\"typescript\", // or relevant language\n paths=[\"src/\"]\n)\n\n// Preview refactoring (DRY RUN)\nast_grep_replace(\n pattern=\"[old_pattern]\",\n rewrite=\"[new_pattern]\",\n lang=\"[language]\",\n dryRun=true // ALWAYS preview first\n)\n```\n\n### Grep for Text Patterns:\n\n```\ngrep(pattern=\"[search_term]\", path=\"src/\", include=\"*.ts\")\n```\n\n## 1.3: Collect Background Results\n\n```\nbackground_output(task_id=\"[agent_1_id]\")\nbackground_output(task_id=\"[agent_2_id]\")\n...\n```\n\n**Mark phase-1 as completed after all results collected.**\n\n---\n\n# PHASE 2: BUILD CODEMAP (DEPENDENCY MAPPING)\n\n**Mark phase-2 as in_progress.**\n\n## 2.1: Construct Definitive Codemap\n\nBased on Phase 1 results, build:\n\n```\n## CODEMAP: [TARGET]\n\n### Core Files (Direct Impact)\n- `path/to/file.ts:L10-L50` - Primary definition\n- `path/to/file2.ts:L25` - Key usage\n\n### Dependency Graph\n```\n[TARGET] \n\u251C\u2500\u2500 imports from: \n\u2502 \u251C\u2500\u2500 module-a (types)\n\u2502 \u2514\u2500\u2500 module-b (utils)\n\u251C\u2500\u2500 imported by:\n\u2502 \u251C\u2500\u2500 consumer-1.ts\n\u2502 \u251C\u2500\u2500 consumer-2.ts\n\u2502 \u2514\u2500\u2500 consumer-3.ts\n\u2514\u2500\u2500 used by:\n \u251C\u2500\u2500 handler.ts (direct call)\n \u2514\u2500\u2500 service.ts (dependency injection)\n```\n\n### Impact Zones\n| Zone | Risk Level | Files Affected | Test Coverage |\n|------|------------|----------------|---------------|\n| Core | HIGH | 3 files | 85% covered |\n| Consumers | MEDIUM | 8 files | 70% covered |\n| Edge | LOW | 2 files | 50% covered |\n\n### Established Patterns\n- Pattern A: [description] - used in N places\n- Pattern B: [description] - established convention\n```\n\n## 2.2: Identify Refactoring Constraints\n\nBased on codemap:\n- **MUST follow**: [existing patterns identified]\n- **MUST NOT break**: [critical dependencies]\n- **Safe to change**: [isolated code zones]\n- **Requires migration**: [breaking changes impact]\n\n**Mark phase-2 as completed.**\n\n---\n\n# PHASE 3: TEST ASSESSMENT (VERIFICATION STRATEGY)\n\n**Mark phase-3 as in_progress.**\n\n## 3.1: Detect Test Infrastructure\n\n```bash\n# Check for test commands\ncat package.json | jq '.scripts | keys[] | select(test(\"test\"))'\n\n# Or for Python\nls -la pytest.ini pyproject.toml setup.cfg\n\n# Or for Go\nls -la *_test.go\n```\n\n## 3.2: Analyze Test Coverage\n\n```\n// Find all tests related to target\ncall_omo_agent(\n subagent_type=\"researcher\",\n run_in_background=false, // Need this synchronously\n prompt=\"Analyze test coverage for [TARGET]:\n 1. Which test files cover this code?\n 2. What test cases exist?\n 3. Are there integration tests?\n 4. What edge cases are tested?\n 5. Estimated coverage percentage?\"\n)\n```\n\n## 3.3: Determine Verification Strategy\n\nBased on test analysis:\n\n| Coverage Level | Strategy |\n|----------------|----------|\n| HIGH (>80%) | Run existing tests after each step |\n| MEDIUM (50-80%) | Run tests + add safety assertions |\n| LOW (<50%) | **PAUSE**: Propose adding tests first |\n| NONE | **BLOCK**: Refuse aggressive refactoring |\n\n**If coverage is LOW or NONE, ask user:**\n\n```\nTest coverage for [TARGET] is [LEVEL].\n\n**Risk Assessment**: Refactoring without adequate tests is dangerous.\n\nOptions:\n1. Add tests first, then refactor (RECOMMENDED)\n2. Proceed with extra caution, manual verification required\n3. Abort refactoring\n\nWhich approach do you prefer?\n```\n\n## 3.4: Document Verification Plan\n\n```\n## VERIFICATION PLAN\n\n### Test Commands\n- Unit: `bun test` / `npm test` / `pytest` / etc.\n- Integration: [command if exists]\n- Type check: `tsc --noEmit` / `pyright` / etc.\n\n### Verification Checkpoints\nAfter each refactoring step:\n1. lsp_diagnostics \u2192 zero new errors\n2. Run test command \u2192 all pass\n3. Type check \u2192 clean\n\n### Regression Indicators\n- [Specific test that must pass]\n- [Behavior that must be preserved]\n- [API contract that must not change]\n```\n\n**Mark phase-3 as completed.**\n\n---\n\n# PHASE 4: PLAN GENERATION (STRATEGIST)\n\n**Mark phase-4 as in_progress.**\n\n## 4.1: Invoke Strategist\n\n```\nTask(\n subagent_type=\"strategist\",\n prompt=\"Create a detailed refactoring plan:\n\n ## Refactoring Goal\n [User's original request]\n\n ## Codemap (from Phase 2)\n [Insert codemap here]\n\n ## Test Coverage (from Phase 3)\n [Insert verification plan here]\n\n ## Constraints\n - MUST follow existing patterns: [list]\n - MUST NOT break: [critical paths]\n - MUST run tests after each step\n\n ## Requirements\n 1. Break down into atomic refactoring steps\n 2. Each step must be independently verifiable\n 3. Order steps by dependency (what must happen first)\n 4. Specify exact files and line ranges for each step\n 5. Include rollback strategy for each step\n 6. Define commit checkpoints\"\n)\n```\n\n## 4.2: Review and Validate Plan\n\nAfter receiving plan from Strategist:\n\n1. **Verify completeness**: All identified files addressed?\n2. **Verify safety**: Each step reversible?\n3. **Verify order**: Dependencies respected?\n4. **Verify verification**: Test commands specified?\n\n## 4.3: Register Detailed Todos\n\nConvert Strategist output into granular todos:\n\n```\nTodoWrite([\n // Each step from the plan becomes a todo\n {\"id\": \"refactor-1\", \"content\": \"Step 1: [description]\", \"status\": \"pending\", \"priority\": \"high\"},\n {\"id\": \"verify-1\", \"content\": \"Verify Step 1: run tests\", \"status\": \"pending\", \"priority\": \"high\"},\n {\"id\": \"refactor-2\", \"content\": \"Step 2: [description]\", \"status\": \"pending\", \"priority\": \"medium\"},\n {\"id\": \"verify-2\", \"content\": \"Verify Step 2: run tests\", \"status\": \"pending\", \"priority\": \"medium\"},\n // ... continue for all steps\n])\n```\n\n**Mark phase-4 as completed.**\n\n---\n\n# PHASE 5: EXECUTE REFACTORING (DETERMINISTIC EXECUTION)\n\n**Mark phase-5 as in_progress.**\n\n## 5.1: Execution Protocol\n\nFor EACH refactoring step:\n\n### Pre-Step\n1. Mark step todo as `in_progress`\n2. Read current file state\n3. Verify lsp_diagnostics is baseline\n\n### Execute Step\nUse appropriate tool:\n\n**For Symbol Renames:**\n```typescript\nlsp_prepare_rename(filePath, line, character) // Validate rename is possible\nlsp_rename(filePath, line, character, newName) // Execute rename\n```\n\n**For Pattern Transformations:**\n```typescript\n// Preview first\nast_grep_replace(pattern, rewrite, lang, dryRun=true)\n\n// If preview looks good, execute\nast_grep_replace(pattern, rewrite, lang, dryRun=false)\n```\n\n**For Structural Changes:**\n```typescript\n// Use Edit tool for precise changes\nedit(filePath, oldString, newString)\n```\n\n### Post-Step Verification (MANDATORY)\n\n```typescript\n// 1. Check diagnostics\nlsp_diagnostics(filePath) // Must be clean or same as baseline\n\n// 2. Run tests\nbash(\"bun test\") // Or appropriate test command\n\n// 3. Type check\nbash(\"tsc --noEmit\") // Or appropriate type check\n```\n\n### Step Completion\n1. If verification passes \u2192 Mark step todo as `completed`\n2. If verification fails \u2192 **STOP AND FIX**\n\n## 5.2: Failure Recovery Protocol\n\nIf ANY verification fails:\n\n1. **STOP** immediately\n2. **REVERT** the failed change\n3. **DIAGNOSE** what went wrong\n4. **OPTIONS**:\n - Fix the issue and retry\n - Skip this step (if optional)\n - Consult critic agent for help\n - Ask user for guidance\n\n**NEVER proceed to next step with broken tests.**\n\n## 5.3: Commit Checkpoints\n\nAfter each logical group of changes:\n\n```bash\ngit add [changed-files]\ngit commit -m \"refactor(scope): description\n\n[details of what was changed and why]\"\n```\n\n**Mark phase-5 as completed when all refactoring steps done.**\n\n---\n\n# PHASE 6: FINAL VERIFICATION (REGRESSION CHECK)\n\n**Mark phase-6 as in_progress.**\n\n## 6.1: Full Test Suite\n\n```bash\n# Run complete test suite\nbun test # or npm test, pytest, go test, etc.\n```\n\n## 6.2: Type Check\n\n```bash\n# Full type check\ntsc --noEmit # or equivalent\n```\n\n## 6.3: Lint Check\n\n```bash\n# Run linter\neslint . # or equivalent\n```\n\n## 6.4: Build Verification (if applicable)\n\n```bash\n# Ensure build still works\nbun run build # or npm run build, etc.\n```\n\n## 6.5: Final Diagnostics\n\n```typescript\n// Check all changed files\nfor (file of changedFiles) {\n lsp_diagnostics(file) // Must all be clean\n}\n```\n\n## 6.6: Generate Summary\n\n```markdown\n## Refactoring Complete\n\n### What Changed\n- [List of changes made]\n\n### Files Modified\n- `path/to/file.ts` - [what changed]\n- `path/to/file2.ts` - [what changed]\n\n### Verification Results\n- Tests: PASSED (X/Y passing)\n- Type Check: CLEAN\n- Lint: CLEAN\n- Build: SUCCESS\n\n### No Regressions Detected\nAll existing tests pass. No new errors introduced.\n```\n\n**Mark phase-6 as completed.**\n\n---\n\n# CRITICAL RULES\n\n## NEVER DO\n- Skip lsp_diagnostics check after changes\n- Proceed with failing tests\n- Make changes without understanding impact\n- Use `as any`, `@ts-ignore`, `@ts-expect-error`\n- Delete tests to make them pass\n- Commit broken code\n- Refactor without understanding existing patterns\n\n## ALWAYS DO\n- Understand before changing\n- Preview before applying (ast_grep dryRun=true)\n- Verify after every change\n- Follow existing codebase patterns\n- Keep todos updated in real-time\n- Commit at logical checkpoints\n- Report issues immediately\n\n## ABORT CONDITIONS\nIf any of these occur, **STOP and consult user**:\n- Test coverage is zero for target code\n- Changes would break public API\n- Refactoring scope is unclear\n- 3 consecutive verification failures\n- User-defined constraints violated\n\n---\n\n# Tool Usage Philosophy\n\nYou already know these tools. Use them intelligently:\n\n## LSP Tools\nLeverage LSP tools for precision analysis. Key patterns:\n- **Understand before changing**: `LspGotoDefinition` to grasp context\n- **Impact analysis**: `LspFindReferences` to map all usages before modification\n- **Safe refactoring**: `lsp_prepare_rename` \u2192 `lsp_rename` for symbol renames\n- **Continuous verification**: `lsp_diagnostics` after every change\n\n## AST-Grep\nUse `ast_grep_search` and `ast_grep_replace` for structural transformations.\n**Critical**: Always `dryRun=true` first, review, then execute.\n\n## Agents\n- `researcher`: Parallel codebase pattern discovery\n- `strategist`: Detailed refactoring plan generation\n- `critic`: Read-only consultation for complex architectural decisions and debugging\n- `researcher`: **Use proactively** when encountering deprecated methods or library migration tasks. Query official docs and OSS examples for modern replacements.\n\n## Deprecated Code & Library Migration\nWhen you encounter deprecated methods/APIs during refactoring:\n1. Fire `researcher` to find the recommended modern alternative\n2. **DO NOT auto-upgrade to latest version** unless user explicitly requests migration\n3. If user requests library migration, use `researcher` to fetch latest API docs before making changes\n\n---\n\n**Remember: Refactoring without tests is reckless. Refactoring without understanding is destructive. This command ensures you do neither.**\n\n<user-request>\n$ARGUMENTS\n</user-request>\n";
|
|
1
|
+
export declare const REFACTOR_TEMPLATE = "# Intelligent Refactor Command\n\n## Usage\n```\n/refactor <refactoring-target> [--scope=<file|module|project>] [--strategy=<safe|aggressive>]\n\nArguments:\n refactoring-target: What to refactor. Can be:\n - File path: src/auth/handler.ts\n - Symbol name: \"AuthService class\"\n - Pattern: \"all functions using deprecated API\"\n - Description: \"extract validation logic into separate module\"\n\nOptions:\n --scope: Refactoring scope (default: module)\n - file: Single file only\n - module: Module/directory scope\n - project: Entire codebase\n\n --strategy: Risk tolerance (default: safe)\n - safe: Conservative, maximum test coverage required\n - aggressive: Allow broader changes with adequate coverage\n```\n\n## What This Command Does\n\nPerforms intelligent, deterministic refactoring with full codebase awareness. Unlike blind search-and-replace, this command:\n\n1. **Understands your intent** - Analyzes what you actually want to achieve\n2. **Maps the codebase** - Builds a definitive codemap before touching anything\n3. **Assesses risk** - Evaluates test coverage and determines verification strategy\n4. **Plans meticulously** - Creates a detailed plan with Strategist\n5. **Executes precisely** - Step-by-step refactoring with LSP and AST-grep\n6. **Verifies constantly** - Runs tests after each change to ensure zero regression\n\n---\n\n# PHASE 0: INTENT GATE (MANDATORY FIRST STEP)\n\n**BEFORE ANY ACTION, classify and validate the request.**\n\n## Step 0.1: Parse Request Type\n\n| Signal | Classification | Action |\n|--------|----------------|--------|\n| Specific file/symbol | Explicit | Proceed to codebase analysis |\n| \"Refactor X to Y\" | Clear transformation | Proceed to codebase analysis |\n| \"Improve\", \"Clean up\" | Open-ended | **MUST ask**: \"What specific improvement?\" |\n| Ambiguous scope | Uncertain | **MUST ask**: \"Which modules/files?\" |\n| Missing context | Incomplete | **MUST ask**: \"What's the desired outcome?\" |\n\n## Step 0.2: Validate Understanding\n\nBefore proceeding, confirm:\n- [ ] Target is clearly identified\n- [ ] Desired outcome is understood\n- [ ] Scope is defined (file/module/project)\n- [ ] Success criteria can be articulated\n\n**If ANY of above is unclear, ASK CLARIFYING QUESTION:**\n\n```\nI want to make sure I understand the refactoring goal correctly.\n\n**What I understood**: [interpretation]\n**What I'm unsure about**: [specific ambiguity]\n\nOptions I see:\n1. [Option A] - [implications]\n2. [Option B] - [implications]\n\n**My recommendation**: [suggestion with reasoning]\n\nShould I proceed with [recommendation], or would you prefer differently?\n```\n\n## Step 0.3: Create Initial Todos\n\n**IMMEDIATELY after understanding the request, create todos:**\n\n```\nTodoWrite([\n {\"id\": \"phase-1\", \"content\": \"PHASE 1: Codebase Analysis - launch parallel researcher agents\", \"status\": \"pending\", \"priority\": \"high\"},\n {\"id\": \"phase-2\", \"content\": \"PHASE 2: Build Codemap - map dependencies and impact zones\", \"status\": \"pending\", \"priority\": \"high\"},\n {\"id\": \"phase-3\", \"content\": \"PHASE 3: Test Assessment - analyze test coverage and verification strategy\", \"status\": \"pending\", \"priority\": \"high\"},\n {\"id\": \"phase-4\", \"content\": \"PHASE 4: Plan Generation - invoke Strategist for detailed refactoring plan\", \"status\": \"pending\", \"priority\": \"high\"},\n {\"id\": \"phase-5\", \"content\": \"PHASE 5: Execute Refactoring - step-by-step with continuous verification\", \"status\": \"pending\", \"priority\": \"high\"},\n {\"id\": \"phase-6\", \"content\": \"PHASE 6: Final Verification - full test suite and regression check\", \"status\": \"pending\", \"priority\": \"high\"}\n])\n```\n\n---\n\n# PHASE 1: CODEBASE ANALYSIS (PARALLEL EXPLORATION)\n\n**Mark phase-1 as in_progress.**\n\n## 1.1: Launch Parallel Researcher Agents (BACKGROUND)\n\nFire ALL of these simultaneously using `call_hiai_agent`:\n\n```\n// Agent 1: Find the refactoring target\ncall_hiai_agent(\n subagent_type=\"researcher\",\n run_in_background=true,\n prompt=\"Find all occurrences and definitions of [TARGET]. \n Report: file paths, line numbers, usage patterns.\"\n)\n\n// Agent 2: Find related code\ncall_hiai_agent(\n subagent_type=\"researcher\", \n run_in_background=true,\n prompt=\"Find all code that imports, uses, or depends on [TARGET].\n Report: dependency chains, import graphs.\"\n)\n\n// Agent 3: Find similar patterns\ncall_hiai_agent(\n subagent_type=\"researcher\",\n run_in_background=true,\n prompt=\"Find similar code patterns to [TARGET] in the codebase.\n Report: analogous implementations, established conventions.\"\n)\n\n// Agent 4: Find tests\ncall_hiai_agent(\n subagent_type=\"researcher\",\n run_in_background=true,\n prompt=\"Find all test files related to [TARGET].\n Report: test file paths, test case names, coverage indicators.\"\n)\n\n// Agent 5: Architecture context\ncall_hiai_agent(\n subagent_type=\"researcher\",\n run_in_background=true,\n prompt=\"Find architectural patterns and module organization around [TARGET].\n Report: module boundaries, layer structure, design patterns in use.\"\n)\n```\n\n## 1.2: Direct Tool Exploration (WHILE AGENTS RUN)\n\nWhile background agents are running, use direct tools:\n\n### LSP Tools for Precise Analysis:\n\n```typescript\n// Find definition(s)\nLspGotoDefinition(filePath, line, character) // Where is it defined?\n\n// Find ALL usages across workspace\nLspFindReferences(filePath, line, character, includeDeclaration=true)\n\n// Get file structure\nLspDocumentSymbols(filePath) // Hierarchical outline\nLspWorkspaceSymbols(filePath, query=\"[target_symbol]\") // Search by name\n\n// Get current diagnostics\nlsp_diagnostics(filePath) // Errors, warnings before we start\n```\n\n### AST-Grep for Pattern Analysis:\n\n```typescript\n// Find structural patterns\nast_grep_search(\n pattern=\"function $NAME($$$) { $$$ }\", // or relevant pattern\n lang=\"typescript\", // or relevant language\n paths=[\"src/\"]\n)\n\n// Preview refactoring (DRY RUN)\nast_grep_replace(\n pattern=\"[old_pattern]\",\n rewrite=\"[new_pattern]\",\n lang=\"[language]\",\n dryRun=true // ALWAYS preview first\n)\n```\n\n### Grep for Text Patterns:\n\n```\ngrep(pattern=\"[search_term]\", path=\"src/\", include=\"*.ts\")\n```\n\n## 1.3: Collect Background Results\n\n```\nbackground_output(task_id=\"[agent_1_id]\")\nbackground_output(task_id=\"[agent_2_id]\")\n...\n```\n\n**Mark phase-1 as completed after all results collected.**\n\n---\n\n# PHASE 2: BUILD CODEMAP (DEPENDENCY MAPPING)\n\n**Mark phase-2 as in_progress.**\n\n## 2.1: Construct Definitive Codemap\n\nBased on Phase 1 results, build:\n\n```\n## CODEMAP: [TARGET]\n\n### Core Files (Direct Impact)\n- `path/to/file.ts:L10-L50` - Primary definition\n- `path/to/file2.ts:L25` - Key usage\n\n### Dependency Graph\n```\n[TARGET] \n\u251C\u2500\u2500 imports from: \n\u2502 \u251C\u2500\u2500 module-a (types)\n\u2502 \u2514\u2500\u2500 module-b (utils)\n\u251C\u2500\u2500 imported by:\n\u2502 \u251C\u2500\u2500 consumer-1.ts\n\u2502 \u251C\u2500\u2500 consumer-2.ts\n\u2502 \u2514\u2500\u2500 consumer-3.ts\n\u2514\u2500\u2500 used by:\n \u251C\u2500\u2500 handler.ts (direct call)\n \u2514\u2500\u2500 service.ts (dependency injection)\n```\n\n### Impact Zones\n| Zone | Risk Level | Files Affected | Test Coverage |\n|------|------------|----------------|---------------|\n| Core | HIGH | 3 files | 85% covered |\n| Consumers | MEDIUM | 8 files | 70% covered |\n| Edge | LOW | 2 files | 50% covered |\n\n### Established Patterns\n- Pattern A: [description] - used in N places\n- Pattern B: [description] - established convention\n```\n\n## 2.2: Identify Refactoring Constraints\n\nBased on codemap:\n- **MUST follow**: [existing patterns identified]\n- **MUST NOT break**: [critical dependencies]\n- **Safe to change**: [isolated code zones]\n- **Requires migration**: [breaking changes impact]\n\n**Mark phase-2 as completed.**\n\n---\n\n# PHASE 3: TEST ASSESSMENT (VERIFICATION STRATEGY)\n\n**Mark phase-3 as in_progress.**\n\n## 3.1: Detect Test Infrastructure\n\n```bash\n# Check for test commands\ncat package.json | jq '.scripts | keys[] | select(test(\"test\"))'\n\n# Or for Python\nls -la pytest.ini pyproject.toml setup.cfg\n\n# Or for Go\nls -la *_test.go\n```\n\n## 3.2: Analyze Test Coverage\n\n```\n// Find all tests related to target\ncall_hiai_agent(\n subagent_type=\"researcher\",\n run_in_background=false, // Need this synchronously\n prompt=\"Analyze test coverage for [TARGET]:\n 1. Which test files cover this code?\n 2. What test cases exist?\n 3. Are there integration tests?\n 4. What edge cases are tested?\n 5. Estimated coverage percentage?\"\n)\n```\n\n## 3.3: Determine Verification Strategy\n\nBased on test analysis:\n\n| Coverage Level | Strategy |\n|----------------|----------|\n| HIGH (>80%) | Run existing tests after each step |\n| MEDIUM (50-80%) | Run tests + add safety assertions |\n| LOW (<50%) | **PAUSE**: Propose adding tests first |\n| NONE | **BLOCK**: Refuse aggressive refactoring |\n\n**If coverage is LOW or NONE, ask user:**\n\n```\nTest coverage for [TARGET] is [LEVEL].\n\n**Risk Assessment**: Refactoring without adequate tests is dangerous.\n\nOptions:\n1. Add tests first, then refactor (RECOMMENDED)\n2. Proceed with extra caution, manual verification required\n3. Abort refactoring\n\nWhich approach do you prefer?\n```\n\n## 3.4: Document Verification Plan\n\n```\n## VERIFICATION PLAN\n\n### Test Commands\n- Unit: `bun test` / `npm test` / `pytest` / etc.\n- Integration: [command if exists]\n- Type check: `tsc --noEmit` / `pyright` / etc.\n\n### Verification Checkpoints\nAfter each refactoring step:\n1. lsp_diagnostics \u2192 zero new errors\n2. Run test command \u2192 all pass\n3. Type check \u2192 clean\n\n### Regression Indicators\n- [Specific test that must pass]\n- [Behavior that must be preserved]\n- [API contract that must not change]\n```\n\n**Mark phase-3 as completed.**\n\n---\n\n# PHASE 4: PLAN GENERATION (STRATEGIST)\n\n**Mark phase-4 as in_progress.**\n\n## 4.1: Invoke Strategist\n\n```\nTask(\n subagent_type=\"strategist\",\n prompt=\"Create a detailed refactoring plan:\n\n ## Refactoring Goal\n [User's original request]\n\n ## Codemap (from Phase 2)\n [Insert codemap here]\n\n ## Test Coverage (from Phase 3)\n [Insert verification plan here]\n\n ## Constraints\n - MUST follow existing patterns: [list]\n - MUST NOT break: [critical paths]\n - MUST run tests after each step\n\n ## Requirements\n 1. Break down into atomic refactoring steps\n 2. Each step must be independently verifiable\n 3. Order steps by dependency (what must happen first)\n 4. Specify exact files and line ranges for each step\n 5. Include rollback strategy for each step\n 6. Define commit checkpoints\"\n)\n```\n\n## 4.2: Review and Validate Plan\n\nAfter receiving plan from Strategist:\n\n1. **Verify completeness**: All identified files addressed?\n2. **Verify safety**: Each step reversible?\n3. **Verify order**: Dependencies respected?\n4. **Verify verification**: Test commands specified?\n\n## 4.3: Register Detailed Todos\n\nConvert Strategist output into granular todos:\n\n```\nTodoWrite([\n // Each step from the plan becomes a todo\n {\"id\": \"refactor-1\", \"content\": \"Step 1: [description]\", \"status\": \"pending\", \"priority\": \"high\"},\n {\"id\": \"verify-1\", \"content\": \"Verify Step 1: run tests\", \"status\": \"pending\", \"priority\": \"high\"},\n {\"id\": \"refactor-2\", \"content\": \"Step 2: [description]\", \"status\": \"pending\", \"priority\": \"medium\"},\n {\"id\": \"verify-2\", \"content\": \"Verify Step 2: run tests\", \"status\": \"pending\", \"priority\": \"medium\"},\n // ... continue for all steps\n])\n```\n\n**Mark phase-4 as completed.**\n\n---\n\n# PHASE 5: EXECUTE REFACTORING (DETERMINISTIC EXECUTION)\n\n**Mark phase-5 as in_progress.**\n\n## 5.1: Execution Protocol\n\nFor EACH refactoring step:\n\n### Pre-Step\n1. Mark step todo as `in_progress`\n2. Read current file state\n3. Verify lsp_diagnostics is baseline\n\n### Execute Step\nUse appropriate tool:\n\n**For Symbol Renames:**\n```typescript\nlsp_prepare_rename(filePath, line, character) // Validate rename is possible\nlsp_rename(filePath, line, character, newName) // Execute rename\n```\n\n**For Pattern Transformations:**\n```typescript\n// Preview first\nast_grep_replace(pattern, rewrite, lang, dryRun=true)\n\n// If preview looks good, execute\nast_grep_replace(pattern, rewrite, lang, dryRun=false)\n```\n\n**For Structural Changes:**\n```typescript\n// Use Edit tool for precise changes\nedit(filePath, oldString, newString)\n```\n\n### Post-Step Verification (MANDATORY)\n\n```typescript\n// 1. Check diagnostics\nlsp_diagnostics(filePath) // Must be clean or same as baseline\n\n// 2. Run tests\nbash(\"bun test\") // Or appropriate test command\n\n// 3. Type check\nbash(\"tsc --noEmit\") // Or appropriate type check\n```\n\n### Step Completion\n1. If verification passes \u2192 Mark step todo as `completed`\n2. If verification fails \u2192 **STOP AND FIX**\n\n## 5.2: Failure Recovery Protocol\n\nIf ANY verification fails:\n\n1. **STOP** immediately\n2. **REVERT** the failed change\n3. **DIAGNOSE** what went wrong\n4. **OPTIONS**:\n - Fix the issue and retry\n - Skip this step (if optional)\n - Consult critic agent for help\n - Ask user for guidance\n\n**NEVER proceed to next step with broken tests.**\n\n## 5.3: Commit Checkpoints\n\nAfter each logical group of changes:\n\n```bash\ngit add [changed-files]\ngit commit -m \"refactor(scope): description\n\n[details of what was changed and why]\"\n```\n\n**Mark phase-5 as completed when all refactoring steps done.**\n\n---\n\n# PHASE 6: FINAL VERIFICATION (REGRESSION CHECK)\n\n**Mark phase-6 as in_progress.**\n\n## 6.1: Full Test Suite\n\n```bash\n# Run complete test suite\nbun test # or npm test, pytest, go test, etc.\n```\n\n## 6.2: Type Check\n\n```bash\n# Full type check\ntsc --noEmit # or equivalent\n```\n\n## 6.3: Lint Check\n\n```bash\n# Run linter\neslint . # or equivalent\n```\n\n## 6.4: Build Verification (if applicable)\n\n```bash\n# Ensure build still works\nbun run build # or npm run build, etc.\n```\n\n## 6.5: Final Diagnostics\n\n```typescript\n// Check all changed files\nfor (file of changedFiles) {\n lsp_diagnostics(file) // Must all be clean\n}\n```\n\n## 6.6: Generate Summary\n\n```markdown\n## Refactoring Complete\n\n### What Changed\n- [List of changes made]\n\n### Files Modified\n- `path/to/file.ts` - [what changed]\n- `path/to/file2.ts` - [what changed]\n\n### Verification Results\n- Tests: PASSED (X/Y passing)\n- Type Check: CLEAN\n- Lint: CLEAN\n- Build: SUCCESS\n\n### No Regressions Detected\nAll existing tests pass. No new errors introduced.\n```\n\n**Mark phase-6 as completed.**\n\n---\n\n# CRITICAL RULES\n\n## NEVER DO\n- Skip lsp_diagnostics check after changes\n- Proceed with failing tests\n- Make changes without understanding impact\n- Use `as any`, `@ts-ignore`, `@ts-expect-error`\n- Delete tests to make them pass\n- Commit broken code\n- Refactor without understanding existing patterns\n\n## ALWAYS DO\n- Understand before changing\n- Preview before applying (ast_grep dryRun=true)\n- Verify after every change\n- Follow existing codebase patterns\n- Keep todos updated in real-time\n- Commit at logical checkpoints\n- Report issues immediately\n\n## ABORT CONDITIONS\nIf any of these occur, **STOP and consult user**:\n- Test coverage is zero for target code\n- Changes would break public API\n- Refactoring scope is unclear\n- 3 consecutive verification failures\n- User-defined constraints violated\n\n---\n\n# Tool Usage Philosophy\n\nYou already know these tools. Use them intelligently:\n\n## LSP Tools\nLeverage LSP tools for precision analysis. Key patterns:\n- **Understand before changing**: `LspGotoDefinition` to grasp context\n- **Impact analysis**: `LspFindReferences` to map all usages before modification\n- **Safe refactoring**: `lsp_prepare_rename` \u2192 `lsp_rename` for symbol renames\n- **Continuous verification**: `lsp_diagnostics` after every change\n\n## AST-Grep\nUse `ast_grep_search` and `ast_grep_replace` for structural transformations.\n**Critical**: Always `dryRun=true` first, review, then execute.\n\n## Agents\n- `researcher`: Parallel codebase pattern discovery\n- `strategist`: Detailed refactoring plan generation\n- `critic`: Read-only consultation for complex architectural decisions and debugging\n- `researcher`: **Use proactively** when encountering deprecated methods or library migration tasks. Query official docs and OSS examples for modern replacements.\n\n## Deprecated Code & Library Migration\nWhen you encounter deprecated methods/APIs during refactoring:\n1. Fire `researcher` to find the recommended modern alternative\n2. **DO NOT auto-upgrade to latest version** unless user explicitly requests migration\n3. If user requests library migration, use `researcher` to fetch latest API docs before making changes\n\n---\n\n**Remember: Refactoring without tests is reckless. Refactoring without understanding is destructive. This command ensures you do neither.**\n\n<user-request>\n$ARGUMENTS\n</user-request>\n";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const START_WORK_TEMPLATE = "You are starting a Bob work session.\n\n## ARGUMENTS\n\n- `/start-work [plan-name] [--worktree <path>]`\n - `plan-name` (optional): name or partial match of the plan to start\n - `--worktree <path>` (optional): absolute path to an existing git worktree to work in\n - If specified and valid: hook pre-sets worktree_path in boulder
|
|
1
|
+
export declare const START_WORK_TEMPLATE = "You are starting a Bob work session.\n\n## ARGUMENTS\n\n- `/start-work [plan-name] [--worktree <path>]`\n - `plan-name` (optional): name or partial match of the plan to start\n - `--worktree <path>` (optional): absolute path to an existing git worktree to work in\n - If specified and valid: hook pre-sets `worktree_path` in the active boulder registry entry\n - If specified but invalid: you must run `git worktree add <path> <branch>` first\n - If omitted: work directly in the current project directory (no worktree)\n\n## WHAT TO DO\n\n1. **Find available plans**: Search for Strategist-generated plan files at `.bob/plans/`\n\n2. **Check for active boulder state**: Read `.bob/boulder-registry/` for active plans\n\n3. **Decision logic**:\n - If the plan already exists in `.bob/boulder-registry/` AND is NOT complete:\n - **APPEND** current session to session_ids\n - Continue work on existing plan\n - If no active plan OR plan is complete:\n - List available plan files\n - If ONE plan: auto-select it\n - If MULTIPLE plans: show list with timestamps, ask user to select\n\n4. **Worktree Setup** (ONLY when `--worktree` was explicitly specified and `worktree_path` not already set in the active registry entry):\n 1. `git worktree list --porcelain` - see available worktrees\n 2. Create: `git worktree add <absolute-path> <branch-or-HEAD>`\n 3. Update the active registry entry to add `\"worktree_path\": \"<absolute-path>\"`\n 4. All work happens inside that worktree directory\n\n5. **Create/Update active boulder registry entry**:\n ```json\n {\n \"active_plan\": \"/absolute/path/to/plan.md\",\n \"started_at\": \"ISO_TIMESTAMP\",\n \"session_ids\": [\"session_id_1\", \"session_id_2\"],\n \"plan_name\": \"plan-name\",\n \"worktree_path\": \"/absolute/path/to/git/worktree\"\n }\n ```\n\n6. **Read the plan file** and start executing tasks according to guard workflow\n\n## OUTPUT FORMAT\n\nWhen listing plans for selection:\n```\nAvailable Work Plans\n\nCurrent Time: {ISO timestamp}\nSession ID: {current session id}\n\n1. [plan-name-1.md] - Modified: {date} - Progress: 3/10 tasks\n2. [plan-name-2.md] - Modified: {date} - Progress: 0/5 tasks\n\nWhich plan would you like to work on? (Enter number or plan name)\n```\n\nWhen resuming existing work:\n```\nResuming Work Session\n\nActive Plan: {plan-name}\nProgress: {completed}/{total} tasks\nSessions: {count} (appending current session)\nWorktree: {worktree_path}\n\nReading plan and continuing from last incomplete task...\n```\n\nWhen auto-selecting single plan:\n```\nStarting Work Session\n\nPlan: {plan-name}\nSession ID: {session_id}\nStarted: {timestamp}\nWorktree: {worktree_path}\n\nReading plan and beginning execution...\n```\n\n## CRITICAL\n\n- The session_id is injected by the hook - use it directly\n- Always update the active boulder registry entry BEFORE starting work\n- If `worktree_path` is set in the active registry entry, all work happens inside that worktree directory\n- Read the FULL plan file before delegating any tasks\n- Follow guard delegation protocols (7-section format)\n\n## TASK BREAKDOWN (MANDATORY)\n\nAfter reading the plan file, you MUST decompose every plan task into granular, implementation-level sub-steps and register ALL of them as task/todo items BEFORE starting any work.\n\n**How to break down**:\n- Each plan checkbox item (e.g., `- [ ] Add user authentication`) must be split into concrete, actionable sub-tasks\n- Sub-tasks should be specific enough that each one touches a clear set of files/functions\n- Include: file to modify, what to change, expected behavior, and how to verify\n- Do NOT leave any task vague - \"implement feature X\" is NOT acceptable; \"add validateToken() to src/auth/middleware.ts that checks JWT expiry and returns 401\" IS acceptable\n\n**Example breakdown**:\nPlan task: `- [ ] Add rate limiting to API`\n\u2192 Todo items:\n 1. Create `src/middleware/rate-limiter.ts` with sliding window algorithm (max 100 req/min per IP)\n 2. Add RateLimiter middleware to `src/app.ts` router chain, before auth middleware\n 3. Add rate limit headers (X-RateLimit-Limit, X-RateLimit-Remaining) to response in `rate-limiter.ts`\n 4. Add test: verify 429 response after exceeding limit in `src/middleware/rate-limiter.test.ts`\n 5. Add test: verify headers are present on normal responses\n\nRegister these as task/todo items so progress is tracked and visible throughout the session.\n\n## WORKTREE COMPLETION\n\nWhen ALL plan tasks are complete:\n1. Commit remaining changes in the worktree\n2. The plugin auto-syncs `.bob/notepads/` back to the main repo\n3. The worktree is auto-removed via `git worktree remove`\n4. The plan is deregistered from `boulder-registry/`\n\nDo NOT manually copy `.bob/` -- the plugin handles this.\n\n## PARALLEL PLANS\n\nMultiple plans can run simultaneously. Each plan lives in its own git worktree\nat `.opencode/worktrees/<plan-name>/` for complete filesystem isolation.\n\n- Auto-worktree: created automatically when a second plan starts - no `--worktree` needed\n- Manual worktree: `--worktree <path>` overrides the default location\n- Registry: `.bob/boulder-registry/{plan-name}.json` tracks each plan independently\n- Stop-continuation: only affects the calling session's plan, not other active plans\n";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { playwrightCliSkill } from "./playwright-cli";
|
|
1
|
+
export { agentBrowserSkill } from "./agent-browser";
|
|
3
2
|
export { frontendUiUxSkill } from "./frontend-ui-ux";
|
|
4
3
|
export { gitMasterSkill } from "./git-master";
|
|
5
4
|
export { devBrowserSkill } from "./dev-browser";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isCriticAgent(agentName: string | undefined): boolean;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const HOOK_NAME = "critic-plans-only";
|
|
2
|
+
export declare const CRITIC_AGENT = "critic";
|
|
3
|
+
export declare const ALLOWED_EXTENSIONS: string[];
|
|
4
|
+
export declare const ALLOWED_PATH_PREFIX = ".bob/plans";
|
|
5
|
+
export declare const BLOCKED_TOOLS: string[];
|
|
6
|
+
export declare const CRITIC_EDIT_PERMISSION_REMINDER: string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { PluginInput } from "@opencode-ai/plugin";
|
|
2
|
+
export declare function createCriticPlansOnlyHook(ctx: PluginInput): {
|
|
3
|
+
"tool.execute.before": (input: {
|
|
4
|
+
tool: string;
|
|
5
|
+
sessionID: string;
|
|
6
|
+
callID: string;
|
|
7
|
+
}, output: {
|
|
8
|
+
args: Record<string, unknown>;
|
|
9
|
+
message?: string;
|
|
10
|
+
}) => Promise<void>;
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isAllowedFile(filePath: string, workspaceRoot: string): boolean;
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export { createStrategistMdOnlyHook } from "./strategist-md-only";
|
|
|
31
31
|
export { createBobJuniorNotepadHook } from "./sub-notepad";
|
|
32
32
|
export { createTaskResumeInfoHook } from "./task-resume-info";
|
|
33
33
|
export { createStartWorkHook } from "./start-work";
|
|
34
|
-
export { createGuardHook } from "./
|
|
34
|
+
export { createGuardHook } from "./manager";
|
|
35
35
|
export { createDelegateTaskRetryHook } from "./delegate-task-retry";
|
|
36
36
|
export { createQuestionLabelTruncatorHook } from "./question-label-truncator";
|
|
37
37
|
export { createStopContinuationGuardHook, type StopContinuationGuard } from "./stop-continuation-guard";
|
|
@@ -50,3 +50,4 @@ export { createTodoDescriptionOverrideHook } from "./todo-description-override";
|
|
|
50
50
|
export { createWebFetchRedirectGuardHook } from "./webfetch-redirect-guard";
|
|
51
51
|
export { createLegacyPluginToastHook } from "./legacy-plugin-toast";
|
|
52
52
|
export { createFastApplyHook } from "./fast-apply";
|
|
53
|
+
export { createMemPalaceAutoSave } from "./mempalace-auto-save";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PluginInput } from "@opencode-ai/plugin";
|
|
2
|
-
export declare const JSON_ERROR_TOOL_EXCLUDE_LIST: readonly ["bash", "read", "glob", "grep", "webfetch", "look_at", "grep_app_searchgithub"
|
|
2
|
+
export declare const JSON_ERROR_TOOL_EXCLUDE_LIST: readonly ["bash", "read", "glob", "grep", "webfetch", "look_at", "grep_app_searchgithub"];
|
|
3
3
|
export declare const JSON_ERROR_PATTERNS: readonly [RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp];
|
|
4
4
|
export declare const JSON_ERROR_REMINDER = "\n[JSON PARSE ERROR - IMMEDIATE ACTION REQUIRED]\n\nYou sent invalid JSON arguments. The system could not parse your tool call.\nSTOP and do this NOW:\n\n1. LOOK at the error message above to see what was expected vs what you sent.\n2. CORRECT your JSON syntax (missing braces, unescaped quotes, trailing commas, etc).\n3. RETRY the tool call with valid JSON.\n\nDO NOT repeat the exact same invalid call.\n";
|
|
5
5
|
export declare function createJsonErrorRecoveryHook(_ctx: PluginInput): {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const HOOK_NAME = "manager";
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { PluginInput } from "@opencode-ai/plugin";
|
|
2
2
|
import type { BoulderState, PlanProgress } from "../../features/boulder-state";
|
|
3
|
+
/**
|
|
4
|
+
* Resolve active boulder session using registry-aware lookup.
|
|
5
|
+
* Uses findPlanNameForSession to locate which plan owns this session,
|
|
6
|
+
* then reads the plan-specific boulder state from registry.
|
|
7
|
+
*/
|
|
3
8
|
export declare function resolveActiveBoulderSession(input: {
|
|
4
9
|
client: PluginInput["client"];
|
|
5
10
|
directory: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const DIRECT_WORK_REMINDER: string;
|
|
2
2
|
export declare const BOULDER_CONTINUATION_PROMPT: string;
|
|
3
|
-
export declare const VERIFICATION_REMINDER = "**THE SUBAGENT JUST CLAIMED THIS TASK IS DONE. THEY ARE PROBABLY LYING.**\n\nSubagents say \"done\" when code has errors, tests pass trivially, logic is wrong,\nor they quietly added features nobody asked for. This happens EVERY TIME.\nAssume the work is broken until YOU prove otherwise.\n\n---\n\n**PHASE 1: READ THE CODE FIRST (before running anything)**\n\nDo NOT run tests yet. Read the code FIRST so you know what you're testing.\n\n1. `Bash(\"git diff --stat -- ':!node_modules'\")` - see exactly which files changed. Any file outside expected scope = scope creep.\n2. `Read` EVERY changed file - no exceptions, no skimming.\n3. For EACH file, critically ask:\n - Does this code ACTUALLY do what the task required? (Re-read the task, compare line by line)\n - Any stubs, TODOs, placeholders, hardcoded values? (`Grep` for TODO, FIXME, HACK, xxx)\n - Logic errors? Trace the happy path AND the error path in your head.\n - Anti-patterns? (`Grep` for `as any`, `@ts-ignore`, empty catch, console.log in changed files)\n - Scope creep? Did the subagent touch things or add features NOT in the task spec?\n4. Cross-check every claim:\n - Said \"Updated X\" - READ X. Actually updated, or just superficially touched?\n - Said \"Added tests\" - READ the tests. Do they test REAL behavior or just `expect(true).toBe(true)`?\n - Said \"Follows patterns\" - OPEN a reference file. Does it ACTUALLY match?\n\n**If you cannot explain what every changed line does, you have NOT reviewed it.**\n\n**PHASE 2: RUN AUTOMATED CHECKS (targeted, then broad)**\n\nNow that you understand the code, verify mechanically:\n1. `lsp_diagnostics` on EACH changed file - ZERO new errors\n2. Run tests for changed modules FIRST, then full suite\n3. Build/typecheck - exit 0\n\nIf Phase 1 found issues but Phase 2 passes: Phase 2 is WRONG. The code has bugs that tests don't cover. Fix the code.\n\n**PHASE 3: HANDS-ON QA - ACTUALLY RUN IT (MANDATORY for user-facing changes)**\n\nTests and linters CANNOT catch: visual bugs, wrong CLI output, broken user flows, API response shape issues.\n\n**If this task produced anything a user would SEE or INTERACT with, you MUST launch it and verify yourself.**\n\n- **Frontend/UI**: `/
|
|
4
|
-
export declare const VERIFICATION_REMINDER_GEMINI = "**THE SUBAGENT HAS FINISHED. THEIR WORK IS EXTREMELY SUSPICIOUS.**\n\nThe subagent CLAIMS this task is done. Based on thousands of executions, subagent claims are FALSE more often than true.\nThey ROUTINELY:\n- Ship code with syntax errors they didn't bother to check\n- Create stub implementations with TODOs and call it \"done\"\n- Write tests that pass trivially (testing nothing meaningful)\n- Implement logic that does NOT match what was requested\n- Add features nobody asked for and call it \"improvement\"\n- Report \"all tests pass\" when they didn't run any tests\n\n**This is NOT a theoretical warning. This WILL happen on this task. Assume the work is BROKEN.**\n\n**YOU MUST VERIFY WITH ACTUAL TOOL CALLS. NOT REASONING. TOOL CALLS.**\nThinking \"it looks correct\" is NOT verification. Running `lsp_diagnostics` IS.\n\n---\n\n**PHASE 1: READ THE CODE FIRST (DO NOT SKIP - DO NOT RUN TESTS YET)**\n\nRead the code FIRST so you know what you're testing.\n\n1. `Bash(\"git diff --stat -- ':!node_modules'\")` - see exactly which files changed.\n2. `Read` EVERY changed file - no exceptions, no skimming.\n3. For EACH file:\n - Does this code ACTUALLY do what the task required? RE-READ the task spec.\n - Any stubs, TODOs, placeholders? `Grep` for TODO, FIXME, HACK, xxx\n - Anti-patterns? `Grep` for `as any`, `@ts-ignore`, empty catch\n - Scope creep? Did the subagent add things NOT in the task spec?\n4. Cross-check EVERY claim against actual code.\n\n**If you cannot explain what every changed line does, GO BACK AND READ AGAIN.**\n\n**PHASE 2: RUN AUTOMATED CHECKS**\n\n1. `lsp_diagnostics` on EACH changed file - ZERO new errors. ACTUALLY RUN THIS.\n2. Run tests for changed modules, then full suite. ACTUALLY RUN THESE.\n3. Build/typecheck - exit 0.\n\nIf Phase 1 found issues but Phase 2 passes: Phase 2 is WRONG. Fix the code.\n\n**PHASE 3: HANDS-ON QA (MANDATORY for user-facing changes)**\n\n- **Frontend/UI**: `/
|
|
3
|
+
export declare const VERIFICATION_REMINDER = "**THE SUBAGENT JUST CLAIMED THIS TASK IS DONE. THEY ARE PROBABLY LYING.**\n\nSubagents say \"done\" when code has errors, tests pass trivially, logic is wrong,\nor they quietly added features nobody asked for. This happens EVERY TIME.\nAssume the work is broken until YOU prove otherwise.\n\n---\n\n**PHASE 1: READ THE CODE FIRST (before running anything)**\n\nDo NOT run tests yet. Read the code FIRST so you know what you're testing.\n\n1. `Bash(\"git diff --stat -- ':!node_modules'\")` - see exactly which files changed. Any file outside expected scope = scope creep.\n2. `Read` EVERY changed file - no exceptions, no skimming.\n3. For EACH file, critically ask:\n - Does this code ACTUALLY do what the task required? (Re-read the task, compare line by line)\n - Any stubs, TODOs, placeholders, hardcoded values? (`Grep` for TODO, FIXME, HACK, xxx)\n - Logic errors? Trace the happy path AND the error path in your head.\n - Anti-patterns? (`Grep` for `as any`, `@ts-ignore`, empty catch, console.log in changed files)\n - Scope creep? Did the subagent touch things or add features NOT in the task spec?\n4. Cross-check every claim:\n - Said \"Updated X\" - READ X. Actually updated, or just superficially touched?\n - Said \"Added tests\" - READ the tests. Do they test REAL behavior or just `expect(true).toBe(true)`?\n - Said \"Follows patterns\" - OPEN a reference file. Does it ACTUALLY match?\n\n**If you cannot explain what every changed line does, you have NOT reviewed it.**\n\n**PHASE 2: RUN AUTOMATED CHECKS (targeted, then broad)**\n\nNow that you understand the code, verify mechanically:\n1. `lsp_diagnostics` on EACH changed file - ZERO new errors\n2. Run tests for changed modules FIRST, then full suite\n3. Build/typecheck - exit 0\n\nIf Phase 1 found issues but Phase 2 passes: Phase 2 is WRONG. The code has bugs that tests don't cover. Fix the code.\n\n**PHASE 3: HANDS-ON QA - ACTUALLY RUN IT (MANDATORY for user-facing changes)**\n\nTests and linters CANNOT catch: visual bugs, wrong CLI output, broken user flows, API response shape issues.\n\n**If this task produced anything a user would SEE or INTERACT with, you MUST launch it and verify yourself.**\n\n- **Frontend/UI**: `/agent-browser` skill - load the page, click through the flow, check console. Verify: page loads, interactions work, console clean, responsive.\n- **TUI/CLI**: Use `/agent-browser` skill or `Bash` - run the command, try good input, try bad input, try --help. Verify: command runs, output correct, error messages helpful, edge inputs handled.\n- **API/Backend**: `Bash` with curl - hit the endpoint, check response body, send malformed input. Verify: returns 200, body correct, error cases return proper errors.\n- **Config/Build**: Actually start the service or import the config. Verify: loads without error, backward compatible.\n\nThis is NOT optional \"if applicable\". If the deliverable is user-facing and you did not run it, you are shipping untested work.\n\n**PHASE 4: GATE DECISION - Should you proceed to the next task?**\n\nAnswer honestly:\n1. Can I explain what EVERY changed line does? (If no - back to Phase 1)\n2. Did I SEE it work with my own eyes? (If user-facing and no - back to Phase 3)\n3. Am I confident nothing existing is broken? (If no - run broader tests)\n\nALL three must be YES. \"Probably\" = NO. \"I think so\" = NO. Investigate until CERTAIN.\n\n- **All 3 YES** - Proceed: mark task complete, move to next.\n- **Any NO** - Reject: resume session with `session_id`, fix the specific issue.\n- **Unsure** - Reject: \"unsure\" = \"no\". Investigate until you have a definitive answer.\n\n**DO NOT proceed to the next task until all 4 phases are complete and the gate passes.**";
|
|
4
|
+
export declare const VERIFICATION_REMINDER_GEMINI = "**THE SUBAGENT HAS FINISHED. THEIR WORK IS EXTREMELY SUSPICIOUS.**\n\nThe subagent CLAIMS this task is done. Based on thousands of executions, subagent claims are FALSE more often than true.\nThey ROUTINELY:\n- Ship code with syntax errors they didn't bother to check\n- Create stub implementations with TODOs and call it \"done\"\n- Write tests that pass trivially (testing nothing meaningful)\n- Implement logic that does NOT match what was requested\n- Add features nobody asked for and call it \"improvement\"\n- Report \"all tests pass\" when they didn't run any tests\n\n**This is NOT a theoretical warning. This WILL happen on this task. Assume the work is BROKEN.**\n\n**YOU MUST VERIFY WITH ACTUAL TOOL CALLS. NOT REASONING. TOOL CALLS.**\nThinking \"it looks correct\" is NOT verification. Running `lsp_diagnostics` IS.\n\n---\n\n**PHASE 1: READ THE CODE FIRST (DO NOT SKIP - DO NOT RUN TESTS YET)**\n\nRead the code FIRST so you know what you're testing.\n\n1. `Bash(\"git diff --stat -- ':!node_modules'\")` - see exactly which files changed.\n2. `Read` EVERY changed file - no exceptions, no skimming.\n3. For EACH file:\n - Does this code ACTUALLY do what the task required? RE-READ the task spec.\n - Any stubs, TODOs, placeholders? `Grep` for TODO, FIXME, HACK, xxx\n - Anti-patterns? `Grep` for `as any`, `@ts-ignore`, empty catch\n - Scope creep? Did the subagent add things NOT in the task spec?\n4. Cross-check EVERY claim against actual code.\n\n**If you cannot explain what every changed line does, GO BACK AND READ AGAIN.**\n\n**PHASE 2: RUN AUTOMATED CHECKS**\n\n1. `lsp_diagnostics` on EACH changed file - ZERO new errors. ACTUALLY RUN THIS.\n2. Run tests for changed modules, then full suite. ACTUALLY RUN THESE.\n3. Build/typecheck - exit 0.\n\nIf Phase 1 found issues but Phase 2 passes: Phase 2 is WRONG. Fix the code.\n\n**PHASE 3: HANDS-ON QA (MANDATORY for user-facing changes)**\n\n- **Frontend/UI**: `/agent-browser`\n- **TUI/CLI**: `/agent-browser` or `Bash`\n- **API/Backend**: `Bash` with curl\n\n**If user-facing and you did not run it, you are shipping UNTESTED BROKEN work.**\n\n**PHASE 4: GATE DECISION**\n\n1. Can I explain what EVERY changed line does? (If no \u2192 Phase 1)\n2. Did I SEE it work via tool calls? (If user-facing and no \u2192 Phase 3)\n3. Am I confident nothing is broken? (If no \u2192 broader tests)\n\nALL three must be YES. \"Probably\" = NO. \"I think so\" = NO.\n\n**DO NOT proceed to the next task until all 4 phases are complete.**";
|
|
5
5
|
export declare const ORCHESTRATOR_DELEGATION_REQUIRED: string;
|
|
6
6
|
export declare const SINGLE_TASK_DIRECTIVE: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const HOOK_NAME = "mempalace-auto-save";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SkillMcpManager } from "../../features/skill-mcp-manager";
|
|
2
|
+
import type { PluginInput } from "@opencode-ai/plugin";
|
|
3
|
+
import type { MemPalaceAutoSaveOptions } from "./types";
|
|
4
|
+
export declare function createMemPalaceAutoSaveHandler(args: {
|
|
5
|
+
ctx: PluginInput;
|
|
6
|
+
skillMcpManager: SkillMcpManager;
|
|
7
|
+
options?: MemPalaceAutoSaveOptions;
|
|
8
|
+
}): (input: {
|
|
9
|
+
event: {
|
|
10
|
+
type: string;
|
|
11
|
+
properties?: unknown;
|
|
12
|
+
};
|
|
13
|
+
}) => Promise<void>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PluginInput } from "@opencode-ai/plugin";
|
|
2
|
+
import type { SkillMcpManager } from "../../features/skill-mcp-manager";
|
|
3
|
+
import type { MemPalaceAutoSaveOptions, MemPalaceAutoSaveState } from "./types";
|
|
4
|
+
export declare const HOOK_NAME_MEMPALACE_AUTO_SAVE = "mempalace-auto-save";
|
|
5
|
+
export interface MemPalaceAutoSave {
|
|
6
|
+
handler: (input: {
|
|
7
|
+
event: {
|
|
8
|
+
type: string;
|
|
9
|
+
properties?: unknown;
|
|
10
|
+
};
|
|
11
|
+
}) => Promise<void>;
|
|
12
|
+
dispose: () => void;
|
|
13
|
+
}
|
|
14
|
+
export declare function createMemPalaceAutoSave(ctx: PluginInput, skillMcpManager: SkillMcpManager, options?: MemPalaceAutoSaveOptions): MemPalaceAutoSave;
|
|
15
|
+
export type { MemPalaceAutoSaveState, MemPalaceAutoSaveOptions };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface MemPalaceAutoSaveState {
|
|
2
|
+
lastSaveAt?: number;
|
|
3
|
+
savedTodos: Set<string>;
|
|
4
|
+
sessionEndSaved: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface MemPalaceAutoSaveOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Minimum interval between auto-saves in milliseconds.
|
|
9
|
+
* Defaults to 60 seconds.
|
|
10
|
+
*/
|
|
11
|
+
debounceMs?: number;
|
|
12
|
+
/**
|
|
13
|
+
* Whether the hook is enabled. Defaults to true.
|
|
14
|
+
*/
|
|
15
|
+
enabled?: boolean;
|
|
16
|
+
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare const WORKTREE_BLOCK_MESSAGE = "\nWorktree isolation active for parallel plan.\n\nWorking in: {worktreePath}\nRegistry: .bob/boulder-registry/{planName}.json\n\nActive plan registry stays in the root project .bob/boulder-registry/.\nThe worktree is only the execution directory referenced by worktree_path.\n";
|
|
2
|
+
export declare function createWorktreeActiveBlock(worktreePath: string, planName?: string): string;
|
|
@@ -6,3 +6,48 @@ export type WorktreeEntry = {
|
|
|
6
6
|
export declare function parseWorktreeListPorcelain(output: string): WorktreeEntry[];
|
|
7
7
|
export declare function listWorktrees(directory: string): WorktreeEntry[];
|
|
8
8
|
export declare function detectWorktreePath(directory: string): string | null;
|
|
9
|
+
/**
|
|
10
|
+
* Create a git worktree for plan isolation
|
|
11
|
+
* @param directory - Project root directory
|
|
12
|
+
* @param planName - Plan name to use for worktree path and branch
|
|
13
|
+
* @returns Worktree path on success, null on failure
|
|
14
|
+
*/
|
|
15
|
+
export declare function createWorktreeForPlan(directory: string, planName: string): string | null;
|
|
16
|
+
/**
|
|
17
|
+
* Validate if a worktree is healthy and usable
|
|
18
|
+
* @param worktreePath - Path to the worktree
|
|
19
|
+
* @returns { valid: boolean, reason?: string }
|
|
20
|
+
*/
|
|
21
|
+
export declare function validateWorktreeHealth(worktreePath: string): {
|
|
22
|
+
valid: boolean;
|
|
23
|
+
reason?: string;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Remove a git worktree
|
|
27
|
+
* @param worktreePath - Path to the worktree
|
|
28
|
+
* @returns true on success, false on failure
|
|
29
|
+
*/
|
|
30
|
+
export declare function removeWorktree(worktreePath: string): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Ensure .bob/ directory exists in worktree
|
|
33
|
+
* @param worktreePath - Path to the worktree
|
|
34
|
+
*/
|
|
35
|
+
export declare function ensureBoulderDirInWorktree(worktreePath: string): void;
|
|
36
|
+
/**
|
|
37
|
+
* Ensure .bob/plans symlink exists in worktree, pointing to root plans directory
|
|
38
|
+
* This allows findStrategistPlans() to find plans when agent runs inside worktree
|
|
39
|
+
* @param worktreePath - Path to the worktree
|
|
40
|
+
* @param rootDirectory - Root directory of the project (where .bob/plans exists)
|
|
41
|
+
*/
|
|
42
|
+
export declare function ensurePlansSymlinkInWorktree(worktreePath: string, rootDirectory: string): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Remove plans symlink from worktree (cleanup)
|
|
45
|
+
* @param worktreePath - Path to the worktree
|
|
46
|
+
*/
|
|
47
|
+
export declare function removePlansSymlinkFromWorktree(worktreePath: string): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Startup health check: validate all worktrees and clean up stale ones
|
|
50
|
+
* @param directory - Project root directory
|
|
51
|
+
* @returns Array of removed stale worktree names
|
|
52
|
+
*/
|
|
53
|
+
export declare function cleanupStaleWorktrees(directory: string): string[];
|
|
@@ -10,7 +10,7 @@ type OpencodeClient = PluginInput["client"];
|
|
|
10
10
|
* This fixes issue #927 where after interruption:
|
|
11
11
|
* - In-memory map is cleared (process restart)
|
|
12
12
|
* - Message files return "strategist" (oldest message from /plan)
|
|
13
|
-
* - But boulder
|
|
13
|
+
* - But the boulder registry entry has agent: "guard" (set by /start-work)
|
|
14
14
|
*/
|
|
15
15
|
export declare function getAgentFromSession(sessionID: string, directory: string, client?: OpencodeClient): Promise<string | undefined>;
|
|
16
16
|
export {};
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
export declare const HOOK_NAME = "strategist-md-only";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const STRATEGIST_AGENT = "strategist";
|
|
3
3
|
export declare const ALLOWED_EXTENSIONS: string[];
|
|
4
4
|
export declare const ALLOWED_PATH_PREFIX = ".bob";
|
|
5
5
|
export declare const BLOCKED_TOOLS: string[];
|
|
6
|
+
export declare const UNCONDITIONAL_BLOCKED_TOOLS: string[];
|
|
7
|
+
export declare const BLOCKED_EXECUTION_SKILLS: string[];
|
|
8
|
+
export declare const BLOCKED_EXECUTION_COMMANDS: string[];
|
|
9
|
+
export declare const ALLOWED_PLANNING_SUBAGENTS: string[];
|
|
10
|
+
export declare const BLOCKED_EXECUTION_CATEGORIES: string[];
|
|
6
11
|
export declare const PLANNING_CONSULT_WARNING: string;
|
|
7
|
-
export declare const
|
|
12
|
+
export declare const STRATEGIST_EXECUTION_BLOCK_MESSAGE: string;
|
|
13
|
+
export declare const STRATEGIST_WORKFLOW_REMINDER: string;
|