domain-knowledge-kit 0.1.0 → 0.2.8
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 +111 -229
- package/dist/cli.js +17 -0
- package/dist/cli.js.map +1 -1
- package/dist/features/agent/commands/init.d.ts +11 -0
- package/dist/features/agent/commands/init.d.ts.map +1 -0
- package/dist/features/agent/commands/init.js +77 -0
- package/dist/features/agent/commands/init.js.map +1 -0
- package/dist/features/agent/commands/prime.d.ts +15 -0
- package/dist/features/agent/commands/prime.d.ts.map +1 -0
- package/dist/features/agent/commands/prime.js +425 -0
- package/dist/features/agent/commands/prime.js.map +1 -0
- package/dist/features/pipeline/indexer.d.ts +1 -1
- package/dist/features/pipeline/indexer.d.ts.map +1 -1
- package/dist/features/pipeline/indexer.js +2 -2
- package/dist/features/pipeline/indexer.js.map +1 -1
- package/dist/features/pipeline/renderer.d.ts +6 -6
- package/dist/features/pipeline/renderer.js +7 -7
- package/dist/features/pipeline/renderer.js.map +1 -1
- package/dist/features/pipeline/tests/indexer.test.js +7 -7
- package/dist/features/pipeline/tests/indexer.test.js.map +1 -1
- package/dist/features/pipeline/tests/renderer.test.js +1 -1
- package/dist/features/pipeline/tests/renderer.test.js.map +1 -1
- package/dist/features/pipeline/tests/validate-schemas.test.js +1 -1
- package/dist/features/pipeline/tests/validate-schemas.test.js.map +1 -1
- package/dist/features/pipeline/tests/validator.test.js +30 -30
- package/dist/features/pipeline/tests/validator.test.js.map +1 -1
- package/dist/features/pipeline/validator.d.ts +1 -1
- package/dist/features/pipeline/validator.js +1 -1
- package/dist/features/pipeline/validator.js.map +1 -1
- package/dist/features/query/commands/search.d.ts +3 -0
- package/dist/features/query/commands/search.d.ts.map +1 -1
- package/dist/features/query/commands/search.js +29 -8
- package/dist/features/query/commands/search.js.map +1 -1
- package/dist/features/query/searcher.js +1 -1
- package/dist/features/query/searcher.js.map +1 -1
- package/dist/features/query/tests/searcher.test.js +7 -7
- package/dist/features/query/tests/searcher.test.js.map +1 -1
- package/dist/features/scaffold/commands/add-item.d.ts +15 -0
- package/dist/features/scaffold/commands/add-item.d.ts.map +1 -0
- package/dist/features/scaffold/commands/add-item.js +125 -0
- package/dist/features/scaffold/commands/add-item.js.map +1 -0
- package/dist/features/scaffold/commands/new-adr.d.ts +12 -0
- package/dist/features/scaffold/commands/new-adr.d.ts.map +1 -0
- package/dist/features/scaffold/commands/new-adr.js +95 -0
- package/dist/features/scaffold/commands/new-adr.js.map +1 -0
- package/dist/features/scaffold/commands/new-context.d.ts +17 -0
- package/dist/features/scaffold/commands/new-context.d.ts.map +1 -0
- package/dist/features/scaffold/commands/new-context.js +67 -0
- package/dist/features/scaffold/commands/new-context.js.map +1 -0
- package/dist/features/scaffold/commands/new-domain.d.ts +14 -0
- package/dist/features/scaffold/commands/new-domain.d.ts.map +1 -0
- package/dist/features/scaffold/commands/new-domain.js +86 -0
- package/dist/features/scaffold/commands/new-domain.js.map +1 -0
- package/dist/shared/adr-parser.js +1 -1
- package/dist/shared/errors.js +1 -1
- package/dist/shared/errors.js.map +1 -1
- package/dist/shared/index.d.ts +1 -1
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index.js +1 -1
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/loader.d.ts +1 -1
- package/dist/shared/loader.js +3 -3
- package/dist/shared/paths.d.ts +34 -13
- package/dist/shared/paths.d.ts.map +1 -1
- package/dist/shared/paths.js +53 -23
- package/dist/shared/paths.js.map +1 -1
- package/dist/shared/tests/graph.test.js +10 -10
- package/dist/shared/tests/graph.test.js.map +1 -1
- package/dist/shared/tests/loader.test.js +23 -23
- package/dist/shared/tests/loader.test.js.map +1 -1
- package/dist/shared/tests/verify-collision-fix.test.js +2 -2
- package/dist/shared/tests/verify-collision-fix.test.js.map +1 -1
- package/dist/shared/types/domain.d.ts +5 -5
- package/dist/shared/types/domain.d.ts.map +1 -1
- package/dist/shared/types/domain.js +1 -1
- package/package.json +11 -3
- /package/tools/{domain-pack → dkk}/schema/.gitkeep +0 -0
- /package/tools/{domain-pack → dkk}/schema/actors.schema.json +0 -0
- /package/tools/{domain-pack → dkk}/schema/adr-frontmatter.schema.json +0 -0
- /package/tools/{domain-pack → dkk}/schema/aggregate.schema.json +0 -0
- /package/tools/{domain-pack → dkk}/schema/command.schema.json +0 -0
- /package/tools/{domain-pack → dkk}/schema/context.schema.json +0 -0
- /package/tools/{domain-pack → dkk}/schema/event.schema.json +0 -0
- /package/tools/{domain-pack → dkk}/schema/glossary.schema.json +0 -0
- /package/tools/{domain-pack → dkk}/schema/index.schema.json +0 -0
- /package/tools/{domain-pack → dkk}/schema/policy.schema.json +0 -0
- /package/tools/{domain-pack → dkk}/schema/read-model.schema.json +0 -0
- /package/tools/{domain-pack → dkk}/templates/.gitkeep +0 -0
- /package/tools/{domain-pack → dkk}/templates/context.md.hbs +0 -0
- /package/tools/{domain-pack → dkk}/templates/index.md.hbs +0 -0
- /package/tools/{domain-pack → dkk}/templates/item.md.hbs +0 -0
package/README.md
CHANGED
|
@@ -1,265 +1,147 @@
|
|
|
1
1
|
# Domain Knowledge Kit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Define, validate, search, and document your domain model — all from YAML.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## What Is This?
|
|
6
|
+
|
|
7
|
+
Domain Knowledge Kit (DKK) is a CLI tool for teams practicing Domain-Driven Design. Instead of scattering domain knowledge across wikis, diagrams, and tribal memory, you define your **bounded contexts**, **events**, **commands**, **policies**, **aggregates**, **read models**, and **glossary** in structured YAML files. DKK then:
|
|
8
|
+
|
|
9
|
+
- **Validates** schema conformance and referential integrity across your entire model
|
|
10
|
+
- **Generates** browsable Markdown documentation from your YAML definitions
|
|
11
|
+
- **Builds** a full-text search index (SQLite FTS5) for instant domain queries
|
|
12
|
+
- **Links** Architecture Decision Records (ADRs) bidirectionally to domain items
|
|
13
|
+
- **Integrates** with AI coding agents so they understand your domain, not just your code
|
|
6
14
|
|
|
7
15
|
## Quick Start
|
|
8
16
|
|
|
9
17
|
```bash
|
|
10
|
-
# Install
|
|
18
|
+
# Install
|
|
11
19
|
npm install -g domain-knowledge-kit
|
|
12
20
|
|
|
13
|
-
#
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
#
|
|
21
|
+
# Create a bounded context (per-item directory format)
|
|
22
|
+
mkdir -p .dkk/domain/contexts/ordering/{events,commands,aggregates}
|
|
23
|
+
|
|
24
|
+
# Context metadata
|
|
25
|
+
cat > .dkk/domain/contexts/ordering/context.yml << 'EOF'
|
|
26
|
+
name: ordering
|
|
27
|
+
description: Handles customer order lifecycle.
|
|
28
|
+
EOF
|
|
29
|
+
|
|
30
|
+
# One file per domain item
|
|
31
|
+
cat > .dkk/domain/contexts/ordering/events/OrderPlaced.yml << 'EOF'
|
|
32
|
+
name: OrderPlaced
|
|
33
|
+
description: Raised when a customer order is confirmed.
|
|
34
|
+
raised_by: Order
|
|
35
|
+
EOF
|
|
36
|
+
|
|
37
|
+
cat > .dkk/domain/contexts/ordering/commands/PlaceOrder.yml << 'EOF'
|
|
38
|
+
name: PlaceOrder
|
|
39
|
+
description: Submit a new customer order.
|
|
40
|
+
handled_by: Order
|
|
41
|
+
EOF
|
|
42
|
+
|
|
43
|
+
cat > .dkk/domain/contexts/ordering/aggregates/Order.yml << 'EOF'
|
|
44
|
+
name: Order
|
|
45
|
+
description: Manages order state and invariants.
|
|
46
|
+
handles:
|
|
47
|
+
commands:
|
|
48
|
+
- PlaceOrder
|
|
49
|
+
emits:
|
|
50
|
+
events:
|
|
51
|
+
- OrderPlaced
|
|
52
|
+
EOF
|
|
53
|
+
|
|
54
|
+
# Register it in .dkk/domain/index.yml
|
|
55
|
+
# Add "- name: ordering" to the contexts array
|
|
56
|
+
|
|
57
|
+
# Validate and render
|
|
17
58
|
dkk validate
|
|
18
|
-
|
|
19
|
-
# Render generated documentation
|
|
20
59
|
dkk render
|
|
21
60
|
|
|
22
|
-
#
|
|
61
|
+
# Explore
|
|
23
62
|
dkk search "order"
|
|
63
|
+
dkk show ordering.OrderPlaced
|
|
64
|
+
dkk related ordering.Order
|
|
24
65
|
```
|
|
25
66
|
|
|
26
|
-
|
|
67
|
+
→ **[Full Getting Started Guide](docs/getting-started.md)** — step-by-step walkthrough with examples.
|
|
27
68
|
|
|
28
|
-
|
|
29
|
-
npm install
|
|
69
|
+
## Documentation
|
|
30
70
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
71
|
+
| Guide | What You'll Learn |
|
|
72
|
+
|-------|-------------------|
|
|
73
|
+
| **[Getting Started](docs/getting-started.md)** | Install, create your first context, run quality gates, search and explore |
|
|
74
|
+
| **[Domain Modeling](docs/domain-modeling.md)** | All item types, YAML structure, cross-references, naming conventions, ID formats |
|
|
75
|
+
| **[CLI Reference](docs/cli-reference.md)** | Every command and flag: `list`, `show`, `search`, `related`, `validate`, `render`, `init`, `prime`, `adr show`, `adr related` |
|
|
76
|
+
| **[ADR Guide](docs/adr-guide.md)** | Architecture Decision Records: format, bidirectional linking, querying, best practices |
|
|
77
|
+
| **[AI Agent Integration](docs/ai-agent-integration.md)** | `dkk init`, `dkk prime`, Copilot integration, reusable prompts, portable skills |
|
|
34
78
|
|
|
35
|
-
|
|
36
|
-
npm run build
|
|
37
|
-
npx dkk validate
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
## Directory Layout
|
|
79
|
+
## Key Commands
|
|
41
80
|
|
|
81
|
+
```bash
|
|
82
|
+
dkk validate # Schema + cross-reference validation
|
|
83
|
+
dkk render # Validate → render docs → rebuild search index
|
|
84
|
+
dkk search "payment" # Full-text search with ranking
|
|
85
|
+
dkk show ordering.Order # Display full item definition
|
|
86
|
+
dkk related ordering.Order # Graph traversal of connected items
|
|
87
|
+
dkk list --type event # List all events across contexts
|
|
88
|
+
dkk init # Set up AI agent onboarding
|
|
89
|
+
dkk prime # Output agent context to stdout
|
|
42
90
|
```
|
|
43
|
-
domain/
|
|
44
|
-
index.yml # Registered contexts + cross-context flows
|
|
45
|
-
actors.yml # Global actors (human | system | external)
|
|
46
|
-
contexts/
|
|
47
|
-
<name>.yml # Bounded context definition
|
|
48
|
-
|
|
49
|
-
docs/
|
|
50
|
-
adr/ # Architecture Decision Records (Markdown + YAML frontmatter)
|
|
51
|
-
domain/ # Generated documentation (do not edit by hand)
|
|
52
|
-
|
|
53
|
-
src/
|
|
54
|
-
cli.ts # Slim CLI entry point (registers commands)
|
|
55
|
-
features/ # Vertical feature slices
|
|
56
|
-
query/ # List, show, search, related commands
|
|
57
|
-
commands/ # CLI command handlers
|
|
58
|
-
searcher.ts # FTS5 search logic
|
|
59
|
-
tests/ # Co-located unit tests
|
|
60
|
-
adr/ # ADR show & related commands
|
|
61
|
-
commands/ # CLI command handlers
|
|
62
|
-
pipeline/ # Validate, render, index pipeline
|
|
63
|
-
commands/ # CLI command handlers
|
|
64
|
-
validator.ts # Schema + cross-ref validation
|
|
65
|
-
renderer.ts # Handlebars doc generation
|
|
66
|
-
indexer.ts # Search index builder
|
|
67
|
-
tests/ # Co-located unit tests
|
|
68
|
-
shared/ # Cross-cutting infrastructure
|
|
69
|
-
types/ # DomainModel, SearchIndexRecord, etc.
|
|
70
|
-
loader.ts # YAML model loading
|
|
71
|
-
graph.ts # BFS graph traversal
|
|
72
|
-
item-visitor.ts # Generic item iteration utility
|
|
73
|
-
adr-parser.ts # ADR frontmatter parsing
|
|
74
|
-
paths.ts # Path resolution helpers
|
|
75
|
-
errors.ts # Error formatting
|
|
76
|
-
yaml.ts # YAML I/O helpers
|
|
77
|
-
tests/ # Co-located unit tests
|
|
78
|
-
|
|
79
|
-
tools/
|
|
80
|
-
domain-pack/
|
|
81
|
-
schema/ # JSON Schemas for domain YAML validation
|
|
82
|
-
templates/ # Handlebars templates for doc generation
|
|
83
|
-
|
|
84
|
-
test/
|
|
85
|
-
cli-integration.ts # End-to-end CLI integration tests
|
|
86
|
-
|
|
87
|
-
.github/
|
|
88
|
-
copilot-instructions.md # Copilot integration instructions
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
### Architecture: Vertical Feature Slices
|
|
92
|
-
|
|
93
|
-
The source code is organized into **vertical feature slices** rather than horizontal layers. Each feature slice (`query`, `adr`, `pipeline`) owns its commands, core logic, and tests. The `shared/` module contains cross-cutting infrastructure used by all slices (loader, graph traversal, type definitions, etc.).
|
|
94
|
-
|
|
95
|
-
This structure ensures that adding a new domain item type or feature requires changes localized to one slice, reducing coupling and making the codebase easier to navigate.
|
|
96
|
-
|
|
97
|
-
## Adding a Bounded Context
|
|
98
|
-
|
|
99
|
-
1. Create a new file `domain/contexts/<name>.yml`:
|
|
100
|
-
|
|
101
|
-
```yaml
|
|
102
|
-
name: <name>
|
|
103
|
-
description: A short description of this bounded context.
|
|
104
|
-
events: []
|
|
105
|
-
commands: []
|
|
106
|
-
policies: []
|
|
107
|
-
aggregates: []
|
|
108
|
-
read_models: []
|
|
109
|
-
glossary: []
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
2. Register it in `domain/index.yml`:
|
|
113
|
-
|
|
114
|
-
```yaml
|
|
115
|
-
contexts:
|
|
116
|
-
- name: <name>
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
3. Run quality gates:
|
|
120
|
-
|
|
121
|
-
```bash
|
|
122
|
-
dkk validate
|
|
123
|
-
dkk render
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
## Adding an ADR and Linking It
|
|
127
|
-
|
|
128
|
-
1. Create a Markdown file in `docs/adr/` following the naming convention `adr-NNNN.md` (e.g. `adr-0002.md`):
|
|
129
|
-
|
|
130
|
-
```markdown
|
|
131
|
-
---
|
|
132
|
-
id: adr-NNNN
|
|
133
|
-
title: Short Title
|
|
134
|
-
status: proposed
|
|
135
|
-
date: YYYY-MM-DD
|
|
136
|
-
domain_refs:
|
|
137
|
-
- <context>.<ItemName>
|
|
138
|
-
---
|
|
139
|
-
|
|
140
|
-
## Context
|
|
141
|
-
...
|
|
142
|
-
|
|
143
|
-
## Decision
|
|
144
|
-
...
|
|
145
|
-
|
|
146
|
-
## Consequences
|
|
147
|
-
...
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
2. Link back from domain items by adding the ADR id to their `adr_refs`:
|
|
151
91
|
|
|
152
|
-
|
|
153
|
-
# In domain/contexts/<name>.yml, on the relevant item:
|
|
154
|
-
adr_refs:
|
|
155
|
-
- adr-NNNN
|
|
156
|
-
```
|
|
92
|
+
→ **[Full CLI Reference](docs/cli-reference.md)**
|
|
157
93
|
|
|
158
|
-
|
|
94
|
+
## AI Agent Integration
|
|
159
95
|
|
|
160
|
-
|
|
161
|
-
dkk validate
|
|
162
|
-
dkk render
|
|
163
|
-
```
|
|
96
|
+
DKK has first-class support for AI coding agents. Two commands get you set up:
|
|
164
97
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
### `list`
|
|
170
|
-
|
|
171
|
-
List all domain items.
|
|
172
|
-
|
|
173
|
-
| Flag | Default | Description |
|
|
174
|
-
|------|---------|-------------|
|
|
175
|
-
| `-c, --context <name>` | — | Filter by bounded context |
|
|
176
|
-
| `-t, --type <type>` | — | Filter by item type (`event`, `command`, `policy`, `aggregate`, `read_model`, `glossary`, `actor`, `adr`, `flow`, `context`) |
|
|
177
|
-
| `--json` | — | Output as JSON |
|
|
178
|
-
| `-r, --root <path>` | repo root | Override repository root |
|
|
179
|
-
|
|
180
|
-
### `show <id>`
|
|
181
|
-
|
|
182
|
-
Display the full YAML of a single domain item.
|
|
183
|
-
|
|
184
|
-
| Flag | Default | Description |
|
|
185
|
-
|------|---------|-------------|
|
|
186
|
-
| `--json` | — | Output as JSON |
|
|
187
|
-
| `-r, --root <path>` | repo root | Override repository root |
|
|
188
|
-
|
|
189
|
-
### `search <query>`
|
|
190
|
-
|
|
191
|
-
FTS5 full-text search with ranking. Requires a pre-built index — run `render` first.
|
|
192
|
-
|
|
193
|
-
| Flag | Default | Description |
|
|
194
|
-
|------|---------|-------------|
|
|
195
|
-
| `-c, --context <name>` | — | Filter results to a bounded context |
|
|
196
|
-
| `-t, --type <type>` | — | Filter by item type |
|
|
197
|
-
| `--tag <tag>` | — | Filter by tag/keyword |
|
|
198
|
-
| `--limit <n>` | `20` | Maximum number of results |
|
|
199
|
-
| `--expand` | — | Expand top results with graph neighbours |
|
|
200
|
-
| `--json` | — | Output as JSON |
|
|
201
|
-
| `-r, --root <path>` | repo root | Override repository root |
|
|
202
|
-
|
|
203
|
-
### `related <id>`
|
|
204
|
-
|
|
205
|
-
BFS graph traversal of related items.
|
|
206
|
-
|
|
207
|
-
| Flag | Default | Description |
|
|
208
|
-
|------|---------|-------------|
|
|
209
|
-
| `-d, --depth <n>` | `1` | Maximum BFS traversal depth |
|
|
210
|
-
| `--json` | — | Output as JSON |
|
|
211
|
-
| `-r, --root <path>` | repo root | Override repository root |
|
|
212
|
-
|
|
213
|
-
### `validate`
|
|
214
|
-
|
|
215
|
-
Schema + cross-reference validation.
|
|
216
|
-
|
|
217
|
-
| Flag | Default | Description |
|
|
218
|
-
|------|---------|-------------|
|
|
219
|
-
| `--warn-missing-fields` | — | Warn about events/commands with no `fields` defined |
|
|
220
|
-
| `--json` | — | Output as JSON |
|
|
221
|
-
| `-r, --root <path>` | repo root | Override repository root |
|
|
222
|
-
|
|
223
|
-
### `render`
|
|
224
|
-
|
|
225
|
-
Validate → render Handlebars Markdown docs → rebuild FTS5 SQLite search index.
|
|
226
|
-
|
|
227
|
-
| Flag | Default | Description |
|
|
228
|
-
|------|---------|-------------|
|
|
229
|
-
| `--skip-validation` | — | Skip the schema + cross-ref validation step |
|
|
230
|
-
| `--json` | — | Output as JSON |
|
|
231
|
-
| `-r, --root <path>` | repo root | Override repository root |
|
|
232
|
-
|
|
233
|
-
### `adr show <id>`
|
|
98
|
+
```bash
|
|
99
|
+
dkk init # Add a DKK section to AGENTS.md (idempotent)
|
|
100
|
+
dkk prime # Output full domain context for AI consumption
|
|
101
|
+
```
|
|
234
102
|
|
|
235
|
-
|
|
103
|
+
Agents can then search, show, and traverse your domain model — making domain-aware decisions when writing, reviewing, or refactoring code. DKK also ships with GitHub Copilot instructions, reusable agent prompts, and a portable agent skill.
|
|
236
104
|
|
|
237
|
-
|
|
238
|
-
|------|---------|-------------|
|
|
239
|
-
| `--json` | — | Output as JSON |
|
|
240
|
-
| `-r, --root <path>` | repo root | Override repository root |
|
|
105
|
+
→ **[AI Agent Integration Guide](docs/ai-agent-integration.md)**
|
|
241
106
|
|
|
242
|
-
|
|
107
|
+
## Directory Layout
|
|
243
108
|
|
|
244
|
-
|
|
109
|
+
```
|
|
110
|
+
.dkk/ # Domain model + generated + managed
|
|
111
|
+
domain/ # Domain model (YAML)
|
|
112
|
+
index.yml # Contexts + flows
|
|
113
|
+
actors.yml # Global actors
|
|
114
|
+
contexts/ # Bounded contexts (one dir each)
|
|
115
|
+
<name>/ # Context directory
|
|
116
|
+
context.yml # Context metadata + glossary
|
|
117
|
+
events/ # One .yml file per event
|
|
118
|
+
commands/ # One .yml file per command
|
|
119
|
+
aggregates/ # One .yml file per aggregate
|
|
120
|
+
policies/ # One .yml file per policy
|
|
121
|
+
read-models/ # One .yml file per read model
|
|
122
|
+
adr/ # Architecture Decision Records
|
|
123
|
+
docs/ # Generated docs (do not edit)
|
|
124
|
+
src/ # Source code (vertical slices)
|
|
125
|
+
tools/dkk/ # Schemas + templates
|
|
126
|
+
schema/ # JSON Schemas for validation
|
|
127
|
+
templates/ # Handlebars templates for rendering
|
|
128
|
+
```
|
|
245
129
|
|
|
246
|
-
|
|
247
|
-
|------|---------|-------------|
|
|
248
|
-
| `-r, --root <path>` | repo root | Override repository root |
|
|
130
|
+
## Contributing / Local Development
|
|
249
131
|
|
|
250
|
-
|
|
132
|
+
```bash
|
|
133
|
+
npm install
|
|
251
134
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
| Actor | `actor.<Name>` | `actor.Customer` |
|
|
256
|
-
| ADR | `adr-NNNN` | `adr-0001` |
|
|
257
|
-
| Flow | `flow.<Name>` | `flow.OrderFulfillment` |
|
|
258
|
-
| Context | `context.<name>` | `context.ordering` |
|
|
135
|
+
# Run directly via tsx (no build step needed)
|
|
136
|
+
npm run dev -- validate
|
|
137
|
+
npm run dev -- render
|
|
259
138
|
|
|
260
|
-
|
|
139
|
+
# Or build first
|
|
140
|
+
npm run build
|
|
141
|
+
npx dkk validate
|
|
142
|
+
```
|
|
261
143
|
|
|
262
|
-
|
|
144
|
+
The source code uses **vertical feature slices** — each feature (`query`, `adr`, `pipeline`, `agent`) owns its commands, logic, and tests. Cross-cutting infrastructure lives in `shared/`.
|
|
263
145
|
|
|
264
146
|
## License
|
|
265
147
|
|
package/dist/cli.js
CHANGED
|
@@ -8,6 +8,12 @@ import { registerValidate } from "./features/pipeline/commands/validate.js";
|
|
|
8
8
|
import { registerRender } from "./features/pipeline/commands/render.js";
|
|
9
9
|
import { registerAdrShow } from "./features/adr/commands/adr-show.js";
|
|
10
10
|
import { registerAdrRelated } from "./features/adr/commands/adr-related.js";
|
|
11
|
+
import { registerInit } from "./features/agent/commands/init.js";
|
|
12
|
+
import { registerPrime } from "./features/agent/commands/prime.js";
|
|
13
|
+
import { registerNewDomain } from "./features/scaffold/commands/new-domain.js";
|
|
14
|
+
import { registerNewContext } from "./features/scaffold/commands/new-context.js";
|
|
15
|
+
import { registerNewAdr } from "./features/scaffold/commands/new-adr.js";
|
|
16
|
+
import { registerAddItem } from "./features/scaffold/commands/add-item.js";
|
|
11
17
|
import { formatCliError } from "./shared/errors.js";
|
|
12
18
|
/** Whether to show full stack traces (set DEBUG=1 in env). */
|
|
13
19
|
const DEBUG = Boolean(process.env.DEBUG);
|
|
@@ -24,12 +30,23 @@ registerSearch(program);
|
|
|
24
30
|
registerRelated(program);
|
|
25
31
|
registerValidate(program);
|
|
26
32
|
registerRender(program);
|
|
33
|
+
registerInit(program);
|
|
34
|
+
registerPrime(program);
|
|
27
35
|
// ADR sub-command group
|
|
28
36
|
const adrCmd = program
|
|
29
37
|
.command("adr")
|
|
30
38
|
.description("ADR-related commands");
|
|
31
39
|
registerAdrShow(adrCmd);
|
|
32
40
|
registerAdrRelated(adrCmd);
|
|
41
|
+
// "new" sub-command group
|
|
42
|
+
const newCmd = program
|
|
43
|
+
.command("new")
|
|
44
|
+
.description("Scaffold new domain structures");
|
|
45
|
+
registerNewDomain(newCmd);
|
|
46
|
+
registerNewContext(newCmd);
|
|
47
|
+
registerNewAdr(newCmd);
|
|
48
|
+
// Top-level "add" command for individual domain items
|
|
49
|
+
registerAddItem(program);
|
|
33
50
|
program.parseAsync().catch((err) => {
|
|
34
51
|
console.error(`Error: ${formatCliError(err)}`);
|
|
35
52
|
if (DEBUG && err instanceof Error && err.stack) {
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEpD,8DAA8D;AAC9D,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAEzC,yEAAyE;AAEzE,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,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,YAAY,KAAK,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;QAC/C,OAAO,CAAC,KAAK,CAAC,mBAAmB,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `dkk init` command — create or update AGENTS.md with a DKK section.
|
|
3
|
+
*
|
|
4
|
+
* Inserts a Domain Knowledge Kit section delimited by HTML comment markers.
|
|
5
|
+
* Idempotent: replaces the section between markers on re-run, appends if
|
|
6
|
+
* markers are absent, creates the file if it does not exist.
|
|
7
|
+
*/
|
|
8
|
+
import type { Command as Cmd } from "commander";
|
|
9
|
+
/** Register the `init` subcommand. */
|
|
10
|
+
export declare function registerInit(program: Cmd): void;
|
|
11
|
+
//# sourceMappingURL=init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../../src/features/agent/commands/init.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,WAAW,CAAC;AA8ChD,sCAAsC;AACtC,wBAAgB,YAAY,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI,CAmC/C"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync, existsSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { repoRoot } from "../../../shared/paths.js";
|
|
4
|
+
const START_MARKER = "<!-- dkk:start -->";
|
|
5
|
+
const END_MARKER = "<!-- dkk:end -->";
|
|
6
|
+
/** The DKK section content (without markers). */
|
|
7
|
+
function dkkSection() {
|
|
8
|
+
return `
|
|
9
|
+
## Domain Knowledge Kit
|
|
10
|
+
|
|
11
|
+
This project uses a structured, YAML-based domain model managed by **dkk** (Domain Knowledge Kit).
|
|
12
|
+
|
|
13
|
+
Run \`dkk prime\` to get full agent context including domain structure, CLI commands, and workflows.
|
|
14
|
+
|
|
15
|
+
### Quick Reference
|
|
16
|
+
|
|
17
|
+
\`\`\`bash
|
|
18
|
+
dkk prime # Output full agent context
|
|
19
|
+
dkk list # List all domain items
|
|
20
|
+
dkk show <id> # Display a domain item
|
|
21
|
+
dkk search "<query>" # Full-text search
|
|
22
|
+
dkk related <id> # Graph traversal of related items
|
|
23
|
+
dkk validate # Schema + cross-reference validation
|
|
24
|
+
dkk render # Validate, render docs, rebuild search index
|
|
25
|
+
\`\`\`
|
|
26
|
+
|
|
27
|
+
### Quality Gates
|
|
28
|
+
|
|
29
|
+
Before committing domain changes, run:
|
|
30
|
+
|
|
31
|
+
\`\`\`bash
|
|
32
|
+
dkk render # Validates → renders docs → rebuilds search index
|
|
33
|
+
\`\`\`
|
|
34
|
+
|
|
35
|
+
\`dkk validate\` is available as a quick dry-run check (no rendering).
|
|
36
|
+
`.trimStart();
|
|
37
|
+
}
|
|
38
|
+
/** Build the full delimited block. */
|
|
39
|
+
function delimitedSection() {
|
|
40
|
+
return `${START_MARKER}\n${dkkSection()}${END_MARKER}\n`;
|
|
41
|
+
}
|
|
42
|
+
/** Register the `init` subcommand. */
|
|
43
|
+
export function registerInit(program) {
|
|
44
|
+
program
|
|
45
|
+
.command("init")
|
|
46
|
+
.description("Create or update AGENTS.md with DKK onboarding section")
|
|
47
|
+
.option("-r, --root <path>", "Override repository root")
|
|
48
|
+
.action((opts) => {
|
|
49
|
+
const root = repoRoot(opts.root);
|
|
50
|
+
const agentsPath = join(root, "AGENTS.md");
|
|
51
|
+
const section = delimitedSection();
|
|
52
|
+
if (!existsSync(agentsPath)) {
|
|
53
|
+
// Create new file with the DKK section
|
|
54
|
+
writeFileSync(agentsPath, `# Agent Instructions\n\n${section}`, "utf-8");
|
|
55
|
+
console.log(`Created ${agentsPath}`);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const existing = readFileSync(agentsPath, "utf-8");
|
|
59
|
+
const startIdx = existing.indexOf(START_MARKER);
|
|
60
|
+
const endIdx = existing.indexOf(END_MARKER);
|
|
61
|
+
if (startIdx !== -1 && endIdx !== -1 && endIdx > startIdx) {
|
|
62
|
+
// Replace existing section between markers (include trailing newline if present)
|
|
63
|
+
const markerEnd = endIdx + END_MARKER.length;
|
|
64
|
+
const before = existing.slice(0, startIdx);
|
|
65
|
+
const after = existing.slice(existing[markerEnd] === "\n" ? markerEnd + 1 : markerEnd);
|
|
66
|
+
writeFileSync(agentsPath, `${before}${section}${after}`, "utf-8");
|
|
67
|
+
console.log(`Updated DKK section in ${agentsPath}`);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
// Append section at the end
|
|
71
|
+
const separator = existing.endsWith("\n") ? "\n" : "\n\n";
|
|
72
|
+
writeFileSync(agentsPath, `${existing}${separator}${section}`, "utf-8");
|
|
73
|
+
console.log(`Appended DKK section to ${agentsPath}`);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../../src/features/agent/commands/init.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,MAAM,YAAY,GAAG,oBAAoB,CAAC;AAC1C,MAAM,UAAU,GAAG,kBAAkB,CAAC;AAEtC,iDAAiD;AACjD,SAAS,UAAU;IACjB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BR,CAAC,SAAS,EAAE,CAAC;AACd,CAAC;AAED,sCAAsC;AACtC,SAAS,gBAAgB;IACvB,OAAO,GAAG,YAAY,KAAK,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AC,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;YACvF,aAAa,CAAC,UAAU,EAAE,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,EAAE,EAAE,OAAO,CAAC,CAAC;YAClE,OAAO,CAAC,GAAG,CAAC,0BAA0B,UAAU,EAAE,CAAC,CAAC;QACtD,CAAC;aAAM,CAAC;YACN,4BAA4B;YAC5B,MAAM,SAAS,GAAG,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;YAC1D,aAAa,CAAC,UAAU,EAAE,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,EAAE,EAAE,OAAO,CAAC,CAAC;YACxE,OAAO,CAAC,GAAG,CAAC,2BAA2B,UAAU,EAAE,CAAC,CAAC;QACvD,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `dkk prime` command — output full agent context to stdout.
|
|
3
|
+
*
|
|
4
|
+
* Prints a comprehensive DKK usage guide for AI agent consumption,
|
|
5
|
+
* followed by a dynamic "Current Domain Summary" section generated
|
|
6
|
+
* from the live domain model on disk.
|
|
7
|
+
*
|
|
8
|
+
* Hardcoded template covering project overview, core principles,
|
|
9
|
+
* domain structure, retrieval workflow, change workflow, ID conventions,
|
|
10
|
+
* CLI reference, and file conventions.
|
|
11
|
+
*/
|
|
12
|
+
import type { Command as Cmd } from "commander";
|
|
13
|
+
/** Register the `prime` subcommand. */
|
|
14
|
+
export declare function registerPrime(program: Cmd): void;
|
|
15
|
+
//# sourceMappingURL=prime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prime.d.ts","sourceRoot":"","sources":["../../../../src/features/agent/commands/prime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,WAAW,CAAC;AA8ahD,uCAAuC;AACvC,wBAAgB,aAAa,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI,CAYhD"}
|