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/README.md
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
# Documentation
|
|
2
|
-
|
|
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
|
-
|
|
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
|
-
- [Host integration](host-integration.md): metadata injection, activation state and optional Read/Write adapters.
|
|
8
|
-
- [Releasing](releasing.md): immutable tags, first publication, Trusted Publishing, registry verification and repair.
|
|
9
|
-
- [Bootstrap Skill](../skills/ntn-skills/SKILL.md): progressive discovery and consumption from an Agent's shell tools.
|
|
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.
|
|
13
|
-
|
|
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
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
# Host integration
|
|
2
|
-
|
|
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
|
-
|
|
5
|
-
## Portable shell integration
|
|
6
|
-
|
|
7
|
-
The host needs Node.js 22.19.0 or newer on PATH to launch the installed `ntn-skills` executable. Install the built package with npm using [the consumer installation instructions](../README.md#installation); online operations also need the official `ntn` CLI. Bun belongs to the repository's development/build path.
|
|
8
|
-
|
|
9
|
-
Install `skills/ntn-skills` in the host's supported local skill directory. Add this instruction when the host needs a broad remote-library trigger:
|
|
10
|
-
|
|
11
|
-
> When a task may benefit from a workflow in the Notion skill library, use the ntn-skills bootstrap Skill to discover applicable workflows before choosing one. Read metadata first, then only the selected workflow's files.
|
|
12
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
21
|
-
## Startup metadata integration
|
|
22
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
33
|
-
## Built-in Read protocol integration
|
|
34
|
-
|
|
35
|
-
An adapter implements the host's URI dispatch contract:
|
|
36
|
-
|
|
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.
|
|
38
|
-
2. Invoke the executable with an argument array: `["read", uri]`. No shell interpolation.
|
|
39
|
-
3. Parse stdout as JSON and honor both `ok` and exit status.
|
|
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.
|
|
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.
|
|
42
|
-
6. Forward errors as tool failures, including candidate IDs and coverage. Never turn errors into an empty skill document.
|
|
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.
|
|
44
|
-
|
|
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.
|
|
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
|
-
|
|
49
|
-
## Explicit write integration
|
|
50
|
-
|
|
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.
|
|
52
|
-
|
|
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).
|
|
62
|
-
|
|
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).
|
|
64
|
-
|
|
65
|
-
|
|
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.
|
|
67
|
-
|
|
68
|
-
The [bootstrap Skill integration reference](../skills/ntn-skills/references/integration.md) follows the same contract. Package maintenance and publishing use [the release procedure](releasing.md).
|
package/docs/protocol.md
DELETED
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
# CLI and ref contract
|
|
2
|
-
|
|
3
|
-
The npm package and executable are `ntn-skills`; the source repository is `notion-skills-cli`. Normal operation outputs one JSON value on stdout. Help and version use Effect CLI's text rendering. `--raw` opts into successful plain text. Failures always return JSON, including parse errors, and nonzero status.
|
|
4
|
-
|
|
5
|
-
The distributed CLI requires Node.js 22.19.0 or newer, matching the Node platform dependency's minimum. npm installs the built tarball and its runtime dependencies; Bun is used only for repository development, building, packing and tests. Online operations additionally require the official `ntn` CLI. See [installation](../README.md#installation) and [contributor setup](../CONTRIBUTING.md#development-setup).
|
|
6
|
-
|
|
7
|
-
For installation and a first successful read, use [the README Quick start](../README.md#quick-start). [Host integration](host-integration.md) describes adapter behavior, [the bootstrap integration reference](../skills/ntn-skills/references/integration.md) covers Agent use, and [the release procedure](releasing.md) describes distribution.
|
|
8
|
-
|
|
9
|
-
Consumers should accept additional JSON fields and treat unfamiliar error codes as structured failures. Existing fields and successful operations keep their documented meaning within patch releases. A 0.x minor release may make breaking changes, with migration guidance in this reference and [CHANGELOG](../CHANGELOG.md). See [the compatibility policy](../CONTRIBUTING.md#compatibility-and-deprecation).
|
|
10
|
-
|
|
11
|
-
`--help` is an offline command-discovery interface. Root help includes workflow, output/exit conventions, authentication, storage and recovery guidance. Command help includes parameter meanings, online/offline behavior, incompatible flags and usage examples. Replace `SNAPSHOT_ID`, `PINNED_REF` and `DATABASE_ID` placeholders before invoking examples. An explicit `--help` takes precedence over validation of other arguments and never executes a command handler. Normal parse failures without `--help` remain one JSON error on stdout.
|
|
12
|
-
|
|
13
|
-
## Identity and references
|
|
14
|
-
|
|
15
|
-
```text
|
|
16
|
-
skill://<encoded-selector>/<encoded-relative-path>?snapshot=s_<64-hex>
|
|
17
|
-
```
|
|
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`. 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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
41
|
-
## Success
|
|
42
|
-
|
|
43
|
-
```json
|
|
44
|
-
{
|
|
45
|
-
"ok": true,
|
|
46
|
-
"skill": {"id": "page-id", "name": "Display Name", "alias": "display-name", "description": "When to use", "database_id": "db-id", "data_source_id": "ds-id", "ref": "skill://page-id/SKILL.md"},
|
|
47
|
-
"snapshot_id": "s_<64-hex>",
|
|
48
|
-
"version_id": "opaque-notion-version",
|
|
49
|
-
"path": "SKILL.md",
|
|
50
|
-
"ref": "skill://page-id/SKILL.md?snapshot=s_<64-hex>",
|
|
51
|
-
"source": "notion",
|
|
52
|
-
"content": "...",
|
|
53
|
-
"range": {"start": 1, "end": 20, "total_lines": 20},
|
|
54
|
-
"has_more": false
|
|
55
|
-
}
|
|
56
|
-
```
|
|
57
|
-
|
|
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.
|
|
59
|
-
|
|
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.
|
|
61
|
-
|
|
62
|
-
Source registrations are stored in `~/.config/ntn-skills/config.json`, with directory precedence `NTN_SKILLS_CONFIG_HOME` > `$XDG_CONFIG_HOME/ntn-skills` > `~/.config/ntn-skills`. `NTN_SKILLS_HOME` controls cached state only. When the new config is absent, reading sources migrates the old state-directory config and retains a `.migrated` backup; existing new configuration wins. Invalid legacy JSON/schema returns `STATE_CORRUPT` without migrating it.
|
|
63
|
-
|
|
64
|
-
Authentication selects non-empty config.token > non-empty NOTION_API_TOKEN > existing ntn login. `config set-token --stdin` requires piped standard input, trims surrounding whitespace and rejects empty or multiple whitespace-separated values. It saves plaintext in the private configuration file offline without remote validation; use doctor to check access. `config clear-token` removes only config.token offline and restores environment/login fallback. `config show` and configuration-change output omit token and add token_configured, which reports configuration presence only, not validity or environment/login availability. Configuration changes preserve the other fields. Tokens reach ntn through the child environment, never command arguments. Help/version and explicit pinned reads/exports do not require credentials.
|
|
65
|
-
|
|
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.
|
|
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
|
-
|
|
81
|
-
## Environment and local storage
|
|
82
|
-
|
|
83
|
-
| Variable | Contract |
|
|
84
|
-
| --- | --- |
|
|
85
|
-
| `NTN_SKILLS_NTN_BIN` | Child-process executable, default `ntn`; select a trusted executable |
|
|
86
|
-
| `NOTION_API_TOKEN` | Non-empty authentication fallback after configuration token |
|
|
87
|
-
| `NTN_SKILLS_CONFIG_HOME` | Full application configuration directory |
|
|
88
|
-
| `XDG_CONFIG_HOME` | Base for the `ntn-skills` configuration directory |
|
|
89
|
-
| `NTN_SKILLS_HOME` | Full application state directory |
|
|
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 |
|
|
93
|
-
| `NOTION_WORKSPACE_ID` | Hashed into authentication scope, default empty, and inherited by `ntn` for workspace selection under its authentication rules |
|
|
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 |
|
|
95
|
-
|
|
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.
|
|
97
|
-
|
|
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.
|
|
101
|
-
|
|
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.
|
|
103
|
-
|
|
104
|
-
## Mutation contract
|
|
105
|
-
|
|
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.
|
|
107
|
-
|
|
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.
|
|
109
|
-
|
|
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.
|
|
111
|
-
|
|
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>.
|
|
113
|
-
|
|
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.
|
|
115
|
-
|
|
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.
|
|
117
|
-
|
|
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.
|
|
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
|
-
|
|
123
|
-
|
|
124
|
-
## Portable export contract
|
|
125
|
-
|
|
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.
|
|
127
|
-
|
|
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).
|
|
129
|
-
|
|
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.
|
|
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
|
-
|
|
153
|
-
## Errors
|
|
154
|
-
|
|
155
|
-
```json
|
|
156
|
-
{"ok":false,"error":{"code":"SKILL_AMBIGUOUS","message":"Multiple skills match; use a page ID or --database.","details":{"selector":"Display Name","candidates":[],"databases":[]}}}
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
| Code | Consumer action |
|
|
160
|
-
| --- | --- |
|
|
161
|
-
| `SKILL_NOT_FOUND` | Read coverage; broaden metadata search or specify a known database/page ID |
|
|
162
|
-
| `SKILL_AMBIGUOUS` | Use candidate database_id and details.databases to select a database alias, or choose a returned page ID |
|
|
163
|
-
| `INVALID_SKILL_NAME` | Correct the Notion Name on the page identified in details; use English letters and single spaces, at most 64 characters |
|
|
164
|
-
| `CATALOG_INCOMPLETE` | Resolve failed sources; do not infer uniqueness from partial results |
|
|
165
|
-
| `AUTH_REQUIRED`, `ACCESS_DENIED` | Check the selected credential: config.token > NOTION_API_TOKEN > existing ntn login. Clear a stale config token to restore fallback; the CLI never starts login |
|
|
166
|
-
| `NTN_UNAVAILABLE`, `NOTION_REQUEST_FAILED`, `RATE_LIMITED` | Check ntn/runtime/API availability; errors do not activate skill content |
|
|
167
|
-
| `SNAPSHOT_MISSING` | Obtain the current snapshot online; arbitrary historical versions cannot be downloaded |
|
|
168
|
-
| `SNAPSHOT_CONFLICT` | Use a ref and snapshot for the same skill/version |
|
|
169
|
-
| `DATABASE_NOT_FOUND`, `DATABASE_AMBIGUOUS` | Use an exact registered alias or database ID/URL; inspect candidates. With no creation selector, configure a default or select one database |
|
|
170
|
-
| `IMPORT_AMBIGUOUS` | Provide SKILL.md, a portable manifest or only one top-level Markdown entrypoint |
|
|
171
|
-
| `CREATE_CONFLICT` | Use import to replace an existing Skill, or select a new name |
|
|
172
|
-
| `OUTPUT_CONFLICT` | Select a new destination; existing export output differs |
|
|
173
|
-
| `WRITE_CONFLICT` | Read the current Skill and rebuild the edit against its new pinned ref |
|
|
174
|
-
| `WRITE_PARTIAL`, `WRITE_OUTCOME_UNKNOWN` | Inspect completed stages and read back the target before retrying |
|
|
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 |
|
|
178
|
-
| `INPUT_FAILED`, `INVALID_INPUT`, `FILE_TOO_LARGE` | Correct the local file/directory or upload size |
|
|
179
|
-
| `FILE_NOT_FOUND` | Inspect the snapshot's file list |
|
|
180
|
-
| `BINARY_FILE` | Use `--output` and an appropriate host viewer |
|
|
181
|
-
| `INVALID_REF`, `INVALID_PATH`, `INVALID_RANGE`, `INVALID_ARGUMENT` | Correct the request |
|
|
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 |
|
|
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 |
|
|
191
|
-
| `INTERNAL_ERROR` | Report a reproducible implementation failure with sanitized context |
|
|
192
|
-
|
|
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.
|
|
194
|
-
|
|
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
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
# Releasing
|
|
2
|
-
|
|
3
|
-
The public package and executable are `ntn-skills`, running on Node.js 22.19.0 or newer. The source repository remains `yoyooyooo/notion-skills-cli`. Only `packages/cli` is published. `packages/core` stays private, and both package versions are kept equal. Development and packing use Bun 1.4.3; CI installs the tarball with npm and exercises it on Node.js 22 and 24 on Linux and macOS.
|
|
4
|
-
|
|
5
|
-
Releases push an annotated tag and publish through GitHub Actions OIDC. The repository can remain private. npm provenance is enabled and verified only for public repositories; private releases retain registry integrity, signatures and consumer checks.
|
|
6
|
-
|
|
7
|
-
## Before a release
|
|
8
|
-
|
|
9
|
-
Use a clean checkout of `main`, with `origin` pointing to `yoyooyooo/notion-skills-cli`. Install Bun 1.4.3, Node 24, npm 11.15.0 or newer, Git, and GitHub CLI. Configure Git author identity and permission to push tags. npm registry reads must work; an unavailable registry stops the release.
|
|
10
|
-
|
|
11
|
-
```sh
|
|
12
|
-
bun install --frozen-lockfile
|
|
13
|
-
bun run release:precheck 0.1.1
|
|
14
|
-
bun run package:check
|
|
15
|
-
```
|
|
16
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
22
|
-
|
|
23
|
-
## First npm publication
|
|
24
|
-
|
|
25
|
-
`0.1.0` was published with maintainer web authentication. Subsequent releases use the Trusted Publisher below. Published versions cannot be replaced.
|
|
26
|
-
|
|
27
|
-
## Configure npm Trusted Publishing
|
|
28
|
-
|
|
29
|
-
Open [the package Access page](https://www.npmjs.com/package/ntn-skills/access) after the first version is visible. Add a GitHub Actions Trusted Publisher with these exact fields:
|
|
30
|
-
|
|
31
|
-
| npm field | Value |
|
|
32
|
-
| --- | --- |
|
|
33
|
-
| Organization or user | `yoyooyooo` |
|
|
34
|
-
| Repository | `notion-skills-cli` |
|
|
35
|
-
| Workflow filename | `publish.yml` |
|
|
36
|
-
| Environment | Leave empty |
|
|
37
|
-
| Allowed action | Allow `npm publish` |
|
|
38
|
-
|
|
39
|
-
The owner is the GitHub owner, which can differ from the npm username. The workflow does not set a GitHub environment. It uses a GitHub-hosted runner with `id-token: write`, Node 24, and npm 11.15.0. It does not use package-manager cache, `registry-url` in setup-node, or `NODE_AUTH_TOKEN`. Do not add npm tokens to Actions secrets.
|
|
40
|
-
|
|
41
|
-
Read the configuration back with `npm trust list ntn-skills`, or inspect the authenticated Access page if terminal 2FA is unavailable. A new configuration must complete its first successful OIDC publish within two days; otherwise delete the expired connection and recreate it. The "not yet validated" status means no publish has used that connection yet.
|
|
42
|
-
|
|
43
|
-
## Automated releases
|
|
44
|
-
|
|
45
|
-
Commit and integrate source changes into `origin/main` before releasing. The checkout must be clean and match that remote branch.
|
|
46
|
-
|
|
47
|
-
Release a patch or an explicit prerelease:
|
|
48
|
-
|
|
49
|
-
```sh
|
|
50
|
-
bun run release patch
|
|
51
|
-
# Or an explicit prerelease:
|
|
52
|
-
bun run release 0.2.0-rc.1
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
The script creates a temporary `release/` branch from the exact fetched `origin/main`, changes only the two package versions and `bun.lock`, runs the local quality check, creates an annotated `v<version>` tag, and pushes only that tag. It never runs `npm publish`. The version commit stays off `main`. On success it returns to the original branch and removes only the temporary branch ref; the tag preserves the commit. On failure it preserves the branch and files for inspection. It never resets, restores, cleans, deletes files, or moves a tag.
|
|
56
|
-
|
|
57
|
-
The workflow proves tag/version equality, valid SemVer, synchronized versions, an annotated tag, one release parent, authorized changed paths, and version-only package JSON changes. A first publication requires the parent to equal current `origin/main`. A repair permits an older parent only while it remains an ancestor of `origin/main`.
|
|
58
|
-
|
|
59
|
-
After quality and fresh consumer checks, the workflow packs and inspects the actual tarball, hashes it, and publishes it through npm OIDC. All tags share one non-cancelling publication queue. Registry readback proves name, version, channel and integrity. Public-repository releases additionally verify provenance against the digest, repository, workflow, tag and commit. Private-repository releases disable provenance because npm does not support it. A fresh registry install and signature check precede GitHub Release creation.
|
|
60
|
-
|
|
61
|
-
Release notes use the previous published version's tag when available and group Conventional Commits. The workflow does not rewrite `CHANGELOG.md`; maintainers update it in normal source changes.
|
|
62
|
-
|
|
63
|
-
## Failure and repair
|
|
64
|
-
|
|
65
|
-
Pushed tags are immutable, including failed tags. If publication failed before npm accepted the version, fix the source or publisher configuration on `main` and choose a higher version. Do not delete or force-push the tag. Registry read errors are not evidence that a version is absent.
|
|
66
|
-
|
|
67
|
-
If npm accepted the version but a later verification or GitHub Release step failed, rerun against the original tag:
|
|
68
|
-
|
|
69
|
-
```sh
|
|
70
|
-
gh workflow run publish.yml --repo yoyooyooo/notion-skills-cli --ref v0.1.1 -f tag=v0.1.1
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
Manual dispatch is repair-only and requires that exact tag as the workflow ref and an already published npm version. A run retry refuses to publish an unpublished failed tag. An existing version skips publication and repeats archive, registry integrity, signatures and consumer checks, plus provenance for public repositories, before repairing its Release. A changed artifact fails verification.
|
|
74
|
-
|
|
75
|
-
For a repair after a newer version has shipped, the selected dist-tag may already point to a higher version. The workflow accepts that forward state, verifies the older exact artifact, and never moves a dist-tag backward. A fresh publication must advance its selected channel.
|
|
76
|
-
|
|
77
|
-
## Deprecation, security patches, and withdrawal
|
|
78
|
-
|
|
79
|
-
The maintainer handles registry changes, release corrections, and security coordination. Report vulnerabilities through [SECURITY.md](../SECURITY.md). Prepare a fix through normal review, release a higher patch version, and describe the affected versions and upgrade path without exposing credentials or private reports.
|
|
80
|
-
|
|
81
|
-
Deprecation changes registry metadata and requires approval. For an affected version, use a precise, actionable message:
|
|
82
|
-
|
|
83
|
-
```sh
|
|
84
|
-
npm deprecate ntn-skills@0.1.1 "Security issue fixed in 0.1.2; upgrade to 0.1.2 or newer." --registry https://registry.npmjs.org
|
|
85
|
-
npm view ntn-skills@0.1.1 deprecated --registry https://registry.npmjs.org
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
Replace the versions and message with the verified incident facts. Prefer a patch and deprecation to withdrawal. If a compromised archive or exposed secret requires removal, follow npm's unpublish policy and obtain explicit incident approval before running `npm unpublish ntn-skills@VERSION --registry https://registry.npmjs.org`. Never unpublish as routine rollback. Rotate exposed credentials independently of package withdrawal. Published version numbers and their Git tags remain permanently reserved.
|
|
89
|
-
|
|
90
|
-
## Local boundary exercises
|
|
91
|
-
|
|
92
|
-
Use a disposable repository and a local bare `origin` to exercise release behavior without external publication. Copy the real release script and config, commit a minimal workspace fixture to `main`, push that fixture to its local origin, and provide a fake `npm` executable that returns controlled `npm view` results. `--no-push` creates only local tags. `--skip-local-check` and `--allow-branch` are accepted only with `--no-push` for such fixtures; production publication always runs the configured local check and exact remote-base gate.
|
|
93
|
-
|
|
94
|
-
Useful cases include clean success, dirty tree rejection, version mismatch, remote-main drift, invalid SemVer, explicit prerelease, forbidden repeat tag, registry error, check-created unauthorized files, and a local failure preserving its branch. The evidence helper supports `version VERSION`, `manifest PACKED_JSON`, and `channel VERSION CHANNEL_VERSION ALREADY_PUBLISHED` for controlled SemVer, packed-manifest, and forward-channel repair cases. These fixtures do not prove npm OIDC or GitHub Release behavior; that evidence comes from a separately authorized real release.
|