abapgit-agent 1.11.2 → 1.11.4

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.
@@ -25,13 +25,6 @@ You are working on an ABAP project using abapGit for version control.
25
25
  | CDS views | "How to define CDS view with associations?" |
26
26
  | Getting syntax errors | Check reference before trying approaches |
27
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
28
  ```bash
36
29
  # Search for a pattern
37
30
  abapgit-agent ref "CORRESPONDING"
@@ -45,7 +38,7 @@ abapgit-agent ref --topic sql
45
38
  abapgit-agent ref --list-topics
46
39
  ```
47
40
 
48
- ### 2. Read `.abapGitAgent` for Folder Location
41
+ ### 2. Read `.abapGitAgent` for Folder Location and Naming Conventions
49
42
 
50
43
  **Before creating ANY ABAP object file, you MUST read `.abapGitAgent` to determine the correct folder.**
51
44
 
@@ -58,171 +51,182 @@ The folder is configured in `.abapGitAgent` (property: `folder`):
58
51
  - If `folder` is `/src/` → files go in `src/` (e.g., `src/zcl_my_class.clas.abap`)
59
52
  - If `folder` is `/abap/` → files go in `abap/` (e.g., `abap/zcl_my_class.clas.abap`)
60
53
 
61
- ### 3. Create XML Metadata for Each ABAP Object
54
+ **Also check naming conventions before creating any new object:**
62
55
 
63
- **Each ABAP object requires an XML metadata file for abapGit to understand how to handle it.**
56
+ ```
57
+ 1. Check guidelines/objects.local.md ← project-specific overrides (if file exists)
58
+ 2. Fall back to guidelines/objects.md ← default Z/Y prefix conventions
59
+ ```
64
60
 
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` |
61
+ `objects.local.md` is created by `abapgit-agent init` and is never overwritten by updates — it holds project-specific prefixes (e.g. `YCL_` instead of `ZCL_`).
72
62
 
73
- **Use `ref --topic abapgit` for complete XML templates.**
63
+ ### 3. Create XML Metadata / Local Classes
74
64
 
75
- ### 4. Use `unit` Command for Unit Tests
65
+ Each ABAP object needs an XML metadata file. Local helper/test-double classes use separate `.locals_def.abap` / `.locals_imp.abap` files.
66
+ → See `guidelines/object-creation.md` for XML templates and local class setup
76
67
 
77
- **Use `abapgit-agent unit` to run ABAP unit tests (AUnit).**
68
+ ### 4. Use Syntax Command Before Commit (for CLAS, INTF, PROG, DDLS)
78
69
 
79
70
  ```
80
- ❌ WRONG: Try to use SE24 or other transaction codes
81
- ✅ CORRECT: Use abapgit-agent unit --files src/zcl_test.clas.testclasses.abap
71
+ ❌ WRONG: Make changes Commit Push Pull → Find errors → Fix → Repeat
72
+ ✅ CORRECT: Make changes Run syntax → Fix locally → Commit → Push → Pull → Done
82
73
  ```
83
74
 
75
+ **For CLAS, INTF, PROG, DDLS files**: Run `syntax` command BEFORE commit to catch errors early.
76
+
84
77
  ```bash
85
- # Run unit tests (after pulling to ABAP)
86
- abapgit-agent unit --files src/zcl_test.clas.testclasses.abap
78
+ # Check syntax of local code (no commit/push needed)
79
+ abapgit-agent syntax --files src/zcl_my_class.clas.abap
80
+
81
+ # Check multiple INDEPENDENT files
82
+ abapgit-agent syntax --files src/zcl_utils.clas.abap,src/zcl_logger.clas.abap
87
83
  ```
88
84
 
89
- ### 5. Use CDS Test Double Framework for CDS View Tests
85
+ **For dependent files, skip `syntax` and use `pull` instead:**
86
+ ```bash
87
+ # ❌ BAD - Interface and implementing class (may show false errors)
88
+ abapgit-agent syntax --files src/zif_my_intf.intf.abap,src/zcl_my_class.clas.abap
90
89
 
