@esthernandez/vibe-doc 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 (95) hide show
  1. package/dist/checker/index.d.ts +34 -0
  2. package/dist/checker/index.d.ts.map +1 -0
  3. package/dist/checker/index.js +154 -0
  4. package/dist/checker/staleness.d.ts +26 -0
  5. package/dist/checker/staleness.d.ts.map +1 -0
  6. package/dist/checker/staleness.js +56 -0
  7. package/dist/classifier/index.d.ts +26 -0
  8. package/dist/classifier/index.d.ts.map +1 -0
  9. package/dist/classifier/index.js +146 -0
  10. package/dist/classifier/llm-prompt.d.ts +12 -0
  11. package/dist/classifier/llm-prompt.d.ts.map +1 -0
  12. package/dist/classifier/llm-prompt.js +123 -0
  13. package/dist/classifier/scoring-engine.d.ts +41 -0
  14. package/dist/classifier/scoring-engine.d.ts.map +1 -0
  15. package/dist/classifier/scoring-engine.js +197 -0
  16. package/dist/classifier/signals.d.ts +16 -0
  17. package/dist/classifier/signals.d.ts.map +1 -0
  18. package/dist/classifier/signals.js +305 -0
  19. package/dist/gap-analyzer/breadcrumbs.d.ts +18 -0
  20. package/dist/gap-analyzer/breadcrumbs.d.ts.map +1 -0
  21. package/dist/gap-analyzer/breadcrumbs.js +314 -0
  22. package/dist/gap-analyzer/index.d.ts +13 -0
  23. package/dist/gap-analyzer/index.d.ts.map +1 -0
  24. package/dist/gap-analyzer/index.js +88 -0
  25. package/dist/gap-analyzer/matrix.d.ts +29 -0
  26. package/dist/gap-analyzer/matrix.d.ts.map +1 -0
  27. package/dist/gap-analyzer/matrix.js +137 -0
  28. package/dist/gap-analyzer/tier-assigner.d.ts +22 -0
  29. package/dist/gap-analyzer/tier-assigner.d.ts.map +1 -0
  30. package/dist/gap-analyzer/tier-assigner.js +112 -0
  31. package/dist/generator/docx-writer.d.ts +15 -0
  32. package/dist/generator/docx-writer.d.ts.map +1 -0
  33. package/dist/generator/docx-writer.js +271 -0
  34. package/dist/generator/extractor.d.ts +11 -0
  35. package/dist/generator/extractor.d.ts.map +1 -0
  36. package/dist/generator/extractor.js +459 -0
  37. package/dist/generator/index.d.ts +25 -0
  38. package/dist/generator/index.d.ts.map +1 -0
  39. package/dist/generator/index.js +106 -0
  40. package/dist/generator/markdown-writer.d.ts +27 -0
  41. package/dist/generator/markdown-writer.d.ts.map +1 -0
  42. package/dist/generator/markdown-writer.js +85 -0
  43. package/dist/index.d.ts +7 -0
  44. package/dist/index.d.ts.map +1 -0
  45. package/dist/index.js +372 -0
  46. package/dist/scanner/artifact-scanner.d.ts +16 -0
  47. package/dist/scanner/artifact-scanner.d.ts.map +1 -0
  48. package/dist/scanner/artifact-scanner.js +189 -0
  49. package/dist/scanner/code-scanner.d.ts +17 -0
  50. package/dist/scanner/code-scanner.d.ts.map +1 -0
  51. package/dist/scanner/code-scanner.js +69 -0
  52. package/dist/scanner/file-scanner.d.ts +16 -0
  53. package/dist/scanner/file-scanner.d.ts.map +1 -0
  54. package/dist/scanner/file-scanner.js +119 -0
  55. package/dist/scanner/git-scanner.d.ts +10 -0
  56. package/dist/scanner/git-scanner.d.ts.map +1 -0
  57. package/dist/scanner/git-scanner.js +120 -0
  58. package/dist/scanner/index.d.ts +15 -0
  59. package/dist/scanner/index.d.ts.map +1 -0
  60. package/dist/scanner/index.js +106 -0
  61. package/dist/state/index.d.ts +20 -0
  62. package/dist/state/index.d.ts.map +1 -0
  63. package/dist/state/index.js +141 -0
  64. package/dist/state/schema.d.ts +101 -0
  65. package/dist/state/schema.d.ts.map +1 -0
  66. package/dist/state/schema.js +6 -0
  67. package/dist/templates/embedded/adr.md +45 -0
  68. package/dist/templates/embedded/api-spec.md +55 -0
  69. package/dist/templates/embedded/data-model.md +55 -0
  70. package/dist/templates/embedded/deployment-procedure.md +63 -0
  71. package/dist/templates/embedded/runbook.md +55 -0
  72. package/dist/templates/embedded/test-plan.md +55 -0
  73. package/dist/templates/embedded/threat-model.md +47 -0
  74. package/dist/templates/index.d.ts +20 -0
  75. package/dist/templates/index.d.ts.map +1 -0
  76. package/dist/templates/index.js +106 -0
  77. package/dist/templates/registry.d.ts +31 -0
  78. package/dist/templates/registry.d.ts.map +1 -0
  79. package/dist/templates/registry.js +172 -0
  80. package/dist/templates/renderer.d.ts +26 -0
  81. package/dist/templates/renderer.d.ts.map +1 -0
  82. package/dist/templates/renderer.js +145 -0
  83. package/dist/utils/language-detect.d.ts +14 -0
  84. package/dist/utils/language-detect.d.ts.map +1 -0
  85. package/dist/utils/language-detect.js +58 -0
  86. package/dist/utils/logger.d.ts +16 -0
  87. package/dist/utils/logger.d.ts.map +1 -0
  88. package/dist/utils/logger.js +35 -0
  89. package/dist/versioning/differ.d.ts +20 -0
  90. package/dist/versioning/differ.d.ts.map +1 -0
  91. package/dist/versioning/differ.js +160 -0
  92. package/dist/versioning/index.d.ts +44 -0
  93. package/dist/versioning/index.d.ts.map +1 -0
  94. package/dist/versioning/index.js +165 -0
  95. package/package.json +40 -0
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ /**
3
+ * Tier Assigner Module
4
+ * Assesses gaps based on breadcrumb searches and requirement analysis
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.getBreadcrumbs = void 0;
8
+ exports.assessGaps = assessGaps;
9
+ const logger_1 = require("../utils/logger");
10
+ /**
11
+ * Assess documentation gaps based on artifact inventory
12
+ */
13
+ function assessGaps(requirements, inventory, breadcrumbs) {
14
+ const gaps = [];
15
+ const allArtifactText = buildArtifactSearchSpace(inventory);
16
+ const artifactsScanned = inventory.categories.sourceCode.count +
17
+ inventory.categories.documentation.count +
18
+ inventory.categories.configuration.count;
19
+ for (const req of requirements) {
20
+ const breadcrumb = breadcrumbs.get(req.docType);
21
+ if (!breadcrumb) {
22
+ logger_1.logger.warn('No breadcrumbs for doc type', { docType: req.docType });
23
+ continue;
24
+ }
25
+ const { found, missing } = searchForDocumentationEvidence(breadcrumb, inventory);
26
+ const gap = {
27
+ docType: req.docType,
28
+ tier: req.tier,
29
+ category: req.category,
30
+ artifactsScanned,
31
+ found,
32
+ missing,
33
+ rationale: buildGapRationale(req.tier, found, missing),
34
+ };
35
+ gaps.push(gap);
36
+ }
37
+ return gaps;
38
+ }
39
+ /**
40
+ * Search for evidence of a documentation type in artifacts
41
+ */
42
+ function searchForDocumentationEvidence(breadcrumb, inventory) {
43
+ let found = 0;
44
+ let missing = 0;
45
+ // Search in documentation files
46
+ const docFiles = inventory.categories.documentation.files;
47
+ const docMatches = docFiles.filter((f) => breadcrumb.keywords.some((kw) => f.toLowerCase().includes(kw))).length;
48
+ // Search in source code files
49
+ const sourceFiles = inventory.categories.sourceCode.files;
50
+ const codeMatches = sourceFiles.filter((f) => breadcrumb.filePatterns.some((pattern) => matchPattern(f, pattern))).length;
51
+ // Search in config files
52
+ const configFiles = inventory.categories.configuration.files;
53
+ const configMatches = configFiles.filter((f) => breadcrumb.filePatterns.some((pattern) => matchPattern(f, pattern))).length;
54
+ // Calculate total found vs missing
55
+ found = docMatches + codeMatches + configMatches;
56
+ const expectedSections = breadcrumb.requiredSections.length;
57
+ missing = Math.max(0, expectedSections - found);
58
+ logger_1.logger.debug('Documentation evidence search', {
59
+ docType: breadcrumb.docType,
60
+ found,
61
+ missing,
62
+ docMatches,
63
+ codeMatches,
64
+ configMatches,
65
+ });
66
+ return { found, missing };
67
+ }
68
+ /**
69
+ * Simple glob pattern matcher
70
+ */
71
+ function matchPattern(filePath, pattern) {
72
+ const regex = patternToRegex(pattern);
73
+ return regex.test(filePath.toLowerCase());
74
+ }
75
+ /**
76
+ * Convert glob pattern to regex
77
+ */
78
+ function patternToRegex(pattern) {
79
+ const escaped = pattern.replace(/[.+^${}()|[\]\\]/g, '\\$&');
80
+ const globRegex = escaped
81
+ .replace(/\*\*/g, '.*')
82
+ .replace(/\*/g, '[^/]*')
83
+ .replace(/\?/g, '.');
84
+ return new RegExp(`^${globRegex}$`, 'i');
85
+ }
86
+ /**
87
+ * Build a rationale for the gap
88
+ */
89
+ function buildGapRationale(tier, found, missing) {
90
+ const tierLabel = tier.charAt(0).toUpperCase() + tier.slice(1);
91
+ if (found === 0) {
92
+ return `${tierLabel}: No evidence found in codebase.`;
93
+ }
94
+ if (missing === 0) {
95
+ return `${tierLabel}: All expected sections found.`;
96
+ }
97
+ const missingPercent = Math.round((missing / (found + missing)) * 100);
98
+ return `${tierLabel}: Found ${found} sections, missing ${missing} (${missingPercent}% incomplete).`;
99
+ }
100
+ /**
101
+ * Build a searchable text space from all artifacts
102
+ */
103
+ function buildArtifactSearchSpace(inventory) {
104
+ const allFiles = [
105
+ ...inventory.categories.sourceCode.files,
106
+ ...inventory.categories.documentation.files,
107
+ ...inventory.categories.configuration.files,
108
+ ];
109
+ return allFiles.join('\n').toLowerCase();
110
+ }
111
+ var breadcrumbs_1 = require("./breadcrumbs");
112
+ Object.defineProperty(exports, "getBreadcrumbs", { enumerable: true, get: function () { return breadcrumbs_1.getBreadcrumbs; } });
@@ -0,0 +1,15 @@
1
+ /**
2
+ * DOCX Writer Module
3
+ * Converts rendered markdown content into professional .docx files
4
+ */
5
+ import { DocMetadata } from './markdown-writer';
6
+ /**
7
+ * Write rendered markdown content to a .docx file
8
+ * @param renderedContent - The rendered markdown content
9
+ * @param docType - Type of document (e.g., 'adr', 'runbook')
10
+ * @param projectPath - Root path of the project
11
+ * @param metadata - Document metadata
12
+ * @returns Promise resolving to the full path of the written file
13
+ */
14
+ export declare function writeDocx(renderedContent: string, docType: string, projectPath: string, metadata: DocMetadata): Promise<string>;
15
+ //# sourceMappingURL=docx-writer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docx-writer.d.ts","sourceRoot":"","sources":["../../src/generator/docx-writer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAoBH,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAOhD;;;;;;;GAOG;AACH,wBAAsB,SAAS,CAC7B,eAAe,EAAE,MAAM,EACvB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,WAAW,GACpB,OAAO,CAAC,MAAM,CAAC,CA0CjB"}
@@ -0,0 +1,271 @@
1
+ "use strict";
2
+ /**
3
+ * DOCX Writer Module
4
+ * Converts rendered markdown content into professional .docx files
5
+ */
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
19
+ }) : function(o, v) {
20
+ o["default"] = v;
21
+ });
22
+ var __importStar = (this && this.__importStar) || (function () {
23
+ var ownKeys = function(o) {
24
+ ownKeys = Object.getOwnPropertyNames || function (o) {
25
+ var ar = [];
26
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
27
+ return ar;
28
+ };
29
+ return ownKeys(o);
30
+ };
31
+ return function (mod) {
32
+ if (mod && mod.__esModule) return mod;
33
+ var result = {};
34
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
35
+ __setModuleDefault(result, mod);
36
+ return result;
37
+ };
38
+ })();
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.writeDocx = writeDocx;
41
+ const path = __importStar(require("path"));
42
+ const fs = __importStar(require("fs"));
43
+ const docx_1 = require("docx");
44
+ const logger_1 = require("../utils/logger");
45
+ // Color scheme
46
+ const NAVY = '1B2A4A';
47
+ const STEEL = '3D5A80';
48
+ const MEDIUM_GRAY = '666666';
49
+ /**
50
+ * Write rendered markdown content to a .docx file
51
+ * @param renderedContent - The rendered markdown content
52
+ * @param docType - Type of document (e.g., 'adr', 'runbook')
53
+ * @param projectPath - Root path of the project
54
+ * @param metadata - Document metadata
55
+ * @returns Promise resolving to the full path of the written file
56
+ */
57
+ async function writeDocx(renderedContent, docType, projectPath, metadata) {
58
+ // Create docs/generated directory
59
+ const docsDir = path.join(projectPath, 'docs', 'generated');
60
+ if (!fs.existsSync(docsDir)) {
61
+ fs.mkdirSync(docsDir, { recursive: true });
62
+ logger_1.logger.debug('Created docs/generated directory', { path: docsDir });
63
+ }
64
+ // Parse markdown and convert to docx elements
65
+ const sections = parseMarkdownContent(renderedContent, docType, metadata);
66
+ // Create document
67
+ const doc = new docx_1.Document({
68
+ sections: [
69
+ {
70
+ children: sections,
71
+ footers: {
72
+ default: new docx_1.Footer({
73
+ children: [
74
+ new docx_1.Paragraph({
75
+ alignment: docx_1.AlignmentType.CENTER,
76
+ children: [new docx_1.TextRun({ children: [docx_1.PageNumber.CURRENT] })],
77
+ }),
78
+ ],
79
+ }),
80
+ },
81
+ },
82
+ ],
83
+ });
84
+ // Write to file
85
+ const buffer = await docx_1.Packer.toBuffer(doc);
86
+ const outputPath = path.join(docsDir, `${docType}.docx`);
87
+ fs.writeFileSync(outputPath, buffer);
88
+ logger_1.logger.info('DOCX written', {
89
+ docType,
90
+ path: outputPath,
91
+ size: buffer.length,
92
+ });
93
+ return outputPath;
94
+ }
95
+ /**
96
+ * Parse markdown content and convert to docx Paragraph and Table objects
97
+ */
98
+ function parseMarkdownContent(content, docType, metadata) {
99
+ const sections = [];
100
+ const lines = content.split('\n');
101
+ let isFirstH1 = true;
102
+ // Add metadata header as paragraphs
103
+ sections.push(new docx_1.Paragraph({
104
+ text: `Generated by Vibe Doc v0.1.0`,
105
+ spacing: { line: 240, lineRule: 'auto' },
106
+ }));
107
+ sections.push(new docx_1.Paragraph({
108
+ text: `Date: ${metadata.generatedAt}`,
109
+ }));
110
+ sections.push(new docx_1.Paragraph({
111
+ text: `Classification: ${metadata.classification}`,
112
+ }));
113
+ sections.push(new docx_1.Paragraph({
114
+ text: `Source artifacts: ${metadata.sourceArtifacts} files scanned`,
115
+ }));
116
+ sections.push(new docx_1.Paragraph({
117
+ text: `Confidence: ${metadata.confidenceSummary.high} high, ${metadata.confidenceSummary.medium} medium, ${metadata.confidenceSummary.low} low sections`,
118
+ spacing: { after: 400 },
119
+ }));
120
+ // Parse markdown lines
121
+ let i = 0;
122
+ while (i < lines.length) {
123
+ const line = lines[i];
124
+ const trimmed = line.trim();
125
+ // Skip empty lines
126
+ if (!trimmed) {
127
+ i++;
128
+ continue;
129
+ }
130
+ // Heading 1
131
+ if (trimmed.startsWith('# ')) {
132
+ const text = trimmed.slice(2).trim();
133
+ const h1Paragraph = new docx_1.Paragraph({
134
+ children: [
135
+ new docx_1.TextRun({
136
+ text,
137
+ bold: true,
138
+ size: 32, // 16pt (in twips)
139
+ color: NAVY,
140
+ }),
141
+ ],
142
+ spacing: { before: isFirstH1 ? 240 : 0, after: 120 },
143
+ pageBreakBefore: !isFirstH1,
144
+ });
145
+ sections.push(h1Paragraph);
146
+ isFirstH1 = false;
147
+ i++;
148
+ continue;
149
+ }
150
+ // Heading 2
151
+ if (trimmed.startsWith('## ')) {
152
+ const text = trimmed.slice(3).trim();
153
+ sections.push(new docx_1.Paragraph({
154
+ children: [
155
+ new docx_1.TextRun({
156
+ text,
157
+ bold: true,
158
+ size: 28, // 14pt (in twips)
159
+ color: STEEL,
160
+ }),
161
+ ],
162
+ spacing: { before: 200, after: 100 },
163
+ }));
164
+ i++;
165
+ continue;
166
+ }
167
+ // Heading 3
168
+ if (trimmed.startsWith('### ')) {
169
+ const text = trimmed.slice(4).trim();
170
+ sections.push(new docx_1.Paragraph({
171
+ children: [
172
+ new docx_1.TextRun({
173
+ text,
174
+ bold: true,
175
+ size: 24, // 12pt (in twips)
176
+ color: MEDIUM_GRAY,
177
+ }),
178
+ ],
179
+ spacing: { before: 160, after: 80 },
180
+ }));
181
+ i++;
182
+ continue;
183
+ }
184
+ // Bullet list
185
+ if (trimmed.startsWith('- ')) {
186
+ const bulletItems = [];
187
+ while (i < lines.length && lines[i].trim().startsWith('- ')) {
188
+ bulletItems.push(lines[i].trim().slice(2).trim());
189
+ i++;
190
+ }
191
+ sections.push(...bulletItems.map((item) => new docx_1.Paragraph({
192
+ text: item,
193
+ bullet: {
194
+ level: 0,
195
+ },
196
+ spacing: { line: 240 },
197
+ })));
198
+ continue;
199
+ }
200
+ // Code block (triple backticks)
201
+ if (trimmed.startsWith('```')) {
202
+ i++; // Skip opening backticks
203
+ const codeLines = [];
204
+ while (i < lines.length && !lines[i].trim().startsWith('```')) {
205
+ codeLines.push(lines[i]);
206
+ i++;
207
+ }
208
+ i++; // Skip closing backticks
209
+ sections.push(new docx_1.Paragraph({
210
+ text: codeLines.join('\n'),
211
+ spacing: { before: 120, after: 120 },
212
+ border: {
213
+ top: { color: 'CCCCCC', space: 1, style: docx_1.BorderStyle.SINGLE, size: 6 },
214
+ bottom: { color: 'CCCCCC', space: 1, style: docx_1.BorderStyle.SINGLE, size: 6 },
215
+ left: { color: 'CCCCCC', space: 1, style: docx_1.BorderStyle.SINGLE, size: 6 },
216
+ right: { color: 'CCCCCC', space: 1, style: docx_1.BorderStyle.SINGLE, size: 6 },
217
+ },
218
+ }));
219
+ continue;
220
+ }
221
+ // Table (simple pipe-separated)
222
+ if (trimmed.startsWith('|')) {
223
+ const tableLines = [];
224
+ while (i < lines.length && lines[i].trim().startsWith('|')) {
225
+ tableLines.push(lines[i].trim());
226
+ i++;
227
+ }
228
+ if (tableLines.length > 0) {
229
+ const table = parseMarkdownTable(tableLines);
230
+ sections.push(table);
231
+ }
232
+ continue;
233
+ }
234
+ // Regular paragraph
235
+ if (trimmed) {
236
+ sections.push(new docx_1.Paragraph({
237
+ text: trimmed,
238
+ spacing: { line: 240, after: 80 },
239
+ }));
240
+ i++;
241
+ continue;
242
+ }
243
+ i++;
244
+ }
245
+ return sections;
246
+ }
247
+ /**
248
+ * Parse a markdown table and convert to docx Table
249
+ */
250
+ function parseMarkdownTable(tableLines) {
251
+ const rows = [];
252
+ for (const line of tableLines) {
253
+ const cells = line
254
+ .split('|')
255
+ .map((cell) => cell.trim())
256
+ .filter((cell) => cell.length > 0);
257
+ rows.push(new docx_1.TableRow({
258
+ children: cells.map((cellText) => new docx_1.TableCell({
259
+ children: [
260
+ new docx_1.Paragraph({
261
+ text: cellText,
262
+ }),
263
+ ],
264
+ })),
265
+ }));
266
+ }
267
+ return new docx_1.Table({
268
+ rows,
269
+ width: { size: 100, type: docx_1.WidthType.PERCENTAGE },
270
+ });
271
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Artifact Data Extractor
3
+ * Maps scan inventory data to template section tokens
4
+ * Extracts rich context from project artifacts to pre-populate templates
5
+ */
6
+ import { VibedocState } from '../state/schema';
7
+ /**
8
+ * Main extraction function - maps doc type to specific extractor
9
+ */
10
+ export declare function extractDataForDocType(docType: string, state: VibedocState, projectPath?: string): Record<string, string>;
11
+ //# sourceMappingURL=extractor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extractor.d.ts","sourceRoot":"","sources":["../../src/generator/extractor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAib/C;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,YAAY,EACnB,WAAW,GAAE,MAAsB,GAClC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA2CxB"}