depwire-cli 0.2.6 → 0.3.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 +56 -2
- package/dist/{chunk-V3SB37U3.js → chunk-C3LAKUAJ.js} +1897 -19
- package/dist/index.js +101 -1
- package/dist/mcpb-entry.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import {
|
|
3
3
|
buildGraph,
|
|
4
4
|
createEmptyState,
|
|
5
|
+
generateDocs,
|
|
5
6
|
getArchitectureSummary,
|
|
6
7
|
getImpact,
|
|
7
8
|
parseProject,
|
|
@@ -11,7 +12,7 @@ import {
|
|
|
11
12
|
startVizServer,
|
|
12
13
|
updateFileInGraph,
|
|
13
14
|
watchProject
|
|
14
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-C3LAKUAJ.js";
|
|
15
16
|
|
|
16
17
|
// src/index.ts
|
|
17
18
|
import { Command } from "commander";
|
|
@@ -86,6 +87,8 @@ function importFromJSON(json) {
|
|
|
86
87
|
}
|
|
87
88
|
|
|
88
89
|
// src/index.ts
|
|
90
|
+
import { readFileSync as readFileSyncNode, appendFileSync, existsSync as existsSyncNode } from "fs";
|
|
91
|
+
import { createInterface } from "readline";
|
|
89
92
|
var __filename = fileURLToPath(import.meta.url);
|
|
90
93
|
var __dirname = dirname(__filename);
|
|
91
94
|
var packageJsonPath = join(__dirname, "../package.json");
|
|
@@ -254,4 +257,101 @@ program.command("mcp").description("Start MCP server for AI coding tools").argum
|
|
|
254
257
|
process.exit(1);
|
|
255
258
|
}
|
|
256
259
|
});
|
|
260
|
+
program.command("docs").description("Generate comprehensive codebase documentation").argument("<directory>", "Project directory to document").option("-o, --output <path>", "Output directory (default: .depwire/ inside project)").option("--format <type>", "Output format: markdown | json", "markdown").option("--gitignore", "Add .depwire/ to .gitignore automatically").option("--no-gitignore", "Don't modify .gitignore").option("--include <docs>", "Comma-separated list of docs to generate (default: all)", "all").option("--update", "Regenerate existing docs").option("--only <docs>", "Used with --update, regenerate only specific docs").option("--verbose", "Show generation progress").option("--stats", "Show generation statistics at the end").option("--exclude <patterns...>", 'Glob patterns to exclude (e.g., "**/*.test.*" "dist/**")').action(async (directory, options) => {
|
|
261
|
+
const startTime = Date.now();
|
|
262
|
+
try {
|
|
263
|
+
const projectRoot = resolve(directory);
|
|
264
|
+
const outputDir = options.output ? resolve(options.output) : join(projectRoot, ".depwire");
|
|
265
|
+
const includeList = options.include.split(",").map((s) => s.trim());
|
|
266
|
+
const onlyList = options.only ? options.only.split(",").map((s) => s.trim()) : void 0;
|
|
267
|
+
if (options.gitignore === void 0 && !existsSyncNode(outputDir)) {
|
|
268
|
+
const answer = await promptGitignore();
|
|
269
|
+
if (answer) {
|
|
270
|
+
addToGitignore(projectRoot, ".depwire/");
|
|
271
|
+
}
|
|
272
|
+
} else if (options.gitignore === true) {
|
|
273
|
+
addToGitignore(projectRoot, ".depwire/");
|
|
274
|
+
}
|
|
275
|
+
console.log(`Parsing project: ${projectRoot}`);
|
|
276
|
+
const parsedFiles = parseProject(projectRoot, {
|
|
277
|
+
exclude: options.exclude,
|
|
278
|
+
verbose: options.verbose
|
|
279
|
+
});
|
|
280
|
+
console.log(`Parsed ${parsedFiles.length} files`);
|
|
281
|
+
const graph = buildGraph(parsedFiles);
|
|
282
|
+
const parseTime = (Date.now() - startTime) / 1e3;
|
|
283
|
+
console.log(`Built graph: ${graph.order} symbols, ${graph.size} edges`);
|
|
284
|
+
if (options.verbose) {
|
|
285
|
+
console.log(`
|
|
286
|
+
Generating documentation to: ${outputDir}`);
|
|
287
|
+
}
|
|
288
|
+
const result = await generateDocs(graph, projectRoot, packageJson.version, parseTime, {
|
|
289
|
+
outputDir,
|
|
290
|
+
format: options.format,
|
|
291
|
+
include: includeList,
|
|
292
|
+
update: options.update || false,
|
|
293
|
+
only: onlyList,
|
|
294
|
+
verbose: options.verbose || false,
|
|
295
|
+
stats: options.stats || false
|
|
296
|
+
});
|
|
297
|
+
if (result.success) {
|
|
298
|
+
console.log(`
|
|
299
|
+
\u2705 Documentation generated successfully!`);
|
|
300
|
+
console.log(`Output directory: ${outputDir}`);
|
|
301
|
+
console.log(`Generated files: ${result.generated.join(", ")}`);
|
|
302
|
+
if (result.stats) {
|
|
303
|
+
console.log(`
|
|
304
|
+
=== Generation Statistics ===`);
|
|
305
|
+
console.log(`Time: ${(result.stats.totalTime / 1e3).toFixed(2)}s`);
|
|
306
|
+
console.log(`Files generated: ${result.stats.filesGenerated}`);
|
|
307
|
+
}
|
|
308
|
+
} else {
|
|
309
|
+
console.error(`
|
|
310
|
+
\u274C Documentation generation completed with errors:`);
|
|
311
|
+
for (const error of result.errors) {
|
|
312
|
+
console.error(` - ${error}`);
|
|
313
|
+
}
|
|
314
|
+
process.exit(1);
|
|
315
|
+
}
|
|
316
|
+
} catch (err) {
|
|
317
|
+
console.error("Error generating documentation:", err);
|
|
318
|
+
process.exit(1);
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
async function promptGitignore() {
|
|
322
|
+
const rl = createInterface({
|
|
323
|
+
input: process.stdin,
|
|
324
|
+
output: process.stdout
|
|
325
|
+
});
|
|
326
|
+
return new Promise((resolve2) => {
|
|
327
|
+
rl.question("Add .depwire/ to .gitignore? [Y/n] ", (answer) => {
|
|
328
|
+
rl.close();
|
|
329
|
+
const normalized = answer.trim().toLowerCase();
|
|
330
|
+
resolve2(normalized === "" || normalized === "y" || normalized === "yes");
|
|
331
|
+
});
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
function addToGitignore(projectRoot, pattern) {
|
|
335
|
+
const gitignorePath = join(projectRoot, ".gitignore");
|
|
336
|
+
try {
|
|
337
|
+
let content = "";
|
|
338
|
+
if (existsSyncNode(gitignorePath)) {
|
|
339
|
+
content = readFileSyncNode(gitignorePath, "utf-8");
|
|
340
|
+
}
|
|
341
|
+
if (content.includes(pattern)) {
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
const newContent = content.endsWith("\n") ? `${content}${pattern}
|
|
345
|
+
` : `${content}
|
|
346
|
+
${pattern}
|
|
347
|
+
`;
|
|
348
|
+
appendFileSync(gitignorePath, content.endsWith("\n") ? `${pattern}
|
|
349
|
+
` : `
|
|
350
|
+
${pattern}
|
|
351
|
+
`, "utf-8");
|
|
352
|
+
console.log(`Added ${pattern} to .gitignore`);
|
|
353
|
+
} catch (err) {
|
|
354
|
+
console.error(`Warning: Failed to update .gitignore: ${err}`);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
257
357
|
program.parse();
|
package/dist/mcpb-entry.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "depwire-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Code cross-reference visualization and AI context engine for TypeScript. Analyzes codebases to show dependencies, enables AI tools with MCP, and renders beautiful arc diagrams.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|