@chrisdudek/yg 4.2.0 → 5.0.0-alpha.2

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.
Files changed (46) hide show
  1. package/README.md +4 -2
  2. package/dist/ast.d.ts +51 -0
  3. package/dist/ast.js +279 -0
  4. package/dist/bin.js +17543 -6420
  5. package/dist/grammars/tree-sitter-c.node-types.json +4615 -0
  6. package/dist/grammars/tree-sitter-c.wasm +0 -0
  7. package/dist/grammars/tree-sitter-c_sharp.node-types.json +7233 -0
  8. package/dist/grammars/tree-sitter-c_sharp.wasm +0 -0
  9. package/dist/grammars/tree-sitter-cpp.node-types.json +7997 -0
  10. package/dist/grammars/tree-sitter-cpp.wasm +0 -0
  11. package/dist/grammars/tree-sitter-go.node-types.json +2995 -0
  12. package/dist/grammars/tree-sitter-go.wasm +0 -0
  13. package/dist/grammars/tree-sitter-java.node-types.json +4586 -0
  14. package/dist/grammars/tree-sitter-java.wasm +0 -0
  15. package/dist/grammars/tree-sitter-javascript.node-types.json +3622 -0
  16. package/dist/grammars/tree-sitter-javascript.wasm +0 -0
  17. package/dist/grammars/tree-sitter-json.node-types.json +183 -0
  18. package/dist/grammars/tree-sitter-json.wasm +0 -0
  19. package/dist/grammars/tree-sitter-kotlin.node-types.json +3091 -0
  20. package/dist/grammars/tree-sitter-kotlin.wasm +0 -0
  21. package/dist/grammars/tree-sitter-php_only.node-types.json +6077 -0
  22. package/dist/grammars/tree-sitter-php_only.wasm +0 -0
  23. package/dist/grammars/tree-sitter-python.node-types.json +3746 -0
  24. package/dist/grammars/tree-sitter-python.wasm +0 -0
  25. package/dist/grammars/tree-sitter-ruby.node-types.json +4108 -0
  26. package/dist/grammars/tree-sitter-ruby.wasm +0 -0
  27. package/dist/grammars/tree-sitter-rust.node-types.json +5554 -0
  28. package/dist/grammars/tree-sitter-rust.wasm +0 -0
  29. package/dist/grammars/tree-sitter-toml.node-types.json +356 -0
  30. package/dist/grammars/tree-sitter-toml.wasm +0 -0
  31. package/dist/grammars/tree-sitter-tsx.node-types.json +6288 -0
  32. package/dist/grammars/tree-sitter-tsx.wasm +0 -0
  33. package/dist/grammars/tree-sitter-typescript.node-types.json +6038 -0
  34. package/dist/grammars/tree-sitter-typescript.wasm +0 -0
  35. package/dist/grammars/tree-sitter-yaml.node-types.json +552 -0
  36. package/dist/grammars/tree-sitter-yaml.wasm +0 -0
  37. package/dist/loader-hook-impl.d.ts +9 -0
  38. package/dist/loader-hook-impl.js +16 -0
  39. package/dist/structure.d.ts +414 -0
  40. package/dist/structure.js +1261 -0
  41. package/graph-schemas/yg-architecture.yaml +39 -6
  42. package/graph-schemas/yg-aspect.yaml +88 -3
  43. package/graph-schemas/yg-config.yaml +28 -12
  44. package/graph-schemas/yg-flow.yaml +5 -3
  45. package/graph-schemas/yg-node.yaml +19 -5
  46. package/package.json +56 -19
package/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # @chrisdudek/yg
2
2
 
3
- Yggdrasil CLI continuous architecture enforcement for AI-assisted development.
3
+ **Your agent will ignore CLAUDE.md. Yggdrasil makes sure it doesn't.**
4
4
 
