Files
sap-cli-skill/.hermes/include-uri-fix-spec.md
T
吴让宇 c5905a5b1e refactor: 本仓升为唯一源(原 sap-cli 源码仓归档)
方向反转:此前 SKILL.md 是「模板渲染产物」、sap-cli 是源;现 sap-cli 归档,
sap-cli-skill 承接开发与分发,SKILL.md 回归手工维护的正本。

迁移(来自 sap-cli,共 104 文件):
- tests/           692 例测试(15 个文件的内联 sys.path 改指 assets/)
- openspec/        SDD 规格与归档变更(42 文件)
- docs/            开发文档与 ADT 原理(含 dev/CLAUDE.md、AGENTS.md)
- .claude/         rules 副本 + settings.json(供 Claude Code)
- .github/ .hermes/ .pre-commit-config.yaml .editorconfig CLAUDE.md
- scripts/ 保持仅 setup.py(pack_skill.py 已随旧仓归档,不迁)

修复(迁移暴露的真实缺陷):
- assets/pyproject.toml 的 build-backend 写作 `setuptools.backends._legacy:_Backend`,
  该模块在 setuptools 中不存在 → `pip install -e` 从来装不上。改为 build_meta。
  实测:临时 venv 安装成功,sap-cli --help 正常列出 31 个命令
- pyproject readme 指向不存在的 assets/README.md(editable 安装会失败)→ 改内联文本
- pyproject urls 改指 sap-cli-skill

机制调整:
- .github/workflows/ci.yml 适配 assets/ 布局;顶部注明该工作流仅 GitHub 执行,
  本仓在 Gitee 不会自动跑
- pre-commit 增本地测试门禁(Gitee 上真正生效的那道)
- .gitignore 合并旧仓完整规则(保留 log/ 下 md 知识库入库,只忽略运行日志)
- 大文件上限 100KB→1MB(架构图 512KB)

守卫测试 tests/unit/test_repo_guards.py(10 → 18 例):
- SKILL.md 须记录 parser 全部 CLI 命令 / 铁律 1-5 须为真实小节标题 / 示例不得违反铁律 5
- references/ 规则齐备;.claude/rules 与 references 必须一致(实测抓到一次真实漂移)
- VERSION == sapcli.__version__ == README 版本
- 仓内不得再出现 pack_skill.py / skill-src(防废弃流程回潮)

698 tests OK;editable 安装与 CLI 入口经临时 venv 实测通过。
docs/RELEASING.md 重写为单源开发流程。
2026-09-11 00:40:15 +08:00

90 lines
3.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Spec: 修复 include 类型的 ADT URI 端点
## 问题描述
`download --type include` 在 NW 7.40 上失败,返回"对象不存在"。
## 根因分析
`types.py` 中 INCLUDE 的 URI 模板复用了 REPORT 的端点:
- 当前(错误):`/sap/bc/adt/programs/programs/{name}`
- 正确端点:`/sap/bc/adt/programs/includes/{name}`
NW 7.40 ADT 对 include 和 report 使用不同的 REST 端点:
- report → `/sap/bc/adt/programs/programs/{name}`
- include → `/sap/bc/adt/programs/includes/{name}`
## 已验证的正确端点
| 用途 | URI |
|------|-----|
| metadata (object_exists) | `GET /sap/bc/adt/programs/includes/{name}` Accept: `application/vnd.sap.adt.programs.includes.v2+xml` |
| source (get_source) | `GET /sap/bc/adt/programs/includes/{name}/source/main` Accept: `text/plain` |
## 修改范围
### 文件 1: `sapcli/types.py` (第 130-137 行)
修改前:
```python
INCLUDE = _register(ObjectTypeConfig(
key="include",
label="Include程序(INCLUDE)",
obj_uri_template="/sap/bc/adt/programs/programs/{name}",
src_uri_template="/sap/bc/adt/programs/programs/{name}/source/main",
collection_uri="/sap/bc/adt/programs/programs",
create_content_type="application/vnd.sap.adt.programs.v2+xml",
))
```
修改后:
```python
INCLUDE = _register(ObjectTypeConfig(
key="include",
label="Include程序(INCLUDE)",
obj_uri_template="/sap/bc/adt/programs/includes/{name}",
src_uri_template="/sap/bc/adt/programs/includes/{name}/source/main",
collection_uri="/sap/bc/adt/programs/includes",
create_content_type="application/vnd.sap.adt.programs.includes.v2+xml",
))
```
### 文件 2: `sapcli/client/_base.py` (object_exists 方法)
当前 `object_exists` 使用 `Accept: */*`,对于 include 端点可能需要特定的 Accept header。但根据测试,`*/*` 也能返回 200,所以这个方法可能不需要修改。如果 object_exists 对 include 返回 406,需要改为使用 `application/vnd.sap.adt.programs.includes.v2+xml`
### 文件 3: `sapcli/commands/crud.py`
`cmd_download``cmd_sync` 中有硬编码检查:
```python
if parsed.src_uri is None:
print(f"\n{type_label}没有源代码,不支持 download 操作")
print(f" functiongroup 是函数模块的容器,不包含可编辑的源代码文件")
```
第二行错误提示只适用于 functiongroupinclude 走不到这个分支(因为 src_uri 不是 None),所以不需要修改。
## 验证标准
修改后,以下命令必须能正常工作:
```bash
# 1. 下载 include 源代码
python main.py download --name LZIDT_MCP_TOOLU04 --type include --path /tmp/test
# 2. 下载各种 include
python main.py download --name LZIDT_MCP_TOOLTOP --type include --path /tmp/test
python main.py download --name LZIDT_MCP_TOOLF01 --type include --path /tmp/test
# 3. 确认原有 report 类型不受影响
python main.py download --name ZIDT_MCP_LOG --type report --path /tmp/test
```
## 测试
运行现有测试确保无回归:
```bash
python -m pytest tests/ -v
```
## 约束
- 只修改 `sapcli/types.py` 中的 INCLUDE 配置(4 个 URI 字段)
- 不修改 `_base.py``_source.py` 或其他文件的通用逻辑
- 不引入新的依赖