@reddb-io/red-skills 4.4.0 → 4.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/bin/build-info.mjs +87 -0
  2. package/bin/cli-frontdoor.mjs +14 -0
  3. package/bin/red-skills-brain.mjs +17 -22
  4. package/bin/red-skills-content.mjs +17 -0
  5. package/bin/red-skills-hook.mjs +45 -0
  6. package/bin/red-skills-memory.mjs +17 -22
  7. package/bin/red-skills-redskilled-mcp.mjs +2 -0
  8. package/bin/red-skills-resource.mjs +21 -0
  9. package/bin/runtime-compatibility.mjs +17 -0
  10. package/bin/runtime-paths.mjs +13 -0
  11. package/dist/code-nav.bundle.min.mjs +1 -1
  12. package/dist/opencode-host.bundle.min.mjs +1 -1
  13. package/dist/redskilled-mcp.bundle.min.mjs +36 -36
  14. package/dist/redskilled.bundle.min.mjs +234 -230
  15. package/dist/release.bundle.min.mjs +1 -1
  16. package/dist/rsp-core.bundle.min.mjs +1 -1
  17. package/dist/rsp.bundle.min.mjs +1 -1
  18. package/dist/statusline.bundle.min.mjs +1 -1
  19. package/package.json +9 -4
  20. package/runtime/hook-routes.json +125 -0
  21. package/runtime/plugins/brain/scripts/bootstrap.mjs +656 -0
  22. package/runtime/plugins/brain/scripts/structural-smoke.sh +7 -0
  23. package/runtime/plugins/dev/hooks/branch-lock-codex.sh +105 -0
  24. package/runtime/plugins/dev/hooks/code-nav-mcp.sh +63 -0
  25. package/runtime/plugins/dev/hooks/command-guard.sh +893 -0
  26. package/runtime/plugins/dev/hooks/ensure-codex-statusline.mjs +144 -0
  27. package/runtime/plugins/dev/hooks/red-fetch.mjs +38 -0
  28. package/runtime/plugins/dev/hooks/redskilled-mcp.sh +64 -0
  29. package/runtime/plugins/dev/hooks/rsp-hook.sh +343 -0
  30. package/runtime/plugins/dev/hooks/tests/command-guard.test.sh +378 -0
  31. package/runtime/plugins/dev/hooks/tests/rsp-hook.test.sh +229 -0
  32. package/runtime/plugins/dev/scripts/memory-bridge.sh +230 -0
  33. package/runtime/plugins/dev/scripts/structural-smoke.sh +7 -0
  34. package/runtime/plugins/dev/scripts/tests/memory-bridge.test.sh +555 -0
  35. package/runtime/plugins/dev/skills/engineering/afk/defaults/cargo-pre-worktree.sh +37 -0
  36. package/runtime/plugins/dev/skills/engineering/afk/defaults/envelope-post-attempt.sh +47 -0
  37. package/runtime/plugins/dev/skills/engineering/afk/defaults/gradle-pre-worktree.sh +45 -0
  38. package/runtime/plugins/dev/skills/engineering/afk/defaults/heartbeat-post-attempt.sh +43 -0
  39. package/runtime/plugins/dev/skills/engineering/afk/defaults/validation-post-merge.sh +77 -0
  40. package/runtime/plugins/dev/skills/engineering/afk/detectors/cargo.sh +27 -0
  41. package/runtime/plugins/dev/skills/engineering/afk/detectors/gradle.sh +38 -0
  42. package/runtime/plugins/dev/skills/engineering/afk/examples/only-mine.sh +32 -0
  43. package/runtime/plugins/dev/skills/engineering/afk/examples/red-afk-attempt-action.yml +53 -0
  44. package/runtime/plugins/dev/skills/engineering/afk/examples/rs-afk-attempt.yml +76 -0
  45. package/runtime/plugins/dev/skills/engineering/afk/hooks/red-cargo +38 -0
  46. package/runtime/plugins/dev/skills/engineering/afk/hooks/red-envelope +50 -0
  47. package/runtime/plugins/dev/skills/engineering/afk/hooks/red-gradle +42 -0
  48. package/runtime/plugins/dev/skills/engineering/afk/hooks/red-heartbeat +46 -0
  49. package/runtime/plugins/dev/skills/engineering/afk/hooks/red-validation +79 -0
  50. package/runtime/plugins/dev/skills/engineering/diagnose/scripts/hitl-loop.template.sh +41 -0
  51. package/runtime/plugins/dev/skills/engineering/red-setup/scripts/install-runtime-shim.sh +181 -0
  52. package/runtime/plugins/dev/skills/engineering/red-setup/workflows/red-issues-needs-triage.yml +36 -0
  53. package/runtime/plugins/dev/skills/engineering/wizard/template.sh +211 -0
  54. package/runtime/plugins/dev/skills/engineering/zoom-out/scripts/graph-mode-plumbing.sh +36 -0
  55. package/runtime/plugins/dev/skills/engineering/zoom-out/scripts/tests/contract.test.sh +168 -0
  56. package/runtime/plugins/dev/skills/misc/branch-lock/scripts/branch-lock-hook.sh +113 -0
  57. package/runtime/plugins/dev/skills/misc/branch-lock/scripts/branch-lock-session-start.sh +81 -0
  58. package/runtime/plugins/dev/skills/misc/branch-lock/scripts/branch-lock.sh +68 -0
  59. package/runtime/plugins/dev/skills/misc/branch-lock/scripts/lib/dev-config.sh +126 -0
  60. package/runtime/plugins/dev/skills/misc/branch-lock/scripts/lib/git-command-classifier.sh +198 -0
  61. package/runtime/plugins/dev/skills/misc/branch-lock/scripts/lib/lock-store.sh +67 -0
  62. package/runtime/plugins/dev/skills/misc/branch-lock/scripts/lib/scope-resolver.sh +43 -0
  63. package/runtime/plugins/dev/skills/misc/branch-lock/scripts/tests/branch-lock-cli.test.sh +114 -0
  64. package/runtime/plugins/dev/skills/misc/branch-lock/scripts/tests/claude-plugin-hook.test.sh +117 -0
  65. package/runtime/plugins/dev/skills/misc/branch-lock/scripts/tests/codex-hook.test.sh +230 -0
  66. package/runtime/plugins/dev/skills/misc/branch-lock/scripts/tests/dev-config.test.sh +99 -0
  67. package/runtime/plugins/dev/skills/misc/branch-lock/scripts/tests/git-command-classifier.test.sh +187 -0
  68. package/runtime/plugins/dev/skills/misc/branch-lock/scripts/tests/lock-store.test.sh +90 -0
  69. package/runtime/plugins/dev/skills/misc/branch-lock/scripts/tests/scope-resolver.test.sh +63 -0
  70. package/runtime/plugins/dev/skills/misc/branch-lock/scripts/tests/session-start.test.sh +123 -0
  71. package/runtime/plugins/dev/skills/misc/git-guardrails-claude-code/scripts/block-dangerous-git.sh +231 -0
  72. package/runtime/plugins/dev/skills/misc/git-guardrails-claude-code/scripts/tests/block-dangerous-git.test.sh +143 -0
  73. package/runtime/plugins/internal/scripts/structural-smoke.sh +7 -0
  74. package/runtime/plugins/internal/skills/maintainer/create-plugin/scripts/create-plugin.sh +308 -0
  75. package/runtime/plugins/memory/scripts/bootstrap.mjs +659 -0
  76. package/runtime/plugins/memory/scripts/structural-smoke.sh +7 -0
  77. package/scripts/check-skills-boundary.mjs +32 -0
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env bash
2
+ # Human-in-the-loop reproduction loop.
3
+ # Copy this file, edit the steps below, and run it.
4
+ # The agent runs the script; the user follows prompts in their terminal.
5
+ #
6
+ # Usage:
7
+ # bash hitl-loop.template.sh
8
+ #
9
+ # Two helpers:
10
+ # step "<instruction>" → show instruction, wait for Enter
11
+ # capture VAR "<question>" → show question, read response into VAR
12
+ #
13
+ # At the end, captured values are printed as KEY=VALUE for the agent to parse.
14
+
15
+ set -euo pipefail
16
+
17
+ step() {
18
+ printf '\n>>> %s\n' "$1"
19
+ read -r -p " [Enter when done] " _
20
+ }
21
+
22
+ capture() {
23
+ local var="$1" question="$2" answer
24
+ printf '\n>>> %s\n' "$question"
25
+ read -r -p " > " answer
26
+ printf -v "$var" '%s' "$answer"
27
+ }
28
+
29
+ # --- edit below ---------------------------------------------------------
30
+
31
+ step "Open the app at http://localhost:3000 and sign in."
32
+
33
+ capture ERRORED "Click the 'Export' button. Did it throw an error? (y/n)"
34
+
35
+ capture ERROR_MSG "Paste the error message (or 'none'):"
36
+
37
+ # --- edit above ---------------------------------------------------------
38
+
39
+ printf '\n--- Captured ---\n'
40
+ printf 'ERRORED=%s\n' "$ERRORED"
41
+ printf 'ERROR_MSG=%s\n' "$ERROR_MSG"
@@ -0,0 +1,181 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ bin_dir="${XDG_BIN_HOME:-$HOME/.local/bin}"
5
+ name="${1:-red-skills-dev}"
6
+ dev_target="$bin_dir/$name"
7
+ rsp_target="$bin_dir/rsp"
8
+
9
+ mkdir -p "$bin_dir"
10
+
11
+ cat >"$dev_target" <<'SH'
12
+ #!/usr/bin/env bash
13
+ set -euo pipefail
14
+
15
+ env_launcher() {
16
+ local root
17
+ for root in \
18
+ "${RED_SKILLS_DEV_PLUGIN_ROOT:-}" \
19
+ "${CLAUDE_PLUGIN_ROOT:-}" \
20
+ "${CODEX_PLUGIN_ROOT:-}" \
21
+ "${OPENCODE_PLUGIN_ROOT:-}"
22
+ do
23
+ [ -n "$root" ] || continue
24
+ if [ -f "$root/skills/engineering/afk/bin/afk.mjs" ]; then
25
+ printf '%s\n' "$root/skills/engineering/afk/bin/afk.mjs"
26
+ return 0
27
+ fi
28
+ done
29
+ return 1
30
+ }
31
+
32
+ latest_cache_launcher() {
33
+ local dir
34
+ for dir in "$HOME"/.codex/plugins/cache/red-skills/dev/* "$HOME"/.claude/plugins/cache/red-skills/dev/*; do
35
+ [ -f "$dir/skills/engineering/afk/bin/afk.mjs" ] &&
36
+ printf '%s\t%s\n' "$(basename "$dir")" "$dir/skills/engineering/afk/bin/afk.mjs"
37
+ done | sort -V | tail -1 | cut -f2-
38
+ }
39
+
40
+ # There is deliberately NO cached-bundle fallback here. ADR 0147 deleted the dev
41
+ # runtime bundle, so `dev-3.21.0.bundle.min.mjs` is the last one that will ever
42
+ # exist and resolving it runs a 3.21.0-era binary against v4 state. A machine
43
+ # that still holds one gets the message below, not silently old code.
44
+
45
+ launcher="$(env_launcher || true)"
46
+ if [ -n "$launcher" ]; then
47
+ exec node "$launcher" "$@"
48
+ fi
49
+
50
+ launcher="$(latest_cache_launcher || true)"
51
+ if [ -n "$launcher" ]; then
52
+ exec node "$launcher" "$@"
53
+ fi
54
+
55
+ cat >&2 <<'EOF'
56
+ red-skills-dev: no RedSkills dev runtime found.
57
+
58
+ Expected one of:
59
+ - an installed dev plugin under ~/.codex/plugins/cache/red-skills/dev/*
60
+ - an installed dev plugin under ~/.claude/plugins/cache/red-skills/dev/*
61
+
62
+ The dev runtime bundle was deleted by ADR 0147; any leftover
63
+ ~/.cache/red-skills/bundles/dev-*.bundle.min.mjs is inert and safe to remove.
64
+
65
+ Fallback:
66
+ npx -y -p @reddb-io/red-skills@<version> red-skills-dev "$@"
67
+
68
+ Run /red-setup in a repo with plugins.dev.enabled: true, then restart the
69
+ agent session so the plugin SessionStart hook can warm the runtime cache, or use
70
+ the npm direct-run fallback above for a fresh machine.
71
+ EOF
72
+ exit 127
73
+ SH
74
+
75
+ cat >"$rsp_target" <<'SH'
76
+ #!/usr/bin/env bash
77
+ set -euo pipefail
78
+
79
+ env_bundle() {
80
+ local root bundle
81
+ for root in \
82
+ "${RED_SKILLS_DEV_PLUGIN_ROOT:-}" \
83
+ "${CLAUDE_PLUGIN_ROOT:-}" \
84
+ "${CODEX_PLUGIN_ROOT:-}" \
85
+ "${OPENCODE_PLUGIN_ROOT:-}"
86
+ do
87
+ [ -n "$root" ] || continue
88
+ for bundle in \
89
+ "$root/../../dist/rsp.bundle.min.mjs" \
90
+ "$root/dist/rsp.bundle.min.mjs"
91
+ do
92
+ if [ -f "$bundle" ]; then
93
+ printf '%s\n' "$bundle"
94
+ return 0
95
+ fi
96
+ done
97
+ done
98
+ return 1
99
+ }
100
+
101
+ latest_cache_bundle() {
102
+ local dir bundle
103
+ for dir in "$HOME"/.codex/plugins/cache/red-skills/dev/* "$HOME"/.claude/plugins/cache/red-skills/dev/*; do
104
+ [ -d "$dir" ] || continue
105
+ for bundle in "$dir/../../dist/rsp.bundle.min.mjs" "$dir/dist/rsp.bundle.min.mjs"; do
106
+ [ -f "$bundle" ] &&
107
+ printf '%s\t%s\n' "$(basename "$dir")" "$bundle"
108
+ done
109
+ done | sort -V | tail -1 | cut -f2-
110
+ }
111
+
112
+ latest_bundle() {
113
+ local cache_root bundle version
114
+ cache_root="${RED_SKILLS_CACHE_DIR:-${XDG_CACHE_HOME:-$HOME/.cache}/red-skills/bundles}"
115
+
116
+ if [ -f "$cache_root/rsp.bundle.min.mjs" ]; then
117
+ printf '%s\n' "$cache_root/rsp.bundle.min.mjs"
118
+ return 0
119
+ fi
120
+
121
+ for bundle in "$cache_root"/rsp-*.bundle.min.mjs; do
122
+ [ -f "$bundle" ] || continue
123
+ version="${bundle##*/rsp-}"
124
+ version="${version%.bundle.min.mjs}"
125
+ printf '%s\t%s\n' "$version" "$bundle"
126
+ done | sort -V | tail -1 | cut -f2-
127
+ }
128
+
129
+ find_red_binary() {
130
+ local cache_root red version
131
+ cache_root="${RED_SKILLS_CACHE_DIR:-${XDG_CACHE_HOME:-$HOME/.cache}/red-skills/bundles}"
132
+
133
+ for red in "$cache_root"/reddb/*/red "$cache_root"/reddb/*/red.exe; do
134
+ [ -x "$red" ] || continue
135
+ version="${red%/*}"
136
+ version="${version##*/}"
137
+ printf '%s\t%s\n' "$version" "$red"
138
+ done | sort -V | tail -1 | cut -f2-
139
+ }
140
+
141
+ with_red_binary() {
142
+ local red
143
+ red="$(find_red_binary || true)"
144
+ if [ -n "$red" ]; then
145
+ REDDB_BIN="$red" exec node "$@"
146
+ fi
147
+ exec node "$@"
148
+ }
149
+
150
+ bundle="$(env_bundle || true)"
151
+ if [ -n "$bundle" ]; then
152
+ with_red_binary "$bundle" "$@"
153
+ fi
154
+
155
+ bundle="$(latest_cache_bundle || true)"
156
+ if [ -n "$bundle" ]; then
157
+ with_red_binary "$bundle" "$@"
158
+ fi
159
+
160
+ bundle="$(latest_bundle || true)"
161
+ if [ -n "$bundle" ]; then
162
+ with_red_binary "$bundle" "$@"
163
+ fi
164
+
165
+ cat >&2 <<'EOF'
166
+ rsp: no RedSkills rsp runtime found.
167
+
168
+ Expected one of:
169
+ - an installed dev plugin with dist/rsp.bundle.min.mjs under ~/.codex/plugins/cache/red-skills/dev/*
170
+ - an installed dev plugin with dist/rsp.bundle.min.mjs under ~/.claude/plugins/cache/red-skills/dev/*
171
+ - a warmed rsp bundle under ${RED_SKILLS_CACHE_DIR:-${XDG_CACHE_HOME:-$HOME/.cache}/red-skills/bundles}
172
+
173
+ Run /red-setup in a repo with plugins.dev.enabled: true, then restart the
174
+ agent session so the plugin SessionStart hook can warm the runtime cache.
175
+ EOF
176
+ exit 127
177
+ SH
178
+
179
+ chmod 0755 "$dev_target" "$rsp_target"
180
+ printf 'installed %s\n' "$dev_target"
181
+ printf 'installed %s\n' "$rsp_target"
@@ -0,0 +1,36 @@
1
+ # Auto-applies the `needs-triage` label to any newly opened or reopened issue
2
+ # that has no labels yet. Keeps fresh issues from slipping past `/triage` and
3
+ # `/afk` (which only consumes `ready-for-agent`).
4
+ #
5
+ # Installed by `/red-setup`. Filename prefix `red-` marks it as belonging
6
+ # to the RedSkills ecosystem.
7
+
8
+ name: red-issues-needs-triage
9
+
10
+ on:
11
+ issues:
12
+ types: [opened, reopened]
13
+
14
+ permissions:
15
+ issues: write
16
+
17
+ jobs:
18
+ label:
19
+ runs-on: ubuntu-latest
20
+ steps:
21
+ - uses: actions/github-script@v7
22
+ with:
23
+ script: |
24
+ const issue = context.payload.issue;
25
+ const labels = (issue.labels || []).map(l => l.name);
26
+ if (labels.length > 0) {
27
+ core.info(`Issue #${issue.number} already labelled (${labels.join(', ')}). Skipping.`);
28
+ return;
29
+ }
30
+ await github.rest.issues.addLabels({
31
+ owner: context.repo.owner,
32
+ repo: context.repo.repo,
33
+ issue_number: issue.number,
34
+ labels: ['needs-triage']
35
+ });
36
+ core.info(`Applied 'needs-triage' to #${issue.number}.`);
@@ -0,0 +1,211 @@
1
+ #!/usr/bin/env bash
2
+ #
3
+ # A wizard — walks a human through a manual procedure step by step.
4
+ # Generated by the /wizard skill.
5
+ #
6
+ # Everything above the "STAGES" marker is the wizard library: do not hand-edit
7
+ # it. Author the per-step stages below the marker.
8
+
9
+ set -euo pipefail
10
+
11
+ # ──────────────────────────────────────────────────────────────────────────
12
+ # Wizard library — delightful, consistent UX. Identical across every wizard.
13
+ # ──────────────────────────────────────────────────────────────────────────
14
+
15
+ if [[ -t 1 ]] && command -v tput >/dev/null 2>&1 && [[ "$(tput colors 2>/dev/null || echo 0)" -ge 8 ]]; then
16
+ BOLD=$(tput bold); DIM=$(tput dim); RESET=$(tput sgr0)
17
+ BLUE=$(tput setaf 4); GREEN=$(tput setaf 2); YELLOW=$(tput setaf 3); RED=$(tput setaf 1)
18
+ else
19
+ BOLD=""; DIM=""; RESET=""; BLUE=""; GREEN=""; YELLOW=""; RED=""
20
+ fi
21
+
22
+ # Author sets these two at the top of the stages section.
23
+ TOTAL_STAGES=0
24
+ TOTAL_MINUTES=0
25
+
26
+ _STAGE_INDEX=0
27
+ _MINUTES_ELAPSED=0
28
+ ENV_FILE="${ENV_FILE:-.env}"
29
+ WRITTEN_ENV=() # KEYs written to ENV_FILE this run
30
+ WRITTEN_SECRET=() # secret NAMEs set this run
31
+ SKIPPED=() # things we couldn't do (e.g. gh missing)
32
+
33
+ # _clear — wipe the terminal so only the current step is on screen. No-op when
34
+ # output isn't a terminal, so piped logs stay readable.
35
+ _clear() {
36
+ [[ -t 1 ]] || return 0
37
+ if command -v tput >/dev/null 2>&1; then tput clear; else printf '\033[2J\033[3J\033[H'; fi
38
+ }
39
+
40
+ # banner "Title" — opening frame: what this wizard does and how long it takes.
41
+ banner() {
42
+ _clear
43
+ printf '\n%s%s %s%s\n' "$BOLD" "$BLUE" "$1" "$RESET"
44
+ printf '%s %s stages · about %s minutes%s\n\n' \
45
+ "$DIM" "$TOTAL_STAGES" "$TOTAL_MINUTES" "$RESET"
46
+ printf '%s You drive the browser; this wizard tells you exactly what to do and\n' "$DIM"
47
+ printf ' captures the values you copy back. Stop any time with Ctrl-C and re-run\n'
48
+ printf ' later — it remembers values already saved.%s\n' "$RESET"
49
+ pause "Ready to start?"
50
+ }
51
+
52
+ # stage "Name" <minutes> — clear the screen, then announce a stage and show
53
+ # progress + time remaining. Clearing keeps only the current step on screen.
54
+ stage() {
55
+ _clear
56
+ _STAGE_INDEX=$((_STAGE_INDEX + 1))
57
+ local remaining=$((TOTAL_MINUTES - _MINUTES_ELAPSED))
58
+ (( remaining < 0 )) && remaining=0
59
+ _MINUTES_ELAPSED=$((_MINUTES_ELAPSED + ${2:-0}))
60
+ printf '\n%s%s▸ Stage %s/%s · %s%s %s(~%s min left)%s\n' \
61
+ "$BOLD" "$BLUE" "$_STAGE_INDEX" "$TOTAL_STAGES" "$1" "$RESET" "$DIM" "$remaining" "$RESET"
62
+ }
63
+
64
+ # say "..." — a plain instruction line.
65
+ say() { printf ' %s\n' "$1"; }
66
+ # step "..." — a numbered-feeling action the human takes in the browser.
67
+ step() { printf ' %s•%s %s\n' "$BLUE" "$RESET" "$1"; }
68
+ note() { printf ' %s%s%s\n' "$DIM" "$1" "$RESET"; }
69
+ warn() { printf ' %s⚠ %s%s\n' "$YELLOW" "$1" "$RESET"; }
70
+
71
+ # open_url URL — open in the human's browser, cross-platform incl. WSL.
72
+ open_url() {
73
+ local url="$1"
74
+ printf ' %s↗ opening%s %s\n' "$GREEN" "$RESET" "$url"
75
+ { if command -v wslview >/dev/null 2>&1; then wslview "$url"
76
+ elif command -v explorer.exe >/dev/null 2>&1; then explorer.exe "$url"
77
+ elif command -v xdg-open >/dev/null 2>&1; then xdg-open "$url"
78
+ elif command -v open >/dev/null 2>&1; then open "$url"
79
+ else warn "couldn't open a browser — visit it manually: $url"; fi
80
+ } >/dev/null 2>&1 || warn "couldn't open a browser — visit it manually: $url"
81
+ }
82
+
83
+ # pause "msg" — wait for the human to confirm they've done the manual part.
84
+ pause() {
85
+ printf ' %s%s%s ' "$DIM" "${1:-Press Enter to continue}" "$RESET"
86
+ read -r _ || true
87
+ }
88
+
89
+ # confirm "question" — y/N gate; returns success on yes.
90
+ confirm() {
91
+ local reply=""
92
+ printf ' %s? %s [y/N] ' "$YELLOW" "$1"
93
+ read -r reply || true
94
+ [[ "$reply" =~ ^[Yy] ]]
95
+ }
96
+
97
+ # _existing KEY — current value of KEY in ENV_FILE, if any.
98
+ _existing() {
99
+ [[ -f "$ENV_FILE" ]] || return 1
100
+ local line; line=$(grep -E "^${1}=" "$ENV_FILE" | tail -n1) || return 1
101
+ printf '%s' "${line#*=}"
102
+ }
103
+
104
+ # ask KEY "Prompt" — read a value into $KEY. Offers the existing .env value as
105
+ # a default on re-runs (Enter keeps it). Visible input (non-secret).
106
+ ask() {
107
+ local key="$1" prompt="$2" current input
108
+ current=$(_existing "$key" || true)
109
+ if [[ -n "$current" ]]; then
110
+ printf ' %s%s%s %s[Enter keeps current]%s ' "$BOLD" "$prompt" "$RESET" "$DIM" "$RESET"
111
+ else
112
+ printf ' %s%s%s ' "$BOLD" "$prompt" "$RESET"
113
+ fi
114
+ read -r input || true
115
+ [[ -z "$input" && -n "$current" ]] && input="$current"
116
+ printf -v "$key" '%s' "$input"
117
+ }
118
+
119
+ # ask_secret KEY "Prompt" — like ask, but input is hidden.
120
+ ask_secret() {
121
+ local key="$1" prompt="$2" current input
122
+ current=$(_existing "$key" || true)
123
+ if [[ -n "$current" ]]; then
124
+ printf ' %s%s%s %s[Enter keeps current]%s ' "$BOLD" "$prompt" "$RESET" "$DIM" "$RESET"
125
+ else
126
+ printf ' %s%s%s ' "$BOLD" "$prompt" "$RESET"
127
+ fi
128
+ read -rs input || true
129
+ printf '\n'
130
+ [[ -z "$input" && -n "$current" ]] && input="$current"
131
+ printf -v "$key" '%s' "$input"
132
+ }
133
+
134
+ # write_env KEY VALUE — upsert KEY=VALUE into ENV_FILE (creates it; replaces
135
+ # any existing line). Idempotent.
136
+ write_env() {
137
+ local key="$1" value="$2" tmp
138
+ touch "$ENV_FILE"
139
+ tmp=$(mktemp)
140
+ grep -vE "^${key}=" "$ENV_FILE" > "$tmp" || true
141
+ printf '%s=%s\n' "$key" "$value" >> "$tmp"
142
+ mv "$tmp" "$ENV_FILE"
143
+ WRITTEN_ENV+=("$key")
144
+ printf ' %s✓ wrote%s %s → %s\n' "$GREEN" "$RESET" "$key" "$ENV_FILE"
145
+ }
146
+
147
+ # set_secret NAME VALUE — set a GitHub Actions repo secret via gh. Falls back
148
+ # to a warning (and records it) if gh is unavailable or unauthenticated.
149
+ set_secret() {
150
+ local name="$1" value="$2"
151
+ if command -v gh >/dev/null 2>&1 && gh auth status >/dev/null 2>&1; then
152
+ if printf '%s' "$value" | gh secret set "$name" >/dev/null 2>&1; then
153
+ WRITTEN_SECRET+=("$name")
154
+ printf ' %s✓ set%s GitHub secret %s\n' "$GREEN" "$RESET" "$name"
155
+ return
156
+ fi
157
+ fi
158
+ SKIPPED+=("GitHub secret $name (set it manually: gh secret set $name)")
159
+ warn "skipped GitHub secret $name — gh not ready; set it later"
160
+ }
161
+
162
+ # set_var NAME VALUE — set a GitHub Actions repo variable (non-secret).
163
+ set_var() {
164
+ local name="$1" value="$2"
165
+ if command -v gh >/dev/null 2>&1 && gh auth status >/dev/null 2>&1; then
166
+ if gh variable set "$name" --body "$value" >/dev/null 2>&1; then
167
+ printf ' %s✓ set%s GitHub variable %s\n' "$GREEN" "$RESET" "$name"
168
+ return
169
+ fi
170
+ fi
171
+ SKIPPED+=("GitHub variable $name")
172
+ warn "skipped GitHub variable $name — gh not ready; set it later"
173
+ }
174
+
175
+ # finish — clear, then a closing summary of everything configured.
176
+ finish() {
177
+ _clear
178
+ printf '\n%s%s ✓ Setup complete%s\n' "$BOLD" "$GREEN" "$RESET"
179
+ (( ${#WRITTEN_ENV[@]} )) && note "wrote ${#WRITTEN_ENV[@]} value(s) to $ENV_FILE: ${WRITTEN_ENV[*]}"
180
+ (( ${#WRITTEN_SECRET[@]} )) && note "set ${#WRITTEN_SECRET[@]} GitHub secret(s): ${WRITTEN_SECRET[*]}"
181
+ if (( ${#SKIPPED[@]} )); then
182
+ printf '\n'; warn "still to do by hand:"
183
+ for s in "${SKIPPED[@]}"; do note " - $s"; done
184
+ fi
185
+ printf '\n'
186
+ }
187
+
188
+ # ──────────────────────────────────────────────────────────────────────────
189
+ # STAGES — author this section. One stage() per step the human takes.
190
+ # Replace the example below. Set the two totals to match the stages you write.
191
+ # ──────────────────────────────────────────────────────────────────────────
192
+
193
+ TOTAL_STAGES=1
194
+ TOTAL_MINUTES=5
195
+
196
+ banner "Stripe setup"
197
+
198
+ # ── Example stage: replace with your real steps ───────────────────────────
199
+ stage "Stripe — API keys" 5
200
+ say "We'll grab your Stripe test keys and store them for local dev + CI."
201
+ open_url "https://dashboard.stripe.com/test/apikeys"
202
+ step "On the API keys page, copy the Publishable key (starts pk_test_)."
203
+ ask STRIPE_PUBLISHABLE_KEY "Paste the publishable key:"
204
+ step "Click 'Reveal test key' on the Secret key row, then copy it."
205
+ ask_secret STRIPE_SECRET_KEY "Paste the secret key:"
206
+ write_env STRIPE_PUBLISHABLE_KEY "$STRIPE_PUBLISHABLE_KEY"
207
+ write_env STRIPE_SECRET_KEY "$STRIPE_SECRET_KEY"
208
+ set_secret STRIPE_SECRET_KEY "$STRIPE_SECRET_KEY" # CI needs this one
209
+ # ──────────────────────────────────────────────────────────────────────────
210
+
211
+ finish
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env bash
2
+ # Graph-mode memory plumbing for zoom-out.
3
+ # Source only; do not execute directly. Called by zoom-out Gather Context
4
+ # when Memory is available. All reads only — no writes, no ingest, no reindex.
5
+
6
+ _zoom_out_focus_label="<skill/module/file/concept label from the user's request, or empty>"
7
+ _zoom_out_path_from="<first explicitly named skill/module/file/concept, or empty>"
8
+ _zoom_out_path_to="<second explicitly named skill/module/file/concept, or empty>"
9
+ _zoom_out_target_file="<focused file path when the user's request names one, or empty>"
10
+ _zoom_out_target_symbol="<focused symbol name when the user's request names one, or empty>"
11
+ if { [ -f .red/config.yaml ] && grep -qE '^[[:space:]]+memory:' .red/config.yaml; } || [ -f .red/memory/config.json ]; then
12
+ _bridge="${CLAUDE_PLUGIN_ROOT:-}/scripts/memory-bridge.sh"
13
+ [ -f "$_bridge" ] || _bridge="$(git rev-parse --show-toplevel 2>/dev/null)/plugins/dev/scripts/memory-bridge.sh"
14
+ if [ -f "$_bridge" ] && source "$_bridge"; then
15
+ MEMORY_REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null)"
16
+ _memory_mode="$(memory_mode . 2>/dev/null || printf 'unavailable\n')"
17
+ if [ "$_memory_mode" = "graph" ]; then
18
+ if memory_graph_ready .; then
19
+ if [ -n "$_zoom_out_path_from" ] && [ -n "$_zoom_out_path_to" ]; then
20
+ memory_path . "$_zoom_out_path_from" "$_zoom_out_path_to" bfs
21
+ fi
22
+ if [ -n "$_zoom_out_target_file" ] || [ -n "$_zoom_out_target_symbol" ]; then
23
+ memory_structural_impact . "$_zoom_out_target_file" "$_zoom_out_target_symbol"
24
+ fi
25
+ if [ -n "$_zoom_out_focus_label" ]; then
26
+ memory_neighbors . "$_zoom_out_focus_label" 1 both
27
+ fi
28
+ memory_recall . "<2-6 keywords for the code area>"
29
+ else
30
+ _zoom_out_memory_ingest_hint=1
31
+ fi
32
+ else
33
+ memory_recall . "<2-6 keywords for the code area>"
34
+ fi
35
+ fi
36
+ fi
@@ -0,0 +1,168 @@
1
+ #!/usr/bin/env bash
2
+ # Contract test for the zoom-out SKILL.md.
3
+ #
4
+ # Asserts the Answer Contract carries an optional Impact section between
5
+ # Relationships and Critical Paths, defines structural impact in the
6
+ # expected terms, requires graph evidence be interpreted (not pasted raw),
7
+ # stays read-only, and does not introduce a new /impact skill or a
8
+ # memory_impact primitive (issue #97, parent #95).
9
+
10
+ set -euo pipefail
11
+
12
+ HERE="$(cd "$(dirname "$0")" && pwd)"
13
+ SKILL_MD="$HERE/../../SKILL.md"
14
+
15
+ if [ ! -f "$SKILL_MD" ]; then
16
+ echo "FAIL SKILL.md not found at $SKILL_MD" >&2
17
+ exit 1
18
+ fi
19
+
20
+ pass=0
21
+ fail=0
22
+
23
+ # absent(needle): assert the literal string does NOT appear anywhere in SKILL.md.
24
+ absent() {
25
+ local label="$1" needle="$2"
26
+ if grep -qF "$needle" "$SKILL_MD"; then
27
+ echo "FAIL $label (forbidden text present: $needle)" >&2
28
+ fail=$((fail + 1))
29
+ else
30
+ echo "ok $label"
31
+ pass=$((pass + 1))
32
+ fi
33
+ }
34
+
35
+ # present(needle): assert the literal string DOES appear.
36
+ present() {
37
+ local label="$1" needle="$2"
38
+ if grep -qF "$needle" "$SKILL_MD"; then
39
+ echo "ok $label"
40
+ pass=$((pass + 1))
41
+ else
42
+ echo "FAIL $label (missing: $needle)" >&2
43
+ fail=$((fail + 1))
44
+ fi
45
+ }
46
+
47
+ # present_re(regex): assert the extended regex matches.
48
+ present_re() {
49
+ local label="$1" re="$2"
50
+ if grep -Eq "$re" "$SKILL_MD"; then
51
+ echo "ok $label"
52
+ pass=$((pass + 1))
53
+ else
54
+ echo "FAIL $label (regex did not match: $re)" >&2
55
+ fail=$((fail + 1))
56
+ fi
57
+ }
58
+
59
+ # --- Section order: Relationships -> Impact -> Critical Paths ----------
60
+
61
+ rel_line="$(grep -n '^2\. \*\*Relationships\*\*' "$SKILL_MD" | head -1 | cut -d: -f1 || true)"
62
+ imp_line="$(grep -n '^3\. \*\*Impact\*\*' "$SKILL_MD" | head -1 | cut -d: -f1 || true)"
63
+ crit_line="$(grep -n '^4\. \*\*Critical Paths\*\*' "$SKILL_MD" | head -1 | cut -d: -f1 || true)"
64
+ risk_line="$(grep -n '^5\. \*\*Risks/Gaps\*\*' "$SKILL_MD" | head -1 | cut -d: -f1 || true)"
65
+
66
+ if [ -n "$rel_line" ] && [ -n "$imp_line" ] && [ -n "$crit_line" ] && [ -n "$risk_line" ] \
67
+ && [ "$rel_line" -lt "$imp_line" ] \
68
+ && [ "$imp_line" -lt "$crit_line" ] \
69
+ && [ "$crit_line" -lt "$risk_line" ]; then
70
+ echo "ok contract lists Relationships < Impact < Critical Paths < Risks/Gaps"
71
+ pass=$((pass + 1))
72
+ else
73
+ echo "FAIL contract section order broken (rel=$rel_line imp=$imp_line crit=$crit_line risk=$risk_line)" >&2
74
+ fail=$((fail + 1))
75
+ fi
76
+
77
+ # Impact must be advertised as optional.
78
+ present_re "Impact is optional" '3\. \*\*Impact\*\*.*optional'
79
+
80
+ # --- Structural impact vocabulary --------------------------------------
81
+
82
+ present "Impact mentions imports" "**imports**"
83
+ present "Impact mentions calls" "**calls**"
84
+ present "Impact mentions containment" "**containment**"
85
+ present "Impact mentions type-use" "**type-use**"
86
+ present "Impact mentions docs links" "**docs links**"
87
+ present "Impact mentions graph neighbors/paths" "**graph neighbors/paths**"
88
+
89
+ # --- Verification against the current worktree -------------------------
90
+
91
+ present_re "Impact requires worktree verification" "verified against the current worktree"
92
+
93
+ # --- Graph-backed structural impact reader -----------------------------
94
+
95
+ present "Gather Context names target file variable" "_zoom_out_target_file"
96
+ present "Gather Context names target symbol variable" "_zoom_out_target_symbol"
97
+ present "Gather Context calls structural-impact helper" "memory_structural_impact"
98
+ present "Gather Context names structural-impact-reader" "structural-impact-reader"
99
+ present_re "Structural Impact consults graph before fallback" "before falling back to ordinary codebase exploration"
100
+ present_re "Structural Impact includes graph-derived import evidence when available" "imports, importers, definitions, and containing files"
101
+ present_re "Structural Impact degrades cleanly when graph evidence is empty" "behave identically to today's ad-hoc file-reading path"
102
+
103
+ # --- Interpret graph evidence, no raw dumps ----------------------------
104
+
105
+ present_re "Impact requires interpretation over raw graph output" "Interpret graph or recall evidence into project terms"
106
+ present_re "Impact forbids raw nodes/edges/paths/recall dump" "do \*\*not\*\* paste raw nodes, edges, paths, recall output"
107
+
108
+ # --- Read-only, no ingest / reindex / graph writes ---------------------
109
+
110
+ present_re "Impact is read-only" "This section is \*\*read-only\*\*"
111
+ present_re "Impact forbids ingest/reindex/graph writes" "must not run .*memory:ingest.*reindex.*graph-write"
112
+ present_re "answer-wide read-only restatement" "The entire .zoom-out. answer is read-only"
113
+
114
+ # --- No new /impact skill or memory_impact primitive -------------------
115
+
116
+ present_re "contract forbids new /impact skill" "must not (create or reference|introduce).*/impact"
117
+ present_re "contract forbids memory_impact primitive" "memory_impact"
118
+
119
+ # A memory_impact mention is only allowed in the *forbidding* clauses.
120
+ # Make sure it never shows up as a callable primitive invocation.
121
+ if grep -Eq '^[[:space:]]*memory_impact\b|`memory_impact `|\$\(memory_impact' "$SKILL_MD"; then
122
+ echo "FAIL memory_impact appears as an invocation, not just a prohibition" >&2
123
+ fail=$((fail + 1))
124
+ else
125
+ echo "ok memory_impact is not invoked anywhere"
126
+ pass=$((pass + 1))
127
+ fi
128
+
129
+ # Same guard for a "/impact" skill invocation (allowed only in prohibitions).
130
+ if grep -Eq '(invoke|run|call|use) /impact\b' "$SKILL_MD"; then
131
+ echo "FAIL /impact appears as an invocation, not just a prohibition" >&2
132
+ fail=$((fail + 1))
133
+ else
134
+ echo "ok /impact skill is not invoked anywhere"
135
+ pass=$((pass + 1))
136
+ fi
137
+
138
+ # --- Structural vs observed impact split (issue #100) ------------------
139
+
140
+ present "Impact names Structural impact sub-bullet" "**Structural impact**"
141
+ present "Impact names Observed impact sub-bullet" "**Observed impact**"
142
+ present_re "Impact separates structural from observed" "separate structural impact from observed impact"
143
+
144
+ # --- Observed-impact vocabulary ----------------------------------------
145
+
146
+ present "Observed impact cites Reasoning attempts" "**Reasoning attempts**"
147
+ present "Observed impact cites touched-together files" "**touched together**"
148
+ present "Observed impact cites repeated failures" "**repeated**"
149
+ present "Observed impact cites retry chains" "**retry chains**"
150
+ present "Observed impact cites validation summaries" "**validation summaries**"
151
+ present_re "Observed impact frames evidence as operational history" "operational history"
152
+ present_re "Observed impact is not authoritative product direction" "not authoritative product (direction|requirements)"
153
+
154
+ # --- Graceful degradation ----------------------------------------------
155
+
156
+ present_re "Impact degrades cleanly when attempt evidence is absent" "degrade cleanly"
157
+ present_re "Impact falls back to structural-only when attempts are missing" "drop the Observed impact sub-bullet"
158
+
159
+ # --- No raw graph dump, attempts included ------------------------------
160
+
161
+ present_re "Impact forbids raw attempt-record dumps" "do \*\*not\*\* paste raw nodes, edges, paths, recall output, attempt records"
162
+
163
+ # --- Summary -----------------------------------------------------------
164
+
165
+ echo
166
+ echo "passed: $pass"
167
+ echo "failed: $fail"
168
+ [ "$fail" -eq 0 ]