@wooksjs/event-cli 0.6.6 → 0.7.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 CHANGED
@@ -1,7 +1,5 @@
1
1
  # @wooksjs/event-cli
2
2
 
3
- **!!! This is work-in-progress library, breaking changes are expected !!!**
4
-
5
3
  <p align="center">
6
4
  <img src="../../wooks-logo.png" width="450px"><br>
7
5
  <a href="https://github.com/wooksjs/wooksjs/blob/main/LICENSE">
@@ -9,41 +7,17 @@
9
7
  </a>
10
8
  </p>
11
9
 
12
- As a part of `wooks` event processing framework, `@wooksjs/event-cli` implements CLI events and provides composables that let you:
13
-
14
- - access flags (- or --)
10
+ CLI event processing for the Wooks framework. Build command-line applications with composable functions for flags, arguments, and auto-generated help.
15
11
 
16
12
  ## Installation
17
13
 
18
- `npm install wooks @wooksjs/event-cli`
19
-
20
- ## Quick Start
21
-
22
- ```js
23
- import { useRouteParams } from 'wooks'
24
- import { createCliApp, useCliOptions } from '@wooksjs/event-cli'
25
-
26
- const app = createCliApp()
27
-
28
- app.cli('test', () => {
29
- console.log('options:')
30
- return useCliOptions()
31
- })
32
-
33
- app.cli(':arg', () => {
34
- console.log('run argument:', useRouteParams().params)
35
- return 'done'
36
- })
37
-
38
- app.run()
39
-
40
- // node ./index.js test
41
- // node ./index.js random
14
+ ```sh
15
+ npm install @wooksjs/event-cli
42
16
  ```
43
17
 
44
18
  ## Documentation
45
19
 
46
- To check out docs, visit [wooks.moost.org](https://wooks.moost.org/cliapp/).
20
+ For full documentation, visit [wooks.moost.org/cliapp](https://wooks.moost.org/cliapp/).
47
21
 
48
22
  ## AI Agent Skills
49
23
 
@@ -51,10 +25,10 @@ This package ships with structured skill files for AI coding agents (Claude Code
51
25
 
52
26
  ```bash
53
27
  # Project-local (recommended — version-locked, commits with your repo)
54
- npx @wooksjs/event-cli setup-skills
28
+ npx wooksjs-event-cli-skill
55
29
 
56
30
  # Global (available across all your projects)
57
- npx @wooksjs/event-cli setup-skills --global
31
+ npx wooksjs-event-cli-skill --global
58
32
  ```
59
33
 
60
34
  To keep skills automatically up-to-date, add a postinstall script to your `package.json`:
@@ -62,9 +36,11 @@ To keep skills automatically up-to-date, add a postinstall script to your `packa
62
36
  ```json
63
37
  {
64
38
  "scripts": {
65
- "postinstall": "npx @wooksjs/event-cli setup-skills --postinstall"
39
+ "postinstall": "wooksjs-event-cli-skill --postinstall"
66
40
  }
67
41
  }
68
42
  ```
69
43
 
70
- This ensures the skill files are refreshed whenever dependencies are installed, without needing a separate command.
44
+ ## License
45
+
46
+ MIT
package/dist/index.cjs CHANGED
@@ -6,11 +6,11 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
8
  var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
- key = keys[i];
11
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key$1; i < n; i++) {
10
+ key$1 = keys[i];
11
+ if (!__hasOwnProp.call(to, key$1) && key$1 !== except) __defProp(to, key$1, {
12
+ get: ((k) => from[k]).bind(null, key$1),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key$1)) || desc.enumerable
14
14
  });
15
15
  }
16
16
  return to;
@@ -22,28 +22,32 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
22
22
 
23
23
  //#endregion
24
24
  const __prostojs_cli_help = __toESM(require("@prostojs/cli-help"));
25
+ const __wooksjs_event_core = __toESM(require("@wooksjs/event-core"));
25
26
  const minimist = __toESM(require("minimist"));
26
27
  const wooks = __toESM(require("wooks"));
27
- const __wooksjs_event_core = __toESM(require("@wooksjs/event-core"));
28
28
 