5
- See the [main README](../../README.md) for documentation, or visit
5
+ Architecture rules your agent can't ignore. You write them in plain Markdown; a reviewer verifies every change and feeds violations back into the agent's loop — before it moves on. Works with Claude Code, Cursor, Copilot, Codex, Cline, and more. The reviewer runs against your code, not your diffs. The feedback is specific, and the agent has to fix before moving on.
6
+
7
+ See the [main README](https://github.com/krzysztofdudek/Yggdrasil#readme) for documentation, or visit
6
8
  [krzysztofdudek.github.io/Yggdrasil](https://krzysztofdudek.github.io/Yggdrasil/).
7
9
 
8
10
  ## Install
package/dist/ast.d.ts ADDED
@@ -0,0 +1,51 @@
1
+ import { Tree, Node } from 'web-tree-sitter';
2
+ export { Node as SyntaxNode, Tree } from 'web-tree-sitter';
3
+
4
+ interface SourceFile {
5
+ /** Project-relative POSIX path */
6
+ path: string;
7
+ /** Raw source code */
8
+ content: string;
9
+ /** Parsed tree-sitter Tree */
10
+ ast: Tree;
11
+ }
12
+ interface CheckContext {
13
+ files: SourceFile[];
14
+ }
15
+ interface Violation {
16
+ /** Project-relative POSIX path */
17
+ file: string;
18
+ /** 1-based line number */
19
+ line: number;
20
+ /** 0-based column number */
21
+ column: number;
22
+ message: string;
23
+ }
24
+
25
+ declare function report(file: SourceFile, node: Node, message: string): Violation;
26
+
27
+ type InFilePattern = {
28
+ glob: string;
29
+ } | {
30
+ regex: RegExp;
31
+ } | {
32
+ contains: string;
33
+ };
34
+ declare function inFile(file: SourceFile, pattern: InFilePattern): boolean;
35
+
36
+ declare function walk(node: Node, visitor: (node: Node) => boolean | void): void;
37
+ declare function closest(node: Node, types: string | string[]): Node | null;
38
+
39
+ type FindCommentsTarget = {
40
+ path: string;
41
+ ast: Tree;
42
+ } | {
43
+ ast: Tree;
44
+ language: string;
45
+ } | {
46
+ rootNode: Node;
47
+ language: string;
48
+ };
49
+ declare function findComments(target: FindCommentsTarget): Node[];
50
+
51
+ export { type CheckContext, type FindCommentsTarget, type InFilePattern, type SourceFile, type Violation, closest, findComments, inFile, report, walk };
package/dist/ast.js ADDED
@@ -0,0 +1,279 @@
1
+ // src/ast/report.ts
2
+ function report(file, node, message) {
3
+ return {
4
+ file: file.path,
5
+ line: node.startPosition.row + 1,
6
+ column: node.startPosition.column,
7
+ message
8
+ };
9
+ }
10
+
11
+ // src/ast/file-path.ts
12
+ import { minimatch } from "minimatch";
13
+ function inFile(file, pattern) {
14
+ if ("glob" in pattern) return minimatch(file.path, pattern.glob);
15
+ if ("regex" in pattern) return pattern.regex.test(file.path);
16
+ if ("contains" in pattern) return file.path.includes(pattern.contains);
17
+ return false;
18
+ }
19
+
20
+ // src/ast/walk.ts
21
+ function walk(node, visitor) {
22
+ const result = visitor(node);
23
+ if (result === false) return;
24
+ for (let i = 0; i < node.childCount; i++) {
25
+ const child = node.child(i);
26
+ if (child !== null) walk(child, visitor);
27
+ }
28
+ }
29
+ function closest(node, types) {
30
+ const typeSet = typeof types === "string" ? /* @__PURE__ */ new Set([types]) : new Set(types);
31
+ let cur = node.parent;
32
+ while (cur !== null) {
33
+ if (typeSet.has(cur.type)) return cur;
34
+ cur = cur.parent;
35
+ }
36
+ return null;
37
+ }
38
+
39
+ // src/ast/find-comments.ts
40
+ import { extname } from "path";
41
+
42
+ // src/core/graph/language-registry.ts
43
+ var LANGUAGES = {
44
+ typescript: {
45
+ id: "typescript",
46
+ extensions: [".ts"],
47
+ wasmFile: "tree-sitter-typescript.wasm",
48
+ wasmPackage: "tree-sitter-typescript",
49
+ grammarRepo: "https://github.com/tree-sitter/tree-sitter-typescript",
50
+ grammarCommit: "",
51
+ treeSitterCliVersion: "",
52
+ externalScanner: false,
53
+ commentTypes: ["comment"],
54
+ commentDelimiters: ["//", "/*"]
55
+ },
56
+ tsx: {
57
+ id: "tsx",
58
+ extensions: [".tsx"],
59
+ wasmFile: "tree-sitter-tsx.wasm",
60
+ wasmPackage: "tree-sitter-typescript",
61
+ grammarRepo: "https://github.com/tree-sitter/tree-sitter-typescript",
62
+ grammarCommit: "",
63
+ treeSitterCliVersion: "",
64
+ externalScanner: false,
65
+ commentTypes: ["comment"],
66
+ commentDelimiters: ["//", "/*"]
67
+ },
68
+ javascript: {
69
+ id: "javascript",
70
+ extensions: [".js", ".mjs", ".cjs", ".jsx"],
71
+ wasmFile: "tree-sitter-javascript.wasm",
72
+ wasmPackage: "tree-sitter-javascript",
73
+ grammarRepo: "https://github.com/tree-sitter/tree-sitter-javascript",
74
+ grammarCommit: "",
75
+ treeSitterCliVersion: "",
76
+ externalScanner: false,
77
+ commentTypes: ["comment"],
78
+ commentDelimiters: ["//", "/*"]
79
+ },
80
+ python: {
81
+ id: "python",
82
+ extensions: [".py"],
83
+ wasmFile: "tree-sitter-python.wasm",
84
+ wasmPackage: "tree-sitter-python",
85
+ grammarRepo: "https://github.com/tree-sitter/tree-sitter-python",
86
+ grammarCommit: "",
87
+ treeSitterCliVersion: "",
88
+ externalScanner: false,
89
+ commentTypes: ["comment"],
90
+ commentDelimiters: ["#"]
91
+ },
92
+ go: {
93
+ id: "go",
94
+ extensions: [".go"],
95
+ wasmFile: "tree-sitter-go.wasm",
96
+ wasmPackage: "tree-sitter-go",
97
+ grammarRepo: "https://github.com/tree-sitter/tree-sitter-go",
98
+ grammarCommit: "",
99
+ treeSitterCliVersion: "",
100
+ externalScanner: false,
101
+ commentTypes: ["comment"],
102
+ commentDelimiters: ["//", "/*"]
103
+ },
104
+ rust: {
105
+ id: "rust",
106
+ extensions: [".rs"],
107
+ wasmFile: "tree-sitter-rust.wasm",
108
+ wasmPackage: "tree-sitter-rust",
109
+ grammarRepo: "https://github.com/tree-sitter/tree-sitter-rust",
110
+ grammarCommit: "",
111
+ treeSitterCliVersion: "",
112
+ externalScanner: false,
113
+ commentTypes: ["line_comment", "block_comment"],
114
+ commentDelimiters: ["//", "/*"]
115
+ },
116
+ java: {
117
+ id: "java",
118
+ extensions: [".java"],
119
+ wasmFile: "tree-sitter-java.wasm",
120
+ wasmPackage: "tree-sitter-java",
121
+ grammarRepo: "https://github.com/tree-sitter/tree-sitter-java",
122
+ grammarCommit: "",
123
+ treeSitterCliVersion: "",
124
+ externalScanner: false,
125
+ commentTypes: ["line_comment", "block_comment"],
126
+ commentDelimiters: ["//", "/*"]
127
+ },
128
+ csharp: {
129
+ id: "csharp",
130
+ extensions: [".cs"],
131
+ wasmFile: "tree-sitter-c_sharp.wasm",
132
+ wasmPackage: "tree-sitter-c-sharp",
133
+ grammarRepo: "https://github.com/tree-sitter/tree-sitter-c-sharp",
134
+ grammarCommit: "",
135
+ treeSitterCliVersion: "",
136
+ externalScanner: false,
137
+ commentTypes: ["comment"],
138
+ commentDelimiters: ["//", "/*"]
139
+ },
140
+ c: {
141
+ id: "c",
142
+ extensions: [".c", ".h"],
143
+ wasmFile: "tree-sitter-c.wasm",
144
+ wasmPackage: "tree-sitter-c",
145
+ grammarRepo: "https://github.com/tree-sitter/tree-sitter-c",
146
+ grammarCommit: "",
147
+ treeSitterCliVersion: "",
148
+ externalScanner: false,
149
+ commentTypes: ["comment"],
150
+ commentDelimiters: ["//", "/*"]
151
+ },
152
+ cpp: {
153
+ id: "cpp",
154
+ extensions: [".cpp", ".cc", ".cxx", ".hpp", ".hh", ".hxx"],
155
+ wasmFile: "tree-sitter-cpp.wasm",
156
+ wasmPackage: "tree-sitter-cpp",
157
+ grammarRepo: "https://github.com/tree-sitter/tree-sitter-cpp",
158
+ grammarCommit: "",
159
+ treeSitterCliVersion: "",
160
+ externalScanner: false,
161
+ commentTypes: ["comment"],
162
+ commentDelimiters: ["//", "/*"]
163
+ },
164
+ php: {
165
+ id: "php",
166
+ extensions: [".php"],
167
+ wasmFile: "tree-sitter-php_only.wasm",
168
+ wasmPackage: "tree-sitter-php",
169
+ grammarRepo: "https://github.com/tree-sitter/tree-sitter-php",
170
+ grammarCommit: "",
171
+ treeSitterCliVersion: "",
172
+ externalScanner: false,
173
+ commentTypes: ["comment"],
174
+ commentDelimiters: ["//", "#", "/*"]
175
+ },
176
+ ruby: {
177
+ id: "ruby",
178
+ extensions: [".rb"],
179
+ wasmFile: "tree-sitter-ruby.wasm",
180
+ wasmPackage: "tree-sitter-ruby",
181
+ grammarRepo: "https://github.com/tree-sitter/tree-sitter-ruby",
182
+ grammarCommit: "",
183
+ treeSitterCliVersion: "",
184
+ externalScanner: false,
185
+ commentTypes: ["comment"],
186
+ commentDelimiters: ["#"]
187
+ },
188
+ json: {
189
+ id: "json",
190
+ extensions: [".json"],
191
+ wasmFile: "tree-sitter-json.wasm",
192
+ wasmPackage: "tree-sitter-json",
193
+ grammarRepo: "https://github.com/tree-sitter/tree-sitter-json",
194
+ grammarCommit: "",
195
+ treeSitterCliVersion: "",
196
+ externalScanner: false,
197
+ commentTypes: [],
198
+ commentDelimiters: []
199
+ },
200
+ kotlin: {
201
+ id: "kotlin",
202
+ extensions: [".kt", ".kts"],
203
+ wasmFile: "tree-sitter-kotlin.wasm",
204
+ wasmPackage: "@tree-sitter-grammars/tree-sitter-kotlin",
205
+ grammarRepo: "https://github.com/tree-sitter-grammars/tree-sitter-kotlin",
206
+ grammarCommit: "",
207
+ treeSitterCliVersion: "",
208
+ externalScanner: false,
209
+ commentTypes: ["line_comment", "block_comment"],
210
+ commentDelimiters: ["//", "/*"]
211
+ },
212
+ yaml: {
213
+ id: "yaml",
214
+ extensions: [".yaml", ".yml"],
215
+ wasmFile: "tree-sitter-yaml.wasm",
216
+ wasmPackage: "@tree-sitter-grammars/tree-sitter-yaml",
217
+ grammarRepo: "https://github.com/tree-sitter-grammars/tree-sitter-yaml",
218
+ grammarCommit: "",
219
+ treeSitterCliVersion: "",
220
+ externalScanner: false,
221
+ commentTypes: ["comment"],
222
+ commentDelimiters: ["#"]
223
+ },
224
+ toml: {
225
+ id: "toml",
226
+ extensions: [".toml"],
227
+ wasmFile: "tree-sitter-toml.wasm",
228
+ wasmPackage: "@tree-sitter-grammars/tree-sitter-toml",
229
+ grammarRepo: "https://github.com/tree-sitter-grammars/tree-sitter-toml",
230
+ grammarCommit: "",
231
+ treeSitterCliVersion: "",
232
+ externalScanner: false,
233
+ commentTypes: ["comment"],
234
+ commentDelimiters: ["#"]
235
+ }
236
+ };
237
+ var EXTENSION_TO_LANGUAGE = Object.fromEntries(
238
+ Object.values(LANGUAGES).flatMap((def) => def.extensions.map((ext) => [ext, def.id]))
239
+ );
240
+ function getLanguageForExtension(ext, overrides) {
241
+ if (overrides && ext in overrides) return overrides[ext];
242
+ return EXTENSION_TO_LANGUAGE[ext] ?? null;
243
+ }
244
+
245
+ // src/ast/find-comments.ts
246
+ function findComments(target) {
247
+ const hasAst = "ast" in target;
248
+ const hasRootNode = "rootNode" in target;
249
+ if (hasAst && hasRootNode) {
250
+ throw new Error("AST_FINDCOMMENTS_AMBIGUOUS_TARGET: pass either ast or rootNode, not both");
251
+ }
252
+ let language = "language" in target ? target.language : void 0;
253
+ if (language === void 0 && "path" in target) {
254
+ language = getLanguageForExtension(extname(target.path)) ?? void 0;
255
+ }
256
+ if (language === void 0) {
257
+ throw new Error(
258
+ "AST_FINDCOMMENTS_NO_LANGUAGE: pass a SourceFile whose path has a known extension, or an explicit { language }"
259
+ );
260
+ }
261
+ const def = LANGUAGES[language];
262
+ if (def === void 0) {
263
+ throw new Error(`AST_FINDCOMMENTS_UNKNOWN_LANGUAGE: '${language}' not in registry`);
264
+ }
265
+ const root = hasAst ? target.ast.rootNode : target.rootNode;
266
+ const out = [];
267
+ for (const type of def.commentTypes) {
268
+ out.push(...root.descendantsOfType(type));
269
+ }
270
+ return out;
271
+ }
272
+ export {
273
+ closest,
274
+ findComments,
275
+ inFile,
276
+ report,
277
+ walk
278
+ };
279
+ //# sourceMappingURL=ast.js.map