Skip to content

chore(figures): stop on unexpected tugime-cli output lines instead of skipping them - #163

Merged
miyaoka merged 6 commits into
mainfrom
chore/strict-cli-readers
Nov 15, 2026
Merged

miyaoka merged 6 commits into
mainfrom
chore/strict-cli-readers

Conversation

@miyaoka

@miyaoka miyaoka commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

目的

tugime-cli の出力の形式が変わったら、図のスクリプトが気づいて止まる状態にする。図のスクリプトは、変換エンジンのログが標準出力に混ざる前提で、結果の行に見えない行を黙って読み飛ばしていた。そのため、形式が変わって結果の行を読めなくなっても、図はそのまま作られていた。

あわせて、README の安全性の図のタイトルを、図の内容と食い違わない、使う人に通じる言葉にする。

出所: 対話での依頼(#160 のスコープ外「tugime-cli が変換エンジンのログを標準出力に混ぜないようにする」と、#161 のタイトルの指摘)。調べると、ログはもう標準出力に出ていなかった。

tugime-cli の出力に想定外の行が来たとき、変更前は黙って読み飛ばして図を作り、変更後はその行を示して止まる。読み飛ばしは azooKey の debug ログを避けるためのもので、azooKey はもう依存に無い

経緯

時期 出来事 出典
2026-10-26 読み飛ばしのコメントを「debug 版だけがログを混ぜる」に直した。ログの出どころは azooKey の debug() f696e0c
2026-10-26 21:27 変換を azooKey からシステム辞書の採点に切り替え、azooKey の依存を外した。これで読み飛ばしが要らなくなった 0a0c01b

変更内容

  • scripts/lib/svg.ts に、tugime-cli の標準出力を行に分ける outputLines を置いた。出力は改行で終わり、途中に空行を含まないことを確かめる。読み飛ばしてよい行(末尾の改行)の規則はここだけにある
  • 打鍵列ごとに 1 行の結果を出すオプション(--live・--whole)の出力を読む部品を、readLive から readPerInput(option, stdout, inputs) に改めた。呼び出し元は読むオプションを渡し、崩れた出力ではそのオプションの名前を示して止まる。返す値の名前も、表示に限らないので result にした
  • readPerInput・readExplains・readLattices と、scripts/make-pipeline.ts の readReading は outputLines で行に分け、結果の行として読めない行が来たら、その行を示して止まる
  • readLattices は、始まり・終わりが整数で、点が数の表記(-12.5、1e-05 の形)であることも確かめる
  • readExplains は区間の並びが空の行で止まり、parseSegments は区間の表記を残らず読めたか(読めた区間をつなぐと元の文字列に戻るか)を確かめる
  • ログの混入を前提にしたコメントと、CLI の出力形式を写したコメントを消した
  • 安全性の図(scripts/make-safety.ts、docs/images/safety.svg)のタイトルを「打った文字は外へ送らず残さない」にし、サブタイトルを消した。README の図の説明文(alt)の先頭も合わせた

安全性の図。タイトルは「打った文字は外へ送らず残さない」。入力欄と tugime の間を矢印が往復し、インターネットと保存・学習には ✕ が付く。下の帯はパスワード欄の扱い

設計判断

  • tugime-cli 側は変えない。今の tugime-cli は debug 版でもリリース版でも、標準出力に結果の行だけを出し、ログは標準エラーに出す(Package.swift の依存に azooKey は無く、ログを出すのは llama.cpp で、標準エラーに出る)
  • 安全性の図の前のタイトル「打った文字は、入力欄にしか届かない」は、打った文字が tugime にも届くことを描いた図の矢印と食い違っていた

合意事項

未合意の判断

なし

スコープ外

なし

完了条件

  • debug 版とリリース版の tugime-cli --live ok testgaotitanode の標準出力が、結果の 2 行だけである
  • bun scripts/make-pipeline.ts・bun scripts/make-readme-figures.ts・bun scripts/make-demo.ts・bun scripts/make-safety.ts・bun scripts/make-hero.ts・bun scripts/check-doc-examples.ts が終了コード 0 で終わり、その後の git status --short に差分が無い
  • 読み取りの部品が、正しい出力を読み、崩れた出力(改行で終わらない、途中の空行、結果でない行、読めない区間、数でない点)で止まる

検証

確認事項

  • GitHub 上で README を開き、安全性の図のタイトルが読めるか

🤖 Generated with Claude Code

@miyaoka miyaoka self-assigned this Nov 15, 2026
@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

標準出力が空でない場合に、末尾改行と空行の有無を検証する outputLines を追加しました。readLive、readExplains、readLattices は出力形式を検証し、不正な行を拒否します。parseSegments は入力全体が区間表記で構成されることを確認します。readReading は --clauses の実行結果を outputLines で検証し、文節形式に一致しない行を拒否します。

Merge Risk: Minimal · up to e0d5b

The change makes figure generation stop and show the offending line when tugime-cli output has an unexpected format, instead of silently skipping it. It only affects the build-time scripts, and no concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed タイトルは、変更の主要点を示している。tugime-cli の想定外の出力行を読み飛ばさず、停止するように変更した内容と一致する。タイトルは PR の目的、変更対象の scripts/lib/svg.ts の readLive・readExplains・readLattices、scripts/make-pipeline.ts の readReading と整合する。
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.
Description check Passed PR説明は変更内容と強く関連している。標準出力の行検証(outputLines、readPerInput、readExplains、readLattices、readReading)の目的、変更前後の挙動、安全性の図のタイトル変更、検証手順を具体的に記述している。raw_summary の内容とも一致する。
Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

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: Advanced
  • Run ID: db4bba2b-b1be-4b6b-8682-704c124a6612
Commits

Reviewing files that changed from the base of the PR and between 32edf14 and e0d5b87.

Files selected for processing: 2

  • scripts/lib/svg.ts
  • scripts/make-pipeline.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@tugime-bot

tugime-bot Bot commented Nov 15, 2026

Copy link
Copy Markdown

変換の精度(lattice)

集まり before after 問題数
ajimee 49.0% 49.0% 200
mozc-oss 74.5% 74.5% 310
mozc-regression 59.8% 59.8% 82

before だけ正解 0 件 / after だけ正解 0 件

片方だけが正解した問題
問題 正解した側 読み 入力の前の文脈 before after 判定

miyaoka and others added 3 commits November 15, 2026 16:58
… skipping them

learned(figures): tugime-cli no longer prints engine logs to stdout in debug or release builds; the logs came from azooKey's debug(), which is no longer a dependency
decision(figures): every non-empty stdout line must be a result line, so a change in the CLI output format stops the figure scripts instead of silently dropping lines

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd split lines in one place

decision(figures): one outputLines helper owns which lines may be skipped (only the trailing newline); the lattice numbers and every segment of --explain must parse, so a format change stops the scripts
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nt list in --explain

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@miyaoka
miyaoka force-pushed the chore/strict-cli-readers branch from d2e958c to e0d5b87 Compare November 15, 2026 07:59
miyaoka and others added 3 commits November 15, 2026 17:07
…t and drop its subtitle

decision(safety-figure): title it "打った文字は外へ送らず残さない"; the old title said typed text reaches only the input field, which the figure's own arrow to tugime contradicts
rejected(safety-figure): a subtitle saying conversion uses no server; Microsoft IME and Simeji send text only in opt-in features and the macOS and Google inputs do not, so it reads as if other inputs send text

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…malformed --whole output says --whole

decision(figures): readLive becomes readPerInput, which takes the option (--live or --whole) from every caller; check-doc-examples reads --whole with it too

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…the conversions rather than the display

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@miyaoka
miyaoka merged commit 75f28ee into main Nov 15, 2026
9 checks passed
@miyaoka
miyaoka deleted the chore/strict-cli-readers branch November 15, 2026 08:22
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