summaryrefslogtreecommitdiff
path: root/plugins/code-modernization/hooks/reader/fs.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/fs.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/fs.ts')
-rw-r--r--plugins/code-modernization/hooks/reader/fs.ts29
1 files changed, 27 insertions, 2 deletions
diff --git a/plugins/code-modernization/hooks/reader/fs.ts b/plugins/code-modernization/hooks/reader/fs.ts
index 44b570ed..1d8e9f6d 100644
--- a/plugins/code-modernization/hooks/reader/fs.ts
+++ b/plugins/code-modernization/hooks/reader/fs.ts
@@ -5,7 +5,8 @@
*/
export type ReaderFs = {
read: (path: string) => Promise<string>
- list: (path: string) => Promise<{ name: string; kind: 'file' | 'dir' | 'other'; size: number }[]>
+ /** An entry as it stands: a symbolic link is `other` (with `isLink`), whatever it leads to. `stat` says what that is. */
+ list: (path: string) => Promise<{ name: string; kind: 'file' | 'dir' | 'other'; size: number; isLink?: boolean }[]>
exists: (path: string) => Promise<boolean>
stat: (path: string) => Promise<{ kind: 'file' | 'dir' | 'other'; size: number; mtimeMs: number }>
}
@@ -28,7 +29,7 @@ export async function readOrNull(fs: ReaderFs, path: string): Promise<string | n
export async function listOrEmpty(
fs: ReaderFs,
path: string,
-): Promise<{ name: string; kind: 'file' | 'dir' | 'other'; size: number }[]> {
+): Promise<{ name: string; kind: 'file' | 'dir' | 'other'; size: number; isLink?: boolean }[]> {
try {
if (!(await fs.exists(path))) {
return []
@@ -52,3 +53,27 @@ export async function mtimeOrNull(fs: ReaderFs, path: string): Promise<number |
return null
}
}
+
+/**
+ * The directories under `path`, by name. A symbolic link to a directory counts: the engine lists a link as `other`,
+ * and a legacy tree is often a link to where the code really lives.
+ */
+export async function dirNamesOf(fs: ReaderFs, path: string): Promise<string[]> {
+ const names: string[] = []
+
+ for (const entry of await listOrEmpty(fs, path)) {
+ if (entry.kind === 'dir') {
+ names.push(entry.name)
+ } else if (entry.kind === 'other') {
+ try {
+ if ((await fs.stat(`${path}/${entry.name}`)).kind === 'dir') {
+ names.push(entry.name)
+ }
+ } catch {
+ // a link that leads nowhere is not a system
+ }
+ }
+ }
+
+ return names
+}