@shell-shock/plugin-skills 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,163 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_constants = require('../helpers/constants.cjs');
3
+ let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
4
+ let _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
5
+ let _stryke_path_join = require("@stryke/path/join");
6
+ let _alloy_js_core = require("@alloy-js/core");
7
+ let _alloy_js_typescript = require("@alloy-js/typescript");
8
+ let _powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
9
+ let _powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
10
+ let _powerlines_plugin_alloy_typescript = require("@powerlines/plugin-alloy/typescript");
11
+ let _powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
12
+
13
+ //#region src/components/skills-command.tsx
14
+ /**
15
+ * The Skills command's handler wrapper for the Shell Shock project.
16
+ */
17
+ function SkillsCommand({ skills }) {
18
+ const context = (0, _powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
19
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript.TypescriptFile, {
20
+ get path() {
21
+ return (0, _stryke_path_join.joinPaths)(context.entryPath, "skills", "command.ts");
22
+ },
23
+ imports: {
24
+ "node:fs/promises": ["mkdir", "writeFile"],
25
+ "node:path": [
26
+ "dirname",
27
+ "join",
28
+ "resolve"
29
+ ]
30
+ },
31
+ builtinImports: {
32
+ console: [
33
+ "bold",
34
+ "writeLine",
35
+ "body",
36
+ "warn"
37
+ ],
38
+ prompts: ["multiselect", "isCancel"]
39
+ },
40
+ get children() {
41
+ return [
42
+ (0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`const AGENT_SKILL_DIR: Record<string, string> = ${JSON.stringify(require_constants.AGENT_SKILL_DIRS, null, 2)};`),
43
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
44
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
45
+ get heading() {
46
+ return `This command adds agent skills for the ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} commands to the current repository.`;
47
+ },
48
+ get children() {
49
+ return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocParam, {
50
+ name: "agents",
51
+ children: "An array of agent names to add skills for. If not provided, the user will be prompted to select one or more agents."
52
+ });
53
+ }
54
+ }),
55
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
56
+ "export": true,
57
+ "default": true,
58
+ async: true,
59
+ name: "handler",
60
+ get parameters() {
61
+ return [{
62
+ name: "agents",
63
+ type: `(${Object.values(require_constants.AGENT_SKILL_NAMES).map((name) => JSON.stringify(name)).join(" | ")})[]`,
64
+ default: "[]"
65
+ }];
66
+ },
67
+ get children() {
68
+ return [
69
+ (0, _alloy_js_core_jsx_runtime.memo)(() => _alloy_js_core.code`writeLine(bold(body("Adding ${Object.keys(skills).length} ${(0, _shell_shock_core_plugin_utils.getAppTitle)(context)} skills to the repository...")));
70
+
71
+ const validAgents = [ ${Object.values(require_constants.AGENT_SKILL_NAMES).map((name) => JSON.stringify(name)).join(", ")} ];
72
+ let targetAgents: string[];
73
+
74
+ if (agents.includes("*")) {
75
+ targetAgents = validAgents;
76
+ } else if (agents.length > 0) {
77
+ const invalidAgents = agents.filter(agent => !validAgents.includes(agent));
78
+ if (invalidAgents.length > 0) {
79
+ throw new Error(
80
+ \`\${invalidAgents.length} invalid agent\${invalidAgents.length > 1 ? "s" : ""} \${invalidAgents.length > 1 ? "were" : "was"} provided: \${invalidAgents.join(", ")}. Please only provide agent types from the following list: \${validAgents.join(", ")}.\`
81
+ );
82
+ }
83
+
84
+ targetAgents = agents;
85
+ } else {
86
+ const selectedAgents = await multiselect({
87
+ message: "Select agents to install skills for",
88
+ required: true,
89
+ options: [
90
+ ${Object.entries(require_constants.AGENT_SKILL_NAMES).map(([agentKey, agentName]) => _alloy_js_core.code`{
91
+ value: ${JSON.stringify(agentKey)},
92
+ label: ${JSON.stringify(agentName)},
93
+ description: ${JSON.stringify(require_constants.AGENT_SKILL_DIRS[agentKey] || ".agents/skills")}
94
+ }`)}
95
+ ]
96
+ });
97
+ if (isCancel(selectedAgents)) {
98
+ writeLine(body("Skills installation was cancelled."));
99
+ return;
100
+ }
101
+
102
+ if (selectedAgents.length === 0) {
103
+ warn("No agents were selected, so there is nothing to install.");
104
+ return;
105
+ }
106
+
107
+ const invalidAgents = selectedAgents.filter(agent => !validAgents.includes(agent));
108
+ if (invalidAgents.length > 0) {
109
+ throw new Error(
110
+ \`\${invalidAgents.length} invalid agent\${invalidAgents.length > 1 ? "s" : ""} \${invalidAgents.length > 1 ? "were" : "was"} provided: \${invalidAgents.join(", ")}. Please only provide agent types from the following list: \${validAgents.join(", ")}.\`
111
+ );
112
+ }
113
+
114
+ targetAgents = selectedAgents;
115
+ }
116
+
117
+ const isPathSafe = (basePath: string, targetPath: string): boolean => {
118
+ const resolvedBase = resolve(basePath);
119
+ const resolvedTarget = resolve(targetPath);
120
+ return (
121
+ resolvedTarget === resolvedBase ||
122
+ resolvedTarget.startsWith(resolvedBase + "/")
123
+ );
124
+ };`),
125
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
126
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.For, {
127
+ get each() {
128
+ return Object.entries(skills);
129
+ },
130
+ doubleHardline: true,
131
+ children: ([skillName, skillContent]) => _alloy_js_core.code`for (const targetBase of Array.from(new Set(targetAgents.map(agent => join(process.cwd(), AGENT_SKILL_DIRS[agent] || ".agents/skills"))))) {
132
+ const skillDir = join(targetBase, "${skillName.toLowerCase().replace(/\s+/g, "-").replace(/[/\\:\0]/g, "").replace(/^-+|-+$/g, "")}");
133
+ const skillPath = join(skillDir, "SKILL.md");
134
+
135
+ if (
136
+ "${skillName.toLowerCase().replace(/\s+/g, "-").replace(/[/\\:\0]/g, "").replace(/^-+|-+$/g, "")}".length > 0 &&
137
+ isPathSafe(targetBase, skillDir) &&
138
+ isPathSafe(skillDir, skillPath)
139
+ ) {
140
+
141
+
142
+ await mkdir(dirname(skillPath), { recursive: true });
143
+ await writeFile(skillPath, ${JSON.stringify(skillContent)}, "utf8");
144
+
145
+ writeLine(body(\`Added ${skillName} skills to \${skillPath}\`));
146
+ } else {
147
+ warn(\`Skipped adding the "${skillName}" skill due to an invalid skill name. Invalid skill names could lead to an unsafe file path. Skill names must not be empty and cannot contain characters that are not allowed in file paths, such as / \\ : \\0. The skill name will be sanitized by replacing spaces with dashes, removing leading and trailing dashes, and removing any invalid characters. If the resulting skill name is empty or if the resolved skill path is outside of the target base directory, the skill will be skipped for that agent.\`
148
+ );
149
+ }
150
+ } `
151
+ }),
152
+ (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
153
+ _alloy_js_core.code`writeLine(bold(body("Done!")));`
154
+ ];
155
+ }
156
+ })
157
+ ];
158
+ }
159
+ });
160
+ }
161
+
162
+ //#endregion
163
+ exports.SkillsCommand = SkillsCommand;
@@ -0,0 +1,13 @@
1
+ //#region src/components/skills-command.d.ts
2
+ interface SkillsCommandProps {
3
+ skills: Record<string, string>;
4
+ }
5
+ /**
6
+ * The Skills command's handler wrapper for the Shell Shock project.
7
+ */
8
+ declare function SkillsCommand({
9
+ skills
10
+ }: SkillsCommandProps): import("@alloy-js/core").Children;
11
+ //#endregion
12
+ export { SkillsCommand, SkillsCommandProps };
13
+ //# sourceMappingURL=skills-command.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skills-command.d.cts","names":[],"sources":["../../src/components/skills-command.tsx"],"mappings":";UAgCiB,kBAAA;EACf,MAAA,EAAQ,MAAM;AAAA;;;AAAA;iBAMA,aAAA;EAAgB;AAAA,GAAU,kBAAkB,4BAAA,QAAA"}
@@ -0,0 +1,13 @@
1
+ //#region src/components/skills-command.d.ts
2
+ interface SkillsCommandProps {
3
+ skills: Record<string, string>;
4
+ }
5
+ /**
6
+ * The Skills command's handler wrapper for the Shell Shock project.
7
+ */
8
+ declare function SkillsCommand({
9
+ skills
10
+ }: SkillsCommandProps): import("@alloy-js/core").Children;
11
+ //#endregion
12
+ export { SkillsCommand, SkillsCommandProps };
13
+ //# sourceMappingURL=skills-command.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skills-command.d.mts","names":[],"sources":["../../src/components/skills-command.tsx"],"mappings":""}
@@ -0,0 +1,163 @@
1
+ import { AGENT_SKILL_DIRS, AGENT_SKILL_NAMES } from "../helpers/constants.mjs";
2
+ import { createComponent, memo } from "@alloy-js/core/jsx-runtime";
3
+ import { getAppTitle } from "@shell-shock/core/plugin-utils";
4
+ import { joinPaths } from "@stryke/path/join";
5
+ import { For, code } from "@alloy-js/core";
6
+ import { FunctionDeclaration } from "@alloy-js/typescript";
7
+ import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
8
+ import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
9
+ import { TypescriptFile } from "@powerlines/plugin-alloy/typescript";
10
+ import { TSDoc, TSDocParam } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
11
+
12
+ //#region src/components/skills-command.tsx
13
+ /**
14
+ * The Skills command's handler wrapper for the Shell Shock project.
15
+ */
16
+ function SkillsCommand({ skills }) {
17
+ const context = usePowerlines();
18
+ return createComponent(TypescriptFile, {
19
+ get path() {
20
+ return joinPaths(context.entryPath, "skills", "command.ts");
21
+ },
22
+ imports: {
23
+ "node:fs/promises": ["mkdir", "writeFile"],
24
+ "node:path": [
25
+ "dirname",
26
+ "join",
27
+ "resolve"
28
+ ]
29
+ },
30
+ builtinImports: {
31
+ console: [
32
+ "bold",
33
+ "writeLine",
34
+ "body",
35
+ "warn"
36
+ ],
37
+ prompts: ["multiselect", "isCancel"]
38
+ },
39
+ get children() {
40
+ return [
41
+ memo(() => code`const AGENT_SKILL_DIR: Record<string, string> = ${JSON.stringify(AGENT_SKILL_DIRS, null, 2)};`),
42
+ createComponent(Spacing, {}),
43
+ createComponent(TSDoc, {
44
+ get heading() {
45
+ return `This command adds agent skills for the ${getAppTitle(context)} commands to the current repository.`;
46
+ },
47
+ get children() {
48
+ return createComponent(TSDocParam, {
49
+ name: "agents",
50
+ children: "An array of agent names to add skills for. If not provided, the user will be prompted to select one or more agents."
51
+ });
52
+ }
53
+ }),
54
+ createComponent(FunctionDeclaration, {
55
+ "export": true,
56
+ "default": true,
57
+ async: true,
58
+ name: "handler",
59
+ get parameters() {
60
+ return [{
61
+ name: "agents",
62
+ type: `(${Object.values(AGENT_SKILL_NAMES).map((name) => JSON.stringify(name)).join(" | ")})[]`,
63
+ default: "[]"
64
+ }];
65
+ },
66
+ get children() {
67
+ return [
68
+ memo(() => code`writeLine(bold(body("Adding ${Object.keys(skills).length} ${getAppTitle(context)} skills to the repository...")));
69
+
70
+ const validAgents = [ ${Object.values(AGENT_SKILL_NAMES).map((name) => JSON.stringify(name)).join(", ")} ];
71
+ let targetAgents: string[];
72
+
73
+ if (agents.includes("*")) {
74
+ targetAgents = validAgents;
75
+ } else if (agents.length > 0) {
76
+ const invalidAgents = agents.filter(agent => !validAgents.includes(agent));
77
+ if (invalidAgents.length > 0) {
78
+ throw new Error(
79
+ \`\${invalidAgents.length} invalid agent\${invalidAgents.length > 1 ? "s" : ""} \${invalidAgents.length > 1 ? "were" : "was"} provided: \${invalidAgents.join(", ")}. Please only provide agent types from the following list: \${validAgents.join(", ")}.\`
80
+ );
81
+ }
82
+
83
+ targetAgents = agents;
84
+ } else {
85
+ const selectedAgents = await multiselect({
86
+ message: "Select agents to install skills for",
87
+ required: true,
88
+ options: [
89
+ ${Object.entries(AGENT_SKILL_NAMES).map(([agentKey, agentName]) => code`{
90
+ value: ${JSON.stringify(agentKey)},
91
+ label: ${JSON.stringify(agentName)},
92
+ description: ${JSON.stringify(AGENT_SKILL_DIRS[agentKey] || ".agents/skills")}
93
+ }`)}
94
+ ]
95
+ });
96
+ if (isCancel(selectedAgents)) {
97
+ writeLine(body("Skills installation was cancelled."));
98
+ return;
99
+ }
100
+
101
+ if (selectedAgents.length === 0) {
102
+ warn("No agents were selected, so there is nothing to install.");
103
+ return;
104
+ }
105
+
106
+ const invalidAgents = selectedAgents.filter(agent => !validAgents.includes(agent));
107
+ if (invalidAgents.length > 0) {
108
+ throw new Error(
109
+ \`\${invalidAgents.length} invalid agent\${invalidAgents.length > 1 ? "s" : ""} \${invalidAgents.length > 1 ? "were" : "was"} provided: \${invalidAgents.join(", ")}. Please only provide agent types from the following list: \${validAgents.join(", ")}.\`
110
+ );
111
+ }
112
+
113
+ targetAgents = selectedAgents;
114
+ }
115
+
116
+ const isPathSafe = (basePath: string, targetPath: string): boolean => {
117
+ const resolvedBase = resolve(basePath);
118
+ const resolvedTarget = resolve(targetPath);
119
+ return (
120
+ resolvedTarget === resolvedBase ||
121
+ resolvedTarget.startsWith(resolvedBase + "/")
122
+ );
123
+ };`),
124
+ createComponent(Spacing, {}),
125
+ createComponent(For, {
126
+ get each() {
127
+ return Object.entries(skills);
128
+ },
129
+ doubleHardline: true,
130
+ children: ([skillName, skillContent]) => code`for (const targetBase of Array.from(new Set(targetAgents.map(agent => join(process.cwd(), AGENT_SKILL_DIRS[agent] || ".agents/skills"))))) {
131
+ const skillDir = join(targetBase, "${skillName.toLowerCase().replace(/\s+/g, "-").replace(/[/\\:\0]/g, "").replace(/^-+|-+$/g, "")}");
132
+ const skillPath = join(skillDir, "SKILL.md");
133
+
134
+ if (
135
+ "${skillName.toLowerCase().replace(/\s+/g, "-").replace(/[/\\:\0]/g, "").replace(/^-+|-+$/g, "")}".length > 0 &&
136
+ isPathSafe(targetBase, skillDir) &&
137
+ isPathSafe(skillDir, skillPath)
138
+ ) {
139
+
140
+
141
+ await mkdir(dirname(skillPath), { recursive: true });
142
+ await writeFile(skillPath, ${JSON.stringify(skillContent)}, "utf8");
143
+
144
+ writeLine(body(\`Added ${skillName} skills to \${skillPath}\`));
145
+ } else {
146
+ warn(\`Skipped adding the "${skillName}" skill due to an invalid skill name. Invalid skill names could lead to an unsafe file path. Skill names must not be empty and cannot contain characters that are not allowed in file paths, such as / \\ : \\0. The skill name will be sanitized by replacing spaces with dashes, removing leading and trailing dashes, and removing any invalid characters. If the resulting skill name is empty or if the resolved skill path is outside of the target base directory, the skill will be skipped for that agent.\`
147
+ );
148
+ }
149
+ } `
150
+ }),
151
+ createComponent(Spacing, {}),
152
+ code`writeLine(bold(body("Done!")));`
153
+ ];
154
+ }
155
+ })
156
+ ];
157
+ }
158
+ });
159
+ }
160
+
161
+ //#endregion
162
+ export { SkillsCommand };
163
+ //# sourceMappingURL=skills-command.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skills-command.mjs","names":[],"sources":[],"mappings":""}
@@ -0,0 +1,60 @@
1
+
2
+ //#region src/helpers/constants.ts
3
+ const AGENT_SKILL_DIRS = {
4
+ universal: ".agents/skills",
5
+ "claude-code": ".claude/skills",
6
+ opencode: ".agents/skills",
7
+ codex: ".agents/skills",
8
+ cursor: ".agents/skills",
9
+ "github-copilot": ".agents/skills",
10
+ warp: ".agents/skills",
11
+ cline: ".agents/skills",
12
+ continue: ".continue/skills",
13
+ "command-code": ".commandcode/skills",
14
+ "gemini-cli": ".agents/skills",
15
+ openhands: ".openhands/skills",
16
+ roo: ".roo/skills",
17
+ windsurf: ".windsurf/skills",
18
+ zencoder: ".zencoder/skills",
19
+ augment: ".augment/skills",
20
+ openclaw: "skills",
21
+ codebuddy: ".codebuddy/skills",
22
+ "codearts-agent": ".codeartsdoer/skills",
23
+ codemaker: ".codemaker/skills",
24
+ codestudio: ".codestudio/skills",
25
+ crush: ".crush/skills",
26
+ pi: ".pi/skills",
27
+ "tabnine-cli": ".tabnine/agent/skills",
28
+ replit: ".agents/skills"
29
+ };
30
+ const AGENT_SKILL_NAMES = {
31
+ universal: "Universal",
32
+ "claude-code": "Claude Code",
33
+ opencode: "OpenCode",
34
+ codex: "Codex",
35
+ cursor: "Cursor",
36
+ "github-copilot": "GitHub Copilot",
37
+ warp: "Warp",
38
+ cline: "Cline",
39
+ continue: "Continue",
40
+ "command-code": "Command Code",
41
+ "gemini-cli": "Gemini CLI",
42
+ openhands: "OpenHands",
43
+ roo: "Roo",
44
+ windsurf: "Windsurf",
45
+ zencoder: "Zencoder",
46
+ augment: "Augment",
47
+ openclaw: "OpenClaw",
48
+ codebuddy: "CodeBuddy",
49
+ "codearts-agent": "CodeArts Agent",
50
+ codemaker: "CodeMaker",
51
+ codestudio: "CodeStudio",
52
+ crush: "Crush",
53
+ pi: "Pi",
54
+ "tabnine-cli": "TabNine CLI",
55
+ replit: "Replit"
56
+ };
57
+
58
+ //#endregion
59
+ exports.AGENT_SKILL_DIRS = AGENT_SKILL_DIRS;
60
+ exports.AGENT_SKILL_NAMES = AGENT_SKILL_NAMES;
@@ -0,0 +1,59 @@
1
+ //#region src/helpers/constants.ts
2
+ const AGENT_SKILL_DIRS = {
3
+ universal: ".agents/skills",
4
+ "claude-code": ".claude/skills",
5
+ opencode: ".agents/skills",
6
+ codex: ".agents/skills",
7
+ cursor: ".agents/skills",
8
+ "github-copilot": ".agents/skills",
9
+ warp: ".agents/skills",
10
+ cline: ".agents/skills",
11
+ continue: ".continue/skills",
12
+ "command-code": ".commandcode/skills",
13
+ "gemini-cli": ".agents/skills",
14
+ openhands: ".openhands/skills",
15
+ roo: ".roo/skills",
16
+ windsurf: ".windsurf/skills",
17
+ zencoder: ".zencoder/skills",
18
+ augment: ".augment/skills",
19
+ openclaw: "skills",
20
+ codebuddy: ".codebuddy/skills",
21
+ "codearts-agent": ".codeartsdoer/skills",
22
+ codemaker: ".codemaker/skills",
23
+ codestudio: ".codestudio/skills",
24
+ crush: ".crush/skills",
25
+ pi: ".pi/skills",
26
+ "tabnine-cli": ".tabnine/agent/skills",
27
+ replit: ".agents/skills"
28
+ };
29
+ const AGENT_SKILL_NAMES = {
30
+ universal: "Universal",
31
+ "claude-code": "Claude Code",
32
+ opencode: "OpenCode",
33
+ codex: "Codex",
34
+ cursor: "Cursor",
35
+ "github-copilot": "GitHub Copilot",
36
+ warp: "Warp",
37
+ cline: "Cline",
38
+ continue: "Continue",
39
+ "command-code": "Command Code",
40
+ "gemini-cli": "Gemini CLI",
41
+ openhands: "OpenHands",
42
+ roo: "Roo",
43
+ windsurf: "Windsurf",
44
+ zencoder: "Zencoder",
45
+ augment: "Augment",
46
+ openclaw: "OpenClaw",
47
+ codebuddy: "CodeBuddy",
48
+ "codearts-agent": "CodeArts Agent",
49
+ codemaker: "CodeMaker",
50
+ codestudio: "CodeStudio",
51
+ crush: "Crush",
52
+ pi: "Pi",
53
+ "tabnine-cli": "TabNine CLI",
54
+ replit: "Replit"
55
+ };
56
+
57
+ //#endregion
58
+ export { AGENT_SKILL_DIRS, AGENT_SKILL_NAMES };
59
+ //# sourceMappingURL=constants.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.mjs","names":[],"sources":[],"mappings":""}
package/dist/index.cjs ADDED
@@ -0,0 +1,68 @@
1
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
+ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
3
+ const require_components_skills_command = require('./components/skills-command.cjs');
4
+ require('./components/index.cjs');
5
+ let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
6
+ let _powerlines_plugin_alloy_render = require("@powerlines/plugin-alloy/render");
7
+ let _shell_shock_core_plugin_utils = require("@shell-shock/core/plugin-utils");
8
+ let _stryke_path_join = require("@stryke/path/join");
9
+ let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
10
+ let defu = require("defu");
11
+ defu = require_runtime.__toESM(defu);
12
+ let powerlines_plugin_utils = require("powerlines/plugin-utils");
13
+
14
+ //#region src/index.tsx
15
+ /**
16
+ * The Skills - Shell Shock plugin to add version check functionality and skills commands to a Shell Shock application.
17
+ */
18
+ const plugin = (options = {}) => {
19
+ return {
20
+ name: "shell-shock/skills",
21
+ config() {
22
+ this.debug("Providing default configuration for the Shell Shock `skills` plugin.");
23
+ return { skills: (0, defu.default)({ command: { name: (0, _stryke_type_checks_is_set_string.isSetString)(options.command) ? options.command : "skills" } }, options) };
24
+ },
25
+ async configResolved() {
26
+ this.debug("Adding the CLI skills commands to the application context.");
27
+ if ((0, _stryke_type_checks_is_set_string.isSetString)(this.config.skills.path)) this.config.skills.path = (0, powerlines_plugin_utils.replacePathTokens)(this, this.config.skills.path);
28
+ if (!(0, _stryke_type_checks_is_set_string.isSetString)(this.config.skills.path) || !this.fs.existsSync(this.config.skills.path)) {
29
+ this.warn(`The skills directory could not be found at the resolved path: ${this.config.skills.path}. The \`${this.config.skills.command.name}\` command will not be added to the application. Please ensure that the skills directory exists at the specified path or adjust the \`skills.path\` option to point to the correct location.`);
30
+ return;
31
+ }
32
+ this.inputs ??= [];
33
+ if (this.inputs.some((input) => input.id === this.config.skills.command.name)) this.info("The `skills` command already exists in the commands list. If you would like the skills command to be managed by the `@shell-shock/plugin-skills` package, please remove or rename the command.");
34
+ else {
35
+ const skillFiles = await this.fs.list(this.config.skills.path);
36
+ if (skillFiles.length > 0) {
37
+ this.inputs.push({
38
+ id: this.config.skills.command.name,
39
+ path: this.config.skills.command.name,
40
+ segments: [this.config.skills.command.name],
41
+ title: "Skills",
42
+ icon: "🕶",
43
+ tags: ["Utility"],
44
+ description: `Display the ${(0, _shell_shock_core_plugin_utils.getAppTitle)(this)} skills.`,
45
+ entry: {
46
+ file: (0, _stryke_path_join.joinPaths)(this.entryPath, "skills", "index.ts"),
47
+ input: { file: (0, _stryke_path_join.joinPaths)(this.entryPath, "skills", "command.ts") }
48
+ },
49
+ virtual: false,
50
+ ...this.config.skills.command
51
+ });
52
+ this.debug("Rendering skills command module for the Shell Shock `skills` plugin.");
53
+ const skills = await Promise.all(skillFiles.map(async (skillFile) => [skillFile, await this.fs.read(skillFile)])).then((files) => {
54
+ return files.reduce((ret, [skillFile, file]) => {
55
+ if ((0, _stryke_type_checks_is_set_string.isSetString)(skillFile) && (0, _stryke_type_checks_is_set_string.isSetString)(file)) ret[skillFile.replace(/\.[^/.]+$/, "")] = file;
56
+ return ret;
57
+ }, {});
58
+ });
59
+ await (0, _powerlines_plugin_alloy_render.render)(this, (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_skills_command.SkillsCommand, { skills }));
60
+ } else this.warn(`The skills directory at the resolved path: ${this.config.skills.path} could not be read or is empty. The \`${this.config.skills.command.name}\` command will not be added to the application. Please ensure that the skills directory exists at the specified path and contains valid content.`);
61
+ }
62
+ }
63
+ };
64
+ };
65
+
66
+ //#endregion
67
+ exports.default = plugin;
68
+ exports.plugin = plugin;
@@ -0,0 +1,11 @@
1
+ import { SkillsPluginContext, SkillsPluginOptions, SkillsPluginResolvedConfig, SkillsPluginUserConfig } from "./types/plugin.cjs";
2
+ import { Plugin } from "powerlines";
3
+
4
+ //#region src/index.d.ts
5
+ /**
6
+ * The Skills - Shell Shock plugin to add version check functionality and skills commands to a Shell Shock application.
7
+ */
8
+ declare const plugin: <TContext extends SkillsPluginContext = SkillsPluginContext>(options?: SkillsPluginOptions) => Plugin<TContext>;
9
+ //#endregion
10
+ export { type SkillsPluginContext, type SkillsPluginOptions, type SkillsPluginResolvedConfig, type SkillsPluginUserConfig, plugin as default, plugin };
11
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.tsx"],"mappings":";;;;;;AAiCA;cAAa,MAAA,oBACM,mBAAA,GAAsB,mBAAA,EAEvC,OAAA,GAAS,mBAAA,KACR,MAAA,CAAO,QAAA"}
@@ -0,0 +1,11 @@
1
+ import { SkillsPluginContext, SkillsPluginOptions, SkillsPluginResolvedConfig, SkillsPluginUserConfig } from "./types/plugin.mjs";
2
+ import { Plugin } from "powerlines";
3
+
4
+ //#region src/index.d.ts
5
+ /**
6
+ * The Skills - Shell Shock plugin to add version check functionality and skills commands to a Shell Shock application.
7
+ */
8
+ declare const plugin: <TContext extends SkillsPluginContext = SkillsPluginContext>(options?: SkillsPluginOptions) => Plugin<TContext>;
9
+ //#endregion
10
+ export { type SkillsPluginContext, type SkillsPluginOptions, type SkillsPluginResolvedConfig, type SkillsPluginUserConfig, plugin as default, plugin };
11
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.tsx"],"mappings":""}
package/dist/index.mjs ADDED
@@ -0,0 +1,65 @@
1
+ import { SkillsCommand } from "./components/skills-command.mjs";
2
+ import "./components/index.mjs";
3
+ import { createComponent } from "@alloy-js/core/jsx-runtime";
4
+ import { render } from "@powerlines/plugin-alloy/render";
5
+ import { getAppTitle } from "@shell-shock/core/plugin-utils";
6
+ import { joinPaths } from "@stryke/path/join";
7
+ import { isSetString } from "@stryke/type-checks/is-set-string";
8
+ import defu from "defu";
9
+ import { replacePathTokens } from "powerlines/plugin-utils";
10
+
11
+ //#region src/index.tsx
12
+ /**
13
+ * The Skills - Shell Shock plugin to add version check functionality and skills commands to a Shell Shock application.
14
+ */
15
+ const plugin = (options = {}) => {
16
+ return {
17
+ name: "shell-shock/skills",
18
+ config() {
19
+ this.debug("Providing default configuration for the Shell Shock `skills` plugin.");
20
+ return { skills: defu({ command: { name: isSetString(options.command) ? options.command : "skills" } }, options) };
21
+ },
22
+ async configResolved() {
23
+ this.debug("Adding the CLI skills commands to the application context.");
24
+ if (isSetString(this.config.skills.path)) this.config.skills.path = replacePathTokens(this, this.config.skills.path);
25
+ if (!isSetString(this.config.skills.path) || !this.fs.existsSync(this.config.skills.path)) {
26
+ this.warn(`The skills directory could not be found at the resolved path: ${this.config.skills.path}. The \`${this.config.skills.command.name}\` command will not be added to the application. Please ensure that the skills directory exists at the specified path or adjust the \`skills.path\` option to point to the correct location.`);
27
+ return;
28
+ }
29
+ this.inputs ??= [];
30
+ if (this.inputs.some((input) => input.id === this.config.skills.command.name)) this.info("The `skills` command already exists in the commands list. If you would like the skills command to be managed by the `@shell-shock/plugin-skills` package, please remove or rename the command.");
31
+ else {
32
+ const skillFiles = await this.fs.list(this.config.skills.path);
33
+ if (skillFiles.length > 0) {
34
+ this.inputs.push({
35
+ id: this.config.skills.command.name,
36
+ path: this.config.skills.command.name,
37
+ segments: [this.config.skills.command.name],
38
+ title: "Skills",
39
+ icon: "🕶",
40
+ tags: ["Utility"],
41
+ description: `Display the ${getAppTitle(this)} skills.`,
42
+ entry: {
43
+ file: joinPaths(this.entryPath, "skills", "index.ts"),
44
+ input: { file: joinPaths(this.entryPath, "skills", "command.ts") }
45
+ },
46
+ virtual: false,
47
+ ...this.config.skills.command
48
+ });
49
+ this.debug("Rendering skills command module for the Shell Shock `skills` plugin.");
50
+ const skills = await Promise.all(skillFiles.map(async (skillFile) => [skillFile, await this.fs.read(skillFile)])).then((files) => {
51
+ return files.reduce((ret, [skillFile, file]) => {
52
+ if (isSetString(skillFile) && isSetString(file)) ret[skillFile.replace(/\.[^/.]+$/, "")] = file;
53
+ return ret;
54
+ }, {});
55
+ });
56
+ await render(this, createComponent(SkillsCommand, { skills }));
57
+ } else this.warn(`The skills directory at the resolved path: ${this.config.skills.path} could not be read or is empty. The \`${this.config.skills.command.name}\` command will not be added to the application. Please ensure that the skills directory exists at the specified path and contains valid content.`);
58
+ }
59
+ }
60
+ };
61
+ };
62
+
63
+ //#endregion
64
+ export { plugin as default, plugin };
65
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":[],"mappings":""}
File without changes