Commit Graph

23 Commits

Author SHA1 Message Date
傅洋 f0436294df Merge pull request #10 from ahnbu/main
feat(block): add GFM table and inline formatting support
2026-03-15 16:47:23 +08:00
傅洋 c30978b9b1 Merge pull request #3 from charys117/dev
fix: repair notion file upload workflow
2026-03-15 16:47:11 +08:00
ahnbu cc0f36a9eb Merge remote-tracking branch 'upstream/main' 2026-03-14 20:09:56 +09:00
ahnbu 6912bc6209 fix(block): move table_row children into table{} per Notion API spec
Notion API validation requires table_row blocks inside table.children
(not at block top-level). Fixes 'table.children should be defined' error.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-14 20:04:30 +09:00
ahnbu 723eec3108 feat(block): add GFM table and inline formatting support
- parseMarkdownToBlocks(): detect pipe-delimited tables, build Notion
  table/table_row block structure (table_width, has_column_header)
- parseInlineFormatting(): tokenize **bold**, *italic*, _italic_,
  \`code\`, ~~strike~~, [link](url) → rich_text annotations array
- makeTextBlock(): now uses parseInlineFormatting instead of plain text
- renderBlockMarkdown(): add table/table_row cases with GFM separator
- richTextToMarkdown(), richTextItemToMarkdown(): helpers for rendering
  annotated rich_text back to markdown
- isTableSeparator(), splitTableRow(), buildTableBlock(): table helpers
- block_test.go: TestParseMarkdownTable, TestParseInlineFormatting,
  TestIsTableSeparator test suites added; all existing tests pass

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-14 19:53:20 +09:00
ahnbu 4eea326f69 fix(auth): doctor reads token from current profile
After profile-based login, cfg.Token is empty because MigrateToProfiles
clears it. doctor was only checking the legacy top-level token field,
causing it to always report 'no token found' even after a successful login.

Fixes #5
2026-03-11 14:28:55 +09:00
chenyu 50d29f8ebe fix(file): repair Notion file upload flow 2026-03-10 17:58:29 -07:00
Fourier cf4f0e3e06 feat: support date ranges (start + end) in page set
Use / separator to specify end date:
  notion page set <id> 'Due=2026-03-07T20:00/2026-03-07T21:00'

Single dates continue to work unchanged.

Closes #1
2026-03-11 06:49:32 +08:00
Fourier fe37d1f99b feat(auth): add multi-profile support with switch command
- Add profiles support to config structure
- Add auth switch command for interactive/direct profile switching
- Update auth login to support --profile flag
- Update auth status to show current profile
- Update getToken() to use profile system
- Backward compatible: auto-migrates legacy single-token config
- Add comprehensive tests for profile functionality

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-24 15:29:00 +08:00
Fourier ac1cbe3a18 feat(comment): add reply command for threaded comments
- GET parent comment to find discussion_id
- POST new comment with discussion_id to same thread
- Shows discussion ID in output for reference

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-24 15:28:52 +08:00
Fourier 6199813c76 feat(db): add export command for exporting database to CSV/JSON/MD
- Query all rows with pagination support
- Support --format csv (default), json, md
- Support --output to write to file (default: stdout)
- CSV: headers from property names, rows from property values
- JSON: array of objects with property values
- MD: markdown table format

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-24 15:28:45 +08:00
Fourier 9c25e2d7dc feat(block): add move command for repositioning blocks
- Supports --after to position after a specific block
- Supports --before to position before a specific block
- Supports --parent to move to a different parent block/page
- Uses PATCH /v1/blocks/{id} with parent and after fields

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-24 15:28:32 +08:00
Fourier 9e189e5a82 feat(page): add edit command for editing pages in text editor
- Downloads page blocks as Markdown
- Opens in $EDITOR (or $VISUAL, fallback to vi)
- Parses edited Markdown back to Notion blocks
- Updates page by deleting old blocks and appending new ones
- Supports --editor flag to override default editor

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-24 15:28:23 +08:00
Fourier 4354884991 fix: lint issues — errcheck, gosimple, format verbs 2026-02-19 06:34:12 +08:00
Fourier 4276333c71 ci: pin Go 1.24 for lint job (match go.mod) 2026-02-19 06:14:36 +08:00
Fourier 2827dc1446 fix: rename duplicate TestMapBlockType → TestMapBlockTypeAliases 2026-02-19 06:14:09 +08:00
Fourier 4f7c2f7cdf fix: CI test failures + goreleaser deprecations
- config_test: use t.Setenv for reliable env isolation on CI
- config_test: skip permission test on Windows
- test.yml: align Go matrix with go.mod (1.24)
- goreleaser: fix deprecated formats/homebrew_casks fields
- block: improve --format md rendering with proper indentation
- block: add more markdown parse test cases
- page: minor improvements
2026-02-19 06:11:59 +08:00
Fourier c435c10ac3 release: v0.2.0 — goreleaser, CI, Docker, full README, distribution
- Add goreleaser config (linux/darwin/windows × amd64/arm64)
- Add GitHub Actions: release (goreleaser on tag) + test (3 OS × 3 Go versions + lint)
- Add Dockerfile (Alpine-based)
- Add Homebrew tap (4ier/homebrew-tap) and Scoop bucket (4ier/scoop-bucket)
- Rewrite README: badges, 6 install methods, command table, feature showcase
- Wire version via ldflags
- Update SKILL.md with new commands and install methods
- Add DISTRIBUTION.md plan
2026-02-19 01:34:39 +08:00
Fourier 2fcf8b0f49 feat: complete all remaining features for 100% completeness
- Add --filter-json for raw Notion API filter JSON (OR/nested queries)
- Add --all pagination to db query (all list commands now support --all/--cursor)
- Add semantic error hints with actionable suggestions for 10 API error codes
- Add page create --db for database parent (schema-aware property detection)
- Add block list --depth N for recursive nested block fetching
- Add block list --md for Markdown output rendering
- Add Markdown-to-blocks parser for --file (h1-h3/bullet/numbered/todo/quote/code/divider)
- Add comment get command
- Move todo parsing before bullet to prevent --[ ] matching as bullet
- Add 24 new tests (block markdown parsing + error hints)

Total: 4,310 lines Go, 1,056 lines tests, 124 test cases, 9.6MB binary
2026-02-19 01:18:57 +08:00
Fourier 3304d8044e test: comprehensive test suite — 100 test cases
Coverage:
- cmd/db_test.go: filter parsing (12 cases), sort parsing (5),
  operator mapping (text/number/date), schema option extraction (4)
- cmd/page_test.go: block type mapping (18), property value building
  (15+3+1+1), property extraction (15), rich text extraction (3)
- internal/util/url_test.go: URL/ID resolution (7)
- internal/config/config_test.go: save/load, missing config, file permissions (3)
- internal/client/client_test.go: constructor, debug toggle, constants,
  no token in URL (4)

Security: verified no token/secret leakage in debug output,
config file permissions test ensures 0600.
2026-02-19 00:34:20 +08:00
Fourier 3718c66d85 feat: absorb competitor features — 38 commands
New commands:
- block insert: positional insertion with --after <block-id>
- block append --file: read content from markdown files
- block delete: now supports multiple IDs in one call
- page restore: unarchive pages (reverse of delete)
- page link/unlink: manage relation properties between pages
- db add-bulk: bulk create rows from JSON file with progress
- auth doctor: health check (config, token, workspace, API)

All following our design: human-friendly syntax, dual output,
schema-aware operations. No raw JSON required from users.

3,878 lines of Go. 38 subcommands. Single binary.
2026-02-19 00:17:11 +08:00
Fourier 576690f810 fix: code block append requires language field
Notion API validates that code blocks must include a 'language' field.
Added --lang flag (default: 'plain text') to block append command.
2026-02-18 23:51:25 +08:00
Fourier c66e1d34bb v0.1.0: Full Notion CLI
30 commands covering the entire Notion API:
- auth: login, status, logout
- search: full-text search with type filter
- page: view, list, create, delete, move, open, set, props
- db: list, view, query (filter/sort), create, update, add, open
- block: list, get, append, update, delete
- comment: list, add
- user: me, list, get
- file: list, upload
- api: raw escape hatch for any endpoint

Features:
- Auto-detect TTY: pretty tables in terminal, JSON when piped
- Full Notion IDs in all output (no truncation)
- URL-to-ID resolution (accepts notion.so URLs everywhere)
- Filter syntax for db query: Status=Done, Date>=2026-01-01, Name~=keyword
- Sort syntax: Date:desc, Name:asc
- Property type auto-detection from schema
- Debug mode (--debug) for API troubleshooting
- Shell completion via cobra

3,239 lines of Go. Single binary. Zero dependencies at runtime.
2026-02-18 23:40:14 +08:00