Repository navigation
refactor(hosts): consolidate claude, kunluncode, and zcode packages under loopx/hosts - #9505
loopx-agent wants to merge 8 commits into
Conversation
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)
[P2] 保住既有 Claude 配置的升级路径。同一个隔离项目中,基线实际 /loopx status 和状态栏都退出 0。换装候选并运行默认更新后,项目配置还指向已移除的脚本,两条实际命令都退出 2。显式重装后均恢复退出 0。 保留兼容 launcher,或在正常更新中仅迁移可证明归属的已托管旧入口,保留用户设置。 源码
动机 / Motivation
把 Claude Code、KunlunCode 和 ZCode 的运行实现收拢到 loopx/hosts,同时保住已选择安装的宿主入口。 基线 Claude 的项目适配器把包内脚本绝对地址写到 /loopx 命令和可选状态栏。wheel 更新与项目的持久配置彼此独立。 既有 Claude Code 项目适配器用户,以及从 Python/Node、面板或命令入口使用 KunlunCode 和 ZCode 的用户。
旧地址退出后,既有项目不能查看状态,且使用可选状态栏的项目收到启动失败,直到显式重新配置。 两个完整 wheel 各自生成 Chat bundle。基线项目命令与状态栏实际退出 0。候选的新位置脚本经显式项目重装重新工作,两条退出 0,用户已有设置条目保持。 精确候选 145 项 Python 和 69 项 TypeScript 定向用例通过。配对 wheel 复验了已安装配置在普通更新的失败及显式重装恢复。 测试覆盖项目 scope、完整 wheel 与执行配置中的真实脚本。Claude 宿主 UI、宿主内 MCP 注册、KunlunCode/ZCode 本机宿主和远端 CI 未核验。 验收契约
改动思路 / Approach
该改动沿用 旧 wheel 项目安装器 → .claude 命令和设置 → 发行版升级默认 CLI → 真实状态命令及状态栏入口。这批变更迁移三种宿主资源和入口,继续用原配置写入器。Python 更新器的默认 facade 安装与 Claude 项目级 opt-in 安装各自运行。 wheel 去掉旧包后,默认 facade 刷新不刷新项目命令和状态栏。显式运行新安装器则把持久地址改到新目录。 保留现有包内稳定 launcher,或仅在所有权可证明时定向更新旧地址,复用原 scoped installer 的配置保留逻辑。
具体改动 / Changes
精确提交 581d7d1,本次对照目标 379b9ea。100 个文件,+268/−173。大部分是三种运行包、面板消费方、资源和文档路径迁移。
关键代码讲解
-
REPO_ROOT。脚本在新包路径下导入正确的共享依赖。原安装输出持久记录旧绝对路径。 源码 -
command_md。把当前包内的绝对脚本路径写入项目 /loopx 命令。 源码 -
hardening_block。显式 opt-in 时把当前包的状态栏入口记录进项目设置。 源码 -
install_slash_commands。默认更新后的 Claude facade 走主技能目录,既有项目级命令及状态栏由另一入口拥有。 源码 -
ZCode native CLI。迁移后的 ZCode 与 KunlunCode 宿主调用继续接入现有 native owners。 源码 -
persisted-claude-project-entrypoint(not_met)。既有项目显式安装的 /loopx 命令与可选状态栏在常规升级后继续启动,在保留用户配置的前提下迁移脚本地址。
对主干的风险 / Risks
在同一个隔离 venv 原位换装精确候选 wheel,按 Python 发行更新器路径执行真实默认 slash-commands --install。已安装的 Claude /loopx status 与可选状态栏命令保留旧绝对路径,实际启动均退出 2。 受影响的已安装项目显示无状态且命令不可启动。只验证新装无法覆盖持久旧地址。 在普通升级保持已安装 launcher 可执行,或准确识别并迁移已托管旧入口;保留用户设置。
语义与 CI 对齐
在同一个隔离 venv 原位换装精确候选 wheel,按 Python 发行更新器路径执行真实默认 slash-commands --install。已安装的 Claude /loopx status 与可选状态栏命令保留旧绝对路径,实际启动均退出 2。 在普通升级保持已安装 launcher 可执行,或准确识别并迁移已托管旧入口;保留用户设置。
我的整体评价 / Verdict
REQUEST_CHANGES。 请先恢复持久 Claude 配置的普通升级路径。候选显式重装的成功结果界定了修复范围。 让已安装的 Claude 会话在运行包重构后维持状态读取能力。
English verdict: REQUEST_CHANGES at 581d7d1. Request changes. The default wheel upgrade leaves existing Claude /loopx status and status-line commands pointing to removed scripts. Reinstalling the scoped adapter restores both.
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)
[P2] 迁移旧脚本时保留自定义 Claude hook 的调用方式。给已安装的 Claude PreToolUse 新增一个合法的项目级自定义调用。它使用 env 包装旧 LoopX 脚本,并设置独立 timeout。默认升级把脚本移到新路径,完整重建 command,丢掉 env 包装而保留 timeout。在两份真实 wheel 的同一项目中复现。 按已知生成结构匹配托管条目,保留用户自定义调用。可无歧义定位其旧脚本参数时仅更换对应路径,保留包装程序、环境和其他参数。补一条已安装配置的更新回归。 源码
动机 / Motivation
合并 Claude、KunlunCode、ZCode 默认宿主包位置,跨原位更新保留已安装的命令和用户自定义。 此前默认更新后项目 Claude 命令仍指向被移除旧脚本。当前增加现存配置的自动迁移。 既有 Claude Code 项目适配器用户,以及从 Python/Node、面板或命令入口使用 KunlunCode 和 ZCode 的用户。
默认升级静默改变项目 hook 的执行上下文。用户以独立配置指定的环境仍影响后续动作。 实际用精确 base/head wheel 在同一 venv 原位升级。从注册项目之外运行默认 slash-commands --install,原项目 /loopx status 与状态栏均退出 0。dry-run 保持文件字节,重复更新幂等,env 和权限键保留。 原位双 wheel、注册项目外的真实更新、dry-run 和再次安装。定向 Python 119、Node 69 通过。安装路径上的用户 wrapper 已复现被覆盖。 安装行为在 macOS 临时 venv、临时 home 和测试项目内验证,默认更新由真实 CLI 执行。Node 69、定向 Python 119 项通过。Windows quoting、真实宿主会话和托管 CI 未核验。 验收契约
改动思路 / Approach
该改动沿用 旧 wheel 项目安装器 → .claude 命令和设置 → 发行版升级默认 CLI → 真实状态命令及状态栏入口。复用默认 slash install 入口与原子文件更新。在迁移 owner 保留现有配置写入边界。 发现注册项目的配置后,按旧脚本路径片段筛选 PreToolUse 与 statusLine,再整体重建 command。引用旧脚本不充分证明整个调用是工具生成。 按已知生成结构匹配托管条目,保留用户自定义调用。可无歧义定位其旧脚本参数时仅更换对应路径,保留包装程序、环境和其他参数。补一条已安装配置的更新回归。
具体改动 / Changes
精确提交 bfd1e3b,本次对照目标 379b9ea。102 文件 +1017/−173。重构包括移动三个宿主包及两幅原样 UI 资源,以及路径消费者、双语文档和回归。相较上一受评头,增量集中在 Claude 迁移、KunlunCode 旧命令识别和相应测试。
关键代码讲解
-
_migrated_settings_payload。命中旧脚本路径片段即重建 command,丢弃用户的包装程序。 源码 -
_discover_claude_migration_targets。由现有配置和注册项目查找历史安装。 源码 -
_is_managed_server。同时识别旧的 managed server 与新发行路径。 源码 -
managed-migration-preserves-custom-hook-invocation(not_met)。默认更新恢复旧安装入口,同时保持所有非托管配置的执行形式与设置。
对主干的风险 / Risks
给已安装的 Claude PreToolUse 新增一个合法的项目级自定义调用。它使用 env 包装旧 LoopX 脚本,并设置独立 timeout。默认升级把脚本移到新路径,完整重建 command,丢掉 env 包装而保留 timeout。在两份真实 wheel 的同一项目中复现。 一般旧项目可以继续使用,含旧脚本路径的自定义 hook 会被改写为标准调用。 按已知生成结构匹配托管条目,保留用户自定义调用。可无歧义定位其旧脚本参数时仅更换对应路径,保留包装程序、环境和其他参数。补一条已安装配置的更新回归。
我的整体评价 / Verdict
REQUEST_CHANGES。 上一轮标准命令和状态栏的升级缺口已关闭。仍需要限定自动迁移的识别与更新范围。 宿主移位后的首次正常升级需要同时保全运行入口和用户已经配置的行为。
English verdict: REQUEST_CHANGES at bfd1e3b. The default wheel upgrade now restores ordinary Claude command and statusline execution. It still rewrites a user-defined PreToolUse command and drops its environment wrapper. Migrate only proven managed entries or preserve the custom invocation.
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)
[P2] 旧脚本路径紧邻 shell 运算符时漏迁。
[P2] 迁移把普通输出参数当作 LoopX 启动命令。
动机 / Motivation
已有 Claude Code LoopX 安装、升级 wheel 后重装 slash commands 的用户。 旧包脚本移到新目录后,已有 statusLine 需要换到新路径,同时保留用户的命令结构与输出。 迁移实际执行的旧 LoopX 脚本,保留 shell 链接符、参数与用户自有的 statusLine 内容。 对照契约
使用实际 Wheel 连续安装旧版和当前提交,运行公开安装 CLI,再按保存的配置执行状态栏及 slash 命令。 紧邻 && 的旧启动命令和先打印路径再启动的组合均退出 2。只打印路径的用户脚本退出 0,但显示内容变化。
已实装 macOS/POSIX wheel 并运行保存的命令。交互式 Claude Code、PowerShell 和托管 CI 未验证。
- S1 脚本搬家后普通命令和空格分隔的包装仍可用。 通过。
- S2 紧邻 shell 运算符的实际 launcher 能迁移。 当前反例成立。
- S3 仅出现在值参数中的旧路径保留原样。 当前反例成立。
改动思路 / Approach
迁移入口读取用户拥有的设置,写回只覆盖已确认归属的 LoopX 命令。 现有迁移入口仍适用。执行位置与值参数由同一 parser 分辨,保留现有命令范围及用户输出。 旧 wheel 自带原路径,五种合成配置全部可执行,状态栏输出和原 slash 命令均正常。 按实际入口执行并读回结果。
具体改动 / Changes
精确提交 b1b3f51f71c64c65bc1ce90bca3b23d5efc9eb6d,102 个文件 +1331/−173。变更集中于 Claude Code、KunlunCode、ZCode host 布局、Wheel 安装兼容与配套 CI 测试。
migrate_legacy_claude_dir。真实安装器迁移旧版 settings 文件。 代码_migrated_settings_payload。对旧 statusLine 和 PreToolUse 调用相同的命令迁移入口。 代码_tokenize_shell_spans。从原命令提取位置,未把不带空格的 shell operator 识别成边界。 代码_rewrite_legacy_claude_command。当前按首个匹配路径后缀选中替换位置。 代码installed legacy Claude command test。既有验证执行迁移后的普通 statusLine 命令。 代码
实际双 Wheel 的普通及带空格包装对照保留了显示,五种 slash 命令均成功,dry-run 保留原设置字节。Python 232 项及 Node 52 项通过。 定向回归测试
对主干的风险 / Risks
标准本地预检 19 项执行检查通过。 针对 PR 基线和复核时主干的只读 merge-tree 及签署检查通过。标准预检从干净提交运行。状态栏错误独立从真实 Wheel 安装复现。
语义与 CI 对齐
已有测试覆盖普通和空格分隔的包装。新增两个真实失败用例分别压缩 shell operator 周围空格,并把匹配路径放在用户命令的值参数位置。
我的整体评价 / Verdict
REQUEST_CHANGES。 普通和空格包装的升级已核验。请让迁移按实际执行位置匹配脚本,保留运算符和用户的普通参数。两个退出 2 的用例及打印内容漂移均可稳定复现。
English verdict: REQUEST_CHANGES at b1b3f51. A real wheel upgrade leaves valid no-space shell operator chains on the removed launcher and rewrites a matching path used only as a printf argument. Verify that the matched span is an executed LoopX script and preserve shell boundaries and literal data.
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)
[P2] 引用 here-document 的输出被当成启动命令改写。 现有 statusLine 用引用 here-document 打印一行旧启动命令,随后执行一次相同的实际 launcher。 真实 wheel 升级后实际 launcher 可执行,但打印出来的文本也变成新路径,第一行 stdout 与旧包不相同。 区分 here-document 重定向与普通文件重定向,跳过数据正文和终止行,只迁移其后的确实执行的命令。 实装后比较原输出字节,断言引用的正文 unchanged 且后续 launcher 确实从新路径执行。 源码
[P2] 条件分支里的旧状态栏 launcher 未迁移。 既有状态栏通过合法的 POSIX if 条件,随后在 then 分支执行旧脚本。 当前安装报告成功,实际 statusLine 却因引用移除的旧版脚本,从退出 0 变成 2。slash 命令仍成功,容易漏掉状态栏故障。 识别已证明安全的复合命令位置,或把无法认证的旧 launcher 报为需手工迁移,提供恢复路径。 从实际旧 wheel 升级,在真实 /bin/sh 下执行原配置并验证状态栏结果和迁移诊断。 源码
动机 / Motivation
已有 Claude Code LoopX 安装、升级 wheel 后重装 slash commands 的用户。 旧包脚本搬家后,状态栏需要换到新路径,同时保留用户已有 shell 包装和输出。 只迁移实际执行的旧 LoopX 脚本,保留用户的打印文本和未覆盖的配置。 对照契约
在隔离 Python 环境先实际安装旧版 wheel,然后安装当前 wheel,再由公开安装 CLI 改写配置。由 POSIX shell 执行保存的状态栏并对照基线输出。 引用 here-document 将旧命令作为纯文本输出时,安装器也改写了数据行,首行输出变化但仍退出 0。条件分支 then 之后的真实 launcher 未迁移,状态栏从退出 0 变成 2。
验证覆盖本地 macOS POSIX 与实际 wheel 安装。未运行交互式 Claude Code、PowerShell 或托管 CI。
- 原失败回归 无空格链接符和用户路径值保留原效果。 通过。
- 引用数据字节 here-document 的用户输出保持原字节。 当前反例成立。
- 条件包装 可执行的条件分支 launcher 完成迁移或提供明确诊断。 当前反例成立。
改动思路 / Approach
显式安装时更新项目或用户已授权的 LoopX 路径。用户自有的文本和非 LoopX 命令不在替换权限内。 复用现有原位迁移和设置归属。把 shell 数据、命令和未知语法先区分,再决定是否替换。 实际旧版 wheel 仍提供原启动路径,七种合成配置和七次 slash 命令均退出 0。 按实际入口执行并读回结果。
具体改动 / Changes
精确提交 bd711a7df78b3804d9afd08d571d5f6e342d65cf,PR 对照目标 379b9ea3e9dab2b5671129bdd0c52b3e47479ed0。102 个文件 +1818/−174。范围是 Claude Code、KunlunCode、ZCode host 打包路径,真实安装迁移,及配套类型、CI 和测试。相比上一审仅两处文件改变。
migrate_legacy_claude_dir。实际迁移入口读取既有 Claude 配置并写回可归属项。 代码_migrated_settings_payload。提取 statusLine 或 PreToolUse 命令且保留已有用户配置。 代码_split_command_segments。分隔命令及重定向。现有 here-document 状态没有跨行保留。 代码_advance_command_wrappers。定位分段内的 wrapper 和命令,未跳过 then 保留字。 代码test_claude_legacy_migration_command_position_and_operator_boundaries。已有定向矩阵保护无空格运算符、普通数据和常见 wrapper。 代码
两份实际打包程序的七组升级测试确保原 slash 命令正常,七次 dry-run 保留设置字节。独立 Python 258 项通过、3 跳过,TypeScript 定向 69 项通过,源类型检查、Chat 构建及两张 ZCode PNG 逐字节对照通过。 定向回归测试
对主干的风险 / Risks
标准本地预检 6 项直接检查和 19 项执行检查均通过。另有 2 项人工图像验收,仍保留预检状态。 相对当前主干 6915df6 的只读 merge-tree 成功,四个提交均有 DCO 签署。两个失败都来自真实 wheel 安装;迁移依然报告成功。已检查两张原有 ZCode 首屏资产,窄屏原生错误和桌面额度门均与基线逐字节相同。
语义与 CI 对齐
当前测试验证常见 shell 链。真实升级反例另对照引用文本和控制流程,确认前者 stdout 漂移,后者退出 2。
我的整体评价 / Verdict
REQUEST_CHANGES。 上一轮三类已复现的旧问题均已关闭。当前还需要保持 here-document 的数据原文,并可靠处理或诊断条件分支中的真实 launcher。
English verdict: REQUEST_CHANGES at bd711a7. The installed upgrade fixes the earlier five cases. It still rewrites displayed text inside a quoted here-document and leaves an executed launcher after then pointing to the removed file, causing statusLine to exit 2. The slash command continues to work in both cases.
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · Gemini · Google · self_reported
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
This exact-head review (c5b6f14bb1b74a58246f3cc33423cfd2a269d684) confirms zero blocking defects across the Batch 2 host consolidation (claude, kunluncode, zcode moved under loopx/hosts/), including heredoc body preservation, POSIX compound clause migration, and fail-closed manual_migration_required reporting. Submitted as a COMMENTED review because GitHub blocks formal self-approval on author-owned PRs.
动机 / Motivation
- Who & trigger: Operators upgrading an existing LoopX installation (
loopx slash-commands --install) or invoking CLI and dashboard integrations for Claude Code, KunlunCode, and ZCode (loopx-kunluncode,loopx zcode-goal, dashboard chat bundle, andloopx/hosts/*), alongside maintainers consolidating top-levelloopx/*_goal_mode/packages underloopx/hosts/. - Before & after scenario: Before: consolidating
loopx/claude_goal_mode/intoloopx/hosts/claude/deletes the old script paths inside newly built wheels, so existing projects whose.claude/settings.jsonhooks,statusLine,.mcp.json, or/loopxcommand still point atclaude_goal_modefail with exit status2; meanwhile, naive substring or flat command rewrites corrupt quoted heredoc bodies andprintfoperands, miss adjacent&&chains orif ...; then ...; fibranches, drop customenvwrappers/timeouts, or silently skip dynamicevalcommands. After: defaultloopx slash-commands --installdiscovers current and registered projects, skips here-document bodies verbatim, rewrites only executable legacy launcher positions across compound POSIX clauses and shell chains while preserving literal operands/wrappers/timeouts, flags unparseable dynamiceval/option references withmanual_migration_requiredrecovery notes, and preserves KunlunCode and ZCode behavior. - Observable outcome: All three adapters (
claude,kunluncode,zcode) operate fromloopx/hosts/{claude,kunluncode,zcode}across Python, TypeScript, dashboard, and wheel builds, KunlunCode legacy MCP detection (_MANAGED_MCP_SCRIPT_SUFFIXES) andloopx-kunluncodestay intact, existing Claude setups upgrade idempotently across simple, heredoc, and compound control commands without modifying--surface codex,--uninstall,print_only, or heredoc-only setups, and dynamicevallegacy commands emit actionablemanual_migration_requireddiagnostics. - Non-goals: Compatibility stub packages under deleted
loopx.*_goal_modeimport paths are intentionally omitted once repository callers cut over, dynamic shells such asevalorenv -Sare never guessed/rewritten automatically, andloopx-kunluncodekeeps its console-script alias until downstream caller cutover completes. - Remaining gap: Six remaining
loopx/*_goal_mode/packages (agy_goal_mode,dsh_goal_mode,kiro_cli_goal_mode,opencode2_goal_mode,opencode_goal_mode,pi_goal_mode) stay deferred to subsequent M2 batches.
改动思路 / Approach
- Entry point & authoritative state: Packaging and runtime cutover flows directly through
pyproject.toml,tsconfig.control-plane.json,loopx/presentation/chat_bundle.py,apps/presentation/dashboard,loopx/hosts/{claude,kunluncode,zcode}, andloopx/slash_command_install.py. During non-uninstallloopx slash-commands --installwhen"claude-code"is active,_discover_claude_migration_targetsenumeratesCLAUDE_HOME,CLAUDE_CONFIG_DIR,cwd/ancestor roots, and active project registries viaread_activation_upgrade_registry, then invokesmigrate_legacy_claude_dirper discovered.claudeor.mcp.jsondirectory. - Architecture assessment (
retain) & boundary: Separating pure shell-span and heredoc parsing (_consume_heredoc_bodies->_tokenize_shell_spans->_split_command_segments->_advance_command_wrappers->_segment_edits) from fail-closed diagnostic reporting (_inspect_legacy_claude_command), target discovery (_discover_claude_migration_targets), and atomic JSON writes (migrate_legacy_claude_dir) keeps invariants, policies, and provider IO distinct without maintaining duplicateloopx/*_goal_modestub packages. Scoped to Batch 2 consolidation (claude,kunluncode,zcode), repository caller/packaging/dashboard/doc cutovers, KunlunCode legacy MCP tolerance, and segment/heredoc/clause-aware Claude upgrade migration with fail-closed manual diagnostics; excludes the remaining 6 host packages.
| Component / Path | Legacy Baseline (9467da4187) |
Batch 2 Consolidated (c5b6f14bb1) |
Migration / Compatibility Behavior |
|---|---|---|---|
| Claude adapter | loopx/claude_goal_mode/* |
loopx/hosts/claude/* |
Span/heredoc/compound-clause migration via loopx slash-commands --install (--surface claude-code) |
| KunlunCode adapter | loopx/kunluncode_goal_mode/* |
loopx/hosts/kunluncode/* |
Keeps loopx-kunluncode alias; _is_managed_server recognizes old + new server.py suffixes |
| ZCode native Goal | loopx/zcode_goal_mode/* |
loopx/hosts/zcode/* |
Updates TS/Python/dashboard/chat-bundle contracts (loopx/hosts/zcode/contract.{ts,json}) |
| Heredoc / compound / dynamic shells | Flat/substring edge gaps | _consume_heredoc_bodies, _CLAUSE_STARTERS, _inspect_legacy_claude_command |
Skips heredocs verbatim; migrates if/then/elif/else/while/do/{}/(); flags eval/env -S as manual_migration_required |
Note: Table derived from inspected source at c5b6f14bb1b74a58246f3cc33423cfd2a269d684; runtime behavior independently verified via live dual-wheel execution probes.
具体改动 / Changes
Across -M20% diff classification (102 files, +2271 / -174):
- Production (
21files,+1056/-32): Core additions live inloopx/hosts/claude/scripts/install.py(+867/-9total across the branch) andloopx/slash_command_install.py, plusloopx/cli_commands/slash_commands.py,loopx/hosts/kunluncode/{cli,runtime,server}.py,loopx/hosts/zcode/{api,bridge,cli,runtime},loopx/presentation/chat_bundle.py,apps/presentation/dashboard/src/{data/zcode-goal.ts,features/personal-workspace/zcode-goal-control.tsx},packages/dsh-loopx-plugin/src/managed-runtime.ts,pyproject.toml,tsconfig.control-plane.json, and CI/install scripts. - Tests & Smokes (
32files,+1124/-60): Regression suites intests/test_slash_command_install.py(including heredocs, POSIX compound clauses,casepatterns,forlists, andevalmanual diagnostics),tests/test_kunluncode_goal_mode.py,tests/test_hosts_goal_mode_batch2_consolidation.py, and updated imports across TS/Py suites. - Docs (
14files,+37/-37) & Mechanical Moves (35files,+54/-45): Bilingual roadmap sync (docs/architecture/rfcs/loopx-overall-roadmap-v0{,.zh-CN}.md), companion docs, andgit mvrelocation ofclaude,kunluncode, andzcode.
关键代码讲解
loopx/hosts/claude/scripts/install.py:640—_tokenize_shell_spans&_consume_heredoc_bodies:618: Queues POSIX<</<<-delimiters (preserving here-string<<<order), consumes queued heredoc bodies and closing delimiters verbatim after(with tab stripping for<<-), fails closed (None) on unterminated heredocs/quotes, and still tokenizes executed commands before(on header lines) and after closing delimiters.loopx/hosts/claude/scripts/install.py:756—_split_command_segments&_advance_command_wrappers:829: Trackscase ... in pattern) ...;; esacarms without matching case patterns, steps over unquoted_CLAUSE_STARTERS(if,elif,then,else,while,until,do,{) while holding_CLAUSE_HEADERS_NON_COMMAND(for,select,case) non-executable sofor s in <old>; do <old_launcher>; doneandif [ ... ]; then <old_launcher>; firewrite only real execution slots, and flagseval/env -S/ unsupported flags only when legacy suffixes remain.loopx/hosts/claude/scripts/install.py:1284—migrate_legacy_claude_dir&loopx/slash_command_install.py:687(_discover_claude_migration_targets,install_slash_commands:967): Upgrades.claude/commands/loopx.md,.claude/settings.json, and.mcp.jsonatomically across registry/home targets, emittingmanual_migration_requiredrows and--scope ... --hardenrecovery notes ininstalled+ Markdownnoteswhen dynamic commands cannot be auto-rewritten.loopx/hosts/kunluncode/cli.py:153—_is_managed_server&pyproject.toml:71: Retainsloopx-kunluncode = "loopx.hosts.kunluncode.cli:main", updates_source_root()(parents[3]), and accepts both/loopx/hosts/kunluncode/server.pyand/loopx/kunluncode_goal_mode/server.pyin_MANAGED_MCP_SCRIPT_SUFFIXES.loopx/hosts/zcode/bridge.py:212—zcode_goal_operation&loopx/presentation/chat_bundle.py:22: Switches-m loopx.hosts.zcode.bridge --validate-binding, relative imports,SOURCE_FILES(loopx/hosts/zcode/contract.{ts,json}), and dashboard imports (zcode-goal.ts,zcode-goal-control.tsx) cleanly without behavioral drift.
Specification mapping (docs/architecture/rfcs/loopx-overall-roadmap-v0.md @ 9467da418740ac483d0f09499f2f08ff1ad559d6):
roadmap-m2-batch2-move(hosts/claude,hosts/kunluncode,hosts/zcodemigrated cleanly, old dirs removed):implementedroadmap-m2-caller-and-packaging-cutover(all internal imports, TS configs,pyproject.toml,chat_bundle.py, dashboard, CI/docs updated):implementedroadmap-m2-claude-and-kunluncode-upgrade-preservation(legacy Claude.claude/.mcp.jsonheredoc/compound-safe migration +manual_migration_required+ KunlunCode legacy MCP detection +loopx-kunluncodealias preserved):implementedroadmap-m2-remaining-6-packages(consolidation ofagy,dsh,kiro_cli,opencode,opencode2,piunderloopx/hosts/):deferred
对主干的风险 / Risks
- Findings: No blocking findings on exact head
c5b6f14bb1b74a58246f3cc33423cfd2a269d684. All6review threads (including Round-4PRRT_kwDOStEbEs68kxW0andPRRT_kwDOStEbEs68kxW3) are verified resolved (6/6) and covered by live dual-wheel and regression verification. - Failure analysis & negative walkthroughs: Verified
print_only(printf),heredoc_only(cat <<'EOF'),heredoc_then_launch(cat <<-'EOF'tab-stripped body + post-EOF launcher),for_literal_and_do(for s in <old>; do <launcher>; done),if_then_compound(if [ -n "$HOME" ]; then <launcher>; fi),eval_dynamic(manual_migration_required == 1with untouched command and actionable recovery guidance),--surface codex,--uninstall, and corrupt JSON handling. Zero false-positive warnings were emitted on benign print/heredoc/for-list setups. - Scope fit, isolation & authority (
default_off_isolation=isolated,authority_semantics=aligned): Active callers are wired in CLI/packaging/dashboard; Claude hooks continue gating on.claude/loop.md/LOOPX_GOAL_FORCE=1, KunlunCode keeps itsloopx-kunluncodeentry point, and ZCode retains its session-scoped controller boundary. - Validation ledger (
ci_policy: not_consulted,wait_for_ci: false):- Dual-wheel live 11-case upgrade counterfactual (
9467da4187->c5b6f14bb1): Built full2.4.1wheels (build:chat+ dashboardtsc --noEmit+setup.py verify_frontend()), installed baseline in an isolated venv, ranloopx slash-commands --installfrom outside project dirs after upgrade:10/10runnable setups (ordinary,spaced_env,adjacent_and,print_only,print_then_launch_adjacent,print_then_launch_spaced,heredoc_only,heredoc_then_launch,if_then_compound,for_literal_and_do) +envPreToolUse(timeout=12) +.mcp.json+/loopx status+loopx-kunluncode --helppassed exit0matching baseline (print_only&heredoc_onlybyte-identical);eval_dynamicremained untouched and emittedmanual_migration_required == 1;--surface codexand--uninstallleft all11untouched; repeat install had zero"updated"rows. - Pytest (
3166 passed, 3 skipped):tests/test_slash_command_install*.py,tests/test_claude_*.py,tests/test_hosts_goal_mode_batch2_consolidation.py,tests/test_kunluncode_goal_mode.py,tests/test_dsh_*.py,tests/test_zcode_*.py,tests/test_host_*.py,tests/test_atomic_write_modes.py,tests/test_runtime_subprocess_utf8.py,tests/presentation/test_chat_bundle.py,tests/cli_commands/test_source_session_lifetime.py,tests/control_plane/,tests/canary/test_maintainability_ratchet.py, andtests/architecture/passed in145.44s(3Windows-only skips intest_claude_goal_install_python_launcher.py). - TypeScript / DSH / CI / Static:
npm run typecheck:control-plane0; Node TS tests85/85passed;packages/dsh-loopx-plugintsc(3tsconfigs)0+ Vitest16/16(405/405passed);scripts/ciunittest discover24/24passed;check_rfc_bilingual.pypassed;ruff check0;mypy --strict --follow-imports=silent0/22(17[tool.mypy]kernel files +install.py+slash_command_install.py+kunluncode/server.py+zcode/{api,bridge}.py);loopx check(98scanned files)errors=0, warnings=1(non-literalcli.ts:87credential token). - Canary premerge (
--tier standard): Direct6/6passed,catalog_run10/10passed,boundary_run1/1passed,risk_profile_run5/8passed (3failures strictly inexamples/canary/dsh-loopx-plugin-validation.py --phase {quality,package,runtime}, exit2:pnpm is required for DSH plugin validation).
- Dual-wheel live 11-case upgrade counterfactual (
- Residual risk & strongest unverified gap: On this macOS host without
pnpm, thepnpm pack/ DSH CLI plugin pack lifecycle (dsh-loopx-plugin-validation.py --phase package,runtime) and the 3 Windows-only shell tests (Git Bash /powershell.exelive execution beyond unit tests intest_slash_command_install.py) were not executed live.
我的整体评价 / Verdict
- Outcome impact (
long_horizon:improved;user_experience:preserved): Advances M2loopx/hosts/consolidation (3of9packages migrated, zero stray*_goal_modecross-imports) while safely upgrading Claude setups (including heredocs and compound POSIX control clauses) and flagging non-rewritable dynamic commands without silent breakage.visual_review:not_applicable—apps/presentation/dashboard/src/data/zcode-goal.tsandzcode-goal-control.tsxmodify only thecontract.jsimport path with no rendered DOM/CSS changes, verified viatsc --noEmitand Vite chat bundle build (unverified_scope:none). - Assessment decisions:
observable_semantics=equivalent,code_volume=necessary(compatibility_assessment:retain),change_proportionality=proportionate(architecture_assessment:retain),default_off_isolation=isolated,authority_semantics=aligned,semantic_alignment=aligned(reuses existingclaude_goal_modelegacy suffixes, ZCode contract schema, and registered registry codecs). Separating pure shell-span and heredoc parsing (_consume_heredoc_bodies->_tokenize_shell_spans->_split_command_segments->_advance_command_wrappers->_segment_edits) from fail-closed diagnostic reporting (_inspect_legacy_claude_command), target discovery (_discover_claude_migration_targets), and atomic JSON writes (migrate_legacy_claude_dir) keeps invariants, policies, and provider IO distinct without maintaining duplicateloopx/*_goal_modestub packages. Scoped to Batch 2 consolidation (claude,kunluncode,zcode), repository caller/packaging/dashboard/doc cutovers, KunlunCode legacy MCP tolerance, and segment/heredoc/clause-aware Claude upgrade migration with fail-closed manual diagnostics; excludes the remaining 6 host packages. - Freshness & Conclusion: Verified at exact head
c5b6f14bb1b74a58246f3cc33423cfd2a269d684(6/6threads resolved,wait_for_ci: false, PR leftOPEN), published asCOMMENTEDreview due to GitHub author-owned restriction.
English Verdict: APPROVE
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)
[P2] then 后的 POSIX 续行让状态栏静默失效。 现有 statusLine 为了换行排版,在 then 后使用反斜杠换行,再缩进实际 LoopX launcher。 POSIX shell 删除反斜杠换行。迁移器却把换行放入独立 token,遗漏后续 launcher。实际升级报告成功且没有手工迁移提示,statusLine 从退出 0 变成 2。 扫描时消除 POSIX 词法续行的值,同时保留源偏移,确保随后明确的命令仍在命令位置。 用两个实际 wheel 升级含续行的有效 if 配置,断言迁移后原 stdout、退出 0 和续行格式。 源码
[P3] 行末注释的普通撇号被当作未闭合引号。 现有 POSIX statusLine 在真实 launcher 后附加行末注释,其中包含一个普通撇号。 shell 忽略该注释。迁移器把注释中的撇号视为引号起点,错误要求手工迁移并保留旧脚本路径。实际升级后状态栏退出 2。 识别词起始位置的未引用注释标记,跳到换行并保留注释内容。引用中的井号和字面词仍应按原义处理。 用实际升级覆盖 launcher 后的撇号注释和含井号的普通数据,校验命令迁移、原注释保留和无误报。 源码
动机 / Motivation
已有 Claude Code LoopX 安装、升级 wheel 后重装 slash commands 的用户。 旧包脚本搬家后,显式安装需要迁移真实启动路径,同时保留自定义状态栏的 shell 结构和用户设置。 迁移有效命令中的旧 LoopX 脚本,保持状态栏可运行并保留用户文本。无法可靠迁移时给出准确诊断。 对照契约
在隔离环境分别安装实际旧 wheel 和新 wheel,由公开安装 CLI 执行升级,再通过 /bin/sh 执行保存的 statusLine 并对照退出码与 stdout。 then 分支的 shell 续行和行末含撇号的注释都会保留已移除的旧路径,使 statusLine 退出 2。续行没有手工迁移提示,注释被误报为未闭合引号或 here-document。两种情况下 slash 命令均退出 0。
覆盖本地 POSIX shell 和真实 wheel 安装。交互式 Claude Code、PowerShell、托管 CI 和正式部署未验证。
- 既有启动与数据显示 普通命令、引用 here-document、行内条件分支和 case 分支保留原输出。 通过。
- POSIX 续行 then 分支中带续行的有效命令应迁移并正常执行。 当前反例成立。
- POSIX 行末注释 包含普通撇号的 Shell 注释应保留原文且不阻断有效 launcher 的迁移。 当前反例成立。
改动思路 / Approach
仅在显式安装 Claude Code slash commands 时迁移可归属的 LoopX 引用。原有设置及 shell 用户文本保持原义。 复用现有原位迁移和设置归属。由同一词法扫描维护执行位置和原字符串偏移。 实际旧 wheel 保留原脚本,十种 statusLine 和十次 slash 命令均退出 0。 按实际入口执行并读回结果。
具体改动 / Changes
精确提交 c5b6f14bb1b74a58246f3cc33423cfd2a269d684,PR 对照目标 379b9ea3e9dab2b5671129bdd0c52b3e47479ed0。103 个文件 +2792/−695。此次涉及 Claude Code、KunlunCode、ZCode 迁包及其打包、CI、文档和验证。相对上一审的三文件增量集中在 shell 判定、诊断透出及回归测试。
migrate_legacy_claude_dir。配置迁移入口写回可归属的旧路径并透出手工迁移诊断。 代码_inspect_settings_migration。提取 statusLine 和 hook 命令,保留其他设置字段。 代码_consume_heredoc_bodies。按声明跳过 here-document 正文,引用正文经实装对照一致。 代码_tokenize_shell_spans。保留词和运算符偏移。当前把续行写入词值,并在注释中识别引号。 代码_split_command_segments。区分命令段和重定向,普通 case 分支中的 launcher 实装成功。 代码test_claude_legacy_migration_heredocs_compound_clauses_and_manual_diagnostics。定向矩阵保护普通复合命令、here-document 和部分手工迁移诊断。 代码
上一轮的引用 here-document 和行内 then 两项已修复,普通 case 额外通过。十个项目的 slash 命令及 dry-run 保留设置字节均通过,非归属权限字段保留。另有 Python 259 项通过和 3 项跳过,TypeScript 69 项通过,控制平面类型检查与 Chat bundle 构建通过。 定向回归测试
对主干的风险 / Risks
标准本地预检 6 项直接检查和 19 项执行检查均通过。另有 2 项人工图像验收,仍保留预检状态。 相对当前主干 6915df6 的只读 merge-tree 成功,五个提交均有 DCO 签署。两张 ZCode 画面均检查过,与基线逐字节一致。两个新增 shell 反例在隔离 wheel 实装中成立。
语义与 CI 对齐
定向矩阵覆盖普通复合语句和 here-document。续行和注释是独立的 POSIX 词法边界,在真实安装路径分别导致漏报和误报。
我的整体评价 / Verdict
REQUEST_CHANGES。 上一轮两项问题已通过原路径复验。请修复续行导致的静默失效及注释误报,并在下一提交复跑两条实装升级样本。
English verdict: REQUEST_CHANGES at c5b6f14. The quoted here-document and inline then regressions are fixed. In an installed-wheel upgrade, a valid POSIX line continuation before the launcher leaves statusLine broken without a diagnostic. An apostrophe in a trailing comment also blocks migration with a false unterminated-quote diagnostic. Both statusLine commands exit 2 while slash commands still work.
|
This pull request has merge conflicts with Choose the remote for the base repository, not an out-of-date fork. git fetch upstream
git rebase upstream/main
# Resolve each conflict, git add the resolved files, then git rebase --continue.
git push --force-with-lease origin HEADFor a same-repository clone whose Keep the DCO |
…nder loopx/hosts Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
…CI assertion Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
…ion Claude launchers Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
… control clauses Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
…gration Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
…oints Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
c5b6f14 to
70abae1
Compare
|
Rebased cleanly onto Updates on this head
Local Verification (
|
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)
Exact head: 70abae1fde1e43921d950a7e14f3dd57f9dd15ae
[P2] Claude 项目迁移后,回退 wheel 会使状态栏与 /loopx 同时失效。 普通 pip 所有的安装在升级时运行 Claude slash-command 迁移,随后在同一环境恢复上一 wheel。原 wheel、升级后迁移前、迁移后三阶段,statusLine 和 /loopx status 都退出 0。降回上一 wheel 后两者均退出 2,报缺少脚本。上一 wheel 的 slash-commands --install 再次退出 0,两处项目入口仍退出 2。用户完成包的回退与命令重装后,已配置项目仍不能查看状态或调用 /loopx。恢复动作需要额外知道并修复先前持久写入的新路径。既然新 wheel 已包含旧入口 shim,可保留已验证且能跨版本运行的现有 launcher。若确需改写,提供有版本感知且可校验的回退或恢复,再重放原配置。用两个正式 wheel 在同一隔离环境跑 baseline→升级→默认迁移→降级→旧版重装。重放原状态栏和 /loopx 入口,检查返回、显示和用户注释。 状态栏写入 命令写入
动机 / Motivation
已启用 Claude Code 集成的用户需要在升级和回退后继续使用原项目的状态栏与 /loopx 入口。该提交将 Claude、KunlunCode 和 ZCode 的运行文件移入 hosts,并补回旧 Python 入口。Claude 安装还会把已保存的命令和状态栏重写到新目录。隔离 wheel 验证确认向前升级可运行,降回上一包后,两处已迁移入口同时失效。本次验收覆盖普通 Python wheel、实际本地命令和打包构建。原生 Windows、Claude 在线宿主、归档安装回退和远端 CI 尚未验证。
改动思路 / Approach
三个宿主继续通过原 CLI 与适配器接入,内部实现迁至统一路径。旧 Python 入口转发到 canonical package,避免继续维护两套实现。向前兼容 shim 已能让旧项目命令在新包运行,继续无条件重写旧命令增加回退依赖。保留统一的 hosts 路径和薄 shim,给持久用户配置补齐双向迁移边界。
具体改动 / Changes
以基线 0bcdffb9926e46a1024bcdacb18e24de37a1b018 的 pip 回退计划核对 Python 回退后的项目入口。原流程恢复上一版本,重装工作流与 slash commands 并检查安装。实测旧版命令重装无法恢复此次项目路径改写。 基线回退计划
- Claude 的旧 shim 在候选 wheel 中成功运行。包含 POSIX 续行和撇号注释的状态栏可以迁移,保留格式、输出及生成项目的其余权限设置。候选迁移同时改写 /loopx 命令文件。 Claude 迁移
- KunlunCode 的 MCP 检查接受新旧 server 地址,Core 源码装配将 canonical 模块和旧 Python shim 一并纳入。 MCP 识别
- ZCode dashboard 改用统一 contract import,两个 PNG 保持原 blob。两端打包构建通过,Node 复测覆盖 ZCode AppServer、guard、native goal 和 host capability。 dashboard 入口
对主干的风险 / Risks
在同一个隔离 venv 中,基线和候选均构建正式 wheel。真实项目状态栏及 /loopx status 在向前升级、迁移前后均正常,回退后两个命令均因脚本缺失退出 2。旧版安装命令退出 0 后同样失败。166 项 Python、76 项 Node 测试通过,两端 Chat bundle 和正式 wheel 均构建通过。 Ruff 和差异空白检查也通过。
语义与发布验证
新目录与 shim 各自能工作。回退验收需要保留真实的已迁移配置,并在装回原包后原样重放入口。此处的失败发生在 Python wheel 环境。
我的整体评价 / Verdict
宿主归并和向前兼容已经有实证,之前的 POSIX 续行及注释问题在这次复验中通过。恢复上一 wheel 后项目入口仍失效,应补齐配置恢复再进入合并判断。
English verdict: REQUEST_CHANGES at 70abae1. After a real in-place wheel rollback, the migrated project status line and /loopx command still point to files absent from the previous wheel. Re-running the previous version's slash-command installer exits successfully without restoring either entrypoint.
…de migration Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
|
Fixed review
|
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · Gemini · Google · self_reported
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
Exact reviewed head: 9505@6682dfc8203a7707fd29cdd9752ecb8ab24fdacd (base=0bcdffb9926e, 128 changed files +8415/-4759, 8 DCO-signed commits). No blocking finding remains; prior [P2] wheel-rollback regression from 70abae1fde1e is resolved and verified.
动机 / Motivation
本次改动面向维护者、打包者以及使用 Claude Code、KunlunCode 和 ZCode 适配器的用户(涵盖包布局整理、安装新版本 wheel、运行默认 loopx slash-commands --install 以及版本回滚场景)。修改前三个宿主运行时分散在顶层 loopx/claude_goal_mode、loopx/kunluncode_goal_mode 和 loopx/zcode_goal_mode,且 70abae1 在运行默认 loopx slash-commands --install 时会无条件改写依然有效的 claude_goal_mode 启动命令与 .mcp.json,导致回滚到基线 wheel 后因缺少 loopx/hosts/claude 目录而直接报错;修改后三套宿主代码迁入 loopx/hosts/{claude,kunluncode,zcode} 并保留 21 个 .py 兼容垫片,同时 install.py 在确认当前安装的垫片与 Python 3.11+ 解释器均存活时保留原启动入口,仅迁移失效解释器、异环境旧路径或损坏的混合片段。当前精确提交 6682dfc 下三套宿主包已收敛到 loopx/hosts/{claude,kunluncode,zcode},21 个垫片可按模块导入或直接按文件路径执行,本地 581 项定向与整合测试、1919 项架构测试、6880 项 TS 控制面测试及 405 项 DSH 插件 vitest 测试均已通过并验证了 5 阶段双 wheel 升级与回滚闭环。本 PR 不在本轮删除旧兼容垫片、不将 Claude/KunlunCode 适配器重写为 TypeScript、不改变 Goal 授权与配额策略,也不在离线环境中强行补装 dashboard 前端依赖或 pnpm。
改动思路 / Approach
架构流上,打包与运行时入口已收敛到 loopx/hosts/:pyproject.toml 将 loopx-kunluncode 指向 loopx.hosts.kunluncode.cli:main 并更新包数据清单,tsconfig.control-plane.json、host_harness_capabilities.ts、chat_server.py、doctor.py 和 slash_command_install.py 统一引用新包路径;用户既有的 loopx.claude_goal_mode / loopx.kunluncode_goal_mode / loopx.zcode_goal_mode 导入与脚本入口则通过 21 个兼容垫片(各自重导出或转发 __main__,且自动确保仓库根在 sys.path)无感过渡。关于架构评估(architecture_assessment.decision=retain):迁移期保留 21 个薄兼容垫片及无状态活垫片守卫,可在仅保持 loopx/hosts/{claude,kunluncode,zcode} 唯一运行时所有者的前提下保护已安装的 .claude 配置、外部导入与跨版本 wheel 回滚,无需引入第二套状态持久化或版本开关。本 PR 边界严格限定于 Batch 2 宿主目录收敛、向后兼容垫片与 Claude 旧配置按段安全迁移,不包含垫片退场或非 TS 宿主重写。
| 场景阶段 | 70abae1fde1e 旧行为 |
6682dfc8203a 现行为 |
验证结果 |
|---|---|---|---|
基线 wheel 升级 -> 默认 slash-commands --install |
无条件把本环境活垫片改写为 hosts/claude/... |
校验垫片与 Python 均存活后保留 claude_goal_mode 启动项 |
PASS (test_two_wheel_claude_upgrade_migration_and_rollback_cycle) |
| 升级后回滚到基线 wheel | hosts/claude/ 消失导致 hook/statusline/MCP/命令报缺文件 |
原垫片路径仍有效且基线重新安装正常通过 | PASS (Stage 4 & Stage 5 两轮实测) |
| 混合片段 / 失效 Python / 外环境旧路径 | 一并重写或遗漏部分段 | 逐段编辑:保留有效段、仅把失效或异环境段迁移到 hosts/claude/... |
PASS (test_slash_command_install.py + 独立探测) |
具体改动 / Changes
全部 128 处 diff(+8415/-4759)分为三类:production(loopx/hosts/{claude,kunluncode,zcode}/* 迁入、loopx/*_goal_mode/*.py 21 个垫片封装、loopx/slash_command_install.py、loopx/control_plane/hosts/host_harness_capabilities.ts、apps/presentation/dashboard/src/... 仅改 contract.js 相对路径、以及仅 1 行注释更新的 packages/dsh-loopx-plugin/src/managed-runtime.ts)、tests_or_fixtures(跨宿主与两阶段 wheel 回滚测试及 smoke 更新,含新增 tests/test_hosts_goal_mode_batch2_consolidation.py 884 行与扩展 tests/test_slash_command_install.py)、以及 docs(README*.md、双语 RFC/手册、pyproject.toml、tsconfig.control-plane.json)。本 PR 无独立 RFC 书面规范(spec_basis: no_spec,spec_source: none),依据现有仓库打包布局、直接脚本契约与 problem_context 验收交付。
关键代码讲解
loopx/hosts/claude/scripts/install.py(L542-L583, L1160-L1194, L1355-L1393)——_resolve_live_python_command与_is_live_legacy_shim_path/_segment_edits:先检查 Python 命令是否为真实可执行且满足 Python 3.11+(shutil.which或绝对路径存在并通过_launches_python,经live_py_cache缓存,拒绝 WindowsApps 假别名与无效路径),再验证脚本路径是否解析到当前REPO_ROOT下真实存在的claude_goal_mode垫片;仅当同一段同时满足“活解释器 + 同安装活垫片”时返回空编辑保留原配置,否则按段精确升级至loopx/hosts/claude/...,并同步保护commands/loopx.md(_migrated_command_md_text)和.mcp.json(_migrated_mcp_json_payload)。loopx/slash_command_install.py(L685-L804, L1012-L1100)——_discover_claude_migration_targets与_migrate_legacy_claude_configs:接收显式registry_path和runtime_root(避免双 runtime root 冲突并发现关联项目下的.claude与.mcp.json),在install_slash_commands(..., uninstall=False)时调度claude_install.migrate_legacy_claude_dir,把只迁移失效旧项的精确摘要与手动诊断透传回安装报告。loopx/hosts/kunluncode/cli.py(L147-L162)——_MANAGED_MCP_SCRIPT_SUFFIXES与_is_managed_server:在判断 KunlunCode 是否托管已有loopxMCP 配置时,同时识别/loopx/hosts/kunluncode/server.py与旧/loopx/kunluncode_goal_mode/server.py,防止升级后丢失对旧配置的所有权识别。loopx/hosts/zcode/bridge.py(L26-L28, L53-L100)——ZCODE_GOAL_ACTIONS与validate_zcode_binding:迁入loopx/hosts/zcode/后直接以包内contract.json为单一动作词表,保持与 TS 侧contract.ts及 dashboardcontract.js引用一致且维持 fail-closed 的 Goal/Agent 绑定校验。
对主干的风险 / Risks
最强回归风险与反例测试聚焦两类边界:第一类是混合或部分损坏的配置回滚场景——当单条 statusLine/hook 命令包含“活垫片 && 无效 /old/python3 或异环境旧路径”多段时,只依赖全文正则极易误保失效段或误改有效段;经独立对抗探针实测与 test_slash_command_install.py#L2359-2420 验证,6682dfc8203 能逐段保留前半活垫片并精准迁移后半失效段,且在 Python 非法名或缺文件时安全迁移为新脚本。第二类是脱离包环境的直接脚本调用:21 个兼容性垫片(实测无非 .py 残留)及全部可执行入口在清理 PYTHONPATH 后自独立工作目录直接以文件路径执行均可正常启动或按参数透传退出(其中 goalmode_cmd.py --help 正确透传至 loopx bootstrap 用法输出)。所有改动均保持 default_off_isolation(默认 slash-commands --install 不启用 --harden hook、仅保护既有有效垫片且不改写用户 deny/hook 规则;ZCode/Claude/KunlunCode 均无默认开启的新权限扩展),无新增公开协议角色或字符串启发式状态机,无非预期默认行为变更。涉及词表的 loopx/semantics/goal_instance_binding_inventory_v1.json 仅更新包路径引用且已同步检查 host_harness_capabilities.ts 与 semantic-vocabulary-drift-smoke.py(34/34)。
本地验证矩阵(不依赖远端 CI,wait_for_ci: false):
- PASS Python 改动及 Batch1-3 整合全套
24个测试文件:581 passed, 3 skipped(跳过项经-rs核验均为 macOS 下sys.platform != "win32"的 Git Bash / PowerShell 条件跳过,tests/test_claude_goal_install_python_launcher.pylines 348, 504, 639),0失败。 - PASS Python 架构全集
tests/architecture/:1919 passed(225.87s)。 - PASS TypeScript 控制面:
npm run typecheck:control-plane(0错误)、5个直接相关.test.ts(76/76 passed)与npm run test:control-plane(6886 tests, 6880 pass, 0 fail, 6 skipped)。 - PASS
packages/dsh-loopx-plugin:npm --prefix packages/dsh-loopx-plugin run typecheck(0错误)与vitest run(16文件、405 passed)。 - PASS 静态与边界门禁:
ruff check全部86个改动.py文件All checks passed!;[tool.mypy].files基线17/17零报错(独立检查新增/迁移宿主与垫片中install.py等核心模块零新增 mypy 问题,slash_commands.py:21与kunluncode/cli.py3 处为原主干既有注解欠缺);scripts/check_rfc_bilingual.py --base origin/main --head HEAD通过;semantic-vocabulary-drift-smoke.py34/34 ok;5个 Claude/KunlunCode 改动 smoke 全部退出0(其中kunluncode因未在PATH上按设计返回skipped: true, ok: true);loopx check扫描4045个文件0错误、public_boundary_scan.ok=true;canary premerge --tier standard的 direct6/6、catalog10/10与 public-boundary1/1全过。 - UNVERIFIED(环境与二进制边界说明):
canary premerge中dsh-loopx-plugin域档3项(quality/package/runtime)因本机缺少pnpm报错退出码2(其中 TStypecheck与405个 vitest 用例已通过npm --prefix packages/dsh-loopx-plugin独立跑通并验证,--phase package/runtime打包安装烟测未运行);apps/presentation/dashboard本地未安装node_modules依赖未单独构建;两张移动 PNG(native-error-mobile.png、native-quota-desktop.png)已通过git ls-tree确认与主干 blob 完全一致(R100无像素改动)并直接看图确认仅含合成演示界面、无隐私泄漏(仍保留canary标注的两处二进制人工复核提示)。
我的整体评价 / Verdict
综合交付影响:long_horizon 为 improved(目录收敛配合活垫片保留机制消除了 upgrade -> default install -> rollback 断链风险,提升长程安装与多宿主协同稳定性);user_experience 为 preserved(升级与回滚无需人工修配置,visual_review 为 not_applicable)。本次未修改渲染布局、样式或图片像素内容:apps/presentation/dashboard/src/data/zcode-goal.ts 与 zcode-goal-control.tsx 仅更新了 contract.js 相对导入路径,loopx/hosts/zcode/images/native-error-mobile.png 与 native-quota-desktop.png 经 git ls-tree 核验为 R100 完全同 blob 迁移且直接看图确认仅含合成演示界面、无隐私信息。未验证范围:本地仓库 apps/presentation/dashboard/node_modules 为空(未装 react 等依赖)故未运行 dashboard Vite/tsc 构建;本地缺少 pnpm 故未执行 dsh-loopx-plugin --phase package 与 --phase runtime 打包安装烟测(但其 TypeScript typecheck 与 405 项 vitest 测试已通过 npm 直接运行并通过);macOS 环境跳过 3 项 Windows Git Bash / PowerShell 条件测试及真实 kunluncode 二进制联调。 与基线行为对照(observable_semantics: equivalent)及代码体量/兼容性评估(code_volume: necessary,compatibility_assessment: retain,change_proportionality: proportionate,default_off_isolation: isolated,authority_semantics: aligned,semantic_alignment: aligned / reuse_existing)均成立,且未改变闭环词表,仅复用既有注册合同并更新迁移路径引用。核心改动、跨版本 wheel 升级回滚闭环与边界隔离已在精确提交 6682dfc8203a7707fd29cdd9752ecb8ab24fdacd 充分验证,无阻塞问题(PR keeps OPEN for maintainer merge decision; wait_for_ci=false)。
English verdict: APPROVE
Goal and delivered outcome
Consolidate the second batch of host goal-mode runtime packages into
loopx/hosts/without adding legacy compatibility shims:loopx/claude_goal_mode/->loopx/hosts/claude/(14 files)loopx/kunluncode_goal_mode/->loopx/hosts/kunluncode/(9 files)loopx/zcode_goal_mode/->loopx/hosts/zcode/(13 files, includingimages/native-{error-mobile,quota-desktop}.pngmoved intact as exactR100renames)Updated all Python, TypeScript (dashboard
zcode-goaldata/UI +packages/dsh-loopx-plugin/src/managed-runtime.ts), package/packaging (pyproject.toml,tsconfig.control-plane.json,loopx/presentation/chat_bundle.py,loopx/semantics/goal_instance_binding_inventory_v1.json,scripts/ci/test_impact_plan.py), smoke/probe scripts, bilingual docs/RFCs, and affected tests, plus addedtests/test_hosts_goal_mode_batch2_consolidation.pyand updatedtests/test_slash_command_install_equivalence.py. Top-levelloopx/*.pyremains112.Upgrade, CI, & Shell Migration Fixes
bfd1e3bb52,PRRT_kwDOStEbEs68h5jkresolved): Defaultloopx slash-commands --install(whenclaude-code/allis selected, never--surface codexor--uninstall) inspects user and project Claude directories and migrates provably LoopX-owned retiredloopx/claude_goal_mode/entries incommands/loopx.md,settings.json, and project.mcp.jsontoloopx/hosts/claude/, leaving user permissions, env, model, custom hooks/statuslines, and unreadable files intact.bfd1e3bb52):_is_managed_serverrecognizes both new and legacyserver.pypaths;scripts/ci/test_impact_plan.pyrestores the mixedloopx/web/chat/index.html+ full-risk assertion.b1b3f51f71,PRRT_kwDOStEbEs68iw4fresolved): Preserves wrapper prefixes, quotes, nestedsh -c, PowerShell&, and trailing flags;_projects_from_registry_fileusesregistry_codec.read_activation_upgrade_registry.bd711a7df7,PRRT_kwDOStEbEs68j7z5&PRRT_kwDOStEbEs68j7z6resolved): Splits unquoted shell operators via_ShellToken(NamedTuple)(preservingspec_from_file_locationimports withoutsys.modules) and inspects command execution position per segment rather than rewriting data args (printf,echo, redirections,python3 -c,command -v).c5b6f14bb1,PRRT_kwDOStEbEs68kxW0&PRRT_kwDOStEbEs68kxW3resolved):_consume_heredoc_bodiesskips pending<<EOF/<<'EOF'/<<-EOFbodies and closing delimiters verbatim after header newlines while migrating real launchers on header lines or after closing delimiters._advance_command_wrappersand_split_command_segmentshandle unquoted POSIX compound clauses (if,elif,then,else,while,until,do,{ ...; },(...),case ... in pat) ...;; esac) while leavingforlists,casepatterns, and quoted keyword tokens intact.eval,env -S, unterminated quotes/heredocs, unsupported flags) stay untouched and emitmanual_migration_requiredwith explicit--scope ... --hardenrecovery notes throughinstall_slash_commands.Verification of the current head (
c5b6f14bb1b74a58246f3cc33423cfd2a269d684)loopx-2.4.1wheels from baseline (9467da4187) and candidate (c5b6f14bb1) in isolated venv site-packages; verified pre-migration exit2, ranloopx slash-commands --installfrom outside project roots, and verified all 9 runnable statusLine configs (ordinary, spacedenvwrapper, adjacent&&,printfprint-only, print-then-launch adjacent & spaced&&, quoted heredoc-only, heredoc-then-launch,if [ ... ]; then <launcher>; fi) plus/loopx statusexit0matching baseline stdout (print_only&heredoc_onlyuntouched verbatim;evalproject cleanly surfacedmanual_migration_required == 1untouched).pytest -q -n 4acrosstest_slash_command_install.py,test_hosts_goal_mode_batch2_consolidation.py,test_claude_goal_mode_{stdio_utf8,hook_fail_closed}.py,test_claude_goal_release_qualification.py,test_kunluncode_goal_mode.py,test_dsh_goal_mode_stdio_utf8.py,test_slash_command_install_equivalence.py, andtests/architecture/:2,102 passed(0failed,0skipped);scripts/ciunittest:Ran 24 tests OK.npm run typecheck:control-plane(0errors);node --experimental-strip-types --test(zcode_*+content_digest_single_owner):69 passed, 0 failed;packages/dsh-loopx-plugintsc --noEmit(0) andvitest run:16 files / 405 passed.ruff check(0),mypy --follow-imports=silent --strict(install.py0),mypy --follow-imports=silent(slash_command_install.py0),scripts/check_rfc_bilingual.py --base origin/main --head HEADpassed,semantic-vocabulary-drift-smoke.pyok(34/34), maintainability ratchetok=true(unreviewed_count=0),git merge-tree --write-tree origin/main HEADclean (0conflicts), 5/5 commits DCO-signed, top-levelloopx/*.py == 112. Goalcanary premerge --tier standard:6/6direct checks,10/10catalog canaries,1/1boundary (loopx checkacross 103 files),5/8risk-profile smokes (3misses strictlydsh-loopx-plugin-validation.pyon absent hostpnpm; DSHtsc+16/16Vitest verified directly above),manual_hold_count=2(R100PNG assets).Author declaration
Written with AI assistance (DCO sign-off preserved).