gunshi 0.37.3 → 1.0.0-beta.1

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/lib/agent.d.ts CHANGED
@@ -1,16 +1,11 @@
1
1
  //#region ../../node_modules/.pnpm/std-env@4.1.0/node_modules/std-env/dist/index.d.mts
2
2
  //#region src/agents.d.ts
3
3
  /**
4
- * Represents the name of an AI coding agent.
5
- */
4
+ * Represents the name of an AI coding agent.
5
+ */
6
6
  type AgentName = (string & {}) | "cursor" | "claude" | "devin" | "replit" | "gemini" | "codex" | "auggie" | "opencode" | "kiro" | "goose" | "pi";
7
- /**
8
- * Provides information about an AI coding agent.
9
- */
10
-
11
7
  //#endregion
12
8
  //#region src/agent.d.ts
13
-
14
9
  /**
15
10
  * A profile that summarizes whether the current process is running on an
16
11
  * AI coding agent.
package/lib/bone.d.ts CHANGED
@@ -1,12 +1,6 @@
1
- import { i as Args, l as ArgToken, n as ArgSchema, r as ArgValues } from "./resolver-CbDvcwY3.js";
2
- import { C as NormalizeToGunshiParams, D as SubCommandable, E as RenderingOptions, O as ValidationErrorsDecorator, S as MergeGunshiExtensions, T as RendererDecorator, _ as ExtractArgs, a as CommandContext, b as GunshiParamsConstraint, c as CommandDecorator, d as CommandLoader, f as CommandRunner, g as ExtractArgExplicitlyProvided, h as ExtendContext, i as CommandCallMode, l as CommandEnvironment, m as DefaultGunshiParams, n as CliOptions, o as CommandContextCore, p as Commandable, r as Command, s as CommandContextExtension, t as Awaitable, u as CommandExamplesFetcher, v as ExtractExtensions, w as Prettify, x as LazyCommand, y as GunshiParams } from "./types-H9nag_2Z.js";
3
-
1
+ import { i as Args, l as ArgToken, n as ArgSchema, r as ArgValues } from "./resolver-BezrTUr7.js";
2
+ import { C as NormalizeToGunshiParams, D as SubCommandable, E as RenderingOptions, O as ValidationErrorsDecorator, S as MergeGunshiExtensions, T as RendererDecorator, _ as ExtractArgs, a as CommandContext, b as GunshiParamsConstraint, c as CommandDecorator, d as CommandLoader, f as CommandRunner, g as ExtractArgExplicitlyProvided, h as ExtendContext, i as CommandCallMode, l as CommandEnvironment, m as DefaultGunshiParams, n as CliOptions, o as CommandContextCore, p as Commandable, r as Command, s as CommandContextExtension, t as Awaitable, u as CommandExamplesFetcher, v as ExtractExtensions, w as Prettify, x as LazyCommand, y as GunshiParams } from "./types-lD5uzpd5.js";
4
3
  //#region src/cli/bone.d.ts
5
- /**
6
- * @author kazuya kawaguchi (a.k.a. kazupon)
7
- * @license MIT
8
- */
9
-
10
4
  /**
11
5
  * Run the command.
12
6
  *
@@ -47,11 +41,4 @@ declare function cli<E extends ExtendContext = ExtendContext, G extends GunshiPa
47
41
  */
48
42
  declare function cli<G extends GunshiParams = DefaultGunshiParams>(args: string[], entry: Command<G> | CommandRunner<G> | LazyCommand<G>, options?: CliOptions<G>): Promise<string | undefined>;
49
43
  //#endregion
50
- //#region src/bone.d.ts
51
- /**
52
- * @author kazuya kawaguchi (a.k.a. kazupon)
53
- * @license MIT
54
- */
55
-
56
- //#endregion
57
- export { ArgSchema, ArgToken, ArgValues, Args, Awaitable, CliOptions, Command, CommandCallMode, CommandContext, CommandContextCore, CommandContextExtension, CommandDecorator, CommandEnvironment, CommandExamplesFetcher, CommandLoader, CommandRunner, Commandable, DefaultGunshiParams, ExtendContext, ExtractArgExplicitlyProvided, ExtractArgs, ExtractExtensions, GunshiParams, GunshiParamsConstraint, LazyCommand, MergeGunshiExtensions, NormalizeToGunshiParams, Prettify, RendererDecorator, RenderingOptions, SubCommandable, ValidationErrorsDecorator, cli };
44
+ export { type ArgSchema, type ArgToken, type ArgValues, type Args, type Awaitable, type CliOptions, type Command, type CommandCallMode, type CommandContext, type CommandContextCore, type CommandContextExtension, type CommandDecorator, type CommandEnvironment, type CommandExamplesFetcher, type CommandLoader, type CommandRunner, type Commandable, type DefaultGunshiParams, type ExtendContext, type ExtractArgExplicitlyProvided, type ExtractArgs, type ExtractExtensions, type GunshiParams, type GunshiParamsConstraint, type LazyCommand, type MergeGunshiExtensions, type NormalizeToGunshiParams, type Prettify, type RendererDecorator, type RenderingOptions, type SubCommandable, type ValidationErrorsDecorator, cli };
package/lib/bone.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as cliCore } from "./core-CLzX86kY.js";
1
+ import { t as cliCore } from "./core-C-EvVI4v.js";
2
2
  //#region src/cli/bone.ts
