vibeostheog 0.15.22 → 0.15.34

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.
Files changed (4) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +86 -236
  3. package/package.json +1 -1
  4. package/src/index.js +1056 -985
package/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.15.23
2
+ - feat: add trinity api-token command to inject VIBEOS_API_TOKEN
3
+
4
+
1
5
  ## 0.15.22
2
6
  - chore: update flash pricing, add fallback indicator to footer
3
7
 
package/README.md CHANGED
@@ -1,225 +1,45 @@
1
1
  # vibeOS for OpenCode
2
2
 
3
- Cost-aware delegation and policy plugin for OpenCode Desktop.
3
+ VIBE is a smart model router for OpenCode Desktop. It automatically selects and switches between brain, medium, and cheap model tiers based on the task at hand — expensive models handle orchestration while cost-effective models execute implementation work. No manual slot-picking needed.
4
4
 
5
- vibeOS helps keep expensive model usage under control by enforcing delegation behavior, tracking savings, and exposing runtime controls through the `trinity` tool.
5
+ The core is the VIBE autoswitcher: a decision engine that routes each request to the right tier based on context, enforcement policy, and session state. You stay in control via the `trinity` tool set, but the default workflow is zero-config.
6
6
 
7
- ## Version
7
+ Beyond routing, vibeOS tracks savings from tier-switching, enforces delegation policies, and provides real-time visibility through a live status footer and web dashboard.
8
8
 
9
- Current package version: `0.14.1`
9
+ ## Savings Categories
10
10
 
11
- ## What It Does
12
-
13
- - Tracks estimated savings from delegation warnings and enforcement events.
14
- - Tracks cache savings as a separate persisted category when scratchpad cache hits are observed.
15
- - Adds a live footer to assistant outputs with model split, cumulative savings, and trend arrow.
16
- - Provides `trinity` runtime controls for slot switching, enforcement toggles, audits, and diagnostics.
17
- - Adds per-session model locking: prevents the plugin from auto-switching models when the user changes the model in the OpenCode GUI (`trinity lock on|off`).
18
- - Adds optional flow checks and TDD skeleton enforcement.
19
- - Adds project guard: ensures AGENTS.md and README.md exist and stay protected in every project.
20
- - Adds report and research-audit tooling.
21
- - Learns recurring struggle and routine patterns per project, with `trinity patterns` inspection and `trinity patterns clear`.
22
- - Stress mitigation pipeline: detects user stress signals, shows live stress gauge in footer, injects protective system prompts, and upgrades Task tier when user is stressed.
23
- - vibeOS MCP server with HTTP API for extended tool capabilities (trinity, reports, session metrics, diagnostics).
24
- - TUI dashboard sidebar plugin for real-time plugin status and controls.
25
- - **Web dashboard** — SolidJS SPA served via standalone server (`npm run dashboard`) or embedded in the MCP server. Real-time SSE push updates at `http://127.0.0.1:3333`.
26
- - Worker-to-Brain (WBP) protocol synthesizes delegated task output directly in assistant chat.
27
- - **Remote API protection**: Core algorithms run on a self-hosted API server (`api.vibetheog.com`) with token-based authentication. Non-paying seats can be deactivated, immediately revoking all API tokens and falling back to local degraded mode.
28
-
29
- ## Remote API Protection
30
-
31
- vibeOS protects its core algorithms by serving them from a self-hosted API server rather than bundling them entirely in the plugin:
32
-
33
- | Algorithm | Endpoint | Description |
34
- |---|---|---|---|
35
- | Delegation enforcement | `POST /api/v1/delegate/check` | Model cost calculation, block/warn routing |
36
- | Model tier routing | `POST /api/v1/route/model` | Tier classification, stress-aware routing |
37
- | Stress scoring | `POST /api/v1/stress/score` | NLP stress signal detection |
38
- | Blackbox engine | `POST /api/v1/blackbox/analyze` | Dialogue trajectory, loop detection, pivot/switch, outcome tracking |
39
- | Blackbox calibration | `POST /api/v1/blackbox/calibrate` | Auto-tune thresholds from session outcomes |
40
- | Blackbox calibration state | `GET /api/v1/blackbox/calibration` | Read calibrated weights per project |
41
- | Blackbox outcome | `POST /api/v1/blackbox/outcome` | Record session satisfaction outcome |
42
- | Blackbox project sessions | `GET /api/v1/blackbox/project-sessions` | List cross-session history per project |
43
- | TDD skeleton gen | `POST /api/v1/tdd/skeleton` | Multi-language test generation |
44
- | Pattern learner | `POST /api/v1/patterns/observe` | Friction/routine detection |
45
- | Model pricing | `POST /api/v1/pricing/fetch` | Dynamic OpenRouter pricing cache |
46
- | Context compression | `POST /api/v1/compress/context` | Bullet-point extraction |
47
-
48
- ### Environment Variables
49
-
50
- ```
51
- VIBEOS_API_URL=https://api.vibetheog.com # API server URL (default: https://api.vibetheog.com)
52
- VIBEOS_API_TOKEN=vos_... # Your API token (required for remote mode)
53
- VIBEOS_API_ENABLED=true # Set to "false" to use local-only mode
54
- CLAUDE_CREDIT_PERCENT=150 # Override credit percentage (default: 100)
55
- CLAUDE_CONTEXT7_AVAILABLE=true # Set to enable context7 cost optimization
56
- CLAUDE_SCRATCHPAD_MAX_AGE_SEC=86400 # Scratchpad cache lifetime in seconds
57
- VIBEOS_MCP_PORT=3001 # MCP server port (default: 3001)
58
- ```
59
-
60
- When `VIBEOS_API_TOKEN` is not set or `VIBEOS_API_ENABLED=false`, the plugin runs in local-only mode with all algorithms bundled. When a valid token is provided, core algorithms are offloaded to the remote API.
61
-
62
- ### Seat & Token Management
63
-
64
- The API server manages licenses via seats:
65
-
66
- - **Create a seat + token** (WordPress integration):
67
- `POST /admin/seats` with `{ "name": "...", "email": "...", "with_token": "label" }`
68
-
69
- - **Suspend a seat** (non-paying customer):
70
- `PATCH /admin/seats/:id` with `{ "status": "suspended" }`
71
- This immediately revokes all API tokens for that seat. The plugin falls back to local degraded mode.
72
-
73
- - **Reactivate a seat**:
74
- `PATCH /admin/seats/:id` with `{ "status": "active" }`
75
-
76
- ## Runtime Model Slots
77
-
78
- Slots are configured in `~/.claude/model-tiers.json`:
79
-
80
- - `brain`
81
- - `medium`
82
- - `cheap`
83
-
84
- On startup, the plugin detects the active model/slot from `model-tiers.json`. No automatic slot switching occurs; use `trinity set <slot>` or `trinity rebuild` to change slots.
85
-
86
- ## Savings Categories (Persisted)
87
-
88
- State file: `~/.claude/delegation-state.json`
89
-
90
- - Delegation savings:
91
- - `sessions[...].warns[].est_savings_usd`
92
- - aggregated into footer totals
93
- - Cache savings:
94
- - `sessions[...].cache_savings_usd`
95
- - `lifetime.cache_savings_usd`
96
- - optional `sessions[...].cache_hits[]` audit entries
97
- - Context7 missed-savings tracker:
98
- - `lifetime.missed_context7_usd`
99
-
100
- ## Footer Format
101
-
102
- Typical output footer:
103
-
104
- `— [model route] | VibeTheOG: <total> saved <arrow> —`
105
-
106
- Example (with savings):
107
-
108
- `— [🧠 deepseek-v4-flash → ⚙ deepseek-chat] | VibeTheOG: 0.01 saved → —`
109
-
110
- Example (no savings yet, tier label only):
111
-
112
- `— [⚙ Mid] —`
113
-
114
- ## `trinity` Tool Commands
115
-
116
- Main commands:
117
-
118
- - `trinity status`
119
- - `trinity set brain|medium|cheap`
120
- - `trinity brain|medium|cheap`
121
- - `trinity enable` / `trinity disable`
122
- - `trinity thinking full|brief|off`
123
- - `trinity enforce` / `trinity enforce on|off`
124
- - `trinity lock on|off` / `trinity lock`
125
- - `trinity flow on|off` / `trinity flow enforce on|off` / `trinity flow`
126
- - `trinity tdd on|off` / `trinity tdd strict on|off` / `trinity tdd quality on|off` / `trinity tdd`
127
- - `trinity project`
128
- - `trinity patterns`
129
- - `trinity patterns clear`
130
- - `trinity patterns suggest`
131
- - `trinity repair-state`
132
- - `trinity guard`
133
- - `trinity diagnose`
134
- - `trinity rebuild`
135
- - `trinity help`
136
-
137
- ## Optional Enforcement Modules
11
+ - **Delegation savings** — Estimated cost avoided by routing tasks to cheaper models.
12
+ - **Cache savings** — Cost avoided from scratchpad cache hits.
138
13
 
139
- - Delegation enforcement:
140
- - Blocks direct `write`/`edit`/`notebookedit` on high-tier brain when enabled.
141
- - Adds user-visible enforcement notes.
142
- - Flow enforcer:
143
- - Rule checks for write/edit patterns.
144
- - Optional TODO/FIXME extraction queue when flow enforcement is enabled.
145
- - TDD enforcer:
146
- - Auto-creates skeleton tests for changed source files when enabled.
147
- - Strict mode is ON by default: TODO tests fail loudly until implemented.
148
- - Project Guard:
149
- - On session init, checks if AGENTS.md and README.md exist in the project root.
150
- - Auto-creates AGENTS.md with protective rules (LLM must ask before modifying code).
151
- - Auto-creates README.md with tech stack auto-detection and feature stubs.
152
- - Flow rules warn/flag on write/edit to these protected files.
153
- - System prompt injects directive to maintain both files.
154
- - `trinity guard` command regenerates both files on demand.
14
+ Both are summed in the live footer and persisted in \`~/.claude/delegation-state.json\` across sessions.
155
15
 
156
- ## Reports and Audit Tools
157
-
158
- - `research-audit`
159
- - `report-save`
160
- - `report-list`
161
- - `report-read`
162
-
163
- These use `~/.claude/reports` and project memory in `~/.claude/project-states.json`.
164
-
165
- ## Pattern Learning
166
-
167
- - Detects repeated friction signals and recurring successful routines from session behavior.
168
- - Stores per-project pattern memory in `~/.claude/project-states.json`.
169
- - Promotes patterns after repeated confirmation across sessions and surfaces them via `trinity patterns`.
170
-
171
- ## Blackbox Decision Engine
172
-
173
- The blackbox tracks dialogue trajectory per-session and per-project, providing real-time decision state insights:
174
-
175
- **Enabled by default.**
176
-
177
- - **Resolution tracking**: Classifies each session into one of 7 sub-regimes (INIT, DIVERGENT, EXPLORING, REFINING, CONVERGING, CLOSED, LOOPING) based on entropy trends, action consistency, feature contradiction, and embedding drift.
178
- - **Real feature extraction**: Derives 11 features from each user message — message length, word count, question ratio, code blocks, urgency signals, sentiment, complexity, repetition, and instruction density.
179
- - **Loop prevention**: Detects when the conversation is going in circles and injects escalating system prompt interventions (gentle → suggestive → assertive → escalated) to break the loop.
180
- - **PIVOT/SWITCH detection**: Recognizes when the user changes context outside the current project scope and injects scope-confirmation directives.
181
- - **Outcome tracking**: Detects satisfaction signals from assistant responses (positive: "thanks/that works/perfect"; negative: "broken/still failing/wrong") and records them for calibration.
182
- - **Cross-session continuity**: State persists per project fingerprint in `~/.claude/blackbox-state.json` and remotely in SQLite, allowing resolution state to carry across terminal restarts.
183
- - **Online calibration**: The API server aggregates session outcomes and auto-tunes loop detection, momentum, and closure thresholds per project via `POST /api/v1/blackbox/calibrate`.
184
-
185
- Commands:
186
- - `trinity blackbox on` — Enable the decision engine
187
- - `trinity blackbox off` — Disable the decision engine
188
- - `trinity blackbox status` — View current resolution, sub-regime, momentum, loop state, and project history
189
- - `trinity blackbox reset` — Clear the resolution tracker for the current session
190
-
191
-
192
- The blackbox injects a decision directive into system prompts showing current resolution state, intent volatility, and continuity. When looping or pivoting is detected, stronger intervention directives are injected to guide the model.
193
-
194
- ### Session Workflow Phases
195
-
196
- The meta-controller maps detected sub-regimes to optimization modes, which are the authority over all plugin settings. Each turn, `syncControlSettings()` writes the mode's control vector to `model-tiers.json`, auto-toggling enforcement, flow, TDD, and thinking level:
197
-
198
- | Regime | Mode | Enforce | Flow | TDD | Tier | Think |
199
- |---|---|---|---|---|---|---|
200
- | INIT | budget | relaxed | audit | lazy | cheap | off |
201
- | EXPLORING / DIVERGENT | budget | relaxed | audit | lazy | cheap | off |
202
- | REFINING | budget | relaxed | audit | lazy | cheap | off |
203
- | CONVERGING / CLOSED | quality | strict | strict | quality | brain | full |
204
- | LOOPING | speed | relaxed | audit | lazy | medium | off |
205
-
206
- **Stress override**: When user stress exceeds 1.5, any regime escalates to `quality` mode — enforcement tightens, brain tier activates. Settings are re-synced every turn; mode is the sole authority. Manual `trinity enforce on/off` still works until the next turn re-evaluates.
16
+ ## What It Does
207
17
 
208
- When the blackbox is disabled, a lightweight `classifyTurnSimple()` fallback inspects user message patterns:
209
- - Q&A patterns (`"how"`, `"what"`, `"explain"`) EXPLORING (relaxed)
210
- - Implementation patterns (`"write"`, `"fix"`, `"implement"`) REFINING (normal)
18
+ - **Smart delegation** Blocks direct write/edit on high-tier models and routes work to cheaper subagents
19
+ - **Cost tracking** Tracks estimated savings from delegation events and cache hits, displayed in a live footer
20
+ - **trinity commands** Runtime controls for model switching, enforcement toggles, audits, and diagnostics
21
+ - **Flow enforcer** — Validates write/edit patterns against project rules; optionally extracts TODOs/FIXMEs
22
+ - **TDD enforcer** — Auto-creates test skeletons for changed source files; strict mode makes TODO tests fail loudly
23
+ - **Project guard** — Protects AGENTS.md and README.md in every project with auto-regeneration
24
+ - **Pattern learner** — Detects recurring friction and routine patterns per project, surfaces via `trinity patterns`
25
+ - **Stress mitigation** — Detects user stress signals, adjusts tier routing, and injects protective prompts
26
+ - **Model locking** — Prevents auto-switching when model is changed in the OpenCode GUI (`trinity lock`)
27
+ - **Report & audit** — `report-save`, `report-list`, `report-read`, and `research-audit` tools
28
+ - **Worker-to-Brain protocol** — Delegates implementation tasks to cheaper subagents, synthesizes results in-chat
29
+ - **Web dashboard** — Real-time status, savings, stress gauge, and controls via browser
30
+ - **TUI sidebar** — Plugin status and controls via OpenCode sidebar plugin
31
+ - **Blackbox decision engine** — Dialogue trajectory tracking with loop prevention, pivot detection, and outcome tracking
211
32
 
212
33
  ## Install
213
34
 
214
35
  ### npm (Recommended)
215
36
 
216
- Published to npm as `vibeOS`:
217
-
218
37
  ```bash
