Skip to content

refactor(cli): print json and jsonl through Loom's views, and stop store export truncating control characters (MMR-595) - #516

Merged
dbtlr merged 3 commits into
mainfrom
chore/mmr-595
Oct 24, 2026
Merged

dbtlr merged 3 commits into
mainfrom
chore/mmr-595

Conversation

@dbtlr

@dbtlr dbtlr commented Oct 24, 2026

Copy link
Copy Markdown
Owner

The Loom CLI and mimir-host still serialized their own JSON: every command pre-stringified its document, and the CLI kept a copy of Loom's control escaping and media-type wrappers. That is a second way to do a job Loom 0.15's json() and jsonl() views already do.

Commands now give Loom data. Each view spec names the document's projection, whether it prints on one line, and whether jsonl repeats the document, prints it compact, or prints one line per row. Two narrow adapters keep the existing bytes. An empty row list still prints one empty line, and a document printed under both formats keeps each format's media type. The CLI's serializers and its C1 escaping are gone. The host admin commands (doctor, pairing, tokens) moved with it.

Review found a real problem here. store export - prints a raw transfer document rather than data, and Loom's style resolver strips DEL and C1 controls from raw view text. A CSI or control-string character also swallows the text after it, so a backup piped from a store with such a title came out truncated. The stream now prints through one document view that escapes those characters as \uXXXX. That restores the json/jsonl behavior and fixes records, ids, and table, which already truncated on main.

Validation:

  • bun run verify: 5,077 Bun tests and 1,069 UI tests pass, including the full parity harness.
  • bun run test:host: 7 pass.
  • New focused tests: render/views.test.ts covers media types, compact array documents, rows, the empty-list newline, and C1 escaping. commands/store.test.ts checks that a control-laden title survives store export - in all five formats.
  • Smoke from source on isolated throwaway stores: 34 read and 23 write/store invocations produce output byte-identical to main's Loom CLI. The only exception is the export stream's escaping, which is intended.

Two independent Opus reviews ran. Round 1 found the export truncation, which is fixed here. Round 2 found two wording issues, both fixed.

Implemented with Claude Opus 5.5 in the Claude Code harness.

dbtlr added 3 commits October 23, 2026 22:41
…MR-595)

Commands now hand Loom's json() and jsonl() a data projection instead
of pre-serialized text, so encoding and control escaping are Loom's and
the CLI's serializers and C1 escaping are gone. A view spec states the
document, whether it prints on one line, and whether jsonl repeats it,
prints it compact, or streams rows. Two narrow adapters keep the
established bytes: an empty row list still prints one empty line, and a
document printed under both formats keeps each format's media type.
The host admin CLI's views move with it.

store export - prints the transfer document exactly as a file holds it
under every format, as the released CLI does, instead of re-escaping C1
controls under json and jsonl.
…der every format (MMR-595)

Loom's style resolution drops DEL and C1 controls from view text, and a
CSI or control-string character swallows the text after it, so a raw
transfer document carrying one printed truncated. The stream now prints
through one document view that writes those characters as \uXXXX
escapes, which inside JSON strings parse to the same characters. This
restores the json and jsonl behavior and fixes records, ids, and table,
which already truncated.
@kody-ai

kody-ai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ✅

Access your configuration settings here.

​

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 146c47d2-0091-4c84-946b-a8aea0c173ac
Commits

Reviewing files that changed from the base of the PR and between a372c39 and ea84e08.

