@graphito/core 0.1.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.
Files changed (2) hide show
  1. package/README.md +327 -0
  2. package/package.json +52 -0
package/README.md ADDED
@@ -0,0 +1,327 @@
1
+ # @gdd/core
2
+
3
+ Core GDD framework for graph resolution, validation, and health scoring.
4
+
5
+ ## What is GDD?
6
+
7
+ Graph-Driven Development (GDD) transforms monolithic documentation into a dependency graph of specialized nodes, optimized for AI agent consumption. Instead of loading a `spec.md` document of 100,000+ tokens, GDD allows loading only the 3-5 relevant nodes for each task, reducing context by 71-90%.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ npm install @gdd/core
13
+ ```
14
+
15
+ ## Quick Start
16
+
17
+ ```typescript
18
+ import { GDD } from '@gdd/core';
19
+
20
+ // Initialize GDD
21
+ const gdd = new GDD({
22
+ systemMapPath: './system-map-v2.yaml',
23
+ docsPath: './docs/nodes-v2'
24
+ });
25
+
26
+ // Resolve dependencies for a node
27
+ const nodes = gdd.resolve('feature-a');
28
+ console.log(`Resolved ${nodes.length} nodes`);
29
+ console.log(`Total tokens: ${nodes.reduce((sum, n) => sum + n.tokenCount, 0)}`);
30
+
31
+ // Validate system
32
+ const validation = gdd.validate();
33
+ if (validation.valid) {
34
+ console.log('System is valid');
35
+ }
36
+
37
+ // Get health score
38
+ const health = gdd.health();
39
+ console.log(`Health Score: ${health.score}/100 (${health.status})`);
40
+
41
+ // Cleanup
42
+ gdd.dispose();
43
+ ```
44
+
45
+ ## API Reference
46
+
47
+ ### GDD Class
48
+
49
+ Main orchestrator class for GDD framework.
50
+
51
+ #### Constructor
52
+
53
+ ```typescript
54
+ new GDD(config: GDDCoreConfig)
55
+ ```
56
+
57
+ **Config:**
58
+ - `systemMapPath`: Path to system-map-v2.yaml
59
+ - `docsPath`: Path to docs/nodes-v2 directory
60
+ - `configPath?`: Optional path to .gddrc.json
61
+ - `verbose?`: Enable verbose logging
62
+
63
+ #### Methods
64
+
65
+ ##### `resolve(nodeNames: string | string[]): ResolvedNode[]`
66
+
67
+ Resolves node dependencies transitively and loads nodes.
68
+
69
+ **Returns:** Array of resolved nodes with token counts and depth information.
70
+
71
+ ##### `validate(): ValidationResult`
72
+
73
+ Validates the entire GDD system.
74
+
75
+ **Returns:** Validation result with errors, warnings, and info messages.
76
+
77
+ ##### `health(): HealthScore`
78
+
79
+ Calculates health score (0-100).
80
+
81
+ **Returns:** Health score with breakdown and status.
82
+
83
+ ##### `predictDrift(): DriftReport`
84
+
85
+ Predicts which nodes are drifting.
86
+
87
+ **Returns:** Drift report with risk categories.
88
+
89
+ ##### `repair(options?: RepairOptions): RepairReport`
90
+
91
+ Auto-repairs common issues.
92
+
93
+ **Options:**
94
+ - `dryRun?`: Don't actually modify files
95
+ - `updateCoverage?`: Update coverage from coverage-summary.json
96
+ - `updateTimestamps?`: Update last_updated timestamps
97
+ - `fixCrossReferences?`: Fix broken cross-references
98
+
99
+ **Returns:** Repair report with fixes applied.
100
+
101
+ ##### `dispose(): void`
102
+
103
+ Cleanup resources (call when done).
104
+
105
+ ## Types
106
+
107
+ ### ResolvedNode
108
+
109
+ ```typescript
110
+ interface ResolvedNode {
111
+ id: string;
112
+ frontmatter: NodeFrontmatter;
113
+ content: string;
114
+ filePath: string;
115
+ lineCount: number;
116
+ wordCount: number;
117
+ tokenCount: number;
118
+ depth: number;
119
+ reason: 'requested' | 'dependency';
120
+ }
121
+ ```
122
+
123
+ ### HealthScore
124
+
125
+ ```typescript
126
+ interface HealthScore {
127
+ score: number; // 0-100
128
+ breakdown: HealthBreakdown;
129
+ status: 'healthy' | 'degraded' | 'critical';
130
+ nodes_detected: number;
131
+ nodes_total: number;
132
+ nodes_missing: number;
133
+ }
134
+ ```
135
+
136
+ ### ValidationResult
137
+
138
+ ```typescript
139
+ interface ValidationResult {
140
+ valid: boolean;
141
+ errors: ValidationIssue[];
142
+ warnings: ValidationIssue[];
143
+ info: ValidationIssue[];
144
+ summary: {
145
+ total_issues: number;
146
+ error_count: number;
147
+ warning_count: number;
148
+ info_count: number;
149
+ };
150
+ }
151
+ ```
152
+
153
+ ## Configuration
154
+
155
+ ### GDDCoreConfig
156
+
157
+ ```typescript
158
+ interface GDDCoreConfig {
159
+ systemMapPath: string; // Path to system-map-v2.yaml
160
+ docsPath: string; // Path to docs/nodes-v2 directory
161
+ configPath?: string; // Optional path to .gddrc.json
162
+ verbose?: boolean; // Enable verbose logging
163
+ }
164
+ ```
165
+
166
+ ### Defaults
167
+
168
+ - `verbose`: `false`
169
+ - `configPath`: Auto-detected from workspace root
170
+
171
+ ## System Map Format
172
+
173
+ The `system-map-v2.yaml` file defines your system's dependency graph:
174
+
175
+ ```yaml
176
+ metadata:
177
+ version: 2.0.0
178
+ total_nodes: 5
179
+ gdd_version: '2.0'
180
+
181
+ nodes:
182
+ feature-a:
183
+ description: Feature A description
184
+ status: production
185
+ priority: critical
186
+ owner: Back-end Dev
187
+ last_updated: '2026-01-29T00:00:00.000Z'
188
+ coverage: 85
189
+ depends_on:
190
+ - feature-b
191
+ required_by: []
192
+ docs:
193
+ - docs/nodes-v2/feature-a.md
194
+ files:
195
+ - src/services/featureA.js
196
+ ```
197
+
198
+ ### Required Fields
199
+
200
+ - `description`: Human-readable description
201
+ - `status`: `production` | `development` | `deprecated`
202
+ - `priority`: `critical` | `high` | `medium` | `low`
203
+ - `owner`: Owner/team name
204
+ - `last_updated`: ISO 8601 date string
205
+ - `coverage`: Test coverage percentage (0-100)
206
+ - `docs`: Array of markdown file paths
207
+
208
+ ### Optional Fields
209
+
210
+ - `depends_on`: Array of node IDs this node depends on
211
+ - `required_by`: Array of node IDs that depend on this node
212
+ - `files`: Array of source code file paths
213
+ - `workers`: Array of worker names
214
+ - `ssot_references`: Array of SSOT reference names
215
+ - `subnodes`: Array of subnode names
216
+
217
+ ## Node Format
218
+
219
+ Each node is a markdown file with YAML frontmatter:
220
+
221
+ ```markdown
222
+ ---
223
+ node_id: feature-a
224
+ status: production
225
+ priority: critical
226
+ owner: Back-end Dev
227
+ last_updated: 2026-01-29
228
+ coverage: 85
229
+ coverage_source: auto
230
+ depends_on:
231
+ - feature-b
232
+ ---
233
+
234
+ # Feature A
235
+
236
+ Documentation content here...
237
+
238
+ ## Dependencies
239
+
240
+ - **feature-b**: Description of dependency
241
+ ```
242
+
243
+ ### Frontmatter Fields
244
+
245
+ **Required:**
246
+ - `node_id`: Must match system-map key
247
+ - `status`: `production` | `development` | `deprecated`
248
+ - `priority`: `critical` | `high` | `medium` | `low`
249
+ - `owner`: Owner name
250
+ - `last_updated`: Date string (YYYY-MM-DD)
251
+ - `coverage`: Number (0-100)
252
+
253
+ **Optional:**
254
+ - `version`: Version string
255
+ - `coverage_source`: `auto` | `manual` (default: `auto`)
256
+ - `depends_on`: Array of node IDs
257
+ - `required_by`: Array of node IDs
258
+ - `workers`: Array of worker names
259
+ - `ssot_references`: Array of SSOT references
260
+ - `subnodes`: Array of subnode names
261
+
262
+ ## Advanced Usage
263
+
264
+ ### Custom Configuration
265
+
266
+ ```typescript
267
+ import { GDD } from '@gdd/core';
268
+ import { createLogger } from '@gdd/core';
269
+
270
+ // Create custom logger
271
+ const logger = createLogger({
272
+ verbose: true,
273
+ level: 'debug'
274
+ });
275
+
276
+ const gdd = new GDD({
277
+ systemMapPath: './system-map-v2.yaml',
278
+ docsPath: './docs/nodes-v2',
279
+ verbose: true
280
+ });
281
+ ```
282
+
283
+ ### CI/CD Integration
284
+
285
+ ```typescript
286
+ // In CI pipeline
287
+ const gdd = new GDD({
288
+ systemMapPath: './system-map-v2.yaml',
289
+ docsPath: './docs/nodes-v2'
290
+ });
291
+
292
+ const health = gdd.health();
293
+ if (health.score < 87) {
294
+ console.error(`Health score ${health.score} below threshold`);
295
+ process.exit(1);
296
+ }
297
+
298
+ const validation = gdd.validate();
299
+ if (!validation.valid) {
300
+ console.error('Validation failed');
301
+ process.exit(1);
302
+ }
303
+ ```
304
+
305
+ ### Troubleshooting
306
+
307
+ **Error: "System map file not found"**
308
+ - Ensure `systemMapPath` points to a valid `system-map-v2.yaml` file
309
+ - Check file permissions
310
+
311
+ **Error: "Node file not found"**
312
+ - Verify `docsPath` contains the node files referenced in system-map
313
+ - Check that paths in `docs` field are relative to system-map directory
314
+
315
+ **Low health score**
316
+ - Run `gdd validate` to identify issues
317
+ - Check for missing nodes, broken dependencies, or outdated coverage
318
+ - Use `gdd repair` to auto-fix common issues
319
+
320
+ ## Examples
321
+
322
+ - [Basic Usage](../examples/basic-usage/index.ts) - Complete TypeScript example
323
+ - [Sample Project](../examples/sample-project/) - Real-world project structure
324
+
325
+ ## License
326
+
327
+ MIT
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@graphito/core",
3
+ "version": "0.1.0",
4
+ "description": "Core GDD framework for graph resolution, validation, and health scoring",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "import": "./dist/index.js",
10
+ "require": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "scripts": {
15
+ "build": "tsc",
16
+ "test": "vitest run",
17
+ "test:watch": "vitest",
18
+ "test:coverage": "vitest run --coverage",
19
+ "typecheck": "tsc --noEmit"
20
+ },
21
+ "dependencies": {
22
+ "yaml": "^2.3.0",
23
+ "gray-matter": "^4.0.3",
24
+ "tiktoken": "^1.0.10",
25
+ "fast-glob": "^3.3.2"
26
+ },
27
+ "devDependencies": {
28
+ "@types/node": "^20.10.0",
29
+ "typescript": "^5.3.0",
30
+ "vitest": "^1.0.0",
31
+ "@vitest/coverage-v8": "^1.0.0"
32
+ },
33
+ "keywords": [
34
+ "graphito",
35
+ "graph-driven-development",
36
+ "documentation",
37
+ "dependency-resolution"
38
+ ],
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "git+https://github.com/Eibon7/Graphito.git",
42
+ "directory": "packages/core"
43
+ },
44
+ "bugs": {
45
+ "url": "https://github.com/Eibon7/Graphito/issues"
46
+ },
47
+ "homepage": "https://github.com/Eibon7/Graphito/tree/main/packages/core#readme",
48
+ "license": "MIT",
49
+ "publishConfig": {
50
+ "access": "public"
51
+ }
52
+ }