@danmoisan/drm-copilot-mcp 1.1.18 → 1.1.20

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 (264) hide show
  1. package/out/mcp-server.js +1149 -661
  2. package/package.json +3 -2
  3. package/resources/claude-customizations/.claude/agents/atomic-executor.md +28 -6
  4. package/resources/claude-customizations/.claude/agents/atomic-planner.md +20 -2
  5. package/resources/claude-customizations/.claude/agents/epic-orchestrator.md +17 -4
  6. package/resources/claude-customizations/.claude/agents/epic-planner.md +5 -4
  7. package/resources/claude-customizations/.claude/agents/feature-review.md +6 -4
  8. package/resources/claude-customizations/.claude/agents/orchestrator.md +9 -5
  9. package/resources/claude-customizations/.claude/agents/parallel-orchestrator.md +35 -13
  10. package/resources/claude-customizations/.claude/agents/parallel-planner.md +9 -6
  11. package/resources/claude-customizations/.claude/agents/pr-author.md +15 -2
  12. package/resources/claude-customizations/.claude/agents/prd-feature.md +1 -1
  13. package/resources/claude-customizations/.claude/agents/task-researcher.md +8 -0
  14. package/resources/claude-customizations/.claude/hooks/check-powershell-test-purity.ps1 +7 -1
  15. package/resources/claude-customizations/.claude/hooks/check-python-test-purity.ps1 +7 -1
  16. package/resources/claude-customizations/.claude/hooks/enforce-checkpoint-monotonic.ps1 +7 -1
  17. package/resources/claude-customizations/.claude/hooks/enforce-completion-consistency.ps1 +111 -46
  18. package/resources/claude-customizations/.claude/hooks/enforce-completion-helpers.ps1 +105 -0
  19. package/resources/claude-customizations/.claude/hooks/enforce-discovery-artifact-gate.ps1 +8 -1
  20. package/resources/claude-customizations/.claude/hooks/enforce-epic-invocation-origin.ps1 +7 -1
  21. package/resources/claude-customizations/.claude/hooks/enforce-epic-merge-gate-command.ps1 +190 -0
  22. package/resources/claude-customizations/.claude/hooks/enforce-epic-merge-gate-resolution.ps1 +116 -59
  23. package/resources/claude-customizations/.claude/hooks/enforce-epic-merge-gate.ps1 +78 -77
  24. package/resources/claude-customizations/.claude/hooks/enforce-epic-wave-barrier.ps1 +74 -75
  25. package/resources/claude-customizations/.claude/hooks/enforce-epic-worktree-removal-gate-resolution.ps1 +127 -35
  26. package/resources/claude-customizations/.claude/hooks/enforce-epic-worktree-removal-gate.ps1 +61 -57
  27. package/resources/claude-customizations/.claude/hooks/enforce-evidence-locations.ps1 +7 -1
  28. package/resources/claude-customizations/.claude/hooks/enforce-feature-folder-order.ps1 +129 -39
  29. package/resources/claude-customizations/.claude/hooks/enforce-mermaid-validation.ps1 +7 -1
  30. package/resources/claude-customizations/.claude/hooks/enforce-model-routing-receipt.ps1 +9 -3
  31. package/resources/claude-customizations/.claude/hooks/enforce-orchestration-preimplementation-gate-epic-scope.ps1 +39 -51
  32. package/resources/claude-customizations/.claude/hooks/enforce-orchestration-preimplementation-gate-helpers.ps1 +31 -58
  33. package/resources/claude-customizations/.claude/hooks/enforce-orchestration-preimplementation-gate-modes.ps1 +63 -47
  34. package/resources/claude-customizations/.claude/hooks/enforce-orchestration-preimplementation-gate-targets.ps1 +433 -0
  35. package/resources/claude-customizations/.claude/hooks/enforce-orchestration-preimplementation-gate.ps1 +17 -12
  36. package/resources/claude-customizations/.claude/hooks/enforce-parallel-abandon-gate.ps1 +9 -3
  37. package/resources/claude-customizations/.claude/hooks/enforce-parallel-cohort-barrier.ps1 +65 -50
  38. package/resources/claude-customizations/.claude/hooks/enforce-parallel-drift-gate.ps1 +49 -42
  39. package/resources/claude-customizations/.claude/hooks/enforce-parallel-worktree-removal-gate.ps1 +54 -72
  40. package/resources/claude-customizations/.claude/hooks/enforce-powershell-batch-budget.ps1 +8 -2
  41. package/resources/claude-customizations/.claude/hooks/enforce-pr-author-command-allowlist.ps1 +279 -0
  42. package/resources/claude-customizations/.claude/hooks/enforce-pr-author-skill-helpers.ps1 +129 -75
  43. package/resources/claude-customizations/.claude/hooks/enforce-pr-author-skill.artifact-root.ps1 +233 -0
  44. package/resources/claude-customizations/.claude/hooks/enforce-pr-author-skill.docs-only.ps1 +224 -0
  45. package/resources/claude-customizations/.claude/hooks/enforce-pr-author-skill.ps1 +69 -24
  46. package/resources/claude-customizations/.claude/hooks/enforce-prd-feature-before-planner-helpers.ps1 +29 -18
  47. package/resources/claude-customizations/.claude/hooks/enforce-prd-feature-before-planner.ps1 +10 -4
  48. package/resources/claude-customizations/.claude/hooks/enforce-promotion-mcp-only.ps1 +14 -5
  49. package/resources/claude-customizations/.claude/hooks/enforce-python-batch-budget.ps1 +8 -2
  50. package/resources/claude-customizations/.claude/hooks/feature-folder-resolution.ps1 +373 -0
  51. package/resources/claude-customizations/.claude/hooks/feature-review-coverage-thresholds.ps1 +85 -0
  52. package/resources/claude-customizations/.claude/hooks/hook-command-heredoc.ps1 +119 -0
  53. package/resources/claude-customizations/.claude/hooks/hook-command-invocation-operands.ps1 +198 -0
  54. package/resources/claude-customizations/.claude/hooks/hook-command-invocation.ps1 +254 -255
  55. package/resources/claude-customizations/.claude/hooks/hook-command-payload-powershell.ps1 +201 -0
  56. package/resources/claude-customizations/.claude/hooks/hook-command-payload.ps1 +484 -0
  57. package/resources/claude-customizations/.claude/hooks/hook-command-scanner.ps1 +27 -110
  58. package/resources/claude-customizations/.claude/hooks/hook-dependency-guard.ps1 +114 -0
  59. package/resources/claude-customizations/.claude/hooks/hook-docs-only-diff.ps1 +497 -0
  60. package/resources/claude-customizations/.claude/hooks/premortem-section.ps1 +149 -0
  61. package/resources/claude-customizations/.claude/hooks/subagentstop-envelope.ps1 +192 -0
  62. package/resources/claude-customizations/.claude/hooks/validate-bash.ps1 +9 -3
  63. package/resources/claude-customizations/.claude/hooks/validate-discovery-artifact-gate.ps1 +40 -42
  64. package/resources/claude-customizations/.claude/hooks/validate-executor-output.ps1 +267 -113
  65. package/resources/claude-customizations/.claude/hooks/validate-feature-review-coverage-metrics.ps1 +180 -0
  66. package/resources/claude-customizations/.claude/hooks/validate-feature-review-coverage-rules.ps1 +195 -0
  67. package/resources/claude-customizations/.claude/hooks/validate-feature-review-coverage.ps1 +141 -395
  68. package/resources/claude-customizations/.claude/hooks/validate-orchestrator-output-resolution.ps1 +311 -0
  69. package/resources/claude-customizations/.claude/hooks/validate-orchestrator-output-routing.ps1 +170 -0
  70. package/resources/claude-customizations/.claude/hooks/validate-orchestrator-output.ps1 +115 -190
  71. package/resources/claude-customizations/.claude/hooks/validate-planner-output.ps1 +77 -33
  72. package/resources/claude-customizations/.claude/hooks/validate-pr-author-output.ps1 +39 -44
  73. package/resources/claude-customizations/.claude/hooks/validate-prd-feature-output.ps1 +43 -14
  74. package/resources/claude-customizations/.claude/hooks/validate-required-artifact-output.ps1 +66 -36
  75. package/resources/claude-customizations/.claude/hooks/validate-task-researcher-output.ps1 +52 -36
  76. package/resources/claude-customizations/.claude/lib/bash/mutate-parallel-run.sh +191 -0
  77. package/resources/claude-customizations/.claude/lib/bash/parallel-cohorts.sh +13 -3
  78. package/resources/claude-customizations/.claude/lib/bash/parallel-mutation-cli.sh +152 -0
  79. package/resources/claude-customizations/.claude/lib/bash/parallel-mutation-ops.sh +193 -0
  80. package/resources/claude-customizations/.claude/lib/bash/parallel-mutation.sh +322 -0
  81. package/resources/claude-customizations/.claude/lib/bash/remove-parallel-item.sh +146 -0
  82. package/resources/claude-customizations/.claude/lib/blast-radius/BlastRadiusExtraction.psm1 +23 -33
  83. package/resources/claude-customizations/.claude/lib/blast-radius/BlastRadiusTokenShape.psm1 +86 -6
  84. package/resources/claude-customizations/.claude/lib/ci-gate/Invoke-CiGateParser.ps1 +91 -19
  85. package/resources/claude-customizations/.claude/lib/ci-gate/Invoke-MergeConfirmationParser.ps1 +203 -0
  86. package/resources/claude-customizations/.claude/lib/orchestrator-state/OrchestratorStateEpicWaveBarrier.psm1 +346 -0
  87. package/resources/claude-customizations/.claude/lib/orchestrator-state/OrchestratorStateIssueAdoption.psm1 +24 -3
  88. package/resources/claude-customizations/.claude/lib/worktree-resolution/WorktreeItemResolution.psm1 +79 -2
  89. package/resources/claude-customizations/.claude/lib/worktree-resolution/WorktreeRunResolution.psm1 +3 -3
  90. package/resources/claude-customizations/.claude/rules/architecture-boundaries.md +5 -5
  91. package/resources/claude-customizations/.claude/rules/csharp.md +2 -2
  92. package/resources/claude-customizations/.claude/rules/general-code-change.md +1 -1
  93. package/resources/claude-customizations/.claude/rules/general-unit-test.md +3 -2
  94. package/resources/claude-customizations/.claude/rules/orchestrator-state.md +37 -4
  95. package/resources/claude-customizations/.claude/rules/parallel-orchestration.md +50 -5
  96. package/resources/claude-customizations/.claude/rules/plan-acceptance-gates.md +85 -10
  97. package/resources/claude-customizations/.claude/rules/quality-tiers.md +11 -7
  98. package/resources/claude-customizations/.claude/rules/shell.md +10 -8
  99. package/resources/claude-customizations/.claude/rules/typescript.md +1 -1
  100. package/resources/claude-customizations/.claude/settings.json +3 -4
  101. package/resources/claude-customizations/.claude/skills/acceptance-criteria-tracking/SKILL.md +1 -1
  102. package/resources/claude-customizations/.claude/skills/atomic-plan-contract/SKILL.md +52 -16
  103. package/resources/claude-customizations/.claude/skills/cleanup-merged-worktrees/SKILL.md +7 -3
  104. package/resources/claude-customizations/.claude/skills/cleanup-merged-worktrees/scripts/cleanup_worktrees_detached_lib.sh +1 -1
  105. package/resources/claude-customizations/.claude/skills/cleanup-merged-worktrees/scripts/cleanup_worktrees_enumerate_lib.sh +2 -0
  106. package/resources/claude-customizations/.claude/skills/cleanup-merged-worktrees/scripts/cleanup_worktrees_scan_helper.sh +2 -0
  107. package/resources/claude-customizations/.claude/skills/csharp-change-budget-router/SKILL.md +2 -2
  108. package/resources/claude-customizations/.claude/skills/epic-orchestrate/SKILL.md +45 -9
  109. package/resources/claude-customizations/.claude/skills/epic-plan/SKILL.md +5 -3
  110. package/resources/claude-customizations/.claude/skills/evidence-and-timestamp-conventions/SKILL.md +10 -1
  111. package/resources/claude-customizations/.claude/skills/execution-environment/SKILL.md +134 -0
  112. package/resources/claude-customizations/.claude/skills/feature-promotion-lifecycle/SKILL.md +1 -1
  113. package/resources/claude-customizations/.claude/skills/feature-review-workflow/SKILL.md +4 -3
  114. package/resources/claude-customizations/.claude/skills/orchestrate/SKILL.md +36 -15
  115. package/resources/claude-customizations/.claude/skills/parallel-add/SKILL.md +52 -14
  116. package/resources/claude-customizations/.claude/skills/parallel-close/SKILL.md +22 -9
  117. package/resources/claude-customizations/.claude/skills/parallel-orchestrate/SKILL.md +108 -21
  118. package/resources/claude-customizations/.claude/skills/parallel-plan/SKILL.md +63 -7
  119. package/resources/claude-customizations/.claude/skills/parallel-remove/SKILL.md +35 -12
  120. package/resources/claude-customizations/.claude/skills/powershell-change-budget-router/SKILL.md +1 -1
  121. package/resources/claude-customizations/.claude/skills/pr-author/SKILL.md +3 -1
  122. package/resources/claude-customizations/.claude/skills/python-change-budget-router/SKILL.md +1 -1
  123. package/resources/claude-customizations/.claude/skills/quota-throttling/SKILL.md +1 -1
  124. package/resources/claude-customizations/.claude/skills/remediation-handoff-atomic-planner/SKILL.md +16 -8
  125. package/resources/claude-customizations/.claude/skills/research-issue/SKILL.md +6 -0
  126. package/resources/claude-customizations/pack-manifests/core.json +27 -0
  127. package/resources/codex-and-agents-customizations/.agents/skills/README.md +1 -0
  128. package/resources/codex-and-agents-customizations/.agents/skills/acceptance-criteria-tracking/SKILL.md +1 -1
  129. package/resources/codex-and-agents-customizations/.agents/skills/architecture-boundaries/SKILL.md +5 -5
  130. package/resources/codex-and-agents-customizations/.agents/skills/atomic-executor/SKILL.md +19 -7
  131. package/resources/codex-and-agents-customizations/.agents/skills/atomic-plan-contract/SKILL.md +43 -4
  132. package/resources/codex-and-agents-customizations/.agents/skills/atomic-planner/SKILL.md +18 -6
  133. package/resources/codex-and-agents-customizations/.agents/skills/csharp/SKILL.md +2 -2
  134. package/resources/codex-and-agents-customizations/.agents/skills/csharp-change-budget-router/SKILL.md +2 -2
  135. package/resources/codex-and-agents-customizations/.agents/skills/csharp-qa-gate/SKILL.md +2 -2
  136. package/resources/codex-and-agents-customizations/.agents/skills/epic-orchestrate/SKILL.md +16 -1
  137. package/resources/codex-and-agents-customizations/.agents/skills/epic-plan/SKILL.md +17 -1
  138. package/resources/codex-and-agents-customizations/.agents/skills/epic-run/SKILL.md +2 -1
  139. package/resources/codex-and-agents-customizations/.agents/skills/evidence-and-timestamp-conventions/SKILL.md +10 -1
  140. package/resources/codex-and-agents-customizations/.agents/skills/execution-environment/SKILL.md +134 -0
  141. package/resources/codex-and-agents-customizations/.agents/skills/feature-review-workflow/SKILL.md +13 -5
  142. package/resources/codex-and-agents-customizations/.agents/skills/general-code-change/SKILL.md +1 -1
  143. package/resources/codex-and-agents-customizations/.agents/skills/general-unit-test/SKILL.md +3 -2
  144. package/resources/codex-and-agents-customizations/.agents/skills/orchestrate/SKILL.md +27 -8
  145. package/resources/codex-and-agents-customizations/.agents/skills/orchestrator-workflow/SKILL.md +1 -1
  146. package/resources/codex-and-agents-customizations/.agents/skills/powershell-change-budget-router/SKILL.md +1 -1
  147. package/resources/codex-and-agents-customizations/.agents/skills/python-change-budget-router/SKILL.md +1 -1
  148. package/resources/codex-and-agents-customizations/.agents/skills/quality-tiers/SKILL.md +11 -7
  149. package/resources/codex-and-agents-customizations/.agents/skills/remediation-handoff-atomic-planner/SKILL.md +7 -3
  150. package/resources/codex-and-agents-customizations/.agents/skills/research-issue/SKILL.md +6 -0
  151. package/resources/codex-and-agents-customizations/.agents/skills/translate-claude-to-codex/SKILL.md +1 -1
  152. package/resources/codex-and-agents-customizations/.agents-variants/csharp-legacy/skills/csharp/SKILL.md +2 -2
  153. package/resources/codex-and-agents-customizations/.agents-variants/csharp-legacy/skills/csharp-qa-gate/SKILL.md +2 -2
  154. package/resources/codex-and-agents-customizations/.codex/agents/atomic-executor-c1.toml +21 -6
  155. package/resources/codex-and-agents-customizations/.codex/agents/atomic-executor-c2.toml +21 -6
  156. package/resources/codex-and-agents-customizations/.codex/agents/atomic-executor-c3-elevated.toml +21 -6
  157. package/resources/codex-and-agents-customizations/.codex/agents/atomic-executor-c3.toml +21 -6
  158. package/resources/codex-and-agents-customizations/.codex/agents/atomic-executor-c4.toml +21 -6
  159. package/resources/codex-and-agents-customizations/.codex/agents/atomic-executor.toml +21 -6
  160. package/resources/codex-and-agents-customizations/.codex/agents/atomic-planner-c1.toml +15 -2
  161. package/resources/codex-and-agents-customizations/.codex/agents/atomic-planner-c2.toml +15 -2
  162. package/resources/codex-and-agents-customizations/.codex/agents/atomic-planner-c3-elevated.toml +15 -2
  163. package/resources/codex-and-agents-customizations/.codex/agents/atomic-planner-c3.toml +15 -2
  164. package/resources/codex-and-agents-customizations/.codex/agents/atomic-planner-c4.toml +15 -2
  165. package/resources/codex-and-agents-customizations/.codex/agents/atomic-planner.toml +15 -2
  166. package/resources/codex-and-agents-customizations/.codex/agents/atomic-planning.toml +1 -1
  167. package/resources/codex-and-agents-customizations/.codex/agents/csharp-atomic-planning.toml +1 -1
  168. package/resources/codex-and-agents-customizations/.codex/agents/epic-orchestrator.toml +4 -1
  169. package/resources/codex-and-agents-customizations/.codex/agents/feature-review.toml +6 -6
  170. package/resources/codex-and-agents-customizations/.codex/agents/orchestrator-c1.toml +7 -4
  171. package/resources/codex-and-agents-customizations/.codex/agents/orchestrator-c2.toml +7 -4
  172. package/resources/codex-and-agents-customizations/.codex/agents/orchestrator-c3-elevated.toml +7 -4
  173. package/resources/codex-and-agents-customizations/.codex/agents/orchestrator-c3.toml +7 -4
  174. package/resources/codex-and-agents-customizations/.codex/agents/orchestrator-c4.toml +7 -4
  175. package/resources/codex-and-agents-customizations/.codex/agents/orchestrator.toml +7 -4
  176. package/resources/codex-and-agents-customizations/.codex/agents/powershell-atomic-planning.toml +1 -1
  177. package/resources/codex-and-agents-customizations/.codex/agents/python-atomic-planning.toml +1 -1
  178. package/resources/codex-and-agents-customizations/.codex/agents/task-researcher-c1.toml +6 -0
  179. package/resources/codex-and-agents-customizations/.codex/agents/task-researcher-c2.toml +6 -0
  180. package/resources/codex-and-agents-customizations/.codex/agents/task-researcher-c3-elevated.toml +6 -0
  181. package/resources/codex-and-agents-customizations/.codex/agents/task-researcher-c3.toml +6 -0
  182. package/resources/codex-and-agents-customizations/.codex/agents/task-researcher-c4.toml +6 -0
  183. package/resources/codex-and-agents-customizations/.codex/agents/task-researcher.toml +6 -0
  184. package/resources/codex-and-agents-customizations/.codex/codex-web-setup.sh +318 -273
  185. package/resources/codex-and-agents-customizations/.codex/config.toml +1 -1
  186. package/resources/codex-and-agents-customizations/.codex/hooks/check-powershell-test-purity.ps1 +7 -1
  187. package/resources/codex-and-agents-customizations/.codex/hooks/check-python-test-purity.ps1 +7 -1
  188. package/resources/codex-and-agents-customizations/.codex/hooks/codex-epic-child-launch-attestation.ps1 +1 -1
  189. package/resources/codex-and-agents-customizations/.codex/hooks/enforce-checkpoint-monotonic.ps1 +7 -1
  190. package/resources/codex-and-agents-customizations/.codex/hooks/enforce-codex-model-routing.ps1 +8 -2
  191. package/resources/codex-and-agents-customizations/.codex/hooks/enforce-completion-consistency.ps1 +97 -44
  192. package/resources/codex-and-agents-customizations/.codex/hooks/enforce-completion-helpers.ps1 +105 -0
  193. package/resources/codex-and-agents-customizations/.codex/hooks/enforce-epic-child-worktree-binding.ps1 +7 -1
  194. package/resources/codex-and-agents-customizations/.codex/hooks/enforce-epic-merge-gate-command.ps1 +190 -0
  195. package/resources/codex-and-agents-customizations/.codex/hooks/enforce-epic-merge-gate.ps1 +54 -43
  196. package/resources/codex-and-agents-customizations/.codex/hooks/enforce-epic-planning-only.ps1 +6 -0
  197. package/resources/codex-and-agents-customizations/.codex/hooks/enforce-epic-root-invocation.ps1 +7 -1
  198. package/resources/codex-and-agents-customizations/.codex/hooks/enforce-epic-wave-barrier.ps1 +7 -1
  199. package/resources/codex-and-agents-customizations/.codex/hooks/enforce-epic-worktree-removal-gate.ps1 +54 -41
  200. package/resources/codex-and-agents-customizations/.codex/hooks/enforce-evidence-locations.ps1 +7 -1
  201. package/resources/codex-and-agents-customizations/.codex/hooks/enforce-orchestration-preimplementation-gate-epic-scope.ps1 +35 -14
  202. package/resources/codex-and-agents-customizations/.codex/hooks/enforce-orchestration-preimplementation-gate-helpers.ps1 +31 -58
  203. package/resources/codex-and-agents-customizations/.codex/hooks/enforce-orchestration-preimplementation-gate-modes.ps1 +63 -47
  204. package/resources/codex-and-agents-customizations/.codex/hooks/enforce-orchestration-preimplementation-gate-targets.ps1 +433 -0
  205. package/resources/codex-and-agents-customizations/.codex/hooks/enforce-orchestration-preimplementation-gate.ps1 +24 -11
  206. package/resources/codex-and-agents-customizations/.codex/hooks/enforce-powershell-batch-budget.ps1 +8 -2
  207. package/resources/codex-and-agents-customizations/.codex/hooks/enforce-promotion-mcp-only.ps1 +13 -4
  208. package/resources/codex-and-agents-customizations/.codex/hooks/enforce-python-batch-budget.ps1 +8 -2
  209. package/resources/codex-and-agents-customizations/.codex/hooks/feature-folder-resolution.ps1 +373 -0
  210. package/resources/codex-and-agents-customizations/.codex/hooks/feature-review-coverage-thresholds.ps1 +85 -0
  211. package/resources/codex-and-agents-customizations/.codex/hooks/hook-command-heredoc.ps1 +119 -0
  212. package/resources/codex-and-agents-customizations/.codex/hooks/hook-command-invocation-operands.ps1 +198 -0
  213. package/resources/codex-and-agents-customizations/.codex/hooks/hook-command-invocation.ps1 +254 -255
  214. package/resources/codex-and-agents-customizations/.codex/hooks/hook-command-payload-powershell.ps1 +201 -0
  215. package/resources/codex-and-agents-customizations/.codex/hooks/hook-command-payload.ps1 +484 -0
  216. package/resources/codex-and-agents-customizations/.codex/hooks/hook-command-scanner.ps1 +27 -110
  217. package/resources/codex-and-agents-customizations/.codex/hooks/hook-dependency-guard.ps1 +114 -0
  218. package/resources/codex-and-agents-customizations/.codex/hooks/hook-docs-only-diff.ps1 +497 -0
  219. package/resources/codex-and-agents-customizations/.codex/hooks/validate-bash.ps1 +8 -2
  220. package/resources/codex-and-agents-customizations/.codex/hooks/validate-codex-subagent-routing.ps1 +7 -1
  221. package/resources/codex-and-agents-customizations/.codex/hooks/validate-feature-review-coverage.ps1 +24 -8
  222. package/resources/codex-and-agents-customizations/.codex/prompts/feature-review-remediate.md +6 -4
  223. package/resources/codex-and-agents-customizations/pack-manifests/core.json +11 -0
  224. package/resources/customizations/.github/agents/atomic_executor.agent.md +21 -11
  225. package/resources/customizations/.github/agents/atomic_planning.agent.md +8 -3
  226. package/resources/customizations/.github/agents/csharp-atomic-executor.agent.md +13 -9
  227. package/resources/customizations/.github/agents/csharp-atomic-planning.agent.md +2 -2
  228. package/resources/customizations/.github/agents/csharp-orchestrator.agent.md +2 -2
  229. package/resources/customizations/.github/agents/csharp-typed-engineer.agent.md +5 -5
  230. package/resources/customizations/.github/agents/orchestrator.agent.md +8 -5
  231. package/resources/customizations/.github/agents/powershell-atomic-executor.agent.md +13 -9
  232. package/resources/customizations/.github/agents/powershell-atomic-planning.agent.md +2 -2
  233. package/resources/customizations/.github/agents/powershell-orchestrator.agent.md +2 -2
  234. package/resources/customizations/.github/agents/powershell-typed-engineer.agent.md +3 -3
  235. package/resources/customizations/.github/agents/python-atomic-executor.agent.md +13 -9
  236. package/resources/customizations/.github/agents/python-atomic-planning.agent.md +2 -2
  237. package/resources/customizations/.github/agents/python-orchestrator.agent.md +2 -2
  238. package/resources/customizations/.github/agents/task-researcher.agent.md +6 -0
  239. package/resources/customizations/.github/instructions/csharp-code-change.instructions.md +4 -4
  240. package/resources/customizations/.github/instructions/csharp-unit-test.instructions.md +2 -2
  241. package/resources/customizations/.github/prompts/generate-atomic-plan.prompt.md +16 -10
  242. package/resources/customizations/.github/prompts/orchestrate-csharp-work.prompt.md +2 -2
  243. package/resources/customizations/.github/prompts/orchestrate-powershell-work.prompt.md +1 -1
  244. package/resources/customizations/.github/prompts/orchestrate-python-work.prompt.md +1 -1
  245. package/resources/customizations/.github/prompts/orchestrate-work.prompt.md +2 -2
  246. package/resources/customizations/.github/skills/acceptance-criteria-tracking/SKILL.md +1 -1
  247. package/resources/customizations/.github/skills/atomic-plan-contract/SKILL.md +43 -4
  248. package/resources/customizations/.github/skills/csharp-change-budget-router/SKILL.md +1 -1
  249. package/resources/customizations/.github/skills/evidence-and-timestamp-conventions/SKILL.md +10 -1
  250. package/resources/customizations/.github/skills/execution-environment/SKILL.md +134 -0
  251. package/resources/customizations/.github/skills/feature-review-workflow/SKILL.md +1 -1
  252. package/resources/customizations/.github/skills/powershell-change-budget-router/SKILL.md +1 -1
  253. package/resources/customizations/.github/skills/remediation-handoff-atomic-planner/SKILL.md +7 -3
  254. package/resources/feature-templates/bug/plan.yyyy-MM-ddTHH-mm.md +10 -0
  255. package/resources/feature-templates/feature/plan.yyyy-MM-ddTHH-mm.md +11 -0
  256. package/resources/feature-templates/refactor/plan.yyyy-MM-ddTHH-mm.md +11 -0
  257. package/resources/powershell/PoshQC/PoshQC.Coverage.psm1 +314 -0
  258. package/resources/powershell/PoshQC/PoshQC.CoverageMerge.psm1 +163 -0
  259. package/resources/powershell/PoshQC/PoshQC.Shard.psm1 +296 -0
  260. package/resources/powershell/PoshQC/PoshQC.Testing.psm1 +48 -32
  261. package/resources/powershell/PoshQC/PoshQC.psd1 +7 -1
  262. package/resources/powershell/PoshQC/PoshQC.psm1 +18 -5
  263. package/resources/powershell/PoshQC/README.md +21 -3
  264. package/resources/powershell/PoshQC/settings/pester.runsettings.psd1 +5 -319
