@eldrforge/kodrdriv 0.0.3 → 0.0.7
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/.kodrdriv/config.yaml +13 -5
- package/.kodrdriv/context/content.md +1 -0
- package/README.md +421 -4
- package/dist/arguments.js +93 -16
- package/dist/arguments.js.map +1 -1
- package/dist/commands/commit.js +15 -8
- package/dist/commands/commit.js.map +1 -1
- package/dist/commands/link.js +183 -0
- package/dist/commands/link.js.map +1 -0
- package/dist/commands/publish.js +216 -0
- package/dist/commands/publish.js.map +1 -0
- package/dist/commands/release.js +4 -1
- package/dist/commands/release.js.map +1 -1
- package/dist/commands/unlink.js +179 -0
- package/dist/commands/unlink.js.map +1 -0
- package/dist/constants.js +24 -3
- package/dist/constants.js.map +1 -1
- package/dist/content/diff.js.map +1 -1
- package/dist/content/log.js.map +1 -1
- package/dist/error/ExitError.js.map +1 -1
- package/dist/logging.js.map +1 -1
- package/dist/main.js +13 -3
- package/dist/main.js.map +1 -1
- package/dist/prompt/instructions/release.md +29 -28
- package/dist/prompt/prompts.js.map +1 -1
- package/dist/types.js +17 -0
- package/dist/types.js.map +1 -1
- package/dist/util/child.js.map +1 -1
- package/dist/util/general.js +13 -1
- package/dist/util/general.js.map +1 -1
- package/dist/util/github.js +144 -0
- package/dist/util/github.js.map +1 -0
- package/dist/util/openai.js.map +1 -1
- package/dist/util/storage.js +4 -0
- package/dist/util/storage.js.map +1 -1
- package/package.json +19 -18
- package/vitest.config.ts +7 -4
- package/.kodrdriv/context/people/context.md +0 -5
- package/.kodrdriv/context/projects/context.md +0 -3
- package/.kodrdriv/instructions/INACTIVE-release-pre.md +0 -1
package/.kodrdriv/config.yaml
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
verbose: false
|
|
2
|
-
model: gpt-
|
|
2
|
+
model: gpt-4.1
|
|
3
3
|
contextDirectories:
|
|
4
|
-
- .kodrdriv/context
|
|
5
|
-
- .kodrdriv/context/projects
|
|
4
|
+
- .kodrdriv/context
|
|
6
5
|
commit:
|
|
6
|
+
add: true
|
|
7
7
|
cached: true
|
|
8
8
|
sendit: true
|
|
9
|
-
messageLimit: 10
|
|
10
9
|
release:
|
|
11
10
|
from: main
|
|
12
|
-
to: HEAD
|
|
11
|
+
to: HEAD
|
|
12
|
+
publish:
|
|
13
|
+
mergeMethod: squash
|
|
14
|
+
dependencyUpdatePatterns: ["@theunwalked/*", "@riotprompt/*"]
|
|
15
|
+
requiredEnvVars: ["NODE_AUTH_TOKEN"]
|
|
16
|
+
link:
|
|
17
|
+
scopeRoots:
|
|
18
|
+
"@theunwalked": "../../SemicolonAmbulance"
|
|
19
|
+
"@riotprompt": "../../StJustReckoning"
|
|
20
|
+
workspaceFile: "pnpm-workspace.yaml"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
KodrDriv is a tool that is designed to help automate the creation of commit messages and release notes. It is also a tool that has been designed to support an opinionated approach to organizing related projects and conducting structured releases with Git. This initial version focuses on pnpm and GitHub, but there are plans to expand coverage over time.
|
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ This will make the `kodrdriv` command available globally on your system.
|
|
|
14
14
|
|
|
15
15
|
## Commands
|
|
16
16
|
|
|
17
|
-
KodrDriv provides
|
|
17
|
+
KodrDriv provides four main commands:
|
|
18
18
|
|
|
19
19
|
### Commit Command
|
|
20
20
|
|
|
@@ -53,6 +53,115 @@ kodrdriv release
|
|
|
53
53
|
>
|
|
54
54
|
> You can use the `--from` and `--to` options to generate release notes comparing two different releases. For example, to see what changed between v1.0.0 and v1.1.0, you could use `kodrdriv release --from v1.0.0 --to v1.1.0`. This is particularly useful for creating detailed changelogs when preparing release documentation.
|
|
55
55
|
|
|
56
|
+
### Publish Command
|
|
57
|
+
|
|
58
|
+
Automate the entire release process, from dependency updates to GitHub release creation:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
kodrdriv publish
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The `publish` command orchestrates a comprehensive release workflow, designed to ensure a safe and consistent release process. Here's what it does:
|
|
65
|
+
|
|
66
|
+
1. **Dependency Management**: If a `pnpm-workspace.yaml` file is present, it's temporarily renamed to switch from workspace dependencies to registry versions. It then runs `pnpm update --latest` to ensure dependencies are up to date. You can configure specific dependency patterns to update instead of updating all dependencies using the `dependencyUpdatePatterns` configuration option.
|
|
67
|
+
|
|
68
|
+
2. **Pre-flight Checks**: Before committing any changes, it runs the `prepublishOnly` script from your `package.json`. This script should contain your project's pre-flight checks (e.g., `clean`, `lint`, `build`, `test`) to ensure the project is in a good state. **Note**: A `prepublishOnly` script is required in your `package.json` - the publish command will fail if this script is not present.
|
|
69
|
+
|
|
70
|
+
3. **Release Commit**: If there are changes to `package.json` or `pnpm-lock.yaml`, it creates an intelligent commit message for the dependency updates.
|
|
71
|
+
|
|
72
|
+
4. **Version Bump**: It automatically bumps the patch version of your project.
|
|
73
|
+
|
|
74
|
+
5. **Release Notes**: It generates release notes based on the recent changes and saves them to `RELEASE_NOTES.md`.
|
|
75
|
+
|
|
76
|
+
6. **Pull Request Automation**:
|
|
77
|
+
* It pushes the changes and tags to the origin.
|
|
78
|
+
* It creates a new pull request for the release.
|
|
79
|
+
* It waits for all status checks on the pull request to pass.
|
|
80
|
+
* Once checks are complete, it automatically merges the pull request using the configured merge method (default: squash).
|
|
81
|
+
|
|
82
|
+
7. **GitHub Release**: After the PR is merged, it checks out the `main` branch, pulls the latest changes, and creates a new GitHub release with the tag and release notes.
|
|
83
|
+
|
|
84
|
+
8. **New Release Branch**: Finally, it creates and pushes a new release branch for the next version (e.g., `release/0.0.5`).
|
|
85
|
+
|
|
86
|
+
This command is designed for repositories that follow a pull-request-based release workflow with required status checks. It streamlines the process, reducing manual steps and potential for error.
|
|
87
|
+
|
|
88
|
+
> [!TIP]
|
|
89
|
+
> ### Choosing the Right Merge Method
|
|
90
|
+
>
|
|
91
|
+
> The merge method you choose affects your Git history and can impact your team's workflow:
|
|
92
|
+
>
|
|
93
|
+
> - **Squash** (default): Best for keeping a clean, linear history. All commits from the feature branch are combined into a single commit, making it easier to understand what was changed in each release.
|
|
94
|
+
>
|
|
95
|
+
> - **Merge**: Preserves the complete commit history from the feature branch. Use this when you want to maintain detailed development history and individual commit information.
|
|
96
|
+
>
|
|
97
|
+
> - **Rebase**: Creates a linear history without merge commits. The commits from the feature branch are replayed on top of the target branch. This keeps history clean while preserving individual commits.
|
|
98
|
+
>
|
|
99
|
+
> Consider your team's preferences and any branch protection rules when choosing a merge method.
|
|
100
|
+
|
|
101
|
+
### Link Command
|
|
102
|
+
|
|
103
|
+
Manage pnpm workspace links for local development with sibling projects:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
kodrdriv link
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
The `link` command automates the creation and management of pnpm workspace configurations for local development. It scans your project's dependencies and automatically discovers matching sibling packages in configured scope directories, then updates your `pnpm-workspace.yaml` file to link them for local development.
|
|
110
|
+
|
|
111
|
+
This is particularly useful when working with monorepos or related packages where you want to use local versions of dependencies instead of published registry versions during development.
|
|
112
|
+
|
|
113
|
+
**How it works:**
|
|
114
|
+
|
|
115
|
+
1. **Dependency Analysis**: Reads your `package.json` and examines all dependencies (including devDependencies and peerDependencies)
|
|
116
|
+
|
|
117
|
+
2. **Scope-based Scanning**: For each configured scope (e.g., `@company`, `@myorg`), it scans the specified root directory to find all available packages by reading their `package.json` files
|
|
118
|
+
|
|
119
|
+
3. **Smart Matching**: Instead of relying on directory naming conventions, it matches dependencies by their actual package names from `package.json`, handling cases where directory names don't match package names
|
|
120
|
+
|
|
121
|
+
4. **Workspace Management**: Updates or creates a `pnpm-workspace.yaml` file with the discovered local packages, preserving any existing workspace configuration
|
|
122
|
+
|
|
123
|
+
**Example Scenario:**
|
|
124
|
+
|
|
125
|
+
Suppose you're working on `@company/api` and it depends on `@company/logging`. Your directory structure might look like:
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
workspace/
|
|
129
|
+
├── company-api/ # Contains @company/api
|
|
130
|
+
├── company-logging-lib/ # Contains @company/logging (note: different directory name)
|
|
131
|
+
└── other-project/
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
The link command would:
|
|
135
|
+
- Scan `../` for packages with scope `@company`
|
|
136
|
+
- Find `@company/logging` in `../company-logging-lib/`
|
|
137
|
+
- Update `pnpm-workspace.yaml` to include `../company-logging-lib`
|
|
138
|
+
|
|
139
|
+
**Configuration Requirements:**
|
|
140
|
+
|
|
141
|
+
The link command requires scope root mappings to be configured. You can provide these via:
|
|
142
|
+
|
|
143
|
+
1. **Command line**: `--scope-roots '{"@company": "../", "@myorg": "../../"}'`
|
|
144
|
+
2. **Configuration file**: Set `link.scopeRoots` in your `.kodrdriv/config.json`
|
|
145
|
+
|
|
146
|
+
**Dry Run Support:**
|
|
147
|
+
|
|
148
|
+
Use `--dry-run` to preview what packages would be linked without making changes:
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
kodrdriv link --scope-roots '{"@company": "../"}' --dry-run
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
> [!TIP]
|
|
155
|
+
> ### Best Practices for Link Command
|
|
156
|
+
>
|
|
157
|
+
> - **Use relative paths**: Configure scope roots with relative paths (like `../` or `../../`) to ensure the workspace file works across different environments
|
|
158
|
+
>
|
|
159
|
+
> - **Scope organization**: Group related packages under the same scope (e.g., `@company/api`, `@company/logging`) for easier management
|
|
160
|
+
>
|
|
161
|
+
> - **Version with caution**: Consider whether to commit the generated `pnpm-workspace.yaml` file. You might want to add it to `.gitignore` if it's only for local development
|
|
162
|
+
>
|
|
163
|
+
> - **Multiple scopes**: You can configure multiple scope roots to handle packages from different organizations or teams in the same workspace
|
|
164
|
+
|
|
56
165
|
## Command Line Options
|
|
57
166
|
|
|
58
167
|
KodrDriv provides several command line options to customize its behavior:
|
|
@@ -62,6 +171,9 @@ KodrDriv provides several command line options to customize its behavior:
|
|
|
62
171
|
- `--dry-run`: Perform a dry run without saving files (default: false)
|
|
63
172
|
- `--verbose`: Enable verbose logging (default: false)
|
|
64
173
|
- `--debug`: Enable debug logging (default: false)
|
|
174
|
+
- `--overrides`: Enable instruction overrides (allows custom instruction files to override defaults)
|
|
175
|
+
- `--config-dir <configDir>`: Specify a custom configuration directory (default: '.kodrdriv')
|
|
176
|
+
- `--excluded-paths [excludedPatterns...]`: Paths to exclude from the diff (can specify multiple patterns)
|
|
65
177
|
- `--version`: Display version information
|
|
66
178
|
|
|
67
179
|
### Commit Command Options
|
|
@@ -71,6 +183,214 @@ KodrDriv provides several command line options to customize its behavior:
|
|
|
71
183
|
- `--context <context>`: Provide additional context (as a string or file path) to guide the commit message generation. This context is included in the prompt sent to the AI and can be used to specify the purpose, theme, or any special considerations for the commit.
|
|
72
184
|
- `--message-limit <messageLimit>`: Limit the number of recent commit messages (from git log) to include in the prompt for context (default: 10). This can help focus the AI on the most relevant recent changes.
|
|
73
185
|
|
|
186
|
+
### Publish Command Options
|
|
187
|
+
|
|
188
|
+
- `--merge-method <method>`: Method to merge pull requests during the publish process (default: 'squash')
|
|
189
|
+
- Available methods: 'merge', 'squash', 'rebase'
|
|
190
|
+
- `merge`: Creates a merge commit that combines the feature branch into the target branch
|
|
191
|
+
- `squash`: Combines all commits from the feature branch into a single commit on the target branch
|
|
192
|
+
- `rebase`: Replays commits from the feature branch onto the target branch without creating a merge commit
|
|
193
|
+
|
|
194
|
+
#### Dependency Update Configuration
|
|
195
|
+
|
|
196
|
+
The publish command supports selective dependency updates through the `dependencyUpdatePatterns` configuration option. This allows you to specify which dependencies should be updated during the release process instead of updating all dependencies.
|
|
197
|
+
|
|
198
|
+
**Configuration:**
|
|
199
|
+
```json
|
|
200
|
+
{
|
|
201
|
+
"publish": {
|
|
202
|
+
"dependencyUpdatePatterns": ["@company/*", "@myorg/*", "specific-package"]
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
**Behavior:**
|
|
208
|
+
- When patterns are specified, only dependencies matching those patterns will be updated
|
|
209
|
+
- Patterns can include npm scopes (e.g., `@company/*`) or specific package names
|
|
210
|
+
- If no patterns are configured, all dependencies are updated (default behavior)
|
|
211
|
+
- This is particularly useful when developing a set of related packages where you want to ensure you're using the latest versions of your organization's packages while keeping other dependencies stable
|
|
212
|
+
|
|
213
|
+
#### Environment Variable Configuration
|
|
214
|
+
|
|
215
|
+
The publish command includes comprehensive environment variable validation to ensure all required credentials and tokens are available before starting the release process. This prevents failures partway through the publication workflow.
|
|
216
|
+
|
|
217
|
+
**Core Required Environment Variables:**
|
|
218
|
+
|
|
219
|
+
The following environment variables are required by default for all publish operations:
|
|
220
|
+
|
|
221
|
+
- `GITHUB_TOKEN`: Required for GitHub API operations (creating pull requests, releases, etc.)
|
|
222
|
+
- `OPENAI_API_KEY`: Required for AI-powered commit message and release note generation
|
|
223
|
+
|
|
224
|
+
**Configurable Additional Environment Variables:**
|
|
225
|
+
|
|
226
|
+
You can specify additional required environment variables specific to your project or organization:
|
|
227
|
+
|
|
228
|
+
**Configuration (config.yaml):**
|
|
229
|
+
```yaml
|
|
230
|
+
publish:
|
|
231
|
+
requiredEnvVars:
|
|
232
|
+
- NODE_AUTH_TOKEN # Often needed for publishing to npm
|
|
233
|
+
- DEPLOY_KEY # Custom deployment credentials
|
|
234
|
+
- CUSTOM_API_TOKEN # Organization-specific tokens
|
|
235
|
+
- CODECOV_TOKEN # Code coverage reporting
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
**Configuration (config.json):**
|
|
239
|
+
```json
|
|
240
|
+
{
|
|
241
|
+
"publish": {
|
|
242
|
+
"requiredEnvVars": [
|
|
243
|
+
"NODE_AUTH_TOKEN",
|
|
244
|
+
"DEPLOY_KEY",
|
|
245
|
+
"CUSTOM_API_TOKEN",
|
|
246
|
+
"CODECOV_TOKEN"
|
|
247
|
+
]
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
**Automatic .npmrc Scanning:**
|
|
253
|
+
|
|
254
|
+
The publish command automatically scans your `.npmrc` file for environment variable references and includes them in the validation. It detects common patterns like:
|
|
255
|
+
|
|
256
|
+
- `${NODE_AUTH_TOKEN}` - Curly brace syntax
|
|
257
|
+
- `$NODE_AUTH_TOKEN` - Direct variable reference
|
|
258
|
+
|
|
259
|
+
Example `.npmrc` file:
|
|
260
|
+
```
|
|
261
|
+
@myorg:registry=https://npm.pkg.github.com/
|
|
262
|
+
//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
In this case, `NODE_AUTH_TOKEN` would be automatically detected and validated.
|
|
266
|
+
|
|
267
|
+
**Validation Behavior:**
|
|
268
|
+
- All environment variable checks happen during the initial prechecks phase
|
|
269
|
+
- If any required environment variables are missing, the publish command fails immediately with a clear error message
|
|
270
|
+
- The error message lists all missing variables at once, making it easy to set them all before retrying
|
|
271
|
+
- Variables from configuration, .npmrc scanning, and core requirements are combined and deduplicated
|
|
272
|
+
|
|
273
|
+
**Example Error:**
|
|
274
|
+
```
|
|
275
|
+
Missing required environment variables: NODE_AUTH_TOKEN, DEPLOY_KEY.
|
|
276
|
+
Please set these environment variables before running publish.
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
**Security Best Practices:**
|
|
280
|
+
- Store sensitive environment variables in your CI/CD system's secure variable storage
|
|
281
|
+
- Use tools like 1Password CLI, HashiCorp Vault, or similar for local development
|
|
282
|
+
- Never commit environment variables or tokens to your repository
|
|
283
|
+
- Consider using `.env` files (with proper .gitignore configuration) for local development
|
|
284
|
+
|
|
285
|
+
#### Workspace Package Management
|
|
286
|
+
|
|
287
|
+
The publish command provides options to control whether workspace packages should be linked or unlinked during the release process. Both operations are enabled by default for backward compatibility, but can be disabled if needed.
|
|
288
|
+
|
|
289
|
+
**Configuration Options:**
|
|
290
|
+
|
|
291
|
+
- `linkWorkspacePackages` (boolean, default: true): Controls whether to restore linked workspace packages after the publish process completes
|
|
292
|
+
- `unlinkWorkspacePackages` (boolean, default: true): Controls whether to unlink workspace packages before starting the publish process
|
|
293
|
+
|
|
294
|
+
**Configuration Example:**
|
|
295
|
+
```json
|
|
296
|
+
{
|
|
297
|
+
"publish": {
|
|
298
|
+
"linkWorkspacePackages": false,
|
|
299
|
+
"unlinkWorkspacePackages": false,
|
|
300
|
+
"mergeMethod": "squash"
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
**Use Cases:**
|
|
306
|
+
|
|
307
|
+
- **Skip Unlinking**: Set `unlinkWorkspacePackages: false` if you want to publish using your current workspace configuration without switching to registry dependencies
|
|
308
|
+
- **Skip Linking**: Set `linkWorkspacePackages: false` if you want to leave the project in a "release-ready" state after publishing, with registry dependencies instead of workspace links
|
|
309
|
+
- **Skip Both**: Disable both options if you're managing workspace configuration manually or using a different dependency management strategy
|
|
310
|
+
|
|
311
|
+
**Default Behavior:**
|
|
312
|
+
When both options are enabled (default), the publish command will:
|
|
313
|
+
1. Unlink workspace packages before starting (switching to registry dependencies)
|
|
314
|
+
2. Perform the release process with registry dependencies
|
|
315
|
+
3. Restore workspace links after completion (returning to local development mode)
|
|
316
|
+
|
|
317
|
+
This ensures that releases are published with proper registry dependencies while maintaining local development convenience.
|
|
318
|
+
|
|
319
|
+
#### prepublishOnly Script Requirement
|
|
320
|
+
|
|
321
|
+
The publish command requires a `prepublishOnly` script to be defined in your `package.json`. This script should contain all the checks and builds necessary to verify your project is ready for release.
|
|
322
|
+
|
|
323
|
+
**Example package.json:**
|
|
324
|
+
```json
|
|
325
|
+
{
|
|
326
|
+
"scripts": {
|
|
327
|
+
"prepublishOnly": "pnpm run clean && pnpm run lint && pnpm run build && pnpm run test",
|
|
328
|
+
"clean": "rimraf dist",
|
|
329
|
+
"lint": "eslint src/",
|
|
330
|
+
"build": "tsc",
|
|
331
|
+
"test": "vitest run"
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
**Why prepublishOnly?**
|
|
337
|
+
- The `prepublishOnly` script is an npm/pnpm standard that runs automatically before publishing packages
|
|
338
|
+
- It ensures consistent pre-flight checks regardless of how the package is published
|
|
339
|
+
- It allows projects to define their own specific validation pipeline
|
|
340
|
+
- The publish command validates this script exists during the initial prechecks phase
|
|
341
|
+
|
|
342
|
+
**Common prepublishOnly Patterns:**
|
|
343
|
+
- `"prepublishOnly": "npm run test"` - Run tests only
|
|
344
|
+
- `"prepublishOnly": "npm run build && npm run test"` - Build and test
|
|
345
|
+
- `"prepublishOnly": "npm run lint && npm run build && npm run test"` - Full validation pipeline
|
|
346
|
+
- `"prepublishOnly": "npm run ci"` - Delegate to a CI script that includes all checks
|
|
347
|
+
|
|
348
|
+
If this script is missing, the publish command will fail immediately with a helpful error message explaining the requirement.
|
|
349
|
+
|
|
350
|
+
### Link Command Options
|
|
351
|
+
|
|
352
|
+
- `--scope-roots <scopeRoots>`: JSON mapping of scopes to root directories for package discovery
|
|
353
|
+
- **Format**: `'{"@scope": "path", "@another": "path"}'`
|
|
354
|
+
- **Example**: `'{"@company": "../", "@myorg": "../../packages/"}'`
|
|
355
|
+
- **Required**: At least one scope mapping must be provided
|
|
356
|
+
- `--workspace-file <workspaceFile>`: Path to the workspace file to create/update (default: 'pnpm-workspace.yaml')
|
|
357
|
+
- Can specify custom workspace file names or paths
|
|
358
|
+
- Useful if your project uses non-standard workspace file naming
|
|
359
|
+
|
|
360
|
+
#### Scope Root Configuration
|
|
361
|
+
|
|
362
|
+
The `--scope-roots` option accepts a JSON object mapping package scopes to their corresponding root directories. Each entry tells the link command where to look for packages with that scope.
|
|
363
|
+
|
|
364
|
+
**Configuration Examples:**
|
|
365
|
+
|
|
366
|
+
```bash
|
|
367
|
+
# Single scope
|
|
368
|
+
kodrdriv link --scope-roots '{"@company": "../"}'
|
|
369
|
+
|
|
370
|
+
# Multiple scopes with different paths
|
|
371
|
+
kodrdriv link --scope-roots '{"@company": "../", "@tools": "../../tools/", "@shared": "../shared-packages/"}'
|
|
372
|
+
|
|
373
|
+
# Absolute paths (not recommended for portability)
|
|
374
|
+
kodrdriv link --scope-roots '{"@company": "/Users/dev/projects/company-packages/"}'
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
**Path Resolution:**
|
|
378
|
+
- Relative paths are resolved from the current working directory
|
|
379
|
+
- Use `../` to scan the parent directory
|
|
380
|
+
- Use `../../` to scan two levels up
|
|
381
|
+
- Multiple levels and subdirectories are supported: `../../company/packages/`
|
|
382
|
+
|
|
383
|
+
**Package Discovery Process:**
|
|
384
|
+
1. For each scope root, the command lists all subdirectories
|
|
385
|
+
2. It reads each subdirectory's `package.json` to get the actual package name
|
|
386
|
+
3. It matches discovered package names against your project's dependencies
|
|
387
|
+
4. Matching packages are added to the workspace configuration
|
|
388
|
+
|
|
389
|
+
This approach handles complex scenarios where:
|
|
390
|
+
- Directory names don't match package names (e.g., `logging-lib` directory contains `@company/logging`)
|
|
391
|
+
- Packages are organized in different directory structures
|
|
392
|
+
- Multiple related packages exist in the same scope root
|
|
393
|
+
|
|
74
394
|
### OpenAI Configuration
|
|
75
395
|
|
|
76
396
|
- `--openai-api-key <key>`: OpenAI API key (can also be set via OPENAI_API_KEY environment variable)
|
|
@@ -131,6 +451,54 @@ kodrdriv commit --context "Refactoring for performance" --message-limit 5
|
|
|
131
451
|
kodrdriv release --context "Quarterly release, focus on stability" --message-limit 20
|
|
132
452
|
```
|
|
133
453
|
|
|
454
|
+
Publish with different merge methods:
|
|
455
|
+
```bash
|
|
456
|
+
# Use default squash merge
|
|
457
|
+
kodrdriv publish
|
|
458
|
+
|
|
459
|
+
# Use merge commit (preserves individual commits)
|
|
460
|
+
kodrdriv publish --merge-method merge
|
|
461
|
+
|
|
462
|
+
# Use rebase (clean linear history)
|
|
463
|
+
kodrdriv publish --merge-method rebase
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
Use excluded paths to filter diff content:
|
|
467
|
+
```bash
|
|
468
|
+
# Exclude specific files or directories from diff analysis
|
|
469
|
+
kodrdriv commit --excluded-paths "*.lock" "dist/" "node_modules/"
|
|
470
|
+
|
|
471
|
+
# Exclude patterns from release notes
|
|
472
|
+
kodrdriv release --excluded-paths "package-lock.json" "pnpm-lock.yaml"
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
Use overrides with custom instructions:
|
|
476
|
+
```bash
|
|
477
|
+
# Enable instruction overrides (requires custom instruction files in .kodrdriv/instructions/)
|
|
478
|
+
kodrdriv commit --overrides
|
|
479
|
+
|
|
480
|
+
# Use custom config directory with overrides
|
|
481
|
+
kodrdriv release --config-dir ~/my-kodrdriv-config --overrides
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
Link local packages for development:
|
|
485
|
+
```bash
|
|
486
|
+
# Basic linking with single scope
|
|
487
|
+
kodrdriv link --scope-roots '{"@company": "../"}'
|
|
488
|
+
|
|
489
|
+
# Multiple scopes with different root directories
|
|
490
|
+
kodrdriv link --scope-roots '{"@company": "../", "@tools": "../../tools/"}'
|
|
491
|
+
|
|
492
|
+
# Dry run to preview changes
|
|
493
|
+
kodrdriv link --scope-roots '{"@company": "../"}' --dry-run --verbose
|
|
494
|
+
|
|
495
|
+
# Custom workspace file
|
|
496
|
+
kodrdriv link --scope-roots '{"@company": "../"}' --workspace-file "workspace.yaml"
|
|
497
|
+
|
|
498
|
+
# Real-world example: linking @company packages from company directory
|
|
499
|
+
kodrdriv link --scope-roots '{"@company": "../../company/"}'
|
|
500
|
+
```
|
|
501
|
+
|
|
134
502
|
### Configuration Directory
|
|
135
503
|
|
|
136
504
|
KodrDriv uses a configuration directory to store custom settings, instructions, and other configuration files. You can specify a custom location using the `--config-dir` option:
|
|
@@ -152,9 +520,58 @@ The configuration directory structure is as follows:
|
|
|
152
520
|
│ ├── release.md # Override for release instructions
|
|
153
521
|
│ ├── release-pre.md # Content prepended to default release instructions
|
|
154
522
|
│ └── release-post.md # Content appended to default release instructions
|
|
523
|
+
├── config.json # Main configuration file
|
|
155
524
|
└── ... # Other configuration files
|
|
156
525
|
```
|
|
157
526
|
|
|
527
|
+
### Configuration File
|
|
528
|
+
|
|
529
|
+
You can create a `config.json` file in your `.kodrdriv` directory to set default options for all commands. This allows you to avoid repeating command-line options and ensures consistent behavior across your project.
|
|
530
|
+
|
|
531
|
+
Example configuration file (`.kodrdriv/config.json`):
|
|
532
|
+
|
|
533
|
+
```json
|
|
534
|
+
{
|
|
535
|
+
"model": "gpt-4o-mini",
|
|
536
|
+
"verbose": true,
|
|
537
|
+
"contextDirectories": ["src", "docs"],
|
|
538
|
+
"publish": {
|
|
539
|
+
"mergeMethod": "merge",
|
|
540
|
+
"dependencyUpdatePatterns": ["@company/*", "@myorg/*"],
|
|
541
|
+
"requiredEnvVars": ["NODE_AUTH_TOKEN", "CUSTOM_TOKEN"],
|
|
542
|
+
"linkWorkspacePackages": true,
|
|
543
|
+
"unlinkWorkspacePackages": true
|
|
544
|
+
},
|
|
545
|
+
"commit": {
|
|
546
|
+
"add": true,
|
|
547
|
+
"messageLimit": 5
|
|
548
|
+
},
|
|
549
|
+
"release": {
|
|
550
|
+
"from": "main",
|
|
551
|
+
"to": "HEAD",
|
|
552
|
+
"messageLimit": 10
|
|
553
|
+
},
|
|
554
|
+
"link": {
|
|
555
|
+
"scopeRoots": {
|
|
556
|
+
"@company": "../",
|
|
557
|
+
"@myorg": "../../org-packages/",
|
|
558
|
+
"@tools": "../shared-tools/"
|
|
559
|
+
},
|
|
560
|
+
"workspaceFile": "pnpm-workspace.yaml"
|
|
561
|
+
},
|
|
562
|
+
"excludedPatterns": [
|
|
563
|
+
"node_modules",
|
|
564
|
+
"dist",
|
|
565
|
+
"*.log"
|
|
566
|
+
]
|
|
567
|
+
}
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
Configuration options set in the file can be overridden by command-line arguments. The precedence order is:
|
|
571
|
+
1. Command-line arguments (highest priority)
|
|
572
|
+
2. Configuration file
|
|
573
|
+
3. Default values (lowest priority)
|
|
574
|
+
|
|
158
575
|
## Default Instructions
|
|
159
576
|
|
|
160
577
|
KodrDriv comes with default instructions that guide the AI in generating release notes or change logs. These instructions are defined in the source code:
|
|
@@ -338,10 +755,10 @@ Whether you're merging branches or writing books, kodrdriv is built for that end
|
|
|
338
755
|
|
|
339
756
|
### Release Command Options
|
|
340
757
|
|
|
341
|
-
- `--from <from>`: Branch or reference to generate release notes from
|
|
342
|
-
- `--to <to>`: Branch or reference to generate release notes to
|
|
758
|
+
- `--from <from>`: Branch or reference to generate release notes from (default: 'main')
|
|
759
|
+
- `--to <to>`: Branch or reference to generate release notes to (default: 'HEAD')
|
|
343
760
|
- `--context <context>`: Provide additional context (as a string or file path) to guide the release notes generation. This context is included in the prompt sent to the AI and can be used to specify the purpose, theme, or any special considerations for the release.
|
|
344
|
-
- `--message-limit <messageLimit>`: Limit the number of recent commit messages (from git log) to include in the release notes prompt (default: 10).
|
|
761
|
+
- `--message-limit <messageLimit>`: Limit the number of recent commit messages (from git log) to include in the release notes prompt (default: 10). Reducing this number can make the summary more focused, while increasing it provides broader historical context.
|
|
345
762
|
|
|
346
763
|
### Explanation
|
|
347
764
|
|