✨ 打包变量屏蔽正式版 agent 入口并移除 debugger 权限(bump 1.4.0)#1518
Merged
Conversation
- scripts/build-config.js:isAgentEnabled(dev/beta 启用) + applyAgentManifest(正式版剥离 debugger) - rspack.config.ts / pack.js:注入 process.env.SC_ENABLE_AGENT,按版本处理 manifest 权限 - const.ts 暴露 EnableAgent,门控侧边栏 agent 菜单与 /agent/* 路由 - MainLayout/install 安装页屏蔽 Skill ZIP、SkillScript、.cat.md 等安装入口 - service_worker/script.ts 屏蔽 .skill.js/.cat.md 的 DNR/webNavigation 拦截与识别 - agent 运行时(CAT_*/AgentService)保持不变;vitest 默认 SC_ENABLE_AGENT=true
- build-config 新增 resolveAgentEnabled:env 覆盖优先,否则按版本派生 - rspack.config.ts / pack.js 改用 resolveAgentEnabled - test.yaml e2e 构建设 SC_ENABLE_AGENT=true,使正式版下 agent 用例仍可运行 - 正式版默认仍屏蔽 agent(无 env 时不变)
Contributor
There was a problem hiding this comment.
Pull request overview
该 PR 通过引入构建期开关 SC_ENABLE_AGENT(由版本号 dev/beta 自动派生,并支持环境变量覆盖),在正式版中屏蔽 agent 相关入口/安装路径,并在构建产物层面移除仅 agent 使用的 debugger 权限,同时将版本号 bump 至 1.4.0,以契合 ScriptCat 的多进程扩展架构下对不同发布渠道的能力分层。
Changes:
- 新增
EnableAgent常量并在 UI/安装页/SW 安装拦截链路中进行门控,正式版不再暴露/agent/*与 Skill 安装入口。 - 构建与打包链路统一应用
applyAgentManifest():当 agent 禁用时从 manifest 的permissions中剥离debugger,并注入process.env.SC_ENABLE_AGENT以便 SWC/构建器做常量折叠。 - 新增
scripts/build-config.*及其 Vitest BDD 单测,并在 CI e2e 构建阶段通过SC_ENABLE_AGENT=true强制开启覆盖用例。
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| vitest.config.ts | 为单测环境注入 SC_ENABLE_AGENT=true,避免门控影响现有测试运行路径。 |
| src/pages/install/utils.ts | 拉取脚本内容时仅在启用 agent 时识别 SkillScript 元数据。 |
| src/pages/install/hooks.tsx | 安装页对 ?skill=、.cat.md URL 等 Skill 安装入口增加 EnableAgent 门控。 |
| src/pages/components/layout/Sider.tsx | 侧边栏与路由层面对 /agent/* 入口增加门控(正式版隐藏)。 |
| src/pages/components/layout/MainLayout.tsx | 拖拽 ZIP/SkillScript 的安装入口在 UI 层增加门控。 |
| src/manifest.json | 将源 manifest 版本号更新为 1.4.0。 |
| src/app/service/service_worker/script.ts | SW 的 webNavigation 过滤与 DNR 规则对 .skill.js/.cat.md 增加门控,正式版不拦截 Skill 安装入口。 |
| src/app/const.ts | 新增 EnableAgent:由 process.env.SC_ENABLE_AGENT 注入并作为全局门控常量使用。 |
| scripts/pack.js | pack 阶段与构建逻辑对齐:解析 agent 开关并对打包用 manifest 应用权限剥离。 |
| scripts/build-config.test.js | 新增构建开关与 manifest 变换逻辑的 BDD 单测覆盖。 |
| scripts/build-config.js | 新增构建配置工具:派生/覆盖 agent 开关与 manifest 变换。 |
| rspack.config.ts | 注入 process.env.SC_ENABLE_AGENT 并在复制 manifest 时应用 applyAgentManifest()。 |
| package.json | 版本号 bump 至 1.4.0(正式版)。 |
| .github/workflows/test.yaml | e2e 构建阶段强制 SC_ENABLE_AGENT=true,确保覆盖 agent 用例。 |
Comment on lines
283
to
285
| <Route path="/tools" element={<Tools />} /> | ||
| <Route path="/agent/*" element={<Agent />} /> | ||
| {EnableAgent && <Route path="/agent/*" element={<Agent />} />} | ||
| <Route path="/setting" element={<Setting />} /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist / 检查清单
Description / 描述
新增打包变量
SC_ENABLE_AGENT,由版本号自动派生:开发版 / beta(版本含-)启用 agent,正式版屏蔽。同时将版本号 bump 到1.4.0(正式版)。构建 / Build
scripts/build-config.js:isAgentEnabled({isDev,isBeta})(dev/beta 启用)+applyAgentManifest()(正式版从permissions剥离debugger,其余权限不变,不改src/manifest.json源文件)。附带 7 个 BDD 单测。rspack.config.ts/scripts/pack.js:注入process.env.SC_ENABLE_AGENT定义;对dist/ext与 zip/crx 的 manifest 套用同一逻辑。入口屏蔽(正式版)/ Gated entries (stable)
/agent/*路由(Sider.tsx)MainLayout.tsx);安装页?skill=、.cat.mdURL、本地 / URL SkillScript(install/hooks.tsx、install/utils.ts).skill.js/.cat.md的 DNR 重定向、webNavigation 过滤、openInstallPageByUrl的 skill 识别(service_worker/script.ts)保持不变 / Unchanged:agent 运行时(
CAT_*GM API、SWAgentService)仍注册;仅正式版构建移除debugger权限。验证 / Verification
debugger、SW bundle 中.skill.js/.cat.md拦截规则被 swc 完全消除;const.ts编译出EnableAgent=!1debugger、拦截规则齐全;EnableAgent=!0tsc0 错、eslint0 错、单测 1994 passedScreenshots / 截图
N/A(构建 / 入口门控改动,无 UI 视觉变化)