abapgit-agent 1.1.6 → 1.3.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 (46) hide show
  1. package/.github/workflows/release.yml +3 -1
  2. package/API.md +261 -0
  3. package/CLAUDE.md +384 -0
  4. package/README.md +16 -2
  5. package/RELEASE_NOTES.md +93 -8
  6. package/abap/CLAUDE.md +282 -6
  7. package/abap/copilot-instructions.md +79 -0
  8. package/abap/zcl_abgagt_agent.clas.abap +2 -2
  9. package/abap/zcl_abgagt_cmd_factory.clas.abap +2 -0
  10. package/abap/zcl_abgagt_command_inspect.clas.abap +255 -36
  11. package/abap/zcl_abgagt_command_tree.clas.abap +237 -0
  12. package/abap/zcl_abgagt_command_tree.clas.xml +15 -0
  13. package/abap/zcl_abgagt_command_view.clas.abap +240 -0
  14. package/abap/zcl_abgagt_command_view.clas.xml +15 -0
  15. package/abap/zcl_abgagt_resource_tree.clas.abap +70 -0
  16. package/abap/zcl_abgagt_resource_tree.clas.xml +15 -0
  17. package/abap/zcl_abgagt_resource_view.clas.abap +68 -0
  18. package/abap/zcl_abgagt_resource_view.clas.xml +15 -0
  19. package/abap/zcl_abgagt_rest_handler.clas.abap +2 -0
  20. package/abap/zcl_abgagt_util.clas.abap +2 -2
  21. package/abap/zcl_abgagt_viewer_clas.clas.abap +58 -0
  22. package/abap/zcl_abgagt_viewer_clas.clas.xml +15 -0
  23. package/abap/zcl_abgagt_viewer_ddls.clas.abap +83 -0
  24. package/abap/zcl_abgagt_viewer_ddls.clas.xml +15 -0
  25. package/abap/zcl_abgagt_viewer_dtel.clas.abap +98 -0
  26. package/abap/zcl_abgagt_viewer_dtel.clas.xml +15 -0
  27. package/abap/zcl_abgagt_viewer_factory.clas.abap +41 -0
  28. package/abap/zcl_abgagt_viewer_factory.clas.xml +15 -0
  29. package/abap/zcl_abgagt_viewer_intf.clas.abap +58 -0
  30. package/abap/zcl_abgagt_viewer_intf.clas.xml +15 -0
  31. package/abap/zcl_abgagt_viewer_stru.clas.abap +59 -0
  32. package/abap/zcl_abgagt_viewer_stru.clas.xml +15 -0
  33. package/abap/zcl_abgagt_viewer_tabl.clas.abap +59 -0
  34. package/abap/zcl_abgagt_viewer_tabl.clas.xml +15 -0
  35. package/abap/zcl_abgagt_viewer_ttyp.clas.abap +93 -0
  36. package/abap/zcl_abgagt_viewer_ttyp.clas.xml +15 -0
  37. package/abap/zif_abgagt_command.intf.abap +3 -1
  38. package/abap/zif_abgagt_viewer.intf.abap +12 -0
  39. package/abap/zif_abgagt_viewer.intf.xml +15 -0
  40. package/bin/abapgit-agent +605 -38
  41. package/docs/commands.md +27 -8
  42. package/docs/tree-command.md +303 -0
  43. package/docs/view-command.md +501 -0
  44. package/package.json +1 -1
  45. package/src/abap-client.js +22 -0
  46. package/src/agent.js +27 -0
package/abap/CLAUDE.md CHANGED
@@ -23,16 +23,68 @@ This is an ABAP project. **Do not attempt local syntax validation** - ABAP code
23
23
  4. **"Error updating where-used list" = SYNTAX ERROR** - This is NOT a warning!
24
24
  5. If Failed Objects > 0, there are syntax errors - fix them before proceeding
25
25
 
