@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,307 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Prompt Generator for C Coding Standards
|
|
3
|
+
*
|
|
4
|
+
* Generates context-aware prompts for AI code generation by combining
|
|
5
|
+
* templates with active rules and examples.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as fs from 'fs/promises';
|
|
9
|
+
import * as path from 'path';
|
|
10
|
+
import { TemplateEngine, TemplateContext } from './template-engine';
|
|
11
|
+
import { RuleRegistry } from './registry';
|
|
12
|
+
import { ConfigurationManager } from './config-manager';
|
|
13
|
+
import { Category, Rule, Configuration } from './types';
|
|
14
|
+
|
|
15
|
+
export interface PromptContext {
|
|
16
|
+
filePath?: string;
|
|
17
|
+
fileType?: string;
|
|
18
|
+
category?: Category;
|
|
19
|
+
functionName?: string;
|
|
20
|
+
codeContext?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface GeneratedPrompt {
|
|
24
|
+
prompt: string;
|
|
25
|
+
category: Category;
|
|
26
|
+
activeRules: Rule[];
|
|
27
|
+
templateUsed: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export class PromptGenerator {
|
|
31
|
+
private templateEngine: TemplateEngine;
|
|
32
|
+
private templateCache: Map<Category, string> = new Map();
|
|
33
|
+
private promptCache: Map<string, GeneratedPrompt> = new Map();
|
|
34
|
+
private cacheEnabled: boolean = true;
|
|
35
|
+
|
|
36
|
+
constructor(
|
|
37
|
+
private ruleRegistry: RuleRegistry,
|
|
38
|
+
private configManager: ConfigurationManager,
|
|
39
|
+
private templatesPath: string
|
|
40
|
+
) {
|
|
41
|
+
this.templateEngine = new TemplateEngine();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Generate a prompt for the given context
|
|
46
|
+
*/
|
|
47
|
+
async generatePrompt(context: PromptContext): Promise<GeneratedPrompt> {
|
|
48
|
+
// Detect category from context
|
|
49
|
+
const category = this.detectCategory(context);
|
|
50
|
+
|
|
51
|
+
// Check cache
|
|
52
|
+
const cacheKey = this.getCacheKey(context, category);
|
|
53
|
+
if (this.cacheEnabled && this.promptCache.has(cacheKey)) {
|
|
54
|
+
return this.promptCache.get(cacheKey)!;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Load template for category
|
|
58
|
+
const template = await this.loadTemplate(category);
|
|
59
|
+
|
|
60
|
+
// Get active rules for category
|
|
61
|
+
const activeRules = this.getActiveRulesForCategory(category);
|
|
62
|
+
|
|
63
|
+
// Build template context
|
|
64
|
+
const templateContext = this.buildTemplateContext(
|
|
65
|
+
category,
|
|
66
|
+
activeRules,
|
|
67
|
+
context
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
// Render prompt
|
|
71
|
+
const prompt = this.templateEngine.render(template, templateContext);
|
|
72
|
+
|
|
73
|
+
const result: GeneratedPrompt = {
|
|
74
|
+
prompt,
|
|
75
|
+
category,
|
|
76
|
+
activeRules,
|
|
77
|
+
templateUsed: `${category}.txt`
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// Cache result
|
|
81
|
+
if (this.cacheEnabled) {
|
|
82
|
+
this.promptCache.set(cacheKey, result);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return result;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Detect category from context
|
|
90
|
+
*/
|
|
91
|
+
private detectCategory(context: PromptContext): Category {
|
|
92
|
+
// If category explicitly provided, use it
|
|
93
|
+
if (context.category) {
|
|
94
|
+
return context.category;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Detect from file path
|
|
98
|
+
if (context.filePath) {
|
|
99
|
+
const filePath = context.filePath.toLowerCase();
|
|
100
|
+
|
|
101
|
+
if (filePath.includes('kernel') || filePath.includes('module')) {
|
|
102
|
+
return 'kernel';
|
|
103
|
+
}
|
|
104
|
+
if (filePath.includes('driver')) {
|
|
105
|
+
return 'drivers';
|
|
106
|
+
}
|
|
107
|
+
if (filePath.includes('embedded') || filePath.includes('firmware')) {
|
|
108
|
+
return 'embedded';
|
|
109
|
+
}
|
|
110
|
+
if (filePath.includes('rtos') || filePath.includes('realtime')) {
|
|
111
|
+
return 'realtime';
|
|
112
|
+
}
|
|
113
|
+
if (filePath.includes('network') || filePath.includes('socket')) {
|
|
114
|
+
return 'networking';
|
|
115
|
+
}
|
|
116
|
+
if (filePath.includes('legacy') || filePath.includes('compat')) {
|
|
117
|
+
return 'legacy';
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Detect from code context
|
|
122
|
+
if (context.codeContext) {
|
|
123
|
+
const code = context.codeContext.toLowerCase();
|
|
124
|
+
|
|
125
|
+
if (code.includes('module_init') || code.includes('module_exit')) {
|
|
126
|
+
return 'kernel';
|
|
127
|
+
}
|
|
128
|
+
if (code.includes('volatile') && code.includes('isr')) {
|
|
129
|
+
return 'embedded';
|
|
130
|
+
}
|
|
131
|
+
if (code.includes('socket') || code.includes('htons')) {
|
|
132
|
+
return 'networking';
|
|
133
|
+
}
|
|
134
|
+
if (code.includes('rtos') || code.includes('freertos')) {
|
|
135
|
+
return 'realtime';
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Default to systems programming
|
|
140
|
+
return 'systems';
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Load template for category
|
|
145
|
+
*/
|
|
146
|
+
private async loadTemplate(category: Category): Promise<string> {
|
|
147
|
+
// Check cache
|
|
148
|
+
if (this.templateCache.has(category)) {
|
|
149
|
+
return this.templateCache.get(category)!;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Load from file
|
|
153
|
+
const templatePath = path.join(this.templatesPath, 'prompts', `${category}.txt`);
|
|
154
|
+
const template = await fs.readFile(templatePath, 'utf-8');
|
|
155
|
+
|
|
156
|
+
// Validate template
|
|
157
|
+
const validation = this.templateEngine.validate(template);
|
|
158
|
+
if (!validation.valid) {
|
|
159
|
+
throw new Error(`Invalid template for ${category}: ${validation.errors.join(', ')}`);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Cache template
|
|
163
|
+
this.templateCache.set(category, template);
|
|
164
|
+
|
|
165
|
+
return template;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Get active rules for category
|
|
170
|
+
*/
|
|
171
|
+
private getActiveRulesForCategory(category: Category): Rule[] {
|
|
172
|
+
const config = this.configManager.getConfiguration();
|
|
173
|
+
|
|
174
|
+
// Get all rules for this category
|
|
175
|
+
const categoryRules = this.ruleRegistry.getRulesByCategory(category);
|
|
176
|
+
|
|
177
|
+
// Get universal rules
|
|
178
|
+
const universalRules = this.ruleRegistry.getRulesByCategory('universal');
|
|
179
|
+
|
|
180
|
+
// Combine and filter for active rules
|
|
181
|
+
const allRules = [...categoryRules, ...universalRules];
|
|
182
|
+
|
|
183
|
+
// Filter by enabled status
|
|
184
|
+
return allRules.filter(rule => rule.enabled);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Build template context from rules and context
|
|
189
|
+
*/
|
|
190
|
+
private buildTemplateContext(
|
|
191
|
+
category: Category,
|
|
192
|
+
rules: Rule[],
|
|
193
|
+
context: PromptContext
|
|
194
|
+
): TemplateContext {
|
|
195
|
+
const config = this.configManager.getConfiguration();
|
|
196
|
+
|
|
197
|
+
// Build context object
|
|
198
|
+
const templateContext: TemplateContext = {
|
|
199
|
+
category,
|
|
200
|
+
c_standard: config?.c_standards.c_standard || 'c11',
|
|
201
|
+
rules: rules.map(rule => ({
|
|
202
|
+
id: rule.id,
|
|
203
|
+
name: rule.name,
|
|
204
|
+
description: rule.description,
|
|
205
|
+
severity: rule.severity
|
|
206
|
+
})),
|
|
207
|
+
examples: this.extractExamples(rules)
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
// Add file context if available
|
|
211
|
+
if (context.filePath) {
|
|
212
|
+
templateContext.file_path = context.filePath;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (context.functionName) {
|
|
216
|
+
templateContext.function_name = context.functionName;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return templateContext;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Extract examples from rules
|
|
224
|
+
*/
|
|
225
|
+
private extractExamples(rules: Rule[]): Array<{ title: string; code: string }> {
|
|
226
|
+
const examples: Array<{ title: string; code: string }> = [];
|
|
227
|
+
|
|
228
|
+
for (const rule of rules) {
|
|
229
|
+
// Add good examples
|
|
230
|
+
for (const example of rule.examples.good) {
|
|
231
|
+
examples.push({
|
|
232
|
+
title: `${rule.name} - Good Example`,
|
|
233
|
+
code: example.code
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// Limit to top 5 examples to keep prompt size reasonable
|
|
239
|
+
return examples.slice(0, 5);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Generate cache key
|
|
244
|
+
*/
|
|
245
|
+
private getCacheKey(context: PromptContext, category: Category): string {
|
|
246
|
+
const parts = [
|
|
247
|
+
category,
|
|
248
|
+
context.filePath || '',
|
|
249
|
+
context.functionName || '',
|
|
250
|
+
context.fileType || ''
|
|
251
|
+
];
|
|
252
|
+
return parts.join(':');
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Clear cache
|
|
257
|
+
*/
|
|
258
|
+
clearCache(): void {
|
|
259
|
+
this.promptCache.clear();
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Enable or disable caching
|
|
264
|
+
*/
|
|
265
|
+
setCacheEnabled(enabled: boolean): void {
|
|
266
|
+
this.cacheEnabled = enabled;
|
|
267
|
+
if (!enabled) {
|
|
268
|
+
this.clearCache();
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Preload all templates
|
|
274
|
+
*/
|
|
275
|
+
async preloadTemplates(): Promise<void> {
|
|
276
|
+
const categories: Category[] = [
|
|
277
|
+
'systems',
|
|
278
|
+
'embedded',
|
|
279
|
+
'kernel',
|
|
280
|
+
'drivers',
|
|
281
|
+
'realtime',
|
|
282
|
+
'networking',
|
|
283
|
+
'legacy'
|
|
284
|
+
];
|
|
285
|
+
|
|
286
|
+
for (const category of categories) {
|
|
287
|
+
await this.loadTemplate(category);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Get statistics about cached prompts
|
|
293
|
+
*/
|
|
294
|
+
getCacheStats(): { size: number; categories: Record<Category, number> } {
|
|
295
|
+
const stats: { size: number; categories: Record<Category, number> } = {
|
|
296
|
+
size: this.promptCache.size,
|
|
297
|
+
categories: {} as Record<Category, number>
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
for (const [, prompt] of this.promptCache) {
|
|
301
|
+
const category = prompt.category;
|
|
302
|
+
stats.categories[category] = (stats.categories[category] || 0) + 1;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
return stats;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rule Evaluator for C Coding Standards
|
|
3
|
+
*
|
|
4
|
+
* Applies active rules to code and generates violation reports.
|
|
5
|
+
* Supports filtering by category, severity, and configuration.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { Rule, Category, Configuration } from './types';
|
|
9
|
+
import { RuleRegistry } from './registry';
|
|
10
|
+
import { ConfigurationManager } from './config-manager';
|
|
11
|
+
|
|
12
|
+
export interface CodeContext {
|
|
13
|
+
filePath: string;
|
|
14
|
+
content: string;
|
|
15
|
+
category?: Category;
|
|
16
|
+
language?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface RuleViolation {
|
|
20
|
+
ruleId: string;
|
|
21
|
+
ruleName: string;
|
|
22
|
+
severity: 'ERROR' | 'WARNING' | 'INFO';
|
|
23
|
+
message: string;
|
|
24
|
+
line?: number;
|
|
25
|
+
column?: number;
|
|
26
|
+
suggestion?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface EvaluationResult {
|
|
30
|
+
filePath: string;
|
|
31
|
+
violations: RuleViolation[];
|
|
32
|
+
summary: {
|
|
33
|
+
errors: number;
|
|
34
|
+
warnings: number;
|
|
35
|
+
info: number;
|
|
36
|
+
total: number;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface EvaluationOptions {
|
|
41
|
+
categories?: Category[];
|
|
42
|
+
severity?: 'ERROR' | 'WARNING' | 'INFO';
|
|
43
|
+
enabledOnly?: boolean;
|
|
44
|
+
maxViolations?: number;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export class RuleEvaluator {
|
|
48
|
+
constructor(
|
|
49
|
+
private registry: RuleRegistry,
|
|
50
|
+
private configManager: ConfigurationManager
|
|
51
|
+
) {}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Evaluate code against active rules
|
|
55
|
+
*/
|
|
56
|
+
async evaluate(
|
|
57
|
+
context: CodeContext,
|
|
58
|
+
options: EvaluationOptions = {}
|
|
59
|
+
): Promise<EvaluationResult> {
|
|
60
|
+
const violations: RuleViolation[] = [];
|
|
61
|
+
|
|
62
|
+
// Get applicable rules
|
|
63
|
+
const rules = this.getApplicableRules(context, options);
|
|
64
|
+
|
|
65
|
+
// Apply each rule
|
|
66
|
+
for (const rule of rules) {
|
|
67
|
+
const ruleViolations = await this.applyRule(rule, context);
|
|
68
|
+
violations.push(...ruleViolations);
|
|
69
|
+
|
|
70
|
+
// Check max violations limit
|
|
71
|
+
if (options.maxViolations && violations.length >= options.maxViolations) {
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Generate summary
|
|
77
|
+
const summary = this.generateSummary(violations);
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
filePath: context.filePath,
|
|
81
|
+
violations,
|
|
82
|
+
summary
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Get rules applicable to the given context
|
|
88
|
+
*/
|
|
89
|
+
private getApplicableRules(
|
|
90
|
+
context: CodeContext,
|
|
91
|
+
options: EvaluationOptions
|
|
92
|
+
): Rule[] {
|
|
93
|
+
const config = this.configManager.getConfiguration();
|
|
94
|
+
|
|
95
|
+
// Start with all rules
|
|
96
|
+
let rules = this.registry.getAllRules();
|
|
97
|
+
|
|
98
|
+
// Filter by enabled status
|
|
99
|
+
if (options.enabledOnly !== false) {
|
|
100
|
+
rules = rules.filter(rule => rule.enabled);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Filter by category
|
|
104
|
+
const categories = options.categories ||
|
|
105
|
+
(context.category ? [context.category] : config.c_standards.categories);
|
|
106
|
+
|
|
107
|
+
if (categories && categories.length > 0) {
|
|
108
|
+
rules = rules.filter(rule =>
|
|
109
|
+
rule.category.some(cat => categories.includes(cat as Category))
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Filter by severity
|
|
114
|
+
if (options.severity) {
|
|
115
|
+
rules = rules.filter(rule => rule.severity === options.severity);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Apply configuration overrides
|
|
119
|
+
rules = this.applyConfigurationFilters(rules, config);
|
|
120
|
+
|
|
121
|
+
return rules;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Apply configuration-based filters to rules
|
|
126
|
+
*/
|
|
127
|
+
private applyConfigurationFilters(
|
|
128
|
+
rules: Rule[],
|
|
129
|
+
config: Configuration
|
|
130
|
+
): Rule[] {
|
|
131
|
+
return rules.filter(rule => {
|
|
132
|
+
// Check if rule is disabled in configuration
|
|
133
|
+
const ruleKey = rule.id.split('-').pop();
|
|
134
|
+
if (ruleKey && config.c_standards.universal_rules) {
|
|
135
|
+
const severity = config.c_standards.universal_rules[ruleKey as keyof typeof config.c_standards.universal_rules];
|
|
136
|
+
if (severity === 'disabled') {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return true;
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Apply a single rule to code context
|
|
146
|
+
*/
|
|
147
|
+
private async applyRule(
|
|
148
|
+
rule: Rule,
|
|
149
|
+
context: CodeContext
|
|
150
|
+
): Promise<RuleViolation[]> {
|
|
151
|
+
const violations: RuleViolation[] = [];
|
|
152
|
+
|
|
153
|
+
// Basic pattern matching for demonstration
|
|
154
|
+
// In production, this would use AST analysis or static analysis tools
|
|
155
|
+
const lines = context.content.split('\n');
|
|
156
|
+
|
|
157
|
+
for (let i = 0; i < lines.length; i++) {
|
|
158
|
+
const line = lines[i];
|
|
159
|
+
const lineNumber = i + 1;
|
|
160
|
+
|
|
161
|
+
// Check for violations based on rule patterns
|
|
162
|
+
const violation = this.checkLineForViolation(rule, line, lineNumber);
|
|
163
|
+
if (violation) {
|
|
164
|
+
violations.push(violation);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return violations;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Check a single line for rule violations
|
|
173
|
+
*/
|
|
174
|
+
private checkLineForViolation(
|
|
175
|
+
rule: Rule,
|
|
176
|
+
line: string,
|
|
177
|
+
lineNumber: number
|
|
178
|
+
): RuleViolation | null {
|
|
179
|
+
// This is a simplified implementation
|
|
180
|
+
// In production, use proper AST parsing and static analysis
|
|
181
|
+
|
|
182
|
+
// Example: Check for naming convention violations
|
|
183
|
+
if (rule.id.includes('naming')) {
|
|
184
|
+
// Check for camelCase in function names (should be snake_case)
|
|
185
|
+
const funcMatch = line.match(/\b([a-z]+[A-Z][a-zA-Z]*)\s*\(/);
|
|
186
|
+
if (funcMatch) {
|
|
187
|
+
return {
|
|
188
|
+
ruleId: rule.id,
|
|
189
|
+
ruleName: rule.name,
|
|
190
|
+
severity: rule.severity,
|
|
191
|
+
message: `Function name '${funcMatch[1]}' should use snake_case, not camelCase`,
|
|
192
|
+
line: lineNumber,
|
|
193
|
+
suggestion: `Use ${this.toSnakeCase(funcMatch[1])} instead`
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// Example: Check for memory safety violations
|
|
199
|
+
if (rule.id.includes('memory')) {
|
|
200
|
+
// Check for malloc without null check
|
|
201
|
+
if (line.includes('malloc(') && !line.includes('if')) {
|
|
202
|
+
return {
|
|
203
|
+
ruleId: rule.id,
|
|
204
|
+
ruleName: rule.name,
|
|
205
|
+
severity: rule.severity,
|
|
206
|
+
message: 'malloc() call should be followed by null pointer check',
|
|
207
|
+
line: lineNumber,
|
|
208
|
+
suggestion: 'Add: if (ptr == NULL) { /* handle error */ }'
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return null;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Convert camelCase to snake_case
|
|
218
|
+
*/
|
|
219
|
+
private toSnakeCase(str: string): string {
|
|
220
|
+
return str.replace(/[A-Z]/g, letter => `_${letter.toLowerCase()}`);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Generate summary statistics
|
|
225
|
+
*/
|
|
226
|
+
private generateSummary(violations: RuleViolation[]): EvaluationResult['summary'] {
|
|
227
|
+
const summary = {
|
|
228
|
+
errors: 0,
|
|
229
|
+
warnings: 0,
|
|
230
|
+
info: 0,
|
|
231
|
+
total: violations.length
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
for (const violation of violations) {
|
|
235
|
+
if (violation.severity === 'ERROR') {
|
|
236
|
+
summary.errors++;
|
|
237
|
+
} else if (violation.severity === 'WARNING') {
|
|
238
|
+
summary.warnings++;
|
|
239
|
+
} else {
|
|
240
|
+
summary.info++;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return summary;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Batch evaluate multiple files
|
|
249
|
+
*/
|
|
250
|
+
async evaluateBatch(
|
|
251
|
+
contexts: CodeContext[],
|
|
252
|
+
options: EvaluationOptions = {}
|
|
253
|
+
): Promise<EvaluationResult[]> {
|
|
254
|
+
const results: EvaluationResult[] = [];
|
|
255
|
+
|
|
256
|
+
for (const context of contexts) {
|
|
257
|
+
const result = await this.evaluate(context, options);
|
|
258
|
+
results.push(result);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
return results;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Generate a formatted report
|
|
266
|
+
*/
|
|
267
|
+
generateReport(results: EvaluationResult[]): string {
|
|
268
|
+
let report = '# C Coding Standards Evaluation Report\n\n';
|
|
269
|
+
|
|
270
|
+
// Overall summary
|
|
271
|
+
const totalViolations = results.reduce((sum, r) => sum + r.summary.total, 0);
|
|
272
|
+
const totalErrors = results.reduce((sum, r) => sum + r.summary.errors, 0);
|
|
273
|
+
const totalWarnings = results.reduce((sum, r) => sum + r.summary.warnings, 0);
|
|
274
|
+
const totalInfo = results.reduce((sum, r) => sum + r.summary.info, 0);
|
|
275
|
+
|
|
276
|
+
report += `## Summary\n\n`;
|
|
277
|
+
report += `- Files evaluated: ${results.length}\n`;
|
|
278
|
+
report += `- Total violations: ${totalViolations}\n`;
|
|
279
|
+
report += `- Errors: ${totalErrors}\n`;
|
|
280
|
+
report += `- Warnings: ${totalWarnings}\n`;
|
|
281
|
+
report += `- Info: ${totalInfo}\n\n`;
|
|
282
|
+
|
|
283
|
+
// Per-file details
|
|
284
|
+
report += `## Details\n\n`;
|
|
285
|
+
|
|
286
|
+
for (const result of results) {
|
|
287
|
+
if (result.violations.length === 0) {
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
report += `### ${result.filePath}\n\n`;
|
|
292
|
+
report += `Violations: ${result.summary.total} (${result.summary.errors} errors, ${result.summary.warnings} warnings, ${result.summary.info} info)\n\n`;
|
|
293
|
+
|
|
294
|
+
for (const violation of result.violations) {
|
|
295
|
+
report += `- **[${violation.severity}]** Line ${violation.line}: ${violation.message}\n`;
|
|
296
|
+
if (violation.suggestion) {
|
|
297
|
+
report += ` - Suggestion: ${violation.suggestion}\n`;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
report += '\n';
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
return report;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|