gh-axi 0.1.31 → 0.1.33
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 +4 -1
- package/dist/src/commands/api.d.ts +2 -2
- package/dist/src/commands/api.js +139 -58
- package/dist/src/commands/api.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -151,7 +151,10 @@ Gist visibility is fixed at creation; a secret gist is unlisted (anyone with the
|
|
|
151
151
|
Two file-on-disk input forms are available: positional paths (`gist create a.py b.py`) or repeatable `--file` flags (`gist create --file a.py --file b.py`); mixing the two is an error.
|
|
152
152
|
To create a gist from piped content, use `--filename <name>` together with a pipe (`echo "..." | gh-axi gist create --filename foo.txt --public`).
|
|
153
153
|
|
|
154
|
-
`gh-axi api` accepts `--field`, `--header`, `--paginate`, `--jq <expression>`, `--template <format>`, and `--full
|
|
154
|
+
`gh-axi api` accepts `-X <method>` and `-X=<method>` as alternatives to the positional HTTP method, plus `--field`, `--header`, `--input <file>`, `--paginate`, `--jq <expression>`, `--template <format>`, and `--full`.
|
|
155
|
+
Use `--input <file>` to send a raw JSON request body, or `--input -` to relay piped stdin byte for byte.
|
|
156
|
+
`--input -` rejects an interactive terminal instead of waiting for input.
|
|
157
|
+
Giving `-X` more than once or together with a positional method is rejected, as is any other unsupported flag, extra positional argument, or repeated `--input`/`--jq`/`--template`.
|
|
155
158
|
JSON responses are normally stripped of noisy fields before TOON encoding, but a response you shaped yourself with `--jq` or `--template` keeps every key and value verbatim — only over-long strings are still truncated so one field cannot flood an agent's context.
|
|
156
159
|
`--full` is an explicit opt-in escape hatch: it keeps every field and every complete value, and it also returns non-JSON response bodies without the length cap. `--full` is a gh-axi flag only, and gh-axi does not send it to `gh`. Compact output stays the default without `--full`.
|
|
157
160
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { RepoContext } from
|
|
2
|
-
export declare const API_HELP = "usage: gh-axi api [<method>] <path>\ndescription: Make an authenticated GitHub API request. Defaults to GET if no method specified.\nmethods[6]:\n GET, POST, PUT, PATCH, DELETE, HEAD\nflags[
|
|
1
|
+
import type { RepoContext } from "../context.js";
|
|
2
|
+
export declare const API_HELP = "usage: gh-axi api [<method>] <path>\ndescription: Make an authenticated GitHub API request. Defaults to GET if no method specified.\nmethods[6]:\n GET, POST, PUT, PATCH, DELETE, HEAD\nflags[8]:\n -X <method> or -X=<method> (alias for the positional method; give once and do not combine with a positional method), --field <key=value> (repeatable), --header <key:value> (repeatable), --input <file> (raw JSON request body; use \"-\" for stdin), --paginate, --jq <expression>, --template <format>, --full (preserve complete field values and response bodies without truncation)\nexamples:\n gh-axi api /repos/{owner}/{repo}\n gh-axi api POST /repos/{owner}/{repo}/issues --field title=\"Bug report\"\n gh-axi api -X POST /repos/{owner}/{repo}/issues --field title=\"Bug report\"\n gh-axi api /repos/{owner}/{repo}/pulls --paginate\n gh-axi api /repos/{owner}/{repo}/issues/1 --jq '[.labels[].name]'\n gh-axi api PUT /repos/{owner}/{repo}/branches/main/protection --input body.json\n cat body.json | gh-axi api PUT /repos/{owner}/{repo}/branches/main/protection --input -";
|
|
3
3
|
export declare function apiCommand(args: string[], ctx?: RepoContext): Promise<string>;
|
package/dist/src/commands/api.js
CHANGED
|
@@ -1,28 +1,41 @@
|
|
|
1
|
-
import { encode } from
|
|
2
|
-
import { ghExec } from
|
|
3
|
-
import { AxiError } from
|
|
4
|
-
import { cleanBody } from
|
|
1
|
+
import { encode } from "@toon-format/toon";
|
|
2
|
+
import { ghExec, ghExecWithStdin } from "../gh.js";
|
|
3
|
+
import { AxiError } from "../errors.js";
|
|
4
|
+
import { cleanBody } from "../body.js";
|
|
5
|
+
import { readStdin, isStdinTTY } from "../stdin.js";
|
|
5
6
|
export const API_HELP = `usage: gh-axi api [<method>] <path>
|
|
6
7
|
description: Make an authenticated GitHub API request. Defaults to GET if no method specified.
|
|
7
8
|
methods[6]:
|
|
8
9
|
GET, POST, PUT, PATCH, DELETE, HEAD
|
|
9
|
-
flags[
|
|
10
|
-
--field <key=value> (repeatable), --header <key:value> (repeatable), --paginate, --jq <expression>, --template <format>, --full (preserve complete field values and response bodies without truncation)
|
|
10
|
+
flags[8]:
|
|
11
|
+
-X <method> or -X=<method> (alias for the positional method; give once and do not combine with a positional method), --field <key=value> (repeatable), --header <key:value> (repeatable), --input <file> (raw JSON request body; use "-" for stdin), --paginate, --jq <expression>, --template <format>, --full (preserve complete field values and response bodies without truncation)
|
|
11
12
|
examples:
|
|
12
13
|
gh-axi api /repos/{owner}/{repo}
|
|
13
14
|
gh-axi api POST /repos/{owner}/{repo}/issues --field title="Bug report"
|
|
15
|
+
gh-axi api -X POST /repos/{owner}/{repo}/issues --field title="Bug report"
|
|
14
16
|
gh-axi api /repos/{owner}/{repo}/pulls --paginate
|
|
15
|
-
gh-axi api /repos/{owner}/{repo}/issues/1 --jq '[.labels[].name]'
|
|
16
|
-
|
|
17
|
+
gh-axi api /repos/{owner}/{repo}/issues/1 --jq '[.labels[].name]'
|
|
18
|
+
gh-axi api PUT /repos/{owner}/{repo}/branches/main/protection --input body.json
|
|
19
|
+
cat body.json | gh-axi api PUT /repos/{owner}/{repo}/branches/main/protection --input -`;
|
|
20
|
+
const HTTP_METHODS = new Set(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD"]);
|
|
21
|
+
/** The `gh api` short flag for HTTP method, equivalent to the positional method. */
|
|
22
|
+
const METHOD_FLAG = "-X";
|
|
17
23
|
/** Value flags that may be given more than once, each occurrence forwarded to gh. */
|
|
18
|
-
const REPEATABLE_VALUE_FLAGS = new Set([
|
|
24
|
+
const REPEATABLE_VALUE_FLAGS = new Set(["--field", "--header"]);
|
|
19
25
|
/** Value flags that gh accepts only one of, so a repeat is a caller mistake. */
|
|
20
|
-
const SINGLE_VALUE_FLAGS = new Set([
|
|
26
|
+
const SINGLE_VALUE_FLAGS = new Set(["--jq", "--template", "--input"]);
|
|
27
|
+
/** Maps a single-value flag's name to its key on `ParsedApiArgs`. */
|
|
28
|
+
const SINGLE_VALUE_FLAG_KEYS = {
|
|
29
|
+
"--jq": "jq",
|
|
30
|
+
"--template": "template",
|
|
31
|
+
"--input": "input",
|
|
32
|
+
};
|
|
21
33
|
/** Flags that stand alone and must not consume the following argument, and are forwarded to gh. */
|
|
22
|
-
const BOOL_FLAGS = new Set([
|
|
34
|
+
const BOOL_FLAGS = new Set(["--paginate"]);
|
|
23
35
|
/** Flags that stand alone, are gh-axi-only, and must not be forwarded to gh. */
|
|
24
|
-
const LOCAL_BOOL_FLAGS = new Set([
|
|
36
|
+
const LOCAL_BOOL_FLAGS = new Set(["--full"]);
|
|
25
37
|
const SUPPORTED_FLAGS = [
|
|
38
|
+
METHOD_FLAG,
|
|
26
39
|
...REPEATABLE_VALUE_FLAGS,
|
|
27
40
|
...SINGLE_VALUE_FLAGS,
|
|
28
41
|
...BOOL_FLAGS,
|
|
@@ -30,7 +43,7 @@ const SUPPORTED_FLAGS = [
|
|
|
30
43
|
];
|
|
31
44
|
/** The flag's name without any `=value` suffix, so errors never echo a value. */
|
|
32
45
|
function flagName(arg) {
|
|
33
|
-
const equals = arg.indexOf(
|
|
46
|
+
const equals = arg.indexOf("=");
|
|
34
47
|
return equals === -1 ? arg : arg.slice(0, equals);
|
|
35
48
|
}
|
|
36
49
|
/**
|
|
@@ -58,52 +71,66 @@ function parseArgs(args) {
|
|
|
58
71
|
};
|
|
59
72
|
for (let i = 0; i < args.length; i++) {
|
|
60
73
|
const arg = args[i];
|
|
61
|
-
if (!arg.startsWith(
|
|
74
|
+
if (!arg.startsWith("-")) {
|
|
62
75
|
parsed.positionals.push(arg);
|
|
63
76
|
continue;
|
|
64
77
|
}
|
|
65
78
|
const name = flagName(arg);
|
|
66
79
|
if (BOOL_FLAGS.has(name)) {
|
|
67
80
|
if (name !== arg)
|
|
68
|
-
throw new AxiError(`${name} does not take a value`,
|
|
81
|
+
throw new AxiError(`${name} does not take a value`, "VALIDATION_ERROR");
|
|
69
82
|
parsed.paginate = true;
|
|
70
83
|
continue;
|
|
71
84
|
}
|
|
72
85
|
if (LOCAL_BOOL_FLAGS.has(name)) {
|
|
73
86
|
if (name !== arg)
|
|
74
|
-
throw new AxiError(`${name} does not take a value`,
|
|
87
|
+
throw new AxiError(`${name} does not take a value`, "VALIDATION_ERROR");
|
|
75
88
|
parsed.full = true;
|
|
76
89
|
continue;
|
|
77
90
|
}
|
|
78
|
-
if (
|
|
79
|
-
|
|
91
|
+
if (name !== METHOD_FLAG &&
|
|
92
|
+
!REPEATABLE_VALUE_FLAGS.has(name) &&
|
|
93
|
+
!SINGLE_VALUE_FLAGS.has(name)) {
|
|
94
|
+
throw new AxiError(`unknown flag ${name} for gh-axi api. Supported flags: ${SUPPORTED_FLAGS.join(", ")}`, "VALIDATION_ERROR");
|
|
80
95
|
}
|
|
81
96
|
// `--flag=value` carries its own value; `--flag value` consumes the next arg.
|
|
82
97
|
let value;
|
|
83
98
|
if (name === arg) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
99
|
+
const next = args[i + 1];
|
|
100
|
+
if (next === undefined ||
|
|
101
|
+
(name === "--input" && SUPPORTED_FLAGS.includes(flagName(next))))
|
|
102
|
+
throw new AxiError(`${name} requires a value`, "VALIDATION_ERROR");
|
|
103
|
+
value = next;
|
|
104
|
+
i++;
|
|
87
105
|
}
|
|
88
106
|
else {
|
|
89
107
|
value = arg.slice(name.length + 1);
|
|
90
108
|
}
|
|
91
|
-
if (name ===
|
|
109
|
+
if (name === METHOD_FLAG) {
|
|
110
|
+
if (parsed.method !== undefined)
|
|
111
|
+
throw new AxiError(`${name} may only be given once`, "VALIDATION_ERROR");
|
|
112
|
+
const upper = value.toUpperCase();
|
|
113
|
+
if (!HTTP_METHODS.has(upper)) {
|
|
114
|
+
throw new AxiError(`${name} ${value} is not a supported HTTP method. Supported: ${[...HTTP_METHODS].join(", ")}`, "VALIDATION_ERROR");
|
|
115
|
+
}
|
|
116
|
+
parsed.method = upper;
|
|
117
|
+
}
|
|
118
|
+
else if (name === "--field") {
|
|
92
119
|
parsed.fields.push(value);
|
|
93
120
|
}
|
|
94
|
-
else if (name ===
|
|
121
|
+
else if (name === "--header") {
|
|
95
122
|
parsed.headers.push(value);
|
|
96
123
|
}
|
|
97
124
|
else {
|
|
98
125
|
// gh takes the last occurrence; discarding the earlier expression silently
|
|
99
126
|
// is the same failure this parser exists to prevent, so reject instead.
|
|
100
|
-
const key = name
|
|
127
|
+
const key = SINGLE_VALUE_FLAG_KEYS[name];
|
|
101
128
|
if (parsed[key] !== undefined)
|
|
102
|
-
throw new AxiError(`${name} may only be given once`,
|
|
129
|
+
throw new AxiError(`${name} may only be given once`, "VALIDATION_ERROR");
|
|
103
130
|
// An empty value (an unset shell variable) is a no-op filter for gh that
|
|
104
131
|
// would still suppress the default field stripping here.
|
|
105
|
-
if (value.trim() ===
|
|
106
|
-
throw new AxiError(`${name} requires a value`,
|
|
132
|
+
if (value.trim() === "")
|
|
133
|
+
throw new AxiError(`${name} requires a value`, "VALIDATION_ERROR");
|
|
107
134
|
parsed[key] = value;
|
|
108
135
|
}
|
|
109
136
|
}
|
|
@@ -116,35 +143,52 @@ const LONG_STRING_CLEANUP_THRESHOLD = 200;
|
|
|
116
143
|
/** Maximum length for cleaned string values before truncation. */
|
|
117
144
|
const STRING_VALUE_TRUNCATION_LIMIT = 2000;
|
|
118
145
|
export async function apiCommand(args, ctx) {
|
|
119
|
-
if (args[0] ===
|
|
146
|
+
if (args[0] === "--help" || args.length === 0)
|
|
120
147
|
return API_HELP;
|
|
121
|
-
const { positionals, fields, headers, jq, template, paginate, full } = parseArgs(args);
|
|
122
|
-
const pathRequired = new AxiError(
|
|
148
|
+
const { positionals, fields, headers, jq, template, method: methodFlag, input, paginate, full, } = parseArgs(args);
|
|
149
|
+
const pathRequired = new AxiError("API path is required: gh-axi api [<method>] <path>", "VALIDATION_ERROR");
|
|
123
150
|
if (positionals.length === 0)
|
|
124
151
|
throw pathRequired;
|
|
125
152
|
// A positional the command cannot place is a caller typo, and dropping it
|
|
126
153
|
// silently requests a different endpoint than the one that was asked for.
|
|
127
154
|
const methodGiven = HTTP_METHODS.has(positionals[0].toUpperCase());
|
|
155
|
+
if (methodFlag !== undefined && methodGiven) {
|
|
156
|
+
throw new AxiError("method given twice: use either -X <method> or the positional method, not both", "VALIDATION_ERROR");
|
|
157
|
+
}
|
|
128
158
|
if (positionals.length > (methodGiven ? 2 : 1)) {
|
|
129
|
-
throw new AxiError(
|
|
159
|
+
throw new AxiError("too many arguments for gh-axi api: expected [<method>] <path>", "VALIDATION_ERROR");
|
|
130
160
|
}
|
|
131
161
|
if (methodGiven && positionals.length < 2)
|
|
132
162
|
throw pathRequired;
|
|
133
|
-
const method = methodGiven ? positionals[0].toUpperCase() :
|
|
163
|
+
const method = methodFlag ?? (methodGiven ? positionals[0].toUpperCase() : "GET");
|
|
134
164
|
const path = methodGiven ? positionals[1] : positionals[0];
|
|
135
|
-
const ghArgs = [
|
|
165
|
+
const ghArgs = ["api", path, "--method", method];
|
|
136
166
|
for (const f of fields) {
|
|
137
|
-
ghArgs.push(
|
|
167
|
+
ghArgs.push("--field", f);
|
|
138
168
|
}
|
|
139
169
|
for (const h of headers) {
|
|
140
|
-
ghArgs.push(
|
|
170
|
+
ghArgs.push("--header", h);
|
|
171
|
+
}
|
|
172
|
+
// `--input -` cannot be forwarded to the child `gh` process as-is: execFile
|
|
173
|
+
// gives the child its own unconnected stdin pipe, so `gh` would block
|
|
174
|
+
// forever waiting for bytes nothing writes. Read our own stdin instead and
|
|
175
|
+
// relay it to gh's stdin (still via `--input -`) through ghExecWithStdin.
|
|
176
|
+
let stdinBody;
|
|
177
|
+
if (input === "-") {
|
|
178
|
+
if (isStdinTTY())
|
|
179
|
+
throw new AxiError("--input - requires piped stdin (no request body to read)", "VALIDATION_ERROR");
|
|
180
|
+
stdinBody = await readStdin();
|
|
181
|
+
ghArgs.push("--input", "-");
|
|
182
|
+
}
|
|
183
|
+
else if (input !== undefined) {
|
|
184
|
+
ghArgs.push("--input", input);
|
|
141
185
|
}
|
|
142
186
|
if (paginate)
|
|
143
|
-
ghArgs.push(
|
|
187
|
+
ghArgs.push("--paginate");
|
|
144
188
|
if (jq !== undefined)
|
|
145
|
-
ghArgs.push(
|
|
189
|
+
ghArgs.push("--jq", jq);
|
|
146
190
|
if (template !== undefined)
|
|
147
|
-
ghArgs.push(
|
|
191
|
+
ghArgs.push("--template", template);
|
|
148
192
|
// A caller who wrote a jq expression or template already chose the exact shape
|
|
149
193
|
// they want, so noisy-field stripping would silently delete fields they asked
|
|
150
194
|
// for by name (`url`, `node_id`, ...). The length clamp still applies, so a
|
|
@@ -156,7 +200,9 @@ export async function apiCommand(args, ctx) {
|
|
|
156
200
|
const stripNoisyKeys = !callerShapedOutput && !full;
|
|
157
201
|
const truncateValues = !full;
|
|
158
202
|
// Try to parse as JSON, strip noisy fields, encode to TOON; fall back to raw output
|
|
159
|
-
const raw =
|
|
203
|
+
const raw = stdinBody !== undefined
|
|
204
|
+
? await ghExecWithStdin(ghArgs, stdinBody, ctx)
|
|
205
|
+
: await ghExec(ghArgs, ctx);
|
|
160
206
|
try {
|
|
161
207
|
const data = JSON.parse(raw);
|
|
162
208
|
return encode(shapeOutput(data, stripNoisyKeys, truncateValues));
|
|
@@ -167,41 +213,71 @@ export async function apiCommand(args, ctx) {
|
|
|
167
213
|
const truncated = !full && trimmed.length > RAW_OUTPUT_TRUNCATION_LIMIT;
|
|
168
214
|
const result = {
|
|
169
215
|
api_response: {
|
|
170
|
-
body: truncated
|
|
216
|
+
body: truncated
|
|
217
|
+
? trimmed.slice(0, RAW_OUTPUT_TRUNCATION_LIMIT)
|
|
218
|
+
: trimmed,
|
|
171
219
|
truncated,
|
|
172
220
|
},
|
|
173
221
|
};
|
|
174
222
|
if (truncated) {
|
|
175
|
-
result.api_response.original_length =
|
|
223
|
+
result.api_response.original_length =
|
|
224
|
+
trimmed.length;
|
|
176
225
|
}
|
|
177
226
|
return encode(result);
|
|
178
227
|
}
|
|
179
228
|
}
|
|
180
229
|
/** Fields from raw GitHub API responses that are noisy/useless for agents */
|
|
181
230
|
const NOISY_KEYS = new Set([
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
231
|
+
"avatar_url",
|
|
232
|
+
"gravatar_id",
|
|
233
|
+
"followers_url",
|
|
234
|
+
"following_url",
|
|
235
|
+
"gists_url",
|
|
236
|
+
"starred_url",
|
|
237
|
+
"subscriptions_url",
|
|
238
|
+
"organizations_url",
|
|
239
|
+
"repos_url",
|
|
240
|
+
"events_url",
|
|
241
|
+
"received_events_url",
|
|
242
|
+
"labels_url",
|
|
243
|
+
"comments_url",
|
|
244
|
+
"events_url",
|
|
245
|
+
"timeline_url",
|
|
246
|
+
"performed_via_github_app",
|
|
247
|
+
"node_id",
|
|
248
|
+
"url",
|
|
249
|
+
"repository_url",
|
|
250
|
+
"html_url",
|
|
251
|
+
"reactions",
|
|
252
|
+
"user_view_type",
|
|
253
|
+
"site_admin",
|
|
254
|
+
"issue_dependencies_summary",
|
|
255
|
+
"sub_issues_summary",
|
|
256
|
+
"pinned_comment",
|
|
257
|
+
"score",
|
|
258
|
+
"permissions",
|
|
259
|
+
"verification",
|
|
260
|
+
"_links",
|
|
190
261
|
]);
|
|
191
262
|
/** Keys ending in _url that are template URLs agents never use */
|
|
192
263
|
function isTemplateUrlKey(key) {
|
|
193
|
-
if (!key.endsWith(
|
|
264
|
+
if (!key.endsWith("_url"))
|
|
194
265
|
return false;
|
|
195
266
|
// Keep a few meaningful URL keys
|
|
196
267
|
const KEEP_URL_KEYS = new Set([
|
|
197
|
-
|
|
198
|
-
|
|
268
|
+
"diff_url",
|
|
269
|
+
"patch_url",
|
|
270
|
+
"clone_url",
|
|
271
|
+
"ssh_url",
|
|
272
|
+
"git_url",
|
|
273
|
+
"svn_url",
|
|
274
|
+
"commit_url", // useful for linking to specific commits
|
|
199
275
|
]);
|
|
200
276
|
return !KEEP_URL_KEYS.has(key);
|
|
201
277
|
}
|
|
202
278
|
/** Collapse repo/repository objects to essential fields only */
|
|
203
279
|
function collapseRepo(obj) {
|
|
204
|
-
if (
|
|
280
|
+
if ("full_name" in obj) {
|
|
205
281
|
const collapsed = { full_name: obj.full_name };
|
|
206
282
|
if (obj.default_branch)
|
|
207
283
|
collapsed.default_branch = obj.default_branch;
|
|
@@ -215,7 +291,7 @@ function collapseRepo(obj) {
|
|
|
215
291
|
function truncateString(value) {
|
|
216
292
|
if (value.length <= STRING_VALUE_TRUNCATION_LIMIT)
|
|
217
293
|
return value;
|
|
218
|
-
return value.slice(0, STRING_VALUE_TRUNCATION_LIMIT) +
|
|
294
|
+
return value.slice(0, STRING_VALUE_TRUNCATION_LIMIT) + "... (truncated)";
|
|
219
295
|
}
|
|
220
296
|
/** Clean and truncate a long string value (e.g. bodies, comments, blobs). */
|
|
221
297
|
function clampString(value) {
|
|
@@ -238,7 +314,7 @@ function shapeOutput(obj, stripNoisyKeys, truncateValues, depth = 0) {
|
|
|
238
314
|
if (Array.isArray(obj)) {
|
|
239
315
|
return obj.map((item) => shapeOutput(item, stripNoisyKeys, truncateValues, depth + 1));
|
|
240
316
|
}
|
|
241
|
-
if (obj !== null && typeof obj ===
|
|
317
|
+
if (obj !== null && typeof obj === "object") {
|
|
242
318
|
const record = obj;
|
|
243
319
|
const result = {};
|
|
244
320
|
for (const [key, value] of Object.entries(record)) {
|
|
@@ -251,12 +327,17 @@ function shapeOutput(obj, stripNoisyKeys, truncateValues, depth = 0) {
|
|
|
251
327
|
if (isTemplateUrlKey(key))
|
|
252
328
|
continue;
|
|
253
329
|
// Strip nested user objects down to just login
|
|
254
|
-
if (key ===
|
|
330
|
+
if (key === "user" &&
|
|
331
|
+
value &&
|
|
332
|
+
typeof value === "object" &&
|
|
333
|
+
"login" in value) {
|
|
255
334
|
result[key] = value.login;
|
|
256
335
|
continue;
|
|
257
336
|
}
|
|
258
337
|
// Collapse repo/repository objects to essential fields
|
|
259
|
-
if ((key ===
|
|
338
|
+
if ((key === "repo" || key === "repository") &&
|
|
339
|
+
value &&
|
|
340
|
+
typeof value === "object") {
|
|
260
341
|
result[key] = collapseRepo(value);
|
|
261
342
|
continue;
|
|
262
343
|
}
|
|
@@ -264,7 +345,7 @@ function shapeOutput(obj, stripNoisyKeys, truncateValues, depth = 0) {
|
|
|
264
345
|
}
|
|
265
346
|
return result;
|
|
266
347
|
}
|
|
267
|
-
if (typeof obj ===
|
|
348
|
+
if (typeof obj === "string") {
|
|
268
349
|
if (!truncateValues)
|
|
269
350
|
return obj;
|
|
270
351
|
return stripNoisyKeys ? clampString(obj) : truncateString(obj);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/commands/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/commands/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEpD,MAAM,CAAC,MAAM,QAAQ,GAAG;;;;;;;;;;;;;0FAakE,CAAC;AAE3F,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;AAEhF,oFAAoF;AACpF,MAAM,WAAW,GAAG,IAAI,CAAC;AAEzB,qFAAqF;AACrF,MAAM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