Skip to content

feat: list models for a workspace with ListModelsOptions.cwd - #364

Merged
xxchan merged 1 commit into
mainfrom
feat/list-models-cwd
Oct 12, 2026
Merged

xxchan merged 1 commit into
mainfrom
feat/list-models-cwd

Conversation

@xxchan

@xxchan xxchan commented Oct 12, 2026

Copy link
Copy Markdown
Member

Rower asked for this after 0.57.0 (#347, #355): rowrow's model menus belong to one workspace, but listModels read every runtime's configuration at the host's cwd, so ModelEntry.default (and on some runtimes the list itself) could be wrong for that workspace.

What changes

  • ListModelsOptions.cwd: the directory a session would run in, resolved against the host's cwd, which stays the default. Each runtime lists there the way a session there would start:
    • claude, kimi, grok, antigravity and opencode start in it (kimi and antigravity also open their throwaway session/new there);
    • codex sends it as the config/read cwd. The app-server itself still starts at the host's cwd, where a session's app-server starts, so a relative CODEX_HOME resolves the same way;
    • pi builds its settings and services for it, so the project's saved default and its .pi/extensions apply.
    • cursor, pi-durable and morph list without one.
  • oar models --cwd <dir>, and the human table marks the default model with (default).
  • Contract, README and pi docs say plainly that listing in a directory can run that workspace's code (pi loads its project extensions), like the inventory readers, so hosts should not list in a directory they do not trust.

Verified against real runtimes (no tokens spent)

  • pi 1.1.0, with an isolated agent dir and a dummy xAI key: the global default grok-4.5 is marked without --cwd. With --cwd on a workspace whose .pi/settings.json saves grok-4.7, that model is marked, and the workspace's .pi/extensions/marker.js ran. It did not run without --cwd.
  • codex 0.162.0, with an isolated CODEX_HOME whose user config sets gpt-5.5:
    • a trusted workspace whose .codex/config.toml sets gpt-6-luna marks gpt-6-luna;
    • the same workspace untrusted marks gpt-5.5 (codex's own rule);
    • listing wrote nothing to config.toml.
  • opencode 1.18.30: a provider defined in the workspace's opencode.json is listed only with --cwd (given as a relative path).
  • claude 2.1.292: the workspace's .claude/settings.json changes the list; moving the file away restores it.

kimi, grok and antigravity are covered by unit tests only: their spawn and session/new now use the same directory a session does.

Validation: typecheck, lint and the full unit suite (1739 tests) pass locally.

🤖 Generated with Claude Code

A project's own configuration can change what a runtime lists and which
model a session runs when none is set (codex project config.toml, pi
project settings and extensions, opencode.json providers, claude project
settings). listModels read all of it at the host's cwd, so a host with
several workspaces (rowrow) could mark the wrong default.

ListModelsOptions.cwd is the directory a session would run in, resolved
against the host's cwd (still the default). claude, kimi, grok,
antigravity and opencode start there as a session would; codex reads
config/read for it from an app-server started like a session's; pi builds
its services for it. cursor, pi-durable and morph are unchanged. oar
models gains --cwd and marks the default model in its table.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@xxchan
xxchan merged commit 8e4c5e4 into main Oct 12, 2026
17 checks passed
@xxchan
xxchan deleted the feat/list-models-cwd branch October 12, 2026 04:28
@xxchan xxchan mentioned this pull request Oct 12, 2026
xxchan added a commit that referenced this pull request Oct 12, 2026
Release OAR and CLI 0.58.0. This PR changes only the two package version
fields.

**Added: list models for a workspace** (#364)
- `ListModelsOptions.cwd` is the directory a session would run in,
resolved against the host's cwd, which stays the default. A project's
own configuration can change what a runtime lists and which model a
session runs when none is set, so a host with several workspaces should
list per workspace:
- codex reads `config/read` for that directory, so a trusted project's
`.codex/config.toml` model is the one marked `default`;
- pi builds its settings and services there (the project's saved
default, providers from its `.pi/extensions`);
  - opencode lists providers from the project's `opencode.json`;
  - claude applies the project's settings;
  - kimi, grok and antigravity start there as a session would.
- cursor, pi-durable and morph list the same everywhere.
- Listing starts the runtime in that directory the way a session would,
so like the inventory readers it can run that workspace's code (pi loads
its project extensions). Do not list in a directory you do not trust.
- `oar models --cwd <dir>`, and the human table marks the default model
with `(default)`.

**Behavior changes**
- None without `cwd`: listing still reads the host's cwd.
- `createPiListModels`'s runtime factory now receives the listing
directory as a second argument.

Validation: #364 passed all 17 checks on its final head, and its merged
tree equals its CI tree. Verified with real runtimes and no tokens
spent:
- pi 1.1.0: a workspace's saved default was marked, and its project
extension ran only when listing there;
- codex 0.162.0: a trusted project's model was marked, an untrusted
project was ignored, and listing wrote nothing to `config.toml`;
- opencode 1.18.30: a project-defined provider was listed only with that
`cwd`;
- claude 2.1.292: project settings changed the list.

After this PR passes CI and merges, tag its exact squash commit as
`v0.58.0` to trigger npm trusted publishing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: exe.dev user <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
xxchan added a commit that referenced this pull request Oct 12, 2026
…fore restarting it (#374)

Test-only. No release needed.

## Problem

`sea-trial/vendor/claude-mcp-config.vendor.test.ts` failed twice on
macOS on 2026-10-12, with the same missing echo both times:

- main 8e4c5e4 (#364), run 38203896898, job `behavior (macos-latest,
claude-aimock)`;
- the #355 branch run at 02:08Z, same job.

```
-   "echo:restarted-stdio via=stdio token=…",
```

The other three echoes arrived.

## Cause

The stdio echo server runs with `--once`: it exits right after answering
its first call. The third step calls it again, so claude has to restart
it. If claude sends that call before it has noticed the exit, the call
goes to the exiting process. claude answers the tool call with
`"Connection closed"` (`is_error: true`) and does not restart the server
for it. On Linux claude notices the exit before the next call; on macOS
it sometimes does not.

## Change

`EchoStep` gets an optional `delayMs`: how long the model waits before
replying with that step's call. It is implemented as aimock's
`streamingProfile.ttft`, which adds a one-time delay. aimock's `latency`
would apply the delay to every streamed chunk.

The `restarted-stdio` step uses `delayMs: 1500`. The test still proves
what it is for: claude restarts the server and the restarted server gets
its credential.

Other users of `echoFixtures` are unchanged. The field is optional.

## Evidence (Linux, real claude 2.1.296, aimock, no account)

To mimic a runtime that notices the exit late, I used a local,
uncommitted patch to `tests/fixtures/echo-mcp-server.mjs`. With it, the
server exits 300 ms or 1000 ms after its answer instead of right away.

| Server exits | Without this change | With this change |
|---|---|---|
| right away (fixture as committed) | passes (6 of 6 runs) | passes
(about 4.2 s vs 3.0 s) |
| 300 ms late | fails in 11 of 12 runs: the third call gets `"Connection
closed"` and `restarted-stdio` is missing, as on macOS CI | passes in 8
of 8 runs |
| 1000 ms late | fails in 5 of 5 runs | passes in 5 of 5 runs |

Lint (`oxlint --type-aware --deny-warnings` on both files), `pnpm run
typecheck`, and the whole vendor file with `OAR_TEST=claude-aimock` (2
of 2) pass.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: exe.dev user <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

1 participant