@chrisdudek/yg 0.2.1 → 0.3.1
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 +18 -7
- package/dist/bin.js.map +1 -1
- package/dist/templates/rules.ts +14 -4
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -123,6 +123,7 @@ You have fundamentally broken Yggdrasil if you do any of the following:
|
|
|
123
123
|
- \u274C You ran \`yg drift-sync\` before updating graph artifacts.
|
|
124
124
|
- \u274C You ran \`yg drift-sync\` after a graph-only change without verifying source files.
|
|
125
125
|
- \u274C You used Blackbox coverage for greenfield/new code.
|
|
126
|
+
- \u274C You answered a question about a mapped file/area without running \`yg build-context\` when the path was known.
|
|
126
127
|
|
|
127
128
|
---
|
|
128
129
|
|
|
@@ -133,15 +134,23 @@ You do not need explicit "session" commands. Follow these conversational trigger
|
|
|
133
134
|
### A. Preflight (First message of the conversation)
|
|
134
135
|
Always execute these commands before doing anything else. *(Exception: If the user's request is clearly read-only, run ONLY step 1).* **Read-only** means the user asks only for explanation, clarification, analysis, or evaluation \u2014 no code or graph modification will occur. Examples: "explain this", "evaluate X", "what does Y do?", "analyze Z". If unsure, run full preflight.
|
|
135
136
|
1. \`yg journal-read\` -> If entries exist, consolidate them into the graph, then \`yg journal-archive\`.
|
|
136
|
-
2. \`yg drift\` -> If
|
|
137
|
+
2. \`yg drift\` -> If **drift** (code changed, graph baseline stale): run \`yg drift-sync\` for each affected node. Do NOT ask the user \u2014 they do not need to know this step. If **missing** or **unmaterialized**: report and ask the user how to proceed.
|
|
137
138
|
3. \`yg status\` -> Report graph health.
|
|
138
139
|
4. \`yg validate\` -> If W008 stale-knowledge appears, update the knowledge artifacts to reflect current node state.
|
|
139
140
|
|
|
140
|
-
### B.
|
|
141
|
-
|
|
141
|
+
### B. Answering Questions (When a specific file or area is known)
|
|
142
|
+
When the user asks a question and you know (or can infer) which file or area of the codebase it concerns:
|
|
143
|
+
1. Run \`yg owner --file <path>\` for the relevant file(s).
|
|
144
|
+
2. **If owner FOUND:** Run \`yg build-context --node <node_path>\` and base your answer on that context. Do NOT answer from grep/search alone \u2014 the graph provides intent, constraints, and relations that yield better answers.
|
|
145
|
+
3. **If owner NOT FOUND:** The file is outside the graph (e.g. third-party code, user's theme/plugin, unmapped area). You may answer from grep/search, but state that the answer is not graph-based.
|
|
146
|
+
|
|
147
|
+
This applies even when you are **not modifying files** \u2014 e.g. when providing code snippets to paste elsewhere, explaining behavior, or suggesting hooks. If the question touches mapped code, build-context first.
|
|
148
|
+
|
|
149
|
+
### C. Session Verification (Wrap-up)
|
|
150
|
+
Triggered by phrases like: "we're done", "wrap up", "that's enough", "done", "ok".
|
|
142
151
|
**Note: The graph should ALREADY be up to date. If the graph requires massive updates at this stage, YOU HAVE FAILED.**
|
|
143
152
|
1. If iterative journal mode was used: consolidate notes to the graph, then \`yg journal-archive\`.
|
|
144
|
-
2. \`yg drift\` ->
|
|
153
|
+
2. \`yg drift\` -> If drift detected, run \`yg drift-sync\` for each affected node. Do NOT ask \u2014 absorb automatically.
|
|
145
154
|
3. \`yg validate\` -> Fix any structural errors.
|
|
146
155
|
4. Report exactly what nodes and files were changed.
|
|
147
156
|
|
|
@@ -254,6 +263,7 @@ When mapping a file, execute this mental routing:
|
|
|
254
263
|
* **Routing:**
|
|
255
264
|
* 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).
|
|
256
265
|
* 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.
|
|
266
|
+
* **Flows \u2014 writing flow content:** When creating or editing flow artifacts (e.g. \`description.md\` in \`flows/<name>/\`), write business-first: describe the process from user/business perspective. Technical details only as inserts when they clarify the flow. Not technical-first with business inserts.
|
|
257
267
|
|
|
258
268
|
### Layer 3: Domain Context (Hierarchy)
|
|
259
269
|
* **What goes here:** Business rules shared by a family of nodes.
|
|
@@ -1244,7 +1254,7 @@ async function buildContext(graph, nodePath) {
|
|
|
1244
1254
|
}
|
|
1245
1255
|
}
|
|
1246
1256
|
}
|
|
1247
|
-
for (const flow of collectParticipatingFlows(graph,
|
|
1257
|
+
for (const flow of collectParticipatingFlows(graph, node)) {
|
|
1248
1258
|
layers.push(buildFlowLayer(flow));
|
|
1249
1259
|
for (const kPath of flow.knowledge ?? []) {
|
|
1250
1260
|
const norm = kPath.replace(/\/$/, "");
|
|
@@ -1306,8 +1316,9 @@ function collectKnowledgeItems(graph, nodePath, nodeTags, seenKnowledge) {
|
|
|
1306
1316
|
}
|
|
1307
1317
|
return result;
|
|
1308
1318
|
}
|
|
1309
|
-
function collectParticipatingFlows(graph,
|
|
1310
|
-
|
|
1319
|
+
function collectParticipatingFlows(graph, node) {
|
|
1320
|
+
const paths = /* @__PURE__ */ new Set([node.path, ...collectAncestors(node).map((a) => a.path)]);
|
|
1321
|
+
return graph.flows.filter((f) => f.nodes.some((n) => paths.has(n)));
|
|
1311
1322
|
}
|
|
1312
1323
|
function buildGlobalLayer(config) {
|
|
1313
1324
|
let content = `**Project:** ${config.name}
|