Skip to content
Closed
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
21 changes: 15 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,19 @@ jobs:
- name: Build Windows
run: |
pnpm run build
pnpm run plugin:official:bundle -- --target-platform win32 --target-arch ${{ matrix.arch }}
pnpm exec electron-builder --win --${{ matrix.arch }} --publish=never
env:
VITE_GITHUB_CLIENT_ID: ${{ secrets.DC_GITHUB_CLIENT_ID }}
VITE_GITHUB_CLIENT_SECRET: ${{ secrets.DC_GITHUB_CLIENT_SECRET }}
VITE_GITHUB_REDIRECT_URI: ${{ secrets.DC_GITHUB_REDIRECT_URI }}
VITE_PROVIDER_DB_URL: ${{ secrets.CDN_PROVIDER_DB_URL }}

- name: Verify bundled official plugins
shell: bash
run: |
pnpm run plugin:official:verify -- --target-platform win32 --target-arch ${{ matrix.arch }} --plugin-root dist/win-unpacked/resources/app.asar.unpacked/plugins

- name: Upload artifacts
uses: actions/upload-artifact@v6
with:
Expand Down Expand Up @@ -125,13 +131,19 @@ jobs:
- name: Build Linux
run: |
pnpm run build
pnpm run plugin:official:bundle -- --target-platform linux --target-arch ${{ matrix.arch }}
pnpm exec electron-builder --linux --${{ matrix.arch }} --publish=never
env:
VITE_GITHUB_CLIENT_ID: ${{ secrets.DC_GITHUB_CLIENT_ID }}
VITE_GITHUB_CLIENT_SECRET: ${{ secrets.DC_GITHUB_CLIENT_SECRET }}
VITE_GITHUB_REDIRECT_URI: ${{ secrets.DC_GITHUB_REDIRECT_URI }}
VITE_PROVIDER_DB_URL: ${{ secrets.CDN_PROVIDER_DB_URL }}

- name: Verify bundled official plugins
shell: bash
run: |
pnpm run plugin:official:verify -- --target-platform linux --target-arch ${{ matrix.arch }} --plugin-root dist/linux-unpacked/resources/app.asar.unpacked/plugins

- name: Upload artifacts
uses: actions/upload-artifact@v6
with:
Expand Down Expand Up @@ -188,7 +200,7 @@ jobs:
- name: Build Mac
run: |
pnpm run build
pnpm run plugin:cua:bundle:mac:${{ matrix.arch }}
pnpm run plugin:official:bundle -- --target-platform darwin --target-arch ${{ matrix.arch }}
pnpm exec electron-builder --mac --${{ matrix.arch }} --publish=never
env:
CSC_LINK: ${{ secrets.DEEPCHAT_CSC_LINK }}
Expand All @@ -203,19 +215,16 @@ jobs:
NODE_OPTIONS: '--max-old-space-size=4096'
VITE_PROVIDER_DB_URL: ${{ secrets.CDN_PROVIDER_DB_URL }}

- name: Verify bundled CUA plugin
- name: Verify bundled official plugins
shell: bash
env:
TARGET_ARCH: ${{ matrix.arch }}
run: |
VERSION="$(node -p "require('./package.json').version")"
APP_DIR="dist/mac/DeepChat.app"
if [ "$TARGET_ARCH" = "arm64" ]; then
APP_DIR="dist/mac-arm64/DeepChat.app"
fi
PLUGIN="${APP_DIR}/Contents/Resources/app.asar.unpacked/plugins/deepchat-plugin-cua-${VERSION}-darwin-${TARGET_ARCH}.dcplugin"
test -f "$PLUGIN"
ls -lh "$PLUGIN"
pnpm run plugin:official:verify -- --target-platform darwin --target-arch "$TARGET_ARCH" --plugin-root "${APP_DIR}/Contents/Resources/app.asar.unpacked/plugins"

- name: Upload artifacts
uses: actions/upload-artifact@v6
Expand Down
21 changes: 15 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ jobs:
- name: Build Windows
run: |
pnpm run build
pnpm run plugin:official:bundle -- --target-platform win32 --target-arch ${{ matrix.arch }}
pnpm exec electron-builder --win --${{ matrix.arch }} --publish=never
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -173,6 +174,11 @@ jobs:
VITE_GITHUB_REDIRECT_URI: ${{ secrets.DC_GITHUB_REDIRECT_URI }}
VITE_PROVIDER_DB_URL: ${{ secrets.CDN_PROVIDER_DB_URL }}

