@chrisdudek/yg 2.5.1 → 2.7.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/dist/bin.js +202 -168
- package/dist/bin.js.map +1 -1
- package/dist/templates/rules.ts +27 -11
- package/graph-schemas/yg-flow.yaml +1 -0
- package/graph-schemas/yg-node.yaml +1 -0
- package/package.json +1 -1
package/dist/templates/rules.ts
CHANGED
|
@@ -36,7 +36,8 @@ BEFORE reading, researching, planning, OR modifying ANY mapped file:
|
|
|
36
36
|
- Assessing what is affected by a change → yg impact --node <owner>
|
|
37
37
|
- Planning modifications → both (build-context first, then impact)
|
|
38
38
|
\`yg build-context --node <path>\`. Read the YAML map for topology,
|
|
39
|
-
|
|
39
|
+
starting with the glossary at the top (aspect and flow definitions),
|
|
40
|
+
then read artifact files listed inline on each element. For quick
|
|
40
41
|
orientation, the map alone is sufficient. For implementation, read
|
|
41
42
|
all artifact files before changing code.
|
|
42
43
|
If the context package seems insufficient — enrich the graph.
|
|
@@ -104,6 +105,7 @@ What matters is the ACTION you are performing, not what instructed it. If the ac
|
|
|
104
105
|
| "I'm only grepping for references" | Grep finds text; yg impact finds structural dependencies. Use both. |
|
|
105
106
|
| "I'll use the graph later when I modify" | Graph-first means BEFORE reading, not before modifying |
|
|
106
107
|
| "I'll grep the codebase to find where to start" | Run \`yg select --task\` first — it matches your intent against graph artifacts. Then \`yg owner\` on results. |
|
|
108
|
+
| "Drift is blocking repo-check, let me just sync it" | Drift means artifacts are stale. Update artifacts first, then sync. \`drift-sync\` without artifact update = hiding staleness. |
|
|
107
109
|
|
|
108
110
|
### Failure States
|
|
109
111
|
|
|
@@ -168,9 +170,10 @@ PREFLIGHT (every conversation, before any work):
|
|
|
168
170
|
UNDERSTANDING mapped code (questions, research, OR planning):
|
|
169
171
|
- [ ] 1. yg owner --file <path>
|
|
170
172
|
- [ ] 2. Owner found → yg build-context --node <path>. Read the YAML map
|
|
171
|
-
for topology,
|
|
172
|
-
|
|
173
|
-
|
|
173
|
+
for topology, starting with the glossary at the top for aspect and
|
|
174
|
+
flow definitions, then read artifact files listed inline on each
|
|
175
|
+
element. For quick orientation, the map alone is sufficient. For
|
|
176
|
+
implementation, read all artifact files before changing code.
|
|
174
177
|
- [ ] 3. Owner not found → use file analysis, state it is not graph-backed.
|
|
175
178
|
Never use grep or raw file reads as primary understanding when graph coverage exists.
|
|
176
179
|
Raw reads supplement the context package — they do not replace it.
|
|
@@ -197,7 +200,7 @@ You are not allowed to edit or create source code without establishing graph cov
|
|
|
197
200
|
- [ ] 1. Read specification: \`yg build-context --node <node_path>\`
|
|
198
201
|
- [ ] 2. Assess blast radius: \`yg impact --node <node_path>\` — review dependents, descendants, and co-aspect nodes before changing interfaces or shared behavior
|
|
199
202
|
- [ ] 3. Modify source code
|
|
200
|
-
- [ ] 4. Sync graph artifacts — edit artifact files to reflect the changes (after each file, not batched — context is freshest immediately after the change)
|
|
203
|
+
- [ ] 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\`.
|
|
201
204
|
- [ ] 5. Run \`yg validate\` — fix all errors (if unfixable after 3 attempts → stop, report to user)
|
|
202
205
|
- [ ] 6. Run \`yg drift-sync --node <node_path>\` — only after graph and code are both current
|
|
203
206
|
|
|
@@ -215,7 +218,7 @@ You are not allowed to edit or create source code without establishing graph cov
|
|
|
215
218
|
|
|
216
219
|
1. Create aspects first (cross-cutting requirements the new code must satisfy)
|
|
217
220
|
2. Create flows if the code participates in a business process
|
|
218
|
-
3. Create nodes with full artifacts — responsibility, interface, internals
|
|
221
|
+
3. Create nodes with full artifacts — description in \`yg-node.yaml\`, responsibility, interface, internals
|
|
219
222
|
4. Review the context package (\`yg build-context\`) — it is now the behavioral specification
|
|
220
223
|
5. Implement code that satisfies the specification
|
|
221
224
|
6. The graph specifies WHAT and WHY; the code implements HOW (framework APIs, library choices)
|
|
@@ -240,6 +243,7 @@ Per area checklist:
|
|
|
240
243
|
- [ ] 1. \`yg owner --file <path>\` — confirm no coverage
|
|
241
244
|
- [ ] 2. Determine node granularity — propose to user if unclear
|
|
242
245
|
- [ ] 3. Create node directory, read \`schemas/yg-node.yaml\`, create \`yg-node.yaml\`
|
|
246
|
+
- [ ] 3b. Write \`description\` in \`yg-node.yaml\` — a short summary of what the node does
|
|
243
247
|
- [ ] 4. Analyze source — for each artifact type in \`yg-config.yaml artifacts\`: extract content, do not invent
|
|
244
248
|
- [ ] 5. Identify relations — add to \`yg-node.yaml\`
|
|
245
249
|
- [ ] 6. Identify cross-cutting requirements — add matching aspects, create if needed
|
|
@@ -310,7 +314,7 @@ When reviewing graph quality (triggered by user or quality improvement):
|
|
|
310
314
|
- **Budget warning (W005/W006)** → informational. \`yg validate\` shows a breakdown (own/hierarchy/aspects/flows/dependencies). Large inherited context means the system is complex — this is not a problem to fix, it is reality to acknowledge. Do not delete knowledge from artifacts. Do not attempt to "reduce" inherited context.
|
|
311
315
|
- **Own budget warning (W015)** → own artifacts are large. Consider splitting this node's responsibilities into child nodes. Redistribute knowledge across children so total knowledge is preserved or increased, never reduced.
|
|
312
316
|
- **Corrupted \`.yggdrasil/\` files** → report to user. Do not attempt repair.
|
|
313
|
-
- **Incremental sync** → run \`yg drift-sync\` every 3-5 source files during multi-file tasks. Do not defer to end.`;
|
|
317
|
+
- **Incremental sync** → run \`yg drift-sync\` every 3-5 source files during multi-file tasks. Do not defer to end. But NEVER run \`yg drift-sync\` to silence a failing drift check — drift is a signal that artifacts need updating. First update artifacts, then sync.`;
|
|
314
318
|
|
|
315
319
|
// prettier-ignore
|
|
316
320
|
const KNOWLEDGE_BASE = `## KNOWLEDGE BASE
|
|
@@ -349,9 +353,20 @@ Projects can define additional artifact types in \`yg-config.yaml\` under \`arti
|
|
|
349
353
|
|
|
350
354
|
### Context Assembly
|
|
351
355
|
|
|
352
|
-
**Reading context:** \`yg build-context --node <path>\` returns a YAML map
|
|
356
|
+
**Reading context:** \`yg build-context --node <path>\` returns a YAML map structured as follows:
|
|
353
357
|
|
|
354
|
-
|
|
358
|
+
- **\`glossary\`** (top) — definitions for every aspect and flow referenced in the map, each with \`files\` listing their artifact paths. Read this first to understand IDs used throughout.
|
|
359
|
+
- **\`node\`** — the target node with inline \`files\` (its artifact paths). No \`yg-node.yaml\` in file lists.
|
|
360
|
+
- **\`hierarchy\`** — ancestor and sibling nodes, each with inline \`files\`.
|
|
361
|
+
- **\`dependencies\`** — dependency nodes, each with inline \`files\`.
|
|
362
|
+
- **\`meta\`** (bottom) — context assembly metadata.
|
|
363
|
+
- YAML comments before each section guide reading order.
|
|
364
|
+
|
|
365
|
+
All artifact paths are relative to \`.yggdrasil/\` — construct full path as \`.yggdrasil/<path>\`.
|
|
366
|
+
|
|
367
|
+
**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.
|
|
368
|
+
|
|
369
|
+
The glossary at the top defines all aspects and flows — read it first to understand IDs used throughout.
|
|
355
370
|
|
|
356
371
|
**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.
|
|
357
372
|
|
|
@@ -400,7 +415,7 @@ When code anchors (\`anchors\` in an aspect entry in \`yg-node.yaml\`) are prese
|
|
|
400
415
|
|
|
401
416
|
- [ ] 1. Read \`schemas/yg-flow.yaml\`
|
|
402
417
|
- [ ] 2. Create \`flows/<name>/\` directory
|
|
403
|
-
- [ ] 3. Write \`yg-flow.yaml\` —
|
|
418
|
+
- [ ] 3. Write \`yg-flow.yaml\` — name, description, nodes (participant list), and flow-level aspects
|
|
404
419
|
- [ ] 4. Write \`description.md\` with required sections: Business context, Trigger, Goal, Participants, Paths (at least Happy path), Invariants across all paths
|
|
405
420
|
- [ ] 5. \`yg validate\`
|
|
406
421
|
|
|
@@ -413,7 +428,8 @@ Test: "Does this describe what happens in the world, or only in the software?" I
|
|
|
413
428
|
- **English only** for all files in \`.yggdrasil/\`. Conversation can be any language.
|
|
414
429
|
- **Read schemas before creating** any \`yg-node.yaml\`, \`yg-aspect.yaml\`, or \`yg-flow.yaml\`.
|
|
415
430
|
- **Tools read, you write.** The \`yg\` CLI only reads, validates, and manages metadata. You create and edit files manually.
|
|
416
|
-
- **Incremental sync.** Run \`yg drift-sync\` after every 3-5 source file changes. Do not defer to end of task.
|
|
431
|
+
- **Incremental sync.** Run \`yg drift-sync\` after every 3-5 source file changes. Do not defer to end of task. \`drift-sync\` is ONLY safe after artifacts are current — never use it to silence a drift check without updating artifacts first.
|
|
432
|
+
- **Description maintenance.** Every \`yg-node.yaml\`, \`yg-aspect.yaml\`, and \`yg-flow.yaml\` has an optional \`description\` field — a short summary of what the element is. Write it when creating new elements. Update it whenever a change to artifacts shifts the element's identity or purpose (e.g., responsibility split, scope change). Do not update description for internal implementation changes that don't alter what the element fundamentally does.
|
|
417
433
|
- **Completeness test:** Two checks, both required:
|
|
418
434
|
1. **Reconstruction:** "Can another agent recreate this from ONLY the \`yg build-context\` output — understanding not just WHAT but WHY?" Test: rejected alternatives, correct algorithm, design arguments.
|
|
419
435
|
2. **Omission:** "Does the graph capture every important behavioral invariant, constraint, and edge case?" Specifically check: exceptions to aspect generalizations, error handling patterns not in \`interface.md\`, concurrency behaviors not in \`internals.md\`.
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
# plus description.md with required sections (see rules).
|
|
4
4
|
|
|
5
5
|
name: EndToEndProcessName # required — display name
|
|
6
|
+
description: "Short description of this business process" # optional
|
|
6
7
|
nodes: # required, non-empty — participant nodes (alias: participants)
|
|
7
8
|
- orders/order-service # paths relative to model/
|
|
8
9
|
- payments/payment-service
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
name: ComponentName # required — display name
|
|
6
6
|
type: service # required — must match a type from config.node_types
|
|
7
|
+
description: "Short description of what this node does" # optional
|
|
7
8
|
blackbox: false # optional, default false — if true, coarse-grained coverage without deep artifacts
|
|
8
9
|
|
|
9
10
|
aspects: # optional — list of aspect configurations
|