@zcy2nn/agent-forge 1.0.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.
Files changed (189) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +266 -0
  3. package/agent-forge.schema.json +675 -0
  4. package/dist/agents/council.d.ts +27 -0
  5. package/dist/agents/councillor.d.ts +2 -0
  6. package/dist/agents/implementer.d.ts +2 -0
  7. package/dist/agents/index.d.ts +30 -0
  8. package/dist/agents/orchestrator.d.ts +30 -0
  9. package/dist/agents/researcher.d.ts +2 -0
  10. package/dist/agents/reviewer.d.ts +2 -0
  11. package/dist/cli/config-io.d.ts +24 -0
  12. package/dist/cli/config-manager.d.ts +4 -0
  13. package/dist/cli/custom-skills.d.ts +29 -0
  14. package/dist/cli/doctor.d.ts +38 -0
  15. package/dist/cli/index.d.ts +2 -0
  16. package/dist/cli/index.js +1932 -0
  17. package/dist/cli/install.d.ts +2 -0
  18. package/dist/cli/migration.d.ts +46 -0
  19. package/dist/cli/model-key-normalization.d.ts +1 -0
  20. package/dist/cli/paths.d.ts +35 -0
  21. package/dist/cli/providers.d.ts +99 -0
  22. package/dist/cli/skills.d.ts +52 -0
  23. package/dist/cli/system.d.ts +6 -0
  24. package/dist/cli/types.d.ts +40 -0
  25. package/dist/config/agent-mcps.d.ts +15 -0
  26. package/dist/config/constants.d.ts +28 -0
  27. package/dist/config/council-schema.d.ts +127 -0
  28. package/dist/config/index.d.ts +5 -0
  29. package/dist/config/loader.d.ts +57 -0
  30. package/dist/config/runtime-preset.d.ts +12 -0
  31. package/dist/config/schema.d.ts +371 -0
  32. package/dist/config/utils.d.ts +15 -0
  33. package/dist/council/council-manager.d.ts +49 -0
  34. package/dist/council/index.d.ts +1 -0
  35. package/dist/divoom/council.gif +0 -0
  36. package/dist/divoom/designer.gif +0 -0
  37. package/dist/divoom/explorer.gif +0 -0
  38. package/dist/divoom/fixer.gif +0 -0
  39. package/dist/divoom/input.gif +0 -0
  40. package/dist/divoom/intro.gif +0 -0
  41. package/dist/divoom/librarian.gif +0 -0
  42. package/dist/divoom/manager.d.ts +57 -0
  43. package/dist/divoom/oracle.gif +0 -0
  44. package/dist/divoom/orchestrator.gif +0 -0
  45. package/dist/hooks/apply-patch/codec.d.ts +7 -0
  46. package/dist/hooks/apply-patch/errors.d.ts +25 -0
  47. package/dist/hooks/apply-patch/execution-context.d.ts +27 -0
  48. package/dist/hooks/apply-patch/index.d.ts +15 -0
  49. package/dist/hooks/apply-patch/matching.d.ts +26 -0
  50. package/dist/hooks/apply-patch/operations.d.ts +3 -0
  51. package/dist/hooks/apply-patch/patch.d.ts +2 -0
  52. package/dist/hooks/apply-patch/prepared-changes.d.ts +17 -0
  53. package/dist/hooks/apply-patch/resolution.d.ts +19 -0
  54. package/dist/hooks/apply-patch/rewrite.d.ts +7 -0
  55. package/dist/hooks/apply-patch/test-helpers.d.ts +6 -0
  56. package/dist/hooks/apply-patch/types.d.ts +80 -0
  57. package/dist/hooks/auto-update-checker/cache.d.ts +11 -0
  58. package/dist/hooks/auto-update-checker/checker.d.ts +32 -0
  59. package/dist/hooks/auto-update-checker/constants.d.ts +11 -0
  60. package/dist/hooks/auto-update-checker/index.d.ts +18 -0
  61. package/dist/hooks/auto-update-checker/types.d.ts +22 -0
  62. package/dist/hooks/chat-headers.d.ts +16 -0
  63. package/dist/hooks/delegate-task-retry/guidance.d.ts +2 -0
  64. package/dist/hooks/delegate-task-retry/hook.d.ts +8 -0
  65. package/dist/hooks/delegate-task-retry/index.d.ts +4 -0
  66. package/dist/hooks/delegate-task-retry/patterns.d.ts +11 -0
  67. package/dist/hooks/filter-available-skills/index.d.ts +32 -0
  68. package/dist/hooks/foreground-fallback/index.d.ts +72 -0
  69. package/dist/hooks/image-hook.d.ts +19 -0
  70. package/dist/hooks/index.d.ts +13 -0
  71. package/dist/hooks/json-error-recovery/hook.d.ts +18 -0
  72. package/dist/hooks/json-error-recovery/index.d.ts +1 -0
  73. package/dist/hooks/phase-reminder/index.d.ts +26 -0
  74. package/dist/hooks/post-file-tool-nudge/index.d.ts +19 -0
  75. package/dist/hooks/task-session-manager/index.d.ts +52 -0
  76. package/dist/hooks/todo-continuation/index.d.ts +53 -0
  77. package/dist/hooks/todo-continuation/todo-hygiene.d.ts +35 -0
  78. package/dist/index.d.ts +5 -0
  79. package/dist/index.js +32981 -0
  80. package/dist/interview/dashboard.d.ts +62 -0
  81. package/dist/interview/document.d.ts +25 -0
  82. package/dist/interview/helpers.d.ts +10 -0
  83. package/dist/interview/index.d.ts +1 -0
  84. package/dist/interview/manager.d.ts +35 -0
  85. package/dist/interview/parser.d.ts +11 -0
  86. package/dist/interview/prompts.d.ts +7 -0
  87. package/dist/interview/server.d.ts +13 -0
  88. package/dist/interview/service.d.ts +34 -0
  89. package/dist/interview/types.d.ts +96 -0
  90. package/dist/interview/ui.d.ts +12 -0
  91. package/dist/mcp/context7.d.ts +6 -0
  92. package/dist/mcp/grep-app.d.ts +6 -0
  93. package/dist/mcp/index.d.ts +8 -0
  94. package/dist/mcp/types.d.ts +12 -0
  95. package/dist/mcp/websearch.d.ts +9 -0
  96. package/dist/multiplexer/factory.d.ts +26 -0
  97. package/dist/multiplexer/index.d.ts +9 -0
  98. package/dist/multiplexer/session-manager.d.ts +53 -0
  99. package/dist/multiplexer/tmux/index.d.ts +22 -0
  100. package/dist/multiplexer/types.d.ts +54 -0
  101. package/dist/multiplexer/zellij/index.d.ts +34 -0
  102. package/dist/tools/ast-grep/cli.d.ts +15 -0
  103. package/dist/tools/ast-grep/constants.d.ts +25 -0
  104. package/dist/tools/ast-grep/downloader.d.ts +5 -0
  105. package/dist/tools/ast-grep/index.d.ts +10 -0
  106. package/dist/tools/ast-grep/tools.d.ts +3 -0
  107. package/dist/tools/ast-grep/types.d.ts +30 -0
  108. package/dist/tools/ast-grep/utils.d.ts +4 -0
  109. package/dist/tools/council.d.ts +10 -0
  110. package/dist/tools/index.d.ts +6 -0
  111. package/dist/tools/preset-manager.d.ts +27 -0
  112. package/dist/tools/skill.d.ts +9 -0
  113. package/dist/tools/smartfetch/binary.d.ts +3 -0
  114. package/dist/tools/smartfetch/cache.d.ts +6 -0
  115. package/dist/tools/smartfetch/constants.d.ts +12 -0
  116. package/dist/tools/smartfetch/index.d.ts +3 -0
  117. package/dist/tools/smartfetch/network.d.ts +38 -0
  118. package/dist/tools/smartfetch/secondary-model.d.ts +28 -0
  119. package/dist/tools/smartfetch/tool.d.ts +3 -0
  120. package/dist/tools/smartfetch/types.d.ts +122 -0
  121. package/dist/tools/smartfetch/utils.d.ts +18 -0
  122. package/dist/tui-state.d.ts +15 -0
  123. package/dist/tui.d.ts +8 -0
  124. package/dist/tui.js +248 -0
  125. package/dist/utils/agent-variant.d.ts +63 -0
  126. package/dist/utils/compat.d.ts +30 -0
  127. package/dist/utils/env.d.ts +1 -0
  128. package/dist/utils/index.d.ts +9 -0
  129. package/dist/utils/internal-initiator.d.ts +6 -0
  130. package/dist/utils/logger.d.ts +8 -0
  131. package/dist/utils/polling.d.ts +21 -0
  132. package/dist/utils/session-manager.d.ts +55 -0
  133. package/dist/utils/session.d.ts +74 -0
  134. package/dist/utils/subagent-depth.d.ts +35 -0
  135. package/dist/utils/system-collapse.d.ts +6 -0
  136. package/dist/utils/task.d.ts +4 -0
  137. package/dist/utils/zip-extractor.d.ts +1 -0
  138. package/package.json +104 -0
  139. package/src/skills/brainstorming/SKILL.md +177 -0
  140. package/src/skills/brainstorming/scripts/frame-template.html +214 -0
  141. package/src/skills/brainstorming/scripts/helper.js +88 -0
  142. package/src/skills/brainstorming/scripts/server.cjs +354 -0
  143. package/src/skills/brainstorming/scripts/start-server.sh +148 -0
  144. package/src/skills/brainstorming/scripts/stop-server.sh +56 -0
  145. package/src/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
  146. package/src/skills/brainstorming/visual-companion.md +279 -0
  147. package/src/skills/codemap/README.md +59 -0
  148. package/src/skills/codemap/SKILL.md +163 -0
  149. package/src/skills/codemap/codemap.md +36 -0
  150. package/src/skills/codemap/scripts/codemap.mjs +483 -0
  151. package/src/skills/codemap/scripts/codemap.test.ts +129 -0
  152. package/src/skills/codemap.md +40 -0
  153. package/src/skills/dispatching-parallel-agents/SKILL.md +193 -0
  154. package/src/skills/executing-plans/SKILL.md +78 -0
  155. package/src/skills/finishing-a-development-branch/SKILL.md +211 -0
  156. package/src/skills/receiving-code-review/SKILL.md +224 -0
  157. package/src/skills/requesting-code-review/SKILL.md +113 -0
  158. package/src/skills/requesting-code-review/code-reviewer.md +146 -0
  159. package/src/skills/simplify/README.md +19 -0
  160. package/src/skills/simplify/SKILL.md +138 -0
  161. package/src/skills/simplify/codemap.md +36 -0
  162. package/src/skills/subagent-driven-development/SKILL.md +288 -0
  163. package/src/skills/subagent-driven-development/code-quality-reviewer-prompt.md +26 -0
  164. package/src/skills/subagent-driven-development/implementer-prompt.md +113 -0
  165. package/src/skills/subagent-driven-development/spec-reviewer-prompt.md +61 -0
  166. package/src/skills/systematic-debugging/CREATION-LOG.md +119 -0
  167. package/src/skills/systematic-debugging/SKILL.md +308 -0
  168. package/src/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
  169. package/src/skills/systematic-debugging/condition-based-waiting.md +115 -0
  170. package/src/skills/systematic-debugging/defense-in-depth.md +122 -0
  171. package/src/skills/systematic-debugging/find-polluter.sh +63 -0
  172. package/src/skills/systematic-debugging/root-cause-tracing.md +169 -0
  173. package/src/skills/systematic-debugging/test-academic.md +14 -0
  174. package/src/skills/systematic-debugging/test-pressure-1.md +58 -0
  175. package/src/skills/systematic-debugging/test-pressure-2.md +68 -0
  176. package/src/skills/systematic-debugging/test-pressure-3.md +69 -0
  177. package/src/skills/test-driven-development/SKILL.md +383 -0
  178. package/src/skills/test-driven-development/testing-anti-patterns.md +299 -0
  179. package/src/skills/using-git-worktrees/SKILL.md +226 -0
  180. package/src/skills/verification-before-completion/SKILL.md +147 -0
  181. package/src/skills/writing-plans/SKILL.md +165 -0
  182. package/src/skills/writing-plans/plan-document-reviewer-prompt.md +49 -0
  183. package/src/skills/writing-skills/SKILL.md +666 -0
  184. package/src/skills/writing-skills/anthropic-best-practices.md +1150 -0
  185. package/src/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +189 -0
  186. package/src/skills/writing-skills/graphviz-conventions.dot +172 -0
  187. package/src/skills/writing-skills/persuasion-principles.md +187 -0
  188. package/src/skills/writing-skills/render-graphs.js +168 -0
  189. package/src/skills/writing-skills/testing-skills-with-subagents.md +384 -0
