ntn-skills 0.1.2 → 0.2.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 +28 -0
- package/CONTRIBUTING.md +6 -0
- package/README.md +38 -9
- package/README.zh-CN.md +38 -9
- package/SECURITY.md +9 -5
- package/dist/ntn-skills.js +3192 -318
- package/docs/README.md +4 -2
- package/docs/host-integration.md +21 -9
- package/docs/protocol.md +81 -13
- package/docs/releasing.md +2 -0
- package/docs/usage.md +91 -11
- package/package.json +7 -3
- package/skills/ntn-skills/SKILL.md +19 -11
- package/skills/ntn-skills/references/commands.md +37 -4
- package/skills/ntn-skills/references/integration.md +9 -5
package/docs/README.md
CHANGED
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
Start with the repository README in [English](../README.md) or [简体中文](../README.zh-CN.md) for requirements, installation and the first successful read. Source development/build instructions belong to [Contributing](../CONTRIBUTING.md#development-setup). Detailed guides below are maintained in English.
|
|
4
4
|
|
|
5
|
-
- [Usage guide](usage.md): installation
|
|
6
|
-
- [CLI and ref contract](protocol.md): identities, selectors, fixed snapshots, JSON responses, storage,
|
|
5
|
+
- [Usage guide](usage.md): installation, authentication, discovery, fixed/current reads, import/export/write, checked local synchronization, cache policy, upgrade and uninstall.
|
|
6
|
+
- [CLI and ref contract](protocol.md): identities, selectors, fixed snapshots, JSON responses, storage, synchronization/recovery, cache boundaries and errors.
|
|
7
7
|
- [Host integration](host-integration.md): metadata injection, activation state and optional Read/Write adapters.
|
|
8
8
|
- [Releasing](releasing.md): immutable tags, first publication, Trusted Publishing, registry verification and repair.
|
|
9
9
|
- [Bootstrap Skill](../skills/ntn-skills/SKILL.md): progressive discovery and consumption from an Agent's shell tools.
|
|
10
10
|
- [Contributing](../CONTRIBUTING.md), [security policy](../SECURITY.md) and [changelog](../CHANGELOG.md): compatibility, maintenance and release status.
|
|
11
|
+
- [Sync/cache CLI design](https://github.com/yoyooyooo/notion-skills-cli/blob/main/docs/sync-cache-cli-design.md): repository-only accepted design and rationale for implemented commands; protocol owns current semantics.
|
|
12
|
+
- [Sync/cache acceptance matrix](https://github.com/yoyooyooo/notion-skills-cli/blob/main/.cursor/skills/verify-ntn-skills/features/sync-cache-verification-plan.md): repository-only acceptance/evidence requirements and [command coverage map](https://github.com/yoyooyooo/notion-skills-cli/blob/main/.cursor/skills/verify-ntn-skills/features/README.md#accepted-design-coverage). Runtime outcomes belong in each external run ledger. These maintenance files are excluded from the npm package; use the source checkout while changes are unpublished.
|
|
11
13
|
|
|
12
14
|
The protocol owns command and response semantics. Host and Skill guidance follows that contract; release claims require the evidence described in the release procedure.
|
package/docs/host-integration.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Host integration
|
|
2
2
|
|
|
3
|
-
Start with [installation and Quick start](../README.md#installation) before configuring a host.
|
|
3
|
+
Start with [installation and Quick start](../README.md#installation) before configuring a host. The 0.x series is experimental; [the compatibility policy](../CONTRIBUTING.md#compatibility-and-deprecation) and [changelog](../CHANGELOG.md) describe consumer expectations. This document defines an adapter contract, not a claim that adapters have been installed in other applications.
|
|
4
4
|
|
|
5
5
|
## Portable shell integration
|
|
6
6
|
|
|
@@ -12,22 +12,24 @@ Install `skills/ntn-skills` in the host's supported local skill directory. Add t
|
|
|
12
12
|
|
|
13
13
|
The bootstrap Skill can call `ntn-skills read skill://...` through a shell tool. It cannot add a protocol handler to a built-in Read tool.
|
|
14
14
|
|
|
15
|
-
Global configuration defaults to `~/.config/ntn-skills/config.json`;
|
|
15
|
+
Global configuration defaults to `~/.config/ntn-skills/config.json`; retained snapshots/recovery state to `~/.local/state/ntn-skills`; disposable observations to `~/.cache/ntn-skills`. Set `NTN_SKILLS_CONFIG_HOME`, `NTN_SKILLS_HOME` and `NTN_SKILLS_CACHE_HOME` to isolate all three complete application directories; XDG config/state/cache bases are also supported. Authentication selects config.token > non-empty NOTION_API_TOKEN > existing ntn login; a shared config token overrides a host's environment credential. Pass a token to `config set-token --stdin` through a trusted stdin pipe, never arguments/logs. `config clear-token` restores fallback; sanitized config reports token presence, not validity. Separate roots do not isolate official `ntn` login; where local login identity cannot be distinguished safely, current reads validate identity online and unpinned offline lookup fails. [Storage and scope contract](protocol.md#environment-and-local-storage).
|
|
16
16
|
|
|
17
17
|
`NTN_SKILLS_NTN_BIN` selects the official CLI executable (default `ntn`). `NOTION_WORKSPACE_ID` and `NOTION_API_BASE_URL` enter the authentication scope and are inherited by `ntn`; its authentication rules govern workspace selection, and `ntn api` honors the API base URL override. Use a trusted executable and endpoint, since authenticated API requests may reach that endpoint. Signed archive downloads follow the service's returned URLs independently. See [the environment contract](protocol.md#environment-and-local-storage).
|
|
18
18
|
|
|
19
|
-
The CLI sends no analytics requests of its own. Online calls use `ntn` and signed Notion
|
|
19
|
+
The CLI sends no analytics requests of its own. Online calls use official `ntn` and signed Notion downloads; `ntn` has its own policies. Local access covers configuration/state/cache, explicit inputs and requested outputs. Snapshots, upload staging, sync plans/baselines/receipts contain private bytes and have no automatic garbage collection. Content/catalog freshness defaults are five minutes/60 seconds and do not control retention. Uninstalling leaves all roots in place; preserve pinned versions and unfinished recovery receipts. Cache clearing retires only disposable observations through system Trash. [Cleanup guidance](usage.md#upgrade-and-uninstall) and [security policy](../SECURITY.md).
|
|
20
20
|
|
|
21
21
|
## Startup metadata integration
|
|
22
22
|
|
|
23
|
-
A startup hook runs ntn-skills list and injects Skill name/description/ID/alias/ref metadata together with the
|
|
23
|
+
A startup hook runs `ntn-skills list` and injects Skill name/description/ID/alias/ref metadata together with the database map, `source`, `freshness`, `fetched_at` and `coverage`. Join database_id to title/domain alias; keep these separate from invocation alias. List paginates without bodies/manifests; `--query` retains the full queried database map. Catalog default age is 60 seconds; use `--refresh` for fresh discovery or intentional `--offline` for cached discovery. Preserve failed_sources identities and incomplete/search-limited coverage. Hosts retain both same-alias pages across databases and select by database scope/page-ID ref rather than a name-only map.
|
|
24
24
|
|
|
25
|
-
Each listed `name` is the English Notion display title; `alias` is its lowercase form with spaces replaced by hyphens. Use this invocation name when exposing a skill to the host.
|
|
25
|
+
Each listed `name` is the English Notion display title; `alias` is its lowercase form with spaces replaced by hyphens. Use this invocation name when exposing a skill to the host. References mode generates matching frontmatter from properties; native Skills mode validates export frontmatter on online activation. Propagate `INVALID_SKILL_NAME` and `INVALID_SKILL` instead of synthesizing a different name.
|
|
26
26
|
|
|
27
|
-
On activation, call `ntn-skills read <ref>` with an actual ref returned by list. Require `ok: true` and retain `content`, `source`,
|
|
27
|
+
On activation, call `ntn-skills read <ref>` with an actual current ref returned by list. Require `ok: true` and retain `content`, `source`, `freshness`, pinned `ref`, `snapshot_id` and `version_id`. Ordinary reads may select content validated within five minutes (`source=local_cache`); use `--refresh` when activation requires current remote access/content (`source=notion`). Hosts must preserve the observation time/age/limit/stale status, not infer freshness from snapshot creation. Once selected, the complete snapshot fixes supporting instructions for the task. List all files with `["files", snapshot_id]` and follow pinned refs (`source=local_snapshot`); pinned versions do not claim latest freshness. Inspecting, summarizing, editing or configuring a Skill does not activate its instructions. Downloaded contents/scripts never execute automatically. [Read walkthrough](usage.md#reading-a-fixed-version).
|
|
28
28
|
|
|
29
29
|
All --database flags accept one ID, URL or exact case-sensitive registered alias. Register domains with source add frontend --database DATABASE_ID, then invoke ["read", name, "--database", "frontend"]. Database titles are display labels only. Repeated --database values return INVALID_ARGUMENT before online access/mutation. config set-default accepts the same selector but stores its ID and affects create/import only. Pinned requests with an alias constraint resolve it locally and enforce cached database ownership. See [database selection](protocol.md#identity-and-references).
|
|
30
30
|
|
|
31
|
+
Databases with rich-text Description and References are discoverable alongside native Skills databases. References mode reads page Markdown, materializes included pages under references/, and rewrites Notion page links relative to the containing file. The version includes every reference page, so child-only edits can cause WRITE_CONFLICT. Host adapters use the same commands and pinned refs for either storage mode. See [References pages](protocol.md#references-pages).
|
|
32
|
+
|
|
31
33
|
## Built-in Read protocol integration
|
|
32
34
|
|
|
33
35
|
An adapter implements the host's URI dispatch contract:
|
|
@@ -35,20 +37,30 @@ An adapter implements the host's URI dispatch contract:
|
|
|
35
37
|
1. Accept only `skill://` requests owned by this adapter. A host already using this scheme must make routing explicit; do not override its existing local skill handler.
|
|
36
38
|
2. Invoke the executable with an argument array: `["read", uri]`. No shell interpolation.
|
|
37
39
|
3. Parse stdout as JSON and honor both `ok` and exit status.
|
|
38
|
-
4. Return `content`, `path`, `ref`, `snapshot_id`, `version_id`, `source`, `range`, and `has_more` to the Agent. Accept additional JSON fields and propagate unfamiliar error codes as failures.
|
|
40
|
+
4. Return `content`, `path`, `ref`, `snapshot_id`, `version_id`, `source`, `freshness`, `range`, and `has_more` to the Agent. Accept additional JSON fields and propagate unfamiliar error codes as failures.
|
|
39
41
|
5. Persist the returned snapshot in the host's activation state. Subsequent relative reads must use pinned refs or pass `--from` with the pinned containing-file ref.
|
|
40
42
|
6. Forward errors as tool failures, including candidate IDs and coverage. Never turn errors into an empty skill document.
|
|
41
43
|
7. Handle binary assets through --output and a host viewer. Identical existing bytes return reused=true; differing output fails with OUTPUT_CONFLICT. Never execute imported scripts automatically.
|
|
42
44
|
|
|
43
45
|
The CLI accepts `--lines` to implement ranged text reads, and `resolve` to preserve versions while resolving relative references. An adapter should not reimplement name matching or path normalization.
|
|
44
46
|
|
|
47
|
+
An adapter may expose one of `--refresh`, `--offline` or `--max-age DURATION` for a current target; the flags are mutually exclusive. Pinned targets or pinned relative `--from` reject refresh/max-age and permit redundant offline. Failed online validation never silently falls back to stale content. A cached observation does not prove current permission; use JSON for freshness metadata rather than raw text. [Read-policy usage](usage.md#reading-a-fixed-version).
|
|
48
|
+
|
|
45
49
|
## Explicit write integration
|
|
46
50
|
|
|
47
51
|
For authorized Skill maintenance, invoke `["write", uri, "--input", localFile]` with an argument array. Use the ref returned by read as the version baseline. A successful write returns a new snapshot; adopt it explicitly for subsequent work and preserve the old activation snapshot for tasks already using it. Do not route host Write requests to local snapshot objects. CLI support for skill:// writes does not register a built-in Write adapter.
|
|
48
52
|
|
|
49
|
-
Use
|
|
53
|
+
Use `--dry-run` to report a concrete target/action. Propagate conflicts and partial/unknown results without automatic retries. Create/import without target choose explicit database > configured default > sole fresh discovery. Inputs are ZIP/folder/Markdown; `--name`/`--description` override metadata. `import INPUT --target TARGET` instead selects one existing current page or pinned main-version baseline, preserves page ID through rename and fails without create/name fallback; database is a constraint. Reject reference-file targets. References become editable pages; omitted references remain in Notion. Files preserves original bytes/frontmatter/assets; page-only output is normalized. Success returns verified snapshot metadata. [Mutation contract](protocol.md#mutation-contract).
|
|
54
|
+
|
|
55
|
+
For portable output, invoke `["export", selector, "--output", localPath]`, optionally with `--format zip|directory`. Pinned selection is offline; current selection uses bounded content policy, with `--refresh` for fresh remote validation. Preserve `.ntn-skills.json` for reimport. Identical destinations return `reused=true`; differing destinations fail with `OUTPUT_CONFLICT`. Export never mutates Notion. [Portable contract](protocol.md#portable-export-contract).
|
|
56
|
+
|
|
57
|
+
## Explicit local synchronization
|
|
58
|
+
|
|
59
|
+
Hosts can register a logical distribution directory with `["sync", "bind", pageId, "--path", directory, "--as", label]`. If contents differ or the ordinary local leaf is absent, review a single-binding `sync plan LABEL --from notion|local`, then `sync apply --plan PLAN_ID`. Later `sync plan LABEL` or `sync plan --all` compares each confirmed common baseline. `--output` saves an identical review copy; apply accepts its path and still checks registered binding, plan digest, remote version/scope, baseline generation, local hashes and resolved link proof.
|
|
60
|
+
|
|
61
|
+
`sync status` is local/provisional unless refreshed; it cannot activate or advance a baseline. Baselines advance only after verified convergence. Preserve operation receipts on interruptions; `sync reconcile LABEL` reads actual outcomes without replay, and affected resources stay fenced while outcome is unresolved. Logical directory/parent/per-file links survive writes to final destinations; link drift rejects a saved plan. Commit-boundary guards do not supply an atomic guarantee against external link retargeting. Removed/replaced bytes require system Trash retention. `sync unbind LABEL` deactivates configuration while retaining content/baselines/plans/receipts. [Workflow and limits](usage.md#synchronizing-local-skills).
|
|
50
62
|
|
|
51
|
-
|
|
63
|
+
Expose offline `cache status` for effective roots/observations and `cache clear TARGET [--database SELECTOR]` or `cache clear --all` with optional `--dry-run`. Clear retires only disposable observations through system Trash; immutable versions and sync state remain. `config set-cache-policy --read-max-age 5m --catalog-max-age 60s` and `config clear-cache-policy` control defaults without changing authentication/sources/bindings. [Cache usage](usage.md#cache-policy-and-cleanup).
|
|
52
64
|
|
|
53
65
|
|
|
54
66
|
This repository ships the portable Skill, CLI, and adapter contract. It does not register adapters into unrelated Agent applications or alter their global configuration.
|
package/docs/protocol.md
CHANGED
|
@@ -16,14 +16,28 @@ Consumers should accept additional JSON fields and treat unfamiliar error codes
|
|
|
16
16
|
skill://<encoded-selector>/<encoded-relative-path>?snapshot=s_<64-hex>
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
Notion Name is 1-64 characters and matches `^[A-Za-z]+(?: [A-Za-z]+)*$`: ASCII English letters with single spaces between words. Lowercasing and replacing each space with `-` yields the invocation name. Each listed `name` holds the Notion display title; `alias` holds the invocation name. For `Release Review`, that name is `release-review`.
|
|
19
|
+
Notion Name is 1-64 characters and matches `^[A-Za-z]+(?: [A-Za-z]+)*$`: ASCII English letters with single spaces between words. Lowercasing and replacing each space with `-` yields the invocation name. Each listed `name` holds the Notion display title; `alias` holds the invocation name. For `Release Review`, that name is `release-review`. References mode generates matching `SKILL.md` frontmatter from page properties. Native Skills activation requires the export's frontmatter `name` and root directory to equal the invocation name, including cached exports. Descriptions and file contents have no English-only restriction.
|
|
20
20
|
|
|
21
|
-
All target commands (`read`, `files`, `open`, `write`, `export`) accept exact display Name, invocation alias, page ID, Notion page URL, `skill://` ref or snapshot ID. Distinct pages sharing an invocation alias are ambiguous; returned pinned refs use page IDs. Historical snapshots preserve their original identity. Unpinned reads/files/open/exports
|
|
21
|
+
All target commands (`read`, `files`, `open`, `write`, `export`) accept exact display Name, invocation alias, page ID, Notion page URL, `skill://` ref or snapshot ID. Distinct pages sharing an invocation alias are ambiguous; returned pinned refs use page IDs. Historical snapshots preserve their original identity. Unpinned reads/files/open/exports reuse complete eligible observations within the configured age limit; an expired or explicitly refreshed request validates current access and the complete page/file version online. Pinned refs and snapshot IDs load immutable cached content offline, verify identity and honor an explicit --database constraint. Writes always check online access; pinned mutation targets provide the expected version baseline.
|
|
22
22
|
|
|
23
23
|
All --database flags accept exactly one ID, Notion URL or case-sensitive exact registered alias. IDs/URLs take priority; titles never implicitly select databases. Unknown aliases return DATABASE_NOT_FOUND with registrations as candidates; conflicting mappings return DATABASE_AMBIGUOUS. Online selection validates the selected database and never falls back. Repeated --database values (including identical values and --database=value syntax) return INVALID_ARGUMENT/exit 2 before the handler; explicit help still takes precedence. source add accepts the same selector when registering/renaming a source. config set-default resolves it online and stores a canonical ID. Omitted read selectors discover broadly; the creation default affects create/import only. Pinned read/files/open/export constraints resolve aliases locally and check the cached database_id, so no authentication/network request is introduced.
|
|
24
24
|
|
|
25
25
|
`read <target> [--path <file>]` defaults to SKILL.md. `files <target> [--path <file-or-directory>]` lists all files when neither the target nor --path supplies a path; a file ref filters its own path. Use `files <snapshot_id>` to list the complete fixed version after a read. A pathless `skill://<selector>` target may use --path; a ref already containing a path rejects --path. `read relative-path --from containing-file-ref` resolves from that file's directory, preserves its snapshot and rejects --path or a non-relative target. `resolve` is an optional offline helper. Query strings accept only one snapshot; malformed encoding, unsupported parameters, absolute paths, backslashes, NUL bytes and traversal escaping the Skill root fail. There is no --snapshot mode or second positional file path.
|
|
26
26
|
|
|
27
|
+
## References pages
|
|
28
|
+
|
|
29
|
+
A database is discoverable when it is a native Skills database or its data source has rich-text `Description` and `References` properties. References mode takes precedence whenever the Skill page has References; otherwise native Skills use the export endpoint. Page mode needs Read content access and does not require the Skills export API. `doctor` reports `skill_read.storage` as `references` or `native_skills` after reading one available Skill.
|
|
30
|
+
|
|
31
|
+
`References` is the complete inclusion list of Notion page mentions or page links, with optional whitespace separators. Property items are fully paginated. Link text ending in `.md` specifies a path under `references/`; other labels use the referenced page title, normalized to a lowercase filename. Chinese titles and nested paths are supported. Repeated page IDs are included once. Duplicate paths, unsafe paths, unavailable pages and incomplete Markdown fail rather than silently dropping content. Pages linked only from the body are not automatically included.
|
|
32
|
+
|
|
33
|
+
Reads materialize the main page as canonical `SKILL.md` and each reference page as UTF-8 Markdown. Links to included pages become relative to the containing file, including links back to SKILL.md; anchors are retained. Markdown links, reference definitions, page mentions and bare URLs are supported. Fenced and inline code, unrelated URLs and links to pages outside the inclusion list remain unchanged. Main-page child-page blocks are excluded from the local body and preserved during replacement.
|
|
34
|
+
|
|
35
|
+
The version digest covers Name, Description, References property items, every included page's ID/path/Markdown and attachment content hashes. Editing a reference page alone invalidates a pinned write. The resulting complete snapshot is immutable and supports offline reads and exports.
|
|
36
|
+
|
|
37
|
+
Create/import convert `references/**/*.md` to editable child pages, allocating all page IDs before rewriting forward or cyclic links. References stores labeled paths. Write replaces one reference page or adds a new page; import replaces the complete inclusion list. Omitted pages remain in Notion and are excluded from new snapshots and portable exports, including preserved source bundles. At most 100 reference pages may be submitted per Skill.
|
|
38
|
+
|
|
39
|
+
`Files` is optional. With Files, the source bundle preserves source bytes, filenames, extra Skill frontmatter and non-reference assets. Without Files, only a main Markdown file and reference Markdown are accepted; export normalizes the main filename to `SKILL.md`, Skill frontmatter and Markdown formatting. Reimport compares normalized page content to allow reuse. `content_id` on successful mutations/reuse identifies the saved portable content, matching export. Keep Files when byte-for-byte source preservation or arbitrary assets are required.
|
|
40
|
+
|
|
27
41
|
## Success
|
|
28
42
|
|
|
29
43
|
```json
|
|
@@ -41,7 +55,7 @@ All --database flags accept exactly one ID, Notion URL or case-sensitive exact r
|
|
|
41
55
|
}
|
|
42
56
|
```
|
|
43
57
|
|
|
44
|
-
`source=notion` identifies
|
|
58
|
+
`source=notion` identifies online validation, `source=local_cache` an unpinned cached observation, and `source=local_snapshot` an explicitly pinned version. Read/open/files/export/list responses carry `freshness` with policy, `validated_at` (ISO timestamp), `age_ms`, `max_age_ms` and `stale`. Cached hits do not move validation time. Pinned freshness uses policy `pinned` and omits latest-validation fields; snapshot creation is not proof of remote freshness. `list` retains scope, fetched_at, databases, skills, count and coverage without bodies/file manifests. Each database has database_id/title/alias/data_source_ids; Skill aliases remain invocation names. --query filters after pagination and retains the queried database map. Cache freshness never upgrades discovery coverage or suppresses failed_sources.
|
|
45
59
|
|
|
46
60
|
`open` returns snapshot metadata without bodies and is optional. `files` emits file paths, sizes and pinned refs. `read --output` returns output, bytes and reused: exact existing bytes return reused=true, differing output returns OUTPUT_CONFLICT; output is never overwritten. --lines uses inclusive 1-based ranges and is incompatible with output; --raw also rejects output.
|
|
47
61
|
|
|
@@ -51,6 +65,19 @@ Authentication selects non-empty config.token > non-empty NOTION_API_TOKEN > exi
|
|
|
51
65
|
|
|
52
66
|
Authentication scope hashes user identity, workspace, API endpoint and the selected credential digest (or an ntn-login marker). Different selected tokens separate online metadata/snapshot caches, even for the same user; the same token from config/environment yields the same scope. Older credential-scope formats remain valid for offline pinned reads; obtain a fresh online ref before writing against a snapshot created with an older scope.
|
|
53
67
|
|
|
68
|
+
## Read policy and cache management
|
|
69
|
+
|
|
70
|
+
`read`, `open`, `files`, `export` and `list` accept mutually exclusive `--refresh`, `--offline` and `--max-age DURATION`. Content defaults to 300,000 ms, catalogs to 60,000 ms. Omitted flags reuse an eligible complete observation; otherwise validate online. `--refresh` always validates online. `--offline` reads locally selected observations even when expired and reports their age; missing/unsafe scope fails explicitly. `--max-age 0` forces online validation. Expired online reads wait, and failure neither updates validation time nor returns stale content implicitly. Current caller code requiring fresh readback must pass `--refresh`.
|
|
71
|
+
|
|
72
|
+
Pinned snapshot IDs/refs, including relative reads from a pinned `--from`, always select one immutable local version. `--offline` is redundant but allowed; `--refresh` and `--max-age` are invalid arguments. Mutation/import/sync plan/apply/reconcile and doctor always validate online and do not accept read-policy shortcuts. `--raw` returns text only, so freshness consumers must use JSON.
|
|
73
|
+
|
|
74
|
+
Durations accept finite nonnegative integer `0`, `Ns`, `Nm`, `Nh` or `Nd`; nonzero bare numbers, fractions, negatives and overflow return INVALID_ARGUMENT before online work. `config set-cache-policy --read-max-age DURATION --catalog-max-age DURATION` saves at least one supplied default offline, preserving other configuration. `config clear-cache-policy` restores built-in defaults without removing content/state. `config show` includes `effective_cache_policy` in milliseconds and sanitized settings.
|
|
75
|
+
|
|
76
|
+
Local token identity, workspace and endpoint select a previously verified account scope without network. A different token never reuses another scope, even for the same user. Official-login identity cannot be safely distinguished locally; normal reads still validate it online, and unpinned offline selection returns CACHE_SCOPE_UNAVAILABLE. Name selection requires a complete compatible scoped catalog; ambiguity/failed-source discovery cannot be resolved from arbitrary latest entries. Explicit pinned reads retain their offline behavior.
|
|
77
|
+
|
|
78
|
+
`cache status [TARGET] [--database SELECTOR]` is offline and returns effective `config_directory`, `state_directory`, `cache_directory`, effective cache policy, recorded scopes, observations and catalogs. Without a target it can inspect multiple scopes without identifying one as the current account. `cache clear TARGET [--database SELECTOR] [--dry-run]` or `cache clear --all [--dry-run]` retires only disposable observations through system Trash. Exactly one target or --all is required. Target clearing conservatively retires catalogs that contain the page or cannot prove appropriate complete coverage. Snapshots, objects, bindings, baselines, plans and receipts survive. Missing Trash capability fails explicitly; no permanent-deletion fallback exists.
|
|
79
|
+
|
|
80
|
+
|
|
54
81
|
## Environment and local storage
|
|
55
82
|
|
|
56
83
|
| Variable | Contract |
|
|
@@ -61,40 +88,68 @@ Authentication scope hashes user identity, workspace, API endpoint and the selec
|
|
|
61
88
|
| `XDG_CONFIG_HOME` | Base for the `ntn-skills` configuration directory |
|
|
62
89
|
| `NTN_SKILLS_HOME` | Full application state directory |
|
|
63
90
|
| `XDG_STATE_HOME` | Base for the `ntn-skills` state directory |
|
|
91
|
+
| `NTN_SKILLS_CACHE_HOME` | Full disposable application-cache directory |
|
|
92
|
+
| `XDG_CACHE_HOME` | Base for the `ntn-skills` cache directory |
|
|
64
93
|
| `NOTION_WORKSPACE_ID` | Hashed into authentication scope, default empty, and inherited by `ntn` for workspace selection under its authentication rules |
|
|
65
94
|
| `NOTION_API_BASE_URL` | Hashed into authentication scope, default `https://api.notion.com`, and inherited by `ntn api` as its API base URL override |
|
|
66
95
|
|
|
67
96
|
Both variables isolate cache scopes and reach the `ntn` child process through its inherited environment. Workspace selection follows [official CLI authentication](https://developers.notion.com/cli/get-started/authentication); API routing follows `ntn api --help`. Only use a trusted API endpoint, since `ntn` may send its authentication credential to it. Archive downloads follow signed URLs returned by the service and do not rewrite them using this override.
|
|
68
97
|
|
|
69
|
-
State defaults to `~/.local/state/ntn-skills`,
|
|
98
|
+
State defaults to `~/.local/state/ntn-skills`, selected by `NTN_SKILLS_HOME` > `$XDG_STATE_HOME/ntn-skills`. It retains immutable `snapshots`, content-addressed `objects`, upload staging and synchronization baselines/plans/receipts. Disposable observation indexes live in `NTN_SKILLS_CACHE_HOME` > `$XDG_CACHE_HOME/ntn-skills` > `~/.cache/ntn-skills`; configuration remains separate. Old state-directory catalogs remain historical data and do not manufacture a fresh current Skill observation. An empty new cache triggers validation; it never removes historical snapshots or initializes a sync baseline. Cache coordination records remain durable across observation retirement so delayed publishers cannot restore cleared data. No automatic garbage collection deletes retained content or staging.
|
|
99
|
+
|
|
100
|
+
Cache retirement holds the selected observation-generation locks, persists every content/catalog invalidation fence, then starts moving files to system Trash. If retention is unavailable or fails, the command returns an explicit error and preserves unmoved bytes; the fenced observations are still unavailable to current reads/status, and delayed publishers cannot restore them. Immutable pinned reads and sync recovery state remain available. This is not an all-or-nothing filesystem transaction.
|
|
70
101
|
|
|
71
|
-
The CLI sends no analytics or telemetry requests of its own. Online operations call the selected `ntn` process for
|
|
102
|
+
The CLI sends no analytics or telemetry requests of its own. Online operations call the selected `ntn` process for authentication/API/uploads and download archives from signed service URLs; this does not attest to `ntn`'s own policies. Local access covers configuration/state/cache, supplied inputs, requested outputs and explicitly bound local Skill destinations. Mutations may upload local inputs; imported scripts are never executed. See [SECURITY](../SECURITY.md) for trust/retention boundaries and [uninstall guidance](usage.md#upgrade-and-uninstall) for cleanup.
|
|
72
103
|
|
|
73
104
|
## Mutation contract
|
|
74
105
|
|
|
75
|
-
`config.json` accepts optional sources, default_database and token. `config set-default <ID-or-URL-or-alias>` validates
|
|
106
|
+
`config.json` accepts optional sources, default_database, token, cache_policy and sync_bindings. Config operations preserve other settings and never expose token values. `config set-default <ID-or-URL-or-alias>` validates online and saves a canonical ID; `config clear-default` works offline. Create/import without a target choose --database > configured default > sole freshly discovered Skills Database. Name conflict/reuse/update decisions are scoped to that database; failed defaults/sources never fall back and ambiguous data sources require explicit selection.
|
|
76
107
|
|
|
77
|
-
Create/import share inputs
|
|
108
|
+
Create/import share inputs: one ZIP, folder or .md/.markdown file. A portable manifest selects metadata/entrypoint; otherwise choose SKILL.md or a unique top-level Markdown after removing one enclosing directory. Any single Markdown filename is the entrypoint. --name/--description override metadata; missing names derive from English filenames and missing descriptions require --description. Ordinary frontmatter stays in the body. With Files, extra Skill frontmatter and all source bytes/names/nested paths are retained in ntn-skills-source.zip; page-only mode follows [the normalization rules](#references-pages). Imported page IDs never select a target. ZIP input max 32 MiB compressed; expanded/folder max 128 MiB and 10,000 entries. The generated source ZIP fits 20 MiB compressed, 128 MiB and 10,000 entries including its manifest. Unsafe/duplicate/reserved paths, links, special files, unsupported ZIP forms and checksum failures fail before mutation.
|
|
78
109
|
|
|
79
|
-
|
|
110
|
+
Create and import without --target freshly query the selected database by invocation alias. Multiple matches return SKILL_AMBIGUOUS; create rejects an existing invocation with CREATE_CONFLICT. Import creates an absent name, reuses identical portable content, or replaces differing whole-Skill content on the existing page. `import INPUT --target TARGET` resolves one existing page once and never falls back to creation or another name. Current targets capture an online baseline; pinned snapshot/main refs enforce expected version, scope and database ownership. Reference-file targets are rejected. --name/--description change source metadata only; a new imported name does not redirect the page. --database constrains a target rather than choosing a creation default. The same save/References path is used by synchronization. The portable digest hashes display Name, Description, main path and sorted file hashes; page-only reuse follows normalized Markdown equality. Version checks precede the first mutation and uploaded-file commit, without a server-side atomic guarantee.
|
|
80
111
|
|
|
81
|
-
`write <target> [--path <file>] --input <local-file>` replaces one logical file, default SKILL.md, and preserves the other files. A pinned ref or snapshot ID is a baseline, never a mutable snapshot destination; stale remote versions return WRITE_CONFLICT. SKILL.md requires name/description and checks system-owned notion_page_id against the target.
|
|
112
|
+
`write <target> [--path <file>] --input <local-file>` replaces one logical file, default SKILL.md, and preserves the other files. A pinned ref or snapshot ID is a baseline, never a mutable snapshot destination; stale remote versions return WRITE_CONFLICT. SKILL.md requires name/description and checks system-owned notion_page_id against the target. With Files, extra frontmatter, nested paths and binary bytes are preserved in the source ZIP. References paths write their corresponding Notion pages. Reserved portability files cannot be written directly. Identical original source or current SKILL.md bytes return action=unchanged, unchanged=true and the existing pinned ref without mutation/upload. Upload staging remains private under uploads/<sha256>/<filename>.
|
|
82
113
|
|
|
83
114
|
Successful create/import/write returns snapshot metadata, operation, action, verified=true, content_id and pinned refs. Create/import add input_type, main_path and reused; actions are create, reuse or update. Writes add path, previous_version_id and unchanged. --dry-run performs the same preflight reads and reports the decision with dry_run=true but never uploads or mutates. Reuse/unchanged results retain the current snapshot. Historical snapshots remain immutable.
|
|
84
115
|
|
|
85
|
-
New pages create properties first, then non-empty Markdown to preserve initial H1 headings; updated pages replace the old Markdown and retain their ID. Source ZIPs record
|
|
116
|
+
New pages create properties first, then non-empty Markdown to preserve initial H1 headings; updated pages replace the old Markdown and retain their ID. Source ZIPs record normalized body/name/description and reference-page projections before attachment. Verification compares the saved portable identity with the submitted content; page-only mode compares normalized Markdown. Endpoint paragraph spacing and equivalent plain-text code labels are normalized; fenced-code blank lines remain literal. Insert/Update and Read content are required for mutation/uploads/verification. Dry runs cannot prove service acceptance. ntn 0.22.12 sometimes emits an API failure only on stderr; such mutation outcomes remain WRITE_OUTCOME_UNKNOWN.
|
|
86
117
|
|
|
87
118
|
Version checks are client preflight checks, not an atomic compare-and-swap. Body and property requests are separate operations. There is no automatic rollback or retry of mutation requests. `WRITE_PARTIAL` reports page/database, stage, completed operations and cause; `WRITE_OUTCOME_UNKNOWN` requires readback before retrying because the request may have succeeded. Creation without a returned ID after an uncertain response requires inspecting the target database before creating again.
|
|
88
119
|
|
|
120
|
+
Reference imports register each allocated child page before writing its body. After readback, an explicit repeat import also discovers matching Markdown child pages left by an interrupted registration; it reuses their IDs and rejects duplicate paths with REFERENCE_PATH_CONFLICT. Completed bodies are not rewritten. Page-only identity treats equivalent local links such as `references/guide.md` and `./references/guide.md` consistently.
|
|
121
|
+
|
|
122
|
+
|
|
89
123
|
|
|
90
124
|
## Portable export contract
|
|
91
125
|
|
|
92
|
-
`export <name-or-page-or-ref-or-snapshot> --output <path> [--format zip|directory]`
|
|
126
|
+
`export <name-or-page-or-ref-or-snapshot> --output <path> [--format zip|directory]` writes every portable file plus `.ntn-skills.json`. .zip selects ZIP, other paths directory. Current inputs follow the read policy; fixed refs/snapshot IDs are offline. --refresh/--offline/--max-age select input freshness only, never authorize replacing different output. Export never mutates Notion.
|
|
93
127
|
|
|
94
|
-
The manifest contains format="ntn-skills", version=1, display name, description and main path. It adds no page/version IDs, snapshot IDs or timestamps. `.ntn-skills.json` and `ntn-skills-source.zip` are reserved paths. Source ZIPs additionally record
|
|
128
|
+
The manifest contains format="ntn-skills", version=1, display name, description and main path. It adds no page/version IDs, snapshot IDs or timestamps. `.ntn-skills.json` and `ntn-skills-source.zip` are reserved paths. Source ZIPs additionally record normalized remote body/name/description and reference-page projections; these internal projections are omitted from portable exports. Original source bytes are retained while their recorded projections match. Changed body/metadata regenerates the main file with canonical frontmatter, preserving extra fields and excluding notion_page_id. Changed reference pages replace their corresponding source files, and removed references are excluded. Native Skills use canonical SKILL.md plus exported attachments. Import expands the retained source ZIP for nested reads. Libraries without Files export normalized page Markdown as described in [References pages](#references-pages).
|
|
95
129
|
|
|
96
130
|
ZIP entries sort by path and use fixed timestamps/compression. Identical content yields identical ZIP bytes across different page identities. ZIP output uses the 20 MiB direct-upload bound; portable content is limited to 128 MiB and 10,000 entries including the manifest. Preserve the manifest when reimporting to retain arbitrary main filenames and display-title casing. An identical existing ZIP/directory returns reused=true; any differing files/content return OUTPUT_CONFLICT without overwrite. A successful export returns operation=export, format, output, reused, content_id, main_path and files with byte counts, alongside snapshot metadata. Verification hashes every cached object before output.
|
|
97
131
|
|
|
132
|
+
## Synchronization
|
|
133
|
+
|
|
134
|
+
`sync bind TARGET --path DIR [--as LABEL] [--database SELECTOR] [--dry-run]` registers one existing current page and an absolute logical local directory. It retains logical spelling and canonical page/database/data-source/scope identities; later operations use page ID. Multiple distributions have independent bindings/baselines. Historical or file targets fail. Label collision requires --as; exact edges reuse their registered label, and a differing supplied --as fails rather than silently relabeling. Different pages targeting one real directory fail before writes. A missing ordinary leaf under a resolvable existing parent permits initial pull; dangling/cyclic links fail. Equal checked contents initialize a baseline; differences require explicit initialization source. Dry-run saves no binding/baseline.
|
|
135
|
+
|
|
136
|
+
`sync status [BINDING] [--refresh]` returns local/common identities, baseline generation, logical/resolved paths, remote snapshot/version/observation age/staleness and pending receipts. Default uses local state/cache without network and marks comparison provisional. Omitted binding lists active registrations. Refresh validates remote state but never advances the common baseline.
|
|
137
|
+
|
|
138
|
+
`sync plan BINDING [--from local|notion] [--output JSON_FILE]` or `sync plan --all [--output JSON_FILE]` strongly reads both sides against their common baseline. One-sided changes choose push/pull; equal new content advances the baseline without content writes; differing two-sided changes return SYNC_CONFLICT with a retained non-executable plan. Differing first binds require --from. Explicit source selection is single-binding only and still enforces every saved precondition. No force or TTY conflict choice exists.
|
|
139
|
+
|
|
140
|
+
Plans persist under `sync/plans/p_<sha256>.json` in state. The digest covers format/version, exact binding configuration, baseline generation/content, expected remote snapshot/version, local hashes, logical/resolved link proofs, source/direction, intended file set and actions. Output contains plan_id/plan_path/applicable/conflicts and per-binding preconditions. --output reuses identical review-copy bytes and rejects differing output. Planning changes no content/common baseline. An exact copied plan must match its registered artifact/configuration; helper import-plan JSON cannot be applied.
|
|
141
|
+
|
|
142
|
+
`sync apply --plan PLAN_ID_OR_FILE` verifies the artifact and all participants' current binding, base, credential scope, remote version/content, local hashes and target/link proofs before its first content write. Actual preconditions determine validity, not plan age. A page group accepts one candidate; differing local candidates conflict before writes. One verified push can fan out to unchanged independent copies. The remote update reuses the whole-Skill writer, then reads back before local fan-out. Each independently verified convergence advances its own baseline; later runtime failures may leave earlier participants complete.
|
|
143
|
+
|
|
144
|
+
An operation receipt is durable before effects, with page-group/per-binding stages, baseline generations and retained-byte locations. Apply returns plan_id/operation_id/verified/receipt_path/receipt and binding actions. Partial/unknown outcomes preserve unfinished bases and receipts. Unresolved receipts fence overlapping page/real-target applies. Live process holders are locked out; proven-dead same-host holders can be retired for recovery without dropping receipts. Malformed state fails explicitly, never becomes overwrite permission.
|
|
145
|
+
|
|
146
|
+
`sync reconcile BINDING` freshly reads both sides without replaying content writes. Recorded intended content and target proofs must agree before closing a receipt and promoting a baseline. Classified divergence retains the old base, returns nonzero and permits deliberate replanning; unsafe/unresolved outcomes retain their fence. Retained inactive bindings remain recoverable. `sync unbind BINDING [--dry-run]` deactivates configuration, invalidates saved applies and retains content/bases/plans/receipts.
|
|
147
|
+
|
|
148
|
+
Reconcile permits the original binding configuration or one intervening unbind while that binding remains inactive. Reactivating, relabeling or otherwise changing its revision before recovery returns `SYNC_PLAN_STALE` and retains the fence. Reconcile unfinished operations before rebinding; deleting receipts or rebinding does not authorize recovery.
|
|
149
|
+
|
|
150
|
+
The local writer resolves root, parent, relative/multi-hop directory and per-file links, stages content and commits to final real files while preserving links during updates. Tracked removal retains old bytes through system Trash; unrelated root files survive. Every actual mkdir/rename/retirement boundary checks saved target proofs, including byte-identical link retargets. Node lacks a portable fd-relative path compare-and-swap: a noncooperating editor may retarget after the final guard and before its syscall. Cooperating sync processes are fenced; this is not atomic protection against every external filesystem race. Notion also uses preflight/readback rather than an atomic multi-request commit.
|
|
151
|
+
|
|
152
|
+
|
|
98
153
|
## Errors
|
|
99
154
|
|
|
100
155
|
```json
|
|
@@ -118,14 +173,27 @@ ZIP entries sort by path and use fixed timestamps/compression. Identical content
|
|
|
118
173
|
| `WRITE_CONFLICT` | Read the current Skill and rebuild the edit against its new pinned ref |
|
|
119
174
|
| `WRITE_PARTIAL`, `WRITE_OUTCOME_UNKNOWN` | Inspect completed stages and read back the target before retrying |
|
|
120
175
|
| `MARKDOWN_INCOMPLETE` | Resolve truncated/unsupported page content before writing |
|
|
176
|
+
| `INVALID_REFERENCES`, `REFERENCE_PATH_CONFLICT`, `REFERENCE_NOT_FOUND` | Fix References page links, distinct safe Markdown paths and page access |
|
|
177
|
+
| `UNSUPPORTED_FILE` | Add a Files property to retain non-reference assets, or submit only main/reference Markdown |
|
|
121
178
|
| `INPUT_FAILED`, `INVALID_INPUT`, `FILE_TOO_LARGE` | Correct the local file/directory or upload size |
|
|
122
179
|
| `FILE_NOT_FOUND` | Inspect the snapshot's file list |
|
|
123
180
|
| `BINARY_FILE` | Use `--output` and an appropriate host viewer |
|
|
124
181
|
| `INVALID_REF`, `INVALID_PATH`, `INVALID_RANGE`, `INVALID_ARGUMENT` | Correct the request |
|
|
125
182
|
| `INVALID_ARCHIVE`, `INVALID_SKILL`, `ARCHIVE_TOO_LARGE` | Fix the export/import input or metadata and size limits; provide missing import metadata with --name/--description |
|
|
126
183
|
| `STATE_CORRUPT`, `STORAGE_ERROR`, `OUTPUT_FAILED` | Inspect local storage or select a new output filename |
|
|
184
|
+
| `CACHE_MISSING`, `CACHE_SCOPE_UNAVAILABLE` | Refresh an appropriate current target online or use an explicit pinned version; never guess another account |
|
|
185
|
+
| `SYNC_BINDING_MISSING`, `SYNC_BINDING_AMBIGUOUS`, `SYNC_BINDING_CONFLICT` | Choose a registered ID/label or use a distinct --as |
|
|
186
|
+
| `SYNC_INITIALIZATION_REQUIRED`, `SYNC_CONFLICT`, `SYNC_TARGET_CONFLICT` | Inspect the retained plan and choose a single-binding source or resolve incompatible candidates/targets |
|
|
187
|
+
| `SYNC_PLAN_MISSING`, `SYNC_PLAN_STALE`, `SYNC_TARGET_DRIFT` | Observe current identities and generate a new plan without bypassing preconditions |
|
|
188
|
+
| `SYNC_PENDING`, `SYNC_DIVERGED` | Run sync reconcile before new applies, retain evidence and replan after outcome classification |
|
|
189
|
+
| `SYNC_LOCAL_MISSING`, `LOCAL_MISSING`, `LOCAL_LINK_BROKEN`, `LOCAL_LINK_CYCLE`, `LOCAL_IO_ERROR` | Repair the concrete directory/link/permissions without treating missing data as deletion intent |
|
|
190
|
+
| `SYNC_LOCKED`, `RETENTION_UNAVAILABLE`, `RETENTION_FAILED`, `CACHE_RETIRE_UNAVAILABLE` | Resolve ownership or the verified system-Trash prerequisite; preserve retained bytes |
|
|
127
191
|
| `INTERNAL_ERROR` | Report a reproducible implementation failure with sanitized context |
|
|
128
192
|
|
|
129
193
|
Exit codes: 0 success, 1 operational failure, 2 CLI argument failure. There is no TTY-dependent choice of output protocol. No signed URLs or credentials appear in the protocol.
|
|
130
194
|
|
|
131
|
-
The ntn transport spaces requests by at least 350 ms. Read/query requests retry `rate_limited
|
|
195
|
+
The ntn transport spaces requests by at least 350 ms. Read/query requests retry `rate_limited`, transient service errors and nonzero-exit network/DNS/transport-timeout failures up to three times, waiting 1, 2 and 4 seconds. Authentication, access, validation, TLS, malformed successful responses and mutation requests are not retried. The current ntn JSON interface does not expose Retry-After. Each child process is scoped and has a 60-second timeout; timeouts for writes produce an unknown outcome rather than proof of failure.
|
|
196
|
+
|
|
197
|
+
Transport failures report only a safe `reason` (`timeout`, `process`, `dns`, `tls`, `network` or `invalid_response`), plus the available exit code and request path. Raw child stderr is never included, since it may contain credentials or signed URLs. Nested mutation errors retain these fields in `cause_details`.
|
|
198
|
+
|
|
199
|
+
References attachment downloads retry transport/body-stream failures, timeouts and HTTP 429/500/502/503/504 up to three times with 1/2/4-second backoff. Each attempt owns a scoped request with a 60-second timeout. TLS, denied/missing resources and invalid archives are not retried; failures expose only the logical attachment path and safe status/reason, never its signed URL.
|
package/docs/releasing.md
CHANGED
|
@@ -16,6 +16,8 @@ bun run package:check
|
|
|
16
16
|
|
|
17
17
|
Replace `0.1.1` with the intended version. Precheck fetches remote state, reads published versions, checks the clean branch and exact `HEAD == origin/main`, and runs `bun run check`. It creates no release commit or tag. `--dry-run` prints the decision without running the quality check. Both modes fetch Git refs. `package:check` creates a Bun tarball, inspects its contents, and installs it with npm into a fresh consumer for Node.js CLI and offline snapshot checks. Registry readback uses the same Node.js consumer path.
|
|
18
18
|
|
|
19
|
+
Before integration, require all four CI jobs for the PR's current head: Ubuntu and macOS 15, each with Node.js 22.19.0 and 24. Jobs run the full deterministic suite and controller-driven installed-consumer verification, then upload seven-day evidence artifacts. macOS exercises system Trash; Linux proves explicit unavailable-retention failure with preserved bytes. Real Notion acceptance remains separate and must not use PR secrets. The tag publication job repeats `check` and package verification on Linux/Node 24; it does not replace the PR's macOS/runtime matrix.
|
|
20
|
+
|
|
19
21
|
Use explicit versions for prereleases, for example `0.2.0-rc.1`. They publish to `next`; stable versions publish to `latest`. Versions use SemVer without build metadata. A version must exceed every previously tagged or published release. `patch`, `minor`, and `major` choose a bump from the highest known version; bumping from a prerelease requires an explicit version.
|
|
20
22
|
|
|
21
23
|
## First npm publication
|
package/docs/usage.md
CHANGED
|
@@ -52,11 +52,13 @@ Authentication priority is non-empty `config.token` → non-empty `NOTION_API_TO
|
|
|
52
52
|
|
|
53
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
54
|
|
|
55
|
-
Read content
|
|
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.
|
|
56
58
|
|
|
57
59
|
## Discovery and identity
|
|
58
60
|
|
|
59
|
-
Default discovery paginates Notion Search
|
|
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.
|
|
60
62
|
|
|
61
63
|
Replace database placeholders before running:
|
|
62
64
|
|
|
@@ -72,13 +74,13 @@ ntn-skills list --refresh
|
|
|
72
74
|
|
|
73
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.
|
|
74
76
|
|
|
75
|
-
`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.
|
|
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.
|
|
76
78
|
|
|
77
|
-
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`.
|
|
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).
|
|
78
80
|
|
|
79
81
|
## Reading a fixed version
|
|
80
82
|
|
|
81
|
-
An unpinned read
|
|
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.
|
|
82
84
|
|
|
83
85
|
Replace these placeholders with values returned by `list`, `read` and `files`:
|
|
84
86
|
|
|
@@ -96,11 +98,28 @@ ntn-skills read reference.md --from 'PINNED_CONTAINING_FILE_REF'
|
|
|
96
98
|
|
|
97
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.
|
|
98
100
|
|
|
99
|
-
|
|
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
|
+
|
|
100
119
|
|
|
101
120
|
## Creating, importing, exporting and updating skills
|
|
102
121
|
|
|
103
|
-
Select a database explicitly, save a creation default, or let the CLI use the sole discovered
|
|
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.
|
|
104
123
|
|
|
105
124
|
After registering `ops`, replace the pinned-ref placeholder with a ref returned by `read`:
|
|
106
125
|
|
|
@@ -118,10 +137,18 @@ ntn-skills write 'PINNED_REF_FROM_READ' --input ./SKILL.md --dry-run
|
|
|
118
137
|
ntn-skills write 'PINNED_REF_FROM_READ' --input ./SKILL.md
|
|
119
138
|
```
|
|
120
139
|
|
|
121
|
-
`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.
|
|
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.
|
|
122
141
|
|
|
123
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.
|
|
124
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
|
+
|
|
125
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.
|
|
126
153
|
|
|
127
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).
|
|
@@ -130,6 +157,59 @@ ZIP input is limited to 32 MiB compressed, 128 MiB expanded and 10,000 entries;
|
|
|
130
157
|
|
|
131
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).
|
|
132
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
|
+
|
|
133
213
|
## Commands and output
|
|
134
214
|
|
|
135
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.
|
|
@@ -138,11 +218,11 @@ The [bootstrap command reference](../skills/ntn-skills/references/commands.md) l
|
|
|
138
218
|
|
|
139
219
|
## Configuration and storage
|
|
140
220
|
|
|
141
|
-
Configuration defaults to `~/.config/ntn-skills/config.json`; state
|
|
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).
|
|
142
222
|
|
|
143
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.
|
|
144
224
|
|
|
145
|
-
State
|
|
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).
|
|
146
226
|
|
|
147
227
|
## Upgrade and uninstall
|
|
148
228
|
|
|
@@ -160,4 +240,4 @@ Remove a project dependency in each consuming project with:
|
|
|
160
240
|
npm uninstall ntn-skills
|
|
161
241
|
```
|
|
162
242
|
|
|
163
|
-
Uninstalling retains
|
|
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.
|