abapgit-agent 1.8.9 → 1.10.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.
package/README.md CHANGED
@@ -144,6 +144,31 @@ abapgit-agent preview --objects SFLIGHT --compact
144
144
  abapgit-agent where --objects ZCL_MY_CLASS
145
145
  abapgit-agent where --objects ZIF_MY_INTERFACE
146
146
  abapgit-agent where --objects ZCL_MY_CLASS --type CLAS
147
+
148
+ # Query short dumps (ST22)
149
+ abapgit-agent dump --date TODAY
150
+ abapgit-agent dump --user DEVELOPER --date TODAY --detail 1
151
+ ```
152
+
153
+ ### Debug Commands
154
+
155
+ ```bash
156
+ # Set a breakpoint
157
+ abapgit-agent debug set --files abap/zcl_my_class.clas.abap:42
158
+
159
+ # Attach and debug interactively (human REPL)
160
+ abapgit-agent debug attach
161
+
162
+ # Attach in scripted AI mode — emits JSON on hit, starts background daemon
163
+ abapgit-agent debug attach --json
164
+
165
+ # Step, inspect variables, call stack (no --session needed)
166
+ abapgit-agent debug step --type over --json
167
+ abapgit-agent debug vars --json
168
+ abapgit-agent debug stack --json
169
+
170
+ # Always release the frozen work process when done
171
+ abapgit-agent debug step --type continue --json
147
172
  ```
148
173
 
149
174
  ### Utility Commands
@@ -188,6 +213,8 @@ npm run pull -- --url <git-url> --branch main
188
213
  | view Command | [docs/view-command.md](docs/view-command.md) |
189
214
  | preview Command | [docs/preview-command.md](docs/preview-command.md) |
190
215
  | where Command | [docs/where-command.md](docs/where-command.md) |
216
+ | dump Command | [docs/dump-command.md](docs/dump-command.md) |
217
+ | debug Command | [docs/debug-command.md](docs/debug-command.md) |
191
218
  | ref Command | [docs/ref-command.md](docs/ref-command.md) |
192
219
  | REST API Reference | [API.md](API.md) |
193
220
  | Error Handling | [ERROR_HANDLING.md](ERROR_HANDLING.md) |
package/abap/CLAUDE.md CHANGED
@@ -256,6 +256,142 @@ abapgit-agent unit --files src/zcl_test1.clas.testclasses.abap,src/zcl_test2.cla
256
256
 
257
257
  ---
258
258
 
259
+ ### 9. Troubleshooting ABAP Issues
260
+
261
+ Two commands are available for investigating bugs at runtime:
262
+
263
+ | Command | Use when | What it gives you |
264
+ |---------|----------|-------------------|
265
+ | `dump` | Error already occurred (ST22 crash) | Error type, call stack, exact source line |
266
+ | `debug` | Need to trace logic step-by-step | Live variable values, step into/over, expand structures |
267
+
268
+ #### When Something Goes Wrong — Start with `dump`
269
+
270
+ **First reflex** for any HTTP 500, runtime error, or user-reported crash:
271
+
272
+ ```bash
273
+ abapgit-agent dump --date TODAY # list today's dumps
274
+ abapgit-agent dump --date TODAY --detail 1 # full detail: call stack + source
275
+ ```
276
+
277
+ The `--detail` output shows the exact failing line (`>>>>>` marker), call stack,
278
+ and SAP's error analysis. Use it before asking the user to open ST22.
279
+
280
+ Common filters:
281
+ ```bash
282
+ abapgit-agent dump --user DEVELOPER --date TODAY # specific user
283
+ abapgit-agent dump --error TIME_OUT # specific error type
284
+ abapgit-agent dump --program ZMY_PROGRAM --detail 1 # specific program, full detail
285
+ ```
286
+
287
+ After identifying the failing class/method, use `view` for broader context:
288
+ ```bash
289
+ abapgit-agent view --objects ZCL_MY_CLASS
290
+ ```
291
+
292
+ #### When There Is No Dump — Use `debug`
293
+
294
+ Use `debug` when:
295
+ - The bug is a logic error (wrong output, no crash)
296
+ - You need to inspect variable values mid-execution
297
+ - You want to verify which branch of code runs
298
+
299
+ **Step 1 — set a breakpoint** on the first executable statement you want to inspect:
300
+ ```bash
301
+ abapgit-agent debug set --files src/zcl_my_class.clas.abap:42 # from local file
302
+ abapgit-agent debug set --objects ZCL_MY_CLASS:42 # by name (no local file needed)
303
+ abapgit-agent debug list # confirm it was registered
304
+ ```
305
+
306
+ > **Line number must point to an executable statement** — not a comment, blank line,
307
+ > `DATA` declaration, or `METHOD`/`ENDMETHOD`. Use `view --objects` to find valid lines.
308
+
309
+ **Step 2 — attach and trigger**
310
+
311
+ Two modes depending on context:
312
+
313
+ *Interactive (human in a terminal):*
314
+ ```bash
315
+ # Terminal 1 — attach (blocks waiting for breakpoint, opens REPL on hit)
316
+ abapgit-agent debug attach
317
+
318
+ # Terminal 2 — trigger (any command that calls the backend)
319
+ abapgit-agent unit --files src/zcl_my_class.clas.testclasses.abap
320
+ abapgit-agent inspect --files src/zcl_my_class.clas.abap
321
+ ```
322
+
323
+ *Scripted (AI / automation) — best practice: individual sequential calls:*
324
+
325
+ Once the daemon is running and the session is saved to the state file, each
326
+ `vars/stack/step` command is a plain standalone call — no bash script needed.
327
+
328
+ ```bash
329
+ # Step 1: start attach listener in background (spawns a daemon, saves session to state file)
330
+ abapgit-agent debug attach --json > /tmp/attach.json 2>&1 &
331
+ sleep 2
332
+
333
+ # Step 2: trigger in background — MUST stay alive for the whole session
334
+ abapgit-agent unit --files src/zcl_my_class.clas.testclasses.abap > /tmp/trigger.json 2>&1 &
335
+
336
+ # Step 3: poll until breakpoint fires and session JSON appears in attach output
337
+ SESSION=""
338
+ for i in $(seq 1 30); do
339
+ sleep 0.5
340
+ SESSION=$(grep -o '"session":"[^"]*"' /tmp/attach.json 2>/dev/null | head -1 | cut -d'"' -f4)
341
+ [ -n "$SESSION" ] && break
342
+ done
343
+
344
+ # Step 4: inspect and step — each is an individual call, no --session needed
345
+ abapgit-agent debug stack --json
346
+ abapgit-agent debug vars --json
347
+ abapgit-agent debug vars --expand LS_OBJECT --json
348
+ abapgit-agent debug step --type over --json
349
+ abapgit-agent debug vars --json
350
+
351
+ # Step 5: ALWAYS release the ABAP work process before finishing
352
+ abapgit-agent debug step --type continue --json
353
+
354
+ # Step 6: check trigger result
355
+ cat /tmp/trigger.json
356
+ rm -f /tmp/attach.json /tmp/trigger.json
357
+ ```
358
+
359
+ > **Four rules for scripted mode:**
360
+ > 1. `sleep 2` after starting attach — the listener must register on the server before the trigger fires
361
+ > 2. Keep the trigger process alive in the background for the entire session — if it exits, the ABAP work process is released and the session ends
362
+ > 3. Always finish with `step --type continue` — this releases the frozen work process so the trigger can complete normally
363
+ > 4. **Never pass `--session` to `step/vars/stack`** — it bypasses the daemon IPC and causes `noSessionAttached`. Omit it and let commands auto-load from the saved state file.
364
+
365
+ **Step 3 — step through and inspect**
366
+
367
+ *Interactive REPL commands (after `attach` without `--json`):*
368
+ ```
369
+ debug> v — show all variables
370
+ debug> x LT_DATA — expand a table or structure
371
+ debug> n — step over
372
+ debug> s — step into
373
+ debug> bt — call stack
374
+ debug> q — detach (program continues); kill — hard abort
375
+ ```
376
+
377
+ *Scripted commands (after `attach --json`) — omit `--session`, commands auto-load from state file:*
378
+ ```bash
379
+ abapgit-agent debug vars --json # all variables
380
+ abapgit-agent debug vars --name LV_RESULT --json # one variable
381
+ abapgit-agent debug vars --expand LT_DATA --json # drill into table/structure
382
+ abapgit-agent debug step --type over --json # step over
383
+ abapgit-agent debug step --type into --json # step into
384
+ abapgit-agent debug step --type continue --json # continue to next breakpoint / finish
385
+ abapgit-agent debug stack --json # call stack (shows which test method is active)
386
+ ```
387
+
388
+ **Clean up** when done:
389
+ ```bash
390
+ abapgit-agent debug delete --all
391
+ ```
392
+
393
+ ---
394
+
259
395
  ## Development Workflow
260
396
 
261
397
  This project's workflow mode is configured in `.abapGitAgent` under `workflow.mode`.
@@ -672,6 +808,13 @@ abapgit-agent view --objects ZTABLE --type TABL
672
808
 
673
809
  # Display package tree
674
810
  abapgit-agent tree --package \$MY_PACKAGE
811
+
812
+ # Investigate runtime errors (ST22 short dumps)
813
+ abapgit-agent dump # Last 7 days
814
+ abapgit-agent dump --user DEVELOPER --date TODAY # Today's dumps for a user
815
+ abapgit-agent dump --program ZMY_PROGRAM # Dumps from a specific program
816
+ abapgit-agent dump --error TIME_OUT # Dumps by error type
817
+ abapgit-agent dump --user DEVELOPER --detail 1 # Full detail of first result
675
818
  ```
