cdspec 0.1.1 → 0.1.4

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.
Files changed (60) hide show
  1. package/dist/cli.js +1 -40
  2. package/dist/config/default.js +1 -48
  3. package/dist/config/loader.js +1 -30
  4. package/dist/config/path.js +1 -11
  5. package/dist/config/types.js +1 -1
  6. package/dist/skill-core/adapters/claudecode-adapter.js +1 -35
  7. package/dist/skill-core/adapters/codex-adapter.js +1 -28
  8. package/dist/skill-core/adapters/iflow-adapter.js +1 -39
  9. package/dist/skill-core/adapters/index.js +1 -34
  10. package/dist/skill-core/adapters/shared.js +1 -36
  11. package/dist/skill-core/manifest-loader.js +1 -60
  12. package/dist/skill-core/scaffold.js +1 -169
  13. package/dist/skill-core/service.js +1 -109
  14. package/dist/skill-core/tool-interactions.js +1 -70
  15. package/dist/skill-core/types.js +1 -1
  16. package/dist/skill-core/validator.js +1 -25
  17. package/dist/utils/frontmatter.js +1 -40
  18. package/dist/utils/fs.js +1 -37
  19. package/package.json +11 -2
  20. package/templates/{standards-backend → backend-standard}/SKILL.md +55 -55
  21. package/templates/backend-standard/agents/openai.yaml +4 -0
  22. package/templates/{standards-backend → backend-standard}/references/DDD/346/236/266/346/236/204/347/272/246/346/235/237.md +103 -103
  23. package/templates/{standards-backend → backend-standard}/references/JUC/345/271/266/345/217/221/350/247/204/350/214/203.md +232 -232
  24. package/templates/{standards-backend → backend-standard}/references//344/274/240/347/273/237/344/270/211/345/261/202/346/236/266/346/236/204/347/272/246/346/235/237.md +35 -35
  25. package/templates/{standards-backend → backend-standard}/references//345/220/216/347/253/257/345/274/200/345/217/221/350/247/204/350/214/203.md +49 -49
  26. package/templates/{standards-backend → backend-standard}/references//346/225/260/346/215/256/345/272/223/350/256/276/350/256/241/350/247/204/350/214/203.md +116 -116
  27. package/templates/{standards-backend → backend-standard}/references//350/256/276/350/256/241/346/250/241/345/274/217/350/220/275/345/234/260/346/211/213/345/206/214.md +395 -395
  28. package/templates/{frontend-develop-standard → frontend-standard}/SKILL.md +63 -63
  29. package/templates/frontend-standard/agents/openai.yaml +4 -0
  30. package/templates/{frontend-develop-standard/references/frontend_develop_standard.md → frontend-standard/references/frontend_standard.md} +28 -321
  31. package/cdspec.config.yaml +0 -34
  32. package/dist/skill-core/agent-config.js +0 -40
  33. package/dist/task-core/parser.js +0 -70
  34. package/dist/task-core/service.js +0 -28
  35. package/dist/task-core/storage.js +0 -159
  36. package/dist/task-core/types.js +0 -1
  37. package/src/cli.ts +0 -44
  38. package/src/config/default.ts +0 -51
  39. package/src/config/loader.ts +0 -37
  40. package/src/config/path.ts +0 -13
  41. package/src/config/types.ts +0 -22
  42. package/src/skill-core/adapters/claudecode-adapter.ts +0 -45
  43. package/src/skill-core/adapters/codex-adapter.ts +0 -36
  44. package/src/skill-core/adapters/iflow-adapter.ts +0 -49
  45. package/src/skill-core/adapters/index.ts +0 -39
  46. package/src/skill-core/adapters/shared.ts +0 -45
  47. package/src/skill-core/manifest-loader.ts +0 -72
  48. package/src/skill-core/scaffold.ts +0 -192
  49. package/src/skill-core/service.ts +0 -137
  50. package/src/skill-core/tool-interactions.ts +0 -95
  51. package/src/skill-core/types.ts +0 -22
  52. package/src/skill-core/validator.ts +0 -28
  53. package/src/types/yaml.d.ts +0 -4
  54. package/src/utils/frontmatter.ts +0 -55
  55. package/src/utils/fs.ts +0 -41
  56. package/templates/frontend-develop-standard/agents/openai.yaml +0 -4
  57. package/templates/standards-backend/agents/openai.yaml +0 -4
  58. package/tests/init.test.ts +0 -63
  59. package/tsconfig.json +0 -16
  60. package/vitest.config.ts +0 -9
