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 重写为单源开发流程。
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
schema: spec-driven
|
||||
change: base-core
|
||||
status: archived
|
||||
archived_at: "2026-06-09"
|
||||
@@ -0,0 +1,31 @@
|
||||
# Proposal: sap-cli 核心基础 — 连接与 CRUD
|
||||
|
||||
## Why
|
||||
|
||||
ABAP 开发者长期依赖 SAP GUI 进行日常开发,需要在 IDE 和 GUI 之间频繁切换。sap-cli 的目标是让开发者用自己喜欢的本地编辑器写 ABAP 代码,通过命令行完成与 SAP 的交互。首先需要建立可靠的基础:连接 SAP 系统、加载配置,并实现开发对象的基本 CRUD 操作。
|
||||
|
||||
## What Changes
|
||||
|
||||
- 通过 SAP ADT REST API 建立连接与身份认证(HTTP Basic Auth + CSRF Token)
|
||||
- 支持 config.ini 和环境变量两种配置方式
|
||||
- 实现 10 种 ABAP 开发对象类型的完整 CRUD:
|
||||
- 源码对象:report、class、interface、function
|
||||
- DDIC 对象:domain、dataelement、table、structure、tabletype
|
||||
- 特殊对象:functiongroup(无源码)
|
||||
- sync 命令实现锁定→写入→解锁→语法检查→激活的完整工作流
|
||||
- create 支持默认模板和自定义源码两种方式
|
||||
- DDIC 对象支持通过 JSON 定义文件创建
|
||||
- delete 操作需要用户交互确认
|
||||
|
||||
## Capabilities
|
||||
|
||||
### New Capabilities
|
||||
- `connection`: SAP ADT 连接建立、认证、配置加载
|
||||
- `object-lifecycle`: 10 种开发对象的创建、下载、同步、查询、删除
|
||||
|
||||
## Impact
|
||||
|
||||
- 建立 sap-cli 的核心架构:main.py → ADTClient → SAP ADT REST API
|
||||
- 定义 10 种对象类型的统一注册表(types.py)
|
||||
- 建立统一异常体系(11 个错误类型)
|
||||
- 为后续批量操作、搜索浏览等功能奠定基础
|
||||
@@ -0,0 +1,45 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: User Authentication
|
||||
|
||||
系统 SHALL 通过 SAP ADT REST API 使用 HTTP Basic Auth 进行身份认证。
|
||||
|
||||
#### Scenario: Successful login
|
||||
- **WHEN** 用户提供有效的 SAP 主机地址、客户端编号、用户名和密码
|
||||
- **THEN** 系统打印 "登录成功" 并建立可用会话
|
||||
|
||||
#### Scenario: Login failure
|
||||
- **WHEN** 用户提供了无效的 SAP 凭据
|
||||
- **THEN** 系统打印错误信息并以非零退出码退出
|
||||
|
||||
#### Scenario: Config not found
|
||||
- **WHEN** 用户未提供配置文件且未设置环境变量
|
||||
- **THEN** 系统打印配置缺失提示,列出需要的环境变量名,并以非零退出码退出
|
||||
|
||||
### Requirement: Configuration Loading
|
||||
|
||||
系统 SHALL 支持 config.ini 文件和环境变量两种配置方式,环境变量优先。
|
||||
|
||||
#### Scenario: Load from config file
|
||||
- **WHEN** 当前目录或指定路径存在有效的 config.ini
|
||||
- **THEN** 系统从配置文件读取 SAP 连接参数
|
||||
|
||||
#### Scenario: Environment variable override
|
||||
- **WHEN** 同时存在配置文件和环境变量
|
||||
- **THEN** 环境变量值覆盖配置文件中的对应项
|
||||
|
||||
#### Scenario: Client number default
|
||||
- **WHEN** 配置中未指定 SAP 客户端编号
|
||||
- **THEN** 系统使用默认值 "100"
|
||||
|
||||
### Requirement: Global Options
|
||||
|
||||
系统 SHALL 支持全局命令行选项。
|
||||
|
||||
#### Scenario: Custom config path
|
||||
- **WHEN** 用户通过 --config 指定配置文件路径
|
||||
- **THEN** 系统从指定路径加载配置
|
||||
|
||||
#### Scenario: No command specified
|
||||
- **WHEN** 用户运行程序但未指定任何子命令
|
||||
- **THEN** 系统打印帮助信息并以退出码 1 退出
|
||||
@@ -0,0 +1,93 @@
|
||||
## ADDED Requirements
|
||||
|
||||
### Requirement: Object Creation
|
||||
|
||||
系统 SHALL 在 SAP 系统中创建开发对象,支持 10 种 ABAP 对象类型。
|
||||
|
||||
#### Scenario: Create with default template
|
||||
- **WHEN** 用户执行 create 命令,指定对象名称和类型,未提供自定义源码
|
||||
- **THEN** 系统使用内置模板生成源码并在 SAP 中创建对象
|
||||
|
||||
#### Scenario: Create with custom source file
|
||||
- **WHEN** 用户通过 --source 参数指定本地 .abap 文件
|
||||
- **THEN** 系统读取文件内容作为源码并在 SAP 中创建对象
|
||||
|
||||
#### Scenario: Create DDIC object with definition
|
||||
- **WHEN** 用户通过 --definition 参数指定 .json 文件创建 DDIC 对象
|
||||
- **THEN** 系统将 JSON 定义转换为 SAP 所需格式并创建对象
|
||||
|
||||
#### Scenario: Create already existing object
|
||||
- **WHEN** SAP 系统中已存在同名同类型对象
|
||||
- **THEN** 系统报告对象已存在的错误
|
||||
|
||||
### Requirement: Source Code Download
|
||||
|
||||
系统 SHALL 从 SAP 系统下载对象源代码并保存到本地文件。
|
||||
|
||||
#### Scenario: Download existing object
|
||||
- **WHEN** 用户执行 download 命令,SAP 系统存在该对象
|
||||
- **THEN** 系统下载源码,保存到指定目录,文件名为小写对象名+.abap
|
||||
|
||||
#### Scenario: Download non-existent object
|
||||
- **WHEN** 用户执行 download 命令,SAP 系统不存在该对象
|
||||
- **THEN** 系统报告对象不存在的错误
|
||||
|
||||
#### Scenario: Download function type
|
||||
- **WHEN** 用户下载 function 类型,名称格式为 "组名/模块名"
|
||||
- **THEN** 系统正确解析组名和模块名,下载函数模块源码
|
||||
|
||||
#### Scenario: Download type without source
|
||||
- **WHEN** 用户尝试下载不支持源码的类型(如 functiongroup)
|
||||
- **THEN** 系统报告该类型不支持下载操作
|
||||
|
||||
### Requirement: Source Code Sync
|
||||
|
||||
系统 SHALL 将本地源代码同步到 SAP 系统,执行锁定→写入→解锁→语法检查→激活流程。
|
||||
|
||||
#### Scenario: Full sync success
|
||||
- **WHEN** 用户执行 sync 命令,本地文件和 SAP 对象均有效
|
||||
- **THEN** 系统依次执行各步骤,每步报告 ✓ 状态
|
||||
|
||||
#### Scenario: Auto-create on sync
|
||||
- **WHEN** 用户同步一个 SAP 中不存在的对象
|
||||
- **THEN** 系统自动创建空对象后继续同步流程
|
||||
|
||||
#### Scenario: Syntax check failure
|
||||
- **WHEN** 源码包含语法错误
|
||||
- **THEN** 系统报告语法错误详情(行号和描述),不继续激活
|
||||
|
||||
#### Scenario: Activation failure
|
||||
- **WHEN** 语法检查通过但激活失败
|
||||
- **THEN** 系统报告激活错误详情
|
||||
|
||||
#### Scenario: Sync with specified transport request
|
||||
- **WHEN** 用户通过 --corr_nr 指定传输请求号
|
||||
- **THEN** 系统在锁定和写入时使用该传输请求
|
||||
|
||||
### Requirement: Object Information Query
|
||||
|
||||
系统 SHALL 查询 SAP 系统中开发对象的元数据信息。
|
||||
|
||||
#### Scenario: Query existing object
|
||||
- **WHEN** 用户执行 info 命令,SAP 系统存在该对象
|
||||
- **THEN** 系统显示名称、类型、描述、激活状态、负责人、修改时间等元数据
|
||||
|
||||
#### Scenario: Query non-existent object
|
||||
- **WHEN** 用户执行 info 命令,SAP 系统不存在该对象
|
||||
- **THEN** 系统报告对象不存在的错误
|
||||
|
||||
### Requirement: Object Deletion
|
||||
|
||||
系统 SHALL 从 SAP 系统中删除开发对象。
|
||||
|
||||
#### Scenario: Delete with confirmation
|
||||
- **WHEN** 用户执行 delete 命令并确认删除
|
||||
- **THEN** 系统锁定、删除对象并报告成功
|
||||
|
||||
#### Scenario: Delete cancelled
|
||||
- **WHEN** 用户执行 delete 命令但未确认
|
||||
- **THEN** 系统取消操作,不执行删除
|
||||
|
||||
#### Scenario: Delete non-existent object
|
||||
- **WHEN** 用户尝试删除 SAP 中不存在的对象
|
||||
- **THEN** 系统报告对象不存在的错误
|
||||
@@ -0,0 +1,69 @@
|
||||
## 1. Project Scaffolding & Entry Point
|
||||
|
||||
- [x] 1.1 Create main.py entry point with argparse subcommand pattern
|
||||
- [x] 1.2 Set up UTF-8 encoding for stdout/stderr
|
||||
- [x] 1.3 Set up logging to log/adt_tools.log
|
||||
|
||||
## 2. SAP ADT Connection
|
||||
|
||||
- [x] 2.1 Implement ADTClient with HTTP Basic Auth + CSRF Token
|
||||
- [x] 2.2 Support stateful/stateless session modes
|
||||
- [x] 2.3 Implement context manager (`with ADTClient(...) as client:`)
|
||||
- [x] 2.4 Disable SSL verification warnings
|
||||
|
||||
## 3. Configuration Loading
|
||||
|
||||
- [x] 3.1 Implement config.ini parsing with ConfigParser
|
||||
- [x] 3.2 Support environment variable override (SAP_HOST, SAP_CLIENT, SAP_USER, SAP_PASSWORD)
|
||||
- [x] 3.3 Support config file search order (--config → current dir → script dir)
|
||||
- [x] 3.4 Default client to "100" when not specified
|
||||
|
||||
## 4. Object Type Registry
|
||||
|
||||
- [x] 4.1 Define ObjectTypeConfig with URI templates, content types, has_source flag
|
||||
- [x] 4.2 Register 10 ABAP object types (report, class, interface, function, functiongroup, domain, dataelement, table, structure, tabletype)
|
||||
- [x] 4.3 Implement parse_object_name for URI expansion
|
||||
- [x] 4.4 Handle function type special naming (GROUP/MODULE format)
|
||||
- [x] 4.5 Handle tabletype uppercase naming
|
||||
|
||||
## 5. Download Command
|
||||
|
||||
- [x] 5.1 Implement object existence check (HEAD/GET)
|
||||
- [x] 5.2 Implement source code download with LF normalization
|
||||
- [x] 5.3 Auto-create output directory
|
||||
- [x] 5.4 Print source code preview (first 20 lines)
|
||||
|
||||
## 6. Sync Command
|
||||
|
||||
- [x] 6.1 Implement full pipeline: lock → write → unlock → syntax check → activate
|
||||
- [x] 6.2 Auto-create object when not exists
|
||||
- [x] 6.3 Support --corr_nr for transport request binding
|
||||
- [x] 6.4 Handle lock failure with transport request selection
|
||||
- [x] 6.5 Report progress per step with ✓/✗ indicators
|
||||
|
||||
## 7. Create Command
|
||||
|
||||
- [x] 7.1 Implement default template generation per type
|
||||
- [x] 7.2 Support --source for custom source code
|
||||
- [x] 7.3 Support --definition for DDIC JSON definitions
|
||||
- [x] 7.4 Support --corr_nr for transport request in creation
|
||||
- [x] 7.5 Support --path for project manifest update
|
||||
|
||||
## 8. Info Command
|
||||
|
||||
- [x] 8.1 Query object metadata via ADT GET
|
||||
- [x] 8.2 Parse ADT core XML for name, type, description, status, author
|
||||
- [x] 8.3 Validate response name matches request name
|
||||
- [x] 8.4 Display status as ✓ 已激活 or ⚠️ 未激活
|
||||
|
||||
## 9. Delete Command
|
||||
|
||||
- [x] 9.1 Check object existence before deletion
|
||||
- [x] 9.2 Require user "yes" confirmation
|
||||
- [x] 9.3 Execute lock → DELETE → unlock flow
|
||||
- [x] 9.4 Support --path for manifest update
|
||||
|
||||
## 10. Error Handling
|
||||
|
||||
- [x] 10.1 Define unified exception hierarchy (SapCliError base + 11 subtypes)
|
||||
- [x] 10.2 Exit with code 1 and user-friendly message on SapCliError
|
||||
Reference in New Issue
Block a user