opencode-ask-agent 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 +124 -0
- package/agents/ask.md +84 -0
- package/dist/cli/index.js +362 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/index.d.mts +111 -0
- package/dist/index.d.ts +111 -0
- package/dist/index.js +178 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +145 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +58 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Israel Toledo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# opencode-ask-agent
|
|
2
|
+
|
|
3
|
+
A read-only **Ask** agent for [OpenCode](https://opencode.ai) with integrated web research capabilities. Perfect for codebase exploration, Q&A, and brainstorming.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Read-only access** - Safely explore code without modifications
|
|
8
|
+
- **Context7** - Official documentation lookup
|
|
9
|
+
- **Grep.app** - Search real-world GitHub code
|
|
10
|
+
- **Exa WebSearch** - Real-time web search (optional API key)
|
|
11
|
+
- **Brainstorming** - Ideation and solution exploration
|
|
12
|
+
|
|
13
|
+
## Quick Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx opencode-ask-agent
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
This will:
|
|
20
|
+
|
|
21
|
+
1. Add `opencode-ask-agent` to your OpenCode plugins
|
|
22
|
+
2. Configure the included MCP servers (context7, grep-app, websearch)
|
|
23
|
+
3. Optionally set up your Exa API key for enhanced web search
|
|
24
|
+
|
|
25
|
+
## Manual Install
|
|
26
|
+
|
|
27
|
+
Add to your `~/.config/opencode/opencode.json`:
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"plugin": ["opencode-ask-agent"]
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Exa WebSearch Setup (Optional)
|
|
36
|
+
|
|
37
|
+
For enhanced web search capabilities, get a free API key:
|
|
38
|
+
|
|
39
|
+
1. Visit https://dashboard.exa.ai/api-keys
|
|
40
|
+
2. Create an API key
|
|
41
|
+
3. Add to your environment:
|
|
42
|
+
```bash
|
|
43
|
+
# Add to ~/.bashrc, ~/.zshrc, or equivalent
|
|
44
|
+
export EXA_API_KEY="your-key-here"
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Usage
|
|
48
|
+
|
|
49
|
+
After installation, restart OpenCode and press **Tab** to switch to the Ask agent.
|
|
50
|
+
|
|
51
|
+
### Example Prompts
|
|
52
|
+
|
|
53
|
+
**Code Analysis:**
|
|
54
|
+
|
|
55
|
+
- "Explain how authentication works in this project"
|
|
56
|
+
- "What does the `processPayment` function do?"
|
|
57
|
+
- "Trace the data flow from API request to database"
|
|
58
|
+
|
|
59
|
+
**Documentation Lookup:**
|
|
60
|
+
|
|
61
|
+
- "Show me the React Query documentation for mutations"
|
|
62
|
+
- "What are the options for Next.js middleware?"
|
|
63
|
+
|
|
64
|
+
**GitHub Code Search:**
|
|
65
|
+
|
|
66
|
+
- "Search GitHub for examples of rate limiting in Express"
|
|
67
|
+
- "Find production examples of WebSocket reconnection logic"
|
|
68
|
+
|
|
69
|
+
**Web Research:**
|
|
70
|
+
|
|
71
|
+
- "What's the best practice for handling errors in React Query?"
|
|
72
|
+
- "Latest recommendations for Next.js 14 caching"
|
|
73
|
+
|
|
74
|
+
**Brainstorming:**
|
|
75
|
+
|
|
76
|
+
- "Let's brainstorm approaches for implementing caching"
|
|
77
|
+
- "What are some ways to improve the performance of this API?"
|
|
78
|
+
- "Help me think through the architecture for a notification system"
|
|
79
|
+
|
|
80
|
+
## What's Included
|
|
81
|
+
|
|
82
|
+
### Ask Agent
|
|
83
|
+
|
|
84
|
+
A read-only agent focused on:
|
|
85
|
+
|
|
86
|
+
- Codebase exploration and analysis
|
|
87
|
+
- Documentation and research
|
|
88
|
+
- Brainstorming and ideation
|
|
89
|
+
|
|
90
|
+
**Configuration:**
|
|
91
|
+
|
|
92
|
+
- Mode: `primary` (appears in Tab selector)
|
|
93
|
+
- Temperature: `0.6` (balanced for creativity)
|
|
94
|
+
- Allowed tools: `read`, `glob`, `grep`, `webfetch`
|
|
95
|
+
- Denied tools: `write`, `edit`, `bash`, `task`
|
|
96
|
+
|
|
97
|
+
### MCP Servers
|
|
98
|
+
|
|
99
|
+
| Server | Description |
|
|
100
|
+
| ----------- | ---------------------------------------------------------- |
|
|
101
|
+
| `context7` | Official documentation lookup for libraries and frameworks |
|
|
102
|
+
| `grep-app` | GitHub code search for real-world implementation examples |
|
|
103
|
+
| `websearch` | Exa-powered web search for current articles and tutorials |
|
|
104
|
+
|
|
105
|
+
## Development
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
# Clone the repository
|
|
109
|
+
git clone https://github.com/israeltoledo/opencode-ask-agent.git
|
|
110
|
+
cd opencode-ask-agent
|
|
111
|
+
|
|
112
|
+
# Install dependencies
|
|
113
|
+
npm install
|
|
114
|
+
|
|
115
|
+
# Build
|
|
116
|
+
npm run build
|
|
117
|
+
|
|
118
|
+
# Type check
|
|
119
|
+
npm run typecheck
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## License
|
|
123
|
+
|
|
124
|
+
MIT
|
package/agents/ask.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Answers questions about your codebase, provides insights based on code analysis, and brainstorm ideas with the user
|
|
3
|
+
mode: primary
|
|
4
|
+
temperature: 0.6
|
|
5
|
+
tools:
|
|
6
|
+
read: true
|
|
7
|
+
glob: true
|
|
8
|
+
grep: true
|
|
9
|
+
webfetch: true
|
|
10
|
+
write: false
|
|
11
|
+
edit: false
|
|
12
|
+
bash: false
|
|
13
|
+
task: false
|
|
14
|
+
permission:
|
|
15
|
+
write: deny
|
|
16
|
+
edit: deny
|
|
17
|
+
bash: deny
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
You are a read-only code analyst and research assistant with brainstorming capabilities. Your purpose is to help users understand their codebase, find information, and explore ideas through collaborative discussion.
|
|
21
|
+
|
|
22
|
+
## Core Principles
|
|
23
|
+
|
|
24
|
+
- **Read-only**: You can only read files, search, and fetch web content. You cannot modify files, execute commands, or write new files.
|
|
25
|
+
- **Scope awareness**: Always respect the user's current working directory. If you need to access files outside the current scope, explicitly ask for permission first, you can always access files within or under the current scope.
|
|
26
|
+
- **Accuracy over speed**: Provide well-researched, accurate answers based on actual code content and documentation.
|
|
27
|
+
- **Web-enabled**: Use web search and fetch tools to find relevant documentation, best practices, and up-to-date information.
|
|
28
|
+
- **Creative collaboration**: When brainstorming, think creatively, suggest multiple approaches, and engage in dialogue to explore ideas thoroughly.
|
|
29
|
+
|
|
30
|
+
## Capabilities
|
|
31
|
+
|
|
32
|
+
1. **Codebase exploration**: Read files, search for patterns, explore project structure
|
|
33
|
+
2. **Code analysis**: Explain code logic, identify patterns, trace dependencies
|
|
34
|
+
3. **Web research**: Search the web for documentation, examples, and best practices
|
|
35
|
+
4. **Documentation lookup**: Fetch and synthesize information from official docs
|
|
36
|
+
5. **Brainstorming**: Discuss ideas, suggest features, explore alternatives, and collaborate on solutions
|
|
37
|
+
|
|
38
|
+
## External MCP Servers
|
|
39
|
+
|
|
40
|
+
- **websearch (Exa)**: Real-time web search. Use for current articles, discussions, tutorials, and bleeding-edge information.
|
|
41
|
+
- **context7**: Official documentation lookup. Use for authoritative API references and framework docs.
|
|
42
|
+
- **grep-app**: GitHub code search. Use for production-ready implementation patterns and real-world examples.
|
|
43
|
+
|
|
44
|
+
## Core Principles
|
|
45
|
+
|
|
46
|
+
- **Current project scope**: You can freely read files within the current working directory
|
|
47
|
+
- **Outside scope**: If you need to access files outside the current project (e.g., user home, other projects), you MUST ask the user first:
|
|
48
|
+
- "I need to access [path] which is outside the current project. May I proceed?"
|
|
49
|
+
- Only access external files after explicit user confirmation
|
|
50
|
+
|
|
51
|
+
## Workflow
|
|
52
|
+
|
|
53
|
+
1. **Understand the question**: Clarify what the user is asking if needed
|
|
54
|
+
2. **Identify the approach**: Determine if this is code analysis, research, or brainstorming
|
|
55
|
+
3. **Explore/research**: Use glob, grep, and MCP tools as appropriate
|
|
56
|
+
4. **Read and analyze**: Read the most important files for context
|
|
57
|
+
5. **Synthesize**: Provide a clear, actionable answer
|
|
58
|
+
|
|
59
|
+
**For brainstorming specifically**:
|
|
60
|
+
|
|
61
|
+
- Acknowledge the idea or problem
|
|
62
|
+
- Ask clarifying questions to understand goals and constraints
|
|
63
|
+
- Suggest multiple approaches with trade-offs
|
|
64
|
+
- Explore alternatives together
|
|
65
|
+
- Help refine and prioritize ideas
|
|
66
|
+
|
|
67
|
+
## Response Guidelines
|
|
68
|
+
|
|
69
|
+
- Be concise but thorough
|
|
70
|
+
- Include relevant code snippets when helpful
|
|
71
|
+
- Reference specific file paths and line numbers (e.g., `src/utils.ts:42`)
|
|
72
|
+
- Suggest related files or areas to explore if relevant
|
|
73
|
+
- If you cannot answer with certainty, say so and suggest alternatives
|
|
74
|
+
|
|
75
|
+
## Limitations
|
|
76
|
+
|
|
77
|
+
If the user asks you to:
|
|
78
|
+
|
|
79
|
+
- Modify files
|
|
80
|
+
- Run commands
|
|
81
|
+
- Create new files
|
|
82
|
+
- Execute code
|
|
83
|
+
|
|
84
|
+
Politely explain that you are a read-only agent and suggest they switch to the Build or Plan agent for those tasks.
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
10
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
|
|
29
|
+
// package.json
|
|
30
|
+
var require_package = __commonJS({
|
|
31
|
+
"package.json"(exports2, module2) {
|
|
32
|
+
module2.exports = {
|
|
33
|
+
name: "opencode-ask-agent",
|
|
34
|
+
version: "1.0.0",
|
|
35
|
+
description: "Read-only Ask agent for OpenCode with web research capabilities",
|
|
36
|
+
main: "dist/index.js",
|
|
37
|
+
module: "dist/index.mjs",
|
|
38
|
+
types: "dist/index.d.ts",
|
|
39
|
+
bin: {
|
|
40
|
+
"opencode-ask-agent": "./dist/cli/index.js"
|
|
41
|
+
},
|
|
42
|
+
scripts: {
|
|
43
|
+
build: "tsup",
|
|
44
|
+
dev: "tsup --watch",
|
|
45
|
+
typecheck: "tsc --noEmit",
|
|
46
|
+
prepublishOnly: "npm run build"
|
|
47
|
+
},
|
|
48
|
+
keywords: [
|
|
49
|
+
"opencode",
|
|
50
|
+
"agent",
|
|
51
|
+
"mcp",
|
|
52
|
+
"ai",
|
|
53
|
+
"code-analysis",
|
|
54
|
+
"research",
|
|
55
|
+
"brainstorming"
|
|
56
|
+
],
|
|
57
|
+
author: "Israel Toledo",
|
|
58
|
+
license: "MIT",
|
|
59
|
+
repository: {
|
|
60
|
+
type: "git",
|
|
61
|
+
url: "git+https://github.com/israeltoledo/opencode-ask-agent.git"
|
|
62
|
+
},
|
|
63
|
+
bugs: {
|
|
64
|
+
url: "https://github.com/israeltoledo/opencode-ask-agent/issues"
|
|
65
|
+
},
|
|
66
|
+
homepage: "https://github.com/israeltoledo/opencode-ask-agent#readme",
|
|
67
|
+
peerDependencies: {
|
|
68
|
+
"@opencode-ai/plugin": "^1.0.0"
|
|
69
|
+
},
|
|
70
|
+
devDependencies: {
|
|
71
|
+
"@opencode-ai/plugin": "^1.1.20",
|
|
72
|
+
"@types/node": "^22.0.0",
|
|
73
|
+
tsup: "^8.0.0",
|
|
74
|
+
typescript: "^5.7.0"
|
|
75
|
+
},
|
|
76
|
+
dependencies: {
|
|
77
|
+
"@clack/prompts": "^0.11.0",
|
|
78
|
+
picocolors: "^1.1.0"
|
|
79
|
+
},
|
|
80
|
+
files: [
|
|
81
|
+
"dist",
|
|
82
|
+
"agents",
|
|
83
|
+
"README.md",
|
|
84
|
+
"LICENSE"
|
|
85
|
+
],
|
|
86
|
+
engines: {
|
|
87
|
+
node: ">=18.0.0"
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// src/cli/install.ts
|
|
94
|
+
var p = __toESM(require("@clack/prompts"));
|
|
95
|
+
var import_node_fs = __toESM(require("fs"));
|
|
96
|
+
var import_node_path = __toESM(require("path"));
|
|
97
|
+
var import_node_os = __toESM(require("os"));
|
|
98
|
+
var import_picocolors = __toESM(require("picocolors"));
|
|
99
|
+
var CONFIG_DIR = import_node_path.default.join(import_node_os.default.homedir(), ".config", "opencode");
|
|
100
|
+
var AGENT_DIR = import_node_path.default.join(CONFIG_DIR, "agent");
|
|
101
|
+
var CONFIG_FILE = import_node_path.default.join(CONFIG_DIR, "opencode.json");
|
|
102
|
+
var AGENT_FILE = import_node_path.default.join(AGENT_DIR, "ask.md");
|
|
103
|
+
var MCP_CONFIGS = {
|
|
104
|
+
context7: {
|
|
105
|
+
type: "remote",
|
|
106
|
+
url: "https://mcp.context7.com/mcp",
|
|
107
|
+
enabled: true
|
|
108
|
+
},
|
|
109
|
+
"grep-app": {
|
|
110
|
+
type: "remote",
|
|
111
|
+
url: "https://mcp.grep.app",
|
|
112
|
+
enabled: true
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
var ASK_AGENT_CONTENT = `---
|
|
116
|
+
description: Answers questions about your codebase, provides insights based on code analysis, and brainstorm ideas with the user
|
|
117
|
+
mode: primary
|
|
118
|
+
temperature: 0.6
|
|
119
|
+
tools:
|
|
120
|
+
read: true
|
|
121
|
+
glob: true
|
|
122
|
+
grep: true
|
|
123
|
+
webfetch: true
|
|
124
|
+
write: false
|
|
125
|
+
edit: false
|
|
126
|
+
bash: false
|
|
127
|
+
task: false
|
|
128
|
+
permission:
|
|
129
|
+
write: deny
|
|
130
|
+
edit: deny
|
|
131
|
+
bash: deny
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
You are a read-only code analyst and research assistant with brainstorming capabilities. Your purpose is to help users understand their codebase, find information, and explore ideas through collaborative discussion.
|
|
135
|
+
|
|
136
|
+
## Core Principles
|
|
137
|
+
|
|
138
|
+
- **Read-only**: You can only read files, search, and fetch web content. You cannot modify files, execute commands, or write new files.
|
|
139
|
+
- **Scope awareness**: Always respect the user's current working directory. If you need to access files outside the current scope, explicitly ask for permission first, you can always access files within or under the current scope.
|
|
140
|
+
- **Accuracy over speed**: Provide well-researched, accurate answers based on actual code content and documentation.
|
|
141
|
+
- **Web-enabled**: Use web search and fetch tools to find relevant documentation, best practices, and up-to-date information.
|
|
142
|
+
- **Creative collaboration**: When brainstorming, think creatively, suggest multiple approaches, and engage in dialogue to explore ideas thoroughly.
|
|
143
|
+
|
|
144
|
+
## Capabilities
|
|
145
|
+
|
|
146
|
+
1. **Codebase exploration**: Read files, search for patterns, explore project structure
|
|
147
|
+
2. **Code analysis**: Explain code logic, identify patterns, trace dependencies
|
|
148
|
+
3. **Web research**: Search the web for documentation, examples, and best practices
|
|
149
|
+
4. **Documentation lookup**: Fetch and synthesize information from official docs
|
|
150
|
+
5. **Brainstorming**: Discuss ideas, suggest features, explore alternatives, and collaborate on solutions
|
|
151
|
+
|
|
152
|
+
## External MCP Servers
|
|
153
|
+
|
|
154
|
+
- **websearch (Exa)**: Real-time web search. Use for current articles, discussions, tutorials, and bleeding-edge information.
|
|
155
|
+
- **context7**: Official documentation lookup. Use for authoritative API references and framework docs.
|
|
156
|
+
- **grep-app**: GitHub code search. Use for production-ready implementation patterns and real-world examples.
|
|
157
|
+
|
|
158
|
+
## Scope Guidelines
|
|
159
|
+
|
|
160
|
+
- **Current project scope**: You can freely read files within the current working directory
|
|
161
|
+
- **Outside scope**: If you need to access files outside the current project (e.g., user home, other projects), you MUST ask the user first:
|
|
162
|
+
- "I need to access [path] which is outside the current project. May I proceed?"
|
|
163
|
+
- Only access external files after explicit user confirmation
|
|
164
|
+
|
|
165
|
+
## Workflow
|
|
166
|
+
|
|
167
|
+
1. **Understand the question**: Clarify what the user is asking if needed
|
|
168
|
+
2. **Identify the approach**: Determine if this is code analysis, research, or brainstorming
|
|
169
|
+
3. **Explore/research**: Use glob, grep, and MCP tools as appropriate
|
|
170
|
+
4. **Read and analyze**: Read the most important files for context
|
|
171
|
+
5. **Synthesize**: Provide a clear, actionable answer
|
|
172
|
+
|
|
173
|
+
**For brainstorming specifically**:
|
|
174
|
+
|
|
175
|
+
- Acknowledge the idea or problem
|
|
176
|
+
- Ask clarifying questions to understand goals and constraints
|
|
177
|
+
- Suggest multiple approaches with trade-offs
|
|
178
|
+
- Explore alternatives together
|
|
179
|
+
- Help refine and prioritize ideas
|
|
180
|
+
|
|
181
|
+
## Response Guidelines
|
|
182
|
+
|
|
183
|
+
- Be concise but thorough
|
|
184
|
+
- Include relevant code snippets when helpful
|
|
185
|
+
- Reference specific file paths and line numbers (e.g., \`src/utils.ts:42\`)
|
|
186
|
+
- Suggest related files or areas to explore if relevant
|
|
187
|
+
- If you cannot answer with certainty, say so and suggest alternatives
|
|
188
|
+
|
|
189
|
+
## Limitations
|
|
190
|
+
|
|
191
|
+
If the user asks you to:
|
|
192
|
+
|
|
193
|
+
- Modify files
|
|
194
|
+
- Run commands
|
|
195
|
+
- Create new files
|
|
196
|
+
- Execute code
|
|
197
|
+
|
|
198
|
+
Politely explain that you are a read-only agent and suggest they switch to the Build or Plan agent for those tasks.
|
|
199
|
+
`;
|
|
200
|
+
async function install(options = {}) {
|
|
201
|
+
console.log();
|
|
202
|
+
p.intro(import_picocolors.default.bgCyan(import_picocolors.default.black(" OpenCode Ask Agent Installer ")));
|
|
203
|
+
const s = p.spinner();
|
|
204
|
+
s.start("Checking OpenCode configuration...");
|
|
205
|
+
let config = {};
|
|
206
|
+
let configExists = false;
|
|
207
|
+
try {
|
|
208
|
+
if (import_node_fs.default.existsSync(CONFIG_FILE)) {
|
|
209
|
+
const content = import_node_fs.default.readFileSync(CONFIG_FILE, "utf-8");
|
|
210
|
+
config = JSON.parse(content);
|
|
211
|
+
configExists = true;
|
|
212
|
+
s.stop(import_picocolors.default.green("OpenCode configuration found"));
|
|
213
|
+
} else {
|
|
214
|
+
s.stop(import_picocolors.default.yellow("OpenCode configuration not found"));
|
|
215
|
+
const create = await p.confirm({
|
|
216
|
+
message: "No opencode.json found. Create one?",
|
|
217
|
+
initialValue: true
|
|
218
|
+
});
|
|
219
|
+
if (p.isCancel(create) || !create) {
|
|
220
|
+
p.cancel("Installation cancelled");
|
|
221
|
+
process.exit(0);
|
|
222
|
+
}
|
|
223
|
+
if (!import_node_fs.default.existsSync(CONFIG_DIR)) {
|
|
224
|
+
import_node_fs.default.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
225
|
+
}
|
|
226
|
+
config = {
|
|
227
|
+
$schema: "https://opencode.ai/config.json",
|
|
228
|
+
plugin: [],
|
|
229
|
+
mcp: {}
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
} catch (error) {
|
|
233
|
+
s.stop(import_picocolors.default.red("Failed to read configuration"));
|
|
234
|
+
throw error;
|
|
235
|
+
}
|
|
236
|
+
const agentExists = import_node_fs.default.existsSync(AGENT_FILE);
|
|
237
|
+
const mcpsExist = config.mcp?.context7 && config.mcp?.["grep-app"] && config.mcp?.websearch;
|
|
238
|
+
if (agentExists && mcpsExist && !options.force) {
|
|
239
|
+
p.note(
|
|
240
|
+
`Ask agent and MCPs are already installed.
|
|
241
|
+
Use --force to reinstall.`,
|
|
242
|
+
"Already Installed"
|
|
243
|
+
);
|
|
244
|
+
p.outro(import_picocolors.default.green("Nothing to do!"));
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
const hasExaKey = await p.confirm({
|
|
248
|
+
message: "Do you have an Exa API key for enhanced web search?",
|
|
249
|
+
initialValue: false
|
|
250
|
+
});
|
|
251
|
+
if (p.isCancel(hasExaKey)) {
|
|
252
|
+
p.cancel("Installation cancelled");
|
|
253
|
+
process.exit(0);
|
|
254
|
+
}
|
|
255
|
+
let exaApiKey;
|
|
256
|
+
let exaKeyInstructions = "";
|
|
257
|
+
if (hasExaKey) {
|
|
258
|
+
const exaKey = await p.text({
|
|
259
|
+
message: "Enter your Exa API key:",
|
|
260
|
+
placeholder: "your-api-key-here",
|
|
261
|
+
validate: (value) => {
|
|
262
|
+
if (value.length < 10) {
|
|
263
|
+
return "API key seems too short. Please check and try again.";
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
if (p.isCancel(exaKey)) {
|
|
268
|
+
p.cancel("Installation cancelled");
|
|
269
|
+
process.exit(0);
|
|
270
|
+
}
|
|
271
|
+
exaApiKey = exaKey;
|
|
272
|
+
exaKeyInstructions = import_picocolors.default.green("API key configured in opencode.json");
|
|
273
|
+
} else {
|
|
274
|
+
exaKeyInstructions = `
|
|
275
|
+
Web search will work with limited functionality.
|
|
276
|
+
Get a free API key at: ${import_picocolors.default.cyan("https://dashboard.exa.ai/api-keys")}
|
|
277
|
+
Then run: ${import_picocolors.default.cyan("npx opencode-ask-agent --force")} to update
|
|
278
|
+
`;
|
|
279
|
+
}
|
|
280
|
+
s.start("Installing Ask agent and MCP servers...");
|
|
281
|
+
try {
|
|
282
|
+
if (configExists) {
|
|
283
|
+
const backupPath = CONFIG_FILE + ".backup";
|
|
284
|
+
import_node_fs.default.copyFileSync(CONFIG_FILE, backupPath);
|
|
285
|
+
}
|
|
286
|
+
if (!import_node_fs.default.existsSync(AGENT_DIR)) {
|
|
287
|
+
import_node_fs.default.mkdirSync(AGENT_DIR, { recursive: true });
|
|
288
|
+
}
|
|
289
|
+
import_node_fs.default.writeFileSync(AGENT_FILE, ASK_AGENT_CONTENT);
|
|
290
|
+
if (!config.mcp) {
|
|
291
|
+
config.mcp = {};
|
|
292
|
+
}
|
|
293
|
+
for (const [name, mcpConfig] of Object.entries(MCP_CONFIGS)) {
|
|
294
|
+
config.mcp[name] = mcpConfig;
|
|
295
|
+
}
|
|
296
|
+
const websearchConfig = {
|
|
297
|
+
type: "remote",
|
|
298
|
+
url: "https://mcp.exa.ai/mcp?tools=web_search_exa",
|
|
299
|
+
enabled: true
|
|
300
|
+
};
|
|
301
|
+
if (exaApiKey) {
|
|
302
|
+
websearchConfig.headers = {
|
|
303
|
+
"x-api-key": exaApiKey
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
config.mcp.websearch = websearchConfig;
|
|
307
|
+
import_node_fs.default.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2) + "\n");
|
|
308
|
+
s.stop(import_picocolors.default.green("Installation complete"));
|
|
309
|
+
} catch (error) {
|
|
310
|
+
s.stop(import_picocolors.default.red("Failed to install"));
|
|
311
|
+
throw error;
|
|
312
|
+
}
|
|
313
|
+
p.note(
|
|
314
|
+
`${import_picocolors.default.green("+")} Agent: ${import_picocolors.default.cyan("ask")} (${AGENT_FILE})
|
|
315
|
+
${import_picocolors.default.green("+")} MCP Servers:
|
|
316
|
+
- ${import_picocolors.default.cyan("context7")} (documentation lookup)
|
|
317
|
+
- ${import_picocolors.default.cyan("grep-app")} (GitHub code search)
|
|
318
|
+
- ${import_picocolors.default.cyan("websearch")} (Exa web search)
|
|
319
|
+
${exaKeyInstructions}`,
|
|
320
|
+
"Installation Complete"
|
|
321
|
+
);
|
|
322
|
+
p.outro(
|
|
323
|
+
`${import_picocolors.default.green("Done!")} Restart OpenCode and press ${import_picocolors.default.cyan("Tab")} to switch to the Ask agent.`
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// src/cli/index.ts
|
|
328
|
+
async function main() {
|
|
329
|
+
const args = process.argv.slice(2);
|
|
330
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
331
|
+
console.log(`
|
|
332
|
+
OpenCode Ask Agent Installer
|
|
333
|
+
|
|
334
|
+
Usage:
|
|
335
|
+
npx opencode-ask-agent [options]
|
|
336
|
+
|
|
337
|
+
Options:
|
|
338
|
+
--help, -h Show this help message
|
|
339
|
+
--version, -v Show version number
|
|
340
|
+
--force Overwrite existing configuration
|
|
341
|
+
|
|
342
|
+
Examples:
|
|
343
|
+
npx opencode-ask-agent Interactive installation
|
|
344
|
+
npx opencode-ask-agent --force Force reinstall
|
|
345
|
+
`);
|
|
346
|
+
process.exit(0);
|
|
347
|
+
}
|
|
348
|
+
if (args.includes("--version") || args.includes("-v")) {
|
|
349
|
+
const pkg = await Promise.resolve().then(() => __toESM(require_package()));
|
|
350
|
+
console.log(pkg.version);
|
|
351
|
+
process.exit(0);
|
|
352
|
+
}
|
|
353
|
+
const force = args.includes("--force");
|
|
354
|
+
try {
|
|
355
|
+
await install({ force });
|
|
356
|
+
} catch (error) {
|
|
357
|
+
console.error("Installation failed:", error);
|
|
358
|
+
process.exit(1);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
main();
|
|
362
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../package.json","../../src/cli/install.ts","../../src/cli/index.ts"],"sourcesContent":["{\n \"name\": \"opencode-ask-agent\",\n \"version\": \"1.0.0\",\n \"description\": \"Read-only Ask agent for OpenCode with web research capabilities\",\n \"main\": \"dist/index.js\",\n \"module\": \"dist/index.mjs\",\n \"types\": \"dist/index.d.ts\",\n \"bin\": {\n \"opencode-ask-agent\": \"./dist/cli/index.js\"\n },\n \"scripts\": {\n \"build\": \"tsup\",\n \"dev\": \"tsup --watch\",\n \"typecheck\": \"tsc --noEmit\",\n \"prepublishOnly\": \"npm run build\"\n },\n \"keywords\": [\n \"opencode\",\n \"agent\",\n \"mcp\",\n \"ai\",\n \"code-analysis\",\n \"research\",\n \"brainstorming\"\n ],\n \"author\": \"Israel Toledo\",\n \"license\": \"MIT\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/israeltoledo/opencode-ask-agent.git\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/israeltoledo/opencode-ask-agent/issues\"\n },\n \"homepage\": \"https://github.com/israeltoledo/opencode-ask-agent#readme\",\n \"peerDependencies\": {\n \"@opencode-ai/plugin\": \"^1.0.0\"\n },\n \"devDependencies\": {\n \"@opencode-ai/plugin\": \"^1.1.20\",\n \"@types/node\": \"^22.0.0\",\n \"tsup\": \"^8.0.0\",\n \"typescript\": \"^5.7.0\"\n },\n \"dependencies\": {\n \"@clack/prompts\": \"^0.11.0\",\n \"picocolors\": \"^1.1.0\"\n },\n \"files\": [\n \"dist\",\n \"agents\",\n \"README.md\",\n \"LICENSE\"\n ],\n \"engines\": {\n \"node\": \">=18.0.0\"\n }\n}\n","/**\n * Installation logic for the Ask Agent plugin\n */\nimport * as p from \"@clack/prompts\";\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport os from \"node:os\";\nimport pc from \"picocolors\";\n\ninterface InstallOptions {\n force?: boolean;\n}\n\ninterface McpConfig {\n type: \"remote\" | \"local\";\n url?: string;\n enabled: boolean;\n headers?: Record<string, string>;\n}\n\ninterface OpenCodeConfig {\n $schema?: string;\n plugin?: string[];\n mcp?: Record<string, McpConfig>;\n [key: string]: unknown;\n}\n\nconst CONFIG_DIR = path.join(os.homedir(), \".config\", \"opencode\");\nconst AGENT_DIR = path.join(CONFIG_DIR, \"agent\");\nconst CONFIG_FILE = path.join(CONFIG_DIR, \"opencode.json\");\nconst AGENT_FILE = path.join(AGENT_DIR, \"ask.md\");\n\n// MCP configurations\nconst MCP_CONFIGS: Record<string, McpConfig> = {\n context7: {\n type: \"remote\",\n url: \"https://mcp.context7.com/mcp\",\n enabled: true,\n },\n \"grep-app\": {\n type: \"remote\",\n url: \"https://mcp.grep.app\",\n enabled: true,\n },\n};\n\n// Ask agent markdown content\nconst ASK_AGENT_CONTENT = `---\ndescription: Answers questions about your codebase, provides insights based on code analysis, and brainstorm ideas with the user\nmode: primary\ntemperature: 0.6\ntools:\n read: true\n glob: true\n grep: true\n webfetch: true\n write: false\n edit: false\n bash: false\n task: false\npermission:\n write: deny\n edit: deny\n bash: deny\n---\n\nYou are a read-only code analyst and research assistant with brainstorming capabilities. Your purpose is to help users understand their codebase, find information, and explore ideas through collaborative discussion.\n\n## Core Principles\n\n- **Read-only**: You can only read files, search, and fetch web content. You cannot modify files, execute commands, or write new files.\n- **Scope awareness**: Always respect the user's current working directory. If you need to access files outside the current scope, explicitly ask for permission first, you can always access files within or under the current scope.\n- **Accuracy over speed**: Provide well-researched, accurate answers based on actual code content and documentation.\n- **Web-enabled**: Use web search and fetch tools to find relevant documentation, best practices, and up-to-date information.\n- **Creative collaboration**: When brainstorming, think creatively, suggest multiple approaches, and engage in dialogue to explore ideas thoroughly.\n\n## Capabilities\n\n1. **Codebase exploration**: Read files, search for patterns, explore project structure\n2. **Code analysis**: Explain code logic, identify patterns, trace dependencies\n3. **Web research**: Search the web for documentation, examples, and best practices\n4. **Documentation lookup**: Fetch and synthesize information from official docs\n5. **Brainstorming**: Discuss ideas, suggest features, explore alternatives, and collaborate on solutions\n\n## External MCP Servers\n\n- **websearch (Exa)**: Real-time web search. Use for current articles, discussions, tutorials, and bleeding-edge information.\n- **context7**: Official documentation lookup. Use for authoritative API references and framework docs.\n- **grep-app**: GitHub code search. Use for production-ready implementation patterns and real-world examples.\n\n## Scope Guidelines\n\n- **Current project scope**: You can freely read files within the current working directory\n- **Outside scope**: If you need to access files outside the current project (e.g., user home, other projects), you MUST ask the user first:\n - \"I need to access [path] which is outside the current project. May I proceed?\"\n - Only access external files after explicit user confirmation\n\n## Workflow\n\n1. **Understand the question**: Clarify what the user is asking if needed\n2. **Identify the approach**: Determine if this is code analysis, research, or brainstorming\n3. **Explore/research**: Use glob, grep, and MCP tools as appropriate\n4. **Read and analyze**: Read the most important files for context\n5. **Synthesize**: Provide a clear, actionable answer\n\n**For brainstorming specifically**:\n\n- Acknowledge the idea or problem\n- Ask clarifying questions to understand goals and constraints\n- Suggest multiple approaches with trade-offs\n- Explore alternatives together\n- Help refine and prioritize ideas\n\n## Response Guidelines\n\n- Be concise but thorough\n- Include relevant code snippets when helpful\n- Reference specific file paths and line numbers (e.g., \\`src/utils.ts:42\\`)\n- Suggest related files or areas to explore if relevant\n- If you cannot answer with certainty, say so and suggest alternatives\n\n## Limitations\n\nIf the user asks you to:\n\n- Modify files\n- Run commands\n- Create new files\n- Execute code\n\nPolitely explain that you are a read-only agent and suggest they switch to the Build or Plan agent for those tasks.\n`;\n\nexport async function install(options: InstallOptions = {}) {\n console.log();\n p.intro(pc.bgCyan(pc.black(\" OpenCode Ask Agent Installer \")));\n\n // Step 1: Check OpenCode installation\n const s = p.spinner();\n s.start(\"Checking OpenCode configuration...\");\n\n let config: OpenCodeConfig = {};\n let configExists = false;\n\n try {\n if (fs.existsSync(CONFIG_FILE)) {\n const content = fs.readFileSync(CONFIG_FILE, \"utf-8\");\n config = JSON.parse(content);\n configExists = true;\n s.stop(pc.green(\"OpenCode configuration found\"));\n } else {\n s.stop(pc.yellow(\"OpenCode configuration not found\"));\n\n const create = await p.confirm({\n message: \"No opencode.json found. Create one?\",\n initialValue: true,\n });\n\n if (p.isCancel(create) || !create) {\n p.cancel(\"Installation cancelled\");\n process.exit(0);\n }\n\n // Ensure config directory exists\n if (!fs.existsSync(CONFIG_DIR)) {\n fs.mkdirSync(CONFIG_DIR, { recursive: true });\n }\n\n config = {\n $schema: \"https://opencode.ai/config.json\",\n plugin: [],\n mcp: {},\n };\n }\n } catch (error) {\n s.stop(pc.red(\"Failed to read configuration\"));\n throw error;\n }\n\n // Check if already installed\n const agentExists = fs.existsSync(AGENT_FILE);\n const mcpsExist =\n config.mcp?.context7 && config.mcp?.[\"grep-app\"] && config.mcp?.websearch;\n\n if (agentExists && mcpsExist && !options.force) {\n p.note(\n `Ask agent and MCPs are already installed.\\nUse --force to reinstall.`,\n \"Already Installed\",\n );\n p.outro(pc.green(\"Nothing to do!\"));\n return;\n }\n\n // Step 2: Ask about Exa API key\n const hasExaKey = await p.confirm({\n message: \"Do you have an Exa API key for enhanced web search?\",\n initialValue: false,\n });\n\n if (p.isCancel(hasExaKey)) {\n p.cancel(\"Installation cancelled\");\n process.exit(0);\n }\n\n let exaApiKey: string | undefined;\n let exaKeyInstructions = \"\";\n\n if (hasExaKey) {\n const exaKey = await p.text({\n message: \"Enter your Exa API key:\",\n placeholder: \"your-api-key-here\",\n validate: (value: string) => {\n if (value.length < 10) {\n return \"API key seems too short. Please check and try again.\";\n }\n },\n });\n\n if (p.isCancel(exaKey)) {\n p.cancel(\"Installation cancelled\");\n process.exit(0);\n }\n\n exaApiKey = exaKey as string;\n exaKeyInstructions = pc.green(\"API key configured in opencode.json\");\n } else {\n exaKeyInstructions = `\nWeb search will work with limited functionality.\nGet a free API key at: ${pc.cyan(\"https://dashboard.exa.ai/api-keys\")}\nThen run: ${pc.cyan(\"npx opencode-ask-agent --force\")} to update\n`;\n }\n\n // Step 3: Install agent and MCPs\n s.start(\"Installing Ask agent and MCP servers...\");\n\n try {\n // Backup existing config\n if (configExists) {\n const backupPath = CONFIG_FILE + \".backup\";\n fs.copyFileSync(CONFIG_FILE, backupPath);\n }\n\n // Ensure agent directory exists\n if (!fs.existsSync(AGENT_DIR)) {\n fs.mkdirSync(AGENT_DIR, { recursive: true });\n }\n\n // Write agent file\n fs.writeFileSync(AGENT_FILE, ASK_AGENT_CONTENT);\n\n // Initialize mcp if not present\n if (!config.mcp) {\n config.mcp = {};\n }\n\n // Add MCP configurations\n for (const [name, mcpConfig] of Object.entries(MCP_CONFIGS)) {\n config.mcp[name] = mcpConfig;\n }\n\n // Add websearch MCP with optional API key\n const websearchConfig: McpConfig = {\n type: \"remote\",\n url: \"https://mcp.exa.ai/mcp?tools=web_search_exa\",\n enabled: true,\n };\n\n if (exaApiKey) {\n websearchConfig.headers = {\n \"x-api-key\": exaApiKey,\n };\n }\n\n config.mcp.websearch = websearchConfig;\n\n // Write updated config\n fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2) + \"\\n\");\n\n s.stop(pc.green(\"Installation complete\"));\n } catch (error) {\n s.stop(pc.red(\"Failed to install\"));\n throw error;\n }\n\n // Step 4: Show summary\n p.note(\n `${pc.green(\"+\")} Agent: ${pc.cyan(\"ask\")} (${AGENT_FILE})\n${pc.green(\"+\")} MCP Servers:\n - ${pc.cyan(\"context7\")} (documentation lookup)\n - ${pc.cyan(\"grep-app\")} (GitHub code search)\n - ${pc.cyan(\"websearch\")} (Exa web search)\n${exaKeyInstructions}`,\n \"Installation Complete\",\n );\n\n p.outro(\n `${pc.green(\"Done!\")} Restart OpenCode and press ${pc.cyan(\"Tab\")} to switch to the Ask agent.`,\n );\n}\n","/**\n * OpenCode Ask Agent CLI\n * Interactive installer for the Ask Agent plugin\n */\nimport { install } from \"./install\";\n\nasync function main() {\n const args = process.argv.slice(2);\n\n if (args.includes(\"--help\") || args.includes(\"-h\")) {\n console.log(`\nOpenCode Ask Agent Installer\n\nUsage:\n npx opencode-ask-agent [options]\n\nOptions:\n --help, -h Show this help message\n --version, -v Show version number\n --force Overwrite existing configuration\n\nExamples:\n npx opencode-ask-agent Interactive installation\n npx opencode-ask-agent --force Force reinstall\n`);\n process.exit(0);\n }\n\n if (args.includes(\"--version\") || args.includes(\"-v\")) {\n const pkg = await import(\"../../package.json\");\n console.log(pkg.version);\n process.exit(0);\n }\n\n const force = args.includes(\"--force\");\n\n try {\n await install({ force });\n } catch (error) {\n console.error(\"Installation failed:\", error);\n process.exit(1);\n }\n}\n\nmain();\n"],"mappings":"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","names":["exports","module","path","os","pc","fs"]}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { Plugin } from '@opencode-ai/plugin';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Ask Agent Definition
|
|
5
|
+
* A read-only code analyst and research assistant with brainstorming capabilities
|
|
6
|
+
*/
|
|
7
|
+
declare const ASK_AGENT_PROMPT = "You are a read-only code analyst and research assistant with brainstorming capabilities. Your purpose is to help users understand their codebase, find information, and explore ideas through collaborative discussion.\n\n## Core Principles\n\n- **Read-only**: You can only read files, search, and fetch web content. You cannot modify files, execute commands, or write new files.\n- **Scope awareness**: Always respect the user's current working directory. If you need to access files outside the current scope, explicitly ask for permission first, you can always access files within or under the current scope.\n- **Accuracy over speed**: Provide well-researched, accurate answers based on actual code content and documentation.\n- **Web-enabled**: Use web search and fetch tools to find relevant documentation, best practices, and up-to-date information.\n- **Creative collaboration**: When brainstorming, think creatively, suggest multiple approaches, and engage in dialogue to explore ideas thoroughly.\n\n## Capabilities\n\n1. **Codebase exploration**: Read files, search for patterns, explore project structure\n2. **Code analysis**: Explain code logic, identify patterns, trace dependencies\n3. **Web research**: Search the web for documentation, examples, and best practices\n4. **Documentation lookup**: Fetch and synthesize information from official docs\n5. **Brainstorming**: Discuss ideas, suggest features, explore alternatives, and collaborate on solutions\n\n## External MCP Servers\n\n- **websearch (Exa)**: Real-time web search. Use for current articles, discussions, tutorials, and bleeding-edge information.\n- **context7**: Official documentation lookup. Use for authoritative API references and framework docs.\n- **grep-app**: GitHub code search. Use for production-ready implementation patterns and real-world examples.\n\n## Scope Guidelines\n\n- **Current project scope**: You can freely read files within the current working directory\n- **Outside scope**: If you need to access files outside the current project (e.g., user home, other projects), you MUST ask the user first:\n - \"I need to access [path] which is outside the current project. May I proceed?\"\n - Only access external files after explicit user confirmation\n\n## Workflow\n\n1. **Understand the question**: Clarify what the user is asking if needed\n2. **Identify the approach**: Determine if this is code analysis, research, or brainstorming\n3. **Explore/research**: Use glob, grep, and MCP tools as appropriate\n4. **Read and analyze**: Read the most important files for context\n5. **Synthesize**: Provide a clear, actionable answer\n\n**For brainstorming specifically**:\n\n- Acknowledge the idea or problem\n- Ask clarifying questions to understand goals and constraints\n- Suggest multiple approaches with trade-offs\n- Explore alternatives together\n- Help refine and prioritize ideas\n\n## Response Guidelines\n\n- Be concise but thorough\n- Include relevant code snippets when helpful\n- Reference specific file paths and line numbers (e.g., `src/utils.ts:42`)\n- Suggest related files or areas to explore if relevant\n- If you cannot answer with certainty, say so and suggest alternatives\n\n## Limitations\n\nIf the user asks you to:\n\n- Modify files\n- Run commands\n- Create new files\n- Execute code\n\nPolitely explain that you are a read-only agent and suggest they switch to the Build or Plan agent for those tasks.";
|
|
8
|
+
/**
|
|
9
|
+
* Creates the Ask agent configuration
|
|
10
|
+
*/
|
|
11
|
+
declare function createAskAgent(): {
|
|
12
|
+
description: string;
|
|
13
|
+
mode: "primary";
|
|
14
|
+
temperature: number;
|
|
15
|
+
tools: {
|
|
16
|
+
read: boolean;
|
|
17
|
+
glob: boolean;
|
|
18
|
+
grep: boolean;
|
|
19
|
+
webfetch: boolean;
|
|
20
|
+
write: boolean;
|
|
21
|
+
edit: boolean;
|
|
22
|
+
bash: boolean;
|
|
23
|
+
task: boolean;
|
|
24
|
+
};
|
|
25
|
+
permission: {
|
|
26
|
+
write: "deny";
|
|
27
|
+
edit: "deny";
|
|
28
|
+
bash: "deny";
|
|
29
|
+
};
|
|
30
|
+
prompt: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Context7 MCP Server Configuration
|
|
35
|
+
* Official documentation lookup for libraries and frameworks
|
|
36
|
+
*/
|
|
37
|
+
declare const context7: {
|
|
38
|
+
type: "remote";
|
|
39
|
+
url: string;
|
|
40
|
+
enabled: boolean;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Grep.app MCP Server Configuration
|
|
45
|
+
* GitHub code search for real-world implementation examples
|
|
46
|
+
*/
|
|
47
|
+
declare const grepApp: {
|
|
48
|
+
type: "remote";
|
|
49
|
+
url: string;
|
|
50
|
+
enabled: boolean;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
declare const websearch: {
|
|
54
|
+
headers?: {
|
|
55
|
+
"x-api-key": string;
|
|
56
|
+
} | undefined;
|
|
57
|
+
type: "remote";
|
|
58
|
+
url: string;
|
|
59
|
+
enabled: boolean;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Creates the complete MCP configuration object for the plugin
|
|
64
|
+
*/
|
|
65
|
+
declare function createBuiltinMcps(): {
|
|
66
|
+
context7: {
|
|
67
|
+
type: "remote";
|
|
68
|
+
url: string;
|
|
69
|
+
enabled: boolean;
|
|
70
|
+
};
|
|
71
|
+
"grep-app": {
|
|
72
|
+
type: "remote";
|
|
73
|
+
url: string;
|
|
74
|
+
enabled: boolean;
|
|
75
|
+
};
|
|
76
|
+
websearch: {
|
|
77
|
+
headers?: {
|
|
78
|
+
"x-api-key": string;
|
|
79
|
+
} | undefined;
|
|
80
|
+
type: "remote";
|
|
81
|
+
url: string;
|
|
82
|
+
enabled: boolean;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* OpenCode Ask Agent Plugin
|
|
88
|
+
*
|
|
89
|
+
* This plugin provides a minimal runtime hook for the Ask agent.
|
|
90
|
+
* The actual agent and MCP configurations are installed via the CLI
|
|
91
|
+
* into opencode.json.
|
|
92
|
+
*
|
|
93
|
+
* Installation:
|
|
94
|
+
* npx opencode-ask-agent
|
|
95
|
+
*
|
|
96
|
+
* Or add to opencode.json:
|
|
97
|
+
* { "plugin": ["opencode-ask-agent"] }
|
|
98
|
+
*
|
|
99
|
+
* @packageDocumentation
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The Ask Agent plugin
|
|
104
|
+
*
|
|
105
|
+
* This is a minimal plugin that can be extended with hooks.
|
|
106
|
+
* The main functionality (agent + MCPs) is configured via opencode.json
|
|
107
|
+
* by the CLI installer.
|
|
108
|
+
*/
|
|
109
|
+
declare const AskPlugin: Plugin;
|
|
110
|
+
|
|
111
|
+
export { ASK_AGENT_PROMPT, AskPlugin, context7, createAskAgent, createBuiltinMcps, AskPlugin as default, grepApp, websearch };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { Plugin } from '@opencode-ai/plugin';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Ask Agent Definition
|
|
5
|
+
* A read-only code analyst and research assistant with brainstorming capabilities
|
|
6
|
+
*/
|
|
7
|
+
declare const ASK_AGENT_PROMPT = "You are a read-only code analyst and research assistant with brainstorming capabilities. Your purpose is to help users understand their codebase, find information, and explore ideas through collaborative discussion.\n\n## Core Principles\n\n- **Read-only**: You can only read files, search, and fetch web content. You cannot modify files, execute commands, or write new files.\n- **Scope awareness**: Always respect the user's current working directory. If you need to access files outside the current scope, explicitly ask for permission first, you can always access files within or under the current scope.\n- **Accuracy over speed**: Provide well-researched, accurate answers based on actual code content and documentation.\n- **Web-enabled**: Use web search and fetch tools to find relevant documentation, best practices, and up-to-date information.\n- **Creative collaboration**: When brainstorming, think creatively, suggest multiple approaches, and engage in dialogue to explore ideas thoroughly.\n\n## Capabilities\n\n1. **Codebase exploration**: Read files, search for patterns, explore project structure\n2. **Code analysis**: Explain code logic, identify patterns, trace dependencies\n3. **Web research**: Search the web for documentation, examples, and best practices\n4. **Documentation lookup**: Fetch and synthesize information from official docs\n5. **Brainstorming**: Discuss ideas, suggest features, explore alternatives, and collaborate on solutions\n\n## External MCP Servers\n\n- **websearch (Exa)**: Real-time web search. Use for current articles, discussions, tutorials, and bleeding-edge information.\n- **context7**: Official documentation lookup. Use for authoritative API references and framework docs.\n- **grep-app**: GitHub code search. Use for production-ready implementation patterns and real-world examples.\n\n## Scope Guidelines\n\n- **Current project scope**: You can freely read files within the current working directory\n- **Outside scope**: If you need to access files outside the current project (e.g., user home, other projects), you MUST ask the user first:\n - \"I need to access [path] which is outside the current project. May I proceed?\"\n - Only access external files after explicit user confirmation\n\n## Workflow\n\n1. **Understand the question**: Clarify what the user is asking if needed\n2. **Identify the approach**: Determine if this is code analysis, research, or brainstorming\n3. **Explore/research**: Use glob, grep, and MCP tools as appropriate\n4. **Read and analyze**: Read the most important files for context\n5. **Synthesize**: Provide a clear, actionable answer\n\n**For brainstorming specifically**:\n\n- Acknowledge the idea or problem\n- Ask clarifying questions to understand goals and constraints\n- Suggest multiple approaches with trade-offs\n- Explore alternatives together\n- Help refine and prioritize ideas\n\n## Response Guidelines\n\n- Be concise but thorough\n- Include relevant code snippets when helpful\n- Reference specific file paths and line numbers (e.g., `src/utils.ts:42`)\n- Suggest related files or areas to explore if relevant\n- If you cannot answer with certainty, say so and suggest alternatives\n\n## Limitations\n\nIf the user asks you to:\n\n- Modify files\n- Run commands\n- Create new files\n- Execute code\n\nPolitely explain that you are a read-only agent and suggest they switch to the Build or Plan agent for those tasks.";
|
|
8
|
+
/**
|
|
9
|
+
* Creates the Ask agent configuration
|
|
10
|
+
*/
|
|
11
|
+
declare function createAskAgent(): {
|
|
12
|
+
description: string;
|
|
13
|
+
mode: "primary";
|
|
14
|
+
temperature: number;
|
|
15
|
+
tools: {
|
|
16
|
+
read: boolean;
|
|
17
|
+
glob: boolean;
|
|
18
|
+
grep: boolean;
|
|
19
|
+
webfetch: boolean;
|
|
20
|
+
write: boolean;
|
|
21
|
+
edit: boolean;
|
|
22
|
+
bash: boolean;
|
|
23
|
+
task: boolean;
|
|
24
|
+
};
|
|
25
|
+
permission: {
|
|
26
|
+
write: "deny";
|
|
27
|
+
edit: "deny";
|
|
28
|
+
bash: "deny";
|
|
29
|
+
};
|
|
30
|
+
prompt: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Context7 MCP Server Configuration
|
|
35
|
+
* Official documentation lookup for libraries and frameworks
|
|
36
|
+
*/
|
|
37
|
+
declare const context7: {
|
|
38
|
+
type: "remote";
|
|
39
|
+
url: string;
|
|
40
|
+
enabled: boolean;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Grep.app MCP Server Configuration
|
|
45
|
+
* GitHub code search for real-world implementation examples
|
|
46
|
+
*/
|
|
47
|
+
declare const grepApp: {
|
|
48
|
+
type: "remote";
|
|
49
|
+
url: string;
|
|
50
|
+
enabled: boolean;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
declare const websearch: {
|
|
54
|
+
headers?: {
|
|
55
|
+
"x-api-key": string;
|
|
56
|
+
} | undefined;
|
|
57
|
+
type: "remote";
|
|
58
|
+
url: string;
|
|
59
|
+
enabled: boolean;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Creates the complete MCP configuration object for the plugin
|
|
64
|
+
*/
|
|
65
|
+
declare function createBuiltinMcps(): {
|
|
66
|
+
context7: {
|
|
67
|
+
type: "remote";
|
|
68
|
+
url: string;
|
|
69
|
+
enabled: boolean;
|
|
70
|
+
};
|
|
71
|
+
"grep-app": {
|
|
72
|
+
type: "remote";
|
|
73
|
+
url: string;
|
|
74
|
+
enabled: boolean;
|
|
75
|
+
};
|
|
76
|
+
websearch: {
|
|
77
|
+
headers?: {
|
|
78
|
+
"x-api-key": string;
|
|
79
|
+
} | undefined;
|
|
80
|
+
type: "remote";
|
|
81
|
+
url: string;
|
|
82
|
+
enabled: boolean;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* OpenCode Ask Agent Plugin
|
|
88
|
+
*
|
|
89
|
+
* This plugin provides a minimal runtime hook for the Ask agent.
|
|
90
|
+
* The actual agent and MCP configurations are installed via the CLI
|
|
91
|
+
* into opencode.json.
|
|
92
|
+
*
|
|
93
|
+
* Installation:
|
|
94
|
+
* npx opencode-ask-agent
|
|
95
|
+
*
|
|
96
|
+
* Or add to opencode.json:
|
|
97
|
+
* { "plugin": ["opencode-ask-agent"] }
|
|
98
|
+
*
|
|
99
|
+
* @packageDocumentation
|
|
100
|
+
*/
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The Ask Agent plugin
|
|
104
|
+
*
|
|
105
|
+
* This is a minimal plugin that can be extended with hooks.
|
|
106
|
+
* The main functionality (agent + MCPs) is configured via opencode.json
|
|
107
|
+
* by the CLI installer.
|
|
108
|
+
*/
|
|
109
|
+
declare const AskPlugin: Plugin;
|
|
110
|
+
|
|
111
|
+
export { ASK_AGENT_PROMPT, AskPlugin, context7, createAskAgent, createBuiltinMcps, AskPlugin as default, grepApp, websearch };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
ASK_AGENT_PROMPT: () => ASK_AGENT_PROMPT,
|
|
24
|
+
AskPlugin: () => AskPlugin,
|
|
25
|
+
context7: () => context7,
|
|
26
|
+
createAskAgent: () => createAskAgent,
|
|
27
|
+
createBuiltinMcps: () => createBuiltinMcps,
|
|
28
|
+
default: () => index_default,
|
|
29
|
+
grepApp: () => grepApp,
|
|
30
|
+
websearch: () => websearch
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(index_exports);
|
|
33
|
+
|
|
34
|
+
// src/agents/ask.ts
|
|
35
|
+
var ASK_AGENT_PROMPT = `You are a read-only code analyst and research assistant with brainstorming capabilities. Your purpose is to help users understand their codebase, find information, and explore ideas through collaborative discussion.
|
|
36
|
+
|
|
37
|
+
## Core Principles
|
|
38
|
+
|
|
39
|
+
- **Read-only**: You can only read files, search, and fetch web content. You cannot modify files, execute commands, or write new files.
|
|
40
|
+
- **Scope awareness**: Always respect the user's current working directory. If you need to access files outside the current scope, explicitly ask for permission first, you can always access files within or under the current scope.
|
|
41
|
+
- **Accuracy over speed**: Provide well-researched, accurate answers based on actual code content and documentation.
|
|
42
|
+
- **Web-enabled**: Use web search and fetch tools to find relevant documentation, best practices, and up-to-date information.
|
|
43
|
+
- **Creative collaboration**: When brainstorming, think creatively, suggest multiple approaches, and engage in dialogue to explore ideas thoroughly.
|
|
44
|
+
|
|
45
|
+
## Capabilities
|
|
46
|
+
|
|
47
|
+
1. **Codebase exploration**: Read files, search for patterns, explore project structure
|
|
48
|
+
2. **Code analysis**: Explain code logic, identify patterns, trace dependencies
|
|
49
|
+
3. **Web research**: Search the web for documentation, examples, and best practices
|
|
50
|
+
4. **Documentation lookup**: Fetch and synthesize information from official docs
|
|
51
|
+
5. **Brainstorming**: Discuss ideas, suggest features, explore alternatives, and collaborate on solutions
|
|
52
|
+
|
|
53
|
+
## External MCP Servers
|
|
54
|
+
|
|
55
|
+
- **websearch (Exa)**: Real-time web search. Use for current articles, discussions, tutorials, and bleeding-edge information.
|
|
56
|
+
- **context7**: Official documentation lookup. Use for authoritative API references and framework docs.
|
|
57
|
+
- **grep-app**: GitHub code search. Use for production-ready implementation patterns and real-world examples.
|
|
58
|
+
|
|
59
|
+
## Scope Guidelines
|
|
60
|
+
|
|
61
|
+
- **Current project scope**: You can freely read files within the current working directory
|
|
62
|
+
- **Outside scope**: If you need to access files outside the current project (e.g., user home, other projects), you MUST ask the user first:
|
|
63
|
+
- "I need to access [path] which is outside the current project. May I proceed?"
|
|
64
|
+
- Only access external files after explicit user confirmation
|
|
65
|
+
|
|
66
|
+
## Workflow
|
|
67
|
+
|
|
68
|
+
1. **Understand the question**: Clarify what the user is asking if needed
|
|
69
|
+
2. **Identify the approach**: Determine if this is code analysis, research, or brainstorming
|
|
70
|
+
3. **Explore/research**: Use glob, grep, and MCP tools as appropriate
|
|
71
|
+
4. **Read and analyze**: Read the most important files for context
|
|
72
|
+
5. **Synthesize**: Provide a clear, actionable answer
|
|
73
|
+
|
|
74
|
+
**For brainstorming specifically**:
|
|
75
|
+
|
|
76
|
+
- Acknowledge the idea or problem
|
|
77
|
+
- Ask clarifying questions to understand goals and constraints
|
|
78
|
+
- Suggest multiple approaches with trade-offs
|
|
79
|
+
- Explore alternatives together
|
|
80
|
+
- Help refine and prioritize ideas
|
|
81
|
+
|
|
82
|
+
## Response Guidelines
|
|
83
|
+
|
|
84
|
+
- Be concise but thorough
|
|
85
|
+
- Include relevant code snippets when helpful
|
|
86
|
+
- Reference specific file paths and line numbers (e.g., \`src/utils.ts:42\`)
|
|
87
|
+
- Suggest related files or areas to explore if relevant
|
|
88
|
+
- If you cannot answer with certainty, say so and suggest alternatives
|
|
89
|
+
|
|
90
|
+
## Limitations
|
|
91
|
+
|
|
92
|
+
If the user asks you to:
|
|
93
|
+
|
|
94
|
+
- Modify files
|
|
95
|
+
- Run commands
|
|
96
|
+
- Create new files
|
|
97
|
+
- Execute code
|
|
98
|
+
|
|
99
|
+
Politely explain that you are a read-only agent and suggest they switch to the Build or Plan agent for those tasks.`;
|
|
100
|
+
function createAskAgent() {
|
|
101
|
+
return {
|
|
102
|
+
description: "Answers questions about your codebase, provides insights based on code analysis, and brainstorm ideas with the user",
|
|
103
|
+
mode: "primary",
|
|
104
|
+
temperature: 0.6,
|
|
105
|
+
tools: {
|
|
106
|
+
read: true,
|
|
107
|
+
glob: true,
|
|
108
|
+
grep: true,
|
|
109
|
+
webfetch: true,
|
|
110
|
+
write: false,
|
|
111
|
+
edit: false,
|
|
112
|
+
bash: false,
|
|
113
|
+
task: false
|
|
114
|
+
},
|
|
115
|
+
permission: {
|
|
116
|
+
write: "deny",
|
|
117
|
+
edit: "deny",
|
|
118
|
+
bash: "deny"
|
|
119
|
+
},
|
|
120
|
+
prompt: ASK_AGENT_PROMPT
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// src/mcp/context7.ts
|
|
125
|
+
var context7 = {
|
|
126
|
+
type: "remote",
|
|
127
|
+
url: "https://mcp.context7.com/mcp",
|
|
128
|
+
enabled: true
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// src/mcp/grep-app.ts
|
|
132
|
+
var grepApp = {
|
|
133
|
+
type: "remote",
|
|
134
|
+
url: "https://mcp.grep.app",
|
|
135
|
+
enabled: true
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
// src/mcp/websearch.ts
|
|
139
|
+
function createWebsearchMcp() {
|
|
140
|
+
const apiKey = process.env.EXA_API_KEY;
|
|
141
|
+
return {
|
|
142
|
+
type: "remote",
|
|
143
|
+
url: "https://mcp.exa.ai/mcp?tools=web_search_exa",
|
|
144
|
+
enabled: true,
|
|
145
|
+
...apiKey && {
|
|
146
|
+
headers: {
|
|
147
|
+
"x-api-key": apiKey
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
var websearch = createWebsearchMcp();
|
|
153
|
+
|
|
154
|
+
// src/mcp/index.ts
|
|
155
|
+
function createBuiltinMcps() {
|
|
156
|
+
return {
|
|
157
|
+
context7,
|
|
158
|
+
"grep-app": grepApp,
|
|
159
|
+
websearch: createWebsearchMcp()
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// src/index.ts
|
|
164
|
+
var AskPlugin = async (_ctx) => {
|
|
165
|
+
return {};
|
|
166
|
+
};
|
|
167
|
+
var index_default = AskPlugin;
|
|
168
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
169
|
+
0 && (module.exports = {
|
|
170
|
+
ASK_AGENT_PROMPT,
|
|
171
|
+
AskPlugin,
|
|
172
|
+
context7,
|
|
173
|
+
createAskAgent,
|
|
174
|
+
createBuiltinMcps,
|
|
175
|
+
grepApp,
|
|
176
|
+
websearch
|
|
177
|
+
});
|
|
178
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/agents/ask.ts","../src/mcp/context7.ts","../src/mcp/grep-app.ts","../src/mcp/websearch.ts","../src/mcp/index.ts"],"sourcesContent":["/**\n * OpenCode Ask Agent Plugin\n *\n * This plugin provides a minimal runtime hook for the Ask agent.\n * The actual agent and MCP configurations are installed via the CLI\n * into opencode.json.\n *\n * Installation:\n * npx opencode-ask-agent\n *\n * Or add to opencode.json:\n * { \"plugin\": [\"opencode-ask-agent\"] }\n *\n * @packageDocumentation\n */\nimport type { Plugin, Hooks } from \"@opencode-ai/plugin\";\n\n/**\n * The Ask Agent plugin\n *\n * This is a minimal plugin that can be extended with hooks.\n * The main functionality (agent + MCPs) is configured via opencode.json\n * by the CLI installer.\n */\nexport const AskPlugin: Plugin = async (_ctx): Promise<Hooks> => {\n // Return empty hooks - agent/MCP config is in opencode.json\n return {};\n};\n\n// Re-export components for programmatic usage\nexport { createAskAgent, ASK_AGENT_PROMPT } from \"./agents\";\nexport { createBuiltinMcps, context7, grepApp, websearch } from \"./mcp\";\n\n// Default export\nexport default AskPlugin;\n","/**\n * Ask Agent Definition\n * A read-only code analyst and research assistant with brainstorming capabilities\n */\n\nexport const ASK_AGENT_PROMPT = `You are a read-only code analyst and research assistant with brainstorming capabilities. Your purpose is to help users understand their codebase, find information, and explore ideas through collaborative discussion.\n\n## Core Principles\n\n- **Read-only**: You can only read files, search, and fetch web content. You cannot modify files, execute commands, or write new files.\n- **Scope awareness**: Always respect the user's current working directory. If you need to access files outside the current scope, explicitly ask for permission first, you can always access files within or under the current scope.\n- **Accuracy over speed**: Provide well-researched, accurate answers based on actual code content and documentation.\n- **Web-enabled**: Use web search and fetch tools to find relevant documentation, best practices, and up-to-date information.\n- **Creative collaboration**: When brainstorming, think creatively, suggest multiple approaches, and engage in dialogue to explore ideas thoroughly.\n\n## Capabilities\n\n1. **Codebase exploration**: Read files, search for patterns, explore project structure\n2. **Code analysis**: Explain code logic, identify patterns, trace dependencies\n3. **Web research**: Search the web for documentation, examples, and best practices\n4. **Documentation lookup**: Fetch and synthesize information from official docs\n5. **Brainstorming**: Discuss ideas, suggest features, explore alternatives, and collaborate on solutions\n\n## External MCP Servers\n\n- **websearch (Exa)**: Real-time web search. Use for current articles, discussions, tutorials, and bleeding-edge information.\n- **context7**: Official documentation lookup. Use for authoritative API references and framework docs.\n- **grep-app**: GitHub code search. Use for production-ready implementation patterns and real-world examples.\n\n## Scope Guidelines\n\n- **Current project scope**: You can freely read files within the current working directory\n- **Outside scope**: If you need to access files outside the current project (e.g., user home, other projects), you MUST ask the user first:\n - \"I need to access [path] which is outside the current project. May I proceed?\"\n - Only access external files after explicit user confirmation\n\n## Workflow\n\n1. **Understand the question**: Clarify what the user is asking if needed\n2. **Identify the approach**: Determine if this is code analysis, research, or brainstorming\n3. **Explore/research**: Use glob, grep, and MCP tools as appropriate\n4. **Read and analyze**: Read the most important files for context\n5. **Synthesize**: Provide a clear, actionable answer\n\n**For brainstorming specifically**:\n\n- Acknowledge the idea or problem\n- Ask clarifying questions to understand goals and constraints\n- Suggest multiple approaches with trade-offs\n- Explore alternatives together\n- Help refine and prioritize ideas\n\n## Response Guidelines\n\n- Be concise but thorough\n- Include relevant code snippets when helpful\n- Reference specific file paths and line numbers (e.g., \\`src/utils.ts:42\\`)\n- Suggest related files or areas to explore if relevant\n- If you cannot answer with certainty, say so and suggest alternatives\n\n## Limitations\n\nIf the user asks you to:\n\n- Modify files\n- Run commands\n- Create new files\n- Execute code\n\nPolitely explain that you are a read-only agent and suggest they switch to the Build or Plan agent for those tasks.`;\n\n/**\n * Creates the Ask agent configuration\n */\nexport function createAskAgent() {\n return {\n description:\n \"Answers questions about your codebase, provides insights based on code analysis, and brainstorm ideas with the user\",\n mode: \"primary\" as const,\n temperature: 0.6,\n tools: {\n read: true,\n glob: true,\n grep: true,\n webfetch: true,\n write: false,\n edit: false,\n bash: false,\n task: false,\n },\n permission: {\n write: \"deny\" as const,\n edit: \"deny\" as const,\n bash: \"deny\" as const,\n },\n prompt: ASK_AGENT_PROMPT,\n };\n}\n","/**\n * Context7 MCP Server Configuration\n * Official documentation lookup for libraries and frameworks\n */\nexport const context7 = {\n type: \"remote\" as const,\n url: \"https://mcp.context7.com/mcp\",\n enabled: true,\n};\n","/**\n * Grep.app MCP Server Configuration\n * GitHub code search for real-world implementation examples\n */\nexport const grepApp = {\n type: \"remote\" as const,\n url: \"https://mcp.grep.app\",\n enabled: true,\n};\n","/**\n * Exa WebSearch MCP Server Configuration\n * Real-time web search for current articles, tutorials, and documentation\n *\n * API Key Setup:\n * 1. Get a free API key at: https://dashboard.exa.ai/api-keys\n * 2. Set the environment variable: export EXA_API_KEY=\"your-key\"\n */\nexport function createWebsearchMcp() {\n const apiKey = process.env.EXA_API_KEY;\n\n return {\n type: \"remote\" as const,\n url: \"https://mcp.exa.ai/mcp?tools=web_search_exa\",\n enabled: true,\n ...(apiKey && {\n headers: {\n \"x-api-key\": apiKey,\n },\n }),\n };\n}\n\nexport const websearch = createWebsearchMcp();\n","/**\n * MCP Server Configurations\n * Exports all MCP servers bundled with the Ask Agent plugin\n */\nimport { context7 } from \"./context7\";\nimport { grepApp } from \"./grep-app\";\nimport { createWebsearchMcp } from \"./websearch\";\n\nexport { context7 } from \"./context7\";\nexport { grepApp } from \"./grep-app\";\nexport { websearch, createWebsearchMcp } from \"./websearch\";\n\n/**\n * Creates the complete MCP configuration object for the plugin\n */\nexport function createBuiltinMcps() {\n return {\n context7,\n \"grep-app\": grepApp,\n websearch: createWebsearchMcp(),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKO,IAAM,mBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqEzB,SAAS,iBAAiB;AAC/B,SAAO;AAAA,IACL,aACE;AAAA,IACF,MAAM;AAAA,IACN,aAAa;AAAA,IACb,OAAO;AAAA,MACL,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,MACV,OAAO;AAAA,MACP,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA,YAAY;AAAA,MACV,OAAO;AAAA,MACP,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA,QAAQ;AAAA,EACV;AACF;;;AC7FO,IAAM,WAAW;AAAA,EACtB,MAAM;AAAA,EACN,KAAK;AAAA,EACL,SAAS;AACX;;;ACJO,IAAM,UAAU;AAAA,EACrB,MAAM;AAAA,EACN,KAAK;AAAA,EACL,SAAS;AACX;;;ACAO,SAAS,qBAAqB;AACnC,QAAM,SAAS,QAAQ,IAAI;AAE3B,SAAO;AAAA,IACL,MAAM;AAAA,IACN,KAAK;AAAA,IACL,SAAS;AAAA,IACT,GAAI,UAAU;AAAA,MACZ,SAAS;AAAA,QACP,aAAa;AAAA,MACf;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,YAAY,mBAAmB;;;ACRrC,SAAS,oBAAoB;AAClC,SAAO;AAAA,IACL;AAAA,IACA,YAAY;AAAA,IACZ,WAAW,mBAAmB;AAAA,EAChC;AACF;;;ALGO,IAAM,YAAoB,OAAO,SAAyB;AAE/D,SAAO,CAAC;AACV;AAOA,IAAO,gBAAQ;","names":[]}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
// src/agents/ask.ts
|
|
2
|
+
var ASK_AGENT_PROMPT = `You are a read-only code analyst and research assistant with brainstorming capabilities. Your purpose is to help users understand their codebase, find information, and explore ideas through collaborative discussion.
|
|
3
|
+
|
|
4
|
+
## Core Principles
|
|
5
|
+
|
|
6
|
+
- **Read-only**: You can only read files, search, and fetch web content. You cannot modify files, execute commands, or write new files.
|
|
7
|
+
- **Scope awareness**: Always respect the user's current working directory. If you need to access files outside the current scope, explicitly ask for permission first, you can always access files within or under the current scope.
|
|
8
|
+
- **Accuracy over speed**: Provide well-researched, accurate answers based on actual code content and documentation.
|
|
9
|
+
- **Web-enabled**: Use web search and fetch tools to find relevant documentation, best practices, and up-to-date information.
|
|
10
|
+
- **Creative collaboration**: When brainstorming, think creatively, suggest multiple approaches, and engage in dialogue to explore ideas thoroughly.
|
|
11
|
+
|
|
12
|
+
## Capabilities
|
|
13
|
+
|
|
14
|
+
1. **Codebase exploration**: Read files, search for patterns, explore project structure
|
|
15
|
+
2. **Code analysis**: Explain code logic, identify patterns, trace dependencies
|
|
16
|
+
3. **Web research**: Search the web for documentation, examples, and best practices
|
|
17
|
+
4. **Documentation lookup**: Fetch and synthesize information from official docs
|
|
18
|
+
5. **Brainstorming**: Discuss ideas, suggest features, explore alternatives, and collaborate on solutions
|
|
19
|
+
|
|
20
|
+
## External MCP Servers
|
|
21
|
+
|
|
22
|
+
- **websearch (Exa)**: Real-time web search. Use for current articles, discussions, tutorials, and bleeding-edge information.
|
|
23
|
+
- **context7**: Official documentation lookup. Use for authoritative API references and framework docs.
|
|
24
|
+
- **grep-app**: GitHub code search. Use for production-ready implementation patterns and real-world examples.
|
|
25
|
+
|
|
26
|
+
## Scope Guidelines
|
|
27
|
+
|
|
28
|
+
- **Current project scope**: You can freely read files within the current working directory
|
|
29
|
+
- **Outside scope**: If you need to access files outside the current project (e.g., user home, other projects), you MUST ask the user first:
|
|
30
|
+
- "I need to access [path] which is outside the current project. May I proceed?"
|
|
31
|
+
- Only access external files after explicit user confirmation
|
|
32
|
+
|
|
33
|
+
## Workflow
|
|
34
|
+
|
|
35
|
+
1. **Understand the question**: Clarify what the user is asking if needed
|
|
36
|
+
2. **Identify the approach**: Determine if this is code analysis, research, or brainstorming
|
|
37
|
+
3. **Explore/research**: Use glob, grep, and MCP tools as appropriate
|
|
38
|
+
4. **Read and analyze**: Read the most important files for context
|
|
39
|
+
5. **Synthesize**: Provide a clear, actionable answer
|
|
40
|
+
|
|
41
|
+
**For brainstorming specifically**:
|
|
42
|
+
|
|
43
|
+
- Acknowledge the idea or problem
|
|
44
|
+
- Ask clarifying questions to understand goals and constraints
|
|
45
|
+
- Suggest multiple approaches with trade-offs
|
|
46
|
+
- Explore alternatives together
|
|
47
|
+
- Help refine and prioritize ideas
|
|
48
|
+
|
|
49
|
+
## Response Guidelines
|
|
50
|
+
|
|
51
|
+
- Be concise but thorough
|
|
52
|
+
- Include relevant code snippets when helpful
|
|
53
|
+
- Reference specific file paths and line numbers (e.g., \`src/utils.ts:42\`)
|
|
54
|
+
- Suggest related files or areas to explore if relevant
|
|
55
|
+
- If you cannot answer with certainty, say so and suggest alternatives
|
|
56
|
+
|
|
57
|
+
## Limitations
|
|
58
|
+
|
|
59
|
+
If the user asks you to:
|
|
60
|
+
|
|
61
|
+
- Modify files
|
|
62
|
+
- Run commands
|
|
63
|
+
- Create new files
|
|
64
|
+
- Execute code
|
|
65
|
+
|
|
66
|
+
Politely explain that you are a read-only agent and suggest they switch to the Build or Plan agent for those tasks.`;
|
|
67
|
+
function createAskAgent() {
|
|
68
|
+
return {
|
|
69
|
+
description: "Answers questions about your codebase, provides insights based on code analysis, and brainstorm ideas with the user",
|
|
70
|
+
mode: "primary",
|
|
71
|
+
temperature: 0.6,
|
|
72
|
+
tools: {
|
|
73
|
+
read: true,
|
|
74
|
+
glob: true,
|
|
75
|
+
grep: true,
|
|
76
|
+
webfetch: true,
|
|
77
|
+
write: false,
|
|
78
|
+
edit: false,
|
|
79
|
+
bash: false,
|
|
80
|
+
task: false
|
|
81
|
+
},
|
|
82
|
+
permission: {
|
|
83
|
+
write: "deny",
|
|
84
|
+
edit: "deny",
|
|
85
|
+
bash: "deny"
|
|
86
|
+
},
|
|
87
|
+
prompt: ASK_AGENT_PROMPT
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// src/mcp/context7.ts
|
|
92
|
+
var context7 = {
|
|
93
|
+
type: "remote",
|
|
94
|
+
url: "https://mcp.context7.com/mcp",
|
|
95
|
+
enabled: true
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// src/mcp/grep-app.ts
|
|
99
|
+
var grepApp = {
|
|
100
|
+
type: "remote",
|
|
101
|
+
url: "https://mcp.grep.app",
|
|
102
|
+
enabled: true
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// src/mcp/websearch.ts
|
|
106
|
+
function createWebsearchMcp() {
|
|
107
|
+
const apiKey = process.env.EXA_API_KEY;
|
|
108
|
+
return {
|
|
109
|
+
type: "remote",
|
|
110
|
+
url: "https://mcp.exa.ai/mcp?tools=web_search_exa",
|
|
111
|
+
enabled: true,
|
|
112
|
+
...apiKey && {
|
|
113
|
+
headers: {
|
|
114
|
+
"x-api-key": apiKey
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
var websearch = createWebsearchMcp();
|
|
120
|
+
|
|
121
|
+
// src/mcp/index.ts
|
|
122
|
+
function createBuiltinMcps() {
|
|
123
|
+
return {
|
|
124
|
+
context7,
|
|
125
|
+
"grep-app": grepApp,
|
|
126
|
+
websearch: createWebsearchMcp()
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// src/index.ts
|
|
131
|
+
var AskPlugin = async (_ctx) => {
|
|
132
|
+
return {};
|
|
133
|
+
};
|
|
134
|
+
var index_default = AskPlugin;
|
|
135
|
+
export {
|
|
136
|
+
ASK_AGENT_PROMPT,
|
|
137
|
+
AskPlugin,
|
|
138
|
+
context7,
|
|
139
|
+
createAskAgent,
|
|
140
|
+
createBuiltinMcps,
|
|
141
|
+
index_default as default,
|
|
142
|
+
grepApp,
|
|
143
|
+
websearch
|
|
144
|
+
};
|
|
145
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/agents/ask.ts","../src/mcp/context7.ts","../src/mcp/grep-app.ts","../src/mcp/websearch.ts","../src/mcp/index.ts","../src/index.ts"],"sourcesContent":["/**\n * Ask Agent Definition\n * A read-only code analyst and research assistant with brainstorming capabilities\n */\n\nexport const ASK_AGENT_PROMPT = `You are a read-only code analyst and research assistant with brainstorming capabilities. Your purpose is to help users understand their codebase, find information, and explore ideas through collaborative discussion.\n\n## Core Principles\n\n- **Read-only**: You can only read files, search, and fetch web content. You cannot modify files, execute commands, or write new files.\n- **Scope awareness**: Always respect the user's current working directory. If you need to access files outside the current scope, explicitly ask for permission first, you can always access files within or under the current scope.\n- **Accuracy over speed**: Provide well-researched, accurate answers based on actual code content and documentation.\n- **Web-enabled**: Use web search and fetch tools to find relevant documentation, best practices, and up-to-date information.\n- **Creative collaboration**: When brainstorming, think creatively, suggest multiple approaches, and engage in dialogue to explore ideas thoroughly.\n\n## Capabilities\n\n1. **Codebase exploration**: Read files, search for patterns, explore project structure\n2. **Code analysis**: Explain code logic, identify patterns, trace dependencies\n3. **Web research**: Search the web for documentation, examples, and best practices\n4. **Documentation lookup**: Fetch and synthesize information from official docs\n5. **Brainstorming**: Discuss ideas, suggest features, explore alternatives, and collaborate on solutions\n\n## External MCP Servers\n\n- **websearch (Exa)**: Real-time web search. Use for current articles, discussions, tutorials, and bleeding-edge information.\n- **context7**: Official documentation lookup. Use for authoritative API references and framework docs.\n- **grep-app**: GitHub code search. Use for production-ready implementation patterns and real-world examples.\n\n## Scope Guidelines\n\n- **Current project scope**: You can freely read files within the current working directory\n- **Outside scope**: If you need to access files outside the current project (e.g., user home, other projects), you MUST ask the user first:\n - \"I need to access [path] which is outside the current project. May I proceed?\"\n - Only access external files after explicit user confirmation\n\n## Workflow\n\n1. **Understand the question**: Clarify what the user is asking if needed\n2. **Identify the approach**: Determine if this is code analysis, research, or brainstorming\n3. **Explore/research**: Use glob, grep, and MCP tools as appropriate\n4. **Read and analyze**: Read the most important files for context\n5. **Synthesize**: Provide a clear, actionable answer\n\n**For brainstorming specifically**:\n\n- Acknowledge the idea or problem\n- Ask clarifying questions to understand goals and constraints\n- Suggest multiple approaches with trade-offs\n- Explore alternatives together\n- Help refine and prioritize ideas\n\n## Response Guidelines\n\n- Be concise but thorough\n- Include relevant code snippets when helpful\n- Reference specific file paths and line numbers (e.g., \\`src/utils.ts:42\\`)\n- Suggest related files or areas to explore if relevant\n- If you cannot answer with certainty, say so and suggest alternatives\n\n## Limitations\n\nIf the user asks you to:\n\n- Modify files\n- Run commands\n- Create new files\n- Execute code\n\nPolitely explain that you are a read-only agent and suggest they switch to the Build or Plan agent for those tasks.`;\n\n/**\n * Creates the Ask agent configuration\n */\nexport function createAskAgent() {\n return {\n description:\n \"Answers questions about your codebase, provides insights based on code analysis, and brainstorm ideas with the user\",\n mode: \"primary\" as const,\n temperature: 0.6,\n tools: {\n read: true,\n glob: true,\n grep: true,\n webfetch: true,\n write: false,\n edit: false,\n bash: false,\n task: false,\n },\n permission: {\n write: \"deny\" as const,\n edit: \"deny\" as const,\n bash: \"deny\" as const,\n },\n prompt: ASK_AGENT_PROMPT,\n };\n}\n","/**\n * Context7 MCP Server Configuration\n * Official documentation lookup for libraries and frameworks\n */\nexport const context7 = {\n type: \"remote\" as const,\n url: \"https://mcp.context7.com/mcp\",\n enabled: true,\n};\n","/**\n * Grep.app MCP Server Configuration\n * GitHub code search for real-world implementation examples\n */\nexport const grepApp = {\n type: \"remote\" as const,\n url: \"https://mcp.grep.app\",\n enabled: true,\n};\n","/**\n * Exa WebSearch MCP Server Configuration\n * Real-time web search for current articles, tutorials, and documentation\n *\n * API Key Setup:\n * 1. Get a free API key at: https://dashboard.exa.ai/api-keys\n * 2. Set the environment variable: export EXA_API_KEY=\"your-key\"\n */\nexport function createWebsearchMcp() {\n const apiKey = process.env.EXA_API_KEY;\n\n return {\n type: \"remote\" as const,\n url: \"https://mcp.exa.ai/mcp?tools=web_search_exa\",\n enabled: true,\n ...(apiKey && {\n headers: {\n \"x-api-key\": apiKey,\n },\n }),\n };\n}\n\nexport const websearch = createWebsearchMcp();\n","/**\n * MCP Server Configurations\n * Exports all MCP servers bundled with the Ask Agent plugin\n */\nimport { context7 } from \"./context7\";\nimport { grepApp } from \"./grep-app\";\nimport { createWebsearchMcp } from \"./websearch\";\n\nexport { context7 } from \"./context7\";\nexport { grepApp } from \"./grep-app\";\nexport { websearch, createWebsearchMcp } from \"./websearch\";\n\n/**\n * Creates the complete MCP configuration object for the plugin\n */\nexport function createBuiltinMcps() {\n return {\n context7,\n \"grep-app\": grepApp,\n websearch: createWebsearchMcp(),\n };\n}\n","/**\n * OpenCode Ask Agent Plugin\n *\n * This plugin provides a minimal runtime hook for the Ask agent.\n * The actual agent and MCP configurations are installed via the CLI\n * into opencode.json.\n *\n * Installation:\n * npx opencode-ask-agent\n *\n * Or add to opencode.json:\n * { \"plugin\": [\"opencode-ask-agent\"] }\n *\n * @packageDocumentation\n */\nimport type { Plugin, Hooks } from \"@opencode-ai/plugin\";\n\n/**\n * The Ask Agent plugin\n *\n * This is a minimal plugin that can be extended with hooks.\n * The main functionality (agent + MCPs) is configured via opencode.json\n * by the CLI installer.\n */\nexport const AskPlugin: Plugin = async (_ctx): Promise<Hooks> => {\n // Return empty hooks - agent/MCP config is in opencode.json\n return {};\n};\n\n// Re-export components for programmatic usage\nexport { createAskAgent, ASK_AGENT_PROMPT } from \"./agents\";\nexport { createBuiltinMcps, context7, grepApp, websearch } from \"./mcp\";\n\n// Default export\nexport default AskPlugin;\n"],"mappings":";AAKO,IAAM,mBAAmB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqEzB,SAAS,iBAAiB;AAC/B,SAAO;AAAA,IACL,aACE;AAAA,IACF,MAAM;AAAA,IACN,aAAa;AAAA,IACb,OAAO;AAAA,MACL,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,MACV,OAAO;AAAA,MACP,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA,YAAY;AAAA,MACV,OAAO;AAAA,MACP,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA,QAAQ;AAAA,EACV;AACF;;;AC7FO,IAAM,WAAW;AAAA,EACtB,MAAM;AAAA,EACN,KAAK;AAAA,EACL,SAAS;AACX;;;ACJO,IAAM,UAAU;AAAA,EACrB,MAAM;AAAA,EACN,KAAK;AAAA,EACL,SAAS;AACX;;;ACAO,SAAS,qBAAqB;AACnC,QAAM,SAAS,QAAQ,IAAI;AAE3B,SAAO;AAAA,IACL,MAAM;AAAA,IACN,KAAK;AAAA,IACL,SAAS;AAAA,IACT,GAAI,UAAU;AAAA,MACZ,SAAS;AAAA,QACP,aAAa;AAAA,MACf;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,YAAY,mBAAmB;;;ACRrC,SAAS,oBAAoB;AAClC,SAAO;AAAA,IACL;AAAA,IACA,YAAY;AAAA,IACZ,WAAW,mBAAmB;AAAA,EAChC;AACF;;;ACGO,IAAM,YAAoB,OAAO,SAAyB;AAE/D,SAAO,CAAC;AACV;AAOA,IAAO,gBAAQ;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "opencode-ask-agent",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Read-only Ask agent for OpenCode with web research capabilities",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"opencode-ask-agent": "./dist/cli/index.js"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsup",
|
|
13
|
+
"dev": "tsup --watch",
|
|
14
|
+
"typecheck": "tsc --noEmit",
|
|
15
|
+
"prepublishOnly": "npm run build"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"opencode",
|
|
19
|
+
"agent",
|
|
20
|
+
"mcp",
|
|
21
|
+
"ai",
|
|
22
|
+
"code-analysis",
|
|
23
|
+
"research",
|
|
24
|
+
"brainstorming"
|
|
25
|
+
],
|
|
26
|
+
"author": "Israel Toledo",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git+https://github.com/israeltoledo/opencode-ask-agent.git"
|
|
31
|
+
},
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/israeltoledo/opencode-ask-agent/issues"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://github.com/israeltoledo/opencode-ask-agent#readme",
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"@opencode-ai/plugin": "^1.0.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@opencode-ai/plugin": "^1.1.20",
|
|
41
|
+
"@types/node": "^22.0.0",
|
|
42
|
+
"tsup": "^8.0.0",
|
|
43
|
+
"typescript": "^5.7.0"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@clack/prompts": "^0.11.0",
|
|
47
|
+
"picocolors": "^1.1.0"
|
|
48
|
+
},
|
|
49
|
+
"files": [
|
|
50
|
+
"dist",
|
|
51
|
+
"agents",
|
|
52
|
+
"README.md",
|
|
53
|
+
"LICENSE"
|
|
54
|
+
],
|
|
55
|
+
"engines": {
|
|
56
|
+
"node": ">=18.0.0"
|
|
57
|
+
}
|
|
58
|
+
}
|