Skip to content

feat: add forge-hub sync — lightweight runtime sync#25

Open
AmberCXX wants to merge 4 commits into
LinekForge:mainfrom
AmberCXX:feat/sync-command
Open

feat: add forge-hub sync — lightweight runtime sync#25
AmberCXX wants to merge 4 commits into
LinekForge:mainfrom
AmberCXX:feat/sync-command

Conversation

@AmberCXX
Copy link
Copy Markdown
Contributor

@AmberCXX AmberCXX commented May 8, 2026

Summary

  • Added forge-hub sync command: only syncs hub-server source files (including channels/) from source to runtime, then restarts Hub
  • Skips: dependency install, dashboard build, plist write, MCP registration
  • Updated 维护地图.md: maintenance principle changed to recommend forge-hub sync instead of full forge-hub install after git pull

Motivation

After git pull, ~/.forge-hub/ runtime files don't auto-update. The previous workaround was forge-hub install, which redoes everything (bun install × 3, dashboard build, plist, MCP reg, etc.) — slow and unnecessary.

This caused a real outage: hub.isAllowed is not a function in feishu channel, because source channel-loader.ts added isAllowed() to HubAPI but runtime wasn't synced.

Changes

File Change
cli.ts Added syncCmd() + wired into dispatch + help text
维护地图.md Updated maintenance principle: forge-hub sync after source update

Self-test

$ bun cli.ts doctor
✅ All checks passed

$ bun cli.ts sync
🔄 Forge Hub sync
✓ hub-server runtime synced(channels/ 已更新)
✅ Sync 完成

🤖 Generated with Claude Code

Xuxian Chen and others added 3 commits May 8, 2026 08:08
chatId.startsWith("oc_") was duplicated at replyTo; now uses the
isGroupMessage variable (already fixed to use chat_type === "group").

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
git pull 后源码更新,但 ~/.forge-hub/ 运行时文件不会自动同步,
导致通道插件调用新 HubAPI 方法(如 isAllowed)时报错。
sync 命令只同步 hub-server 源文件 + 重启 Hub,跳过 deps install /
dashboard build / plist / MCP 注册,比 install 快得多。

维护地图.md 同步更新:源码更新后跑 forge-hub sync 对齐运行时。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@LinekForge
Copy link
Copy Markdown
Owner

Thanks for this — the motivation is solid and the implementation is clean. forge-hub sync solves a real pain point (the hub.isAllowed is not a function outage you hit is a perfect example).

One change needed before we can merge:

Missing cleanDirContents(CHANNELS_RUNTIME) before copy

installCmd (L79) clears the channels runtime directory before copying:

cleanDirContents(CHANNELS_RUNTIME);
cpDir(path.join(serverSrc, "channels"), CHANNELS_RUNTIME, [".ts"]);

syncCmd skips the clean step and goes straight to cpDir. This means if a channel file was deleted or renamed in source (e.g. we remove a deprecated channel plugin), the old .ts file remains in ~/.forge-hub/channels/ and channel-loader.ts will continue to load it.

In normal operation this might just cause a harmless "plugin has no send" warning, but in edge cases (renamed exports, conflicting registrations) it could break channel loading entirely.

Fix: Add cleanDirContents(CHANNELS_RUNTIME); before the channels cpDir call:

cleanDirContents(CHANNELS_RUNTIME);
cpDir(path.join(serverSrc, "channels"), CHANNELS_RUNTIME, [".ts"]);

cleanDirContents is already imported and used in installCmd, so no new dependencies needed.

Everything else looks good — stagePackageRuntime reuse, chmod 700, launchctl kickstart with bootout fallback, and the 维护地图.md update are all solid.

— Forge (maintainer)

LinekForge added a commit that referenced this pull request May 8, 2026
Co-authored-by: Forge <270260515+ForgeLinek@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Per review feedback on PR LinekForge#25: syncCmd missed the cleanDirContents step
before cpDir for channels. If a channel file is deleted or renamed in
source, the old .ts file would otherwise remain in ~/.forge-hub/channels/
and channel-loader would keep loading it (harmless warning at best,
broken channel registration at worst).

Mirrors installCmd behavior at L79-82.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants