domain-knowledge-kit 0.2.14 → 0.2.16
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/.github/skills/{flow-implementer → dkk-flow-implementer}/skill.md +17 -8
- package/.github/skills/{story-analyst → dkk-story-analyst}/skill.md +23 -13
- package/README.md +5 -0
- package/dist/cli.js +20 -0
- package/dist/cli.js.map +1 -1
- package/dist/features/agent/commands/init.d.ts.map +1 -1
- package/dist/features/agent/commands/init.js +141 -3
- package/dist/features/agent/commands/init.js.map +1 -1
- package/dist/features/agent/commands/prime.d.ts +11 -0
- package/dist/features/agent/commands/prime.d.ts.map +1 -1
- package/dist/features/agent/commands/prime.js +122 -10
- package/dist/features/agent/commands/prime.js.map +1 -1
- package/dist/features/federation/commands/consumers.d.ts +40 -0
- package/dist/features/federation/commands/consumers.d.ts.map +1 -0
- package/dist/features/federation/commands/consumers.js +126 -0
- package/dist/features/federation/commands/consumers.js.map +1 -0
- package/dist/features/federation/commands/peers-add.d.ts +14 -0
- package/dist/features/federation/commands/peers-add.d.ts.map +1 -0
- package/dist/features/federation/commands/peers-add.js +79 -0
- package/dist/features/federation/commands/peers-add.js.map +1 -0
- package/dist/features/federation/commands/peers-list.d.ts +8 -0
- package/dist/features/federation/commands/peers-list.d.ts.map +1 -0
- package/dist/features/federation/commands/peers-list.js +51 -0
- package/dist/features/federation/commands/peers-list.js.map +1 -0
- package/dist/features/federation/commands/peers-status.d.ts +8 -0
- package/dist/features/federation/commands/peers-status.d.ts.map +1 -0
- package/dist/features/federation/commands/peers-status.js +78 -0
- package/dist/features/federation/commands/peers-status.js.map +1 -0
- package/dist/features/federation/commands/pull.d.ts +18 -0
- package/dist/features/federation/commands/pull.d.ts.map +1 -0
- package/dist/features/federation/commands/pull.js +153 -0
- package/dist/features/federation/commands/pull.js.map +1 -0
- package/dist/features/federation/git-fetcher.d.ts +45 -0
- package/dist/features/federation/git-fetcher.d.ts.map +1 -0
- package/dist/features/federation/git-fetcher.js +70 -0
- package/dist/features/federation/git-fetcher.js.map +1 -0
- package/dist/features/federation/loader.d.ts +60 -0
- package/dist/features/federation/loader.d.ts.map +1 -0
- package/dist/features/federation/loader.js +193 -0
- package/dist/features/federation/loader.js.map +1 -0
- package/dist/features/federation/lock.d.ts +12 -0
- package/dist/features/federation/lock.d.ts.map +1 -0
- package/dist/features/federation/lock.js +48 -0
- package/dist/features/federation/lock.js.map +1 -0
- package/dist/features/federation/tests/git-fetcher.test.d.ts +2 -0
- package/dist/features/federation/tests/git-fetcher.test.d.ts.map +1 -0
- package/dist/features/federation/tests/git-fetcher.test.js +167 -0
- package/dist/features/federation/tests/git-fetcher.test.js.map +1 -0
- package/dist/features/federation/tests/loader.test.d.ts +2 -0
- package/dist/features/federation/tests/loader.test.d.ts.map +1 -0
- package/dist/features/federation/tests/loader.test.js +144 -0
- package/dist/features/federation/tests/loader.test.js.map +1 -0
- package/dist/features/federation/tests/phase5.test.d.ts +2 -0
- package/dist/features/federation/tests/phase5.test.d.ts.map +1 -0
- package/dist/features/federation/tests/phase5.test.js +137 -0
- package/dist/features/federation/tests/phase5.test.js.map +1 -0
- package/dist/features/federation/tests/schema-load.test.d.ts +2 -0
- package/dist/features/federation/tests/schema-load.test.d.ts.map +1 -0
- package/dist/features/federation/tests/schema-load.test.js +97 -0
- package/dist/features/federation/tests/schema-load.test.js.map +1 -0
- package/dist/features/federation/tests/validator.test.d.ts +2 -0
- package/dist/features/federation/tests/validator.test.d.ts.map +1 -0
- package/dist/features/federation/tests/validator.test.js +319 -0
- package/dist/features/federation/tests/validator.test.js.map +1 -0
- package/dist/features/mcp/commands/serve.d.ts +10 -0
- package/dist/features/mcp/commands/serve.d.ts.map +1 -0
- package/dist/features/mcp/commands/serve.js +12 -0
- package/dist/features/mcp/commands/serve.js.map +1 -0
- package/dist/features/mcp/server.d.ts +15 -0
- package/dist/features/mcp/server.d.ts.map +1 -0
- package/dist/features/mcp/server.js +438 -0
- package/dist/features/mcp/server.js.map +1 -0
- package/dist/features/pipeline/commands/validate.d.ts.map +1 -1
- package/dist/features/pipeline/commands/validate.js +7 -0
- package/dist/features/pipeline/commands/validate.js.map +1 -1
- package/dist/features/pipeline/indexer.d.ts +28 -2
- package/dist/features/pipeline/indexer.d.ts.map +1 -1
- package/dist/features/pipeline/indexer.js +84 -29
- package/dist/features/pipeline/indexer.js.map +1 -1
- package/dist/features/pipeline/validator.d.ts +10 -0
- package/dist/features/pipeline/validator.d.ts.map +1 -1
- package/dist/features/pipeline/validator.js +274 -27
- package/dist/features/pipeline/validator.js.map +1 -1
- package/dist/features/query/commands/list.d.ts +10 -0
- package/dist/features/query/commands/list.d.ts.map +1 -1
- package/dist/features/query/commands/list.js +1 -1
- package/dist/features/query/commands/list.js.map +1 -1
- package/dist/features/query/commands/locate.d.ts +1 -0
- package/dist/features/query/commands/locate.d.ts.map +1 -1
- package/dist/features/query/commands/locate.js +1 -1
- package/dist/features/query/commands/locate.js.map +1 -1
- package/dist/features/query/commands/search.d.ts.map +1 -1
- package/dist/features/query/commands/search.js +2 -0
- package/dist/features/query/commands/search.js.map +1 -1
- package/dist/features/query/commands/show.d.ts +15 -0
- package/dist/features/query/commands/show.d.ts.map +1 -1
- package/dist/features/query/commands/show.js +116 -58
- package/dist/features/query/commands/show.js.map +1 -1
- package/dist/features/query/commands/story.d.ts +70 -0
- package/dist/features/query/commands/story.d.ts.map +1 -1
- package/dist/features/query/commands/story.js +3 -2
- package/dist/features/query/commands/story.js.map +1 -1
- package/dist/features/query/commands/summary.d.ts +3 -0
- package/dist/features/query/commands/summary.d.ts.map +1 -1
- package/dist/features/query/commands/summary.js +1 -1
- package/dist/features/query/commands/summary.js.map +1 -1
- package/dist/features/query/searcher.d.ts +18 -1
- package/dist/features/query/searcher.d.ts.map +1 -1
- package/dist/features/query/searcher.js +11 -2
- package/dist/features/query/searcher.js.map +1 -1
- package/dist/features/scaffold/commands/service-init.d.ts +12 -0
- package/dist/features/scaffold/commands/service-init.d.ts.map +1 -0
- package/dist/features/scaffold/commands/service-init.js +69 -0
- package/dist/features/scaffold/commands/service-init.js.map +1 -0
- package/dist/shared/graph.d.ts +8 -0
- package/dist/shared/graph.d.ts.map +1 -1
- package/dist/shared/graph.js +180 -112
- package/dist/shared/graph.js.map +1 -1
- package/dist/shared/index.d.ts +4 -1
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index.js +6 -1
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/loader.d.ts +22 -0
- package/dist/shared/loader.d.ts.map +1 -1
- package/dist/shared/loader.js +31 -1
- package/dist/shared/loader.js.map +1 -1
- package/dist/shared/paths.d.ts +59 -7
- package/dist/shared/paths.d.ts.map +1 -1
- package/dist/shared/paths.js +93 -11
- package/dist/shared/paths.js.map +1 -1
- package/dist/shared/refs.d.ts +96 -0
- package/dist/shared/refs.d.ts.map +1 -0
- package/dist/shared/refs.js +182 -0
- package/dist/shared/refs.js.map +1 -0
- package/dist/shared/service-id.d.ts +11 -0
- package/dist/shared/service-id.d.ts.map +1 -0
- package/dist/shared/service-id.js +64 -0
- package/dist/shared/service-id.js.map +1 -0
- package/dist/shared/tests/paths.test.d.ts +2 -0
- package/dist/shared/tests/paths.test.d.ts.map +1 -0
- package/dist/shared/tests/paths.test.js +111 -0
- package/dist/shared/tests/paths.test.js.map +1 -0
- package/dist/shared/tests/refs.test.d.ts +2 -0
- package/dist/shared/tests/refs.test.d.ts.map +1 -0
- package/dist/shared/tests/refs.test.js +104 -0
- package/dist/shared/tests/refs.test.js.map +1 -0
- package/dist/shared/types/domain.d.ts +20 -0
- package/dist/shared/types/domain.d.ts.map +1 -1
- package/dist/shared/types/federation.d.ts +60 -0
- package/dist/shared/types/federation.d.ts.map +1 -0
- package/dist/shared/types/federation.js +12 -0
- package/dist/shared/types/federation.js.map +1 -0
- package/package.json +6 -3
- package/tools/dkk/claude/agents/dkk-domain-reviewer.md +69 -0
- package/tools/dkk/claude/commands/dkk-adr.md +11 -0
- package/tools/dkk/claude/commands/dkk-impact.md +34 -0
- package/tools/dkk/claude/commands/dkk-implement.md +12 -0
- package/tools/dkk/claude/commands/dkk-prime.md +6 -0
- package/tools/dkk/claude/commands/dkk-review.md +12 -0
- package/tools/dkk/claude/commands/dkk-story.md +12 -0
- package/tools/dkk/claude/hooks/post-edit-validate.mjs +51 -0
- package/tools/dkk/claude/hooks/pre-edit-block-generated.mjs +39 -0
- package/tools/dkk/claude/hooks/session-start-prime.mjs +33 -0
- package/tools/dkk/claude/hooks/stop-validate.mjs +48 -0
- package/tools/dkk/claude/settings.json +62 -0
- package/tools/dkk/claude/skills/dkk-adr-author/SKILL.md +54 -0
- package/tools/dkk/claude/skills/dkk-flow-implementer/SKILL.md +51 -0
- package/tools/dkk/claude/skills/dkk-story-analyst/SKILL.md +108 -0
- package/tools/dkk/schema/actors.schema.json +11 -1
- package/tools/dkk/schema/adr-frontmatter.schema.json +4 -4
- package/tools/dkk/schema/aggregate.schema.json +1 -1
- package/tools/dkk/schema/command.schema.json +1 -1
- package/tools/dkk/schema/event.schema.json +1 -1
- package/tools/dkk/schema/federation.schema.json +71 -0
- package/tools/dkk/schema/glossary.schema.json +1 -1
- package/tools/dkk/schema/index.schema.json +2 -2
- package/tools/dkk/schema/policy.schema.json +1 -1
- package/tools/dkk/schema/read-model.schema.json +15 -1
- package/tools/dkk/schema/service.schema.json +30 -0
- package/.github/skills/domain-knowledge/skill.md +0 -93
|
@@ -6,13 +6,15 @@ import { domainDir } from "../../../shared/paths.js";
|
|
|
6
6
|
* The full agent context document.
|
|
7
7
|
* Keep the CLI Command Reference tables in sync with the Quick Reference block in init.ts#dkkSection.
|
|
8
8
|
*/
|
|
9
|
-
function primeContent() {
|
|
9
|
+
export function primeContent() {
|
|
10
10
|
return `# Domain Knowledge Kit — Agent Context
|
|
11
11
|
|
|
12
12
|
## Project Overview
|
|
13
13
|
|
|
14
14
|
This project uses a **Domain Knowledge Pack**: a structured, YAML-based domain model with Architecture Decision Records (ADRs), full-text search, and generated Markdown documentation. The CLI tool is \`dkk\`.
|
|
15
15
|
|
|
16
|
+
DKK supports **multi-repo federation**: when a \`.dkk/service.yml\` exists, the repo declares itself a service, and a \`.dkk/federation.yml\` can list peer services (other repos, by local path or git URL). The loader transparently merges peer domain models so that queries, search, graph traversal, validation, and \`dkk consumers\` span every loaded peer. Cross-service references use the additive grammar \`<service>:<context>.<Item>\` — bare refs stay local-only.
|
|
17
|
+
|
|
16
18
|
## Core Principles
|
|
17
19
|
|
|
18
20
|
1. **Domain YAML is the single source of truth.** Never generate domain knowledge from code.
|
|
@@ -26,6 +28,11 @@ This project uses a **Domain Knowledge Pack**: a structured, YAML-based domain m
|
|
|
26
28
|
|
|
27
29
|
\`\`\`
|
|
28
30
|
.dkk/
|
|
31
|
+
service.yml # OPTIONAL: declares this repo as a federated service
|
|
32
|
+
# { name: kebab-case, exports: [<ctx-name>, ...] }
|
|
33
|
+
federation.yml # OPTIONAL: lists peer services (local path or git URL+branch)
|
|
34
|
+
federation.lock.json # AUTO: pins resolved git-source commit SHAs
|
|
35
|
+
imports/ # AUTO (gitignored): cached peer .dkk/ trees from \`dkk pull\`
|
|
29
36
|
domain/
|
|
30
37
|
index.yml # Top-level: registered contexts + cross-context flows
|
|
31
38
|
actors.yml # Global actors (human | system | external)
|
|
@@ -49,9 +56,9 @@ This project uses a **Domain Knowledge Pack**: a structured, YAML-based domain m
|
|
|
49
56
|
| **Command** | An instruction to change state | \`name\`, \`description\`, \`fields\`, \`actor\`, \`handled_by\`, \`adr_refs\` |
|
|
50
57
|
| **Policy** | Reactive logic triggered by events | \`name\`, \`description\`, \`when\`, \`then\`, \`adr_refs\` |
|
|
51
58
|
| **Aggregate** | Consistency boundary handling commands | \`name\`, \`description\`, \`handles\`, \`emits\`, \`adr_refs\` |
|
|
52
|
-
| **Read Model** | Query-optimized projection | \`name\`, \`description\`, \`subscribes_to\`, \`used_by\`, \`adr_refs\` |
|
|
59
|
+
| **Read Model** | Query-optimized projection | \`name\`, \`description\`, \`fields\`, \`subscribes_to\`, \`used_by\`, \`adr_refs\` |
|
|
53
60
|
| **Glossary** | Ubiquitous language term | \`term\`, \`definition\`, \`aliases\`, \`adr_refs\` |
|
|
54
|
-
| **Actor** | Person or system interacting with the domain | \`name\`, \`type\` (human/system/external), \`description\`, \`adr_refs\` |
|
|
61
|
+
| **Actor** | Person or system interacting with the domain | \`name\`, \`type\` (human/system/external), \`description\`, \`capabilities\`, \`failure_modes\`, \`adr_refs\` |
|
|
55
62
|
| **Flow** | Cross-context sequence of steps | \`name\`, \`description\`, \`steps[]\` |
|
|
56
63
|
|
|
57
64
|
## ID Conventions
|
|
@@ -64,6 +71,18 @@ This project uses a **Domain Knowledge Pack**: a structured, YAML-based domain m
|
|
|
64
71
|
| Flow | \`flow.<Name>\` | \`flow.OrderFulfillment\` |
|
|
65
72
|
| Context | \`context.<name>\` | \`context.ordering\` |
|
|
66
73
|
|
|
74
|
+
**Federated form** (cross-repo references): prefix any id with \`<service>:\`.
|
|
75
|
+
|
|
76
|
+
| Federated Form | Example |
|
|
77
|
+
|------------------------------------------------|----------------------------------------|
|
|
78
|
+
| \`<service>:<context>.<ItemName>\` | \`ordering:ordering.OrderPlaced\` |
|
|
79
|
+
| \`<service>:actor.<Name>\` | \`payments:actor.PaymentGateway\` |
|
|
80
|
+
| \`<service>:adr-NNNN\` | \`ordering:adr-0007\` |
|
|
81
|
+
| \`<service>:flow.<Name>\` | \`ordering:flow.OrderFulfillment\` |
|
|
82
|
+
| \`<service>:context.<name>\` | \`ordering:context.ordering\` |
|
|
83
|
+
|
|
84
|
+
Bare ids resolve only against the local repo. Service-prefixed ids resolve against \`model.peers.get(<service>)\`. A self-prefix (\`<localService>:<id>\`) is treated as local. Use the fully-qualified form (\`<service>:<context>.<Name>\`) when writing cross-service refs in YAML — the name-only shorthand is reserved for \`dkk show\`.
|
|
85
|
+
|
|
67
86
|
## CLI Command Reference
|
|
68
87
|
|
|
69
88
|
### Query
|
|
@@ -115,10 +134,29 @@ This project uses a **Domain Knowledge Pack**: a structured, YAML-based domain m
|
|
|
115
134
|
|
|
116
135
|
### Agent
|
|
117
136
|
|
|
118
|
-
| Command
|
|
119
|
-
|
|
120
|
-
| \`dkk init\`
|
|
121
|
-
| \`dkk
|
|
137
|
+
| Command | Purpose |
|
|
138
|
+
|------------------------|------------------------------------------------------|
|
|
139
|
+
| \`dkk init\` | Create/update AGENTS.md with DKK section |
|
|
140
|
+
| \`dkk init --skills\` | Also install agent skills into \`.github/skills/\` |
|
|
141
|
+
| \`dkk init --claude\` | Also scaffold \`.claude/\` (settings, hooks, skills, agents, commands) |
|
|
142
|
+
| \`dkk prime\` | Output this agent context to stdout |
|
|
143
|
+
| \`dkk mcp\` | Run the DKK MCP server over stdio |
|
|
144
|
+
|
|
145
|
+
### Federation
|
|
146
|
+
|
|
147
|
+
| Command | Purpose |
|
|
148
|
+
|----------------------------------------------------|------------------------------------------------------|
|
|
149
|
+
| \`dkk service init --name <n> --export <ctx>\` | Declare this repo a federated service (writes \`.dkk/service.yml\`) |
|
|
150
|
+
| \`dkk peers add <name> --local <path>\` | Register a peer by filesystem path |
|
|
151
|
+
| \`dkk peers add <name> --git <url> --branch <b>\` | Register a peer by git URL + branch |
|
|
152
|
+
| \`dkk peers list\` | List configured peers + reachability state |
|
|
153
|
+
| \`dkk peers status\` | Detailed peer status: service id, exports, contexts |
|
|
154
|
+
| \`dkk pull [name]\` | Sparse-checkout git peers into \`.dkk/imports/\` |
|
|
155
|
+
| \`dkk pull --refresh\` | Re-fetch even when cache exists |
|
|
156
|
+
| \`dkk pull --offline\` | Use cache only; no network |
|
|
157
|
+
| \`dkk consumers <id>\` | Reverse-lookup: which peers reference this item |
|
|
158
|
+
| \`dkk validate --federation strict\` | Promote unreachable-peer warnings to errors (CI gate) |
|
|
159
|
+
| \`dkk search --service <n>\` | Narrow search to one service (local or peer) |
|
|
122
160
|
|
|
123
161
|
## Domain Search Workflow
|
|
124
162
|
|
|
@@ -260,6 +298,13 @@ emits:
|
|
|
260
298
|
\`\`\`yaml
|
|
261
299
|
name: OrderSummary
|
|
262
300
|
description: Read-optimized view of order details.
|
|
301
|
+
fields:
|
|
302
|
+
- name: orderId
|
|
303
|
+
type: UUID
|
|
304
|
+
- name: status
|
|
305
|
+
type: string
|
|
306
|
+
- name: totalAmount
|
|
307
|
+
type: Money
|
|
263
308
|
subscribes_to:
|
|
264
309
|
- OrderPlaced
|
|
265
310
|
used_by:
|
|
@@ -273,6 +318,15 @@ actors:
|
|
|
273
318
|
- name: Customer
|
|
274
319
|
type: human
|
|
275
320
|
description: End user who places and tracks orders.
|
|
321
|
+
- name: PaymentGateway
|
|
322
|
+
type: external
|
|
323
|
+
description: Third-party payment processor.
|
|
324
|
+
capabilities:
|
|
325
|
+
- Authorize payments
|
|
326
|
+
- Issue refunds
|
|
327
|
+
failure_modes:
|
|
328
|
+
- Gateway timeout
|
|
329
|
+
- Card declined
|
|
276
330
|
\`\`\`
|
|
277
331
|
|
|
278
332
|
**Index file** (\`.dkk/domain/index.yml\`):
|
|
@@ -319,13 +373,49 @@ When reviewing changes for domain impact:
|
|
|
319
373
|
\`\`\`
|
|
320
374
|
7. **Compile impact analysis** — Report impacted items, blast radius, invariant violations, affected ADRs, and recommendations.
|
|
321
375
|
|
|
376
|
+
## Federation Workflow
|
|
377
|
+
|
|
378
|
+
When the local repo has a \`.dkk/federation.yml\`, the loader hydrates every reachable peer's domain into \`model.peers\`. Reading commands (\`dkk show\`, \`dkk search\`, \`dkk related\`, \`dkk graph\`) and the MCP server transparently span peers.
|
|
379
|
+
|
|
380
|
+
1. **Inspect peer state**:
|
|
381
|
+
\`\`\`bash
|
|
382
|
+
dkk peers list # quick overview
|
|
383
|
+
dkk peers status # exports + contexts per peer
|
|
384
|
+
\`\`\`
|
|
385
|
+
2. **Reference a peer item** — when authoring a local policy, ADR, or flow that consumes something across the boundary, use the fully-qualified form:
|
|
386
|
+
\`\`\`yaml
|
|
387
|
+
when:
|
|
388
|
+
events:
|
|
389
|
+
- ordering:ordering.OrderPlaced # peer service "ordering", context "ordering", item "OrderPlaced"
|
|
390
|
+
\`\`\`
|
|
391
|
+
3. **Inspect a peer item directly**:
|
|
392
|
+
\`\`\`bash
|
|
393
|
+
dkk show ordering:OrderPlaced # shorthand (single-export service)
|
|
394
|
+
dkk show ordering:ordering.OrderPlaced # fully qualified
|
|
395
|
+
\`\`\`
|
|
396
|
+
4. **Find downstream consumers of a local item** before renaming/deprecating:
|
|
397
|
+
\`\`\`bash
|
|
398
|
+
dkk consumers ordering.OrderPlaced
|
|
399
|
+
\`\`\`
|
|
400
|
+
5. **Refresh git-source peers** when needed:
|
|
401
|
+
\`\`\`bash
|
|
402
|
+
dkk pull ordering # fetch (no-op if SHA matches the lockfile)
|
|
403
|
+
dkk pull ordering --refresh # force re-fetch
|
|
404
|
+
\`\`\`
|
|
405
|
+
|
|
406
|
+
**Reference resolution rules:**
|
|
407
|
+
- A **bare** ref (\`OrderPlaced\`, \`ordering.OrderPlaced\`) resolves only against the local repo's items. Never falls through to peers — collisions are silent data corruption.
|
|
408
|
+
- A **service-prefixed** ref (\`ordering:ordering.OrderPlaced\`) resolves only against \`model.peers.get(<service>)\`. If the service equals the local service name, it's treated as a local ref (self-prefix is harmless).
|
|
409
|
+
- An **unreachable peer** produces a warning by default. CI gates that must guarantee resolution should run \`dkk validate --federation strict\`.
|
|
410
|
+
|
|
322
411
|
## Validation
|
|
323
412
|
|
|
324
413
|
The validator checks:
|
|
325
414
|
|
|
326
|
-
- **Schema conformance** — Each YAML file is validated against its JSON Schema.
|
|
327
|
-
- **Cross-references** — All item-to-item, item-to-ADR, and ADR-to-item references resolve correctly.
|
|
415
|
+
- **Schema conformance** — Each YAML file is validated against its JSON Schema. \`.dkk/service.yml\` and \`.dkk/federation.yml\` are validated at load time.
|
|
416
|
+
- **Cross-references** — All item-to-item, item-to-ADR, and ADR-to-item references resolve correctly, including federated forms.
|
|
328
417
|
- **Context registration** — Every context directory in \`.dkk/domain/contexts/\` is registered in \`.dkk/domain/index.yml\`.
|
|
418
|
+
- **Federation strictness** (\`--federation strict\`): unreachable peers escalate from warnings to errors; refs to non-exported peer contexts always warn.
|
|
329
419
|
|
|
330
420
|
## Generated Documentation
|
|
331
421
|
|
|
@@ -352,7 +442,7 @@ Do not edit files under \`.dkk/docs/\` by hand; they are regenerated on each ren
|
|
|
352
442
|
* model on disk. Returns the Markdown string to append after the static
|
|
353
443
|
* instructions.
|
|
354
444
|
*/
|
|
355
|
-
function buildDomainSummary(root) {
|
|
445
|
+
export function buildDomainSummary(root) {
|
|
356
446
|
// If there's no .dkk/domain/ directory at all, short-circuit.
|
|
357
447
|
if (!existsSync(domainDir(root))) {
|
|
358
448
|
return ("\n## Current Domain Summary\n\n" +
|
|
@@ -392,6 +482,28 @@ function buildDomainSummary(root) {
|
|
|
392
482
|
`**${totalItems}** domain item(s), ` +
|
|
393
483
|
`**${model.actors.length}** actor(s), ` +
|
|
394
484
|
`**${model.adrs.size}** ADR(s)\n`);
|
|
485
|
+
// ── Service identity & peers (federation) ────────────────────────
|
|
486
|
+
if (model.service) {
|
|
487
|
+
lines.push(`### Service Identity\n`);
|
|
488
|
+
lines.push(`- **name:** \`${model.service.name}\``);
|
|
489
|
+
lines.push(`- **exports:** ${model.service.exports.map((e) => `\`${e}\``).join(", ") || "(none)"}`);
|
|
490
|
+
if (model.service.description) {
|
|
491
|
+
lines.push(`- **description:** ${model.service.description}`);
|
|
492
|
+
}
|
|
493
|
+
lines.push("");
|
|
494
|
+
}
|
|
495
|
+
if (model.peers && model.peers.size > 0) {
|
|
496
|
+
lines.push(`### Federated Peers (${model.peers.size})\n`);
|
|
497
|
+
for (const [peerName, peerModel] of model.peers) {
|
|
498
|
+
const peerExports = peerModel.service?.exports ?? [];
|
|
499
|
+
const peerCtxCount = peerModel.contexts.size;
|
|
500
|
+
const exportsStr = peerExports.length ? peerExports.map((e) => `\`${e}\``).join(", ") : "(none declared)";
|
|
501
|
+
lines.push(`- **${peerName}**: ${peerCtxCount} context(s), exports: ${exportsStr}`);
|
|
502
|
+
}
|
|
503
|
+
lines.push("");
|
|
504
|
+
lines.push("Reference any peer item as \`<service>:<context>.<Name>\` (e.g. \`ordering:ordering.OrderPlaced\`).");
|
|
505
|
+
lines.push("");
|
|
506
|
+
}
|
|
395
507
|
// ── Contexts detail ──────────────────────────────────────────────
|
|
396
508
|
if (model.contexts.size > 0) {
|
|
397
509
|
lines.push("### Contexts\n");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prime.js","sourceRoot":"","sources":["../../../../src/features/agent/commands/prime.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAiB,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAGrD;;;GAGG;AACH,
|
|
1
|
+
{"version":3,"file":"prime.js","sourceRoot":"","sources":["../../../../src/features/agent/commands/prime.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAiB,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAGrD;;;GAGG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;YACtD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;YACtD,KAAK,CAAC,IAAI,CACR,OAAO,GAAG,IAAI,GAAG,CAAC,IAAI,gBAAgB,MAAM,cAAc,MAAM,GAAG,CACpE,CAAC;QACJ,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjB,CAAC;IAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,uCAAuC;AACvC,MAAM,UAAU,aAAa,CAAC,OAAY;IACxC,OAAO;SACJ,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,yCAAyC,CAAC;SACtD,MAAM,CAAC,mBAAmB,EAAE,0BAA0B,CAAC;SACvD,MAAM,CAAC,eAAe,EAAE,2DAA2D,CAAC;SACpF,MAAM,CAAC,CAAC,IAA6C,EAAE,EAAE;QACxD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC;QACrC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACtD,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `dkk consumers <id>` — reverse lookup across federated peers.
|
|
3
|
+
*
|
|
4
|
+
* Given a local item id (e.g. `ordering.OrderPlaced`), walk every
|
|
5
|
+
* loaded peer model and report references back to that item. This is
|
|
6
|
+
* the producer-side answer to "who breaks if I rename this?".
|
|
7
|
+
*
|
|
8
|
+
* The walk inspects the ref-bearing fields that the validator already
|
|
9
|
+
* understands: events.raised_by, commands.handled_by / actor,
|
|
10
|
+
* aggregates.handles / emits, policies.when / then, read_models.subscribes_to
|
|
11
|
+
* / used_by, ADR domain_refs / superseded_by, and flow step refs.
|
|
12
|
+
*
|
|
13
|
+
* Both fully-qualified peer refs (`<localService>:<ctx>.<Name>`) and
|
|
14
|
+
* the same-service bare form (when a peer happens to have a local
|
|
15
|
+
* service named the same as ours — rare) are matched.
|
|
16
|
+
*/
|
|
17
|
+
import type { Command as Cmd } from "commander";
|
|
18
|
+
import type { DomainModel } from "../../../shared/types/domain.js";
|
|
19
|
+
import "../loader.js";
|
|
20
|
+
interface ConsumerHit {
|
|
21
|
+
/** Peer service that references the queried item. */
|
|
22
|
+
service: string;
|
|
23
|
+
/** Reference path describing where in the peer model the match was found. */
|
|
24
|
+
source: string;
|
|
25
|
+
/** The relation kind (e.g. "when.events", "subscribes_to", "domain_refs"). */
|
|
26
|
+
relation: string;
|
|
27
|
+
/** The raw ref string as written in the peer's YAML. */
|
|
28
|
+
ref: string;
|
|
29
|
+
}
|
|
30
|
+
export declare function registerConsumers(program: Cmd): void;
|
|
31
|
+
/**
|
|
32
|
+
* Walk every loaded peer model and collect references back to the
|
|
33
|
+
* queried item. Matches both the fully-qualified peer form
|
|
34
|
+
* (`<localService>:<ctx>.<Name>`) and bare names — the latter handles
|
|
35
|
+
* the case where a peer references the same item via shorthand
|
|
36
|
+
* inside its own walk (uncommon, but possible).
|
|
37
|
+
*/
|
|
38
|
+
export declare function findConsumers(model: DomainModel, rawId: string, localService: string | undefined): ConsumerHit[];
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=consumers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consumers.d.ts","sourceRoot":"","sources":["../../../../src/features/federation/commands/consumers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,WAAW,CAAC;AAGhD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAGnE,OAAO,cAAc,CAAC;AAEtB,UAAU,WAAW;IACnB,qDAAqD;IACrD,OAAO,EAAE,MAAM,CAAC;IAChB,6EAA6E;IAC7E,MAAM,EAAE,MAAM,CAAC;IACf,8EAA8E;IAC9E,QAAQ,EAAE,MAAM,CAAC;IACjB,wDAAwD;IACxD,GAAG,EAAE,MAAM,CAAC;CACb;AAQD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI,CAkCpD;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,WAAW,EAClB,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,MAAM,GAAG,SAAS,GAC/B,WAAW,EAAE,CAmCf"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { loadDomainModel } from "../../../shared/loader.js";
|
|
2
|
+
import { parseRef } from "../../../shared/refs.js";
|
|
3
|
+
// Side-effect import: registers the peer-hydration hook with the
|
|
4
|
+
// shared loader so `loadDomainModel` populates `model.peers`.
|
|
5
|
+
import "../loader.js";
|
|
6
|
+
export function registerConsumers(program) {
|
|
7
|
+
program
|
|
8
|
+
.command("consumers <id>")
|
|
9
|
+
.description("List peers that reference this local item (reverse lookup across federation)")
|
|
10
|
+
.option("-r, --root <path>", "Override repository root")
|
|
11
|
+
.option("--json", "Output as JSON")
|
|
12
|
+
.option("--minify", "Minify JSON output")
|
|
13
|
+
.action((id, opts) => {
|
|
14
|
+
const model = loadDomainModel({ root: opts.root });
|
|
15
|
+
const localService = model.service?.name;
|
|
16
|
+
const hits = findConsumers(model, id, localService);
|
|
17
|
+
if (opts.json) {
|
|
18
|
+
console.log(JSON.stringify({ item: id, service: localService ?? null, consumers: hits }, null, opts.minify ? 0 : 2));
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (hits.length === 0) {
|
|
22
|
+
console.log(`No peer consumers of "${id}" found in ${model.peers?.size ?? 0} federated peer(s).`);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
console.log(`${hits.length} reference(s) to "${id}":`);
|
|
26
|
+
for (const h of hits) {
|
|
27
|
+
console.log(` ${h.service} ${h.source} [${h.relation}] → ${h.ref}`);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Walk every loaded peer model and collect references back to the
|
|
33
|
+
* queried item. Matches both the fully-qualified peer form
|
|
34
|
+
* (`<localService>:<ctx>.<Name>`) and bare names — the latter handles
|
|
35
|
+
* the case where a peer references the same item via shorthand
|
|
36
|
+
* inside its own walk (uncommon, but possible).
|
|
37
|
+
*/
|
|
38
|
+
export function findConsumers(model, rawId, localService) {
|
|
39
|
+
const hits = [];
|
|
40
|
+
if (!model.peers || model.peers.size === 0)
|
|
41
|
+
return hits;
|
|
42
|
+
const parsed = parseRef(rawId);
|
|
43
|
+
if (!parsed)
|
|
44
|
+
return hits;
|
|
45
|
+
// The forms a peer might use to reference our local item:
|
|
46
|
+
// - Full federated: `<localService>:<ctx>.<Name>` (or `:<ItemName>` shorthand)
|
|
47
|
+
// - Bare: only valid when peer happens to share our service name (rare)
|
|
48
|
+
// We pre-compute the candidate strings to match.
|
|
49
|
+
const matches = new Set();
|
|
50
|
+
if (parsed.kind === "item") {
|
|
51
|
+
if (localService) {
|
|
52
|
+
matches.add(`${localService}:${parsed.context}.${parsed.name}`);
|
|
53
|
+
matches.add(`${localService}:${parsed.name}`);
|
|
54
|
+
}
|
|
55
|
+
matches.add(`${parsed.context}.${parsed.name}`);
|
|
56
|
+
}
|
|
57
|
+
else if (parsed.kind === "adr") {
|
|
58
|
+
if (localService)
|
|
59
|
+
matches.add(`${localService}:${parsed.id}`);
|
|
60
|
+
matches.add(parsed.id);
|
|
61
|
+
}
|
|
62
|
+
else if (parsed.kind === "actor") {
|
|
63
|
+
if (localService)
|
|
64
|
+
matches.add(`${localService}:actor.${parsed.name}`);
|
|
65
|
+
matches.add(`actor.${parsed.name}`);
|
|
66
|
+
}
|
|
67
|
+
for (const [peerName, peerModel] of model.peers) {
|
|
68
|
+
walkRefs(peerModel, peerName, (relation, source, ref) => {
|
|
69
|
+
if (matches.has(ref)) {
|
|
70
|
+
hits.push({ service: peerName, source, relation, ref });
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return hits;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Visit every ref-bearing field in a model, invoking `visit` with
|
|
78
|
+
* (relation, source-path, raw-ref) per occurrence.
|
|
79
|
+
*
|
|
80
|
+
* Intentionally narrow — covers the validator's lookup sites so the
|
|
81
|
+
* reverse view stays consistent with the forward view.
|
|
82
|
+
*/
|
|
83
|
+
function walkRefs(model, modelName, visit) {
|
|
84
|
+
for (const [ctxName, ctx] of model.contexts) {
|
|
85
|
+
for (const e of ctx.events ?? []) {
|
|
86
|
+
if (e.raised_by)
|
|
87
|
+
visit("raised_by", `${modelName}:${ctxName}.${e.name}`, e.raised_by);
|
|
88
|
+
}
|
|
89
|
+
for (const c of ctx.commands ?? []) {
|
|
90
|
+
if (c.handled_by)
|
|
91
|
+
visit("handled_by", `${modelName}:${ctxName}.${c.name}`, c.handled_by);
|
|
92
|
+
if (c.actor)
|
|
93
|
+
visit("actor", `${modelName}:${ctxName}.${c.name}`, c.actor);
|
|
94
|
+
}
|
|
95
|
+
for (const a of ctx.aggregates ?? []) {
|
|
96
|
+
for (const h of a.handles?.commands ?? [])
|
|
97
|
+
visit("handles.commands", `${modelName}:${ctxName}.${a.name}`, h);
|
|
98
|
+
for (const ev of a.emits?.events ?? [])
|
|
99
|
+
visit("emits.events", `${modelName}:${ctxName}.${a.name}`, ev);
|
|
100
|
+
}
|
|
101
|
+
for (const p of ctx.policies ?? []) {
|
|
102
|
+
for (const t of p.when?.events ?? [])
|
|
103
|
+
visit("when.events", `${modelName}:${ctxName}.${p.name}`, t);
|
|
104
|
+
for (const t of p.then?.commands ?? [])
|
|
105
|
+
visit("then.commands", `${modelName}:${ctxName}.${p.name}`, t);
|
|
106
|
+
}
|
|
107
|
+
for (const r of ctx.read_models ?? []) {
|
|
108
|
+
for (const s of r.subscribes_to ?? [])
|
|
109
|
+
visit("subscribes_to", `${modelName}:${ctxName}.${r.name}`, s);
|
|
110
|
+
for (const u of r.used_by ?? [])
|
|
111
|
+
visit("used_by", `${modelName}:${ctxName}.${r.name}`, u);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
for (const [adrId, adr] of model.adrs) {
|
|
115
|
+
for (const ref of adr.domain_refs ?? [])
|
|
116
|
+
visit("domain_refs", `${modelName}:${adrId}`, ref);
|
|
117
|
+
if (adr.superseded_by)
|
|
118
|
+
visit("superseded_by", `${modelName}:${adrId}`, adr.superseded_by);
|
|
119
|
+
}
|
|
120
|
+
for (const flow of model.index.flows ?? []) {
|
|
121
|
+
for (const step of flow.steps) {
|
|
122
|
+
visit("flow.steps.ref", `${modelName}:flow.${flow.name}`, step.ref);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=consumers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consumers.js","sourceRoot":"","sources":["../../../../src/features/federation/commands/consumers.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEnD,iEAAiE;AACjE,8DAA8D;AAC9D,OAAO,cAAc,CAAC;AAmBtB,MAAM,UAAU,iBAAiB,CAAC,OAAY;IAC5C,OAAO;SACJ,OAAO,CAAC,gBAAgB,CAAC;SACzB,WAAW,CAAC,8EAA8E,CAAC;SAC3F,MAAM,CAAC,mBAAmB,EAAE,0BAA0B,CAAC;SACvD,MAAM,CAAC,QA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S,EAAE,GAAG,SAAS,IAAI,OAAO,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;QAC5F,CAAC;IACH,CAAC;IACD,KAAK,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;QACtC,KAAK,MAAM,GAAG,IAAI,GAAG,CAAC,WAAW,IAAI,EAAE;YAAE,KAAK,CAAC,aAAa,EAAE,GAAG,SAAS,IAAI,KAAK,EAAE,EAAE,GAAG,CAAC,CAAC;QAC5F,IAAI,GAAG,CAAC,aAAa;YAAE,KAAK,CAAC,eAAe,EAAE,GAAG,SAAS,IAAI,KAAK,EAAE,EAAE,GAAG,CAAC,aAAa,CAAC,CAAC;IAC5F,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC;QAC3C,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC9B,KAAK,CAAC,gBAAgB,EAAE,GAAG,SAAS,SAAS,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;QACtE,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `dkk peers add <name>` — append a peer to .dkk/federation.yml.
|
|
3
|
+
*
|
|
4
|
+
* Two source forms (Phase 2 ships local; --git lands in Phase 3 but
|
|
5
|
+
* is parsed here so the CLI surface is forward-compatible):
|
|
6
|
+
* dkk peers add <name> --local <path>
|
|
7
|
+
* dkk peers add <name> --git <url> --branch <branch> [--git-path <subpath>]
|
|
8
|
+
*
|
|
9
|
+
* Idempotent: re-adding an existing peer with the same source is a
|
|
10
|
+
* no-op; replacing requires --force.
|
|
11
|
+
*/
|
|
12
|
+
import type { Command as Cmd } from "commander";
|
|
13
|
+
export declare function registerPeersAdd(parent: Cmd): void;
|
|
14
|
+
//# sourceMappingURL=peers-add.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"peers-add.d.ts","sourceRoot":"","sources":["../../../../src/features/federation/commands/peers-add.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,WAAW,CAAC;AA0BhD,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI,CAgFlD"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { dirname } from "node:path";
|
|
3
|
+
import { federationFile } from "../../../shared/paths.js";
|
|
4
|
+
import { parseYaml, stringifyYaml } from "../../../shared/yaml.js";
|
|
5
|
+
function isValidKebab(name) {
|
|
6
|
+
return /^[a-z][a-z0-9-]*$/.test(name);
|
|
7
|
+
}
|
|
8
|
+
export function registerPeersAdd(parent) {
|
|
9
|
+
parent
|
|
10
|
+
.command("add <name>")
|
|
11
|
+
.description("Register a peer service in .dkk/federation.yml")
|
|
12
|
+
.option("--local <path>", "Local filesystem path to the peer's repository root")
|
|
13
|
+
.option("--git <url>", "Git URL of the peer repository")
|
|
14
|
+
.option("--branch <branch>", "Branch to track for git sources", "main")
|
|
15
|
+
.option("--git-path <subpath>", "Sub-path inside the peer repo where .dkk/ lives")
|
|
16
|
+
.option("-r, --root <path>", "Override repository root")
|
|
17
|
+
.option("--force", "Replace an existing entry for this peer")
|
|
18
|
+
.option("--json", "Output as JSON")
|
|
19
|
+
.option("--minify", "Minify JSON output")
|
|
20
|
+
.action((name, opts) => {
|
|
21
|
+
if (!isValidKebab(name)) {
|
|
22
|
+
console.error(`Error: Peer name "${name}" must be kebab-case.`);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
if (!opts.local && !opts.git) {
|
|
26
|
+
console.error("Error: must specify either --local <path> or --git <url>.");
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
if (opts.local && opts.git) {
|
|
30
|
+
console.error("Error: --local and --git are mutually exclusive.");
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
let source;
|
|
34
|
+
if (opts.local) {
|
|
35
|
+
source = { type: "local", path: opts.local };
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
const branch = opts.branch ?? "main";
|
|
39
|
+
source = { type: "git", url: opts.git, branch };
|
|
40
|
+
if (opts.gitPath)
|
|
41
|
+
source.path = opts.gitPath;
|
|
42
|
+
}
|
|
43
|
+
const path = federationFile(opts.root);
|
|
44
|
+
let manifest;
|
|
45
|
+
if (existsSync(path)) {
|
|
46
|
+
manifest = parseYaml(readFileSync(path, "utf-8"));
|
|
47
|
+
if (!Array.isArray(manifest.peers))
|
|
48
|
+
manifest.peers = [];
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
manifest = { peers: [] };
|
|
52
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
53
|
+
}
|
|
54
|
+
const existingIdx = manifest.peers.findIndex((p) => p.name === name);
|
|
55
|
+
if (existingIdx >= 0 && !opts.force) {
|
|
56
|
+
console.error(`Error: peer "${name}" already exists. Use --force to replace.`);
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
const entry = { name, source };
|
|
60
|
+
if (existingIdx >= 0) {
|
|
61
|
+
manifest.peers[existingIdx] = entry;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
manifest.peers.push(entry);
|
|
65
|
+
}
|
|
66
|
+
const header = "# Federation manifest — peer services to load alongside this repo.\n";
|
|
67
|
+
writeFileSync(path, header + stringifyYaml(manifest), "utf-8");
|
|
68
|
+
if (opts.json) {
|
|
69
|
+
console.log(JSON.stringify({ path, peer: entry, replaced: existingIdx >= 0 }, null, opts.minify ? 0 : 2));
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const action = existingIdx >= 0 ? "Replaced" : "Added";
|
|
73
|
+
const summary = source.type === "local"
|
|
74
|
+
? `local: ${source.path}`
|
|
75
|
+
: `git: ${source.url} @ ${source.branch}`;
|
|
76
|
+
console.log(`${action} peer "${name}" (${summary}) in ${path}`);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=peers-add.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"peers-add.js","sourceRoot":"","sources":["../../../../src/features/federation/commands/peers-add.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAOnE,SAAS,YAAY,CAAC,IAAY;IAChC,OAAO,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACxC,CAAC;AAaD,MAAM,UAAU,gBAAgB,CAAC,MAAW;IAC1C,MAAM;SACH,OAAO,CAAC,YAAY,CAAC;SACrB,WAAW,CAAC,gDAAgD,CAAC;SAC7D,MAAM,CAAC,gBAAgB,EAAE,qDAAqD,CAAC;SAC/E,MAAM,CAAC,aAAa,EAAE,gCAAgC,CAAC;SACvD,MAAM,CAAC,mBAAmB,EAAE,iCAAiC,EAAE,MAAM,CAAC;SACtE,MAAM,CAAC,sBAAsB,EAAE,iDAAiD,CAAC;SACjF,MAAM,CAAC,mBAAmB,EAAE,0BAA0B,CAAC;SACvD,MAAM,CAAC,SAAS,EAAE,yCAAyC,CAAC;SAC5D,MAAM,CAAC,QAAQ,EAAE,gBAAgB,CAAC;SAClC,MAAM,CAAC,UAAU,EAAE,oBAAoB,CAAC;SACxC,MAAM,CAAC,CAAC,IAAY,EAAE,IAAa,EAAE,EAAE;QACtC,IA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AAC,CACpB,CACF,CAAC;YACF,OAAO;QACT,CAAC;QAED,MAAM,MAAM,GAAG,WAAW,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC;QACvD,MAAM,OAAO,GACX,MAAM,CAAC,IAAI,KAAK,OAAO;YACrB,CAAC,CAAC,UAAU,MAAM,CAAC,IAAI,EAAE;YACzB,CAAC,CAAC,QAAQ,MAAM,CAAC,GAAG,MAAM,MAAM,CAAC,MAAM,EAAE,CAAC;QAC9C,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,UAAU,IAAI,MAAM,OAAO,QAAQ,IAAI,EAAE,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `dkk peers list` — display the configured peer services and their
|
|
3
|
+
* reachability state. Reads `.dkk/federation.yml` and resolves each
|
|
4
|
+
* peer source without actually loading peer models.
|
|
5
|
+
*/
|
|
6
|
+
import type { Command as Cmd } from "commander";
|
|
7
|
+
export declare function registerPeersList(parent: Cmd): void;
|
|
8
|
+
//# sourceMappingURL=peers-list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"peers-list.d.ts","sourceRoot":"","sources":["../../../../src/features/federation/commands/peers-list.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,WAAW,CAAC;AAUhD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI,CAoDnD"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { repoRoot } from "../../../shared/paths.js";
|
|
2
|
+
import { loadFederation, resolvePeerRoot, peerEnvKey } from "../loader.js";
|
|
3
|
+
export function registerPeersList(parent) {
|
|
4
|
+
parent
|
|
5
|
+
.command("list")
|
|
6
|
+
.description("List configured federation peers and reachability state")
|
|
7
|
+
.option("-r, --root <path>", "Override repository root")
|
|
8
|
+
.option("--json", "Output as JSON")
|
|
9
|
+
.option("--minify", "Minify JSON output")
|
|
10
|
+
.action((opts) => {
|
|
11
|
+
const root = repoRoot(opts.root);
|
|
12
|
+
const manifest = loadFederation(opts.root);
|
|
13
|
+
if (!manifest || manifest.peers.length === 0) {
|
|
14
|
+
if (opts.json) {
|
|
15
|
+
console.log(JSON.stringify({ peers: [] }, null, opts.minify ? 0 : 2));
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
console.log("No peers configured. Add one with `dkk peers add <name> --local <path>`.");
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const rows = manifest.peers.map((peer) => {
|
|
22
|
+
const resolution = resolvePeerRoot(peer, root);
|
|
23
|
+
const envKey = peerEnvKey(peer.name);
|
|
24
|
+
const envOverride = process.env[envKey];
|
|
25
|
+
return {
|
|
26
|
+
name: peer.name,
|
|
27
|
+
source: peer.source,
|
|
28
|
+
peerRoot: resolution.peerRoot,
|
|
29
|
+
reachable: resolution.reachable,
|
|
30
|
+
envOverride: envOverride ?? null,
|
|
31
|
+
reason: resolution.reason ?? null,
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
if (opts.json) {
|
|
35
|
+
console.log(JSON.stringify({ peers: rows }, null, opts.minify ? 0 : 2));
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
for (const row of rows) {
|
|
39
|
+
const label = row.source.type === "local"
|
|
40
|
+
? `local: ${row.source.path}`
|
|
41
|
+
: `git: ${row.source.url} @ ${row.source.branch}`;
|
|
42
|
+
const status = row.reachable ? "reachable" : "unreachable";
|
|
43
|
+
const overrideTag = row.envOverride ? ` (env: ${row.envOverride})` : "";
|
|
44
|
+
console.log(`${row.name} ${label} [${status}]${overrideTag}`);
|
|
45
|
+
if (!row.reachable && row.reason) {
|
|
46
|
+
console.log(` ${row.reason}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=peers-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"peers-list.js","sourceRoot":"","sources":["../../../../src/features/federation/commands/peers-list.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAQ3E,MAAM,UAAU,iBAAiB,CAAC,MAAW;IAC3C,MAAM;SACH,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,yDAAyD,CAAC;SACtE,MAAM,CAAC,mBAAmB,EAAE,0BAA0B,CAAC;SACvD,MAAM,CAAC,QAAQ,EAAE,gBAAgB,CAAC;SAClC,MAAM,CAAC,UAAU,EAAE,oBAAoB,CAAC;SACxC,MAAM,CAAC,CAAC,IAAc,EAAE,EAAE;QACzB,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjC,MAAM,QAAQ,GAAG,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE3C,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC7C,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;gBACd,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACtE,OAAO;YACT,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,0EAA0E,CAAC,CAAC;YACxF,OAAO;QACT,CAAC;QAED,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;YACvC,MAAM,UAAU,GAAG,eAAe,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,GAAG,GAAG,CAAC,IAAI,KAAK,KAAK,MAAM,MAAM,IAAI,WAAW,EAAE,CAAC,CAAC;YAChE,IAAI,CAAC,GAAG,CAAC,SAAS,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;gBACjC,OAAO,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;YACjC,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `dkk peers status` — diagnostic view of each configured peer:
|
|
3
|
+
* source, env override, reachability, loaded service identity, exports,
|
|
4
|
+
* and a peer-load warning count. More detailed than `peers list`.
|
|
5
|
+
*/
|
|
6
|
+
import type { Command as Cmd } from "commander";
|
|
7
|
+
export declare function registerPeersStatus(parent: Cmd): void;
|
|
8
|
+
//# sourceMappingURL=peers-status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"peers-status.d.ts","sourceRoot":"","sources":["../../../../src/features/federation/commands/peers-status.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,WAAW,CAAC;AAsBhD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI,CA4ErD"}
|