ima2-gen 3.16.0 → 3.16.1

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
@@ -26,6 +26,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
26
26
 
27
27
  - **Windows installer npm handling** — compose global npm lockfile path with nested `Join-Path` calls for PowerShell 5.1 compatibility; wrap npm invocations in `Invoke-Npm` with `Continue` error action preference so stderr warnings do not abort the installer (#110, #111).
28
28
 
29
+ ## [3.16.1] - 2026-09-17
30
+
31
+ ### Fixed
32
+
33
+ - **`ima2 grok` subcommands ignored `--help`** (#244) — `grok login`, `grok status`, and `grok logout` were dispatched before their arguments were parsed, so `ima2 grok login --help` started a real xAI device-code flow and sat polling instead of printing anything, and `ima2 grok logout --help` deleted `~/.progrok/auth.json` before any help text appeared. Each subcommand now answers `--help`/`-h` with its own usage before doing anything observable, and rejects options it does not accept.
34
+
35
+ ### Changed
36
+
37
+ - **Dependencies** — `@openai/codex` 0.153.2 to 0.153.4; the UI development group moves `@playwright/test` 1.62.1 to 1.63.0 and `@types/react-dom` 19.2.5 to 19.2.7.
38
+
29
39
  ## [3.16.0] - 2026-09-09
30
40
 
31
41
  ### Removed
@@ -29,13 +29,53 @@ const HELP = `
29
29
  ima2 grok login uses a running 'ima2 serve' when one is available so the
30
30
  CLI and the web UI share one login; otherwise it runs the flow directly.
31
31
  `;
32
- const SPEC = {
32
+ const LOGIN_HELP = `
33
+ ima2 grok login
34
+
35
+ Log in to xAI with the OAuth device-code flow. Prints a verification URL and a
36
+ user code, then waits for the approval. Uses a running 'ima2 serve' when one
37
+ answers so the CLI and the web UI share a single session.
38
+
39
+ Options:
40
+ -h, --help Show this help
41
+ `;
42
+ const STATUS_HELP = `
43
+ ima2 grok status [--json] [--probe]
44
+
45
+ Show the stored xAI OAuth session: account, expiry, and whether a refresh
46
+ token is present.
47
+
48
+ Options:
49
+ --json Print the status as one JSON object
50
+ --probe Call /v1/models and list the visible grok-imagine models
51
+ -h, --help Show this help
52
+ `;
53
+ const LOGOUT_HELP = `
54
+ ima2 grok logout
55
+
56
+ Remove the stored xAI OAuth session from ~/.progrok/auth.json. The progrok CLI
57
+ shares that file, so this logs both out.
58
+
59
+ Options:
60
+ -h, --help Show this help
61
+ `;
62
+ /** login and logout take no options of their own; only help is valid. */
63
+ const HELP_ONLY_SPEC = {
64
+ flags: {
65
+ help: { short: "h", type: "boolean" },
66
+ },
67
+ };
68
+ const STATUS_SPEC = {
33
69
  flags: {
34
70
  json: { type: "boolean" },
35
71
  probe: { type: "boolean" },
36
72
  help: { short: "h", type: "boolean" },
37
73
  },
38
74
  };
75
+ function rejectUnknownFlags(args) {
76
+ if (args._unknown?.length)
77
+ die(2, `unknown option: ${args._unknown[0]}`);
78
+ }
39
79
  const POLL_INTERVAL_MS = 3_000;
40
80
  function sleep(ms) {
41
81
  return new Promise((resolve) => {
@@ -83,7 +123,16 @@ async function loginViaServer(base) {
83
123
  }
84
124
  throw new Error("xAI device login expired before it was approved");
85
125
  }
86
- async function loginCmd() {
126
+ async function loginCmd(argv) {
127
+ // Help is answered before anything observable happens. Until 3.16.1 this
128
+ // function started server discovery and a real device-code flow for
129
+ // 'ima2 grok login --help' (#244).
130
+ const args = parseArgs(argv, HELP_ONLY_SPEC);
131
+ if (args.help) {
132
+ out(LOGIN_HELP);
133
+ return;
134
+ }
135
+ rejectUnknownFlags(args);
87
136
  let server = null;
88
137
  try {
89
138
  server = await findRunningServer({ includeEnv: false });
@@ -128,7 +177,12 @@ async function probeResult() {
128
177
  }
129
178
  }
130
179
  async function statusCmd(argv) {
131
- const args = parseArgs(argv, SPEC);
180
+ const args = parseArgs(argv, STATUS_SPEC);
181
+ if (args.help) {
182
+ out(STATUS_HELP);
183
+ return;
184
+ }
185
+ rejectUnknownFlags(args);
132
186
  const creds = loadGrokCredentials();
133
187
  const probe = args.probe === true && creds !== null ? await probeResult() : undefined;
134
188
  if (args.json) {
@@ -150,6 +204,18 @@ async function statusCmd(argv) {
150
204
  const ids = probe.imagineModels ?? [];
151
205
  out(ids.length ? ` imagine models: ${ids.join(", ")}` : color.yellow(" no grok-imagine model is visible to this session"));
152
206
  }
207
+ function logoutCmd(argv) {
208
+ // Same reason as loginCmd: 'ima2 grok logout --help' used to delete the
209
+ // stored session before anyone read the help text (#244).
210
+ const args = parseArgs(argv, HELP_ONLY_SPEC);
211
+ if (args.help) {
212
+ out(LOGOUT_HELP);
213
+ return;
214
+ }
215
+ rejectUnknownFlags(args);
216
+ clearGrokCredentials();
217
+ out(color.green("✓ ") + "Removed the stored Grok OAuth session");
218
+ }
153
219
  export default async function grokCmd(argv) {
154
220
  const sub = argv[0];
155
221
  if (!sub || sub === "--help" || sub === "-h") {
@@ -158,13 +224,10 @@ export default async function grokCmd(argv) {
158
224
  }
159
225
  const rest = argv.slice(1);
160
226
  if (sub === "login")
161
- return loginCmd();
227
+ return loginCmd(rest);
162
228
  if (sub === "status")
163
229
  return statusCmd(rest);
164
- if (sub === "logout") {
165
- clearGrokCredentials();
166
- out(color.green("✓ ") + "Removed the stored Grok OAuth session");
167
- return;
168
- }
230
+ if (sub === "logout")
231
+ return logoutCmd(rest);
169
232
  die(2, `unknown subcommand '${sub}'. Run 'ima2 grok --help'.`);
170
233
  }
package/lib/xaiAuth.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * xAI (Grok) OAuth credential store and refresh client.
3
3
  *
4
4
  * Ported from OpenCodex `src/oauth/xai.ts` (refresh path only) with the D1-D6/D9 fixes
5
- * recorded in devlog/_plan/260909_grok_native_oauth/001_opencodex_port_spec.md.
5
+ * recorded in devlog/_fin/260909_grok_native_oauth/001_opencodex_port_spec.md.
6
6
  *
7
7
  * MUST stay a leaf module: only node:fs, node:crypto, node:os, node:path. No imports from
8
8
  * config, routes, adapters, or the logger — adapters call loadGrokCredentials() synchronously.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ima2-gen",
3
- "version": "3.16.0",
3
+ "version": "3.16.1",
4
4
  "packageManager": "npm@11.18.0",
5
5
  "description": "Local-first visual generation runtime and studio for people and coding agents, with reproducible image and video workflows across multiple providers.",
6
6
  "type": "module",
@@ -92,7 +92,7 @@
92
92
  "dependencies": {
93
93
  "@modelcontextprotocol/sdk": "1.30.0",
94
94
  "@neplex/vectorizer": "0.1.0",
95
- "@openai/codex": "0.153.2",
95
+ "@openai/codex": "0.153.4",
96
96
  "better-sqlite3": "^13.0.3",
97
97
  "dotenv": "^17.4.2",
98
98
  "express": "^5.1.0",
@@ -125,5 +125,5 @@
125
125
  "typescript": "^5.9.3",
126
126
  "yaml": "2.9.0"
127
127
  },
128
- "gitHead": "7fa7d426d92813caeeff667a458b781237029df0"
128
+ "gitHead": "5f33e44a7886580330ee03ea58a71a4d842014e5"
129
129
  }