ntn-skills 2.2.0 → 2.3.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/dist/bin.js +187 -51
- package/package.json +2 -2
package/dist/bin.js
CHANGED
|
@@ -234,8 +234,27 @@ function normalizeUuid(raw) {
|
|
|
234
234
|
function libShortHash(libraryId) {
|
|
235
235
|
return normalizeUuid(libraryId).replace(/-/g, "").slice(0, 8);
|
|
236
236
|
}
|
|
237
|
+
var SKILL_SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
238
|
+
function isValidSkillSlug(raw) {
|
|
239
|
+
return SKILL_SLUG_RE.test(raw);
|
|
240
|
+
}
|
|
237
241
|
function normalizeSkillSlug(raw) {
|
|
238
|
-
return raw.trim().toLowerCase().replace(/[
|
|
242
|
+
return raw.trim().toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
243
|
+
}
|
|
244
|
+
function resolveCanonicalSkillName(preferred, fallback) {
|
|
245
|
+
const pref = (preferred ?? "").trim();
|
|
246
|
+
if (pref && isValidSkillSlug(pref))
|
|
247
|
+
return pref;
|
|
248
|
+
const isAsciiOnly = pref.length > 0 && /^[\x20-\x7E]+$/.test(pref);
|
|
249
|
+
if (isAsciiOnly) {
|
|
250
|
+
const prefSlug = normalizeSkillSlug(pref);
|
|
251
|
+
if (prefSlug)
|
|
252
|
+
return prefSlug;
|
|
253
|
+
}
|
|
254
|
+
const fbSlug = normalizeSkillSlug(fallback ?? "");
|
|
255
|
+
if (fbSlug)
|
|
256
|
+
return fbSlug;
|
|
257
|
+
return normalizeSkillSlug(pref);
|
|
239
258
|
}
|
|
240
259
|
function computeOverlapWindowIso(watermarkIso, overlapMs = 120000) {
|
|
241
260
|
const ms = Date.parse(watermarkIso);
|
|
@@ -346,22 +365,26 @@ function parseSkillFrontmatter(markdown) {
|
|
|
346
365
|
hasFrontmatter: true
|
|
347
366
|
};
|
|
348
367
|
}
|
|
349
|
-
function applyAuthoritativeFrontmatter(rawMarkdown, authoritativeName, authoritativeDescription) {
|
|
368
|
+
function applyAuthoritativeFrontmatter(rawMarkdown, authoritativeName, authoritativeDescription, requiresPaths) {
|
|
350
369
|
const parsed = parseSkillFrontmatter(rawMarkdown);
|
|
370
|
+
const canonicalName = normalizeSkillSlug(authoritativeName) || authoritativeName.trim();
|
|
351
371
|
const headerLines = [
|
|
352
372
|
"---",
|
|
353
|
-
`name: ${JSON.stringify(
|
|
373
|
+
`name: ${JSON.stringify(canonicalName)}`,
|
|
354
374
|
`description: ${JSON.stringify(authoritativeDescription)}`,
|
|
355
375
|
...parsed.extraLines,
|
|
356
376
|
"---"
|
|
357
377
|
];
|
|
378
|
+
const reqPairs = Object.entries(requiresPaths ?? {}).sort(([a], [b]) => a.localeCompare(b)).map(([k, v]) => `${k}=${v}`);
|
|
379
|
+
const reqLine = reqPairs.length > 0 ? `
|
|
380
|
+
Requires: ${reqPairs.join(", ")}
|
|
381
|
+
` : "";
|
|
358
382
|
const cleanBody = parsed.body.replace(/^\n+/, "").replace(/\s+$/, "");
|
|
359
383
|
return cleanBody.length > 0 ? `${headerLines.join(`
|
|
360
|
-
`)}
|
|
361
|
-
|
|
384
|
+
`)}${reqLine}
|
|
362
385
|
${cleanBody}
|
|
363
386
|
` : `${headerLines.join(`
|
|
364
|
-
`)}
|
|
387
|
+
`)}${reqLine}
|
|
365
388
|
`;
|
|
366
389
|
}
|
|
367
390
|
function computeEffectiveRev(input) {
|
|
@@ -677,9 +700,25 @@ function sanitizeSceneSlug(raw) {
|
|
|
677
700
|
const slug = raw.trim().toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
678
701
|
return slug || "general";
|
|
679
702
|
}
|
|
703
|
+
function summarizeCatalogDescription(raw, maxChars = 140) {
|
|
704
|
+
const flat = raw.replace(/\s+/g, " ").trim();
|
|
705
|
+
if (!flat)
|
|
706
|
+
return "(no description)";
|
|
707
|
+
if (flat.length <= maxChars)
|
|
708
|
+
return flat;
|
|
709
|
+
const window = flat.slice(0, maxChars);
|
|
710
|
+
const sentenceEnd = window.search(/(?:\.\s+|。\s*|;\s*)/);
|
|
711
|
+
if (sentenceEnd >= 24 && sentenceEnd <= maxChars - 1) {
|
|
712
|
+
const endChar = window[sentenceEnd];
|
|
713
|
+
const cut = endChar === "." ? sentenceEnd + 1 : sentenceEnd + 1;
|
|
714
|
+
return window.slice(0, cut).trim();
|
|
715
|
+
}
|
|
716
|
+
return `${flat.slice(0, maxChars - 3).trimEnd()}...`;
|
|
717
|
+
}
|
|
680
718
|
function synthesizeSkillCatalogPackage(args) {
|
|
681
719
|
const enc = new TextEncoder;
|
|
682
720
|
const normalizedByNameRoot = args.byNameRoot?.trim().replace(/\/+$/, "");
|
|
721
|
+
const cliCmd = args.cliCommand?.trim() || "ntn-skills";
|
|
683
722
|
const sorted = [...args.discoverableEntries].sort((a, b) => {
|
|
684
723
|
if (a.kind === "router" && b.kind !== "router")
|
|
685
724
|
return -1;
|
|
@@ -688,12 +727,16 @@ function synthesizeSkillCatalogPackage(args) {
|
|
|
688
727
|
return a.name.localeCompare(b.name);
|
|
689
728
|
});
|
|
690
729
|
const formatEntryBullet = (e) => {
|
|
691
|
-
const
|
|
730
|
+
const slug = normalizeSkillSlug(e.name) || e.name;
|
|
731
|
+
const reqNames = e.requiresIds.map((id) => {
|
|
732
|
+
const n = args.allEntriesById.get(id)?.name;
|
|
733
|
+
return n ? normalizeSkillSlug(n) || n : undefined;
|
|
734
|
+
}).filter((n) => Boolean(n));
|
|
692
735
|
const kindBadge = e.kind === "router" ? " `[strategy-router]`" : "";
|
|
693
|
-
const desc = e.description
|
|
736
|
+
const desc = summarizeCatalogDescription(e.description, 140);
|
|
694
737
|
const reqSuffix = reqNames.length > 0 ? ` *(requires: ${reqNames.join(", ")})*` : "";
|
|
695
|
-
const unmaterializedSuffix = !e.materializedPath ? ` *(load via
|
|
696
|
-
return `- **${
|
|
738
|
+
const unmaterializedSuffix = !e.materializedPath ? ` *(load via \`${cliCmd} load "${slug}" --path-only </dev/null\`)*` : "";
|
|
739
|
+
return `- **${slug}**${kindBadge}: ${desc}${reqSuffix}${unmaterializedSuffix}`;
|
|
697
740
|
};
|
|
698
741
|
const groups = new Map;
|
|
699
742
|
for (const e of sorted) {
|
|
@@ -713,12 +756,12 @@ function synthesizeSkillCatalogPackage(args) {
|
|
|
713
756
|
});
|
|
714
757
|
const files = [];
|
|
715
758
|
const groupSummaryLines = [];
|
|
716
|
-
const sceneLoadLine = normalizedByNameRoot ? `Load a skill by reading \`${normalizedByNameRoot}/<name>/SKILL.md\`.` :
|
|
759
|
+
const sceneLoadLine = normalizedByNameRoot ? `Load a skill by reading \`${normalizedByNameRoot}/<name>/SKILL.md\`.` : `Load a skill via \`${cliCmd} load "<name>" --path-only </dev/null\` then read \`<dir>/SKILL.md\`.`;
|
|
717
760
|
for (const gk of orderedGroupKeys) {
|
|
718
761
|
const items = groups.get(gk);
|
|
719
762
|
const relPath = `references/${gk}.md`;
|
|
720
763
|
const previewCandidates = items.filter((i) => i.kind !== "router");
|
|
721
|
-
const sampleNames = previewCandidates.slice(0, 4).map((i) => i.name);
|
|
764
|
+
const sampleNames = previewCandidates.slice(0, 4).map((i) => normalizeSkillSlug(i.name) || i.name);
|
|
722
765
|
const sampleSuffix = sampleNames.length > 0 ? `: ${sampleNames.join(", ")}${previewCandidates.length > 4 ? "..." : ""}` : "";
|
|
723
766
|
groupSummaryLines.push(`- \`${relPath}\` (${items.length})${sampleSuffix}`);
|
|
724
767
|
const refMd = [
|
|
@@ -739,15 +782,17 @@ function synthesizeSkillCatalogPackage(args) {
|
|
|
739
782
|
const routerSection = strategyRouters.length > 0 ? [
|
|
740
783
|
"## Strategy Routers",
|
|
741
784
|
...strategyRouters.map((e) => {
|
|
742
|
-
const
|
|
743
|
-
const
|
|
744
|
-
|
|
785
|
+
const slug = normalizeSkillSlug(e.name) || e.name;
|
|
786
|
+
const desc = summarizeCatalogDescription(e.description, 140);
|
|
787
|
+
const unmat = !e.materializedPath ? ` (run: ${cliCmd} load "${slug}" --path-only </dev/null)` : "";
|
|
788
|
+
return `- **${slug}**: ${desc}${unmat}`;
|
|
745
789
|
}),
|
|
746
790
|
""
|
|
747
791
|
] : [];
|
|
748
|
-
const topLoadInstruction = normalizedByNameRoot ? `Open the matching scene file below, then read \`${normalizedByNameRoot}/<name>/SKILL.md\`.` :
|
|
792
|
+
const topLoadInstruction = normalizedByNameRoot ? `Open the matching scene file below, then read \`${normalizedByNameRoot}/<name>/SKILL.md\`.` : `Open the matching scene file below, then run \`${cliCmd} load "<name>" --path-only </dev/null\` and read \`<dir>/SKILL.md\`.`;
|
|
793
|
+
const cliSearchInstruction = `To search all skills (including manual skills) or materialize on demand, run \`${cliCmd} find "<query>" </dev/null\` and \`${cliCmd} load "<name>" --path-only </dev/null\`.`;
|
|
749
794
|
const byNameDescClause = normalizedByNameRoot ? `; skill files live at ${normalizedByNameRoot}/<name>/SKILL.md` : "";
|
|
750
|
-
const topDescription = `On-demand index of ${sorted.length} specialized skills by scene
|
|
795
|
+
const topDescription = `On-demand index of ${sorted.length} specialized skills by scene${byNameDescClause}. Read ONLY when top-level skills do not cover a specialized workflow or tool; skip for routine coding/Q&A, or use skill_find directly if available.`;
|
|
751
796
|
const mainMd = [
|
|
752
797
|
"---",
|
|
753
798
|
`name: ${JSON.stringify(args.routerName)}`,
|
|
@@ -756,6 +801,7 @@ function synthesizeSkillCatalogPackage(args) {
|
|
|
756
801
|
"",
|
|
757
802
|
`# ${args.routerName} (${sorted.length})`,
|
|
758
803
|
topLoadInstruction,
|
|
804
|
+
cliSearchInstruction,
|
|
759
805
|
"",
|
|
760
806
|
...routerSection,
|
|
761
807
|
"## Scenes",
|
|
@@ -835,13 +881,29 @@ function formatSkillFindResults(args) {
|
|
|
835
881
|
};
|
|
836
882
|
}
|
|
837
883
|
function formatLoadedSkillBlock(args) {
|
|
884
|
+
const parsed = parseSkillFrontmatter(args.markdown);
|
|
885
|
+
let bodyText = parsed.hasFrontmatter ? parsed.body.replace(/^\n+/, "") : args.markdown;
|
|
886
|
+
let inlineReqLine = "";
|
|
887
|
+
const leadingReqMatch = bodyText.match(/^Requires:\s*([^\n]+)\n+/);
|
|
888
|
+
if (leadingReqMatch) {
|
|
889
|
+
inlineReqLine = leadingReqMatch[1].trim();
|
|
890
|
+
bodyText = bodyText.slice(leadingReqMatch[0].length);
|
|
891
|
+
}
|
|
838
892
|
const pairs = Object.entries(args.requiresPaths ?? {}).map(([k, v]) => `${k}=${v}`);
|
|
839
|
-
const
|
|
840
|
-
|
|
841
|
-
|
|
893
|
+
const mergedReq = pairs.length > 0 ? pairs.join(", ") : inlineReqLine;
|
|
894
|
+
const reqLine = mergedReq ? `
|
|
895
|
+
Requires: ${mergedReq}` : "";
|
|
896
|
+
const extraFrontmatter = parsed.hasFrontmatter && parsed.extraLines.length > 0 ? `---
|
|
897
|
+
${parsed.extraLines.join(`
|
|
898
|
+
`)}
|
|
899
|
+
---
|
|
900
|
+
|
|
901
|
+
` : "";
|
|
902
|
+
const cleanPayload = `${extraFrontmatter}${bodyText.trim()}`.trim();
|
|
903
|
+
return `<skill name="${args.name}" path="${args.dir}">
|
|
842
904
|
References are relative to ${args.dir}.${reqLine}
|
|
843
905
|
|
|
844
|
-
${
|
|
906
|
+
${cleanPayload}
|
|
845
907
|
</skill>`;
|
|
846
908
|
}
|
|
847
909
|
// packages/core/src/notion/markdown-blocks.ts
|
|
@@ -3950,7 +4012,7 @@ var UpstreamLiveLayer = Layer3.effect(UpstreamPort, Effect3.gen(function* () {
|
|
|
3950
4012
|
const rawText = mdTexts.get(smd.path) ?? "";
|
|
3951
4013
|
const parsed = parseSkillFrontmatter(rawText);
|
|
3952
4014
|
const fallbackName = dir === "." ? repoUrl.replace(/\.git$/i, "").split("/").pop() : dir.split("/").pop();
|
|
3953
|
-
const finalName = (parsed.name
|
|
4015
|
+
const finalName = resolveCanonicalSkillName(parsed.name, fallbackName);
|
|
3954
4016
|
if (!finalName || seenGh.has(finalName.toLowerCase()))
|
|
3955
4017
|
continue;
|
|
3956
4018
|
seenGh.add(finalName.toLowerCase());
|
|
@@ -3994,7 +4056,7 @@ var UpstreamLiveLayer = Layer3.effect(UpstreamPort, Effect3.gen(function* () {
|
|
|
3994
4056
|
const rawText = new TextDecoder().decode(smd.bytes);
|
|
3995
4057
|
const parsed = parseSkillFrontmatter(rawText);
|
|
3996
4058
|
const fallbackName = dir === "." ? repoUrl.replace(/\.git$/i, "").split("/").pop() : dir.split("/").pop();
|
|
3997
|
-
const finalName = (parsed.name
|
|
4059
|
+
const finalName = resolveCanonicalSkillName(parsed.name, fallbackName);
|
|
3998
4060
|
if (!finalName || seenNames.has(finalName.toLowerCase()))
|
|
3999
4061
|
continue;
|
|
4000
4062
|
seenNames.add(finalName.toLowerCase());
|
|
@@ -4129,6 +4191,7 @@ var UpstreamLiveLayer = Layer3.effect(UpstreamPort, Effect3.gen(function* () {
|
|
|
4129
4191
|
// packages/core/src/sync/sync-engine.ts
|
|
4130
4192
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
4131
4193
|
import * as fsp5 from "node:fs/promises";
|
|
4194
|
+
import * as os2 from "node:os";
|
|
4132
4195
|
import * as nodePath5 from "node:path";
|
|
4133
4196
|
import { Effect as Effect4, Schema as Schema3 } from "effect";
|
|
4134
4197
|
function isHomeOrEnvPrefixed(raw) {
|
|
@@ -4419,6 +4482,26 @@ function initLibraryCommand(args) {
|
|
|
4419
4482
|
};
|
|
4420
4483
|
});
|
|
4421
4484
|
}
|
|
4485
|
+
async function resolveLocalCliCommandHint(homeDir) {
|
|
4486
|
+
const isExec = async (p) => fsp5.access(p, fsp5.constants.X_OK).then(() => true).catch(() => false);
|
|
4487
|
+
for (const seg of (process.env.PATH ?? "").split(nodePath5.delimiter)) {
|
|
4488
|
+
const dir = seg.trim();
|
|
4489
|
+
if (!dir)
|
|
4490
|
+
continue;
|
|
4491
|
+
if (await isExec(nodePath5.join(dir, "ntn-skills"))) {
|
|
4492
|
+
return "ntn-skills";
|
|
4493
|
+
}
|
|
4494
|
+
}
|
|
4495
|
+
const candidates = [
|
|
4496
|
+
nodePath5.join(process.env.HOME?.trim() || os2.homedir(), ".local", "bin", "ntn-skills"),
|
|
4497
|
+
nodePath5.join(homeDir, "bin", "ntn-skills")
|
|
4498
|
+
];
|
|
4499
|
+
for (const c of candidates) {
|
|
4500
|
+
if (await isExec(c))
|
|
4501
|
+
return c;
|
|
4502
|
+
}
|
|
4503
|
+
return "ntn-skills";
|
|
4504
|
+
}
|
|
4422
4505
|
function doctorCommand(args) {
|
|
4423
4506
|
return Effect4.gen(function* () {
|
|
4424
4507
|
const notion = yield* NotionPort;
|
|
@@ -4530,6 +4613,23 @@ function doctorCommand(args) {
|
|
|
4530
4613
|
status: "pass",
|
|
4531
4614
|
detail: `Synced catalog: ${activeSources} source(s), ${activeSkills} active skill(s), ${activeFiles} file row(s) (lastSync=${libState.lastSyncedAt ?? libState.watermark ?? "unknown"}).`
|
|
4532
4615
|
});
|
|
4616
|
+
const nonSlugSkills = Object.values(libState.skills).filter((s) => s.enabled && !isValidSkillSlug(s.name)).map((s) => s.name).sort();
|
|
4617
|
+
if (nonSlugSkills.length > 0) {
|
|
4618
|
+
const sample = nonSlugSkills.slice(0, 6).join(", ");
|
|
4619
|
+
const more = nonSlugSkills.length > 6 ? `, +${nonSlugSkills.length - 6} more` : "";
|
|
4620
|
+
checks.push({
|
|
4621
|
+
name: "skill_names",
|
|
4622
|
+
status: "warn",
|
|
4623
|
+
detail: `${nonSlugSkills.length} active skill(s) use non-slug names (${sample}${more}); local exports fall back to normalized lowercase slugs.`,
|
|
4624
|
+
hint: "Rename Skills.Name in Notion to lowercase hyphenated slugs (a-z, 0-9, -) for clean cross-agent compatibility."
|
|
4625
|
+
});
|
|
4626
|
+
} else {
|
|
4627
|
+
checks.push({
|
|
4628
|
+
name: "skill_names",
|
|
4629
|
+
status: "pass",
|
|
4630
|
+
detail: `All ${activeSkills} active skill name(s) conform to lowercase hyphenated slug format.`
|
|
4631
|
+
});
|
|
4632
|
+
}
|
|
4533
4633
|
}
|
|
4534
4634
|
const realStoreRoot = yield* Effect4.tryPromise(() => fsp5.realpath(store.paths.storeRoot)).pipe(Effect4.catch(() => Effect4.succeed(store.paths.storeRoot)));
|
|
4535
4635
|
const storePrefixes = Array.from(new Set([`${store.paths.storeRoot}${nodePath5.sep}`, `${realStoreRoot}${nodePath5.sep}`]));
|
|
@@ -4650,7 +4750,7 @@ function materializeOneSkill(args) {
|
|
|
4650
4750
|
};
|
|
4651
4751
|
}
|
|
4652
4752
|
}
|
|
4653
|
-
const authoritativeSkillMd = applyAuthoritativeFrontmatter(rawMainMarkdown, args.skill.name, args.skill.description);
|
|
4753
|
+
const authoritativeSkillMd = applyAuthoritativeFrontmatter(rawMainMarkdown, args.skill.name, args.skill.description, args.requiresPaths);
|
|
4654
4754
|
fileMap.set("SKILL.md", {
|
|
4655
4755
|
path: "SKILL.md",
|
|
4656
4756
|
bytes: new TextEncoder().encode(authoritativeSkillMd),
|
|
@@ -4710,21 +4810,22 @@ function planExportTarget(args) {
|
|
|
4710
4810
|
const seenNames = new Map;
|
|
4711
4811
|
const duplicateNames = new Map;
|
|
4712
4812
|
for (const entry of args.selectedEntries) {
|
|
4713
|
-
const
|
|
4813
|
+
const exportName = normalizeSkillSlug(entry.name) || entry.name.trim();
|
|
4814
|
+
const prev = seenNames.get(exportName);
|
|
4714
4815
|
if (prev && prev.skillId !== entry.skillId) {
|
|
4715
4816
|
if (onConflict === "error") {
|
|
4716
4817
|
return yield* Effect4.fail(new ConflictError({
|
|
4717
4818
|
kind: "duplicate_name",
|
|
4718
|
-
message: `Duplicate active skill name '${
|
|
4819
|
+
message: `Duplicate active skill name '${exportName}' in Notion (${prev.skillId} vs ${entry.skillId}); refusing export.`,
|
|
4719
4820
|
details: [prev.skillId, entry.skillId]
|
|
4720
4821
|
}));
|
|
4721
4822
|
}
|
|
4722
|
-
const ids = duplicateNames.get(
|
|
4823
|
+
const ids = duplicateNames.get(exportName) ?? new Set([prev.skillId]);
|
|
4723
4824
|
ids.add(entry.skillId);
|
|
4724
|
-
duplicateNames.set(
|
|
4825
|
+
duplicateNames.set(exportName, ids);
|
|
4725
4826
|
continue;
|
|
4726
4827
|
}
|
|
4727
|
-
seenNames.set(
|
|
4828
|
+
seenNames.set(exportName, entry);
|
|
4728
4829
|
}
|
|
4729
4830
|
for (const [dupName, ids] of duplicateNames) {
|
|
4730
4831
|
seenNames.delete(dupName);
|
|
@@ -4895,21 +4996,22 @@ function publishExportTarget(args) {
|
|
|
4895
4996
|
const seenNames = new Map;
|
|
4896
4997
|
const duplicateNames = new Map;
|
|
4897
4998
|
for (const entry of args.selectedEntries) {
|
|
4898
|
-
const
|
|
4999
|
+
const exportName = normalizeSkillSlug(entry.name) || entry.name.trim();
|
|
5000
|
+
const prev = seenNames.get(exportName);
|
|
4899
5001
|
if (prev && prev.skillId !== entry.skillId) {
|
|
4900
5002
|
if (onConflict === "error") {
|
|
4901
5003
|
return yield* Effect4.fail(new ConflictError({
|
|
4902
5004
|
kind: "duplicate_name",
|
|
4903
|
-
message: `Duplicate active skill name '${
|
|
5005
|
+
message: `Duplicate active skill name '${exportName}' in Notion (${prev.skillId} vs ${entry.skillId}); refusing export.`,
|
|
4904
5006
|
details: [prev.skillId, entry.skillId]
|
|
4905
5007
|
}));
|
|
4906
5008
|
}
|
|
4907
|
-
const ids = duplicateNames.get(
|
|
5009
|
+
const ids = duplicateNames.get(exportName) ?? new Set([prev.skillId]);
|
|
4908
5010
|
ids.add(entry.skillId);
|
|
4909
|
-
duplicateNames.set(
|
|
5011
|
+
duplicateNames.set(exportName, ids);
|
|
4910
5012
|
continue;
|
|
4911
5013
|
}
|
|
4912
|
-
seenNames.set(
|
|
5014
|
+
seenNames.set(exportName, entry);
|
|
4913
5015
|
}
|
|
4914
5016
|
for (const [dupName, ids] of duplicateNames) {
|
|
4915
5017
|
seenNames.delete(dupName);
|
|
@@ -5102,7 +5204,7 @@ async function copyDirectoryContentsWritable(srcDir, dstDir) {
|
|
|
5102
5204
|
}
|
|
5103
5205
|
}
|
|
5104
5206
|
async function upsertByNameSymlink(byNameRoot, skillName, targetDir) {
|
|
5105
|
-
const trimmed = skillName.trim();
|
|
5207
|
+
const trimmed = normalizeSkillSlug(skillName) || skillName.trim();
|
|
5106
5208
|
if (!trimmed || trimmed === "." || trimmed === ".." || trimmed.startsWith(".") || nodePath5.basename(trimmed) !== trimmed) {
|
|
5107
5209
|
return;
|
|
5108
5210
|
}
|
|
@@ -5149,7 +5251,7 @@ async function reconcileByNameDirectory(args) {
|
|
|
5149
5251
|
for (const e of ordered) {
|
|
5150
5252
|
if (!e.enabled || !e.materializedPath)
|
|
5151
5253
|
continue;
|
|
5152
|
-
const trimmed = e.name.trim();
|
|
5254
|
+
const trimmed = normalizeSkillSlug(e.name) || e.name.trim();
|
|
5153
5255
|
if (!trimmed || trimmed === "." || trimmed === ".." || trimmed.startsWith(".") || nodePath5.basename(trimmed) !== trimmed || desired.has(trimmed)) {
|
|
5154
5256
|
continue;
|
|
5155
5257
|
}
|
|
@@ -5631,6 +5733,14 @@ function syncCommand(options = {}) {
|
|
|
5631
5733
|
revMemo.delete(sid);
|
|
5632
5734
|
}
|
|
5633
5735
|
const rev = getEffectiveRevFor(sid);
|
|
5736
|
+
const reqPathsForMat = {};
|
|
5737
|
+
for (const reqId of sk.requiresIds) {
|
|
5738
|
+
const reqSkill = effectiveById.get(reqId);
|
|
5739
|
+
if (!reqSkill)
|
|
5740
|
+
continue;
|
|
5741
|
+
const reqSlug = normalizeSkillSlug(reqSkill.name) || reqSkill.name.trim();
|
|
5742
|
+
reqPathsForMat[reqSlug] = store.getStoreSkillDir(libraryId, reqId, getEffectiveRevFor(reqId));
|
|
5743
|
+
}
|
|
5634
5744
|
if (isDryRun) {
|
|
5635
5745
|
const alreadyReady = yield* store.hasVerifiedStorePackage(libraryId, sid, rev);
|
|
5636
5746
|
const expectedDir = store.getStoreSkillDir(libraryId, sid, rev);
|
|
@@ -5652,7 +5762,8 @@ function syncCommand(options = {}) {
|
|
|
5652
5762
|
pinnedCommit: src.pinnedCommit || (resolvedCommits.get(src.id) ?? "")
|
|
5653
5763
|
} : null,
|
|
5654
5764
|
overlayFiles: filesBySkillId.get(sid) ?? [],
|
|
5655
|
-
effectiveRev: rev
|
|
5765
|
+
effectiveRev: rev,
|
|
5766
|
+
requiresPaths: reqPathsForMat
|
|
5656
5767
|
}).pipe(Effect4.map((ok) => ({ ok: true, value: ok })), Effect4.catchTag("UpstreamError", (err) => Effect4.succeed({ ok: false, err })));
|
|
5657
5768
|
if (!matRes.ok) {
|
|
5658
5769
|
const warnMsg = `Skill '${sk.name}' skipped materialization due to upstream fetch error: ${matRes.err.message}`;
|
|
@@ -5759,6 +5870,7 @@ function syncCommand(options = {}) {
|
|
|
5759
5870
|
}
|
|
5760
5871
|
const manifestExports = [];
|
|
5761
5872
|
const preparedExports = [];
|
|
5873
|
+
const cliCommand = yield* Effect4.promise(() => resolveLocalCliCommandHint(store.paths.homeDir));
|
|
5762
5874
|
for (const { resolved, selection } of exportSelections) {
|
|
5763
5875
|
const exp = resolved.target;
|
|
5764
5876
|
const selectedEntries = selection.selected.map((s) => exportEntryMapById.get(s.id)).filter((e) => Boolean(e?.materializedPath));
|
|
@@ -5771,7 +5883,8 @@ function syncCommand(options = {}) {
|
|
|
5771
5883
|
routerName,
|
|
5772
5884
|
discoverableEntries,
|
|
5773
5885
|
allEntriesById: exportEntryMapById,
|
|
5774
|
-
byNameRoot: store.paths.byNameRoot
|
|
5886
|
+
byNameRoot: store.paths.byNameRoot,
|
|
5887
|
+
cliCommand
|
|
5775
5888
|
});
|
|
5776
5889
|
const routerSkillId = `_router-${routerName}`;
|
|
5777
5890
|
const routerStoreDir = isDryRun ? store.getStoreSkillDir(libraryId, routerSkillId, synth.effectiveRev) : yield* store.publishImmutablePackage({
|
|
@@ -6289,6 +6402,17 @@ function loadSkillCommand(args) {
|
|
|
6289
6402
|
requiresRevs: []
|
|
6290
6403
|
});
|
|
6291
6404
|
}
|
|
6405
|
+
const reqPathsForLoad = {};
|
|
6406
|
+
for (const reqId of sk.requiresIds) {
|
|
6407
|
+
const reqSkill = effectiveById.get(reqId);
|
|
6408
|
+
if (!reqSkill)
|
|
6409
|
+
continue;
|
|
6410
|
+
const reqSlug = normalizeSkillSlug(reqSkill.name) || reqSkill.name.trim();
|
|
6411
|
+
const knownDir = matDirs.get(reqId);
|
|
6412
|
+
if (knownDir) {
|
|
6413
|
+
reqPathsForLoad[reqSlug] = knownDir;
|
|
6414
|
+
}
|
|
6415
|
+
}
|
|
6292
6416
|
const mat = yield* materializeOneSkill({
|
|
6293
6417
|
libraryId,
|
|
6294
6418
|
libState: workingLib,
|
|
@@ -6296,7 +6420,8 @@ function loadSkillCommand(args) {
|
|
|
6296
6420
|
source: src,
|
|
6297
6421
|
overlayFiles: filesBySkill.get(cid) ?? [],
|
|
6298
6422
|
effectiveRev: targetRev,
|
|
6299
|
-
forceRefreshBodies: Boolean(args.refresh)
|
|
6423
|
+
forceRefreshBodies: Boolean(args.refresh),
|
|
6424
|
+
requiresPaths: reqPathsForLoad
|
|
6300
6425
|
});
|
|
6301
6426
|
workingLib = mat.updatedLibState;
|
|
6302
6427
|
matDirs.set(cid, mat.storeDir);
|
|
@@ -6756,11 +6881,13 @@ function exportCommand(args) {
|
|
|
6756
6881
|
let routerEntry = null;
|
|
6757
6882
|
const routerName = (target.router?.name ?? "skill-catalog").trim() || "skill-catalog";
|
|
6758
6883
|
if (selection.resolvedRouterEnabled && discoverableEntries.length > 0 && !directNameSet.has(routerName.toLowerCase())) {
|
|
6884
|
+
const cliCommand = yield* Effect4.promise(() => resolveLocalCliCommandHint(store.paths.homeDir));
|
|
6759
6885
|
const synth = synthesizeSkillCatalogPackage({
|
|
6760
6886
|
routerName,
|
|
6761
6887
|
discoverableEntries,
|
|
6762
6888
|
allEntriesById: entryCacheById,
|
|
6763
|
-
byNameRoot: store.paths.byNameRoot
|
|
6889
|
+
byNameRoot: store.paths.byNameRoot,
|
|
6890
|
+
cliCommand
|
|
6764
6891
|
});
|
|
6765
6892
|
const routerSkillId = `_router-${routerName}`;
|
|
6766
6893
|
const routerStoreDir = isDryRun ? store.getStoreSkillDir(libraryId, routerSkillId, synth.effectiveRev) : yield* store.publishImmutablePackage({
|
|
@@ -7135,7 +7262,8 @@ function loadTableMetadataLibrary(explicitLibraryId) {
|
|
|
7135
7262
|
}
|
|
7136
7263
|
function findSkillOrFail(libState, name) {
|
|
7137
7264
|
const needle = name.trim().toLowerCase();
|
|
7138
|
-
const
|
|
7265
|
+
const needleSlug = normalizeSkillSlug(name);
|
|
7266
|
+
const candidates = Object.values(libState.skills).filter((s) => s.name.toLowerCase() === needle || needleSlug.length > 0 && normalizeSkillSlug(s.name) === needleSlug).sort((a, b) => Number(b.enabled) - Number(a.enabled) || b.lastEditedTime.localeCompare(a.lastEditedTime));
|
|
7139
7267
|
const found = candidates[0];
|
|
7140
7268
|
return found ? Effect6.succeed(found) : Effect6.fail(new NotFoundError({ entity: "skill", target: name, message: `Skill '${name}' not found.` }));
|
|
7141
7269
|
}
|
|
@@ -7159,7 +7287,9 @@ function editOrPullSkillCommand(args) {
|
|
|
7159
7287
|
const store = yield* StorePort;
|
|
7160
7288
|
const upstream = yield* UpstreamPort;
|
|
7161
7289
|
const { libraryId, binding, catalog, libState } = yield* loadSyncedLibrary(args.libraryId);
|
|
7162
|
-
const
|
|
7290
|
+
const targetLower = args.name.trim().toLowerCase();
|
|
7291
|
+
const targetSlug = normalizeSkillSlug(args.name);
|
|
7292
|
+
const entry = catalog.entries.find((e) => e.libraryId === libraryId && (e.name.toLowerCase() === targetLower || targetSlug.length > 0 && normalizeSkillSlug(e.name) === targetSlug));
|
|
7163
7293
|
if (!entry) {
|
|
7164
7294
|
return yield* Effect6.fail(new NotFoundError({
|
|
7165
7295
|
entity: "skill",
|
|
@@ -7706,7 +7836,12 @@ function createNewSkillCommand(args) {
|
|
|
7706
7836
|
return yield* Effect6.fail(new StoreError({ path: absDir, message: `Missing SKILL.md in ${absDir}.` }));
|
|
7707
7837
|
const rawMain = new TextDecoder().decode(mainFile.bytes);
|
|
7708
7838
|
const parsed = parseSkillFrontmatter(rawMain);
|
|
7709
|
-
const skillName = (args.name
|
|
7839
|
+
const skillName = args.name?.trim() ? normalizeSkillSlug(args.name) : resolveCanonicalSkillName(parsed.name, nodePath7.basename(absDir));
|
|
7840
|
+
if (!skillName || !isValidSkillSlug(skillName)) {
|
|
7841
|
+
return yield* Effect6.fail(new ConfigError({
|
|
7842
|
+
message: `Invalid skill name for ${absDir}: must form a lowercase hyphenated English slug (a-z, 0-9, -). Pass --name <slug>.`
|
|
7843
|
+
}));
|
|
7844
|
+
}
|
|
7710
7845
|
const duplicate = catalog.entries.find((e) => e.libraryId === libraryId && (e.name.toLowerCase() === skillName.toLowerCase() || normalizeSkillSlug(e.name) === normalizeSkillSlug(skillName)));
|
|
7711
7846
|
if (duplicate) {
|
|
7712
7847
|
return yield* Effect6.fail(new ConflictError({
|
|
@@ -9276,7 +9411,8 @@ function createNewSkillsBatchCommand(args) {
|
|
|
9276
9411
|
const mainFile = scan.files.get("SKILL.md");
|
|
9277
9412
|
const rawMain = mainFile ? new TextDecoder().decode(mainFile.bytes) : "";
|
|
9278
9413
|
const parsed = mainFile ? parseSkillFrontmatter(rawMain) : null;
|
|
9279
|
-
const
|
|
9414
|
+
const explicitName = explicitDirs.length === 1 && !isPending ? args.name?.trim() : undefined;
|
|
9415
|
+
const skillName = explicitName ? normalizeSkillSlug(explicitName) : resolveCanonicalSkillName(parsed?.name, fallbackName);
|
|
9280
9416
|
const resolvedVisibility = explicitVisibility ?? (parsed?.disableModelInvocation ? "manual" : "discoverable");
|
|
9281
9417
|
if (scan.blockedFiles.length > 0) {
|
|
9282
9418
|
failed.push({
|
|
@@ -9308,10 +9444,10 @@ function createNewSkillsBatchCommand(args) {
|
|
|
9308
9444
|
});
|
|
9309
9445
|
continue;
|
|
9310
9446
|
}
|
|
9311
|
-
if (!skillName) {
|
|
9447
|
+
if (!skillName || !isValidSkillSlug(skillName)) {
|
|
9312
9448
|
failed.push({
|
|
9313
9449
|
dir: absDir,
|
|
9314
|
-
name: null,
|
|
9450
|
+
name: skillName || null,
|
|
9315
9451
|
visibility: resolvedVisibility,
|
|
9316
9452
|
fileCount: scan.fileCount,
|
|
9317
9453
|
totalBytes: scan.totalBytes,
|
|
@@ -9319,7 +9455,7 @@ function createNewSkillsBatchCommand(args) {
|
|
|
9319
9455
|
blockedFiles: [],
|
|
9320
9456
|
conflict: false,
|
|
9321
9457
|
code: "invalid_skill_name",
|
|
9322
|
-
error: `
|
|
9458
|
+
error: `Skill name for ${absDir} must form a lowercase hyphenated English slug (a-z, 0-9, -).`
|
|
9323
9459
|
});
|
|
9324
9460
|
continue;
|
|
9325
9461
|
}
|
|
@@ -10044,7 +10180,7 @@ function makeCoreLiveLayer(options) {
|
|
|
10044
10180
|
// packages/core/src/schedule/scheduler.ts
|
|
10045
10181
|
import { spawn as spawn4 } from "node:child_process";
|
|
10046
10182
|
import * as fsp9 from "node:fs/promises";
|
|
10047
|
-
import * as
|
|
10183
|
+
import * as os3 from "node:os";
|
|
10048
10184
|
import * as nodePath9 from "node:path";
|
|
10049
10185
|
import { fileURLToPath } from "node:url";
|
|
10050
10186
|
import { Effect as Effect8 } from "effect";
|
|
@@ -10270,7 +10406,7 @@ function isMacOsTccProtectedPath(absPath, safeHomeDir) {
|
|
|
10270
10406
|
if (norm === normSafe || norm.startsWith(`${normSafe}${nodePath9.sep}`)) {
|
|
10271
10407
|
return false;
|
|
10272
10408
|
}
|
|
10273
|
-
const home = process.env.HOME?.trim() ||
|
|
10409
|
+
const home = process.env.HOME?.trim() || os3.homedir();
|
|
10274
10410
|
const protectedRoots = ["Documents", "Desktop", "Downloads"].map((d) => nodePath9.join(home, d));
|
|
10275
10411
|
return protectedRoots.some((r) => norm === r || norm.startsWith(`${r}${nodePath9.sep}`));
|
|
10276
10412
|
}
|
|
@@ -10565,8 +10701,8 @@ function installScheduleCommand(args) {
|
|
|
10565
10701
|
try: () => {
|
|
10566
10702
|
const cleanEnvArgs = [
|
|
10567
10703
|
"-i",
|
|
10568
|
-
`HOME=${process.env.HOME?.trim() ||
|
|
10569
|
-
`USER=${
|
|
10704
|
+
`HOME=${process.env.HOME?.trim() || os3.homedir()}`,
|
|
10705
|
+
`USER=${os3.userInfo().username}`,
|
|
10570
10706
|
"PATH=/usr/bin:/bin",
|
|
10571
10707
|
...process.env.XDG_DATA_HOME?.trim() ? [`XDG_DATA_HOME=${process.env.XDG_DATA_HOME.trim()}`] : [],
|
|
10572
10708
|
...process.env.XDG_CONFIG_HOME?.trim() ? [`XDG_CONFIG_HOME=${process.env.XDG_CONFIG_HOME.trim()}`] : [],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ntn-skills",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.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.3.0"
|
|
41
41
|
}
|
|
42
42
|
}
|