From 6f86d1af28d5523578ea641470fe209f153ddcdc Mon Sep 17 00:00:00 2001 From: StanPonomarev Date: Thu, 8 Oct 2026 09:22:30 +0200 Subject: [PATCH] update readme and installer --- AGENTS.md | 4 ++++ README.md | 31 +++++++++++-------------------- scripts/install.ts | 10 +++++++++- tests/install.test.ts | 24 ++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 21 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 570428d..57c25fe 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,3 +1,7 @@ # CI-safe tests and scripts Do not assume local directories, files, tools, or generated artifacts exist in a clean CI environment. In particular, `/tmp/opencode` is an agent-environment convenience, not a CI guarantee. Tests should create temporary directories with `node:os` `tmpdir()` and `mkdtemp(join(tmpdir(), prefix))`, explicitly create required parent directories and fixtures, and clean up the files they create. + +# README + +Keep README.md to the absolutely required sections (installation, configuration, usage) with at most one short sentence of prose per section, plus code blocks. diff --git a/README.md b/README.md index 2ca1896..ff0f6af 100644 --- a/README.md +++ b/README.md @@ -1,36 +1,19 @@ # stanp-opencode -## Release installation +## Installation -Requires OpenCode 2.0.22, Bun 1.4.2+, Bash, curl, jq, and `sha256sum` on Linux/WSL. +Requires OpenCode 2.0.22, Bun 1.4.2+, Bash, curl, jq and `sha256sum` on Linux/WSL. ```sh curl -fsSL https://git.krtss.de/StanPonomarev/stanp-opencode/raw/branch/main/install.sh | bash -s -- --plugins agents,multi-work,quota,optchat ``` -Choose any plugin subset; Multi-work requires Agents first. - -Quota shows ChatGPT limits for the connected OpenAI account and, when Claude Code is logged in, Claude subscription limits read from `${CLAUDE_CONFIG_DIR:-~/.claude}/.credentials.json` (read-only; Claude Code refreshes the token). - -Optchat implements [VictorTaelin's optchat recipe](https://gist.github.com/VictorTaelin/91837951a5ce5b38f341ec1ba1df6449). It is off by default; run `/optchat on`, `/optchat off`, or `/optchat status` in a root session. In an enabled session, each turn sees a constant-size view of the whole chat, made of one-line summaries, plus the new message. The model can open any line with the `zoom` tool and read message times with `date`. Optchat does not apply to subagent sessions. Memory is stored in `~/.local/share/opencode/optchat//`. Compactions run in a child session named "optchat compactions". Optchat activates only when the `compactionModel` option is set, in the format `provider/model[#variant]` (for example `opencode/claude-haiku-5-5#xhigh`); without it (or when empty) the plugin registers nothing. A non-empty `dataDir` overrides the memory location. The installer writes both options as empty strings for you to fill in. - -## Local installation - -From a local checkout, run: - -```sh -bash /path/to/stanp-opencode/install-local.sh --plugins agents,multi-work,quota -opencode service restart -``` - ## Configuration -Agents registers nothing until its `agents` option is set. The installer writes every missing option with an empty value (`""`) for you to fill in; an empty value means unset, so a fresh install stays inert. Each assignment is `provider/model[#variant]`; the variant selects the model's reasoning variant, falling back to a `reasoningEffort` request setting when the model does not advertise it. Merge this into `~/.config/opencode/opencode.json`, preserving unrelated settings and plugins; update existing plugin entries instead of appending duplicates. The `deep-lo` and `deep-hi` assignments are optional as a pair; if either is omitted, both deep workers are disabled and orchestration uses `good-lo`. +Fill in the empty values the installer writes to `~/.config/opencode/opencode.json`; empty plugins stay inactive. ```jsonc { - "$schema": "https://opencode.ai/config.json", - // Required at the root and in worktrees. "experimental": { "subagent_depth": 2 }, "plugins": [ { @@ -48,6 +31,14 @@ Agents registers nothing until its `agents` option is set. The installer writes }, { "package": "./plugins/stanp-opencode/multi-work" }, { "package": "./plugins/stanp-opencode/quota" }, + { + "package": "./plugins/stanp-opencode/optchat", + "options": { "compactionModel": "opencode/claude-haiku-5-5#xhigh", "dataDir": "" }, + }, ], } ``` + +## Usage + +Run `/optchat on|off|status` in a root session to toggle optchat. diff --git a/scripts/install.ts b/scripts/install.ts index a648a4d..1a7eed8 100644 --- a/scripts/install.ts +++ b/scripts/install.ts @@ -42,6 +42,7 @@ const pluginSchema = z.union([z.string(), entrySchema]); const registrationSchema = z .union([z.string().transform((packageName) => ({ package: packageName })), entrySchema]) .pipe(entrySchema); +const experimentalSchema = z.object({ subagent_depth: z.number().optional() }).catchall(z.json()); const configSchema = z .object({ plugins: z.array(pluginSchema).optional(), $schema: z.string().optional() }) .catchall(z.json()); @@ -145,11 +146,18 @@ export async function install(source: string, config: string, selection?: string const first = configured.findIndex((entry) => isOwned(entry.package)); const next = entries.filter((_entry, index) => !isOwned(configured[index]!.package)); next.splice(first < 0 ? next.length : first, 0, ...registrations); - const updated = { + const updated: z.infer = { ...current, $schema: current.$schema ?? "https://opencode.ai/config.json", plugins: next, }; + // Coordinate delegates to workers from Multi-work children, so routing needs depth >= 2. + const experimental = experimentalSchema.safeParse(current.experimental ?? {}); + if (selected.includes("agents") && experimental.success) + updated.experimental = { + ...experimental.data, + subagent_depth: Math.max(experimental.data.subagent_depth ?? 0, 2), + }; const parent = join(config, "plugins"); await mkdir(parent, { recursive: true }); const staged = join(parent, `.stanp-opencode.new.${process.pid}`); diff --git a/tests/install.test.ts b/tests/install.test.ts index f3330ee..acfda0d 100644 --- a/tests/install.test.ts +++ b/tests/install.test.ts @@ -265,6 +265,30 @@ test("installer writes empty option skeletons, fills only missing keys, and is i expect(await contents(f.config)).toEqual(filled); }); +test("agents installs set experimental.subagent_depth to at least 2", async () => { + const f = await fixture(); + await install(f.source, f.config, "quota"); + expect((await contents(f.config)).experimental).toBeUndefined(); + await install(f.source, f.config, "agents"); + const fresh = await contents(f.config); + expect(fresh.experimental).toEqual({ subagent_depth: 2 }); + expect(fresh).toMatchObject(unrelated); + for (const [depth, expected] of [ + [1, 2], + [3, 3], + ]) { + await writeFile( + join(f.config, "opencode.json"), + JSON.stringify({ ...fresh, experimental: { subagent_depth: depth, other: true } }), + ); + await install(f.source, f.config); + const result = await contents(f.config); + expect(result.experimental).toEqual({ subagent_depth: expected, other: true }); + await install(f.source, f.config); + expect(await contents(f.config)).toEqual(result); + } +}); + test("local installer retains executable permissions and supports direct invocation", async () => { const f = await fixture(); const path = new URL("../install-local.sh", import.meta.url).pathname;