@primitive.ai/prim 0.1.0-alpha.114 → 0.1.0-alpha.115
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.
- package/README.md +19 -0
- package/assets/primitive-gameplan/SKILL.md +134 -0
- package/assets/primitive-gameplan/claude-hooks.json +28 -0
- package/assets/primitive-gameplan/scripts/activate.mjs +37 -0
- package/dist/hook-runtime/index.js +621 -265
- package/dist/index.js +498 -142
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -203,6 +203,25 @@ prim codex install # Install OpenAI Codex hooks (user scope; --s
|
|
|
203
203
|
prim hermes install # Install Hermes Agent hooks (global ~/.hermes/config.yaml)
|
|
204
204
|
```
|
|
205
205
|
|
|
206
|
+
For `$write-gameplan` or `$write-workstream` authoring in Codex, install the
|
|
207
|
+
separate Primitive planning companion from the target repository after the
|
|
208
|
+
public `$write-gameplan` skill is available:
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
prim setup --agent codex
|
|
212
|
+
prim gameplan install --agent codex
|
|
213
|
+
prim gameplan status
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
`gameplan install` adds the companion to this repository and a prompt dispatcher
|
|
217
|
+
to the user's Codex hooks, including linked worktrees. It does not replace the
|
|
218
|
+
public planning skill or install Conflict Gates; `setup` handles the latter.
|
|
219
|
+
Review `/hooks` in Codex and start a fresh session. `prim gameplan uninstall`
|
|
220
|
+
removes this repository's companion and leaves the shared user hook in place;
|
|
221
|
+
pass `--remove-user-hook` only when no other repository needs it. A Decision
|
|
222
|
+
scoped only to a code path named inside a gameplan is surfaced during planning,
|
|
223
|
+
but the edit gate sees the changed gameplan path.
|
|
224
|
+
|
|
206
225
|
Passive capture is repo-scoped even when these integrations are installed at user
|
|
207
226
|
scope. `prim enable` marks the current Git repo active; `prim disable` makes it
|
|
208
227
|
inactive. A project-scoped install activates its repo automatically. In an inactive
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: primitive-gameplan
|
|
3
|
+
description: Use alongside write-gameplan and write-workstream to bring applicable Primitive Decisions into architectural discussion, review plans for unsupported architectural additions, and preserve engineer-approved resolutions. Does not replace either public skill or authorize implementation.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Primitive companion for gameplanning
|
|
7
|
+
|
|
8
|
+
Use the public planning skill unchanged. This companion adds decision context to
|
|
9
|
+
its existing architecture discussion and final review; it adds no schema fields
|
|
10
|
+
or human checkpoints between execution patches. Codex is the primary host:
|
|
11
|
+
discover this companion under `.agents/skills`, make the public skills available
|
|
12
|
+
to Codex, and use `$write-gameplan` or `$write-workstream`.
|
|
13
|
+
`prim gameplan install --agent codex` places a dispatcher
|
|
14
|
+
in the user's Codex hooks to load this companion for explicit invocations;
|
|
15
|
+
`AGENTS.md` also binds implicit planning-skill use.
|
|
16
|
+
Claude retains `/write-gameplan` and `/write-workstream` through
|
|
17
|
+
[the Claude hook configuration](claude-hooks.json), merged into
|
|
18
|
+
`.claude/settings.json` without replacing existing hooks.
|
|
19
|
+
|
|
20
|
+
## Before choosing architecture
|
|
21
|
+
|
|
22
|
+
Inspect the requested behavior and its existing code path. Identify both the
|
|
23
|
+
intended code files and the plan/workstream path, even if the plan does not exist
|
|
24
|
+
yet. From the target repository root, use the installed `prim` CLI, or
|
|
25
|
+
`npx --yes @primitive.ai/prim` when there is no `prim` executable:
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
prim auth status
|
|
29
|
+
prim decisions check --files "src/billing/export.ts,gameplans/billing-export.yaml"
|
|
30
|
+
prim decisions show dec_123
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Replace the example paths and ID with real ones. `check` accepts comma-separated
|
|
34
|
+
repo-relative paths and emits JSON without a `--json` flag. Check intended code
|
|
35
|
+
paths as well as the artifact: a decision scoped to billing may not govern the
|
|
36
|
+
gameplans directory. Repeat the lookup if the planned footprint expands. Use
|
|
37
|
+
`show` on decisions you will rely on to inspect their full constraints, rationale,
|
|
38
|
+
source/attribution, status, and scope. A path match alone does not settle a choice.
|
|
39
|
+
|
|
40
|
+
Give a short brief before patch decomposition: relevant settled choices,
|
|
41
|
+
explicitly rejected approaches, and remaining architectural questions. Cite the
|
|
42
|
+
Decision IDs and explain their bearing on this change. Do not invent a blanket
|
|
43
|
+
ban on validators, workers, or persistence from an example of overengineering.
|
|
44
|
+
|
|
45
|
+
An empty successful lookup means no matching decisions were returned, not that
|
|
46
|
+
the proposed architecture is approved. Nonzero exits, `unavailable`, partial or
|
|
47
|
+
truncated responses, and missing provenance mean coverage is unknown or limited.
|
|
48
|
+
Report that limitation and use available engineer-supplied constraints. Do not
|
|
49
|
+
claim Primitive clearance, start an authentication flow, enable capture, or change
|
|
50
|
+
enforcement settings merely to finish planning.
|
|
51
|
+
|
|
52
|
+
## Resolve choices in the existing format
|
|
53
|
+
|
|
54
|
+
Use `architectureDesign.decisions[].resolution` in the public gameplan schema:
|
|
55
|
+
|
|
56
|
+
- `engineer_approved`: an actual engineer answer or identifiable engineer-approved
|
|
57
|
+
source covers this exact choice and scope. Evidence includes the Primitive ID,
|
|
58
|
+
substantive constraint, source of approval, and why it applies here.
|
|
59
|
+
- `constrained`: binding requirements eliminate meaningful alternatives; explain
|
|
60
|
+
that reasoning, including the applicable Decision when one supplies a constraint.
|
|
61
|
+
- `delegated`: the engineer explicitly delegated this choice within a stated
|
|
62
|
+
scope; retain that delegation. The agent's resulting selection is not a new
|
|
63
|
+
user-originated decision without ratification.
|
|
64
|
+
- `unresolved`: the remaining choice needs an answer. Keep it in `openQuestions`
|
|
65
|
+
too, and leave dependent patches/specs provisional until it is resolved.
|
|
66
|
+
|
|
67
|
+
Keep rationale in `resolution.rationale`. A captured agent suggestion, an author
|
|
68
|
+
name, adoption status alone, an existing implementation, or a broad milestone is
|
|
69
|
+
not evidence that an engineer approved a new mechanism. For example, approval of
|
|
70
|
+
PostgreSQL does not approve another durable ledger. Conflicting or ambiguous
|
|
71
|
+
Decisions require clarification; do not silently prefer the newest one.
|
|
72
|
+
|
|
73
|
+
When alternatives remain, present the minimal approach, credible alternatives,
|
|
74
|
+
and relevant prior constraints before choosing. Ask one question at a time when
|
|
75
|
+
answers depend on each other. Do not repeat a question already answered within
|
|
76
|
+
the same scope. For a workstream, use its existing decisions/open-questions prose
|
|
77
|
+
rather than introducing gameplan fields.
|
|
78
|
+
|
|
79
|
+
## Review the complete artifact before handoff
|
|
80
|
+
|
|
81
|
+
Read the solution, operational considerations, every patch, and every formal spec
|
|
82
|
+
against the resolved architecture. Look for consequential choices introduced as
|
|
83
|
+
implementation details: another source of truth, validation boundary, state
|
|
84
|
+
lifetime, worker, scheduler, retry protocol, or cross-runtime data flow. Check
|
|
85
|
+
each against its actual evidence and scope, not merely whether an ID is present.
|
|
86
|
+
This is a semantic review by the planning agent: `prim decisions check` is a
|
|
87
|
+
lookup, not that review.
|
|
88
|
+
|
|
89
|
+
For an unsupported addition, identify the patch and concrete choice. Remove an
|
|
90
|
+
unnecessary agent-added mechanism consistently from the artifact, or present it
|
|
91
|
+
as an unresolved exception with alternatives before finalizing dependent work.
|
|
92
|
+
Discussion of a rejected option is allowed; adopting it without resolution is not.
|
|
93
|
+
Re-run the public skill's schema/spec validation after changes. A validator PASS
|
|
94
|
+
does not verify that a human approved the design.
|
|
95
|
+
|
|
96
|
+
## Preserve the answers
|
|
97
|
+
|
|
98
|
+
At a natural planning boundary, retain durable engineer resolutions in Primitive
|
|
99
|
+
when recording is authorized. Check the applicable records and
|
|
100
|
+
`prim decisions recent --limit 20` to avoid duplicates. Use the installed Prim
|
|
101
|
+
recording policy when available; a request to draft a plan alone does not grant
|
|
102
|
+
permission to publish decisions into an inactive repository.
|
|
103
|
+
|
|
104
|
+
Before a create, check `prim decisions create --help`. Record the exact approved
|
|
105
|
+
choice with `--intent`, `--attribution user`, source-grounded `--rationale`, one
|
|
106
|
+
`--decided` per binding constraint, and `--alternatives` only for options actually
|
|
107
|
+
rejected. An agent selection under delegation uses `--attribution agent` unless
|
|
108
|
+
the engineer ratifies that selection. Missing rationale is a question, not a
|
|
109
|
+
license to invent one. Apply only the approved scope using `--files`,
|
|
110
|
+
`--scope-dir`, or `--scope-repo`; include the plan path when that scope governs it.
|
|
111
|
+
Do not silently broaden a code-only constraint to all plans or the whole repo.
|
|
112
|
+
|
|
113
|
+
Honor existing recording authorization without asking again. For an inactive repo,
|
|
114
|
+
Prim's global `--yes` is appropriate only for a specifically authorized create;
|
|
115
|
+
npm's `npx --yes` is merely package-install confirmation. Preserve returned IDs
|
|
116
|
+
in the existing evidence fields. Report failed writes as unsaved, retaining the
|
|
117
|
+
approved wording in the plan for recovery; after an ambiguous failure, check for
|
|
118
|
+
an existing record before retrying. Never invent an ID or a successful save.
|
|
119
|
+
|
|
120
|
+
For parent workstreams, follow the public skill's write-back procedure: present
|
|
121
|
+
the concrete edits and obtain its required approval before applying them. Saving
|
|
122
|
+
a Primitive Decision does not authorize a workstream edit.
|
|
123
|
+
|
|
124
|
+
## Enforcement boundary
|
|
125
|
+
|
|
126
|
+
Existing Conflict Gates may inspect saved plans when enabled and in scope. This
|
|
127
|
+
companion neither installs nor enables gates. It does not guarantee detection of
|
|
128
|
+
every architectural implication or cryptographically verify approval. Chat-only
|
|
129
|
+
plans bypass file-write gates, and infrastructure failures may fail open.
|
|
130
|
+
|
|
131
|
+
If a gate flags a conflict, surface the governing Decision and resolve the
|
|
132
|
+
architectural choice with the engineer. Do not run `prim reconcile`, weaken gate
|
|
133
|
+
mode, or change/supersede the Decision merely to make the plan pass. A bypass or
|
|
134
|
+
change of constraint needs explicit engineer authorization for that action.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"hooks": {
|
|
3
|
+
"UserPromptExpansion": [
|
|
4
|
+
{
|
|
5
|
+
"matcher": "(^|:)write-(gameplan|workstream)$",
|
|
6
|
+
"hooks": [
|
|
7
|
+
{
|
|
8
|
+
"type": "command",
|
|
9
|
+
"command": "node \"$CLAUDE_PROJECT_DIR/.agents/skills/primitive-gameplan/scripts/activate.mjs\"",
|
|
10
|
+
"timeout": 5
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"PreToolUse": [
|
|
16
|
+
{
|
|
17
|
+
"matcher": "Skill",
|
|
18
|
+
"hooks": [
|
|
19
|
+
{
|
|
20
|
+
"type": "command",
|
|
21
|
+
"command": "node \"$CLAUDE_PROJECT_DIR/.agents/skills/primitive-gameplan/scripts/activate.mjs\"",
|
|
22
|
+
"timeout": 5
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
|
|
3
|
+
const event = JSON.parse(readFileSync(0, "utf8"));
|
|
4
|
+
let name;
|
|
5
|
+
if (event.hook_event_name === "UserPromptSubmit") {
|
|
6
|
+
name = event.prompt?.match(
|
|
7
|
+
/^\s*[$/](write-(?:gameplan|workstream))(?=\s|$)/
|
|
8
|
+
)?.[1];
|
|
9
|
+
} else if (
|
|
10
|
+
event.hook_event_name === "UserPromptExpansion" &&
|
|
11
|
+
event.expansion_type === "slash_command"
|
|
12
|
+
) {
|
|
13
|
+
name = event.command_name;
|
|
14
|
+
} else if (
|
|
15
|
+
event.hook_event_name === "PreToolUse" &&
|
|
16
|
+
event.tool_name === "Skill"
|
|
17
|
+
) {
|
|
18
|
+
name = event.tool_input?.skill;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (
|
|
22
|
+
typeof name === "string" &&
|
|
23
|
+
/^(?:[^:]+:)*write-(?:gameplan|workstream)$/.test(name)
|
|
24
|
+
) {
|
|
25
|
+
const companion = readFileSync(
|
|
26
|
+
new URL("../SKILL.md", import.meta.url),
|
|
27
|
+
"utf8"
|
|
28
|
+
);
|
|
29
|
+
process.stdout.write(
|
|
30
|
+
`${JSON.stringify({
|
|
31
|
+
hookSpecificOutput: {
|
|
32
|
+
hookEventName: event.hook_event_name,
|
|
33
|
+
additionalContext: `This repository uses the Primitive planning companion alongside ${name}. Its local skill follows:\n\n${companion}`,
|
|
34
|
+
},
|
|
35
|
+
})}\n`
|
|
36
|
+
);
|
|
37
|
+
}
|