Skip to content

[EPIC-D][LOU-D31] loushy dev serves agent directories, TS agents and specs with hot reload - #110

Merged
LinuxDevil merged 2 commits into
mainfrom
lou-d31-dev-dirs-hot-reload
Oct 1, 2026
Merged

LinuxDevil merged 2 commits into
mainfrom
lou-d31-dev-dirs-hot-reload

Conversation

@LinuxDevil

Copy link
Copy Markdown
Owner

What

loushy dev <path> now accepts a spec file (as before), an agent directory (loadAgentDir) or a .ts/.js module whose default (or agent) export is a SimpleAgent or a createAgent() options object. New src/cli/devReload.ts holds target detection, the watcher and the reload swap; dev.ts uses it and gains GET /dev/status; the chat page shows a banner when the last reload failed. importModule() gains an AsyncLocalStorage-based withFreshImports() so directory tool/config files are imported with ?t=<token>.

Why

Matrix rows "Hot reload" and "Dev TUI / REPL" were partial: dev only watched one spec file. eve's eve dev hot-reloads instructions and config; this brings directories and TS agents to parity.

Acceptance criteria

  • loushy dev <path> accepts a spec file, an agent directory or a .ts/.js module (default or agent export: SimpleAgent or createAgent config); detection by path type and extension; errors use LOU-D2 codes/hints (LOUSHY_CONFIG_INVALID, LOUSHY_SPEC_UNSUPPORTED_FORMAT)
  • Hot reload: watches the directory tree, or the module and its relative imports (walked once, no bundler); debounced (100 ms); cache-busted ?t= import so edited tools reload; new agent is built and ready() first, swapped in, then the previous agent is close()d; logs what reloaded; a failed reload keeps the last good agent and reports the error in the console, the chat UI banner and /dev/status
  • Spec-file behaviour unchanged (existing tests untouched and passing); chat is still one shared agent (no streaming / per-tab state; that is LOU-D32)
  • Tests in src/cli/dev.test.ts: dir mode (fixture), TS module mode (fixture), instructions.md and tool edits trigger a reload (real watcher, 20 ms debounce, temp copy), failed reload keeps the previous agent and recovers
  • Docs: docs/cli.md dev section, docs/agent-directories.md "Run it with loushy dev", llms files regenerated, CHANGELOG (Added)

Notes: a module imported by a reloaded file (shared helper) stays cached by Node, so it needs a restart (documented); changes to it still trigger a reload. The new agent is readied before the old one is closed (rather than closing first) so a failing reload never leaves a closed agent in service.

How verified

  • npx tsc --noEmit: pass
  • npm run lint: 0 errors, 402 warnings (main: 404)
  • npm run test:types: 6 files, 30 tests passed
  • npx vitest run: 157 files passed, 2287 passed, 3 skipped
  • npm run build && npm run build --workspace=packages/create-loushy-agent: success
  • npm run docs:verify-snippets -- --skip-build: all 120 snippets type-check, 6 run cleanly
  • npm run docs:llms:check: pass
  • npm run test:coverage: 157 files passed, 2287 passed; All files 90.42% statements
  • npm run fallow: No issues found
  • Manual: built node bin/loushy.js dev agent.ts, edited the file, the next /chat answered from the new version and /dev/status reported reloads: 1

🤖 Generated with Claude Code

https://claude.ai/code/session_016bY29ibQgv3MDdjAbUT4YR


Generated by Claude Code

claude added 2 commits October 1, 2026 16:50
…specs with hot reload

loushy dev <path> now takes a spec file, an agent directory (loadAgentDir) or a
.ts/.js module exporting a SimpleAgent or createAgent() config. It watches the
directory tree or the module and its relative imports, debounces, rebuilds with
a ?t= cache-busted import, readies the new agent, swaps it in and closes the
previous one. A failed reload keeps the last good agent and is reported in the
console, the chat page banner and GET /dev/status.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016bY29ibQgv3MDdjAbUT4YR
@LinuxDevil
LinuxDevil merged commit a685da2 into main Oct 1, 2026
2 checks passed
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.

2 participants