@weavelogic/knowledge-graph-agent 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 (74) hide show
  1. package/README.md +264 -0
  2. package/dist/cli/bin.d.ts +8 -0
  3. package/dist/cli/bin.d.ts.map +1 -0
  4. package/dist/cli/bin.js +20 -0
  5. package/dist/cli/bin.js.map +1 -0
  6. package/dist/cli/commands/claude.d.ts +11 -0
  7. package/dist/cli/commands/claude.d.ts.map +1 -0
  8. package/dist/cli/commands/claude.js +102 -0
  9. package/dist/cli/commands/claude.js.map +1 -0
  10. package/dist/cli/commands/docs.d.ts +11 -0
  11. package/dist/cli/commands/docs.d.ts.map +1 -0
  12. package/dist/cli/commands/docs.js +108 -0
  13. package/dist/cli/commands/docs.js.map +1 -0
  14. package/dist/cli/commands/graph.d.ts +11 -0
  15. package/dist/cli/commands/graph.d.ts.map +1 -0
  16. package/dist/cli/commands/graph.js +122 -0
  17. package/dist/cli/commands/graph.js.map +1 -0
  18. package/dist/cli/commands/init.d.ts +11 -0
  19. package/dist/cli/commands/init.d.ts.map +1 -0
  20. package/dist/cli/commands/init.js +80 -0
  21. package/dist/cli/commands/init.js.map +1 -0
  22. package/dist/cli/commands/search.d.ts +11 -0
  23. package/dist/cli/commands/search.d.ts.map +1 -0
  24. package/dist/cli/commands/search.js +80 -0
  25. package/dist/cli/commands/search.js.map +1 -0
  26. package/dist/cli/commands/stats.d.ts +11 -0
  27. package/dist/cli/commands/stats.d.ts.map +1 -0
  28. package/dist/cli/commands/stats.js +84 -0
  29. package/dist/cli/commands/stats.js.map +1 -0
  30. package/dist/cli/commands/sync.d.ts +11 -0
  31. package/dist/cli/commands/sync.d.ts.map +1 -0
  32. package/dist/cli/commands/sync.js +76 -0
  33. package/dist/cli/commands/sync.js.map +1 -0
  34. package/dist/cli/index.d.ts +11 -0
  35. package/dist/cli/index.d.ts.map +1 -0
  36. package/dist/cli/index.js +45 -0
  37. package/dist/cli/index.js.map +1 -0
  38. package/dist/core/database.d.ts +121 -0
  39. package/dist/core/database.d.ts.map +1 -0
  40. package/dist/core/database.js +470 -0
  41. package/dist/core/database.js.map +1 -0
  42. package/dist/core/graph.d.ts +109 -0
  43. package/dist/core/graph.d.ts.map +1 -0
  44. package/dist/core/graph.js +343 -0
  45. package/dist/core/graph.js.map +1 -0
  46. package/dist/core/security.d.ts +62 -0
  47. package/dist/core/security.d.ts.map +1 -0
  48. package/dist/core/security.js +31 -0
  49. package/dist/core/security.js.map +1 -0
  50. package/dist/core/types.d.ts +232 -0
  51. package/dist/core/types.d.ts.map +1 -0
  52. package/dist/core/types.js +37 -0
  53. package/dist/core/types.js.map +1 -0
  54. package/dist/generators/claude-md.d.ts +33 -0
  55. package/dist/generators/claude-md.d.ts.map +1 -0
  56. package/dist/generators/claude-md.js +410 -0
  57. package/dist/generators/claude-md.js.map +1 -0
  58. package/dist/generators/docs-init.d.ts +20 -0
  59. package/dist/generators/docs-init.d.ts.map +1 -0
  60. package/dist/generators/docs-init.js +625 -0
  61. package/dist/generators/docs-init.js.map +1 -0
  62. package/dist/generators/graph-generator.d.ts +41 -0
  63. package/dist/generators/graph-generator.d.ts.map +1 -0
  64. package/dist/generators/graph-generator.js +266 -0
  65. package/dist/generators/graph-generator.js.map +1 -0
  66. package/dist/index.d.ts +41 -0
  67. package/dist/index.d.ts.map +1 -0
  68. package/dist/index.js +99 -0
  69. package/dist/index.js.map +1 -0
  70. package/dist/integrations/claude-flow.d.ts +62 -0
  71. package/dist/integrations/claude-flow.d.ts.map +1 -0
  72. package/dist/integrations/claude-flow.js +243 -0
  73. package/dist/integrations/claude-flow.js.map +1 -0
  74. package/package.json +77 -0