3
3
  /**
4
4
  * @author kazuya kawaguchi (a.k.a. kazupon)
@@ -1,7 +1,7 @@
1
- import { r as hasPriorityValidationError } from "./error-B5QxSzk9.js";
2
- import { t as plugin } from "./plugin-DneW3Toi.js";
3
- import { a as namespacedId, o as COMMON_ARGS, t as renderer } from "./src-80_afJQM.js";
4
- import { t as cliCore } from "./core-CLzX86kY.js";
1
+ import { a as hasPriorityValidationError } from "./error-wB83kWiv.js";
2
+ import { t as plugin } from "./plugin-CG94VzCl.js";
3
+ import { a as namespacedId, o as COMMON_ARGS, t as renderer } from "./src-BI37Q7Wx.js";
4
+ import { t as cliCore } from "./core-C-EvVI4v.js";
5
5
  //#region ../plugin-global/src/types.ts
6
6
  /**
7
7
  * @author kazuya kawaguchi (a.k.a. kazupon)
@@ -24,16 +24,21 @@ const pluginId = namespacedId("global");
24
24
  * @returns A command decorator that adds global options handling
25
25
  */
26
26
  const decorator = (baseRunner) => async (ctx) => {
27
- const { values, validationError, extensions: { [pluginId]: { showVersion, showHeader, showUsage, showValidationErrors } } } = ctx;
27
+ /**
28
+ * NOTE(kazupon): the core puts the globals still in effect on `env.globalOptions`. A command that
29
+ * declares the same name — even with an identical schema — is not in that map, so `--version` /
30
+ * `--help` belong to the command.
31
+ */
32
+ const { values, validationError, env: { globalOptions }, extensions: { [pluginId]: { showVersion, showHeader, showUsage, showValidationErrors } } } = ctx;
28
33
  if (hasPriorityValidationError(validationError)) {
29
34
  await showValidationErrors(validationError);
30
35
  throw validationError;
31
36
  }
32
- if (values.version) return showVersion();
37
+ if (values.version && globalOptions?.has("version")) return showVersion();
33
38
  const buf = [];
34
39
  const header = await showHeader();
35
40
  if (header) buf.push(header);
36
- if (values.help) {
41
+ if (values.help && globalOptions?.has("help")) {
37
42
  const usage = await showUsage();
38
43
  if (usage) {
39
44
  buf.push(usage);
@@ -160,14 +165,29 @@ function global() {
160
165
  * @returns A rendered usage or undefined. if you will use {@linkcode CliOptions.usageSilent} option, it will return rendered usage string.
161
166
  */
162
167
  async function cli(args, entry, options = {}) {
163
- const builtInPlugins = [global(), renderer()];
164
- return cliCore(args, entry, options, builtInPlugins);
168
+ return cliCore(args, entry, options, createBuiltInPlugins());
165
169
  }
166
- //#endregion
167
- //#region src/cli.ts
168
170
  /**
169
- * @author kazuya kawaguchi (a.k.a. kazupon)
170
- * @license MIT
171
+ * Render the usage of a command, without running it.
172
+ *
173
+ * This is what `generate` of `gunshi/generator` is made of. It resolves the command the same way
174
+ * {@linkcode cli} does, with the same built-in plugins, and renders the usage of the command it
175
+ * arrives at, whatever that command declares as its own arguments.
176
+ *
177
+ * @internal
178
+ *
179
+ * @typeParam G - A type extending {@linkcode GunshiParams} to specify the shape of command and cli options.
180
+ *
181
+ * @param args - Command line arguments, which name the command to render
182
+ * @param entry - A {@link Command | entry command}, an {@link CommandRunner | inline command runner}, or a {@link LazyCommand | lazily-loaded command}
183
+ * @param options - A {@link CliOptions | CLI options}
184
+ * @returns A rendered usage, or `undefined` if there is no usage renderer to render it
171
185
  */
186
+ async function cliUsage(args, entry, options = {}) {
187
+ return cliCore(args, entry, options, createBuiltInPlugins(), true);
188
+ }
189
+ function createBuiltInPlugins() {
190
+ return [global(), renderer()];
191
+ }
172
192
  //#endregion
173
- export { cli as t };
193
+ export { cliUsage as n, cli as t };