219
38
  npm install vibeOS
220
39
  ```
221
40
 
222
- Then register in `~/.config/opencode/opencode.json`:
41
+ Register in `~/.config/opencode/opencode.json`:
42
+
223
43
  ```json
224
44
  "plugins": [
225
45
  { "id": "vibeOS", "path": "node_modules/vibeOS/src/index.js" }
@@ -228,19 +48,9 @@ Then register in `~/.config/opencode/opencode.json`:
228
48
 
229
49
  ### Local Plugin File
230
50
 
231
- For OpenCode Desktop local plugin usage, copy these files to `~/.config/opencode/plugins/`:
232
-
233
- ```
234
- cp src/index.js ~/.config/opencode/plugins/vibeOS.js
235
- cp src/vibeOS-lib/flow-enforcer.js ~/.config/opencode/plugins/vibeOS-lib/flow-enforcer.js
236
- cp src/vibeOS-lib/session-metrics.js ~/.config/opencode/plugins/vibeOS-lib/session-metrics.js
237
- cp src/vibeOS-lib/flow-rules.json ~/.config/opencode/plugins/vibeOS-lib/flow-rules.json
238
- cp src/utils/cost-formatter.js ~/.config/opencode/plugins/vibeOS-lib/cost-formatter.js
239
- cp src/utils/math.js ~/.config/opencode/plugins/vibeOS-lib/math.js
240
- cp src/utils/timer.js ~/.config/opencode/plugins/vibeOS-lib/timer.js
241
- ```
51
+ Copy the plugin and lib files to `~/.config/opencode/plugins/`. See the repository for the complete file list.
242
52
 
243
- Then register the plugin in `~/.config/opencode/opencode.json`:
53
+ Register in `~/.config/opencode/opencode.json`:
244
54
 
245
55
  ```json
246
56
  "plugins": [
@@ -248,39 +58,79 @@ Then register the plugin in `~/.config/opencode/opencode.json`:
248
58
  ]
249
59
  ```
250
60
 
251
- Restart OpenCode Desktop. The plugin auto-creates `~/.claude/model-tiers.json` on first run.
61
+ Restart OpenCode Desktop. The plugin auto-creates its configuration on first run.
62
+
63
+ ## trinity Commands
64
+
65
+ | Command | Description |
66
+ |---|---|
67
+ | `trinity status` | Show current plugin state |
68
+ | `trinity set brain\|medium\|cheap` | Switch model slot |
69
+ | `trinity brain\|medium\|cheap` | Shorthand slot switch |
70
+ | `trinity enable` / `trinity disable` | Toggle plugin on/off |
71
+ | `trinity thinking full\|brief\|off` | Set reasoning depth |
72
+ | `trinity enforce on\|off` | Toggle delegation enforcement |
73
+ | `trinity lock on\|off` | Toggle model locking |
74
+ | `trinity flow on\|off` | Toggle flow enforcer |
75
+ | `trinity flow enforce on\|off` | Toggle auto TODO extraction |
76
+ | `trinity tdd on\|off` | Toggle test skeleton gen |
77
+ | `trinity tdd strict on\|off` | Toggle strict mode |
78
+ | `trinity tdd quality on\|off` | Toggle quality mode |
79
+ | `trinity blackbox on\|off\|status\|reset` | Decision engine controls |
80
+ | `trinity project` | Per-project analytics |
81
+ | `trinity patterns` / `trinity patterns clear` | Inspect / clear patterns |
82
+ | `trinity guard` | Regenerate project guard files |
83
+ | `trinity diagnose` | Run diagnostics |
84
+ | `trinity rebuild` | Auto-detect available models |
85
+ | `trinity help` | Command reference |
252
86
 
253
- ## Web Dashboard
87
+ ## Footer Format
88
+
89
+ Typical output footer:
90
+
91
+ ```
92
+ — [model route] | VibeTheOG: <total> saved <arrow> —
93
+ ```
254
94
 
255
- Open `http://127.0.0.1:3333` in your browser after starting the server.
95
+ The footer shows model split, cumulative savings, stress gauge, and trend arrow.
96
+
97
+ ## Web Dashboard
256
98
 
257
99
  ```bash
258
- npm run build:dashboard # Build the SPA (one-time)
259
- npm run dashboard # Start standalone server on :3333
260
- npm run dev:dashboard # Vite dev server on :5173 with hot-reload
100
+ npm run build:dashboard # Build the SPA
101
+ npm run dashboard # Start server on http://127.0.0.1:3333
261
102
  ```
262
103
 
263
- Features: model split, savings, sessions, stress gauge, trinity controls, reports, blackbox state. SSE push updates every 1.5s.
104
+ Displays model split, savings, session history, stress gauge, trinity controls, reports, and blackbox state with SSE push updates every 1.5s.
264
105
 
265
- ## Build
106
+ ## Environment Variables
266
107
 
267
- - `npm run build`
268
- - `npm run build:dashboard` (build the web dashboard SPA)
108
+ | Variable | Default | Description |
109
+ |---|---|---|
110
+ | `VIBEOS_API_URL` | `https://api.vibetheog.com` | API server URL |
111
+ | `VIBEOS_API_TOKEN` | — | API token (required for remote mode) |
112
+ | `VIBEOS_API_ENABLED` | `true` | Set to `false` for local-only mode |
113
+ | `CLAUDE_CREDIT_PERCENT` | `100` | Credit percentage override |
114
+ | `CLAUDE_CONTEXT7_AVAILABLE` | — | Enable context7 cost optimization |
115
+ | `CLAUDE_SCRATCHPAD_MAX_AGE_SEC` | `86400` | Scratchpad cache lifetime |
116
+ | `VIBEOS_MCP_PORT` | `3001` | MCP server port |
269
117
 
270
- `npm run build` compiles TypeScript source-of-truth modules and syncs generated JS artifacts used by runtime.
118
+ Without an API token, the plugin runs in local-only mode with all algorithms bundled locally.
271
119
 
272
- ## CI/CD
273
-
274
- GitHub Actions workflows are in `.github/workflows/`:
120
+ ## Runtime Model Slots
275
121
 
276
- - **CI** (`.github/workflows/ci.yml`): Runs on every push/PR to `main`/`master`. Executes typecheck, syntax check, test suite, TypeScript audit, and build validation.
122
+ Tier configuration in `~/.claude/model-tiers.json`:
277
123
 
278
- - **Release** (`.github/workflows/release.yml`): Manual trigger via GitHub Actions UI (`workflow_dispatch`). Prompts for version bump type (patch/minor/major), then runs tests, builds, and executes `scripts/release.mjs --yes --ci` which bumps version, updates changelog, commits/tags/pushes, creates a GitHub Release, and publishes to npm.
124
+ | Slot | Purpose |
125
+ |---|---|
126
+ | `brain` | High-tier model for orchestration |
127
+ | `medium` | Mid-tier for moderate tasks |
128
+ | `cheap` | Low-tier for delegation subagents |
279
129
 
280
- Before using the release workflow, add an `NPM_TOKEN` secret to the repository with an npm automation token that has publish permissions for the `vibeOS` package.
130
+ Use `trinity set brain|medium|cheap` or `trinity rebuild` to configure.
281
131
 
282
132
  ## Known Limitations
283
133
 
284
- - OpenCode runtime behavior can vary by version for per-task model override handling.
285
- - Some legacy tests in this repo are older than current enforcement defaults and may fail due to changed policy semantics rather than runtime breakage.
286
- - Savings are estimates, not billing data.
134
+ - OpenCode runtime behavior can vary by version.
135
+ - Some test suite tests may fail due to policy semantic changes rather than actual breakage.
136
+ - Savings displayed are estimates, not billing data.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vibeostheog",
3
- "version": "0.15.22",
3
+ "version": "0.15.34",
4
4
  "description": "Cost-aware delegation enforcer for OpenCode. Tracks model usage, routes Task subagents to cheaper tiers, surfaces cumulative savings in chat. Includes research audit, reporting framework, project memory, progressive scratchpad decadence, and trinity CLI for brain/medium/cheap slot switching.",
5
5
  "scripts": {
6
6
  "release": "node scripts/release.mjs",