name: notion-sync description: Sync local workspace directories and files to Notion pages using the notion-sync CLI or programmatic API. Use when the user wants to push files to Notion, mirror a directory structure into Notion, initialize notion-sync config, manage ignore patterns, or check sync status.
CLI and library for syncing a local directory tree into Notion. Folders become Notion pages, files become sub-pages with content.
npm install -g @kitakitsune/notion-sync
Requires Node.js >= 18.
notion-sync init --token ntn_xxx --page <notion-page-id> [--dir <path>]
.notion-sync.json in the target directorynotion-sync sync # sync everything
notion-sync sync --dry-run # preview changes
notion-sync sync --diff # only sync changed files
notion-sync sync --dir /some/path # sync a specific directory
notion-sync status # show sync state
notion-sync ignore list # list ignore patterns
notion-sync ignore add "*.env" # add ignore pattern
node_modules, .git, dist, .notion-sync.json, *.lock, *.log
import { syncWorkspace, initConfig, loadConfig, saveConfig } from '@kitakitsune/notion-sync';
import type { NotionSyncConfig } from '@kitakitsune/notion-sync';
const config = loadConfig(process.cwd());
const result = await syncWorkspace(config, { dryRun: false, diffOnly: true });
// result.pushed - files that were synced
// result.skipped - files unchanged (when diffOnly)
// result.errors - files that failed
src/
cli.ts - Commander.js CLI (init, sync, ignore, status)
sync.ts - Core sync logic, Notion API calls, checksum diffing
config.ts - Load/save/init .notion-sync.json
types.ts - NotionSyncConfig interface
index.ts - Public API exports
bin/
notion-sync.js - CLI entry point
.notion-sync.json under checksums field. Used by --diff to skip unchanged files.folderCache avoids redundant API calls..notion-sync.json:
{ "path": "/absolute/path", "notion": { "token": "ntn_...", "rootPageId": "page-id" }, "ignore": ["node_modules", ".git", "dist", ".notion-sync.json", "*.lock", "*.log"], "checksums": { "src/index.ts": "md5hash" } }7w4.net小葱技能站收录全网优质技能,值得收藏。
npm run dev # watch mode (tsup)
npm run build # production build
Build uses tsup to bundle TypeScript to ESM format. Output goes to dist/.
这个 Skill 质量不错,功能设计完整,文档清晰易读,基本的同步和配置功能都能正常工作。优点是上手简单、支持增量同步和忽略模式,可以放心使用。不足之处在于更新文件时的处理方式存在一定风险,如果同步中途出错可能导致内容丢失;另外大文件夹同步速度可能较慢。总体来说适合小中型项目使用,如果需要处理重要数据,建议先做好备份。