Skip to content

Releases: Coastal-Programs/notion-cli

v6.3.2

15 May 01:31

Choose a tag to compare

Fixed

  • OAuth token endpoint requests now include Notion-Version and Accept: application/json headers, matching the official Notion JS SDK (makenotion/notion-sdk-js) and developer-docs spec. Applied to exchangeCode, TokenRefresh, TokenIntrospect, and TokenRevoke in internal/oauth/oauth.go.

v6.3.1

11 May 14:00

Choose a tag to compare

Breaking

  • Go module path is now github.com/Coastal-Programs/notion-cli/v6. Per Go's major-version-suffix rule, modules at v2+ must carry a /vN suffix. Without it, go install github.com/Coastal-Programs/notion-cli/cmd/notion-cli@latest resolved to v5.9.0+incompatible and failed because that older tag did not contain cmd/notion-cli. Update any go install command and any import of pkg/output to use the /v6 prefix (e.g. go install github.com/Coastal-Programs/notion-cli/v6/cmd/notion-cli@latest). Fixes #86.

Changed

  • Bumped default Notion-Version header from 2022-06-28 to 2026-03-11 (latest).
  • db query now calls /v1/data_sources/{id}/query (Notion API 2025-09-03). Use --data-source to target a specific source on multi-source databases.
  • block append now uses the position object (Notion API 2026-03-11). The --after flag is deprecated; use --position=after --after-block <id>.
  • Use in_trash instead of archived; recognise meeting_notes block type (renamed from transcription) per Notion API 2026-03-11.

Fixed

  • Config fields previously loaded but never applied to the runtime client are now wired through. NOTION_CLI_BASE_URL, NOTION_CLI_MAX_RETRIES, NOTION_CLI_BASE_DELAY, NOTION_CLI_MAX_DELAY, and NOTION_CLI_HTTP_KEEP_ALIVE (and their config-file equivalents) now affect HTTP behavior. NOTION_CLI_VERBOSE / verbose is honored as a fallback when the --verbose flag isn't set.

Added

  • auth refresh — explicitly refresh OAuth access token using stored refresh token; prints new expiry.
  • auth status --remote — also calls token introspect to show active status, scope, and issued_at/expires_at.
  • auth logout --local-only — skip the API revoke call and only clear local config.
  • oauth.TokenRefresh, oauth.TokenIntrospect, oauth.TokenRevoke client functions in internal/oauth/oauth.go.
  • Config.OAuthRefreshToken and Config.OAuthTokenExpiresAt (RFC3339) with full persistence (save/load/clear).
  • Config.NeedsRefresh() — returns true when token expires within 5 minutes and a refresh token is present.
  • Auto-refresh-on-401: the Notion HTTP client transparently refreshes the OAuth token and retries once when a refresh token is available in config.
  • custom-emoji list --all — auto-paginate through all workspace custom emojis. Table output (id, name, url) by default. New httptest coverage for CustomEmojiList client method.
  • files command group (upload, retrieve, list) wrapping the Notion File Uploads API. files upload <path> auto-selects single-part (≤20 MB) or multi-part (>20 MB) upload, streams file contents in 10 MB chunks, shows a progress bar on TTY, and prints the file_upload_id to stdout for piping. files list supports --page-size and --all for full pagination. Five new Notion client methods: FileUploadCreate, FileUploadSend, FileUploadComplete, FileUploadRetrieve, FileUploadList.
  • view create — create a new Notion database view with --data-source, --name, --type (required) and optional --database, --filter, --sorts (JSON string or @<file>).
  • view update <view_id> — update an existing view's --name, --filter, and/or --sorts.
  • view delete <view_id> — delete a Notion view.
  • view query --all — auto-paginate through all view query results and clean up the server-side query cache on completion.
  • ViewCreate, ViewUpdate, ViewDelete methods added to the Notion HTTP client.
  • page trash <page_id> — moves a page to trash (in_trash: true). Requires --yes in non-TTY environments. Interactive mode prompts for confirmation.
  • page restore <page_id> — restores a trashed page (in_trash: false).
  • page move <page_id> — moves a page to a new parent via POST /pages/{id}/move. Supports --parent <page-id>, --data-source <data-source-id>, and --workspace (mutually exclusive).
  • PageTrash, PageRestore, PageMove methods added to the Notion HTTP client.
  • comment command group (create, list, retrieve, update, delete) wrapping the Notion Comments API (Notion-Version 2026-03-11). comment create supports --page/--block/--discussion parents (mutually exclusive), --text or --rich-text <file.json>, plus optional --display-name and repeatable --attach-file <upload-id> (max 3). comment list supports --page-size and --all for full pagination.
  • markdown command group (get, set) for reading and writing page content as enhanced markdown via /v1/pages/{id}/markdown (Notion API 2026-03-11). set supports replace (default) and --append, with content from --content, --file, or stdin.
  • custom-emoji command group (list, retrieve) per Notion API 2026-03-11.
  • notion.WithKeepAlive(bool) client option installs a transport with DisableKeepAlives=true when keep-alive is disabled in config.
  • Data Source HTTP client methods and resolver helper for the 2025-09-03 multi-source database split.
  • data-source command group (retrieve, create, update, query) for the 2025-09-03 multi-source database API.
  • data-source templates <id> — lists page templates for a data source with --all pagination support.
  • data-source properties update <id> --schema <json|@file> — updates a data source's properties schema.
  • db query now emits a deprecation notice to stderr when routing through auto-resolved data sources; suppress with --quiet.
  • Workspace cache (sync) now indexes data sources extracted from database search results (data_sources key), stored in ~/.notion-cli/databases.json under data_sources.
  • list command now includes a data_sources array alongside databases in the output.
  • ExtractID in the resolver now recognises the dataSource= query parameter in Notion URLs, returning the data source ID instead of the page/database path ID.
  • ds alias moved from db to data-source (breaking: notion-cli ds now invokes data-source).
  • view command group (list, retrieve, query, results, delete-query) per Notion API 2026-03-11.

