Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
docs(dev): map tasks to owners and focused verification
chengyongru0a654a666dfc
diff --git a/.agent/design.md b/.agent/design.mdindex 56cb71fee..66bcde0b9 100644--- a/.agent/design.md+++ b/.agent/design.md@@ -20,6 +20,10 @@ Python rules live in [scripts/check_import_boundaries.py](../scripts/check_imporThe checks cover selected direct imports and client initialization dependencies. They do not establish a complete runtime dependency graph; execution, state ownership, and security contracts still require behavioral verification.+## Keep a change locally understandable++Group code by the behavior it owns, not a target file length. A useful extraction owns its state, subscriptions, and cleanup behind a narrow typed interface; moving helpers while exposing the original component's entire state does not create a boundary. Keep collaborating logic together when separating it would require more context to understand the same change. Preserve cross-owner tests and point task navigation at the new owner when one moves.+## Prefer duplication over premature abstractionChannels and providers are allowed to repeat similar logic (send retries, media handling, message splitting). Do not introduce complex base classes or shared helpers just to eliminate duplication across channel files. Each channel file should remain self-contained and readable on its own. The same applies to provider implementations.diff --git a/.agent/navigation.md b/.agent/navigation.mdnew file mode 100644index 000000000..e57e730d7--- /dev/null+++ b/.agent/navigation.md@@ -0,0 +1,34 @@+# Find the owning code++Choose the affected behavior below, then read its owner and existing tests. Follow only the relevant links; this is a task index, not a required reading list. Search the selected area for the user-visible operation before expanding to callers and shared contracts.++| Change | Start here | Existing coverage |+| --- | --- | --- |+| Browser input, pairing, navigation, history, or settings | [WebUI change map](../webui/README.md#change-a-behavior) | The map pairs each behavior with component and browser tests |+| Terminal input, menus, or rendering | [TUI source layout](../tui/README.md#source-layout) | Colocated tests; application interactions in [`tui/src/app/`](../tui/src/app/) |+| A chat channel or its setup UI | [Channel package guide](../docs/channel-package-guide.md), then its package in [`nanobot/channels/`](../nanobot/channels/) | The channel's own `tests/`, including `tests/webui/`; shared contracts in [`tests/channels/`](../tests/channels/) |+| Provider selection or model requests | [Provider extension guide](../docs/development.md#adding-an-llm-provider), [`providers/routing.py`](../nanobot/providers/routing.py), then the selected adapter | [`tests/providers/`](../tests/providers/) |+| A tool's arguments or execution | The implementation and adjacent configuration in [`agent/tools/`](../nanobot/agent/tools/); [`base.py`](../nanobot/agent/tools/base.py) for the shared contract | [`tests/tools/`](../tests/tools/); runtime/session tools in [`tests/agent/tools/`](../tests/agent/tools/) |+| Slash commands or command dispatch | [`command/router.py`](../nanobot/command/router.py), [`command/builtin.py`](../nanobot/command/builtin.py) | [`tests/command/`](../tests/command/) |+| Turn scheduling, cancellation, or delivery | [`agent/loop.py`](../nanobot/agent/loop.py), [`agent/turn_delivery.py`](../nanobot/agent/turn_delivery.py) | [`test_loop_concurrency.py`](../tests/agent/test_loop_concurrency.py), [`test_task_cancel.py`](../tests/agent/test_task_cancel.py), [`test_turn_delivery.py`](../tests/agent/test_turn_delivery.py) |+| Model/tool iterations, retry, or injected input | [`agent/runner.py`](../nanobot/agent/runner.py) | [`test_runner_core.py`](../tests/agent/test_runner_core.py), [`test_runner_fallback.py`](../tests/agent/test_runner_fallback.py), [`test_runner_injections.py`](../tests/agent/test_runner_injections.py) |+| Prompt assembly, skills, or context limits | [`agent/context.py`](../nanobot/agent/context.py), [`agent/context_governance.py`](../nanobot/agent/context_governance.py); [prompt cautions](gotchas.md#prompt-templates) | [`test_context_builder.py`](../tests/agent/test_context_builder.py), [`test_skills_loader.py`](../tests/agent/test_skills_loader.py), [`test_context_governance.py`](../tests/agent/test_context_governance.py) |+| Session persistence or recovery | [`session/state.py`](../nanobot/session/state.py), [`session/sqlite_store.py`](../nanobot/session/sqlite_store.py), [`session/recovery.py`](../nanobot/session/recovery.py) | [`tests/session/`](../tests/session/), [`test_loop_recovery.py`](../tests/agent/test_loop_recovery.py) |+| WebUI/TUI wire events or displayed history | [`webui/outbound_delivery.py`](../nanobot/webui/outbound_delivery.py), [`webui/transcript.py`](../nanobot/webui/transcript.py); [client compatibility](review-guide.md) | [`tests/webui/`](../tests/webui/), [`WebSocket tests`](../nanobot/channels/websocket/tests/), and affected client tests |+| Workspace access or sandbox enforcement | [`security/workspace_access.py`](../nanobot/security/workspace_access.py), [`agent/tools/sandbox.py`](../nanobot/agent/tools/sandbox.py); [security rules](security.md) | [`tests/security/`](../tests/security/), [`test_workspace_scope.py`](../tests/agent/test_workspace_scope.py), [`test_sandbox.py`](../tests/tools/test_sandbox.py) |+| Gateway startup, shutdown, or launchers | [`gateway/`](../nanobot/gateway/), [`cli/gateway_runtime.py`](../nanobot/cli/gateway_runtime.py) | [`tests/gateway/`](../tests/gateway/), the matching launcher tests in [`tests/cli/`](../tests/cli/) |++For the end-to-end runtime flow, expand to [Architecture](../docs/architecture.md). For ownership changes, read [Design Constraints](design.md); directory proximity does not permit crossing those boundaries.++## Find the smallest useful check++Start with an existing test that exercises the changed operation and its relevant failure or lifecycle edge. File names above are entry points, not an exhaustive acceptance list. Keep integration coverage when the change crosses owners.++| Surface | Focused command | Setup and full checks |+| --- | --- | --- |+| Python | From the root: `uv run --no-sync python -m pytest tests/path/test_feature.py` | [Contribution setup](../CONTRIBUTING.md#development-setup), including channel dependencies for strict checking |+| WebUI | From `webui/`: `bun run test src/tests/feature.test.tsx` | [WebUI checks](../webui/README.md#test); channel UI tests are included by the same configuration |+| Browser | From `webui/`: `bun run test:browser browser/feature.spec.ts` | [WebUI checks](../webui/README.md#test) and the existing fixture for the affected interaction |+| TUI | From `tui/`: `bun test src/feature/feature.test.ts` | [TUI checks](../tui/README.md); terminal behavior still needs its real terminal path |++The command paths in this table are placeholders: substitute the selected existing file. Respect the task's local/remote verification boundary. Focused checks shorten feedback; they do not replace the required CI checks selected by [the workflow](../.github/workflows/ci.yml) and [its path rules](../scripts/ci_scope.py).diff --git a/AGENTS.md b/AGENTS.mdindex c03a774a6..9f2cdae9c 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -6,6 +6,7 @@ The Python gateway owns agent execution, sessions, tools, memory, and security p| When working on | Read || --- | --- |+| Finding the owning code and focused tests | [`.agent/navigation.md`](.agent/navigation.md) || Core boundaries, extensions, or internal types | [`.agent/design.md`](.agent/design.md) || Refactoring, fallbacks, or test selection | [`.agent/simplify.md`](.agent/simplify.md) || User-facing copy, feature naming, or localization | [`.agent/copywriting.md`](.agent/copywriting.md) |diff --git a/docs/development.md b/docs/development.mdindex ef6cdde8f..7b315ae54 100644--- a/docs/development.md+++ b/docs/development.md@@ -2,7 +2,7 @@This page collects contributor-facing notes for extending nanobot. User-facing setup and runtime options live in [`configuration.md`](./configuration.md).-For browser interface changes, start with [WebUI development](../webui/README.md). For Python setup and contribution checks, see [CONTRIBUTING.md](../CONTRIBUTING.md). The sections below cover provider extensions.+For source and test entry points by task, start with the [development navigation](../.agent/navigation.md). For browser interface changes, use the [WebUI change map](../webui/README.md#change-a-behavior). For Python setup and contribution checks, see [CONTRIBUTING.md](../CONTRIBUTING.md). The sections below cover provider extensions.## Adding an LLM Providerdiff --git a/webui/README.md b/webui/README.mdindex 586df7e80..1cd816aa3 100644--- a/webui/README.md+++ b/webui/README.md@@ -29,6 +29,23 @@ nanobot/channels/*/webui/ channel-owned interface codenanobot/channels/*/tests/webui/ channel interface tests```+## Change a behavior++Choose the behavior first, then follow the owning module and its existing tests. Paths below are relative to `webui/` unless they start with `../`. Read [component ownership](COMPONENTS.md#where-components-belong) when introducing or moving a boundary.++| Change | Owning source | Start verification with |+| --- | --- | --- |+| Composer input, attachments, mentions, or waiting prompts | [`ThreadComposer.tsx`](src/components/thread/ThreadComposer.tsx) and its feature-owned hooks | [`thread-composer.test.tsx`](src/tests/thread-composer.test.tsx), [`thread-composer-attach.test.tsx`](src/tests/thread-composer-attach.test.tsx) |+| Chat-channel pairing prompts and approval | [`components/pairing/`](src/components/pairing/); backend [`nanobot/pairing/`](../nanobot/pairing/) | Pairing scenarios in [`app-layout.test.tsx`](src/tests/app-layout.test.tsx), [`pairing-refresh.spec.ts`](browser/pairing-refresh.spec.ts) |+| Startup, authentication, navigation, or session selection | [`App.tsx`](src/App.tsx), [`useSessions.ts`](src/hooks/useSessions.ts), [`ClientProvider.tsx`](src/providers/ClientProvider.tsx) | [`app-layout.test.tsx`](src/tests/app-layout.test.tsx); keep shell integration checks when moving an owner |+| Live messages, delivery, or completion | [`nanobot-client.ts`](src/lib/nanobot-client.ts), [`useNanobotStream.ts`](src/hooks/useNanobotStream.ts), [`ThreadShell.tsx`](src/components/thread/ThreadShell.tsx) | [`nanobot-client.test.ts`](src/tests/nanobot-client.test.ts), [`useNanobotStream.test.tsx`](src/tests/useNanobotStream.test.tsx), [`thread-shell.test.tsx`](src/tests/thread-shell.test.tsx) |+| History pagination, reading position, or boundary motion | [`usePromptHistory.ts`](src/hooks/usePromptHistory.ts), [`ThreadViewport.tsx`](src/components/thread/ThreadViewport.tsx); [motion ownership](COMPONENTS.md#history-boundary-motion) | [`thread-viewport.test.tsx`](src/tests/thread-viewport.test.tsx), [`thread-history-spring.test.ts`](src/tests/thread-history-spring.test.ts), [`thread-loading.spec.ts`](browser/thread-loading.spec.ts) |+| Settings forms or persistence | The feature under [`components/settings/`](src/components/settings/) and [`useSettingsController.ts`](src/components/settings/useSettingsController.ts) | Matching `settings-*.test.tsx` in [`src/tests/`](src/tests/); backend settings tests in [`tests/webui/`](../tests/webui/) |+| A channel's setup interface | Its package under [`nanobot/channels/`](../nanobot/channels/), including `webui/` and translations | The same package's `tests/webui/`, plus [`settings-channels.test.tsx`](src/tests/settings-channels.test.tsx) |+| A shared control or content renderer | [Component guide and gallery](COMPONENTS.md) | Its existing component tests and affected production caller; browser tests for layout, focus, or motion |++For a focused component check, run `bun run test src/tests/thread-composer.test.tsx`; for the pairing browser flow, run `bun run test:browser browser/pairing-refresh.spec.ts`. These are examples, not a substitute for [full checks](#test). HTTP/WebSocket, host, or persisted-state changes also require the [client/host compatibility review](../.agent/review-guide.md).+## Develop the WebUI (Vite HMR)### 1. Install nanobot from source