@eldrforge/kodrdriv 1.2.21 → 1.2.22

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 (67) hide show
  1. package/WORKFLOW-PRECHECK-IMPLEMENTATION.md +239 -0
  2. package/WORKFLOW-SKIP-SUMMARY.md +121 -0
  3. package/dist/arguments.js +2 -2
  4. package/dist/arguments.js.map +1 -1
  5. package/dist/commands/audio-commit.js +15 -6
  6. package/dist/commands/audio-commit.js.map +1 -1
  7. package/dist/commands/audio-review.js +31 -15
  8. package/dist/commands/audio-review.js.map +1 -1
  9. package/dist/commands/commit.js +30 -19
  10. package/dist/commands/commit.js.map +1 -1
  11. package/dist/commands/link.js +27 -27
  12. package/dist/commands/link.js.map +1 -1
  13. package/dist/commands/publish.js +74 -21
  14. package/dist/commands/publish.js.map +1 -1
  15. package/dist/commands/release.js +30 -17
  16. package/dist/commands/release.js.map +1 -1
  17. package/dist/commands/review.js +33 -26
  18. package/dist/commands/review.js.map +1 -1
  19. package/dist/commands/select-audio.js +4 -4
  20. package/dist/commands/select-audio.js.map +1 -1
  21. package/dist/commands/tree.js +122 -35
  22. package/dist/commands/tree.js.map +1 -1
  23. package/dist/commands/unlink.js +13 -13
  24. package/dist/commands/unlink.js.map +1 -1
  25. package/dist/commands/updates.js +21 -0
  26. package/dist/commands/updates.js.map +1 -1
  27. package/dist/commands/versions.js +5 -5
  28. package/dist/commands/versions.js.map +1 -1
  29. package/dist/constants.js +4 -4
  30. package/dist/constants.js.map +1 -1
  31. package/dist/content/files.js +4 -4
  32. package/dist/content/files.js.map +1 -1
  33. package/dist/logging.js +3 -3
  34. package/dist/logging.js.map +1 -1
  35. package/dist/util/aiAdapter.js +28 -0
  36. package/dist/util/aiAdapter.js.map +1 -0
  37. package/dist/util/general.js +5 -5
  38. package/dist/util/general.js.map +1 -1
  39. package/dist/util/interactive.js +6 -437
  40. package/dist/util/interactive.js.map +1 -1
  41. package/dist/util/loggerAdapter.js +24 -0
  42. package/dist/util/loggerAdapter.js.map +1 -0
  43. package/dist/util/performance.js +4 -4
  44. package/dist/util/performance.js.map +1 -1
  45. package/dist/util/safety.js +4 -4
  46. package/dist/util/safety.js.map +1 -1
  47. package/dist/util/storage.js +2 -2
  48. package/dist/util/storage.js.map +1 -1
  49. package/dist/util/storageAdapter.js +25 -0
  50. package/dist/util/storageAdapter.js.map +1 -0
  51. package/package.json +5 -4
  52. package/GITHUB-TOOLS-INTEGRATION.md +0 -323
  53. package/INTEGRATION-SUMMARY.md +0 -232
  54. package/TEST-STATUS.md +0 -168
  55. package/dist/prompt/commit.js +0 -76
  56. package/dist/prompt/commit.js.map +0 -1
  57. package/dist/prompt/instructions/commit.md +0 -133
  58. package/dist/prompt/instructions/release.md +0 -188
  59. package/dist/prompt/instructions/review.md +0 -169
  60. package/dist/prompt/personas/releaser.md +0 -24
  61. package/dist/prompt/personas/you.md +0 -55
  62. package/dist/prompt/release.js +0 -100
  63. package/dist/prompt/release.js.map +0 -1
  64. package/dist/prompt/review.js +0 -64
  65. package/dist/prompt/review.js.map +0 -1
  66. package/dist/util/openai.js +0 -365
  67. package/dist/util/openai.js.map +0 -1
