@pourkit/cli 0.0.0-next-20260625073725 → 0.0.0-next-20260627024509

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.
@@ -50,6 +50,8 @@ After PRD-0040 migration, the **Async Adapter Seam** entry in `.pourkit/CONTEXT.
50
50
 
51
51
  Durable planning lives in PRD Plan Workspaces under `.pourkit/plans/<NNNN>-<slug>/`. See the **PRD Plan Workspace** entry in `.pourkit/CONTEXT.md` for the full definition. Explicit `publish-prd` publication is required to publish workspace content to GitHub — direct authoring skills (`to-prd`, `to-issues`) write workspace files only.
52
52
 
53
+ In Beads-backed PRD workflows, `to-prd` and `to-issues` write workspace files only — they do not publish to GitHub or write directly to Beads. Explicit `publish-prd` publication validates the workspace through the PRD Plan Workspace Publication Gate, registers the PRD and child Issues in the Beads Work Graph using deterministic IDs (`PRD-0078 -> bd-0078`, `I-01 -> bd-0078.1`), and projects GitHub Issues and labels as collaboration surfaces. GitHub Issues and labels are projections in Beads-backed workflows — they are not the authority for PRD child work readiness.
54
+
53
55
  ## Flag ADR conflicts
54
56
 
55
57
  If your output contradicts an existing ADR, surface it explicitly rather than silently overriding:
@@ -5,7 +5,7 @@ description: Publish a PRD Plan Workspace to GitHub explicitly and write PUBLISH
5
5
 
6
6
  # Publish PRD
7
7
 
8
- Publish a PRD Plan Workspace to GitHub by creating or updating a parent PRD Issue and its child Issues from authored workspace files, or a single Task Issue from a oneshot workspace. Publication metadata is written to workspace root `PUBLISH.md`. Authored `PRD.md`, `TASK.md`, and `issues/*.md` bodies are never mutated.
8
+ Publish a PRD Plan Workspace by running the PRD Plan Workspace Publication Gate, publishing GitHub Issues and labels as collaboration surfaces, and writing `PUBLISH.md` as publication metadata. When the current Pourkit install exposes a Pourkit-owned Beads publication transaction, that transaction also registers the workspace in the Beads Work Graph before GitHub projection. Agents must not perform Beads side effects manually. Authored `PRD.md`, `TASK.md`, and `issues/*.md` bodies are never mutated. The Task route remains GitHub-backed — it does not use the Beads Work Graph.
9
9
 
10
10
  ## Process
11
11
 
@@ -32,11 +32,19 @@ Inspect the workspace root to determine which route to follow:
32
32
 
33
33
  #### 2a. PRD/Plan validation
34
34
 
35
- Block before any GitHub mutation if:
35
+ Block before any Beads or GitHub mutation if:
36
36
 
37
37
  - `PRD.md` is missing or empty.
38
38
  - No `issues/I-0N-*.md` files exist — the PRD/Plan route requires at least one child Issue to publish. Block with a clear message rather than publishing an empty parent-only Issue set.
39
39
 
40
+ After file-existence checks pass, run the hard PRD Plan Workspace Publication Gate:
41
+
42
+ ```sh
43
+ pourkit validate-artifact prd-plan-workspace <workspace> --prd-ref <PRD-NNNN>
44
+ ```
45
+
46
+ If validation fails (non-zero exit), block before any Beads, GitHub Issue, or `PUBLISH.md` side effect. Authored files (`PRD.md`, `issues/*.md`), Beads state, GitHub state, and `PUBLISH.md` must remain unchanged. Report the validation diagnostics and require human review/repair — do not auto-repair.
47
+
40
48
  #### 2b. Task validation
41
49
 
42
50
  Block before any GitHub mutation if:
@@ -58,16 +66,27 @@ Read the full contents of the relevant authored files based on workspace type:
58
66
 
59
67
  Record content hashes or store the raw text for comparison at handoff. These are the exact bodies published to GitHub; do not modify them during publication.
60
68
 
61
- ### 4. Publish or update GitHub Issues
62
-
63
- Using the GitHub context available to the agent:
69
+ ### 4. Publish through the Pourkit-owned transaction
64
70
 
65
71
  **PRD/Plan route:**
66
72
 
67
- 1. Create or update the parent PRD Issue using the `PRD.md` body. Apply the PRD title derived from the first line or frontmatter of `PRD.md`.
68
- 2. For each `issues/I-0N-*.md`, create or update a child GitHub Issue using the exact file body. Derive the title from the first line or frontmatter of the file.
69
- 3. Apply intended labels to each Issue. Child Issues default to `ready-for-agent` plus exactly one `type:*` label; include `blocked` when the child has unresolved dependencies. Infer labels from file content if present, but treat `needs-triage` on PRD child Issues as stale authoring metadata and publish `ready-for-agent` instead. Parent PRDs default to `needs-triage` and must not receive `ready-for-agent` unless explicitly requested by the maintainer.
70
- 4. In the publication flow only, resolve local dependency placeholders (e.g. `I-01`, `I-02`) to GitHub issue numbers (e.g. `#124`, `#125`) in body text. This resolution happens in the GitHub publication flow only; local files are not modified.
73
+ Run the Pourkit-owned Beads-backed publication transaction:
74
+
75
+ ```sh
76
+ pourkit prd-plan-workspace publish <workspace> --prd-ref <PRD-NNNN>
77
+ ```
78
+
79
+ This command owns the full transaction:
80
+
81
+ 1. Validates the PRD Plan Workspace gate before side effects.
82
+ 2. Creates or updates Beads parent/child records and `blocks` dependency edges.
83
+ 3. Creates or updates parent and child GitHub Issues as projections.
84
+ 4. Backfills Beads `pourkit` metadata with `githubIssueNumber` and `githubIssueUrl`.
85
+ 5. Writes `PUBLISH.md` as the human-readable receipt.
86
+
87
+ Agents must not shell out to `bd` directly or hand-maintain Beads records. Beads registration, dependency edges, and metadata backfill are Pourkit implementation responsibilities only.
88
+
89
+ If this command is unavailable because the operator is running an older Pourkit install, continue with GitHub-backed publication after the validation gate. Record a warning in `PUBLISH.md` that no Beads Work Graph records were written and PRD Run must use its GitHub-compatible path until the PRD has a valid Beads epic.
71
90
 
72
91
  **Task route:**
73
92
 
@@ -79,7 +98,36 @@ Using the GitHub context available to the agent:
79
98
 
80
99
  Write workspace root `PUBLISH.md` with the appropriate structure based on workspace type:
81
100
 
82
- **PRD/Plan route:**
101
+ **PRD/Plan route with Beads-backed publication:**
102
+
103
+ Use `renderPrdPublishReceipt` or `writePrdPublishReceipt` from `pourkit/prd-plan-workspace/publish-receipt.ts` to generate the receipt programmatically. The receipt shape:
104
+
105
+ ```yaml
106
+ workspace: .pourkit/plans/<NNNN>-<slug>
107
+ route: prd
108
+ parent:
109
+ prd_ref: <PRD-NNNN>
110
+ beads_id: bd-<NNNN>
111
+ number: <number>
112
+ url: https://github.com/OWNER/REPO/issues/<number>
113
+ children:
114
+ - child_ref: I-0N
115
+ beads_id: bd-<NNNN>.<N>
116
+ number: <number>
117
+ url: https://github.com/OWNER/REPO/issues/<number>
118
+ source_file: issues/I-0N-<slug>.md
119
+ dependency_mappings:
120
+ - from: I-0N
121
+ to: I-0N
122
+ beads_edge_type: blocks
123
+ publication_timestamp: <ISO-8601>
124
+ authored_bodies_mutated: false
125
+ warnings: []
126
+ ```
127
+
128
+ **PRD/Plan route with GitHub-compatible publication:**
129
+
130
+ Use this shape when no Pourkit-owned Beads publication transaction is available and no Beads records were written:
83
131
 
84
132
  ```yaml
85
133
  workspace: .pourkit/plans/<NNNN>-<slug>
@@ -96,11 +144,14 @@ children:
96
144
  - ready-for-agent
97
145
  - type:feature
98
146
  dependency_mappings:
99
- - local: I-0N
100
- github: "#<number>"
147
+ - from: I-0N
148
+ to: I-0N
149
+ github_from: "#<number>"
150
+ github_to: "#<number>"
101
151
  publication_timestamp: <ISO-8601>
102
152
  authored_bodies_mutated: false
103
- warnings: []
153
+ warnings:
154
+ - Beads publication transaction unavailable; no Beads Work Graph records were written.
104
155
  ```
105
156
 
106
157
  **Task route:**
@@ -130,24 +181,51 @@ Compare content hashes or raw text of all authored files against what was read i
130
181
 
131
182
  ## Validation receipt
132
183
 
133
- **PRD/Plan route success:**
184
+ **PRD/Plan route success with Beads-backed publication:**
134
185
 
135
186
  ```yaml
136
187
  workspace: .pourkit/plans/<NNNN>-<slug>
137
188
  route: prd
138
189
  parent:
190
+ prd_ref: PRD-0078
191
+ beads_id: bd-0078
139
192
  number: 123
140
193
  url: https://github.com/OWNER/REPO/issues/123
141
194
  children:
142
- - id: I-01
195
+ - child_ref: I-01
196
+ beads_id: bd-0078.1
143
197
  number: 124
144
198
  url: https://github.com/OWNER/REPO/issues/124
199
+ source_file: issues/I-01-example.md
145
200
  dependency_mappings: []
146
- publish_path: .pourkit/plans/<NNNN>-<slug>/PUBLISH.md
201
+ publication_timestamp: <ISO-8601>
147
202
  authored_bodies_mutated: false
148
203
  warnings: []
149
204
  ```
150
205
 
206
+ **PRD/Plan route success with GitHub-compatible publication:**
207
+
208
+ ```yaml
209
+ workspace: .pourkit/plans/<NNNN>-<slug>
210
+ route: prd
211
+ parent:
212
+ number: 123
213
+ url: https://github.com/OWNER/REPO/issues/123
214
+ children:
215
+ - id: I-01
216
+ title: PRD-0078 / I-01: Example
217
+ number: 124
218
+ url: https://github.com/OWNER/REPO/issues/124
219
+ labels:
220
+ - ready-for-agent
221
+ - type:feature
222
+ dependency_mappings: []
223
+ publication_timestamp: <ISO-8601>
224
+ authored_bodies_mutated: false
225
+ warnings:
226
+ - Beads publication transaction unavailable; no Beads Work Graph records were written.
227
+ ```
228
+
151
229
  **Task route success:**
152
230
 
153
231
  ```yaml
@@ -166,10 +244,14 @@ On block or failure, return a blocker summary with the reason and required actio
166
244
  ## Edge cases
167
245
 
168
246
  - **Missing `PRD.md` in PRD/Plan route**: block before any GitHub mutation. Report the missing file path.
247
+ - **Validation gate failure in PRD/Plan route**: `pourkit validate-artifact prd-plan-workspace` exits non-zero. Block before any Beads, GitHub Issue, or `PUBLISH.md` side effect. Diagnostics are from the gate command. Authored files, Beads state, GitHub state, and `PUBLISH.md` remain unchanged. Do not auto-repair — require human review/repair.
169
248
  - **Missing `TASK.md` in Task route**: block before any GitHub mutation. Report the missing file path.
170
249
  - **No `issues/I-0N-*.md` in PRD/Plan route**: block — PRD/Plan route requires at least one child Issue. Do not publish parent-only.
171
250
  - **Both `PRD.md` and `TASK.md` present**: ask the user which to publish before proceeding.
172
251
  - **Neither `PRD.md` nor `TASK.md` present**: block with a clear message naming the workspace path.
252
+ - **Beads publication transaction unavailable**: continue with GitHub-compatible publication after validation. Do not call `bd` manually. Include the warning in `PUBLISH.md`.
253
+ - **Beads registration failure from a Pourkit-owned transaction**: block before any GitHub Issue mutation. Pourkit reports this when Beads is unavailable (missing binary or unusable state) or when a Beads command fails. Report the failure and require human intervention.
254
+ - **Beads metadata update failure after GitHub projection in a Pourkit-owned transaction**: block before writing `PUBLISH.md`. Report the parent or child Beads ID and GitHub issue number/URL that failed to persist. Do not treat `PUBLISH.md` as a substitute runtime database.
173
255
  - **Existing `PUBLISH.md`**: update it as publication metadata. This is a receipt update, not source behavior mutation.
174
256
  - **Existing GitHub Issues**: update bodies and labels rather than creating duplicates. Match by title heuristic or by previous `PUBLISH.md` record.
175
257
  - **Missing GitHub token or repo context**: block with setup guidance.
@@ -179,23 +261,84 @@ On block or failure, return a blocker summary with the reason and required actio
179
261
  **PRD/Plan route:**
180
262
 
181
263
  ```yaml
264
+ workspace: string
265
+ route: "prd"
182
266
  parent:
267
+ prd_ref: string
268
+ beads_id: string
183
269
  number: number
184
270
  url: string
185
271
  children:
186
- - id: I-0N
272
+ - child_ref: string
273
+ beads_id: string
274
+ number: number
275
+ url: string
276
+ source_file: string
277
+ dependency_mappings:
278
+ - from: string
279
+ to: string
280
+ beads_edge_type: "blocks"
281
+ publication_timestamp: ISO-8601 string
282
+ authored_bodies_mutated: false
283
+ warnings: string[]
284
+ ```
285
+
286
+ **PRD/Plan route with GitHub-compatible publication:**
287
+
288
+ ```yaml
289
+ workspace: string
290
+ route: "prd"
291
+ parent:
292
+ number: number
293
+ url: string
294
+ children:
295
+ - id: string
187
296
  title: string
188
297
  number: number
189
298
  url: string
190
299
  labels: string[]
191
300
  dependency_mappings:
192
- - local: I-0N
193
- github: "#<number>"
301
+ - from: string
302
+ to: string
303
+ github_from: string
304
+ github_to: string
194
305
  publication_timestamp: ISO-8601 string
195
306
  authored_bodies_mutated: false
196
307
  warnings: string[]
197
308
  ```
198
309
 
310
+ > **Contract**: `PUBLISH.md` is a human-readable receipt and is not the runtime authority for PRD Run selection. When Beads-backed publication is used, Beads metadata is the authoritative source for PRD child work identity, dependencies, and readiness. When GitHub-compatible publication is used because no Pourkit-owned Beads transaction exists, no Beads authority is claimed for that PRD and PRD Run must use its GitHub-compatible path unless a valid Beads epic is later created by Pourkit.
311
+
312
+ TypeScript contract (from `pourkit/prd-plan-workspace/publish-receipt.ts`):
313
+
314
+ ```ts
315
+ export type PrdPublishReceiptOptions = {
316
+ workspacePath: string;
317
+ parent: {
318
+ prdRef: string;
319
+ beadsId: string;
320
+ githubIssue: { number: number; url: string };
321
+ };
322
+ children: Array<{
323
+ childRef: string;
324
+ beadsId: string;
325
+ githubIssue: { number: number; url: string };
326
+ sourceFile: string;
327
+ }>;
328
+ dependencyMappings: Array<{
329
+ from: string;
330
+ to: string;
331
+ beadsEdgeType: "blocks";
332
+ }>;
333
+ publicationTimestamp: string;
334
+ authoredBodiesMutated: false;
335
+ warnings: string[];
336
+ };
337
+
338
+ export function renderPrdPublishReceipt(options: PrdPublishReceiptOptions): string;
339
+ export function writePrdPublishReceipt(options: PrdPublishReceiptOptions & { workspaceRoot: string }): Promise<string>;
340
+ ```
341
+
199
342
  **Task route:**
200
343
 
201
344
  ```yaml
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pourkit/cli",
3
- "version": "0.0.0-next-20260625073725",
3
+ "version": "0.0.0-next-20260627024509",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "repository": {