Skip to main content
Glama
Still in Business

Still in Business

by winston003
README.md
# workbuddy-plugin-still-in-business

[![CI](https://github.com/winston003/workbuddy-plugin-still-in-business/actions/workflows/ci.yml/badge.svg)](https://github.com/winston003/workbuddy-plugin-still-in-business/actions/workflows/ci.yml)
![License: MIT (bridge) / AGPL-3.0 (game)](https://img.shields.io/badge/License-MIT%20%2B%20AGPL--3.0-blue.svg)
![MCP Apps](https://img.shields.io/badge/MCP%20Apps-io.modelcontextprotocol%2Fui-blue)

**活过第一年(Still in Business)** 的 WorkBuddy / CodeBuddy 插件:在对话里直接打开的
**单机经营模拟**——一家车库公司的 365 天,3D 办公室与多窗口经营面板随包分发,
进度落插件数据目录,零配置零依赖零账号。

**EN**: A WorkBuddy / CodeBuddy plugin for **Still in Business**, a standalone business
simulation game. `open_game` renders an interactive 3D game panel right in the
conversation via MCP Apps; `get_status` gives your agent a save-game briefing.

| 🏠 标题 | 🏢 经营中 | 🧩 可裁剪 | 🌐 多语言 |
| :---: | :---: | :---: | :---: |
| ![标题](assets/screenshot-title.png) | ![经营](assets/screenshot-game.png) | ![开关](assets/screenshot-modules.png) | ![西语](assets/screenshot-spanish.png) |

## ✨ 特性

- 🎮 **对话即玩**:`open_game` 经 [MCP Apps](https://modelcontextprotocol.io/extensions/apps/overview)
  (`io.modelcontextprotocol/ui`)在对话里渲染完整游戏面板——three.js 3D 街区、多窗口经营、加速与暂停
- 🤖 **Agent 幕僚**:`get_status` 只读回报存档简报(天数/现金/客户/MRR/团队/胜负),agent 可以陪你复盘
- 🎒 **装上即玩**:游戏前端与本地引擎随包分发(单文件内联,~2MB),零服务端、零账号、零外部请求
- 💾 **跨会话存档**:沙箱 iframe 不可靠存储由桥接层兜底——存档经 MCP 桥落插件数据目录,乐观并发 + 幂等写入
- 🗣️ **六种语言**:中文 / English / Español / Português / Français / Deutsch,自动识别
- 🧩 **部署裁剪**:`STILL_IN_BUSINESS_CONFIG` 特性开关(与 DSH 插件同一套),fail-open 到全量
- 🧪 **测试守卫**:`npm test` 即跑,零依赖零构建

## 安装

### 方式一 · 插件市场(WorkBuddy / CodeBuddy CLI 与桌面端)

本仓库自身就是一个单插件市场:

```
/plugin marketplace add winston003/workbuddy-plugin-still-in-business
/plugin install still-in-business@still-in-business-marketplace
```

桌面端:插件页面 → 添加插件市场 → 输入 `winston003/workbuddy-plugin-still-in-business` → 安装。

### 方式二 · 手动注册 MCP server

把下面这段加进 `~/.workbuddy/mcp.json`(WorkBuddy)或 `~/.codebuddy/mcp.json`(CodeBuddy CLI),
然后重启客户端:

```json
{
  "mcpServers": {
    "still-in-business": {
      "type": "stdio",
      "command": "<本仓库路径>/mcp-app/bin/run-node",
      "args": ["<本仓库路径>/mcp-app/server.mjs"]
    }
  }
}
```

### 方式三 · 本地目录安装

```
/plugin install /path/to/workbuddy-plugin-still-in-business
```

## 使用

对话里说:

- 「打开活过第一年,我想玩一会儿」→ agent 调 `open_game`,面板渲染在对话里
- 「我玩到哪了?帮我看看这局经营得怎么样」→ agent 调 `get_status`,只读简报
- 存档由面板节流批量写回;首次保存宿主会请求授权,选「始终允许」即可

> 面板在不渲染 MCP Apps 的界面(终端等)自动降级为文本:`open_game` 返回存档概览,
> 照常陪用户分析。存档文件在插件数据目录 `saves/local-storage.json`,可直接备份。

## 它是怎么工作的

```
WorkBuddy / CodeBuddy(MCP Apps 宿主)
 ├─ tools/call open_game ──► 宿主渲染 ui://still-in-business/app
 │     └─ 单文件 HTML(lib/ui-bundle.mjs 把 browser/ 全量内联)
 │          ├─ mcp-app/fw-host.js:JSON-RPC postMessage 桥 + localStorage 垫片
 │          └─ 游戏前端 + 本地引擎(browser/,AGPL-3.0)
 ├─ resources/read fwsave://… ──► 启动时灌入存档
 ├─ tools/call save_local_storage ──► 节流批量写回(乐观并发 + 幂等键)
 └─ get_status ──► 只读存档简报(不渲染面板的宿主的文本兜底)
```

- **单文件内联**:MCP Apps 的 UI 资源默认 CSP 禁止一切外部资源,`lib/ui-bundle.mjs` 把
  入口页的 1 个样式表与全部脚本收成惰性块,存档就绪后按原顺序注入执行。
- **存储垫片**:沙箱 iframe 没有可靠持久存储,`fw-host.js` 把 `localStorage` 换成内存垫片——
  游戏代码零改动;写入经节流批量提交给 `tools/call`,版本冲突回 `STALE` 由面板叠加重写。
- **模拟在本地**:经济结算全部在浏览器内引擎跑完,服务端只管开局/读档/存档——AI 不碰账本。

## 开发与测试

零依赖、零构建(Node ≥ 22):

```sh
npm test          # 测试守卫(清单自洽 / 协议行为 / 存档语义 / 打包安全)
npm run dev       # 模拟宿主:http://127.0.0.1:8807/dev-host.html 真实浏览器联调
```

模拟宿主按规范实现了宿主侧协议(握手 / 读资源 / 工具授权 / 尺寸 / 全屏 / 代下载),
在真实浏览器里端到端联调,不需要启动 WorkBuddy。

## 许可与商标

- 桥接层(`mcp-app/` `lib/` `skills/` `test/` `.codebuddy-plugin/`):**MIT**,见 [LICENSE](./LICENSE)
- 游戏前端 `browser/`:**AGPL-3.0**,衍生自
  [tobeficv/founders-way](https://github.com/tobeficv/founders-way)(© Felipe Callejas),
  来源与改动清单见 [PROVENANCE.md](./PROVENANCE.md);AGPL 对应源即本仓库
- `browser/fw-three.min.js`:three.js,MIT
- **商标**:`Founder's Way` 及其角色 "Doc" 是 Felipe Callejas 的商标;按上游
  TRADEMARKS.md 政策("Forks must use a different name"),本插件以
  **Still in Business / 活过第一年** 之名发布

## 致谢

- [MCP Apps](https://modelcontextprotocol.io/extensions/apps/overview) —
  让 MCP 工具返回可交互 UI 的开放标准
- [founders-way](https://github.com/tobeficv/founders-way) — 游戏前端的上游
- [three.js](https://threejs.org/) — 3D 渲染