26
+ ## Inspect Command (Syntax Check)
27
+
28
+ Use the `inspect` command to perform syntax validation on ABAP objects and CDS views.
29
+
30
+ ### Usage
31
+ ```bash
32
+ # Syntax check single file
33
+ abapgit-agent inspect --files abap/zcl_my_class.clas.abap
34
+
35
+ # Syntax check multiple files
36
+ abapgit-agent inspect --files abap/zcl_class1.clas.abap,abap/zcl_class2.clas.abap
37
+
38
+ # Syntax check CDS view
39
+ abapgit-agent inspect --files abap/zc_my_view.ddls.asddls
40
+ ```
41
+
42
+ ### Supported Object Types
43
+
44
+ | Type | Description | Validation Method |
45
+ |------|-------------|------------------|
46
+ | CLAS | Class | Code Inspector (SCI) |
47
+ | INTF | Interface | Code Inspector (SCI) |
48
+ | PROG | Program | Code Inspector (SCI) |
49
+ | DDLS | CDS View/Entity | DDL Handler |
50
+
51
+ ### CDS Views (DDLS) Validation
52
+
53
+ For CDS views, the inspect command uses `CL_DD_DDL_HANDLER_FACTORY`:
54
+ - Checks **inactive version first** (`get_state = 'M'`)
55
+ - Falls back to active version if no inactive version exists
56
+ - Uses `get_errors()` and `get_warnings()` methods for detailed error information
57
+
58
+ ### Examples
59
+
60
+ **Passed:**
61
+ ```
62
+ ✅ CLAS ZCL_MY_CLASS - Syntax check passed
63
+ ```
64
+
65
+ **With Warnings:**
66
+ ```
67
+ ⚠️ DDLS ZC_MY_VIEW - Syntax check passed with warnings (4):
68
+ Line 9 : ParentPackage
69
+ Line 11 : SoftwareComponent
70
+ ```
71
+
72
+ **Failed:**
73
+ ```
74
+ ❌ DDLS ZC_MY_VIEW - Syntax check failed (1 error(s)):
75
+ Line 21, Column 12: Error message text
76
+ ```
77
+
26
78
  ## Fast Iteration Workflow
27
79
 
28
80
  For quick ABAP code changes:
29
81
 
30
82
  ```bash
31
83
  # 1. Make small change to ABAP file
32
- # 2. Commit and push
84
+ # 2. Commit and push to git
33
85
  git add abap/zcl_my_class.clas.abap
34
86
  git commit -m "fix: ..."
35
- git push
87
+ git push # CRITICAL: Push BEFORE pulling!
36
88
 
37
89
  # 3. Pull only changed file (seconds, not minutes)
38
90
  abapgit-agent pull --files abap/zcl_my_class.clas.abap
@@ -66,6 +118,102 @@ abapgit-agent inspect --files abap/zcl_my_class.clas.abap
66
118
  ```
67
119
  This will show detailed syntax errors including line numbers and error messages.
68
120
 
