@chrisdudek/yg 2.3.2 → 2.4.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 -1
- package/dist/bin.js +462 -156
- package/dist/bin.js.map +1 -1
- package/dist/templates/rules.ts +26 -13
- package/package.json +1 -1
package/dist/templates/rules.ts
CHANGED
|
@@ -35,11 +35,10 @@ BEFORE reading, researching, planning, OR modifying ANY mapped file:
|
|
|
35
35
|
- Understanding how/why it works → yg build-context --node <owner>
|
|
36
36
|
- Assessing what is affected by a change → yg impact --node <owner>
|
|
37
37
|
- Planning modifications → both (build-context first, then impact)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
implementations may deviate.
|
|
38
|
+
\`yg build-context --node <path>\`. Read the YAML map for topology,
|
|
39
|
+
then read artifact files listed in the artifacts section. For quick
|
|
40
|
+
orientation, the map alone is sufficient. For implementation, read
|
|
41
|
+
all artifact files before changing code.
|
|
43
42
|
If the context package seems insufficient — enrich the graph.
|
|
44
43
|
|
|
45
44
|
AFTER modifying:
|
|
@@ -64,7 +63,7 @@ WHEN UNSURE: ask the user. Never guess. Never assume.
|
|
|
64
63
|
### Five Core Rules
|
|
65
64
|
|
|
66
65
|
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.
|
|
67
|
-
2. **
|
|
66
|
+
2. **The graph is the specification; code implements it.** The graph absorbs knowledge from every source — external docs, conversations, decisions — and must be self-sufficient. If all other sources disappeared, the graph alone must contain enough to understand the system. Do not leave knowledge in external documents and reference them — capture the knowledge in graph artifacts. Update graph artifacts immediately after each file change, while context is fresh — do not batch graph updates to the end of a task. Code and graph move together: code changed → graph updated before moving to the next file. Graph changed → source verified in the same response. When planning work — in any tool, skill, or workflow — graph updates are part of each step's definition of done, never a separate phase.
|
|
68
67
|
3. **Never invent why.** The graph captures human intent. If you don't know why something was decided, ask. Never hallucinate rationale.
|
|
69
68
|
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.
|
|
70
69
|
5. **Ask before resolving ambiguity.** When multiple valid interpretations exist, stop, list options, ask the user. Never silently choose.
|
|
@@ -111,7 +110,7 @@ What matters is the ACTION you are performing, not what instructed it. If the ac
|
|
|
111
110
|
You have broken Yggdrasil if you do any of the following:
|
|
112
111
|
|
|
113
112
|
- ❌ 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).
|
|
114
|
-
- ❌ Modified source code without updating graph artifacts
|
|
113
|
+
- ❌ Modified source code without updating graph artifacts before moving to the next file, or vice versa.
|
|
115
114
|
- ❌ Resolved a code-graph inconsistency or ambiguity without asking the user first.
|
|
116
115
|
- ❌ Created or edited a graph element without reading its schema in \`schemas/\` first.
|
|
117
116
|
- ❌ Ran \`yg drift-sync\` before both graph artifacts and source code are current.
|
|
@@ -145,9 +144,13 @@ Include this as the FIRST instruction in every subagent prompt:
|
|
|
145
144
|
|
|
146
145
|
\`\`\`
|
|
147
146
|
BEFORE doing anything else: read .yggdrasil/agent-rules.md and follow its protocol.
|
|
147
|
+
DELIVERABLES — all required, incomplete work will be rejected:
|
|
148
|
+
1. Working source code
|
|
149
|
+
2. Graph nodes with artifacts for every new/modified source file
|
|
150
|
+
3. \`yg validate\` passing
|
|
148
151
|
\`\`\`
|
|
149
152
|
|
|
150
|
-
A subagent that
|
|
153
|
+
A subagent that delivers code without corresponding graph updates has not completed its task. Before accepting subagent output, verify: are there new or modified source files without corresponding graph coverage? If yes, the work is incomplete.`;
|
|
151
154
|
|
|
152
155
|
// prettier-ignore
|
|
153
156
|
const OPERATIONS = `## OPERATIONS
|
|
@@ -163,7 +166,10 @@ PREFLIGHT (every conversation, before any work):
|
|
|
163
166
|
|
|
164
167
|
UNDERSTANDING mapped code (questions, research, OR planning):
|
|
165
168
|
- [ ] 1. yg owner --file <path>
|
|
166
|
-
- [ ] 2. Owner found → yg build-context --node <path>.
|
|
169
|
+
- [ ] 2. Owner found → yg build-context --node <path>. Read the YAML map
|
|
170
|
+
for topology, then read artifact files from the artifacts section.
|
|
171
|
+
For quick orientation, the map alone is sufficient. For implementation,
|
|
172
|
+
read all artifact files before changing code.
|
|
167
173
|
- [ ] 3. Owner not found → use file analysis, state it is not graph-backed.
|
|
168
174
|
Never use grep or raw file reads as primary understanding when graph coverage exists.
|
|
169
175
|
Raw reads supplement the context package — they do not replace it.
|
|
@@ -175,7 +181,7 @@ WRAP-UP (user signals "done", "wrap up", "that's enough"):
|
|
|
175
181
|
|
|
176
182
|
BEFORE ENDING ANY RESPONSE (self-audit):
|
|
177
183
|
- [ ] Did I interact with mapped code (read, research, or modify)? If yes → did I use a graph tool BEFORE reading source?
|
|
178
|
-
- [ ] Did I modify source code? If yes → did I update graph artifacts
|
|
184
|
+
- [ ] Did I modify source code? If yes → did I update graph artifacts before moving to the next file?
|
|
179
185
|
- [ ] If you broke either rule, you have broken the protocol. Do not finish until both are fixed.
|
|
180
186
|
\`\`\`
|
|
181
187
|
|
|
@@ -190,7 +196,7 @@ You are not allowed to edit or create source code without establishing graph cov
|
|
|
190
196
|
- [ ] 1. Read specification: \`yg build-context --node <node_path>\`
|
|
191
197
|
- [ ] 2. Assess blast radius: \`yg impact --node <node_path>\` — review dependents, descendants, and co-aspect nodes before changing interfaces or shared behavior
|
|
192
198
|
- [ ] 3. Modify source code
|
|
193
|
-
- [ ] 4. Sync graph artifacts — edit artifact files to reflect the changes
|
|
199
|
+
- [ ] 4. Sync graph artifacts — edit artifact files to reflect the changes (after each file, not batched — context is freshest immediately after the change)
|
|
194
200
|
- [ ] 5. Run \`yg validate\` — fix all errors (if unfixable after 3 attempts → stop, report to user)
|
|
195
201
|
- [ ] 6. Run \`yg drift-sync --node <node_path>\` — only after graph and code are both current
|
|
196
202
|
|
|
@@ -341,7 +347,13 @@ Projects can define additional artifact types in \`yg-config.yaml\` under \`arti
|
|
|
341
347
|
|
|
342
348
|
### Context Assembly
|
|
343
349
|
|
|
344
|
-
|
|
350
|
+
**Reading context:** \`yg build-context --node <path>\` returns a YAML map with the node's topology (hierarchy, dependencies, aspects, flows) and an \`artifacts\` section listing files to read. All artifact paths are relative to \`.yggdrasil/\` — construct full path as \`.yggdrasil/<path>\`.
|
|
351
|
+
|
|
352
|
+
**Default mode (paths-only):** Use for all graph operations. Read the YAML map first to understand topology. Then read artifact files from the \`artifacts\` section 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.
|
|
353
|
+
|
|
354
|
+
**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.
|
|
355
|
+
|
|
356
|
+
Artifact paths are stable identifiers within a session. When building context for multiple nodes, skip reading files you have already read — same path means same content.
|
|
345
357
|
|
|
346
358
|
### Information Routing
|
|
347
359
|
|
|
@@ -411,7 +423,8 @@ Test: "Does this describe what happens in the world, or only in the software?" I
|
|
|
411
423
|
\`\`\`
|
|
412
424
|
yg preflight [--quick] Unified diagnostic: drift + status + validate.
|
|
413
425
|
yg owner --file <path> Find the node that owns this file.
|
|
414
|
-
yg build-context --node <path> Assemble context
|
|
426
|
+
yg build-context --node <path> Assemble context map with artifact paths (default).
|
|
427
|
+
yg build-context --node <path> --full Same map + file contents appended below separator.
|
|
415
428
|
yg tree [--root <path>] [--depth N] Print graph structure.
|
|
416
429
|
yg aspects List aspects with metadata (YAML output).
|
|
417
430
|
yg flows List flows with metadata (YAML output).
|