@eldrforge/kodrdriv 1.2.26 → 1.2.28

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 (79) hide show
  1. package/AI-FRIENDLY-LOGGING-GUIDE.md +237 -0
  2. package/AI-LOGGING-MIGRATION-COMPLETE.md +371 -0
  3. package/ALREADY-PUBLISHED-PACKAGES-FIX.md +264 -0
  4. package/AUDIT-BRANCHES-PROGRESS-FIX.md +90 -0
  5. package/AUDIT-EXAMPLE-OUTPUT.md +113 -0
  6. package/CHECKPOINT-RECOVERY-FIX.md +450 -0
  7. package/LOGGING-MIGRATION-STATUS.md +186 -0
  8. package/PARALLEL-PUBLISH-FIXES-IMPLEMENTED.md +405 -0
  9. package/PARALLEL-PUBLISH-IMPROVEMENTS-IMPLEMENTED.md +439 -0
  10. package/PARALLEL-PUBLISH-QUICK-REFERENCE.md +375 -0
  11. package/PARALLEL_EXECUTION_FIX.md +2 -2
  12. package/PUBLISH_IMPROVEMENTS_IMPLEMENTED.md +294 -0
  13. package/VERSION-AUDIT-FIX.md +333 -0
  14. package/dist/application.js +6 -6
  15. package/dist/application.js.map +1 -1
  16. package/dist/arguments.js +43 -13
  17. package/dist/arguments.js.map +1 -1
  18. package/dist/commands/audio-commit.js +18 -18
  19. package/dist/commands/audio-commit.js.map +1 -1
  20. package/dist/commands/audio-review.js +32 -32
  21. package/dist/commands/audio-review.js.map +1 -1
  22. package/dist/commands/clean.js +9 -9
  23. package/dist/commands/clean.js.map +1 -1
  24. package/dist/commands/commit.js +20 -20
  25. package/dist/commands/commit.js.map +1 -1
  26. package/dist/commands/development.js +91 -90
  27. package/dist/commands/development.js.map +1 -1
  28. package/dist/commands/link.js +36 -36
  29. package/dist/commands/link.js.map +1 -1
  30. package/dist/commands/publish.js +345 -225
  31. package/dist/commands/publish.js.map +1 -1
  32. package/dist/commands/release.js +14 -14
  33. package/dist/commands/release.js.map +1 -1
  34. package/dist/commands/review.js +15 -17
  35. package/dist/commands/review.js.map +1 -1
  36. package/dist/commands/select-audio.js +5 -5
  37. package/dist/commands/select-audio.js.map +1 -1
  38. package/dist/commands/tree.js +75 -34
  39. package/dist/commands/tree.js.map +1 -1
  40. package/dist/commands/unlink.js +39 -39
  41. package/dist/commands/unlink.js.map +1 -1
  42. package/dist/commands/updates.js +150 -14
  43. package/dist/commands/updates.js.map +1 -1
  44. package/dist/commands/versions.js +14 -13
  45. package/dist/commands/versions.js.map +1 -1
  46. package/dist/constants.js +1 -1
  47. package/dist/content/diff.js +5 -5
  48. package/dist/content/diff.js.map +1 -1
  49. package/dist/content/files.js +2 -2
  50. package/dist/content/files.js.map +1 -1
  51. package/dist/content/log.js +3 -3
  52. package/dist/content/log.js.map +1 -1
  53. package/dist/execution/CommandValidator.js +6 -6
  54. package/dist/execution/CommandValidator.js.map +1 -1
  55. package/dist/execution/DynamicTaskPool.js +33 -10
  56. package/dist/execution/DynamicTaskPool.js.map +1 -1
  57. package/dist/execution/RecoveryManager.js +99 -21
  58. package/dist/execution/RecoveryManager.js.map +1 -1
  59. package/dist/execution/TreeExecutionAdapter.js +65 -48
  60. package/dist/execution/TreeExecutionAdapter.js.map +1 -1
  61. package/dist/main.js +2 -2
  62. package/dist/main.js.map +1 -1
  63. package/dist/util/checkpointManager.js +4 -4
  64. package/dist/util/checkpointManager.js.map +1 -1
  65. package/dist/util/dependencyGraph.js +2 -2
  66. package/dist/util/dependencyGraph.js.map +1 -1
  67. package/dist/util/fileLock.js +1 -1
  68. package/dist/util/fileLock.js.map +1 -1
  69. package/dist/util/general.js +148 -15
  70. package/dist/util/general.js.map +1 -1
  71. package/dist/util/interactive.js +2 -2
  72. package/dist/util/interactive.js.map +1 -1
  73. package/dist/util/performance.js.map +1 -1
  74. package/dist/util/safety.js +13 -13
  75. package/dist/util/safety.js.map +1 -1
  76. package/dist/utils/branchState.js +567 -0
  77. package/dist/utils/branchState.js.map +1 -0
  78. package/package.json +1 -1
  79. package/scripts/update-test-log-assertions.js +73 -0
