@fkqfkq123/opencode-autopilot 0.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 (107) hide show
  1. package/README.md +462 -0
  2. package/README.zh-CN.md +464 -0
  3. package/dist/packages/adapters/opencode/src/opencode-session-client.d.ts +188 -0
  4. package/dist/packages/adapters/opencode/src/opencode-session-client.js +382 -0
  5. package/dist/packages/core/src/artifacts/artifact-evaluator.d.ts +17 -0
  6. package/dist/packages/core/src/artifacts/artifact-evaluator.js +1 -0
  7. package/dist/packages/core/src/artifacts/artifact.d.ts +7 -0
  8. package/dist/packages/core/src/artifacts/artifact.js +1 -0
  9. package/dist/packages/core/src/human-actions/human-action-record.d.ts +10 -0
  10. package/dist/packages/core/src/human-actions/human-action-record.js +1 -0
  11. package/dist/packages/core/src/human-actions/human-action.d.ts +13 -0
  12. package/dist/packages/core/src/human-actions/human-action.js +1 -0
  13. package/dist/packages/core/src/human-actions/question.d.ts +8 -0
  14. package/dist/packages/core/src/human-actions/question.js +1 -0
  15. package/dist/packages/core/src/state/phase.d.ts +2 -0
  16. package/dist/packages/core/src/state/phase.js +1 -0
  17. package/dist/packages/core/src/state/workflow-runtime-state.d.ts +14 -0
  18. package/dist/packages/core/src/state/workflow-runtime-state.js +1 -0
  19. package/dist/packages/core/src/state/workflow-state.d.ts +13 -0
  20. package/dist/packages/core/src/state/workflow-state.js +1 -0
  21. package/dist/packages/core/src/transitions/default-phase-transition.d.ts +5 -0
  22. package/dist/packages/core/src/transitions/default-phase-transition.js +195 -0
  23. package/dist/packages/core/src/transitions/phase-transition.d.ts +22 -0
  24. package/dist/packages/core/src/transitions/phase-transition.js +1 -0
  25. package/dist/packages/core/src/transitions/transition-action.d.ts +20 -0
  26. package/dist/packages/core/src/transitions/transition-action.js +1 -0
  27. package/dist/packages/runtime/src/artifacts/file-system-artifact-evaluator.d.ts +36 -0
  28. package/dist/packages/runtime/src/artifacts/file-system-artifact-evaluator.js +1213 -0
  29. package/dist/packages/runtime/src/attach/attach-service.d.ts +15 -0
  30. package/dist/packages/runtime/src/attach/attach-service.js +31 -0
  31. package/dist/packages/runtime/src/bootstrap/create-harness.d.ts +33 -0
  32. package/dist/packages/runtime/src/bootstrap/create-harness.js +79 -0
  33. package/dist/packages/runtime/src/bootstrap/initialize-workflow.d.ts +8 -0
  34. package/dist/packages/runtime/src/bootstrap/initialize-workflow.js +33 -0
  35. package/dist/packages/runtime/src/commands/create-opencode-workflow-commands.d.ts +12 -0
  36. package/dist/packages/runtime/src/commands/create-opencode-workflow-commands.js +24 -0
  37. package/dist/packages/runtime/src/commands/default-workflow-command-runner.d.ts +4 -0
  38. package/dist/packages/runtime/src/commands/default-workflow-command-runner.js +343 -0
  39. package/dist/packages/runtime/src/commands/opencode-plugin-command-adapter.d.ts +20 -0
  40. package/dist/packages/runtime/src/commands/opencode-plugin-command-adapter.js +22 -0
  41. package/dist/packages/runtime/src/commands/workflow-command-runner.d.ts +19 -0
  42. package/dist/packages/runtime/src/commands/workflow-command-runner.js +1 -0
  43. package/dist/packages/runtime/src/commands/workflow-open-request.d.ts +10 -0
  44. package/dist/packages/runtime/src/commands/workflow-open-request.js +220 -0
  45. package/dist/packages/runtime/src/config/skill-registry.d.ts +15 -0
  46. package/dist/packages/runtime/src/config/skill-registry.js +108 -0
  47. package/dist/packages/runtime/src/config/workflow-config.d.ts +17 -0
  48. package/dist/packages/runtime/src/config/workflow-config.js +51 -0
  49. package/dist/packages/runtime/src/diagnostics/workflow-diagnostics-format.d.ts +4 -0
  50. package/dist/packages/runtime/src/diagnostics/workflow-diagnostics-format.js +70 -0
  51. package/dist/packages/runtime/src/diagnostics/workflow-doctor.d.ts +23 -0
  52. package/dist/packages/runtime/src/diagnostics/workflow-doctor.js +120 -0
  53. package/dist/packages/runtime/src/engine/default-workflow-engine.d.ts +9 -0
  54. package/dist/packages/runtime/src/engine/default-workflow-engine.js +337 -0
  55. package/dist/packages/runtime/src/engine/workflow-engine.d.ts +28 -0
  56. package/dist/packages/runtime/src/engine/workflow-engine.js +1 -0
  57. package/dist/packages/runtime/src/events/file-system-workflow-event-store.d.ts +8 -0
  58. package/dist/packages/runtime/src/events/file-system-workflow-event-store.js +28 -0
  59. package/dist/packages/runtime/src/events/workflow-event-store.d.ts +10 -0
  60. package/dist/packages/runtime/src/events/workflow-event-store.js +1 -0
  61. package/dist/packages/runtime/src/index.d.ts +4 -0
  62. package/dist/packages/runtime/src/index.js +4 -0
  63. package/dist/packages/runtime/src/install/workflow-installer.d.ts +15 -0
  64. package/dist/packages/runtime/src/install/workflow-installer.js +111 -0
  65. package/dist/packages/runtime/src/plugin/workflow-plugin-entry.d.ts +167 -0
  66. package/dist/packages/runtime/src/plugin/workflow-plugin-entry.js +340 -0
  67. package/dist/packages/runtime/src/presentation/human-action-renderer.d.ts +13 -0
  68. package/dist/packages/runtime/src/presentation/human-action-renderer.js +161 -0
  69. package/dist/packages/runtime/src/presentation/watch-renderer.d.ts +12 -0
  70. package/dist/packages/runtime/src/presentation/watch-renderer.js +17 -0
  71. package/dist/packages/runtime/src/recovery/basic-recovery-classifier.d.ts +4 -0
  72. package/dist/packages/runtime/src/recovery/basic-recovery-classifier.js +12 -0
  73. package/dist/packages/runtime/src/recovery/recovery-classifier.d.ts +4 -0
  74. package/dist/packages/runtime/src/recovery/recovery-classifier.js +1 -0
  75. package/dist/packages/runtime/src/scheduling/immediate-tick-scheduler.d.ts +9 -0
  76. package/dist/packages/runtime/src/scheduling/immediate-tick-scheduler.js +28 -0
  77. package/dist/packages/runtime/src/scheduling/tick-scheduler.d.ts +3 -0
  78. package/dist/packages/runtime/src/scheduling/tick-scheduler.js +1 -0
  79. package/dist/packages/runtime/src/sessions/file-system-session-coordinator.d.ts +19 -0
  80. package/dist/packages/runtime/src/sessions/file-system-session-coordinator.js +132 -0
  81. package/dist/packages/runtime/src/sessions/session-activity-monitor.d.ts +22 -0
  82. package/dist/packages/runtime/src/sessions/session-activity-monitor.js +112 -0
  83. package/dist/packages/runtime/src/sessions/session-coordinator.d.ts +24 -0
  84. package/dist/packages/runtime/src/sessions/session-coordinator.js +1 -0
  85. package/dist/packages/runtime/src/shared/json-file.d.ts +2 -0
  86. package/dist/packages/runtime/src/shared/json-file.js +19 -0
  87. package/dist/packages/runtime/src/state/file-system-human-action-store.d.ts +15 -0
  88. package/dist/packages/runtime/src/state/file-system-human-action-store.js +69 -0
  89. package/dist/packages/runtime/src/state/file-system-workflow-state-store.d.ts +15 -0
  90. package/dist/packages/runtime/src/state/file-system-workflow-state-store.js +59 -0
  91. package/dist/packages/runtime/src/state/human-action-service.d.ts +21 -0
  92. package/dist/packages/runtime/src/state/human-action-service.js +80 -0
  93. package/dist/packages/runtime/src/state/human-action-store.d.ts +9 -0
  94. package/dist/packages/runtime/src/state/human-action-store.js +1 -0
  95. package/dist/packages/runtime/src/state/workflow-state-store.d.ts +11 -0
  96. package/dist/packages/runtime/src/state/workflow-state-store.js +1 -0
  97. package/dist/packages/runtime/src/subtasks/noop-subtask-tracker.d.ts +4 -0
  98. package/dist/packages/runtime/src/subtasks/noop-subtask-tracker.js +5 -0
  99. package/dist/packages/runtime/src/subtasks/subtask-tracker.d.ts +3 -0
  100. package/dist/packages/runtime/src/subtasks/subtask-tracker.js +1 -0
  101. package/dist/packages/runtime/src/workspace/workflow-workspace.d.ts +31 -0
  102. package/dist/packages/runtime/src/workspace/workflow-workspace.js +43 -0
  103. package/dist/plugin.d.ts +1 -0
  104. package/dist/plugin.js +1 -0
  105. package/dist/src/cli.d.ts +1 -0
  106. package/dist/src/cli.js +175 -0
  107. package/package.json +56 -0
