@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,181 @@
|
|
|
1
|
+
# Web Service Project Template
|
|
2
|
+
|
|
3
|
+
## Context
|
|
4
|
+
|
|
5
|
+
You are generating Go code for a **web service** project. This includes HTTP servers, RESTful APIs, web applications, and API gateways.
|
|
6
|
+
|
|
7
|
+
## Standards
|
|
8
|
+
|
|
9
|
+
Follow these Go coding standards for web services:
|
|
10
|
+
|
|
11
|
+
### Universal Rules
|
|
12
|
+
|
|
13
|
+
1. **Naming Conventions**: Use MixedCaps for exported names, mixedCaps for unexported
|
|
14
|
+
2. **Error Handling**: Return errors explicitly, use `errors.Is/As` for error inspection
|
|
15
|
+
3. **Concurrency**: Use goroutines and channels properly, always pass context
|
|
16
|
+
4. **Testing**: Write table-driven tests, use `httptest` for HTTP testing
|
|
17
|
+
5. **Code Organization**: Keep packages flat and focused
|
|
18
|
+
6. **Documentation**: Add godoc comments for all exported functions
|
|
19
|
+
7. **Performance**: Minimize allocations, use `sync.Pool` for reusable objects
|
|
20
|
+
|
|
21
|
+
### Web Services Rules
|
|
22
|
+
|
|
23
|
+
#### HTTP Handlers
|
|
24
|
+
- Use standard `http.Handler` and `http.HandlerFunc` interfaces
|
|
25
|
+
- Always use `context.Context` from `r.Context()` for request-scoped values
|
|
26
|
+
- Return appropriate HTTP status codes (2xx, 4xx, 5xx)
|
|
27
|
+
- Validate all inputs before processing
|
|
28
|
+
- Use `http.Error` for error responses
|
|
29
|
+
|
|
30
|
+
#### Middleware
|
|
31
|
+
- Implement middleware using `func(http.Handler) http.Handler` pattern
|
|
32
|
+
- Chain middleware for logging, authentication, metrics, recovery
|
|
33
|
+
- Use context to pass values between middleware layers
|
|
34
|
+
- Always include panic recovery middleware
|
|
35
|
+
- Instrument with Prometheus metrics
|
|
36
|
+
|
|
37
|
+
#### Routing
|
|
38
|
+
- Use established routing libraries (`chi`, `gorilla/mux`, `echo`)
|
|
39
|
+
- Follow RESTful resource naming (plural nouns, standard HTTP methods)
|
|
40
|
+
- Extract and validate URL parameters safely
|
|
41
|
+
- Implement API versioning (e.g., `/api/v1`, `/api/v2`)
|
|
42
|
+
- Use query parameters for filtering, sorting, pagination
|
|
43
|
+
|
|
44
|
+
#### Graceful Shutdown
|
|
45
|
+
- Implement signal-based shutdown (SIGINT, SIGTERM)
|
|
46
|
+
- Set appropriate shutdown timeout (typically 30 seconds)
|
|
47
|
+
- Clean up resources (database connections, file handles)
|
|
48
|
+
- Update health checks to mark service as unhealthy during shutdown
|
|
49
|
+
|
|
50
|
+
## Key Requirements
|
|
51
|
+
|
|
52
|
+
### HTTP Server Setup
|
|
53
|
+
```go
|
|
54
|
+
srv := &http.Server{
|
|
55
|
+
Addr: ":8080",
|
|
56
|
+
Handler: routes(),
|
|
57
|
+
ReadTimeout: 15 * time.Second,
|
|
58
|
+
WriteTimeout: 15 * time.Second,
|
|
59
|
+
IdleTimeout: 60 * time.Second,
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Handler Pattern
|
|
64
|
+
```go
|
|
65
|
+
func handleResource(w http.ResponseWriter, r *http.Request) {
|
|
66
|
+
ctx := r.Context()
|
|
67
|
+
|
|
68
|
+
// Extract parameters
|
|
69
|
+
id := chi.URLParam(r, "id")
|
|
70
|
+
|
|
71
|
+
// Validate input
|
|
72
|
+
if id == "" {
|
|
73
|
+
http.Error(w, "Missing ID", http.StatusBadRequest)
|
|
74
|
+
return
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Process request
|
|
78
|
+
result, err := processRequest(ctx, id)
|
|
79
|
+
if err != nil {
|
|
80
|
+
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
81
|
+
return
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Return response
|
|
85
|
+
w.Header().Set("Content-Type", "application/json")
|
|
86
|
+
json.NewEncoder(w).Encode(result)
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Middleware Pattern
|
|
91
|
+
```go
|
|
92
|
+
func loggingMiddleware(next http.Handler) http.Handler {
|
|
93
|
+
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
94
|
+
start := time.Now()
|
|
95
|
+
next.ServeHTTP(w, r)
|
|
96
|
+
log.Printf("%s %s %v", r.Method, r.URL.Path, time.Since(start))
|
|
97
|
+
})
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Graceful Shutdown
|
|
102
|
+
```go
|
|
103
|
+
func main() {
|
|
104
|
+
srv := &http.Server{Addr: ":8080", Handler: routes()}
|
|
105
|
+
|
|
106
|
+
go func() {
|
|
107
|
+
if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
|
108
|
+
log.Fatal(err)
|
|
109
|
+
}
|
|
110
|
+
}()
|
|
111
|
+
|
|
112
|
+
quit := make(chan os.Signal, 1)
|
|
113
|
+
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
|
|
114
|
+
<-quit
|
|
115
|
+
|
|
116
|
+
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
|
117
|
+
defer cancel()
|
|
118
|
+
|
|
119
|
+
if err := srv.Shutdown(ctx); err != nil {
|
|
120
|
+
log.Fatal(err)
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## Common Patterns
|
|
126
|
+
|
|
127
|
+
### RESTful API Structure
|
|
128
|
+
```
|
|
129
|
+
GET /api/v1/users - List users
|
|
130
|
+
POST /api/v1/users - Create user
|
|
131
|
+
GET /api/v1/users/{id} - Get user
|
|
132
|
+
PUT /api/v1/users/{id} - Update user
|
|
133
|
+
DELETE /api/v1/users/{id} - Delete user
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Error Response Format
|
|
137
|
+
```go
|
|
138
|
+
type ErrorResponse struct {
|
|
139
|
+
Error string `json:"error"`
|
|
140
|
+
Message string `json:"message"`
|
|
141
|
+
Code int `json:"code"`
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Pagination Response
|
|
146
|
+
```go
|
|
147
|
+
type PaginatedResponse struct {
|
|
148
|
+
Data interface{} `json:"data"`
|
|
149
|
+
Total int `json:"total"`
|
|
150
|
+
Page int `json:"page"`
|
|
151
|
+
Limit int `json:"limit"`
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Tools
|
|
156
|
+
|
|
157
|
+
Ensure generated code passes:
|
|
158
|
+
- `go build` - Compiles without errors
|
|
159
|
+
- `golangci-lint run` - Passes all linters
|
|
160
|
+
- `go vet` - No suspicious constructs
|
|
161
|
+
- `gofmt -d .` - Properly formatted
|
|
162
|
+
- `go test -race` - No race conditions
|
|
163
|
+
|
|
164
|
+
## Output Format
|
|
165
|
+
|
|
166
|
+
Generate complete, production-ready Go code with:
|
|
167
|
+
- Package declaration and imports
|
|
168
|
+
- Struct definitions with JSON tags
|
|
169
|
+
- HTTP handlers with proper error handling
|
|
170
|
+
- Middleware for cross-cutting concerns
|
|
171
|
+
- Graceful shutdown implementation
|
|
172
|
+
- Comprehensive godoc comments
|
|
173
|
+
- Example usage in comments
|
|
174
|
+
|
|
175
|
+
## References
|
|
176
|
+
|
|
177
|
+
- [Effective Go](https://golang.org/doc/effective_go)
|
|
178
|
+
- [Go net/http package](https://pkg.go.dev/net/http)
|
|
179
|
+
- [chi router](https://github.com/go-chi/chi)
|
|
180
|
+
- [Uber Go Style Guide](https://github.com/uber-go/guide)
|
|
181
|
+
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Integration Tests: Go Module Integration
|
|
3
|
+
*
|
|
4
|
+
* Tests for end-to-end module integration with Augment Extensions.
|
|
5
|
+
* Covers GOL.4.2 - Integration Tests
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { describe, it, expect } from 'vitest';
|
|
9
|
+
import { existsSync, readFileSync } from 'fs';
|
|
10
|
+
import { join } from 'path';
|
|
11
|
+
|
|
12
|
+
const MODULE_ROOT = join(__dirname, '../..');
|
|
13
|
+
const AUGMENT_ROOT = join(__dirname, '../../../..');
|
|
14
|
+
|
|
15
|
+
describe('Module Integration', () => {
|
|
16
|
+
describe('Single Category Selection', () => {
|
|
17
|
+
it('should load web category successfully', () => {
|
|
18
|
+
const webRulesPath = join(MODULE_ROOT, 'rules/web');
|
|
19
|
+
const universalRulesPath = join(MODULE_ROOT, 'rules/universal');
|
|
20
|
+
|
|
21
|
+
expect(existsSync(webRulesPath)).toBe(true);
|
|
22
|
+
expect(existsSync(universalRulesPath)).toBe(true);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('should load microservices category successfully', () => {
|
|
26
|
+
const microRulesPath = join(MODULE_ROOT, 'rules/microservices');
|
|
27
|
+
const universalRulesPath = join(MODULE_ROOT, 'rules/universal');
|
|
28
|
+
|
|
29
|
+
expect(existsSync(microRulesPath)).toBe(true);
|
|
30
|
+
expect(existsSync(universalRulesPath)).toBe(true);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('should load cli category successfully', () => {
|
|
34
|
+
const cliRulesPath = join(MODULE_ROOT, 'rules/cli');
|
|
35
|
+
const universalRulesPath = join(MODULE_ROOT, 'rules/universal');
|
|
36
|
+
|
|
37
|
+
expect(existsSync(cliRulesPath)).toBe(true);
|
|
38
|
+
expect(existsSync(universalRulesPath)).toBe(true);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
describe('Multiple Category Combinations', () => {
|
|
43
|
+
it('should support web + api combination', () => {
|
|
44
|
+
const webPath = join(MODULE_ROOT, 'rules/web');
|
|
45
|
+
const apiPath = join(MODULE_ROOT, 'rules/api');
|
|
46
|
+
|
|
47
|
+
expect(existsSync(webPath)).toBe(true);
|
|
48
|
+
expect(existsSync(apiPath)).toBe(true);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('should support microservices + distributed combination', () => {
|
|
52
|
+
const microPath = join(MODULE_ROOT, 'rules/microservices');
|
|
53
|
+
const distPath = join(MODULE_ROOT, 'rules/distributed');
|
|
54
|
+
|
|
55
|
+
expect(existsSync(microPath)).toBe(true);
|
|
56
|
+
expect(existsSync(distPath)).toBe(true);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('should support cli + devops combination', () => {
|
|
60
|
+
const cliPath = join(MODULE_ROOT, 'rules/cli');
|
|
61
|
+
const devopsPath = join(MODULE_ROOT, 'rules/devops');
|
|
62
|
+
|
|
63
|
+
expect(existsSync(cliPath)).toBe(true);
|
|
64
|
+
expect(existsSync(devopsPath)).toBe(true);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
describe('Rule Application Workflow', () => {
|
|
69
|
+
it('should have accessible universal rules', () => {
|
|
70
|
+
const universalPath = join(MODULE_ROOT, 'rules/universal');
|
|
71
|
+
const namingPath = join(universalPath, 'naming-conventions.md');
|
|
72
|
+
const errorPath = join(universalPath, 'error-handling.md');
|
|
73
|
+
|
|
74
|
+
expect(existsSync(namingPath)).toBe(true);
|
|
75
|
+
expect(existsSync(errorPath)).toBe(true);
|
|
76
|
+
|
|
77
|
+
const namingContent = readFileSync(namingPath, 'utf-8');
|
|
78
|
+
expect(namingContent).toContain('MixedCaps');
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('should have accessible category rules', () => {
|
|
82
|
+
const webPath = join(MODULE_ROOT, 'rules/web');
|
|
83
|
+
const files = require('fs').readdirSync(webPath);
|
|
84
|
+
|
|
85
|
+
expect(files.length).toBeGreaterThan(0);
|
|
86
|
+
files.forEach((file: string) => {
|
|
87
|
+
const filePath = join(webPath, file);
|
|
88
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
89
|
+
expect(content.length).toBeGreaterThan(0);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
describe('AI Prompt Generation', () => {
|
|
95
|
+
it('should have web-service template for AI', () => {
|
|
96
|
+
const templatePath = join(MODULE_ROOT, 'templates/web-service.md');
|
|
97
|
+
expect(existsSync(templatePath)).toBe(true);
|
|
98
|
+
|
|
99
|
+
const content = readFileSync(templatePath, 'utf-8');
|
|
100
|
+
expect(content).toContain('## Context');
|
|
101
|
+
expect(content).toContain('## Standards');
|
|
102
|
+
expect(content).toContain('## Examples');
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it('should have microservice template for AI', () => {
|
|
106
|
+
const templatePath = join(MODULE_ROOT, 'templates/microservice.md');
|
|
107
|
+
expect(existsSync(templatePath)).toBe(true);
|
|
108
|
+
|
|
109
|
+
const content = readFileSync(templatePath, 'utf-8');
|
|
110
|
+
expect(content).toContain('gRPC');
|
|
111
|
+
expect(content).toContain('service discovery');
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('should have cli-tool template for AI', () => {
|
|
115
|
+
const templatePath = join(MODULE_ROOT, 'templates/cli-tool.md');
|
|
116
|
+
expect(existsSync(templatePath)).toBe(true);
|
|
117
|
+
|
|
118
|
+
const content = readFileSync(templatePath, 'utf-8');
|
|
119
|
+
expect(content).toContain('Cobra');
|
|
120
|
+
expect(content).toContain('command-line');
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('should reference universal rules in templates', () => {
|
|
124
|
+
const templatePath = join(MODULE_ROOT, 'templates/web-service.md');
|
|
125
|
+
const content = readFileSync(templatePath, 'utf-8');
|
|
126
|
+
|
|
127
|
+
expect(content).toContain('Naming Conventions');
|
|
128
|
+
expect(content).toContain('Error Handling');
|
|
129
|
+
expect(content).toContain('Testing');
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
describe('Module Catalog Integration', () => {
|
|
134
|
+
it('should be listed in augment-extensions', () => {
|
|
135
|
+
const modulePath = join(MODULE_ROOT, 'module.json');
|
|
136
|
+
expect(existsSync(modulePath)).toBe(true);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('should have proper module type', () => {
|
|
140
|
+
const modulePath = join(MODULE_ROOT, 'module.json');
|
|
141
|
+
const module = JSON.parse(readFileSync(modulePath, 'utf-8'));
|
|
142
|
+
|
|
143
|
+
expect(module.type).toBe('coding-standards');
|
|
144
|
+
expect(module.language).toBe('go');
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
describe('Configuration Integration', () => {
|
|
149
|
+
it('should have valid configuration schema', () => {
|
|
150
|
+
const schemaPath = join(MODULE_ROOT, 'config/schema.json');
|
|
151
|
+
const schema = JSON.parse(readFileSync(schemaPath, 'utf-8'));
|
|
152
|
+
|
|
153
|
+
expect(schema.type).toBe('object');
|
|
154
|
+
expect(schema.properties).toBeDefined();
|
|
155
|
+
expect(schema.properties.categories).toBeDefined();
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it('should have example configurations', () => {
|
|
159
|
+
const examplesPath = join(MODULE_ROOT, 'config/examples');
|
|
160
|
+
expect(existsSync(examplesPath)).toBe(true);
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unit Tests: Category Selection
|
|
3
|
+
*
|
|
4
|
+
* Tests for category selection mechanism and rule loading.
|
|
5
|
+
* Covers GOL.4.1.2 - Category Selection Tests
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { describe, it, expect } from 'vitest';
|
|
9
|
+
import { existsSync, readdirSync } from 'fs';
|
|
10
|
+
import { join } from 'path';
|
|
11
|
+
|
|
12
|
+
const MODULE_ROOT = join(__dirname, '../..');
|
|
13
|
+
|
|
14
|
+
describe('Category Selection', () => {
|
|
15
|
+
const categories = [
|
|
16
|
+
'web',
|
|
17
|
+
'microservices',
|
|
18
|
+
'cli',
|
|
19
|
+
'cloud',
|
|
20
|
+
'distributed',
|
|
21
|
+
'devops',
|
|
22
|
+
'api'
|
|
23
|
+
];
|
|
24
|
+
|
|
25
|
+
describe('Category Directories', () => {
|
|
26
|
+
categories.forEach(category => {
|
|
27
|
+
it(`should have ${category} rules directory`, () => {
|
|
28
|
+
const categoryPath = join(MODULE_ROOT, 'rules', category);
|
|
29
|
+
expect(existsSync(categoryPath)).toBe(true);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
describe('Category Rules', () => {
|
|
35
|
+
it('should have web category rules', () => {
|
|
36
|
+
const webPath = join(MODULE_ROOT, 'rules/web');
|
|
37
|
+
const files = readdirSync(webPath);
|
|
38
|
+
expect(files.length).toBeGreaterThan(0);
|
|
39
|
+
expect(files.some(f => f.endsWith('.md'))).toBe(true);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('should have microservices category rules', () => {
|
|
43
|
+
const microPath = join(MODULE_ROOT, 'rules/microservices');
|
|
44
|
+
const files = readdirSync(microPath);
|
|
45
|
+
expect(files.length).toBeGreaterThan(0);
|
|
46
|
+
expect(files.some(f => f.endsWith('.md'))).toBe(true);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('should have cli category rules', () => {
|
|
50
|
+
const cliPath = join(MODULE_ROOT, 'rules/cli');
|
|
51
|
+
const files = readdirSync(cliPath);
|
|
52
|
+
expect(files.length).toBeGreaterThan(0);
|
|
53
|
+
expect(files.some(f => f.endsWith('.md'))).toBe(true);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
describe('Category Examples', () => {
|
|
58
|
+
it('should have web examples', () => {
|
|
59
|
+
const webExamplePath = join(MODULE_ROOT, 'examples/web');
|
|
60
|
+
expect(existsSync(webExamplePath)).toBe(true);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('should have microservices examples', () => {
|
|
64
|
+
const microExamplePath = join(MODULE_ROOT, 'examples/microservices');
|
|
65
|
+
expect(existsSync(microExamplePath)).toBe(true);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('should have cli examples', () => {
|
|
69
|
+
const cliExamplePath = join(MODULE_ROOT, 'examples/cli');
|
|
70
|
+
expect(existsSync(cliExamplePath)).toBe(true);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
describe('Category Templates', () => {
|
|
75
|
+
it('should have web-service template', () => {
|
|
76
|
+
const templatePath = join(MODULE_ROOT, 'templates/web-service.md');
|
|
77
|
+
expect(existsSync(templatePath)).toBe(true);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('should have microservice template', () => {
|
|
81
|
+
const templatePath = join(MODULE_ROOT, 'templates/microservice.md');
|
|
82
|
+
expect(existsSync(templatePath)).toBe(true);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('should have cli-tool template', () => {
|
|
86
|
+
const templatePath = join(MODULE_ROOT, 'templates/cli-tool.md');
|
|
87
|
+
expect(existsSync(templatePath)).toBe(true);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
describe('Category Metadata', () => {
|
|
92
|
+
it('should have category descriptions in module.json', () => {
|
|
93
|
+
const modulePath = join(MODULE_ROOT, 'module.json');
|
|
94
|
+
const content = require(modulePath);
|
|
95
|
+
|
|
96
|
+
categories.forEach(category => {
|
|
97
|
+
expect(content.categories).toContain(category);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
describe('Rule Loading', () => {
|
|
103
|
+
it('should load universal rules for all categories', () => {
|
|
104
|
+
const universalPath = join(MODULE_ROOT, 'rules/universal');
|
|
105
|
+
const files = readdirSync(universalPath);
|
|
106
|
+
|
|
107
|
+
const expectedRules = [
|
|
108
|
+
'naming-conventions.md',
|
|
109
|
+
'error-handling.md',
|
|
110
|
+
'concurrency.md',
|
|
111
|
+
'testing.md',
|
|
112
|
+
'code-organization.md',
|
|
113
|
+
'documentation.md',
|
|
114
|
+
'performance.md'
|
|
115
|
+
];
|
|
116
|
+
|
|
117
|
+
expectedRules.forEach(rule => {
|
|
118
|
+
expect(files).toContain(rule);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('should have category-specific rules separate from universal', () => {
|
|
123
|
+
const webPath = join(MODULE_ROOT, 'rules/web');
|
|
124
|
+
const webFiles = readdirSync(webPath);
|
|
125
|
+
|
|
126
|
+
const universalPath = join(MODULE_ROOT, 'rules/universal');
|
|
127
|
+
const universalFiles = readdirSync(universalPath);
|
|
128
|
+
|
|
129
|
+
// Web rules should not duplicate universal rules
|
|
130
|
+
const overlap = webFiles.filter(f => universalFiles.includes(f));
|
|
131
|
+
expect(overlap.length).toBe(0);
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
describe('Multi-Category Support', () => {
|
|
136
|
+
it('should support selecting multiple categories', () => {
|
|
137
|
+
// Test that multiple category directories can coexist
|
|
138
|
+
const selectedCategories = ['web', 'microservices', 'api'];
|
|
139
|
+
|
|
140
|
+
selectedCategories.forEach(category => {
|
|
141
|
+
const categoryPath = join(MODULE_ROOT, 'rules', category);
|
|
142
|
+
expect(existsSync(categoryPath)).toBe(true);
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unit Tests: Go Module Structure
|
|
3
|
+
*
|
|
4
|
+
* Tests for module structure validation, file existence, and metadata correctness.
|
|
5
|
+
* Covers GOL.4.1.1 - Configuration Loading Tests
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { describe, it, expect } from 'vitest';
|
|
9
|
+
import { existsSync, readFileSync } from 'fs';
|
|
10
|
+
import { join } from 'path';
|
|
11
|
+
|
|
12
|
+
const MODULE_ROOT = join(__dirname, '../..');
|
|
13
|
+
|
|
14
|
+
describe('Go Module Structure', () => {
|
|
15
|
+
describe('Required Files', () => {
|
|
16
|
+
it('should have module.json', () => {
|
|
17
|
+
const modulePath = join(MODULE_ROOT, 'module.json');
|
|
18
|
+
expect(existsSync(modulePath)).toBe(true);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('should have README.md', () => {
|
|
22
|
+
const readmePath = join(MODULE_ROOT, 'README.md');
|
|
23
|
+
expect(existsSync(readmePath)).toBe(true);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('should have config/schema.json', () => {
|
|
27
|
+
const schemaPath = join(MODULE_ROOT, 'config/schema.json');
|
|
28
|
+
expect(existsSync(schemaPath)).toBe(true);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
describe('Module Metadata', () => {
|
|
33
|
+
it('should have valid module.json structure', () => {
|
|
34
|
+
const modulePath = join(MODULE_ROOT, 'module.json');
|
|
35
|
+
const content = readFileSync(modulePath, 'utf-8');
|
|
36
|
+
const module = JSON.parse(content);
|
|
37
|
+
|
|
38
|
+
expect(module.name).toBe('go-coding-standards');
|
|
39
|
+
expect(module.version).toBe('1.0.0');
|
|
40
|
+
expect(module.description).toBeTruthy();
|
|
41
|
+
expect(module.type).toBe('coding-standards');
|
|
42
|
+
expect(module.language).toBe('go');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('should have all required categories', () => {
|
|
46
|
+
const modulePath = join(MODULE_ROOT, 'module.json');
|
|
47
|
+
const content = readFileSync(modulePath, 'utf-8');
|
|
48
|
+
const module = JSON.parse(content);
|
|
49
|
+
|
|
50
|
+
const expectedCategories = [
|
|
51
|
+
'web',
|
|
52
|
+
'microservices',
|
|
53
|
+
'cli',
|
|
54
|
+
'cloud',
|
|
55
|
+
'distributed',
|
|
56
|
+
'devops',
|
|
57
|
+
'api'
|
|
58
|
+
];
|
|
59
|
+
|
|
60
|
+
expect(module.categories).toBeDefined();
|
|
61
|
+
expectedCategories.forEach(cat => {
|
|
62
|
+
expect(module.categories).toContain(cat);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('should have configuration schema reference', () => {
|
|
67
|
+
const modulePath = join(MODULE_ROOT, 'module.json');
|
|
68
|
+
const content = readFileSync(modulePath, 'utf-8');
|
|
69
|
+
const module = JSON.parse(content);
|
|
70
|
+
|
|
71
|
+
expect(module.configSchema).toBe('./config/schema.json');
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
describe('Directory Structure', () => {
|
|
76
|
+
it('should have rules directory', () => {
|
|
77
|
+
const rulesPath = join(MODULE_ROOT, 'rules');
|
|
78
|
+
expect(existsSync(rulesPath)).toBe(true);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('should have examples directory', () => {
|
|
82
|
+
const examplesPath = join(MODULE_ROOT, 'examples');
|
|
83
|
+
expect(existsSync(examplesPath)).toBe(true);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('should have templates directory', () => {
|
|
87
|
+
const templatesPath = join(MODULE_ROOT, 'templates');
|
|
88
|
+
expect(existsSync(templatesPath)).toBe(true);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('should have config directory', () => {
|
|
92
|
+
const configPath = join(MODULE_ROOT, 'config');
|
|
93
|
+
expect(existsSync(configPath)).toBe(true);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('should have universal rules directory', () => {
|
|
97
|
+
const universalPath = join(MODULE_ROOT, 'rules/universal');
|
|
98
|
+
expect(existsSync(universalPath)).toBe(true);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
describe('Universal Rules', () => {
|
|
103
|
+
const universalRules = [
|
|
104
|
+
'naming-conventions.md',
|
|
105
|
+
'error-handling.md',
|
|
106
|
+
'concurrency.md',
|
|
107
|
+
'testing.md',
|
|
108
|
+
'code-organization.md',
|
|
109
|
+
'documentation.md',
|
|
110
|
+
'performance.md'
|
|
111
|
+
];
|
|
112
|
+
|
|
113
|
+
universalRules.forEach(rule => {
|
|
114
|
+
it(`should have ${rule}`, () => {
|
|
115
|
+
const rulePath = join(MODULE_ROOT, 'rules/universal', rule);
|
|
116
|
+
expect(existsSync(rulePath)).toBe(true);
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
describe('Configuration Schema', () => {
|
|
122
|
+
it('should have valid JSON schema', () => {
|
|
123
|
+
const schemaPath = join(MODULE_ROOT, 'config/schema.json');
|
|
124
|
+
const content = readFileSync(schemaPath, 'utf-8');
|
|
125
|
+
const schema = JSON.parse(content);
|
|
126
|
+
|
|
127
|
+
expect(schema.$schema).toBeTruthy();
|
|
128
|
+
expect(schema.type).toBe('object');
|
|
129
|
+
expect(schema.properties).toBeDefined();
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('should define categories property', () => {
|
|
133
|
+
const schemaPath = join(MODULE_ROOT, 'config/schema.json');
|
|
134
|
+
const content = readFileSync(schemaPath, 'utf-8');
|
|
135
|
+
const schema = JSON.parse(content);
|
|
136
|
+
|
|
137
|
+
expect(schema.properties.categories).toBeDefined();
|
|
138
|
+
expect(schema.properties.categories.type).toBe('array');
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
describe('README Content', () => {
|
|
143
|
+
it('should have comprehensive README', () => {
|
|
144
|
+
const readmePath = join(MODULE_ROOT, 'README.md');
|
|
145
|
+
const content = readFileSync(readmePath, 'utf-8');
|
|
146
|
+
|
|
147
|
+
expect(content.length).toBeGreaterThan(500);
|
|
148
|
+
expect(content).toContain('# Go Coding Standards');
|
|
149
|
+
expect(content).toContain('## Overview');
|
|
150
|
+
expect(content).toContain('## Categories');
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Validate Character Count
|
|
2
|
+
$MODULE_ROOT = Split-Path -Parent $PSScriptRoot
|
|
3
|
+
$totalChars = 0
|
|
4
|
+
Get-ChildItem -Path $MODULE_ROOT -Recurse -Include *.md,*.go,*.json -File | ForEach-Object {
|
|
5
|
+
$content = Get-Content $_.FullName -Raw -ErrorAction SilentlyContinue
|
|
6
|
+
if ($content) { $totalChars += $content.Length }
|
|
7
|
+
}
|
|
8
|
+
Write-Host "Total Characters: $totalChars"
|
|
9
|
+
if ($totalChars -ge 20000 -and $totalChars -le 30000) {
|
|
10
|
+
Write-Host "PASS: Within target range (20,000-30,000)" -ForegroundColor Green
|
|
11
|
+
} else {
|
|
12
|
+
Write-Host "WARNING: Outside target range" -ForegroundColor Yellow
|
|
13
|
+
}
|