@alvarolorentedev/opencode-taskfeed 0.0.0-stage → 0.1.0-alpha.1

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 (58) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +431 -2
  3. package/docs/architecture.md +123 -0
  4. package/docs/configuration.md +123 -0
  5. package/docs/development.md +312 -0
  6. package/docs/integrations.md +84 -0
  7. package/docs/operations.md +136 -0
  8. package/docs/releases/v0.1.0-alpha.1.md +164 -0
  9. package/docs/security.md +120 -0
  10. package/examples/README.md +7 -0
  11. package/examples/approvals/README.md +27 -0
  12. package/examples/flowgraph/config.yaml +28 -0
  13. package/examples/flowgraph/opencode.jsonc +14 -0
  14. package/examples/headless/README.md +25 -0
  15. package/examples/headless/config.yaml +21 -0
  16. package/examples/native-agent/config.yaml +31 -0
  17. package/examples/native-agent/opencode.jsonc +10 -0
  18. package/examples/playground/README.md +61 -0
  19. package/examples/playground/config.yaml +40 -0
  20. package/examples/playground/opencode.jsonc +5 -0
  21. package/package.json +89 -4
  22. package/src/config/load.ts +122 -0
  23. package/src/config/repository.ts +72 -0
  24. package/src/config/schema.ts +215 -0
  25. package/src/core/approval.ts +190 -0
  26. package/src/core/comments.ts +175 -0
  27. package/src/core/index.ts +5 -0
  28. package/src/core/ports.ts +185 -0
  29. package/src/core/state.ts +186 -0
  30. package/src/core/types.ts +430 -0
  31. package/src/executors/flowgraph/client.ts +27 -0
  32. package/src/executors/flowgraph/executor.ts +593 -0
  33. package/src/executors/flowgraph/lazy.ts +77 -0
  34. package/src/executors/flowgraph/rpc.ts +145 -0
  35. package/src/executors/flowgraph/worker.ts +538 -0
  36. package/src/executors/native/bridge.ts +421 -0
  37. package/src/executors/native/executor.ts +295 -0
  38. package/src/executors/native/prompt.ts +57 -0
  39. package/src/executors/native/trust.ts +105 -0
  40. package/src/index.ts +116 -0
  41. package/src/rpc.ts +75 -0
  42. package/src/runtime/backends.ts +27 -0
  43. package/src/runtime/engine.ts +2345 -0
  44. package/src/runtime/server-backends.ts +136 -0
  45. package/src/runtime/service.ts +276 -0
  46. package/src/sources/github/client.ts +98 -0
  47. package/src/sources/github/source.ts +490 -0
  48. package/src/storage/capacity.ts +223 -0
  49. package/src/storage/jobs.ts +249 -0
  50. package/src/storage/locks.ts +342 -0
  51. package/src/tui.tsx +399 -0
  52. package/src/util/ids.ts +18 -0
  53. package/src/util/logger.ts +52 -0
  54. package/src/util/process.ts +119 -0
  55. package/src/util/redact.ts +28 -0
  56. package/src/version.ts +2 -0
  57. package/src/workspaces/native.ts +162 -0
  58. package/src/workspaces/publication.ts +477 -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 CHANGED
@@ -1,3 +1,432 @@
1
- # Temporary Holding Version
1
+ # Taskfeed
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![CI](https://github.com/alvarolorentedev/opencode-taskfeed/actions/workflows/ci.yml/badge.svg)](https://github.com/alvarolorentedev/opencode-taskfeed/actions/workflows/ci.yml)
4
+ [![npm](https://img.shields.io/npm/v/@alvarolorentedev/opencode-taskfeed)](https://www.npmjs.com/package/@alvarolorentedev/opencode-taskfeed)
5
+ [![license](https://img.shields.io/badge/license-Apache--2.0-blue)](LICENSE)
6
+
7
+ **Turn your backlog into agent work.**
8
+
9
+ Taskfeed is an OpenCode V2 plugin. It discovers GitHub issues that an authorized developer has explicitly marked ready, runs them through an existing native OpenCode agent, isolates each execution in a Git worktree, publishes a draft pull request when enabled, and synchronizes decisions and results back to GitHub. Flowgraph workflow execution is available as an experimental opt-in.
10
+
11
+ Taskfeed is not another coding harness, agent platform, model provider, SDLC engine, or dashboard. It brings your existing agents, models, permissions and workflows to work that already exists in GitHub.
12
+
13
+ - npm package: `@alvarolorentedev/opencode-taskfeed`
14
+ - Current release: `0.1.0-alpha.1` (native workflow prerelease)
15
+ - License: Apache 2.0
16
+ - OpenCode V2 plugin APIs are the integration boundary
17
+
18
+ > This alpha validates the native workflow. Install and operate Taskfeed without Flowgraph. Flowgraph remains experimental and is not production-ready.
19
+
20
+ > Worktrees provide file isolation, not a security sandbox. Native OpenCode permissions remain authoritative.
21
+
22
+ ## What it does
23
+
24
+ 1. Discovers open GitHub issues carrying the configured ready label.
25
+ 2. Verifies that the ready label was applied by a configured enqueue user.
26
+ 3. Claims the issue with Taskfeed status labels.
27
+ 4. Creates an isolated Git worktree and a deterministic Taskfeed branch.
28
+ 5. Starts the configured existing native OpenCode agent in that worktree. Flowgraph workflows are an experimental opt-in.
29
+ 6. Tracks the native session (or experimental Flowgraph run), permission blockers, timeouts and recovery.
30
+ 7. For native execution, requires the agent to commit and leave a clean worktree.
31
+ 8. When publication is enabled, pushes only the Taskfeed-owned branch and creates or reuses a draft pull request.
32
+ 9. Publishes a review gate with the pull request, exact commit SHA and `/taskfeed` decision commands.
33
+ 10. Relays an authorized GitHub decision to the same execution, or completes the job.
34
+ 11. Posts the result to GitHub and updates Taskfeed labels.
35
+
36
+ Taskfeed never calls an LLM to poll, schedule, prioritize, synchronize, validate approvals or reconcile state.
37
+
38
+ ## What it is not
39
+
40
+ - It does not merge, deploy, or approve its own work.
41
+ - It does not define agents, models, prompts, provider credentials or permission policies.
42
+ - It does not provide a separate workflow engine or interpret a Flowgraph graph.
43
+ - It does not run a web dashboard, hosted service, broker or database server.
44
+ - It does not create GitHub Actions or infrastructure.
45
+ - It does not monitor repositories that OpenCode has not opened/activated.
46
+
47
+ ## Requirements
48
+
49
+ - OpenCode V2 (`opencode` 2.3.x or later) with OpenCode's own provider/model access.
50
+ - `git` and an authenticated GitHub CLI (`gh auth login`).
51
+ - Bun for plugin development and packaging. OpenCode loads TypeScript plugin source with Bun.
52
+ - Node.js 20.19+ to run the Vitest suite (the plugin itself runs inside OpenCode).
53
+ - Optional experimental: `@alvarolorentedev/opencode-flowgraph` for workflow execution. It is not required.
54
+
55
+ ## Install
56
+
57
+ Add the explicit prerelease version through OpenCode's plugin configuration. A published install can be global:
58
+
59
+ ```jsonc title="~/.config/opencode/opencode.jsonc"
60
+ {
61
+ "plugins": [
62
+ "@alvarolorentedev/opencode-taskfeed@0.1.0-alpha.1"
63
+ ]
64
+ }
65
+ ```
66
+
67
+ Or project-local:
68
+
69
+ ```jsonc title="opencode.jsonc"
70
+ {
71
+ "plugins": ["@alvarolorentedev/opencode-taskfeed@0.1.0-alpha.1"]
72
+ }
73
+ ```
74
+
75
+ Do not install the unversioned package until a stable `latest` release exists. A complete first-run example is in [`examples/playground`](examples/playground).
76
+
77
+ For a local checkout:
78
+
79
+ ```jsonc
80
+ {
81
+ "plugins": ["/absolute/path/to/opencode-taskfeed"]
82
+ }
83
+ ```
84
+
85
+ **Important:** Taskfeed creates worktrees. OpenCode loads plugins per location, including a worktree. The Taskfeed and optional Flowgraph plugin entries must be visible from worktrees. Install them globally, or commit the `opencode.jsonc` (and optional `.flowgraph/` files) so each worktree sees them. If the plugin is not available at the worktree location, Flowgraph execution fails closed. Taskfeed's scheduler always runs from the canonical checkout; worktree instances are observers and Flowgraph RPC workers.
86
+
87
+ Restart OpenCode after changing plugin configuration. The TUI part is loaded from the same package.
88
+
89
+ ## Quick start
90
+
91
+ 1. Authenticate GitHub:
92
+
93
+ ```sh
94
+ gh auth login
95
+ gh auth status
96
+ ```
97
+
98
+ 2. Add Taskfeed configuration at the repository root:
99
+
100
+ ```yaml title=".taskfeed/config.yaml"
101
+ version: 1
102
+
103
+ source:
104
+ type: github
105
+ repository: auto
106
+ labels:
107
+ - agent-ready
108
+
109
+ execution:
110
+ type: agent
111
+ name: build
112
+
113
+ scheduler:
114
+ enabled: false
115
+ poll_interval_seconds: 60
116
+ concurrency: 1
117
+
118
+ workspace:
119
+ isolation: worktree
120
+
121
+ limits:
122
+ max_attempts: 2
123
+ max_feedback_iterations: 3
124
+ execution_timeout_seconds: 14400
125
+ retry_backoff_seconds: 30
126
+
127
+ approvals:
128
+ provider: github
129
+ authorized_users:
130
+ - your-github-login
131
+ enqueue_users:
132
+ - your-github-login
133
+
134
+ publication:
135
+ enabled: false
136
+ remote: origin
137
+ draft_pull_request: true
138
+ branch_prefix: "taskfeed/"
139
+ ```
140
+
141
+ 3. Start OpenCode in the canonical repository and open `/taskfeed` in the TUI. Enable automation explicitly, and enable `publication.enabled` once the repository and identities are verified. If this is a headless server, activate the location once and disable location idle eviction as described below.
142
+
143
+ 4. Create an issue and apply the ready label **from an authorized enqueue user**:
144
+
145
+ ```sh
146
+ gh issue create --title "Fix connection timeout" --body "..."
147
+ gh issue edit <number> --add-label agent-ready
148
+ ```
149
+
150
+ The label alone is not authorization. Taskfeed checks the current issue labels and the latest active label event in the issue timeline, and requires the actor to be in `enqueue_users` (which defaults to `authorized_users`). Removal withdraws authorization; removal and reapplication are revalidated immediately before a durable job is created. The actor, label event IDs and timestamps are persisted with the job. After admission, Taskfeed consumes the label and reloads context without requiring it again.
151
+
152
+ 5. A native agent must commit its change and leave the worktree clean. Taskfeed does not auto-commit dirty files. With publication enabled it pushes the Taskfeed branch, creates/reuses a draft PR, and publishes a review gate. If publication is disabled or fails, the job is blocked as local-only rather than presented as ready for independent review.
153
+
154
+ ## GitHub labels
155
+
156
+ Defaults:
157
+
158
+ | Label | Meaning |
159
+ |---|---|
160
+ | `agent-ready` | Authorized scheduling signal. Removed when work starts. |
161
+ | `agent-running` | Taskfeed owns active execution. |
162
+ | `agent-review` | External review or approval is required. |
163
+ | `agent-blocked` | Permission, publication, recovery or other intervention needed. |
164
+ | `agent-completed` | Approved/completed. |
165
+
166
+ Taskfeed removes and adds only its configured automation labels. It does not remove unrelated labels. Status labels can be overridden under `source.status_labels`.
167
+
168
+ ## External decisions
169
+
170
+ Review gates publish commands like:
171
+
172
+ ```text
173
+ /taskfeed approve <gate-id> <revision>
174
+ ```
175
+
176
+ ```text
177
+ /taskfeed request-changes <gate-id> <revision>
178
+
179
+ Explain the required change.
180
+ ```
181
+
182
+ For a Flowgraph human gate whose declared outcomes are not `approved` / `changes_requested`, the gate publishes declared outcome commands:
183
+
184
+ ```text
185
+ /taskfeed outcome <gate-id> <revision> <declared-outcome>
186
+ ```
187
+
188
+ Only configured `authorized_users` are accepted. Decisions are bound to the repository, issue, job, current run/gate, exact revision, and the captured review artifact. Commit review fetches the live PR before acceptance and forwarding and requires it to be open and a draft, with the gate SHA, current worktree HEAD and current PR head SHA all equal. Content review publishes immutable text to GitHub and binds approval to its exact digest without requiring a PR. Comments must have valid, exactly matching creation/modification timestamps. Stale, duplicate, malformed, unauthorized, edited and pre-gate commands are rejected. Natural language is never treated as approval.
189
+
190
+ GitHub comments are attributed to an account, not to a human or bot behind that account. If ChatGPT and a developer share one GitHub identity, GitHub cannot distinguish them. Authorization is an explicit delegation to that identity.
191
+
192
+ ## Native agent execution
193
+
194
+ `execution.type: agent` uses an existing OpenCode agent by name. Taskfeed verifies the agent exists and is selectable, but never defines or modifies it. The agent's native model, tools and permission rules remain authoritative.
195
+
196
+ Taskfeed creates a native session in the isolated worktree with session-scoped restrictions for external directories and `.taskfeed/**`. It never answers a permission request automatically. A pending native permission becomes a visible blocker and retains execution capacity; the developer must resolve it in OpenCode.
197
+
198
+ Completion criteria are explicit:
199
+
200
+ - the native session outcome is `succeeded`;
201
+ - no native permission is pending;
202
+ - no idle-hook background work remains;
203
+ - the worktree exists and is clean;
204
+ - a publication artifact exists when external review is requested.
205
+
206
+ Idle alone is not success. If a provider or outcome cannot be proven, the job is blocked rather than silently replayed.
207
+
208
+ ## Remote publication
209
+
210
+ Publication is opt-in:
211
+
212
+ ```yaml
213
+ publication:
214
+ enabled: true
215
+ remote: origin
216
+ draft_pull_request: true
217
+ branch_prefix: "taskfeed/"
218
+ # base_branch: main
219
+ ```
220
+
221
+ When enabled, Taskfeed:
222
+
223
+ - refuses dirty worktrees;
224
+ - inspects every committed changed file, including added, modified and renamed paths, for protected/generated paths, symlinks, submodules, size limits and common credential/private-key markers;
225
+ - blocks files larger than the configured `max_file_bytes` (default 1 MiB);
226
+ - pushes only a recorded Taskfeed-owned branch, never force-pushes;
227
+ - creates a draft PR or reuses one open, still-draft PR for that branch;
228
+ - verifies the remote head SHA;
229
+ - records the PR URL and exact SHA on the review gate.
230
+
231
+ Draft enforcement is mandatory. `publication.draft_pull_request` must be `true`; configurations that disable it are rejected.
232
+
233
+ If publication is disabled or fails, the result is shown as local-only and the job is blocked; no approval gate is published. Automatic merging and deployment are not implemented.
234
+
235
+ For Flowgraph execution, Taskfeed does not create a second publication path. It requires the workflow's own publication step to produce a linked PR whose head SHA matches the worktree. Otherwise the external gate is blocked/local-only. This avoids duplicating Flowgraph SDLC behavior.
236
+
237
+ ## Flowgraph integration (experimental)
238
+
239
+ Flowgraph is opt-in and experimental in this prerelease. The native workflow does not require it. Flowgraph plan approval remains fail-closed until the upstream public API exposes a typed content artifact and a per-node admission/policy hook.
240
+
241
+ Configure an existing workflow:
242
+
243
+ ```yaml
244
+ execution:
245
+ type: workflow
246
+ name: development
247
+ ```
248
+
249
+ Taskfeed uses Flowgraph's documented location-scoped RPC. It does not read Flowgraph storage or interpret the graph.
250
+
251
+ - The workflow is validated from the canonical checkout.
252
+ - The worktree must contain the same workflow hash; Taskfeed fails closed if it differs.
253
+ - Taskfeed activates the worktree location through the public OpenCode plugin/session APIs.
254
+ - A non-canonical Taskfeed observer proxy invokes Flowgraph RPC at that exact location, because server-plugin RPC is location-bound.
255
+ - The run session and every agent step session are checked against the worktree. Any mismatch cancels the run and blocks the job.
256
+ - Human gates are relayed through `respondRun` with the current revision and declared outcome.
257
+ - If Flowgraph is unavailable, workflow jobs fail clearly; native execution is unaffected.
258
+
259
+ If the Flowgraph plugin or worktree workflow files are not visible from the worktree, Flowgraph execution fails closed with a clear error. This is a host configuration requirement, not a Taskfeed fallback.
260
+
261
+ ## TUI
262
+
263
+ Run `/taskfeed` from OpenCode. The page shows repository, configuration, scheduler ownership, project/global concurrency, warnings, and jobs grouped by state.
264
+
265
+ Keys:
266
+
267
+ | Key | Action |
268
+ |---|---|
269
+ | `up` / `down` | Select a job |
270
+ | `enter` | Open the associated native session |
271
+ | `a` | Enable/disable automation (durable runtime override) |
272
+ | `p` | Pause/resume new scheduling; active jobs continue |
273
+ | `d` | Manually dispatch an eligible job |
274
+ | `x` | Cancel a job with confirmation |
275
+ | `t` | Retry safely, or retry publication after a completed native session |
276
+ | `c` | Clean up a clean, terminal worktree; branch/commits are kept |
277
+ | `w` | Pause/resume a Flowgraph run where supported |
278
+ | `r` | Refresh |
279
+
280
+ `/taskfeed on`, `/taskfeed off`, `/taskfeed pause`, `/taskfeed resume` and `/taskfeed refresh` are also available.
281
+
282
+ The TUI controls through the typed Taskfeed RPC. A worktree TUI queues control requests through shared storage; the canonical scheduler owner executes them. No separate daemon or web dashboard is created.
283
+
284
+ ## Headless operation
285
+
286
+ The scheduler is server-side and does not require the TUI to be open.
287
+
288
+ 1. Set a durable location lifetime in project/global OpenCode config:
289
+
290
+ ```jsonc
291
+ {
292
+ "experimental": { "location_idle_timeout": false }
293
+ }
294
+ ```
295
+
296
+ 2. Start `opencode serve`.
297
+ 3. Activate the project once through the API (creating a session is enough; no model prompt is needed):
298
+
299
+ ```sh
300
+ opencode api POST /api/session \
301
+ --data '{"location":{"directory":"/absolute/path/to/repo"}}'
302
+ ```
303
+
304
+ If the project location is evicted, its plugins and scheduler unload. Taskfeed cannot retain an OpenCode location by itself. Keep the location loaded (`location_idle_timeout: false`) for persistent headless operation.
305
+
306
+ Taskfeed does not claim to monitor repositories that OpenCode has never activated.
307
+
308
+ ## Concurrency and ownership
309
+
310
+ - One scheduler owner per project/canonical checkout is elected with a file lease.
311
+ - The canonical checkout is the only scheduler owner; worktree instances are observers and Flowgraph workers.
312
+ - A stale owner checks the lease before dispatch and before forwarding approvals. If ownership is lost, it stops.
313
+ - Global execution capacity is shared across projects in the supported server boundary through file-backed capacity slots. It defaults to **1** and is configured with the plugin option `globalConcurrency`.
314
+ - The project's configured `scheduler.concurrency` is an additional project cap.
315
+ - Ambiguous executions retain capacity until proven inactive. Pending native permissions also retain capacity. Jobs awaiting external approval release capacity but retain their worktree.
316
+ - An approval that resumes execution acquires capacity first. If none is available, the decision is persisted and forwarded when capacity becomes available.
317
+
318
+ The supported ownership boundary is one local OpenCode server/user on one machine. Cross-host exactly-once execution is not promised.
319
+
320
+ ## Recovery
321
+
322
+ State is durable in OpenCode's native plugin storage; scheduler/state locks and global capacity use private local files. On restart Taskfeed:
323
+
324
+ - reuses recorded sessions/runs and worktrees;
325
+ - adopts existing capacity obligations;
326
+ - never silently launches a duplicate when admission or outcome is ambiguous;
327
+ - persists an external decision admission before forwarding it, then reconciles instead of replaying after a crash;
328
+ - marks unproven executions blocked with an actionable message;
329
+ - keeps dirty worktrees and branches;
330
+ - releases capacity only after explicit completion, cancellation, or a proven inactive state.
331
+
332
+ ## Configuration reference
333
+
334
+ | Key | Default | Notes |
335
+ |---|---|---|
336
+ | `source.repository` | `auto` | `auto` requires one GitHub remote; otherwise use `owner/repo`. |
337
+ | `source.labels` | `[agent-ready]` | Trigger labels. |
338
+ | `source.status_labels` | documented labels | Taskfeed-owned status labels. |
339
+ | `execution.type` | required | `agent` or `workflow`. No fallback. |
340
+ | `execution.name` | required | Existing native agent or Flowgraph workflow ID. |
341
+ | `scheduler.enabled` | `false` | Durable TUI override can change at runtime. |
342
+ | `scheduler.poll_interval_seconds` | `60` | Minimum 5. |
343
+ | `scheduler.concurrency` | `1` | Project cap; global cap also applies. |
344
+ | `workspace.isolation` | `worktree` | Only worktree isolation is supported. |
345
+ | `workspace.base_branch` | repository default | Starting ref for the worktree. |
346
+ | `limits.max_attempts` | `2` | Bounded attempts. |
347
+ | `limits.max_feedback_iterations` | `3` | Bounded native/Flowgraph rework decisions. |
348
+ | `limits.execution_timeout_seconds` | `14400` | Cancels overrunning execution. |
349
+ | `limits.retry_backoff_seconds` | `30` | Retry backoff. |
350
+ | `approvals.authorized_users` | `[]` | Required for native approval; a GitHub account allowlist. |
351
+ | `approvals.enqueue_users` | authorized users | Who may apply the ready label. |
352
+ | `publication.enabled` | `false` | Explicit opt-in for push/draft PR. |
353
+ | `publication.remote` | `origin` | Git remote. |
354
+ | `publication.base_branch` | repository default | PR base. |
355
+ | `publication.draft_pull_request` | `true` | Must be `true`; draft enforcement cannot be disabled. |
356
+ | `publication.branch_prefix` | `taskfeed/` | Taskfeed-owned branches only. |
357
+ | `publication.protected_paths` | safe defaults | Nested secret/credential paths block publication when changed. |
358
+ | `publication.generated_artifacts` | safe defaults | Generated paths that block publication. |
359
+ | `publication.max_file_bytes` | `1048576` | Per-file publication size limit. |
360
+
361
+ Unknown keys and unsupported modes are rejected. Configuration is read only from the canonical checkout; edits made by an agent inside a worktree cannot change scheduler permissions or trusted configuration.
362
+
363
+ Plugin option:
364
+
365
+ ```jsonc
366
+ {
367
+ "plugins": [
368
+ {
369
+ "package": "@alvarolorentedev/opencode-taskfeed@0.1.0-alpha.1",
370
+ "options": { "globalConcurrency": 2 }
371
+ }
372
+ ]
373
+ }
374
+ ```
375
+
376
+ ## Security
377
+
378
+ - External issues, comments, attachments and PR text are untrusted requirements, never policy.
379
+ - All `gh` and `git` calls use structured argument arrays, not shell interpolation.
380
+ - Publication establishes the remote baseline, scans all outgoing commits and newly reachable objects (including intermediate versions and commit messages), and pushes only the exact validated SHA.
381
+ - Taskfeed never requests or logs provider credentials.
382
+ - Native permission requests are never auto-approved.
383
+ - Worktrees are not a security sandbox. Shell tools run with the host user's filesystem and network authority; prompt instructions are not a security boundary.
384
+ - Automation is disabled by default. A ready label is insufficient without an authorized enqueue actor.
385
+ - External side effects (push, PR, comments, workflow decisions) are gated by trusted configuration and explicit authorization.
386
+ - A worktree is not trusted to change the execution policy of subsequent jobs. Configuration, agents and workflow validation come from the canonical checkout.
387
+
388
+ See [docs/security.md](docs/security.md) for the full model.
389
+
390
+ ## Cost
391
+
392
+ Polling, scheduling, labels, comments, recovery, approval validation and publication use no model tokens. Taskfeed does not instantiate an LLM client or call `generate` for orchestration.
393
+
394
+ When an execution runs, the configured native agent or Flowgraph workflow consumes the user's existing OpenCode model quota exactly as a manual session would. Taskfeed cannot enforce a monetary budget when the provider does not expose one; it exposes provider-reported token/cost fields where available.
395
+
396
+ ## Testing
397
+
398
+ ```sh
399
+ bun install
400
+ bun run typecheck
401
+ bun run test
402
+ bun run verify:pack
403
+ ```
404
+
405
+ Default tests use fakes and temporary Git repositories and make no paid model calls. Real OpenCode integration tests are opt-in and separate:
406
+
407
+ ```sh
408
+ bun run test:real:native # supported native workflow
409
+ bun run test:real:flowgraph # experimental Flowgraph coverage
410
+ bun run test:real # both real OpenCode suites
411
+ bun run test:real:github # opt-in disposable GitHub repository
412
+ ```
413
+
414
+ The native suite starts a real OpenCode server with a deterministic mock provider that performs real file edits and commits, and restart coverage uses genuine process interruption. It does not require Flowgraph. The GitHub mutation suite requires an explicit disposable-repository allowlist and is never run by CI or the release workflow. See [docs/development.md](docs/development.md).
415
+
416
+ ## Known limitations
417
+
418
+ - This is an alpha prerelease for the native workflow. Flowgraph integration is experimental.
419
+ - No automatic merge or deployment.
420
+ - Taskfeed-created pull requests are drafts; merging is always external.
421
+ - Native execution requires the agent to commit. Taskfeed does not auto-commit dirty files or bypass repository hooks.
422
+ - Flowgraph external review requires the workflow to publish a linked PR; Taskfeed does not duplicate Flowgraph publication.
423
+ - Flowgraph worktree activation requires Taskfeed and Flowgraph to be loadable at the worktree location (global install or committed plugin config).
424
+ - One scheduler owner is supported per local machine; cross-host coordination is not.
425
+ - No browser automation, ChatGPT session automation, Jira/Linear/GitLab adapters, or separate dashboard.
426
+ - The TUI and server must see the same OpenCode server to share RPC state.
427
+ - Approval edit detection uses GitHub REST second precision; an edit within the same second as creation is indistinguishable.
428
+ - Worktrees are not a sandbox. Taskfeed pins/hashes agent and plugin context at supported RPC boundaries, but cannot revoke plugin code already loaded in the worktree process.
429
+ - Flowgraph executes nodes between Taskfeed observations; trusted-context checks happen before location activation and at start, respond and observation boundaries. The public Flowgraph API has no per-node policy hook.
430
+ - Flowgraph's current public human gate does not expose typed content artifacts, so plan-only external review remains blocked until the upstream contract is extended. Taskfeed does not infer stage or content from node names or prose.
431
+ - The internal publication scanner is a conservative denylist, not a full secret-scanning product.
432
+ - Real-model and real-GitHub-mutation verification is opt-in.