@kosuke-ai/kosuke 1.0.61 → 1.0.63

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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.63
4
+
5
+ - Keep a QA Run's Mac film when the session's shell may not move footage out of the screen recording folder.
6
+
7
+ ## 1.0.62
8
+
9
+ - Add a global `--json` and `KOSUKE_OUTPUT=json`, which print a command's platform JSON as today, and `--all` on `sessions list`, `tasks list`, `crons list`, `activity list` and `sensei threads list`, which changes nothing yet. Scripts that parse the output should pass them now: a later release makes shorter output the default.
10
+
3
11
  ## 1.0.61
4
12
 
5
13
  - A Chat Session's shell and file writes on a Mac stay in its scratch folder ~/KosukeQA/<session8>/, Xcode DerivedData, CoreSimulator, the temporary folders and the folders its project declares in deviceWritePaths, which a member sets with `kosuke projects settings update --device-write-paths`. A write elsewhere fails. Sensei's own Mac calls are unchanged.
package/README.md CHANGED
@@ -8,7 +8,7 @@ installed inside sandboxes alongside this platform CLI, never by hand.
8
8
  ```sh
9
9
  npm install -g @kosuke-ai/kosuke
10
10
  kosuke auth login # paste an API key from Settings
11
- kosuke projects list | jq '.data[] | {id, name}'
11
+ kosuke projects list --json | jq '.data[] | {id, name}'
12
12
  kosuke sessions create <projectId> --title "Fix the login form" \
13
13
  --content "See the screenshot" --status backlog --attach shot.png
14
14
  kosuke crons create <workspaceId> --project <projectId> --project <projectId> \
@@ -17,7 +17,11 @@ kosuke crons create <workspaceId> --project <projectId> --project <projectId> \
17
17
  kosuke workspaces timezone set <workspaceId> --timezone Europe/Zurich
18
18
  ```
19
19
 
20
- Every API command prints the platform's JSON response, so it pipes into `jq`.
20
+ Every API command prints the platform's JSON response. `--json`, or `KOSUKE_OUTPUT=json`, asks
21
+ for it by name: pass it in anything that pipes into `jq`. It prints what the command prints
22
+ anyway today, and it keeps doing so when a later release makes shorter output the default.
23
+ `sessions list`, `tasks list`, `crons list`, `activity list` and `sensei threads list` also take
24
+ `--all`, which changes nothing today and keeps every row once those lists get a default limit.
21
25
  Path params are positional, request fields are flags (`--exclude-archived`,
22
26
  `--start-line-number 12`, and `--project a --project b` where a field takes
23
27
  several values), and any body can be passed whole with `--body '{…}'`,
@@ -3,6 +3,7 @@ import { InvalidArgumentError } from 'commander';
3
3
  import { leafAt } from '../runtime/attach.js';
4
4
  import { HAND_WRITTEN } from './hand-written.js';
5
5
  import { isTurnToken } from '../runtime/credentials.js';
6
+ import { jsonRequested } from '../runtime/runtime.js';
6
7
  import { connectionOf, failureOf, isRow, oneLine, readOverview, rowsOf, TOOLS_PATH, transportFailure, } from '../integrations/api.js';
7
8
  import { FILE_UPLOAD_PATH, fileSize, MAX_FILE_BYTES, md5Of, mimetypeOf, parseFileArgument, putFile, setAt, uploadName, } from '../integrations/file-upload.js';
8
9
  import { choiceLines, renderOverview } from '../integrations/render.js';
