@kosuke-ai/kosuke 1.0.141 → 1.0.143
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/CHANGELOG.md +8 -0
- package/README.md +3 -1
- package/dist/commands/skill-runs.js +3 -0
- package/dist/generated/commands/crons/list--personal.js +21 -0
- package/dist/generated/commands/crons/list.js +21 -0
- package/dist/generated/commands/github/connection-get.js +7 -0
- package/dist/generated/commands/integrations/browser-connections-create--personal-network-linkedin.js +4 -0
- package/dist/generated/commands/integrations/browser-connections-create--personal-network-x.js +4 -0
- package/dist/generated/commands/integrations/browser-connections-list--personal-network-linkedin.js +13 -0
- package/dist/generated/commands/integrations/browser-connections-list--personal-network-x.js +13 -0
- package/dist/generated/commands/integrations/connections-delete--personal.js +4 -0
- package/dist/generated/commands/integrations/connections-list--personal.js +31 -0
- package/dist/generated/commands/models/list.js +10 -0
- package/dist/generated/commands/projects/labels-list.js +4 -0
- package/dist/generated/commands/projects/list.js +63 -0
- package/dist/generated/commands/providers/get--personal.js +16 -0
- package/dist/generated/commands/providers/get.js +8 -0
- package/dist/generated/commands/providers/google-get.js +5 -0
- package/dist/generated/commands/providers/google-methods-set.js +4 -0
- package/dist/generated/commands/providers/google-set.js +5 -0
- package/dist/generated/commands/providers/grok-get--personal.js +9 -0
- package/dist/generated/commands/providers/grok-get.js +4 -0
- package/dist/generated/commands/providers/grok-update--personal.js +9 -0
- package/dist/generated/commands/providers/grok-update.js +9 -0
- package/dist/generated/commands/providers/logins-complete--personal-provider-antigravity.js +8 -0
- package/dist/generated/commands/providers/logins-complete--personal-provider-claude-code.js +6 -0
- package/dist/generated/commands/providers/logins-complete--personal-provider-codex.js +6 -0
- package/dist/generated/commands/providers/logins-complete--personal-provider-muse-code.js +6 -0
- package/dist/generated/commands/providers/logins-complete--provider-antigravity.js +8 -0
- package/dist/generated/commands/providers/logins-complete--provider-claude-code.js +6 -0
- package/dist/generated/commands/providers/logins-complete--provider-codex.js +6 -0
- package/dist/generated/commands/providers/logins-complete--provider-muse-code.js +6 -0
- package/dist/generated/commands/providers/logins-start--personal-provider-antigravity.js +8 -0
- package/dist/generated/commands/providers/logins-start--personal-provider-claude-code.js +4 -0
- package/dist/generated/commands/providers/logins-start--personal-provider-codex.js +6 -0
- package/dist/generated/commands/providers/logins-start--personal-provider-muse-code.js +6 -0
- package/dist/generated/commands/providers/logins-start--provider-antigravity.js +8 -0
- package/dist/generated/commands/providers/logins-start--provider-claude-code.js +4 -0
- package/dist/generated/commands/providers/logins-start--provider-codex.js +6 -0
- package/dist/generated/commands/providers/logins-start--provider-muse-code.js +6 -0
- package/dist/generated/commands/providers/set.js +8 -0
- package/dist/generated/commands/providers/usage-get--personal.js +8 -0
- package/dist/generated/commands/providers/usage-get--provider-antigravity.js +8 -0
- package/dist/generated/commands/providers/usage-get--provider-claude-code.js +8 -0
- package/dist/generated/commands/providers/usage-get--provider-codex.js +8 -0
- package/dist/generated/commands/providers/usage-get--provider-coding-plan.js +8 -0
- package/dist/generated/commands/providers/usage-get--provider-deepseek-api.js +8 -0
- package/dist/generated/commands/providers/usage-get--provider-grok.js +8 -0
- package/dist/generated/commands/providers/usage-get--provider-kimi-code.js +8 -0
- package/dist/generated/commands/providers/usage-get--provider-muse-code.js +8 -0
- package/dist/generated/commands/sensei/cards-list.js +68 -0
- package/dist/generated/commands/sensei/cards-set.js +16 -0
- package/dist/generated/commands/sensei/reels-later-holds-create.js +3 -0
- package/dist/generated/commands/sensei/reels-later-holds-delete.js +3 -0
- package/dist/generated/commands/sensei/reels-later-holds-list.js +8 -0
- package/dist/generated/commands/sensei/sessions-facts-get.js +23 -0
- package/dist/generated/commands/sensei/threads-close.js +4 -0
- package/dist/generated/commands/sensei/threads-get.js +16 -0
- package/dist/generated/commands/sensei/threads-list.js +8 -1
- package/dist/generated/commands/sessions/files-get.js +8 -0
- package/dist/generated/commands/sessions/get.js +17 -0
- package/dist/generated/commands/sessions/labels-set.js +4 -0
- package/dist/generated/commands/sessions/list--all.js +79 -0
- package/dist/generated/commands/sessions/list.js +126 -0
- package/dist/generated/commands/skills/get--personal.js +10 -0
- package/dist/generated/commands/skills/list--personal.js +9 -0
- package/dist/generated/commands/tasks/get--personal.js +29 -0
- package/dist/generated/commands/tasks/get.js +29 -0
- package/dist/generated/commands/tasks/labels-list.js +4 -0
- package/dist/generated/commands/tasks/list--all.js +23 -0
- package/dist/generated/commands/tasks/list--personal.js +23 -0
- package/dist/generated/commands/tasks/list.js +23 -0
- package/dist/generated/commands/tasks/start--personal.js +4 -0
- package/dist/generated/commands/tasks/start.js +4 -0
- package/dist/generated/commands/user/profile-get.js +16 -0
- package/dist/generated/commands/user/settings-get.js +7 -0
- package/dist/generated/commands/user/settings-update.js +7 -0
- package/dist/generated/commands/user/usage-get.js +11 -0
- package/dist/generated/commands/workspaces/get.js +11 -0
- package/dist/generated/commands/workspaces/list.js +6 -0
- package/dist/generated/commands/workspaces/members-list--all.js +5 -0
- package/dist/generated/commands/workspaces/members-list.js +6 -0
- package/dist/generated/commands/workspaces/timezone-set.js +3 -0
- package/dist/generated/commands/workspaces/usage-breakdown-get.js +11 -0
- package/dist/program.js +5 -3
- package/dist/runtime/attach.js +7 -4
- package/dist/runtime/fields.js +29 -10
- package/dist/runtime/help.js +119 -2
- package/dist/runtime/runtime.js +1 -0
- package/openapi.json +816 -2
- package/package.json +4 -4
package/dist/runtime/fields.js
CHANGED
|
@@ -126,18 +126,24 @@ function closest(field, available) {
|
|
|
126
126
|
.slice(0, 5)
|
|
127
127
|
.map(({ path }) => path);
|
|
128
128
|
}
|
|
129
|
+
/** How many top-level fields the unknown-field error names, at most. */
|
|
130
|
+
const TOP_LEVEL_SHOWN = 30;
|
|
131
|
+
/** The top-level keys of the rows: each one's on a list, else the object's. */
|
|
132
|
+
function topLevelOf(rows) {
|
|
133
|
+
return [...new Set(rows.slice(0, 50).flatMap((row) => (isRecord(row) ? Object.keys(row) : [])))];
|
|
134
|
+
}
|
|
129
135
|
/** The members of an object that hold a list of objects (an empty list counts). */
|
|
130
136
|
const listsOf = (value) => Object.keys(value).filter((key) => {
|
|
131
137
|
const member = value[key];
|
|
132
138
|
return Array.isArray(member) && member.every(isRecord);
|
|
133
139
|
});
|
|
134
140
|
/** The rows the fields read, or why no reading has them all. */
|
|
135
|
-
function rowsOf(value, fields, listing) {
|
|
141
|
+
function rowsOf(value, fields, listing, declared = new Set()) {
|
|
136
142
|
const split = (fields ?? []).map((field) => field.split('.'));
|
|
137
143
|
if (Array.isArray(value)) {
|
|
138
|
-
const unknown = (fields ?? []).filter((
|
|
144
|
+
const unknown = (fields ?? []).filter((field, i) => !known(value, split[i]) && !declared.has(field));
|
|
139
145
|
if (unknown.length)
|
|
140
|
-
return { unknown, available: [...pathsOf(value)] };
|
|
146
|
+
return { unknown, available: [...pathsOf(value)], top: topLevelOf(value) };
|
|
141
147
|
return { rows: value, list: true, paths: split };
|
|
142
148
|
}
|
|
143
149
|
if (!isRecord(value))
|
|
@@ -158,11 +164,16 @@ function rowsOf(value, fields, listing) {
|
|
|
158
164
|
if (paths.every((path) => known(rows, path)))
|
|
159
165
|
return { rows, list: true, key: first, paths };
|
|
160
166
|
}
|
|
161
|
-
|
|
167
|
+
// Declared paths are the object's on a get, or when one names a member the object has
|
|
168
|
+
// (`threads,also` on `{threads: [...]}`); else, on a list that holds one, its rows'.
|
|
169
|
+
const onWrapper = held === undefined || [...declared].some((path) => Object.hasOwn(value, path.split('.')[0]));
|
|
170
|
+
const onObject = fields.filter((field, i) => !known([value], split[i]) && !(onWrapper && declared.has(field)));
|
|
162
171
|
if (!onObject.length)
|
|
163
172
|
return { rows: [value], list: false, paths: split };
|
|
164
173
|
// `id,name` on `{crons: [...], total}`: its one list's items.
|
|
165
|
-
const onRows = held === undefined
|
|
174
|
+
const onRows = held === undefined
|
|
175
|
+
? fields
|
|
176
|
+
: fields.filter((field, i) => !known(heldRows, split[i]) && (onWrapper || !declared.has(field)));
|
|
166
177
|
if (held !== undefined && !onRows.length) {
|
|
167
178
|
return { rows: heldRows, list: true, key: held, paths: split };
|
|
168
179
|
}
|
|
@@ -174,7 +185,11 @@ function rowsOf(value, fields, listing) {
|
|
|
174
185
|
if (held !== undefined)
|
|
175
186
|
pathsOf(heldRows, '', available);
|
|
176
187
|
// Unknown both ways; never empty, as the mix above took the rest.
|
|
177
|
-
return {
|
|
188
|
+
return {
|
|
189
|
+
unknown: onObject.filter((field) => onRows.includes(field)),
|
|
190
|
+
available: [...available],
|
|
191
|
+
top: topLevelOf(held === undefined ? [value] : heldRows),
|
|
192
|
+
};
|
|
178
193
|
}
|
|
179
194
|
const TIMESTAMP = /^(\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d)\.\d+(Z|[+-]\d\d:?\d\d)?$/;
|
|
180
195
|
const toSeconds = (_key, value) => typeof value === 'string' ? value.replace(TIMESTAMP, '$1$2') : value;
|
|
@@ -223,12 +238,12 @@ function besideLine(envelope, value, key) {
|
|
|
223
238
|
* The answer shaped by `--fields` and `--format`. JSON keeps the envelope's `meta` and puts the
|
|
224
239
|
* picked fields in `data`, nested as in the answer. Compact prints a header, then a line per row,
|
|
225
240
|
* tab-separated, with what lies beside the rows for stderr. A field no row has is refused with
|
|
226
|
-
* the closest the answer offers.
|
|
241
|
+
* the closest the answer offers and its top-level fields (each row's on a list).
|
|
227
242
|
*/
|
|
228
|
-
export function shape(body, { fields, format = 'json', list: listing = false }) {
|
|
243
|
+
export function shape(body, { fields, format = 'json', list: listing = false, declared }) {
|
|
229
244
|
const envelope = isRecord(body) && 'data' in body ? body : null;
|
|
230
245
|
const value = envelope ? envelope.data : body;
|
|
231
|
-
const found = rowsOf(value, fields?.length ? fields : undefined, listing);
|
|
246
|
+
const found = rowsOf(value, fields?.length ? fields : undefined, listing, new Set(declared));
|
|
232
247
|
if ('mixed' in found) {
|
|
233
248
|
const [rowFields, besideFields] = found.mixed;
|
|
234
249
|
return {
|
|
@@ -239,9 +254,13 @@ export function shape(body, { fields, format = 'json', list: listing = false })
|
|
|
239
254
|
};
|
|
240
255
|
}
|
|
241
256
|
if ('unknown' in found) {
|
|
257
|
+
const { top } = found;
|
|
258
|
+
const topLevel = top.length
|
|
259
|
+
? ` Top-level fields: ${top.slice(0, TOP_LEVEL_SHOWN).join(', ')}${top.length > TOP_LEVEL_SHOWN ? ` and ${top.length - TOP_LEVEL_SHOWN} more` : ''}.`
|
|
260
|
+
: '';
|
|
242
261
|
const lines = found.unknown.map((field) => {
|
|
243
262
|
const near = closest(field, found.available);
|
|
244
|
-
return `error: unknown field "${field}".${near.length ? ` Closest: ${near.join(', ')}
|
|
263
|
+
return `error: unknown field "${field}".${near.length ? ` Closest: ${near.join(', ')}.${topLevel}` : ' The answer has no fields.'}`;
|
|
245
264
|
});
|
|
246
265
|
return { ok: false, message: lines.join('\n') };
|
|
247
266
|
}
|
package/dist/runtime/help.js
CHANGED
|
@@ -16,6 +16,42 @@ const afterText = new WeakMap();
|
|
|
16
16
|
const optionShapes = new WeakMap();
|
|
17
17
|
/** The configurations `helpConfiguration` made, which print the after-text themselves. */
|
|
18
18
|
const configurations = new WeakSet();
|
|
19
|
+
/** The root's own flags that shape a command's output, in the order its help lists them. */
|
|
20
|
+
const OUTPUT_OPTIONS = ['--fields', '--format', '--json', '--pretty'];
|
|
21
|
+
const OUTPUT_HEADING = 'Output options:';
|
|
22
|
+
/** What a command printing its own text says of its output, in place of its output flags. */
|
|
23
|
+
export const OWN_TEXT = 'Output: its own text; --fields and --format do not apply.';
|
|
24
|
+
/** The fields line of a command whose answer's paths are not published. */
|
|
25
|
+
const ANY_FIELDS = "Fields: the answer's top-level keys (each row's on a list); a wrong one is refused with the valid ones.";
|
|
26
|
+
/** Characters of the short help's `Fields:` line. */
|
|
27
|
+
const FIELDS_WIDTH = 100;
|
|
28
|
+
/** Per root: the words of the commands that print their own text rather than the platform's JSON. */
|
|
29
|
+
const ownOutput = new WeakMap();
|
|
30
|
+
const answerFields = new WeakMap();
|
|
31
|
+
/** The commands under `root`, by their words, that print their own text: no `--fields` there. */
|
|
32
|
+
export function setOwnOutput(root, words) {
|
|
33
|
+
ownOutput.set(root, words);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The field paths a leaf's answer offers, for its `Fields:` line: each reachable form's, under
|
|
37
|
+
* its usage, as a call reaches that form's answer. A leaf of one form passes it alone.
|
|
38
|
+
*/
|
|
39
|
+
export function setFormFields(leaf, forms, usage) {
|
|
40
|
+
const entries = forms.map((form) => ({ form: usage(form), fields: form.fields }));
|
|
41
|
+
if (entries.some((entry) => entry.fields?.length))
|
|
42
|
+
answerFields.set(leaf, entries);
|
|
43
|
+
}
|
|
44
|
+
/** One `Fields:` line; the short help keeps as many as fit, then how many more. */
|
|
45
|
+
function fieldsLine(label, fields, long) {
|
|
46
|
+
const line = `${label} ${fields.join(', ')}`;
|
|
47
|
+
if (long || line.length <= FIELDS_WIDTH)
|
|
48
|
+
return line;
|
|
49
|
+
let shown = fields.length - 1;
|
|
50
|
+
const head = (count) => `${label} ${fields.slice(0, count).join(', ')} and ${fields.length - count} more`;
|
|
51
|
+
while (shown > 1 && head(shown).length > FIELDS_WIDTH)
|
|
52
|
+
shown -= 1;
|
|
53
|
+
return head(shown);
|
|
54
|
+
}
|
|
19
55
|
export function setAfterHelp(leaf, text) {
|
|
20
56
|
afterText.set(leaf, text);
|
|
21
57
|
// A tree built without this help, as a test builds one, still prints it, in full.
|
|
@@ -94,16 +130,90 @@ function shapeLines(shape) {
|
|
|
94
130
|
const [head, ...members] = shape;
|
|
95
131
|
return [`Shape: ${head}`, ...members.map((member) => ` ${member}`)].join('\n');
|
|
96
132
|
}
|
|
133
|
+
function rootOf(command) {
|
|
134
|
+
let root = command;
|
|
135
|
+
while (root.parent)
|
|
136
|
+
root = root.parent;
|
|
137
|
+
return root;
|
|
138
|
+
}
|
|
139
|
+
const runnable = (command) => command._actionHandler !== null;
|
|
140
|
+
/**
|
|
141
|
+
* Whether a command prints its own text: a leaf the root names so, or a group whose every
|
|
142
|
+
* command does. The root is neither: its help lists the flags themselves.
|
|
143
|
+
*/
|
|
144
|
+
function printsOwnText(command) {
|
|
145
|
+
if (!command.parent)
|
|
146
|
+
return false;
|
|
147
|
+
const own = ownOutput.get(rootOf(command));
|
|
148
|
+
if (!own)
|
|
149
|
+
return false;
|
|
150
|
+
const leaves = [];
|
|
151
|
+
const walk = (at) => {
|
|
152
|
+
if (runnable(at))
|
|
153
|
+
leaves.push(at);
|
|
154
|
+
at.commands.forEach(walk);
|
|
155
|
+
};
|
|
156
|
+
walk(command);
|
|
157
|
+
return leaves.length > 0 && leaves.every((leaf) => own.has(commandPath(leaf).join(' ')));
|
|
158
|
+
}
|
|
159
|
+
/** The root's output flags a command's help lists under `Output options:`. */
|
|
160
|
+
function outputOptions(command) {
|
|
161
|
+
if (!command.parent || printsOwnText(command))
|
|
162
|
+
return [];
|
|
163
|
+
const root = rootOf(command);
|
|
164
|
+
return OUTPUT_OPTIONS.flatMap((flag) => {
|
|
165
|
+
const option = root.options.find((candidate) => candidate.long === flag);
|
|
166
|
+
return option ? [option] : [];
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* What a command says of its output after its flags: that it prints its own text, or, on a
|
|
171
|
+
* leaf, the paths `--fields` takes. The short help keeps them on one line, ending with how many
|
|
172
|
+
* more the long help lists.
|
|
173
|
+
*/
|
|
174
|
+
function outputText(command, long) {
|
|
175
|
+
if (!command.parent)
|
|
176
|
+
return '';
|
|
177
|
+
if (printsOwnText(command))
|
|
178
|
+
return `\n${OWN_TEXT}\n`;
|
|
179
|
+
if (!runnable(command) || command.commands.length)
|
|
180
|
+
return '';
|
|
181
|
+
const forms = answerFields.get(command);
|
|
182
|
+
if (!forms)
|
|
183
|
+
return `\n${ANY_FIELDS}\n`;
|
|
184
|
+
const same = (a, b) => (a ?? []).join(',') === (b ?? []).join(',');
|
|
185
|
+
// One list when every form answers alike; else each form's own, as a call reaches one form.
|
|
186
|
+
if (forms.every((entry) => same(entry.fields, forms[0].fields))) {
|
|
187
|
+
return `\n${fieldsLine('Fields:', forms[0].fields, long)}\n`;
|
|
188
|
+
}
|
|
189
|
+
const lines = forms.map((entry) => entry.fields?.length
|
|
190
|
+
? fieldsLine(`Fields (${entry.form}):`, entry.fields, long)
|
|
191
|
+
: `Fields (${entry.form}): the answer's top-level keys.`);
|
|
192
|
+
return `\n${lines.join('\n')}\n`;
|
|
193
|
+
}
|
|
97
194
|
/** The help configuration of the whole tree, short or long. */
|
|
98
195
|
export function helpConfiguration(long) {
|
|
99
196
|
const configuration = build(long);
|
|
100
197
|
configurations.add(configuration);
|
|
101
198
|
return configuration;
|
|
102
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* Every command but the root lists the root's output flags, under `Output options:`, as
|
|
202
|
+
* commander's global options; a command that prints its own text lists none.
|
|
203
|
+
*/
|
|
204
|
+
const OUTPUT_SECTION = {
|
|
205
|
+
showGlobalOptions: true,
|
|
206
|
+
visibleGlobalOptions: outputOptions,
|
|
207
|
+
formatItemList(heading, items, helper) {
|
|
208
|
+
const title = heading === 'Global Options:' ? OUTPUT_HEADING : heading;
|
|
209
|
+
return Help.prototype.formatItemList.call(this, title, items, helper);
|
|
210
|
+
},
|
|
211
|
+
};
|
|
103
212
|
function build(long) {
|
|
104
213
|
const base = Help.prototype;
|
|
105
214
|
if (long) {
|
|
106
215
|
return {
|
|
216
|
+
...OUTPUT_SECTION,
|
|
107
217
|
sortSubcommands: true,
|
|
108
218
|
subcommandTerm(command) {
|
|
109
219
|
return subcommandTerm(this, command, true);
|
|
@@ -116,9 +226,11 @@ function build(long) {
|
|
|
116
226
|
return text ? `${text}\n${shapeLine(shape)}` : shapeLine(shape);
|
|
117
227
|
},
|
|
118
228
|
formatHelp(command, helper) {
|
|
119
|
-
|
|
229
|
+
let text = base.formatHelp.call(this, command, helper);
|
|
120
230
|
const after = afterText.get(command);
|
|
121
|
-
|
|
231
|
+
if (after)
|
|
232
|
+
text += `${after(true)}\n`;
|
|
233
|
+
return text + outputText(command, true);
|
|
122
234
|
},
|
|
123
235
|
};
|
|
124
236
|
}
|
|
@@ -134,6 +246,7 @@ function build(long) {
|
|
|
134
246
|
return short;
|
|
135
247
|
};
|
|
136
248
|
return {
|
|
249
|
+
...OUTPUT_SECTION,
|
|
137
250
|
sortSubcommands: true,
|
|
138
251
|
// Never wrapped: a flag is one line, however wide the terminal.
|
|
139
252
|
helpWidth: 100_000,
|
|
@@ -164,6 +277,10 @@ function build(long) {
|
|
|
164
277
|
const after = afterText.get(command);
|
|
165
278
|
if (after)
|
|
166
279
|
text += `${after(false)}\n`;
|
|
280
|
+
const output = outputText(command, false);
|
|
281
|
+
if (output !== outputText(command, true))
|
|
282
|
+
cut = true;
|
|
283
|
+
text += output;
|
|
167
284
|
if (commandPath(command).join(' ') === 'sensei cards set')
|
|
168
285
|
return `${text}\n${CARD_RULES}\n`;
|
|
169
286
|
return cut ? `${text}\n${FULL_TEXT}\n` : text;
|
package/dist/runtime/runtime.js
CHANGED
|
@@ -98,6 +98,7 @@ export function createRuntime({ flags, env = process.env, fetch, stdout = (line)
|
|
|
98
98
|
...(flags.fields ? { fields: flags.fields } : {}),
|
|
99
99
|
...(flags.format ? { format: flags.format } : {}),
|
|
100
100
|
list: context?.list === true,
|
|
101
|
+
...(context?.declared ? { declared: context.declared } : {}),
|
|
101
102
|
});
|
|
102
103
|
if (!shaped.ok) {
|
|
103
104
|
flushHeld();
|