@reddb-io/red-skills 4.4.1 → 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 +1 -1
  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,230 @@
1
+ #!/usr/bin/env bash
2
+ # memory-bridge.sh — dev's soft, optional bridge to the `memory` plugin (issue #57, PRD #49).
3
+ #
4
+ # The `memory` plugin lives ON TOP of `dev` and improves its processes
5
+ # (`/afk` recall, `/triage` dedup, `/diagnose` history). The dependency is
6
+ # strictly one-directional: `memory` hard-requires `dev`; `dev` only ever
7
+ # *soft-uses* `memory`. So everything here degrades to a SILENT NO-OP — exit 0,
8
+ # no output — when memory is absent or uninitialized. `dev` never hard-depends
9
+ # on `memory`, and sourcing this file must never change behaviour for a repo
10
+ # that has not run `/memory:init`.
11
+ #
12
+ # Detection has two independent gates, both required:
13
+ # 1. the project opted in — `.red/memory/config.json` exists under the repo root;
14
+ # 2. a memory CLI resolves — via $RED_MEMORY_CLI, a `memory` bin on PATH, a
15
+ # sibling-plugin dist build, or an in-repo checkout.
16
+ #
17
+ # Source it, then call `memory_available <root>` to gate, `memory_neighbors
18
+ # <root> <label>` for focused graph context, `memory_structural_impact <root>
19
+ # <file> <symbol>` for graph-derived change impact, `memory_path <root> <from>
20
+ # <to>` for relationship paths, `memory_recall <root> <query…>` to fetch a
21
+ # ready-to-fold context block (or nothing), or `memory_record_attempt <root>
22
+ # <payload-json-file>` to best-effort write an AFK terminal attempt.
23
+
24
+ # Resolve the memory CLI invocation into the global MEMORY_CLI array.
25
+ # Returns 0 and populates MEMORY_CLI on success; returns 1 (MEMORY_CLI empty)
26
+ # when no usable CLI is found. Pure resolution — does not execute anything.
27
+ _memory_resolve_cli() {
28
+ MEMORY_CLI=()
29
+
30
+ # 1. Explicit override — an absolute path to the built cli.js. Highest
31
+ # priority so a host can pin the exact binary regardless of layout.
32
+ if [[ -n "${RED_MEMORY_CLI:-}" ]]; then
33
+ if [[ -f "${RED_MEMORY_CLI}" ]]; then
34
+ MEMORY_CLI=(node "${RED_MEMORY_CLI}")
35
+ return 0
36
+ fi
37
+ return 1
38
+ fi
39
+
40
+ if command -v red-skills-memory >/dev/null 2>&1; then
41
+ MEMORY_CLI=(red-skills-memory)
42
+ return 0
43
+ fi
44
+
45
+ # 2. A `memory` bin on PATH (the plugin's package.json `bin`).
46
+ if command -v memory >/dev/null 2>&1; then
47
+ MEMORY_CLI=(memory)
48
+ return 0
49
+ fi
50
+
51
+ # 3. Dynamic-fetch cache bundle. In a real (cache) install there is no built
52
+ # dist; the memory plugin's bootstrap.mjs (ADR 0029) fetches the bundled CLI
53
+ # into a version-keyed cache at <runtimeRoot>/<version>/memory-cli.mjs, where
54
+ # runtimeRoot = <RED_MEMORY_CACHE_DIR | XDG_CACHE_HOME | ~/.cache>/reddb-memory.
55
+ # Resolve the memory plugin's version from its manifest (sibling of dev or the
56
+ # in-repo checkout) and use the cached bundle if present.
57
+ local mem_manifest mem_ver runtime_root cache_cli
58
+ for mem_manifest in \
59
+ "${CLAUDE_PLUGIN_ROOT:-}/../memory/.claude-plugin/plugin.json" \
60
+ "${MEMORY_REPO_ROOT:-}/plugins/memory/.claude-plugin/plugin.json"; do
61
+ [[ -f "$mem_manifest" ]] || continue
62
+ mem_ver="$(node -e "process.stdout.write(require(process.argv[1]).version)" "$mem_manifest" 2>/dev/null)"
63
+ [[ -n "$mem_ver" ]] || continue
64
+ runtime_root="${RED_MEMORY_CACHE_DIR:-${XDG_CACHE_HOME:-$HOME/.cache}}/reddb-memory"
65
+ cache_cli="$runtime_root/$mem_ver/memory-cli.mjs"
66
+ if [[ -f "$cache_cli" ]]; then
67
+ MEMORY_CLI=(node "$cache_cli")
68
+ return 0
69
+ fi
70
+ done
71
+
72
+ # 4 & 5. Built dist of a sibling/in-repo memory plugin (dev checkout only).
73
+ # CLAUDE_PLUGIN_ROOT points at the *dev* plugin when a dev skill runs; the
74
+ # memory plugin is installed alongside it. MEMORY_REPO_ROOT covers the
75
+ # in-repo checkout (this monorepo) where both plugins live under plugins/.
76
+ local cand
77
+ for cand in \
78
+ "${CLAUDE_PLUGIN_ROOT:-}/../memory/dist/cli.js" \
79
+ "${MEMORY_REPO_ROOT:-}/plugins/memory/dist/cli.js"; do
80
+ if [[ "$cand" != "/../memory/dist/cli.js" && "$cand" != "/plugins/memory/dist/cli.js" && -f "$cand" ]]; then
81
+ MEMORY_CLI=(node "$cand")
82
+ return 0
83
+ fi
84
+ done
85
+
86
+ return 1
87
+ }
88
+
89
+ # memory_available <root> — 0 iff memory is opted-in for <root> AND a CLI resolves.
90
+ # <root> defaults to $PWD. Never prints anything.
91
+ memory_available() {
92
+ local root="${1:-$PWD}"
93
+ [[ -f "$root/.red/memory/config.json" ]] || return 1
94
+ _memory_resolve_cli || return 1
95
+ return 0
96
+ }
97
+
98
+ # memory_mode <root> — print the configured storage mode, or "unavailable" when
99
+ # memory has not been initialized or the config cannot be read. This is a local
100
+ # config read only; it does not require the memory CLI.
101
+ memory_mode() {
102
+ local root="${1:-$PWD}"
103
+ local config="$root/.red/memory/config.json"
104
+ [[ -f "$config" ]] || {
105
+ printf 'unavailable\n'
106
+ return 0
107
+ }
108
+
109
+ local mode
110
+ mode="$(sed -nE 's/.*"mode"[[:space:]]*:[[:space:]]*"([^"]+)".*/\1/p' "$config" 2>/dev/null | head -n 1)"
111
+ if [[ -n "$mode" ]]; then
112
+ printf '%s\n' "$mode"
113
+ else
114
+ printf 'unavailable\n'
115
+ fi
116
+ return 0
117
+ }
118
+
119
+ # memory_graph_ready <root> — 0 iff memory is configured for graph mode, a CLI
120
+ # resolves, and the graph read surface reports at least one node. Never prints
121
+ # anything; failures/errors are an absent optimization for dev callers.
122
+ memory_graph_ready() {
123
+ local root="${1:-$PWD}"
124
+ [[ "$(memory_mode "$root")" == "graph" ]] || return 1
125
+ _memory_resolve_cli || return 1
126
+
127
+ local out nodes
128
+ out="$("${MEMORY_CLI[@]}" stats --root "$root" 2>/dev/null)" || return 1
129
+ nodes="$(printf '%s\n' "$out" | sed -nE 's/^[^0-9]*([0-9]+)[[:space:]]+node\(s\).*/\1/p' | head -n 1)"
130
+ [[ -n "$nodes" && "$nodes" -gt 0 ]] || return 1
131
+ return 0
132
+ }
133
+
134
+ # memory_neighbors <root> <label> [depth] [direction] — print the graph
135
+ # neighborhood for a focused label, or nothing. ALWAYS returns 0: absent,
136
+ # markdown-only, empty, or erroring graph reads are an optimization miss, not a
137
+ # failure of the calling dev process.
138
+ memory_neighbors() {
139
+ local root="${1:-$PWD}"
140
+ local label="${2:-}"
141
+ local depth="${3:-1}"
142
+ local direction="${4:-both}"
143
+ [[ -n "$label" ]] || return 0
144
+ memory_graph_ready "$root" || return 0
145
+
146
+ local out
147
+ out="$("${MEMORY_CLI[@]}" neighbors "$label" --root "$root" --depth "$depth" --direction "$direction" 2>/dev/null)" || return 0
148
+ [[ -n "$out" ]] || return 0
149
+ printf '%s\n' "$out" | grep -Eq '^memory: 0 neighbor\(s\)' && return 0
150
+ printf '%s\n' "$out"
151
+ return 0
152
+ }
153
+
154
+ # memory_path <root> <from> <to> [algorithm] — print a graph path between two
155
+ # focused labels, or nothing. ALWAYS returns 0: absent, markdown-only, no-path,
156
+ # empty, or erroring graph reads are an optimization miss, not a failure of the
157
+ # calling dev process.
158
+ memory_path() {
159
+ local root="${1:-$PWD}"
160
+ local from="${2:-}"
161
+ local to="${3:-}"
162
+ local algorithm="${4:-bfs}"
163
+ [[ -n "$from" && -n "$to" ]] || return 0
164
+ memory_graph_ready "$root" || return 0
165
+
166
+ local out
167
+ out="$("${MEMORY_CLI[@]}" path "$from" "$to" --root "$root" --algorithm "$algorithm" 2>/dev/null)" || return 0
168
+ [[ -n "$out" ]] || return 0
169
+ printf '%s\n' "$out" | grep -Eq '^memory: no path from ' && return 0
170
+ printf '%s\n' "$out"
171
+ return 0
172
+ }
173
+
174
+ # memory_structural_impact <root> <file> <symbol> — print graph-derived
175
+ # structural impact evidence for a focused file/symbol, or nothing. ALWAYS
176
+ # returns 0: absent, markdown-only, empty graph, unknown target, or errors are
177
+ # an optimization miss, not a failure of the calling dev process.
178
+ memory_structural_impact() {
179
+ local root="${1:-$PWD}"
180
+ local file="${2:-}"
181
+ local symbol="${3:-}"
182
+ [[ -n "$file" || -n "$symbol" ]] || return 0
183
+ memory_graph_ready "$root" || return 0
184
+
185
+ local args=()
186
+ [[ -n "$file" ]] && args+=(--file "$file")
187
+ [[ -n "$symbol" ]] && args+=(--symbol "$symbol")
188
+
189
+ local out
190
+ out="$("${MEMORY_CLI[@]}" structural-impact --root "$root" "${args[@]}" 2>/dev/null)" || return 0
191
+ [[ -n "$out" ]] || return 0
192
+ printf '%s\n' "$out" | grep -Eq '^memory: no structural impact for ' && return 0
193
+ printf '%s\n' "$out"
194
+ return 0
195
+ }
196
+
197
+ # memory_recall <root> <query…> — print a recall context block for the query,
198
+ # or nothing. ALWAYS returns 0: a missing/uninitialized/erroring memory is not a
199
+ # failure of the calling dev process, just an absent optimization.
200
+ memory_recall() {
201
+ local root="$1"
202
+ shift
203
+ [[ $# -gt 0 ]] || return 0
204
+ memory_available "$root" || return 0
205
+ local out
206
+ out="$("${MEMORY_CLI[@]}" recall "$@" 2>/dev/null)" || return 0
207
+ [[ -n "$out" ]] && printf '%s\n' "$out"
208
+ return 0
209
+ }
210
+
211
+ # memory_record_attempt <root> <payload-json-file> — best-effort write of one
212
+ # AFK terminal attempt into graph Memory. ALWAYS returns 0: absent,
213
+ # uninitialized, markdown-only, CLI-missing, invalid payload, or write-failing
214
+ # Memory must not affect the dev caller's terminal outcome.
215
+ memory_record_attempt() {
216
+ local root="${1:-$PWD}"
217
+ local payload_file="${2:-}"
218
+ [[ -f "$payload_file" ]] || return 0
219
+ [[ "$(memory_mode "$root")" == "graph" ]] || return 0
220
+ _memory_resolve_cli || return 0
221
+
222
+ if command -v timeout >/dev/null 2>&1; then
223
+ timeout --kill-after=5s 30s "${MEMORY_CLI[@]}" attempt record --root "$root" \
224
+ < "$payload_file" >/dev/null 2>&1 || true
225
+ else
226
+ "${MEMORY_CLI[@]}" attempt record --root "$root" \
227
+ < "$payload_file" >/dev/null 2>&1 || true
228
+ fi
229
+ return 0
230
+ }
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ REPO="$(cd "$(dirname "$0")/../../.." && pwd)"
5
+ cd "$REPO"
6
+
7
+ node scripts/plugin-structural-smoke.mjs plugins/dev