@open-product-primer/cli 2.0.0 → 2.2.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.
- package/README.md +6 -0
- package/dist/cli.js +4 -0
- package/dist/commands/context.d.ts +2 -0
- package/dist/commands/context.js +188 -0
- package/dist/commands/doctor.js +49 -0
- package/dist/commands/validate.d.ts +2 -0
- package/dist/commands/validate.js +131 -0
- package/dist/lib/config-merge.js +5 -1
- package/dist/lib/install-agent.js +78 -938
- package/dist/lib/remote-context.d.ts +50 -0
- package/dist/lib/remote-context.js +299 -0
- package/dist/lib/spec-delta.d.ts +30 -0
- package/dist/lib/spec-delta.js +216 -0
- package/dist/lib/templates.js +2 -1
- package/dist/lib/validate-checks.d.ts +13 -0
- package/dist/lib/validate-checks.js +145 -0
- package/dist/lib/workflow-renderer.d.ts +19 -0
- package/dist/lib/workflow-renderer.js +103 -0
- package/dist/lib/workflow-schema.d.ts +37 -0
- package/dist/lib/workflow-schema.js +126 -0
- package/dist/workflows/archive.inline.md +10 -0
- package/dist/workflows/archive.schema.yaml +13 -0
- package/dist/workflows/archive.template.md +106 -0
- package/dist/workflows/bet.cursor-command.md +1 -0
- package/dist/workflows/bet.inline.md +13 -0
- package/dist/workflows/bet.schema.yaml +14 -0
- package/dist/workflows/bet.template.md +114 -0
- package/dist/workflows/context.schema.yaml +13 -0
- package/dist/workflows/context.template.md +34 -0
- package/dist/workflows/criteria.cursor-command.md +1 -0
- package/dist/workflows/criteria.inline.md +11 -0
- package/dist/workflows/criteria.schema.yaml +14 -0
- package/dist/workflows/criteria.template.md +52 -0
- package/dist/workflows/note.cursor-command.md +1 -0
- package/dist/workflows/note.inline.md +11 -0
- package/dist/workflows/note.schema.yaml +14 -0
- package/dist/workflows/note.template.md +66 -0
- package/dist/workflows/pdr.cursor-command.md +1 -0
- package/dist/workflows/pdr.inline.md +10 -0
- package/dist/workflows/pdr.schema.yaml +14 -0
- package/dist/workflows/pdr.template.md +67 -0
- package/dist/workflows/promote.native.template.md +29 -0
- package/dist/workflows/promote.none.template.md +25 -0
- package/dist/workflows/promote.openspec.template.md +40 -0
- package/dist/workflows/promote.schema.yaml +14 -0
- package/dist/workflows/review.cursor-command.md +1 -0
- package/dist/workflows/review.inline.md +11 -0
- package/dist/workflows/review.schema.yaml +14 -0
- package/dist/workflows/review.template.md +69 -0
- package/dist/workflows/sequence.cursor-command.md +12 -0
- package/dist/workflows/sequence.inline.md +10 -0
- package/dist/workflows/sequence.schema.yaml +13 -0
- package/dist/workflows/sequence.template.md +88 -0
- package/dist/workflows/spec-authoring.schema.yaml +13 -0
- package/dist/workflows/spec-authoring.template.md +68 -0
- package/package.json +2 -2
|
@@ -54,6 +54,8 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
54
54
|
const scaffold_1 = require("./scaffold");
|
|
55
55
|
const detect_1 = require("./detect");
|
|
56
56
|
const config_merge_1 = require("./config-merge");
|
|
57
|
+
const workflow_schema_1 = require("./workflow-schema");
|
|
58
|
+
const workflow_renderer_1 = require("./workflow-renderer");
|
|
57
59
|
exports.SUPPORTED_AGENTS = ['claude', 'cursor', 'codex', 'gemini', 'poolside'];
|
|
58
60
|
// oprim/config.yaml (via integrations.spec_framework) is the source of truth for the
|
|
59
61
|
// selected speccing framework; .claude/hooks/config.json is checked only as a fallback for
|
|
@@ -136,6 +138,21 @@ async function promptOkfFrontmatter() {
|
|
|
136
138
|
default: false,
|
|
137
139
|
});
|
|
138
140
|
}
|
|
141
|
+
// Workflow ids installed as Claude/Poolside/Cursor skill files — see packages/cli/src/workflows/.
|
|
142
|
+
// Order matches the pre-refactor CLAUDE_SKILLS/POOLSIDE_SKILLS/CURSOR_SKILLS declaration order.
|
|
143
|
+
const CLAUDE_SKILL_WORKFLOW_IDS = ['pdr', 'bet', 'note', 'criteria', 'review', 'archive', 'sequence', 'context'];
|
|
144
|
+
const POOLSIDE_SKILL_WORKFLOW_IDS = ['pdr', 'bet', 'note', 'criteria', 'review', 'archive', 'sequence'];
|
|
145
|
+
const CURSOR_SKILL_WORKFLOW_IDS = ['pdr', 'bet', 'note', 'criteria', 'review'];
|
|
146
|
+
// Claude command wrappers (thin, invoke skill) — filename -> workflow id. Order matches the
|
|
147
|
+
// pre-refactor CLAUDE_COMMANDS declaration order.
|
|
148
|
+
const CLAUDE_COMMAND_WORKFLOWS = [
|
|
149
|
+
{ filename: 'promote.md', id: 'promote' },
|
|
150
|
+
{ filename: 'sequence.md', id: 'sequence' },
|
|
151
|
+
{ filename: 'archive.md', id: 'archive' },
|
|
152
|
+
{ filename: 'context-init.md', id: 'context' },
|
|
153
|
+
];
|
|
154
|
+
// Cursor command files (full inline). Order matches the pre-refactor CURSOR_COMMANDS declaration order.
|
|
155
|
+
const CURSOR_COMMAND_WORKFLOW_IDS = ['promote', 'sequence', 'pdr', 'bet', 'note', 'criteria', 'review'];
|
|
139
156
|
function installAgentSkills(agent, projectRoot, framework = 'openspec', pdrSurfacing = false) {
|
|
140
157
|
if (agent === 'claude') {
|
|
141
158
|
const claudeDir = path.join(projectRoot, '.claude');
|
|
@@ -156,15 +173,20 @@ function installAgentSkills(agent, projectRoot, framework = 'openspec', pdrSurfa
|
|
|
156
173
|
console.log(chalk_1.default.dim(' removed .claude/skills/oprim:context/SKILL.md'));
|
|
157
174
|
}
|
|
158
175
|
// oprim skills — prepend Step 0 when opted in
|
|
159
|
-
for (const
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
|
|
176
|
+
for (const id of CLAUDE_SKILL_WORKFLOW_IDS) {
|
|
177
|
+
const schema = (0, workflow_schema_1.loadWorkflowSchema)(id, projectRoot);
|
|
178
|
+
if (!schema.claude.skill || !schema.skillName)
|
|
179
|
+
continue;
|
|
180
|
+
const body = (0, workflow_renderer_1.renderSkillBody)(id, projectRoot);
|
|
181
|
+
const skillContent = pdrSurfacing ? withContextStep(body) : body;
|
|
182
|
+
(0, scaffold_1.writeFile)(path.join(skillsBase, schema.skillName, 'SKILL.md'), skillContent);
|
|
183
|
+
console.log(chalk_1.default.green('✓') + ` .claude/skills/${schema.skillName}/SKILL.md`);
|
|
163
184
|
}
|
|
164
185
|
// oprim-spec (native spec authoring) — install only when spec_framework is native, remove otherwise
|
|
165
186
|
const specSkillPath = path.join(skillsBase, 'oprim-spec', 'SKILL.md');
|
|
166
187
|
if (framework === 'native') {
|
|
167
|
-
const
|
|
188
|
+
const specBody = (0, workflow_renderer_1.renderSkillBody)('spec-authoring', projectRoot);
|
|
189
|
+
const specSkillContent = pdrSurfacing ? withContextStep(specBody) : specBody;
|
|
168
190
|
(0, scaffold_1.writeFile)(specSkillPath, specSkillContent);
|
|
169
191
|
console.log(chalk_1.default.green('✓') + ' .claude/skills/oprim-spec/SKILL.md');
|
|
170
192
|
}
|
|
@@ -190,13 +212,9 @@ function installAgentSkills(agent, projectRoot, framework = 'openspec', pdrSurfa
|
|
|
190
212
|
}
|
|
191
213
|
}
|
|
192
214
|
const cmdsDir = path.join(claudeDir, 'commands', 'oprim');
|
|
193
|
-
for (const
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
const finalContent = filename === 'promote.md'
|
|
197
|
-
? claudeWrapper('OPRIM: Promote', 'Promote a note into a bet, or a prioritized bet into a capability spec', promoteContent(framework))
|
|
198
|
-
: content;
|
|
199
|
-
(0, scaffold_1.writeFile)(path.join(cmdsDir, filename), finalContent);
|
|
215
|
+
for (const { filename, id } of CLAUDE_COMMAND_WORKFLOWS) {
|
|
216
|
+
const content = (0, workflow_renderer_1.renderClaudeCommand)(id, projectRoot, framework);
|
|
217
|
+
(0, scaffold_1.writeFile)(path.join(cmdsDir, filename), content);
|
|
200
218
|
console.log(chalk_1.default.green('✓') + ` .claude/commands/oprim/${filename}`);
|
|
201
219
|
}
|
|
202
220
|
// Tombstone cleanup: remove command wrappers deleted in v0.2.0 (bet/criteria/pdr/review
|
|
@@ -236,13 +254,16 @@ function installAgentSkills(agent, projectRoot, framework = 'openspec', pdrSurfa
|
|
|
236
254
|
const poolsideDir = path.join(projectRoot, '.poolside');
|
|
237
255
|
const dirCreated = !fs.existsSync(poolsideDir);
|
|
238
256
|
const skillsBase = path.join(poolsideDir, 'skills');
|
|
239
|
-
for (const
|
|
240
|
-
(0,
|
|
241
|
-
|
|
257
|
+
for (const id of POOLSIDE_SKILL_WORKFLOW_IDS) {
|
|
258
|
+
const schema = (0, workflow_schema_1.loadWorkflowSchema)(id, projectRoot);
|
|
259
|
+
if (!schema.poolside.skill || !schema.skillName)
|
|
260
|
+
continue;
|
|
261
|
+
(0, scaffold_1.writeFile)(path.join(skillsBase, schema.skillName, 'SKILL.md'), (0, workflow_renderer_1.renderSkillBody)(id, projectRoot));
|
|
262
|
+
console.log(chalk_1.default.green('✓') + ` .poolside/skills/${schema.skillName}/SKILL.md`);
|
|
242
263
|
}
|
|
243
264
|
const poolsideSpecSkillPath = path.join(skillsBase, 'oprim-spec', 'SKILL.md');
|
|
244
265
|
if (framework === 'native') {
|
|
245
|
-
(0, scaffold_1.writeFile)(poolsideSpecSkillPath,
|
|
266
|
+
(0, scaffold_1.writeFile)(poolsideSpecSkillPath, (0, workflow_renderer_1.renderSkillBody)('spec-authoring', projectRoot));
|
|
246
267
|
console.log(chalk_1.default.green('✓') + ' .poolside/skills/oprim-spec/SKILL.md');
|
|
247
268
|
}
|
|
248
269
|
else if (fs.existsSync(poolsideSpecSkillPath)) {
|
|
@@ -274,13 +295,16 @@ function installAgentSkills(agent, projectRoot, framework = 'openspec', pdrSurfa
|
|
|
274
295
|
const cursorDir = path.join(projectRoot, '.cursor');
|
|
275
296
|
const dirCreated = !fs.existsSync(cursorDir);
|
|
276
297
|
const skillsBase = path.join(cursorDir, 'skills');
|
|
277
|
-
for (const
|
|
278
|
-
(0,
|
|
279
|
-
|
|
298
|
+
for (const id of CURSOR_SKILL_WORKFLOW_IDS) {
|
|
299
|
+
const schema = (0, workflow_schema_1.loadWorkflowSchema)(id, projectRoot);
|
|
300
|
+
if (!schema.cursor.skill || !schema.skillName)
|
|
301
|
+
continue;
|
|
302
|
+
(0, scaffold_1.writeFile)(path.join(skillsBase, schema.skillName, 'SKILL.md'), (0, workflow_renderer_1.renderSkillBody)(id, projectRoot));
|
|
303
|
+
console.log(chalk_1.default.green('✓') + ` .cursor/skills/${schema.skillName}/SKILL.md`);
|
|
280
304
|
}
|
|
281
305
|
const cursorSpecSkillPath = path.join(skillsBase, 'oprim-spec', 'SKILL.md');
|
|
282
306
|
if (framework === 'native') {
|
|
283
|
-
(0, scaffold_1.writeFile)(cursorSpecSkillPath,
|
|
307
|
+
(0, scaffold_1.writeFile)(cursorSpecSkillPath, (0, workflow_renderer_1.renderSkillBody)('spec-authoring', projectRoot));
|
|
284
308
|
console.log(chalk_1.default.green('✓') + ' .cursor/skills/oprim-spec/SKILL.md');
|
|
285
309
|
}
|
|
286
310
|
else if (fs.existsSync(cursorSpecSkillPath)) {
|
|
@@ -292,14 +316,13 @@ function installAgentSkills(agent, projectRoot, framework = 'openspec', pdrSurfa
|
|
|
292
316
|
console.log(chalk_1.default.dim(' removed .cursor/skills/oprim-spec/SKILL.md'));
|
|
293
317
|
}
|
|
294
318
|
const cmdsDir = path.join(cursorDir, 'commands');
|
|
295
|
-
for (const
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
console.log(chalk_1.default.green('✓') + ` .cursor/commands/${filename}`);
|
|
319
|
+
for (const id of CURSOR_COMMAND_WORKFLOW_IDS) {
|
|
320
|
+
const schema = (0, workflow_schema_1.loadWorkflowSchema)(id, projectRoot);
|
|
321
|
+
if (!schema.cursor.command)
|
|
322
|
+
continue;
|
|
323
|
+
const content = (0, workflow_renderer_1.renderCursorCommand)(id, projectRoot, framework);
|
|
324
|
+
(0, scaffold_1.writeFile)(path.join(cmdsDir, schema.cursor.command), content);
|
|
325
|
+
console.log(chalk_1.default.green('✓') + ` .cursor/commands/${schema.cursor.command}`);
|
|
303
326
|
}
|
|
304
327
|
if (dirCreated) {
|
|
305
328
|
console.log(chalk_1.default.dim(' .cursor/ created — Cursor will discover these files automatically.'));
|
|
@@ -373,494 +396,9 @@ function removeContextStepFromFile(content) {
|
|
|
373
396
|
const after = content.slice(e + CTX_STEP_END.length).replace(/^\n+/, '\n');
|
|
374
397
|
return before + after;
|
|
375
398
|
}
|
|
376
|
-
//
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
'oprim-bet': betSkill(),
|
|
380
|
-
'oprim-note': noteSkill(),
|
|
381
|
-
'oprim-criteria': criteriaSkill(),
|
|
382
|
-
'oprim-review': reviewSkill(),
|
|
383
|
-
'oprim-archive': archiveSkill(),
|
|
384
|
-
'oprim-sequence': oprimSequenceSkill(),
|
|
385
|
-
};
|
|
386
|
-
// ─── Claude command wrappers (thin, invoke skill) ────────────────────────────
|
|
387
|
-
exports.CLAUDE_COMMANDS = {
|
|
388
|
-
'promote.md': claudeWrapper('OPRIM: Promote', 'Promote a note into a bet, or a prioritized bet into a capability spec', promoteContent()),
|
|
389
|
-
'sequence.md': claudeWrapper('OPRIM: Sequence', 'Validate and update the primer sequencing board', sequenceContent()),
|
|
390
|
-
'archive.md': claudeWrapper('OPRIM: Archive', 'Archive a completed bet — move it out of the active board', archiveCommandContent()),
|
|
391
|
-
};
|
|
392
|
-
// ─── Poolside skill playbooks ─────────────────────────────────────────────────
|
|
393
|
-
exports.POOLSIDE_SKILLS = {
|
|
394
|
-
'oprim-pdr': pdrSkill(),
|
|
395
|
-
'oprim-bet': betSkill(),
|
|
396
|
-
'oprim-note': noteSkill(),
|
|
397
|
-
'oprim-criteria': criteriaSkill(),
|
|
398
|
-
'oprim-review': reviewSkill(),
|
|
399
|
-
'oprim-archive': archiveSkill(),
|
|
400
|
-
'oprim-sequence': oprimSequenceSkill(),
|
|
401
|
-
};
|
|
402
|
-
// ─── Cursor skill playbooks ───────────────────────────────────────────────────
|
|
403
|
-
exports.CURSOR_SKILLS = {
|
|
404
|
-
'oprim-pdr': pdrSkill(),
|
|
405
|
-
'oprim-bet': betSkill(),
|
|
406
|
-
'oprim-note': noteSkill(),
|
|
407
|
-
'oprim-criteria': criteriaSkill(),
|
|
408
|
-
'oprim-review': reviewSkill(),
|
|
409
|
-
};
|
|
410
|
-
// ─── Cursor command files (full inline — no Skill tool in Cursor) ────────────
|
|
411
|
-
exports.CURSOR_COMMANDS = {
|
|
412
|
-
'oprim-promote.md': cursorWrapper('oprim-promote', 'Promote a note into a bet, or a prioritized bet into a capability spec', promoteContent()),
|
|
413
|
-
'oprim-sequence.md': cursorWrapper('oprim-sequence', 'Validate and update the primer sequencing board', sequenceInlineContent()),
|
|
414
|
-
'oprim-pdr.md': cursorWrapper('oprim-pdr', 'Create a new Product Decision Record with auto-assigned ID', pdrInlineContent()),
|
|
415
|
-
'oprim-bet.md': cursorWrapper('oprim-bet', 'Create a new bet decision and register it on the sequencing board', betInlineContent()),
|
|
416
|
-
'oprim-note.md': cursorWrapper('oprim-note', 'Create a new atomic note for lightweight thinking capture', noteInlineContent()),
|
|
417
|
-
'oprim-criteria.md': cursorWrapper('oprim-criteria', 'Create or append to a criteria.yaml contract for a bet', criteriaInlineContent()),
|
|
418
|
-
'oprim-review.md': cursorWrapper('oprim-review', "Create a KPI review artifact pre-filled from a bet's criteria contract", reviewInlineContent()),
|
|
419
|
-
};
|
|
420
|
-
// ─── Helpers ─────────────────────────────────────────────────────────────────
|
|
421
|
-
function claudeWrapper(name, description, body) {
|
|
422
|
-
return `---
|
|
423
|
-
name: "${name}"
|
|
424
|
-
description: ${description}
|
|
425
|
-
category: Workflow
|
|
426
|
-
tags: [workflow, primer]
|
|
427
|
-
---
|
|
428
|
-
|
|
429
|
-
${description}.
|
|
430
|
-
|
|
431
|
-
${body}`;
|
|
432
|
-
}
|
|
433
|
-
function cursorWrapper(id, description, body) {
|
|
434
|
-
return `---
|
|
435
|
-
name: /${id}
|
|
436
|
-
id: ${id}
|
|
437
|
-
category: Workflow
|
|
438
|
-
description: ${description}
|
|
439
|
-
---
|
|
440
|
-
|
|
441
|
-
${body}`;
|
|
442
|
-
}
|
|
443
|
-
// ─── Skill content ────────────────────────────────────────────────────────────
|
|
444
|
-
function pdrSkill() {
|
|
445
|
-
return `---
|
|
446
|
-
name: oprim-pdr
|
|
447
|
-
description: Create a new Product Decision Record in oprim/decisions/ with auto-assigned ID and guided prompting
|
|
448
|
-
---
|
|
449
|
-
|
|
450
|
-
Create a new Product Decision Record (PDR) in \`oprim/decisions/\`.
|
|
451
|
-
|
|
452
|
-
**Interactive prompts:** Use the **AskUserQuestion tool** for every question in this skill — do not write questions as plain text.
|
|
453
|
-
|
|
454
|
-
## Steps
|
|
455
|
-
|
|
456
|
-
### 1. Get the decision title
|
|
457
|
-
If not provided, ask: "What is the title of this product decision?"
|
|
458
|
-
|
|
459
|
-
### 2. Assign the next PDR ID
|
|
460
|
-
Scan \`oprim/decisions/\` for files matching \`PDR-(\\d+)-\`. Extract all integers. Assign max+1, zero-padded to 3 digits. Default \`001\` if none found.
|
|
461
|
-
Slug: title → lowercase → spaces to hyphens → remove non-alphanumeric (except hyphens).
|
|
462
|
-
Output path: \`oprim/decisions/PDR-NNN-<slug>.md\`
|
|
463
|
-
|
|
464
|
-
### 2b. Check for custom rules
|
|
465
|
-
Read \`oprim/config.yaml\`. If it has a non-empty \`rules.pdr\` value, treat it as additional guidance from the team — factor it into the questions you ask in step 3 and reflect it in the generated content. If \`rules.pdr\` is absent or empty, skip this step; behavior is unchanged.
|
|
466
|
-
|
|
467
|
-
### 3. Gather content
|
|
468
|
-
Ask: Context (what forced this decision), Decision (clear statement), Alternatives considered (why rejected), Consequences (positives / trade-offs / follow-ups), Evidence links (optional), Related bets (optional), Related OpenSpec changes (optional).
|
|
469
|
-
|
|
470
|
-
### 4. Check for supersession
|
|
471
|
-
Ask: "Does this supersede an existing PDR? If so, which ID? (Enter to skip)"
|
|
472
|
-
|
|
473
|
-
### 4b. Check for OKF frontmatter
|
|
474
|
-
Read \`oprim/templates/pdr.md\`. If it begins with a YAML frontmatter block (\`---\` ... \`---\`), this workspace has OKF frontmatter enabled. Ask for a one-line description and comma-separated tags (subject-area keywords). Prepare a frontmatter block with \`type: pdr\`, \`title: <title>\`, \`description: <description>\`, \`tags: [<tags>]\`, \`timestamp: <today's date, ISO 8601>\`, to prepend in step 5.
|
|
475
|
-
If no frontmatter block is found in the template, skip this step — write the file with no frontmatter, matching current behavior.
|
|
476
|
-
|
|
477
|
-
### 5. Write the PDR file
|
|
478
|
-
Prepend the frontmatter block from step 4b, if one was prepared.
|
|
479
|
-
\`\`\`
|
|
480
|
-
# PDR-NNN: <title>
|
|
481
|
-
|
|
482
|
-
## Status
|
|
483
|
-
Proposed
|
|
484
|
-
|
|
485
|
-
## Context
|
|
486
|
-
<context>
|
|
487
|
-
|
|
488
|
-
## Decision
|
|
489
|
-
<decision>
|
|
490
|
-
|
|
491
|
-
## Alternatives considered
|
|
492
|
-
<alternatives as bullet list>
|
|
493
|
-
|
|
494
|
-
## Consequences
|
|
495
|
-
- Positive: <...>
|
|
496
|
-
- Trade-offs: <...>
|
|
497
|
-
- Follow-ups: <...>
|
|
498
|
-
|
|
499
|
-
## Evidence
|
|
500
|
-
<evidence or "None">
|
|
501
|
-
|
|
502
|
-
## Related
|
|
503
|
-
- Bets: <BET-IDs or "None">
|
|
504
|
-
- OpenSpec: <change paths or "None">
|
|
505
|
-
- Supersedes: <PDR-ID or "None">
|
|
506
|
-
\`\`\`
|
|
507
|
-
|
|
508
|
-
### 6. Update superseded PDR (if applicable)
|
|
509
|
-
Read the superseded file → replace Status value with \`Superseded by PDR-NNN\` → write back.
|
|
510
|
-
|
|
511
|
-
### 7. Report what was created
|
|
512
|
-
`;
|
|
513
|
-
}
|
|
514
|
-
function betSkill() {
|
|
515
|
-
return `---
|
|
516
|
-
name: oprim-bet
|
|
517
|
-
description: Create a new bet directory and bet-decision artifact in oprim/bets/, and add the bet to oprim/sequence.yaml backlog
|
|
518
|
-
---
|
|
519
|
-
|
|
520
|
-
Create a new bet in \`oprim/bets/\` and register it on the sequencing board.
|
|
521
|
-
|
|
522
|
-
**Interactive prompts:** Use the **AskUserQuestion tool** for every question in this skill — do not write questions as plain text.
|
|
523
|
-
|
|
524
|
-
## What you're creating
|
|
525
|
-
|
|
526
|
-
A bet is a product decision you're committing to explore: a problem worth solving, a hypothesis worth testing, or a direction worth taking. You'll name it, explain why now, and set a kill criterion so you know when to stop.
|
|
527
|
-
|
|
528
|
-
## Steps
|
|
529
|
-
|
|
530
|
-
### 1. Get the bet title
|
|
531
|
-
Display the naming convention before asking:
|
|
532
|
-
|
|
533
|
-
> **Naming tip:** Use "verb + object [for context]"
|
|
534
|
-
> - Good: "Improve bet naming for scannability"
|
|
535
|
-
> - Bad: "Naming"
|
|
536
|
-
|
|
537
|
-
If not provided, ask: "What is the title of this bet?"
|
|
538
|
-
|
|
539
|
-
After receiving the title, validate: if fewer than 4 words OR fewer than 25 characters:
|
|
540
|
-
- Show: "Warning: this title may be too vague to scan at a glance."
|
|
541
|
-
- Suggest a reformulation, e.g. "Consider: 'Improve <what> for <why>'"
|
|
542
|
-
- Ask: "Proceed with this title anyway? (y/N)"
|
|
543
|
-
- If "n" or Enter: ask for a revised title and re-validate
|
|
544
|
-
- If "y": proceed with the original title
|
|
545
|
-
|
|
546
|
-
### 2. Assign the next BET ID
|
|
547
|
-
Scan both \`oprim/bets/\` and \`oprim/bets/archived/\` for directories whose names match \`BET-(\\d+)(-[^/]*)?\` (handles both \`BET-NNN/\` and \`BET-NNN-<slug>/\`). Extract the numeric part from each match. Assign max+1, zero-padded to 3 digits. Default \`001\` if none found in either location.
|
|
548
|
-
|
|
549
|
-
### 2b. Derive the slug
|
|
550
|
-
From the bet title: lowercase all characters, replace any character that is not a letter or digit with a hyphen, collapse consecutive hyphens to one, strip leading/trailing hyphens, truncate to 40 characters at the last hyphen boundary. This becomes \`<slug>\`. Example: "Add title slugs to bet directories for scannability" → \`add-title-slugs-to-bet-dirs-for\`.
|
|
551
|
-
|
|
552
|
-
### 3. Check sequence.yaml exists
|
|
553
|
-
If \`oprim/sequence.yaml\` not found: report and stop — advise \`oprim init\`.
|
|
554
|
-
|
|
555
|
-
### 3b. Check for custom rules
|
|
556
|
-
Read \`oprim/config.yaml\`. If it has a non-empty \`rules.bet\` value, treat it as additional guidance from the team — factor it into the questions you ask in step 4 and reflect it in the generated \`bet-decision.md\` content. If \`rules.bet\` is absent or empty, skip this step; behavior is unchanged.
|
|
557
|
-
|
|
558
|
-
### 4. Gather content
|
|
559
|
-
Ask: Decision (Build now / Defer / Kill, default Build now), Owner, Review date (YYYY-MM-DD), Why now, Alternatives considered, Expected outcomes (metric: baseline → target in timeframe), Kill criteria / rollback trigger, PDR links (optional).
|
|
560
|
-
|
|
561
|
-
Then ask about reversibility:
|
|
562
|
-
- "Is this a **2-way door** (reversible — easy to undo, safe to try) or a **1-way door** (hard to reverse — requires high confidence)?"
|
|
563
|
-
|
|
564
|
-
Then ask about each of the four risk dimensions (Low / Medium / High + short rationale):
|
|
565
|
-
- "**Value risk**: Will users/customers actually use or buy this? (Low / Medium / High — and why?)"
|
|
566
|
-
- "**Usability risk**: Can users figure out how to use it without help? (Low / Medium / High — and why?)"
|
|
567
|
-
- "**Feasibility risk**: Can we build this with our current skills, time, and technology? (Low / Medium / High — and why?)"
|
|
568
|
-
- "**Business viability risk**: Does this solution work for the business (revenue, legal, ops)? (Low / Medium / High — and why?)"
|
|
569
|
-
|
|
570
|
-
### 4b. Check for OKF frontmatter
|
|
571
|
-
Read \`oprim/templates/bet-decision.md\`. If it begins with a YAML frontmatter block (\`---\` ... \`---\`), this workspace has OKF frontmatter enabled. Ask for a one-line description and comma-separated tags (subject-area keywords). Prepare a frontmatter block with \`type: bet-decision\`, \`title: <title>\`, \`description: <description>\`, \`tags: [<tags>]\`, \`timestamp: <today's date, ISO 8601>\`, to prepend in step 5.
|
|
572
|
-
If no frontmatter block is found in the template, skip this step — write the file with no frontmatter, matching current behavior.
|
|
573
|
-
|
|
574
|
-
### 5. Write oprim/bets/BET-NNN-<slug>/bet-decision.md
|
|
575
|
-
Prepend the frontmatter block from step 4b, if one was prepared.
|
|
576
|
-
\`\`\`
|
|
577
|
-
# Decision: BET-NNN <title>
|
|
578
|
-
<!-- Naming tip: verb + object [for context] — e.g. "Improve bet naming for scannability" not "Naming" -->
|
|
579
|
-
|
|
580
|
-
## Status
|
|
581
|
-
- Decision: <decision>
|
|
582
|
-
- Date: <today YYYY-MM-DD>
|
|
583
|
-
- Owner: <owner>
|
|
584
|
-
- Review date: <review date>
|
|
585
|
-
|
|
586
|
-
## Door type
|
|
587
|
-
- [<x if 2-way>] 2-way door (reversible — safe to try, easy to undo)
|
|
588
|
-
- [<x if 1-way>] 1-way door (hard to reverse — requires higher confidence before committing)
|
|
589
|
-
|
|
590
|
-
## Risk profile
|
|
591
|
-
- **Value risk**: <Low / Medium / High> — <rationale>
|
|
592
|
-
- **Usability risk**: <Low / Medium / High> — <rationale>
|
|
593
|
-
- **Feasibility risk**: <Low / Medium / High> — <rationale>
|
|
594
|
-
- **Business viability risk**: <Low / Medium / High> — <rationale>
|
|
595
|
-
|
|
596
|
-
## Why now
|
|
597
|
-
<why-now as bullet list>
|
|
598
|
-
|
|
599
|
-
## Alternatives considered
|
|
600
|
-
<alternatives as bullet list>
|
|
601
|
-
|
|
602
|
-
## Expected outcomes
|
|
603
|
-
<outcomes as bullet list>
|
|
604
|
-
|
|
605
|
-
## Kill criteria / rollback trigger
|
|
606
|
-
<kill criteria as bullet list>
|
|
607
|
-
|
|
608
|
-
## Links
|
|
609
|
-
- PDRs: <PDR-IDs or "None">
|
|
610
|
-
- OpenSpec change: <to be filled when promoted>
|
|
611
|
-
\`\`\`
|
|
612
|
-
|
|
613
|
-
### 6. Append to oprim/sequence.yaml backlog
|
|
614
|
-
Read → parse YAML → append → write back (2-space indentation):
|
|
615
|
-
\`\`\`yaml
|
|
616
|
-
- id: BET-NNN
|
|
617
|
-
title: "<title>"
|
|
618
|
-
blocked_by: []
|
|
619
|
-
unlocks: []
|
|
620
|
-
requires_pdrs: []
|
|
621
|
-
\`\`\`
|
|
622
|
-
|
|
623
|
-
### 7. Prompt for optional discovery scaffolding
|
|
624
|
-
Ask: "Do you want to scaffold a discovery.md now? (y/N)"
|
|
625
|
-
- If "y": write \`oprim/bets/BET-NNN-<slug>/discovery.md\` from the discovery template (same structure as \`oprim/templates/discovery.md\`).
|
|
626
|
-
- If "n" or Enter: skip silently.
|
|
627
|
-
|
|
628
|
-
### 8. Report what was created
|
|
629
|
-
`;
|
|
630
|
-
}
|
|
631
|
-
function noteSkill() {
|
|
632
|
-
return `---
|
|
633
|
-
name: oprim-note
|
|
634
|
-
description: Create a new atomic note in oprim/notes/ for lightweight thinking capture, with tiered frontmatter and optional bet links
|
|
635
|
-
---
|
|
636
|
-
|
|
637
|
-
Create a new note in \`oprim/notes/\` for lightweight thinking capture — an observation, idea, or connection that hasn't yet earned a place in a bet or PDR.
|
|
638
|
-
|
|
639
|
-
**Interactive prompts:** Use the **AskUserQuestion tool** for every question in this skill — do not write questions as plain text.
|
|
640
|
-
|
|
641
|
-
## What you're creating
|
|
642
|
-
|
|
643
|
-
A note is a small, disposable unit of thinking: an observation, a stray idea, or a connection between bets, captured before it's proven enough to belong in a discovery hypothesis or bet-decision. Notes carry no owner and no kill criterion — they're not commitments. Promote a note into a bet later with \`/oprim:promote NOTE-NNN\` once it's worth committing to.
|
|
644
|
-
|
|
645
|
-
## Steps
|
|
646
|
-
|
|
647
|
-
### 1. Get the note title
|
|
648
|
-
If not provided, ask: "What is this note about? (a short title)"
|
|
649
|
-
|
|
650
|
-
### 2. Assign the next NOTE ID
|
|
651
|
-
Scan \`oprim/notes/\` for files matching \`NOTE-(\\d+)-\`. Extract the numeric part from each match. Assign max+1, zero-padded to 3 digits. Default \`001\` if none found.
|
|
652
|
-
|
|
653
|
-
### 2b. Derive the slug
|
|
654
|
-
From the note title: lowercase all characters, replace any character that is not a letter or digit with a hyphen, collapse consecutive hyphens to one, strip leading/trailing hyphens, truncate to 40 characters at the last hyphen boundary. This becomes \`<slug>\`.
|
|
655
|
-
Output path: \`oprim/notes/NOTE-NNN-<slug>.md\`
|
|
656
|
-
|
|
657
|
-
### 3. Gather the note body
|
|
658
|
-
Ask: "What's the observation, idea, or connection?" (free-form prose — this becomes the note body).
|
|
659
|
-
|
|
660
|
-
### 4. Gather tags
|
|
661
|
-
Read \`oprim/config.yaml\`. If it has a \`notes:\` section with a \`tags:\` list, show it and ask the user to pick from it or add new ones. If \`notes.tags\` is absent or empty, ask for tags directly (comma-separated) — there's no vocabulary yet to constrain against.
|
|
662
|
-
A tag not already in \`notes.tags\` SHALL be accepted, never rejected, and appended to \`oprim/config.yaml\`'s \`notes.tags\` list (creating the \`notes:\` section if absent) — the vocabulary grows from usage rather than requiring upfront authoring.
|
|
663
|
-
|
|
664
|
-
### 5. Gather optional bet links
|
|
665
|
-
Ask: "Does this relate to any existing bets? (comma-separated BET-IDs, or Enter to skip)"
|
|
666
|
-
|
|
667
|
-
### 6. Check the frontmatter tier
|
|
668
|
-
Read \`oprim/templates/note.md\`.
|
|
669
|
-
- If it exists and its frontmatter block contains a \`description:\` field, this workspace is on the **OKF tier** — ask for a one-line description.
|
|
670
|
-
- If it exists with no \`description:\` field, use the **minimal tier** — skip the description.
|
|
671
|
-
- If the file doesn't exist (project initialized before notes were introduced), read \`oprim/config.yaml\` directly: \`okf.enabled: true\` → OKF tier (ask for a description); otherwise → minimal tier.
|
|
672
|
-
|
|
673
|
-
### 7. Write oprim/notes/NOTE-NNN-<slug>.md
|
|
674
|
-
|
|
675
|
-
Minimal tier:
|
|
676
|
-
\`\`\`
|
|
677
|
-
---
|
|
678
|
-
type: note
|
|
679
|
-
title: "<title>"
|
|
680
|
-
tags: [<tags>]
|
|
681
|
-
timestamp: <today, ISO 8601>
|
|
682
|
-
---
|
|
683
|
-
|
|
684
|
-
# Note: <title>
|
|
685
|
-
|
|
686
|
-
<body>
|
|
687
|
-
|
|
688
|
-
## Bets
|
|
689
|
-
- <BET-IDs from step 5, or "None">
|
|
690
|
-
\`\`\`
|
|
691
|
-
|
|
692
|
-
OKF tier: same as above, with \`description: "<description>"\` inserted immediately after \`title\`.
|
|
693
|
-
|
|
694
|
-
### 8. Link back from referenced bets
|
|
695
|
-
For each BET-ID gathered in step 5: read \`oprim/bets/BET-NNN/bet-decision.md\`, and add \`- Notes: NOTE-NNN\` under its \`## Links\` section (append to an existing \`Notes:\` line, or add a new one).
|
|
696
|
-
|
|
697
|
-
### 9. Report what was created
|
|
698
|
-
`;
|
|
699
|
-
}
|
|
700
|
-
function criteriaSkill() {
|
|
701
|
-
return `---
|
|
702
|
-
name: oprim-criteria
|
|
703
|
-
description: Create or append to a criteria.yaml contract for a bet, with structured Amplitude and BigQuery source mapping
|
|
704
|
-
---
|
|
705
|
-
|
|
706
|
-
Create or append to \`oprim/bets/BET-NNN/criteria.yaml\`.
|
|
707
|
-
|
|
708
|
-
**Interactive prompts:** Use the **AskUserQuestion tool** for every question in this skill — do not write questions as plain text.
|
|
709
|
-
|
|
710
|
-
## Steps
|
|
711
|
-
|
|
712
|
-
### 1. Identify the bet
|
|
713
|
-
If not provided, ask: "Which bet are you adding criteria for? (e.g. BET-042)"
|
|
714
|
-
|
|
715
|
-
### 2. Verify bet exists
|
|
716
|
-
If \`oprim/bets/BET-NNN/\` not found: report and stop — advise using the \`oprim-bet\` skill first.
|
|
717
|
-
|
|
718
|
-
### 3. Gather metric details
|
|
719
|
-
Ask: metric ID (snake_case), metric name, baseline (numeric), target (numeric), timeframe, launch date (YYYY-MM-DD or TBD), segment (optional).
|
|
720
|
-
|
|
721
|
-
### 4. Gather source mapping
|
|
722
|
-
Ask: source type (amplitude / bigquery)
|
|
723
|
-
|
|
724
|
-
If amplitude: event name, aggregation (unique_users / event_count / property_sum), denominator event (optional).
|
|
725
|
-
\`\`\`yaml
|
|
726
|
-
source:
|
|
727
|
-
type: amplitude
|
|
728
|
-
definition:
|
|
729
|
-
event: <event_name>
|
|
730
|
-
aggregation: <aggregation>
|
|
731
|
-
denominator_event: <event_name | null>
|
|
732
|
-
\`\`\`
|
|
733
|
-
|
|
734
|
-
If bigquery: table, metric column, SQL filter, aggregation (sum / count / count_distinct / avg), denominator query (optional).
|
|
735
|
-
\`\`\`yaml
|
|
736
|
-
source:
|
|
737
|
-
type: bigquery
|
|
738
|
-
definition:
|
|
739
|
-
table: "<project.dataset.table>"
|
|
740
|
-
metric_column: "<column>"
|
|
741
|
-
filter: "<sql_filter>"
|
|
742
|
-
aggregation: <aggregation>
|
|
743
|
-
denominator_query: <sql | null>
|
|
744
|
-
\`\`\`
|
|
745
|
-
|
|
746
|
-
### 5. Build metric entry and write
|
|
747
|
-
If file exists: read → parse → append to \`metrics\` → write back (never overwrite).
|
|
748
|
-
If not: create with \`metrics:\` list.
|
|
749
|
-
|
|
750
|
-
### 6. Ask if more metrics needed. If yes, return to step 3.
|
|
751
|
-
|
|
752
|
-
### 7. Report what was created
|
|
753
|
-
`;
|
|
754
|
-
}
|
|
755
|
-
function archiveSkill() {
|
|
756
|
-
return `---
|
|
757
|
-
name: oprim-archive
|
|
758
|
-
description: Archive a completed bet — moves it to oprim/bets/archived/, removes its sequence.yaml entry, and folds any spec deltas under its specs/ directory into oprim/specs/ current truth
|
|
759
|
-
---
|
|
760
|
-
|
|
761
|
-
Archive a completed bet by moving it to \`oprim/bets/archived/\`, removing it from \`sequence.yaml\`, and (if present) merging its spec deltas into current truth.
|
|
762
|
-
|
|
763
|
-
**Interactive prompts:** Use the **AskUserQuestion tool** for every question in this skill — do not write questions as plain text.
|
|
764
|
-
|
|
765
|
-
## Steps
|
|
766
|
-
|
|
767
|
-
### 1. Get the bet ID
|
|
768
|
-
|
|
769
|
-
If provided as an argument (e.g., \`/oprim:archive BET-005\`), use it directly.
|
|
770
|
-
|
|
771
|
-
If not provided, ask: "Which bet ID would you like to archive? (e.g., BET-005)"
|
|
772
|
-
|
|
773
|
-
Normalize the input: accept \`bet-005\`, \`005\`, \`5\`, or \`BET-005\` — always treat as \`BET-NNN\` zero-padded to 3 digits.
|
|
774
|
-
|
|
775
|
-
### 2. Resolve the bet directory
|
|
776
|
-
|
|
777
|
-
Look for the bet directory in \`oprim/bets/\` using two patterns:
|
|
778
|
-
1. Exact match: \`oprim/bets/BET-NNN/\` (legacy non-slug format)
|
|
779
|
-
2. Slug variant: any directory starting with \`BET-NNN-\` (e.g., \`BET-NNN-<slug>/\`)
|
|
780
|
-
|
|
781
|
-
Use whichever pattern matches. Call this the **resolved directory name**.
|
|
782
|
-
|
|
783
|
-
If multiple directories match (e.g., both \`BET-NNN/\` and \`BET-NNN-slug/\` exist):
|
|
784
|
-
- Report: "Ambiguous: found multiple directories for BET-NNN: [list them]. Please archive manually."
|
|
785
|
-
- Stop.
|
|
786
|
-
|
|
787
|
-
If neither pattern matches:
|
|
788
|
-
- Report: "Bet BET-NNN was not found in oprim/bets/. Nothing was changed."
|
|
789
|
-
- Stop.
|
|
790
|
-
|
|
791
|
-
### 3. Check for active dependencies and concurrent spec-delta conflicts
|
|
792
|
-
|
|
793
|
-
Read \`oprim/sequence.yaml\`. Scan every entry across all buckets (now, next, later, backlog) for any entry whose \`blocked_by\` or \`unlocks\` list contains the target bet ID.
|
|
794
|
-
|
|
795
|
-
Separately, if \`oprim/bets/<resolved-dir>/specs/\` exists: for each \`<capability>/spec.md\` delta file under it, extract every \`### Requirement:\` header from its \`## ADDED\`/\`## MODIFIED\`/\`## REMOVED Requirements\` sections. Then scan every other bet directory directly under \`oprim/bets/\` (excluding \`archived/\` and the bet being archived) for a \`specs/<capability>/spec.md\` file for the same capability; if one exists, extract its \`### Requirement:\` headers too. Flag any header that matches (whitespace-insensitive) between the archiving bet's delta and another still-active bet's delta as an **overlap**.
|
|
796
|
-
|
|
797
|
-
If either sequence.yaml dependents or delta overlaps are found:
|
|
798
|
-
- Show a combined warning listing each dependent entry and each overlapping requirement.
|
|
799
|
-
|
|
800
|
-
Example:
|
|
801
|
-
\`\`\`
|
|
802
|
-
⚠ Warning: BET-005 is referenced by active bets:
|
|
803
|
-
- BET-007 (blocked_by: [BET-005])
|
|
804
|
-
- BET-008 (unlocks: [BET-005])
|
|
805
|
-
⚠ Warning: BET-005's delta for requirement "The system SHALL ..." in capability foo overlaps with active bet BET-009's delta for the same requirement. Archiving BET-005 now applies its version to oprim/specs/foo/spec.md; if BET-009 archives later, its version will overwrite this requirement again (last-write-wins — no 3-way merge is attempted).
|
|
806
|
-
\`\`\`
|
|
807
|
-
- Ask: "Archive BET-NNN anyway? (y/N)"
|
|
808
|
-
- If "n" or Enter: stop, no changes made.
|
|
809
|
-
- If "y": proceed.
|
|
810
|
-
|
|
811
|
-
If neither is found: proceed without warning.
|
|
812
|
-
|
|
813
|
-
### 4. Fold spec deltas into current truth
|
|
814
|
-
|
|
815
|
-
If \`oprim/bets/<resolved-dir>/specs/\` does not exist: skip this step entirely and go to Step 5 — archive behavior is unchanged from before spec deltas existed.
|
|
816
|
-
|
|
817
|
-
Otherwise, for each capability subdirectory under \`oprim/bets/<resolved-dir>/specs/\` containing a \`spec.md\`:
|
|
818
|
-
|
|
819
|
-
1. Read the delta file's \`## ADDED Requirements\` / \`## MODIFIED Requirements\` / \`## REMOVED Requirements\` sections. Each \`### Requirement:\` block runs from its header through its body and any \`#### Scenario:\` sub-entries, up to the next \`### Requirement:\` or \`## \` header.
|
|
820
|
-
2. Read \`oprim/specs/<capability>/spec.md\` if it exists (current truth uses a single flat \`## Requirements\` section).
|
|
821
|
-
- **If it does not exist:**
|
|
822
|
-
- If the delta is entirely \`## ADDED Requirements\` (no MODIFIED/REMOVED sections): create \`oprim/specs/<capability>/spec.md\` with a \`## Requirements\` header and append each ADDED requirement block beneath it.
|
|
823
|
-
- If the delta contains any MODIFIED or REMOVED requirements: stop before moving anything and report an error — "cannot modify/remove requirement '<header>' in capability <capability> — no current-truth spec exists yet for this capability."
|
|
824
|
-
- **If it does exist:**
|
|
825
|
-
- **ADDED**: append the requirement block to the end of the \`## Requirements\` section.
|
|
826
|
-
- **MODIFIED**: find the existing \`### Requirement:\` block whose header text matches the delta's (whitespace-insensitive); replace that entire block (header, body, and scenarios) with the delta's version. If no match is found, treat it as ADDED instead (append) and note this in the final report.
|
|
827
|
-
- **REMOVED**: find and delete the matching block entirely. If no match is found, note this in the final report and continue — nothing to remove.
|
|
828
|
-
3. Write the updated \`oprim/specs/<capability>/spec.md\`.
|
|
829
|
-
|
|
830
|
-
This fold always overwrites the matched requirement wholesale — it never reconciles two bets' overlapping changes. If a later bet's archive touches the same requirement again, its version simply replaces this one (last-write-wins, confirmed by construction — no 3-way merge).
|
|
831
|
-
|
|
832
|
-
Track which capabilities were merged (and any no-match notes) for the final report.
|
|
833
|
-
|
|
834
|
-
### 5. Move the bet directory to archive
|
|
835
|
-
|
|
836
|
-
Create the archive subfolder if it doesn't exist:
|
|
837
|
-
\`\`\`bash
|
|
838
|
-
mkdir -p oprim/bets/archived
|
|
839
|
-
\`\`\`
|
|
840
|
-
|
|
841
|
-
Move the resolved directory:
|
|
842
|
-
\`\`\`bash
|
|
843
|
-
mv oprim/bets/<resolved-dir> oprim/bets/archived/<resolved-dir>
|
|
844
|
-
\`\`\`
|
|
845
|
-
|
|
846
|
-
### 6. Remove the bet entry from sequence.yaml
|
|
847
|
-
|
|
848
|
-
Read \`oprim/sequence.yaml\`, parse it, and remove the entry with \`id: BET-NNN\` from whichever bucket it appears in (now, next, later, or backlog). Write the updated YAML back using 2-space indentation. Do not modify any other entries.
|
|
849
|
-
|
|
850
|
-
### 7. Report what was done
|
|
851
|
-
|
|
852
|
-
\`\`\`
|
|
853
|
-
## Bet Archived
|
|
854
|
-
|
|
855
|
-
**Bet:** BET-NNN
|
|
856
|
-
**Archived to:** oprim/bets/archived/<resolved-dir>/
|
|
857
|
-
**Removed from sequence.yaml:** ✓
|
|
858
|
-
**Spec deltas merged:** <capability-1>, <capability-2> (omit this line if no specs/ directory was present)
|
|
859
|
-
|
|
860
|
-
The bet is preserved in full at the archive location.
|
|
861
|
-
\`\`\`
|
|
862
|
-
`;
|
|
863
|
-
}
|
|
399
|
+
// The oprim:context skill (PDR-surfacing lookup) is install-time plumbing tied to the
|
|
400
|
+
// pdrSurfacing toggle, not a forkable workflow artifact — it stays a small literal here
|
|
401
|
+
// rather than moving into the declarative workflow-schema system.
|
|
864
402
|
function oprimContextSkill() {
|
|
865
403
|
return `---
|
|
866
404
|
name: oprim:context
|
|
@@ -891,258 +429,28 @@ List each match on its own line, then return — the invoking skill continues to
|
|
|
891
429
|
If no PDRs match: exit silently — produce no output.
|
|
892
430
|
`;
|
|
893
431
|
}
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
Otherwise, enter **Triage mode** — go to Step 2A.
|
|
916
|
-
|
|
917
|
-
### 2A. Triage mode — compute board health
|
|
918
|
-
|
|
919
|
-
Read \`oprim/sequence.yaml\`. Compute:
|
|
920
|
-
|
|
921
|
-
- **WIP utilization**: count entries in \`now\` vs \`wip_limits.now\`
|
|
922
|
-
- **WIP violations**: entries in \`now\` that exceed the WIP limit
|
|
923
|
-
- **Blocked Now bets**: entries in \`now\` whose \`blocked_by\` list contains a bet ID still present in any active lane (now/next/later/backlog)
|
|
924
|
-
- **Ready-to-pull bets**: entries in \`next\` whose \`blocked_by\` list is empty or all resolved (each blocked_by ID is absent from all active lanes)
|
|
925
|
-
- **PDR gaps**: entries in any lane whose \`requires_pdrs\` list contains a PDR ID not found in \`oprim/decisions/\`
|
|
926
|
-
|
|
927
|
-
Surface **ranked suggestions**, most urgent first:
|
|
928
|
-
1. WIP violations → name each excess bet, suggest deferring to \`next\` or \`later\`
|
|
929
|
-
2. Blocked Now bets → name the bet and its unresolved blocker, suggest deferring until blocker resolves
|
|
930
|
-
3. Open Now slot (count < \`wip_limits.now\`) with a ready Next bet → name a specific bet to pull into \`now\`
|
|
931
|
-
4. PDR gaps → name the bet and missing PDR, suggest creating it first
|
|
932
|
-
|
|
933
|
-
Each suggestion must name the exact bet ID, current lane, target lane, and reason.
|
|
934
|
-
|
|
935
|
-
If the board is healthy (no violations, no ready moves): report current WIP utilization and state the board is healthy. Offer to move something anyway if the user wants.
|
|
936
|
-
|
|
937
|
-
After surfacing suggestions, ask: "Which move would you like to make?"
|
|
938
|
-
|
|
939
|
-
### 2B. Seeded mode — target specific context
|
|
940
|
-
|
|
941
|
-
Use the provided context to jump to the most relevant suggestion:
|
|
942
|
-
|
|
943
|
-
- \`bet-created\`: A new bet just landed in backlog. Check if \`now\` has an open slot and \`next\` has a ready bet to pull. If so, suggest the specific bet to pull. Otherwise, confirm the new bet is in backlog and the board looks healthy.
|
|
944
|
-
- \`bet-promoted\`: A bet was just promoted to an OpenSpec change. Verify the bet is still correctly sequenced and surface any resequencing action the promotion warrants.
|
|
945
|
-
- Bet archived (e.g. "BET-011 was archived"): Check if \`now\` dropped below \`wip_limits.now\`. If so, find the most ready bet in \`next\` and suggest pulling it.
|
|
946
|
-
|
|
947
|
-
If no relevant move is found for the provided context, fall back to Triage mode (Step 2A).
|
|
948
|
-
|
|
949
|
-
### 3. Validate the requested move
|
|
950
|
-
|
|
951
|
-
Before executing any move, verify all three constraints:
|
|
952
|
-
|
|
953
|
-
**WIP limit**: Moving a bet to \`now\` must not push the count above \`wip_limits.now\`. If it would, explain the violation and suggest deferring an existing \`now\` bet first.
|
|
954
|
-
|
|
955
|
-
**Blocker resolution**: Moving a bet to \`now\` requires its \`blocked_by\` list to be empty or all resolved (IDs absent from all active lanes). If unresolved, name each unresolved blocker.
|
|
956
|
-
|
|
957
|
-
**PDR preconditions**: Moving a bet to \`now\` requires all \`requires_pdrs\` entries to exist as files in \`oprim/decisions/\`. If any are missing, name them and suggest creating them first.
|
|
958
|
-
|
|
959
|
-
If the move is invalid: explain which constraint failed and suggest the nearest valid alternative. Do not proceed to Step 4.
|
|
960
|
-
|
|
961
|
-
### 4. Preview and confirm
|
|
962
|
-
|
|
963
|
-
Show the exact YAML change before writing. Name the entry that will move: its \`id\`, \`title\`, source lane, and target lane.
|
|
964
|
-
|
|
965
|
-
\`\`\`
|
|
966
|
-
Before: BET-005 is in next (now: 1/2 slots filled)
|
|
967
|
-
After: BET-005 moves to now (now: 2/2 slots filled)
|
|
968
|
-
\`\`\`
|
|
969
|
-
|
|
970
|
-
Ask: "Apply this change? (y/N)"
|
|
971
|
-
- If "n" or Enter: stop, no changes made.
|
|
972
|
-
- If "y": proceed to Step 5.
|
|
973
|
-
|
|
974
|
-
### 5. Write sequence.yaml
|
|
975
|
-
|
|
976
|
-
Read \`oprim/sequence.yaml\`. Remove the bet entry from its current lane. Insert it into the target lane. Write back with 2-space indentation. Do not modify any other entries.
|
|
977
|
-
|
|
978
|
-
### 6. Regenerate view
|
|
979
|
-
|
|
980
|
-
Run \`node oprim/scripts/generate-sequence-view.js\` from the project root to update \`oprim/sequence-view.md\`.
|
|
981
|
-
|
|
982
|
-
### 7. Report what was done
|
|
983
|
-
`;
|
|
984
|
-
}
|
|
985
|
-
function archiveCommandContent() {
|
|
986
|
-
return `Use the Skill tool to invoke the \`oprim-archive\` skill.`;
|
|
987
|
-
}
|
|
988
|
-
function reviewSkill() {
|
|
989
|
-
return `---
|
|
990
|
-
name: oprim-review
|
|
991
|
-
description: Create a KPI review artifact for a completed bet, pre-filled from criteria.yaml with actuals gathered from the user
|
|
992
|
-
---
|
|
993
|
-
|
|
994
|
-
Create a KPI review in \`oprim/reviews/\`.
|
|
995
|
-
|
|
996
|
-
**Interactive prompts:** Use the **AskUserQuestion tool** for every question in this skill — do not write questions as plain text.
|
|
997
|
-
|
|
998
|
-
## Steps
|
|
999
|
-
|
|
1000
|
-
### 1. Identify the bet
|
|
1001
|
-
If not provided, ask: "Which bet are you reviewing? (e.g. BET-042)"
|
|
1002
|
-
|
|
1003
|
-
### 1b. Check for custom rules
|
|
1004
|
-
Read \`oprim/config.yaml\`. If it has a non-empty \`rules.review\` value, treat it as additional guidance from the team — factor it into the questions you ask in step 4 and reflect it in the generated review content. If \`rules.review\` is absent or empty, skip this step; behavior is unchanged.
|
|
1005
|
-
|
|
1006
|
-
### 2. Load criteria and check for a run result
|
|
1007
|
-
|
|
1008
|
-
Read \`oprim/bets/BET-NNN/criteria.yaml\` if it exists (pre-fills baseline and target).
|
|
1009
|
-
If not found: inform user and continue with empty metrics list.
|
|
1010
|
-
|
|
1011
|
-
**Check for measurement run result:** Scan \`oprim/bets/BET-NNN/measurements/\` for files matching \`run-*.yaml\`. If any exist, sort by filename (date-based) and read the most recent.
|
|
1012
|
-
|
|
1013
|
-
**If a run result exists:** use it to pre-populate actuals and status for every metric. Skip step 3 for those metrics. Note the run date — include "Actuals from run: YYYY-MM-DD" in the review artifact.
|
|
1014
|
-
|
|
1015
|
-
**If no run result exists:** proceed to step 3 to gather actuals manually.
|
|
1016
|
-
|
|
1017
|
-
### 3. Gather actuals per metric (only when no run result)
|
|
1018
|
-
For each metric show name/baseline/target and ask: "What was the actual result? (number or 'pending')"
|
|
1019
|
-
|
|
1020
|
-
Status logic:
|
|
1021
|
-
- actual >= target → \`hit\`
|
|
1022
|
-
- actual < target → \`missed\`
|
|
1023
|
-
- 'pending' or not provided → \`pending\`
|
|
1024
|
-
|
|
1025
|
-
### 4. Get review metadata
|
|
1026
|
-
Ask: reviewer name, decision quality notes.
|
|
1027
|
-
|
|
1028
|
-
### 5. Output path
|
|
1029
|
-
\`oprim/reviews/YYYY-MM-DD-BET-NNN-kpi.md\` (today's date)
|
|
1030
|
-
|
|
1031
|
-
### 5b. Check for OKF frontmatter
|
|
1032
|
-
Read \`oprim/templates/kpi-review.md\`. If it begins with a YAML frontmatter block (\`---\` ... \`---\`), this workspace has OKF frontmatter enabled. Ask for a one-line description and comma-separated tags (derived from the reviewed bet's subject area). Prepare a frontmatter block with \`type: kpi-review\`, \`title: <bet ID and title>\`, \`description: <description>\`, \`tags: [<tags>]\`, \`timestamp: <review date, ISO 8601>\`, to prepend in step 6.
|
|
1033
|
-
If no frontmatter block is found in the template, skip this step — write the file with no frontmatter, matching current behavior.
|
|
1034
|
-
|
|
1035
|
-
### 6. Write the review file
|
|
1036
|
-
Prepend the frontmatter block from step 5b, if one was prepared.
|
|
1037
|
-
\`\`\`markdown
|
|
1038
|
-
# KPI Review: BET-NNN
|
|
1039
|
-
|
|
1040
|
-
**Review date:** YYYY-MM-DD
|
|
1041
|
-
**Reviewed by:** <reviewer>
|
|
1042
|
-
**Actuals from run:** YYYY-MM-DD ← include only when a run result was ingested
|
|
1043
|
-
|
|
1044
|
-
| Metric | Baseline | Target | Actual | Status |
|
|
1045
|
-
|--------|----------|--------|--------|--------|
|
|
1046
|
-
| <name> | <baseline> | <target> | <actual> | <status> |
|
|
1047
|
-
|
|
1048
|
-
## Decision quality
|
|
1049
|
-
<notes>
|
|
1050
|
-
|
|
1051
|
-
## Actions
|
|
1052
|
-
- [ ] Update bet-decision outcome section
|
|
1053
|
-
- [ ] Update affected PDRs
|
|
1054
|
-
- [ ] Re-sequence impacted bets
|
|
1055
|
-
\`\`\`
|
|
1056
|
-
|
|
1057
|
-
### 7. Report what was created
|
|
1058
|
-
`;
|
|
1059
|
-
}
|
|
432
|
+
// ─── Bundled skill/command exports (bundled defaults, no project overrides — used by tests
|
|
433
|
+
// and oprim doctor's skill-drift check; installAgentSkills() itself resolves overrides
|
|
434
|
+
// per-project via workflow-schema.ts/workflow-renderer.ts) ────────────────────────────────
|
|
435
|
+
exports.CLAUDE_SKILLS = Object.fromEntries(CLAUDE_SKILL_WORKFLOW_IDS.map((id) => {
|
|
436
|
+
const schema = (0, workflow_schema_1.loadWorkflowSchema)(id);
|
|
437
|
+
return [schema.skillName, (0, workflow_renderer_1.renderSkillBody)(id)];
|
|
438
|
+
}));
|
|
439
|
+
exports.CLAUDE_COMMANDS = Object.fromEntries(CLAUDE_COMMAND_WORKFLOWS.map(({ filename, id }) => [filename, (0, workflow_renderer_1.renderClaudeCommand)(id)]));
|
|
440
|
+
exports.POOLSIDE_SKILLS = Object.fromEntries(POOLSIDE_SKILL_WORKFLOW_IDS.map((id) => {
|
|
441
|
+
const schema = (0, workflow_schema_1.loadWorkflowSchema)(id);
|
|
442
|
+
return [schema.skillName, (0, workflow_renderer_1.renderSkillBody)(id)];
|
|
443
|
+
}));
|
|
444
|
+
exports.CURSOR_SKILLS = Object.fromEntries(CURSOR_SKILL_WORKFLOW_IDS.map((id) => {
|
|
445
|
+
const schema = (0, workflow_schema_1.loadWorkflowSchema)(id);
|
|
446
|
+
return [schema.skillName, (0, workflow_renderer_1.renderSkillBody)(id)];
|
|
447
|
+
}));
|
|
448
|
+
exports.CURSOR_COMMANDS = Object.fromEntries(CURSOR_COMMAND_WORKFLOW_IDS.map((id) => {
|
|
449
|
+
const schema = (0, workflow_schema_1.loadWorkflowSchema)(id);
|
|
450
|
+
return [schema.cursor.command, (0, workflow_renderer_1.renderCursorCommand)(id)];
|
|
451
|
+
}));
|
|
1060
452
|
function specAuthoringSkill() {
|
|
1061
|
-
return
|
|
1062
|
-
name: oprim-spec
|
|
1063
|
-
description: Generate a native oprim capability spec delta at oprim/bets/BET-NNN-<slug>/specs/<capability>/spec.md while a bet is active, in RFC 2119 (SHALL/SHOULD/MAY) requirements and Gherkin scenarios — folded into oprim/specs/<capability>/spec.md (current truth) when the bet is archived
|
|
1064
|
-
---
|
|
1065
|
-
|
|
1066
|
-
Generate a capability spec delta for an active bet — RFC 2119 requirements plus Gherkin scenarios, no OpenSpec required. This skill never writes to \`oprim/specs/\` directly; \`oprim-archive\` folds the delta into current truth when the bet is archived.
|
|
1067
|
-
|
|
1068
|
-
**Interactive prompts:** Use the **AskUserQuestion tool** for every question in this skill — do not write questions as plain text.
|
|
1069
|
-
|
|
1070
|
-
## Steps
|
|
1071
|
-
|
|
1072
|
-
### 1. Get the active bet
|
|
1073
|
-
If a bet ID was provided as context (e.g. invoked from \`/oprim:promote\`), use it directly. Otherwise ask: "Which bet is this spec change for? (e.g. BET-005)"
|
|
1074
|
-
|
|
1075
|
-
Resolve it to a directory in \`oprim/bets/\` using the same two patterns \`oprim-archive\` uses: exact \`BET-NNN/\` (legacy, no slug) or the slug variant \`BET-NNN-<slug>/\`. If neither matches, report "Bet BET-NNN was not found in oprim/bets/ — spec deltas can only be authored against an active bet" and stop.
|
|
1076
|
-
|
|
1077
|
-
### 2. Get the capability name and description
|
|
1078
|
-
If not provided, ask: "What capability are you specifying? (a short name, e.g. 'spec-authoring')" and "What does it do? (one or two sentences)"
|
|
1079
|
-
|
|
1080
|
-
### 2b. Derive the slug
|
|
1081
|
-
From the capability name: lowercase all characters, replace any character that is not a letter or digit with a hyphen, collapse consecutive hyphens to one, strip leading/trailing hyphens. This becomes \`<capability>\`.
|
|
1082
|
-
Output path: \`oprim/bets/<resolved-bet-dir>/specs/<capability>/spec.md\` (a delta, not \`oprim/specs/<capability>/spec.md\` — that file is current truth and is only ever written by \`oprim-archive\`'s merge step).
|
|
1083
|
-
|
|
1084
|
-
### 2c. Check for custom rules
|
|
1085
|
-
Read \`oprim/config.yaml\`. If it has a non-empty \`rules.spec\` value, treat it as additional guidance from the team — factor it into the requirements and scenarios you draft. If \`rules.spec\` is absent or empty, skip this step; behavior is unchanged.
|
|
1086
|
-
|
|
1087
|
-
### 3. Determine the delta type for each requirement
|
|
1088
|
-
For each requirement, ask whether it is new (**ADDED**), a change to an existing current-truth requirement (**MODIFIED**), or a removal of one (**REMOVED**).
|
|
1089
|
-
|
|
1090
|
-
- **ADDED**: gather the requirement statement fresh.
|
|
1091
|
-
- **MODIFIED / REMOVED**: read \`oprim/specs/<capability>/spec.md\` if it exists and list its \`### Requirement:\` headers so the user can pick the one being changed. The header text must match exactly (whitespace-insensitive) for \`oprim-archive\`'s merge step to find it later. If the file doesn't exist yet, MODIFIED/REMOVED aren't possible for this capability — fall back to ADDED.
|
|
1092
|
-
|
|
1093
|
-
### 4. Gather requirements and scenarios
|
|
1094
|
-
For ADDED and MODIFIED requirements, phrase each as an RFC 2119 statement using SHALL (mandatory), SHOULD (recommended), or MAY (optional), then ask for at least one scenario: a WHEN (trigger) and a THEN (expected outcome), with an optional GIVEN (context) and additional AND steps. REMOVED requirements only need the matching header — no new scenarios.
|
|
1095
|
-
|
|
1096
|
-
### 5. Write the delta file
|
|
1097
|
-
Append to (or create) \`oprim/bets/<resolved-bet-dir>/specs/<capability>/spec.md\`, grouping requirements under the matching section header — only include a section if it has at least one requirement under it:
|
|
1098
|
-
|
|
1099
|
-
\`\`\`markdown
|
|
1100
|
-
## ADDED Requirements
|
|
1101
|
-
|
|
1102
|
-
### Requirement: <capability> SHALL/SHOULD/MAY <requirement statement>
|
|
1103
|
-
<one-sentence elaboration>
|
|
1104
|
-
|
|
1105
|
-
#### Scenario: <scenario title>
|
|
1106
|
-
- **GIVEN** <context> (optional)
|
|
1107
|
-
- **WHEN** <trigger>
|
|
1108
|
-
- **THEN** <outcome>
|
|
1109
|
-
- **AND** <additional outcome> (optional)
|
|
1110
|
-
|
|
1111
|
-
## MODIFIED Requirements
|
|
1112
|
-
|
|
1113
|
-
### Requirement: <exact header text matched from oprim/specs/<capability>/spec.md>
|
|
1114
|
-
<revised elaboration>
|
|
1115
|
-
|
|
1116
|
-
#### Scenario: <scenario title>
|
|
1117
|
-
- **WHEN** <trigger>
|
|
1118
|
-
- **THEN** <outcome>
|
|
1119
|
-
|
|
1120
|
-
## REMOVED Requirements
|
|
1121
|
-
|
|
1122
|
-
### Requirement: <exact header text matched from oprim/specs/<capability>/spec.md>
|
|
1123
|
-
\`\`\`
|
|
1124
|
-
|
|
1125
|
-
If the delta file already exists (a prior spec-authoring pass for this bet/capability), append new requirements to the matching section, creating that section if it's not yet present.
|
|
1126
|
-
|
|
1127
|
-
### 6. Report what was created
|
|
1128
|
-
Show the delta file path, which bet it's scoped to, and a summary of the ADDED/MODIFIED/REMOVED requirements captured. Note that it merges into \`oprim/specs/<capability>/spec.md\` when \`BET-NNN\` is archived — nothing is current truth yet.
|
|
1129
|
-
`;
|
|
1130
|
-
}
|
|
1131
|
-
// ─── Cursor inline content (condensed versions for command files) ─────────────
|
|
1132
|
-
function pdrInlineContent() {
|
|
1133
|
-
return `Create a new PDR in \`oprim/decisions/\`. Scan for \`PDR-(\\d+)-\` to assign next ID (zero-padded, default 001). Read \`oprim/config.yaml\`'s \`rules.pdr\` — if non-empty, apply it as additional guidance and reflect it in the generated content; if empty, behavior is unchanged. Gather: title, context, decision, alternatives, consequences, evidence, related bets/specs. Ask if superseding an existing PDR. Write \`oprim/decisions/PDR-NNN-<slug>.md\`. If superseding: update old PDR Status to "Superseded by PDR-NNN". Report what was created.`;
|
|
1134
|
-
}
|
|
1135
|
-
function betInlineContent() {
|
|
1136
|
-
return `Create a new bet in \`oprim/bets/\`. First explain: "A bet is a product decision you're committing to explore — a problem worth solving, a hypothesis worth testing, or a direction worth taking. You'll name it, explain why now, and set a kill criterion." Then show: "Naming tip: verb + object [for context] — Good: 'Improve bet naming for scannability' / Bad: 'Naming'". Scan \`BET-(\\d+)\` dirs for next ID (zero-padded, default 001). Check \`oprim/sequence.yaml\` exists (stop if not — advise oprim init). Read \`oprim/config.yaml\`'s \`rules.bet\` — if non-empty, apply it as additional guidance and reflect it in the generated content; if empty, behavior is unchanged. After receiving the title, validate: if fewer than 4 words OR fewer than 25 characters, warn "this title may be too vague", suggest a reformulation, and ask "Proceed anyway? (y/N)" — if "n", prompt for a revised title. Gather: decision (default Build now), owner, review date, why-now, alternatives, expected outcomes, kill criteria, PDR links. Write \`oprim/bets/BET-NNN/bet-decision.md\` with an inline naming tip comment in the header. Append entry to sequence.yaml backlog: \`{id, title, blocked_by: [], unlocks: [], requires_pdrs: []}\`. Then ask: "Do you want to scaffold a discovery.md now? (y/N)" — if "y", write \`oprim/bets/BET-NNN/discovery.md\` from the discovery template (sections: Problem Framing, User Research Signals, Competitive Context, Open Questions); if "n" or Enter, skip silently. Report what was created.`;
|
|
1137
|
-
}
|
|
1138
|
-
function noteInlineContent() {
|
|
1139
|
-
return `Create a new note in \`oprim/notes/\` for lightweight thinking capture — an observation, idea, or connection that hasn't yet earned a place in a bet or PDR. Notes carry no owner or kill criterion; promote one into a bet later with \`/oprim:promote NOTE-NNN\`. Ask for a short title. Scan \`oprim/notes/NOTE-(\\d+)-\` for the next id (zero-padded, default 001). Ask for the note body (free-form), tags, and optional related BET-IDs. Tags are checked against \`oprim/config.yaml\`'s \`notes.tags\`; any new tag is accepted and appended to that list rather than rejected — the vocabulary grows from usage. Read \`oprim/templates/note.md\` — if its frontmatter has a \`description:\` field, this workspace is on the OKF tier and needs a one-line description; if it has no \`description:\` field, use the minimal tier; if the file doesn't exist, fall back to reading \`okf.enabled\` directly from \`oprim/config.yaml\`. Write \`oprim/notes/NOTE-NNN-<slug>.md\` with the correct frontmatter tier and a \`## Bets\` section listing any related BET-IDs. For each related bet, append \`- Notes: NOTE-NNN\` to that bet-decision's \`## Links\` section. Report what was created.`;
|
|
1140
|
-
}
|
|
1141
|
-
function criteriaInlineContent() {
|
|
1142
|
-
return `Add metrics to \`oprim/bets/BET-NNN/criteria.yaml\`. Verify bet dir exists. Gather: metric ID, name, baseline, target, timeframe, launch date, segment. Ask source type (amplitude or bigquery). Amplitude: event, aggregation, denominator_event. BigQuery: table, metric_column, filter, aggregation, denominator_query. If file exists: append to metrics list (never overwrite). If not: create. Ask if adding more metrics. Report what was created.`;
|
|
1143
|
-
}
|
|
1144
|
-
function reviewInlineContent() {
|
|
1145
|
-
return `Create KPI review in \`oprim/reviews/YYYY-MM-DD-BET-NNN-kpi.md\`. Read \`oprim/config.yaml\`'s \`rules.review\` — if non-empty, apply it as additional guidance and reflect it in the generated content; if empty, behavior is unchanged. Read \`criteria.yaml\` for pre-fill (baseline/target). Check \`oprim/bets/BET-NNN/measurements/\` for \`run-*.yaml\` files — if found, use the most recent to pre-populate actuals and status (include "Actuals from run: YYYY-MM-DD" note). If no run result, ask for each metric's actual value. Status: actual >= target → hit, actual < target → missed, not provided → pending. Ask reviewer name and decision quality notes. Write review with metric table and Actions checklist. Report what was created.`;
|
|
453
|
+
return (0, workflow_renderer_1.renderSkillBody)('spec-authoring');
|
|
1146
454
|
}
|
|
1147
455
|
// ─── Hook scripts: co-archival coordination ──────────────────────────────────
|
|
1148
456
|
function hooksConfig(framework) {
|
|
@@ -1293,86 +601,6 @@ function mergeClaudeSettingsHooks(claudeDir) {
|
|
|
1293
601
|
fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + '\n', 'utf-8');
|
|
1294
602
|
console.log(chalk_1.default.green('✓') + ' .claude/settings.json (UserPromptSubmit + Stop hooks registered)');
|
|
1295
603
|
}
|
|
1296
|
-
// ─── Legacy content (promote remains inline; sequence now delegates to skill) ─
|
|
1297
|
-
function promoteContent(framework = 'openspec') {
|
|
1298
|
-
const sectionATitle = framework === 'openspec'
|
|
1299
|
-
? 'A. Bet → OpenSpec change'
|
|
1300
|
-
: framework === 'native'
|
|
1301
|
-
? 'A. Bet → native oprim spec'
|
|
1302
|
-
: 'A. Bet → spec (no framework configured)';
|
|
1303
|
-
const sectionABody = framework === 'openspec'
|
|
1304
|
-
? `1. **Locate the bet** — read \`oprim/bets/BET-XXX/bet-decision.md\`
|
|
1305
|
-
2. **Validate status** — decision must be "Build now"
|
|
1306
|
-
3. **Check authority boundary** — confirm primer artifact owns why/order/outcome only
|
|
1307
|
-
4. **Create OpenSpec change** — derive the change name as \`bet-NNN-<slug>\` where \`NNN\` is the zero-padded bet number (e.g. BET-004 → \`bet-004\`) and \`<slug>\` is a short kebab-case summary of the change. Then invoke the \`/openspec-propose\` skill (or \`/opsx:propose\`) with that name to create the change directory with **all required artifacts**: \`proposal.md\`, \`design.md\`, \`tasks.md\`, and \`specs/<capability>/spec.md\` for every capability listed under \`## Capabilities\`.
|
|
1308
|
-
- Pass the bet decision content as context so the proposal reflects the bet's why/outcome
|
|
1309
|
-
- **Do not manually create a partial change directory** — the propose skill ensures no artifact is omitted
|
|
1310
|
-
- The spec file(s) are mandatory: each capability modified or added must have WHEN/THEN scenarios under \`## ADDED Requirements\` or \`## MODIFIED Requirements\`
|
|
1311
|
-
5. **Link artifacts**:
|
|
1312
|
-
- Add OpenSpec change path to bet-decision \`## Links\` section
|
|
1313
|
-
- Add bet ID to OpenSpec proposal \`## Context\` section
|
|
1314
|
-
6. **Copy criteria** — if \`oprim/bets/BET-XXX/criteria.yaml\` exists, link it from OpenSpec proposal
|
|
1315
|
-
7. **Verify completeness** — confirm the change directory contains:
|
|
1316
|
-
- \`proposal.md\`
|
|
1317
|
-
- \`design.md\`
|
|
1318
|
-
- \`tasks.md\`
|
|
1319
|
-
- \`specs/<capability>/spec.md\` for each capability in \`## Capabilities\`
|
|
1320
|
-
If any artifact is missing, create it before reporting done.
|
|
1321
|
-
8. **Report** — show what was linked and what remains for engineering`
|
|
1322
|
-
: framework === 'native'
|
|
1323
|
-
? `1. **Locate the bet** — read \`oprim/bets/BET-XXX/bet-decision.md\`
|
|
1324
|
-
2. **Validate status** — decision must be "Build now"
|
|
1325
|
-
3. **Check authority boundary** — confirm primer artifact owns why/order/outcome only
|
|
1326
|
-
4. **Generate the native spec delta(s)** — for each capability listed under the bet's \`## Capabilities\` section (or a single capability derived from the bet title if none is listed), invoke the \`oprim-spec\` skill with this bet as context to write \`oprim/bets/BET-XXX/specs/<capability>/spec.md\` — a delta using \`## ADDED\`/\`## MODIFIED\`/\`## REMOVED Requirements\` headers reflecting the bet's why/outcome. No OpenSpec change directory is created and OpenSpec need not be installed. Nothing is written to \`oprim/specs/<capability>/spec.md\` (current truth) at promote time — that only happens when this bet is archived.
|
|
1327
|
-
5. **Link artifacts** — add \`- Spec (delta): oprim/bets/BET-XXX/specs/<capability>/spec.md\` (one line per capability) to the bet-decision \`## Links\` section
|
|
1328
|
-
6. **Copy criteria** — if \`oprim/bets/BET-XXX/criteria.yaml\` exists, note it alongside the spec link
|
|
1329
|
-
7. **Report** — show what was created and linked, and note that merge-on-archive will fold the delta into \`oprim/specs/\` when the bet archives`
|
|
1330
|
-
: `1. **Locate the bet** — read \`oprim/bets/BET-XXX/bet-decision.md\`
|
|
1331
|
-
2. **Validate status** — decision must be "Build now"
|
|
1332
|
-
3. **Report and stop** — no speccing framework is configured (\`integrations.spec_framework: none\`). Add \`- Spec: none (no speccing framework configured)\` to the bet-decision \`## Links\` section. No spec artifact is created.`;
|
|
1333
|
-
return `
|
|
1334
|
-
Promote an atomic note into a bet, or a prioritized bet into a capability spec. The promotion path is determined solely by the prefix of the ID argument — there is no separate command for each.
|
|
1335
|
-
|
|
1336
|
-
**Input**: Specify an ID (e.g., \`/oprim:promote BET-042\` or \`/oprim:promote NOTE-005\`) or omit to be prompted.
|
|
1337
|
-
|
|
1338
|
-
### 0. Determine the promotion path from the ID prefix
|
|
1339
|
-
- \`BET-\` → **${sectionATitle}**
|
|
1340
|
-
- \`NOTE-\` → **B. Note → Bet**
|
|
1341
|
-
- Anything else → report "Unrecognized ID prefix — expected BET- or NOTE-" and stop. Do not silently do nothing.
|
|
1342
|
-
|
|
1343
|
-
## ${sectionATitle}
|
|
1344
|
-
|
|
1345
|
-
${sectionABody}
|
|
1346
|
-
|
|
1347
|
-
## B. Note → Bet
|
|
1348
|
-
|
|
1349
|
-
1. **Locate the note** — read \`oprim/notes/NOTE-XXX-<slug>.md\`
|
|
1350
|
-
2. **Assign the next BET ID** — scan both \`oprim/bets/\` and \`oprim/bets/archived/\` for directories matching \`BET-(\\d+)(-[^/]*)?\`, max+1 zero-padded to 3 digits (default 001) — same convention \`oprim-bet\` uses
|
|
1351
|
-
3. **Derive the slug** from the note's title (lowercase, non-alphanumeric → hyphen, collapse/trim hyphens, truncate to 40 chars at a hyphen boundary)
|
|
1352
|
-
4. **Draft the bet** — write \`oprim/bets/BET-NNN-<slug>/bet-decision.md\` from the standard bet-decision structure, pre-filling only \`## Why now\` from the note's body. Leave \`Alternatives considered\`, \`Expected outcomes\`, and \`Kill criteria / rollback trigger\` as template placeholders — draft from the note, don't fabricate content it doesn't support. Ask for \`Owner\` and \`Review date\`; default \`Decision: Build now\` and \`Date\` to today.
|
|
1353
|
-
5. **Register the new bet** — append to \`oprim/sequence.yaml\` backlog: \`{id, title, blocked_by: [], unlocks: [], requires_pdrs: []}\`
|
|
1354
|
-
6. **Link back** — add \`Bets: BET-NNN\` to the note (creating or extending its \`## Bets\` section)
|
|
1355
|
-
7. **Report** — show the new bet's path and flag that \`Alternatives considered\`, \`Expected outcomes\`, and \`Kill criteria\` still need authoring before this bet can itself be promoted
|
|
1356
|
-
`;
|
|
1357
|
-
}
|
|
1358
|
-
function sequenceContent() {
|
|
1359
|
-
return `Use the Skill tool to invoke the \`oprim-sequence\` skill.`;
|
|
1360
|
-
}
|
|
1361
|
-
function sequenceInlineContent() {
|
|
1362
|
-
return `
|
|
1363
|
-
Validate the primer sequencing board and suggest rebalancing if needed.
|
|
1364
|
-
|
|
1365
|
-
**Steps**
|
|
1366
|
-
|
|
1367
|
-
1. **Read board** — load \`oprim/sequence.yaml\`
|
|
1368
|
-
2. **Check WIP limits** — compare \`now\` count against \`wip_limits.now\`
|
|
1369
|
-
3. **Validate blockers** — for each bet in \`now\`, confirm all \`blocked_by\` entries are complete or absent
|
|
1370
|
-
4. **Validate PDR preconditions** — confirm all \`requires_pdrs\` entries exist in \`oprim/decisions/\`
|
|
1371
|
-
5. **Report violations** — list any WIP excess, unresolved blockers, or missing PDRs
|
|
1372
|
-
6. **Suggest moves** — recommend bets to defer to \`next\` or \`later\` to resolve violations
|
|
1373
|
-
7. **Regenerate view** — run \`node oprim/scripts/generate-sequence-view.js\` from the project root to update \`oprim/sequence-view.md\`
|
|
1374
|
-
`;
|
|
1375
|
-
}
|
|
1376
604
|
// ─── Instruction-file helpers (Codex / Gemini CLI) ────────────────────────────
|
|
1377
605
|
const OPRIM_START = '<!-- oprim:start -->';
|
|
1378
606
|
const OPRIM_END = '<!-- oprim:end -->';
|
|
@@ -1395,100 +623,12 @@ function writeAgentInstructionFile(filePath, section) {
|
|
|
1395
623
|
fs.writeFileSync(filePath, existing + separator + delimited + '\n', 'utf-8');
|
|
1396
624
|
}
|
|
1397
625
|
}
|
|
1398
|
-
function oprimWorkflowsInline() {
|
|
1399
|
-
return `
|
|
1400
|
-
## oprim workflows
|
|
1401
|
-
|
|
1402
|
-
### Bet authoring (oprim-bet)
|
|
1403
|
-
Create a new bet in \`oprim/bets/\` and register it on the sequencing board.
|
|
1404
|
-
|
|
1405
|
-
1. Show naming tip: "verb + object [for context] — e.g. 'Improve bet naming for scannability'"
|
|
1406
|
-
2. Ask for the bet title. Validate: fewer than 4 words OR fewer than 25 chars → warn, suggest reformulation, ask "Proceed anyway? (y/N)".
|
|
1407
|
-
3. Assign next BET ID: scan \`oprim/bets/BET-(\\d+)\` dirs, max+1 zero-padded to 3 digits (default 001).
|
|
1408
|
-
4. Check \`oprim/sequence.yaml\` exists — stop if not, advise \`oprim init\`.
|
|
1409
|
-
4b. Read \`oprim/config.yaml\`'s \`rules.bet\` — if non-empty, apply it as additional guidance and reflect it in the generated content; if empty, behavior is unchanged.
|
|
1410
|
-
5. Gather: decision (default Build now), owner, review date (YYYY-MM-DD), why now, alternatives, expected outcomes, kill criteria, PDR links.
|
|
1411
|
-
6. Write \`oprim/bets/BET-NNN/bet-decision.md\` with all fields.
|
|
1412
|
-
7. Append to \`oprim/sequence.yaml\` backlog: \`{id, title, blocked_by: [], unlocks: [], requires_pdrs: []}\`.
|
|
1413
|
-
8. Ask: "Scaffold a discovery.md now? (y/N)" — if "y", write \`oprim/bets/BET-NNN/discovery.md\`.
|
|
1414
|
-
9. Report what was created.
|
|
1415
|
-
|
|
1416
|
-
### Note authoring (oprim-note)
|
|
1417
|
-
Create a new note in \`oprim/notes/\` for lightweight thinking capture — not a bet, no owner or kill criterion.
|
|
1418
|
-
|
|
1419
|
-
1. Ask for a short title.
|
|
1420
|
-
2. Assign next NOTE ID: scan \`oprim/notes/NOTE-(\\d+)-\`, max+1 zero-padded to 3 digits (default 001).
|
|
1421
|
-
3. Ask for the note body (free-form), tags, and optional related BET-IDs.
|
|
1422
|
-
4. Tags: check against \`oprim/config.yaml\`'s \`notes.tags\` — accept and append any new tag rather than rejecting it (the vocabulary grows from usage).
|
|
1423
|
-
5. Check \`oprim/templates/note.md\`: a \`description:\` field in its frontmatter means the OKF tier (gather a one-line description); no field means the minimal tier; if the file is missing, fall back to \`okf.enabled\` in \`oprim/config.yaml\`.
|
|
1424
|
-
6. Write \`oprim/notes/NOTE-NNN-<slug>.md\` with the correct frontmatter tier and a \`## Bets\` section.
|
|
1425
|
-
7. For each related bet, append \`- Notes: NOTE-NNN\` to that bet's \`## Links\` section.
|
|
1426
|
-
8. Report what was created.
|
|
1427
|
-
|
|
1428
|
-
### Criteria authoring (oprim-criteria)
|
|
1429
|
-
Create or append to \`oprim/bets/BET-NNN/criteria.yaml\`.
|
|
1430
|
-
|
|
1431
|
-
1. Ask which bet (e.g. BET-042). Verify dir exists.
|
|
1432
|
-
2. Gather: metric ID (snake_case), name, baseline, target, timeframe, launch date, segment.
|
|
1433
|
-
3. Ask source type (amplitude / bigquery).
|
|
1434
|
-
- Amplitude: event, aggregation (unique_users/event_count/property_sum), denominator_event.
|
|
1435
|
-
- BigQuery: table, metric_column, filter, aggregation, denominator_query.
|
|
1436
|
-
4. If file exists: append to \`metrics\` list (never overwrite). If not: create.
|
|
1437
|
-
5. Ask if adding more metrics.
|
|
1438
|
-
6. Report what was created.
|
|
1439
|
-
|
|
1440
|
-
### PDR authoring (oprim-pdr)
|
|
1441
|
-
Create a new Product Decision Record in \`oprim/decisions/\`.
|
|
1442
|
-
|
|
1443
|
-
1. Ask for decision title.
|
|
1444
|
-
2. Assign next PDR ID: scan \`oprim/decisions/PDR-(\\d+)-\`, max+1 zero-padded to 3 digits (default 001).
|
|
1445
|
-
2b. Read \`oprim/config.yaml\`'s \`rules.pdr\` — if non-empty, apply it as additional guidance and reflect it in the generated content; if empty, behavior is unchanged.
|
|
1446
|
-
3. Gather: context, decision, alternatives, consequences, evidence, related bets/specs.
|
|
1447
|
-
4. Ask if superseding an existing PDR.
|
|
1448
|
-
5. Write \`oprim/decisions/PDR-NNN-<slug>.md\`. If superseding, update old PDR Status.
|
|
1449
|
-
6. Report what was created.
|
|
1450
|
-
|
|
1451
|
-
### KPI review (oprim-review)
|
|
1452
|
-
Create a KPI review artifact in \`oprim/reviews/\`.
|
|
1453
|
-
|
|
1454
|
-
1. Ask which bet (e.g. BET-042).
|
|
1455
|
-
1b. Read \`oprim/config.yaml\`'s \`rules.review\` — if non-empty, apply it as additional guidance and reflect it in the generated content; if empty, behavior is unchanged.
|
|
1456
|
-
2. Read \`oprim/bets/BET-NNN/criteria.yaml\` for pre-fill. Check \`oprim/bets/BET-NNN/measurements/\` for \`run-*.yaml\` — use most recent if present.
|
|
1457
|
-
3. If no run result, ask for each metric's actual value.
|
|
1458
|
-
4. Status: actual >= target → hit; actual < target → missed; not provided → pending.
|
|
1459
|
-
5. Ask reviewer name and decision quality notes.
|
|
1460
|
-
6. Write \`oprim/reviews/YYYY-MM-DD-BET-NNN-kpi.md\`.
|
|
1461
|
-
7. Report what was created.
|
|
1462
|
-
|
|
1463
|
-
### Bet archiving (oprim-archive)
|
|
1464
|
-
Archive a completed bet.
|
|
1465
|
-
|
|
1466
|
-
1. Ask for bet ID (accept bet-005, 005, 5, BET-005 — normalize to BET-NNN).
|
|
1467
|
-
2. Verify \`oprim/bets/BET-NNN/\` exists.
|
|
1468
|
-
3. Check \`oprim/sequence.yaml\` for entries where \`blocked_by\` or \`unlocks\` reference the target bet — warn if found. Also check other active bet dirs for delta specs against the same requirement (matching \`### Requirement:\` headers, whitespace-insensitive) — warn if an overlap is found. Ask "Archive anyway? (y/N)" if either warning fires.
|
|
1469
|
-
4. If \`oprim/bets/BET-NNN/specs/\` exists, fold each capability's \`## ADDED\`/\`## MODIFIED\`/\`## REMOVED Requirements\` delta into \`oprim/specs/<capability>/spec.md\` (matching by \`### Requirement:\` header; create the current-truth file if the delta is entirely ADDED) — last-write-wins on overlaps, no 3-way merge. Skip this step entirely if no \`specs/\` dir is present.
|
|
1470
|
-
5. Move directory: \`oprim/bets/BET-NNN → oprim/bets/archived/BET-NNN\`.
|
|
1471
|
-
6. Remove the bet entry from \`oprim/sequence.yaml\`.
|
|
1472
|
-
7. Report what was done.
|
|
1473
|
-
|
|
1474
|
-
### Sequencing board (oprim-sequence)
|
|
1475
|
-
Validate the primer sequencing board and regenerate the visual view.
|
|
1476
|
-
|
|
1477
|
-
1. **Read board** — load \`oprim/sequence.yaml\`
|
|
1478
|
-
2. **Check WIP limits** — compare \`now\` count against \`wip_limits.now\`
|
|
1479
|
-
3. **Validate blockers** — for each bet in \`now\`, confirm all \`blocked_by\` entries are complete or absent
|
|
1480
|
-
4. **Validate PDR preconditions** — confirm all \`requires_pdrs\` entries exist in \`oprim/decisions/\`
|
|
1481
|
-
5. **Report violations** — list any WIP excess, unresolved blockers, or missing PDRs
|
|
1482
|
-
6. **Suggest moves** — recommend bets to defer to \`next\` or \`later\` to resolve violations
|
|
1483
|
-
7. **Regenerate view** — run \`node oprim/scripts/generate-sequence-view.js\` from the project root to update \`oprim/sequence-view.md\`
|
|
1484
|
-
`;
|
|
1485
|
-
}
|
|
1486
626
|
function codexInstructions() {
|
|
1487
|
-
return
|
|
627
|
+
return (0, workflow_renderer_1.renderAgentInstructions)();
|
|
1488
628
|
}
|
|
1489
629
|
function geminiInstructions() {
|
|
1490
|
-
return
|
|
630
|
+
return (0, workflow_renderer_1.renderAgentInstructions)();
|
|
1491
631
|
}
|
|
1492
632
|
function poolsideInstructions() {
|
|
1493
|
-
return
|
|
633
|
+
return (0, workflow_renderer_1.renderAgentInstructions)();
|
|
1494
634
|
}
|