@chrisdudek/yg 0.1.0 → 0.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.
- package/dist/bin.js +247 -192
- package/dist/bin.js.map +1 -1
- package/dist/templates/default-config.ts +12 -4
- package/dist/templates/rules.ts +133 -58
- package/package.json +1 -1
- package/graph-templates/knowledge-scope-nodes.yaml +0 -5
- package/graph-templates/knowledge-scope-tags.yaml +0 -3
- package/graph-templates/library.yaml +0 -22
- package/graph-templates/module.yaml +0 -18
- package/graph-templates/service.yaml +0 -30
|
@@ -17,25 +17,33 @@ artifacts:
|
|
|
17
17
|
responsibility.md:
|
|
18
18
|
required: always
|
|
19
19
|
description: "What this node is responsible for, and what it is not"
|
|
20
|
+
structural_context: true
|
|
20
21
|
interface.md:
|
|
21
22
|
required:
|
|
22
23
|
when: has_incoming_relations
|
|
23
24
|
description: "Public API — methods, parameters, return types, contracts"
|
|
24
25
|
structural_context: true
|
|
26
|
+
logic.md:
|
|
27
|
+
required: never
|
|
28
|
+
description: "Algorithmic flow, control flow, branching logic, decision trees — the 'how' of execution"
|
|
25
29
|
constraints.md:
|
|
26
30
|
required: never
|
|
27
31
|
description: "Validation rules, business rules, invariants"
|
|
32
|
+
structural_context: true
|
|
28
33
|
errors.md:
|
|
29
34
|
required:
|
|
30
35
|
when: has_incoming_relations
|
|
31
|
-
description: "
|
|
36
|
+
description: "Failure modes, edge cases, error conditions, recovery behavior"
|
|
32
37
|
structural_context: true
|
|
38
|
+
model.md:
|
|
39
|
+
required: never
|
|
40
|
+
description: "Data structures, schemas, entities, type definitions — the shape of data this node owns or manages"
|
|
33
41
|
state.md:
|
|
34
42
|
required: never
|
|
35
43
|
description: "State machines, lifecycle, transitions"
|
|
36
44
|
decisions.md:
|
|
37
45
|
required: never
|
|
38
|
-
description: "Local design decisions and rationale"
|
|
46
|
+
description: "Local design decisions and rationale — choices specific to this node, not system-wide"
|
|
39
47
|
|
|
40
48
|
knowledge_categories:
|
|
41
49
|
- name: decisions
|
|
@@ -49,7 +57,7 @@ quality:
|
|
|
49
57
|
min_artifact_length: 50
|
|
50
58
|
max_direct_relations: 10
|
|
51
59
|
context_budget:
|
|
52
|
-
warning:
|
|
53
|
-
error:
|
|
60
|
+
warning: 10000
|
|
61
|
+
error: 20000
|
|
54
62
|
knowledge_staleness_days: 90
|
|
55
63
|
`;
|
package/dist/templates/rules.ts
CHANGED
|
@@ -12,6 +12,16 @@ THIS PROMPT IS YOUR ENTIRE OPERATING MANUAL. Read it carefully. Follow it strict
|
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
15
|
+
## 0. ATOMIC INVARIANT — OVERRIDES EVERYTHING
|
|
16
|
+
|
|
17
|
+
**CODE ↔ GRAPH ARE ONE.**
|
|
18
|
+
- Code changed → graph artifacts MUST be updated IN THE SAME RESPONSE. No exceptions.
|
|
19
|
+
- Graph changed → source files MUST be verified/updated IN THE SAME RESPONSE. No exceptions.
|
|
20
|
+
- There is NO "code-only" response. There is NO "graph-only" response (unless explicitly a dry-run plan).
|
|
21
|
+
- If you complete a response and one side is changed but the other is not, you have VIOLATED the core contract of Yggdrasil.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
15
25
|
## 1. CORE PRINCIPLES (NON-NEGOTIABLE)
|
|
16
26
|
|
|
17
27
|
1. **Graph First, Always:** Before answering a question, modifying code, or planning a feature, you MUST consult the graph.
|
|
@@ -21,6 +31,20 @@ THIS PROMPT IS YOUR ENTIRE OPERATING MANUAL. Read it carefully. Follow it strict
|
|
|
21
31
|
5. **Tools Read, You Write:** The \`yg\` CLI tools only read, validate, and manage metadata. YOU must create and edit graph directories, \`.yaml\` files, and \`.md\` artifacts manually.
|
|
22
32
|
6. **English Only for Artifacts:** All graph artifact files (filenames from \`config.artifacts\`, in the same directory as \`node.yaml\`) MUST be written in English. Conversation can be in the user's language.
|
|
23
33
|
7. **Never Touch Operational Metadata:** NEVER manually edit \`.yggdrasil/.drift-state\` or \`.yggdrasil/.journal.yaml\`.
|
|
34
|
+
8. **Ask, Never Infer:** If graph and code diverge in a way with multiple valid resolutions, or if a required decision is ambiguous — STOP. State the ambiguity. List interpretations. Ask the user to decide. Never silently choose. Never patch without confirmation.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 1.5 FAILURE STATES
|
|
39
|
+
|
|
40
|
+
You have fundamentally broken Yggdrasil if you do any of the following:
|
|
41
|
+
- ❌ You modified source code without updating graph artifacts in the SAME response.
|
|
42
|
+
- ❌ You modified graph files without verifying/updating source code alignment in the SAME response.
|
|
43
|
+
- ❌ You resolved a code↔graph inconsistency without asking the user first.
|
|
44
|
+
- ❌ You created or edited a graph element without reading its schema in \`.yggdrasil/templates/\`.
|
|
45
|
+
- ❌ You ran \`yg drift-sync\` before updating graph artifacts.
|
|
46
|
+
- ❌ You ran \`yg drift-sync\` after a graph-only change without verifying source files.
|
|
47
|
+
- ❌ You used Blackbox coverage for greenfield/new code.
|
|
24
48
|
|
|
25
49
|
---
|
|
26
50
|
|
|
@@ -29,15 +53,15 @@ THIS PROMPT IS YOUR ENTIRE OPERATING MANUAL. Read it carefully. Follow it strict
|
|
|
29
53
|
You do not need explicit "session" commands. Follow these conversational triggers:
|
|
30
54
|
|
|
31
55
|
### A. Preflight (First message of the conversation)
|
|
32
|
-
Always execute these commands before doing anything else:
|
|
56
|
+
Always execute these commands before doing anything else. *(Exception: If the user's request is clearly read-only, like "explain this", run ONLY step 1).*
|
|
33
57
|
1. \`yg journal-read\` -> If entries exist, consolidate them into the graph, then \`yg journal-archive\`.
|
|
34
58
|
2. \`yg drift\` -> If divergence is detected, present states (\`ok\`, \`drift\`, \`missing\`, \`unmaterialized\`). Ask the user: Absorb (update graph) or Reject (re-materialize code from graph)?
|
|
35
59
|
3. \`yg status\` -> Report graph health.
|
|
36
60
|
4. \`yg validate\` -> If W008 stale-knowledge appears, update the knowledge artifacts to reflect current node state.
|
|
37
61
|
|
|
38
|
-
### B. Wrap-up
|
|
39
|
-
Triggered by phrases like: "
|
|
40
|
-
**Note: The graph should ALREADY be up to date.
|
|
62
|
+
### B. Session Verification (Wrap-up)
|
|
63
|
+
Triggered by phrases like: "we're done", "wrap up", "that's enough", "done".
|
|
64
|
+
**Note: The graph should ALREADY be up to date. If the graph requires massive updates at this stage, YOU HAVE FAILED.**
|
|
41
65
|
1. If iterative journal mode was used: consolidate notes to the graph, then \`yg journal-archive\`.
|
|
42
66
|
2. \`yg drift\` -> Check if files changed manually during the conversation.
|
|
43
67
|
3. \`yg validate\` -> Fix any structural errors.
|
|
@@ -45,64 +69,66 @@ Triggered by phrases like: "kończymy", "wrap up", "to tyle", "gotowe".
|
|
|
45
69
|
|
|
46
70
|
---
|
|
47
71
|
|
|
48
|
-
## 3. WORKFLOW: MODIFYING OR CREATING FILES
|
|
72
|
+
## 3. WORKFLOW: MODIFYING OR CREATING FILES (Code-First)
|
|
49
73
|
|
|
50
74
|
You are NOT ALLOWED to edit or create source code without establishing graph coverage first.
|
|
51
75
|
|
|
52
76
|
**Step 1: Check coverage** -> Run \`yg owner --file <path>\`
|
|
53
77
|
|
|
54
78
|
**Step 2: If Owner FOUND (The Execution Checklist)**
|
|
55
|
-
Whenever you write or edit source code, you MUST output this exact checklist in your response to the user, and execute each step BEFORE finishing your turn
|
|
56
|
-
|
|
57
|
-
- [x] 1. Read Specification (ran \`yg build-context\`)
|
|
58
|
-
- [x] 2. Modify Source Code
|
|
59
|
-
- [x] 3. Sync Graph Artifacts (manually edit the node's artifact files — filenames from \`config.artifacts\` — IMMEDIATELY to match new code behavior)
|
|
60
|
-
- [x] 4. Baseline Hash (ran \`yg drift-sync\` ONLY AFTER updating the graph)
|
|
79
|
+
Whenever you write or edit source code, you MUST output this exact checklist in your response to the user, and execute each step BEFORE finishing your turn:
|
|
61
80
|
|
|
62
|
-
|
|
81
|
+
- [ ] 1. Read Specification (ran \`yg build-context\`)
|
|
82
|
+
- [ ] 2. Modify Source Code
|
|
83
|
+
- [ ] 3. Sync Graph Artifacts (manually edit the node's artifact files IMMEDIATELY to match new code behavior)
|
|
84
|
+
- [ ] 4. Baseline Hash (ran \`yg drift-sync\` ONLY AFTER updating the graph)
|
|
63
85
|
|
|
64
86
|
**Step 3: If Owner NOT FOUND (Uncovered Area)**
|
|
65
|
-
STOP. Do not modify the code. First determine: **Is this greenfield
|
|
66
|
-
|
|
67
|
-
* **If GREENFIELD (empty directory, new project, code not yet written):** Do NOT offer blackbox. Use Option 1 only — create proper nodes (reverse engineering or upfront design) before implementing. Blackbox is forbidden for new code.
|
|
68
|
-
* **If EXISTING CODE (legacy, third-party, shipped-but-unmapped):** Present the user with 3 options and wait for their decision:
|
|
69
|
-
* **Option 1: Reverse Engineering:** Create/extend standard nodes to map the area fully before modifying.
|
|
70
|
-
* **Option 2: Blackbox Coverage:** Create a \`blackbox: true\` node at a user-chosen granularity to establish ownership without deep semantic exploration.
|
|
71
|
-
* **Option 3: Abort/Change Plan:** Do not touch the file.
|
|
87
|
+
STOP. Do not modify the code. First determine: **Is this greenfield or existing code?**
|
|
72
88
|
|
|
89
|
+
* **If GREENFIELD (empty directory, new project):** Do NOT offer blackbox. Create proper nodes (reverse engineering or upfront design) before implementing.
|
|
90
|
+
* **If PARTIALLY MAPPED (file is unmapped, but lives inside a mapped module):** Stop and ask the user if this file should be added to the existing node or if a new node is required.
|
|
91
|
+
* **If EXISTING CODE (legacy, third-party):** Present the user with 3 options and wait:
|
|
92
|
+
* **Option 1: Reverse Engineering:** Create/extend standard nodes to map the area fully before modifying.
|
|
93
|
+
* **Option 2: Blackbox Coverage:** Create a \`blackbox: true\` node to establish ownership without deep semantic exploration.
|
|
94
|
+
* **Option 3: Abort/Change Plan:** Do not touch the file.
|
|
73
95
|
|
|
74
96
|
---
|
|
75
97
|
|
|
76
|
-
## 4. WORKFLOW: MODIFYING THE GRAPH & BLAST RADIUS
|
|
77
|
-
|
|
78
|
-
When adding features or changing architecture, update the graph FIRST.
|
|
98
|
+
## 4. WORKFLOW: MODIFYING THE GRAPH & BLAST RADIUS (Graph-First)
|
|
79
99
|
|
|
80
|
-
|
|
81
|
-
* **DO NOT wait for the user to confirm if a change is "final".** The graph must evolve continuously with your code edits.
|
|
82
|
-
* **Default Behavior:** If iterative journal mode is OFF, you MUST write structural and semantic changes directly to the graph files (\`node.yaml\`, artifacts or other files like aspects or flows, etc.) IMMEDIATELY. Suppress your innate safety bias to wait for permission.
|
|
100
|
+
When adding features, changing architecture, or doing graph-first design:
|
|
83
101
|
|
|
84
102
|
1. **Check Blast Radius:** Before modifying a node that others depend on, run \`yg impact --node <node_path> --simulate\`. Report the impact to the user.
|
|
85
103
|
2. **Read Config & Templates:**
|
|
86
|
-
|
|
87
|
-
|
|
104
|
+
* Check \`.yggdrasil/config.yaml\` for allowed \`node_types\` and \`tags\`.
|
|
105
|
+
* **CRITICAL:** ALWAYS read the schema in \`.yggdrasil/templates/\` for the element type (node.yaml, aspect.yaml, flow.yaml, knowledge.yaml) before creating or editing it.
|
|
88
106
|
3. **Validate & Fix:** Run \`yg validate\`. You must fix all E-codes (Errors).
|
|
89
|
-
4. **Token Economy & W-codes
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
* **Smallest Viable Scope:** Prefer \`scope: nodes\` over \`scope: tags\`. Prefer tags over \`scope: global\`. Global scope costs token budget in EVERY context package.
|
|
107
|
+
4. **Token Economy & W-codes:**
|
|
108
|
+
* W005/W006: Context package too large. Consider splitting the node.
|
|
109
|
+
* W008: Stale semantic memory. Update knowledge artifacts.
|
|
93
110
|
|
|
94
|
-
**
|
|
95
|
-
|
|
96
|
-
|
|
111
|
+
**Graph Modification Checklist**
|
|
112
|
+
Whenever you change the graph structure or semantics, you MUST output and execute this exact checklist:
|
|
113
|
+
|
|
114
|
+
- [ ] 1. Read schema from \`.yggdrasil/templates/\` (node.yaml, aspect.yaml, flow.yaml, or knowledge.yaml for the element type)
|
|
115
|
+
- [ ] 2. Edit graph files (\`node.yaml\`, artifacts)
|
|
116
|
+
- [ ] 3. Verify corresponding source files exist and their behavior matches updated artifacts
|
|
117
|
+
- [ ] 4. Validate (ran \`yg validate\` — fix all Errors)
|
|
118
|
+
- [ ] 5. Baseline Hash (ran \`yg drift-sync\` ONLY AFTER steps 2-3 are confirmed)
|
|
119
|
+
|
|
120
|
+
**Journaling (Iterative Mode Scope):**
|
|
121
|
+
* **Default:** Write changes directly to graph files immediately. Do not defer.
|
|
122
|
+
* **Opt-in:** ONLY if the user says "use iterative mode" or "use journal". Once activated, it remains active for the ENTIRE conversation until wrap-up. Use \`yg journal-add --note "..."\` to buffer intent.
|
|
97
123
|
|
|
98
124
|
---
|
|
99
125
|
|
|
100
126
|
## 5. PATH CONVENTIONS (CRITICAL)
|
|
101
127
|
|
|
102
128
|
To avoid broken references (\`E004\`, \`E005\`), use correct relative paths:
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
129
|
+
* **Node paths** (used in CLI, relations, flow nodes): Relative to \`.yggdrasil/model/\` (e.g., \`orders/order-service\`).
|
|
130
|
+
* **File paths** (used in mapping, \`yg owner\`): Relative to the repository root (e.g., \`src/modules/orders/order.service.ts\`).
|
|
131
|
+
* **Knowledge paths** (used in node explicit refs): Relative to \`.yggdrasil/knowledge/\` (e.g., \`decisions/001-event-sourcing\`).
|
|
106
132
|
|
|
107
133
|
---
|
|
108
134
|
|
|
@@ -110,33 +136,82 @@ To avoid broken references (\`E004\`, \`E005\`), use correct relative paths:
|
|
|
110
136
|
|
|
111
137
|
The graph lives entirely under \`.yggdrasil/\`. You NEVER guess structure. You MUST ALWAYS read the corresponding schema reference in \`.yggdrasil/templates/\` before creating or editing any graph file.
|
|
112
138
|
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
|
|
120
|
-
|
|
139
|
+
* **\`.yggdrasil/config.yaml\`**: Defines \`node_types\`, \`tags\`, \`artifacts\`, \`knowledge_categories\`.
|
|
140
|
+
* **\`.yggdrasil/templates/\`**: Schemas for each graph layer — \`node.yaml\`, \`aspect.yaml\`, \`flow.yaml\`, \`knowledge.yaml\`.
|
|
141
|
+
* **\`.yggdrasil/model/\`**: Node tree. Each node is a directory with \`node.yaml\` and artifact files.
|
|
142
|
+
* **\`.yggdrasil/aspects/\`**: Cross-cutting rules. Directory contains \`aspect.yaml\` and \`.md\` content.
|
|
143
|
+
* **\`.yggdrasil/flows/\`**: End-to-end processes. Directory contains \`flow.yaml\` and \`.md\` content.
|
|
144
|
+
* **\`.yggdrasil/knowledge/\`**: Repo-wide wisdom. Directory contains \`knowledge.yaml\` and \`.md\` content.
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## 7. CONTEXT ASSEMBLY & KNOWLEDGE DECONSTRUCTION (HOW TO MAP FILES)
|
|
149
|
+
|
|
150
|
+
Your ultimate goal when describing a file or node is **Context Reproducibility**. A future agent reading ONLY the output of \`yg build-context\` for this node must be able to perfectly reconstruct the source code's behavior, constraints, environment, and purpose.
|
|
151
|
+
|
|
152
|
+
However, you must NOT dump all knowledge into a single file. Yggdrasil's context package is **multi-layered** and hierarchically assembled. When you map existing code or design new code, you must deconstruct the knowledge and place it at the correct abstraction layer so the engine can mechanically reassemble it.
|
|
153
|
+
|
|
154
|
+
### CRITICAL RULE: CAPTURE INTENT, BUT NEVER INVENT IT
|
|
155
|
+
The graph is not just a structural map; it is the semantic meaning of the system. Code explains "what" and "how". The graph MUST explain "WHY".
|
|
156
|
+
|
|
157
|
+
1. **ALWAYS Capture the User's "Why":** If the user explains the business reason, intent, or rationale behind a request (e.g., "We need to do X because Y"), you MUST permanently record this reasoning in the relevant graph artifacts (e.g., \`responsibility.md\`, \`constraints.md\`, \`decisions.md\`). Do not let the conversation context evaporate.
|
|
158
|
+
2. **NEVER Invent the "Why":** Files that imply human judgment (like \`decisions.md\` or \`knowledge/invariants\`) must reflect ACTUAL human choices.
|
|
159
|
+
3. **NO Hallucinations:** You MUST NEVER infer or hallucinate a rationale, an architectural decision, or a business rule.
|
|
160
|
+
4. **Ask if Missing:** If the user requests a significant architectural or business logic change but does not provide the rationale, you MUST ask them "Why are we making this change?" before documenting the decision in the graph.
|
|
161
|
+
|
|
162
|
+
When mapping a file, execute this mental routing:
|
|
163
|
+
|
|
164
|
+
### Layer 1: Unit Identity (Local Node Artifacts)
|
|
165
|
+
* **What goes here:** Things exclusively true for this specific node.
|
|
166
|
+
* **Routing:** **DO NOT ASSUME FILE NAMES.** You MUST read \`.yggdrasil/config.yaml\` (the \`artifacts\` section) to see the exact allowed filenames for the current project and their requirement conditions (e.g., \`required: always\` vs \`when: has_incoming_relations\`). Write local node knowledge ONLY into these configured files next to \`node.yaml\`.
|
|
167
|
+
* **logic.md:** Algorithmic flow, control flow, branching logic, decision trees — the "how" of execution. Create when the node has non-trivial logic that cannot be inferred from interface alone. Extract from source; do not invent.
|
|
168
|
+
* **model.md:** Data structures, schemas, entities, type definitions — the shape of data this node owns. Create when the node manages non-trivial data structures. Extract from source types/interfaces; do not invent fields.
|
|
169
|
+
|
|
170
|
+
**Subagents:** When mapping a node (reverse engineering or graph-first), if the source code contains non-trivial logic (branching, control flow, algorithms, workflows), create \`logic.md\` for that node. Document: control flow, branching conditions, decision trees, sequencing. Follow Layer 1 routing. Do not invent — extract only what is implemented.
|
|
171
|
+
|
|
172
|
+
### Layer 2: Surroundings (Relations & Flows)
|
|
173
|
+
* **What goes here:** How this node interacts with others. You must not duplicate external interfaces locally.
|
|
174
|
+
* **Routing:**
|
|
175
|
+
* If it calls another module: Add an outgoing structural \`relation\` in \`node.yaml\`. (The engine will automatically fetch the target's structural-context artifacts: responsibility, interface, constraints, errors).
|
|
176
|
+
* If it participates in an end-to-end process: Do not explain the whole process locally. Ensure the node is listed in \`.yggdrasil/flows/<flow_name>/flow.yaml\`. The engine will attach the flow knowledge automatically.
|
|
177
|
+
|
|
178
|
+
### Layer 3: Domain Context (Hierarchy)
|
|
179
|
+
* **What goes here:** Business rules shared by a family of nodes.
|
|
180
|
+
* **Routing:** Do not repeat module-wide rules in every child node. Place the child node directory *inside* a parent Module Node directory. Write the shared rules in the parent's configured artifacts. The engine inherently passes parent context to children.
|
|
181
|
+
|
|
182
|
+
### Layer 4: Cross-Cutting Rules (Aspects)
|
|
183
|
+
* **What goes here:** Horizontal requirements like logging, auth, rate-limiting, or specific frameworks.
|
|
184
|
+
* **Routing:** Do NOT write generic rules like "This node must log all errors" in local artifacts. Instead, read \`config.yaml\` for available \`tags\`. Add the relevant tag (e.g., \`requires-audit\`) to \`node.yaml\`. The engine will automatically attach the aspect knowledge.
|
|
185
|
+
|
|
186
|
+
### Layer 5: Long-Term Memory (Knowledge Elements)
|
|
187
|
+
* **What goes here:** Global architectural decisions, design patterns, and systemic invariants.
|
|
188
|
+
* **Routing:** Read \`config.yaml\` (the \`knowledge_categories\` section) to know what categories exist.
|
|
189
|
+
* If the file implements a standard pattern: Do not describe the pattern locally. Add a \`knowledge\` reference in \`node.yaml\` to the existing pattern.
|
|
190
|
+
* If the file reveals an undocumented global invariant or decision: Ask the user to confirm it. If confirmed, create it under \`.yggdrasil/knowledge/<category>/\` so all future nodes inherit it.
|
|
191
|
+
|
|
192
|
+
**THE COMPLETENESS CHECK:**
|
|
193
|
+
Before finishing a mapping, ask yourself: *"If I delete the source file and give another agent ONLY the output of \`yg build-context\`, can they recreate it perfectly based on the configured artifacts, AND will they understand EXACTLY WHY this code exists and why it was designed this way?"*
|
|
194
|
+
- If no -> You missed a local constraint, a relation, or you failed to capture the user's provided rationale.
|
|
195
|
+
- If yes, but the local files are bloated -> You failed to deconstruct knowledge into Tags, Aspects, Flows, and Hierarchy. Fix the routing.
|
|
121
196
|
|
|
122
197
|
---
|
|
123
198
|
|
|
124
|
-
##
|
|
199
|
+
## 8. CLI TOOLS REFERENCE (\`yg\`)
|
|
125
200
|
|
|
126
201
|
Always use these exact commands.
|
|
127
202
|
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
203
|
+
* \`yg owner --file <file_path>\` -> Find owning node.
|
|
204
|
+
* \`yg build-context --node <node_path>\` -> Assemble strict specification.
|
|
205
|
+
* \`yg tree [--root <node_path>] [--depth N]\` -> Print graph structure.
|
|
206
|
+
* \`yg deps --node <node_path> [--type structural|event|all]\` -> Show dependencies.
|
|
207
|
+
* \`yg impact --node <node_path> --simulate\` -> Simulate blast radius.
|
|
208
|
+
* \`yg status\` -> Graph health metrics.
|
|
209
|
+
* \`yg validate [--scope <node_path>|all]\` -> Compile/check graph. Run after EVERY graph edit.
|
|
210
|
+
* \`yg drift [--scope <node_path>|all]\` -> Check code vs graph baseline.
|
|
211
|
+
* \`yg drift-sync --node <node_path>\` -> Save current file hash as new baseline. Run ONLY after ensuring graph artifacts match the code.
|
|
137
212
|
|
|
138
213
|
*(Iterative mode only)*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
214
|
+
* \`yg journal-read\`
|
|
215
|
+
* \`yg journal-add --note "<content>" [--target <node_path>]\`
|
|
216
|
+
* \`yg journal-archive\`
|
|
142
217
|
`;
|
package/package.json
CHANGED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
node_type: library
|
|
2
|
-
suggested_artifacts:
|
|
3
|
-
- responsibility
|
|
4
|
-
- interface
|
|
5
|
-
guidance: |
|
|
6
|
-
A library node represents shared code, utilities, or reusable components that
|
|
7
|
-
other nodes depend on. It has no business logic of its own — it provides
|
|
8
|
-
capabilities.
|
|
9
|
-
|
|
10
|
-
responsibility.md: Define what capabilities this library provides and what it
|
|
11
|
-
does not. "Provides date formatting, timezone conversion, and scheduling helpers.
|
|
12
|
-
Does not contain business rules or domain logic."
|
|
13
|
-
|
|
14
|
-
interface.md: Required when other nodes depend on this one. List exported functions,
|
|
15
|
-
classes, or APIs. For each: signature, purpose, usage constraints. Libraries are
|
|
16
|
-
often consumed by many nodes — a clear interface prevents misuse.
|
|
17
|
-
|
|
18
|
-
constraints.md: Optional. Use for usage constraints: "All dates must be ISO 8601
|
|
19
|
-
UTC. Thread-safe. No side effects."
|
|
20
|
-
|
|
21
|
-
mapping: Typically "directory" pointing to the library source. Path relative
|
|
22
|
-
to repository root.
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
node_type: module
|
|
2
|
-
suggested_artifacts:
|
|
3
|
-
- responsibility
|
|
4
|
-
guidance: |
|
|
5
|
-
A module node represents a domain or subsystem that groups child components.
|
|
6
|
-
It provides domain context that all descendants inherit during context assembly.
|
|
7
|
-
|
|
8
|
-
responsibility.md: Define the business domain this module owns. What is in scope
|
|
9
|
-
(e.g. "orders, order lifecycle, order state transitions") and what is out of scope
|
|
10
|
-
(e.g. "payment processing belongs to payments module"). Child nodes inherit this
|
|
11
|
-
context — a service under this module is understood within this domain.
|
|
12
|
-
|
|
13
|
-
Modules typically have no mapping (they are organizational, not implementation units).
|
|
14
|
-
If the module maps to a directory, that directory contains the implementation of
|
|
15
|
-
all child nodes collectively.
|
|
16
|
-
|
|
17
|
-
Keep responsibility concise but precise. The agent uses it to understand boundaries
|
|
18
|
-
when implementing or modifying child nodes.
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
node_type: service
|
|
2
|
-
suggested_artifacts:
|
|
3
|
-
- responsibility
|
|
4
|
-
- interface
|
|
5
|
-
- constraints
|
|
6
|
-
- errors
|
|
7
|
-
guidance: |
|
|
8
|
-
A service node represents a component with a public API that other components depend on.
|
|
9
|
-
It is the primary implementation unit for business logic.
|
|
10
|
-
|
|
11
|
-
responsibility.md: State clearly what this service does and what it does NOT do.
|
|
12
|
-
Define boundaries: "Creates and validates orders; does not process payments."
|
|
13
|
-
Include edge cases: "Handles partial fulfillment; does not handle refunds."
|
|
14
|
-
|
|
15
|
-
interface.md: Required when other nodes depend on this one (has_incoming_relations).
|
|
16
|
-
List every public method with: name, parameters (types), return type, contract.
|
|
17
|
-
For each method: preconditions, postconditions, idempotency, error conditions.
|
|
18
|
-
Example: "createOrder(items: OrderItem[]): Promise<Order> — creates order in pending
|
|
19
|
-
state; items must have positive quantity; returns order with generated id."
|
|
20
|
-
|
|
21
|
-
constraints.md: Validation rules, business rules, invariants this service enforces.
|
|
22
|
-
Be explicit: "Order must have at least 1 item, max 100 items. Total must be > 0."
|
|
23
|
-
Include rate limits, quotas, or SLA constraints if applicable.
|
|
24
|
-
|
|
25
|
-
errors.md: Required when others depend on this node. Document error conditions,
|
|
26
|
-
error codes, and recovery behavior. "INSUFFICIENT_STOCK: retry after inventory
|
|
27
|
-
refresh. PAYMENT_FAILED: order marked payment-failed, manual intervention."
|
|
28
|
-
|
|
29
|
-
mapping: Use type "directory" for a service implemented in one folder, or "file"
|
|
30
|
-
for a single-file service. Path relative to repository root.
|