@@ -1,169 +1 @@
1
- import { mkdtemp, readdir, readFile, rm, writeFile } from "node:fs/promises";
2
- import os from "node:os";
3
- import path from "node:path";
4
- import { fileURLToPath } from "node:url";
5
- import { parseFrontmatter } from "../utils/frontmatter.js";
6
- import { ensureDir, listDirs, pathExists } from "../utils/fs.js";
7
- const DEFAULT_SKILL_NAME = "openspec-core";
8
- const BUILTIN_TEMPLATE_DIR = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../../templates/default-skill");
9
- export async function cleanupLegacyDefaultSkillDir(cwd) {
10
- await rm(path.join(cwd, ".codex", DEFAULT_SKILL_NAME), { recursive: true, force: true });
11
- await rm(path.join(cwd, ".cdspec", "seed-skills"), { recursive: true, force: true });
12
- }
13
- export async function loadDefaultSkillManifest(cwd) {
14
- const projectTemplateManifests = await loadProjectTemplateManifests(cwd);
15
- if (projectTemplateManifests.length > 0)
16
- return projectTemplateManifests[0];
17
- if (await pathExists(path.join(BUILTIN_TEMPLATE_DIR, "SKILL.md"))) {
18
- return buildManifestFromDir(BUILTIN_TEMPLATE_DIR);
19
- }
20
- const tempDir = await buildFallbackTemplateInTemp();
21
- return buildManifestFromDir(tempDir);
22
- }
23
- export async function loadProjectTemplateManifests(cwd) {
24
- return loadFromProjectTemplates(path.join(cwd, "templates"));
25
- }
26
- async function buildManifestFromDir(skillDir) {
27
- const raw = await readFile(path.join(skillDir, "SKILL.md"), "utf8");
28
- const parsed = parseFrontmatter(raw);
29
- const name = parsed.attributes.name?.trim() || DEFAULT_SKILL_NAME;
30
- const description = parsed.attributes.description?.trim() || "OpenSpec default skill";
31
- const agents = await collectRelativeFiles(path.join(skillDir, "agents"));
32
- const references = await collectRelativeFiles(path.join(skillDir, "references"));
33
- const scripts = await collectRelativeFiles(path.join(skillDir, "scripts"));
34
- const assets = await collectRelativeFiles(path.join(skillDir, "assets"));
35
- return {
36
- name,
37
- description,
38
- body: parsed.body.trim(),
39
- agents,
40
- resources: [...references, ...scripts, ...assets],
41
- sourcePath: skillDir
42
- };
43
- }
44
- async function collectRelativeFiles(dirPath) {
45
- if (!(await pathExists(dirPath)))
46
- return [];
47
- const base = path.dirname(dirPath);
48
- const result = [];
49
- const dirs = [dirPath];
50
- while (dirs.length > 0) {
51
- const current = dirs.pop();
52
- const children = await listDirs(current);
53
- for (const child of children) {
54
- dirs.push(path.join(current, child));
55
- }
56
- const entries = await readdir(current, { withFileTypes: true });
57
- for (const entry of entries) {
58
- if (!entry.isFile())
59
- continue;
60
- const fullPath = path.join(current, entry.name);
61
- result.push(path.relative(base, fullPath).replaceAll("\\", "/"));
62
- }
63
- }
64
- return result;
65
- }
66
- async function buildFallbackTemplateInTemp() {
67
- const root = await mkdtemp(path.join(os.tmpdir(), "cdspec-skill-"));
68
- await ensureDir(path.join(root, "agents"));
69
- await ensureDir(path.join(root, "references"));
70
- const skillMd = [
71
- "---",
72
- "name: openspec-core",
73
- "description: OpenSpec-style change workflow skill. Use for proposing, exploring, applying, and archiving spec-driven changes.",
74
- "---",
75
- "",
76
- "# OpenSpec Core Skill",
77
- "",
78
- "1. /opsx-propose",
79
- "2. /opsx-explore",
80
- "3. /opsx-apply",
81
- "4. /opsx-archive"
82
- ].join("\n");
83
- const openaiYaml = [
84
- "interface:",
85
- ' display_name: "OpenSpec Core"',
86
- ' short_description: "Spec-driven change workflow with propose/explore/apply/archive"',
87
- ' default_prompt: "Use $openspec-core to run OpenSpec-style workflows in this repository."'
88
- ].join("\n");
89
- await writeFile(path.join(root, "SKILL.md"), `${skillMd}\n`, "utf8");
90
- await writeFile(path.join(root, "agents", "openai.yaml"), `${openaiYaml}\n`, "utf8");
91
- await writeFile(path.join(root, "references", "project_notes.md"), "# OpenSpec Workflow Notes\n");
92
- return root;
93
- }
94
- async function loadFromProjectTemplates(templateRoot) {
95
- if (!(await pathExists(templateRoot)))
96
- return [];
97
- const manifests = [];
98
- const childDirs = await listDirs(templateRoot);
99
- for (const child of childDirs) {
100
- const full = path.join(templateRoot, child);
101
- if (await pathExists(path.join(full, "SKILL.md"))) {
102
- manifests.push(await buildManifestFromDir(full));
103
- }
104
- }
105
- if (manifests.length > 0)
106
- return manifests;
107
- const markdownFiles = await collectMarkdownFiles(templateRoot);
108
- for (const selected of markdownFiles.sort()) {
109
- manifests.push(await buildManifestFromMarkdown(templateRoot, selected));
110
- }
111
- return manifests;
112
- }
113
- async function buildManifestFromMarkdown(templateRoot, selected) {
114
- const raw = await readFile(selected, "utf8");
115
- const parsed = parseFrontmatter(raw);
116
- const baseName = path.basename(selected, path.extname(selected));
117
- const skillName = normalizeSkillName(parsed.attributes.name || baseName);
118
- const description = parsed.attributes.description ||
119
- `Generated from templates/${path.relative(templateRoot, selected).replaceAll("\\", "/")}`;
120
- const body = parsed.body.trim() || raw.trim();
121
- const tmp = await mkdtemp(path.join(os.tmpdir(), "cdspec-template-"));
122
- await ensureDir(path.join(tmp, "agents"));
123
- await ensureDir(path.join(tmp, "references"));
124
- const skillMd = ["---", `name: ${skillName}`, `description: ${description}`, "---", "", body].join("\n");
125
- const openaiYaml = [
126
- "interface:",
127
- ` display_name: "${humanizeName(skillName)}"`,
128
- ` short_description: "${escapeYaml(description)}"`,
129
- ` default_prompt: "Use $${skillName} to follow this template skill."`
130
- ].join("\n");
131
- await writeFile(path.join(tmp, "SKILL.md"), `${skillMd}\n`, "utf8");
132
- await writeFile(path.join(tmp, "agents", "openai.yaml"), `${openaiYaml}\n`, "utf8");
133
- await writeFile(path.join(tmp, "references", path.basename(selected)), raw, "utf8");
134
- return buildManifestFromDir(tmp);
135
- }
136
- async function collectMarkdownFiles(root) {
137
- const files = [];
138
- const queue = [root];
139
- while (queue.length > 0) {
140
- const current = queue.pop();
141
- const dirs = await listDirs(current);
142
- for (const dir of dirs) {
143
- queue.push(path.join(current, dir));
144
- }
145
- const entries = await readdir(current, { withFileTypes: true });
146
- for (const entry of entries) {
147
- if (entry.isFile() && entry.name.toLowerCase().endsWith(".md")) {
148
- files.push(path.join(current, entry.name));
149
- }
150
- }
151
- }
152
- return files;
153
- }
154
- function normalizeSkillName(input) {
155
- return input
156
- .toLowerCase()
157
- .replace(/[^a-z0-9]+/g, "-")
158
- .replace(/^-+|-+$/g, "") || DEFAULT_SKILL_NAME;
159
- }
160
- function humanizeName(input) {
161
- return input
162
- .split("-")
163
- .filter(Boolean)
164
- .map((part) => part[0].toUpperCase() + part.slice(1))
165
- .join(" ");
166
- }
167
- function escapeYaml(value) {
168
- return value.replace(/"/g, '\\"');
169
- }
1
+ const _0x76320c=_0x2137;(function(_0x221dca,_0x402ed8){const _0x57f774=_0x2137,_0x49396e=_0x221dca();while(!![]){try{const _0x27708d=-parseInt(_0x57f774(0x157))/(-0x91c*0x1+-0x136*-0x16+-0x1187)*(parseInt(_0x57f774(0x13b))/(0x1019+0x7e1+-0x17f8))+parseInt(_0x57f774(0x160))/(-0x64*-0x12+0x17b5+-0x1eba)*(-parseInt(_0x57f774(0x140))/(0x114f+-0xa*0x118+-0x65b))+parseInt(_0x57f774(0x15e))/(-0x1f10+-0x10be+0x2fd3)*(-parseInt(_0x57f774(0x15c))/(-0x36c+-0x17*0x107+-0xef*-0x1d))+parseInt(_0x57f774(0x149))/(-0xc06+-0x1458+-0x1*-0x2065)*(parseInt(_0x57f774(0x14f))/(0x43*-0x4c+-0x13d4+0x27c0))+parseInt(_0x57f774(0x166))/(-0xc*0x293+-0x3f*0x5c+0x15*0x28d)*(parseInt(_0x57f774(0x146))/(-0x1119+0x108e+0x95*0x1))+-parseInt(_0x57f774(0x136))/(0x1bb6+0x10*0x1a7+0x201*-0x1b)*(-parseInt(_0x57f774(0x163))/(-0x1a58+0x49d*-0x5+0x3175))+-parseInt(_0x57f774(0x138))/(-0x1691+-0xafd+0x219b);if(_0x27708d===_0x402ed8)break;else _0x49396e['push'](_0x49396e['shift']());}catch(_0x16816e){_0x49396e['push'](_0x49396e['shift']());}}}(_0x4efb,-0x2*0x3fc67+0x3167+0x3f*0x3494));import{mkdtemp,readdir,readFile,rm,writeFile}from'node:fs/promises';import _0x515952 from'node:os';function _0x2137(_0x1019f5,_0x1ba794){_0x1019f5=_0x1019f5-(-0x1*-0x6f1+0x5*-0x74c+0x1eaf);const _0x10c08c=_0x4efb();let _0x1b2cbb=_0x10c08c[_0x1019f5];return _0x1b2cbb;}import _0x176846 from'node:path';import{fileURLToPath}from'node:url';import{parseFrontmatter}from'../utils/frontmatter.js';import{ensureDir,listDirs,pathExists}from'../utils/fs.js';const DEFAULT_SKILL_NAME=_0x76320c(0x135),BUILTIN_TEMPLATE_DIR=_0x176846[_0x76320c(0x161)](_0x176846[_0x76320c(0x147)](fileURLToPath(import.meta.url)),_0x76320c(0x145));export async function cleanupLegacyDefaultSkillDir(_0x83c5ab){const _0x4e3222=_0x76320c;await rm(_0x176846['join'](_0x83c5ab,_0x4e3222(0x12c),DEFAULT_SKILL_NAME),{'recursive':!![],'force':!![]}),await rm(_0x176846[_0x4e3222(0x14c)](_0x83c5ab,'.cdspec',_0x4e3222(0x153)),{'recursive':!![],'force':!![]});}export async function loadDefaultSkillManifest(_0x1faffe){const _0x5cb9ef=_0x76320c,_0x5b80d9=await loadProjectTemplateManifests(_0x1faffe);if(_0x5b80d9[_0x5cb9ef(0x133)]>-0x10cf+0xeed+0x1e2)return _0x5b80d9[-0x1f27+0x240b+-0x139*0x4];if(await pathExists(_0x176846[_0x5cb9ef(0x14c)](BUILTIN_TEMPLATE_DIR,'SKILL.md')))return buildManifestFromDir(BUILTIN_TEMPLATE_DIR);const _0x19847c=await buildFallbackTemplateInTemp();return buildManifestFromDir(_0x19847c);}export async function loadProjectTemplateManifests(_0x53bb98){const _0x393df9=_0x76320c;return loadFromProjectTemplates(_0x176846[_0x393df9(0x14c)](_0x53bb98,_0x393df9(0x142)));}async function buildManifestFromDir(_0x2d39c0){const _0x4f040c=_0x76320c,_0x3df226=await readFile(_0x176846[_0x4f040c(0x14c)](_0x2d39c0,_0x4f040c(0x12b)),_0x4f040c(0x124)),_0xd5206b=parseFrontmatter(_0x3df226),_0x49959a=_0xd5206b['attributes']['name']?.[_0x4f040c(0x13d)]()||DEFAULT_SKILL_NAME,_0x1fbd7d=_0xd5206b[_0x4f040c(0x14d)][_0x4f040c(0x167)]?.[_0x4f040c(0x13d)]()||_0x4f040c(0x152),_0x1ba0f3=await collectRelativeFiles(_0x176846[_0x4f040c(0x14c)](_0x2d39c0,_0x4f040c(0x14b))),_0x152c41=await collectRelativeFiles(_0x176846[_0x4f040c(0x14c)](_0x2d39c0,_0x4f040c(0x148))),_0x20e678=await collectRelativeFiles(_0x176846[_0x4f040c(0x14c)](_0x2d39c0,_0x4f040c(0x14a))),_0x340099=await collectRelativeFiles(_0x176846[_0x4f040c(0x14c)](_0x2d39c0,_0x4f040c(0x13e)));return{'name':_0x49959a,'description':_0x1fbd7d,'body':_0xd5206b[_0x4f040c(0x129)][_0x4f040c(0x13d)](),'agents':_0x1ba0f3,'resources':[..._0x152c41,..._0x20e678,..._0x340099],'sourcePath':_0x2d39c0};}async function collectRelativeFiles(_0x383e78){const _0x138986=_0x76320c;if(!await pathExists(_0x383e78))return[];const _0x3e1b5a=_0x176846[_0x138986(0x147)](_0x383e78),_0x3e52a3=[],_0x3a302f=[_0x383e78];while(_0x3a302f[_0x138986(0x133)]>-0x5*0x6eb+-0x4a3+0x139d*0x2){const _0x4ac9f6=_0x3a302f[_0x138986(0x12d)](),_0x182cf6=await listDirs(_0x4ac9f6);for(const _0x24140b of _0x182cf6){_0x3a302f[_0x138986(0x13f)](_0x176846[_0x138986(0x14c)](_0x4ac9f6,_0x24140b));}const _0x538707=await readdir(_0x4ac9f6,{'withFileTypes':!![]});for(const _0x1654e2 of _0x538707){if(!_0x1654e2['isFile']())continue;const _0x1b3258=_0x176846[_0x138986(0x14c)](_0x4ac9f6,_0x1654e2[_0x138986(0x158)]);_0x3e52a3[_0x138986(0x13f)](_0x176846['relative'](_0x3e1b5a,_0x1b3258)[_0x138986(0x126)]('\x5c','/'));}}return _0x3e52a3;}function _0x4efb(){const _0x12b869=['openai.yaml','\x20\x20short_description:\x20\x22','../../templates/default-skill','440yPCdhY','dirname','references','2093EEvJPg','scripts','agents','join','attributes','map','11952XivnZF','cdspec-skill-','description:\x20OpenSpec-style\x20change\x20workflow\x20skill.\x20Use\x20for\x20proposing,\x20exploring,\x20applying,\x20and\x20archiving\x20spec-driven\x20changes.','OpenSpec\x20default\x20skill','seed-skills','interface:','description:\x20','\x20\x20default_prompt:\x20\x22Use\x20$openspec-core\x20to\x20run\x20OpenSpec-style\x20workflows\x20in\x20this\x20repository.\x22','6676ZaVrGg','name','replace','\x20\x20short_description:\x20\x22Spec-driven\x20change\x20workflow\x20with\x20propose/explore/apply/archive\x22','#\x20OpenSpec\x20Workflow\x20Notes\x0a','6IwQuNT','name:\x20openspec-core','1076495tgnskY','\x20\x20default_prompt:\x20\x22Use\x20$','3wRFDyD','resolve','---','132pQUOaP','split','toLowerCase','35262rtsIKA','description','utf8','slice','replaceAll','basename','2.\x20/opsx-explore','body','cdspec-template-','SKILL.md','.codex','pop','.md','toUpperCase','3.\x20/opsx-apply','\x20to\x20follow\x20this\x20template\x20skill.\x22','Generated\x20from\x20templates/','length','project_notes.md','openspec-core','282667ZIVpIV','relative','1206738TFjAGT','tmpdir','sort','44jfYiSO','\x20\x20display_name:\x20\x22OpenSpec\x20Core\x22','trim','assets','push','434348PjIUbv','filter','templates'];_0x4efb=function(){return _0x12b869;};return _0x4efb();}async function buildFallbackTemplateInTemp(){const _0x1cbc82=_0x76320c,_0x2acf74=await mkdtemp(_0x176846[_0x1cbc82(0x14c)](_0x515952[_0x1cbc82(0x139)](),_0x1cbc82(0x150)));await ensureDir(_0x176846[_0x1cbc82(0x14c)](_0x2acf74,_0x1cbc82(0x14b))),await ensureDir(_0x176846[_0x1cbc82(0x14c)](_0x2acf74,_0x1cbc82(0x148)));const _0x5a2cdd=['---',_0x1cbc82(0x15d),_0x1cbc82(0x151),_0x1cbc82(0x162),'','#\x20OpenSpec\x20Core\x20Skill','','1.\x20/opsx-propose',_0x1cbc82(0x128),_0x1cbc82(0x130),'4.\x20/opsx-archive']['join']('\x0a'),_0x22c42b=[_0x1cbc82(0x154),_0x1cbc82(0x13c),_0x1cbc82(0x15a),_0x1cbc82(0x156)]['join']('\x0a');return await writeFile(_0x176846[_0x1cbc82(0x14c)](_0x2acf74,_0x1cbc82(0x12b)),_0x5a2cdd+'\x0a',_0x1cbc82(0x124)),await writeFile(_0x176846[_0x1cbc82(0x14c)](_0x2acf74,_0x1cbc82(0x14b),'openai.yaml'),_0x22c42b+'\x0a','utf8'),await writeFile(_0x176846[_0x1cbc82(0x14c)](_0x2acf74,_0x1cbc82(0x148),_0x1cbc82(0x134)),_0x1cbc82(0x15b)),_0x2acf74;}async function loadFromProjectTemplates(_0x5555e1){const _0x5be9e8=_0x76320c;if(!await pathExists(_0x5555e1))return[];const _0x24d988=[],_0x5dcea9=await listDirs(_0x5555e1);for(const _0x4609f9 of _0x5dcea9){const _0x1fda21=_0x176846[_0x5be9e8(0x14c)](_0x5555e1,_0x4609f9);await pathExists(_0x176846[_0x5be9e8(0x14c)](_0x1fda21,_0x5be9e8(0x12b)))&&_0x24d988[_0x5be9e8(0x13f)](await buildManifestFromDir(_0x1fda21));}if(_0x24d988[_0x5be9e8(0x133)]>-0x1*0x287+0x1*0x269f+-0x2418)return _0x24d988;const _0x55bb5b=await collectMarkdownFiles(_0x5555e1);for(const _0x255005 of _0x55bb5b[_0x5be9e8(0x13a)]()){_0x24d988[_0x5be9e8(0x13f)](await buildManifestFromMarkdown(_0x5555e1,_0x255005));}return _0x24d988;}async function buildManifestFromMarkdown(_0x16523f,_0x36a3d3){const _0x28035e=_0x76320c,_0x4cfc6f=await readFile(_0x36a3d3,_0x28035e(0x124)),_0x1b0008=parseFrontmatter(_0x4cfc6f),_0x58e9b7=_0x176846[_0x28035e(0x127)](_0x36a3d3,_0x176846['extname'](_0x36a3d3)),_0x397ee3=normalizeSkillName(_0x1b0008['attributes'][_0x28035e(0x158)]||_0x58e9b7),_0x41e3c4=_0x1b0008['attributes']['description']||_0x28035e(0x132)+_0x176846[_0x28035e(0x137)](_0x16523f,_0x36a3d3)[_0x28035e(0x126)]('\x5c','/'),_0x27eb2d=_0x1b0008[_0x28035e(0x129)][_0x28035e(0x13d)]()||_0x4cfc6f[_0x28035e(0x13d)](),_0x20cb1=await mkdtemp(_0x176846['join'](_0x515952[_0x28035e(0x139)](),_0x28035e(0x12a)));await ensureDir(_0x176846['join'](_0x20cb1,_0x28035e(0x14b))),await ensureDir(_0x176846[_0x28035e(0x14c)](_0x20cb1,_0x28035e(0x148)));const _0x20f438=[_0x28035e(0x162),'name:\x20'+_0x397ee3,_0x28035e(0x155)+_0x41e3c4,'---','',_0x27eb2d][_0x28035e(0x14c)]('\x0a'),_0x5ca1ed=[_0x28035e(0x154),'\x20\x20display_name:\x20\x22'+humanizeName(_0x397ee3)+'\x22',_0x28035e(0x144)+escapeYaml(_0x41e3c4)+'\x22',_0x28035e(0x15f)+_0x397ee3+_0x28035e(0x131)][_0x28035e(0x14c)]('\x0a');return await writeFile(_0x176846['join'](_0x20cb1,_0x28035e(0x12b)),_0x20f438+'\x0a',_0x28035e(0x124)),await writeFile(_0x176846[_0x28035e(0x14c)](_0x20cb1,_0x28035e(0x14b),_0x28035e(0x143)),_0x5ca1ed+'\x0a',_0x28035e(0x124)),await writeFile(_0x176846['join'](_0x20cb1,_0x28035e(0x148),_0x176846[_0x28035e(0x127)](_0x36a3d3)),_0x4cfc6f,_0x28035e(0x124)),buildManifestFromDir(_0x20cb1);}async function collectMarkdownFiles(_0x46c001){const _0x170f9a=_0x76320c,_0x417e75=[],_0x49750a=[_0x46c001];while(_0x49750a['length']>0x1*0x1307+-0x7e5*0x1+-0xb22){const _0x2afc02=_0x49750a['pop'](),_0x4ba927=await listDirs(_0x2afc02);for(const _0x2058f4 of _0x4ba927){_0x49750a[_0x170f9a(0x13f)](_0x176846[_0x170f9a(0x14c)](_0x2afc02,_0x2058f4));}const _0x36eaea=await readdir(_0x2afc02,{'withFileTypes':!![]});for(const _0x1a8384 of _0x36eaea){_0x1a8384['isFile']()&&_0x1a8384[_0x170f9a(0x158)]['toLowerCase']()['endsWith'](_0x170f9a(0x12e))&&_0x417e75[_0x170f9a(0x13f)](_0x176846[_0x170f9a(0x14c)](_0x2afc02,_0x1a8384[_0x170f9a(0x158)]));}}return _0x417e75;}function normalizeSkillName(_0x2457cb){const _0x1c64ad=_0x76320c;return _0x2457cb[_0x1c64ad(0x165)]()[_0x1c64ad(0x159)](/[^a-z0-9]+/g,'-')[_0x1c64ad(0x159)](/^-+|-+$/g,'')||DEFAULT_SKILL_NAME;}function humanizeName(_0x3852f4){const _0x68c86e=_0x76320c;return _0x3852f4[_0x68c86e(0x164)]('-')[_0x68c86e(0x141)](Boolean)[_0x68c86e(0x14e)](_0x27d6c5=>_0x27d6c5[0x3ce+-0xe74+0xaa6*0x1][_0x68c86e(0x12f)]()+_0x27d6c5[_0x68c86e(0x125)](-0x26e0+0x609+0x836*0x4))[_0x68c86e(0x14c)]('\x20');}function escapeYaml(_0x43317a){const _0x4792aa=_0x76320c;return _0x43317a[_0x4792aa(0x159)](/"/g,'\x5c\x22');}
@@ -1,109 +1 @@
1
- import path from "node:path";
2
- import { rm } from "node:fs/promises";
3
- import { loadConfig } from "../config/loader.js";
4
- import { resolveAgentRoot } from "../config/path.js";
5
- import { loadAllSkillManifests } from "./manifest-loader.js";
6
- import { expandTargets, getAdapter } from "./adapters/index.js";
7
- import { installToolInteractionTemplates, writeSharedAgentsStub } from "./tool-interactions.js";
8
- import { cleanupLegacyDefaultSkillDir, loadDefaultSkillManifest, loadProjectTemplateManifests } from "./scaffold.js";
9
- import { validateManifest } from "./validator.js";
10
- export async function initSkills(cwd, agentsRaw, force) {
11
- await cleanupLegacyDefaultSkillDir(cwd);
12
- const baseConfig = await loadConfig(cwd);
13
- const projectTemplateManifests = await loadProjectTemplateManifests(cwd);
14
- let manifests = projectTemplateManifests.length > 0
15
- ? projectTemplateManifests
16
- : await loadAllSkillManifests(cwd);
17
- if (manifests.length === 0)
18
- manifests = [await loadDefaultSkillManifest(cwd)];
19
- const config = buildInitConfig(baseConfig, manifests);
20
- const targets = expandTargets(agentsRaw);
21
- if (force) {
22
- for (const target of targets) {
23
- const root = resolveAgentRoot(cwd, config.agents[target].rootDir);
24
- await rm(path.join(root, "skills"), {
25
- recursive: true,
26
- force: true
27
- });
28
- await rm(path.join(root, config.agents[target].commandsDir), {
29
- recursive: true,
30
- force: true
31
- });
32
- const guide = config.agents[target].guideAtProjectRoot
33
- ? path.join(cwd, config.agents[target].guideFile)
34
- : path.join(root, config.agents[target].guideFile);
35
- await rm(guide, { force: true });
36
- }
37
- }
38
- for (const manifest of manifests) {
39
- const diagnostics = [...validateManifest(manifest)];
40
- for (const target of targets) {
41
- diagnostics.push(...getAdapter(target).validate(manifest));
42
- }
43
- failIfErrors(diagnostics);
44
- }
45
- for (const manifest of manifests) {
46
- for (const target of targets) {
47
- const outDir = path.join(resolveAgentRoot(cwd, config.agents[target].rootDir), "skills", manifest.name);
48
- await getAdapter(target).emit(manifest, outDir, force);
49
- }
50
- }
51
- const files = [];
52
- for (const target of targets) {
53
- files.push(...(await installToolInteractionTemplates(cwd, target, manifests, config)));
54
- }
55
- files.push(await writeSharedAgentsStub(cwd, targets, manifests, config));
56
- return files;
57
- }
58
- function buildInitConfig(config, manifests) {
59
- const available = new Set(manifests.map((item) => item.name));
60
- const skillDrivenBindings = buildSkillDrivenBindings(manifests);
61
- return {
62
- ...config,
63
- commandBindings: skillDrivenBindings.length > 0
64
- ? skillDrivenBindings
65
- : config.commandBindings.map((item) => available.has(item.skill) ? item : { ...item, skill: manifests[0]?.name || item.skill }),
66
- agents: {
67
- codex: { ...config.agents.codex, commandFilePattern: "{id}.md", slashPattern: "/{id}" },
68
- claudecode: {
69
- ...config.agents.claudecode,
70
- commandFilePattern: "{id}.md",
71
- slashPattern: "/{id}"
72
- },
73
- iflow: { ...config.agents.iflow, commandFilePattern: "{id}.md", slashPattern: "/{id}" }
74
- }
75
- };
76
- }
77
- function buildSkillDrivenBindings(manifests) {
78
- const used = new Set();
79
- return manifests.map((manifest) => {
80
- const base = commandIdForSkillName(manifest.name);
81
- let id = base;
82
- let i = 2;
83
- while (used.has(id)) {
84
- id = `${base}${i}`;
85
- i += 1;
86
- }
87
- used.add(id);
88
- return {
89
- id,
90
- skill: manifest.name,
91
- description: `Run skill ${manifest.name}`
92
- };
93
- });
94
- }
95
- function commandIdForSkillName(skillName) {
96
- const normalizedName = skillName
97
- .toLowerCase()
98
- .replace(/[^a-z0-9]+/g, "-")
99
- .replace(/^-+|-+$/g, "");
100
- return `cd-${normalizedName || "skill"}`;
101
- }
102
- function failIfErrors(diagnostics) {
103
- const warnings = diagnostics.filter((item) => item.level === "warning");
104
- warnings.forEach((warning) => console.warn(`[warn] ${warning.message}`));
105
- const errors = diagnostics.filter((item) => item.level === "error");
106
- if (errors.length > 0) {
107
- throw new Error(errors.map((error) => error.message).join("\n"));
108
- }
109
- }
1
+ const _0x1c543e=_0xd8f7;(function(_0x36f3c7,_0x166459){const _0xe53bb2=_0xd8f7,_0x4aaea1=_0x36f3c7();while(!![]){try{const _0x4037fe=parseInt(_0xe53bb2(0xff))/(0x1fed+-0xdca+-0x1222)*(parseInt(_0xe53bb2(0xf8))/(0x1*-0x19c6+-0x209d+0x3a65))+parseInt(_0xe53bb2(0x108))/(-0x1*-0x21bb+-0xf6d+-0x1*0x124b)+-parseInt(_0xe53bb2(0x10b))/(-0x145f+0x48e+-0x7*-0x243)+-parseInt(_0xe53bb2(0x100))/(0x1cb1+-0x8*-0x162+-0x27bc*0x1)+parseInt(_0xe53bb2(0x107))/(-0x110e+0xfeb+0x129)+-parseInt(_0xe53bb2(0xf6))/(0x23ca+0x2c*0xd8+-0x48e3)*(parseInt(_0xe53bb2(0xfe))/(0x17*-0x2+-0x1*-0x22f1+-0x11*0x20b))+-parseInt(_0xe53bb2(0xf0))/(0x3c4*-0x6+-0x46*0x86+0x3b45)*(-parseInt(_0xe53bb2(0xf3))/(0xa4b+-0x4*-0x431+-0x1b05));if(_0x4037fe===_0x166459)break;else _0x4aaea1['push'](_0x4aaea1['shift']());}catch(_0x14cef0){_0x4aaea1['push'](_0x4aaea1['shift']());}}}(_0x94ec,0x17*0x1027+-0x2e8b*0x11+0x35e40));import _0x5886dc from'node:path';import{rm}from'node:fs/promises';import{loadConfig}from'../config/loader.js';import{resolveAgentRoot}from'../config/path.js';import{loadAllSkillManifests}from'./manifest-loader.js';import{expandTargets,getAdapter}from'./adapters/index.js';import{installToolInteractionTemplates}from'./tool-interactions.js';import{cleanupLegacyDefaultSkillDir,loadDefaultSkillManifest,loadProjectTemplateManifests}from'./scaffold.js';import{validateManifest}from'./validator.js';export async function initSkills(_0x40570c,_0x1e754a,_0x10a654,_0x102a43=_0x1c543e(0x110)){const _0x2c976f=_0x1c543e;await cleanupLegacyDefaultSkillDir(_0x40570c);const _0x2af003=await loadConfig(_0x40570c),_0x4164a8=await loadProjectTemplateManifests(_0x40570c);let _0x30d9fa=_0x4164a8[_0x2c976f(0x10a)]>-0xeda+-0x2336+-0x321*-0x10?_0x4164a8:await loadAllSkillManifests(_0x40570c);if(_0x30d9fa[_0x2c976f(0x10a)]===0x17db+0xc11*0x2+0x1*-0x2ffd)_0x30d9fa=[await loadDefaultSkillManifest(_0x40570c)];const _0x1020a3=buildInitConfig(_0x2af003,_0x30d9fa,_0x102a43),_0x16e303=expandTargets(_0x1e754a);if(_0x10a654){for(const _0x2e4450 of _0x16e303){const _0x5f4143=resolveAgentRoot(_0x40570c,_0x1020a3['agents'][_0x2e4450][_0x2c976f(0xf2)]);await rm(_0x5886dc[_0x2c976f(0x112)](_0x5f4143,_0x2c976f(0xeb)),{'recursive':!![],'force':!![]}),await rm(_0x5886dc['join'](_0x5f4143,_0x1020a3['agents'][_0x2e4450][_0x2c976f(0x113)]),{'recursive':!![],'force':!![]});const _0x5394d3=_0x1020a3[_0x2c976f(0xed)][_0x2e4450][_0x2c976f(0xf4)]?_0x5886dc['join'](_0x40570c,_0x1020a3[_0x2c976f(0xed)][_0x2e4450][_0x2c976f(0x101)]):_0x5886dc['join'](_0x5f4143,_0x1020a3[_0x2c976f(0xed)][_0x2e4450][_0x2c976f(0x101)]);await rm(_0x5394d3,{'force':!![]});}await rm(_0x5886dc[_0x2c976f(0x112)](_0x40570c,_0x2c976f(0xfc)),{'force':!![]});}for(const _0x1ece67 of _0x30d9fa){const _0xc81918=[...validateManifest(_0x1ece67)];for(const _0x256fd1 of _0x16e303){_0xc81918[_0x2c976f(0xea)](...getAdapter(_0x256fd1)[_0x2c976f(0x105)](_0x1ece67));}failIfErrors(_0xc81918);}for(const _0x4d4558 of _0x30d9fa){for(const _0x1af836 of _0x16e303){const _0x597223=_0x5886dc['join'](resolveAgentRoot(_0x40570c,_0x1020a3[_0x2c976f(0xed)][_0x1af836][_0x2c976f(0xf2)]),'skills',_0x4d4558[_0x2c976f(0xf5)]);await getAdapter(_0x1af836)['emit'](_0x4d4558,_0x597223,_0x10a654);}}const _0x529e2d=[];for(const _0x5cb191 of _0x16e303){_0x529e2d[_0x2c976f(0xea)](...await installToolInteractionTemplates(_0x40570c,_0x5cb191,_0x30d9fa,_0x1020a3));}return _0x529e2d;}function buildInitConfig(_0x3cf59e,_0x2f2d87,_0x3fcd5a){const _0x2a5377=_0x1c543e,_0x4c6523=new Set(_0x2f2d87[_0x2a5377(0xf7)](_0x4b9900=>_0x4b9900['name'])),_0x366943=buildSkillDrivenBindings(_0x2f2d87),_0x17e846=_0x3fcd5a==='project'?{'codex':{..._0x3cf59e['agents'][_0x2a5377(0x10c)],'rootDir':toProjectRootDir(_0x3cf59e[_0x2a5377(0xed)][_0x2a5377(0x10c)][_0x2a5377(0xf2)],_0x2a5377(0xfb))},'claudecode':{..._0x3cf59e[_0x2a5377(0xed)][_0x2a5377(0x109)],'rootDir':toProjectRootDir(_0x3cf59e['agents'][_0x2a5377(0x109)][_0x2a5377(0xf2)],_0x2a5377(0xec))},'iflow':{..._0x3cf59e[_0x2a5377(0xed)]['iflow'],'rootDir':toProjectRootDir(_0x3cf59e[_0x2a5377(0xed)][_0x2a5377(0xee)][_0x2a5377(0xf2)],_0x2a5377(0x115))}}:_0x3cf59e['agents'];return{..._0x3cf59e,'commandBindings':_0x366943[_0x2a5377(0x10a)]>0xb8f+-0x2a8+0x35*-0x2b?_0x366943:_0x3cf59e[_0x2a5377(0xfd)][_0x2a5377(0xf7)](_0x3d7872=>_0x4c6523[_0x2a5377(0x10f)](_0x3d7872[_0x2a5377(0x106)])?_0x3d7872:{..._0x3d7872,'skill':_0x2f2d87[-0xc0b+0xc69+0x5e*-0x1]?.[_0x2a5377(0xf5)]||_0x3d7872[_0x2a5377(0x106)]}),'agents':{'codex':{..._0x17e846[_0x2a5377(0x10c)],'commandFilePattern':'{id}.md','slashPattern':_0x2a5377(0xef)},'claudecode':{..._0x17e846['claudecode'],'commandFilePattern':_0x2a5377(0x102),'slashPattern':_0x2a5377(0xef)},'iflow':{..._0x17e846[_0x2a5377(0xee)],'commandFilePattern':_0x2a5377(0x102),'slashPattern':_0x2a5377(0xef)}}};}function toProjectRootDir(_0x437309,_0x4e6b2f){const _0x1f5a22=_0x1c543e;if(!_0x437309)return _0x4e6b2f;if(!_0x437309[_0x1f5a22(0x116)]('~/')&&!_0x437309[_0x1f5a22(0x116)]('~\x5c')&&!_0x5886dc[_0x1f5a22(0x10e)](_0x437309))return _0x437309;const _0x7c33e3=_0x437309[_0x1f5a22(0x103)](/[/\\]+$/,''),_0x38618a=_0x5886dc['basename'](_0x7c33e3);return _0x38618a||_0x4e6b2f;}function buildSkillDrivenBindings(_0x4d9fbd){const _0x5a04e7=_0x1c543e,_0x7e621c=new Set();return _0x4d9fbd[_0x5a04e7(0xf7)](_0x203985=>{const _0x2e9285=_0x5a04e7,_0x9a11e2=commandIdForSkillName(_0x203985[_0x2e9285(0xf5)]);let _0x5bb32a=_0x9a11e2,_0x5888d3=0x570+0x2132+-0x26a0;while(_0x7e621c[_0x2e9285(0x10f)](_0x5bb32a)){_0x5bb32a=''+_0x9a11e2+_0x5888d3,_0x5888d3+=-0x1*-0x2371+-0x641+-0x1d2f;}return _0x7e621c['add'](_0x5bb32a),{'id':_0x5bb32a,'skill':_0x203985[_0x2e9285(0xf5)],'description':_0x2e9285(0xf1)+_0x203985[_0x2e9285(0xf5)]};});}function _0x94ec(){const _0x54ab84=['map','2ZWpXMA','[warn]\x20','cd-','.codex','AGENTS.md','commandBindings','8quRHGZ','142481wFLZTz','751195jgFedJ','guideFile','{id}.md','replace','level','validate','skill','759882eCBDUV','467667iwwIDm','claudecode','length','331960uFOLMs','codex','error','isAbsolute','has','default','message','join','commandsDir','warn','.iflow','startsWith','push','skills','.claude','agents','iflow','/{id}','9981CYPXoF','Run\x20skill\x20','rootDir','410sJwElV','guideAtProjectRoot','name','867797jwVGeI'];_0x94ec=function(){return _0x54ab84;};return _0x94ec();}function _0xd8f7(_0xdee536,_0x2e799e){_0xdee536=_0xdee536-(0xd12+-0xc55+0x2d*0x1);const _0x47e63f=_0x94ec();let _0x29b344=_0x47e63f[_0xdee536];return _0x29b344;}function commandIdForSkillName(_0x8cec6a){const _0xa6c3a9=_0x1c543e,_0x33c368=_0x8cec6a['toLowerCase']()[_0xa6c3a9(0x103)](/[^a-z0-9]+/g,'-')[_0xa6c3a9(0x103)](/^-+|-+$/g,'');return _0xa6c3a9(0xfa)+(_0x33c368||'skill');}function failIfErrors(_0x3d4e04){const _0x5c4214=_0x1c543e,_0x563e66=_0x3d4e04['filter'](_0x4d3508=>_0x4d3508[_0x5c4214(0x104)]==='warning');_0x563e66['forEach'](_0x572520=>console[_0x5c4214(0x114)](_0x5c4214(0xf9)+_0x572520[_0x5c4214(0x111)]));const _0x3dfc7f=_0x3d4e04['filter'](_0x313553=>_0x313553[_0x5c4214(0x104)]===_0x5c4214(0x10d));if(_0x3dfc7f[_0x5c4214(0x10a)]>0x317*0x4+-0x1*-0x7cf+-0x142b)throw new Error(_0x3dfc7f[_0x5c4214(0xf7)](_0x3661f3=>_0x3661f3['message'])[_0x5c4214(0x112)]('\x0a'));}
@@ -1,70 +1 @@
1
- import { writeFile } from "node:fs/promises";
2
- import path from "node:path";
3
- import { resolveAgentRoot } from "../config/path.js";
4
- import { ensureDir } from "../utils/fs.js";
5
- export async function installToolInteractionTemplates(cwd, target, skills, config) {
6
- const agent = config.agents[target];
7
- const root = resolveAgentRoot(cwd, agent.rootDir);
8
- const commandsDir = path.join(root, agent.commandsDir);
9
- await ensureDir(commandsDir);
10
- const created = [];
11
- for (const binding of config.commandBindings) {
12
- const fileName = agent.commandFilePattern.replace("{id}", binding.id);
13
- const file = path.join(commandsDir, fileName);
14
- await writeFile(file, renderCommandTemplate(target, binding.id, binding.skill, binding.description), "utf8");
15
- created.push(file);
16
- }
17
- const guidePath = agent.guideAtProjectRoot
18
- ? path.join(cwd, agent.guideFile)
19
- : path.join(root, agent.guideFile);
20
- await writeFile(guidePath, renderGuide(target, skills, config), "utf8");
21
- created.push(guidePath);
22
- return created;
23
- }
24
- export async function writeSharedAgentsStub(cwd, targets, skills, config) {
25
- const file = path.join(cwd, "AGENTS.md");
26
- const lines = [
27
- "# AGENTS instructions",
28
- "",
29
- "<INSTRUCTIONS>",
30
- "## OpenSpec Setup",
31
- `Enabled targets: ${targets.join(", ")}`,
32
- "### Skills",
33
- ...skills.map((skill) => `- ${skill.name}: ${skill.description || "No description"}`),
34
- "### Command Bindings",
35
- ...config.commandBindings.map((binding) => `- ${binding.id} -> ${binding.skill}`),
36
- "</INSTRUCTIONS>",
37
- ""
38
- ];
39
- await writeFile(file, lines.join("\n"), "utf8");
40
- return file;
41
- }
42
- function renderCommandTemplate(target, commandId, skillName, description) {
43
- return [
44
- `# ${commandId} (${target})`,
45
- "",
46
- description,
47
- "",
48
- "## Skill binding",
49
- `- skill: ${skillName}`,
50
- "",
51
- "## Required output",
52
- "- Change ID",
53
- "- Updated files",
54
- "- Validation summary"
55
- ].join("\n");
56
- }
57
- function renderGuide(target, skills, config) {
58
- const agent = config.agents[target];
59
- const commandList = config.commandBindings.map((binding) => `- ${agent.slashPattern.replace("{id}", binding.id)} -> ${binding.skill}`);
60
- return [
61
- `# ${target} OpenSpec-style setup`,
62
- "",
63
- "## Installed skills",
64
- ...skills.map((skill) => `- ${skill.name}: ${skill.description || "No description"}`),
65
- "",
66
- "## Commands",
67
- ...commandList,
68
- ""
69
- ].join("\n");
70
- }
1
+ (function(_0x49863d,_0x70edfc){const _0x24f0e6=_0x1e91,_0x3af24b=_0x49863d();while(!![]){try{const _0x431eb9=-parseInt(_0x24f0e6(0x76))/(0x1263+0x1*-0x113+-0x5c5*0x3)*(parseInt(_0x24f0e6(0x70))/(0x202a+0x1bf+0x1*-0x21e7))+-parseInt(_0x24f0e6(0x6d))/(0x1278+-0x142d+0x1b8)*(-parseInt(_0x24f0e6(0x71))/(0xd7*-0x20+-0x1*0xc51+0x1*0x2735))+-parseInt(_0x24f0e6(0x7c))/(-0xd8c+0x12f8+0x567*-0x1)*(-parseInt(_0x24f0e6(0x79))/(0x11bf+-0x161f*0x1+-0x466*-0x1))+parseInt(_0x24f0e6(0x73))/(0x1001*0x2+-0x198e+0x23*-0x2f)*(-parseInt(_0x24f0e6(0x7a))/(-0x1b0+0x1fa3+0x1deb*-0x1))+parseInt(_0x24f0e6(0x80))/(0x42a+0x24bd+-0x28de)+-parseInt(_0x24f0e6(0x6f))/(-0x12a8+-0x1f*0xa2+-0x1328*-0x2)*(parseInt(_0x24f0e6(0x69))/(0x95*0x2b+-0x2*0x7c1+-0x97a))+-parseInt(_0x24f0e6(0x6b))/(0x5e2+-0x6*0x5b2+-0x1f*-0xea);if(_0x431eb9===_0x70edfc)break;else _0x3af24b['push'](_0x3af24b['shift']());}catch(_0xc3bb41){_0x3af24b['push'](_0x3af24b['shift']());}}}(_0x5c70,0x1*-0x506ab+-0x1eb5*-0x26+0xb8e2*0x6));import{writeFile}from'node:fs/promises';function _0x1e91(_0x2715ac,_0x5998ed){_0x2715ac=_0x2715ac-(-0xb*-0x3e+-0xf38+0xcf7);const _0x268bb2=_0x5c70();let _0x408cf9=_0x268bb2[_0x2715ac];return _0x408cf9;}import _0x5914ef from'node:path';import{resolveAgentRoot}from'../config/path.js';import{ensureDir}from'../utils/fs.js';export async function installToolInteractionTemplates(_0x435f3d,_0x49ed9c,_0x1fe416,_0x371707){const _0x441339=_0x1e91,_0x25bc3d=_0x371707[_0x441339(0x77)][_0x49ed9c],_0x51270a=resolveAgentRoot(_0x435f3d,_0x25bc3d[_0x441339(0x75)]),_0x59eb3e=_0x5914ef[_0x441339(0x74)](_0x51270a,_0x25bc3d['commandsDir']);await ensureDir(_0x59eb3e);const _0x4715f9=[];for(const _0x3ade12 of _0x371707['commandBindings']){const _0xb1d665=_0x25bc3d['commandFilePattern']['replace'](_0x441339(0x7d),_0x3ade12['id']),_0x5585dc=_0x5914ef['join'](_0x59eb3e,_0xb1d665);await writeFile(_0x5585dc,renderCommandTemplate(_0x49ed9c,_0x3ade12['id'],_0x3ade12[_0x441339(0x7b)],_0x3ade12[_0x441339(0x72)]),_0x441339(0x6c)),_0x4715f9[_0x441339(0x7f)](_0x5585dc);}return _0x4715f9;}function _0x5c70(){const _0x1e12e4=['699nQJGJy','agents','-\x20skill:\x20','60jGwkCJ','902248slxePf','skill','212200MuQWPD','{id}','##\x20Required\x20output','push','3106503fGSaEv','5425519jGGiVp','-\x20Updated\x20files','2154828ofeUlT','utf8','24onPKJF','##\x20Skill\x20binding','10bGwSAY','302WjKHTi','187436OeADPB','description','7nYcnBh','join','rootDir'];_0x5c70=function(){return _0x1e12e4;};return _0x5c70();}function renderCommandTemplate(_0x5bcfa6,_0x190db8,_0x1b8dc2,_0x13e1f5){const _0x191fe5=_0x1e91;return['#\x20'+_0x190db8+'\x20('+_0x5bcfa6+')','',_0x13e1f5,'',_0x191fe5(0x6e),_0x191fe5(0x78)+_0x1b8dc2,'',_0x191fe5(0x7e),'-\x20Change\x20ID',_0x191fe5(0x6a),'-\x20Validation\x20summary']['join']('\x0a');}
@@ -1 +1 @@
1
- export {};
1
+ export{};
@@ -1,25 +1 @@
1
- export function validateManifest(manifest) {
2
- const diagnostics = [];
3
- if (!manifest.name) {
4
- diagnostics.push({ level: "error", message: "Skill name is required." });
5
- }
6
- if (!manifest.description) {
7
- diagnostics.push({
8
- level: "error",
9
- message: `Skill "${manifest.name}" is missing frontmatter description.`
10
- });
11
- }
12
- if (!manifest.body) {
13
- diagnostics.push({
14
- level: "warning",
15
- message: `Skill "${manifest.name}" has empty SKILL.md body.`
16
- });
17
- }
18
- if (!/^[a-z0-9-]+$/.test(manifest.name)) {
19
- diagnostics.push({
20
- level: "warning",
21
- message: `Skill "${manifest.name}" should use lowercase letters, numbers, and hyphens.`
22
- });
23
- }
24
- return diagnostics;
25
- }
1
+ function _0x1c5a(_0x38d2b7,_0x7568ae){_0x38d2b7=_0x38d2b7-(-0x8*-0x8b+0x1bce*0x1+-0x1f40);const _0x1a1f5e=_0x5cb0();let _0x3398bf=_0x1a1f5e[_0x38d2b7];return _0x3398bf;}function _0x5cb0(){const _0x38b3f5=['warning','437327WIofVy','\x22\x20has\x20empty\x20SKILL.md\x20body.','10gNiHEX','24vdaowX','4077225COPzMn','description','4528405KsEsTf','Skill\x20\x22','4kMlEWg','99457amdSFb','error','name','test','push','1452345FbNqtT','body','8582862rVXbWQ','2792034zxBcjS','60oCwQCO','\x22\x20is\x20missing\x20frontmatter\x20description.','Skill\x20name\x20is\x20required.'];_0x5cb0=function(){return _0x38b3f5;};return _0x5cb0();}(function(_0x4e83fd,_0x4e9613){const _0x187b49=_0x1c5a,_0x213012=_0x4e83fd();while(!![]){try{const _0xd5e82b=-parseInt(_0x187b49(0xec))/(0x1eb+0x190b+-0x1af5)*(parseInt(_0x187b49(0xfb))/(0x15fc+0x7d*-0x5+-0x683*0x3))+-parseInt(_0x187b49(0xf1))/(0x1700+-0x1e5f*-0x1+0xd57*-0x4)+-parseInt(_0x187b49(0xeb))/(0x1*0xd72+0x25f5+0xa47*-0x5)*(-parseInt(_0x187b49(0xe7))/(0x2e*-0xbb+-0x1b85+0x3d24))+parseInt(_0x187b49(0xf3))/(0x5ca+0x1379*-0x2+0x1*0x212e)+parseInt(_0x187b49(0xe9))/(0x1*-0x89f+-0x3*-0x509+-0x227*0x3)+-parseInt(_0x187b49(0xe6))/(0x50e*0x7+0x1152+-0x34ac)*(parseInt(_0x187b49(0xf4))/(-0x588*-0x1+0x1*0x18da+-0x1e59))+-parseInt(_0x187b49(0xf5))/(-0x181d+-0x63d*-0x2+0x31*0x3d)*(parseInt(_0x187b49(0xf9))/(-0x20fc+-0x160f*0x1+0x3716));if(_0xd5e82b===_0x4e9613)break;else _0x213012['push'](_0x213012['shift']());}catch(_0x183285){_0x213012['push'](_0x213012['shift']());}}}(_0x5cb0,-0xc*0xeec3+0x69d*-0x1cd+0x226d26));export function validateManifest(_0x3398bf){const _0x2fb7eb=_0x1c5a,_0x2eef17=[];return!_0x3398bf[_0x2fb7eb(0xee)]&&_0x2eef17[_0x2fb7eb(0xf0)]({'level':_0x2fb7eb(0xed),'message':_0x2fb7eb(0xf7)}),!_0x3398bf[_0x2fb7eb(0xe8)]&&_0x2eef17['push']({'level':_0x2fb7eb(0xed),'message':_0x2fb7eb(0xea)+_0x3398bf['name']+_0x2fb7eb(0xf6)}),!_0x3398bf[_0x2fb7eb(0xf2)]&&_0x2eef17[_0x2fb7eb(0xf0)]({'level':_0x2fb7eb(0xf8),'message':'Skill\x20\x22'+_0x3398bf[_0x2fb7eb(0xee)]+_0x2fb7eb(0xfa)}),!/^[a-z0-9-]+$/[_0x2fb7eb(0xef)](_0x3398bf[_0x2fb7eb(0xee)])&&_0x2eef17[_0x2fb7eb(0xf0)]({'level':_0x2fb7eb(0xf8),'message':_0x2fb7eb(0xea)+_0x3398bf[_0x2fb7eb(0xee)]+'\x22\x20should\x20use\x20lowercase\x20letters,\x20numbers,\x20and\x20hyphens.'}),_0x2eef17;}
@@ -1,40 +1 @@
1
- export function parseFrontmatter(content) {
2
- const normalized = content.replace(/^\uFEFF/, "").replace(/\r\n/g, "\n");
3
- if (!normalized.startsWith("---\n")) {
4
- return { attributes: {}, body: normalized };
5
- }
6
- const endIndex = normalized.indexOf("\n---\n", 4);
7
- if (endIndex === -1) {
8
- return { attributes: {}, body: normalized };
9
- }
10
- const header = normalized.slice(4, endIndex);
11
- const body = normalized.slice(endIndex + 5);
12
- const attributes = {};
13
- for (const rawLine of header.split("\n")) {
14
- const line = rawLine.trim();
15
- if (!line || line.startsWith("#"))
16
- continue;
17
- const idx = line.indexOf(":");
18
- if (idx <= 0)
19
- continue;
20
- const key = line.slice(0, idx).trim();
21
- let value = line.slice(idx + 1).trim();
22
- value = stripQuotes(value);
23
- attributes[key] = value;
24
- }
25
- return { attributes, body };
26
- }
27
- export function stringifyFrontmatter(attributes, body) {
28
- const lines = Object.entries(attributes).map(([key, value]) => {
29
- const escaped = value.replace(/"/g, '\\"');
30
- return `${key}: "${escaped}"`;
31
- });
32
- return `---\n${lines.join("\n")}\n---\n\n${body.trimEnd()}\n`;
33
- }
34
- function stripQuotes(value) {
35
- if ((value.startsWith('"') && value.endsWith('"')) ||
36
- (value.startsWith("'") && value.endsWith("'"))) {
37
- return value.slice(1, -1);
38
- }
39
- return value;
40
- }
1
+ function _0x4e46(_0x355822,_0x20359f){_0x355822=_0x355822-(-0x82b+0x1*-0xea3+0x173d);const _0x52014c=_0x20ab();let _0x42b501=_0x52014c[_0x355822];return _0x42b501;}(function(_0x3de6f3,_0x10c9ed){const _0x3a0b78=_0x4e46,_0x588865=_0x3de6f3();while(!![]){try{const _0x189210=-parseInt(_0x3a0b78(0x82))/(0x1*-0x8cb+0x257b*-0x1+0x435*0xb)*(parseInt(_0x3a0b78(0x71))/(-0x73c+-0x11f+-0x85d*-0x1))+-parseInt(_0x3a0b78(0x7e))/(-0x3*-0x16e+-0x3*-0xc5f+-0x3*0xdcc)+parseInt(_0x3a0b78(0x79))/(-0x3c4*0x3+0x15*-0xe+0x91*0x16)+-parseInt(_0x3a0b78(0x7b))/(-0x48d+-0x239*-0x7+-0xafd)+-parseInt(_0x3a0b78(0x77))/(0x21df+0x11b*0x2+-0xb5*0x33)*(parseInt(_0x3a0b78(0x78))/(-0x17*0x58+-0x217*0x7+0x5a4*0x4))+parseInt(_0x3a0b78(0x74))/(0x1*0x20ab+0xd*-0x15e+-0xedd)+parseInt(_0x3a0b78(0x75))/(0x1e89+0x359*-0x2+0x22a*-0xb);if(_0x189210===_0x10c9ed)break;else _0x588865['push'](_0x588865['shift']());}catch(_0x1bf7a8){_0x588865['push'](_0x588865['shift']());}}}(_0x20ab,-0x53fc*-0x1+-0x5daa+0x42bda));export function parseFrontmatter(_0x33c4a1){const _0x1d42c7=_0x4e46,_0x465edb=_0x33c4a1['replace'](/^\uFEFF/,'')[_0x1d42c7(0x80)](/\r\n/g,'\x0a');if(!_0x465edb[_0x1d42c7(0x7a)](_0x1d42c7(0x70)))return{'attributes':{},'body':_0x465edb};const _0x5996d4=_0x465edb[_0x1d42c7(0x7c)]('\x0a---\x0a',0x1*-0x2243+0x3fc+0x1e4b);if(_0x5996d4===-(-0x1f71+-0x1e91+0xc67*0x5))return{'attributes':{},'body':_0x465edb};const _0x7f07da=_0x465edb[_0x1d42c7(0x7f)](-0x93*0x10+-0x1b66+0x249a,_0x5996d4),_0x30ad4f=_0x465edb[_0x1d42c7(0x7f)](_0x5996d4+(-0x18db+0x1a18+0x27*-0x8)),_0x194a23={};for(const _0x599dac of _0x7f07da['split']('\x0a')){const _0x539bb5=_0x599dac[_0x1d42c7(0x81)]();if(!_0x539bb5||_0x539bb5['startsWith']('#'))continue;const _0x83f224=_0x539bb5[_0x1d42c7(0x7c)](':');if(_0x83f224<=0x5e7*-0x6+0x161*-0x6+-0x6*-0x748)continue;const _0x39ecba=_0x539bb5[_0x1d42c7(0x7f)](-0xcfa+-0xc*0x338+0x339a,_0x83f224)[_0x1d42c7(0x81)]();let _0x48a203=_0x539bb5[_0x1d42c7(0x7f)](_0x83f224+(0x1a5a*-0x1+-0x1d13+0x376e))[_0x1d42c7(0x81)]();_0x48a203=stripQuotes(_0x48a203),_0x194a23[_0x39ecba]=_0x48a203;}return{'attributes':_0x194a23,'body':_0x30ad4f};}export function stringifyFrontmatter(_0x9509ef,_0x4fa06f){const _0x4b39eb=_0x4e46,_0x695e09=Object[_0x4b39eb(0x72)](_0x9509ef)['map'](([_0x548011,_0x2f8583])=>{const _0xd61263=_0x2f8583['replace'](/"/g,'\x5c\x22');return _0x548011+':\x20\x22'+_0xd61263+'\x22';});return _0x4b39eb(0x70)+_0x695e09[_0x4b39eb(0x6f)]('\x0a')+_0x4b39eb(0x76)+_0x4fa06f[_0x4b39eb(0x7d)]()+'\x0a';}function _0x20ab(){const _0x2c154f=['\x0a---\x0a\x0a','1157154mScjsw','7AoznHX','1878360fcNhIP','startsWith','1488940LKLIQe','indexOf','trimEnd','1161870akgGFY','slice','replace','trim','5lhmAXH','join','---\x0a','158042FquyOI','entries','endsWith','2252856PGSPRy','7134633VlKMWg'];_0x20ab=function(){return _0x2c154f;};return _0x20ab();}function stripQuotes(_0x21b2f6){const _0x35187a=_0x4e46;if(_0x21b2f6[_0x35187a(0x7a)]('\x22')&&_0x21b2f6[_0x35187a(0x73)]('\x22')||_0x21b2f6[_0x35187a(0x7a)]('\x27')&&_0x21b2f6[_0x35187a(0x73)]('\x27'))return _0x21b2f6[_0x35187a(0x7f)](-0xe68+0x247a+0x15*-0x10d,-(-0xe29+0xa*0x3ce+0x17e2*-0x1));return _0x21b2f6;}
package/dist/utils/fs.js CHANGED
@@ -1,37 +1 @@
1
- import { mkdir, readdir, rm, stat, copyFile } from "node:fs/promises";
2
- import path from "node:path";
3
- export async function ensureDir(dirPath) {
4
- await mkdir(dirPath, { recursive: true });
5
- }
6
- export async function pathExists(target) {
7
- try {
8
- await stat(target);
9
- return true;
10
- }
11
- catch {
12
- return false;
13
- }
14
- }
15
- export async function emptyDir(dirPath) {
16
- await rm(dirPath, { recursive: true, force: true });
17
- await mkdir(dirPath, { recursive: true });
18
- }
19
- export async function copyDir(srcDir, dstDir) {
20
- await ensureDir(dstDir);
21
- const entries = await readdir(srcDir, { withFileTypes: true });
22
- for (const entry of entries) {
23
- const srcPath = path.join(srcDir, entry.name);
24
- const dstPath = path.join(dstDir, entry.name);
25
- if (entry.isDirectory()) {
26
- await copyDir(srcPath, dstPath);
27
- continue;
28
- }
29
- await copyFile(srcPath, dstPath);
30
- }
31
- }
32
- export async function listDirs(dirPath) {
33
- if (!(await pathExists(dirPath)))
34
- return [];
35
- const entries = await readdir(dirPath, { withFileTypes: true });
36
- return entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name);
37
- }
1
+ (function(_0x6aa5d2,_0x45c489){const _0x41ada9=_0x567a,_0x37ea2a=_0x6aa5d2();while(!![]){try{const _0x467499=parseInt(_0x41ada9(0x83))/(0x6a0+-0x1e2d+0x178e)*(-parseInt(_0x41ada9(0x89))/(-0xcf9*-0x1+-0x1f5b+0x1264))+-parseInt(_0x41ada9(0x82))/(0x419+0x1*0xf9e+-0x34*0x61)+-parseInt(_0x41ada9(0x87))/(0x1*0x841+-0x1*0x1b0f+0x12d2)+-parseInt(_0x41ada9(0x8d))/(-0x20f6+-0xbc2+0x2cbd)+parseInt(_0x41ada9(0x86))/(-0x1*-0xc68+-0x1*0xa2b+-0x237)*(parseInt(_0x41ada9(0x85))/(0x291*0x6+-0x123b*-0x1+0x1fa*-0x11))+-parseInt(_0x41ada9(0x8c))/(0x2*0x4a5+-0xb*-0x34f+-0x2da7)+parseInt(_0x41ada9(0x8a))/(-0x1*-0xbe4+-0x829+-0x3b2);if(_0x467499===_0x45c489)break;else _0x37ea2a['push'](_0x37ea2a['shift']());}catch(_0x4efe05){_0x37ea2a['push'](_0x37ea2a['shift']());}}}(_0x3b16,0x343d*0x5+0x2*-0x5f8e2+0x1*0x1456c0));function _0x3b16(){const _0x2811a9=['896642asfNhG','29790198kCyLNc','name','300560kcBXvK','3837855UvMiVb','filter','2039448hDSHMw','1AlQytN','isDirectory','245kjudjB','14646SZLZvw','3380696TzhOqt','join'];_0x3b16=function(){return _0x2811a9;};return _0x3b16();}import{mkdir,readdir,rm,stat,copyFile}from'node:fs/promises';import _0x587c03 from'node:path';function _0x567a(_0x22bd6a,_0x5229b3){_0x22bd6a=_0x22bd6a-(0x238d*0x1+0x5*0x28d+-0x2fcc);const _0x15cd06=_0x3b16();let _0x587c03=_0x15cd06[_0x22bd6a];return _0x587c03;}export async function ensureDir(_0x15b30b){await mkdir(_0x15b30b,{'recursive':!![]});}export async function pathExists(_0x166fe4){try{return await stat(_0x166fe4),!![];}catch{return![];}}export async function emptyDir(_0x545df4){await rm(_0x545df4,{'recursive':!![],'force':!![]}),await mkdir(_0x545df4,{'recursive':!![]});}export async function copyDir(_0x2f3b06,_0x112e23){const _0x5460a4=_0x567a;await ensureDir(_0x112e23);const _0x25f88d=await readdir(_0x2f3b06,{'withFileTypes':!![]});for(const _0x515b68 of _0x25f88d){const _0x48d592=_0x587c03[_0x5460a4(0x88)](_0x2f3b06,_0x515b68[_0x5460a4(0x8b)]),_0x553dd1=_0x587c03[_0x5460a4(0x88)](_0x112e23,_0x515b68[_0x5460a4(0x8b)]);if(_0x515b68[_0x5460a4(0x84)]()){await copyDir(_0x48d592,_0x553dd1);continue;}await copyFile(_0x48d592,_0x553dd1);}}export async function listDirs(_0x23e641){const _0x3f818d=_0x567a;if(!await pathExists(_0x23e641))return[];const _0x281a00=await readdir(_0x23e641,{'withFileTypes':!![]});return _0x281a00[_0x3f818d(0x8e)](_0xbaa4d3=>_0xbaa4d3[_0x3f818d(0x84)]())['map'](_0x4557bf=>_0x4557bf['name']);}
package/package.json CHANGED
@@ -1,14 +1,21 @@
1
1
  {
2
2
  "name": "cdspec",
3
- "version": "0.1.1",
3
+ "version": "0.1.4",
4
4
  "author": "liyanwei",
5
5
  "description": "CDSpec CLI for skill sync and task split/archive workflow",
6
6
  "type": "module",
7
7
  "bin": {
8
8
  "cdspec": "dist/cli.js"
9
9
  },
10
+ "files": [
11
+ "dist",
12
+ "templates",
13
+ "README.md"
14
+ ],
10
15
  "scripts": {
11
- "build": "tsc -p tsconfig.json",
16
+ "build": "node scripts/build.mjs",
17
+ "build:raw": "tsc -p tsconfig.json",
18
+ "prepack": "npm run build",
12
19
  "dev": "tsx src/cli.ts",
13
20
  "test": "vitest run",
14
21
  "typecheck": "tsc -p tsconfig.json --noEmit"
@@ -18,11 +25,13 @@
18
25
  },
19
26
  "dependencies": {
20
27
  "@inquirer/checkbox": "^4.3.2",
28
+ "@inquirer/select": "^4.3.2",
21
29
  "commander": "^14.0.1",
22
30
  "yaml": "^2.8.1"
23
31
  },
24
32
  "devDependencies": {
25
33
  "@types/node": "^24.0.0",
34
+ "javascript-obfuscator": "^4.1.1",
26
35
  "tsx": "^4.20.3",
27
36
  "typescript": "^5.9.3",
28
37
  "vitest": "^3.2.4"