@documentation-robotics/cli 0.1.5 → 0.1.8
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/dist/analyzers/stdio-client.js +4 -2
- package/dist/analyzers/stdio-client.js.map +2 -2
- package/dist/cli.js +1 -1
- package/dist/commands/version.js +1 -1
- package/dist/commands/visualize.js +6 -5
- package/dist/commands/visualize.js.map +2 -2
- package/dist/server/server.js +144 -86
- package/dist/server/server.js.map +2 -2
- package/dist/server-entry.js.map +2 -2
- package/dist/telemetry/index.js +1 -1
- package/package.json +20 -15
package/dist/server-entry.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/server-entry.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Visualization Server Entry Point\n * This is a Bun
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/**\n * Visualization Server Entry Point\n * This is spawned as a subprocess by `dr visualize` (see cli/src/commands/visualize.ts),\n * using whichever runtime (Node.js or Bun) is already running the parent CLI process.\n * It receives configuration via environment variables and starts the server.\n */\n\nimport { Model } from \"./core/model.js\";\nimport { VisualizationServer } from \"./server/server.js\";\nimport { getErrorMessage } from \"./utils/errors.js\";\n\n// Get configuration from environment variables\nconst port = parseInt(process.env.DR_VISUALIZE_PORT || \"8080\", 10);\nconst projectPath = process.env.DR_PROJECT_PATH || process.cwd();\nconst authEnabled = process.env.DR_AUTH_ENABLED !== \"false\";\n// Only pass authToken if it's a non-empty string, otherwise let server generate one\nconst authToken =\n process.env.DR_AUTH_TOKEN && process.env.DR_AUTH_TOKEN.length > 0\n ? process.env.DR_AUTH_TOKEN\n : undefined;\nconst withDanger = process.env.DR_WITH_DANGER === \"true\";\nconst viewerPath = process.env.DR_VIEWER_PATH;\n\n// Conditional telemetry import based on compile-time flag\ndeclare const TELEMETRY_ENABLED: boolean | undefined;\nconst isTelemetryEnabled = typeof TELEMETRY_ENABLED !== \"undefined\" ? TELEMETRY_ENABLED : false;\n\nlet serverInstance: VisualizationServer | null = null;\nlet isShuttingDown = false;\n\nasync function main() {\n try {\n // CRITICAL: Initialize telemetry SDK in subprocess\n // Without this, no spans will be created or exported even though TELEMETRY_ENABLED=true\n if (isTelemetryEnabled) {\n try {\n const { initTelemetry } = await import(\"./telemetry/index.js\");\n await initTelemetry();\n\n // Load and display actual OTLP configuration\n const { loadOTLPConfig } = await import(\"./telemetry/config.js\");\n const otlpConfig = await loadOTLPConfig();\n\n if (process.env.DEBUG || process.env.VERBOSE) {\n console.log(`[Telemetry] SDK initialized in server subprocess`);\n console.log(`[Telemetry] OTLP traces endpoint: ${otlpConfig.endpoint}`);\n console.log(`[Telemetry] OTLP logs endpoint: ${otlpConfig.logsEndpoint}`);\n console.log(`[Telemetry] Service name: ${otlpConfig.serviceName}`);\n\n // Runtime detection and compatibility info\n const isBun = typeof (globalThis as any).Bun !== \"undefined\";\n if (isBun) {\n console.log(`[Telemetry] Runtime: Bun (using fetch-based OTLP exporter)`);\n } else {\n console.log(`[Telemetry] Runtime: Node.js (using http-based OTLP exporter)`);\n }\n }\n } catch (error) {\n // Log telemetry initialization errors but don't fail the server\n console.error(\"[Telemetry] Failed to initialize telemetry:\", error);\n console.error(\"[Telemetry] Server will continue without telemetry\");\n }\n } else if (process.env.DEBUG || process.env.VERBOSE) {\n console.log(`[Telemetry] TELEMETRY_ENABLED is false - telemetry disabled`);\n }\n\n // Load model with full content\n const model = await Model.load(projectPath, { lazyLoad: false });\n\n // Create and start server\n const server = new VisualizationServer(model, {\n authEnabled,\n authToken,\n withDanger,\n viewerPath,\n });\n serverInstance = server; // Store for signal handlers\n await server.start(port);\n\n // Output token for parent process to read\n if (authEnabled) {\n console.log(`TOKEN:${server.getAuthToken()}`);\n }\n\n // Setup graceful shutdown handlers\n setupShutdownHandlers();\n } catch (error) {\n const message = getErrorMessage(error);\n console.error(`Error: ${message}`);\n if (error instanceof Error) {\n console.error(`Stack: ${error.stack}`);\n }\n await gracefulShutdown(1);\n }\n}\n\n/**\n * Gracefully shutdown the server and flush telemetry\n */\nasync function gracefulShutdown(exitCode: number = 0): Promise<void> {\n if (isShuttingDown) {\n return; // Prevent multiple shutdown attempts\n }\n isShuttingDown = true;\n\n try {\n // Stop the visualization server\n if (serverInstance) {\n serverInstance.stop();\n serverInstance = null;\n }\n\n // Flush telemetry spans before exit\n if (isTelemetryEnabled) {\n console.log(\"[Telemetry] Shutting down telemetry and flushing spans...\");\n const { shutdownTelemetry } = await import(\"./telemetry/index.js\");\n await shutdownTelemetry();\n console.log(\"[Telemetry] Telemetry shutdown complete\");\n } else {\n if (process.env.DEBUG) {\n console.log(\"[Telemetry] Telemetry is disabled (TELEMETRY_ENABLED=false at build time)\");\n }\n }\n } catch (error) {\n // Don't block shutdown on errors\n if (process.env.DEBUG) {\n console.error(\"Error during shutdown:\", error);\n }\n } finally {\n process.exit(exitCode);\n }\n}\n\n/**\n * Setup handlers for graceful shutdown on signals\n */\nfunction setupShutdownHandlers(): void {\n // Handle Ctrl-C (SIGINT)\n process.on(\"SIGINT\", async () => {\n console.log(\"\\n[SIGINT] Shutting down visualization server...\");\n await gracefulShutdown(0);\n });\n\n // Handle termination signal (SIGTERM)\n process.on(\"SIGTERM\", async () => {\n console.log(\"\\n[SIGTERM] Shutting down visualization server...\");\n await gracefulShutdown(0);\n });\n\n // Handle uncaught exceptions\n process.on(\"uncaughtException\", async (error) => {\n console.error(\"Uncaught exception:\", error);\n await gracefulShutdown(1);\n });\n\n // Handle unhandled promise rejections\n process.on(\"unhandledRejection\", async (reason) => {\n console.error(\"Unhandled rejection:\", reason);\n await gracefulShutdown(1);\n });\n}\n\nmain();\n"],
|
|
5
|
+
"mappings": "AAOA,SAAS,aAAa;AACtB,SAAS,2BAA2B;AACpC,SAAS,uBAAuB;AAGhC,MAAM,OAAO,SAAS,QAAQ,IAAI,qBAAqB,QAAQ,EAAE,GAC3D,cAAc,QAAQ,IAAI,m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AAM,UAAU,OAAO,EAAE,GAC7B,iBAAiB,SACnB,QAAQ,MAAM,UAAU,MAAM,KAAK,EAAE,GAEvC,MAAM,iBAAiB,CAAC;EAC1B;AACF;AAKA,eAAe,iBAAiB,WAAmB,GAAC;AAClD,MAAI,iBAGJ;qBAAiB;AAEjB,QAAI;AAQF,UANI,mBACF,eAAe,KAAI,GACnB,iBAAiB,OAIf,oBAAoB;AACtB,gBAAQ,IAAI,2DAA2D;AACvE,cAAM,EAAE,kBAAiB,IAAK,MAAM,OAAO,sBAAsB;AACjE,cAAM,kBAAiB,GACvB,QAAQ,IAAI,yCAAyC;MACvD;AACE,QAAI,QAAQ,IAAI,SACd,QAAQ,IAAI,2EAA2E;IAG7F,SAAS,OAAO;AAEd,MAAI,QAAQ,IAAI,SACd,QAAQ,MAAM,0BAA0B,KAAK;IAEjD;AACE,cAAQ,KAAK,QAAQ;IACvB;;AACF;AAKA,SAAS,wBAAqB;AAE5B,UAAQ,GAAG,UAAU,YAAW;AAC9B,YAAQ,IAAI;+CAAkD,GAC9D,MAAM,iBAAiB,CAAC;EAC1B,CAAC,GAGD,QAAQ,GAAG,WAAW,YAAW;AAC/B,YAAQ,IAAI;gDAAmD,GAC/D,MAAM,iBAAiB,CAAC;EAC1B,CAAC,GAGD,QAAQ,GAAG,qBAAqB,OAAO,UAAS;AAC9C,YAAQ,MAAM,uBAAuB,KAAK,GAC1C,MAAM,iBAAiB,CAAC;EAC1B,CAAC,GAGD,QAAQ,GAAG,sBAAsB,OAAO,WAAU;AAChD,YAAQ,MAAM,wBAAwB,MAAM,GAC5C,MAAM,iBAAiB,CAAC;EAC1B,CAAC;AACH;AAEA,KAAI;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/telemetry/index.js
CHANGED
|
@@ -21,7 +21,7 @@ async function initTelemetry() {
|
|
|
21
21
|
`), process.stderr.write(` - Logs endpoint: ${otlpConfig.logsEndpoint}
|
|
22
22
|
`), process.stderr.write(` - Service name: ${otlpConfig.serviceName}
|
|
23
23
|
`));
|
|
24
|
-
const cliVersion = "0.1.
|
|
24
|
+
const cliVersion = "0.1.8";
|
|
25
25
|
let projectName = "unknown";
|
|
26
26
|
try {
|
|
27
27
|
const [{ readFileSync, existsSync }, { parse }] = await Promise.all([
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@documentation-robotics/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "CLI for Documentation Robotics",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/cli.js",
|
|
@@ -24,17 +24,17 @@
|
|
|
24
24
|
"dev": "node dist/cli.js",
|
|
25
25
|
"lint": "tsc --noEmit",
|
|
26
26
|
"type-check": "tsc --noEmit",
|
|
27
|
-
"test": "bun test --concurrent ./tests/unit/core/ ./tests/unit/validators/ ./tests/unit/telemetry/ ./tests/unit/utils/ ./tests/unit/coding-agents/ ./tests/unit/integrations/ ./tests/unit/server/ ./tests/unit/audit/ ./tests/unit/export/ ./tests/compatibility/ --test-name-pattern '^(?!BaseIntegrationManager)' ; bun test ./tests/unit/analyzers/ ; bun test tests/unit/chat/*.test.ts tests/integration/**/*.test.ts tests/unit/integrations/base-manager.test.ts",
|
|
28
|
-
"test:unit": "bun test --concurrent ./tests/unit/core/ ./tests/unit/validators/ ./tests/unit/telemetry/ ./tests/unit/utils/ ./tests/unit/coding-agents/ ./tests/unit/integrations/ ./tests/unit/server/ ./tests/unit/scripts/ ./tests/unit/audit/ ./tests/unit/export/ --test-name-pattern '^(?!BaseIntegrationManager)' ; bun test ./tests/unit/analyzers/ ; bun test tests/unit/chat/*.test.ts tests/unit/integrations/base-manager.test.ts",
|
|
29
|
-
"test:generated": "bun test tests/unit/generators/*.test.ts",
|
|
30
|
-
"test:integration": "[ -f dist/cli.js ] || npm run build && bun test tests/integration/*.test.ts",
|
|
31
|
-
"test:validators": "bun test --concurrent ./tests/unit/validators/",
|
|
32
|
-
"test:compatibility": "bun test --concurrent tests/compatibility",
|
|
33
|
-
"test:all": "[ -f dist/cli.js ] || npm run build && bun test --concurrent ./tests/ --test-name-pattern '^(?!BaseIntegrationManager)' ; bun test tests/unit/integrations/base-manager.test.ts",
|
|
34
|
-
"test:coverage": "[ -f dist/cli.js ] || npm run build && bun test --concurrent --coverage ./tests/ --test-name-pattern '^(?!BaseIntegrationManager)' ; bun test --coverage tests/unit/integrations/base-manager.test.ts",
|
|
35
|
-
"test:coverage:html": "[ -f dist/cli.js ] || npm run build && bun test --concurrent --coverage --coverage-reporter=html ./tests/ --test-name-pattern '^(?!BaseIntegrationManager)' ; bun test --coverage --coverage-reporter=html tests/unit/integrations/base-manager.test.ts",
|
|
36
|
-
"test:coverage:ci": "[ -f dist/cli.js ] || npm run build && bun test --concurrent --coverage --coverage-reporter=lcov ./tests/ --test-name-pattern '^(?!BaseIntegrationManager)' ; bun test --coverage --coverage-reporter=lcov tests/unit/integrations/base-manager.test.ts && node scripts/validate-coverage-threshold.js",
|
|
37
|
-
"test:perf": "bun test tests/performance/**/*.test.ts",
|
|
27
|
+
"test": "bun test --timeout=30000 --concurrent ./tests/unit/core/ ./tests/unit/validators/ ./tests/unit/telemetry/ ./tests/unit/utils/ ./tests/unit/coding-agents/ ./tests/unit/integrations/ ./tests/unit/server/ ./tests/unit/audit/ ./tests/unit/export/ ./tests/compatibility/ --test-name-pattern '^(?!BaseIntegrationManager)' ; bun test --timeout=30000 ./tests/unit/analyzers/ ; bun test --timeout=30000 tests/unit/chat/*.test.ts tests/integration/**/*.test.ts tests/unit/integrations/base-manager.test.ts",
|
|
28
|
+
"test:unit": "bun test --timeout=30000 --concurrent ./tests/unit/core/ ./tests/unit/validators/ ./tests/unit/telemetry/ ./tests/unit/utils/ ./tests/unit/coding-agents/ ./tests/unit/integrations/ ./tests/unit/server/ ./tests/unit/scripts/ ./tests/unit/audit/ ./tests/unit/export/ --test-name-pattern '^(?!BaseIntegrationManager)' ; bun test --timeout=30000 ./tests/unit/analyzers/ ; bun test --timeout=30000 tests/unit/chat/*.test.ts tests/unit/integrations/base-manager.test.ts",
|
|
29
|
+
"test:generated": "bun test --timeout=30000 tests/unit/generators/*.test.ts",
|
|
30
|
+
"test:integration": "[ -f dist/cli.js ] || npm run build && bun test --timeout=30000 tests/integration/*.test.ts",
|
|
31
|
+
"test:validators": "bun test --timeout=30000 --concurrent ./tests/unit/validators/",
|
|
32
|
+
"test:compatibility": "bun test --timeout=30000 --concurrent tests/compatibility",
|
|
33
|
+
"test:all": "[ -f dist/cli.js ] || npm run build && bun test --timeout=30000 --concurrent ./tests/ --test-name-pattern '^(?!BaseIntegrationManager)' ; bun test --timeout=30000 tests/unit/integrations/base-manager.test.ts",
|
|
34
|
+
"test:coverage": "[ -f dist/cli.js ] || npm run build && bun test --timeout=30000 --concurrent --coverage ./tests/ --test-name-pattern '^(?!BaseIntegrationManager)' ; bun test --timeout=30000 --coverage tests/unit/integrations/base-manager.test.ts",
|
|
35
|
+
"test:coverage:html": "[ -f dist/cli.js ] || npm run build && bun test --timeout=30000 --concurrent --coverage --coverage-reporter=html ./tests/ --test-name-pattern '^(?!BaseIntegrationManager)' ; bun test --timeout=30000 --coverage --coverage-reporter=html tests/unit/integrations/base-manager.test.ts",
|
|
36
|
+
"test:coverage:ci": "[ -f dist/cli.js ] || npm run build && bun test --timeout=30000 --concurrent --coverage --coverage-reporter=lcov ./tests/ --test-name-pattern '^(?!BaseIntegrationManager)' ; bun test --timeout=30000 --coverage --coverage-reporter=lcov tests/unit/integrations/base-manager.test.ts && node scripts/validate-coverage-threshold.js",
|
|
37
|
+
"test:perf": "bun test --timeout=30000 tests/performance/**/*.test.ts",
|
|
38
38
|
"test:smoke": "[ -f dist/cli.js ] || npm run build && bash scripts/run-smoke-tests.sh"
|
|
39
39
|
},
|
|
40
40
|
"keywords": [
|
|
@@ -56,14 +56,20 @@
|
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@anthropic-ai/sdk": "^0.71.2",
|
|
58
58
|
"@clack/prompts": "^0.8.0",
|
|
59
|
+
"@hono/node-server": "^1.19.17",
|
|
60
|
+
"@hono/node-ws": "^1.3.1",
|
|
59
61
|
"@hono/swagger-ui": "^0.5.3",
|
|
60
62
|
"@hono/zod-openapi": "^1.2.1",
|
|
61
63
|
"@hono/zod-validator": "^0.7.6",
|
|
64
|
+
"@opentelemetry/api": "^1.9.0",
|
|
65
|
+
"@opentelemetry/api-logs": "^0.57.0",
|
|
62
66
|
"@xmldom/xmldom": "^0.8.11",
|
|
63
67
|
"ajv": "^8.12.0",
|
|
64
68
|
"ajv-formats": "^2.1.0",
|
|
65
69
|
"ansis": "^3.0.0",
|
|
70
|
+
"chokidar": "^4.0.3",
|
|
66
71
|
"commander": "^12.0.0",
|
|
72
|
+
"glob": "^11.1.0",
|
|
67
73
|
"graphology": "^0.25.4",
|
|
68
74
|
"graphology-traversal": "^0.3.1",
|
|
69
75
|
"graphology-types": "^0.24.8",
|
|
@@ -73,10 +79,10 @@
|
|
|
73
79
|
"zod": "^4.3.6"
|
|
74
80
|
},
|
|
75
81
|
"devDependencies": {
|
|
76
|
-
"@opentelemetry/
|
|
77
|
-
"@opentelemetry/api-logs": "^0.57.0",
|
|
82
|
+
"@opentelemetry/core": "^1.30.1",
|
|
78
83
|
"@opentelemetry/exporter-logs-otlp-http": "^0.57.0",
|
|
79
84
|
"@opentelemetry/exporter-trace-otlp-http": "^0.57.0",
|
|
85
|
+
"@opentelemetry/resources": "^1.30.1",
|
|
80
86
|
"@opentelemetry/sdk-logs": "^0.57.0",
|
|
81
87
|
"@opentelemetry/sdk-node": "^0.57.0",
|
|
82
88
|
"@opentelemetry/sdk-trace-base": "^1.30.0",
|
|
@@ -86,7 +92,6 @@
|
|
|
86
92
|
"bun-types": "^1.3.5",
|
|
87
93
|
"diff": "^8.0.2",
|
|
88
94
|
"esbuild": "^0.24.2",
|
|
89
|
-
"glob": "^11.1.0",
|
|
90
95
|
"prettier": "^3.8.1",
|
|
91
96
|
"tsx": "^4.7.0",
|
|
92
97
|
"typescript": "^5.3.0"
|