domain-knowledge-kit 0.2.13 → 0.2.14

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,93 @@
1
+ ---
2
+ name: domain-knowledge
3
+ description: Portable Agent Skill for working with a Domain Knowledge Pack.
4
+ ---
5
+
6
+ # Domain Knowledge Skill
7
+
8
+ > Portable Agent Skill for working with a Domain Knowledge Pack.
9
+
10
+ ## Description
11
+
12
+ This skill enables an AI agent to understand, query, and maintain a structured domain model defined in YAML with linked Architecture Decision Records (ADRs). The domain model follows Domain-Driven Design (DDD) patterns: bounded contexts, events, commands, policies, aggregates, read models, glossary terms, actors, and cross-context flows.
13
+
14
+ ## Canonical Model
15
+
16
+ The domain model is stored as YAML files on disk:
17
+
18
+ | Path | Content |
19
+ |------|---------|
20
+ | `domain/index.yml` | Registered bounded contexts and cross-context flows |
21
+ | `domain/actors.yml` | Global actors (human, system, external) |
22
+ | `domain/contexts/<name>.yml` | Bounded context: events, commands, policies, aggregates, read models, glossary |
23
+ | `.dkk/adr/adr-NNNN.md` | Architecture Decision Records with YAML frontmatter linking to domain items |
24
+
25
+ ### Item Types
26
+
27
+ | Type | Description | Key Fields |
28
+ |------|-------------|------------|
29
+ | **Event** | Something that happened in the domain | `name`, `description`, `fields`, `raised_by`, `adr_refs` |
30
+ | **Command** | An instruction to change state | `name`, `description`, `fields`, `actor`, `handled_by`, `adr_refs` |
31
+ | **Policy** | Reactive logic triggered by events | `name`, `description`, `when`, `then`, `adr_refs` |
32
+ | **Aggregate** | Consistency boundary handling commands | `name`, `description`, `handles`, `emits`, `adr_refs` |
33
+ | **Read Model** | Query-optimized projection | `name`, `description`, `subscribes_to`, `used_by`, `adr_refs` |
34
+ | **Glossary** | Ubiquitous language term | `term`, `definition`, `aliases`, `adr_refs` |
35
+ | **Actor** | Person or system interacting with the domain | `name`, `type`, `description`, `adr_refs` |
36
+ | **Flow** | Cross-context sequence of steps | `name`, `description`, `steps[]` |
37
+
38
+ ### ID Conventions
39
+
40
+ | Scope | Format | Example |
41
+ |-------|--------|---------|
42
+ | Context item | `<context>.<ItemName>` | `ordering.OrderPlaced` |
43
+ | Actor | `actor.<Name>` | `actor.Customer` |
44
+ | ADR | `adr-NNNN` | `adr-0001` |
45
+ | Flow | `flow.<Name>` | `flow.OrderFulfillment` |
46
+ | Context | `context.<name>` | `context.ordering` |
47
+
48
+ ## Retrieval Rules
49
+
50
+ When answering questions about the domain, always query the model rather than guessing:
51
+
52
+ 1. **Search** — `npx tsx src/cli.ts search "<query>"` performs FTS5 full-text search with relevance ranking.
53
+ 2. **Show** — `npx tsx src/cli.ts show <id>` returns the full YAML definition of any item.
54
+ 3. **Related** — `npx tsx src/cli.ts related <id> --depth <n>` performs BFS graph traversal to find connected items.
55
+ 4. **List** — `npx tsx src/cli.ts list [--context <name>] [--type <type>]` enumerates items with optional filtering.
56
+ 5. **ADR links** — `npx tsx src/cli.ts adr related <id>` finds bidirectional ADR ↔ domain-item links.
57
+
58
+ ## Update Rules
59
+
60
+ When modifying the domain model:
61
+
62
+ 1. **Edit YAML files directly** — never generate domain items from application code.
63
+ 2. **Maintain referential integrity:**
64
+ - `adr_refs` must point to existing ADRs in `.dkk/adr/`.
65
+ - `domain_refs` in ADR frontmatter must point to existing domain items.
66
+ - Cross-references (`handles`, `emits`, `triggers`, `subscribes_to`, `used_by`, `raised_by`, `handled_by`, `actor`) must resolve within the same context or to global actors.
67
+ 3. **Follow naming conventions:**
68
+ - Items: PascalCase (`OrderPlaced`, `PlaceOrder`).
69
+ - Contexts: kebab-case (`ordering`, `inventory-management`).
70
+ - ADR ids: `adr-NNNN` (zero-padded).
71
+ 4. **Run quality gates after every change:**
72
+ ```bash
73
+ npx tsx src/cli.ts validate # Schema + cross-reference checks
74
+ npx tsx src/cli.ts render # Validate → render docs → rebuild search index
75
+ ```
76
+ 5. **Update ADRs** when changes affect architectural decisions — add `domain_refs` to the ADR and `adr_refs` to the domain items.
77
+
78
+ ## Validation
79
+
80
+ The validator checks:
81
+ - **Schema conformance** — Each YAML file is validated against its JSON Schema (`tools/dkk/schema/`).
82
+ - **Cross-references** — All item-to-item, item-to-ADR, and ADR-to-item references resolve correctly.
83
+ - **Context registration** — Every context file in `domain/contexts/` is registered in `domain/index.yml`.
84
+
85
+ ## Generated Documentation
86
+
87
+ Running `npx tsx src/cli.ts render` produces:
88
+ - `.dkk/docs/index.md` — Top-level domain overview.
89
+ - `.dkk/docs/<context>/index.md` — Per-context overview.
90
+ - `.dkk/docs/<context>/<ItemName>.md` — Per-item detail page.
91
+ - SQLite FTS5 search index for the `search` command.
92
+
93
+ Do not edit files under `.dkk/docs/` by hand; they are regenerated on each render.
@@ -0,0 +1,40 @@
1
+ ---
2
+ name: flow-implementer
3
+ description: Portable Agent Skill for guiding developers through framework-agnostic implementation of a flow based on a Domain Knowledge Pack.
4
+ ---
5
+
6
+ # Flow Implementer Skill
7
+
8
+ > Portable Agent Skill for guiding developers through framework-agnostic implementation of a flow based on a Domain Knowledge Pack.
9
+
10
+ ## Description
11
+
12
+ This skill enables an AI agent to guide developers through implementing a specific predefined flow. It uses the `dkk story` command to gather the full domain context, checks architectural constraints, and provides step-by-step, framework-agnostic guidance checklists. It focuses on domain invariants, policies, and behavior rather than generating rigid application boilerplate code.
13
+
14
+ ## Primary Command
15
+
16
+ ```bash
17
+ dkk story <flow-id> # Aggregate full story context (markdown)
18
+ dkk story <flow-id> --json # Machine-readable output for agents
19
+ ```
20
+
21
+ ## Implementation Guidance Workflow
22
+
23
+ When asked to implement, build, or code a flow/feature:
24
+
25
+ 1. **Identify the flow** — Ask the user for the relevant flow ID if not provided, or search for it: \`dkk list --type flow\`.
26
+ 2. **Retrieve full context** — Run \`dkk story <flow-id>\` or \`dkk story <flow-id> --json\` to obtain domain rules.
27
+ 3. **Present Architectural Constraints** — Before any implementation begins, output the ADRs (Architecture Decision Records) from the context. Ask the user to acknowledge these constraints before proceeding.
28
+ 4. **Generate Implementation Checklist** — Create a logical, framework-agnostic checklist of work needed. Typical buckets include:
29
+ - **Domain/Aggregates**: Entities, state transitions, and invariants to model.
30
+ - **Commands/Controllers**: Handlers for incoming commands, preconditions, and validations.
31
+ - **Events**: Domain events to be explicitly published upon successful command validation.
32
+ - **Policies**: Side-effects and reactive logic that triggers when events occur.
33
+ - **Read Models**: Projections that need to be updated in response to events.
34
+ 5. **Interactive Step-by-step Delivery** — Ask the user which checklist item they want to tackle first. Guide them through the logic without writing framework-specific boilerplate initially (unless explicitly requested by the user's overarching project instructions). Keep guidance focused on the domain logic, invariants, and policies defined in the \`dkk story\` output.
35
+ 6. **Noun Enforcement (MANDATORY)** — You MUST use the exact terminology defined in the DKK output. Do not invent new names for entities, commands, or events.
36
+
37
+ ## Interaction Rules
38
+ - Do NOT generate full boilerplate application code initially. Wait for the user to request code generation for a specific checklist item.
39
+ - DO ask the user for confirmation before moving to the next checklist item.
40
+ - DO reference project-level \`.github/copilot-instructions.md\` if the user asks for framework-specific implementations later on.
@@ -0,0 +1,105 @@
1
+ ---
2
+ name: story-analyst
3
+ description: Portable Agent Skill for generating, splitting, and reshaping user stories from a Domain Knowledge Pack.
4
+ ---
5
+
6
+ # Story Analyst Skill
7
+
8
+ > Portable Agent Skill for generating, splitting, and reshaping user stories from a Domain Knowledge Pack.
9
+
10
+ ## Description
11
+
12
+ This skill enables an AI agent to generate accurate, domain-grounded user stories, epics, and acceptance criteria by leveraging the structured domain model managed by DKK. It uses the `dkk story` command to aggregate a flow's complete context in a single call, then maps that context onto standard Agile story formats.
13
+
14
+ ## Primary Command
15
+
16
+ ```bash
17
+ dkk story <flow-id> # Aggregate full story context (markdown)
18
+ dkk story <flow-id> --json # Machine-readable output for agents
19
+ ```
20
+
21
+ Accepts both `flow.Name` and bare `Name` (auto-prefixes `flow.`).
22
+
23
+ ## Story Generation Workflow
24
+
25
+ When asked to write, draft, or generate a user story:
26
+
27
+ 1. **Identify the flow** — Ask the user for the relevant flow ID, or search for it: `dkk list --type flow`. If the user provides a feature name, run `dkk search "<feature>"` to locate the matching flow or command.
28
+ 2. **Retrieve full context** — Run `dkk story <flow-id>`. This returns actors, ordered steps, triggered policies, BDD examples, ADRs, and downstream effects in one call.
29
+ 3. **Map to story format** using the output:
30
+ - **As a** `[Actor from "Actors" section]`
31
+ - **I want to** `[Command description from Steps]`
32
+ - **So that** `[Flow description]`
33
+ 4. **Write acceptance criteria** from the "Policies" and "BDD Examples" sections:
34
+ - Policies provide the **Given/When/Then** structure: When [triggering event] → Then [consequent command]
35
+ - BDD Examples from commands and events are pre-written scenarios — use them directly or expand them
36
+ 5. **Add an Architectural Constraints section** listing all ADRs from the output. Developers must respect these when implementing the story.
37
+ 6. **Add an Implementation Notes section** from "Downstream Effects": read models that must be updated, secondary policies that will fire.
38
+
39
+ ## Noun Enforcement (MANDATORY)
40
+
41
+ Only use terminology present in the `dkk story` output. Never:
42
+ - Invent entity names, command names, or event names not in the output
43
+ - Rename domain terms (if DKK says `OrderBasket`, the story must not say `ShoppingCart`)
44
+ - Reference bounded contexts not mentioned in the step refs
45
+
46
+ If you are uncertain whether a term is canonical, run `dkk search "<term>"` to verify.
47
+
48
+ ## Epic vs. Story Decision Rules
49
+
50
+ After retrieving the flow context, apply these rules:
51
+
52
+ - **Single story:** Flow has ≤3 command steps and spans ≤1 bounded context.
53
+ - **Epic with story slices:** Flow has >3 command steps OR spans >1 bounded context. Slice by:
54
+ 1. Group consecutive steps that share the same bounded context prefix (e.g., all `ordering.*` steps → Story 1)
55
+ 2. Each policy trigger becomes an explicit story ("As a system, when X happens, I want Y to be triggered, so that Z")
56
+ 3. Each slice that produces an event consumed by a read model must explicitly include updating that read model in its scope or acceptance criteria
57
+
58
+ When recommending an epic breakdown, present the slice boundaries and explain which downstream effects belong to each slice.
59
+
60
+ ## Story Reshaping Workflow
61
+
62
+ When asked to refine, split, or revise an existing story:
63
+
64
+ 1. Run `dkk story <flow-id>` for the relevant flow to get the current domain truth
65
+ 2. Compare the story's entities and terminology against the DKK output
66
+ 3. Flag any mismatches: invented terms, missing actors, acceptance criteria that contradict policies
67
+ 4. Suggest corrections using exact DKK terminology
68
+ 5. Ensure the reshaped story still covers all downstream effects (read models, secondary policies)
69
+
70
+ ## Fallback: No Flow Exists
71
+
72
+ If no flow has been defined for the requested feature:
73
+
74
+ 1. Locate the most relevant command: `dkk search "<feature>" --type command`
75
+ 2. Get its full definition: `dkk show <command-id>`
76
+ 3. Get its graph neighbors: `dkk related <command-id> --depth 2`
77
+ 4. Assemble the story from:
78
+ - Command `actor` field → "As a..."
79
+ - Command `description` → "I want to..."
80
+ - Command `preconditions`, `rejections`, `examples` → acceptance criteria
81
+ - Neighboring policies and read models → downstream effects
82
+ 5. Note in the story that no formal flow has been modeled for this feature and recommend the team define one
83
+
84
+ ## Output Format
85
+
86
+ Use this markdown structure for generated stories:
87
+
88
+ ```markdown
89
+ ## [Story Title]
90
+
91
+ **As a** [Actor], **I want to** [action], **so that** [business value].
92
+
93
+ ### Acceptance Criteria
94
+
95
+ - **Given** [precondition], **When** [command/event], **Then** [expected outcome]
96
+ - (repeat for each policy rule and BDD example)
97
+
98
+ ### Architectural Constraints
99
+
100
+ - [adr-NNNN]: [title] ([status])
101
+
102
+ ### Implementation Notes
103
+
104
+ - [Downstream read models, secondary policy triggers, cross-context effects]
105
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "domain-knowledge-kit",
3
- "version": "0.2.13",
3
+ "version": "0.2.14",
4
4
  "description": "Domain Knowledge Pack — YAML + ADR links + deterministic search + generated docs",
5
5
  "type": "module",
6
6
  "repository": {
@@ -18,6 +18,7 @@
18
18
  "dist/",
19
19
  "tools/dkk/schema/",
20
20
  "tools/dkk/templates/",
21
+ ".github/skills/",
21
22
  "LICENSE",
22
23
  "README.md"
23
24
  ],