@njuptlzf/mcp-adapter 2.29.0-0.0.1

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 (131) hide show
  1. package/CHANGELOG.md +1205 -0
  2. package/LICENSE +21 -0
  3. package/MAPPING.md +73 -0
  4. package/README.md +564 -0
  5. package/abort.ts +34 -0
  6. package/adapters/pi-renderer.ts +7 -0
  7. package/adapters/protocol-elicitation-forwarder.ts +164 -0
  8. package/adapters/protocol-sampling-forwarder.ts +108 -0
  9. package/adapters/universal-host.ts +213 -0
  10. package/agent-dir.ts +68 -0
  11. package/agent-plugin-loader.ts +377 -0
  12. package/app-bridge.bundle.js +67 -0
  13. package/banner.png +0 -0
  14. package/bin/mcp-server.ts +282 -0
  15. package/cli.js +392 -0
  16. package/commands.ts +735 -0
  17. package/config.ts +1284 -0
  18. package/consent-manager.ts +64 -0
  19. package/direct-tools.ts +619 -0
  20. package/dist/agent-dir.d.ts +10 -0
  21. package/dist/agent-dir.js +63 -0
  22. package/dist/agent-dir.js.map +1 -0
  23. package/dist/agent-plugin-loader.d.ts +8 -0
  24. package/dist/agent-plugin-loader.js +356 -0
  25. package/dist/agent-plugin-loader.js.map +1 -0
  26. package/dist/config.d.ts +123 -0
  27. package/dist/config.js +1087 -0
  28. package/dist/config.js.map +1 -0
  29. package/dist/metadata-cache.d.ts +19 -0
  30. package/dist/metadata-cache.js +319 -0
  31. package/dist/metadata-cache.js.map +1 -0
  32. package/dist/package-mcp-loader.d.ts +2 -0
  33. package/dist/package-mcp-loader.js +156 -0
  34. package/dist/package-mcp-loader.js.map +1 -0
  35. package/dist/resource-tools.d.ts +1 -0
  36. package/dist/resource-tools.js +15 -0
  37. package/dist/resource-tools.js.map +1 -0
  38. package/dist/types.d.ts +564 -0
  39. package/dist/types.js +287 -0
  40. package/dist/types.js.map +1 -0
  41. package/dist/ui-app-bridge-helpers.d.ts +6 -0
  42. package/dist/ui-app-bridge-helpers.js +37 -0
  43. package/dist/ui-app-bridge-helpers.js.map +1 -0
  44. package/dist/ui-stream-types.d.ts +104 -0
  45. package/dist/ui-stream-types.js +59 -0
  46. package/dist/ui-stream-types.js.map +1 -0
  47. package/dist/ui-tool-visibility.d.ts +4 -0
  48. package/dist/ui-tool-visibility.js +27 -0
  49. package/dist/ui-tool-visibility.js.map +1 -0
  50. package/dist/utils.d.ts +32 -0
  51. package/dist/utils.js +338 -0
  52. package/dist/utils.js.map +1 -0
  53. package/elicitation-handler.ts +348 -0
  54. package/error-signal.ts +21 -0
  55. package/errors.ts +223 -0
  56. package/failure-backoff.ts +23 -0
  57. package/glimpse-ui.ts +80 -0
  58. package/host-html-template.ts +461 -0
  59. package/index.ts +1291 -0
  60. package/init.ts +692 -0
  61. package/interfaces/agent-paths.ts +67 -0
  62. package/interfaces/host-types.ts +102 -0
  63. package/interfaces/sampling.ts +57 -0
  64. package/json-schema-validator.ts +69 -0
  65. package/lifecycle.ts +446 -0
  66. package/logger.ts +169 -0
  67. package/mcp-auth-flow.ts +1026 -0
  68. package/mcp-auth.ts +1000 -0
  69. package/mcp-bearer-store.ts +387 -0
  70. package/mcp-callback-server.ts +534 -0
  71. package/mcp-code.ts +360 -0
  72. package/mcp-keyring-helper.cjs +89 -0
  73. package/mcp-oauth-provider.ts +666 -0
  74. package/mcp-output-guard.ts +496 -0
  75. package/mcp-panel.ts +1044 -0
  76. package/mcp-probe.ts +201 -0
  77. package/mcp-references.ts +368 -0
  78. package/mcp-script-worker.mjs +130 -0
  79. package/mcp-server.mjs +2133 -0
  80. package/mcp-setup-panel.ts +667 -0
  81. package/mcp-status.ts +98 -0
  82. package/mcp-trace.ts +306 -0
  83. package/metadata-cache.ts +382 -0
  84. package/namespace-tools.ts +276 -0
  85. package/npx-resolver.ts +543 -0
  86. package/oauth-handler.ts +30 -0
  87. package/oauth.ts +48 -0
  88. package/onboarding-state.ts +76 -0
  89. package/package-mcp-loader.ts +168 -0
  90. package/package.json +225 -0
  91. package/panel-keys.ts +53 -0
  92. package/prompts.ts +353 -0
  93. package/proxy-modes.ts +1418 -0
  94. package/request-headers-command.ts +330 -0
  95. package/resource-tools.ts +17 -0
  96. package/runtime-owner.ts +91 -0
  97. package/sampling-handler.ts +284 -0
  98. package/search-ranking.ts +278 -0
  99. package/server-manager.ts +1318 -0
  100. package/session-recovery.ts +158 -0
  101. package/skills/README.md +64 -0
  102. package/skills/mcp-adapter/SKILL.md +332 -0
  103. package/skills/mcp-adapter/references/deploy-examples.md +259 -0
  104. package/skills/mcp-adapter/references/deploy.md +89 -0
  105. package/skills/mcp-adapter/references/generate.md +144 -0
  106. package/skills/mcp-adapter/references/resolver.md +105 -0
  107. package/skills/mcp-adapter/references/verify.md +157 -0
  108. package/skills/mcp-scripting/SKILL.md +38 -0
  109. package/skills/resolve-conflicts/SKILL.md +482 -0
  110. package/skills/resolve-conflicts/references/patterns.md +432 -0
  111. package/skills/resolve-conflicts/references/sample-plan.md +96 -0
  112. package/skills/resolve-conflicts/scripts/handle-deleted-modified.sh +183 -0
  113. package/skills/resolve-conflicts/scripts/validate-conflicts.sh +120 -0
  114. package/skills/upstream-merge/SKILL.md +486 -0
  115. package/skills/upstream-merge/references/pi-coupling-markers.md +129 -0
  116. package/skills/upstream-merge/references/special-cases.md +39 -0
  117. package/state.ts +60 -0
  118. package/tool-approval.ts +195 -0
  119. package/tool-metadata.ts +296 -0
  120. package/tool-registrar.ts +253 -0
  121. package/tool-result-renderer.ts +477 -0
  122. package/ts-shape.ts +149 -0
  123. package/types.ts +991 -0
  124. package/ui-app-bridge-helpers.ts +40 -0
  125. package/ui-resource-handler.ts +250 -0
  126. package/ui-server.ts +852 -0
  127. package/ui-session.ts +571 -0
  128. package/ui-stream-types.ts +89 -0
  129. package/ui-tool-visibility.ts +25 -0
  130. package/unix-socket-transport.ts +85 -0
  131. package/utils.ts +382 -0
