@documentation-robotics/cli 0.1.0 → 0.1.7
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/LICENSE +21 -0
- package/README.md +466 -693
- package/dist/analysis/data-model-analyzer.js +189 -0
- package/dist/analysis/data-model-analyzer.js.map +7 -0
- package/dist/analysis/index.js +3 -0
- package/dist/analysis/index.js.map +7 -0
- package/dist/analysis/relationship-classifier.js +181 -0
- package/dist/analysis/relationship-classifier.js.map +7 -0
- package/dist/analyzers/base-analyzer.js +1 -0
- package/dist/analyzers/base-analyzer.js.map +7 -0
- package/dist/analyzers/call-graph-utils.js +39 -0
- package/dist/analyzers/call-graph-utils.js.map +7 -0
- package/dist/analyzers/cbm-analyzer.js +1205 -0
- package/dist/analyzers/cbm-analyzer.js.map +7 -0
- package/dist/analyzers/heuristic-utils.js +55 -0
- package/dist/analyzers/heuristic-utils.js.map +7 -0
- package/dist/analyzers/mapping-loader.js +146 -0
- package/dist/analyzers/mapping-loader.js.map +7 -0
- package/dist/analyzers/registry.js +124 -0
- package/dist/analyzers/registry.js.map +7 -0
- package/dist/analyzers/session-state.js +176 -0
- package/dist/analyzers/session-state.js.map +7 -0
- package/dist/analyzers/stdio-client.js +208 -0
- package/dist/analyzers/stdio-client.js.map +7 -0
- package/dist/analyzers/types.js +15 -0
- package/dist/analyzers/types.js.map +7 -0
- package/dist/analyzers/verify-engine.js +209 -0
- package/dist/analyzers/verify-engine.js.map +7 -0
- package/dist/analyzers/verify-ignore.js +130 -0
- package/dist/analyzers/verify-ignore.js.map +7 -0
- package/dist/analyzers/version.js +8 -0
- package/dist/analyzers/version.js.map +7 -0
- package/dist/audit/ai/runner.js +41 -0
- package/dist/audit/ai/runner.js.map +7 -0
- package/dist/audit/differential-analyzer.js +183 -0
- package/dist/audit/differential-analyzer.js.map +7 -0
- package/dist/audit/index.js +32 -0
- package/dist/audit/index.js.map +7 -0
- package/dist/audit/nodes/ai/evaluator.js +49 -0
- package/dist/audit/nodes/ai/evaluator.js.map +7 -0
- package/dist/audit/nodes/ai/parser.js +55 -0
- package/dist/audit/nodes/ai/parser.js.map +7 -0
- package/dist/audit/nodes/ai/prompts.js +103 -0
- package/dist/audit/nodes/ai/prompts.js.map +7 -0
- package/dist/audit/nodes/analysis/node-completeness-checker.js +32 -0
- package/dist/audit/nodes/analysis/node-completeness-checker.js.map +7 -0
- package/dist/audit/nodes/analysis/node-definition-analyzer.js +47 -0
- package/dist/audit/nodes/analysis/node-definition-analyzer.js.map +7 -0
- package/dist/audit/nodes/analysis/node-overlap-detector.js +79 -0
- package/dist/audit/nodes/analysis/node-overlap-detector.js.map +7 -0
- package/dist/audit/nodes/model/orchestrator.js +82 -0
- package/dist/audit/nodes/model/orchestrator.js.map +7 -0
- package/dist/audit/nodes/spec/loader.js +116 -0
- package/dist/audit/nodes/spec/loader.js.map +7 -0
- package/dist/audit/nodes/spec/orchestrator.js +68 -0
- package/dist/audit/nodes/spec/orchestrator.js.map +7 -0
- package/dist/audit/nodes/types.js +1 -0
- package/dist/audit/nodes/types.js.map +7 -0
- package/dist/audit/pipeline/index.js +5 -0
- package/dist/audit/pipeline/index.js.map +7 -0
- package/dist/audit/pipeline/pipeline-orchestrator.js +218 -0
- package/dist/audit/pipeline/pipeline-orchestrator.js.map +7 -0
- package/dist/audit/relationships/ai/evaluator.js +235 -0
- package/dist/audit/relationships/ai/evaluator.js.map +7 -0
- package/dist/audit/relationships/ai/parser.js +197 -0
- package/dist/audit/relationships/ai/parser.js.map +7 -0
- package/dist/audit/relationships/ai/prompts.js +274 -0
- package/dist/audit/relationships/ai/prompts.js.map +7 -0
- package/dist/audit/relationships/analysis/balance-assessor.js +115 -0
- package/dist/audit/relationships/analysis/balance-assessor.js.map +7 -0
- package/dist/audit/relationships/analysis/coverage-analyzer.js +99 -0
- package/dist/audit/relationships/analysis/coverage-analyzer.js.map +7 -0
- package/dist/audit/relationships/analysis/duplicate-detector.js +95 -0
- package/dist/audit/relationships/analysis/duplicate-detector.js.map +7 -0
- package/dist/audit/relationships/analysis/gap-analyzer.js +99 -0
- package/dist/audit/relationships/analysis/gap-analyzer.js.map +7 -0
- package/dist/audit/relationships/analysis/layer-templates.js +294 -0
- package/dist/audit/relationships/analysis/layer-templates.js.map +7 -0
- package/dist/audit/relationships/graph/connectivity.js +129 -0
- package/dist/audit/relationships/graph/connectivity.js.map +7 -0
- package/dist/audit/relationships/graph/relationship-graph.js +179 -0
- package/dist/audit/relationships/graph/relationship-graph.js.map +7 -0
- package/dist/audit/relationships/model/balance-assessor.js +49 -0
- package/dist/audit/relationships/model/balance-assessor.js.map +7 -0
- package/dist/audit/relationships/model/coverage-analyzer.js +34 -0
- package/dist/audit/relationships/model/coverage-analyzer.js.map +7 -0
- package/dist/audit/relationships/model/duplicate-detector.js +68 -0
- package/dist/audit/relationships/model/duplicate-detector.js.map +7 -0
- package/dist/audit/relationships/model/gap-analyzer.js +41 -0
- package/dist/audit/relationships/model/gap-analyzer.js.map +7 -0
- package/dist/audit/relationships/model/orchestrator.js +126 -0
- package/dist/audit/relationships/model/orchestrator.js.map +7 -0
- package/dist/audit/relationships/spec/orchestrator.js +157 -0
- package/dist/audit/relationships/spec/orchestrator.js.map +7 -0
- package/dist/audit/reports/index.js +5 -0
- package/dist/audit/reports/index.js.map +7 -0
- package/dist/audit/reports/report-generator.js +118 -0
- package/dist/audit/reports/report-generator.js.map +7 -0
- package/dist/audit/snapshot-storage.js +163 -0
- package/dist/audit/snapshot-storage.js.map +7 -0
- package/dist/audit/types.js +21 -0
- package/dist/audit/types.js.map +7 -0
- package/dist/cli.js +223 -92
- package/dist/cli.js.map +3 -3
- package/dist/coding-agents/agents/claude-code.js +147 -0
- package/dist/coding-agents/agents/claude-code.js.map +7 -0
- package/dist/coding-agents/agents/index.js +5 -0
- package/dist/coding-agents/agents/index.js.map +7 -0
- package/dist/coding-agents/agents/types.js +1 -0
- package/dist/coding-agents/agents/types.js.map +7 -0
- package/dist/coding-agents/base-chat-client.js +45 -0
- package/dist/coding-agents/base-chat-client.js.map +7 -0
- package/dist/coding-agents/chat-utils.js +23 -0
- package/dist/coding-agents/chat-utils.js.map +7 -0
- package/dist/coding-agents/claude-code-client.js +246 -0
- package/dist/coding-agents/claude-code-client.js.map +7 -0
- package/dist/coding-agents/copilot-client.js +209 -0
- package/dist/coding-agents/copilot-client.js.map +7 -0
- package/dist/commands/add.js +95 -33
- package/dist/commands/add.js.map +2 -2
- package/dist/commands/analyzer.js +511 -0
- package/dist/commands/analyzer.js.map +7 -0
- package/dist/commands/audit-diff.js +49 -0
- package/dist/commands/audit-diff.js.map +7 -0
- package/dist/commands/audit-snapshots.js +62 -0
- package/dist/commands/audit-snapshots.js.map +7 -0
- package/dist/commands/audit.js +81 -0
- package/dist/commands/audit.js.map +7 -0
- package/dist/commands/catalog.js +248 -0
- package/dist/commands/catalog.js.map +7 -0
- package/dist/commands/changeset.js +577 -66
- package/dist/commands/changeset.js.map +2 -2
- package/dist/commands/chat.js +106 -83
- package/dist/commands/chat.js.map +2 -2
- package/dist/commands/claude.js +74 -0
- package/dist/commands/claude.js.map +7 -0
- package/dist/commands/conformance.js +71 -68
- package/dist/commands/conformance.js.map +2 -2
- package/dist/commands/copilot.js +75 -0
- package/dist/commands/copilot.js.map +7 -0
- package/dist/commands/delete.js +125 -11
- package/dist/commands/delete.js.map +3 -3
- package/dist/commands/discover-logic.js +44 -0
- package/dist/commands/discover-logic.js.map +7 -0
- package/dist/commands/docs.js +87 -0
- package/dist/commands/docs.js.map +7 -0
- package/dist/commands/element.js +14 -20
- package/dist/commands/element.js.map +2 -2
- package/dist/commands/export.js +13 -3
- package/dist/commands/export.js.map +2 -2
- package/dist/commands/import.js +51 -0
- package/dist/commands/import.js.map +7 -0
- package/dist/commands/info.js +30 -24
- package/dist/commands/info.js.map +2 -2
- package/dist/commands/init.js +27 -11
- package/dist/commands/init.js.map +2 -2
- package/dist/commands/list.js +63 -13
- package/dist/commands/list.js.map +3 -3
- package/dist/commands/relationship.js +225 -37
- package/dist/commands/relationship.js.map +2 -2
- package/dist/commands/report.js +54 -0
- package/dist/commands/report.js.map +7 -0
- package/dist/commands/reports.js +45 -0
- package/dist/commands/reports.js.map +7 -0
- package/dist/commands/schema.js +135 -0
- package/dist/commands/schema.js.map +7 -0
- package/dist/commands/search.js +40 -12
- package/dist/commands/search.js.map +2 -2
- package/dist/commands/show.js +58 -27
- package/dist/commands/show.js.map +2 -2
- package/dist/commands/stats.js +35 -0
- package/dist/commands/stats.js.map +7 -0
- package/dist/commands/trace.js +39 -16
- package/dist/commands/trace.js.map +2 -2
- package/dist/commands/update.js +141 -14
- package/dist/commands/update.js.map +2 -2
- package/dist/commands/upgrade.js +210 -46
- package/dist/commands/upgrade.js.map +3 -3
- package/dist/commands/validate.js +142 -23
- package/dist/commands/validate.js.map +3 -3
- package/dist/commands/version.js +8 -12
- package/dist/commands/version.js.map +2 -2
- package/dist/commands/visualize.js +162 -25
- package/dist/commands/visualize.js.map +2 -2
- package/dist/core/base-snapshot-manager.js +84 -0
- package/dist/core/base-snapshot-manager.js.map +7 -0
- package/dist/core/changeset-exporter.js +305 -0
- package/dist/core/changeset-exporter.js.map +7 -0
- package/dist/core/changeset-validator.js +41 -0
- package/dist/core/changeset-validator.js.map +7 -0
- package/dist/core/changeset.js +88 -173
- package/dist/core/changeset.js.map +2 -2
- package/dist/core/dependency-tracker.js +4 -2
- package/dist/core/dependency-tracker.js.map +2 -2
- package/dist/core/element.js +98 -27
- package/dist/core/element.js.map +2 -2
- package/dist/core/golden-copy-cache.js +290 -0
- package/dist/core/golden-copy-cache.js.map +7 -0
- package/dist/core/graph-model.js +266 -0
- package/dist/core/graph-model.js.map +7 -0
- package/dist/core/layer.js +159 -16
- package/dist/core/layer.js.map +2 -2
- package/dist/core/layers.js +32 -0
- package/dist/core/layers.js.map +7 -0
- package/dist/core/manifest.js +32 -11
- package/dist/core/manifest.js.map +2 -2
- package/dist/core/migration-registry.js +56 -1
- package/dist/core/migration-registry.js.map +2 -2
- package/dist/core/model.js +424 -217
- package/dist/core/model.js.map +3 -3
- package/dist/core/mutation-handler.js +179 -0
- package/dist/core/mutation-handler.js.map +7 -0
- package/dist/core/reference-registry.js +29 -21
- package/dist/core/reference-registry.js.map +2 -2
- package/dist/core/relationship-catalog.js +189 -0
- package/dist/core/relationship-catalog.js.map +7 -0
- package/dist/core/relationship-registry.js.map +2 -2
- package/dist/core/relationships.js.map +1 -1
- package/dist/core/report-data-model.js +285 -0
- package/dist/core/report-data-model.js.map +7 -0
- package/dist/core/spec-data-service.js +185 -0
- package/dist/core/spec-data-service.js.map +7 -0
- package/dist/core/spec-loader-types.js +1 -0
- package/dist/core/spec-loader-types.js.map +7 -0
- package/dist/core/spec-loader.js +234 -0
- package/dist/core/spec-loader.js.map +7 -0
- package/dist/core/staged-changeset-storage.js +282 -0
- package/dist/core/staged-changeset-storage.js.map +7 -0
- package/dist/core/staging-area.js +1002 -0
- package/dist/core/staging-area.js.map +7 -0
- package/dist/core/stats-collector.js +169 -0
- package/dist/core/stats-collector.js.map +7 -0
- package/dist/core/virtual-projection.js +443 -0
- package/dist/core/virtual-projection.js.map +7 -0
- package/dist/export/archimate-exporter.js +99 -60
- package/dist/export/archimate-exporter.js.map +2 -2
- package/dist/export/audit-formatters.js +479 -0
- package/dist/export/audit-formatters.js.map +7 -0
- package/dist/export/diff-formatters.js +99 -0
- package/dist/export/diff-formatters.js.map +7 -0
- package/dist/export/export-manager.js.map +2 -2
- package/dist/export/graphml-exporter.js +44 -27
- package/dist/export/graphml-exporter.js.map +2 -2
- package/dist/export/index.js +4 -0
- package/dist/export/index.js.map +2 -2
- package/dist/export/json-schema-exporter.js +55 -42
- package/dist/export/json-schema-exporter.js.map +2 -2
- package/dist/export/markdown-exporter.js +92 -70
- package/dist/export/markdown-exporter.js.map +2 -2
- package/dist/export/markdown-generator.js +248 -0
- package/dist/export/markdown-generator.js.map +7 -0
- package/dist/export/markdown-utils.js +30 -0
- package/dist/export/markdown-utils.js.map +7 -0
- package/dist/export/mermaid-markdown-exporter.js +37 -0
- package/dist/export/mermaid-markdown-exporter.js.map +7 -0
- package/dist/export/openapi-exporter.js +119 -71
- package/dist/export/openapi-exporter.js.map +2 -2
- package/dist/export/plantuml-exporter.js +104 -39
- package/dist/export/plantuml-exporter.js.map +2 -2
- package/dist/export/report-formatters.js +111 -0
- package/dist/export/report-formatters.js.map +7 -0
- package/dist/export/stats-formatters.js +98 -0
- package/dist/export/stats-formatters.js.map +7 -0
- package/dist/export/types.js +2 -14
- package/dist/export/types.js.map +2 -2
- package/dist/export/verify-formatters.js +153 -0
- package/dist/export/verify-formatters.js.map +7 -0
- package/dist/generated/compiled-validators.js +17 -0
- package/dist/generated/compiled-validators.js.map +7 -0
- package/dist/generated/index.js +31 -0
- package/dist/generated/index.js.map +7 -0
- package/dist/generated/layer-registry.js +190 -0
- package/dist/generated/layer-registry.js.map +7 -0
- package/dist/generated/layer-types.js +7 -0
- package/dist/generated/layer-types.js.map +7 -0
- package/dist/generated/node-types.js +1719 -0
- package/dist/generated/node-types.js.map +7 -0
- package/dist/generated/relationship-index.js +14552 -0
- package/dist/generated/relationship-index.js.map +7 -0
- package/dist/import/archimate-importer.js +166 -0
- package/dist/import/archimate-importer.js.map +7 -0
- package/dist/import/index.js +47 -0
- package/dist/import/index.js.map +7 -0
- package/dist/import/openapi-importer.js +143 -0
- package/dist/import/openapi-importer.js.map +7 -0
- package/dist/import/types.js +1 -0
- package/dist/import/types.js.map +7 -0
- package/dist/integrations/base-manager.js +311 -0
- package/dist/integrations/base-manager.js.map +7 -0
- package/dist/integrations/claude-manager.js +360 -0
- package/dist/integrations/claude-manager.js.map +7 -0
- package/dist/integrations/claude_code/agents/dr-advisor.md +253 -0
- package/dist/integrations/claude_code/agents/dr-architect.md +278 -0
- package/dist/integrations/claude_code/agents/dr-extractor.md +286 -0
- package/dist/integrations/claude_code/commands/dr-changeset.md +657 -0
- package/dist/integrations/claude_code/commands/dr-design.md +373 -0
- package/dist/integrations/claude_code/commands/dr-info.md +132 -0
- package/dist/integrations/claude_code/commands/dr-init.md +251 -0
- package/dist/integrations/claude_code/commands/dr-map.md +936 -0
- package/dist/integrations/claude_code/commands/dr-model.md +493 -0
- package/dist/integrations/claude_code/commands/dr-relate.md +814 -0
- package/dist/integrations/claude_code/commands/dr-sync.md +279 -0
- package/dist/integrations/claude_code/commands/dr-validate.md +654 -0
- package/dist/integrations/claude_code/commands/dr-verify.md +559 -0
- package/dist/integrations/claude_code/docs/END_TO_END_WALKTHROUGH.md +903 -0
- package/dist/integrations/claude_code/docs/QUICK_START.md +271 -0
- package/dist/integrations/claude_code/docs/README.md +347 -0
- package/dist/integrations/claude_code/skills/dr_01_motivation_layer/SKILL.md +550 -0
- package/dist/integrations/claude_code/skills/dr_02_business_layer/SKILL.md +620 -0
- package/dist/integrations/claude_code/skills/dr_03_security_layer/SKILL.md +642 -0
- package/dist/integrations/claude_code/skills/dr_04_application_layer/SKILL.md +911 -0
- package/dist/integrations/claude_code/skills/dr_05_technology_layer/SKILL.md +836 -0
- package/dist/integrations/claude_code/skills/dr_06_api_layer/SKILL.md +933 -0
- package/dist/integrations/claude_code/skills/dr_07_data_model_layer/SKILL.md +210 -0
- package/dist/integrations/claude_code/skills/dr_08_dataset_layer/SKILL.md +319 -0
- package/dist/integrations/claude_code/skills/dr_09_ux_layer/SKILL.md +319 -0
- package/dist/integrations/claude_code/skills/dr_10_navigation_layer/SKILL.md +318 -0
- package/dist/integrations/claude_code/skills/dr_11_apm_layer/SKILL.md +273 -0
- package/dist/integrations/claude_code/skills/dr_12_testing_layer/SKILL.md +273 -0
- package/dist/integrations/claude_code/skills/dr_changeset_reviewer/SKILL.md +187 -0
- package/dist/integrations/claude_code/skills/dr_codebase_memory/SKILL.md +590 -0
- package/dist/integrations/claude_code/skills/dr_engineering_guide/SKILL.md +295 -0
- package/dist/integrations/copilot-manager.js +328 -0
- package/dist/integrations/copilot-manager.js.map +7 -0
- package/dist/integrations/github_copilot/agents/dr-advisor.md +243 -0
- package/dist/integrations/github_copilot/agents/dr-architect.md +1567 -0
- package/dist/integrations/github_copilot/skills/dr_01_motivation_layer/SKILL.md +491 -0
- package/dist/integrations/github_copilot/skills/dr_02_business_layer/SKILL.md +539 -0
- package/dist/integrations/github_copilot/skills/dr_03_security_layer/SKILL.md +667 -0
- package/dist/integrations/github_copilot/skills/dr_04_application_layer/SKILL.md +670 -0
- package/dist/integrations/github_copilot/skills/dr_05_technology_layer/SKILL.md +660 -0
- package/dist/integrations/github_copilot/skills/dr_06_api_layer/SKILL.md +855 -0
- package/dist/integrations/github_copilot/skills/dr_07_data_model_layer/SKILL.md +171 -0
- package/dist/integrations/github_copilot/skills/dr_08_dataset_layer/SKILL.md +216 -0
- package/dist/integrations/github_copilot/skills/dr_09_ux_layer/SKILL.md +230 -0
- package/dist/integrations/github_copilot/skills/dr_10_navigation_layer/SKILL.md +228 -0
- package/dist/integrations/github_copilot/skills/dr_11_apm_layer/SKILL.md +234 -0
- package/dist/integrations/github_copilot/skills/dr_12_testing_layer/SKILL.md +230 -0
- package/dist/integrations/github_copilot/skills/dr_changeset_reviewer/SKILL.md +187 -0
- package/dist/integrations/hash-utils.js +51 -0
- package/dist/integrations/hash-utils.js.map +7 -0
- package/dist/integrations/types.js +16 -0
- package/dist/integrations/types.js.map +7 -0
- package/dist/reports/model-layer-report-generator.js +278 -0
- package/dist/reports/model-layer-report-generator.js.map +7 -0
- package/dist/reports/model-report-data.js +57 -0
- package/dist/reports/model-report-data.js.map +7 -0
- package/dist/reports/model-report-orchestrator.js +103 -0
- package/dist/reports/model-report-orchestrator.js.map +7 -0
- package/dist/schemas/bundled/analyzers/cbm.json +595 -0
- package/dist/schemas/bundled/analyzers/manifest.json +9 -0
- package/dist/schemas/bundled/api.json +3411 -0
- package/dist/schemas/bundled/apm.json +2371 -0
- package/dist/schemas/bundled/application.json +1253 -0
- package/dist/schemas/bundled/base.json +1622 -0
- package/dist/schemas/bundled/business.json +1279 -0
- package/dist/schemas/bundled/data-model.json +1298 -0
- package/dist/schemas/bundled/data-store.json +2025 -0
- package/dist/schemas/bundled/manifest.json +93 -0
- package/dist/schemas/bundled/motivation.json +1360 -0
- package/dist/schemas/bundled/navigation.json +1874 -0
- package/dist/schemas/bundled/security.json +3488 -0
- package/dist/schemas/bundled/technology.json +2067 -0
- package/dist/schemas/bundled/testing.json +3120 -0
- package/dist/schemas/bundled/ux.json +3592 -0
- package/dist/server/schemas.js +202 -0
- package/dist/server/schemas.js.map +7 -0
- package/dist/server/server.js +1336 -252
- package/dist/server/server.js.map +3 -3
- package/dist/server/telemetry-middleware.js +22 -15
- package/dist/server/telemetry-middleware.js.map +2 -2
- package/dist/server-entry.js +65 -0
- package/dist/server-entry.js.map +7 -0
- package/dist/telemetry/config.js +89 -0
- package/dist/telemetry/config.js.map +7 -0
- package/dist/telemetry/console-interceptor.js.map +1 -1
- package/dist/telemetry/detect.js +24 -0
- package/dist/telemetry/detect.js.map +7 -0
- package/dist/telemetry/fetch-otlp-exporter.js +112 -0
- package/dist/telemetry/fetch-otlp-exporter.js.map +7 -0
- package/dist/telemetry/index.js +153 -3
- package/dist/telemetry/index.js.map +2 -2
- package/dist/telemetry/resilient-exporter.js +22 -8
- package/dist/telemetry/resilient-exporter.js.map +2 -2
- package/dist/telemetry/resilient-log-exporter.js +17 -8
- package/dist/telemetry/resilient-log-exporter.js.map +2 -2
- package/dist/telemetry/test-instrumentation.js.map +2 -2
- package/dist/types/index.js +84 -0
- package/dist/types/index.js.map +3 -3
- package/dist/types/source-reference.js +1 -0
- package/dist/types/source-reference.js.map +7 -0
- package/dist/utils/chat-logger.js +292 -0
- package/dist/utils/chat-logger.js.map +7 -0
- package/dist/utils/claude-stream.js +8 -0
- package/dist/utils/claude-stream.js.map +7 -0
- package/dist/utils/date-utils.js +7 -0
- package/dist/utils/date-utils.js.map +7 -0
- package/dist/utils/element-utils.js.map +1 -1
- package/dist/utils/errors.js +88 -15
- package/dist/utils/errors.js.map +3 -3
- package/dist/utils/export-python-annotations.js +82 -0
- package/dist/utils/export-python-annotations.js.map +7 -0
- package/dist/utils/file-io.js +7 -2
- package/dist/utils/file-io.js.map +2 -2
- package/dist/utils/file-lock.js +156 -0
- package/dist/utils/file-lock.js.map +7 -0
- package/dist/utils/id-generator.js +18 -0
- package/dist/utils/id-generator.js.map +7 -0
- package/dist/utils/layer-name-formatter.js +16 -0
- package/dist/utils/layer-name-formatter.js.map +7 -0
- package/dist/utils/markdown-anchor.js +7 -0
- package/dist/utils/markdown-anchor.js.map +7 -0
- package/dist/utils/markdown-link.js +12 -0
- package/dist/utils/markdown-link.js.map +7 -0
- package/dist/utils/markdown-table.js +17 -0
- package/dist/utils/markdown-table.js.map +7 -0
- package/dist/utils/mermaid-utils.js +11 -0
- package/dist/utils/mermaid-utils.js.map +7 -0
- package/dist/utils/project-paths.js.map +2 -2
- package/dist/utils/source-reference.js +52 -0
- package/dist/utils/source-reference.js.map +7 -0
- package/dist/utils/spec-installer.js +40 -53
- package/dist/utils/spec-installer.js.map +2 -2
- package/dist/utils/spec-version.js +5 -1
- package/dist/utils/spec-version.js.map +2 -2
- package/dist/utils/string-utils.js +12 -0
- package/dist/utils/string-utils.js.map +7 -0
- package/dist/utils/table-formatting.js +19 -0
- package/dist/utils/table-formatting.js.map +7 -0
- package/dist/validators/index.js +4 -0
- package/dist/validators/index.js.map +2 -2
- package/dist/validators/naming-validator.js +20 -23
- package/dist/validators/naming-validator.js.map +2 -2
- package/dist/validators/reference-validator.js +23 -38
- package/dist/validators/reference-validator.js.map +2 -2
- package/dist/validators/relationship-schema-validator.js +243 -0
- package/dist/validators/relationship-schema-validator.js.map +7 -0
- package/dist/validators/schema-validator.js +168 -68
- package/dist/validators/schema-validator.js.map +2 -2
- package/dist/validators/semantic-validator.js +36 -60
- package/dist/validators/semantic-validator.js.map +2 -2
- package/dist/validators/types.js.map +2 -2
- package/dist/validators/validation-formatter.js +159 -0
- package/dist/validators/validation-formatter.js.map +7 -0
- package/dist/validators/validator.js +24 -38
- package/dist/validators/validator.js.map +2 -2
- package/dist/viewer/README.md +139 -0
- package/dist/viewer/assets/main-CY0Xufuj.css +1 -0
- package/dist/viewer/assets/main-DtgErnwF.js +81 -0
- package/dist/viewer/assets/vendor-CxKvDp2x.js +17 -0
- package/dist/viewer/favicon.svg +11 -0
- package/dist/viewer/fonts/inter/Inter-Black.woff2 +0 -0
- package/dist/viewer/fonts/inter/Inter-Bold.woff2 +0 -0
- package/dist/viewer/fonts/inter/Inter-ExtraBold.woff2 +0 -0
- package/dist/viewer/fonts/inter/Inter-Light.woff2 +0 -0
- package/dist/viewer/fonts/inter/Inter-Medium.woff2 +0 -0
- package/dist/viewer/fonts/inter/Inter-Regular.woff2 +0 -0
- package/dist/viewer/fonts/inter/Inter-SemiBold.woff2 +0 -0
- package/dist/viewer/fonts/jetbrains-mono/JetBrainsMono-Medium.woff2 +0 -0
- package/dist/viewer/fonts/jetbrains-mono/JetBrainsMono-Regular.woff2 +0 -0
- package/dist/viewer/fonts/jetbrains-mono/JetBrainsMono-SemiBold.woff2 +0 -0
- package/dist/viewer/index.html +15 -0
- package/dist/viewer/manifest.json +99 -0
- package/dist/viewer/version.json +1 -0
- package/package.json +42 -16
- package/PYTHON_CLI_PARITY.md +0 -265
- package/PYTHON_CLI_STRUCTURE_UPDATE.md +0 -246
- package/biome.json +0 -42
- package/bunfig.toml +0 -3
- package/dist/ai/claude-client.js +0 -71
- package/dist/ai/claude-client.js.map +0 -7
- package/dist/ai/context-provider.js +0 -129
- package/dist/ai/context-provider.js.map +0 -7
- package/dist/ai/tools.js +0 -231
- package/dist/ai/tools.js.map +0 -7
- package/dist/commands/migrate.js +0 -36
- package/dist/commands/migrate.js.map +0 -7
- package/dist/commands/project.js +0 -74
- package/dist/commands/project.js.map +0 -7
- package/dist/core/active-changeset.js +0 -52
- package/dist/core/active-changeset.js.map +0 -7
- package/dist/core/projection-engine.js +0 -288
- package/dist/core/projection-engine.js.map +0 -7
- package/dist/schemas/bundled/01-motivation-layer.schema.json +0 -942
- package/dist/schemas/bundled/02-business-layer.schema.json +0 -1293
- package/dist/schemas/bundled/03-security-layer.schema.json +0 -2177
- package/dist/schemas/bundled/04-application-layer.schema.json +0 -1328
- package/dist/schemas/bundled/05-technology-layer.schema.json +0 -1465
- package/dist/schemas/bundled/06-api-layer.schema.json +0 -1743
- package/dist/schemas/bundled/07-data-model-layer.schema.json +0 -1253
- package/dist/schemas/bundled/08-datastore-layer.schema.json +0 -892
- package/dist/schemas/bundled/09-ux-layer.schema.json +0 -1506
- package/dist/schemas/bundled/10-navigation-layer.schema.json +0 -843
- package/dist/schemas/bundled/11-apm-observability-layer.schema.json +0 -1430
- package/dist/schemas/bundled/12-testing-layer.schema.json +0 -1091
- package/dist/schemas/bundled/common/layer-extensions.schema.json +0 -266
- package/dist/schemas/bundled/common/predicates.schema.json +0 -493
- package/dist/schemas/bundled/common/relationships.schema.json +0 -791
- package/dist/schemas/bundled/common/source-references.schema.json +0 -71
- package/dist/schemas/bundled/link-registry.json +0 -1839
- package/dist/schemas/bundled/link-registry.schema.json +0 -339
- package/dist/schemas/bundled/relationship-catalog.json +0 -1302
- package/dist/schemas/bundled/relationship-type.schema.json +0 -221
- package/dist/utils/model-path.js +0 -22
- package/dist/utils/model-path.js.map +0 -7
- package/docs/TEST-INSTRUMENTATION.md +0 -405
- package/docs/telemetry.md +0 -427
- package/test-debug.js +0 -33
- package/test-special.mjs +0 -46
- package/test_runner.ts +0 -7
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { recommendationImpactScore } from "../../types.js";
|
|
2
|
+
import { getErrorMessage } from "../../../utils/errors.js";
|
|
3
|
+
class ResponseParser {
|
|
4
|
+
/**
|
|
5
|
+
* Parse element evaluation recommendations from Claude response
|
|
6
|
+
*/
|
|
7
|
+
parseElementRecommendations(response) {
|
|
8
|
+
const jsonMatch = response.match(/```json\n([\s\S]*?)\n```/) || response.match(/\[[\s\S]*\]/);
|
|
9
|
+
if (!jsonMatch) {
|
|
10
|
+
const truncated = response.substring(0, 200);
|
|
11
|
+
throw new Error(`Failed to extract JSON from AI response. Expected JSON array in code block or raw JSON array.
|
|
12
|
+
Received: ${truncated}${response.length > 200 ? "..." : ""}`);
|
|
13
|
+
}
|
|
14
|
+
const jsonString = jsonMatch[1] || jsonMatch[0];
|
|
15
|
+
let recommendations;
|
|
16
|
+
try {
|
|
17
|
+
recommendations = JSON.parse(jsonString);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
const truncated = jsonString.substring(0, 200);
|
|
20
|
+
throw new Error(`Failed to parse JSON from AI response: ${getErrorMessage(error)}
|
|
21
|
+
Received: ${truncated}${jsonString.length > 200 ? "..." : ""}`);
|
|
22
|
+
}
|
|
23
|
+
if (!Array.isArray(recommendations))
|
|
24
|
+
throw new Error("Expected JSON array of recommendations from AI response");
|
|
25
|
+
return recommendations.map((r, index) => {
|
|
26
|
+
if (typeof r != "object" || r === null)
|
|
27
|
+
throw new Error(`Recommendation at index ${index} is not a valid object`);
|
|
28
|
+
const rec = r;
|
|
29
|
+
if (!rec.predicate || typeof rec.predicate != "string")
|
|
30
|
+
throw new Error(`Recommendation at index ${index} missing or invalid required field: predicate (must be string)`);
|
|
31
|
+
const sourceNodeType = rec.sourceNodeType || rec.source;
|
|
32
|
+
if (!sourceNodeType || typeof sourceNodeType != "string")
|
|
33
|
+
throw new Error(`Recommendation at index ${index} missing or invalid required field: sourceNodeType or source (must be string)`);
|
|
34
|
+
const destinationNodeType = rec.destinationNodeType || rec.destination;
|
|
35
|
+
if (!destinationNodeType || typeof destinationNodeType != "string")
|
|
36
|
+
throw new Error(`Recommendation at index ${index} missing or invalid required field: destinationNodeType or destination (must be string)`);
|
|
37
|
+
const justification = rec.justification || rec.reason;
|
|
38
|
+
if (!justification || typeof justification != "string")
|
|
39
|
+
throw new Error(`Recommendation at index ${index} missing or invalid required field: justification or reason (must be string)`);
|
|
40
|
+
const priority = rec.priority;
|
|
41
|
+
if (priority && typeof priority != "string")
|
|
42
|
+
throw new Error(`Recommendation at index ${index} has invalid priority field (must be string)`);
|
|
43
|
+
const standardReference = rec.standardReference;
|
|
44
|
+
if (standardReference !== void 0 && typeof standardReference != "string")
|
|
45
|
+
throw new Error(`Recommendation at index ${index} has invalid standardReference field (must be string)`);
|
|
46
|
+
const resolvedPriority = priority || "medium", impactScore = recommendationImpactScore(resolvedPriority);
|
|
47
|
+
return {
|
|
48
|
+
sourceNodeType,
|
|
49
|
+
predicate: rec.predicate,
|
|
50
|
+
destinationNodeType,
|
|
51
|
+
justification,
|
|
52
|
+
priority: resolvedPriority,
|
|
53
|
+
standardReference: typeof standardReference == "string" ? standardReference : void 0,
|
|
54
|
+
impactScore,
|
|
55
|
+
alignmentScore: 100 - impactScore
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Parse layer review from Claude response
|
|
61
|
+
*/
|
|
62
|
+
parseLayerReview(response) {
|
|
63
|
+
const jsonMatch = response.match(/```json\n([\s\S]*?)\n```/) || response.match(/\{[\s\S]*\}/);
|
|
64
|
+
if (!jsonMatch) {
|
|
65
|
+
const truncated = response.substring(0, 200);
|
|
66
|
+
throw new Error(`Failed to extract JSON from layer review. Expected JSON object in code block or raw JSON object.
|
|
67
|
+
Received: ${truncated}${response.length > 200 ? "..." : ""}`);
|
|
68
|
+
}
|
|
69
|
+
const jsonString = jsonMatch[1] || jsonMatch[0];
|
|
70
|
+
let review;
|
|
71
|
+
try {
|
|
72
|
+
review = JSON.parse(jsonString);
|
|
73
|
+
} catch (error) {
|
|
74
|
+
const truncated = jsonString.substring(0, 200);
|
|
75
|
+
throw new Error(`Failed to parse JSON from layer review: ${getErrorMessage(error)}
|
|
76
|
+
Received: ${truncated}${jsonString.length > 200 ? "..." : ""}`);
|
|
77
|
+
}
|
|
78
|
+
if (typeof review != "object" || review === null)
|
|
79
|
+
throw new Error("Layer review response is not a valid object");
|
|
80
|
+
const reviewObj = review, coherenceIssues = reviewObj.coherenceIssues || reviewObj.coherence_issues;
|
|
81
|
+
if (!coherenceIssues || !Array.isArray(coherenceIssues))
|
|
82
|
+
throw new Error("Layer review missing or invalid required field: coherenceIssues (must be array)");
|
|
83
|
+
if (!coherenceIssues.every((item) => typeof item == "string"))
|
|
84
|
+
throw new Error("Layer review coherenceIssues must contain only strings");
|
|
85
|
+
const missingPatterns = reviewObj.missingPatterns || reviewObj.missing_patterns;
|
|
86
|
+
if (!missingPatterns || !Array.isArray(missingPatterns))
|
|
87
|
+
throw new Error("Layer review missing or invalid required field: missingPatterns (must be array)");
|
|
88
|
+
if (!missingPatterns.every((item) => typeof item == "string"))
|
|
89
|
+
throw new Error("Layer review missingPatterns must contain only strings");
|
|
90
|
+
const recommendations = reviewObj.recommendations;
|
|
91
|
+
if (!recommendations || !Array.isArray(recommendations))
|
|
92
|
+
throw new Error("Layer review missing or invalid required field: recommendations (must be array)");
|
|
93
|
+
const validatedRecommendations = recommendations.map((r, index) => {
|
|
94
|
+
if (typeof r != "object" || r === null)
|
|
95
|
+
throw new Error(`Recommendation at index ${index} in layer review is not a valid object`);
|
|
96
|
+
const rec = r;
|
|
97
|
+
if (!rec.predicate || typeof rec.predicate != "string")
|
|
98
|
+
throw new Error(`Recommendation at index ${index} in layer review missing or invalid required field: predicate (must be string)`);
|
|
99
|
+
const sourceNodeType = rec.sourceNodeType || rec.source;
|
|
100
|
+
if (!sourceNodeType || typeof sourceNodeType != "string")
|
|
101
|
+
throw new Error(`Recommendation at index ${index} in layer review missing or invalid required field: sourceNodeType or source (must be string)`);
|
|
102
|
+
const destinationNodeType = rec.destinationNodeType || rec.destination;
|
|
103
|
+
if (!destinationNodeType || typeof destinationNodeType != "string")
|
|
104
|
+
throw new Error(`Recommendation at index ${index} in layer review missing or invalid required field: destinationNodeType or destination (must be string)`);
|
|
105
|
+
const justification = rec.justification || rec.reason;
|
|
106
|
+
if (!justification || typeof justification != "string")
|
|
107
|
+
throw new Error(`Recommendation at index ${index} in layer review missing or invalid required field: justification or reason (must be string)`);
|
|
108
|
+
const priority = rec.priority;
|
|
109
|
+
if (priority && typeof priority != "string")
|
|
110
|
+
throw new Error(`Recommendation at index ${index} in layer review has invalid priority field (must be string)`);
|
|
111
|
+
const standardReference = rec.standardReference;
|
|
112
|
+
if (standardReference !== void 0 && typeof standardReference != "string")
|
|
113
|
+
throw new Error(`Recommendation at index ${index} in layer review has invalid standardReference field (must be string)`);
|
|
114
|
+
const resolvedPriority = priority || "medium", impactScore = recommendationImpactScore(resolvedPriority);
|
|
115
|
+
return {
|
|
116
|
+
sourceNodeType,
|
|
117
|
+
predicate: rec.predicate,
|
|
118
|
+
destinationNodeType,
|
|
119
|
+
justification,
|
|
120
|
+
priority: resolvedPriority,
|
|
121
|
+
standardReference: typeof standardReference == "string" ? standardReference : void 0,
|
|
122
|
+
impactScore,
|
|
123
|
+
alignmentScore: 100 - impactScore
|
|
124
|
+
};
|
|
125
|
+
}), balanceAssessment = reviewObj.balanceAssessment || reviewObj.balance_assessment;
|
|
126
|
+
if (!balanceAssessment || typeof balanceAssessment != "string")
|
|
127
|
+
throw new Error("Layer review missing or invalid required field: balanceAssessment (must be string)");
|
|
128
|
+
return {
|
|
129
|
+
coherenceIssues,
|
|
130
|
+
missingPatterns,
|
|
131
|
+
recommendations: validatedRecommendations,
|
|
132
|
+
balanceAssessment
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Parse inter-layer validation from Claude response
|
|
137
|
+
*/
|
|
138
|
+
parseInterLayerValidation(response) {
|
|
139
|
+
const jsonMatch = response.match(/```json\n([\s\S]*?)\n```/) || response.match(/\{[\s\S]*\}/);
|
|
140
|
+
if (!jsonMatch) {
|
|
141
|
+
const truncated = response.substring(0, 200);
|
|
142
|
+
throw new Error(`Failed to extract JSON from inter-layer validation. Expected JSON object in code block or raw JSON object.
|
|
143
|
+
Received: ${truncated}${response.length > 200 ? "..." : ""}`);
|
|
144
|
+
}
|
|
145
|
+
const jsonString = jsonMatch[1] || jsonMatch[0];
|
|
146
|
+
let validation;
|
|
147
|
+
try {
|
|
148
|
+
validation = JSON.parse(jsonString);
|
|
149
|
+
} catch (error) {
|
|
150
|
+
const truncated = jsonString.substring(0, 200);
|
|
151
|
+
throw new Error(`Failed to parse JSON from inter-layer validation: ${getErrorMessage(error)}
|
|
152
|
+
Received: ${truncated}${jsonString.length > 200 ? "..." : ""}`);
|
|
153
|
+
}
|
|
154
|
+
if (typeof validation != "object" || validation === null)
|
|
155
|
+
throw new Error("Inter-layer validation response is not a valid object");
|
|
156
|
+
const validationObj = validation, violations = validationObj.violations || validationObj.hierarchy_violations || validationObj.cross_layer_violations || validationObj.layer_violations;
|
|
157
|
+
if (!violations || !Array.isArray(violations))
|
|
158
|
+
throw new Error("Inter-layer validation missing or invalid required field: violations (must be array)");
|
|
159
|
+
const validatedViolations = violations.map((v, index) => {
|
|
160
|
+
if (typeof v != "object" || v === null)
|
|
161
|
+
throw new Error(`Violation at index ${index} is not a valid object`);
|
|
162
|
+
const violation = v, rawSource = violation.source, sourceLayer = violation.sourceLayer || (typeof rawSource == "object" && rawSource !== null ? rawSource.layer : void 0) || violation.source_layer || violation.from;
|
|
163
|
+
if (!sourceLayer || typeof sourceLayer != "string")
|
|
164
|
+
throw new Error(`Violation at index ${index} missing or invalid field: sourceLayer (must be string)`);
|
|
165
|
+
const rawDest = violation.destination, targetLayer = violation.targetLayer || (typeof rawDest == "object" && rawDest !== null ? rawDest.layer : void 0) || violation.target_layer || violation.to;
|
|
166
|
+
if (!targetLayer || typeof targetLayer != "string")
|
|
167
|
+
throw new Error(`Violation at index ${index} missing or invalid field: targetLayer (must be string)`);
|
|
168
|
+
const issue = violation.issue || violation.violation || violation.description || violation.message || violation.problem;
|
|
169
|
+
if (!issue || typeof issue != "string")
|
|
170
|
+
throw new Error(`Violation at index ${index} missing or invalid field: issue (must be string)`);
|
|
171
|
+
return {
|
|
172
|
+
sourceLayer,
|
|
173
|
+
targetLayer,
|
|
174
|
+
issue
|
|
175
|
+
};
|
|
176
|
+
}), rawRecs = validationObj.recommendations;
|
|
177
|
+
if (!rawRecs || !Array.isArray(rawRecs))
|
|
178
|
+
throw new Error("Inter-layer validation missing or invalid required field: recommendations (must be array)");
|
|
179
|
+
const recommendations = rawRecs.map((r) => {
|
|
180
|
+
if (typeof r == "string")
|
|
181
|
+
return r;
|
|
182
|
+
if (typeof r == "object" && r !== null) {
|
|
183
|
+
const obj = r;
|
|
184
|
+
return String(obj.action || obj.description || JSON.stringify(r));
|
|
185
|
+
}
|
|
186
|
+
return String(r);
|
|
187
|
+
});
|
|
188
|
+
return {
|
|
189
|
+
violations: validatedViolations,
|
|
190
|
+
recommendations
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
export {
|
|
195
|
+
ResponseParser
|
|
196
|
+
};
|
|
197
|
+
//# sourceMappingURL=parser.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/audit/relationships/ai/parser.ts"],
|
|
4
|
+
"sourcesContent": ["import { recommendationImpactScore } from \"../../types.js\";\nimport { getErrorMessage } from \"../../../utils/errors.js\";\n\nexport interface RelationshipRecommendation {\n sourceNodeType: string;\n predicate: string;\n destinationNodeType: string;\n justification: string;\n priority: \"high\" | \"medium\" | \"low\";\n standardReference?: string;\n /** How necessary this recommendation is (0\u2013100). Derived from priority. */\n impactScore: number;\n /** 100 - impactScore; aligns with NodeAIEvaluation.alignmentScore semantics */\n alignmentScore: number;\n}\n\nexport interface LayerReview {\n coherenceIssues: string[];\n missingPatterns: string[];\n recommendations: RelationshipRecommendation[];\n balanceAssessment: string;\n}\n\nexport interface InterLayerValidation {\n violations: Array<{\n sourceLayer: string;\n targetLayer: string;\n issue: string;\n }>;\n recommendations: string[];\n}\n\nexport class ResponseParser {\n /**\n * Parse element evaluation recommendations from Claude response\n */\n parseElementRecommendations(response: string): RelationshipRecommendation[] {\n // Extract JSON from Claude response\n const jsonMatch =\n response.match(/```json\\n([\\s\\S]*?)\\n```/) || response.match(/\\[[\\s\\S]*\\]/);\n\n if (!jsonMatch) {\n const truncated = response.substring(0, 200);\n throw new Error(\n `Failed to extract JSON from AI response. Expected JSON array in code block or raw JSON array.\\nReceived: ${truncated}${response.length > 200 ? \"...\" : \"\"}`\n );\n }\n\n const jsonString = jsonMatch[1] || jsonMatch[0];\n let recommendations: unknown;\n\n try {\n recommendations = JSON.parse(jsonString);\n } catch (error: unknown) {\n const truncated = jsonString.substring(0, 200);\n throw new Error(\n `Failed to parse JSON from AI response: ${getErrorMessage(error)}\\nReceived: ${truncated}${jsonString.length > 200 ? \"...\" : \"\"}`\n );\n }\n\n if (!Array.isArray(recommendations)) {\n throw new Error(\"Expected JSON array of recommendations from AI response\");\n }\n\n // Validate structure and normalize field names\n return recommendations.map((r: unknown, index: number) => {\n // Type narrowing: ensure r is an object\n if (typeof r !== \"object\" || r === null) {\n throw new Error(`Recommendation at index ${index} is not a valid object`);\n }\n\n const rec = r as Record<string, unknown>;\n\n // Validate and extract required fields with type guards\n if (!rec.predicate || typeof rec.predicate !== \"string\") {\n throw new Error(\n `Recommendation at index ${index} missing or invalid required field: predicate (must be string)`\n );\n }\n\n const sourceNodeType = rec.sourceNodeType || rec.source;\n if (!sourceNodeType || typeof sourceNodeType !== \"string\") {\n throw new Error(\n `Recommendation at index ${index} missing or invalid required field: sourceNodeType or source (must be string)`\n );\n }\n\n const destinationNodeType = rec.destinationNodeType || rec.destination;\n if (!destinationNodeType || typeof destinationNodeType !== \"string\") {\n throw new Error(\n `Recommendation at index ${index} missing or invalid required field: destinationNodeType or destination (must be string)`\n );\n }\n\n const justification = rec.justification || rec.reason;\n if (!justification || typeof justification !== \"string\") {\n throw new Error(\n `Recommendation at index ${index} missing or invalid required field: justification or reason (must be string)`\n );\n }\n\n const priority = rec.priority;\n if (priority && typeof priority !== \"string\") {\n throw new Error(\n `Recommendation at index ${index} has invalid priority field (must be string)`\n );\n }\n\n const standardReference = rec.standardReference;\n if (standardReference !== undefined && typeof standardReference !== \"string\") {\n throw new Error(\n `Recommendation at index ${index} has invalid standardReference field (must be string)`\n );\n }\n\n const resolvedPriority = (priority as \"high\" | \"medium\" | \"low\") || \"medium\";\n const impactScore = recommendationImpactScore(resolvedPriority);\n return {\n sourceNodeType,\n predicate: rec.predicate,\n destinationNodeType,\n justification,\n priority: resolvedPriority,\n standardReference: typeof standardReference === \"string\" ? standardReference : undefined,\n impactScore,\n alignmentScore: 100 - impactScore,\n };\n });\n }\n\n /**\n * Parse layer review from Claude response\n */\n parseLayerReview(response: string): LayerReview {\n const jsonMatch =\n response.match(/```json\\n([\\s\\S]*?)\\n```/) || response.match(/\\{[\\s\\S]*\\}/);\n\n if (!jsonMatch) {\n const truncated = response.substring(0, 200);\n throw new Error(\n `Failed to extract JSON from layer review. Expected JSON object in code block or raw JSON object.\\nReceived: ${truncated}${response.length > 200 ? \"...\" : \"\"}`\n );\n }\n\n const jsonString = jsonMatch[1] || jsonMatch[0];\n let review: unknown;\n\n try {\n review = JSON.parse(jsonString);\n } catch (error: unknown) {\n const truncated = jsonString.substring(0, 200);\n throw new Error(\n `Failed to parse JSON from layer review: ${getErrorMessage(error)}\\nReceived: ${truncated}${jsonString.length > 200 ? \"...\" : \"\"}`\n );\n }\n\n // Type narrowing: ensure review is an object\n if (typeof review !== \"object\" || review === null) {\n throw new Error(\"Layer review response is not a valid object\");\n }\n\n const reviewObj = review as Record<string, unknown>;\n\n // Validate and extract required fields with type guards\n const coherenceIssues = reviewObj.coherenceIssues || reviewObj.coherence_issues;\n if (!coherenceIssues || !Array.isArray(coherenceIssues)) {\n throw new Error(\"Layer review missing or invalid required field: coherenceIssues (must be array)\");\n }\n if (!coherenceIssues.every((item) => typeof item === \"string\")) {\n throw new Error(\"Layer review coherenceIssues must contain only strings\");\n }\n\n const missingPatterns = reviewObj.missingPatterns || reviewObj.missing_patterns;\n if (!missingPatterns || !Array.isArray(missingPatterns)) {\n throw new Error(\"Layer review missing or invalid required field: missingPatterns (must be array)\");\n }\n if (!missingPatterns.every((item) => typeof item === \"string\")) {\n throw new Error(\"Layer review missingPatterns must contain only strings\");\n }\n\n const recommendations = reviewObj.recommendations;\n if (!recommendations || !Array.isArray(recommendations)) {\n throw new Error(\"Layer review missing or invalid required field: recommendations (must be array)\");\n }\n\n // Validate each recommendation in the array with per-element structural validation\n const validatedRecommendations = recommendations.map((r: unknown, index: number) => {\n // Type narrowing: ensure r is an object\n if (typeof r !== \"object\" || r === null) {\n throw new Error(`Recommendation at index ${index} in layer review is not a valid object`);\n }\n\n const rec = r as Record<string, unknown>;\n\n // Validate and extract required fields with type guards (matching parseElementRecommendations)\n if (!rec.predicate || typeof rec.predicate !== \"string\") {\n throw new Error(\n `Recommendation at index ${index} in layer review missing or invalid required field: predicate (must be string)`\n );\n }\n\n const sourceNodeType = rec.sourceNodeType || rec.source;\n if (!sourceNodeType || typeof sourceNodeType !== \"string\") {\n throw new Error(\n `Recommendation at index ${index} in layer review missing or invalid required field: sourceNodeType or source (must be string)`\n );\n }\n\n const destinationNodeType = rec.destinationNodeType || rec.destination;\n if (!destinationNodeType || typeof destinationNodeType !== \"string\") {\n throw new Error(\n `Recommendation at index ${index} in layer review missing or invalid required field: destinationNodeType or destination (must be string)`\n );\n }\n\n const justification = rec.justification || rec.reason;\n if (!justification || typeof justification !== \"string\") {\n throw new Error(\n `Recommendation at index ${index} in layer review missing or invalid required field: justification or reason (must be string)`\n );\n }\n\n const priority = rec.priority;\n if (priority && typeof priority !== \"string\") {\n throw new Error(\n `Recommendation at index ${index} in layer review has invalid priority field (must be string)`\n );\n }\n\n const standardReference = rec.standardReference;\n if (standardReference !== undefined && typeof standardReference !== \"string\") {\n throw new Error(\n `Recommendation at index ${index} in layer review has invalid standardReference field (must be string)`\n );\n }\n\n const resolvedPriority = (priority as \"high\" | \"medium\" | \"low\") || \"medium\";\n const impactScore = recommendationImpactScore(resolvedPriority);\n return {\n sourceNodeType,\n predicate: rec.predicate,\n destinationNodeType,\n justification,\n priority: resolvedPriority,\n standardReference: typeof standardReference === \"string\" ? standardReference : undefined,\n impactScore,\n alignmentScore: 100 - impactScore,\n };\n });\n\n const balanceAssessment = reviewObj.balanceAssessment || reviewObj.balance_assessment;\n if (!balanceAssessment || typeof balanceAssessment !== \"string\") {\n throw new Error(\"Layer review missing or invalid required field: balanceAssessment (must be string)\");\n }\n\n return {\n coherenceIssues,\n missingPatterns,\n recommendations: validatedRecommendations,\n balanceAssessment,\n };\n }\n\n /**\n * Parse inter-layer validation from Claude response\n */\n parseInterLayerValidation(response: string): InterLayerValidation {\n const jsonMatch =\n response.match(/```json\\n([\\s\\S]*?)\\n```/) || response.match(/\\{[\\s\\S]*\\}/);\n\n if (!jsonMatch) {\n const truncated = response.substring(0, 200);\n throw new Error(\n `Failed to extract JSON from inter-layer validation. Expected JSON object in code block or raw JSON object.\\nReceived: ${truncated}${response.length > 200 ? \"...\" : \"\"}`\n );\n }\n\n const jsonString = jsonMatch[1] || jsonMatch[0];\n let validation: unknown;\n\n try {\n validation = JSON.parse(jsonString);\n } catch (error: unknown) {\n const truncated = jsonString.substring(0, 200);\n throw new Error(\n `Failed to parse JSON from inter-layer validation: ${getErrorMessage(error)}\\nReceived: ${truncated}${jsonString.length > 200 ? \"...\" : \"\"}`\n );\n }\n\n // Type narrowing: ensure validation is an object\n if (typeof validation !== \"object\" || validation === null) {\n throw new Error(\"Inter-layer validation response is not a valid object\");\n }\n\n const validationObj = validation as Record<string, unknown>;\n\n // Normalize top-level violations key (Claude may use alternate key names)\n const violations =\n validationObj.violations ||\n validationObj.hierarchy_violations ||\n validationObj.cross_layer_violations ||\n validationObj.layer_violations;\n if (!violations || !Array.isArray(violations)) {\n throw new Error(\"Inter-layer validation missing or invalid required field: violations (must be array)\");\n }\n\n // Validate each violation object with field normalization\n const validatedViolations = violations.map((v: unknown, index: number) => {\n if (typeof v !== \"object\" || v === null) {\n throw new Error(`Violation at index ${index} is not a valid object`);\n }\n const violation = v as Record<string, unknown>;\n\n // Normalize sourceLayer: accepts sourceLayer, source.layer, source_layer, from\n const rawSource = violation.source;\n const sourceLayer =\n violation.sourceLayer ||\n (typeof rawSource === \"object\" && rawSource !== null\n ? (rawSource as Record<string, unknown>).layer\n : undefined) ||\n violation.source_layer ||\n violation.from;\n if (!sourceLayer || typeof sourceLayer !== \"string\") {\n throw new Error(`Violation at index ${index} missing or invalid field: sourceLayer (must be string)`);\n }\n\n // Normalize targetLayer: accepts targetLayer, destination.layer, target.layer, target_layer, to\n const rawDest = violation.destination;\n const targetLayer =\n violation.targetLayer ||\n (typeof rawDest === \"object\" && rawDest !== null\n ? (rawDest as Record<string, unknown>).layer\n : undefined) ||\n violation.target_layer ||\n violation.to;\n if (!targetLayer || typeof targetLayer !== \"string\") {\n throw new Error(`Violation at index ${index} missing or invalid field: targetLayer (must be string)`);\n }\n\n // Normalize issue: accepts issue, violation, description, message, problem\n const issue =\n violation.issue ||\n violation.violation ||\n violation.description ||\n violation.message ||\n violation.problem;\n if (!issue || typeof issue !== \"string\") {\n throw new Error(`Violation at index ${index} missing or invalid field: issue (must be string)`);\n }\n\n return {\n sourceLayer: sourceLayer as string,\n targetLayer: targetLayer as string,\n issue: issue as string,\n };\n });\n\n // Normalize recommendations: accept string[] or object[]{action, description}\n const rawRecs = validationObj.recommendations;\n if (!rawRecs || !Array.isArray(rawRecs)) {\n throw new Error(\"Inter-layer validation missing or invalid required field: recommendations (must be array)\");\n }\n const recommendations = rawRecs.map((r: unknown) => {\n if (typeof r === \"string\") return r;\n if (typeof r === \"object\" && r !== null) {\n const obj = r as Record<string, unknown>;\n return String(obj.action || obj.description || JSON.stringify(r));\n }\n return String(r);\n });\n\n return {\n violations: validatedViolations,\n recommendations,\n };\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,iCAAiC;AAC1C,SAAS,uBAAuB;AA+B1B,MAAO,eAAc;;;;EAIzB,4BAA4B,UAAgB;AAE1C,UAAM,YACJ,SAAS,MAAM,0BAA0B,KAAK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YAAY,cAAc,OAC3C,UAAsC,QACvC,WACJ,UAAU,gBACV,UAAU;AACZ,UAAI,CAAC,eAAe,OAAO,eAAgB;AACzC,cAAM,IAAI,MAAM,sBAAsB,KAAK,yDAAyD;AAItG,YAAM,UAAU,UAAU,aACpB,cACJ,UAAU,gBACT,OAAO,WAAY,YAAY,YAAY,OACvC,QAAoC,QACrC,WACJ,UAAU,gBACV,UAAU;AACZ,UAAI,CAAC,eAAe,OAAO,eAAgB;AACzC,cAAM,IAAI,MAAM,sBAAsB,KAAK,yDAAyD;AAItG,YAAM,QACJ,UAAU,SACV,UAAU,aACV,UAAU,eACV,UAAU,WACV,UAAU;AACZ,UAAI,CAAC,SAAS,OAAO,SAAU;AAC7B,cAAM,IAAI,MAAM,sBAAsB,KAAK,mDAAmD;AAGhG,aAAO;QACL;QACA;QACA;;IAEJ,CAAC,GAGK,UAAU,cAAc;AAC9B,QAAI,CAAC,WAAW,CAAC,MAAM,QAAQ,OAAO;AACpC,YAAM,IAAI,MAAM,2FAA2F;AAE7G,UAAM,kBAAkB,QAAQ,IAAI,CAAC,MAAc;AACjD,UAAI,OAAO,KAAM;AAAU,eAAO;AAClC,UAAI,OAAO,KAAM,YAAY,MAAM,MAAM;AACvC,cAAM,MAAM;AACZ,eAAO,OAAO,IAAI,UAAU,IAAI,eAAe,KAAK,UAAU,CAAC,CAAC;MAClE;AACA,aAAO,OAAO,CAAC;IACjB,CAAC;AAED,WAAO;MACL,YAAY;MACZ;;EAEJ;;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
class PromptTemplates {
|
|
2
|
+
/**
|
|
3
|
+
* Generate element evaluation prompt for low-coverage node types
|
|
4
|
+
*/
|
|
5
|
+
elementEvaluation(nodeType, coverage, predicates) {
|
|
6
|
+
const [layer, type] = nodeType.split("."), standard = this.getLayerStandard(layer), targetRange = this.getTargetRange();
|
|
7
|
+
return `Evaluate the node type '${nodeType}' for missing intra-layer relationships.
|
|
8
|
+
|
|
9
|
+
Layer: ${layer}
|
|
10
|
+
Node Type: ${type}
|
|
11
|
+
Current Relationships: ${coverage.relationshipsPerNodeType} (target: ${targetRange})
|
|
12
|
+
Layer Standard: ${standard}
|
|
13
|
+
|
|
14
|
+
Available Predicates:
|
|
15
|
+
${predicates.map((p) => `- ${p}: ${this.getPredicateDefinition(p)}`).join(`
|
|
16
|
+
`)}
|
|
17
|
+
|
|
18
|
+
Suggest meaningful intra-layer relationships based on ${standard} patterns.
|
|
19
|
+
For each suggestion, provide:
|
|
20
|
+
1. Source node type (this type: ${nodeType})
|
|
21
|
+
2. Predicate (from available list)
|
|
22
|
+
3. Destination node type (must exist in ${layer} layer)
|
|
23
|
+
4. Architectural justification (reference ${standard} specification)
|
|
24
|
+
5. Priority (high/medium/low)
|
|
25
|
+
|
|
26
|
+
Format as JSON array of relationship recommendations.`;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Generate layer review prompt for overall coherence evaluation
|
|
30
|
+
*/
|
|
31
|
+
layerReview(layer, coverage) {
|
|
32
|
+
const layerMetrics = coverage.find((c) => c.layer === layer);
|
|
33
|
+
if (!layerMetrics)
|
|
34
|
+
throw new Error(`No coverage metrics found for layer: ${layer}`);
|
|
35
|
+
const standard = this.getLayerStandard(layer);
|
|
36
|
+
return `Review the ${layer} layer relationship coverage.
|
|
37
|
+
|
|
38
|
+
Node Types: ${layerMetrics.nodeTypeCount}
|
|
39
|
+
Current Relationships: ${layerMetrics.relationshipCount}
|
|
40
|
+
Isolation: ${layerMetrics.isolationPercentage}%
|
|
41
|
+
Density: ${layerMetrics.relationshipsPerNodeType} per node type
|
|
42
|
+
Standard: ${standard}
|
|
43
|
+
|
|
44
|
+
Evaluate:
|
|
45
|
+
1. Semantic coherence of existing relationships
|
|
46
|
+
2. Missing critical relationship patterns from ${standard}
|
|
47
|
+
3. Prioritized recommendations for relationship additions
|
|
48
|
+
4. Balance assessment (are we over/under-specifying?)
|
|
49
|
+
|
|
50
|
+
Respond with ONLY the following JSON, wrapped in a json code block (no other text before or after):
|
|
51
|
+
|
|
52
|
+
\`\`\`json
|
|
53
|
+
{
|
|
54
|
+
"coherenceIssues": ["description of coherence issue"],
|
|
55
|
+
"missingPatterns": ["description of missing pattern from ${standard}"],
|
|
56
|
+
"recommendations": [
|
|
57
|
+
{
|
|
58
|
+
"sourceNodeType": "${layer}.nodeType",
|
|
59
|
+
"predicate": "predicate-name",
|
|
60
|
+
"destinationNodeType": "${layer}.otherNodeType",
|
|
61
|
+
"justification": "architectural justification",
|
|
62
|
+
"priority": "high"
|
|
63
|
+
}
|
|
64
|
+
],
|
|
65
|
+
"balanceAssessment": "brief assessment of relationship density and coverage"
|
|
66
|
+
}
|
|
67
|
+
\`\`\``;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Generate inter-layer gap identification prompt.
|
|
71
|
+
*
|
|
72
|
+
* Identifies cross-layer relationship schemas that are architecturally missing
|
|
73
|
+
* from the spec — schemas that SHOULD exist but DON'T — rather than validating
|
|
74
|
+
* existing ones. Output `violations` entries represent missing schemas;
|
|
75
|
+
* `recommendations` list the concrete spec files to create.
|
|
76
|
+
*
|
|
77
|
+
* @param sourceLayer - The more-abstract (lower-numbered) layer in the pair
|
|
78
|
+
* @param targetLayer - The more-concrete (higher-numbered) layer in the pair
|
|
79
|
+
* @param context - Optional spec context to ground suggestions in real node types
|
|
80
|
+
*/
|
|
81
|
+
interLayerValidation(sourceLayer, targetLayer, context) {
|
|
82
|
+
const sourceNum = context?.sourceLayerNumber ?? this.getLayerNumber(sourceLayer), targetNum = context?.targetLayerNumber ?? this.getLayerNumber(targetLayer), [concreteLayer, concreteNum, abstractLayer, abstractNum] = sourceNum < targetNum ? [targetLayer, targetNum, sourceLayer, sourceNum] : [sourceLayer, sourceNum, targetLayer, targetNum], concreteTypes = context?.concreteNodeTypes?.join(", ") ?? this.getLayerNodeTypeHint(concreteLayer), abstractTypes = context?.abstractNodeTypes?.join(", ") ?? this.getLayerNodeTypeHint(abstractLayer), existingSection = context?.existingSchemas && context.existingSchemas.length > 0 ? `
|
|
83
|
+
## Schemas Already Defined for This Pair
|
|
84
|
+
Do NOT re-suggest these \u2014 they exist:
|
|
85
|
+
${context.existingSchemas.map((s) => `- ${s}`).join(`
|
|
86
|
+
`)}
|
|
87
|
+
` : "", predicateSection = context?.availablePredicates && context.availablePredicates.length > 0 ? `
|
|
88
|
+
## Valid Cross-Layer Predicates
|
|
89
|
+
Only use predicates from this list:
|
|
90
|
+
${context.availablePredicates.map((p) => `- ${p}`).join(`
|
|
91
|
+
`)}
|
|
92
|
+
` : `
|
|
93
|
+
## Commonly Valid Cross-Layer Predicates
|
|
94
|
+
Use one of: realizes, serves, accesses, uses, references, triggers, monitors, tests, covers, satisfies, implements, depends-on, maps-to, requires
|
|
95
|
+
`;
|
|
96
|
+
return `You are an architecture spec analyst for the Documentation Robotics 12-layer model.
|
|
97
|
+
|
|
98
|
+
## Task
|
|
99
|
+
Identify cross-layer relationship schemas that are MISSING from the spec for the layer pair:
|
|
100
|
+
**${concreteLayer}** (layer ${concreteNum}, more concrete) \u2192 **${abstractLayer}** (layer ${abstractNum}, more abstract)
|
|
101
|
+
|
|
102
|
+
A "missing schema" is a relationship type that:
|
|
103
|
+
- Would be meaningfully instantiated in real codebases regularly \u2014 not just theoretically possible
|
|
104
|
+
- Does NOT yet exist in the spec for this layer pair
|
|
105
|
+
- Enables traceability, governance, or cross-cutting concern validation across this boundary
|
|
106
|
+
- Follows the correct reference direction: ${concreteLayer} \u2192 ${abstractLayer}
|
|
107
|
+
|
|
108
|
+
## The 12-Layer Model (concrete \u2192 abstract)
|
|
109
|
+
|
|
110
|
+
| # | Layer | Standard | Representative Node Types |
|
|
111
|
+
|---|-------|----------|--------------------------|
|
|
112
|
+
| 12 | testing | IEEE 829 | testsuite, testcase, testdata, teststrategy, testcoverage |
|
|
113
|
+
| 11 | apm | OpenTelemetry | metric, trace, span, alert, dashboard, traceconfiguration |
|
|
114
|
+
| 10 | navigation | Router patterns | route, menu, menuitem, breadcrumb, flow, tab |
|
|
115
|
+
| 9 | ux | Component patterns | view, subview, librarycomponent, actioncomponent, formcomponent |
|
|
116
|
+
| 8 | data-store | DB patterns | database, table, collection, index, view |
|
|
117
|
+
| 7 | data-model | JSON Schema | entity, attribute, relationship, enum, type |
|
|
118
|
+
| 6 | api | OpenAPI 3.0 | operation, pathitem, requestbody, response, schema, securityscheme |
|
|
119
|
+
| 5 | technology | ArchiMate | node, device, systemsoftware, technologyservice, infrastructureservice |
|
|
120
|
+
| 4 | application | ArchiMate | applicationcomponent, applicationservice, applicationfunction, applicationinterface |
|
|
121
|
+
| 3 | security | NIST SP 800-53 | secureresource, securitypolicy, threat, control, accesscontrol |
|
|
122
|
+
| 2 | business | ArchiMate | businessprocess, businessservice, businessfunction, businessrole, businessobject |
|
|
123
|
+
| 1 | motivation | ArchiMate | goal, driver, requirement, principle, constraint, outcome, stakeholder |
|
|
124
|
+
|
|
125
|
+
## Reference Direction Rule
|
|
126
|
+
CONCRETE layers (higher numbers, closer to implementation) reference ABSTRACT layers (lower numbers, closer to goals). References flow downward through the stack:
|
|
127
|
+
testing(12) \u2192 apm(11) \u2192 navigation(10) \u2192 ux(9) \u2192 data-store(8) \u2192 data-model(7) \u2192 api(6) \u2192 technology(5) \u2192 application(4) \u2192 security(3) \u2192 business(2) \u2192 motivation(1)
|
|
128
|
+
|
|
129
|
+
For this pair, valid schemas define relationships **from ${concreteLayer} node types to ${abstractLayer} node types**.
|
|
130
|
+
${existingSection}${predicateSection}
|
|
131
|
+
## Node Types in This Pair
|
|
132
|
+
|
|
133
|
+
**${concreteLayer}** (source of relationships): ${concreteTypes}
|
|
134
|
+
**${abstractLayer}** (target of relationships): ${abstractTypes}
|
|
135
|
+
|
|
136
|
+
## Anti-Noise Criteria
|
|
137
|
+
ONLY suggest a schema if ALL of the following hold:
|
|
138
|
+
1. A real development team would routinely create instances of this relationship
|
|
139
|
+
2. The schema enables meaningful traceability or cross-cutting validation at this layer boundary
|
|
140
|
+
3. The source and target node types are semantically compatible (the relationship "makes sense" to a developer)
|
|
141
|
+
4. The gap would affect \u226510% of real models containing both layers
|
|
142
|
+
5. The relationship is NOT already covered by an existing schema for this pair
|
|
143
|
+
|
|
144
|
+
Do NOT suggest schemas that are:
|
|
145
|
+
- Speculative, aspirational, or "might be useful someday"
|
|
146
|
+
- Already covered by existing schemas (listed above)
|
|
147
|
+
- In the wrong direction (abstract \u2192 concrete references are violations of the model)
|
|
148
|
+
- Between node types with no natural semantic connection
|
|
149
|
+
|
|
150
|
+
## Output Format
|
|
151
|
+
Respond with ONLY the following JSON, wrapped in a json code block (no other text before or after):
|
|
152
|
+
|
|
153
|
+
\`\`\`json
|
|
154
|
+
{
|
|
155
|
+
"violations": [
|
|
156
|
+
{
|
|
157
|
+
"sourceLayer": "${concreteLayer}",
|
|
158
|
+
"targetLayer": "${abstractLayer}",
|
|
159
|
+
"issue": "Missing schema: {sourceNodeType}.{predicate}.{targetNodeType} \u2014 {one-sentence architectural justification}"
|
|
160
|
+
}
|
|
161
|
+
],
|
|
162
|
+
"recommendations": [
|
|
163
|
+
"Add spec/schemas/relationships/${concreteLayer}/{sourceNodeType}.{predicate}.{targetNodeType}.relationship.schema.json"
|
|
164
|
+
]
|
|
165
|
+
}
|
|
166
|
+
\`\`\`
|
|
167
|
+
|
|
168
|
+
Rules:
|
|
169
|
+
- Each violation entry corresponds to exactly one missing schema
|
|
170
|
+
- Each recommendation is the concrete spec file path to create for that schema
|
|
171
|
+
- Limit to at most 8 gap suggestions \u2014 prefer highest-confidence, highest-impact gaps
|
|
172
|
+
- If no schemas are architecturally missing, return: { "violations": [], "recommendations": [] }`;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Get the canonical layer number (1–12) for a layer name.
|
|
176
|
+
* Returns 0 if the layer name is unrecognized.
|
|
177
|
+
*/
|
|
178
|
+
getLayerNumber(layer) {
|
|
179
|
+
const idx = [
|
|
180
|
+
"motivation",
|
|
181
|
+
"business",
|
|
182
|
+
"security",
|
|
183
|
+
"application",
|
|
184
|
+
"technology",
|
|
185
|
+
"api",
|
|
186
|
+
"data-model",
|
|
187
|
+
"data-store",
|
|
188
|
+
"ux",
|
|
189
|
+
"navigation",
|
|
190
|
+
"apm",
|
|
191
|
+
"testing"
|
|
192
|
+
].indexOf(layer);
|
|
193
|
+
return idx >= 0 ? idx + 1 : 0;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Get a representative hint string for the node types in a layer.
|
|
197
|
+
* Used as a fallback when context.concreteNodeTypes / context.abstractNodeTypes
|
|
198
|
+
* are not provided by the caller.
|
|
199
|
+
*/
|
|
200
|
+
getLayerNodeTypeHint(layer) {
|
|
201
|
+
return {
|
|
202
|
+
motivation: "goal, driver, requirement, principle, constraint, outcome, stakeholder",
|
|
203
|
+
business: "businessprocess, businessservice, businessfunction, businessrole, businessobject, businessactor, product",
|
|
204
|
+
security: "secureresource, securitypolicy, threat, control, accesscontrol, identitysubject",
|
|
205
|
+
application: "applicationcomponent, applicationservice, applicationfunction, applicationinterface, applicationevent",
|
|
206
|
+
technology: "node, device, systemsoftware, technologyservice, technologyfunction, infrastructureservice",
|
|
207
|
+
api: "openapidocument, pathitem, operation, requestbody, response, schema, securityscheme, server, ratelimit",
|
|
208
|
+
"data-model": "entity, attribute, relationship, enum, type",
|
|
209
|
+
"data-store": "database, table, collection, index, view",
|
|
210
|
+
ux: "view, subview, librarycomponent, actioncomponent, formcomponent, contentcomponent, loadingstate, modal",
|
|
211
|
+
navigation: "route, menu, menuitem, breadcrumb, flow, tab",
|
|
212
|
+
apm: "metric, trace, span, alert, dashboard, traceconfiguration, logsource, sdkconfig",
|
|
213
|
+
testing: "testsuite, testcase, testdata, teststrategy, testcoverage"
|
|
214
|
+
}[layer] ?? "see layer spec for node types";
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Get the standard/framework for a layer
|
|
218
|
+
*/
|
|
219
|
+
getLayerStandard(layer) {
|
|
220
|
+
return {
|
|
221
|
+
motivation: "ArchiMate 3.2",
|
|
222
|
+
business: "ArchiMate 3.2",
|
|
223
|
+
security: "NIST SP 800-53",
|
|
224
|
+
application: "ArchiMate 3.2",
|
|
225
|
+
technology: "ArchiMate 3.2",
|
|
226
|
+
api: "OpenAPI 3.0",
|
|
227
|
+
"data-model": "JSON Schema Draft 7",
|
|
228
|
+
"data-store": "Database patterns",
|
|
229
|
+
ux: "React/Component patterns",
|
|
230
|
+
navigation: "Router patterns",
|
|
231
|
+
apm: "OpenTelemetry",
|
|
232
|
+
testing: "Test patterns"
|
|
233
|
+
}[layer] || "Architecture best practices";
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Get target relationship range for a node type
|
|
237
|
+
*
|
|
238
|
+
* Returns a static range "2-5" for all types. This is intentionally
|
|
239
|
+
* simplified for AI prompts to avoid over-constraining suggestions.
|
|
240
|
+
* Type-specific refinement could be added in the future if needed,
|
|
241
|
+
* but the current approach works well for generating diverse recommendations.
|
|
242
|
+
*/
|
|
243
|
+
getTargetRange() {
|
|
244
|
+
return "2-5";
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Get predicate definition/description
|
|
248
|
+
*
|
|
249
|
+
* NOTE: These predicate definitions are intentionally a curated subset
|
|
250
|
+
* rather than being loaded from the full relationship catalog. This is
|
|
251
|
+
* by design to keep AI prompts focused on the most common and important
|
|
252
|
+
* relationships. The full catalog has 252 relationship types which would
|
|
253
|
+
* overwhelm the AI context window and reduce prompt clarity.
|
|
254
|
+
*/
|
|
255
|
+
getPredicateDefinition(predicate) {
|
|
256
|
+
return {
|
|
257
|
+
realizes: "Realization relationship - implements or fulfills",
|
|
258
|
+
serves: "Serving relationship - provides service to",
|
|
259
|
+
accesses: "Access relationship - reads/writes data",
|
|
260
|
+
triggers: "Triggering relationship - initiates or causes",
|
|
261
|
+
influences: "Influence relationship - affects or impacts",
|
|
262
|
+
uses: "Usage relationship - employs or utilizes",
|
|
263
|
+
composes: "Composition relationship - structural part-of",
|
|
264
|
+
aggregates: "Aggregation relationship - logical grouping",
|
|
265
|
+
specializes: "Specialization relationship - is-a subtype of",
|
|
266
|
+
assigns: "Assignment relationship - allocates responsibility",
|
|
267
|
+
flows: "Flow relationship - information or control transfer"
|
|
268
|
+
}[predicate] || "Relationship between elements";
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
export {
|
|
272
|
+
PromptTemplates
|
|
273
|
+
};
|
|
274
|
+
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/audit/relationships/ai/prompts.ts"],
|
|
4
|
+
"sourcesContent": ["import type { CoverageMetrics } from \"../../types.js\";\n\n/**\n * Optional spec context passed to interLayerValidation() to ground the prompt\n * in real node types and existing schemas rather than relying on static hints.\n */\nexport interface InterLayerContext {\n /** 1-based layer number of the more-abstract (lower-numbered) layer */\n sourceLayerNumber: number;\n /** 1-based layer number of the more-concrete (higher-numbered) layer */\n targetLayerNumber: number;\n /** Node types available in the more-concrete layer (concrete \u2192 abstract references) */\n concreteNodeTypes?: string[];\n /** Node types available in the more-abstract layer */\n abstractNodeTypes?: string[];\n /** Cross-layer schemas already defined for this pair \u2014 excluded from suggestions */\n existingSchemas?: string[];\n /** Predicates valid for cross-layer use in this spec version */\n availablePredicates?: string[];\n}\n\nexport class PromptTemplates {\n /**\n * Generate element evaluation prompt for low-coverage node types\n */\n elementEvaluation(\n nodeType: string,\n coverage: CoverageMetrics,\n predicates: string[]\n ): string {\n const [layer, type] = nodeType.split(\".\");\n const standard = this.getLayerStandard(layer);\n const targetRange = this.getTargetRange();\n\n return `Evaluate the node type '${nodeType}' for missing intra-layer relationships.\n\nLayer: ${layer}\nNode Type: ${type}\nCurrent Relationships: ${coverage.relationshipsPerNodeType} (target: ${targetRange})\nLayer Standard: ${standard}\n\nAvailable Predicates:\n${predicates.map((p) => `- ${p}: ${this.getPredicateDefinition(p)}`).join(\"\\n\")}\n\nSuggest meaningful intra-layer relationships based on ${standard} patterns.\nFor each suggestion, provide:\n1. Source node type (this type: ${nodeType})\n2. Predicate (from available list)\n3. Destination node type (must exist in ${layer} layer)\n4. Architectural justification (reference ${standard} specification)\n5. Priority (high/medium/low)\n\nFormat as JSON array of relationship recommendations.`;\n }\n\n /**\n * Generate layer review prompt for overall coherence evaluation\n */\n layerReview(layer: string, coverage: CoverageMetrics[]): string {\n const layerMetrics = coverage.find((c) => c.layer === layer);\n if (!layerMetrics) {\n throw new Error(`No coverage metrics found for layer: ${layer}`);\n }\n\n const standard = this.getLayerStandard(layer);\n\n return `Review the ${layer} layer relationship coverage.\n\nNode Types: ${layerMetrics.nodeTypeCount}\nCurrent Relationships: ${layerMetrics.relationshipCount}\nIsolation: ${layerMetrics.isolationPercentage}%\nDensity: ${layerMetrics.relationshipsPerNodeType} per node type\nStandard: ${standard}\n\nEvaluate:\n1. Semantic coherence of existing relationships\n2. Missing critical relationship patterns from ${standard}\n3. Prioritized recommendations for relationship additions\n4. Balance assessment (are we over/under-specifying?)\n\nRespond with ONLY the following JSON, wrapped in a json code block (no other text before or after):\n\n\\`\\`\\`json\n{\n \"coherenceIssues\": [\"description of coherence issue\"],\n \"missingPatterns\": [\"description of missing pattern from ${standard}\"],\n \"recommendations\": [\n {\n \"sourceNodeType\": \"${layer}.nodeType\",\n \"predicate\": \"predicate-name\",\n \"destinationNodeType\": \"${layer}.otherNodeType\",\n \"justification\": \"architectural justification\",\n \"priority\": \"high\"\n }\n ],\n \"balanceAssessment\": \"brief assessment of relationship density and coverage\"\n}\n\\`\\`\\``;\n }\n\n /**\n * Generate inter-layer gap identification prompt.\n *\n * Identifies cross-layer relationship schemas that are architecturally missing\n * from the spec \u2014 schemas that SHOULD exist but DON'T \u2014 rather than validating\n * existing ones. Output `violations` entries represent missing schemas;\n * `recommendations` list the concrete spec files to create.\n *\n * @param sourceLayer - The more-abstract (lower-numbered) layer in the pair\n * @param targetLayer - The more-concrete (higher-numbered) layer in the pair\n * @param context - Optional spec context to ground suggestions in real node types\n */\n interLayerValidation(\n sourceLayer: string,\n targetLayer: string,\n context?: InterLayerContext\n ): string {\n // Determine which layer is more concrete (higher-numbered = closer to implementation).\n // The pipeline always passes source=lower-index, target=higher-index, so target\n // is typically the concrete layer. Use context numbers when available.\n const sourceNum = context?.sourceLayerNumber ?? this.getLayerNumber(sourceLayer);\n const targetNum = context?.targetLayerNumber ?? this.getLayerNumber(targetLayer);\n\n const [concreteLayer, concreteNum, abstractLayer, abstractNum] =\n sourceNum < targetNum\n ? [targetLayer, targetNum, sourceLayer, sourceNum]\n : [sourceLayer, sourceNum, targetLayer, targetNum];\n\n // Node type sections \u2014 use context when available, otherwise fall back to static list\n const concreteTypes =\n context?.concreteNodeTypes?.join(\", \") ??\n this.getLayerNodeTypeHint(concreteLayer);\n const abstractTypes =\n context?.abstractNodeTypes?.join(\", \") ??\n this.getLayerNodeTypeHint(abstractLayer);\n\n // Existing-schema section (skip boilerplate when the pair has no prior schemas)\n const existingSection =\n context?.existingSchemas && context.existingSchemas.length > 0\n ? `\\n## Schemas Already Defined for This Pair\\nDo NOT re-suggest these \u2014 they exist:\\n${context.existingSchemas.map((s) => `- ${s}`).join(\"\\n\")}\\n`\n : \"\";\n\n // Available predicates section\n const predicateSection =\n context?.availablePredicates && context.availablePredicates.length > 0\n ? `\\n## Valid Cross-Layer Predicates\\nOnly use predicates from this list:\\n${context.availablePredicates.map((p) => `- ${p}`).join(\"\\n\")}\\n`\n : `\\n## Commonly Valid Cross-Layer Predicates\\nUse one of: realizes, serves, accesses, uses, references, triggers, monitors, tests, covers, satisfies, implements, depends-on, maps-to, requires\\n`;\n\n return `You are an architecture spec analyst for the Documentation Robotics 12-layer model.\n\n## Task\nIdentify cross-layer relationship schemas that are MISSING from the spec for the layer pair:\n **${concreteLayer}** (layer ${concreteNum}, more concrete) \u2192 **${abstractLayer}** (layer ${abstractNum}, more abstract)\n\nA \"missing schema\" is a relationship type that:\n- Would be meaningfully instantiated in real codebases regularly \u2014 not just theoretically possible\n- Does NOT yet exist in the spec for this layer pair\n- Enables traceability, governance, or cross-cutting concern validation across this boundary\n- Follows the correct reference direction: ${concreteLayer} \u2192 ${abstractLayer}\n\n## The 12-Layer Model (concrete \u2192 abstract)\n\n| # | Layer | Standard | Representative Node Types |\n|---|-------|----------|--------------------------|\n| 12 | testing | IEEE 829 | testsuite, testcase, testdata, teststrategy, testcoverage |\n| 11 | apm | OpenTelemetry | metric, trace, span, alert, dashboard, traceconfiguration |\n| 10 | navigation | Router patterns | route, menu, menuitem, breadcrumb, flow, tab |\n| 9 | ux | Component patterns | view, subview, librarycomponent, actioncomponent, formcomponent |\n| 8 | data-store | DB patterns | database, table, collection, index, view |\n| 7 | data-model | JSON Schema | entity, attribute, relationship, enum, type |\n| 6 | api | OpenAPI 3.0 | operation, pathitem, requestbody, response, schema, securityscheme |\n| 5 | technology | ArchiMate | node, device, systemsoftware, technologyservice, infrastructureservice |\n| 4 | application | ArchiMate | applicationcomponent, applicationservice, applicationfunction, applicationinterface |\n| 3 | security | NIST SP 800-53 | secureresource, securitypolicy, threat, control, accesscontrol |\n| 2 | business | ArchiMate | businessprocess, businessservice, businessfunction, businessrole, businessobject |\n| 1 | motivation | ArchiMate | goal, driver, requirement, principle, constraint, outcome, stakeholder |\n\n## Reference Direction Rule\nCONCRETE layers (higher numbers, closer to implementation) reference ABSTRACT layers (lower numbers, closer to goals). References flow downward through the stack:\n testing(12) \u2192 apm(11) \u2192 navigation(10) \u2192 ux(9) \u2192 data-store(8) \u2192 data-model(7) \u2192 api(6) \u2192 technology(5) \u2192 application(4) \u2192 security(3) \u2192 business(2) \u2192 motivation(1)\n\nFor this pair, valid schemas define relationships **from ${concreteLayer} node types to ${abstractLayer} node types**.\n${existingSection}${predicateSection}\n## Node Types in This Pair\n\n**${concreteLayer}** (source of relationships): ${concreteTypes}\n**${abstractLayer}** (target of relationships): ${abstractTypes}\n\n## Anti-Noise Criteria\nONLY suggest a schema if ALL of the following hold:\n1. A real development team would routinely create instances of this relationship\n2. The schema enables meaningful traceability or cross-cutting validation at this layer boundary\n3. The source and target node types are semantically compatible (the relationship \"makes sense\" to a developer)\n4. The gap would affect \u226510% of real models containing both layers\n5. The relationship is NOT already covered by an existing schema for this pair\n\nDo NOT suggest schemas that are:\n- Speculative, aspirational, or \"might be useful someday\"\n- Already covered by existing schemas (listed above)\n- In the wrong direction (abstract \u2192 concrete references are violations of the model)\n- Between node types with no natural semantic connection\n\n## Output Format\nRespond with ONLY the following JSON, wrapped in a json code block (no other text before or after):\n\n\\`\\`\\`json\n{\n \"violations\": [\n {\n \"sourceLayer\": \"${concreteLayer}\",\n \"targetLayer\": \"${abstractLayer}\",\n \"issue\": \"Missing schema: {sourceNodeType}.{predicate}.{targetNodeType} \u2014 {one-sentence architectural justification}\"\n }\n ],\n \"recommendations\": [\n \"Add spec/schemas/relationships/${concreteLayer}/{sourceNodeType}.{predicate}.{targetNodeType}.relationship.schema.json\"\n ]\n}\n\\`\\`\\`\n\nRules:\n- Each violation entry corresponds to exactly one missing schema\n- Each recommendation is the concrete spec file path to create for that schema\n- Limit to at most 8 gap suggestions \u2014 prefer highest-confidence, highest-impact gaps\n- If no schemas are architecturally missing, return: { \"violations\": [], \"recommendations\": [] }`;\n }\n\n /**\n * Get the canonical layer number (1\u201312) for a layer name.\n * Returns 0 if the layer name is unrecognized.\n */\n private getLayerNumber(layer: string): number {\n const order = [\n \"motivation\",\n \"business\",\n \"security\",\n \"application\",\n \"technology\",\n \"api\",\n \"data-model\",\n \"data-store\",\n \"ux\",\n \"navigation\",\n \"apm\",\n \"testing\",\n ];\n const idx = order.indexOf(layer);\n return idx >= 0 ? idx + 1 : 0;\n }\n\n /**\n * Get a representative hint string for the node types in a layer.\n * Used as a fallback when context.concreteNodeTypes / context.abstractNodeTypes\n * are not provided by the caller.\n */\n private getLayerNodeTypeHint(layer: string): string {\n const hints: Record<string, string> = {\n motivation: \"goal, driver, requirement, principle, constraint, outcome, stakeholder\",\n business:\n \"businessprocess, businessservice, businessfunction, businessrole, businessobject, businessactor, product\",\n security: \"secureresource, securitypolicy, threat, control, accesscontrol, identitysubject\",\n application:\n \"applicationcomponent, applicationservice, applicationfunction, applicationinterface, applicationevent\",\n technology:\n \"node, device, systemsoftware, technologyservice, technologyfunction, infrastructureservice\",\n api: \"openapidocument, pathitem, operation, requestbody, response, schema, securityscheme, server, ratelimit\",\n \"data-model\": \"entity, attribute, relationship, enum, type\",\n \"data-store\": \"database, table, collection, index, view\",\n ux: \"view, subview, librarycomponent, actioncomponent, formcomponent, contentcomponent, loadingstate, modal\",\n navigation: \"route, menu, menuitem, breadcrumb, flow, tab\",\n apm: \"metric, trace, span, alert, dashboard, traceconfiguration, logsource, sdkconfig\",\n testing: \"testsuite, testcase, testdata, teststrategy, testcoverage\",\n };\n return hints[layer] ?? \"see layer spec for node types\";\n }\n\n /**\n * Get the standard/framework for a layer\n */\n getLayerStandard(layer: string): string {\n const standards: Record<string, string> = {\n motivation: \"ArchiMate 3.2\",\n business: \"ArchiMate 3.2\",\n security: \"NIST SP 800-53\",\n application: \"ArchiMate 3.2\",\n technology: \"ArchiMate 3.2\",\n api: \"OpenAPI 3.0\",\n \"data-model\": \"JSON Schema Draft 7\",\n \"data-store\": \"Database patterns\",\n ux: \"React/Component patterns\",\n navigation: \"Router patterns\",\n apm: \"OpenTelemetry\",\n testing: \"Test patterns\",\n };\n return standards[layer] || \"Architecture best practices\";\n }\n\n /**\n * Get target relationship range for a node type\n *\n * Returns a static range \"2-5\" for all types. This is intentionally\n * simplified for AI prompts to avoid over-constraining suggestions.\n * Type-specific refinement could be added in the future if needed,\n * but the current approach works well for generating diverse recommendations.\n */\n private getTargetRange(): string {\n // Default target based on common patterns across all types\n return \"2-5\";\n }\n\n /**\n * Get predicate definition/description\n *\n * NOTE: These predicate definitions are intentionally a curated subset\n * rather than being loaded from the full relationship catalog. This is\n * by design to keep AI prompts focused on the most common and important\n * relationships. The full catalog has 252 relationship types which would\n * overwhelm the AI context window and reduce prompt clarity.\n */\n private getPredicateDefinition(predicate: string): string {\n // Curated predicate definitions (subset of relationship catalog)\n const definitions: Record<string, string> = {\n realizes: \"Realization relationship - implements or fulfills\",\n serves: \"Serving relationship - provides service to\",\n accesses: \"Access relationship - reads/writes data\",\n triggers: \"Triggering relationship - initiates or causes\",\n influences: \"Influence relationship - affects or impacts\",\n uses: \"Usage relationship - employs or utilizes\",\n composes: \"Composition relationship - structural part-of\",\n aggregates: \"Aggregation relationship - logical grouping\",\n specializes: \"Specialization relationship - is-a subtype of\",\n assigns: \"Assignment relationship - allocates responsibility\",\n flows: \"Flow relationship - information or control transfer\",\n };\n\n return definitions[predicate] || \"Relationship between elements\";\n }\n}\n"],
|
|
5
|
+
"mappings": "AAqBM,MAAO,gBAAe;;;;EAI1B,kBACE,UACA,UACA,YAAoB;AAEpB,UAAM,CAAC,OAAO,IAAI,IAAI,SAAS,MAAM,GAAG,GAClC,WAAW,KAAK,iBAAiB,KAAK,GACtC,cAAc,KAAK,eAAc;AAEvC,WAAO,2BAA2B,QAAQ;;SAErC,KAAK;aACD,IAAI;yBACQ,SAAS,wBAAwB,aAAa,WAAW;kBAChE,QAAQ;;;EAGxB,WAAW,IAAI,CAAC,MAAM,KAAK,CAAC,KAAK,KAAK,uBAAuB,CAAC,CAAC,EAAE,EAAE,KAAK;CAAI,CAAC;;wDAEvB,QAAQ;;kCAE9B,QAAQ;;0CAEA,KAAK;4CACH,QAAQ;;;;EAIlD;;;;EAKA,YAAY,OAAe,UAA2B;AACpD,UAAM,eAAe,SAAS,KAAK,CAAC,MAAM,EAAE,UAAU,KAAK;AAC3D,QAAI,CAAC;AACH,YAAM,IAAI,MAAM,wCAAwC,KAAK,EAAE;AAGjE,UAAM,WAAW,KAAK,iBAAiB,KAAK;AAE5C,WAAO,cAAc,KAAK;;cAEhB,aAAa,aAAa;yBACf,aAAa,iBAAiB;aAC1C,aAAa,mBA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