specweave 0.22.13 → 0.23.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 (312) hide show
  1. package/.claude-plugin/README.md +2 -2
  2. package/CLAUDE.md +447 -52
  3. package/README.md +33 -10
  4. package/dist/plugins/specweave-github/lib/ThreeLayerSyncManager.d.ts +1 -1
  5. package/dist/plugins/specweave-github/lib/ThreeLayerSyncManager.js +1 -1
  6. package/dist/plugins/specweave-github/lib/enhanced-github-sync.js +1 -1
  7. package/dist/plugins/specweave-github/lib/enhanced-github-sync.js.map +1 -1
  8. package/dist/plugins/specweave-github/lib/github-spec-content-sync.d.ts.map +1 -1
  9. package/dist/plugins/specweave-github/lib/github-spec-content-sync.js +4 -1
  10. package/dist/plugins/specweave-github/lib/github-spec-content-sync.js.map +1 -1
  11. package/dist/plugins/specweave-github/lib/github-spec-sync.d.ts +1 -1
  12. package/dist/plugins/specweave-github/lib/github-spec-sync.js +1 -1
  13. package/dist/plugins/specweave-github/lib/github-sync-bidirectional.d.ts +9 -0
  14. package/dist/plugins/specweave-github/lib/github-sync-bidirectional.d.ts.map +1 -1
  15. package/dist/plugins/specweave-github/lib/github-sync-bidirectional.js +10 -1
  16. package/dist/plugins/specweave-github/lib/github-sync-bidirectional.js.map +1 -1
  17. package/dist/plugins/specweave-github/lib/progress-comment-builder.js +2 -2
  18. package/dist/plugins/specweave-github/lib/progress-comment-builder.js.map +1 -1
  19. package/dist/plugins/specweave-github/lib/types.d.ts +1 -1
  20. package/dist/src/cli/commands/import-external.d.ts +22 -0
  21. package/dist/src/cli/commands/import-external.d.ts.map +1 -0
  22. package/dist/src/cli/commands/import-external.js +282 -0
  23. package/dist/src/cli/commands/import-external.js.map +1 -0
  24. package/dist/src/cli/commands/init.d.ts.map +1 -1
  25. package/dist/src/cli/commands/init.js +359 -1
  26. package/dist/src/cli/commands/init.js.map +1 -1
  27. package/dist/src/cli/helpers/github-repo-selector.d.ts +59 -0
  28. package/dist/src/cli/helpers/github-repo-selector.d.ts.map +1 -0
  29. package/dist/src/cli/helpers/github-repo-selector.js +265 -0
  30. package/dist/src/cli/helpers/github-repo-selector.js.map +1 -0
  31. package/dist/src/cli/helpers/issue-tracker/index.d.ts.map +1 -1
  32. package/dist/src/cli/helpers/issue-tracker/index.js +41 -24
  33. package/dist/src/cli/helpers/issue-tracker/index.js.map +1 -1
  34. package/dist/src/config/import-config.d.ts +69 -0
  35. package/dist/src/config/import-config.d.ts.map +1 -0
  36. package/dist/src/config/import-config.js +136 -0
  37. package/dist/src/config/import-config.js.map +1 -0
  38. package/dist/src/config/types.d.ts +26 -26
  39. package/dist/src/core/increment/ac-status-manager.d.ts.map +1 -1
  40. package/dist/src/core/increment/ac-status-manager.js +4 -2
  41. package/dist/src/core/increment/ac-status-manager.js.map +1 -1
  42. package/dist/src/core/increment/completion-validator.d.ts +30 -1
  43. package/dist/src/core/increment/completion-validator.d.ts.map +1 -1
  44. package/dist/src/core/increment/completion-validator.js +151 -3
  45. package/dist/src/core/increment/completion-validator.js.map +1 -1
  46. package/dist/src/core/increment/increment-archiver.d.ts +25 -0
  47. package/dist/src/core/increment/increment-archiver.d.ts.map +1 -1
  48. package/dist/src/core/increment/increment-archiver.js +130 -3
  49. package/dist/src/core/increment/increment-archiver.js.map +1 -1
  50. package/dist/src/core/living-docs/feature-archiver.d.ts +37 -0
  51. package/dist/src/core/living-docs/feature-archiver.d.ts.map +1 -1
  52. package/dist/src/core/living-docs/feature-archiver.js +262 -18
  53. package/dist/src/core/living-docs/feature-archiver.js.map +1 -1
  54. package/dist/src/core/living-docs/feature-id-manager.d.ts +17 -0
  55. package/dist/src/core/living-docs/feature-id-manager.d.ts.map +1 -1
  56. package/dist/src/core/living-docs/feature-id-manager.js +25 -0
  57. package/dist/src/core/living-docs/feature-id-manager.js.map +1 -1
  58. package/dist/src/core/living-docs/living-docs-sync.d.ts +16 -0
  59. package/dist/src/core/living-docs/living-docs-sync.d.ts.map +1 -1
  60. package/dist/src/core/living-docs/living-docs-sync.js +56 -1
  61. package/dist/src/core/living-docs/living-docs-sync.js.map +1 -1
  62. package/dist/src/core/living-docs/task-project-specific-generator.d.ts +2 -2
  63. package/dist/src/core/living-docs/task-project-specific-generator.js +2 -2
  64. package/dist/src/core/repo-structure/prompt-consolidator.d.ts +2 -2
  65. package/dist/src/core/repo-structure/prompt-consolidator.d.ts.map +1 -1
  66. package/dist/src/core/repo-structure/prompt-consolidator.js +3 -15
  67. package/dist/src/core/repo-structure/prompt-consolidator.js.map +1 -1
  68. package/dist/src/core/repo-structure/repo-structure-manager.d.ts +1 -1
  69. package/dist/src/core/repo-structure/repo-structure-manager.d.ts.map +1 -1
  70. package/dist/src/core/repo-structure/repo-structure-manager.js +3 -6
  71. package/dist/src/core/repo-structure/repo-structure-manager.js.map +1 -1
  72. package/dist/src/core/spec-content-sync.d.ts +4 -1
  73. package/dist/src/core/spec-content-sync.d.ts.map +1 -1
  74. package/dist/src/core/spec-content-sync.js +139 -4
  75. package/dist/src/core/spec-content-sync.js.map +1 -1
  76. package/dist/src/core/spec-task-mapper.d.ts.map +1 -1
  77. package/dist/src/core/spec-task-mapper.js +9 -8
  78. package/dist/src/core/spec-task-mapper.js.map +1 -1
  79. package/dist/src/core/status-line-validator.d.ts +63 -0
  80. package/dist/src/core/status-line-validator.d.ts.map +1 -0
  81. package/dist/src/core/status-line-validator.js +253 -0
  82. package/dist/src/core/status-line-validator.js.map +1 -0
  83. package/dist/src/core/sync/bidirectional-engine.d.ts +10 -1
  84. package/dist/src/core/sync/bidirectional-engine.d.ts.map +1 -1
  85. package/dist/src/core/sync/bidirectional-engine.js +10 -1
  86. package/dist/src/core/sync/bidirectional-engine.js.map +1 -1
  87. package/dist/src/core/sync/profile-manager.d.ts.map +1 -1
  88. package/dist/src/core/sync/profile-manager.js +3 -0
  89. package/dist/src/core/sync/profile-manager.js.map +1 -1
  90. package/dist/src/core/sync/project-context.d.ts.map +1 -1
  91. package/dist/src/core/sync/project-context.js +3 -0
  92. package/dist/src/core/sync/project-context.js.map +1 -1
  93. package/dist/src/core/sync/status-sync-engine.d.ts +1 -1
  94. package/dist/src/core/sync/status-sync-engine.js +1 -1
  95. package/dist/src/core/sync/sync-event-logger.d.ts +15 -1
  96. package/dist/src/core/sync/sync-event-logger.d.ts.map +1 -1
  97. package/dist/src/core/sync/sync-event-logger.js +39 -1
  98. package/dist/src/core/sync/sync-event-logger.js.map +1 -1
  99. package/dist/src/core/types/origin-metadata.d.ts +153 -0
  100. package/dist/src/core/types/origin-metadata.d.ts.map +1 -0
  101. package/dist/src/core/types/origin-metadata.js +166 -0
  102. package/dist/src/core/types/origin-metadata.js.map +1 -0
  103. package/dist/src/core/types/sync-config-validator.d.ts +57 -0
  104. package/dist/src/core/types/sync-config-validator.d.ts.map +1 -0
  105. package/dist/src/core/types/sync-config-validator.js +116 -0
  106. package/dist/src/core/types/sync-config-validator.js.map +1 -0
  107. package/dist/src/core/types/sync-profile.d.ts +8 -2
  108. package/dist/src/core/types/sync-profile.d.ts.map +1 -1
  109. package/dist/src/core/types/sync-profile.js.map +1 -1
  110. package/dist/src/core/types/sync-settings.d.ts +73 -0
  111. package/dist/src/core/types/sync-settings.d.ts.map +1 -0
  112. package/dist/src/core/types/sync-settings.js +90 -0
  113. package/dist/src/core/types/sync-settings.js.map +1 -0
  114. package/dist/src/core/utils/permission-checker.d.ts +100 -0
  115. package/dist/src/core/utils/permission-checker.d.ts.map +1 -0
  116. package/dist/src/core/utils/permission-checker.js +166 -0
  117. package/dist/src/core/utils/permission-checker.js.map +1 -0
  118. package/dist/src/generators/spec/spec-parser.js +3 -3
  119. package/dist/src/generators/spec/spec-parser.js.map +1 -1
  120. package/dist/src/generators/spec/task-parser.js +4 -4
  121. package/dist/src/generators/spec/task-parser.js.map +1 -1
  122. package/dist/src/id-generators/task-id-generator.d.ts +96 -0
  123. package/dist/src/id-generators/task-id-generator.d.ts.map +1 -0
  124. package/dist/src/id-generators/task-id-generator.js +143 -0
  125. package/dist/src/id-generators/task-id-generator.js.map +1 -0
  126. package/dist/src/id-generators/us-id-generator.d.ts +96 -0
  127. package/dist/src/id-generators/us-id-generator.d.ts.map +1 -0
  128. package/dist/src/id-generators/us-id-generator.js +143 -0
  129. package/dist/src/id-generators/us-id-generator.js.map +1 -0
  130. package/dist/src/importers/ado-importer.d.ts +43 -0
  131. package/dist/src/importers/ado-importer.d.ts.map +1 -0
  132. package/dist/src/importers/ado-importer.js +234 -0
  133. package/dist/src/importers/ado-importer.js.map +1 -0
  134. package/dist/src/importers/duplicate-detector.d.ts +107 -0
  135. package/dist/src/importers/duplicate-detector.d.ts.map +1 -0
  136. package/dist/src/importers/duplicate-detector.js +189 -0
  137. package/dist/src/importers/duplicate-detector.js.map +1 -0
  138. package/dist/src/importers/external-importer.d.ts +96 -0
  139. package/dist/src/importers/external-importer.d.ts.map +1 -0
  140. package/dist/src/importers/external-importer.js +13 -0
  141. package/dist/src/importers/external-importer.js.map +1 -0
  142. package/dist/src/importers/github-importer.d.ts +37 -0
  143. package/dist/src/importers/github-importer.d.ts.map +1 -0
  144. package/dist/src/importers/github-importer.js +161 -0
  145. package/dist/src/importers/github-importer.js.map +1 -0
  146. package/dist/src/importers/import-coordinator.d.ts +105 -0
  147. package/dist/src/importers/import-coordinator.d.ts.map +1 -0
  148. package/dist/src/importers/import-coordinator.js +224 -0
  149. package/dist/src/importers/import-coordinator.js.map +1 -0
  150. package/dist/src/importers/item-converter.d.ts +96 -0
  151. package/dist/src/importers/item-converter.d.ts.map +1 -0
  152. package/dist/src/importers/item-converter.js +246 -0
  153. package/dist/src/importers/item-converter.js.map +1 -0
  154. package/dist/src/importers/jira-importer.d.ts +42 -0
  155. package/dist/src/importers/jira-importer.d.ts.map +1 -0
  156. package/dist/src/importers/jira-importer.js +221 -0
  157. package/dist/src/importers/jira-importer.js.map +1 -0
  158. package/dist/src/importers/rate-limiter.d.ts +128 -0
  159. package/dist/src/importers/rate-limiter.d.ts.map +1 -0
  160. package/dist/src/importers/rate-limiter.js +200 -0
  161. package/dist/src/importers/rate-limiter.js.map +1 -0
  162. package/dist/src/init/compliance/types.d.ts +2 -2
  163. package/dist/src/init/repo/types.d.ts +2 -2
  164. package/dist/src/integrations/ado/ado-client.d.ts +6 -0
  165. package/dist/src/integrations/ado/ado-client.d.ts.map +1 -1
  166. package/dist/src/integrations/ado/ado-client.js +23 -0
  167. package/dist/src/integrations/ado/ado-client.js.map +1 -1
  168. package/dist/src/integrations/jira/jira-client.d.ts +6 -0
  169. package/dist/src/integrations/jira/jira-client.d.ts.map +1 -1
  170. package/dist/src/integrations/jira/jira-client.js +38 -0
  171. package/dist/src/integrations/jira/jira-client.js.map +1 -1
  172. package/dist/src/integrations/jira/jira-mapper.d.ts +1 -1
  173. package/dist/src/integrations/jira/jira-mapper.js +1 -1
  174. package/dist/src/living-docs/fs-id-allocator.d.ts +149 -0
  175. package/dist/src/living-docs/fs-id-allocator.d.ts.map +1 -0
  176. package/dist/src/living-docs/fs-id-allocator.js +325 -0
  177. package/dist/src/living-docs/fs-id-allocator.js.map +1 -0
  178. package/dist/src/living-docs/id-registry.d.ts +124 -0
  179. package/dist/src/living-docs/id-registry.d.ts.map +1 -0
  180. package/dist/src/living-docs/id-registry.js +230 -0
  181. package/dist/src/living-docs/id-registry.js.map +1 -0
  182. package/dist/src/progress/us-progress-tracker.d.ts +68 -0
  183. package/dist/src/progress/us-progress-tracker.d.ts.map +1 -0
  184. package/dist/src/progress/us-progress-tracker.js +120 -0
  185. package/dist/src/progress/us-progress-tracker.js.map +1 -0
  186. package/dist/src/sync/external-item-sync-service.d.ts +150 -0
  187. package/dist/src/sync/external-item-sync-service.d.ts.map +1 -0
  188. package/dist/src/sync/external-item-sync-service.js +241 -0
  189. package/dist/src/sync/external-item-sync-service.js.map +1 -0
  190. package/dist/src/sync/format-preservation-sync.d.ts +90 -0
  191. package/dist/src/sync/format-preservation-sync.d.ts.map +1 -0
  192. package/dist/src/sync/format-preservation-sync.js +173 -0
  193. package/dist/src/sync/format-preservation-sync.js.map +1 -0
  194. package/dist/src/sync/index.d.ts +8 -0
  195. package/dist/src/sync/index.d.ts.map +1 -0
  196. package/dist/src/sync/index.js +6 -0
  197. package/dist/src/sync/index.js.map +1 -0
  198. package/dist/src/sync/sync-coordinator.d.ts +49 -0
  199. package/dist/src/sync/sync-coordinator.d.ts.map +1 -0
  200. package/dist/src/sync/sync-coordinator.js +248 -0
  201. package/dist/src/sync/sync-coordinator.js.map +1 -0
  202. package/dist/src/sync/sync-metadata.d.ts +75 -0
  203. package/dist/src/sync/sync-metadata.d.ts.map +1 -0
  204. package/dist/src/sync/sync-metadata.js +100 -0
  205. package/dist/src/sync/sync-metadata.js.map +1 -0
  206. package/dist/src/types/living-docs-us-file.d.ts +63 -0
  207. package/dist/src/types/living-docs-us-file.d.ts.map +1 -0
  208. package/dist/src/types/living-docs-us-file.js +27 -0
  209. package/dist/src/types/living-docs-us-file.js.map +1 -0
  210. package/dist/src/validators/format-preservation-validator.d.ts +127 -0
  211. package/dist/src/validators/format-preservation-validator.d.ts.map +1 -0
  212. package/dist/src/validators/format-preservation-validator.js +187 -0
  213. package/dist/src/validators/format-preservation-validator.js.map +1 -0
  214. package/package.json +3 -2
  215. package/plugins/specweave/.claude-plugin/plugin.json +36 -2
  216. package/plugins/specweave/agents/architect/AGENT.md +11 -2
  217. package/plugins/specweave/agents/test-aware-planner/AGENT.md +81 -25
  218. package/plugins/specweave/commands/specweave-archive-features.md +11 -1
  219. package/plugins/specweave/commands/specweave-import-external.md +407 -0
  220. package/plugins/specweave/commands/specweave-progress.md +45 -97
  221. package/plugins/specweave/hooks/post-edit-spec.sh +41 -0
  222. package/plugins/specweave/hooks/post-increment-completion.sh +168 -26
  223. package/plugins/specweave/hooks/post-increment-planning.sh +148 -4
  224. package/plugins/specweave/hooks/post-spec-update.sh +0 -0
  225. package/plugins/specweave/hooks/post-task-completion.sh +75 -5
  226. package/plugins/specweave/hooks/post-write-spec.sh +37 -0
  227. package/plugins/specweave/lib/hooks/auto-transition.js +1 -1
  228. package/plugins/specweave/lib/hooks/auto-transition.ts +1 -1
  229. package/plugins/specweave/lib/hooks/invoke-translator-skill.js +1 -1
  230. package/plugins/specweave/lib/hooks/invoke-translator-skill.ts +1 -1
  231. package/plugins/specweave/lib/hooks/sync-cache.js +294 -0
  232. package/plugins/specweave/lib/hooks/sync-living-docs.js +67 -2
  233. package/plugins/specweave/lib/hooks/sync-us-tasks.js +200 -14
  234. package/plugins/specweave/lib/hooks/translate-file.js +1 -1
  235. package/plugins/specweave/lib/hooks/translate-file.ts +1 -1
  236. package/plugins/specweave/lib/hooks/update-ac-status.js +1 -1
  237. package/plugins/specweave/lib/hooks/update-ac-status.ts +1 -1
  238. package/plugins/specweave/lib/vendor/core/increment/ac-status-manager.d.ts +115 -0
  239. package/plugins/specweave/lib/vendor/core/increment/ac-status-manager.js +345 -0
  240. package/plugins/specweave/lib/vendor/core/increment/ac-status-manager.js.map +1 -0
  241. package/plugins/specweave/lib/vendor/core/increment/active-increment-manager.d.ts +106 -0
  242. package/plugins/specweave/lib/vendor/core/increment/active-increment-manager.js +220 -0
  243. package/plugins/specweave/lib/vendor/core/increment/active-increment-manager.js.map +1 -0
  244. package/plugins/specweave/lib/vendor/core/increment/auto-transition-manager.d.ts +60 -0
  245. package/plugins/specweave/lib/vendor/core/increment/auto-transition-manager.js +192 -0
  246. package/plugins/specweave/lib/vendor/core/increment/auto-transition-manager.js.map +1 -0
  247. package/plugins/specweave/lib/vendor/core/increment/duplicate-detector.d.ts +52 -0
  248. package/plugins/specweave/lib/vendor/core/increment/duplicate-detector.js +276 -0
  249. package/plugins/specweave/lib/vendor/core/increment/duplicate-detector.js.map +1 -0
  250. package/plugins/specweave/lib/vendor/core/increment/metadata-manager.d.ts +163 -0
  251. package/plugins/specweave/lib/vendor/core/increment/metadata-manager.js +541 -0
  252. package/plugins/specweave/lib/vendor/core/increment/metadata-manager.js.map +1 -0
  253. package/plugins/specweave/lib/vendor/core/types/increment-metadata.d.ts +157 -0
  254. package/plugins/specweave/lib/vendor/core/types/increment-metadata.js +191 -0
  255. package/plugins/specweave/lib/vendor/core/types/increment-metadata.js.map +1 -0
  256. package/plugins/specweave/lib/vendor/generators/spec/task-parser.d.ts +95 -0
  257. package/plugins/specweave/lib/vendor/generators/spec/task-parser.js +301 -0
  258. package/plugins/specweave/lib/vendor/generators/spec/task-parser.js.map +1 -0
  259. package/plugins/specweave/lib/vendor/utils/logger.d.ts +48 -0
  260. package/plugins/specweave/lib/vendor/utils/logger.js +53 -0
  261. package/plugins/specweave/lib/vendor/utils/logger.js.map +1 -0
  262. package/plugins/specweave/lib/vendor/utils/translation.d.ts +187 -0
  263. package/plugins/specweave/lib/vendor/utils/translation.js +414 -0
  264. package/plugins/specweave/lib/vendor/utils/translation.js.map +1 -0
  265. package/plugins/specweave-ado/.claude-plugin/plugin.json +1 -1
  266. package/plugins/specweave-ado/lib/ado-multi-project-sync.js +0 -1
  267. package/plugins/specweave-ado/lib/conflict-resolver.ts +1 -1
  268. package/plugins/specweave-alternatives/.claude-plugin/plugin.json +1 -1
  269. package/plugins/specweave-backend/.claude-plugin/plugin.json +1 -1
  270. package/plugins/specweave-confluent/.claude-plugin/plugin.json +1 -1
  271. package/plugins/specweave-cost-optimizer/.claude-plugin/plugin.json +1 -1
  272. package/plugins/specweave-diagrams/.claude-plugin/plugin.json +1 -1
  273. package/plugins/specweave-docs/.claude-plugin/plugin.json +1 -1
  274. package/plugins/specweave-docs-preview/.claude-plugin/plugin.json +1 -1
  275. package/plugins/specweave-figma/.claude-plugin/plugin.json +1 -1
  276. package/plugins/specweave-frontend/.claude-plugin/plugin.json +1 -1
  277. package/plugins/specweave-github/.claude-plugin/plugin.json +1 -1
  278. package/plugins/specweave-github/commands/specweave-github-update-user-story.md +1 -1
  279. package/plugins/specweave-github/hooks/post-task-completion.sh +37 -22
  280. package/plugins/specweave-github/lib/ThreeLayerSyncManager.ts +1 -1
  281. package/plugins/specweave-github/lib/enhanced-github-sync.js +1 -1
  282. package/plugins/specweave-github/lib/enhanced-github-sync.ts +1 -1
  283. package/plugins/specweave-github/lib/github-spec-content-sync.js +2 -1
  284. package/plugins/specweave-github/lib/github-spec-content-sync.ts +4 -1
  285. package/plugins/specweave-github/lib/github-spec-sync.js +1 -1
  286. package/plugins/specweave-github/lib/github-spec-sync.ts +1 -1
  287. package/plugins/specweave-github/lib/github-sync-bidirectional.js +1 -1
  288. package/plugins/specweave-github/lib/github-sync-bidirectional.ts +10 -1
  289. package/plugins/specweave-github/lib/progress-comment-builder.js +1 -1
  290. package/plugins/specweave-github/lib/progress-comment-builder.ts +2 -2
  291. package/plugins/specweave-github/lib/types.ts +1 -1
  292. package/plugins/specweave-github/skills/github-issue-standard/SKILL.md +1 -1
  293. package/plugins/specweave-infrastructure/.claude-plugin/plugin.json +1 -1
  294. package/plugins/specweave-jira/.claude-plugin/plugin.json +1 -1
  295. package/plugins/specweave-jira/lib/enhanced-jira-sync.js +3 -3
  296. package/plugins/specweave-kafka/.claude-plugin/plugin.json +1 -1
  297. package/plugins/specweave-kafka-streams/.claude-plugin/plugin.json +1 -1
  298. package/plugins/specweave-kubernetes/.claude-plugin/plugin.json +1 -1
  299. package/plugins/specweave-ml/.claude-plugin/plugin.json +1 -1
  300. package/plugins/specweave-mobile/.claude-plugin/plugin.json +1 -1
  301. package/plugins/specweave-n8n/.claude-plugin/plugin.json +1 -1
  302. package/plugins/specweave-payments/.claude-plugin/plugin.json +1 -1
  303. package/plugins/specweave-release/.claude-plugin/plugin.json +1 -1
  304. package/plugins/specweave-testing/.claude-plugin/plugin.json +1 -1
  305. package/plugins/specweave-tooling/.claude-plugin/plugin.json +1 -1
  306. package/plugins/specweave-ui/.claude-plugin/plugin.json +1 -1
  307. package/src/templates/.env.example +5 -0
  308. package/src/templates/config-permissions-guide.md +413 -0
  309. package/src/templates/config.json.template +68 -0
  310. package/src/templates/tasks.md.template +180 -201
  311. package/plugins/specweave-ado/lib/enhanced-ado-sync.js +0 -170
  312. package/plugins/specweave-release/hooks/.specweave/logs/dora-tracking.log +0 -5442
@@ -0,0 +1,301 @@
1
+ /**
2
+ * Task Parser with US-Task Linkage Support
3
+ *
4
+ * Parses tasks.md files to extract task metadata including new US linkage fields:
5
+ * - userStory: US-ID this task implements (e.g., "US-001")
6
+ * - satisfiesACs: List of AC-IDs this task satisfies (e.g., ["AC-US1-01", "AC-US1-02"])
7
+ *
8
+ * Supports hierarchical task structure grouped by User Story.
9
+ */
10
+ import { readFileSync } from 'fs';
11
+ /**
12
+ * Parse tasks.md and extract all tasks with US linkage
13
+ *
14
+ * @param tasksPath - Path to tasks.md file
15
+ * @returns Map of User Story ID → Tasks
16
+ * @throws Error if tasks.md cannot be read or is malformed
17
+ */
18
+ export function parseTasksWithUSLinks(tasksPath) {
19
+ try {
20
+ const content = readFileSync(tasksPath, 'utf-8');
21
+ const tasks = {};
22
+ // Split content into lines for line number tracking
23
+ const lines = content.split('\n');
24
+ // Regex patterns for task parsing (T-029: Support E suffix for external IDs)
25
+ const taskHeaderRegex = /^###\s+(T-\d{3}E?):\s*(.+)$/;
26
+ const userStoryRegex = /^\*\*User Story\*\*:\s*(US-\d{3}E?)/;
27
+ const satisfiesACsRegex = /^\*\*Satisfies ACs\*\*:\s*(AC-US\d+E?-\d{2}(?:,\s*AC-US\d+E?-\d{2})*)/;
28
+ const statusRegex = /^\*\*Status\*\*:\s*\[([x ])\]\s*(\w+)/;
29
+ const priorityRegex = /^\*\*Priority\*\*:\s*(.+)/;
30
+ const estimatedEffortRegex = /^\*\*Estimated Effort\*\*:\s*(.+)/;
31
+ const dependenciesRegex = /^\*\*Dependencies\*\*:\s*(.+)/;
32
+ let currentTask = null;
33
+ let currentDescription = [];
34
+ let currentSection = 'none';
35
+ for (let i = 0; i < lines.length; i++) {
36
+ const line = lines[i];
37
+ const lineNumber = i + 1;
38
+ // Check for task header (### T-XXX: Title)
39
+ const taskHeaderMatch = line.match(taskHeaderRegex);
40
+ if (taskHeaderMatch) {
41
+ // Save previous task if exists
42
+ if (currentTask) {
43
+ saveTask(tasks, currentTask, currentDescription);
44
+ }
45
+ // Start new task
46
+ currentTask = {
47
+ id: taskHeaderMatch[1],
48
+ title: taskHeaderMatch[2],
49
+ status: 'pending',
50
+ lineNumber
51
+ };
52
+ currentDescription = [];
53
+ currentSection = 'none';
54
+ continue;
55
+ }
56
+ // Skip if no current task
57
+ if (!currentTask)
58
+ continue;
59
+ // Parse task fields
60
+ const userStoryMatch = line.match(userStoryRegex);
61
+ if (userStoryMatch) {
62
+ currentTask.userStory = userStoryMatch[1];
63
+ continue;
64
+ }
65
+ const satisfiesACsMatch = line.match(satisfiesACsRegex);
66
+ if (satisfiesACsMatch) {
67
+ // Split comma-separated AC-IDs and trim whitespace
68
+ currentTask.satisfiesACs = satisfiesACsMatch[1]
69
+ .split(',')
70
+ .map(ac => ac.trim());
71
+ continue;
72
+ }
73
+ const statusMatch = line.match(statusRegex);
74
+ if (statusMatch) {
75
+ const checkbox = statusMatch[1];
76
+ const statusText = statusMatch[2].toLowerCase();
77
+ // Map checkbox and status text to TaskStatus
78
+ if (checkbox === 'x') {
79
+ currentTask.status = 'completed';
80
+ }
81
+ else if (statusText.includes('progress')) {
82
+ currentTask.status = 'in_progress';
83
+ }
84
+ else if (statusText.includes('transfer')) {
85
+ currentTask.status = 'transferred';
86
+ }
87
+ else if (statusText.includes('cancel')) {
88
+ currentTask.status = 'canceled';
89
+ }
90
+ else {
91
+ currentTask.status = 'pending';
92
+ }
93
+ continue;
94
+ }
95
+ const priorityMatch = line.match(priorityRegex);
96
+ if (priorityMatch) {
97
+ currentTask.priority = priorityMatch[1];
98
+ continue;
99
+ }
100
+ const estimatedEffortMatch = line.match(estimatedEffortRegex);
101
+ if (estimatedEffortMatch) {
102
+ currentTask.estimatedEffort = estimatedEffortMatch[1];
103
+ continue;
104
+ }
105
+ const dependenciesMatch = line.match(dependenciesRegex);
106
+ if (dependenciesMatch) {
107
+ // Parse dependencies (T-001, T-002, etc.)
108
+ currentTask.dependencies = dependenciesMatch[1]
109
+ .split(',')
110
+ .map(dep => dep.trim())
111
+ .filter(dep => dep.match(/^T-\d{3}$/));
112
+ continue;
113
+ }
114
+ // Track sections for description parsing
115
+ if (line.startsWith('**Description**:')) {
116
+ currentSection = 'description';
117
+ continue;
118
+ }
119
+ if (line.startsWith('**Implementation Steps**:')) {
120
+ currentSection = 'implementation';
121
+ continue;
122
+ }
123
+ if (line.startsWith('**Test Plan**:')) {
124
+ currentSection = 'test';
125
+ continue;
126
+ }
127
+ if (line.startsWith('**Files Affected**:')) {
128
+ currentSection = 'files';
129
+ currentTask.filesAffected = [];
130
+ continue;
131
+ }
132
+ // Collect description lines
133
+ if (currentSection === 'description' && line.trim() && !line.startsWith('**')) {
134
+ currentDescription.push(line.trim());
135
+ }
136
+ // Collect files affected
137
+ if (currentSection === 'files' && line.trim().startsWith('- `')) {
138
+ const filePath = line.trim().replace(/^- `(.+)`/, '$1');
139
+ if (currentTask.filesAffected) {
140
+ currentTask.filesAffected.push(filePath);
141
+ }
142
+ }
143
+ }
144
+ // Save last task
145
+ if (currentTask) {
146
+ saveTask(tasks, currentTask, currentDescription);
147
+ }
148
+ return tasks;
149
+ }
150
+ catch (error) {
151
+ throw new Error(`Failed to parse tasks.md at ${tasksPath}: ${error}`);
152
+ }
153
+ }
154
+ /**
155
+ * Helper: Save task to tasks map, grouped by User Story
156
+ */
157
+ function saveTask(tasks, task, description) {
158
+ // Set description
159
+ if (description.length > 0) {
160
+ task.description = description.join(' ');
161
+ }
162
+ // Group by User Story (or "unassigned" if no userStory field)
163
+ const usId = task.userStory || 'unassigned';
164
+ if (!tasks[usId]) {
165
+ tasks[usId] = [];
166
+ }
167
+ tasks[usId].push(task);
168
+ }
169
+ /**
170
+ * Validate task US and AC linkage
171
+ *
172
+ * @param task - Task to validate
173
+ * @param validUSIds - List of valid US-IDs from spec.md
174
+ * @param validACIds - List of valid AC-IDs from spec.md
175
+ * @returns Array of validation errors (empty if valid)
176
+ */
177
+ export function validateTaskLinkage(task, validUSIds, validACIds) {
178
+ const errors = [];
179
+ // Validate userStory field
180
+ if (task.userStory) {
181
+ // Check format (US-XXX)
182
+ if (!task.userStory.match(/^US-\d{3}$/)) {
183
+ errors.push({
184
+ taskId: task.id,
185
+ field: 'userStory',
186
+ value: task.userStory,
187
+ message: `Invalid US-ID format: "${task.userStory}" (expected format: US-001)`,
188
+ suggestedFix: 'Use format: US-XXX where XXX is a 3-digit number'
189
+ });
190
+ }
191
+ // Check if US exists in spec.md
192
+ else if (!validUSIds.includes(task.userStory)) {
193
+ errors.push({
194
+ taskId: task.id,
195
+ field: 'userStory',
196
+ value: task.userStory,
197
+ message: `User Story ${task.userStory} not found in spec.md`,
198
+ suggestedFix: `Valid User Stories: ${validUSIds.join(', ')}`
199
+ });
200
+ }
201
+ }
202
+ // Validate satisfiesACs field
203
+ if (task.satisfiesACs && task.satisfiesACs.length > 0) {
204
+ for (const acId of task.satisfiesACs) {
205
+ // Check format (AC-USXX-YY)
206
+ if (!acId.match(/^AC-US\d+-\d{2}$/)) {
207
+ errors.push({
208
+ taskId: task.id,
209
+ field: 'satisfiesACs',
210
+ value: acId,
211
+ message: `Invalid AC-ID format: "${acId}" (expected format: AC-US1-01)`,
212
+ suggestedFix: 'Use format: AC-USXX-YY where XX is US number, YY is AC number'
213
+ });
214
+ continue;
215
+ }
216
+ // Check if AC exists in spec.md
217
+ if (!validACIds.includes(acId)) {
218
+ errors.push({
219
+ taskId: task.id,
220
+ field: 'satisfiesACs',
221
+ value: acId,
222
+ message: `Acceptance Criteria ${acId} not found in spec.md`,
223
+ suggestedFix: `Check spec.md for valid AC-IDs in this User Story`
224
+ });
225
+ continue;
226
+ }
227
+ // Check if AC belongs to correct User Story
228
+ if (task.userStory) {
229
+ const acUSNumber = extractUSNumberFromACId(acId);
230
+ const taskUSNumber = extractUSNumber(task.userStory);
231
+ if (acUSNumber !== taskUSNumber) {
232
+ errors.push({
233
+ taskId: task.id,
234
+ field: 'satisfiesACs',
235
+ value: acId,
236
+ message: `AC ${acId} belongs to US-${String(acUSNumber).padStart(3, '0')}, but task is linked to ${task.userStory}`,
237
+ suggestedFix: `Either link task to US-${String(acUSNumber).padStart(3, '0')} or use different AC-ID`
238
+ });
239
+ }
240
+ }
241
+ }
242
+ }
243
+ return errors;
244
+ }
245
+ /**
246
+ * Extract US number from AC-ID (AC-US1-01 → 1)
247
+ */
248
+ function extractUSNumberFromACId(acId) {
249
+ const match = acId.match(/^AC-US(\d+)-\d{2}$/);
250
+ return match ? parseInt(match[1], 10) : -1;
251
+ }
252
+ /**
253
+ * Extract US number from US-ID (US-001 → 1)
254
+ */
255
+ function extractUSNumber(usId) {
256
+ const match = usId.match(/^US-(\d{3})$/);
257
+ return match ? parseInt(match[1], 10) : -1;
258
+ }
259
+ /**
260
+ * Get all tasks (flattened, not grouped by US)
261
+ *
262
+ * @param tasksByUS - Tasks grouped by User Story
263
+ * @returns Array of all tasks
264
+ */
265
+ export function getAllTasks(tasksByUS) {
266
+ return Object.values(tasksByUS).flat();
267
+ }
268
+ /**
269
+ * Count tasks by status
270
+ *
271
+ * @param tasksByUS - Tasks grouped by User Story
272
+ * @returns Map of status → count
273
+ */
274
+ export function countTasksByStatus(tasksByUS) {
275
+ const counts = {
276
+ pending: 0,
277
+ in_progress: 0,
278
+ completed: 0,
279
+ transferred: 0,
280
+ canceled: 0
281
+ };
282
+ const allTasks = getAllTasks(tasksByUS);
283
+ allTasks.forEach(task => {
284
+ counts[task.status]++;
285
+ });
286
+ return counts;
287
+ }
288
+ /**
289
+ * Calculate completion percentage
290
+ *
291
+ * @param tasksByUS - Tasks grouped by User Story
292
+ * @returns Completion percentage (0-100)
293
+ */
294
+ export function calculateCompletionPercentage(tasksByUS) {
295
+ const allTasks = getAllTasks(tasksByUS);
296
+ if (allTasks.length === 0)
297
+ return 0;
298
+ const completedTasks = allTasks.filter(t => t.status === 'completed').length;
299
+ return Math.round((completedTasks / allTasks.length) * 100);
300
+ }
301
+ //# sourceMappingURL=task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,MAAM,GAA+B;QACzC,OAAO,EAAE,CAAC;QACV,WAAW,EAAE,CAAC;QACd,SAAS,EAAE,CAAC;QACZ,WAAW,EAAE,CAAC;QACd,QAAQ,EAAE,CAAC;KACZ,CAAC;IAEF,MAAM,QAAQ,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;IACxC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QACtB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;IACxB,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,6BAA6B,CAAC,SAA2B;IACvE,MAAM,QAAQ,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC;IACxC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAEpC,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC,MAAM,CAAC;IAC7E,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC;AAC9D,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Logger Interface
3
+ *
4
+ * Abstraction for logging to enable silent testing and flexible log output.
5
+ * Prevents test output pollution from expected error conditions.
6
+ */
7
+ /**
8
+ * Logger interface for dependency injection
9
+ */
10
+ export interface Logger {
11
+ /**
12
+ * Log informational message
13
+ */
14
+ log(message: string): void;
15
+ /**
16
+ * Log error message with optional error object
17
+ */
18
+ error(message: string, error?: any): void;
19
+ /**
20
+ * Log warning message
21
+ */
22
+ warn(message: string): void;
23
+ /**
24
+ * Log debug message
25
+ */
26
+ debug(message: string): void;
27
+ }
28
+ /**
29
+ * Console logger (default production logger)
30
+ *
31
+ * Logs to console.log/error/warn
32
+ */
33
+ export declare const consoleLogger: Logger;
34
+ /**
35
+ * Silent logger (for testing)
36
+ *
37
+ * Suppresses all log output - use in tests to prevent pollution
38
+ * from expected error conditions.
39
+ */
40
+ export declare const silentLogger: Logger;
41
+ /**
42
+ * Create a custom logger that filters based on log level
43
+ *
44
+ * @param minLevel - Minimum level to log (debug=0, log=1, warn=2, error=3)
45
+ * @returns Logger instance
46
+ */
47
+ export declare function createFilteredLogger(minLevel?: 'debug' | 'log' | 'warn' | 'error'): Logger;
48
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Logger Interface
3
+ *
4
+ * Abstraction for logging to enable silent testing and flexible log output.
5
+ * Prevents test output pollution from expected error conditions.
6
+ */
7
+ /**
8
+ * Console logger (default production logger)
9
+ *
10
+ * Logs to console.log/error/warn
11
+ */
12
+ export const consoleLogger = {
13
+ log: (message) => console.log(message),
14
+ error: (message, error) => {
15
+ if (error) {
16
+ console.error(message, error);
17
+ }
18
+ else {
19
+ console.error(message);
20
+ }
21
+ },
22
+ warn: (message) => console.warn(message),
23
+ debug: (message) => console.log(message)
24
+ };
25
+ /**
26
+ * Silent logger (for testing)
27
+ *
28
+ * Suppresses all log output - use in tests to prevent pollution
29
+ * from expected error conditions.
30
+ */
31
+ export const silentLogger = {
32
+ log: () => { },
33
+ error: () => { },
34
+ warn: () => { },
35
+ debug: () => { }
36
+ };
37
+ /**
38
+ * Create a custom logger that filters based on log level
39
+ *
40
+ * @param minLevel - Minimum level to log (debug=0, log=1, warn=2, error=3)
41
+ * @returns Logger instance
42
+ */
43
+ export function createFilteredLogger(minLevel = 'log') {
44
+ const levels = { debug: 0, log: 1, warn: 2, error: 3 };
45
+ const threshold = levels[minLevel];
46
+ return {
47
+ log: (msg) => levels.log >= threshold && console.log(msg),
48
+ error: (msg, err) => levels.error >= threshold && (err ? console.error(msg, err) : console.error(msg)),
49
+ warn: (msg) => levels.warn >= threshold && console.warn(msg),
50
+ debug: (msg) => levels.debug >= threshold && console.log(msg)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AAC,MAAM,CAAC,GAAG,IAAI,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;QACzD,KAAK,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,IAAI,SAAS,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACtG,IAAI,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,IAAI,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC;QAC5D,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,IAAI,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC;KAC9D,CAAC;AACJ,CAAC"}
@@ -0,0 +1,187 @@
1
+ /**
2
+ * Translation Utilities
3
+ *
4
+ * LLM-native translation system for SpecWeave multilingual support.
5
+ * Provides zero-cost language detection and cost-efficient translation
6
+ * using Claude Haiku via current LLM session.
7
+ *
8
+ * Strategy:
9
+ * - Language Detection: Simple heuristic (no API calls, <1ms)
10
+ * - Translation: Claude Haiku via current session (~$0.0025 per file)
11
+ * - Preservation: Markdown, code blocks, technical terms stay intact
12
+ *
13
+ * @see .specweave/increments/0006-llm-native-i18n/reports/DESIGN-POST-GENERATION-TRANSLATION.md
14
+ */
15
+ /**
16
+ * Supported languages for translation
17
+ */
18
+ export type SupportedLanguage = 'en' | 'ru' | 'es' | 'zh' | 'de' | 'fr' | 'ja' | 'ko' | 'pt' | 'ar' | 'he' | 'unknown';
19
+ /**
20
+ * Language detection result
21
+ */
22
+ export interface LanguageDetectionResult {
23
+ language: SupportedLanguage;
24
+ confidence: number;
25
+ nonAsciiRatio: number;
26
+ detectionMethod: 'heuristic' | 'explicit';
27
+ }
28
+ /**
29
+ * Preserved content structure for code blocks
30
+ */
31
+ export interface PreservedContent {
32
+ preserved: string;
33
+ blocks: string[];
34
+ inlineCode: string[];
35
+ links: string[];
36
+ }
37
+ /**
38
+ * Translation result with metadata
39
+ */
40
+ export interface TranslationResult {
41
+ translated: string;
42
+ sourceLanguage: SupportedLanguage;
43
+ targetLanguage: SupportedLanguage;
44
+ estimatedTokens: number;
45
+ estimatedCost: number;
46
+ preservedBlocks: number;
47
+ }
48
+ /**
49
+ * Detects the language of the given content using simple heuristics
50
+ *
51
+ * @param content - The text content to analyze
52
+ * @returns Language detection result with confidence score
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * const result = detectLanguage('Это тестовый документ');
57
+ * console.log(result.language); // 'ru'
58
+ * console.log(result.confidence); // 0.95
59
+ * ```
60
+ */
61
+ export declare function detectLanguage(content: string): LanguageDetectionResult;
62
+ /**
63
+ * Detects specific language from content
64
+ *
65
+ * @param content - The text content to analyze
66
+ * @returns Detected language code or 'unknown'
67
+ *
68
+ * @example
69
+ * ```typescript
70
+ * detectSpecificLanguage('Это текст'); // 'ru'
71
+ * detectSpecificLanguage('这是文本'); // 'zh'
72
+ * ```
73
+ */
74
+ export declare function detectSpecificLanguage(content: string): SupportedLanguage;
75
+ /**
76
+ * Preserves code blocks, inline code, and links before translation
77
+ *
78
+ * @param content - Markdown content to preserve
79
+ * @returns Preserved content with placeholders
80
+ *
81
+ * @example
82
+ * ```typescript
83
+ * const content = 'Text\n```js\ncode\n```\nMore text';
84
+ * const preserved = preserveCodeBlocks(content);
85
+ * // preserved.blocks = ['```js\ncode\n```']
86
+ * // preserved.preserved = 'Text\n__CODE_BLOCK_0__\nMore text'
87
+ * ```
88
+ */
89
+ export declare function preserveCodeBlocks(content: string): PreservedContent;
90
+ /**
91
+ * Restores preserved code blocks, inline code, and links after translation
92
+ *
93
+ * @param translated - Translated text with placeholders
94
+ * @param preserved - Preserved content structure
95
+ * @returns Restored text with original code blocks and links
96
+ *
97
+ * @example
98
+ * ```typescript
99
+ * const translated = 'Текст\n__CODE_BLOCK_0__\nБольше текста';
100
+ * const preserved = { blocks: ['```js\ncode\n```'], inlineCode: [], links: [] };
101
+ * const restored = restoreCodeBlocks(translated, preserved);
102
+ * // Result: 'Текст\n```js\ncode\n```\nБольше текста'
103
+ * ```
104
+ */
105
+ export declare function restoreCodeBlocks(translated: string, preserved: Pick<PreservedContent, 'blocks' | 'inlineCode' | 'links'>): string;
106
+ /**
107
+ * Estimates the number of tokens in a text
108
+ * Rule of thumb: ~4 characters per token for English, ~2-3 for other languages
109
+ *
110
+ * @param text - Text to estimate
111
+ * @param language - Language code for estimation
112
+ * @returns Estimated token count
113
+ */
114
+ export declare function estimateTokens(text: string, language?: SupportedLanguage): number;
115
+ /**
116
+ * Estimates translation cost using Claude Haiku pricing
117
+ * Haiku pricing (as of 2025): $0.25 per 1M input tokens, $1.25 per 1M output tokens
118
+ *
119
+ * @param inputTokens - Input token count
120
+ * @param outputTokens - Output token count (defaults to input for balanced estimate)
121
+ * @returns Estimated cost in USD
122
+ */
123
+ export declare function estimateTranslationCost(inputTokens: number, outputTokens?: number): number;
124
+ /**
125
+ * Generates translation prompt for LLM
126
+ *
127
+ * @param content - Content to translate
128
+ * @param sourceLanguage - Source language code
129
+ * @param targetLanguage - Target language code (default: 'en')
130
+ * @returns Translation prompt for LLM
131
+ */
132
+ export declare function generateTranslationPrompt(content: string, sourceLanguage: SupportedLanguage, targetLanguage?: SupportedLanguage): string;
133
+ /**
134
+ * Translates content to English using LLM (Claude Haiku)
135
+ * This function generates the prompt but delegates actual LLM invocation
136
+ * to the caller (via Task tool, skill, or direct API)
137
+ *
138
+ * @param content - Content to translate
139
+ * @param sourceLanguage - Source language code
140
+ * @returns Translation prompt and metadata (caller must invoke LLM)
141
+ *
142
+ * @example
143
+ * ```typescript
144
+ * const content = 'Это тестовый документ';
145
+ * const result = prepareTranslation(content, 'ru');
146
+ * // Caller then invokes LLM with result.prompt
147
+ * ```
148
+ */
149
+ export declare function prepareTranslation(content: string, sourceLanguage: SupportedLanguage, targetLanguage?: SupportedLanguage): {
150
+ prompt: string;
151
+ preserved: PreservedContent;
152
+ estimatedTokens: number;
153
+ estimatedCost: number;
154
+ };
155
+ /**
156
+ * Post-processes translated content
157
+ * Restores code blocks, validates markdown, cleans up extra whitespace
158
+ *
159
+ * @param translated - Translated text from LLM
160
+ * @param preserved - Preserved content structure
161
+ * @returns Cleaned and restored translated content
162
+ */
163
+ export declare function postProcessTranslation(translated: string, preserved: PreservedContent): string;
164
+ /**
165
+ * Validates that translated content preserves markdown structure
166
+ * Returns warnings if structure doesn't match
167
+ *
168
+ * @param original - Original content
169
+ * @param translated - Translated content
170
+ * @returns Array of validation warnings (empty if valid)
171
+ */
172
+ export declare function validateTranslation(original: string, translated: string): string[];
173
+ /**
174
+ * Gets human-readable language name
175
+ *
176
+ * @param code - Language code
177
+ * @returns Human-readable name
178
+ */
179
+ export declare function getLanguageName(code: SupportedLanguage): string;
180
+ /**
181
+ * Formats cost for display
182
+ *
183
+ * @param cost - Cost in USD
184
+ * @returns Formatted string (e.g., "$0.0025" or "<$0.001")
185
+ */
186
+ export declare function formatCost(cost: number): string;
187
+ //# sourceMappingURL=translation.d.ts.map