v2.3.0: 标准工作流 + NW740错误模式 + Gitee仓库规范 + 错误知识库引用
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
name: sap-cli
|
name: sap-cli
|
||||||
description: "SAP ABAP ADT CLI for AI agents. Trigger when: operating ABAP objects, syncing code to/from SAP, managing transports, querying DDIC, running ABAP programs, reading SAP tables, or any SAP development task via terminal."
|
description: "SAP ABAP ADT CLI for AI agents. Trigger when: operating ABAP objects, syncing code to/from SAP, managing transports, querying DDIC, running ABAP programs, reading SAP tables, or any SAP development task via terminal."
|
||||||
version: "2.2.1"
|
version: "2.3.0"
|
||||||
author: WuRangyu
|
author: WuRangyu
|
||||||
license: MIT
|
license: MIT
|
||||||
triggers:
|
triggers:
|
||||||
@@ -41,7 +41,7 @@ Global params (before command): `--profile <name>`, `--verify-ssl`. Optional par
|
|||||||
| Category | Command | Key Parameters |
|
| Category | Command | Key Parameters |
|
||||||
|----------|---------|----------------|
|
|----------|---------|----------------|
|
||||||
| CRUD | `create` | `--name --type [--description --source <.abap> --definition <.json> --package <$TMP> --corr_nr]` |
|
| CRUD | `create` | `--name --type [--description --source <.abap> --definition <.json> --package <$TMP> --corr_nr]` |
|
||||||
| CRUD | `info` | `--name --type` |
|
| CRUD | `info` | `--name --type` [^1] |
|
||||||
| CRUD | `download` | `--name --type --path` |
|
| CRUD | `download` | `--name --type --path` |
|
||||||
| CRUD | `sync` | `--name --type --path --corr_nr` **(REQUIRED)** |
|
| CRUD | `sync` | `--name --type --path --corr_nr` **(REQUIRED)** |
|
||||||
| CRUD | `delete` | `--name --type` |
|
| CRUD | `delete` | `--name --type` |
|
||||||
@@ -73,6 +73,8 @@ Global params (before command): `--profile <name>`, `--verify-ssl`. Optional par
|
|||||||
| Other | `cds download` | `--name --path` |
|
| Other | `cds download` | `--name --path` |
|
||||||
| Other | `scaffold` | `--name --template <t>` — alv-report, bapi-wrapper, interface-class, data-model |
|
| Other | `scaffold` | `--name --template <t>` — alv-report, bapi-wrapper, interface-class, data-model |
|
||||||
|
|
||||||
|
[^1]: ⚠️ `info` 不返回 `package`/`packageRef` 字段。需通过 ADT API 查询:`GET /sap/bc/adt/programs/programs/<name>` 返回 XML 中含 `<adtcore:packageRef>`。也可用 `list --package <pkg>` 反向查找。
|
||||||
|
|
||||||
Batch sync dependency order: `domain(10) → dataelement(20) → table(30) → tabletype(40) → interface(50) → class(60) → function(70) → report(80)`.
|
Batch sync dependency order: `domain(10) → dataelement(20) → table(30) → tabletype(40) → interface(50) → class(60) → function(70) → report(80)`.
|
||||||
|
|
||||||
Step-wise sync for lock-heavy automation — split the atomic `sync` when lock conflicts are frequent; upload now, verify, activate later:
|
Step-wise sync for lock-heavy automation — split the atomic `sync` when lock conflicts are frequent; upload now, verify, activate later:
|
||||||
@@ -99,6 +101,7 @@ python main.py activate --name ZMY_CLASS --type class --corr_nr DEVK901XXX
|
|||||||
## ⚠️ Constraints (HARD RULES — DO NOT VIOLATE)
|
## ⚠️ Constraints (HARD RULES — DO NOT VIOLATE)
|
||||||
|
|
||||||
Full rules: `references/sap-tool-constraints.md`. Violations are intercepted by hooks.
|
Full rules: `references/sap-tool-constraints.md`. Violations are intercepted by hooks.
|
||||||
|
质检标准: `references/abap-coding-rules.md`(28条规则,6大类:安全/性能/可维护性/错误处理/NW740兼容/风格)。质检员在代码审计时以此文档为唯一标准,判定体系:✅合规 / ❌违反(必须修复) / ⚠️建议(推荐修复)。
|
||||||
|
|
||||||
1. **Only `python main.py <cmd>` touches SAP** — no `requests`/`urllib`, no curl to ADT/SOAP/RFC, no `python -c` inline, no importing `ADTClient` internals, no hand-built ADT XML. Exceptions: `run-program` custom reports, explicit user request, or developing sap-cli itself.
|
1. **Only `python main.py <cmd>` touches SAP** — no `requests`/`urllib`, no curl to ADT/SOAP/RFC, no `python -c` inline, no importing `ADTClient` internals, no hand-built ADT XML. Exceptions: `run-program` custom reports, explicit user request, or developing sap-cli itself.
|
||||||
2. **Never modify SAP standard objects** (`CL_*`, `CX_*`, `IF_*`, `SAPL*`, or any non-user original system) — read-only only: download/info/list/search/whereused/show-table/read-table/diff. When unsure, ask the user.
|
2. **Never modify SAP standard objects** (`CL_*`, `CX_*`, `IF_*`, `SAPL*`, or any non-user original system) — read-only only: download/info/list/search/whereused/show-table/read-table/diff. When unsure, ask the user.
|
||||||
@@ -107,8 +110,87 @@ Full rules: `references/sap-tool-constraints.md`. Violations are intercepted by
|
|||||||
5. **Non-interactive `delete` needs piped confirm** — `echo "yes" | python main.py delete ...` (else EOFError).
|
5. **Non-interactive `delete` needs piped confirm** — `echo "yes" | python main.py delete ...` (else EOFError).
|
||||||
6. **DDIC `sync` failure on NW 7.40 (HTTP 406) is a system limit** — do not retry; report to the user for SE09.
|
6. **DDIC `sync` failure on NW 7.40 (HTTP 406) is a system limit** — do not retry; report to the user for SE09.
|
||||||
|
|
||||||
|
## 🔄 Standard Workflow(SAP 对象操作标准流程)
|
||||||
|
|
||||||
|
> 所有 SAP 对象修改操作必须按此顺序执行,不得跳过或调整步骤顺序。
|
||||||
|
|
||||||
|
```
|
||||||
|
步骤1 info — 确认程序存在、已激活、关联请求号
|
||||||
|
├─ 有请求号 → 记录
|
||||||
|
└─ 无请求号 → transport list 找老板的请求号推荐
|
||||||
|
→ 无合适的则帮老板新建(含请求描述)
|
||||||
|
|
||||||
|
步骤2 download — 源码下载到本地
|
||||||
|
|
||||||
|
步骤3 五角色流水线:研究员 → 创作者 → 质检 → 老板批准
|
||||||
|
|
||||||
|
步骤4 建 Gitee 仓库(ADT 层级:src/包/类型/对象/)+ 同步确认请求号
|
||||||
|
└─ 请求号写入 doc 文档
|
||||||
|
|
||||||
|
步骤5 工程师改代码(本地,不 commit)
|
||||||
|
|
||||||
|
步骤6 请求号绑定对象(如 SE09 未自动绑定)
|
||||||
|
|
||||||
|
步骤7 sync --corr_nr → 语法检查 → 迭代修复 → 激活成功
|
||||||
|
└─ 全程带请求号,不要到编译阶段才关联
|
||||||
|
|
||||||
|
步骤8 激活成功 → git commit + tag → push
|
||||||
|
└─ git = 细粒度变更追溯 / 请求号 = 系统大版本管理
|
||||||
|
```
|
||||||
|
|
||||||
|
**核心原则:**
|
||||||
|
- info 同时查请求号,不单独处理
|
||||||
|
- 建 Gitee 仓库同时确认请求号,不滞后
|
||||||
|
- sync 全程带 `--corr_nr`,不等编译阶段补
|
||||||
|
- 只有激活成功才 git commit,不是每次本地改就提交
|
||||||
|
- git 管变更细节,请求号管系统大版本
|
||||||
|
|
||||||
|
## 📦 Gitee仓库规范
|
||||||
|
|
||||||
|
### 目录结构(ADT 层级)
|
||||||
|
|
||||||
|
每个 SAP 项目的 Gitee 仓库按 ADT 层级组织源码:
|
||||||
|
|
||||||
|
```
|
||||||
|
sap-<project-name>/
|
||||||
|
├── src/
|
||||||
|
│ └── <package>/ # SAP 包名(如 $ZIDTR)
|
||||||
|
│ ├── report/ # 程序类型目录
|
||||||
|
│ │ └── ZXXX.abap # ABAP 源码(.abap 扩展名)
|
||||||
|
│ ├── class/
|
||||||
|
│ │ └── ZCL_XXX.abap
|
||||||
|
│ ├── interface/
|
||||||
|
│ │ └── ZIF_XXX.abap
|
||||||
|
│ ├── function/
|
||||||
|
│ │ └── ZGROUP_ZFUNC.abap
|
||||||
|
│ ├── domain/
|
||||||
|
│ ├── dataelement/
|
||||||
|
│ ├── table/
|
||||||
|
│ └── ...
|
||||||
|
├── doc/ # 文档(请求号记录、设计说明)
|
||||||
|
│ └── transport-<corr_nr>.md # 每次传输的请求号记录
|
||||||
|
├── references/ # 参照文档
|
||||||
|
└── log/ # 错误知识库
|
||||||
|
```
|
||||||
|
|
||||||
|
### 请求号同步确认
|
||||||
|
|
||||||
|
1. **创建仓库时**:确认传输请求号(`transport list` 或 `transport info --corr_nr DEVK9XXXXX`),写入 `doc/transport-<corr_nr>.md`
|
||||||
|
2. **每次 sync 前**:确认请求号仍有效(未释放、未满),检查 `transport objects --corr_nr DEVK9XXXXX` 确保对象已绑定
|
||||||
|
3. **激活成功后**:更新 `doc/` 记录本次变更摘要
|
||||||
|
4. **仓库命名建议**:`sap-<package-name>`,小写、hyphen 分隔,如 `sap-zidtradmin`
|
||||||
|
|
||||||
|
### Git 提交时机
|
||||||
|
|
||||||
|
- **只有 `sync` 激活成功后才 git commit**,不是每次本地修改就提交
|
||||||
|
- commit message 包含:对象名 + 请求号 + 变更摘要
|
||||||
|
- tag 使用请求号命名:`DEVK9XXXXX`
|
||||||
|
- git 管变更细节追溯,请求号管系统大版本管理
|
||||||
|
|
||||||
## Error Handling (Quick Reference)
|
## Error Handling (Quick Reference)
|
||||||
|
|
||||||
|
错误知识库: `log/` 目录(LLM-WIKI 格式),每个错误独立一页。**先查 log/,再查 `references/error-handling.md`**。新错误按 `log/SCHEMA.md` 规范入库。
|
||||||
|
|
||||||
Full flow: `references/error-handling.md`.
|
Full flow: `references/error-handling.md`.
|
||||||
|
|
||||||
| Error Pattern | Action |
|
| Error Pattern | Action |
|
||||||
@@ -118,7 +200,9 @@ Full flow: `references/error-handling.md`.
|
|||||||
| HTTP 400 (SaveFailure) | Class DEFINITION mismatch — diff local vs SAP source |
|
| HTTP 400 (SaveFailure) | Class DEFINITION mismatch — diff local vs SAP source |
|
||||||
| HTTP 404 (DDIC download/sync) | NW 7.40 has no `/source/main` endpoint (7.50+) — DDIC objects only create/info/delete |
|
| HTTP 404 (DDIC download/sync) | NW 7.40 has no `/source/main` endpoint (7.50+) — DDIC objects only create/info/delete |
|
||||||
| HTTP 423 (Transport lock) | Object bound to transport — report to user → SE09 |
|
| HTTP 423 (Transport lock) | Object bound to transport — report to user → SE09 |
|
||||||
|
| HTTP 500 (set_source) | Lock 成功但写入 500,传输请求中无对象 → SE09 手动添加对象到请求 → `log/adt-set-source-500.md` |
|
||||||
| Activate fails, still inactive | double-activate built-in; still fails → report → SE09 |
|
| Activate fails, still inactive | double-activate built-in; still fails → report → SE09 |
|
||||||
|
| Open SQL @ 转义不一致 | 语法检查 2 错误——一处用 `@` 则全局必须一致(`WHERE field = @lv_var` → `INTO TABLE @lt_data`) → `log/adt-nw740-open-sql-consistency.md` |
|
||||||
| `WITH EMPTY KEY` dump | NW 7.40 unsupported — use `WITH NON-UNIQUE KEY` / `WITH DEFAULT KEY` |
|
| `WITH EMPTY KEY` dump | NW 7.40 unsupported — use `WITH NON-UNIQUE KEY` / `WITH DEFAULT KEY` |
|
||||||
| Function name error | Missing `/` separator — use `ZGROUP/Z_FUNC` |
|
| Function name error | Missing `/` separator — use `ZGROUP/Z_FUNC` |
|
||||||
| EOFError on delete | Non-interactive — prepend `echo "yes" \|` |
|
| EOFError on delete | Non-interactive — prepend `echo "yes" \|` |
|
||||||
@@ -133,9 +217,9 @@ Automation fallbacks — exhaust in order before requesting any SAP GUI action:
|
|||||||
|
|
||||||
- **Never bypass sap-cli** (no requests / curl / ADTClient) — report the failure and its cause.
|
- **Never bypass sap-cli** (no requests / curl / ADTClient) — report the failure and its cause.
|
||||||
- **Give the complete change checklist at once** — do the full comparison first (`show-table` vs code field refs); never surface issues incrementally.
|
- **Give the complete change checklist at once** — do the full comparison first (`show-table` vs code field refs); never surface issues incrementally.
|
||||||
- **System-table writes** — 4-step authorization: explain reason → list exact statements → state risks & alternatives → await explicit approval.
|
- **System-table writes** — 4-step authorization: explain *** → list exact statements → state risks & alternatives → await explicit approval.
|
||||||
|
|
||||||
## NW 7.40 Compatibility (E2E verified — v2.2.1)
|
## NW 7.40 Compatibility (E2E verified — v2.3.0)
|
||||||
|
|
||||||
Full matrix: `docs/NW740-COMPATIBILITY.md`.
|
Full matrix: `docs/NW740-COMPATIBILITY.md`.
|
||||||
|
|
||||||
@@ -149,4 +233,6 @@ NW 7.40 specifics:
|
|||||||
- **DDIC Lock** — `delete` fixed (dedicated Accept header); `sync` still 406.
|
- **DDIC Lock** — `delete` fixed (dedicated Accept header); `sync` still 406.
|
||||||
- **Activation false-negative** — first activate may report failure but actually succeed; double-activate is built in.
|
- **Activation false-negative** — first activate may report failure but actually succeed; double-activate is built in.
|
||||||
- **ABAP syntax limits** — no string templates `\|...\|`, no inline `DATA(...)`, no `WITH EMPTY KEY`.
|
- **ABAP syntax limits** — no string templates `\|...\|`, no inline `DATA(...)`, no `WITH EMPTY KEY`.
|
||||||
|
- **Open SQL @ 转义一致性** — NW 7.40 要求一处用 `@` 则全 SQL 必须一致(`WHERE field = @lv_var` → `INTO TABLE @lt_data`),混用导致语法检查 2 错误。详见 `log/adt-nw740-open-sql-consistency.md`。
|
||||||
|
- **set_source HTTP 500(传输请求无对象)** — Lock 成功但写入 500,根因:Lock API 创建锁句柄但未绑定对象到传输请求。NW 7.40 需 SE09 手动添加对象。详见 `log/adt-set-source-500.md`。
|
||||||
- **CSRF token** — all writes require it; sap-cli handles automatically.
|
- **CSRF token** — all writes require it; sap-cli handles automatically.
|
||||||
|
|||||||
Reference in New Issue
Block a user