@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,526 @@
1
+ # Rule: Legacy Code Maintenance
2
+
3
+ ## Metadata
4
+ - **ID**: category-legacy
5
+ - **Category**: legacy
6
+ - **Severity**: WARNING
7
+ - **Standard**: Best Practices for Legacy Code
8
+ - **Version**: 1.0.0
9
+
10
+ ## Description
11
+ Legacy code maintenance rules covering backward compatibility, safe refactoring techniques, deprecation patterns, version compatibility, and migration paths.
12
+
13
+ ## Rationale
14
+ Legacy code often cannot be rewritten from scratch. These rules ensure safe, incremental improvements while maintaining compatibility with existing systems and minimizing risk of regressions.
15
+
16
+ ## Applies To
17
+ - C Standards: c89, c99, c11, c17, c23
18
+ - Categories: legacy
19
+ - Platforms: All platforms with existing codebases
20
+
21
+ ## Rule Details
22
+
23
+ ### 1. Backward Compatibility
24
+ - Maintain existing API signatures
25
+ - Use versioned APIs for breaking changes
26
+ - Provide compatibility shims
27
+ - Document compatibility requirements
28
+ - Test with old and new code
29
+
30
+ ### 2. Safe Refactoring
31
+ - Make small, incremental changes
32
+ - Add tests before refactoring
33
+ - Preserve existing behavior
34
+ - Use compiler warnings to find issues
35
+ - Refactor with feature flags
36
+
37
+ ### 3. Deprecation Patterns
38
+ - Mark deprecated functions clearly
39
+ - Provide migration path
40
+ - Give adequate deprecation period
41
+ - Log deprecation warnings
42
+ - Document replacement APIs
43
+
44
+ ### 4. Version Compatibility
45
+ - Support multiple C standards
46
+ - Handle platform differences
47
+ - Use feature detection, not version checks
48
+ - Provide fallback implementations
49
+ - Test on target platforms
50
+
51
+ ### 5. Migration Strategies
52
+ - Create parallel implementations
53
+ - Use adapter patterns
54
+ - Implement gradual migration
55
+ - Maintain dual support during transition
56
+ - Provide migration tools/scripts
57
+
58
+ ## Examples
59
+
60
+ ### ✅ Example 1: Deprecation with Compiler Warnings
61
+
62
+ ```c
63
+ #include <stdio.h>
64
+
65
+ // Old function - deprecated
66
+ #ifdef __GNUC__
67
+ __attribute__((deprecated("Use new_process_data() instead")))
68
+ #elif defined(_MSC_VER)
69
+ __declspec(deprecated("Use new_process_data() instead"))
70
+ #endif
71
+ int process_data(const char *data) {
72
+ // Old implementation
73
+ fprintf(stderr, "Warning: process_data() is deprecated, use new_process_data()\n");
74
+ return new_process_data(data, strlen(data));
75
+ }
76
+
77
+ // New function with improved API
78
+ int new_process_data(const char *data, size_t len) {
79
+ // New, safer implementation
80
+ if (data == NULL || len == 0) {
81
+ return -1;
82
+ }
83
+
84
+ // Process data...
85
+ return 0;
86
+ }
87
+ ```
88
+
89
+ ### ❌ Example 1: Abrupt API Change
90
+
91
+ ```c
92
+ // WRONG: Breaking change without deprecation period
93
+ // Old code using process_data(data) will break immediately!
94
+ int process_data(const char *data, size_t len) { // Changed signature!
95
+ // ...
96
+ }
97
+ ```
98
+
99
+ ### ✅ Example 2: Versioned API
100
+
101
+ ```c
102
+ #include <stdint.h>
103
+
104
+ // Version 1 API (legacy)
105
+ typedef struct {
106
+ int id;
107
+ char name[32];
108
+ } DeviceInfo_v1;
109
+
110
+ // Version 2 API (current)
111
+ typedef struct {
112
+ int id;
113
+ char name[64];
114
+ uint32_t capabilities;
115
+ uint32_t flags;
116
+ } DeviceInfo_v2;
117
+
118
+ // Legacy function - still supported
119
+ int get_device_info(int device_id, DeviceInfo_v1 *info) {
120
+ DeviceInfo_v2 info_v2;
121
+ int ret;
122
+
123
+ ret = get_device_info_v2(device_id, &info_v2);
124
+ if (ret < 0) {
125
+ return ret;
126
+ }
127
+
128
+ // Convert v2 to v1
129
+ info->id = info_v2.id;
130
+ strncpy(info->name, info_v2.name, sizeof(info->name) - 1);
131
+ info->name[sizeof(info->name) - 1] = '\0';
132
+
133
+ return 0;
134
+ }
135
+
136
+ // New function with extended capabilities
137
+ int get_device_info_v2(int device_id, DeviceInfo_v2 *info) {
138
+ // Full implementation
139
+ return 0;
140
+ }
141
+ ```
142
+
143
+ ### ✅ Example 3: Compatibility Shim
144
+
145
+ ```c
146
+ #include <string.h>
147
+
148
+ // Modern systems have strlcpy, older ones don't
149
+ #ifndef HAVE_STRLCPY
150
+
151
+ // Provide our own implementation for compatibility
152
+ size_t strlcpy(char *dst, const char *src, size_t size) {
153
+ size_t src_len = strlen(src);
154
+
155
+ if (size == 0) {
156
+ return src_len;
157
+ }
158
+
159
+ size_t copy_len = (src_len >= size) ? size - 1 : src_len;
160
+ memcpy(dst, src, copy_len);
161
+ dst[copy_len] = '\0';
162
+
163
+ return src_len;
164
+ }
165
+
166
+ #endif // HAVE_STRLCPY
167
+ ```
168
+
169
+ ### ✅ Example 4: Feature Detection
170
+
171
+ ```c
172
+ #include <stddef.h>
173
+
174
+ // Detect C11 features
175
+ #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
176
+ #define HAVE_C11_FEATURES 1
177
+ #include <stdatomic.h>
178
+ #include <threads.h>
179
+ #else
180
+ #define HAVE_C11_FEATURES 0
181
+ #endif
182
+
183
+ // Use C11 atomics if available, fallback otherwise
184
+ #if HAVE_C11_FEATURES
185
+ typedef atomic_int counter_t;
186
+ #define counter_init(c, val) atomic_init(c, val)
187
+ #define counter_increment(c) atomic_fetch_add(c, 1)
188
+ #define counter_get(c) atomic_load(c)
189
+ #else
190
+ typedef volatile int counter_t;
191
+ #define counter_init(c, val) (*(c) = (val))
192
+ #define counter_increment(c) (++(*(c)))
193
+ #define counter_get(c) (*(c))
194
+ #endif
195
+ ```
196
+
197
+ ### ✅ Example 5: Gradual Migration with Feature Flags
198
+
199
+ ```c
200
+ #include <stdbool.h>
201
+
202
+ // Feature flag for new implementation
203
+ #ifndef USE_NEW_PARSER
204
+ #define USE_NEW_PARSER 0
205
+ #endif
206
+
207
+ int parse_config(const char *filename) {
208
+ #if USE_NEW_PARSER
209
+ // New, improved parser
210
+ return parse_config_new(filename);
211
+ #else
212
+ // Old parser (default for now)
213
+ return parse_config_legacy(filename);
214
+ #endif
215
+ }
216
+
217
+ // Can be enabled with: -DUSE_NEW_PARSER=1
218
+ ```
219
+
220
+ ### ✅ Example 6: Adapter Pattern for API Migration
221
+
222
+ ```c
223
+ // Old API that external code depends on
224
+ typedef struct {
225
+ void (*callback)(int status);
226
+ void *user_data;
227
+ } OldCallback;
228
+
229
+ // New API with better design
230
+ typedef struct {
231
+ void (*callback)(int status, const char *message, void *user_data);
232
+ void *user_data;
233
+ } NewCallback;
234
+
235
+ // Adapter to bridge old and new APIs
236
+ static void callback_adapter(int status, const char *message, void *user_data) {
237
+ OldCallback *old_cb = (OldCallback*)user_data;
238
+
239
+ // Call old callback (ignoring new message parameter)
240
+ if (old_cb && old_cb->callback) {
241
+ old_cb->callback(status);
242
+ }
243
+ }
244
+
245
+ // Old function - wraps new implementation
246
+ void register_callback_old(OldCallback *cb) {
247
+ NewCallback new_cb;
248
+
249
+ new_cb.callback = callback_adapter;
250
+ new_cb.user_data = cb;
251
+
252
+ register_callback_new(&new_cb);
253
+ }
254
+
255
+ // New function
256
+ void register_callback_new(NewCallback *cb) {
257
+ // New implementation
258
+ }
259
+ ```
260
+
261
+ ### ✅ Example 7: Safe Refactoring with Tests
262
+
263
+ ```c
264
+ #include <assert.h>
265
+ #include <string.h>
266
+
267
+ // Original implementation (legacy)
268
+ int legacy_string_copy(char *dest, const char *src, int max_len) {
269
+ int i;
270
+ for (i = 0; i < max_len - 1 && src[i] != '\0'; i++) {
271
+ dest[i] = src[i];
272
+ }
273
+ dest[i] = '\0';
274
+ return i;
275
+ }
276
+
277
+ // Refactored implementation (safer, clearer)
278
+ int refactored_string_copy(char *dest, const char *src, int max_len) {
279
+ if (dest == NULL || src == NULL || max_len <= 0) {
280
+ return -1;
281
+ }
282
+
283
+ size_t src_len = strlen(src);
284
+ size_t copy_len = (src_len >= (size_t)(max_len - 1)) ?
285
+ (size_t)(max_len - 1) : src_len;
286
+
287
+ memcpy(dest, src, copy_len);
288
+ dest[copy_len] = '\0';
289
+
290
+ return (int)copy_len;
291
+ }
292
+
293
+ // Test to verify behavior is preserved
294
+ void test_string_copy_compatibility(void) {
295
+ char buf1[32], buf2[32];
296
+ const char *test = "Hello, World!";
297
+ int len1, len2;
298
+
299
+ len1 = legacy_string_copy(buf1, test, sizeof(buf1));
300
+ len2 = refactored_string_copy(buf2, test, sizeof(buf2));
301
+
302
+ assert(len1 == len2);
303
+ assert(strcmp(buf1, buf2) == 0);
304
+ }
305
+ ```
306
+
307
+ ### ✅ Example 8: Platform Compatibility Macros
308
+
309
+ ```c
310
+ // Handle platform differences
311
+ #ifdef _WIN32
312
+ #include <windows.h>
313
+ #define SLEEP_MS(ms) Sleep(ms)
314
+ #define PATH_SEPARATOR '\\'
315
+ typedef HANDLE thread_handle_t;
316
+ #else
317
+ #include <unistd.h>
318
+ #define SLEEP_MS(ms) usleep((ms) * 1000)
319
+ #define PATH_SEPARATOR '/'
320
+ typedef pthread_t thread_handle_t;
321
+ #endif
322
+
323
+ // Cross-platform sleep function
324
+ void portable_sleep(unsigned int milliseconds) {
325
+ SLEEP_MS(milliseconds);
326
+ }
327
+
328
+ // Cross-platform path handling
329
+ void normalize_path(char *path) {
330
+ char *p = path;
331
+ while (*p) {
332
+ if (*p == '/' || *p == '\\') {
333
+ *p = PATH_SEPARATOR;
334
+ }
335
+ p++;
336
+ }
337
+ }
338
+ ```
339
+
340
+ ### ✅ Example 9: Maintaining Multiple C Standard Support
341
+
342
+ ```c
343
+ #include <stddef.h>
344
+
345
+ // C99 and later have inline keyword
346
+ #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
347
+ #define INLINE inline
348
+ #elif defined(__GNUC__)
349
+ #define INLINE __inline__
350
+ #elif defined(_MSC_VER)
351
+ #define INLINE __inline
352
+ #else
353
+ #define INLINE
354
+ #endif
355
+
356
+ // C99 and later have restrict keyword
357
+ #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
358
+ #define RESTRICT restrict
359
+ #elif defined(__GNUC__)
360
+ #define RESTRICT __restrict__
361
+ #elif defined(_MSC_VER)
362
+ #define RESTRICT __restrict
363
+ #else
364
+ #define RESTRICT
365
+ #endif
366
+
367
+ // Use the compatibility macros
368
+ INLINE void fast_copy(void *RESTRICT dest, const void *RESTRICT src, size_t n) {
369
+ memcpy(dest, src, n);
370
+ }
371
+ ```
372
+
373
+ ### ✅ Example 10: Logging Deprecation Warnings
374
+
375
+ ```c
376
+ #include <stdio.h>
377
+ #include <time.h>
378
+
379
+ static int deprecation_warning_shown = 0;
380
+
381
+ void log_deprecation_warning(const char *old_func, const char *new_func) {
382
+ if (!deprecation_warning_shown) {
383
+ time_t now = time(NULL);
384
+ fprintf(stderr, "[%s] DEPRECATION WARNING: %s() is deprecated. "
385
+ "Use %s() instead.\n",
386
+ ctime(&now), old_func, new_func);
387
+ deprecation_warning_shown = 1;
388
+ }
389
+ }
390
+
391
+ // Deprecated function with runtime warning
392
+ int old_api_function(int value) {
393
+ log_deprecation_warning("old_api_function", "new_api_function");
394
+ return new_api_function(value, 0); // Call new API with default
395
+ }
396
+
397
+ int new_api_function(int value, int flags) {
398
+ // New implementation
399
+ return value * 2;
400
+ }
401
+ ```
402
+
403
+ ### ✅ Example 11: Incremental Refactoring Strategy
404
+
405
+ ```c
406
+ // Step 1: Extract function (no behavior change)
407
+ static int validate_input(const char *input) {
408
+ if (input == NULL || input[0] == '\0') {
409
+ return 0;
410
+ }
411
+ return 1;
412
+ }
413
+
414
+ static int process_valid_input(const char *input) {
415
+ // Original processing logic
416
+ return strlen(input);
417
+ }
418
+
419
+ // Step 2: Refactor original function to use extracted functions
420
+ int legacy_process(const char *input) {
421
+ // Before: all logic was inline
422
+ // After: delegated to smaller functions
423
+ if (!validate_input(input)) {
424
+ return -1;
425
+ }
426
+ return process_valid_input(input);
427
+ }
428
+
429
+ // Step 3: Can now test validate_input and process_valid_input separately
430
+ // Step 4: Can replace implementations incrementally
431
+ ```
432
+
433
+ ### ✅ Example 12: Migration Documentation
434
+
435
+ ```c
436
+ /**
437
+ * @file legacy_api.h
438
+ * @brief Legacy API - Maintained for backward compatibility
439
+ *
440
+ * MIGRATION GUIDE:
441
+ *
442
+ * Old API | New API | Notes
443
+ * ---------------------------|------------------------------|------------------
444
+ * init_system() | system_init_v2() | Added error codes
445
+ * process_data(data) | process_data_ex(data, len) | Added length param
446
+ * get_status() | get_status_detailed() | More information
447
+ *
448
+ * DEPRECATION TIMELINE:
449
+ * - v2.0 (2024-01): Old API marked deprecated
450
+ * - v2.5 (2024-06): Deprecation warnings added
451
+ * - v3.0 (2025-01): Old API removed
452
+ *
453
+ * COMPATIBILITY:
454
+ * - Supports C89, C99, C11, C17
455
+ * - Tested on: Linux, Windows, macOS
456
+ * - Minimum versions: GCC 4.8, Clang 3.5, MSVC 2015
457
+ */
458
+
459
+ // Example of well-documented legacy function
460
+ /**
461
+ * @deprecated Use system_init_v2() instead
462
+ * @brief Initialize system (legacy version)
463
+ * @return 0 on success, -1 on error
464
+ *
465
+ * This function is maintained for backward compatibility only.
466
+ * New code should use system_init_v2() which provides better
467
+ * error reporting and resource management.
468
+ *
469
+ * Will be removed in version 3.0 (January 2025).
470
+ */
471
+ int init_system(void) {
472
+ int result;
473
+ log_deprecation_warning("init_system", "system_init_v2");
474
+
475
+ result = system_init_v2();
476
+ return (result == 0) ? 0 : -1; // Convert new error codes to old format
477
+ }
478
+
479
+ /**
480
+ * @brief Initialize system (current version)
481
+ * @return 0 on success, negative error code on failure
482
+ *
483
+ * Error codes:
484
+ * - 0: Success
485
+ * - -1: Invalid configuration
486
+ * - -2: Resource allocation failed
487
+ * - -3: Hardware initialization failed
488
+ */
489
+ int system_init_v2(void) {
490
+ // New implementation with detailed error codes
491
+ return 0;
492
+ }
493
+ ```
494
+
495
+ ## References
496
+
497
+ - "Working Effectively with Legacy Code" by Michael Feathers
498
+ - "Refactoring: Improving the Design of Existing Code" by Martin Fowler
499
+ - "Code Complete" by Steve McConnell
500
+ - C Portability Guide
501
+ - GNU Coding Standards
502
+
503
+ ## Related Rules
504
+
505
+ - universal-documentation
506
+ - universal-error-handling
507
+ - category-systems
508
+
509
+ ## Configuration
510
+
511
+ Enable in `.augment/c-standards.json`:
512
+
513
+ ```json
514
+ {
515
+ "categories": ["legacy"],
516
+ "category_overrides": {
517
+ "legacy": {
518
+ "allow_deprecated_apis": true,
519
+ "require_migration_docs": true,
520
+ "enforce_compatibility_tests": true,
521
+ "min_c_standard": "c89"
522
+ }
523
+ }
524
+ }
525
+ ```
526
+