@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.
Files changed (307) hide show
  1. package/augment-extensions/coding-standards/c/CHANGELOG.md +55 -0
  2. package/augment-extensions/coding-standards/c/LICENSE +22 -0
  3. package/augment-extensions/coding-standards/c/README.md +167 -0
  4. package/augment-extensions/coding-standards/c/config/defaults.json +26 -0
  5. package/augment-extensions/coding-standards/c/config/examples/embedded.yaml +25 -0
  6. package/augment-extensions/coding-standards/c/config/examples/systems.json +31 -0
  7. package/augment-extensions/coding-standards/c/config/schema.json +244 -0
  8. package/augment-extensions/coding-standards/c/docs/API.md +613 -0
  9. package/augment-extensions/coding-standards/c/docs/CONFIGURATION.md +259 -0
  10. package/augment-extensions/coding-standards/c/docs/USER_GUIDE.md +567 -0
  11. package/augment-extensions/coding-standards/c/examples/drivers/Makefile +33 -0
  12. package/augment-extensions/coding-standards/c/examples/drivers/README.md +192 -0
  13. package/augment-extensions/coding-standards/c/examples/drivers/dma-example.c +224 -0
  14. package/augment-extensions/coding-standards/c/examples/drivers/example.dts +64 -0
  15. package/augment-extensions/coding-standards/c/examples/drivers/platform-driver.c +174 -0
  16. package/augment-extensions/coding-standards/c/examples/embedded/README.md +167 -0
  17. package/augment-extensions/coding-standards/c/examples/embedded/gpio-control.c +172 -0
  18. package/augment-extensions/coding-standards/c/examples/embedded/timer-isr.c +198 -0
  19. package/augment-extensions/coding-standards/c/examples/embedded/uart-communication.c +212 -0
  20. package/augment-extensions/coding-standards/c/examples/kernel/Makefile +82 -0
  21. package/augment-extensions/coding-standards/c/examples/kernel/README.md +168 -0
  22. package/augment-extensions/coding-standards/c/examples/kernel/char-device.c +198 -0
  23. package/augment-extensions/coding-standards/c/examples/kernel/proc-file.c +131 -0
  24. package/augment-extensions/coding-standards/c/examples/kernel/simple-module.c +111 -0
  25. package/augment-extensions/coding-standards/c/examples/legacy/Makefile +62 -0
  26. package/augment-extensions/coding-standards/c/examples/legacy/README.md +255 -0
  27. package/augment-extensions/coding-standards/c/examples/legacy/c89-to-c11-migration.c +268 -0
  28. package/augment-extensions/coding-standards/c/examples/legacy/compatibility-layer.c +239 -0
  29. package/augment-extensions/coding-standards/c/examples/networking/Makefile +35 -0
  30. package/augment-extensions/coding-standards/c/examples/networking/README.md +207 -0
  31. package/augment-extensions/coding-standards/c/examples/networking/protocol-parser.c +270 -0
  32. package/augment-extensions/coding-standards/c/examples/networking/tcp-server.c +197 -0
  33. package/augment-extensions/coding-standards/c/examples/networking/udp-multicast.c +220 -0
  34. package/augment-extensions/coding-standards/c/examples/realtime/Makefile +53 -0
  35. package/augment-extensions/coding-standards/c/examples/realtime/README.md +199 -0
  36. package/augment-extensions/coding-standards/c/examples/realtime/deadline-monitoring.c +260 -0
  37. package/augment-extensions/coding-standards/c/examples/realtime/priority-scheduling.c +258 -0
  38. package/augment-extensions/coding-standards/c/examples/systems/Makefile +34 -0
  39. package/augment-extensions/coding-standards/c/examples/systems/README.md +123 -0
  40. package/augment-extensions/coding-standards/c/examples/systems/ipc-pipes.c +181 -0
  41. package/augment-extensions/coding-standards/c/examples/systems/process-management.c +153 -0
  42. package/augment-extensions/coding-standards/c/examples/systems/signal-handling.c +162 -0
  43. package/augment-extensions/coding-standards/c/module.json +149 -0
  44. package/augment-extensions/coding-standards/c/rules/categories/drivers.md +635 -0
  45. package/augment-extensions/coding-standards/c/rules/categories/embedded.md +510 -0
  46. package/augment-extensions/coding-standards/c/rules/categories/kernel.md +653 -0
  47. package/augment-extensions/coding-standards/c/rules/categories/legacy.md +526 -0
  48. package/augment-extensions/coding-standards/c/rules/categories/networking.md +735 -0
  49. package/augment-extensions/coding-standards/c/rules/categories/realtime.md +631 -0
  50. package/augment-extensions/coding-standards/c/rules/categories/systems.md +586 -0
  51. package/augment-extensions/coding-standards/c/rules/universal/const-correctness.md +275 -0
  52. package/augment-extensions/coding-standards/c/rules/universal/documentation.md +251 -0
  53. package/augment-extensions/coding-standards/c/rules/universal/error-handling.md +250 -0
  54. package/augment-extensions/coding-standards/c/rules/universal/header-guards.md +254 -0
  55. package/augment-extensions/coding-standards/c/rules/universal/memory-safety.md +233 -0
  56. package/augment-extensions/coding-standards/c/rules/universal/naming.md +146 -0
  57. package/augment-extensions/coding-standards/c/src/conflict-detector.ts +461 -0
  58. package/augment-extensions/coding-standards/c/src/prompt-generator.ts +307 -0
  59. package/augment-extensions/coding-standards/c/src/rule-evaluator.ts +307 -0
  60. package/augment-extensions/coding-standards/c/src/rule-override.ts +427 -0
  61. package/augment-extensions/coding-standards/c/src/template-engine.ts +217 -0
  62. package/augment-extensions/coding-standards/c/templates/prompts/drivers.txt +191 -0
  63. package/augment-extensions/coding-standards/c/templates/prompts/embedded.txt +164 -0
  64. package/augment-extensions/coding-standards/c/templates/prompts/kernel.txt +175 -0
  65. package/augment-extensions/coding-standards/c/templates/prompts/legacy.txt +280 -0
  66. package/augment-extensions/coding-standards/c/templates/prompts/networking.txt +259 -0
  67. package/augment-extensions/coding-standards/c/templates/prompts/realtime.txt +219 -0
  68. package/augment-extensions/coding-standards/c/templates/prompts/systems.txt +147 -0
  69. package/augment-extensions/coding-standards/c/tests/integration/category-specific.test.ts +356 -0
  70. package/augment-extensions/coding-standards/c/tests/integration/end-to-end-workflow.test.ts +377 -0
  71. package/augment-extensions/coding-standards/c/tests/performance/benchmarks.test.ts +407 -0
  72. package/augment-extensions/coding-standards/c/tests/unit/config-manager.test.ts +345 -0
  73. package/augment-extensions/coding-standards/c/tests/unit/conflict-detector.test.ts +294 -0
  74. package/augment-extensions/coding-standards/c/tests/unit/prompt-generator.test.ts +174 -0
  75. package/augment-extensions/coding-standards/c/tests/unit/registry.test.ts +313 -0
  76. package/augment-extensions/coding-standards/c/tests/unit/rule-evaluator.test.ts +318 -0
  77. package/augment-extensions/coding-standards/c/tests/unit/rule-override.test.ts +326 -0
  78. package/augment-extensions/coding-standards/c/tests/unit/template-engine.test.ts +314 -0
  79. package/augment-extensions/coding-standards/go/CHARACTER-COUNT-REPORT.md +135 -0
  80. package/augment-extensions/coding-standards/go/PHASE1-COMPLETION.md +146 -0
  81. package/augment-extensions/coding-standards/go/PHASE4-COMPLETION.md +184 -0
  82. package/augment-extensions/coding-standards/go/README.md +200 -0
  83. package/augment-extensions/coding-standards/go/VALIDATION-CHECKLIST.md +154 -0
  84. package/augment-extensions/coding-standards/go/config/examples/example-cli.json +15 -0
  85. package/augment-extensions/coding-standards/go/config/examples/example-microservices.json +21 -0
  86. package/augment-extensions/coding-standards/go/config/examples/example-multi-category.yaml +24 -0
  87. package/augment-extensions/coding-standards/go/config/examples/example-web.json +15 -0
  88. package/augment-extensions/coding-standards/go/config/schema.json +110 -0
  89. package/augment-extensions/coding-standards/go/docs/CATEGORIES.md +221 -0
  90. package/augment-extensions/coding-standards/go/docs/CONFIGURATION.md +198 -0
  91. package/augment-extensions/coding-standards/go/docs/TROUBLESHOOTING.md +285 -0
  92. package/augment-extensions/coding-standards/go/examples/cli/cobra-app.go +287 -0
  93. package/augment-extensions/coding-standards/go/examples/cloud-native-app.go +217 -0
  94. package/augment-extensions/coding-standards/go/examples/devops-tool.go +250 -0
  95. package/augment-extensions/coding-standards/go/examples/distributed-system.go +247 -0
  96. package/augment-extensions/coding-standards/go/examples/microservices/grpc-service.go +253 -0
  97. package/augment-extensions/coding-standards/go/examples/rest-api.go +270 -0
  98. package/augment-extensions/coding-standards/go/examples/web/http-server.go +224 -0
  99. package/augment-extensions/coding-standards/go/module.json +139 -0
  100. package/augment-extensions/coding-standards/go/rules/categories/api-development/api-versioning.md +149 -0
  101. package/augment-extensions/coding-standards/go/rules/categories/api-development/rate-limiting.md +209 -0
  102. package/augment-extensions/coding-standards/go/rules/categories/api-development/rest-api-design.md +183 -0
  103. package/augment-extensions/coding-standards/go/rules/categories/cloud-native/cloud-config.md +193 -0
  104. package/augment-extensions/coding-standards/go/rules/categories/cloud-native/health-checks.md +231 -0
  105. package/augment-extensions/coding-standards/go/rules/categories/cloud-native/kubernetes.md +180 -0
  106. package/augment-extensions/coding-standards/go/rules/categories/devops-tooling/automation.md +179 -0
  107. package/augment-extensions/coding-standards/go/rules/categories/devops-tooling/ci-cd-integration.md +147 -0
  108. package/augment-extensions/coding-standards/go/rules/categories/devops-tooling/infrastructure-as-code.md +231 -0
  109. package/augment-extensions/coding-standards/go/rules/categories/distributed-systems/caching.md +150 -0
  110. package/augment-extensions/coding-standards/go/rules/categories/distributed-systems/consensus.md +187 -0
  111. package/augment-extensions/coding-standards/go/rules/categories/distributed-systems/event-sourcing.md +246 -0
  112. package/augment-extensions/coding-standards/go/rules/cli/command-parsing.md +264 -0
  113. package/augment-extensions/coding-standards/go/rules/cli/configuration.md +268 -0
  114. package/augment-extensions/coding-standards/go/rules/cli/cross-platform.md +324 -0
  115. package/augment-extensions/coding-standards/go/rules/microservices/distributed-tracing.md +253 -0
  116. package/augment-extensions/coding-standards/go/rules/microservices/grpc.md +257 -0
  117. package/augment-extensions/coding-standards/go/rules/microservices/metrics.md +278 -0
  118. package/augment-extensions/coding-standards/go/rules/microservices/service-discovery.md +249 -0
  119. package/augment-extensions/coding-standards/go/rules/universal/code-organization.md +221 -0
  120. package/augment-extensions/coding-standards/go/rules/universal/documentation.md +269 -0
  121. package/augment-extensions/coding-standards/go/rules/universal/performance.md +323 -0
  122. package/augment-extensions/coding-standards/go/rules/universal/testing.md +162 -0
  123. package/augment-extensions/coding-standards/go/rules/web/graceful-shutdown.md +249 -0
  124. package/augment-extensions/coding-standards/go/rules/web/http-handlers.md +164 -0
  125. package/augment-extensions/coding-standards/go/rules/web/middleware.md +234 -0
  126. package/augment-extensions/coding-standards/go/rules/web/routing.md +251 -0
  127. package/augment-extensions/coding-standards/go/templates/prompts/api.md +160 -0
  128. package/augment-extensions/coding-standards/go/templates/prompts/cli.md +225 -0
  129. package/augment-extensions/coding-standards/go/templates/prompts/cloud-native.md +121 -0
  130. package/augment-extensions/coding-standards/go/templates/prompts/devops.md +146 -0
  131. package/augment-extensions/coding-standards/go/templates/prompts/distributed.md +133 -0
  132. package/augment-extensions/coding-standards/go/templates/prompts/microservices.md +225 -0
  133. package/augment-extensions/coding-standards/go/templates/prompts/web.md +181 -0
  134. package/augment-extensions/coding-standards/go/tests/integration/module-integration.test.ts +164 -0
  135. package/augment-extensions/coding-standards/go/tests/unit/category-selection.test.ts +147 -0
  136. package/augment-extensions/coding-standards/go/tests/unit/module-structure.test.ts +154 -0
  137. package/augment-extensions/coding-standards/go/tests/validate-character-count.ps1 +13 -0
  138. package/augment-extensions/coding-standards/go/tests/validate-examples.ps1 +148 -0
  139. package/augment-extensions/coding-standards/go/tests/validate-examples.sh +135 -0
  140. package/cli/dist/analysis/ast-parser.d.ts +47 -0
  141. package/cli/dist/analysis/ast-parser.d.ts.map +1 -0
  142. package/cli/dist/analysis/ast-parser.js +161 -0
  143. package/cli/dist/analysis/ast-parser.js.map +1 -0
  144. package/cli/dist/analysis/complexity-analyzer.d.ts +27 -0
  145. package/cli/dist/analysis/complexity-analyzer.d.ts.map +1 -0
  146. package/cli/dist/analysis/complexity-analyzer.js +189 -0
  147. package/cli/dist/analysis/complexity-analyzer.js.map +1 -0
  148. package/cli/dist/analysis/dependency-analyzer.d.ts +23 -0
  149. package/cli/dist/analysis/dependency-analyzer.d.ts.map +1 -0
  150. package/cli/dist/analysis/dependency-analyzer.js +237 -0
  151. package/cli/dist/analysis/dependency-analyzer.js.map +1 -0
  152. package/cli/dist/analysis/index.d.ts +9 -0
  153. package/cli/dist/analysis/index.d.ts.map +1 -0
  154. package/cli/dist/analysis/index.js +25 -0
  155. package/cli/dist/analysis/index.js.map +1 -0
  156. package/cli/dist/analysis/security-scanner.d.ts +11 -0
  157. package/cli/dist/analysis/security-scanner.d.ts.map +1 -0
  158. package/cli/dist/analysis/security-scanner.js +294 -0
  159. package/cli/dist/analysis/security-scanner.js.map +1 -0
  160. package/cli/dist/analysis/types.d.ts +151 -0
  161. package/cli/dist/analysis/types.d.ts.map +1 -0
  162. package/cli/dist/analysis/types.js +6 -0
  163. package/cli/dist/analysis/types.js.map +1 -0
  164. package/cli/dist/cli.js +24 -0
  165. package/cli/dist/cli.js.map +1 -1
  166. package/cli/dist/commands/code-analysis.d.ts +11 -0
  167. package/cli/dist/commands/code-analysis.d.ts.map +1 -0
  168. package/cli/dist/commands/code-analysis.js +412 -0
  169. package/cli/dist/commands/code-analysis.js.map +1 -0
  170. package/modules.md +99 -3
  171. package/package.json +14 -2
  172. package/cli/dist/commands/agent.d.ts +0 -37
  173. package/cli/dist/commands/agent.d.ts.map +0 -1
  174. package/cli/dist/commands/agent.js +0 -222
  175. package/cli/dist/commands/agent.js.map +0 -1
  176. package/cli/dist/commands/beads.d.ts +0 -64
  177. package/cli/dist/commands/beads.d.ts.map +0 -1
  178. package/cli/dist/commands/beads.js +0 -377
  179. package/cli/dist/commands/beads.js.map +0 -1
  180. package/cli/dist/commands/change.d.ts +0 -54
  181. package/cli/dist/commands/change.d.ts.map +0 -1
  182. package/cli/dist/commands/change.js +0 -243
  183. package/cli/dist/commands/change.js.map +0 -1
  184. package/cli/dist/commands/clean.d.ts +0 -15
  185. package/cli/dist/commands/clean.d.ts.map +0 -1
  186. package/cli/dist/commands/clean.js +0 -63
  187. package/cli/dist/commands/clean.js.map +0 -1
  188. package/cli/dist/commands/clone.d.ts +0 -15
  189. package/cli/dist/commands/clone.d.ts.map +0 -1
  190. package/cli/dist/commands/clone.js +0 -49
  191. package/cli/dist/commands/clone.js.map +0 -1
  192. package/cli/dist/commands/config.d.ts +0 -33
  193. package/cli/dist/commands/config.d.ts.map +0 -1
  194. package/cli/dist/commands/config.js +0 -166
  195. package/cli/dist/commands/config.js.map +0 -1
  196. package/cli/dist/commands/context.d.ts +0 -38
  197. package/cli/dist/commands/context.d.ts.map +0 -1
  198. package/cli/dist/commands/context.js +0 -205
  199. package/cli/dist/commands/context.js.map +0 -1
  200. package/cli/dist/commands/create.d.ts +0 -18
  201. package/cli/dist/commands/create.d.ts.map +0 -1
  202. package/cli/dist/commands/create.js +0 -178
  203. package/cli/dist/commands/create.js.map +0 -1
  204. package/cli/dist/commands/diff.d.ts +0 -19
  205. package/cli/dist/commands/diff.d.ts.map +0 -1
  206. package/cli/dist/commands/diff.js +0 -104
  207. package/cli/dist/commands/diff.js.map +0 -1
  208. package/cli/dist/commands/doctor.d.ts +0 -14
  209. package/cli/dist/commands/doctor.d.ts.map +0 -1
  210. package/cli/dist/commands/doctor.js +0 -62
  211. package/cli/dist/commands/doctor.js.map +0 -1
  212. package/cli/dist/commands/export.d.ts +0 -28
  213. package/cli/dist/commands/export.d.ts.map +0 -1
  214. package/cli/dist/commands/export.js +0 -135
  215. package/cli/dist/commands/export.js.map +0 -1
  216. package/cli/dist/commands/import.d.ts +0 -23
  217. package/cli/dist/commands/import.d.ts.map +0 -1
  218. package/cli/dist/commands/import.js +0 -118
  219. package/cli/dist/commands/import.js.map +0 -1
  220. package/cli/dist/commands/prompt.d.ts +0 -45
  221. package/cli/dist/commands/prompt.d.ts.map +0 -1
  222. package/cli/dist/commands/prompt.js +0 -223
  223. package/cli/dist/commands/prompt.js.map +0 -1
  224. package/cli/dist/commands/spec.d.ts +0 -57
  225. package/cli/dist/commands/spec.d.ts.map +0 -1
  226. package/cli/dist/commands/spec.js +0 -279
  227. package/cli/dist/commands/spec.js.map +0 -1
  228. package/cli/dist/commands/stats.d.ts +0 -18
  229. package/cli/dist/commands/stats.d.ts.map +0 -1
  230. package/cli/dist/commands/stats.js +0 -85
  231. package/cli/dist/commands/stats.js.map +0 -1
  232. package/cli/dist/commands/task.d.ts +0 -65
  233. package/cli/dist/commands/task.d.ts.map +0 -1
  234. package/cli/dist/commands/task.js +0 -282
  235. package/cli/dist/commands/task.js.map +0 -1
  236. package/cli/dist/commands/template.d.ts +0 -17
  237. package/cli/dist/commands/template.d.ts.map +0 -1
  238. package/cli/dist/commands/template.js +0 -55
  239. package/cli/dist/commands/template.js.map +0 -1
  240. package/cli/dist/utils/agent-config.d.ts +0 -129
  241. package/cli/dist/utils/agent-config.d.ts.map +0 -1
  242. package/cli/dist/utils/agent-config.js +0 -297
  243. package/cli/dist/utils/agent-config.js.map +0 -1
  244. package/cli/dist/utils/beads-graph.d.ts +0 -17
  245. package/cli/dist/utils/beads-graph.d.ts.map +0 -1
  246. package/cli/dist/utils/beads-graph.js +0 -150
  247. package/cli/dist/utils/beads-graph.js.map +0 -1
  248. package/cli/dist/utils/beads-integration.d.ts +0 -112
  249. package/cli/dist/utils/beads-integration.d.ts.map +0 -1
  250. package/cli/dist/utils/beads-integration.js +0 -312
  251. package/cli/dist/utils/beads-integration.js.map +0 -1
  252. package/cli/dist/utils/beads-reporter.d.ts +0 -17
  253. package/cli/dist/utils/beads-reporter.d.ts.map +0 -1
  254. package/cli/dist/utils/beads-reporter.js +0 -160
  255. package/cli/dist/utils/beads-reporter.js.map +0 -1
  256. package/cli/dist/utils/cache-manager.d.ts +0 -55
  257. package/cli/dist/utils/cache-manager.d.ts.map +0 -1
  258. package/cli/dist/utils/cache-manager.js +0 -150
  259. package/cli/dist/utils/cache-manager.js.map +0 -1
  260. package/cli/dist/utils/change-manager.d.ts +0 -70
  261. package/cli/dist/utils/change-manager.d.ts.map +0 -1
  262. package/cli/dist/utils/change-manager.js +0 -412
  263. package/cli/dist/utils/change-manager.js.map +0 -1
  264. package/cli/dist/utils/config-manager-enhanced.d.ts +0 -66
  265. package/cli/dist/utils/config-manager-enhanced.d.ts.map +0 -1
  266. package/cli/dist/utils/config-manager-enhanced.js +0 -77
  267. package/cli/dist/utils/config-manager-enhanced.js.map +0 -1
  268. package/cli/dist/utils/context-manager.d.ts +0 -96
  269. package/cli/dist/utils/context-manager.d.ts.map +0 -1
  270. package/cli/dist/utils/context-manager.js +0 -258
  271. package/cli/dist/utils/context-manager.js.map +0 -1
  272. package/cli/dist/utils/diff-engine.d.ts +0 -78
  273. package/cli/dist/utils/diff-engine.d.ts.map +0 -1
  274. package/cli/dist/utils/diff-engine.js +0 -233
  275. package/cli/dist/utils/diff-engine.js.map +0 -1
  276. package/cli/dist/utils/export-system.d.ts +0 -101
  277. package/cli/dist/utils/export-system.d.ts.map +0 -1
  278. package/cli/dist/utils/export-system.js +0 -289
  279. package/cli/dist/utils/export-system.js.map +0 -1
  280. package/cli/dist/utils/health-checker.d.ts +0 -66
  281. package/cli/dist/utils/health-checker.d.ts.map +0 -1
  282. package/cli/dist/utils/health-checker.js +0 -285
  283. package/cli/dist/utils/health-checker.js.map +0 -1
  284. package/cli/dist/utils/import-system.d.ts +0 -74
  285. package/cli/dist/utils/import-system.d.ts.map +0 -1
  286. package/cli/dist/utils/import-system.js +0 -317
  287. package/cli/dist/utils/import-system.js.map +0 -1
  288. package/cli/dist/utils/module-cloner.d.ts +0 -40
  289. package/cli/dist/utils/module-cloner.d.ts.map +0 -1
  290. package/cli/dist/utils/module-cloner.js +0 -136
  291. package/cli/dist/utils/module-cloner.js.map +0 -1
  292. package/cli/dist/utils/prompt-manager.d.ts +0 -90
  293. package/cli/dist/utils/prompt-manager.d.ts.map +0 -1
  294. package/cli/dist/utils/prompt-manager.js +0 -302
  295. package/cli/dist/utils/prompt-manager.js.map +0 -1
  296. package/cli/dist/utils/spec-manager.d.ts +0 -65
  297. package/cli/dist/utils/spec-manager.d.ts.map +0 -1
  298. package/cli/dist/utils/spec-manager.js +0 -329
  299. package/cli/dist/utils/spec-manager.js.map +0 -1
  300. package/cli/dist/utils/stats-collector.d.ts +0 -74
  301. package/cli/dist/utils/stats-collector.d.ts.map +0 -1
  302. package/cli/dist/utils/stats-collector.js +0 -164
  303. package/cli/dist/utils/stats-collector.js.map +0 -1
  304. package/cli/dist/utils/template-engine.d.ts +0 -47
  305. package/cli/dist/utils/template-engine.d.ts.map +0 -1
  306. package/cli/dist/utils/template-engine.js +0 -204
  307. package/cli/dist/utils/template-engine.js.map +0 -1