91
- **When creating unit tests for CDS views, use the CDS Test Double Framework (`CL_CDS_TEST_ENVIRONMENT`).**
90
+ # GOOD - Use pull instead for dependent files
91
+ git add . && git commit && git push
92
+ abapgit-agent pull --files src/zif_my_intf.intf.abap,src/zcl_my_class.clas.abap
93
+ ```
94
+
95
+ ### 5. Local Helper / Test-Double Classes
96
+
97
+ → See `guidelines/object-creation.md` for local class setup (`locals_def.abap` / `locals_imp.abap`)
98
+
99
+ ### 6. Use `ref`, `view` and `where` Commands to Learn About Unknown Classes/Methods
100
+
101
+ **When working with unfamiliar ABAP classes or methods, follow this priority:**
92
102
 
93
103
  ```
94
- WRONG: Use regular AUnit test class without test doubles
95
- CORRECT: Use CL_CDS_TEST_ENVIRONMENT to create test doubles for CDS views
104
+ 1. First: Check local git repo for usage examples
105
+ 2. Second: Check ABAP reference/cheat sheets
106
+ 3. Third: Use view/where commands to query ABAP system (if needed)
96
107
  ```
97
108
 
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
109
+ ```bash
110
+ # Find where a class/interface is USED
111
+ abapgit-agent where --objects ZIF_UNKNOWN_INTERFACE
102
112
 
103
- See `../guidelines/testing.md` for code examples.
113
+ # View CLASS DEFINITION
114
+ abapgit-agent view --objects ZCL_UNKNOWN_CLASS
115
+ ```
104
116
 
105
- ---
117
+ ### 7. CDS Unit Tests
106
118
 
107
- ## Development Workflow
119
+ Use `CL_CDS_TEST_ENVIRONMENT` for unit tests that read CDS views.
120
+ → See `guidelines/cds-testing.md` for code examples
121
+
122
+ ### 8. Use `unit` Command for Unit Tests
108
123
 
124
+ **Use `abapgit-agent unit` to run ABAP unit tests (AUnit).**
125
+
126
+ ```
127
+ ❌ WRONG: Try to use SE24, SE37, or other transaction codes
128
+ ✅ CORRECT: Use abapgit-agent unit --files src/zcl_test.clas.testclasses.abap
109
129
  ```
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
130
 
152
131
  ```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
132
+ # Run unit tests (after pulling to ABAP)
133
+ abapgit-agent unit --files src/zcl_test.clas.testclasses.abap
158
134
 
159
- # Run unit tests (multiple test classes)
135
+ # Multiple test classes
160
136
  abapgit-agent unit --files src/zcl_test1.clas.testclasses.abap,src/zcl_test2.clas.testclasses.abap
137
+ ```
161
138
 
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
139
+ ### 9. Troubleshooting ABAP Issues
167
140
 
168
- # Explore table structures
169
- abapgit-agent view --objects ZTABLE --type TABL
141
+ | Symptom | Tool | When |
142
+ |---|---|---|
143
+ | HTTP 500 / runtime crash (ST22) | `dump` | Error already occurred |
144
+ | Wrong output, no crash | `debug` | Need to trace logic |
170
145
 
171
- # Display package tree
172
- abapgit-agent tree --package \$MY_PACKAGE
146
+ Quick start:
147
+ ```bash
148
+ abapgit-agent dump --date TODAY --detail 1 # inspect last crash
149
+ abapgit-agent debug set --objects ZCL_FOO:42 # set breakpoint then attach
173
150
  ```
151
+ → See `guidelines/debug-dump.md` for dump analysis workflow
152
+ → See `guidelines/debug-session.md` for full debug session guide, breakpoint tips, and pull flow architecture
174
153
 
175
154
  ---
176
155
 
177
- ## Explore Unknown Objects
156
+ ## Development Workflow
157
+
158
+ This project's workflow mode is configured in `.abapGitAgent` under `workflow.mode`.
178
159
 
179
- **Before working with unfamiliar objects, use `view` command:**
160
+ ### Project-Level Config (`.abapgit-agent.json`)
180
161
 
181
- ```bash
182
- # Check table structure
183
- abapgit-agent view --objects ZMY_TABLE --type TABL
162
+ Checked into the repository — applies to all developers. **Read this file at the start of every session.**
184
163
 
185
- # Check class definition
186
- abapgit-agent view --objects ZCL_UNKNOWN_CLASS
164
+ | Setting | Values | Default | Effect |
165
+ |---------|--------|---------|--------|
166
+ | `safeguards.requireFilesForPull` | `true`/`false` | `false` | Requires `--files` on every pull |
167
+ | `safeguards.disablePull` | `true`/`false` | `false` | Disables pull entirely (CI/CD-only projects) |
168
+ | `conflictDetection.mode` | `"abort"`/`"ignore"` | `"abort"` | Whether to abort pull on conflict |
169
+ | `transports.allowCreate` | `true`/`false` | `true` | When `false`, `transport create` is blocked |
170
+ | `transports.allowRelease` | `true`/`false` | `true` | When `false`, `transport release` is blocked |
187
171
 
188
- # Check interface
189
- abapgit-agent view --objects ZIF_UNKNOWN_INTERFACE
172
+ ### Workflow Modes
190
173
 
191
- # Check data element
192
- abapgit-agent view --objects ZMY_DTEL --type DTEL
174
+ | Mode | Branch Strategy | Rebase Before Pull | Create PR |
175
+ |------|----------------|-------------------|-----------|
176
+ | `"branch"` | Feature branches | ✓ Always | ✓ Yes (squash merge) |
177
+ | `"trunk"` | Direct to default branch | ✗ No | ✗ No |
178
+ | (not set) | Direct to default branch | ✗ No | ✗ No |
179
+
180
+ ### Trunk Workflow (`"mode": "trunk"`)
181
+
182
+ ```bash
183
+ git checkout main
184
+ git pull origin main
185
+ edit src/zcl_auth_handler.clas.abap
186
+ abapgit-agent syntax --files src/zcl_auth_handler.clas.abap
187
+ git add . && git commit -m "feat: add authentication handler"
188
+ git push origin main
189
+ abapgit-agent pull --files src/zcl_auth_handler.clas.abap
193
190
  ```
194
191
 
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
192
+ ### Branch Workflow (`"mode": "branch"`)
199
193
 
200
- ---
194
+ → See `guidelines/branch-workflow.md` for step-by-step commands and examples
201
195
 
202
- ## Key ABAP Rules
196
+ ### AI Tool Guidelines
203
197
 
