@chrisdudek/yg 2.12.0 → 3.0.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.
@@ -1,4 +1,4 @@
1
- export const DEFAULT_CONFIG = `version: "2.0.0"
1
+ export const DEFAULT_CONFIG = `version: "3.0.0"
2
2
 
3
3
  name: ""
4
4
 
@@ -12,20 +12,6 @@ node_types:
12
12
  infrastructure:
13
13
  description: "Guards, middleware, interceptors — invisible in call graphs but affect blast radius"
14
14
 
15
- artifacts:
16
- responsibility.md:
17
- required: always
18
- description: "What this node is responsible for, and what it is not"
19
- included_in_relations: true
20
- interface.md:
21
- required:
22
- when: has_incoming_relations
23
- description: "Public API — methods, parameters, return types, contracts, failure modes, exposed data structures"
24
- included_in_relations: true
25
- internals.md:
26
- required: never
27
- description: "How the node works and why — algorithms, business rules, state machines, design decisions with rejected alternatives"
28
-
29
15
  quality:
30
16
  min_artifact_length: 50
31
17
  max_direct_relations: 10
@@ -16,14 +16,30 @@ This is your operating manual for working in a Yggdrasil-managed repository.
16
16
 
17
17
  <critical_protocol>
18
18
  BEFORE starting any task — brainstorming, design, planning, OR implementation:
