@moostjs/event-cli 0.5.32 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -3
- package/dist/index.cjs +32 -9
- package/dist/index.d.ts +12 -12
- package/dist/index.mjs +15 -10
- package/package.json +38 -32
- package/scripts/setup-skills.js +78 -0
- package/skills/moostjs-event-cli/SKILL.md +38 -0
- package/skills/moostjs-event-cli/advanced.md +202 -0
- package/skills/moostjs-event-cli/commands.md +152 -0
- package/skills/moostjs-event-cli/controllers.md +142 -0
- package/skills/moostjs-event-cli/core.md +114 -0
- package/skills/moostjs-event-cli/help.md +160 -0
- package/skills/moostjs-event-cli/interceptors.md +160 -0
- package/skills/moostjs-event-cli/options.md +180 -0
package/README.md
CHANGED
|
@@ -29,13 +29,35 @@ You can also provide a name for your project:
|
|
|
29
29
|
npm create moost my-cli-app -- --cli
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
This command will initiate a setup tool that will guide you through the project initialization process. It will prompt you to
|
|
32
|
+
This command will initiate a setup tool that will guide you through the project initialization process. It will prompt you to configure:
|
|
33
33
|
|
|
34
|
-
-
|
|
35
|
-
-
|
|
34
|
+
- Project and package name.
|
|
35
|
+
- Whether to add do-me-lint (smart eslint installer).
|
|
36
36
|
|
|
37
37
|
## [Official Documentation](https://moost.org/cliapp/)
|
|
38
38
|
|
|
39
|
+
## AI Agent Skills
|
|
40
|
+
|
|
41
|
+
This package ships with structured skill files for AI coding agents (Claude Code, Cursor, Windsurf, Codex, etc.).
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# Project-local (recommended — version-locked, commits with your repo)
|
|
45
|
+
npx moostjs-event-cli-skill
|
|
46
|
+
|
|
47
|
+
# Global (available across all your projects)
|
|
48
|
+
npx moostjs-event-cli-skill --global
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
To keep skills automatically up-to-date, add a postinstall script to your `package.json`:
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
{
|
|
55
|
+
"scripts": {
|
|
56
|
+
"postinstall": "moostjs-event-cli-skill --postinstall"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
39
61
|
## Contributing
|
|
40
62
|
|
|
41
63
|
We are excited to welcome contributors who are passionate about improving Moostjs. No matter your level of experience, your unique perspective and skills can make valuable contributions to our growing community.
|
package/dist/index.cjs
CHANGED
|
@@ -23,6 +23,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
23
|
//#endregion
|
|
24
24
|
const moost = __toESM(require("moost"));
|
|
25
25
|
const __wooksjs_event_cli = __toESM(require("@wooksjs/event-cli"));
|
|
26
|
+
const __wooksjs_event_core = __toESM(require("@wooksjs/event-core"));
|
|
26
27
|
|
|
27
28
|
//#region packages/event-cli/src/meta-types.ts
|
|
28
29
|
function getCliMate() {
|
|
@@ -47,7 +48,7 @@ function getCliMate() {
|
|
|
47
48
|
* @returns
|
|
48
49
|
*/ function Cli(path) {
|
|
49
50
|
return getCliMate().decorate("handlers", {
|
|
50
|
-
path: path?.
|
|
51
|
+
path: path?.replaceAll(/\s+/g, "/"),
|
|
51
52
|
type: "CLI"
|
|
52
53
|
}, true);
|
|
53
54
|
}
|
|
@@ -164,7 +165,7 @@ const CONTEXT_TYPE = "CLI";
|
|
|
164
165
|
* ```
|
|
165
166
|
*/ var MoostCli = class {
|
|
166
167
|
async onNotFound() {
|
|
167
|
-
const pathParams = (0,
|
|
168
|
+
const pathParams = (0, __wooksjs_event_core.current)().get(__wooksjs_event_cli.cliKind.keys.pathParams) || [];
|
|
168
169
|
const response = await (0, moost.defineMoostEventHandler)({
|
|
169
170
|
loggerTitle: LOGGER_TITLE,
|
|
170
171
|
getIterceptorHandler: () => this.moost?.getGlobalInterceptorHandler(),
|
|
@@ -187,8 +188,8 @@ const CONTEXT_TYPE = "CLI";
|
|
|
187
188
|
for (const handler of opts.handlers) {
|
|
188
189
|
if (handler.type !== "CLI") continue;
|
|
189
190
|
const path = typeof handler.path === "string" ? handler.path : typeof opts.method === "string" ? opts.method : "";
|
|
190
|
-
const prefix = opts.prefix.
|
|
191
|
-
const makePath = (p) => `${prefix}/${p}`.
|
|
191
|
+
const prefix = opts.prefix.replaceAll(/\s+/g, "/") || "";
|
|
192
|
+
const makePath = (p) => `${prefix}/${p}`.replaceAll(/\/\/+/g, "/").replaceAll(/\/\\:/g, "\\:").replaceAll(/^\/+/g, "");
|
|
192
193
|
const targetPath = makePath(path);
|
|
193
194
|
fn = (0, moost.defineMoostEventHandler)({
|
|
194
195
|
contextType: CONTEXT_TYPE,
|
|
@@ -196,6 +197,7 @@ const CONTEXT_TYPE = "CLI";
|
|
|
196
197
|
getIterceptorHandler: opts.getIterceptorHandler,
|
|
197
198
|
getControllerInstance: opts.getInstance,
|
|
198
199
|
controllerMethod: opts.method,
|
|
200
|
+
controllerName: opts.controllerName,
|
|
199
201
|
resolveArgs: opts.resolveArgs,
|
|
200
202
|
logErrors: this.opts?.debug,
|
|
201
203
|
targetPath,
|
|
@@ -285,10 +287,13 @@ const aliasTypes = [
|
|
|
285
287
|
* new Moost().applyGlobalInterceptors(cliHelpInterceptor({ colors: true }))
|
|
286
288
|
* ```
|
|
287
289
|
* @param opts {} { helpOptions: ['help', 'h'], colors: true } cli options to invoke help renderer
|
|
288
|
-
* @returns
|
|
289
|
-
*/ const cliHelpInterceptor = (opts) => (0, moost.
|
|
290
|
+
* @returns TInterceptorDef
|
|
291
|
+
*/ const cliHelpInterceptor = (opts) => (0, moost.defineBeforeInterceptor)((reply) => {
|
|
290
292
|
try {
|
|
291
|
-
if ((0, __wooksjs_event_cli.useAutoHelp)(opts?.helpOptions, opts?.colors))
|
|
293
|
+
if ((0, __wooksjs_event_cli.useAutoHelp)(opts?.helpOptions, opts?.colors)) {
|
|
294
|
+
reply("");
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
292
297
|
} catch (error) {}
|
|
293
298
|
if (opts?.lookupLevel) {
|
|
294
299
|
const { getMethod } = (0, moost.useControllerContext)();
|
|
@@ -453,9 +458,27 @@ Object.defineProperty(exports, 'Param', {
|
|
|
453
458
|
}
|
|
454
459
|
});
|
|
455
460
|
exports.cliHelpInterceptor = cliHelpInterceptor;
|
|
456
|
-
Object.defineProperty(exports, '
|
|
461
|
+
Object.defineProperty(exports, 'cliKind', {
|
|
462
|
+
enumerable: true,
|
|
463
|
+
get: function () {
|
|
464
|
+
return __wooksjs_event_cli.cliKind;
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
Object.defineProperty(exports, 'defineAfterInterceptor', {
|
|
468
|
+
enumerable: true,
|
|
469
|
+
get: function () {
|
|
470
|
+
return moost.defineAfterInterceptor;
|
|
471
|
+
}
|
|
472
|
+
});
|
|
473
|
+
Object.defineProperty(exports, 'defineBeforeInterceptor', {
|
|
474
|
+
enumerable: true,
|
|
475
|
+
get: function () {
|
|
476
|
+
return moost.defineBeforeInterceptor;
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
Object.defineProperty(exports, 'defineInterceptor', {
|
|
457
480
|
enumerable: true,
|
|
458
481
|
get: function () {
|
|
459
|
-
return
|
|
482
|
+
return moost.defineInterceptor;
|
|
460
483
|
}
|
|
461
484
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { WooksCli, TWooksCliOptions } from '@wooksjs/event-cli';
|
|
2
|
-
export {
|
|
2
|
+
export { cliKind } from '@wooksjs/event-cli';
|
|
3
3
|
import * as moost from 'moost';
|
|
4
|
-
import { TMoostAdapter, Moost, TMoostAdapterOptions } from 'moost';
|
|
5
|
-
export { Controller, Description, Intercept, Optional, Param, TInterceptorPriority,
|
|
4
|
+
import { TFunction, TMoostAdapter, Moost, TMoostAdapterOptions } from 'moost';
|
|
5
|
+
export { Controller, Description, Intercept, Optional, Param, TInterceptorPriority, defineAfterInterceptor, defineBeforeInterceptor, defineInterceptor } from 'moost';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* ## Define CLI Command
|
|
@@ -74,11 +74,11 @@ declare function CliGlobalOption(option: {
|
|
|
74
74
|
value?: string;
|
|
75
75
|
}): ClassDecorator;
|
|
76
76
|
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
/** Handler metadata for CLI events, carrying the command path. */
|
|
79
78
|
interface TCliHandlerMeta {
|
|
80
79
|
path: string;
|
|
81
80
|
}
|
|
81
|
+
/** Configuration options for the MoostCli adapter. */
|
|
82
82
|
interface TMoostCliOpts {
|
|
83
83
|
/**
|
|
84
84
|
* WooksCli options or instance
|
|
@@ -91,11 +91,11 @@ interface TMoostCliOpts {
|
|
|
91
91
|
/**
|
|
92
92
|
* Array of cli options applicable to every cli command
|
|
93
93
|
*/
|
|
94
|
-
globalCliOptions?:
|
|
94
|
+
globalCliOptions?: {
|
|
95
95
|
keys: string[];
|
|
96
96
|
description?: string;
|
|
97
97
|
type?: TFunction;
|
|
98
|
-
}
|
|
98
|
+
}[];
|
|
99
99
|
}
|
|
100
100
|
/**
|
|
101
101
|
* ## Moost Cli Adapter
|
|
@@ -149,7 +149,7 @@ declare class MoostCli implements TMoostAdapter<TCliHandlerMeta> {
|
|
|
149
149
|
* new Moost().applyGlobalInterceptors(cliHelpInterceptor({ colors: true }))
|
|
150
150
|
* ```
|
|
151
151
|
* @param opts {} { helpOptions: ['help', 'h'], colors: true } cli options to invoke help renderer
|
|
152
|
-
* @returns
|
|
152
|
+
* @returns TInterceptorDef
|
|
153
153
|
*/
|
|
154
154
|
declare const cliHelpInterceptor: (opts?: {
|
|
155
155
|
/**
|
|
@@ -167,7 +167,7 @@ declare const cliHelpInterceptor: (opts?: {
|
|
|
167
167
|
* Enable lookup for a command
|
|
168
168
|
*/
|
|
169
169
|
lookupLevel?: number;
|
|
170
|
-
}) => moost.
|
|
170
|
+
}) => moost.TInterceptorDef;
|
|
171
171
|
/**
|
|
172
172
|
* ## @Decorator
|
|
173
173
|
* ### Interceptor Factory for CliHelpRenderer
|
|
@@ -191,7 +191,7 @@ declare const cliHelpInterceptor: (opts?: {
|
|
|
191
191
|
*/
|
|
192
192
|
declare const CliHelpInterceptor: (...opts: Parameters<typeof cliHelpInterceptor>) => ClassDecorator & MethodDecorator;
|
|
193
193
|
|
|
194
|
-
|
|
194
|
+
interface THelpOptions {
|
|
195
195
|
name?: string;
|
|
196
196
|
title?: string;
|
|
197
197
|
maxWidth?: number;
|
|
@@ -199,7 +199,7 @@ type THelpOptions = {
|
|
|
199
199
|
mark?: string;
|
|
200
200
|
colors?: boolean;
|
|
201
201
|
lookupLevel?: number;
|
|
202
|
-
}
|
|
202
|
+
}
|
|
203
203
|
/**
|
|
204
204
|
* Quick CLI App factory class.
|
|
205
205
|
*
|
|
@@ -229,7 +229,7 @@ declare class CliApp extends Moost {
|
|
|
229
229
|
* Each controller can be an object, a class, or a tuple with a name and the controller.
|
|
230
230
|
* @returns {this} The CliApp instance for method chaining.
|
|
231
231
|
*/
|
|
232
|
-
controllers(...controllers:
|
|
232
|
+
controllers(...controllers: (object | Function | [string, object | Function])[]): this;
|
|
233
233
|
/**
|
|
234
234
|
* Configures the CLI help options.
|
|
235
235
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Controller, Description, Intercept, Intercept as Intercept$1, Moost, Optional, Param, Resolve, TInterceptorPriority,
|
|
2
|
-
import { WooksCli,
|
|
1
|
+
import { Controller, Description, Intercept, Intercept as Intercept$1, Moost, Optional, Param, Resolve, TInterceptorPriority, defineAfterInterceptor, defineBeforeInterceptor, defineBeforeInterceptor as defineBeforeInterceptor$1, defineInterceptor, defineMoostEventHandler, getMoostMate, setInfactLoggingOptions, useControllerContext } from "moost";
|
|
2
|
+
import { WooksCli, cliKind, cliKind as cliKind$1, createCliApp, useAutoHelp, useCliOption, useCommandLookupHelp } from "@wooksjs/event-cli";
|
|
3
|
+
import { current } from "@wooksjs/event-core";
|
|
3
4
|
|
|
4
5
|
//#region packages/event-cli/src/meta-types.ts
|
|
5
6
|
function getCliMate() {
|
|
@@ -24,7 +25,7 @@ function getCliMate() {
|
|
|
24
25
|
* @returns
|
|
25
26
|
*/ function Cli(path) {
|
|
26
27
|
return getCliMate().decorate("handlers", {
|
|
27
|
-
path: path?.
|
|
28
|
+
path: path?.replaceAll(/\s+/g, "/"),
|
|
28
29
|
type: "CLI"
|
|
29
30
|
}, true);
|
|
30
31
|
}
|
|
@@ -141,7 +142,7 @@ const CONTEXT_TYPE = "CLI";
|
|
|
141
142
|
* ```
|
|
142
143
|
*/ var MoostCli = class {
|
|
143
144
|
async onNotFound() {
|
|
144
|
-
const pathParams =
|
|
145
|
+
const pathParams = current().get(cliKind$1.keys.pathParams) || [];
|
|
145
146
|
const response = await defineMoostEventHandler({
|
|
146
147
|
loggerTitle: LOGGER_TITLE,
|
|
147
148
|
getIterceptorHandler: () => this.moost?.getGlobalInterceptorHandler(),
|
|
@@ -164,8 +165,8 @@ const CONTEXT_TYPE = "CLI";
|
|
|
164
165
|
for (const handler of opts.handlers) {
|
|
165
166
|
if (handler.type !== "CLI") continue;
|
|
166
167
|
const path = typeof handler.path === "string" ? handler.path : typeof opts.method === "string" ? opts.method : "";
|
|
167
|
-
const prefix = opts.prefix.
|
|
168
|
-
const makePath = (p) => `${prefix}/${p}`.
|
|
168
|
+
const prefix = opts.prefix.replaceAll(/\s+/g, "/") || "";
|
|
169
|
+
const makePath = (p) => `${prefix}/${p}`.replaceAll(/\/\/+/g, "/").replaceAll(/\/\\:/g, "\\:").replaceAll(/^\/+/g, "");
|
|
169
170
|
const targetPath = makePath(path);
|
|
170
171
|
fn = defineMoostEventHandler({
|
|
171
172
|
contextType: CONTEXT_TYPE,
|
|
@@ -173,6 +174,7 @@ const CONTEXT_TYPE = "CLI";
|
|
|
173
174
|
getIterceptorHandler: opts.getIterceptorHandler,
|
|
174
175
|
getControllerInstance: opts.getInstance,
|
|
175
176
|
controllerMethod: opts.method,
|
|
177
|
+
controllerName: opts.controllerName,
|
|
176
178
|
resolveArgs: opts.resolveArgs,
|
|
177
179
|
logErrors: this.opts?.debug,
|
|
178
180
|
targetPath,
|
|
@@ -262,10 +264,13 @@ const aliasTypes = [
|
|
|
262
264
|
* new Moost().applyGlobalInterceptors(cliHelpInterceptor({ colors: true }))
|
|
263
265
|
* ```
|
|
264
266
|
* @param opts {} { helpOptions: ['help', 'h'], colors: true } cli options to invoke help renderer
|
|
265
|
-
* @returns
|
|
266
|
-
*/ const cliHelpInterceptor = (opts) =>
|
|
267
|
+
* @returns TInterceptorDef
|
|
268
|
+
*/ const cliHelpInterceptor = (opts) => defineBeforeInterceptor$1((reply) => {
|
|
267
269
|
try {
|
|
268
|
-
if (useAutoHelp(opts?.helpOptions, opts?.colors))
|
|
270
|
+
if (useAutoHelp(opts?.helpOptions, opts?.colors)) {
|
|
271
|
+
reply("");
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
269
274
|
} catch (error) {}
|
|
270
275
|
if (opts?.lookupLevel) {
|
|
271
276
|
const { getMethod } = useControllerContext();
|
|
@@ -391,4 +396,4 @@ function _define_property(obj, key, value) {
|
|
|
391
396
|
};
|
|
392
397
|
|
|
393
398
|
//#endregion
|
|
394
|
-
export { Cli, CliAlias, CliApp, CliExample, CliGlobalOption, CliHelpInterceptor, CliOption, Controller, Description, Intercept, MoostCli, Optional, Param, cliHelpInterceptor,
|
|
399
|
+
export { Cli, CliAlias, CliApp, CliExample, CliGlobalOption, CliHelpInterceptor, CliOption, Controller, Description, Intercept, MoostCli, Optional, Param, cliHelpInterceptor, cliKind, defineAfterInterceptor, defineBeforeInterceptor, defineInterceptor };
|
package/package.json
CHANGED
|
@@ -1,12 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moostjs/event-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "@moostjs/event-cli",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"composables",
|
|
7
|
+
"framework",
|
|
8
|
+
"moost",
|
|
9
|
+
"moostjs",
|
|
10
|
+
"prostojs",
|
|
11
|
+
"wooksjs"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://github.com/moostjs/moostjs/tree/main/packages/event-cli#readme",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/moostjs/moostjs/issues"
|
|
16
|
+
},
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"author": "Artem Maltsev",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/moostjs/moostjs.git",
|
|
22
|
+
"directory": "packages/event-cli"
|
|
23
|
+
},
|
|
24
|
+
"bin": {
|
|
25
|
+
"moostjs-event-cli-skill": "./scripts/setup-skills.js"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"skills",
|
|
30
|
+
"scripts/setup-skills.js"
|
|
31
|
+
],
|
|
32
|
+
"type": "module",
|
|
33
|
+
"sideEffects": false,
|
|
5
34
|
"main": "dist/index.cjs",
|
|
6
35
|
"module": "dist/index.mjs",
|
|
7
36
|
"types": "dist/index.d.ts",
|
|
8
|
-
"type": "module",
|
|
9
|
-
"sideEffects": false,
|
|
10
37
|
"exports": {
|
|
11
38
|
"./package.json": "./package.json",
|
|
12
39
|
".": {
|
|
@@ -15,41 +42,20 @@
|
|
|
15
42
|
"require": "./dist/index.cjs"
|
|
16
43
|
}
|
|
17
44
|
},
|
|
18
|
-
"files": [
|
|
19
|
-
"dist"
|
|
20
|
-
],
|
|
21
|
-
"repository": {
|
|
22
|
-
"type": "git",
|
|
23
|
-
"url": "git+https://github.com/moostjs/moostjs.git",
|
|
24
|
-
"directory": "packages/event-cli"
|
|
25
|
-
},
|
|
26
|
-
"keywords": [
|
|
27
|
-
"moost",
|
|
28
|
-
"moostjs",
|
|
29
|
-
"composables",
|
|
30
|
-
"framework",
|
|
31
|
-
"wooksjs",
|
|
32
|
-
"prostojs"
|
|
33
|
-
],
|
|
34
|
-
"author": "Artem Maltsev",
|
|
35
|
-
"license": "MIT",
|
|
36
|
-
"bugs": {
|
|
37
|
-
"url": "https://github.com/moostjs/moostjs/issues"
|
|
38
|
-
},
|
|
39
|
-
"homepage": "https://github.com/moostjs/moostjs/tree/main/packages/event-cli#readme",
|
|
40
|
-
"peerDependencies": {
|
|
41
|
-
"@wooksjs/event-core": "^0.6.2",
|
|
42
|
-
"wooks": "^0.6.2",
|
|
43
|
-
"moost": "^0.5.32"
|
|
44
|
-
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@wooksjs/event-cli": "^0.
|
|
46
|
+
"@wooksjs/event-cli": "^0.7.3"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"vitest": "3.2.4"
|
|
50
50
|
},
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"@wooksjs/event-core": "^0.7.3",
|
|
53
|
+
"wooks": "^0.7.3",
|
|
54
|
+
"moost": "^0.6.0"
|
|
55
|
+
},
|
|
51
56
|
"scripts": {
|
|
52
57
|
"pub": "pnpm publish --access public",
|
|
53
|
-
"test": "vitest"
|
|
58
|
+
"test": "vitest",
|
|
59
|
+
"setup-skills": "node ./scripts/setup-skills.js"
|
|
54
60
|
}
|
|
55
61
|
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/* prettier-ignore */
|
|
3
|
+
import fs from 'fs'
|
|
4
|
+
import path from 'path'
|
|
5
|
+
import os from 'os'
|
|
6
|
+
import { fileURLToPath } from 'url'
|
|
7
|
+
|
|
8
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
9
|
+
|
|
10
|
+
const SKILL_NAME = 'moostjs-event-cli'
|
|
11
|
+
const SKILL_SRC = path.join(__dirname, '..', 'skills', SKILL_NAME)
|
|
12
|
+
|
|
13
|
+
if (!fs.existsSync(SKILL_SRC)) {
|
|
14
|
+
console.error(`No skills found at ${SKILL_SRC}`)
|
|
15
|
+
console.error('Add your SKILL.md files to the skills/' + SKILL_NAME + '/ directory first.')
|
|
16
|
+
process.exit(1)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const AGENTS = {
|
|
20
|
+
'Claude Code': { dir: '.claude/skills', global: path.join(os.homedir(), '.claude', 'skills') },
|
|
21
|
+
'Cursor': { dir: '.cursor/skills', global: path.join(os.homedir(), '.cursor', 'skills') },
|
|
22
|
+
'Windsurf': { dir: '.windsurf/skills', global: path.join(os.homedir(), '.windsurf', 'skills') },
|
|
23
|
+
'Codex': { dir: '.codex/skills', global: path.join(os.homedir(), '.codex', 'skills') },
|
|
24
|
+
'OpenCode': { dir: '.opencode/skills', global: path.join(os.homedir(), '.opencode', 'skills') },
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const args = process.argv.slice(2)
|
|
28
|
+
const isGlobal = args.includes('--global') || args.includes('-g')
|
|
29
|
+
const isPostinstall = args.includes('--postinstall')
|
|
30
|
+
let installed = 0, skipped = 0
|
|
31
|
+
const installedDirs = []
|
|
32
|
+
|
|
33
|
+
for (const [agentName, cfg] of Object.entries(AGENTS)) {
|
|
34
|
+
const targetBase = isGlobal ? cfg.global : path.join(process.cwd(), cfg.dir)
|
|
35
|
+
const agentRootDir = path.dirname(cfg.global) // Check if the agent has ever been installed globally
|
|
36
|
+
|
|
37
|
+
// In postinstall mode: silently skip agents that aren't set up globally
|
|
38
|
+
if (isPostinstall || isGlobal) {
|
|
39
|
+
if (!fs.existsSync(agentRootDir)) { skipped++; continue }
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const dest = path.join(targetBase, SKILL_NAME)
|
|
43
|
+
try {
|
|
44
|
+
fs.mkdirSync(dest, { recursive: true })
|
|
45
|
+
fs.cpSync(SKILL_SRC, dest, { recursive: true })
|
|
46
|
+
console.log(`✅ ${agentName}: installed to ${dest}`)
|
|
47
|
+
installed++
|
|
48
|
+
if (!isGlobal) installedDirs.push(cfg.dir + '/' + SKILL_NAME)
|
|
49
|
+
} catch (err) {
|
|
50
|
+
console.warn(`⚠️ ${agentName}: failed — ${err.message}`)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Add locally-installed skill dirs to .gitignore
|
|
55
|
+
if (!isGlobal && installedDirs.length > 0) {
|
|
56
|
+
const gitignorePath = path.join(process.cwd(), '.gitignore')
|
|
57
|
+
let gitignoreContent = ''
|
|
58
|
+
try { gitignoreContent = fs.readFileSync(gitignorePath, 'utf8') } catch {}
|
|
59
|
+
const linesToAdd = installedDirs.filter(d => !gitignoreContent.includes(d))
|
|
60
|
+
if (linesToAdd.length > 0) {
|
|
61
|
+
const hasHeader = gitignoreContent.includes('# AI agent skills')
|
|
62
|
+
const block = (gitignoreContent && !gitignoreContent.endsWith('\n') ? '\n' : '')
|
|
63
|
+
+ (hasHeader ? '' : '\n# AI agent skills (auto-generated by setup-skills)\n')
|
|
64
|
+
+ linesToAdd.join('\n') + '\n'
|
|
65
|
+
fs.appendFileSync(gitignorePath, block)
|
|
66
|
+
console.log(`📝 Added ${linesToAdd.length} entries to .gitignore`)
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (installed === 0 && isPostinstall) {
|
|
71
|
+
// Silence is fine — no agents present, nothing to do
|
|
72
|
+
} else if (installed === 0 && skipped === Object.keys(AGENTS).length) {
|
|
73
|
+
console.log('No agent directories detected. Try --global or run without it for project-local install.')
|
|
74
|
+
} else if (installed === 0) {
|
|
75
|
+
console.log('Nothing installed. Run without --global to install project-locally.')
|
|
76
|
+
} else {
|
|
77
|
+
console.log(`\n✨ Done! Restart your AI agent to pick up the "${SKILL_NAME}" skill.`)
|
|
78
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: moostjs-event-cli
|
|
3
|
+
description: Use this skill when working with @moostjs/event-cli — to build CLI applications with CliApp or MoostCli, define commands with @Cli(), parse flags and options with @CliOption(), organize commands into controllers with @Controller() and @ImportController(), generate auto-help with cliHelpInterceptor() and @CliHelpInterceptor, define command aliases with @CliAlias(), add usage examples with @CliExample(), set global options with @CliGlobalOption(), use composables like useCliOption()/useCliOptions()/useCliHelp(), combine CLI with HTTP via multi-adapter setup, or access cliKind for event type identification.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# @moostjs/event-cli
|
|
7
|
+
|
|
8
|
+
Moost adapter for building decorator-driven CLI applications. Wraps `@wooksjs/event-cli` and integrates with Moost's DI, interceptors, and pipes.
|
|
9
|
+
|
|
10
|
+
## How to use this skill
|
|
11
|
+
|
|
12
|
+
Read the domain file that matches the task. Do not load all files — only what you need.
|
|
13
|
+
|
|
14
|
+
| Domain | File | Load when... |
|
|
15
|
+
|--------|------|------------|
|
|
16
|
+
| Core concepts & setup | [core.md](core.md) | Starting a new project, understanding the mental model, installing the package |
|
|
17
|
+
| Commands | [commands.md](commands.md) | Defining commands with @Cli(), command paths, positional arguments, aliases, examples |
|
|
18
|
+
| Options & arguments | [options.md](options.md) | Adding flags with @CliOption(), boolean options, @Description, @Optional, @Value, @CliGlobalOption |
|
|
19
|
+
| Controllers | [controllers.md](controllers.md) | Organizing commands into groups, nesting with @ImportController, path composition |
|
|
20
|
+
| Help system | [help.md](help.md) | Configuring auto-help, cliHelpInterceptor, @CliHelpInterceptor, unknown command handling |
|
|
21
|
+
| Interceptors | [interceptors.md](interceptors.md) | Adding guards, error handlers, timing, cross-cutting CLI logic |
|
|
22
|
+
| Advanced | [advanced.md](advanced.md) | Manual MoostCli setup, Wooks composables, DI scopes, multi-adapter CLI+HTTP, cliKind |
|
|
23
|
+
|
|
24
|
+
## Quick reference
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
// Most common imports
|
|
28
|
+
import { CliApp, Cli, CliOption, CliAlias, CliExample, CliGlobalOption } from '@moostjs/event-cli'
|
|
29
|
+
import { Controller, Param, Description, Optional, Intercept } from '@moostjs/event-cli'
|
|
30
|
+
import { cliHelpInterceptor, CliHelpInterceptor } from '@moostjs/event-cli'
|
|
31
|
+
import { MoostCli, cliKind } from '@moostjs/event-cli'
|
|
32
|
+
|
|
33
|
+
// Minimal app
|
|
34
|
+
new CliApp()
|
|
35
|
+
.controllers(AppController)
|
|
36
|
+
.useHelp({ name: 'my-cli' })
|
|
37
|
+
.start()
|
|
38
|
+
```
|