package/README.md ADDED
@@ -0,0 +1,462 @@
1
+ # Autopilot
2
+
3
+ English | [中文说明](./README.zh-CN.md)
4
+
5
+ Autopilot is an OpenCode-oriented **attached-session workflow harness**. It provides a workflow runtime skeleton covering refinement, planning, development, review, and testing, plus a locally loadable plugin, CLI entrypoints, and diagnostics.
6
+
7
+ ## 1. What this project provides
8
+
9
+ - A full workflow phase chain: `spec_refinement -> plan -> develop -> review -> test -> done`
10
+ - OpenCode-facing workflow commands such as `workflow_open`, `workflow_attach`, `workflow_status`, `workflow_answer`, `workflow_approve`, `workflow_resume`, and `workflow_back`
11
+ - Plugin loading and native primary workflow agent registration for OpenCode-style hosts
12
+ - `install` and `doctor` flows for bootstrapping configuration and validating setup
13
+ - Review/test loop-back semantics, human breakpoints, event storage, attach/re-attach support
14
+
15
+ ## 2. Who this is for
16
+
17
+ Autopilot is a good fit if you want to:
18
+
19
+ - add a workflow primary agent to an OpenCode-style host,
20
+ - structure engineering work into explicit workflow phases,
21
+ - validate a workflow runtime and command surface through a plugin.
22
+
23
+ ## 3. Prerequisites
24
+
25
+ Recommended environment:
26
+
27
+ - macOS / Linux / Windows
28
+ - [Bun](https://bun.sh/) `1.3.5` or a compatible version
29
+ - OpenCode installed if you want to actually load and verify the plugin
30
+
31
+ Check Bun:
32
+
33
+ ```bash
34
+ bun --version
35
+ ```
36
+
37
+ If Bun is not installed yet:
38
+
39
+ ```bash
40
+ curl -fsSL https://bun.sh/install | bash
41
+ ```
42
+
43
+ Then restart your terminal and verify again:
44
+
45
+ ```bash
46
+ bun --version
47
+ ```
48
+
49
+ ## 4. Installation
50
+
51
+ ### 4.1 Recommended: install as an npm plugin package
52
+
53
+ OpenCode supports npm-based plugins directly. Once this package is published, the simplest configuration is:
54
+
55
+ ```json
56
+ {
57
+ "plugin": ["@fkqfkq123/opencode-autopilot"]
58
+ }
59
+ ```
60
+
61
+ You can also pin a version:
62
+
63
+ ```json
64
+ {
65
+ "plugin": ["@fkqfkq123/opencode-autopilot@0.1.0"]
66
+ }
67
+ ```
68
+
69
+ In this mode, OpenCode installs and caches the npm package automatically. No manual `git clone`, local `plugin.js`, or extra install script is required.
70
+
71
+ ### 4.2 Fallback: install from GitHub Releases
72
+
73
+ If you prefer a local-file installation path or need a fallback distribution mode, use the one-line installer from GitHub Releases:
74
+
75
+ ```bash
76
+ curl -fsSL https://raw.githubusercontent.com/juhuaxia/Autopilot/main/install.sh | bash
77
+ ```
78
+
79
+ Install a specific version:
80
+
81
+ ```bash
82
+ curl -fsSL https://raw.githubusercontent.com/juhuaxia/Autopilot/main/install.sh | bash -s -- --version v0.1.0
83
+ ```
84
+
85
+ The fallback installer will:
86
+
87
+ - download the prebuilt release package from GitHub Releases,
88
+ - install it into `~/.config/opencode/plugins/autopilot/`,
89
+ - update `~/.config/opencode/opencode.json`.
90
+
91
+ Release requirement:
92
+
93
+ - Each GitHub Release must include `autopilot-release.tar.gz`
94
+ - The repository includes `.github/workflows/release.yml`, which builds and uploads that file automatically on `v*` tags
95
+
96
+ If you want to modify the codebase or work from source, continue with the source setup below.
97
+
98
+ ### 4.3 Clone the repository
99
+
100
+ ```bash
101
+ git clone https://github.com/juhuaxia/Autopilot.git
102
+ cd Autopilot
103
+ ```
104
+
105
+ ### 4.4 Install dependencies
106
+
107
+ ```bash
108
+ bun install
109
+ ```
110
+
111
+ The project uses `bun.lock`, so dependencies are expected to stay reproducible.
112
+
113
+ ## 5. Recommended first-run commands
114
+
115
+ Run these from the project root:
116
+
117
+ ```bash
118
+ bun run src/cli.ts install
119
+ bun run src/cli.ts doctor
120
+ bun run build
121
+ ```
122
+
123
+ What they do:
124
+
125
+ 1. `install`
126
+ - creates project-level `.workflow-harness/workflow.json`
127
+ - tries to safely update `~/.config/opencode/opencode.json`
128
+ - normalizes `opencode.jsonc` into `opencode.json` when safe
129
+ 2. `doctor`
130
+ - checks `workflow.json`
131
+ - checks `skillRoots`
132
+ - checks phase-level `requiredSkills`
133
+ - reports warnings and missing pieces
134
+ 3. `build`
135
+ - compiles TypeScript
136
+ - produces `dist/plugin.js`
137
+
138
+ After that, confirm:
139
+
140
+ - `.workflow-harness/workflow.json` exists
141
+ - `doctor` shows no blocking configuration issue
142
+ - `dist/plugin.js` exists
143
+
144
+ ## 6. Common development commands
145
+
146
+ ### 6.1 Build
147
+
148
+ ```bash
149
+ bun run build
150
+ ```
151
+
152
+ ### 6.2 Typecheck
153
+
154
+ ```bash
155
+ bun run typecheck
156
+ ```
157
+
158
+ ### 6.3 Run tests
159
+
160
+ ```bash
161
+ bun test
162
+ ```
163
+
164
+ ### 6.4 Run plugin smoke tests
165
+
166
+ ```bash
167
+ bun run smoke:plugin
168
+ ```
169
+
170
+ ### 6.5 Run CLI commands directly
171
+
172
+ ```bash
173
+ bun run src/cli.ts doctor
174
+ bun run src/cli.ts install
175
+ ```
176
+
177
+ Or through the script alias:
178
+
179
+ ```bash
180
+ bun run cli --help
181
+ ```
182
+
183
+ > The CLI mainly provides workflow initialization, attach/status flows, and install/doctor actions.
184
+
185
+ ## 7. CLI quick usage
186
+
187
+ ### 7.1 Initialize config
188
+
189
+ ```bash
190
+ bun run src/cli.ts install
191
+ ```
192
+
193
+ ### 7.2 Run a self-check
194
+
195
+ ```bash
196
+ bun run src/cli.ts doctor
197
+ ```
198
+
199
+ ### 7.3 Create a workflow
200
+
201
+ ```bash
202
+ bun run src/cli.ts workflow-open wf-1
203
+ ```
204
+
205
+ ### 7.4 Check workflow status
206
+
207
+ ```bash
208
+ bun run src/cli.ts workflow-status wf-1
209
+ ```
210
+
211
+ ### 7.5 Re-attach to the workflow channel
212
+
213
+ ```bash
214
+ bun run src/cli.ts workflow-attach wf-1
215
+ ```
216
+
217
+ ## 8. Loading the plugin into OpenCode
218
+
219
+ ### 8.0 Recommended npm plugin path
220
+
221
+ Recommended OpenCode config:
222
+
223
+ ```json
224
+ {
225
+ "plugin": ["@fkqfkq123/opencode-autopilot"]
226
+ }
227
+ ```
228
+
229
+ ### 8.1 Fallback release-based path
230
+
231
+ If you prefer a local installed fallback plugin, use:
232
+
233
+ ```bash
234
+ curl -fsSL https://raw.githubusercontent.com/juhuaxia/Autopilot/main/install.sh | bash
235
+ ```
236
+
237
+ Default install location:
238
+
239
+ ```txt
240
+ ~/.config/opencode/plugins/autopilot/
241
+ ```
242
+
243
+ The installer will register a plugin entry similar to:
244
+
245
+ ```txt
246
+ file:///Users/<your-user>/.config/opencode/plugins/autopilot/plugin.js
247
+ ```
248
+
249
+ ### 8.2 Source-development path
250
+
251
+ Run:
252
+
253
+ ```bash
254
+ bun run src/cli.ts install
255
+ bun run src/cli.ts doctor
256
+ ```
257
+
258
+ If the installer can safely update the OpenCode config, you usually do not need to edit anything manually.
259
+
260
+ > `install.sh` targets GitHub Releases installs. The project-local installer targets source-development setups.
261
+
262
+ ### 8.3 Manual plugin registration
263
+
264
+ OpenCode config is usually located at:
265
+
266
+ - `~/.config/opencode/opencode.json`
267
+ - or `~/.config/opencode/opencode.jsonc`
268
+
269
+ #### Option A: load the built plugin
270
+
271
+ Build first:
272
+
273
+ ```bash
274
+ bun run build
275
+ ```
276
+
277
+ Then add this to OpenCode config:
278
+
279
+ ```json
280
+ {
281
+ "plugin": [
282
+ "file:///ABSOLUTE_PATH_TO_PROJECT/dist/plugin.js"
283
+ ]
284
+ }
285
+ ```
286
+
287
+ #### Option B: load source directly during development
288
+
289
+ ```json
290
+ {
291
+ "plugin": [
292
+ "file:///ABSOLUTE_PATH_TO_PROJECT/plugin.ts"
293
+ ]
294
+ }
295
+ ```
296
+
297
+ ### 8.4 Start OpenCode
298
+
299
+ Interactive mode:
300
+
301
+ ```bash
302
+ opencode
303
+ ```
304
+
305
+ Server mode:
306
+
307
+ ```bash
308
+ opencode serve
309
+ ```
310
+
311
+ ## 9. What you should see after loading
312
+
313
+ The plugin exposes these tools/commands:
314
+
315
+ - `workflow_channel`
316
+ - `workflow_open`
317
+ - `workflow_attach`
318
+ - `workflow_status`
319
+ - `workflow_answer`
320
+ - `workflow_approve`
321
+ - `workflow_resume`
322
+ - `workflow_back`
323
+ - `workflow_doctor`
324
+
325
+ Recommended split-tool entrypoints:
326
+
327
+ - `workflow_open`
328
+ - `workflow_attach`
329
+ - `workflow_status`
330
+ - `workflow_answer`
331
+ - `workflow_approve`
332
+ - `workflow_resume`
333
+ - `workflow_back`
334
+
335
+ Typical load log:
336
+
337
+ ```txt
338
+ [autopilot] Autopilot plugin loaded (... commands)
339
+ ```
340
+
341
+ ## 10. Directory layout
342
+
343
+ ### 10.1 Configuration layers
344
+
345
+ - user default: `~/.config/opencode/workflow.json`
346
+ - project override: `<repo>/.workflow-harness/workflow.json`
347
+ - runtime state: `<repo>/.workflow-harness/workflows/<workflowId>/`
348
+
349
+ ### 10.2 What each directory does
350
+
351
+ - `src/` — CLI entrypoints and top-level source files
352
+ - `packages/runtime/` — workflow runtime implementation
353
+ - `tests/` — tests
354
+ - `scripts/` — auxiliary scripts
355
+ - `.workflow-harness/` — runtime config, state, and artifacts
356
+ - `dist/` — build output
357
+
358
+ ## 11. Minimal `workflow.json` example
359
+
360
+ Start with a fully neutral config:
361
+
362
+ ```json
363
+ {
364
+ "skillRoots": ["~/.claude/skills", "~/.config/opencode/skills"],
365
+ "phases": {
366
+ "develop": { "requiredSkills": [] },
367
+ "test": { "requiredSkills": [] }
368
+ }
369
+ }
370
+ ```
371
+
372
+ Then add skills per project. For example, for a frontend-oriented project:
373
+
374
+ ```json
375
+ {
376
+ "skillRoots": ["~/.claude/skills", "~/.config/opencode/skills"],
377
+ "phases": {
378
+ "develop": { "requiredSkills": ["frontend-design"] },
379
+ "test": { "requiredSkills": ["playwright"] }
380
+ }
381
+ }
382
+ ```
383
+
384
+ That frontend example is only an example. The workflow runtime is not frontend-bound by default.
385
+
386
+ Recommendations:
387
+
388
+ - keep skill/profile config in global or project-level `workflow.json`
389
+ - do not put skill config under `workflows/<workflowId>/`
390
+ - run `workflow_doctor` or CLI `doctor` before using a new config
391
+
392
+ ## 12. FAQ
393
+
394
+ ### Q1: What if `install` cannot update my OpenCode config?
395
+
396
+ Edit OpenCode config manually and add either the release plugin path or the local build path to the `plugin` array. Example:
397
+
398
+ ```json
399
+ {
400
+ "plugin": [
401
+ "file:///Users/<your-user>/.config/opencode/plugins/autopilot/plugin.js"
402
+ ]
403
+ }
404
+ ```
405
+
406
+ For source development, you can also point to your local `dist/plugin.js`.
407
+
408
+ If you are using the npm plugin mode, you can simply configure:
409
+
410
+ ```json
411
+ {
412
+ "plugin": ["@fkqfkq123/opencode-autopilot"]
413
+ }
414
+ ```
415
+
416
+ ### Q2: Why can’t I see workflow commands after building?
417
+
418
+ That usually means the host integration layer has not actually registered the exported `workflowCommands` onto the host command/tool surface.
419
+
420
+ ### Q3: What should I validate first?
421
+
422
+ Validate this order first:
423
+
424
+ 1. the host can import the plugin file
425
+ 2. the host can call the default export
426
+ 3. the host receives a plugin-like object
427
+
428
+ Do not start by validating UI behavior first.
429
+
430
+ ### Q4: Any important rule for the plugin root entry?
431
+
432
+ The root `plugin.ts` entry should only expose a single host-callable default export. Do not expose extra internal classes or helper functions from the root entry.
433
+
434
+ ## 13. Recommended reading
435
+
436
+ | Document | Purpose |
437
+ |---|---|
438
+ | `README.md` | Main entry for installation, release, and usage |
439
+ | `WORKFLOW_SKILL_PROFILE_ARCHITECTURE_CN.md` | Skill/profile configuration design |
440
+ | `OPENCODE_WORKFLOW_AGENT_GUIDE.md` | Agent/tool calling loop |
441
+ | `REQUIREMENT_TEMPLATE.md` | Requirement input template |
442
+
443
+ Internal planning notes, acceptance drafts, and status scratch docs can be kept locally under `docs_internal/`, which is ignored by default.
444
+
445
+ ## 14. Fastest path to a working setup
446
+
447
+ If you just want the fastest local source setup:
448
+
449
+ ```bash
450
+ bun install
451
+ bun run src/cli.ts install
452
+ bun run src/cli.ts doctor
453
+ bun run build
454
+ opencode
455
+ ```
456
+
457
+ Then:
458
+
459
+ 1. confirm `.workflow-harness/workflow.json` exists
460
+ 2. confirm `dist/plugin.js` exists
461
+ 3. if OpenCode does not auto-load the plugin, add `file:///ABSOLUTE_PATH_TO_PROJECT/dist/plugin.js` manually to config
462
+ 4. verify `workflow_open`, `workflow_attach`, and `workflow_status` are visible in the host