121
+ ## View ABAP Object Definitions
122
+
123
+ Use the `view` command to inspect ABAP object definitions (classes, interfaces, tables, data elements) directly from the ABAP system. **Very useful when working with unfamiliar tables** - shows complete structure including fields, types, and descriptions.
124
+
125
+ ```bash
126
+ # View a table definition
127
+ abapgit-agent view --objects ZMY_TABLE --type TABL
128
+
129
+ # View a data element definition
130
+ abapgit-agent view --objects ZMY_DTEL --type DTEL
131
+
132
+ # View a class definition
133
+ abapgit-agent view --objects ZCL_MY_CLASS
134
+
135
+ # View an interface definition
136
+ abapgit-agent view --objects ZIF_MY_INTERFACE
137
+
138
+ # View a table type definition
139
+ abapgit-agent view --objects ZMY_TTYP --type TTYP
140
+
141
+ # View multiple objects
142
+ abapgit-agent view --objects ZCL_CLASS1,ZCL_CLASS2,ZIF_INTERFACE1
143
+
144
+ # JSON output for scripting
145
+ abapgit-agent view --objects ZMY_TABLE --type TABL --json
146
+ ```
147
+
148
+ ### When to Use View Command
149
+
150
+ AI assistant SHOULD call `view` command when:
151
+
152
+ - User asks to "check", "look up", or "explore" an unfamiliar object
153
+ - Working with a table/structure and you don't know the field names/types
154
+ - Calling a class/interface method and you don't know the parameters
155
+ - User provides an object name that may not exist in the git repository
156
+
157
+ **Example workflow:**
158
+ ```
159
+ User: "Check if SFLIGHT table has a PRICE field"
160
+
161
+ Assistant: <calls `abapgit-agent view --objects SFLIGHT --type TABL`>
162
+ → Shows table structure with all fields including PRICE
163
+ ```
164
+
165
+ ## Explore Package Structure
166
+
167
+ Use the `tree` command to display package hierarchy from ABAP system:
168
+
169
+ ```bash
170
+ # Display package hierarchy
171
+ abapgit-agent tree --package $MY_PACKAGE
172
+
173
+ # With object counts
174
+ abapgit-agent tree --package $MY_PACKAGE --include-objects
175
+
176
+ # Limit depth
177
+ abapgit-agent tree --package $MY_PACKAGE --depth 2
178
+
179
+ # JSON output for scripting
180
+ abapgit-agent tree --package $MY_PACKAGE --json
181
+ ```
182
+
183
+ **Table Output Example:**
184
+ ```
185
+ TABLE ZCAIS_D1:
186
+ |----------------+-----+----------------+----------+----------------+----------------------|
187
+ | Field | Key | Type | Length | Data Elem | Description |
188
+ |----------------+-----+----------------+----------+----------------+----------------------|
189
+ | CLIENT | X | CLNT | 3 | MANDT | Client |
190
+ | ID | X | NUMC | 4 | NUMC4 | Count parameters |
191
+ | NAME | | CHAR | 50 | CHAR50 | Comment |
192
+ |----------------+-----+----------------+----------+----------------+----------------------|
193
+ ```
194
+
195
+ **Data Element Output Example:**
196
+ ```
197
+ DATA ELEMENT ZMY_DTEL:
198
+ |----------------+----------------+----------+----------------+----------------------|
199
+ | Field | Type | Length | Domain | Description |
200
+ |----------------+----------------+----------+----------------+----------------------|
201
+ | DOMAIN | CHAR | 20 | ZMY_DOMAIN | Domain: ZMY_DOMAIN |
202
+ | DATA_TYPE | CHAR | 10 | | ABAP Type: CHAR |
203
+ | LENGTH | NUMC | 5 | | Length: 20 |
204
+ |----------------+----------------+----------+----------------+----------------------|
205
+ ```
206
+
207
+ **Table Type Output Example:**
208
+ ```
209
+ 📖 ZMY_TTYP (Table Type)
210
+ Table Type ZMY_TTYP in $PACKAGE
211
+
212
+ Line Type: ZMY_STRUCTURE
213
+ Access Mode: STANDARD
214
+ Key Definition: WITH KEY
215
+ ```
216
+
69
217
  ## JSON Handling - ALWAYS Use /ui2/cl_json
70
218
 
71
219
  **CRITICAL**: Always use `/ui2/cl_json` for JSON serialization and deserialization.
@@ -138,7 +286,16 @@ ENDCLASS.
138
286
 
139
287
  ## Creating New ABAP Objects - XML Metadata Required
140
288
 
141
- **IMPORTANT**: When creating new ABAP objects in abapGit format, you MUST create XML metadata files alongside the `.clas.abap` and `.intf.abap` files.
289
+ **CRITICAL CHECKLIST - Never Forget!**
290
+
291
+ When creating ANY new ABAP object file, you MUST also create its XML metadata file:
292
+
293
+ | ABAP File | Required XML File |
294
+ |-----------|------------------|
295
+ | `zcl_my_class.clas.abap` | `zcl_my_class.clas.xml` |
296
+ | `zif_my_intf.intf.abap` | `zif_my_intf.intf.xml` |
297
+
298
+ **Without XML files**, abapGit will NOT recognize the objects during pull, and they won't be activated.
142
299
 
