ntn-skills 0.2.0 → 2.0.0
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/CHANGELOG.md +13 -83
- package/CONTRIBUTING.md +19 -43
- package/INSTALL.md +132 -0
- package/LICENSE +1 -1
- package/README.md +212 -132
- package/README.zh-CN.md +215 -134
- package/SECURITY.md +13 -32
- package/assets/ntn-skills/SKILL.md +187 -0
- package/dist/bin.js +9054 -0
- package/package.json +26 -44
- package/THIRD_PARTY_NOTICES.md +0 -25
- package/dist/ntn-skills.js +0 -6223
- package/docs/README.md +0 -14
- package/docs/host-integration.md +0 -68
- package/docs/protocol.md +0 -199
- package/docs/releasing.md +0 -94
- package/docs/usage.md +0 -243
- package/skills/ntn-skills/SKILL.md +0 -53
- package/skills/ntn-skills/references/commands.md +0 -100
- package/skills/ntn-skills/references/integration.md +0 -44
package/docs/usage.md
DELETED
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
# Usage guide
|
|
2
|
-
|
|
3
|
-
Start with [English](../README.md#quick-start) or [简体中文](../README.zh-CN.md#快速开始) for the first successful read. This guide covers installation variants and everyday operations. The [protocol](protocol.md) owns exact command, response and storage semantics; the [documentation index](README.md) routes to host integration and publishing.
|
|
4
|
-
|
|
5
|
-
## Installation options
|
|
6
|
-
|
|
7
|
-
Install [Node.js 22.19.0 or newer](https://nodejs.org), including npm. Online use also needs the [official Notion CLI](https://developers.notion.com/cli). [Source builds](../CONTRIBUTING.md#development-setup) use Bun 1.4.3.
|
|
8
|
-
|
|
9
|
-
### Install from npm globally
|
|
10
|
-
|
|
11
|
-
Install from the official registry:
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
npm install --global ntn-skills --registry https://registry.npmjs.org
|
|
15
|
-
ntn-skills --help
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
On Unix, npm installs global executables under `$(npm prefix --global)/bin`; ensure that directory is on PATH. If it is missing, add it to your shell configuration:
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
export PATH="$(npm prefix --global)/bin:$PATH"
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
### Install a local tarball globally
|
|
25
|
-
|
|
26
|
-
For an offline or unpublished build, replace the archive path with the file supplied by a maintainer:
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
npm install --global /absolute/path/ntn-skills-VERSION.tgz
|
|
30
|
-
ntn-skills --help
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
The filename follows the package version. Global PATH setup is the same as for registry installation.
|
|
34
|
-
|
|
35
|
-
### Install in a consuming project
|
|
36
|
-
|
|
37
|
-
From the consuming project's root:
|
|
38
|
-
|
|
39
|
-
```bash
|
|
40
|
-
npm install ntn-skills --registry https://registry.npmjs.org
|
|
41
|
-
export PATH="$PWD/node_modules/.bin:$PATH"
|
|
42
|
-
ntn-skills --help
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
This consumes the built package with Node.js. Global and project-local installs use the same package boundary. Build and pack steps belong to [Contributing](../CONTRIBUTING.md#development-setup).
|
|
46
|
-
|
|
47
|
-
To pin a published version, use `ntn-skills@VERSION`. To consume a local tarball instead, replace the package name with its absolute archive path.
|
|
48
|
-
|
|
49
|
-
## Authentication
|
|
50
|
-
|
|
51
|
-
Authentication priority is non-empty `config.token` → non-empty `NOTION_API_TOKEN` → existing `ntn login`. Configure `ntn` through [its authentication guide](https://developers.notion.com/cli/get-started/authentication), or pipe one token from a trusted secret source into `ntn-skills config set-token --stdin`. Never place a token in a command argument or a report.
|
|
52
|
-
|
|
53
|
-
The saved token is plaintext in the private configuration file. `set-token` works offline and validates input shape, not remote access. `config show` exposes `token_configured` and omits the token. Check access with `doctor`. Remove a saved token with `config clear-token` to restore environment/login fallback. Both commands preserve sources and the default database. The CLI never starts login or reads `ntn`'s private credential files.
|
|
54
|
-
|
|
55
|
-
Read content and an accessible database with rich-text Description/References are sufficient for page-based reads. Existing native Skills databases use the Skills export API when References is absent. Mutations require Insert/Update content; uploads additionally require a Files property. `doctor` reads and caches one available Skill and reports skill_read.storage.
|
|
56
|
-
|
|
57
|
-
Eligible cached reads require a locally distinguishable credential/workspace/endpoint scope. With existing official `ntn login`, the CLI may need online identity validation even for an otherwise warm read; unpinned `--offline` lookup fails when scope cannot be determined safely. Explicit pinned snapshots remain offline and can outlive remote permission. Never infer current authorization from cached bytes.
|
|
58
|
-
|
|
59
|
-
## Discovery and identity
|
|
60
|
-
|
|
61
|
-
Default discovery paginates Notion Search and accepts native Skills databases or data sources with rich-text Description and References. Registered sources supplement Search. Search is eventually consistent and [does not guarantee exhaustive enumeration](https://developers.notion.com/reference/search-optimizations-and-limitations). A missing result means absent from the discovered scope, not necessarily from the workspace.
|
|
62
|
-
|
|
63
|
-
Replace database placeholders before running:
|
|
64
|
-
|
|
65
|
-
```bash
|
|
66
|
-
ntn-skills source add frontend --database 'FRONTEND_DATABASE_ID_OR_URL'
|
|
67
|
-
ntn-skills source add ops --database 'OPS_DATABASE_ID_OR_URL'
|
|
68
|
-
ntn-skills database list
|
|
69
|
-
ntn-skills list --database frontend
|
|
70
|
-
ntn-skills read 'Release Review' --database ops
|
|
71
|
-
ntn-skills source list
|
|
72
|
-
ntn-skills list --refresh
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
Every `--database` accepts one ID, Notion URL or exact registered alias. Aliases are case-sensitive; database titles are display labels. Repeated selectors fail even when identical, and an inaccessible selection never falls back. `config set-default 'frontend'` stores the canonical ID and affects creation/import only. Omitting a selector for reads still discovers all visible and registered sources. Pinned reads with alias constraints resolve registrations locally and check the cached database ownership.
|
|
76
|
-
|
|
77
|
-
`list --query` filters Name, invocation alias and Description after pagination. It returns metadata plus the full queried `databases` map and `coverage`; bodies and file manifests are excluded. Join each Skill's `database_id` to that map. A Skill's invocation alias and its database's registered alias have different meanings. `database list` discovers databases without querying Skill rows. No custom Status field is assumed or silently filtered. Catalog observations default to 60 seconds; `list --refresh` validates online, and `--offline` deliberately uses an eligible stored catalog without upgrading its coverage.
|
|
78
|
-
|
|
79
|
-
Notion Names use ASCII English letters with single spaces, no surrounding spaces, and at most 64 characters. Lowercasing and replacing spaces with hyphens yields the invocation name: `Release Review` → `release-review`. References mode generates matching frontmatter from properties; native exports must have matching root/frontmatter names. Description and contents may use any language. Name lookup accepts exact display titles or invocation names; page IDs and page URLs select a specific Skill. Same-name collisions return `SKILL_AMBIGUOUS`; failed discovery prevents proving name uniqueness and returns `CATALOG_INCOMPLETE`. [Identity and selector contract](protocol.md#identity-and-references).
|
|
80
|
-
|
|
81
|
-
## Reading a fixed version
|
|
82
|
-
|
|
83
|
-
An unpinned read selects a complete snapshot from a recent eligible observation or validates online and saves it locally, while emitting only the requested file. The default content age limit is five minutes. Retain `read.ref`, `read.snapshot_id` and `freshness` for the task. Use `files` with the snapshot ID to list every file; a file ref filters only that file.
|
|
84
|
-
|
|
85
|
-
Replace these placeholders with values returned by `list`, `read` and `files`:
|
|
86
|
-
|
|
87
|
-
```bash
|
|
88
|
-
ntn-skills read 'REF_FROM_LIST'
|
|
89
|
-
ntn-skills files 'SNAPSHOT_ID_FROM_READ'
|
|
90
|
-
ntn-skills read 'ATTACHMENT_REF_FROM_FILES'
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
For a relative file, resolve from the containing file's pinned ref:
|
|
94
|
-
|
|
95
|
-
```bash
|
|
96
|
-
ntn-skills read reference.md --from 'PINNED_CONTAINING_FILE_REF'
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
That relative file must exist in the snapshot. `read --lines 10-30` uses inclusive, 1-based lines and reports `range` and `has_more`. `--raw` emits successful UTF-8 text; failures remain JSON. Binary files require `--output ./attachment.bin`. Identical output is reused with `reused=true`; different existing output returns `OUTPUT_CONFLICT` without overwrite. Scripts are never executed.
|
|
100
|
-
|
|
101
|
-
`read`, `open`, `files`, `export` and `list` accept one of `--refresh`, `--offline` or `--max-age DURATION`; the flags are mutually exclusive. `--refresh` validates online regardless of age, `--offline` uses only eligible local observations even when expired, and `--max-age 30s` overrides the invocation's age limit (`0` requires validation). Expired ordinary reads wait for validation and fail on validation error; there is no automatic stale fallback. A hit never moves `validated_at`.
|
|
102
|
-
|
|
103
|
-
```bash
|
|
104
|
-
ntn-skills read 'REF_FROM_LIST' --refresh
|
|
105
|
-
ntn-skills open 'CURRENT_PAGE_ID' --max-age 30s
|
|
106
|
-
ntn-skills files 'CURRENT_PAGE_ID' --offline
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
JSON reports `source=notion` for online validation, `local_cache` for an unpinned observation, and `local_snapshot` for an explicitly pinned version. Preserve `freshness` (policy, validation time, age, effective limit and stale status) when deciding whether the observation is suitable. Pinned reads, including relative reads with pinned `--from`, work offline; `--offline` is redundant, while `--refresh` and `--max-age` are invalid. A pinned version makes no latest-remote freshness claim. Historical snapshots must already exist on this machine. `open` returns metadata/file refs without contents. `--raw` omits JSON freshness fields. [Response contract](protocol.md#success).
|
|
110
|
-
|
|
111
|
-
## References pages
|
|
112
|
-
|
|
113
|
-
Create a rich-text `References` property alongside `Description`. Add page mentions or links; whitespace separators are allowed. Link labels ending in `.md` specify a filename, including `references/subdirectory/guide.md`. Other labels use the referenced page's title, normalized into a lowercase filename. Chinese titles are supported. Duplicate paths fail with REFERENCE_PATH_CONFLICT; inaccessible or incomplete pages fail the read rather than producing a partial skill.
|
|
114
|
-
|
|
115
|
-
Every listed page is materialized under `references/`. The property is the complete inclusion list: additional pages linked in the body stay online links until added to References. Markdown links, Notion page mentions and bare Notion URLs to included pages become relative paths; code examples and unrelated external links remain unchanged. Reference-page changes participate in version checks even if the main page is untouched. Pinned reads and exports remain offline.
|
|
116
|
-
|
|
117
|
-
Create/import write `references/**/*.md` as child pages, allocate all pages before rewriting links, and update References with their paths. Write updates an existing reference page or adds a new one. Import replaces the inclusion list; omitted pages remain in Notion but disappear from the current skill file set. Child-page blocks are retained during body updates. Non-reference assets and exact source bytes use the optional Files source bundle. Without Files, only the main Markdown and reference Markdown are accepted; source formatting/frontmatter is normalized. Keep Files for reversible arbitrary-file imports.
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
## Creating, importing, exporting and updating skills
|
|
121
|
-
|
|
122
|
-
Select a database explicitly, save a creation default, or let the CLI use the sole discovered skill database. The order is `--database` → `config.default_database` → sole fresh discovery. Multiple databases, failed registered sources or an inaccessible configured default require a valid selection. `config clear-default` removes the preference offline; it does not change read scope.
|
|
123
|
-
|
|
124
|
-
After registering `ops`, replace the pinned-ref placeholder with a ref returned by `read`:
|
|
125
|
-
|
|
126
|
-
```bash
|
|
127
|
-
ntn-skills config set-default ops
|
|
128
|
-
ntn-skills config show
|
|
129
|
-
ntn-skills create ./my-skill --dry-run
|
|
130
|
-
ntn-skills create ./my-skill
|
|
131
|
-
ntn-skills import ./my-skill.zip --dry-run
|
|
132
|
-
ntn-skills import ./my-skill.zip
|
|
133
|
-
ntn-skills import ./workflow.md --name 'My Workflow' --description 'When to use this workflow'
|
|
134
|
-
ntn-skills export 'My Workflow' --output ./my-workflow.zip
|
|
135
|
-
ntn-skills export 'PINNED_REF_FROM_READ' --output ./my-workflow
|
|
136
|
-
ntn-skills write 'PINNED_REF_FROM_READ' --input ./SKILL.md --dry-run
|
|
137
|
-
ntn-skills write 'PINNED_REF_FROM_READ' --input ./SKILL.md
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
`create` and `import` accept one ZIP, folder or `.md`/`.markdown` file. A portable `.ntn-skills.json` manifest selects metadata and entrypoint. Other folder/ZIP inputs use `SKILL.md` or a unique top-level Markdown after wrapper removal; ambiguous inputs fail. A single Markdown input supplies the body regardless of filename. `--name` and `--description` override metadata. Optional Files preserves extra frontmatter, original bytes, filenames and nested supporting files in a source ZIP; without it main/reference Markdown follows [the page normalization rules](#references-pages). Imported page IDs do not select a target.
|
|
141
|
-
|
|
142
|
-
`create` rejects an existing invocation name with `CREATE_CONFLICT`. `import` creates when absent, reuses identical content, or replaces a same-name Skill's body, metadata and whole file set while keeping its page ID. Both decisions are scoped to the selected database. `--dry-run` reports create/reuse/update without uploading or mutating.
|
|
143
|
-
|
|
144
|
-
`import INPUT --target TARGET` replaces a selected existing page instead of selecting by imported name. Use a current selector or a pinned main-file ref/snapshot as the expected-version baseline; a reference-file target is invalid. Name/description overrides can rename that page without changing its ID. `--database` constrains the target rather than redirecting it through a creation default. Missing/inaccessible targets fail with no create or same-name fallback; stale pinned targets return `WRITE_CONFLICT`. Preview with `--dry-run`, then reuse the exact target within authorization.
|
|
145
|
-
|
|
146
|
-
```bash
|
|
147
|
-
ntn-skills import ./renamed-skill --target 'PINNED_MAIN_REF_FROM_READ' --database ops --dry-run
|
|
148
|
-
ntn-skills import ./renamed-skill --target 'PINNED_MAIN_REF_FROM_READ' --database ops
|
|
149
|
-
ntn-skills read 'TARGET_PAGE_ID' --database ops --refresh
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
`write` replaces one logical file and retains the others. A target ref with a file path cannot combine with `--path`. Pinned refs and snapshot IDs provide an online version baseline; stale versions return `WRITE_CONFLICT`. Identical input returns `unchanged=true` without uploading or mutating. Updated `SKILL.md` name/description also update the page properties. If `notion_page_id` is present, it must match the target.
|
|
153
|
-
|
|
154
|
-
`export` writes every file plus the portable manifest. `.zip` selects ZIP; other paths select a directory; `--format zip|directory` overrides that choice. Pinned exports work offline. Preserve the manifest for reimport. ZIP bytes are deterministic; differing existing output fails rather than overwriting. [Portable format and source preservation](protocol.md#portable-export-contract).
|
|
155
|
-
|
|
156
|
-
ZIP input is limited to 32 MiB compressed, 128 MiB expanded and 10,000 entries; folders use the expanded/entry limits. Generated source ZIPs and portable ZIP output must fit 20 MiB compressed. Unsafe paths, links, special files, duplicates and checksum failures are rejected. Notion read-export archives use gzip/tar and are separate from local import inputs.
|
|
157
|
-
|
|
158
|
-
Successful changes return a verified snapshot and pinned refs. Body, properties and file uploads are separate requests; client version checks cannot guarantee an atomic transaction or name uniqueness. `WRITE_PARTIAL` and `WRITE_OUTCOME_UNKNOWN` report stage and identities. Inspect the target before retrying. Dry runs do not prove service acceptance. [Mutation contract](protocol.md#mutation-contract) and [error recovery](protocol.md#errors).
|
|
159
|
-
|
|
160
|
-
After an interrupted reference import, read the current returned page ID with `--refresh`, then explicitly repeat `import` with the same input/database and, if used, the same explicit target to reuse matching child-page IDs. Duplicate child paths fail with `REFERENCE_PATH_CONFLICT`. For transport failures, inspect `details.reason` or nested `cause_details.reason`; raw `ntn` stderr is excluded from CLI JSON.
|
|
161
|
-
|
|
162
|
-
## Synchronizing local Skills
|
|
163
|
-
|
|
164
|
-
Bind one existing Notion page to one logical local Skill directory. Labels are local configuration, separate from invocation aliases. Bind resolves the page once; later operations follow its canonical page ID even after rename. It never creates a remote page or chooses a content source implicitly. Equal initial contents can establish a verified baseline; differing contents or an absent ordinary leaf report `needs_initialization`.
|
|
165
|
-
|
|
166
|
-
Replace page/plan placeholders with actual returned values and choose `--from` only when initializing or deliberately resolving a conflict:
|
|
167
|
-
|
|
168
|
-
```bash
|
|
169
|
-
ntn-skills sync bind PAGE_ID --path ~/.agents/skills/release-review --as release-review-global --dry-run
|
|
170
|
-
ntn-skills sync bind PAGE_ID --path ~/.agents/skills/release-review --as release-review-global
|
|
171
|
-
ntn-skills sync plan release-review-global --from notion
|
|
172
|
-
ntn-skills sync apply --plan PLAN_ID_FROM_INITIALIZATION
|
|
173
|
-
ntn-skills sync status release-review-global
|
|
174
|
-
ntn-skills sync status release-review-global --refresh
|
|
175
|
-
ntn-skills sync plan release-review-global --output ./reviewed-sync-plan.json
|
|
176
|
-
ntn-skills sync apply --plan ./reviewed-sync-plan.json
|
|
177
|
-
ntn-skills sync plan --all
|
|
178
|
-
ntn-skills sync plan release-review-global --from local
|
|
179
|
-
ntn-skills sync apply --plan PLAN_ID_FROM_RESOLUTION
|
|
180
|
-
ntn-skills sync reconcile release-review-global
|
|
181
|
-
ntn-skills sync unbind release-review-global --dry-run
|
|
182
|
-
ntn-skills sync unbind release-review-global
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
Status without refresh inspects local content, common baseline and last remote observation only; its comparison is provisional. Refresh updates the observation without advancing a baseline. Plan always reads strongly, persists a state artifact and changes no Skill content/baseline. Exactly one binding or `--all` is required; `--from local|notion` is single-binding only. One-sided changes choose direction from the confirmed baseline; differing two-sided changes stop until an explicit source-selection plan is reviewed. Batch plans reject competing contents for one page and can fan out one accepted update to independent unchanged copies with separate baselines.
|
|
186
|
-
|
|
187
|
-
Apply accepts the returned plan ID or an identical reviewable JSON copy. It rechecks schema/digest, current registered bindings, scope, baseline generation, remote expected version, local hashes, logical/resolved path and link proof before effects. Editing a copied plan or moving it to another machine does not authorize execution. Only readback-confirmed convergence advances a baseline. There is no global transaction: a later failure can leave earlier verified bindings complete, recorded independently in the receipt. Retain unfinished receipts; they fence affected resources. Reconcile observes actual local/remote results without replaying writes, and advances a baseline only when convergence is proved. It reports divergence so a new checked plan can be made.
|
|
188
|
-
|
|
189
|
-
Reconcile unfinished operations before reactivating or relabeling a binding. Recovery accepts an unchanged binding or one unbind that leaves it inactive; rebinding changes its revision and retains the old operation's fence with `SYNC_PLAN_STALE`. [Recovery contract](protocol.md#synchronization).
|
|
190
|
-
|
|
191
|
-
Logical directory, parent and per-file symlinks are supported and preserved through writes to their final destinations. Changed chains/targets invalidate saved plans, including byte-identical retargets. A missing ordinary leaf under a resolvable parent can initialize from Notion; dangling links/cycles and a missing established root are errors, never deletion intent. Commit-boundary checks cannot promise an atomic filesystem transaction across an external process's link retargeting. Removed/replaced tracked bytes are retained through system Trash; unrelated files survive. Unbind deactivates configuration and retains local/remote content, common bases, plans and recovery receipts. [Authoritative command/output contract](protocol.md).
|
|
192
|
-
|
|
193
|
-
## Cache policy and cleanup
|
|
194
|
-
|
|
195
|
-
Content observations default to five minutes (`300000` ms), catalogs to 60 seconds (`60000` ms). Save either or both defaults offline; clearing policy restores built-ins and preserves all other configuration/state. Durations are finite nonnegative integers: `0`, `Ns`, `Nm`, `Nh`, `Nd`; bare nonzero numbers, fractions, negatives and overflow are invalid.
|
|
196
|
-
|
|
197
|
-
```bash
|
|
198
|
-
ntn-skills config set-cache-policy --read-max-age 5m --catalog-max-age 60s
|
|
199
|
-
ntn-skills config show
|
|
200
|
-
ntn-skills config clear-cache-policy
|
|
201
|
-
ntn-skills cache status
|
|
202
|
-
ntn-skills cache status PAGE_ID --database ops
|
|
203
|
-
ntn-skills cache clear PAGE_ID --database ops --dry-run
|
|
204
|
-
ntn-skills cache clear PAGE_ID --database ops
|
|
205
|
-
ntn-skills cache clear --all --dry-run
|
|
206
|
-
ntn-skills cache clear --all
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
Cache status is offline and reports effective roots and recorded scopes/observations without declaring any stored account current. Targeted clear retires appropriate latest/selector/catalog observations in the selected scope; `--all` retires disposable observations across recorded scopes. Exactly one target or `--all` is required. Unsafe local name/account selection fails instead of guessing; use a page ID and explicit database when needed. Clearing conservatively retires catalogs containing the target rather than fabricating exhaustive coverage. System Trash retention is required and missing support fails explicitly; no permanent deletion is substituted. It never removes immutable snapshots/objects, bindings, common bases, plans, uploads or unfinished receipts, and is not state reset or garbage collection. [Storage contract](protocol.md#environment-and-local-storage).
|
|
210
|
-
|
|
211
|
-
Clear invalidates the entire selected content/catalog observation batch before moving files. If system Trash is unavailable or fails, it reports an error and leaves unmoved bytes in place; those old observations still cannot serve current reads/status. Refresh to obtain a new current observation. Pinned reads, configuration and sync recovery state remain available. [Retention contract](protocol.md#environment-and-local-storage).
|
|
212
|
-
|
|
213
|
-
## Commands and output
|
|
214
|
-
|
|
215
|
-
Run `ntn-skills --help` or `ntn-skills <command> --help` for flags and examples. Help is offline and an explicit `--help` takes precedence without running the command. Normal output is JSON, including errors; help/version are text. Exit status is 0 for success, 1 for operation failure and 2 for invalid arguments. `read --raw` affects successful content only.
|
|
216
|
-
|
|
217
|
-
The [bootstrap command reference](../skills/ntn-skills/references/commands.md) lists commands and errors. The [protocol](protocol.md) defines exact selectors and result semantics.
|
|
218
|
-
|
|
219
|
-
## Configuration and storage
|
|
220
|
-
|
|
221
|
-
Configuration defaults to `~/.config/ntn-skills/config.json`; retained state to `~/.local/state/ntn-skills`; disposable observations to `~/.cache/ntn-skills`. `NTN_SKILLS_CONFIG_HOME`, `NTN_SKILLS_HOME` and `NTN_SKILLS_CACHE_HOME` each name a complete application directory and take priority over `$XDG_CONFIG_HOME/ntn-skills`, `$XDG_STATE_HOME/ntn-skills` and `$XDG_CACHE_HOME/ntn-skills` respectively. Isolate all three when separating hosts or verification runs. [Environment contract](protocol.md#environment-and-local-storage).
|
|
222
|
-
|
|
223
|
-
When the new configuration is absent, source/list access can migrate the old state-directory configuration, retaining a `.migrated` backup. New configuration wins; invalid legacy configuration fails without migration. Snapshots do not move.
|
|
224
|
-
|
|
225
|
-
State retains private immutable manifests/content objects, upload staging, sync baselines, plans and receipts, with no automatic garbage collection. Latest/catalog/selector observations belong in cache. On upgrade preserve existing state/config, snapshots/objects and recovery data; rebuild disposable indexes under the cache root. Historical state catalogs cannot establish a fresh current observation or initialize a sync baseline. An empty cache causes online validation rather than state deletion. Older pinned scope formats remain readable offline; obtain a fresh online ref before writing from an older format. Online calls use `ntn` and signed export URLs; the CLI sends no analytics requests of its own. [Security policy](../SECURITY.md).
|
|
226
|
-
|
|
227
|
-
## Upgrade and uninstall
|
|
228
|
-
|
|
229
|
-
For a registry installation, repeat the global or project-local npm install command with the desired published version. For a tarball installation, obtain the newer built archive and repeat its install command. Read [the changelog](../CHANGELOG.md) before upgrading across a 0.x minor version. Source updates, builds and packaging follow [Contributing](../CONTRIBUTING.md#development-setup).
|
|
230
|
-
|
|
231
|
-
Remove a global installation with:
|
|
232
|
-
|
|
233
|
-
```bash
|
|
234
|
-
npm uninstall --global ntn-skills
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
Remove a project dependency in each consuming project with:
|
|
238
|
-
|
|
239
|
-
```bash
|
|
240
|
-
npm uninstall ntn-skills
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
Uninstalling retains all three roots, including historical pinned versions, sync bindings/baselines/plans and unfinished receipts. Before uninstalling, run `ntn-skills config clear-token` to remove a saved token if desired; environment credentials and `ntn` login belong to their tools. Record effective paths with `cache status` and `config show`, stop hosts using them, and retain required pinned versions/recovery evidence before optional reclamation. `cache clear --all` retires only disposable observations to system Trash. Move state/config application directories or legacy backups through system Trash/approved retention only when deliberately retiring that data: removing state makes pinned refs unavailable and loses sync recovery history. No cleanup step permanently deletes content.
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: ntn-skills
|
|
3
|
-
description: Discover, read, create, import, export and synchronize reusable workflows in Notion through ntn-skills. Use when a task may benefit from the Notion skill library, names a remote skill, follows skill:// references, or requests Skill maintenance/sync. Read metadata first, then needed files; retain freshness and pinned refs, and review saved sync plans before authorized apply.
|
|
4
|
-
compatibility: Requires Node.js >= 22.19.0, official ntn CLI, ntn-skills, and a Notion Read content connection to a database with rich-text Description/References or native Skills support. Creating/importing/updating requires Insert/Update content capabilities. Shell tool access is sufficient; host protocol adapters are optional.
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Remote Notion skills
|
|
8
|
-
|
|
9
|
-
Use Notion as the maintained source and ntn-skills for progressive reads and explicit authorized writes. Do not install or load every remote skill's contents to discover what is available.
|
|
10
|
-
|
|
11
|
-
Authentication priority is non-empty config.token > NOTION_API_TOKEN > existing ntn login. Save through `config set-token --stdin` with piped input; clear with `config clear-token` to restore fallback. Tokens are plaintext in private configuration, never command arguments/output. `config show` reports token_configured only; use doctor for actual access checks. Never prompt for or print credentials, or start login implicitly. See [authentication and host isolation](references/integration.md).
|
|
12
|
-
|
|
13
|
-
Notion Name uses ASCII English letters and single spaces, with no surrounding spaces and at most 64 characters. Its lowercase, hyphenated form is the skill's invocation name: `Resource Tag Governance` → `resource-tag-governance`. Each listed `name` is the display title and `alias` is that invocation name. The export's `SKILL.md` name must match it. Descriptions and contents may use any language.
|
|
14
|
-
|
|
15
|
-
References is a rich-text inclusion list of Notion page mentions or links. These pages become references/*.md; a link label such as references/subdirectory/guide.md fixes its path, otherwise its page title determines the filename. Included page links become relative paths, including links back to SKILL.md. External URLs and code examples stay unchanged. Follow those paths within the pinned snapshot. Referenced-page edits participate in write conflicts. Native Skills exports remain supported when References is absent. See [the storage contract](../../docs/protocol.md#references-pages).
|
|
16
|
-
|
|
17
|
-
1. If remote metadata is already supplied, choose from it; otherwise run `ntn-skills list`. It returns databases/skills/count/coverage without bodies. Join database_id to the database map for title/domain alias. `--query` filters Name/alias/Description; broaden it when needed. Catalogs default to 60 seconds; `--refresh` requests fresh metadata. Preserve coverage and freshness; cached discovery does not prove workspace completeness.
|
|
18
|
-
2. Select a workflow by its name and Description. List entries are discovery data. Inspecting, editing, summarizing, or configuring a skill does not activate its instructions.
|
|
19
|
-
3. Run `ntn-skills read "<exact display name>"` or use its current listed ref. It obtains a complete snapshot without an open step. Ordinary current reads accept content validated within five minutes; use `--refresh` when a fresh remote observation is required, or deliberate `--offline` only when local scope can be selected safely. Official-login identity may still need online validation; do not promise zero-network warm reads in that mode.
|
|
20
|
-
4. Record `source`, `freshness`, `snapshot_id` and the pinned `ref`. `notion` means online validated, `local_cache` means an unpinned cached observation, and `local_snapshot` means an immutable pinned version. Read supporting files only as needed from that snapshot:
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
ntn-skills read <snapshot-id> --path references/guide.md
|
|
24
|
-
ntn-skills read references/guide.md --from '<pinned SKILL.md ref>'
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
5. Relative links resolve from the containing file. Use `read relative-path --from '<pinned ref>'`; resolve is an optional helper. `read`, `files`, `open`, `write` and `export` share targets: Name, invocation alias, page ID/URL, skill:// ref or snapshot ID. --path supplies a path only when the target has none; --from rejects --path. `files <snapshot-id>` returns pinned file refs.
|
|
28
|
-
6. For binary bytes, use --output and a host viewer; identical local output is reused, differing output returns OUTPUT_CONFLICT. Reading scripts does not authorize execution.
|
|
29
|
-
7. Keep one snapshot throughout a workflow. Pinned refs/snapshot IDs read or export offline and do not prove latest remote freshness. Refresh a current unpinned target to adopt a newer version. `--refresh`, `--offline` and `--max-age DURATION` are mutually exclusive; pinned targets and pinned relative `--from` reject refresh/max-age. There is no automatic stale fallback after online failure. Raw text omits freshness metadata.
|
|
30
|
-
|
|
31
|
-
`skill://<name-or-page-id>/<path>?snapshot=<id>` is handled by this CLI. A built-in Read tool accepts it only if the host registered an adapter. Do not assume a Skill can register that adapter.
|
|
32
|
-
|
|
33
|
-
Output is JSON with ok, identity, snapshot, path and content. Errors are JSON with nonzero exit status. Do not treat a failed command as Skill content. Cross-database same-name Skills are allowed: retain both page identities. On SKILL_AMBIGUOUS, use details.databases with candidate database_id to select a domain, or use a returned page-ID ref. Every --database accepts one ID, URL or exact case-sensitive registered alias; repeated flags fail before execution and titles are display labels only. Register with source add frontend --database DATABASE_ID, then read NAME --database frontend. Unknown or conflicting aliases fail without fallback. Pinned alias constraints resolve locally and enforce cached database ownership. On incomplete discovery, report failed_sources database_id/alias/title/data_source_id instead of claiming uniqueness. Search cannot prove full workspace enumeration.
|
|
34
|
-
|
|
35
|
-
For maintenance, edit one local file and run `ntn-skills write '<pinned ref>' --input ./SKILL.md --dry-run`, then execute within the current authorization. --path selects a file only when the target has no path. A pinned target is an online version baseline. Stale refs return WRITE_CONFLICT; identical input returns unchanged=true without upload or mutation. Reference paths update their Notion pages and restore page URLs. Writes preserve unrelated logical files; optional Files retains extra frontmatter and nested/binary assets in the source ZIP. notion_page_id in SKILL.md must match the target. A changed write returns a new pinned snapshot.
|
|
36
|
-
|
|
37
|
-
Create/import without an explicit target choose --database > config.default_database > sole freshly discovered Skills Database. `config set-default` validates online and stores the canonical ID; show/clear-default manage it. Failed defaults never fall back. This preference does not restrict reads and cannot redirect an existing import target.
|
|
38
|
-
|
|
39
|
-
`create <input>` and `import <input>` share ZIP/folder/Markdown inputs and --name/--description overrides. Portable manifests select metadata/entrypoints; other ZIPs/folders choose SKILL.md or one top-level Markdown after wrapper removal. A single Markdown filename is the body. Missing names derive from English filenames; missing descriptions require --description. References Markdown becomes editable child pages, allocated before writing cyclic links. Files retains extra Skill frontmatter, arbitrary filenames and nested assets in ntn-skills-source.zip; without Files only main/reference Markdown is accepted and formatting/frontmatter is normalized. Imported page IDs never select a target. Input ZIP max 32 MiB compressed; expanded/folder max 128 MiB/10,000 entries; source ZIP max 20 MiB including its manifest. Unsafe/duplicate paths, links and special files fail before mutation.
|
|
40
|
-
|
|
41
|
-
Create requires a new invocation name or returns CREATE_CONFLICT. Import without target creates absent names, reuses identical content or replaces differing content on the same-name page. `import INPUT --target TARGET` selects one existing current page or pinned main-file/snapshot baseline instead: preserve page ID when metadata renames it, constrain with --database, reject reference-file targets, and fail missing/inaccessible/stale targets without create/name fallback. Overwrite replaces the whole file set; omitted references remain in Notion. Preview with --dry-run. Version checks are strong online client checks, not an atomic server guarantee.
|
|
42
|
-
|
|
43
|
-
`export <target> --output <path> [--format zip|directory]` writes a complete reversible Skill. .zip selects ZIP; other paths select directory. Pinned targets work offline. Preserve .ntn-skills.json for metadata/entrypoint and title casing. Original source bytes stay exact while their recorded projection matches current body/metadata; live edits regenerate the main file and retain other content. ZIP order/timestamps are deterministic. Identical destinations return reused=true; different output returns OUTPUT_CONFLICT. Reimport reuses identical content or overwrites differing same-name content.
|
|
44
|
-
|
|
45
|
-
New pages write body after properties to preserve an initial H1. Optional source ZIPs record normalized body/name/description and reference projections. Successful changes verify complete saved content; page-only mode compares normalized Markdown. Create/import return input_type/main_path/content_id/action/reused; write adds previous_version_id/path/unchanged. Body/properties/files are separate requests. Insert/Update and Read content are required. WRITE_PARTIAL/WRITE_OUTCOME_UNKNOWN includes stage/page identity; read back before retrying. Dry runs cannot prove service acceptance.
|
|
46
|
-
|
|
47
|
-
For an authorized local distribution workflow, bind an existing current page with `sync bind PAGE_ID --path LOGICAL_DIR --as LABEL` (optional --database/--dry-run). Equal content may initialize a common baseline; otherwise review `sync plan LABEL --from notion` or `--from local`, then `sync apply --plan PLAN_ID`. Later `sync plan LABEL` or `sync plan --all` selects direction from each confirmed baseline and rejects competing/two-sided contents. `--output ./plan.json` saves a reviewable copy; apply accepts that path but rechecks digest, registered binding/scope, baseline generation, remote version, local hashes and link proof. Neither reads nor plans advance baselines.
|
|
48
|
-
|
|
49
|
-
`sync status [LABEL]` is local/provisional; --refresh validates only the remote observation. Apply advances each baseline only after verified convergence. Keep partial/unknown receipts and run `sync reconcile LABEL` before another apply; reconciliation reads actual effects without replaying mutation. `sync unbind LABEL [--dry-run]` deactivates configuration and retains contents/bases/plans/receipts. Logical directory/parent/per-file links are preserved, drift rejects plans, and commit-boundary checks are not an atomic guarantee against external filesystem retargeting. Removed/replaced bytes require system Trash retention. See [sync usage](../../docs/usage.md#synchronizing-local-skills) and [protocol](../../docs/protocol.md) rather than inventing plan fields.
|
|
50
|
-
|
|
51
|
-
`cache status [TARGET] [--database SELECTOR]` is offline. `cache clear TARGET [--database SELECTOR] [--dry-run]` or `cache clear --all [--dry-run]` retires disposable observations through system Trash; never erase immutable snapshots/objects or sync recovery state. Config/state/cache roots use NTN_SKILLS_CONFIG_HOME/NTN_SKILLS_HOME/NTN_SKILLS_CACHE_HOME and their XDG fallbacks; isolate all three. `config set-cache-policy --read-max-age 5m --catalog-max-age 60s` saves defaults; clear-cache-policy restores built-ins. Durations use nonnegative integers `0`, `Ns`, `Nm`, `Nh`, `Nd`. Upgrades rebuild disposable cache and retain pinned/state data; uninstall retains all roots. [Cache/storage guidance](../../docs/usage.md#cache-policy-and-cleanup).
|
|
52
|
-
|
|
53
|
-
See [commands and errors](references/commands.md) for exact flags and responses. See [discovery and host integration](references/integration.md) when setting up metadata injection or handling missing sources.
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
# Commands and recovery
|
|
2
|
-
|
|
3
|
-
```bash
|
|
4
|
-
ntn-skills list [--query text] [--database id-or-url-or-alias] [--refresh | --offline | --max-age duration]
|
|
5
|
-
ntn-skills read "Exact Display Name"
|
|
6
|
-
ntn-skills read skill://exact-display-name/SKILL.md
|
|
7
|
-
ntn-skills open <target>
|
|
8
|
-
ntn-skills files <target> [--path directory-or-file]
|
|
9
|
-
ntn-skills read <current-target> --refresh
|
|
10
|
-
ntn-skills open <current-target> --max-age 30s
|
|
11
|
-
ntn-skills files <current-target> --offline
|
|
12
|
-
ntn-skills read <snapshot-id> --path references/guide.md
|
|
13
|
-
ntn-skills read references/guide.md --from '<pinned-main-ref>'
|
|
14
|
-
ntn-skills resolve ../assets/template.md --from '<pinned-reference-ref>'
|
|
15
|
-
ntn-skills read '<pinned-ref>' --lines 10-30
|
|
16
|
-
ntn-skills read '<pinned-binary-ref>' --output <new-local-path>
|
|
17
|
-
ntn-skills config show
|
|
18
|
-
ntn-skills config set-default <id-or-url-or-alias>
|
|
19
|
-
ntn-skills config clear-default
|
|
20
|
-
ntn-skills config set-token --stdin
|
|
21
|
-
ntn-skills config clear-token
|
|
22
|
-
ntn-skills config set-cache-policy --read-max-age 5m --catalog-max-age 60s
|
|
23
|
-
ntn-skills config clear-cache-policy
|
|
24
|
-
ntn-skills cache status [target] [--database id-or-url-or-alias]
|
|
25
|
-
ntn-skills cache clear <current-target> [--database id-or-url-or-alias] [--dry-run]
|
|
26
|
-
ntn-skills cache clear --all [--dry-run]
|
|
27
|
-
ntn-skills create <zip-or-folder-or-markdown> [--database id-or-url-or-alias] [--name title] [--description text] [--dry-run]
|
|
28
|
-
ntn-skills import ./my-skill.zip [--database id-or-url-or-alias] [--name 'My Skill'] [--description text] [--dry-run]
|
|
29
|
-
ntn-skills import ./my-skill [--dry-run]
|
|
30
|
-
ntn-skills import ./workflow.md --name 'My Workflow' --description 'When to use this workflow'
|
|
31
|
-
ntn-skills import ./renamed-skill --target '<current-page-id-or-pinned-main-ref>' [--database id-or-url-or-alias] [--dry-run]
|
|
32
|
-
ntn-skills export 'My Workflow' --output ./my-workflow.zip
|
|
33
|
-
ntn-skills export '<pinned-main-ref>' --output ./my-workflow [--format directory]
|
|
34
|
-
ntn-skills export <snapshot-id> --output ./my-workflow.zip
|
|
35
|
-
ntn-skills write '<pinned-main-ref>' --input ./SKILL.md [--dry-run]
|
|
36
|
-
ntn-skills write 'skill://exact-display-name/vocabulary.md' --input ./vocabulary.md
|
|
37
|
-
ntn-skills write <snapshot-id> --path references/guide.md --input ./guide.md
|
|
38
|
-
ntn-skills database list [--database id-or-url-or-alias]
|
|
39
|
-
ntn-skills doctor
|
|
40
|
-
ntn-skills sync bind <current-target> --path <logical-directory> [--as label] [--database id-or-url-or-alias] [--dry-run]
|
|
41
|
-
ntn-skills sync status [binding] [--refresh]
|
|
42
|
-
ntn-skills sync plan <binding> [--from local|notion] [--output ./reviewed-plan.json]
|
|
43
|
-
ntn-skills sync plan --all [--output ./reviewed-plan.json]
|
|
44
|
-
ntn-skills sync apply --plan <plan-id-or-json-file>
|
|
45
|
-
ntn-skills sync reconcile <binding>
|
|
46
|
-
ntn-skills sync unbind <binding> [--dry-run]
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
list returns databases/skills/count/coverage and paginates automatically without bodies. Join each Skill database_id to the map (database_id/title/alias/data_source_ids); the Skill alias remains its invocation name. --query filters Skill Name/alias/Description and retains the full queried database map. --database selects one ID/URL/exact case-sensitive registered alias; database titles never select targets and repeated flags fail with INVALID_ARGUMENT/exit 2. Register a domain with source add frontend --database DATABASE_ID, then list --database frontend. Unknown/conflicting aliases return DATABASE_NOT_FOUND/DATABASE_AMBIGUOUS. --refresh bypasses metadata cache. Failed queries retain database_id/alias/title and data_source_id in coverage.failed_sources. database list discovers databases without Skill row queries. Shared read/files/open/write/export targets accept Name, invocation alias, page ID/URL, ref or snapshot ID. Pinned read/files/open/export targets are offline, including local alias constraints; pinned writes are online baselines. --path cannot combine with a target already containing a path; read --from rejects --path.
|
|
50
|
-
|
|
51
|
-
Use `ntn-skills --help` for workflow, output and authentication guidance, then `ntn-skills <command> --help` for argument meanings, offline modes, flag conflicts and examples. Help runs without credentials. Replace example placeholders with actual returned values; explicit `--help` shows help without running the requested operation.
|
|
52
|
-
|
|
53
|
-
Authentication: config.token > non-empty NOTION_API_TOKEN > existing ntn login. `config set-token --stdin` must receive one token through piped stdin from a trusted secret source; surrounding whitespace is trimmed and empty/multiple values fail. It saves plaintext in the private config file offline without remote validation, preserving sources/default_database. `clear-token` removes only config.token offline. Configuration output omits the token and adds token_configured for configuration presence only; use doctor to check access. Clear an invalid config token before expecting environment/login fallback. Never put a token in command arguments or logs.
|
|
54
|
-
|
|
55
|
-
The default successful read is JSON with `ok=true`, content, page identity, snapshot ID, version, pinned ref, and range metadata. `--raw` returns successful text only and should be used only when the caller already keeps version state. Help/version are text; every failure is JSON.
|
|
56
|
-
|
|
57
|
-
Current-target `read`, `open`, `files`, `export` and `list` accept at most one of `--refresh`, `--offline`, `--max-age DURATION`. Default content/catalog limits are 5m/60s. Refresh validates online, offline intentionally uses eligible local observations even if expired, and max-age overrides the invocation (`0` requires validation). Durations use finite nonnegative integers `0`, `Ns`, `Nm`, `Nh`, `Nd`. Pinned targets and pinned relative --from reject refresh/max-age; redundant offline is allowed. JSON source is notion/local_cache/local_snapshot with freshness metadata; a hit does not update validation time and failed validation does not fall back to stale. Existing official-login identity may require online checking; unpinned offline lookup must fail if scope cannot be selected safely. Writes, sync plans/applies/reconcile and doctor always validate online. [Protocol](../../../docs/protocol.md#success).
|
|
58
|
-
|
|
59
|
-
Errors have `ok=false`, `error.code`, `error.message`, and optional `error.details`. Exit 1 is an operation failure; exit 2 is invalid CLI input.
|
|
60
|
-
|
|
61
|
-
- SKILL_AMBIGUOUS: candidates and their owning databases map are under details; scope by database alias or choose a page-ID ref. Do not select the first row or collapse cross-database same-name entries.
|
|
62
|
-
- `INVALID_SKILL_NAME`: fix the identified Notion page's Name; allow only English letters with single spaces, no surrounding spaces, and at most 64 characters.
|
|
63
|
-
- `INVALID_SKILL`: verify that SKILL.md frontmatter `name` and its export directory equal the lowercase, hyphenated Notion Name.
|
|
64
|
-
- `SKILL_NOT_FOUND`: no match in discovered scope. Try a broader list query or --database for a known source.
|
|
65
|
-
- `CATALOG_INCOMPLETE`: some queries failed; do not treat a single remaining match as unique.
|
|
66
|
-
- `SNAPSHOT_MISSING`: a historical local snapshot is absent. Opening a current skill does not recover an arbitrary historical version.
|
|
67
|
-
- `SNAPSHOT_CONFLICT`: the ref and requested snapshot belong to different identities/versions.
|
|
68
|
-
- DATABASE_NOT_FOUND, DATABASE_AMBIGUOUS: supply a database ID/URL/exact registered alias, or set config.default_database for creation; inspect candidates and do not select the first one. config set-default saves a canonical ID.
|
|
69
|
-
- `IMPORT_AMBIGUOUS`: provide SKILL.md, a portable manifest or one top-level Markdown file.
|
|
70
|
-
- `CREATE_CONFLICT`: create requires a new name; use import to replace the existing Skill or supply another --name.
|
|
71
|
-
- `OUTPUT_CONFLICT`: choose a new destination; the existing output differs and is never overwritten.
|
|
72
|
-
- `INVALID_ARCHIVE`, `ARCHIVE_TOO_LARGE`: fix the ZIP or import size/count limits (32 MiB compressed ZIP, 128 MiB expanded/folder, 10,000 entries); unsafe/duplicate paths, links, special files and checksum failures are rejected.
|
|
73
|
-
- `WRITE_CONFLICT`: remote version differs from the pinned baseline; refresh the current target and rebuild the edit.
|
|
74
|
-
- `WRITE_PARTIAL`, `WRITE_OUTCOME_UNKNOWN`: inspect details.stage/completed/page_id and refresh the current page before an explicit retry; do not refresh the old pinned ref. For unfinished sync, retain its receipt and reconcile before another apply.
|
|
75
|
-
- `MARKDOWN_INCOMPLETE`: truncated or unsupported page Markdown prevents safe writes.
|
|
76
|
-
- `INVALID_REFERENCES`, `REFERENCE_PATH_CONFLICT`, `REFERENCE_NOT_FOUND`: fix page links, safe distinct Markdown paths and page access in References.
|
|
77
|
-
- `UNSUPPORTED_FILE`: add Files to retain non-reference assets, or submit only main/reference Markdown.
|
|
78
|
-
- `INPUT_FAILED`, `INVALID_INPUT`, `FILE_TOO_LARGE`: correct the local input or size (20 MiB per upload).
|
|
79
|
-
- `FILE_NOT_FOUND`: inspect files and preserve the actual layout.
|
|
80
|
-
- `BINARY_FILE`: use output; do not decode binary content as instructions.
|
|
81
|
-
- `AUTH_REQUIRED`, `ACCESS_DENIED`, `NTN_UNAVAILABLE`: diagnose the selected credential and runtime; config.token overrides environment/login credentials. Use config clear-token to restore fallback. Never ask the user to paste credentials into command output or start a login implicitly.
|
|
82
|
-
- Transport failures: inspect `details.reason` or nested `cause_details.reason` (`timeout`, `process`, `dns`, `tls`, `network`, `invalid_response`); never request raw stderr that may contain credentials or signed URLs.
|
|
83
|
-
- Read/query calls retry transient network and service failures up to three times with 1/2/4-second backoff; mutation calls never retry automatically.
|
|
84
|
-
- After readback of an interrupted reference import, repeat the same input/database to reuse matching child-page IDs; duplicate paths fail with `REFERENCE_PATH_CONFLICT`.
|
|
85
|
-
|
|
86
|
-
Line numbers are inclusive and 1-based. Relative paths resolve from the containing file. Traversal outside the skill root is rejected. Scripts are files; reading them does not authorize execution.
|
|
87
|
-
|
|
88
|
-
Create/import priority: --database > config.default_database > sole discovered skill database; failed defaults never fall back. Both accept ZIP/folder/Markdown, choose manifest or SKILL.md/unique Markdown and accept --name/--description overrides. References Markdown becomes editable child pages; writes restore Notion page links. Files preserves source bytes, extra frontmatter and other assets in a source ZIP (20 MiB including manifest). Without Files only main/reference Markdown is accepted and export is normalized. Create rejects existing invocation names. Import creates absent names, reuses identical content, or replaces different body/metadata/whole file sets on the existing page. Omitted reference pages remain in Notion but are excluded from new snapshots. Imported page IDs never select the target. Overwrite uses fresh version checks; --dry-run validates the storage mode and reports create/reuse/update without mutation. Write replaces one logical file and keeps others; unchanged bytes return unchanged=true. Pinned refs are online write baselines; child-only edits cause conflicts. Body/properties/files are separate requests; partial/unknown outcomes require readback.
|
|
89
|
-
|
|
90
|
-
Export accepts names/page IDs/URLs, pinned refs and snapshot IDs. Pinned exports are offline. --output is required; .zip selects ZIP, otherwise a directory, with --format zip|directory available. Output includes .ntn-skills.json, original source names/bytes/paths for unchanged imports, and current remote edits otherwise. Preserve the manifest for reimport. Deterministic ZIPs contain no generated page/version identity or timestamps. ZIP output fits 20 MiB; portable content fits 128 MiB and 10,000 entries including the manifest. Identical existing output returns reused=true; different output fails with OUTPUT_CONFLICT. Success includes content_id, main_path, format, output and files. Reimporting an unchanged export reuses its page.
|
|
91
|
-
|
|
92
|
-
With `import --target`, select an existing current page or pinned main-version baseline once. Imported name/description changes preserve page ID; --database constrains that target, reference-file targets are rejected, and missing/inaccessible/stale targets fail with no create/name fallback. Imported identity metadata itself never selects the target. [Mutation contract](../../../docs/protocol.md#mutation-contract).
|
|
93
|
-
|
|
94
|
-
Sync binds canonical page IDs to logical local paths. Equal registration may initialize a baseline; differing or absent ordinary local leaves need explicit source-selection initialization. Plan is a preview with retained digest-protected state; --all checks shared-page candidates and independent baselines. A review copy remains executable only against its registered resources after scope/version/base/hash/link rechecks. Apply advances baselines only after confirmed convergence and persists per-binding/group receipts; reconcile reads outcomes without replay. Unresolved receipts fence affected resources. Logical links are preserved, target drift is rejected, and commit guards cannot promise atomicity against external retargeting. Unbind retains content/bases/plans/receipts; removed/replaced bytes use system Trash. [Workflow](../../../docs/usage.md#synchronizing-local-skills).
|
|
95
|
-
|
|
96
|
-
Reconcile pending operations before reactivating/relabeling a binding. Recovery permits an unchanged binding or one unbind that leaves it inactive; a later revision returns `SYNC_PLAN_STALE` while retaining the fence. [Recovery contract](../../../docs/protocol.md#synchronization).
|
|
97
|
-
|
|
98
|
-
Cache status is offline. Clear requires one current target or --all and retires only disposable scoped observations via system Trash, preserving immutable snapshots/objects and all sync state. Missing retention support fails rather than deleting permanently. Config/state/cache roots are separate; isolate all three. Upgrades rebuild disposable cache while retaining pinned/state/config data; uninstall retains all roots. [Policy, cleanup and migration](../../../docs/usage.md#cache-policy-and-cleanup).
|
|
99
|
-
|
|
100
|
-
Before moving bytes, clear invalidates the entire selected content/catalog batch and rejects its delayed publishers. A retention error preserves unmoved files without making those observations usable again; refresh for a new current observation. Pinned versions and sync recovery remain available. [Retention contract](../../../docs/protocol.md#environment-and-local-storage).
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
# Discovery and integration
|
|
2
|
-
|
|
3
|
-
Use [the README](../../../README.md#quick-start) for prerequisites, installation and a first read. [The protocol](../../../docs/protocol.md) and [host adapter contract](../../../docs/host-integration.md) are the shared public references.
|
|
4
|
-
|
|
5
|
-
Install the built CLI package with npm and run it on Node.js 22.19.0 or newer. The host must put Node.js and `ntn-skills` on PATH; online operations also need the official `ntn` executable. Repository development/build/test tooling uses Bun separately.
|
|
6
|
-
|
|
7
|
-
Discover metadata before loading bodies. Read an actual current ref returned by `list`, require `ok: true`, and retain `content`, `ref`, `snapshot_id`, `version_id`, `source` and `freshness`. Ordinary content reads accept observations validated within five minutes (`source=local_cache`); `--refresh` validates current remote access/content (`source=notion`). Use `files <snapshot_id>` for every file in the fixed version and follow its pinned refs (`source=local_snapshot`). Pinned versions do not claim latest freshness. Inspecting, summarizing, editing or configuring a retained Skill does not activate its instructions; activate only the workflow selected for the task. No content or script executes automatically.
|
|
8
|
-
|
|
9
|
-
ntn-skills list follows all Search/row-query pages and returns databases/skills/count/coverage without bodies. Join Skill database_id to database title/alias/data_source_ids; Skill alias remains its invocation name. --query filters Skill Name/alias/Description and retains the full queried database map, including empty/no-match databases. --refresh bypasses the list cache. Discovery is limited to credential visibility and cannot prove workspace-wide completeness; preserve failed_sources database_id/alias/title/data_source_id. database list discovers database maps without querying Skill rows.
|
|
10
|
-
|
|
11
|
-
Discovery accepts native Skills databases and data sources with rich-text Description and References. References mode uses page Markdown; included page links become relative files under references/, with a path fixed by a `.md` link label or derived from the page title. Reference-only edits change the version. Optional Files preserves source bytes and other assets; without it main/reference Markdown exports are normalized. Host adapters retain the same command/ref interface for both modes. See [References pages](../../../docs/protocol.md#references-pages).
|
|
12
|
-
|
|
13
|
-
To query a known database directly:
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
ntn-skills source add frontend --database <database-id-or-url>
|
|
17
|
-
ntn-skills list --database frontend
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
All --database flags and config set-default accept one ID, URL or exact case-sensitive registered alias. IDs/URLs take priority; titles are display labels only. Repeated flags fail with INVALID_ARGUMENT/exit 2. Unknown aliases fail with DATABASE_NOT_FOUND; conflicting mappings fail with DATABASE_AMBIGUOUS; inaccessible selections never redirect. Pinned targets resolve aliases from local configuration and check snapshot ownership offline. Different databases may have the same Skill invocation name; retain both page identities and use the ambiguity error's databases map to select the domain or use a page-ID ref.
|
|
21
|
-
|
|
22
|
-
Source registrations are local, supplement discovery, and do not modify Notion. No custom Status filter is applied by default. Notion Name must use ASCII English letters separated by single spaces and be at most 64 characters. Lowercase it and replace spaces with hyphens to obtain the invocation name shown as the listed `alias`; the export's frontmatter `name` must match. Exact display titles and invocation names resolve only when one distinct page ID matches; case-only title differences can collide. Invalid titles return `INVALID_SKILL_NAME`, and mismatched export names return `INVALID_SKILL`. Descriptions and contents may use any language.
|
|
23
|
-
|
|
24
|
-
Source registrations and sync bindings live in config (`~/.config/ntn-skills/config.json`); immutable snapshots/objects, uploads, baselines/plans/receipts in state (`~/.local/state/ntn-skills`); disposable latest/catalog/selector observations in cache (`~/.cache/ntn-skills`). Override the complete roots with NTN_SKILLS_CONFIG_HOME, NTN_SKILLS_HOME and NTN_SKILLS_CACHE_HOME; XDG config/state/cache bases are also supported. Isolate all three for separate hosts. Legacy valid state config migrates only when new config is absent, retaining a `.migrated` backup. Upgrades preserve state/config and rebuild disposable indexes; old catalogs cannot manufacture freshness or initialize baselines.
|
|
25
|
-
|
|
26
|
-
The config may contain default_database. config set-default accepts the same ID/URL/alias selector, validates online and stores its canonical ID. Manage it through config show/clear-default. It applies to create/import only: --database wins, then the default, then the sole freshly discovered database. Name conflict/reuse/update is scoped to that database. Failed defaults and failed/ambiguous discovery never silently redirect writes.
|
|
27
|
-
|
|
28
|
-
Authentication selects non-empty config.token > NOTION_API_TOKEN > existing ntn login. Set a token through trusted piped stdin, never arguments/logs; clear-token restores fallback. Config operations preserve sources/defaults/policy/bindings and report token presence only. Tokens are plaintext with private permissions. Separate roots do not isolate official login; safe local credential/workspace/endpoint identity is required for eligible cached lookup. Official-login identity may need online validation; unpinned offline selection fails when scope cannot be determined safely. Pinned snapshots remain explicitly offline and older scopes remain readable; obtain a fresh current ref before writing from an older scope. [Scope contract](../../../docs/protocol.md#environment-and-local-storage).
|
|
29
|
-
|
|
30
|
-
`NTN_SKILLS_NTN_BIN` selects the trusted official CLI executable, default `ntn`. `NOTION_WORKSPACE_ID` and `NOTION_API_BASE_URL` enter the authentication scope and are inherited by `ntn`; workspace selection follows its authentication rules, while `ntn api` honors the API base URL override. Select a trusted endpoint because authenticated requests may reach it. Signed archive downloads follow the returned URLs independently. See [the environment contract](../../../docs/protocol.md#environment-and-local-storage).
|
|
31
|
-
|
|
32
|
-
The CLI sends no analytics requests of its own. Online operations use official `ntn` and signed download URLs; `ntn` has its own policies. Local access includes config/state/cache, explicit inputs and outputs. State's private immutable bytes, uploads and sync recovery have no automatic garbage collection. Content/catalog defaults are 5m/60s, configurable through set-cache-policy; TTL controls freshness, not retention. Cache status is offline and clear retires disposable observations through system Trash only. Uninstall retains all roots and pinned versions/recovery evidence. [Retention guidance](../../../docs/usage.md#upgrade-and-uninstall) and [security policy](../../../SECURITY.md).
|
|
33
|
-
|
|
34
|
-
For startup awareness, the host must inject list metadata or carry an instruction to use this bootstrap Skill for relevant tasks. A Skill description alone does not guarantee that the host already knows every remote workflow.
|
|
35
|
-
|
|
36
|
-
For direct Read tool support, the host must register a skill:// protocol adapter that invokes ntn-skills read with an argument array, parses JSON, preserves the snapshot, and propagates errors. If the host already owns skill:// for local skills, route explicitly instead of replacing its handler. Without an adapter, invoke the CLI through the shell tool.
|
|
37
|
-
|
|
38
|
-
Current read/open/files/export/list accept mutually exclusive `--refresh`, `--offline` or `--max-age DURATION`; expired ordinary reads validate or fail without stale fallback. Pinned snapshots and relative pinned --from reject refresh/max-age and permit redundant offline. Preserve JSON freshness; raw text omits it. Cached local content can remain after remote access revocation and is not proof of current permission. Never modify immutable cache/state objects directly.
|
|
39
|
-
|
|
40
|
-
For host Write integration, call `["write", uri, "--input", localFile]` as an argument array under current task authorization. Reuse the pinned read ref as the remote version baseline, propagate conflicts and partial/unknown outcomes, and adopt the new returned snapshot only after success. Never mutate cache objects or automatically retry an uncertain remote write. CLI support for skill:// writes does not register a host Write adapter.
|
|
41
|
-
|
|
42
|
-
For complete replacement, `import INPUT --target TARGET` selects an existing current page or pinned main-version baseline, preserves page ID on metadata rename, rejects reference-file targets and never falls back to create/name selection. Database constrains that target. Host synchronization registers a logical local path with sync bind, initializes differing/absent local content through an explicit sync plan --from notion|local, and applies only its saved plan ID/review copy after version/scope/base/hash/link checks. Plan --all checks shared-page candidates; status is provisional unless refreshed. Baselines advance only after verified convergence. Retain unresolved receipts and use sync reconcile without replay before another apply; unbind retains content/recovery. Logical links survive, retargeting invalidates plans, and filesystem checks are not atomic against external retargeting. Removed/replaced bytes require system Trash. [Sync workflow](../../../docs/usage.md#synchronizing-local-skills) and [authoritative protocol](../../../docs/protocol.md).
|
|
43
|
-
|
|
44
|
-
Adapters must tolerate additional JSON fields and propagate unfamiliar error codes as failures. Patch releases preserve current semantics; 0.x minor releases may break compatibility with documented migration steps. See [CONTRIBUTING](../../../CONTRIBUTING.md#compatibility-and-deprecation) and [the release procedure](../../../docs/releasing.md).
|