Removed

  • Dead code cleanup: removed the unused in-memory TTL Cache struct, NewCache, TTL constants (DatabaseTTL, UserTTL, PageTTL, BlockTTL), and CacheKeyForResource from internal/cache/cache.go (and its test file). Only the workspace database cache (internal/cache/workspace.go) was ever wired up; the response cache was never integrated. The cache_enabled / cache_max_size / disk_cache_enabled config fields are kept for forward compatibility but documented as reserved.
  • Removed unused error factory functions IntegrationNotShared, ResourceNotFound, DatabaseIdConfusion, InvalidProperty, NetworkError, and Timeout from internal/errors/errors.go. The HTTP client uses FromNotionAPI for all API errors; these factories had no production callers.

v6.3.0

06 May 21:38
02f14b3

Choose a tag to compare

Why

After rotating NOTION_OAUTH_SECRET in Notion, the npm-published v6.2.1 binary became dead — its embedded secret no longer matches Notion's record. This release re-bakes the new secret and ships production hardening.

Highlights

  • Multi-port OAuth callback (8080 → 8081 → 8089) — first free port wins. Fixes the most common failure (port conflict with Jenkins/Tomcat/dev servers).
  • auth login --manual — paste-back flow for SSH/container/firewall users. Auto-on when $SSH_TTY is set.
  • Polished OAuth callback page with dark-mode support.
  • doctor now probes OAuth port availability and the Notion authorize endpoint.
  • 5-minute auth login timeout (was 2).

Upgrade

npm i -g @coastal-programs/notion-cli@latest
notion-cli auth login

Operational notes

  • Notion integration now requires three redirect URIs registered: http://localhost:{8080,8081,8089}/callback.
  • NOTION_OAUTH_SECRET was rotated; old npm versions cannot authenticate.

v6.2.1

06 May 03:49

Choose a tag to compare

Changed

  • Bumped Go toolchain from 1.25 to 1.26
  • Updated github.com/spf13/pflag from v1.0.9 to v1.0.10
  • Updated CI publish workflow to use Go 1.26

Fixed

  • Migrated golangci-lint config to v2 format (added version: "2", removed gosimple linter merged into staticcheck)
  • Resolved all pre-existing errcheck, staticcheck QF1012, and unused lint errors across the codebase

v6.2.0 - Output flag & platform packages

02 Mar 15:06

Choose a tag to compare

What's New

  • --output / -o flag: All commands now accept --output <format> (or -o <format>) as an alternative to boolean flags. Valid formats: json, compact-json, csv, markdown, table, raw, pretty. Invalid values return a structured error envelope with suggestions.

Fixes

  • Publish workflow: Platform package publish failures are no longer silently ignored. The workflow now reports explicit errors when packages fail to publish.

Upgrade

npm install -g @coastal-programs/notion-cli@latest

See CHANGELOG.md for full details.

v6.1.2 - Security fixes, bug fixes, OAuth credential rotation

02 Mar 09:47

