@outfitter/cli 0.5.3 → 1.0.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 +105 -2
- package/dist/actions.d.ts +5 -2
- package/dist/actions.js +2 -2
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +8 -1
- package/dist/command.d.ts +3 -43
- package/dist/command.js +241 -13
- package/dist/envelope.d.ts +5 -0
- package/dist/envelope.js +160 -0
- package/dist/flags.d.ts +5 -189
- package/dist/flags.js +5 -1
- package/dist/hints.d.ts +34 -0
- package/dist/hints.js +26 -0
- package/dist/index.d.ts +3 -2
- package/dist/input.d.ts +3 -124
- package/dist/input.js +14 -359
- package/dist/internal/envelope-helpers.d.ts +4 -0
- package/dist/internal/envelope-helpers.js +24 -0
- package/dist/internal/envelope-types.d.ts +3 -0
- package/dist/internal/envelope-types.js +1 -0
- package/dist/internal/flag-builders.d.ts +3 -0
- package/dist/internal/flag-builders.js +155 -0
- package/dist/internal/flag-types.d.ts +3 -0
- package/dist/internal/flag-types.js +13 -0
- package/dist/internal/hint-action-graph.d.ts +5 -0
- package/dist/internal/hint-action-graph.js +11 -0
- package/dist/internal/hint-command-tree.d.ts +5 -0
- package/dist/internal/hint-command-tree.js +9 -0
- package/dist/internal/hint-error-recovery.d.ts +2 -0
- package/dist/internal/hint-error-recovery.js +7 -0
- package/dist/internal/hint-types.d.ts +4 -0
- package/dist/internal/hint-types.js +1 -0
- package/dist/internal/input-helpers.d.ts +18 -0
- package/dist/internal/input-helpers.js +11 -0
- package/dist/internal/input-normalization.d.ts +3 -0
- package/dist/internal/input-normalization.js +9 -0
- package/dist/internal/input-parsers.d.ts +3 -0
- package/dist/internal/input-parsers.js +19 -0
- package/dist/internal/input-security.d.ts +22 -0
- package/dist/internal/input-security.js +11 -0
- package/dist/internal/output-formatting.d.ts +3 -0
- package/dist/internal/output-formatting.js +21 -0
- package/dist/internal/presets.d.ts +3 -0
- package/dist/{shared/@outfitter/cli-pdb7znbq.js → internal/presets.js} +49 -223
- package/dist/internal/schema-commands.d.ts +3 -0
- package/dist/{shared/@outfitter/cli-5vtr4bdt.js → internal/schema-commands.js} +8 -99
- package/dist/internal/schema-formatting.d.ts +2 -0
- package/dist/internal/schema-formatting.js +7 -0
- package/dist/internal/schema-types.d.ts +2 -0
- package/dist/internal/schema-types.js +1 -0
- package/dist/output.d.ts +4 -3
- package/dist/output.js +13 -166
- package/dist/pagination.d.ts +1 -1
- package/dist/query.d.ts +84 -2
- package/dist/query.js +8 -45
- package/dist/schema-input.d.ts +80 -0
- package/dist/schema-input.js +15 -0
- package/dist/schema.d.ts +4 -1
- package/dist/schema.js +1 -1
- package/dist/shared/@outfitter/cli-10wxfc78.d.ts +45 -0
- package/dist/shared/@outfitter/cli-16wg5mka.d.ts +71 -0
- package/dist/shared/@outfitter/cli-1q5redaj.js +267 -0
- package/dist/shared/@outfitter/cli-2dfxs239.js +98 -0
- package/dist/shared/@outfitter/cli-30mt7c5w.d.ts +112 -0
- package/dist/shared/@outfitter/cli-3jta1h1h.js +134 -0
- package/dist/shared/@outfitter/cli-4h85mpth.js +76 -0
- package/dist/shared/@outfitter/cli-6shkwxdc.js +28 -0
- package/dist/shared/@outfitter/cli-89335n9a.js +16 -0
- package/dist/shared/@outfitter/cli-8999qjdd.js +3 -0
- package/dist/shared/@outfitter/cli-8cfxdady.js +60 -0
- package/dist/shared/@outfitter/cli-bcajqy33.d.ts +25 -0
- package/dist/shared/@outfitter/cli-c09332vm.d.ts +39 -0
- package/dist/shared/@outfitter/cli-cgha038c.d.ts +3 -0
- package/dist/shared/@outfitter/{cli-zahqsaby.js → cli-d40m2x1d.js} +19 -3
- package/dist/shared/@outfitter/cli-dg0cz7rw.js +127 -0
- package/dist/shared/@outfitter/cli-dv8kk4jw.d.ts +24 -0
- package/dist/shared/@outfitter/cli-g43887b7.js +20 -0
- package/dist/shared/@outfitter/cli-gqtkhgw4.js +52 -0
- package/dist/shared/@outfitter/cli-h4ejpmjs.d.ts +104 -0
- package/dist/shared/@outfitter/cli-htzez8v2.js +70 -0
- package/dist/shared/@outfitter/cli-hvg2m5gf.js +79 -0
- package/dist/shared/@outfitter/cli-n54zs151.d.ts +78 -0
- package/dist/shared/@outfitter/cli-nbpgw7z7.d.ts +15 -0
- package/dist/shared/@outfitter/cli-nkt399zf.d.ts +94 -0
- package/dist/shared/@outfitter/cli-pmd04gtv.d.ts +60 -0
- package/dist/shared/@outfitter/{cli-xy3gs50c.d.ts → cli-q6csxmeh.d.ts} +19 -12
- package/dist/shared/@outfitter/cli-qcskd96y.d.ts +11 -0
- package/dist/shared/@outfitter/cli-ry7btmy4.js +118 -0
- package/dist/shared/@outfitter/cli-sy99pjyj.js +32 -0
- package/dist/shared/@outfitter/cli-tm2fzngs.d.ts +23 -0
- package/dist/shared/@outfitter/cli-vvvhjwks.js +106 -0
- package/dist/shared/@outfitter/cli-wjv7g1aq.d.ts +16 -0
- package/dist/shared/@outfitter/{cli-98aa9104.d.ts → cli-x6qr7bnd.d.ts} +338 -16
- package/dist/shared/@outfitter/cli-xde45xcc.d.ts +53 -0
- package/dist/shared/@outfitter/cli-xw8ys1je.d.ts +123 -0
- package/dist/shared/@outfitter/cli-yfewnyc2.d.ts +43 -0
- package/dist/shared/@outfitter/cli-zkzj0q4q.js +99 -0
- package/dist/shared/@outfitter/cli-zv3ah6f0.js +3 -0
- package/dist/streaming.d.ts +47 -0
- package/dist/streaming.js +13 -0
- package/dist/truncation.d.ts +104 -0
- package/dist/truncation.js +111 -0
- package/dist/types.d.ts +2 -2
- package/dist/verbs.d.ts +1 -1
- package/package.json +55 -25
- package/dist/shared/@outfitter/cli-n1k0d23k.d.ts +0 -33
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { expandFileArg, parseFilter, parseGlob, parseKeyValue, parseRange, parseSortSpec } from "../shared/@outfitter/cli-h4ejpmjs.js";
|
|
2
|
+
import "../shared/@outfitter/cli-x6qr7bnd.js";
|
|
3
|
+
export { parseSortSpec, parseRange, parseKeyValue, parseGlob, parseFilter, expandFileArg };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
expandFileArg,
|
|
4
|
+
parseFilter,
|
|
5
|
+
parseGlob,
|
|
6
|
+
parseKeyValue,
|
|
7
|
+
parseRange,
|
|
8
|
+
parseSortSpec
|
|
9
|
+
} from "../shared/@outfitter/cli-1q5redaj.js";
|
|
10
|
+
import"../shared/@outfitter/cli-sy99pjyj.js";
|
|
11
|
+
import"../shared/@outfitter/cli-6shkwxdc.js";
|
|
12
|
+
export {
|
|
13
|
+
parseSortSpec,
|
|
14
|
+
parseRange,
|
|
15
|
+
parseKeyValue,
|
|
16
|
+
parseGlob,
|
|
17
|
+
parseFilter,
|
|
18
|
+
expandFileArg
|
|
19
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validates that a path doesn't contain traversal patterns.
|
|
3
|
+
*
|
|
4
|
+
* Rejects paths that:
|
|
5
|
+
* - Start with .. or contain /.. or \..
|
|
6
|
+
* - Contain null bytes
|
|
7
|
+
* - Are absolute paths (unless explicitly allowed)
|
|
8
|
+
*/
|
|
9
|
+
declare function isSecurePath(filePath: string, allowAbsolute?: boolean): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Validates that a glob pattern doesn't escape the workspace.
|
|
12
|
+
*
|
|
13
|
+
* Rejects patterns that:
|
|
14
|
+
* - Start with ..
|
|
15
|
+
* - Contain /../
|
|
16
|
+
*/
|
|
17
|
+
declare function isSecureGlobPattern(pattern: string): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Validates that a resolved path is within the workspace boundary.
|
|
20
|
+
*/
|
|
21
|
+
declare function isWithinWorkspace(resolvedPath: string, workspaceRoot: string): boolean;
|
|
22
|
+
export { isWithinWorkspace, isSecurePath, isSecureGlobPattern };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { applyOutputTruncation, cliStringify, detectMode, formatErrorHuman, formatHuman, getExitCode, serializeErrorToJson, writeWithBackpressure } from "../shared/@outfitter/cli-10wxfc78.js";
|
|
2
|
+
import "../shared/@outfitter/cli-x6qr7bnd.js";
|
|
3
|
+
export { writeWithBackpressure, serializeErrorToJson, getExitCode, formatHuman, formatErrorHuman, detectMode, cliStringify, applyOutputTruncation };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
applyOutputTruncation,
|
|
4
|
+
cliStringify,
|
|
5
|
+
detectMode,
|
|
6
|
+
formatErrorHuman,
|
|
7
|
+
formatHuman,
|
|
8
|
+
getExitCode,
|
|
9
|
+
serializeErrorToJson,
|
|
10
|
+
writeWithBackpressure
|
|
11
|
+
} from "../shared/@outfitter/cli-dg0cz7rw.js";
|
|
12
|
+
export {
|
|
13
|
+
writeWithBackpressure,
|
|
14
|
+
serializeErrorToJson,
|
|
15
|
+
getExitCode,
|
|
16
|
+
formatHuman,
|
|
17
|
+
formatErrorHuman,
|
|
18
|
+
detectMode,
|
|
19
|
+
cliStringify,
|
|
20
|
+
applyOutputTruncation
|
|
21
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { colorPreset, cwdPreset, dryRunPreset, executionPreset, forcePreset, interactionPreset, paginationPreset, projectionPreset, strictPreset, timeWindowPreset, verbosePreset } from "../shared/@outfitter/cli-xw8ys1je.js";
|
|
2
|
+
import "../shared/@outfitter/cli-x6qr7bnd.js";
|
|
3
|
+
export { verbosePreset, timeWindowPreset, strictPreset, projectionPreset, paginationPreset, interactionPreset, forcePreset, executionPreset, dryRunPreset, cwdPreset, colorPreset };
|
|
@@ -1,193 +1,20 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
preset[PRESET_IDS] = [config.id];
|
|
10
|
-
return preset;
|
|
11
|
-
}
|
|
12
|
-
var PRESET_IDS = Symbol("presetIds");
|
|
13
|
-
function getPresetIds(preset) {
|
|
14
|
-
const ids = preset[PRESET_IDS];
|
|
15
|
-
return ids && ids.length > 0 ? ids : [preset.id];
|
|
16
|
-
}
|
|
17
|
-
function composePresets(...presets) {
|
|
18
|
-
const seen = new Set;
|
|
19
|
-
const mergedIds = [];
|
|
20
|
-
const mergedOptions = [];
|
|
21
|
-
const resolvers = [];
|
|
22
|
-
for (const preset of presets) {
|
|
23
|
-
const presetIds = getPresetIds(preset);
|
|
24
|
-
if (presetIds.every((id) => seen.has(id)))
|
|
25
|
-
continue;
|
|
26
|
-
for (const id of presetIds) {
|
|
27
|
-
if (seen.has(id))
|
|
28
|
-
continue;
|
|
29
|
-
seen.add(id);
|
|
30
|
-
mergedIds.push(id);
|
|
31
|
-
}
|
|
32
|
-
mergedOptions.push(...preset.options);
|
|
33
|
-
resolvers.push(preset.resolve);
|
|
34
|
-
}
|
|
35
|
-
const composed = {
|
|
36
|
-
id: mergedIds.join("+"),
|
|
37
|
-
options: mergedOptions,
|
|
38
|
-
resolve: (flags) => {
|
|
39
|
-
let result = {};
|
|
40
|
-
for (const resolver of resolvers) {
|
|
41
|
-
result = { ...result, ...resolver(flags) };
|
|
42
|
-
}
|
|
43
|
-
return result;
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
composed[PRESET_IDS] = mergedIds;
|
|
47
|
-
return composed;
|
|
48
|
-
}
|
|
49
|
-
function resolveSourceKeys(key, sources) {
|
|
50
|
-
return sources && sources.length > 0 ? sources : [key];
|
|
51
|
-
}
|
|
52
|
-
function booleanFlagPreset(config) {
|
|
53
|
-
const sources = resolveSourceKeys(config.key, config.sources);
|
|
54
|
-
const defaultValue = config.defaultValue ?? false;
|
|
55
|
-
const isNegatedFlag = config.flags.includes("--no-");
|
|
56
|
-
const optionDefault = isNegatedFlag && config.defaultValue === undefined ? {} : { defaultValue };
|
|
57
|
-
return createPreset({
|
|
58
|
-
id: config.id,
|
|
59
|
-
options: [
|
|
60
|
-
{
|
|
61
|
-
flags: config.flags,
|
|
62
|
-
description: config.description,
|
|
63
|
-
...optionDefault,
|
|
64
|
-
...config.required === true ? { required: true } : {}
|
|
65
|
-
}
|
|
66
|
-
],
|
|
67
|
-
resolve: (flags) => {
|
|
68
|
-
for (const source of sources) {
|
|
69
|
-
const value = flags[source];
|
|
70
|
-
if (typeof value === "boolean") {
|
|
71
|
-
return { [config.key]: value };
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
if (config.negatedSources) {
|
|
75
|
-
for (const source of config.negatedSources) {
|
|
76
|
-
const value = flags[source];
|
|
77
|
-
if (typeof value === "boolean") {
|
|
78
|
-
return { [config.key]: !value };
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return { [config.key]: defaultValue };
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
function enumFlagPreset(config) {
|
|
87
|
-
const sources = resolveSourceKeys(config.key, config.sources);
|
|
88
|
-
const allowed = new Set(config.values);
|
|
89
|
-
return createPreset({
|
|
90
|
-
id: config.id,
|
|
91
|
-
options: [
|
|
92
|
-
{
|
|
93
|
-
flags: config.flags,
|
|
94
|
-
description: config.description,
|
|
95
|
-
...config.required === true ? { required: true } : {}
|
|
96
|
-
}
|
|
97
|
-
],
|
|
98
|
-
resolve: (flags) => {
|
|
99
|
-
for (const source of sources) {
|
|
100
|
-
const value = flags[source];
|
|
101
|
-
if (typeof value === "string" && allowed.has(value)) {
|
|
102
|
-
return { [config.key]: value };
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return {
|
|
106
|
-
[config.key]: config.defaultValue
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
function numberFlagPreset(config) {
|
|
112
|
-
const sources = resolveSourceKeys(config.key, config.sources);
|
|
113
|
-
return createPreset({
|
|
114
|
-
id: config.id,
|
|
115
|
-
options: [
|
|
116
|
-
{
|
|
117
|
-
flags: config.flags,
|
|
118
|
-
description: config.description,
|
|
119
|
-
...config.required === true ? { required: true } : {}
|
|
120
|
-
}
|
|
121
|
-
],
|
|
122
|
-
resolve: (flags) => {
|
|
123
|
-
let parsed;
|
|
124
|
-
for (const source of sources) {
|
|
125
|
-
const value = flags[source];
|
|
126
|
-
if (value === "" || value == null || typeof value === "boolean") {
|
|
127
|
-
continue;
|
|
128
|
-
}
|
|
129
|
-
const numeric = Number(value);
|
|
130
|
-
if (Number.isFinite(numeric)) {
|
|
131
|
-
parsed = config.integer === false ? numeric : Math.floor(numeric);
|
|
132
|
-
break;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
if (parsed === undefined) {
|
|
136
|
-
parsed = config.defaultValue;
|
|
137
|
-
}
|
|
138
|
-
if (typeof config.min === "number" && Number.isFinite(config.min)) {
|
|
139
|
-
parsed = Math.max(parsed, config.min);
|
|
140
|
-
}
|
|
141
|
-
if (typeof config.max === "number" && Number.isFinite(config.max)) {
|
|
142
|
-
parsed = Math.min(parsed, config.max);
|
|
143
|
-
}
|
|
144
|
-
return { [config.key]: parsed };
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
function normalizeStringListInput(value, separator) {
|
|
149
|
-
if (Array.isArray(value)) {
|
|
150
|
-
const items2 = value.filter((item) => typeof item === "string").map((item) => item.trim()).filter(Boolean);
|
|
151
|
-
return items2.length > 0 ? items2 : undefined;
|
|
152
|
-
}
|
|
2
|
+
import {
|
|
3
|
+
createPreset
|
|
4
|
+
} from "../shared/@outfitter/cli-8cfxdady.js";
|
|
5
|
+
|
|
6
|
+
// packages/cli/src/internal/presets.ts
|
|
7
|
+
function parseCommaSeparated(value) {
|
|
153
8
|
if (typeof value !== "string")
|
|
154
9
|
return;
|
|
155
|
-
const items = value.split(
|
|
10
|
+
const items = value.split(",").map((s) => s.trim()).filter(Boolean);
|
|
156
11
|
return items.length > 0 ? items : undefined;
|
|
157
12
|
}
|
|
158
|
-
function
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
return
|
|
163
|
-
id: config.id,
|
|
164
|
-
options: [
|
|
165
|
-
{
|
|
166
|
-
flags: config.flags,
|
|
167
|
-
description: config.description,
|
|
168
|
-
...config.required === true ? { required: true } : {}
|
|
169
|
-
}
|
|
170
|
-
],
|
|
171
|
-
resolve: (flags) => {
|
|
172
|
-
let resolved;
|
|
173
|
-
for (const source of sources) {
|
|
174
|
-
const parsed = normalizeStringListInput(flags[source], separator);
|
|
175
|
-
if (parsed !== undefined) {
|
|
176
|
-
resolved = parsed;
|
|
177
|
-
break;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
if (resolved === undefined) {
|
|
181
|
-
resolved = fallback === undefined ? undefined : [...fallback];
|
|
182
|
-
}
|
|
183
|
-
if (resolved && config.dedupe) {
|
|
184
|
-
resolved = [...new Set(resolved)];
|
|
185
|
-
}
|
|
186
|
-
return {
|
|
187
|
-
[config.key]: resolved
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
});
|
|
13
|
+
function sanitizePositiveInteger(value, fallback) {
|
|
14
|
+
const parsed = Number(value);
|
|
15
|
+
if (!Number.isFinite(parsed) || parsed <= 0)
|
|
16
|
+
return fallback;
|
|
17
|
+
return Math.floor(parsed);
|
|
191
18
|
}
|
|
192
19
|
function verbosePreset() {
|
|
193
20
|
return createPreset({
|
|
@@ -319,12 +146,6 @@ function colorPreset() {
|
|
|
319
146
|
}
|
|
320
147
|
});
|
|
321
148
|
}
|
|
322
|
-
function parseCommaSeparated(value) {
|
|
323
|
-
if (typeof value !== "string")
|
|
324
|
-
return;
|
|
325
|
-
const items = value.split(",").map((s) => s.trim()).filter(Boolean);
|
|
326
|
-
return items.length > 0 ? items : undefined;
|
|
327
|
-
}
|
|
328
149
|
function projectionPreset() {
|
|
329
150
|
return createPreset({
|
|
330
151
|
id: "projection",
|
|
@@ -350,36 +171,6 @@ function projectionPreset() {
|
|
|
350
171
|
})
|
|
351
172
|
});
|
|
352
173
|
}
|
|
353
|
-
var DURATION_SUFFIXES = {
|
|
354
|
-
w: 7 * 24 * 60 * 60 * 1000,
|
|
355
|
-
d: 24 * 60 * 60 * 1000,
|
|
356
|
-
h: 60 * 60 * 1000,
|
|
357
|
-
m: 60 * 1000
|
|
358
|
-
};
|
|
359
|
-
function parseDate(value, nowMs = Date.now()) {
|
|
360
|
-
if (typeof value !== "string" || value === "")
|
|
361
|
-
return;
|
|
362
|
-
const durationMatch = value.match(/^(\d+(?:\.\d+)?)(w|d|h|m)$/);
|
|
363
|
-
if (durationMatch) {
|
|
364
|
-
const amount = Number(durationMatch[1]);
|
|
365
|
-
const suffix = durationMatch[2];
|
|
366
|
-
const multiplier = suffix ? DURATION_SUFFIXES[suffix] : undefined;
|
|
367
|
-
if (amount > 0 && multiplier !== undefined) {
|
|
368
|
-
return new Date(nowMs - amount * multiplier);
|
|
369
|
-
}
|
|
370
|
-
return;
|
|
371
|
-
}
|
|
372
|
-
const date = new Date(value);
|
|
373
|
-
if (Number.isNaN(date.getTime()))
|
|
374
|
-
return;
|
|
375
|
-
return date;
|
|
376
|
-
}
|
|
377
|
-
function sanitizePositiveInteger(value, fallback) {
|
|
378
|
-
const parsed = Number(value);
|
|
379
|
-
if (!Number.isFinite(parsed) || parsed <= 0)
|
|
380
|
-
return fallback;
|
|
381
|
-
return Math.floor(parsed);
|
|
382
|
-
}
|
|
383
174
|
function timeWindowPreset(config) {
|
|
384
175
|
return createPreset({
|
|
385
176
|
id: "timeWindow",
|
|
@@ -496,5 +287,40 @@ function paginationPreset(config) {
|
|
|
496
287
|
}
|
|
497
288
|
});
|
|
498
289
|
}
|
|
499
|
-
|
|
500
|
-
|
|
290
|
+
var DURATION_SUFFIXES = {
|
|
291
|
+
w: 7 * 24 * 60 * 60 * 1000,
|
|
292
|
+
d: 24 * 60 * 60 * 1000,
|
|
293
|
+
h: 60 * 60 * 1000,
|
|
294
|
+
m: 60 * 1000
|
|
295
|
+
};
|
|
296
|
+
function parseDate(value, nowMs = Date.now()) {
|
|
297
|
+
if (typeof value !== "string" || value === "")
|
|
298
|
+
return;
|
|
299
|
+
const durationMatch = value.match(/^(\d+(?:\.\d+)?)(w|d|h|m)$/);
|
|
300
|
+
if (durationMatch) {
|
|
301
|
+
const amount = Number(durationMatch[1]);
|
|
302
|
+
const suffix = durationMatch[2];
|
|
303
|
+
const multiplier = suffix ? DURATION_SUFFIXES[suffix] : undefined;
|
|
304
|
+
if (amount > 0 && multiplier !== undefined) {
|
|
305
|
+
return new Date(nowMs - amount * multiplier);
|
|
306
|
+
}
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
const date = new Date(value);
|
|
310
|
+
if (Number.isNaN(date.getTime()))
|
|
311
|
+
return;
|
|
312
|
+
return date;
|
|
313
|
+
}
|
|
314
|
+
export {
|
|
315
|
+
verbosePreset,
|
|
316
|
+
timeWindowPreset,
|
|
317
|
+
strictPreset,
|
|
318
|
+
projectionPreset,
|
|
319
|
+
paginationPreset,
|
|
320
|
+
interactionPreset,
|
|
321
|
+
forcePreset,
|
|
322
|
+
executionPreset,
|
|
323
|
+
dryRunPreset,
|
|
324
|
+
cwdPreset,
|
|
325
|
+
colorPreset
|
|
326
|
+
};
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
|
|
2
|
+
import {
|
|
3
|
+
formatManifestHuman
|
|
4
|
+
} from "../shared/@outfitter/cli-zkzj0q4q.js";
|
|
5
|
+
|
|
6
|
+
// packages/cli/src/internal/schema-commands.ts
|
|
3
7
|
import { mkdir, writeFile } from "fs/promises";
|
|
4
8
|
import { dirname, join } from "path";
|
|
5
9
|
import {
|
|
@@ -12,102 +16,6 @@ import {
|
|
|
12
16
|
writeSurfaceMap
|
|
13
17
|
} from "@outfitter/schema";
|
|
14
18
|
import { Command } from "commander";
|
|
15
|
-
import { generateManifest as generateManifest2 } from "@outfitter/schema";
|
|
16
|
-
function formatManifestHuman(manifest, programName, actionId) {
|
|
17
|
-
if (actionId) {
|
|
18
|
-
return formatActionDetail(manifest, actionId);
|
|
19
|
-
}
|
|
20
|
-
return formatSummary(manifest, programName);
|
|
21
|
-
}
|
|
22
|
-
function formatSummary(manifest, programName) {
|
|
23
|
-
const lines = [];
|
|
24
|
-
const name = programName ?? "cli";
|
|
25
|
-
const actionCount = manifest.actions.length;
|
|
26
|
-
const surfaceCount = manifest.surfaces.length;
|
|
27
|
-
const surfaceLabel = surfaceCount === 1 ? `${surfaceCount} surface` : `${surfaceCount} surfaces`;
|
|
28
|
-
lines.push(`${name} \u2014 ${actionCount} actions across ${surfaceLabel}`);
|
|
29
|
-
lines.push("");
|
|
30
|
-
const grouped = new Map;
|
|
31
|
-
const ungrouped = [];
|
|
32
|
-
for (const action of manifest.actions) {
|
|
33
|
-
const group = action.cli?.group;
|
|
34
|
-
if (group) {
|
|
35
|
-
const existing = grouped.get(group) ?? [];
|
|
36
|
-
existing.push(action);
|
|
37
|
-
grouped.set(group, existing);
|
|
38
|
-
} else {
|
|
39
|
-
ungrouped.push(action);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
for (const [groupName, groupActions] of grouped.entries()) {
|
|
43
|
-
lines.push(groupName);
|
|
44
|
-
for (const action of groupActions) {
|
|
45
|
-
const commandPart = action.cli?.command ?? "";
|
|
46
|
-
const isBase = !commandPart || commandPart.startsWith("[") || commandPart.startsWith("<");
|
|
47
|
-
const displayCommand = isBase ? ` ${groupName} ${commandPart}`.trimEnd() : ` ${groupName} ${commandPart}`;
|
|
48
|
-
const desc = action.cli?.description ?? action.description ?? "";
|
|
49
|
-
lines.push(padCommand(displayCommand, desc));
|
|
50
|
-
}
|
|
51
|
-
lines.push("");
|
|
52
|
-
}
|
|
53
|
-
for (const action of ungrouped) {
|
|
54
|
-
const commandPart = action.cli?.command ?? action.id;
|
|
55
|
-
const desc = action.cli?.description ?? action.description ?? "";
|
|
56
|
-
lines.push(padCommand(`${commandPart}`, desc));
|
|
57
|
-
}
|
|
58
|
-
lines.push("");
|
|
59
|
-
lines.push("Use --output json for machine-readable format.");
|
|
60
|
-
lines.push("Use --surface <name> to filter (cli, mcp, api, server).");
|
|
61
|
-
return lines.join(`
|
|
62
|
-
`);
|
|
63
|
-
}
|
|
64
|
-
function padCommand(command, description) {
|
|
65
|
-
const padding = Math.max(1, 32 - command.length);
|
|
66
|
-
return `${command}${" ".repeat(padding)}${description}`;
|
|
67
|
-
}
|
|
68
|
-
function formatActionDetail(manifest, actionId) {
|
|
69
|
-
const entry = manifest.actions.find((a) => a.id === actionId);
|
|
70
|
-
if (!entry) {
|
|
71
|
-
return `Unknown action: ${actionId}`;
|
|
72
|
-
}
|
|
73
|
-
const lines = [];
|
|
74
|
-
const desc = entry.cli?.description ?? entry.description ?? "";
|
|
75
|
-
lines.push(`${entry.id} \u2014 ${desc}`);
|
|
76
|
-
lines.push("");
|
|
77
|
-
if (entry.cli) {
|
|
78
|
-
const group = entry.cli.group;
|
|
79
|
-
const commandPart = entry.cli.command ?? (group ? "" : entry.id);
|
|
80
|
-
const fullCommand = group ? `${group} ${commandPart}`.trimEnd() : commandPart;
|
|
81
|
-
lines.push(` Command: ${fullCommand}`);
|
|
82
|
-
}
|
|
83
|
-
lines.push(` Surfaces: ${entry.surfaces.join(", ")}`);
|
|
84
|
-
if (entry.cli?.group) {
|
|
85
|
-
lines.push(` Group: ${entry.cli.group}`);
|
|
86
|
-
}
|
|
87
|
-
if (entry.cli?.aliases && entry.cli.aliases.length > 0) {
|
|
88
|
-
lines.push(` Aliases: ${entry.cli.aliases.join(", ")}`);
|
|
89
|
-
}
|
|
90
|
-
if (entry.cli?.options && entry.cli.options.length > 0) {
|
|
91
|
-
lines.push("");
|
|
92
|
-
lines.push(" Options:");
|
|
93
|
-
for (const opt of entry.cli.options) {
|
|
94
|
-
const defaultStr = opt.defaultValue !== undefined ? ` [${String(opt.defaultValue)}]` : "";
|
|
95
|
-
lines.push(padCommand(` ${opt.flags}`, `${opt.description}${defaultStr}`));
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
if (entry.mcp) {
|
|
99
|
-
lines.push("");
|
|
100
|
-
lines.push(" MCP:");
|
|
101
|
-
if (entry.mcp.tool) {
|
|
102
|
-
lines.push(` Tool: ${entry.mcp.tool}`);
|
|
103
|
-
}
|
|
104
|
-
if (entry.mcp.description) {
|
|
105
|
-
lines.push(` Description: ${entry.mcp.description}`);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return lines.join(`
|
|
109
|
-
`);
|
|
110
|
-
}
|
|
111
19
|
function handleShow(source, programName, parentCmd, actionArg, cmdOptions) {
|
|
112
20
|
const manifestOptions = {};
|
|
113
21
|
if (cmdOptions.surface) {
|
|
@@ -318,5 +226,6 @@ function createSchemaCommand(source, options) {
|
|
|
318
226
|
}
|
|
319
227
|
return cmd;
|
|
320
228
|
}
|
|
321
|
-
|
|
322
|
-
|
|
229
|
+
export {
|
|
230
|
+
createSchemaCommand
|
|
231
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// @bun
|
package/dist/output.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { exitWithError, output, resolveVerbose } from "./shared/@outfitter/cli-
|
|
2
|
-
import "./shared/@outfitter/cli-
|
|
3
|
-
|
|
1
|
+
import { exitWithError, output, resolveVerbose } from "./shared/@outfitter/cli-q6csxmeh.js";
|
|
2
|
+
import { cliStringify, detectMode, formatHuman } from "./shared/@outfitter/cli-10wxfc78.js";
|
|
3
|
+
import "./shared/@outfitter/cli-x6qr7bnd.js";
|
|
4
|
+
export { resolveVerbose, output, formatHuman, exitWithError, detectMode, cliStringify };
|