204
- 1. **Global classes MUST use `PUBLIC`**:
205
- ```abap
206
- CLASS zcl_my_class DEFINITION PUBLIC. " <- REQUIRED
207
- ```
198
+ **When `workflow.mode = "branch"`:**
199
+ 1. ✓ Create feature branches (naming: `feature/description`)
200
+ 2. Always `git fetch origin <default> && git rebase origin/<default>` before `pull` command
201
+ 3. ✓ Use `--force-with-lease` after rebase (never `--force`)
202
+ 4. ✓ Create PR with squash merge when feature complete
203
+ 5. ✗ Never commit directly to default branch
208
204
 
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
- ```
205
+ **When `workflow.mode = "trunk"` or not set:**
206
+ 1. ✓ Commit directly to default branch
207
+ 2. `git pull origin <default>` before push
208
+ 3. Don't create feature branches
215
209
 
216
- 3. **Test class name max 30 chars**: `ltcl_util` (not `ltcl_abgagt_util_test`)
210
+ **When `safeguards.requireFilesForPull = true`:** always include `--files` in every `pull` command
217
211
 
218
- 4. **Interface method implementation**: Use prefix `zif_interface~method_name`
212
+ **When `safeguards.disablePull = true`:** do not run `abapgit-agent pull` at all
219
213
 
220
- ---
214
+ **When `conflictDetection.mode = "abort"`:** if pull aborts with conflict error, inform user and suggest `--conflict-mode ignore` to override for that run
215
+
216
+ ### Quick Decision Tree
221
217
 
222
- ## Error Handling
218
+ ```
219
+ Modified ABAP files?
220
+ ├─ CLAS/INTF/PROG/DDLS files?
221
+ │ ├─ Independent files (no cross-dependencies)?
222
+ │ │ └─ ✅ Use: syntax → commit → push → pull
223
+ │ └─ Dependent files (interface + class, class uses class)?
224
+ │ └─ ✅ Use: skip syntax → commit → push → pull
225
+ └─ Other types (FUGR, TABL, etc.)?
226
+ └─ ✅ Use: skip syntax → commit → push → pull → (if errors: inspect)
227
+ ```
223
228
 
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
229
+ See `guidelines/workflow-detailed.md` for full workflow decision tree, error indicators, and complete command reference
226
230
 
227
231
  ---
228
232
 
@@ -232,23 +236,29 @@ Detailed guidelines are available in the `guidelines/` folder:
232
236
 
233
237
  | File | Topic |
234
238
  |------|-------|
235
- | `../guidelines/sql.md` | ABAP SQL Best Practices |
236
- | `../guidelines/exceptions.md` | Exception Handling |
237
- | `../guidelines/testing.md` | Unit Testing (including CDS) |
238
- | `../guidelines/cds.md` | CDS Views |
239
- | `../guidelines/classes.md` | ABAP Classes and Objects |
240
- | `../guidelines/objects.md` | Object Naming Conventions |
241
- | `../guidelines/json.md` | JSON Handling |
242
- | `../guidelines/abapgit.md` | abapGit XML Metadata Templates |
239
+ | `guidelines/sql.md` | ABAP SQL Best Practices |
240
+ | `guidelines/exceptions.md` | Exception Handling |
241
+ | `guidelines/testing.md` | Unit Testing (including CDS) |
242
+ | `guidelines/cds.md` | CDS Views |
243
+ | `guidelines/classes.md` | ABAP Classes and Objects |
244
+ | `guidelines/objects.md` | Object Naming Conventions (defaults) |
245
+ | `guidelines/objects.local.md` | **Project** Naming Conventions — overrides `objects.md` (never overwritten) |
246
+ | `guidelines/json.md` | JSON Handling |
247
+ | `guidelines/abapgit.md` | abapGit XML Metadata Templates |
248
+ | `guidelines/unit-testable-code.md` | Unit Testable Code Guidelines (Dependency Injection) |
249
+ | `guidelines/common-errors.md` | Common ABAP Errors - Quick Fixes |
250
+ | `guidelines/debug-session.md` | Debug Session Guide |
251
+ | `guidelines/debug-dump.md` | Dump Analysis Guide |
252
+ | `guidelines/branch-workflow.md` | Branch Workflow |
253
+ | `guidelines/workflow-detailed.md` | Development Workflow (Detailed) |
254
+ | `guidelines/object-creation.md` | Object Creation (XML metadata, local classes) |
255
+ | `guidelines/cds-testing.md` | CDS Testing (Test Double Framework) |
243
256
 
244
257
  These guidelines are automatically searched by the `ref` command.
245
258
 
246
259
  ---
247
260
 
248
- ## Object Naming
261
+ ## For More Information
249
262
 
250
- | Pattern | Type |
251
- |---------|------|
252
- | `ZCL_*` | Class |
253
- | `ZIF_*` | Interface |
254
- | `Z*` | Other objects |
263
+ - [SAP ABAP Cheat Sheets](https://github.com/SAP-samples/abap-cheat-sheets)
264
+ - [ABAP Keyword Documentation](https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/index.htm)
package/abap/CLAUDE.md CHANGED
@@ -54,7 +54,7 @@ abapgit-agent ref --topic sql
54
54
  abapgit-agent ref --list-topics
55
55
  ```
56
56
 
57
- ### 2. Read `.abapGitAgent` for Folder Location
57
+ ### 2. Read `.abapGitAgent` for Folder Location and Naming Conventions
58
58
 
59
59
  **Before creating ANY ABAP object file, you MUST read `.abapGitAgent` to determine the correct folder.**
