refactor: integrate @doist/cli-core 0.6.0 (markdown + changelog)#319
Conversation
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
left a comment
There was a problem hiding this comment.
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.
- 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>
|
🎉 This PR is included in version 1.62.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
## 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>
Summary
src/lib/markdown.tsnow delegatespreloadMarkdown/renderMarkdownto@doist/cli-core/markdown, keeping the local leading-*bullet escape (uncompletable task prefix) on top. Drops the localmarked-terminal-rendererambient.d.tsshim now that cli-core owns the typing.src/commands/changelog.tsis now a thin wrapper overregisterChangelogCommandfrom@doist/cli-core/commands, passingpath,repoUrl, andversion. cli-core defaults match prior behavior (heading 2,*bullets, no continuation indent, no empty-version filtering). Local test deleted — cli-core covers the behavior.src/index.tsnow matchesinstanceof BaseCliError(cli-core class) so errors thrown from cli-core commands route through the existingformatErrorpath. The localCliErrorextends base, so subclass throws still match.formatError/formatErrorJsonwidened accordingly.@doist/cli-corefrom0.5.0to0.6.0.Test plan
npm run check(oxlint + oxfmt)npx tsc --noEmitnpm test(1578 tests, 6 changelog tests removed alongside the local impl — covered by cli-core)td changelog -n 1— output unchangedtd changelog -n abc— error routes via cli-coreCliError(INVALID_TYPE)through todoist's top-level handler🤖 Generated with Claude Code