@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
@@ -0,0 +1,123 @@
1
+ # Architecture
2
+
3
+ Taskfeed is an automation layer around existing OpenCode execution. It owns discovery, durable job state, scheduling, worktrees, publication and external synchronization. It does not own agents, models, prompts, native permissions, or workflow routing.
4
+
5
+ ## Boundaries
6
+
7
+ ```text
8
+ GitHub
9
+ requirements, backlog, external decisions
10
+ │
11
+ ▼
12
+ Taskfeed
13
+ discovery · scheduler · jobs · workspaces · publication · reconciliation
14
+ │
15
+ ├── existing OpenCode agent/session
16
+ └── optional experimental Flowgraph workflow
17
+ existing SDLC, agents and routing
18
+ ```
19
+
20
+ Taskfeed and Flowgraph are sibling OpenCode plugins. Neither requires the other. Native agent execution is always available and is the supported alpha workflow. Workflow execution is experimental, opt-in, and uses Flowgraph's public location-scoped RPC.
21
+
22
+ ## Module layout
23
+
24
+ ```text
25
+ src/
26
+ core/ portable contracts, state machine, approval parser, comments
27
+ configuration/ strict YAML schema, repository discovery
28
+ storage/ native KV job store, leases, global capacity
29
+ sources/github/ gh CLI adapter
30
+ executors/native/ existing OpenCode agent execution
31
+ executors/flowgraph/ Flowgraph RPC adapter + worktree location worker
32
+ workspaces/ OpenCode worktrees, Git branches, publication
33
+ runtime/ plugin wiring, scheduler engine, RPC actions, recovery
34
+ tui.tsx native OpenCode TUI page
35
+ rpc.ts shared typed RPC contract
36
+ index.ts server plugin entry
37
+ ```
38
+
39
+ `src/core` does not import GitHub, OpenCode, Flowgraph or TUI implementation code. Adapters depend on core contracts, never the reverse. An architecture test enforces that.
40
+
41
+ ## Plugin lifecycle
42
+
43
+ OpenCode loads a server plugin at each location. Taskfeed:
44
+
45
+ - reads trusted configuration and elects scheduler ownership only from the canonical checkout;
46
+ - uses a file lease keyed by project + canonical checkout so multiple plugin instances, sessions, clients and worktrees do not run duplicate schedulers;
47
+ - starts a lightweight observer/Flowgraph location worker in non-canonical worktrees;
48
+ - never requires the TUI for scheduling;
49
+ - releases the lease on cleanup but never cancels running work merely because the plugin unloads.
50
+
51
+ The TUI is a separate plugin part and communicates only through Taskfeed RPC.
52
+
53
+ ## Jobs and durable state
54
+
55
+ The internal state machine is independent of GitHub labels:
56
+
57
+ ```text
58
+ discovered → queued → starting → running → awaiting_approval → completed
59
+ │ │
60
+ ├─ paused ┘
61
+ ├─ blocked
62
+ ├─ failed → queued (bounded retry)
63
+ └─ cancelled
64
+ ```
65
+
66
+ Jobs store stable task identity, admission authorization evidence, idempotency key, execution provider, attempts, workspace/branch, native session or Flowgraph run identity, gate identity and revision, reviewed artifact, capacity token+generation and recovery errors. Native storage is the durable source of truth for execution ownership. GitHub is the source of truth for requirements and external decisions.
67
+
68
+ Discovery, admission and context loading are separate contracts. `listReady` discovers candidates. `authorizeAdmission` re-reads the open issue, current labels and active timeline immediately before the durable admission boundary and returns actor/label-event evidence. `loadContext` reloads an already admitted issue without requiring the consumed ready label. Label consumption therefore cannot revoke the job's own authorization. Queued work is withdrawn when eligibility disappears; admitted work keeps its provenance and is blocked if its issue closes or context identity changes. Legacy jobs created before admission evidence was persisted are treated as previously admitted from their durable task fields; new jobs always store the full evidence.
69
+
70
+ Labels are a synchronization surface, not a lock.
71
+
72
+ ## Scheduler
73
+
74
+ Only the canonical owner polls and dispatches. Each tick:
75
+
76
+ 1. verifies the scheduler lease;
77
+ 2. loads trusted configuration and prepares the GitHub/execution adapters;
78
+ 3. processes queued TUI controls;
79
+ 4. reconciles capacity and active jobs;
80
+ 5. polls GitHub at the configured interval;
81
+ 6. dispatches queued jobs while respecting project/global capacity;
82
+ 7. synchronizes labels and pending external decisions.
83
+
84
+ Only the canonical checkout can acquire the scheduler lease or execute a tick. Worktree observers reject enable/disable, pause, refresh, dispatch, cancel, retry, cleanup and workflow-control requests with an actionable error; they never execute those controls locally. The public engine and service entry points enforce this independently of startup.
85
+
86
+ A stale owner re-checks the lease before dispatch, before prompt submission, before forwarding decisions and before publication. If it loses ownership, it stops dispatching; a new owner observes existing sessions/runs and does not start replacements. Lease acquisition is atomic; stale takeover/release are serialized by a `proper-lockfile` guard, and heartbeat uses an open descriptor. Taskfeed's token+generation remain the ownership authority. Capacity slots use token+generation fencing under a serialized mutex. `proper-lockfile` judges guard staleness by mtime, so a process paused past the guard threshold can lose the guard; scheduler and capacity generations still fence it from mutating shared state. These are local single-machine guarantees, not cross-host exactly-once execution.
87
+
88
+ ## Worktrees
89
+
90
+ Taskfeed uses OpenCode's native worktree API, then creates/records a Taskfeed branch inside the linked worktree. The canonical checkout is never modified. Native sessions are created at the worktree location. Cleanup is explicit, inventory-checked, and refuses dirty worktrees. Branches are retained.
91
+
92
+ The Flowgraph worktree location worker invokes location-scoped RPC through the Taskfeed plugin instance at that location. This avoids using the canonical location for sessions that must run in isolation.
93
+
94
+ Before activating a worktree location, Taskfeed hashes the project-controlled executable policy (`opencode.json`, `opencode.jsonc` and `.opencode/**`) and compares it with the canonical checkout. The canonical Flowgraph executor and native executor also capture effective agent/plugin snapshots and publish canonical agent definitions to shared Taskfeed storage. The worktree Taskfeed plugin pins those definitions with OpenCode's agent transform. Worker requests carry the expected trusted-context snapshot, scheduler generation and expiry. Immediately before a side effect, the worker re-reads the request, cancellation tombstone, live scheduler generation and lease, claim, job/attempt/run identity and capacity reservation. A durable admission record distinguishes cancellation before admission from an operation already in flight.
95
+
96
+ Native execution uses a deterministic OpenCode message ID for each job/attempt prompt and each decision continuation. Recovery requires exact job/attempt/worktree metadata and never adopts an arbitrary session. A newly submitted prompt is not considered complete until a later assistant/idle message is visible, preventing the previous turn's success from satisfying a rework.
97
+
98
+ ## Publication
99
+
100
+ Native success requires a clean committed worktree; Taskfeed never creates a snapshot commit and never bypasses hooks. Publication resolves an immutable candidate SHA and establishes the trusted baseline from the remote branch, or the remote base branch when the Taskfeed branch does not yet exist. It verifies fast-forward ancestry, enumerates every outgoing commit and newly reachable object, scans intermediate file versions and commit messages, and fails closed on truncated or unsupported output. Only the validated SHA is pushed; symbolic `HEAD` is never pushed.
101
+
102
+ Before any push, an existing PR must be open, a draft, and target the expected repository branch/base. Draft status is mandatory and cannot be disabled by configuration. Review approval binds to the remote SHA and re-verifies the live PR and worktree immediately before acceptance and forwarding.
103
+
104
+ Flowgraph publication remains Flowgraph's responsibility. Taskfeed requires a linked draft PR with a matching head SHA for commit-based review and does not create a competing PR.
105
+
106
+ ## Review artifacts
107
+
108
+ Taskfeed supports two typed external review artifacts:
109
+
110
+ - **Content artifact:** immutable text plus a canonical digest, published as a GitHub issue comment. Approval is bound to the gate, revision, run and exact published content digest. It requires no branch or PR.
111
+ - **Commit artifact:** repository, draft PR number/URL and exact reviewed commit SHA, with the existing live local/remote SHA checks.
112
+
113
+ Flowgraph's current public `human_input` blocker does not expose a typed content artifact. Taskfeed therefore fails closed for plan-style gates until Flowgraph exposes the generic artifact contract; it does not infer stage or content from node names or prose. The minimal upstream extension is an optional `artifact` field on the human blocker using the same `{ type: "content", content, contentHash }` / `{ type: "commit", repository, pullRequestNumber, url, headSHA }` shape. Taskfeed's RPC schema already accepts and maps that field.
114
+
115
+ ## Failure semantics
116
+
117
+ - Capacity is released only after confirmed completion, cancellation or proven pre-admission rejection.
118
+ - Ambiguous admission/outcome, missing session/run, unconfirmed cancellation or lost provider response → blocked, capacity retained in `ambiguous` state.
119
+ - Native permission pending → blocked, capacity retained.
120
+ - Publication disabled/failed after confirmed completion → local-only/blocked, no external gate.
121
+ - Awaiting approval → capacity released, workspace retained. An already-admitted decision keeps capacity until the execution is reconciled.
122
+ - Approval resume → capacity acquired before forwarding; a lost response retains capacity and is never automatically replayed.
123
+ - Restart → observe, adopt with a new capacity generation, never blindly replay.
@@ -0,0 +1,123 @@
1
+ # Configuration
2
+
3
+ Configuration lives at `.taskfeed/config.yaml` in the canonical checkout. It is strict YAML validated with Zod. Unknown keys are rejected. Worktree copies are ignored by the scheduler.
4
+
5
+ ## Full example
6
+
7
+ ```yaml
8
+ version: 1
9
+
10
+ source:
11
+ type: github
12
+ repository: auto
13
+ labels: [agent-ready]
14
+ status_labels:
15
+ running: agent-running
16
+ review: agent-review
17
+ blocked: agent-blocked
18
+ completed: agent-completed
19
+
20
+ execution:
21
+ type: agent # or workflow
22
+ name: build
23
+
24
+ scheduler:
25
+ enabled: false
26
+ poll_interval_seconds: 60
27
+ concurrency: 1
28
+
29
+ workspace:
30
+ isolation: worktree
31
+ # base_branch: main
32
+
33
+ limits:
34
+ max_attempts: 2
35
+ max_feedback_iterations: 3
36
+ execution_timeout_seconds: 14400
37
+ retry_backoff_seconds: 30
38
+
39
+ approvals:
40
+ provider: github
41
+ authorized_users: [alice]
42
+ enqueue_users: [alice]
43
+
44
+ publication:
45
+ enabled: true
46
+ provider: github
47
+ remote: origin
48
+ # base_branch: main
49
+ draft_pull_request: true
50
+ branch_prefix: taskfeed/
51
+ ```
52
+
53
+ ## Repository resolution
54
+
55
+ `repository: auto` looks at Git remotes, preferring `origin`. One unique GitHub remote is required. Multiple/ambiguous remotes are an error; set `repository: owner/repo` explicitly. Credentials embedded in remotes are discarded.
56
+
57
+ ## Execution
58
+
59
+ `agent` names an existing OpenCode agent. `workflow` names an existing Flowgraph workflow. There is no fallback between them and Taskfeed never defines an agent, model or workflow.
60
+
61
+ The configured execution is validated at prepare time. Jobs pin their execution provider; a later configuration change does not silently switch an existing job.
62
+
63
+ ## Automation and concurrency
64
+
65
+ `enabled` defaults to false. The TUI can persist a runtime override without editing the trusted YAML.
66
+
67
+ `concurrency` is a project cap. A server-wide cap is configured through the plugin option `globalConcurrency` (default 1). Both must allow a new execution.
68
+
69
+ Awaiting-approval jobs do not consume execution capacity. Pending native permissions and ambiguous executions retain capacity until resolved.
70
+
71
+ ## Approvals and enqueue authorization
72
+
73
+ At least one `enqueue_users` entry is required. It defaults to `authorized_users`. An issue ready label is accepted only when the latest active application of every configured ready label was made by an allowed account. Label removal withdraws authorization; removal and reapplication are evaluated from the current issue labels and timeline immediately before a durable job is created. The actor, label event IDs and timestamps are stored with the job. After admission, Taskfeed consumes the label and reloads context without requiring it again. A label alone is never authorization.
74
+
75
+ `authorized_users` is the allowlist for approval commands and must be non-empty for native agent execution. Approval requires an unedited comment that matches the gate ID/revision. Commit-based review additionally requires a live draft PR whose head SHA, the gate's reviewed SHA and the current worktree HEAD all agree. Content-based review binds to an immutable published content digest and needs no PR. The artifact and original comment are rechecked immediately before forwarding. GitHub cannot distinguish two users sharing one authenticated identity; delegation is explicit.
76
+
77
+ ## Publication
78
+
79
+ Publication is disabled by default. Enabling it authorizes Taskfeed to push a Taskfeed-owned branch and create/reuse a draft PR. It never force-pushes, merges, deploys or writes a non-Taskfeed branch.
80
+
81
+ The worktree must be clean. The agent must commit. Publication always creates a draft PR; `draft_pull_request` is accepted only as `true`, and existing PRs must still be open drafts. Publication establishes the remote baseline, verifies fast-forward ancestry, scans every outgoing commit and newly reachable object (including intermediate file versions and commit messages), and pushes only the exact validated SHA. Failure blocks external review.
82
+
83
+ ```yaml
84
+ publication:
85
+ enabled: true
86
+ protected_paths:
87
+ - "**/.env"
88
+ - "**/.env.*"
89
+ - "**/.npmrc"
90
+ - "**/.pypirc"
91
+ - "**/.aws/**"
92
+ - "**/.ssh/**"
93
+ - "**/*.pem"
94
+ - "**/*.key"
95
+ generated_artifacts:
96
+ - "**/dist/**"
97
+ - "**/coverage/**"
98
+ - "**/*.tgz"
99
+ max_file_bytes: 1048576
100
+ ```
101
+
102
+ Defaults include nested `.env`, `.npmrc`, `.pypirc`, `.aws`, `.ssh`, private key/certificate patterns and a generated-artifact denylist. The scanner is a conservative internal denylist; add repository-specific paths or use an external scanner if your policy requires more.
103
+
104
+ ## Global defaults
105
+
106
+ OpenCode does not provide a native per-repository Taskfeed defaults mechanism. Repository configuration is the trusted source. The only global setting is the plugin option:
107
+
108
+ ```jsonc
109
+ {
110
+ "plugins": [
111
+ {
112
+ "package": "@alvarolorentedev/opencode-taskfeed@0.1.0-alpha.1",
113
+ "options": { "globalConcurrency": 2 }
114
+ }
115
+ ]
116
+ }
117
+ ```
118
+
119
+ ## Rejecting configuration
120
+
121
+ Missing, non-regular or oversized files, symlinks, invalid YAML, unknown keys, invalid labels, unavailable agents/workflows, incomplete authorization and `draft_pull_request: false` are surfaced in the TUI and stop new work. They never cause a silent fallback.
122
+
123
+ Flowgraph execution additionally requires the effective worktree agent/plugin context to match the canonical snapshot. Taskfeed pins canonical agent definitions in worktree locations and fails closed when the worker sees a mismatch. Existing installations that changed `draft_pull_request` to `false` must remove the key or set it to `true`.
@@ -0,0 +1,312 @@
1
+ # Development
2
+
3
+ ## Architecture and ownership
4
+
5
+ - OpenCode owns agents, sessions, permissions, models and tools.
6
+ - Taskfeed owns GitHub discovery, authorization evidence, job state, worktree isolation, publication, approval validation and recovery.
7
+ - GitHub is the source of truth for requirements and external decisions. Native Taskfeed storage owns execution ownership and recovery.
8
+ - `.taskfeed/config.yaml` is read from the canonical checkout. A worktree cannot change trusted policy.
9
+ - The canonical checkout owns the scheduler. Worktree locations are observers and optional Flowgraph RPC workers.
10
+ - Flowgraph is optional and experimental. The native agent workflow must install and run without it.
11
+
12
+ ### Modules
13
+
14
+ | Module | Responsibility |
15
+ |---|---|
16
+ | `src/core/` | Portable contracts, job state, approval parsing and comment rendering. No adapter imports. |
17
+ | `src/config/` | Strict configuration schema and canonical-checkout loading. |
18
+ | `src/sources/github/` | GitHub discovery, admission authorization, comments, pull requests and publication reads. |
19
+ | `src/executors/native/` | Native OpenCode sessions, deterministic prompts, trust snapshots and execution inspection. |
20
+ | `src/executors/flowgraph/` | Experimental Flowgraph RPC integration, worker fencing and trusted-context checks. |
21
+ | `src/workspaces/` | Worktree creation/cleanup and full-history publication scanning. |
22
+ | `src/storage/` | Durable job state, capacity fencing and local filesystem locks. |
23
+ | `src/runtime/` | Scheduler engine, service lifecycle, RPC and recovery. |
24
+ | `src/tui.tsx` | Native OpenCode TUI page. |
25
+
26
+ ## Local development
27
+
28
+ ```sh
29
+ bun install
30
+ bun run typecheck
31
+ bun run test
32
+ bun run build
33
+ bun run verify:pack
34
+ ```
35
+
36
+ `bun run build` performs the version consistency check and typechecks the
37
+ package. There is no bundled CLI or portable runtime: OpenCode loads the
38
+ TypeScript plugin source.
39
+
40
+ Taskfeed needs `git` and an authenticated `gh` for real operation. Unit and
41
+ integration tests use fakes and temporary Git repositories and make no paid
42
+ model calls.
43
+
44
+ ## Test commands
45
+
46
+ ```sh
47
+ bun run test # deterministic unit and integration suites
48
+ bun run test:unit
49
+ bun run test:integration
50
+
51
+ bun run test:real:native # real OpenCode, mock provider, native workflow only
52
+ bun run test:real:flowgraph # experimental Flowgraph coverage
53
+ bun run test:real # both real OpenCode suites
54
+ bun run test:real:github # opt-in disposable GitHub repository suite
55
+ ```
56
+
57
+ ### Native runtime integration
58
+
59
+ The native suite starts a real `opencode serve` against a temporary repository
60
+ and a deterministic OpenAI-compatible mock provider. It exercises issue
61
+ discovery, authorization, label consumption, an isolated worktree, real file
62
+ edits and commits, draft PR publication, changes requested, rework in the same
63
+ session, approval of the exact new commit, and restart recovery without
64
+ duplicate execution. It uses no Flowgraph installation and no paid model quota.
65
+
66
+ ```sh
67
+ bun run test:real:native
68
+ ```
69
+
70
+ The mock model still performs real `bash` file edits and commits. Success means
71
+ the OpenCode provider, session, permission, storage and worktree boundaries were
72
+ actually exercised; it does not claim real-model quality.
73
+
74
+ ### Experimental Flowgraph integration
75
+
76
+ Flowgraph coverage resolves the plugin from `../opencode-flowgraph` or
77
+ `FLOWGRAPH_PLUGIN`. Flowgraph failures are not a release dependency for the
78
+ native-only alpha.
79
+
80
+ ```sh
81
+ FLOWGRAPH_PLUGIN=/path/to/opencode-flowgraph bun run test:real:flowgraph
82
+ ```
83
+
84
+ ### Real disposable GitHub repository
85
+
86
+ This suite is opt-in, requires a disposable repository allowlist, and must never
87
+ target a production repository. It is not run by CI or by the release workflow.
88
+
89
+ ```sh
90
+ TASKFEED_GITHUB_ALLOWLIST=owner/disposable-repo \
91
+ REAL_GITHUB_REPOSITORY=owner/disposable-repo \
92
+ bun run test:real:github
93
+ ```
94
+
95
+ Do not execute this suite without an explicitly authorized test repository.
96
+
97
+ ## Package verification
98
+
99
+ `bun run verify:pack` packs the actual npm artifact, installs the tarball into
100
+ a clean consumer, and verifies:
101
+
102
+ - package name and version;
103
+ - public exports and native server/TUI/RPC entry points;
104
+ - required runtime dependencies and absence of Flowgraph;
105
+ - automation and publication defaults remain disabled;
106
+ - no tests, local state, worktrees, development scripts, credentials or
107
+ machine configuration are packed.
108
+
109
+ To load the packed plugin in a real OpenCode server:
110
+
111
+ ```sh
112
+ OPENCODE_BIN=/path/to/opencode bun run verify:pack
113
+ ```
114
+
115
+ That smoke starts the supported OpenCode version, loads the installed tarball
116
+ without Flowgraph, calls the Taskfeed snapshot RPC and confirms automation is
117
+ disabled. Without `OPENCODE_BIN`, packaging structure is verified and the load
118
+ smoke is reported as skipped.
119
+
120
+ ## Continuous integration
121
+
122
+ `.github/workflows/ci.yml` runs on GitHub-hosted Ubuntu with Bun 1.4.4 and
123
+ Node 22, read-only repository permissions and superseded-run cancellation:
124
+
125
+ ```sh
126
+ bun install --frozen-lockfile
127
+ bun run typecheck
128
+ bun run test
129
+ bun run build
130
+ bun run verify:pack
131
+ ```
132
+
133
+ CI does not run real model, Flowgraph or GitHub mutation suites, require
134
+ production GitHub credentials, or publish packages. GitHub Actions exist only
135
+ to develop and release Taskfeed itself; Taskfeed runtime automation never
136
+ depends on GitHub Actions.
137
+
138
+ ## Releasing
139
+
140
+ Releases publish from GitHub Actions with npm Trusted Publishing (OIDC). There is
141
+ no long-lived npm token or `NPM_TOKEN` fallback.
142
+
143
+ Prerequisites:
144
+
145
+ - public GitHub repository;
146
+ - npm CLI **11.5.1+** (the workflow installs the latest npm);
147
+ - Node **22.14+** locally for npm publishing;
148
+ - npm account with 2FA enabled.
149
+
150
+ The package version, `src/version.ts`, the Git tag and the npm dist-tag are
151
+ validated by `scripts/release.ts`. `bun run check:version` fails when they drift.
152
+
153
+ ### First publish (one-time bootstrap)
154
+
155
+ Trusted publishing can only be configured after the package exists on npm.
156
+ Bootstrap `0.1.0-alpha.1` once from a clean checkout:
157
+
158
+ ```sh
159
+ npm login
160
+ npm publish --access public --tag next
161
+ ```
162
+
163
+ `prepublishOnly` runs the full check and packed-install verification. The
164
+ bootstrap publication has no OIDC provenance; that is expected.
165
+
166
+ Then configure the trusted publisher at
167
+ `https://www.npmjs.com/package/@alvarolorentedev/opencode-taskfeed`:
168
+
169
+ 1. Open **Settings** → **Trusted Publisher**.
170
+ 2. Choose **GitHub Actions**.
171
+ 3. Enter:
172
+ - **Organization or user:** `alvarolorentedev`
173
+ - **Repository:** `opencode-taskfeed`
174
+ - **Workflow filename:** `release.yml`
175
+ - **Environment name:** leave blank
176
+ - **Allowed actions:** enable **Allow npm publish**
177
+ 4. Save.
178
+
179
+ With npm CLI 11.15+:
180
+
181
+ ```sh
182
+ npm trust github @alvarolorentedev/opencode-taskfeed \
183
+ --repo alvarolorentedev/opencode-taskfeed \
184
+ --file release.yml \
185
+ --allow-publish
186
+ ```
187
+
188
+ Verify:
189
+
190
+ ```sh
191
+ npm trust list @alvarolorentedev/opencode-taskfeed
192
+ ```
193
+
194
+ After the trusted publisher works, optionally require 2FA and disallow token
195
+ publishing in the package's **Publishing access** settings.
196
+
197
+ ### Validate trusted publishing
198
+
199
+ A new trusted publisher must complete a successful OIDC publish within **2
200
+ days**. Bump to the next prerelease, commit, tag, and push the tag:
201
+
202
+ ```sh
203
+ # edit package.json and src/version.ts to 0.1.0-alpha.2
204
+ bun run check:version
205
+ git add package.json src/version.ts docs/releases
206
+ git commit -m "release: v0.1.0-alpha.2"
207
+ git push
208
+ git tag v0.1.0-alpha.2
209
+ git push origin v0.1.0-alpha.2
210
+ ```
211
+
212
+ The tag must match both versions exactly:
213
+
214
+ - tag `v0.1.0-alpha.1` → version `0.1.0-alpha.1`
215
+
216
+ ### Prerelease versus stable
217
+
218
+ | Version | npm dist-tag | GitHub release |
219
+ |---|---|---|
220
+ | `0.1.0-alpha.1` | `next` | Prerelease |
221
+ | `0.1.0-alpha.2` | `next` | Prerelease |
222
+ | `0.1.0-beta.1` | `next` | Prerelease |
223
+ | `0.1.0` | `latest` | Stable |
224
+ | `0.1.1` | `latest` | Stable |
225
+
226
+ A prerelease never moves the `latest` dist-tag. The release workflow reads
227
+ `docs/releases/<tag>.md` and falls back to generated notes. It creates the
228
+ GitHub release with `--prerelease` for prerelease versions.
229
+
230
+ Do not move or republish an existing tag. If the exact version already exists,
231
+ the workflow does not publish it, verifies the recorded `gitHead` when GitHub
232
+ provides one, and still creates the GitHub release when appropriate. A skipped
233
+ publication explicitly reports that OIDC was not exercised.
234
+
235
+ If the package is missing from npm, the workflow stops with the bootstrap
236
+ instructions. Authentication, connectivity and registry errors are reported as
237
+ errors, never as proof that the package is unpublished.
238
+
239
+ ### Release process
240
+
241
+ ```sh
242
+ # 1. Bump the version in package.json and src/version.ts, and add
243
+ # docs/releases/v<version>.md
244
+ bun run check:version
245
+ bun run check
246
+ bun run verify:pack
247
+
248
+ # 2. Commit the release
249
+ git add package.json src/version.ts docs/releases
250
+ git commit -m "release: v<version>"
251
+ git push
252
+
253
+ # 3. Tag and push
254
+ git tag v<version>
255
+ git push origin v<version>
256
+ ```
257
+
258
+ The workflow validates the tag, installs with the frozen lockfile, runs
259
+ typecheck, tests, build and packed-install verification, publishes with OIDC,
260
+ and creates the GitHub release.
261
+
262
+ ### Verify
263
+
264
+ ```sh
265
+ npm view @alvarolorentedev/opencode-taskfeed version
266
+ npm view @alvarolorentedev/opencode-taskfeed dist-tags
267
+ npm audit signatures
268
+ ```
269
+
270
+ ### Versioning and compatibility
271
+
272
+ - Use semantic versioning. Keep the plugin ID `taskfeed`, storage namespace and
273
+ RPC identifiers stable.
274
+ - The peer range is currently `@opencode/plugin` 2.3.2 with OpenCode 2.3.x.
275
+ - A breaking RPC, configuration or job-state change is a major version.
276
+ - Prefer `npm deprecate` over unpublishing.
277
+
278
+ ### Rollback
279
+
280
+ Publish a fixed version and deprecate the broken one:
281
+
282
+ ```sh
283
+ npm deprecate @alvarolorentedev/opencode-taskfeed@0.1.0-alpha.1 "Broken prerelease; use 0.1.0-alpha.2"
284
+ ```
285
+
286
+ Do not rewrite tags. The workflow publishes exactly the tagged commit.
287
+
288
+ ### Troubleshooting
289
+
290
+ - **`ENEEDAUTH`**: the trusted publisher fields do not match the workflow
291
+ exactly. Check repository, workflow filename and `id-token: write`.
292
+ - **Provenance missing**: the repository must be public and the publish must use
293
+ OIDC.
294
+ - **Configuration expired**: recreate the trusted publisher and publish within
295
+ 2 days.
296
+ - **Wrong package version**: tag, `package.json` and `src/version.ts` must match.
297
+ - **`latest` moved to a prerelease**: this should be impossible through the
298
+ workflow; inspect the dist-tags and deprecate the bad version rather than
299
+ rewriting tags.
300
+
301
+ ## Scope restriction
302
+
303
+ This release does not implement the Flowgraph typed content-artifact contract or
304
+ a per-node admission guard. Those remain upstream requirements:
305
+
306
+ - a public Flowgraph human-gate artifact that can carry typed plan/content text
307
+ and a stable content digest;
308
+ - a per-node policy hook that lets Taskfeed revalidate trusted context before
309
+ each node side effect.
310
+
311
+ Until both exist, Flowgraph plan-only external review fails closed and its
312
+ complete SDLC integration is not advertised as production-ready.
@@ -0,0 +1,84 @@
1
+ # Integrations
2
+
3
+ ## GitHub
4
+
5
+ Taskfeed uses the authenticated `gh` CLI. It never asks for a separate GitHub token or stores one. All calls use argument arrays and JSON output; untrusted issue text never enters a shell.
6
+
7
+ ### Authentication
8
+
9
+ ```sh
10
+ gh auth login
11
+ gh auth status
12
+ ```
13
+
14
+ Taskfeed checks repository read/write access because it needs labels and comments. If publication is enabled, the existing Git credentials must also allow pushing the Taskfeed branch to the configured remote.
15
+
16
+ ### Discovery
17
+
18
+ Taskfeed lists only open, non-PR issues carrying all configured trigger labels. It then checks the timeline for the `labeled` event that applied a trigger label. The latest event actor must be in `enqueue_users`; otherwise the issue is skipped and a warning is shown. This prevents a ready label alone from becoming authorization.
19
+
20
+ Ordering is deterministic by issue creation/number. Pagination is bounded. Issue bodies and a bounded set of recent comments are treated as untrusted execution context.
21
+
22
+ ### Labels
23
+
24
+ Taskfeed owns only the configured status labels. It removes the ready trigger when work starts, then moves through running/review/blocked/completed. Unrelated labels are never removed. Labels are not distributed locks.
25
+
26
+ ### Comments and gates
27
+
28
+ Approval requests and results use hidden markers so a restart can find/edit its previous comment instead of duplicating it. A comment command is accepted only if:
29
+
30
+ - it is a comment on the same issue, created after the gate;
31
+ - the actor is in `authorized_users`;
32
+ - the gate, issue, job and revision match;
33
+ - the live GitHub PR is open and a draft, and its current head SHA matches both the gate's reviewed SHA and the current worktree HEAD;
34
+ - the gate is still open;
35
+ - the decision is a declared outcome.
36
+
37
+ Approval comments older than the gate, edited/replayed decisions, stale revisions and malformed commands are rejected. The live PR/worktree check is repeated immediately before forwarding. Natural language is never an approval.
38
+
39
+ ### Rate limits and failures
40
+
41
+ Rate-limit/auth/network failures are logged, surfaced in the TUI and retried with backoff. Job state is not guessed. A failure does not cause a duplicate execution.
42
+
43
+ ### Linked pull requests
44
+
45
+ Taskfeed reads issue timeline cross-references and resolves current PR head SHAs and draft state directly for approval. For Flowgraph it requires an existing remote draft PR with a matching head SHA; it does not create a second one.
46
+
47
+ ## Native OpenCode agents
48
+
49
+ Taskfeed validates the configured agent, creates a native session at the worktree location, and prompts it with the issue context marked as untrusted. Existing agent/model/tool/permission definitions are authoritative.
50
+
51
+ Session creation adds scoped deny rules for external directories and `.taskfeed/**`. These are additional restrictions, not a sandbox. Taskfeed never replies to a permission request. A pending permission is a blocker.
52
+
53
+ Completion uses native session outcome, pending permissions, idle-hook background work, and the worktree state. The agent must commit and leave the worktree clean. Taskfeed does not auto-commit.
54
+
55
+ Request-changes decisions continue the same session and worktree, bounded by `max_feedback_iterations`.
56
+
57
+ ## Flowgraph (experimental)
58
+
59
+ Flowgraph execution is opt-in and experimental in the `0.1.0-alpha.1` release. The native workflow does not require it.
60
+
61
+ Taskfeed uses Flowgraph's public RPC:
62
+
63
+ - `capabilities`
64
+ - `listWorkflows` (canonical validation and worktree hash match)
65
+ - `startRun`, `getRun`, `getRunStep`
66
+ - `respondRun`, `pauseRun`, `resumeRun`, `cancelRun`
67
+
68
+ It does not read Flowgraph storage, inspect internal graph state or interpret routing.
69
+
70
+ ### Worktree location
71
+
72
+ OpenCode server-plugin RPC is bound to the location where the plugin is loaded. Taskfeed activates the worktree location, then uses a Taskfeed observer at that location as a storage-backed RPC worker for Flowgraph. The canonical Taskfeed instance remains the scheduler owner and verifies:
73
+
74
+ - the workflow hash at the worktree matches the canonical validated workflow;
75
+ - the Flowgraph run session is at the worktree;
76
+ - every subsequent/parallel step session is at the worktree.
77
+
78
+ Mismatch cancels the run and blocks the job. An unverifiable session blocks external review. This is fail-closed.
79
+
80
+ The worktree must be able to load the Taskfeed and Flowgraph plugins. Use a global plugin install or commit the plugin `opencode.jsonc`/workflow files. Otherwise workflow execution fails clearly. Taskfeed does not install Flowgraph or fall back to the canonical checkout.
81
+
82
+ ### Human outcomes
83
+
84
+ Flowgraph gates expose declared outcomes. `approve` maps to `approved` and `request-changes` maps to `changes_requested` only when declared. Otherwise the external command uses a declared outcome. Taskfeed relays the decision through `respondRun` with the current revision and lets Flowgraph route.