- name: Verify bundled official plugins
shell: bash
run: |
pnpm run plugin:official:verify -- --target-platform win32 --target-arch ${{ matrix.arch }} --plugin-root dist/win-unpacked/resources/app.asar.unpacked/plugins

- name: Upload artifacts
uses: actions/upload-artifact@v6
with:
Expand Down Expand Up @@ -221,6 +227,7 @@ jobs:
- name: Build Linux
run: |
pnpm run build
pnpm run plugin:official:bundle -- --target-platform linux --target-arch ${{ matrix.arch }}
pnpm exec electron-builder --linux --${{ matrix.arch }} --publish=never
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -229,6 +236,11 @@ jobs:
VITE_GITHUB_REDIRECT_URI: ${{ secrets.DC_GITHUB_REDIRECT_URI }}
VITE_PROVIDER_DB_URL: ${{ secrets.CDN_PROVIDER_DB_URL }}

- name: Verify bundled official plugins
shell: bash
run: |
pnpm run plugin:official:verify -- --target-platform linux --target-arch ${{ matrix.arch }} --plugin-root dist/linux-unpacked/resources/app.asar.unpacked/plugins

- name: Upload artifacts
uses: actions/upload-artifact@v6
with:
Expand Down Expand Up @@ -288,7 +300,7 @@ jobs:
- name: Build Mac
run: |
pnpm run build
pnpm run plugin:cua:bundle:mac:${{ matrix.arch }}
pnpm run plugin:official:bundle -- --target-platform darwin --target-arch ${{ matrix.arch }}
pnpm exec electron-builder --mac --${{ matrix.arch }} --publish=never
env:
CSC_LINK: ${{ secrets.DEEPCHAT_CSC_LINK }}
Expand All @@ -304,19 +316,16 @@ jobs:
NODE_OPTIONS: '--max-old-space-size=4096'
VITE_PROVIDER_DB_URL: ${{ secrets.CDN_PROVIDER_DB_URL }}

- name: Verify bundled CUA plugin
- name: Verify bundled official plugins
shell: bash
env:
TARGET_ARCH: ${{ matrix.arch }}
run: |
VERSION="$(node -p "require('./package.json').version")"
APP_DIR="dist/mac/DeepChat.app"
if [ "$TARGET_ARCH" = "arm64" ]; then
APP_DIR="dist/mac-arm64/DeepChat.app"
fi
PLUGIN="${APP_DIR}/Contents/Resources/app.asar.unpacked/plugins/deepchat-plugin-cua-${VERSION}-darwin-${TARGET_ARCH}.dcplugin"
test -f "$PLUGIN"
ls -lh "$PLUGIN"
pnpm run plugin:official:verify -- --target-platform darwin --target-arch "$TARGET_ARCH" --plugin-root "${APP_DIR}/Contents/Resources/app.asar.unpacked/plugins"

