Skip to content

refactor: integrate @doist/cli-core 0.6.0 (markdown + changelog)#319

Merged
scottlovegrove merged 4 commits into
mainfrom
scottl/core-updates-2
May 9, 2026
Merged

refactor: integrate @doist/cli-core 0.6.0 (markdown + changelog)#319
scottlovegrove merged 4 commits into
mainfrom
scottl/core-updates-2

Conversation

@scottlovegrove
Copy link
Copy Markdown
Collaborator

Summary

  • Markdown renderingsrc/lib/markdown.ts now delegates preloadMarkdown / renderMarkdown to @doist/cli-core/markdown, keeping the local leading-* bullet escape (uncompletable task prefix) on top. Drops the local marked-terminal-renderer ambient .d.ts shim now that cli-core owns the typing.
  • Changelog commandsrc/commands/changelog.ts is now a thin wrapper over registerChangelogCommand from @doist/cli-core/commands, passing path, repoUrl, and version. cli-core defaults match prior behavior (heading 2, * bullets, no continuation indent, no empty-version filtering). Local test deleted — cli-core covers the behavior.
  • Top-level error handlersrc/index.ts now matches instanceof BaseCliError (cli-core class) so errors thrown from cli-core commands route through the existing formatError path. The local CliError extends base, so subclass throws still match. formatError / formatErrorJson widened accordingly.
  • Bumps @doist/cli-core from 0.5.0 to 0.6.0.

Test plan

  • npm run check (oxlint + oxfmt)
  • npx tsc --noEmit
  • npm test (1578 tests, 6 changelog tests removed alongside the local impl — covered by cli-core)
  • Smoke td changelog -n 1 — output unchanged
  • Smoke td changelog -n abc — error routes via cli-core CliError(INVALID_TYPE) through todoist's top-level handler

🤖 Generated with Claude Code

scottlovegrove and others added 3 commits May 9, 2026 09:00
Wraps the upcoming cli-core markdown module (preloadMarkdown +
renderMarkdown) and keeps the local "* " bullet-escape for
uncompletable task prefixes. Drops the marked-terminal-renderer
ambient .d.ts shim now that cli-core owns the typing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replace the local changelog command implementation with a thin wrapper
over registerChangelogCommand from @doist/cli-core/commands, passing the
todoist-specific path, repo URL, and version. cli-core defaults match
the prior behavior (heading 2, `*` bullets, no continuation indent).

Top-level error handler now matches against the cli-core base CliError
so errors thrown from cli-core commands route through the existing
formatError path; the local CliError extends base, so subclass throws
still match. formatError / formatErrorJson widened accordingly.

Local changelog tests removed — cli-core covers the behavior.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Picks up the released ./markdown and ./commands subpaths consumed by
src/lib/markdown.ts and src/commands/changelog.ts.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@doistbot doistbot requested a review from rfgamaral May 9, 2026 08:25
Copy link
Copy Markdown
Member

@doistbot doistbot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR successfully integrates @doist/cli-core 0.6.0 to standardize markdown rendering and the changelog command while thoughtfully reducing local boilerplate. Transitioning these features to the shared package improves long-term maintainability by letting the core module handle the heavy lifting. A few adjustments are needed to fully align the integration, such as centralizing the new core error types within our local abstraction, preserving slim integration coverage for the changelog wiring, synchronizing markdown preload behavior, and updating both test coverage and repository documentation to reflect the structural changes.

Share FeedbackReview Logs

Comment thread src/lib/markdown.ts Outdated
Comment thread src/index.ts Outdated
Comment thread src/commands/changelog.test.ts
Comment thread src/commands/changelog.ts
Comment thread src/lib/output.ts
Comment thread src/index.ts
Comment thread src/types/marked-terminal-renderer.d.ts
- markdown wrapper: replace dual-source preload flag with a cached
  preload promise — single source of truth for readiness, can't drift
  from cli-core's own state.
