opencode-architect 0.2.4 → 0.4.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/README.md +78 -18
- package/agent-loader.ts +98 -0
- package/assets/agents/opencode-agent-designer.md +13 -47
- package/assets/agents/opencode-architect.md +60 -244
- package/assets/agents/opencode-command-crafter.md +9 -27
- package/assets/agents/opencode-extension-auditor.md +25 -36
- package/assets/agents/opencode-mcp-integrator.md +13 -17
- package/assets/agents/opencode-packager.md +31 -203
- package/assets/agents/opencode-plugin-engineer.md +16 -29
- package/assets/agents/opencode-publisher.md +27 -206
- package/assets/agents/opencode-skill-creator.md +15 -35
- package/assets/agents/opencode-tool-builder.md +13 -17
- package/assets/references/agents.md +68 -0
- package/assets/references/commands.md +49 -0
- package/assets/references/config.md +50 -0
- package/assets/references/mcp-servers.md +55 -0
- package/assets/references/opencode-architect-oneshots.md +19 -58
- package/assets/references/plugins.md +76 -0
- package/assets/references/prompt-engineering.md +46 -0
- package/assets/references/skills.md +55 -0
- package/assets/references/tools.md +49 -0
- package/assets/templates/skill-structure.template.md +4 -4
- package/cli.ts +120 -0
- package/index.ts +4 -103
- package/installer.ts +319 -0
- package/package.json +30 -8
- package/assets/templates/package-analysis.template.md +0 -60
- package/commands/sync-docs.ts +0 -9
- package/scripts/fetch-opencode-docs.ts +0 -193
- package/scripts/logger.ts +0 -20
- package/tools/sync-docs.ts +0 -24
package/README.md
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
# opencode-architect
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/opencode-architect)
|
|
4
|
+
[](./LICENSE.md)
|
|
5
|
+
[](https://opencode.ai/docs/plugins)
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
**Ten specialist agents that design, build, and package OpenCode extensions — agent skills, slash commands, custom tools, plugins, and MCP server integrations — right inside your AI coding assistant.**
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
opencode-architect is an [OpenCode](https://opencode.ai) plugin and CLI that ships a suite of AI agent experts for OpenCode work: designing agents, creating skills and slash commands, building plugins and custom tools, integrating MCP servers, and packaging extensions for npm. Install it once and every specialist agent is available in your coding sessions.
|
|
10
|
+
|
|
11
|
+
## Quick start: install the OpenCode plugin suite
|
|
12
|
+
|
|
13
|
+
### Option 1 — Install as an OpenCode plugin
|
|
14
|
+
|
|
15
|
+
Add the package to the `plugin` array in your OpenCode config — `.opencode/opencode.json` in your project, or `~/.config/opencode/opencode.json` for all projects:
|
|
8
16
|
|
|
9
17
|
```json
|
|
10
18
|
{
|
|
@@ -12,27 +20,73 @@ Add to "plugin" in `.opencode/opencode.json`:
|
|
|
12
20
|
}
|
|
13
21
|
```
|
|
14
22
|
|
|
15
|
-
|
|
23
|
+
The plugin registers the full agent suite at startup, with self-contained bundled references — no network sync.
|
|
24
|
+
|
|
25
|
+
### Option 2 — Install with the CLI (bunx or npx)
|
|
26
|
+
|
|
27
|
+
Copy the agents, references, and templates straight into your OpenCode directories, where you can read and modify every file:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
# Project scope (default): copies into ./.opencode/
|
|
31
|
+
bunx opencode-architect install
|
|
32
|
+
|
|
33
|
+
# Global scope: copies into ~/.config/opencode/
|
|
34
|
+
bunx opencode-architect install --scope global
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
`npx opencode-architect install` works the same way if you prefer npm's runner.
|
|
38
|
+
|
|
39
|
+
Useful flags and commands:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
bunx opencode-architect status # show install mode and version for a scope
|
|
43
|
+
bunx opencode-architect uninstall # remove exactly the files a copy install wrote
|
|
44
|
+
bunx opencode-architect install --force # overwrite locally modified files, switch a scope from plugin to copy install
|
|
45
|
+
bunx opencode-architect --help # full usage
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
A copy install writes 10 agents into `agents/`, 9 reference docs into `opencode-architect/references/`, and 9 starter templates into `opencode-architect/templates/` of the scope base, plus an `opencode-architect.json` manifest that tracks versions and file hashes for safe upgrades. Relative reference paths inside agents are rewritten to absolute paths at install time.
|
|
49
|
+
|
|
50
|
+
Plugin install and copy install are mutually exclusive per scope — the CLI refuses to copy over an existing plugin entry unless you pass `--force`.
|
|
51
|
+
|
|
52
|
+
## What you get: ten specialist OpenCode agents
|
|
53
|
+
|
|
54
|
+
Ten specialist agents, one router:
|
|
16
55
|
|
|
17
|
-
|
|
56
|
+
| Agent | What it does |
|
|
57
|
+
| --- | --- |
|
|
58
|
+
| `opencode-architect` | Routes OpenCode meta tasks to the right specialist — agents, skills, commands, tools, plugins, MCP setup, packaging, publishing |
|
|
59
|
+
| `opencode-agent-designer` | Designs OpenCode agents and orchestrator subagents — roles, constraints, tools, permissions |
|
|
60
|
+
| `opencode-skill-creator` | Creates OpenCode skills in `.opencode/skills` — SKILL.md, frontmatter, progressive disclosure |
|
|
61
|
+
| `opencode-command-crafter` | Creates OpenCode slash commands in `.opencode/commands` — prompt templates, `$ARGUMENTS`, frontmatter |
|
|
62
|
+
| `opencode-tool-builder` | Creates OpenCode custom tools in `.opencode/tools` — Zod schemas and execute logic |
|
|
63
|
+
| `opencode-plugin-engineer` | Builds OpenCode plugins in `.opencode/plugins` — event hooks, custom tools, TypeScript |
|
|
64
|
+
| `opencode-mcp-integrator` | Configures MCP servers and tool scoping in `opencode.json` — local/remote servers, permissions |
|
|
65
|
+
| `opencode-packager` | Packages OpenCode extensions for local sharing across projects — `file:///` plugin packages |
|
|
66
|
+
| `opencode-publisher` | Publishes OpenCode extensions to npm — transforms local packages into distributable ones |
|
|
67
|
+
| `opencode-extension-auditor` | Analyzes `.opencode/` contents and reports packaging readiness — inventory, dependencies, complications |
|
|
18
68
|
|
|
19
|
-
|
|
69
|
+
Also bundled and installed with the agents:
|
|
20
70
|
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
- Automatic doc sync on startup with a toast error if the sync fails
|
|
24
|
-
- Built-in alignment with OpenCode best practices for coding and prompt engineering
|
|
71
|
+
- **References** — self-contained docs covering stable OpenCode fundamentals: agents, commands, config, MCP servers, plugins, prompt engineering, skills, tools, plus worked one-shot examples
|
|
72
|
+
- **Templates** — starter files for new skills, plugins, package manifests, and TypeScript configs
|
|
25
73
|
|
|
26
|
-
##
|
|
74
|
+
## When to use these OpenCode agents
|
|
27
75
|
|
|
28
|
-
|
|
76
|
+
Reach for opencode-architect whenever you want to:
|
|
29
77
|
|
|
30
|
-
- Spin up new OpenCode agents
|
|
31
|
-
-
|
|
32
|
-
-
|
|
33
|
-
- Integrate MCP servers with confidence
|
|
78
|
+
- Spin up new OpenCode agents with consistent frontmatter and tool permissions
|
|
79
|
+
- Create agent skills and slash commands with solid prompt engineering
|
|
80
|
+
- Build OpenCode plugins and custom tools in TypeScript
|
|
81
|
+
- Integrate MCP servers into your OpenCode setup with confidence
|
|
82
|
+
- Package and publish your extensions so other developers can install them
|
|
34
83
|
|
|
35
|
-
##
|
|
84
|
+
## Requirements
|
|
85
|
+
|
|
86
|
+
- [OpenCode](https://opencode.ai) — the AI coding assistant the plugin extends
|
|
87
|
+
- [Bun](https://bun.sh) — runs the plugin and the CLI (`bunx`); if you use `npx`, Bun must still be on your `PATH` because the CLI ships as TypeScript
|
|
88
|
+
|
|
89
|
+
## Development
|
|
36
90
|
|
|
37
91
|
Install dependencies:
|
|
38
92
|
|
|
@@ -46,7 +100,13 @@ Type check:
|
|
|
46
100
|
bun run check
|
|
47
101
|
```
|
|
48
102
|
|
|
49
|
-
|
|
103
|
+
Run the test suite:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
bun test
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Acknowledgements
|
|
50
110
|
|
|
51
111
|
- [OpenCode](https://opencode.ai) - The AI coding assistant that makes this plugin possible
|
|
52
112
|
- [Bun](https://bun.sh) - The fast all-in-one JavaScript runtime
|
package/agent-loader.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { parse as parseYaml } from "yaml";
|
|
4
|
+
import type { AgentConfig } from "@opencode-ai/sdk";
|
|
5
|
+
|
|
6
|
+
export const AGENT_FILENAMES: readonly string[] = [
|
|
7
|
+
"opencode-agent-designer.md",
|
|
8
|
+
"opencode-architect.md",
|
|
9
|
+
"opencode-command-crafter.md",
|
|
10
|
+
"opencode-extension-auditor.md",
|
|
11
|
+
"opencode-packager.md",
|
|
12
|
+
"opencode-publisher.md",
|
|
13
|
+
"opencode-mcp-integrator.md",
|
|
14
|
+
"opencode-plugin-engineer.md",
|
|
15
|
+
"opencode-skill-creator.md",
|
|
16
|
+
"opencode-tool-builder.md",
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
const FRONTMATTER_REGEX = /^---\r?\n([\s\S]*?)\r?\n---\r?\n([\s\S]*)$/;
|
|
20
|
+
export const RELATIVE_REFERENCE_REGEX = /`((?:\.{1,2})(?:[\\/][^`\\/]+)+)`/g;
|
|
21
|
+
|
|
22
|
+
interface AgentFrontmatter {
|
|
23
|
+
description: string;
|
|
24
|
+
mode: "primary" | "subagent" | "all";
|
|
25
|
+
tools?: Record<string, boolean>;
|
|
26
|
+
permission?: {
|
|
27
|
+
edit?: "ask" | "allow" | "deny";
|
|
28
|
+
bash?: ("ask" | "allow" | "deny") | Record<string, "ask" | "allow" | "deny">;
|
|
29
|
+
webfetch?: "ask" | "allow" | "deny";
|
|
30
|
+
doom_loop?: "ask" | "allow" | "deny";
|
|
31
|
+
external_directory?: "ask" | "allow" | "deny";
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export class AgentLoader {
|
|
36
|
+
private readonly agentsDir: string;
|
|
37
|
+
|
|
38
|
+
public constructor(agentsDir: string) {
|
|
39
|
+
this.agentsDir = agentsDir;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public async loadAgents(): Promise<Record<string, AgentConfig>> {
|
|
43
|
+
const agents: Record<string, AgentConfig> = {};
|
|
44
|
+
|
|
45
|
+
for (const filename of AGENT_FILENAMES) {
|
|
46
|
+
const agentPath = path.join(this.agentsDir, filename);
|
|
47
|
+
const agentContent = await readFile(agentPath, "utf-8");
|
|
48
|
+
const agentName = path.basename(filename, ".md");
|
|
49
|
+
agents[agentName] = await this.parseAgentMarkdown(agentPath, agentContent, agentName);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return agents;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
private async parseAgentMarkdown(
|
|
56
|
+
agentPath: string,
|
|
57
|
+
content: string,
|
|
58
|
+
agentName: string,
|
|
59
|
+
): Promise<AgentConfig> {
|
|
60
|
+
const match = content.match(FRONTMATTER_REGEX);
|
|
61
|
+
|
|
62
|
+
if (!match || match.length < 3) {
|
|
63
|
+
throw new Error(`Agent ${agentName} must have YAML frontmatter`);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const frontmatterYaml = match[1] as string;
|
|
67
|
+
const rawPrompt = match[2] as string;
|
|
68
|
+
const frontmatter = parseYaml(frontmatterYaml) as AgentFrontmatter;
|
|
69
|
+
const prompt = this.resolveReferencePaths(
|
|
70
|
+
rawPrompt.replace(/^\r?\n/, ""),
|
|
71
|
+
path.dirname(agentPath),
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
const config: AgentConfig = {
|
|
75
|
+
description: frontmatter.description,
|
|
76
|
+
mode: frontmatter.mode,
|
|
77
|
+
prompt,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
if (frontmatter.tools) {
|
|
81
|
+
config.tools = frontmatter.tools;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (frontmatter.permission) {
|
|
85
|
+
config.permission = frontmatter.permission;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return config;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
private resolveReferencePaths(prompt: string, agentDir: string): string {
|
|
92
|
+
return prompt.replace(RELATIVE_REFERENCE_REGEX, (_token: string, relativePath: string) => {
|
|
93
|
+
const normalized = relativePath.replaceAll("\\", "/");
|
|
94
|
+
const absolute = path.resolve(agentDir, normalized).replaceAll("\\", "/");
|
|
95
|
+
return `\`${absolute}\``;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: Designs OpenCode agents and orchestrator subagents
|
|
2
|
+
description: Designs OpenCode agents and orchestrator subagents - roles, constraints, tools, permissions
|
|
3
3
|
mode: subagent
|
|
4
4
|
tools:
|
|
5
5
|
read: true
|
|
@@ -10,53 +10,19 @@ tools:
|
|
|
10
10
|
bash: false
|
|
11
11
|
---
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Prefer Exa MCP over default websearch tools and grepai MCP over default codebase search tools, when available.
|
|
14
14
|
|
|
15
|
-
You create or refine OpenCode agents in
|
|
15
|
+
You create or refine OpenCode agents in `.opencode/agents/` as Markdown with YAML frontmatter; the filename becomes the agent name.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
## Workflow
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
1. Read `../references/prompt-engineering.md` for prompt-engineering techniques before drafting anything.
|
|
20
|
+
2. Consult `../references/agents.md` for agent fields, modes, tools, and permissions; `../references/tools.md` for tool IDs and behavior; `../references/config.md` for config precedence and defaults.
|
|
21
|
+
3. Write the frontmatter: description (required), mode (primary or subagent - set it explicitly), model (only when the user names one), temperature, maxSteps, tools, permission, hidden, as needed.
|
|
22
|
+
4. Write the prompt in this order: role and scope boundaries first, then expected inputs and output format, then direct, specific instructions.
|
|
23
|
+
5. Reinforce the instructions where they fit: structure with headings and lists, critical instructions at the end, examples for ambiguous tasks and output formats, explicit constraints, structured outputs (JSON, XML) where precise parsing is needed, reasoning prompts for multi-step tasks, persistent context and persona for primary agents.
|
|
24
|
+
6. Scope capability to the job: tools block enables or disables specific tools, permission gates edit, bash, or webfetch, permission.task limits which subagents run, and the prompt scans no wider than the job requires.
|
|
25
|
+
7. For a new agent, add one line describing it to `.opencode/AGENTS.md`.
|
|
26
|
+
8. Verify: fields valid per the references, role stated in one sentence, inputs and output format defined.
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
- tools block enables or disables specific tools.
|
|
28
|
-
- permission can deny or ask for edit, bash, or webfetch.
|
|
29
|
-
- task permissions can scope which subagents are allowed.
|
|
30
|
-
|
|
31
|
-
Prompt design
|
|
32
|
-
|
|
33
|
-
- Declare role and what the agent must not do.
|
|
34
|
-
- Define inputs expected and output format.
|
|
35
|
-
- Keep instructions concise and actionable.
|
|
36
|
-
- Avoid repo-wide scans unless required.
|
|
37
|
-
|
|
38
|
-
Prompting best practices
|
|
39
|
-
|
|
40
|
-
- Put critical instructions at the end of the prompt for emphasis.
|
|
41
|
-
- Use markdown structure (headings, lists) for complex prompts.
|
|
42
|
-
- Be direct and specific rather than verbose; Claude 4 handles terse instructions well.
|
|
43
|
-
- Provide examples for ambiguous tasks or desired output formats.
|
|
44
|
-
- Use system prompts to establish persistent context and persona.
|
|
45
|
-
- Set explicit constraints and boundaries to scope agent behavior.
|
|
46
|
-
- Leverage structured outputs (JSON, XML) when precise parsing is needed.
|
|
47
|
-
- Include thinking or reasoning prompts for multi-step tasks.
|
|
48
|
-
|
|
49
|
-
Deliverables
|
|
50
|
-
|
|
51
|
-
- Create or update the agent file.
|
|
52
|
-
- If adding a new agent, add a short line to '.opencode/AGENTS.md' describing it.
|
|
53
|
-
|
|
54
|
-
Docs usage
|
|
55
|
-
|
|
56
|
-
- Use '~/.cache/opencode/opencode-architect/docs/agents.md' for agent fields, modes, tools, and permissions.
|
|
57
|
-
- Use '~/.cache/opencode/opencode-architect/docs/tools.md' for available tool IDs and behavior.
|
|
58
|
-
- Use '~/.cache/opencode/opencode-architect/docs/config.md' for agent config precedence and defaults.
|
|
59
|
-
|
|
60
|
-
Required reading
|
|
61
|
-
|
|
62
|
-
Before writing or editing any agent prompt, you MUST read '~/.cache/opencode/opencode-architect/docs/claude-4-best-practices.md' for prompt engineering techniques. Do not skip this step.
|
|
28
|
+
Done when the agent file loads with valid frontmatter and a prompt that names role, inputs, and output format.
|