devflow-kit 2.2.0 → 2.4.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/CHANGELOG.md +45 -0
- package/dist/cli/commands/attribution-prompts.js +144 -0
- package/dist/cli/commands/compliance-prompts.js +7 -11
- package/dist/cli/commands/init-seed.js +45 -4
- package/dist/cli/commands/init.js +49 -6
- package/dist/cli/commands/prompt-io.js +38 -0
- package/dist/cli/commands/proxy.js +91 -31
- package/dist/cli/commands/uninstall.js +22 -12
- package/dist/commands/resolve.md +29 -16
- package/dist/core/flags.js +145 -4
- package/dist/core/proxy-log.js +4 -2
- package/dist/core/proxy-state.js +91 -37
- package/dist/targets/claude-code/post-install.js +106 -29
- package/package.json +2 -2
- package/src/assets/agents/learning.md +63 -13
- package/src/assets/agents/triage.md +19 -1
- package/src/assets/commands/resolve.mds +29 -16
- package/src/assets/scripts/hooks/background-memory-update +180 -37
- package/src/assets/scripts/hooks/ensure-proxy +64 -5
- package/src/assets/scripts/hooks/is-hex-sha +14 -0
- package/src/assets/scripts/hooks/json-helper.cjs +223 -38
- package/src/assets/scripts/hooks/lib/decisions-format.cjs +264 -43
- package/src/assets/scripts/hooks/lib/mkdir-lock.cjs +1 -1
- package/src/assets/scripts/hooks/lib/render-decisions.cjs +59 -28
- package/src/assets/scripts/hooks/pre-compact-memory +40 -22
- package/src/assets/scripts/hooks/session-start-memory +19 -20
- package/src/assets/skills/git/SKILL.md +1 -5
- package/src/assets/skills/git/references/patterns.md +0 -6
- package/src/targets/claude-code/templates/settings.json +0 -4
|
@@ -23,6 +23,7 @@ source "$SCRIPT_DIR/hook-bootstrap" "pre-compact-memory"
|
|
|
23
23
|
|
|
24
24
|
# JSON parsing (jq with node fallback) — silently no-op if neither available
|
|
25
25
|
source "$SCRIPT_DIR/json-parse" || { echo "pre-compact-memory: failed to source json-parse" >&2; exit 1; }
|
|
26
|
+
source "$SCRIPT_DIR/is-hex-sha" || { echo "pre-compact-memory: failed to source is-hex-sha" >&2; exit 1; }
|
|
26
27
|
if [ "$_JSON_AVAILABLE" = "false" ]; then exit 0; fi
|
|
27
28
|
|
|
28
29
|
INPUT=$(cat)
|
|
@@ -64,6 +65,7 @@ source "$SCRIPT_DIR/ensure-devflow-init" "$CWD" || exit 0
|
|
|
64
65
|
BACKUP_FILE="$MEMORY_DIR/backup.json"
|
|
65
66
|
|
|
66
67
|
# Capture git state
|
|
68
|
+
GIT_HEAD_SHA=""
|
|
67
69
|
GIT_BRANCH=""
|
|
68
70
|
GIT_STATUS=""
|
|
69
71
|
GIT_LOG=""
|
|
@@ -71,11 +73,12 @@ GIT_DIFF_STAT=""
|
|
|
71
73
|
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
|
72
74
|
|
|
73
75
|
if cd "$CWD" 2>/dev/null && git rev-parse --git-dir >/dev/null 2>&1; then
|
|
76
|
+
GIT_HEAD_SHA=$(git rev-parse HEAD 2>/dev/null || echo "")
|
|
74
77
|
GIT_BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown")
|
|
75
78
|
GIT_STATUS=$(git status --porcelain 2>/dev/null | head -30 || echo "")
|
|
76
79
|
GIT_LOG=$(git log --oneline -10 2>/dev/null || echo "")
|
|
77
80
|
GIT_DIFF_STAT=$(git diff --stat HEAD 2>/dev/null || echo "")
|
|
78
|
-
dbg "GIT_BRANCH=$GIT_BRANCH"
|
|
81
|
+
dbg "GIT_BRANCH=$GIT_BRANCH HEAD=$GIT_HEAD_SHA"
|
|
79
82
|
fi
|
|
80
83
|
|
|
81
84
|
# Snapshot current WORKING-MEMORY.md (preserves session context through compaction)
|
|
@@ -98,28 +101,43 @@ json_backup_construct \
|
|
|
98
101
|
log "Wrote backup: $BACKUP_FILE"
|
|
99
102
|
dbg "Wrote backup: $BACKUP_FILE"
|
|
100
103
|
|
|
101
|
-
# Bootstrap minimal WORKING-MEMORY.md if
|
|
102
|
-
#
|
|
104
|
+
# Bootstrap minimal WORKING-MEMORY.md if absent; skip on detached HEAD, unborn branch,
|
|
105
|
+
# or malformed SHA. is_hex_sha 40 40: exactly 40 lowercase hex chars required.
|
|
106
|
+
# avoids REL-5: O_EXCL-style atomic create via noclobber so the existence test and the
|
|
107
|
+
# create are one operation — if the worker's CAS mv lands in the window, noclobber fails
|
|
108
|
+
# (file already exists) and we skip the bootstrap rather than truncating fresh memory.
|
|
103
109
|
MEMORY_FILE="$MEMORY_DIR/WORKING-MEMORY.md"
|
|
104
|
-
if [
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
110
|
+
if [ -n "$GIT_BRANCH" ] && is_hex_sha "$GIT_HEAD_SHA" 40 40; then
|
|
111
|
+
if (set -o noclobber; : > "$MEMORY_FILE") 2>/dev/null; then
|
|
112
|
+
{
|
|
113
|
+
echo "<!-- memory-head: $GIT_HEAD_SHA branch: $GIT_BRANCH -->"
|
|
114
|
+
echo ""
|
|
115
|
+
echo "## Now"
|
|
116
|
+
echo "- Session compacted before working memory was established"
|
|
117
|
+
echo ""
|
|
118
|
+
echo "## Progress"
|
|
119
|
+
echo "- (no history yet)"
|
|
120
|
+
echo ""
|
|
121
|
+
echo "## Decisions"
|
|
122
|
+
echo "- (none recorded)"
|
|
123
|
+
echo ""
|
|
124
|
+
echo "## Context"
|
|
125
|
+
echo "- Branch: $GIT_BRANCH"
|
|
126
|
+
echo "$GIT_LOG" | head -3 | while IFS= read -r line; do
|
|
127
|
+
[ -n "$line" ] && echo "- $line"
|
|
128
|
+
done
|
|
129
|
+
if [ -n "$GIT_STATUS" ]; then
|
|
130
|
+
echo "- Modified files:"
|
|
131
|
+
echo "$GIT_STATUS" | head -10 | while IFS= read -r line; do
|
|
132
|
+
[ -n "$line" ] && echo " - $(echo "$line" | awk '{print $2}')"
|
|
133
|
+
done
|
|
134
|
+
fi
|
|
135
|
+
echo ""
|
|
136
|
+
echo "## Session Log"
|
|
137
|
+
echo "- (no entries)"
|
|
138
|
+
} >> "$MEMORY_FILE"
|
|
139
|
+
dbg "Bootstrapped minimal WORKING-MEMORY.md with stamp and canonical sections"
|
|
140
|
+
fi
|
|
123
141
|
fi
|
|
124
142
|
|
|
125
143
|
log "PreCompact complete"
|
|
@@ -68,6 +68,7 @@ fi
|
|
|
68
68
|
# Non-clobber: only recovers when .pending-turns.jsonl does NOT already exist,
|
|
69
69
|
# so a concurrent session's fresh queue is never overwritten.
|
|
70
70
|
source "$SCRIPT_DIR/get-mtime" || { echo "session-start-memory: failed to source get-mtime" >&2; exit 1; }
|
|
71
|
+
source "$SCRIPT_DIR/is-hex-sha" || { echo "session-start-memory: failed to source is-hex-sha" >&2; exit 1; }
|
|
71
72
|
_SSM_PT_PROC="$MEMORY_DIR/.pending-turns.processing"
|
|
72
73
|
_SSM_PT_JSONL="$MEMORY_DIR/.pending-turns.jsonl"
|
|
73
74
|
if [ -f "$_SSM_PT_PROC" ]; then
|
|
@@ -112,26 +113,11 @@ parse_and_validate_stamp() {
|
|
|
112
113
|
STAMP_BRANCH=$(echo "$FIRST_LINE" | sed -n 's/<!-- memory-head: [^ ]* branch: \([^ ]*\) -->/\1/p')
|
|
113
114
|
;;
|
|
114
115
|
esac
|
|
115
|
-
# Hex-validation security gate — must stay before any git use of STAMP_SHA
|
|
116
|
-
if [ -n "$STAMP_SHA" ]; then
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
local _SHA_CLEAN
|
|
121
|
-
_SHA_CLEAN=$(echo "$STAMP_SHA" | sed 's/[^0-9a-f]//g')
|
|
122
|
-
local _SHA_LEN=${#STAMP_SHA}
|
|
123
|
-
if [ "$_SHA_CLEAN" != "$STAMP_SHA" ] || [ "$_SHA_LEN" -gt 40 ]; then
|
|
124
|
-
dbg "STAMP_SHA rejected (non-hex chars or >40): $STAMP_SHA"
|
|
125
|
-
STAMP_SHA=""
|
|
126
|
-
STAMP_BRANCH=""
|
|
127
|
-
fi
|
|
128
|
-
;;
|
|
129
|
-
*)
|
|
130
|
-
dbg "STAMP_SHA rejected (bad prefix): $STAMP_SHA"
|
|
131
|
-
STAMP_SHA=""
|
|
132
|
-
STAMP_BRANCH=""
|
|
133
|
-
;;
|
|
134
|
-
esac
|
|
116
|
+
# Hex-validation security gate — must stay before any git use of STAMP_SHA.
|
|
117
|
+
if [ -n "$STAMP_SHA" ] && ! is_hex_sha "$STAMP_SHA"; then
|
|
118
|
+
dbg "STAMP_SHA rejected (non-hex or out of range): $STAMP_SHA"
|
|
119
|
+
STAMP_SHA=""
|
|
120
|
+
STAMP_BRANCH=""
|
|
135
121
|
fi
|
|
136
122
|
dbg "STAMP_SHA=$STAMP_SHA STAMP_BRANCH=$STAMP_BRANCH"
|
|
137
123
|
# Strip stamp line from injected body
|
|
@@ -147,16 +133,29 @@ parse_and_validate_stamp() {
|
|
|
147
133
|
|
|
148
134
|
# --- detect_refresh_failing: sets REFRESH_FAILING in caller's scope.
|
|
149
135
|
# Condition: queue non-empty AND (.last-refresh-ok missing OR >600s old)
|
|
136
|
+
# orphaned-processing depth fix: count both .pending-turns.jsonl AND
|
|
137
|
+
# .pending-turns.processing toward _queue_depth. Before this fix, an orphaned
|
|
138
|
+
# .processing (whose mtime is between 0s and the D56c 300s cold-path gate)
|
|
139
|
+
# was invisible to State-C — a crashed worker's batch would sit silently with
|
|
140
|
+
# no user-visible warning.
|
|
150
141
|
detect_refresh_failing() {
|
|
151
142
|
local _now="$1"
|
|
152
143
|
local _memory_dir="$2"
|
|
153
144
|
local _log_dir="$3"
|
|
154
145
|
local _queue_file="$_memory_dir/.pending-turns.jsonl"
|
|
146
|
+
local _proc_file="$_memory_dir/.pending-turns.processing"
|
|
155
147
|
local _ok_file="$_memory_dir/.last-refresh-ok"
|
|
156
148
|
local _queue_depth=0
|
|
157
149
|
if [ -f "$_queue_file" ] && [ -s "$_queue_file" ]; then
|
|
158
150
|
_queue_depth=$(wc -l < "$_queue_file" | tr -d ' ')
|
|
159
151
|
fi
|
|
152
|
+
# Also count lines in .processing — an orphaned batch left by a crashed worker
|
|
153
|
+
# is unprocessed content even if .jsonl is empty (applies B4 blind-spot fix)
|
|
154
|
+
if [ -f "$_proc_file" ] && [ -s "$_proc_file" ]; then
|
|
155
|
+
local _proc_depth
|
|
156
|
+
_proc_depth=$(wc -l < "$_proc_file" | tr -d ' ')
|
|
157
|
+
_queue_depth=$(( _queue_depth + _proc_depth ))
|
|
158
|
+
fi
|
|
160
159
|
local _ok_age=9999999
|
|
161
160
|
if [ -f "$_ok_file" ]; then
|
|
162
161
|
local _ok_mtime
|
|
@@ -97,8 +97,6 @@ See `references/patterns.md` for extended recovery and stash workflows.
|
|
|
97
97
|
<optional body explaining what and why>
|
|
98
98
|
|
|
99
99
|
<optional footer with references>
|
|
100
|
-
|
|
101
|
-
Co-Authored-By: Claude <noreply@anthropic.com>
|
|
102
100
|
```
|
|
103
101
|
|
|
104
102
|
### Types
|
|
@@ -125,8 +123,6 @@ Implement token validation middleware with:
|
|
|
125
123
|
- Expiration checking
|
|
126
124
|
|
|
127
125
|
Closes #123
|
|
128
|
-
|
|
129
|
-
Co-Authored-By: Claude <noreply@anthropic.com>
|
|
130
126
|
EOF
|
|
131
127
|
)"
|
|
132
128
|
```
|
|
@@ -205,7 +201,7 @@ sleep 1 # Between each API call
|
|
|
205
201
|
|
|
206
202
|
- Only lines in the PR diff can receive inline comments
|
|
207
203
|
- Deduplicate before posting (same file + line = keep one)
|
|
208
|
-
- Always include suggested fix and
|
|
204
|
+
- Always include a suggested fix; every comment carries the `<!-- devflow:* -->` marker, and the visible devflow footer (*Posted by [devflow](https://github.com/dean0x/devflow)*) is appended only on summary comments (see src/assets/agents/git.md)
|
|
209
205
|
|
|
210
206
|
### Releases
|
|
211
207
|
|
|
@@ -177,8 +177,6 @@ Previous implementation assumed UTC, causing off-by-one errors
|
|
|
177
177
|
for dates near midnight in non-UTC timezones.
|
|
178
178
|
|
|
179
179
|
Fixes #456
|
|
180
|
-
|
|
181
|
-
Co-Authored-By: Claude <noreply@anthropic.com>
|
|
182
180
|
EOF
|
|
183
181
|
)"
|
|
184
182
|
```
|
|
@@ -193,8 +191,6 @@ BREAKING CHANGE: API responses now follow JSON:API specification.
|
|
|
193
191
|
All clients must update to handle new response structure.
|
|
194
192
|
|
|
195
193
|
Migration guide: docs/migration/v2-response-format.md
|
|
196
|
-
|
|
197
|
-
Co-Authored-By: Claude <noreply@anthropic.com>
|
|
198
194
|
EOF
|
|
199
195
|
)"
|
|
200
196
|
```
|
|
@@ -255,8 +251,6 @@ gh pr create \
|
|
|
255
251
|
Implements JWT-based authentication...
|
|
256
252
|
|
|
257
253
|
[Full description content]
|
|
258
|
-
|
|
259
|
-
Generated with [Claude Code](https://claude.com/claude-code)
|
|
260
254
|
EOF
|
|
261
255
|
)"
|
|
262
256
|
```
|