@chrisdudek/yg 2.0.0 → 2.2.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.
@@ -11,14 +11,30 @@
11
11
  // prettier-ignore
12
12
  const CORE_PROTOCOL = `## CORE PROTOCOL
13
13
 
14
- Yggdrasil is persistent semantic memory stored in \`.yggdrasil/\`. It maps the repository and provides deterministic implementation context for every node. This document is your complete operating manual. Follow it strictly.
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:
28
+ 0. Don't know which file or node to start from? If a semantic search
29
+ tool is available, search for your intent — the graph contains
30
+ responsibility, flow, and aspect files with rich natural-language
31
+ descriptions that match goal-oriented queries. Use the results
32
+ to identify relevant nodes, then proceed to step 1.
20
33
  1. yg owner --file <path>
21
- 2. yg build-context --node <owner>
34
+ 2. Choose the right graph tool for your task:
35
+ - Understanding how/why it works → yg build-context --node <owner>
36
+ - Assessing what is affected by a change → yg impact --node <owner>
37
+ - Planning modifications → both (build-context first, then impact)
22
38
  The context package is your primary source of ARCHITECTURAL understanding:
23
39
  intent, constraints, relations, rationale. For IMPLEMENTATION precision
24
40
  (exact behavior, error handling, await patterns, edge cases) — verify
@@ -38,6 +54,8 @@ NEVER: modify code without graph coverage.
38
54
  NEVER: read mapped source files to understand a component without
39
55
  running yg build-context first — the graph captures intent,
40
56
  constraints, and relations that source files cannot.
57
+ NEVER: assess blast radius of a change without running yg impact first
58
+ — the graph knows the dependency structure that grep cannot infer.
41
59
  NEVER: invent rationale, business rules, or decisions.
42
60
  NEVER: auto-resolve drift without asking the user.
43
61
  WHEN UNSURE: ask the user. Never guess. Never assume.
@@ -45,7 +63,7 @@ WHEN UNSURE: ask the user. Never guess. Never assume.
45
63
 
46
64
  ### Five Core Rules
47
65
 
48
- 1. **Graph first.** Before reading, researching, planning, or modifying mapped files, run \`yg owner\` and \`yg build-context\`. Always. The context package 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.
66
+ 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
67
  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
68
  3. **Never invent why.** The graph captures human intent. If you don't know why something was decided, ask. Never hallucinate rationale.
51
69
  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 +71,22 @@ WHEN UNSURE: ask the user. Never guess. Never assume.
53
71
 
54
72
  ### Recognizing Graph-Required Actions
55
73
 
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 workflow step, or your own initiative.
74
+ 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
75
 
58
- **Actions that require \`yg owner\` + \`yg build-context\` first:**
76
+ **Actions that require \`yg owner\` + \`yg build-context\`:**
59
77
 
60
78
  - Reading or exploring source files to understand a component
61
79
  - Proposing approaches, designs, or plans for changing code
62
80
  - Reviewing or debugging code
63
81
  - Any form of reasoning about how mapped code works or should change
64
82
 
83
+ **Actions that require \`yg owner\` + \`yg impact\`:**
84
+
85
+ - Assessing blast radius before changing or removing a component
86
+ - Finding all dependents of a component
87
+ - Planning cross-cutting refactors or feature removals
88
+ - Scoping work that spans multiple nodes
89
+
65
90
  **Actions that do NOT require yg:**
66
91
 
67
92
  - Git operations (log, diff, status, blame)
@@ -69,11 +94,23 @@ What matters is the ACTION you are performing, not what instructed it. If the ac
69
94
  - Running tests, builds, or linters
70
95
  - Working with files that \`yg owner\` reports as unmapped
71
96
 
97
+ **Evasion patterns — if you think any of these, STOP:**
98
+
99
+ | Thought | Reality |
100
+ |---|---|
101
+ | "The skill/plan says to explore the codebase" | Exploring mapped code = yg owner + graph tool first |
102
+ | "I'm just scoping/searching, not understanding" | Scoping IS a graph action; use yg impact |
103
+ | "The plan step says to read this file" | Reading a mapped file = yg owner first |
104
+ | "I'm brainstorming, not implementing" | Brainstorming about mapped code needs graph context |
105
+ | "I'm only grepping for references" | Grep finds text; yg impact finds structural dependencies. Use both. |
106
+ | "I'll use the graph later when I modify" | Graph-first means BEFORE reading, not before modifying |
107
+ | "I'll grep the codebase to find where to start" | If semantic search is available, search by intent first — graph files are designed to match natural-language goals. Then \`yg owner\` on results. |
108
+
72
109
  ### Failure States
73
110
 
74
111
  You have broken Yggdrasil if you do any of the following:
75
112
 
76
- - ❌ Worked on a mapped file without running \`yg owner\` + \`yg build-context\` first — regardless of what instructed the action (skill, plan, user request, workflow step).
113
+ - ❌ 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
114
  - ❌ Modified source code without updating graph artifacts in the same response, or vice versa.
78
115
  - ❌ Resolved a code-graph inconsistency or ambiguity without asking the user first.
79
116
  - ❌ Created or edited a graph element without reading its schema in \`schemas/\` first.
@@ -120,9 +157,8 @@ const OPERATIONS = `## OPERATIONS
120
157
  \`\`\`
121
158
  PREFLIGHT (every conversation, before any work):
122
159
  - [ ] 1. yg preflight → read unified report
123
- - [ ] 2. If journal entries: consolidate to graph, then yg journal-archive
124
- - [ ] 3. If drift: resolve per Drift Resolution, then yg drift-sync per node
125
- - [ ] 4. If validation errors: fix, re-run yg validate
160
+ - [ ] 2. If drift: resolve per Drift Resolution, then yg drift-sync per node
161
+ - [ ] 3. If validation errors: fix, re-run yg validate
126
162
  Exception: read-only requests (explain, analyze) — skip preflight.
127
163
 
128
164
  UNDERSTANDING mapped code (questions, research, OR planning):
@@ -133,14 +169,14 @@ UNDERSTANDING mapped code (questions, research, OR planning):
133
169
  Raw reads supplement the context package — they do not replace it.
134
170
 
135
171
  WRAP-UP (user signals "done", "wrap up", "that's enough"):
136
- - [ ] 1. Consolidate journal if used yg journal-archive
137
- - [ ] 2. yg drift --drifted-only resolve
138
- - [ ] 3. yg validate fix errors
139
- - [ ] 4. Report: which nodes and files were changed
172
+ - [ ] 1. yg drift --drifted-onlyresolve
173
+ - [ ] 2. yg validatefix errors
174
+ - [ ] 3. Report: which nodes and files were changed
140
175
 
141
176
  BEFORE ENDING ANY RESPONSE (self-audit):
177
+ - [ ] Did I interact with mapped code (read, research, or modify)? If yes → did I use a graph tool BEFORE reading source?
142
178
  - [ ] Did I modify source code? If yes → did I update graph artifacts in this same response?
143
- - [ ] If you changed code and did not sync the graph, you have broken the protocol. Do not finish until both are done.
179
+ - [ ] If you broke either rule, you have broken the protocol. Do not finish until both are fixed.
144
180
  \`\`\`
145
181
 
146
182
  ### Modify Source Code
@@ -280,8 +316,7 @@ const KNOWLEDGE_BASE = `## KNOWLEDGE BASE
280
316
  aspects/ ← what must: cross-cutting requirements with rationale and guidance