- errors: re-export `BaseCliError` from `src/lib/errors.ts` so the
  top-level handler in `src/index.ts` and the formatter widening in
  `src/lib/output.ts` consume cli-core's error class through the local
  abstraction instead of importing `@doist/cli-core` in two places.
- changelog: re-add a slim integration test exercising the wrapper's
  todoist-specific path / repoUrl / version wiring.
- output.test: cover `formatError` / `formatErrorJson` against a real
  cli-core `CliError` instance so the new formatter path can't regress.
- AGENTS.md / CODEBASE.md: drop the removed `src/types/` entry from the
  repo map and document that the global error handler also matches the
  re-exported `BaseCliError`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@scottlovegrove scottlovegrove self-assigned this May 9, 2026
@scottlovegrove scottlovegrove added the 👀 Show PR PR must be reviewed before or after merging label May 9, 2026
@scottlovegrove scottlovegrove merged commit 3d90382 into main May 9, 2026
4 checks passed
@scottlovegrove scottlovegrove deleted the scottl/core-updates-2 branch May 9, 2026 08:46
@doist-release-bot
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.62.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link
Copy Markdown
Member

@rfgamaral rfgamaral left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scottlovegrove added a commit to Doist/outline-cli that referenced this pull request May 11, 2026
## Summary

- **Changelog command** — `src/commands/changelog.ts` is now a thin
wrapper over `registerChangelogCommand` from `@doist/cli-core/commands`,
passing `path`, `repoUrl`, `version`, and `bulletMarkers: ['*', '-']`
(preserves outline's local support for both bullet styles). Drops ~110
lines of local parsing/formatting now owned by cli-core.
- **Top-level error handler** — `src/index.ts` now matches `instanceof
BaseCliError` so errors thrown from cli-core helpers (e.g. the delegated
`changelog` command's `INVALID_TYPE` / `FILE_READ_ERROR`) route through
`formatError` / `formatErrorJson`. The local `CliError` extends the same
base, so existing throws still match.
- **Global JSON flag** — declared `--json` and `--ndjson` at the program
level with `enablePositionalOptions()`, plus an `isJsonMode()` helper in
`src/lib/global-args.ts` backed by cli-core's `parseGlobalArgs` argv
scan. `ol --json <subcommand>` now produces a JSON error envelope for
any `BaseCliError` thrown after parsing.
- **`formatError` / `formatErrorJson`** — widened in `src/lib/output.ts`
to accept either positional `(code, message, hints?)` or a
`BaseCliError` instance.
- **`src/lib/errors.ts`** — re-exports `CoreCliError` as `BaseCliError`
so the top-level `instanceof` check covers both.

Mirrors
[todoist-cli#319](Doist/todoist-cli#319). No
`@doist/cli-core` version bump (already on `0.9.0`).

## Behavior changes

- `ol changelog -n abc` now exits non-zero with `Error: INVALID_TYPE /
Count must be a positive integer` (was a custom `chalk.red('Error:')`
line with `Count must be a positive number`) — intentional alignment
with the cli-core contract.
- `ol --json changelog -n abc` now emits
`{"error":{"code":"INVALID_TYPE","message":"Count must be a positive
integer"}}`.
- `--json` / `--ndjson` now appear as global options in `ol --help`
(existing per-subcommand `--json` flags still work the same).

## Test plan

- [x] `npm run type-check`
- [x] `npm run lint:check` + `npm run format:check`
- [x] `npm test` (108 tests pass; changelog suite slimmed from 6 tests
to 2 wrapper smoke tests covering path-passthrough and footer URL;
output suite gains `BaseCliError`-instance + `formatErrorJson` cases)
- [x] Smoke `ol changelog -n 1` — version block + footer link unchanged
- [x] Smoke `ol changelog -n abc` — human red error, exit 1
- [x] Smoke `ol --json changelog -n abc` — JSON error envelope, exit 1
- [x] Smoke `ol doc list --json` — per-subcommand `--json` still routes
to output formatter

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released 👀 Show PR PR must be reviewed before or after merging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants