@grunnverk/kodrdriv 1.3.0

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 (84) hide show
  1. package/.claude/settings.local.json +12 -0
  2. package/.cursor/rules/no-local-dependencies.md +6 -0
  3. package/.gitignore~ +23 -0
  4. package/.kodrdriv-example-branch-targeting.yaml +71 -0
  5. package/BUG_TREE_PUBLISH_CONFIG_DIR.md +79 -0
  6. package/LICENSE +190 -0
  7. package/README.md +218 -0
  8. package/dist/application.js +228 -0
  9. package/dist/application.js.map +1 -0
  10. package/dist/arguments.js +1307 -0
  11. package/dist/arguments.js.map +1 -0
  12. package/dist/constants.js +255 -0
  13. package/dist/constants.js.map +1 -0
  14. package/dist/logging.js +176 -0
  15. package/dist/logging.js.map +1 -0
  16. package/dist/main.js +24 -0
  17. package/dist/main.js.map +1 -0
  18. package/dist/mcp/prompts/check_development.md +169 -0
  19. package/dist/mcp/prompts/dependency_update.md +62 -0
  20. package/dist/mcp/prompts/fix_and_commit.md +53 -0
  21. package/dist/mcp/prompts/publish.md +100 -0
  22. package/dist/mcp/prompts/tree_fix_and_commit.md +102 -0
  23. package/dist/mcp/prompts/tree_publish.md +118 -0
  24. package/dist/mcp-server.js +15601 -0
  25. package/dist/mcp-server.js.map +7 -0
  26. package/dist/types.js +303 -0
  27. package/dist/types.js.map +1 -0
  28. package/guide/ai-system.md +522 -0
  29. package/guide/architecture.md +349 -0
  30. package/guide/commands.md +383 -0
  31. package/guide/configuration.md +516 -0
  32. package/guide/debugging.md +587 -0
  33. package/guide/development.md +632 -0
  34. package/guide/index.md +224 -0
  35. package/guide/integration.md +510 -0
  36. package/guide/monorepo.md +533 -0
  37. package/guide/quickstart.md +249 -0
  38. package/guide/testing.md +463 -0
  39. package/guide/tree-operations.md +621 -0
  40. package/guide/usage.md +578 -0
  41. package/input/250509-kodrdriv-library-rules.m4a +0 -0
  42. package/package.json +105 -0
  43. package/packages/components/package.json +7 -0
  44. package/packages/tools/package.json +7 -0
  45. package/packages/utils/package.json +7 -0
  46. package/processed/250705-kodrdriv-confirm-editor-for-commit-and-release.m4a +0 -0
  47. package/processed/250705-kodrdriv-confirm-flag-release.m4a +0 -0
  48. package/processed/250705-kodrdriv-context-for-review.m4a +0 -0
  49. package/processed/250705-kodrdriv-feedback-on-publish-pipeline.m4a +0 -0
  50. package/processed/250705-kodrdriv-intelligent-eslint-style.m4a +0 -0
  51. package/processed/250705-kodrdriv-make-review-less-strict.m4a +0 -0
  52. package/processed/250705-kodrdriv-multilevel-transcription.m4a +0 -0
  53. package/processed/250705-kodrdriv-opinionated-review.m4a +0 -0
  54. package/processed/250705-kodrdriv-publish-next-version.m4a +0 -0
  55. package/processed/250705-kodrdriv-release-branches-and-milestones.m4a +0 -0
  56. package/processed/250705-kodrdriv-scope-check-fix-or-ignore.m4a +0 -0
  57. package/processed/250705-kodrdriv-scope-checker.m4a +0 -0
  58. package/processed/250705-kodrdriv-specify-a-release-note-for-publish.m4a +0 -0
  59. package/scripts/build-mcp.js +111 -0
  60. package/scripts/pre-commit-hook.sh +52 -0
  61. package/scripts/test-get-version-tool.js +102 -0
  62. package/scripts/test-mcp-compliance.js +254 -0
  63. package/scripts/update-test-log-assertions.js +73 -0
  64. package/temp-dist/arguments.js +817 -0
  65. package/temp-dist/constants.js +202 -0
  66. package/temp-dist/logging.js +130 -0
  67. package/temp-dist/types.js +112 -0
  68. package/temp-dist/util/stdin.js +132 -0
  69. package/temp-dist/util/storage.js +149 -0
  70. package/temp-dist/util/validation.js +110 -0
  71. package/test-external-unlink/package.json +16 -0
  72. package/test-externals/package.json +8 -0
  73. package/test-increment.js +0 -0
  74. package/test-multiline/cli/package.json +8 -0
  75. package/test-multiline/core/package.json +5 -0
  76. package/test-multiline/mobile/package.json +8 -0
  77. package/test-multiline/web/package.json +8 -0
  78. package/test-project/package-lock.json +21 -0
  79. package/test-project/package.json +1 -0
  80. package/test-review-flow.sh +15 -0
  81. package/test-sort-files/alpha.md +3 -0
  82. package/test-sort-files/middle.txt +3 -0
  83. package/test-sort-files/zebra.txt +3 -0
  84. package/test_output.txt +161 -0
