Skip to content

Commit 0e0dac5

Browse files
committed
Add host repository inventory to CLI and bot menu
1 parent 6fbaaf8 commit 0e0dac5

21 files changed

Lines changed: 578 additions & 15 deletions

‎AGENTS.md‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ steps, project setup, headless operation, and removal.
2828
| [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. |
2929
| [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. |
3030
| [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. |
31-
| [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. |
31+
| [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. |
3232
| [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. |
3333
| [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. |
3434
| [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. |
@@ -43,6 +43,10 @@ For common investigations:
4343
and the configuration reference's automatic-merge rules.
4444
- **Why did a session tab open or close?** Read the runtime tab sections and
4545
workflow section 7.
46+
- **Which folders are configured, running, paused, or missing?** Read the runtime
47+
repository inventory section and advanced monitoring notes. `list` and `/bot`
48+
→ **Repositories** use timestamped host snapshots; do not activate owners to
49+
inspect them. Discovery is an explicit registration operation.
4650
- **Why is polling inactive or duplicated?** Read architecture ownership,
4751
workflow section 1, and installation registration details.
4852

@@ -72,6 +76,9 @@ the installation block without making remote writes. Keep its markers intact.
7276
`src/runtime-panel.ts` owns polling, freshness and presentation;
7377
`src/monitor.ts` defines read-only monitoring schemas. `src/rpc.ts` defines RPC contracts; `src/manage.ts` exposes
7478
management operations.
79+
- `src/repositories.ts` owns host registry registration, explicit discovery and
80+
component snapshot files; `src/repository-report.ts` defines inventory schemas
81+
and shared CLI/TUI formatting. Neither inventory reader starts bot work.
7582
- `src/setup.ts`, `src/wizard.ts`, `src/install.ts`, and `scripts/` cover setup and
7683
installation. `examples/` contains configuration examples; `test/` contains
7784
automated tests. `package.json` defines build and validation commands.

‎CHANGELOG.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ include the full version, for example `## 0.7.0-beta.1`.
2424

2525
### Added
2626

27+
- List configured repositories across the host with `opencode2-automation list`
28+
(`--json` for scripts) and `/bot` → **Repositories**. Show owner/checkout paths,
29+
base branches, timestamped dispatcher/scheduler status and concrete issue
30+
failures without activating other bots. Register projects during init/startup;
31+
import older inactive standard configurations with `list --discover <root>`.
32+
Preserve missing entries and explicitly mark stopped, stale or unavailable data.
33+
2734
- Manage tasks directly from `/bot`: inspect details, open sessions, close idle
2835
tabs, restart workflows, or stop sessions and durably end tracking without
2936
deleting work. Preserve closed tasks as history and skip rediscovery, feedback,

‎README.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,12 @@ installations are not removed by `npm uninstall --global`.
249249
- **Merging:** approve the bot's PR or post a configured merge phrase. The author
250250
must be allowed and have repository write access. Set `autoMerge.enabled` to
251251
`false` to disable this. `signature` controls the signature on new bot messages.
252+
- **Repository inventory:** run `opencode2-automation list` from any directory,
253+
or choose **Repositories** in `/bot`. See registered GitHub repositories, owner
254+
and checkout paths, base branches, timestamped runtime status, scan timing and
255+
issue counts/errors. Use `list --json` for scripts and
256+
`list --discover /absolute/path/to/projects` to import older standard configs
257+
without starting bots. See [repository inventory](docs/runtime.md#repository-inventory).
252258
- **Runtime status:** the right sidebar's **BOT RUNTIME** panel shows dispatcher
253259
work, GitHub discovery, scheduled scans, queue counts and the selected task.
254260
`/botstatus` opens a full text report. Status refreshes every five seconds;

‎docs/advanced.md‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,31 @@ Each poll has a four-second bound; failures retain marked stale data. The existi
122122
Full task history remains available through `status`; see the
123123
[runtime sidebar](runtime.md#runtime-status-sidebar) for display and selection rules.
124124

125+
### Host repository inventory
126+
127+
`opencode2-automation list [--json]` is independent of the current checkout and
128+
service discovery. `automation.github.repositories` accepts `{}` and returns the
129+
same `{ entries, warnings }` report on the connected server. The method reads
130+
local registry/snapshot files; it does not invoke RPC in other owner locations,
131+
which could activate their plugins. `/bot` → **Repositories** consumes this API.
132+
133+
`init` and combined-plugin activation register standard configurations. Dispatcher
134+
startup registers all advanced `repositories` entries under its canonical owner.
135+
Dispatcher and scheduler write separate atomic snapshots every five seconds while
136+
they hold their existing ownership locks, with PID, timestamp and shutdown state.
137+
Disposal settles the last snapshot before releasing ownership. Readers verify
138+
process existence and 15-second freshness; stale details remain historical.
139+
Snapshot/registration errors are reported but do not abort execution or alter
140+
queue state. The registry uses private files under `XDG_STATE_HOME` (default
141+
`~/.local/state`), separate from Git-backed state; no GitHub token or model
142+
credentials are stored there.
143+
144+
Use `list --discover /absolute/path/to/projects` to register older inactive
145+
standard `.opencode/automation.json` configurations without loading owners.
146+
Discovery has explicit filesystem/depth limits and does not import arbitrary
147+
advanced plugin options. For statuses and migration details, see
148+
[repository inventory](runtime.md#repository-inventory).
149+
125150
## Persistence and reconciliation
126151

127152
The queue stores analysis decisions and clarification dialogue, comment ID, session ID, phase, pinned base branch,

‎docs/architecture.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ loads a generic scheduler, a GitHub dispatcher, and a terminal UI component.
1616
session history, and exposes `/bot` and `/restartworkflow` task selectors.
1717
A read-only runtime sidebar and `/botstatus` combine live dispatcher diagnostics,
1818
scheduler state and task snapshots, marking stale or unavailable data.
19+
- **Repository inventory:** `init` and owner activation register configured
20+
checkouts in a per-user host registry. Dispatcher and scheduler publish separate
21+
local status snapshots every five seconds. CLI `list` reads these without
22+
activating owners; `/bot` → **Repositories** reads the connected server's same
23+
registry through `automation.github.repositories`. Missing/stale data is explicit;
24+
discovery can import inactive standard configs without starting automation.
1925

2026
## Workflow
2127

‎docs/bot-workflow.md‎

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

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

93113
## 2. Discovery and routing
94114

@@ -490,7 +510,9 @@ flowchart TD
490510
Ack --> UI[Activity events and TUI polling every 10 seconds]
491511
Refresh --> UI
492512
Local[Task closure finishes with status closed] --> UI
493-
Menu[bot menu: select issue] --> Action[Open session, details, close tabs, restart workflow, stop and close task]
513+
Menu[bot menu: select issue or Repositories] --> Action[Open session, details, close tabs, restart workflow, stop and close task]
514+
Menu -->|Repositories| Repos[Read connected server inventory, choose repository, show timestamped details]
515+
Repos --> Observe[No task or scheduler mutation, no activation of other owners]
494516
Action -->|Stop and close task| Confirm[Confirm stop and close, queue durable closing request]
495517
UI --> Busy{Associated tab busy?}
496518
Busy -->|Yes| Defer[Retry closure on a later snapshot]

‎docs/configuration.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,14 @@ acknowledgements. They identify the message in its text; GitHub still attributes
167167
posts to the account authenticated by your token. Existing posts are not rewritten.
168168
Set `"autoMerge": { "enabled": false }` to disable automatic merging.
169169

170+
171+
## Repository inventory registration
172+
173+
`init` and owner activation register the configured checkout for
174+
`opencode2-automation list` and `/bot` → **Repositories**. No new project setting
175+
is required. The registry stores last-resolved repository/base-branch metadata
176+
and timestamped component snapshots under the user's state directory; it does
177+
not replace `.opencode/automation.json` or the shared Git queue. Changes to default
178+
branches are reflected when the owner is activated again. See
179+
[repository inventory](runtime.md#repository-inventory) to import older inactive
180+
configurations and distinguish configured projects from running bots.

‎docs/installation.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,5 +123,13 @@ commands and action menus such as `/bot` task closure and `/restartworkflow`; me
123123
reload its client's command registrations. A service restart preserves queue
124124
blocks and pending questions. Use [workflow recovery](runtime.md#interrupted-sessions-and-workflow-recovery)
125125
for an execution stop instead of reinstalling or deleting state.
126+
After upgrading, activated owners register themselves for
127+
`opencode2-automation list`. Import older, currently inactive standard projects
128+
with `opencode2-automation list --discover /absolute/path/to/projects`; this does
129+
not activate them. Use the same user and `XDG_STATE_HOME` as the service. The TUI's
130+
**Repositories** option reads the connected server registry. See
131+
[repository inventory](runtime.md#repository-inventory) for discovery limits,
132+
status freshness, and missing-directory behavior.
133+
126134
Do not change an active project's `origin` to switch repositories: clone another
127135
project and configure it separately.

0 commit comments

Comments
 (0)