@@ -184,7 +185,7 @@ export function attachIntegrationsCommands(root, runtime, deps = {}) {
184
185
  .option('--workspace <id>', WORKSPACE_HELP)
185
186
  .option('--json', "Print the platform's answer as JSON.")
186
187
  .addHelpText('after', '\nExit codes:\n 0 ok\n 1 the platform refused or could not answer\n 2 --workspace missing with an API key')
187
- .action(guarded(async (flags) => {
188
+ .action(guarded(async (flags, command) => {
188
189
  const client = runtime.client();
189
190
  const workspace = workspaceFor(runtime, flags.workspace);
190
191
  const result = await readOverview(client, {
@@ -196,7 +197,8 @@ export function attachIntegrationsCommands(root, runtime, deps = {}) {
196
197
  }, AbortSignal.timeout(readTimeoutMs));
197
198
  if (!result.ok)
198
199
  return fail(result);
199
- if (flags.json) {
200
+ // The program's own --json takes the flag wherever it is written, so it is read from there.
201
+ if (jsonRequested(command.optsWithGlobals().json, env)) {
200
202
  stdout(`${JSON.stringify(result.raw, null, 2)}\n`);
201
203
  // stdout stays parseable, so the cut is told beside it.
202
204
  if (result.overview.note)
@@ -94,7 +94,9 @@ async function receiptData(response) {
94
94
  }
95
95
  }
96
96
  /** Marker errors bypass Commander and the shared retrying client so they cannot stop agent work. */
97
- export async function runSkillMarkerCommand(args, options = {}) {
97
+ export async function runSkillMarkerCommand(argv, options = {}) {
98
+ // Global, as everywhere and at any place on the line: it is no word of the marker.
99
+ const args = argv.filter((arg) => arg !== '--json');
98
100
  const [group, noun] = HAND_WRITTEN.sessionsSkillRuns.command;
99
101
  if (args[0] !== group || args[1] !== noun)
100
102
  return false;
package/dist/program.js CHANGED
@@ -25,6 +25,7 @@ export function createProgram(options = {}) {
25
25
  .option('--api-key <key>', 'API key; overrides KOSUKE_API_KEY and the stored one.')
26
26
  .option('--api-url <url>', 'Platform URL; overrides KOSUKE_API_URL. Default https://app.kosuke.ai.')
27
27
  .option('--pretty', 'Indented JSON; the default at a terminal, one line when piped.')
28
+ .option('--json', "The platform's whole answer as JSON, for a script. Or KOSUKE_OUTPUT=json.")
28
29
  // commander's default is kept: a program option is read wherever it
29
30
  // appears, so `kosuke projects list --api-key X` works as the README shows.
30
31
  .showHelpAfterError('(add --help for usage)')
@@ -12,14 +12,25 @@ export const CLI_GLOBAL_FLAGS = new Map([
12
12
  ['--api-key', true],
13
13
  ['--api-url', true],
14
14
  ['--pretty', false],
15
+ ['--json', false],
15
16
  ['--long', false],
16
17
  ['--help', false],
17
18
  ['-h', false],
18
19
  ['--version', false],
19
20
  ]);
21
+ /**
22
+ * Program flags that take no value and that the CLI reads at any place, so one may stand before
23
+ * a command or between its words. The prompt-commands lint gate reads it too.
24
+ */
25
+ export const CLI_OUTPUT_FLAGS = new Set(['--json', '--pretty']);
20
26
  /** CLI-only flags of generated commands, by command words, each a boolean. */
21
27
  export const CLI_ONLY_FLAGS = {
22
28
  'sensei threads get': ['--tools'],
29
+ 'sessions list': ['--all'],
30
+ 'tasks list': ['--all'],
31
+ 'crons list': ['--all'],
32
+ 'activity list': ['--all'],
33
+ 'sensei threads list': ['--all'],
23
34
  };
24
35
  export const SESSION_ID_FLAG = 'session-id';
25
36
  function fieldsOf(form) {
@@ -47,10 +47,7 @@ function attachLeaf(root, path, operation, runtime, hidden) {
47
47
  if (addsSessionIdFlag(operation)) {
48
48
  leaf.addOption(new Option(`--${SESSION_ID_FLAG} <id>`, 'Session id, in place of <sessionId>; the project is read from it.'));
49
49
  }
50
- const view = VIEWS[operation.command.join(' ')];
51
- for (const flag of CLI_ONLY_FLAGS[operation.command.join(' ')] ?? []) {
52
- leaf.addOption(new Option(flag, view?.flags[flag] ?? ''));
53
- }
50
+ addCliOnlyOptions(leaf, operation);
54
51
  addBodyOptions(leaf, operation);
55
52
  leaf.action(async (...args) => {
56
53
  const options = args[args.length - 2];
@@ -112,6 +109,14 @@ const VIEWS = {
112
109
  view: (body, options) => threadView(body, { tools: options.tools === true }),
113
110
  },
114
111
  };
112
+ /** A list's `--all`. It changes nothing yet: a script passes it to keep every row when lists get a default limit. */
113
+ const ALL_FLAG_HELP = 'Every row, as a list prints now. Scripts pass it to stay whole.';
114
+ function addCliOnlyOptions(leaf, operation) {
115
+ const command = operation.command.join(' ');
116
+ for (const flag of CLI_ONLY_FLAGS[command] ?? []) {
117
+ leaf.addOption(new Option(flag, VIEWS[command]?.flags[flag] ?? (flag === '--all' ? ALL_FLAG_HELP : '')));
118
+ }
119
+ }
115
120
  const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
116
121
  /**
117
122
  * The path params of a `projectId, sessionId, ...` command: all of them, one fewer with the
@@ -230,6 +235,7 @@ function attachForms(root, forms, runtime, reachable) {
230
235
  }
231
236
  }
232
237
  }
238
+ addCliOnlyOptions(leaf, forms[0]);
233
239
  addBodyOptions(leaf, {
234
240
  body: forms.find((form) => form.body)?.body ?? null,
235
241
  multipart: forms.find((form) => form.multipart)?.multipart ?? null,
@@ -1,4 +1,5 @@
1
1
  import { Help } from 'commander';
2
+ import { CLI_OUTPUT_FLAGS } from './arguments.js';
2
3
  /**
3
4
  * The help an agent reads. Short by default: the usage line, the description's first sentence
4
5
  * and one line per flag. `--help --long` prints the whole text. `kosuke help --compact` prints
@@ -30,7 +31,8 @@ export function setOptionShape(option, shape) {
30
31
  */
31
32
  export function takeLongHelp(argv) {
32
33
  const args = argv.slice(2);
33
- const asksHelp = args.includes('--help') || args.includes('-h') || args[0] === 'help';
34
+ const command = args.find((arg) => !CLI_OUTPUT_FLAGS.has(arg));
35
+ const asksHelp = args.includes('--help') || args.includes('-h') || command === 'help';
34
36
  if (!asksHelp || !args.includes(LONG_HELP_FLAG))
35
37
  return { argv: [...argv], long: false };
36
38
  return { argv: [...argv.slice(0, 2), ...args.filter((a) => a !== LONG_HELP_FLAG)], long: true };
@@ -1,5 +1,12 @@
1
1
  import { createApiClient } from './client.js';
2
2
  import { resolveCredentials, } from './credentials.js';
3
+ /**
4
+ * Whether the call asked for JSON: `--json` or `KOSUKE_OUTPUT=json`, one switch. Every generated
5
+ * command already prints it, so only a command whose own default is text reads this.
6
+ */
7
+ export function jsonRequested(flag, env) {
8
+ return flag === true || env.KOSUKE_OUTPUT === 'json';
9
+ }
3
10
  export function createRuntime({ flags, env = process.env, fetch, stdout = (line) => process.stdout.write(line + '\n'), stderr = (line) => process.stderr.write(line + '\n'), exit = (code) => {
4
11
  process.exitCode = code;
5
12
  }, tty = { stdout: process.stdout.isTTY === true, stderr: process.stderr.isTTY === true }, }) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kosuke-ai/kosuke",
3
- "version": "1.0.61",
3
+ "version": "1.0.63",
4
4
  "description": "Sensei platform CLI. The client customers install to drive app.kosuke.ai from their own machine.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -43,10 +43,10 @@
43
43
  "minimatch": "^11.0.1"
44
44
  },
45
45
  "kosukeRelease": {
46
- "sourceCommit": "ab954c7c62c405306a487ae257ca74d0c243d0fa",
47
- "sourceIdentity": "4e544c0ff9c9c9902f0290efed2f704509ef0599945faeab51bc6bef33f4f21c",
46
+ "sourceCommit": "387b0b15c055bd33a14a701023160da085a28c41",
47
+ "sourceIdentity": "db296793b80910f8aba1e841912bb2e0b55c53cf8eb89817d24eedc84972363a",
48
48
  "fragments": [
49
- "session-fence-iau7rc.json"
49
+ "qa-mac-film-container-copy-6p7adx.json"
50
50
  ]
51
51
  }
52
52
  }