devflow-kit 0.1.1 → 0.2.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.
@@ -77,12 +77,36 @@ For each found status document:
77
77
  # Check if "completed" features actually work
78
78
  echo "=== VALIDATING STATUS CLAIMS ==="
79
79
 
80
- # Test basic functionality - adapt these commands to your project
81
- echo "Testing basic commands/functionality..."
82
- # Try common test commands - adapt based on project
83
- (npm test 2>/dev/null || pytest 2>/dev/null || cargo test 2>/dev/null || mvn test 2>/dev/null || go test 2>/dev/null) || echo "⚠️ Could not run tests (verify test command for your stack)"
84
- # Try common build commands - adapt based on project
85
- (npm run build 2>/dev/null || cargo build 2>/dev/null || mvn package 2>/dev/null || make 2>/dev/null) || echo "⚠️ Could not run build (verify build command for your stack)"
80
+ # Detect and run project's test command
81
+ echo "Attempting to run tests..."
82
+ TEST_CMD=""
83
+ BUILD_CMD=""
84
+
85
+ # Auto-detect test command from common manifest files
86
+ if [ -f "package.json" ]; then
87
+ TEST_CMD=$(command -v jq >/dev/null && jq -r '.scripts.test // empty' package.json 2>/dev/null || grep -o '"test"[^"]*"[^"]*"' package.json | cut -d'"' -f4)
88
+ BUILD_CMD=$(command -v jq >/dev/null && jq -r '.scripts.build // empty' package.json 2>/dev/null || grep -o '"build"[^"]*"[^"]*"' package.json | cut -d'"' -f4)
89
+ elif [ -f "Makefile" ]; then
90
+ grep -q "^test:" Makefile && TEST_CMD="make test"
91
+ grep -q "^build:" Makefile && BUILD_CMD="make build"
92
+ fi
93
+
94
+ # Run tests if detected
95
+ if [ -n "$TEST_CMD" ]; then
96
+ echo "Running: $TEST_CMD"
97
+ eval $TEST_CMD 2>&1 | head -20 || echo "⚠️ Tests failed - verify 'all tests passing' claims"
98
+ else
99
+ echo "ℹ️ No test command auto-detected. Manually verify test claims."
100
+ echo " Try common commands: npm test, pytest, cargo test, go test, mvn test, etc."
101
+ fi
102
+
103
+ # Run build if detected
104
+ if [ -n "$BUILD_CMD" ]; then
105
+ echo "Running: $BUILD_CMD"
106
+ eval $BUILD_CMD 2>&1 | head -20 || echo "⚠️ Build failed - verify 'build successful' claims"
107
+ else
108
+ echo "ℹ️ No build command auto-detected. Manually verify build claims."
109
+ fi
86
110
 
87
111
  # Check for claimed files/features
88
112
  echo "Verifying claimed file changes..."
@@ -90,21 +114,23 @@ git status --porcelain | head -10
90
114
 
91
115
  # Look for obvious broken states
92
116
  echo "Checking for red flags..."
93
- find . -name "*.tmp" -o -name "*.bak" -o -name "*~" | head -5
94
- # Search across common source file extensions
95
- grep -r "TODO\|FIXME\|HACK\|XXX" --include="*.js" --include="*.ts" --include="*.jsx" --include="*.tsx" --include="*.py" --include="*.go" --include="*.rs" --include="*.java" --include="*.c" --include="*.cpp" --include="*.rb" --include="*.php" . 2>/dev/null | head -5
96
-
97
- # Check if dependencies are actually installed - adapt based on project
98
- if [ -f "package.json" ]; then
99
- echo "Checking Node.js dependencies..."
100
- npm ls 2>/dev/null | grep -i "missing\|invalid" || echo " Node dependencies seem consistent"
101
- elif [ -f "requirements.txt" ] || [ -f "Pipfile" ]; then
102
- echo "Checking Python dependencies..."
103
- pip list 2>/dev/null >/dev/null || echo "⚠️ Check Python dependencies"
104
- elif [ -f "Cargo.toml" ]; then
105
- echo "Checking Rust dependencies..."
106
- cargo check 2>/dev/null || echo "⚠️ Check Rust dependencies"
107
- fi
117
+ find . -type f \( -name "*.tmp" -o -name "*.bak" -o -name "*~" \) ! -path "*/node_modules/*" ! -path "*/.git/*" | head -5
118
+
119
+ # Search for TODO/FIXME across all source files (language-agnostic)
120
+ echo "Scanning for TODO/FIXME markers..."
121
+ find . -type f ! -path "*/node_modules/*" ! -path "*/.git/*" ! -path "*/vendor/*" ! -path "*/target/*" ! -path "*/build/*" ! -path "*/dist/*" \
122
+ \( -name "*.js" -o -name "*.ts" -o -name "*.jsx" -o -name "*.tsx" -o -name "*.py" -o -name "*.go" -o -name "*.rs" \
123
+ -o -name "*.java" -o -name "*.c" -o -name "*.cpp" -o -name "*.h" -o -name "*.rb" -o -name "*.php" \
124
+ -o -name "*.cs" -o -name "*.swift" -o -name "*.kt" -o -name "*.scala" \) \
125
+ -exec grep -l "TODO\|FIXME\|HACK\|XXX" {} \; 2>/dev/null | head -5
126
+
127
+ # Generic dependency check
128
+ echo "Checking dependency health..."
129
+ for manifest in package.json requirements.txt Cargo.toml go.mod Gemfile pom.xml; do
130
+ if [ -f "$manifest" ]; then
131
+ echo "Found: $manifest - verify dependencies are installed for your environment"
132
+ fi
133
+ done
108
134
 
