E52D fix(scripts/af): macOS bash compatibility fixes by rooz-live · Pull Request #2 · rooz-live/agentic-flow · GitHub
[go: up one dir, main page]

Skip to content

fix(scripts/af): macOS bash compatibility fixes#2

Open
rooz-live wants to merge 1 commit intomainfrom
fix/scripts-af-bash-macos-compatibility
Open

fix(scripts/af): macOS bash compatibility fixes#2
rooz-live wants to merge 1 commit intomainfrom
fix/scripts-af-bash-macos-compatibility

Conversation

@rooz-live
Copy link
Owner

Summary

This PR addresses issue AF-SCRIPTS-001 (tracked in .goalie/insights_log.jsonl) with macOS bash compatibility fixes for scripts/af.

Problem

The scripts/af script had several macOS-specific compatibility issues:

  1. df output format handling
  2. date +%s%3N milliseconds format not supported
  3. return and local keywords used outside function scope

Changes

1. Line 196 - df Output Format

- local available_space=$(df "$PROJECT_ROOT" | awk 'NR==1 {print $4}' | tail -1)
+ local available_space=$(df "$PROJECT_ROOT" | awk 'NR==2 {print $4}')
+ # Handle non-numeric values (e.g., macOS may return different formats)
+ if [[ "$available_space" =~ ^[0-9]+$ ]] && [ "$available_space" -lt 1000 ]; then
  • Changed from NR==1 to NR==2 to capture data row instead of header
  • Added numeric validation guard

2. Lines 380, 413 - date Milliseconds

# macOS: %3N produces literal "N", use seconds * 1000
if date +%s%3N 2>/dev/null | grep -q 'N$'; then
    start_time=$(($(date +%s) * 1000))
else
    # Linux: %3N works correctly
    start_time=$(date +%s%3N)
fi
  • Added portable detection for macOS vs Linux
  • Fallback uses $(date +%s) * 1000 on macOS

3. Lines 2425-2707 - return/local Outside Function

- return 1
+ exit 1
  • Changed return 1 to exit 1 in main case blocks (6 occurrences)
  • Removed local keyword from top-level case block variables

Testing

  • Bash syntax validation: bash -n scripts/af passes
  • IRIS prod-cycle integration tests: 5/6 passing
    • 1 failure unrelated (missing governance.py)
  • macOS date compatibility verified
  • df output parsing verified on macOS

Issue Reference

Issue ID: AF-SCRIPTS-001
Tracked in: .goalie/insights_log.jsonl

Platform Tested

  • macOS 14.x (Sonoma)
  • zsh shell
  • Bash 5.x

Pull Request opened by Augment Code with guidance from the PR author

This commit addresses issue AF-SCRIPTS-001 with the following fixes:

1. Line 196 (df output format):
   - Changed from 'NR==1' to 'NR==2' to capture data row instead of header
   - Added numeric validation guard to handle macOS-specific output formats
   - Fixes: df on macOS includes header row, Linux may have different format

2. Lines 380, 413 (date +%s%3N milliseconds):
   - macOS date doesn't support %3N (produces literal 'N' suffix)
   - Added portable detection: checks if output ends with 'N'
   - Fallback: uses $(date +%s) * 1000 on macOS
   - Linux: continues using native %3N support

3. Lines 2425, 2443, 2467, 2667, 2687, 2707 (return outside function):
   - Changed 'return 1' to 'exit 1' in main case blocks
   - These are in top-level case statements, not inside functions
   - 'local' at line 2461-2462 also fixed (removed 'local' keyword)

Tested on:
- macOS 14.x (Sonoma) with zsh
- Bash syntax validation: bash -n scripts/af passes
- IRIS prod-cycle integration: 5/6 tests passing
  (1 failure unrelated - missing governance.py)

Issue: AF-SCRIPTS-001
Tracked in: .goalie/insights_log.jsonl

