每轮只推进合理适量的上下文、禁止顺手扩功能 smoke:同步第6组指针

This commit is contained in:
cnc
2026-06-01 19:57:26 +08:00
parent cb9fb0fd00
commit 324a89a43b
3 changed files with 210 additions and 72 deletions

View File

@@ -1,44 +1,92 @@
# 技能:对齐 LinuxCNC G 代码 (align-linuxcnc)
---
name: align-linuxcnc
description: Use this skill for this CNC Web/WASM simulator whenever evaluating progress or changing LinuxCNC G-code behavior, RS274 source integration, kinematics, M428/M429/M430 remaps, tool data, modal state, parameters, tests, fixtures, build scripts, or bridge code.
---
## 触发条件
目标:对标 LinuxCNC分阶段完善 Web 版数控系统仿真的 WASM 程序,逐步补齐完整功能并严格测试。
# Align LinuxCNC
近期重点:
- 刀补
- 坐标系
- 固定循环
- 五轴 / RTCP
- M428、M429、M430
- 子程序调用
## Mission
实现约束:若 WASM 编译后涉及文件读写,可考虑使用 OPFS 满足文件处理需求。
继续进一步完善程序步步为营。G代码语法与linuxcnc一致。程序主要来源于linuxcnc项目中的源程序。功能和G代码与linuxcnc对标。
Advance the simulator only by aligning it with LinuxCNC source behavior. The
project goal is a LinuxCNC-source-backed Web/WASM CNC simulator, not a
from-scratch compatible interpreter.
## 标准作业程序S.O.P.
严格遵循以下“分析-计划-实现-验证”循环,每一步都要遵循“最小变更原则”。
## Hard Constraints
### 阶段 1差异分析与目标选择
1. **扫描当前代码**:使用 `grep` 或代码导航工具,在 `src/` 目录下寻找已实现的 G/M 代码处理逻辑。
2. **对比 LinuxCNC 源码**:查阅 LinuxCNC 官方仓库中对应的源码文件(如 `src/emc/rs274ngc/rs274ngc_return.hh``interp_execute.cc` 等)。
3. **找出一个差异点**:从以下角度寻找**一个**最微小的差异:
- **数值解析**:如科学计数法、前导零、特殊字符处理。
- **参数范围与处理**:字参数(如 F、S、P 的值域)和表达式参数。
- **错误检查**:缺少某个 LinuxCNC 已实现但本项目尚未实现的 `CHK``CHKS` 校验逻辑。
- **模态状态**:某个 G 代码组内部的状态切换不完全一致。
4. **以书面形式明确目标**:在回复的开始,用一句话清晰说明本次要修复的具体差异点。例如:“**目标对齐科学计数法解析行为。LinuxCNC 不允许 `1e3`,本项目当前会将其解析为 `1000`,需修复为解析失败。**”
- Port-first: prefer direct LinuxCNC source porting, trimming, wrapping, or
platform adaptation over project-authored replacements.
- Do not write independent functional CNC behavior.
- Do not use intuition or documentation as the final behavioral source.
- Before any functional change, locate LinuxCNC source in `../linuxcnc/src` or
`../linuxcnc/configs`.
- Allowed code: LinuxCNC source port/wrap/trim/adaptation, platform shims,
thin wasm/API/event bridges, generated fixtures, tests, build scripts, docs.
- Temporary smoke paths may be tested, but should shrink over time.
- Browser-side WASM filesystem access must use OPFS-backed storage.
### 阶段 2编写测试先写测试
1. **创建失败的测试**:在 `tests/` 或相应目录下,先编写一个能够清晰验证此行为的、**预期会失败**的测试用例。
2. **运行测试以确认失败**:执行 `./test-native.sh`,确保因为新测试而导致整体测试失败,这验证了测试的有效性。
## Work Directory
### 阶段 3实施代码修改小步快跑
1. **定位源码**:找到项目中对应该行为的实现位置。
2. **参考 LinuxCNC 源码实现**:严格模仿 LinuxCNC 源码中的数据结构、算法和函数调用方式来进行修改。
3. **最小化修改**:只改动实现该功能的**最小必要代码行**。严禁“顺便”重构无关代码。
4. **保留接口一致性**:确保修改后的函数签名、返回值和副作用与 LinuxCNC 源码中的对应实现完全一致。
```bash
cd /home/cnc/桌面/cnc/wasm-simulator
git status --short
```
### 阶段 4验证与循环
1. **运行本地测试**:执行 `./test-native.sh`。如果失败,分析错误并修复,直到通过。
2. **运行完整回归测试**:执行 `./test-linuxcnc-source-link.sh`。如果失败,修复到通过为止。
3. **记录与完成**:在回复中简要报告:“差异点 `[目标]` 已修复,测试全部通过。准备进行下一轮分析。”
4. **无条件循环**:报告完成后,**必须立即、自动地**将思维跳转回**阶段 1**,并开始寻找下一个差异点。**严禁在报告完成后停止,除非已达到 AGENTS.md 中定义的中断条件。**
Related roots:
- Project root: `/home/cnc/桌面/cnc`
- LinuxCNC source: `/home/cnc/桌面/cnc/linuxcnc` or `$LINUXCNC_ROOT`
- LinuxCNC unit tests: `/home/cnc/桌面/cnc/linuxcnc/unit_tests`
## Required Checks
For code or generated fixture changes, run:
```bash
./test-native.sh
./test-linuxcnc-source-link.sh
```
For switchkins/remap table changes, also run:
```bash
./check-linuxcnc-switchkins-remap-table.sh linuxcnc-kinematics-source-files.txt
```
## Fast Loop
1. Pick one tiny gap.
2. Find the LinuxCNC source/config/remap.
3. Add or update a source-backed test/fixture.
4. Implement only bridge/shim/wrapper/generator changes.
5. Run required tests.
6. Report percent complete, source basis, changed files, and tests.
## Source Pointers
- RS274: `../linuxcnc/src/emc/rs274ngc/`
- Kinematics: `../linuxcnc/src/emc/kinematics/`
- Tooldata: `../linuxcnc/src/emc/tooldata/`
- Canon: `../linuxcnc/src/emc/nml_intf/canon.hh`
- Sim remaps/configs: `../linuxcnc/configs/sim/`
Useful project docs:
- `docs/linuxcnc-source-policy.md`
- `docs/linuxcnc-porting.md`
- `docs/linuxcnc-rs274-source-map.md`
- `linuxcnc-rs274-source-files.txt`
- `linuxcnc-rs274-wasm-source-files.txt`
- `linuxcnc-kinematics-source-files.txt`
## Current Baseline
Completion estimate: about 72%.
Strong areas: source manifests, native/source-linked RS274 runners, broad
G-code regression corpus, generated M428/M429/M430 switchkins remap fixtures,
Node/browser WASM smoke coverage.
Main remaining risks: smoke parser removal, Python/Boost.Python remap
replacement, dynamic loading shims, tooldata/HAL/filesystem assumptions,
continued source-backed expansion of kinematics/RTCP coverage, and real browser
verification that WASM file reads/writes persist through OPFS.