@davidorex/pi-project-workflows 0.14.4 → 0.26.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.
@@ -0,0 +1,684 @@
1
+ ---
2
+ name: pi-context
3
+ description: >
4
+ Schema-driven project state management with typed JSON blocks, schema
5
+ validation, substrate config, lens views, closure-table relations, and
6
+ cross-block referential integrity. Use when managing .project/ blocks,
7
+ scaffolding project structure, installing block kinds from the packaged samples
8
+ catalog, validating project state, rendering lens views, or adding work items.
9
+ ---
10
+
11
+ <tools_reference>
12
+ <tool name="append-block-item">
13
+ Append an item to an array in a project block file. Schema validation is automatic. Set autoId:true to allocate the next id from the block's id pattern when the item has no id.
14
+
15
+ *Append items to project blocks (issues, decisions, or any user-defined block)*
16
+
17
+ | Parameter | Type | Required | Description |
18
+ |-----------|------|----------|-------------|
19
+ | `block` | string | yes | Block name (e.g., 'issues', 'decisions') |
20
+ | `arrayKey` | string | yes | Array key in the block (e.g., 'issues', 'decisions') |
21
+ | `item` | unknown | yes | Item object to append — must conform to block schema |
22
+ | `autoId` | boolean | no | When true and the item has no id, allocate the next id from the block's id pattern |
23
+ </tool>
24
+
25
+ <tool name="update-block-item">
26
+ Update fields on an item in a project block array. Finds by predicate field match.
27
+
28
+ *Update items in project blocks — change status, add details, mark resolved*
29
+
30
+ | Parameter | Type | Required | Description |
31
+ |-----------|------|----------|-------------|
32
+ | `block` | string | yes | Block name (e.g., 'issues', 'decisions') |
33
+ | `arrayKey` | string | yes | Array key in the block |
34
+ | `match` | object | yes | Fields to match (e.g., { id: 'issue-123' }) |
35
+ | `updates` | object | yes | Fields to update (e.g., { status: 'resolved' }) |
36
+ </tool>
37
+
38
+ <tool name="append-relation">
39
+ Append a closure-table relation (edge: parent, child, relation_type, optional ordinal) to relations.json. Shape is AJV-validated; an exact-duplicate edge (same parent+child+relation_type) is a no-op. Reference integrity (endpoints resolve, relation_type registered, no cycle) is NOT checked here — run context-validate after. Creates relations.json if absent.
40
+
41
+ *Create a relation/edge between two items (parent→child under a relation_type)*
42
+
43
+ | Parameter | Type | Required | Description |
44
+ |-----------|------|----------|-------------|
45
+ | `parent` | string | yes | Canonical id (or lens bin name) of the parent endpoint |
46
+ | `child` | string | yes | Canonical id of the child endpoint |
47
+ | `relation_type` | string | yes | Registered relation_type canonical_id / hierarchy edge type / lens id |
48
+ | `ordinal` | integer | no | Optional sibling-ordering within (parent, relation_type) |
49
+ </tool>
50
+
51
+ <tool name="append-block-nested-item">
52
+ Append an item to a nested array on a parent-array item in a project block. Schema validation is automatic.
53
+
54
+ *Append items to nested arrays inside parent items (e.g., findings inside a review)*
55
+
56
+ | Parameter | Type | Required | Description |
57
+ |-----------|------|----------|-------------|
58
+ | `block` | string | yes | Block name (e.g., 'spec-reviews') |
59
+ | `arrayKey` | string | yes | Parent array key (e.g., 'reviews') |
60
+ | `match` | object | yes | Fields to match the parent item (e.g., { id: 'REVIEW-001' }) |
61
+ | `nestedKey` | string | yes | Nested array key on the matched parent (e.g., 'findings') |
62
+ | `item` | unknown | yes | Item object to append to the nested array — must conform to schema |
63
+ </tool>
64
+
65
+ <tool name="update-block-nested-item">
66
+ Update fields on a nested-array item inside a parent-array item in a project block. Finds parent and nested by predicate field match. Throws on parent or nested miss (mirrors update-block-item semantics).
67
+
68
+ *Update items inside nested arrays — change finding state, mark resolved*
69
+
70
+ | Parameter | Type | Required | Description |
71
+ |-----------|------|----------|-------------|
72
+ | `block` | string | yes | Block name (e.g., 'spec-reviews') |
73
+ | `arrayKey` | string | yes | Parent array key (e.g., 'reviews') |
74
+ | `match` | object | yes | Fields to match the parent item (e.g., { id: 'REVIEW-001' }) |
75
+ | `nestedKey` | string | yes | Nested array key on the matched parent (e.g., 'findings') |
76
+ | `nestedMatch` | object | yes | Fields to match the nested item (e.g., { id: 'F-001' }) |
77
+ | `updates` | object | yes | Fields to update on the nested item (e.g., { state: 'resolved' }) |
78
+ </tool>
79
+
80
+ <tool name="remove-block-item">
81
+ Remove items matching a predicate from a top-level array in a project block. Idempotent — returns { removed: 0 } on no match without throwing. Schema validation runs after removal.
82
+
83
+ *Remove items from project blocks — prune retracted issues, dedupe entries*
84
+
85
+ | Parameter | Type | Required | Description |
86
+ |-----------|------|----------|-------------|
87
+ | `block` | string | yes | Block name (e.g., 'issues') |
88
+ | `arrayKey` | string | yes | Top-level array key (e.g., 'issues') |
89
+ | `match` | object | yes | Fields to match (e.g., { id: 'issue-123' }) |
90
+ </tool>
91
+
92
+ <tool name="remove-block-nested-item">
93
+ Remove items matching a predicate from a nested array on a parent-array item in a project block. Throws on parent miss; returns { removed: 0 } on nested miss without throwing.
94
+
95
+ *Remove nested items — drop rejected findings, retract nested references*
96
+
97
+ | Parameter | Type | Required | Description |
98
+ |-----------|------|----------|-------------|
99
+ | `block` | string | yes | Block name (e.g., 'spec-reviews') |
100
+ | `arrayKey` | string | yes | Parent array key (e.g., 'reviews') |
101
+ | `match` | object | yes | Fields to match the parent item (e.g., { id: 'REVIEW-001' }) |
102
+ | `nestedKey` | string | yes | Nested array key on the matched parent (e.g., 'findings') |
103
+ | `nestedMatch` | object | yes | Fields to match the nested items to remove (e.g., { id: 'F-001' }) |
104
+ </tool>
105
+
106
+ <tool name="read-block-dir">
107
+ Enumerate and parse all .json files in a .project/<subdir>/ directory, returned as a sorted array. Missing directories return [].
108
+
109
+ *Enumerate project block subdirectories (phases, schemas, etc.) as parsed JSON*
110
+
111
+ | Parameter | Type | Required | Description |
112
+ |-----------|------|----------|-------------|
113
+ | `subdir` | string | yes | Subdirectory under .project/ (e.g., 'phases', 'schemas') |
114
+ </tool>
115
+
116
+ <tool name="read-block">
117
+ Read a project block file as structured JSON.
118
+
119
+ *Read a project block as structured JSON*
120
+
121
+ | Parameter | Type | Required | Description |
122
+ |-----------|------|----------|-------------|
123
+ | `block` | string | yes | Block name (e.g., 'issues', 'tasks', 'requirements') |
124
+ </tool>
125
+
126
+ <tool name="write-block">
127
+ Write or replace an entire project block with schema validation.
128
+
129
+ *Write or replace a project block with schema validation*
130
+
131
+ | Parameter | Type | Required | Description |
132
+ |-----------|------|----------|-------------|
133
+ | `block` | string | yes | Block name (e.g., 'project', 'architecture') |
134
+ | `data` | unknown | yes | Complete block data — must conform to block schema |
135
+ </tool>
136
+
137
+ <tool name="context-status">
138
+ Get derived context state — source metrics, block summaries, planning lifecycle status.
139
+
140
+ *Get context state — source metrics, block summaries, planning lifecycle status*
141
+
142
+ </tool>
143
+
144
+ <tool name="context-validate">
145
+ Validate cross-block referential integrity — check that IDs referenced across blocks exist.
146
+
147
+ *Validate cross-block referential integrity*
148
+
149
+ </tool>
150
+
151
+ <tool name="read-config">
152
+ Read the substrate config.json as structured JSON — vocabulary, lenses, relation_types, status_buckets, display_strings, layers, block_kinds, installed_schemas, installed_blocks.
153
+
154
+ *Read project config — vocabulary, lenses, relation_types, status_buckets*
155
+
156
+ </tool>
157
+
158
+ <tool name="list-tools">
159
+ List every tool bound into the current Pi session — name, description, parameter JSON-schema, and source extension — plus which tools are currently active. Self-introspection of the agent's own tool surface (all loaded extensions + builtins).
160
+
161
+ *Discover available tools — names, params, descriptions, active set*
162
+
163
+ </tool>
164
+
165
+ <tool name="read-samples-catalog">
166
+ Enumerate installable sample block kinds (DEC-0037 packaged view): per kind — title, description, item shape, applicable relation_types (as source/target), invariants, lenses — plus top-level relation_type/lens/invariant/layer/status_bucket registries. Package-intrinsic: reads the extension's bundled samples catalog, independent of any project. Optional `kind` returns one packaged kind.
167
+
168
+ *Discover installable sample block kinds — title, shape, relation_types, invariants, lenses*
169
+
170
+ | Parameter | Type | Required | Description |
171
+ |-----------|------|----------|-------------|
172
+ | `kind` | string | no | Filter to one block_kind canonical_id (e.g. 'tasks') |
173
+ </tool>
174
+
175
+ <tool name="context-current-state">
176
+ Derive 'where are we + what's next' purely from .project substrate — focus, in-flight tasks, ranked atomic-next actions (open framework-gaps then unblocked planned tasks), and blocked tasks. No writes; nothing hand-stored.
177
+
178
+ *Derive current project state — focus, in-flight, next actions, blocked*
179
+
180
+ </tool>
181
+
182
+ <tool name="context-bootstrap-state">
183
+ Derive the substrate bootstrap state for the cwd, purely from the filesystem (DEC-0040): 'no-pointer' | 'no-config' | 'not-installed' | 'ready', plus the resolved contextDir and any declared-but-unmaterialized installed assets. Unlike every other tool, this NEVER throws on an un-bootstrapped substrate — it returns 'no-pointer' so you can detect a fresh substrate and tell the human to run /context start (bootstrap is human-only). No writes.
184
+
185
+ *Derive substrate bootstrap state — no-pointer | no-config | not-installed | ready (never throws pre-bootstrap)*
186
+
187
+ </tool>
188
+
189
+ <tool name="rename-canonical-id">
190
+ Rename a canonical_id (kind: item | relation_type | lens | layer) from oldId to newId across all substrate surfaces that carry it as DATA — item home block + relations.json edges, or the relevant config registries. Out-of-substrate occurrences (analysis MDs, git history) are REPORTED, never rewritten. block_kind renames are unsupported (filesystem cascade). Use dryRun to preview the would-change counts without writing.
191
+
192
+ *Rename a canonical_id (item/relation_type/lens/layer) across substrate; dryRun to preview*
193
+
194
+ | Parameter | Type | Required | Description |
195
+ |-----------|------|----------|-------------|
196
+ | `kind` | string | yes | One of: item | relation_type | lens | layer |
197
+ | `oldId` | string | yes | Current canonical_id to rename from |
198
+ | `newId` | string | yes | New canonical_id to rename to |
199
+ | `dryRun` | boolean | no | Compute would-change counts without writing |
200
+ </tool>
201
+
202
+ <tool name="amend-config">
203
+ Scoped add / replace / remove of ONE entry in ONE config.json registry (block_kinds, relation_types, lenses, layers, invariants, status_buckets, display_strings, naming, installed_schemas, installed_blocks, hierarchy). The whole resulting config is AJV-validated (SHAPE) and op-correctness is enforced (add ⇒ key absent, replace/remove ⇒ key present). Cross-registry referential integrity (removing a still-referenced relation_type / lens / layer / block_kind) is NOT checked here — run context-validate after. dryRun previews without writing.
204
+
205
+ *Add/replace/remove one entry in a config.json registry (vocabulary, lenses, invariants, status_buckets)*
206
+
207
+ | Parameter | Type | Required | Description |
208
+ |-----------|------|----------|-------------|
209
+ | `registry` | string | yes | One of: block_kinds | relation_types | lenses | layers | invariants | status_buckets | display_strings | naming | installed_schemas | installed_blocks | hierarchy |
210
+ | `operation` | string | yes | add | replace | remove |
211
+ | `key` | string | yes | Entry key: id for keyed-array (block_kinds/relation_types/lenses/layers/invariants), map key for map (status_buckets/display_strings/naming), the string value for string-array (installed_schemas/installed_blocks), or a JSON {parent_block, child_block, relation_type} for hierarchy |
212
+ | `entry` | unknown | no | Entry payload: object for keyed-array/hierarchy, string for map value; omit for remove. For keyed-array its id field must equal key; for string-array (when given) it must equal key |
213
+ | `dryRun` | boolean | no | Preview the op without writing config.json |
214
+ </tool>
215
+
216
+ <tool name="read-schema">
217
+ Read a substrate schema by name as parsed JSON. Returns null when the schema file is absent.
218
+
219
+ *Read a block schema as structured JSON*
220
+
221
+ | Parameter | Type | Required | Description |
222
+ |-----------|------|----------|-------------|
223
+ | `schemaName` | string | yes | Schema name without extension (e.g., 'tasks', 'decisions', 'issues') |
224
+ </tool>
225
+
226
+ <tool name="write-schema">
227
+ Create or replace a substrate block-kind JSON Schema. operation 'create' requires the schema absent; 'replace' requires it present. The body is AJV draft-07 meta-validated before an atomic write. CAVEAT: a 'replace' that changes the schema's version does NOT migrate existing block items — read-time validateBlockWithMigration throws a version mismatch until a code-level MigrationFn is registered (no tool surface for that). Registering the block_kind that points at this schema is a separate step (amend-config block_kinds).
228
+
229
+ *Create or replace a block-kind JSON Schema (meta-validated, atomic)*
230
+
231
+ | Parameter | Type | Required | Description |
232
+ |-----------|------|----------|-------------|
233
+ | `operation` | string | yes | create | replace |
234
+ | `schemaName` | string | yes | Schema name without extension (e.g., 'tasks') |
235
+ | `schema` | unknown | yes | The whole JSON Schema object (draft-07). Accepts a JSON string. |
236
+ | `dryRun` | boolean | no | Meta-validate without writing |
237
+ </tool>
238
+
239
+ <tool name="context-init">
240
+ Initialize the substrate dir (bootstrap pointer + dirs only; run accept-all + install to populate).
241
+
242
+ *Initialize the substrate dir (bootstrap pointer + dirs only; run accept-all + install to populate)*
243
+
244
+ | Parameter | Type | Required | Description |
245
+ |-----------|------|----------|-------------|
246
+ | `contextDir` | string | yes | Substrate dir name (e.g. .project). Required per DEC-0015 — no default. |
247
+ </tool>
248
+
249
+ <tool name="context-accept-all">
250
+ Adopt the canonical packaged conception (samples/conception.json) as this substrate's config.json (accept-all). Writes config only — run install after. Idempotent: never overwrites an existing config.
251
+
252
+ *Adopt the canonical conception as config (accept-all)*
253
+
254
+ </tool>
255
+
256
+ <tool name="filter-block-items">
257
+ Filter the array items of a block by a single-field predicate (eq / neq / in / matches). Discovers the single top-level array property in the block; items missing the predicate field are never matched. Wraps the canonical readBlock + caller-side filter into one queryable surface; never mutates the block.
258
+
259
+ *Filter a block's items by a predicate — eq / neq / in / matches against a single field*
260
+
261
+ | Parameter | Type | Required | Description |
262
+ |-----------|------|----------|-------------|
263
+ | `block` | string | yes | Block name (e.g., 'tasks', 'decisions', 'framework-gaps', 'context-contracts') |
264
+ | `field` | string | yes | Item field to test (e.g., 'status', 'priority', 'id') |
265
+ | `op` | unknown | yes | Comparison operator: eq (===), neq (!==), in (value is array, item[field] in it), matches (regexp test on string) |
266
+ | `value` | unknown | yes | Comparison value — scalar for eq/neq, array for in, regexp pattern string for matches |
267
+ </tool>
268
+
269
+ <tool name="resolve-item-by-id">
270
+ Look up the block, array key, and item payload for a given ID across all .project/ blocks. Returns null when no item matches. Mirrors the resolveItemById SDK function and shares its prefix-vs-block invariant — IDs whose prefix maps to a known block but live elsewhere throw at index-build time.
271
+
272
+ *Resolve a kind-prefixed ID (DEC-/FEAT-/FGAP-/issue-/REQ-/TASK-/etc.) to its owning block and item*
273
+
274
+ | Parameter | Type | Required | Description |
275
+ |-----------|------|----------|-------------|
276
+ | `id` | string | yes | Kind-prefixed ID, e.g., DEC-0001 / FEAT-001 / FGAP-003 / issue-064 |
277
+ </tool>
278
+
279
+ <tool name="read-block-item">
280
+ Read a single item from a named block by its id — returns the item or null. Block-scoped (unlike resolve-item-by-id, which searches all blocks by kind-prefixed id). Avoids fetching a whole large block to get one item.
281
+
282
+ *Read one item from a block by id (block-scoped; null if absent)*
283
+
284
+ | Parameter | Type | Required | Description |
285
+ |-----------|------|----------|-------------|
286
+ | `block` | string | yes | Block name (e.g., 'tasks', 'decisions', 'framework-gaps') |
287
+ | `id` | string | yes | Item id within the block (e.g., 'TASK-001') |
288
+ </tool>
289
+
290
+ <tool name="read-block-page">
291
+ Paginate a block's items: returns { items, total, hasMore }. offset default 0, limit default 50. Use for blocks too large to fetch whole (past the 50KB read-block cap). total is the full item count; hasMore signals another page.
292
+
293
+ *Paginate a block's items — offset + limit; returns {items,total,hasMore}*
294
+
295
+ | Parameter | Type | Required | Description |
296
+ |-----------|------|----------|-------------|
297
+ | `block` | string | yes | Block name (e.g., 'framework-gaps', 'decisions', 'issues') |
298
+ | `offset` | integer | no | Start index (default 0) |
299
+ | `limit` | integer | no | Max items to return (default 50) |
300
+ </tool>
301
+
302
+ <tool name="join-blocks">
303
+ Join two blocks in one call (FGAP-043). EDGE mode: pass `relationType` — pairs left items with right-block items connected by that relations.json edge (`leftEndpoint` parent|child, default parent). FIELD mode: pass `leftField`+`rightField` — pairs where left[leftField] === right[rightField]. Optional left pre-filter via where{Field,Op,Value}. Returns [{left, right:[]}] (right always an array; one-to-many). Use instead of N+1 read-block + resolve calls.
304
+
305
+ *Join two blocks in one call — by relation edge or shared field; returns {left,right[]} pairs*
306
+
307
+ | Parameter | Type | Required | Description |
308
+ |-----------|------|----------|-------------|
309
+ | `leftBlock` | string | yes | Left block name (e.g., 'tasks') |
310
+ | `rightBlock` | string | yes | Right block name (e.g., 'verification') |
311
+ | `relationType` | string | no | Edge mode: relations.json relation_type |
312
+ | `leftField` | string | no | Field mode: left item field |
313
+ | `rightField` | string | no | Field mode: right item field |
314
+ | `leftEndpoint` | unknown | no | Edge mode: is the left item the edge parent (default) or child |
315
+ | `whereField` | string | no | Optional left pre-filter field |
316
+ | `whereOp` | unknown | no | |
317
+ | `whereValue` | unknown | no | Optional left pre-filter value |
318
+ </tool>
319
+
320
+ <tool name="resolve-items-by-id">
321
+ Bulk variant of resolve-item-by-id — resolve N kind-prefixed ids against a single buildIdIndex traversal. Returns an object mapping each input id to its ItemLocation (block / arrayKey / item) or null when not found. Coexists with the singular resolve-item-by-id tool; bulk collapses the N×singular-call pattern for callers resolving multiple ids in one render pass.
322
+
323
+ *Resolve a batch of kind-prefixed ids (DEC-/FGAP-/TASK-/issue-/REQ-/...) in one call*
324
+
325
+ | Parameter | Type | Required | Description |
326
+ |-----------|------|----------|-------------|
327
+ | `ids` | array | yes | Array of kind-prefixed ids (DEC-/FGAP-/TASK-/issue-/REQ-/...) to resolve in one call |
328
+ </tool>
329
+
330
+ <tool name="complete-task">
331
+ Complete a task with verification gate — requires a passing verification entry targeting the task.
332
+
333
+ *Complete a task — gates on passing verification before updating status*
334
+
335
+ | Parameter | Type | Required | Description |
336
+ |-----------|------|----------|-------------|
337
+ | `taskId` | string | yes | Task ID to complete |
338
+ | `verificationId` | string | yes | Verification entry ID (must target this task with status 'passed') |
339
+ </tool>
340
+
341
+ <tool name="context-validate-relations">
342
+ Validate substrate relations.json edges against config-declared lenses + hierarchy + relation_types and the cross-block id index. Returns SubstrateValidationResult with status (clean/warnings/invalid) and per-issue diagnostics.
343
+
344
+ *Validate substrate relations against config + items*
345
+
346
+ </tool>
347
+
348
+ <tool name="context-edges-for-lens">
349
+ Materialize the Edge[] for a named lens — synthetic edges from derived_from_field for auto-derived lenses; authored edges filtered by relation_type for hand-curated lenses; unioned items from composition members for kind=composition lenses.
350
+
351
+ *Materialize edges for a named lens (auto-derived or hand-curated)*
352
+
353
+ | Parameter | Type | Required | Description |
354
+ |-----------|------|----------|-------------|
355
+ | `lensId` | string | yes | Lens id from config.lenses[].id |
356
+ </tool>
357
+
358
+ <tool name="context-walk-descendants">
359
+ Walk closure-table descendants of a parent id under a given relation_type. Returns string[] of descendant ids (may be empty if no children or relations.json absent).
360
+
361
+ *Walk closure-table descendants under a relation_type*
362
+
363
+ | Parameter | Type | Required | Description |
364
+ |-----------|------|----------|-------------|
365
+ | `parentId` | string | yes | Parent id (canonical id or lens bin name) |
366
+ | `relationType` | string | yes | Relation type from config.relation_types[].canonical_id |
367
+ </tool>
368
+
369
+ <tool name="walk-ancestors">
370
+ Walk closure-table ancestors of an item id under a given relation_type — reverse-direction counterpart to context-walk-descendants. Returns string[] of ancestor ids (may be empty if no parents or relations.json absent).
371
+
372
+ *Walk closure-table ancestors under a relation_type*
373
+
374
+ | Parameter | Type | Required | Description |
375
+ |-----------|------|----------|-------------|
376
+ | `itemId` | string | yes | Child item id whose ancestors are sought |
377
+ | `relationType` | string | yes | Relation type from config.relation_types[].canonical_id |
378
+ </tool>
379
+
380
+ <tool name="find-references">
381
+ Find all closure-table edges incident on an item id (inbound, outbound, or both). Returns Edge[] preserving relation_type + ordinal per record — edge-level view, not the id-chain projection that walk-ancestors / context-walk-descendants emit.
382
+
383
+ *Find closure-table edges incident on an item id*
384
+
385
+ | Parameter | Type | Required | Description |
386
+ |-----------|------|----------|-------------|
387
+ | `itemId` | string | yes | Item id whose incident edges are sought |
388
+ | `direction` | unknown | no | inbound: edges where child === itemId; outbound: edges where parent === itemId; both: union (default). |
389
+ </tool>
390
+
391
+ <tool name="gather-execution-context">
392
+ Compose a ContextBundle for a work-unit by reading its context-contract (by unit_kind) and walking declared relation_types bidirectionally per direction semantic. Returns unit + perRelationType buckets of resolved items + traversal_depth + scoped_at. Per DEC-0017 substrate primitive serving harness-confined dispatch.
393
+
394
+ *Compose ContextBundle for unit + context-contract-declared bundle_relation_types*
395
+
396
+ | Parameter | Type | Required | Description |
397
+ |-----------|------|----------|-------------|
398
+ | `unitId` | string | yes | Work-unit id (e.g. TASK-NNN / DEC-NNNN / FGAP-NNN) |
399
+ | `kind` | string | yes | Unit-kind type tag (e.g. 'task', 'decision', 'verification') matching a context-contract entry's unit_kind |
400
+ | `maxDepth` | integer | no | Override per-relation-type max_depth via Math.min against each spec.max_depth |
401
+ </tool>
402
+
403
+ <tool name="context-roadmap-load">
404
+ Load a roadmap by id and return the materialized RoadmapView (phases, lens-views, status rollup, milestone resolution, scoped phase_depends_on edges, topo-ordered phaseOrder + cycles). Per DEC-0012 phase ordering lives in relations.json with relation_type='phase_depends_on'.
405
+
406
+ *Load a roadmap by id*
407
+
408
+ | Parameter | Type | Required | Description |
409
+ |-----------|------|----------|-------------|
410
+ | `roadmapId` | string | yes | ROADMAP-NNN id from <config.root>/roadmap.json |
411
+ </tool>
412
+
413
+ <tool name="context-roadmap-render">
414
+ Render a roadmap by id as pure-textual markdown — phase order list, per-phase adjacency lines (sourced from view.edges, alphabetically sorted), status rollup counts, milestone resolution, exit criteria. NO mermaid / graph syntax: per-phase **Depends on:** lines come strictly from authored phase_depends_on edges scoped to in-roadmap phases.
415
+
416
+ *Render a roadmap as markdown*
417
+
418
+ | Parameter | Type | Required | Description |
419
+ |-----------|------|----------|-------------|
420
+ | `roadmapId` | string | yes | ROADMAP-NNN id from <config.root>/roadmap.json |
421
+ </tool>
422
+
423
+ <tool name="context-roadmap-validate">
424
+ Validate every roadmap × phase × milestone in <config.root>/roadmap.json. Codes: roadmap_lens_missing, roadmap_phase_dep_missing, roadmap_phase_cycle, roadmap_composition_cycle, roadmap_milestone_evidence_block_missing, roadmap_milestone_query_invalid, roadmap_status_unknown_value. Display strings flow through config.display_strings (pi-context divergence). Optional roadmapId filter restricts issue list to a single roadmap.
425
+
426
+ *Validate roadmaps*
427
+
428
+ | Parameter | Type | Required | Description |
429
+ |-----------|------|----------|-------------|
430
+ | `roadmapId` | string | no | Filter to issues matching this roadmap_id (omit for full-project validation) |
431
+ </tool>
432
+
433
+ <tool name="context-roadmap-list">
434
+ List every roadmap in <config.root>/roadmap.json with id, title, optional status, and phase count. Returns [] when roadmap.json absent (opt-in block; absence is the truthful answer).
435
+
436
+ *List roadmaps*
437
+
438
+ </tool>
439
+
440
+ </tools_reference>
441
+
442
+ <commands_reference>
443
+ <command name="/context">
444
+ Context state management
445
+
446
+ Subcommands: `init`, `install`, `accept-all`, `view`, `lens-curate`, `roadmap-list`, `roadmap-view`, `roadmap-validate`, `status`, `add-work`, `validate`, `help`
447
+ </command>
448
+
449
+ </commands_reference>
450
+
451
+ <events>
452
+ `session_start`
453
+ </events>
454
+
455
+ <bundled_resources>
456
+ 9 schemas, 31 samples bundled.
457
+ See references/bundled-resources.md for full inventory.
458
+ </bundled_resources>
459
+
460
+ <installable_blocks>
461
+
462
+ Names valid for the `installed_blocks` array in `.project/config.json`. Install with `/context install <block>`.
463
+
464
+ | Block | Source File |
465
+ |-------|-------------|
466
+ | `decisions` | `samples/blocks/decisions.json` |
467
+ | `framework-gaps` | `samples/blocks/framework-gaps.json` |
468
+ | `tasks` | `samples/blocks/tasks.json` |
469
+ | `verification` | `samples/blocks/verification.json` |
470
+ | `issues` | `samples/blocks/issues.json` |
471
+ | `features` | `samples/blocks/features.json` |
472
+ | `research` | `samples/blocks/research.json` |
473
+ | `rationale` | `samples/blocks/rationale.json` |
474
+ | `spec-reviews` | `samples/blocks/spec-reviews.json` |
475
+ | `layer-plans` | `samples/blocks/layer-plans.json` |
476
+ | `requirements` | `samples/blocks/requirements.json` |
477
+ | `conventions` | `samples/blocks/conventions.json` |
478
+ | `context-contracts` | `samples/blocks/context-contracts.json` |
479
+ | `phase` | `samples/blocks/phase.json` |
480
+ | `story` | `samples/blocks/story.json` |
481
+
482
+ </installable_blocks>
483
+
484
+ <installable_schemas>
485
+
486
+ Names valid for the `installed_schemas` array in `.project/config.json`. Schemas back block validation; install with `/context install <schema>`.
487
+
488
+ | Schema | Source File |
489
+ |--------|-------------|
490
+ | `decisions` | `samples/schemas/decisions.schema.json` |
491
+ | `framework-gaps` | `samples/schemas/framework-gaps.schema.json` |
492
+ | `tasks` | `samples/schemas/tasks.schema.json` |
493
+ | `verification` | `samples/schemas/verification.schema.json` |
494
+ | `issues` | `samples/schemas/issues.schema.json` |
495
+ | `features` | `samples/schemas/features.schema.json` |
496
+ | `research` | `samples/schemas/research.schema.json` |
497
+ | `rationale` | `samples/schemas/rationale.schema.json` |
498
+ | `spec-reviews` | `samples/schemas/spec-reviews.schema.json` |
499
+ | `layer-plans` | `samples/schemas/layer-plans.schema.json` |
500
+ | `requirements` | `samples/schemas/requirements.schema.json` |
501
+ | `conventions` | `samples/schemas/conventions.schema.json` |
502
+ | `context-contracts` | `samples/schemas/context-contracts.schema.json` |
503
+ | `phase` | `samples/schemas/phase.schema.json` |
504
+ | `story` | `samples/schemas/story.schema.json` |
505
+
506
+ </installable_schemas>
507
+
508
+ <planning_vocabulary>
509
+
510
+ **Block Types:**
511
+
512
+ | Block | Title | Array Key | Item Fields |
513
+ |-------|-------|-----------|-------------|
514
+ | `decisions` | Decisions | `decisions` | id, title, status (string (open|enacted|superseded)), context, decision, options_considered? (array), consequences (array), references? (array), created_by, created_at, enacted_by?, enacted_at? |
515
+ | `framework-gaps` | Framework Gaps | `gaps` | id, title, status (string (identified|accepted|in-progress|closed|wontfix)), priority? (string (P0|P1|P2|P3)), package, layer? (string (L1|L2|L3|L4|L5)), description, evidence (array), impact, canonical_vocabulary?, proposed_resolution, created_by, created_at, closed_by?, closed_at? |
516
+ | `tasks` | Tasks | `tasks` | id, description, status (string (planned|in-progress|completed|blocked|cancelled)), files? (array), acceptance_criteria? (array), assigned_agent?, notes? |
517
+ | `verification` | Verification | `verifications` | id, status (string (passed|failed|partial|skipped)), method (string (command|inspect|test)), evidence?, timestamp?, criteria_results? (array) |
518
+ | `issues` | Issues | `issues` | id, title, body, location, status (string (open|resolved|deferred)), category (string (primitive|issue|cleanup|capability|composition)), priority (string (low|medium|high|critical)), package, source? (string (human|agent|monitor|workflow)), resolved_by? |
519
+ | `features` | Features | `features` | id, title, status (string (proposed|approved|in-progress|in-review|complete|blocked|cancelled)), layer (string (L1|L2|L3|L4|L5)), description, motivation?, acceptance_criteria (array), created_by, created_at, modified_by?, modified_at?, approved_by?, approved_at? |
520
+ | `research` | Research | `research` | id, title, status (string (planned|in-progress|complete|stale|superseded|revised)), layer (string (L1|L2|L3|L4|L5)), type (string (investigative|comparative|empirical|historical|audit|landscape|feasibility|curation)), question, method, scope? (array), findings_summary, findings_document?, grounding? (object), grounded_at?, stale_conditions? (array), citations? (array), conducted_by?, conducted_at?, created_by, created_at, modified_by?, modified_at? |
521
+ | `rationale` | Design Rationale | `rationales` | id, title, narrative, phase? (integer) |
522
+ | `spec-reviews` | Spec Reviews | `reviews` | id, target, target_revision?, reviewer?, status (string (not-started|in-progress|complete|abandoned)), scope? (array), method?, clean? (boolean), created_by, created_at, completed_at? |
523
+ | `layer-plans` | Layer Restructure Plans | `plans` | id, title, status (string (draft|proposed|decided|in-progress|complete|abandoned)), model, description?, layers (array), migration_phases (array), created_by, created_at |
524
+ | `requirements` | Requirements | `requirements` | id, description, type (string (functional|non-functional|constraint|integration)), status (string (proposed|accepted|deferred|implemented|verified)), priority (string (must|should|could|wont)), acceptance_criteria? (array), source? (string (human|agent|analysis)) |
525
+ | `conventions` | Conventions | `rules` | id, description, enforcement (string (lint|test|review|manual)), severity (string (error|warning|info)) |
526
+ | `context-contracts` | Context contracts | `contracts` | id, unit_kind, bundle_relation_types (array), description?, notes?, created_by, created_at, modified_by?, modified_at? |
527
+ | `phase` | Phases | `phases` | id, name, intent, goal?, status (string (planned|in-progress|completed)), success_criteria? (array), specs? (array), artifacts_produced? (array) |
528
+ | `story` | Stories | `stories` | id, title, status (string (proposed|ready|in-progress|in-review|complete|blocked)), description?, acceptance_criteria? (array), created_by?, created_at?, modified_by?, modified_at? |
529
+
530
+ **Status Enums:**
531
+
532
+ | Block | Field | Values |
533
+ |-------|-------|--------|
534
+ | `decisions` | `status` | open, enacted, superseded |
535
+ | `framework-gaps` | `status` | identified, accepted, in-progress, closed, wontfix |
536
+ | `framework-gaps` | `priority` | P0, P1, P2, P3 |
537
+ | `framework-gaps` | `layer` | L1, L2, L3, L4, L5 |
538
+ | `tasks` | `status` | planned, in-progress, completed, blocked, cancelled |
539
+ | `verification` | `status` | passed, failed, partial, skipped |
540
+ | `verification` | `method` | command, inspect, test |
541
+ | `issues` | `status` | open, resolved, deferred |
542
+ | `issues` | `category` | primitive, issue, cleanup, capability, composition |
543
+ | `issues` | `priority` | low, medium, high, critical |
544
+ | `issues` | `source` | human, agent, monitor, workflow |
545
+ | `features` | `status` | proposed, approved, in-progress, in-review, complete, blocked, cancelled |
546
+ | `features` | `layer` | L1, L2, L3, L4, L5 |
547
+ | `research` | `status` | planned, in-progress, complete, stale, superseded, revised |
548
+ | `research` | `layer` | L1, L2, L3, L4, L5 |
549
+ | `research` | `type` | investigative, comparative, empirical, historical, audit, landscape, feasibility, curation |
550
+ | `spec-reviews` | `status` | not-started, in-progress, complete, abandoned |
551
+ | `layer-plans` | `status` | draft, proposed, decided, in-progress, complete, abandoned |
552
+ | `requirements` | `type` | functional, non-functional, constraint, integration |
553
+ | `requirements` | `status` | proposed, accepted, deferred, implemented, verified |
554
+ | `requirements` | `priority` | must, should, could, wont |
555
+ | `requirements` | `source` | human, agent, analysis |
556
+ | `conventions` | `enforcement` | lint, test, review, manual |
557
+ | `conventions` | `severity` | error, warning, info |
558
+ | `phase` | `status` | planned, in-progress, completed |
559
+ | `story` | `status` | proposed, ready, in-progress, in-review, complete, blocked |
560
+
561
+ </planning_vocabulary>
562
+
563
+ <objective>
564
+ pi-context manages structured project state in `.project/` — a directory of JSON block files validated against schemas. The substrate (config + lenses + closure-table relations) is degree-zero state that defines where the rest lives and how items group into views.
565
+ </objective>
566
+
567
+ <block_files>
568
+ Blocks are JSON files under the substrate root (e.g., `gaps.json`, `decisions.json`). Each block has a corresponding schema in `<root>/schemas/`. When you write to a block via the tools, the data is validated against its schema before persisting. Writes are atomic (tmp file + rename) and serialised per block via `withBlockLock`. The substrate root is the dir chosen at init (recorded in the `.pi-context.json` bootstrap pointer) and written to `config.json`'s `root` field by `/context accept-all`; the framework ships no default (DEC-0015). block-api routes through `resolveContextDir(cwd)` — which resolves `config.root` when set and otherwise falls back to the pointer — so a relocated root reaches every read/write site.
569
+ </block_files>
570
+
571
+ <schema_validation>
572
+ Every block write validates against `<root>/schemas/<blockname>.schema.json`. If the schema file doesn't exist, writes proceed without validation. Validation errors include the specific JSON Schema violations.
573
+ </schema_validation>
574
+
575
+ <context_init>
576
+ `/context init <dir>` creates the substrate skeleton: the `.pi-context.json` bootstrap pointer (declaring the substrate-dir name per DEC-0015) plus the substrate root and its `schemas/` directory. Nothing is imposed — no `config.json`, no schemas, and no starter blocks are written (DEC-0011 ship-no-defaults). Idempotent: re-running preserves existing dirs. Populate the substrate next with `/context accept-all` (adopt the canonical conception) followed by `/context install`.
577
+ </context_init>
578
+
579
+ <context_accept_all>
580
+ `/context accept-all` adopts the package's canonical packaged conception (`samples/conception.json`) as the substrate's `config.json` — the full vocabulary (`block_kinds`, `relation_types`, `lenses`, `invariants`) plus the `installed_schemas` / `installed_blocks` manifest — with `root` set to the actual substrate dir. It writes `config.json` only (run `/context install` after to materialize the schemas + starter blocks) and is idempotent: it never overwrites an existing `config.json` (offer, don't impose). This is the accept-all path; per-entry step-through curation is a separate surface.
581
+ </context_accept_all>
582
+
583
+ <context_install>
584
+ `/context install` reconciles the substrate against the `installed_schemas` and `installed_blocks` lists declared in `config.json`. For each declared name it copies the matching asset from the package-shipped samples catalog (`samples/schemas/` for schemas, `samples/blocks/` for starter blocks) into the substrate. Default behavior is skip-if-exists (preserves user edits); pass `--update` to overwrite and report the asset as `updated`. Sources missing from the catalog are reported as `notFound`. Empty install lists are not an error — the result is a clean no-op message instructing the user to edit `config.json`.
585
+
586
+ The installable catalog IS the packaged conception (`samples/conception.json`): its `block_kinds` enumerate the available kinds, each carrying its schema (`samples/schemas/`) and starter block (`samples/blocks/`). The generated installable-catalog table below lists the authoritative names — declare any subset in `installed_*` and run `/context install`, or take the whole conception via `/context accept-all`.
587
+ </context_install>
588
+
589
+ <substrate_config>
590
+ `.project/config.json` is the substrate bootstrap. Its `root` field declares where every other block, schema, agent, and template lives — closing the GitHub #3 surface where downstream consumers had to assume `.project/`. `naming` aliases canonical block ids to display names (used by `/context view` rendering). `hierarchy` declares legal closure-table edges (parent block → child block via relation_type). `lenses` declares named projections over a target block. `installed_schemas` / `installed_blocks` are the install manifest consumed by `/context install`.
591
+
592
+ `config.json` and `relations.json` are exempt from `root` redirection — they always live at `.project/` because they are the substrate that defines `root`. All other state lives under `<config.root>/...` per `resolveContextDir(cwd)`. The package ships their schemas in `schemas/` (config.schema.json, relations.schema.json) and resolves them via three-tier search: project override > user override > package-shipped.
593
+
594
+ The `loadContext(cwd)` SDK returns an mtime-keyed cached snapshot of `{ config, relations, configMtime, relationsMtime }` for one cwd. Consumers must not mutate.
595
+ </substrate_config>
596
+
597
+ <lens_views>
598
+ Lenses are named projections over a target block. A lens declares `id`, `target` (block name), `relation_type`, `derived_from_field` (optional — synthesizes edges from a per-item field instead of requiring authored edges), `bins` (named groupings), and `render_uncategorized`.
599
+
600
+ Edges live in `.project/relations.json` as a closure table — each row is `{ parent, child, relation_type }`. `parent` is either a canonical id (hierarchy edges) or a lens.bins value (lens edges); disambiguation lives in `validateRelations`.
601
+
602
+ The lens-view algorithm: `edgesForLens(lens, items, authoredEdges)` returns synthetic edges (when `derived_from_field` is set) or filtered authored edges (otherwise). `groupByLens(items, lens, lensEdges)` produces a `Map<binName, ItemRecord[]>`. `walkDescendants(parentId, relationType, edges)` traverses the closure table from any parent.
603
+
604
+ `/context view <lensId>` loads the lens via `loadLensView(cwd, lensId)`, runs `groupByLens`, and renders the result as markdown headings + bullet lines (id + status + title) into the conversation via `renderLensView`. `lens.render_uncategorized: false` omits the uncategorized bucket.
605
+ </lens_views>
606
+
607
+ <context_lens_curate>
608
+ `/context lens-curate <lensId>` walks items in the lens's target block that have no edge in any declared bin and surfaces bin-assignment suggestions (would-be `relations.json` edge appends) as a follow-up turn. The LLM reads the suggestions and persists the chosen edges via `append-block-item` against `relations.json`. The command itself does not write — curation is a follow-up-turn pattern so the model decides which suggestions to enact.
609
+ </context_lens_curate>
610
+
611
+ <context_view>
612
+ `/context view <lensId>` renders a configured lens as markdown into the conversation. Bins become headings, items become bullet lines (id + status + title where present). `naming` aliases from config.json are honored for the target block name. Errors (missing config, unknown lens, unreadable target block, no array property in target) surface via `ctx.ui.notify` with severity `error`.
613
+ </context_view>
614
+
615
+ <substrate_validation>
616
+ `validateRelations(cwd)` (exposed as the `context-validate-relations` tool) checks the closure-table edges in `relations.json` against the config + per-block item snapshots. Diagnostics codes: `edge_unknown_relation_type`, `edge_parent_not_in_bins`, `edge_unresolved_parent`, `edge_unresolved_child`, `edge_parent_wrong_block`, `edge_child_wrong_block`, `edge_cycle_detected`. Returns `{ status: "clean" | "warnings" | "invalid", issues[] }` where each issue carries the offending edge or cycle path.
617
+
618
+ Two derived substrate tools complement validation: `context-edges-for-lens` returns the materialized `Edge[]` for a named lens (synthetic from `derived_from_field` or filtered authored edges); `context-walk-descendants` returns the transitive descendant id list from a parent under a given relation_type.
619
+ </substrate_validation>
620
+
621
+ <block_item_reads>
622
+ Item-level reads complement whole-block `read-block` (which is all-or-nothing and caps at the 50KB read limit): `read-block-item` returns one item from a named block by its id (block-scoped — null if absent; distinct from `resolve-item-by-id`, which searches every block by kind-prefixed id). `read-block-page` paginates a block too large to fetch whole — `{ items, total, hasMore }` where `total` is the full item count and pagination uses `offset`/`limit` (defaults 0/50).
623
+ `join-blocks` — one-call cross-block join, EDGE mode (relations.json relation_type, leftEndpoint parent|child) or FIELD mode (shared field value), optional left pre-filter; returns {left, right[]} pairs; replaces N+1 read+resolve.
624
+ </block_item_reads>
625
+
626
+ <context_status>
627
+ `/context status` derives project state dynamically from the filesystem:
628
+ - Source file count and line count (`.ts` files excluding tests)
629
+ - Test count and test file count
630
+ - Schema count, block count, phase count
631
+ - Block summaries with array item counts and status distributions
632
+ - Requirements summary (total, by status, by priority) — from requirements.json (if installed)
633
+ - Tasks summary (total, by status) — from tasks.json (if installed)
634
+ - Domain entry count — from domain.json (if installed)
635
+ - Verification summary (total, passed, failed) — from verification.json (if installed)
636
+ - Handoff presence — whether handoff.json exists
637
+ - Recent git commits
638
+ - Current phase detection
639
+ </context_status>
640
+
641
+ <context_add_work>
642
+ `/context add-work` discovers appendable blocks (blocks with array schemas), reads their schemas, and sends a structured instruction to the LLM to extract items from the conversation into the typed blocks. This is a follow-up message that triggers the LLM to use the `append-block-item` tool.
643
+ </context_add_work>
644
+
645
+ <duplicate_detection>
646
+ `append-block-item` checks for duplicate items by `id` field before appending. If an item with the same `id` already exists in the target array, it returns a message instead of appending.
647
+ </duplicate_detection>
648
+
649
+ <context_validate>
650
+ Two separate validators address two concerns:
651
+
652
+ `/context validate` (the `context-validate` tool) checks cross-block referential integrity:
653
+ - task.phase references a valid phase
654
+ - task.depends_on references valid task IDs
655
+ - decision.phase references a valid phase
656
+ - gap.resolved_by references a valid ID
657
+ - requirement.traces_to references valid phase/task IDs
658
+ - requirement.depends_on references valid requirement IDs
659
+ - verification.target references a valid target ID
660
+ - rationale.related_decisions references valid decision IDs
661
+
662
+ Returns errors (broken dependency references) and warnings (unresolved cross-references).
663
+
664
+ The `context-validate-relations` tool (see `<substrate_validation>`) validates closure-table edges in `relations.json` — a separate concern from cross-block ID resolution.
665
+ </context_validate>
666
+
667
+ <update_check>
668
+ On `session_start`, checks npm registry for newer versions of `@davidorex/pi-project-workflows` and notifies via UI if an update is available. Non-blocking — failures are silently ignored.
669
+ </update_check>
670
+
671
+ <success_criteria>
672
+ - `.project/`, `.project/schemas/`, `.project/phases/`, and `.project/config.json` exist after `/context init`
673
+ - `installed_schemas` / `installed_blocks` declared in `config.json` are reified by `/context install`; `--update` overwrites
674
+ - Block writes validate against schemas — invalid data rejected with specific error
675
+ - `/context status` returns current derived state without errors
676
+ - `/context validate` returns no errors for well-formed cross-block references
677
+ - `context-validate-relations` returns no errors for a well-formed `relations.json`
678
+ - `/context view <lensId>` renders the configured projection; `/context lens-curate <lensId>` surfaces suggestions for uncategorized items
679
+ - `append-block-item` rejects duplicate IDs
680
+ - Schema customizations (field additions, enum changes) take effect on next write
681
+ - A relocated `config.root` reaches every read/write because all path construction routes through `resolveContextDir(cwd)`
682
+ </success_criteria>
683
+
684
+ *Generated from source by `scripts/generate-skills.js` — do not edit by hand.*