Skip to content

feat(tera): add haiku() function for random name generation#7399

Merged
jdx merged 3 commits intomainfrom
feat/tera-random-name
Dec 18, 2025
Merged

feat(tera): add haiku() function for random name generation#7399
jdx merged 3 commits intomainfrom
feat/tera-random-name

Conversation

@jdx
Copy link
Owner

@jdx jdx commented Dec 18, 2025

Summary

Adds a new Tera template function haiku() that generates random names like silent-forest-42.

Options:

Parameter Default Description
words 2 Number of words
separator - String between parts
number true Include trailing number
number_max 99 Maximum number value

Examples:

{{ haiku() }}                              -> "ancient-moon-73"
{{ haiku(words=3) }}                       -> "cold-river-wild-15"
{{ haiku(number=false) }}                  -> "hidden-butterfly"
{{ haiku(separator="_", number_max=999) }} -> "misty_dawn_847"

Use cases:

  • Unique session IDs
  • Temporary file/directory names
  • Test data generation
  • Human-readable identifiers

Word lists inspired by https://github.com/nishanths/rust-haikunator

🤖 Generated with Claude Code


Note

Introduce haiku() Tera function for human-readable random names with tests; update key dependencies (e.g., xx 2.3.0, zip 6.0.0) and allow CC0-1.0 license.

  • Tera:
    • Add haiku() function with options words, separator, and digits using xx::rand::haiku.
  • Tests:
    • Add test_haiku covering defaults and custom options.
  • Dependencies:
    • Bump xx to 2.3.0; update zip to 6.0.0 (adds ppmd-rust, lzma-rust2 0.13.0, etc.).
    • Align various transitive versions (e.g., windows-sys downgrades across crates, base64 for oauth2).
  • Licenses/Policy:
    • Add CC0-1.0 to deny.toml allowed licenses.

Written by Cursor Bugbot for commit 4a62b3e. This will update automatically on new commits. Configure here.

Copilot AI review requested due to automatic review settings December 18, 2025 22:10
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a new random_name() Tera template function that generates random, human-readable identifiers in the format adjective-noun-number (e.g., flying-rabbit-23). This is useful for creating unique session IDs, temporary names, or test data.

Key Changes:

  • Implements random_name() function with 64 adjectives and 64 nouns, generating numbers from 1-99
  • Adds test coverage verifying the output format (3 dash-separated parts with parseable number)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

src/tera.rs Outdated
"water",
"wildflower",
"wave",
"water",
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

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

Duplicate entry: 'water' appears twice in the NOUNS array (lines 214 and 217). Remove one occurrence to maintain the claimed count of 64 unique nouns.

Copilot uses AI. Check for mistakes.
src/tera.rs Outdated
"wave",
"water",
"resonance",
"sun",
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

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

Duplicate entry: 'sun' appears twice in the NOUNS array (lines 187 and 219). Remove one occurrence to maintain the claimed count of 64 unique nouns.

Copilot uses AI. Check for mistakes.
src/tera.rs Outdated
Comment on lines +238 to +240
let mut rng = rand::rng();
let adj = ADJECTIVES.choose(&mut rng).unwrap();
let noun = NOUNS.choose(&mut rng).unwrap();
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

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

The ADJECTIVES and NOUNS arrays are recreated on every function call. Consider moving these const arrays outside the closure to avoid repeated allocations and improve performance when this function is called frequently.

Copilot uses AI. Check for mistakes.
src/tera.rs Outdated
let mut rng = rand::rng();
let adj = ADJECTIVES.choose(&mut rng).unwrap();
let noun = NOUNS.choose(&mut rng).unwrap();
let num: u32 = rng.random_range(1..100);
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

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

The range 1..100 generates numbers from 1-99, but the PR description claims this gives ~400k unique combinations. With the current implementation: 64 adjectives × 64 nouns × 99 numbers = ~406k combinations. However, due to the duplicate entries in NOUNS, the actual count is lower. Update either the word lists or the documentation to be accurate.

