@danmoisan/drm-copilot-mcp 1.1.12 → 1.1.15

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 (38) hide show
  1. package/out/mcp-server.js +30 -78
  2. package/package.json +2 -2
  3. package/resources/claude-customizations/.claude/agents/parallel-planner.md +18 -1
  4. package/resources/claude-customizations/.claude/hooks/enforce-completion-consistency.ps1 +16 -8
  5. package/resources/claude-customizations/.claude/hooks/enforce-orchestration-preimplementation-gate-helpers.ps1 +27 -27
  6. package/resources/claude-customizations/.claude/lib/blast-radius/BlastRadius.psm1 +43 -6
  7. package/resources/claude-customizations/.claude/lib/blast-radius/BlastRadiusScheduling.psm1 +486 -0
  8. package/resources/claude-customizations/.claude/lib/blast-radius/BlastRadiusValidation.psm1 +5 -2
  9. package/resources/claude-customizations/.claude/lib/blast-radius/BlastRadiusWriteIntent.psm1 +446 -0
  10. package/resources/claude-customizations/.claude/lib/ci-gate/Invoke-CiGateParser.ps1 +330 -0
  11. package/resources/claude-customizations/.claude/rules/parallel-orchestration.md +150 -2
  12. package/resources/claude-customizations/.claude/rules/plan-acceptance-gates.md +5 -5
  13. package/resources/claude-customizations/.claude/rules/shell.md +8 -7
  14. package/resources/claude-customizations/.claude/skills/cleanup-merged-worktrees/SKILL.md +8 -8
  15. package/resources/claude-customizations/.claude/skills/cleanup-merged-worktrees/scripts/cleanup-worktrees.sh +234 -0
  16. package/resources/claude-customizations/.claude/skills/cleanup-merged-worktrees/scripts/cleanup_worktrees_actions_lib.sh +451 -0
  17. package/resources/claude-customizations/.claude/skills/cleanup-merged-worktrees/scripts/cleanup_worktrees_detached_lib.sh +301 -0
  18. package/resources/claude-customizations/.claude/skills/cleanup-merged-worktrees/scripts/cleanup_worktrees_dirt_lib.sh +495 -0
  19. package/resources/claude-customizations/.claude/skills/cleanup-merged-worktrees/scripts/cleanup_worktrees_enumerate_lib.sh +252 -0
  20. package/resources/claude-customizations/.claude/skills/cleanup-merged-worktrees/scripts/cleanup_worktrees_lib.sh +496 -0
  21. package/resources/claude-customizations/.claude/skills/cleanup-merged-worktrees/scripts/cleanup_worktrees_preserve_eol_lib.sh +212 -0
  22. package/resources/claude-customizations/.claude/skills/cleanup-merged-worktrees/scripts/cleanup_worktrees_preserve_lib.sh +492 -0
  23. package/resources/claude-customizations/.claude/skills/cleanup-merged-worktrees/scripts/cleanup_worktrees_report_records_lib.sh +476 -0
  24. package/resources/claude-customizations/.claude/skills/cleanup-merged-worktrees/scripts/cleanup_worktrees_scan_helper.sh +182 -0
  25. package/resources/claude-customizations/.claude/skills/epic-orchestrate/SKILL.md +1 -1
  26. package/resources/claude-customizations/.claude/skills/epic-plan/SKILL.md +11 -0
  27. package/resources/claude-customizations/.claude/skills/orchestrate/SKILL.md +1 -1
  28. package/resources/claude-customizations/.claude/skills/parallel-add/SKILL.md +32 -17
  29. package/resources/claude-customizations/.claude/skills/parallel-plan/SKILL.md +39 -10
  30. package/resources/claude-customizations/config/blast-radius.json +14 -1
  31. package/resources/claude-customizations/pack-manifests/core.json +13 -0
  32. package/resources/codex-and-agents-customizations/.codex/config.toml +1 -1
  33. package/resources/codex-and-agents-customizations/.codex/hooks/enforce-orchestration-preimplementation-gate-epic-resolution.ps1 +493 -0
  34. package/resources/codex-and-agents-customizations/.codex/hooks/enforce-orchestration-preimplementation-gate-epic-scope.ps1 +189 -0
  35. package/resources/codex-and-agents-customizations/.codex/hooks/enforce-orchestration-preimplementation-gate-helpers.ps1 +27 -27
  36. package/resources/codex-and-agents-customizations/.codex/hooks/enforce-orchestration-preimplementation-gate.ps1 +14 -27
  37. package/resources/codex-and-agents-customizations/pack-manifests/core.json +2 -0
  38. package/resources/powershell/PoshQC/settings/pester.runsettings.psd1 +16 -0
