gunshi 0.30.8 → 0.31.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 +0 -4
- package/lib/agent.d.ts +61 -0
- package/lib/agent.js +222 -0
- package/lib/bone.d.ts +2 -2
- package/lib/bone.js +1 -1
- package/lib/{cli-BIViXHPa.js → cli-DfaFk6tk.js} +2 -2
- package/lib/combinators.d.ts +2 -2
- package/lib/combinators.js +5 -1
- package/lib/{constants-BKVrvh3H.d.ts → constants-CPTXtFxe.d.ts} +1 -1
- package/lib/context.d.ts +2 -2
- package/lib/context.js +1 -1
- package/lib/{core-BQot-D_g.js → core-BKtZQ6dG.js} +22 -10
- package/lib/definition.d.ts +2 -2
- package/lib/generator.d.ts +1 -1
- package/lib/generator.js +2 -2
- package/lib/index.d.ts +3 -3
- package/lib/index.js +3 -3
- package/lib/plugin.d.ts +3 -3
- package/lib/renderer.d.ts +1 -1
- package/lib/renderer.js +1 -1
- package/lib/{resolver-DGtVt298.d.ts → resolver-CIPNDx1a.d.ts} +2 -2
- package/lib/{src-Dwp0BoQ5.js → src-dTYUlEw_.js} +1 -1
- package/lib/{types-FFgtdrno.d.ts → types-CyyzAaDx.d.ts} +1 -1
- package/lib/{utils-CMJNteYK.js → utils-jNy8sqR5.js} +1 -1
- package/lib/utils.d.ts +2 -2
- package/lib/utils.js +1 -1
- package/package.json +14 -7
package/README.md
CHANGED
|
@@ -28,10 +28,6 @@ Gunshi is designed to simplify the creation of modern command-line interfaces:
|
|
|
28
28
|
- 🌍 **Internationalization**: Built with global users in mind, featuring locale-aware design, resource management, and multi-language support.
|
|
29
29
|
- 🔌 **Pluggable**: Extensible plugin system with dependency management and lifecycle hooks for modular CLI development.
|
|
30
30
|
|
|
31
|
-
## 📡 Status
|
|
32
|
-
|
|
33
|
-
- v0.27: stable
|
|
34
|
-
|
|
35
31
|
## 💿 Installation
|
|
36
32
|
|
|
37
33
|
```sh
|
package/lib/agent.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/std-env@4.1.0/node_modules/std-env/dist/index.d.mts
|
|
2
|
+
//#region src/agents.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Represents the name of an AI coding agent.
|
|
5
|
+
*/
|
|
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
|
+
//#endregion
|
|
12
|
+
//#region src/agent.d.ts
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A profile that summarizes whether the current process is running on an
|
|
16
|
+
* AI coding agent.
|
|
17
|
+
*
|
|
18
|
+
* The shape is intentionally minimal so that callers can use it as a UX hint
|
|
19
|
+
* (for example, to switch output format) without coupling to specific agent
|
|
20
|
+
* names. To get the type, use `ReturnType<typeof getAgentProfile>`.
|
|
21
|
+
*/
|
|
22
|
+
interface AgentProfile {
|
|
23
|
+
/**
|
|
24
|
+
* `true` if the current process is detected as running on an AI coding
|
|
25
|
+
* agent.
|
|
26
|
+
*
|
|
27
|
+
* Detection is delegated to `std-env`. Prefer checking this flag over the
|
|
28
|
+
* {@link AgentProfile.name | name} field.
|
|
29
|
+
*/
|
|
30
|
+
isAgent: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* The name of the detected AI coding agent, if any.
|
|
33
|
+
*
|
|
34
|
+
* This is the value reported by `std-env`. Use it only when a specific
|
|
35
|
+
* agent has a known constraint that requires special handling.
|
|
36
|
+
*/
|
|
37
|
+
name?: AgentName;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get the AI coding agent profile of the current process.
|
|
41
|
+
*
|
|
42
|
+
* The detection itself is delegated to `std-env`. This function only converts
|
|
43
|
+
* the upstream `agentInfo` into Gunshi's minimal {@link AgentProfile} shape.
|
|
44
|
+
*
|
|
45
|
+
* @returns An {@link AgentProfile} describing whether the process is running
|
|
46
|
+
* on an AI coding agent and, if so, which agent was detected.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```js
|
|
50
|
+
* import { getAgentProfile } from 'gunshi/agent'
|
|
51
|
+
*
|
|
52
|
+
* const profile = getAgentProfile()
|
|
53
|
+
*
|
|
54
|
+
* if (profile.isAgent) {
|
|
55
|
+
* // adjust output for AI agent execution
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
declare function getAgentProfile(): AgentProfile;
|
|
60
|
+
//#endregion
|
|
61
|
+
export { getAgentProfile };
|
package/lib/agent.js
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/std-env@4.1.0/node_modules/std-env/dist/index.mjs
|
|
2
|
+
const e = globalThis.process?.env || Object.create(null), t = globalThis.process || { env: e }, n = t !== void 0 && t.env && t.env.NODE_ENV || void 0, r = [
|
|
3
|
+
[`claude`, [`CLAUDECODE`, `CLAUDE_CODE`]],
|
|
4
|
+
[`replit`, [`REPL_ID`]],
|
|
5
|
+
[`gemini`, [`GEMINI_CLI`]],
|
|
6
|
+
[`codex`, [`CODEX_SANDBOX`, `CODEX_THREAD_ID`]],
|
|
7
|
+
[`opencode`, [`OPENCODE`]],
|
|
8
|
+
[`pi`, [i(`PATH`, /\.pi[\\/]agent/)]],
|
|
9
|
+
[`auggie`, [`AUGMENT_AGENT`]],
|
|
10
|
+
[`goose`, [`GOOSE_PROVIDER`]],
|
|
11
|
+
[`devin`, [i(`EDITOR`, /devin/)]],
|
|
12
|
+
[`cursor`, [`CURSOR_AGENT`]],
|
|
13
|
+
[`kiro`, [i(`TERM_PROGRAM`, /kiro/)]]
|
|
14
|
+
];
|
|
15
|
+
function i(t, n) {
|
|
16
|
+
return () => {
|
|
17
|
+
let r = e[t];
|
|
18
|
+
return r ? n.test(r) : !1;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function a() {
|
|
22
|
+
let t = e.AI_AGENT;
|
|
23
|
+
if (t) return { name: t.toLowerCase() };
|
|
24
|
+
for (let [t, n] of r) for (let r of n) if (typeof r == `string` ? e[r] : r()) return { name: t };
|
|
25
|
+
return {};
|
|
26
|
+
}
|
|
27
|
+
const o = a();
|
|
28
|
+
o.name;
|
|
29
|
+
o.name;
|
|
30
|
+
const l = [
|
|
31
|
+
[`APPVEYOR`],
|
|
32
|
+
[
|
|
33
|
+
`AWS_AMPLIFY`,
|
|
34
|
+
`AWS_APP_ID`,
|
|
35
|
+
{ ci: !0 }
|
|
36
|
+
],
|
|
37
|
+
[`AZURE_PIPELINES`, `SYSTEM_TEAMFOUNDATIONCOLLECTIONURI`],
|
|
38
|
+
[`AZURE_STATIC`, `INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN`],
|
|
39
|
+
[`APPCIRCLE`, `AC_APPCIRCLE`],
|
|
40
|
+
[`BAMBOO`, `bamboo_planKey`],
|
|
41
|
+
[`BITBUCKET`, `BITBUCKET_COMMIT`],
|
|
42
|
+
[`BITRISE`, `BITRISE_IO`],
|
|
43
|
+
[`BUDDY`, `BUDDY_WORKSPACE_ID`],
|
|
44
|
+
[`BUILDKITE`],
|
|
45
|
+
[`CIRCLE`, `CIRCLECI`],
|
|
46
|
+
[`CIRRUS`, `CIRRUS_CI`],
|
|
47
|
+
[
|
|
48
|
+
`CLOUDFLARE_PAGES`,
|
|
49
|
+
`CF_PAGES`,
|
|
50
|
+
{ ci: !0 }
|
|
51
|
+
],
|
|
52
|
+
[
|
|
53
|
+
`CLOUDFLARE_WORKERS`,
|
|
54
|
+
`WORKERS_CI`,
|
|
55
|
+
{ ci: !0 }
|
|
56
|
+
],
|
|
57
|
+
[`GOOGLE_CLOUDRUN`, `K_SERVICE`],
|
|
58
|
+
[`GOOGLE_CLOUDRUN_JOB`, `CLOUD_RUN_JOB`],
|
|
59
|
+
[`CODEBUILD`, `CODEBUILD_BUILD_ARN`],
|
|
60
|
+
[`CODEFRESH`, `CF_BUILD_ID`],
|
|
61
|
+
[`DRONE`],
|
|
62
|
+
[`DRONE`, `DRONE_BUILD_EVENT`],
|
|
63
|
+
[`DSARI`],
|
|
64
|
+
[`GITHUB_ACTIONS`],
|
|
65
|
+
[`GITLAB`, `GITLAB_CI`],
|
|
66
|
+
[`GITLAB`, `CI_MERGE_REQUEST_ID`],
|
|
67
|
+
[`GOCD`, `GO_PIPELINE_LABEL`],
|
|
68
|
+
[`LAYERCI`],
|
|
69
|
+
[`JENKINS`, `JENKINS_URL`],
|
|
70
|
+
[`HUDSON`, `HUDSON_URL`],
|
|
71
|
+
[`MAGNUM`],
|
|
72
|
+
[`NETLIFY`],
|
|
73
|
+
[
|
|
74
|
+
`NETLIFY`,
|
|
75
|
+
`NETLIFY_LOCAL`,
|
|
76
|
+
{ ci: !1 }
|
|
77
|
+
],
|
|
78
|
+
[`NEVERCODE`],
|
|
79
|
+
[`RENDER`],
|
|
80
|
+
[`SAIL`, `SAILCI`],
|
|
81
|
+
[`SEMAPHORE`],
|
|
82
|
+
[`SCREWDRIVER`],
|
|
83
|
+
[`SHIPPABLE`],
|
|
84
|
+
[`SOLANO`, `TDDIUM`],
|
|
85
|
+
[`STRIDER`],
|
|
86
|
+
[`TEAMCITY`, `TEAMCITY_VERSION`],
|
|
87
|
+
[`TRAVIS`],
|
|
88
|
+
[`VERCEL`, `NOW_BUILDER`],
|
|
89
|
+
[
|
|
90
|
+
`VERCEL`,
|
|
91
|
+
`VERCEL`,
|
|
92
|
+
{ ci: !1 }
|
|
93
|
+
],
|
|
94
|
+
[
|
|
95
|
+
`VERCEL`,
|
|
96
|
+
`VERCEL_ENV`,
|
|
97
|
+
{ ci: !1 }
|
|
98
|
+
],
|
|
99
|
+
[`APPCENTER`, `APPCENTER_BUILD_ID`],
|
|
100
|
+
[
|
|
101
|
+
`CODESANDBOX`,
|
|
102
|
+
`CODESANDBOX_SSE`,
|
|
103
|
+
{ ci: !1 }
|
|
104
|
+
],
|
|
105
|
+
[
|
|
106
|
+
`CODESANDBOX`,
|
|
107
|
+
`CODESANDBOX_HOST`,
|
|
108
|
+
{ ci: !1 }
|
|
109
|
+
],
|
|
110
|
+
[`STACKBLITZ`],
|
|
111
|
+
[`STORMKIT`],
|
|
112
|
+
[`CLEAVR`],
|
|
113
|
+
[`ZEABUR`],
|
|
114
|
+
[
|
|
115
|
+
`CODESPHERE`,
|
|
116
|
+
`CODESPHERE_APP_ID`,
|
|
117
|
+
{ ci: !0 }
|
|
118
|
+
],
|
|
119
|
+
[`RAILWAY`, `RAILWAY_PROJECT_ID`],
|
|
120
|
+
[`RAILWAY`, `RAILWAY_SERVICE_ID`],
|
|
121
|
+
[`DENO-DEPLOY`, `DENO_DEPLOY`],
|
|
122
|
+
[`DENO-DEPLOY`, `DENO_DEPLOYMENT_ID`],
|
|
123
|
+
[
|
|
124
|
+
`FIREBASE_APP_HOSTING`,
|
|
125
|
+
`FIREBASE_APP_HOSTING`,
|
|
126
|
+
{ ci: !0 }
|
|
127
|
+
],
|
|
128
|
+
[
|
|
129
|
+
`EDGEONE_PAGES`,
|
|
130
|
+
`EO_PAGES_CI`,
|
|
131
|
+
{ ci: !0 }
|
|
132
|
+
]
|
|
133
|
+
];
|
|
134
|
+
function u() {
|
|
135
|
+
for (let t of l) if (e[t[1] || t[0]]) return {
|
|
136
|
+
name: t[0].toLowerCase(),
|
|
137
|
+
...t[2]
|
|
138
|
+
};
|
|
139
|
+
return e.SHELL === `/bin/jsh` && t.versions?.webcontainer ? {
|
|
140
|
+
name: `stackblitz`,
|
|
141
|
+
ci: !1
|
|
142
|
+
} : {
|
|
143
|
+
name: ``,
|
|
144
|
+
ci: !1
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
const d = u();
|
|
148
|
+
d.name;
|
|
149
|
+
const p = t.platform || ``;
|
|
150
|
+
e.CI || d.ci;
|
|
151
|
+
const h = !!t.stdout?.isTTY;
|
|
152
|
+
e.DEBUG;
|
|
153
|
+
n === `test` || e.TEST;
|
|
154
|
+
n === `production` || e.MODE;
|
|
155
|
+
n === `dev` || n === `development` || e.MODE;
|
|
156
|
+
e.MINIMAL;
|
|
157
|
+
const S = /^win/i.test(p);
|
|
158
|
+
/^linux/i.test(p);
|
|
159
|
+
/^darwin/i.test(p);
|
|
160
|
+
!e.NO_COLOR && (e.FORCE_COLOR || (h || S) && e.TERM);
|
|
161
|
+
const E = (t.versions?.node || ``).replace(/^v/, ``) || null;
|
|
162
|
+
Number(E?.split(`.`)[0]);
|
|
163
|
+
const O = !!t?.versions?.node, k = `Bun` in globalThis, A = `Deno` in globalThis, j = `fastly` in globalThis, M = `Netlify` in globalThis, N = `EdgeRuntime` in globalThis, P = globalThis.navigator?.userAgent === `Cloudflare-Workers`, F = [
|
|
164
|
+
[M, `netlify`],
|
|
165
|
+
[N, `edge-light`],
|
|
166
|
+
[P, `workerd`],
|
|
167
|
+
[j, `fastly`],
|
|
168
|
+
[A, `deno`],
|
|
169
|
+
[k, `bun`],
|
|
170
|
+
[O, `node`]
|
|
171
|
+
];
|
|
172
|
+
function I() {
|
|
173
|
+
let e = F.find((e) => e[0]);
|
|
174
|
+
if (e) return { name: e[1] };
|
|
175
|
+
}
|
|
176
|
+
I()?.name;
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region src/agent.ts
|
|
179
|
+
/**
|
|
180
|
+
* The entry point for AI agent detection utility.
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* ```js
|
|
184
|
+
* import { getAgentProfile } from 'gunshi/agent'
|
|
185
|
+
* ```
|
|
186
|
+
*
|
|
187
|
+
* @experimental
|
|
188
|
+
* The `gunshi/agent` entry point is experimental. The agent detection rules
|
|
189
|
+
* are delegated to {@link https://github.com/unjs/std-env | std-env} and may
|
|
190
|
+
* change as the upstream detector list evolves.
|
|
191
|
+
*
|
|
192
|
+
* @author kazuya kawaguchi (a.k.a. kazupon)
|
|
193
|
+
* @license MIT
|
|
194
|
+
*/
|
|
195
|
+
/**
|
|
196
|
+
* Get the AI coding agent profile of the current process.
|
|
197
|
+
*
|
|
198
|
+
* The detection itself is delegated to `std-env`. This function only converts
|
|
199
|
+
* the upstream `agentInfo` into Gunshi's minimal {@link AgentProfile} shape.
|
|
200
|
+
*
|
|
201
|
+
* @returns An {@link AgentProfile} describing whether the process is running
|
|
202
|
+
* on an AI coding agent and, if so, which agent was detected.
|
|
203
|
+
*
|
|
204
|
+
* @example
|
|
205
|
+
* ```js
|
|
206
|
+
* import { getAgentProfile } from 'gunshi/agent'
|
|
207
|
+
*
|
|
208
|
+
* const profile = getAgentProfile()
|
|
209
|
+
*
|
|
210
|
+
* if (profile.isAgent) {
|
|
211
|
+
* // adjust output for AI agent execution
|
|
212
|
+
* }
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
function getAgentProfile() {
|
|
216
|
+
return {
|
|
217
|
+
isAgent: !!o.name,
|
|
218
|
+
name: o.name
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
//#endregion
|
|
222
|
+
export { getAgentProfile };
|
package/lib/bone.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as Args, n as ArgSchema, o as ArgToken, r as ArgValues } from "./resolver-
|
|
2
|
-
import { C as Prettify, D as ValidationErrorsDecorator, E as SubCommandable, S as NormalizeToGunshiParams, T as RenderingOptions, _ 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 RendererDecorator, x as LazyCommand, y as GunshiParams } from "./types-
|
|
1
|
+
import { i as Args, n as ArgSchema, o as ArgToken, r as ArgValues } from "./resolver-CIPNDx1a.js";
|
|
2
|
+
import { C as Prettify, D as ValidationErrorsDecorator, E as SubCommandable, S as NormalizeToGunshiParams, T as RenderingOptions, _ 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 RendererDecorator, x as LazyCommand, y as GunshiParams } from "./types-CyyzAaDx.js";
|
|
3
3
|
|
|
4
4
|
//#region src/cli/bone.d.ts
|
|
5
5
|
/**
|
package/lib/bone.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as plugin } from "./core-D1daCTTE.js";
|
|
2
|
-
import { a as namespacedId, o as COMMON_ARGS, t as renderer } from "./src-
|
|
3
|
-
import { t as cliCore } from "./core-
|
|
2
|
+
import { a as namespacedId, o as COMMON_ARGS, t as renderer } from "./src-dTYUlEw_.js";
|
|
3
|
+
import { t as cliCore } from "./core-BKtZQ6dG.js";
|
|
4
4
|
//#region ../plugin-global/src/types.ts
|
|
5
5
|
/**
|
|
6
6
|
* @author kazuya kawaguchi (a.k.a. kazupon)
|
package/lib/combinators.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as Args, n as ArgSchema } from "./resolver-
|
|
1
|
+
import { i as Args, n as ArgSchema } from "./resolver-CIPNDx1a.js";
|
|
2
2
|
|
|
3
|
-
//#region ../../node_modules/.pnpm/args-tokens@0.
|
|
3
|
+
//#region ../../node_modules/.pnpm/args-tokens@0.25.0/node_modules/args-tokens/lib/combinators.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* @author kazuya kawaguchi (a.k.a. kazupon)
|
|
6
6
|
* @license MIT
|
package/lib/combinators.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/args-tokens@0.
|
|
1
|
+
//#region ../../node_modules/.pnpm/args-tokens@0.25.0/node_modules/args-tokens/lib/combinators.js
|
|
2
|
+
/**
|
|
3
|
+
* @author kazuya kawaguchi (a.k.a. kazupon)
|
|
4
|
+
* @license MIT
|
|
5
|
+
*/
|
|
2
6
|
/**
|
|
3
7
|
* Create a string argument schema with optional validation.
|
|
4
8
|
*
|
package/lib/context.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as Args, o as ArgToken, r as ArgValues } from "./resolver-
|
|
2
|
-
import { _ as ExtractArgs, a as CommandContext, b as GunshiParamsConstraint, g as ExtractArgExplicitlyProvided, h as ExtendContext, i as CommandCallMode, m as DefaultGunshiParams, n as CliOptions, r as Command, s as CommandContextExtension, x as LazyCommand, y as GunshiParams } from "./types-
|
|
1
|
+
import { i as Args, o as ArgToken, r as ArgValues } from "./resolver-CIPNDx1a.js";
|
|
2
|
+
import { _ as ExtractArgs, a as CommandContext, b as GunshiParamsConstraint, g as ExtractArgExplicitlyProvided, h as ExtendContext, i as CommandCallMode, m as DefaultGunshiParams, n as CliOptions, r as Command, s as CommandContextExtension, x as LazyCommand, y as GunshiParams } from "./types-CyyzAaDx.js";
|
|
3
3
|
|
|
4
4
|
//#region src/context.d.ts
|
|
5
5
|
|
package/lib/context.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as CLI_OPTIONS_DEFAULT, r as NOOP, t as ANONYMOUS_COMMAND_NAME } from "./constants-D_ixLD32.js";
|
|
2
|
-
import { a as log, i as isLazyCommand, n as deepFreeze, t as create } from "./utils-
|
|
2
|
+
import { a as log, i as isLazyCommand, n as deepFreeze, t as create } from "./utils-jNy8sqR5.js";
|
|
3
3
|
//#region src/context.ts
|
|
4
4
|
/**
|
|
5
5
|
* The entry for gunshi context.
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import { n as CLI_OPTIONS_DEFAULT, r as NOOP } from "./constants-D_ixLD32.js";
|
|
2
|
-
import { i as isLazyCommand, o as resolveLazyCommand, r as getCommandSubCommands, s as kebabnize, t as create } from "./utils-
|
|
2
|
+
import { i as isLazyCommand, o as resolveLazyCommand, r as getCommandSubCommands, s as kebabnize, t as create } from "./utils-jNy8sqR5.js";
|
|
3
3
|
import { createCommandContext } from "./context.js";
|
|
4
|
-
//#region ../../node_modules/.pnpm/args-tokens@0.
|
|
4
|
+
//#region ../../node_modules/.pnpm/args-tokens@0.25.0/node_modules/args-tokens/lib/parser.js
|
|
5
|
+
/**
|
|
6
|
+
* forked from `nodejs/node` (`pkgjs/parseargs`)
|
|
7
|
+
* repository url: https://github.com/nodejs/node (https://github.com/pkgjs/parseargs)
|
|
8
|
+
* code url: https://github.com/nodejs/node/blob/main/lib/internal/util/parse_args/parse_args.js
|
|
9
|
+
*
|
|
10
|
+
* @author kazuya kawaguchi (a.k.a. kazupon)
|
|
11
|
+
* @license MIT
|
|
12
|
+
*/
|
|
5
13
|
const HYPHEN_CHAR = "-";
|
|
6
14
|
const HYPHEN_CODE = HYPHEN_CHAR.codePointAt(0);
|
|
7
15
|
const EQUAL_CHAR = "=";
|
|
@@ -198,7 +206,7 @@ function hasOptionValue(value) {
|
|
|
198
206
|
return !(value == null) && value.codePointAt(0) !== HYPHEN_CODE;
|
|
199
207
|
}
|
|
200
208
|
//#endregion
|
|
201
|
-
//#region ../../node_modules/.pnpm/args-tokens@0.
|
|
209
|
+
//#region ../../node_modules/.pnpm/args-tokens@0.25.0/node_modules/args-tokens/lib/resolver.js
|
|
202
210
|
/**
|
|
203
211
|
* Entry point of argument options resolver.
|
|
204
212
|
*
|
|
@@ -257,14 +265,14 @@ function resolveArgs(args, tokens, { shortGrouping = false, skipPositional = SKI
|
|
|
257
265
|
return value;
|
|
258
266
|
}
|
|
259
267
|
}
|
|
260
|
-
function applyLongOptionValue(value
|
|
268
|
+
function applyLongOptionValue(value) {
|
|
261
269
|
if (currentLongOption) {
|
|
262
270
|
currentLongOption.value = value;
|
|
263
271
|
optionTokens.push({ ...currentLongOption });
|
|
264
272
|
currentLongOption = void 0;
|
|
265
273
|
}
|
|
266
274
|
}
|
|
267
|
-
function applyShortOptionValue(value
|
|
275
|
+
function applyShortOptionValue(value) {
|
|
268
276
|
if (currentShortOption) {
|
|
269
277
|
currentShortOption.value = value || toShortValue();
|
|
270
278
|
optionTokens.push({ ...currentShortOption });
|
|
@@ -498,7 +506,11 @@ function checkConflicts(args, explicit, toKebab, actualInputNames) {
|
|
|
498
506
|
return [];
|
|
499
507
|
}
|
|
500
508
|
//#endregion
|
|
501
|
-
//#region ../../node_modules/.pnpm/args-tokens@0.
|
|
509
|
+
//#region ../../node_modules/.pnpm/args-tokens@0.25.0/node_modules/args-tokens/lib/index.js
|
|
510
|
+
/**
|
|
511
|
+
* @author kazuya kawaguchi (a.k.a. kazupon)
|
|
512
|
+
* @license MIT
|
|
513
|
+
*/
|
|
502
514
|
/**
|
|
503
515
|
* @author kazuya kawaguchi (a.k.a. kazupon)
|
|
504
516
|
* @license MIT
|
|
@@ -696,16 +708,16 @@ async function cliCore(argv, entry, options, plugins) {
|
|
|
696
708
|
const resolved = resolveCommandTree(tokens, entry, cliOptions);
|
|
697
709
|
const { commandName: name, command, callMode, commandPath, depth, levelSubCommands } = resolved;
|
|
698
710
|
if (!command) throw new Error(`Command not found: ${name || ""}`);
|
|
699
|
-
|
|
711
|
+
if (levelSubCommands) cliOptions.subCommands = levelSubCommands;
|
|
712
|
+
const resolvedCommand = isLazyCommand(command) ? await resolveLazyCommand(command, name, true) : command;
|
|
713
|
+
const args = resolveArguments(pluginContext, getCommandArgs(resolvedCommand));
|
|
700
714
|
const skipPositional = depth > 0 ? depth - 1 : -1;
|
|
701
715
|
const { explicit, values, positionals, rest, error } = resolveArgs(args, tokens, {
|
|
702
716
|
shortGrouping: true,
|
|
703
|
-
toKebab:
|
|
717
|
+
toKebab: resolvedCommand.toKebab,
|
|
704
718
|
skipPositional
|
|
705
719
|
});
|
|
706
720
|
const omitted = resolved.omitted;
|
|
707
|
-
if (levelSubCommands) cliOptions.subCommands = levelSubCommands;
|
|
708
|
-
const resolvedCommand = isLazyCommand(command) ? await resolveLazyCommand(command, name, true) : command;
|
|
709
721
|
return await executeCommand(resolvedCommand, await createCommandContext({
|
|
710
722
|
args,
|
|
711
723
|
explicit,
|
package/lib/definition.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as Args, n as ArgSchema, r as ArgValues } from "./resolver-
|
|
2
|
-
import { C as Prettify, _ as ExtractArgs, b as GunshiParamsConstraint, d as CommandLoader, f as CommandRunner, h as ExtendContext, m as DefaultGunshiParams, r as Command, v as ExtractExtensions, x as LazyCommand, y as GunshiParams } from "./types-
|
|
1
|
+
import { i as Args, n as ArgSchema, r as ArgValues } from "./resolver-CIPNDx1a.js";
|
|
2
|
+
import { C as Prettify, _ as ExtractArgs, b as GunshiParamsConstraint, d as CommandLoader, f as CommandRunner, h as ExtendContext, m as DefaultGunshiParams, r as Command, v as ExtractExtensions, x as LazyCommand, y as GunshiParams } from "./types-CyyzAaDx.js";
|
|
3
3
|
import { CommandContextParams, createCommandContext } from "./context.js";
|
|
4
4
|
|
|
5
5
|
//#region src/definition.d.ts
|
package/lib/generator.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as GunshiParamsConstraint, m as DefaultGunshiParams, n as CliOptions, r as Command, x as LazyCommand } from "./types-
|
|
1
|
+
import { b as GunshiParamsConstraint, m as DefaultGunshiParams, n as CliOptions, r as Command, x as LazyCommand } from "./types-CyyzAaDx.js";
|
|
2
2
|
|
|
3
3
|
//#region src/generator.d.ts
|
|
4
4
|
|
package/lib/generator.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as create } from "./utils-
|
|
2
|
-
import { t as cli } from "./cli-
|
|
1
|
+
import { t as create } from "./utils-jNy8sqR5.js";
|
|
2
|
+
import { t as cli } from "./cli-DfaFk6tk.js";
|
|
3
3
|
//#region src/generator.ts
|
|
4
4
|
/**
|
|
5
5
|
* The entry for usage generator.
|
package/lib/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as resolveArgs, i as Args, n as ArgSchema, o as ArgToken, r as ArgValues, s as parseArgs } from "./resolver-
|
|
2
|
-
import { A as PluginDependency, C as Prettify, D as ValidationErrorsDecorator, E as SubCommandable, F as PluginWithoutExtension, I as plugin, L as PluginContext, M as PluginFunction, N as PluginOptions, O as OnPluginExtension, P as PluginWithExtension, S as NormalizeToGunshiParams, T as RenderingOptions, _ 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, j as PluginExtension, k as Plugin, 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 RendererDecorator, x as LazyCommand, y as GunshiParams } from "./types-
|
|
1
|
+
import { a as resolveArgs, i as Args, n as ArgSchema, o as ArgToken, r as ArgValues, s as parseArgs } from "./resolver-CIPNDx1a.js";
|
|
2
|
+
import { A as PluginDependency, C as Prettify, D as ValidationErrorsDecorator, E as SubCommandable, F as PluginWithoutExtension, I as plugin, L as PluginContext, M as PluginFunction, N as PluginOptions, O as OnPluginExtension, P as PluginWithExtension, S as NormalizeToGunshiParams, T as RenderingOptions, _ 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, j as PluginExtension, k as Plugin, 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 RendererDecorator, x as LazyCommand, y as GunshiParams } from "./types-CyyzAaDx.js";
|
|
3
3
|
import { CommandContextParams, createCommandContext } from "./context.js";
|
|
4
4
|
import { define, defineWithTypes, lazy, lazyWithTypes } from "./definition.js";
|
|
5
|
-
import { t as ANONYMOUS_COMMAND_NAME } from "./constants-
|
|
5
|
+
import { t as ANONYMOUS_COMMAND_NAME } from "./constants-CPTXtFxe.js";
|
|
6
6
|
|
|
7
7
|
//#region ../plugin-i18n/src/types.d.ts
|
|
8
8
|
/**
|
package/lib/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as ANONYMOUS_COMMAND_NAME } from "./constants-D_ixLD32.js";
|
|
2
2
|
import { createCommandContext } from "./context.js";
|
|
3
3
|
import { t as plugin } from "./core-D1daCTTE.js";
|
|
4
|
-
import { a as namespacedId } from "./src-
|
|
5
|
-
import { n as resolveArgs, r as parseArgs } from "./core-
|
|
6
|
-
import { t as cli } from "./cli-
|
|
4
|
+
import { a as namespacedId } from "./src-dTYUlEw_.js";
|
|
5
|
+
import { n as resolveArgs, r as parseArgs } from "./core-BKtZQ6dG.js";
|
|
6
|
+
import { t as cli } from "./cli-DfaFk6tk.js";
|
|
7
7
|
import { define, defineWithTypes, lazy, lazyWithTypes } from "./definition.js";
|
|
8
8
|
//#region ../plugin-i18n/src/translation.ts
|
|
9
9
|
/**
|
package/lib/plugin.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { i as Args, n as ArgSchema, o as ArgToken, r as ArgValues } from "./resolver-
|
|
2
|
-
import { A as PluginDependency, C as Prettify, D as ValidationErrorsDecorator, F as PluginWithoutExtension, I as plugin, L as PluginContext, M as PluginFunction, N as PluginOptions, O as OnPluginExtension, P as PluginWithExtension, S as NormalizeToGunshiParams, _ as ExtractArgs, a as CommandContext, b as GunshiParamsConstraint, c as CommandDecorator, f as CommandRunner, h as ExtendContext, j as PluginExtension, k as Plugin, m as DefaultGunshiParams, o as CommandContextCore, r as Command, s as CommandContextExtension, t as Awaitable, u as CommandExamplesFetcher, v as ExtractExtensions, w as RendererDecorator, x as LazyCommand, y as GunshiParams } from "./types-
|
|
1
|
+
import { i as Args, n as ArgSchema, o as ArgToken, r as ArgValues } from "./resolver-CIPNDx1a.js";
|
|
2
|
+
import { A as PluginDependency, C as Prettify, D as ValidationErrorsDecorator, F as PluginWithoutExtension, I as plugin, L as PluginContext, M as PluginFunction, N as PluginOptions, O as OnPluginExtension, P as PluginWithExtension, S as NormalizeToGunshiParams, _ as ExtractArgs, a as CommandContext, b as GunshiParamsConstraint, c as CommandDecorator, f as CommandRunner, h as ExtendContext, j as PluginExtension, k as Plugin, m as DefaultGunshiParams, o as CommandContextCore, r as Command, s as CommandContextExtension, t as Awaitable, u as CommandExamplesFetcher, v as ExtractExtensions, w as RendererDecorator, x as LazyCommand, y as GunshiParams } from "./types-CyyzAaDx.js";
|
|
3
3
|
import { CommandContextParams, createCommandContext } from "./context.js";
|
|
4
|
-
import { n as CLI_OPTIONS_DEFAULT, t as ANONYMOUS_COMMAND_NAME } from "./constants-
|
|
4
|
+
import { n as CLI_OPTIONS_DEFAULT, t as ANONYMOUS_COMMAND_NAME } from "./constants-CPTXtFxe.js";
|
|
5
5
|
|
|
6
6
|
//#region src/plugin.d.ts
|
|
7
7
|
/**
|
package/lib/renderer.d.ts
CHANGED
package/lib/renderer.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as renderHeader, n as renderValidationErrors, r as renderUsage } from "./src-
|
|
1
|
+
import { i as renderHeader, n as renderValidationErrors, r as renderUsage } from "./src-dTYUlEw_.js";
|
|
2
2
|
//#region src/renderer.ts
|
|
3
3
|
/**
|
|
4
4
|
* @author kazuya kawaguchi (a.k.a. kazupon)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/args-tokens@0.
|
|
1
|
+
//#region ../../node_modules/.pnpm/args-tokens@0.25.0/node_modules/args-tokens/lib/parser-D95CJBHr.d.ts
|
|
2
2
|
//#region src/parser.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Entry point of argument parser.
|
|
@@ -88,7 +88,7 @@ declare function parseArgs(args: string[], options?: ParserOptions): ArgToken[];
|
|
|
88
88
|
* @returns Whether `arg` is a short option.
|
|
89
89
|
*/
|
|
90
90
|
//#endregion
|
|
91
|
-
//#region ../../node_modules/.pnpm/args-tokens@0.
|
|
91
|
+
//#region ../../node_modules/.pnpm/args-tokens@0.25.0/node_modules/args-tokens/lib/resolver.d.ts
|
|
92
92
|
//#region src/resolver.d.ts
|
|
93
93
|
/**
|
|
94
94
|
* An argument schema definition for command-line argument parsing.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./constants-D_ixLD32.js";
|
|
2
|
-
import { o as resolveLazyCommand, s as kebabnize } from "./utils-
|
|
2
|
+
import { o as resolveLazyCommand, s as kebabnize } from "./utils-jNy8sqR5.js";
|
|
3
3
|
import { t as plugin } from "./core-D1daCTTE.js";
|
|
4
4
|
/**
|
|
5
5
|
* @author kazuya kawaguchi (a.k.a. kazupon)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as Args, n as ArgSchema, o as ArgToken, r as ArgValues, t as ArgExplicitlyProvided } from "./resolver-
|
|
1
|
+
import { i as Args, n as ArgSchema, o as ArgToken, r as ArgValues, t as ArgExplicitlyProvided } from "./resolver-CIPNDx1a.js";
|
|
2
2
|
|
|
3
3
|
//#region src/plugin/context.d.ts
|
|
4
4
|
/**
|
package/lib/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { b as GunshiParamsConstraint, m as DefaultGunshiParams, p as Commandable, r as Command, x as LazyCommand } from "./types-
|
|
1
|
+
import { b as GunshiParamsConstraint, m as DefaultGunshiParams, p as Commandable, r as Command, x as LazyCommand } from "./types-CyyzAaDx.js";
|
|
2
2
|
|
|
3
|
-
//#region ../../node_modules/.pnpm/args-tokens@0.
|
|
3
|
+
//#region ../../node_modules/.pnpm/args-tokens@0.25.0/node_modules/args-tokens/lib/utils.d.ts
|
|
4
4
|
|
|
5
5
|
//#region src/utils.d.ts
|
|
6
6
|
/**
|
package/lib/utils.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as log, i as isLazyCommand, n as deepFreeze, o as resolveLazyCommand, r as getCommandSubCommands, s as kebabnize, t as create } from "./utils-
|
|
1
|
+
import { a as log, i as isLazyCommand, n as deepFreeze, o as resolveLazyCommand, r as getCommandSubCommands, s as kebabnize, t as create } from "./utils-jNy8sqR5.js";
|
|
2
2
|
export { create, deepFreeze, getCommandSubCommands, isLazyCommand, kebabnize, log, resolveLazyCommand };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gunshi",
|
|
3
3
|
"description": "Modern javascript command-line library",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.31.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "kazuya kawaguchi",
|
|
7
7
|
"email": "kawakazu80@gmail.com"
|
|
@@ -90,6 +90,12 @@
|
|
|
90
90
|
"require": "./lib/combinators.js",
|
|
91
91
|
"default": "./lib/combinators.js"
|
|
92
92
|
},
|
|
93
|
+
"./agent": {
|
|
94
|
+
"types": "./lib/agent.d.ts",
|
|
95
|
+
"import": "./lib/agent.js",
|
|
96
|
+
"require": "./lib/agent.js",
|
|
97
|
+
"default": "./lib/agent.js"
|
|
98
|
+
},
|
|
93
99
|
"./package.json": "./package.json"
|
|
94
100
|
},
|
|
95
101
|
"types": "lib/index.d.ts",
|
|
@@ -102,18 +108,19 @@
|
|
|
102
108
|
}
|
|
103
109
|
},
|
|
104
110
|
"devDependencies": {
|
|
105
|
-
"args-tokens": "^0.
|
|
111
|
+
"args-tokens": "^0.25.0",
|
|
106
112
|
"deno": "^2.7.14",
|
|
107
113
|
"jsr": "^0.14.3",
|
|
108
114
|
"jsr-exports-lint": "^0.4.2",
|
|
109
115
|
"publint": "^0.3.20",
|
|
116
|
+
"std-env": "^4.1.0",
|
|
110
117
|
"tsdown": "0.21.0",
|
|
111
118
|
"zod": "^4.4.3",
|
|
112
|
-
"@gunshi/plugin-global": "0.
|
|
113
|
-
"@gunshi/plugin-
|
|
114
|
-
"@gunshi/
|
|
115
|
-
"@gunshi/
|
|
116
|
-
"@gunshi/shared": "0.
|
|
119
|
+
"@gunshi/plugin-global": "0.31.0",
|
|
120
|
+
"@gunshi/plugin-i18n": "0.31.0",
|
|
121
|
+
"@gunshi/plugin-renderer": "0.31.0",
|
|
122
|
+
"@gunshi/resources": "0.31.0",
|
|
123
|
+
"@gunshi/shared": "0.31.0"
|
|
117
124
|
},
|
|
118
125
|
"scripts": {
|
|
119
126
|
"build": "tsdown",
|