@agentrules/cli 0.0.8 → 0.0.9

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.
Files changed (2) hide show
  1. package/dist/index.js +10 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -865,7 +865,6 @@ async function loadStore() {
865
865
  try {
866
866
  const raw = await readFile(credentialsPath, "utf8");
867
867
  const store = JSON.parse(raw);
868
- log.debug(`Loaded credentials for ${Object.keys(store).length} registries`);
869
868
  return store;
870
869
  } catch (error$2) {
871
870
  log.debug(`Failed to load credentials: ${error$2 instanceof Error ? error$2.message : String(error$2)}`);
@@ -885,7 +884,6 @@ async function saveStore(store) {
885
884
  mode: 384
886
885
  });
887
886
  await chmodAsync(credentialsPath, 384);
888
- log.debug(`Saved credentials for ${Object.keys(store).length} registries to ${credentialsPath}`);
889
887
  }
890
888
  /**
891
889
  * Gets credentials for a specific registry
@@ -916,8 +914,8 @@ async function saveCredentials(registryUrl, credentials) {
916
914
  const store = await loadStore();
917
915
  const key = normalizeUrl(registryUrl);
918
916
  store[key] = credentials;
919
- log.debug(`Saving credentials for registry ${registryUrl}${credentials.expiresAt ? ` (expires ${credentials.expiresAt})` : ""}`);
920
917
  await saveStore(store);
918
+ log.debug(`Saved credentials for ${registryUrl}${credentials.expiresAt ? ` (expires ${credentials.expiresAt})` : ""}`);
921
919
  }
922
920
  /**
923
921
  * Clears credentials for a specific registry
@@ -1042,7 +1040,7 @@ const CLIENT_ID = "agentrules-cli";
1042
1040
  * Performs device code flow login to an agentrules registry.
1043
1041
  */
1044
1042
  async function login(options = {}) {
1045
- const { noBrowser = false, onDeviceCode, onBrowserOpen, onPollingStart } = options;
1043
+ const { noBrowser = false, onDeviceCode, onBrowserOpen, onPollingStart, onAuthorized } = options;
1046
1044
  const ctx = useAppContext();
1047
1045
  if (!ctx) throw new Error("App context not initialized");
1048
1046
  const { url: registryUrl } = ctx.registry;
@@ -1084,6 +1082,7 @@ async function login(options = {}) {
1084
1082
  success: false,
1085
1083
  error: pollResult.error
1086
1084
  };
1085
+ onAuthorized?.();
1087
1086
  const token = pollResult.token.access_token;
1088
1087
  log.debug("Fetching user info");
1089
1088
  const session = await fetchSession(registryUrl, token);
@@ -2385,6 +2384,9 @@ program.command("login").description("Authenticate with the registry").option("-
2385
2384
  },
2386
2385
  onPollingStart: async () => {
2387
2386
  spinner$1 = await log.spinner("Waiting for authorization...");
2387
+ },
2388
+ onAuthorized: () => {
2389
+ spinner$1.update("Finalizing...");
2388
2390
  }
2389
2391
  });
2390
2392
  if (!result.success) {
@@ -2437,9 +2439,11 @@ program.command("unpublish").description("Remove a preset version from the regis
2437
2439
  });
2438
2440
  if (!result.success) process.exitCode = 1;
2439
2441
  }));
2440
- program.parseAsync(process.argv).catch((err) => {
2442
+ program.parseAsync(process.argv).then(() => {
2443
+ process.exit(process.exitCode ?? 0);
2444
+ }).catch((err) => {
2441
2445
  log.error(err instanceof Error ? err.message : String(err));
2442
- process.exitCode = 1;
2446
+ process.exit(1);
2443
2447
  });
2444
2448
  function handle(fn) {
2445
2449
  return async (...args) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentrules/cli",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "author": "Brian Cheung <bcheung.dev@gmail.com> (https://github.com/bcheung)",
5
5
  "license": "MIT",
6
6
  "homepage": "https://agentrules.directory",