@@ -0,0 +1,625 @@
1
+ import { existsSync, mkdirSync, writeFileSync, readFileSync } from "fs";
2
+ import { join, basename } from "path";
3
+ import Handlebars from "handlebars";
4
+ const DEFAULT_STRUCTURE = {
5
+ directories: [
6
+ // Core concepts
7
+ "concepts",
8
+ "concepts/architecture",
9
+ "concepts/patterns",
10
+ // Components
11
+ "components",
12
+ "components/ui",
13
+ "components/utilities",
14
+ // Services
15
+ "services",
16
+ "services/api",
17
+ "services/workers",
18
+ // Features
19
+ "features",
20
+ "features/core",
21
+ "features/advanced",
22
+ // Integrations
23
+ "integrations",
24
+ "integrations/databases",
25
+ "integrations/auth-providers",
26
+ "integrations/storage",
27
+ "integrations/monitoring",
28
+ // Standards
29
+ "standards",
30
+ "standards/coding-standards",
31
+ "standards/programming-languages",
32
+ "standards/build-tools",
33
+ // Guides
34
+ "guides",
35
+ "guides/getting-started",
36
+ "guides/testing",
37
+ "guides/deployment",
38
+ // References
39
+ "references",
40
+ "references/api",
41
+ "references/cli",
42
+ // Meta
43
+ "_templates",
44
+ "_attachments"
45
+ ],
46
+ files: {
47
+ "README.md": "readme",
48
+ "PRIMITIVES.md": "primitives",
49
+ "MOC.md": "moc",
50
+ "_templates/concept.md": "template-concept",
51
+ "_templates/technical.md": "template-technical",
52
+ "_templates/feature.md": "template-feature",
53
+ "_templates/service.md": "template-service",
54
+ "_templates/guide.md": "template-guide"
55
+ }
56
+ };
57
+ const TEMPLATES = {
58
+ readme: `# {{projectName}} Documentation
59
+
60
+ Welcome to the {{projectName}} knowledge base.
61
+
62
+ ## Quick Navigation
63
+
64
+ - [[MOC|Map of Content]] - Overview of all documentation
65
+ - [[PRIMITIVES|Primitives]] - Core building blocks and technologies
66
+
67
+ ## Structure
68
+
69
+ This documentation follows the Weave-NN knowledge graph methodology:
70
+
71
+ \`\`\`
72
+ docs/
73
+ ├── concepts/ # Abstract concepts and ideas
74
+ ├── components/ # Reusable components and utilities
75
+ ├── services/ # Backend services and APIs
76
+ ├── features/ # Product features and capabilities
77
+ ├── integrations/ # External integrations
78
+ ├── standards/ # Coding standards and conventions
79
+ ├── guides/ # How-to guides and tutorials
80
+ └── references/ # API and CLI references
81
+ \`\`\`
82
+
83
+ ## Getting Started
84
+
85
+ 1. Browse the [[MOC|Map of Content]] for an overview
86
+ 2. Check [[PRIMITIVES]] for technology decisions
87
+ 3. Read [[guides/getting-started/index|Getting Started Guide]]
88
+
89
+ ---
90
+ *Generated by @weave-nn/knowledge-graph-agent*
91
+ `,
92
+ primitives: `# Primitives
93
+
94
+ Core building blocks and technology decisions for {{projectName}}.
95
+
96
+ ## Overview
97
+
98
+ Primitives are the foundational technologies that power this project. Each primitive represents a key technology choice with its rationale and usage patterns.
99
+
100
+ ## Categories
101
+
102
+ ### Languages
103
+ {{#each languages}}
104
+ - [[standards/programming-languages/{{this}}|{{this}}]]
105
+ {{/each}}
106
+
107
+ ### Frameworks
108
+ {{#each frameworks}}
109
+ - [[{{category}}/{{slug}}|{{name}}]]
110
+ {{/each}}
111
+
112
+ ### Key Dependencies
113
+ {{#each dependencies}}
114
+ - [[{{category}}/{{slug}}|{{name}}]] - {{description}}
115
+ {{/each}}
116
+
117
+ ## Technology Decisions
118
+
119
+ | Category | Choice | Rationale |
120
+ |----------|--------|-----------|
121
+ | Runtime | Node.js | Modern JavaScript runtime |
122
+ | Language | TypeScript | Type safety and DX |
123
+ | Package Manager | npm/bun | Fast, reliable |
124
+
125
+ ---
126
+ *Generated by @weave-nn/knowledge-graph-agent*
127
+ `,
128
+ moc: `# Map of Content
129
+
130
+ Central navigation hub for {{projectName}} documentation.
131
+
132
+ ## Core Concepts
133
+ {{#each concepts}}
134
+ - [[concepts/{{this}}]]
135
+ {{/each}}
136
+ {{#unless concepts}}
137
+ - *No concepts documented yet*
138
+ {{/unless}}
139
+
140
+ ## Components
141
+ {{#each components}}
142
+ - [[components/{{this}}]]
143
+ {{/each}}
144
+ {{#unless components}}
145
+ - *No components documented yet*
146
+ {{/unless}}
147
+
148
+ ## Services
149
+ {{#each services}}
150
+ - [[services/{{this}}]]
151
+ {{/each}}
152
+ {{#unless services}}
153
+ - *No services documented yet*
154
+ {{/unless}}
155
+
156
+ ## Features
157
+ {{#each features}}
158
+ - [[features/{{this}}]]
159
+ {{/each}}
160
+ {{#unless features}}
161
+ - *No features documented yet*
162
+ {{/unless}}
163
+
164
+ ## Guides
165
+ - [[guides/getting-started/index|Getting Started]]
166
+ - [[guides/testing/index|Testing Guide]]
167
+ - [[guides/deployment/index|Deployment Guide]]
168
+
169
+ ## References
170
+ - [[references/api/index|API Reference]]
171
+ - [[references/cli/index|CLI Reference]]
172
+
173
+ ---
174
+ *Last updated: {{date}}*
175
+ `,
176
+ "template-concept": `---
177
+ title: {{title}}
178
+ type: concept
179
+ status: draft
180
+ tags: [concept]
181
+ created: {{date}}
182
+ updated: {{date}}
183
+ ---
184
+
185
+ # {{title}}
186
+
187
+ ## Overview
188
+
189
+ Brief description of this concept.
190
+
191
+ ## Key Ideas
192
+
193
+ - Point 1
194
+ - Point 2
195
+ - Point 3
196
+
197
+ ## Related Concepts
198
+
199
+ - [[related-concept-1]]
200
+ - [[related-concept-2]]
201
+
202
+ ## References
203
+
204
+ - External reference 1
205
+ - External reference 2
206
+ `,
207
+ "template-technical": `---
208
+ title: {{title}}
209
+ type: technical
210
+ status: draft
211
+ tags: [technical]
212
+ created: {{date}}
213
+ updated: {{date}}
214
+ ---
215
+
216
+ # {{title}}
217
+
218
+ ## Overview
219
+
220
+ Brief description of this technical component.
221
+
222
+ ## Implementation
223
+
224
+ \`\`\`typescript
225
+ // Code example
226
+ \`\`\`
227
+
228
+ ## Usage
229
+
230
+ How to use this component.
231
+
232
+ ## Configuration
233
+
234
+ Available configuration options.
235
+
236
+ ## Related
237
+
238
+ - [[related-technical-1]]
239
+ `,
240
+ "template-feature": `---
241
+ title: {{title}}
242
+ type: feature
243
+ status: draft
244
+ tags: [feature]
245
+ created: {{date}}
246
+ updated: {{date}}
247
+ ---
248
+
249
+ # {{title}}
250
+
251
+ ## Overview
252
+
253
+ Brief description of this feature.
254
+
255
+ ## User Story
256
+
257
+ As a [user type], I want [goal] so that [benefit].
258
+
259
+ ## Acceptance Criteria
260
+
261
+ - [ ] Criterion 1
262
+ - [ ] Criterion 2
263
+ - [ ] Criterion 3
264
+
265
+ ## Technical Implementation
266
+
267
+ How this feature is implemented.
268
+
269
+ ## Related Features
270
+
271
+ - [[related-feature-1]]
272
+ `,
273
+ "template-service": `---
274
+ title: {{title}}
275
+ type: service
276
+ status: draft
277
+ tags: [service, api]
278
+ created: {{date}}
279
+ updated: {{date}}
280
+ ---
281
+
282
+ # {{title}}
283
+
284
+ ## Overview
285
+
286
+ Brief description of this service.
287
+
288
+ ## Endpoints
289
+
290
+ | Method | Path | Description |
291
+ |--------|------|-------------|
292
+ | GET | /api/... | Description |
293
+ | POST | /api/... | Description |
294
+
295
+ ## Configuration
296
+
297
+ Environment variables and configuration options.
298
+
299
+ ## Dependencies
300
+
301
+ - [[dependency-1]]
302
+ - [[dependency-2]]
303
+
304
+ ## Deployment
305
+
306
+ Deployment instructions.
307
+ `,
308
+ "template-guide": `---
309
+ title: {{title}}
310
+ type: guide
311
+ status: draft
312
+ tags: [guide, tutorial]
313
+ created: {{date}}
314
+ updated: {{date}}
315
+ ---
316
+
317
+ # {{title}}
318
+
319
+ ## Prerequisites
320
+
321
+ - Prerequisite 1
322
+ - Prerequisite 2
323
+
324
+ ## Steps
325
+
326
+ ### Step 1: Title
327
+
328
+ Instructions for step 1.
329
+
330
+ ### Step 2: Title
331
+
332
+ Instructions for step 2.
333
+
334
+ ### Step 3: Title
335
+
336
+ Instructions for step 3.
337
+
338
+ ## Troubleshooting
339
+
340
+ Common issues and solutions.
341
+
342
+ ## Next Steps
343
+
344
+ - [[next-guide-1]]
345
+ - [[next-guide-2]]
346
+ `
347
+ };
348
+ async function initDocs(options) {
349
+ const result = {
350
+ success: true,
351
+ docsPath: "",
352
+ filesCreated: [],
353
+ errors: []
354
+ };
355
+ try {
356
+ const { projectRoot, docsPath = "docs", includeExamples = true, detectFramework = true } = options;
357
+ const fullDocsPath = join(projectRoot, docsPath);
358
+ result.docsPath = fullDocsPath;
359
+ const projectName = await detectProjectName(projectRoot);
360
+ const frameworks = detectFramework ? await detectFrameworks(projectRoot) : [];
361
+ const languages = detectFramework ? await detectLanguages(projectRoot) : [];
362
+ const dependencies = detectFramework ? await detectDependencies(projectRoot) : [];
363
+ const context = {
364
+ projectName,
365
+ date: (/* @__PURE__ */ new Date()).toISOString().split("T")[0],
366
+ frameworks,
367
+ languages,
368
+ dependencies,
369
+ concepts: [],
370
+ components: [],
371
+ services: [],
372
+ features: []
373
+ };
374
+ for (const dir of DEFAULT_STRUCTURE.directories) {
375
+ const dirPath = join(fullDocsPath, dir);
376
+ if (!existsSync(dirPath)) {
377
+ mkdirSync(dirPath, { recursive: true });
378
+ result.filesCreated.push(dirPath);
379
+ }
380
+ }
381
+ for (const [filePath, templateName] of Object.entries(DEFAULT_STRUCTURE.files)) {
382
+ const fullPath = join(fullDocsPath, filePath);
383
+ if (existsSync(fullPath)) {
384
+ continue;
385
+ }
386
+ const template = TEMPLATES[templateName];
387
+ if (!template) {
388
+ result.errors.push(`Template not found: ${templateName}`);
389
+ continue;
390
+ }
391
+ try {
392
+ const compiled = Handlebars.compile(template);
393
+ const content = compiled(context);
394
+ writeFileSync(fullPath, content, "utf-8");
395
+ result.filesCreated.push(fullPath);
396
+ } catch (error) {
397
+ result.errors.push(`Failed to create ${filePath}: ${error}`);
398
+ }
399
+ }
400
+ if (includeExamples) {
401
+ await createExampleFiles(fullDocsPath, context, result);
402
+ }
403
+ const obsidianPath = join(fullDocsPath, ".obsidian");
404
+ if (!existsSync(obsidianPath)) {
405
+ mkdirSync(obsidianPath, { recursive: true });
406
+ const appJson = {
407
+ "legacyEditor": false,
408
+ "livePreview": true
409
+ };
410
+ writeFileSync(join(obsidianPath, "app.json"), JSON.stringify(appJson, null, 2));
411
+ result.filesCreated.push(obsidianPath);
412
+ }
413
+ result.success = result.errors.length === 0;
414
+ } catch (error) {
415
+ result.success = false;
416
+ result.errors.push(`Init failed: ${error}`);
417
+ }
418
+ return result;
419
+ }
420
+ async function detectProjectName(projectRoot) {
421
+ try {
422
+ const pkgPath = join(projectRoot, "package.json");
423
+ if (existsSync(pkgPath)) {
424
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
425
+ if (pkg.name) {
426
+ return pkg.name.replace(/^@[^/]+\//, "");
427
+ }
428
+ }
429
+ } catch {
430
+ }
431
+ return basename(projectRoot);
432
+ }
433
+ async function detectFrameworks(projectRoot) {
434
+ const frameworks = [];
435
+ try {
436
+ const pkgPath = join(projectRoot, "package.json");
437
+ if (existsSync(pkgPath)) {
438
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
439
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies };
440
+ const patterns = [
441
+ { name: "React", packages: ["react"], category: "components/ui" },
442
+ { name: "Next.js", packages: ["next"], category: "services/api" },
443
+ { name: "Vue", packages: ["vue"], category: "components/ui" },
444
+ { name: "Express", packages: ["express"], category: "services/api" },
445
+ { name: "Fastify", packages: ["fastify"], category: "services/api" },
446
+ { name: "Prisma", packages: ["@prisma/client", "prisma"], category: "integrations/databases" },
447
+ { name: "TypeORM", packages: ["typeorm"], category: "integrations/databases" },
448
+ { name: "Jest", packages: ["jest"], category: "guides/testing" },
449
+ { name: "Vitest", packages: ["vitest"], category: "guides/testing" },
450
+ { name: "Vite", packages: ["vite"], category: "standards/build-tools" },
451
+ { name: "Webpack", packages: ["webpack"], category: "standards/build-tools" }
452
+ ];
453
+ for (const pattern of patterns) {
454
+ for (const pkg2 of pattern.packages) {
455
+ if (deps[pkg2]) {
456
+ frameworks.push({
457
+ name: pattern.name,
458
+ slug: pattern.name.toLowerCase().replace(/[^a-z0-9]+/g, "-"),
459
+ category: pattern.category,
460
+ version: deps[pkg2]
461
+ });
462
+ break;
463
+ }
464
+ }
465
+ }
466
+ }
467
+ } catch {
468
+ }
469
+ return frameworks;
470
+ }
471
+ async function detectLanguages(projectRoot) {
472
+ const languages = /* @__PURE__ */ new Set();
473
+ try {
474
+ if (existsSync(join(projectRoot, "tsconfig.json"))) {
475
+ languages.add("typescript");
476
+ }
477
+ if (existsSync(join(projectRoot, "package.json"))) {
478
+ languages.add("javascript");
479
+ }
480
+ if (existsSync(join(projectRoot, "requirements.txt")) || existsSync(join(projectRoot, "pyproject.toml"))) {
481
+ languages.add("python");
482
+ }
483
+ if (existsSync(join(projectRoot, "Cargo.toml"))) {
484
+ languages.add("rust");
485
+ }
486
+ if (existsSync(join(projectRoot, "go.mod"))) {
487
+ languages.add("go");
488
+ }
489
+ } catch {
490
+ }
491
+ return Array.from(languages);
492
+ }
493
+ async function detectDependencies(projectRoot) {
494
+ const deps = [];
495
+ try {
496
+ const pkgPath = join(projectRoot, "package.json");
497
+ if (existsSync(pkgPath)) {
498
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
499
+ const allDeps = { ...pkg.dependencies };
500
+ const topDeps = Object.keys(allDeps).slice(0, 10);
501
+ for (const dep of topDeps) {
502
+ deps.push({
503
+ name: dep,
504
+ slug: dep.replace(/^@/, "").replace(/[^a-z0-9]+/g, "-"),
505
+ category: "components/utilities",
506
+ description: `Version ${allDeps[dep]}`
507
+ });
508
+ }
509
+ }
510
+ } catch {
511
+ }
512
+ return deps;
513
+ }
514
+ async function createExampleFiles(docsPath, context, result) {
515
+ const examples = [
516
+ {
517
+ path: "guides/getting-started/index.md",
518
+ content: `---
519
+ title: Getting Started
520
+ type: guide
521
+ status: active
522
+ tags: [guide, getting-started]
523
+ created: ${context.date}
524
+ updated: ${context.date}
525
+ ---
526
+
527
+ # Getting Started with ${context.projectName}
528
+
529
+ Welcome! This guide will help you get up and running.
530
+
531
+ ## Prerequisites
532
+
533
+ - Node.js 20+
534
+ - npm or bun
535
+
536
+ ## Installation
537
+
538
+ \`\`\`bash
539
+ npm install
540
+ \`\`\`
541
+
542
+ ## Quick Start
543
+
544
+ 1. Clone the repository
545
+ 2. Install dependencies
546
+ 3. Run the development server
547
+
548
+ ## Next Steps
549
+
550
+ - Explore the [[MOC|Map of Content]]
551
+ - Review [[PRIMITIVES|Technology Primitives]]
552
+ `
553
+ },
554
+ {
555
+ path: "concepts/architecture/index.md",
556
+ content: `---
557
+ title: Architecture Overview
558
+ type: concept
559
+ status: active
560
+ tags: [architecture, concept]
561
+ created: ${context.date}
562
+ updated: ${context.date}
563
+ ---
564
+
565
+ # Architecture Overview
566
+
567
+ High-level architecture of ${context.projectName}.
568
+
569
+ ## System Diagram
570
+
571
+ \`\`\`
572
+ ┌──────────────┐ ┌──────────────┐
573
+ │ Frontend │────▶│ Backend │
574
+ └──────────────┘ └──────────────┘
575
+
576
+ ┌──────▼──────┐
577
+ │ Database │
578
+ └─────────────┘
579
+ \`\`\`
580
+
581
+ ## Key Components
582
+
583
+ - **Frontend**: User interface
584
+ - **Backend**: API and business logic
585
+ - **Database**: Data persistence
586
+
587
+ ## Design Principles
588
+
589
+ 1. Separation of concerns
590
+ 2. Single responsibility
591
+ 3. Dependency injection
592
+ `
593
+ }
594
+ ];
595
+ for (const example of examples) {
596
+ const fullPath = join(docsPath, example.path);
597
+ if (!existsSync(fullPath)) {
598
+ const dir = join(fullPath, "..");
599
+ if (!existsSync(dir)) {
600
+ mkdirSync(dir, { recursive: true });
601
+ }
602
+ writeFileSync(fullPath, example.content, "utf-8");
603
+ result.filesCreated.push(fullPath);
604
+ }
605
+ }
606
+ }
607
+ function docsExist(projectRoot, docsPath = "docs") {
608
+ return existsSync(join(projectRoot, docsPath));
609
+ }
610
+ function getDocsPath(projectRoot) {
611
+ const possiblePaths = ["docs", "documentation", "doc", "wiki"];
612
+ for (const path of possiblePaths) {
613
+ const fullPath = join(projectRoot, path);
614
+ if (existsSync(fullPath)) {
615
+ return fullPath;
616
+ }
617
+ }
618
+ return null;
619
+ }
620
+ export {
621
+ docsExist,
622
+ getDocsPath,
623
+ initDocs
624
+ };
625
+ //# sourceMappingURL=docs-init.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docs-init.js","sources":["../../src/generators/docs-init.ts"],"sourcesContent":["/**\n * Docs Directory Initializer\n *\n * Creates the initial docs directory structure following the weave-nn\n * methodology with proper PRIMITIVES.md taxonomy.\n */\n\nimport { existsSync, mkdirSync, writeFileSync, readFileSync } from 'fs';\nimport { join, basename } from 'path';\nimport fg from 'fast-glob';\nimport Handlebars from 'handlebars';\nimport type {\n DocsInitOptions,\n DocsInitResult,\n NodeType,\n} from '../core/types.js';\n\n/**\n * Default docs structure based on PRIMITIVES.md taxonomy\n */\nconst DEFAULT_STRUCTURE = {\n directories: [\n // Core concepts\n 'concepts',\n 'concepts/architecture',\n 'concepts/patterns',\n\n // Components\n 'components',\n 'components/ui',\n 'components/utilities',\n\n // Services\n 'services',\n 'services/api',\n 'services/workers',\n\n // Features\n 'features',\n 'features/core',\n 'features/advanced',\n\n // Integrations\n 'integrations',\n 'integrations/databases',\n 'integrations/auth-providers',\n 'integrations/storage',\n 'integrations/monitoring',\n\n // Standards\n 'standards',\n 'standards/coding-standards',\n 'standards/programming-languages',\n 'standards/build-tools',\n\n // Guides\n 'guides',\n 'guides/getting-started',\n 'guides/testing',\n 'guides/deployment',\n\n // References\n 'references',\n 'references/api',\n 'references/cli',\n\n // Meta\n '_templates',\n '_attachments',\n ],\n files: {\n 'README.md': 'readme',\n 'PRIMITIVES.md': 'primitives',\n 'MOC.md': 'moc',\n '_templates/concept.md': 'template-concept',\n '_templates/technical.md': 'template-technical',\n '_templates/feature.md': 'template-feature',\n '_templates/service.md': 'template-service',\n '_templates/guide.md': 'template-guide',\n },\n};\n\n/**\n * Template content for docs files\n */\nconst TEMPLATES: Record<string, string> = {\n readme: `# {{projectName}} Documentation\n\nWelcome to the {{projectName}} knowledge base.\n\n## Quick Navigation\n\n- [[MOC|Map of Content]] - Overview of all documentation\n- [[PRIMITIVES|Primitives]] - Core building blocks and technologies\n\n## Structure\n\nThis documentation follows the Weave-NN knowledge graph methodology:\n\n\\`\\`\\`\ndocs/\n├── concepts/ # Abstract concepts and ideas\n├── components/ # Reusable components and utilities\n├── services/ # Backend services and APIs\n├── features/ # Product features and capabilities\n├── integrations/ # External integrations\n├── standards/ # Coding standards and conventions\n├── guides/ # How-to guides and tutorials\n└── references/ # API and CLI references\n\\`\\`\\`\n\n## Getting Started\n\n1. Browse the [[MOC|Map of Content]] for an overview\n2. Check [[PRIMITIVES]] for technology decisions\n3. Read [[guides/getting-started/index|Getting Started Guide]]\n\n---\n*Generated by @weave-nn/knowledge-graph-agent*\n`,\n\n primitives: `# Primitives\n\nCore building blocks and technology decisions for {{projectName}}.\n\n## Overview\n\nPrimitives are the foundational technologies that power this project. Each primitive represents a key technology choice with its rationale and usage patterns.\n\n## Categories\n\n### Languages\n{{#each languages}}\n- [[standards/programming-languages/{{this}}|{{this}}]]\n{{/each}}\n\n### Frameworks\n{{#each frameworks}}\n- [[{{category}}/{{slug}}|{{name}}]]\n{{/each}}\n\n### Key Dependencies\n{{#each dependencies}}\n- [[{{category}}/{{slug}}|{{name}}]] - {{description}}\n{{/each}}\n\n## Technology Decisions\n\n| Category | Choice | Rationale |\n|----------|--------|-----------|\n| Runtime | Node.js | Modern JavaScript runtime |\n| Language | TypeScript | Type safety and DX |\n| Package Manager | npm/bun | Fast, reliable |\n\n---\n*Generated by @weave-nn/knowledge-graph-agent*\n`,\n\n moc: `# Map of Content\n\nCentral navigation hub for {{projectName}} documentation.\n\n## Core Concepts\n{{#each concepts}}\n- [[concepts/{{this}}]]\n{{/each}}\n{{#unless concepts}}\n- *No concepts documented yet*\n{{/unless}}\n\n## Components\n{{#each components}}\n- [[components/{{this}}]]\n{{/each}}\n{{#unless components}}\n- *No components documented yet*\n{{/unless}}\n\n## Services\n{{#each services}}\n- [[services/{{this}}]]\n{{/each}}\n{{#unless services}}\n- *No services documented yet*\n{{/unless}}\n\n## Features\n{{#each features}}\n- [[features/{{this}}]]\n{{/each}}\n{{#unless features}}\n- *No features documented yet*\n{{/unless}}\n\n## Guides\n- [[guides/getting-started/index|Getting Started]]\n- [[guides/testing/index|Testing Guide]]\n- [[guides/deployment/index|Deployment Guide]]\n\n## References\n- [[references/api/index|API Reference]]\n- [[references/cli/index|CLI Reference]]\n\n---\n*Last updated: {{date}}*\n`,\n\n 'template-concept': `---\ntitle: {{title}}\ntype: concept\nstatus: draft\ntags: [concept]\ncreated: {{date}}\nupdated: {{date}}\n---\n\n# {{title}}\n\n## Overview\n\nBrief description of this concept.\n\n## Key Ideas\n\n- Point 1\n- Point 2\n- Point 3\n\n## Related Concepts\n\n- [[related-concept-1]]\n- [[related-concept-2]]\n\n## References\n\n- External reference 1\n- External reference 2\n`,\n\n 'template-technical': `---\ntitle: {{title}}\ntype: technical\nstatus: draft\ntags: [technical]\ncreated: {{date}}\nupdated: {{date}}\n---\n\n# {{title}}\n\n## Overview\n\nBrief description of this technical component.\n\n## Implementation\n\n\\`\\`\\`typescript\n// Code example\n\\`\\`\\`\n\n## Usage\n\nHow to use this component.\n\n## Configuration\n\nAvailable configuration options.\n\n## Related\n\n- [[related-technical-1]]\n`,\n\n 'template-feature': `---\ntitle: {{title}}\ntype: feature\nstatus: draft\ntags: [feature]\ncreated: {{date}}\nupdated: {{date}}\n---\n\n# {{title}}\n\n## Overview\n\nBrief description of this feature.\n\n## User Story\n\nAs a [user type], I want [goal] so that [benefit].\n\n## Acceptance Criteria\n\n- [ ] Criterion 1\n- [ ] Criterion 2\n- [ ] Criterion 3\n\n## Technical Implementation\n\nHow this feature is implemented.\n\n## Related Features\n\n- [[related-feature-1]]\n`,\n\n 'template-service': `---\ntitle: {{title}}\ntype: service\nstatus: draft\ntags: [service, api]\ncreated: {{date}}\nupdated: {{date}}\n---\n\n# {{title}}\n\n## Overview\n\nBrief description of this service.\n\n## Endpoints\n\n| Method | Path | Description |\n|--------|------|-------------|\n| GET | /api/... | Description |\n| POST | /api/... | Description |\n\n## Configuration\n\nEnvironment variables and configuration options.\n\n## Dependencies\n\n- [[dependency-1]]\n- [[dependency-2]]\n\n## Deployment\n\nDeployment instructions.\n`,\n\n 'template-guide': `---\ntitle: {{title}}\ntype: guide\nstatus: draft\ntags: [guide, tutorial]\ncreated: {{date}}\nupdated: {{date}}\n---\n\n# {{title}}\n\n## Prerequisites\n\n- Prerequisite 1\n- Prerequisite 2\n\n## Steps\n\n### Step 1: Title\n\nInstructions for step 1.\n\n### Step 2: Title\n\nInstructions for step 2.\n\n### Step 3: Title\n\nInstructions for step 3.\n\n## Troubleshooting\n\nCommon issues and solutions.\n\n## Next Steps\n\n- [[next-guide-1]]\n- [[next-guide-2]]\n`,\n};\n\n/**\n * Framework detection result\n */\ninterface FrameworkInfo {\n name: string;\n slug: string;\n category: string;\n version?: string;\n}\n\n/**\n * Initialize docs directory\n */\nexport async function initDocs(options: DocsInitOptions): Promise<DocsInitResult> {\n const result: DocsInitResult = {\n success: true,\n docsPath: '',\n filesCreated: [],\n errors: [],\n };\n\n try {\n const { projectRoot, docsPath = 'docs', includeExamples = true, detectFramework = true } = options;\n const fullDocsPath = join(projectRoot, docsPath);\n result.docsPath = fullDocsPath;\n\n // Detect project information\n const projectName = await detectProjectName(projectRoot);\n const frameworks = detectFramework ? await detectFrameworks(projectRoot) : [];\n const languages = detectFramework ? await detectLanguages(projectRoot) : [];\n const dependencies = detectFramework ? await detectDependencies(projectRoot) : [];\n\n // Create template context\n const context = {\n projectName,\n date: new Date().toISOString().split('T')[0],\n frameworks,\n languages,\n dependencies,\n concepts: [],\n components: [],\n services: [],\n features: [],\n };\n\n // Create directories\n for (const dir of DEFAULT_STRUCTURE.directories) {\n const dirPath = join(fullDocsPath, dir);\n if (!existsSync(dirPath)) {\n mkdirSync(dirPath, { recursive: true });\n result.filesCreated.push(dirPath);\n }\n }\n\n // Create files from templates\n for (const [filePath, templateName] of Object.entries(DEFAULT_STRUCTURE.files)) {\n const fullPath = join(fullDocsPath, filePath);\n\n // Skip if file exists\n if (existsSync(fullPath)) {\n continue;\n }\n\n // Get template and compile\n const template = TEMPLATES[templateName];\n if (!template) {\n result.errors.push(`Template not found: ${templateName}`);\n continue;\n }\n\n try {\n const compiled = Handlebars.compile(template);\n const content = compiled(context);\n writeFileSync(fullPath, content, 'utf-8');\n result.filesCreated.push(fullPath);\n } catch (error) {\n result.errors.push(`Failed to create ${filePath}: ${error}`);\n }\n }\n\n // Create example files if requested\n if (includeExamples) {\n await createExampleFiles(fullDocsPath, context, result);\n }\n\n // Create .obsidian folder for vault detection\n const obsidianPath = join(fullDocsPath, '.obsidian');\n if (!existsSync(obsidianPath)) {\n mkdirSync(obsidianPath, { recursive: true });\n\n // Create minimal app.json for Obsidian\n const appJson = {\n \"legacyEditor\": false,\n \"livePreview\": true,\n };\n writeFileSync(join(obsidianPath, 'app.json'), JSON.stringify(appJson, null, 2));\n result.filesCreated.push(obsidianPath);\n }\n\n result.success = result.errors.length === 0;\n } catch (error) {\n result.success = false;\n result.errors.push(`Init failed: ${error}`);\n }\n\n return result;\n}\n\n/**\n * Detect project name from package.json or directory\n */\nasync function detectProjectName(projectRoot: string): Promise<string> {\n try {\n const pkgPath = join(projectRoot, 'package.json');\n if (existsSync(pkgPath)) {\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));\n if (pkg.name) {\n // Remove scope if present\n return pkg.name.replace(/^@[^/]+\\//, '');\n }\n }\n } catch {\n // Ignore errors\n }\n\n // Fall back to directory name\n return basename(projectRoot);\n}\n\n/**\n * Detect frameworks from project files\n */\nasync function detectFrameworks(projectRoot: string): Promise<FrameworkInfo[]> {\n const frameworks: FrameworkInfo[] = [];\n\n try {\n const pkgPath = join(projectRoot, 'package.json');\n if (existsSync(pkgPath)) {\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));\n const deps = { ...pkg.dependencies, ...pkg.devDependencies };\n\n // Framework detection patterns\n const patterns: Array<{ name: string; packages: string[]; category: string }> = [\n { name: 'React', packages: ['react'], category: 'components/ui' },\n { name: 'Next.js', packages: ['next'], category: 'services/api' },\n { name: 'Vue', packages: ['vue'], category: 'components/ui' },\n { name: 'Express', packages: ['express'], category: 'services/api' },\n { name: 'Fastify', packages: ['fastify'], category: 'services/api' },\n { name: 'Prisma', packages: ['@prisma/client', 'prisma'], category: 'integrations/databases' },\n { name: 'TypeORM', packages: ['typeorm'], category: 'integrations/databases' },\n { name: 'Jest', packages: ['jest'], category: 'guides/testing' },\n { name: 'Vitest', packages: ['vitest'], category: 'guides/testing' },\n { name: 'Vite', packages: ['vite'], category: 'standards/build-tools' },\n { name: 'Webpack', packages: ['webpack'], category: 'standards/build-tools' },\n ];\n\n for (const pattern of patterns) {\n for (const pkg of pattern.packages) {\n if (deps[pkg]) {\n frameworks.push({\n name: pattern.name,\n slug: pattern.name.toLowerCase().replace(/[^a-z0-9]+/g, '-'),\n category: pattern.category,\n version: deps[pkg],\n });\n break;\n }\n }\n }\n }\n } catch {\n // Ignore errors\n }\n\n return frameworks;\n}\n\n/**\n * Detect programming languages used\n */\nasync function detectLanguages(projectRoot: string): Promise<string[]> {\n const languages: Set<string> = new Set();\n\n try {\n // Check for TypeScript\n if (existsSync(join(projectRoot, 'tsconfig.json'))) {\n languages.add('typescript');\n }\n\n // Check for package.json (JavaScript/Node.js)\n if (existsSync(join(projectRoot, 'package.json'))) {\n languages.add('javascript');\n }\n\n // Check for Python\n if (existsSync(join(projectRoot, 'requirements.txt')) ||\n existsSync(join(projectRoot, 'pyproject.toml'))) {\n languages.add('python');\n }\n\n // Check for Rust\n if (existsSync(join(projectRoot, 'Cargo.toml'))) {\n languages.add('rust');\n }\n\n // Check for Go\n if (existsSync(join(projectRoot, 'go.mod'))) {\n languages.add('go');\n }\n } catch {\n // Ignore errors\n }\n\n return Array.from(languages);\n}\n\n/**\n * Detect major dependencies\n */\nasync function detectDependencies(projectRoot: string): Promise<Array<{ name: string; slug: string; category: string; description: string }>> {\n const deps: Array<{ name: string; slug: string; category: string; description: string }> = [];\n\n try {\n const pkgPath = join(projectRoot, 'package.json');\n if (existsSync(pkgPath)) {\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));\n const allDeps = { ...pkg.dependencies };\n\n // Top dependencies to document\n const topDeps = Object.keys(allDeps).slice(0, 10);\n\n for (const dep of topDeps) {\n deps.push({\n name: dep,\n slug: dep.replace(/^@/, '').replace(/[^a-z0-9]+/g, '-'),\n category: 'components/utilities',\n description: `Version ${allDeps[dep]}`,\n });\n }\n }\n } catch {\n // Ignore errors\n }\n\n return deps;\n}\n\n/**\n * Create example documentation files\n */\nasync function createExampleFiles(\n docsPath: string,\n context: Record<string, unknown>,\n result: DocsInitResult\n): Promise<void> {\n const examples = [\n {\n path: 'guides/getting-started/index.md',\n content: `---\ntitle: Getting Started\ntype: guide\nstatus: active\ntags: [guide, getting-started]\ncreated: ${context.date}\nupdated: ${context.date}\n---\n\n# Getting Started with ${context.projectName}\n\nWelcome! This guide will help you get up and running.\n\n## Prerequisites\n\n- Node.js 20+\n- npm or bun\n\n## Installation\n\n\\`\\`\\`bash\nnpm install\n\\`\\`\\`\n\n## Quick Start\n\n1. Clone the repository\n2. Install dependencies\n3. Run the development server\n\n## Next Steps\n\n- Explore the [[MOC|Map of Content]]\n- Review [[PRIMITIVES|Technology Primitives]]\n`,\n },\n {\n path: 'concepts/architecture/index.md',\n content: `---\ntitle: Architecture Overview\ntype: concept\nstatus: active\ntags: [architecture, concept]\ncreated: ${context.date}\nupdated: ${context.date}\n---\n\n# Architecture Overview\n\nHigh-level architecture of ${context.projectName}.\n\n## System Diagram\n\n\\`\\`\\`\n┌──────────────┐ ┌──────────────┐\n│ Frontend │────▶│ Backend │\n└──────────────┘ └──────────────┘\n │\n ┌──────▼──────┐\n │ Database │\n └─────────────┘\n\\`\\`\\`\n\n## Key Components\n\n- **Frontend**: User interface\n- **Backend**: API and business logic\n- **Database**: Data persistence\n\n## Design Principles\n\n1. Separation of concerns\n2. Single responsibility\n3. Dependency injection\n`,\n },\n ];\n\n for (const example of examples) {\n const fullPath = join(docsPath, example.path);\n if (!existsSync(fullPath)) {\n const dir = join(fullPath, '..');\n if (!existsSync(dir)) {\n mkdirSync(dir, { recursive: true });\n }\n writeFileSync(fullPath, example.content, 'utf-8');\n result.filesCreated.push(fullPath);\n }\n }\n}\n\n/**\n * Check if docs directory exists\n */\nexport function docsExist(projectRoot: string, docsPath = 'docs'): boolean {\n return existsSync(join(projectRoot, docsPath));\n}\n\n/**\n * Get docs path for a project\n */\nexport function getDocsPath(projectRoot: string): string | null {\n const possiblePaths = ['docs', 'documentation', 'doc', 'wiki'];\n\n for (const path of possiblePaths) {\n const fullPath = join(projectRoot, path);\n if (existsSync(fullPath)) {\n return fullPath;\n }\n }\n\n return null;\n}\n"],"names":["pkg"],"mappings":";;;AAoBA,MAAM,oBAAoB;AAAA,EACxB,aAAa;AAAA;AAAA,IAEX;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IAGA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IAGA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IAGA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IAGA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IAGA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IAGA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IAGA;AAAA,IACA;AAAA,IACA;AAAA;AAAA,IAGA;AAAA,IACA;AAAA,EAAA;AAAA,EAEF,OAAO;AAAA,IACL,aAAa;AAAA,IACb,iBAAiB;AAAA,IACjB,UAAU;AAAA,IACV,yBAAyB;AAAA,IACzB,2BAA2B;AAAA,IAC3B,yBAAyB;AAAA,IACzB,yBAAyB;AAAA,IACzB,uBAAuB;AAAA,EAAA;AAE3B;AAKA,MAAM,YAAoC;AAAA,EACxC,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmCR,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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