Copilot uses AI. Check for mistakes.
@jdx jdx force-pushed the feat/tera-random-name branch from eafcc04 to 752ec9b Compare December 18, 2025 22:12
@jdx jdx changed the title feat(tera): add random_name() function feat(tera): add haiku() function for random name generation Dec 18, 2025
@github-actions
Copy link

github-actions bot commented Dec 18, 2025

Hyperfine Performance

mise x -- echo

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.12.12 x -- echo 15.8 ± 0.5 14.8 19.6 1.00
mise x -- echo 16.3 ± 0.5 15.2 17.8 1.04 ± 0.04

mise env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.12.12 env 15.3 ± 0.3 14.3 16.8 1.00
mise env 15.9 ± 0.6 14.8 20.6 1.04 ± 0.04

mise hook-env

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.12.12 hook-env 15.7 ± 0.5 14.7 20.4 1.00
mise hook-env 16.1 ± 0.4 15.0 17.4 1.02 ± 0.04

mise ls

Command Mean [ms] Min [ms] Max [ms] Relative
mise-2025.12.12 ls 14.3 ± 0.4 13.4 15.7 1.00
mise ls 14.8 ± 0.4 13.7 16.3 1.04 ± 0.04

xtasks/test/perf

Command mise-2025.12.12 mise Variance
install (cached) 82ms 82ms +0%
ls (cached) 54ms 54ms +0%
bin-paths (cached) 57ms 57ms +0%
task-ls (cached) 228ms 230ms +0%

jdx and others added 3 commits December 18, 2025 17:31
Generates random names like "silent-forest-42". Configurable options:
- words: number of words (default 2)
- separator: string between parts (default "-")
- number: include trailing number (default true)
- number_max: max number value (default 99)

Examples:
  {{ haiku() }}                              -> "ancient-moon-73"
  {{ haiku(words=3) }}                       -> "cold-river-wild-15"
  {{ haiku(number=false) }}                  -> "hidden-butterfly"
  {{ haiku(separator="_", number_max=999) }} -> "misty_dawn_847"