@@ -0,0 +1,234 @@
1
+ #!/usr/bin/env bash
2
+ # cleanup-worktrees.sh: thin CLI wrapper for the cleanup-merged-worktrees tool. It
3
+ # classifies local branches/worktrees against main and, in apply mode only, deletes
4
+ # delete-eligible candidates and drives consolidation. All logic lives in the two
5
+ # sourceable libraries so the functions are unit-testable from bats by sourcing them
6
+ # directly; this wrapper only resolves paths, prints usage, and dispatches.
7
+ set -euo pipefail
8
+
9
+ # Resolve this script's own directory so the libraries source regardless of cwd.
10
+ SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
11
+ # The library paths are resolved at runtime from SCRIPT_DIR, so shellcheck cannot load
12
+ # them as static inputs without -x; SC1091 is the expected, benign result. The
13
+ # enumeration/protection library is sourced first because cleanup_worktrees_lib.sh's
14
+ # classification functions call cleanup_wt_git, parse_worktree_list, compute_protected,
15
+ # and normalize_wt_path defined there.
16
+ # shellcheck source=.claude/skills/cleanup-merged-worktrees/scripts/cleanup_worktrees_enumerate_lib.sh
17
+ # shellcheck disable=SC1091
18
+ source "$SCRIPT_DIR/cleanup_worktrees_enumerate_lib.sh"
19
+ # The report-record library depends on the enumeration library above and is called BY
20
+ # run_report/run_apply in the two libraries sourced below, so it is sourced between them.
21
+ # shellcheck source=.claude/skills/cleanup-merged-worktrees/scripts/cleanup_worktrees_report_records_lib.sh
22
+ # shellcheck disable=SC1091
23
+ source "$SCRIPT_DIR/cleanup_worktrees_report_records_lib.sh"
24
+ # shellcheck source=.claude/skills/cleanup-merged-worktrees/scripts/cleanup_worktrees_lib.sh
25
+ # shellcheck disable=SC1091
26
+ source "$SCRIPT_DIR/cleanup_worktrees_lib.sh"
27
+ # shellcheck source=.claude/skills/cleanup-merged-worktrees/scripts/cleanup_worktrees_actions_lib.sh
28
+ # shellcheck disable=SC1091
29
+ source "$SCRIPT_DIR/cleanup_worktrees_actions_lib.sh"
30
+ # shellcheck source=.claude/skills/cleanup-merged-worktrees/scripts/cleanup_worktrees_detached_lib.sh
31
+ # shellcheck disable=SC1091
32
+ source "$SCRIPT_DIR/cleanup_worktrees_detached_lib.sh"
33
+ # Neither of the three libraries below requires being sourced last, and neither claims to
34
+ # be. Each library's source-time work is limited to function definitions plus constant and
35
+ # environment-default variable assignments; none of them calls a function while being
36
+ # sourced, and no function name is defined by more than one library, so no later source can
37
+ # shadow an earlier definition. Bash resolves a function name when the call runs, not when
38
+ # the caller is defined, so the cross-library calls resolve whatever the order: the
39
+ # disposable-dirt classifier is called BY run_report and BY delete_candidate in the
40
+ # libraries above, and the preserve library calls cleanup_wt_git from the enumeration
41
+ # library and consolidation_worktree_path from the actions library. The order here is
42
+ # therefore grouping for readability only.
43
+ # shellcheck source=.claude/skills/cleanup-merged-worktrees/scripts/cleanup_worktrees_dirt_lib.sh
44
+ # shellcheck disable=SC1091
45
+ source "$SCRIPT_DIR/cleanup_worktrees_dirt_lib.sh"
46
+ # The line-ending and index group is placed immediately before the preserve library, whose
47
+ # read-only planning phase calls the functions it defines.
48
+ # shellcheck source=.claude/skills/cleanup-merged-worktrees/scripts/cleanup_worktrees_preserve_eol_lib.sh
49
+ # shellcheck disable=SC1091
50
+ source "$SCRIPT_DIR/cleanup_worktrees_preserve_eol_lib.sh"
51
+ # shellcheck source=.claude/skills/cleanup-merged-worktrees/scripts/cleanup_worktrees_preserve_lib.sh
52
+ # shellcheck disable=SC1091
53
+ source "$SCRIPT_DIR/cleanup_worktrees_preserve_lib.sh"
54
+
55
+ usage() {
56
+ # Print the wrapper usage/help text.
57
+ cat <<'EOF'
58
+ Usage: cleanup-worktrees.sh [command]
59
+
60
+ Commands:
61
+ (no args) | report Dry-run report (default). Classifies every local branch and
62
+ worktree against main and prints a deterministic, machine-
63
+ parseable report. Performs NO mutation of any kind.
64
+ --apply | apply Apply mode. Deletes delete-eligible candidates (MERGED_CLEAN,
65
+ MERGED_CONTENT_NEUTRAL, MERGED_EQUIVALENT) after same-process
66
+ re-verification, removing worktrees without force and deleting
67
+ branches with -D. Never acts on NOT_MERGED,
68
+ HAS_UNIQUE_RESIDUALS, or PROTECTED_CURRENT candidates.
69
+ preserve | --preserve
70
+ Stage the manifest's preserved_files[] findings onto the
71
+ consolidation branch. Takes no operand; the manifest path comes
72
+ from CLEANUP_WT_MANIFEST_PATH. Copies each named source file
73
+ verbatim, carries its MEMORY.md index line across using the
74
+ destination file's own re-derived line-ending convention, and
75
+ refuses the whole pass when the incoming bytes carry a
76
+ host-identifying token. Exit 0 clean, 1 something was skipped or
77
+ an index was created, 3 host-token hard stop, 127 a required tool
78
+ could not be resolved.
79
+ --help | -h | help Print this help and exit 0.
80
+
81
+ Flags:
82
+ --clear-disposable Apply mode only, opt-in, and destructive. When a worktree removal
83
+ is blocked because the worktree is dirty, and every per-file
84
+ verdict for that worktree is disposable, the working tree is
85
+ cleared with reset --hard and clean -fd and the SAME unforced
86
+ removal is retried once after a fresh in-process re-verification.
87
+ Refuses the clear for the whole worktree when any per-file verdict
88
+ is UNIQUE, including the fail-closed UNIQUE assigned when a
89
+ classification read errors. Ignored files are never cleared. This
90
+ flag may be given before or after the apply argument; supplying it
91
+ without apply mode is a usage error and exits 2.
92
+
93
+ Report lines (pipe-delimited, LC_ALL=C ordered): BRANCH|<name>|<state>;
94
+ COMMIT|<branch>|<sha>|<state>|<paths>|<author>|<date>;
95
+ WORKTREE|<path>|<branch>|<flags> for a branch-backed worktree registration;
96
+ WORKTREE|<path>|DETACHED|<state>|<flags> for a detached-HEAD worktree registration,
97
+ which is classified on its own HEAD SHA and whose fifth field preserves the porcelain
98
+ locked and prunable markers; WARN|main-divergence|<local>|<origin>;
99
+ DIRTY|<path>|<status>; ACTION|<verb>|<target>|<result> (apply mode);
100
+ DIRTFILE|<worktree>|<verdict>|<detail>|<xy>|<path>, one per dirty entry in porcelain order;
101
+ DIRTSUM|<worktree>|<aggregate>|<detail>, exactly one per dirty worktree. The verdicts are
102
+ DISPOSABLE_BUILD_ARTIFACT, DISPOSABLE_SESSION_ARTIFACT, CONTENT_ON_MAIN, CONTENT_IN_HISTORY,
103
+ STAGED_TREE_IS_COMMIT, and UNIQUE; the aggregate is ALL_DISPOSABLE or HAS_UNIQUE. Both are
104
+ read-only records and neither unlocks a destructive action on its own.
105
+
106
+ PRESERVE|<worktree-path>|<source-path>|<verdict> (preserve mode), a manifest
107
+ preserved_files[] finding staged onto the consolidation branch, whose per-file outcome is
108
+ reported by the companion ACTION|preserve-stage|... record.
109
+
110
+ Advisory, read-only records (report and apply mode; none unlocks a destructive action):
111
+ ORPHAN_DIR|<path>|<size> for a scanned directory with no .git pointer file and no
112
+ worktree registration, where <size> is best-effort and may be the literal unknown;
113
+ STALE_REF|<refname> for a refs/remotes/<name>/* ref whose <name> is not a configured
114
+ remote, in full ref form; CHILD_OF|<branch>|<ancestor> emitted alongside a branch's own
115
+ BRANCH| line when it is a git ancestor of a branch that resolved exactly NOT_MERGED;
116
+ WARN|registration-lost|<path> for a worktree whose .git gitdir pointer no longer
117
+ resolves. Deleting any of these is a manual, individually confirmed action.
118
+
119
+ Branch and detached-worktree states: MERGED_CLEAN, MERGED_CONTENT_NEUTRAL,
120
+ MERGED_EQUIVALENT, NOT_MERGED, HAS_UNIQUE_RESIDUALS, PROTECTED_CURRENT, and
121
+ ANCESTRY_ERROR. The first three are the delete-eligible allowlist; ANCESTRY_ERROR is a
122
+ hard git failure and never unlocks a destructive action.
123
+
124
+ PROTECTED_CURRENT also covers the base branch main, which is protected by name in every
125
+ checkout topology: main is never deleted and a worktree checked out on main is never
126
+ removed. As a second guard, apply mode refuses a deletion request for main with the
127
+ action result BLOCKED-PROTECTED-BASE.
128
+
129
+ In apply mode a blocked detached removal sets a non-zero exit status. The blocked results
130
+ are BLOCKED-DIRTY, BLOCKED-LOCKED, and BLOCKED-REVERIFY. A checkout holding dirty or
131
+ locked detached worktrees therefore exits non-zero from --apply where it previously
132
+ exited 0.
133
+
134
+ Environment overrides:
135
+ CLEANUP_WT_GIT_BIN Path to the git binary; an empty or nonexistent value
136
+ is treated as missing (falls back to PATH git). This is
137
+ the test-stub seam.
138
+ CLEANUP_WT_SCAN_BIN Path to the filesystem-scan helper; an empty or
139
+ nonexistent value is treated as missing (falls back to
140
+ the bundled cleanup_worktrees_scan_helper.sh). This is
141
+ the filesystem-scan test-stub seam.
142
+ CLEANUP_WT_ORPHAN_ROOTS Colon-separated override for the worktree-tracking roots
143
+ scanned for ORPHAN_DIR and WARN|registration-lost.
144
+ CLEANUP_WT_STUB_SCENARIO Scenario directory consumed by the checked-in git and
145
+ scan stubs (tests only).
146
+ CLEANUP_WT_CONSOLIDATION_PATH Override the derived consolidation worktree path
147
+ (<main-worktree-path>-wt/documentationandmemories).
148
+ CLEANUP_WT_MANIFEST_PATH Path to the cleanup-worktrees manifest read by preserve
149
+ mode. Defaults to
150
+ artifacts/orchestration/cleanup-worktrees-manifest.json.
151
+ CLEANUP_WT_JQ_BIN Path to the jq binary used to read that manifest; an empty
152
+ or nonexistent value is treated as missing (falls back to
153
+ PATH jq). No default. This is the jq test-stub seam.
154
+ EOF
155
+ }
156
+
157
+ main() {
158
+ # Dispatch on the first argument. No args or `report` runs the dry-run report;
159
+ # `--apply`/`apply` runs apply mode; `preserve`/`--preserve` stages the manifest's
160
+ # preserved_files[] findings onto the consolidation branch and takes no operand,
161
+ # reading its manifest path from CLEANUP_WT_MANIFEST_PATH; `--help`/`-h`/`help`
162
+ # prints usage and exits 0;
163
+ # anything else prints usage to stderr and exits 2 (usage-error parity with
164
+ # shell-qc.sh). Subcommand return codes are captured so an intermediate failure is
165
+ # never masked before the final exit.
166
+ local exit_code=0
167
+ # --clear-disposable pre-pass, run before the dispatch below so the flag may be given
168
+ # on either side of the mode argument. The flag is stripped from the argument list and
169
+ # the remaining first argument must select apply mode: the flag is opt-in and
170
+ # destructive, so pairing it with report mode (or with no mode at all) is a usage error
171
+ # rather than a silently ignored flag. Every case arm below is unchanged.
172
+ local -a args=()
173
+ local clear_flag=0 arg
174
+ for arg in "$@"; do
175
+ if [[ $arg == "--clear-disposable" ]]; then
176
+ clear_flag=1
177
+ continue
178
+ fi
179
+ args+=("$arg")
180
+ done
181
+ if ((clear_flag == 1)); then
182
+ case "${args[0]:-}" in
183
+ --apply | apply) ;;
184
+ *)
185
+ usage >&2
186
+ return 2
187
+ ;;
188
+ esac
189
+ # Read across a source boundary shellcheck does not follow:
190
+ # cleanup_worktrees_dirt_lib.sh gates clear_disposable_dirt on this variable and
191
+ # cleanup_worktrees_actions_lib.sh gates delete_candidate's clear-and-retry block
192
+ # on it, so SC2034 reports it unused here. The suppression below is line-scoped,
193
+ # not file-scoped, so SC2034 stays live for every other variable in this file.
194
+ # The assignment's effect is pinned end to end by the wrapper-driven test pair at
195
+ # the foot of tests/shell/test_cleanup_worktrees_dirt_clear.bats.
196
+ # shellcheck disable=SC2034
197
+ CLEANUP_WT_CLEAR_DISPOSABLE=1
198
+ fi
199
+ if ((${#args[@]} > 0)); then
200
+ set -- "${args[@]}"
201
+ else
202
+ set --
203
+ fi
204
+ local command=${1:-}
205
+ case "$command" in
206
+ "" | report)
207
+ run_report || exit_code=$?
208
+ ;;
209
+ --apply | apply)
210
+ run_apply || exit_code=$?
211
+ ;;
212
+ preserve | --preserve)
213
+ run_preserve || exit_code=$?
214
+ ;;
215
+ --help | -h | help)
216
+ usage
217
+ return 0
218
+ ;;
219
+ *)
220
+ usage >&2
221
+ return 2
222
+ ;;
223
+ esac
224
+ return "$exit_code"
225
+ }
226
+
227
+ # Guard so the file can be sourced without executing main. main's return code is
228
+ # captured and re-exited explicitly as the final statement, so intermediate
229
+ # `|| rc=$?` captures inside the libraries cannot mask a real failure.
230
+ if [[ ${BASH_SOURCE[0]} == "${0}" ]]; then
231
+ rc=0
232
+ main "$@" || rc=$?
233
+ exit "$rc"
234
+ fi