Text Chunker 引き継ぎ — v4.2-final → v4.3-final
v4.2-final から 7-L2 / 7-M / 7-N / 7-P / 7-P-fix / 7-Q を経た最終状態。単一配列モデル、pinChunk 統合、trim 変更、emoji swap、commit→snapshot rename + schemaVersion 3 migration を反映。
Text Chunker 引き継ぎ — v4.2-final → v4.3-final
0. 一行サマリ
v4.2-final に 7 バッチ(7-L2 / 7-M / 7-N / 7-P / 7-P-fix / 7-Q / 7-Q2)を追加適用。 単一配列モデル(app.autos 廃止)、pinChunk 統合、末尾改行 trim 変更、emoji swap、commit* → snapshot* 識別子 rename(schemaVersion 3 migration 付き)を達成。bundle / verify / audit 全て通過。
1. 到達点
1.1 検証済み状態
| 項目 | 状態 |
|---|---|
bundle.mjs | ✓ bundled 5 css + 18 js |
verify.mjs | ✓ All files match (23 files) |
audit-imports.mjs | ✓ Total remaining issues: 0 |
| 循環依存 | ✓ 0 件 |
app.autos | ✓ 完全撤去 |
内部識別子 commit* | ✓ snapshot* へ rename 済み |
schemaVersion | ✓ 3 |
1.2 ファイル構成(v4.3-final)
public/tools/text-chunker/├── index.html├── manifest.json├── package.json├── scripts/html-build/ ← ツール│ ├── _shared.mjs│ ├── bundle.mjs│ ├── split.mjs│ ├── verify.mjs│ ├── audit-imports.mjs│ ├── rename-identifiers.mjs ← 7-Q 用(適用済)│ └── rename-maps/│ └── commit-to-snapshot.json├── styles/ (5 css)├── js/ (18 js)└── bundle/index.html2. バッチサマリ(v4.2-final 以降)
Batch 7-L2: Row 2/3 レイアウト再構成 + Merge メニュー
変更ファイル:
index.html— Row 2(chunkStatus / pin / ✓ / ⋮)、Row 3(◀▶⇣ / 📋 / [Text|Diff] / 🔍)js/130-tree.js—Merge with next chunk/Merge with next master text…追加js/140-workflow.js— pin ボタン状態更新js/170-wireui.js—pin-toggle/jump-chunk-endACTIONstyles/20-components.css/styles/40-theme-light.css—.pinBtnスタイル
Batch 7-M: 長さ表示一貫性 + ゼロ長可視化
変更ファイル:
js/70-compose.js—contentTextOf/composeOutputの trim を\n+$→\n$js/90-editor.js—ChunkLabelMarkerにarr常時渡し(同一行 chunk 番号クリックを常時有効)js/130-tree.js— badge 計算をcontentTextOfベースにjs/140-workflow.js—updateEditorTopに診断 tooltipstyles/20-components.css—.badge.unpinned/.pinBtn色統一styles/30-editor.css—.cm-zero-len-markermin-heightstyles/40-theme-light.css— ライト版
Batch 7-N: pinChunk 統合
pinChunk(c, opts)にopts.silent追加openNotesDialogからsvc.pinChunk(c, { silent: true })で呼ぶpinChunkLocal削除
変更ファイル:
js/120-crud.js—pinChunk(c, opts)js/140-workflow.js—pinChunkLocal削除js/180-boot.js—svc.pinChunkpopulate
Batch 7-P: 単一配列モデル
設計:
app.chunksに persisted(id != null)と ephemeral(id == null)を混在app.autos削除- 新規 helper:
isPersisted(c)/isEphemeral(c)/persistedChunks()/ephemeralChunks() recomputeAutoChunks(mode)全面書き換え
変更ファイル(7 ファイル):
js/60-model.jsjs/80-split.jsjs/90-editor.jsjs/120-crud.jsjs/130-tree.jsjs/140-workflow.jsjs/160-dialogs.js
Batch 7-P-fix: pin / unpinned emoji swap
変更ファイル:
js/140-workflow.js—updateEditorTopの pin ボタン emoji(3 箇所)pinned→ 📍unpinned→ 📌
Batch 7-Q: commit* → snapshot* rename(スクリプト)
作成したツール:
scripts/html-build/rename-identifiers.mjs— 汎用 rename ツール(_shared.mjs統合、--project/--map/--dry/--apply/--show対応)scripts/html-build/rename-maps/commit-to-snapshot.json— 11 ペアのマップ
適用した rename(11 識別子):
| 旧 | 新 |
|---|---|
commitVersion | snapshotVersion |
commitText | snapshotText |
commitAt | snapshotAt |
commitAutoPin | snapshotAutoPin |
commitChunk | snapshotChunk |
commitOnly | snapshotOnly |
copyAndCommit | copyAndSnapshot |
copyAndCommitChunk | copyAndSnapshotChunk |
undoLastCommit | undoLastSnapshot |
commitBtn(DOM id) | snapshotBtn |
commit-only(data-act) | snapshot-only |
変更ファイル: 10 ファイル(js 8 / css 1 / html 1)
Batch 7-Q2: schemaVersion 3 への移行(手作業)
変更ファイル 3 つ:
-
js/60-model.js:defaultSettings().schemaVersion: 2 → 3migrateChunkに v2 → v3 フィールド移行追加(// rename:skipで囲む)
-
js/110-ui.js:loadSettingsに v2 → v3 settings migration 追加(// rename:skipで囲む)
-
js/160-dialogs.js:exportJSONのschemaVersion: 2 → 3importJSONWithModeの許容バージョン[1, 2] → [1, 2, 3]
migration の冪等性: rename:skip マーカーで保護されているため、rename-identifiers.mjs を再実行しても migration コードは破壊されない。
3. 主要な設計判断
3.1 単一配列モデル(7-P)
根拠:
app.chunks/app.autosの同期漏れバグが頻発chunkKeyが文脈依存- 新操作追加時に両配列を意識する負担
トレードオフ: 配列内で id == null 判定が必要、Store 境界で明示的 filter。
3.2 pinChunk 統合(7-N)
opts.silent で挙動切替。svc 経由で openNotesDialog から呼ぶ。
3.3 trim を \n+$ → \n$(7-M)
段落末尾の空行(\n\n)を保持。EOF の \n 1 つだけを separator として扱う。
3.4 emoji swap(7-P-fix)
- 📍 = location marker(置いてある)→ pinned
- 📌 = pushpin(刺さっている)→ unpinned
3.5 commit* → snapshot* rename(7-Q)
設計判断:
- 識別子 rename は機械的スクリプトで実施(
rename-identifiers.mjs) - 永続化 migration は手作業(
migrateChunk/loadSettings) - migration コードは
// rename:skip-begin~// rename:skip-endで保護 - スキーマバージョンを 2 → 3 に更新
- 既存 v2 データは on-read 変換(非破壊)
冪等性:
- rename script は 2 回実行しても no-op
- migration は
schemaVersion < 3判定で 1 回のみ実行 - 旧フィールドは変換後
deleteされ、次回以降は新フィールドのみ
4. ファイル適用マトリクス
v4.2-final + 7-L2 + 7-M + 7-N + 7-P + 7-P-fix + 7-Q + 7-Q2 を全て適用した状態 = v4.3-final:
| # | ファイル | 最終バッチ | 変更概要 |
|---|---|---|---|
| 1 | index.html | 7-L2 + 7-Q | Row 2/3 再構成、snapshotBtn |
| 2 | js/00-main.js | v4.2 | 変更なし |
| 3 | js/10-utils.js | v4.2 | 変更なし |
| 4 | js/20-count.js | v4.2 | 変更なし |
| 5 | js/30-safe-pos.js | v4.2 | 変更なし |
| 6 | js/40-candidates.js | v4.2 | 変更なし |
| 7 | js/50-storage.js | v4.2 | 変更なし |
| 8 | js/60-model.js | 7-P + 7-Q + 7-Q2 | 単一配列、snapshot*、schemaVersion 3 |
| 9 | js/70-compose.js | 7-M + 7-Q | trim \n$、snapshotText |
| 10 | js/80-split.js | 7-P + 7-Q | recomputeAutoChunks 書換、snapshot* |
| 11 | js/90-editor.js | 7-P + 7-Q | 単一配列参照、snapshot* |
| 12 | js/110-ui.js | 7-Q + 7-Q2 | settings migration v2→v3、snapshotAutoPin |
| 13 | js/120-crud.js | 7-P + 7-Q | 全操作を単一配列に、snapshot* |
| 14 | js/130-tree.js | 7-P + 7-Q | app.autos マージ削除、snapshot* |
| 15 | js/140-workflow.js | 7-P-fix + 7-Q | emoji swap、snapshot* |
| 16 | js/150-checkpoint.js | v4.2 + 7-Q | 変更なし(commit* 未使用)+ rename |
| 17 | js/160-dialogs.js | 7-P + 7-Q + 7-Q2 | breakdown 単一配列、schemaVersion 3 |
| 18 | js/170-wireui.js | 7-L2 + 7-Q | pin-toggle / jump-chunk-end、snapshot-only |
| 19 | js/180-boot.js | 7-N + 7-Q | svc.pinChunk populate、snapshot* |
| 20 | styles/00-base.css | v4.2 | 変更なし |
| 21 | styles/10-layout.css | v4.2 | 変更なし |
| 22 | styles/20-components.css | 7-M + 7-Q | .badge.unpinned / .pinBtn、#snapshotBtn |
| 23 | styles/30-editor.css | 7-M | zero-len min-height |
| 24 | styles/40-theme-light.css | 7-M + 7-Q | ライト版、#snapshotBtn |
5. 検証手順
node scripts/html-build/bundle.mjs --project text-chunkernode scripts/html-build/verify.mjs --project text-chunkernode scripts/html-build/audit-imports.mjs --project text-chunker期待結果:
✓ bundled 5 css + 18 js✓ All files match (23 files)Total remaining issues: 0
migration 検証:
| テスト | 期待 |
|---|---|
旧 v2 データ(commitVersion)で起動 | 正常動作、内部で snapshotVersion に変換 |
新 v3 データ(snapshotVersion)で起動 | 無変換で動作 |
| 旧データを新コードで保存 → 再読込 | snapshotVersion で永続化 |
| v2 JSON を import | mapImportedChunk 経由で成功 |
| v3 JSON を export | schemaVersion: 3 で出力 |
| v3 JSON を再 import | そのまま読める |
6. 既知の制約
| # | 内容 | 影響 |
|---|---|---|
| 1 | chunkKey の unpinned@<offset> 位置依存 | 稀に誤選択 |
| 2 | mergeWithNextDocument の seq 再採番がセッション依存 | single-tab lock 下では実害なし |
| 3 | #diffView 高さ 40% 固定 | 実機調整の余地 |
| 4 | app.ui.historyExpanded デッドステート | v4.4 で削除予定 |
| 5 | #detailPanel 関連 CSS 残存 | v4.4 で削除予定 |
7. 次のバッチ(推奨順)
| 名前 | 内容 | 優先度 |
|---|---|---|
| 8-A | app.ui.historyExpanded / #detailPanel 削除 | 中 |
| 8-B | chunkKey の ephemeral キー再設計 | 中 |
| 8-C | #diffView 高さ可変化 | 低 |
| 8-D | 自動テストフレームワーク導入(node --test) | 中 |
| 8-E | svc レジストリの必要性見直し | 低 |
8. 参照
- v4.3-final 仕様書: 2026-09-30-text-chunker-spec-v4.3-final
- v4.2-final 仕様書: 2026-09-29-text-chunker-spec-v4.2-final
- v4.2-final 引き継ぎ: 2026-09-29-text-chunker-handover-v4.2-final
- directive: 260929_directive