ntn-skills 0.3.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,236 +1,270 @@
1
1
  <h1 align="center">ntn-skills</h1>
2
-
3
- <p align="center">Bring your Notion workflow library into an Agent or terminal.<br>Discover the right Skill, read its instructions, and keep one version for the whole task.</p>
4
-
2
+ <p align="center">Notion 3-table control plane and zero-latency local skill runtime for AI coding agents.</p>
5
3
  <p align="center">
6
4
  <a href="./README.md">English</a> · <a href="./README.zh-CN.md">简体中文</a>
7
5
  </p>
8
-
9
- <p align="center">
10
- <a href="#installation">Install</a> · <a href="#quick-start">Quick start</a> · <a href="#common-workflows">Workflows</a> · <a href="#agent-integration">Agent integration</a> · <a href="./docs/README.md">Docs</a>
11
- </p>
12
-
13
6
  <p align="center">
14
- <a href="./CHANGELOG.md"><img src="https://img.shields.io/badge/status-experimental-orange" alt="Status: experimental"></a>
15
- <a href="https://nodejs.org"><img src="https://img.shields.io/badge/runtime-Node.js%2022.22.3%2B%20(22.x)%20or%2024.20.0%2B-green" alt="Runtime: Node.js 22.22.3+ (22.x) or 24.20.0+"></a>
16
- <a href="./LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="License: MIT"></a>
7
+ <a href="#quick-start">Quick Start</a> ·
8
+ <a href="#how-it-works">How It Works</a> ·
9
+ <a href="#cli-reference">CLI Reference</a> ·
10
+ <a href="#security-privacy--data-boundaries">Security</a> ·
11
+ <a href="./INSTALL.md">Agent Setup (<code>INSTALL.md</code>)</a> ·
12
+ <a href="./assets/ntn-skills/SKILL.md">Built-in Guide (<code>SKILL.md</code>)</a>
17
13
  </p>
18
14
 
19
- ```bash
20
- ntn-skills list
21
- ntn-skills read 'Release Review'
22
- ```
15
+ ---
23
16
 
