@hybridlabor-api/aos 4.8.0 → 4.9.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 (166) hide show
  1. package/.agents/agents.md +1 -1
  2. package/.agents/nodes.json +1 -1
  3. package/.agents/vendor-manifest.json +23 -1
  4. package/.claude/agents/godmode-media-eventtech.md +1 -1
  5. package/.claude/hooks/conventional-commits.mjs +125 -0
  6. package/.claude/hooks/env-file-protection.mjs +105 -0
  7. package/.claude/hooks/go-gate.mjs +101 -81
  8. package/.claude/settings.json +13 -0
  9. package/.opencode/agents/godmode-media-eventtech.md +1 -1
  10. package/.opencode/plugins/bdb-aos.js +31 -4
  11. package/README.de.md +1 -1
  12. package/README.md +1 -1
  13. package/README.pt.md +1 -1
  14. package/THIRD_PARTY_NOTICES.md +88 -0
  15. package/docs/skills_table.md +1 -1
  16. package/installer.js +174 -46
  17. package/package.json +6 -2
  18. package/packages/aos-cli/README.md +80 -0
  19. package/packages/aos-cli/bin/aos-cli.mjs +134 -0
  20. package/packages/aos-cli/core-skills.json +12 -0
  21. package/packages/aos-cli/extensions/aos.ts +321 -0
  22. package/packages/aos-cli/package-lock.json +1923 -0
  23. package/packages/aos-cli/package.json +29 -0
  24. package/packages/aos-cli/scripts/check-theme.mjs +63 -0
  25. package/packages/aos-cli/themes/aos.json +97 -0
  26. package/scripts/build-plugin-manifest.mjs +131 -0
  27. package/scripts/validate-skills.mjs +81 -6
  28. package/skills/basic/ao-orchestrator/SKILL.md +116 -0
  29. package/skills/global_config/agenttrail/SKILL.md +6 -1
  30. package/skills/global_config/ask-tim/SKILL.md +4 -4
  31. package/skills/global_config/bash-script-generator/SKILL.md +201 -0
  32. package/skills/global_config/bash-script-generator/assets/templates/standard-template.sh +96 -0
  33. package/skills/global_config/bash-script-generator/docs/bash-scripting-guide.md +729 -0
  34. package/skills/global_config/bash-script-generator/docs/generation-best-practices.md +193 -0
  35. package/skills/global_config/bash-script-generator/docs/script-patterns.md +566 -0
  36. package/skills/global_config/bash-script-generator/docs/text-processing-guide.md +437 -0
  37. package/skills/global_config/bash-script-generator/examples/log-analyzer.sh +92 -0
  38. package/skills/global_config/bash-script-generator/scripts/generate_script_template.sh +123 -0
  39. package/skills/global_config/bash-script-generator/scripts/run_ci_checks.sh +172 -0
  40. package/skills/global_config/bash-script-generator/scripts/test_generator.sh +413 -0
  41. package/skills/global_config/bash-script-validator/SKILL.md +249 -0
  42. package/skills/global_config/bash-script-validator/docs/awk-reference.md +449 -0
  43. package/skills/global_config/bash-script-validator/docs/bash-reference.md +468 -0
  44. package/skills/global_config/bash-script-validator/docs/common-mistakes.md +623 -0
  45. package/skills/global_config/bash-script-validator/docs/grep-reference.md +395 -0
  46. package/skills/global_config/bash-script-validator/docs/regex-reference.md +391 -0
  47. package/skills/global_config/bash-script-validator/docs/sed-reference.md +454 -0
  48. package/skills/global_config/bash-script-validator/docs/shell-reference.md +463 -0
  49. package/skills/global_config/bash-script-validator/docs/shellcheck-reference.md +399 -0
  50. package/skills/global_config/bash-script-validator/examples/bad-bash.sh +55 -0
  51. package/skills/global_config/bash-script-validator/examples/bad-shell.sh +54 -0
  52. package/skills/global_config/bash-script-validator/examples/good-bash.sh +71 -0
  53. package/skills/global_config/bash-script-validator/examples/good-shell.sh +69 -0
  54. package/skills/global_config/bash-script-validator/scripts/run_ci_checks.sh +23 -0
  55. package/skills/global_config/bash-script-validator/scripts/shellcheck_wrapper.sh +174 -0
  56. package/skills/global_config/bash-script-validator/scripts/test_validate.sh +446 -0
  57. package/skills/global_config/bash-script-validator/scripts/validate.sh +512 -0
  58. package/skills/global_config/ci-pipeline/SKILL.md +135 -0
  59. package/skills/global_config/dispatching-parallel-agents/SKILL.md +170 -0
  60. package/skills/global_config/dockerfile-generator/SKILL.md +1038 -0
  61. package/skills/global_config/dockerfile-generator/examples/example.dockerignore +95 -0
  62. package/skills/global_config/dockerfile-generator/examples/golang-distroless.Dockerfile +34 -0
  63. package/skills/global_config/dockerfile-generator/examples/java-springboot.Dockerfile +45 -0
  64. package/skills/global_config/dockerfile-generator/examples/nextjs-production.Dockerfile +49 -0
  65. package/skills/global_config/dockerfile-generator/examples/nodejs-multistage.Dockerfile +55 -0
  66. package/skills/global_config/dockerfile-generator/examples/python-fastapi.Dockerfile +48 -0
  67. package/skills/global_config/dockerfile-generator/references/language_specific_guides.md +510 -0
  68. package/skills/global_config/dockerfile-generator/references/multistage_builds.md +570 -0
  69. package/skills/global_config/dockerfile-generator/references/optimization_patterns.md +492 -0
  70. package/skills/global_config/dockerfile-generator/references/security_best_practices.md +375 -0
  71. package/skills/global_config/dockerfile-generator/scripts/generate_dockerignore.sh +199 -0
  72. package/skills/global_config/dockerfile-generator/scripts/generate_golang.sh +172 -0
  73. package/skills/global_config/dockerfile-generator/scripts/generate_java.sh +185 -0
  74. package/skills/global_config/dockerfile-generator/scripts/generate_nodejs.sh +279 -0
  75. package/skills/global_config/dockerfile-generator/scripts/generate_python.sh +218 -0
  76. package/skills/global_config/dockerfile-generator/scripts/test_generator.sh +210 -0
  77. package/skills/global_config/dockerfile-validator/SKILL.md +300 -0
  78. package/skills/global_config/dockerfile-validator/examples/.dockerignore.example +34 -0
  79. package/skills/global_config/dockerfile-validator/examples/bad-example.Dockerfile +37 -0
  80. package/skills/global_config/dockerfile-validator/examples/golang-distroless.Dockerfile +50 -0
  81. package/skills/global_config/dockerfile-validator/examples/good-example.Dockerfile +52 -0
  82. package/skills/global_config/dockerfile-validator/examples/python-optimized.Dockerfile +53 -0
  83. package/skills/global_config/dockerfile-validator/examples/security-issues.Dockerfile +42 -0
  84. package/skills/global_config/dockerfile-validator/references/docker_best_practices.md +348 -0
  85. package/skills/global_config/dockerfile-validator/references/optimization_guide.md +473 -0
  86. package/skills/global_config/dockerfile-validator/references/security_checklist.md +208 -0
  87. package/skills/global_config/dockerfile-validator/scripts/dockerfile-validate.sh +699 -0
  88. package/skills/global_config/dockerfile-validator/scripts/test_validate.sh +35 -0
  89. package/skills/global_config/dockerfile-validator/tests/fixtures/copy-before-yarn-lock-read.Dockerfile +6 -0
  90. package/skills/global_config/dockerfile-validator/tests/fixtures/copy-before-yarn.Dockerfile +6 -0
  91. package/skills/global_config/dockerfile-validator/tests/fixtures/from-platform-nonroot.Dockerfile +7 -0
  92. package/skills/global_config/dockerfile-validator/tests/test_regression.sh +164 -0
  93. package/skills/global_config/finishing-a-development-branch/SKILL.md +228 -0
  94. package/skills/global_config/github-actions-generator/SKILL.md +353 -0
  95. package/skills/global_config/github-actions-generator/assets/templates/action/composite/action.yml +82 -0
  96. package/skills/global_config/github-actions-generator/assets/templates/action/docker/Dockerfile +25 -0
  97. package/skills/global_config/github-actions-generator/assets/templates/action/docker/action.yml +42 -0
  98. package/skills/global_config/github-actions-generator/assets/templates/action/docker/entrypoint.sh +27 -0
  99. package/skills/global_config/github-actions-generator/assets/templates/action/javascript/action.yml +33 -0
  100. package/skills/global_config/github-actions-generator/assets/templates/action/javascript/index.js +50 -0
  101. package/skills/global_config/github-actions-generator/assets/templates/action/javascript/package.json +27 -0
  102. package/skills/global_config/github-actions-generator/assets/templates/workflow/basic_workflow.yml +242 -0
  103. package/skills/global_config/github-actions-generator/assets/templates/workflow/reusable_workflow.yml +106 -0
  104. package/skills/global_config/github-actions-generator/examples/README.md +147 -0
  105. package/skills/global_config/github-actions-generator/examples/actions/setup-node-cached/action.yml +93 -0
  106. package/skills/global_config/github-actions-generator/examples/caching/docker-buildkit.yml +256 -0
  107. package/skills/global_config/github-actions-generator/examples/security/dependency-review.yml +62 -0
  108. package/skills/global_config/github-actions-generator/examples/security/sbom-attestation.yml +119 -0
  109. package/skills/global_config/github-actions-generator/examples/triggers/chatops-commands.yml +475 -0
  110. package/skills/global_config/github-actions-generator/examples/triggers/repository-dispatch.yml +418 -0
  111. package/skills/global_config/github-actions-generator/examples/triggers/workflow-orchestration.yml +404 -0
  112. package/skills/global_config/github-actions-generator/examples/workflows/docker-build-push.yml +68 -0
  113. package/skills/global_config/github-actions-generator/examples/workflows/go-ci.yml +161 -0
  114. package/skills/global_config/github-actions-generator/examples/workflows/monorepo-ci.yml +340 -0
  115. package/skills/global_config/github-actions-generator/examples/workflows/multi-environment-deploy.yml +406 -0
  116. package/skills/global_config/github-actions-generator/examples/workflows/nodejs-ci.yml +122 -0
  117. package/skills/global_config/github-actions-generator/examples/workflows/python-ci.yml +157 -0
  118. package/skills/global_config/github-actions-generator/examples/workflows/scheduled-tasks.yml +376 -0
  119. package/skills/global_config/github-actions-generator/references/advanced-triggers.md +917 -0
  120. package/skills/global_config/github-actions-generator/references/best-practices.md +755 -0
  121. package/skills/global_config/github-actions-generator/references/common-actions.md +715 -0
  122. package/skills/global_config/github-actions-generator/references/custom-actions.md +320 -0
  123. package/skills/global_config/github-actions-generator/references/expressions-and-contexts.md +688 -0
  124. package/skills/global_config/github-actions-generator/references/modern-features.md +421 -0
  125. package/skills/global_config/github-actions-generator/scripts/test_generator.sh +344 -0
  126. package/skills/global_config/github-actions-templates/SKILL.md +7 -0
  127. package/skills/global_config/github-actions-validator/SKILL.md +576 -0
  128. package/skills/global_config/github-actions-validator/examples/README.md +88 -0
  129. package/skills/global_config/github-actions-validator/examples/outdated-versions.yml +76 -0
  130. package/skills/global_config/github-actions-validator/examples/valid-ci.yml +79 -0
  131. package/skills/global_config/github-actions-validator/examples/with-errors.yml +47 -0
  132. package/skills/global_config/github-actions-validator/references/act_usage.md +233 -0
  133. package/skills/global_config/github-actions-validator/references/action_versions.md +122 -0
  134. package/skills/global_config/github-actions-validator/references/actionlint_usage.md +343 -0
  135. package/skills/global_config/github-actions-validator/references/common_errors.md +512 -0
  136. package/skills/global_config/github-actions-validator/references/modern_features.md +384 -0
  137. package/skills/global_config/github-actions-validator/references/runners.md +317 -0
  138. package/skills/global_config/github-actions-validator/scripts/install_tools.sh +113 -0
  139. package/skills/global_config/github-actions-validator/scripts/validate_workflow.sh +910 -0
  140. package/skills/global_config/github-actions-validator/tests/test_validate_workflow.sh +237 -0
  141. package/skills/global_config/makefile-generator/SKILL.md +614 -0
  142. package/skills/global_config/makefile-generator/assets/templates/.gitkeep +1 -0
  143. package/skills/global_config/makefile-generator/docs/makefile-structure.md +530 -0
  144. package/skills/global_config/makefile-generator/docs/optimization-guide.md +784 -0
  145. package/skills/global_config/makefile-generator/docs/patterns-guide.md +642 -0
  146. package/skills/global_config/makefile-generator/docs/security-guide.md +361 -0
  147. package/skills/global_config/makefile-generator/docs/targets-guide.md +642 -0
  148. package/skills/global_config/makefile-generator/docs/variables-guide.md +596 -0
  149. package/skills/global_config/makefile-generator/scripts/add_standard_targets.sh +539 -0
  150. package/skills/global_config/makefile-generator/scripts/generate_makefile_template.sh +690 -0
  151. package/skills/global_config/makefile-generator/test/test_helper_scripts.sh +190 -0
  152. package/skills/global_config/makefile-validator/SKILL.md +244 -0
  153. package/skills/global_config/makefile-validator/docs/bake-tool.md +1000 -0
  154. package/skills/global_config/makefile-validator/docs/best-practices.md +858 -0
  155. package/skills/global_config/makefile-validator/docs/common-mistakes.md +944 -0
  156. package/skills/global_config/makefile-validator/examples/bad-makefile.mk +77 -0
  157. package/skills/global_config/makefile-validator/examples/good-makefile.mk +103 -0
  158. package/skills/global_config/makefile-validator/scripts/test_validate.sh +382 -0
  159. package/skills/global_config/makefile-validator/scripts/validate_makefile.sh +712 -0
  160. package/skills/global_config/{MCP_Manage → mcp-manage}/SKILL.md +3 -3
  161. package/skills/global_config/requesting-code-review/SKILL.md +98 -0
  162. package/skills/global_config/requesting-code-review/code-reviewer.md +198 -0
  163. package/skills/global_config/using-git-worktrees/SKILL.md +170 -0
  164. package/skills/global_config/verification-before-completion/SKILL.md +123 -0
  165. package/skills/global_config/writing-plans/SKILL.md +126 -46
  166. package/skills/global_config/writing-plans-legacy/SKILL.md +139 -0
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env bash
2
+ #
3
+ # CI-friendly regression entrypoint for dockerfile-validator.
4
+ # Runs syntax checks, regression tests, and optional ShellCheck linting.
5
+
6
+ set -euo pipefail
7
+
8
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9
+ readonly SCRIPT_DIR
10
+ SKILL_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
11
+ readonly SKILL_DIR
12
+
13
+ VALIDATOR_SCRIPT="$SKILL_DIR/scripts/dockerfile-validate.sh"
14
+ REGRESSION_SCRIPT="$SKILL_DIR/tests/test_regression.sh"
15
+ STRICT_SHELLCHECK="${STRICT_SHELLCHECK:-false}"
16
+
17
+ echo "Running dockerfile-validator CI checks..."
18
+
19
+ # Fast syntax guard for scripts used by the regression suite.
20
+ bash -n "$VALIDATOR_SCRIPT" "$REGRESSION_SCRIPT" "$0"
21
+
22
+ # Regression coverage for parser/best-practice branches.
23
+ bash "$REGRESSION_SCRIPT"
24
+
25
+ if command -v shellcheck >/dev/null 2>&1; then
26
+ shellcheck "$VALIDATOR_SCRIPT" "$REGRESSION_SCRIPT" "$0"
27
+ echo "ShellCheck: PASS"
28
+ elif [[ "$STRICT_SHELLCHECK" == "true" ]]; then
29
+ echo "ShellCheck: required but not installed (STRICT_SHELLCHECK=true)" >&2
30
+ exit 1
31
+ else
32
+ echo "ShellCheck: SKIP (not installed; set STRICT_SHELLCHECK=true to require it)"
33
+ fi
34
+
35
+ echo "PASS: dockerfile-validator CI checks"
@@ -0,0 +1,6 @@
1
+ FROM node:20-alpine
2
+ WORKDIR /app
3
+ COPY . .
4
+ RUN cat yarn.lock >/dev/null 2>&1 || true
5
+ USER 1000
6
+ CMD ["node", "server.js"]
@@ -0,0 +1,6 @@
1
+ FROM node:20-alpine
2
+ WORKDIR /app
3
+ COPY . .
4
+ RUN yarn
5
+ USER 1000
6
+ CMD ["node", "server.js"]
@@ -0,0 +1,7 @@
1
+ FROM --platform=linux/amd64 golang:1.24-alpine AS build
2
+ WORKDIR /src
3
+ RUN printf '#!/bin/sh\necho hello\n' > /out && chmod +x /out
4
+
5
+ FROM --platform linux/amd64 gcr.io/distroless/static-debian11:nonroot AS runtime
6
+ COPY --from=build /out /out
7
+ ENTRYPOINT ["/out"]
@@ -0,0 +1,164 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ SKILL_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5
+ VALIDATOR="$SKILL_DIR/scripts/dockerfile-validate.sh"
6
+ FIXTURES_DIR="$SKILL_DIR/tests/fixtures"
7
+ TMP_DIR="$(mktemp -d)"
8
+
9
+ cleanup() {
10
+ rm -rf "$TMP_DIR"
11
+ }
12
+ trap cleanup EXIT
13
+
14
+ PASS=0
15
+ FAIL=0
16
+
17
+ pass() {
18
+ echo " PASS: $1"
19
+ PASS=$((PASS + 1))
20
+ }
21
+
22
+ fail() {
23
+ echo " FAIL: $1"
24
+ FAIL=$((FAIL + 1))
25
+ }
26
+
27
+ make_stub_tools() {
28
+ mkdir -p "$TMP_DIR/bin"
29
+
30
+ cat > "$TMP_DIR/bin/hadolint" <<'EOF'
31
+ #!/usr/bin/env bash
32
+ set -euo pipefail
33
+ exit 0
34
+ EOF
35
+
36
+ cat > "$TMP_DIR/bin/checkov" <<'EOF'
37
+ #!/usr/bin/env bash
38
+ set -euo pipefail
39
+ exit 0
40
+ EOF
41
+
42
+ chmod +x "$TMP_DIR/bin/hadolint" "$TMP_DIR/bin/checkov"
43
+ }
44
+
45
+ validator_output() {
46
+ local dockerfile="$1"
47
+ PATH="$TMP_DIR/bin:$PATH" bash "$VALIDATOR" "$dockerfile" 2>&1 || true
48
+ }
49
+
50
+ validator_exit_code() {
51
+ local dockerfile="$1"
52
+ local exit_code=0
53
+ PATH="$TMP_DIR/bin:$PATH" bash "$VALIDATOR" "$dockerfile" >/dev/null 2>&1 || exit_code=$?
54
+ echo "$exit_code"
55
+ }
56
+
57
+ assert_output_contains() {
58
+ local label="$1"
59
+ local dockerfile="$2"
60
+ local pattern="$3"
61
+
62
+ local output
63
+ output="$(validator_output "$dockerfile")"
64
+
65
+ if echo "$output" | grep -qE "$pattern"; then
66
+ pass "$label"
67
+ else
68
+ fail "$label (missing pattern: $pattern)"
69
+ echo " --- validator output ---"
70
+ echo "$output" | sed 's/^/ /'
71
+ echo " --- end output ---"
72
+ fi
73
+ }
74
+
75
+ assert_output_not_contains() {
76
+ local label="$1"
77
+ local dockerfile="$2"
78
+ local pattern="$3"
79
+
80
+ local output
81
+ output="$(validator_output "$dockerfile")"
82
+
83
+ if echo "$output" | grep -qE "$pattern"; then
84
+ fail "$label (unexpected pattern: $pattern)"
85
+ echo " --- validator output ---"
86
+ echo "$output" | sed 's/^/ /'
87
+ echo " --- end output ---"
88
+ else
89
+ pass "$label"
90
+ fi
91
+ }
92
+
93
+ assert_exit_zero() {
94
+ local label="$1"
95
+ local dockerfile="$2"
96
+
97
+ local exit_code
98
+ exit_code="$(validator_exit_code "$dockerfile")"
99
+
100
+ if [[ "$exit_code" -eq 0 ]]; then
101
+ pass "$label"
102
+ else
103
+ fail "$label (expected 0, got $exit_code)"
104
+ fi
105
+ }
106
+
107
+ echo "Running dockerfile-validator regression tests..."
108
+ echo ""
109
+
110
+ make_stub_tools
111
+
112
+ COPY_BEFORE_YARN="$FIXTURES_DIR/copy-before-yarn.Dockerfile"
113
+ COPY_BEFORE_YARN_LOCK="$FIXTURES_DIR/copy-before-yarn-lock-read.Dockerfile"
114
+ FROM_PLATFORM_NONROOT="$FIXTURES_DIR/from-platform-nonroot.Dockerfile"
115
+
116
+ echo "[copy-before-yarn]"
117
+ assert_output_contains \
118
+ "flags COPY . before bare RUN yarn" \
119
+ "$COPY_BEFORE_YARN" \
120
+ "COPY \\. appears before dependency installation"
121
+ assert_exit_zero \
122
+ "warn-only result stays non-failing" \
123
+ "$COPY_BEFORE_YARN"
124
+
125
+ echo ""
126
+ echo "[copy-before-yarn-lock-read]"
127
+ assert_output_not_contains \
128
+ "does not misclassify yarn.lock as yarn install" \
129
+ "$COPY_BEFORE_YARN_LOCK" \
130
+ "COPY \\. appears before dependency installation"
131
+ assert_exit_zero \
132
+ "non-install RUN after COPY . remains non-failing" \
133
+ "$COPY_BEFORE_YARN_LOCK"
134
+
135
+ echo ""
136
+ echo "[from-platform-nonroot]"
137
+ assert_output_contains \
138
+ "parses --platform final image as non-root base" \
139
+ "$FROM_PLATFORM_NONROOT" \
140
+ "No USER directive, but final base image is non-root: gcr.io/distroless/static-debian11:nonroot"
141
+ assert_output_not_contains \
142
+ "does not emit root warning for non-root distroless base" \
143
+ "$FROM_PLATFORM_NONROOT" \
144
+ "container will run as root"
145
+ assert_output_contains \
146
+ "optimization stage reports parsed minimal final base" \
147
+ "$FROM_PLATFORM_NONROOT" \
148
+ "Using minimal base for final stage: gcr.io/distroless/static-debian11:nonroot"
149
+ assert_output_not_contains \
150
+ "base image analysis never treats --platform as image" \
151
+ "$FROM_PLATFORM_NONROOT" \
152
+ "Consider Alpine alternative for: --platform"
153
+ assert_exit_zero \
154
+ "platform flag fixture exits successfully" \
155
+ "$FROM_PLATFORM_NONROOT"
156
+
157
+ echo ""
158
+ echo "Summary: $PASS passed, $FAIL failed"
159
+
160
+ if [[ "$FAIL" -ne 0 ]]; then
161
+ exit 1
162
+ fi
163
+
164
+ echo "PASS: dockerfile-validator regression tests"
@@ -0,0 +1,228 @@
1
+ ---
2
+ name: finishing-a-development-branch
3
+ description: Use when implementation is complete, all tests pass, and you need to decide how to integrate the work
4
+ category: engineering-method
5
+ source: superpowers
6
+ date_added: "2026-09-25"
7
+ ---
8
+
9
+ # Finishing a Development Branch
10
+
11
+ ## Overview
12
+
13
+ **Core principle:** Verify tests → Detect environment → Present options → Execute choice → Clean up.
14
+
15
+ **Announce at start:** "I'm using the finishing-a-development-branch skill to complete this work."
16
+
17
+ ## Step 1: Verify Tests
18
+
19
+ Run the project's full test suite (`npm test` / `cargo test` / `pytest` / `go test ./...`).
20
+
21
+ **If tests fail**, report the failures and stop — the menu comes after a green suite:
22
+
23
+ ```
24
+ Tests failing (<N> failures). Must fix before completing:
25
+
26
+ [Show failures]
27
+ ```
28
+
29
+ **If tests pass:** continue to Step 2.
30
+
31
+ ## Step 2: Detect Environment
32
+
33
+ ```bash
34
+ GIT_DIR=$(cd "$(git rev-parse --git-dir)" 2>/dev/null && pwd -P)
35
+ GIT_COMMON=$(cd "$(git rev-parse --git-common-dir)" 2>/dev/null && pwd -P)
36
+ # Capture now, while still inside the workspace — Step 5 changes directory
37
+ # before cleanup (Step 6) needs this value
38
+ WORKTREE_PATH=$(git rev-parse --show-toplevel)
39
+ ```
40
+
41
+ This determines which menu to show and how cleanup works:
42
+
43
+ | State | Menu | Cleanup |
44
+ |-------|------|---------|
45
+ | `GIT_DIR == GIT_COMMON` (normal repo) | Standard 3 options | No worktree to clean up |
46
+ | `GIT_DIR != GIT_COMMON`, named branch | Standard 3 options | Provenance-based (see Step 6) |
47
+ | `GIT_DIR != GIT_COMMON`, detached HEAD | Reduced 2 options (no merge) | Externally managed — leave in place |
48
+
49
+ ## Step 3: Determine Base Branch
50
+
51
+ The base branch is whatever this work forked from — usually named in the
52
+ plan, the conversation, or the branch's upstream. If it is not already
53
+ known, ask: "This branch split from <your best guess> - is that correct?"
54
+ Confirm before merging: merging into the wrong base is expensive to undo.
55
+
56
+ ## Step 4: Present Options
57
+
58
+ **Normal repo and named-branch worktree — present exactly these 3 options:**
59
+
60
+ ```
61
+ Implementation complete. What would you like to do?
62
+
63
+ 1. Merge back to <base-branch> locally
64
+ 2. Push and create a Pull Request
65
+ 3. Keep the branch as-is (I'll handle it later)
66
+
67
+ Which option?
68
+ ```
69
+
70
+ **Detached HEAD — present exactly these 2 options:**
71
+
72
+ ```
73
+ Implementation complete. You're on a detached HEAD (externally managed workspace).
74
+
75
+ 1. Push as new branch and create a Pull Request
76
+ 2. Keep as-is (I'll handle it later)
77
+
78
+ Which option?
79
+ ```
80
+
81
+ Present the menu exactly as written — concise, with every option coming
82
+ from the list above. Discarding the work happens only in response to your
83
+ human partner explicitly asking for it (see "If your human partner asks to
84
+ discard the work" below). Wait for their answer; the integration decision
85
+ is theirs.
86
+
87
+ ## Step 5: Execute Choice
88
+
89
+ ### Option 1: Merge Locally
90
+
91
+ ```bash
92
+ # Get main repo root for CWD safety
93
+ MAIN_ROOT=$(git -C "$(git rev-parse --git-common-dir)/.." rev-parse --show-toplevel)
94
+ cd "$MAIN_ROOT"
95
+
96
+ # Merge first — verify success before removing anything
97
+ git checkout <base-branch>
98
+ git pull
99
+ git merge <feature-branch>
100
+
101
+ # Verify tests on merged result
102
+ <test command>
103
+ ```
104
+
105
+ If tests fail on the merged result: stop, leave the worktree and branch in
106
+ place, and investigate — nothing has been pushed, so the merge is local
107
+ and recoverable.
108
+
109
+ Once the merged result is green: clean up the worktree (Step 6), then
110
+ delete the branch:
111
+
112
+ ```bash
113
+ git branch -d <feature-branch>
114
+ ```
115
+
116
+ ### Option 2: Push and Create PR
117
+
118
+ ```bash
119
+ git push -u origin <feature-branch>
120
+ # From a detached HEAD, name the new branch on the remote:
121
+ # git push origin HEAD:refs/heads/<new-branch>
122
+ ```
123
+
124
+ Then create the pull/merge request against <base-branch> with the forge's
125
+ tooling — its CLI if one is available, or the creation URL most forges
126
+ print when you push — following the repo's PR template and conventions if
127
+ present, and report the URL to your human partner.
128
+
129
+ Keep the worktree — your human partner iterates on PR feedback there.
130
+
131
+ ### Option 3: Keep As-Is
132
+
133
+ Report: "Keeping branch <name>. Worktree preserved at <path>."
134
+
135
+ ### If your human partner asks to discard the work
136
+
137
+ This path exists only as a response to an explicit request to throw the
138
+ work away. Confirm first:
139
+
140
+ ```
141
+ This will permanently delete:
142
+ - Branch <name>
143
+ - All commits: <commit-list>
144
+ - Worktree at <path>
145
+
146
+ Type 'discard' to confirm.
147
+ ```
148
+
149
+ Wait for that exact confirmation. When it arrives:
150
+
151
+ ```bash
152
+ MAIN_ROOT=$(git -C "$(git rev-parse --git-common-dir)/.." rev-parse --show-toplevel)
153
+ cd "$MAIN_ROOT"
154
+ ```
155
+
156
+ Then clean up the worktree (Step 6) and force-delete the branch:
157
+
158
+ ```bash
159
+ git branch -D <feature-branch>
160
+ ```
161
+
162
+ ## Step 6: Cleanup Workspace
163
+
164
+ **Runs for Option 1 and confirmed discards.** Options 2 and 3 always
165
+ preserve the worktree. Both callers have already changed directory to the
166
+ main repo root — worktree removal must run from outside the worktree —
167
+ and use the `GIT_DIR`/`GIT_COMMON`/`WORKTREE_PATH` values captured in
168
+ Step 2, from before that directory change.
169
+
170
+ **If `GIT_DIR == GIT_COMMON`:** Normal repo, no worktree to clean up. Done.
171
+
172
+ **If `WORKTREE_PATH` is under `.worktrees/` or `worktrees/`:** Superpowers
173
+ created this worktree — we own cleanup:
174
+
175
+ ```bash
176
+ git worktree remove "$WORKTREE_PATH"
177
+ git worktree prune # Self-healing: clean up any stale registrations
178
+ ```
179
+
180
+ **If removal is refused** (`contains modified or untracked files`): the
181
+ worktree holds files that exist nowhere else — uncommitted plans, notes,
182
+ or scratch work. Never `--force` on your own initiative. Show your human
183
+ partner what is at stake and ask:
184
+
185
+ ```bash
186
+ git -C "$WORKTREE_PATH" status --porcelain -uall
187
+ ```
188
+
189
+ ```
190
+ Worktree removal refused — these files were never committed:
191
+
192
+ <file list>
193
+
194
+ 1. Commit them to <branch> before cleanup
195
+ 2. Move them into <main repo root>
196
+ 3. Delete them (unrecoverable)
197
+
198
+ Which?
199
+ ```
200
+
201
+ Carry out the choice, then remove the worktree.
202
+
203
+ **Otherwise:** The host environment owns this workspace — leave it in
204
+ place. If your platform provides a workspace-exit tool, use it.
205
+
206
+ ## Quick Reference
207
+
208
+ | Option | Merge | Push | Keep Worktree | Cleanup Branch |
209
+ |--------|-------|------|---------------|----------------|
210
+ | 1. Merge locally | yes | - | - | yes |
211
+ | 2. Create PR | - | yes | yes | - |
212
+ | 3. Keep as-is | - | - | yes | - |
213
+ | Discard (explicit request only) | - | - | - | yes (force) |
214
+
215
+ ## Common Rationalizations
216
+
217
+ | Excuse | Reality |
218
+ |--------|---------|
219
+ | "Tests passed earlier this session" | Run the suite on the tree you are about to integrate. A green run only proves the tree it ran on. |
220
+ | "They obviously want it merged" | Integration is your human partner's decision. Present the menu and wait. |
221
+ | "They seem done with this feature — I'll offer to discard it" | The menu is complete as written. Discard happens only when your human partner asks for it in so many words. |
222
+ | "'Yeah, get rid of it' counts as confirmation" | Only the typed word `discard` authorizes deletion. |
223
+ | "The PR is up, so the worktree is clutter now" | PR feedback gets fixed in that worktree. It stays until the work lands. |
224
+ | "This other worktree looks stale — I'll clean it too" | Clean up only worktrees under `.worktrees/` or `worktrees/`. Everything else belongs to the host. |
225
+ | "Removal refused — `--force` is just finishing the cleanup" | The refusal means files exist only in that worktree. `--force` destroys them permanently. Show your human partner and ask. |
226
+ | "The merged-result failure is probably flaky" | A failing merged result stops everything. Branch and worktree stay put while you investigate. |
227
+ | "The base branch is obviously main" | Confirm the fork point or ask. Merging into the wrong base is expensive to undo. |
228
+ | "The push was rejected — force-push will fix it" | A rejected push means the remote moved. Investigate; force-push only on your human partner's explicit request. |