143
300
  ### XML Metadata Format for CLAS
144
301
 
@@ -184,15 +341,27 @@ For `zif_abgagt_util.intf.abap`, create `zif_abgagt_util.intf.xml`:
184
341
  </abapGit>
185
342
  ```
186
343
 
187
- **Without XML files**, abapGit will NOT recognize the objects during pull, and they won't be activated in the ABAP system.
344
+ ### Important Notes
345
+
346
+ 1. **CRITICAL: Push to git BEFORE pulling into ABAP**
347
+ - Always commit and push ABAP files to git first
348
+ - Then run `abapgit-agent pull` to activate in ABAP
349
+ - Never run `abapgit-agent pull` without pushing changes first
350
+
351
+ 2. **Only pull ABAP files** - The XML metadata stays in git:
352
+ ```bash
353
+ abapgit-agent pull --files zcl_my_class.clas.abap
354
+ ```
355
+ 2. abapGit reads the XML from git to deserialize the ABAP code
356
+ 3. XML files are NOT activated in ABAP - they are only for abapGit
188
357
 
189
358
  ```bash
190
359
  # After making changes to ABAP files
191
360
  git add .
192
361
  git commit -m "Describe changes"
193
- git push
362
+ git push # CRITICAL: Push BEFORE pulling
194
363
 
195
- # Validate in ABAP system (single file - fast)
364
+ # Then validate in ABAP system (single file - fast)
196
365
  abapgit-agent pull --files abap/zcl_my_class.clas.abap
197
366
 
198
367
  # Or validate all files
@@ -303,6 +472,113 @@ Common object types in this project:
303
472
  - `TABL` - Tables
304
473
  - `DDLS` - Data Definitions
305
474
 