19
- \`yg select --task "<goal>"\` → \`yg build-context\` on each result → read ALL artifact files
20
- This is how you learn WHAT the system already knows before proposing anything.
19
+ \`yg select --task "<goal>"\` → \`yg build-context\` on each result → read artifact files.
20
+ This is the READING phase collect constraints that shape your design:
21
+ - Aspects = cross-cutting requirements your work MUST satisfy. Read their content files — not just the YAML description. The rules are inside.
22
+ - Flows = business processes your work must not break. Read invariants.
23
+ - Relations = interfaces your code consumes or that consume your code. Changes without checking dependents break contracts silently.
24
+ - Parent artifacts = inherited context not repeated in child nodes.
25
+ Internalize these constraints BEFORE designing your approach. This is the moment that determines quality — everything after follows from what you learn here.
21
26
 
22
27
  BEFORE reading, analyzing, or modifying ANY source file:
23
28
  \`yg build-context --file <path>\`
24
- One command. No exceptions. No "I'll do it later." No "this is just analysis."
25
-
26
- Both triggers apply regardless of what instructed the task — skills, plans, workflows, user requests.
29
+ Resolves owner, gives you local context (node artifacts, dependencies).
30
+ If you have NOT done the task-level READING phase above — stop and do it now. File-level work without task-level constraints leads to code that violates cross-cutting requirements.
31
+
32
+ WHEN spec/external documents are provided AND work is greenfield:
33
+ BEFORE creating any feature aspect, node, or code — do this first:
34
+ 1. Read ALL spec documents completely.
35
+ 2. Separate two categories of knowledge in the specs:
36
+ a) Knowledge that WILL map to source files (feature behavior, UI, API) → this goes to node artifacts later.
37
+ b) Knowledge that will NEVER appear in source code (business strategy, target audience, pricing rationale, quality targets, what the system deliberately does NOT do and why) → this must go to the graph NOW, because there will be no source-file trigger to capture it later.
38
+ 3. For category (b): create root node and/or aspects immediately. This is the only moment this knowledge can be captured. Once you start coding, you will forget it.
39
+ 4. NOW create feature aspects, flows, and implementation nodes for category (a).
40
+ Test before moving on: if all spec files were deleted right now, does the graph contain everything a future agent needs — not just HOW the system works, but WHY it exists, WHO it serves, and WHAT value it delivers? If no → add the missing knowledge before continuing.
41
+
42
+ All three triggers apply regardless of what instructed the task — skills, plans, workflows, user requests.
27
43
  The graph captures intent and relations that source files cannot — without it, you will make wrong decisions and the user will have to re-explain what the graph already knows.
28
44
  </critical_protocol>
29
45
 
@@ -38,21 +54,24 @@ Yggdrasil is persistent semantic memory stored in \`.yggdrasil/\`. It maps the r
38
54
  EVERY conversation: yg preflight — no exceptions.
39
55
 
40
56
  BEFORE any task (brainstorming, design, planning, implementation):
41
- yg select --task "<goal>" → yg build-context on results → read ALL artifacts
42
- The graph is your primary knowledge source. Raw file reads supplement it, never replace it.
57
+ yg select --task "<goal>" → yg build-context on results
58
+ READ phase collect constraints before designing:
59
+ - Aspects: read content files (not just YAML description). Rules are inside.
60
+ - Flows: read invariants. Your changes must not break business processes.
61
+ - Relations: check interfaces — who depends on you, who you depend on.
62
+ - Parent artifacts: inherited context not repeated in child nodes.
63
+ This is the moment that determines quality. Everything after follows from here.
43
64
 
44
65
  BEFORE any source file interaction:
45
- 1. yg build-context --file <path>
46
- One command: resolves owner, assembles context.
47
- Read the YAML mapglossary first (aspect/flow definitions),
48
- then artifact files listed on each element.
49
- For blast radius: also run yg impact --file <path>.
50
- Don't know where to start? yg select --task "<goal>"
66
+ yg build-context --file <path>
67
+ Resolves owner. Read local node artifacts.
68
+ If you skipped the task-level READ phase above do it now before proceeding.
69
+ For blast radius: also run yg impact --file <path>.
51
70
 
52
71
  AFTER modifying:
53
- 2. Update graph artifacts (per file, not batched)
54
- 3. yg validate — fix all errors
55
- 4. yg drift-sync --node <owner>
72
+ Update graph artifacts (per file, not batched)
73
+ yg validate — fix all errors
74
+ yg drift-sync --node <owner>
56
75
 
57
76
  ALWAYS: establish graph coverage before modifying code.
58
77
  ALWAYS: run yg build-context --file before reading source.
@@ -70,9 +89,9 @@ You are not allowed to edit or create source code without establishing graph cov
70
89
 
71
90
  **Step 2a** — Owner found: execute checklist:
72
91
 
73
- - [ ] 1. Read the context package (already assembled by step 1)
92
+ - [ ] 1. Read local node artifacts (responsibility, interface, internals) and dependency interfaces from the context package. Cross-cutting constraints (aspects, flows) should already be internalized from the task-level READ phase — if not, stop and do it now.
74
93
  - [ ] 2. Assess blast radius: \`yg impact --node <node_path>\` — review dependents, descendants, and co-aspect nodes before changing interfaces or shared behavior
75
- - [ ] 3. Modify source code
94
+ - [ ] 3. Modify source code. When implementing logic subject to an aspect (e.g., writing a save function on a node with the autosave aspect), re-read that aspect's content file NOW — don't rely on memory from the task-level READ phase. Aspect rules are specific (exact timings, error handling patterns, UI details) and fade from working memory. Read them at the moment you need them.
76
95
  - [ ] 4. Sync graph artifacts — edit artifact files to reflect the changes (after each file, not batched — context is freshest immediately after the change). If the node's purpose changed, update \`description\` in \`yg-node.yaml\`.
77
96
  - [ ] 4b. If you split, merged, or renamed a node: run \`yg flows\` and update any flow \`nodes\` lists that referenced the old node path to point to the correct child/new nodes.
78
97
  - [ ] 5. Run \`yg validate\` — fix all errors (if unfixable after 3 attempts → stop, report to user)
@@ -90,12 +109,14 @@ You are not allowed to edit or create source code without establishing graph cov
90
109
 
91
110
  *Greenfield (new code):* Only Option A. Blackbox is forbidden for new code. Follow the graph-first workflow:
92
111
 
112
+ 0. **If spec/external documents exist:** route ALL knowledge from specs to the graph per the Information Routing table BEFORE any feature work. Use the appropriate location for each piece of knowledge — root node, aspects, flows, or node artifacts depending on its nature.
93
113
  1. Create aspects first (cross-cutting requirements the new code must satisfy)
94
114
  2. Create flows if the code participates in a business process
95
115
  3. Create nodes with full artifacts — description in \`yg-node.yaml\`, responsibility, interface, internals
96
116
  4. Review the context package (\`yg build-context\`) — it is now the behavioral specification
97
- 5. Implement code that satisfies the specification
98
- 6. The graph specifies WHAT and WHY; the code implements HOW (framework APIs, library choices)
117
+ 5. Implement code that satisfies the specification. Every source file must be mapped — including shared utilities, types, and helpers.
118
+ 6. After implementing each node, write \`internals.md\` with a ## Decisions section. Record every design choice: "Chose X over Y because Z." This is required in greenfield — not optional. Every node has design decisions (data model shape, algorithm, library, UI pattern). If you made a choice between alternatives, document it now — you will not remember later.
119
+ 7. The graph specifies WHAT and WHY; the code implements HOW (framework APIs, library choices)
99
120
 
100
121
  **Node sizing rule:** One node per cohesive feature area, NOT per directory. If a node would map >10 source files or cover >3 distinct user workflows, split it into child nodes. Example: an admin panel should be \`admin/blog\`, \`admin/gallery\`, \`admin/clients\`, \`admin/orders\` — not one \`admin-pages\` node. The CLI enforces this with W017, but plan granularity upfront rather than splitting after the fact.
101
122
 
@@ -150,13 +171,15 @@ Result: graph is stale, next agent asks user the same questions
150
171
  User: "Here are the spec docs. Implement the admin blog editor."
151
172
 
152
173
  1. Read ALL spec docs (blog-editor.md, autosave.md, user-persona.md, version-history.md)
153
- 2. Extract cross-cutting patterns create aspects (admin-ux-rules, autosave, version-history) if they don't exist
154
- 3. Create flow if the blog participates in a business process
155
- 4. Create node admin/blog with artifacts populated from spec (responsibility, interface, internals)
156
- 5. Run yg build-context the context package is now the behavioral specification
157
- 6. Implement code that satisfies the specification
158
- 7. Update artifacts with any implementation details that emerged during coding
159
- 8. yg validate, yg drift-sync
174
+ 2. Route all knowledge from spec docs to the graph per Information Routing table — business context to root node artifacts, cross-cutting requirements to aspects, business processes to flows, feature specs to node artifacts
175
+ 3. Extract cross-cutting patterns create aspects (admin-ux-rules, autosave, version-history) if they don't exist
176
+ 4. Create flow if the blog participates in a business process
177
+ 5. Create node admin/blog with artifacts populated from spec (responsibility, interface, internals)
178
+ 6. Run yg build-context the context package is now the behavioral specification
179
+ 7. Implement code that satisfies the specification
180
+ 8. Update artifacts with any implementation details that emerged during coding
181
+ 9. yg validate, yg drift-sync
182
+ Test: if spec files disappeared today, does the graph contain everything a future agent needs to understand the system?
160
183
 
161
184
  </example_correct>
162
185
 
@@ -164,13 +187,13 @@ User: "Here are the spec docs. Implement the admin blog editor."
164
187
 
165
188
  User: "Here are the spec docs. Implement the admin blog editor."
166
189
 
167
- 1. Read blog-editor.md spec
168
- 2. Implement all the codeWRONG: spec knowledge not captured in graph
169
- 3. Create node admin-pages, map 20 admin files ← WRONG: too wide, W017
190
+ 1. Read spec docs
191
+ 2. Create aspects and flow for the blog feature INCOMPLETE: knowledge from spec docs not routed to graph per Information Routing table
192
+ 3. Create node admin/blog, implement code
170
193
  4. Write responsibility.md summarizing what the code does ← WRONG: describes code, not spec intent
171
- 5. Business context (persona, UX rules, autosave rationale) lost ← WRONG: spec was input, not persisted
194
+ 5. Knowledge from spec docs lost ← WRONG: spec treated as consumed input, not persisted to graph
172
195
 
173
- Result: graph mirrors code but misses WHY. Next agent reads graph, understands HOW but not WHO it's for or WHAT UX rules govern it.
196
+ Result: graph mirrors code structure but misses everything spec docs contained that has no corresponding source file. Future agent must re-read spec files or ask the user.
174
197
 
175
198
  </example_wrong>
176
199
 
@@ -259,7 +282,7 @@ const REFERENCE = `## REFERENCE
259
282
 