29
+ //#region packages/event-cli/src/cli-kind.ts
30
+ const cliKind = (0, __wooksjs_event_core.defineEventKind)("CLI", {
31
+ argv: (0, __wooksjs_event_core.slot)(),
32
+ pathParams: (0, __wooksjs_event_core.slot)(),
33
+ command: (0, __wooksjs_event_core.slot)(),
34
+ opts: (0, __wooksjs_event_core.slot)(),
35
+ cliHelp: (0, __wooksjs_event_core.slot)()
36
+ });
37
+ const flagsKey = (0, __wooksjs_event_core.key)("cli.flags");
38
+
39
+ //#endregion
29
40
  //#region packages/event-cli/src/event-cli.ts
30
- /** Creates a new async event context for a CLI command invocation. */
41
+ /** Creates a new event context for a CLI command invocation. */
31
42
  function createCliContext(data, options) {
32
- return (0, __wooksjs_event_core.createAsyncEventContext)({
33
- event: {
34
- ...data,
35
- type: "CLI"
36
- },
37
- options
38
- });
39
- }
40
- /**
41
- * Wrapper on top of useEventContext that provides
42
- * proper context types for CLI event
43
- * @returns set of hooks { getCtx, restoreCtx, clearCtx, hookStore, getStore, setStore }
44
- */
45
- function useCliContext() {
46
- return (0, __wooksjs_event_core.useAsyncEventContext)("CLI");
43
+ const ctx = new __wooksjs_event_core.EventContext(options);
44
+ return (fn) => (0, __wooksjs_event_core.run)(ctx, () => ctx.seed(cliKind, {
45
+ argv: data.argv,
46
+ pathParams: data.pathParams,
47
+ command: data.command,
48
+ opts: data.opts,
49
+ cliHelp: data.cliHelp
50
+ }, fn));
47
51
  }
48
52
 
49
53
  //#endregion