@@ -0,0 +1,264 @@
1
+ # Already-Published Packages Fix
2
+
3
+ ## Summary
4
+
5
+ Fixed critical issues preventing kodrdriv from handling monorepos with already-published packages on npm. The tool now intelligently checks npm registry state, handles tag conflicts gracefully, and provides clear recovery options.
6
+
7
+ ## Issues Fixed
8
+
9
+ ### 1. ✅ No NPM Registry Version Checking
10
+
11
+ **Before**: Tool blindly attempted to publish everything without checking what's already on npm.
12
+
13
+ **After**:
14
+ - Added `getNpmPublishedVersion()` utility to query npm registry
15
+ - Added `isVersionPublishedOnNpm()` to check specific versions
16
+ - Added `getTagInfo()` to analyze git tags
17
+
18
+ ### 2. ✅ Hard Failure on Existing Tags
19
+
20
+ **Before**: Threw error immediately when tag exists: `"Tag vX.Y.Z already exists. Please choose a different version or delete the existing tag."`
21
+
22
+ **After**: Smart analysis with actionable recovery:
23
+ ```
24
+ ⚠️ Tag v4.4.72 already exists
25
+
26
+ 📊 Situation Analysis:
27
+ • Tag v4.4.72 exists (commit: 5b84859b)
28
+ • npm registry version: 4.4.70
29
+ • This suggests a previous publish attempt failed after creating the tag
30
+
31
+ 🔧 Recovery Options:
32
+ 1. Force republish (delete tag and retry):
33
+ kodrdriv publish --force-republish
34
+ 2. Skip this version and bump:
35
+ npm version patch && kodrdriv publish
36
+ 3. Manually delete tag:
37
+ git tag -d v4.4.72
38
+ git push origin :refs/tags/v4.4.72
39
+ ```
40
+
41
+ ### 3. ✅ Skip Already-Published Packages
42
+
43
+ **Before**: Tried to publish packages that are already at target version on npm.
44
+
45
+ **After**:
46
+ ```bash
47
+ kodrdriv publish --skip-already-published
48
+ ```
49
+
50
+ When version is already on npm:
51
+ ```
52
+ ✓ Version 4.4.72 is already published on npm
53
+ ⊘ Skipping publish - package is already at target version
54
+
55
+ 💡 If you need to republish:
56
+ 1. Bump version: npm version patch (or minor/major)
57
+ 2. Re-run: kodrdriv publish
58
+ ```
59
+
60
+ ### 4. ✅ Force Republish Flag
61
+
62
+ **Before**: No way to override and force past tag conflicts.
63
+
64
+ **After**:
65
+ ```bash
66
+ kodrdriv publish --force-republish
67
+ ```
68
+
69
+ Automatically:
70
+ - Deletes local tag
71
+ - Deletes remote tag
72
+ - Continues with publish
73
+
74
+ ## New Command-Line Flags
75
+
76
+ ### `--skip-already-published`
77
+ Skip packages where the working version matches the npm published version.
78
+
79
+ **Use Case**: Publishing multiple packages in a tree where some are already up-to-date.
80
+
81
+ ```bash
82
+ # Individual package
83
+ kodrdriv publish --skip-already-published
84
+
85
+ # Tree publish
86
+ kodrdriv tree publish --parallel --skip-already-published
87
+ ```
88
+
89
+ ### `--force-republish`
90
+ Delete existing git tags and force republish even if tag exists.
91
+
92
+ **Use Case**: Recovery from failed publish attempts that created tags but didn't complete npm publish.
93
+
94
+ ```bash
95
+ # Force past tag conflicts
96
+ kodrdriv publish --force-republish
97
+
98
+ # Can combine with other flags
99
+ kodrdriv tree publish --parallel --force-republish --model "gpt-5-mini"
100
+ ```
101
+
102
+ ## Implementation Details
103
+
104
+ ### New Utility Functions (`src/util/general.ts`)
105
+
106
+ ```typescript
107
+ // Query npm for published version
108
+ export const getNpmPublishedVersion = async (packageName: string): Promise<string | null>
109
+
110
+ // Check if specific version exists on npm
111
+ export const isVersionPublishedOnNpm = async (packageName: string, version: string): Promise<boolean>
112
+
113
+ // Get detailed tag information
114
+ export const getTagInfo = async (tagName: string): Promise<{ exists: boolean; commit?: string; version?: string } | null>
115
+ ```
116
+
117
+ ### Enhanced Tag Conflict Logic (`src/commands/publish.ts`)
118
+
119
+ The tag existence check now:
120
+ 1. Checks if tag exists locally
121
+ 2. Queries npm for package version
122
+ 3. Compares states to determine situation:
123
+ - **Tag exists + npm has it**: Skip (already published)
124
+ - **Tag exists + npm doesn't**: Offer recovery options
125
+ - **No conflicts**: Proceed normally
126
+
127
+ ### Type Updates
128
+
129
+ Added to `PublishConfig` type:
130
+ - `skipAlreadyPublished?: boolean`
131
+ - `forceRepublish?: boolean`
132
+
133
+ ## Real-World Usage
134
+
135
+ ### Scenario 1: Package Already Published
136
+
137
+ ```bash
138
+ cd ~/gitw/getfjell/common-config
139
+ kodrdriv publish --model "gpt-5-mini"
140
+
141
+ # Output:
142
+ ✓ Version 1.1.36 is already published on npm
143
+ ⊘ Skipping publish - package is already at target version
144
+ ```
145
+
146
+ ### Scenario 2: Failed Publish Left Orphaned Tag
147
+
148
+ ```bash
149
+ cd ~/gitw/getfjell/core
150
+ kodrdriv publish --model "gpt-5-mini"
151
+
152
+ # Output:
153
+ ⚠️ Tag v4.4.72 already exists
154
+ 📊 Situation Analysis:
155
+ • Tag v4.4.72 exists (commit: 5b84859b)
156
+ • npm registry version: 4.4.70
157
+ • This suggests a previous publish attempt failed after creating the tag
158
+
159
+ # Solution:
160
+ kodrdriv publish --force-republish --model "gpt-5-mini"
161
+
162
+ # Output:
163
+ 🔄 Force republish enabled - deleting existing tag...
164
+ ✓ Deleted local tag v4.4.72
165
+ ✓ Deleted remote tag v4.4.72
166
+ ✓ Tag deleted, continuing with publish...
167
+ ```
168
+
169
+ ### Scenario 3: Tree Publish with Mixed State
170
+
171
+ ```bash
172
+ cd ~/gitw/getfjell
173
+ kodrdriv tree publish --parallel --skip-already-published --model "gpt-5-mini"
174
+
175
+ # Now handles:
176
+ # - Skips packages already at target version
177
+ # - Publishes packages with changes
178
+ # - Handles tag conflicts gracefully
179
+ # - Proceeds with dependent packages after resolution
180
+ ```
181
+
182
+ ## Files Modified
183
+
184
+ ```
185
+ src/util/general.ts - Added npm registry query functions
186
+ src/commands/publish.ts - Enhanced tag conflict handling
187
+ src/arguments.ts - Added new CLI flags
188
+ src/types.ts - Added PublishConfig fields
189
+ ALREADY-PUBLISHED-PACKAGES-FIX.md - This documentation
190
+ ```
191
+
192
+ ## Backward Compatibility
193
+
194
+ ✅ **Fully backward compatible**
195
+
196
+ - No changes to default behavior
197
+ - New flags are optional
198
+ - Existing commands work exactly as before
199
+ - New features activated only with explicit flags
200
+
201
+ ## Remaining Work
202
+
203
+ ### --sync-target Fix (Partially Complete)
204
+
205
+ The `--sync-target` flag implementation exists but needs verification:
206
+ - Uses `safeSyncBranchWithRemote()` from git-tools
207
+ - May need enhancement to ensure target branch actually syncs
208
+ - Currently handles conflicts but sync result verification needed
209
+
210
+ ### Future Enhancements (Not Implemented)
211
+
212
+ These were requested but are lower priority:
213
+
214
+ 1. **Dry Run Mode**
215
+ ```bash
216
+ kodrdriv tree publish --dry-run
217
+ ```
218
+ Show what would be published without executing.
219
+
220
+ 2. **Incremental Publish**
221
+ ```bash
222
+ kodrdriv tree publish --since v1.0.0
223
+ ```
224
+ Only publish packages with changes since specific tag/commit.
225
+
226
+ 3. **Interactive Recovery**
227
+ When tag conflicts detected, prompt user for action instead of requiring flag.
228
+
229
+ ## Testing
230
+
231
+ Manual testing performed with Fjell monorepo (16 packages):
232
+ - ✅ Skip already-published packages
233
+ - ✅ Force republish past tag conflicts
234
+ - ✅ Proper npm registry version checking
235
+ - ✅ Clear error messages with recovery options
236
+
237
+ Automated tests needed for:
238
+ - npm version checking functions
239
+ - Tag conflict resolution logic
240
+ - Skip logic in tree publish context
241
+
242
+ ## Impact
243
+
244
+ ### Before These Fixes
245
+ - ❌ Unusable for monorepos with existing packages
246
+ - ❌ No recovery from failed publishes
247
+ - ❌ Manual intervention required for every conflict
248
+ - ❌ 80-160 minutes of manual work per 16-package monorepo
249
+
250
+ ### After These Fixes
251
+ - ✅ Works with any existing monorepo state
252
+ - ✅ Automatic recovery options
253
+ - ✅ Clear guidance for every scenario
254
+ - ✅ Fully automated with appropriate flags
255
+ - ✅ Estimated 5-10 minutes for full monorepo publish
256
+
257
+ ## Version
258
+
259
+ Implemented in: **kodrdriv 1.2.29-dev.0**
260
+
261
+ ---
262
+
263
+ **Note**: This fix works in conjunction with the checkpoint recovery fix to provide complete monorepo publish automation capabilities.
264
+
@@ -0,0 +1,90 @@
1
+ # Branch Audit Progress Feedback Improvements
2
+
3
+ ## Problem
4
+
5
+ The `kodrdriv tree publish --audit-branches` command takes a long time to run (several minutes for large monorepos) with no progress feedback, making it difficult to know if the command is actually running or stuck.
6
+
7
+ ## Root Cause
8
+
9
+ The `auditBranchState` function in `src/utils/branchState.ts` performs extensive checks on every package:
10
+ - Git operations (fetch, ls-remote, rev-list, merge-tree)
11
+ - GitHub API calls to check for existing PRs
12
+ - Version validation
13
+ - Target branch sync checks
14
+
15
+ For a monorepo with 50+ packages, these sequential operations can take 2-3 seconds per package (100-150 seconds total) with no feedback during execution.
16
+
17
+ ## Changes Made
18
+
19
+ ### 1. Phase-based Progress Reporting
20
+
21
+ Added two-phase execution with clear messaging:
22
+
23
+ ```
24
+ Phase 1/2: Detecting most common branch across packages...
25
+ [1/50] Checking branch: package-a
26
+ [2/50] Checking branch: package-b
27
+ ...
28
+ ✓ Most common branch: development (48/50 packages)
29
+
30
+ Phase 2/2: Auditing package state (checking git status, conflicts, PRs, versions)...
31
+ [1/50] Auditing: package-a
32
+ [2/50] Auditing: package-b
33
+ ...
34
+ ✓ Audit complete: 45/50 packages have no issues
35
+ Issues found in 5 package(s)
36
+ ```
37
+
38
+ ### 2. Per-Package Progress Counters
39
+
40
+ Each package now shows its position in the queue `[N/Total]` so users can track overall progress.
41
+
42
+ ### 3. Verbose Operation Logging
43
+
44
+ Added verbose logging for expensive operations within each package check:
45
+ - "Fetching latest from origin..."
46
+ - "Checking for merge conflicts..."
47
+ - "Checking GitHub for existing PRs..."
48
+ - "Found existing PR #123..."
49
+
50
+ These only appear when `--verbose` or `--debug` flags are used, providing more detailed feedback without cluttering default output.
51
+
52
+ ### 4. Completion Summary
53
+
54
+ Added clear completion message showing:
55
+ - Number of packages with no issues
56
+ - Number of packages with issues (if any)
57
+
58
+ ## Impact
59
+
60
+ Users can now:
61
+ 1. **See that the command is running** - immediate feedback with progress counters
62
+ 2. **Estimate completion time** - `[15/50]` indicates 30% complete
63
+ 3. **Identify slow operations** - verbose mode shows which operation is taking time
64
+ 4. **Know when it's done** - clear completion message
65
+
66
+ ## Files Modified
67
+
68
+ - `src/utils/branchState.ts` - Added progress logging to `auditBranchState` and `checkBranchStatus` functions
69
+
70
+ ## Testing
71
+
72
+ Compile check: ✅ Passed (`tsc --noEmit`)
73
+
74
+ Manual testing recommended:
75
+ ```bash
76
+ kodrdriv tree publish --audit-branches
77
+ kodrdriv tree publish --audit-branches --verbose
78
+ kodrdriv tree publish --audit-branches --debug
79
+ ```
80
+
81
+ ## Future Optimizations (Not Implemented)
82
+
83
+ Potential future improvements for faster execution:
84
+ 1. **Parallel package checks** - Process multiple packages simultaneously (requires careful handling of git operations)
85
+ 2. **Batch GitHub API calls** - Use GraphQL to query multiple PRs at once
86
+ 3. **Cache git fetch results** - Avoid fetching the same remote multiple times
87
+ 4. **Skip checks for packages with no changes** - Use git status to detect unchanged packages early
88
+
89
+ These optimizations would require more significant refactoring and testing.
90
+
@@ -0,0 +1,113 @@
1
+ # Example Output: Branch Audit with Progress Feedback
2
+
3
+ ## Before (No Feedback)
4
+
5
+ ```bash
6
+ $ kodrdriv tree publish --audit-branches
7
+ 🔍 Auditing branch state across all packages...
8
+ BRANCH_STATE_AUDIT: Auditing branch state for packages | Package Count: 50 | Purpose: Verify synchronization
9
+ Checking for merge conflicts with 'main' and existing pull requests...
10
+
11
+ [... 2-3 minutes of silence ...]
12
+
13
+ ✅ All 45 package(s) are in good state!
14
+ ```
15
+
16
+ **Problem:** Users don't know if the command is running or stuck.
17
+
18
+ ---
19
+
20
+ ## After (With Progress Feedback)
21
+
22
+ ### Default Output
23
+
24
+ ```bash
25
+ $ kodrdriv tree publish --audit-branches
26
+ 🔍 Auditing branch state across all packages...
27
+ BRANCH_STATE_AUDIT: Auditing branch state for packages | Package Count: 50 | Purpose: Verify synchronization
28
+ Checking for merge conflicts with 'main' and existing pull requests...
29
+
30
+ 📋 Phase 1/2: Detecting most common branch across packages...
31
+ [1/50] Checking branch: @myorg/core
32
+ [2/50] Checking branch: @myorg/utils
33
+ [3/50] Checking branch: @myorg/api
34
+ ...
35
+ [48/50] Checking branch: @myorg/tests
36
+ [49/50] Checking branch: @myorg/docs
37
+ [50/50] Checking branch: @myorg/cli
38
+ ✓ Most common branch: development (48/50 packages)
39
+
40
+ 📋 Phase 2/2: Auditing package state (checking git status, conflicts, PRs, versions)...
41
+ [1/50] Auditing: @myorg/core
42
+ [2/50] Auditing: @myorg/utils
43
+ [3/50] Auditing: @myorg/api
44
+ ...
45
+ [48/50] Auditing: @myorg/tests
46
+ [49/50] Auditing: @myorg/docs
47
+ [50/50] Auditing: @myorg/cli
48
+ ✓ Audit complete: 45/50 packages have no issues
49
+ Issues found in 5 package(s)
50
+
51
+ [... detailed issue report ...]
52
+
53
+ ⚠️ Found issues in 5 package(s). Review the fixes above.
54
+ ```
55
+
56
+ ### Verbose Output (`--verbose`)
57
+
58
+ ```bash
59
+ $ kodrdriv tree publish --audit-branches --verbose
60
+ 🔍 Auditing branch state across all packages...
61
+ BRANCH_STATE_AUDIT: Auditing branch state for packages | Package Count: 50 | Purpose: Verify synchronization
62
+ Checking for merge conflicts with 'main' and existing pull requests...
63
+
64
+ 📋 Phase 1/2: Detecting most common branch across packages...
65
+ [1/50] Checking branch: @myorg/core
66
+ [2/50] Checking branch: @myorg/utils
67
+ ...
68
+ ✓ Most common branch: development (48/50 packages)
69
+
70
+ 📋 Phase 2/2: Auditing package state (checking git status, conflicts, PRs, versions)...
71
+ [1/50] Auditing: @myorg/core
72
+ Fetching latest from origin for /path/to/core...
73
+ Checking for merge conflicts with main...
74
+ Checking GitHub for existing PRs...
75
+ [2/50] Auditing: @myorg/utils
76
+ Fetching latest from origin for /path/to/utils...
77
+ Checking for merge conflicts with main...
78
+ Checking GitHub for existing PRs...
79
+ Found existing PR #123: https://github.com/myorg/utils/pull/123
80
+ [3/50] Auditing: @myorg/api
81
+ Fetching latest from origin for /path/to/api...
82
+ Checking for merge conflicts with main...
83
+ ⚠️ Merge conflicts detected with main
84
+ Checking GitHub for existing PRs...
85
+ ...
86
+ ✓ Audit complete: 45/50 packages have no issues
87
+ Issues found in 5 package(s)
88
+ ```
89
+
90
+ ## Benefits
91
+
92
+ 1. **Immediate Feedback:** Users see progress start immediately
93
+ 2. **Progress Tracking:** `[N/Total]` shows exactly where you are
94
+ 3. **Time Estimation:** If `[10/50]` takes 30 seconds, expect ~2.5 minutes total
95
+ 4. **Debug Support:** Verbose mode shows which operations are slow
96
+ 5. **Clear Completion:** Final summary shows results at a glance
97
+
98
+ ## Testing the Changes
99
+
100
+ ```bash
101
+ # Test in a monorepo with multiple packages
102
+ cd /path/to/your/monorepo
103
+
104
+ # Default output (progress with package names)
105
+ kodrdriv tree publish --audit-branches
106
+
107
+ # Verbose output (shows git operations)
108
+ kodrdriv tree publish --audit-branches --verbose
109
+
110
+ # Debug output (most detailed)
111
+ kodrdriv tree publish --audit-branches --debug
112
+ ```
113
+