opencode-orchestrator-plugin 1.0.0-beta.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 +202 -0
- package/README.md +130 -0
- package/README.test.md +51 -0
- package/dist/commands/implement.d.ts +1 -0
- package/dist/commands/implement.js +30 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +153 -0
- package/dist/prompts/agent/implementer.md +22 -0
- package/dist/prompts/agent/orchestrator.md +35 -0
- package/dist/prompts/agent.md +23 -0
- package/dist/prompts/orchestrator/implement.json +4 -0
- package/dist/prompts/orchestrator/newTrack.json +4 -0
- package/dist/prompts/orchestrator/revert.json +4 -0
- package/dist/prompts/orchestrator/setup.json +4 -0
- package/dist/prompts/orchestrator/status.json +4 -0
- package/dist/prompts/strategies/delegate.md +11 -0
- package/dist/prompts/strategies/manual.md +9 -0
- package/dist/templates/code_styleguides/c.md +28 -0
- package/dist/templates/code_styleguides/cpp.md +46 -0
- package/dist/templates/code_styleguides/csharp.md +115 -0
- package/dist/templates/code_styleguides/dart.md +238 -0
- package/dist/templates/code_styleguides/general.md +23 -0
- package/dist/templates/code_styleguides/go.md +48 -0
- package/dist/templates/code_styleguides/html-css.md +49 -0
- package/dist/templates/code_styleguides/java.md +39 -0
- package/dist/templates/code_styleguides/javascript.md +51 -0
- package/dist/templates/code_styleguides/julia.md +27 -0
- package/dist/templates/code_styleguides/kotlin.md +41 -0
- package/dist/templates/code_styleguides/php.md +37 -0
- package/dist/templates/code_styleguides/python.md +37 -0
- package/dist/templates/code_styleguides/react.md +37 -0
- package/dist/templates/code_styleguides/ruby.md +39 -0
- package/dist/templates/code_styleguides/rust.md +44 -0
- package/dist/templates/code_styleguides/shell.md +35 -0
- package/dist/templates/code_styleguides/solidity.md +60 -0
- package/dist/templates/code_styleguides/sql.md +39 -0
- package/dist/templates/code_styleguides/swift.md +36 -0
- package/dist/templates/code_styleguides/typescript.md +43 -0
- package/dist/templates/code_styleguides/vue.md +38 -0
- package/dist/templates/code_styleguides/zig.md +27 -0
- package/dist/templates/workflow.md +336 -0
- package/dist/tools/background.d.ts +54 -0
- package/dist/tools/background.js +198 -0
- package/dist/tools/commands.d.ts +11 -0
- package/dist/tools/commands.js +80 -0
- package/dist/tools/commands.test.d.ts +1 -0
- package/dist/tools/commands.test.js +145 -0
- package/dist/tools/delegate.d.ts +3 -0
- package/dist/tools/delegate.js +45 -0
- package/dist/utils/bootstrap.d.ts +1 -0
- package/dist/utils/bootstrap.js +46 -0
- package/dist/utils/commandFactory.d.ts +11 -0
- package/dist/utils/commandFactory.js +69 -0
- package/dist/utils/stateManager.d.ts +10 -0
- package/dist/utils/stateManager.js +30 -0
- package/package.json +88 -0
- package/scripts/convert-legacy.cjs +17 -0
- package/scripts/postinstall.cjs +38 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# Orchestrator Plugin for OpenCode
|
|
2
|
+
|
|
3
|
+
> **Measure twice, code once.**
|
|
4
|
+
|
|
5
|
+
Orchestrator is a specialized OpenCode plugin designed to enforce a rigorous, **Context-Driven Development** lifecycle. It transforms OpenCode from a reactive coding tool into a proactive project architect that follows a strict protocol to specify, plan, and implement software features and bug fixes.
|
|
6
|
+
|
|
7
|
+
Note: Slash commands now use the `/orchestrator:*` prefix to differentiate this rebranded plugin from the original opencode-conductor project. This plugin is OpenCode-only and does not target Gemini CLI.
|
|
8
|
+
|
|
9
|
+
The philosophy is simple: **control your code by controlling your context.** By treating project requirements and plans as managed artifacts, Orchestrator ensures every agent interaction is grounded in deep, persistent project awareness.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 🚀 Key Features
|
|
14
|
+
|
|
15
|
+
* **Specialized `@orchestrator` Agent**: A dedicated subagent that acts as your Project Architect and Technical Lead.
|
|
16
|
+
* **Native Slash Commands**: Integrated shortcuts like `/orchestrator:setup`, `/orchestrator:newTrack`, and `/orchestrator:implement` for frictionless project management.
|
|
17
|
+
* **Modern Permissions**: Fully compatible with OpenCode v1.1.1 granular permission system.
|
|
18
|
+
* **Protocol-Driven Workflow**: Automated enforcement of the **Context -> Spec -> Plan -> Implement** lifecycle.
|
|
19
|
+
* **Smart Revert**: A Git-aware revert system that understands logical units of work (Tracks, Phases, Tasks) instead of just raw commit hashes.
|
|
20
|
+
* **19+ Style Templates**: Built-in support for a vast range of languages including Rust, Solidity, Zig, Julia, Kotlin, Swift, and more.
|
|
21
|
+
* **Zero-Config Bootstrap**: Automatically installs agents and commands to your global OpenCode configuration on first run.
|
|
22
|
+
* **Sisyphus Synergy**: Optimized to work alongside [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode) for a multi-agent team experience.
|
|
23
|
+
* **Agent Agnostic**: Commands can be invoked by any agent, giving you the freedom to choose your primary interface.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 🛠️ The Orchestrator Lifecycle
|
|
28
|
+
|
|
29
|
+
Orchestrator organizes your work into **Tracks** (features or bug fixes). Every Track follows three mandatory phases:
|
|
30
|
+
|
|
31
|
+
### 1. Project Initialization (`/orchestrator:setup`)
|
|
32
|
+
Run this once per project. The agent will interview you to define:
|
|
33
|
+
* **Product Vision**: Target users, core goals, and primary features.
|
|
34
|
+
* **Tech Stack**: Languages, frameworks, and databases.
|
|
35
|
+
* **Workflow Rules**: Testing standards (e.g., TDD), commit strategies, and documentation patterns.
|
|
36
|
+
|
|
37
|
+
### 2. Track Planning (`/orchestrator:newTrack`)
|
|
38
|
+
When you're ready for a new task, tell the agent what you want to build.
|
|
39
|
+
* **Specification (`spec.md`)**: Orchestrator asks 3-5 targeted questions to clarify the "What" and "Why".
|
|
40
|
+
* **Implementation Plan (`plan.md`)**: Once the spec is approved, Orchestrator generates a step-by-step checklist adhering to your project's workflow rules.
|
|
41
|
+
|
|
42
|
+
### 3. Autonomous Implementation (`/orchestrator:implement`)
|
|
43
|
+
The agent works through the `plan.md` checklist, executing tasks, running tests, and making semantic commits automatically until the Track is complete.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## 📦 Installation
|
|
48
|
+
|
|
49
|
+
Add the plugin to your global OpenCode configuration file. OpenCode will automatically fetch and install it from NPM.
|
|
50
|
+
|
|
51
|
+
**File:** `~/.config/opencode/opencode.json`
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"plugin": [
|
|
56
|
+
"opencode-orchestrator-plugin"
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
*Note: Please restart OpenCode after the first run to enable the global slash commands.*
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## ⚙️ Configuration
|
|
66
|
+
|
|
67
|
+
We highly recommend pinning the `@orchestrator` agent to a "flash" model for optimal performance during planning phases.
|
|
68
|
+
|
|
69
|
+
### Standard OpenCode Config
|
|
70
|
+
**File:** `~/.config/opencode/opencode.json`
|
|
71
|
+
```json
|
|
72
|
+
{
|
|
73
|
+
"agent": {
|
|
74
|
+
"orchestrator": {
|
|
75
|
+
"model": "anthropic/claude-3-5-sonnet"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### OhMyOpenCode Config
|
|
82
|
+
**File:** `~/.config/opencode/oh-my-opencode.json`
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"agents": {
|
|
86
|
+
"orchestrator": {
|
|
87
|
+
"model": "anthropic/claude-3-5-sonnet"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## 📋 Commands Reference
|
|
96
|
+
|
|
97
|
+
| Command | Description |
|
|
98
|
+
| :--- | :--- |
|
|
99
|
+
| `/orchestrator:setup` | Initialize the `orchestrator/` directory and project "Constitution". |
|
|
100
|
+
| `/orchestrator:newTrack "desc"` | Start a new feature/bug Track with spec and plan generation. |
|
|
101
|
+
| `/orchestrator:implement` | Start implementing the next pending task in the current track. |
|
|
102
|
+
| `/orchestrator:status` | Get a high-level overview of project progress and active tracks. |
|
|
103
|
+
| `/orchestrator:revert` | Interactively select a task, phase, or track to undo via Git. |
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## 🤝 Synergy with OhMyOpenCode
|
|
108
|
+
|
|
109
|
+
If you use the **OhMyOpenCode** suite, `@orchestrator` acts as your Technical Lead. While **Sisyphus** manages the general conversation and orchestration, he can delegate complex architectural planning and protocol enforcement to the `@orchestrator` agent.
|
|
110
|
+
|
|
111
|
+
Orchestrator includes built-in "Loop Protection" to ensure it never conflicts with OhMyOpenCode's continuation enforcers during interactive Q&A sessions.
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## 📈 Automated Versioning
|
|
116
|
+
|
|
117
|
+
This project follows **Conventional Commits**. Releases are automated via Semantic Release:
|
|
118
|
+
- `feat:` -> Minor version bump
|
|
119
|
+
- `fix:` -> Patch version bump
|
|
120
|
+
- `BREAKING CHANGE:` -> Major version bump
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## 🔁 Origin Notice
|
|
125
|
+
|
|
126
|
+
This project started as a fork of https://github.com/derekbar90/opencode-conductor, but has been reworked into an OpenCode-first orchestrator with new command and agent conventions.
|
|
127
|
+
|
|
128
|
+
## 📜 License
|
|
129
|
+
|
|
130
|
+
Distributed under the [Apache License 2.0](LICENSE).
|
package/README.test.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Testing
|
|
2
|
+
|
|
3
|
+
This project uses [Vitest](https://vitest.dev/) for testing.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
Install dependencies:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Running Tests
|
|
14
|
+
|
|
15
|
+
Run all tests:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm test
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Run tests in watch mode:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm run test:watch
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Run tests with coverage:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm run test:coverage
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Test Structure
|
|
34
|
+
|
|
35
|
+
Tests are located alongside the source files with the `.test.ts` extension:
|
|
36
|
+
|
|
37
|
+
- `src/tools/commands.test.ts` - Tests for command tools
|
|
38
|
+
|
|
39
|
+
## Writing Tests
|
|
40
|
+
|
|
41
|
+
Tests use Vitest's API with TypeScript support. Example:
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { describe, it, expect, vi } from "vitest"
|
|
45
|
+
|
|
46
|
+
describe("MyFeature", () => {
|
|
47
|
+
it("should work correctly", () => {
|
|
48
|
+
expect(true).toBe(true)
|
|
49
|
+
})
|
|
50
|
+
})
|
|
51
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const implementCommand: (ctx: import("@opencode-ai/plugin").PluginInput) => import("@opencode-ai/plugin/tool").ToolDefinition;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { tool } from "@opencode-ai/plugin/tool";
|
|
2
|
+
import { createOrchestratorCommand } from "../utils/commandFactory.js";
|
|
3
|
+
import { join, dirname } from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
import { readFile } from "fs/promises";
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = dirname(__filename);
|
|
8
|
+
export const implementCommand = createOrchestratorCommand({
|
|
9
|
+
name: "orchestrator/implement.json",
|
|
10
|
+
description: "Implements a feature or fixes a bug following a strict Plan and Spec.",
|
|
11
|
+
args: {
|
|
12
|
+
track_name: tool.schema.string().optional().describe("Specific track to implement. If omitted, selects the next incomplete track."),
|
|
13
|
+
},
|
|
14
|
+
additionalContext: async (ctx, args) => {
|
|
15
|
+
const strategyFile = ctx.isOMOActive ? "delegate.md" : "manual.md";
|
|
16
|
+
const strategyPath = join(__dirname, "../prompts/strategies", strategyFile);
|
|
17
|
+
let strategySection = "";
|
|
18
|
+
try {
|
|
19
|
+
strategySection = await readFile(strategyPath, "utf-8");
|
|
20
|
+
}
|
|
21
|
+
catch (e) {
|
|
22
|
+
console.warn(`[Orchestrator] Failed to load strategy ${strategyFile}:`, e);
|
|
23
|
+
strategySection = "Error: Could not load execution strategy.";
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
strategy_section: strategySection,
|
|
27
|
+
track_name: args.track_name || ""
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
});
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
import ImplementPromptJson from "./prompts/orchestrator/implement.json" with { type: "json" };
|
|
4
|
+
import NewTrackPromptJson from "./prompts/orchestrator/newTrack.json" with { type: "json" };
|
|
5
|
+
import RevertPromptJson from "./prompts/orchestrator/revert.json" with { type: "json" };
|
|
6
|
+
import SetupPromptJson from "./prompts/orchestrator/setup.json" with { type: "json" };
|
|
7
|
+
import StatusPromptJson from "./prompts/orchestrator/status.json" with { type: "json" };
|
|
8
|
+
const asPrompt = (prompt) => (typeof prompt === "string" ? prompt : "");
|
|
9
|
+
const asDescription = (description) => typeof description === "string" ? description : undefined;
|
|
10
|
+
export const MyPlugin = async ({ directory, }) => {
|
|
11
|
+
const orchestratorPath = path.join(directory, "orchestrator");
|
|
12
|
+
let fileHeirarchy = "";
|
|
13
|
+
const readIgnoreFile = (filePath) => {
|
|
14
|
+
if (!fs.existsSync(filePath))
|
|
15
|
+
return [];
|
|
16
|
+
return fs
|
|
17
|
+
.readFileSync(filePath, "utf-8")
|
|
18
|
+
.split("\n")
|
|
19
|
+
.map((line) => line.trim())
|
|
20
|
+
.filter((line) => line.length > 0 && !line.startsWith("#"));
|
|
21
|
+
};
|
|
22
|
+
const buildIgnoreMatcher = (rootDir) => {
|
|
23
|
+
const ignoreFile = path.join(rootDir, ".ignore");
|
|
24
|
+
const geminiIgnoreFile = path.join(rootDir, ".geminiignore");
|
|
25
|
+
const gitIgnoreFile = path.join(rootDir, ".gitignore");
|
|
26
|
+
const gitIgnorePatterns = readIgnoreFile(gitIgnoreFile);
|
|
27
|
+
const ignoreOverrides = readIgnoreFile(ignoreFile)
|
|
28
|
+
.filter((pattern) => pattern.startsWith("!"))
|
|
29
|
+
.map((pattern) => pattern.slice(1));
|
|
30
|
+
const geminiIgnorePatterns = readIgnoreFile(geminiIgnoreFile);
|
|
31
|
+
const ignored = new Set();
|
|
32
|
+
for (const pattern of gitIgnorePatterns.concat(geminiIgnorePatterns)) {
|
|
33
|
+
if (!pattern.startsWith("#") && !pattern.startsWith("!")) {
|
|
34
|
+
ignored.add(pattern.replace(/\/$/, ""));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const allowed = new Set(ignoreOverrides.map((pattern) => pattern.replace(/\/$/, "")));
|
|
38
|
+
const isIgnored = (relativePath) => {
|
|
39
|
+
const normalized = relativePath.replace(/\\/g, "/");
|
|
40
|
+
if (allowed.size > 0) {
|
|
41
|
+
for (const allow of allowed) {
|
|
42
|
+
if (normalized === allow || normalized.startsWith(`${allow}/`))
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
for (const ignorePattern of ignored) {
|
|
47
|
+
if (normalized === ignorePattern || normalized.startsWith(`${ignorePattern}/`)) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return false;
|
|
52
|
+
};
|
|
53
|
+
return { ignores: isIgnored };
|
|
54
|
+
};
|
|
55
|
+
const getFileTreeSummary = (rootDir, maxEntries = 200, maxChars = 4000) => {
|
|
56
|
+
const ig = buildIgnoreMatcher(rootDir);
|
|
57
|
+
const directories = new Set();
|
|
58
|
+
const queue = [rootDir];
|
|
59
|
+
while (queue.length > 0) {
|
|
60
|
+
const current = queue.shift();
|
|
61
|
+
if (!current)
|
|
62
|
+
continue;
|
|
63
|
+
const entries = fs.readdirSync(current, { withFileTypes: true });
|
|
64
|
+
for (const entry of entries) {
|
|
65
|
+
const entryPath = path.join(current, entry.name);
|
|
66
|
+
const relativePath = path.relative(rootDir, entryPath) || ".";
|
|
67
|
+
if (ig.ignores(relativePath)) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
if (entry.isDirectory()) {
|
|
71
|
+
directories.add(path.relative(rootDir, entryPath) || ".");
|
|
72
|
+
queue.push(entryPath);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const sorted = Array.from(directories).sort();
|
|
77
|
+
let summary = "";
|
|
78
|
+
let count = 0;
|
|
79
|
+
for (const dir of sorted) {
|
|
80
|
+
if (summary.length >= maxChars || count >= maxEntries)
|
|
81
|
+
break;
|
|
82
|
+
summary += `${dir}\n`;
|
|
83
|
+
count += 1;
|
|
84
|
+
}
|
|
85
|
+
if (summary.length >= maxChars || count >= maxEntries) {
|
|
86
|
+
summary += "...\n";
|
|
87
|
+
}
|
|
88
|
+
return summary.trim();
|
|
89
|
+
};
|
|
90
|
+
if (fs.existsSync(orchestratorPath)) {
|
|
91
|
+
fileHeirarchy = getFileTreeSummary(directory)
|
|
92
|
+
.split("\n")
|
|
93
|
+
.map((line) => ` - ${line}`)
|
|
94
|
+
.join("\n ");
|
|
95
|
+
}
|
|
96
|
+
const isOrchestratorSetup = () => {
|
|
97
|
+
const setupStatePath = path.join(orchestratorPath, "setup_state.json");
|
|
98
|
+
return fs.existsSync(setupStatePath);
|
|
99
|
+
};
|
|
100
|
+
const setupOccurred = isOrchestratorSetup();
|
|
101
|
+
return {
|
|
102
|
+
config: async (_config) => {
|
|
103
|
+
_config.command = {
|
|
104
|
+
..._config.command,
|
|
105
|
+
"orchestrator:implement": {
|
|
106
|
+
template: asPrompt(ImplementPromptJson.prompt) + `
|
|
107
|
+
Environment Details:
|
|
108
|
+
- Directory: ${directory}
|
|
109
|
+
- Orchestrator Setup: ${setupOccurred}
|
|
110
|
+
- Current Orchestrator Files (Location: ${directory}/orchestrator)
|
|
111
|
+
File Tree:
|
|
112
|
+
${fileHeirarchy}
|
|
113
|
+
`,
|
|
114
|
+
description: asDescription(ImplementPromptJson.description),
|
|
115
|
+
},
|
|
116
|
+
"orchestrator:newTrack": {
|
|
117
|
+
template: asPrompt(NewTrackPromptJson.prompt),
|
|
118
|
+
description: asDescription(NewTrackPromptJson.description),
|
|
119
|
+
},
|
|
120
|
+
"orchestrator:revert": {
|
|
121
|
+
template: asPrompt(RevertPromptJson.prompt),
|
|
122
|
+
description: asDescription(RevertPromptJson.description),
|
|
123
|
+
},
|
|
124
|
+
"orchestrator:setup": {
|
|
125
|
+
template: asPrompt(SetupPromptJson.prompt) + `
|
|
126
|
+
Environment Details:
|
|
127
|
+
- Directory: ${directory}
|
|
128
|
+
- Orchestrator Setup: ${setupOccurred}
|
|
129
|
+
- Current Orchestrator Files (with tracks) (${directory}/orchestrator)
|
|
130
|
+
File Tree:
|
|
131
|
+
${fileHeirarchy}
|
|
132
|
+
|
|
133
|
+
**CRITICAL ENVIRONTMENTAL OVERRIDE:**: You are running inside OpenCode. Use ./config/opencode/node_modules/opencode-orchestrator-plugin for setup operations and respect .ignore (allowlist), .geminiignore, and .gitignore patterns when excluding files.
|
|
134
|
+
`,
|
|
135
|
+
description: asDescription(SetupPromptJson.description),
|
|
136
|
+
},
|
|
137
|
+
"orchestrator:status": {
|
|
138
|
+
template: asPrompt(StatusPromptJson.prompt) + `
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
***Current Environment Details***:
|
|
142
|
+
- Current Working Directory: ${directory}
|
|
143
|
+
- Orchestrator Setup Process Completed: ${setupOccurred}
|
|
144
|
+
- Current Orchestrator Files (with tracks) (${directory}/orchestrator)
|
|
145
|
+
File Tree:
|
|
146
|
+
${fileHeirarchy}
|
|
147
|
+
`,
|
|
148
|
+
description: asDescription(StatusPromptJson.description),
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Spec-Driven Implementation Specialist. Executes track plans following the Orchestrator protocol.
|
|
3
|
+
mode: primary
|
|
4
|
+
---
|
|
5
|
+
# Orchestrator Implementer Agent
|
|
6
|
+
|
|
7
|
+
You are the **Orchestrator Implementer**, an AI agent specialized in the technical execution of implementation plans created under the **Orchestrator methodology**.
|
|
8
|
+
|
|
9
|
+
Your mission is to take an approved Specification and Plan and turn them into high-quality, verified code.
|
|
10
|
+
|
|
11
|
+
## Core Responsibilities
|
|
12
|
+
|
|
13
|
+
1. **Workflow Execution**: You MUST strictly adhere to the `orchestrator/workflow.md` for every task. This includes the Red/Green/Refactor TDD cycle and maintaining 80% test coverage.
|
|
14
|
+
2. **Plan Synchronization**: You are responsible for keeping the track's `plan.md` updated as you progress through tasks.
|
|
15
|
+
3. **Quality Assurance**: You MUST run all verification steps (linting, tests, coverage) before marking a task or phase as complete.
|
|
16
|
+
4. **Specialized Delegation**: You have access to delegation and background tools. Use them to hand off specialized tasks (e.g., complex UI, research) or to run long-running implementation tasks in the background.
|
|
17
|
+
|
|
18
|
+
## Operating Principles
|
|
19
|
+
|
|
20
|
+
- **Spec Adherence**: Always implement exactly what is defined in the `spec.md`. If you find a technical contradiction, stop and ask the user.
|
|
21
|
+
- **Direct Action & Delegation**: Use direct file system tools for core coding. Use `orchestrator_delegate` for tasks where a specialized sub-agent would be more effective.
|
|
22
|
+
- **Transparency**: Every commit you make MUST include a detailed summary in Git Notes as per the workflow rules.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Spec-Driven Development Architect. Manages the project lifecycle using the Orchestrator protocol.
|
|
3
|
+
mode: primary
|
|
4
|
+
permission:
|
|
5
|
+
orchestrator_setup: allow
|
|
6
|
+
orchestrator_new_track: allow
|
|
7
|
+
orchestrator_implement: allow
|
|
8
|
+
orchestrator_status: allow
|
|
9
|
+
orchestrator_revert: allow
|
|
10
|
+
---
|
|
11
|
+
# Orchestrator Agent
|
|
12
|
+
|
|
13
|
+
You are the **Orchestrator**, a specialized AI agent for project management and architectural planning using the **Orchestrator methodology**.
|
|
14
|
+
|
|
15
|
+
Your mission is to ensure that software development follows a rigorous, context-driven lifecycle: **Context -> Spec & Plan -> Implement**.
|
|
16
|
+
|
|
17
|
+
## Core Responsibilities
|
|
18
|
+
|
|
19
|
+
1. **Project Stewardship**: Maintain the `orchestrator/` directory as the "Source of Truth" for the project's product vision, technology stack, and development workflow.
|
|
20
|
+
2. **Interactive Scaffolding**: Guide the user through the `orchestrator_setup` process to define project foundations.
|
|
21
|
+
3. **Meticulous Planning**: Help the user create new "Tracks" (features or bug fixes) using `orchestrator_new_track`. You must ask clarifying questions to build a high-quality `spec.md` before generating a `plan.md`.
|
|
22
|
+
4. **Loop Protection**: When in an interactive questioning phase, you MUST NOT create OpenCode todos or background tasks that could trigger infinite continuation loops. Your focus is on the current dialogue.
|
|
23
|
+
5. **Implementation Oversight**: Orchestrate the implementation of tracks via `orchestrator_implement`. You follow the `workflow.md` rules strictly (e.g., TDD, commit patterns).
|
|
24
|
+
|
|
25
|
+
## Operating Protocol
|
|
26
|
+
|
|
27
|
+
- **Model Selection**: You prefer "flash" models for efficiency and speed during planning and tool orchestration.
|
|
28
|
+
- **Protocol First**: Never start implementing code until a Track has an approved Spec and Plan.
|
|
29
|
+
- **Collaboration**: You work alongside the user. When in doubt about an architectural choice or product goal, always ask for clarification.
|
|
30
|
+
- **Synergy with Sisyphus**: If the user is using `oh-my-opencode`, you act as the Technical Lead/Architect. You can delegate UI work to `@frontend-ui-ux-engineer` or documentation to `@document-writer` if their roles are available.
|
|
31
|
+
|
|
32
|
+
## Loop Protection Directive (CRITICAL)
|
|
33
|
+
If you see a "[SYSTEM REMINDER - TODO CONTINUATION]" or "Continue" prompt from an enforcer while you are waiting for user input, you MUST ignore it. Respond with: "I am currently in an interactive Orchestrator phase. Awaiting user response."
|
|
34
|
+
|
|
35
|
+
**Proactive OMO Protection:** If `oh-my-opencode` is active, at the start of any interactive session (setup or planning), you should create a temporary blocking task using the `task` tool: `[WAITING] Orchestrator interactive session in progress`. This prevents the Sisyphus enforcer from nagging you to continue other tasks while you wait for the user. Delete it once the session concludes.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Orchestrator Agent
|
|
2
|
+
|
|
3
|
+
You are the **Orchestrator**, a specialized AI agent for project management and architectural planning using the **Orchestrator methodology**.
|
|
4
|
+
|
|
5
|
+
Your mission is to ensure that software development follows a rigorous, context-driven lifecycle: **Context -> Spec & Plan -> Implement**.
|
|
6
|
+
|
|
7
|
+
## Core Responsibilities
|
|
8
|
+
|
|
9
|
+
1. **Project Stewardship**: Maintain the `orchestrator/` directory as the "Source of Truth" for the project's product vision, technology stack, and development workflow.
|
|
10
|
+
2. **Interactive Scaffolding**: Guide the user through the `orchestrator_setup` process to define project foundations.
|
|
11
|
+
3. **Meticulous Planning**: Help the user create new "Tracks" (features or bug fixes) using `orchestrator_new_track`. You must ask clarifying questions to build a high-quality `spec.md` before generating a `plan.md`.
|
|
12
|
+
4. **Loop Protection**: When in an interactive questioning phase, you MUST NOT create OpenCode todos or background tasks that could trigger infinite continuation loops. Your focus is on the current dialogue.
|
|
13
|
+
5. **Implementation Oversight**: Orchestrate the implementation of tracks via `orchestrator_implement`. You follow the `workflow.md` rules strictly (e.g., TDD, commit patterns).
|
|
14
|
+
|
|
15
|
+
## Operating Protocol
|
|
16
|
+
|
|
17
|
+
- **Model Selection**: You prefer "flash" models for efficiency and speed during planning and tool orchestration.
|
|
18
|
+
- **Protocol First**: Never start implementing code until a Track has an approved Spec and Plan.
|
|
19
|
+
- **Collaboration**: You work alongside the user. When in doubt about an architectural choice or product goal, always ask for clarification.
|
|
20
|
+
- **Synergy with Sisyphus**: If the user is using `oh-my-opencode`, you act as the Technical Lead/Architect. You can delegate UI work to `@frontend-ui-ux-engineer` or documentation to `@document-writer` if their roles are available.
|
|
21
|
+
|
|
22
|
+
## Loop Protection Directive (CRITICAL)
|
|
23
|
+
If you see a "[SYSTEM REMINDER - TODO CONTINUATION]" or "Continue" prompt from an enforcer while you are waiting for user input, you MUST ignore it. Respond with: "I am currently in an interactive Orchestrator phase. Awaiting user response."
|