opencode-dux 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +452 -0
- package/dist/agents/descriptions.d.ts +6 -0
- package/dist/agents/designer.d.ts +2 -0
- package/dist/agents/explorer.d.ts +2 -0
- package/dist/agents/fixer.d.ts +2 -0
- package/dist/agents/index.d.ts +22 -0
- package/dist/agents/interpreter.d.ts +2 -0
- package/dist/agents/librarian.d.ts +2 -0
- package/dist/agents/oracle.d.ts +2 -0
- package/dist/agents/orchestrator.d.ts +27 -0
- package/dist/agents/overrides.d.ts +18 -0
- package/dist/agents/prompt-blocks.d.ts +97 -0
- package/dist/agents/steward.d.ts +3 -0
- package/dist/cli/config-io.d.ts +24 -0
- package/dist/cli/config-manager.d.ts +4 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +1006 -0
- package/dist/cli/install.d.ts +2 -0
- package/dist/cli/mcps.d.ts +13 -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 +137 -0
- package/dist/cli/skills.d.ts +22 -0
- package/dist/cli/system.d.ts +5 -0
- package/dist/cli/types.d.ts +38 -0
- package/dist/config/constants.d.ts +12 -0
- package/dist/config/index.d.ts +4 -0
- package/dist/config/loader.d.ts +40 -0
- package/dist/config/runtime-preset.d.ts +12 -0
- package/dist/config/schema.d.ts +281 -0
- package/dist/config/utils.d.ts +10 -0
- package/dist/discovery/local/types.d.ts +79 -0
- package/dist/discovery/local.d.ts +73 -0
- package/dist/discovery/mcp-servers.d.ts +88 -0
- package/dist/discovery/skills.d.ts +94 -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/context-pressure-reminder/index.d.ts +33 -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 +5 -0
- package/dist/hooks/index.d.ts +14 -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 +31782 -0
- package/dist/mcp/context7.d.ts +6 -0
- package/dist/mcp/grep-app.d.ts +6 -0
- package/dist/mcp/index.d.ts +13 -0
- package/dist/mcp/types.d.ts +12 -0
- package/dist/mcp/websearch.d.ts +9 -0
- package/dist/skills/registry.d.ts +29 -0
- package/dist/subscriptions/accounts-store.d.ts +57 -0
- package/dist/subscriptions/index.d.ts +13 -0
- package/dist/subscriptions/neuralwatt-scraper.d.ts +14 -0
- package/dist/subscriptions/opencode-go-scraper.d.ts +27 -0
- package/dist/subscriptions/types.d.ts +115 -0
- package/dist/subscriptions/usage-service.d.ts +74 -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/delegate.d.ts +14 -0
- package/dist/tools/index.d.ts +5 -0
- package/dist/tools/preset-manager.d.ts +27 -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 +168 -0
- package/dist/tui.d.ts +37 -0
- package/dist/tui.js +1896 -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 +90 -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/index.ts +1 -0
- package/opencode-dux.schema.json +634 -0
- package/package.json +103 -0
- package/src/agents/descriptions.ts +55 -0
- package/src/agents/designer.test.ts +86 -0
- package/src/agents/designer.ts +154 -0
- package/src/agents/display-name.test.ts +186 -0
- package/src/agents/explorer.test.ts +79 -0
- package/src/agents/explorer.ts +144 -0
- package/src/agents/fixer.test.ts +79 -0
- package/src/agents/fixer.ts +145 -0
- package/src/agents/index.test.ts +472 -0
- package/src/agents/index.ts +248 -0
- package/src/agents/interpreter.ts +136 -0
- package/src/agents/librarian.test.ts +80 -0
- package/src/agents/librarian.ts +145 -0
- package/src/agents/oracle.test.ts +89 -0
- package/src/agents/oracle.ts +184 -0
- package/src/agents/orchestrator.test.ts +116 -0
- package/src/agents/orchestrator.ts +574 -0
- package/src/agents/overrides.ts +95 -0
- package/src/agents/prompt-blocks.test.ts +114 -0
- package/src/agents/prompt-blocks.ts +640 -0
- package/src/agents/steward.ts +146 -0
- package/src/cli/config-io.test.ts +536 -0
- package/src/cli/config-io.ts +473 -0
- package/src/cli/config-manager.test.ts +141 -0
- package/src/cli/config-manager.ts +4 -0
- package/src/cli/index.ts +88 -0
- package/src/cli/install.ts +282 -0
- package/src/cli/mcps.test.ts +62 -0
- package/src/cli/mcps.ts +39 -0
- package/src/cli/model-key-normalization.test.ts +21 -0
- package/src/cli/model-key-normalization.ts +60 -0
- package/src/cli/paths.test.ts +167 -0
- package/src/cli/paths.ts +144 -0
- package/src/cli/providers.test.ts +118 -0
- package/src/cli/providers.ts +141 -0
- package/src/cli/skills.test.ts +111 -0
- package/src/cli/skills.ts +103 -0
- package/src/cli/system.test.ts +91 -0
- package/src/cli/system.ts +180 -0
- package/src/cli/types.ts +43 -0
- package/src/config/constants.ts +58 -0
- package/src/config/index.ts +4 -0
- package/src/config/loader.test.ts +1194 -0
- package/src/config/loader.ts +269 -0
- package/src/config/model-resolution.test.ts +176 -0
- package/src/config/runtime-preset.test.ts +61 -0
- package/src/config/runtime-preset.ts +37 -0
- package/src/config/schema.ts +248 -0
- package/src/config/utils.test.ts +41 -0
- package/src/config/utils.ts +23 -0
- package/src/discovery/local/types.ts +85 -0
- package/src/discovery/local.ts +322 -0
- package/src/discovery/mcp-servers.ts +804 -0
- package/src/discovery/skills.ts +959 -0
- package/src/hooks/apply-patch/codec.test.ts +184 -0
- package/src/hooks/apply-patch/codec.ts +352 -0
- package/src/hooks/apply-patch/errors.ts +117 -0
- package/src/hooks/apply-patch/execution-context.ts +432 -0
- package/src/hooks/apply-patch/hook.test.ts +768 -0
- package/src/hooks/apply-patch/index.ts +126 -0
- package/src/hooks/apply-patch/matching.test.ts +215 -0
- package/src/hooks/apply-patch/matching.ts +586 -0
- package/src/hooks/apply-patch/operations.test.ts +1535 -0
- package/src/hooks/apply-patch/operations.ts +3 -0
- package/src/hooks/apply-patch/patch.ts +9 -0
- package/src/hooks/apply-patch/prepared-changes.ts +400 -0
- package/src/hooks/apply-patch/resolution.test.ts +420 -0
- package/src/hooks/apply-patch/resolution.ts +437 -0
- package/src/hooks/apply-patch/rewrite.ts +496 -0
- package/src/hooks/apply-patch/test-helpers.ts +52 -0
- package/src/hooks/apply-patch/types.ts +111 -0
- package/src/hooks/auto-update-checker/cache.test.ts +179 -0
- package/src/hooks/auto-update-checker/cache.ts +188 -0
- package/src/hooks/auto-update-checker/checker.test.ts +159 -0
- package/src/hooks/auto-update-checker/checker.ts +308 -0
- package/src/hooks/auto-update-checker/constants.ts +33 -0
- package/src/hooks/auto-update-checker/index.test.ts +282 -0
- package/src/hooks/auto-update-checker/index.ts +225 -0
- package/src/hooks/auto-update-checker/types.ts +26 -0
- package/src/hooks/chat-headers.test.ts +236 -0
- package/src/hooks/chat-headers.ts +97 -0
- package/src/hooks/context-pressure-reminder/index.test.ts +179 -0
- package/src/hooks/context-pressure-reminder/index.ts +137 -0
- package/src/hooks/delegate-task-retry/guidance.ts +41 -0
- package/src/hooks/delegate-task-retry/hook.ts +23 -0
- package/src/hooks/delegate-task-retry/index.test.ts +38 -0
- package/src/hooks/delegate-task-retry/index.ts +7 -0
- package/src/hooks/delegate-task-retry/patterns.ts +79 -0
- package/src/hooks/filter-available-skills/index.test.ts +297 -0
- package/src/hooks/filter-available-skills/index.ts +160 -0
- package/src/hooks/foreground-fallback/index.test.ts +624 -0
- package/src/hooks/foreground-fallback/index.ts +374 -0
- package/src/hooks/image-hook.ts +6 -0
- package/src/hooks/index.ts +17 -0
- package/src/hooks/json-error-recovery/hook.ts +73 -0
- package/src/hooks/json-error-recovery/index.test.ts +111 -0
- package/src/hooks/json-error-recovery/index.ts +6 -0
- package/src/hooks/phase-reminder/index.test.ts +74 -0
- package/src/hooks/phase-reminder/index.ts +85 -0
- package/src/hooks/post-file-tool-nudge/index.test.ts +94 -0
- package/src/hooks/post-file-tool-nudge/index.ts +63 -0
- package/src/hooks/task-session-manager/index.test.ts +833 -0
- package/src/hooks/task-session-manager/index.ts +434 -0
- package/src/hooks/todo-continuation/index.test.ts +3026 -0
- package/src/hooks/todo-continuation/index.ts +878 -0
- package/src/hooks/todo-continuation/todo-hygiene.test.ts +204 -0
- package/src/hooks/todo-continuation/todo-hygiene.ts +207 -0
- package/src/index.ts +1672 -0
- package/src/mcp/context7.ts +14 -0
- package/src/mcp/grep-app.ts +11 -0
- package/src/mcp/index.test.ts +96 -0
- package/src/mcp/index.ts +66 -0
- package/src/mcp/types.ts +16 -0
- package/src/mcp/websearch.ts +47 -0
- package/src/skills/codemap/README.md +60 -0
- package/src/skills/codemap/SKILL.md +174 -0
- package/src/skills/codemap/scripts/codemap.mjs +483 -0
- package/src/skills/codemap/scripts/codemap.test.ts +129 -0
- package/src/skills/registry.ts +218 -0
- package/src/skills/simplify/README.md +19 -0
- package/src/skills/simplify/SKILL.md +138 -0
- package/src/subscriptions/accounts-store.test.ts +236 -0
- package/src/subscriptions/accounts-store.ts +184 -0
- package/src/subscriptions/index.ts +30 -0
- package/src/subscriptions/neuralwatt-scraper.ts +108 -0
- package/src/subscriptions/opencode-go-scraper.ts +301 -0
- package/src/subscriptions/types.ts +145 -0
- package/src/subscriptions/usage-service.test.ts +202 -0
- package/src/subscriptions/usage-service.ts +651 -0
- package/src/tools/ast-grep/cli.ts +257 -0
- package/src/tools/ast-grep/constants.ts +214 -0
- package/src/tools/ast-grep/downloader.ts +131 -0
- package/src/tools/ast-grep/index.ts +24 -0
- package/src/tools/ast-grep/tools.ts +117 -0
- package/src/tools/ast-grep/types.ts +51 -0
- package/src/tools/ast-grep/utils.ts +126 -0
- package/src/tools/delegate-handoff.test.ts +18 -0
- package/src/tools/delegate.ts +508 -0
- package/src/tools/index.ts +8 -0
- package/src/tools/preset-manager.test.ts +795 -0
- package/src/tools/preset-manager.ts +332 -0
- package/src/tools/smartfetch/binary.ts +58 -0
- package/src/tools/smartfetch/cache.test.ts +34 -0
- package/src/tools/smartfetch/cache.ts +112 -0
- package/src/tools/smartfetch/constants.ts +29 -0
- package/src/tools/smartfetch/index.ts +8 -0
- package/src/tools/smartfetch/network.test.ts +178 -0
- package/src/tools/smartfetch/network.ts +614 -0
- package/src/tools/smartfetch/secondary-model.test.ts +85 -0
- package/src/tools/smartfetch/secondary-model.ts +276 -0
- package/src/tools/smartfetch/tool.test.ts +60 -0
- package/src/tools/smartfetch/tool.ts +832 -0
- package/src/tools/smartfetch/types.ts +135 -0
- package/src/tools/smartfetch/utils.test.ts +24 -0
- package/src/tools/smartfetch/utils.ts +456 -0
- package/src/tui-state.test.ts +867 -0
- package/src/tui-state.ts +1255 -0
- package/src/tui.test.ts +336 -0
- package/src/tui.ts +1539 -0
- package/src/utils/agent-variant.test.ts +244 -0
- package/src/utils/agent-variant.ts +187 -0
- package/src/utils/compat.ts +91 -0
- package/src/utils/env.ts +12 -0
- package/src/utils/index.ts +9 -0
- package/src/utils/internal-initiator.ts +28 -0
- package/src/utils/logger.test.ts +220 -0
- package/src/utils/logger.ts +136 -0
- package/src/utils/polling.test.ts +191 -0
- package/src/utils/polling.ts +67 -0
- package/src/utils/session-manager.test.ts +173 -0
- package/src/utils/session-manager.ts +356 -0
- package/src/utils/session.test.ts +110 -0
- package/src/utils/session.ts +389 -0
- package/src/utils/subagent-depth.test.ts +170 -0
- package/src/utils/subagent-depth.ts +75 -0
- package/src/utils/system-collapse.test.ts +86 -0
- package/src/utils/system-collapse.ts +24 -0
- package/src/utils/task.test.ts +24 -0
- package/src/utils/task.ts +20 -0
- package/src/utils/zip-extractor.ts +102 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RemoteMcpConfig } from './types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Context7 - official documentation lookup for libraries
|
|
5
|
+
* @see https://context7.com
|
|
6
|
+
*/
|
|
7
|
+
export const context7: RemoteMcpConfig = {
|
|
8
|
+
type: 'remote',
|
|
9
|
+
url: 'https://mcp.context7.com/mcp',
|
|
10
|
+
headers: process.env.CONTEXT7_API_KEY
|
|
11
|
+
? { CONTEXT7_API_KEY: process.env.CONTEXT7_API_KEY }
|
|
12
|
+
: undefined,
|
|
13
|
+
oauth: false,
|
|
14
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RemoteMcpConfig } from './types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* grep.app - ultra-fast code search across GitHub repositories
|
|
5
|
+
* @see https://grep.app
|
|
6
|
+
*/
|
|
7
|
+
export const grep_app: RemoteMcpConfig = {
|
|
8
|
+
type: 'remote',
|
|
9
|
+
url: 'https://mcp.grep.app',
|
|
10
|
+
oauth: false,
|
|
11
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
import { createBuiltinMcps } from './index';
|
|
3
|
+
|
|
4
|
+
describe('createBuiltinMcps', () => {
|
|
5
|
+
test('returns all MCPs when no disabled list provided', () => {
|
|
6
|
+
const mcps = createBuiltinMcps();
|
|
7
|
+
const names = Object.keys(mcps);
|
|
8
|
+
|
|
9
|
+
expect(names).toContain('websearch');
|
|
10
|
+
expect(names).toContain('context7');
|
|
11
|
+
expect(names).toContain('grep_app');
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test('returns all MCPs with empty disabled list', () => {
|
|
15
|
+
const mcps = createBuiltinMcps([]);
|
|
16
|
+
const names = Object.keys(mcps);
|
|
17
|
+
|
|
18
|
+
expect(names.length).toBe(3);
|
|
19
|
+
expect(names).toContain('websearch');
|
|
20
|
+
expect(names).toContain('context7');
|
|
21
|
+
expect(names).toContain('grep_app');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('excludes single disabled MCP', () => {
|
|
25
|
+
const mcps = createBuiltinMcps(['websearch']);
|
|
26
|
+
const names = Object.keys(mcps);
|
|
27
|
+
|
|
28
|
+
expect(names).not.toContain('websearch');
|
|
29
|
+
expect(names).toContain('context7');
|
|
30
|
+
expect(names).toContain('grep_app');
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('excludes multiple disabled MCPs', () => {
|
|
34
|
+
const mcps = createBuiltinMcps(['websearch', 'grep_app']);
|
|
35
|
+
const names = Object.keys(mcps);
|
|
36
|
+
|
|
37
|
+
expect(names).not.toContain('websearch');
|
|
38
|
+
expect(names).not.toContain('grep_app');
|
|
39
|
+
expect(names).toContain('context7');
|
|
40
|
+
expect(names.length).toBe(1);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('excludes all MCPs when all disabled', () => {
|
|
44
|
+
const mcps = createBuiltinMcps(['websearch', 'context7', 'grep_app']);
|
|
45
|
+
const names = Object.keys(mcps);
|
|
46
|
+
|
|
47
|
+
expect(names.length).toBe(0);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test('ignores unknown MCP names in disabled list', () => {
|
|
51
|
+
const mcps = createBuiltinMcps(['unknown_mcp', 'nonexistent']);
|
|
52
|
+
const names = Object.keys(mcps);
|
|
53
|
+
|
|
54
|
+
// All valid MCPs should still be present
|
|
55
|
+
expect(names.length).toBe(3);
|
|
56
|
+
expect(names).toContain('websearch');
|
|
57
|
+
expect(names).toContain('context7');
|
|
58
|
+
expect(names).toContain('grep_app');
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('MCP configs have required properties', () => {
|
|
62
|
+
const mcps = createBuiltinMcps();
|
|
63
|
+
|
|
64
|
+
for (const [_name, config] of Object.entries(mcps)) {
|
|
65
|
+
expect(config).toBeDefined();
|
|
66
|
+
// Each MCP should have either url (remote) or command (local)
|
|
67
|
+
const hasUrl = 'url' in config;
|
|
68
|
+
const hasCommand = 'command' in config;
|
|
69
|
+
expect(hasUrl || hasCommand).toBe(true);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test('websearch MCP has correct structure', () => {
|
|
74
|
+
const mcps = createBuiltinMcps();
|
|
75
|
+
const websearch = mcps.websearch;
|
|
76
|
+
|
|
77
|
+
expect(websearch).toBeDefined();
|
|
78
|
+
expect('url' in websearch).toBe(true);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
test('context7 MCP has correct structure', () => {
|
|
82
|
+
const mcps = createBuiltinMcps();
|
|
83
|
+
const context7 = mcps.context7;
|
|
84
|
+
|
|
85
|
+
expect(context7).toBeDefined();
|
|
86
|
+
expect('url' in context7).toBe(true);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test('grep_app MCP has correct structure', () => {
|
|
90
|
+
const mcps = createBuiltinMcps();
|
|
91
|
+
const grep_app = mcps.grep_app;
|
|
92
|
+
|
|
93
|
+
expect(grep_app).toBeDefined();
|
|
94
|
+
expect('url' in grep_app).toBe(true);
|
|
95
|
+
});
|
|
96
|
+
});
|
package/src/mcp/index.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { McpName, WebsearchConfig } from '../config';
|
|
2
|
+
import { context7 } from './context7';
|
|
3
|
+
import { grep_app } from './grep-app';
|
|
4
|
+
import type { McpConfig } from './types';
|
|
5
|
+
import { createWebsearchConfig, websearch } from './websearch';
|
|
6
|
+
|
|
7
|
+
export type { LocalMcpConfig, McpConfig, RemoteMcpConfig } from './types';
|
|
8
|
+
|
|
9
|
+
const allBuiltinMcps: Record<McpName, McpConfig> = {
|
|
10
|
+
websearch,
|
|
11
|
+
context7,
|
|
12
|
+
grep_app,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Creates MCP configurations, excluding disabled ones.
|
|
17
|
+
* Accepts an optional websearchConfig to override the default Exa provider.
|
|
18
|
+
*/
|
|
19
|
+
export function createBuiltinMcps(
|
|
20
|
+
disabledMcps: readonly string[] = [],
|
|
21
|
+
websearchConfig?: WebsearchConfig,
|
|
22
|
+
): Record<string, McpConfig> {
|
|
23
|
+
const mcps = Object.fromEntries(
|
|
24
|
+
Object.entries(allBuiltinMcps).filter(
|
|
25
|
+
([name]) => !disabledMcps.includes(name),
|
|
26
|
+
),
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
// Override websearch with user-configured provider (default: Exa)
|
|
30
|
+
if (!disabledMcps.includes('websearch')) {
|
|
31
|
+
mcps.websearch = createWebsearchConfig(websearchConfig);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return mcps;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Filter MCP configs for a specific agent based on its MCP permissions.
|
|
39
|
+
* When no permission rules exist, all MCPs are available.
|
|
40
|
+
*/
|
|
41
|
+
export function filterMcpsForAgent(
|
|
42
|
+
allMcps: Record<string, McpConfig>,
|
|
43
|
+
_agentName: string,
|
|
44
|
+
mcpPermissionRules?: Record<string, 'allow' | 'ask' | 'deny'>,
|
|
45
|
+
): Record<string, McpConfig> {
|
|
46
|
+
if (!mcpPermissionRules) {
|
|
47
|
+
return allMcps; // all allowed
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const hasWildcard = mcpPermissionRules['*'] === 'allow';
|
|
51
|
+
const filtered: Record<string, McpConfig> = {};
|
|
52
|
+
|
|
53
|
+
for (const [name, config] of Object.entries(allMcps)) {
|
|
54
|
+
const specific = mcpPermissionRules[name];
|
|
55
|
+
if (specific === 'allow') {
|
|
56
|
+
filtered[name] = config;
|
|
57
|
+
} else if (specific === 'deny') {
|
|
58
|
+
} else if (hasWildcard) {
|
|
59
|
+
// No specific rule and wildcard is active → include
|
|
60
|
+
filtered[name] = config;
|
|
61
|
+
}
|
|
62
|
+
// else: no wildcard and no specific rule → exclude
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return filtered;
|
|
66
|
+
}
|
package/src/mcp/types.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// MCP types - McpName is defined in config/schema.ts to avoid duplication
|
|
2
|
+
|
|
3
|
+
export type RemoteMcpConfig = {
|
|
4
|
+
type: 'remote';
|
|
5
|
+
url: string;
|
|
6
|
+
headers?: Record<string, string>;
|
|
7
|
+
oauth?: false;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type LocalMcpConfig = {
|
|
11
|
+
type: 'local';
|
|
12
|
+
command: string[];
|
|
13
|
+
environment?: Record<string, string>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type McpConfig = RemoteMcpConfig | LocalMcpConfig;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { WebsearchConfig } from '../config';
|
|
2
|
+
import type { RemoteMcpConfig } from './types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Creates a websearch MCP config based on the provided configuration.
|
|
6
|
+
* Supports Exa (default) and Tavily providers.
|
|
7
|
+
* @see https://exa.ai @see https://tavily.com
|
|
8
|
+
*/
|
|
9
|
+
export function createWebsearchConfig(
|
|
10
|
+
config?: WebsearchConfig,
|
|
11
|
+
): RemoteMcpConfig {
|
|
12
|
+
const provider = config?.provider || 'exa';
|
|
13
|
+
|
|
14
|
+
if (provider === 'tavily') {
|
|
15
|
+
const tavilyKey = process.env.TAVILY_API_KEY;
|
|
16
|
+
if (!tavilyKey) {
|
|
17
|
+
throw new Error(
|
|
18
|
+
'TAVILY_API_KEY environment variable is required for Tavily provider',
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
type: 'remote',
|
|
23
|
+
url: 'https://mcp.tavily.com/mcp/',
|
|
24
|
+
headers: {
|
|
25
|
+
Authorization: `Bearer ${tavilyKey}`,
|
|
26
|
+
},
|
|
27
|
+
oauth: false,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Default: Exa provider
|
|
32
|
+
// Prefer exaApiKey in URL (reliably validated by Exa MCP endpoint)
|
|
33
|
+
// Fall back to anonymous access when no key is available
|
|
34
|
+
const exaKey = process.env.EXA_API_KEY;
|
|
35
|
+
const exaUrl = exaKey
|
|
36
|
+
? `https://mcp.exa.ai/mcp?tools=web_search_exa&exaApiKey=${encodeURIComponent(exaKey)}`
|
|
37
|
+
: 'https://mcp.exa.ai/mcp?tools=web_search_exa';
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
type: 'remote',
|
|
41
|
+
url: exaUrl,
|
|
42
|
+
oauth: false,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Backward compatibility: default export using default (Exa) config
|
|
47
|
+
export const websearch: RemoteMcpConfig = createWebsearchConfig();
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Codemap Skill
|
|
2
|
+
|
|
3
|
+
Repository understanding and hierarchical codemap generation.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Codemap helps orchestrators map and understand codebases by:
|
|
8
|
+
|
|
9
|
+
1. Selecting relevant code/config files using LLM judgment
|
|
10
|
+
2. Creating `.slim/codemap.json` for change tracking
|
|
11
|
+
3. Generating empty `codemap.md` templates for fixers to fill in
|
|
12
|
+
|
|
13
|
+
Legacy `.slim/cartography.json` state is migrated to `.slim/codemap.json` automatically.
|
|
14
|
+
|
|
15
|
+
## Commands
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Initialize mapping
|
|
19
|
+
node codemap.mjs init --root /repo --include "src/**/*.ts" --exclude "node_modules/**"
|
|
20
|
+
|
|
21
|
+
# Check what changed
|
|
22
|
+
node codemap.mjs changes --root /repo
|
|
23
|
+
|
|
24
|
+
# Update hashes
|
|
25
|
+
node codemap.mjs update --root /repo
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Outputs
|
|
29
|
+
|
|
30
|
+
### .slim/codemap.json
|
|
31
|
+
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"metadata": {
|
|
35
|
+
"version": "1.0.0",
|
|
36
|
+
"last_run": "2026-01-25T19:00:00Z",
|
|
37
|
+
"include_patterns": ["src/**/*.ts"],
|
|
38
|
+
"exclude_patterns": ["node_modules/**"]
|
|
39
|
+
},
|
|
40
|
+
"file_hashes": {
|
|
41
|
+
"src/index.ts": "abc123..."
|
|
42
|
+
},
|
|
43
|
+
"folder_hashes": {
|
|
44
|
+
"src": "def456..."
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### codemap.md (per folder)
|
|
50
|
+
|
|
51
|
+
Empty templates created in each folder for fixers to fill with:
|
|
52
|
+
- Responsibility
|
|
53
|
+
- Design patterns
|
|
54
|
+
- Data/control flow
|
|
55
|
+
- Integration points
|
|
56
|
+
|
|
57
|
+
## Installation
|
|
58
|
+
|
|
59
|
+
Bundled with `opencode-dux` and auto-scanned on plugin init. The plugin
|
|
60
|
+
registers it automatically; no manual installation needed.
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: codemap
|
|
3
|
+
description: Generate comprehensive hierarchical codemaps for UNFAMILIAR repositories. Expensive operation - only use when explicitly asked for codebase documentation or initial repository mapping
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Codemap Skill
|
|
7
|
+
|
|
8
|
+
You help users understand and map repositories by creating hierarchical codemaps.
|
|
9
|
+
|
|
10
|
+
## When to Use
|
|
11
|
+
|
|
12
|
+
- User asks to understand/map a repository
|
|
13
|
+
- User wants codebase documentation
|
|
14
|
+
- Starting work on an unfamiliar codebase
|
|
15
|
+
|
|
16
|
+
## Workflow
|
|
17
|
+
|
|
18
|
+
### Step 1: Check for Existing State
|
|
19
|
+
|
|
20
|
+
**First, check if `.slim/codemap.json` exists in the repo root.**
|
|
21
|
+
|
|
22
|
+
If it does not exist, check for legacy state at `.slim/cartography.json`.
|
|
23
|
+
|
|
24
|
+
If legacy state exists: move `.slim/cartography.json` to `.slim/codemap.json`, then continue with change detection.
|
|
25
|
+
|
|
26
|
+
If `.slim/codemap.json` exists: Skip to Step 3 (Detect Changes) - no need to re-initialize.
|
|
27
|
+
|
|
28
|
+
If neither file exists: Continue to Step 2 (Initialize).
|
|
29
|
+
|
|
30
|
+
### Step 2: Initialize (Only if no state exists)
|
|
31
|
+
|
|
32
|
+
1. **Analyze the repository structure** - List files, understand directories
|
|
33
|
+
2. **Infer patterns** for **core code/config files ONLY** to include:
|
|
34
|
+
- **Include**: `src/**/*.ts`, `package.json`, etc.
|
|
35
|
+
- **Exclude (MANDATORY)**: Do NOT include tests, documentation, or translations.
|
|
36
|
+
- Tests: `**/*.test.ts`, `**/*.spec.ts`, `tests/**`, `__tests__/**`
|
|
37
|
+
- Docs: `docs/**`, `*.md` (except root `README.md` if needed), `LICENSE`
|
|
38
|
+
- Build/Deps: `node_modules/**`, `dist/**`, `build/**`, `*.min.js`
|
|
39
|
+
- Respect `.gitignore` automatically
|
|
40
|
+
3. **Run codemap.mjs init**:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
node ~/.config/opencode/skills/codemap/scripts/codemap.mjs init \
|
|
44
|
+
--root ./ \
|
|
45
|
+
--include "src/**/*.ts" \
|
|
46
|
+
--exclude "**/*.test.ts" --exclude "dist/**" --exclude "node_modules/**"
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
This creates:
|
|
50
|
+
|
|
51
|
+
- `.slim/codemap.json` - File and folder hashes for change detection
|
|
52
|
+
- Empty `codemap.md` files in all relevant subdirectories
|
|
53
|
+
|
|
54
|
+
4. **Delegate codemap writing to Fixer agents** - Spawn one fixer per folder to read code and create or update its specific `codemap.md` file.
|
|
55
|
+
|
|
56
|
+
### Step 3: Detect Changes (If state already exists)
|
|
57
|
+
|
|
58
|
+
1. **Run codemap.mjs changes** to see what changed:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
node ~/.config/opencode/skills/codemap/scripts/codemap.mjs changes \
|
|
62
|
+
--root ./
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
2. **Review the output** - It shows:
|
|
66
|
+
|
|
67
|
+
- Added files
|
|
68
|
+
- Removed files
|
|
69
|
+
- Modified files
|
|
70
|
+
- Affected folders
|
|
71
|
+
|
|
72
|
+
3. **Only update affected codemaps** - Spawn one fixer per affected folder to update its `codemap.md`.
|
|
73
|
+
4. **Run update** to save new state:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
node ~/.config/opencode/skills/codemap/scripts/codemap.mjs update \
|
|
77
|
+
--root ./
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Step 4: Finalize Repository Atlas (Root Codemap)
|
|
81
|
+
|
|
82
|
+
Once all specific directories are mapped, the Orchestrator must create or update the root `codemap.md`. This file serves as the **Master Entry Point** for any agent or human entering the repository.
|
|
83
|
+
|
|
84
|
+
1. **Map Root Assets**: Document the root-level files (e.g., `package.json`, `index.ts`, `plugin.json`) and the project's overall purpose.
|
|
85
|
+
2. **Aggregate Sub-Maps**: Create a "Repository Directory Map" section. For every folder that has a `codemap.md`, extract its **Responsibility** summary and include it in a table or list in the root map.
|
|
86
|
+
3. **Cross-Reference**: Ensure that the root map contains the absolute or relative paths to the sub-maps so agents can jump directly to the relevant details.
|
|
87
|
+
|
|
88
|
+
### Step 5: Register Codemap in AGENTS.md
|
|
89
|
+
|
|
90
|
+
**OpenCode auto-loads `AGENTS.md` into agent context on every session.** To ensure agents automatically discover and use the codemap, update (or create) `AGENTS.md` at the repo root:
|
|
91
|
+
|
|
92
|
+
1. If `AGENTS.md` already exists and already contains a `## Repository Map` section, **skip this step** - the reference is already set up.
|
|
93
|
+
2. If `AGENTS.md` exists but has no `## Repository Map` section, **append** the section below.
|
|
94
|
+
3. If `AGENTS.md` doesn't exist, **create** it with the section below.
|
|
95
|
+
|
|
96
|
+
```markdown
|
|
97
|
+
## Repository Map
|
|
98
|
+
|
|
99
|
+
A full codemap is available at `codemap.md` in the project root.
|
|
100
|
+
|
|
101
|
+
Before working on any task, read `codemap.md` to understand:
|
|
102
|
+
|
|
103
|
+
- Project architecture and entry points
|
|
104
|
+
- Directory responsibilities and design patterns
|
|
105
|
+
- Data flow and integration points between modules
|
|
106
|
+
|
|
107
|
+
For deep work on a specific folder, also read that folder's `codemap.md`.
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
This is idempotent - repeated codemap runs will detect the existing section and skip. No duplication.
|
|
111
|
+
|
|
112
|
+
## Codemap Content
|
|
113
|
+
|
|
114
|
+
Fixers are responsible for writing `codemap.md` files during this workflow. Use precise technical terminology to document the implementation:
|
|
115
|
+
|
|
116
|
+
- **Responsibility** - Define the specific role of this directory using standard software engineering terms (e.g., "Service Layer", "Data Access Object", "Middleware").
|
|
117
|
+
- **Design Patterns** - Identify and name specific patterns used (e.g., "Observer", "Singleton", "Factory", "Strategy"). Detail the abstractions and interfaces.
|
|
118
|
+
- **Data & Control Flow** - Explicitly trace how data enters and leaves the module. Mention specific function call sequences and state transitions.
|
|
119
|
+
- **Integration Points** - List dependencies and consumer modules. Use technical names for hooks, events, or API endpoints.
|
|
120
|
+
|
|
121
|
+
Example codemap:
|
|
122
|
+
|
|
123
|
+
```markdown
|
|
124
|
+
# src/agents/
|
|
125
|
+
|
|
126
|
+
## Responsibility
|
|
127
|
+
|
|
128
|
+
Defines agent personalities and manages their configuration lifecycle.
|
|
129
|
+
|
|
130
|
+
## Design
|
|
131
|
+
|
|
132
|
+
Each agent is a prompt + permission set. Config system uses:
|
|
133
|
+
|
|
134
|
+
- Default prompts (orchestrator.ts, explorer.ts, etc.)
|
|
135
|
+
- User overrides from ~/.config/opencode/opencode-dux.json
|
|
136
|
+
- Permission wildcards for skill/MCP access control
|
|
137
|
+
|
|
138
|
+
## Flow
|
|
139
|
+
|
|
140
|
+
1. Plugin loads → calls getAgentConfigs()
|
|
141
|
+
2. Reads user config preset
|
|
142
|
+
3. Merges defaults with overrides
|
|
143
|
+
4. Applies permission rules (wildcard expansion)
|
|
144
|
+
5. Returns agent configs to OpenCode
|
|
145
|
+
|
|
146
|
+
## Integration
|
|
147
|
+
|
|
148
|
+
- Consumed by: Main plugin (src/index.ts)
|
|
149
|
+
- Depends on: Config loader, skills registry
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Example **Root Codemap (Atlas)**:
|
|
153
|
+
|
|
154
|
+
```markdown
|
|
155
|
+
# Repository Atlas: opencode-dux
|
|
156
|
+
|
|
157
|
+
## Project Responsibility
|
|
158
|
+
|
|
159
|
+
A high-performance, low-latency agent orchestration plugin for OpenCode, focusing on specialized sub-agent delegation and multiplexer-assisted child sessions.
|
|
160
|
+
|
|
161
|
+
## System Entry Points
|
|
162
|
+
|
|
163
|
+
- `src/index.ts`: Plugin initialization and OpenCode integration.
|
|
164
|
+
- `package.json`: Dependency manifest and build scripts.
|
|
165
|
+
- `opencode-dux.json`: User configuration schema.
|
|
166
|
+
|
|
167
|
+
## Directory Map (Aggregated)
|
|
168
|
+
|
|
169
|
+
| Directory | Responsibility Summary | Detailed Map |
|
|
170
|
+
| --------------- | --------------------------------------------------------------------------------- | ----------------------------------- |
|
|
171
|
+
| `src/agents/` | Defines agent personalities (Orchestrator, Explorer) and manages model routing. | [View Map](src/agents/codemap.md) |
|
|
172
|
+
| `src/features/` | Core logic for tmux integration and session state. | [View Map](src/features/codemap.md) |
|
|
173
|
+
| `src/config/` | Implements the configuration loading pipeline and environment variable injection. | [View Map](src/config/codemap.md) |
|
|
174
|
+
```
|