@shardflux/cli 0.13.1 → 0.13.2

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,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.13.2
4
+
5
+ - On macOS, `shard` starts the menu bar by itself (with launch at login) the first time it runs; `shard menubar stop` turns that off and `shard menubar start` turns it back on.
6
+
3
7
  ## 0.13.1
4
8
 
5
9
  - `npx @shardflux/cli` runs `shard` again: the package exposes one command. The Git remote helper that `shard` uses for agent branches runs from a private shim on the PATH of the git commands `shard` starts.
package/dist/args.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const CLI_VERSION = "0.13.1";
1
+ export declare const CLI_VERSION = "0.13.2";
2
2
  export interface OptionSpec {
3
3
  type: 'string' | 'boolean';
4
4
  short?: string;
package/dist/args.js CHANGED
@@ -12,7 +12,7 @@
12
12
  import { parseArgs } from 'node:util';
13
13
  import { ACCOUNT_COMMANDS } from "./account-args.js";
14
14
  import { UsageError } from "./errors.js";
15
- export const CLI_VERSION = '0.13.1';
15
+ export const CLI_VERSION = '0.13.2';
16
16
  export const GLOBAL_OPTIONS = {
17
17
  'api-url': { type: 'string', value: '<url>', description: 'API base URL (default $SHARDFLUX_API_URL, else https://api.shardflux.dev).' },
18
18
  json: { type: 'boolean', description: 'Print machine-readable JSON on stdout (errors as JSON on stderr).' },
@@ -6,7 +6,7 @@ import { agentAction, availableTargets } from "./command-center-actions.js";
6
6
  import { centerRows, loadCenter } from "./command-center-model.js";
7
7
  import { AnsiRenderer, renderCenter } from "./command-center-renderer.js";
8
8
  import { CenterKeys } from "./command-center-keys.js";
9
- import { menubarHint } from "./menubar.js";
9
+ import { ensureMenubar } from "./menubar.js";
10
10
  import { MenubarManager } from "./menubar.js";
11
11
  import { homedir } from 'node:os';
12
12
  import { retrySetupStep } from "./assisted-setup.js";
@@ -17,7 +17,7 @@ export async function showCenter(ctx, scope, options = {}) {
17
17
  const { HANDLERS } = await import("./handlers.js");
18
18
  const extra = [['m', 'merge'], ['k', 'keep'], ['d', 'discard']].filter(([, command]) => HANDLERS[`agents ${command}`]);
19
19
  const view = { rows: [], selected: undefined, filter: '', message: 'Loading agents…', extraKeys: extra.map(([key, command]) => `${key} ${command}`) };
20
- const hint = await menubarHint(ctx.store.dir, new MenubarManager({ home: ctx.io.env.HOME || homedir(), signal: ctx.signal }));
20
+ const hint = await ensureMenubar(ctx.store.dir, ctx.apiUrl, new MenubarManager({ home: ctx.io.env.HOME || homedir(), signal: ctx.signal }));
21
21
  if (hint)
22
22
  view.menubarHint = hint;
23
23
  const renderer = new AnsiRenderer(), keys = new CenterKeys();
package/dist/menubar.d.ts CHANGED
@@ -26,7 +26,8 @@ export declare class MenubarManager {
26
26
  login(value: 'on' | 'off'): Promise<MenubarStatus>;
27
27
  start(configDir: string, apiUrl: string): Promise<MenubarStatus>;
28
28
  }
29
- /** Only the command center consumes this hint. It reads status, never resolves or installs the optional package. */
30
- export declare function menubarHint(dir: string, manager?: MenubarManager): Promise<string | undefined>;
29
+ /** On macOS, `shard` brings the menu bar up by itself (with launch at login) unless the user ran `shard menubar stop`.
30
+ * It never fails the command center: a missing optional package or a refused start just leaves it off. */
31
+ export declare function ensureMenubar(dir: string, apiUrl: string, manager?: MenubarManager, platform?: NodeJS.Platform): Promise<string | undefined>;
31
32
  export declare const MENUBAR_HANDLERS: Record<string, Handler>;
32
33
  export {};
package/dist/menubar.js CHANGED
@@ -148,22 +148,28 @@ export class MenubarManager {
148
148
  throw new UsageError(`Shardflux did not start. Check ${join(configDir, 'menubar.log')}.`);
149
149
  }
150
150
  }
151
- /** Only the command center consumes this hint. It reads status, never resolves or installs the optional package. */
152
- export async function menubarHint(dir, manager = new MenubarManager()) {
153
- if (process.platform !== 'darwin')
151
+ /** On macOS, `shard` brings the menu bar up by itself (with launch at login) unless the user ran `shard menubar stop`.
152
+ * It never fails the command center: a missing optional package or a refused start just leaves it off. */
153
+ export async function ensureMenubar(dir, apiUrl, manager = new MenubarManager(), platform = process.platform) {
154
+ if (platform !== 'darwin')
154
155
  return undefined;
155
156
  const store = new AgentStateStore(dir);
156
- if (store.read().menubar_hint_shown === true)
157
+ if (store.read().menubar_stopped === true)
157
158
  return undefined;
158
159
  try {
159
- if ((await manager.status()).running)
160
+ const status = await manager.status();
161
+ if (status.running)
160
162
  return undefined;
163
+ const started = await manager.start(dir, apiUrl);
164
+ if (!started.running)
165
+ return undefined;
166
+ if (started.login !== 'on')
167
+ await manager.login('on').catch(() => undefined);
168
+ return 'Menu bar started · shard menubar stop to turn it off';
161
169
  }
162
170
  catch {
163
171
  return undefined;
164
172
  }
165
- store.update(doc => { doc.menubar_hint_shown = true; });
166
- return 'Menu bar: shard menubar start';
167
173
  }
168
174
  export const MENUBAR_HANDLERS = Object.fromEntries(['start', 'stop', 'status'].map(action => {
169
175
  const handler = async (ctx, values) => {
@@ -171,6 +177,12 @@ export const MENUBAR_HANDLERS = Object.fromEntries(['start', 'stop', 'status'].m
171
177
  throw new UsageError('--login must be on or off.');
172
178
  const manager = new MenubarManager({ home: ctx.io.env.HOME || homedir(), signal: ctx.signal });
173
179
  let status = action === 'start' ? await manager.start(ctx.store.dir, ctx.apiUrl) : action === 'stop' ? await manager.stop() : await manager.status();
180
+ // An explicit stop keeps `shard` from starting the menu bar again; an explicit start re-enables it.
181
+ if (action !== 'status')
182
+ new AgentStateStore(ctx.store.dir).update(doc => { if (action === 'stop')
183
+ doc.menubar_stopped = true;
184
+ else
185
+ delete doc.menubar_stopped; });
174
186
  if (values.login === 'on' || values.login === 'off')
175
187
  status = await manager.login(values.login);
176
188
  ctx.io.stdout.write(ctx.json ? json(status) : `Menu bar: ${status.running ? 'running' : 'stopped'}${status.installed ? ` · app ${status.version}` : ' · not installed'} · login ${status.login}\n`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shardflux/cli",
3
- "version": "0.13.1",
3
+ "version": "0.13.2",
4
4
  "type": "module",
5
5
  "description": "shard: the Shardflux command line. Create an account, sign in, set up keys and billing, then open, run commands in, move files to, suspend, resume and fork serverless agent workspaces.",
6
6
  "license": "Apache-2.0",