Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ steps, project setup, headless operation, and removal.
| [docs/architecture.md](docs/architecture.md) | Component responsibilities, a short issue-to-PR overview, configuration ownership, scheduler ownership, and shared state. | Start here to understand how the system is divided before locating implementation code. |
| [docs/bot-workflow.md](docs/bot-workflow.md) | Eight Mermaid diagrams and detailed implementation notes: startup and polling; discovery and routing; task phases; sessions and questions; media helpers; verification and publication; feedback, merging, and tab closure; status, retries, and recovery. Includes links to the source for each area. | Use for exact execution order, state transitions, checkpoint behavior, failure paths, and tracing a bot task from issue to merged PR. |
| [docs/configuration.md](docs/configuration.md) | The standard `.opencode/automation.json` format, defaults, setup flags, configuration tracking across Git branches, authors, triggers, checks, base branches, model capabilities, media helpers, custom prompts, signatures, and auto-merge settings. | Use when adding or changing user-facing configuration, defaults, or setup examples. |
| [docs/runtime.md](docs/runtime.md) | User-visible behavior while the bot runs: GitHub questions and permission replies, branch selection, media inputs, prompt loading, follow-up comments, session tabs, runtime sidebar/status freshness, local task closure, and routine management commands. | Use when changing issue conversations, session continuation, runtime tools, or TUI behavior. |
| [docs/runtime.md](docs/runtime.md) | User-visible behavior while the bot runs: GitHub questions and permission replies, branch selection, media inputs, prompt loading, follow-up comments, session tabs, runtime sidebar/status freshness, host repository inventory and discovery, local task closure, and routine management commands. | Use when changing issue conversations, session continuation, runtime tools, or TUI behavior. |
| [docs/advanced.md](docs/advanced.md) | Separate scheduler/dispatcher setup, multiple repositories, custom RPC jobs, full options, timeouts, management and retry commands, persistence, reconciliation, locks, and known limits. | Use for low-level configuration, operational troubleshooting, recovery, or ownership/concurrency changes. |
| [docs/installation.md](docs/installation.md) | Loader registration, config-directory precedence, prerequisites, source installation, project-local installation, upgrade conflicts, testing on another machine, and migration limits. | Use when working on packaging, installers, registration, upgrades, or deployment troubleshooting. |
| [docs/releases.md](docs/releases.md) | Feature-to-devel and devel-to-release PR checks, automatic patch versions, manual npm version/tag releases, exact changelog notes, publication recovery, README commits on release, automatic release-to-devel synchronization, and promotion PRs into protected main. | Use for CI triggers, versioning, packaging, GitHub Release publication, branch permissions, or recovery after a failed release. |
Expand All @@ -43,6 +43,10 @@ For common investigations:
and the configuration reference's automatic-merge rules.
- **Why did a session tab open or close?** Read the runtime tab sections and
workflow section 7.
- **Which folders are configured, running, paused, or missing?** Read the runtime
repository inventory section and advanced monitoring notes. `list` and `/bot`
→ **Repositories** use timestamped host snapshots; do not activate owners to
inspect them. Discovery is an explicit registration operation.
- **Why is polling inactive or duplicated?** Read architecture ownership,
workflow section 1, and installation registration details.

Expand Down Expand Up @@ -72,6 +76,9 @@ the installation block without making remote writes. Keep its markers intact.
`src/runtime-panel.ts` owns polling, freshness and presentation;
`src/monitor.ts` defines read-only monitoring schemas. `src/rpc.ts` defines RPC contracts; `src/manage.ts` exposes
management operations.
- `src/repositories.ts` owns host registry registration, explicit discovery and
component snapshot files; `src/repository-report.ts` defines inventory schemas
and shared CLI/TUI formatting. Neither inventory reader starts bot work.
- `src/setup.ts`, `src/wizard.ts`, `src/install.ts`, and `scripts/` cover setup and
installation. `examples/` contains configuration examples; `test/` contains
automated tests. `package.json` defines build and validation commands.
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ include the full version, for example `## 0.7.0-beta.1`.

### Added

- List configured repositories across the host with `opencode2-automation list`
(`--json` for scripts) and `/bot` → **Repositories**. Show owner/checkout paths,
base branches, timestamped dispatcher/scheduler status and concrete issue
failures without activating other bots. Register projects during init/startup;
import older inactive standard configurations with `list --discover <root>`.
Preserve missing entries and explicitly mark stopped, stale or unavailable data.

