Files
sap-cli-skill/openspec/changes/archive/2026-06-09-base-core/tasks.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

2.7 KiB

1. Project Scaffolding & Entry Point

  • 1.1 Create main.py entry point with argparse subcommand pattern
  • 1.2 Set up UTF-8 encoding for stdout/stderr
  • 1.3 Set up logging to log/adt_tools.log

2. SAP ADT Connection

  • 2.1 Implement ADTClient with HTTP Basic Auth + CSRF Token
  • 2.2 Support stateful/stateless session modes
  • 2.3 Implement context manager (with ADTClient(...) as client:)
  • 2.4 Disable SSL verification warnings

3. Configuration Loading

  • 3.1 Implement config.ini parsing with ConfigParser
  • 3.2 Support environment variable override (SAP_HOST, SAP_CLIENT, SAP_USER, SAP_PASSWORD)
  • 3.3 Support config file search order (--config → current dir → script dir)
  • 3.4 Default client to "100" when not specified

4. Object Type Registry

  • 4.1 Define ObjectTypeConfig with URI templates, content types, has_source flag
  • 4.2 Register 10 ABAP object types (report, class, interface, function, functiongroup, domain, dataelement, table, structure, tabletype)
  • 4.3 Implement parse_object_name for URI expansion
  • 4.4 Handle function type special naming (GROUP/MODULE format)
  • 4.5 Handle tabletype uppercase naming

5. Download Command

  • 5.1 Implement object existence check (HEAD/GET)
  • 5.2 Implement source code download with LF normalization
  • 5.3 Auto-create output directory
  • 5.4 Print source code preview (first 20 lines)

6. Sync Command

  • 6.1 Implement full pipeline: lock → write → unlock → syntax check → activate
  • 6.2 Auto-create object when not exists
  • 6.3 Support --corr_nr for transport request binding
  • 6.4 Handle lock failure with transport request selection
  • 6.5 Report progress per step with ✓/✗ indicators

7. Create Command

  • 7.1 Implement default template generation per type
  • 7.2 Support --source for custom source code
  • 7.3 Support --definition for DDIC JSON definitions
  • 7.4 Support --corr_nr for transport request in creation
  • 7.5 Support --path for project manifest update

8. Info Command

  • 8.1 Query object metadata via ADT GET
  • 8.2 Parse ADT core XML for name, type, description, status, author
  • 8.3 Validate response name matches request name
  • 8.4 Display status as ✓ 已激活 or ⚠️ 未激活

9. Delete Command

  • 9.1 Check object existence before deletion
  • 9.2 Require user "yes" confirmation
  • 9.3 Execute lock → DELETE → unlock flow
  • 9.4 Support --path for manifest update

10. Error Handling

  • 10.1 Define unified exception hierarchy (SapCliError base + 11 subtypes)
  • 10.2 Exit with code 1 and user-friendly message on SapCliError