diff options
| author | Morgan Lunt <morganl@anthropic.com> | 2026-09-24 18:19:16 -0700 |
|---|---|---|
| committer | Morgan Lunt <morganl@anthropic.com> | 2026-09-24 18:19:16 -0700 |
| commit | 54772aaaabf371dc212480fbf7da216bd65990c7 (patch) | |
| tree | df16d07b32801b695d616f16d87c1ad1a37739b5 /plugins/code-modernization/hooks/reader/progress.ts | |
| parent | c9e990089c6c87cb96e227e998edbada1df82861 (diff) | |
code-modernization: mark the pane's notes as data and clean the names in them
The pane adds two kinds of text to what the model reads: a note about the
file it just read (names, rule titles and delta ids from the analysis
files) and a one-line state. Those names were written by analysis agents
from the legacy code, so a hostile comment could reach the model through
them.
Each such value is now cut to one short plain line: control, invisible
and bidirectional characters, backticks, angle and square brackets and
double quotes are replaced, and long values are trimmed. A note opens by
saying its contents are data, never instructions, and closes with an end
line no value can forge. The state line says it is a status line and not
an instruction, and the next-step command names a module only when the
module id is one plain token. The pane lists only system directories
whose names the plugin's workflows accept.
Diffstat (limited to 'plugins/code-modernization/hooks/reader/progress.ts')
| -rw-r--r-- | plugins/code-modernization/hooks/reader/progress.ts | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/plugins/code-modernization/hooks/reader/progress.ts b/plugins/code-modernization/hooks/reader/progress.ts index 711cabac..ee795978 100644 --- a/plugins/code-modernization/hooks/reader/progress.ts +++ b/plugins/code-modernization/hooks/reader/progress.ts @@ -1,4 +1,5 @@ import { join } from '../paths' +import { isSystemName, isToken, plain } from '../text' import { parseBrief, type Brief, type Phase } from './brief' import { discoverEstate, sourceSizes } from './discover' import { estateOfTopology, keysOfUnit, type EstateModel, type EstateUnit } from './estate-model' @@ -183,7 +184,8 @@ export async function systemsOf(fs: ReaderFs, legacyDir = 'legacy'): Promise<str for (const root of ['analysis', legacyDir]) { for (const entry of await listOrEmpty(fs, root)) { - if (entry.kind === 'dir' && !entry.name.startsWith('.')) { + // The names the plugin's workflows accept: anything else could not be run on, and is not put in a command or a note. + if (entry.kind === 'dir' && isSystemName(entry.name)) { names.add(entry.name) } } @@ -274,10 +276,13 @@ function nextOfTransform( }) if (open !== undefined) { + // A module id is text from the map: it goes in a command only when it is one plain token. + const isNamed = isToken(open) + return { - text: cmd('transform', `${open}${target === '' ? '' : ` ${target}`}`), - isByHand: false, - reason: `Phase ${phase.number} names ${open} and it is not reviewed yet`, + text: cmd('transform', `${isNamed ? open : '<module>'}${target === '' ? '' : ` ${target}`}`), + isByHand: !isNamed, + reason: `Phase ${phase.number} names ${plain(open, 60)} and it is not reviewed yet`, } } |