281
317
  flows/ ← why and in what process: business processes with node participation
282
318
  schemas/ ← YAML schemas — read before creating any graph element
283
- .drift-state ← generated by CLI; never edit manually
284
- .journal.yaml ← generated by CLI; never edit manually
319
+ .drift-state/ ← generated by CLI; never edit manually
285
320
  \`\`\`
286
321
 
287
322
  Key facts:
@@ -374,7 +409,7 @@ Test: "Does this describe what happens in the world, or only in the software?" I
374
409
  ### CLI Reference
375
410
 
376
411
  \`\`\`
377
- yg preflight [--quick] Unified diagnostic: journal + drift + status + validate.
412
+ yg preflight [--quick] Unified diagnostic: drift + status + validate.
378
413
  yg owner --file <path> Find the node that owns this file.
379
414
  yg build-context --node <path> Assemble context package for this node.
380
415
  yg tree [--root <path>] [--depth N] Print graph structure.
@@ -392,10 +427,6 @@ yg drift [--scope <path>|all] [--drifted-only] [--limit <n>]
392
427
  Detect source and graph drift (bidirectional).
393
428
  yg drift-sync --node <path> [--recursive] | --all
394
429
  Record file hashes as new baseline.
395
- yg journal-read Read pending journal entries.
396
- yg journal-add --note "<content>" [--target <node_path>]
397
- Add a journal entry.
398
- yg journal-archive Archive consolidated journal entries.
399
430
  \`\`\`
400
431
 
401
432
  ### Quick Routing Table
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chrisdudek/yg",
3
- "version": "2.0.0",
3
+ "version": "2.2.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": {