@@ -0,0 +1,174 @@
1
+ /**
2
+ * Unit Tests for PromptGenerator
3
+ * Tests AI prompt generation, category detection, and template rendering
4
+ */
5
+
6
+ import * as fs from 'fs/promises';
7
+ import * as path from 'path';
8
+ import { PromptGenerator } from '../../src/prompt-generator';
9
+ import { RuleRegistry } from '../../src/registry';
10
+ import { ConfigurationManager } from '../../src/config-manager';
11
+
12
+ describe('PromptGenerator', () => {
13
+ let tempDir: string;
14
+ let rulesPath: string;
15
+ let configPath: string;
16
+ let registry: RuleRegistry;
17
+ let configManager: ConfigurationManager;
18
+ let generator: PromptGenerator;
19
+
20
+ beforeEach(async () => {
21
+ // Create temporary directories
22
+ tempDir = path.join(__dirname, '../fixtures/temp-prompt');
23
+ rulesPath = path.join(tempDir, 'rules');
24
+ configPath = tempDir;
25
+
26
+ await fs.mkdir(path.join(rulesPath, 'universal'), { recursive: true });
27
+ await fs.mkdir(path.join(configPath, '.augment'), { recursive: true });
28
+
29
+ // Create sample rules
30
+ await createSampleRules();
31
+
32
+ // Create sample template
33
+ await createSampleTemplate();
34
+
35
+ // Initialize components
36
+ registry = new RuleRegistry(rulesPath);
37
+ await registry.loadRules();
38
+
39
+ configManager = new ConfigurationManager(configPath);
40
+ await configManager.load();
41
+
42
+ generator = new PromptGenerator(registry, configManager);
43
+ });
44
+
45
+ afterEach(async () => {
46
+ try {
47
+ await fs.rm(tempDir, { recursive: true, force: true });
48
+ } catch (error) {
49
+ // Ignore cleanup errors
50
+ }
51
+ });
52
+
53
+ async function createSampleRules() {
54
+ const namingRule = `# Rule: Naming Conventions
55
+
56
+ ## Metadata
57
+ - **ID**: universal-naming
58
+ - **Category**: universal
59
+ - **Severity**: ERROR
60
+
61
+ ## Description
62
+ Use snake_case for functions and variables.
63
+
64
+ ## Examples
65
+
66
+ ### Good Example
67
+ \`\`\`c
68
+ int my_function() { return 0; }
69
+ \`\`\`
70
+ `;
71
+
72
+ await fs.writeFile(path.join(rulesPath, 'universal/naming.md'), namingRule);
73
+ }
74
+
75
+ async function createSampleTemplate() {
76
+ const template = `# C Coding Standards - {category}
77
+
78
+ ## Active Rules
79
+ {rules}
80
+
81
+ ## Guidelines
82
+ Follow these standards for {category} programming.
83
+ `;
84
+
85
+ await fs.writeFile(
86
+ path.join(configPath, '.augment/prompt-template.md'),
87
+ template
88
+ );
89
+ }
90
+
91
+ describe('generatePrompt()', () => {
92
+ it('should generate prompt with file context', async () => {
93
+ const prompt = await generator.generatePrompt({
94
+ filePath: '/project/src/network/tcp_server.c',
95
+ codeContext: 'int handle_connection() { return 0; }'
96
+ });
97
+
98
+ expect(prompt).toBeDefined();
99
+ expect(prompt.length).toBeGreaterThan(0);
100
+ expect(prompt).toContain('C Coding Standards');
101
+ });
102
+
103
+ it('should include relevant rules in prompt', async () => {
104
+ const prompt = await generator.generatePrompt({
105
+ filePath: '/project/src/main.c',
106
+ codeContext: 'int main() { return 0; }'
107
+ });
108
+
109
+ expect(prompt).toContain('universal-naming');
110
+ });
111
+
112
+ it('should filter rules by category', async () => {
113
+ const prompt = await generator.generatePrompt({
114
+ filePath: '/project/embedded/sensor.c',
115
+ codeContext: 'volatile uint32_t* reg;',
116
+ category: 'embedded'
117
+ });
118
+
119
+ expect(prompt).toBeDefined();
120
+ });
121
+
122
+ it('should use custom template if provided', async () => {
123
+ const customTemplate = '# Custom Template\n{rules}';
124
+
125
+ const prompt = await generator.generatePrompt({
126
+ filePath: '/project/src/main.c',
127
+ codeContext: 'int main() {}',
128
+ template: customTemplate
129
+ });
130
+
131
+ expect(prompt).toContain('Custom Template');
132
+ });
133
+
134
+ it('should cache generated prompts', async () => {
135
+ const context = {
136
+ filePath: '/project/src/main.c',
137
+ codeContext: 'int main() { return 0; }'
138
+ };
139
+
140
+ const prompt1 = await generator.generatePrompt(context);
141
+ const prompt2 = await generator.generatePrompt(context);
142
+
143
+ expect(prompt1).toBe(prompt2); // Same reference due to caching
144
+ });
145
+ });
146
+
147
+ describe('detectCategory()', () => {
148
+ it('should detect embedded category from file path', () => {
149
+ const category = generator.detectCategory('/project/embedded/sensor.c');
150
+ expect(category).toContain('embedded');
151
+ });
152
+
153
+ it('should detect kernel category from file path', () => {
154
+ const category = generator.detectCategory('/project/kernel/scheduler.c');
155
+ expect(category).toContain('kernel');
156
+ });
157
+
158
+ it('should detect networking category from file path', () => {
159
+ const category = generator.detectCategory('/project/network/tcp.c');
160
+ expect(category).toContain('networking');
161
+ });
162
+
163
+ it('should detect drivers category from file path', () => {
164
+ const category = generator.detectCategory('/project/drivers/usb.c');
165
+ expect(category).toContain('drivers');
166
+ });
167
+
168
+ it('should detect realtime category from file path', () => {
169
+ const category = generator.detectCategory('/project/realtime/scheduler.c');
170
+ expect(category).toContain('realtime');
171
+ });
172
+ });
173
+ });
174
+
@@ -0,0 +1,313 @@
1
+ /**
2
+ * Unit Tests for RuleRegistry
3
+ * Tests rule loading, indexing, querying, and caching
4
+ */
5
+
6
+ import * as fs from 'fs/promises';
7
+ import * as path from 'path';
8
+ import { RuleRegistry } from '../../src/registry';
9
+ import { Rule } from '../../src/types';
10
+
11
+ describe('RuleRegistry', () => {
12
+ let tempDir: string;
13
+ let rulesPath: string;
14
+ let registry: RuleRegistry;
15
+
16
+ beforeEach(async () => {
17
+ // Create temporary directory for test rules
18
+ tempDir = path.join(__dirname, '../fixtures/temp-rules');
19
+ rulesPath = path.join(tempDir, 'rules');
20
+ await fs.mkdir(path.join(rulesPath, 'universal'), { recursive: true });
21
+ await fs.mkdir(path.join(rulesPath, 'categories'), { recursive: true });
22
+
23
+ // Create sample rule files
24
+ await createSampleRules();
25
+
26
+ registry = new RuleRegistry(rulesPath);
27
+ });
28
+
29
+ afterEach(async () => {
30
+ try {
31
+ await fs.rm(tempDir, { recursive: true, force: true });
32
+ } catch (error) {
33
+ // Ignore cleanup errors
34
+ }
35
+ });
36
+
37
+ async function createSampleRules() {
38
+ // Universal naming rule
39
+ const namingRule = `# Rule: Naming Conventions
40
+
41
+ ## Metadata
42
+ - **ID**: universal-naming
43
+ - **Category**: universal
44
+ - **Severity**: ERROR
45
+
46
+ ## Description
47
+ Use snake_case for functions and variables, UPPER_CASE for macros and constants.
48
+
49
+ ## Rationale
50
+ Consistent naming improves code readability and maintainability.
51
+
52
+ ## Examples
53
+
54
+ ### Bad Example
55
+ \`\`\`c
56
+ int myFunction() { return 0; }
57
+ \`\`\`
58
+
59
+ ### Good Example
60
+ \`\`\`c
61
+ int my_function() { return 0; }
62
+ \`\`\`
63
+ `;
64
+
65
+ await fs.writeFile(path.join(rulesPath, 'universal/naming.md'), namingRule);
66
+
67
+ // Systems programming rule
68
+ const systemsRule = `# Rule: POSIX Compliance
69
+
70
+ ## Metadata
71
+ - **ID**: systems-posix
72
+ - **Category**: systems
73
+ - **Severity**: WARNING
74
+
75
+ ## Description
76
+ Follow POSIX standards for system programming.
77
+
78
+ ## Rationale
79
+ POSIX compliance ensures portability across Unix-like systems.
80
+
81
+ ## Examples
82
+
83
+ ### Bad Example
84
+ \`\`\`c
85
+ // Non-portable code
86
+ \`\`\`
87
+
88
+ ### Good Example
89
+ \`\`\`c
90
+ // POSIX-compliant code
91
+ \`\`\`
92
+ `;
93
+
94
+ await fs.writeFile(path.join(rulesPath, 'categories/systems.md'), systemsRule);
95
+
96
+ // Embedded systems rule
97
+ const embeddedRule = `# Rule: Volatile Hardware Access
98
+
99
+ ## Metadata
100
+ - **ID**: embedded-volatile
101
+ - **Category**: embedded
102
+ - **Severity**: ERROR
103
+
104
+ ## Description
105
+ Use volatile keyword for hardware register access.
106
+
107
+ ## Rationale
108
+ Prevents compiler optimizations that could break hardware interactions.
109
+ `;
110
+
111
+ await fs.writeFile(path.join(rulesPath, 'categories/embedded.md'), embeddedRule);
112
+ }
113
+
114
+ describe('loadRules()', () => {
115
+ it('should load all rules from directories', async () => {
116
+ await registry.loadRules();
117
+
118
+ const allRules = registry.getAllRules();
119
+ expect(allRules.length).toBeGreaterThan(0);
120
+ });
121
+
122
+ it('should parse rule metadata correctly', async () => {
123
+ await registry.loadRules();
124
+
125
+ const namingRule = registry.getRule('universal-naming');
126
+ expect(namingRule).toBeDefined();
127
+ expect(namingRule?.name).toBe('Naming Conventions');
128
+ expect(namingRule?.severity).toBe('ERROR');
129
+ expect(namingRule?.category).toContain('universal');
130
+ });
131
+
132
+ it('should handle missing directories gracefully', async () => {
133
+ const emptyRegistry = new RuleRegistry('/nonexistent/path');
134
+ await expect(emptyRegistry.loadRules()).resolves.not.toThrow();
135
+ });
136
+ });
137
+
138
+ describe('getRule()', () => {
139
+ beforeEach(async () => {
140
+ await registry.loadRules();
141
+ });
142
+
143
+ it('should retrieve rule by ID', () => {
144
+ const rule = registry.getRule('universal-naming');
145
+ expect(rule).toBeDefined();
146
+ expect(rule?.id).toBe('universal-naming');
147
+ });
148
+
149
+ it('should return undefined for non-existent rule', () => {
150
+ const rule = registry.getRule('nonexistent-rule');
151
+ expect(rule).toBeUndefined();
152
+ });
153
+ });
154
+
155
+ describe('getRulesByCategory()', () => {
156
+ beforeEach(async () => {
157
+ await registry.loadRules();
158
+ });
159
+
160
+ it('should return all rules for a category', () => {
161
+ const universalRules = registry.getRulesByCategory('universal');
162
+ expect(universalRules.length).toBeGreaterThan(0);
163
+ expect(universalRules.every(r => r.category.includes('universal'))).toBe(true);
164
+ });
165
+
166
+ it('should return empty array for non-existent category', () => {
167
+ const rules = registry.getRulesByCategory('nonexistent');
168
+ expect(rules).toEqual([]);
169
+ });
170
+
171
+ it('should use cache for repeated queries', () => {
172
+ const rules1 = registry.getRulesByCategory('universal');
173
+ const rules2 = registry.getRulesByCategory('universal');
174
+ expect(rules1).toBe(rules2); // Same reference due to caching
175
+ });
176
+ });
177
+
178
+ describe('getRulesBySeverity()', () => {
179
+ beforeEach(async () => {
180
+ await registry.loadRules();
181
+ });
182
+
183
+ it('should return all ERROR severity rules', () => {
184
+ const errorRules = registry.getRulesBySeverity('ERROR');
185
+ expect(errorRules.length).toBeGreaterThan(0);
186
+ expect(errorRules.every(r => r.severity === 'ERROR')).toBe(true);
187
+ });
188
+
189
+ it('should return all WARNING severity rules', () => {
190
+ const warningRules = registry.getRulesBySeverity('WARNING');
191
+ expect(warningRules.every(r => r.severity === 'WARNING')).toBe(true);
192
+ });
193
+
194
+ it('should use cache for repeated queries', () => {
195
+ const rules1 = registry.getRulesBySeverity('ERROR');
196
+ const rules2 = registry.getRulesBySeverity('ERROR');
197
+ expect(rules1).toBe(rules2);
198
+ });
199
+ });
200
+
201
+ describe('getActiveRules()', () => {
202
+ beforeEach(async () => {
203
+ await registry.loadRules();
204
+ });
205
+
206
+ it('should return only enabled rules', () => {
207
+ const activeRules = registry.getActiveRules();
208
+ expect(activeRules.every(r => r.enabled !== false)).toBe(true);
209
+ });
210
+
211
+ it('should exclude disabled rules', () => {
212
+ registry.setRuleEnabled('universal-naming', false);
213
+ const activeRules = registry.getActiveRules();
214
+ expect(activeRules.find(r => r.id === 'universal-naming')).toBeUndefined();
215
+ });
216
+ });
217
+
218
+ describe('queryRules()', () => {
219
+ beforeEach(async () => {
220
+ await registry.loadRules();
221
+ });
222
+
223
+ it('should filter by category and severity', () => {
224
+ const results = registry.queryRules({
225
+ category: 'universal',
226
+ severity: 'ERROR'
227
+ });
228
+
229
+ expect(results.every(r => r.category.includes('universal'))).toBe(true);
230
+ expect(results.every(r => r.severity === 'ERROR')).toBe(true);
231
+ });
232
+
233
+ it('should filter by enabled status', () => {
234
+ registry.setRuleEnabled('universal-naming', false);
235
+
236
+ const enabledRules = registry.queryRules({ enabled: true });
237
+ expect(enabledRules.find(r => r.id === 'universal-naming')).toBeUndefined();
238
+
239
+ const disabledRules = registry.queryRules({ enabled: false });
240
+ expect(disabledRules.find(r => r.id === 'universal-naming')).toBeDefined();
241
+ });
242
+
243
+ it('should search by text in name or description', () => {
244
+ const results = registry.queryRules({ search: 'naming' });
245
+ expect(results.length).toBeGreaterThan(0);
246
+ expect(results.some(r =>
247
+ r.name.toLowerCase().includes('naming') ||
248
+ r.description.toLowerCase().includes('naming')
249
+ )).toBe(true);
250
+ });
251
+ });
252
+
253
+ describe('setRuleEnabled()', () => {
254
+ beforeEach(async () => {
255
+ await registry.loadRules();
256
+ });
257
+
258
+ it('should enable a rule', () => {
259
+ registry.setRuleEnabled('universal-naming', true);
260
+ const rule = registry.getRule('universal-naming');
261
+ expect(rule?.enabled).toBe(true);
262
+ });
263
+
264
+ it('should disable a rule', () => {
265
+ registry.setRuleEnabled('universal-naming', false);
266
+ const rule = registry.getRule('universal-naming');
267
+ expect(rule?.enabled).toBe(false);
268
+ });
269
+
270
+ it('should clear cache when rule status changes', () => {
271
+ const activeRules1 = registry.getActiveRules();
272
+ registry.setRuleEnabled('universal-naming', false);
273
+ const activeRules2 = registry.getActiveRules();
274
+
275
+ expect(activeRules1).not.toBe(activeRules2); // Cache cleared
276
+ });
277
+ });
278
+
279
+ describe('clearCache()', () => {
280
+ beforeEach(async () => {
281
+ await registry.loadRules();
282
+ });
283
+
284
+ it('should clear all cached queries', () => {
285
+ const rules1 = registry.getRulesByCategory('universal');
286
+ registry.clearCache();
287
+ const rules2 = registry.getRulesByCategory('universal');
288
+
289
+ expect(rules1).not.toBe(rules2); // Different references after cache clear
290
+ });
291
+ });
292
+
293
+ describe('getAllRules()', () => {
294
+ beforeEach(async () => {
295
+ await registry.loadRules();
296
+ });
297
+
298
+ it('should return all loaded rules', () => {
299
+ const allRules = registry.getAllRules();
300
+ expect(allRules.length).toBeGreaterThan(0);
301
+ });
302
+
303
+ it('should include both universal and category-specific rules', () => {
304
+ const allRules = registry.getAllRules();
305
+ const hasUniversal = allRules.some(r => r.category.includes('universal'));
306
+ const hasCategory = allRules.some(r => !r.category.includes('universal'));
307
+
308
+ expect(hasUniversal).toBe(true);
309
+ expect(hasCategory).toBe(true);
310
+ });
311
+ });
312
+ });
313
+