You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Consolidate the public library interface and CLI adapter #19
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.
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.
Library operations — list, extract, update/plan/apply/check, run, dump, and transforms return Result; they never call console or process.exit.
Reporter callback — optional caller-provided event/diagnostic callback for observable progress without requiring global console state.
CLI adapter — converts Result into human text or versioned JSON and sets the process exit code after all operation work completes. Do not call process.exit from library code.
Public migration — replace or deprecate the default transform helper in favor of the structured operation interface; update examples to @gcmdev/mdcode and the object-form transformer signature ({ tag, meta, code }) => ... .
Acceptance criteria:
Public library operations return structured success values, changes, diagnostics, and errors.
No library operation writes to global console or terminates the process.
Callers can supply a reporter callback to observe operation events or diagnostics.
The CLI is a thin adapter that renders human/JSON output and assigns exit codes.
A logging framework or globally configured output mechanism.
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.
Only commands/transform.ts still does it: transform() reads process.stdin and both it and transformWithFunction() print every block with console.log. main.ts sets process.exitCode; nothing calls process.exit.
Reporter callback
run({ onBlock }) and watch({ onEvent }) already exist and are tested. The other operations are one-shot and return every diagnostic in their result.
CLI is a thin adapter
Execute() renders via format*() and returns the exit code.
Docs use the package identity and object-form transformer
Already mdcode-ts and ({ tag, meta, code }). @gcmdev/mdcode belongs to #3 and stays out of scope.
Remaining work, which is all this issue now covers:
Remove transform() and transformWithFunction(). No CLI command uses them. transformWithFunction(source, fn, filter) is update({ source, transformer: fn, filter }) without the file= reads, plus console noise. Callers move to update(), or to walk() to skip file= reads. Breaking, but the package is 0.0.x.
extract({ updateSource, ignoreAnonymous }) throws a plain Error, which maps to unexpected_error. Make it a CommandError("invalid_usage") as the CLI already does.
Keep the mdcode() default export: it already wraps update() and is documented as the simple string API.
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)