Continuing the dynamic-import-of-cached-module sweep started in 33cb210.
Same antipattern, same fix, four more files cleaned up:
src/commands/guidance.ts (5 sites)
All 5 handlers re-imported existsSync on every invocation.
Hoisted to static `import { existsSync } from 'node:fs'` at the top.
src/commands/performance.ts (3 sites)
metrics action re-imported os/fs/path together. Hoisted as namespace
imports so the existing `os.loadavg()` / `fs.statSync` / `path.resolve`
call sites stay readable.
src/commands/process.ts (2 sites)
daemon-stats action re-imported node:os; logs scanner re-imported
node:fs.readdirSync. Hoisted both to named imports
(cpus/loadavg/totalmem/freemem from os, readdirSync alongside the
existing fs imports).
src/commands/appliance.ts (3 sites)
requireFile, header, and rvfa extract action all re-imported
fs/path. Hoisted as named imports — pathJoin/pathResolve aliased
to avoid colliding with local `path` parameters.
Net: 13 dynamic-stdlib-import sites removed across 4 command files. Each
clears ~2µs (per the bench in 33cb210) and an async boundary that was
forcing the helper signatures to be unnecessarily async-colored.
Verified: tsc --noEmit clean (0 errors); commands.test.ts +
commands-deep.test.ts: 431/431 passing.
Remove Math.random() metrics from 6 locations:
- agent_health: CPU/memory/latency were random — now null with notes
- system_health: all checks were hardcoded "healthy" — now real fs checks
- coordination_metrics: latency/throughput were random — now null with real sync data
- github-tools: all 5 tools fabricated — now return _stub:true, local CRUD only
- process monitor: all metrics random — now real os.loadavg/memoryUsage
- hook-handler route: random latency, hardcoded matches — removed
Fix 6 bugs:
- task-tools path mismatch: agents.json → agents/store.json
- token-optimizer double-increment of editsOptimized
- config get: now reads real configManager instead of hardcoded map
- config providers: now reads/writes real config, mutation flags work
- session restore: now syncs to sql.js database after legacy JSON write
- claims rebalance: now executes moves when dryRun=false
Mark stubs honestly (_stub:true):
- neural compress/optimize
- performance bottleneck/profile/optimize
- hooks metrics/pretrain/intelligence-reset (reset now actually deletes files)
- workflow execute/resume (steps stay pending, not auto-completed)
- hooks session-end summary: reads real counts from stores
- hooks explain: reads real success rate from routing-outcomes.json
- hooks transfer: returns failure instead of demo data when source empty
- status.ts: performance claims → 'not measured'
Co-Authored-By: claude-flow <ruv@ruv.net>
- Updated standard-checkpoint-hooks.sh to accept both JSON and plain paths
- Fixed pre-edit and post-edit functions to detect input format
- Fixed v3 CLI hook flags (-f -> --file, -c -> --command, etc.)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>