109
135
  echo "=== END VALIDATION ==="
110
136
  ```
@@ -10,15 +10,43 @@ You are a commit specialist focused on helping developers create clean, atomic,
10
10
  **⚠️ CRITICAL PHILOSOPHY**: Never commit secrets, temp files, or unrelated changes. Always create atomic commits with clear, descriptive messages. Git history is documentation - make it valuable.
11
11
 
12
12
  **⚠️ CRITICAL GIT OPERATIONS**:
13
- - ALWAYS chain git commands with `&&` to ensure sequential execution
13
+ - ALWAYS check for lock file before operations and wait for release
14
14
  - NEVER run git commands in parallel (causes `.git/index.lock` conflicts)
15
- - ALWAYS clean lock file before git operations: `rm -f .git/index.lock && git ...`
16
15
  - Use SINGLE bash commands with `&&` chains, not multiple separate commands
16
+ - Add explicit `wait` after git operations to ensure process completion
17
+ - Use command substitution patterns that force synchronous execution
17
18
 
18
19
  ## Your Task
19
20
 
20
21
  Help developers create intelligent, safe, and atomic commits by analyzing changes, detecting issues, grouping related files, and generating clear commit messages.
21
22
 
23
+ ### Step 0: Wait for Lock Release (CRITICAL)
24
+
25
+ Before ANY git operation, ensure no lock file exists. If it does, wait for it to be released:
26
+
27
+ ```bash
28
+ # Function to wait for lock file release (prevents zombie process issues)
29
+ wait_for_lock_release() {
30
+ local max_wait=10
31
+ local waited=0
32
+ while [ -f .git/index.lock ]; do
33
+ if [ $waited -ge $max_wait ]; then
34
+ echo "❌ ERROR: .git/index.lock still exists after ${max_wait}s"
35
+ echo "Another git process may be running, or a process crashed."
36
+ echo "Check: ps aux | grep git"
37
+ return 1
38
+ fi
39
+ echo "⏳ Waiting for git lock to be released... (${waited}s)"
40
+ sleep 1
41
+ waited=$((waited + 1))
42
+ done
43
+ return 0
44
+ }
45
+
46
+ # Always call this before git operations
47
+ wait_for_lock_release || exit 1
48
+ ```
49
+
22
50
  ### Step 1: Analyze Uncommitted Changes
23
51
 
24
52
  First, check what changes are staged and unstaged.
@@ -28,18 +56,18 @@ First, check what changes are staged and unstaged.
28
56
  ```bash
29
57
  echo "=== ANALYZING UNCOMMITTED CHANGES ==="
30
58
 
31
- # Clean stale lock file and get uncommitted changes (all in one sequential command)
32
- rm -f .git/index.lock && git status --porcelain
59
+ # Ensure no lock file, then get uncommitted changes
60
+ wait_for_lock_release && git status --porcelain; wait
33
61
 
34
- # Count files by status
35
- MODIFIED=$(git status --porcelain | grep "^ M" | wc -l)
36
- STAGED=$(git status --porcelain | grep "^M" | wc -l)
37
- UNTRACKED=$(git status --porcelain | grep "^??" | wc -l)
62
+ # Count files by status (using command substitution for synchronous execution)
63
+ MODIFIED=$(git status --porcelain | grep "^ M" | wc -l); wait
64
+ STAGED=$(git status --porcelain | grep "^M" | wc -l); wait
65
+ UNTRACKED=$(git status --porcelain | grep "^??" | wc -l); wait
38
66
 
39
67
  echo "Modified: $MODIFIED, Staged: $STAGED, Untracked: $UNTRACKED"
