Skip to content

feat: add header comment to generated lockfiles#8481

Merged
jdx merged 4 commits intojdx:mainfrom
ivy:lockfile-header
Mar 6, 2026
Merged

feat: add header comment to generated lockfiles#8481
jdx merged 4 commits intojdx:mainfrom
ivy:lockfile-header

Conversation

@ivy
Copy link
Copy Markdown
Contributor

@ivy ivy commented Mar 6, 2026

Hey friend! 👋

My agents keep trying to update the mise lockfile by hand. It's ridiculous. I could settle for a line in AGENTS.md/CLAUDE.md but I figured, it'd help to put a headder in the lockfile that explains the obvious until the training data catches up.

It might also help with the confused humans too.

(Note: I didn't not wordsmith this.)

Example:

# This file is auto-generated by mise.
# It is not intended to be edited manually.
# mise docs: https://mise.jdx.dev/dev-tools/mise-lock.html
# mise CLI: `mise lock`

Adds a comment block at the top of mise.lock files instructing coding
agents and users not to edit them by hand, with a link to the docs and
the CLI command for managing lockfiles.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a clear, informative header comment to all mise generated lockfiles. This change aims to prevent unintended manual modifications by both automated agents and human users, by explicitly stating that the files are auto-generated and should not be edited. This improves the maintainability and reliability of mise projects by ensuring lockfiles are treated as machine-managed artifacts.

Highlights

  • Lockfile Header: A header comment was added to all generated mise lockfiles to explicitly state they are auto-generated and should not be manually edited.
  • Test Updates: End-to-end tests were updated to assert the presence of the new lockfile header in the generated files.
Changelog
  • e2e/assert.sh
    • Defined a new LOCKFILE_HEADER shell variable containing the multi-line comment text.
  • e2e/cli/test_use_latest
    • Modified assert "cat mise.lock" commands to include the $LOCKFILE_HEADER variable in the expected output.
  • e2e/lockfile/test_lockfile_use
    • Modified assert "cat mise.lock" commands to include the $LOCKFILE_HEADER variable in the expected output for various lockfile states.
  • src/lockfile.rs
    • Prepended a multi-line header comment to the lockfile content before it is written to disk within the save_to_file method.
Activity
  • The author, ivy, initiated this pull request to address issues where automated agents and humans were manually modifying mise lockfiles, which are intended to be auto-generated.
  • The author noted that the specific wording of the header comment was not extensively refined.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a header comment to generated lockfiles to discourage manual editing. The implementation in src/lockfile.rs correctly prepends the header. I've made one suggestion to improve the formatting of the header string to avoid unintended whitespace in the output file. The test files have been updated accordingly, which is great.

Comment on lines +319 to +326
let content = format!(
"# This file is auto-generated by mise.\n\
# It is not intended to be edited manually.\n\
# mise docs: https://mise.jdx.dev/dev-tools/mise-lock.html\n\
# mise CLI: `mise lock`\n\
\n\
{content}"
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current formatting of the header string will include leading whitespace from the source code indentation in the output file. This can be avoided by using a const for the header, which also improves readability and makes it easier to keep it in sync with the test files.

Suggested change
let content = format!(
"# This file is auto-generated by mise.\n\
# It is not intended to be edited manually.\n\
# mise docs: https://mise.jdx.dev/dev-tools/mise-lock.html\n\
# mise CLI: `mise lock`\n\
\n\
{content}"
);
const LOCKFILE_HEADER: &str = "# This file is auto-generated by mise.\n# It is not intended to be edited manually.\n# mise docs: https://mise.jdx.dev/dev-tools/mise-lock.html\n# mise CLI: `mise lock`";
let content = format!("{LOCKFILE_HEADER}\n\n{content}");

Copy link
Copy Markdown
Contributor Author

@ivy ivy Mar 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad robot! I verified locally.

───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: mise.lock
───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1 + │ # This file is auto-generated by mise.
   2 + │ # It is not intended to be edited manually.
   3 + │ # mise docs: https://mise.jdx.dev/dev-tools/mise-lock.html
   4 + │ # mise CLI: `mise lock`

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 6, 2026

Greptile Summary

This PR prepends a 4-line comment block to every generated mise.lock file explaining that it is auto-generated and should not be edited manually, targeting both AI agents and human contributors who might otherwise modify it by hand.

Key changes:

  • src/lockfile.rs — After TOML serialization and formatting, the save() function prepends the header string via format!() before the atomic write. Placement after format() is intentional and correct: the toml_edit-based formatter would not strip top-level comments, but inserting before ensures the comment always leads the file regardless of TOML tooling.
  • e2e/assert.sh — A shared LOCKFILE_HEADER variable is defined once and reused across all test scripts (sourced before every test by run_test).
  • e2e/cli/test_use_latest and e2e/lockfile/test_lockfile_use — All 7 exact-match (assert "cat mise.lock") assertions are updated. The remaining tests in the broader e2e suite (which use assert_contains / assert_not_contains) require no changes.
  • Backward-compatible: TOML's native #-comment support means Lockfile::read() parses files with or without the header without any code changes. Existing lockfiles without a header will acquire it on the next mise use or mise lock run.

Confidence Score: 5/5

  • This PR is safe to merge — the change is purely additive, backward-compatible, and well-tested.
  • The implementation is straightforward: a fixed string is prepended to the file content before writing, after all TOML processing is complete. TOML's native comment syntax means the parser requires zero changes. All exact-match e2e tests were correctly updated, and every other lockfile test in the suite uses substring matching which is unaffected by the new header. No logic paths, error handling, or public APIs are altered.
  • No files require special attention.

Sequence Diagram

sequenceDiagram
    participant User as User / Agent
    participant CLI as mise CLI
    participant Lockfile as Lockfile::save()
    participant FS as mise.lock (file)

    User->>CLI: mise use / mise lock
    CLI->>Lockfile: save(path)
    Lockfile->>Lockfile: Build TOML table (tools, conda-packages)
    Lockfile->>Lockfile: toml::to_string_pretty()
    Lockfile->>Lockfile: format() — sort keys, inline platform tables
    Lockfile->>Lockfile: Prepend header comment block
    Note over Lockfile: "# This file is auto-generated by mise.\n# It is not intended to be edited manually.\n..."
    Lockfile->>FS: Atomic write (temp file → rename)

    User->>CLI: mise install / mise ls
    CLI->>Lockfile: Lockfile::read(path)
    Lockfile->>FS: Read file contents
    FS-->>Lockfile: content (with header comments)
    Lockfile->>Lockfile: toml::from_str() — TOML ignores # comments natively
    Lockfile-->>CLI: Parsed Lockfile struct
Loading

Last reviewed commit: d2cf116

@ivy
Copy link
Copy Markdown
Contributor Author

ivy commented Mar 6, 2026

Okay, I didn't shellcheck. You caught me. (One sec.)

ivy and others added 2 commits March 6, 2026 06:03
@jdx
Copy link
Copy Markdown
Owner

jdx commented Mar 6, 2026

Suggestion: simplify the header to a single line with @generated (which GitHub and AI agents recognize as machine-generated):

# @generated - this file is auto-generated by `mise lock` https://mise.jdx.dev/dev-tools/mise-lock.html

This comment was generated by Claude Code.

Replaces the four-line verbose header with a concise `@generated` style
comment, consistent with standard tooling conventions.
@jdx jdx enabled auto-merge (squash) March 6, 2026 20:03
@ivy
Copy link
Copy Markdown
Contributor Author

ivy commented Mar 6, 2026

Oh, interesting! There might be some other cool GitHub stuff we can do with linguist to improve how these lockfiles are rendered in the repo web UI: https://github.com/github-linguist/linguist/blob/d403bc76daf1d83d97f7ee40cd64957cadc33706/lib/linguist/generated.rb#L53-L59

@jdx jdx merged commit 38abb82 into jdx:main Mar 6, 2026
47 of 49 checks passed
mise-en-dev added a commit that referenced this pull request Mar 7, 2026
### 🚀 Features

- **(github)** keep exe extensions on Windows by @iki in
[#8424](#8424)
- **(task)** add `interactive` field for exclusive terminal access by
@jdx in [#8491](#8491)
- add header comment to generated lockfiles by @ivy in
[#8481](#8481)
- runtime musl/glibc detection for correct libc variant selection by
@jdx in [#8490](#8490)

### 🐛 Bug Fixes

- **(github)** use registry platform options during install by @jdx in
[#8492](#8492)
- **(http)** store tool opts as native TOML to fix platform switching by
@jdx in [#8448](#8448)
- **(installer)** error if MISE_INSTALL_PATH is a directory by @jdx in
[#8468](#8468)
- **(prepare)** resolve sources/outputs relative to `dir` when set by
@jdx in [#8472](#8472)
- **(ruby)** fetch precompiled binary by release tag instead of listing
all releases by @jdx in [#8488](#8488)
- **(schema)** support structured objects in task depends by @risu729 in
[#8463](#8463)
- **(task)** replace println!/eprintln! with calm_io in task output
macros by @vmaleze in [#8485](#8485)
- handle scoped npm package names without backend prefix by @jdx in
[#8477](#8477)

### 📦️ Dependency Updates

- update ghcr.io/jdx/mise:copr docker digest to c485c4c by
@renovate[bot] in [#8484](#8484)
- update ghcr.io/jdx/mise:alpine docker digest to 8118bc7 by
@renovate[bot] in [#8483](#8483)

### 📦 Registry

- disable sd version test by @jdx in
[#8489](#8489)

### New Contributors

- @ivy made their first contribution in
[#8481](#8481)
- @iki made their first contribution in
[#8424](#8424)

## 📦 Aqua Registry Updates

#### New Packages (5)

- [`datadog-labs/pup`](https://github.com/datadog-labs/pup)
- [`k1LoW/mo`](https://github.com/k1LoW/mo)
- [`rtk-ai/rtk`](https://github.com/rtk-ai/rtk)
-
[`suzuki-shunsuke/docfresh`](https://github.com/suzuki-shunsuke/docfresh)
- [`yashikota/exiftool-go`](https://github.com/yashikota/exiftool-go)

#### Updated Packages (6)

- [`cloudflare/cloudflared`](https://github.com/cloudflare/cloudflared)
- [`mozilla/sccache`](https://github.com/mozilla/sccache)
- [`owenlamont/ryl`](https://github.com/owenlamont/ryl)
- [`spinel-coop/rv`](https://github.com/spinel-coop/rv)
-
[`technicalpickles/envsense`](https://github.com/technicalpickles/envsense)
- [`weaviate/weaviate`](https://github.com/weaviate/weaviate)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants