@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,356 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Integration Tests for All 7 C Coding Categories
|
|
3
|
+
* Tests category-specific rules and workflows
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import * as fs from 'fs/promises';
|
|
7
|
+
import * as path from 'path';
|
|
8
|
+
import { ConfigurationManager } from '../../src/config-manager';
|
|
9
|
+
import { RuleRegistry } from '../../src/registry';
|
|
10
|
+
import { PromptGenerator } from '../../src/prompt-generator';
|
|
11
|
+
import { RuleEvaluator } from '../../src/rule-evaluator';
|
|
12
|
+
|
|
13
|
+
describe('Category-Specific Integration Tests', () => {
|
|
14
|
+
let tempDir: string;
|
|
15
|
+
let rulesPath: string;
|
|
16
|
+
let configPath: string;
|
|
17
|
+
let configManager: ConfigurationManager;
|
|
18
|
+
let registry: RuleRegistry;
|
|
19
|
+
let promptGenerator: PromptGenerator;
|
|
20
|
+
let evaluator: RuleEvaluator;
|
|
21
|
+
|
|
22
|
+
beforeEach(async () => {
|
|
23
|
+
tempDir = path.join(__dirname, '../fixtures/temp-categories');
|
|
24
|
+
rulesPath = path.join(tempDir, 'rules');
|
|
25
|
+
configPath = tempDir;
|
|
26
|
+
|
|
27
|
+
await fs.mkdir(path.join(rulesPath, 'categories'), { recursive: true });
|
|
28
|
+
await fs.mkdir(path.join(configPath, '.augment'), { recursive: true });
|
|
29
|
+
|
|
30
|
+
await createCategoryRules();
|
|
31
|
+
|
|
32
|
+
configManager = new ConfigurationManager(configPath);
|
|
33
|
+
await configManager.load();
|
|
34
|
+
|
|
35
|
+
registry = new RuleRegistry(rulesPath);
|
|
36
|
+
await registry.loadRules();
|
|
37
|
+
|
|
38
|
+
promptGenerator = new PromptGenerator(registry, configManager);
|
|
39
|
+
evaluator = new RuleEvaluator(registry, configManager);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
afterEach(async () => {
|
|
43
|
+
try {
|
|
44
|
+
await fs.rm(tempDir, { recursive: true, force: true });
|
|
45
|
+
} catch (error) {
|
|
46
|
+
// Ignore cleanup errors
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
async function createCategoryRules() {
|
|
51
|
+
// Systems Programming
|
|
52
|
+
const systemsRule = `# Rule: POSIX Compliance
|
|
53
|
+
|
|
54
|
+
## Metadata
|
|
55
|
+
- **ID**: systems-posix
|
|
56
|
+
- **Category**: systems
|
|
57
|
+
- **Severity**: WARNING
|
|
58
|
+
|
|
59
|
+
## Description
|
|
60
|
+
Follow POSIX standards for system programming.
|
|
61
|
+
`;
|
|
62
|
+
|
|
63
|
+
await fs.writeFile(path.join(rulesPath, 'categories/systems.md'), systemsRule);
|
|
64
|
+
|
|
65
|
+
// Embedded Systems
|
|
66
|
+
const embeddedRule = `# Rule: Volatile Hardware Access
|
|
67
|
+
|
|
68
|
+
## Metadata
|
|
69
|
+
- **ID**: embedded-volatile
|
|
70
|
+
- **Category**: embedded
|
|
71
|
+
- **Severity**: ERROR
|
|
72
|
+
|
|
73
|
+
## Description
|
|
74
|
+
Use volatile for hardware register access.
|
|
75
|
+
`;
|
|
76
|
+
|
|
77
|
+
await fs.writeFile(path.join(rulesPath, 'categories/embedded.md'), embeddedRule);
|
|
78
|
+
|
|
79
|
+
// Kernel Development
|
|
80
|
+
const kernelRule = `# Rule: Kernel Coding Style
|
|
81
|
+
|
|
82
|
+
## Metadata
|
|
83
|
+
- **ID**: kernel-style
|
|
84
|
+
- **Category**: kernel
|
|
85
|
+
- **Severity**: ERROR
|
|
86
|
+
|
|
87
|
+
## Description
|
|
88
|
+
Follow Linux kernel coding style guidelines.
|
|
89
|
+
`;
|
|
90
|
+
|
|
91
|
+
await fs.writeFile(path.join(rulesPath, 'categories/kernel.md'), kernelRule);
|
|
92
|
+
|
|
93
|
+
// Device Drivers
|
|
94
|
+
const driversRule = `# Rule: Driver Error Handling
|
|
95
|
+
|
|
96
|
+
## Metadata
|
|
97
|
+
- **ID**: drivers-error-handling
|
|
98
|
+
- **Category**: drivers
|
|
99
|
+
- **Severity**: ERROR
|
|
100
|
+
|
|
101
|
+
## Description
|
|
102
|
+
Proper error handling in device drivers.
|
|
103
|
+
`;
|
|
104
|
+
|
|
105
|
+
await fs.writeFile(path.join(rulesPath, 'categories/drivers.md'), driversRule);
|
|
106
|
+
|
|
107
|
+
// Real-time Systems
|
|
108
|
+
const realtimeRule = `# Rule: Deterministic Execution
|
|
109
|
+
|
|
110
|
+
## Metadata
|
|
111
|
+
- **ID**: realtime-deterministic
|
|
112
|
+
- **Category**: realtime
|
|
113
|
+
- **Severity**: ERROR
|
|
114
|
+
|
|
115
|
+
## Description
|
|
116
|
+
Ensure deterministic execution paths.
|
|
117
|
+
`;
|
|
118
|
+
|
|
119
|
+
await fs.writeFile(path.join(rulesPath, 'categories/realtime.md'), realtimeRule);
|
|
120
|
+
|
|
121
|
+
// Networking
|
|
122
|
+
const networkingRule = `# Rule: Network Byte Order
|
|
123
|
+
|
|
124
|
+
## Metadata
|
|
125
|
+
- **ID**: networking-byte-order
|
|
126
|
+
- **Category**: networking
|
|
127
|
+
- **Severity**: ERROR
|
|
128
|
+
|
|
129
|
+
## Description
|
|
130
|
+
Use htons/htonl for network byte order.
|
|
131
|
+
`;
|
|
132
|
+
|
|
133
|
+
await fs.writeFile(path.join(rulesPath, 'categories/networking.md'), networkingRule);
|
|
134
|
+
|
|
135
|
+
// Legacy Code
|
|
136
|
+
const legacyRule = `# Rule: Legacy Compatibility
|
|
137
|
+
|
|
138
|
+
## Metadata
|
|
139
|
+
- **ID**: legacy-compatibility
|
|
140
|
+
- **Category**: legacy
|
|
141
|
+
- **Severity**: WARNING
|
|
142
|
+
|
|
143
|
+
## Description
|
|
144
|
+
Maintain compatibility with legacy systems.
|
|
145
|
+
`;
|
|
146
|
+
|
|
147
|
+
await fs.writeFile(path.join(rulesPath, 'categories/legacy.md'), legacyRule);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
describe('Category 1: Systems Programming', () => {
|
|
151
|
+
it('should load systems programming rules', () => {
|
|
152
|
+
const systemsRules = registry.getRulesByCategory('systems');
|
|
153
|
+
expect(systemsRules.length).toBeGreaterThan(0);
|
|
154
|
+
expect(systemsRules[0].id).toBe('systems-posix');
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it('should generate systems-specific prompts', async () => {
|
|
158
|
+
const prompt = await promptGenerator.generatePrompt({
|
|
159
|
+
filePath: '/project/systems/process.c',
|
|
160
|
+
codeContext: 'fork();',
|
|
161
|
+
category: 'systems'
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
expect(prompt).toBeDefined();
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
describe('Category 2: Embedded Systems', () => {
|
|
169
|
+
it('should load embedded systems rules', () => {
|
|
170
|
+
const embeddedRules = registry.getRulesByCategory('embedded');
|
|
171
|
+
expect(embeddedRules.length).toBeGreaterThan(0);
|
|
172
|
+
expect(embeddedRules[0].id).toBe('embedded-volatile');
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it('should detect embedded violations', async () => {
|
|
176
|
+
const code = 'uint32_t* reg = (uint32_t*)0x40000000;';
|
|
177
|
+
|
|
178
|
+
const violations = await evaluator.evaluate(code, {
|
|
179
|
+
filePath: '/project/embedded/sensor.c',
|
|
180
|
+
rules: ['embedded-volatile']
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
expect(violations.length).toBeGreaterThan(0);
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
describe('Category 3: Kernel Development', () => {
|
|
188
|
+
it('should load kernel development rules', () => {
|
|
189
|
+
const kernelRules = registry.getRulesByCategory('kernel');
|
|
190
|
+
expect(kernelRules.length).toBeGreaterThan(0);
|
|
191
|
+
expect(kernelRules[0].id).toBe('kernel-style');
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it('should generate kernel-specific prompts', async () => {
|
|
195
|
+
const prompt = await promptGenerator.generatePrompt({
|
|
196
|
+
filePath: '/project/kernel/scheduler.c',
|
|
197
|
+
codeContext: 'schedule();',
|
|
198
|
+
category: 'kernel'
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
expect(prompt).toBeDefined();
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
describe('Category 4: Device Drivers', () => {
|
|
206
|
+
it('should load device driver rules', () => {
|
|
207
|
+
const driversRules = registry.getRulesByCategory('drivers');
|
|
208
|
+
expect(driversRules.length).toBeGreaterThan(0);
|
|
209
|
+
expect(driversRules[0].id).toBe('drivers-error-handling');
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
it('should generate driver-specific prompts', async () => {
|
|
213
|
+
const prompt = await promptGenerator.generatePrompt({
|
|
214
|
+
filePath: '/project/drivers/usb.c',
|
|
215
|
+
codeContext: 'usb_register_driver();',
|
|
216
|
+
category: 'drivers'
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
expect(prompt).toBeDefined();
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
describe('Category 5: Real-time Systems', () => {
|
|
224
|
+
it('should load real-time systems rules', () => {
|
|
225
|
+
const realtimeRules = registry.getRulesByCategory('realtime');
|
|
226
|
+
expect(realtimeRules.length).toBeGreaterThan(0);
|
|
227
|
+
expect(realtimeRules[0].id).toBe('realtime-deterministic');
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
it('should generate real-time specific prompts', async () => {
|
|
231
|
+
const prompt = await promptGenerator.generatePrompt({
|
|
232
|
+
filePath: '/project/realtime/scheduler.c',
|
|
233
|
+
codeContext: 'rt_task_create();',
|
|
234
|
+
category: 'realtime'
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
expect(prompt).toBeDefined();
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
describe('Category 6: Networking', () => {
|
|
242
|
+
it('should load networking rules', () => {
|
|
243
|
+
const networkingRules = registry.getRulesByCategory('networking');
|
|
244
|
+
expect(networkingRules.length).toBeGreaterThan(0);
|
|
245
|
+
expect(networkingRules[0].id).toBe('networking-byte-order');
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it('should detect networking violations', async () => {
|
|
249
|
+
const code = 'uint16_t port = 8080;'; // Should use htons
|
|
250
|
+
|
|
251
|
+
const violations = await evaluator.evaluate(code, {
|
|
252
|
+
filePath: '/project/network/tcp.c',
|
|
253
|
+
rules: ['networking-byte-order']
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
expect(violations.length).toBeGreaterThan(0);
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
it('should generate networking-specific prompts', async () => {
|
|
260
|
+
const prompt = await promptGenerator.generatePrompt({
|
|
261
|
+
filePath: '/project/network/tcp.c',
|
|
262
|
+
codeContext: 'socket();',
|
|
263
|
+
category: 'networking'
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
expect(prompt).toBeDefined();
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
describe('Category 7: Legacy Code', () => {
|
|
271
|
+
it('should load legacy code rules', () => {
|
|
272
|
+
const legacyRules = registry.getRulesByCategory('legacy');
|
|
273
|
+
expect(legacyRules.length).toBeGreaterThan(0);
|
|
274
|
+
expect(legacyRules[0].id).toBe('legacy-compatibility');
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
it('should generate legacy-specific prompts', async () => {
|
|
278
|
+
const prompt = await promptGenerator.generatePrompt({
|
|
279
|
+
filePath: '/project/legacy/old_system.c',
|
|
280
|
+
codeContext: 'legacy_function();',
|
|
281
|
+
category: 'legacy'
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
expect(prompt).toBeDefined();
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
describe('Cross-Category Integration', () => {
|
|
289
|
+
it('should handle multiple categories simultaneously', async () => {
|
|
290
|
+
const systemsRules = registry.getRulesByCategory('systems');
|
|
291
|
+
const embeddedRules = registry.getRulesByCategory('embedded');
|
|
292
|
+
const kernelRules = registry.getRulesByCategory('kernel');
|
|
293
|
+
|
|
294
|
+
expect(systemsRules.length).toBeGreaterThan(0);
|
|
295
|
+
expect(embeddedRules.length).toBeGreaterThan(0);
|
|
296
|
+
expect(kernelRules.length).toBeGreaterThan(0);
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
it('should evaluate code with multiple category rules', async () => {
|
|
300
|
+
const code = `
|
|
301
|
+
volatile uint32_t* reg = (volatile uint32_t*)0x40000000;
|
|
302
|
+
int result = fork();
|
|
303
|
+
`;
|
|
304
|
+
|
|
305
|
+
const violations = await evaluator.evaluate(code, {
|
|
306
|
+
filePath: '/project/mixed/code.c',
|
|
307
|
+
rules: ['embedded-volatile', 'systems-posix']
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
expect(violations).toBeDefined();
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
it('should generate prompts for mixed categories', async () => {
|
|
314
|
+
const prompt = await promptGenerator.generatePrompt({
|
|
315
|
+
filePath: '/project/mixed/code.c',
|
|
316
|
+
codeContext: 'mixed code',
|
|
317
|
+
category: 'systems,embedded'
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
expect(prompt).toBeDefined();
|
|
321
|
+
});
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
describe('Category Detection from File Paths', () => {
|
|
325
|
+
it('should detect embedded from path', () => {
|
|
326
|
+
const category = promptGenerator.detectCategory('/project/embedded/sensor.c');
|
|
327
|
+
expect(category).toContain('embedded');
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
it('should detect kernel from path', () => {
|
|
331
|
+
const category = promptGenerator.detectCategory('/project/kernel/scheduler.c');
|
|
332
|
+
expect(category).toContain('kernel');
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
it('should detect networking from path', () => {
|
|
336
|
+
const category = promptGenerator.detectCategory('/project/network/tcp.c');
|
|
337
|
+
expect(category).toContain('networking');
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
it('should detect drivers from path', () => {
|
|
341
|
+
const category = promptGenerator.detectCategory('/project/drivers/usb.c');
|
|
342
|
+
expect(category).toContain('drivers');
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
it('should detect realtime from path', () => {
|
|
346
|
+
const category = promptGenerator.detectCategory('/project/realtime/task.c');
|
|
347
|
+
expect(category).toContain('realtime');
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
it('should detect legacy from path', () => {
|
|
351
|
+
const category = promptGenerator.detectCategory('/project/legacy/old.c');
|
|
352
|
+
expect(category).toContain('legacy');
|
|
353
|
+
});
|
|
354
|
+
});
|
|
355
|
+
});
|
|
356
|
+
|