triss-coworker 0.28.0 → 0.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,38 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.29.0] — 2026-08-06
11
+
12
+ ### Added
13
+
14
+ - **Existing OpenAI-compatible worker profiles are now available in coder
15
+ mode.** `triss coder init --provider worker` registers an env-backed
16
+ `triss-worker` provider through `@ai-sdk/openai-compatible`, reusing
17
+ `TRISS_WORKER_API_KEY`, `TRISS_WORKER_BASE_URL`, and the configured
18
+ flash/pro model ids instead of introducing another credential. Init, run,
19
+ model inspection/switching, status, MCP, wizard/help output, and generated
20
+ agent instructions all understand `triss-worker/<model-id>`. V1 supports one
21
+ custom profile and the Chat Completions protocol; Crush remains Z.AI-only.
22
+
23
+ ### Changed
24
+
25
+ - Worker setup resolves credentials, endpoint, and model ids from the selected
26
+ local/global scope while preserving genuine parent-shell overrides. Worker
27
+ readiness now has one shared definition across `triss status` and MCP, and
28
+ the MCP coder-status description names `TRISS_WORKER_API_KEY` explicitly.
29
+ - OpenCode init, persistent model changes, and rollback now coordinate through
30
+ the same PID/token `(engine, scope)` filesystem lock with dead-PID recovery.
31
+
32
+ ### Security
33
+
34
+ - Worker init and run fail closed before forwarding credentials when the
35
+ effective project/global `provider["triss-worker"]`, endpoint, env-backed key
36
+ binding, package, or complete flash/pro model allowlist is missing, stale, or
37
+ conflicting. A global init cannot persist project-local endpoint settings or
38
+ report success over a higher-precedence unsafe project provider.
39
+ - Jira issue output and its model-summarization corpus no longer include the
40
+ presence or absence of the worker credential.
41
+
10
42
  ## [0.28.0] — 2026-08-06
11
43
 
12
44
  ### Added
package/README.md CHANGED
@@ -237,7 +237,8 @@ The exposed tool set is **filtered by configured credentials**:
237
237
  - **`triss_github_*`** when `GITHUB_TOKEN` is set (or `gh` CLI logged in).
238
238
  - **`triss_gitlab_*`** when `GITLAB_TOKEN` is set.
239
239
  - **`triss_coder_run` + `triss_coder_status`** when any coder provider key is
240
- set — `ZHIPU_API_KEY` (Z.AI GLM), `OPENCODE_API_KEY` (OpenCode Zen or Go),
240
+ set — `TRISS_WORKER_API_KEY` (the existing OpenAI-compatible worker),
241
+ `ZHIPU_API_KEY` (Z.AI GLM), `OPENCODE_API_KEY` (OpenCode Zen or Go),
241
242
  `MOONSHOT_API_KEY` (Moonshot Kimi), or `KIMI_API_KEY` (Kimi for Coding)
242
243
  (setup: `triss coder init`). `triss_coder_run` takes an optional `engine`
243
244
  (`opencode` default, or `crush`); its timeout defaults to
@@ -271,8 +272,8 @@ and writing**.
271
272
  | `triss review` | Code review on current branch or a PR (diff + linked ticket) | The agent reading the whole diff |
272
273
  | `triss commit-msg` | Generates a commit message from staged diff | Hand-writing or copy-pasting from web LLMs |
273
274
  | `triss usage` | Cumulative cost / token usage with per-project breakdown | Squinting at stderr after each call |
274
- | `triss coder init` | Sets up a coding agent (default `opencode` engine; `--engine crush` for crush): provider key (Z.AI GLM default; `--provider opencode-zen` for free rotating Zen models; `--provider opencode-go` for the paid OpenCode Go subscription; `--provider moonshot` / `kimi-for-coding` for Kimi), config, permission policy, and agent templates. Blocks (non-zero) on an unsafe existing `opencode.json` — missing deny-first bash policy (override with `--allow-unsafe-bash`) or a stale/cross-provider `small_model`. | Manually installing/configuring opencode |
275
- | `triss coder run` | Spawns the coding agent (GLM, Kimi, OpenCode Zen, or OpenCode Go) and prints one JSON envelope (`--engine opencode\|crush`; `--isolate` for a disposable worktree — opencode defaults to isolate-OFF, crush defaults to isolate-ON; crush adds opt-in `--restrict`/`--no-restrict` for its CLI allowlist). **POSIX only** (macOS/Linux) — refuses to run on Windows. | Manually driving `opencode run` and parsing its ndjson stream |
275
+ | `triss coder init` | Sets up a coding agent (default `opencode` engine; `--engine crush` for crush): provider key/profile (`--provider worker` reuses `TRISS_WORKER_*`; Z.AI GLM default; Zen, Go, and Kimi are also supported), config, permission policy, and agent templates. Blocks (non-zero) on an unsafe existing `opencode.json` — missing deny-first bash policy (override with `--allow-unsafe-bash`) or a stale/cross-provider `small_model`. | Manually installing/configuring opencode |
276
+ | `triss coder run` | Spawns the coding agent (the OpenAI-compatible Triss worker, GLM, Kimi, OpenCode Zen, or OpenCode Go) and prints one JSON envelope (`--engine opencode\|crush`; `--isolate` for a disposable worktree — opencode defaults to isolate-OFF, crush defaults to isolate-ON; crush adds opt-in `--restrict`/`--no-restrict` for its CLI allowlist). **POSIX only** (macOS/Linux) — refuses to run on Windows. | Manually driving `opencode run` and parsing its ndjson stream |
276
277
  | `triss coder clean` | Removes finished `.triss/wt` isolation worktrees (`--all` forces all) | Manually finding and deleting stale git worktrees |
277
278
  | `triss init` | Drops a tiny (~15 line) delegation block into `CLAUDE.md` / `AGENTS.md` | Hand-writing routing rules |