@@ -0,0 +1,169 @@
1
+ # Check Development Readiness
2
+
3
+ ## Objective
4
+
5
+ Verify that projects are ready for development work. This prompt provides a comprehensive check to ensure:
6
+ 1. No projects are on the main branch
7
+ 2. All repositories have pulled the latest changes from remote
8
+ 3. Packages are on dev tag versions locally
9
+ 4. Local packages are linked via `kodrdriv link` or `kodrdriv tree link`
10
+
11
+ This is a quick verification step before starting development work to ensure you're working with the latest code and proper local dependencies.
12
+
13
+ ## Determining Tree vs Single-Package Operation
14
+
15
+ **Important**: Before proceeding, determine if this is a tree operation or a single-package operation:
16
+
17
+ - **Tree Operation**: If the directory (${directory}) contains subdirectories with `package.json` files, this is a monorepo/tree operation. Check all packages in the tree.
18
+ - **Single-Package Operation**: If the directory is a leaf project (single package without subdirectories containing `package.json`), check only this single package.
19
+
20
+ ## Workflow Steps
21
+
22
+ ### For Tree Operations (Monorepo)
23
+
24
+ 1. **Check Branch Status**
25
+ - For each package in the tree, check the current git branch
26
+ - Use `git branch --show-current` or `getGitStatusSummary()` from `@grunnverk/git-tools` to get the current branch
27
+ - **Fail if any package is on `main` or `master` branch** - these should be on `working` or a feature branch
28
+ - Report which packages are on the wrong branch
29
+
30
+ 2. **Check Remote Sync Status**
31
+ - For each package, check if the local branch is up to date with remote
32
+ - Use `git fetch` first to update remote refs
33
+ - Compare local branch with `origin/{branch}` using `git rev-parse` or `git status`
34
+ - **Fail if any package is behind remote** - run `kodrdriv_tree_pull` to sync
35
+ - Report which packages need to pull changes
36
+
37
+ 3. **Check Dev Version Status**
38
+ - For each package, read `package.json` and check the version field
39
+ - Verify that versions contain a dev tag (e.g., `1.2.3-dev.0`, `0.5.1-dev.2`)
40
+ - Use `isDevelopmentVersion()` from `@grunnverk/core` if available, or check for patterns like `-dev.`, `-alpha`, `-beta`, `-rc`
41
+ - **Fail if any package has a non-dev version** (e.g., `1.2.3` without `-dev.0`) - this suggests the package needs `kodrdriv development` run
42
+ - Report which packages have incorrect version formats
43
+
44
+ 4. **Check Link Status**
45
+ - For each package, check if local dependencies are properly linked
46
+ - Use `getGloballyLinkedPackages()` and `getLinkedDependencies()` from `@grunnverk/git-tools` to check link status
47
+ - Alternatively, check `node_modules` for symlinks pointing to local packages
48
+ - Check `package.json` dependencies - if they reference scoped packages (e.g., `@grunnverk/*`), verify they're linked, not using registry versions
49
+ - **Fail if local dependencies are not linked** - run `kodrdriv_tree_link` to set up local links
50
+ - Report which packages need linking
51
+
52
+ 5. **Summary Report**
53
+ - Provide a clear summary of all checks
54
+ - List any failures with specific packages and what needs to be fixed
55
+ - If all checks pass, confirm that the project is ready for development
56
+
57
+ ### For Single-Package Operations (Leaf Project)
58
+
59
+ 1. **Check Branch Status**
60
+ - Check the current git branch using `git branch --show-current` or `getGitStatusSummary()`
61
+ - **Fail if on `main` or `master` branch** - should be on `working` or a feature branch
62
+ - Report the current branch
63
+
64
+ 2. **Check Remote Sync Status**
65
+ - Run `git fetch` to update remote refs
66
+ - Compare local branch with `origin/{branch}` using `git rev-parse` or `git status`
67
+ - **Fail if behind remote** - run `kodrdriv_pull` to sync
68
+ - Report sync status
69
+
70
+ 3. **Check Dev Version Status**
71
+ - Read `package.json` and check the version field
72
+ - Verify that version contains a dev tag (e.g., `1.2.3-dev.0`)
73
+ - **Fail if version is not a dev version** - run `kodrdriv development` to update
74
+ - Report the current version
75
+
76
+ 4. **Check Link Status**
77
+ - Check if local dependencies are properly linked
78
+ - Use `getLinkedDependencies()` from `@grunnverk/git-tools` to check link status
79
+ - Check `node_modules` for symlinks pointing to local packages
80
+ - Check `package.json` dependencies - if they reference scoped packages, verify they're linked
81
+ - **Fail if local dependencies are not linked** - run `kodrdriv link` to set up local links
82
+ - Report link status
83
+
84
+ 5. **Summary Report**
85
+ - Provide a clear summary of all checks
86
+ - List any failures and what needs to be fixed
87
+ - If all checks pass, confirm that the project is ready for development
88
+
89
+ ## Common Issues and Fixes
90
+
91
+ ### Issue: Package on main branch
92
+ **Fix**: Switch to working branch or create a feature branch
93
+ ```bash
94
+ git checkout working
95
+ # or
96
+ git checkout -b feature/my-feature
97
+ ```
98
+
99
+ ### Issue: Behind remote
100
+ **Fix**: Pull latest changes
101
+ ```bash
102
+ # For tree operations
103
+ kodrdriv tree pull
104
+
105
+ # For single package
106
+ kodrdriv pull
107
+ ```
108
+
109
+ ### Issue: Not on dev version
110
+ **Fix**: Run development command to bump to dev version
111
+ ```bash
112
+ # For tree operations (if supported)
113
+ kodrdriv development
114
+
115
+ # For single package
116
+ kodrdriv development
117
+ ```
118
+
119
+ ### Issue: Local dependencies not linked
120
+ **Fix**: Run link command
121
+ ```bash
122
+ # For tree operations
123
+ kodrdriv tree link
124
+
125
+ # For single package
126
+ kodrdriv link
127
+ ```
128
+
129
+ ## Expected End State
130
+
131
+ After all checks pass, you should have:
132
+ - All packages on `working` or feature branches (not `main`)
133
+ - All repositories synced with remote
134
+ - All packages with dev versions (e.g., `1.2.3-dev.0`)
135
+ - All local dependencies properly linked via `kodrdriv link`
136
+
137
+ ## Important Notes
138
+
139
+ - **Branch Check**: The main branch check is critical - you should never develop directly on `main`
140
+ - **Remote Sync**: Always ensure you have the latest changes before starting work
141
+ - **Dev Versions**: Working branches should always have dev versions to distinguish from release versions
142
+ - **Link Status**: Local development requires linking to test changes across packages
143
+ - **Efficiency**: For large monorepos, checks can be done in parallel where possible
144
+
145
+ ## Example Output
146
+
147
+ ```
148
+ ✅ Branch Check: All packages on working branch
149
+ ✅ Remote Sync: All packages up to date with remote
150
+ ✅ Dev Versions: All packages have dev versions (e.g., 1.2.3-dev.0)
151
+ ✅ Link Status: All local dependencies properly linked
152
+
153
+ Project is ready for development!
154
+ ```
155
+
156
+ Or if issues are found:
157
+
158
+ ```
159
+ ❌ Branch Check: @grunnverk/core is on main branch
160
+ ⚠️ Remote Sync: @grunnverk/git-tools is 3 commits behind origin/working
161
+ ❌ Dev Versions: @grunnverk/core has version 1.2.3 (should be 1.2.3-dev.0)
162
+ ⚠️ Link Status: @grunnverk/commands-git is not linked locally
163
+
164
+ Actions needed:
165
+ 1. Switch @grunnverk/core to working branch
166
+ 2. Run kodrdriv tree pull to sync @grunnverk/git-tools
167
+ 3. Run kodrdriv development in @grunnverk/core
168
+ 4. Run kodrdriv tree link to link local dependencies
169
+ ```
@@ -0,0 +1,62 @@
1
+ Update dependencies to the latest published versions from npmjs for configured scopes and the package's own scope.
2
+
3
+ **CRITICAL RULES:**
4
+ - NEVER update to dev-tagged versions (e.g., `-dev.0`, `-dev.1`, `-alpha`, `-beta`, `-rc`)
5
+ - Projects should NEVER depend on dev versions - they should use `kodrdriv link` for local development
6
+ - Only update to stable, published versions available on npmjs
7
+
8
+ ## Determining Tree vs Single-Package Operation
9
+
10
+ **Important**: Before proceeding, determine if this is a tree operation or a single-package operation:
11
+
12
+ - **Tree Operation**: If the current directory contains subdirectories with `package.json` files, this is a monorepo/tree operation. Use `kodrdriv_tree_updates` command.
13
+ - **Single-Package Operation**: If the directory is a leaf project (single package without subdirectories containing `package.json`), this is NOT a tree operation. Use `kodrdriv_updates` command instead.
14
+
15
+ **Workflow:**
16
+
17
+ ### For Tree Operations (Monorepo)
18
+
19
+ 1. Determine which scopes to update:
20
+ - Check configuration for `updates.scopes` or `publish.scopedDependencyUpdates`
21
+ - If the current package has a scope (e.g., `@grunnverk/my-package`), include that scope
22
+ - Use all configured scopes plus the package's own scope
23
+
24
+ 2. Run `kodrdriv_tree_updates`:
25
+ - This uses npm-check-updates to find latest versions matching the scope pattern across all packages in the tree
26
+ - Updates only packages published on npmjs (not dev versions)
27
+ - Updates dependencies, devDependencies, and peerDependencies sections
28
+
29
+ 3. After updates:
30
+ - Run `npm install` in each updated package to update package-lock.json
31
+ - Review changes to ensure no dev versions were introduced
32
+ - Run `kodrdriv_tree_precommit` to verify everything still works across the tree
33
+ - **Note**: If precommit fails due to coverage threshold issues and the project uses lcov format, consider using the `brennpunkt` MCP server tools to analyze coverage gaps and prioritize test improvements. Install brennpunkt as an MCP server with: `npx -y -p @redaksjon/brennpunkt brennpunkt-mcp`
34
+ - Commit the changes with `kodrdriv_tree_commit`
35
+
36
+ ### For Single-Package Operations (Leaf Project)
37
+
38
+ 1. Determine which scopes to update:
39
+ - Check configuration for `updates.scopes` or `publish.scopedDependencyUpdates`
40
+ - If the current package has a scope (e.g., `@grunnverk/my-package`), include that scope
41
+ - Use all configured scopes plus the package's own scope
42
+
43
+ 2. Run `kodrdriv_updates`:
44
+ - This uses npm-check-updates to find latest versions matching the scope pattern for the single package
45
+ - Updates only packages published on npmjs (not dev versions)
46
+ - Updates dependencies, devDependencies, and peerDependencies sections
47
+
48
+ 3. After updates:
49
+ - Run `npm install` to update package-lock.json
50
+ - Review changes to ensure no dev versions were introduced
51
+ - Run `kodrdriv_precommit` to verify everything still works
52
+ - **Note**: If precommit fails due to coverage threshold issues and the project uses lcov format, consider using the `brennpunkt` MCP server tools to analyze coverage gaps and prioritize test improvements. Install brennpunkt as an MCP server with: `npx -y -p @redaksjon/brennpunkt brennpunkt-mcp`
53
+ - Commit the changes with `kodrdriv_commit`
54
+
55
+ **Example:**
56
+ If package is `@grunnverk/my-package` and config has `scopedDependencyUpdates: ["@riotprompt"]`, update:
57
+ - `@grunnverk/*` dependencies (package's own scope)
58
+ - `@riotprompt/*` dependencies (configured scope)
59
+
60
+ **Verification:**
61
+ - Check that no dependencies were updated to versions containing `-dev`, `-alpha`, `-beta`, or `-rc`
62
+ - If any dev versions are found, they should be removed and replaced with `kodrdriv link` workflow instead
@@ -0,0 +1,53 @@
1
+ # Fix and Commit Workflow
2
+
3
+ ## Objective
4
+
5
+ Ensure that precommit checks pass successfully for a single package. When failures occur, understand the root cause, fix the issues, and iterate until all checks pass.
6
+
7
+ ## Workflow Steps
8
+
9
+ 1. **Run Precommit Check**
10
+ - Run `kodrdriv_precommit` with `fix=true` on the directory (${directory})
11
+ - This will execute precommit checks (linting, type checking, tests, build) for the single package
12
+
13
+ 2. **Handle Failures**
14
+ - If precommit fails, analyze the error output and fix the issues:
15
+ - For lint errors: Fix code style issues or disable specific rules with inline comments if justified
16
+ - For type errors: Fix TypeScript type issues
17
+ - For test failures: Update or fix tests to match new behavior
18
+ - For build failures: Fix compilation or bundling issues
19
+ - For coverage drops: Add tests to maintain coverage thresholds
20
+ - **Tip**: If the project uses lcov format for coverage reports and you're struggling with coverage thresholds, consider using the `brennpunkt` MCP server tools (e.g., `brennpunkt_get_priorities`, `brennpunkt_coverage_summary`, `brennpunkt_get_file_coverage`) to identify high-priority files and understand coverage gaps. Install brennpunkt as an MCP server with: `npx -y -p @redaksjon/brennpunkt brennpunkt-mcp`
21
+
22
+ 3. **Iterate Until Success**
23
+ - Re-run `kodrdriv_precommit` with `fix=true` after each fix until all checks pass
24
+
25
+ 4. **Commit Changes**
26
+ - Once precommit checks pass, commit the fixes using `kodrdriv_commit` with `sendit=true`
27
+ - The commit message will be automatically generated from the changes
28
+
29
+ ## Important Notes
30
+
31
+ - **Fix Flag**: Use `fix=true` to enable auto-fixing where possible, but manual fixes may still be required
32
+ - **Iterative Process**: Continue fixing and re-running precommit until all checks pass
33
+
34
+ ## Example Flow
35
+
36
+ ```
37
+ 1. kodrdriv_precommit({ directory: "/path/to/package", fix: true })
38
+ → Fails: TypeScript type error in src/index.ts:42
39
+
40
+ 2. Analyze error: TypeScript type error in src/index.ts:42
41
+ → Fix the type error
42
+
43
+ 3. kodrdriv_precommit({ directory: "/path/to/package", fix: true })
44
+ → Fails: Linting error in src/utils.ts:15
45
+
46
+ 4. Fix linting error
47
+
48
+ 5. kodrdriv_precommit({ directory: "/path/to/package", fix: true })
49
+ → All checks pass
50
+
51
+ 6. kodrdriv_commit({ directory: "/path/to/package", sendit: true })
52
+ → Commits all fixes
53
+ ```
@@ -0,0 +1,100 @@
1
+ # Publish Workflow
2
+
3
+ ## Objective
4
+
5
+ Execute a complete publishing workflow for a single package. Handle errors gracefully, fix issues as they arise, and resume appropriately.
6
+
7
+ ## Pre-Publish Verification
8
+
9
+ Before running `kodrdriv_publish`, verify that `kodrdriv_precommit` works successfully.
10
+
11
+ **Exception**: If `fix_and_commit` was just executed successfully, you can skip the precommit check and proceed directly to publish. The `fix_and_commit` workflow already ensures all precommit checks pass.
12
+
13
+ ## Publishing Workflow
14
+
15
+ 1. **Run Publish**
16
+ - Execute `kodrdriv_publish` with appropriate parameters
17
+ - The command will start generating output
18
+
19
+ 2. **Monitor for Errors**
20
+ - Watch for errors:
21
+ - **GitHub Actions/Workflows errors**: Build failures, test failures, or validation errors in Pull Requests
22
+ - **Git conflicts**: Merge conflicts or branch state issues
23
+ - **Precondition check failures**: Version conflicts, branch state issues, or dependency problems
24
+
25
+ 3. **Handle Pull Request Errors**
26
+ - If an error occurs during Pull Request validation:
27
+ - The error message will typically include a link to the failing PR or workflow
28
+ - Navigate to the provided link and investigate the build/test errors
29
+ - Fix the issues in the codebase
30
+ - **Tip**: If test failures are related to coverage thresholds and the project uses lcov format, consider using the `brennpunkt` MCP server tools (e.g., `brennpunkt_get_priorities`, `brennpunkt_coverage_summary`) to identify which files need test coverage improvements. Install brennpunkt as an MCP server with: `npx -y -p @redaksjon/brennpunkt brennpunkt-mcp`
31
+ - Commit and push the fixes
32
+ - Simply restart `kodrdriv_publish` - the system will automatically check if a Pull Request exists and resume appropriately
33
+ - **Note**: Single-package publish does not use the `continue` parameter
34
+
35
+ 4. **Handle Release Workflow Errors**
36
+ - If an error occurs while waiting for a Release Workflow:
37
+ - This indicates a more serious problem
38
+ - Ask the user how to proceed
39
+ - The system may be in an inconsistent state that requires manual intervention
40
+
41
+ 5. **Handle Precondition Check Failures**
42
+ - If precondition checks fail (version conflicts, branch state, etc.):
43
+ - Analyze the error message to understand what needs to be fixed
44
+ - Fix the underlying issues
45
+ - Re-run `kodrdriv_publish`
46
+
47
+ ## Error Resolution Strategy
48
+
49
+ ### When Errors Occur
50
+
51
+ 1. **Read the Error Message Carefully**
52
+ - Error messages typically indicate:
53
+ - What type of error occurred
54
+ - Where to look for more information (PR links, file paths, etc.)
55
+
56
+ 2. **Investigate the Root Cause**
57
+ - For GitHub workflow errors: Check the PR/workflow logs
58
+ - For Git errors: Check branch state, conflicts, or merge issues
59
+ - For precondition errors: Check version numbers, branch names, or dependency states
60
+
61
+ 3. **Fix the Issues**
62
+ - Make necessary code changes
63
+ - Fix version conflicts
64
+ - Resolve Git conflicts
65
+ - Update dependencies if needed
66
+
67
+ 4. **Commit and Push**
68
+ - Commit fixes with appropriate messages
69
+ - Push changes to trigger re-validation
70
+
71
+ 5. **Resume Appropriately**
72
+ - Simply restart `kodrdriv_publish` - the system will automatically detect existing PRs and resume appropriately
73
+
74
+ ## Expected End State
75
+
76
+ After a successful publish workflow, the project should end up in a "working" branch with:
77
+ - An incremented version number
78
+ - A dev tag (e.g., `1.2.3-dev.0`)
79
+
80
+ **Note**: This is information for verification purposes. The publish workflow handles versioning automatically - you don't need to manually manage versions or tags.
81
+
82
+ ## Important Notes
83
+
84
+ - **Don't Skip Precommit**: Unless `fix_and_commit` was just run, always verify precommit checks pass before publishing.
85
+ - **Error Links**: When GitHub errors occur, they often provide direct links to PRs or workflows - use these to understand what needs fixing.
86
+ - **Resume Strategy**: Simply restart `kodrdriv_publish` - the system will automatically detect existing PRs and resume appropriately.
87
+
88
+ ## Example Flow
89
+
90
+ ```
91
+ 1. Run kodrdriv_precommit (unless fix_and_commit was just run)
92
+ 2. Run kodrdriv_publish
93
+ → Error: PR validation failed
94
+ → Link provided: https://github.com/org/repo/pull/456
95
+ 3. Investigate PR #456 → Find linting error
96
+ 4. Fix the linting error → Commit and push
97
+ 5. Run kodrdriv_publish again
98
+ → System detects existing PR and resumes appropriately
99
+ 6. Monitor for completion
100
+ ```
@@ -0,0 +1,102 @@
1
+ # Tree Fix and Commit Workflow
2
+
3
+ ## Objective
4
+
5
+ Ensure that precommit checks pass successfully across the entire monorepo tree. When failures occur, understand the root cause, fix the issues, and resume from the point of failure rather than restarting from the beginning.
6
+
7
+ ## Critical: Monorepo Root Directory
8
+
9
+ **IMPORTANT**: The monorepo root directory is `/Users/tobrien/gitw/grunnverk`, NOT `/Users/tobrien/gitw/grunnverk/kodrdriv`.
10
+
11
+ - `kodrdriv` is a subdirectory within the `grunnverk` monorepo
12
+ - All tree commands MUST be run from the grunnverk root: `/Users/tobrien/gitw/grunnverk`
13
+ - Never run tree commands from within the kodrdriv subdirectory
14
+ - The `directory` parameter for all MCP tree commands should be `/Users/tobrien/gitw/grunnverk`
15
+
16
+ ## Workflow Steps
17
+
18
+ 1. **Initial Precommit Check**
19
+ - **ALWAYS use the MCP tool**: Run `kodrdriv_tree_precommit` with `fix=true`, `parallel=true`, and `directory="/Users/tobrien/gitw/grunnverk"`
20
+ - **CRITICAL: Use `parallel=true`** - This dramatically speeds up execution for large monorepos by running independent packages concurrently
21
+ - **DO NOT** fall back to manual command-line execution (`npx kodrdriv tree precommit`) unless the MCP tool is completely broken
22
+ - If the MCP tool fails, investigate the error message carefully - it will tell you which package failed and why
23
+ - This will execute precommit checks (linting, type checking, tests, build) across all packages, respecting dependency order even in parallel mode
24
+
25
+ 2. **Handle Failures**
26
+ - **If the MCP tool fails**: The error message will indicate which package failed (e.g., "Command failed in package @grunnverk/tree-execution")
27
+ - **DO NOT** switch to manual command-line execution - continue using the MCP tool with `start_from` parameter
28
+ - Carefully analyze the error output to understand:
29
+ - Which package failed
30
+ - What type of error occurred (lint error, type error, test failure, build failure)
31
+ - The specific files and lines involved
32
+ - Fix the issues in the failing package:
33
+ - For lint errors: Fix code style issues or disable specific rules with inline comments if justified
34
+ - For type errors: Fix TypeScript type issues
35
+ - For test failures: Update or fix tests to match new behavior
36
+ - For build failures: Fix compilation or bundling issues
37
+ - For coverage drops: Add tests to maintain coverage thresholds
38
+ - **Tip**: If the project uses lcov format for coverage reports and you're struggling with coverage thresholds, consider using the `brennpunkt` MCP server tools (e.g., `brennpunkt_get_priorities`, `brennpunkt_coverage_summary`, `brennpunkt_get_file_coverage`) to identify high-priority files and understand coverage gaps. Install brennpunkt as an MCP server with: `npx -y -p @redaksjon/brennpunkt brennpunkt-mcp`
39
+
40
+ 3. **Resume from Failure Point**
41
+ - After fixing issues, use `start_from` parameter to resume from the package that failed
42
+ - **ALWAYS include `parallel=true`** when resuming - it significantly reduces wait time
43
+ - This avoids re-running checks on packages that already passed, saving significant time in large projects
44
+ - Example: If package `@grunnverk/core` failed, run `kodrdriv_tree_precommit` with `start_from="@grunnverk/core"`, `parallel=true`, and `fix=true`
45
+ - The `start_from` parameter accepts either package name (e.g., `@grunnverk/core`) or directory name (e.g., `core`)
46
+
47
+ 4. **Iterate Until Success**
48
+ - Repeat steps 2-3 until all packages pass precommit checks
49
+ - Each iteration should resume from the last failing package
50
+
51
+ 5. **Commit Changes**
52
+ - Once all precommit checks pass, commit the fixes using `kodrdriv_tree_commit` with `sendit=true`
53
+ - The commit message will be automatically generated from the changes
54
+
55
+ ## Important Notes
56
+
57
+ - **ALWAYS use MCP tools**: Use `kodrdriv_tree_precommit`, `kodrdriv_tree_commit`, etc. - do NOT fall back to manual command-line execution
58
+ - **Monorepo Root**: Always use `directory="/Users/tobrien/gitw/grunnverk"` - kodrdriv is a subdirectory, not the root
59
+ - **Parallel Execution**: **ALWAYS use `parallel=true`** - This is critical for large monorepos as it can reduce execution time from 20-30 minutes to 5-10 minutes by running independent packages concurrently
60
+ - **Efficiency**: For large monorepos, always use `start_from` to resume from failures rather than restarting the entire process
61
+ - **Dependency Order**: The tree commands process packages in dependency order, even in parallel mode - independent packages run concurrently while respecting dependencies
62
+ - **Fix Flag**: Use `fix=true` to enable auto-fixing where possible, but manual fixes may still be required
63
+ - **All Tree Commands Support `start_from`**: The `start_from` parameter works with all tree MCP commands (`kodrdriv_tree_precommit`, `kodrdriv_tree_publish`, `kodrdriv_tree_commit`, etc.)
64
+ - **MCP Tool Failures**: If the MCP tool reports an error, investigate the error message - it contains the package name and failure reason. Continue using the MCP tool with `start_from` and `parallel=true` to resume from the failure point.
65
+
66
+ ## Example Flow
67
+
68
+ ```
69
+ 1. kodrdriv_tree_precommit({
70
+ directory: "/Users/tobrien/gitw/grunnverk",
71
+ fix: true,
72
+ parallel: true // CRITICAL: Speeds up execution significantly
73
+ })
74
+ → Fails at package "@grunnverk/commands-git"
75
+ → Error: "Command failed in package @grunnverk/commands-git"
76
+
77
+ 2. Analyze error: TypeScript type error in src/git.ts:42
78
+ → Fix the type error in the commands-git package
79
+
80
+ 3. kodrdriv_tree_precommit({
81
+ directory: "/Users/tobrien/gitw/grunnverk",
82
+ fix: true,
83
+ parallel: true, // ALWAYS include parallel=true
84
+ start_from: "commands-git" // or "@grunnverk/commands-git"
85
+ })
86
+ → Continues from commands-git, may fail at next package
87
+
88
+ 4. Repeat until all pass (always using MCP tools with parallel=true, never manual commands)
89
+
90
+ 5. kodrdriv_tree_commit({
91
+ directory: "/Users/tobrien/gitw/grunnverk",
92
+ sendit: true
93
+ })
94
+ → Commits all fixes
95
+ ```
96
+
97
+ ## What NOT to Do
98
+
99
+ - ❌ **DO NOT** run `npx kodrdriv tree precommit` manually from the command line
100
+ - ❌ **DO NOT** use `/Users/tobrien/gitw/grunnverk/kodrdriv` as the directory - that's a subdirectory, not the root
101
+ - ❌ **DO NOT** switch to manual execution if the MCP tool fails - investigate the error and use `start_from` to resume
102
+ - ❌ **DO NOT** run commands from within the kodrdriv directory - always use the grunnverk root
@@ -0,0 +1,118 @@
1
+ # Tree Publish Workflow
2
+
3
+ ## Objective
4
+
5
+ Execute a complete publishing workflow for a monorepo tree. Handle errors gracefully, fix issues as they arise, and resume from checkpoints when appropriate.
6
+
7
+ ## Pre-Publish Verification
8
+
9
+ **Important**: Before running `kodrdriv_tree_publish`, verify that `kodrdriv_tree_precommit` works successfully.
10
+
11
+ **CRITICAL: Use `parallel=true`** when running `kodrdriv_tree_precommit` - this dramatically speeds up execution for large monorepos (reduces time from 20-30 minutes to 5-10 minutes).
12
+
13
+ **Exception**: If `tree_fix_and_commit` was just executed successfully, you can skip the precommit check and proceed directly to publish. The `tree_fix_and_commit` workflow already ensures all precommit checks pass.
14
+
15
+ ## Publishing Workflow
16
+
17
+ **CRITICAL: Maintain Tree Publish Context**
18
+
19
+ Once you start a `kodrdriv_tree_publish` operation, you establish a context file that facilitates coordinated version updates across all projects in the monorepo. **DO NOT switch between tree and single-package operations** during a publish workflow.
20
+
21
+ - **If tree publish fails**: Fix the problem at the failing package, then return to the **top-level directory** and run `kodrdriv_tree_publish` with `continue: true`
22
+ - **NEVER switch to `kodrdriv_publish`** in a subproject when recovering from a tree publish failure
23
+ - The context file created by tree publish tracks version coordination across packages - switching to single-package publish breaks this coordination
24
+
25
+ 1. **Run Tree Publish**
26
+ - Execute `kodrdriv_tree_publish` with appropriate parameters
27
+ - If specific packages are provided (${packages}), use the `packages` parameter to target only those packages
28
+ - The command will start generating output as it processes packages in dependency order
29
+ - This creates a context file that tracks version updates across the entire tree
30
+
31
+ 2. **Monitor for Errors**
32
+ - Watch the output carefully for errors
33
+ - Common error sources:
34
+ - **GitHub Actions/Workflows**: Build failures, test failures, or validation errors in Pull Requests
35
+ - **Git Conflicts**: Merge conflicts or branch state issues
36
+ - **Precondition Checks**: Version conflicts, branch state issues, or dependency problems
37
+
38
+ 3. **Handle Pull Request Errors**
39
+ - If an error occurs during Pull Request validation:
40
+ - The error message will typically include a link to the failing PR or workflow
41
+ - Navigate to the provided link and investigate the build/test errors
42
+ - Fix the issues in the codebase
43
+ - **Tip**: If test failures are related to coverage thresholds and the project uses lcov format, consider using the `brennpunkt` MCP server tools (e.g., `brennpunkt_get_priorities`, `brennpunkt_coverage_summary`) to identify which files need test coverage improvements. Install brennpunkt as an MCP server with: `npx -y -p @redaksjon/brennpunkt brennpunkt-mcp`
44
+ - Commit and push the fixes
45
+ - Once the PR starts re-validating, use `kodrdriv_tree_publish` with `continue: true` to resume from the checkpoint
46
+ - **Important**: The `continue` parameter only works during the Pull Request wait phase
47
+
48
+ 4. **Handle Release Workflow Errors**
49
+ - If an error occurs while waiting for a Release Workflow:
50
+ - This indicates a more serious problem
51
+ - **Do NOT attempt to use `continue`** - ask the user how to proceed
52
+ - The system may be in an inconsistent state that requires manual intervention
53
+
54
+ 5. **Handle Precondition Check Failures**
55
+ - If precondition checks fail (version conflicts, branch state, etc.):
56
+ - Analyze the error message to understand what needs to be fixed
57
+ - Fix the underlying issues
58
+ - Re-run `kodrdriv_tree_publish` (you may need to use `continue: true` if a checkpoint exists)
59
+
60
+ ## Error Resolution Strategy
61
+
62
+ ### When Errors Occur
63
+
64
+ 1. **Read the Error Message Carefully**
65
+ - Error messages typically indicate:
66
+ - Which package failed
67
+ - What type of error occurred
68
+ - Where to look for more information (PR links, file paths, etc.)
69
+
70
+ 2. **Investigate the Root Cause**
71
+ - For GitHub workflow errors: Check the PR/workflow logs
72
+ - For Git errors: Check branch state, conflicts, or merge issues
73
+ - For precondition errors: Check version numbers, branch names, or dependency states
74
+
75
+ 3. **Fix the Issues**
76
+ - Make necessary code changes
77
+ - Fix version conflicts
78
+ - Resolve Git conflicts
79
+ - Update dependencies if needed
80
+
81
+ 4. **Commit and Push**
82
+ - Commit fixes with appropriate messages
83
+ - Push changes to trigger re-validation
84
+
85
+ 5. **Resume Appropriately**
86
+ - Return to the **top-level directory** and use `kodrdriv_tree_publish` with `continue: true` during PR wait phase
87
+ - **CRITICAL**: Do NOT switch to `kodrdriv_publish` in a subproject - this breaks the tree publish context
88
+
89
+ ## Expected End State
90
+
91
+ After a successful publish workflow, projects should end up in a "working" branch with:
92
+ - An incremented version number
93
+ - A dev tag (e.g., `1.2.3-dev.0`)
94
+
95
+ **Note**: This is information for verification purposes. The publish workflow handles versioning automatically - you don't need to manually manage versions or tags.
96
+
97
+ ## Important Notes
98
+
99
+ - **Maintain Tree Publish Context**: Once you start `kodrdriv_tree_publish`, you establish a context file that coordinates version updates across projects. If tree publish fails, fix the issue and return to the top-level directory to run `kodrdriv_tree_publish` with `continue: true`. **NEVER switch to `kodrdriv_publish` in a subproject** - this breaks version coordination.
100
+ - **Checkpoint Recovery**: The `continue` parameter only works during Pull Request validation waits. It does NOT work for Release Workflow errors.
101
+ - **Don't Skip Precommit**: Unless `fix_and_commit` was just run, always verify precommit checks pass before publishing.
102
+ - **Error Links**: When GitHub errors occur, they often provide direct links to PRs or workflows - use these to understand what needs fixing.
103
+ - **Resume Strategy**: Use `continue: true` to resume from checkpoints at the **top-level directory**.
104
+
105
+ ## Example Flow
106
+
107
+ ```
108
+ 1. Run kodrdriv_tree_precommit({ parallel: true }) (unless fix_and_commit was just run)
109
+ → Use parallel=true to speed up execution significantly
110
+ 2. Run kodrdriv_tree_publish
111
+ → Error: PR validation failed for @org/package-a
112
+ → Link provided: https://github.com/org/repo/pull/123
113
+ 3. Investigate PR #123 → Find failing test
114
+ 4. Fix the test → Commit and push
115
+ 5. **Return to top-level directory** → Run kodrdriv_tree_publish({ continue: true })
116
+ → Resumes from checkpoint, continues processing with maintained context
117
+ 6. Monitor for additional errors or completion
118
+ ```