- Manage tasks directly from `/bot`: inspect details, open sessions, close idle
tabs, restart workflows, or stop sessions and durably end tracking without
deleting work. Preserve closed tasks as history and skip rediscovery, feedback,
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,12 @@ installations are not removed by `npm uninstall --global`.
- **Merging:** approve the bot's PR or post a configured merge phrase. The author
must be allowed and have repository write access. Set `autoMerge.enabled` to
`false` to disable this. `signature` controls the signature on new bot messages.
- **Repository inventory:** run `opencode2-automation list` from any directory,
or choose **Repositories** in `/bot`. See registered GitHub repositories, owner
and checkout paths, base branches, timestamped runtime status, scan timing and
issue counts/errors. Use `list --json` for scripts and
`list --discover /absolute/path/to/projects` to import older standard configs
without starting bots. See [repository inventory](docs/runtime.md#repository-inventory).
- **Runtime status:** the right sidebar's **BOT RUNTIME** panel shows dispatcher
work, GitHub discovery, scheduled scans, queue counts and the selected task.
`/botstatus` opens a full text report. Status refreshes every five seconds;
Expand Down
25 changes: 25 additions & 0 deletions docs/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,31 @@ Each poll has a four-second bound; failures retain marked stale data. The existi
Full task history remains available through `status`; see the
[runtime sidebar](runtime.md#runtime-status-sidebar) for display and selection rules.

### Host repository inventory

`opencode2-automation list [--json]` is independent of the current checkout and
service discovery. `automation.github.repositories` accepts `{}` and returns the
same `{ entries, warnings }` report on the connected server. The method reads
local registry/snapshot files; it does not invoke RPC in other owner locations,
which could activate their plugins. `/bot` → **Repositories** consumes this API.

`init` and combined-plugin activation register standard configurations. Dispatcher
startup registers all advanced `repositories` entries under its canonical owner.
Dispatcher and scheduler write separate atomic snapshots every five seconds while
they hold their existing ownership locks, with PID, timestamp and shutdown state.
Disposal settles the last snapshot before releasing ownership. Readers verify
process existence and 15-second freshness; stale details remain historical.
Snapshot/registration errors are reported but do not abort execution or alter
queue state. The registry uses private files under `XDG_STATE_HOME` (default
`~/.local/state`), separate from Git-backed state; no GitHub token or model
credentials are stored there.

Use `list --discover /absolute/path/to/projects` to register older inactive
standard `.opencode/automation.json` configurations without loading owners.
Discovery has explicit filesystem/depth limits and does not import arbitrary
advanced plugin options. For statuses and migration details, see
[repository inventory](runtime.md#repository-inventory).

## Persistence and reconciliation

The queue stores analysis decisions and clarification dialogue, comment ID, session ID, phase, pinned base branch,
Expand Down
6 changes: 6 additions & 0 deletions docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ loads a generic scheduler, a GitHub dispatcher, and a terminal UI component.
session history, and exposes `/bot` and `/restartworkflow` task selectors.
A read-only runtime sidebar and `/botstatus` combine live dispatcher diagnostics,
scheduler state and task snapshots, marking stale or unavailable data.
- **Repository inventory:** `init` and owner activation register configured
checkouts in a per-user host registry. Dispatcher and scheduler publish separate
local status snapshots every five seconds. CLI `list` reads these without
activating owners; `/bot` → **Repositories** reads the connected server's same
registry through `automation.github.repositories`. Missing/stale data is explicit;
discovery can import inactive standard configs without starting automation.

## Workflow

Expand Down
32 changes: 27 additions & 5 deletions docs/bot-workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ flowchart TD
Owner -->|No or outside Git| Inactive[Plugin stays inactive]
Owner -->|Yes| Config[Use nonempty plugin options or read .opencode/automation.json]
Config -->|No project config| Inactive
Config --> Resolve[Validate settings and resolve GitHub auth, routes and defaults]
Resolve --> GH[Acquire github lock and load queue.json]
Config --> Register[Register primary checkout in local user inventory without activating other owners]
Register --> Resolve[Validate settings and resolve GitHub auth, routes and defaults]
Resolve --> Metadata[Register resolved repositories and base branches]
Metadata --> GH[Acquire github lock and load queue.json]
GH --> RPC[Register runtime bridge and dispatcher RPC]
RPC --> Worker[Immediate worker tick, then every workerEverySeconds]
RPC --> Scheduler[Start scheduler after GitHub setup succeeds]
Expand Down Expand Up @@ -50,7 +52,7 @@ flowchart TD
Keepalive --> PID{Registered service PID matches this process?}
PID -->|Yes| Touch[Create or reuse maintenance session, then emit rename event]
PID -->|No| Skip[Skip keepalive]
Stop[Owner reload or shutdown] --> Cleanup[Stop timers and local waits, settle writes, dispose RPC, release locks]
Stop[Owner reload or shutdown] --> Cleanup[Stop timers, save stopped inventory snapshots, settle writes, dispose RPC, release locks]
Cleanup --> Preserve[Preserve durable queue and healthy worktree execution]
Preserve --> Load
View[Runtime sidebar or botstatus] -.-> Monitor[Read dispatcher monitor and scheduler status every five seconds]
Expand All @@ -59,8 +61,25 @@ flowchart TD
Monitor --> Fresh{Both readings available and fresh?}
Fresh -->|Yes| Display[Show live operations, queue and selected task]
Fresh -->|No| Stale[Mark unavailable or retained stale readings]
RPC -.-> DS[Publish dispatcher snapshot every five seconds]
State -.-> SS[Publish scheduler snapshot every five seconds]
DS --> Inventory[Per-user registry and separate atomic component snapshots]
SS --> Inventory
Register --> Inventory
Metadata --> Inventory
Init[CLI init or explicit list --discover] --> Inventory
List[CLI list or bot Repositories via current owner RPC] --> Read[Read local inventory without activating owners]
Inventory -.-> Read
Read --> Check[Check paths, config, PID and 15-second freshness]
Check --> Report[Report repository status, scan timing, task counts and issue errors]
```

- Registration and component snapshots are observational, best-effort writes.
Registry errors do not stop the bot. `init` registers after configuration succeeds;
explicit discovery imports old standard configs without auth or service startup.
The CLI and TUI report share a per-user host registry, not the task queue.
Missing paths and stale/dead processes are shown explicitly. See
[inventory behavior and limits](runtime.md#repository-inventory).
- Easy configuration puts state under the shared Git directory at
`opencode2-automation/`. Worker worktrees do not start another scheduler.
- Default discovery interval: **60 seconds**. Default worker interval:
Expand Down Expand Up @@ -88,7 +107,8 @@ flowchart TD
Sources: [index.ts](../src/index.ts), [easy.ts](../src/easy.ts),
[GitHub plugin](../src/plugins/github.ts),
[scheduler plugin](../src/plugins/scheduler.ts), [lifecycle.ts](../src/lifecycle.ts),
[dispatcher.ts — workOnce](../src/dispatcher.ts), [state.ts](../src/state.ts).
[dispatcher.ts — workOnce](../src/dispatcher.ts), [state.ts](../src/state.ts),
[repositories.ts](../src/repositories.ts), [repository-report.ts](../src/repository-report.ts).

## 2. Discovery and routing

Expand Down Expand Up @@ -490,7 +510,9 @@ flowchart TD
Ack --> UI[Activity events and TUI polling every 10 seconds]
Refresh --> UI
Local[Task closure finishes with status closed] --> UI
Menu[bot menu: select issue] --> Action[Open session, details, close tabs, restart workflow, stop and close task]
Menu[bot menu: select issue or Repositories] --> Action[Open session, details, close tabs, restart workflow, stop and close task]
Menu -->|Repositories| Repos[Read connected server inventory, choose repository, show timestamped details]
Repos --> Observe[No task or scheduler mutation, no activation of other owners]
Action -->|Stop and close task| Confirm[Confirm stop and close, queue durable closing request]
UI --> Busy{Associated tab busy?}
Busy -->|Yes| Defer[Retry closure on a later snapshot]
Expand Down
11 changes: 11 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,14 @@ acknowledgements. They identify the message in its text; GitHub still attributes
posts to the account authenticated by your token. Existing posts are not rewritten.
Set `"autoMerge": { "enabled": false }` to disable automatic merging.


## Repository inventory registration

`init` and owner activation register the configured checkout for
`opencode2-automation list` and `/bot` → **Repositories**. No new project setting
is required. The registry stores last-resolved repository/base-branch metadata
and timestamped component snapshots under the user's state directory; it does
not replace `.opencode/automation.json` or the shared Git queue. Changes to default
branches are reflected when the owner is activated again. See
[repository inventory](runtime.md#repository-inventory) to import older inactive
configurations and distinguish configured projects from running bots.
8 changes: 8 additions & 0 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,13 @@ commands and action menus such as `/bot` task closure and `/restartworkflow`; me
reload its client's command registrations. A service restart preserves queue
blocks and pending questions. Use [workflow recovery](runtime.md#interrupted-sessions-and-workflow-recovery)
for an execution stop instead of reinstalling or deleting state.
After upgrading, activated owners register themselves for
`opencode2-automation list`. Import older, currently inactive standard projects
with `opencode2-automation list --discover /absolute/path/to/projects`; this does
not activate them. Use the same user and `XDG_STATE_HOME` as the service. The TUI's
**Repositories** option reads the connected server registry. See
[repository inventory](runtime.md#repository-inventory) for discovery limits,
status freshness, and missing-directory behavior.

Do not change an active project's `origin` to switch repositories: clone another
project and configure it separately.
Loading