@eldrforge/kodrdriv 1.2.29 → 1.2.123
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/dist/application.js +16 -13
- package/dist/application.js.map +1 -1
- package/dist/arguments.js +5 -5
- package/dist/arguments.js.map +1 -1
- package/dist/commands/audio-review.js +2 -5
- package/dist/commands/audio-review.js.map +1 -1
- package/dist/commands/clean.js +2 -4
- package/dist/commands/clean.js.map +1 -1
- package/dist/commands/commit.js +3 -6
- package/dist/commands/commit.js.map +1 -1
- package/dist/commands/development.js +7 -7
- package/dist/commands/development.js.map +1 -1
- package/dist/commands/link.js +3 -7
- package/dist/commands/link.js.map +1 -1
- package/dist/commands/precommit.js +99 -0
- package/dist/commands/precommit.js.map +1 -0
- package/dist/commands/publish.js +47 -32
- package/dist/commands/publish.js.map +1 -1
- package/dist/commands/release.js +3 -7
- package/dist/commands/release.js.map +1 -1
- package/dist/commands/review.js +4 -6
- package/dist/commands/review.js.map +1 -1
- package/dist/commands/tree.js +213 -84
- package/dist/commands/tree.js.map +1 -1
- package/dist/commands/unlink.js +3 -7
- package/dist/commands/unlink.js.map +1 -1
- package/dist/commands/updates.js +2 -4
- package/dist/commands/updates.js.map +1 -1
- package/dist/commands/versions.js +3 -7
- package/dist/commands/versions.js.map +1 -1
- package/dist/constants.js +4 -2
- package/dist/constants.js.map +1 -1
- package/dist/content/files.js +2 -4
- package/dist/content/files.js.map +1 -1
- package/dist/execution/CommandValidator.js +33 -1
- package/dist/execution/CommandValidator.js.map +1 -1
- package/dist/execution/ResourceMonitor.js +26 -1
- package/dist/execution/ResourceMonitor.js.map +1 -1
- package/dist/execution/TreeExecutionAdapter.js +2 -2
- package/dist/execution/TreeExecutionAdapter.js.map +1 -1
- package/dist/util/checkpointManager.js +2 -4
- package/dist/util/checkpointManager.js.map +1 -1
- package/dist/util/dependencyGraph.js +2 -4
- package/dist/util/dependencyGraph.js.map +1 -1
- package/dist/util/general.js +7 -107
- package/dist/util/general.js.map +1 -1
- package/dist/util/gitMutex.js +63 -18
- package/dist/util/gitMutex.js.map +1 -1
- package/dist/util/precommitOptimizations.js +310 -0
- package/dist/util/precommitOptimizations.js.map +1 -0
- package/dist/util/storageAdapter.js +2 -6
- package/dist/util/storageAdapter.js.map +1 -1
- package/dist/utils/branchState.js +178 -45
- package/dist/utils/branchState.js.map +1 -1
- package/package.json +6 -5
- package/AI-FRIENDLY-LOGGING-GUIDE.md +0 -237
- package/AI-LOGGING-MIGRATION-COMPLETE.md +0 -371
- package/ALREADY-PUBLISHED-PACKAGES-FIX.md +0 -264
- package/AUDIT-BRANCHES-PROGRESS-FIX.md +0 -90
- package/AUDIT-EXAMPLE-OUTPUT.md +0 -113
- package/CHECKPOINT-RECOVERY-FIX.md +0 -450
- package/LOGGING-MIGRATION-STATUS.md +0 -186
- package/MONOREPO-PUBLISH-IMPROVEMENTS.md +0 -281
- package/PARALLEL-EXECUTION-FIXES.md +0 -132
- package/PARALLEL-PUBLISH-DEBUGGING-GUIDE.md +0 -441
- package/PARALLEL-PUBLISH-FIXES-IMPLEMENTED.md +0 -405
- package/PARALLEL-PUBLISH-IMPROVEMENTS-IMPLEMENTED.md +0 -439
- package/PARALLEL-PUBLISH-LOGGING-FIXES.md +0 -274
- package/PARALLEL-PUBLISH-QUICK-REFERENCE.md +0 -375
- package/PARALLEL_EXECUTION_FIX.md +0 -146
- package/PUBLISH_IMPROVEMENTS_IMPLEMENTED.md +0 -294
- package/RECOVERY-FIXES.md +0 -72
- package/SUBMODULE-LOCK-FIX.md +0 -132
- package/VERSION-AUDIT-FIX.md +0 -333
- package/WORKFLOW-PRECHECK-IMPLEMENTATION.md +0 -239
- package/WORKFLOW-SKIP-SUMMARY.md +0 -121
- package/dist/util/safety.js +0 -166
- package/dist/util/safety.js.map +0 -1
- package/dist/util/stdin.js +0 -133
- package/dist/util/stdin.js.map +0 -1
- package/dist/util/storage.js +0 -187
- package/dist/util/storage.js.map +0 -1
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
# Kodrdriv Publish Improvements - Implementation Summary
|
|
2
|
-
|
|
3
|
-
**Date:** December 11, 2025
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
|
|
7
|
-
This document summarizes the improvements made to kodrdriv's publish workflow based on feedback from a catastrophic parallel publish failure in another project. The improvements focus on better error handling, user feedback, and git operations.
|
|
8
|
-
|
|
9
|
-
## Critical Issues Addressed
|
|
10
|
-
|
|
11
|
-
### 1. ✅ PR Already Exists Error (P0 - Blocker)
|
|
12
|
-
|
|
13
|
-
**Problem:** When a PR already existed from a previous run, the publish command would:
|
|
14
|
-
- Run expensive build operations
|
|
15
|
-
- Generate release notes with OpenAI (27+ seconds, API costs)
|
|
16
|
-
- Push changes
|
|
17
|
-
- THEN fail with "PR already exists" error
|
|
18
|
-
|
|
19
|
-
**Solution Implemented:**
|
|
20
|
-
|
|
21
|
-
Modified `github-tools/src/github.ts` to make PR creation more resilient:
|
|
22
|
-
|
|
23
|
-
```typescript
|
|
24
|
-
// Enhanced error handling in createPullRequest()
|
|
25
|
-
if (existingPR && existingPR.base.ref === base) {
|
|
26
|
-
logger.info(`♻️ Found and reusing existing PR #${existingPR.number} (created after initial check)`);
|
|
27
|
-
logger.info(` URL: ${existingPR.html_url}`);
|
|
28
|
-
logger.info(` This can happen when PRs are created in parallel or from a previous failed run`);
|
|
29
|
-
return existingPR;
|
|
30
|
-
}
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
**Impact:**
|
|
34
|
-
- No more wasted build time or API costs
|
|
35
|
-
- Automatically resumes existing PRs
|
|
36
|
-
- Better handling of parallel publish operations
|
|
37
|
-
|
|
38
|
-
### 2. ✅ Silent Long Operations (P0 - Critical UX)
|
|
39
|
-
|
|
40
|
-
**Problem:** During 27-second OpenAI API call, there was zero terminal output, making users think the command was frozen.
|
|
41
|
-
|
|
42
|
-
**Solution Implemented:**
|
|
43
|
-
|
|
44
|
-
Added progress indicator to `ai-service/src/ai.ts`:
|
|
45
|
-
|
|
46
|
-
```typescript
|
|
47
|
-
// Progress indicator that updates every 5 seconds
|
|
48
|
-
let progressIntervalId: NodeJS.Timeout | null = null;
|
|
49
|
-
progressIntervalId = setInterval(() => {
|
|
50
|
-
const elapsed = Math.round((Date.now() - startTime) / 1000);
|
|
51
|
-
logger.info(' ⏳ Waiting for response... %ds', elapsed);
|
|
52
|
-
}, 5000);
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
**Example Output:**
|
|
56
|
-
```
|
|
57
|
-
🤖 Making request to OpenAI
|
|
58
|
-
Model: gpt-5-mini | Reasoning: low
|
|
59
|
-
Request size: 104.93 KB (107,446 bytes)
|
|
60
|
-
⏳ Waiting for response... 5s
|
|
61
|
-
⏳ Waiting for response... 10s
|
|
62
|
-
⏳ Waiting for response... 15s
|
|
63
|
-
⏳ Waiting for response... 20s
|
|
64
|
-
⏳ Waiting for response... 25s
|
|
65
|
-
Response size: 7.22 KB (7,394 bytes)
|
|
66
|
-
Time: 27.2s
|
|
67
|
-
Token usage: 25,089 prompt + 1,926 completion = 27,015 total
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
**Impact:**
|
|
71
|
-
- Users know the command is still running
|
|
72
|
-
- Clear indication of progress
|
|
73
|
-
- No more "is it frozen?" confusion
|
|
74
|
-
|
|
75
|
-
### 3. ✅ Git Rebase Errors (P1 - Configuration Conflicts)
|
|
76
|
-
|
|
77
|
-
**Problem:** `git pull origin branch --no-edit` conflicted with users who have `pull.rebase = true` in their git config, causing "Cannot rebase onto multiple branches" errors.
|
|
78
|
-
|
|
79
|
-
**Solution Implemented:**
|
|
80
|
-
|
|
81
|
-
Replaced all `git pull` commands with explicit `git fetch` + `git merge`:
|
|
82
|
-
|
|
83
|
-
**Files Updated:**
|
|
84
|
-
- `kodrdriv/src/commands/publish.ts` (2 occurrences)
|
|
85
|
-
- `kodrdriv/src/commands/development.ts` (1 occurrence)
|
|
86
|
-
|
|
87
|
-
```typescript
|
|
88
|
-
// Old (problematic):
|
|
89
|
-
await run(`git pull origin ${branch} --no-edit`);
|
|
90
|
-
|
|
91
|
-
// New (explicit and config-independent):
|
|
92
|
-
await run(`git fetch origin ${branch}`);
|
|
93
|
-
await run(`git merge origin/${branch} --no-ff --no-edit`);
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
**Impact:**
|
|
97
|
-
- Works with any git config (`pull.rebase = true` or `false`)
|
|
98
|
-
- No more mysterious rebase errors
|
|
99
|
-
- Explicit merge behavior
|
|
100
|
-
|
|
101
|
-
### 4. ✅ Better Skip Messages (P1 - UX)
|
|
102
|
-
|
|
103
|
-
**Problem:** Skip messages were cryptic:
|
|
104
|
-
```
|
|
105
|
-
Skipping publish: Only version changed in package.json (plus lockfile).
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
**Solution Implemented:**
|
|
109
|
-
|
|
110
|
-
Enhanced skip messages in `kodrdriv/src/commands/publish.ts`:
|
|
111
|
-
|
|
112
|
-
```typescript
|
|
113
|
-
return {
|
|
114
|
-
necessary: false,
|
|
115
|
-
reason: `No meaningful changes detected:
|
|
116
|
-
• Current version: ${currentVersion}
|
|
117
|
-
• Target branch version: ${targetVersion}
|
|
118
|
-
• Only package.json version field differs
|
|
119
|
-
|
|
120
|
-
To force republish: Add meaningful code changes or use --force (not yet implemented)`
|
|
121
|
-
};
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
**Example Output:**
|
|
125
|
-
```
|
|
126
|
-
⏭️ Skipping publish: No meaningful changes detected:
|
|
127
|
-
• Current version: 0.0.133-dev.0
|
|
128
|
-
• Target branch version: 0.0.132
|
|
129
|
-
• Only package.json version field differs
|
|
130
|
-
|
|
131
|
-
To force republish: Add meaningful code changes or use --force (not yet implemented)
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
**Impact:**
|
|
135
|
-
- Clear explanation of why skipped
|
|
136
|
-
- Shows version information
|
|
137
|
-
- Provides actionable next steps
|
|
138
|
-
|
|
139
|
-
### 5. ✅ Enhanced Summary (P1 - UX)
|
|
140
|
-
|
|
141
|
-
**Problem:** Tree publish summary was minimal and didn't provide enough context after execution.
|
|
142
|
-
|
|
143
|
-
**Solution Implemented:**
|
|
144
|
-
|
|
145
|
-
Complete rewrite of `formatParallelResult()` in `kodrdriv/src/execution/TreeExecutionAdapter.ts`:
|
|
146
|
-
|
|
147
|
-
**Example Output:**
|
|
148
|
-
```
|
|
149
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
150
|
-
📊 Publish Summary
|
|
151
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
152
|
-
|
|
153
|
-
✅ Published (2):
|
|
154
|
-
- @project/lib
|
|
155
|
-
- @project/hooks
|
|
156
|
-
|
|
157
|
-
⏭️ Skipped (6) - no code changes:
|
|
158
|
-
- @project/interfaces
|
|
159
|
-
- @project/core
|
|
160
|
-
- @project/calc
|
|
161
|
-
- @project/client-api
|
|
162
|
-
- @project/cache
|
|
163
|
-
- @project/providers
|
|
164
|
-
|
|
165
|
-
❌ Failed (1):
|
|
166
|
-
- @project/api
|
|
167
|
-
|
|
168
|
-
⊘ Skipped due to dependencies (2):
|
|
169
|
-
- @project/ullr
|
|
170
|
-
- @project/e2e
|
|
171
|
-
|
|
172
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
173
|
-
|
|
174
|
-
Total time: 8m 34s
|
|
175
|
-
Success rate: 75% (8/11 packages processed)
|
|
176
|
-
Peak concurrency: 4 packages
|
|
177
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
178
|
-
|
|
179
|
-
📋 Next steps:
|
|
180
|
-
1. Review the errors above for each failed package
|
|
181
|
-
2. Fix the issues in the failed packages
|
|
182
|
-
3. Retry the publish command
|
|
183
|
-
|
|
184
|
-
Note: Once failed packages are fixed, their dependent packages will also be published.
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
**Impact:**
|
|
188
|
-
- Clear categorization of results
|
|
189
|
-
- Shows all packages and their status
|
|
190
|
-
- Time and success rate metrics
|
|
191
|
-
- Actionable next steps
|
|
192
|
-
|
|
193
|
-
## Features Already Implemented
|
|
194
|
-
|
|
195
|
-
### 6. ✅ Dry Run Mode
|
|
196
|
-
|
|
197
|
-
**Status:** Already implemented in tree commands
|
|
198
|
-
|
|
199
|
-
The feedback suggested adding `--dry-run`, but it's already fully implemented:
|
|
200
|
-
- Propagates to all subcommands
|
|
201
|
-
- Shows preview of what would be published
|
|
202
|
-
- Prevents actual execution
|
|
203
|
-
|
|
204
|
-
**Usage:**
|
|
205
|
-
```bash
|
|
206
|
-
kodrdriv tree publish --parallel --dry-run
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
### 7. ✅ Resume/Continue from Failure
|
|
210
|
-
|
|
211
|
-
**Status:** Already implemented via multiple options
|
|
212
|
-
|
|
213
|
-
The feedback suggested adding `--continue-from`, but equivalent functionality exists:
|
|
214
|
-
- `--skip <packages>` - Skip specific packages and their dependents
|
|
215
|
-
- `--retry-failed` - Retry all previously failed packages
|
|
216
|
-
- `--skip-failed` - Skip failed packages and continue with remaining
|
|
217
|
-
- `--mark-completed <packages>` - Mark packages as completed for recovery
|
|
218
|
-
|
|
219
|
-
**Usage:**
|
|
220
|
-
```bash
|
|
221
|
-
# Skip a problematic package
|
|
222
|
-
kodrdriv tree publish --skip lib
|
|
223
|
-
|
|
224
|
-
# Retry after fixing failures
|
|
225
|
-
kodrdriv tree publish --retry-failed
|
|
226
|
-
|
|
227
|
-
# Mark a package as completed and continue
|
|
228
|
-
kodrdriv tree publish --mark-completed lib
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
## Testing
|
|
232
|
-
|
|
233
|
-
All changes have been compiled and tested:
|
|
234
|
-
|
|
235
|
-
```bash
|
|
236
|
-
# ai-service
|
|
237
|
-
cd ~gitw/calenvarek/ai-service
|
|
238
|
-
npm run build # ✅ Success
|
|
239
|
-
|
|
240
|
-
# github-tools
|
|
241
|
-
cd ~gitw/calenvarek/github-tools
|
|
242
|
-
npm run build # ✅ Success
|
|
243
|
-
|
|
244
|
-
# kodrdriv
|
|
245
|
-
cd ~gitw/calenvarek/kodrdriv
|
|
246
|
-
npm run build # ✅ Success
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
No linter errors detected in any of the modified files.
|
|
250
|
-
|
|
251
|
-
## Files Modified
|
|
252
|
-
|
|
253
|
-
### ai-service
|
|
254
|
-
- `src/ai.ts` - Added progress indicator for long-running OpenAI API calls
|
|
255
|
-
|
|
256
|
-
### github-tools
|
|
257
|
-
- `src/github.ts` - Enhanced PR creation error handling to reuse existing PRs
|
|
258
|
-
|
|
259
|
-
### kodrdriv
|
|
260
|
-
- `src/commands/publish.ts` - Fixed git sync, improved skip messages
|
|
261
|
-
- `src/commands/development.ts` - Fixed git sync
|
|
262
|
-
- `src/execution/TreeExecutionAdapter.ts` - Enhanced summary formatting
|
|
263
|
-
|
|
264
|
-
## Impact Summary
|
|
265
|
-
|
|
266
|
-
| Issue | Priority | Status | Impact |
|
|
267
|
-
|-------|----------|--------|--------|
|
|
268
|
-
| PR Already Exists | P0 | ✅ Fixed | Saves build time and API costs, auto-resumes |
|
|
269
|
-
| Silent Long Operations | P0 | ✅ Fixed | Users know command is running, eliminates confusion |
|
|
270
|
-
| Git Rebase Errors | P1 | ✅ Fixed | Works with any git config, no more errors |
|
|
271
|
-
| Better Skip Messages | P1 | ✅ Fixed | Clear explanations with version info and next steps |
|
|
272
|
-
| Enhanced Summary | P1 | ✅ Fixed | Complete view of results with metrics and guidance |
|
|
273
|
-
| Dry Run Mode | P2 | ✅ Exists | Already fully implemented |
|
|
274
|
-
| Resume from Failure | P2 | ✅ Exists | Multiple options available |
|
|
275
|
-
|
|
276
|
-
## Recommendations for Future Improvements
|
|
277
|
-
|
|
278
|
-
Based on the feedback document, these could be considered for future releases:
|
|
279
|
-
|
|
280
|
-
1. **Cost Estimation** - Show estimated API costs before running expensive operations
|
|
281
|
-
2. **Interactive Prompts** - Add confirmation prompts for expensive operations in non-sendit mode
|
|
282
|
-
3. **Parallel Progress Dashboard** - Real-time dashboard showing status of all packages during parallel execution
|
|
283
|
-
4. **--force flag** - Force republish even when no code changes detected
|
|
284
|
-
|
|
285
|
-
## Conclusion
|
|
286
|
-
|
|
287
|
-
All critical and high-priority issues from the feedback have been addressed. The kodrdriv publish system now provides:
|
|
288
|
-
- ✅ Better error recovery (auto-resume existing PRs)
|
|
289
|
-
- ✅ Better user feedback (progress indicators during long operations)
|
|
290
|
-
- ✅ Better reliability (git operations work with any config)
|
|
291
|
-
- ✅ Better UX (clear skip messages and comprehensive summaries)
|
|
292
|
-
|
|
293
|
-
The changes maintain backward compatibility while significantly improving the user experience during publish operations.
|
|
294
|
-
|
package/RECOVERY-FIXES.md
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
# Recovery System Fixes
|
|
2
|
-
|
|
3
|
-
## Issues Fixed
|
|
4
|
-
|
|
5
|
-
### 1. Checkpoint Deleted When Packages Are Skipped
|
|
6
|
-
|
|
7
|
-
**Problem**: When using `--mark-completed` to mark a failed package as done, the system would delete the checkpoint even though dependent packages were skipped. This resulted in:
|
|
8
|
-
- Misleading "All X packages completed successfully! 🎉" message when packages were actually skipped
|
|
9
|
-
- Lost checkpoint making it impossible to continue the execution
|
|
10
|
-
- No way to resume and complete the skipped packages
|
|
11
|
-
|
|
12
|
-
**Root Cause**: In `DynamicTaskPool.ts`, the cleanup logic only checked for failed packages, not skipped packages:
|
|
13
|
-
|
|
14
|
-
```typescript
|
|
15
|
-
// Before (WRONG)
|
|
16
|
-
if (this.state.failed.length === 0) {
|
|
17
|
-
await this.checkpointManager.cleanup(); // Deletes checkpoint
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// After (FIXED)
|
|
21
|
-
const allCompleted = this.state.failed.length === 0 && this.state.skipped.length === 0;
|
|
22
|
-
if (allCompleted) {
|
|
23
|
-
await this.checkpointManager.cleanup();
|
|
24
|
-
}
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
**Fix**: Modified `src/execution/DynamicTaskPool.ts` to preserve the checkpoint when packages are skipped, and updated `src/execution/TreeExecutionAdapter.ts` to show the correct message when packages are skipped.
|
|
28
|
-
|
|
29
|
-
### 2. Inconsistent Package Identifier Format
|
|
30
|
-
|
|
31
|
-
**Problem**: The `--mark-completed` option required NPM package names (e.g., `"@eldrforge/git-tools"`), while `--start-from` accepted directory names (e.g., `"git-tools"`). This was confusing and inconsistent.
|
|
32
|
-
|
|
33
|
-
**Fix**: Updated `src/execution/RecoveryManager.ts` to accept both directory names and package names for `--mark-completed`, matching the behavior of `--start-from`:
|
|
34
|
-
|
|
35
|
-
```typescript
|
|
36
|
-
// Now both work:
|
|
37
|
-
kodrdriv tree publish --continue --mark-completed "git-tools"
|
|
38
|
-
kodrdriv tree publish --continue --mark-completed "@eldrforge/git-tools"
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
The system will:
|
|
42
|
-
1. Try exact package name match first
|
|
43
|
-
2. Fall back to directory name match
|
|
44
|
-
3. Provide helpful error with available packages if not found
|
|
45
|
-
|
|
46
|
-
**Updated Files**:
|
|
47
|
-
- `src/execution/RecoveryManager.ts` - Added `resolvePackageName()` helper and updated `markCompleted()`
|
|
48
|
-
- `src/arguments.ts` - Updated help text
|
|
49
|
-
- `src/ui/ProgressFormatter.ts` - Updated recovery guidance to use directory names
|
|
50
|
-
|
|
51
|
-
## Testing
|
|
52
|
-
|
|
53
|
-
All existing tests pass, including the specific RecoveryManager tests.
|
|
54
|
-
|
|
55
|
-
## Usage
|
|
56
|
-
|
|
57
|
-
Now you can use directory names (much simpler):
|
|
58
|
-
|
|
59
|
-
```bash
|
|
60
|
-
# Start a parallel publish
|
|
61
|
-
kodrdriv tree publish --parallel
|
|
62
|
-
|
|
63
|
-
# If git-tools fails due to merge conflict, fix it manually, then:
|
|
64
|
-
kodrdriv tree publish --continue --mark-completed "git-tools"
|
|
65
|
-
|
|
66
|
-
# The remaining packages (ai-service, github-tools, kodrdriv) will now execute
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
The system will:
|
|
70
|
-
1. Keep the checkpoint if packages are skipped
|
|
71
|
-
2. Show accurate status messages
|
|
72
|
-
3. Allow you to continue execution to complete the skipped packages
|
package/SUBMODULE-LOCK-FIX.md
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
# Git Submodule Lock File Fix
|
|
2
|
-
|
|
3
|
-
## Problem
|
|
4
|
-
|
|
5
|
-
The file-based lock mechanism used to prevent concurrent git operations was failing when used with git submodules. The issue occurred because:
|
|
6
|
-
|
|
7
|
-
1. In regular git repositories, `.git` is a directory
|
|
8
|
-
2. In git submodules, `.git` is a file containing a `gitdir:` reference pointing to the actual git directory
|
|
9
|
-
3. The code assumed `.git` was always a directory and tried to create lock files in `.git/kodrdriv.lock`
|
|
10
|
-
4. This caused `ENOTDIR` errors when operating on submodules
|
|
11
|
-
|
|
12
|
-
## Example Submodule Structure
|
|
13
|
-
|
|
14
|
-
```
|
|
15
|
-
my-submodule/
|
|
16
|
-
├── .git # FILE (not directory) containing: "gitdir: ../.git/modules/my-submodule"
|
|
17
|
-
├── src/
|
|
18
|
-
└── package.json
|
|
19
|
-
|
|
20
|
-
parent-repo/
|
|
21
|
-
└── .git/
|
|
22
|
-
└── modules/
|
|
23
|
-
└── my-submodule/ # Actual git directory for the submodule
|
|
24
|
-
├── HEAD
|
|
25
|
-
├── refs/
|
|
26
|
-
└── objects/
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## Solution
|
|
30
|
-
|
|
31
|
-
Modified `src/util/fileLock.ts` to handle both regular repositories and submodules:
|
|
32
|
-
|
|
33
|
-
### Key Changes
|
|
34
|
-
|
|
35
|
-
1. **Added `resolveGitDirectory()` method** that:
|
|
36
|
-
- Checks if `.git` is a directory (regular repo) or file (submodule)
|
|
37
|
-
- If it's a file, reads and parses the `gitdir:` reference
|
|
38
|
-
- Resolves the gitdir path (handles both relative and absolute paths)
|
|
39
|
-
- Returns the actual git directory path where locks can be created
|
|
40
|
-
|
|
41
|
-
2. **Updated `getRepositoryLock()` method** to:
|
|
42
|
-
- Use `resolveGitDirectory()` instead of assuming `.git` is a directory
|
|
43
|
-
- Create lock files in the resolved git directory
|
|
44
|
-
- Log the actual lock path for debugging
|
|
45
|
-
|
|
46
|
-
### Code Implementation
|
|
47
|
-
|
|
48
|
-
```typescript
|
|
49
|
-
private resolveGitDirectory(repoPath: string): string {
|
|
50
|
-
const gitPath = path.join(repoPath, '.git');
|
|
51
|
-
|
|
52
|
-
try {
|
|
53
|
-
const stat = fs.statSync(gitPath);
|
|
54
|
-
|
|
55
|
-
if (stat.isDirectory()) {
|
|
56
|
-
// Regular git repository
|
|
57
|
-
return gitPath;
|
|
58
|
-
} else if (stat.isFile()) {
|
|
59
|
-
// Git submodule - .git is a file with format: gitdir: <path>
|
|
60
|
-
const gitFileContent = fs.readFileSync(gitPath, 'utf-8').trim();
|
|
61
|
-
const match = gitFileContent.match(/^gitdir:\s*(.+)$/);
|
|
62
|
-
|
|
63
|
-
if (match && match[1]) {
|
|
64
|
-
// Resolve the gitdir path (it's relative to the repo path)
|
|
65
|
-
const gitDirPath = path.resolve(repoPath, match[1]);
|
|
66
|
-
this.logger.debug(`Resolved submodule gitdir: ${gitDirPath}`);
|
|
67
|
-
|
|
68
|
-
// Ensure the git directory exists
|
|
69
|
-
if (!fs.existsSync(gitDirPath)) {
|
|
70
|
-
throw new Error(`Submodule git directory does not exist: ${gitDirPath}`);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return gitDirPath;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
throw new Error(`Invalid .git file format in ${gitPath}: ${gitFileContent}`);
|
|
77
|
-
}
|
|
78
|
-
} catch (error: any) {
|
|
79
|
-
// Check if error is from statSync (file doesn't exist)
|
|
80
|
-
if (error.code === 'ENOENT') {
|
|
81
|
-
throw new Error(`No .git directory or file found in ${repoPath}`);
|
|
82
|
-
}
|
|
83
|
-
throw new Error(`Failed to resolve git directory for ${repoPath}: ${error.message}`);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
throw new Error(`No .git directory or file found in ${repoPath}`);
|
|
87
|
-
}
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
## Testing
|
|
91
|
-
|
|
92
|
-
Comprehensive test suite added in `tests/fileLock.test.ts` covering:
|
|
93
|
-
|
|
94
|
-
1. **Basic lock operations**
|
|
95
|
-
- Acquire and release locks
|
|
96
|
-
- Block concurrent lock acquisition
|
|
97
|
-
- Handle stale locks
|
|
98
|
-
|
|
99
|
-
2. **Regular repository support**
|
|
100
|
-
- Create locks in `.git` directory
|
|
101
|
-
|
|
102
|
-
3. **Submodule support** (NEW)
|
|
103
|
-
- Handle `.git` file with `gitdir:` reference
|
|
104
|
-
- Resolve relative gitdir paths
|
|
105
|
-
- Create locks in the actual git directory
|
|
106
|
-
- Proper error handling for missing submodule directories
|
|
107
|
-
- Proper error handling for invalid `.git` file format
|
|
108
|
-
|
|
109
|
-
4. **Lock manager functionality**
|
|
110
|
-
- Execute operations under lock
|
|
111
|
-
- Release locks on operation failure
|
|
112
|
-
- Serialize multiple operations on same repo
|
|
113
|
-
|
|
114
|
-
All 12 tests pass successfully with 86%+ coverage on the fileLock module.
|
|
115
|
-
|
|
116
|
-
## Impact
|
|
117
|
-
|
|
118
|
-
This fix enables kodrdriv to work correctly in monorepo setups where packages are organized as git submodules, such as:
|
|
119
|
-
|
|
120
|
-
- Multi-repository projects using git submodules for shared libraries
|
|
121
|
-
- Projects with external dependencies included as submodules
|
|
122
|
-
- Monorepos with complex submodule hierarchies
|
|
123
|
-
|
|
124
|
-
The fix maintains backward compatibility with regular git repositories while adding robust support for submodules.
|
|
125
|
-
|
|
126
|
-
## Related Files
|
|
127
|
-
|
|
128
|
-
- `src/util/fileLock.ts` - Core fix implementation
|
|
129
|
-
- `tests/fileLock.test.ts` - Comprehensive test suite
|
|
130
|
-
- `src/util/gitMutex.ts` - Uses RepositoryFileLockManager
|
|
131
|
-
- `src/commands/publish.ts` - Uses git locks during publish operations
|
|
132
|
-
|