opencode-ask 1.1.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.
Files changed (3) hide show
  1. package/README.md +89 -0
  2. package/ask.js +65 -0
  3. package/package.json +28 -0
package/README.md ADDED
@@ -0,0 +1,89 @@
1
+ # Ask — Code Q&A for OpenCode
2
+
3
+ Ask is a read-only Q&A agent for [OpenCode](https://opencode.ai). It answers questions about your codebase — explains how things work, finds relevant code, explores architecture, and provides deep insights — without ever editing your files.
4
+
5
+ Powered by your existing OpenCode model. No extra API keys. No subscriptions.
6
+
7
+ ---
8
+
9
+ ## Quick Start
10
+
11
+ ### Install
12
+
13
+ 1. Clone this repo or download `ask.js`
14
+ 2. Copy or symlink `ask.js` to your OpenCode config plugins:
15
+ ```bash
16
+ mkdir -p ~/.config/opencode/plugins
17
+ cp ask.js ~/.config/opencode/plugins/ask.js
18
+ ```
19
+ 3. Add to `~/.config/opencode/opencode.json`:
20
+ ```json
21
+ {
22
+ "plugin": ["./plugins/ask.js"]
23
+ }
24
+ ```
25
+ 4. Restart OpenCode.
26
+
27
+ ### Use
28
+
29
+ Ask is available both as a **general agent** (selectable in OpenCode's agent picker) and via `@ask` in any conversation:
30
+
31
+ - **General mode** — Select "Ask" from the agent list for a dedicated Q&A session
32
+ - **Subagent mode** — Type `@ask how does collision work?` mid-conversation
33
+
34
+ Ask will explore the codebase, gather context, and give you a thorough answer — complete with file paths, line numbers, and architectural context.
35
+
36
+ ---
37
+
38
+ ## How It Works
39
+
40
+ Ask is an OpenCode plugin that registers a `subagent` named `ask`. When invoked, the agent:
41
+
42
+ 1. **Explores** — searches your codebase with grep, glob, and targeted file reads
43
+ 2. **Analyzes** — traces code paths, understands architecture, identifies patterns
44
+ 3. **Answers** — provides a clear, structured response with source citations
45
+ 4. **Never edits** — the agent has `edit: deny` and `write: deny` baked in
46
+
47
+ ---
48
+
49
+ ## vs. GitHub Copilot `/ask`
50
+
51
+ | | GitHub Copilot `/ask` | OpenCode **Ask** |
52
+ |---|---|---|
53
+ | **Scope** | Current file + editor selection | Full workspace exploration |
54
+ | **Search tools** | None (inline context only) | grep, glob, read, bash, web |
55
+ | **Architecture awareness** | Limited to visible code | Deep — traces across files and layers |
56
+ | **Permission model** | Read-only by convention | Enforced: `edit: deny`, `write: deny` |
57
+ | **Invocation** | In-editor chat panel | `@ask` in any OpenCode conversation |
58
+ | **Model** | Copilot's model | Your configured OpenCode model |
59
+ | **Subagent dispatch** | No | Yes — can delegate parallel searches via `task` |
60
+ | **Custom prompt** | Fixed | Open source — fork and customize |
61
+ | **Offline** | No (cloud only) | Depends on your model provider |
62
+
63
+ ### When to use which
64
+
65
+ **Use Copilot `/ask`** when you need a quick answer about the file or selection you're actively editing — minimal context switching.
66
+
67
+ **Use OpenCode Ask** when you need deep understanding — tracing logic across many files, understanding architecture, investigating bugs, or orienting yourself in an unfamiliar codebase.
68
+
69
+ ---
70
+
71
+ ## Permissions
72
+
73
+ | Tool | Access |
74
+ |------|--------|
75
+ | `read` | `allow` |
76
+ | `grep` | `allow` |
77
+ | `glob` | `allow` |
78
+ | `bash` | `git *: allow, *: ask` |
79
+ | `webfetch` | `allow` |
80
+ | `websearch` | `allow` |
81
+ | `task` | `allow` |
82
+ | `edit` | `deny` |
83
+ | `write` | `deny` |
84
+
85
+ ---
86
+
87
+ ## License
88
+
89
+ MIT
package/ask.js ADDED
@@ -0,0 +1,65 @@
1
+ const PROMPT = `You are Ask, a specialized code Q&A agent for OpenCode.
2
+
3
+ Your purpose is to answer questions about the codebase — explain how things work,
4
+ find relevant code, explore architecture, and provide deep insights.
5
+ You NEVER write or edit code. You are an answerer, not a doer.
6
+
7
+ ## Core Behavior
8
+
9
+ 1. **Explore before answering** — Use grep, glob, read, and bash (git) to gather
10
+ full context before formulating answers. Don't rely on a single search hit.
11
+
12
+ 2. **Cite sources** — Always include specific file paths and line numbers.
13
+ Example: \`src/core/auth.ts:45-60\`. If code is spread across multiple files,
14
+ reference each one.
15
+
16
+ 3. **Explain the "why"** — Don't just describe what code does. Explain the
17
+ design decisions, trade-offs, and architectural context that led to it.
18
+
19
+ 4. **Be thorough** — Cover edge cases, error paths, and related code. If
20
+ something looks important, dig deeper with additional reads.
21
+
22
+ 5. **Be humble** — If uncertain, say so. Suggest what additional context would
23
+ help provide a definitive answer.
24
+
25
+ 6. **Think conversationally** — Ask clarifying questions when the intent is
26
+ unclear. Build on previous context in the same session.
27
+
28
+ ## Response Format
29
+
30
+ - Start with a brief answer summary (1-2 sentences)
31
+ - Follow with detailed explanation and code references
32
+ - Use code blocks for relevant snippets
33
+ - End with a follow-up prompt if appropriate
34
+
35
+ ## Restrictions
36
+
37
+ - NEVER use edit or write tools
38
+ - If asked to make changes, politely redirect: "I'm a Q&A agent — I can help
39
+ you understand this code. OpenCode's main agent can make the change."
40
+ - Do not generate boilerplate or scaffold new files`
41
+
42
+ export default async () => {
43
+ return {
44
+ config: (cfg) => {
45
+ cfg.agent = cfg.agent || {}
46
+ cfg.agent["ask"] = {
47
+ mode: "all",
48
+ description:
49
+ "Ask questions about your codebase — explores, explains architecture, finds relevant code, and provides insights. Read-only. No edits.",
50
+ permission: {
51
+ edit: "deny",
52
+ write: "deny",
53
+ read: "allow",
54
+ grep: "allow",
55
+ glob: "allow",
56
+ bash: { "git *": "allow", "*": "ask" },
57
+ webfetch: "allow",
58
+ websearch: "allow",
59
+ task: "allow",
60
+ },
61
+ prompt: PROMPT,
62
+ }
63
+ },
64
+ }
65
+ }
package/package.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "opencode-ask",
3
+ "version": "1.1.0",
4
+ "description": "Ask Agent for OpenCode — Q&A about your codebase, inspired by GitHub Copilot's /ask",
5
+ "main": "ask.js",
6
+ "files": [
7
+ "ask.js",
8
+ "README.md"
9
+ ],
10
+ "type": "module",
11
+ "keywords": [
12
+ "opencode",
13
+ "plugin",
14
+ "ask",
15
+ "qna",
16
+ "code-review"
17
+ ],
18
+ "license": "MIT",
19
+ "author": "RASHEEM",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/MRZ07/ask.git"
23
+ },
24
+ "publishConfig": {
25
+ "registry": "https://registry.npmjs.org",
26
+ "access": "public"
27
+ }
28
+ }