@chrisdudek/yg 1.4.3 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -7
- package/dist/bin.js +831 -561
- package/dist/bin.js.map +1 -1
- package/dist/templates/default-config.ts +12 -12
- package/dist/templates/rules.ts +91 -54
- package/graph-schemas/{aspect.yaml → yg-aspect.yaml} +5 -1
- package/graph-schemas/{config.yaml → yg-config.yaml} +15 -8
- package/graph-schemas/{flow.yaml → yg-flow.yaml} +1 -1
- package/graph-schemas/{node.yaml → yg-node.yaml} +10 -3
- package/package.json +3 -1
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
export const DEFAULT_CONFIG = `
|
|
1
|
+
export const DEFAULT_CONFIG = `version: "2.0.0"
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
language: ""
|
|
5
|
-
runtime: ""
|
|
6
|
-
|
|
7
|
-
standards: ""
|
|
3
|
+
name: ""
|
|
8
4
|
|
|
9
5
|
node_types:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
module:
|
|
7
|
+
description: "Business logic unit with clear domain responsibility"
|
|
8
|
+
service:
|
|
9
|
+
description: "Component providing functionality to other nodes"
|
|
10
|
+
library:
|
|
11
|
+
description: "Shared utility code with no domain knowledge"
|
|
12
|
+
infrastructure:
|
|
13
|
+
description: "Guards, middleware, interceptors — invisible in call graphs but affect blast radius"
|
|
14
14
|
|
|
15
15
|
artifacts:
|
|
16
16
|
responsibility.md:
|
|
17
17
|
required: always
|
|
18
18
|
description: "What this node is responsible for, and what it is not"
|
|
19
|
-
|
|
19
|
+
included_in_relations: true
|
|
20
20
|
interface.md:
|
|
21
21
|
required:
|
|
22
22
|
when: has_incoming_relations
|
|
23
23
|
description: "Public API — methods, parameters, return types, contracts, failure modes, exposed data structures"
|
|
24
|
-
|
|
24
|
+
included_in_relations: true
|
|
25
25
|
internals.md:
|
|
26
26
|
required: never
|
|
27
27
|
description: "How the node works and why — algorithms, business rules, state machines, design decisions with rejected alternatives"
|
package/dist/templates/rules.ts
CHANGED
|
@@ -11,14 +11,25 @@
|
|
|
11
11
|
// prettier-ignore
|
|
12
12
|
const CORE_PROTOCOL = `## CORE PROTOCOL
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
<EXTREMELY-IMPORTANT>
|
|
15
|
+
This is your operating manual for working in a Yggdrasil-managed repository. Every rule below is mandatory — no skill, plan, workflow, or instruction overrides these requirements.
|
|
16
|
+
|
|
17
|
+
BEFORE working with ANY source file, you MUST run \`yg owner\` to check if it is mapped. If mapped, you MUST use the graph before reading source. YOU DO NOT HAVE A CHOICE.
|
|
18
|
+
|
|
19
|
+
This is not negotiable. This is not optional. You cannot rationalize your way out of this.
|
|
20
|
+
</EXTREMELY-IMPORTANT>
|
|
21
|
+
|
|
22
|
+
Yggdrasil is persistent semantic memory stored in \`.yggdrasil/\`. It maps the repository and provides deterministic implementation context for every node.
|
|
15
23
|
|
|
16
24
|
### Quick Start Protocol
|
|
17
25
|
|
|
18
26
|
\`\`\`
|
|
19
27
|
BEFORE reading, researching, planning, OR modifying ANY mapped file:
|
|
20
28
|
1. yg owner --file <path>
|
|
21
|
-
2.
|
|
29
|
+
2. Choose the right graph tool for your task:
|
|
30
|
+
- Understanding how/why it works → yg build-context --node <owner>
|
|
31
|
+
- Assessing what is affected by a change → yg impact --node <owner>
|
|
32
|
+
- Planning modifications → both (build-context first, then impact)
|
|
22
33
|
The context package is your primary source of ARCHITECTURAL understanding:
|
|
23
34
|
intent, constraints, relations, rationale. For IMPLEMENTATION precision
|
|
24
35
|
(exact behavior, error handling, await patterns, edge cases) — verify
|
|
@@ -38,6 +49,8 @@ NEVER: modify code without graph coverage.
|
|
|
38
49
|
NEVER: read mapped source files to understand a component without
|
|
39
50
|
running yg build-context first — the graph captures intent,
|
|
40
51
|
constraints, and relations that source files cannot.
|
|
52
|
+
NEVER: assess blast radius of a change without running yg impact first
|
|
53
|
+
— the graph knows the dependency structure that grep cannot infer.
|
|
41
54
|
NEVER: invent rationale, business rules, or decisions.
|
|
42
55
|
NEVER: auto-resolve drift without asking the user.
|
|
43
56
|
WHEN UNSURE: ask the user. Never guess. Never assume.
|
|
@@ -45,7 +58,7 @@ WHEN UNSURE: ask the user. Never guess. Never assume.
|
|
|
45
58
|
|
|
46
59
|
### Five Core Rules
|
|
47
60
|
|
|
48
|
-
1. **Graph first.** Before reading, researching, planning, or modifying mapped files, run \`yg owner\` and \`yg build-context
|
|
61
|
+
1. **Graph first.** Before reading, researching, planning, or modifying mapped files, run \`yg owner\` and the appropriate graph tool: \`yg build-context\` to understand a component, \`yg impact\` to assess blast radius. The graph is your primary source of architectural understanding. For implementation-level precision (exact behavior, error paths, edge cases) — verify against source code after loading the context package.
|
|
49
62
|
2. **Code and graph are one.** Code changed → graph updated in the same response. Graph changed → source verified in the same response. No exceptions.
|
|
50
63
|
3. **Never invent why.** The graph captures human intent. If you don't know why something was decided, ask. Never hallucinate rationale.
|
|
51
64
|
4. **Always capture why — especially why NOT.** When the user explains a reason, record it in the graph immediately. When a design choice is made, also record rejected alternatives: "Chose X over Y because Z." Rejected alternatives are the highest-value information — invisible in code and irrecoverable once forgotten. Conversation evaporates; graph persists.
|
|
@@ -53,15 +66,22 @@ WHEN UNSURE: ask the user. Never guess. Never assume.
|
|
|
53
66
|
|
|
54
67
|
### Recognizing Graph-Required Actions
|
|
55
68
|
|
|
56
|
-
What matters is the ACTION you are performing, not what instructed it. If the action involves understanding mapped code, the graph protocol applies — whether the instruction came from a skill, a plan, a user message, a
|
|
69
|
+
What matters is the ACTION you are performing, not what instructed it. If the action involves reading, understanding, or modifying mapped code, the graph protocol applies — whether the instruction came from a skill, a plan, a user message, a brainstorming session, a debugging workflow, or your own initiative. This is not negotiable. You cannot rationalize your way out of this.
|
|
57
70
|
|
|
58
|
-
**Actions that require \`yg owner\` + \`yg build-context
|
|
71
|
+
**Actions that require \`yg owner\` + \`yg build-context\`:**
|
|
59
72
|
|
|
60
73
|
- Reading or exploring source files to understand a component
|
|
61
74
|
- Proposing approaches, designs, or plans for changing code
|
|
62
75
|
- Reviewing or debugging code
|
|
63
76
|
- Any form of reasoning about how mapped code works or should change
|
|
64
77
|
|
|
78
|
+
**Actions that require \`yg owner\` + \`yg impact\`:**
|
|
79
|
+
|
|
80
|
+
- Assessing blast radius before changing or removing a component
|
|
81
|
+
- Finding all dependents of a component
|
|
82
|
+
- Planning cross-cutting refactors or feature removals
|
|
83
|
+
- Scoping work that spans multiple nodes
|
|
84
|
+
|
|
65
85
|
**Actions that do NOT require yg:**
|
|
66
86
|
|
|
67
87
|
- Git operations (log, diff, status, blame)
|
|
@@ -69,11 +89,22 @@ What matters is the ACTION you are performing, not what instructed it. If the ac
|
|
|
69
89
|
- Running tests, builds, or linters
|
|
70
90
|
- Working with files that \`yg owner\` reports as unmapped
|
|
71
91
|
|
|
92
|
+
**Evasion patterns — if you think any of these, STOP:**
|
|
93
|
+
|
|
94
|
+
| Thought | Reality |
|
|
95
|
+
|---|---|
|
|
96
|
+
| "The skill/plan says to explore the codebase" | Exploring mapped code = yg owner + graph tool first |
|
|
97
|
+
| "I'm just scoping/searching, not understanding" | Scoping IS a graph action; use yg impact |
|
|
98
|
+
| "The plan step says to read this file" | Reading a mapped file = yg owner first |
|
|
99
|
+
| "I'm brainstorming, not implementing" | Brainstorming about mapped code needs graph context |
|
|
100
|
+
| "I'm only grepping for references" | Grep finds text; yg impact finds structural dependencies. Use both. |
|
|
101
|
+
| "I'll use the graph later when I modify" | Graph-first means BEFORE reading, not before modifying |
|
|
102
|
+
|
|
72
103
|
### Failure States
|
|
73
104
|
|
|
74
105
|
You have broken Yggdrasil if you do any of the following:
|
|
75
106
|
|
|
76
|
-
- ❌ Worked on a mapped file without running \`yg owner\` + \`
|
|
107
|
+
- ❌ Worked on a mapped file without running \`yg owner\` + the appropriate graph tool (\`build-context\` or \`impact\`) first — regardless of what instructed the action (skill, plan, user request, workflow step).
|
|
77
108
|
- ❌ Modified source code without updating graph artifacts in the same response, or vice versa.
|
|
78
109
|
- ❌ Resolved a code-graph inconsistency or ambiguity without asking the user first.
|
|
79
110
|
- ❌ Created or edited a graph element without reading its schema in \`schemas/\` first.
|
|
@@ -95,7 +126,22 @@ Before preflight:
|
|
|
95
126
|
|
|
96
127
|
- Verify \`yg\` CLI is available. If not found, inform user and stop.
|
|
97
128
|
- If \`yg preflight\` shows 0 nodes → enter BOOTSTRAP MODE (see Operations).
|
|
98
|
-
- If drift report shows >10 drifted nodes → report scope to user, ask which area to prioritize. Do not resolve all at once
|
|
129
|
+
- If drift report shows >10 drifted nodes → report scope to user, ask which area to prioritize. Do not resolve all at once.
|
|
130
|
+
|
|
131
|
+
### Delegating to Subagents
|
|
132
|
+
|
|
133
|
+
When you delegate work to a subagent (any subprocess, tool agent, or spawned assistant), the subagent does NOT inherit your Yggdrasil knowledge. Before any other instruction, the subagent MUST:
|
|
134
|
+
|
|
135
|
+
1. Read \`.yggdrasil/agent-rules.md\` — this is the complete operating manual
|
|
136
|
+
2. Follow the Quick Start Protocol from that file before touching any mapped code
|
|
137
|
+
|
|
138
|
+
Include this as the FIRST instruction in every subagent prompt:
|
|
139
|
+
|
|
140
|
+
\`\`\`
|
|
141
|
+
BEFORE doing anything else: read .yggdrasil/agent-rules.md and follow its protocol.
|
|
142
|
+
\`\`\`
|
|
143
|
+
|
|
144
|
+
A subagent that skips this step will read code without graph context, miss architectural constraints, and produce changes that break graph-code consistency.`;
|
|
99
145
|
|
|
100
146
|
// prettier-ignore
|
|
101
147
|
const OPERATIONS = `## OPERATIONS
|
|
@@ -105,9 +151,8 @@ const OPERATIONS = `## OPERATIONS
|
|
|
105
151
|
\`\`\`
|
|
106
152
|
PREFLIGHT (every conversation, before any work):
|
|
107
153
|
- [ ] 1. yg preflight → read unified report
|
|
108
|
-
- [ ] 2. If
|
|
109
|
-
- [ ] 3. If
|
|
110
|
-
- [ ] 4. If validation errors: fix, re-run yg validate
|
|
154
|
+
- [ ] 2. If drift: resolve per Drift Resolution, then yg drift-sync per node
|
|
155
|
+
- [ ] 3. If validation errors: fix, re-run yg validate
|
|
111
156
|
Exception: read-only requests (explain, analyze) — skip preflight.
|
|
112
157
|
|
|
113
158
|
UNDERSTANDING mapped code (questions, research, OR planning):
|
|
@@ -118,14 +163,14 @@ UNDERSTANDING mapped code (questions, research, OR planning):
|
|
|
118
163
|
Raw reads supplement the context package — they do not replace it.
|
|
119
164
|
|
|
120
165
|
WRAP-UP (user signals "done", "wrap up", "that's enough"):
|
|
121
|
-
- [ ] 1.
|
|
122
|
-
- [ ] 2. yg
|
|
123
|
-
- [ ] 3.
|
|
124
|
-
- [ ] 4. Report: which nodes and files were changed
|
|
166
|
+
- [ ] 1. yg drift --drifted-only → resolve
|
|
167
|
+
- [ ] 2. yg validate → fix errors
|
|
168
|
+
- [ ] 3. Report: which nodes and files were changed
|
|
125
169
|
|
|
126
170
|
BEFORE ENDING ANY RESPONSE (self-audit):
|
|
171
|
+
- [ ] Did I interact with mapped code (read, research, or modify)? If yes → did I use a graph tool BEFORE reading source?
|
|
127
172
|
- [ ] Did I modify source code? If yes → did I update graph artifacts in this same response?
|
|
128
|
-
- [ ] If you
|
|
173
|
+
- [ ] If you broke either rule, you have broken the protocol. Do not finish until both are fixed.
|
|
129
174
|
\`\`\`
|
|
130
175
|
|
|
131
176
|
### Modify Source Code
|
|
@@ -181,11 +226,11 @@ Per area checklist:
|
|
|
181
226
|
|
|
182
227
|
- [ ] 1. \`yg owner --file <path>\` — confirm no coverage
|
|
183
228
|
- [ ] 2. Determine node granularity — propose to user if unclear
|
|
184
|
-
- [ ] 3. Create node directory, read \`schemas/node.yaml\`, create \`node.yaml\`
|
|
185
|
-
- [ ] 4. Analyze source — for each artifact type in \`config.artifacts\`: extract content, do not invent
|
|
186
|
-
- [ ] 5. Identify relations — add to \`node.yaml\`
|
|
229
|
+
- [ ] 3. Create node directory, read \`schemas/yg-node.yaml\`, create \`yg-node.yaml\`
|
|
230
|
+
- [ ] 4. Analyze source — for each artifact type in \`yg-config.yaml artifacts\`: extract content, do not invent
|
|
231
|
+
- [ ] 5. Identify relations — add to \`yg-node.yaml\`
|
|
187
232
|
- [ ] 6. Identify cross-cutting requirements — add matching aspects, create if needed
|
|
188
|
-
- [ ] 6b. For each aspect on the node: identify 2-5 code anchors (function names, constants) that evidence the pattern → add
|
|
233
|
+
- [ ] 6b. For each aspect on the node: identify 2-5 code anchors (function names, constants) that evidence the pattern → add as \`anchors\` in the aspect entry in \`yg-node.yaml\`
|
|
189
234
|
- [ ] 7. Identify business process participation — add to flow, ask user if process unclear
|
|
190
235
|
- [ ] 8. \`yg validate\` — fix errors
|
|
191
236
|
- [ ] 9. \`yg drift-sync --node <path>\`
|
|
@@ -235,7 +280,7 @@ When reviewing graph quality (triggered by user or quality improvement):
|
|
|
235
280
|
- [ ] 1. \`yg build-context --node <path>\`
|
|
236
281
|
- [ ] 2. Read mapped source files
|
|
237
282
|
- [ ] 3. For each claim in graph: verify against source code
|
|
238
|
-
- [ ] 4. For each aspect: verify the pattern holds in THIS node. If it deviates, add \`
|
|
283
|
+
- [ ] 4. For each aspect: verify the pattern holds in THIS node. If it deviates, add \`exceptions\` to the aspect entry in \`yg-node.yaml\`
|
|
239
284
|
- [ ] 5. Report inconsistencies
|
|
240
285
|
|
|
241
286
|
**Step 2 — Completeness** (catches MISSING information):
|
|
@@ -260,27 +305,21 @@ const KNOWLEDGE_BASE = `## KNOWLEDGE BASE
|
|
|
260
305
|
|
|
261
306
|
\`\`\`
|
|
262
307
|
.yggdrasil/
|
|
263
|
-
config.yaml
|
|
308
|
+
yg-config.yaml ← version, vocabulary, node types, artifact rules, required aspects
|
|
264
309
|
model/ ← what exists: nodes, hierarchy, relations, file mappings
|
|
265
310
|
aspects/ ← what must: cross-cutting requirements with rationale and guidance
|
|
266
311
|
flows/ ← why and in what process: business processes with node participation
|
|
267
312
|
schemas/ ← YAML schemas — read before creating any graph element
|
|
268
|
-
.drift-state
|
|
269
|
-
.journal.yaml ← generated by CLI; never edit manually
|
|
313
|
+
.drift-state/ ← generated by CLI; never edit manually
|
|
270
314
|
\`\`\`
|
|
271
315
|
|
|
272
316
|
Key facts:
|
|
273
317
|
|
|
274
318
|
- **Hierarchy:** nodes nest in \`model/\`. Children inherit parent context. Do not repeat parent content in children.
|
|
275
|
-
- **Aspect id = directory path** under \`aspects/\`. Each aspect has \`aspect.yaml\` + content \`.md\` files. No automatic parent-child — use \`implies\` explicitly.
|
|
319
|
+
- **Aspect id = directory path** under \`aspects/\`. Each aspect has \`yg-aspect.yaml\` + content \`.md\` files. No automatic parent-child — use \`implies\` explicitly.
|
|
276
320
|
- **Flows = business processes.** A flow describes what happens in the world, not code sequences. Flow aspects propagate to all participants.
|
|
277
321
|
|
|
278
|
-
**Node type guidance:**
|
|
279
|
-
|
|
280
|
-
- \`module\` — business logic unit with clear domain responsibility
|
|
281
|
-
- \`service\` — component providing functionality to other nodes
|
|
282
|
-
- \`library\` — shared utility code with no domain knowledge
|
|
283
|
-
- \`infrastructure\` — guards, resolvers, middleware, interceptors, validators that intercept or modify request flow. These affect blast radius of changes but are invisible in call graphs. Map them to make blast radius analysis accurate. Key signal: code that runs WITHOUT being explicitly called by business logic (e.g., NestJS guards, Express middleware, GraphQL resolvers).
|
|
322
|
+
**Node type guidance:** Each type in \`yg-config.yaml node_types\` has a \`description\` that tells you when to use it. Check the project's config for the full list and descriptions. Common types: \`module\` (business logic), \`service\` (providing functionality), \`library\` (shared utilities), \`infrastructure\` (guards, middleware, interceptors — invisible in call graphs but affect blast radius).
|
|
284
323
|
|
|
285
324
|
### Artifact Structure
|
|
286
325
|
|
|
@@ -292,26 +331,28 @@ Three artifacts capture node knowledge at three levels:
|
|
|
292
331
|
|
|
293
332
|
**Enrichment priority (when adding incrementally):** \`interface.md\` first (highest cross-module ROI — contracts enable other nodes to reason about interactions), then \`responsibility.md\` (identity and boundaries), then \`internals.md\` (depth for complex nodes). A node with only \`interface.md\` provides more cross-module value than one with only \`internals.md\`.
|
|
294
333
|
|
|
334
|
+
Projects can define additional artifact types in \`yg-config.yaml\` under \`artifacts\`. Each custom artifact has a \`description\` (tells you what to write), a \`required\` condition (\`always\`, \`never\`, \`when: has_incoming_relations\`, \`when: has_aspect:<id>\`), and an \`included_in_relations\` flag (if true, included in dependency context packages for structural relations). The three standard artifacts are always present in config. Check \`yg-config.yaml\` to see all defined artifacts for the project.
|
|
335
|
+
|
|
295
336
|
### Context Assembly
|
|
296
337
|
|
|
297
|
-
Run \`yg build-context --node <path>\` to get the deterministic context package for a node. The package assembles global
|
|
338
|
+
Run \`yg build-context --node <path>\` to get the deterministic context package for a node. The package assembles global project identity, hierarchy, own artifacts, aspects, and relational context. It is your architectural map. For implementation-level claims (exact call patterns, error handling, await vs fire-and-forget) — verify against source code. If the package is insufficient, enrich the graph.
|
|
298
339
|
|
|
299
340
|
### Information Routing
|
|
300
341
|
|
|
301
342
|
When you encounter information, route it to the correct location:
|
|
302
343
|
|
|
303
|
-
- **Specific to this node** → local node artifact (check \`config.yaml artifacts\` for available types)
|
|
304
|
-
- **Rule for many nodes** → aspect (\`aspects/<id>/\` with \`aspect.yaml\` + content \`.md\` files). If applies to ALL nodes of a type → \`node_types
|
|
305
|
-
- **Business process** → flow (\`flows/<name>/\` with \`flow.yaml\` + \`description.md\`). Ask user if process unclear.
|
|
344
|
+
- **Specific to this node** → local node artifact (check \`yg-config.yaml artifacts\` for available types)
|
|
345
|
+
- **Rule for many nodes** → aspect (\`aspects/<id>/\` with \`yg-aspect.yaml\` + content \`.md\` files). If applies to ALL nodes of a type → \`node_types.<type>.required_aspects\` in \`yg-config.yaml\`
|
|
346
|
+
- **Business process** → flow (\`flows/<name>/\` with \`yg-flow.yaml\` + \`description.md\`). Ask user if process unclear.
|
|
306
347
|
- **Shared across a domain** → parent node artifact. Children receive it through hierarchy.
|
|
307
|
-
- **Technology stack or standard** → \`
|
|
308
|
-
- **Decision (why + why NOT):** one node → Decisions section of \`internals.md\` with format "Chose X over Y because Z"; category of nodes → aspect content files; tech choice →
|
|
348
|
+
- **Technology stack or standard** → node artifact at the appropriate hierarchy level (e.g., root node's \`responsibility.md\` for single-stack repos, or deployment unit node for monorepos)
|
|
349
|
+
- **Decision (why + why NOT):** one node → Decisions section of \`internals.md\` with format "Chose X over Y because Z"; category of nodes → aspect content files; tech choice → node artifact at the level where the technology applies. Always include rejected alternatives — they are the highest-value graph content. If the rationale is unknown: record the decision with "rationale: unknown" and note what CAN be observed from the code. Never invent a plausible-sounding rationale.
|
|
309
350
|
|
|
310
351
|
### Creating Aspects
|
|
311
352
|
|
|
312
|
-
- [ ] 1. Read \`schemas/aspect.yaml\`
|
|
353
|
+
- [ ] 1. Read \`schemas/yg-aspect.yaml\`
|
|
313
354
|
- [ ] 2. Create \`aspects/<id>/\` directory
|
|
314
|
-
- [ ] 3. Write \`aspect.yaml\` — name, optional description, optional implies
|
|
355
|
+
- [ ] 3. Write \`yg-aspect.yaml\` — name, optional description, optional implies
|
|
315
356
|
- [ ] 4. Write content \`.md\` files: WHAT must be satisfied + WHY (user's words, do not invent)
|
|
316
357
|
- [ ] 5. \`yg validate\`
|
|
317
358
|
|
|
@@ -323,23 +364,23 @@ Test: "Does this requirement apply to more than one node?" Yes → aspect. No
|
|
|
323
364
|
- **Architectural:** Structural patterns with rationale (e.g., dual-rollback on provider failure, idempotency via key generation, fire-and-forget dispatch)
|
|
324
365
|
- **Concurrency:** Shared concurrency strategies (e.g., pessimistic locking, retry-on-deadlock, optimistic versioning)
|
|
325
366
|
|
|
326
|
-
When a node follows an aspect's pattern with exceptions, record exceptions in \`node.yaml
|
|
367
|
+
When a node follows an aspect's pattern with exceptions, record them in the \`exceptions\` field of the aspect entry in \`yg-node.yaml\`. Example: aspect says "fire-and-forget" but this node awaits the publish call — add \`exceptions: ["awaits publish call instead of fire-and-forget because..."]\`. Exceptions appear in the context package next to the aspect content, preventing abstractions from masking implementation details.
|
|
327
368
|
|
|
328
369
|
**Aspect lifecycle warning.** Aspects decay CATASTROPHICALLY — a pattern either exists or it doesn't. When a pattern changes, ALL aspect claims become wrong at once. This differs from other artifacts: \`interface.md\` and \`responsibility.md\` are most stable (~9-year half-life); \`internals.md\` has moderate stability (~2.5-year half-life); aspects are least stable (~2.4-year half-life, binary decay). After any significant feature addition, review ALL aspects touching the affected area. Don't wait for drift — aspects can be 100% wrong without any mapped file changing.
|
|
329
370
|
|
|
330
|
-
**Aspect stability tiers.** If an aspect has a \`stability\` field in \`aspect.yaml\`, use it to calibrate review urgency:
|
|
371
|
+
**Aspect stability tiers.** If an aspect has a \`stability\` field in \`yg-aspect.yaml\`, use it to calibrate review urgency:
|
|
331
372
|
|
|
332
373
|
- \`schema\` — enforced by data model; review only when data model changes (most stable)
|
|
333
374
|
- \`protocol\` — contractual pattern; review when contracts or interfaces change
|
|
334
375
|
- \`implementation\` — specific mechanism; review after ANY significant code change (least stable)
|
|
335
376
|
|
|
336
|
-
When code anchors (\`anchors\`
|
|
377
|
+
When code anchors (\`anchors\` in an aspect entry in \`yg-node.yaml\`) are present, they list code patterns (function names, constants, SQL fragments) evidencing the aspect's implementation in this node. \`yg validate\` checks that each anchor exists in the node's mapped source files — a missing anchor (W014) signals the aspect may be stale for this node.
|
|
337
378
|
|
|
338
379
|
### Creating Flows
|
|
339
380
|
|
|
340
|
-
- [ ] 1. Read \`schemas/flow.yaml\`
|
|
381
|
+
- [ ] 1. Read \`schemas/yg-flow.yaml\`
|
|
341
382
|
- [ ] 2. Create \`flows/<name>/\` directory
|
|
342
|
-
- [ ] 3. Write \`flow.yaml\` — declare participants and flow-level aspects
|
|
383
|
+
- [ ] 3. Write \`yg-flow.yaml\` — declare participants and flow-level aspects
|
|
343
384
|
- [ ] 4. Write \`description.md\` with required sections: Business context, Trigger, Goal, Participants, Paths (at least Happy path), Invariants across all paths
|
|
344
385
|
- [ ] 5. \`yg validate\`
|
|
345
386
|
|
|
@@ -350,7 +391,7 @@ Test: "Does this describe what happens in the world, or only in the software?" I
|
|
|
350
391
|
### Operational Rules
|
|
351
392
|
|
|
352
393
|
- **English only** for all files in \`.yggdrasil/\`. Conversation can be any language.
|
|
353
|
-
- **Read schemas before creating** any \`node.yaml\`, \`aspect.yaml\`, or \`flow.yaml\`.
|
|
394
|
+
- **Read schemas before creating** any \`yg-node.yaml\`, \`yg-aspect.yaml\`, or \`yg-flow.yaml\`.
|
|
354
395
|
- **Tools read, you write.** The \`yg\` CLI only reads, validates, and manages metadata. You create and edit files manually.
|
|
355
396
|
- **Incremental sync.** Run \`yg drift-sync\` after every 3-5 source file changes. Do not defer to end of task.
|
|
356
397
|
- **Completeness test:** Two checks, both required:
|
|
@@ -362,7 +403,7 @@ Test: "Does this describe what happens in the world, or only in the software?" I
|
|
|
362
403
|
### CLI Reference
|
|
363
404
|
|
|
364
405
|
\`\`\`
|
|
365
|
-
yg preflight [--quick] Unified diagnostic:
|
|
406
|
+
yg preflight [--quick] Unified diagnostic: drift + status + validate.
|
|
366
407
|
yg owner --file <path> Find the node that owns this file.
|
|
367
408
|
yg build-context --node <path> Assemble context package for this node.
|
|
368
409
|
yg tree [--root <path>] [--depth N] Print graph structure.
|
|
@@ -380,23 +421,19 @@ yg drift [--scope <path>|all] [--drifted-only] [--limit <n>]
|
|
|
380
421
|
Detect source and graph drift (bidirectional).
|
|
381
422
|
yg drift-sync --node <path> [--recursive] | --all
|
|
382
423
|
Record file hashes as new baseline.
|
|
383
|
-
yg journal-read Read pending journal entries.
|
|
384
|
-
yg journal-add --note "<content>" [--target <node_path>]
|
|
385
|
-
Add a journal entry.
|
|
386
|
-
yg journal-archive Archive consolidated journal entries.
|
|
387
424
|
\`\`\`
|
|
388
425
|
|
|
389
426
|
### Quick Routing Table
|
|
390
427
|
|
|
391
428
|
| What you have | Where it goes |
|
|
392
429
|
|---|---|
|
|
393
|
-
| Information specific to this node | Local node artifact (check \`config.yaml artifacts\` for types) |
|
|
430
|
+
| Information specific to this node | Local node artifact (check \`yg-config.yaml artifacts\` for types) |
|
|
394
431
|
| Rule that applies to many nodes | Aspect (content \`.md\` files in \`aspects/<id>/\`) |
|
|
395
|
-
| Architectural invariant for a node type | Required aspect in \`config.yaml node_types\` |
|
|
396
|
-
| Business process participation | Flow (\`flow.yaml participants\`) |
|
|
432
|
+
| Architectural invariant for a node type | Required aspect in \`yg-config.yaml node_types\` |
|
|
433
|
+
| Business process participation | Flow (\`yg-flow.yaml participants\`) |
|
|
397
434
|
| Process-level requirement | Flow \`aspects\` + aspect directory |
|
|
398
435
|
| Context shared across a domain | Parent node artifact |
|
|
399
|
-
| Technology stack |
|
|
400
|
-
|
|
|
436
|
+
| Technology stack | Node artifact at appropriate hierarchy level |
|
|
437
|
+
| Coding standards | Node artifact at appropriate hierarchy level |`;
|
|
401
438
|
|
|
402
439
|
export const AGENT_RULES_CONTENT = [CORE_PROTOCOL, OPERATIONS, KNOWLEDGE_BASE].join('\n\n---\n\n') + '\n';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# aspect.yaml — Schema for cross-cutting aspects
|
|
1
|
+
# yg-aspect.yaml — Schema for cross-cutting aspects
|
|
2
2
|
# Each aspect is a directory under .yggdrasil/aspects/ containing this file
|
|
3
3
|
# plus any number of .md content files (requirements, rationale, guidance).
|
|
4
4
|
# Aspect identifier = relative path from aspects/ to the directory (e.g. observability/logging).
|
|
@@ -7,3 +7,7 @@
|
|
|
7
7
|
name: CrossCuttingRequirementName # required — display name
|
|
8
8
|
description: "Short description for discovery via yg aspects" # optional
|
|
9
9
|
# implies: [other-aspect, another-aspect] # optional — other aspect identifiers included automatically (recursive, must be acyclic)
|
|
10
|
+
# stability: protocol # optional — schema | protocol | implementation
|
|
11
|
+
# schema = enforced by data model (most stable)
|
|
12
|
+
# protocol = enforced by convention/contract
|
|
13
|
+
# implementation = specific mechanism (least stable, review after any code change)
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
# config.yaml — Schema for the Yggdrasil project configuration
|
|
2
|
-
# Located at .yggdrasil/config.yaml — one per project.
|
|
1
|
+
# yg-config.yaml — Schema for the Yggdrasil project configuration
|
|
2
|
+
# Located at .yggdrasil/yg-config.yaml — one per project.
|
|
3
3
|
# Edit this after running yg init to describe your project.
|
|
4
4
|
|
|
5
|
+
version: "2.0.0" # managed by CLI — do not edit manually. Tracks the CLI version
|
|
6
|
+
# that created or last migrated this config. Used by the migration
|
|
7
|
+
# system to determine which migrations to run on upgrade.
|
|
8
|
+
|
|
5
9
|
name: "My Project" # required — project display name
|
|
6
10
|
|
|
7
11
|
stack: # required — technology stack (freeform keys)
|
|
@@ -13,22 +17,25 @@ stack: # required — technology stack (freeform keys
|
|
|
13
17
|
|
|
14
18
|
standards: "" # optional — global coding conventions (free text)
|
|
15
19
|
|
|
16
|
-
node_types: # required —
|
|
17
|
-
|
|
20
|
+
node_types: # required — non-empty object of node type definitions
|
|
21
|
+
module: # key = type name used in yg-node.yaml
|
|
22
|
+
description: "Business logic unit with clear domain responsibility"
|
|
18
23
|
# required_aspects: [] # optional — aspects every node of this type must have
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
service:
|
|
25
|
+
description: "Component providing functionality to other nodes"
|
|
26
|
+
library:
|
|
27
|
+
description: "Shared utility code with no domain knowledge"
|
|
21
28
|
|
|
22
29
|
artifacts: # required — artifact type definitions
|
|
23
30
|
responsibility.md: # key = filename in node directories
|
|
24
31
|
required: always # always | never | { when: <condition> }
|
|
25
32
|
description: "What this node is responsible for, and what it is not"
|
|
26
|
-
|
|
33
|
+
included_in_relations: true # true = included in dependency context packages
|
|
27
34
|
interface.md:
|
|
28
35
|
required:
|
|
29
36
|
when: has_incoming_relations # conditions: has_incoming_relations, has_outgoing_relations, has_aspect:<id>
|
|
30
37
|
description: "Public API — methods, parameters, return types, contracts"
|
|
31
|
-
|
|
38
|
+
included_in_relations: true
|
|
32
39
|
# Additional artifact types: logic.md, constraints.md, errors.md, model.md, state.md, decisions.md
|
|
33
40
|
|
|
34
41
|
quality: # optional — quality thresholds
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
# node.yaml — Schema for model nodes
|
|
1
|
+
# yg-node.yaml — Schema for model nodes
|
|
2
2
|
# Every node is a directory under .yggdrasil/model/ containing this file
|
|
3
|
-
# plus artifact .md files defined in config.yaml.
|
|
3
|
+
# plus artifact .md files defined in yg-config.yaml.
|
|
4
4
|
|
|
5
5
|
name: ComponentName # required — display name
|
|
6
6
|
type: service # required — must match a type from config.node_types
|
|
7
|
-
aspects: [] # optional — list of aspect identifiers (directory paths under aspects/)
|
|
8
7
|
blackbox: false # optional, default false — if true, coarse-grained coverage without deep artifacts
|
|
9
8
|
|
|
9
|
+
aspects: # optional — list of aspect configurations
|
|
10
|
+
- aspect: aspect-id # required — aspect identifier (directory path under aspects/)
|
|
11
|
+
exceptions: # optional — how this node deviates from the aspect's pattern
|
|
12
|
+
- "Description of deviation and why"
|
|
13
|
+
anchors: # optional — code patterns for aspect staleness detection
|
|
14
|
+
- functionName # yg validate checks each pattern exists in mapped source files (W014)
|
|
15
|
+
- CONSTANT_NAME
|
|
16
|
+
|
|
10
17
|
relations: # optional — outgoing dependencies to other nodes
|
|
11
18
|
- target: other/module-path # required — path relative to model/
|
|
12
19
|
type: calls # required — calls | uses | extends | implements | emits | listens
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chrisdudek/yg",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Make your repository self-aware. Persistent semantic memory and deterministic context assembly for AI agents.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -53,11 +53,13 @@
|
|
|
53
53
|
"chalk": "^5.6.2",
|
|
54
54
|
"commander": "^14.0.3",
|
|
55
55
|
"ignore": "^7.0.5",
|
|
56
|
+
"semver": "^7.7.4",
|
|
56
57
|
"yaml": "^2.8.2"
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|
|
59
60
|
"@eslint/js": "^10.0.1",
|
|
60
61
|
"@types/node": "^25.3.0",
|
|
62
|
+
"@types/semver": "^7.7.1",
|
|
61
63
|
"@vitest/coverage-v8": "^4.0.18",
|
|
62
64
|
"eslint": "^10.0.1",
|
|
63
65
|
"prettier": "^3.8.1",
|