Closed
Labels
enhancementNew feature or requestNew feature or requestready-for-agentFully specified and ready for an AFK agentFully specified and ready for an AFK agent
Description
What to build
Consolidate the public mdcode library interface so programmatic callers receive structured results and errors without inheriting CLI process exits or terminal formatting behavior.
Acceptance criteria
- The public library interface returns structured results, changes, and errors for supported operations.
- CLI presentation and process-exit behavior are implemented in a thin adapter rather than in library operations.
- Documentation and examples use the current package identity and accurate transformer signatures.
- Library callers can provide or observe output without relying on global console state.
- The migrated interface is covered by focused library and CLI integration tests.
Blocked by
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestready-for-agentFully specified and ready for an AFK agentFully specified and ready for an AFK agent
Activity
adrianbrowning commentedon Aug 8, 2026
Agent Brief
Category: enhancement
Summary: Consolidate mdcode library operations around structured outcomes and make the CLI a presentation/exit-code adapter.
Current behavior:
Public command functions mix operation logic with console output. The exported Execute function calls process.exit in command error paths. The default library helper returns only transformed Markdown, and its documentation uses an outdated package identity and transformer signature.
Desired behavior:
Programmatic callers receive structured success values, changes, diagnostics, and errors without terminal formatting or process termination. The CLI renders the same outcomes for humans or JSON and chooses its exit code at the outermost adapter. Callers may observe progress through an explicit callback instead of global console state.
Key interfaces:
Acceptance criteria:
Out of scope:
Verification status:
Confirmed: commands call console, CLI paths call process.exit, and the current default library example uses an outdated package identity/signature. This issue is blocked by #5 and #6.
adrianbrowning commentedon Oct 6, 2026
Scope check against
main(c50021e) before starting. Most of the brief was written before #5/#6 landed and is already done:list,extract,update,validate,watch,run,dumpall return typed results; failures throwMetadataError/BlockFailure/CommandError, whicherrorsFrom()maps onto contract codes.commands/transform.tsstill does it:transform()readsprocess.stdinand both it andtransformWithFunction()print every block withconsole.log.main.tssetsprocess.exitCode; nothing callsprocess.exit.run({ onBlock })andwatch({ onEvent })already exist and are tested. The other operations are one-shot and return every diagnostic in their result.Execute()renders viaformat*()and returns the exit code.mdcode-tsand({ tag, meta, code }).@gcmdev/mdcodebelongs to #3 and stays out of scope.Remaining work, which is all this issue now covers:
transform()andtransformWithFunction(). No CLI command uses them.transformWithFunction(source, fn, filter)isupdate({ source, transformer: fn, filter })without thefile=reads, plus console noise. Callers move toupdate(), or towalk()to skipfile=reads. Breaking, but the package is 0.0.x.extract({ updateSource, ignoreAnonymous })throws a plainError, which maps tounexpected_error. Make it aCommandError("invalid_usage")as the CLI already does.mdcode()default export: it already wrapsupdate()and is documented as the simple string API.feat!: drop console-printing transform API; add update onBlock; extra…
chore: guardrails from the #19 retro (#48)