Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/native-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Native Windows WorkBuddy (pinned, synthetic)
on:
push:
paths:
- 'src/**'
- 'plugins/**'
- 'scripts/**'
- 'ci/**'
- '.github/workflows/native-windows.yml'
pull_request:
paths:
- 'src/**'
- 'plugins/**'
- 'scripts/**'
- 'ci/**'
- '.github/workflows/native-windows.yml'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true
permissions:
contents: read
jobs:
native:
runs-on: windows-2025
timeout-minutes: 20
env:
PYTHONUTF8: '1'
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Build the native plugin
run: python scripts/build_plugins.py
- name: Windows unit and actual PowerShell parser gates
working-directory: src/plugin
run: python -m unittest discover -s tests -v
- name: Download verified official artifact and statically extract (never run installer)
shell: pwsh
run: ./scripts/prepare_windows_runtime.ps1 -Output (Join-Path $env:RUNNER_TEMP 'wb-pinned-runtime')
- name: Actual native CLI using only a synthetic isolated profile
shell: pwsh
run: python scripts/native_smoke.py --node $env:WORKBUDDY_TEST_NODE --cli $env:WORKBUDDY_TEST_CLI --output (Join-Path $env:RUNNER_TEMP 'wb-native-smoke')
- name: Preserve synthetic diagnostics, never vendor binaries
if: always()
uses: actions/upload-artifact@v4
with:
name: native-windows-synthetic-diagnostics
path: |
${{ runner.temp }}/wb-native-smoke/result.json
${{ runner.temp }}/wb-native-smoke/logs/*.txt
${{ runner.temp }}/wb-pinned-runtime/runtime.json
if-no-files-found: ignore
33 changes: 33 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Synthetic tests
on: [push, pull_request, workflow_dispatch]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true
permissions:
contents: read
jobs:
test:
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest]
python: ['3.10', '3.12']
runs-on: ${{ matrix.os }}
env:
PYTHONUTF8: '1'
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Build native plugin
run: python scripts/build_plugins.py
- name: Compile
run: python -m compileall -q src plugins
- name: Synthetic regression tests (no WorkBuddy binary or API calls)
working-directory: src/plugin
run: python -m unittest discover -s tests -v
- name: Check plugin packaging
run: python -m unittest discover -s tests -v
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
__pycache__/
*.py[cod]
.venv/
.env
.env.*
*.db
*.db-*
*.jsonl
.conversation-tools.json
.codebuddy/
.workbuddy/
*operations/
runtime/
source_reference/
*.zip
.DS_Store
Thumbs.db
13 changes: 13 additions & 0 deletions .workbuddy-plugin/marketplace.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "workbuddy-plugins",
"owner": {
"name": "WorkBuddy Conversation Tools"
},
"plugins": [
{
"name": "workbuddy-tools",
"source": "./plugins/workbuddy-tools",
"version": "0.2.0"
}
]
}
113 changes: 111 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,111 @@
# workbuddy-plugins
Combined conversation branching and style plugin for WorkBuddy on Windows.
# WorkBuddy 会话分支/思考风格 seed 原生插件

一个原生插件,同时提供会话分支和显式最小思考风格 seed。**Windows 优先,Linux 回归**;不是独立 GUI,不是 Git 分支工具。

安装名 `workbuddy-tools`,统一命名空间 `/workbuddy-tools:`。代码位于一个仓库,可公开发布;不包含私人 seed 或账号历史。

当前版本 `0.2.0`。已在 GitHub 云端 Windows Server 2025 上使用官方 WorkBuddy 5.9.3.42398134 / CLI 2.165.0 完成真实原生回归;Windows/Linux × Python 3.10/3.12 合成测试也全部通过。覆盖原生 CLI、hook、会话持久化和本地登记,不冒充桌面 GUI 或真实模型效果验证。详细证据见 [VERIFICATION.md](VERIFICATION.md)。

## 安装前检查

- Windows:WorkBuddy 5.9.3,bundled CLI package 2.165.0;已完成固定版本真实原生云端回归;未知 CLI 版本或数据库结构会拒绝写入。
- Linux:WorkBuddy 5.6.2.40046327 / CLI 2.147.0,最终合并版本的原生分支、hook、seed、DB 及丢输出 fail-closed 压力回归均已通过。
- Python **3.10+**,Windows 还必须有 **PowerShell 7 `pwsh`**,并可被 WorkBuddy 子进程 PATH 找到。不会安装软件或更改执行策略。
- 仅支持本地磁盘;拒绝 UNC、junction/reparse point、符号链接。Windows 新会话原子发布需要支持硬链接的文件系统(通常 NTFS);不宣称网络盘/FAT 支持。
- Node/CLI 使用你确认的官方安装文件或受信任的现有 Node;不从网络下载运行时。部分 Windows 安装把 bundled Node 留在 `resources/vendor/node.zip`,本工具不擅自解压或修改厂商安装。

```powershell
py -3 -X utf8 .\plugins\workbuddy-tools\scripts\discover.py
Get-Command pwsh
```

`discover.py` 只查标准安装路径;非标准安装可先设置 `$env:WORKBUDDY_INSTALL_DIR`。结果仅为候选,必须确认属于目标 WorkBuddy 安装。可以直接给脚本明确的 `--cli` 与 `--node`。

## Windows PowerShell 安装

将仓库放到固定目录,不要在安装后移动。下面变量改为你实际路径:

```powershell
$Repo = 'C:\Tools\workbuddy-plugins'
$Python = 'C:\Path\To\python.exe' # 3.10+
$Node = 'C:\Path\To\node.exe'
$Cli = 'C:\Path\To\WorkBuddy\resources\app.asar.unpacked\cli\bin\codebuddy'
$Project = 'C:\Projects\My Project'
$env:CODEBUDDY_CONFIG_DIR = Join-Path $HOME '.workbuddy'
$env:WORKBUDDY_CONFIG_DIR = $env:CODEBUDDY_CONFIG_DIR
$env:CODEBUDDY_FORCE_LITE_WB_BUNDLE = '1' # Windows pinned distribution ships lite-WB only
& $Node $Cli plugin validate $Repo
& $Node $Cli plugin marketplace add $Repo
& $Node $Cli plugin install 'workbuddy-tools@workbuddy-plugins'
& $Node $Cli plugin list --json
& $Python -X utf8 "$Repo\plugins\workbuddy-tools\scripts\manage.py" install --project $Project --cli $Cli --node $Node --hook-shell powershell
```

只需安装这一个插件。原生插件默认 hook 故意为空:宿主首次 prompt 存在异步加载竞态,因此确定性命令使用上述安装器注册的**项目级原生 UserPromptSubmit hook**。Windows 明确指定 `shell: powershell`,固定 argv 单引号转义;用户命令参数只从 stdin JSON 读取,从不拼进 shell。Linux 使用 `--hook-shell posix`,并设置 `CODEBUDDY_FORCE_HEADLESS_BUNDLE=1`(不要沿用 Windows lite-WB 变量)。

安装器保留其它 hooks/权限,首次备份 settings;插件使用唯一项目 router hook 按命名空间分发,避免宿主多 hook 结果聚合与快速退出丢 stdout 的问题。已处理命令无论成功或失败都使用原生退出码 2 阻断;shell 包装将解释器/脚本异常同样映射为 2,不依赖延时。普通 prompt 则无输出退出 0。共享 `.conversation-tools.json` 仅保存官方 CLI argv;不信任新工作区、不修改权限、账号、密钥或默认模型。

安装后重启会话或 `/reload-plugins`。先在实际 WorkBuddy 会话执行 `/workbuddy-tools:status`,必须看到本地适配器信息;若出现认证/模型回答或缺失 hook 结果,停止使用创建命令,检查实际宿主的 pwsh/Python PATH。shell 自身无法启动时,插件没有执行机会,宿主行为不在本工具控制内。用同一 Python 执行 `manage.py check --project $Project --hook-shell powershell` 检查插件。

## 使用

```text
/workbuddy-tools:points
/workbuddy-tools:branch {"at":"latest","title":"方案 B"}
/workbuddy-tools:branch {"at":"完整回复的小写 UUID","title":"从此处分支"}
/workbuddy-tools:style-new {"seed":"C:\\Templates\\we-need.json","title":"带 seed 的新会话"}
/workbuddy-tools:status
/workbuddy-tools:status
```

JSON Windows 路径反斜杠需写成 `\\`,也可以使用 `C:/Templates/we-need.json`。完成结果含新会话 UUID 与 `workbuddy://chat/<UUID>`,由你手动打开;GUI 跳转及列表刷新未验证。不自动向模型发 prompt。

`examples/minimal-seed.json` 与 `examples/we-need-demo.json` 在每个插件目录下,都是公开合成示例。后者是简短的 “We need” 规划摘要,不是私人思考记录。seed schema 1:1–2 组严格交替 user/assistant `{role,text}`;assistant 可带纯文本 `reasoning`。不允许 providerData、签名、旧环境、权限、凭证或任意历史结构。文件限 16 KiB,单条可见文字 2000 字、reasoning 4000 字。

已证明原生 JSONL 能保留 reasoning/rawContent;Linux 官方离线转换器在模型能力条件满足时能回填 reasoning_content。**没有调用真实模型验证效果,不保证 We need 措辞、固定风格、推理能力提升或原私人模板的等价效果**。默认关闭,只作用于显式创建的新会话,不切换模型。

## 安全与恢复

本工具从不写源历史/源 DB 行,只克隆并校验本次新目标。宿主自己可能追加 slash 命令与 hook 结果,因此不承诺整个源文件跨操作字节完全相等。未知 CLI 版本、schema、未闭合工具、子代理图或路径越界均拒绝写入。

官方 EOF fork 的选定边界不一定持久化;本工具核验克隆契约后,只原子修正新目标。操作回执保存 ID、摘要与状态,不存完整历史。DB insert-only 事务、幂等 UUID、提交前后摘要核验;不创建/迁移数据库。

```text
/workbuddy-tools:recover {"operation_id":"操作 UUID"}
/workbuddy-tools:recover {"operation_id":"操作 UUID"}
```

恢复只接受已准备摘要与归属一致的目标。来源/目标变化、未确定克隆或 schema 变化时保留诊断,不自动重克隆/删除。源桌面行变化可能导致登记恢复安全停止,需要人工核对。

## 卸载

```powershell
& $Python -X utf8 "$Repo\plugins\workbuddy-tools\scripts\manage.py" uninstall --project $Project --hook-shell powershell
& $Node $Cli plugin uninstall 'workbuddy-tools@workbuddy-plugins'
```

其它用户 hooks 保持不变。卸载依据持久安装归属删除自己的 hook,不删源/新会话、seed、回执或其它设置。不要移动安装目录后直接删除文件,先卸载原项目 hook。

## 构建与 CI

```text
python scripts/build_plugins.py
cd src/plugin
python -m unittest discover -s tests -v
cd ../..
python -m unittest discover -s tests -v
```

`src/plugin` 为共享实现与合成测试;`plugins/workbuddy-tools` 为原生插件产物;`.workbuddy-plugin/marketplace.json` 为原生 marketplace。GitHub Actions 在 Windows/Linux、Python 3.10/3.12 运行无 API 合成测试。CI 配置存在不等于远端 CI 已执行。

没有附加开源许可授权;公开可读不等于授权再分发,许可由所有者另行选择。发行物不含厂商二进制、私人历史、账户配置或原始私人项目引用文件。

## 可选真实宿主回归(不下载运行时)

```text
python scripts/native_smoke.py --node /absolute/node --cli /absolute/codebuddy --output /new/isolated/output
```

输出目录必须不存在。脚本仅新建合成 HOME/profile/workspace 和数据库,白名单环境不继承凭证;验证安装幂等、会话分支、reasoning EOF、归属卸载。普通 CI 不执行它;另外提供代码路径 push/PR 自动触发、也可手动执行的 `Native Windows WorkBuddy (pinned, synthetic)` workflow,固定官方安装包 SHA256,使用预装 7-Zip 静态提取而不运行安装器。实际宿主任务已通过;更新后仍应检查对应提交的 CI 结果。

官方 Windows 固定包证据见 `ci/workbuddy-windows-pin.json`;[官方更新元数据](https://www.workbuddy.cn/v2/update?platform=workbuddy-win32-x64-user) 与实际下载 SHA256 已核对。下载脚本不使用浮动 latest、不接受外部传入 URL、不携带账号密钥;完整验证范围见 [原生验证协议](docs/NATIVE_VERIFICATION.md)。
36 changes: 36 additions & 0 deletions VERIFICATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Verification — 2026-11-01

## Real Windows cloud result: PASS

Verified implementation commit: [`63c1b4e31f0818d59d5b411da0f750c912e5990b`](https://github.com/bartholo4/workbuddy-plugins/commit/63c1b4e31f0818d59d5b411da0f750c912e5990b).

- [Native Windows run 41301284752](https://github.com/bartholo4/workbuddy-plugins/actions/runs/41301284752): **success**, GitHub-hosted Windows Server 2025.
- [Windows/Linux × Python 3.10/3.12 matrix 41301284940](https://github.com/bartholo4/workbuddy-plugins/actions/runs/41301284940): **all four jobs successful**.
- Native diagnostic artifact `13081881016`, SHA256 `497d18185319d6d80ed451e47d64282299fdce25a3ac19e93410236c82332484` (retention limited by GitHub).

The Windows job downloaded official WorkBuddy **5.9.3.42398134**, verified pinned SHA256, statically extracted NSIS/app-64.7z/Node ZIP without executing the installer, and ran its real **CLI 2.165.0** with bundled **Node 22.22.2**. It selected the shipped **lite-WB** bundle; the separate Linux adapter selects its headless bundle.

Passed in the real Windows host:

- Native plugin validate, marketplace add/install/list, unified five-command namespace.
- Selected-boundary conversation branching; same workspace; source database row unchanged.
- Insert-only registration against the exact synthetic 40-column schema.
- Reasoning seed creation and native EOF resume/fork roundtrip; **API duration 0**.
- Five additional independent style creations.
- Entire hook stdout/stderr discarded: final shell exit **2** still blocks.
- Missing interpreter: shell guard still blocks rather than forwarding to a model.
- Owned uninstall and installation idempotence.

Unit gates cover 57 core cases plus 2 packaging cases. Windows actually executes cross-process file-lock and PowerShell parser tests, including spaces, quotes, metacharacters and non-ASCII arguments; external Python exits 1 and 2 both produce final PowerShell exit 2. Platform-inapplicable POSIX/symlink-privilege cases are explicitly skipped; a missing Windows `pwsh` fails, never silently skips.

## Linux regression: PASS

Real official Linux WorkBuddy **5.6.2.40046327 / CLI 2.147.0** completed the same combined-plugin native flow, five-repeat style stress, discarded-output guard, missing-interpreter guard and synthetic database checks. The shared-core Linux run passed 54 cases with 3 genuine Windows/PowerShell-specific skips; both packaging cases passed.

## Scope and remaining limitations

- Desktop GUI buttons, list refresh and `workbuddy://chat` navigation are **not tested or claimed**. Windows proof is the real native CLI/hook/storage path, not a visual GUI simulation.
- Live model effects are **not tested or promised**. No paid model call is part of these tests. Reasoning persistence is not a guarantee of intelligence, wording or provider behavior.
- All native tests use newly created synthetic HOME/profile/workspace and a credential-free environment. No existing user profile, account, source history, security setting or vendor installation was modified.
- The public repository does not bundle vendor executables, private history, original private source files or credentials.
- Source code changes after the linked commit must be revalidated. Version/verification-document promotion does not replace CI for its resulting commit.
12 changes: 12 additions & 0 deletions ci/workbuddy-windows-pin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"product": "WorkBuddy",
"platform": "workbuddy-win32-x64-user",
"version": "5.9.3.42398134",
"cli_version": "2.165.0",
"node_version": "22.22.2",
"metadata_url": "https://www.workbuddy.cn/v2/update?platform=workbuddy-win32-x64-user",
"url": "https://download.codebuddy.cn/workbuddy/saas/win32-x64-user/WorkBuddy-win32-x64-user-5.9.3.42398134-d4692421.exe",
"sha256": "b5edb52bd6c5b6c7296cf2fff697b019c86d11992a8a814c3010d611896852f9",
"format": "NSIS-3 Unicode; embedded $PLUGINSDIR/app-64.7z",
"verification": "Official update metadata and independent full artifact SHA256 matched; installer not executed."
}
Loading
Loading