opensddrag 0.1.2 → 0.2.2

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,35 @@
1
+ /**
2
+ * Shared helpers for OpenSddRag skill templates.
3
+ *
4
+ * Each skill lives in its own module (propose.js, spec.js, …) and exports an
5
+ * object: { name, description, body(slug, note) }. The aggregator in index.js
6
+ * wraps `body` with the Claude Code or OpenCode header (`note`) and the YAML
7
+ * frontmatter, so the workflow is authored exactly once and the CC/OC pair is
8
+ * always in sync (command-skill-separation-contract REQ-001).
9
+ */
10
+
11
+ /**
12
+ * Renders the reusable harness phase-gate checklist block, inlined into the
13
+ * spec/apply/verify/archive skills at the point just before the phase gate.
14
+ * Mirrors the legacy harnessChecklistStep() that used to live in the command
15
+ * templates.
16
+ */
17
+ export function harnessChecklistBlock(slug, trigger, gateLabel) {
18
+ return `### Step — Harness checklist (${trigger})
19
+ Call the MCP tool to load all enabled harness rules for the \`${trigger}\` trigger:
20
+ \`get_harness_checklist(trigger="${trigger}", project_slug="${slug}")\`
21
+
22
+ Process the response:
23
+ - **If the result is an empty array \`[]\`** → output "No harness rules for this trigger." and continue.
24
+ - **If any rule has \`severity="error"\`** → present it as:
25
+ \`\`\`
26
+ MUST complete before proceeding (${gateLabel}):
27
+ - [<name>] <instruction>
28
+ \`\`\`
29
+ Then \`STOP\` and wait until each error-severity rule is confirmed satisfied before continuing.
30
+ - **If any rule has \`severity="warning"\`** → present it as "SHOULD complete: [<name>] <instruction>" (advisory; proceed if satisfied).
31
+ - **If any rule has \`severity="info"\`** → present inline as "Info: [<name>] <instruction>" and proceed.
32
+ - Rules are returned sorted error-first then by name; preserve that order when displaying.
33
+ - This step MUST run BEFORE ${gateLabel.toLowerCase()}.
34
+ `;
35
+ }
@@ -0,0 +1,73 @@
1
+ import { harnessChecklistBlock } from "./_shared.js";
2
+
3
+ export const applySkill = {
4
+ name: "opensddrag-apply",
5
+ description:
6
+ "Implement the next pending task against spec acceptance criteria",
7
+ body: (slug, note) => `# OpenSddRag — Apply
8
+ ${note}## When to use
9
+ To implement tasks one at a time, validating each against its spec acceptance criteria before
10
+ marking it done. Read the design (and, per task, the spec it implements) as context — the
11
+ proposal is not re-read during apply, since the design already encodes its decisions.
12
+
13
+ ## Inputs
14
+ $ARGUMENTS = change name, or a specific task name.
15
+
16
+ ## Workflow
17
+
18
+ ### Step 1 — Load implementation context
19
+ 1. Load the working context:
20
+ \`get_working_context(project_slug="${slug}")\`
21
+ 2. Fetch the list of all artifacts to serve as the freshness oracle:
22
+ \`list_artifacts(project_slug="${slug}")\`
23
+ 3. Retrieve the change's design content (\`<change-name>-design\`):
24
+ - Locate the design artifact in the \`list_artifacts\` results to get its \`id\` and \`updated_at\`.
25
+ - If no design exists, output "Design missing for change '<change-name>'. Run /opsr:design before /opsr:apply." and STOP.
26
+ - Look up the design's \`id\` in the working context's \`context.content_cache\` (if present):
27
+ - **CACHE HIT:** If the cache entry exists and its \`updated_at\` matches the oracle's \`updated_at\`, use the cached design content. Do not call \`read_artifact\`.
28
+ - **CACHE MISS/STALE:** If the cache entry is missing or its \`updated_at\` does not match, call \`read_artifact(name="<change-name>-design", project_slug="${slug}")\`. Then, update the working context cache by calling \`update_working_context\` with \`context.content_cache[<artifact_id>] = {type: "design", content: "<content>", updated_at: "<updated_at>"}\`.
29
+ 4. Do NOT read the proposal during apply — its rationale is already captured in the design.
30
+ 5. Read the specific spec a task implements pointwise at validation time (Step 6) using the same caching logic (check cache, hit → use, miss/stale → read and cache). Tasks themselves are never cached.
31
+
32
+ ### Step 2 — List pending tasks
33
+ \`list_artifacts(type="task", status="active", project_slug="${slug}")\`
34
+ \`list_artifacts(type="task", status="draft", project_slug="${slug}")\`
35
+ Combine both; filter by metadata.change_name. Prioritize \`active\` (resuming) then \`draft\` in dependency order.
36
+
37
+ ### Step 3 — Select the next task
38
+ If $ARGUMENTS names a task, use it. Otherwise:
39
+ 1. Prefer any task with status="active" (interrupted session).
40
+ 2. Else pick the first draft task whose dependencies are all archived.
41
+ \`read_artifact(name="<task-name>", project_slug="${slug}")\`
42
+
43
+ ### Step 4 — Mark the task active
44
+ \`update_artifact(name="<task-name>", status="active", project_slug="${slug}")\`
45
+ \`update_working_context(context={"current_task": "<task-name>"}, project_slug="${slug}")\`
46
+
47
+ ### Step 5 — Implement the task
48
+ Write the code changes required by the task using Edit/Write/Bash (local files — this is expected).
49
+ The implementation MUST satisfy every acceptance criterion. Pause and ask if anything is unclear — do not guess.
50
+
51
+ ### Step 6 — Validate against spec requirements
52
+ For each acceptance criterion (REQ-NNN): confirm the implementation satisfies it and no spec scenario is broken.
53
+
54
+ ${harnessChecklistBlock(slug, "on_apply", "Marking the task archived")}
55
+ ### Step 7 — Mark the task done
56
+ \`update_artifact(name="<task-name>", status="archived", project_slug="${slug}")\`
57
+
58
+ ### Step 8 — Record and check remaining work
59
+ \`record_trace(action="apply_task", result_summary="Completed task: <task-name>", artifact_id="<artifact-id>", project_slug="${slug}")\`
60
+ \`list_artifacts(type="task", status="draft", project_slug="${slug}")\`
61
+ - If tasks remain: "Task complete. Run /opsr:apply <change-name> for the next task."
62
+ - If all done: "All tasks complete. Run /opsr:verify <change-name>, then /opsr:archive <change-name>."
63
+
64
+ ## Output
65
+ - Code changes on disk satisfying the task's acceptance criteria.
66
+ - Task status advanced draft → active → archived in the database.
67
+
68
+ ## Important rules
69
+ - Read the design and the task's spec before implementing — never code from the task alone. Do not re-read the proposal during apply.
70
+ - Run the harness checklist (on_apply) BEFORE marking a task archived; STOP on any error-severity rule.
71
+ - One task at a time; do not batch-archive tasks.
72
+ `,
73
+ };
@@ -0,0 +1,52 @@
1
+ import { harnessChecklistBlock } from "./_shared.js";
2
+
3
+ export const archiveSkill = {
4
+ name: "opensddrag-archive",
5
+ description: "Finalize a completed change by archiving all its artifacts",
6
+ body: (slug, note) => `# OpenSddRag — Archive
7
+ ${note}## When to use
8
+ To finalize a completed change: run completion checks, sync delta specs into main specs, then
9
+ archive all the change's artifacts.
10
+
11
+ ## Inputs
12
+ $ARGUMENTS = change name. If not provided, list active changes and ask.
13
+
14
+ ## Workflow
15
+
16
+ ### Step 1 — Load the change bundle
17
+ \`read_change_bundle(change_name="<change-name>", project_slug="${slug}")\`
18
+ Archiving sweeps every artifact of the change, so load them all in one call. The
19
+ response carries the proposal, design, specs, and the task list
20
+ (\`tasks[] = {name, status}\`) with \`task_count\`. Proceed to Step 2.
21
+
22
+ ### Step 2 — Validate artifact completion
23
+ From the bundle's \`tasks[]\`, treat any task whose \`status\` is not \`archived\` as pending.
24
+ If pending tasks exist → warn the user and ask for confirmation to archive anyway.
25
+
26
+ ### Step 3 — Validate task completion
27
+ Count pending vs archived tasks from the bundle. If any non-archived tasks remain → warn and confirm.
28
+
29
+ ### Step 4 — Check for delta specs that need syncing
30
+ From the bundle's \`specs[]\`, filter for metadata.change_name = "<change-name>" AND metadata.is_delta = true.
31
+ If deltas exist: show the affected capabilities and ask "Sync delta specs to main specs now? (recommended)".
32
+ - If yes → run the /opsr:sync workflow (load the opensddrag-sync skill) for each delta.
33
+ - If no → archive without syncing.
34
+
35
+ ${harnessChecklistBlock(slug, "on_archive", "Archiving change artifacts")}
36
+ ### Step 5 — Archive all change artifacts
37
+ For each artifact (proposal, all specs, design, all tasks):
38
+ \`update_artifact(name="<artifact>", status="archived", metadata={"archived_at": "<ISO timestamp>", "change_name": "<change-name>"}, project_slug="${slug}")\`
39
+
40
+ ### Step 6 — Record and show a summary
41
+ \`record_trace(action="archive", result_summary="Archived change: <change-name> (<N> artifacts)", project_slug="${slug}")\`
42
+ Show: artifacts archived, specs synced (if any), and "Change <change-name> is complete."
43
+
44
+ ## Output
45
+ - Every artifact of the change set to status=archived; deltas merged into main specs.
46
+
47
+ ## Important rules
48
+ - Run the harness checklist (on_archive) BEFORE archiving; STOP on any error-severity rule.
49
+ - Never archive over pending tasks without explicit user confirmation.
50
+ - Sync delta specs before archiving so the main specs stay authoritative.
51
+ `,
52
+ };
@@ -0,0 +1,63 @@
1
+ export const continueSkill = {
2
+ name: "opensddrag-continue",
3
+ description: "Create the next single artifact in the SDD dependency chain",
4
+ body: (slug, note) => `# OpenSddRag — Continue
5
+ ${note}## When to use
6
+ To create the NEXT SINGLE artifact in the dependency chain for a change and then stop. Unlike
7
+ /opsr:flow (which creates everything), this advances exactly one step per invocation.
8
+
9
+ Dependency order: proposal → specs → design → tasks.
10
+
11
+ ## Inputs
12
+ $ARGUMENTS = change name.
13
+
14
+ ## Workflow
15
+
16
+ ### Step 1 — Get the current status
17
+ \`list_artifacts(type="proposal", project_slug="${slug}")\`
18
+ \`get_relationships(name="<change-name>-proposal", project_slug="${slug}")\`
19
+ Gather all existing artifacts for this change.
20
+
21
+ ### Step 2 — Find the next artifact to create
22
+ Walk the dependency order and find the first gap:
23
+ 1. proposal → if missing, stop and tell the user to run /opsr:propose first.
24
+ 2. specs → if any capability has no spec → the next artifact is ONE spec.
25
+ 3. design → if missing and all specs exist → the next artifact is the design.
26
+ 4. tasks → if missing and the design exists → the next artifacts are the tasks.
27
+
28
+ If every artifact already exists → tell the user "All planning artifacts complete. Run /opsr:apply."
29
+
30
+ ### Step 3 — Create the NEXT artifact only, by delegating to the matching skill
31
+ Do NOT inline the workflow here — load the corresponding skill and follow it for a single artifact:
32
+ - next = spec → load the \`opensddrag-spec\` skill and create ONE capability's spec.
33
+ - next = design → load the \`opensddrag-design\` skill and create the design.
34
+ - next = tasks → load the \`opensddrag-tasks\` skill and create the tasks.
35
+ Then STOP — do not proceed to the following artifact in this invocation.
36
+
37
+ ### Step 4 — Show progress
38
+ - Show what was created.
39
+ - Show what is now unlocked (next in the dependency chain).
40
+ - Suggest: "Run /opsr:continue <change-name> to create the next artifact."
41
+
42
+ ## Worked example
43
+ Given a change with a proposal and 2 of 3 capabilities specced:
44
+ 1. Step 2 detects the gap: one capability still has no spec.
45
+ 2. Step 3 loads \`opensddrag-spec\` and creates ONLY that capability's spec, then stops.
46
+ 3. Step 4 reports "spec created (3/3). Next: design. Run /opsr:continue <change-name>."
47
+
48
+ Next invocation detects all specs exist but no design → creates the design and stops. And so on
49
+ until tasks exist, at which point it directs the user to /opsr:apply.
50
+
51
+ ## Why one step at a time
52
+ /opsr:continue is for reviewing each artifact before the next is generated. When you want the
53
+ whole chain produced in one pass without pausing, use /opsr:flow instead.
54
+
55
+ ## Output
56
+ - Exactly one new artifact (or one batch of tasks), advancing the change by a single step.
57
+
58
+ ## Important rules
59
+ - Create ONE artifact (or the single tasks batch) per invocation, then stop.
60
+ - Delegate the actual artifact creation to the matching skill — never duplicate its steps here.
61
+ - Respect dependency order; never skip a missing upstream artifact.
62
+ `,
63
+ };
@@ -0,0 +1,82 @@
1
+ export const designSkill = {
2
+ name: "opensddrag-design",
3
+ description:
4
+ "Document technical decisions, architecture, and trade-offs for a change",
5
+ body: (slug, note) => `# OpenSddRag — Design
6
+ ${note}## When to use
7
+ After the specs exist, to capture the technical decisions, architecture, trade-offs, and open
8
+ questions for a change. The design is grounded in the proposal and spec artifacts already saved.
9
+
10
+ ## Inputs
11
+ $ARGUMENTS = change name.
12
+
13
+ ## Workflow
14
+
15
+ ### Step 1 — Read proposal and all specs
16
+ \`read_artifact(name="<change-name>-proposal", project_slug="${slug}")\`
17
+ \`list_artifacts(type="spec", project_slug="${slug}")\`
18
+ \`get_relationships(name="<change-name>-proposal", project_slug="${slug}")\`
19
+ Read each spec linked to this change.
20
+
21
+ ### Step 2 — Search for related prior designs
22
+ \`search_semantic(query="<change topic> design decisions", project_slug="${slug}", limit=3)\`
23
+ Use findings as context — do not duplicate prior work.
24
+
25
+ ### Step 3 — Write the design content
26
+ \`\`\`markdown
27
+ # Design: <change-name>
28
+
29
+ ## Context
30
+ [Background, current state, constraints that shaped this design]
31
+
32
+ ## Goals / Non-Goals
33
+ **Goals:**
34
+ - [What this design achieves]
35
+
36
+ **Non-Goals:**
37
+ - [What this design deliberately does NOT address]
38
+
39
+ ## Decisions
40
+
41
+ ### Decision: <Title>
42
+ **Chosen:** [What was chosen and why]
43
+ **Alternatives considered:**
44
+ - [Alternative 1] — rejected because [reason]
45
+ - [Alternative 2] — rejected because [reason]
46
+
47
+ ## Architecture
48
+ [Components, data flow, integration points — ASCII diagrams if helpful]
49
+
50
+ ## Risks / Trade-offs
51
+ | Risk | Mitigation |
52
+ |------|------------|
53
+ | [Risk] | [Mitigation] |
54
+
55
+ ## Migration Plan
56
+ [Deployment steps, backward compatibility, rollback plan]
57
+
58
+ ## Open Questions
59
+ - [ ] [Question that still needs resolution]
60
+ \`\`\`
61
+
62
+ ### Step 4 — Save the design
63
+ \`create_artifact(name="<change-name>-design", type="design", content="<full design markdown>", metadata={"change_name": "<change-name>"}, project_slug="${slug}")\`
64
+ If a draft design skeleton already exists, use \`update_artifact\` instead of creating a duplicate.
65
+
66
+ ### Step 5 — Link the design to the proposal
67
+ \`link_artifacts(source_name="<change-name>-design", target_name="<change-name>-proposal", relationship_type="depends_on", project_slug="${slug}")\`
68
+
69
+ ### Step 6 — Record and show next steps
70
+ \`record_trace(action="design", result_summary="Created design: <change-name>-design", project_slug="${slug}")\`
71
+ Tell the user: "Design saved. Run /opsr:tasks <change-name> to decompose into tasks."
72
+
73
+ ## Output
74
+ - A \`<change-name>-design\` artifact linked to the proposal.
75
+ - **Unlocks:** /opsr:tasks.
76
+
77
+ ## Important rules
78
+ - Every Decision MUST list the chosen approach AND the alternatives considered with reasons.
79
+ - DO NOT write application code — this phase is design only.
80
+ - If a design already exists, amend it (update_artifact) rather than creating a second one.
81
+ `,
82
+ };
@@ -0,0 +1,62 @@
1
+ export const exploreSkill = {
2
+ name: "opensddrag-explore",
3
+ description: "Investigate a problem or idea without writing any code",
4
+ body: (slug, note) => `# OpenSddRag — Explore
5
+ ${note}## When to use
6
+ Thinking mode — to investigate a problem, idea, or question and build understanding BEFORE
7
+ committing to a proposal. You may capture insights as artifacts, but you NEVER write code here.
8
+
9
+ ## Inputs
10
+ $ARGUMENTS = topic, question, or idea to explore.
11
+
12
+ ## Stance
13
+ You are in THINKING MODE. Your role is to:
14
+ - Ask clarifying questions.
15
+ - Surface at least two options with trade-offs.
16
+ - Investigate the codebase (read-only).
17
+ - Create ASCII diagrams to illustrate ideas.
18
+ - Challenge assumptions and reference existing specs for context.
19
+
20
+ You MUST NOT:
21
+ - Write application code.
22
+ - Create implementation files.
23
+ - Make changes to the codebase.
24
+
25
+ ## Workflow
26
+
27
+ ### Step 1 — Check for existing related work
28
+ \`search_semantic(query="$ARGUMENTS", project_slug="${slug}", limit=5)\`
29
+ \`recall_episodes(query="$ARGUMENTS", project_slug="${slug}", limit=3)\`
30
+ Share any existing specs or past decisions that are relevant.
31
+
32
+ ### Step 2 — Investigate and think
33
+ - Read relevant codebase files (read-only).
34
+ - Identify constraints and dependencies.
35
+ - Surface at least two different approaches; for each, list trade-offs.
36
+
37
+ ### Step 3 — Capture insights (only if the user asks)
38
+ \`create_artifact(name="explore-<topic>-<date>", type="proposal", content="<exploration notes, options, trade-offs>", metadata={"explore": true}, project_slug="${slug}")\`
39
+ If amending an existing design/proposal, use \`update_artifact\` instead.
40
+
41
+ ### Step 4 — Transition when ready
42
+ Summarize the key findings and a recommendation, then ask:
43
+ "Ready to create a formal proposal? Run /opsr:propose <name>."
44
+
45
+ ## Example prompts this skill handles well
46
+ - "Is it coherent to refactor X this way?" → validate the premise against the code, surface risks.
47
+ - "Two ways to model Y — which is better here?" → compare approaches with trade-offs and a pick.
48
+ - "What would it take to add Z?" → scope the work, list constraints and dependencies, no code.
49
+
50
+ ## Output shape
51
+ A short written analysis: premise check → 2+ options with trade-offs → a recommendation →
52
+ optional follow-up actions (amend a design, create an explore-* artifact, or move to /opsr:propose).
53
+
54
+ ## Output
55
+ - Shared analysis and a recommendation; optionally an \`explore-*\` artifact capturing the decision.
56
+
57
+ ## Important rules
58
+ - NEVER write application code or create implementation files in this phase.
59
+ - Only create/update OpenSddRag artifacts when the user explicitly asks to capture something.
60
+ - Prefer presenting trade-offs and a recommendation over an exhaustive survey.
61
+ `,
62
+ };
@@ -0,0 +1,65 @@
1
+ export const flowSkill = {
2
+ name: "opensddrag-flow",
3
+ description: "Run the complete SDD flow end-to-end in one session",
4
+ body: (slug, note) => `# OpenSddRag — Flow
5
+ ${note}## When to use
6
+ To run the complete SDD flow end-to-end in a single session: propose → spec → design → tasks →
7
+ apply → archive. Planning artifacts are saved to the database; implementation code is written locally.
8
+
9
+ This skill is a thin **orchestrator**: each phase delegates to the matching skill, which is the
10
+ single source of truth for that phase's workflow. Do NOT duplicate those steps here.
11
+
12
+ ## Inputs
13
+ $ARGUMENTS = feature description or change name.
14
+
15
+ ## Workflow
16
+
17
+ ### Phase 1 — Propose
18
+ Load the \`opensddrag-propose\` skill and follow it: search for duplicates, compose the proposal
19
+ (Why / What Changes / Capabilities / Impact), and save the \`<change-name>-proposal\` artifact.
20
+
21
+ ### Phase 2 — Spec
22
+ Load the \`opensddrag-spec\` skill and follow it for each capability in the proposal: compose the
23
+ spec (Purpose / Requirements with SHALL / Scenarios with WHEN-THEN), save it, link it to the
24
+ proposal, and validate it. Fix validation errors before continuing.
25
+
26
+ ### Phase 3 — Design
27
+ Load the \`opensddrag-design\` skill and follow it: read all specs, compose the design
28
+ (Context / Goals / Decisions / Architecture / Risks / Migration), save it, and link it to the proposal.
29
+
30
+ ### Phase 4 — Tasks
31
+ Load the \`opensddrag-tasks\` skill and follow it: read proposal + specs + design, create one task
32
+ artifact per unit of work, link each to its spec(s), and update the working context.
33
+
34
+ ### Phase 5 — Apply (repeat for each task in order)
35
+ Load the \`opensddrag-apply\` skill and follow it for each task: read all planning artifacts, mark
36
+ the task active, implement it locally (Edit/Write/Bash), run the on_apply harness checklist, then
37
+ mark it archived and record a trace. Repeat until no draft tasks remain.
38
+
39
+ ### Phase 6 — Archive
40
+ Load the \`opensddrag-archive\` skill and follow it: sync any delta specs, run the on_archive
41
+ harness checklist, archive all change artifacts, and record the completion trace.
42
+
43
+ ## Resuming a partially-complete flow
44
+ Flow is idempotent at the phase level. Before each phase, check what already exists
45
+ (\`get_relationships(name="<change-name>-proposal", project_slug="${slug}")\`) and skip phases whose
46
+ artifacts are already present:
47
+ - Proposal exists → skip Phase 1.
48
+ - All capabilities specced → skip Phase 2.
49
+ - Design exists → skip Phase 3.
50
+ - Tasks exist → skip Phase 4 and resume Phase 5 at the first non-archived task.
51
+ This lets /opsr:flow pick up an interrupted change instead of recreating planning artifacts.
52
+
53
+ ## Pacing
54
+ Pause for user confirmation between planning phases (1–4) when scope is ambiguous; once tasks are
55
+ agreed, Phase 5 can run task-by-task with a trace after each.
56
+
57
+ ## Output
58
+ - A fully executed change: all planning artifacts archived, deltas synced, code implemented.
59
+
60
+ ## Important rules
61
+ - Delegate each phase to its skill — never inline another skill's workflow into this one.
62
+ - Honor every phase gate (validation, harness checklists) as defined by the delegated skill.
63
+ - Implementation code is written to local files; planning artifacts live only in the database.
64
+ `,
65
+ };