@mytechtoday/augment-extensions 1.3.1 → 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/README.md +105 -6
- 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 +21 -2
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Integration Tests for End-to-End Workflows
|
|
3
|
+
* Tests complete workflows from configuration loading to violation reporting
|
|
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
|
+
import { Configuration } from '../../src/types';
|
|
13
|
+
|
|
14
|
+
describe('End-to-End Workflow Integration Tests', () => {
|
|
15
|
+
let tempDir: string;
|
|
16
|
+
let rulesPath: string;
|
|
17
|
+
let configPath: string;
|
|
18
|
+
let configManager: ConfigurationManager;
|
|
19
|
+
let registry: RuleRegistry;
|
|
20
|
+
let promptGenerator: PromptGenerator;
|
|
21
|
+
let evaluator: RuleEvaluator;
|
|
22
|
+
|
|
23
|
+
beforeEach(async () => {
|
|
24
|
+
// Create temporary test environment
|
|
25
|
+
tempDir = path.join(__dirname, '../fixtures/temp-e2e');
|
|
26
|
+
rulesPath = path.join(tempDir, 'rules');
|
|
27
|
+
configPath = tempDir;
|
|
28
|
+
|
|
29
|
+
await fs.mkdir(path.join(rulesPath, 'universal'), { recursive: true });
|
|
30
|
+
await fs.mkdir(path.join(rulesPath, 'categories'), { recursive: true });
|
|
31
|
+
await fs.mkdir(path.join(configPath, '.augment'), { recursive: true });
|
|
32
|
+
|
|
33
|
+
// Create comprehensive test rules
|
|
34
|
+
await createTestRules();
|
|
35
|
+
|
|
36
|
+
// Create test configuration
|
|
37
|
+
await createTestConfiguration();
|
|
38
|
+
|
|
39
|
+
// Initialize all components
|
|
40
|
+
configManager = new ConfigurationManager(configPath);
|
|
41
|
+
await configManager.load();
|
|
42
|
+
|
|
43
|
+
registry = new RuleRegistry(rulesPath);
|
|
44
|
+
await registry.loadRules();
|
|
45
|
+
|
|
46
|
+
promptGenerator = new PromptGenerator(registry, configManager);
|
|
47
|
+
evaluator = new RuleEvaluator(registry, configManager);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
afterEach(async () => {
|
|
51
|
+
try {
|
|
52
|
+
await fs.rm(tempDir, { recursive: true, force: true });
|
|
53
|
+
} catch (error) {
|
|
54
|
+
// Ignore cleanup errors
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
async function createTestRules() {
|
|
59
|
+
// Universal naming rule
|
|
60
|
+
const namingRule = `# Rule: Naming Conventions
|
|
61
|
+
|
|
62
|
+
## Metadata
|
|
63
|
+
- **ID**: universal-naming
|
|
64
|
+
- **Category**: universal
|
|
65
|
+
- **Severity**: ERROR
|
|
66
|
+
|
|
67
|
+
## Description
|
|
68
|
+
Use snake_case for functions and variables, UPPER_CASE for macros.
|
|
69
|
+
|
|
70
|
+
## Pattern
|
|
71
|
+
^[a-z][a-z0-9_]*$ for functions/variables
|
|
72
|
+
^[A-Z][A-Z0-9_]*$ for macros
|
|
73
|
+
|
|
74
|
+
## Examples
|
|
75
|
+
|
|
76
|
+
### Bad Example
|
|
77
|
+
\`\`\`c
|
|
78
|
+
int myFunction() { return 0; }
|
|
79
|
+
#define myMacro 1
|
|
80
|
+
\`\`\`
|
|
81
|
+
|
|
82
|
+
### Good Example
|
|
83
|
+
\`\`\`c
|
|
84
|
+
int my_function() { return 0; }
|
|
85
|
+
#define MY_MACRO 1
|
|
86
|
+
\`\`\`
|
|
87
|
+
`;
|
|
88
|
+
|
|
89
|
+
await fs.writeFile(path.join(rulesPath, 'universal/naming.md'), namingRule);
|
|
90
|
+
|
|
91
|
+
// Memory safety rule
|
|
92
|
+
const memoryRule = `# Rule: Memory Safety
|
|
93
|
+
|
|
94
|
+
## Metadata
|
|
95
|
+
- **ID**: universal-memory-safety
|
|
96
|
+
- **Category**: universal
|
|
97
|
+
- **Severity**: ERROR
|
|
98
|
+
|
|
99
|
+
## Description
|
|
100
|
+
Always check malloc/calloc return values and free allocated memory.
|
|
101
|
+
|
|
102
|
+
## Examples
|
|
103
|
+
|
|
104
|
+
### Bad Example
|
|
105
|
+
\`\`\`c
|
|
106
|
+
int* ptr = malloc(sizeof(int));
|
|
107
|
+
*ptr = 5; // No null check
|
|
108
|
+
\`\`\`
|
|
109
|
+
|
|
110
|
+
### Good Example
|
|
111
|
+
\`\`\`c
|
|
112
|
+
int* ptr = malloc(sizeof(int));
|
|
113
|
+
if (ptr == NULL) return -1;
|
|
114
|
+
*ptr = 5;
|
|
115
|
+
free(ptr);
|
|
116
|
+
\`\`\`
|
|
117
|
+
`;
|
|
118
|
+
|
|
119
|
+
await fs.writeFile(path.join(rulesPath, 'universal/memory-safety.md'), memoryRule);
|
|
120
|
+
|
|
121
|
+
// Embedded systems rule
|
|
122
|
+
const embeddedRule = `# Rule: Volatile Hardware Access
|
|
123
|
+
|
|
124
|
+
## Metadata
|
|
125
|
+
- **ID**: embedded-volatile
|
|
126
|
+
- **Category**: embedded
|
|
127
|
+
- **Severity**: ERROR
|
|
128
|
+
|
|
129
|
+
## Description
|
|
130
|
+
Use volatile keyword for hardware register access.
|
|
131
|
+
|
|
132
|
+
## Examples
|
|
133
|
+
|
|
134
|
+
### Bad Example
|
|
135
|
+
\`\`\`c
|
|
136
|
+
uint32_t* reg = (uint32_t*)0x40000000;
|
|
137
|
+
*reg = 0x01;
|
|
138
|
+
\`\`\`
|
|
139
|
+
|
|
140
|
+
### Good Example
|
|
141
|
+
\`\`\`c
|
|
142
|
+
volatile uint32_t* reg = (volatile uint32_t*)0x40000000;
|
|
143
|
+
*reg = 0x01;
|
|
144
|
+
\`\`\`
|
|
145
|
+
`;
|
|
146
|
+
|
|
147
|
+
await fs.writeFile(path.join(rulesPath, 'categories/embedded.md'), embeddedRule);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
async function createTestConfiguration() {
|
|
151
|
+
const config: Configuration = {
|
|
152
|
+
c_standards: {
|
|
153
|
+
version: '1.0.0',
|
|
154
|
+
categories: ['systems', 'embedded'],
|
|
155
|
+
c_standard: 'c11',
|
|
156
|
+
universal_rules: {
|
|
157
|
+
naming: 'enabled',
|
|
158
|
+
memory_safety: 'enabled',
|
|
159
|
+
error_handling: 'enabled',
|
|
160
|
+
documentation: 'warning',
|
|
161
|
+
header_guards: 'enabled',
|
|
162
|
+
const_correctness: 'enabled'
|
|
163
|
+
},
|
|
164
|
+
category_overrides: {
|
|
165
|
+
embedded: {
|
|
166
|
+
allow_dynamic_allocation: false
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
static_analysis: {
|
|
170
|
+
clang_tidy: true,
|
|
171
|
+
cppcheck: true,
|
|
172
|
+
valgrind: false
|
|
173
|
+
},
|
|
174
|
+
custom_rules: {
|
|
175
|
+
enabled: false,
|
|
176
|
+
path: '.augment/c-standards/custom-rules/'
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
await fs.writeFile(
|
|
182
|
+
path.join(configPath, '.augment/c-standards.json'),
|
|
183
|
+
JSON.stringify(config, null, 2)
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
describe('Complete Workflow: Configuration → Rules → Evaluation', () => {
|
|
188
|
+
it('should load configuration and rules successfully', async () => {
|
|
189
|
+
const config = configManager.getConfiguration();
|
|
190
|
+
const allRules = registry.getAllRules();
|
|
191
|
+
|
|
192
|
+
expect(config).toBeDefined();
|
|
193
|
+
expect(allRules.length).toBeGreaterThan(0);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
it('should evaluate code and detect violations', async () => {
|
|
197
|
+
const code = `
|
|
198
|
+
int myFunction() {
|
|
199
|
+
int* ptr = malloc(sizeof(int));
|
|
200
|
+
*ptr = 5;
|
|
201
|
+
return *ptr;
|
|
202
|
+
}
|
|
203
|
+
`;
|
|
204
|
+
|
|
205
|
+
const violations = await evaluator.evaluate(code, {
|
|
206
|
+
filePath: '/project/src/main.c',
|
|
207
|
+
rules: ['universal-naming', 'universal-memory-safety']
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
expect(violations.length).toBeGreaterThan(0);
|
|
211
|
+
expect(violations.some(v => v.ruleId === 'universal-naming')).toBe(true);
|
|
212
|
+
expect(violations.some(v => v.ruleId === 'universal-memory-safety')).toBe(true);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it('should generate AI prompt with active rules', async () => {
|
|
216
|
+
const prompt = await promptGenerator.generatePrompt({
|
|
217
|
+
filePath: '/project/src/main.c',
|
|
218
|
+
codeContext: 'int main() { return 0; }'
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
expect(prompt).toBeDefined();
|
|
222
|
+
expect(prompt.length).toBeGreaterThan(0);
|
|
223
|
+
expect(prompt).toContain('C Coding Standards');
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
it('should respect configuration overrides', async () => {
|
|
227
|
+
const config = configManager.getConfiguration();
|
|
228
|
+
expect(config.c_standards.categories).toContain('embedded');
|
|
229
|
+
|
|
230
|
+
const embeddedRules = registry.getRulesByCategory('embedded');
|
|
231
|
+
expect(embeddedRules.length).toBeGreaterThan(0);
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
it('should filter rules by enabled status', async () => {
|
|
235
|
+
registry.setRuleEnabled('universal-naming', false);
|
|
236
|
+
|
|
237
|
+
const code = 'int myFunction() { return 0; }';
|
|
238
|
+
const violations = await evaluator.evaluate(code, {
|
|
239
|
+
filePath: '/project/src/main.c',
|
|
240
|
+
rules: ['universal-naming']
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
expect(violations.length).toBe(0);
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
describe('Category-Specific Workflows', () => {
|
|
248
|
+
it('should apply embedded category rules', async () => {
|
|
249
|
+
const code = `
|
|
250
|
+
uint32_t* reg = (uint32_t*)0x40000000;
|
|
251
|
+
*reg = 0x01;
|
|
252
|
+
`;
|
|
253
|
+
|
|
254
|
+
const violations = await evaluator.evaluate(code, {
|
|
255
|
+
filePath: '/project/embedded/sensor.c',
|
|
256
|
+
rules: ['embedded-volatile']
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
expect(violations.length).toBeGreaterThan(0);
|
|
260
|
+
expect(violations[0].ruleId).toBe('embedded-volatile');
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
it('should generate category-specific prompts', async () => {
|
|
264
|
+
const prompt = await promptGenerator.generatePrompt({
|
|
265
|
+
filePath: '/project/embedded/sensor.c',
|
|
266
|
+
codeContext: 'volatile uint32_t* reg;',
|
|
267
|
+
category: 'embedded'
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
expect(prompt).toBeDefined();
|
|
271
|
+
expect(prompt).toContain('embedded');
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
describe('Multi-File Evaluation', () => {
|
|
276
|
+
it('should evaluate multiple files in batch', async () => {
|
|
277
|
+
const files = [
|
|
278
|
+
{
|
|
279
|
+
path: '/project/src/file1.c',
|
|
280
|
+
content: 'int myFunction() { return 0; }'
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
path: '/project/src/file2.c',
|
|
284
|
+
content: 'int my_function() { return 0; }'
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
path: '/project/src/file3.c',
|
|
288
|
+
content: 'int anotherBadName() { return 0; }'
|
|
289
|
+
}
|
|
290
|
+
];
|
|
291
|
+
|
|
292
|
+
const results = await evaluator.evaluateBatch(files, {
|
|
293
|
+
rules: ['universal-naming']
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
expect(results.length).toBe(3);
|
|
297
|
+
expect(results[0].violations.length).toBeGreaterThan(0);
|
|
298
|
+
expect(results[1].violations.length).toBe(0);
|
|
299
|
+
expect(results[2].violations.length).toBeGreaterThan(0);
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
it('should generate summary report for batch evaluation', async () => {
|
|
303
|
+
const files = [
|
|
304
|
+
{
|
|
305
|
+
path: '/project/src/file1.c',
|
|
306
|
+
content: 'int myFunction() { return 0; }'
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
path: '/project/src/file2.c',
|
|
310
|
+
content: 'int my_function() { return 0; }'
|
|
311
|
+
}
|
|
312
|
+
];
|
|
313
|
+
|
|
314
|
+
const results = await evaluator.evaluateBatch(files, {
|
|
315
|
+
rules: ['universal-naming']
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
const allViolations = results.flatMap(r => r.violations);
|
|
319
|
+
const report = evaluator.generateReport(allViolations, {
|
|
320
|
+
format: 'json',
|
|
321
|
+
includeSummary: true
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
const parsed = JSON.parse(report);
|
|
325
|
+
expect(parsed.summary).toBeDefined();
|
|
326
|
+
expect(parsed.summary.total).toBeGreaterThan(0);
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
describe('Configuration Hot-Reload', () => {
|
|
331
|
+
it('should reload configuration and update rules', async () => {
|
|
332
|
+
const config1 = configManager.getConfiguration();
|
|
333
|
+
expect(config1.c_standards.categories).toContain('systems');
|
|
334
|
+
|
|
335
|
+
// Modify configuration
|
|
336
|
+
const newConfig: Configuration = {
|
|
337
|
+
c_standards: {
|
|
338
|
+
...config1.c_standards,
|
|
339
|
+
categories: ['networking', 'kernel']
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
await fs.writeFile(
|
|
344
|
+
path.join(configPath, '.augment/c-standards.json'),
|
|
345
|
+
JSON.stringify(newConfig, null, 2)
|
|
346
|
+
);
|
|
347
|
+
|
|
348
|
+
await configManager.reload();
|
|
349
|
+
|
|
350
|
+
const config2 = configManager.getConfiguration();
|
|
351
|
+
expect(config2.c_standards.categories).toEqual(['networking', 'kernel']);
|
|
352
|
+
});
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
describe('Error Handling and Recovery', () => {
|
|
356
|
+
it('should handle invalid code gracefully', async () => {
|
|
357
|
+
const invalidCode = 'this is not valid C code @#$%';
|
|
358
|
+
|
|
359
|
+
await expect(evaluator.evaluate(invalidCode, {
|
|
360
|
+
filePath: '/project/src/invalid.c',
|
|
361
|
+
rules: ['universal-naming']
|
|
362
|
+
})).resolves.not.toThrow();
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
it('should handle missing rules gracefully', async () => {
|
|
366
|
+
const code = 'int my_function() { return 0; }';
|
|
367
|
+
|
|
368
|
+
const violations = await evaluator.evaluate(code, {
|
|
369
|
+
filePath: '/project/src/main.c',
|
|
370
|
+
rules: ['nonexistent-rule']
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
expect(violations).toBeDefined();
|
|
374
|
+
});
|
|
375
|
+
});
|
|
376
|
+
});
|
|
377
|
+
|