Skip to content

feat(cli): add mex export (bundle scaffold to a single Markdown file) - #183

Open
abhinav-phi wants to merge 2 commits into
mex-memory:mainfrom
abhinav-phi:feat/export-command
Open

feat(cli): add mex export (bundle scaffold to a single Markdown file)#183
abhinav-phi wants to merge 2 commits into
mex-memory:mainfrom
abhinav-phi:feat/export-command

Conversation

@abhinav-phi

Copy link
Copy Markdown
Contributor

Resolves #56.

What

mex export concatenates the whole scaffold into one Markdown document, for pasting into tools that don't read files well:

  • Same discovery as mex check — reuses findScaffoldFiles + DEFAULT_SCAFFOLD_PATTERNS, so the export is exactly what the drift scanner sees, never a divergent file list.
  • Each file lands under a ## <scaffold-relative-path> header, with content trimmed of trailing whitespace so the document stays clean.
  • Deterministic order (sorted by path), so repeated exports diff cleanly.
  • mex export → stdout; mex export --out exports/scaffold.md → file (parent directories created) plus a one-line count report.
  • An empty scaffold fails with No scaffold files found. Run: mex setup.

Tests

Three cases in test/export.test.ts: full bundle (headers, content, deterministic order), --out write + count report, and missing-scaffold guidance. npm run typecheck green.

Concatenates every scaffold file the drift scanner discovers
(DEFAULT_SCAFFOLD_PATTERNS through findScaffoldFiles) into a single
Markdown document with a '## <path>' section header per source file, so
what gets exported is exactly what mex check scans.

Output goes to stdout by default, or to a path via --out (parent
directories created). An empty scaffold fails with the setup guidance.
Resolves mex-memory#56
src/export.ts writes one bundle file to a user-specified path — a
brand-new file, never scaffold bytes — which is exactly the class the
allowlist's own comment carves out. Registered by write call with its
exemption, per the rule that a new writer names its scope.
@abhinav-phi

Copy link
Copy Markdown
Contributor Author

CI caught this PR violating the wiki-architecture write pin: src/export.ts introduces a writeFileSync outside src/wiki/, so the pinned-writers test counted 15 writers against the allowlist's 14. Registered the writer with its exemption — the --out path is a brand-new file the user names, which is the class the allowlist's own comment describes ("write JSON, hooks, or brand-new files, so there are no bytes of anybody's to preserve"). No production change needed; the test now documents the export writer's scope like every other entry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add mex export (bundle scaffold to a single Markdown file)

1 participant