475
+ ## Creating CDS Views (DDLS)
476
+
477
+ CDS views (Data Definition Language Source) require specific file naming and structure for abapGit.
478
+
479
+ ### File Naming
480
+
481
+ CDS views require **two files**:
482
+
483
+ | File | Description |
484
+ |------|-------------|
485
+ | `zc_my_view.ddls.asddls` | DDL source code |
486
+ | `zc_my_view.ddls.xml` | XML metadata |
487
+
488
+ **Important:** Do NOT use `.ddls.abap` extension - use `.ddls.asddls` for the source.
489
+
490
+ ### DDL Source File (`.ddls.asddls`)
491
+
492
+ ```abap
493
+ @AbapCatalog.sqlViewName: 'ZCMYVIEW'
494
+ @AbapCatalog.compiler.compareFilter: true
495
+ @AccessControl.authorizationCheck: #NOT_REQUIRED
496
+ @EndUserText.label: 'My CDS View'
497
+ define view ZC_My_View as select from tdevc
498
+ {
499
+ key devclass as Devclass,
500
+ parentcl as ParentPackage,
501
+ ctext as Description
502
+ }
503
+ where devclass not like '$%'
504
+ ```
505
+
506
+ ### XML Metadata File (`.ddls.xml`)
507
+
508
+ ```xml
509
+ <?xml version="1.0" encoding="utf-8"?>
510
+ <abapGit version="v1.0.0" serializer="LCL_OBJECT_DDLS" serializer_version="v1.0.0">
511
+ <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
512
+ <asx:values>
513
+ <DDLS>
514
+ <DDLNAME>ZC_MY_VIEW</DDLNAME>
515
+ <DDLANGUAGE>E</DDLANGUAGE>
516
+ <DDTEXT>My CDS View</DDTEXT>
517
+ </DDLS>
518
+ </asx:values>
519
+ </asx:abap>
520
+ </abapGit>
521
+ ```
522
+
523
+ ### Key Points
524
+
525
+ 1. **Avoid reserved words** - Field names like `PACKAGE`, `CLASS`, `INTERFACE` are reserved in CDS. Use alternatives like `PackageName`, `ClassName`.
526
+
527
+ 2. **Pull all files to activate** - When activating CDS views, use `abapgit-agent pull` (not single file) to ensure proper activation:
528
+ ```bash
529
+ abapgit-agent pull # Pull all files
530
+ ```
531
+
532
+ 3. **System support** - CDS views require SAP systems with CDS capability (S/4HANA, SAP BW/4HANA, or ABAP 7.51+). Older systems will show error: "Object type DDLS is not supported by this system"
533
+
534
+ ### Debugging Activation Errors
535
+
536
+ When pull shows generic errors like "Activation cancelled. Check the inactive objects":
537
+
538
+ 1. **Check in ADT/Eclipse** - Open the DDL source in ADT and run syntax check for detailed errors
539
+ 2. **Pull all files** - Sometimes `abapgit-agent pull` (all files) works better than single file for CDS views
540
+
541
+ ## Creating CDS View Entities
542
+
543
+ CDS View Entities (`define view entity`) are the modern replacement for CDS Views with additional features like **associations for OData navigation**.
544
+
545
+ ### Differences from CDS Views
546
+
547
+ | Aspect | CDS View | View Entity |
548
+ |--------|----------|-------------|
549
+ | Syntax | `define view` | `define view entity` |
550
+ | Associations | No | Yes (exposed for navigation) |
551
+ | OData/Navigation | Requires separate service | Auto-exposes associations |
552
+ | ABAP Version | 7.40+ | 7.55+ / S/4HANA Cloud |
553
+
554
+ ### DDL Source File with Association
555
+
556
+ ```abap
557
+ @EndUserText.label: 'Package Hierarchy'
558
+ @AccessControl.authorizationCheck: #NOT_REQUIRED
559
+ define view entity ZC_Pkg_Hierarchy_VE
560
+ as select from tdevc
561
+ association [0..1] to tdevc as _Parent
562
+ on _Parent.devclass = $projection.ParentPackage
563
+ {
564
+ key devclass as PackageName,
565
+ parentcl as ParentPackage,
566
+ ctext as Description,
567
+ dlvunit as SoftwareComponent,
568
+
569
+ // Exposed associations
570
+ _Parent
571
+ }
572
+ where devclass not like '$%'
573
+ ```
574
+
575
+ ### Key Points for View Entities
576
+
577
+ 1. **Association syntax**: Use `$projection` to reference fields in the current entity
578
+ 2. **Association cardinality**: `[0..1]`, `[1..1]`, `[0..n]`, `[1..n]`
579
+ 3. **Expose associations**: Add the association name at the end of the SELECT to expose it for OData navigation
580
+ 4. **Activation warnings**: Search help warnings are informational and don't block activation
581
+
306
582
  ## Naming Conventions
307
583
 
308
584
  - Use `Z_` or `Y_` prefix for custom objects