60
60
 
@@ -67,6 +67,15 @@ The folder is configured in `.abapGitAgent` (property: `folder`):
67
67
  - If `folder` is `/src/` → files go in `src/` (e.g., `src/zcl_my_class.clas.abap`)
68
68
  - If `folder` is `/abap/` → files go in `abap/` (e.g., `abap/zcl_my_class.clas.abap`)
69
69
 
70
+ **Also check naming conventions before creating any new object:**
71
+
72
+ ```
73
+ 1. Check guidelines/objects.local.md ← project-specific overrides (if file exists)
74
+ 2. Fall back to guidelines/objects.md ← default Z/Y prefix conventions
75
+ ```
76
+
77
+ `objects.local.md` is created by `abapgit-agent init` and is never overwritten by updates — it holds project-specific prefixes (e.g. `YCL_` instead of `ZCL_`).
78
+
70
79
  ---
71
80
 
72
81
  ### 3. Create XML Metadata / Local Classes
@@ -122,7 +131,7 @@ abapgit-agent pull --files src/zif_my_intf.intf.abap,src/zcl_my_class.clas.abap
122
131
 
123
132
  ---
124
133
 
125
- ### 5. (covered in object-creation.md)
134
+ ### 5. Local Helper / Test-Double Classes
126
135
 
127
136
  → See `guidelines/object-creation.md` for local class setup (`locals_def.abap` / `locals_imp.abap`)
128
137
 
@@ -367,7 +376,8 @@ Detailed guidelines are available in the `guidelines/` folder:
367
376
  | `guidelines/testing.md` | Unit Testing (including CDS) |
368
377
  | `guidelines/cds.md` | CDS Views |
369
378
  | `guidelines/classes.md` | ABAP Classes and Objects |
370
- | `guidelines/objects.md` | Object Naming Conventions |
379
+ | `guidelines/objects.md` | Object Naming Conventions (defaults) |
380
+ | `guidelines/objects.local.md` | **Project** Naming Conventions — overrides `objects.md` (created by `init`, never overwritten) |
371
381
  | `guidelines/json.md` | JSON Handling |
372
382
  | `guidelines/abapgit.md` | abapGit XML Metadata Templates |
373
383
  | `guidelines/unit-testable-code.md` | Unit Testable Code Guidelines (Dependency Injection) |
@@ -8,6 +8,9 @@ grand_parent: ABAP Development
8
8
 
9
9
  # ABAP Object Naming Conventions
10
10
 
11
+ > **Project-specific overrides**: Add your naming conventions to `guidelines/objects.local.md`.
12
+ > That file is never overwritten by `abapgit-agent init --update` and is searched by the `ref` command.
13
+
11
14
  **Searchable keywords**: naming convention, Z prefix, namespace, object type, CLAS, INTF, PROG, TABL, DDLS
12
15
 
13
16
  ## TOPICS IN THIS FILE
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "abapgit-agent",
3
- "version": "1.11.2",
3
+ "version": "1.11.4",
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": [
@@ -4,6 +4,7 @@
4
4
 
5
5
  const pathModule = require('path');
6
6
  const fs = require('fs');
7
+ const readline = require('readline');
7
8
 