676
819
 
677
820
  ---
package/bin/abapgit-agent CHANGED
@@ -50,6 +50,8 @@ async function main() {
50
50
  view: require('../src/commands/view'),
51
51
  preview: require('../src/commands/preview'),
52
52
  where: require('../src/commands/where'),
53
+ dump: require('../src/commands/dump'),
54
+ debug: require('../src/commands/debug'),
53
55
  ref: require('../src/commands/ref'),
54
56
  init: require('../src/commands/init'),
55
57
  pull: require('../src/commands/pull'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "abapgit-agent",
3
- "version": "1.8.9",
3
+ "version": "1.10.0",
4
4
  "description": "ABAP Git Agent - Pull and activate ABAP code via abapGit from any git repository",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -33,6 +33,12 @@
33
33
  "test:cmd:view": "node tests/run-all.js --cmd --command=view",
34
34
  "test:cmd:preview": "node tests/run-all.js --cmd --command=preview",
35
35
  "test:cmd:tree": "node tests/run-all.js --cmd --command=tree",
36
+ "test:cmd:dump": "node tests/run-all.js --cmd --command=dump",
37
+ "test:cmd:debug": "node tests/run-all.js --cmd --command=debug",
38
+ "test:debug:scenarios": "bash tests/integration/debug-scenarios.sh",
39
+ "test:debug:scenarios:1": "bash tests/integration/debug-scenarios.sh 1",
40
+ "test:debug:scenarios:2": "bash tests/integration/debug-scenarios.sh 2",
41
+ "test:debug:scenarios:3": "bash tests/integration/debug-scenarios.sh 3",
36
42
  "test:cmd:upgrade": "node tests/run-all.js --cmd --command=upgrade",
37
43
  "test:lifecycle": "node tests/run-all.js --lifecycle",
38
44
  "test:pull": "node tests/run-all.js --pull",