ntn-skills 0.3.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/README.zh-CN.md CHANGED
@@ -1,236 +1,271 @@
1
1
  <h1 align="center">ntn-skills</h1>
2
-
3
- <p align="center">让 Agent 和终端用上你在 Notion 中维护的工作流。<br>先找到合适的 Skill,再读取指令,整项任务始终使用同一版本。</p>
4
-
2
+ <p align="center">基于 Notion 极简三表控制面与零延迟本地消费的 AI Agent 技能管理器。</p>
5
3
  <p align="center">
6
4
  <a href="./README.md">English</a> · <a href="./README.zh-CN.md">简体中文</a>
7
5
  </p>
8
-
9
- <p align="center">
10
- <a href="#安装">安装</a> · <a href="#快速开始">快速开始</a> · <a href="#常用场景">常用场景</a> · <a href="#接入-agent">接入 Agent</a> · <a href="./docs/README.md">文档</a>
11
- </p>
12
-
13
6
  <p align="center">
14
- <a href="./CHANGELOG.md"><img src="https://img.shields.io/badge/status-experimental-orange" alt="状态:实验性"></a>
15
- <a href="https://nodejs.org"><img src="https://img.shields.io/badge/runtime-Node.js%2022.22.3%2B%20(22.x)%20or%2024.20.0%2B-green" alt="运行时:Node.js 22.22.3+ (22.x) or 24.20.0+"></a>
16
- <a href="./LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue" alt="许可证:MIT"></a>
7
+ <a href="#快速开始">快速开始</a> ·
8
+ <a href="#双视角工作流">双视角工作流</a> ·
9
+ <a href="#命令速查">命令速查</a> ·
10
+ <a href="#安全与数据边界">安全与数据边界</a> ·
11
+ <a href="./INSTALL.md">Agent 安装协议 (<code>INSTALL.md</code>)</a> ·
12
+ <a href="./assets/ntn-skills/SKILL.md">内置手册 (<code>SKILL.md</code>)</a>
17
13
  </p>
18
14
 