@@ -0,0 +1,79 @@
1
+ # ABAP Development with abapGit
2
+
3
+ You are working on an ABAP project using abapGit for version control.
4
+
5
+ ## Commands
6
+
7
+ | Command | Description |
8
+ |---------|-------------|
9
+ | `abapgit-agent pull` | Pull and activate all ABAP objects |
10
+ | `abapgit-agent pull --files <file>` | Pull and activate specific file only |
11
+ | `abapgit-agent inspect --files <file>` | Syntax check ABAP source |
12
+ | `abapgit-agent unit --files <file>` | Run AUnit tests |
13
+ | `abapgit-agent tree --package <package>` | Display package hierarchy |
14
+ | `abapgit-agent view --objects <name>` | View object definitions |
15
+
16
+ ## Explore Unknown Objects
17
+
18
+ **Before working with unfamiliar objects, use `view` command:**
19
+
20
+ ```bash
21
+ # Check table structure
22
+ abapgit-agent view --objects ZMY_TABLE --type TABL
23
+
24
+ # Check class definition
25
+ abapgit-agent view --objects ZCL_UNKNOWN_CLASS
26
+
27
+ # Check interface
28
+ abapgit-agent view --objects ZIF_UNKNOWN_INTERFACE
29
+
30
+ # Check data element
31
+ abapgit-agent view --objects ZMY_DTEL --type DTEL
32
+ ```
33
+
34
+ ## When to Use View Command
35
+
36
+ AI assistant SHOULD call `view` command when:
37
+ - User asks to "check", "look up", or "explore" an unfamiliar object
38
+ - Working with a table/structure and you don't know the fields
39
+ - Calling a class/interface method and you don't know the parameters
40
+ - You need to verify an object exists before using it
41
+
42
+ ## Key ABAP Rules
43
+
44
+ 1. **Global classes MUST use `PUBLIC`**:
45
+ ```abap
46
+ CLASS zcl_my_class DEFINITION PUBLIC. " <- REQUIRED
47
+ ```
48
+
49
+ 2. **Use `/ui2/cl_json` for JSON**:
50
+ ```abap
51
+ DATA ls_data TYPE ty_request.
52
+ ls_data = /ui2/cl_json=>deserialize( json = lv_json ).
53
+ lv_json = /ui2/cl_json=>serialize( data = ls_response ).
54
+ ```
55
+
56
+ 3. **Test class name max 30 chars**: `ltcl_util` (not `ltcl_abgagt_util_test`)
57
+
58
+ 4. **Interface method implementation**: Use prefix `zif_interface~method_name`
59
+
60
+ 5. **abapGit files need XML metadata**: `.clas.xml`, `.intf.xml` alongside `.clas.abap`, `.intf.abap`
61
+
62
+ ## Workflow
63
+
64
+ 1. Edit ABAP file in `/abap/`
65
+ 2. `git add <file> && git commit -m "..." && git push`
66
+ 3. `abapgit-agent pull --files <file>` (seconds, not minutes)
67
+
68
+ ## Error Handling
69
+
70
+ - Activation fails with "Error updating where-used list" = **syntax error**
71
+ - Use `abapgit-agent inspect --files <file>` for detailed error messages
72
+
73
+ ## Object Naming
74
+
75
+ | Pattern | Type |
76
+ |---------|------|
77
+ | `ZCL_*` | Class |
78
+ | `ZIF_*` | Interface |
79
+ | `Z*` | Other objects |
@@ -389,8 +389,8 @@ CLASS zcl_abgagt_agent IMPLEMENTATION.
389
389
  ENDIF.
390
390
  ENDIF.
391
391
 
392
- " Error/Abort/Warning messages - add to failed objects
393
- IF ls_msg-type = 'E' OR ls_msg-type = 'A' OR ls_msg-type = 'W'.
392
+ " Error/Abort messages - add to failed objects (warnings are not failures)
393
+ IF ls_msg-type = 'E' OR ls_msg-type = 'A'.
394
394
  APPEND ls_object TO rs_result-failed_objects.
395
395
  ENDIF.
396
396
  ENDLOOP.
@@ -27,6 +27,8 @@ CLASS zcl_abgagt_cmd_factory IMPLEMENTATION.
27
27
  ( command = zif_abgagt_command=>gc_unit class_name = 'ZCL_ABGAGT_COMMAND_UNIT' )
28
28
  ( command = zif_abgagt_command=>gc_create class_name = 'ZCL_ABGAGT_COMMAND_CREATE' )
29
29
  ( command = zif_abgagt_command=>gc_import class_name = 'ZCL_ABGAGT_COMMAND_IMPORT' )
30
+ ( command = zif_abgagt_command=>gc_tree class_name = 'ZCL_ABGAGT_COMMAND_TREE' )
31
+ ( command = zif_abgagt_command=>gc_view class_name = 'ZCL_ABGAGT_COMMAND_VIEW' )
30
32
  ).
31
33
  ENDMETHOD.
32
34