260
283
  \`\`\`
261
284
  .yggdrasil/
262
- yg-config.yaml ← version, vocabulary, node types, artifact rules, required aspects
285
+ yg-config.yaml ← version, vocabulary, node types, required aspects
263
286
  model/ ← what exists: nodes, hierarchy, relations, file mappings
264
287
  aspects/ ← what must: cross-cutting requirements with rationale and guidance
265
288
  flows/ ← why and in what process: business processes with node participation
@@ -285,7 +308,7 @@ Three artifacts capture node knowledge at three levels:
285
308
 
286
309
  **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\`.
287
310
 
288
- 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.
311
+ These three artifacts are built into the CLI and are not configurable. \`responsibility.md\` is always required, \`interface.md\` is required when the node has incoming relations, and \`internals.md\` is always optional.
289
312
 
290
313
  ### Context Assembly
291
314
 
@@ -300,9 +323,14 @@ Projects can define additional artifact types in \`yg-config.yaml\` under \`arti
300
323
 
301
324
  All artifact paths are relative to \`.yggdrasil/\` — construct full path as \`.yggdrasil/<path>\`.
302
325
 
303
- **Default mode (paths-only):** Use for all graph operations. Read the YAML map first — start with the \`glossary\` to understand aspects and flows, then the \`node\` section for the target. Read artifact files inline on each element using the Read tool. For quick orientation (scoping, blast radius assessment), the map alone is sufficient. For implementation or modification, read all artifact files before changing code.
326
+ **Default mode (paths-only):** Use for all graph operations. Read the YAML map, then read artifact files with purpose:
327
+
328
+ 1. **Glossary first** — defines aspects and flows. Aspects are constraints your implementation must satisfy (not background reading). Flows are business processes whose invariants you must not break.
329
+ 2. **Node section** — your target's own artifacts. Read before modifying.
330
+ 3. **Hierarchy** — parent artifacts contain inherited requirements not repeated in child nodes.
331
+ 4. **Dependencies** — interfaces you consume or that consume you. Read before changing contracts.
304
332
 
305
- The glossary at the top defines all aspects and flowsread it first to understand IDs used throughout.
333
+ A typical context package is ~8K tokens (less than a single source file). Read ALL artifact files listed the cost is low, the risk of skipping is high (violating constraints you didn't know about).
306
334
 
307
335
  **Full mode (\`--full\`):** Use only when you cannot read files individually — e.g., when pasting context into a prompt, sharing with a user, or when you have no Read tool available.
308
336
 
@@ -312,7 +340,7 @@ Artifact paths are stable identifiers within a session. When building context fo
312
340
 
313
341
  When you encounter information, route it to the correct location:
314
342
 
315
- - **Specific to this node** → local node artifact (check \`yg-config.yaml artifacts\` for available types)
343
+ - **Specific to this node** → local node artifact (\`responsibility.md\`, \`interface.md\`, or \`internals.md\` depending on the knowledge type)
316
344
  - **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\`
317
345
  - **Business process** → flow (\`flows/<name>/\` with \`yg-flow.yaml\` + \`description.md\`). Ask user if process unclear.
318
346
  - **Shared across a domain** → parent node artifact. Children receive it through hierarchy.
@@ -423,6 +451,7 @@ yg owner --file <path> Find the node that owns this file (quick che
423
451
  yg build-context --file <path> Resolve owner + assemble context in one step.
424
452
  yg build-context --node <path> Assemble context map for a known node.
425
453
  yg build-context --node <path> --full Same map + file contents appended below separator.
454
+ yg build-context --file <path> --self Own artifacts only (no hierarchy/deps/aspects/flows).
426
455
  yg tree [--root <path>] [--depth N] Print graph structure.
427
456
  yg aspects List aspects with metadata (YAML output).
428
457
  yg flows List flows with metadata (YAML output).
@@ -447,7 +476,7 @@ yg drift-sync --node <path> [--recursive] | --all
447
476
 
448
477
  | What you have | Where it goes |
449
478
  |---|---|
450
- | Information specific to this node | Local node artifact (check \`yg-config.yaml artifacts\` for types) |
479
+ | Information specific to this node | Local node artifact (\`responsibility.md\`, \`interface.md\`, or \`internals.md\`) |
451
480
  | Rule that applies to many nodes | Aspect (content \`.md\` files in \`aspects/<id>/\`) |
452
481
  | Architectural invariant for a node type | Required aspect in \`yg-config.yaml node_types\` |
453
482
  | Business process participation | Flow (\`yg-flow.yaml nodes\`) |
@@ -524,11 +553,15 @@ What matters is the ACTION you are performing, not what instructed it. If the ac
524
553
  | "Flows can wait until I understand the full system" | Flows capture business processes from specs. Create them BEFORE implementing — they are part of the specification, not an afterthought. |
525
554
  | "I split the node but the flow still works" | Flow participants reference specific node paths. After a split, old paths are stale. Run \`yg flows\` and update. |
526
555
  | "This is just CRUD, not a business process" | A user performing a sequence of steps toward a goal IS a business process — even single-actor workflows (publish blog, manage portfolio, fulfill order). Create a flow. |
556
+ | "The context package is too large to read" | A typical context package is ~8K tokens — less than one source file. Read ALL of it. |
557
+ | "I have a plan, I don't need graph context" | A plan is not a substitute for graph context. Plans capture task steps; the graph captures cross-cutting aspects, flows, and conventions that plans may not repeat. Always run \`build-context\`. |
558
+ | "The user told me what to do, that's my plan" | A verbal instruction is not a written plan. And even a written plan does not exempt you from the graph protocol. |
527
559
 
528
560
  ### Failure States
529
561
 
530
562
  You have broken Yggdrasil if you do any of the following:
531
563
 
564
+ - ❌ Started brainstorming, design, or planning without running \`yg select --task\` and reading graph context first. The graph contains aspects, flows, and conventions that MUST inform design decisions.
532
565
  - ❌ Worked on a source file without running \`yg build-context --file\` first — regardless of what instructed the action (skill, plan, user request, workflow step).
533
566
  - ❌ Modified source code without updating graph artifacts before moving to the next file, or vice versa.
534
567
  - ❌ Batched graph updates to "do later" — deferred = forgotten. Update after EACH file.
@@ -558,7 +591,7 @@ Per area checklist:
558
591
  - [ ] 2. Determine node granularity — propose to user if unclear
559
592
  - [ ] 3. Create node directory, read \`schemas/yg-node.yaml\`, create \`yg-node.yaml\`
560
593
  - [ ] 3b. Write \`description\` in \`yg-node.yaml\` — a short summary of what the node does
561
- - [ ] 4. Analyze source — for each artifact type in \`yg-config.yaml artifacts\`: extract content, do not invent
594
+ - [ ] 4. Analyze source — write \`responsibility.md\`, \`interface.md\`, and \`internals.md\` from code analysis, do not invent
562
595
  - [ ] 5. Identify relations — add to \`yg-node.yaml\`
563
596
  - [ ] 6. Identify cross-cutting requirements — add matching aspects, create if needed
564
597
  - [ ] 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\`
@@ -2,7 +2,7 @@
2
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
5
+ version: "3.0.0" # managed by CLI — do not edit manually. Tracks the CLI version
6
6
  # that created or last migrated this config. Used by the migration
7
7
  # system to determine which migrations to run on upgrade.
8
8
 
@@ -17,17 +17,8 @@ node_types: # required — non-empty object of node type d
17
17
  library:
18
18
  description: "Shared utility code with no domain knowledge"
19
19
 
20
- artifacts: # required artifact type definitions
21
- responsibility.md: # key = filename in node directories
22
- required: always # always | never | { when: <condition> }
23
- description: "What this node is responsible for, and what it is not"
24
- included_in_relations: true # true = included in dependency context packages
25
- interface.md:
26
- required:
27
- when: has_incoming_relations # conditions: has_incoming_relations, has_outgoing_relations, has_aspect:<id>
28
- description: "Public API — methods, parameters, return types, contracts"
29
- included_in_relations: true
30
- # Additional artifact types: logic.md, constraints.md, errors.md, model.md, state.md, decisions.md
20
+ # artifacts are hardcoded in the CLI (responsibility.md, interface.md, internals.md)
21
+ # and cannot be configured. See STANDARD_ARTIFACTS in source code.
31
22
 
32
23
  quality: # optional — quality thresholds
33
24
  min_artifact_length: 50 # minimum characters for an artifact (warning if below)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chrisdudek/yg",
3
- "version": "2.12.0",
3
+ "version": "3.0.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": {