8
9
  /**
9
10
  * Copy a file if source exists (helper for init --update)
@@ -43,6 +44,11 @@ async function copyGuidelinesFolder(srcPath, destPath, overwrite = false) {
43
44
 
44
45
  for (const file of files) {
45
46
  if (file.endsWith('.md')) {
47
+ // Never overwrite *.local.md files — these are project-specific customisations
48
+ if (file.endsWith('.local.md')) {
49
+ continue;
50
+ }
51
+
46
52
  const srcFile = pathModule.join(srcPath, file);
47
53
  const destFile = pathModule.join(destPath, file);
48
54
 
@@ -69,6 +75,42 @@ async function copyGuidelinesFolder(srcPath, destPath, overwrite = false) {
69
75
  }
70
76
  }
71
77
 
78
+ /**
79
+ * Detect old numbered guideline files (e.g. 00_index.md, 01_sql.md) and
80
+ * prompt user to delete them if found.
81
+ */
82
+ async function cleanupOldGuidelineFiles(guidelinesPath) {
83
+ if (!fs.existsSync(guidelinesPath)) return;
84
+
85
+ const oldFiles = fs.readdirSync(guidelinesPath)
86
+ .filter(f => /^\d+_.*\.md$/.test(f));
87
+
88
+ if (oldFiles.length === 0) return;
89
+
90
+ console.log('');
91
+ console.log('⚠️ Old numbered guideline files detected (from a previous version):');
92
+ oldFiles.forEach(f => console.log(` guidelines/${f}`));
93
+ console.log(' These have been renamed and are no longer used.');
94
+
95
+ const answer = await new Promise((resolve) => {
96
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
97
+ rl.question('Delete old files? [Y/n] ', (ans) => {
98
+ rl.close();
99
+ resolve(ans.trim().toLowerCase());
100
+ });
101
+ });
102
+
103
+ if (answer === '' || answer === 'y' || answer === 'yes') {
104
+ oldFiles.forEach(f => {
105
+ fs.unlinkSync(pathModule.join(guidelinesPath, f));
106
+ console.log(` 🗑 Deleted guidelines/${f}`);
107
+ });
108
+ console.log(`✅ Old guideline files removed`);
109
+ } else {
110
+ console.log('⚠️ Old files kept — they may appear as duplicates in ref search results');
111
+ }
112
+ }
113
+
72
114
  module.exports = {
73
115
  name: 'init',
74
116
  description: 'Initialize local repository configuration',
@@ -182,6 +224,9 @@ Examples:
182
224
  true // overwrite
183
225
  );
184
226
 
227
+ // Detect and offer to remove old numbered guideline files
228
+ await cleanupOldGuidelineFiles(pathModule.join(process.cwd(), 'guidelines'));
229
+
185
230
  console.log(`
186
231
  📋 Update complete!
187
232
  Run 'abapgit-agent ref --list-topics' to see available topics.
@@ -396,6 +441,41 @@ Examples:
396
441
  } else {
397
442
  console.log(`⚠️ guidelines/ already exists, skipped`);
398
443
  }
444
+
445
+ // Create objects.local.md stub if not already present
446
+ const localNamingPath = pathModule.join(guidelinesDestPath, 'objects.local.md');
447
+ if (!fs.existsSync(localNamingPath)) {
448
+ const localNamingStub = `---
449
+ nav_order: 8
450
+ ---
451
+
452
+ # Project Naming Conventions (Override)
453
+
454
+ This file overrides \`guidelines/objects.md\` for this project.
455
+ It is **never overwritten** by \`abapgit-agent init --update\` — safe to customise.
456
+
457
+ Searched by the \`ref\` command alongside all other guidelines.
458
+
459
+ ## Naming Conventions
460
+
461
+ Uncomment and edit the rows that differ from the defaults in \`guidelines/objects.md\`:
462
+
463
+ | Object Type | Prefix | Example |
464
+ |---|---|---|
465
+ | Class | ZCL_ | ZCL_MY_CLASS |
466
+ | Interface | ZIF_ | ZIF_MY_INTERFACE |
467
+ | Program | Z | ZMY_PROGRAM |
468
+ | Package | $ | $MY_PACKAGE |
469
+ | Table | Z | ZMY_TABLE |
470
+ | CDS View | ZC_ | ZC_MY_VIEW |
471
+ | CDS Entity | ZE_ | ZE_MY_ENTITY |
472
+ | Data Element | Z | ZMY_ELEMENT |
473
+ | Structure | Z | ZMY_STRUCTURE |
474
+ | Table Type | Z | ZMY_TABLE_TYPE |
475
+ `;
476
+ fs.writeFileSync(localNamingPath, localNamingStub);
477
+ console.log(`✅ Created guidelines/objects.local.md (project naming conventions)`);
478
+ }
399
479
  } else {
400
480
  console.log(`⚠️ guidelines folder not found in abap/ directory`);
401
481
  }