summaryrefslogtreecommitdiff
path: root/plugins/code-modernization/hooks/reader/rules.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/reader/rules.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/reader/rules.ts')
-rw-r--r--plugins/code-modernization/hooks/reader/rules.ts11
1 files changed, 6 insertions, 5 deletions
diff --git a/plugins/code-modernization/hooks/reader/rules.ts b/plugins/code-modernization/hooks/reader/rules.ts
index dec397fd..080edab8 100644
--- a/plugins/code-modernization/hooks/reader/rules.ts
+++ b/plugins/code-modernization/hooks/reader/rules.ts
@@ -1,4 +1,5 @@
import { baseName } from '../paths'
+import { linesOf } from '../text'
/**
* `analysis/<system>/BUSINESS_RULES.md`, read into rule cards.
@@ -112,7 +113,7 @@ const priorityOf = (id: string, body: string): string => {
}
// `P0` · Calculation · confidence High · `app/cbl/A.cbl:10-20`
- const header = body.split('\n').find(line => line.trim() !== '') ?? ''
+ const header = linesOf(body).find(line => line.trim() !== '') ?? ''
return /^\s*`?\**(P\d)\**`?\s*(?:·|$)/.exec(header)?.[1] ?? ''
}
@@ -132,7 +133,7 @@ const gwtOf = (body: string, word: string): string | undefined => {
}
const markedOf = (body: string, marker: RegExp): string | undefined => {
- for (const line of body.split('\n')) {
+ for (const line of linesOf(body)) {
if (marker.test(line)) {
const text = clean(line.replace(/^>\s*/, '').replace(marker, ''))
.replace(/^[—–-]\s*/, '')
@@ -162,7 +163,7 @@ const specOf = (body: string): { given?: string; when?: string; then?: string }
const clauses: Record<'given' | 'when' | 'then', string[]> = { given: [], when: [], then: [] }
let current: 'given' | 'when' | 'then' | undefined
- for (const raw of block.split('\n')) {
+ for (const raw of linesOf(block)) {
const line = raw.trim().replace(/^```\w*$/, '').replace(/^[-*]\s+/, '')
const match = /^(Given|When|Then|And)\s+(.*)$/.exec(line)
@@ -196,7 +197,7 @@ function cardOf(
body: string,
domain: string | undefined,
): Rule {
- const lines = body.split('\n')
+ const lines = linesOf(body)
const header = lines.find(line => line.trim() !== '') ?? ''
const headerParts = header.split('·').map(part => clean(part))
@@ -337,7 +338,7 @@ function rowOf(
/** Parses BUSINESS_RULES.md. Never throws; an unreadable file is no rules. */
export function parseRules(text: string): RuleSet {
- const lines = text.split('\n')
+ const lines = linesOf(text)
const rules: Rule[] = []
let domain: string | undefined
/** Set by a top-level heading: `# P1 rules` gives its rows a priority, an index or appendix is skipped. */