@documentation-robotics/cli 0.3.0 → 0.4.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 +10 -14
- package/dist/analyzers/active-analyzer.js +62 -0
- package/dist/analyzers/active-analyzer.js.map +7 -0
- package/dist/analyzers/cards/build.js +21 -1
- package/dist/analyzers/cards/build.js.map +2 -2
- package/dist/analyzers/cards/extract.js +138 -0
- package/dist/analyzers/cards/extract.js.map +7 -0
- package/dist/analyzers/cards/routes.js +96 -0
- package/dist/analyzers/cards/routes.js.map +7 -0
- package/dist/analyzers/cbm-analyzer.js +76 -4
- package/dist/analyzers/cbm-analyzer.js.map +2 -2
- package/dist/analyzers/cbm-responses.js +12 -6
- package/dist/analyzers/cbm-responses.js.map +2 -2
- package/dist/analyzers/code-changes.js +159 -0
- package/dist/analyzers/code-changes.js.map +7 -0
- package/dist/analyzers/edge-relationships.js +6 -2
- package/dist/analyzers/edge-relationships.js.map +2 -2
- package/dist/analyzers/extraction-plan.js +541 -0
- package/dist/analyzers/extraction-plan.js.map +7 -0
- package/dist/analyzers/index-job.js +229 -0
- package/dist/analyzers/index-job.js.map +7 -0
- package/dist/cli.js +12 -10
- package/dist/cli.js.map +2 -2
- package/dist/coding-agents/drbot-mcp.js +120 -18
- package/dist/coding-agents/drbot-mcp.js.map +2 -2
- package/dist/commands/add.js +4 -2
- package/dist/commands/add.js.map +2 -2
- package/dist/commands/analyzer.js +35 -35
- package/dist/commands/analyzer.js.map +2 -2
- package/dist/commands/changeset-verify.js +16 -8
- package/dist/commands/changeset-verify.js.map +2 -2
- package/dist/commands/changeset.js +41 -11
- package/dist/commands/changeset.js.map +2 -2
- package/dist/commands/init.js +9 -26
- package/dist/commands/init.js.map +2 -2
- package/dist/commands/mcp.js +35 -31
- package/dist/commands/mcp.js.map +3 -3
- package/dist/commands/relationship.js +2 -12
- package/dist/commands/relationship.js.map +2 -2
- package/dist/commands/reports.js +3 -3
- package/dist/commands/reports.js.map +2 -2
- package/dist/commands/update.js +14 -13
- package/dist/commands/update.js.map +2 -2
- package/dist/commands/upgrade.js +28 -120
- package/dist/commands/upgrade.js.map +2 -2
- package/dist/commands/validate.js +19 -3
- package/dist/commands/validate.js.map +2 -2
- package/dist/commands/version.js +1 -1
- package/dist/commands/visualize.js +30 -12
- package/dist/commands/visualize.js.map +2 -2
- package/dist/core/annotation-store.js +15 -5
- package/dist/core/annotation-store.js.map +2 -2
- package/dist/core/catalog-migration.js +2 -1
- package/dist/core/catalog-migration.js.map +2 -2
- package/dist/core/changeset-base-index.js +7 -0
- package/dist/core/changeset-base-index.js.map +2 -2
- package/dist/core/changeset-brief-compact.js +256 -0
- package/dist/core/changeset-brief-compact.js.map +7 -0
- package/dist/core/changeset-verify.js +356 -26
- package/dist/core/changeset-verify.js.map +3 -3
- package/dist/core/extraction-observability.js +161 -0
- package/dist/core/extraction-observability.js.map +7 -0
- package/dist/core/migration-registry.js +13 -1
- package/dist/core/migration-registry.js.map +2 -2
- package/dist/core/project-init.js +53 -0
- package/dist/core/project-init.js.map +7 -0
- package/dist/core/relationship-staging.js +94 -1
- package/dist/core/relationship-staging.js.map +2 -2
- package/dist/core/staged-changeset-storage.js +83 -3
- package/dist/core/staged-changeset-storage.js.map +2 -2
- package/dist/core/staging-area.js +85 -8
- package/dist/core/staging-area.js.map +2 -2
- package/dist/core/upgrade-plan.js +117 -0
- package/dist/core/upgrade-plan.js.map +7 -0
- package/dist/generated/relationship-index.js +124 -15
- package/dist/generated/relationship-index.js.map +2 -2
- package/dist/integrations/claude_code/.claude-plugin/plugin.json +24 -0
- package/dist/integrations/claude_code/agents/dr-architect.md +19 -5
- package/dist/integrations/claude_code/agents/dr-extractor.md +7 -1
- package/dist/integrations/claude_code/commands/dr-changeset.md +2 -1
- package/dist/integrations/claude_code/commands/dr-map.md +7 -1
- package/dist/integrations/claude_code/commands/dr-plan.md +42 -16
- package/dist/integrations/claude_code/docs/MCP_SERVER.md +28 -31
- package/dist/integrations/claude_code/docs/README.md +20 -1
- package/dist/integrations/claude_code/plugin-agents/dr-advisor.md +255 -0
- package/dist/integrations/claude_code/plugin-agents/dr-architect.md +306 -0
- package/dist/integrations/claude_code/skills/dr_13_testing_layer/SKILL.md +3 -0
- package/dist/integrations/claude_code/skills/dr_change_planning/SKILL.md +90 -31
- package/dist/integrations/claude_code/skills/dr_changeset_reviewer/SKILL.md +5 -0
- package/dist/integrations/claude_code/skills/dr_engineering_guide/SKILL.md +5 -0
- package/dist/integrations/github_copilot/agents/dr-architect.md +2 -0
- package/dist/integrations/github_copilot/skills/dr_13_testing_layer/SKILL.md +3 -0
- package/dist/integrations/github_copilot/skills/dr_change_planning/SKILL.md +88 -30
- package/dist/mcp/changeset-only.js +14 -3
- package/dist/mcp/changeset-only.js.map +2 -2
- package/dist/mcp/project-root.js +85 -0
- package/dist/mcp/project-root.js.map +7 -0
- package/dist/mcp/server-instructions.js +27 -0
- package/dist/mcp/server-instructions.js.map +7 -0
- package/dist/mcp/strict-schema.js +52 -0
- package/dist/mcp/strict-schema.js.map +7 -0
- package/dist/mcp/tool-registry.js +39 -5
- package/dist/mcp/tool-registry.js.map +2 -2
- package/dist/mcp/tools/changeset-analysis-tools.js +25 -5
- package/dist/mcp/tools/changeset-analysis-tools.js.map +3 -3
- package/dist/mcp/tools/changeset-commit.js +224 -0
- package/dist/mcp/tools/changeset-commit.js.map +7 -0
- package/dist/mcp/tools/changeset-editing.js +133 -57
- package/dist/mcp/tools/changeset-editing.js.map +3 -3
- package/dist/mcp/tools/changeset-lifecycle.js +1 -1
- package/dist/mcp/tools/changeset-lifecycle.js.map +2 -2
- package/dist/mcp/tools/changeset-verify.js +12 -6
- package/dist/mcp/tools/changeset-verify.js.map +2 -2
- package/dist/mcp/tools/codebase-extract.js +836 -0
- package/dist/mcp/tools/codebase-extract.js.map +7 -0
- package/dist/mcp/tools/codebase-index.js +125 -0
- package/dist/mcp/tools/codebase-index.js.map +7 -0
- package/dist/mcp/tools/codebase-shared.js +265 -0
- package/dist/mcp/tools/codebase-shared.js.map +7 -0
- package/dist/mcp/tools/codebase-verify.js +48 -0
- package/dist/mcp/tools/codebase-verify.js.map +7 -0
- package/dist/mcp/tools/index.js +15 -0
- package/dist/mcp/tools/index.js.map +2 -2
- package/dist/mcp/tools/model-add.js +189 -73
- package/dist/mcp/tools/model-add.js.map +2 -2
- package/dist/mcp/tools/model-update.js +16 -12
- package/dist/mcp/tools/model-update.js.map +2 -2
- package/dist/mcp/tools/model-validate.js +46 -4
- package/dist/mcp/tools/model-validate.js.map +2 -2
- package/dist/mcp/tools/project-status-collectors.js +381 -0
- package/dist/mcp/tools/project-status-collectors.js.map +7 -0
- package/dist/mcp/tools/project-status.js +237 -0
- package/dist/mcp/tools/project-status.js.map +7 -0
- package/dist/mcp/tools/project-tools.js +505 -0
- package/dist/mcp/tools/project-tools.js.map +7 -0
- package/dist/mcp/tools/relationship-tools.js +89 -20
- package/dist/mcp/tools/relationship-tools.js.map +2 -2
- package/dist/mcp/tools/review-open.js +210 -0
- package/dist/mcp/tools/review-open.js.map +7 -0
- package/dist/mcp/tools/shared.js +10 -2
- package/dist/mcp/tools/shared.js.map +2 -2
- package/dist/reports/model-report-orchestrator.js +31 -2
- package/dist/reports/model-report-orchestrator.js.map +2 -2
- package/dist/schemas/bundled/analyzers/cbm.json +22 -10
- package/dist/schemas/bundled/analyzers/manifest.json +2 -2
- package/dist/schemas/bundled/api.json +1 -1
- package/dist/schemas/bundled/apm.json +1 -1
- package/dist/schemas/bundled/application.json +1 -1
- package/dist/schemas/bundled/base.json +1 -1
- package/dist/schemas/bundled/business.json +1 -1
- package/dist/schemas/bundled/data-model.json +1 -1
- package/dist/schemas/bundled/data-store.json +1 -1
- package/dist/schemas/bundled/manifest.json +3 -3
- package/dist/schemas/bundled/motivation.json +1 -1
- package/dist/schemas/bundled/navigation.json +1 -1
- package/dist/schemas/bundled/product.json +1 -1
- package/dist/schemas/bundled/security.json +1 -1
- package/dist/schemas/bundled/technology.json +1 -1
- package/dist/schemas/bundled/testing.json +145 -1
- package/dist/schemas/bundled/ux.json +1 -1
- package/dist/server/server.js +508 -237
- package/dist/server/server.js.map +3 -3
- package/dist/server/viewer-registry.js +264 -0
- package/dist/server/viewer-registry.js.map +7 -0
- package/dist/telemetry/index.js +1 -1
- package/dist/utils/id-generator.js +5 -2
- package/dist/utils/id-generator.js.map +2 -2
- package/dist/utils/source-reference.js +58 -27
- package/dist/utils/source-reference.js.map +2 -2
- package/dist/utils/spec-version.js +2 -2
- package/dist/utils/spec-version.js.map +1 -1
- package/dist/validators/model-warnings.js +28 -0
- package/dist/validators/model-warnings.js.map +7 -0
- package/dist/viewer/README.md +6 -6
- package/dist/viewer/assets/main-CUOQGGRA.css +1 -0
- package/dist/viewer/assets/main-DvH3gYrI.js +84 -0
- package/dist/viewer/index.html +2 -2
- package/dist/viewer/manifest.json +10 -10
- package/dist/viewer/version.json +1 -1
- package/package.json +1 -1
- package/dist/viewer/assets/main-CxzcuU_o.js +0 -84
- package/dist/viewer/assets/main-j-7ULYpm.css +0 -1
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { spawnSync } from "child_process";
|
|
2
2
|
import * as path from "path";
|
|
3
|
-
import { readFile } from "fs/promises";
|
|
3
|
+
import { readFile, writeFile } from "fs/promises";
|
|
4
4
|
import { CLIError, ErrorCategory, handleWarning } from "../utils/errors.js";
|
|
5
5
|
import { VALID_HTTP_METHODS } from "./types.js";
|
|
6
6
|
import { StdioClient } from "./stdio-client.js";
|
|
7
7
|
import { readIndexMeta, writeIndexMeta } from "./session-state.js";
|
|
8
8
|
import { getCliVersion } from "./version.js";
|
|
9
9
|
import { StagingAreaManager } from "../core/staging-area.js";
|
|
10
|
+
import { DR_OWN_DIRS } from "./code-changes.js";
|
|
10
11
|
import { VerifyEngine } from "./verify-engine.js";
|
|
11
12
|
import { clampDepth, shapeCallGraphNode, determineEdgeType } from "./call-graph-utils.js";
|
|
12
13
|
import { evaluateHeuristic, capConfidence, matchPattern, getKnownHeuristicNames } from "./heuristic-utils.js";
|
|
@@ -16,7 +17,8 @@ import { cbmCardGraph } from "./cards/graph.js";
|
|
|
16
17
|
import { classifyTier0, defaultLabels } from "./cards/classify.js";
|
|
17
18
|
import { CARD_FIELDS } from "./cards/build.js";
|
|
18
19
|
import { tier0RulesFrom } from "./tier0-rules.js";
|
|
19
|
-
|
|
20
|
+
import { collectExtraction, extractionConfigFrom } from "./cards/extract.js";
|
|
21
|
+
const EXTRACT_CALL_TIMEOUT_MS = 12e4, SOURCE_CODE_EXT_RE = /\.(ts|tsx|js|jsx|mjs|cjs|vue|svelte|py|go|rb|java|rs|php|cs|cpp|c|h|kt|swift|sh|bash)$/i;
|
|
20
22
|
function isLikelyHttpRoute(qualifiedName) {
|
|
21
23
|
const httpPath = qualifiedName.replace(/^__route__[A-Z]+__/, "");
|
|
22
24
|
return !SOURCE_CODE_EXT_RE.test(httpPath) && !httpPath.startsWith("/.dr/") && !httpPath.startsWith("/schemas/");
|
|
@@ -293,7 +295,14 @@ class CbmAnalyzer {
|
|
|
293
295
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
294
296
|
handleWarning("Failed to read active changeset", [`Error: ${errorMsg}`, "Continuing with indexing"]);
|
|
295
297
|
}
|
|
296
|
-
|
|
298
|
+
try {
|
|
299
|
+
const ignore = await ensureCbmIgnore(effectiveCodebaseRoot, projectRoot);
|
|
300
|
+
ignore.added.length > 0 && console.log(`Added ${ignore.added.join(", ")} to ${ignore.path} so the index leaves DR's own files out`);
|
|
301
|
+
} catch (error) {
|
|
302
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
303
|
+
handleWarning("Could not update .cbmignore; DR's own files may be indexed", [`Error: ${errorMsg}`]);
|
|
304
|
+
}
|
|
305
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString(), indexResponse = await tools.indexRepository(effectiveCodebaseRoot, options?.timeoutMs ? { timeout: options.timeoutMs } : void 0), nodeCount = typeof indexResponse.nodes == "number" ? indexResponse.nodes : 0, edgeCount = typeof indexResponse.edges == "number" ? indexResponse.edges : 0;
|
|
297
306
|
typeof indexResponse.nodes != "number" && handleWarning("Invalid node count from index_repository", [
|
|
298
307
|
`Expected number, got ${typeof indexResponse.nodes}: ${String(indexResponse.nodes)}`,
|
|
299
308
|
"Defaulting to 0 - index may be incomplete or corrupted"
|
|
@@ -1183,6 +1192,41 @@ class CbmAnalyzer {
|
|
|
1183
1192
|
client.close();
|
|
1184
1193
|
}
|
|
1185
1194
|
}
|
|
1195
|
+
/** The Tier-0 rules, edge mappings and node-mapping decisions extraction runs with. */
|
|
1196
|
+
extractionConfig() {
|
|
1197
|
+
const nodeMappings = this.mapper.getNodeLabels().map((label) => this.mapper.getNodeMapping(label)).filter((m) => !!m), edgeMappings = this.mapper.getEdgeTypes().map((type) => this.mapper.getEdgeMapping(type)).filter((m) => !!m);
|
|
1198
|
+
return extractionConfigFrom(tier0RulesFrom(this.mapper.getHeuristics()), edgeMappings, nodeMappings);
|
|
1199
|
+
}
|
|
1200
|
+
/**
|
|
1201
|
+
* What `codebase_extract` reads from the index (src/analyzers/cards/extract.ts): cards with
|
|
1202
|
+
* their Tier-0 outcomes, the mapped edges and the symbols of the files asked about. Read-only.
|
|
1203
|
+
* Graph reads get two minutes each, past the client's 30s default, for large graphs.
|
|
1204
|
+
*
|
|
1205
|
+
* @throws CLIError if the project is not indexed or the mapping has no Tier-0 rules
|
|
1206
|
+
*/
|
|
1207
|
+
async extract(projectRoot, options = {}) {
|
|
1208
|
+
const effectiveCodebaseRoot = options.codebaseRoot ?? projectRoot, config = this.extractionConfig();
|
|
1209
|
+
if (config.rules.length === 0)
|
|
1210
|
+
throw new CLIError(`The ${this.name} analyzer mapping has no Tier-0 rules`, ErrorCategory.USER);
|
|
1211
|
+
const status = await this.status(projectRoot, { codebaseRoot: effectiveCodebaseRoot });
|
|
1212
|
+
if (!status.indexed)
|
|
1213
|
+
throw new CLIError(`Project not indexed: ${projectRoot}`, ErrorCategory.NOT_FOUND, ["Run `dr analyzer index` to index the project"]);
|
|
1214
|
+
if (!status.detected.installed)
|
|
1215
|
+
throw new CLIError("CBM analyzer not installed", ErrorCategory.NOT_FOUND, [
|
|
1216
|
+
"Install codebase-memory-mcp: npm install -g codebase-memory-mcp"
|
|
1217
|
+
]);
|
|
1218
|
+
const client = new StdioClient();
|
|
1219
|
+
try {
|
|
1220
|
+
client.spawn(status.detected.binary_path), await client.initialize({ name: "dr-cli", version: await getCliVersion() });
|
|
1221
|
+
const tools = new CbmTools(client, { timeout: EXTRACT_CALL_TIMEOUT_MS }), projectName = await this.resolveProjectName(tools, effectiveCodebaseRoot);
|
|
1222
|
+
return await collectExtraction(cbmCardGraph(tools, projectName), config, this.name, {
|
|
1223
|
+
sourceRoot: effectiveCodebaseRoot,
|
|
1224
|
+
...options
|
|
1225
|
+
});
|
|
1226
|
+
} finally {
|
|
1227
|
+
client.close();
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1186
1230
|
/**
|
|
1187
1231
|
* Verify that graph-discovered routes align with model endpoints
|
|
1188
1232
|
*
|
|
@@ -1222,8 +1266,36 @@ class CbmAnalyzer {
|
|
|
1222
1266
|
}
|
|
1223
1267
|
}
|
|
1224
1268
|
}
|
|
1269
|
+
const CBM_IGNORE_HEADING = "# Added by Documentation Robotics: its model, changesets and analyzer state are not code.";
|
|
1270
|
+
async function ensureCbmIgnore(codebaseRoot, projectRoot) {
|
|
1271
|
+
const file = path.join(codebaseRoot, ".cbmignore");
|
|
1272
|
+
let text = "", created = !0;
|
|
1273
|
+
try {
|
|
1274
|
+
text = await readFile(file, "utf-8"), created = !1;
|
|
1275
|
+
} catch (error) {
|
|
1276
|
+
if (error.code !== "ENOENT")
|
|
1277
|
+
throw error;
|
|
1278
|
+
}
|
|
1279
|
+
const lines = text.split(/\r?\n/).map((line) => line.trim()).filter((line) => line && !line.startsWith("#")), folder = (line) => line.replace(/^\/+/, "").replace(/\/+$/, ""), listed = new Set(lines.filter((line) => !line.startsWith("!")).map(folder)), negated = new Set(lines.filter((line) => line.startsWith("!")).map((line) => folder(line.slice(1)))), added = [];
|
|
1280
|
+
for (const dir of DR_OWN_DIRS) {
|
|
1281
|
+
const relative = path.relative(codebaseRoot, path.join(projectRoot, dir)).split(path.sep).join("/");
|
|
1282
|
+
!relative || relative.startsWith("..") || path.isAbsolute(relative) || !listed.has(relative) && !negated.has(relative) && added.push(`/${relative}/`);
|
|
1283
|
+
}
|
|
1284
|
+
if (added.length === 0)
|
|
1285
|
+
return { path: file, added, created: !1 };
|
|
1286
|
+
const separator = text.length === 0 ? "" : text.endsWith(`
|
|
1287
|
+
`) ? `
|
|
1288
|
+
` : `
|
|
1289
|
+
|
|
1290
|
+
`, heading = text.includes(CBM_IGNORE_HEADING) ? "" : `${CBM_IGNORE_HEADING}
|
|
1291
|
+
`;
|
|
1292
|
+
return await writeFile(file, `${text}${separator}${heading}${added.join(`
|
|
1293
|
+
`)}
|
|
1294
|
+
`), { path: file, added, created };
|
|
1295
|
+
}
|
|
1225
1296
|
export {
|
|
1226
1297
|
CbmAnalyzer,
|
|
1227
|
-
SOURCE_CODE_EXT_RE
|
|
1298
|
+
SOURCE_CODE_EXT_RE,
|
|
1299
|
+
ensureCbmIgnore
|
|
1228
1300
|
};
|
|
1229
1301
|
//# sourceMappingURL=cbm-analyzer.js.map
|