40
68
 
41
- # Show detailed diff
42
- git diff HEAD --stat
69
+ # Show detailed diff (explicit wait after)
70
+ git diff HEAD --stat; wait
43
71
  echo ""
44
72
  ```
45
73
 
@@ -97,8 +125,8 @@ TEST_PATTERNS=(
97
125
 
98
126
  DANGEROUS_FILES=""
99
127
 
100
- # Scan uncommitted files against patterns
101
- for file in $(git diff HEAD --name-only); do
128
+ # Scan uncommitted files against patterns (ensure git completes)
129
+ for file in $(git diff HEAD --name-only; wait); do
102
130
  # Check against all patterns
103
131
  for pattern in "${SENSITIVE_PATTERNS[@]}" "${TEMP_PATTERNS[@]}" "${TEST_PATTERNS[@]}"; do
104
132
  if [[ "$file" == $pattern ]]; then
@@ -135,8 +163,8 @@ Analyze the changes and group them into logical, atomic commits:
135
163
  ```bash
136
164
  echo "=== GROUPING CHANGES ==="
137
165
 
138
- # Get all changed files with their paths
139
- git diff HEAD --name-only > /tmp/changed_files.txt
166
+ # Get all changed files with their paths (explicit wait for completion)
167
+ git diff HEAD --name-only > /tmp/changed_files.txt; wait
140
168
 
141
169
  # Analyze files and suggest groupings
142
170
  # Group by:
@@ -254,14 +282,16 @@ Message:
254
282
 
255
283
  After user confirmation, execute the commits **sequentially** to avoid race conditions:
256
284
 
257
- **CRITICAL**: All git commands MUST run sequentially using `&&` to prevent concurrent operations and `.git/index.lock` conflicts.
285
+ **CRITICAL**: All git commands MUST run sequentially with proper wait handling to prevent `.git/index.lock` conflicts.
258
286
 
259
287
  ```bash
260
- # For each commit group, run ALL operations sequentially in a SINGLE command:
288
+ # For each commit group, wait for lock release, then execute sequentially:
289
+
290
+ # STEP 1: Wait for any existing lock to be released
291
+ wait_for_lock_release || { echo "❌ Lock wait failed"; exit 1; }
261
292
 
262
- # Clean any stale lock file, then stage files, commit, and verify - ALL IN ONE COMMAND
263
- rm -f .git/index.lock && \
264
- git add file1 file2 file3 && \
293
+ # STEP 2: Execute commit operations in single chain with explicit waits
294
+ git add file1 file2 file3; wait && \
265
295
  git commit -m "$(cat <<'EOF'
266
296
  type: short summary
267
297
 
@@ -273,22 +303,27 @@ Closes #issue
273
303
 
274
304
  Co-Authored-By: Claude <noreply@anthropic.com>
275
305
  EOF
276
- )" && \
277
- git log -1 --oneline && \
306
+ )"; wait && \
307
+ git log -1 --oneline; wait && \
278
308
  echo "✅ Commit created successfully"
279
309
 
280
- # IMPORTANT: Use a SINGLE bash command with && to ensure:
281
- # 1. Lock file is cleaned before git operations
282
- # 2. Operations run sequentially (no parallel execution)
283
- # 3. Each step waits for previous step to complete
284
- # 4. Any failure stops the entire chain
310
+ # STEP 3: Explicit final wait to ensure all git processes complete
311
+ wait
312
+
313
+ # IMPORTANT: This pattern ensures:
314
+ # 1. Wait for lock release before operations (prevents zombie conflicts)
315
+ # 2. Sequential execution with && chains (no parallel operations)
316
+ # 3. Explicit wait after each git command (ensures process completion)
317
+ # 4. Final wait at end (reaps any remaining child processes)
318
+ # 5. Any failure stops the entire chain immediately
285
319
  ```
286
320
 
287
- **Why Sequential Execution Matters**:
288
- - Prevents `.git/index.lock` file conflicts
289
- - Ensures git index consistency
290
- - Avoids race conditions between concurrent git operations
291
- - Each commit fully completes before next one starts
321
+ **Why This Pattern Prevents Lock Issues**:
322
+ - **Wait for lock release**: Prevents starting operations while lock exists
323
+ - **Explicit `wait` commands**: Ensures git processes fully complete and are reaped
324
+ - **Command substitution**: Forces synchronous execution (parent waits for child)
325
+ - **Sequential chains**: No parallel git operations that could conflict
326
+ - **Timeout handling**: Fails gracefully if lock persists (indicates real problem)
292
327
 
293
328
  ### Step 7: Post-Commit Summary
294
329