@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.
- package/LICENSE +21 -0
- package/README.md +266 -0
- package/agent-forge.schema.json +675 -0
- package/dist/agents/council.d.ts +27 -0
- package/dist/agents/councillor.d.ts +2 -0
- package/dist/agents/implementer.d.ts +2 -0
- package/dist/agents/index.d.ts +30 -0
- package/dist/agents/orchestrator.d.ts +30 -0
- package/dist/agents/researcher.d.ts +2 -0
- package/dist/agents/reviewer.d.ts +2 -0
- package/dist/cli/config-io.d.ts +24 -0
- package/dist/cli/config-manager.d.ts +4 -0
- package/dist/cli/custom-skills.d.ts +29 -0
- package/dist/cli/doctor.d.ts +38 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +1932 -0
- package/dist/cli/install.d.ts +2 -0
- package/dist/cli/migration.d.ts +46 -0
- package/dist/cli/model-key-normalization.d.ts +1 -0
- package/dist/cli/paths.d.ts +35 -0
- package/dist/cli/providers.d.ts +99 -0
- package/dist/cli/skills.d.ts +52 -0
- package/dist/cli/system.d.ts +6 -0
- package/dist/cli/types.d.ts +40 -0
- package/dist/config/agent-mcps.d.ts +15 -0
- package/dist/config/constants.d.ts +28 -0
- package/dist/config/council-schema.d.ts +127 -0
- package/dist/config/index.d.ts +5 -0
- package/dist/config/loader.d.ts +57 -0
- package/dist/config/runtime-preset.d.ts +12 -0
- package/dist/config/schema.d.ts +371 -0
- package/dist/config/utils.d.ts +15 -0
- package/dist/council/council-manager.d.ts +49 -0
- package/dist/council/index.d.ts +1 -0
- package/dist/divoom/council.gif +0 -0
- package/dist/divoom/designer.gif +0 -0
- package/dist/divoom/explorer.gif +0 -0
- package/dist/divoom/fixer.gif +0 -0
- package/dist/divoom/input.gif +0 -0
- package/dist/divoom/intro.gif +0 -0
- package/dist/divoom/librarian.gif +0 -0
- package/dist/divoom/manager.d.ts +57 -0
- package/dist/divoom/oracle.gif +0 -0
- package/dist/divoom/orchestrator.gif +0 -0
- package/dist/hooks/apply-patch/codec.d.ts +7 -0
- package/dist/hooks/apply-patch/errors.d.ts +25 -0
- package/dist/hooks/apply-patch/execution-context.d.ts +27 -0
- package/dist/hooks/apply-patch/index.d.ts +15 -0
- package/dist/hooks/apply-patch/matching.d.ts +26 -0
- package/dist/hooks/apply-patch/operations.d.ts +3 -0
- package/dist/hooks/apply-patch/patch.d.ts +2 -0
- package/dist/hooks/apply-patch/prepared-changes.d.ts +17 -0
- package/dist/hooks/apply-patch/resolution.d.ts +19 -0
- package/dist/hooks/apply-patch/rewrite.d.ts +7 -0
- package/dist/hooks/apply-patch/test-helpers.d.ts +6 -0
- package/dist/hooks/apply-patch/types.d.ts +80 -0
- package/dist/hooks/auto-update-checker/cache.d.ts +11 -0
- package/dist/hooks/auto-update-checker/checker.d.ts +32 -0
- package/dist/hooks/auto-update-checker/constants.d.ts +11 -0
- package/dist/hooks/auto-update-checker/index.d.ts +18 -0
- package/dist/hooks/auto-update-checker/types.d.ts +22 -0
- package/dist/hooks/chat-headers.d.ts +16 -0
- package/dist/hooks/delegate-task-retry/guidance.d.ts +2 -0
- package/dist/hooks/delegate-task-retry/hook.d.ts +8 -0
- package/dist/hooks/delegate-task-retry/index.d.ts +4 -0
- package/dist/hooks/delegate-task-retry/patterns.d.ts +11 -0
- package/dist/hooks/filter-available-skills/index.d.ts +32 -0
- package/dist/hooks/foreground-fallback/index.d.ts +72 -0
- package/dist/hooks/image-hook.d.ts +19 -0
- package/dist/hooks/index.d.ts +13 -0
- package/dist/hooks/json-error-recovery/hook.d.ts +18 -0
- package/dist/hooks/json-error-recovery/index.d.ts +1 -0
- package/dist/hooks/phase-reminder/index.d.ts +26 -0
- package/dist/hooks/post-file-tool-nudge/index.d.ts +19 -0
- package/dist/hooks/task-session-manager/index.d.ts +52 -0
- package/dist/hooks/todo-continuation/index.d.ts +53 -0
- package/dist/hooks/todo-continuation/todo-hygiene.d.ts +35 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +32981 -0
- package/dist/interview/dashboard.d.ts +62 -0
- package/dist/interview/document.d.ts +25 -0
- package/dist/interview/helpers.d.ts +10 -0
- package/dist/interview/index.d.ts +1 -0
- package/dist/interview/manager.d.ts +35 -0
- package/dist/interview/parser.d.ts +11 -0
- package/dist/interview/prompts.d.ts +7 -0
- package/dist/interview/server.d.ts +13 -0
- package/dist/interview/service.d.ts +34 -0
- package/dist/interview/types.d.ts +96 -0
- package/dist/interview/ui.d.ts +12 -0
- package/dist/mcp/context7.d.ts +6 -0
- package/dist/mcp/grep-app.d.ts +6 -0
- package/dist/mcp/index.d.ts +8 -0
- package/dist/mcp/types.d.ts +12 -0
- package/dist/mcp/websearch.d.ts +9 -0
- package/dist/multiplexer/factory.d.ts +26 -0
- package/dist/multiplexer/index.d.ts +9 -0
- package/dist/multiplexer/session-manager.d.ts +53 -0
- package/dist/multiplexer/tmux/index.d.ts +22 -0
- package/dist/multiplexer/types.d.ts +54 -0
- package/dist/multiplexer/zellij/index.d.ts +34 -0
- package/dist/tools/ast-grep/cli.d.ts +15 -0
- package/dist/tools/ast-grep/constants.d.ts +25 -0
- package/dist/tools/ast-grep/downloader.d.ts +5 -0
- package/dist/tools/ast-grep/index.d.ts +10 -0
- package/dist/tools/ast-grep/tools.d.ts +3 -0
- package/dist/tools/ast-grep/types.d.ts +30 -0
- package/dist/tools/ast-grep/utils.d.ts +4 -0
- package/dist/tools/council.d.ts +10 -0
- package/dist/tools/index.d.ts +6 -0
- package/dist/tools/preset-manager.d.ts +27 -0
- package/dist/tools/skill.d.ts +9 -0
- package/dist/tools/smartfetch/binary.d.ts +3 -0
- package/dist/tools/smartfetch/cache.d.ts +6 -0
- package/dist/tools/smartfetch/constants.d.ts +12 -0
- package/dist/tools/smartfetch/index.d.ts +3 -0
- package/dist/tools/smartfetch/network.d.ts +38 -0
- package/dist/tools/smartfetch/secondary-model.d.ts +28 -0
- package/dist/tools/smartfetch/tool.d.ts +3 -0
- package/dist/tools/smartfetch/types.d.ts +122 -0
- package/dist/tools/smartfetch/utils.d.ts +18 -0
- package/dist/tui-state.d.ts +15 -0
- package/dist/tui.d.ts +8 -0
- package/dist/tui.js +248 -0
- package/dist/utils/agent-variant.d.ts +63 -0
- package/dist/utils/compat.d.ts +30 -0
- package/dist/utils/env.d.ts +1 -0
- package/dist/utils/index.d.ts +9 -0
- package/dist/utils/internal-initiator.d.ts +6 -0
- package/dist/utils/logger.d.ts +8 -0
- package/dist/utils/polling.d.ts +21 -0
- package/dist/utils/session-manager.d.ts +55 -0
- package/dist/utils/session.d.ts +74 -0
- package/dist/utils/subagent-depth.d.ts +35 -0
- package/dist/utils/system-collapse.d.ts +6 -0
- package/dist/utils/task.d.ts +4 -0
- package/dist/utils/zip-extractor.d.ts +1 -0
- package/package.json +104 -0
- package/src/skills/brainstorming/SKILL.md +177 -0
- package/src/skills/brainstorming/scripts/frame-template.html +214 -0
- package/src/skills/brainstorming/scripts/helper.js +88 -0
- package/src/skills/brainstorming/scripts/server.cjs +354 -0
- package/src/skills/brainstorming/scripts/start-server.sh +148 -0
- package/src/skills/brainstorming/scripts/stop-server.sh +56 -0
- package/src/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
- package/src/skills/brainstorming/visual-companion.md +279 -0
- package/src/skills/codemap/README.md +59 -0
- package/src/skills/codemap/SKILL.md +163 -0
- package/src/skills/codemap/codemap.md +36 -0
- package/src/skills/codemap/scripts/codemap.mjs +483 -0
- package/src/skills/codemap/scripts/codemap.test.ts +129 -0
- package/src/skills/codemap.md +40 -0
- package/src/skills/dispatching-parallel-agents/SKILL.md +193 -0
- package/src/skills/executing-plans/SKILL.md +78 -0
- package/src/skills/finishing-a-development-branch/SKILL.md +211 -0
- package/src/skills/receiving-code-review/SKILL.md +224 -0
- package/src/skills/requesting-code-review/SKILL.md +113 -0
- package/src/skills/requesting-code-review/code-reviewer.md +146 -0
- package/src/skills/simplify/README.md +19 -0
- package/src/skills/simplify/SKILL.md +138 -0
- package/src/skills/simplify/codemap.md +36 -0
- package/src/skills/subagent-driven-development/SKILL.md +288 -0
- package/src/skills/subagent-driven-development/code-quality-reviewer-prompt.md +26 -0
- package/src/skills/subagent-driven-development/implementer-prompt.md +113 -0
- package/src/skills/subagent-driven-development/spec-reviewer-prompt.md +61 -0
- package/src/skills/systematic-debugging/CREATION-LOG.md +119 -0
- package/src/skills/systematic-debugging/SKILL.md +308 -0
- package/src/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
- package/src/skills/systematic-debugging/condition-based-waiting.md +115 -0
- package/src/skills/systematic-debugging/defense-in-depth.md +122 -0
- package/src/skills/systematic-debugging/find-polluter.sh +63 -0
- package/src/skills/systematic-debugging/root-cause-tracing.md +169 -0
- package/src/skills/systematic-debugging/test-academic.md +14 -0
- package/src/skills/systematic-debugging/test-pressure-1.md +58 -0
- package/src/skills/systematic-debugging/test-pressure-2.md +68 -0
- package/src/skills/systematic-debugging/test-pressure-3.md +69 -0
- package/src/skills/test-driven-development/SKILL.md +383 -0
- package/src/skills/test-driven-development/testing-anti-patterns.md +299 -0
- package/src/skills/using-git-worktrees/SKILL.md +226 -0
- package/src/skills/verification-before-completion/SKILL.md +147 -0
- package/src/skills/writing-plans/SKILL.md +165 -0
- package/src/skills/writing-plans/plan-document-reviewer-prompt.md +49 -0
- package/src/skills/writing-skills/SKILL.md +666 -0
- package/src/skills/writing-skills/anthropic-best-practices.md +1150 -0
- package/src/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +189 -0
- package/src/skills/writing-skills/graphviz-conventions.dot +172 -0
- package/src/skills/writing-skills/persuasion-principles.md +187 -0
- package/src/skills/writing-skills/render-graphs.js +168 -0
- package/src/skills/writing-skills/testing-skills-with-subagents.md +384 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ApplyPatchRuntimeOptions, MatchHit, PatchChunk, ResolvedChunk } from './types';
|
|
2
|
+
export declare function readFileLines(file: string): Promise<string[]>;
|
|
3
|
+
export declare function resolveChunkStart(lines: string[], chunk: PatchChunk, start: number): number;
|
|
4
|
+
export declare function locateChunk(lines: string[], file: string, chunk: PatchChunk, start: number, cfg: ApplyPatchRuntimeOptions): ResolvedChunk;
|
|
5
|
+
export declare function applyHits(lines: string[], hits: MatchHit[], eol?: '\n' | '\r\n', hasFinalNewline?: boolean): string;
|
|
6
|
+
export declare function resolveUpdateChunks(file: string, chunks: PatchChunk[], cfg: ApplyPatchRuntimeOptions): Promise<{
|
|
7
|
+
lines: string[];
|
|
8
|
+
resolved: ResolvedChunk[];
|
|
9
|
+
eol: '\n' | '\r\n';
|
|
10
|
+
hasFinalNewline: boolean;
|
|
11
|
+
}>;
|
|
12
|
+
export declare function deriveNewContentFromText(file: string, text: string, chunks: PatchChunk[], cfg: ApplyPatchRuntimeOptions): string;
|
|
13
|
+
export declare function resolveUpdateChunksFromText(file: string, text: string, chunks: PatchChunk[], cfg: ApplyPatchRuntimeOptions): {
|
|
14
|
+
lines: string[];
|
|
15
|
+
resolved: ResolvedChunk[];
|
|
16
|
+
eol: '\n' | '\r\n';
|
|
17
|
+
hasFinalNewline: boolean;
|
|
18
|
+
};
|
|
19
|
+
export declare function deriveNewContent(file: string, chunks: PatchChunk[], cfg: ApplyPatchRuntimeOptions): Promise<string>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ApplyPatchRuntimeOptions } from './types';
|
|
2
|
+
export type RewritePatchResult = {
|
|
3
|
+
patchText: string;
|
|
4
|
+
changed: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare function rewritePatch(root: string, patchText: string, cfg: ApplyPatchRuntimeOptions, worktree?: string): Promise<RewritePatchResult>;
|
|
7
|
+
export declare function rewritePatchText(root: string, patchText: string, cfg: ApplyPatchRuntimeOptions, worktree?: string): Promise<string>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ApplyPatchRuntimeOptions } from './types';
|
|
2
|
+
export declare const DEFAULT_OPTIONS: ApplyPatchRuntimeOptions;
|
|
3
|
+
export declare function createTempDir(prefix?: string): Promise<string>;
|
|
4
|
+
export declare function writeFixture(root: string, relativePath: string, contents: string): Promise<void>;
|
|
5
|
+
export declare function readText(root: string, relativePath: string): Promise<string>;
|
|
6
|
+
export declare function applyPatch(root: string, patchText: string, cfg?: ApplyPatchRuntimeOptions): Promise<void>;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export type ApplyPatchRuntimeOptions = {
|
|
2
|
+
prefixSuffix: boolean;
|
|
3
|
+
lcsRescue: boolean;
|
|
4
|
+
};
|
|
5
|
+
export type ApplyPatchErrorKind = 'blocked' | 'validation' | 'verification' | 'internal';
|
|
6
|
+
export type ApplyPatchErrorCode = 'malformed_patch' | 'outside_workspace' | 'verification_failed' | 'internal_unexpected';
|
|
7
|
+
export type ApplyPatchRescueStrategy = 'prefix/suffix' | 'lcs' | 'anchor';
|
|
8
|
+
export type MatchComparatorName = 'exact' | 'unicode' | 'trim-end' | 'unicode-trim-end' | 'trim' | 'unicode-trim';
|
|
9
|
+
export type PatchChunk = {
|
|
10
|
+
old_lines: string[];
|
|
11
|
+
new_lines: string[];
|
|
12
|
+
change_context?: string;
|
|
13
|
+
is_end_of_file?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export type AddPatchHunk = {
|
|
16
|
+
type: 'add';
|
|
17
|
+
path: string;
|
|
18
|
+
contents: string;
|
|
19
|
+
};
|
|
20
|
+
export type DeletePatchHunk = {
|
|
21
|
+
type: 'delete';
|
|
22
|
+
path: string;
|
|
23
|
+
};
|
|
24
|
+
export type UpdatePatchHunk = {
|
|
25
|
+
type: 'update';
|
|
26
|
+
path: string;
|
|
27
|
+
move_path?: string;
|
|
28
|
+
chunks: PatchChunk[];
|
|
29
|
+
};
|
|
30
|
+
export type PatchHunk = AddPatchHunk | DeletePatchHunk | UpdatePatchHunk;
|
|
31
|
+
export type ParsedPatch = {
|
|
32
|
+
hunks: PatchHunk[];
|
|
33
|
+
};
|
|
34
|
+
export type AddPreparedChange = {
|
|
35
|
+
type: 'add';
|
|
36
|
+
file: string;
|
|
37
|
+
text: string;
|
|
38
|
+
};
|
|
39
|
+
export type DeletePreparedChange = {
|
|
40
|
+
type: 'delete';
|
|
41
|
+
file: string;
|
|
42
|
+
};
|
|
43
|
+
export type UpdatePreparedChange = {
|
|
44
|
+
type: 'update';
|
|
45
|
+
file: string;
|
|
46
|
+
move?: string;
|
|
47
|
+
text: string;
|
|
48
|
+
};
|
|
49
|
+
export type PreparedChange = AddPreparedChange | DeletePreparedChange | UpdatePreparedChange;
|
|
50
|
+
export type MatchHit = {
|
|
51
|
+
start: number;
|
|
52
|
+
del: number;
|
|
53
|
+
add: string[];
|
|
54
|
+
};
|
|
55
|
+
export type SeekHit = {
|
|
56
|
+
index: number;
|
|
57
|
+
comparator: MatchComparatorName;
|
|
58
|
+
exact: boolean;
|
|
59
|
+
};
|
|
60
|
+
export type ResolvedChunk = {
|
|
61
|
+
hit: MatchHit;
|
|
62
|
+
old_lines: string[];
|
|
63
|
+
canonical_old_lines: string[];
|
|
64
|
+
canonical_new_lines: string[];
|
|
65
|
+
canonical_change_context?: string;
|
|
66
|
+
resolved_is_end_of_file: boolean;
|
|
67
|
+
rewritten: boolean;
|
|
68
|
+
strategy?: ApplyPatchRescueStrategy;
|
|
69
|
+
matchComparator?: MatchComparatorName;
|
|
70
|
+
};
|
|
71
|
+
export type RescueResult = {
|
|
72
|
+
kind: 'miss';
|
|
73
|
+
} | {
|
|
74
|
+
kind: 'ambiguous';
|
|
75
|
+
phase: 'prefix_suffix' | 'lcs';
|
|
76
|
+
} | {
|
|
77
|
+
kind: 'match';
|
|
78
|
+
hit: MatchHit;
|
|
79
|
+
};
|
|
80
|
+
export type LineComparator = (a: string, b: string) => boolean;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
interface AutoUpdateInstallContext {
|
|
2
|
+
installDir: string;
|
|
3
|
+
packageJsonPath: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function resolveInstallContext(runtimePackageJsonPath?: string | null): AutoUpdateInstallContext | null;
|
|
6
|
+
/**
|
|
7
|
+
* Prepares the current install root for a clean re-install of the target version.
|
|
8
|
+
* Returns the install directory to run `bun install` in.
|
|
9
|
+
*/
|
|
10
|
+
export declare function preparePackageUpdate(version: string, packageName?: string, runtimePackageJsonPath?: string | null): string | null;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { PluginEntryInfo } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Extracts the update channel (latest, alpha, beta, etc.) from a version string.
|
|
4
|
+
* @param version The version or tag to analyze.
|
|
5
|
+
* @returns The channel name.
|
|
6
|
+
*/
|
|
7
|
+
export declare function extractChannel(version: string | null): string;
|
|
8
|
+
/**
|
|
9
|
+
* Resolves the version of the plugin when running in local development mode.
|
|
10
|
+
*/
|
|
11
|
+
export declare function getLocalDevVersion(directory: string): string | null;
|
|
12
|
+
/**
|
|
13
|
+
* Resolves the package.json for the currently running plugin bundle.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getCurrentRuntimePackageJsonPath(currentModuleUrl?: string): string | null;
|
|
16
|
+
/**
|
|
17
|
+
* Searches across all config locations to find the current installation entry for this plugin.
|
|
18
|
+
*/
|
|
19
|
+
export declare function findPluginEntry(directory: string): PluginEntryInfo | null;
|
|
20
|
+
/**
|
|
21
|
+
* Resolves the installed version from node_modules, with memoization.
|
|
22
|
+
*/
|
|
23
|
+
export declare function getCachedVersion(): string | null;
|
|
24
|
+
/**
|
|
25
|
+
* Safely updates a pinned version in the configuration file.
|
|
26
|
+
* It attempts to replace the exact plugin string to preserve comments and formatting.
|
|
27
|
+
*/
|
|
28
|
+
export declare function updatePinnedVersion(configPath: string, oldEntry: string, newVersion: string): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Fetches the latest version for a specific channel from the NPM registry.
|
|
31
|
+
*/
|
|
32
|
+
export declare function getLatestVersion(channel?: string): Promise<string | null>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const PACKAGE_NAME = "@zcy2nn/agent-forge";
|
|
2
|
+
export declare const NPM_REGISTRY_URL = "https://registry.npmjs.org/-/package/@zcy2nn/agent-forge/dist-tags";
|
|
3
|
+
export declare const NPM_FETCH_TIMEOUT = 5000;
|
|
4
|
+
/** The directory used by OpenCode to cache node_modules for plugins. */
|
|
5
|
+
export declare const CACHE_DIR: string;
|
|
6
|
+
/** Path to this plugin's package.json within the OpenCode cache. */
|
|
7
|
+
export declare const INSTALLED_PACKAGE_JSON: string;
|
|
8
|
+
/** Primary OpenCode configuration file path (standard JSON). */
|
|
9
|
+
export declare const USER_OPENCODE_CONFIG: string;
|
|
10
|
+
/** Alternative OpenCode configuration file path (JSON with Comments). */
|
|
11
|
+
export declare const USER_OPENCODE_CONFIG_JSONC: string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { PluginInput } from '@opencode-ai/plugin';
|
|
2
|
+
import type { AutoUpdateCheckerOptions } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Creates an OpenCode hook that checks for plugin updates when a new session is created.
|
|
5
|
+
* @param ctx The plugin input context.
|
|
6
|
+
* @param options Configuration options for the update checker.
|
|
7
|
+
* @returns A hook object for the session.created event.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createAutoUpdateCheckerHook(ctx: PluginInput, options?: AutoUpdateCheckerOptions): {
|
|
10
|
+
event: ({ event }: {
|
|
11
|
+
event: {
|
|
12
|
+
type: string;
|
|
13
|
+
properties?: unknown;
|
|
14
|
+
};
|
|
15
|
+
}) => void;
|
|
16
|
+
};
|
|
17
|
+
export declare function getAutoUpdateInstallDir(): string;
|
|
18
|
+
export type { AutoUpdateCheckerOptions } from './types';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface NpmDistTags {
|
|
2
|
+
latest: string;
|
|
3
|
+
[key: string]: string;
|
|
4
|
+
}
|
|
5
|
+
export interface OpencodeConfig {
|
|
6
|
+
plugin?: unknown[];
|
|
7
|
+
[key: string]: unknown;
|
|
8
|
+
}
|
|
9
|
+
export interface PackageJson {
|
|
10
|
+
version: string;
|
|
11
|
+
name?: string;
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
}
|
|
14
|
+
export interface AutoUpdateCheckerOptions {
|
|
15
|
+
autoUpdate?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface PluginEntryInfo {
|
|
18
|
+
entry: string;
|
|
19
|
+
isPinned: boolean;
|
|
20
|
+
pinnedVersion: string | null;
|
|
21
|
+
configPath: string;
|
|
22
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { PluginInput, ProviderContext } from '@opencode-ai/plugin';
|
|
2
|
+
import type { Model, UserMessage } from '@opencode-ai/sdk';
|
|
3
|
+
interface ChatHeadersInput {
|
|
4
|
+
sessionID: string;
|
|
5
|
+
model: Model;
|
|
6
|
+
provider: ProviderContext;
|
|
7
|
+
message: UserMessage;
|
|
8
|
+
}
|
|
9
|
+
interface ChatHeadersOutput {
|
|
10
|
+
headers: Record<string, string>;
|
|
11
|
+
}
|
|
12
|
+
export declare function __resetInternalMarkerCacheForTesting(): void;
|
|
13
|
+
export declare function createChatHeadersHook(ctx: PluginInput): {
|
|
14
|
+
'chat.headers': (input: ChatHeadersInput, output: ChatHeadersOutput) => Promise<void>;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface DelegateTaskErrorPattern {
|
|
2
|
+
pattern: string;
|
|
3
|
+
errorType: string;
|
|
4
|
+
fixHint: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const DELEGATE_TASK_ERROR_PATTERNS: DelegateTaskErrorPattern[];
|
|
7
|
+
export interface DetectedError {
|
|
8
|
+
errorType: string;
|
|
9
|
+
originalOutput: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function detectDelegateTaskError(output: string): DetectedError | null;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filter available_skills block based on the current agent's permission.skill rules.
|
|
3
|
+
* OpenCode core injects `<available_skills>` globally, so this hook rewrites that
|
|
4
|
+
* block before the prompt is sent.
|
|
5
|
+
*/
|
|
6
|
+
import type { PluginInput } from '@opencode-ai/plugin';
|
|
7
|
+
import { type PluginConfig } from '../../config';
|
|
8
|
+
interface MessageInfo {
|
|
9
|
+
role: string;
|
|
10
|
+
agent?: string;
|
|
11
|
+
}
|
|
12
|
+
interface MessagePart {
|
|
13
|
+
type: string;
|
|
14
|
+
text?: string;
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
}
|
|
17
|
+
interface MessageWithParts {
|
|
18
|
+
info: MessageInfo;
|
|
19
|
+
parts: MessagePart[];
|
|
20
|
+
}
|
|
21
|
+
type SkillRule = 'allow' | 'ask' | 'deny';
|
|
22
|
+
declare function filterAvailableSkillsText(text: string, permissionRules: Record<string, SkillRule>): string;
|
|
23
|
+
/**
|
|
24
|
+
* Creates the experimental.chat.messages.transform hook for filtering available skills.
|
|
25
|
+
* This hook runs right before sending to API, so it doesn't affect UI display.
|
|
26
|
+
*/
|
|
27
|
+
export declare function createFilterAvailableSkillsHook(_ctx: PluginInput, config: PluginConfig): {
|
|
28
|
+
'experimental.chat.messages.transform': (_input: Record<string, never>, output: {
|
|
29
|
+
messages: MessageWithParts[];
|
|
30
|
+
}) => Promise<void>;
|
|
31
|
+
};
|
|
32
|
+
export { filterAvailableSkillsText };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime model fallback for foreground (interactive) agent sessions.
|
|
3
|
+
*
|
|
4
|
+
* When OpenCode fires a session.error, message.updated, or session.status
|
|
5
|
+
* event containing a rate-limit signal, this manager:
|
|
6
|
+
* 1. Looks up the next untried model in the agent's configured chain
|
|
7
|
+
* 2. Aborts the rate-limited prompt via client.session.abort()
|
|
8
|
+
* 3. Re-queues the last user message via client.session.promptAsync()
|
|
9
|
+
* with the new model — promptAsync returns immediately so we never
|
|
10
|
+
* block the event handler waiting for a full LLM response.
|
|
11
|
+
*
|
|
12
|
+
* This mirrors the same fallback loop used for delegated sessions, but operates
|
|
13
|
+
* reactively through the event system instead of wrapping prompt() in a
|
|
14
|
+
* try/catch, which is not possible for interactive (foreground) sessions.
|
|
15
|
+
*/
|
|
16
|
+
import type { PluginInput } from '@opencode-ai/plugin';
|
|
17
|
+
type OpencodeClient = PluginInput['client'];
|
|
18
|
+
export declare function isRateLimitError(error: unknown): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Manages runtime model fallback for foreground agent sessions.
|
|
21
|
+
*
|
|
22
|
+
* Constructed at plugin init with the ordered fallback chains for each agent
|
|
23
|
+
* (built from _modelArray entries merged with fallback.chains config).
|
|
24
|
+
*/
|
|
25
|
+
export declare class ForegroundFallbackManager {
|
|
26
|
+
private readonly client;
|
|
27
|
+
/**
|
|
28
|
+
* Ordered fallback chains per agent.
|
|
29
|
+
* e.g. { orchestrator: ['anthropic/claude-opus-4-5', 'openai/gpt-4o'] }
|
|
30
|
+
* The first model that hasn't been tried yet is selected on each fallback.
|
|
31
|
+
*/
|
|
32
|
+
private readonly chains;
|
|
33
|
+
private readonly enabled;
|
|
34
|
+
/** sessionID → last observed model string ("providerID/modelID") */
|
|
35
|
+
private readonly sessionModel;
|
|
36
|
+
/** sessionID → agent name (populated from message.updated info.agent field) */
|
|
37
|
+
private readonly sessionAgent;
|
|
38
|
+
/** sessionID → set of models already attempted this session */
|
|
39
|
+
private readonly sessionTried;
|
|
40
|
+
/** Sessions with an active fallback switch in flight */
|
|
41
|
+
private readonly inProgress;
|
|
42
|
+
/** sessionID → timestamp of last trigger (for deduplication) */
|
|
43
|
+
private readonly lastTrigger;
|
|
44
|
+
constructor(client: OpencodeClient,
|
|
45
|
+
/**
|
|
46
|
+
* Ordered fallback chains per agent.
|
|
47
|
+
* e.g. { orchestrator: ['anthropic/claude-opus-4-5', 'openai/gpt-4o'] }
|
|
48
|
+
* The first model that hasn't been tried yet is selected on each fallback.
|
|
49
|
+
*/
|
|
50
|
+
chains: Record<string, string[]>, enabled: boolean);
|
|
51
|
+
/**
|
|
52
|
+
* Process an OpenCode plugin event.
|
|
53
|
+
* Call this from the plugin's `event` hook for every event received.
|
|
54
|
+
*/
|
|
55
|
+
handleEvent(rawEvent: unknown): Promise<void>;
|
|
56
|
+
private tryFallback;
|
|
57
|
+
/**
|
|
58
|
+
* Determine the fallback chain to use for a session.
|
|
59
|
+
*
|
|
60
|
+
* Priority:
|
|
61
|
+
* 1. Agent name known AND has a configured chain → return it directly
|
|
62
|
+
* 2. Agent name known but NO chain configured → return [] (no fallback;
|
|
63
|
+
* do NOT bleed into other agents' chains which would re-prompt the
|
|
64
|
+
* session with a model belonging to a completely different agent)
|
|
65
|
+
* 3. Agent name unknown, current model known → search all chains for
|
|
66
|
+
* the model to infer which chain to use
|
|
67
|
+
* 4. Nothing matches → flatten all chains as a last resort (only
|
|
68
|
+
* reached when both agent name and current model are unavailable)
|
|
69
|
+
*/
|
|
70
|
+
private resolveChain;
|
|
71
|
+
}
|
|
72
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
interface MessageWithParts {
|
|
2
|
+
info: {
|
|
3
|
+
role: string;
|
|
4
|
+
agent?: string;
|
|
5
|
+
sessionID?: string;
|
|
6
|
+
};
|
|
7
|
+
parts: Array<{
|
|
8
|
+
type: string;
|
|
9
|
+
text?: string;
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
13
|
+
export declare function processImageAttachments(args: {
|
|
14
|
+
messages: MessageWithParts[];
|
|
15
|
+
workDir: string;
|
|
16
|
+
disabledAgents: Set<string>;
|
|
17
|
+
log: (msg: string) => void;
|
|
18
|
+
}): void;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export { createApplyPatchHook } from './apply-patch';
|
|
2
|
+
export type { AutoUpdateCheckerOptions } from './auto-update-checker';
|
|
3
|
+
export { createAutoUpdateCheckerHook } from './auto-update-checker';
|
|
4
|
+
export { createChatHeadersHook } from './chat-headers';
|
|
5
|
+
export { createDelegateTaskRetryHook } from './delegate-task-retry';
|
|
6
|
+
export { createFilterAvailableSkillsHook } from './filter-available-skills';
|
|
7
|
+
export { ForegroundFallbackManager, isRateLimitError, } from './foreground-fallback';
|
|
8
|
+
export { processImageAttachments } from './image-hook';
|
|
9
|
+
export { createJsonErrorRecoveryHook } from './json-error-recovery';
|
|
10
|
+
export { createPhaseReminderHook } from './phase-reminder';
|
|
11
|
+
export { createPostFileToolNudgeHook } from './post-file-tool-nudge';
|
|
12
|
+
export { createTaskSessionManagerHook } from './task-session-manager';
|
|
13
|
+
export { createTodoContinuationHook } from './todo-continuation';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { PluginInput } from '@opencode-ai/plugin';
|
|
2
|
+
export declare const JSON_ERROR_TOOL_EXCLUDE_LIST: readonly ["bash", "read", "glob", "webfetch", "grep_app_searchgithub", "websearch_web_search_exa"];
|
|
3
|
+
export declare const JSON_ERROR_PATTERNS: readonly [RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp, RegExp];
|
|
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
|
+
interface ToolExecuteAfterInput {
|
|
6
|
+
tool: string;
|
|
7
|
+
sessionID: string;
|
|
8
|
+
callID: string;
|
|
9
|
+
}
|
|
10
|
+
interface ToolExecuteAfterOutput {
|
|
11
|
+
title: string;
|
|
12
|
+
output: unknown;
|
|
13
|
+
metadata: unknown;
|
|
14
|
+
}
|
|
15
|
+
export declare function createJsonErrorRecoveryHook(_ctx: PluginInput): {
|
|
16
|
+
'tool.execute.after': (input: ToolExecuteAfterInput, output: ToolExecuteAfterOutput) => Promise<void>;
|
|
17
|
+
};
|
|
18
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createJsonErrorRecoveryHook, JSON_ERROR_PATTERNS, JSON_ERROR_REMINDER, JSON_ERROR_TOOL_EXCLUDE_LIST, } from './hook';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const PHASE_REMINDER = "<internal_reminder>!IMPORTANT! Recall the workflow rules:\nUnderstand \u2192 choose the best parallelized path based on your capabilities and agents delegation rules \u2192 recall session reuse rules \u2192 execute \u2192 verify.\nIf delegating, launch the specialist in the same turn you mention it !END!</internal_reminder>";
|
|
2
|
+
interface MessageInfo {
|
|
3
|
+
role: string;
|
|
4
|
+
agent?: string;
|
|
5
|
+
sessionID?: string;
|
|
6
|
+
}
|
|
7
|
+
interface MessagePart {
|
|
8
|
+
type: string;
|
|
9
|
+
text?: string;
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
}
|
|
12
|
+
interface MessageWithParts {
|
|
13
|
+
info: MessageInfo;
|
|
14
|
+
parts: MessagePart[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Creates the experimental.chat.messages.transform hook for phase reminder injection.
|
|
18
|
+
* This hook runs right before sending to API, so it doesn't affect UI display.
|
|
19
|
+
* Only injects for the orchestrator agent.
|
|
20
|
+
*/
|
|
21
|
+
export declare function createPhaseReminderHook(): {
|
|
22
|
+
'experimental.chat.messages.transform': (_input: Record<string, never>, output: {
|
|
23
|
+
messages: MessageWithParts[];
|
|
24
|
+
}) => Promise<void>;
|
|
25
|
+
};
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Post-tool nudge - queues a delegation reminder after file reads/writes.
|
|
3
|
+
* Catches the "inspect/edit files → implement myself" anti-pattern.
|
|
4
|
+
*/
|
|
5
|
+
interface ToolExecuteAfterInput {
|
|
6
|
+
tool: string;
|
|
7
|
+
sessionID?: string;
|
|
8
|
+
callID?: string;
|
|
9
|
+
}
|
|
10
|
+
interface ToolExecuteAfterOutput {
|
|
11
|
+
output?: unknown;
|
|
12
|
+
}
|
|
13
|
+
interface PostFileToolNudgeOptions {
|
|
14
|
+
shouldInject?: (sessionID: string) => boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare function createPostFileToolNudgeHook(options?: PostFileToolNudgeOptions): {
|
|
17
|
+
'tool.execute.after': (input: ToolExecuteAfterInput, output: ToolExecuteAfterOutput) => Promise<void>;
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { PluginInput } from '@opencode-ai/plugin';
|
|
2
|
+
interface ChatMessagePart {
|
|
3
|
+
type: string;
|
|
4
|
+
text?: string;
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
}
|
|
7
|
+
interface ChatMessage {
|
|
8
|
+
info: {
|
|
9
|
+
role: string;
|
|
10
|
+
agent?: string;
|
|
11
|
+
sessionID?: string;
|
|
12
|
+
};
|
|
13
|
+
parts: ChatMessagePart[];
|
|
14
|
+
}
|
|
15
|
+
export declare function createTaskSessionManagerHook(_ctx: PluginInput, options: {
|
|
16
|
+
maxSessionsPerAgent: number;
|
|
17
|
+
readContextMinLines?: number;
|
|
18
|
+
readContextMaxFiles?: number;
|
|
19
|
+
shouldManageSession: (sessionID: string) => boolean;
|
|
20
|
+
}): {
|
|
21
|
+
'tool.execute.before': (input: {
|
|
22
|
+
tool: string;
|
|
23
|
+
sessionID?: string;
|
|
24
|
+
callID?: string;
|
|
25
|
+
}, output: {
|
|
26
|
+
args?: unknown;
|
|
27
|
+
}) => Promise<void>;
|
|
28
|
+
'tool.execute.after': (input: {
|
|
29
|
+
tool: string;
|
|
30
|
+
sessionID?: string;
|
|
31
|
+
callID?: string;
|
|
32
|
+
}, output: {
|
|
33
|
+
output: unknown;
|
|
34
|
+
metadata?: unknown;
|
|
35
|
+
}) => Promise<void>;
|
|
36
|
+
'experimental.chat.messages.transform': (_input: Record<string, never>, output: {
|
|
37
|
+
messages: ChatMessage[];
|
|
38
|
+
}) => Promise<void>;
|
|
39
|
+
event: (input: {
|
|
40
|
+
event: {
|
|
41
|
+
type: string;
|
|
42
|
+
properties?: {
|
|
43
|
+
info?: {
|
|
44
|
+
id?: string;
|
|
45
|
+
parentID?: string;
|
|
46
|
+
};
|
|
47
|
+
sessionID?: string;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
}) => Promise<void>;
|
|
51
|
+
};
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { PluginInput } from '@opencode-ai/plugin';
|
|
2
|
+
interface MessagePart {
|
|
3
|
+
type?: string;
|
|
4
|
+
text?: string;
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
}
|
|
7
|
+
interface ChatTransformMessage {
|
|
8
|
+
info: {
|
|
9
|
+
id?: string;
|
|
10
|
+
role?: string;
|
|
11
|
+
agent?: string;
|
|
12
|
+
sessionID?: string;
|
|
13
|
+
};
|
|
14
|
+
parts: MessagePart[];
|
|
15
|
+
}
|
|
16
|
+
export declare function createTodoContinuationHook(ctx: PluginInput, config?: {
|
|
17
|
+
maxContinuations?: number;
|
|
18
|
+
cooldownMs?: number;
|
|
19
|
+
autoEnable?: boolean;
|
|
20
|
+
autoEnableThreshold?: number;
|
|
21
|
+
}): {
|
|
22
|
+
tool: Record<string, unknown>;
|
|
23
|
+
handleToolExecuteAfter: (input: {
|
|
24
|
+
tool: string;
|
|
25
|
+
sessionID?: string;
|
|
26
|
+
}, output?: {
|
|
27
|
+
output?: unknown;
|
|
28
|
+
}) => Promise<void>;
|
|
29
|
+
handleMessagesTransform: (output: {
|
|
30
|
+
messages: ChatTransformMessage[];
|
|
31
|
+
}) => Promise<void>;
|
|
32
|
+
handleEvent: (input: {
|
|
33
|
+
event: {
|
|
34
|
+
type: string;
|
|
35
|
+
properties?: Record<string, unknown>;
|
|
36
|
+
};
|
|
37
|
+
}) => Promise<void>;
|
|
38
|
+
handleChatMessage: (input: {
|
|
39
|
+
sessionID: string;
|
|
40
|
+
agent?: string;
|
|
41
|
+
}) => void;
|
|
42
|
+
handleCommandExecuteBefore: (input: {
|
|
43
|
+
command: string;
|
|
44
|
+
sessionID: string;
|
|
45
|
+
arguments: string;
|
|
46
|
+
}, output: {
|
|
47
|
+
parts: Array<{
|
|
48
|
+
type: string;
|
|
49
|
+
text?: string;
|
|
50
|
+
}>;
|
|
51
|
+
}) => Promise<void>;
|
|
52
|
+
};
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export declare const TODO_HYGIENE_REMINDER = "If the active task changed or finished, update the todo list to match the current work state.";
|
|
2
|
+
export declare const TODO_FINAL_ACTIVE_REMINDER = "If you are finishing now, do not leave the active todo in_progress. Mark it completed, or move unfinished work back to pending.";
|
|
3
|
+
interface ToolInput {
|
|
4
|
+
tool: string;
|
|
5
|
+
sessionID?: string;
|
|
6
|
+
}
|
|
7
|
+
interface EventInput {
|
|
8
|
+
type: string;
|
|
9
|
+
properties?: {
|
|
10
|
+
info?: {
|
|
11
|
+
id?: string;
|
|
12
|
+
};
|
|
13
|
+
sessionID?: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
interface RequestStartInput {
|
|
17
|
+
sessionID: string;
|
|
18
|
+
}
|
|
19
|
+
interface Options {
|
|
20
|
+
getTodoState: (sessionID: string) => Promise<{
|
|
21
|
+
hasOpenTodos: boolean;
|
|
22
|
+
openCount: number;
|
|
23
|
+
inProgressCount: number;
|
|
24
|
+
pendingCount: number;
|
|
25
|
+
}>;
|
|
26
|
+
shouldInject?: (sessionID: string) => boolean;
|
|
27
|
+
log?: (message: string, meta?: Record<string, unknown>) => void;
|
|
28
|
+
}
|
|
29
|
+
export declare function createTodoHygiene(options: Options): {
|
|
30
|
+
handleRequestStart(input: RequestStartInput): void;
|
|
31
|
+
handleToolExecuteAfter(input: ToolInput, _output?: unknown): Promise<void>;
|
|
32
|
+
getPendingReminder(sessionID: string): string | null;
|
|
33
|
+
handleEvent(event: EventInput): void;
|
|
34
|
+
};
|
|
35
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Plugin } from '@opencode-ai/plugin';
|
|
2
|
+
declare const OhMyOpenCodeLite: Plugin;
|
|
3
|
+
export default OhMyOpenCodeLite;
|
|
4
|
+
export type { AgentName, AgentOverrideConfig, McpName, MultiplexerConfig, MultiplexerLayout, MultiplexerType, PluginConfig, TmuxConfig, TmuxLayout, } from './config';
|
|
5
|
+
export type { RemoteMcpConfig } from './mcp';
|