cleargate 0.2.0 → 0.3.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.
- package/LICENSE +21 -0
- package/dist/MANIFEST.json +59 -17
- package/dist/admin-api/index.cjs +88 -1
- package/dist/admin-api/index.cjs.map +1 -1
- package/dist/admin-api/index.d.cts +105 -1
- package/dist/admin-api/index.d.ts +105 -1
- package/dist/admin-api/index.js +77 -1
- package/dist/admin-api/index.js.map +1 -1
- package/dist/bootstrap-root-FGWDICDT.js +130 -0
- package/dist/bootstrap-root-FGWDICDT.js.map +1 -0
- package/dist/chunk-OM4FAEA7.js +184 -0
- package/dist/chunk-OM4FAEA7.js.map +1 -0
- package/dist/cli.cjs +7995 -3984
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +4062 -561
- package/dist/cli.js.map +1 -1
- package/dist/templates/cleargate-planning/.claude/agents/architect.md +72 -0
- package/dist/templates/cleargate-planning/.claude/agents/developer.md +45 -3
- package/dist/templates/cleargate-planning/.claude/agents/qa.md +7 -3
- package/dist/templates/cleargate-planning/.claude/agents/reporter.md +72 -75
- package/dist/templates/cleargate-planning/.claude/hooks/pending-task-sentinel.sh +204 -0
- package/dist/templates/cleargate-planning/.claude/hooks/pre-commit-surface-gate.sh +10 -0
- package/dist/templates/cleargate-planning/.claude/hooks/pre-commit-test-ratchet.sh +58 -0
- package/dist/templates/cleargate-planning/.claude/hooks/pre-commit.sh +19 -0
- package/dist/templates/cleargate-planning/.claude/hooks/session-start.sh +51 -0
- package/dist/templates/cleargate-planning/.claude/hooks/token-ledger.sh +1 -1
- package/dist/templates/cleargate-planning/.claude/settings.json +11 -0
- package/dist/templates/cleargate-planning/.claude/skills/flashcard/SKILL.md +31 -12
- package/dist/templates/cleargate-planning/.cleargate/FLASHCARD.md +2 -1
- package/dist/templates/cleargate-planning/.cleargate/config.example.yml +37 -0
- package/dist/templates/cleargate-planning/.cleargate/knowledge/cleargate-protocol.md +407 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/assert_story_files.mjs +146 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/close_sprint.mjs +250 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/constants.mjs +57 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/file_surface_diff.sh +320 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/gate-checks.json +15 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/init_gate_config.sh +38 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/init_sprint.mjs +187 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/pre_gate_common.sh +132 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/pre_gate_runner.sh +307 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/prefill_report.mjs +280 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/run_script.sh +123 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/state.schema.json +110 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/suggest_improvements.mjs +247 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/surface-whitelist.txt +27 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/test/test_assert_story_files.sh +261 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/test/test_file_surface.sh +210 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/test/test_flashcard_gate.sh +190 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/test/test_test_ratchet.sh +327 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/test_ratchet.mjs +261 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/update_state.mjs +154 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/validate_bounce_readiness.mjs +111 -0
- package/dist/templates/cleargate-planning/.cleargate/scripts/validate_state.mjs +164 -0
- package/dist/templates/cleargate-planning/.cleargate/templates/Bug.md +9 -0
- package/dist/templates/cleargate-planning/.cleargate/templates/CR.md +9 -0
- package/dist/templates/cleargate-planning/.cleargate/templates/Sprint Plan Template.md +29 -3
- package/dist/templates/cleargate-planning/.cleargate/templates/epic.md +9 -0
- package/dist/templates/cleargate-planning/.cleargate/templates/proposal.md +9 -0
- package/dist/templates/cleargate-planning/.cleargate/templates/sprint_context.md +42 -0
- package/dist/templates/cleargate-planning/.cleargate/templates/sprint_report.md +175 -0
- package/dist/templates/cleargate-planning/.cleargate/templates/story.md +29 -0
- package/dist/templates/cleargate-planning/CLAUDE.md +3 -0
- package/dist/templates/cleargate-planning/MANIFEST.json +59 -17
- package/dist/whoami-CX7CXJD5.js +76 -0
- package/dist/whoami-CX7CXJD5.js.map +1 -0
- package/package.json +6 -2
- package/templates/cleargate-planning/.claude/agents/architect.md +72 -0
- package/templates/cleargate-planning/.claude/agents/developer.md +45 -3
- package/templates/cleargate-planning/.claude/agents/qa.md +7 -3
- package/templates/cleargate-planning/.claude/agents/reporter.md +72 -75
- package/templates/cleargate-planning/.claude/hooks/pending-task-sentinel.sh +204 -0
- package/templates/cleargate-planning/.claude/hooks/pre-commit-surface-gate.sh +10 -0
- package/templates/cleargate-planning/.claude/hooks/pre-commit-test-ratchet.sh +58 -0
- package/templates/cleargate-planning/.claude/hooks/pre-commit.sh +19 -0
- package/templates/cleargate-planning/.claude/hooks/session-start.sh +51 -0
- package/templates/cleargate-planning/.claude/hooks/token-ledger.sh +1 -1
- package/templates/cleargate-planning/.claude/settings.json +11 -0
- package/templates/cleargate-planning/.claude/skills/flashcard/SKILL.md +31 -12
- package/templates/cleargate-planning/.cleargate/FLASHCARD.md +2 -1
- package/templates/cleargate-planning/.cleargate/config.example.yml +37 -0
- package/templates/cleargate-planning/.cleargate/knowledge/cleargate-protocol.md +407 -0
- package/templates/cleargate-planning/.cleargate/scripts/assert_story_files.mjs +146 -0
- package/templates/cleargate-planning/.cleargate/scripts/close_sprint.mjs +250 -0
- package/templates/cleargate-planning/.cleargate/scripts/constants.mjs +57 -0
- package/templates/cleargate-planning/.cleargate/scripts/file_surface_diff.sh +320 -0
- package/templates/cleargate-planning/.cleargate/scripts/gate-checks.json +15 -0
- package/templates/cleargate-planning/.cleargate/scripts/init_gate_config.sh +38 -0
- package/templates/cleargate-planning/.cleargate/scripts/init_sprint.mjs +187 -0
- package/templates/cleargate-planning/.cleargate/scripts/pre_gate_common.sh +132 -0
- package/templates/cleargate-planning/.cleargate/scripts/pre_gate_runner.sh +307 -0
- package/templates/cleargate-planning/.cleargate/scripts/prefill_report.mjs +280 -0
- package/templates/cleargate-planning/.cleargate/scripts/run_script.sh +123 -0
- package/templates/cleargate-planning/.cleargate/scripts/state.schema.json +110 -0
- package/templates/cleargate-planning/.cleargate/scripts/suggest_improvements.mjs +247 -0
- package/templates/cleargate-planning/.cleargate/scripts/surface-whitelist.txt +27 -0
- package/templates/cleargate-planning/.cleargate/scripts/test/test_assert_story_files.sh +261 -0
- package/templates/cleargate-planning/.cleargate/scripts/test/test_file_surface.sh +210 -0
- package/templates/cleargate-planning/.cleargate/scripts/test/test_flashcard_gate.sh +190 -0
- package/templates/cleargate-planning/.cleargate/scripts/test/test_test_ratchet.sh +327 -0
- package/templates/cleargate-planning/.cleargate/scripts/test_ratchet.mjs +261 -0
- package/templates/cleargate-planning/.cleargate/scripts/update_state.mjs +154 -0
- package/templates/cleargate-planning/.cleargate/scripts/validate_bounce_readiness.mjs +111 -0
- package/templates/cleargate-planning/.cleargate/scripts/validate_state.mjs +164 -0
- package/templates/cleargate-planning/.cleargate/templates/Bug.md +9 -0
- package/templates/cleargate-planning/.cleargate/templates/CR.md +9 -0
- package/templates/cleargate-planning/.cleargate/templates/Sprint Plan Template.md +29 -3
- package/templates/cleargate-planning/.cleargate/templates/epic.md +9 -0
- package/templates/cleargate-planning/.cleargate/templates/proposal.md +9 -0
- package/templates/cleargate-planning/.cleargate/templates/sprint_context.md +42 -0
- package/templates/cleargate-planning/.cleargate/templates/sprint_report.md +175 -0
- package/templates/cleargate-planning/.cleargate/templates/story.md +29 -0
- package/templates/cleargate-planning/CLAUDE.md +3 -0
- package/templates/cleargate-planning/MANIFEST.json +59 -17
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# file_surface_diff.sh — Parse §3.1 of the active story file and compare
|
|
3
|
+
# declared file paths against `git diff --cached --name-only`.
|
|
4
|
+
#
|
|
5
|
+
# Usage: file_surface_diff.sh [--story-file <path>] [--whitelist <path>] [--v1]
|
|
6
|
+
#
|
|
7
|
+
# Environment:
|
|
8
|
+
# SKIP_SURFACE_GATE=1 — bypass the gate (exit 0 always)
|
|
9
|
+
# CLEARGATE_REPO_ROOT — override repo root (default: CWD git toplevel)
|
|
10
|
+
#
|
|
11
|
+
# Exit codes:
|
|
12
|
+
# 0 — all staged files are on-surface or whitelisted, or v1 mode
|
|
13
|
+
# 1 — off-surface files detected (v2 mode only)
|
|
14
|
+
|
|
15
|
+
set -euo pipefail
|
|
16
|
+
|
|
17
|
+
# ---- Configuration ---------------------------------------------------------
|
|
18
|
+
|
|
19
|
+
REPO_ROOT="${CLEARGATE_REPO_ROOT:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}"
|
|
20
|
+
WHITELIST_DEFAULT="${REPO_ROOT}/.cleargate/scripts/surface-whitelist.txt"
|
|
21
|
+
ACTIVE_SENTINEL="${REPO_ROOT}/.cleargate/sprint-runs/.active"
|
|
22
|
+
STATE_JSON_GLOB="${REPO_ROOT}/.cleargate/sprint-runs"
|
|
23
|
+
|
|
24
|
+
# Parse args
|
|
25
|
+
STORY_FILE=""
|
|
26
|
+
WHITELIST_FILE="${WHITELIST_DEFAULT}"
|
|
27
|
+
FORCE_V1=0
|
|
28
|
+
|
|
29
|
+
while [[ $# -gt 0 ]]; do
|
|
30
|
+
case "$1" in
|
|
31
|
+
--story-file) STORY_FILE="$2"; shift 2 ;;
|
|
32
|
+
--whitelist) WHITELIST_FILE="$2"; shift 2 ;;
|
|
33
|
+
--v1) FORCE_V1=1; shift ;;
|
|
34
|
+
*) shift ;;
|
|
35
|
+
esac
|
|
36
|
+
done
|
|
37
|
+
|
|
38
|
+
# ---- Bypass check ----------------------------------------------------------
|
|
39
|
+
|
|
40
|
+
if [[ "${SKIP_SURFACE_GATE:-0}" == "1" ]]; then
|
|
41
|
+
echo "[surface-gate] SKIP_SURFACE_GATE=1 — bypassing gate" >&2
|
|
42
|
+
exit 0
|
|
43
|
+
fi
|
|
44
|
+
|
|
45
|
+
# ---- Execution mode --------------------------------------------------------
|
|
46
|
+
|
|
47
|
+
detect_execution_mode() {
|
|
48
|
+
local state_file="${STATE_JSON_GLOB}"
|
|
49
|
+
# Determine active sprint
|
|
50
|
+
local sprint_id=""
|
|
51
|
+
if [[ -f "${ACTIVE_SENTINEL}" ]]; then
|
|
52
|
+
sprint_id="$(tr -d '[:space:]' < "${ACTIVE_SENTINEL}")"
|
|
53
|
+
fi
|
|
54
|
+
if [[ -z "${sprint_id}" ]]; then
|
|
55
|
+
echo "v1"
|
|
56
|
+
return
|
|
57
|
+
fi
|
|
58
|
+
local state_json="${REPO_ROOT}/.cleargate/sprint-runs/${sprint_id}/state.json"
|
|
59
|
+
if [[ -f "${state_json}" ]]; then
|
|
60
|
+
local mode
|
|
61
|
+
mode="$(grep -oE '"execution_mode"\s*:\s*"v[12]"' "${state_json}" 2>/dev/null | grep -oE 'v[12]' | head -1 || true)"
|
|
62
|
+
if [[ -n "${mode}" ]]; then
|
|
63
|
+
echo "${mode}"
|
|
64
|
+
return
|
|
65
|
+
fi
|
|
66
|
+
fi
|
|
67
|
+
# Fallback: check sprint file frontmatter
|
|
68
|
+
local sprint_file
|
|
69
|
+
sprint_file="$(ls "${REPO_ROOT}/.cleargate/delivery/pending-sync/SPRINT-${sprint_id}_"*.md 2>/dev/null | head -1 || true)"
|
|
70
|
+
if [[ -z "${sprint_file}" ]]; then
|
|
71
|
+
sprint_file="$(ls "${REPO_ROOT}/.cleargate/delivery/archive/SPRINT-${sprint_id}_"*.md 2>/dev/null | head -1 || true)"
|
|
72
|
+
fi
|
|
73
|
+
if [[ -n "${sprint_file}" ]]; then
|
|
74
|
+
local mode
|
|
75
|
+
mode="$(grep -E '^execution_mode:' "${sprint_file}" 2>/dev/null | grep -oE 'v[12]' | head -1 || true)"
|
|
76
|
+
if [[ -n "${mode}" ]]; then
|
|
77
|
+
echo "${mode}"
|
|
78
|
+
return
|
|
79
|
+
fi
|
|
80
|
+
fi
|
|
81
|
+
echo "v1"
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if [[ "${FORCE_V1}" == "1" ]]; then
|
|
85
|
+
EXECUTION_MODE="v1"
|
|
86
|
+
else
|
|
87
|
+
EXECUTION_MODE="$(detect_execution_mode)"
|
|
88
|
+
fi
|
|
89
|
+
|
|
90
|
+
# ---- Resolve active story file ---------------------------------------------
|
|
91
|
+
|
|
92
|
+
resolve_story_file() {
|
|
93
|
+
local sprint_id=""
|
|
94
|
+
if [[ -f "${ACTIVE_SENTINEL}" ]]; then
|
|
95
|
+
sprint_id="$(tr -d '[:space:]' < "${ACTIVE_SENTINEL}")"
|
|
96
|
+
fi
|
|
97
|
+
if [[ -z "${sprint_id}" ]]; then
|
|
98
|
+
echo ""
|
|
99
|
+
return
|
|
100
|
+
fi
|
|
101
|
+
|
|
102
|
+
local state_json="${REPO_ROOT}/.cleargate/sprint-runs/${sprint_id}/state.json"
|
|
103
|
+
if [[ ! -f "${state_json}" ]]; then
|
|
104
|
+
echo ""
|
|
105
|
+
return
|
|
106
|
+
fi
|
|
107
|
+
|
|
108
|
+
# Find first non-terminal story (In Progress or Ready)
|
|
109
|
+
local story_id=""
|
|
110
|
+
story_id="$(python3 -c "
|
|
111
|
+
import json, sys
|
|
112
|
+
data = json.load(open('${state_json}'))
|
|
113
|
+
stories = data.get('stories', {})
|
|
114
|
+
for sid, st in stories.items():
|
|
115
|
+
if st.get('state','') in ('In Progress','Ready','In Review'):
|
|
116
|
+
print(sid)
|
|
117
|
+
break
|
|
118
|
+
" 2>/dev/null || true)"
|
|
119
|
+
|
|
120
|
+
if [[ -z "${story_id}" ]]; then
|
|
121
|
+
# Fallback: most recently updated
|
|
122
|
+
story_id="$(python3 -c "
|
|
123
|
+
import json, sys
|
|
124
|
+
data = json.load(open('${state_json}'))
|
|
125
|
+
stories = data.get('stories', {})
|
|
126
|
+
latest = max(stories.items(), key=lambda kv: kv[1].get('updated_at',''), default=(None,None))
|
|
127
|
+
if latest[0]:
|
|
128
|
+
print(latest[0])
|
|
129
|
+
" 2>/dev/null || true)"
|
|
130
|
+
fi
|
|
131
|
+
|
|
132
|
+
if [[ -z "${story_id}" ]]; then
|
|
133
|
+
echo ""
|
|
134
|
+
return
|
|
135
|
+
fi
|
|
136
|
+
|
|
137
|
+
# Convert e.g. STORY-014-01 -> find file
|
|
138
|
+
local story_num="${story_id#STORY-}"
|
|
139
|
+
local story_file
|
|
140
|
+
story_file="$(ls "${REPO_ROOT}/.cleargate/delivery/pending-sync/STORY-${story_num}_"*.md 2>/dev/null | head -1 || true)"
|
|
141
|
+
if [[ -z "${story_file}" ]]; then
|
|
142
|
+
story_file="$(ls "${REPO_ROOT}/.cleargate/delivery/archive/STORY-${story_num}_"*.md 2>/dev/null | head -1 || true)"
|
|
143
|
+
fi
|
|
144
|
+
echo "${story_file}"
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if [[ -z "${STORY_FILE}" ]]; then
|
|
148
|
+
STORY_FILE="$(resolve_story_file)"
|
|
149
|
+
fi
|
|
150
|
+
|
|
151
|
+
if [[ -z "${STORY_FILE}" || ! -f "${STORY_FILE}" ]]; then
|
|
152
|
+
echo "[surface-gate] WARNING: No active story file found — skipping surface check" >&2
|
|
153
|
+
exit 0
|
|
154
|
+
fi
|
|
155
|
+
|
|
156
|
+
# ---- Parse §3.1 file surface table -----------------------------------------
|
|
157
|
+
|
|
158
|
+
parse_surface_paths() {
|
|
159
|
+
local story_file="$1"
|
|
160
|
+
# Extract rows between "### 3.1" and the next "### " header.
|
|
161
|
+
# Table rows: | Item | Value |
|
|
162
|
+
# Only rows where Value cell looks like a path (contains . or /)
|
|
163
|
+
# Strip backticks. Split on ", " for multiple paths in one cell.
|
|
164
|
+
awk '
|
|
165
|
+
/^### 3\.1/ { in_section=1; next }
|
|
166
|
+
in_section && /^### / { in_section=0; next }
|
|
167
|
+
in_section && /^\|/ {
|
|
168
|
+
# Remove leading/trailing pipe, split into fields
|
|
169
|
+
line=$0
|
|
170
|
+
gsub(/^\||\|$/, "", line)
|
|
171
|
+
n=split(line, cols, "|")
|
|
172
|
+
if (n < 2) next
|
|
173
|
+
val=cols[2]
|
|
174
|
+
# Trim whitespace
|
|
175
|
+
gsub(/^[[:space:]]+|[[:space:]]+$/, "", val)
|
|
176
|
+
# Only process if value looks like a path (contains . or /)
|
|
177
|
+
if (val !~ /[.\/]/) next
|
|
178
|
+
# Strip backticks
|
|
179
|
+
gsub(/`/, "", val)
|
|
180
|
+
# Handle multiple paths separated by ", "
|
|
181
|
+
npaths=split(val, paths, ", ")
|
|
182
|
+
for (i=1; i<=npaths; i++) {
|
|
183
|
+
p=paths[i]
|
|
184
|
+
gsub(/^[[:space:]]+|[[:space:]]+$/, "", p)
|
|
185
|
+
if (p != "" && (p ~ /[.\/]/)) print p
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
' "${story_file}"
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
# Collect declared paths into array (portable bash 3.2 compat — no mapfile)
|
|
192
|
+
declared_paths=()
|
|
193
|
+
while IFS= read -r p; do
|
|
194
|
+
declared_paths+=("$p")
|
|
195
|
+
done < <(parse_surface_paths "${STORY_FILE}")
|
|
196
|
+
|
|
197
|
+
if [[ ${#declared_paths[@]} -eq 0 ]]; then
|
|
198
|
+
echo "[surface-gate] WARNING: No file paths found in §3.1 of ${STORY_FILE} — skipping surface check" >&2
|
|
199
|
+
exit 0
|
|
200
|
+
fi
|
|
201
|
+
|
|
202
|
+
# ---- Get staged files -------------------------------------------------------
|
|
203
|
+
|
|
204
|
+
staged_files=()
|
|
205
|
+
while IFS= read -r f; do
|
|
206
|
+
staged_files+=("$f")
|
|
207
|
+
done < <(git -C "${REPO_ROOT}" diff --cached --name-only 2>/dev/null || true)
|
|
208
|
+
|
|
209
|
+
if [[ ${#staged_files[@]} -eq 0 ]]; then
|
|
210
|
+
# Nothing staged — nothing to check
|
|
211
|
+
exit 0
|
|
212
|
+
fi
|
|
213
|
+
|
|
214
|
+
# ---- Load whitelist ---------------------------------------------------------
|
|
215
|
+
|
|
216
|
+
whitelist_patterns=()
|
|
217
|
+
if [[ -f "${WHITELIST_FILE}" ]]; then
|
|
218
|
+
while IFS= read -r line; do
|
|
219
|
+
# Skip comments and blank lines
|
|
220
|
+
[[ -z "${line}" || "${line}" =~ ^# ]] && continue
|
|
221
|
+
whitelist_patterns+=("$line")
|
|
222
|
+
done < "${WHITELIST_FILE}"
|
|
223
|
+
fi
|
|
224
|
+
|
|
225
|
+
# ---- Helper: match file against whitelist -----------------------------------
|
|
226
|
+
|
|
227
|
+
is_whitelisted() {
|
|
228
|
+
local file="$1"
|
|
229
|
+
local pattern
|
|
230
|
+
for pattern in "${whitelist_patterns[@]+"${whitelist_patterns[@]}"}"; do
|
|
231
|
+
# Use bash glob matching — convert ** to * for simple matching
|
|
232
|
+
# Try direct fnmatch with case
|
|
233
|
+
if [[ "${file}" == ${pattern} ]]; then
|
|
234
|
+
return 0
|
|
235
|
+
fi
|
|
236
|
+
# Try matching basename
|
|
237
|
+
local basename="${file##*/}"
|
|
238
|
+
local pat_base="${pattern##*/}"
|
|
239
|
+
if [[ "${basename}" == ${pat_base} && "${pat_base}" == "${basename}" ]]; then
|
|
240
|
+
: # need full path match
|
|
241
|
+
fi
|
|
242
|
+
# Try: if pattern has **, match any path segment
|
|
243
|
+
local simple_pat="${pattern//\*\*\//*/}"
|
|
244
|
+
if [[ "${file}" == ${simple_pat} ]]; then
|
|
245
|
+
return 0
|
|
246
|
+
fi
|
|
247
|
+
# Also: check if file path contains the pattern as suffix
|
|
248
|
+
if [[ "${file}" == *"${pattern}" ]]; then
|
|
249
|
+
return 0
|
|
250
|
+
fi
|
|
251
|
+
done
|
|
252
|
+
return 1
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
# ---- Helper: normalize path for comparison ----------------------------------
|
|
256
|
+
|
|
257
|
+
normalize_path() {
|
|
258
|
+
local p="$1"
|
|
259
|
+
# Strip leading ./
|
|
260
|
+
p="${p#./}"
|
|
261
|
+
# If absolute path under REPO_ROOT, make it relative
|
|
262
|
+
if [[ "${p}" == "${REPO_ROOT}/"* ]]; then
|
|
263
|
+
p="${p#${REPO_ROOT}/}"
|
|
264
|
+
fi
|
|
265
|
+
echo "${p}"
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
# ---- Compare staged vs declared ---------------------------------------------
|
|
269
|
+
|
|
270
|
+
off_surface=()
|
|
271
|
+
for staged in "${staged_files[@]}"; do
|
|
272
|
+
staged_norm="$(normalize_path "${staged}")"
|
|
273
|
+
|
|
274
|
+
# Check whitelist first
|
|
275
|
+
if is_whitelisted "${staged_norm}"; then
|
|
276
|
+
continue
|
|
277
|
+
fi
|
|
278
|
+
# Also check absolute path against whitelist
|
|
279
|
+
if is_whitelisted "${REPO_ROOT}/${staged_norm}"; then
|
|
280
|
+
continue
|
|
281
|
+
fi
|
|
282
|
+
|
|
283
|
+
# Check against declared surface
|
|
284
|
+
found=0
|
|
285
|
+
for declared in "${declared_paths[@]+"${declared_paths[@]}"}"; do
|
|
286
|
+
declared_norm="$(normalize_path "${declared}")"
|
|
287
|
+
if [[ "${staged_norm}" == "${declared_norm}" ]]; then
|
|
288
|
+
found=1
|
|
289
|
+
break
|
|
290
|
+
fi
|
|
291
|
+
done
|
|
292
|
+
|
|
293
|
+
if [[ "${found}" == "0" ]]; then
|
|
294
|
+
off_surface+=("${staged_norm}")
|
|
295
|
+
fi
|
|
296
|
+
done
|
|
297
|
+
|
|
298
|
+
# ---- Report -----------------------------------------------------------------
|
|
299
|
+
|
|
300
|
+
if [[ ${#off_surface[@]} -eq 0 ]]; then
|
|
301
|
+
exit 0
|
|
302
|
+
fi
|
|
303
|
+
|
|
304
|
+
# Off-surface files detected
|
|
305
|
+
if [[ "${EXECUTION_MODE}" == "v1" ]]; then
|
|
306
|
+
echo "[surface-gate] WARNING (v1 advisory): staged files outside declared §3.1 surface:" >&2
|
|
307
|
+
for f in "${off_surface[@]}"; do
|
|
308
|
+
echo " off-surface: ${f}" >&2
|
|
309
|
+
done
|
|
310
|
+
echo "[surface-gate] v1 mode — not blocking commit. Switch to v2 to enforce." >&2
|
|
311
|
+
exit 0
|
|
312
|
+
else
|
|
313
|
+
echo "[surface-gate] BLOCKED: staged files outside declared §3.1 surface:" >&2
|
|
314
|
+
for f in "${off_surface[@]}"; do
|
|
315
|
+
echo " off-surface: ${f}" >&2
|
|
316
|
+
done
|
|
317
|
+
echo "[surface-gate] Commit blocked. Declare these files in §3.1 or open a CR:scope-change." >&2
|
|
318
|
+
echo "[surface-gate] Set SKIP_SURFACE_GATE=1 to bypass (v2 mode — use sparingly)." >&2
|
|
319
|
+
exit 1
|
|
320
|
+
fi
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema_version": 1,
|
|
3
|
+
"qa": {
|
|
4
|
+
"typecheck": "npm run typecheck",
|
|
5
|
+
"debug_patterns": ["console.log", "console.debug", "debugger"],
|
|
6
|
+
"todo_patterns": ["TODO", "FIXME", "XXX"],
|
|
7
|
+
"test": "npm test"
|
|
8
|
+
},
|
|
9
|
+
"arch": {
|
|
10
|
+
"typecheck": "npm run typecheck",
|
|
11
|
+
"new_deps_check": true,
|
|
12
|
+
"stray_env_files": [".env", ".env.local", ".env.production"],
|
|
13
|
+
"file_count_report": true
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# init_gate_config.sh — Idempotent seeder for gate-checks.json
|
|
3
|
+
# Usage: init_gate_config.sh [--config-path <path>]
|
|
4
|
+
# If gate-checks.json already exists, exits 0 without overwriting.
|
|
5
|
+
set -euo pipefail
|
|
6
|
+
|
|
7
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
8
|
+
CONFIG_PATH="${SCRIPT_DIR}/gate-checks.json"
|
|
9
|
+
|
|
10
|
+
# Allow override via argument
|
|
11
|
+
if [[ "${1:-}" == "--config-path" && -n "${2:-}" ]]; then
|
|
12
|
+
CONFIG_PATH="$2"
|
|
13
|
+
fi
|
|
14
|
+
|
|
15
|
+
if [[ -f "$CONFIG_PATH" ]]; then
|
|
16
|
+
echo "gate-checks.json already exists at ${CONFIG_PATH} — no-op." >&2
|
|
17
|
+
exit 0
|
|
18
|
+
fi
|
|
19
|
+
|
|
20
|
+
cat > "$CONFIG_PATH" << 'EOF'
|
|
21
|
+
{
|
|
22
|
+
"schema_version": 1,
|
|
23
|
+
"qa": {
|
|
24
|
+
"typecheck": "npm run typecheck",
|
|
25
|
+
"debug_patterns": ["console.log", "console.debug", "debugger"],
|
|
26
|
+
"todo_patterns": ["TODO", "FIXME", "XXX"],
|
|
27
|
+
"test": "npm test"
|
|
28
|
+
},
|
|
29
|
+
"arch": {
|
|
30
|
+
"typecheck": "npm run typecheck",
|
|
31
|
+
"new_deps_check": true,
|
|
32
|
+
"stray_env_files": [".env", ".env.local", ".env.production"],
|
|
33
|
+
"file_count_report": true
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
EOF
|
|
37
|
+
|
|
38
|
+
echo "gate-checks.json created at ${CONFIG_PATH}" >&2
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* init_sprint.mjs — Initialize a sprint state.json
|
|
4
|
+
*
|
|
5
|
+
* Usage: node init_sprint.mjs <sprint-id> --stories ID1,ID2,... [--force]
|
|
6
|
+
*
|
|
7
|
+
* Creates .cleargate/sprint-runs/<sprint-id>/state.json with initial state
|
|
8
|
+
* "Ready to Bounce" for each story. Refuses if state.json already exists
|
|
9
|
+
* unless --force is passed.
|
|
10
|
+
*
|
|
11
|
+
* Under execution_mode: v2 (read from sprint frontmatter):
|
|
12
|
+
* - Asserts all story files exist in pending-sync/ before writing state.json.
|
|
13
|
+
* - On failure: prints missing list to stderr and exits 1 WITHOUT creating state.json.
|
|
14
|
+
*
|
|
15
|
+
* Under execution_mode: v1:
|
|
16
|
+
* - Runs the same assertion but only warns on failure (does not block).
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import fs from 'node:fs';
|
|
20
|
+
import path from 'node:path';
|
|
21
|
+
import { fileURLToPath } from 'node:url';
|
|
22
|
+
import { spawnSync } from 'node:child_process';
|
|
23
|
+
import { SCHEMA_VERSION, VALID_STATES, TERMINAL_STATES } from './constants.mjs';
|
|
24
|
+
|
|
25
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
26
|
+
// Resolve repo root: .cleargate/scripts/ -> ../../ (two levels up)
|
|
27
|
+
// CLEARGATE_REPO_ROOT env var overrides for testing
|
|
28
|
+
const REPO_ROOT = process.env.CLEARGATE_REPO_ROOT
|
|
29
|
+
? path.resolve(process.env.CLEARGATE_REPO_ROOT)
|
|
30
|
+
: path.resolve(__dirname, '..', '..');
|
|
31
|
+
|
|
32
|
+
function usage() {
|
|
33
|
+
process.stderr.write(
|
|
34
|
+
'Usage: node init_sprint.mjs <sprint-id> --stories ID1,ID2,... [--force]\n'
|
|
35
|
+
);
|
|
36
|
+
process.exit(2);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Read execution_mode from a sprint file's YAML frontmatter.
|
|
41
|
+
* Uses a single-field regex — does NOT hand-roll a full YAML parser.
|
|
42
|
+
* Returns 'v2' | 'v1' (defaults to 'v1' if field absent or unreadable).
|
|
43
|
+
*/
|
|
44
|
+
function readExecutionMode(sprintFilePath) {
|
|
45
|
+
let content;
|
|
46
|
+
try {
|
|
47
|
+
content = fs.readFileSync(sprintFilePath, 'utf8');
|
|
48
|
+
} catch {
|
|
49
|
+
return 'v1';
|
|
50
|
+
}
|
|
51
|
+
// Match frontmatter block
|
|
52
|
+
const fm = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
|
|
53
|
+
if (!fm) return 'v1';
|
|
54
|
+
const modeMatch = fm[1].match(/^execution_mode:\s*["']?(v[12])/m);
|
|
55
|
+
if (!modeMatch) return 'v1';
|
|
56
|
+
return modeMatch[1];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Locate the sprint file in pending-sync/ or archive/ for the given sprint ID.
|
|
61
|
+
* Returns the absolute path if found, null otherwise.
|
|
62
|
+
*/
|
|
63
|
+
function findSprintFile(repoRoot, sprintId) {
|
|
64
|
+
const searchDirs = [
|
|
65
|
+
path.join(repoRoot, '.cleargate', 'delivery', 'pending-sync'),
|
|
66
|
+
path.join(repoRoot, '.cleargate', 'delivery', 'archive'),
|
|
67
|
+
];
|
|
68
|
+
for (const dir of searchDirs) {
|
|
69
|
+
let entries;
|
|
70
|
+
try {
|
|
71
|
+
entries = fs.readdirSync(dir);
|
|
72
|
+
} catch {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
const prefix = `${sprintId}_`;
|
|
76
|
+
const match = entries.find(
|
|
77
|
+
(e) => (e === `${sprintId}.md` || e.startsWith(prefix)) && e.endsWith('.md')
|
|
78
|
+
);
|
|
79
|
+
if (match) return path.join(dir, match);
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Run assert_story_files.mjs for the given sprint file.
|
|
86
|
+
* Returns { exitCode, stderr }.
|
|
87
|
+
*/
|
|
88
|
+
function runAssertStoryFiles(repoRoot, sprintFilePath) {
|
|
89
|
+
// Use __dirname to locate the sibling script (not CLEARGATE_REPO_ROOT, which is a test-isolation
|
|
90
|
+
// override that points to a tmpdir without scripts).
|
|
91
|
+
const assertScript = path.join(__dirname, 'assert_story_files.mjs');
|
|
92
|
+
const env = { ...process.env, CLEARGATE_REPO_ROOT: repoRoot };
|
|
93
|
+
const result = spawnSync(process.execPath, [assertScript, sprintFilePath], {
|
|
94
|
+
encoding: 'utf8',
|
|
95
|
+
env,
|
|
96
|
+
});
|
|
97
|
+
return {
|
|
98
|
+
exitCode: result.status ?? 1,
|
|
99
|
+
stderr: result.stderr || '',
|
|
100
|
+
stdout: result.stdout || '',
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function main() {
|
|
105
|
+
const args = process.argv.slice(2);
|
|
106
|
+
|
|
107
|
+
const sprintId = args[0];
|
|
108
|
+
if (!sprintId || sprintId.startsWith('--')) usage();
|
|
109
|
+
|
|
110
|
+
const storiesIdx = args.indexOf('--stories');
|
|
111
|
+
if (storiesIdx === -1 || !args[storiesIdx + 1]) usage();
|
|
112
|
+
|
|
113
|
+
const storyIds = args[storiesIdx + 1].split(',').map((s) => s.trim()).filter(Boolean);
|
|
114
|
+
if (storyIds.length === 0) {
|
|
115
|
+
process.stderr.write('Error: --stories requires at least one story ID\n');
|
|
116
|
+
process.exit(2);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const force = args.includes('--force');
|
|
120
|
+
|
|
121
|
+
const sprintDir = path.join(REPO_ROOT, '.cleargate', 'sprint-runs', sprintId);
|
|
122
|
+
const stateFile = path.join(sprintDir, 'state.json');
|
|
123
|
+
|
|
124
|
+
if (fs.existsSync(stateFile) && !force) {
|
|
125
|
+
process.stderr.write(
|
|
126
|
+
`state.json already exists at ${stateFile}; pass --force to overwrite\n`
|
|
127
|
+
);
|
|
128
|
+
process.exit(1);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// --- Read execution_mode from sprint frontmatter ---
|
|
132
|
+
const sprintFilePath = findSprintFile(REPO_ROOT, sprintId);
|
|
133
|
+
const executionMode = sprintFilePath ? readExecutionMode(sprintFilePath) : 'v1';
|
|
134
|
+
|
|
135
|
+
// --- Gate-2 story-file assertion ---
|
|
136
|
+
if (sprintFilePath) {
|
|
137
|
+
const { exitCode, stderr, stdout } = runAssertStoryFiles(REPO_ROOT, sprintFilePath);
|
|
138
|
+
if (exitCode !== 0) {
|
|
139
|
+
if (executionMode === 'v2') {
|
|
140
|
+
// Hard block: do not create state.json
|
|
141
|
+
process.stderr.write(stderr);
|
|
142
|
+
process.stderr.write(
|
|
143
|
+
`ERROR: v2 sprint init blocked — story files missing. Fix the above, then re-run init.\n`
|
|
144
|
+
);
|
|
145
|
+
process.exit(1);
|
|
146
|
+
} else {
|
|
147
|
+
// v1: warn only
|
|
148
|
+
process.stderr.write(
|
|
149
|
+
`WARN: missing story files: ${stderr.trim().split('\n').pop() || 'see above'}\n`
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const now = new Date().toISOString();
|
|
156
|
+
const stories = {};
|
|
157
|
+
for (const id of storyIds) {
|
|
158
|
+
stories[id] = {
|
|
159
|
+
state: 'Ready to Bounce',
|
|
160
|
+
qa_bounces: 0,
|
|
161
|
+
arch_bounces: 0,
|
|
162
|
+
worktree: null,
|
|
163
|
+
updated_at: now,
|
|
164
|
+
notes: '',
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const state = {
|
|
169
|
+
schema_version: SCHEMA_VERSION,
|
|
170
|
+
sprint_id: sprintId,
|
|
171
|
+
execution_mode: executionMode,
|
|
172
|
+
sprint_status: 'Active',
|
|
173
|
+
stories,
|
|
174
|
+
last_action: `Sprint ${sprintId} initialised`,
|
|
175
|
+
updated_at: now,
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
fs.mkdirSync(sprintDir, { recursive: true });
|
|
179
|
+
|
|
180
|
+
const tmpFile = `${stateFile}.tmp.${process.pid}`;
|
|
181
|
+
fs.writeFileSync(tmpFile, JSON.stringify(state, null, 2) + '\n', 'utf8');
|
|
182
|
+
fs.renameSync(tmpFile, stateFile);
|
|
183
|
+
|
|
184
|
+
process.stdout.write(`Initialized state.json for sprint ${sprintId} with ${storyIds.length} stories\n`);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
main();
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# pre_gate_common.sh — Shared helpers for pre_gate_runner.sh
|
|
3
|
+
# Sourced by pre_gate_runner.sh. Do NOT execute directly.
|
|
4
|
+
# Handles Node+TS stacks only (no Python/Rust/Go/Java/Swift detectors).
|
|
5
|
+
set -euo pipefail
|
|
6
|
+
|
|
7
|
+
# ---------------------------------------------------------------------------
|
|
8
|
+
# read_config_field <field_path> <config_file>
|
|
9
|
+
# Uses node -p to parse JSON and extract a field.
|
|
10
|
+
# field_path: dot-separated path, e.g. "qa.typecheck"
|
|
11
|
+
# ---------------------------------------------------------------------------
|
|
12
|
+
read_config_field() {
|
|
13
|
+
local field_path="$1"
|
|
14
|
+
local config_file="$2"
|
|
15
|
+
node -p "
|
|
16
|
+
const c = JSON.parse(require('fs').readFileSync('${config_file}', 'utf8'));
|
|
17
|
+
const parts = '${field_path}'.split('.');
|
|
18
|
+
let v = c;
|
|
19
|
+
for (const p of parts) { v = v[p]; }
|
|
20
|
+
Array.isArray(v) ? JSON.stringify(v) : (v === undefined ? '' : String(v));
|
|
21
|
+
" 2>/dev/null || echo ""
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
# ---------------------------------------------------------------------------
|
|
25
|
+
# get_modified_files <worktree_path>
|
|
26
|
+
# Lists files modified in the current git index vs HEAD.
|
|
27
|
+
# ---------------------------------------------------------------------------
|
|
28
|
+
get_modified_files() {
|
|
29
|
+
local worktree="$1"
|
|
30
|
+
git -C "$worktree" diff --name-only HEAD 2>/dev/null || true
|
|
31
|
+
git -C "$worktree" diff --cached --name-only 2>/dev/null || true
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
# ---------------------------------------------------------------------------
|
|
35
|
+
# get_staged_diff <worktree_path>
|
|
36
|
+
# Returns unified diff of staged changes.
|
|
37
|
+
# ---------------------------------------------------------------------------
|
|
38
|
+
get_staged_diff() {
|
|
39
|
+
local worktree="$1"
|
|
40
|
+
git -C "$worktree" diff --cached 2>/dev/null || git -C "$worktree" diff HEAD 2>/dev/null || true
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
# ---------------------------------------------------------------------------
|
|
44
|
+
# record_result <report_file> <check_name> <status> [details]
|
|
45
|
+
# Appends one result line to the report.
|
|
46
|
+
# status: PASS | FAIL | WARN | INFO
|
|
47
|
+
# ---------------------------------------------------------------------------
|
|
48
|
+
record_result() {
|
|
49
|
+
local report_file="$1"
|
|
50
|
+
local check_name="$2"
|
|
51
|
+
local status="$3"
|
|
52
|
+
local details="${4:-}"
|
|
53
|
+
echo "[${status}] ${check_name}: ${details}" >> "$report_file"
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
# ---------------------------------------------------------------------------
|
|
57
|
+
# print_summary <report_file>
|
|
58
|
+
# Prints count of PASS/FAIL/WARN lines from the report.
|
|
59
|
+
# ---------------------------------------------------------------------------
|
|
60
|
+
print_summary() {
|
|
61
|
+
local report_file="$1"
|
|
62
|
+
local pass_count fail_count warn_count
|
|
63
|
+
pass_count=$(grep -c '^\[PASS\]' "$report_file" 2>/dev/null || echo 0)
|
|
64
|
+
fail_count=$(grep -c '^\[FAIL\]' "$report_file" 2>/dev/null || echo 0)
|
|
65
|
+
warn_count=$(grep -c '^\[WARN\]' "$report_file" 2>/dev/null || echo 0)
|
|
66
|
+
echo "Summary: ${pass_count} passed, ${fail_count} failed, ${warn_count} warnings"
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
# ---------------------------------------------------------------------------
|
|
70
|
+
# write_report <report_file> <mode> <worktree_path> <branch>
|
|
71
|
+
# Writes the report header.
|
|
72
|
+
# ---------------------------------------------------------------------------
|
|
73
|
+
write_report_header() {
|
|
74
|
+
local report_file="$1"
|
|
75
|
+
local mode="$2"
|
|
76
|
+
local worktree="$3"
|
|
77
|
+
local branch="$4"
|
|
78
|
+
mkdir -p "$(dirname "$report_file")"
|
|
79
|
+
{
|
|
80
|
+
echo "# ClearGate Pre-Gate Scan Report"
|
|
81
|
+
echo "Mode: ${mode}"
|
|
82
|
+
echo "Worktree: ${worktree}"
|
|
83
|
+
echo "Branch: ${branch}"
|
|
84
|
+
echo "Timestamp: $(date -u '+%Y-%m-%dT%H:%M:%SZ')"
|
|
85
|
+
echo "---"
|
|
86
|
+
} > "$report_file"
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
# ---------------------------------------------------------------------------
|
|
90
|
+
# detect_stack <worktree_path>
|
|
91
|
+
# Returns "node-ts" if package.json + tsconfig.json found, else "unknown".
|
|
92
|
+
# Node+TS only — no Python/Rust/Go/Java/Swift detectors.
|
|
93
|
+
# ---------------------------------------------------------------------------
|
|
94
|
+
detect_stack() {
|
|
95
|
+
local worktree="$1"
|
|
96
|
+
if [[ -f "${worktree}/package.json" ]]; then
|
|
97
|
+
if [[ -f "${worktree}/tsconfig.json" ]]; then
|
|
98
|
+
echo "node-ts"
|
|
99
|
+
else
|
|
100
|
+
echo "node"
|
|
101
|
+
fi
|
|
102
|
+
else
|
|
103
|
+
echo "unknown"
|
|
104
|
+
fi
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
# ---------------------------------------------------------------------------
|
|
108
|
+
# diff_package_json <worktree_path> <branch>
|
|
109
|
+
# Prints new runtime deps (non-dev) introduced vs <branch>^.
|
|
110
|
+
# Returns lines like: "new runtime dep: <name>"
|
|
111
|
+
# ---------------------------------------------------------------------------
|
|
112
|
+
diff_package_json() {
|
|
113
|
+
local worktree="$1"
|
|
114
|
+
local branch="$2"
|
|
115
|
+
|
|
116
|
+
# Get old package.json from branch parent (branch^ in the worktree's git)
|
|
117
|
+
local old_json
|
|
118
|
+
old_json=$(git -C "$worktree" show "${branch}^:package.json" 2>/dev/null || echo '{"dependencies":{}}')
|
|
119
|
+
|
|
120
|
+
local new_json
|
|
121
|
+
new_json=$(cat "${worktree}/package.json" 2>/dev/null || echo '{"dependencies":{}}')
|
|
122
|
+
|
|
123
|
+
# Extract dep keys using node
|
|
124
|
+
node -e "
|
|
125
|
+
const oldPkg = JSON.parse($(echo "$old_json" | node -e "let d='';process.stdin.on('data',c=>d+=c);process.stdin.on('end',()=>process.stdout.write(JSON.stringify(d)))"));
|
|
126
|
+
const newPkg = JSON.parse($(echo "$new_json" | node -e "let d='';process.stdin.on('data',c=>d+=c);process.stdin.on('end',()=>process.stdout.write(JSON.stringify(d)))"));
|
|
127
|
+
const oldDeps = Object.keys(oldPkg.dependencies || {});
|
|
128
|
+
const newDeps = Object.keys(newPkg.dependencies || {});
|
|
129
|
+
const added = newDeps.filter(d => !oldDeps.includes(d));
|
|
130
|
+
added.forEach(d => console.log('new runtime dep: ' + d));
|
|
131
|
+
" 2>/dev/null || true
|
|
132
|
+
}
|