19
- ```bash
20
- ntn-skills list
21
- ntn-skills read 'Release Review'
22
- ```
23
-
24
- `Release Review` 是示例名称,请选择你自己的 `list` 返回的 Skill。npm 安装包、命令和入口 Skill 都叫 **`ntn-skills`**。入口、内容维护与同步三个 Skill 均可通过 `ctl builtin` 独立管理,见[接入 Agent](#接入-agent)。
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 内容可能被修改。第一次成功读取会返回一个**快照**,把工作流和附件固定为一个本地版本。任务中持续使用返回的引用。普通未固定版本的读取可复用五分钟内验证过的内容;新任务需要确认远端最新内容时,在当前目标上加 `--refresh`。 已提交内容在 Notion 中的稳定手改可沿同一 current read 路径读取,旧 pinned 快照保持不变;未完成发布仍保留原恢复约束。
33
-
34
- 对于已提交且源 ZIP 与正文一致的原生 Skill,首次完整校验后会记录本地版本基线。之后普通读取可先核对主页面、引用页、完整包含关系和附件身份;一致时复用完整本地文件,不再逐页读取正文或重复下载源包,结果标记 `freshness.validation="metadata"`。修改时间未变化的编辑可能被快检漏过;`--refresh` 或显式 `--max-age 0` 始终完整校验正文和资源。新机器或没有基线时先走完整读取。详见[读取策略](docs/protocol.md#read-policy-and-cache-management)。
35
-
36
- | 你想做什么 | 使用的命令 |
37
- | --- | --- |
38
- | 找到工作流,避免一次加载整座库的正文 | `list` |
39
- | 从同一版本读取指令和附件 | `read`,再用 `files` |
40
- | 在本地文件和 Notion 之间迁移完整 Skill | `create`、`replace`、`export` |
41
- | 对固定页面一次应用文件和属性变更 | `apply` |
42
- | 将 Git Skills 订阅到 Notion 并持续更新 | `sync upstream connect`、`sync upstream run` |
43
- | 同步已有 Notion 页面与本地 Skill 目录 | `sync local connect`、`sync local run` |
44
-
45
- ## 安装
15
+ ---
46
16
 
47
- 安装 [Node.js](https://nodejs.org) **22.x 分支的 22.22.3+,或 24.20.0+**,其中包含 npm。在线操作还需要支持 `api --notion-version` 的[官方 Notion CLI](https://developers.notion.com/cli) **`ntn`**;本项目已使用 `ntn` 0.22.12 验证。
17
+ `ntn-skills` 将 **Notion 的 3 张数据表**(`Sources`、`Skills`、`Files`)作为可视化、跨机器同步的技能控制面;同时在消费侧彻底去耦合,通过只读不可变快照、标准软链(`~/.agents/skills`)、受管副本目录(如云沙盒 `:copy` 模式)与自动合成的本地目录路由技能(`skill-catalog`),在任何 Agent 宿主上实现 **0 毫秒纯本地读取消费**。
48
18
 
49
- 从官方 npm registry 安装已发布版本:
19
+ 日常业务对话不挂 MCP、不发 Notion 网络请求、不塞爆默认上下文;而你随时可以在 Notion 网页或手机上改分组、调可见性、写草稿,或让 Agent 给任意上游技能打热补丁实测。
50
20
 
51
- ```bash
52
- npm install --global ntn-skills --registry https://registry.npmjs.org
53
- ntn-skills --version
54
- ntn-skills --help
55
- ```
56
-
57
- 版本命令输出已安装版本;帮助列出可用命令。使用者需要 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)见使用指南。
58
-
59
- 需要自行生成安装包时,按[贡献指南中的开发与构建步骤](CONTRIBUTING.md#development-setup) 操作。Bun 用于安装依赖和构建;开发 CLI 与真实 SQLite 消费者均由 Node.js 执行。
21
+ ---
60
22
 
61
23
  ## 快速开始
62
24
 
63
- ### 1. 连接 Notion
64
-
65
- 按[官方认证指南](https://developers.notion.com/cli/get-started/authentication) 配置 `ntn`。连接需要 Read content 权限,并能访问具备 `Description` 和 `References` 两个富文本属性的数据库。`References` 保存 Notion 页面提及或页面链接,CLI 将这些页面转成 `references/` 下的 Markdown。已有原生 Skills 数据库及其导出模式也可继续使用。
66
-
67
- 数据库中至少需要一个有效 Skill。Notion Name 和作者填写的 frontmatter `name` 是人类可读的名称,按原值保留;允许 Unicode、数字、空格和连字符,名称必须非空且不含控制字符。例如,`Tty7` 保持为 `Tty7`,调用别名为 `tty7`。别名按 NFC 规范化并转为小写,去掉首尾空白,将连续空白替换为 `-`,对 Unicode 字母、组合标记、数字、`_` 和 `-` 以外的字符做百分号编码。别名只用于选择,不是身份;冲突时须使用精确页面 ID 或引用。`--name` 显式覆盖人类标题,不改变页面身份。[命名与数据库要求](docs/protocol.md#identity-and-references)。
68
-
69
- `ctl database init --parent PAGE_ID` 会在自有父页下创建内容表与独立的上游订阅表;接入已有两表时使用 `--content-database ID --upstream-database ID`。命令先验证字段类型和原生关系目标,通过读回后才保存配置;同一目标可安全重入。普通默认写入库独立,只有显式 `--set-default` 才改变。
70
-
71
- 内容来源使用独立的 `Source Type`(`builtin`、`upstream`、`manual`)与保存精确包 ID 的 rich-text `Builtin ID`,不与 Kind 或 Sync Mode 混用。显式 init 可升级已有两表,包括重复已发布的 attach operation;不会回填旧记录。普通 create 兼容缺少字段的旧表,replace/write 保留来源。builtin/upstream 发布要求先升级字段。正文相同而来源不同只更新元数据;全部一致时无远端修改地复用。详见[来源与冻结恢复协议](docs/protocol.md)。
72
-
73
- 用 `ntn-skills sync upstream connect SOURCE --database DATABASE` 注册 Git 来源并同步其中的 Skills;重复相同连接会复用订阅。后续 `sync upstream run` 使用可重复的 `--target SUBSCRIPTION_ID` 或 `--all`,二选一。每次运行记录同步状态、尝试与成功时间及摘要;失败或部分完成时继续其他目标,并以非零退出码结束。高级注册与 plan/apply 仍位于 `sync upstream`。[持续同步与两表配置](docs/usage.md#recurring-upstream-synchronization)。
74
-
75
- 普通 `run` 先检查原有未完成工作,再规划新变更;原归属页可读取且确认位于 Notion Trash 时,会恢复受管的 tracked 成员。旧页仍留在 Trash,经过验证的新页替换该成员映射。找不到页面或权限错误会明确失败。历史重建、adopt 和专项修复使用独立的 [operator 工件](docs/historical-operations.md)。
76
-
77
- 内容表支持 `Kind=skill|router|prompt`:Skill 入口为 `SKILL.md`;Router 入口为 `ROUTER.md`,包含成员元数据与稳定引用,由 Agent 按需读取成员;Prompt 入口为 `PROMPT.md`,每次显式引用都成为本轮用户要求。`list` 返回带 kind、稳定身份、locator 和 entrypoint 的 `records`;读取与导出返回同一 `record` 与固定快照。历史缺少 Kind 的条目按 Skill 处理。
78
-
79
- 创建 Prompt 或 Router 时,先准备 portable v2 manifest 与正文文件,再使用现有 `create` 参数:[完整 Prompt/Router 文件与命令示例](docs/usage.md#creating-a-prompt-or-router-from-portable-v2)。文件名或 frontmatter 不会决定 kind;详见 [portable 输入契约](docs/protocol.md#portable-input-contract)。
80
-
81
- 上游订阅只有至少两个已验证、已发布的有效 Skill 时才提供自动 Router。零个或一个成员不会产生 Router 目录项;单成员直接使用该 Skill 的引用。当前版本的精确 Router 读取也会拒绝不足两个成员的订阅。内容表中手工编写的 Router 继续按作者设置的 Members 工作,详见[订阅与 Router 用法](docs/usage.md#initialize-content-and-subscription-tables)。
82
-
83
- Skill 与 Router 的 `Default Context` 复选框各自独立,缺失或未勾选均为 false。Prompt 始终排除默认发现、后台预取和原生 Skill 安装;下一轮再次选择会重新加入本轮要求。初始化会创建该复选框,但不会自动勾选。
84
-
85
- 认证优先级为:已保存的 `config.token` → 非空 `NOTION_API_TOKEN` → 已有 `ntn login` 登录态。保存的 token 以明文存入私有配置文件;`ctl config show` 只显示是否已配置。[设置与移除 token](docs/usage.md#authentication)。
86
-
87
- ### 2. 检查访问权限,选择工作流
25
+ 将下面这句话直接发给 **Claude Code、Cursor、Pi、Codex、Grok Bot、Antigravity** 或任何具备终端能力的 Agent:
88
26
 
89
- ```bash
90
- ntn-skills ctl doctor
91
- ntn-skills list
27
+ ```text
28
+ 请阅读 https://raw.githubusercontent.com/yoyooyooo/ntn-skills/main/INSTALL.md 并帮我完成 ntn-skills 的安装与初始化。
92
29
  ```
93
30
 
94
- 有效 Skill 可访问时,`ctl doctor` 应返回 `ok: true`、`authentication: "available"`、大于零的 `skill_count`,以及 `skill_read.available: true`。它实际读取并缓存一个 Skill,验证当前存储模式。`list` 返回元数据和覆盖范围,不加载工作流正文。
95
-
96
- Notion Search 可能漏掉数据库。请查看 `coverage`;如果已知数据库,可使用 `ntn-skills list --database 'DATABASE_ID_OR_URL'`,将其中的值替换成实际数据库 ID 或 URL。
31
+ 你的 Agent 会自动检测本机环境、安装 CLI(自动挂载随包内置的 `ntn-skills` 管理技能)、引导你将 Notion Token 写入 `0600` 权限的本地文件(绝不经聊天记录泄露),并在你提供的空白 Notion 页面上一键创建纯净 3 表、开启后台增量同步,最后用 `ntn-skills doctor`(`6/6 pass`)完成验收。
97
32
 
98
- ### 3. 读取选中的 Skill
99
-
100
- 从 `records` 中复制一个条目的 `ref`,替换下面的占位值:
33
+ <details>
34
+ <summary>偏好手动安装?点击展开</summary>
101
35
 
102
36
  ```bash
103
- ntn-skills read 'REF_FROM_LIST'
37
+ # 1. 通过 npm / Bun 一键全局安装 CLI(需 Node >= 20 或 Bun >= 1.2;使用 Pi 可用下方 install.sh --with-pi)
38
+ npm install -g ntn-skills && ntn-skills skill --install
39
+ # 备选(含 Pi 扩展挂载):curl -fsSL https://raw.githubusercontent.com/yoyooyooo/ntn-skills/main/scripts/install.sh | bash -s -- --with-pi
40
+
41
+ # 2. 写入 Notion Integration Token(强制 0600 权限,原生遵循 XDG_CONFIG_HOME)
42
+ mkdir -p "${XDG_CONFIG_HOME:-$HOME/.config}/ntn-skills"
43
+ cat > "${XDG_CONFIG_HOME:-$HOME/.config}/ntn-skills/credentials.env" <<'EOF'
44
+ NOTION_TOKEN=ntn_你的令牌
45
+ # 可选:避免 GitHub API 限流及拉取私有 GitHub 技能仓
46
+ # GITHUB_TOKEN=ghp_你的令牌
47
+ EOF
48
+ chmod 600 "${XDG_CONFIG_HOME:-$HOME/.config}/ntn-skills/credentials.env"
49
+
50
+ # 3. 传入空白 Notion 页面 URL(自动建 3 表 + 默认开启 discoverable 预物化 + 首次同步)或已有 Library URL
51
+ ntn-skills init --root "https://www.notion.so/你的页面链接"
52
+
53
+ # 4. 开启原生后台静默增量同步(macOS launchd / Linux systemd)
54
+ ntn-skills schedule install
55
+
56
+ # 5. 一键体检验收(预期 0 fail)
57
+ ntn-skills doctor
58
+ ntn-skills skill # 直接打印随当前二进制内置的权威 Agent 指南
104
59
  ```
105
60
 
106
- 成功响应包含 `ok: true`、`content` 中的指令、以 `s_` 开头的 `snapshot_id`,以及包含 `?snapshot=...` 的固定版本 `ref`。`source: "notion"` 表示本次在线验证,`source: "local_cache"` 表示有时间边界的缓存观察。将 `freshness`、引用和快照 ID 保留在任务上下文中;需要确认当前访问权限与远端内容时,对当前引用加 `--refresh`。[响应字段说明](docs/protocol.md#success)。
107
-
108
- ### 4. 从同一版本读取附件
61
+ </details>
62
+
63
+ ---
64
+
65
+ ## 运行前提与支持平台
66
+
67
+ - **操作系统**:macOS(原生 `launchd` 定时同步与系统废纸篓)与 Linux(`systemd --user` 定时同步与 XDG 回收站);Windows 建议通过 WSL2 运行。
68
+ - **运行依赖**:`git`,以及 **Node.js `>= 20`**(支持 `npm install -g ntn-skills` 直接运行)或 **[Bun](https://bun.sh) `>= 1.2.0`**。
69
+ - **Notion 准备**:一个 [Notion 内部集成令牌](https://www.notion.so/profile/integrations),并将该集成授权给你准备的一个空白 Notion 页面(或已有 `ntn-skills` 根页面)。
70
+ - **宿主兼容**:开箱兼容 Claude Code、Codex、Cursor、Pi、Antigravity、Grok Bot(`${HOME}/agent-data/workflows:copy`)及所有支持从本地目录读取 `SKILL.md` 的 Agent 环境。
71
+
72
+ ---
73
+
74
+ ## 双视角工作流
75
+
76
+ 理解 `ntn-skills` 最简单的方式,是把 **“人的日常操作”** 与 **“Agent 的后台行为”** 分开看——你平时根本不需要背下面的 CLI 参数。
77
+
78
+ ### 一、人的视角(你在 Notion 和对话里怎么用)
79
+
80
+ 1. **在 Notion 网页 / 手机上随手改表格字段**
81
+ - **做什么**:调整 `Visibility`(把高频技能设为 `always` 常驻顶层、把自用专项技能设为 `discoverable` 编入按需目录、把外部大仓长尾留在 `manual` 静默待命),修改触发描述 `Description`、领域分类 `Scenes`、多机分组 `Profiles`,或取消勾选 `Enabled` 停用技能。
82
+ - **怎么生效**:改完直接关网页即可。每台机器后台每 12 分钟自动增量同步并刷新本地软链与 `skill-catalog`;想下一秒立刻生效,对 Agent 说一句 *“同步下技能”*(`ntn-skills sync`)。
83
+
84
+ 2. **在 Notion 页面里直接改 `SKILL.md` 正文(注意一个关键区别)**
85
+ - **纯 Notion 自有草稿技能(`Origin` 为空)**:Notion 页面正文就是它的唯一正本,你在网页里怎么改,同步到本地就是什么样(若 Notion 偶发未刷新外层时间戳,跑一次 `ntn-skills sync --full` 即可强制重拉正文)。
86
+ - **来自 Git 仓库的上游技能(`Origin` 有值)**:默认 `Custom Main` 未勾选时,Notion 页面里的正文只是方便你阅读的**上游只读预览镜像**,本地实际消费仍以 Git 提交为准。如果你直接在 Notion 网页里改了上游技能正文并希望生效,**请同时勾选 `Custom Main`**(若忘记勾选,`sync` 会给出未生效漂移提醒,防止你误以为网页修改已上线)。
87
+
88
+ 3. **想微调某个外部/内部上游技能去实测,又不想 Fork 仓库**
89
+ - **怎么做**:直接在对话里对 Agent 说:*“给 `dagu` 技能加一段我们本机的路径约定和一个检查脚本,推回 Notion 让我实测几天。”*
90
+ - **效果**:Agent 自动拉起隔离工作区改好推回 Notion(自动置 `Custom Main = true` 并在 `Files` 表记录 `override / delete` 差异层),你的所有机器立刻消费「Git 上游基线 + Notion 热补丁」的合成版本。
91
+ - **两个收口方向**:
92
+ - 实测不满意:对 Agent 说 *“撤掉 `dagu` 的本地覆盖恢复原版”*(`reset-overlay`),一秒还原干净跟随上游;
93
+ - 实测成熟想正式入仓:对 Agent 说 *“把 `dagu` 导出干净源码到我的个人技能仓库提交”*(`pull --clean` + `attach` / `upstream apply`)。当上游 Git 追平补丁后,Notion 里的临时覆盖行会**自动归档清零**。
94
+
95
+ 4. **先在本机孵化试跑一个临时技能,确认好用后再存进 Notion**
96
+ - **怎么做**:先让 Agent 在 `~/.agents/skills/<新技能名>/` 下直接写一个普通本地技能目录,不用碰 Notion,直接在本地反复改、反复试跑(后台定时同步绝不触碰非受管的本地目录,且 `sync` 会在 `Local Pending` 中清晰提示未入库的本地技能)。
97
+ - **怎么转正**:试跑满意后,对 Agent 说一句 *“这个技能没问题了,存进 Notion 吧”*(`ntn-skills new ~/.agents/skills/<新技能名> [--always | --discoverable]`)。系统会在完整上传至 Notion 后,自动将原本地临时目录安全移入系统废纸篓,并原地无缝切换为受管只读软链(`always`)或编入 `skill-catalog`(`discoverable`)。
98
+
99
+ 5. **导入几百个技能的外部大仓 + 定期看一眼治理面板**
100
+ - 收藏第三方大仓时默认全进 `manual`(0 上下文负担);接入你自己的主力技能仓时可设为 `discoverable` 一键编入目录。
101
+ - 隔段时间看一眼 `ntn-skills status`:看近 30 天按需加载热度榜(`Hot Loads`)决定谁该升 `always`,看草稿池(`Draft Buffer`)和热补丁(`Overlays`)决定谁该毕业沉淀进 Git。
102
+
103
+ ### 二、Agent 的视角(99% 消费态 vs 1% 管理态严格隔离)
104
+
105
+ | 状态 | 触发时机 | Agent 看到与执行的内容 |
106
+ | :--- | :--- | :--- |
107
+ | **日常干活(消费态,99% 会话)** | 所有普通编码、调研、运维业务任务 | **完全不知道 Notion 的存在,0 网络请求**:<br>1. **`always` 技能**:已在 `~/.agents/skills/<name>`(或 `:copy` 目标目录)顶层就位,直接读取。<br>2. **`discoverable` 技能**:所有宿主顶层都会看到一个纯本地自动合成的只读目录技能 **`skill-catalog`** —— 遇到专项任务时,Agent 翻开 `skill-catalog/SKILL.md` -> 对应领域的 `references/<scene>.md` -> 直接读取本地已预物化的只读 `store/.../SKILL.md`(纯文件两跳直达,零插件依赖)。<br>3. **`manual` 技能**:平时完全隐身;在 Pi 中通过用户输入 `$skill` 或 `skill_find / skill_load` 工具按需唤醒,在其他宿主中通过策略型 Router 指引或 `ntn-skills load` 点名加载。<br>4. **只读红线**:`store/` 目录固定 `0444/0555` 只读权限,绝不允许原地修改。 |
108
+ | **技能维护(管理态,1% 会话)** | 仅当人类明确要求新建、修改、打补丁、导入源或排障技能库时 | 按需读取随 CLI 内置发布的 **`ntn-skills`** 技能(或运行 `ntn-skills skill` 获取与当前二进制版本严格对齐的手册),通过 `new / set / edit / diff --remote / push` 操作控制面,完活后自动将临时工作区移入系统废纸篓。 |
109
+
110
+ ---
111
+
112
+ ## 架构总览
113
+
114
+ ```mermaid
115
+ flowchart LR
116
+ subgraph Control["Notion 控制面(人类可视化工作台)"]
117
+ SRC["Sources 表
118
+ (外部与私有 Git 源)"]
119
+ SKL["Skills 表
120
+ (Visibility / Scenes / SKILL.md)"]
121
+ FIL["Files 表
122
+ (草稿附属文件 & 热补丁差异层)"]
123
+ end
124
+
125
+ subgraph Local["本机只读运行时($XDG_DATA_HOME/ntn-skills)"]
126
+ CAT["catalog.json & manifest.json
127
+ (增量游标 + 静态机器可读清单)"]
128
+ STO["只读不可变快照 store/
129
+ (0444/0555 · always + discoverable 预物化)"]
130
+ end
131
+
132
+ subgraph Hosts["跨宿主零延迟消费层"]
133
+ EXP["~/.agents/skills/ 或 :copy 目标目录
134
+ (always 技能 + 自动合成 skill-catalog)"]
135
+ ANY["任意宿主(Claude Code / Codex / Grok Bot / Cursor / Antigravity)
136
+ 纯文件 Read 两跳直达"]
137
+ PI["Pi 扩展
138
+ ($skill 内联注入 + skill_find / skill_load)"]
139
+ end
140
+
141
+ SRC --> SKL
142
+ FIL --> SKL
143
+ Control -- "每 12 分钟增量同步
144
+ (launchd / systemd)" --> CAT
145
+ CAT --> STO
146
+ STO -- "原子软链 / 受管副本" --> EXP
147
+ EXP --> ANY
148
+ CAT --> PI
149
+ STO --> PI
150
+ ```
109
151
 
110
- 每一步都用前一个命令返回的实际值替换占位值:
152
+ ---
111
153
 
112
- ```bash
113
- ntn-skills files 'SNAPSHOT_ID_FROM_READ'
114
- ntn-skills read 'ATTACHMENT_REF_FROM_FILES'
115
- ```
154
+ ## 极简三表结构
116
155
 
117
- 用快照 ID 列出**全部**文件;传入某个文件的引用,只会列出那个文件。请选择 `files` 实际返回的附件。它的固定版本引用使用同一个快照,即使没有认证或网络,读取也会返回 `source: "local_snapshot"`。历史版本只能读取本机已经保存过的快照。
156
+ 由 `ntn-skills init --root <空白页链接>` 自动创建并双向关联:
118
157
 
119
- 二进制附件加上 `--output ./attachment.bin`,再用合适的查看器打开。文本可用 `--lines 10-30` 读取包含首尾的行区间,或用 `--raw` 输出 UTF-8 原文。脚本不会被自动执行。
158
+ | 数据表 | 职责 | 核心字段 |
159
+ | :--- | :--- | :--- |
160
+ | **`Sources`** | 管理外部上游与自有私有 Git 仓库 | `Name`、`Repo URL`、`Ref`、`Pinned Commit`、`Policy` (`track \| pinned \| manual`)、`Enabled`、`Last Checked`、`Skills` |
161
+ | **`Skills`** | 技能总目录、三档可见性路由与 `SKILL.md` 正文 | `Name`、`Description`、`Enabled`、`Visibility` (`always \| discoverable \| manual`)、`Kind` (`skill \| router \| prompt`)、`Profiles`、`Scenes`、`Requires`、`Origin`、`Source Path`、`Custom Main`、`Revision`、`Preview Hash`、`Status`、`Supporting Files` |
162
+ | **`Files`** | 自有技能附属文件与上游技能差异补丁 | `Name`、`Skill`、`Path`、`Status` (`override \| delete`)、`Executable`、`SHA256`、`External URL`、`Attachment` |
120
163
 
121
- ## 常用场景
164
+ > **子树哈希剪枝与零冗余**:未改动的上游技能在 `Files` 表中占 **0 行**(上游文件清单自动展示在技能页第 1 行的只读子页 `Upstream Files` 中)。当多技能上游仓库有新提交时,未改动的同仓其他技能触发 **0 次 Notion 写入**,本地 `effectiveRev` 保持稳定不重物化。
122
165
 
123
- ### 按领域选择工作流库
166
+ ---
124
167
 
125
- 为已知数据库注册领域别名,然后明确选择它。执行前替换数据库占位值:
168
+ ## 命令速查
126
169
 
170
+ ### 初始化、内置手册、体检与消费检索
127
171
  ```bash
128
- ntn-skills ctl database register ops --database 'DATABASE_ID_OR_URL'
129
- ntn-skills list --database ops
130
- ntn-skills read 'Release Review' --database ops
172
+ # 若 XDG 配置中已有 default_library,重跑 init 可省略 --root
173
+ ntn-skills init [--root <notion-page-url>] [--export ~/.agents/skills] [--export '${HOME}/agent-data/workflows:copy'] [--profile default] [--prefetch discoverable]
174
+ ntn-skills skill [--path] [--install [--dest ~/.agents/skills] [--force]] [--uninstall]
175
+ ntn-skills doctor [--json]
176
+ ntn-skills status [--days 30] [--json]
177
+ ntn-skills sync [--full] [--coalesce] [--json]
178
+ ntn-skills find [关键词] [--scene <场景>] [--visibility always|discoverable|manual] [--kind skill|router|prompt] [--json]
179
+ ntn-skills info <name> [--json]
180
+ ntn-skills load <name> [--refresh] [--path-only]
131
181
  ```
132
182
 
133
- 数据库别名精确匹配,区分大小写。两个数据库存在同名 Skill 时,选择数据库,或使用 `list` 返回的包含页面 ID 的引用。已注册的来源会补充自动发现的范围。[发现、别名与覆盖范围](docs/usage.md#discovery-and-identity)。
134
-
135
- ### 导入、导出或更新 Skill
136
-
137
- Skill 可以来自文件夹、ZIP 或 Markdown 文件。先预览远端变更,再执行:
138
-
183
+ ### 草稿创建、批量元数据、Overlay 调优与入仓毕业
139
184
  ```bash
140
- ntn-skills create ./my-skill --database ops --dry-run
141
- ntn-skills create ./my-skill --database ops
142
- ntn-skills export 'My Skill' --database ops --output ./my-skill.zip
143
- ntn-skills apply 'PINNED_MAIN_REF_FROM_READ' --input ./changed-files --dry-run
185
+ # 隔离工作区编辑闭环(严禁直接修改只读 store/)
186
+ WORKDIR=$(ntn-skills edit "<name>")
187
+ ntn-skills diff "$WORKDIR" --remote
188
+ ntn-skills push "$WORKDIR" [--dry-run]
189
+ ntn-skills abort "$WORKDIR"
190
+
191
+ # 新建/原地收编纯 Notion 草稿技能 & 单个/按源批量修改元数据
192
+ ntn-skills new <dir> [--name <name>] [--visibility always|discoverable|manual] [--profiles default] [--scenes ops] [--no-adopt]
193
+ ntn-skills set [<name...>] [--source <source-name>] \
194
+ [--visibility always|discoverable|manual | --always | --discoverable | --manual] \
195
+ [--kind skill|router|prompt] [--enable|--disable] [--add-profile <p>] [--add-scene <s>] [--require <dep>]
196
+
197
+ # 导出干净源码入仓、草稿毕业挂源、解绑、回退补丁与软退役
198
+ ntn-skills pull <name> <git-repo-skill-dir> --clean
199
+ ntn-skills attach <name> --source <source-name> [--path <repo-relative-dir>]
200
+ ntn-skills detach <name>
201
+ ntn-skills reset-overlay <name> [<file-path>]
202
+ ntn-skills rm <name> # 软标记 retired 并撤回本地软链,绝不物理硬删
144
203
  ```
145
204
 
146
- `create` 要求名称尚不存在。更新已有页面时,`apply` 针对一个 pinned 主文件 ref 或 snapshot,一次合并变更文件、可重复的 `--remove PATH` 和显式属性参数。`./changed-files` 只放本次新增或修改的文件,其余文件保留;去掉 `--dry-run` 执行已审阅的变更。基线过期会在发布前失败。单独修改文件或属性仍可使用 `write`、`update`。[输入格式、冲突与部分成功的处理](docs/usage.md#creating-importing-exporting-and-updating-skills)。
147
-
148
- 用 `replace ./my-skill --target 'CURRENT_PAGE_ID_OR_PINNED_MAIN_REF' --database ops --dry-run` 明确替换已有页面。即使导入的名称、描述变化,`--target` 仍保留选定页面身份;目标缺失、不可访问或版本过期时失败,不按导入名称回退或创建新页。
149
-
150
- 普通导入在目标和替换行为已获授权后,执行一次即可;退出码 0、`ok: true`、`verified: true` 且没有 `dry_run: true` 就是完成标准。CLI 自动读回核对正文、参考页和完整文件身份;有 Files 时同时保留并校验原始字节。日常无需再逐项 read/files/export 验收。这验证的是存储结果,不代表已执行或验证 Skill 工作流本身。
151
-
152
- 目标是 upstream → Notion,以及当前 Notion → Markdown/缓存 → Agent 两条链路不丢指令、代码、链接和资源,不要求任意 Markdown 与 Notion 无限双向逐字节可逆。原生 Markdown 允许约定的格式归一化,但拒绝指令变化。纯文本 Skill 可显式用 `--storage markdown_files` 存成 Notion 中可编辑的文件代码块;消费读取当前代码正文,不用源 ZIP 掩盖后续编辑。[存储、归一化与恢复契约](docs/protocol.md#mutation-contract)。
153
-
154
- ### 同步本地分发目录
155
-
156
- 将 `PAGE_ID` 替换为实际选中的页面 ID。绑定标签是本地配置,与 Skill 调用别名分开。
157
-
205
+ ### 上游源维护与后台定时调度
158
206
  ```bash
159
- ntn-skills sync local connect PAGE_ID --path ~/.agents/skills/release-review --as release-review-global
160
- ntn-skills sync local run release-review-global
161
- ntn-skills sync local status release-review-global
207
+ # 导入新 Git 源(外部大仓默认 manual;个人主力仓可加 --discoverable 与 --scenes)
208
+ ntn-skills source add <repo-url> [--name <name>] [--ref main] [--root skills] [--policy track|pinned|manual] [--discoverable] [--scenes ops,coding]
209
+ ntn-skills source list
210
+ ntn-skills source sync <name> [--update-pinned]
211
+ ntn-skills upstream check [<source>]
212
+ ntn-skills upstream apply [<source>] [--dry-run] [--max-sources 10] [--timeout-sec 180]
213
+
214
+ # 原生系统定时任务(macOS launchd / Linux systemd)与外部调度器模板导出
215
+ ntn-skills schedule install [--sync-every 12m] [--full-at 04:12] [--upstream-every 6h]
216
+ ntn-skills schedule status
217
+ ntn-skills schedule uninstall
218
+ ntn-skills schedule export --target dagu|github-actions|crontab
162
219
  ```
163
220
 
164
- 目录尚不存在时从 Notion 初始化;已有目录内容不同时,必须用 `--from local|notion` 明确选择来源。后续运行按已确认的共同基线比较两侧,保留冲突。重复相同连接会复用绑定。原有回执只有在观察确认收敛时才会结清;仍未决的结果保留原 operation ID 和下一步指引。
221
+ ---
165
222
 
166
- 需要分别审阅计划时,可用高级 `bind`、`plan`、`apply --plan`。执行前重新检查绑定、版本、内容及逻辑路径和真实目标。`status` 默认报告已有观察,`--refresh` 才在线验证;`unbind` 保留内容、基线、计划和回执。符号链接保持原链接,移除或替换的旧字节通过系统废纸篓保留。详见[同步使用说明](docs/usage.md#synchronizing-local-skills)。
223
+ ## Pi 扩展
167
224
 
168
- ### 在 Notion 中维护参考页面
225
+ 安装时追加 `--with-pi`(或将 `packages/pi-extension` 软链至 `~/.pi/agent/extensions/ntn-skills`),即可在 Pi 中获得:
226
+ - **`$skill-name` 内联自动物化**:即使技能处于 `discoverable` 或 `manual` 档位,在提示词中直接写 `$技能名` 即可从本地只读存储按需注入本轮上下文;
227
+ - **`skill_find` 与 `skill_load` 原生工具**:支持按关键词、`scene`、`visibility`、`kind` 零网络检索本地全量目录并按需加载长尾技能,自动计入 `Hot Loads` 热度榜。
169
228
 
170
- 在富文本 `References` 属性中添加页面提及或链接。链接文字写成 `references/guide.md` 时固定本地路径,否则按页面标题生成文件名。正文照常使用 Notion 页面链接;CLI 读取和导出时转换为 `./references/guide.md` 等相对路径。参考文档互相引用时按所在文件目录解析,CLI 写回时恢复 Notion URL。其他网站链接和代码示例保持原样。
229
+ ---
171
230
 
172
- `create`、`replace` 将 `references/**/*.md` 创建为可编辑的子页面;`write` 更新对应参考页。导入时移除某个参考文件,会让它退出新快照,原 Notion 页面保留。纯页面库可以不设 `Files`;需要保留原始字节、额外 frontmatter 或非 Markdown 资源时继续保留它。详见 [References 契约](docs/protocol.md#references-pages)。
231
+ ## 安全与数据边界
173
232
 
233
+ - **日常消费零网络请求**:日常会话仅读取 `$XDG_DATA_HOME/ntn-skills/store/`(默认 `~/.local/share/ntn-skills/store/`)下的只读不可变快照(`0444/0555`);仅在显式运行同步/维护 CLI 或系统定时任务时访问 `api.notion.com` 与用户配置的 Git 远端。
234
+ - **本地凭据保护与零第三方遥测**:`credentials.env` 存放在 `$XDG_CONFIG_HOME/ntn-skills/`(默认 `~/.config/ntn-skills/credentials.env`),`doctor` 强制校验 `0600` 权限;工作区自动剥离 `.env` 等敏感文件;调用统计(`telemetry/usage.jsonl`)与同步日志(`2 MiB` 上限轮转)100% 留在本机,绝不外发。
235
+ - **非受管目录保护与零永久删除**:`export` 绝不覆盖宿主目录中已有的非受管文件或软链;工作区和过期缓存回收统一移入系统废纸篓;Notion 技能下线走软标记 `Status = retired`。
236
+ - **形式化验证**:核心并发锁、重叠窗口增量同步与原子快照切换不变量配有 TLA+ 规约(见 [`verification/`](https://github.com/yoyooyooo/ntn-skills/tree/main/verification))。
174
237
 
175
- ## 接入 Agent
238
+ ---
176
239
 
177
- 随包提供三个职责明确的 Skill。让入口 Skill 默认可发现,正文只在任务需要时加载。“官方”指本项目维护。
240
+ ## 适用范围与非目标
178
241
 
179
- | Builtin ID | 职责 |
180
- | --- | --- |
181
- | `notion/ntn-skills` | [发现、读取工作流和任务路由](skills/ntn-skills/SKILL.md) |
182
- | `notion/ntn-skills-maintain` | [维护 Notion 内容、References 与可移植副本](skills/notion/ntn-skills-maintain/SKILL.md) |
183
- | `notion/ntn-skills-sync` | [连接来源和本地目录、持续同步并恢复原操作](skills/notion/ntn-skills-sync/SKILL.md) |
242
+ - **聚焦 Agent Skills 生命周期**:`ntn-skills` 专注管理基于 `SKILL.md` 与附属脚本/参考文档的技能资产;不承担 MCP Server 托管代理、通用密钥管理或宿主系统初始化编排。
243
+ - **刻意保持单向同步边界**:`ntn-skills sync` 仅从 Notion/Git 向本机单向拉取并在 `Local Pending` 提示本地未入库增量,绝不静默将本地临时试验推上云端;所有写回均须显式经过 `new` 或 `edit -> diff --remote -> push`。
184
244
 
185
- 启用 Context Broker 后,在 Pi/OMP/Tern 的普通 `$` 发现中选择 `$ntn-skills@builtin`、`$ntn-skills-maintain@builtin` 或 `$ntn-skills-sync@builtin`。随包正文与引用不依赖 Notion 来源或额外本地安装。`/context-broker` 负责会话、View 和刷新;内容任务由选中的 Skill 调用公共 CLI 完成。[随包 Skill 的宿主入口](docs/host-integration.md#bundled-skills-in-hosts)。
186
-
187
- CLI 同样可离线检查包内指令。需要为其他消费者保留独立管理的本地副本时,再显式安装:
188
-
189
- ```bash
190
- ntn-skills ctl builtin list
191
- ntn-skills ctl builtin read notion/ntn-skills
192
- ntn-skills ctl builtin install notion/ntn-skills
193
- ntn-skills ctl builtin install notion/ntn-skills-maintain
194
- ntn-skills ctl builtin install notion/ntn-skills-sync
195
- ntn-skills ctl builtin status
196
- ntn-skills ctl builtin update notion/ntn-skills
197
- ```
198
-
199
- `install`、`status`、`update` 无需认证,可离线运行。受管文件统一位于 `${XDG_DATA_HOME:-~/.local/share}/ntn-skills/skills/<name>`,默认在 `~/.agents/skills/<name>` 建立软链。可重复传入 `--agent-dir DIR` 增加其他 Agent 根目录,各自的 `DIR/skills/<name>` 都指向同一份安装;已登记目标会保留供后续更新使用。完整文件回执保护本地修改与无归属目录,替换的旧字节进入系统废纸篓。旧版 profile 安装需要独立迁移工件;普通命令保留其内容并明确报冲突。安装后重载或重启宿主以刷新原生发现;升级 npm 包不会自动更新已安装 Skill。Broker 选择的是自己的随包副本;这里的显式本地安装独立更新。[宿主入口](docs/host-integration.md#bundled-skills-in-hosts)。
200
-
201
- `ctl builtin export` 仍用于导出可移植副本。发布到 Notion 是独立的在线操作:可选用 `ctl config set builtin_database ops` 配置发布目标,再以 `ctl builtin publish notion/ntn-skills-maintain --dry-run` 预览。首次发布遇到任何同名页都报冲突;明确更新必须用 `--target` 指定页面身份或固定版本基线。远端页面不能靠同名或 publisher 文字获得官方身份。[命令、回执与重名规则](docs/usage.md#optional-official-skills)。
202
-
203
- 启用 OMP/Pi Context Broker 后,`<ntn-skills-guidance>` 提供实际 CLI 和来源范围。所选 Notion View 决定默认 Skill/Router 的名称和描述,不预载正文。来源配置 `default_view_id` 优先;未配置时使用 API 返回的第一个 View。`Default Context` 只是普通属性,只有 View 的筛选使用它时才影响成员集合。启动可准备目录和快照,但不发起模型请求;用户首次发送时,当前目录在 provider 调用前加入提示词。切换 View 影响下一轮目录,不撤回已读正文。完整 `$` 和未限定 View 的 CLI 发现仍可使用。仅安装入口 Skill 不会安装 Broker。[宿主接入契约](docs/host-integration.md)。
204
-
205
- 检查或维护 Skill 不会激活其中的指令。宿主仅激活当前任务选择的工作流并保留其新鲜度信息;下载的内容、脚本不会自动执行。
206
-
207
- `pi-context-broker` 在独立仓库提供单向 Notion 来源适配器,使用元数据 `list`、页面 ID `read` 和固定快照目录 `export`。所选 View 成员在发现后准备,其他项在选择时准备;消费前不激活其中的指令。消费者保留 scope、coverage 与快照身份,核对导出 `main_path` 与 manifest `main`,再加载真实入口与附件。broker 负责宿主接入,本仓库不安装它或注册宿主钩子。详见 [broker 消费契约](docs/host-integration.md#broker-source-consumption)。源码 checkout 的 verification Skill 提供验收地图;安装包消费者使用公开契约与 CLI。
208
-
209
- ## 使用边界与本地数据
210
-
211
- - 历史本地验证覆盖 macOS arm64 的 Node.js 24.20.0 和 Linux arm64 的 Node.js 22.19.0 上的 npm 安装与预置快照离线行为;后者现已不受支持。真实 Notion 读取使用 macOS 和 `ntn` 0.22.12 验证。CI 配置为 Ubuntu、macOS 15 上的 Node.js 22.22.3 和 24.20.0;工作流配置不代表新变更已运行成功。Windows 未验证。
212
- - 内容写入、`ctl builtin publish` 和同步的 `connect/run/apply` 可能修改内容。发布支持 `--progress` 输出 stderr 阶段与耗时,并保留冻结输入和回执;中断后用 `operation resume OPERATION_ID` 在原发布上继续,无法确认的写入仍明确报错。本地同步检查原有回执,未确认收敛时返回原 operation 和下一步指引。客户端版本检查不等于原子提交。[发布恢复](docs/usage.md#creating-importing-exporting-and-updating-skills)。
213
- - 配置默认位于 `~/.config/ntn-skills/config.json`;快照、上传暂存和同步恢复状态位于 `~/.local/state/ntn-skills`;可丢弃观察缓存位于 `~/.cache/ntn-skills`。受管 builtin 位于 `~/.local/share/ntn-skills`,可用 `NTN_SKILLS_DATA_HOME` 或 XDG 数据根覆盖。正文默认五分钟、目录元数据默认 60 秒;[缓存策略与清理](docs/usage.md#cache-policy-and-cleanup)说明配置及系统废纸篓保留。
214
- - 在线操作通过 `ntn` 和 Notion 的签名下载 URL 完成。未固定版本的离线查找必须能安全确定本地身份范围;官方登录身份可能仍需在线检查。缓存观察不能证明当前权限。CLI 自身不发送遥测请求;`ntn` 有自己的政策。导入的脚本不会自动执行。
215
-
216
- 详见[配置与存储](docs/protocol.md#environment-and-local-storage)、[错误恢复](docs/protocol.md#errors) 和[安全与隐私](SECURITY.md)。
245
+ ---
217
246
 
218
247
  ## 升级与卸载
219
248
 
220
- tarball 安装可获取新版已构建安装包,再执行 npm 安装命令。跨 0.x 次版本升级前,请阅读[变更记录](CHANGELOG.md)。源码构建按[贡献指南](CONTRIBUTING.md#development-setup) 操作。
249
+ ```bash
250
+ # 无损升级至最新版(保留已有配置、凭据与本地快照)
251
+ npm install -g ntn-skills@latest # 若通过源码脚本安装则重跑 scripts/install.sh
221
252
 
222
- 全局安装用 `npm uninstall --global ntn-skills` 卸载。配置、缓存、保留状态、已安装 builtin 数据与分发软链仍在;保留所需固定版本、同步基线、计划与未完成回执。需要移除已保存的 token 时,在卸载前执行 `ntn-skills ctl config clear-token`。升级保留状态与配置,在独立缓存根重建可丢弃观察;原先假定每次未固定读取都在线的调用者应加 `--refresh`。[卸载与可选保留说明](docs/usage.md#upgrade-and-uninstall)说明应保留哪些数据。
253
+ # 干净卸载本机运行时(绝不会删除你的 Notion 云端数据)
254
+ ntn-skills schedule uninstall
255
+ ntn-skills skill --uninstall
256
+ # 随后将 ~/.local/share/ntn-skills、~/.config/ntn-skills 与 ~/.local/bin/ntn-skills 移入系统废纸篓即可
257
+ ```
223
258
 
224
- ## 文档与贡献
259
+ ---
225
260
 
226
- | 下一步 | 文档 |
227
- | --- | --- |
228
- | 安装变体与日常 CLI 操作 | [使用指南](docs/usage.md) |
229
- | 选择器、JSON 输出、存储与错误 | [CLI 与引用契约](docs/protocol.md) |
230
- | 启动时的元数据注入与 Read/Write 适配器 | [宿主接入](docs/host-integration.md) |
231
- | 开发环境与兼容政策 | [贡献指南](CONTRIBUTING.md) |
232
- | 发版与发布结果验证 | [发布流程](docs/releasing.md) |
261
+ ## 开发与开源治理
233
262
 
234
- 问题报告和使用咨询请在 [GitHub issues](https://github.com/yoyooyooo/notion-skills-cli/issues) 提交脱敏信息;漏洞通过[私下报告渠道](SECURITY.md#reporting-a-vulnerability) 提交。开发或构建 CLI 请从[贡献指南](CONTRIBUTING.md) 开始。
263
+ ```bash
264
+ bun install
265
+ bun run check # 依次执行 biome lint、tsc 类型检查与全套不变量单元测试
266
+ ```
235
267
 
236
- [文档目录](docs/README.md) · [变更记录](CHANGELOG.md) · [MIT 许可证](LICENSE)
268
+ - [贡献指南 (`CONTRIBUTING.md`)](./CONTRIBUTING.md)
269
+ - [安全策略 (`SECURITY.md`)](./SECURITY.md)
270
+ - [变更日志 (`CHANGELOG.md`)](./CHANGELOG.md)
271
+ - [MIT 许可证 (`LICENSE`)](./LICENSE)
package/SECURITY.md CHANGED
@@ -1,46 +1,19 @@
1
- # Security policy
1
+ # Security Policy
2
2
 
3
- ## Supported versions
3
+ ## Supported Versions
4
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.
5
+ | Version | Supported |
6
+ | :--- | :--- |
7
+ | `2.0.x` | Yes |
8
+ | `< 2.0.0` | No |
6
9
 
7
- ## Reporting a vulnerability
10
+ ## Data, Network & Credential Boundaries
8
11
 
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.
12
+ - **Local Secret Storage**: `ntn-skills` reads `NOTION_TOKEN` and optional `GITHUB_TOKEN` from `$XDG_CONFIG_HOME/ntn-skills/credentials.env` (default `~/.config/ntn-skills/credentials.env`) and verifies `0600` file permissions via `ntn-skills doctor`.
13
+ - **Zero Consumer-Time Network Access**: Everyday skill consumption reads immutable local files (`0444/0555`) under `$XDG_DATA_HOME/ntn-skills/store/`. Network calls to `api.notion.com` and configured Git remotes occur only during explicit CLI commands or user-installed background sync jobs.
14
+ - **Local-Only Telemetry**: Usage counters (`telemetry/usage.jsonl`) and API latency logs are bounded (`2 MiB` rotation) and stored strictly on the local machine. Nothing is transmitted to third-party analytics endpoints.
15
+ - **Workdir Secret Scrubbing**: Isolated edit workdirs ignore `.env`, `.env.*`, and credential files during `diff` and `push`.
10
16
 
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. Current-target reads may reuse a complete observation within the configured age; use `--refresh` to verify present remote access. Isolate `NTN_SKILLS_HOME`, `NTN_SKILLS_CONFIG_HOME` and `NTN_SKILLS_CACHE_HOME` for separate host identities; a shared config token overrides a host's environment credential. Protect all three roots and config.json backups according to your retention policy. Defaults are `~/.local/state/ntn-skills`, `~/.config/ntn-skills` and `~/.cache/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
- Content/catalog defaults of five minutes/60 seconds control freshness only. Immutable snapshot manifests, content-addressed objects, uploads and sync baselines/plans/receipts are retained without automatic garbage collection; upload staging can contain original input bytes. Uninstalling retains configuration, state and cache. `cache clear` retires only disposable observations through the implemented system Trash capability and preserves recovery state. Where retention is unavailable it fails explicitly and leaves bytes in place. Remove a saved token with `config clear-token`; deliberately reclaim other identified directories only through an approved recycle/retention process after stopping hosts. State cleanup loses pinned versions and sync recovery history. See [storage and uninstall guidance](docs/usage.md#upgrade-and-uninstall).
20
-
21
- Cache retirement invalidates the selected content/catalog observation batch before moving bytes. A retention error leaves unmoved files in place but does not reactivate those observations or delayed publishers. Pinned content and recovery state remain usable; see the [retention contract](docs/protocol.md#environment-and-local-storage).
22
-
23
- ## Network and local access
24
-
25
- 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.
26
-
27
- Local access covers configuration, retained state, disposable cache, explicitly selected ZIP/folder/Markdown or write inputs, requested outputs and registered logical sync directories with their resolved destinations. Explicit create/import/write and sync push 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).
28
-
29
- ## Content and mutation boundaries
30
-
31
- Archives reject root escapes, duplicate entries, links and special files, with compressed/expanded limits. ZIPs expand in memory and verify checksums. Files preserves extra metadata, nested paths and binary bytes in a source ZIP without executing them. References mode reads the inclusion list of page mentions/links and rewrites only links to included pages; code examples and external URLs remain unchanged. Without Files, main/reference Markdown is normalized. Create rejects existing names; import replaces differing same-name content on the existing page and excludes omitted reference pages without deleting them. 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.
32
-
33
- Pinned write refs are checked against the current authentication scope, page identity and complete version, including all referenced-page content. 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.
34
-
35
- Publications freeze original input bytes in retained content objects and persist state-relative `publications/<operation_id>.json` receipts before remote mutation. `resume` reauthenticates, validates the source and compares recorded remote observations before continuing on fixed page IDs; external edits conflict and unproven creation is not replayed. Receipts contain private content and mutation evidence and survive cache retirement and CLI upgrades. `--progress` emits only controlled stage/timing fields on stderr; protect the state root as private data. These client guards do not create a remote transaction or remove the check-to-write race.
36
-
37
- `sync local plan/apply` always validate online; read TTL cannot authorize a write. Saved plans retain binding, version, baseline, content and link preconditions. Unknown/partial outcomes retain receipts and fence overlapping resources; `operation reconcile OPERATION_ID` observes them without replay and does not itself close a pending local-sync receipt or advance its baseline. Further changes require a new reviewed plan. Local links are preserved through real-destination writes, but Node commit guards are not atomic protection against a noncooperating process's link retargeting. Removed/replaced bytes require system Trash; unsupported hosts retain bytes and report the missing capability. [Synchronization contract](docs/protocol.md#synchronization).
38
-
39
- 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.
40
-
41
- Optional official Skills are supplied by this project under `skills/notion`, embedded in the CLI and exposed through a separate exact-ID `builtin` catalog. The publisher/origin fields describe installed package bytes, not a signature, Notion endorsement or ownership of remote pages. Matching names or copied frontmatter cannot make a remote page official. Export preserves differing local customizations by returning OUTPUT_CONFLICT. First `builtin publish` rejects same-name pages; updates require an explicitly selected page identity/pinned baseline and use the existing version/readback checks. Publication is opt-in and never installs or upgrades host/remote Skills automatically.
42
-
43
- Explicit `builtin install/update` writes central files under `NTN_SKILLS_DATA_HOME` > `$XDG_DATA_HOME/ntn-skills` > `~/.local/share/ntn-skills` and creates per-Skill links in `~/.agents/skills` plus optional explicit Agent roots. Version-2 `.ntn-builtin-install.json` records exact ID, canonical data root/path, package/content version and every exported file's path, bytes and SHA-256. Separate distribution records establish ownership of links. Neither record is a signature or remote provenance. Replacement checks complete content and registered targets; modified trees, foreign links and unowned directories are preserved. Clean legacy profile installations migrate only when their root is explicitly selected and their complete receipt-v1 baseline matches; retained bytes go through system Trash. The shared installation is local data, separate from Notion credential isolation.
44
-
45
- Installation locks, staging, previous trees and interrupted transaction records remain outside `skills`; preserve them for recovery. Registered modified Skills remain discoverable as user bytes while updates refuse replacement. Locks coordinate cooperating processes and identity/hash guards detect observed drift, but Node filesystem operations cannot atomically guard every pathname against a noncooperating writer between a check and syscall. Central replacement and multi-directory distribution are not one atomic transaction. If Trash succeeds but its completion record is lost, recovery preserves the fence rather than guessing success. [Concurrency and recovery limits](docs/protocol.md#official-built-in-skills).
17
+ ## Reporting a Vulnerability
46
18
 
19
+ Please **do not** open public issues for suspected security vulnerabilities or credential exposure bugs. Instead, report privately via [GitHub Private Vulnerability Reporting](https://github.com/yoyooyooo/ntn-skills/security/advisories/new) with reproduction steps and affected versions. We aim to acknowledge reports within 72 hours.