This guide provides a terminal-focused reference for the maintenance and diagnostic utilities available in the scripts/ directory.
File: update.js
Purpose: Perform a safe, production-ready update.
# Pull latest code, install deps, and reload PM2
node dexbot updateNote: Protects your profiles/ directory and logs all changes to profiles/logs/update.log.
File: create-bot-symlinks.sh
Purpose: Create convenience root-level symlinks to profile data.
# Creates logs -> profiles/logs and orders -> profiles/orders
bash scripts/create-bot-symlinks.shFile: clear-logs.sh
Purpose: Delete all bot .log files.
# IRREVERSIBLE: Deletes all files in profiles/logs/*.log
bash scripts/clear-logs.shFile: clear-orders.sh
Purpose: Delete all persistent order state files.
# IRREVERSIBLE: Deletes all files in profiles/orders/*
bash scripts/clear-orders.shFile: clear-all.sh
Purpose: Delete order state files and .log files in one confirmed operation.
# IRREVERSIBLE: Deletes profiles/orders/* and profiles/logs/*.log
bash scripts/clear-all.shFile: validate_bots.js
Purpose: Check bots.json for schema errors or missing required fields.
# Validate both example and live bot configurations
node scripts/validate_bots.jsFile: divergence-calc.js
Purpose: Measure the "drift" between in-memory grid and disk state using RMS divergence metric.
# Calculates RMS Error (Default threshold is 14.3%)
# RMS quadratically penalizes large errors - see docs/README.md for threshold interpretation
node scripts/divergence-calc.jsReference: RMS threshold explanation in root README GRID RECALCULATION section
File: analyze-orders.js
Purpose: Analyze grid trading metrics and order distribution patterns.
# Analyzes spread accuracy, geometric consistency, and fund distribution
node scripts/analyze-orders.jsFile: analyze-repo-stats.js
Purpose: Generate a visual complexity and size report.
# Outputs repo-stats.html
node scripts/analyze-repo-stats.jsFile: git-viewer.sh
Purpose: Interactive monitor for uncommitted, committed, and pushed changes.
# Launch interactive git changes viewer with fzf search
bash scripts/git-viewer.shFeatures:
- View uncommitted (working tree) changes
- View committed (staged) changes
- View pushed vs. remote-tracking changes
- Smart auto-refresh (1s for local, 15s for remote)
- Fuzzy search with
fzffor finding files - Toggle between full file view and diff-only view
Usage:
# Press 'u' to toggle uncommitted changes
# Press 'c' to toggle committed changes
# Press 'p' to toggle pushed status
# Press 's' to search with fzf
# Press 'f' to toggle full file view
# Press 'q' to quitFile: dev-install.sh
Purpose: Install Jest, ESLint, and other dev-only dependencies.
bash scripts/dev-install.shFile: pmain.sh (also: npm run pmain)
Purpose: Sync local test branch through dev to main remote.
# Push test → dev → main
bash scripts/pmain.sh
# OR
npm run pmainFile: pdev.sh (also: npm run pdev)
Purpose: Sync local test branch to dev remote.
# Push test → dev
bash scripts/pdev.sh
# OR
npm run pdevFile: ptest.sh (also: npm run ptest)
Purpose: Push local test branch to remote.
# Push test to origin/test
bash scripts/ptest.sh
# OR
npm run ptestThe following scripts allow you to call dexbot commands directly from the scripts/ directory:
| Wrapper | Target Command | Usage |
|---|---|---|
scripts/bots |
node dexbot bots |
./scripts/bots |
scripts/keys |
node dexbot keys |
./scripts/keys |
scripts/dexbot |
node dexbot |
./scripts/dexbot <cmd> |
scripts/pm2 |
node pm2.js |
./scripts/pm2 |
| Command | Purpose |
|---|---|
npm run ptest |
Sync local test → origin/test |
npm run pdev |
Sync local test → dev |
npm run pmain |
Sync local test → dev → main |
npm test |
Run full test suite (100+ test cases) |
For understanding the systems these scripts interact with:
- Module Architecture: See root README 📦 Modules section
- Copy-on-Write Pattern: See docs/COPY_ON_WRITE_MASTER_PLAN.md for rebalancing architecture
- Fund Accounting: See docs/FUND_MOVEMENT_AND_ACCOUNTING.md
- Grid Divergence: See docs/README.md for RMS threshold explanations
- Logging System: See docs/LOGGING.md for log configuration and levels
Boost your workflow by adding these aliases to your ~/.bashrc or ~/.zshrc:
# DEXBot2 Shortcuts
alias dbu='node dexbot update'
alias dbc='bash scripts/clear-logs.sh'
alias dbr='bash scripts/clear-orders.sh'
alias dba='bash scripts/clear-all.sh'
alias dbv='node scripts/validate_bots.js'
alias dbd='node scripts/divergence-calc.js'Monitor live updates while running a script:
# Tail the update log in a separate pane
tail -f profiles/logs/update.logRun a specific bot dry-run from the CLI:
# Force a clean start for 'my-bot'
bash scripts/clear-orders.sh && BOT_NAME=my-bot node dexbot start