Choose a tag to compare

What's Changed

Security

  • Rotated OAuth client secret after credential leak in v6.1.1 binary
  • Removed hardcoded OAuth client ID from Makefile — credentials now sourced exclusively from GitHub Secrets
  • OAuth callback server binds to 127.0.0.1 instead of 0.0.0.0 (prevents interception on shared machines)
  • Token exchange JSON body built with json.Marshal instead of string formatting (prevents injection)

Bug Fixes

  • OAuth authorization URL now properly URL-encodes redirect_uri parameter
  • JSON envelope version metadata now shows correct version (was stuck at 6.0.0)
  • User-Agent header now reports actual CLI version (was stuck at 1.0)
  • db schema no longer panics on databases with no properties
  • doctor command now returns error envelope and non-zero exit code when checks fail
  • search date filters validate format upfront instead of failing silently
  • search --page-size validated against Notion's 100 limit
  • db query --sort-direction validates input with clear error for invalid values
  • batch alias changed from b to ba to avoid collision with block
  • Removed dead --search flag from db query
  • All error messages in batch and config commands now use structured NotionCLIError
  • whoami, sync, list, doctor now reject unexpected arguments

CI/CD

  • Publish workflow now passes NOTION_OAUTH_CLIENT_ID secret to build steps

See CHANGELOG.md for full details.

v6.1.1 - Workflow & README fixes

02 Mar 08:33

Choose a tag to compare

Fixed

  • Publish workflow now uploads binaries to GitHub releases correctly
  • Publish workflow creates platform bin/ directories before copying
  • OAuth client secret now passed to build steps so auth login works in published binaries
  • Go version bumped to 1.25 in CI to match go.mod

Changed

  • README updated: OAuth login is the recommended setup method
  • Added Authentication section with token precedence table
  • Updated project structure, test counts, and troubleshooting docs

Full Changelog: v6.1.0...v6.1.1

v6.1.0 - OAuth Authentication

02 Mar 08:18

Choose a tag to compare

What's New

OAuth Authentication — Log in to Notion from the CLI without managing API tokens manually.

  • notion-cli auth login — Opens your browser, you authorize, and the token is saved automatically
  • notion-cli auth logout — Clears stored OAuth tokens
  • notion-cli auth status — Shows current auth method and workspace info

Token Precedence

  1. NOTION_TOKEN env var (CI/automation)
  2. OAuth token from config (interactive login)
  3. Manual token from config file (fallback)

Other Improvements

  • doctor command now shows authentication method (oauth/env/token/none) with workspace name
  • Updated error messages to suggest auth login as the primary setup path
  • 6 new OAuth-specific error codes with actionable suggestions
  • Build-time OAuth credential injection via Makefile ldflags

Technical Details

  • New internal/oauth package (stdlib only — net/http, crypto/rand)
  • CSRF protection via cryptographic state parameter
  • Config file permissions remain 0600
  • 14 new tests, 196 total passing

See CHANGELOG.md for full details.

v5.9.0 - Performance Optimizations & Critical Bug Fixes

05 Feb 08:21
9766e16

Choose a tag to compare

🚀 Performance Optimizations

This release implements 5 major performance optimizations that provide 1.5-2x performance improvement for batch operations and repeated data access.

What's New

Optimization Best Case Typical Case
Request Deduplication 50% fewer API calls 30% fewer calls
Parallel Operations 80% faster bulk ops 60% faster
Persistent Disk Cache 60% better hit rate 40% better
HTTP Keep-Alive 20% latency reduction 10% reduction
Response Compression 70% bandwidth saved 60% saved

Phase 1: Request Deduplication

  • Prevents duplicate concurrent API calls using promise memoization
  • Automatically deduplicates identical requests in flight
  • 30-50% reduction in duplicate API calls
  • Files: src/deduplication.ts (100% test coverage)

Phase 2: Parallel Operations

  • Converts sequential operations to parallel execution
  • Block deletion: 5 concurrent operations (configurable)
  • Child fetching: 10 concurrent operations (configurable)
  • 60-80% faster for bulk operations
  • Files: Updated src/notion.ts with batchWithRetry

Phase 3: Persistent Disk Cache

  • Cache persists across CLI invocations in ~/.notion-cli/cache/
  • Atomic writes prevent corruption
  • LRU eviction with 100MB default max size
  • 40-60% improved cache hit rate
  • Files: src/utils/disk-cache.ts (95.38% test coverage)

Phase 4: HTTP Keep-Alive & Connection Pooling

  • Reuses connections across requests
  • Configurable pool size and keep-alive timeout
  • 5-10% latency reduction
  • Files: src/http-agent.ts (100% test coverage)

Phase 5: Response Compression

  • Automatic compression negotiation (gzip, deflate, brotli)
  • 60-70% bandwidth reduction for JSON responses
  • Zero configuration required
  • Files: Updated src/notion.ts fetch wrapper

🐛 Critical Bug Fixes

Three critical bugs identified during code review have been fixed:

1. Disk cache never returned data on first call

Problem: Fire-and-forget async pattern caused immediate cache miss.
Fix: Made cache.get() properly async with await for disk lookups.

2. HTTP agent imported but never used

Problem: Native fetch() doesn't support agent option.
Fix: Switched to undici Agent with dispatcher option.

3. Impossible error condition in parallel ops

Problem: Condition !result.success && result.data could never be true.
Fix: Changed to result.success && result.data && !result.data.success.

🧪 Testing

  • 268 total tests (121 existing + 147 new)
  • 90%+ coverage on all new code
  • Zero test regressions

New Test Files

  • test/deduplication.test.ts - 37 tests (100% coverage)
  • test/disk-cache.test.ts - 65 tests (95.38% coverage)
  • test/http-agent.test.ts - 38 tests (100% coverage)
  • test/cache-disk-integration.test.ts - 30 integration tests
  • test/notion.test.ts - 59 integration tests
  • test/parallel-operations.test.ts - 21 timing tests
  • test/compression.test.ts - 18 tests

📦 Installation

npm install -g @coastal-programs/notion-cli@5.9.0

🔧 Configuration

All features enabled by default. Configure via environment variables:

# Deduplication
NOTION_CLI_DEDUP_ENABLED=false

# Parallel Operations
NOTION_CLI_DELETE_CONCURRENCY=5
NOTION_CLI_CHILDREN_CONCURRENCY=10

# Disk Cache
NOTION_CLI_DISK_CACHE_ENABLED=false
NOTION_CLI_DISK_CACHE_MAX_SIZE=104857600
NOTION_CLI_DISK_CACHE_SYNC_INTERVAL=5000

# HTTP Keep-Alive
NOTION_CLI_HTTP_KEEP_ALIVE=false
NOTION_CLI_HTTP_KEEP_ALIVE_MS=60000
NOTION_CLI_HTTP_MAX_SOCKETS=50
NOTION_CLI_HTTP_MAX_FREE_SOCKETS=10
NOTION_CLI_HTTP_TIMEOUT=30000

🔄 Migration

No breaking changes! All features work out of the box:

# Same commands, better performance
notion-cli db query <DB_ID>

# First run creates cache
notion-cli db query <DB_ID>  # Fetches from API

# Second run uses disk cache
notion-cli db query <DB_ID>  # Returns from cache (faster)

📊 Dependencies

  • Zero new production dependencies (uses Node.js built-ins only)
  • All dependencies already in project

📝 Full Changelog

See CHANGELOG.md for complete details.


🤖 Built with Claude Code

v5.8.0 - Test Coverage & Codecov Improvements

05 Feb 01:40
8e999d8

Choose a tag to compare

🧪 What's New

This release significantly improves test coverage and Codecov integration.

✨ Test Coverage Improvements

  • Comprehensive table-formatter tests: Added 75 unit tests achieving 100% line coverage and 96.42% branch coverage
  • Covers all table rendering modes: CSV output, table formatting, sorting, filtering, and edge cases
  • Includes real-world usage patterns from actual commands
  • Tests follow project conventions with Mocha + Chai

🔧 Codecov Configuration

  • Added .codecov.yml configuration file with coverage thresholds
  • Updated Codecov action to v4 (from v3)
  • Fixed coverage file path to use lcov.info
  • Configured PR comment layouts for better visibility
  • Added flag definitions with carryforward enabled

📝 Documentation Updates

  • Updated docs/user-guides/envelope-testing.md with correct Codecov examples
  • Added explanatory comments to CI workflow for maintainability
  • Improved documentation accuracy to match actual CI configuration

🐛 Bug Fixes

  • Fixed table format tests for oclif v4 / cli-table3 compatibility
  • Corrected coverage reporting paths in CI workflow

📊 Test Coverage Statistics

  • table-formatter.ts: 100% lines | 96.42% branches | 100% functions
  • 75 new unit tests added
  • All CI checks passing

🔗 Links

🤖 Generated with Claude Code