@mycodemap/mycodemap 0.4.2 → 0.5.1
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/CHANGELOG.md +105 -3
- package/README.md +192 -53
- package/dist/ai/claude.d.ts +38 -0
- package/dist/ai/claude.d.ts.map +1 -0
- package/dist/ai/claude.js +169 -0
- package/dist/ai/claude.js.map +1 -0
- package/dist/ai/codex.d.ts +38 -0
- package/dist/ai/codex.d.ts.map +1 -0
- package/dist/ai/codex.js +169 -0
- package/dist/ai/codex.js.map +1 -0
- package/dist/ai/factory.d.ts +48 -0
- package/dist/ai/factory.d.ts.map +1 -0
- package/dist/ai/factory.js +95 -0
- package/dist/ai/factory.js.map +1 -0
- package/dist/ai/index.d.ts +12 -0
- package/dist/ai/index.d.ts.map +1 -0
- package/dist/ai/index.js +29 -0
- package/dist/ai/index.js.map +1 -0
- package/dist/ai/provider.d.ts +70 -0
- package/dist/ai/provider.d.ts.map +1 -0
- package/dist/ai/provider.js +31 -0
- package/dist/ai/provider.js.map +1 -0
- package/dist/ai/subagent-caller.d.ts +90 -0
- package/dist/ai/subagent-caller.d.ts.map +1 -0
- package/dist/ai/subagent-caller.js +280 -0
- package/dist/ai/subagent-caller.js.map +1 -0
- package/dist/ai/types.d.ts +70 -0
- package/dist/ai/types.d.ts.map +1 -0
- package/dist/ai/types.js +5 -0
- package/dist/ai/types.js.map +1 -0
- package/dist/cli/commands/analyze.d.ts +18 -0
- package/dist/cli/commands/analyze.d.ts.map +1 -1
- package/dist/cli/commands/analyze.js +239 -6
- package/dist/cli/commands/analyze.js.map +1 -1
- package/dist/cli/commands/check.d.ts +22 -0
- package/dist/cli/commands/check.d.ts.map +1 -0
- package/dist/cli/commands/check.js +168 -0
- package/dist/cli/commands/check.js.map +1 -0
- package/dist/cli/commands/ci.d.ts +25 -0
- package/dist/cli/commands/ci.d.ts.map +1 -1
- package/dist/cli/commands/ci.js +139 -36
- package/dist/cli/commands/ci.js.map +1 -1
- package/dist/cli/commands/complexity.d.ts.map +1 -1
- package/dist/cli/commands/complexity.js +6 -0
- package/dist/cli/commands/complexity.js.map +1 -1
- package/dist/cli/commands/design.d.ts +52 -0
- package/dist/cli/commands/design.d.ts.map +1 -0
- package/dist/cli/commands/design.js +274 -0
- package/dist/cli/commands/design.js.map +1 -0
- package/dist/cli/commands/generate.d.ts +1 -0
- package/dist/cli/commands/generate.d.ts.map +1 -1
- package/dist/cli/commands/generate.js +121 -8
- package/dist/cli/commands/generate.js.map +1 -1
- package/dist/cli/commands/history.d.ts +26 -0
- package/dist/cli/commands/history.d.ts.map +1 -0
- package/dist/cli/commands/history.js +92 -0
- package/dist/cli/commands/history.js.map +1 -0
- package/dist/cli/commands/mcp.d.ts +13 -0
- package/dist/cli/commands/mcp.d.ts.map +1 -0
- package/dist/cli/commands/mcp.js +108 -0
- package/dist/cli/commands/mcp.js.map +1 -0
- package/dist/cli/commands/server.d.ts +9 -0
- package/dist/cli/commands/server.d.ts.map +1 -0
- package/dist/cli/commands/server.js +65 -0
- package/dist/cli/commands/server.js.map +1 -0
- package/dist/cli/commands/ship/pipeline.d.ts.map +1 -1
- package/dist/cli/commands/ship/pipeline.js +8 -1
- package/dist/cli/commands/ship/pipeline.js.map +1 -1
- package/dist/cli/commands/ship/publisher.d.ts +9 -1
- package/dist/cli/commands/ship/publisher.d.ts.map +1 -1
- package/dist/cli/commands/ship/publisher.js +149 -6
- package/dist/cli/commands/ship/publisher.js.map +1 -1
- package/dist/cli/commands/workflow.d.ts.map +1 -1
- package/dist/cli/commands/workflow.js +22 -2
- package/dist/cli/commands/workflow.js.map +1 -1
- package/dist/cli/config-loader.d.ts.map +1 -1
- package/dist/cli/config-loader.js +3 -2
- package/dist/cli/config-loader.js.map +1 -1
- package/dist/cli/contract-checker.d.ts +33 -0
- package/dist/cli/contract-checker.d.ts.map +1 -0
- package/dist/cli/contract-checker.js +719 -0
- package/dist/cli/contract-checker.js.map +1 -0
- package/dist/cli/contract-diff-scope.d.ts +14 -0
- package/dist/cli/contract-diff-scope.d.ts.map +1 -0
- package/dist/cli/contract-diff-scope.js +127 -0
- package/dist/cli/contract-diff-scope.js.map +1 -0
- package/dist/cli/contract-gate-thresholds.d.ts +14 -0
- package/dist/cli/contract-gate-thresholds.d.ts.map +1 -0
- package/dist/cli/contract-gate-thresholds.js +19 -0
- package/dist/cli/contract-gate-thresholds.js.map +1 -0
- package/dist/cli/design-contract-loader.d.ts +15 -0
- package/dist/cli/design-contract-loader.d.ts.map +1 -0
- package/dist/cli/design-contract-loader.js +527 -0
- package/dist/cli/design-contract-loader.js.map +1 -0
- package/dist/cli/design-contract-schema.d.ts +11 -0
- package/dist/cli/design-contract-schema.d.ts.map +1 -0
- package/dist/cli/design-contract-schema.js +75 -0
- package/dist/cli/design-contract-schema.js.map +1 -0
- package/dist/cli/design-handoff-builder.d.ts +15 -0
- package/dist/cli/design-handoff-builder.d.ts.map +1 -0
- package/dist/cli/design-handoff-builder.js +345 -0
- package/dist/cli/design-handoff-builder.js.map +1 -0
- package/dist/cli/design-scope-resolver.d.ts +8 -0
- package/dist/cli/design-scope-resolver.d.ts.map +1 -0
- package/dist/cli/design-scope-resolver.js +760 -0
- package/dist/cli/design-scope-resolver.js.map +1 -0
- package/dist/cli/design-verification-builder.d.ts +8 -0
- package/dist/cli/design-verification-builder.d.ts.map +1 -0
- package/dist/cli/design-verification-builder.js +369 -0
- package/dist/cli/design-verification-builder.js.map +1 -0
- package/dist/cli/index.js +20 -6
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/paths.d.ts.map +1 -1
- package/dist/cli/paths.js +30 -7
- package/dist/cli/paths.js.map +1 -1
- package/dist/cli-new/commands/server.d.ts +13 -0
- package/dist/cli-new/commands/server.d.ts.map +1 -0
- package/dist/cli-new/commands/server.js +90 -0
- package/dist/cli-new/commands/server.js.map +1 -0
- package/dist/core/analyzer.d.ts.map +1 -1
- package/dist/core/analyzer.js +16 -0
- package/dist/core/analyzer.js.map +1 -1
- package/dist/domain/entities/CodeGraph.d.ts +5 -1
- package/dist/domain/entities/CodeGraph.d.ts.map +1 -1
- package/dist/domain/entities/CodeGraph.js +29 -12
- package/dist/domain/entities/CodeGraph.js.map +1 -1
- package/dist/domain/entities/Dependency.d.ts +8 -1
- package/dist/domain/entities/Dependency.d.ts.map +1 -1
- package/dist/domain/entities/Dependency.js +19 -4
- package/dist/domain/entities/Dependency.js.map +1 -1
- package/dist/domain/entities/Symbol.d.ts +2 -1
- package/dist/domain/entities/Symbol.d.ts.map +1 -1
- package/dist/domain/entities/Symbol.js +6 -3
- package/dist/domain/entities/Symbol.js.map +1 -1
- package/dist/generator/ai-overview.d.ts +51 -0
- package/dist/generator/ai-overview.d.ts.map +1 -0
- package/dist/generator/ai-overview.js +160 -0
- package/dist/generator/ai-overview.js.map +1 -0
- package/dist/infrastructure/storage/StorageFactory.d.ts +13 -5
- package/dist/infrastructure/storage/StorageFactory.d.ts.map +1 -1
- package/dist/infrastructure/storage/StorageFactory.js +62 -16
- package/dist/infrastructure/storage/StorageFactory.js.map +1 -1
- package/dist/infrastructure/storage/adapters/FileSystemStorage.d.ts +3 -1
- package/dist/infrastructure/storage/adapters/FileSystemStorage.d.ts.map +1 -1
- package/dist/infrastructure/storage/adapters/FileSystemStorage.js +10 -2
- package/dist/infrastructure/storage/adapters/FileSystemStorage.js.map +1 -1
- package/dist/infrastructure/storage/adapters/KuzuDBStorage.d.ts +3 -1
- package/dist/infrastructure/storage/adapters/KuzuDBStorage.d.ts.map +1 -1
- package/dist/infrastructure/storage/adapters/KuzuDBStorage.js +9 -1
- package/dist/infrastructure/storage/adapters/KuzuDBStorage.js.map +1 -1
- package/dist/infrastructure/storage/adapters/MemoryStorage.d.ts +3 -1
- package/dist/infrastructure/storage/adapters/MemoryStorage.d.ts.map +1 -1
- package/dist/infrastructure/storage/adapters/MemoryStorage.js +9 -1
- package/dist/infrastructure/storage/adapters/MemoryStorage.js.map +1 -1
- package/dist/infrastructure/storage/adapters/Neo4jStorage.d.ts +41 -0
- package/dist/infrastructure/storage/adapters/Neo4jStorage.d.ts.map +1 -0
- package/dist/infrastructure/storage/adapters/Neo4jStorage.js +162 -0
- package/dist/infrastructure/storage/adapters/Neo4jStorage.js.map +1 -0
- package/dist/infrastructure/storage/adapters/SQLiteStorage.d.ts +53 -0
- package/dist/infrastructure/storage/adapters/SQLiteStorage.d.ts.map +1 -0
- package/dist/infrastructure/storage/adapters/SQLiteStorage.js +879 -0
- package/dist/infrastructure/storage/adapters/SQLiteStorage.js.map +1 -0
- package/dist/infrastructure/storage/graph-helpers.d.ts +3 -1
- package/dist/infrastructure/storage/graph-helpers.d.ts.map +1 -1
- package/dist/infrastructure/storage/graph-helpers.js +90 -0
- package/dist/infrastructure/storage/graph-helpers.js.map +1 -1
- package/dist/infrastructure/storage/index.d.ts +1 -1
- package/dist/infrastructure/storage/index.d.ts.map +1 -1
- package/dist/infrastructure/storage/interfaces/StorageBase.d.ts +3 -1
- package/dist/infrastructure/storage/interfaces/StorageBase.d.ts.map +1 -1
- package/dist/infrastructure/storage/interfaces/StorageBase.js.map +1 -1
- package/dist/infrastructure/storage/sqlite/GovernanceGraphCache.d.ts +27 -0
- package/dist/infrastructure/storage/sqlite/GovernanceGraphCache.d.ts.map +1 -0
- package/dist/infrastructure/storage/sqlite/GovernanceGraphCache.js +246 -0
- package/dist/infrastructure/storage/sqlite/GovernanceGraphCache.js.map +1 -0
- package/dist/infrastructure/storage/sqlite/perf-thresholds.d.ts +25 -0
- package/dist/infrastructure/storage/sqlite/perf-thresholds.d.ts.map +1 -0
- package/dist/infrastructure/storage/sqlite/perf-thresholds.js +25 -0
- package/dist/infrastructure/storage/sqlite/perf-thresholds.js.map +1 -0
- package/dist/infrastructure/storage/sqlite/schema.d.ts +4 -0
- package/dist/infrastructure/storage/sqlite/schema.d.ts.map +1 -0
- package/dist/infrastructure/storage/sqlite/schema.js +111 -0
- package/dist/infrastructure/storage/sqlite/schema.js.map +1 -0
- package/dist/interface/types/design-check.d.ts +73 -0
- package/dist/interface/types/design-check.d.ts.map +1 -0
- package/dist/interface/types/design-check.js +4 -0
- package/dist/interface/types/design-check.js.map +1 -0
- package/dist/interface/types/design-contract.d.ts +123 -0
- package/dist/interface/types/design-contract.d.ts.map +1 -0
- package/dist/interface/types/design-contract.js +7 -0
- package/dist/interface/types/design-contract.js.map +1 -0
- package/dist/interface/types/design-handoff.d.ts +68 -0
- package/dist/interface/types/design-handoff.d.ts.map +1 -0
- package/dist/interface/types/design-handoff.js +4 -0
- package/dist/interface/types/design-handoff.js.map +1 -0
- package/dist/interface/types/design-mapping.d.ts +51 -0
- package/dist/interface/types/design-mapping.d.ts.map +1 -0
- package/dist/interface/types/design-mapping.js +4 -0
- package/dist/interface/types/design-mapping.js.map +1 -0
- package/dist/interface/types/design-verification.d.ts +49 -0
- package/dist/interface/types/design-verification.d.ts.map +1 -0
- package/dist/interface/types/design-verification.js +4 -0
- package/dist/interface/types/design-verification.js.map +1 -0
- package/dist/interface/types/history-risk.d.ts +90 -0
- package/dist/interface/types/history-risk.d.ts.map +1 -0
- package/dist/interface/types/history-risk.js +4 -0
- package/dist/interface/types/history-risk.js.map +1 -0
- package/dist/interface/types/index.d.ts +20 -1
- package/dist/interface/types/index.d.ts.map +1 -1
- package/dist/interface/types/storage.d.ts +28 -1
- package/dist/interface/types/storage.d.ts.map +1 -1
- package/dist/orchestrator/adapters/ast-grep-adapter.d.ts +10 -0
- package/dist/orchestrator/adapters/ast-grep-adapter.d.ts.map +1 -1
- package/dist/orchestrator/adapters/ast-grep-adapter.js +46 -17
- package/dist/orchestrator/adapters/ast-grep-adapter.js.map +1 -1
- package/dist/orchestrator/adapters/codemap-adapter.d.ts.map +1 -1
- package/dist/orchestrator/adapters/codemap-adapter.js +2 -22
- package/dist/orchestrator/adapters/codemap-adapter.js.map +1 -1
- package/dist/orchestrator/ai-feed-generator.d.ts +210 -0
- package/dist/orchestrator/ai-feed-generator.d.ts.map +1 -0
- package/dist/orchestrator/ai-feed-generator.js +377 -0
- package/dist/orchestrator/ai-feed-generator.js.map +1 -0
- package/dist/orchestrator/history-risk-service.d.ts +55 -0
- package/dist/orchestrator/history-risk-service.d.ts.map +1 -0
- package/dist/orchestrator/history-risk-service.js +680 -0
- package/dist/orchestrator/history-risk-service.js.map +1 -0
- package/dist/orchestrator/types.d.ts +19 -1
- package/dist/orchestrator/types.d.ts.map +1 -1
- package/dist/orchestrator/types.js +19 -0
- package/dist/orchestrator/types.js.map +1 -1
- package/dist/server/mcp/index.d.ts +4 -0
- package/dist/server/mcp/index.d.ts.map +1 -0
- package/dist/server/mcp/index.js +5 -0
- package/dist/server/mcp/index.js.map +1 -0
- package/dist/server/mcp/server.d.ts +17 -0
- package/dist/server/mcp/server.d.ts.map +1 -0
- package/dist/server/mcp/server.js +84 -0
- package/dist/server/mcp/server.js.map +1 -0
- package/dist/server/mcp/service.d.ts +22 -0
- package/dist/server/mcp/service.d.ts.map +1 -0
- package/dist/server/mcp/service.js +177 -0
- package/dist/server/mcp/service.js.map +1 -0
- package/dist/server/mcp/types.d.ts +56 -0
- package/dist/server/mcp/types.d.ts.map +1 -0
- package/dist/server/mcp/types.js +4 -0
- package/dist/server/mcp/types.js.map +1 -0
- package/docs/AI_ASSISTANT_SETUP.md +1 -1
- package/docs/SETUP_GUIDE.md +6 -6
- package/docs/ai-guide/COMMANDS.md +171 -4
- package/docs/ai-guide/INTEGRATION.md +137 -433
- package/docs/ai-guide/OUTPUT.md +890 -5
- package/docs/ai-guide/PATTERNS.md +54 -14
- package/docs/ai-guide/PROMPTS.md +17 -6
- package/docs/archive/test-report-symbol-search.md +384 -0
- package/docs/archive/test-scenario-4-complexity-analysis.md +460 -0
- package/docs/archive/test_report_scenario5.md +615 -0
- package/docs/archive/test_scenario_3_impact_analysis_report.md +520 -0
- package/docs/backlog.md +177 -0
- package/docs/eatdogfood-reports/2026-04-17-eatdogfood-agent-experience.md +231 -0
- package/docs/exec-plans/completed/2026-04-17-eatdogfood-codemap-cli.md +103 -0
- package/docs/ideation/2026-04-15-executable-architecture-constitution-ideation.md +102 -0
- package/docs/product-specs/DESIGN_CONTRACT_TEMPLATE.md +126 -0
- package/docs/product-specs/MVP3-ARCHITECTURE-COMPARISON.md +11 -10
- package/docs/product-specs/MVP3-ARCHITECTURE-REDESIGN-PRD.md +10 -10
- package/docs/product-specs/MVP3-ARCHITECTURE-REDESIGN-TECH-PRD.md +17 -12
- package/docs/product-specs/README.md +2 -1
- package/docs/rules/README.md +16 -11
- package/docs/rules/architecture-guardrails.md +24 -336
- package/docs/rules/code-quality-redlines.md +25 -311
- package/docs/rules/engineering-with-codex-openai.md +20 -3
- package/docs/rules/validation.md +90 -37
- package/mycodemap.config.schema.json +3 -3
- package/package.json +7 -2
- package/scripts/benchmark-governance-graph.mjs +132 -0
- package/scripts/calibrate-contract-gate.mjs +221 -0
- package/scripts/capability-report.py +255 -0
- package/scripts/experiments/arcadedb-http-smoke.mjs +90 -0
- package/scripts/qa-rule-control.sh +254 -0
- package/scripts/report-high-risk-files.mjs +395 -0
- package/scripts/rule-context.mjs +155 -0
- package/scripts/smoke-sqlite-impact.mjs +85 -0
- package/scripts/sync-analyze-docs.js +1 -0
- package/scripts/tests/test_capability_report.py +89 -0
- package/scripts/tests/test_rule_control_workflow.py +51 -0
- package/scripts/tests/test_validate_rules.py +81 -0
- package/scripts/validate-ai-docs.js +283 -1
- package/scripts/validate-docs.js +479 -25
- package/scripts/validate-rules.py +254 -0
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import json
|
|
7
|
+
import subprocess
|
|
8
|
+
import sys
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
from typing import Any, Callable, Sequence
|
|
11
|
+
|
|
12
|
+
REPO_ROOT = Path(__file__).resolve().parent.parent
|
|
13
|
+
DIST_CLI_PATH = REPO_ROOT / "dist" / "cli" / "index.js"
|
|
14
|
+
ALLOWED_LEVELS = ("P0", "P1", "P2")
|
|
15
|
+
ALLOWED_STATUSES = ("passed", "failed", "unavailable")
|
|
16
|
+
TYPECHECK_COMMAND = "npm run typecheck"
|
|
17
|
+
TEST_COMMAND = "npm test"
|
|
18
|
+
LINT_COMMAND = "npm run lint"
|
|
19
|
+
ARCH_COMMAND = "node dist/cli/index.js deps -m src/domain"
|
|
20
|
+
Runner = Callable[[Sequence[str]], dict[str, str]]
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def command_to_string(command: Sequence[str]) -> str:
|
|
24
|
+
return " ".join(command)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def combine_output(stdout: str | None, stderr: str | None) -> str:
|
|
28
|
+
parts = [part.strip() for part in (stdout, stderr) if part and part.strip()]
|
|
29
|
+
if parts:
|
|
30
|
+
return "\n".join(parts)
|
|
31
|
+
return "(no output)"
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def run_command(command: Sequence[str]) -> dict[str, str]:
|
|
35
|
+
try:
|
|
36
|
+
completed = subprocess.run(
|
|
37
|
+
list(command),
|
|
38
|
+
cwd=REPO_ROOT,
|
|
39
|
+
capture_output=True,
|
|
40
|
+
text=True,
|
|
41
|
+
timeout=300,
|
|
42
|
+
check=False,
|
|
43
|
+
)
|
|
44
|
+
except FileNotFoundError as error:
|
|
45
|
+
return {"status": "unavailable", "output": str(error)}
|
|
46
|
+
except OSError as error:
|
|
47
|
+
return {"status": "unavailable", "output": str(error)}
|
|
48
|
+
except subprocess.TimeoutExpired as error:
|
|
49
|
+
return {
|
|
50
|
+
"status": "failed",
|
|
51
|
+
"output": combine_output(error.stdout, error.stderr)
|
|
52
|
+
+ "\nCommand timed out after 300 seconds.",
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
"status": "passed" if completed.returncode == 0 else "failed",
|
|
57
|
+
"output": combine_output(completed.stdout, completed.stderr),
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def make_check(
|
|
62
|
+
name: str,
|
|
63
|
+
level: str,
|
|
64
|
+
command: Sequence[str],
|
|
65
|
+
status: str,
|
|
66
|
+
output: str,
|
|
67
|
+
) -> dict[str, str]:
|
|
68
|
+
if level not in ALLOWED_LEVELS:
|
|
69
|
+
raise ValueError(f"Unsupported level: {level}")
|
|
70
|
+
if status not in ALLOWED_STATUSES:
|
|
71
|
+
raise ValueError(f"Unsupported status: {status}")
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
"name": name,
|
|
75
|
+
"level": level,
|
|
76
|
+
"status": status,
|
|
77
|
+
"command": command_to_string(command),
|
|
78
|
+
"output": output,
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def code_check_specs() -> list[dict[str, Any]]:
|
|
83
|
+
return [
|
|
84
|
+
{
|
|
85
|
+
"name": "typecheck",
|
|
86
|
+
"level": "P0",
|
|
87
|
+
"command": TYPECHECK_COMMAND.split(),
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"name": "test",
|
|
91
|
+
"level": "P0",
|
|
92
|
+
"command": TEST_COMMAND.split(),
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"name": "lint",
|
|
96
|
+
"level": "P1",
|
|
97
|
+
"command": LINT_COMMAND.split(),
|
|
98
|
+
},
|
|
99
|
+
]
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def arch_check_specs(dist_cli_path: Path = DIST_CLI_PATH) -> list[dict[str, Any]]:
|
|
103
|
+
command = ARCH_COMMAND.split()
|
|
104
|
+
if not dist_cli_path.exists():
|
|
105
|
+
return [
|
|
106
|
+
make_check(
|
|
107
|
+
name="architecture-domain-deps",
|
|
108
|
+
level="P0",
|
|
109
|
+
command=command,
|
|
110
|
+
status="unavailable",
|
|
111
|
+
output=f"dist CLI is unavailable: {dist_cli_path} was not found.",
|
|
112
|
+
)
|
|
113
|
+
]
|
|
114
|
+
|
|
115
|
+
return [
|
|
116
|
+
{
|
|
117
|
+
"name": "architecture-domain-deps",
|
|
118
|
+
"level": "P0",
|
|
119
|
+
"command": command,
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def build_specs(target: str, dist_cli_path: Path = DIST_CLI_PATH) -> list[dict[str, Any]]:
|
|
125
|
+
if target == "code":
|
|
126
|
+
return code_check_specs()
|
|
127
|
+
if target == "arch":
|
|
128
|
+
return arch_check_specs(dist_cli_path=dist_cli_path)
|
|
129
|
+
if target == "all":
|
|
130
|
+
return code_check_specs() + arch_check_specs(dist_cli_path=dist_cli_path)
|
|
131
|
+
raise ValueError(f"Unsupported target: {target}")
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def execute_checks(
|
|
135
|
+
target: str,
|
|
136
|
+
runner: Runner = run_command,
|
|
137
|
+
dist_cli_path: Path = DIST_CLI_PATH,
|
|
138
|
+
) -> list[dict[str, str]]:
|
|
139
|
+
checks: list[dict[str, str]] = []
|
|
140
|
+
|
|
141
|
+
for spec in build_specs(target=target, dist_cli_path=dist_cli_path):
|
|
142
|
+
if "status" in spec:
|
|
143
|
+
checks.append(spec)
|
|
144
|
+
continue
|
|
145
|
+
|
|
146
|
+
result = runner(spec["command"])
|
|
147
|
+
checks.append(
|
|
148
|
+
make_check(
|
|
149
|
+
name=spec["name"],
|
|
150
|
+
level=spec["level"],
|
|
151
|
+
command=spec["command"],
|
|
152
|
+
status=result["status"],
|
|
153
|
+
output=result["output"],
|
|
154
|
+
)
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
return checks
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def count_checks(checks: list[dict[str, str]], *, status: str, level: str | None = None) -> int:
|
|
161
|
+
return sum(
|
|
162
|
+
1
|
|
163
|
+
for check in checks
|
|
164
|
+
if check["status"] == status and (level is None or check["level"] == level)
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def resolve_exit_code(checks: list[dict[str, str]], report_only: bool) -> int:
|
|
169
|
+
if report_only:
|
|
170
|
+
return 0
|
|
171
|
+
if any(check["status"] == "unavailable" for check in checks):
|
|
172
|
+
return 4
|
|
173
|
+
if any(check["status"] == "failed" and check["level"] == "P0" for check in checks):
|
|
174
|
+
return 1
|
|
175
|
+
if any(check["status"] == "failed" and check["level"] == "P1" for check in checks):
|
|
176
|
+
return 2
|
|
177
|
+
if any(check["status"] == "failed" and check["level"] == "P2" for check in checks):
|
|
178
|
+
return 3
|
|
179
|
+
return 0
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def build_summary(checks: list[dict[str, str]], exit_code: int, report_only: bool) -> dict[str, Any]:
|
|
183
|
+
return {
|
|
184
|
+
"reportOnly": report_only,
|
|
185
|
+
"exitCode": exit_code,
|
|
186
|
+
"failedByLevel": {
|
|
187
|
+
level: count_checks(checks, status="failed", level=level)
|
|
188
|
+
for level in ALLOWED_LEVELS
|
|
189
|
+
},
|
|
190
|
+
"passed": count_checks(checks, status="passed"),
|
|
191
|
+
"unavailable": count_checks(checks, status="unavailable"),
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def build_report(target: str, checks: list[dict[str, str]], report_only: bool) -> dict[str, Any]:
|
|
196
|
+
exit_code = resolve_exit_code(checks, report_only=report_only)
|
|
197
|
+
return {
|
|
198
|
+
"target": target,
|
|
199
|
+
"checks": checks,
|
|
200
|
+
"summary": build_summary(checks, exit_code=exit_code, report_only=report_only),
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
def summary_text(report: dict[str, Any]) -> str:
|
|
205
|
+
summary = report["summary"]
|
|
206
|
+
failed = summary["failedByLevel"]
|
|
207
|
+
return (
|
|
208
|
+
"SUMMARY "
|
|
209
|
+
f"target={report['target']} "
|
|
210
|
+
f"report_only={str(summary['reportOnly']).lower()} "
|
|
211
|
+
f"exit_code={summary['exitCode']} "
|
|
212
|
+
f"P0={failed['P0']} "
|
|
213
|
+
f"P1={failed['P1']} "
|
|
214
|
+
f"P2={failed['P2']} "
|
|
215
|
+
f"unavailable={summary['unavailable']}"
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
def parse_args(argv: Sequence[str]) -> argparse.Namespace:
|
|
220
|
+
parser = argparse.ArgumentParser(
|
|
221
|
+
description="Validate repo-local rule checks for code and architecture gates."
|
|
222
|
+
)
|
|
223
|
+
parser.add_argument("target", choices=("code", "arch", "all"))
|
|
224
|
+
parser.add_argument("--report-only", action="store_true", dest="report_only")
|
|
225
|
+
return parser.parse_args(argv)
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
def exit_process(exit_code: int) -> None:
|
|
229
|
+
if exit_code == 0:
|
|
230
|
+
sys.exit(0)
|
|
231
|
+
if exit_code == 1:
|
|
232
|
+
sys.exit(1)
|
|
233
|
+
if exit_code == 2:
|
|
234
|
+
sys.exit(2)
|
|
235
|
+
if exit_code == 3:
|
|
236
|
+
sys.exit(3)
|
|
237
|
+
sys.exit(4)
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
def main(argv: Sequence[str] | None = None) -> int:
|
|
241
|
+
args = parse_args(argv if argv is not None else sys.argv[1:])
|
|
242
|
+
report = build_report(
|
|
243
|
+
target=args.target,
|
|
244
|
+
checks=execute_checks(target=args.target),
|
|
245
|
+
report_only=args.report_only,
|
|
246
|
+
)
|
|
247
|
+
json.dump(report, sys.stdout, ensure_ascii=False, indent=2)
|
|
248
|
+
sys.stdout.write("\n")
|
|
249
|
+
print(summary_text(report), file=sys.stderr)
|
|
250
|
+
return int(report["summary"]["exitCode"])
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
if __name__ == "__main__":
|
|
254
|
+
exit_process(main())
|