abapgit-agent 1.7.1 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/.abapGitAgent.example +11 -0
  2. package/README.md +7 -7
  3. package/abap/.github/copilot-instructions.md +254 -0
  4. package/abap/CLAUDE.md +432 -0
  5. package/abap/guidelines/00_index.md +8 -0
  6. package/abap/guidelines/01_sql.md +8 -0
  7. package/abap/guidelines/02_exceptions.md +8 -0
  8. package/abap/guidelines/03_testing.md +8 -0
  9. package/abap/guidelines/04_cds.md +8 -0
  10. package/abap/guidelines/05_classes.md +8 -0
  11. package/abap/guidelines/06_objects.md +8 -0
  12. package/abap/guidelines/07_json.md +8 -0
  13. package/abap/guidelines/08_abapgit.md +8 -0
  14. package/abap/guidelines/09_unit_testable_code.md +8 -0
  15. package/bin/abapgit-agent +61 -2789
  16. package/package.json +25 -5
  17. package/src/agent.js +213 -20
  18. package/src/commands/create.js +102 -0
  19. package/src/commands/delete.js +72 -0
  20. package/src/commands/health.js +24 -0
  21. package/src/commands/help.js +111 -0
  22. package/src/commands/import.js +99 -0
  23. package/src/commands/init.js +321 -0
  24. package/src/commands/inspect.js +184 -0
  25. package/src/commands/list.js +143 -0
  26. package/src/commands/preview.js +277 -0
  27. package/src/commands/pull.js +278 -0
  28. package/src/commands/ref.js +96 -0
  29. package/src/commands/status.js +52 -0
  30. package/src/commands/syntax.js +290 -0
  31. package/src/commands/tree.js +209 -0
  32. package/src/commands/unit.js +133 -0
  33. package/src/commands/view.js +215 -0
  34. package/src/commands/where.js +138 -0
  35. package/src/config.js +11 -1
  36. package/src/utils/abap-http.js +347 -0
  37. package/src/{ref-search.js → utils/abap-reference.js} +119 -1
  38. package/src/utils/git-utils.js +58 -0
  39. package/src/utils/validators.js +72 -0
  40. package/src/utils/version-check.js +80 -0
  41. package/src/abap-client.js +0 -523
@@ -0,0 +1,11 @@
1
+ {
2
+ "host": "your-sap-system.com",
3
+ "sapport": 443,
4
+ "client": "100",
5
+ "user": "TECH_USER",
6
+ "password": "your-password",
7
+ "language": "EN",
8
+ "gitUsername": "github-username",
9
+ "gitPassword": "github-token",
10
+ "referenceFolder": "~/abap-reference"
11
+ }
package/README.md CHANGED
@@ -25,7 +25,7 @@ git clone https://github.com/user/abap-project.git
25
25
  cd abap-project
26
26
 
27
27
  # 3. Initialize configuration
28
- abapgit-agent init --folder /abap/ --package ZMY_PACKAGE
28
+ abapgit-agent init --folder /src/ --package ZMY_PACKAGE
29
29
 
30
30
  # 4. Edit .abapGitAgent with credentials
31
31
 
