@codeyam/codeyam-cli 0.1.5 → 0.1.7
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/analyzer-template/.build-info.json +7 -7
- package/analyzer-template/log.txt +3 -3
- package/analyzer-template/package.json +2 -2
- package/analyzer-template/packages/ai/package.json +1 -1
- package/analyzer-template/packages/ai/src/lib/completionCall.ts +102 -113
- package/analyzer-template/packages/aws/package.json +1 -1
- package/codeyam-cli/src/cli.js +5 -11
- package/codeyam-cli/src/cli.js.map +1 -1
- package/codeyam-cli/src/commands/memory.js +26 -2
- package/codeyam-cli/src/commands/memory.js.map +1 -1
- package/codeyam-cli/src/utils/install-skills.js +4 -4
- package/codeyam-cli/src/utils/install-skills.js.map +1 -1
- package/codeyam-cli/src/utils/requireSimulations.js +1 -1
- package/codeyam-cli/src/utils/requireSimulations.js.map +1 -1
- package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js +5 -6
- package/codeyam-cli/src/utils/ruleReflection/__tests__/contextBuilder.test.js.map +1 -1
- package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js +2 -5
- package/codeyam-cli/src/utils/ruleReflection/__tests__/promptBuilder.test.js.map +1 -1
- package/codeyam-cli/src/utils/rules/__tests__/rulePlacement.test.js +72 -0
- package/codeyam-cli/src/utils/rules/__tests__/rulePlacement.test.js.map +1 -0
- package/codeyam-cli/src/utils/rules/__tests__/sourceFiles.test.js +11 -18
- package/codeyam-cli/src/utils/rules/__tests__/sourceFiles.test.js.map +1 -1
- package/codeyam-cli/src/utils/rules/rulePlacement.js +65 -0
- package/codeyam-cli/src/utils/rules/rulePlacement.js.map +1 -0
- package/codeyam-cli/src/utils/rules/sourceFiles.js +2 -6
- package/codeyam-cli/src/utils/rules/sourceFiles.js.map +1 -1
- package/codeyam-cli/src/utils/simulationGateMiddleware.js +63 -42
- package/codeyam-cli/src/utils/simulationGateMiddleware.js.map +1 -1
- package/codeyam-cli/src/utils/transcriptPruning.js +67 -0
- package/codeyam-cli/src/utils/transcriptPruning.js.map +1 -0
- package/codeyam-cli/src/webserver/backgroundServer.js +10 -0
- package/codeyam-cli/src/webserver/backgroundServer.js.map +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{CopyButton-jNYXRRNI.js → CopyButton-CtmbP4Gl.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{EntityItem-bwuHPyTa.js → EntityItem-DlMph_Hm.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeBadge-CvzqMxcu.js → EntityTypeBadge-B-0PjGOU.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{EntityTypeIcon-BH0XDim7.js → EntityTypeIcon-DN9eiJAO.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{InlineSpinner-EhOseatT.js → InlineSpinner-C1rIyZdV.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{InteractivePreview-yjIHlOGa.js → InteractivePreview-rE_fI2h2.js} +2 -2
- package/codeyam-cli/src/webserver/build/client/assets/{LibraryFunctionPreview-Cq5o8jL4.js → LibraryFunctionPreview-CnatsCw2.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{LoadingDots-BvMu2i-g.js → LoadingDots-CSP6DZrh.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{LogViewer-kgBTLoJD.js → LogViewer-CMK8Q7yk.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{ReportIssueModal-BzPgx-xO.js → ReportIssueModal-TCV_HBjy.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{SafeScreenshot-CwZrv-Ok.js → SafeScreenshot-CG2uh31y.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{ScenarioViewer-BX2Ny2Qj.js → ScenarioViewer-CU_TDYd8.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{TruncatedFilePath-CDpEprKa.js → TruncatedFilePath-D7IoaWUW.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{_index-BRx8ZGZo.js → _index-B8z7mjR-.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{activity.(_tab)-4S4yPfFw.js → activity.(_tab)-DZu78RI1.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/agent-transcripts-Dm5RS9il.js +22 -0
- package/codeyam-cli/src/webserver/build/client/assets/api.rule-path-l0sNRNKZ.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{book-open-D4IPYH_y.js → book-open-Bp5FLkd4.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{chevron-down-CG65viiV.js → chevron-down-DQJA9f4o.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{chunk-JZWAC4HX-DB3aFuEO.js → chunk-JZWAC4HX-7VptmeIr.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{circle-check-igfMr5DY.js → circle-check-B6C4LY9o.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{copy-Coc4o_8c.js → copy-6nzYCu0G.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{createLucideIcon-D1zB-pYc.js → createLucideIcon-D-QUFOwe.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{dev.empty-JTAjQ54M.js → dev.empty-DmzSmblj.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha._-B0h9AqE6.js → entity._sha._-C6PQhwY5.js} +9 -9
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha.scenarios._scenarioId.fullscreen-DjLxr2JB.js → entity._sha.scenarios._scenarioId.fullscreen-DVTcUnur.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.create-scenario-CtYowLOt.js → entity._sha_.create-scenario-BVgNO76F.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entity._sha_.edit._scenarioId-PePWg17F.js → entity._sha_.edit._scenarioId-C7ysA4Jq.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{entry.client-I-Wo99C_.js → entry.client-CU6EUArK.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{fileTableUtils-9sMMAiWJ.js → fileTableUtils-EWpfFU4X.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{files-Co65J0s3.js → files-CrxAoWIL.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{git-BdHOxVfg.js → git-BldHtKeW.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/globals-CLmFdUae.css +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{index-CUM5iXwc.js → index-7-1FmlHo.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{index-_417gcQW.js → index-DuYcwYp_.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{labs-DAvt-sy-.js → labs-CPPVOSWB.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{loader-circle-TzRHMVog.js → loader-circle-BnDcD54R.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-717e346a.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/memory-0wMU4KXe.js +93 -0
- package/codeyam-cli/src/webserver/build/client/assets/{pause-hjzB7t2z.js → pause-DhQX2g22.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{root-DoB3B10-.js → root-DqfSDjyQ.js} +13 -13
- package/codeyam-cli/src/webserver/build/client/assets/{search-DcAwD_Ln.js → search-DborVoKD.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/settings-BWunYSXt.js +1 -0
- package/codeyam-cli/src/webserver/build/client/assets/{simulations-DVNJVQgD.js → simulations-BtrtCYJg.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{terminal-DbEAHMbA.js → terminal-Bs4NC-VZ.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{triangle-alert-CAD5b1o_.js → triangle-alert-DTf3Jojp.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useCustomSizes-BqgrAzs3.js → useCustomSizes-D_bDZyDU.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useLastLogLine-DAFqfEDH.js → useLastLogLine-DZp6rrQD.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useReportContext-DZlYx2c4.js → useReportContext-BsQb6rFd.js} +1 -1
- package/codeyam-cli/src/webserver/build/client/assets/{useToast-ihdMtlf6.js → useToast-BOur3mUv.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/{index-C_nP9_jr.js → index-B8jmgmn2.js} +1 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-9OU4lmvL.js +285 -0
- package/codeyam-cli/src/webserver/build/server/index.js +1 -1
- package/codeyam-cli/src/webserver/build-info.json +5 -5
- package/codeyam-cli/templates/codeyam-new-rule.md +0 -2
- package/codeyam-cli/templates/hooks/staleness-check.sh +43 -0
- package/codeyam-cli/templates/prompts/conversation-guidance.txt +44 -0
- package/codeyam-cli/templates/prompts/conversation-prompt.txt +28 -0
- package/codeyam-cli/templates/prompts/interruption-prompt.txt +31 -0
- package/codeyam-cli/templates/prompts/stale-rules-prompt.txt +24 -0
- package/codeyam-cli/templates/rule-notification-hook.py +44 -17
- package/codeyam-cli/templates/rule-reflection-hook.py +24 -4
- package/codeyam-cli/templates/rules-instructions.md +34 -88
- package/package.json +1 -1
- package/packages/ai/src/lib/completionCall.js +0 -5
- package/packages/ai/src/lib/completionCall.js.map +1 -1
- package/codeyam-cli/src/commands/detect-universal-mocks.js +0 -120
- package/codeyam-cli/src/commands/detect-universal-mocks.js.map +0 -1
- package/codeyam-cli/src/commands/list.js +0 -31
- package/codeyam-cli/src/commands/list.js.map +0 -1
- package/codeyam-cli/src/commands/webapp-info.js +0 -146
- package/codeyam-cli/src/commands/webapp-info.js.map +0 -1
- package/codeyam-cli/src/utils/universal-mocks.js +0 -152
- package/codeyam-cli/src/utils/universal-mocks.js.map +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/agent-transcripts-DHKuQSmR.js +0 -17
- package/codeyam-cli/src/webserver/build/client/assets/globals-B4MPiL7S.css +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/manifest-e24d6600.js +0 -1
- package/codeyam-cli/src/webserver/build/client/assets/memory-bAp4y2hv.js +0 -92
- package/codeyam-cli/src/webserver/build/client/assets/settings-CclxrcPK.js +0 -1
- package/codeyam-cli/src/webserver/build/server/assets/server-build-BEaMCeTu.js +0 -273
- package/codeyam-cli/templates/codeyam-stop-hook.sh +0 -284
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
# CodeYam Stop Hook (portable, jq-free, last-stop tracking)
|
|
3
|
-
# - Reads input JSON from stdin
|
|
4
|
-
# - Gets conversation start from:
|
|
5
|
-
# 1. Last stop time (if available from .codeyam/.last-stop-time)
|
|
6
|
-
# 2. Transcript line 2 ISO-8601 timestamp (session start)
|
|
7
|
-
# - If any relevant files changed since then, blocks with message to run `codeyam verify`
|
|
8
|
-
# - Saves current time to .codeyam/.last-stop-time for next continuation
|
|
9
|
-
# - Toggle logs with CODEYAM_HOOK_DEBUG=1
|
|
10
|
-
|
|
11
|
-
set -uo pipefail
|
|
12
|
-
|
|
13
|
-
exit 0
|
|
14
|
-
|
|
15
|
-
# =========================
|
|
16
|
-
# Debugging (toggleable) Change to 1 to enable
|
|
17
|
-
# =========================
|
|
18
|
-
DEBUG_ON="0"
|
|
19
|
-
DEBUG_LOG="/tmp/codeyam-stop-hook-debug.log"
|
|
20
|
-
log() { [[ "$DEBUG_ON" == "1" ]] && echo "$@" >> "$DEBUG_LOG"; }
|
|
21
|
-
if [[ "$DEBUG_ON" == "1" ]]; then
|
|
22
|
-
{
|
|
23
|
-
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
24
|
-
echo "🔍 Stop Hook Fired at $(date -u +"%Y-%m-%dT%H:%M:%SZ")"
|
|
25
|
-
echo "PWD: $(pwd)"
|
|
26
|
-
echo "USER: ${USER:-unknown}"
|
|
27
|
-
echo "SHELL: ${SHELL:-unknown}"
|
|
28
|
-
} >> "$DEBUG_LOG"
|
|
29
|
-
fi
|
|
30
|
-
|
|
31
|
-
# =========================
|
|
32
|
-
# Helpers
|
|
33
|
-
# =========================
|
|
34
|
-
|
|
35
|
-
json_get_str() {
|
|
36
|
-
local key="$1" json="$2"
|
|
37
|
-
printf '%s' "$json" \
|
|
38
|
-
| sed -nE 's/.*"'$key'":[[:space:]]*"(([^"\\]|\\.)*)".*/\1/p' \
|
|
39
|
-
| sed 's/\\"/"/g'
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
json_get_bool() {
|
|
43
|
-
local key="$1" json="$2"
|
|
44
|
-
printf '%s' "$json" \
|
|
45
|
-
| sed -nE 's/.*"'$key'":[[:space:]]*(true|false).*/\1/p'
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
extract_iso8601() {
|
|
49
|
-
local line="$1"
|
|
50
|
-
if command -v grep >/dev/null 2>&1; then
|
|
51
|
-
printf '%s\n' "$line" \
|
|
52
|
-
| grep -Eo '[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\.[0-9]+)?(Z|[+\-][0-9]{2}(:?[0-9]{2})?)' \
|
|
53
|
-
| head -n1
|
|
54
|
-
else
|
|
55
|
-
printf '%s\n' "$line" \
|
|
56
|
-
| awk '
|
|
57
|
-
match($0, /[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\.[0-9]+)?(Z|[+\-][0-9]{2}(:?[0-9]{2})?)/, m) { print m[0] }
|
|
58
|
-
' | head -n1
|
|
59
|
-
fi
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
date_is_gnu() { date --version >/dev/null 2>&1; }
|
|
63
|
-
|
|
64
|
-
normalize_for_bsd() {
|
|
65
|
-
local ts="$1"
|
|
66
|
-
# drop fractional seconds
|
|
67
|
-
ts="${ts%%.*}$(printf '%s' "$ts" | sed -nE 's/^[^.]*((\.[0-9]+)?)(.*)$/\3/p')"
|
|
68
|
-
# Z -> +0000
|
|
69
|
-
ts="$(printf '%s' "$ts" | sed -E 's/Z$/+0000/')"
|
|
70
|
-
# remove colon in tz offset
|
|
71
|
-
ts="$(printf '%s' "$ts" | sed -E 's/([+\-][0-9]{2}):?([0-9]{2})$/\1\2/')"
|
|
72
|
-
printf '%s' "$ts"
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
iso_to_epoch() {
|
|
76
|
-
local in="$1"
|
|
77
|
-
if date_is_gnu; then
|
|
78
|
-
date -d "$in" +%s 2>/dev/null && return 0
|
|
79
|
-
fi
|
|
80
|
-
local ts_bsd
|
|
81
|
-
ts_bsd="$(normalize_for_bsd "$in")"
|
|
82
|
-
if ! printf '%s' "$ts_bsd" | grep -Eq '(Z|[+\-][0-9]{4})$'; then
|
|
83
|
-
ts_bsd="${ts_bsd}+0000"
|
|
84
|
-
fi
|
|
85
|
-
date -j -f "%Y-%m-%dT%H:%M:%S%z" "$ts_bsd" "+%s" 2>/dev/null && return 0
|
|
86
|
-
return 1
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
file_mtime_epoch() {
|
|
90
|
-
local f="$1"
|
|
91
|
-
stat -f %m "$f" 2>/dev/null || stat -c %Y "$f" 2>/dev/null || echo 0
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
# Try multiple ways to run `codeyam verify`
|
|
95
|
-
run_codeyam_verify_bg() {
|
|
96
|
-
local root="$1"
|
|
97
|
-
local logfile="$2"
|
|
98
|
-
local cmd=""
|
|
99
|
-
if command -v codeyam >/dev/null 2>&1; then
|
|
100
|
-
cmd="codeyam verify"
|
|
101
|
-
elif command -v pnpm >/dev/null 2>&1 && [[ -f "$root/package.json" ]]; then
|
|
102
|
-
# prefer direct bin if present, otherwise script
|
|
103
|
-
if [[ -x "$root/node_modules/.bin/codeyam" ]]; then
|
|
104
|
-
cmd="$root/node_modules/.bin/codeyam verify"
|
|
105
|
-
else
|
|
106
|
-
cmd="pnpm codeyam verify"
|
|
107
|
-
fi
|
|
108
|
-
elif command -v npm >/dev/null 2>&1 && [[ -f "$root/package.json" ]]; then
|
|
109
|
-
if [[ -x "$root/node_modules/.bin/codeyam" ]]; then
|
|
110
|
-
cmd="$root/node_modules/.bin/codeyam verify"
|
|
111
|
-
else
|
|
112
|
-
cmd="npm run --silent codeyam -- verify"
|
|
113
|
-
fi
|
|
114
|
-
else
|
|
115
|
-
# last resort: npx fetch
|
|
116
|
-
cmd="npx -y codeyam verify"
|
|
117
|
-
fi
|
|
118
|
-
|
|
119
|
-
log "▶️ Launching verify command: (cd \"$root\" && $cmd)"
|
|
120
|
-
# Detach: nohup + background, independent of the hook lifecycle
|
|
121
|
-
( cd "$root" && nohup bash -lc "$cmd" >> "$logfile" 2>&1 & ) >/dev/null 2>&1
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
# Simple lock to avoid parallel verify runs
|
|
125
|
-
acquire_lock() {
|
|
126
|
-
local lock="$1"
|
|
127
|
-
if ( set -o noclobber; : > "$lock" ) 2>/dev/null; then
|
|
128
|
-
echo $$ > "$lock"
|
|
129
|
-
return 0
|
|
130
|
-
fi
|
|
131
|
-
return 1
|
|
132
|
-
}
|
|
133
|
-
release_lock() {
|
|
134
|
-
local lock="$1"
|
|
135
|
-
rm -f "$lock" 2>/dev/null || true
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
# =========================
|
|
139
|
-
# Read input JSON
|
|
140
|
-
# =========================
|
|
141
|
-
|
|
142
|
-
INPUT="$(cat)"
|
|
143
|
-
log "📥 Received input: $INPUT"
|
|
144
|
-
|
|
145
|
-
STOP_HOOK_ACTIVE="$(json_get_bool 'stop_hook_active' "$INPUT")"
|
|
146
|
-
TRANSCRIPT_PATH="$(json_get_str 'transcript_path' "$INPUT")"
|
|
147
|
-
REQUEST_CWD="$(json_get_str 'cwd' "$INPUT")"
|
|
148
|
-
|
|
149
|
-
log "Parsed stop_hook_active=${STOP_HOOK_ACTIVE:-}"
|
|
150
|
-
log "Parsed transcript_path=${TRANSCRIPT_PATH:-}"
|
|
151
|
-
log "Parsed cwd=${REQUEST_CWD:-}"
|
|
152
|
-
|
|
153
|
-
# If already in continuation loop, allow stop
|
|
154
|
-
if [[ "${STOP_HOOK_ACTIVE:-false}" == "true" ]]; then
|
|
155
|
-
log "⚠️ stop_hook_active=true - allow stop"
|
|
156
|
-
exit 0
|
|
157
|
-
fi
|
|
158
|
-
|
|
159
|
-
# cd to provided cwd if valid
|
|
160
|
-
if [[ -n "${REQUEST_CWD:-}" && -d "${REQUEST_CWD}" ]]; then
|
|
161
|
-
log "📂 cd $REQUEST_CWD"
|
|
162
|
-
cd "$REQUEST_CWD" || log "❌ cd failed"
|
|
163
|
-
fi
|
|
164
|
-
|
|
165
|
-
# Discover project root
|
|
166
|
-
PROJECT_ROOT="$(pwd)"
|
|
167
|
-
while [[ ! -d "$PROJECT_ROOT/.codeyam" && "$PROJECT_ROOT" != "/" ]]; do
|
|
168
|
-
PROJECT_ROOT="$(dirname "$PROJECT_ROOT")"
|
|
169
|
-
done
|
|
170
|
-
if [[ "$PROJECT_ROOT" == "/" ]]; then
|
|
171
|
-
log "❌ No .codeyam found; allow stop"
|
|
172
|
-
exit 0
|
|
173
|
-
fi
|
|
174
|
-
log "✅ Project root: $PROJECT_ROOT"
|
|
175
|
-
|
|
176
|
-
# Determine conversation start time
|
|
177
|
-
# Use the MORE RECENT of: last stop time OR session start time
|
|
178
|
-
LAST_STOP_FILE="$PROJECT_ROOT/.codeyam/.last-stop-time"
|
|
179
|
-
CONVERSATION_START_TIME=""
|
|
180
|
-
SESSION_START_TIME=""
|
|
181
|
-
LAST_STOP_TIME=""
|
|
182
|
-
|
|
183
|
-
# Get transcript session start time
|
|
184
|
-
if [[ -z "${TRANSCRIPT_PATH:-}" || ! -f "${TRANSCRIPT_PATH}" ]]; then
|
|
185
|
-
log "❌ transcript_path missing or file not found; allow stop"
|
|
186
|
-
exit 0
|
|
187
|
-
fi
|
|
188
|
-
|
|
189
|
-
SECOND_LINE="$(sed -n '2p' -- "$TRANSCRIPT_PATH" 2>/dev/null || true)"
|
|
190
|
-
log "Line2 (<=200 chars): ${SECOND_LINE:0:200}"
|
|
191
|
-
|
|
192
|
-
ISO_TS="$(extract_iso8601 "$SECOND_LINE" || true)"
|
|
193
|
-
log "ISO8601: ${ISO_TS:-<none>}"
|
|
194
|
-
|
|
195
|
-
if [[ -z "$ISO_TS" ]]; then
|
|
196
|
-
log "❌ Could not extract timestamp; allow stop"
|
|
197
|
-
exit 0
|
|
198
|
-
fi
|
|
199
|
-
|
|
200
|
-
if ! SESSION_START_TIME="$(iso_to_epoch "$ISO_TS")"; then
|
|
201
|
-
log "❌ Could not convert timestamp to epoch; allow stop"
|
|
202
|
-
exit 0
|
|
203
|
-
fi
|
|
204
|
-
log "🕒 Session start epoch: $SESSION_START_TIME"
|
|
205
|
-
|
|
206
|
-
# Get last stop time if it exists
|
|
207
|
-
if [[ -f "$LAST_STOP_FILE" ]]; then
|
|
208
|
-
LAST_STOP_TIME="$(cat "$LAST_STOP_FILE" 2>/dev/null || true)"
|
|
209
|
-
if [[ -n "$LAST_STOP_TIME" ]] && [[ "$LAST_STOP_TIME" =~ ^[0-9]+$ ]]; then
|
|
210
|
-
log "🕒 Last stop epoch: $LAST_STOP_TIME"
|
|
211
|
-
else
|
|
212
|
-
LAST_STOP_TIME=""
|
|
213
|
-
fi
|
|
214
|
-
fi
|
|
215
|
-
|
|
216
|
-
# Use whichever is more recent (higher epoch number)
|
|
217
|
-
if [[ -n "$LAST_STOP_TIME" ]] && [[ $LAST_STOP_TIME -gt $SESSION_START_TIME ]]; then
|
|
218
|
-
CONVERSATION_START_TIME="$LAST_STOP_TIME"
|
|
219
|
-
log "✅ Using last stop time (more recent): $CONVERSATION_START_TIME"
|
|
220
|
-
else
|
|
221
|
-
CONVERSATION_START_TIME="$SESSION_START_TIME"
|
|
222
|
-
log "✅ Using session start time: $CONVERSATION_START_TIME"
|
|
223
|
-
fi
|
|
224
|
-
|
|
225
|
-
# Gather changed files since start
|
|
226
|
-
log "git diff --name-only --diff-filter=AM"
|
|
227
|
-
ALL_CHANGED_FILES="$(
|
|
228
|
-
git diff --name-only --diff-filter=AM 2>/dev/null \
|
|
229
|
-
| grep -E '\.(ts|tsx|jsx|vue)$' \
|
|
230
|
-
| grep -Ev '\.(test|spec)\.(ts|tsx|jsx)$' \
|
|
231
|
-
| grep -Ev '\.d\.ts$' \
|
|
232
|
-
|| true
|
|
233
|
-
)"
|
|
234
|
-
|
|
235
|
-
CHANGED_FILES=""
|
|
236
|
-
if [[ -n "$ALL_CHANGED_FILES" ]]; then
|
|
237
|
-
while IFS= read -r file; do
|
|
238
|
-
[[ -z "$file" ]] && continue
|
|
239
|
-
[[ -f "$file" ]] || continue
|
|
240
|
-
FILE_MTIME="$(file_mtime_epoch "$file")"
|
|
241
|
-
log " $file mtime=$FILE_MTIME vs $CONVERSATION_START_TIME"
|
|
242
|
-
if [[ "$FILE_MTIME" =~ ^[0-9]+$ ]] && [[ $FILE_MTIME -ge $CONVERSATION_START_TIME ]]; then
|
|
243
|
-
CHANGED_FILES+="$file"$'\n'
|
|
244
|
-
fi
|
|
245
|
-
done <<< "$ALL_CHANGED_FILES"
|
|
246
|
-
fi
|
|
247
|
-
|
|
248
|
-
CHANGED_FILES="$(echo "$CHANGED_FILES" | sed '/^$/d')"
|
|
249
|
-
|
|
250
|
-
if [[ -n "$CHANGED_FILES" ]]; then
|
|
251
|
-
FILE_COUNT="$(echo "$CHANGED_FILES" | wc -l | tr -d ' ')"
|
|
252
|
-
log "✅ $FILE_COUNT changed file(s):"
|
|
253
|
-
log "$(echo "$CHANGED_FILES" | sed 's/^/ • /')"
|
|
254
|
-
|
|
255
|
-
# Save current time as last stop time BEFORE blocking
|
|
256
|
-
CURRENT_TIME="$(date +%s)"
|
|
257
|
-
echo "$CURRENT_TIME" > "$LAST_STOP_FILE" 2>/dev/null || log "⚠️ Could not save last stop time"
|
|
258
|
-
log "💾 Saved stop time: $CURRENT_TIME (before blocking)"
|
|
259
|
-
|
|
260
|
-
# Return structured JSON here if you want to block & trigger follow-up.
|
|
261
|
-
JSON_RESPONSE=$(cat << EOF
|
|
262
|
-
{
|
|
263
|
-
"decision": "block",
|
|
264
|
-
"reason": "$FILE_COUNT application files have changed. If these changes will likely be committed please use the \"CodeYam Verify\" skill to simulate these changes. If you are just debugging, then there is no need to.",
|
|
265
|
-
}
|
|
266
|
-
EOF
|
|
267
|
-
)
|
|
268
|
-
|
|
269
|
-
log "📤 Returning JSON (to stderr): $JSON_RESPONSE"
|
|
270
|
-
echo "$JSON_RESPONSE" >&2
|
|
271
|
-
|
|
272
|
-
log "✅ Hook completed successfully"
|
|
273
|
-
log "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
274
|
-
exit 2
|
|
275
|
-
else
|
|
276
|
-
log "ℹ️ No changed files since start"
|
|
277
|
-
# Save current time as last stop time for next continuation
|
|
278
|
-
CURRENT_TIME="$(date +%s)"
|
|
279
|
-
echo "$CURRENT_TIME" > "$LAST_STOP_FILE" 2>/dev/null || log "⚠️ Could not save last stop time"
|
|
280
|
-
log "💾 Saved stop time: $CURRENT_TIME"
|
|
281
|
-
fi
|
|
282
|
-
|
|
283
|
-
# Always allow the stop to proceed
|
|
284
|
-
exit 0
|