@@ -0,0 +1,239 @@
1
+ # Workflow Precheck Implementation
2
+
3
+ ## Problem Statement
4
+
5
+ The `kodrdriv publish` command was freezing when running in the getfjell/http-api repository during the `publish-tree` operation.
6
+
7
+ ### Root Cause
8
+
9
+ The workflow file at `~/gitw/getfjell/http-api/.github/workflows/test.yml` is configured with:
10
+
11
+ ```yaml
12
+ on:
13
+ push:
14
+ branches:
15
+ - main
16
+ - working
17
+ - 'feature/**'
18
+ ```
19
+
20
+ **The problem:** This workflow triggers on `push` events but **NOT on `pull_request` events**.
21
+
22
+ When `kodrdriv publish`:
23
+ 1. Creates a new branch and pushes commits ✅
24
+ 2. Creates a pull request ✅
25
+ 3. Waits for PR checks to complete using `waitForPullRequestChecks()` ❌
26
+
27
+ The `waitForPullRequestChecks()` function queries the GitHub API for check runs associated with the PR. Because the workflow only triggers on `push` (not `pull_request`), GitHub doesn't associate those workflow runs with the PR, so the API returns no checks.
28
+
29
+ The function was designed to detect this after 1 minute (6 consecutive checks with no results), but in your case it was likely stuck in a detection loop or the command was running with `skipUserConfirmation: true` which caused it to wait for the full 1-hour timeout.
30
+
31
+ ## Solution
32
+
33
+ I've implemented **two complementary improvements** to prevent this issue:
34
+
35
+ ### 1. Workflow Validation Precheck (runs before PR creation)
36
+ ### 2. Smart Wait Skipping (skips waiting if no PR workflows detected)
37
+
38
+ ### Changes Made
39
+
40
+ #### 1. Workflow Validation Precheck
41
+
42
+ **New function** `checkWorkflowConfiguration()` in `@eldrforge/github-tools` that:
43
+ - Lists all workflows in the repository
44
+ - Analyzes each workflow file's YAML content
45
+ - Determines if workflows will be triggered by PRs to the target branch
46
+ - Returns detailed information about workflow configuration
47
+
48
+ **Location:** `~/gitw/calenvarek/github-tools/src/github.ts`
49
+
50
+ **Example output:**
51
+ ```typescript
52
+ {
53
+ hasWorkflows: true,
54
+ workflowCount: 4,
55
+ hasPullRequestTriggers: false, // ⚠️ This is the warning
56
+ triggeredWorkflowNames: [],
57
+ warning: "4 workflow(s) are configured, but none appear to trigger on pull requests to main"
58
+ }
59
+ ```
60
+
61
+ #### 2. Smart Wait Skipping
62
+
63
+ **After** the PR is created, the publish command now checks the workflow configuration again and **skips waiting entirely** if no workflows will trigger on the PR.
64
+
65
+ **Location:** `~/gitw/calenvarek/kodrdriv/src/commands/publish.ts` (lines 833-850)
66
+
67
+ **Output when skipping:**
68
+ ```
69
+ Waiting for PR #75 checks to complete...
70
+ ⏭️ Skipping check wait - no workflows configured to trigger on this PR
71
+ ```
72
+
73
+ This prevents the command from freezing when workflows exist but don't trigger on PRs.
74
+
75
+ #### 3. Improved Detection in `waitForPullRequestChecks`
76
+
77
+ Made the wait function smarter and faster:
78
+ - **Reduced wait time**: Now checks after 30 seconds instead of 1 minute
79
+ - **Better detection**: Distinguishes between "no workflow runs" vs "workflow runs exist on branch but aren't PR checks"
80
+ - **Explicit handling**: When workflows trigger on `push` but not `pull_request`, it detects this and proceeds without waiting
81
+
82
+ **Location:** `~/gitw/calenvarek/github-tools/src/github.ts`
83
+
84
+ **Key improvements:**
85
+ ```typescript
86
+ // Changed from 6 checks (1 minute) to 3 checks (30 seconds)
87
+ const maxConsecutiveNoChecks = 3;
88
+
89
+ // New logic to detect workflows that trigger on push but not pull_request
90
+ logger.info(`Found workflow runs on the branch, but none appear as PR checks.`);
91
+ logger.info(`This usually means workflows trigger on 'push' but not 'pull_request'.`);
92
+ // ... proceeds without waiting in non-interactive mode
93
+ ```
94
+
95
+ #### 4. Precheck Warning
96
+
97
+ Modified the `runPrechecks()` function to call `checkWorkflowConfiguration()` and warn users before creating the PR.
98
+
99
+ **Location:** `~/gitw/calenvarek/kodrdriv/src/commands/publish.ts` (lines 244-267)
100
+
101
+ **Output when workflows are missing:**
102
+ ```
103
+ Checking GitHub Actions workflow configuration...
104
+ ⚠️ Found 4 workflow(s), but none are triggered by PRs to main.
105
+ The publish process will create a PR but will not wait for any checks to complete.
106
+ Consider updating workflow triggers to include: on.pull_request.branches: [main]
107
+ ```
108
+
109
+ #### 5. Tests
110
+
111
+ Created comprehensive test suite with 8 test cases covering:
112
+ - No workflows configured
113
+ - Workflows with `pull_request` triggers
114
+ - Workflows without `pull_request` triggers
115
+ - Branch-specific triggers
116
+ - Wildcard patterns
117
+ - Multiple workflows with mixed configurations
118
+ - API error handling
119
+
120
+ **Location:** `~/gitw/calenvarek/github-tools/tests/checkWorkflowConfiguration.test.ts`
121
+
122
+ **Result:** All 8 tests passing ✅
123
+
124
+ ## How to Fix the http-api Workflow
125
+
126
+ Update `~/gitw/getfjell/http-api/.github/workflows/test.yml`:
127
+
128
+ ```yaml
129
+ name: Run Tests
130
+
131
+ on:
132
+ push:
133
+ branches:
134
+ - main
135
+ - working
136
+ - 'feature/**'
137
+ pull_request: # ← ADD THIS
138
+ branches:
139
+ - main
140
+
141
+ permissions:
142
+ contents: read
143
+ statuses: write
144
+
145
+ jobs:
146
+ test:
147
+ runs-on: ubuntu-latest
148
+ steps:
149
+ - uses: actions/checkout@v4
150
+ - uses: actions/setup-node@v4
151
+ with:
152
+ node-version: 22
153
+
154
+ - run: npm ci
155
+ - run: npm run lint
156
+ - run: npm run build
157
+ - run: npm test
158
+
159
+ - uses: codecov/codecov-action@v5
160
+ with:
161
+ slug: getfjell/http-api
162
+ token: ${{ secrets.CODECOV_TOKEN }}
163
+ ```
164
+
165
+ **What this does:**
166
+ - Triggers the workflow when PRs are opened/updated targeting `main` branch
167
+ - GitHub will now associate the check runs with the PR
168
+ - `kodrdriv publish` will detect the checks and wait for them to complete
169
+ - The PR merge will only proceed after checks pass ✅
170
+
171
+ ## Testing the Fix
172
+
173
+ After updating the workflow file and rebuilding:
174
+
175
+ 1. **Test the precheck:**
176
+ ```bash
177
+ cd ~/gitw/getfjell/http-api
178
+ kodrdriv publish --dry-run
179
+ ```
180
+
181
+ Before fix: Would warn about missing PR triggers
182
+ After fix: Should show workflow will run on PRs ✅
183
+
184
+ 2. **Test actual publish:**
185
+ ```bash
186
+ kodrdriv publish
187
+ ```
188
+
189
+ Should now:
190
+ - Create PR
191
+ - Detect workflow runs
192
+ - Wait for checks to complete
193
+ - Merge when checks pass
194
+
195
+ ## Related Files Modified
196
+
197
+ ### github-tools package:
198
+ - `~/gitw/calenvarek/github-tools/src/github.ts` - Added `checkWorkflowConfiguration()` and `isTriggeredByPullRequest()`
199
+ - `~/gitw/calenvarek/github-tools/src/index.ts` - Exported new function
200
+ - `~/gitw/calenvarek/github-tools/tests/checkWorkflowConfiguration.test.ts` - New test file
201
+
202
+ ### kodrdriv package:
203
+ - `~/gitw/calenvarek/kodrdriv/src/commands/publish.ts` - Added workflow validation to prechecks
204
+
205
+ Both packages have been built and all tests pass.
206
+
207
+ ## Future Improvements
208
+
209
+ Consider adding:
210
+ 1. Configuration option to skip workflow validation if desired
211
+ 2. Ability to specify minimum required workflows
212
+ 3. Integration with workflow file templates for new projects
213
+
214
+ ## Summary
215
+
216
+ **What was frozen:** The `kodrdriv publish` command waiting for PR checks that never appeared
217
+
218
+ **Why it happened:** The workflow triggers on `push` but not `pull_request`, so GitHub doesn't associate runs with the PR
219
+
220
+ **How we fixed it:**
221
+ 1. ✅ **Precheck Warning**: Validates workflow configuration before creating the PR and warns about missing triggers
222
+ 2. ✅ **Smart Wait Skipping**: Automatically skips waiting if no workflows will trigger on the PR (no more freezing!)
223
+ 3. ✅ **Improved Detection**: Detects within 30 seconds when workflows exist on branch but aren't PR checks
224
+
225
+ **How to fix your workflow:** Add `pull_request` trigger to your workflow files (see above)
226
+
227
+ **Current state:**
228
+ - ✅ Precheck implemented and warns users
229
+ - ✅ Smart skip logic prevents freezing
230
+ - ✅ Faster detection (30s instead of 1 minute)
231
+ - ✅ Better error messages
232
+ - ✅ All tests passing (8/8)
233
+ - ✅ Both packages built
234
+ - ⚠️ http-api workflow needs updating for best experience (see above)
235
+
236
+ **Behavior now:**
237
+ - **Before fix**: Command would freeze for up to 1 hour waiting for checks
238
+ - **After fix**: Command detects the issue within 30 seconds and proceeds automatically in non-interactive mode, or prompts user in interactive mode
239
+
@@ -0,0 +1,121 @@
1
+ # Smart Workflow Wait Skipping - Implementation Summary
2
+
3
+ ## The Problem You Asked About
4
+
5
+ > "If there is no action fired from a pull request workflow, can we just not wait for it to complete?"
6
+
7
+ **Answer: YES! ✅ Now implemented.**
8
+
9
+ ## What I've Added
10
+
11
+ ### 1. Pre-check Before Creating PR
12
+ The publish command now checks workflow configuration **before** creating the PR and warns you:
13
+
14
+ ```
15
+ Checking GitHub Actions workflow configuration...
16
+ ⚠️ Found 4 workflow(s), but none are triggered by PRs to main.
17
+ The publish process will create a PR but will not wait for any checks to complete.
18
+ ```
19
+
20
+ ### 2. **Smart Skip After Creating PR** ⭐ (This is what you asked for!)
21
+ After the PR is created, the command checks workflow configuration again and **skips waiting entirely**:
22
+
23
+ ```
24
+ Waiting for PR #75 checks to complete...
25
+ ⏭️ Skipping check wait - no workflows configured to trigger on this PR
26
+ ```
27
+
28
+ **No more freezing!** The command proceeds immediately instead of waiting.
29
+
30
+ ### 3. Faster Detection When Checks Won't Appear
31
+ If we can't determine workflow configuration in advance, the wait logic now:
32
+ - Detects the issue in **30 seconds** instead of 1 minute
33
+ - Distinguishes between "no workflows" vs "workflows exist but don't trigger on PRs"
34
+ - Automatically proceeds in non-interactive mode (like in `publish-tree`)
35
+
36
+ ## How It Works
37
+
38
+ ```typescript
39
+ // In publish.ts - after PR is created
40
+ const workflowConfig = await GitHub.checkWorkflowConfiguration(targetBranch);
41
+ if (!workflowConfig.hasWorkflows || !workflowConfig.hasPullRequestTriggers) {
42
+ logger.info('⏭️ Skipping check wait - no workflows configured to trigger on this PR');
43
+ shouldSkipWait = true;
44
+ }
45
+ ```
46
+
47
+ The command:
48
+ 1. Checks if workflows are configured
49
+ 2. Checks if any workflows will trigger on this PR
50
+ 3. If NO → skips waiting entirely
51
+ 4. If YES → waits for checks as normal
52
+
53
+ ## Timeline Comparison
54
+
55
+ ### Before These Changes:
56
+ ```
57
+ Create PR ✓
58
+ Wait for checks...
59
+ [10s] No checks found
60
+ [20s] No checks found
61
+ [30s] No checks found
62
+ [40s] No checks found
63
+ [50s] No checks found
64
+ [60s] No checks found - checking workflows...
65
+ [70s] Workflows exist, checking if triggered for PR...
66
+ [80s] Found runs on branch...
67
+ ... continues waiting or hangs ...
68
+ ```
69
+
70
+ ### After These Changes:
71
+ ```
72
+ Precheck: Workflows exist but don't trigger on PRs ⚠️
73
+ Create PR ✓
74
+ Check workflow config again...
75
+ ⏭️ Skipping check wait - no workflows configured to trigger on this PR
76
+ Merge PR ✓
77
+ ```
78
+
79
+ **Time saved per publish:** Up to 60 minutes (if you were hitting the timeout!)
80
+
81
+ ## What Gets Detected
82
+
83
+ The smart skip detects:
84
+ - ❌ No workflows configured at all
85
+ - ❌ Workflows configured but none trigger on `pull_request` events
86
+ - ❌ Workflows trigger on PRs but not to your target branch (e.g., only to `develop`)
87
+ - ✅ Workflows will run on this PR → waits normally
88
+
89
+ ## For Your http-api Repository
90
+
91
+ The command will now:
92
+ 1. **Warn during precheck**: "4 workflow(s) configured, but none trigger on PRs to main"
93
+ 2. **Skip waiting**: Proceeds immediately after creating the PR
94
+ 3. **No freezing**: Command completes successfully
95
+
96
+ To get actual CI checks on your PRs (recommended), add to `test.yml`:
97
+ ```yaml
98
+ on:
99
+ push:
100
+ branches: [main, working, 'feature/**']
101
+ pull_request: # ← Add this
102
+ branches: [main]
103
+ ```
104
+
105
+ ## Testing
106
+
107
+ Run your `publish-tree` command again - it should now:
108
+ - Complete much faster (no 1-hour wait!)
109
+ - Show skip messages for repos without PR workflows
110
+ - Wait normally for repos with PR workflows
111
+ - Never freeze
112
+
113
+ ## Files Modified
114
+
115
+ - `github-tools/src/github.ts` - Added `checkWorkflowConfiguration()`, improved `waitForPullRequestChecks()`
116
+ - `github-tools/src/index.ts` - Exported new function
117
+ - `kodrdriv/src/commands/publish.ts` - Added precheck + smart skip logic
118
+ - `github-tools/tests/checkWorkflowConfiguration.test.ts` - 8 comprehensive tests (all passing)
119
+
120
+ Both packages rebuilt and ready to use! ✅
121
+
package/dist/arguments.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Command } from 'commander';
2
- import path__default from 'path';
2
+ import path from 'path';
3
3
  import { z } from 'zod';
4
4
  import { PROGRAM_NAME, VERSION, KODRDRIV_DEFAULTS, ALLOWED_COMMANDS, DEFAULT_COMMAND } from './constants.js';
5
5
  import { getLogger } from './logging.js';
@@ -364,7 +364,7 @@ const configure = async (cardigantime)=>{
364
364
  const transformedCliArgs = transformCliArgs(cliArgs);
365
365
  // Use CardiganTime's built-in generateConfig method
366
366
  const configDir = transformedCliArgs.configDirectory || KODRDRIV_DEFAULTS.configDirectory;
367
- const absoluteConfigDir = path__default.isAbsolute(configDir) ? configDir : path__default.resolve(process.cwd(), configDir);
367
+ const absoluteConfigDir = path.isAbsolute(configDir) ? configDir : path.resolve(process.cwd(), configDir);
368
368
  await cardigantime.generateConfig(absoluteConfigDir);
369
369
  // Return minimal config for consistency, but main processing is done
370
370
  const config = await validateAndProcessOptions({});