@@ -0,0 +1,432 @@
1
+ # Conflict Resolution Patterns
2
+
3
+ This document provides detailed patterns for resolving specific types of conflicts.
4
+
5
+ **Important**: For each conflict you resolve, provide a one-line explanation of your resolution strategy. When the correct resolution isn't clear from the diff, present numbered options to the user.
6
+
7
+ ## Import Conflicts
8
+
9
+ When both branches modify import statements, merge both sets of imports:
10
+
11
+ ### Pattern: Combine and Deduplicate
12
+
13
+ ```
14
+ <<<<<<< HEAD
15
+ import { foo, bar } from './module';
16
+ import { baz } from './other';
17
+ =======
18
+ import { foo, qux } from './module';
19
+ import { newThing } from './another';
20
+ >>>>>>> branch
21
+ ```
22
+
23
+ **Resolution:** Merge all unique imports, group by module:
24
+
25
+ ```
26
+ import { foo, bar, qux } from './module';
27
+ import { baz } from './other';
28
+ import { newThing } from './another';
29
+ ```
30
+
31
+ ### Rust Imports
32
+
33
+ ```
34
+ <<<<<<< HEAD
35
+ use std::collections::HashMap;
36
+ use crate::domain::User;
37
+ =======
38
+ use std::collections::HashSet;
39
+ use crate::domain::Account;
40
+ >>>>>>> branch
41
+ ```
42
+
43
+ **Resolution:**
44
+
45
+ ```
46
+ use std::collections::{HashMap, HashSet};
47
+ use crate::domain::{Account, User};
48
+ ```
49
+
50
+ **Key principles:**
51
+ - Combine all unique imports
52
+ - Remove duplicates
53
+ - Follow language-specific style (group by module, alphabetize)
54
+ - Preserve any re-exports or aliases from both sides
55
+
56
+ **One-line explanation example**: "Merging imports by combining unique imports from both branches and grouping by module."
57
+
58
+ ## Test Conflicts
59
+
60
+ Tests should almost always include both changes, as tests are additive.
61
+
62
+ ### Pattern: Merge Test Cases
63
+
64
+ ```
65
+ <<<<<<< HEAD
66
+ #[test]
67
+ fn test_user_creation() { ... }
68
+
69
+ #[test]
70
+ fn test_user_validation() { ... }
71
+ =======
72
+ #[test]
73
+ fn test_user_creation() { ... }
74
+
75
+ #[test]
76
+ fn test_user_deletion() { ... }
77
+ >>>>>>> branch
78
+ ```
79
+
80
+ **Resolution:** Include all tests (assuming test_user_creation is identical):
81
+
82
+ ```
83
+ #[test]
84
+ fn test_user_creation() { ... }
85
+
86
+ #[test]
87
+ fn test_user_validation() { ... }
88
+
89
+ #[test]
90
+ fn test_user_deletion() { ... }
91
+ ```
92
+
93
+ ### Test Setup/Fixtures Conflicts
94
+
95
+ When both branches modify test fixtures, merge the changes:
96
+
97
+ ```
98
+ <<<<<<< HEAD
99
+ fn setup() -> TestContext {
100
+ TestContext {
101
+ user: create_test_user(),
102
+ admin: create_admin(),
103
+ }
104
+ }
105
+ =======
106
+ fn setup() -> TestContext {
107
+ TestContext {
108
+ user: create_test_user(),
109
+ database: init_test_db(),
110
+ }
111
+ }
112
+ >>>>>>> branch
113
+ ```
114
+
115
+ **Resolution:**
116
+
117
+ ```
118
+ fn setup() -> TestContext {
119
+ TestContext {
120
+ user: create_test_user(),
121
+ admin: create_admin(),
122
+ database: init_test_db(),
123
+ }
124
+ }
125
+ ```
126
+
127
+ **Key principles:**
128
+ - Keep all test cases unless they test the exact same thing
129
+ - Merge test fixtures and setup functions
130
+ - If test names conflict but test different things, rename one
131
+ - Preserve all assertions from both sides
132
+
133
+ **One-line explanation example**: "Including all test cases from both branches and merging test fixtures."
134
+
135
+ ## Lock File Conflicts
136
+
137
+ Lock files (Cargo.lock, package-lock.json, yarn.lock, etc.) should be regenerated rather than manually resolved.
138
+
139
+ ### Pattern: Regenerate Lock File
140
+
141
+ ```bash
142
+ # For Cargo.lock
143
+ git checkout --theirs Cargo.lock # or --ours, either works
144
+ cargo update # or cargo build
145
+
146
+ # For package-lock.json
147
+ git checkout --theirs package-lock.json
148
+ npm install
149
+
150
+ # For yarn.lock
151
+ git checkout --theirs yarn.lock
152
+ yarn install
153
+
154
+ # For Gemfile.lock
155
+ git checkout --theirs Gemfile.lock
156
+ bundle install
157
+
158
+ # For poetry.lock
159
+ git checkout --theirs poetry.lock
160
+ poetry lock --no-update
161
+ ```
162
+
163
+ **Key principles:**
164
+ - Always regenerate, never manually merge
165
+ - Choose either version (--ours or --theirs), doesn't matter
166
+ - Run the package manager's update/install command
167
+ - The result will include dependencies from both branches
168
+
169
+ **One-line explanation example**: "Regenerating lock file with package manager to include dependencies from both branches."
170
+
171
+ ## Configuration File Conflicts
172
+
173
+ Configuration files often need careful merging of both changes.
174
+
175
+ ### Pattern: Merge Configuration Values
176
+
177
+ ```yaml
178
+ <<<<<<< HEAD
179
+ server:
180
+ port: 8080
181
+ timeout: 30
182
+ max_connections: 100
183
+ =======
184
+ server:
185
+ port: 8080
186
+ timeout: 60
187
+ enable_https: true
188
+ >>>>>>> branch
189
+ ```
190
+
191
+ **Resolution:**
192
+
193
+ ```yaml
194
+ server:
195
+ port: 8080
196
+ timeout: 60 # Prefer the newer/safer value
197
+ max_connections: 100
198
+ enable_https: true
199
+ ```
200
+
201
+ **Key principles:**
202
+ - Include all configuration keys from both sides
203
+ - When same key has different values, choose based on:
204
+ - Newer value (if timestamp available)
205
+ - Safer/more conservative value
206
+ - Production-ready value
207
+ - Document the choice in commit message
208
+
209
+ **One-line explanation example**: "Merging all config keys and choosing incoming value for 'timeout' as it's more recent."
210
+
211
+ **When to ask the user**: If conflicting values have significant implications (e.g., security settings, API endpoints), present options:
212
+ ```
213
+ Config conflict in config.yaml for key 'timeout':
214
+
215
+ **Option 1**: Keep current value (30 seconds)
216
+ **Option 2**: Keep incoming value (60 seconds)
217
+ **Option 3**: Provide a different value
218
+
219
+ Please select an option.
220
+ ```
221
+
222
+ ## Code Logic Conflicts
223
+
224
+ When both branches modify the same function, carefully analyze the intent.
225
+
226
+ ### Pattern: Sequential Changes
227
+
228
+ If changes are independent and can coexist:
229
+
230
+ ```
231
+ <<<<<<< HEAD
232
+ fn process(data: &str) -> Result<String> {
233
+ let cleaned = data.trim();
234
+ validate(cleaned)?;
235
+ Ok(cleaned.to_uppercase())
236
+ }
237
+ =======
238
+ fn process(data: &str) -> Result<String> {
239
+ let cleaned = data.trim();
240
+ if cleaned.is_empty() {
241
+ return Err(Error::EmptyInput);
242
+ }
243
+ Ok(cleaned.to_uppercase())
244
+ }
245
+ >>>>>>> branch
246
+ ```
247
+
248
+ **Resolution:** Combine both validations:
249
+
250
+ ```
251
+ fn process(data: &str) -> Result<String> {
252
+ let cleaned = data.trim();
253
+ if cleaned.is_empty() {
254
+ return Err(Error::EmptyInput);
255
+ }
256
+ validate(cleaned)?;
257
+ Ok(cleaned.to_uppercase())
258
+ }
259
+ ```
260
+
261
+ **One-line explanation**: "Merging both validations as they check different conditions (emptiness and validation)."
262
+
263
+ ### Pattern: Conflicting Logic
264
+
265
+ If changes represent different approaches:
266
+
267
+ ```
268
+ <<<<<<< HEAD
269
+ fn calculate_price(item: &Item) -> f64 {
270
+ item.base_price * (1.0 + item.tax_rate)
271
+ }
272
+ =======
273
+ fn calculate_price(item: &Item) -> f64 {
274
+ item.base_price + item.tax_amount
275
+ }
276
+ >>>>>>> branch
277
+ ```
278
+
279
+ **Resolution:** Analyze which approach is correct:
280
+ - Review PR/commit messages for context
281
+ - Check which calculation matches business requirements
282
+ - Consider running tests with both approaches
283
+ - Choose one and document why in commit message
284
+
285
+ **When to ask the user**: Present this as options when the correct approach isn't clear:
286
+
287
+ ```
288
+ Code logic conflict in calculate_price function:
289
+
290
+ <<<<<<< HEAD (Current Branch)
291
+ fn calculate_price(item: &Item) -> f64 {
292
+ item.base_price * (1.0 + item.tax_rate)
293
+ }
294
+ =======
295
+ fn calculate_price(item: &Item) -> f64 {
296
+ item.base_price + item.tax_amount
297
+ }
298
+ >>>>>>> feature-branch (Incoming Branch)
299
+
300
+ These represent different calculation methods:
301
+
302
+ **Option 1**: Keep current branch - calculates tax as percentage (base_price * tax_rate)
303
+ **Option 2**: Keep incoming branch - uses pre-calculated tax amount (base_price + tax_amount)
304
+ **Option 3**: Ask you to clarify the correct business logic
305
+
306
+ Please select an option.
307
+ ```
308
+
309
+ **One-line explanation example**: "Choosing current branch approach as it calculates tax dynamically based on rate (per user selection)."
310
+
311
+ ## Struct/Type Definition Conflicts
312
+
313
+ Merge all fields from both branches.
314
+
315
+ ### Pattern: Merge Struct Fields
316
+
317
+ ```
318
+ <<<<<<< HEAD
319
+ pub struct User {
320
+ pub id: i64,
321
+ pub name: String,
322
+ pub email: String,
323
+ pub created_at: DateTime,
324
+ }
325
+ =======
326
+ pub struct User {
327
+ pub id: i64,
328
+ pub name: String,
329
+ pub role: UserRole,
330
+ pub updated_at: DateTime,
331
+ }
332
+ >>>>>>> branch
333
+ ```
334
+
335
+ **Resolution:**
336
+
337
+ ```
338
+ pub struct User {
339
+ pub id: i64,
340
+ pub name: String,
341
+ pub email: String,
342
+ pub role: UserRole,
343
+ pub created_at: DateTime,
344
+ pub updated_at: DateTime,
345
+ }
346
+ ```
347
+
348
+ **Key principles:**
349
+ - Include all fields from both sides
350
+ - If field types conflict, analyze which is more appropriate
351
+ - Update all usages of the struct accordingly
352
+ - Fix compilation errors after merging
353
+
354
+ **One-line explanation example**: "Including all fields from both branches in User struct."
355
+
356
+ **When to ask the user**: If the same field has different types:
357
+ ```
358
+ Struct conflict - field 'role' has different types:
359
+
360
+ **Option 1**: Keep current type (role: String)
361
+ **Option 2**: Keep incoming type (role: UserRole enum)
362
+ **Option 3**: Provide more context
363
+
364
+ Please select an option.
365
+ ```
366
+
367
+ ## Documentation Conflicts
368
+
369
+ Merge all documentation improvements.
370
+
371
+ ### Pattern: Combine Documentation
372
+
373
+ ```
374
+ <<<<<<< HEAD
375
+ /// Processes user input and returns validated data.
376
+ ///
377
+ /// # Arguments
378
+ /// * `input` - The raw user input
379
+ =======
380
+ /// Processes user input and returns validated data.
381
+ ///
382
+ /// # Errors
383
+ /// Returns `Error::InvalidInput` if validation fails
384
+ >>>>>>> branch
385
+ ```
386
+
387
+ **Resolution:**
388
+
389
+ ```
390
+ /// Processes user input and returns validated data.
391
+ ///
392
+ /// # Arguments
393
+ /// * `input` - The raw user input
394
+ ///
395
+ /// # Errors
396
+ /// Returns `Error::InvalidInput` if validation fails
397
+ ```
398
+
399
+ **Key principles:**
400
+ - Preserve all documentation sections
401
+ - If descriptions conflict, choose the more accurate/detailed one
402
+ - Keep all examples from both sides
403
+ - Maintain consistent formatting
404
+
405
+ **One-line explanation example**: "Combining all documentation sections from both branches."
406
+
407
+ ## Deleted File Special Cases
408
+
409
+ ### Pattern: File Renamed/Moved
410
+
411
+ If file was deleted on one branch but modified on another, and there's a similar new file:
412
+
413
+ 1. Check if file was renamed: `git log --follow --diff-filter=R -- <file>`
414
+ 2. Apply modifications to the new location
415
+ 3. Remove the old file
416
+
417
+ ### Pattern: File Legitimately Deleted
418
+
419
+ If file deletion was intentional (feature removed, refactored):
420
+
421
+ 1. Review the modifications from the other branch
422
+ 2. Determine if any changes are still relevant
423
+ 3. If yes, apply to the appropriate new location
424
+ 4. If no, accept the deletion
425
+
426
+ ### Pattern: Accidental Deletion
427
+
428
+ If file should not have been deleted:
429
+
430
+ 1. Restore the file from the branch that kept it
431
+ 2. Apply any additional modifications
432
+ 3. Verify tests pass
@@ -0,0 +1,96 @@
1
+ # Sample Merge Resolution Plan
2
+
3
+ This file provides a complete example of a merge resolution plan for a typical conflict scenario.
4
+
5
+ ## Merge Resolution Plan
6
+
7
+ ### Conflict Summary
8
+
9
+ - **Total conflicted files**: 5
10
+ - **Deleted-modified conflicts**: 1
11
+ - **Generated files**: 1
12
+ - **Regular conflicts**: 3
13
+
14
+ ### Resolution Strategy by File
15
+
16
+ #### 1. `Cargo.lock`
17
+
18
+ **Conflict Type**: generated
19
+ **Strategy**: Regenerate from Cargo.toml after merge
20
+ **Rationale**: Lock files should never be manually merged; regeneration ensures all dependencies are correctly resolved
21
+ **Risk**: Low - Standard procedure for lock files
22
+ **Action Items**:
23
+
24
+ - [ ] Choose either version temporarily
25
+ - [ ] Run `cargo update` to regenerate
26
+ - [ ] Stage the regenerated file
27
+
28
+ #### 2. `src/utils/helpers.rs` (deleted in incoming, modified in current)
29
+
30
+ **Conflict Type**: deleted-modified
31
+ **Strategy**: Backup modifications and apply to new location if applicable
32
+ **Rationale**: File may have been moved/renamed; need to preserve modifications
33
+ **Risk**: Medium - Requires analysis of where changes should go
34
+ **Action Items**:
35
+
36
+ - [ ] Run handle-deleted-modified script to create backup
37
+ - [ ] Review analysis report for potential relocation targets
38
+ - [ ] Apply modifications to new location if found
39
+
40
+ #### 3. `src/lib.rs`
41
+
42
+ **Conflict Type**: imports
43
+ **Strategy**: Merge all unique imports from both branches
44
+ **Rationale**: Both branches likely added new dependencies; combining ensures all code works
45
+ **Risk**: Low - Standard import merge pattern
46
+ **Action Items**:
47
+
48
+ - [ ] Extract imports from both sides
49
+ - [ ] Deduplicate and sort by module
50
+ - [ ] Verify no unused imports
51
+
52
+ #### 4. `tests/integration_test.rs`
53
+
54
+ **Conflict Type**: tests
55
+ **Strategy**: Include all test cases from both branches
56
+ **Rationale**: Both branches added new test coverage; all tests should be preserved
57
+ **Risk**: Low - Tests are additive
58
+ **Action Items**:
59
+
60
+ - [ ] Merge test functions from both branches
61
+ - [ ] Combine test fixtures if needed
62
+ - [ ] Ensure no duplicate test names
63
+
64
+ #### 5. `src/config.rs`
65
+
66
+ **Conflict Type**: code logic
67
+ **Strategy**: Need user input - both branches modify validation logic differently
68
+ **Rationale**: Cannot determine correct business logic from code alone
69
+ **Risk**: High - Affects core validation behavior
70
+ **Action Items**:
71
+
72
+ - [ ] Present both approaches to user
73
+ - [ ] Get user decision on which validation logic to use
74
+ - [ ] Implement chosen approach
75
+
76
+ ### Execution Order
77
+
78
+ 1. **Phase 1: Deleted-Modified Files** - Handle helpers.rs backup and analysis
79
+ 2. **Phase 2: Generated Files** - Regenerate Cargo.lock
80
+ 3. **Phase 3: Low-Risk Merges** - Merge imports in lib.rs and tests in integration_test.rs
81
+ 4. **Phase 4: High-Risk Merges** - Resolve config.rs after user input
82
+ 5. **Phase 5: Validation** - Compile, test, verify
83
+
84
+ ### Questions/Decisions Needed
85
+
86
+ - [ ] **src/config.rs**: Validation logic conflict - which approach should we use?
87
+ - Current branch: Validates using regex patterns
88
+ - Incoming branch: Validates using a validation library
89
+ - Options: (1) Keep current, (2) Keep incoming, (3) Use both with feature flag
90
+
91
+ ### Validation Steps
92
+
93
+ - [ ] Run conflict validation script
94
+ - [ ] Compile with `cargo check`
95
+ - [ ] Run full test suite with `cargo test`
96
+ - [ ] Manual verification of config.rs changes
@@ -0,0 +1,183 @@
1
+ #!/bin/bash
2
+ # Handles deleted-but-modified file conflicts by creating backups and analyzing where changes should go
3
+ # Usage: ./handle-deleted-modified.sh
4
+
5
+ set -euo pipefail
6
+
7
+ # Colors
8
+ RED='\033[0;31m'
9
+ GREEN='\033[0;32m'
10
+ YELLOW='\033[1;33m'
11
+ BLUE='\033[0;34m'
12
+ NC='\033[0m'
13
+
14
+ BACKUP_DIR=".git/conflict-backups/$(date +%Y%m%d-%H%M%S)"
15
+
16
+ # Check if we're in a git repository
17
+ if ! git rev-parse --git-dir > /dev/null 2>&1; then
18
+ echo -e "${RED}Error: Not a git repository${NC}" >&2
19
+ exit 1
20
+ fi
21
+
22
+ # Find files with delete/modify conflicts
23
+ find_deleted_modified() {
24
+ git status --porcelain | grep -E '^(DU|UD|DD|UA|AU|AA)' || true
25
+ }
26
+
27
+ # Get the content from the branch that modified the file
28
+ get_modified_content() {
29
+ local file="$1"
30
+ local status="$2"
31
+
32
+ case "$status" in
33
+ DU) # Deleted by us, modified by them
34
+ git show ":3:$file" 2>/dev/null || echo ""
35
+ ;;
36
+ UD) # Deleted by them, modified by us
37
+ git show ":2:$file" 2>/dev/null || echo ""
38
+ ;;
39
+ *)
40
+ echo ""
41
+ ;;
42
+ esac
43
+ }
44
+
45
+ # Main processing
46
+ echo -e "${BLUE}🔍 Checking for deleted-but-modified files...${NC}"
47
+ echo ""
48
+
49
+ deleted_modified=$(find_deleted_modified)
50
+
51
+ if [[ -z "$deleted_modified" ]]; then
52
+ echo -e "${GREEN}✓ No deleted-but-modified conflicts found${NC}"
53
+ exit 0
54
+ fi
55
+
56
+ # Create backup directory
57
+ mkdir -p "$BACKUP_DIR"
58
+ echo -e "${YELLOW}Creating backups in: $BACKUP_DIR${NC}"
59
+ echo ""
60
+
61
+ # Process each conflicted file
62
+ while IFS= read -r line; do
63
+ status="${line:0:2}"
64
+ file="${line:3}"
65
+
66
+ echo -e "${YELLOW}Processing: $file (status: $status)${NC}"
67
+
68
+ # Get the modified content
69
+ content=$(get_modified_content "$file" "$status")
70
+
71
+ if [[ -n "$content" ]]; then
72
+ # Create backup with directory structure
73
+ backup_file="$BACKUP_DIR/$file"
74
+ backup_dir=$(dirname "$backup_file")
75
+ mkdir -p "$backup_dir"
76
+
77
+ echo "$content" > "$backup_file"
78
+ echo -e " ${GREEN}✓${NC} Backed up to: $backup_file"
79
+
80
+ # Try to find similar files (potential relocation targets)
81
+ filename=$(basename "$file")
82
+ base_name="${filename%.*}"
83
+ extension="${filename##*.}"
84
+
85
+ echo -e " ${BLUE}Searching for potential relocation targets...${NC}"
86
+
87
+ # Search for files with similar names
88
+ similar_files=$(git ls-files | grep -i "$base_name" | grep -v "^$file$" || true)
89
+
90
+ if [[ -n "$similar_files" ]]; then
91
+ echo -e " ${YELLOW}⚠ Potential relocation targets:${NC}"
92
+ echo "$similar_files" | sed 's/^/ → /'
93
+ else
94
+ echo -e " ${YELLOW}⚠ No obvious relocation target found${NC}"
95
+ echo -e " ${YELLOW}⚠ Changes may need to be manually integrated${NC}"
96
+ fi
97
+
98
+ # Create an analysis file
99
+ analysis_file="$BACKUP_DIR/$file.analysis.txt"
100
+ cat > "$analysis_file" << EOF
101
+ File: $file
102
+ Status: $status
103
+ Conflict Type: $([ "$status" = "DU" ] && echo "Deleted by us, modified by them" || echo "Deleted by them, modified by us")
104
+
105
+ Backed up to: $backup_file
106
+
107
+ Potential Actions:
108
+ 1. If the file was renamed/moved: Apply changes to the new location
109
+ 2. If the file was deleted intentionally: Review if changes are still needed
110
+ 3. If the file was refactored: Distribute changes to new file structure
111
+
112
+ Potential Relocation Targets:
113
+ $similar_files
114
+
115
+ To view the changes:
116
+ cat "$backup_file"
117
+
118
+ To compare with similar files:
119
+ $(echo "$similar_files" | while read -r sf; do echo " diff \"$backup_file\" \"$sf\""; done)
120
+ EOF
121
+
122
+ echo -e " ${GREEN}✓${NC} Analysis saved to: $analysis_file"
123
+ else
124
+ echo -e " ${RED}✗${NC} Could not retrieve content"
125
+ fi
126
+
127
+ # Resolve by removing (user must manually apply changes)
128
+ if [[ "$status" == "DU" ]]; then
129
+ git rm "$file" 2>/dev/null || true
130
+ echo -e " ${GREEN}✓${NC} Marked as deleted (ours)"
131
+ elif [[ "$status" == "UD" ]]; then
132
+ git add "$file" 2>/dev/null || git rm "$file" 2>/dev/null || true
133
+ echo -e " ${GREEN}✓${NC} Resolved conflict"
134
+ fi
135
+
136
+ echo ""
137
+ done <<< "$deleted_modified"
138
+
139
+ # Create a summary file
140
+ summary_file="$BACKUP_DIR/SUMMARY.md"
141
+ cat > "$summary_file" << EOF
142
+ # Conflict Resolution Summary
143
+
144
+ Generated: $(date)
145
+
146
+ ## Deleted-Modified Files Processed
147
+
148
+ $(echo "$deleted_modified" | while IFS= read -r line; do
149
+ status="${line:0:2}"
150
+ file="${line:3}"
151
+ echo "- **$file** (status: $status)"
152
+ done)
153
+
154
+ ## Next Steps
155
+
156
+ 1. Review each backup file in this directory
157
+ 2. Identify where the changes should be applied
158
+ 3. Manually integrate the changes into the appropriate files
159
+ 4. Run tests to validate the integration
160
+ 5. Commit the resolved changes
161
+
162
+ ## Files Structure
163
+
164
+ $(find "$BACKUP_DIR" -type f -name "*.analysis.txt" | while read -r f; do
165
+ file=$(basename "$f" .analysis.txt)
166
+ echo "- \`$file\`"
167
+ echo " - Backup: \`$file\`"
168
+ echo " - Analysis: \`$file.analysis.txt\`"
169
+ done)
170
+
171
+ EOF
172
+
173
+ echo -e "${GREEN}✓ Summary created: $summary_file${NC}"
174
+ echo ""
175
+ echo -e "${BLUE}═══════════════════════════════════════════════════════${NC}"
176
+ echo -e "${GREEN}✓ All deleted-but-modified files backed up successfully${NC}"
177
+ echo -e "${BLUE}═══════════════════════════════════════════════════════${NC}"
178
+ echo ""
179
+ echo "Next steps:"
180
+ echo " 1. Review backups: ls -la $BACKUP_DIR"
181
+ echo " 2. Read summary: cat $summary_file"
182
+ echo " 3. Integrate changes manually into appropriate files"
183
+ echo " 4. Run validation: .forge/skills/resolve-conflicts/scripts/validate-conflicts.sh"