@@ -47,7 +47,7 @@ See [Creating New ABAP Projects](INSTALL.md#creating-new-abap-projects) to set u
47
47
 
48
48
  ```bash
49
49
  # Initialize local configuration for existing git repo
50
- abapgit-agent init --folder /abap/ --package ZMY_PACKAGE
50
+ abapgit-agent init --folder /src/ --package ZMY_PACKAGE
51
51
 
52
52
  # Create online repository in ABAP
53
53
  abapgit-agent create
@@ -69,7 +69,7 @@ abapgit-agent pull
69
69
  abapgit-agent pull --branch develop
70
70
 
71
71
  # Pull specific files only (fast iteration)
72
- abapgit-agent pull --files zcl_my_class.clas.abap,zif_my_intf.intf.abap
72
+ abapgit-agent pull --files src/zcl_my_class.clas.abap,src/zif_my_intf.intf.abap
73
73
 
74
74
  # Override git URL if needed
75
75
  abapgit-agent pull --url https://github.com/user/repo --branch main
@@ -88,20 +88,20 @@ abapgit-agent import --message "feat: add new feature"
88
88
 
89
89
  ```bash
90
90
  # Inspect source file for issues
91
- abapgit-agent inspect --files abap/zcl_my_class.clas.abap
91
+ abapgit-agent inspect --files src/zcl_my_class.clas.abap
92
92
 
93
93
  # Run AUnit tests for test classes
94
- abapgit-agent unit --files abap/zcl_my_test.clas.testclasses.abap
94
+ abapgit-agent unit --files src/zcl_my_test.clas.testclasses.abap
95
95
 
96
96
  # Run tests for multiple test classes
97
- abapgit-agent unit --files abap/zcl_test1.clas.testclasses.abap,abap/zcl_test2.clas.testclasses.abap
97
+ abapgit-agent unit --files src/zcl_test1.clas.testclasses.abap,src/zcl_test2.clas.testclasses.abap
98
98
  ```
99
99
 
100
100
  ### Explore Commands
101
101
 
102
102
  ```bash
103
103
  # Display package hierarchy tree
104
- abapgit-agent tree --package $MY_PACKAGE
104
+ abapgit-agent tree --package '$MY_PACKAGE'
105
105
 
106
106
  # View object definitions from ABAP system (classes, interfaces, tables, data elements)
107
107
  abapgit-agent view --objects ZCL_MY_CLASS
@@ -0,0 +1,254 @@
1
+ # ABAP Development with abapGit
2
+
3
+ You are working on an ABAP project using abapGit for version control.
4
+
5
+ ---
6
+
7
+ ## Critical Rules
8
+
9
+ ### 1. Use `ref` Command for Unfamiliar Topics
10
+
11
+ **When starting to work on ANY unfamiliar ABAP topic, syntax, or pattern, you MUST use the `ref` command BEFORE writing any code.**
12
+
13
+ ```
14
+ ❌ WRONG: Start writing code immediately based on assumptions
15
+ ✅ CORRECT: Run ref command first to look up the correct pattern
16
+ ```
17
+
18
+ **Why**: ABAP syntax is strict. Guessing leads to activation errors that waste time.
19
+
20
+ | Scenario | Example |
21
+ |----------|---------|
22
+ | Implementing new ABAP feature | "How do I use FILTER operator?" |
23
+ | Unfamiliar pattern | "What's the correct VALUE #() syntax?" |
24
+ | SQL operations | "How to write a proper SELECT with JOIN?" |
25
+ | CDS views | "How to define CDS view with associations?" |
26
+ | Getting syntax errors | Check reference before trying approaches |
27
+
28
+ ```bash
29
+ # For CDS topics
30
+ abapgit-agent ref --topic cds
31
+ abapgit-agent ref "CDS view"
32
+ abapgit-agent ref "association"
33
+ ```
34
+
35
+ ```bash
36
+ # Search for a pattern
37
+ abapgit-agent ref "CORRESPONDING"
38
+ abapgit-agent ref "FILTER #"
39
+
40
+ # Browse by topic
41
+ abapgit-agent ref --topic exceptions
42
+ abapgit-agent ref --topic sql
43
+
44
+ # List all topics
45
+ abapgit-agent ref --list-topics
46
+ ```
47
+
48
+ ### 2. Read `.abapGitAgent` for Folder Location
49
+
50
+ **Before creating ANY ABAP object file, you MUST read `.abapGitAgent` to determine the correct folder.**
51
+
52
+ ```
53
+ ❌ WRONG: Assume files go in "abap/" folder
54
+ ✅ CORRECT: Read .abapGitAgent to get the "folder" property value
55
+ ```
56
+
57
+ The folder is configured in `.abapGitAgent` (property: `folder`):
58
+ - If `folder` is `/src/` → files go in `src/` (e.g., `src/zcl_my_class.clas.abap`)
59
+ - If `folder` is `/abap/` → files go in `abap/` (e.g., `abap/zcl_my_class.clas.abap`)
60
+
61
+ ### 3. Create XML Metadata for Each ABAP Object
62
+
63
+ **Each ABAP object requires an XML metadata file for abapGit to understand how to handle it.**
64
+
65
+ | Object Type | ABAP File (if folder=/src/) | XML File |
66
+ |-------------|------------------------------|----------|
67
+ | Class | `src/zcl_*.clas.abap` | `src/zcl_*.clas.xml` |
68
+ | Interface | `src/zif_*.intf.abap` | `src/zif_*.intf.xml` |
69
+ | Program | `src/z*.prog.abap` | `src/z*.prog.xml` |
70
+ | Table | `src/z*.tabl.abap` | `src/z*.tabl.xml` |
71
+ | CDS View | `src/zc_*.ddls.asddls` | `src/zc_*.ddls.xml` |
72
+
73
+ **Use `ref --topic abapgit` for complete XML templates.**
74
+
75
+ ### 4. Use `unit` Command for Unit Tests
76
+
77
+ **Use `abapgit-agent unit` to run ABAP unit tests (AUnit).**
78
+
79
+ ```
80
+ ❌ WRONG: Try to use SE24 or other transaction codes
81
+ ✅ CORRECT: Use abapgit-agent unit --files src/zcl_test.clas.testclasses.abap
82
+ ```
83
+
84
+ ```bash
85
+ # Run unit tests (after pulling to ABAP)
86
+ abapgit-agent unit --files src/zcl_test.clas.testclasses.abap
87
+ ```
88
+
89
+ ### 5. Use CDS Test Double Framework for CDS View Tests
90
+
91
+ **When creating unit tests for CDS views, use the CDS Test Double Framework (`CL_CDS_TEST_ENVIRONMENT`).**
92
+
93
+ ```
94
+ ❌ WRONG: Use regular AUnit test class without test doubles
95
+ ✅ CORRECT: Use CL_CDS_TEST_ENVIRONMENT to create test doubles for CDS views
96
+ ```
97
+
98
+ **Why**: CDS views read from database tables. Using test doubles allows:
99
+ - Injecting test data without affecting production data
100
+ - Testing specific scenarios that may not exist in production
101
+ - Fast, isolated tests that don't depend on database state
102
+
103
+ See `../guidelines/03_testing.md` for code examples.
104
+
105
+ ---
106
+
107
+ ## Development Workflow
108
+
109
+ ```
110
+ 1. Read .abapGitAgent → get folder value
111
+
112
+
113
+ 2. Research → use ref command for unfamiliar topics
114
+
115
+
116
+ 3. Write code → place in correct folder (e.g., src/zcl_*.clas.abap)
117
+
118
+
119
+ 4. Commit and push → git add . && git commit && git push
120
+
121
+
122
+ 5. Activate → abapgit-agent pull --files src/file.clas.abap
123
+
124
+
125
+ 6. Verify → Check pull output
126
+ - **Do NOT run inspect before commit/push/pull** - ABAP validates on pull
127
+ - **Do NOT run unit before pull** - Tests run against ABAP system, code must be activated first
128
+ - Objects NOT in "Activated Objects" but in "Failed Objects Log" → Syntax error (check inspect)
129
+ - Objects NOT appearing at all → XML metadata issue
130
+
131
+
132
+ 7. (Optional) Run unit tests → abapgit-agent unit --files src/zcl_test.clas.testclasses.abap (ONLY if test file exists, AFTER successful pull)
133
+
134
+
135
+ 8. If needed → Use inspect to check syntax (runs against ABAP system)
136
+ ```
137
+
138
+ **IMPORTANT**:
139
+ - **ALWAYS push to git BEFORE running pull** - abapGit reads from git
140
+ - **Use inspect AFTER pull** to check syntax on objects already in ABAP
141
+ - **Check pull output**:
142
+ - In "Failed Objects Log" → Syntax error (use inspect for details)
143
+ - Not appearing at all → XML metadata is wrong
144
+
145
+ **When to use inspect vs view**:
146
+ - **inspect**: Use when there are SYNTAX ERRORS (to find line numbers and details)
147
+ - **view**: Use when you need to understand an object STRUCTURE (table fields, class methods)
148
+ - Do NOT use view to debug syntax errors - view shows definitions, not errors
149
+
150
+ ### Commands
151
+
152
+ ```bash
153
+ # 1. Pull/activate after pushing to git (abapGit reads from git!)
154
+ abapgit-agent pull --files src/zcl_class1.clas.abap,src/zcl_class2.clas.abap
155
+
156
+ # 2. Inspect AFTER pull to check syntax (runs against ABAP system)
157
+ abapgit-agent inspect --files src/zcl_class1.clas.abap,src/zif_interface1.intf.abap
158
+
159
+ # Run unit tests (multiple test classes)
160
+ abapgit-agent unit --files src/zcl_test1.clas.testclasses.abap,src/zcl_test2.clas.testclasses.abap
161
+
162
+ # View object definitions (multiple objects)
163
+ abapgit-agent view --objects ZCL_CLASS1,ZCL_CLASS2,ZIF_INTERFACE
164
+
165
+ # Preview table data (multiple tables/views)
166
+ abapgit-agent preview --objects ZTABLE1,ZTABLE2
167
+
168
+ # Explore table structures
169
+ abapgit-agent view --objects ZTABLE --type TABL
170
+
171
+ # Display package tree
172
+ abapgit-agent tree --package \$MY_PACKAGE
173
+ ```
174
+
175
+ ---
176
+
177
+ ## Explore Unknown Objects
178
+
179
+ **Before working with unfamiliar objects, use `view` command:**
180
+
181
+ ```bash
182
+ # Check table structure
183
+ abapgit-agent view --objects ZMY_TABLE --type TABL
184
+
185
+ # Check class definition
186
+ abapgit-agent view --objects ZCL_UNKNOWN_CLASS
187
+
188
+ # Check interface
189
+ abapgit-agent view --objects ZIF_UNKNOWN_INTERFACE
190
+
191
+ # Check data element
192
+ abapgit-agent view --objects ZMY_DTEL --type DTEL
193
+ ```
194
+
195
+ AI assistant SHOULD call `view` command when:
196
+ - User asks to "check", "look up", or "explore" an unfamiliar object
197
+ - Working with a table/structure and you don't know the fields
198
+ - Calling a class/interface method and you don't know the parameters
199
+
200
+ ---
201
+
202
+ ## Key ABAP Rules
203
+
204
+ 1. **Global classes MUST use `PUBLIC`**:
205
+ ```abap
206
+ CLASS zcl_my_class DEFINITION PUBLIC. " <- REQUIRED
207
+ ```
208
+
209
+ 2. **Use `/ui2/cl_json` for JSON**:
210
+ ```abap
211
+ DATA ls_data TYPE ty_request.
212
+ ls_data = /ui2/cl_json=>deserialize( json = lv_json ).
213
+ lv_json = /ui2/cl_json=>serialize( data = ls_response ).
214
+ ```
215
+
216
+ 3. **Test class name max 30 chars**: `ltcl_util` (not `ltcl_abgagt_util_test`)
217
+
218
+ 4. **Interface method implementation**: Use prefix `zif_interface~method_name`
219
+
220
+ ---
221
+
222
+ ## Error Handling
223
+
224
+ - **"Error updating where-used list"** → This is a **SYNTAX ERROR** (not a warning!)
225
+ - Use `abapgit-agent inspect --files <file>` for detailed error messages with line numbers
226
+
227
+ ---
228
+
229
+ ## Guidelines Index
230
+
231
+ Detailed guidelines are available in the `guidelines/` folder:
232
+
233
+ | File | Topic |
234
+ |------|-------|
235
+ | `../guidelines/01_sql.md` | ABAP SQL Best Practices |
236
+ | `../guidelines/02_exceptions.md` | Exception Handling |
237
+ | `../guidelines/03_testing.md` | Unit Testing (including CDS) |
238
+ | `../guidelines/04_cds.md` | CDS Views |
239
+ | `../guidelines/05_classes.md` | ABAP Classes and Objects |
240
+ | `../guidelines/06_objects.md` | Object Naming Conventions |
241
+ | `../guidelines/07_json.md` | JSON Handling |
242
+ | `../guidelines/08_abapgit.md` | abapGit XML Metadata Templates |
243
+
244
+ These guidelines are automatically searched by the `ref` command.
245
+
246
+ ---
247
+
248
+ ## Object Naming
249
+
250
+ | Pattern | Type |
251
+ |---------|------|
252
+ | `ZCL_*` | Class |
253
+ | `ZIF_*` | Interface |
254
+ | `Z*` | Other objects |