Skip to content

[Feature] Add tnmsc compile command for syncing front matter per file #24

@TrueNine

Description

@TrueNine

Feature Description

Add a tnmsc compile subcommand that performs a simple sync of front matter per file—i.e. update or normalize the YAML front matter in each source file without running the full Input → Transform → Output pipeline. This supports workflows where users only want to refresh front matter (e.g. from export metadata or a canonical schema) without writing to Cursor/Kiro/Warp/etc.

  • Current behavior: tnmsc has subcommands like help, version, config, dry-run, clean, plugins; the default (no subcommand) runs the full sync pipeline (ExecuteCommand). There is no dedicated command that only compiles/syncs front matter in place per file.
  • Problem: Users who only need to sync front matter definitions (e.g. merge export metadata into YAML, or normalize keys) must either run the full pipeline or use external tooling.

Use Case

  1. User has skill/rule/command markdown under skill, rule, or fastCommand src dirs with existing front matter.
  2. User runs tnmsc compile (optionally with scope/glob or config).
  3. CLI compiles each file (e.g. MDX → metadata + content via @truenine/md-compiler), merges or normalizes front matter (e.g. from mdxToMd export metadata), and writes back the same files with updated front matter only (or minimal content change), without invoking any output plugin.
  4. Result: source files have consistent, up-to-date front matter for use in the next full tnmsc sync or by other tools.

Typical workflow: edit content or exports → tnmsc compile to refresh front matter → commit or run full sync.

Expected Outcome

  • New subcommand compile registered in PluginPipeline (e.g. in Subcommand type and VALID_SUBCOMMANDS).
  • A new command implementation (e.g. CompileCommand) that:
    • Uses existing config (e.g. skill, rule, fastCommand src paths from shadow/global config).
    • For each relevant file: parse front matter + optional MDX compile, compute merged/normalized front matter, write back to the same file (or optional dry-run).
  • No change to existing sync/output plugins; compile is a separate, lightweight path.
  • Scope: CLI only; affected modules: cli/src/PluginPipeline.ts, cli/src/commands/, config for src dirs.

Context Information

  • Branch: dev
  • Latest Commit: 83fe32b chore: update version number in package.json to 2026.10219.10518
  • Working Tree: clean
  • OS: Windows (win32 10.0.26200)
  • Relevant code: Front matter is already parsed/built in RuleInputPlugin (parseMarkdown, mdxToMd, mergedFrontMatter), and in output plugins via buildMarkdownWithFrontMatter from @truenine/md-compiler/markdown. The new command would reuse these utilities to read → merge/normalize → write per file.

Additional Notes

  • Preserve read-only constraint where possible: "compile" updates only the front matter (and possibly normalized content) of source files that are under the user's config; it does not modify arbitrary files.
  • Consider --dry-run for compile to preview front matter changes without writing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions