dev-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.
- package/README.md +152 -0
- package/dist/analyzer.d.ts +59 -0
- package/dist/analyzer.d.ts.map +1 -0
- package/dist/analyzer.js +285 -0
- package/dist/analyzer.js.map +1 -0
- package/dist/cache.d.ts +51 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +143 -0
- package/dist/cache.js.map +1 -0
- package/dist/chunker.d.ts +18 -0
- package/dist/chunker.d.ts.map +1 -0
- package/dist/chunker.js +56 -0
- package/dist/chunker.js.map +1 -0
- package/dist/claude.d.ts +39 -0
- package/dist/claude.d.ts.map +1 -0
- package/dist/claude.js +179 -0
- package/dist/claude.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +149 -0
- package/dist/cli.js.map +1 -0
- package/dist/mongodb.d.ts +78 -0
- package/dist/mongodb.d.ts.map +1 -0
- package/dist/mongodb.js +197 -0
- package/dist/mongodb.js.map +1 -0
- package/dist/scanner.d.ts +12 -0
- package/dist/scanner.d.ts.map +1 -0
- package/dist/scanner.js +60 -0
- package/dist/scanner.js.map +1 -0
- package/package.json +49 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { ProjectAnalysis } from "./analyzer";
|
|
2
|
+
export interface MongoDBConfig {
|
|
3
|
+
connectionString?: string;
|
|
4
|
+
database?: string;
|
|
5
|
+
host?: string;
|
|
6
|
+
port?: number;
|
|
7
|
+
username?: string;
|
|
8
|
+
password?: string;
|
|
9
|
+
authSource?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface DocumentationRecord {
|
|
12
|
+
projectPath: string;
|
|
13
|
+
version: string;
|
|
14
|
+
generatedAt: Date;
|
|
15
|
+
summary: string;
|
|
16
|
+
framework?: string;
|
|
17
|
+
stats: {
|
|
18
|
+
totalFiles: number;
|
|
19
|
+
totalChunks: number;
|
|
20
|
+
cachedFiles: number;
|
|
21
|
+
analyzedFiles: number;
|
|
22
|
+
};
|
|
23
|
+
fileAnalyses: Array<{
|
|
24
|
+
path: string;
|
|
25
|
+
relativePath: string;
|
|
26
|
+
analysis: string;
|
|
27
|
+
chunks: number;
|
|
28
|
+
fromCache?: boolean;
|
|
29
|
+
}>;
|
|
30
|
+
metadata: {
|
|
31
|
+
model?: string;
|
|
32
|
+
cacheEnabled?: boolean;
|
|
33
|
+
analysisOptions?: any;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export declare class MongoDBStorage {
|
|
37
|
+
private client;
|
|
38
|
+
private db;
|
|
39
|
+
private config;
|
|
40
|
+
constructor(config: MongoDBConfig);
|
|
41
|
+
/**
|
|
42
|
+
* Builds MongoDB connection string from config
|
|
43
|
+
*/
|
|
44
|
+
private buildConnectionString;
|
|
45
|
+
/**
|
|
46
|
+
* Connects to MongoDB
|
|
47
|
+
*/
|
|
48
|
+
connect(): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Creates necessary indexes for efficient queries
|
|
51
|
+
*/
|
|
52
|
+
private createIndexes;
|
|
53
|
+
/**
|
|
54
|
+
* Saves documentation to MongoDB
|
|
55
|
+
*/
|
|
56
|
+
saveDocumentation(projectPath: string, analysis: ProjectAnalysis, version?: string): Promise<string>;
|
|
57
|
+
/**
|
|
58
|
+
* Retrieves latest documentation for a project
|
|
59
|
+
*/
|
|
60
|
+
getLatestDocumentation(projectPath: string): Promise<DocumentationRecord | null>;
|
|
61
|
+
/**
|
|
62
|
+
* Retrieves documentation by project path and version
|
|
63
|
+
*/
|
|
64
|
+
getDocumentation(projectPath: string, version: string): Promise<DocumentationRecord | null>;
|
|
65
|
+
/**
|
|
66
|
+
* Lists all documentations for a project
|
|
67
|
+
*/
|
|
68
|
+
listDocumentations(projectPath?: string): Promise<DocumentationRecord[]>;
|
|
69
|
+
/**
|
|
70
|
+
* Searches documentation by text
|
|
71
|
+
*/
|
|
72
|
+
searchDocumentations(searchText: string, projectPath?: string): Promise<DocumentationRecord[]>;
|
|
73
|
+
/**
|
|
74
|
+
* Closes MongoDB connection
|
|
75
|
+
*/
|
|
76
|
+
disconnect(): Promise<void>;
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=mongodb.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongodb.d.ts","sourceRoot":"","sources":["../src/mongodb.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,WAAW,aAAa;IAC5B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,IAAI,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE;QACL,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,MAAM,CAAC;QACpB,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,YAAY,EAAE,KAAK,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;QACb,YAAY,EAAE,MAAM,CAAC;QACrB,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,OAAO,CAAC;KACrB,CAAC,CAAC;IACH,QAAQ,EAAE;QACR,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,eAAe,CAAC,EAAE,GAAG,CAAC;KACvB,CAAC;CACH;AAED,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,EAAE,CAAmB;IAC7B,OAAO,CAAC,MAAM,CAAgB;gBAElB,MAAM,EAAE,aAAa;IAIjC;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAoB7B;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IA2C9B;;OAEG;YACW,aAAa;IAwB3B;;OAEG;IACG,iBAAiB,CACrB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,eAAe,EACzB,OAAO,GAAE,MAAgB,GACxB,OAAO,CAAC,MAAM,CAAC;IA2ClB;;OAEG;IACG,sBAAsB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;IAgBtF;;OAEG;IACG,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC;IAWjG;;OAEG;IACG,kBAAkB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC;IAgB9E;;OAEG;IACG,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC;IAuBpG;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CAQlC"}
|
package/dist/mongodb.js
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MongoDBStorage = void 0;
|
|
4
|
+
const mongodb_1 = require("mongodb");
|
|
5
|
+
class MongoDBStorage {
|
|
6
|
+
constructor(config) {
|
|
7
|
+
this.client = null;
|
|
8
|
+
this.db = null;
|
|
9
|
+
this.config = config;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Builds MongoDB connection string from config
|
|
13
|
+
*/
|
|
14
|
+
buildConnectionString() {
|
|
15
|
+
// If connection string is provided, use it directly
|
|
16
|
+
if (this.config.connectionString) {
|
|
17
|
+
return this.config.connectionString;
|
|
18
|
+
}
|
|
19
|
+
// Otherwise build from components
|
|
20
|
+
const { host, port, username, password, database, authSource } = this.config;
|
|
21
|
+
if (!host || !database) {
|
|
22
|
+
throw new Error("MongoDB connection requires either connectionString or (host + database)");
|
|
23
|
+
}
|
|
24
|
+
const portPart = port ? `:${port}` : "";
|
|
25
|
+
const authPart = username && password ? `${username}:${password}@` : "";
|
|
26
|
+
const authSourcePart = authSource ? `?authSource=${authSource}` : "";
|
|
27
|
+
return `mongodb://${authPart}${host}${portPart}/${database}${authSourcePart}`;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Connects to MongoDB
|
|
31
|
+
*/
|
|
32
|
+
async connect() {
|
|
33
|
+
if (this.client) {
|
|
34
|
+
return; // Already connected
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
const connectionString = this.buildConnectionString();
|
|
38
|
+
// Extract database name from connection string if present
|
|
39
|
+
let databaseName = this.config.database;
|
|
40
|
+
if (!databaseName && this.config.connectionString) {
|
|
41
|
+
// For mongodb+srv:// format, database comes after the cluster path
|
|
42
|
+
const uri = new URL(connectionString);
|
|
43
|
+
const pathParts = uri.pathname.split('/').filter(p => p);
|
|
44
|
+
if (pathParts.length > 0 && pathParts[0]) {
|
|
45
|
+
databaseName = pathParts[0];
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
// Check query params for database
|
|
49
|
+
const dbParam = uri.searchParams.get('database') || uri.searchParams.get('db');
|
|
50
|
+
if (dbParam) {
|
|
51
|
+
databaseName = dbParam;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// Default database name if still not set
|
|
56
|
+
if (!databaseName) {
|
|
57
|
+
databaseName = "devdoc";
|
|
58
|
+
}
|
|
59
|
+
// Silent connection - no logging
|
|
60
|
+
this.client = new mongodb_1.MongoClient(connectionString);
|
|
61
|
+
await this.client.connect();
|
|
62
|
+
this.db = this.client.db(databaseName);
|
|
63
|
+
// Create indexes
|
|
64
|
+
await this.createIndexes();
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
throw new Error(`Failed to connect to MongoDB: ${error instanceof Error ? error.message : error}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Creates necessary indexes for efficient queries
|
|
72
|
+
*/
|
|
73
|
+
async createIndexes() {
|
|
74
|
+
if (!this.db)
|
|
75
|
+
return;
|
|
76
|
+
const collection = this.db.collection("documentations");
|
|
77
|
+
// Index for project path and version (unique combination)
|
|
78
|
+
await collection.createIndex({ projectPath: 1, version: 1 }, { unique: true });
|
|
79
|
+
// Index for generatedAt (for sorting by date)
|
|
80
|
+
await collection.createIndex({ generatedAt: -1 });
|
|
81
|
+
// Index for projectPath (for filtering by project)
|
|
82
|
+
await collection.createIndex({ projectPath: 1 });
|
|
83
|
+
// Text index for full-text search on summary and analyses
|
|
84
|
+
await collection.createIndex({
|
|
85
|
+
summary: "text",
|
|
86
|
+
"fileAnalyses.analysis": "text",
|
|
87
|
+
"fileAnalyses.relativePath": "text",
|
|
88
|
+
});
|
|
89
|
+
// Indexes created silently
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Saves documentation to MongoDB
|
|
93
|
+
*/
|
|
94
|
+
async saveDocumentation(projectPath, analysis, version = "1.0.0") {
|
|
95
|
+
if (!this.db) {
|
|
96
|
+
await this.connect();
|
|
97
|
+
}
|
|
98
|
+
const collection = this.db.collection("documentations");
|
|
99
|
+
const record = {
|
|
100
|
+
projectPath: projectPath,
|
|
101
|
+
version,
|
|
102
|
+
generatedAt: new Date(),
|
|
103
|
+
summary: analysis.summary,
|
|
104
|
+
framework: analysis.framework,
|
|
105
|
+
stats: analysis.stats,
|
|
106
|
+
fileAnalyses: analysis.fileAnalyses.map(f => ({
|
|
107
|
+
path: f.path,
|
|
108
|
+
relativePath: f.relativePath,
|
|
109
|
+
analysis: f.analysis,
|
|
110
|
+
chunks: f.chunks,
|
|
111
|
+
fromCache: f.fromCache,
|
|
112
|
+
})),
|
|
113
|
+
metadata: {
|
|
114
|
+
model: undefined, // Can be added from options
|
|
115
|
+
cacheEnabled: true,
|
|
116
|
+
},
|
|
117
|
+
};
|
|
118
|
+
// Silent save - no logging to keep it hidden from users
|
|
119
|
+
// Upsert: update if exists, insert if not
|
|
120
|
+
const result = await collection.updateOne({ projectPath, version }, { $set: record }, { upsert: true });
|
|
121
|
+
// Silent save - no logging
|
|
122
|
+
const docId = result.upsertedId?.toString() || result.acknowledged ? "saved" : "failed";
|
|
123
|
+
return docId;
|
|
124
|
+
return docId;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Retrieves latest documentation for a project
|
|
128
|
+
*/
|
|
129
|
+
async getLatestDocumentation(projectPath) {
|
|
130
|
+
if (!this.db) {
|
|
131
|
+
await this.connect();
|
|
132
|
+
}
|
|
133
|
+
const collection = this.db.collection("documentations");
|
|
134
|
+
const doc = await collection
|
|
135
|
+
.findOne({ projectPath }, { sort: { generatedAt: -1 } });
|
|
136
|
+
return doc;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Retrieves documentation by project path and version
|
|
140
|
+
*/
|
|
141
|
+
async getDocumentation(projectPath, version) {
|
|
142
|
+
if (!this.db) {
|
|
143
|
+
await this.connect();
|
|
144
|
+
}
|
|
145
|
+
const collection = this.db.collection("documentations");
|
|
146
|
+
const doc = await collection.findOne({ projectPath, version });
|
|
147
|
+
return doc;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Lists all documentations for a project
|
|
151
|
+
*/
|
|
152
|
+
async listDocumentations(projectPath) {
|
|
153
|
+
if (!this.db) {
|
|
154
|
+
await this.connect();
|
|
155
|
+
}
|
|
156
|
+
const collection = this.db.collection("documentations");
|
|
157
|
+
const query = projectPath ? { projectPath } : {};
|
|
158
|
+
const docs = await collection
|
|
159
|
+
.find(query)
|
|
160
|
+
.sort({ generatedAt: -1 })
|
|
161
|
+
.toArray();
|
|
162
|
+
return docs;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Searches documentation by text
|
|
166
|
+
*/
|
|
167
|
+
async searchDocumentations(searchText, projectPath) {
|
|
168
|
+
if (!this.db) {
|
|
169
|
+
await this.connect();
|
|
170
|
+
}
|
|
171
|
+
const collection = this.db.collection("documentations");
|
|
172
|
+
const query = {
|
|
173
|
+
$text: { $search: searchText },
|
|
174
|
+
};
|
|
175
|
+
if (projectPath) {
|
|
176
|
+
query.projectPath = projectPath;
|
|
177
|
+
}
|
|
178
|
+
const docs = await collection
|
|
179
|
+
.find(query)
|
|
180
|
+
.sort({ score: { $meta: "textScore" } })
|
|
181
|
+
.toArray();
|
|
182
|
+
return docs;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Closes MongoDB connection
|
|
186
|
+
*/
|
|
187
|
+
async disconnect() {
|
|
188
|
+
if (this.client) {
|
|
189
|
+
await this.client.close();
|
|
190
|
+
this.client = null;
|
|
191
|
+
this.db = null;
|
|
192
|
+
console.log("✓ MongoDB connection closed");
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
exports.MongoDBStorage = MongoDBStorage;
|
|
197
|
+
//# sourceMappingURL=mongodb.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mongodb.js","sourceRoot":"","sources":["../src/mongodb.ts"],"names":[],"mappings":";;;AAAA,qCAAsD;AAwCtD,MAAa,cAAc;IAKzB,YAAY,MAAqB;QAJzB,WAAM,GAAuB,IAAI,CAAC;QAClC,OAAE,GAAc,IAAI,CAAC;QAI3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;OA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EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,EAAE,CAAC;aACvC,OAAO,EAAE,CAAC;QAEb,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,UAAU;QACd,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;YAC1B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;YACnB,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC;YACf,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;CACF;AApPD,wCAoPC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface FileResult {
|
|
2
|
+
path: string;
|
|
3
|
+
content: string;
|
|
4
|
+
relativePath: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ScannerOptions {
|
|
7
|
+
ignoreDirs?: string[];
|
|
8
|
+
fileExtensions?: string[];
|
|
9
|
+
includePatterns?: RegExp[];
|
|
10
|
+
}
|
|
11
|
+
export declare function readCodebase(dir: string, options?: ScannerOptions): FileResult[];
|
|
12
|
+
//# sourceMappingURL=scanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scanner.d.ts","sourceRoot":"","sources":["../src/scanner.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B;AAID,wBAAgB,YAAY,CAC1B,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,cAAmB,GAC3B,UAAU,EAAE,CA2Dd"}
|
package/dist/scanner.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.readCodebase = readCodebase;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const DEFAULT_IGNORE_DIRS = ["node_modules", ".git", "dist", "build", ".next", ".cache"];
|
|
10
|
+
const DEFAULT_EXTENSIONS = ["ts", "js", "tsx", "jsx", "json", "md", "py", "java", "go", "rs", "rb", "php"];
|
|
11
|
+
function readCodebase(dir, options = {}) {
|
|
12
|
+
const { ignoreDirs = DEFAULT_IGNORE_DIRS, fileExtensions = DEFAULT_EXTENSIONS, includePatterns = [], } = options;
|
|
13
|
+
const results = [];
|
|
14
|
+
const baseDir = path_1.default.resolve(dir);
|
|
15
|
+
const extensionPattern = new RegExp(`\\.(${fileExtensions.join("|")})$`, "i");
|
|
16
|
+
function walk(current) {
|
|
17
|
+
try {
|
|
18
|
+
const files = fs_1.default.readdirSync(current);
|
|
19
|
+
for (const file of files) {
|
|
20
|
+
const fullPath = path_1.default.join(current, file);
|
|
21
|
+
const stat = fs_1.default.statSync(fullPath);
|
|
22
|
+
if (stat.isDirectory()) {
|
|
23
|
+
if (!ignoreDirs.includes(file) && !file.startsWith(".")) {
|
|
24
|
+
walk(fullPath);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
const relativePath = path_1.default.relative(baseDir, fullPath);
|
|
29
|
+
// Check extension match
|
|
30
|
+
if (!extensionPattern.test(file)) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
// Check custom patterns if provided
|
|
34
|
+
if (includePatterns.length > 0) {
|
|
35
|
+
const matches = includePatterns.some(pattern => pattern.test(relativePath));
|
|
36
|
+
if (!matches)
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
const content = fs_1.default.readFileSync(fullPath, "utf8");
|
|
41
|
+
results.push({
|
|
42
|
+
path: fullPath,
|
|
43
|
+
relativePath,
|
|
44
|
+
content,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
console.warn(`Warning: Could not read ${fullPath}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
console.warn(`Warning: Could not access ${current}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
walk(baseDir);
|
|
58
|
+
return results;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=scanner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scanner.js","sourceRoot":"","sources":["../src/scanner.ts"],"names":[],"mappings":";;;;;AAmBA,oCA8DC;AAjFD,4CAAoB;AACpB,gDAAwB;AAExB,MAAM,mBAAmB,GAAG,CAAC,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;AAczF,MAAM,kBAAkB,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;AAE3G,SAAgB,YAAY,CAC1B,GAAW,EACX,UAA0B,EAAE;IAE5B,MAAM,EACJ,UAAU,GAAG,mBAAmB,EAChC,cAAc,GAAG,kBAAkB,EACnC,eAAe,GAAG,EAAE,GACrB,GAAG,OAAO,CAAC;IAEZ,MAAM,OAAO,GAAiB,EAAE,CAAC;IACjC,MAAM,OAAO,GAAG,cAAI,CAAC,OAAO,CAAC,GAAG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OAAO,CAAC,IAAI,CAAC;4BACX,IAAI,EAAE,QAAQ;4BACd,YAAY;4BACZ,OAAO;yBACR,CAAC,CAAC;oBACL,CAAC;oBAAC,OAAO,KAAK,EAAE,CAAC;wBACf,OAAO,CAAC,IAAI,CAAC,2BAA2B,QAAQ,EAAE,CAAC,CAAC;oBACtD,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,IAAI,CAAC,6BAA6B,OAAO,EAAE,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,CAAC;IACd,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "dev-doc",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "AI-powered codebase analyzer using Claude AI to generate documentation and insights",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"dev-doc": "dist/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"start": "node dist/cli.js",
|
|
12
|
+
"dev": "ts-node src/cli.ts",
|
|
13
|
+
"test:backend": "ts-node src/cli.ts test-backend/src --format markdown --output test-backend/ANALYSIS.md",
|
|
14
|
+
"test:backend:db": "ts-node src/cli.ts test-backend/src --format markdown --output test-backend/ANALYSIS.md --save-to-db",
|
|
15
|
+
"prepublishOnly": "npm run build"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"ai",
|
|
19
|
+
"code-analysis",
|
|
20
|
+
"documentation",
|
|
21
|
+
"claude",
|
|
22
|
+
"codebase",
|
|
23
|
+
"analyzer"
|
|
24
|
+
],
|
|
25
|
+
"author": "",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": ""
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@anthropic-ai/sdk": "^0.24.0",
|
|
33
|
+
"commander": "^11.1.0",
|
|
34
|
+
"dotenv": "^16.6.1",
|
|
35
|
+
"mongodb": "^6.21.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/node": "^20.10.0",
|
|
39
|
+
"ts-node": "^10.9.2",
|
|
40
|
+
"typescript": "^5.3.3"
|
|
41
|
+
},
|
|
42
|
+
"files": [
|
|
43
|
+
"dist",
|
|
44
|
+
"README.md"
|
|
45
|
+
],
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": ">=18.0.0"
|
|
48
|
+
}
|
|
49
|
+
}
|