@mytechtoday/augment-extensions 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/augment-extensions/coding-standards/c/CHANGELOG.md +55 -0
- package/augment-extensions/coding-standards/c/LICENSE +22 -0
- package/augment-extensions/coding-standards/c/README.md +167 -0
- package/augment-extensions/coding-standards/c/config/defaults.json +26 -0
- package/augment-extensions/coding-standards/c/config/examples/embedded.yaml +25 -0
- package/augment-extensions/coding-standards/c/config/examples/systems.json +31 -0
- package/augment-extensions/coding-standards/c/config/schema.json +244 -0
- package/augment-extensions/coding-standards/c/docs/API.md +613 -0
- package/augment-extensions/coding-standards/c/docs/CONFIGURATION.md +259 -0
- package/augment-extensions/coding-standards/c/docs/USER_GUIDE.md +567 -0
- package/augment-extensions/coding-standards/c/examples/drivers/Makefile +33 -0
- package/augment-extensions/coding-standards/c/examples/drivers/README.md +192 -0
- package/augment-extensions/coding-standards/c/examples/drivers/dma-example.c +224 -0
- package/augment-extensions/coding-standards/c/examples/drivers/example.dts +64 -0
- package/augment-extensions/coding-standards/c/examples/drivers/platform-driver.c +174 -0
- package/augment-extensions/coding-standards/c/examples/embedded/README.md +167 -0
- package/augment-extensions/coding-standards/c/examples/embedded/gpio-control.c +172 -0
- package/augment-extensions/coding-standards/c/examples/embedded/timer-isr.c +198 -0
- package/augment-extensions/coding-standards/c/examples/embedded/uart-communication.c +212 -0
- package/augment-extensions/coding-standards/c/examples/kernel/Makefile +82 -0
- package/augment-extensions/coding-standards/c/examples/kernel/README.md +168 -0
- package/augment-extensions/coding-standards/c/examples/kernel/char-device.c +198 -0
- package/augment-extensions/coding-standards/c/examples/kernel/proc-file.c +131 -0
- package/augment-extensions/coding-standards/c/examples/kernel/simple-module.c +111 -0
- package/augment-extensions/coding-standards/c/examples/legacy/Makefile +62 -0
- package/augment-extensions/coding-standards/c/examples/legacy/README.md +255 -0
- package/augment-extensions/coding-standards/c/examples/legacy/c89-to-c11-migration.c +268 -0
- package/augment-extensions/coding-standards/c/examples/legacy/compatibility-layer.c +239 -0
- package/augment-extensions/coding-standards/c/examples/networking/Makefile +35 -0
- package/augment-extensions/coding-standards/c/examples/networking/README.md +207 -0
- package/augment-extensions/coding-standards/c/examples/networking/protocol-parser.c +270 -0
- package/augment-extensions/coding-standards/c/examples/networking/tcp-server.c +197 -0
- package/augment-extensions/coding-standards/c/examples/networking/udp-multicast.c +220 -0
- package/augment-extensions/coding-standards/c/examples/realtime/Makefile +53 -0
- package/augment-extensions/coding-standards/c/examples/realtime/README.md +199 -0
- package/augment-extensions/coding-standards/c/examples/realtime/deadline-monitoring.c +260 -0
- package/augment-extensions/coding-standards/c/examples/realtime/priority-scheduling.c +258 -0
- package/augment-extensions/coding-standards/c/examples/systems/Makefile +34 -0
- package/augment-extensions/coding-standards/c/examples/systems/README.md +123 -0
- package/augment-extensions/coding-standards/c/examples/systems/ipc-pipes.c +181 -0
- package/augment-extensions/coding-standards/c/examples/systems/process-management.c +153 -0
- package/augment-extensions/coding-standards/c/examples/systems/signal-handling.c +162 -0
- package/augment-extensions/coding-standards/c/module.json +149 -0
- package/augment-extensions/coding-standards/c/rules/categories/drivers.md +635 -0
- package/augment-extensions/coding-standards/c/rules/categories/embedded.md +510 -0
- package/augment-extensions/coding-standards/c/rules/categories/kernel.md +653 -0
- package/augment-extensions/coding-standards/c/rules/categories/legacy.md +526 -0
- package/augment-extensions/coding-standards/c/rules/categories/networking.md +735 -0
- package/augment-extensions/coding-standards/c/rules/categories/realtime.md +631 -0
- package/augment-extensions/coding-standards/c/rules/categories/systems.md +586 -0
- package/augment-extensions/coding-standards/c/rules/universal/const-correctness.md +275 -0
- package/augment-extensions/coding-standards/c/rules/universal/documentation.md +251 -0
- package/augment-extensions/coding-standards/c/rules/universal/error-handling.md +250 -0
- package/augment-extensions/coding-standards/c/rules/universal/header-guards.md +254 -0
- package/augment-extensions/coding-standards/c/rules/universal/memory-safety.md +233 -0
- package/augment-extensions/coding-standards/c/rules/universal/naming.md +146 -0
- package/augment-extensions/coding-standards/c/src/conflict-detector.ts +461 -0
- package/augment-extensions/coding-standards/c/src/prompt-generator.ts +307 -0
- package/augment-extensions/coding-standards/c/src/rule-evaluator.ts +307 -0
- package/augment-extensions/coding-standards/c/src/rule-override.ts +427 -0
- package/augment-extensions/coding-standards/c/src/template-engine.ts +217 -0
- package/augment-extensions/coding-standards/c/templates/prompts/drivers.txt +191 -0
- package/augment-extensions/coding-standards/c/templates/prompts/embedded.txt +164 -0
- package/augment-extensions/coding-standards/c/templates/prompts/kernel.txt +175 -0
- package/augment-extensions/coding-standards/c/templates/prompts/legacy.txt +280 -0
- package/augment-extensions/coding-standards/c/templates/prompts/networking.txt +259 -0
- package/augment-extensions/coding-standards/c/templates/prompts/realtime.txt +219 -0
- package/augment-extensions/coding-standards/c/templates/prompts/systems.txt +147 -0
- package/augment-extensions/coding-standards/c/tests/integration/category-specific.test.ts +356 -0
- package/augment-extensions/coding-standards/c/tests/integration/end-to-end-workflow.test.ts +377 -0
- package/augment-extensions/coding-standards/c/tests/performance/benchmarks.test.ts +407 -0
- package/augment-extensions/coding-standards/c/tests/unit/config-manager.test.ts +345 -0
- package/augment-extensions/coding-standards/c/tests/unit/conflict-detector.test.ts +294 -0
- package/augment-extensions/coding-standards/c/tests/unit/prompt-generator.test.ts +174 -0
- package/augment-extensions/coding-standards/c/tests/unit/registry.test.ts +313 -0
- package/augment-extensions/coding-standards/c/tests/unit/rule-evaluator.test.ts +318 -0
- package/augment-extensions/coding-standards/c/tests/unit/rule-override.test.ts +326 -0
- package/augment-extensions/coding-standards/c/tests/unit/template-engine.test.ts +314 -0
- package/augment-extensions/coding-standards/go/CHARACTER-COUNT-REPORT.md +135 -0
- package/augment-extensions/coding-standards/go/PHASE1-COMPLETION.md +146 -0
- package/augment-extensions/coding-standards/go/PHASE4-COMPLETION.md +184 -0
- package/augment-extensions/coding-standards/go/README.md +200 -0
- package/augment-extensions/coding-standards/go/VALIDATION-CHECKLIST.md +154 -0
- package/augment-extensions/coding-standards/go/config/examples/example-cli.json +15 -0
- package/augment-extensions/coding-standards/go/config/examples/example-microservices.json +21 -0
- package/augment-extensions/coding-standards/go/config/examples/example-multi-category.yaml +24 -0
- package/augment-extensions/coding-standards/go/config/examples/example-web.json +15 -0
- package/augment-extensions/coding-standards/go/config/schema.json +110 -0
- package/augment-extensions/coding-standards/go/docs/CATEGORIES.md +221 -0
- package/augment-extensions/coding-standards/go/docs/CONFIGURATION.md +198 -0
- package/augment-extensions/coding-standards/go/docs/TROUBLESHOOTING.md +285 -0
- package/augment-extensions/coding-standards/go/examples/cli/cobra-app.go +287 -0
- package/augment-extensions/coding-standards/go/examples/cloud-native-app.go +217 -0
- package/augment-extensions/coding-standards/go/examples/devops-tool.go +250 -0
- package/augment-extensions/coding-standards/go/examples/distributed-system.go +247 -0
- package/augment-extensions/coding-standards/go/examples/microservices/grpc-service.go +253 -0
- package/augment-extensions/coding-standards/go/examples/rest-api.go +270 -0
- package/augment-extensions/coding-standards/go/examples/web/http-server.go +224 -0
- package/augment-extensions/coding-standards/go/module.json +139 -0
- package/augment-extensions/coding-standards/go/rules/categories/api-development/api-versioning.md +149 -0
- package/augment-extensions/coding-standards/go/rules/categories/api-development/rate-limiting.md +209 -0
- package/augment-extensions/coding-standards/go/rules/categories/api-development/rest-api-design.md +183 -0
- package/augment-extensions/coding-standards/go/rules/categories/cloud-native/cloud-config.md +193 -0
- package/augment-extensions/coding-standards/go/rules/categories/cloud-native/health-checks.md +231 -0
- package/augment-extensions/coding-standards/go/rules/categories/cloud-native/kubernetes.md +180 -0
- package/augment-extensions/coding-standards/go/rules/categories/devops-tooling/automation.md +179 -0
- package/augment-extensions/coding-standards/go/rules/categories/devops-tooling/ci-cd-integration.md +147 -0
- package/augment-extensions/coding-standards/go/rules/categories/devops-tooling/infrastructure-as-code.md +231 -0
- package/augment-extensions/coding-standards/go/rules/categories/distributed-systems/caching.md +150 -0
- package/augment-extensions/coding-standards/go/rules/categories/distributed-systems/consensus.md +187 -0
- package/augment-extensions/coding-standards/go/rules/categories/distributed-systems/event-sourcing.md +246 -0
- package/augment-extensions/coding-standards/go/rules/cli/command-parsing.md +264 -0
- package/augment-extensions/coding-standards/go/rules/cli/configuration.md +268 -0
- package/augment-extensions/coding-standards/go/rules/cli/cross-platform.md +324 -0
- package/augment-extensions/coding-standards/go/rules/microservices/distributed-tracing.md +253 -0
- package/augment-extensions/coding-standards/go/rules/microservices/grpc.md +257 -0
- package/augment-extensions/coding-standards/go/rules/microservices/metrics.md +278 -0
- package/augment-extensions/coding-standards/go/rules/microservices/service-discovery.md +249 -0
- package/augment-extensions/coding-standards/go/rules/universal/code-organization.md +221 -0
- package/augment-extensions/coding-standards/go/rules/universal/documentation.md +269 -0
- package/augment-extensions/coding-standards/go/rules/universal/performance.md +323 -0
- package/augment-extensions/coding-standards/go/rules/universal/testing.md +162 -0
- package/augment-extensions/coding-standards/go/rules/web/graceful-shutdown.md +249 -0
- package/augment-extensions/coding-standards/go/rules/web/http-handlers.md +164 -0
- package/augment-extensions/coding-standards/go/rules/web/middleware.md +234 -0
- package/augment-extensions/coding-standards/go/rules/web/routing.md +251 -0
- package/augment-extensions/coding-standards/go/templates/prompts/api.md +160 -0
- package/augment-extensions/coding-standards/go/templates/prompts/cli.md +225 -0
- package/augment-extensions/coding-standards/go/templates/prompts/cloud-native.md +121 -0
- package/augment-extensions/coding-standards/go/templates/prompts/devops.md +146 -0
- package/augment-extensions/coding-standards/go/templates/prompts/distributed.md +133 -0
- package/augment-extensions/coding-standards/go/templates/prompts/microservices.md +225 -0
- package/augment-extensions/coding-standards/go/templates/prompts/web.md +181 -0
- package/augment-extensions/coding-standards/go/tests/integration/module-integration.test.ts +164 -0
- package/augment-extensions/coding-standards/go/tests/unit/category-selection.test.ts +147 -0
- package/augment-extensions/coding-standards/go/tests/unit/module-structure.test.ts +154 -0
- package/augment-extensions/coding-standards/go/tests/validate-character-count.ps1 +13 -0
- package/augment-extensions/coding-standards/go/tests/validate-examples.ps1 +148 -0
- package/augment-extensions/coding-standards/go/tests/validate-examples.sh +135 -0
- package/cli/dist/analysis/ast-parser.d.ts +47 -0
- package/cli/dist/analysis/ast-parser.d.ts.map +1 -0
- package/cli/dist/analysis/ast-parser.js +161 -0
- package/cli/dist/analysis/ast-parser.js.map +1 -0
- package/cli/dist/analysis/complexity-analyzer.d.ts +27 -0
- package/cli/dist/analysis/complexity-analyzer.d.ts.map +1 -0
- package/cli/dist/analysis/complexity-analyzer.js +189 -0
- package/cli/dist/analysis/complexity-analyzer.js.map +1 -0
- package/cli/dist/analysis/dependency-analyzer.d.ts +23 -0
- package/cli/dist/analysis/dependency-analyzer.d.ts.map +1 -0
- package/cli/dist/analysis/dependency-analyzer.js +237 -0
- package/cli/dist/analysis/dependency-analyzer.js.map +1 -0
- package/cli/dist/analysis/index.d.ts +9 -0
- package/cli/dist/analysis/index.d.ts.map +1 -0
- package/cli/dist/analysis/index.js +25 -0
- package/cli/dist/analysis/index.js.map +1 -0
- package/cli/dist/analysis/security-scanner.d.ts +11 -0
- package/cli/dist/analysis/security-scanner.d.ts.map +1 -0
- package/cli/dist/analysis/security-scanner.js +294 -0
- package/cli/dist/analysis/security-scanner.js.map +1 -0
- package/cli/dist/analysis/types.d.ts +151 -0
- package/cli/dist/analysis/types.d.ts.map +1 -0
- package/cli/dist/analysis/types.js +6 -0
- package/cli/dist/analysis/types.js.map +1 -0
- package/cli/dist/cli.js +24 -0
- package/cli/dist/cli.js.map +1 -1
- package/cli/dist/commands/code-analysis.d.ts +11 -0
- package/cli/dist/commands/code-analysis.d.ts.map +1 -0
- package/cli/dist/commands/code-analysis.js +412 -0
- package/cli/dist/commands/code-analysis.js.map +1 -0
- package/modules.md +99 -3
- package/package.json +14 -2
- package/cli/dist/commands/agent.d.ts +0 -37
- package/cli/dist/commands/agent.d.ts.map +0 -1
- package/cli/dist/commands/agent.js +0 -222
- package/cli/dist/commands/agent.js.map +0 -1
- package/cli/dist/commands/beads.d.ts +0 -64
- package/cli/dist/commands/beads.d.ts.map +0 -1
- package/cli/dist/commands/beads.js +0 -377
- package/cli/dist/commands/beads.js.map +0 -1
- package/cli/dist/commands/change.d.ts +0 -54
- package/cli/dist/commands/change.d.ts.map +0 -1
- package/cli/dist/commands/change.js +0 -243
- package/cli/dist/commands/change.js.map +0 -1
- package/cli/dist/commands/clean.d.ts +0 -15
- package/cli/dist/commands/clean.d.ts.map +0 -1
- package/cli/dist/commands/clean.js +0 -63
- package/cli/dist/commands/clean.js.map +0 -1
- package/cli/dist/commands/clone.d.ts +0 -15
- package/cli/dist/commands/clone.d.ts.map +0 -1
- package/cli/dist/commands/clone.js +0 -49
- package/cli/dist/commands/clone.js.map +0 -1
- package/cli/dist/commands/config.d.ts +0 -33
- package/cli/dist/commands/config.d.ts.map +0 -1
- package/cli/dist/commands/config.js +0 -166
- package/cli/dist/commands/config.js.map +0 -1
- package/cli/dist/commands/context.d.ts +0 -38
- package/cli/dist/commands/context.d.ts.map +0 -1
- package/cli/dist/commands/context.js +0 -205
- package/cli/dist/commands/context.js.map +0 -1
- package/cli/dist/commands/create.d.ts +0 -18
- package/cli/dist/commands/create.d.ts.map +0 -1
- package/cli/dist/commands/create.js +0 -178
- package/cli/dist/commands/create.js.map +0 -1
- package/cli/dist/commands/diff.d.ts +0 -19
- package/cli/dist/commands/diff.d.ts.map +0 -1
- package/cli/dist/commands/diff.js +0 -104
- package/cli/dist/commands/diff.js.map +0 -1
- package/cli/dist/commands/doctor.d.ts +0 -14
- package/cli/dist/commands/doctor.d.ts.map +0 -1
- package/cli/dist/commands/doctor.js +0 -62
- package/cli/dist/commands/doctor.js.map +0 -1
- package/cli/dist/commands/export.d.ts +0 -28
- package/cli/dist/commands/export.d.ts.map +0 -1
- package/cli/dist/commands/export.js +0 -135
- package/cli/dist/commands/export.js.map +0 -1
- package/cli/dist/commands/import.d.ts +0 -23
- package/cli/dist/commands/import.d.ts.map +0 -1
- package/cli/dist/commands/import.js +0 -118
- package/cli/dist/commands/import.js.map +0 -1
- package/cli/dist/commands/prompt.d.ts +0 -45
- package/cli/dist/commands/prompt.d.ts.map +0 -1
- package/cli/dist/commands/prompt.js +0 -223
- package/cli/dist/commands/prompt.js.map +0 -1
- package/cli/dist/commands/spec.d.ts +0 -57
- package/cli/dist/commands/spec.d.ts.map +0 -1
- package/cli/dist/commands/spec.js +0 -279
- package/cli/dist/commands/spec.js.map +0 -1
- package/cli/dist/commands/stats.d.ts +0 -18
- package/cli/dist/commands/stats.d.ts.map +0 -1
- package/cli/dist/commands/stats.js +0 -85
- package/cli/dist/commands/stats.js.map +0 -1
- package/cli/dist/commands/task.d.ts +0 -65
- package/cli/dist/commands/task.d.ts.map +0 -1
- package/cli/dist/commands/task.js +0 -282
- package/cli/dist/commands/task.js.map +0 -1
- package/cli/dist/commands/template.d.ts +0 -17
- package/cli/dist/commands/template.d.ts.map +0 -1
- package/cli/dist/commands/template.js +0 -55
- package/cli/dist/commands/template.js.map +0 -1
- package/cli/dist/utils/agent-config.d.ts +0 -129
- package/cli/dist/utils/agent-config.d.ts.map +0 -1
- package/cli/dist/utils/agent-config.js +0 -297
- package/cli/dist/utils/agent-config.js.map +0 -1
- package/cli/dist/utils/beads-graph.d.ts +0 -17
- package/cli/dist/utils/beads-graph.d.ts.map +0 -1
- package/cli/dist/utils/beads-graph.js +0 -150
- package/cli/dist/utils/beads-graph.js.map +0 -1
- package/cli/dist/utils/beads-integration.d.ts +0 -112
- package/cli/dist/utils/beads-integration.d.ts.map +0 -1
- package/cli/dist/utils/beads-integration.js +0 -312
- package/cli/dist/utils/beads-integration.js.map +0 -1
- package/cli/dist/utils/beads-reporter.d.ts +0 -17
- package/cli/dist/utils/beads-reporter.d.ts.map +0 -1
- package/cli/dist/utils/beads-reporter.js +0 -160
- package/cli/dist/utils/beads-reporter.js.map +0 -1
- package/cli/dist/utils/cache-manager.d.ts +0 -55
- package/cli/dist/utils/cache-manager.d.ts.map +0 -1
- package/cli/dist/utils/cache-manager.js +0 -150
- package/cli/dist/utils/cache-manager.js.map +0 -1
- package/cli/dist/utils/change-manager.d.ts +0 -70
- package/cli/dist/utils/change-manager.d.ts.map +0 -1
- package/cli/dist/utils/change-manager.js +0 -412
- package/cli/dist/utils/change-manager.js.map +0 -1
- package/cli/dist/utils/config-manager-enhanced.d.ts +0 -66
- package/cli/dist/utils/config-manager-enhanced.d.ts.map +0 -1
- package/cli/dist/utils/config-manager-enhanced.js +0 -77
- package/cli/dist/utils/config-manager-enhanced.js.map +0 -1
- package/cli/dist/utils/context-manager.d.ts +0 -96
- package/cli/dist/utils/context-manager.d.ts.map +0 -1
- package/cli/dist/utils/context-manager.js +0 -258
- package/cli/dist/utils/context-manager.js.map +0 -1
- package/cli/dist/utils/diff-engine.d.ts +0 -78
- package/cli/dist/utils/diff-engine.d.ts.map +0 -1
- package/cli/dist/utils/diff-engine.js +0 -233
- package/cli/dist/utils/diff-engine.js.map +0 -1
- package/cli/dist/utils/export-system.d.ts +0 -101
- package/cli/dist/utils/export-system.d.ts.map +0 -1
- package/cli/dist/utils/export-system.js +0 -289
- package/cli/dist/utils/export-system.js.map +0 -1
- package/cli/dist/utils/health-checker.d.ts +0 -66
- package/cli/dist/utils/health-checker.d.ts.map +0 -1
- package/cli/dist/utils/health-checker.js +0 -285
- package/cli/dist/utils/health-checker.js.map +0 -1
- package/cli/dist/utils/import-system.d.ts +0 -74
- package/cli/dist/utils/import-system.d.ts.map +0 -1
- package/cli/dist/utils/import-system.js +0 -317
- package/cli/dist/utils/import-system.js.map +0 -1
- package/cli/dist/utils/module-cloner.d.ts +0 -40
- package/cli/dist/utils/module-cloner.d.ts.map +0 -1
- package/cli/dist/utils/module-cloner.js +0 -136
- package/cli/dist/utils/module-cloner.js.map +0 -1
- package/cli/dist/utils/prompt-manager.d.ts +0 -90
- package/cli/dist/utils/prompt-manager.d.ts.map +0 -1
- package/cli/dist/utils/prompt-manager.js +0 -302
- package/cli/dist/utils/prompt-manager.js.map +0 -1
- package/cli/dist/utils/spec-manager.d.ts +0 -65
- package/cli/dist/utils/spec-manager.d.ts.map +0 -1
- package/cli/dist/utils/spec-manager.js +0 -329
- package/cli/dist/utils/spec-manager.js.map +0 -1
- package/cli/dist/utils/stats-collector.d.ts +0 -74
- package/cli/dist/utils/stats-collector.d.ts.map +0 -1
- package/cli/dist/utils/stats-collector.js +0 -164
- package/cli/dist/utils/stats-collector.js.map +0 -1
- package/cli/dist/utils/template-engine.d.ts +0 -47
- package/cli/dist/utils/template-engine.d.ts.map +0 -1
- package/cli/dist/utils/template-engine.js +0 -204
- package/cli/dist/utils/template-engine.js.map +0 -1
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unit Tests for ConfigurationManager
|
|
3
|
+
* Tests configuration loading, validation, merging, and hot-reload
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import * as fs from 'fs/promises';
|
|
7
|
+
import * as path from 'path';
|
|
8
|
+
import { ConfigurationManager } from '../../src/config-manager';
|
|
9
|
+
import { Configuration } from '../../src/types';
|
|
10
|
+
|
|
11
|
+
describe('ConfigurationManager', () => {
|
|
12
|
+
let tempDir: string;
|
|
13
|
+
let configManager: ConfigurationManager;
|
|
14
|
+
|
|
15
|
+
beforeEach(async () => {
|
|
16
|
+
// Create temporary directory for tests
|
|
17
|
+
tempDir = path.join(__dirname, '../fixtures/temp-config');
|
|
18
|
+
await fs.mkdir(tempDir, { recursive: true });
|
|
19
|
+
await fs.mkdir(path.join(tempDir, '.augment'), { recursive: true });
|
|
20
|
+
|
|
21
|
+
configManager = new ConfigurationManager(tempDir);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
afterEach(async () => {
|
|
25
|
+
// Clean up temporary directory
|
|
26
|
+
try {
|
|
27
|
+
await fs.rm(tempDir, { recursive: true, force: true });
|
|
28
|
+
} catch (error) {
|
|
29
|
+
// Ignore cleanup errors
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
describe('load()', () => {
|
|
34
|
+
it('should load default configuration when no user config exists', async () => {
|
|
35
|
+
const config = await configManager.load();
|
|
36
|
+
|
|
37
|
+
expect(config).toBeDefined();
|
|
38
|
+
expect(config.c_standards).toBeDefined();
|
|
39
|
+
expect(config.c_standards.version).toBe('1.0.0');
|
|
40
|
+
expect(config.c_standards.categories).toContain('systems');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('should load and merge JSON configuration', async () => {
|
|
44
|
+
const userConfig: Configuration = {
|
|
45
|
+
c_standards: {
|
|
46
|
+
version: '1.0.0',
|
|
47
|
+
categories: ['embedded', 'realtime'],
|
|
48
|
+
c_standard: 'c99',
|
|
49
|
+
universal_rules: {
|
|
50
|
+
naming: 'enabled',
|
|
51
|
+
memory_safety: 'enabled',
|
|
52
|
+
error_handling: 'warning',
|
|
53
|
+
documentation: 'enabled',
|
|
54
|
+
header_guards: 'enabled',
|
|
55
|
+
const_correctness: 'warning'
|
|
56
|
+
},
|
|
57
|
+
category_overrides: {
|
|
58
|
+
embedded: {
|
|
59
|
+
allow_dynamic_allocation: false
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
static_analysis: {
|
|
63
|
+
clang_tidy: true,
|
|
64
|
+
cppcheck: true,
|
|
65
|
+
valgrind: false
|
|
66
|
+
},
|
|
67
|
+
custom_rules: {
|
|
68
|
+
enabled: false,
|
|
69
|
+
path: '.augment/c-standards/custom-rules/'
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
await fs.writeFile(
|
|
75
|
+
path.join(tempDir, '.augment/c-standards.json'),
|
|
76
|
+
JSON.stringify(userConfig, null, 2)
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
const config = await configManager.load();
|
|
80
|
+
|
|
81
|
+
expect(config.c_standards.categories).toEqual(['embedded', 'realtime']);
|
|
82
|
+
expect(config.c_standards.c_standard).toBe('c99');
|
|
83
|
+
expect(config.c_standards.universal_rules?.error_handling).toBe('warning');
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('should load and merge YAML configuration', async () => {
|
|
87
|
+
const yamlConfig = `
|
|
88
|
+
c_standards:
|
|
89
|
+
version: "1.0.0"
|
|
90
|
+
categories:
|
|
91
|
+
- kernel
|
|
92
|
+
- drivers
|
|
93
|
+
c_standard: c11
|
|
94
|
+
universal_rules:
|
|
95
|
+
naming: enabled
|
|
96
|
+
memory_safety: enabled
|
|
97
|
+
error_handling: enabled
|
|
98
|
+
documentation: warning
|
|
99
|
+
header_guards: enabled
|
|
100
|
+
const_correctness: enabled
|
|
101
|
+
`;
|
|
102
|
+
|
|
103
|
+
await fs.writeFile(
|
|
104
|
+
path.join(tempDir, '.augment/c-standards.yaml'),
|
|
105
|
+
yamlConfig
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
const config = await configManager.load();
|
|
109
|
+
|
|
110
|
+
expect(config.c_standards.categories).toEqual(['kernel', 'drivers']);
|
|
111
|
+
expect(config.c_standards.c_standard).toBe('c11');
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('should throw error for invalid JSON', async () => {
|
|
115
|
+
await fs.writeFile(
|
|
116
|
+
path.join(tempDir, '.augment/c-standards.json'),
|
|
117
|
+
'{ invalid json }'
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
await expect(configManager.load()).rejects.toThrow('Failed to parse JSON configuration');
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('should throw error for invalid schema', async () => {
|
|
124
|
+
const invalidConfig = {
|
|
125
|
+
c_standards: {
|
|
126
|
+
version: '1.0.0',
|
|
127
|
+
categories: 'not-an-array', // Should be array
|
|
128
|
+
c_standard: 'c11'
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
await fs.writeFile(
|
|
133
|
+
path.join(tempDir, '.augment/c-standards.json'),
|
|
134
|
+
JSON.stringify(invalidConfig)
|
|
135
|
+
);
|
|
136
|
+
|
|
137
|
+
await expect(configManager.load()).rejects.toThrow('Invalid configuration');
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
describe('validateConfiguration()', () => {
|
|
142
|
+
it('should validate correct configuration', async () => {
|
|
143
|
+
await configManager.load();
|
|
144
|
+
const config = configManager.getConfiguration();
|
|
145
|
+
const result = configManager.validateConfiguration(config);
|
|
146
|
+
|
|
147
|
+
expect(result.valid).toBe(true);
|
|
148
|
+
expect(result.errors).toHaveLength(0);
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it('should warn about inactive category overrides', async () => {
|
|
152
|
+
const config: Configuration = {
|
|
153
|
+
c_standards: {
|
|
154
|
+
version: '1.0.0',
|
|
155
|
+
categories: ['systems'],
|
|
156
|
+
c_standard: 'c11',
|
|
157
|
+
universal_rules: {
|
|
158
|
+
naming: 'enabled',
|
|
159
|
+
memory_safety: 'enabled',
|
|
160
|
+
error_handling: 'enabled',
|
|
161
|
+
documentation: 'enabled',
|
|
162
|
+
header_guards: 'enabled',
|
|
163
|
+
const_correctness: 'enabled'
|
|
164
|
+
},
|
|
165
|
+
category_overrides: {
|
|
166
|
+
embedded: { // Not in active categories
|
|
167
|
+
allow_dynamic_allocation: false
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
static_analysis: {
|
|
171
|
+
clang_tidy: false,
|
|
172
|
+
cppcheck: false,
|
|
173
|
+
valgrind: false
|
|
174
|
+
},
|
|
175
|
+
custom_rules: {
|
|
176
|
+
enabled: false,
|
|
177
|
+
path: '.augment/c-standards/custom-rules/'
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
await configManager.load();
|
|
183
|
+
const result = configManager.validateConfiguration(config);
|
|
184
|
+
|
|
185
|
+
expect(result.warnings.length).toBeGreaterThan(0);
|
|
186
|
+
expect(result.warnings[0]).toContain('embedded');
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
describe('getConfiguration()', () => {
|
|
191
|
+
it('should return loaded configuration', async () => {
|
|
192
|
+
await configManager.load();
|
|
193
|
+
const config = configManager.getConfiguration();
|
|
194
|
+
|
|
195
|
+
expect(config).toBeDefined();
|
|
196
|
+
expect(config.c_standards).toBeDefined();
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it('should throw error if configuration not loaded', () => {
|
|
200
|
+
const newManager = new ConfigurationManager(tempDir);
|
|
201
|
+
expect(() => newManager.getConfiguration()).toThrow('Configuration not loaded');
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
describe('isRuleEnabled()', () => {
|
|
206
|
+
beforeEach(async () => {
|
|
207
|
+
await configManager.load();
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it('should return true for enabled rules', () => {
|
|
211
|
+
expect(configManager.isRuleEnabled('universal-naming')).toBe(true);
|
|
212
|
+
expect(configManager.isRuleEnabled('universal-memory_safety')).toBe(true);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it('should return true for warning rules', async () => {
|
|
216
|
+
const config: Configuration = {
|
|
217
|
+
c_standards: {
|
|
218
|
+
version: '1.0.0',
|
|
219
|
+
categories: ['systems'],
|
|
220
|
+
c_standard: 'c11',
|
|
221
|
+
universal_rules: {
|
|
222
|
+
naming: 'warning',
|
|
223
|
+
memory_safety: 'enabled',
|
|
224
|
+
error_handling: 'enabled',
|
|
225
|
+
documentation: 'enabled',
|
|
226
|
+
header_guards: 'enabled',
|
|
227
|
+
const_correctness: 'enabled'
|
|
228
|
+
},
|
|
229
|
+
category_overrides: {},
|
|
230
|
+
static_analysis: { clang_tidy: false, cppcheck: false, valgrind: false },
|
|
231
|
+
custom_rules: { enabled: false, path: '' }
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
await fs.writeFile(
|
|
236
|
+
path.join(tempDir, '.augment/c-standards.json'),
|
|
237
|
+
JSON.stringify(config)
|
|
238
|
+
);
|
|
239
|
+
|
|
240
|
+
await configManager.load();
|
|
241
|
+
expect(configManager.isRuleEnabled('universal-naming')).toBe(true);
|
|
242
|
+
});
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
describe('getRuleSeverity()', () => {
|
|
246
|
+
beforeEach(async () => {
|
|
247
|
+
await configManager.load();
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
it('should return ERROR for enabled rules', () => {
|
|
251
|
+
expect(configManager.getRuleSeverity('universal-naming')).toBe('ERROR');
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
it('should return WARNING for warning rules', async () => {
|
|
255
|
+
const config: Configuration = {
|
|
256
|
+
c_standards: {
|
|
257
|
+
version: '1.0.0',
|
|
258
|
+
categories: ['systems'],
|
|
259
|
+
c_standard: 'c11',
|
|
260
|
+
universal_rules: {
|
|
261
|
+
naming: 'warning',
|
|
262
|
+
memory_safety: 'enabled',
|
|
263
|
+
error_handling: 'enabled',
|
|
264
|
+
documentation: 'enabled',
|
|
265
|
+
header_guards: 'enabled',
|
|
266
|
+
const_correctness: 'enabled'
|
|
267
|
+
},
|
|
268
|
+
category_overrides: {},
|
|
269
|
+
static_analysis: { clang_tidy: false, cppcheck: false, valgrind: false },
|
|
270
|
+
custom_rules: { enabled: false, path: '' }
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
await fs.writeFile(
|
|
275
|
+
path.join(tempDir, '.augment/c-standards.json'),
|
|
276
|
+
JSON.stringify(config)
|
|
277
|
+
);
|
|
278
|
+
|
|
279
|
+
await configManager.load();
|
|
280
|
+
expect(configManager.getRuleSeverity('universal-naming')).toBe('WARNING');
|
|
281
|
+
});
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
describe('reload()', () => {
|
|
285
|
+
it('should reload configuration', async () => {
|
|
286
|
+
await configManager.load();
|
|
287
|
+
const config1 = configManager.getConfiguration();
|
|
288
|
+
|
|
289
|
+
// Modify configuration file
|
|
290
|
+
const newConfig: Configuration = {
|
|
291
|
+
c_standards: {
|
|
292
|
+
...config1.c_standards,
|
|
293
|
+
categories: ['networking']
|
|
294
|
+
}
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
await fs.writeFile(
|
|
298
|
+
path.join(tempDir, '.augment/c-standards.json'),
|
|
299
|
+
JSON.stringify(newConfig)
|
|
300
|
+
);
|
|
301
|
+
|
|
302
|
+
await configManager.reload();
|
|
303
|
+
const config2 = configManager.getConfiguration();
|
|
304
|
+
|
|
305
|
+
expect(config2.c_standards.categories).toEqual(['networking']);
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
it('should notify watchers on reload', async () => {
|
|
309
|
+
await configManager.load();
|
|
310
|
+
|
|
311
|
+
let notified = false;
|
|
312
|
+
configManager.watch((config) => {
|
|
313
|
+
notified = true;
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
await configManager.reload();
|
|
317
|
+
expect(notified).toBe(true);
|
|
318
|
+
});
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
describe('watch()', () => {
|
|
322
|
+
it('should register watcher callback', async () => {
|
|
323
|
+
await configManager.load();
|
|
324
|
+
|
|
325
|
+
const callback = jest.fn();
|
|
326
|
+
configManager.watch(callback);
|
|
327
|
+
|
|
328
|
+
await configManager.reload();
|
|
329
|
+
expect(callback).toHaveBeenCalled();
|
|
330
|
+
});
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
describe('dispose()', () => {
|
|
334
|
+
it('should clean up resources', async () => {
|
|
335
|
+
await configManager.load();
|
|
336
|
+
configManager.watch(() => {});
|
|
337
|
+
|
|
338
|
+
configManager.dispose();
|
|
339
|
+
|
|
340
|
+
// Should not throw
|
|
341
|
+
expect(() => configManager.dispose()).not.toThrow();
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
});
|
|
345
|
+
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unit Tests for ConflictDetector
|
|
3
|
+
* Tests rule conflict detection and resolution suggestions
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import * as fs from 'fs/promises';
|
|
7
|
+
import * as path from 'path';
|
|
8
|
+
import { ConflictDetector } from '../../src/conflict-detector';
|
|
9
|
+
import { RuleRegistry } from '../../src/registry';
|
|
10
|
+
import { Rule } from '../../src/types';
|
|
11
|
+
|
|
12
|
+
describe('ConflictDetector', () => {
|
|
13
|
+
let tempDir: string;
|
|
14
|
+
let rulesPath: string;
|
|
15
|
+
let registry: RuleRegistry;
|
|
16
|
+
let detector: ConflictDetector;
|
|
17
|
+
|
|
18
|
+
beforeEach(async () => {
|
|
19
|
+
// Create temporary directories
|
|
20
|
+
tempDir = path.join(__dirname, '../fixtures/temp-conflicts');
|
|
21
|
+
rulesPath = path.join(tempDir, 'rules');
|
|
22
|
+
|
|
23
|
+
await fs.mkdir(path.join(rulesPath, 'universal'), { recursive: true });
|
|
24
|
+
await fs.mkdir(path.join(rulesPath, 'categories'), { recursive: true });
|
|
25
|
+
|
|
26
|
+
// Create sample rules with potential conflicts
|
|
27
|
+
await createConflictingRules();
|
|
28
|
+
|
|
29
|
+
// Initialize components
|
|
30
|
+
registry = new RuleRegistry(rulesPath);
|
|
31
|
+
await registry.loadRules();
|
|
32
|
+
|
|
33
|
+
detector = new ConflictDetector(registry);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
afterEach(async () => {
|
|
37
|
+
try {
|
|
38
|
+
await fs.rm(tempDir, { recursive: true, force: true });
|
|
39
|
+
} catch (error) {
|
|
40
|
+
// Ignore cleanup errors
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
async function createConflictingRules() {
|
|
45
|
+
// Rule 1: Requires dynamic allocation
|
|
46
|
+
const rule1 = `# Rule: Dynamic Memory Required
|
|
47
|
+
|
|
48
|
+
## Metadata
|
|
49
|
+
- **ID**: systems-dynamic-memory
|
|
50
|
+
- **Category**: systems
|
|
51
|
+
- **Severity**: ERROR
|
|
52
|
+
|
|
53
|
+
## Description
|
|
54
|
+
Use dynamic memory allocation for flexible data structures.
|
|
55
|
+
|
|
56
|
+
## Conflicts
|
|
57
|
+
- embedded-no-dynamic-memory
|
|
58
|
+
`;
|
|
59
|
+
|
|
60
|
+
await fs.writeFile(path.join(rulesPath, 'categories/systems-dynamic.md'), rule1);
|
|
61
|
+
|
|
62
|
+
// Rule 2: Prohibits dynamic allocation
|
|
63
|
+
const rule2 = `# Rule: No Dynamic Memory
|
|
64
|
+
|
|
65
|
+
## Metadata
|
|
66
|
+
- **ID**: embedded-no-dynamic-memory
|
|
67
|
+
- **Category**: embedded
|
|
68
|
+
- **Severity**: ERROR
|
|
69
|
+
|
|
70
|
+
## Description
|
|
71
|
+
Avoid dynamic memory allocation in embedded systems.
|
|
72
|
+
|
|
73
|
+
## Conflicts
|
|
74
|
+
- systems-dynamic-memory
|
|
75
|
+
`;
|
|
76
|
+
|
|
77
|
+
await fs.writeFile(path.join(rulesPath, 'categories/embedded-no-dynamic.md'), rule2);
|
|
78
|
+
|
|
79
|
+
// Rule 3: Compatible rule
|
|
80
|
+
const rule3 = `# Rule: Naming Conventions
|
|
81
|
+
|
|
82
|
+
## Metadata
|
|
83
|
+
- **ID**: universal-naming
|
|
84
|
+
- **Category**: universal
|
|
85
|
+
- **Severity**: ERROR
|
|
86
|
+
|
|
87
|
+
## Description
|
|
88
|
+
Use snake_case for functions and variables.
|
|
89
|
+
`;
|
|
90
|
+
|
|
91
|
+
await fs.writeFile(path.join(rulesPath, 'universal/naming.md'), rule3);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
describe('detectConflicts()', () => {
|
|
95
|
+
it('should detect conflicting rules', async () => {
|
|
96
|
+
const conflicts = await detector.detectConflicts();
|
|
97
|
+
|
|
98
|
+
expect(conflicts.length).toBeGreaterThan(0);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('should identify specific conflicting rule pairs', async () => {
|
|
102
|
+
const conflicts = await detector.detectConflicts();
|
|
103
|
+
|
|
104
|
+
const hasConflict = conflicts.some(c =>
|
|
105
|
+
(c.rule1.id === 'systems-dynamic-memory' && c.rule2.id === 'embedded-no-dynamic-memory') ||
|
|
106
|
+
(c.rule1.id === 'embedded-no-dynamic-memory' && c.rule2.id === 'systems-dynamic-memory')
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
expect(hasConflict).toBe(true);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('should not report false positives', async () => {
|
|
113
|
+
const conflicts = await detector.detectConflicts();
|
|
114
|
+
|
|
115
|
+
const falsePositive = conflicts.some(c =>
|
|
116
|
+
c.rule1.id === 'universal-naming' || c.rule2.id === 'universal-naming'
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
expect(falsePositive).toBe(false);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('should include conflict descriptions', async () => {
|
|
123
|
+
const conflicts = await detector.detectConflicts();
|
|
124
|
+
|
|
125
|
+
if (conflicts.length > 0) {
|
|
126
|
+
expect(conflicts[0].description).toBeDefined();
|
|
127
|
+
expect(conflicts[0].description.length).toBeGreaterThan(0);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
describe('detectConflictsForRules()', () => {
|
|
133
|
+
it('should detect conflicts for specific rule set', async () => {
|
|
134
|
+
const ruleIds = ['systems-dynamic-memory', 'embedded-no-dynamic-memory'];
|
|
135
|
+
|
|
136
|
+
const conflicts = await detector.detectConflictsForRules(ruleIds);
|
|
137
|
+
|
|
138
|
+
expect(conflicts.length).toBeGreaterThan(0);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('should return empty array for non-conflicting rules', async () => {
|
|
142
|
+
const ruleIds = ['universal-naming'];
|
|
143
|
+
|
|
144
|
+
const conflicts = await detector.detectConflictsForRules(ruleIds);
|
|
145
|
+
|
|
146
|
+
expect(conflicts.length).toBe(0);
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
describe('suggestResolution()', () => {
|
|
151
|
+
it('should suggest resolution for conflicts', async () => {
|
|
152
|
+
const conflicts = await detector.detectConflicts();
|
|
153
|
+
|
|
154
|
+
if (conflicts.length > 0) {
|
|
155
|
+
const suggestions = detector.suggestResolution(conflicts[0]);
|
|
156
|
+
|
|
157
|
+
expect(suggestions).toBeDefined();
|
|
158
|
+
expect(Array.isArray(suggestions)).toBe(true);
|
|
159
|
+
expect(suggestions.length).toBeGreaterThan(0);
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it('should suggest disabling one rule', async () => {
|
|
164
|
+
const conflicts = await detector.detectConflicts();
|
|
165
|
+
|
|
166
|
+
if (conflicts.length > 0) {
|
|
167
|
+
const suggestions = detector.suggestResolution(conflicts[0]);
|
|
168
|
+
|
|
169
|
+
const hasDisableSuggestion = suggestions.some(s =>
|
|
170
|
+
s.type === 'disable' && (s.ruleId === conflicts[0].rule1.id || s.ruleId === conflicts[0].rule2.id)
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
expect(hasDisableSuggestion).toBe(true);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
it('should suggest category-based resolution', async () => {
|
|
178
|
+
const conflicts = await detector.detectConflicts();
|
|
179
|
+
|
|
180
|
+
if (conflicts.length > 0) {
|
|
181
|
+
const suggestions = detector.suggestResolution(conflicts[0]);
|
|
182
|
+
|
|
183
|
+
const hasCategorySuggestion = suggestions.some(s => s.type === 'category');
|
|
184
|
+
|
|
185
|
+
expect(hasCategorySuggestion).toBe(true);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
describe('analyzeConflictSeverity()', () => {
|
|
191
|
+
it('should analyze conflict severity', async () => {
|
|
192
|
+
const conflicts = await detector.detectConflicts();
|
|
193
|
+
|
|
194
|
+
if (conflicts.length > 0) {
|
|
195
|
+
const severity = detector.analyzeConflictSeverity(conflicts[0]);
|
|
196
|
+
|
|
197
|
+
expect(severity).toBeDefined();
|
|
198
|
+
expect(['HIGH', 'MEDIUM', 'LOW']).toContain(severity);
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it('should rate ERROR-ERROR conflicts as HIGH', async () => {
|
|
203
|
+
const conflicts = await detector.detectConflicts();
|
|
204
|
+
|
|
205
|
+
const errorConflict = conflicts.find(c =>
|
|
206
|
+
c.rule1.severity === 'ERROR' && c.rule2.severity === 'ERROR'
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
if (errorConflict) {
|
|
210
|
+
const severity = detector.analyzeConflictSeverity(errorConflict);
|
|
211
|
+
expect(severity).toBe('HIGH');
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
describe('generateConflictReport()', () => {
|
|
217
|
+
it('should generate text report', async () => {
|
|
218
|
+
const conflicts = await detector.detectConflicts();
|
|
219
|
+
|
|
220
|
+
const report = detector.generateConflictReport(conflicts, { format: 'text' });
|
|
221
|
+
|
|
222
|
+
expect(report).toBeDefined();
|
|
223
|
+
expect(typeof report).toBe('string');
|
|
224
|
+
expect(report.length).toBeGreaterThan(0);
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
it('should generate JSON report', async () => {
|
|
228
|
+
const conflicts = await detector.detectConflicts();
|
|
229
|
+
|
|
230
|
+
const report = detector.generateConflictReport(conflicts, { format: 'json' });
|
|
231
|
+
|
|
232
|
+
expect(report).toBeDefined();
|
|
233
|
+
expect(() => JSON.parse(report)).not.toThrow();
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
it('should include resolution suggestions in report', async () => {
|
|
237
|
+
const conflicts = await detector.detectConflicts();
|
|
238
|
+
|
|
239
|
+
const report = detector.generateConflictReport(conflicts, {
|
|
240
|
+
format: 'json',
|
|
241
|
+
includeSuggestions: true
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
const parsed = JSON.parse(report);
|
|
245
|
+
if (parsed.conflicts && parsed.conflicts.length > 0) {
|
|
246
|
+
expect(parsed.conflicts[0].suggestions).toBeDefined();
|
|
247
|
+
}
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
describe('isConflictResolved()', () => {
|
|
252
|
+
it('should check if conflict is resolved', async () => {
|
|
253
|
+
const conflicts = await detector.detectConflicts();
|
|
254
|
+
|
|
255
|
+
if (conflicts.length > 0) {
|
|
256
|
+
const isResolved = detector.isConflictResolved(conflicts[0]);
|
|
257
|
+
expect(typeof isResolved).toBe('boolean');
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
it('should return true when one rule is disabled', async () => {
|
|
262
|
+
const conflicts = await detector.detectConflicts();
|
|
263
|
+
|
|
264
|
+
if (conflicts.length > 0) {
|
|
265
|
+
registry.setRuleEnabled(conflicts[0].rule1.id, false);
|
|
266
|
+
const isResolved = detector.isConflictResolved(conflicts[0]);
|
|
267
|
+
expect(isResolved).toBe(true);
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
describe('getConflictsByCategory()', () => {
|
|
273
|
+
it('should group conflicts by category', async () => {
|
|
274
|
+
const conflicts = await detector.detectConflicts();
|
|
275
|
+
|
|
276
|
+
const grouped = detector.getConflictsByCategory(conflicts);
|
|
277
|
+
|
|
278
|
+
expect(grouped).toBeDefined();
|
|
279
|
+
expect(typeof grouped).toBe('object');
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
it('should include all relevant categories', async () => {
|
|
283
|
+
const conflicts = await detector.detectConflicts();
|
|
284
|
+
|
|
285
|
+
const grouped = detector.getConflictsByCategory(conflicts);
|
|
286
|
+
|
|
287
|
+
if (conflicts.length > 0) {
|
|
288
|
+
const categories = Object.keys(grouped);
|
|
289
|
+
expect(categories.length).toBeGreaterThan(0);
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
});
|
|
293
|
+
});
|
|
294
|
+
|