ntn-skills 2.3.0 → 2.4.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.md +23 -2
- package/README.zh-CN.md +23 -2
- package/assets/ntn-skills/SKILL.md +6 -2
- package/dist/bin.js +224 -7
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -158,11 +158,31 @@ Created automatically by `ntn-skills init --root <blank-page-url>`:
|
|
|
158
158
|
| Table | Purpose | Key Properties |
|
|
159
159
|
| :--- | :--- | :--- |
|
|
160
160
|
| **`Sources`** | Upstream & private Git skill repositories | `Name`, `Repo URL`, `Ref`, `Pinned Commit`, `Policy` (`track \| pinned \| manual`), `Enabled`, `Last Checked`, `Skills` |
|
|
161
|
-
| **`Skills`** | Master catalog, 3-tier routing & `SKILL.md` body | `Name
|
|
161
|
+
| **`Skills`** | Master catalog, 3-tier routing, zero-fork customization & `SKILL.md` body | `Name` (lowercase `a-b-c` slug), `Description`, `Enabled`, `Visibility` (`always \| discoverable \| manual`), `Kind` (`skill \| router \| prompt`), `Profiles`, `Scenes`, `Requires`, `Origin`, `Source Path`, `Custom Main`, `Custom Description`, `Local Patch`, `Status` (`active \| draft \| retired`), `Revision`, `Preview Hash`, `Supporting Files` |
|
|
162
162
|
| **`Files`** | Draft supporting files & upstream diff overlays | `Name`, `Skill`, `Path`, `Status` (`override \| delete`), `Executable`, `SHA256`, `External URL`, `Attachment` |
|
|
163
163
|
|
|
164
164
|
> **Subtree-Hash Pruning & Zero Redundancy**: Unmodified upstream skills store **0 rows** in `Files` (an auto-maintained read-only `Upstream Files` child page at row 1 of each Skill page shows the upstream file tree). When a multi-skill upstream repo gets a new commit, untouched sibling skills incur **0 Notion writes** and keep a stable `effectiveRev`.
|
|
165
165
|
|
|
166
|
+
### How Notion Fields & Local `config.json` Work Together
|
|
167
|
+
|
|
168
|
+
Notion owns **logical intent**, while each machine's `~/.config/ntn-skills/config.json` owns **physical host mounts**:
|
|
169
|
+
|
|
170
|
+
1. **`Visibility` × `Profiles` × `Scenes` (Three Orthogonal Axes)**
|
|
171
|
+
- **`Visibility` (Context budget)**: `always` exports directly into default agent skill folders; `discoverable` pre-materializes under `by-name/` behind an $O(1)$ constant-size index (`skill-catalog` or `skill_find`); `manual` stays indexed only until explicitly loaded via `$skill` or `load`.
|
|
172
|
+
- **`Profiles` (Where a skill lands — machine, agent, or org boundary)**: Intersects `Skills.Profiles` (empty defaults to `["default"]`) with top-level `config.profiles` and per-target `exports[i].profiles`.
|
|
173
|
+
- *Machine-bound skills*: Tag desktop-only tools (e.g. `ego-browser`) with `["pro"]` and include `"pro"` only in that machine's `config.json`—headless workers never see them.
|
|
174
|
+
- *Agent-specific skills*: Export shared skills (`["default"]`) to `~/.agents/skills`, and target host-specific skills (`["claude"]`, `["cursor"]`) via per-directory `exports` rules (`profiles`, `skills`, or `exclude`).
|
|
175
|
+
- *Workspace isolation*: Isolate work/internal skills under `["company"]` to keep your personal `default` plane clean.
|
|
176
|
+
- **`Scenes` (What task topic it serves)**: Cross-machine topic tags (`coding`, `ops`, `design`, `research`) used strictly for on-demand discovery.
|
|
177
|
+
2. **Zero-Fork Upstream Customization (3 Tiers)**
|
|
178
|
+
- **Tier ① Lock routing boundaries (`Custom Description`)**: Upstream skills often ship overly broad *"MUST USE"* descriptions that collide on a shared plane. Setting `Custom Description = true` (or `ntn-skills set <name> --description "..."`) keeps your tailored routing description intact across `upstream apply` updates while continuing to track upstream `SKILL.md` body changes.
|
|
179
|
+
- **Tier ② Declarative materialization hooks (`Local Patch`)**: Adapt upstream `SKILL.md` content during local materialization without setting `Custom Main = true` (included in `effectiveRev`):
|
|
180
|
+
- `@replace "Cursor" => "your coding agent"`: Replaces prose terms while **automatically skipping fenced code blocks and inline backticks** so real CLI binary names stay intact (use `@replace-all` to include code spans);
|
|
181
|
+
- `@prepend` / `@append`: Inject local credential/proxy rules at the top or workflow notes at the bottom (plain text without `@` directives defaults to `@prepend`).
|
|
182
|
+
- **Tier ③ File overlays & full body takeover (`Files` Overlay / `Custom Main`)**: Use `edit -> push` for supporting-file `override | delete` rows, reserving `Custom Main = true` only when replacing the entire `SKILL.md`.
|
|
183
|
+
3. **Pausing vs. Soft Archiving (`Enabled` vs. `Status = retired`)**
|
|
184
|
+
- Uncheck `Enabled` to pause temporarily; run `ntn-skills rm <name>` (`Enabled = false`, `Visibility = manual`, `Status = retired`) to soft-archive obsolete skills—withdrawing local links across all machines while preserving Notion history (filter Notion views by `Status != retired`).
|
|
185
|
+
|
|
166
186
|
---
|
|
167
187
|
|
|
168
188
|
## CLI Reference
|
|
@@ -209,7 +229,8 @@ ntn-skills abort "$WORKDIR"
|
|
|
209
229
|
ntn-skills new [<dir...>] [--pending] [--exclude <name,...>] [--include-symlinks] [--name <name>] [--visibility always|discoverable|manual | --always | --discoverable | --manual] [--profiles default] [--scenes ops] [--adopt | --no-adopt] [--dry-run] [--json]
|
|
210
230
|
ntn-skills set [<name...>] [--source <source-name>] \
|
|
211
231
|
[--visibility always|discoverable|manual | --always | --discoverable | --manual] \
|
|
212
|
-
[--kind skill|router|prompt] [--enable|--disable] [--add-profile <p>] [--add-scene <s>] [--require <dep>]
|
|
232
|
+
[--kind skill|router|prompt] [--enable|--disable] [--add-profile <p>] [--rm-profile <p>] [--add-scene <s>] [--rm-scene <s>] [--require <dep>] \
|
|
233
|
+
[--description <text> | --reset-description] [--patch <rules> | --clear-patch]
|
|
213
234
|
|
|
214
235
|
# Graduate draft or overlay back to Git, or revert overlays
|
|
215
236
|
ntn-skills pull <name> <git-repo-skill-dir> --clean
|
package/README.zh-CN.md
CHANGED
|
@@ -159,11 +159,31 @@ flowchart LR
|
|
|
159
159
|
| 数据表 | 职责 | 核心字段 |
|
|
160
160
|
| :--- | :--- | :--- |
|
|
161
161
|
| **`Sources`** | 管理外部上游与自有私有 Git 仓库 | `Name`、`Repo URL`、`Ref`、`Pinned Commit`、`Policy` (`track \| pinned \| manual`)、`Enabled`、`Last Checked`、`Skills` |
|
|
162
|
-
| **`Skills`** |
|
|
162
|
+
| **`Skills`** | 技能总目录、三档可见性路由、本地无分叉定制与 `SKILL.md` 正文 | `Name`(规范小写 `a-b-c` slug)、`Description`、`Enabled`、`Visibility` (`always \| discoverable \| manual`)、`Kind` (`skill \| router \| prompt`)、`Profiles`、`Scenes`、`Requires`、`Origin`、`Source Path`、`Custom Main`、`Custom Description`、`Local Patch`、`Status` (`active \| draft \| retired`)、`Revision`、`Preview Hash`、`Supporting Files` |
|
|
163
163
|
| **`Files`** | 自有技能附属文件与上游技能差异补丁 | `Name`、`Skill`、`Path`、`Status` (`override \| delete`)、`Executable`、`SHA256`、`External URL`、`Attachment` |
|
|
164
164
|
|
|
165
165
|
> **子树哈希剪枝与零冗余**:未改动的上游技能在 `Files` 表中占 **0 行**(上游文件清单自动展示在技能页第 1 行的只读子页 `Upstream Files` 中)。当多技能上游仓库有新提交时,未改动的同仓其他技能触发 **0 次 Notion 写入**,本地 `effectiveRev` 保持稳定不重物化。
|
|
166
166
|
|
|
167
|
+
### 字段与本机 `config.json` 协同心智(怎么配不打架、不膨胀)
|
|
168
|
+
|
|
169
|
+
Notion 控制面只声明**「逻辑属性」**,每台机器的 `~/.config/ntn-skills/config.json` 只声明**「本机物理挂载」**,二者通过正交组合覆盖多机器、多宿主与外部上游共存场景:
|
|
170
|
+
|
|
171
|
+
1. **`Visibility` × `Profiles` × `Scenes` 三维分工(切忌混用)**
|
|
172
|
+
- **`Visibility`(何时占用上下文)**:`always` 直接挂入宿主默认目录(每轮对话可见,建议精选高频底座);`discoverable` 本地预物化到 `by-name/`,日常仅占 `skill-catalog` 或 `skill_find` 的 $O(1)$ 常数索引,绝不随库规模膨胀;`manual` 仅留索引,显式 `$skill` 或 `load` 时才拉取。
|
|
173
|
+
- **`Profiles`(投递给哪台机器 / 哪个宿主 / 哪个组织边界)**:`Skills.Profiles` 多选标签(空值视为 `["default"]`)与本机 `config.json` 的顶层 `profiles` 及单个 `exports[i].profiles` 取交集。
|
|
174
|
+
- *跟机器走*:例如桌面浏览器 `ego-browser` 仅安装在主力机 `pro`,将其 `Profiles` 设为 `["pro"]`,仅在 `pro` 的 `config.json` 声明 `"profiles": ["default", "pro"]`,纯 Worker 机器则完全看不见它。
|
|
175
|
+
- *跟宿主走*:公共目录 `~/.agents/skills` 放 `["default"]` 公约数;特定 Coding Agent 独享技能(如 `claude`、`cursor`)通过对应私有导出目录(如 `~/.claude/skills`)的 `profiles` / `skills` / `exclude` 精准投递。
|
|
176
|
+
- *公私隔离*:公司内部部署/监控技能设为 `["company"]`,与个人日常 `default` 平面天然隔离。
|
|
177
|
+
- **`Scenes`(做什么任务时被检索)**:如 `coding`、`ops`、`design`、`research`,跨机器通用,专供 Agent 按任务主题检索 `discoverable` / `manual` 技能。
|
|
178
|
+
2. **外部上游技能「无分叉定制」三阶梯(既持续跟进上游更新,又在同一平面守规矩)**
|
|
179
|
+
- **阶梯 ① 锁选路边界(`Custom Description`)**:第三方上游常在 `description` 中写满 `MUST USE` 抢夺调用权。勾选 `Custom Description`(或运行 `ntn-skills set <name> --description "..."`)后,`upstream apply` 在自动拉取上游最新 `SKILL.md` 正文与脚本时**绝不覆盖你的本地 `Description`**。
|
|
180
|
+
- **阶梯 ② 轻量物化钩子(`Local Patch`)**:无需勾选 `Custom Main` 硬分叉全文,直接在 Notion 的 `Local Patch` 文本列(或 `--patch`)填写声明式物化指令,每次本地合成 `SKILL.md` 时自动套用(纳入 `effectiveRev`):
|
|
181
|
+
- `@replace "Cursor" => "your coding agent"`:替换说明文本中的宿主绑定词(**默认自动跳过代码块与行内反引号命令**,防止误伤真实 CLI 命令名;需连同代码块替换时用 `@replace-all`);
|
|
182
|
+
- `@prepend` / `@append`:在正文顶部置入本机凭据/代理红线,或在底部追加联动说明(未写 `@` 指令的纯文本默认按 `@prepend` 置顶)。
|
|
183
|
+
- **阶梯 ③ 文件级覆盖与全文接管(`Files` Overlay / `Custom Main`)**:需替换/屏蔽附属脚本时走 `edit -> push` 写入 `Files` 表 `override | delete`;仅当需彻底重写整篇 `SKILL.md` 时才启用 `Custom Main = true`。
|
|
184
|
+
3. **停用与软归档(`Enabled` vs `Status = retired`)**
|
|
185
|
+
- 临时调试停用仅取消勾选 `Enabled`;早期不再使用的历史技能运行 `ntn-skills rm <name>`(自动置 `Enabled = false`、`Visibility = manual`、`Status = retired` 并撤回全机软链),Notion 页面完整保留备查,网页主视图过滤 `Status != retired` 即可保持清爽。
|
|
186
|
+
|
|
167
187
|
---
|
|
168
188
|
|
|
169
189
|
## 命令速查
|
|
@@ -210,7 +230,8 @@ ntn-skills abort "$WORKDIR"
|
|
|
210
230
|
ntn-skills new [<dir...>] [--pending] [--exclude <name,...>] [--include-symlinks] [--name <name>] [--visibility always|discoverable|manual | --always | --discoverable | --manual] [--profiles default] [--scenes ops] [--adopt | --no-adopt] [--dry-run] [--json]
|
|
211
231
|
ntn-skills set [<name...>] [--source <source-name>] \
|
|
212
232
|
[--visibility always|discoverable|manual | --always | --discoverable | --manual] \
|
|
213
|
-
[--kind skill|router|prompt] [--enable|--disable] [--add-profile <p>] [--add-scene <s>] [--require <dep>]
|
|
233
|
+
[--kind skill|router|prompt] [--enable|--disable] [--add-profile <p>] [--rm-profile <p>] [--add-scene <s>] [--rm-scene <s>] [--require <dep>] \
|
|
234
|
+
[--description <text> | --reset-description] [--patch <rules> | --clear-patch]
|
|
214
235
|
|
|
215
236
|
# 导出干净源码入仓、草稿毕业挂源、解绑、回退补丁与软退役
|
|
216
237
|
ntn-skills pull <name> <git-repo-skill-dir> --clean
|
|
@@ -123,7 +123,9 @@ ntn-skills set [<name...>] [--source <source-name-or-id>] \
|
|
|
123
123
|
[--enable | --disable] \
|
|
124
124
|
[--add-profile <p>] [--rm-profile <p>] \
|
|
125
125
|
[--add-scene <s>] [--rm-scene <s>] \
|
|
126
|
-
[--require <dep1,dep2>]
|
|
126
|
+
[--require <dep1,dep2>] \
|
|
127
|
+
[--description <text> | --reset-description] \
|
|
128
|
+
[--patch <rules> | --clear-patch] </dev/null
|
|
127
129
|
|
|
128
130
|
# 将当前合成后的干净技能源码树(不含 .ntn-skill.json 元数据,自动清理已被删除/改名的旧文件)导出到指定 Git 仓库目录
|
|
129
131
|
ntn-skills pull <name> <git-repo-skill-dir> --clean </dev/null
|
|
@@ -146,7 +148,9 @@ ntn-skills rm <name> </dev/null
|
|
|
146
148
|
|
|
147
149
|
### 4.2 三层演进工作流(草稿孵化 -> Overlay 在线调优 -> 沉淀入自有 Git 仓)
|
|
148
150
|
- **阶段 ① 孵化草稿**:临时想法无需建 Git 分支,直接 `ntn-skills new <dir>` 放入 Notion 缓冲池,通过 `edit -> push` 跨机器快速迭代试跑。
|
|
149
|
-
- **阶段 ②
|
|
151
|
+
- **阶段 ② 在线打补丁调优(无分叉定制 + Overlay)**:
|
|
152
|
+
- **无分叉上游矫正(首选,保持 `Custom Main = false` 持续自动跟进上游正文更新)**:用 `ntn-skills set <name> --description "..."` 开启 `Custom Description` 锁死本地选路触发边界(不被 `upstream apply` 覆盖);用 `--patch`(或 Notion `Local Patch` 列)声明物化规则:`@replace "from" => "to"`(默认自动跳过代码块与行内反引号命令,全局替换用 `@replace-all`)、`@prepend`(置顶本机红线)、`@append`(追加联动说明)。
|
|
153
|
+
- **文件级覆盖 / 全文接管**:对附属脚本跑 `edit -> 修改/新增/删除 -> push`(写入 `Files` 表 `override | delete`);仅当需整篇接管 `SKILL.md` 时修改主文置 `Custom Main = true`,不理想用 `reset-overlay` 秒退。
|
|
150
154
|
- **阶段 ③ 定稿沉淀入 Git 仓**:
|
|
151
155
|
1. 执行 `ntn-skills pull <name> <repo/skills/name> --clean </dev/null` 导出干净源码树到私有 Git 仓库,审查 `git diff` 后 `commit & push`;
|
|
152
156
|
2. 若原为纯 Notion 草稿:执行 `ntn-skills attach <name> --source <my-repo> </dev/null` 完成无损挂源并清空冗余 `Files` 行;
|
package/dist/bin.js
CHANGED
|
@@ -59,6 +59,8 @@ var SkillRecordSchema = Schema.Struct({
|
|
|
59
59
|
originSourceId: Schema.NullOr(Schema.String),
|
|
60
60
|
sourcePath: Schema.String,
|
|
61
61
|
customMain: Schema.Boolean,
|
|
62
|
+
customDescription: Schema.optional(Schema.Boolean),
|
|
63
|
+
localPatch: Schema.optional(Schema.String),
|
|
62
64
|
revision: Schema.String,
|
|
63
65
|
previewHash: Schema.String,
|
|
64
66
|
kind: Schema.Literals(["skill", "router", "prompt"]),
|
|
@@ -159,6 +161,8 @@ var CatalogEntrySchema = Schema.Struct({
|
|
|
159
161
|
originPinnedCommit: Schema.NullOr(Schema.String),
|
|
160
162
|
sourcePath: Schema.String,
|
|
161
163
|
customMain: Schema.Boolean,
|
|
164
|
+
customDescription: Schema.optional(Schema.Boolean),
|
|
165
|
+
localPatch: Schema.optional(Schema.String),
|
|
162
166
|
revision: Schema.String,
|
|
163
167
|
previewHash: Schema.String,
|
|
164
168
|
effectiveRev: Schema.String,
|
|
@@ -365,7 +369,107 @@ function parseSkillFrontmatter(markdown) {
|
|
|
365
369
|
hasFrontmatter: true
|
|
366
370
|
};
|
|
367
371
|
}
|
|
368
|
-
function
|
|
372
|
+
function parseReplaceSpec(spec) {
|
|
373
|
+
const quotedMatch = spec.match(/^(?:"((?:\\.|[^"\\])*)"|'((?:''|[^'])*)')\s*=>\s*(?:"((?:\\.|[^"\\])*)"|'((?:''|[^'])*)')$/);
|
|
374
|
+
if (quotedMatch) {
|
|
375
|
+
const from = quotedMatch[1] !== undefined ? unquoteYamlScalar(`"${quotedMatch[1]}"`) : unquoteYamlScalar(`'${quotedMatch[2] ?? ""}'`);
|
|
376
|
+
const to = quotedMatch[3] !== undefined ? unquoteYamlScalar(`"${quotedMatch[3]}"`) : unquoteYamlScalar(`'${quotedMatch[4] ?? ""}'`);
|
|
377
|
+
return from.length > 0 ? { from, to } : null;
|
|
378
|
+
}
|
|
379
|
+
const arrowIdx = spec.indexOf("=>");
|
|
380
|
+
if (arrowIdx <= 0)
|
|
381
|
+
return null;
|
|
382
|
+
const from = unquoteYamlScalar(spec.slice(0, arrowIdx).trim());
|
|
383
|
+
const to = unquoteYamlScalar(spec.slice(arrowIdx + 2).trim());
|
|
384
|
+
return from.length > 0 ? { from, to } : null;
|
|
385
|
+
}
|
|
386
|
+
function parseLocalPatch(rawPatch) {
|
|
387
|
+
const normalized = (rawPatch ?? "").replace(/\r\n/g, `
|
|
388
|
+
`).trim();
|
|
389
|
+
if (!normalized)
|
|
390
|
+
return { replaces: [], prepends: [], appends: [] };
|
|
391
|
+
const replaces = [];
|
|
392
|
+
const prepends = [];
|
|
393
|
+
const appends = [];
|
|
394
|
+
let section = "prepend";
|
|
395
|
+
let buffer = [];
|
|
396
|
+
const flushBuffer = () => {
|
|
397
|
+
const text = buffer.join(`
|
|
398
|
+
`).trim();
|
|
399
|
+
if (text.length > 0) {
|
|
400
|
+
if (section === "prepend")
|
|
401
|
+
prepends.push(text);
|
|
402
|
+
else
|
|
403
|
+
appends.push(text);
|
|
404
|
+
}
|
|
405
|
+
buffer = [];
|
|
406
|
+
};
|
|
407
|
+
for (const line of normalized.split(`
|
|
408
|
+
`)) {
|
|
409
|
+
const trimmed = line.trim();
|
|
410
|
+
if (buffer.length === 0 && trimmed.startsWith("//"))
|
|
411
|
+
continue;
|
|
412
|
+
if (/^@prepend\s*$/i.test(trimmed)) {
|
|
413
|
+
flushBuffer();
|
|
414
|
+
section = "prepend";
|
|
415
|
+
continue;
|
|
416
|
+
}
|
|
417
|
+
if (/^@append\s*$/i.test(trimmed)) {
|
|
418
|
+
flushBuffer();
|
|
419
|
+
section = "append";
|
|
420
|
+
continue;
|
|
421
|
+
}
|
|
422
|
+
const repAll = trimmed.match(/^@replace-all\s+(.+)$/i);
|
|
423
|
+
if (repAll) {
|
|
424
|
+
flushBuffer();
|
|
425
|
+
const parsed = parseReplaceSpec(repAll[1].trim());
|
|
426
|
+
if (parsed)
|
|
427
|
+
replaces.push({ ...parsed, codeSafe: false });
|
|
428
|
+
continue;
|
|
429
|
+
}
|
|
430
|
+
const repSafe = trimmed.match(/^@replace\s+(.+)$/i);
|
|
431
|
+
if (repSafe) {
|
|
432
|
+
flushBuffer();
|
|
433
|
+
const parsed = parseReplaceSpec(repSafe[1].trim());
|
|
434
|
+
if (parsed)
|
|
435
|
+
replaces.push({ ...parsed, codeSafe: true });
|
|
436
|
+
continue;
|
|
437
|
+
}
|
|
438
|
+
buffer.push(line);
|
|
439
|
+
}
|
|
440
|
+
flushBuffer();
|
|
441
|
+
return { replaces, prepends, appends };
|
|
442
|
+
}
|
|
443
|
+
function replaceOutsideCodeSpans(text, from, to) {
|
|
444
|
+
const parts = text.split(/(```[\s\S]*?```|`[^`\n]+`)/g);
|
|
445
|
+
return parts.map((part, idx) => idx % 2 === 0 ? part.split(from).join(to) : part).join("");
|
|
446
|
+
}
|
|
447
|
+
function applyLocalPatch(markdownBody, rawPatch) {
|
|
448
|
+
const parsed = parseLocalPatch(rawPatch);
|
|
449
|
+
if (parsed.replaces.length === 0 && parsed.prepends.length === 0 && parsed.appends.length === 0) {
|
|
450
|
+
return markdownBody;
|
|
451
|
+
}
|
|
452
|
+
let out = markdownBody;
|
|
453
|
+
for (const r of parsed.replaces) {
|
|
454
|
+
out = r.codeSafe ? replaceOutsideCodeSpans(out, r.from, r.to) : out.split(r.from).join(r.to);
|
|
455
|
+
}
|
|
456
|
+
const blocks = [];
|
|
457
|
+
if (parsed.prepends.length > 0)
|
|
458
|
+
blocks.push(parsed.prepends.join(`
|
|
459
|
+
|
|
460
|
+
`));
|
|
461
|
+
const cleanCore = out.replace(/^\n+/, "").replace(/\s+$/, "");
|
|
462
|
+
if (cleanCore.length > 0)
|
|
463
|
+
blocks.push(cleanCore);
|
|
464
|
+
if (parsed.appends.length > 0)
|
|
465
|
+
blocks.push(parsed.appends.join(`
|
|
466
|
+
|
|
467
|
+
`));
|
|
468
|
+
return blocks.join(`
|
|
469
|
+
|
|
470
|
+
`);
|
|
471
|
+
}
|
|
472
|
+
function applyAuthoritativeFrontmatter(rawMarkdown, authoritativeName, authoritativeDescription, requiresPaths, localPatch) {
|
|
369
473
|
const parsed = parseSkillFrontmatter(rawMarkdown);
|
|
370
474
|
const canonicalName = normalizeSkillSlug(authoritativeName) || authoritativeName.trim();
|
|
371
475
|
const headerLines = [
|
|
@@ -379,7 +483,8 @@ function applyAuthoritativeFrontmatter(rawMarkdown, authoritativeName, authorita
|
|
|
379
483
|
const reqLine = reqPairs.length > 0 ? `
|
|
380
484
|
Requires: ${reqPairs.join(", ")}
|
|
381
485
|
` : "";
|
|
382
|
-
const
|
|
486
|
+
const patchedBody = applyLocalPatch(parsed.body, localPatch);
|
|
487
|
+
const cleanBody = patchedBody.replace(/^\n+/, "").replace(/\s+$/, "");
|
|
383
488
|
return cleanBody.length > 0 ? `${headerLines.join(`
|
|
384
489
|
`)}${reqLine}
|
|
385
490
|
${cleanBody}
|
|
@@ -390,6 +495,7 @@ ${cleanBody}
|
|
|
390
495
|
function computeEffectiveRev(input) {
|
|
391
496
|
const sortedOverlays = [...input.overlays].sort((a, b) => a.path.localeCompare(b.path));
|
|
392
497
|
const sortedRequires = [...input.requiresRevs].sort((a, b) => a.skillId.localeCompare(b.skillId));
|
|
498
|
+
const trimmedPatch = (input.localPatch ?? "").trim();
|
|
393
499
|
const canonical = JSON.stringify({
|
|
394
500
|
v: 2,
|
|
395
501
|
commit: input.originPinnedCommit ?? null,
|
|
@@ -397,6 +503,7 @@ function computeEffectiveRev(input) {
|
|
|
397
503
|
customMain: input.customMain,
|
|
398
504
|
name: input.name,
|
|
399
505
|
description: input.description,
|
|
506
|
+
...trimmedPatch ? { localPatch: trimmedPatch } : {},
|
|
400
507
|
main: input.mainContentIdentity,
|
|
401
508
|
overlays: sortedOverlays,
|
|
402
509
|
requires: sortedRequires
|
|
@@ -2748,6 +2855,8 @@ function decodeSkillPage(page) {
|
|
|
2748
2855
|
originSourceId: origins[0] ?? null,
|
|
2749
2856
|
sourcePath,
|
|
2750
2857
|
customMain: propCheckbox(p["Custom Main"]),
|
|
2858
|
+
customDescription: propCheckbox(p["Custom Description"]),
|
|
2859
|
+
localPatch: propPlain(p["Local Patch"]).trim(),
|
|
2751
2860
|
revision: propPlain(p.Revision).trim(),
|
|
2752
2861
|
previewHash: propPlain(p["Preview Hash"]).trim(),
|
|
2753
2862
|
kind,
|
|
@@ -2936,6 +3045,8 @@ function makeNotionServiceFromTransport(transport) {
|
|
|
2936
3045
|
},
|
|
2937
3046
|
"Source Path": { rich_text: {} },
|
|
2938
3047
|
"Custom Main": { checkbox: {} },
|
|
3048
|
+
"Custom Description": { checkbox: {} },
|
|
3049
|
+
"Local Patch": { rich_text: {} },
|
|
2939
3050
|
Revision: { rich_text: {} },
|
|
2940
3051
|
"Preview Hash": { rich_text: {} },
|
|
2941
3052
|
Kind: {
|
|
@@ -2977,6 +3088,22 @@ function makeNotionServiceFromTransport(transport) {
|
|
|
2977
3088
|
}
|
|
2978
3089
|
}
|
|
2979
3090
|
});
|
|
3091
|
+
} else {
|
|
3092
|
+
const existingSkillsDs = await transport.requestJson("GET", `/v1/data_sources/${found.skills}`).catch(() => null);
|
|
3093
|
+
if (existingSkillsDs?.properties) {
|
|
3094
|
+
const missingProps = {};
|
|
3095
|
+
if (!existingSkillsDs.properties["Custom Description"]) {
|
|
3096
|
+
missingProps["Custom Description"] = { checkbox: {} };
|
|
3097
|
+
}
|
|
3098
|
+
if (!existingSkillsDs.properties["Local Patch"]) {
|
|
3099
|
+
missingProps["Local Patch"] = { rich_text: {} };
|
|
3100
|
+
}
|
|
3101
|
+
if (Object.keys(missingProps).length > 0) {
|
|
3102
|
+
await transport.requestJson("PATCH", `/v1/data_sources/${found.skills}`, {
|
|
3103
|
+
properties: missingProps
|
|
3104
|
+
});
|
|
3105
|
+
}
|
|
3106
|
+
}
|
|
2980
3107
|
}
|
|
2981
3108
|
if (!found.files) {
|
|
2982
3109
|
const created = await createChildDb("Files", {
|
|
@@ -3248,6 +3375,14 @@ function makeNotionServiceFromTransport(transport) {
|
|
|
3248
3375
|
}
|
|
3249
3376
|
if (input.customMain !== undefined)
|
|
3250
3377
|
props["Custom Main"] = { checkbox: input.customMain };
|
|
3378
|
+
if (input.customDescription !== undefined) {
|
|
3379
|
+
props["Custom Description"] = { checkbox: input.customDescription };
|
|
3380
|
+
}
|
|
3381
|
+
if (input.localPatch !== undefined) {
|
|
3382
|
+
props["Local Patch"] = {
|
|
3383
|
+
rich_text: input.localPatch ? [{ type: "text", text: { content: input.localPatch.slice(0, 1950) } }] : []
|
|
3384
|
+
};
|
|
3385
|
+
}
|
|
3251
3386
|
if (input.revision !== undefined) {
|
|
3252
3387
|
props.Revision = {
|
|
3253
3388
|
rich_text: input.revision ? [{ type: "text", text: { content: input.revision } }] : []
|
|
@@ -3287,6 +3422,14 @@ function makeNotionServiceFromTransport(transport) {
|
|
|
3287
3422
|
},
|
|
3288
3423
|
"Source Path": { rich_text: rtPath },
|
|
3289
3424
|
"Custom Main": { checkbox: input.customMain },
|
|
3425
|
+
...input.customDescription !== undefined ? { "Custom Description": { checkbox: input.customDescription } } : {},
|
|
3426
|
+
...input.localPatch ? {
|
|
3427
|
+
"Local Patch": {
|
|
3428
|
+
rich_text: [
|
|
3429
|
+
{ type: "text", text: { content: input.localPatch.slice(0, 1950) } }
|
|
3430
|
+
]
|
|
3431
|
+
}
|
|
3432
|
+
} : {},
|
|
3290
3433
|
Revision: {
|
|
3291
3434
|
rich_text: input.revision ? [{ type: "text", text: { content: input.revision } }] : []
|
|
3292
3435
|
},
|
|
@@ -4750,7 +4893,7 @@ function materializeOneSkill(args) {
|
|
|
4750
4893
|
};
|
|
4751
4894
|
}
|
|
4752
4895
|
}
|
|
4753
|
-
const authoritativeSkillMd = applyAuthoritativeFrontmatter(rawMainMarkdown, args.skill.name, args.skill.description, args.requiresPaths);
|
|
4896
|
+
const authoritativeSkillMd = applyAuthoritativeFrontmatter(rawMainMarkdown, args.skill.name, args.skill.description, args.requiresPaths, args.skill.localPatch);
|
|
4754
4897
|
fileMap.set("SKILL.md", {
|
|
4755
4898
|
path: "SKILL.md",
|
|
4756
4899
|
bytes: new TextEncoder().encode(authoritativeSkillMd),
|
|
@@ -5111,9 +5254,23 @@ function publishExportTarget(args) {
|
|
|
5111
5254
|
}
|
|
5112
5255
|
publishableEntries.set(skillName, entry);
|
|
5113
5256
|
}
|
|
5257
|
+
const existingCaseMap = new Map;
|
|
5258
|
+
for (const ex of await fsp5.readdir(destRoot).catch(() => [])) {
|
|
5259
|
+
existingCaseMap.set(ex.toLowerCase(), ex);
|
|
5260
|
+
}
|
|
5114
5261
|
for (const [skillName, entry] of publishableEntries) {
|
|
5115
5262
|
const storePath = entry.materializedPath;
|
|
5116
5263
|
const destPath = nodePath5.join(destRoot, skillName);
|
|
5264
|
+
const prevCased = existingCaseMap.get(skillName.toLowerCase());
|
|
5265
|
+
if (prevCased && prevCased !== skillName) {
|
|
5266
|
+
const prevFull = nodePath5.join(destRoot, prevCased);
|
|
5267
|
+
const prevLst = await fsp5.lstat(prevFull).catch(() => null);
|
|
5268
|
+
if (prevLst?.isSymbolicLink()) {
|
|
5269
|
+
await fsp5.unlink(prevFull).catch(() => {
|
|
5270
|
+
return;
|
|
5271
|
+
});
|
|
5272
|
+
}
|
|
5273
|
+
}
|
|
5117
5274
|
if (args.target.mode === "symlink") {
|
|
5118
5275
|
const lst = await fsp5.lstat(destPath).catch(() => null);
|
|
5119
5276
|
if (lst?.isSymbolicLink()) {
|
|
@@ -5685,6 +5842,7 @@ function syncCommand(options = {}) {
|
|
|
5685
5842
|
customMain: sk.customMain,
|
|
5686
5843
|
name: sk.name,
|
|
5687
5844
|
description: sk.description,
|
|
5845
|
+
...sk.localPatch ? { localPatch: sk.localPatch } : {},
|
|
5688
5846
|
mainContentIdentity: mainIdentity,
|
|
5689
5847
|
overlays,
|
|
5690
5848
|
requiresRevs: reqRevs
|
|
@@ -5832,6 +5990,8 @@ function syncCommand(options = {}) {
|
|
|
5832
5990
|
originPinnedCommit: src ? src.pinnedCommit || (resolvedCommits.get(src.id) ?? null) : null,
|
|
5833
5991
|
sourcePath: sk.sourcePath,
|
|
5834
5992
|
customMain: sk.customMain,
|
|
5993
|
+
customDescription: Boolean(sk.customDescription),
|
|
5994
|
+
localPatch: sk.localPatch ?? "",
|
|
5835
5995
|
revision: sk.revision,
|
|
5836
5996
|
previewHash: sk.previewHash,
|
|
5837
5997
|
effectiveRev: rev,
|
|
@@ -6397,6 +6557,7 @@ function loadSkillCommand(args) {
|
|
|
6397
6557
|
customMain: sk.customMain,
|
|
6398
6558
|
name: sk.name,
|
|
6399
6559
|
description: sk.description,
|
|
6560
|
+
...sk.localPatch ? { localPatch: sk.localPatch } : {},
|
|
6400
6561
|
mainContentIdentity: mainId,
|
|
6401
6562
|
overlays,
|
|
6402
6563
|
requiresRevs: []
|
|
@@ -6526,6 +6687,7 @@ function materializeSkillOutsideCatalog(args) {
|
|
|
6526
6687
|
customMain: sk.customMain,
|
|
6527
6688
|
name: sk.name,
|
|
6528
6689
|
description: sk.description,
|
|
6690
|
+
...sk.localPatch ? { localPatch: sk.localPatch } : {},
|
|
6529
6691
|
mainContentIdentity: mainIdentity,
|
|
6530
6692
|
overlays: overlayFiles.map((ov) => ({
|
|
6531
6693
|
path: ov.path,
|
|
@@ -6989,9 +7151,11 @@ function statusCommand(args) {
|
|
|
6989
7151
|
const entryByName = new Map(entries.map((e) => [e.name.toLowerCase(), e]));
|
|
6990
7152
|
const activeSources = libState ? Object.values(libState.sources).filter((s) => s.enabled).length : 0;
|
|
6991
7153
|
const draftEntries = entries.filter((e) => !e.originSourceId).sort((a, b) => b.lastEditedTime.localeCompare(a.lastEditedTime));
|
|
6992
|
-
const activeOverlays = entries.filter((e) => Boolean(e.originSourceId) && (e.customMain || e.overlays.length > 0)).map((e) => ({
|
|
7154
|
+
const activeOverlays = entries.filter((e) => Boolean(e.originSourceId) && (e.customMain || Boolean(e.customDescription) || Boolean(e.localPatch?.trim()) || e.overlays.length > 0)).map((e) => ({
|
|
6993
7155
|
name: e.name,
|
|
6994
7156
|
customMain: e.customMain,
|
|
7157
|
+
customDescription: Boolean(e.customDescription),
|
|
7158
|
+
hasLocalPatch: Boolean(e.localPatch?.trim()),
|
|
6995
7159
|
overrides: e.overlays.filter((o) => o.status === "override").length,
|
|
6996
7160
|
deletes: e.overlays.filter((o) => o.status === "delete").length,
|
|
6997
7161
|
warnings: e.warnings
|
|
@@ -7944,7 +8108,18 @@ function createNewSkillCommand(args) {
|
|
|
7944
8108
|
function setSkillMetaCommand(args) {
|
|
7945
8109
|
return Effect6.gen(function* () {
|
|
7946
8110
|
const notion = yield* NotionPort;
|
|
8111
|
+
const upstream = yield* UpstreamPort;
|
|
7947
8112
|
const { libraryId, libState } = yield* loadSyncedLibrary(args.libraryId);
|
|
8113
|
+
if (args.description !== undefined && args.resetDescription) {
|
|
8114
|
+
return yield* Effect6.fail(new ConfigError({
|
|
8115
|
+
message: "Cannot combine --description with --reset-description."
|
|
8116
|
+
}));
|
|
8117
|
+
}
|
|
8118
|
+
if (args.localPatch !== undefined && args.clearPatch) {
|
|
8119
|
+
return yield* Effect6.fail(new ConfigError({
|
|
8120
|
+
message: "Cannot combine --patch with --clear-patch."
|
|
8121
|
+
}));
|
|
8122
|
+
}
|
|
7948
8123
|
const requestedNames = [...args.name ? [args.name] : [], ...args.names ?? []].map((n) => n.trim()).filter(Boolean);
|
|
7949
8124
|
if (requestedNames.length === 0 && !args.sourceQuery?.trim()) {
|
|
7950
8125
|
return yield* Effect6.fail(new ConfigError({
|
|
@@ -7994,6 +8169,33 @@ function setSkillMetaCommand(args) {
|
|
|
7994
8169
|
nextScenes.add(s);
|
|
7995
8170
|
for (const s of args.rmScenes ?? [])
|
|
7996
8171
|
nextScenes.delete(s);
|
|
8172
|
+
let nextDescPatch = {};
|
|
8173
|
+
if (args.description !== undefined) {
|
|
8174
|
+
nextDescPatch = { description: args.description, customDescription: true };
|
|
8175
|
+
} else if (args.resetDescription) {
|
|
8176
|
+
let restoredDesc;
|
|
8177
|
+
const src = targetSkill.originSourceId ? libState.sources[targetSkill.originSourceId] : undefined;
|
|
8178
|
+
if (src && !targetSkill.customMain) {
|
|
8179
|
+
const commitSha = src.pinnedCommit || (yield* upstream.resolveHeadCommit(src.repoUrl, src.ref));
|
|
8180
|
+
const subtree = yield* upstream.fetchSubtree({
|
|
8181
|
+
repoUrl: src.repoUrl,
|
|
8182
|
+
commitSha,
|
|
8183
|
+
sourcePath: targetSkill.sourcePath || "."
|
|
8184
|
+
}).pipe(Effect6.catch(() => Effect6.succeed(null)));
|
|
8185
|
+
const upMain = subtree?.find((f) => f.path === "SKILL.md");
|
|
8186
|
+
if (upMain) {
|
|
8187
|
+
const parsedUp = parseSkillFrontmatter(new TextDecoder().decode(upMain.bytes));
|
|
8188
|
+
if (parsedUp.description !== undefined) {
|
|
8189
|
+
restoredDesc = parsedUp.description;
|
|
8190
|
+
}
|
|
8191
|
+
}
|
|
8192
|
+
}
|
|
8193
|
+
nextDescPatch = {
|
|
8194
|
+
customDescription: false,
|
|
8195
|
+
...restoredDesc !== undefined ? { description: restoredDesc } : {}
|
|
8196
|
+
};
|
|
8197
|
+
}
|
|
8198
|
+
const nextLocalPatch = args.localPatch !== undefined ? args.localPatch : args.clearPatch ? "" : undefined;
|
|
7997
8199
|
yield* notion.updateSkillProps({
|
|
7998
8200
|
libraryId,
|
|
7999
8201
|
skillId: targetSkill.id,
|
|
@@ -8003,6 +8205,8 @@ function setSkillMetaCommand(args) {
|
|
|
8003
8205
|
...args.addProfiles?.length || args.rmProfiles?.length ? { profiles: [...nextProfiles] } : {},
|
|
8004
8206
|
...args.addScenes?.length || args.rmScenes?.length ? { scenes: [...nextScenes] } : {},
|
|
8005
8207
|
...nextRequires !== undefined ? { requiresIds: nextRequires } : {},
|
|
8208
|
+
...nextDescPatch,
|
|
8209
|
+
...nextLocalPatch !== undefined ? { localPatch: nextLocalPatch } : {},
|
|
8006
8210
|
revision: makeRevisionStamp(extractSubtreeDigestFromRevision(targetSkill.revision))
|
|
8007
8211
|
});
|
|
8008
8212
|
}), { concurrency: UPSTREAM_SKILL_CONCURRENCY });
|
|
@@ -8869,7 +9073,7 @@ function upstreamCheckOrApplyCommand(args) {
|
|
|
8869
9073
|
}
|
|
8870
9074
|
if (matchesTargetUpstream && rawMainText !== null) {
|
|
8871
9075
|
const parsedMain = parseSkillFrontmatter(rawMainText);
|
|
8872
|
-
if (parsedMain.description !== undefined && parsedMain.description !== sk.description) {
|
|
9076
|
+
if (!sk.customDescription && parsedMain.description !== undefined && parsedMain.description !== sk.description) {
|
|
8873
9077
|
nextDesc = parsedMain.description;
|
|
8874
9078
|
}
|
|
8875
9079
|
nextPreviewHash = sha256Hex(currentBody.rawMarkdown);
|
|
@@ -8878,7 +9082,7 @@ function upstreamCheckOrApplyCommand(args) {
|
|
|
8878
9082
|
}
|
|
8879
9083
|
} else if (rawMainText !== null) {
|
|
8880
9084
|
const parsedMain = parseSkillFrontmatter(rawMainText);
|
|
8881
|
-
if (parsedMain.description !== undefined && parsedMain.description !== sk.description) {
|
|
9085
|
+
if (!sk.customDescription && parsedMain.description !== undefined && parsedMain.description !== sk.description) {
|
|
8882
9086
|
nextDesc = parsedMain.description;
|
|
8883
9087
|
}
|
|
8884
9088
|
yield* notion.writeSkillBody({
|
|
@@ -12097,6 +12301,9 @@ var infoCmd = Command.make("info", {
|
|
|
12097
12301
|
`Scenes: ${exact.scenes.join(", ") || "-"}`,
|
|
12098
12302
|
`Origin: ${exact.originRepoUrl ? `${exact.originRepoUrl} @ ${exact.originPinnedCommit ?? exact.originRef} (${exact.sourcePath || "."})` : "native"}`,
|
|
12099
12303
|
`Custom Main: ${exact.customMain}`,
|
|
12304
|
+
`Custom Desc: ${Boolean(exact.customDescription)}`,
|
|
12305
|
+
`Local Patch: ${exact.localPatch?.trim() ? `active (${exact.localPatch.trim().split(`
|
|
12306
|
+
`).length} line(s))` : "none"}`,
|
|
12100
12307
|
`Overlays: ${exact.overlays.length === 0 ? "none" : exact.overlays.map((o) => `${o.path}[${o.status}]`).join(", ")}`,
|
|
12101
12308
|
`Store Path: ${exact.materializedPath ?? "(not materialized yet)"}`,
|
|
12102
12309
|
...exact.warnings.length > 0 ? [`Warnings: ${exact.warnings.join("; ")}`] : []
|
|
@@ -12469,6 +12676,10 @@ var setCmd = Command.make("set", {
|
|
|
12469
12676
|
addScene: Flag.String("add-scene").pipe(Flag.atLeast(0)),
|
|
12470
12677
|
rmScene: Flag.String("rm-scene").pipe(Flag.atLeast(0)),
|
|
12471
12678
|
require: Flag.String("require").pipe(Flag.atLeast(0)),
|
|
12679
|
+
description: Flag.String("description").pipe(Flag.withDescription("Set authoritative Description and lock Custom Description=true"), Flag.optional),
|
|
12680
|
+
resetDescription: Flag.Boolean("reset-description").pipe(Flag.withDescription("Unlock Custom Description=false and restore upstream description"), Flag.withDefault(false)),
|
|
12681
|
+
patch: Flag.String("patch").pipe(Flag.withDescription("Set Local Patch materialization rules (@replace, @replace-all, @prepend, @append)"), Flag.optional),
|
|
12682
|
+
clearPatch: Flag.Boolean("clear-patch").pipe(Flag.withDescription("Clear Local Patch rules"), Flag.withDefault(false)),
|
|
12472
12683
|
library: libraryFlag,
|
|
12473
12684
|
json: jsonFlag
|
|
12474
12685
|
}, (cfg) => Effect9.gen(function* () {
|
|
@@ -12478,6 +12689,8 @@ var setCmd = Command.make("set", {
|
|
|
12478
12689
|
const enable = cfg.enable ? true : cfg.disable ? false : undefined;
|
|
12479
12690
|
const visibility = visOpt ?? (cfg.always || cfg.default ? "always" : cfg.discoverable || cfg.noDefault ? "discoverable" : cfg.manual ? "manual" : undefined);
|
|
12480
12691
|
const srcOpt = Option2.getOrUndefined(cfg.source);
|
|
12692
|
+
const descOpt = Option2.getOrUndefined(cfg.description);
|
|
12693
|
+
const patchOpt = Option2.getOrUndefined(cfg.patch);
|
|
12481
12694
|
const nameList = splitMulti(cfg.names);
|
|
12482
12695
|
const reqs = splitMulti(cfg.require);
|
|
12483
12696
|
const res = yield* setSkillMetaCommand({
|
|
@@ -12491,10 +12704,14 @@ var setCmd = Command.make("set", {
|
|
|
12491
12704
|
addScenes: splitMulti(cfg.addScene),
|
|
12492
12705
|
rmScenes: splitMulti(cfg.rmScene),
|
|
12493
12706
|
...reqs.length > 0 ? { requireNames: reqs } : {},
|
|
12707
|
+
...descOpt !== undefined ? { description: descOpt } : {},
|
|
12708
|
+
...cfg.resetDescription ? { resetDescription: true } : {},
|
|
12709
|
+
...patchOpt !== undefined ? { localPatch: patchOpt } : {},
|
|
12710
|
+
...cfg.clearPatch ? { clearPatch: true } : {},
|
|
12494
12711
|
...lib ? { libraryId: lib } : {}
|
|
12495
12712
|
});
|
|
12496
12713
|
yield* printOut(cfg.json, res, `Updated metadata for ${res.updatedSkills.length} skill(s): ${res.updatedSkills.join(", ")}`);
|
|
12497
|
-
})).pipe(Command.withDescription("Declaratively update Visibility
|
|
12714
|
+
})).pipe(Command.withDescription("Declaratively update Visibility, Kind, Enabled, Profiles, Scenes, Requires, Custom Description, or Local Patch"));
|
|
12498
12715
|
var attachCmd = Command.make("attach", {
|
|
12499
12716
|
name: Argument.String("name"),
|
|
12500
12717
|
source: Flag.String("source").pipe(Flag.withDescription("Target upstream Git Source name or Notion page UUID")),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ntn-skills",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"ntn-skills": "./dist/bin.js"
|
|
@@ -37,6 +37,6 @@
|
|
|
37
37
|
"bun": ">=1.2.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@ntn-skills/core": "2.
|
|
40
|
+
"@ntn-skills/core": "2.4.0"
|
|
41
41
|
}
|
|
42
42
|
}
|