Commit Graph

45 Commits

Author SHA1 Message Date
Fourier f1d4d119c6 fix(client): replace go1.25 multipart.FileContentDisposition with compatible impl
multipart.FileContentDisposition was introduced in Go 1.25 but go.mod
targets 1.24, causing CI build failures. Replace with manual
Content-Disposition header construction with proper quote escaping.
2026-03-20 11:20:32 +08:00
Fourier 218de498fa refactor(client): use context.WithTimeout for upload instead of mutating httpClient
Replace the pattern of temporarily swapping httpClient.Timeout (not
concurrency-safe) with context.WithTimeout on the request. This is
the idiomatic Go approach and safe for concurrent use.
2026-03-20 09:04:57 +08:00
傅洋 3d0fb6b096 Merge pull request #11 from Acring/fix/file-upload-timeout
fix(client): increase timeout for file upload requests
2026-03-20 09:03:50 +08:00
liu.zhen 5a0989489e fix(client): increase timeout for file upload requests
The default 30s HTTP client timeout is too short for file uploads,
causing "context deadline exceeded" errors. Use a dedicated 5-minute
timeout for the UploadFileContent method.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-18 11:49:38 +08:00
傅洋 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 9e8b80720d chore(gitignore): add notion.exe to ignored binaries
Windows build artifact — should not be tracked alongside the unix binary.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-14 20:34:42 +09: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 ad95149a25 docs(changelog): GFM table + 인라인 서식 구현 이력 기록
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-14 19:53:36 +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
傅洋 9ff1532c32 Merge pull request #8 from 4ier/docs/msys-path-workaround
docs: add MSYS/Git Bash path workaround
2026-03-12 17:50:09 +08:00
傅洋 90010ed02b Merge pull request #6 from ahnbu/fix/auth-doctor-profile-token
fix(auth): doctor reads token from current profile
2026-03-12 17:49:58 +08:00
傅洋 e1a1f54d31 Merge pull request #4 from hypn4/docs/fix-auth-cli-flags
docs: fix auth CLI flags to match implementation
2026-03-12 17:49:38 +08:00
Fourier 44e8ab0ed2 docs: add MSYS/Git Bash path workaround
Closes #7
2026-03-12 16:37:01 +08: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
hypn4 aa7e0e5f14 docs: fix auth CLI flags to match actual implementation
README.md and DESIGN.md documented `--token` which doesn't exist.
The actual flag is `--with-token` (boolean, reads token from stdin).
Also added missing `switch` subcommand to README command table.
2026-03-11 11:15:12 +09:00
chenyu 10c44cd967 fix(client): escape quoted multipart filenames 2026-03-10 18:27:11 -07:00
chenyu 50d29f8ebe fix(file): repair Notion file upload flow 2026-03-10 17:58:29 -07:00
傅洋 1625ccb974 Merge pull request #2 from 4ier/fix/date-range-support
feat: support date ranges (start + end) in page set
2026-03-11 07:05:25 +08: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 0c3ca7a016 ci: split tokens — GITHUB_TOKEN for release, HOMEBREW_TAP_TOKEN for cross-repo v0.3.0 2026-02-24 17:26:31 +08:00
Fourier b5ddd58c9e ci: use HOMEBREW_TAP_TOKEN for cross-repo push 2026-02-24 17:08:55 +08:00
Fourier 2bc33ce168 fix: lint gosimple S1009 — remove redundant nil checks on map 2026-02-24 16:21:33 +08:00
Fourier 1fc3f1643e Merge feat/v0.3-features: page edit, block move, db export, comment reply, auth switch 2026-02-24 16:18:38 +08:00
Fourier d9bbf612ab docs: update SKILL.md with v0.3.0 commands 2026-02-24 16:18: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 3f74f41d35 docs: add demo GIF to README 2026-02-19 06:42:50 +08:00
Fourier f49f500d86 feat: add Docker multi-arch build to goreleaser v0.2.0 2026-02-19 06:36:30 +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 bb90f8d8a3 fix: clean up agent skill dirs, update SKILL.md for 38 commands
- Restore skills/notion-cli/SKILL.md as real file (not symlink)
- Add agent install dirs to .gitignore
- Update skill with new commands: insert, restore, link/unlink, add-bulk, doctor
2026-02-19 00:18:36 +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 c978f95fe7 add agent skill for skills.sh
Skill teaches AI agents how to use the notion CLI: full command
reference, filter/sort syntax, output modes, and practical tips.

Install: npx skills add 4ier/notion-cli
2026-02-18 23:58:26 +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