summaryrefslogtreecommitdiff
path: root/plugins/code-modernization/hooks/text.ts
diff options
context:
space:
mode:
authorMorgan Lunt <morganl@anthropic.com>2026-09-24 20:52:27 -0700
committerMorgan Lunt <morganl@anthropic.com>2026-09-24 20:52:27 -0700
commit51b1ae9e20486d62b839ed9f37e1cfc7d55bf85c (patch)
treeeb31cc4964d84b4a82b8032452739fe1e9b37d3f /plugins/code-modernization/hooks/text.ts
parent5b8ec4b30f45b5e8b4c8a6efd63719730cf1a5ad (diff)
code-modernization: make the live pane work below 144 columns and show the proof
Found by exercising the pane against the real outputs of finished runs: - Below 144 columns the engine holds an unasked pane back; the pane ignored that, so it drew no pane, no show bar, and the panel command "hid" a pane that was never there. - A symlinked legacy/<name> lists as another kind of entry, so the source link that preflight now creates was never recognized as a system. - Uplift and reimagine next steps were placeholders with no button. - The refresh debounce was starved while agents ran, so the map froze. - Hostile lines in the brief, rules and baseline could take seconds to match; lines are now capped. The rule-review ledger is validated on read and merged on save, and keeps a reviewer's note. - A baseline with no row read as "the baseline had 0"; one-module baseline totals now count as that module's row. New: a verdict chip with words on every built module, a verify-first next step, and a readable palette that follows the terminal theme. 140 engine tests pass and the type check is clean.
Diffstat (limited to 'plugins/code-modernization/hooks/text.ts')
-rw-r--r--plugins/code-modernization/hooks/text.ts6
1 files changed, 6 insertions, 0 deletions
diff --git a/plugins/code-modernization/hooks/text.ts b/plugins/code-modernization/hooks/text.ts
index ecbf1bc5..f7c0cb38 100644
--- a/plugins/code-modernization/hooks/text.ts
+++ b/plugins/code-modernization/hooks/text.ts
@@ -35,3 +35,9 @@ const SYSTEM_NAME = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/
export const isToken = (value: string): boolean => TOKEN.test(value)
export const isSystemName = (value: string): boolean => SYSTEM_NAME.test(value)
+
+/** The longest line a reader looks at. A line of a table or a heading is a few hundred characters; a longer one is not a card, and a pattern run over a million characters of it is what a hostile file is for. */
+export const MAX_LINE = 4_000
+
+/** `text` as lines, each cut to what a reader looks at. */
+export const linesOf = (text: string): string[] => text.split('\n').map(line => (line.length > MAX_LINE ? line.slice(0, MAX_LINE) : line))