Skip to content

feat(spec): output KDL multiline strings for descriptions#639

Merged
jdx merged 1 commit into
jdx:mainfrom
gaojunran:feat/multiline-kdl-strings-new
May 17, 2026
Merged

feat(spec): output KDL multiline strings for descriptions#639
jdx merged 1 commit into
jdx:mainfrom
gaojunran:feat/multiline-kdl-strings-new

Conversation

@gaojunran
Copy link
Copy Markdown
Contributor

No description provided.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 17, 2026

Codecov Report

❌ Patch coverage is 5.49451% with 86 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.57%. Comparing base (cd0fd34) to head (3666a79).

Files with missing lines Patch % Lines
lib/src/spec/helpers.rs 13.15% 10 Missing and 23 partials ⚠️
lib/src/spec/cmd.rs 0.00% 10 Missing and 7 partials ⚠️
lib/src/spec/mod.rs 0.00% 12 Missing and 4 partials ⚠️
lib/src/spec/flag.rs 0.00% 2 Missing and 4 partials ⚠️
lib/src/spec/arg.rs 0.00% 1 Missing and 4 partials ⚠️
lib/src/spec/config.rs 0.00% 1 Missing and 4 partials ⚠️
lib/src/spec/complete.rs 0.00% 1 Missing and 2 partials ⚠️
lib/src/spec/mount.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #639      +/-   ##
==========================================
- Coverage   75.34%   73.57%   -1.77%     
==========================================
  Files          49       49              
  Lines        7389     7455      +66     
  Branches     7389     7455      +66     
==========================================
- Hits         5567     5485      -82     
- Misses       1217     1254      +37     
- Partials      605      716     +111     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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 introduces a string_entry helper function to centralize KDL string entry creation and automatically use multiline string syntax for values containing newlines. Various spec files and snapshot tests were updated to adopt this new formatting. Feedback indicates that the string_entry implementation should be hardened to handle cases where the input string contains triple-quote sequences, which would otherwise result in invalid KDL output.

Comment thread lib/src/spec/helpers.rs Outdated
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 17, 2026

Greptile Summary

This PR refactors the KDL serialization layer to emit raw multiline strings (#"""..."""#) for string values that contain newlines, replacing escaped single-line strings like "foo\nbar". A new string_entry helper in helpers.rs handles the format selection, and raw_multiline_hash_count computes the minimum number of # characters needed to safely embed any """ sequences present in the value.

  • lib/src/spec/helpers.rs: Introduces string_entry (public helper) and raw_multiline_hash_count (private); all other spec serialization files (arg.rs, cmd.rs, complete.rs, config.rs, flag.rs, mod.rs, mount.rs) are updated to call it uniformly.
  • Snapshot tests and cli/usage.usage.kdl are regenerated to reflect the new human-readable multiline output.
  • mise.lock has an unrelated comment URL change (mise.jdx.devmise.en.dev) that should be reverted.

Confidence Score: 5/5

Safe to merge after reverting the unrelated mise.lock URL change.

The multiline string logic in raw_multiline_hash_count is correct — it conservatively computes the minimum hash count by scanning every """ occurrence in the value, so it may emit more # chars than strictly necessary but can never produce a premature closing delimiter. The KDL repr format correctly round-trips through the KDL parser since the newlines adjacent to the delimiters are consumed by the format rules. All changed serialization call-sites are mechanical substitutions.

mise.lock — the docs URL in the auto-generated comment was changed from mise.jdx.dev to mise.en.dev and should be reverted.

Important Files Changed

Filename Overview
lib/src/spec/helpers.rs Adds string_entry and raw_multiline_hash_count — the core new helpers for emitting KDL raw multiline strings when a value contains newlines; logic is correct and handles embedded """ safely.
lib/src/spec/cmd.rs All KdlEntry::new/KdlEntry::new_prop calls replaced with string_entry; adds new cmd.deprecated serialization; KdlValue import removed as now unused.
lib/src/spec/flag.rs Switches all string entry construction to string_entry; no logic changes beyond repr selection.
lib/src/spec/mod.rs Top-level Spec serialization updated to use string_entry throughout; KdlValue import removed.
lib/src/spec/arg.rs All property entries use string_entry; single-value default path updated consistently.
lib/src/spec/complete.rs Complete run and type entries use string_entry; snapshot tests updated to reflect multiline repr for the run shell script.
cli/usage.usage.kdl Long-help strings throughout the CLI spec converted from escaped single-line strings to readable raw multiline format.
mise.lock Auto-generated lockfile comment URL changed from mise.jdx.dev to mise.en.dev — unrelated to this PR and likely an accidental side-effect of running a different mise build.

Reviews (4): Last reviewed commit: "feat(spec): output KDL multiline strings..." | Re-trigger Greptile

Comment thread lib/src/spec/helpers.rs Outdated
Comment thread lib/src/spec/cmd.rs
@gaojunran gaojunran force-pushed the feat/multiline-kdl-strings-new branch from b14e16c to d1a903a Compare May 17, 2026 13:20
@gaojunran gaojunran force-pushed the feat/multiline-kdl-strings-new branch from d1a903a to 3666a79 Compare May 17, 2026 13:30
@gaojunran
Copy link
Copy Markdown
Contributor Author

@greptileai

@gaojunran gaojunran marked this pull request as ready for review May 17, 2026 13:45
@jdx jdx merged commit 9797565 into jdx:main May 17, 2026
6 checks passed
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