@@ -0,0 +1,373 @@
1
+ <#
2
+ .SYNOPSIS
3
+ Pure feature-folder target resolution shared by the Claude and Codex enforcement hooks
4
+ (issue #565).
5
+
6
+ .DESCRIPTION
7
+ One resolution rule, implemented once and parameterized per gate. A feature folder is
8
+ identified structurally, as the single path segment immediately below
9
+ docs/features/active/, and never by string length or prompt position.
10
+
11
+ - Find-FeatureFolderCandidate extracts the distinct cited folder basenames (R1).
12
+ - ConvertTo-FeatureFolderBasename normalizes a record value or token (R2).
13
+ - Find-FeatureFolderRecord is the union-index record lookup (issue_num or folder).
14
+ - Select-FeatureFolderTarget applies dependency pruning, the declared-issue-number
15
+ tie-break, and the fallback issue number, and reports Resolved, NoTarget, or
16
+ Ambiguous (R3-R6).
17
+ - Resolve-FeatureFolderWorkMode parses the persisted work-mode marker of issue.md.
18
+ - Get-FeatureFolderPlanPrerequisite maps a work mode to its plan prerequisites.
19
+
20
+ The file is byte-identical in .claude/hooks/ and .codex/hooks/ and is dot-sourced by its
21
+ callers, each of which guards the dot-source and fails closed when it cannot be loaded.
22
+
23
+ .NOTES
24
+ Compatible with PowerShell 7+. PURITY: every function is pure string and object logic.
25
+ The file opens no file, probes no path, reads no environment value, launches no process,
26
+ issues no web request, and loads no module. It declares functions only.
27
+ #>
28
+
29
+ function Find-FeatureFolderCandidate {
30
+ <#
31
+ .SYNOPSIS
32
+ Returns the distinct feature-folder basenames cited in a text, in first-occurrence
33
+ order (R1).
34
+ .DESCRIPTION
35
+ Scans for docs/features/active/ path tokens with any prefix and either separator.
36
+ Each token is normalized to forward slashes and split into segments; empty and '.'
37
+ segments are dropped. A token with fewer than four segments yields no candidate.
38
+ The fourth segment is the folder, with trailing '.', ',', ';', ':', ')', ']', '>', '*', and '_' trimmed.
39
+ Duplicates are removed ordinally, keeping the first occurrence.
40
+ .PARAMETER Text
41
+ The prompt or other text to scan. Null or empty text yields no output.
42
+ .OUTPUTS
43
+ System.String[] (no output when no qualifying token is present)
44
+ #>
45
+ [CmdletBinding()]
46
+ [OutputType([string[]])]
47
+ param(
48
+ [AllowNull()]
49
+ [AllowEmptyString()]
50
+ [string] $Text
51
+ )
52
+
53
+ if ([string]::IsNullOrEmpty($Text)) {
54
+ return
55
+ }
56
+
57
+ $found = [System.Collections.Generic.List[string]]::new()
58
+ foreach ($match in [regex]::Matches($Text, 'docs[\\/]+features[\\/]+active[\\/]+[^\s"''`]+')) {
59
+ $segments = @(($match.Value -replace '\\', '/') -split '/' | Where-Object { $_ -and $_ -ne '.' })
60
+ if ($segments.Count -lt 4) {
61
+ continue
62
+ }
63
+ $folder = $segments[3].TrimEnd('.', ',', ';', ':', ')', ']', '>', '*', '_')
64
+ if (-not $folder -or $found.Contains($folder)) {
65
+ continue
66
+ }
67
+ $found.Add($folder)
68
+ }
69
+ return $found.ToArray()
70
+ }
71
+
72
+ function ConvertTo-FeatureFolderBasename {
73
+ <#
74
+ .SYNOPSIS
75
+ Normalizes a feature-folder record value or token to its basename (R2).
76
+ .DESCRIPTION
77
+ Separators are normalized to forward slashes, surrounding whitespace and trailing
78
+ slashes are trimmed, and one leading docs/features/<lifecycle>/, active/, or
79
+ completed/ prefix is stripped. The last remaining segment is returned.
80
+ .PARAMETER Value
81
+ The record value or token to normalize.
82
+ .OUTPUTS
83
+ System.String, or $null when no folder segment remains.
84
+ #>
85
+ [CmdletBinding()]
86
+ [OutputType([string])]
87
+ param(
88
+ [AllowNull()]
89
+ [AllowEmptyString()]
90
+ [string] $Value
91
+ )
92
+
93
+ if ([string]::IsNullOrWhiteSpace($Value)) {
94
+ return $null
95
+ }
96
+ $normalized = ($Value -replace '\\', '/').Trim().TrimEnd('/')
97
+ $normalized = $normalized -replace '^(docs/features/[^/]+(/|$)|active/|completed/)', ''
98
+ $segment = ($normalized -split '/')[-1]
99
+ if (-not $segment -or $segment -eq '.') {
100
+ return $null
101
+ }
102
+ return $segment
103
+ }
104
+
105
+ function Find-FeatureFolderRecord {
106
+ <#
107
+ .SYNOPSIS
108
+ Finds the single record a reference identifies, through a union index of issue_num
109
+ and normalized feature_folder.
110
+ .DESCRIPTION
111
+ A non-string reference, or a string of digits only, matches records whose issue_num
112
+ string form equals it. Any other string matches records whose normalized
113
+ feature_folder basename ordinally equals the reference's normalized basename.
114
+ .PARAMETER Records
115
+ The checkpoint records (features[] or items[]).
116
+ .PARAMETER Reference
117
+ An issue number, a folder basename, or a folder path.
118
+ .OUTPUTS
119
+ The matching record, or $null when zero or several records match.
120
+ #>
121
+ [CmdletBinding()]
122
+ [OutputType([object])]
123
+ param(
124
+ [AllowNull()]
125
+ [AllowEmptyCollection()]
126
+ [object[]] $Records,
127
+
128
+ [AllowNull()]
129
+ [object] $Reference
130
+ )
131
+
132
+ if ($null -eq $Records -or $null -eq $Reference) {
133
+ return $null
134
+ }
135
+
136
+ $byIssue = (-not ($Reference -is [string])) -or ($Reference -match '^\d+$')
137
+ $key = if ($byIssue) { [string]$Reference } else { ConvertTo-FeatureFolderBasename -Value $Reference }
138
+ if (-not $key) {
139
+ return $null
140
+ }
141
+ $field = if ($byIssue) { 'issue_num' } else { 'feature_folder' }
142
+
143
+ $matched = @(foreach ($record in $Records) {
144
+ if ($null -eq $record) {
145
+ continue
146
+ }
147
+ $property = $record.PSObject.Properties[$field]
148
+ if ($null -eq $property -or $null -eq $property.Value) {
149
+ continue
150
+ }
151
+ $value = if ($byIssue) { [string]$property.Value } else { ConvertTo-FeatureFolderBasename -Value ([string]$property.Value) }
152
+ if ($value -ceq $key) {
153
+ $record
154
+ }
155
+ })
156
+ if ($matched.Count -ne 1) {
157
+ return $null
158
+ }
159
+ return $matched[0]
160
+ }
161
+
162
+ function Select-FeatureFolderTarget {
163
+ <#
164
+ .SYNOPSIS
165
+ Selects the target feature folder from the cited candidates and the run records
166
+ (R2-R6).
167
+ .DESCRIPTION
168
+ Each candidate maps to at most one record. Unmatched candidates stay in the set.
169
+ With -DependencyAware, a matched candidate is removed when its record lies in the
170
+ transitive depends_on closure of another cited candidate's record and that record
171
+ does not lie in its own closure, so a cycle removes neither. One remaining candidate
172
+ is Resolved. Several remaining candidates are Resolved only when
173
+ -DeclaredIssueNumber names exactly one remaining record. Zero candidates resolve
174
+ through -FallbackIssueNumber when it names a record. Otherwise the result is
175
+ NoTarget for zero and Ambiguous for several. Neither string length nor candidate
176
+ position affects the status.
177
+ .PARAMETER Records
178
+ The checkpoint records (features[] or items[]).
179
+ .PARAMETER Candidate
180
+ The cited folder basenames, in first-occurrence order.
181
+ .PARAMETER DeclaredIssueNumber
182
+ Optional tie-break from the canonical issue-number line.
183
+ .PARAMETER FallbackIssueNumber
184
+ Optional issue number used only when no candidate is cited.
185
+ .PARAMETER DependencyAware
186
+ Removes cited candidates that are dependencies of another cited candidate.
187
+ .OUTPUTS
188
+ System.Management.Automation.PSCustomObject with Status, Record, Basename,
189
+ Remaining, and Detail.
190
+ #>
191
+ [CmdletBinding()]
192
+ [OutputType([pscustomobject])]
193
+ param(
194
+ [AllowNull()]
195
+ [AllowEmptyCollection()]
196
+ [object[]] $Records,
197
+
198
+ [AllowNull()]
199
+ [AllowEmptyCollection()]
200
+ [string[]] $Candidate,
201
+
202
+ [int] $DeclaredIssueNumber,
203
+
204
+ [int] $FallbackIssueNumber,
205
+
206
+ [switch] $DependencyAware
207
+ )
208
+
209
+ $recordList = @($Records | Where-Object { $null -ne $_ })
210
+ $entries = @(foreach ($name in @($Candidate | Where-Object { -not [string]::IsNullOrWhiteSpace($_) })) {
211
+ [pscustomobject]@{ Basename = $name; Record = Find-FeatureFolderRecord -Records $recordList -Reference $name }
212
+ })
213
+
214
+ if ($DependencyAware -and $entries.Count -gt 1) {
215
+ # Transitive depends_on closure of each matched candidate's record.
216
+ $closures = @(foreach ($entry in $entries) {
217
+ $closure = [System.Collections.Generic.List[object]]::new()
218
+ $pending = [System.Collections.Generic.Stack[object]]::new()
219
+ if ($null -ne $entry.Record) {
220
+ $pending.Push($entry.Record)
221
+ }
222
+ while ($pending.Count -gt 0) {
223
+ $dependsOn = $pending.Pop().PSObject.Properties['depends_on']
224
+ if ($null -eq $dependsOn) {
225
+ continue
226
+ }
227
+ foreach ($reference in @($dependsOn.Value)) {
228
+ $dependency = Find-FeatureFolderRecord -Records $recordList -Reference $reference
229
+ if ($null -ne $dependency -and -not $closure.Contains($dependency)) {
230
+ $closure.Add($dependency)
231
+ $pending.Push($dependency)
232
+ }
233
+ }
234
+ }
235
+ , $closure
236
+ })
237
+
238
+ $kept = for ($i = 0; $i -lt $entries.Count; $i++) {
239
+ $pruned = $false
240
+ for ($j = 0; $j -lt $entries.Count -and $null -ne $entries[$i].Record; $j++) {
241
+ if ($i -eq $j -or $null -eq $entries[$j].Record) {
242
+ continue
243
+ }
244
+ if ($closures[$j].Contains($entries[$i].Record) -and -not $closures[$i].Contains($entries[$j].Record)) {
245
+ $pruned = $true
246
+ break
247
+ }
248
+ }
249
+ if (-not $pruned) {
250
+ $entries[$i]
251
+ }
252
+ }
253
+ $entries = @($kept)
254
+ }
255
+
256
+ $remaining = [string[]]@($entries | ForEach-Object { $_.Basename })
257
+ $selected = $null
258
+ if ($entries.Count -eq 1) {
259
+ $selected = $entries[0]
260
+ }
261
+ elseif ($entries.Count -gt 1 -and $PSBoundParameters.ContainsKey('DeclaredIssueNumber')) {
262
+ $declared = [string]$DeclaredIssueNumber
263
+ $byIssue = @($entries | Where-Object {
264
+ $null -ne $_.Record -and $null -ne $_.Record.PSObject.Properties['issue_num'] -and
265
+ ([string]$_.Record.issue_num) -ceq $declared
266
+ })
267
+ if ($byIssue.Count -eq 1) {
268
+ $selected = $byIssue[0]
269
+ }
270
+ }
271
+ elseif ($entries.Count -eq 0 -and $PSBoundParameters.ContainsKey('FallbackIssueNumber')) {
272
+ $fallback = Find-FeatureFolderRecord -Records $recordList -Reference $FallbackIssueNumber
273
+ if ($null -ne $fallback) {
274
+ $folder = $fallback.PSObject.Properties['feature_folder']
275
+ $basename = if ($null -ne $folder) { ConvertTo-FeatureFolderBasename -Value ([string]$folder.Value) } else { $null }
276
+ $selected = [pscustomobject]@{ Basename = $basename; Record = $fallback }
277
+ }
278
+ }
279
+
280
+ if ($null -ne $selected) {
281
+ return [pscustomobject]@{
282
+ Status = 'Resolved'
283
+ Record = $selected.Record
284
+ Basename = $selected.Basename
285
+ Remaining = $remaining
286
+ Detail = "resolved target feature folder '$($selected.Basename)'"
287
+ }
288
+ }
289
+ if ($entries.Count -eq 0) {
290
+ return [pscustomobject]@{
291
+ Status = 'NoTarget'
292
+ Record = $null
293
+ Basename = $null
294
+ Remaining = $remaining
295
+ Detail = 'no target feature folder is cited'
296
+ }
297
+ }
298
+ return [pscustomobject]@{
299
+ Status = 'Ambiguous'
300
+ Record = $null
301
+ Basename = $null
302
+ Remaining = $remaining
303
+ Detail = 'ambiguous target feature folder; remaining candidates: ' + ($remaining -join ', ')
304
+ }
305
+ }
306
+
307
+ function Resolve-FeatureFolderWorkMode {
308
+ <#
309
+ .SYNOPSIS
310
+ Parses the persisted '- Work Mode:' marker out of issue.md content.
311
+ .DESCRIPTION
312
+ Returns minor-audit, full-bug, or full-feature. The legacy full marker normalizes to
313
+ full-feature. Missing, empty, malformed, or unrecognized content returns
314
+ -UnresolvedMode.
315
+ .PARAMETER IssueContent
316
+ The raw issue.md text, or $null when it could not be read.
317
+ .PARAMETER UnresolvedMode
318
+ The value returned when no recognized marker is present. Defaults to full-feature.
319
+ .OUTPUTS
320
+ System.String
321
+ #>
322
+ [CmdletBinding()]
323
+ [OutputType([string])]
324
+ param(
325
+ [AllowNull()]
326
+ [AllowEmptyString()]
327
+ [string] $IssueContent,
328
+
329
+ [AllowNull()]
330
+ [AllowEmptyString()]
331
+ [string] $UnresolvedMode = 'full-feature'
332
+ )
333
+
334
+ if ([string]::IsNullOrWhiteSpace($IssueContent)) {
335
+ return $UnresolvedMode
336
+ }
337
+ $match = [regex]::Match($IssueContent, '(?im)^-\s*Work Mode:\s*(minor-audit|full-feature|full-bug|full)\s*$')
338
+ if (-not $match.Success) {
339
+ return $UnresolvedMode
340
+ }
341
+ $rawMode = $match.Groups[1].Value
342
+ if ($rawMode -eq 'full') {
343
+ return 'full-feature'
344
+ }
345
+ return $rawMode
346
+ }
347
+
348
+ function Get-FeatureFolderPlanPrerequisite {
349
+ <#
350
+ .SYNOPSIS
351
+ Maps a work mode to the files a feature folder must contain before a plan is written.
352
+ .DESCRIPTION
353
+ minor-audit requires issue.md; full-bug requires issue.md and spec.md; full-feature
354
+ and every other value require issue.md, spec.md, and user-story.md.
355
+ .PARAMETER WorkMode
356
+ The resolved work mode.
357
+ .OUTPUTS
358
+ System.String[]
359
+ #>
360
+ [CmdletBinding()]
361
+ [OutputType([string[]])]
362
+ param(
363
+ [AllowNull()]
364
+ [AllowEmptyString()]
365
+ [string] $WorkMode
366
+ )
367
+
368
+ switch ($WorkMode) {
369
+ 'minor-audit' { return [string[]]@('issue.md') }
370
+ 'full-bug' { return [string[]]@('issue.md', 'spec.md') }
371
+ default { return [string[]]@('issue.md', 'spec.md', 'user-story.md') }
372
+ }
373
+ }
@@ -0,0 +1,85 @@
1
+ <#
2
+ .SYNOPSIS
3
+ Resolve the coverage thresholds that govern the feature-review coverage validation.
4
+ .DESCRIPTION
5
+ Implements the threshold precedence of the pushed quality-tiers rule for the
6
+ feature-review SubagentStop hook (issue #824, follow-up FU-823-1). When the
7
+ repository's root CLAUDE.md states a line or branch coverage threshold, that threshold
8
+ governs; otherwise the default governs (85 percent line, 75 percent branch). Each
9
+ metric is resolved on its own, so a root CLAUDE.md that states only a line threshold
10
+ leaves the branch default in force.
11
+
12
+ Pure string logic only: the caller supplies the CLAUDE.md text. No disk, process,
13
+ network, clock, or environment access. It is dot-sourced by
14
+ validate-feature-review-coverage.ps1 as:
15
+ . (Join-Path $PSScriptRoot 'feature-review-coverage-thresholds.ps1')
16
+ #>
17
+
18
+
19
+ function Get-FeatureReviewCoverageThreshold {
20
+ <#
21
+ .SYNOPSIS
22
+ Return the governing line and branch coverage thresholds for a root CLAUDE.md text.
23
+ .DESCRIPTION
24
+ For each metric M in 'line' and 'branch', a figure is read only when a comparator
25
+ or floor phrase links it to the metric on the same line as 'M coverage'. Two forms
26
+ are accepted, and any text without a percent sign may sit between 'M coverage' and
27
+ the comparator or the figure:
28
+
29
+ - Comparator before the figure: one of '>=', the U+2265 sign, 'at least',
30
+ 'minimum', 'minimum of', or 'no less than', an optional colon, and the figure
31
+ followed by a percent sign (for example 'line coverage >= 85%').
32
+ - Trailing floor phrase after the figure: the figure followed by a percent sign,
33
+ then one of 'minimum', 'at least', 'or more', 'or higher', 'or above', or
34
+ 'or greater' (for example 'line coverage: 70% minimum').
35
+
36
+ Prose such as 'line coverage was 62% last release' is not read. The first match in
37
+ text order across both forms whose value parses (invariant culture) to a number
38
+ from 0 to 100 sets that metric and its source to 'claude-md'. Otherwise the metric
39
+ keeps its default (line 85, branch 75) and its source is 'default'.
40
+
41
+ Known limitation: a combined statement such as 'line and branch coverage >= 70%'
42
+ matches neither metric, because the metric name must be followed directly by
43
+ 'coverage' and must not be joined to the other metric name by 'and', 'or', '&',
44
+ or '/'. Both metrics then keep their defaults, which is the stricter direction.
45
+ .PARAMETER ClaudeMdText
46
+ The text of the repository's root CLAUDE.md; $null or empty when it is absent.
47
+ .OUTPUTS
48
+ System.Management.Automation.PSCustomObject - Line, Branch, LineSource, BranchSource.
49
+ #>
50
+ [CmdletBinding()]
51
+ [OutputType([pscustomobject])]
52
+ param(
53
+ [Parameter(Mandatory)][AllowNull()][AllowEmptyString()][string] $ClaudeMdText
54
+ )
55
+
56
+ $defaults = [ordered]@{ line = 85.0; branch = 75.0 }
57
+ $resolved = @{}
58
+ $culture = [System.Globalization.CultureInfo]::InvariantCulture
59
+ $style = [System.Globalization.NumberStyles]::Float
60
+
61
+ foreach ($metric in $defaults.Keys) {
62
+ $value = [double]$defaults[$metric]
63
+ $source = 'default'
64
+ if (-not [string]::IsNullOrEmpty($ClaudeMdText)) {
65
+ $pattern = '(?im)(?<!\b(?:line|branch)\s*(?:and|or|&|/)\s*)\b' + $metric + '\s+coverage\b[^\r\n%]*?(?:(?:>=|' + [char]0x2265 + '|\bat\s+least\b|\bminimum(?:\s+of)?\b|\bno\s+less\s+than\b)\s*:?\s*(?<![\d.])(?<pct>\d{1,3}(?:\.\d+)?)\s*%|(?<![\d.])(?<pct>\d{1,3}(?:\.\d+)?)\s*%\s*(?:minimum|at\s+least|or\s+(?:more|higher|above|greater))\b)'
66
+ foreach ($match in [regex]::Matches($ClaudeMdText, $pattern)) {
67
+ $parsed = 0.0
68
+ $isNumber = [double]::TryParse($match.Groups['pct'].Value, $style, $culture, [ref]$parsed)
69
+ if ($isNumber -and $parsed -ge 0 -and $parsed -le 100) {
70
+ $value = $parsed
71
+ $source = 'claude-md'
72
+ break
73
+ }
74
+ }
75
+ }
76
+ $resolved[$metric] = [pscustomobject]@{ Value = $value; Source = $source }
77
+ }
78
+
79
+ return [pscustomobject]@{
80
+ Line = $resolved['line'].Value
81
+ Branch = $resolved['branch'].Value
82
+ LineSource = $resolved['line'].Source
83
+ BranchSource = $resolved['branch'].Source
84
+ }
85
+ }
@@ -0,0 +1,119 @@
1
+ <#
2
+ .SYNOPSIS
3
+ Heredoc header and body readers for the Bash command-line segment scanner.
4
+ .DESCRIPTION
5
+ Holds Read-CommandLineHeredocHeader and Read-CommandLineHeredocBody, moved verbatim
6
+ from hook-command-scanner.ps1 (issue #824) so the scanner stays under the 500-line
7
+ limit once it records each segment's Delimiter and TokenText. The functions read
8
+ $script:CommandLineSegmentDelimiters, which the scanner declares before it
9
+ dot-sources this file.
10
+
11
+ Pure string logic only: no disk, process, network, clock, or environment access. It is
12
+ dot-sourced by hook-command-scanner.ps1 as:
13
+ . (Join-Path $PSScriptRoot 'hook-command-heredoc.ps1')
14
+ #>
15
+
16
+ function Read-CommandLineHeredocHeader {
17
+ <#
18
+ .SYNOPSIS
19
+ Read a heredoc header beginning at a '<<' operator and report its delimiter.
20
+ .DESCRIPTION
21
+ Handles the plain '<<' form, the tab-stripping '<<-' form, and an optionally quoted
22
+ delimiter word. A delimiter produced by expansion is reported as non-literal, which
23
+ makes the segment unresolvable under R3. Returns NextIndex, Delimiter, StripTabs,
24
+ and IsLiteral.
25
+ .OUTPUTS
26
+ System.Management.Automation.PSCustomObject
27
+ #>
28
+ [CmdletBinding()]
29
+ [OutputType([pscustomobject])]
30
+ param(
31
+ [Parameter(Mandatory)][string] $Text,
32
+ [Parameter(Mandatory)][int] $StartIndex
33
+ )
34
+
35
+ $cursor = $StartIndex + 2
36
+ $stripTabs = $false
37
+ if ($cursor -lt $Text.Length -and $Text[$cursor] -eq '-') {
38
+ $stripTabs = $true
39
+ $cursor++
40
+ }
41
+
42
+ while ($cursor -lt $Text.Length -and ($Text[$cursor] -eq ' ' -or $Text[$cursor] -eq "`t")) { $cursor++ }
43
+
44
+ $word = [System.Text.StringBuilder]::new()
45
+ $isLiteral = $true
46
+ $openQuote = [char]0
47
+ while ($cursor -lt $Text.Length) {
48
+ $character = $Text[$cursor]
49
+ if ($openQuote -ne [char]0) {
50
+ if ($character -eq $openQuote) {
51
+ $openQuote = [char]0
52
+ } else {
53
+ if ($openQuote -eq '"' -and ($character -eq '$' -or $character -eq '`')) { $isLiteral = $false }
54
+ [void]$word.Append($character)
55
+ }
56
+ $cursor++
57
+ continue
58
+ }
59
+
60
+ if ($character -eq '"' -or $character -eq "'") {
61
+ $openQuote = $character
62
+ $cursor++
63
+ continue
64
+ }
65
+
66
+ if ([char]::IsWhiteSpace($character) -or $script:CommandLineSegmentDelimiters -contains $character) { break }
67
+ if ($character -eq '$' -or $character -eq '`') { $isLiteral = $false }
68
+ [void]$word.Append($character)
69
+ $cursor++
70
+ }
71
+
72
+ $delimiter = $word.ToString()
73
+ if ($openQuote -ne [char]0 -or [string]::IsNullOrEmpty($delimiter)) { $isLiteral = $false }
74
+
75
+ return [pscustomobject]@{
76
+ NextIndex = $cursor
77
+ Delimiter = $delimiter
78
+ StripTabs = $stripTabs
79
+ IsLiteral = $isLiteral
80
+ }
81
+ }
82
+
83
+ function Read-CommandLineHeredocBody {
84
+ <#
85
+ .SYNOPSIS
86
+ Consume one heredoc body from a start index and report where it ends.
87
+ .DESCRIPTION
88
+ Consumes lines until a line whose content - after optional leading tabs for the
89
+ '<<-' form - equals the delimiter exactly, case-sensitively as in the shell. An
90
+ unterminated body is consumed to end of text and reported through Unbalanced.
91
+ .OUTPUTS
92
+ System.Management.Automation.PSCustomObject
93
+ #>
94
+ [CmdletBinding()]
95
+ [OutputType([pscustomobject])]
96
+ param(
97
+ [Parameter(Mandatory)][string] $Text,
98
+ [Parameter(Mandatory)][int] $StartIndex,
99
+ [Parameter(Mandatory)][AllowEmptyString()][string] $Delimiter,
100
+ [Parameter(Mandatory)][bool] $StripTabs
101
+ )
102
+
103
+ $cursor = $StartIndex
104
+ $length = $Text.Length
105
+ while ($cursor -lt $length) {
106
+ $lineEnd = $Text.IndexOf("`n", $cursor)
107
+ if ($lineEnd -lt 0) { $lineEnd = $length }
108
+
109
+ $line = $Text.Substring($cursor, $lineEnd - $cursor).TrimEnd("`r")
110
+ if ($StripTabs) { $line = $line.TrimStart("`t") }
111
+
112
+ $cursor = if ($lineEnd -lt $length) { $lineEnd + 1 } else { $length }
113
+ if ($line -ceq $Delimiter) {
114
+ return [pscustomobject]@{ NextIndex = $cursor; Terminated = $true }
115
+ }
116
+ }
117
+
118
+ return [pscustomobject]@{ NextIndex = $length; Terminated = $false }
119
+ }