278
279
  | `triss agent-help` | Prints the full delegation cookbook on demand (the nano block points here) | A 200-line CLAUDE.md that always loads |
@@ -453,7 +454,8 @@ default timeout, configurable via `--timeout <ms>`.
453
454
 
454
455
  ### `triss coder`
455
456
 
456
- Delegates an implementation task to a cheap coding agent — GLM, Kimi,
457
+ Delegates an implementation task to a cheap coding agent — the existing
458
+ OpenAI-compatible Triss worker, GLM, Kimi,
457
459
  OpenCode Zen, or OpenCode Go models (the `opencode` engine by default; `crush` is an
458
460
  alternative — see **Engines** below) instead of the primary model writing
459
461
  the code itself.
@@ -467,7 +469,8 @@ triss coder clean # remove finished isolation wo
467
469
  ```
468
470
 
469
471
  `triss coder init` first asks which provider to configure — **Z.AI GLM**
470
- (default), **OpenCode Zen** (`--provider opencode-zen`, free rotating
472
+ (default), the existing **Triss worker** (`--provider worker`, aliases
473
+ `openai` / `openai-compatible`), **OpenCode Zen** (`--provider opencode-zen`, free rotating
471
474
  models), **OpenCode Go** (`--provider opencode-go`, paid subscription),
472
475
  **Moonshot Kimi** (`--provider moonshot`, pay-as-you-go
473
476
  `moonshotai/*` models like `kimi-k2.7-code`), or **Kimi for Coding**
@@ -513,7 +516,9 @@ natively; triss also forwards it as `ZAI_API_KEY` for older binaries; see
513
516
  `docs/crush-restrict-issues.md` for the live-verified bug facts.
514
517
 
515
518
  **Providers** — the `opencode` engine isn't limited to Z.AI. The required
516
- API key follows the model's `<provider>/` prefix: `zai-coding-plan/*` and
519
+ API key follows the model's `<provider>/` prefix: `triss-worker/*` reuses
520
+ the existing `TRISS_WORKER_API_KEY` + `TRISS_WORKER_BASE_URL` profile;
521
+ `zai-coding-plan/*` and
517
522
  `zai/*` (GLM) use `ZHIPU_API_KEY`; `opencode/*` models — served free by
518
523
  [OpenCode Zen](https://opencode.ai/docs/zen/) — and paid `opencode-go/*`
519
524
  models use the shared `OPENCODE_API_KEY`;
@@ -523,6 +528,22 @@ models use the shared `OPENCODE_API_KEY`;
523
528
  **`kimi-for-coding/k3`** (Kimi K3) — use `KIMI_API_KEY`. Zen ids rotate
524
529
  freely, so discover the current id and pass it rather than hard-coding one:
525
530
 
531
+ ```bash
532
+ triss coder init --provider worker
533
+ triss coder run "mechanical task" --model triss-worker/deepseek-v4-flash
534
+ ```
535
+
536
+ The worker route uses Chat Completions through `@ai-sdk/openai-compatible`.
537
+ It creates no second API key and is supported by the OpenCode engine only.
538
+ After changing the worker base URL or flash/pro model ids, rerun
539
+ `triss coder init --provider worker`; `coder model set --provider worker`
540
+ fails closed until the matching env-backed provider block is present. Global
541
+ init reads only global worker settings (except genuine shell exports) and
542
+ rejects a conflicting higher-precedence project provider. Every worker run
543
+ revalidates the effective endpoint and model allowlist before forwarding the
544
+ key, and prints an exact scope-specific init command when the saved provider is
545
+ missing or stale.
546
+
526
547
  ```bash
527
548
  triss coder init --provider opencode-zen # guided: key + opencode.json
528
549
  triss coder models --provider opencode-zen # see live Zen ids
@@ -581,19 +602,19 @@ confusion is conflating them:
581
602
  - **Engine** = *how* the agent is launched: `opencode` (default) or
582
603
  `crush`. Set at `triss coder init --engine …` or per run with
583
604
  `triss coder run --engine …`.
584
- - **Provider** = *which* API serves the model: Z.AI GLM, OpenCode Zen, OpenCode Go,
605
+ - **Provider** = *which* API serves the model: Triss worker, Z.AI GLM, OpenCode Zen, OpenCode Go,
585
606
  Moonshot Kimi, Kimi for Coding. Set at `triss coder init --provider …`.
586
607
 
587
608
  Not every engine speaks every provider:
588
609
 
589
610
  | Engine | Providers served |
590
611
  | ---------- | ------------------------------------------------- |
591
- | `opencode` | Z.AI GLM, OpenCode Zen, OpenCode Go, Moonshot, Kimi for Coding |
612
+ | `opencode` | Triss worker, Z.AI GLM, OpenCode Zen, OpenCode Go, Moonshot, Kimi for Coding |
592
613
  | `crush` | Z.AI GLM (coding-plan only) |
593
614
 
594
615
  `triss coder init` drives setup in that order — **engine, then provider,
595
616
  then it asks for only that provider's credential** and writes the matching
596
- model prefix (`opencode/<id>`, `opencode-go/<id>`, `zai-coding-plan/*`, `moonshotai/*`, or
617
+ model prefix (`triss-worker/<id>`, `opencode/<id>`, `opencode-go/<id>`, `zai-coding-plan/*`, `moonshotai/*`, or
597
618
  `kimi-for-coding/*`).
598
619
 
599
620
  **Choosing a model.** `--model` on `triss coder run` is a
package/bin/triss.js CHANGED
@@ -183,7 +183,7 @@ config
183
183
  .option('--standard', 'API key + one model only — skip the standard/advanced prompt')
184
184
  .option('--advanced', 'full wizard with presets, base URL, integrations — skip the prompt')
185
185
  .option('--coder-engine <name>', 'coder target only: coding engine to configure (opencode default, or crush). `coder init` uses --engine')
186
- .option('--coder-provider <name>', 'coder target only: opencode engine provider (zai, opencode-zen, opencode-go, moonshot, kimi-for-coding). `coder init` uses --provider')
186
+ .option('--coder-provider <name>', 'coder target only: opencode engine provider (zai, worker, opencode-zen, opencode-go, moonshot, kimi-for-coding). `coder init` uses --provider')
187
187
  .action(wrap(runWizard));
188
188
 
189
189
  config
@@ -238,14 +238,14 @@ coder
238
238
  .option('-g, --global', 'save to the global scope (~/.config/triss/.env, ~/.config/opencode/)')
239
239
  .option('-l, --local', 'save to the project scope (./.triss.env, ./opencode.json)')
240
240
  .option('--engine <name>', 'coding engine to configure: opencode (default) or crush')
241
- .option('--provider <name>', 'opencode engine model provider: zai (Z.AI GLM, default), opencode-zen (free rotating models), opencode-go (paid Go subscription), moonshot (Kimi pay-as-you-go), or kimi-for-coding (subscription)')
241
+ .option('--provider <name>', 'opencode engine model provider: zai, worker (existing OpenAI-compatible TRISS_WORKER_* profile), opencode-zen, opencode-go, moonshot, or kimi-for-coding')
242
242
  .option('--allow-unverified', 'requires explicit --provider opencode-go (alias: go): allow the built-in fallback only after a temporary network or HTTP 408/429/500/502/503/504 catalogue failure (never bypasses 401/403, empty, or invalid responses)')
243
243
  .option('--allow-unsafe-bash', 'proceed even if an existing opencode.json has no deny-first bash policy (the agent runs with --auto)')
244
244
  .action(wrap(runCoderInit));
245
245
 
246
246
  coder
247
247
  .command('run [prompt]')
248
- .description('Spawn a coding agent — GLM, Kimi, OpenCode Zen, or OpenCode Go models (opencode default, or --engine crush) — and print a JSON envelope to stdout')
248
+ .description('Spawn a coding agent — GLM, the OpenAI-compatible Triss worker, Kimi, OpenCode Zen, or OpenCode Go (opencode default, or --engine crush) — and print a JSON envelope to stdout')
249
249
  .option('--engine <name>', 'coding engine: opencode (default) or crush')
250
250
  .option('--session <id>', 'triss-side session slug, mapped to a real opencode session id in .triss/sessions.json')
251
251
  .option('--continue', 'continue the most recent opencode session (maps to opencode --continue)')
@@ -274,7 +274,7 @@ coder
274
274
  ' • opencode: project opencode.json (local) or ~/.config/opencode/opencode.json (global)\n' +
275
275
  ' • crush: ./.crush/crush.json (local) or ~/.local/share/crush/crush.json (global)')
276
276
  .option('--engine <name>', 'coding engine: opencode (default) or crush')
277
- .option('--provider <name>', 'provider kind: zai, opencode-zen, opencode-go, moonshot, or kimi-for-coding')
277
+ .option('--provider <name>', 'provider kind: zai, worker, opencode-zen, opencode-go, moonshot, or kimi-for-coding')
278
278
  .option('--json', 'print the stable machine-readable state object (no secrets)')
279
279
  .action(wrap(runCoderModels));
280
280
 
@@ -296,7 +296,7 @@ coderModel
296
296
  )
297
297
  .option('--small <model>', 'small/fast model id (omit to keep the current compatible value)')
298
298
  .option('--engine <name>', 'coding engine: opencode (default) or crush')
299
- .option('--provider <name>', 'provider kind: zai, opencode-zen, opencode-go, moonshot, or kimi-for-coding')
299
+ .option('--provider <name>', 'provider kind: zai, worker, opencode-zen, opencode-go, moonshot, or kimi-for-coding')
300
300
  .option('-g, --global', 'write to the global scope (OpenCode: ~/.config/opencode/opencode.json + global .env; Crush: ~/.local/share/crush/crush.json)')
301
301
  .option('-l, --local', 'write to the project scope (OpenCode: ./opencode.json + ./.triss.env; Crush: ./.crush/crush.json)')
302
302
  .option('--allow-unverified', 'with explicit main + --small, bypass only a provider-defined transient catalogue failure (Go: transport or HTTP 408/429/500/502/503/504; Zen: timeout/http-error/parse-error; never auth or authoritative failure)')
@@ -30,7 +30,7 @@ management and recovery workflow.
30
30
 
31
31
  | Engine | Supported providers | Persistent model store |
32
32
  | --- | --- | --- |
33
- | `opencode` | Z.AI GLM, OpenCode Zen, Moonshot Kimi, Kimi for Coding | `opencode.json` plus `TRISS_CODER_MODEL` / `TRISS_CODER_SMALL_MODEL` |
33
+ | `opencode` | Triss worker (OpenAI-compatible), Z.AI GLM, OpenCode Zen, OpenCode Go, Moonshot Kimi, Kimi for Coding | `opencode.json` plus `TRISS_CODER_MODEL` / `TRISS_CODER_SMALL_MODEL` |
34
34
  | `crush` | Z.AI GLM only | crush large/fast model roles in `crush.json` |
35
35
 
36
36
  OpenCode Zen is not an engine and `hy3-free` was not a GLM model. It was one
@@ -648,7 +648,7 @@ verification contract as OpenCode applies (Corrective Blocker A):
648
648
  released on every exit (success, failure, rollback-failed).
649
649
  - `deps.lock` is an OVERRIDE seam for deterministic unit tests ONLY. Absence of
650
650
  `deps.lock` MUST NEVER mean unlocked: when `deps.lock` is not supplied the
651
- operation MUST use the built-in filesystem lock via `acquireDefaultLock`.
651
+ operation MUST use the shared filesystem lock via `acquireCoderMutationLock`.
652
652
  - The lock seam is `deps.lock(engine, scope)` returning `{ release() }`. When
653
653
  `deps.lock` is injected, the apply MUST call it; tests assert acquire happens
654
654
  before the config read and release happens after verification completes.
@@ -130,7 +130,7 @@ Removes a variable.
130
130
  | `worker` | `TRISS_WORKER_API_KEY`, `TRISS_WORKER_BASE_URL`, `TRISS_WORKER_FLASH_MODEL`, `TRISS_WORKER_PRO_MODEL` | only `TRISS_WORKER_API_KEY` is required |
131
131
  | `jira` | `ATLASSIAN_BASE_URL`, `ATLASSIAN_EMAIL`, `ATLASSIAN_API_TOKEN` | all three |
132
132
  | `linear` | `LINEAR_API_KEY`, `LINEAR_API_URL` | only `LINEAR_API_KEY` is required |
133
- | `coder` | `ZHIPU_API_KEY`, `OPENCODE_API_KEY`, `MOONSHOT_API_KEY`, `KIMI_API_KEY` (setup: `triss config wizard coder --coder-engine <engine> --coder-provider <provider>`, or `triss coder init --engine <engine> --provider <provider>`) | the **selected provider's** key — `ZHIPU_API_KEY` (`glm`), shared `OPENCODE_API_KEY` (`opencode-zen` or `opencode-go`), `MOONSHOT_API_KEY` (`moonshot`), `KIMI_API_KEY` (`kimi-for-coding`) |
133
+ | `coder` | `TRISS_WORKER_API_KEY`, `ZHIPU_API_KEY`, `OPENCODE_API_KEY`, `MOONSHOT_API_KEY`, `KIMI_API_KEY` (setup: `triss config wizard coder --coder-engine <engine> --coder-provider <provider>`, or `triss coder init --engine <engine> --provider <provider>`) | the **selected provider's** key — existing `TRISS_WORKER_API_KEY` (`worker`), `ZHIPU_API_KEY` (`glm`), shared `OPENCODE_API_KEY` (`opencode-zen` or `opencode-go`), `MOONSHOT_API_KEY` (`moonshot`), `KIMI_API_KEY` (`kimi-for-coding`) |
134
134
 
135
135
  When you add a new integration (see [extending.md](extending.md)), its
136
136
  `envVars` declaration is automatically picked up — no wizard changes needed.
@@ -267,7 +267,7 @@ self-hosted endpoints).
267
267
  | `MOONSHOT_API_KEY` | no¹ | — | Moonshot AI (Kimi) key for `ask`/`review --provider kimi` and `moonshotai/*` coder models — <https://platform.kimi.ai/console/api-keys> |
268
268
  | `KIMI_API_KEY` | no¹ | — | Kimi for Coding subscription key (opencode engine only) — unlocks `kimi-for-coding/*` models like `kimi-for-coding/k3` — <https://www.kimi.com/code/docs/en/> |
269
269
  | `TRISS_KIMI_BASE_URL` | no | `https://api.moonshot.ai/v1` | Endpoint for `--provider kimi` ask/review calls — set `https://api.moonshot.cn/v1` for a China-mainland key. Trailing slashes are stripped; a blank/degenerate value falls back to the default |
270
- | `TRISS_CODER_MODEL` | no | `zai-coding-plan/glm-5.2` | Resolved **main** model, passed to opencode via `--model`. Go uses `opencode-go/<id>`; Zen uses `opencode/<id>`. Main and small must stay within one provider prefix. |
270
+ | `TRISS_CODER_MODEL` | no | `zai-coding-plan/glm-5.2` | Resolved **main** model, passed to opencode via `--model`. Worker uses `triss-worker/<id>`, Go uses `opencode-go/<id>`, and Zen uses `opencode/<id>`. Main and small must stay within one provider prefix. |
271
271
  | `TRISS_CODER_SMALL_MODEL` | no | `zai-coding-plan/glm-5-turbo` | Small/fast **management/init intent** — written to `opencode.json` `small_model` by `init`/`triss coder model set`. **Not** a runtime override of an already-pinned small role (see precedence) |
272
272
  | `TRISS_CODER_OPENCODE_VERSION` | no | `1.18.7` | Pin override for the `opencode-ai` npm install |
273
273
  | `TRISS_CODER_ENGINE` | no | `opencode` | Coding engine: `opencode` (default) or `crush` |
@@ -429,11 +429,23 @@ fixed order so only the right single key is prompted:
429
429
  defaulting — give it `--engine` (or export `TRISS_CODER_ENGINE`) to
430
430
  proceed unattended.
431
431
  2. **Provider** next, *after* the engine and *before* any credential
432
- prompt: `--provider` (`glm`, `opencode-zen`, `opencode-go`, `moonshot`,
432
+ prompt: `--provider` (`glm`, `worker`, `opencode-zen`, `opencode-go`, `moonshot`,
433
433
  `kimi-for-coding`) → the engine's default for the keys already set.
434
434
  3. Triss then prompts for **only** that provider's key and writes the
435
435
  matching `opencode.json`/`crush.json`.
436
436
 
437
+ `--provider worker` is OpenCode-only and reuses the existing
438
+ `TRISS_WORKER_API_KEY`, `TRISS_WORKER_BASE_URL`, and worker flash/pro model
439
+ settings. It creates `triss-worker/*` model pins and does not introduce or copy
440
+ another secret. V1 supports one active worker profile and Chat Completions.
441
+ Rerun `triss coder init --provider worker` after changing the base URL or
442
+ flash/pro model ids so the managed OpenCode provider stays in sync. `--global`
443
+ reads the global worker profile rather than project-local values; parent-shell
444
+ exports remain explicit overrides. Before a worker run forwards the key, Triss
445
+ checks the effective project/global provider, endpoint, and complete model
446
+ allowlist and fails with a scope-specific init command if they are stale. Init,
447
+ model changes, and rollback share one `(engine, scope)` mutation lock.
448
+
437
449
  **Stale-model incident — don't hardcode a Zen free id.** Zen rotates its
438
450
  free tier, so a previously-working pinned id (the `opencode/hy3-*` free
439
451
  model) went stale mid-session: once Zen withdrew/renamed that id, configs
@@ -41,7 +41,8 @@ behind the same adapter interface. crush is always fed `ZHIPU_API_KEY`
41
41
  (bridged to `ZAI_API_KEY`); opencode is fed whichever key its resolved model
42
42
  needs — `ZHIPU_API_KEY` for GLM, `OPENCODE_API_KEY` for OpenCode Zen or Go (§3),
43
43
  `MOONSHOT_API_KEY` for `moonshotai/*` Kimi, `KIMI_API_KEY` for
44
- `kimi-for-coding/*`.
44
+ `kimi-for-coding/*`, or `TRISS_WORKER_API_KEY` for the managed
45
+ `triss-worker/*` OpenAI-compatible provider.
45
46
 
46
47
  ---
47
48
 
@@ -52,9 +53,9 @@ needs — `ZHIPU_API_KEY` for GLM, `OPENCODE_API_KEY` for OpenCode Zen or Go (§
52
53
  | Select via | default, or `--engine opencode` | `--engine crush` / `TRISS_CODER_ENGINE=crush` |
53
54
  | npm package | `opencode-ai` (pinned `1.18.7`) | `@phpcraftdream/crush` (pinned `0.1.6`) |
54
55
  | Version pin env | `TRISS_CODER_OPENCODE_VERSION` | `TRISS_CODER_CRUSH_VERSION` |
55
- | Key it reads | `ZHIPU_API_KEY` (native); shared `OPENCODE_API_KEY` for `opencode/…` Zen and `opencode-go/…` Go models; `MOONSHOT_API_KEY` for `moonshotai/…`; `KIMI_API_KEY` for `kimi-for-coding/…` | `ZAI_API_KEY` (Triss bridges from `ZHIPU_API_KEY`; crush ≥0.1.1 also reads `ZHIPU_API_KEY` natively) |
56
- | Providers | Z.AI GLM, OpenCode Zen (`opencode/…`; [opencode-zen.md](opencode-zen.md)), OpenCode Go (`opencode-go/…`; [opencode-go.md](opencode-go.md)), and Moonshot Kimi | Z.AI GLM only |
57
- | Provider config | `opencode.json` with a `zai-coding-plan/…` (or `zai/…`) model prefix; Zen/Kimi models resolve via opencode's built-in `opencode` / `moonshotai` / `kimi-for-coding` providers | `crush.json` `models` block (atoms `glm5_2` / `glm5_turbo`) |
56
+ | Key it reads | `TRISS_WORKER_API_KEY` for `triss-worker/…`; `ZHIPU_API_KEY` for GLM; shared `OPENCODE_API_KEY` for `opencode/…` Zen and `opencode-go/…` Go models; `MOONSHOT_API_KEY` for `moonshotai/…`; `KIMI_API_KEY` for `kimi-for-coding/…` | `ZAI_API_KEY` (Triss bridges from `ZHIPU_API_KEY`; crush ≥0.1.1 also reads `ZHIPU_API_KEY` natively) |
57
+ | Providers | Triss worker (`triss-worker/…`, OpenAI-compatible), Z.AI GLM, OpenCode Zen (`opencode/…`; [opencode-zen.md](opencode-zen.md)), OpenCode Go (`opencode-go/…`; [opencode-go.md](opencode-go.md)), Moonshot Kimi, and Kimi for Coding | Z.AI GLM only |
58
+ | Provider config | `opencode.json` with a provider-qualified model prefix. Triss writes `provider["triss-worker"]` with `@ai-sdk/openai-compatible`; Zen/Kimi models resolve via OpenCode's built-in providers | `crush.json` `models` block (atoms `glm5_2` / `glm5_turbo`) |
58
59
  | Output | ndjson stream that Triss folds into one envelope | ONE JSON object at end-of-run — trivial last-line parse |
59
60
  | Sessions | slug → real `ses_…` id mapped in `.triss/sessions.json` | native get-or-create with the caller's arbitrary id — no map |
60
61
  | Safety model | **deny-first bash allowlist** in `opencode.json` (persistent, enforced) | config `permissions.run` seeded into `crush.json` for forward-compat, but **currently inert** — enforcement is opt-in via `--restrict`, which emits the allowlist as **CLI flags** (`--allow-bash`/`--allow-tool`). See §8 |
@@ -310,7 +311,8 @@ derived from model ids):
310
311
  | `zai-coding-plan/glm-5.2` | `glm5_2` | large / smart |
311
312
  | `zai-coding-plan/glm-5-turbo` | `glm5_turbo` | small / fast |
312
313
 
313
- `zai/*` PAYG, every non-Z.AI prefix, and OpenCode Zen / Moonshot / Kimi models
314
+ `zai/*` PAYG, every non-Z.AI prefix, and Triss worker / OpenCode Zen / Go /
315
+ Moonshot / Kimi models
314
316
  are rejected before crush spawns, with an exact opencode alternative. Configured
315
317
  via `crush models use glm5_2 glm5_turbo`; `--role smart|fast` selects the atom
316
318
  at run time.
package/docs/mcp.md CHANGED
@@ -311,12 +311,13 @@ override for self-hosted instances):
311
311
  - `triss_gitlab_search` `triss_gitlab_issue` `triss_gitlab_create`
312
312
  `triss_gitlab_update` `triss_gitlab_comment`
313
313
 
314
- Exposed **when a provider credential is set** — `ZHIPU_API_KEY` (Z.AI GLM,
314
+ Exposed **when a provider credential is set** — `TRISS_WORKER_API_KEY` (the
315
+ existing OpenAI-compatible worker profile), `ZHIPU_API_KEY` (Z.AI GLM,
315
316
  the default), `OPENCODE_API_KEY` (OpenCode Zen or paid OpenCode Go — see
316
317
  [opencode-zen.md](opencode-zen.md) and [opencode-go.md](opencode-go.md)),
317
318
  `MOONSHOT_API_KEY` (Moonshot Kimi pay-as-you-go), **or** `KIMI_API_KEY`
318
319
  (Kimi for Coding subscription). Setup: `triss coder init`
319
- (`--provider opencode-zen`, `--provider opencode-go`, `--provider moonshot`, or
320
+ (`--provider worker`, `--provider opencode-zen`, `--provider opencode-go`, `--provider moonshot`, or
320
321
  `--provider kimi-for-coding`) or `triss config wizard coder`.
321
322
 
322
323
  - `triss_coder_run` — delegate an implementation task to a coding
@@ -332,7 +333,8 @@ the default), `OPENCODE_API_KEY` (OpenCode Zen or paid OpenCode Go — see
332
333
  isolate-OFF, crush resolves unset to isolate-ON (crush 0.1.3's
333
334
  `permissions.run` config is inert and denied bash deadlocks, so the
334
335
  worktree is its reliable safety layer). `model` takes a `<provider>/<id>`
335
- string — a Z.AI GLM (`zai-coding-plan/glm-5.2`), an OpenCode Zen model
336
+ string — a Triss worker model (`triss-worker/deepseek-v4-flash`, reuses
337
+ `TRISS_WORKER_API_KEY`), a Z.AI GLM (`zai-coding-plan/glm-5.2`), an OpenCode Zen model
336
338
  (`opencode/deepseek-v4-flash-free`, needs `OPENCODE_API_KEY`), an OpenCode
337
339
  Go model (`opencode-go/deepseek-v4-flash`, needs `OPENCODE_API_KEY` and Go
338
340
  entitlement), a Moonshot Kimi model (`moonshotai/kimi-k2.7-code`, needs
@@ -341,7 +343,7 @@ the default), `OPENCODE_API_KEY` (OpenCode Zen or paid OpenCode Go — see
341
343
  - `triss_coder_status` — the default engine, each engine's version/install
342
344
  state (`opencode` vs the pinned version, `crush` presence), which
343
345
  `opencode.json` / `crush.json` files exist, provider key presence
344
- (`ZHIPU_API_KEY` / `OPENCODE_API_KEY` / `MOONSHOT_API_KEY` /
346
+ (`TRISS_WORKER_API_KEY` / `ZHIPU_API_KEY` / `OPENCODE_API_KEY` / `MOONSHOT_API_KEY` /
345
347
  `KIMI_API_KEY` — never the value), and how many isolation
346
348
  worktrees are live.
347
349
 
@@ -0,0 +1,259 @@
1
+ # OpenAI-compatible coder provider plan
2
+
3
+ Implementation contract for running `triss coder` through a user-supplied
4
+ OpenAI-compatible Chat Completions endpoint without adding a provider-specific
5
+ branch to Triss for every vendor.
6
+
7
+ ## Accepted v1 decisions
8
+
9
+ - One active profile: the existing `TRISS_WORKER_*` configuration.
10
+ - Chat Completions only through `@ai-sdk/openai-compatible`.
11
+ - OpenCode engine only; Crush remains Z.AI-only.
12
+ - No additional coder API key, endpoint, or named-profile namespace.
13
+
14
+ ## Status and first acceptance provider
15
+
16
+ OpenCode supports custom providers in `opencode.json` through
17
+ `@ai-sdk/openai-compatible`. A provider definition names a stable provider id,
18
+ an API base URL, an environment-backed key, and the model ids that OpenCode may
19
+ run.
20
+
21
+ The first live acceptance provider is the official DeepSeek API:
22
+
23
+ | Setting | Value |
24
+ | --- | --- |
25
+ | OpenCode provider id | `triss-worker` |
26
+ | Base URL | `TRISS_WORKER_BASE_URL` (`https://api.deepseek.com/v1` by default) |
27
+ | Main model | `TRISS_WORKER_FLASH_MODEL` (`deepseek-v4-flash` by default) |
28
+ | Small model | `TRISS_WORKER_FLASH_MODEL` (`deepseek-v4-flash` by default) |
29
+ | Triss model | `triss-worker/deepseek-v4-flash` |
30
+ | Credential | Existing `TRISS_WORKER_API_KEY` |
31
+
32
+ DeepSeek is an acceptance recipe, not a hard-coded provider kind. The same
33
+ implementation must work when the existing worker profile points to another
34
+ compatible endpoint. The provider deliberately reuses that profile instead of
35
+ creating a second API-key namespace.
36
+
37
+ ## Goals
38
+
39
+ - Add `openai-compatible` as a first-class provider kind for the OpenCode coder
40
+ engine.
41
+ - Make the existing OpenAI-compatible worker profile available to the coder
42
+ under the stable OpenCode provider id `triss-worker`.
43
+ - Generate the corresponding `opencode.json.provider` entry with no literal
44
+ secret.
45
+ - Support the custom provider in `coder init`, `coder run`, `coder models`,
46
+ `coder model set`, status, the config wizard, MCP, and shell completion.
47
+ - Preserve provider-key isolation: a worker-provider run receives only
48
+ `TRISS_WORKER_API_KEY`, never every configured provider key.
49
+ - Preserve unknown `opencode.json` fields and the deny-first bash policy, and
50
+ use a locked atomic write while adding the provider definition and model
51
+ pins.
52
+ - Reuse the worker key, base URL, and model presets directly, without copying
53
+ or duplicating the secret.
54
+
55
+ ## Non-goals for v1
56
+
57
+ - Custom providers for the Crush engine. Crush remains Z.AI-only.
58
+ - Multiple simultaneously active worker profiles managed by Triss.
59
+ - OpenAI Responses API providers (`@ai-sdk/openai`). V1 targets the widely
60
+ supported `/chat/completions` contract through
61
+ `@ai-sdk/openai-compatible`.
62
+ - Provider-specific pricing, subscription, region, or privacy management.
63
+ - Automatic billable inference during setup.
64
+ - Arbitrary custom headers or arbitrary credential environment-variable names.
65
+ - A second coder-specific OpenAI-compatible key or endpoint namespace.
66
+
67
+ ## Configuration contract
68
+
69
+ The coder consumes the existing worker variables:
70
+
71
+ | Variable | Purpose |
72
+ | --- | --- |
73
+ | `TRISS_WORKER_API_KEY` | Existing worker secret; the only credential forwarded for this provider |
74
+ | `TRISS_WORKER_BASE_URL` | Existing OpenAI-compatible base URL |
75
+ | `TRISS_WORKER_FLASH_MODEL` | Default cheap/fast model id |
76
+ | `TRISS_WORKER_PRO_MODEL` | Optional larger model id exposed to model selection |
77
+ | `TRISS_CODER_MODEL` | Provider-qualified main pin, for example `triss-worker/deepseek-v4-flash` |
78
+ | `TRISS_CODER_SMALL_MODEL` | Provider-qualified small pin under `triss-worker/` |
79
+
80
+ The OpenCode provider id is the fixed `triss-worker`, so changing the worker
81
+ backend does not create stale provider prefixes. HTTPS is required for remote
82
+ hosts. Plain HTTP is accepted only for loopback hosts so the already documented
83
+ Ollama worker recipe remains usable without adding an insecure remote-key path.
84
+
85
+ For the DeepSeek example, Triss writes this provider shape while retaining the
86
+ existing permission policy and unrelated fields:
87
+
88
+ ```json
89
+ {
90
+ "model": "triss-worker/deepseek-v4-flash",
91
+ "small_model": "triss-worker/deepseek-v4-flash",
92
+ "provider": {
93
+ "triss-worker": {
94
+ "npm": "@ai-sdk/openai-compatible",
95
+ "name": "Triss worker (OpenAI-compatible)",
96
+ "options": {
97
+ "baseURL": "https://api.deepseek.com/v1",
98
+ "apiKey": "{env:TRISS_WORKER_API_KEY}"
99
+ },
100
+ "models": {
101
+ "deepseek-v4-flash": {
102
+ "name": "deepseek-v4-flash"
103
+ }
104
+ }
105
+ }
106
+ }
107
+ }
108
+ ```
109
+
110
+ No key value may appear in `opencode.json`, logs, errors, status JSON,
111
+ transaction snapshots, or recovery commands.
112
+
113
+ ## CLI contract
114
+
115
+ ```bash
116
+ # Guided setup reuses the configured worker key, endpoint, and model presets.
117
+ triss coder init --provider worker --global
118
+
119
+ # Configure a different compatible backend through the existing worker surface.
120
+ triss config set TRISS_WORKER_BASE_URL https://example.test/v1
121
+ triss config set TRISS_WORKER_FLASH_MODEL example-code-model
122
+ triss coder init --provider worker --global
123
+
124
+ # Read-only state from the configured worker profile.
125
+ triss coder models --provider worker
126
+
127
+ # Persistent switch within the configured custom provider.
128
+ # Run init again first whenever the worker endpoint or flash/pro ids change.
129
+ triss coder model set triss-worker/deepseek-v4-pro \
130
+ --small triss-worker/deepseek-v4-flash \
131
+ --provider worker --engine opencode --global --yes
132
+
133
+ # One-run override. The prefix resolves the active custom credential.
134
+ triss coder run --model triss-worker/deepseek-v4-flash "implement the task"
135
+ ```
136
+
137
+ `--provider openai-compatible` and `--provider openai` are aliases for
138
+ `--provider worker`. Model strings use `triss-worker/<model-id>` because that is
139
+ the stable identity OpenCode uses. The worker's unqualified flash/pro model ids
140
+ are converted to that form during init; run and model-management surfaces
141
+ continue to require a qualified id.
142
+
143
+ ## Discovery and validation
144
+
145
+ An OpenAI-compatible server is not required to expose `GET /models`, and its
146
+ catalogue authentication or response shape may differ from Chat Completions.
147
+ Triss therefore does not probe a generic worker endpoint during setup. The
148
+ configured `TRISS_WORKER_FLASH_MODEL` and `TRISS_WORKER_PRO_MODEL` values form
149
+ the authoritative local model list and are the only ids written into the
150
+ managed OpenCode provider. `coder models` reports that list with catalogue
151
+ status `not-supported`. `coder model set` rejects ids outside it and also
152
+ requires the selected `opencode.json` to contain the matching env-backed
153
+ provider definition; `coder init --provider worker` creates or refreshes it.
154
+
155
+ Setup validates the profile locally: the base URL must be absolute, remote
156
+ hosts require HTTPS, loopback HTTP is allowed, and credentials, query strings,
157
+ or fragments may not be embedded in the URL. It never sends a
158
+ `chat/completions` request because that can incur cost and send content to the
159
+ provider. A real minimal `coder run` is the live acceptance test after
160
+ configuration and reports the provider's exact runtime error on failure.
161
+
162
+ ## Existing-config and atomic-write rules
163
+
164
+ Custom-provider setup cannot use only the historical create-only behavior: an
165
+ existing file needs the provider definition in addition to model pins. For an
166
+ existing `opencode.json`, setup follows these rules:
167
+
168
+ 1. Acquire a sibling exclusive filesystem lock before reading the file.
169
+ 2. Parse and audit the effective `opencode.json`; malformed JSON or a missing
170
+ deny-first policy blocks unless the existing explicit safety override
171
+ applies.
172
+ 3. Reject a collision on `provider["triss-worker"]` unless it has the exact
173
+ Triss-managed shape. A managed definition may be refreshed when the worker
174
+ endpoint or flash/pro settings change; unknown fields and literal keys
175
+ block replacement.
176
+ 4. Mutate only `model`, `small_model`, and `provider["triss-worker"]`, while
177
+ preserving unrelated fields, indentation, newline convention, and file
178
+ mode; publish through a same-directory temporary file and atomic rename.
179
+ 5. Persist only the coder model pins in the selected Triss env scope; never
180
+ duplicate or rewrite the existing worker secret/profile.
181
+ 6. Audit effective higher-precedence config as part of setup. A blocking
182
+ finding stops completion, although the selected-scope atomic config update
183
+ may already be present and is safe to rerun. If a later env-pin write fails,
184
+ setup reports failure and can likewise be rerun; it does not claim a
185
+ cross-file transaction across `opencode.json` and the env file.
186
+
187
+ An identical provider definition is idempotent. A provider entry that uses a
188
+ literal API key is a blocking security finding; Triss must not copy, print, or
189
+ silently preserve that secret as its managed definition.
190
+
191
+ ## Docs-first TDD sequence
192
+
193
+ 1. Add RED tests for worker base-URL validation, closed-enum routing,
194
+ DeepSeek config generation, credential isolation, and Crush rejection.
195
+ 2. Add RED atomic-write tests for a new file, a safe existing file,
196
+ idempotency, provider collision, malformed JSON, missing deny-first policy,
197
+ managed-profile refresh, and higher-precedence shadowing.
198
+ 3. Add RED model-management tests proving that discovery is local, performs no
199
+ network request, and accepts only the configured flash/pro ids.
200
+ 4. Implement the minimum provider metadata, custom profile resolver, config
201
+ builder, transaction extension, and run-time credential mapping.
202
+ 5. Update CLI/wizard/MCP/help, `.env.example`, README, configuration docs, and
203
+ generated agent instruction templates in lockstep.
204
+ 6. Run focused tests, lint, `git diff --check`, and the complete suite.
205
+ 7. With the existing worker DeepSeek key, run a minimal isolated live coder
206
+ task and verify the child receives no unrelated credential.
207
+ 8. Run an adversarial review with at least 16384 output tokens, remediate every
208
+ confirmed finding, and repeat until no actionable findings remain.
209
+
210
+ ## Acceptance criteria
211
+
212
+ - `--provider openai-compatible` is accepted only with the OpenCode engine.
213
+ - A valid worker profile produces `triss-worker/deepseek-v4-flash` without hard-coding
214
+ DeepSeek into generic routing logic.
215
+ - The generated provider block uses `@ai-sdk/openai-compatible`, the exact
216
+ normalized worker base URL, and `{env:TRISS_WORKER_API_KEY}`.
217
+ - An existing safe config is updated under a lock with atomic replacement and
218
+ retains unknown fields and its permission policy; a conflicting provider
219
+ entry is unchanged and blocks setup.
220
+ - Main and small model prefixes must equal `triss-worker`.
221
+ - `coder model set --provider worker` fails with an exact init command unless
222
+ the target scope already contains the current env-backed worker provider and
223
+ both requested model definitions.
224
+ - A worker-provider run succeeds with only `TRISS_WORKER_API_KEY` configured
225
+ and forwards only that provider key.
226
+ - Missing custom credentials, invalid profile metadata, insecure remote HTTP,
227
+ cross-provider model pairs, and Crush usage fail before spawning OpenCode.
228
+ - No generic catalogue request is made. Only the configured worker flash/pro
229
+ ids can be selected or persisted by Triss.
230
+ - Existing Z.AI, OpenCode Zen, OpenCode Go, Moonshot, and Kimi behavior remains
231
+ unchanged.
232
+ - DeepSeek live acceptance completes through its official API and reports the
233
+ exact provider error if the endpoint rejects the request.
234
+ - User-facing documentation explains the one-profile v1 limit, secret
235
+ boundary, local model list, and Chat Completions-only scope.
236
+
237
+ ## PR review remediation contract
238
+
239
+ The implementation must preserve these additional invariants across init,
240
+ model management, and run:
241
+
242
+ 1. Worker settings are resolved for the requested scope. A global operation
243
+ reads the global Triss env file only; a local operation reads local values
244
+ with global fallback. Values inherited from the parent shell override either
245
+ scope, but dotenv-injected values are never mistaken for shell overrides.
246
+ 2. A global setup audits any higher-precedence project
247
+ `provider["triss-worker"]`. If present, it must exactly match the managed
248
+ env-backed provider, endpoint, and complete flash/pro model set. Project
249
+ worker model pins must also belong to that set.
250
+ 3. Every worker run validates the effective managed provider, current endpoint,
251
+ and selected model before isolation or engine spawn. A missing or stale
252
+ definition fails closed with an engine-explicit, scope-explicit init command.
253
+ 4. Worker init, `coder model set`, and rollback use the same
254
+ `(engine, scope)` filesystem lock, including PID/token ownership and dead-PID
255
+ recovery. Init holds it from its first config read through the config rename
256
+ and model-pin persistence; new-file creation is not an unlocked exception.
257
+ 5. Worker readiness metadata has one shared source used by status and MCP.
258
+ 6. Tracker responses never include coder credential inventory; Jira issue
259
+ output and summarization corpus are independent of `TRISS_WORKER_API_KEY`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triss-coworker",
3
- "version": "0.28.0",
3
+ "version": "0.29.0",
4
4
  "description": "Give your AI coding agent a cheap DeepSeek coworker. Delegate bulk reads, boilerplate, and doc updates to save 60-70% of your token budget.",
5
5
  "type": "module",
6
6
  "bin": {