Files selected for processing: 27
  • .changes/mmr-595.md
  • packages/cli/src/commands/artifacts.ts
  • packages/cli/src/commands/bind.ts
  • packages/cli/src/commands/doctor.ts
  • packages/cli/src/commands/get.ts
  • packages/cli/src/commands/overview.ts
  • packages/cli/src/commands/pair.ts
  • packages/cli/src/commands/scratch.ts
  • packages/cli/src/commands/search.ts
  • packages/cli/src/commands/seeds.ts
  • packages/cli/src/commands/status.ts
  • packages/cli/src/commands/store.test.ts
  • packages/cli/src/commands/store.ts
  • packages/cli/src/commands/tree.ts
  • packages/cli/src/commands/update.ts
  • packages/cli/src/render/echo.ts
  • packages/cli/src/render/machine.ts
  • packages/cli/src/render/node-set.ts
  • packages/cli/src/render/scratch.ts
  • packages/cli/src/render/seeds.ts
  • packages/cli/src/render/views.test.ts
  • packages/cli/src/render/views.ts
  • packages/cli/src/render/writes.ts
  • packages/cli/src/testing/parity.ts
  • packages/host/src/admin/commands/doctor.ts
  • packages/host/src/admin/commands/pairing.ts
  • packages/host/src/admin/commands/tokens.ts

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

📝 Summary

Summary by CodeRabbit

  • Improvements
    • JSON and JSONL output across Loom CLI and mimir-host now uses consistent formatting while preserving existing output bytes, including one-line JSON documents and empty JSONL results.
    • store export - escapes DEL and C1 control characters in records, IDs, and table formats, while retaining the original characters in the exported document.
  • Tests
    • Added coverage for JSON and JSONL rendering, empty results, output formats, and control-character escaping.

The CLI and host now pass JSON data projections to Loom’s JSON and JSONL formatters instead of pre-serialized strings. store export - renders streamed documents through a control-escaping view. Tests cover formatting, empty JSONL output, media types, and DEL/C1 escaping.

Changes: CLI and host output rendering

Layer / File(s) Summary
Data-based JSON and JSONL view rendering
packages/cli/src/render/views.ts, packages/cli/src/render/machine.ts, packages/cli/src/render/views.test.ts
The view API accepts JSON data projections and supports indented or compact documents and JSONL rows. Document rendering escapes DEL and C1 controls. Tests cover formatting, media types, empty rows, and control escaping.
CLI command and renderer view updates
packages/cli/src/commands/*.ts, packages/cli/src/render/{echo,node-set,scratch,seeds,writes}.ts, packages/cli/src/testing/parity.ts
CLI commands and renderers return JSON objects or row projections to the shared view renderer. Their compact output settings and parity comparison use the updated view model.
Host administration view updates
packages/host/src/admin/commands/{doctor,pairing,tokens}.ts
Host doctor, pairing, and token views return data projections and select compact JSONL output through the shared view configuration.
Store export stream rendering
packages/cli/src/commands/store.ts, packages/cli/src/commands/store.test.ts, .changes/mmr-595.md
Store export separates streamed and file results. Streamed documents use the document view across formats. Tests check that DEL and C1 controls are escaped while the parsed title is retained.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Refactor

Merge Risk: Minimal · up to ea84e

The output changes appear ready to merge after normal checks; streamed exports retain their media types and the control-character behavior is covered by tests.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 57.69% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 26 functions across 26 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title names the main change: moving CLI and mimir-host JSON/JSONL output onto Loom's views (refactor(cli)). It also names the store export control-character fix (MMR-595). The change set includes …
Description check Passed The description explains the change. It covers the move from local JSON serializers to Loom's json() and jsonl() views, the view specs, the two adapters that keep existing output, and the store export…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: moving CLI and mimir-host JSON/JSONL output onto Loom's views (refactor(cli)). It also names the store export control-character fix (MMR-595). The change set includes both, so the title matches the changeset. The title is long at 119 characters, but it is specific and not vague.

Full details: Description check

Explanation

The description explains the change. It covers the move from local JSON serializers to Loom's json() and jsonl() views, the view specs, the two adapters that keep existing output, and the store export fix that escapes DEL and C1 controls. It also lists validation steps. It relates directly to the changeset.

Full details: Docstring Coverage

Explanation

Docstring coverage is 57.69% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 26 functions across 26 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

Comment thread packages/cli/src/testing/parity.ts
@dbtlr
dbtlr merged commit d9568b4 into main Oct 24, 2026
10 checks passed
@dbtlr
dbtlr deleted the chore/mmr-595 branch October 24, 2026 03:14
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.

1 participant