24
- `Release Review` is an example title; choose a Skill returned by your own `list`. The npm package, executable and entrypoint Skill are all **`ntn-skills`**. The entrypoint, content-maintenance and synchronization Skills are independently managed through the `ctl builtin` catalog; see [Agent integration](#agent-integration).
17
+ `ntn-skills` turns a **3-table Notion database** (`Sources`, `Skills`, `Files`) into a visual, cross-machine control plane for your AI Agent skills — while keeping **everyday skill consumption 100% local, immutable, and zero-latency** via standard symlinks (`~/.agents/skills`), managed directory copies (e.g. cloud sandboxes), and an auto-synthesized local directory skill (`skill-catalog`).
25
18
 
26
- Available on [npm](https://www.npmjs.com/package/ntn-skills). For source builds, see [Contributing](CONTRIBUTING.md#development-setup).
19
+ No MCP tool overhead on every prompt. No bloated git-submodule choreography across machines. Just clean local files for every agent host, and a clean Notion cockpit for you.
27
20
 
28
- ## Why use it?
21
+ ---
29
22
 
30
- You maintain reusable instructions in Notion, but an Agent only needs a few of them for its current task. `ntn-skills list` exposes names and descriptions so the Agent can choose a relevant workflow before loading its instructions. `read` loads the selected file and saves the complete Skill export locally.
23
+ ## Quick Start
31
24
 
32
- A task can outlive an edit in Notion. The first successful read returns a **snapshot**: a local, fixed version of the workflow and its files. Keep the returned refs for the task. Ordinary current-target reads may reuse content validated within five minutes; use `--refresh` to adopt a freshly validated remote version for a new task. Stable manual edits to committed Notion content are readable through that same current-page path; old pinned snapshots stay unchanged, and unfinished publications retain their original recovery guards.
25
+ Paste this single sentence into **Claude Code, Cursor, Pi, Codex, Grok Bot, Antigravity**, or any coding agent with shell access:
33
26
 
34
- After a complete read proves a committed native Skill and its source ZIP aligned, ordinary reads can revalidate root/reference metadata, complete inclusion and immutable attachment identity, then reuse all local files without repeated body reads or bundle downloads. `freshness.validation="metadata"` identifies this check; edits with unchanged reported versions can be missed. `--refresh` or explicit `--max-age 0` always validates complete bodies/resources. New machines and missing checkpoints use the full reader. See [read policy](docs/protocol.md#read-policy-and-cache-management).
35
-
36
- | When you want to… | Use |
37
- | --- | --- |
38
- | Find a workflow without loading the whole library | `list` |
39
- | Read instructions and supporting files from one version | `read`, then `files` |
40
- | Move a complete Skill between local files and Notion | `create`, `replace`, `export` |
41
- | Apply file and metadata changes to one pinned page | `apply` |
42
- | Subscribe Git Skills into Notion and keep them current | `sync upstream connect`, `sync upstream run` |
43
- | Keep an existing page and local Skill directory in sync | `sync local connect`, `sync local run` |
44
-
45
- ## Installation
46
-
47
- Install [Node.js](https://nodejs.org) **22.22.3+ within 22.x, or 24.20.0+**, which includes npm. Online operations also need the [official Notion CLI](https://developers.notion.com/cli) **`ntn`** with `api --notion-version` support; `ntn` 0.22.12 has been exercised with this project.
48
-
49
- Install the published release from the official npm registry:
50
-
51
- ```bash
52
- npm install --global ntn-skills --registry https://registry.npmjs.org
53
- ntn-skills --version
54
- ntn-skills --help
27
+ ```text
28
+ Read https://raw.githubusercontent.com/yoyooyooo/ntn-skills/main/INSTALL.md and set up ntn-skills for me.
55
29
  ```
56
30
 
57
- The version command prints the installed version; help lists the available commands. A consumer needs Node.js and npm. [Project-local installation](docs/usage.md#install-in-a-consuming-project), [PATH setup](docs/usage.md#install-from-npm-globally) and [local tarball installation](docs/usage.md#install-a-local-tarball-globally) are covered in the usage guide.
58
-
59
- To produce a package yourself, follow [the contributor setup and build instructions](CONTRIBUTING.md#development-setup). Bun installs dependencies and builds the package; development and real SQLite consumers execute on Node.js.
31
+ Your agent will inspect your machine, install the CLI (linking the built-in `ntn-skills` guide), help you store your Notion token in a `0600` local file (never pasted into chat), automatically create the 3 Notion tables on a blank page, enable background sync, and verify everything with `ntn-skills doctor` (`6/6 pass`).
60
32
 
61
- ## Quick start
62
-
63
- ### 1. Connect Notion
64
-
65
- Configure `ntn` through [its authentication guide](https://developers.notion.com/cli/get-started/authentication). Your connection needs Read content access to a database with rich-text `Description` and `References` properties. `References` lists Notion page mentions or page links; each linked page becomes a Markdown file under `references/`. The native Skills database/export mode is also supported for existing libraries.
66
-
67
- That database needs at least one valid Skill. Notion Name and authored frontmatter `name` are human-readable names preserved exactly: Unicode, digits, spaces and hyphens are allowed; names must be nonempty and contain no control characters. For example, `Tty7` stays `Tty7`, while its callable alias is `tty7`. Aliases normalize to NFC and lowercase, trim surrounding whitespace, replace whitespace runs with `-`, and percent-encode characters outside Unicode letters, marks, numbers, `_` and `-`. Aliases are selection values, never identity; collisions require an exact page ID or ref. `--name` explicitly overrides the human title without changing page identity. [Naming and database requirements](docs/protocol.md#identity-and-references).
68
-
69
- `ctl database init --parent PAGE_ID` creates a content table and a separate upstream subscription table under an owned page; attach exact existing tables with `--content-database ID --upstream-database ID`. It validates field types and native relation targets before publishing configuration. Repeat the same target to resume safely. The default write database stays independent unless `--set-default` is supplied.
70
-
71
- Content origin uses `Source Type` (`builtin`, `upstream`, `manual`) and exact rich-text `Builtin ID`, independently of Kind and Sync Mode. Explicit init upgrades existing tables, including repeated published attaches, without backfilling legacy rows. Ordinary create supports tables missing these fields; replace/write preserve provenance. Deliberate builtin/upstream publication requires the upgraded schema. Equal content with changed provenance is a metadata-only update; complete equality is mutation-free reuse. [Origin and frozen recovery](docs/protocol.md).
72
-
73
- Use `ntn-skills sync upstream connect SOURCE --database DATABASE` to register a Git source and synchronize its Skills. Repeating the same connection reuses its subscription. Later, `sync upstream run` takes either repeatable `--target SUBSCRIPTION_ID` or `--all`. Each run records status, attempt/success times and a summary; failed or partial batches continue other targets and exit nonzero. Advanced registration and plan/apply remain available under `sync upstream`. [Recurring synchronization and table setup](docs/usage.md#recurring-upstream-synchronization).
74
-
75
- Ordinary `run` checks retained work before planning new changes and restores an owned tracked member whose original page is confirmed readable in Notion Trash. The old page stays in Trash; a verified replacement updates that member's mapping. Missing or inaccessible pages are explicit failures. Historical rebuild, adoption and targeted repair commands belong to the separate [operator artifact](docs/historical-operations.md).
76
-
77
- The content table supports `Kind=skill|router|prompt`. Skill uses `SKILL.md`; Router uses `ROUTER.md` with member metadata and stable refs, and loads members only when the Agent selects them; Prompt uses `PROMPT.md` as an explicit user requirement on each submission. `list` returns `records` with kind, stable identity, locator and entrypoint. Reads and exports return the same `record` and fixed snapshot. Missing historical Kind means Skill.
78
-
79
- To create a Prompt or Router, stage a portable v2 manifest and body file, then use `create` with the existing flags: [complete Prompt/Router staging and commands](docs/usage.md#creating-a-prompt-or-router-from-portable-v2). Filename/frontmatter alone does not select kind; [portable input contract](docs/protocol.md#portable-input-contract).
80
-
81
- Automatic upstream subscription Routers require at least two verified published active Skills. Zero or one member produces no Router catalog entry; use the individual Skill ref for a single member. Current exact Router reads reject insufficient membership. Manually authored content-table Routers keep their explicit Members behavior. See [subscription and Router usage](docs/usage.md#initialize-content-and-subscription-tables).
82
-
83
- `Default Context` is an independent checkbox for each Skill or Router. Missing or unchecked means false. Prompt is always excluded from default discovery, background prefetch and native Skill installation; explicitly selecting it again adds its requirements to the new turn. Initialization creates the checkbox but never checks it automatically.
84
-
85
- Authentication priority is saved `config.token` → non-empty `NOTION_API_TOKEN` → existing `ntn login`. A saved token is plaintext in the private config file; `ctl config show` reports only whether it is configured. [Token setup and removal](docs/usage.md#authentication).
86
-
87
- ### 2. Check access and choose a workflow
33
+ <details>
34
+ <summary>Prefer manual installation?</summary>
88
35
 
89
36
  ```bash
90
- ntn-skills ctl doctor
91
- ntn-skills list
37
+ # 1. Install CLI via npm / Bun (Node >= 20 or Bun >= 1.2), or use install.sh --with-pi for Pi extension
38
+ npm install -g ntn-skills && ntn-skills skill --install
39
+ # Alternative (with Pi extension): curl -fsSL https://raw.githubusercontent.com/yoyooyooo/ntn-skills/main/scripts/install.sh | bash -s -- --with-pi
40
+
41
+ # 2. Save your Notion Integration token (0600 permissions; respects XDG_CONFIG_HOME)
42
+ mkdir -p "${XDG_CONFIG_HOME:-$HOME/.config}/ntn-skills"
43
+ cat > "${XDG_CONFIG_HOME:-$HOME/.config}/ntn-skills/credentials.env" <<'EOF'
44
+ NOTION_TOKEN=ntn_your_token_here
45
+ # Optional: GITHUB_TOKEN=ghp_...
46
+ EOF
47
+ chmod 600 "${XDG_CONFIG_HOME:-$HOME/.config}/ntn-skills/credentials.env"
48
+
49
+ # 3. Bootstrap a blank Notion page (defaults to prefetch=discoverable) + initial sync
50
+ ntn-skills init --root "https://www.notion.so/your-page-url"
51
+
52
+ # 4. Enable native background sync (launchd on macOS / systemd on Linux)
53
+ ntn-skills schedule install
54
+
55
+ # 5. Verify health (expect 0 fail)
56
+ ntn-skills doctor
57
+ ntn-skills skill # Print built-in agent guide shipped with this binary
92
58
  ```
93
59
 
94
- With a valid Skill available, `ctl doctor` should report `ok: true`, `authentication: "available"`, a positive `skill_count`, and `skill_read.available: true`. It reads and caches one Skill to verify the selected storage mode. `list` returns metadata and coverage without loading workflow bodies.
95
-
96
- Notion Search may miss databases. Read `coverage`; if you know the database, use `ntn-skills list --database 'DATABASE_ID_OR_URL'`, replacing that value with your database ID or URL.
97
-
98
- ### 3. Read the selected Skill
99
-
100
- Copy an entry's `ref` from `records` into this command, replacing the placeholder:
101
-
102
- ```bash
103
- ntn-skills read 'REF_FROM_LIST'
60
+ </details>
61
+
62
+ ---
63
+
64
+ ## Prerequisites & Supported Platforms
65
+
66
+ - **OS**: macOS (launchd background timer, Finder Trash) and Linux (systemd user timer, XDG Trash). Windows is supported via WSL2.
67
+ - **Runtime**: `git` plus **Node.js `>= 20`** (via `npm install -g ntn-skills`) or **[Bun](https://bun.sh) `>= 1.2.0`**.
68
+ - **Notion**: A [Notion Internal Integration](https://www.notion.so/profile/integrations) token granted access to one blank Notion page (or an existing `ntn-skills` root page).
69
+ - **Host Compatibility**: Works out of the box with Claude Code, Codex, Cursor, Pi, Antigravity, Grok Bot (`${HOME}/agent-data/workflows:copy`), and any agent reading Markdown skills from disk.
70
+
71
+ ---
72
+
73
+ ## How It Works
74
+
75
+ You do **not** need to memorize CLI flags for daily use. `ntn-skills` separates **what you do as a human** from **how your agents consume or maintain skills**.
76
+
77
+ ### 1. The Human Perspective (What You Care About)
78
+
79
+ 1. **Tweaking Properties Directly in Notion (Desktop or Mobile)**
80
+ - **What you do**: Change `Visibility` (`always` for top-level daily skills, `discoverable` for curated on-demand skills indexed into `skill-catalog`, `manual` for silent external reserves), edit `Description` triggers, organize `Scenes` / `Profiles`, or uncheck `Enabled`.
81
+ - **How it takes effect**: Just close the tab. Each machine's 12-minute background sync updates local symlinks and rebuilds `skill-catalog` automatically — or tell your agent *"sync my skills"* (`ntn-skills sync`) to apply immediately.
82
+
83
+ 2. **Editing `SKILL.md` Body Text in Notion (One Important Distinction)**
84
+ - **Notion-native draft skills (`Origin` is empty)**: The Notion page body *is* the single source of truth. Any edit you make in Notion flows straight to your machines on sync (`ntn-skills sync --full` forces an immediate body refresh if Notion omits page-body timestamps).
85
+ - **Upstream Git skills (`Origin` is set)**: By default (`Custom Main` unchecked), the Notion page body is a **read-only preview mirror** of the upstream Git file, and local consumption follows Git. If you intentionally edit an upstream skill's body in Notion and want machines to consume your version, **check `Custom Main`** (otherwise `sync` surfaces a drift warning so you never wonder why a web edit didn't go live).
86
+
87
+ 3. **Live-Patching an Upstream Skill Without Forking Its Repo**
88
+ - **What you do**: Tell your agent in plain language: *"Add our local directory conventions and a helper script to the `dagu` skill and push the patch to Notion so I can test it this week."*
89
+ - **What happens**: Your agent runs an isolated `edit -> diff --remote -> push` cycle, setting `Custom Main = true` and recording `override / delete` entries in `Files`. Every machine immediately consumes the merged UnionFS snapshot (Upstream Git + Notion overlay).
90
+ - **Two clean exits**:
91
+ - Discard the experiment: say *"Revert local overlays on `dagu`"* (`reset-overlay`) to snap back to clean upstream in one second.
92
+ - Graduate into your personal Git repo: say *"Export `dagu` cleanly into my personal skills repo"* (`pull --clean` + `attach` / `upstream apply`). Once upstream Git catches up, redundant Notion overlays auto-archive back to zero.
93
+
94
+ 4. **Incubating a Temporary Local Skill First, Then Saving It to Notion**
95
+ - **Incubate locally**: Have your agent create a plain local skill folder right inside `~/.agents/skills/<temp-skill>/` and iterate across local sessions without touching Notion (background sync never touches unmanaged local folders, and `sync` reports unmanaged local candidates under `Local Pending`).
96
+ - **Save & adopt in place**: Once happy, tell your agent *"Save `<temp-skill>` to Notion"* (`ntn-skills new ~/.agents/skills/<temp-skill> [--always | --discoverable]`). After Notion upload succeeds, `ntn-skills` automatically moves the temporary folder to OS Trash and seamlessly replaces it with an immutable managed symlink (`always`) or indexes it into `skill-catalog` (`discoverable`).
97
+
98
+ 5. **Collecting Huge External Repos + Checking Governance Health**
99
+ - Import 200-skill community repos safely as `manual` (zero context cost); import your own primary repo with `--discoverable`.
100
+ - Run `ntn-skills status` anytime to see 30-day on-demand `Hot Loads` (promote frequent winners to `always`), active `Overlays`, and `Draft Buffer` candidates ready to graduate to Git.
101
+
102
+ ### 2. The Agent Perspective (99% Consumer Mode vs. 1% Maintainer Mode)
103
+
104
+ | Mode | When Active | What the Agent Sees & Does |
105
+ | :--- | :--- | :--- |
106
+ | **Consumer Mode (99% of sessions)** | Normal coding, research, design, and ops tasks | **Zero Notion awareness, zero network calls**:<br>1. **`always` skills**: Linked directly at `~/.agents/skills/<name>` (or copied for `:copy` targets) for `0 ms` reads.<br>2. **`discoverable` skills**: Every host sees one auto-synthesized read-only skill **`skill-catalog`**. When a specialized task arises, the agent reads `skill-catalog/SKILL.md` -> `references/<scene>.md` -> directly `Read`s the pre-materialized local `store/.../SKILL.md` (two pure file reads, no plugins required).<br>3. **`manual` skills**: Hidden from default context and `skill-catalog`; woken on demand via `$skill` / `skill_find` / `skill_load` in Pi, strategy routers, or `ntn-skills load`.<br>4. **Read-only rule**: `store/` snapshots are `0444/0555` immutable; agents never edit them in place. |
107
+ | **Maintainer Mode (1% of sessions)** | Only when you ask to set up, import, create, patch, or diagnose skills | Reads the built-in **`ntn-skills`** guide shipped with the CLI (or runs `ntn-skills skill`), executes isolated `new / set / edit / diff --remote / push` workflows, and moves temporary workdirs to OS Trash on completion. |
108
+
109
+ ---
110
+
111
+ ## Architecture
112
+
113
+ ```mermaid
114
+ flowchart LR
115
+ subgraph Control["Notion Control Plane (Human Visual Cockpit)"]
116
+ SRC["Sources
117
+ (Upstream & Private Git Repos)"]
118
+ SKL["Skills
119
+ (Visibility / Scenes / SKILL.md)"]
120
+ FIL["Files
121
+ (Draft Assets & Overlay Diffs)"]
122
+ end
123
+
124
+ subgraph Local["Local Runtime ($XDG_DATA_HOME/ntn-skills)"]
125
+ CAT["catalog.json & manifest.json
126
+ (Delta Watermark + Static Lockfile)"]
127
+ STO["Immutable Store
128
+ (0444/0555 · always + discoverable prefetched)"]
129
+ end
130
+
131
+ subgraph Hosts["Host-Agnostic Zero-Latency Consumption"]
132
+ EXP["~/.agents/skills/ or :copy target
133
+ (always skills + auto skill-catalog)"]
134
+ ANY["Any Agent Host (Claude Code / Codex / Grok Bot / Cursor / Antigravity)
135
+ 2-hop pure file Read"]
136
+ PI["Pi Extension
137
+ ($skill inline injection + skill_find / skill_load)"]
138
+ end
139
+
140
+ SRC --> SKL
141
+ FIL --> SKL
142
+ Control -- "12m delta sync
143
+ (launchd / systemd)" --> CAT
144
+ CAT --> STO
145
+ STO -- "Atomic Symlink / Copy" --> EXP
146
+ EXP --> ANY
147
+ CAT --> PI
148
+ STO --> PI
104
149
  ```
105
150
 
106
- A successful response contains `ok: true`, instructions in `content`, a `snapshot_id` starting with `s_`, and a pinned `ref` containing `?snapshot=...`. `source: "notion"` means online validation; `source: "local_cache"` means a bounded cached observation. Retain `freshness`, the ref and snapshot ID with your task. Add `--refresh` to the current ref when current remote access/content must be checked. [Response fields](docs/protocol.md#success).
107
-
108
- ### 4. Read supporting files from the same version
151
+ ---
109
152
 
110
- Replace each placeholder with the value returned by the preceding command:
153
+ ## Minimal 3-Table Notion Schema
111
154
 
112
- ```bash
113
- ntn-skills files 'SNAPSHOT_ID_FROM_READ'
114
- ntn-skills read 'ATTACHMENT_REF_FROM_FILES'
115
- ```
155
+ Created automatically by `ntn-skills init --root <blank-page-url>`:
116
156
 
117
- Use the snapshot ID to list **all** files; passing a file ref lists only that file. Read an attachment actually returned by `files`. Its pinned ref uses the same snapshot and returns `source: "local_snapshot"`, even without authentication or network access. Historical versions are available only if already saved on this machine.
157
+ | Table | Purpose | Key Properties |
158
+ | :--- | :--- | :--- |
159
+ | **`Sources`** | Upstream & private Git skill repositories | `Name`, `Repo URL`, `Ref`, `Pinned Commit`, `Policy` (`track \| pinned \| manual`), `Enabled`, `Last Checked`, `Skills` |
160
+ | **`Skills`** | Master catalog, 3-tier routing & `SKILL.md` body | `Name`, `Description`, `Enabled`, `Visibility` (`always \| discoverable \| manual`), `Kind` (`skill \| router \| prompt`), `Profiles`, `Scenes`, `Requires`, `Origin`, `Source Path`, `Custom Main`, `Revision`, `Preview Hash`, `Status`, `Supporting Files` |
161
+ | **`Files`** | Draft supporting files & upstream diff overlays | `Name`, `Skill`, `Path`, `Status` (`override \| delete`), `Executable`, `SHA256`, `External URL`, `Attachment` |
118
162
 
119
- For a binary attachment, add `--output ./attachment.bin` and use an appropriate viewer. For text, use `--lines 10-30` for an inclusive line range or `--raw` for plain UTF-8 output. Scripts are never executed automatically.
163
+ > **Subtree-Hash Pruning & Zero Redundancy**: Unmodified upstream skills store **0 rows** in `Files` (an auto-maintained read-only `Upstream Files` child page at row 1 of each Skill page shows the upstream file tree). When a multi-skill upstream repo gets a new commit, untouched sibling skills incur **0 Notion writes** and keep a stable `effectiveRev`.
120
164
 
121
- ## Common workflows
165
+ ---
122
166
 
123
- ### Keep workflow libraries separate
124
-
125
- Register a known database as a domain, then select it explicitly. Replace the database placeholder before running:
167
+ ## CLI Reference
126
168
 
169
+ ### Setup, Built-in Guide & Diagnostics
127
170
  ```bash
128
- ntn-skills ctl database register ops --database 'DATABASE_ID_OR_URL'
129
- ntn-skills list --database ops
130
- ntn-skills read 'Release Review' --database ops
171
+ # Omit --root when re-initializing if default_library is already set in XDG config
172
+ ntn-skills init [--root <notion-page-url>] [--export ~/.agents/skills] [--export '${HOME}/agent-data/workflows:copy'] [--profile default] [--prefetch discoverable]
173
+ ntn-skills skill [--path] [--install [--dest ~/.agents/skills] [--force]] [--uninstall]
174
+ ntn-skills doctor [--json]
175
+ ntn-skills status [--days 30] [--json]
176
+ ntn-skills sync [--full] [--coalesce] [--json]
177
+ ntn-skills find [query] [--scene <scene>] [--visibility always|discoverable|manual] [--kind skill|router|prompt] [--json]
178
+ ntn-skills info <name> [--json]
179
+ ntn-skills load <name> [--refresh] [--path-only]
131
180
  ```
132
181
 
133
- Database aliases are exact and case-sensitive. If two databases have the same Skill name, select a database or use a page-ID ref from `list`. Registered sources supplement automatic discovery. [Discovery, aliases and coverage](docs/usage.md#discovery-and-identity).
134
-
135
- ### Import, export or update a Skill
136
-
137
- A Skill can be a folder, ZIP, or Markdown file. Preview remote changes before applying them:
138
-
182
+ ### Editing, Batch Metadata, Drafts & Overlay Tuning
139
183
  ```bash
140
- ntn-skills create ./my-skill --database ops --dry-run
141
- ntn-skills create ./my-skill --database ops
142
- ntn-skills export 'My Skill' --database ops --output ./my-skill.zip
143
- ntn-skills apply 'PINNED_MAIN_REF_FROM_READ' --input ./changed-files --dry-run
184
+ # Safe isolated edit workflow (never mutates read-only store/)
185
+ WORKDIR=$(ntn-skills edit "<name>")
186
+ ntn-skills diff "$WORKDIR" --remote
187
+ ntn-skills push "$WORKDIR" [--dry-run]
188
+ ntn-skills abort "$WORKDIR"
189
+
190
+ # Create/adopt a Notion-native draft skill & single/batch update metadata
191
+ ntn-skills new <dir> [--name <name>] [--visibility always|discoverable|manual] [--profiles default] [--scenes ops] [--no-adopt]
192
+ ntn-skills set [<name...>] [--source <source-name>] \
193
+ [--visibility always|discoverable|manual | --always | --discoverable | --manual] \
194
+ [--kind skill|router|prompt] [--enable|--disable] [--add-profile <p>] [--add-scene <s>] [--require <dep>]
195
+
196
+ # Graduate draft or overlay back to Git, or revert overlays
197
+ ntn-skills pull <name> <git-repo-skill-dir> --clean
198
+ ntn-skills attach <name> --source <source-name> [--path <repo-relative-dir>]
199
+ ntn-skills detach <name>
200
+ ntn-skills reset-overlay <name> [<file-path>]
201
+ ntn-skills rm <name> # Soft retire (never hard-deletes)
144
202
  ```
145
203
 
146
- `create` requires a new name. For an existing page, `apply` combines sparse changed files, optional repeated `--remove PATH` and explicit metadata flags against one pinned main ref or snapshot. Put only the files being added or changed in `./changed-files`; all other files remain. Remove `--dry-run` to execute the reviewed change. A stale baseline fails before publication. `write` and `update` remain available for individual file/property operations. [Inputs, conflicts and partial outcomes](docs/usage.md#creating-importing-exporting-and-updating-skills).
147
-
148
- Use `replace ./my-skill --target 'CURRENT_PAGE_ID_OR_PINNED_MAIN_REF' --database ops --dry-run` to replace a selected existing page deliberately. `--target` preserves that page identity even when imported name/description changes; a missing, inaccessible or stale target fails without creating a page or falling back to its imported name.
149
-
150
- For an authorized ordinary import, the command's exit 0, `ok: true` and `verified: true` (without `dry_run: true`) are the completion check. The CLI reads back main/reference content and the complete file identity; Files mode also preserves and verifies exact source bytes. No routine read/files/export audit is needed. This checks storage, not execution of the imported workflow.
151
-
152
- The goal is complete instructions, code, links and resources across upstream → Notion and current Notion → Markdown/cache → Agent, not arbitrary byte-identical bidirectional round trips. Native Markdown permits documented formatting normalization and rejects changed instructions. For text-only Skills, explicit `--storage markdown_files` stores editable literal files in Notion and consumes those live code bytes without a source-ZIP fallback. [Storage, normalization and recovery](docs/protocol.md#mutation-contract).
153
-
154
- ### Synchronize a local distribution directory
155
-
156
- Replace `PAGE_ID` with an actual selected page ID. The binding label is local configuration, separate from the Skill's invocation alias.
157
-
204
+ ### Upstream Git Sources & Scheduling
158
205
  ```bash
159
- ntn-skills sync local connect PAGE_ID --path ~/.agents/skills/release-review --as release-review-global
160
- ntn-skills sync local run release-review-global
161
- ntn-skills sync local status release-review-global
206
+ # Onboard Git repos (community repos default to manual; pass --discoverable for personal primary repos)
207
+ ntn-skills source add <repo-url> [--name <name>] [--ref main] [--root skills] [--policy track|pinned|manual] [--discoverable] [--scenes ops,coding]
208
+ ntn-skills source list
209
+ ntn-skills source sync <name> [--update-pinned]
210
+ ntn-skills upstream check [<source>]
211
+ ntn-skills upstream apply [<source>] [--dry-run] [--max-sources 10] [--timeout-sec 180]
212
+
213
+ # Native OS background timers (macOS launchd / Linux systemd) & CI/CD exports
214
+ ntn-skills schedule install [--sync-every 12m] [--full-at 04:12] [--upstream-every 6h]
215
+ ntn-skills schedule status
216
+ ntn-skills schedule uninstall
217
+ ntn-skills schedule export --target dagu|github-actions|crontab
162
218
  ```
163
219
 
164
- A missing directory initializes from Notion. Existing differing contents require an explicit `--from local|notion`; later runs compare both sides with the confirmed common baseline and preserve conflicts. Repeating the same connection reuses its binding. Retained receipts settle only when observations confirm convergence; unresolved outcomes keep their original operation IDs and next action.
220
+ ---
165
221
 
166
- Advanced `bind`, `plan` and `apply --plan` support separately reviewed plans. Apply rechecks the saved binding, versions, content and logical/resolved path. Status is provisional unless `--refresh` is used; `unbind` retains content, baselines, plans and receipts. Symlink paths retain their links, and removed/replaced bytes go through system Trash retention. See [sync usage](docs/usage.md#synchronizing-local-skills).
222
+ ## Pi Extension
167
223
 
168
- ### Maintain reference pages in Notion
224
+ Install with `--with-pi` (or link `packages/pi-extension` into `~/.pi/agent/extensions/ntn-skills`) to unlock:
225
+ - **Inline `$skill-name` triggers**: Type `$my-long-tail-skill` in any prompt — even if its `Visibility` is `discoverable` or `manual` — and Pi automatically materializes it into the immutable local store and injects its path into the turn;
226
+ - **`skill_find` & `skill_load` tools**: Search the local catalog by keyword, `scene`, `visibility`, or `kind` (0 network requests), load long-tail skills on demand, and record `Hot Loads` usage counts.
169
227
 
170
- Add page mentions or links to the rich-text `References` property. A link labeled `references/guide.md` fixes the local path; otherwise the page title determines its filename. Write normal Notion page links in the instructions: reads and exports turn links to included pages into relative paths such as `./references/guide.md`. Links between reference files resolve from the containing file, and CLI writes restore the Notion URLs. Other websites and code examples remain unchanged.
228
+ ---
171
229
 
172
- `create` and `replace` turn `references/**/*.md` into editable child pages. `write` updates the page behind a reference path. Removing a reference from an imported file set excludes it from new snapshots but retains the Notion page. `Files` is optional for page-only libraries; keep it when preserving original source bytes, extra frontmatter or non-Markdown assets. See [the References contract](docs/protocol.md#references-pages).
230
+ ## Security, Privacy & Data Boundaries
173
231
 
232
+ - **Zero Consumer-Time Network Access**: Everyday skill consumption reads immutable local files (`0444/0555`) under `$XDG_DATA_HOME/ntn-skills/store/` (default `~/.local/share/ntn-skills/store/`). Network requests to `api.notion.com` and your configured Git remotes happen only during explicit CLI invocations or scheduled sync jobs.
233
+ - **Local-Only Credentials & Telemetry**: `credentials.env` lives under `$XDG_CONFIG_HOME/ntn-skills/` (default `~/.config/ntn-skills/credentials.env`) with enforced `0600` permissions. Usage counters (`telemetry/usage.jsonl`) and bounded sync logs (`2 MiB` rotation) never leave your machine.
234
+ - **Foreign Directory Guard & Trash-Only Cleanup**: `export` never overwrites unmanaged files or symlinks inside host skill directories. Workdir and expired cache cleanups move files to the OS Trash rather than permanently unlinking them; retiring skills in Notion marks `Status = retired`.
235
+ - **Formal Verification**: Core concurrency locks, overlap-window delta sync, and atomic snapshot switching are verified with TLA+ specifications under [`verification/`](https://github.com/yoyooyooo/ntn-skills/tree/main/verification).
174
236
 
175
- ## Agent integration
237
+ ---
176
238
 
177
- The package provides three Skills with separate responsibilities. Make the entrypoint discoverable by default; load a Skill's body only when its task is relevant. “Official” means maintained by this project.
239
+ ## Scope & Non-Goals
178
240
 
179
- | Builtin ID | Responsibility |
180
- | --- | --- |
181
- | `notion/ntn-skills` | [Discover/read workflows and route tasks](skills/ntn-skills/SKILL.md) |
182
- | `notion/ntn-skills-maintain` | [Maintain Notion content, References and portable copies](skills/notion/ntn-skills-maintain/SKILL.md) |
183
- | `notion/ntn-skills-sync` | [Connect sources and local directories, run synchronization and recover original operations](skills/notion/ntn-skills-sync/SKILL.md) |
241
+ - **Focused on Agent Skills**: `ntn-skills` governs Markdown/script-based Agent Skills (`SKILL.md` + supporting references/scripts). It is **not** an MCP server proxy, secret manager, or general machine provisioning tool.
242
+ - **One-Way Sync by Design**: `ntn-skills sync` strictly pulls from Notion/Git to local snapshots and reports `Local Pending` items without silently pushing local scratch edits to Notion. Publishing always requires explicit `new` or `edit -> diff --remote -> push`.
184
243
 
185
- With Context Broker, select `$ntn-skills@builtin`, `$ntn-skills-maintain@builtin` or `$ntn-skills-sync@builtin` through ordinary `$` discovery on Pi/OMP/Tern. Their packaged bodies and references work without a Notion source or separate local installation. `/context-broker` owns session/View/refresh controls; content tasks use the selected Skill and public CLI. [Bundled Skills in hosts](docs/host-integration.md#bundled-skills-in-hosts).
244
+ ---
186
245
 
187
- The CLI can also inspect package instructions offline. To keep independently managed local copies for other consumers, use explicit installation:
246
+ ## Upgrade & Uninstall
188
247
 
189
248
  ```bash
190
- ntn-skills ctl builtin list
191
- ntn-skills ctl builtin read notion/ntn-skills
192
- ntn-skills ctl builtin install notion/ntn-skills
193
- ntn-skills ctl builtin install notion/ntn-skills-maintain
194
- ntn-skills ctl builtin install notion/ntn-skills-sync
195
- ntn-skills ctl builtin status
196
- ntn-skills ctl builtin update notion/ntn-skills
197
- ```
198
-
199
- `install`, `status` and `update` work offline without credentials. Managed files live in `${XDG_DATA_HOME:-~/.local/share}/ntn-skills/skills/<name>`, with a default symlink at `~/.agents/skills/<name>`. Repeat `--agent-dir DIR` to add other Agent roots; each receives `DIR/skills/<name>` pointing to the same installation. Targets persist for later updates. Complete file receipts protect local edits and unowned directories; replaced bytes go to system Trash. Receipt-v1 profiles require the independent migration artifact; normal commands preserve them and report a conflict. Reload/restart native discovery after installation; upgrading the npm package does not update installed Skills. Broker selections use their bundled package copies; these explicit local installations have their own update lifecycle. [Host entrypoints](docs/host-integration.md#bundled-skills-in-hosts).
200
-
201
- `ctl builtin export` remains portable output. Publishing to Notion is a separate online operation: optionally configure `ctl config set builtin_database ops`, then preview `ctl builtin publish notion/ntn-skills-maintain --dry-run`. First publication rejects any same-name page; deliberate updates require `--target` with an exact page identity or pinned baseline. Remote pages never become official by name or publisher text. [Commands, receipts and collision rules](docs/usage.md#optional-official-skills).
202
-
203
- With the OMP/Pi Context Broker enabled, a short `<ntn-skills-guidance>` block explains the actual CLI and source scope. The selected Notion View supplies Skill/Router names and descriptions, not bodies. A source's `default_view_id` wins; when absent, the first View in API order is used. `Default Context` is an ordinary checkbox used only when the View filters on it. Startup may prepare metadata and snapshots without a model request. The first user submission receives the selected directory before the provider call; changing the View replaces this directory on the next submission without withdrawing loaded bodies. Full `$` selection and unfiltered CLI discovery remain available. Installing the bootstrap Skill alone does not install the Broker. [Host integration contract](docs/host-integration.md).
204
-
205
- Inspecting or maintaining a Skill does not activate its instructions. Hosts activate only a workflow selected for the current task and retain its freshness metadata; no downloaded content or script executes automatically.
206
-
207
- `pi-context-broker` provides a one-way Notion source adapter in its own repository using metadata-only `list`, page-ID `read` and pinned directory `export`. It prepares selected-View records after discovery and other records on selection, without activating instructions until consumed. Consumers retain scope, coverage and snapshot identities, match export `main_path` to manifest `main`, and load that entry with its supporting files. The broker owns host integration; this repository does not install it or register host hooks. See [the broker consumption contract](docs/host-integration.md#broker-source-consumption). Source acceptance recipes live in this checkout's verification Skill; package consumers use the public contract and installed CLI.
208
-
209
- ## Boundaries and local data
249
+ # Upgrade to the latest release (preserves config, credentials, and local store)
250
+ npm install -g ntn-skills@latest # or re-run scripts/install.sh if installed from source
210
251
 
211
- - Historical local verification covered npm installation and seeded offline behavior on macOS arm64 with Node.js 24.20.0 and Linux arm64 with Node.js 22.19.0; the latter is now unsupported. Real Notion reads were verified on macOS with `ntn` 0.22.12. CI is configured for Node.js 22.22.3 and 24.20.0 on Ubuntu and macOS 15; configured jobs do not establish successful runs for a new change. Windows is unverified.
212
- - Content mutations, `ctl builtin publish` and sync `connect/run/apply` can change content. Publications support `--progress` on stderr and retain frozen input/receipts; use `operation resume OPERATION_ID` for guarded publication continuation. Unresolved writes remain explicit. Local sync checks retained receipts and reports the original operation and next action when convergence remains unresolved. Client version checks are not atomic commits. [Publication recovery](docs/usage.md#creating-importing-exporting-and-updating-skills).
213
- - Configuration defaults to `~/.config/ntn-skills/config.json`; retained snapshots, uploads and sync recovery state to `~/.local/state/ntn-skills`; disposable observations to `~/.cache/ntn-skills`. Managed builtins use `~/.local/share/ntn-skills`, overridden by `NTN_SKILLS_DATA_HOME` or the XDG data base. Freshness defaults are five minutes for content and 60 seconds for catalogs. [Cache policy and cleanup](docs/usage.md#cache-policy-and-cleanup) explain overrides and system Trash retention.
214
- - Online operations use `ntn` and Notion's signed download URLs. Safe local identity is required for unpinned offline lookup; official-login identity may still require online checks. A cached observation does not prove present access. The CLI sends no telemetry requests of its own; `ntn` has its own policies. Imported scripts are never executed automatically.
215
-
216
- See [configuration and storage](docs/protocol.md#environment-and-local-storage), [error recovery](docs/protocol.md#errors), and [security and privacy](SECURITY.md).
217
-
218
- ## Upgrade and uninstall
219
-
220
- For a tarball installation, obtain the newer built package and repeat the npm installation command. Read [the changelog](CHANGELOG.md) before a 0.x minor upgrade. Source builds follow [the contributor instructions](CONTRIBUTING.md#development-setup).
221
-
222
- Remove a global installation with `npm uninstall --global ntn-skills`. Configuration, cache, retained state, installed builtin data and its distribution links remain afterward. Preserve pinned versions, sync baselines/plans and unfinished receipts. To remove a saved token, run `ntn-skills ctl config clear-token` before uninstalling. Upgrade retains state/config and rebuilds disposable observations in the cache root; use `--refresh` in callers that previously assumed every unpinned read was fresh. [Removal and optional retention](docs/usage.md#upgrade-and-uninstall) explain what to preserve.
252
+ # Uninstall cleanly (never deletes your Notion database)
253
+ ntn-skills schedule uninstall
254
+ ntn-skills skill --uninstall
255
+ # Then move ~/.local/share/ntn-skills, ~/.config/ntn-skills, and ~/.local/bin/ntn-skills to Trash
256
+ ```
223
257
 
224
- ## Documentation and contributing
258
+ ---
225
259
 
226
- | Next step | Guide |
227
- | --- | --- |
228
- | Installation variants and everyday CLI usage | [Usage guide](docs/usage.md) |
229
- | Selectors, JSON output, storage and errors | [CLI and ref contract](docs/protocol.md) |
230
- | Startup metadata and Read/Write adapters | [Host integration](docs/host-integration.md) |
231
- | Development setup and compatibility policy | [Contributing](CONTRIBUTING.md) |
232
- | Publishing and release verification | [Releasing](docs/releasing.md) |
260
+ ## Development, Contributing & License
233
261
 
234
- Use [GitHub issues](https://github.com/yoyooyooo/notion-skills-cli/issues) for sanitized bug reports and usage questions; vulnerabilities use [private reporting](SECURITY.md#reporting-a-vulnerability). To develop or build the CLI, start with [Contributing](CONTRIBUTING.md).
262
+ ```bash
263
+ bun install
264
+ bun run check # Runs biome lint + tsc typecheck + 28 invariant & unit tests
265
+ ```
235
266
 
236
- [Documentation index](docs/README.md) · [Changelog](CHANGELOG.md) · [MIT license](LICENSE)
267
+ - [Contributing Guide (`CONTRIBUTING.md`)](./CONTRIBUTING.md)
268
+ - [Security Policy (`SECURITY.md`)](./SECURITY.md)
269
+ - [Changelog (`CHANGELOG.md`)](./CHANGELOG.md)
270
+ - [MIT License (`LICENSE`)](./LICENSE)