# ─── Retro→Code Linking Tags (optional but recommended) ───
# Add tags to link commits to retrospectives and track WSJF metrics:
#
# [QW-ID:xxx] [RETRO-ID:yyy] [WSJF:x.y] [CoD:$zzz] [Repo:agentic-flow]
#
# Example:
# [QW-ID:NOW-1] [RETRO-ID:2025-11-13] [WSJF:10.0] [CoD:$500/day] [Repo:agentic-flow]
#
# Quick reference:
# - QW-ID: Quick wins item ID (NOW-1, NEXT-4, etc.)
# - RETRO-ID: Retrospective date or ID
# - WSJF: Weighted Shortest Job First score
# - CoD: Cost of Delay estimate
# - Repo: Repository name for cross-repo tracking
rooz-live pushed a commit that referenced this pull request Nov 29, 2025
…ompletions (#40)

## Problem
The --stream flag in agentic-flow CLI provided no real-time output during agent
execution. Users saw only "⏳ Running..." for 5-60 minute tasks with no visibility
into what the agent was doing, making it appear frozen.

## Root Cause
The streaming implementation only handled `msg.type === 'assistant'` text messages
and completely ignored:
- Tool use events (when agent calls MCP tools)
- Tool completion events
- Progress indicators during long operations

## Solution
Enhanced streaming to capture and display all agent activity in real-time:

### 1. Enhanced Message Handling (src/agents/claudeAgent.ts)
- Added detection of `content_block_start` events with tool_use
- Added detection of `content_block_stop` events (tool completion)
- Added tool call counter to track number of tools executed
- Added timestamps to all progress messages for debugging
- Separated progress indicators (stderr) from content (stdout)
- Added `process.stderr.uncork()` and `process.stdout.uncork()` for immediate output

### 2. Improved Stream Handler (src/index.ts)
- Enhanced stream handler to route progress indicators to stderr
- Routes assistant text content to stdout (keeps output clean)
- Forces immediate flush for both stdout and stderr

### 3. Test Script (tests/test-streaming-output.js)
- Validates tool calls are logged in real-time
- Validates tool completions are logged
- Validates timestamps are included
- Validates stdout/stderr separation

## Expected Output (After Fix)
```
⏳ Running...

[16:40:15] 🔍 Tool call #1: Bash
[16:40:19] ✅ Tool completed
[16:40:20] 🔍 Tool call #2: Write
[16:40:21] ✅ Tool completed
✅ Analysis complete
```

## Impact
- ✅ Real-time visibility into agent progress
- ✅ Tool execution tracking for debugging
- ✅ Better production monitoring
- ✅ Improved E2B sandbox timeout management
- ✅ Real-time cost/token tracking

Fixes #40
rooz-live pushed a commit that referenced this pull request Nov 29, 2025
- Tool calls appear in msg.type === 'assistant' with content blocks
- Added detection of tool_use blocks in message.content
- Added DEBUG_STREAMING mode for troubleshooting
- Streaming now shows tool calls in real-time with timestamps

Tested with live API and confirmed working:
[21:00:30] 🔍 Tool call #1: Bash
[21:00:31] 🔍 Tool call #2: Write
rooz-live pushed a commit that referenced this pull request Dec 9, 2025
This commit resolves two critical issues in the AgentDB CLI:

1. MCP Command Integration (Issue #1)
   - Added `handleMcpCommand()` function to launch MCP server
   - Integrated `mcp start` command into CLI entry point
   - MCP server now accessible via `agentdb mcp start`
   - Starts successfully with 29 tools (5 core + 9 frontier + 10 learning + 5 AgentDB)

2. Schema Loading Fix (Issue #2)
   - Updated build process to copy SQL schemas to dist directory
   - Added `copy:schemas` npm script to package.json
   - Fixed CLI to load BOTH schema.sql and frontier-schema.sql
   - Added multiple fallback paths for schema discovery
   - Improved error messages for schema loading failures

Changes:
- src/cli/agentdb-cli.ts:
  * Lines 22-26: Added ESM __dirname support
  * Lines 66-104: Dual schema loading with fallback paths
  * Lines 651-665: MCP command routing
  * Lines 699-726: New handleMcpCommand() function
  * Lines 888-890: Updated help text with MCP commands

- package.json:
  * Line 24: Updated build script to include copy:schemas
  * Line 26: New copy:schemas script

- tests/cli-test-suite.sh: Comprehensive automated test suite
- docs/CLI-VALIDATION-RESULTS.md: Detailed validation report
- docs/VALIDATION-SUMMARY.md: Executive summary

Test Results: 17/17 PASSED ✅
- Help & Info Commands (2 tests)
- Database Commands (1 test)
- Reflexion Commands (3 tests)
- Skill Commands (3 tests)
- Causal Commands (5 tests)
- Recall Commands (1 test)
- Learner Commands (1 test)
- MCP Commands (1 test)

All AgentDB CLI commands now fully functional and validated.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
rooz-live pushed a commit that referenced this pull request Dec 9, 2025
…ompletions (#40)

## Problem
The --stream flag in agentic-flow CLI provided no real-time output during agent
execution. Users saw only "⏳ Running..." for 5-60 minute tasks with no visibility
into what the agent was doing, making it appear frozen.

## Root Cause
The streaming implementation only handled `msg.type === 'assistant'` text messages
and completely ignored:
- Tool use events (when agent calls MCP tools)
- Tool completion events
- Progress indicators during long operations

## Solution
Enhanced streaming to capture and display all agent activity in real-time:

### 1. Enhanced Message Handling (src/agents/claudeAgent.ts)
- Added detection of `content_block_start` events with tool_use
- Added detection of `content_block_stop` events (tool completion)
- Added tool call counter to track number of tools executed
- Added timestamps to all progress messages for debugging
- Separated progress indicators (stderr) from content (stdout)
- Added `process.stderr.uncork()` and `process.stdout.uncork()` for immediate output

### 2. Improved Stream Handler (src/index.ts)
- Enhanced stream handler to route progress indicators to stderr
- Routes assistant text content to stdout (keeps output clean)
- Forces immediate flush for both stdout and stderr

### 3. Test Script (tests/test-streaming-output.js)
- Validates tool calls are logged in real-time
- Validates tool completions are logged
- Validates timestamps are included
- Validates stdout/stderr separation

## Expected Output (After Fix)
```
⏳ Running...

[16:40:15] 🔍 Tool call #1: Bash
[16:40:19] ✅ Tool completed
[16:40:20] 🔍 Tool call #2: Write
[16:40:21] ✅ Tool completed
✅ Analysis complete
```

## Impact
- ✅ Real-time visibility into agent progress
- ✅ Tool execution tracking for debugging
- ✅ Better production monitoring
- ✅ Improved E2B sandbox timeout management
- ✅ Real-time cost/token tracking

Fixes #40
rooz-live pushed a commit that referenced this pull request Dec 9, 2025
- Tool calls appear in msg.type === 'assistant' with content blocks
- Added detection of tool_use blocks in message.content
- Added DEBUG_STREAMING mode for troubleshooting
- Streaming now shows tool calls in real-time with timestamps

Tested with live API and confirmed working:
[21:00:30] 🔍 Tool call #1: Bash
[21:00:31] 🔍 Tool call #2: Write
@rooz-live rooz-live force-pushed the fix/scripts-af-bash-macos-compatibility branch from 2581d8a to e6d6bfd Compare December 9, 2025 00:51
rooz-live pushed a commit that referenced this pull request Feb 28, 2026
- Generate reports/roam-assessment.json from trajectory + skills data
- Calculate 4 ROAM dimensions: Reach (60), Optimize (92), Automate (55), Monitor (50)
- Overall score: 64/100 with 100% measurement coverage
- Schema v1.0 with staleness threshold (3 days)
- Data sources: 8 trajectory baselines, 2 skills
- P0 Fix #2 complete (30 min)

Co-Authored-By: Warp <agent@warp.dev>
rooz-live pushed a commit that referenced this pull request Feb 28, 2026
- evidence-bundle-accelerator.sh: Automates photo/financial/work-order status check
  - ROI: 6hr manual → 30min automated = 12x speedup
  - Validates: 3 photos (✅), 0 financials (❌), 0 work orders (❌)
  - Clear TODO list for MAA portal exports

- pdf_classifier.py: Classifies legal PDFs (Answer/Motion/Complaint/Order)
  - Uses macOS textutil + fallback to pdftotext
  - Generates suggested rename commands
  - Note: Court PDFs are often scanned images (text extraction failed)

Trial #1: March 3 (8 days)
Trial #2: March 10 (15 days)

Co-Authored-By: Warp <agent@warp.dev>
rooz-live pushed a commit that referenced this pull request Feb 28, 2026
WSJF #2: Validator discovery catalog (VALIDATOR_INVENTORY.md)
  - 4 Rust, 9 Python, 30+ shell, 4 TS validators inventoried
  - EmailValidatorService and evidence_validator.rs flagged 0 tests

WSJF #3: TS consumer CI (packages/neural-trader/tests/consumer.test.js)
  - 3 pure-Node consumer contract tests
  - node-test job already in wsjf-domain-bridge.yml from prior commit

WSJF #4: ServiceDirectory module (crates/reverse-recruiter/)
  - 6 real services (Sprout, FindMyProfession, CareerAgents, etc.)
  - 20/20 unit tests passing
  - Wired into domains/mod.rs and lib.rs re-exports
  - Full crate: profile, job_matching, application, integration, scoring

ROAM cycle_22: Tracker refreshed (was 6 days stale, 96h threshold breached)
  - last_updated: 2026-02-22 → 2026-02-28
  - days_remaining: Trial #1 = 3d, Trial #2 = 10d
  - R005 staleness risk → MITIGATED
  - DPC_R = 79.0 (target ≥72) ✓

Co-Authored-By: Oz <oz-agent@warp.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0