ntn-skills 0.0.0-stage → 0.1.2

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 ADDED
@@ -0,0 +1,57 @@
1
+ # Changelog
2
+
3
+ ## 0.1.2 — 2026-10-14
4
+
5
+ - Publish from GitHub Actions with npm OIDC; verify provenance for public repositories and registry evidence for private repositories.
6
+ - Simplify installation and release documentation.
7
+
8
+ ## 0.1.0 — 2026-10-14
9
+
10
+ Initial npm release, published with maintainer web authentication.
11
+
12
+ ### Public repository baseline
13
+
14
+ - Set the public npm package name to `ntn-skills`, matching the executable and bootstrap Skill; retain the `notion-skills-cli` source repository.
15
+ - Add equivalent English and Simplified Chinese READMEs with a centered header, language switch and section navigation; package both language files.
16
+ - Move detailed operations into the [usage guide](docs/usage.md), and document source-access and release status.
17
+ - Separate consumer installation and use from contributor source/build steps in both READMEs; consumers install a built tarball with npm and run on Node.js 22.19.0 or newer.
18
+ - Replace the Bun runtime platform, executable shebang and distribution target with Node.js; keep Bun 1.4.3 for development/build/tests, and exercise npm consumers on Node.js 22 and 24 in CI.
19
+ - Add an English installation and first-read walkthrough, tarball consumption, upgrade and uninstall instructions, and explicit runtime/platform evidence boundaries in [README](README.md).
20
+ - Document metadata freshness separately from retained snapshots and upload staging, inherited workspace/API endpoint settings, network behavior and optional local data cleanup across the [protocol](docs/protocol.md), [host integration](docs/host-integration.md) and [Skill reference](skills/ntn-skills/references/integration.md).
21
+ - Use the returned snapshot ID to list every attachment; a pinned file ref filters only its own path.
22
+ - Set the public issue and private vulnerability-reporting channels, security support for the latest patch of the current 0.x series, and a seven-day acknowledgement target without a promised fix deadline in [SECURITY](SECURITY.md).
23
+ - Define 0.x compatibility, deprecation migration guidance and fast-forward integration in [CONTRIBUTING](CONTRIBUTING.md), and prepare the package/release metadata and CI release lane.
24
+ - Update production archive dependency `fflate` to 0.8.3.
25
+
26
+ ### Initial 0.1.0 functionality
27
+
28
+ - Add Bun development monorepo with a Node.js CLI using Effect 4.0.4, platform services, schemas, and scoped ntn transport.
29
+ - Discover accessible typed Skills Databases with explicit search coverage and registered-source supplementation.
30
+ - Resolve exact skill names, metadata-derived aliases, page IDs, and page URLs; return structured missing/ambiguous/incomplete errors.
31
+ - Read immutable export snapshots one file at a time, including line ranges, UTF-8 BOM text, and explicit binary output.
32
+ - Support skill:// refs, pinned snapshots, and relative reference resolution.
33
+ - Ship ntn-skills bootstrap Skill, host integration contract, contributor/security policies, and reproducible CI checks.
34
+ - Keep parser failures machine-readable, with optional Boolean switches and no interactive wizard.
35
+ - Bound rate-limit retries and validate Notion error responses with Schema.
36
+ - Package docs and bundled dependency licenses, and check formatting with pinned Biome.
37
+ - Store global source configuration under ~/.config/ntn-skills with XDG_CONFIG_HOME and NTN_SKILLS_CONFIG_HOME overrides; migrate legacy registrations once and retain a backup without moving snapshots.
38
+ - Require English-letter Notion titles with single spaces and derive the invocation name by lowercasing and replacing spaces with hyphens; validate matching export frontmatter and preserve historical snapshot reads.
39
+ - Make root and command help self-contained for agents with argument/flag descriptions, online/offline modes, usage examples, output conventions, storage and error-recovery guidance.
40
+ - Add create/write with dry runs, shared targets, pinned-version conflict detection, verified snapshots and explicit partial/unknown outcomes; preserve nested paths and extra metadata in the source ZIP.
41
+ - Add config.default_database and config show/set-default/clear-default; create selects an explicit database, the configured default, or the sole discovered Skills Database. Preserve the default when adding sources and reject ambiguous/incomplete discovery.
42
+ - Add import for a local ZIP, folder or any .md/.markdown filename, with one-Skill entrypoint selection, name/description overrides, bounded ZIP decoding, preserved attachment bytes, dry runs and verified new snapshots.
43
+ - Preserve initial H1 headings on create/import by writing Markdown after page creation and compare normalized write responses with page readback and exported content.
44
+ - Add complete ZIP/directory export with offline pinned refs, a versioned portable manifest, deterministic archive bytes, content digests and reuse/conflict handling for existing output.
45
+ - Preserve imported source bytes, arbitrary Markdown filenames, extra frontmatter and nested supporting files in a retained source ZIP; reconstruct current edits without changing historical snapshots.
46
+ - Make create pure creation with CREATE_CONFLICT on an existing invocation name; import creates absent names, reuses identical content or replaces different content on the same page with version checks.
47
+ - Compare page and Skills Markdown across equivalent plain-text code labels and paragraph spacing without discarding blank lines inside fenced code.
48
+ - Rename the discovery command from catalog to list; make ntn-skills list the agent-facing entrypoint in help, the bootstrap Skill and host integration, with automatic pagination and metadata-only output.
49
+ - Unify read/files/open/write/export targets across names, invocation aliases, page IDs/URLs, refs and snapshot IDs; use --path instead of second positional paths and remove read --snapshot/refresh modes.
50
+ - Replace ls with files and databases with database list; database discovery no longer queries Skill rows. List queries match invocation aliases and return compact metadata/count/coverage.
51
+ - Reuse identical local read/export output with reused=true; reject differing output with OUTPUT_CONFLICT. Identical writes return unchanged=true without remote mutation.
52
+ - Add optional global config.token with priority over NOTION_API_TOKEN and existing ntn login; set via config set-token --stdin, clear offline, preserve other settings and expose only token_configured in configuration output.
53
+ - Scope online caches by the selected credential digest; existing pinned snapshots remain readable offline, while pinned writes from an older scope format require a fresh online read.
54
+ - Accept Database IDs, URLs and exact registered aliases consistently across --database flags and config set-default; persist defaults as canonical IDs and enforce alias constraints on offline pinned targets.
55
+ - Return the queried databases map in list, retain cross-database same-name Skills, and include database maps in ambiguity errors plus owning database labels in failed-source coverage.
56
+ - Reject repeated --database values before execution, including identical values and --database=value; explicit help remains offline and takes precedence.
57
+ - Accept notion.so URLs alongside notion.com/notion.site when resolving database and page identities.
@@ -0,0 +1,48 @@
1
+ # Contributing
2
+
3
+ ## Development setup
4
+
5
+ Use Bun 1.4.3 for development and the committed lockfile. The published CLI runs on Node.js 22.19.0 or newer; install Node.js and npm as well for the fresh-consumer checks. Clone the repository, then work from the checkout root:
6
+
7
+ ```bash
8
+ git clone https://github.com/yoyooyooo/notion-skills-cli.git
9
+ cd notion-skills-cli
10
+ bun install --frozen-lockfile
11
+ bun run dev --help
12
+ bun run check && bun run package:check
13
+ ```
14
+
15
+ Build and pack a consumer artifact from the checkout root:
16
+
17
+ ```bash
18
+ bun run build
19
+ node packages/cli/dist/ntn-skills.js --help
20
+ mkdir -p release
21
+ bun pm pack --cwd packages/cli --destination ../../release
22
+ ```
23
+
24
+ The archive filename follows the package version. Consumers install that tarball with npm as described in [the README](README.md#installation). Update source with `git pull --ff-only`, reinstall dependencies and rebuild before producing a new tarball.
25
+
26
+ `check` runs type checking, formatting checks, tests and the Node.js distribution build. `package:check` validates documentation links, packs the CLI and installs it with npm in a fresh consuming project, then executes the installed binary with Node.js. CI covers Node.js 22 and 24 on Linux and macOS. Run both checks before proposing a pull request or release. Tests must not depend on personal credentials or mutate a live Notion workspace. Keep live verification separate and disclose the environment and authorization used.
27
+
28
+ Keep Effect and platform versions aligned at 4.0.4. New commands use `effect/cli`; external execution uses scoped Effect platform capabilities. Pure path and identity transformations remain ordinary TypeScript. Preserve the [JSON and ref contract](docs/protocol.md), explicit discovery coverage and immutable snapshot semantics.
29
+
30
+ Preserve the Skill naming contract: Notion Name uses ASCII English letters and single spaces (1-64 characters); its lowercase form with spaces replaced by hyphens is the invocation name and must equal the export frontmatter name. Do not introduce independent alias configuration or silently normalize invalid titles. Descriptions and file contents may use any language.
31
+
32
+ Add behavior tests for plausible consumer-visible failures: ambiguity, pagination, partial discovery, file boundaries, version consistency and permission failure. Avoid asserting implementation text or internal call wiring. A pull request should explain the user-visible problem, resulting behavior and checks actually run. Keep unrelated changes separate.
33
+
34
+ ## Compatibility and deprecation
35
+
36
+ The 0.x series is experimental. A minor release may change public commands or protocol behavior incompatibly; a patch release preserves existing semantics and provides compatible fixes. Consumers should tolerate additional JSON fields and handle unfamiliar error codes as structured failures. Additional fields or codes must not silently change the meaning of existing fields or successful operations.
37
+
38
+ Document a deprecation and its replacement in the relevant reference and [CHANGELOG](CHANGELOG.md), including migration steps and the version that removes it. Breaking changes must be called out before consumers upgrade. Update both READMEs ([English](README.md) and [简体中文](README.zh-CN.md)), the [usage guide](docs/usage.md), [protocol documentation](docs/protocol.md), [host integration](docs/host-integration.md) and affected Skill references when public behavior changes. Keep language navigation, commands, release status, capabilities and limits equivalent; detailed guides are maintained in English. Verify README rendering, anchors and packaged language files when the entry structure changes.
39
+
40
+ ## Git and release workflow
41
+
42
+ Update your checkout with `git pull --ff-only`. Integration is fast-forward only; rebase contributions onto the current target branch rather than creating merge commits. Keep reviewable commits focused on the change.
43
+
44
+ The private core is bundled into the CLI distribution. Before release, verify the tarball from outside the workspace and follow [the release procedure](docs/releasing.md). Releases use immutable annotated `v<version>` tags; publishing a registry package or creating a hosted repository requires explicit release authorization. A prepared version or local tarball does not establish that a package is published.
45
+
46
+ ## Reporting bugs and vulnerabilities
47
+
48
+ Use [GitHub issues](https://github.com/yoyooyooo/notion-skills-cli/issues) for bugs and usage questions. Include the command, sanitized response, runtime and `ntn` versions, expected behavior and a minimal reproduction. Never include credentials, signed URLs, private Skill contents or personal database identifiers in public reports. Report vulnerabilities through [the private channel in SECURITY.md](SECURITY.md#reporting-a-vulnerability).
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 notion-skills-cli contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,161 @@
1
- # Temporary Holding Version
1
+ <h1 align="center">ntn-skills</h1>
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ <p align="center">Bring your Notion workflow library into an Agent or terminal.<br>Discover the right Skill, read its instructions, and keep one version for the whole task.</p>
4
+
5
+ <p align="center">
6
+ <a href="./README.md">English</a> · <a href="./README.zh-CN.md">简体中文</a>
7
+ </p>
8
+
9
+ <p align="center">
10
+ <a href="#installation">Install</a> · <a href="#quick-start">Quick start</a> · <a href="#common-workflows">Workflows</a> · <a href="#agent-integration">Agent integration</a> · <a href="./docs/README.md">Docs</a>
11
+ </p>
12
+
13
+ <p align="center">
14
+ <a href="./CHANGELOG.md"><img src="https://img.shields.io/badge/status-experimental-orange" alt="Status: experimental"></a>
15
+ <a href="https://nodejs.org"><img src="https://img.shields.io/badge/runtime-Node.js%20%3E%3D%2022.19.0-green" alt="Runtime: Node.js >= 22.19.0"></a>
16
+ <a href="./LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="License: MIT"></a>
17
+ </p>
18
+
19
+ ```bash
20
+ ntn-skills list
21
+ ntn-skills read 'Release Review'
22
+ ```
23
+
24
+ `Release Review` is an example title; choose a Skill returned by your own `list`. The npm package, executable and bootstrap Skill are all **`ntn-skills`**.
25
+
26
+ Available on [npm](https://www.npmjs.com/package/ntn-skills). For source builds, see [Contributing](CONTRIBUTING.md#development-setup).
27
+
28
+ ## Why use it?
29
+
30
+ You maintain reusable instructions in Notion, but an Agent only needs a few of them for its current task. `ntn-skills list` exposes names and descriptions so the Agent can choose a relevant workflow before loading its instructions. `read` loads the selected file and saves the complete Skill export locally.
31
+
32
+ A task can outlive an edit in Notion. Reading instructions before that edit and an attachment afterward can mix two versions. The first successful read returns a **snapshot**: a local, fixed version of the workflow and its files. Keep the returned refs for the task; a later online read can adopt a newer version for the next task.
33
+
34
+ | When you want to… | Use |
35
+ | --- | --- |
36
+ | Find a workflow without loading the whole library | `list` |
37
+ | Read instructions and supporting files from one version | `read`, then `files` |
38
+ | Move a complete Skill between local files and Notion | `import`, `export` |
39
+ | Add a new Skill or replace one file deliberately | `create`, `write` |
40
+
41
+ ## Installation
42
+
43
+ Install [Node.js](https://nodejs.org) **22.19.0 or newer**, which includes npm. Online operations also need the [official Notion CLI](https://developers.notion.com/cli) **`ntn`** with `api --notion-version` support; `ntn` 0.22.12 has been exercised with this project.
44
+
45
+ Install the published release from the official npm registry:
46
+
47
+ ```bash
48
+ npm install --global ntn-skills --registry https://registry.npmjs.org
49
+ ntn-skills --version
50
+ ntn-skills --help
51
+ ```
52
+
53
+ The version command prints the installed version; help lists the available commands. A consumer needs Node.js and npm. [Project-local installation](docs/usage.md#install-in-a-consuming-project), [PATH setup](docs/usage.md#install-from-npm-globally) and [local tarball installation](docs/usage.md#install-a-local-tarball-globally) are covered in the usage guide.
54
+
55
+ To produce a package yourself, follow [the contributor setup and build instructions](CONTRIBUTING.md#development-setup). Bun is the development/build tool.
56
+
57
+ ## Quick start
58
+
59
+ ### 1. Connect Notion
60
+
61
+ Configure `ntn` through [its authentication guide](https://developers.notion.com/cli/get-started/authentication). Your connection needs Read content access, the Skills API enabled, and an accessible database with `database_type: "skills"`. A normal database named “Skills” is insufficient.
62
+
63
+ That database needs at least one valid Skill. For example, the Notion Name `Release Review` maps to `name: release-review` in its exported `SKILL.md`. Names use English letters separated by single spaces, up to 64 characters; descriptions and instructions can use any language. [Naming and database requirements](docs/protocol.md#identity-and-references).
64
+
65
+ Authentication priority is saved `config.token` → non-empty `NOTION_API_TOKEN` → existing `ntn login`. A saved token is plaintext in the private config file; `config show` reports only whether it is configured. [Token setup and removal](docs/usage.md#authentication).
66
+
67
+ ### 2. Check access and choose a workflow
68
+
69
+ ```bash
70
+ ntn-skills doctor
71
+ ntn-skills list
72
+ ```
73
+
74
+ With a valid Skill available, `doctor` should report `ok: true`, `authentication: "available"`, a positive `skill_count`, and `skills_api.available: true`. Resolve reported errors before continuing. `list` returns `skills`, `databases`, `count`, and `coverage` without loading workflow bodies.
75
+
76
+ Notion Search may miss databases. Read `coverage`; if you know the database, use `ntn-skills list --database 'DATABASE_ID_OR_URL'`, replacing that value with your database ID or URL.
77
+
78
+ ### 3. Read the selected Skill
79
+
80
+ Copy an entry's `ref` from `skills` into this command, replacing the placeholder:
81
+
82
+ ```bash
83
+ ntn-skills read 'REF_FROM_LIST'
84
+ ```
85
+
86
+ A successful response contains `ok: true`, the instructions in `content`, `source: "notion"`, a `snapshot_id` starting with `s_`, and a pinned `ref` containing `?snapshot=...`. Keep that ref and snapshot ID with your task. [Response fields](docs/protocol.md#success).
87
+
88
+ ### 4. Read supporting files from the same version
89
+
90
+ Replace each placeholder with the value returned by the preceding command:
91
+
92
+ ```bash
93
+ ntn-skills files 'SNAPSHOT_ID_FROM_READ'
94
+ ntn-skills read 'ATTACHMENT_REF_FROM_FILES'
95
+ ```
96
+
97
+ Use the snapshot ID to list **all** files; passing a file ref lists only that file. Read an attachment actually returned by `files`. Its pinned ref uses the same snapshot and returns `source: "local_snapshot"`, even without authentication or network access. Historical versions are available only if already saved on this machine.
98
+
99
+ For a binary attachment, add `--output ./attachment.bin` and use an appropriate viewer. For text, use `--lines 10-30` for an inclusive line range or `--raw` for plain UTF-8 output. Scripts are never executed automatically.
100
+
101
+ ## Common workflows
102
+
103
+ ### Keep workflow libraries separate
104
+
105
+ Register a known database as a domain, then select it explicitly. Replace the database placeholder before running:
106
+
107
+ ```bash
108
+ ntn-skills source add ops --database 'DATABASE_ID_OR_URL'
109
+ ntn-skills list --database ops
110
+ ntn-skills read 'Release Review' --database ops
111
+ ```
112
+
113
+ Database aliases are exact and case-sensitive. If two databases have the same Skill name, select a database or use a page-ID ref from `list`. Registered sources supplement automatic discovery. [Discovery, aliases and coverage](docs/usage.md#discovery-and-identity).
114
+
115
+ ### Import, export or update a Skill
116
+
117
+ A Skill can be a folder, ZIP, or Markdown file. Preview remote changes before applying them:
118
+
119
+ ```bash
120
+ ntn-skills import ./my-skill --database ops --dry-run
121
+ ntn-skills import ./my-skill --database ops
122
+ ntn-skills export 'My Skill' --database ops --output ./my-skill.zip
123
+ ntn-skills write 'PINNED_REF_FROM_READ' --input ./SKILL.md --dry-run
124
+ ```
125
+
126
+ `create` requires a new name. `import` creates an absent name, reuses identical content, or replaces the existing same-name Skill's body, metadata and complete file set. `write` replaces one file while retaining the others; run it without `--dry-run` to apply the reviewed change. Pinned writes check the current online version and fail if it changed. [Inputs, conflicts and partial outcomes](docs/usage.md#creating-importing-exporting-and-updating-skills).
127
+
128
+ ## Agent integration
129
+
130
+ Copy the [bootstrap Skill](skills/ntn-skills/SKILL.md) directory into your Agent host's supported local skill directory. It teaches the Agent to discover metadata, read a selected workflow, and follow pinned attachment refs through shell commands.
131
+
132
+ For startup awareness of every available workflow, the host needs a startup hook that runs `ntn-skills list` and injects the returned metadata. A bootstrap Skill by itself does not expose the remote catalog at startup. Direct use of `Read skill://...` requires a host adapter; shell integration works wherever shell tools are available. [Host integration contract](docs/host-integration.md).
133
+
134
+ ## Boundaries and local data
135
+
136
+ - Local verification covers npm installation, offline behavior and real Notion reads on macOS arm64 with Node.js 24.20.0 and `ntn` 0.22.12. CI is configured for Node.js 22.19.0 and 24 on Linux and macOS; configured jobs do not establish successful runs. The minimum version has not been exercised locally because runtime downloads failed. Windows is unverified.
137
+ - Explicit `create`, `import`, and `write` commands change Notion. Version checks are client preflight checks; body, properties, and files are separate requests. On `WRITE_PARTIAL` or `WRITE_OUTCOME_UNKNOWN`, inspect the target before retrying.
138
+ - Configuration defaults to `~/.config/ntn-skills/config.json`; snapshots and upload staging default to `~/.local/state/ntn-skills`. The 60-second metadata cache lifetime controls freshness. Local data has no automatic garbage collection.
139
+ - Online operations use `ntn` and Notion's signed download URLs. The CLI sends no telemetry requests of its own; `ntn` has its own policies. Imported scripts are never executed automatically.
140
+
141
+ See [configuration and storage](docs/protocol.md#environment-and-local-storage), [error recovery](docs/protocol.md#errors), and [security and privacy](SECURITY.md).
142
+
143
+ ## Upgrade and uninstall
144
+
145
+ For a tarball installation, obtain the newer built package and repeat the npm installation command. Read [the changelog](CHANGELOG.md) before a 0.x minor upgrade. Source builds follow [the contributor instructions](CONTRIBUTING.md#development-setup).
146
+
147
+ Remove a global installation with `npm uninstall --global ntn-skills`. Configuration and snapshots remain afterward. To remove a saved token, run `ntn-skills config clear-token` before uninstalling. [Project-local removal and optional data cleanup](docs/usage.md#upgrade-and-uninstall) explain what to retain and what pinned refs lose when state is discarded.
148
+
149
+ ## Documentation and contributing
150
+
151
+ | Next step | Guide |
152
+ | --- | --- |
153
+ | Installation variants and everyday CLI usage | [Usage guide](docs/usage.md) |
154
+ | Selectors, JSON output, storage and errors | [CLI and ref contract](docs/protocol.md) |
155
+ | Startup metadata and Read/Write adapters | [Host integration](docs/host-integration.md) |
156
+ | Development setup and compatibility policy | [Contributing](CONTRIBUTING.md) |
157
+ | Publishing and release verification | [Releasing](docs/releasing.md) |
158
+
159
+ Use [GitHub issues](https://github.com/yoyooyooo/notion-skills-cli/issues) for sanitized bug reports and usage questions; vulnerabilities use [private reporting](SECURITY.md#reporting-a-vulnerability). To develop or build the CLI, start with [Contributing](CONTRIBUTING.md).
160
+
161
+ [Documentation index](docs/README.md) · [Changelog](CHANGELOG.md) · [MIT license](LICENSE)
@@ -0,0 +1,161 @@
1
+ <h1 align="center">ntn-skills</h1>
2
+
3
+ <p align="center">让 Agent 和终端用上你在 Notion 中维护的工作流。<br>先找到合适的 Skill,再读取指令,整项任务始终使用同一版本。</p>
4
+
5
+ <p align="center">
6
+ <a href="./README.md">English</a> · <a href="./README.zh-CN.md">简体中文</a>
7
+ </p>
8
+
9
+ <p align="center">
10
+ <a href="#安装">安装</a> · <a href="#快速开始">快速开始</a> · <a href="#常用场景">常用场景</a> · <a href="#接入-agent">接入 Agent</a> · <a href="./docs/README.md">文档</a>
11
+ </p>
12
+
13
+ <p align="center">
14
+ <a href="./CHANGELOG.md"><img src="https://img.shields.io/badge/status-experimental-orange" alt="状态:实验性"></a>
15
+ <a href="https://nodejs.org"><img src="https://img.shields.io/badge/runtime-Node.js%20%3E%3D%2022.19.0-green" alt="运行时:Node.js >= 22.19.0"></a>
16
+ <a href="./LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="许可证:MIT"></a>
17
+ </p>
18
+
19
+ ```bash
20
+ ntn-skills list
21
+ ntn-skills read 'Release Review'
22
+ ```
23
+
24
+ `Release Review` 是示例名称,请选择你自己的 `list` 返回的 Skill。npm 安装包、命令和引导 Skill 都叫 **`ntn-skills`**。
25
+
26
+ 已发布到 [npm](https://www.npmjs.com/package/ntn-skills)。从源码构建见[贡献指南](CONTRIBUTING.md#development-setup)。
27
+
28
+ ## 它解决什么问题?
29
+
30
+ 你在 Notion 中维护了一组可复用的操作指令,但 Agent 在当前任务里只需要其中几项。`ntn-skills list` 先提供名称和描述,让 Agent 选出适用的工作流,再用 `read` 读取需要的文件,同时把该 Skill 的完整导出保存到本地。
31
+
32
+ 任务执行期间,Notion 内容可能被修改。如果先读取指令、修改后再读取附件,两次读取就可能混用不同版本。第一次成功读取会返回一个**快照**,把工作流和附件固定为一个本地版本。任务中持续使用返回的引用;下次任务可以重新在线读取,采用更新后的版本。
33
+
34
+ | 你想做什么 | 使用的命令 |
35
+ | --- | --- |
36
+ | 找到工作流,避免一次加载整座库的正文 | `list` |
37
+ | 从同一版本读取指令和附件 | `read`,再用 `files` |
38
+ | 在本地文件和 Notion 之间迁移完整 Skill | `import`、`export` |
39
+ | 明确新增一个 Skill 或替换一个文件 | `create`、`write` |
40
+
41
+ ## 安装
42
+
43
+ 安装 [Node.js](https://nodejs.org) **22.19.0 或更新版本**,其中包含 npm。在线操作还需要支持 `api --notion-version` 的[官方 Notion CLI](https://developers.notion.com/cli) **`ntn`**;本项目已使用 `ntn` 0.22.12 验证。
44
+
45
+ 从官方 npm registry 安装已发布版本:
46
+
47
+ ```bash
48
+ npm install --global ntn-skills --registry https://registry.npmjs.org
49
+ ntn-skills --version
50
+ ntn-skills --help
51
+ ```
52
+
53
+ 版本命令输出已安装版本;帮助列出可用命令。使用者需要 Node.js 和 npm。[项目内安装](docs/usage.md#install-in-a-consuming-project)、[PATH 配置](docs/usage.md#install-from-npm-globally)与[本地 tarball 安装](docs/usage.md#install-a-local-tarball-globally)见使用指南。
54
+
55
+ 需要自行生成安装包时,按[贡献指南中的开发与构建步骤](CONTRIBUTING.md#development-setup) 操作。Bun 用于开发和构建。
56
+
57
+ ## 快速开始
58
+
59
+ ### 1. 连接 Notion
60
+
61
+ 按[官方认证指南](https://developers.notion.com/cli/get-started/authentication) 配置 `ntn`。连接需要 Read content 权限、已启用 Skills API,并能访问 `database_type: "skills"` 的数据库。普通数据库仅仅命名为 Skills,并不满足条件。
62
+
63
+ 数据库中至少需要一个有效 Skill。比如,Notion 中的 Name 为 `Release Review`,其导出的 `SKILL.md` 必须包含 `name: release-review`。名称只能用英文字母,单词之间用一个空格,最多 64 个字符;描述和正文可以使用任何语言。[命名与数据库要求](docs/protocol.md#identity-and-references)。
64
+
65
+ 认证优先级为:已保存的 `config.token` → 非空 `NOTION_API_TOKEN` → 已有 `ntn login` 登录态。保存的 token 以明文存入私有配置文件;`config show` 只显示是否已配置。[设置与移除 token](docs/usage.md#authentication)。
66
+
67
+ ### 2. 检查访问权限,选择工作流
68
+
69
+ ```bash
70
+ ntn-skills doctor
71
+ ntn-skills list
72
+ ```
73
+
74
+ 有效 Skill 可访问时,`doctor` 应返回 `ok: true`、`authentication: "available"`、大于零的 `skill_count`,以及 `skills_api.available: true`。先解决返回的错误,再继续。`list` 返回 `skills`、`databases`、`count` 和 `coverage`,不会加载工作流正文。
75
+
76
+ Notion Search 可能漏掉数据库。请查看 `coverage`;如果已知数据库,可使用 `ntn-skills list --database 'DATABASE_ID_OR_URL'`,将其中的值替换成实际数据库 ID 或 URL。
77
+
78
+ ### 3. 读取选中的 Skill
79
+
80
+ 从 `skills` 中复制一个条目的 `ref`,替换下面的占位值:
81
+
82
+ ```bash
83
+ ntn-skills read 'REF_FROM_LIST'
84
+ ```
85
+
86
+ 成功响应包含 `ok: true`、`content` 中的指令、`source: "notion"`、以 `s_` 开头的 `snapshot_id`,以及包含 `?snapshot=...` 的固定版本 `ref`。将这个引用和快照 ID 保留在任务上下文中。[响应字段说明](docs/protocol.md#success)。
87
+
88
+ ### 4. 从同一版本读取附件
89
+
90
+ 每一步都用前一个命令返回的实际值替换占位值:
91
+
92
+ ```bash
93
+ ntn-skills files 'SNAPSHOT_ID_FROM_READ'
94
+ ntn-skills read 'ATTACHMENT_REF_FROM_FILES'
95
+ ```
96
+
97
+ 用快照 ID 列出**全部**文件;传入某个文件的引用,只会列出那个文件。请选择 `files` 实际返回的附件。它的固定版本引用使用同一个快照,即使没有认证或网络,读取也会返回 `source: "local_snapshot"`。历史版本只能读取本机已经保存过的快照。
98
+
99
+ 二进制附件加上 `--output ./attachment.bin`,再用合适的查看器打开。文本可用 `--lines 10-30` 读取包含首尾的行区间,或用 `--raw` 输出 UTF-8 原文。脚本不会被自动执行。
100
+
101
+ ## 常用场景
102
+
103
+ ### 按领域选择工作流库
104
+
105
+ 为已知数据库注册领域别名,然后明确选择它。执行前替换数据库占位值:
106
+
107
+ ```bash
108
+ ntn-skills source add ops --database 'DATABASE_ID_OR_URL'
109
+ ntn-skills list --database ops
110
+ ntn-skills read 'Release Review' --database ops
111
+ ```
112
+
113
+ 数据库别名精确匹配,区分大小写。两个数据库存在同名 Skill 时,选择数据库,或使用 `list` 返回的包含页面 ID 的引用。已注册的来源会补充自动发现的范围。[发现、别名与覆盖范围](docs/usage.md#discovery-and-identity)。
114
+
115
+ ### 导入、导出或更新 Skill
116
+
117
+ Skill 可以来自文件夹、ZIP 或 Markdown 文件。先预览远端变更,再执行:
118
+
119
+ ```bash
120
+ ntn-skills import ./my-skill --database ops --dry-run
121
+ ntn-skills import ./my-skill --database ops
122
+ ntn-skills export 'My Skill' --database ops --output ./my-skill.zip
123
+ ntn-skills write 'PINNED_REF_FROM_READ' --input ./SKILL.md --dry-run
124
+ ```
125
+
126
+ `create` 要求名称尚不存在。`import` 会创建缺失的名称、复用相同内容,或替换已有同名 Skill 的正文、元数据和完整文件集。`write` 只替换一个文件,保留其他文件;确认预览后,去掉 `--dry-run` 执行。固定版本写入会在线核对当前版本,版本已变化就失败。[输入格式、冲突与部分成功的处理](docs/usage.md#creating-importing-exporting-and-updating-skills)。
127
+
128
+ ## 接入 Agent
129
+
130
+ 把[引导 Skill](skills/ntn-skills/SKILL.md) 所在目录复制到 Agent 宿主支持的本地 Skill 目录。它让 Agent 通过终端命令发现元数据、读取选中的工作流,并沿固定版本引用读取附件。
131
+
132
+ 如果希望宿主启动时就知道所有可用工作流,需要启动钩子执行 `ntn-skills list` 并注入返回的元数据。仅安装引导 Skill,并不会在启动时自动暴露远端目录。直接使用 `Read skill://...` 需要宿主适配器;宿主提供终端工具时,即可通过 CLI 接入。[宿主接入契约](docs/host-integration.md)。
133
+
134
+ ## 使用边界与本地数据
135
+
136
+ - 本地已用 macOS arm64、Node.js 24.20.0 和 `ntn` 0.22.12 验证 npm 安装、离线操作及真实 Notion 读取。CI 已配置 Linux 与 macOS 上的 Node.js 22.19.0 和 24;工作流配置不代表运行已成功。最低版本运行时下载失败,尚未在本地验证。Windows 未验证。
137
+ - 明确执行 `create`、`import` 或 `write` 会修改 Notion。版本检查属于客户端预检查;正文、属性和文件由不同请求更新。遇到 `WRITE_PARTIAL` 或 `WRITE_OUTCOME_UNKNOWN`,先检查目标,再决定是否重试。
138
+ - 配置默认位于 `~/.config/ntn-skills/config.json`;快照和上传暂存默认位于 `~/.local/state/ntn-skills`。元数据缓存的 60 秒有效期只控制新鲜度,本地数据没有自动回收机制。
139
+ - 在线操作通过 `ntn` 和 Notion 的签名下载 URL 完成。CLI 自身不发送遥测请求;`ntn` 有自己的政策。导入的脚本不会被自动执行。
140
+
141
+ 详见[配置与存储](docs/protocol.md#environment-and-local-storage)、[错误恢复](docs/protocol.md#errors) 和[安全与隐私](SECURITY.md)。
142
+
143
+ ## 升级与卸载
144
+
145
+ tarball 安装可获取新版已构建安装包,再执行 npm 安装命令。跨 0.x 次版本升级前,请阅读[变更记录](CHANGELOG.md)。源码构建按[贡献指南](CONTRIBUTING.md#development-setup) 操作。
146
+
147
+ 全局安装用 `npm uninstall --global ntn-skills` 卸载。配置和快照会保留。需要移除已保存的 token 时,在卸载前执行 `ntn-skills config clear-token`。[项目内卸载与可选数据清理](docs/usage.md#upgrade-and-uninstall) 说明保留哪些数据,以及丢弃状态目录会让哪些固定版本引用失效。
148
+
149
+ ## 文档与贡献
150
+
151
+ | 下一步 | 文档 |
152
+ | --- | --- |
153
+ | 安装变体与日常 CLI 操作 | [使用指南](docs/usage.md) |
154
+ | 选择器、JSON 输出、存储与错误 | [CLI 与引用契约](docs/protocol.md) |
155
+ | 启动时的元数据注入与 Read/Write 适配器 | [宿主接入](docs/host-integration.md) |
156
+ | 开发环境与兼容政策 | [贡献指南](CONTRIBUTING.md) |
157
+ | 发版与发布结果验证 | [发布流程](docs/releasing.md) |
158
+
159
+ 问题报告和使用咨询请在 [GitHub issues](https://github.com/yoyooyooo/notion-skills-cli/issues) 提交脱敏信息;漏洞通过[私下报告渠道](SECURITY.md#reporting-a-vulnerability) 提交。开发或构建 CLI 请从[贡献指南](CONTRIBUTING.md) 开始。
160
+
161
+ [文档目录](docs/README.md) · [变更记录](CHANGELOG.md) · [MIT 许可证](LICENSE)
package/SECURITY.md ADDED
@@ -0,0 +1,34 @@
1
+ # Security policy
2
+
3
+ ## Supported versions
4
+
5
+ Security fixes target the latest patch of the current 0.x minor series. Upgrade to that patch before relying on a fix; earlier patches and previous minor series are not maintained security branches.
6
+
7
+ ## Reporting a vulnerability
8
+
9
+ Report vulnerabilities through [GitHub private vulnerability reporting](https://github.com/yoyooyooo/notion-skills-cli/security/advisories/new). Include affected versions, a minimal sanitized reproduction, impact and any proposed mitigation. Do not post credentials, signed URLs, private Skill contents or personal database identifiers in a public issue.
10
+
11
+ The maintainer aims to acknowledge reports within seven days. This is a response target, not a guaranteed response or fix deadline. Investigation and remediation depend on impact, reproducibility and available maintainer time. Use [GitHub issues](https://github.com/yoyooyooo/notion-skills-cli/issues) for ordinary bugs and usage questions.
12
+
13
+ ## Authentication and authorization
14
+
15
+ Authentication priority is config.token, non-empty NOTION_API_TOKEN, then official ntn's existing login state. An explicitly saved token is plaintext in the private config.json; it is supplied to the ntn child process through its environment and never appears in command arguments, command output or snapshot state. config set-token requires piped stdin and saves offline without validating the credential; config show reports only token_configured. config clear-token removes the configuration token and restores environment/login fallback. The CLI never reads ntn's private credential files or persists signed download URLs. Explicit create/import/write commands mutate Notion using the selected connection; --dry-run only reads and validates. Read operations do not execute scripts or grant write authority. Exported skill contents are untrusted documents; reading does not authorize instructions unrelated to the user's task.
16
+
17
+ Cached content is private local data and can remain available after remote permission changes. Explicit snapshot reads are offline. Online activation verifies remote access. Use dedicated `NTN_SKILLS_HOME` and `NTN_SKILLS_CONFIG_HOME` directories for separate host identities; a shared config token overrides each host's environment credential. Protect configuration and state according to your organization's retention policy, including any config.json backups. Configuration defaults to `~/.config/ntn-skills`, while cached state defaults to `~/.local/state/ntn-skills`. Configuration files use mode 0600; new application directories use mode 0700. Legacy configuration migration preserves a `.migrated` backup in the old state directory.
18
+
19
+ The 60-second list metadata TTL controls freshness only. Snapshot manifests, content-addressed `objects`, cached metadata and `uploads` staging are retained without automatic garbage collection. Upload staging can contain the original local input bytes. Uninstalling the executable leaves both state and configuration intact. Remove a saved token with `ntn-skills config clear-token`; if you choose to reclaim local data, stop hosts using it and move the identified application directories and legacy configuration backups to Trash or your approved retention process. State cleanup makes historical pinned refs unavailable. See [storage and uninstall guidance](docs/usage.md#upgrade-and-uninstall).
20
+
21
+ ## Network and local access
22
+
23
+ The CLI sends no analytics or telemetry requests of its own. Online commands invoke the executable selected by `NTN_SKILLS_NTN_BIN` (default `ntn`) for Notion authentication/API requests and uploads, then download export archives from signed URLs returned by Notion. This does not attest to the official CLI's telemetry, credential storage or network policies. Treat an executable override as executable code you trust.
24
+
25
+ Local access covers configuration and state, explicitly selected ZIP/folder/Markdown or write input paths, and requested output destinations. Explicit create/import/write operations may upload those inputs. `NOTION_WORKSPACE_ID` and `NOTION_API_BASE_URL` enter the cache scope and are inherited by `ntn`. Workspace selection follows its authentication rules; the API base URL override can direct authenticated requests to another endpoint, so use only an endpoint you trust. Signed archive downloads follow the URLs returned by the service independently. See [the environment contract](docs/protocol.md#environment-and-local-storage).
26
+
27
+ ## Content and mutation boundaries
28
+
29
+ Archives reject root escapes, duplicate entries, links and special files, with compressed/expanded limits. ZIPs expand in memory and verify checksums. Create/import/write preserve extra metadata, nested paths and binary bytes in a source ZIP without executing them. Create rejects existing names; import replaces differing same-name content on the existing page, while write preserves unrelated logical files. Local read/export output verifies bytes, reuses identical output and rejects differing output without overwrite. Portable manifests add no generated remote identity or timestamps; original source fields may remain verbatim. Hashes detect corruption, not malicious authorized local modification.
30
+
31
+ Pinned write refs are checked against the current authentication scope, page identity and export version. This is a client preflight check, not a server-side atomic commit. Body/properties/files can partially succeed; mutation requests are not automatically retried. Read back WRITE_PARTIAL/WRITE_OUTCOME_UNKNOWN before retrying. A new write returns a new snapshot and never edits historical objects. The configured default database affects creation only; explicit --database has priority.
32
+
33
+ Database selection accepts one ID/URL or exact registered alias; IDs/URLs take priority and titles do not select targets. Unknown, conflicting or inaccessible aliases fail without redirecting to a default. Repeated --database flags fail before any command handler. Different databases may hold the same Skill name; name resolution fails on ambiguity, while page-ID refs remain exact. A pinned alias constraint checks local registration and snapshot database ownership without network access. Configuration registration aliases are local preferences, not remote identity or proof of permission.
34
+
@@ -0,0 +1,25 @@
1
+ # Third-party notices
2
+
3
+ The CLI bundle includes fflate 0.8.3, used for gzip and ZIP decompression. Effect packages remain external runtime dependencies and retain their own licenses in the distribution dependency tree.
4
+
5
+ ## fflate (MIT License)
6
+
7
+ Copyright (c) 2023 Arjun Barrett
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy
10
+ of this software and associated documentation files (the "Software"), to deal
11
+ in the Software without restriction, including without limitation the rights
12
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
+ copies of the Software, and to permit persons to whom the Software is
14
+ furnished to do so, subject to the following conditions:
15
+
16
+ The above copyright notice and this permission notice shall be included in all
17
+ copies or substantial portions of the Software.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ SOFTWARE.