@@ -0,0 +1,63 @@
1
+ import { type PluginConfig } from '../config';
2
+ /**
3
+ * Normalizes an agent name by trimming whitespace and removing the optional @ prefix.
4
+ *
5
+ * @param agentName - The agent name to normalize (e.g., "@oracle" or "oracle")
6
+ * @returns The normalized agent name without @ prefix and trimmed of whitespace
7
+ *
8
+ * @example
9
+ * normalizeAgentName("@oracle") // returns "oracle"
10
+ * normalizeAgentName(" explore ") // returns "explore"
11
+ */
12
+ export declare function normalizeAgentName(agentName: string): string;
13
+ /**
14
+ * Resolves the variant configuration for a specific agent.
15
+ *
16
+ * Looks up the agent's variant in the plugin configuration. Returns undefined if:
17
+ * - No config is provided
18
+ * - The agent has no variant configured
19
+ * - The variant is not a string
20
+ * - The variant is empty or whitespace-only
21
+ *
22
+ * @param config - The plugin configuration object
23
+ * @param agentName - The name of the agent (with or without @ prefix)
24
+ * @returns The trimmed variant string, or undefined if no valid variant is found
25
+ *
26
+ * @example
27
+ * resolveAgentVariant(config, "@oracle") // returns "high" if configured
28
+ */
29
+ export declare function resolveAgentVariant(config: PluginConfig | undefined, agentName: string): string | undefined;
30
+ /**
31
+ * Resolve a runtime-provided agent name to an internal agent name.
32
+ *
33
+ * Supports:
34
+ * - internal names (e.g. "oracle")
35
+ * - @-prefixed names (e.g. "@oracle")
36
+ * - displayName aliases (e.g. "advisor" -> "oracle")
37
+ */
38
+ export declare function resolveRuntimeAgentName(config: PluginConfig | undefined, agentName: string): string;
39
+ export type DisplayNameMentionRewriter = (text: string) => string;
40
+ export declare function createDisplayNameMentionRewriter(config: PluginConfig | undefined): DisplayNameMentionRewriter;
41
+ /**
42
+ * Rewrites user-facing display-name mentions (e.g. @advisor) into internal
43
+ * agent mentions (e.g. @oracle) for runtime routing.
44
+ */
45
+ export declare function rewriteDisplayNameMentions(config: PluginConfig | undefined, text: string): string;
46
+ /**
47
+ * Applies a variant to a request body if the body doesn't already have one.
48
+ *
49
+ * This function will NOT override an existing variant in the body. If no variant
50
+ * is provided or the body already has a variant, the original body is returned.
51
+ *
52
+ * @template T - The type of the body object, must have an optional variant property
53
+ * @param variant - The variant string to apply (or undefined)
54
+ * @param body - The request body object
55
+ * @returns The body with the variant applied (new object) or the original body unchanged
56
+ *
57
+ * @example
58
+ * applyAgentVariant("high", { agent: "oracle" }) // returns { agent: "oracle", variant: "high" }
59
+ * applyAgentVariant("high", { agent: "oracle", variant: "low" }) // returns original body with variant: "low"
60
+ */
61
+ export declare function applyAgentVariant<T extends {
62
+ variant?: string;
63
+ }>(variant: string | undefined, body: T): T;
@@ -0,0 +1,30 @@
1
+ import type { ChildProcess } from 'node:child_process';
2
+ export declare const isBun: boolean;
3
+ export interface CrossSpawnResult {
4
+ proc: ChildProcess;
5
+ /** Collects all stdout into a string */
6
+ stdout: () => Promise<string>;
7
+ /** Collects all stderr into a string */
8
+ stderr: () => Promise<string>;
9
+ /** Resolves when process exits with exit code */
10
+ exited: Promise<number>;
11
+ /** Kill the process */
12
+ kill: (signal?: NodeJS.Signals | number) => boolean;
13
+ /** Current exit code or null if running */
14
+ get exitCode(): number | null;
15
+ }
16
+ /**
17
+ * Cross-runtime spawn that works in both Bun and Node.js.
18
+ * API mimics Bun.spawn but uses node:child_process internally.
19
+ */
20
+ export declare function crossSpawn(command: string[], options?: {
21
+ stdout?: 'pipe' | 'inherit' | 'ignore';
22
+ stderr?: 'pipe' | 'inherit' | 'ignore';
23
+ stdin?: 'pipe' | 'inherit' | 'ignore';
24
+ cwd?: string;
25
+ env?: Record<string, string | undefined>;
26
+ }): CrossSpawnResult;
27
+ /**
28
+ * Cross-runtime file write that works in both Bun and Node.js.
29
+ */
30
+ export declare function crossWrite(path: string, data: ArrayBuffer | Buffer | string): Promise<void>;
@@ -0,0 +1 @@
1
+ export declare function getEnv(name: string): string | undefined;
@@ -0,0 +1,9 @@
1
+ export * from './agent-variant';
2
+ export * from './env';
3
+ export * from './internal-initiator';
4
+ export { getLogDir, initLogger, log, resetLogger } from './logger';
5
+ export * from './polling';
6
+ export * from './session';
7
+ export * from './session-manager';
8
+ export * from './task';
9
+ export { extractZip } from './zip-extractor';
@@ -0,0 +1,6 @@
1
+ export declare const SLIM_INTERNAL_INITIATOR_MARKER = "<!-- SLIM_INTERNAL_INITIATOR -->";
2
+ export declare function createInternalAgentTextPart(text: string): {
3
+ type: 'text';
4
+ text: string;
5
+ };
6
+ export declare function hasInternalInitiatorMarker(part: unknown): boolean;
@@ -0,0 +1,8 @@
1
+ declare function getLogDir(): string;
2
+ export declare function initLogger(sessionId: string): void;
3
+ /** @internal Reset logger state for testing */
4
+ export declare function resetLogger(): void;
5
+ /** @internal Wait for queued log writes in tests. */
6
+ export declare function flushLoggerForTesting(): Promise<void>;
7
+ export { getLogDir };
8
+ export declare function log(message: string, data?: unknown): void;
@@ -0,0 +1,21 @@
1
+ export interface PollOptions {
2
+ pollInterval?: number;
3
+ maxPollTime?: number;
4
+ stableThreshold?: number;
5
+ signal?: AbortSignal;
6
+ }
7
+ export interface PollResult<T> {
8
+ success: boolean;
9
+ data?: T;
10
+ timedOut?: boolean;
11
+ aborted?: boolean;
12
+ }
13
+ /**
14
+ * Generic polling utility that waits for a condition to be met.
15
+ * Returns when the condition is satisfied or timeout/abort occurs.
16
+ */
17
+ export declare function pollUntilStable<T>(fetchFn: () => Promise<T>, isStable: (current: T, previous: T | null, stableCount: number) => boolean, opts?: PollOptions): Promise<PollResult<T>>;
18
+ /**
19
+ * Simple delay utility
20
+ */
21
+ export declare function delay(ms: number): Promise<void>;
@@ -0,0 +1,55 @@
1
+ import type { AgentName } from '../config';
2
+ export interface ContextFile {
3
+ path: string;
4
+ lineCount: number;
5
+ lineNumbers?: number[];
6
+ lastReadAt: number;
7
+ }
8
+ export interface RememberedTaskSession {
9
+ alias: string;
10
+ taskId: string;
11
+ agentType: AgentName;
12
+ label: string;
13
+ contextFiles: ContextFile[];
14
+ createdAt: number;
15
+ lastUsedAt: number;
16
+ }
17
+ interface SessionManagerOptions {
18
+ readContextMinLines?: number;
19
+ readContextMaxFiles?: number;
20
+ }
21
+ export declare function deriveTaskSessionLabel(input: {
22
+ description?: string;
23
+ prompt?: string;
24
+ agentType: AgentName;
25
+ }): string;
26
+ export declare class SessionManager {
27
+ private readonly maxSessionsPerAgent;
28
+ private readonly readContextMinLines;
29
+ private readonly readContextMaxFiles;
30
+ private readonly sessionsByParent;
31
+ private readonly nextAliasIndexByParent;
32
+ private orderCounter;
33
+ constructor(maxSessionsPerAgent: number, options?: SessionManagerOptions);
34
+ remember(input: {
35
+ parentSessionId: string;
36
+ taskId: string;
37
+ agentType: AgentName;
38
+ label: string;
39
+ }): RememberedTaskSession;
40
+ markUsed(parentSessionId: string, agentType: AgentName, key: string): void;
41
+ resolve(parentSessionId: string, agentType: AgentName, key: string): RememberedTaskSession | undefined;
42
+ drop(parentSessionId: string, agentType: AgentName, key: string): void;
43
+ dropTask(taskId: string): void;
44
+ taskIds(): Set<string>;
45
+ addContext(taskId: string, files: ContextFile[]): void;
46
+ clearParent(parentSessionId: string): void;
47
+ formatForPrompt(parentSessionId: string): string | undefined;
48
+ private getAgentGroup;
49
+ private setAgentGroup;
50
+ private nextAlias;
51
+ private trimGroup;
52
+ private trimContextFiles;
53
+ private nextOrder;
54
+ }
55
+ export {};
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Shared session utilities for council and background managers.
3
+ */
4
+ import type { PluginInput } from '@opencode-ai/plugin';
5
+ type OpencodeClient = PluginInput['client'];
6
+ export declare const SESSION_ABORT_TIMEOUT_MS = 1000;
7
+ export declare class OperationTimeoutError extends Error {
8
+ constructor(message: string);
9
+ }
10
+ export declare function withTimeout<T>(operation: Promise<T>, timeoutMs: number, message: string): Promise<T>;
11
+ export declare function abortSessionWithTimeout(client: OpencodeClient, sessionId: string, timeoutMs?: number): Promise<void>;
12
+ /**
13
+ * Extract the short model label from a "provider/model" string.
14
+ * E.g. "openai/gpt-5.4-mini" → "gpt-5.4-mini"
15
+ */
16
+ export declare function shortModelLabel(model: string): string;
17
+ export type PromptBody = {
18
+ messageID?: string;
19
+ model?: {
20
+ providerID: string;
21
+ modelID: string;
22
+ };
23
+ agent?: string;
24
+ noReply?: boolean;
25
+ system?: string;
26
+ tools?: {
27
+ [key: string]: boolean;
28
+ };
29
+ parts: Array<{
30
+ type: 'text';
31
+ text: string;
32
+ }>;
33
+ variant?: string;
34
+ };
35
+ /**
36
+ * Parse a model reference string into provider and model IDs.
37
+ * @param model - Model string in format "provider/model"
38
+ * @returns Object with providerID and modelID, or null if invalid
39
+ */
40
+ export declare function parseModelReference(model: string): {
41
+ providerID: string;
42
+ modelID: string;
43
+ } | null;
44
+ /**
45
+ * Send a prompt to a session with optional timeout.
46
+ * If timeout is exceeded, the session is aborted and an error is thrown.
47
+ * @param client - OpenCode client instance
48
+ * @param args - Arguments for session.prompt()
49
+ * @param timeoutMs - Timeout in milliseconds (0 = no timeout)
50
+ * @throws Error if timeout is exceeded
51
+ */
52
+ export declare function promptWithTimeout(client: OpencodeClient, args: Parameters<OpencodeClient['session']['prompt']>[0], timeoutMs: number): Promise<void>;
53
+ /**
54
+ * Result of extracting session content.
55
+ * `empty` is true when the assistant produced zero text content —
56
+ * the provider returned an empty response (e.g. rate-limited silently).
57
+ */
58
+ export interface SessionExtractionResult {
59
+ text: string;
60
+ empty: boolean;
61
+ }
62
+ /**
63
+ * Extract the result text from a session.
64
+ * Collects all assistant messages and concatenates their text parts.
65
+ * @param client - OpenCode client instance
66
+ * @param sessionId - Session ID to extract from
67
+ * @param options - Optional: `includeReasoning` (default true) controls whether
68
+ * reasoning/chain-of-thought parts are included.
69
+ * @returns Object with extracted text and an `empty` flag for zero-content detection
70
+ */
71
+ export declare function extractSessionResult(client: OpencodeClient, sessionId: string, options?: {
72
+ includeReasoning?: boolean;
73
+ }): Promise<SessionExtractionResult>;
74
+ export {};
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Tracks subagent spawn depth to prevent excessive nesting.
3
+ *
4
+ * Depth 0 = root session (user's main conversation)
5
+ * Depth 1 = agent spawned by root (e.g., explorer, council)
6
+ * Depth 2 = agent spawned by depth-1 agent (e.g., councillor spawned by council)
7
+ * Depth 3 = agent spawned by depth-2 agent (max depth by default)
8
+ *
9
+ * When max depth is exceeded, the spawn is blocked.
10
+ */
11
+ export declare class SubagentDepthTracker {
12
+ private depthBySession;
13
+ private readonly _maxDepth;
14
+ constructor(maxDepth?: number);
15
+ /** Maximum allowed depth. */
16
+ get maxDepth(): number;
17
+ /**
18
+ * Get the current depth of a session.
19
+ * Root sessions (not tracked) have depth 0.
20
+ */
21
+ getDepth(sessionId: string): number;
22
+ /**
23
+ * Register a child session and check if the spawn is allowed.
24
+ * @returns true if allowed, false if max depth exceeded
25
+ */
26
+ registerChild(parentSessionId: string, childSessionId: string): boolean;
27
+ /**
28
+ * Clean up session tracking when a session is deleted.
29
+ */
30
+ cleanup(sessionId: string): void;
31
+ /**
32
+ * Clean up all tracking data.
33
+ */
34
+ cleanupAll(): void;
35
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Collapse a system message array into a single element by joining all
3
+ * entries with double-newline separators. Mutates the array in-place so
4
+ * that callers holding a reference to the original array see the change.
5
+ */
6
+ export declare function collapseSystemInPlace(system: string[]): void;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Parse Task tool output to recover a session/task ID for resumption.
3
+ */
4
+ export declare function parseTaskIdFromTaskOutput(output: string): string | undefined;
@@ -0,0 +1 @@
1
+ export declare function extractZip(archivePath: string, destDir: string): Promise<void>;
package/package.json ADDED
@@ -0,0 +1,104 @@
1
+ {
2
+ "name": "@zcy2nn/agent-forge",
3
+ "version": "1.0.1",
4
+ "description": "Lightweight agent orchestration plugin for OpenCode - a slimmed-down fork of oh-my-opencode",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/index.js",
10
+ "types": "./dist/index.d.ts"
11
+ },
12
+ "./tui": {
13
+ "import": "./dist/tui.js",
14
+ "types": "./dist/tui.d.ts"
15
+ }
16
+ },
17
+ "bin": {
18
+ "agent-forge": "./dist/cli/index.js"
19
+ },
20
+ "type": "module",
21
+ "license": "MIT",
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "keywords": [
26
+ "opencode",
27
+ "opencode-plugin",
28
+ "ai",
29
+ "agents",
30
+ "orchestration",
31
+ "llm",
32
+ "claude",
33
+ "gpt",
34
+ "gemini"
35
+ ],
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "https://cnb.cool/zcyoop/ai-assistant/agent-forge"
39
+ },
40
+ "bugs": {
41
+ "url": "https://cnb.cool/zcyoop/ai-assistant/agent-forge/issues"
42
+ },
43
+ "homepage": "https://cnb.cool/zcyoop/ai-assistant/agent-forge#readme",
44
+ "files": [
45
+ "dist",
46
+ "src/skills",
47
+ "agent-forge.schema.json",
48
+ "README.md",
49
+ "LICENSE"
50
+ ],
51
+ "scripts": {
52
+ "build:plugin": "bun build src/index.ts src/tui.ts --outdir dist --target node --format esm --external @ast-grep/napi --external @opencode-ai/plugin --external @opencode-ai/sdk --external @opentui/core --external @opentui/solid --external jsdom --external zod",
53
+ "build:cli": "bun build src/cli/index.ts --outdir dist/cli --target node --format esm --external @ast-grep/napi --external @opencode-ai/plugin --external @opencode-ai/sdk --external jsdom --external zod",
54
+ "copy:divoom-assets": "bun run scripts/copy-divoom-assets.ts",
55
+ "build": "bun run build:plugin && bun run build:cli && bun run copy:divoom-assets && tsc --emitDeclarationOnly && bun run generate-schema",
56
+ "prepare": "bun run build",
57
+ "contributors:add": "all-contributors add",
58
+ "contributors:check": "all-contributors check",
59
+ "contributors:generate": "all-contributors generate",
60
+ "generate-schema": "bun run scripts/generate-schema.ts",
61
+ "verify:release": "bun run scripts/verify-release-artifact.ts",
62
+ "verify:host-smoke": "bun run scripts/verify-opencode-host-smoke.ts",
63
+ "typecheck": "tsc --noEmit",
64
+ "test": "bun test",
65
+ "lint": "biome lint .",
66
+ "format": "biome format . --write",
67
+ "check": "biome check --write .",
68
+ "check:ci": "biome check .",
69
+ "dev": "bun run build && opencode",
70
+ "prepublishOnly": "bun run build",
71
+ "release:patch": "npm version patch && git push --follow-tags && npm publish --access public",
72
+ "release:minor": "npm version minor && git push --follow-tags && npm publish --access public",
73
+ "release:major": "npm version major && git push --follow-tags && npm publish --access public"
74
+ },
75
+ "dependencies": {
76
+ "@ast-grep/cli": "^0.42.1",
77
+ "@modelcontextprotocol/sdk": "^1.29.0",
78
+ "@mozilla/readability": "^0.6.0",
79
+ "@opencode-ai/plugin": "^1.3.17",
80
+ "@opencode-ai/sdk": "^1.3.17",
81
+ "jsdom": "^26.1.0",
82
+ "lru-cache": "^11.3.3",
83
+ "turndown": "^7.2.4"
84
+ },
85
+ "optionalDependencies": {
86
+ "@opentui/solid": "^0.1.97"
87
+ },
88
+ "devDependencies": {
89
+ "@biomejs/biome": "2.4.11",
90
+ "@types/jsdom": "^21.1.7",
91
+ "@types/node": "^24.6.1",
92
+ "@types/turndown": "^5.0.6",
93
+ "all-contributors-cli": "^6.26.1",
94
+ "bun-types": "1.3.12",
95
+ "typescript": "^5.9.3",
96
+ "zod": "^4.3.6"
97
+ },
98
+ "peerDependencies": {
99
+ "zod": "^4.0.0"
100
+ },
101
+ "trustedDependencies": [
102
+ "@ast-grep/cli"
103
+ ]
104
+ }
@@ -0,0 +1,177 @@
1
+ ---
2
+ name: brainstorming
3
+ description: "You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation."
4
+ ---
5
+
6
+ # Brainstorming Ideas Into Designs
7
+
8
+ Help turn ideas into fully formed designs and specs through natural collaborative dialogue.
9
+
10
+ Start by understanding the current project context, then ask questions one at a time to refine the idea. Once you understand what you're building, present the design and get user approval.
11
+
12
+ <HARD-GATE>
13
+ Do NOT invoke any implementation skill, write any code, scaffold any project, or take any implementation action until you have presented a design and the user has approved it. This applies to EVERY project regardless of perceived simplicity.
14
+ </HARD-GATE>
15
+
16
+ ## Anti-Pattern: "This Is Too Simple To Need A Design"
17
+
18
+ Every project goes through this process. A todo list, a single-function utility, a config change — all of them. "Simple" projects are where unexamined assumptions cause the most wasted work. The design can be short (a few sentences for truly simple projects), but you MUST present it and get approval.
19
+
20
+ ## Checklist
21
+
22
+ You MUST create a task for each of these items and complete them in order:
23
+
24
+ 1. **Explore project context** — check files, docs, recent commits
25
+ 2. **Offer visual companion** (if topic will involve visual questions) — this is its own message, not combined with a clarifying question. See the Visual Companion section below.
26
+ 3. **Ask clarifying questions** — one at a time, understand purpose/constraints/success criteria
27
+ 4. **Propose 2-3 approaches** — with trade-offs and your recommendation
28
+ 5. **Present design** — in sections scaled to their complexity, get user approval after each section
29
+ 6. **Write design doc** — save to `docs/superpowers/specs/YYYY-MM-DD-<topic>-design.md` and commit
30
+ 7. **Spec self-review** — quick inline check for placeholders, contradictions, ambiguity, scope (see below)
31
+ 8. **User reviews written spec** — ask user to review the spec file before proceeding
32
+ 9. **Transition to implementation** — invoke writing-plans skill to create implementation plan
33
+
34
+ ## Process Flow
35
+
36
+ ```dot
37
+ digraph brainstorming {
38
+ "Explore project context" [shape=box];
39
+ "Visual questions ahead?" [shape=diamond];
40
+ "Offer Visual Companion\n(own message, no other content)" [shape=box];
41
+ "Ask clarifying questions" [shape=box];
42
+ "Propose 2-3 approaches" [shape=box];
43
+ "Present design sections" [shape=box];
44
+ "User approves design?" [shape=diamond];
45
+ "Write design doc" [shape=box];
46
+ "Spec self-review\n(fix inline)" [shape=box];
47
+ "User reviews spec?" [shape=diamond];
48
+ "Invoke writing-plans skill" [shape=doublecircle];
49
+
50
+ "Explore project context" -> "Visual questions ahead?";
51
+ "Visual questions ahead?" -> "Offer Visual Companion\n(own message, no other content)" [label="yes"];
52
+ "Visual questions ahead?" -> "Ask clarifying questions" [label="no"];
53
+ "Offer Visual Companion\n(own message, no other content)" -> "Ask clarifying questions";
54
+ "Ask clarifying questions" -> "Propose 2-3 approaches";
55
+ "Propose 2-3 approaches" -> "Present design sections";
56
+ "Present design sections" -> "User approves design?";
57
+ "User approves design?" -> "Present design sections" [label="no, revise"];
58
+ "User approves design?" -> "Write design doc" [label="yes"];
59
+ "Write design doc" -> "Spec self-review\n(fix inline)";
60
+ "Spec self-review\n(fix inline)" -> "User reviews spec?";
61
+ "User reviews spec?" -> "Write design doc" [label="changes requested"];
62
+ "User reviews spec?" -> "Invoke writing-plans skill" [label="approved"];
63
+ }
64
+ ```
65
+
66
+ **The terminal state is invoking writing-plans.** Do NOT invoke frontend-design, mcp-builder, or any other implementation skill. The ONLY skill you invoke after brainstorming is writing-plans.
67
+
68
+ ## The Process
69
+
70
+ **Understanding the idea:**
71
+
72
+ - Check out the current project state first (files, docs, recent commits)
73
+ - Before asking detailed questions, assess scope: if the request describes multiple independent subsystems (e.g., "build a platform with chat, file storage, billing, and analytics"), flag this immediately. Don't spend questions refining details of a project that needs to be decomposed first.
74
+ - If the project is too large for a single spec, help the user decompose into sub-projects: what are the independent pieces, how do they relate, what order should they be built? Then brainstorm the first sub-project through the normal design flow. Each sub-project gets its own spec → plan → implementation cycle.
75
+ - For appropriately-scoped projects, ask questions one at a time to refine the idea
76
+ - Prefer multiple choice questions when possible, but open-ended is fine too
77
+ - Only one question per message - if a topic needs more exploration, break it into multiple questions
78
+ - Focus on understanding: purpose, constraints, success criteria
79
+
80
+ **Exploring approaches:**
81
+
82
+ - Propose 2-3 different approaches with trade-offs
83
+ - Present options conversationally with your recommendation and reasoning
84
+ - Lead with your recommended option and explain why
85
+
86
+ **Presenting the design:**
87
+
88
+ - Once you believe you understand what you're building, present the design
89
+ - Scale each section to its complexity: a few sentences if straightforward, up to 200-300 words if nuanced
90
+ - Ask after each section whether it looks right so far
91
+ - Cover: architecture, components, data flow, error handling, testing
92
+ - Be ready to go back and clarify if something doesn't make sense
93
+
94
+ **Design for isolation and clarity:**
95
+
96
+ - Break the system into smaller units that each have one clear purpose, communicate through well-defined interfaces, and can be understood and tested independently
97
+ - For each unit, you should be able to answer: what does it do, how do you use it, and what does it depend on?
98
+ - Can someone understand what a unit does without reading its internals? Can you change the internals without breaking consumers? If not, the boundaries need work.
99
+ - Smaller, well-bounded units are also easier for you to work with - you reason better about code you can hold in context at once, and your edits are more reliable when files are focused. When a file grows large, that's often a signal that it's doing too much.
100
+
101
+ **Working in existing codebases:**
102
+
103
+ - Explore the current structure before proposing changes. Follow existing patterns.
104
+ - Where existing code has problems that affect the work (e.g., a file that's grown too large, unclear boundaries, tangled responsibilities), include targeted improvements as part of the design - the way a good developer improves code they're working in.
105
+ - Don't propose unrelated refactoring. Stay focused on what serves the current goal.
106
+
107
+ ## After the Design
108
+
109
+ **Documentation:**
110
+
111
+ - Write the validated design (spec) to `docs/superpowers/specs/YYYY-MM-DD-<topic>-design.md`
112
+ - (User preferences for spec location override this default)
113
+ - Use elements-of-style:writing-clearly-and-concisely skill if available
114
+ - Commit the design document to git
115
+
116
+ **Spec Self-Review:**
117
+ After writing the spec document, look at it with fresh eyes:
118
+
119
+ 1. **Placeholder scan:** Any "TBD", "TODO", incomplete sections, or vague requirements? Fix them.
120
+ 2. **Internal consistency:** Do any sections contradict each other? Does the architecture match the feature descriptions?
121
+ 3. **Scope check:** Is this focused enough for a single implementation plan, or does it need decomposition?
122
+ 4. **Ambiguity check:** Could any requirement be interpreted two different ways? If so, pick one and make it explicit.
123
+
124
+ Fix any issues inline. No need to re-review — just fix and move on.
125
+
126
+ **User Review Gate:**
127
+ After the spec review loop passes, ask the user to review the written spec before proceeding:
128
+
129
+ > "Spec written and committed to `<path>`. Please review it and let me know if you want to make any changes before we start writing out the implementation plan."
130
+
131
+ Wait for the user's response. If they request changes, make them and re-run the spec review loop. Only proceed once the user approves.
132
+
133
+ **Implementation:**
134
+
135
+ - Invoke the writing-plans skill to create a detailed implementation plan
136
+ - Do NOT invoke any other skill. writing-plans is the next step.
137
+
138
+ ## Key Principles
139
+
140
+ - **One question at a time** - Don't overwhelm with multiple questions
141
+ - **Multiple choice preferred** - Easier to answer than open-ended when possible
142
+ - **YAGNI ruthlessly** - Remove unnecessary features from all designs
143
+ - **Explore alternatives** - Always propose 2-3 approaches before settling
144
+ - **Incremental validation** - Present design, get approval before moving on
145
+ - **Be flexible** - Go back and clarify when something doesn't make sense
146
+
147
+ ## Complexity Assessment
148
+
149
+ **Lightweight usage:**
150
+ - Skip context exploration, skip one-by-one questions
151
+ - Give 2-3 options directly for user to pick
152
+ - No spec document — oral confirmation is enough
153
+
154
+ **Standard usage:**
155
+ - Full flow: explore context → one-by-one questions → compare approaches → present design → write spec
156
+
157
+ **Deep usage:**
158
+ - Standard + visual companion + detailed spec self-review + multiple revisions
159
+
160
+ ## Visual Companion
161
+
162
+ A browser-based companion for showing mockups, diagrams, and visual options during brainstorming. Available as a tool — not a mode. Accepting the companion means it's available for questions that benefit from visual treatment; it does NOT mean every question goes through the browser.
163
+
164
+ **Offering the companion:** When you anticipate that upcoming questions will involve visual content (mockups, layouts, diagrams), offer it once for consent:
165
+ > "Some of what we're working on might be easier to explain if I can show it to you in a web browser. I can put together mockups, diagrams, comparisons, and other visuals as we go. This feature is still new and can be token-intensive. Want to try it? (Requires opening a local URL)"
166
+
167
+ **This offer MUST be its own message.** Do not combine it with clarifying questions, context summaries, or any other content. The message should contain ONLY the offer above and nothing else. Wait for the user's response before continuing. If they decline, proceed with text-only brainstorming.
168
+
169
+ **Per-question decision:** Even after the user accepts, decide FOR EACH QUESTION whether to use the browser or the terminal. The test: **would the user understand this better by seeing it than reading it?**
170
+
171
+ - **Use the browser** for content that IS visual — mockups, wireframes, layout comparisons, architecture diagrams, side-by-side visual designs
172
+ - **Use the terminal** for content that is text — requirements questions, conceptual choices, tradeoff lists, A/B/C/D text options, scope decisions
173
+
174
+ A question about a UI topic is not automatically a visual question. "What does personality mean in this context?" is a conceptual question — use the terminal. "Which wizard layout works better?" is a visual question — use the browser.
175
+
176
+ If they agree to the companion, read the detailed guide before proceeding:
177
+ `skills/brainstorming/visual-companion.md`