- name: Upload artifacts
uses: actions/upload-artifact@v6
Expand Down
52 changes: 46 additions & 6 deletions docs/guides/plugin-packaging.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,28 @@ Official packages keep DeepChat release asset URLs in their manifest metadata:
https://github.com/ThinkInAIXYZ/deepchat/releases/download/v<version>/<asset-name>.dcplugin
```

## Official Plugin Artifacts

DeepChat bundles official plugins from `build/bundled-plugins/`. The official plugin script scans
`plugins/*/plugin.json`, selects manifests with `source.type: deepchat-official`, and packages the
plugins supported by the target platform:

- Feishu/Lark on `darwin`, `linux`, and `win32`.
- CUA on `darwin` only.

Feishu packages are platform and architecture specific:

```text
deepchat-plugin-feishu-<version>-darwin-arm64.dcplugin
deepchat-plugin-feishu-<version>-darwin-x64.dcplugin
deepchat-plugin-feishu-<version>-linux-x64.dcplugin
deepchat-plugin-feishu-<version>-win32-x64.dcplugin
```

Development startup runs the official plugin ensure step before Electron starts. The ensure step
creates only missing expected artifacts; use the clean bundle command when plugin sources changed
without a version bump.

## CUA Plugin Artifacts

The CUA plugin ships one macOS helper app per CPU architecture. The bundled package filename
Expand Down Expand Up @@ -73,8 +95,20 @@ pnpm run plugin:cua:package:mac:x64
Build the package that will be embedded into the macOS app:

```bash
pnpm run plugin:cua:bundle:mac:arm64
pnpm run plugin:cua:bundle:mac:x64
pnpm run plugin:official:bundle -- --target-platform darwin --target-arch arm64
pnpm run plugin:official:bundle -- --target-platform darwin --target-arch x64
```

Build package artifacts for one official plugin:

```bash
pnpm run plugin:official:package -- --plugin feishu --target-platform linux --target-arch x64
```

Refresh all bundled official plugins for the current platform and architecture:

```bash
pnpm run plugin:official:bundle
```

Validate explicit macOS architectures after their helper runtimes have been staged:
Expand All @@ -98,15 +132,17 @@ build/bundled-plugins/

## CI And Release

The macOS build matrix in `.github/workflows/build.yml` builds the matching CUA plugin bundle before
The build matrix in `.github/workflows/build.yml` builds the matching official plugin bundle before
running `electron-builder`. Electron Builder embeds it into:

```text
DeepChat.app/Contents/Resources/app.asar.unpacked/plugins/
resources/app.asar.unpacked/plugins/
```

Each matrix job verifies the expected bundled `.dcplugin` exists inside the app before uploading
artifacts.
Each matrix job verifies the expected bundled `.dcplugin` files exist inside the app before
uploading artifacts. The workflow calls the generic official plugin verifier once per platform; the
script decides which plugin artifacts are expected from the manifests, so adding a normal official
plugin does not require a new CI verification step.

The release workflow repeats the same bundled package step. The final release uploads app artifacts
only; `.dcplugin` files are not published as separate GitHub Release assets.
Expand All @@ -116,4 +152,8 @@ Expected embedded files:
```text
app.asar.unpacked/plugins/deepchat-plugin-cua-<version>-darwin-x64.dcplugin
app.asar.unpacked/plugins/deepchat-plugin-cua-<version>-darwin-arm64.dcplugin
app.asar.unpacked/plugins/deepchat-plugin-feishu-<version>-darwin-x64.dcplugin
app.asar.unpacked/plugins/deepchat-plugin-feishu-<version>-darwin-arm64.dcplugin
app.asar.unpacked/plugins/deepchat-plugin-feishu-<version>-linux-x64.dcplugin
app.asar.unpacked/plugins/deepchat-plugin-feishu-<version>-win32-x64.dcplugin
```
29 changes: 29 additions & 0 deletions docs/issues/feishu-plugin-bundling/plan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Feishu Plugin Bundling Plan

## Approach

- Add an official-plugin ensure script that scans official plugin manifests, computes expected
artifact names, and packages only missing files.
- Wire the ensure script into dev startup scripts so fresh clones get Feishu automatically.
- Add explicit Feishu package/bundle commands plus aggregate official bundle commands for build and
CI.
- Move bundled plugin resources into shared Electron Builder resources so every platform embeds
`.dcplugin` files.
- Update CI/release verification to call one generic official-plugin verifier per platform so the
script, not workflow YAML, decides which plugin artifacts are required.

## Compatibility

- Existing installed plugin configuration stays under user data and is preserved by the current
plugin installer refresh logic.
- Existing CUA packaging commands continue to work, but aggregate official bundle scripts own the
clean step before multi-plugin bundling.
- Developers can force stale package refresh with the clean/rebundle script.

## Tests

- Add package/config/workflow assertions proving dev scripts run the ensure step and platform
builds use official plugin bundling.
- Add a main-process regression covering packaged Feishu discovery and activation from
`build/bundled-plugins`.
- Validate Feishu package metadata for all supported platforms.
35 changes: 35 additions & 0 deletions docs/issues/feishu-plugin-bundling/spec.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Feishu Plugin Bundling

## User Story

As a user starting a fresh DeepChat checkout or installing a packaged app, I need the Feishu/Lark
official plugin to appear and enable reliably so I can use its settings, MCP tools, and skill
guidance without manually packaging plugin assets.

## Acceptance Criteria

- Fresh development startup packages the expected official plugin artifacts into
`build/bundled-plugins` before Electron starts.
- Development startup only packages a plugin artifact when the exact expected `.dcplugin` file is
missing.
- Feishu is bundled for `darwin`, `linux`, and `win32` using the current app version, target
platform, and target architecture.
- CUA remains bundled only for macOS and continues to build its runtime before packaging.
- Packaged apps on Windows, Linux, and macOS embed Feishu under
`app.asar.unpacked/plugins`.
- Enabling Feishu still registers its settings contribution, `feishu-tools` MCP server, and plugin
skill.

## Non-goals

- Rebuild existing dev plugin packages based on timestamps, hashes, or source changes.
- Change Feishu MCP behavior, settings UI, credential storage, or tool approval defaults.
- Publish standalone `.dcplugin` files as release assets.

## Constraints

- Keep official plugin packages trusted by using the existing `scripts/package-plugin.mjs`
manifest hydration and checksums.
- Preserve the manual clean/rebundle path for stale local plugin packages.
- Do not move auto-packaging into `PluginPresenter`; dev packaging must happen before Electron
startup.
9 changes: 9 additions & 0 deletions docs/issues/feishu-plugin-bundling/tasks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Feishu Plugin Bundling Tasks

- [x] Add official plugin ensure script.
- [x] Add Feishu and aggregate official plugin package scripts.
- [x] Wire dev startup scripts to ensure missing plugin packages.
- [x] Bundle plugin resources on every Electron Builder target.
- [x] Update build and release workflows with bundling and Feishu verification.
- [x] Add plugin presenter regression coverage and source assertions.
- [x] Run packaging validation and focused tests.
7 changes: 3 additions & 4 deletions electron-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ extraResources:
- from: ./resources/skills/
to: app.asar.unpacked/resources/skills
filter: ['**/*']
- from: ./build/bundled-plugins/
to: app.asar.unpacked/plugins
filter: ['**/*.dcplugin']
electronLanguages:
- zh-CN
- zh-TW
Expand Down Expand Up @@ -78,10 +81,6 @@ nsis:
afterSign: scripts/notarize.js
afterPack: scripts/afterPack.js
mac:
extraResources:
- from: ./build/bundled-plugins/
to: app.asar.unpacked/plugins
filter: ['**/*.dcplugin']
entitlementsInherit: build/entitlements.mac.plist
extendInfo:
- NSCameraUsageDescription: Application requests access to the device's camera.
Expand Down
37 changes: 19 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,22 @@
"typecheck:web": "vue-tsgo --project tsconfig.app.tsgo.json",
"typecheck": "pnpm run typecheck:node && pnpm run typecheck:web",
"start": "electron-vite preview",
"dev": "electron-vite dev --watch",
"dev:trace": "cross-env DEEPCHAT_VUE_DEVTOOLS_OVERLAY=0 electron-vite dev --watch",
"dev:inspect": "electron-vite dev --watch --inspect=9229",
"dev:linux": "electron-vite dev --watch --noSandbox",
"dev": "pnpm run plugin:official:ensure && electron-vite dev --watch",
"dev:trace": "pnpm run plugin:official:ensure && cross-env DEEPCHAT_VUE_DEVTOOLS_OVERLAY=0 electron-vite dev --watch",
"dev:inspect": "pnpm run plugin:official:ensure && electron-vite dev --watch --inspect=9229",
"dev:linux": "pnpm run plugin:official:ensure && electron-vite dev --watch --noSandbox",
"build": "pnpm run typecheck && electron-vite build",
"release:ff": "node scripts/release-fast-forward.mjs",
"postinstall": "electron-builder install-app-deps && simple-git-hooks",
"build:unpack": "pnpm run build && electron-builder --dir",
"build:win": "pnpm run build && electron-builder --win",
"build:win:x64": "pnpm run build && electron-builder --win --x64",
"build:win:arm64": "pnpm run build && electron-builder --win --arm64",
"plugin:cua:bundle:clean": "node -e \"require('fs').rmSync('build/bundled-plugins',{recursive:true,force:true})\"",
"plugin:cua:bundle": "pnpm run plugin:cua:bundle:clean && pnpm run plugin:cua:build && node scripts/package-plugin.mjs --release-version-from-root --target-platform darwin --out build/bundled-plugins plugins/cua",
"plugin:cua:bundle:mac:arm64": "pnpm run plugin:cua:bundle:clean && pnpm run plugin:cua:build:mac:arm64 && node scripts/package-plugin.mjs --release-version-from-root --target-platform darwin --target-arch arm64 --out build/bundled-plugins plugins/cua",
"plugin:cua:bundle:mac:x64": "pnpm run plugin:cua:bundle:clean && pnpm run plugin:cua:build:mac:x64 && node scripts/package-plugin.mjs --release-version-from-root --target-platform darwin --target-arch x64 --out build/bundled-plugins plugins/cua",
"build:unpack": "pnpm run build && pnpm run plugin:official:bundle && electron-builder --dir",
"build:win": "pnpm run build && pnpm run plugin:official:bundle -- --target-platform win32 --target-arch x64 && electron-builder --win",
"build:win:x64": "pnpm run build && pnpm run plugin:official:bundle -- --target-platform win32 --target-arch x64 && electron-builder --win --x64",
"build:win:arm64": "pnpm run build && pnpm run plugin:official:bundle -- --target-platform win32 --target-arch arm64 && electron-builder --win --arm64",
"plugin:official:ensure": "node scripts/ensure-official-plugins.mjs",
"plugin:official:bundle:clean": "node scripts/ensure-official-plugins.mjs --clean-only",
"plugin:official:bundle": "node scripts/ensure-official-plugins.mjs --clean",
"plugin:official:package": "node scripts/ensure-official-plugins.mjs --out dist/plugins",
"plugin:official:verify": "node scripts/ensure-official-plugins.mjs --verify",
"plugin:cua:build": "node scripts/build-cua-plugin-runtime.mjs",
"plugin:cua:build:mac:arm64": "node scripts/build-cua-plugin-runtime.mjs --arch arm64",
"plugin:cua:build:mac:x64": "node scripts/build-cua-plugin-runtime.mjs --arch x64",
Expand All @@ -56,12 +57,12 @@
"plugin:cua:package:mac:arm64": "pnpm run plugin:cua:build:mac:arm64 && node scripts/package-plugin.mjs --release-version-from-root --target-platform darwin --target-arch arm64 plugins/cua",
"plugin:cua:package:mac:x64": "pnpm run plugin:cua:build:mac:x64 && node scripts/package-plugin.mjs --release-version-from-root --target-platform darwin --target-arch x64 plugins/cua",
"install:sharp": "node scripts/install-sharp-for-platform.js",
"build:mac": "pnpm run build && pnpm run plugin:cua:bundle && electron-builder --mac",
"build:mac:arm64": "pnpm run build && pnpm run plugin:cua:bundle:mac:arm64 && electron-builder --mac --arm64",
"build:mac:x64": "pnpm run build && pnpm run plugin:cua:bundle:mac:x64 && electron-builder --mac --x64",
"build:linux": "pnpm run build && electron-builder --linux",
"build:linux:x64": "pnpm run build && electron-builder --linux --x64",
"build:linux:arm64": "pnpm run build && electron-builder --linux --arm64",
"build:mac": "pnpm run build && pnpm run plugin:official:bundle && electron-builder --mac",
"build:mac:arm64": "pnpm run build && pnpm run plugin:official:bundle -- --target-platform darwin --target-arch arm64 && electron-builder --mac --arm64",
"build:mac:x64": "pnpm run build && pnpm run plugin:official:bundle -- --target-platform darwin --target-arch x64 && electron-builder --mac --x64",
"build:linux": "pnpm run build && pnpm run plugin:official:bundle -- --target-platform linux --target-arch x64 && electron-builder --linux",
"build:linux:x64": "pnpm run build && pnpm run plugin:official:bundle -- --target-platform linux --target-arch x64 && electron-builder --linux --x64",
"build:linux:arm64": "pnpm run build && pnpm run plugin:official:bundle -- --target-platform linux --target-arch arm64 && electron-builder --linux --arm64",
"afterSign": "scripts/notarize.js",
"installRuntime": "npx -y tiny-runtime-injector --type uv --dir ./runtime/uv --runtime-version 0.9.18 && npx -y tiny-runtime-injector --type node --dir ./runtime/node && npx -y tiny-runtime-injector --type ripgrep --dir ./runtime/ripgrep && npx -y tiny-runtime-injector --type rtk --dir ./runtime/rtk",
"installRuntime:win:x64": "npx -y tiny-runtime-injector --type uv --dir ./runtime/uv --runtime-version 0.9.18 -a x64 -p win32 && npx -y tiny-runtime-injector --type node --dir ./runtime/node -a x64 -p win32 && npx -y tiny-runtime-injector --type ripgrep --dir ./runtime/ripgrep -a x64 -p win32 && npx -y tiny-runtime-injector --type rtk --dir ./runtime/rtk -a x64 -p win32",
Expand Down
Loading