notion-doc-sync 1.0.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.
- package/README.md +203 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +80 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/analyze.d.ts +6 -0
- package/dist/commands/analyze.js +58 -0
- package/dist/commands/analyze.js.map +1 -0
- package/dist/commands/fetch.d.ts +2 -0
- package/dist/commands/fetch.js +26 -0
- package/dist/commands/fetch.js.map +1 -0
- package/dist/commands/init.d.ts +2 -0
- package/dist/commands/init.js +21 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/stamp.d.ts +2 -0
- package/dist/commands/stamp.js +57 -0
- package/dist/commands/stamp.js.map +1 -0
- package/dist/commands/sync.d.ts +6 -0
- package/dist/commands/sync.js +125 -0
- package/dist/commands/sync.js.map +1 -0
- package/dist/lib/config.d.ts +32 -0
- package/dist/lib/config.js +85 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/doc-mapper.d.ts +111 -0
- package/dist/lib/doc-mapper.js +390 -0
- package/dist/lib/doc-mapper.js.map +1 -0
- package/dist/lib/git-analyzer.d.ts +14 -0
- package/dist/lib/git-analyzer.js +132 -0
- package/dist/lib/git-analyzer.js.map +1 -0
- package/dist/lib/local-docs-reader.d.ts +24 -0
- package/dist/lib/local-docs-reader.js +163 -0
- package/dist/lib/local-docs-reader.js.map +1 -0
- package/dist/lib/md-to-notion-converter.d.ts +5 -0
- package/dist/lib/md-to-notion-converter.js +14 -0
- package/dist/lib/md-to-notion-converter.js.map +1 -0
- package/dist/lib/notion-client.d.ts +29 -0
- package/dist/lib/notion-client.js +183 -0
- package/dist/lib/notion-client.js.map +1 -0
- package/dist/lib/notion-md-converter.d.ts +7 -0
- package/dist/lib/notion-md-converter.js +17 -0
- package/dist/lib/notion-md-converter.js.map +1 -0
- package/dist/lib/timestamp-utils.d.ts +7 -0
- package/dist/lib/timestamp-utils.js +47 -0
- package/dist/lib/timestamp-utils.js.map +1 -0
- package/dist/types/doc-sync.d.ts +103 -0
- package/dist/types/doc-sync.js +6 -0
- package/dist/types/doc-sync.js.map +1 -0
- package/package.json +62 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface AppConfig {
|
|
2
|
+
readonly nodeEnv: string;
|
|
3
|
+
readonly notion: {
|
|
4
|
+
readonly apiKey: string;
|
|
5
|
+
readonly databaseId: string;
|
|
6
|
+
};
|
|
7
|
+
readonly github: {
|
|
8
|
+
readonly token: string;
|
|
9
|
+
readonly owner: string;
|
|
10
|
+
readonly repo: string;
|
|
11
|
+
};
|
|
12
|
+
readonly analysis: {
|
|
13
|
+
readonly sourceDir: string;
|
|
14
|
+
readonly docsDir: string;
|
|
15
|
+
readonly excludePatterns: string[];
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
interface FileConfig {
|
|
19
|
+
readonly notionApiKey?: string;
|
|
20
|
+
readonly notionDatabaseId?: string;
|
|
21
|
+
readonly githubToken?: string;
|
|
22
|
+
readonly githubOwner?: string;
|
|
23
|
+
readonly githubRepo?: string;
|
|
24
|
+
readonly sourceDir?: string;
|
|
25
|
+
readonly docsDir?: string;
|
|
26
|
+
readonly excludePatterns?: string[];
|
|
27
|
+
}
|
|
28
|
+
export declare function resolveConfig(): AppConfig;
|
|
29
|
+
export declare function validateConfig(config: AppConfig, requiredFields: string[]): void;
|
|
30
|
+
export declare function getDefaultConfig(): FileConfig;
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveConfig = resolveConfig;
|
|
4
|
+
exports.validateConfig = validateConfig;
|
|
5
|
+
exports.getDefaultConfig = getDefaultConfig;
|
|
6
|
+
const fs_1 = require("fs");
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
const CONFIG_FILENAME = '.notion-doc-sync.json';
|
|
9
|
+
function loadConfigFile() {
|
|
10
|
+
const filePath = (0, path_1.join)(process.cwd(), CONFIG_FILENAME);
|
|
11
|
+
if (!(0, fs_1.existsSync)(filePath)) {
|
|
12
|
+
return {};
|
|
13
|
+
}
|
|
14
|
+
try {
|
|
15
|
+
const raw = (0, fs_1.readFileSync)(filePath, 'utf-8');
|
|
16
|
+
return JSON.parse(raw);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
throw new Error(`Failed to parse config file: ${filePath}`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function resolveConfig() {
|
|
23
|
+
const fileConfig = loadConfigFile();
|
|
24
|
+
return {
|
|
25
|
+
nodeEnv: process.env['NODE_ENV'] ?? 'development',
|
|
26
|
+
notion: {
|
|
27
|
+
apiKey: fileConfig.notionApiKey ?? '',
|
|
28
|
+
databaseId: fileConfig.notionDatabaseId ?? '',
|
|
29
|
+
},
|
|
30
|
+
github: {
|
|
31
|
+
token: fileConfig.githubToken ?? '',
|
|
32
|
+
owner: fileConfig.githubOwner ?? '',
|
|
33
|
+
repo: fileConfig.githubRepo ?? '',
|
|
34
|
+
},
|
|
35
|
+
analysis: {
|
|
36
|
+
sourceDir: fileConfig.sourceDir ?? './src',
|
|
37
|
+
docsDir: fileConfig.docsDir ?? './notionDocs',
|
|
38
|
+
excludePatterns: fileConfig.excludePatterns ?? [
|
|
39
|
+
'node_modules/**',
|
|
40
|
+
'dist/**',
|
|
41
|
+
'**/*.test.ts',
|
|
42
|
+
'**/*.spec.ts',
|
|
43
|
+
'**/__tests__/**',
|
|
44
|
+
'.git/**',
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function validateConfig(config, requiredFields) {
|
|
50
|
+
const errors = [];
|
|
51
|
+
for (const field of requiredFields) {
|
|
52
|
+
switch (field) {
|
|
53
|
+
case 'notionApiKey':
|
|
54
|
+
if (config.notion.apiKey === '') {
|
|
55
|
+
errors.push('Notion API key is required. Set in .notion-doc-sync.json. Run `notion-doc-sync init` to create one.');
|
|
56
|
+
}
|
|
57
|
+
break;
|
|
58
|
+
case 'notionDatabaseId':
|
|
59
|
+
if (config.notion.databaseId === '') {
|
|
60
|
+
errors.push('Notion database ID is required. Set in .notion-doc-sync.json. Run `notion-doc-sync init` to create one.');
|
|
61
|
+
}
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (errors.length > 0) {
|
|
66
|
+
throw new Error(`Configuration errors:\n - ${errors.join('\n - ')}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
function getDefaultConfig() {
|
|
70
|
+
return {
|
|
71
|
+
notionApiKey: '',
|
|
72
|
+
notionDatabaseId: '',
|
|
73
|
+
sourceDir: './src',
|
|
74
|
+
docsDir: './notionDocs',
|
|
75
|
+
excludePatterns: [
|
|
76
|
+
'node_modules/**',
|
|
77
|
+
'dist/**',
|
|
78
|
+
'**/*.test.ts',
|
|
79
|
+
'**/*.spec.ts',
|
|
80
|
+
'**/__tests__/**',
|
|
81
|
+
'.git/**',
|
|
82
|
+
],
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":";;AAiDA,sCA2BC;AAED,wCAyBC;AAED,4CAeC;AAxHD,2BAA8C;AAC9C,+BAA4B;AAE5B,MAAM,eAAe,GAAG,uBAAuB,CAAC;AA+BhD,SAAS,cAAc;IACrB,MAAM,QAAQ,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,eAAe,CAAC,CAAC;IAEtD,IAAI,CAAC,IAAA,eAAU,EAAC,QAAQ,CAAC,EAAE,CAAC;QAC1B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,CAAC;QACH,MAAM,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BACJ,CAAC;gBACD,MAAM;YACR,KAAK,kBAAkB;gBACrB,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,KAAK,EAAE,EAAE,CAAC;oBACpC,MAAM,CAAC,IAAI,CACT,yGAAyG,CAC1G,CAAC;gBACJ,CAAC;gBACD,MAAM;QACV,CAAC;IACH,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,8BAA8B,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACzE,CAAC;AACH,CAAC;AAED,SAAgB,gBAAgB;IAC9B,OAAO;QACL,YAAY,EAAE,EAAE;QAChB,gBAAgB,EAAE,EAAE;QACpB,SAAS,EAAE,OAAO;QAClB,OAAO,EAAE,cAAc;QACvB,eAAe,EAAE;YACf,iBAAiB;YACjB,SAAS;YACT,cAAc;YACd,cAAc;YACd,iBAAiB;YACjB,SAAS;SACV;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { DocumentationFile } from '../types/doc-sync';
|
|
2
|
+
/**
|
|
3
|
+
* Maps documentation files to relevant code files using content analysis and heuristics
|
|
4
|
+
*/
|
|
5
|
+
export declare class DocMapper {
|
|
6
|
+
private readonly mappingCache;
|
|
7
|
+
/**
|
|
8
|
+
* Scans documentation content for explicit file path references
|
|
9
|
+
* @param content - The documentation content to scan
|
|
10
|
+
* @returns Array of file paths referenced in the documentation
|
|
11
|
+
*/
|
|
12
|
+
extractFilePathReferences(content: string): string[];
|
|
13
|
+
/**
|
|
14
|
+
* Helper method to validate if a string looks like a valid file path
|
|
15
|
+
* @param path - The potential file path to validate
|
|
16
|
+
* @returns true if the path looks like a valid file path
|
|
17
|
+
*/
|
|
18
|
+
private isValidFilePath;
|
|
19
|
+
/**
|
|
20
|
+
* Extracts function name references from documentation content
|
|
21
|
+
* @param content - The documentation content to scan
|
|
22
|
+
* @returns Array of function names referenced in the documentation
|
|
23
|
+
*/
|
|
24
|
+
extractFunctionNameReferences(content: string): string[];
|
|
25
|
+
/**
|
|
26
|
+
* Creates a mapping table of documentation files to relevant code files
|
|
27
|
+
* @param documentationFiles - Array of documentation files to analyze
|
|
28
|
+
* @param availableCodeFiles - Array of available code file paths
|
|
29
|
+
* @returns Map of doc file paths to arrays of linked code file paths
|
|
30
|
+
*/
|
|
31
|
+
buildMappingTable(documentationFiles: DocumentationFile[], availableCodeFiles: string[]): Map<string, string[]>;
|
|
32
|
+
/**
|
|
33
|
+
* Matches documentation filenames to code file patterns using heuristics
|
|
34
|
+
* @param docFilePath - Path to the documentation file
|
|
35
|
+
* @param availableCodeFiles - Array of available code file paths
|
|
36
|
+
* @returns Array of potentially matching code files
|
|
37
|
+
*/
|
|
38
|
+
matchFilenamePatterns(docFilePath: string, availableCodeFiles: string[]): string[];
|
|
39
|
+
/**
|
|
40
|
+
* Helper method to extract base name from a file path (without extension and directory)
|
|
41
|
+
* @param filePath - The file path to process
|
|
42
|
+
* @returns The base name or null if extraction fails
|
|
43
|
+
*/
|
|
44
|
+
private extractBaseName;
|
|
45
|
+
/**
|
|
46
|
+
* Helper method to generate search terms from a base name
|
|
47
|
+
* @param baseName - The base name to generate terms from
|
|
48
|
+
* @returns Array of search terms
|
|
49
|
+
*/
|
|
50
|
+
private generateSearchTerms;
|
|
51
|
+
/**
|
|
52
|
+
* Implements directory structure-based mapping
|
|
53
|
+
* @param docFilePath - Path to the documentation file
|
|
54
|
+
* @param availableCodeFiles - Array of available code file paths
|
|
55
|
+
* @returns Array of code files in related directories
|
|
56
|
+
*/
|
|
57
|
+
matchDirectoryStructure(docFilePath: string, availableCodeFiles: string[]): string[];
|
|
58
|
+
/**
|
|
59
|
+
* Helper method to extract meaningful path parts from a file path
|
|
60
|
+
* @param filePath - The file path to process
|
|
61
|
+
* @returns Array of path parts (excluding root 'src', 'docs', 'lib', etc.)
|
|
62
|
+
*/
|
|
63
|
+
private extractPathParts;
|
|
64
|
+
/**
|
|
65
|
+
* Helper method to check if two path structures match
|
|
66
|
+
* @param docParts - Path parts from documentation file
|
|
67
|
+
* @param codeParts - Path parts from code file
|
|
68
|
+
* @returns true if they share meaningful directory structure
|
|
69
|
+
*/
|
|
70
|
+
private hasMatchingDirectoryStructure;
|
|
71
|
+
/**
|
|
72
|
+
* Calculates confidence score for mapping relationships
|
|
73
|
+
* @param docFile - Documentation file to analyze
|
|
74
|
+
* @param codeFile - Code file to check mapping confidence for
|
|
75
|
+
* @returns Confidence score between 0 and 1
|
|
76
|
+
*/
|
|
77
|
+
calculateMappingConfidence(docFile: DocumentationFile, codeFile: string): number;
|
|
78
|
+
/**
|
|
79
|
+
* Helper method to check if two words are similar (share common parts)
|
|
80
|
+
* @param word1 - First word to compare
|
|
81
|
+
* @param word2 - Second word to compare
|
|
82
|
+
* @returns true if words share significant common parts
|
|
83
|
+
*/
|
|
84
|
+
private similarWords;
|
|
85
|
+
/**
|
|
86
|
+
* Enhances DocumentationFile objects with linked code files
|
|
87
|
+
* @param documentationFiles - Array of documentation files to enhance
|
|
88
|
+
* @param availableCodeFiles - Array of available code file paths
|
|
89
|
+
* @returns Array of enhanced DocumentationFile objects with linkedCodeFiles populated
|
|
90
|
+
*/
|
|
91
|
+
enhanceDocumentationFiles(documentationFiles: DocumentationFile[], availableCodeFiles: string[]): DocumentationFile[];
|
|
92
|
+
/**
|
|
93
|
+
* Caches mapping results for performance optimization
|
|
94
|
+
* @param mappingTable - The mapping table to cache
|
|
95
|
+
* @returns void
|
|
96
|
+
*/
|
|
97
|
+
cacheMappingResults(mappingTable: Map<string, string[]>): void;
|
|
98
|
+
/**
|
|
99
|
+
* Retrieves cached mapping results
|
|
100
|
+
* @param docFilePath - Path to the documentation file
|
|
101
|
+
* @returns Cached mapping results or null if not found
|
|
102
|
+
*/
|
|
103
|
+
getCachedMappingResults(docFilePath: string): string[] | null;
|
|
104
|
+
/**
|
|
105
|
+
* Invalidates cached mapping results
|
|
106
|
+
* @param docFilePath - Path to the documentation file to invalidate, or undefined to clear all
|
|
107
|
+
* @returns void
|
|
108
|
+
*/
|
|
109
|
+
invalidateMappingCache(docFilePath?: string): void;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=doc-mapper.d.ts.map
|
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DocMapper = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Maps documentation files to relevant code files using content analysis and heuristics
|
|
6
|
+
*/
|
|
7
|
+
class DocMapper {
|
|
8
|
+
mappingCache = new Map();
|
|
9
|
+
/**
|
|
10
|
+
* Scans documentation content for explicit file path references
|
|
11
|
+
* @param content - The documentation content to scan
|
|
12
|
+
* @returns Array of file paths referenced in the documentation
|
|
13
|
+
*/
|
|
14
|
+
extractFilePathReferences(content) {
|
|
15
|
+
const filePaths = new Set();
|
|
16
|
+
// Pattern 1: File paths wrapped in backticks: `src/index.ts`
|
|
17
|
+
const backtickPattern = /`([^`]+\.[a-zA-Z]+)`/g;
|
|
18
|
+
let match;
|
|
19
|
+
while ((match = backtickPattern.exec(content)) !== null) {
|
|
20
|
+
const path = match[1];
|
|
21
|
+
if (this.isValidFilePath(path)) {
|
|
22
|
+
filePaths.add(path);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
// Pattern 2: File paths in comments: // File: src/main.ts
|
|
26
|
+
const commentPattern = /\/\/\s*File:\s*([^\s\n]+)/g;
|
|
27
|
+
while ((match = commentPattern.exec(content)) !== null) {
|
|
28
|
+
const path = match[1];
|
|
29
|
+
if (this.isValidFilePath(path)) {
|
|
30
|
+
filePaths.add(path);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// Pattern 3: File paths in import/require statements
|
|
34
|
+
const importFromPattern = /from\s+['"`]([^'"`]+\.[a-zA-Z]+)['"`]/g;
|
|
35
|
+
while ((match = importFromPattern.exec(content)) !== null) {
|
|
36
|
+
const path = match[1];
|
|
37
|
+
if (this.isValidFilePath(path)) {
|
|
38
|
+
filePaths.add(path);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const requirePattern = /require\s*\(\s*['"`]([^'"`]+\.[a-zA-Z]+)['"`]\s*\)/g;
|
|
42
|
+
while ((match = requirePattern.exec(content)) !== null) {
|
|
43
|
+
const path = match[1];
|
|
44
|
+
if (this.isValidFilePath(path)) {
|
|
45
|
+
filePaths.add(path);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// Pattern 4: File paths in markdown links: [text](./file.ext)
|
|
49
|
+
const markdownLinkPattern = /\[([^\]]*)\]\(([^)]+\.[a-zA-Z]+)\)/g;
|
|
50
|
+
while ((match = markdownLinkPattern.exec(content)) !== null) {
|
|
51
|
+
const path = match[2];
|
|
52
|
+
if (this.isValidFilePath(path)) {
|
|
53
|
+
filePaths.add(path);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return Array.from(filePaths);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Helper method to validate if a string looks like a valid file path
|
|
60
|
+
* @param path - The potential file path to validate
|
|
61
|
+
* @returns true if the path looks like a valid file path
|
|
62
|
+
*/
|
|
63
|
+
isValidFilePath(path) {
|
|
64
|
+
// Must have a file extension
|
|
65
|
+
if (!/\.[a-zA-Z]+$/.test(path)) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
// Handle relative paths starting with ./
|
|
69
|
+
if (path.startsWith('./')) {
|
|
70
|
+
return path.length > 2 && /^\.\/[a-zA-Z0-9._/-]+$/.test(path);
|
|
71
|
+
}
|
|
72
|
+
// Should not be just a file extension like ".js"
|
|
73
|
+
if (path.startsWith('.') && !path.includes('/')) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
// Should contain path-like characters
|
|
77
|
+
return /^[a-zA-Z0-9._/-]+$/.test(path);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Extracts function name references from documentation content
|
|
81
|
+
* @param content - The documentation content to scan
|
|
82
|
+
* @returns Array of function names referenced in the documentation
|
|
83
|
+
*/
|
|
84
|
+
extractFunctionNameReferences(content) {
|
|
85
|
+
const functionNames = new Set();
|
|
86
|
+
// Pattern 1: Function calls in backticks: `functionName()`
|
|
87
|
+
const backtickFunctionPattern = /`([a-zA-Z_$][a-zA-Z0-9_$]*)\(\)`/g;
|
|
88
|
+
let match;
|
|
89
|
+
while ((match = backtickFunctionPattern.exec(content)) !== null) {
|
|
90
|
+
functionNames.add(match[1]);
|
|
91
|
+
}
|
|
92
|
+
// Pattern 2: Function declarations in code blocks: function myFunction()
|
|
93
|
+
const functionDeclarationPattern = /function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/g;
|
|
94
|
+
while ((match = functionDeclarationPattern.exec(content)) !== null) {
|
|
95
|
+
functionNames.add(match[1]);
|
|
96
|
+
}
|
|
97
|
+
// Pattern 3: Method calls in code: object.methodName()
|
|
98
|
+
const methodCallPattern = /\.([a-zA-Z_$][a-zA-Z0-9_$]*)\(\)/g;
|
|
99
|
+
while ((match = methodCallPattern.exec(content)) !== null) {
|
|
100
|
+
functionNames.add(match[1]);
|
|
101
|
+
}
|
|
102
|
+
return Array.from(functionNames);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Creates a mapping table of documentation files to relevant code files
|
|
106
|
+
* @param documentationFiles - Array of documentation files to analyze
|
|
107
|
+
* @param availableCodeFiles - Array of available code file paths
|
|
108
|
+
* @returns Map of doc file paths to arrays of linked code file paths
|
|
109
|
+
*/
|
|
110
|
+
buildMappingTable(documentationFiles, availableCodeFiles) {
|
|
111
|
+
const mappingTable = new Map();
|
|
112
|
+
for (const docFile of documentationFiles) {
|
|
113
|
+
const linkedFiles = new Set();
|
|
114
|
+
// Extract file path references from the documentation content
|
|
115
|
+
const referencedPaths = this.extractFilePathReferences(docFile.content);
|
|
116
|
+
// Add any referenced paths that exist in available code files
|
|
117
|
+
for (const refPath of referencedPaths) {
|
|
118
|
+
if (availableCodeFiles.includes(refPath)) {
|
|
119
|
+
linkedFiles.add(refPath);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
// Store the mapping
|
|
123
|
+
mappingTable.set(docFile.filePath, Array.from(linkedFiles));
|
|
124
|
+
}
|
|
125
|
+
return mappingTable;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Matches documentation filenames to code file patterns using heuristics
|
|
129
|
+
* @param docFilePath - Path to the documentation file
|
|
130
|
+
* @param availableCodeFiles - Array of available code file paths
|
|
131
|
+
* @returns Array of potentially matching code files
|
|
132
|
+
*/
|
|
133
|
+
matchFilenamePatterns(docFilePath, availableCodeFiles) {
|
|
134
|
+
const matches = [];
|
|
135
|
+
// Extract the base name from the doc file (e.g., 'doc-mapper' from 'docs/doc-mapper.md')
|
|
136
|
+
const docBaseName = this.extractBaseName(docFilePath);
|
|
137
|
+
if (docBaseName === null) {
|
|
138
|
+
return matches;
|
|
139
|
+
}
|
|
140
|
+
// Create variations of the doc name to search for
|
|
141
|
+
const searchTerms = this.generateSearchTerms(docBaseName);
|
|
142
|
+
for (const codeFile of availableCodeFiles) {
|
|
143
|
+
const codeBaseName = this.extractBaseName(codeFile);
|
|
144
|
+
if (codeBaseName === null) {
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
// Check if any search term matches the code file base name (case-insensitive)
|
|
148
|
+
const codeBaseNameLower = codeBaseName.toLowerCase();
|
|
149
|
+
for (const term of searchTerms) {
|
|
150
|
+
const termLower = term.toLowerCase();
|
|
151
|
+
if (codeBaseNameLower.includes(termLower) || termLower.includes(codeBaseNameLower)) {
|
|
152
|
+
matches.push(codeFile);
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return matches;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Helper method to extract base name from a file path (without extension and directory)
|
|
161
|
+
* @param filePath - The file path to process
|
|
162
|
+
* @returns The base name or null if extraction fails
|
|
163
|
+
*/
|
|
164
|
+
extractBaseName(filePath) {
|
|
165
|
+
const parts = filePath.split('/');
|
|
166
|
+
const fileName = parts[parts.length - 1] ?? '';
|
|
167
|
+
const nameWithoutExt = fileName.split('.')[0];
|
|
168
|
+
return nameWithoutExt !== undefined && nameWithoutExt !== '' ? nameWithoutExt : null;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Helper method to generate search terms from a base name
|
|
172
|
+
* @param baseName - The base name to generate terms from
|
|
173
|
+
* @returns Array of search terms
|
|
174
|
+
*/
|
|
175
|
+
generateSearchTerms(baseName) {
|
|
176
|
+
const terms = new Set();
|
|
177
|
+
// Add the original name
|
|
178
|
+
terms.add(baseName);
|
|
179
|
+
// Handle hyphenated names (e.g., 'doc-mapper' -> ['doc', 'mapper'])
|
|
180
|
+
const hyphenParts = baseName.split('-');
|
|
181
|
+
if (hyphenParts.length > 1) {
|
|
182
|
+
hyphenParts.forEach((part) => terms.add(part));
|
|
183
|
+
}
|
|
184
|
+
// Handle camelCase/PascalCase names
|
|
185
|
+
const camelParts = baseName.split(/(?=[A-Z])/);
|
|
186
|
+
if (camelParts.length > 1) {
|
|
187
|
+
camelParts.forEach((part) => terms.add(part.toLowerCase()));
|
|
188
|
+
}
|
|
189
|
+
return Array.from(terms);
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Implements directory structure-based mapping
|
|
193
|
+
* @param docFilePath - Path to the documentation file
|
|
194
|
+
* @param availableCodeFiles - Array of available code file paths
|
|
195
|
+
* @returns Array of code files in related directories
|
|
196
|
+
*/
|
|
197
|
+
matchDirectoryStructure(docFilePath, availableCodeFiles) {
|
|
198
|
+
const matches = [];
|
|
199
|
+
// Extract directory path from doc file (e.g., 'docs/components/button.md' -> ['components', 'button'])
|
|
200
|
+
const docPathParts = this.extractPathParts(docFilePath);
|
|
201
|
+
for (const codeFile of availableCodeFiles) {
|
|
202
|
+
const codePathParts = this.extractPathParts(codeFile);
|
|
203
|
+
// Check if the code file shares directory structure with the doc file
|
|
204
|
+
if (this.hasMatchingDirectoryStructure(docPathParts, codePathParts)) {
|
|
205
|
+
matches.push(codeFile);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return matches;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Helper method to extract meaningful path parts from a file path
|
|
212
|
+
* @param filePath - The file path to process
|
|
213
|
+
* @returns Array of path parts (excluding root 'src', 'docs', 'lib', etc.)
|
|
214
|
+
*/
|
|
215
|
+
extractPathParts(filePath) {
|
|
216
|
+
const parts = filePath.split('/');
|
|
217
|
+
const filtered = [];
|
|
218
|
+
for (const part of parts) {
|
|
219
|
+
// Skip common root directories and the file name with extension
|
|
220
|
+
if (part !== 'src' &&
|
|
221
|
+
part !== 'docs' &&
|
|
222
|
+
part !== 'lib' &&
|
|
223
|
+
part !== 'tests' &&
|
|
224
|
+
part !== 'test' &&
|
|
225
|
+
!part.includes('.')) {
|
|
226
|
+
filtered.push(part);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return filtered;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Helper method to check if two path structures match
|
|
233
|
+
* @param docParts - Path parts from documentation file
|
|
234
|
+
* @param codeParts - Path parts from code file
|
|
235
|
+
* @returns true if they share meaningful directory structure
|
|
236
|
+
*/
|
|
237
|
+
hasMatchingDirectoryStructure(docParts, codeParts) {
|
|
238
|
+
if (docParts.length === 0 || codeParts.length === 0) {
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
// Check if any doc path parts match code path parts
|
|
242
|
+
for (const docPart of docParts) {
|
|
243
|
+
if (codeParts.includes(docPart)) {
|
|
244
|
+
return true;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return false;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Calculates confidence score for mapping relationships
|
|
251
|
+
* @param docFile - Documentation file to analyze
|
|
252
|
+
* @param codeFile - Code file to check mapping confidence for
|
|
253
|
+
* @returns Confidence score between 0 and 1
|
|
254
|
+
*/
|
|
255
|
+
calculateMappingConfidence(docFile, codeFile) {
|
|
256
|
+
let confidence = 0;
|
|
257
|
+
// High confidence: Explicit file path references (0.9)
|
|
258
|
+
const referencedPaths = this.extractFilePathReferences(docFile.content);
|
|
259
|
+
if (referencedPaths.includes(codeFile)) {
|
|
260
|
+
confidence = Math.max(confidence, 0.9);
|
|
261
|
+
}
|
|
262
|
+
// Medium-high confidence: File path in linkedCodeFiles (0.85)
|
|
263
|
+
if (docFile.linkedCodeFiles.includes(codeFile)) {
|
|
264
|
+
confidence = Math.max(confidence, 0.85);
|
|
265
|
+
}
|
|
266
|
+
// Medium confidence: Function name matches with code file name (0.5-0.6)
|
|
267
|
+
const functionNames = this.extractFunctionNameReferences(docFile.content);
|
|
268
|
+
const codeBaseName = this.extractBaseName(codeFile);
|
|
269
|
+
if (codeBaseName !== null) {
|
|
270
|
+
for (const funcName of functionNames) {
|
|
271
|
+
const funcLower = funcName.toLowerCase();
|
|
272
|
+
const codeLower = codeBaseName.toLowerCase();
|
|
273
|
+
if (funcLower.includes(codeLower) ||
|
|
274
|
+
codeLower.includes(funcLower) ||
|
|
275
|
+
this.similarWords(funcLower, codeLower)) {
|
|
276
|
+
confidence = Math.max(confidence, 0.5);
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
// Low-medium confidence: Filename pattern matches (0.3)
|
|
282
|
+
const filenameMatches = this.matchFilenamePatterns(docFile.filePath, [codeFile]);
|
|
283
|
+
if (filenameMatches.length > 0) {
|
|
284
|
+
confidence = Math.max(confidence, 0.3);
|
|
285
|
+
}
|
|
286
|
+
// Low confidence: Directory structure matches (0.15)
|
|
287
|
+
const directoryMatches = this.matchDirectoryStructure(docFile.filePath, [codeFile]);
|
|
288
|
+
if (directoryMatches.length > 0) {
|
|
289
|
+
confidence = Math.max(confidence, 0.15);
|
|
290
|
+
}
|
|
291
|
+
return confidence;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Helper method to check if two words are similar (share common parts)
|
|
295
|
+
* @param word1 - First word to compare
|
|
296
|
+
* @param word2 - Second word to compare
|
|
297
|
+
* @returns true if words share significant common parts
|
|
298
|
+
*/
|
|
299
|
+
similarWords(word1, word2) {
|
|
300
|
+
// Check if they share common substrings of length 4 or more
|
|
301
|
+
const minLength = 4;
|
|
302
|
+
for (let i = 0; i <= word1.length - minLength; i++) {
|
|
303
|
+
const substring = word1.substring(i, i + minLength);
|
|
304
|
+
if (word2.includes(substring)) {
|
|
305
|
+
return true;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
return false;
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Enhances DocumentationFile objects with linked code files
|
|
312
|
+
* @param documentationFiles - Array of documentation files to enhance
|
|
313
|
+
* @param availableCodeFiles - Array of available code file paths
|
|
314
|
+
* @returns Array of enhanced DocumentationFile objects with linkedCodeFiles populated
|
|
315
|
+
*/
|
|
316
|
+
enhanceDocumentationFiles(documentationFiles, availableCodeFiles) {
|
|
317
|
+
return documentationFiles.map((docFile) => {
|
|
318
|
+
const linkedFiles = new Set();
|
|
319
|
+
// 1. Extract explicit file path references from content
|
|
320
|
+
const referencedPaths = this.extractFilePathReferences(docFile.content);
|
|
321
|
+
for (const refPath of referencedPaths) {
|
|
322
|
+
if (availableCodeFiles.includes(refPath)) {
|
|
323
|
+
linkedFiles.add(refPath);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
// 2. Add files from filename pattern matching
|
|
327
|
+
const filenameMatches = this.matchFilenamePatterns(docFile.filePath, availableCodeFiles);
|
|
328
|
+
for (const match of filenameMatches) {
|
|
329
|
+
linkedFiles.add(match);
|
|
330
|
+
}
|
|
331
|
+
// 3. Add files from directory structure matching
|
|
332
|
+
const directoryMatches = this.matchDirectoryStructure(docFile.filePath, availableCodeFiles);
|
|
333
|
+
for (const match of directoryMatches) {
|
|
334
|
+
linkedFiles.add(match);
|
|
335
|
+
}
|
|
336
|
+
// Convert Set to Array
|
|
337
|
+
const linkedCodeFiles = Array.from(linkedFiles);
|
|
338
|
+
// Calculate overall confidence score
|
|
339
|
+
// Use the highest confidence among all linked files
|
|
340
|
+
let maxConfidence = 0;
|
|
341
|
+
for (const codeFile of linkedCodeFiles) {
|
|
342
|
+
const confidence = this.calculateMappingConfidence({ ...docFile, linkedCodeFiles }, codeFile);
|
|
343
|
+
maxConfidence = Math.max(maxConfidence, confidence);
|
|
344
|
+
}
|
|
345
|
+
// Return enhanced documentation file
|
|
346
|
+
return {
|
|
347
|
+
...docFile,
|
|
348
|
+
linkedCodeFiles,
|
|
349
|
+
mappingConfidence: maxConfidence,
|
|
350
|
+
};
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Caches mapping results for performance optimization
|
|
355
|
+
* @param mappingTable - The mapping table to cache
|
|
356
|
+
* @returns void
|
|
357
|
+
*/
|
|
358
|
+
cacheMappingResults(mappingTable) {
|
|
359
|
+
// Store all entries from the mapping table into the cache
|
|
360
|
+
for (const [docFilePath, codeFiles] of mappingTable.entries()) {
|
|
361
|
+
this.mappingCache.set(docFilePath, [...codeFiles]);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Retrieves cached mapping results
|
|
366
|
+
* @param docFilePath - Path to the documentation file
|
|
367
|
+
* @returns Cached mapping results or null if not found
|
|
368
|
+
*/
|
|
369
|
+
getCachedMappingResults(docFilePath) {
|
|
370
|
+
const cached = this.mappingCache.get(docFilePath);
|
|
371
|
+
return cached ? [...cached] : null;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Invalidates cached mapping results
|
|
375
|
+
* @param docFilePath - Path to the documentation file to invalidate, or undefined to clear all
|
|
376
|
+
* @returns void
|
|
377
|
+
*/
|
|
378
|
+
invalidateMappingCache(docFilePath) {
|
|
379
|
+
if (docFilePath === undefined) {
|
|
380
|
+
// Clear all cache entries
|
|
381
|
+
this.mappingCache.clear();
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
// Remove specific cache entry
|
|
385
|
+
this.mappingCache.delete(docFilePath);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
exports.DocMapper = DocMapper;
|
|
390
|
+
//# sourceMappingURL=doc-mapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doc-mapper.js","sourceRoot":"","sources":["../../src/lib/doc-mapper.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,MAAa,SAAS;IACH,YAAY,GAA0B,IAAI,GAAG,EAAE,CAAC;IAEjE;;;;OAIG;IACH,yBAAyB,CAAC,OAAe;QACvC,MAAM,SAAS,GAAG,IAAI,GAAG,EAAU,CAAC;QAEpC,6DAA6D;QAC7D,MAAM,eAAe,GAAG,uBAAuB,CAAC;QAChD,IAAI,KAAK,CAAC;QACV,OAAO,CAAC,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;YACxD,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACtB,IAAI,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC/B,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACtB,CAAC;QACH,CAAC;QAED,0DAA0D;QAC1D,MAAM,cAAc,GAAG,4BAA4B,CAAC;QACpD,OAAO,CAAC,KAAK,GAAG,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;YACvD,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACtB,IAAI,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC/B,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAA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
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CodeChange } from '../types/doc-sync';
|
|
2
|
+
export declare class GitAnalyzer {
|
|
3
|
+
getCodeChanges(baseBranch: string, targetBranch: string): CodeChange[];
|
|
4
|
+
isSourceCodeFile(filePath: string): boolean;
|
|
5
|
+
parseGitStatusLine(statusLine: string): {
|
|
6
|
+
changeType: 'added' | 'modified' | 'deleted';
|
|
7
|
+
filePath: string;
|
|
8
|
+
};
|
|
9
|
+
countDiffLines(diff: string): {
|
|
10
|
+
linesAdded: number;
|
|
11
|
+
linesRemoved: number;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=git-analyzer.d.ts.map
|