@@ -161,13 +165,13 @@ var WooksCli = class extends wooks.WooksAdapterBase {
161
165
  pathParams,
162
166
  cliHelp: this.cliHelp,
163
167
  command: path.replace(/\//gu, " ").trim()
164
- }, this.mergeEventOptions(this.opts?.eventOptions));
168
+ }, this.getEventContextOptions());
165
169
  return runInContext(async () => {
166
- const { store } = useCliContext();
167
- store("flags").value = parsedFlags;
170
+ const ctx = (0, __wooksjs_event_core.current)();
171
+ ctx.set(flagsKey, parsedFlags);
168
172
  this.computeAliases();
169
173
  const { handlers: foundHandlers, firstStatic } = this.wooks.lookup("CLI", path);
170
- if (typeof firstStatic === "string") store("event").set("command", firstStatic.replace(/\//gu, " ").trim());
174
+ if (typeof firstStatic === "string") ctx.set(cliKind.keys.command, firstStatic.replace(/\//gu, " ").trim());
171
175
  const handlers = foundHandlers || this.opts?.onNotFound && [this.opts.onNotFound] || null;
172
176
  if (handlers) try {
173
177
  for (const handler of handlers) {
@@ -239,13 +243,13 @@ function createCliApp(opts, wooks$1) {
239
243
  * @returns an object with CLI options
240
244
  */
241
245
  function useCliOptions() {
242
- const { store } = useCliContext();
243
- const flags = store("flags");
244
- if (!flags.value) {
245
- const event = store("event");
246
- flags.value = (0, minimist.default)(event.get("argv"), event.get("opts"));
246
+ const ctx = (0, __wooksjs_event_core.current)();
247
+ if (!ctx.has(flagsKey)) {
248
+ const argv = ctx.get(cliKind.keys.argv);
249
+ const opts = ctx.get(cliKind.keys.opts);
250
+ ctx.set(flagsKey, (0, minimist.default)(argv, opts));
247
251
  }
248
- return flags.value;
252
+ return ctx.get(flagsKey);
249
253
  }
250
254
  /**
251
255
  * Getter for Cli Option value
@@ -265,7 +269,7 @@ function useCliOption(name) {
265
269
  const options = useCliHelp().getEntry().options || [];
266
270
  const opt = options.find((o) => o.keys.includes(name));
267
271
  if (opt) {
268
- for (const key of opt.keys) if (useCliOptions()[key]) return useCliOptions()[key];
272
+ for (const key$1 of opt.keys) if (useCliOptions()[key$1]) return useCliOptions()[key$1];
269
273
  }
270
274
  } catch {}
271
275
  return useCliOptions()[name];
@@ -287,15 +291,15 @@ function useCliOption(name) {
287
291
  * @returns
288
292
  */
289
293
  function useCliHelp() {
290
- const event = useCliContext().store("event");
291
- const getCliHelp = () => event.get("cliHelp");
292
- const getEntry = () => getCliHelp().match(event.get("command")).main;
294
+ const ctx = (0, __wooksjs_event_core.current)();
295
+ const getCliHelp = () => ctx.get(cliKind.keys.cliHelp);
296
+ const getEntry = () => getCliHelp().match(ctx.get(cliKind.keys.command)).main;
293
297
  return {
294
298
  getCliHelp,
295
299
  getEntry,
296
- render: (width, withColors) => getCliHelp().render(event.get("command"), width, withColors),
300
+ render: (width, withColors) => getCliHelp().render(ctx.get(cliKind.keys.command), width, withColors),
297
301
  print: (withColors) => {
298
- getCliHelp().print(event.get("command"), withColors);
302
+ getCliHelp().print(ctx.get(cliKind.keys.command), withColors);
299
303
  }
300
304
  };
301
305
  }
@@ -362,7 +366,8 @@ function useAutoHelp(keys = ["help"], colors = true) {
362
366
  * ...
363
367
  */
364
368
  function useCommandLookupHelp(lookupDepth = 3) {
365
- const parts = useCliContext().store("event").get("pathParams")?.flatMap((p) => `${p} `.split(":").map((s, i) => i ? `:${s}` : s)) || [];
369
+ const ctx = (0, __wooksjs_event_core.current)();
370
+ const parts = ctx.get(cliKind.keys.pathParams)?.flatMap((p) => `${p} `.split(":").map((s, i) => i ? `:${s}` : s)) || [];
366
371
  const cliHelp = useCliHelp().getCliHelp();
367
372
  const cmd = cliHelp.getCliName();
368
373
  let data;
@@ -385,12 +390,25 @@ function useCommandLookupHelp(lookupDepth = 3) {
385
390
 
386
391
  //#endregion
387
392
  exports.WooksCli = WooksCli;
393
+ exports.cliKind = cliKind;
388
394
  exports.cliShortcuts = cliShortcuts;
389
395
  exports.createCliApp = createCliApp;
390
396
  exports.createCliContext = createCliContext;
397
+ exports.flagsKey = flagsKey;
391
398
  exports.useAutoHelp = useAutoHelp;
392
- exports.useCliContext = useCliContext;
393
399
  exports.useCliHelp = useCliHelp;
394
400
  exports.useCliOption = useCliOption;
395
401
  exports.useCliOptions = useCliOptions;
396
- exports.useCommandLookupHelp = useCommandLookupHelp;
402
+ exports.useCommandLookupHelp = useCommandLookupHelp;
403
+ Object.defineProperty(exports, 'useLogger', {
404
+ enumerable: true,
405
+ get: function () {
406
+ return __wooksjs_event_core.useLogger;
407
+ }
408
+ });
409
+ Object.defineProperty(exports, 'useRouteParams', {
410
+ enumerable: true,
411
+ get: function () {
412
+ return __wooksjs_event_core.useRouteParams;
413
+ }
414
+ });
package/dist/index.d.ts CHANGED
@@ -4,23 +4,11 @@ import * as _prostojs_cli_help from '@prostojs/cli-help';
4
4
  import { CliHelpRenderer, TCliEntry, TCliHelpOptions } from '@prostojs/cli-help';
5
5
  import { TConsoleBase } from '@prostojs/logger';
6
6
  import * as _wooksjs_event_core from '@wooksjs/event-core';
7
- import { TEventOptions, TEmpty } from '@wooksjs/event-core';
7
+ import { EventContextOptions } from '@wooksjs/event-core';
8
+ export { EventContext, EventContextOptions, useLogger, useRouteParams } from '@wooksjs/event-core';
8
9
  import minimist from 'minimist';
9
10
  import { TProstoRouterPathHandle } from '@prostojs/router';
10
11
 
11
- /** Event data describing a CLI command invocation. */
12
- interface TCliEventData {
13
- argv: string[];
14
- pathParams: string[];
15
- command: string;
16
- opts?: minimist.Opts;
17
- type: 'CLI';
18
- cliHelp: TCliHelpRenderer;
19
- }
20
- /** Context store for CLI events, holding parsed flags. */
21
- interface TCliContextStore {
22
- flags?: Record<string, boolean | string>;
23
- }
24
12
  /** Custom data attached to CLI help entries for handler resolution. */
25
13
  interface TCliHelpCustom {
26
14
  handler: TWooksHandler<any>;
@@ -45,7 +33,7 @@ interface TWooksCliOptions {
45
33
  onNotFound?: TWooksHandler;
46
34
  onUnknownCommand?: (params: string[], raiseError: () => void) => unknown;
47
35
  logger?: TConsoleBase;
48
- eventOptions?: TEventOptions;
36
+ eventOptions?: EventContextOptions;
49
37
  cliHelp?: TCliHelpRenderer | TCliHelpOptions;
50
38
  router?: TWooksOptions['router'];
51
39
  }
@@ -133,6 +121,15 @@ declare class WooksCli extends WooksAdapterBase {
133
121
  */
134
122
  declare function createCliApp(opts?: TWooksCliOptions, wooks?: Wooks | WooksAdapterBase): WooksCli;
135
123
 
124
+ declare const cliKind: _wooksjs_event_core.EventKind<{
125
+ argv: _wooksjs_event_core.SlotMarker<string[]>;
126
+ pathParams: _wooksjs_event_core.SlotMarker<string[]>;
127
+ command: _wooksjs_event_core.SlotMarker<string>;
128
+ opts: _wooksjs_event_core.SlotMarker<minimist.Opts | undefined>;
129
+ cliHelp: _wooksjs_event_core.SlotMarker<TCliHelpRenderer>;
130
+ }>;
131
+ declare const flagsKey: _wooksjs_event_core.Key<Record<string, string | boolean>>;
132
+
136
133
  /**
137
134
  * ## useCliHelp
138
135
  * ### Composable
@@ -232,14 +229,15 @@ declare function useCliOptions(): Record<string, string | boolean>;
232
229
  */
233
230
  declare function useCliOption(name: string): string | boolean;
234
231
 
235
- /** Creates a new async event context for a CLI command invocation. */
236
- declare function createCliContext(data: Omit<TCliEventData, 'type'>, options: TEventOptions): <T>(cb: (...a: unknown[]) => T) => T;
237
- /**
238
- * Wrapper on top of useEventContext that provides
239
- * proper context types for CLI event
240
- * @returns set of hooks { getCtx, restoreCtx, clearCtx, hookStore, getStore, setStore }
241
- */
242
- declare function useCliContext<T extends TEmpty>(): _wooksjs_event_core.TCtxHelpers<TCliContextStore & T & _wooksjs_event_core.TGenericContextStore<TCliEventData>>;
232
+ interface TCliEventInput {
233
+ argv: string[];
234
+ pathParams: string[];
235
+ command: string;
236
+ opts?: minimist.Opts;
237
+ cliHelp: TCliHelpRenderer;
238
+ }
239
+ /** Creates a new event context for a CLI command invocation. */
240
+ declare function createCliContext(data: TCliEventInput, options: EventContextOptions): <R>(fn: () => R) => R;
243
241
 
244
- export { WooksCli, cliShortcuts, createCliApp, createCliContext, useAutoHelp, useCliContext, useCliHelp, useCliOption, useCliOptions, useCommandLookupHelp };
245
- export type { TCliContextStore, TCliEventData, TCliHelpCustom, TCliHelpRenderer, TWooksCliEntry, TWooksCliOptions };
242
+ export { WooksCli, cliKind, cliShortcuts, createCliApp, createCliContext, flagsKey, useAutoHelp, useCliHelp, useCliOption, useCliOptions, useCommandLookupHelp };
243
+ export type { TCliEventInput, TCliHelpCustom, TCliHelpRenderer, TWooksCliEntry, TWooksCliOptions };
package/dist/index.mjs CHANGED
@@ -1,26 +1,30 @@
1
1
  import { CliHelpRenderer } from "@prostojs/cli-help";
2
+ import { EventContext, current, defineEventKind, key, run, slot, useLogger, useRouteParams } from "@wooksjs/event-core";
2
3
  import minimist from "minimist";
3
4
  import { WooksAdapterBase } from "wooks";
4
- import { createAsyncEventContext, useAsyncEventContext } from "@wooksjs/event-core";
5
5
 
6
+ //#region packages/event-cli/src/cli-kind.ts
7
+ const cliKind = defineEventKind("CLI", {
8
+ argv: slot(),
9
+ pathParams: slot(),
10
+ command: slot(),
11
+ opts: slot(),
12
+ cliHelp: slot()
13
+ });
14
+ const flagsKey = key("cli.flags");
15
+
16
+ //#endregion
6
17
  //#region packages/event-cli/src/event-cli.ts
7
- /** Creates a new async event context for a CLI command invocation. */
18
+ /** Creates a new event context for a CLI command invocation. */
8
19
  function createCliContext(data, options) {
9
- return createAsyncEventContext({
10
- event: {
11
- ...data,
12
- type: "CLI"
13
- },
14
- options
15
- });
16
- }
17
- /**
18
- * Wrapper on top of useEventContext that provides
19
- * proper context types for CLI event
20
- * @returns set of hooks { getCtx, restoreCtx, clearCtx, hookStore, getStore, setStore }
21
- */
22
- function useCliContext() {
23
- return useAsyncEventContext("CLI");
20
+ const ctx = new EventContext(options);
21
+ return (fn) => run(ctx, () => ctx.seed(cliKind, {
22
+ argv: data.argv,
23
+ pathParams: data.pathParams,
24
+ command: data.command,
25
+ opts: data.opts,
26
+ cliHelp: data.cliHelp
27
+ }, fn));
24
28
  }
25
29
 
26
30
  //#endregion
@@ -138,13 +142,13 @@ var WooksCli = class extends WooksAdapterBase {
138
142
  pathParams,
139
143
  cliHelp: this.cliHelp,
140
144
  command: path.replace(/\//gu, " ").trim()
141
- }, this.mergeEventOptions(this.opts?.eventOptions));
145
+ }, this.getEventContextOptions());
142
146
  return runInContext(async () => {
143
- const { store } = useCliContext();
144
- store("flags").value = parsedFlags;
147
+ const ctx = current();
148
+ ctx.set(flagsKey, parsedFlags);
145
149
  this.computeAliases();
146
150
  const { handlers: foundHandlers, firstStatic } = this.wooks.lookup("CLI", path);
147
- if (typeof firstStatic === "string") store("event").set("command", firstStatic.replace(/\//gu, " ").trim());
151
+ if (typeof firstStatic === "string") ctx.set(cliKind.keys.command, firstStatic.replace(/\//gu, " ").trim());
148
152
  const handlers = foundHandlers || this.opts?.onNotFound && [this.opts.onNotFound] || null;
149
153
  if (handlers) try {
150
154
  for (const handler of handlers) {
@@ -216,13 +220,13 @@ function createCliApp(opts, wooks) {
216
220
  * @returns an object with CLI options
217
221
  */
218
222
  function useCliOptions() {
219
- const { store } = useCliContext();
220
- const flags = store("flags");
221
- if (!flags.value) {
222
- const event = store("event");
223
- flags.value = minimist(event.get("argv"), event.get("opts"));
223
+ const ctx = current();
224
+ if (!ctx.has(flagsKey)) {
225
+ const argv = ctx.get(cliKind.keys.argv);
226
+ const opts = ctx.get(cliKind.keys.opts);
227
+ ctx.set(flagsKey, minimist(argv, opts));
224
228
  }
225
- return flags.value;
229
+ return ctx.get(flagsKey);
226
230
  }
227
231
  /**
228
232
  * Getter for Cli Option value
@@ -242,7 +246,7 @@ function useCliOption(name) {
242
246
  const options = useCliHelp().getEntry().options || [];
243
247
  const opt = options.find((o) => o.keys.includes(name));
244
248
  if (opt) {
245
- for (const key of opt.keys) if (useCliOptions()[key]) return useCliOptions()[key];
249
+ for (const key$1 of opt.keys) if (useCliOptions()[key$1]) return useCliOptions()[key$1];
246
250
  }
247
251
  } catch {}
248
252
  return useCliOptions()[name];
@@ -264,15 +268,15 @@ function useCliOption(name) {
264
268
  * @returns
265
269
  */
266
270
  function useCliHelp() {
267
- const event = useCliContext().store("event");
268
- const getCliHelp = () => event.get("cliHelp");
269
- const getEntry = () => getCliHelp().match(event.get("command")).main;
271
+ const ctx = current();
272
+ const getCliHelp = () => ctx.get(cliKind.keys.cliHelp);
273
+ const getEntry = () => getCliHelp().match(ctx.get(cliKind.keys.command)).main;
270
274
  return {
271
275
  getCliHelp,
272
276
  getEntry,
273
- render: (width, withColors) => getCliHelp().render(event.get("command"), width, withColors),
277
+ render: (width, withColors) => getCliHelp().render(ctx.get(cliKind.keys.command), width, withColors),
274
278
  print: (withColors) => {
275
- getCliHelp().print(event.get("command"), withColors);
279
+ getCliHelp().print(ctx.get(cliKind.keys.command), withColors);
276
280
  }
277
281
  };
278
282
  }
@@ -339,7 +343,8 @@ function useAutoHelp(keys = ["help"], colors = true) {
339
343
  * ...
340
344
  */
341
345
  function useCommandLookupHelp(lookupDepth = 3) {
342
- const parts = useCliContext().store("event").get("pathParams")?.flatMap((p) => `${p} `.split(":").map((s, i) => i ? `:${s}` : s)) || [];
346
+ const ctx = current();
347
+ const parts = ctx.get(cliKind.keys.pathParams)?.flatMap((p) => `${p} `.split(":").map((s, i) => i ? `:${s}` : s)) || [];
343
348
  const cliHelp = useCliHelp().getCliHelp();
344
349
  const cmd = cliHelp.getCliName();
345
350
  let data;
@@ -361,4 +366,4 @@ function useCommandLookupHelp(lookupDepth = 3) {
361
366
  }
362
367
 
363
368
  //#endregion
364
- export { WooksCli, cliShortcuts, createCliApp, createCliContext, useAutoHelp, useCliContext, useCliHelp, useCliOption, useCliOptions, useCommandLookupHelp };
369
+ export { WooksCli, cliKind, cliShortcuts, createCliApp, createCliContext, flagsKey, useAutoHelp, useCliHelp, useCliOption, useCliOptions, useCommandLookupHelp, useLogger, useRouteParams };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wooksjs/event-cli",
3
- "version": "0.6.6",
3
+ "version": "0.7.0",
4
4
  "description": "@wooksjs/event-cli",
5
5
  "keywords": [
6
6
  "api",
@@ -26,7 +26,7 @@
26
26
  "directory": "packages/event-cli"
27
27
  },
28
28
  "bin": {
29
- "setup-skills": "scripts/setup-skills.js"
29
+ "wooksjs-event-cli-skill": "scripts/setup-skills.js"
30
30
  },
31
31
  "files": [
32
32
  "dist",
@@ -52,14 +52,14 @@
52
52
  "@types/minimist": "^1.2.5",
53
53
  "typescript": "^5.9.3",
54
54
  "vitest": "^3.2.4",
55
- "@wooksjs/event-core": "^0.6.6",
56
- "wooks": "^0.6.6"
55
+ "@wooksjs/event-core": "^0.7.0",
56
+ "wooks": "^0.7.0"
57
57
  },
58
58
  "peerDependencies": {
59
59
  "@prostojs/logger": "^0.4.3",
60
- "@prostojs/router": "^0.3.1",
61
- "@wooksjs/event-core": "^0.6.6",
62
- "wooks": "^0.6.6"
60
+ "@prostojs/router": "^0.3.2",
61
+ "@wooksjs/event-core": "^0.7.0",
62
+ "wooks": "^0.7.0"
63
63
  },
64
64
  "scripts": {
65
65
  "build": "rolldown -c ../../rolldown.config.mjs",
@@ -1,35 +1,31 @@
1
1
  ---
2
2
  name: wooksjs-event-cli
3
- description: Wooks CLI framework — composable, command-line application framework for Node.js. Load when building CLI apps with wooks; defining CLI commands or using the wooks router for command routing; using CLI composables (useCliOptions, useCliOption, useCliHelp, useAutoHelp, useCommandLookupHelp, useRouteParams); creating custom event context composables; working with @wooksjs/event-core context store (init, get, set, hook); parsing CLI flags and options; generating command help and usage text; handling unknown commands; building multi-command CLI tools.
3
+ description: Use this skill when working with @wooksjs/event-cli — to build CLI applications with createCliApp(), register commands with app.cli(), parse flags and options with useCliOptions()/useCliOption(), generate auto-help with useCliHelp()/useAutoHelp(), handle unknown commands with useCommandLookupHelp(), define command aliases/args/options metadata, or run CLI commands programmatically with app.run().
4
4
  ---
5
5
 
6
6
  # @wooksjs/event-cli
7
7
 
8
- A composable CLI framework for Node.js built on async context (AsyncLocalStorage). Instead of imperative argument parsing libraries, you call composable functions (`useCliOptions()`, `useCliHelp()`, etc.) anywhere in your command handler — flags are parsed on demand and cached per invocation.
8
+ CLI adapter for Wooks. Build command-line applications with the same composable architecture as Wooks HTTP — routed commands, typed options, auto-generated help, and per-invocation context.
9
9
 
10
10
  ## How to use this skill
11
11
 
12
12
  Read the domain file that matches the task. Do not load all files — only what you need.
13
13
 
14
- | Domain | File | Load when... |
15
- |--------|------|------------|
16
- | Event context (core machinery) | [event-core.md](event-core.md) | Understanding the context store API (`init`/`get`/`set`/`hook`), creating custom composables, lazy evaluation and caching, building your own `use*()` functions |
17
- | CLI app setup | [core.md](core.md) | Creating a CLI app, running commands, `createCliApp`, `app.run()`, error handling, unknown command handling, sharing routers, testing |
18
- | Commands & help | [commands.md](commands.md) | Defining commands with `app.cli()`, command syntax (args, aliases, options, examples), help generation (`useCliHelp`, `useAutoHelp`, `useCommandLookupHelp`), accessing flags (`useCliOptions`, `useCliOption`), route params in CLI |
14
+ | Domain | File | Load when... |
15
+ | -------------------- | -------------------------- | --------------------------------------------------------------------------------------------------------------------------- |
16
+ | Core setup & routing | [core.md](core.md) | Creating a CLI app, registering commands, running commands, understanding the architecture |
17
+ | Commands & help | [commands.md](commands.md) | Command registration with options/args/aliases, help generation, composables (`useCliOptions`, `useCliHelp`, `useAutoHelp`) |
19
18
 
20
19
  ## Quick reference
21
20
 
22
21
  ```ts
23
- import { useRouteParams } from '@wooksjs/event-core'
24
- import { createCliApp, useCliOptions } from '@wooksjs/event-cli'
25
-
26
- const app = createCliApp()
27
- app.cli('greet/:name', () => {
28
- const { get } = useRouteParams<{ name: string }>()
29
- const flags = useCliOptions()
30
- return `Hello, ${get('name')}!`
31
- })
32
- app.run()
22
+ import { createCliApp } from '@wooksjs/event-cli'
23
+ import { useRouteParams, useLogger } from '@wooksjs/event-cli'
24
+ import {
25
+ useCliOptions,
26
+ useCliOption,
27
+ useCliHelp,
28
+ useAutoHelp,
29
+ useCommandLookupHelp,
30
+ } from '@wooksjs/event-cli'
33
31
  ```
34
-
35
- Key composables: `useCliOptions()`, `useCliOption(name)`, `useCliHelp()`, `useAutoHelp()`, `useCommandLookupHelp()`, `useRouteParams()`, `useEventId()`, `useEventLogger()`.