Word lists inspired by https://github.com/nishanths/rust-haikunator

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Update to xx 2.3.0 which includes the haiku module
- Replace inline word lists and logic with xx::rand::haiku
- Change API from number/number_max to digits parameter

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@jdx jdx force-pushed the feat/tera-random-name branch from f2d3b31 to 4a62b3e Compare December 18, 2025 23:31
@jdx jdx merged commit d4d2c92 into main Dec 18, 2025
30 checks passed
@jdx jdx deleted the feat/tera-random-name branch December 18, 2025 23:49
jekis913 added a commit to jekis913/mise that referenced this pull request Dec 19, 2025
* upstream/renovate/lockfile-maintenance:
  chore(deps): lock file maintenance
  fix(ci): improve GHA cache efficiency and fix registry-ci bug (jdx#7404)
  feat(tera): add haiku() function for random name generation (jdx#7399)
  feat: implement independent versioning for subcrates (jdx#7402)
  docs: add comprehensive glossary (jdx#7401)
  docs: improve installation documentation (jdx#7403)
  test: add token pool integration for rate limit distribution (jdx#7397)
  docs: add link to COPR package page for Fedora/RHEL
  test: rename duplicate 'ci' job names for clarity (jdx#7398)
  registry: add github backend for swiftformat (jdx#7396)
  chore: rename mise-tools to mise-versions
  chore: release 2025.12.12 (jdx#7386)
  fix(github): use version_prefix when fetching release for SLSA verification (jdx#7391)
  refactor(vfox): remove submodules, embed plugins directly (jdx#7389)
  test(registry): add final ci job as merge gate (jdx#7390)
  test: split unit job to speed up macOS CI (jdx#7388)
  feat(backend): add security features to github backend (jdx#7387)
jdx pushed a commit that referenced this pull request Dec 19, 2025
### 🚀 Features

- **(tera)** add haiku() function for random name generation by @jdx in
[#7399](#7399)
- implement independent versioning for subcrates by @jdx in
[#7402](#7402)

### 🐛 Bug Fixes

- **(ci)** improve GHA cache efficiency and fix registry-ci bug by @jdx
in [#7404](#7404)
- **(ci)** use !cancelled() instead of always() for registry-ci by @jdx
in [#7435](#7435)
- **(test)** update backend_arg test to use clojure instead of poetry by
@jdx in [#7436](#7436)

### 📚 Documentation

- add link to COPR package page for Fedora/RHEL by @jdx in
[bc8ac73](bc8ac73)
- improve installation documentation by @jdx in
[#7403](#7403)
- add comprehensive glossary by @jdx in
[#7401](#7401)

### 🧪 Testing

- rename duplicate 'ci' job names for clarity by @jdx in
[#7398](#7398)
- add token pool integration for rate limit distribution by @jdx in
[#7397](#7397)

### 📦 Registry

- add github backend for swiftformat by @jdx in
[#7396](#7396)
- use pipx backend for azure-cli by @jdx in
[#7406](#7406)
- use pipx backend for dvc by @jdx in
[#7413](#7413)
- add github backend for zprint by @jdx in
[#7410](#7410)
- use gem backend for cocoapods by @jdx in
[#7411](#7411)
- use pipx backend for gallery-dl by @jdx in
[#7409](#7409)
- add aqua backends for HashiCorp tools by @jdx in
[#7408](#7408)
- use npm backend for danger-js by @jdx in
[#7407](#7407)
- use pipx backend for pipenv by @jdx in
[#7415](#7415)
- use pipx backend for poetry by @jdx in
[#7416](#7416)
- add github backend for xcodegen
([github:yonaskolb/XcodeGen](https://github.com/yonaskolb/XcodeGen)) by
@jdx in [#7417](#7417)
- use npm backend for heroku by @jdx in
[#7418](#7418)
- add aqua backend for setup-envtest by @jdx in
[#7421](#7421)
- add github backend for xcresultparser
([github:a7ex/xcresultparser](https://github.com/a7ex/xcresultparser))
by @jdx in [#7422](#7422)
- add aqua backend for tomcat by @jdx in
[#7423](#7423)
- use npm backend for serverless by @jdx in
[#7424](#7424)
- add github backend for daytona
([github:daytonaio/daytona](https://github.com/daytonaio/daytona)) by
@jdx in [#7412](#7412)
- add github backend for flyway
([github:flyway/flyway](https://github.com/flyway/flyway)) by @jdx in
[#7414](#7414)
- add github backend for schemacrawler
([github:schemacrawler/SchemaCrawler](https://github.com/schemacrawler/SchemaCrawler))
by @jdx in [#7419](#7419)
- add github backend for codeql by @jdx in
[#7420](#7420)
- use pipx backend for mitmproxy by @jdx in
[#7425](#7425)
- use pipx backend for sshuttle by @jdx in
[#7426](#7426)
- add github backend for quarkus by @jdx in
[#7428](#7428)
- add github backend for smithy by @jdx in
[#7430](#7430)
- add github backend for xchtmlreport
([github:XCTestHTMLReport/XCTestHTMLReport](https://github.com/XCTestHTMLReport/XCTestHTMLReport))
by @jdx in [#7431](#7431)
- add github backend for grails by @jdx in
[#7429](#7429)
- use npm backend for esy by @jdx in
[#7434](#7434)
- add github backend for micronaut by @jdx in
[#7433](#7433)
- add github backend for dome by @jdx in
[#7432](#7432)
- use vfox backend for poetry by @jdx in
[#7438](#7438)

### Chore

- **(docker)** add Node LTS to mise Docker image by @jdx in
[#7405](#7405)
- rename mise-tools to mise-versions by @jdx in
[ab3e1b8](ab3e1b8)
- s/mise task/mise tasks/g in docs and tests by @muzimuzhi in
[#7400](#7400)

### New Contributors

- @muzimuzhi made their first contribution in
[#7400](#7400)
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