@scheduler-systems/gal-run 0.0.307 → 0.0.308

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.cjs +187 -54
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -3970,7 +3970,7 @@ var cliVersion, defaultApiUrl, BUILD_CONSTANTS, constants_default;
3970
3970
  var init_constants = __esm({
3971
3971
  "src/constants.ts"() {
3972
3972
  "use strict";
3973
- cliVersion = true ? "0.0.307" : "0.0.0-dev";
3973
+ cliVersion = true ? "0.0.308" : "0.0.0-dev";
3974
3974
  defaultApiUrl = true ? "https://api.gal.run" : "http://localhost:3000";
3975
3975
  BUILD_CONSTANTS = Object.freeze([cliVersion, defaultApiUrl]);
3976
3976
  constants_default = BUILD_CONSTANTS;
@@ -4460,6 +4460,27 @@ function shouldShowUpdateNotification({
4460
4460
  if (!cache.lastNotificationShown) return true;
4461
4461
  return now - cache.lastNotificationShown > throttleWindowMs;
4462
4462
  }
4463
+ function shouldShowInteractivePrompt({
4464
+ cache,
4465
+ currentVersion,
4466
+ hasJsonFlag,
4467
+ isCI,
4468
+ isInteractiveTTY,
4469
+ isUpdateCommand,
4470
+ isAutoUpdateDisabled,
4471
+ now = Date.now(),
4472
+ throttleWindowMs = UPDATE_NOTIFICATION_WINDOW_MS
4473
+ }) {
4474
+ if (!cache?.latestVersion) return false;
4475
+ if (compareVersions(currentVersion, cache.latestVersion) >= 0) return false;
4476
+ if (hasJsonFlag) return false;
4477
+ if (isCI) return false;
4478
+ if (isAutoUpdateDisabled) return false;
4479
+ if (!isInteractiveTTY) return false;
4480
+ if (isUpdateCommand) return false;
4481
+ if (cache.lastInteractivePromptShown && now - cache.lastInteractivePromptShown < throttleWindowMs) return false;
4482
+ return true;
4483
+ }
4463
4484
  var UPDATE_NOTIFICATION_WINDOW_MS;
4464
4485
  var init_update_notification = __esm({
4465
4486
  "src/utils/update-notification.ts"() {
@@ -4859,7 +4880,7 @@ function detectEnvironment() {
4859
4880
  return "dev";
4860
4881
  }
4861
4882
  try {
4862
- const version = true ? "0.0.307" : void 0;
4883
+ const version = true ? "0.0.308" : void 0;
4863
4884
  if (version && version.includes("-local")) {
4864
4885
  return "dev";
4865
4886
  }
@@ -5228,7 +5249,7 @@ function getId() {
5228
5249
  }
5229
5250
  function getCliVersion() {
5230
5251
  try {
5231
- return true ? "0.0.307" : "0.0.0-dev";
5252
+ return true ? "0.0.308" : "0.0.0-dev";
5232
5253
  } catch {
5233
5254
  return "0.0.0-dev";
5234
5255
  }
@@ -30952,17 +30973,50 @@ function isAgentInstalled(agent) {
30952
30973
  }
30953
30974
  function installCursorHooks() {
30954
30975
  const cursorDir = (0, import_path14.join)((0, import_os14.homedir)(), ".cursor");
30976
+ const cursorHooksScriptDir = (0, import_path14.join)(cursorDir, "hooks");
30977
+ const scriptPath = (0, import_path14.join)(cursorHooksScriptDir, "gal-hooks.sh");
30955
30978
  const hooksPath = (0, import_path14.join)(cursorDir, "hooks.json");
30956
30979
  try {
30957
30980
  if (!(0, import_fs15.existsSync)(cursorDir)) {
30958
30981
  (0, import_fs15.mkdirSync)(cursorDir, { recursive: true });
30959
30982
  }
30983
+ if (!(0, import_fs15.existsSync)(cursorHooksScriptDir)) {
30984
+ (0, import_fs15.mkdirSync)(cursorHooksScriptDir, { recursive: true });
30985
+ }
30986
+ const scriptContent = `#!/bin/sh
30987
+ # GAL Config Sync Hook for Cursor
30988
+ # Installed by: gal hooks install
30989
+ # GAL_HOOK_VERSION = "2.0.0"
30990
+
30991
+ # Auto-update: silently upgrade gal CLI if newer version is cached
30992
+ UPDATE_CACHE="$HOME/.gal/update-cache.json"
30993
+ if [ "$GAL_NO_AUTO_UPDATE" != "1" ] && [ -z "$CI" ] && [ -f "$UPDATE_CACHE" ]; then
30994
+ LATEST=$(node -e "try{process.stdout.write(JSON.parse(require('fs').readFileSync(process.env.HOME+'/.gal/update-cache.json')).latestVersion||'')}catch(e){}" 2>/dev/null)
30995
+ CURRENT=$(gal --version 2>/dev/null)
30996
+ if [ -n "$LATEST" ] && [ -n "$CURRENT" ] && [ "$CURRENT" != "$LATEST" ]; then
30997
+ gal update 2>/dev/null || true
30998
+ UPDATED=$(gal --version 2>/dev/null)
30999
+ if [ -n "$UPDATED" ] && [ "$UPDATED" != "$CURRENT" ]; then
31000
+ echo "\u{1F504} GAL: Updated to v$UPDATED"
31001
+ fi
31002
+ fi
31003
+ fi
31004
+
31005
+ # Refresh update cache in background if stale (>24h)
31006
+ nohup sh -c "gal update --check 2>/dev/null" >/dev/null 2>&1 &
31007
+
31008
+ # Config sync
31009
+ gal sync --pull --auto 2>/dev/null || true
31010
+ `;
31011
+ (0, import_fs15.writeFileSync)(scriptPath, scriptContent, "utf-8");
31012
+ (0, import_fs15.chmodSync)(scriptPath, "755");
30960
31013
  const hookEntry = {
30961
31014
  type: "command",
30962
- command: "gal sync --pull --auto",
30963
- description: "GAL config sync",
30964
- timeout: 5e3,
30965
- installed_by: "gal-cli"
31015
+ command: scriptPath,
31016
+ description: "GAL config sync and auto-update",
31017
+ timeout: 1e4,
31018
+ installed_by: "gal-cli",
31019
+ version: "2.0.0"
30966
31020
  };
30967
31021
  let hooks = { hooks: { startup: [] } };
30968
31022
  if ((0, import_fs15.existsSync)(hooksPath)) {
@@ -30979,11 +31033,18 @@ function installCursorHooks() {
30979
31033
  (entry) => entry.installed_by === "gal-cli"
30980
31034
  );
30981
31035
  if (existingIndex >= 0) {
31036
+ if (hooks.hooks.startup[existingIndex].version === "2.0.0") {
31037
+ return {
31038
+ agent: "cursor",
31039
+ status: "up_to_date",
31040
+ path: hooksPath
31041
+ };
31042
+ }
30982
31043
  hooks.hooks.startup[existingIndex] = hookEntry;
30983
31044
  (0, import_fs15.writeFileSync)(hooksPath, JSON.stringify(hooks, null, 2), "utf-8");
30984
31045
  return {
30985
31046
  agent: "cursor",
30986
- status: "up_to_date",
31047
+ status: "updated",
30987
31048
  path: hooksPath
30988
31049
  };
30989
31050
  } else {
@@ -31005,17 +31066,50 @@ function installCursorHooks() {
31005
31066
  }
31006
31067
  function installWindsurfHooks() {
31007
31068
  const windsurfDir = (0, import_path14.join)((0, import_os14.homedir)(), ".windsurf");
31069
+ const windsurfHooksScriptDir = (0, import_path14.join)(windsurfDir, "hooks");
31070
+ const scriptPath = (0, import_path14.join)(windsurfHooksScriptDir, "gal-hooks.sh");
31008
31071
  const hooksPath = (0, import_path14.join)(windsurfDir, "hooks.json");
31009
31072
  try {
31010
31073
  if (!(0, import_fs15.existsSync)(windsurfDir)) {
31011
31074
  (0, import_fs15.mkdirSync)(windsurfDir, { recursive: true });
31012
31075
  }
31076
+ if (!(0, import_fs15.existsSync)(windsurfHooksScriptDir)) {
31077
+ (0, import_fs15.mkdirSync)(windsurfHooksScriptDir, { recursive: true });
31078
+ }
31079
+ const scriptContent = `#!/bin/sh
31080
+ # GAL Config Sync Hook for Windsurf
31081
+ # Installed by: gal hooks install
31082
+ # GAL_HOOK_VERSION = "2.0.0"
31083
+
31084
+ # Auto-update: silently upgrade gal CLI if newer version is cached
31085
+ UPDATE_CACHE="$HOME/.gal/update-cache.json"
31086
+ if [ "$GAL_NO_AUTO_UPDATE" != "1" ] && [ -z "$CI" ] && [ -f "$UPDATE_CACHE" ]; then
31087
+ LATEST=$(node -e "try{process.stdout.write(JSON.parse(require('fs').readFileSync(process.env.HOME+'/.gal/update-cache.json')).latestVersion||'')}catch(e){}" 2>/dev/null)
31088
+ CURRENT=$(gal --version 2>/dev/null)
31089
+ if [ -n "$LATEST" ] && [ -n "$CURRENT" ] && [ "$CURRENT" != "$LATEST" ]; then
31090
+ gal update 2>/dev/null || true
31091
+ UPDATED=$(gal --version 2>/dev/null)
31092
+ if [ -n "$UPDATED" ] && [ "$UPDATED" != "$CURRENT" ]; then
31093
+ echo "\u{1F504} GAL: Updated to v$UPDATED"
31094
+ fi
31095
+ fi
31096
+ fi
31097
+
31098
+ # Refresh update cache in background if stale (>24h)
31099
+ nohup sh -c "gal update --check 2>/dev/null" >/dev/null 2>&1 &
31100
+
31101
+ # Config sync
31102
+ gal sync --pull --auto 2>/dev/null || true
31103
+ `;
31104
+ (0, import_fs15.writeFileSync)(scriptPath, scriptContent, "utf-8");
31105
+ (0, import_fs15.chmodSync)(scriptPath, "755");
31013
31106
  const hookEntry = {
31014
31107
  type: "command",
31015
- command: "gal sync --pull --auto",
31016
- description: "GAL config sync",
31017
- timeout: 5e3,
31018
- installed_by: "gal-cli"
31108
+ command: scriptPath,
31109
+ description: "GAL config sync and auto-update",
31110
+ timeout: 1e4,
31111
+ installed_by: "gal-cli",
31112
+ version: "2.0.0"
31019
31113
  };
31020
31114
  let hooks = { hooks: { startup: [] } };
31021
31115
  if ((0, import_fs15.existsSync)(hooksPath)) {
@@ -31032,11 +31126,18 @@ function installWindsurfHooks() {
31032
31126
  (entry) => entry.installed_by === "gal-cli"
31033
31127
  );
31034
31128
  if (existingIndex >= 0) {
31129
+ if (hooks.hooks.startup[existingIndex].version === "2.0.0") {
31130
+ return {
31131
+ agent: "windsurf",
31132
+ status: "up_to_date",
31133
+ path: hooksPath
31134
+ };
31135
+ }
31035
31136
  hooks.hooks.startup[existingIndex] = hookEntry;
31036
31137
  (0, import_fs15.writeFileSync)(hooksPath, JSON.stringify(hooks, null, 2), "utf-8");
31037
31138
  return {
31038
31139
  agent: "windsurf",
31039
- status: "up_to_date",
31140
+ status: "updated",
31040
31141
  path: hooksPath
31041
31142
  };
31042
31143
  } else {
@@ -31066,12 +31167,31 @@ function installGeminiHooks() {
31066
31167
  const hookContent = `#!/bin/sh
31067
31168
  # GAL Config Sync Hook for Gemini CLI
31068
31169
  # Installed by: gal hooks install
31069
- # GAL_HOOK_VERSION = "1.0.0"
31170
+ # GAL_HOOK_VERSION = "2.0.0"
31171
+
31172
+ # Auto-update: silently upgrade gal CLI if newer version is cached
31173
+ UPDATE_CACHE="$HOME/.gal/update-cache.json"
31174
+ if [ "$GAL_NO_AUTO_UPDATE" != "1" ] && [ -z "$CI" ] && [ -f "$UPDATE_CACHE" ]; then
31175
+ LATEST=$(node -e "try{process.stdout.write(JSON.parse(require('fs').readFileSync(process.env.HOME+'/.gal/update-cache.json')).latestVersion||'')}catch(e){}" 2>/dev/null)
31176
+ CURRENT=$(gal --version 2>/dev/null)
31177
+ if [ -n "$LATEST" ] && [ -n "$CURRENT" ] && [ "$CURRENT" != "$LATEST" ]; then
31178
+ gal update 2>/dev/null || true
31179
+ UPDATED=$(gal --version 2>/dev/null)
31180
+ if [ -n "$UPDATED" ] && [ "$UPDATED" != "$CURRENT" ]; then
31181
+ echo "\u{1F504} GAL: Updated to v$UPDATED"
31182
+ fi
31183
+ fi
31184
+ fi
31185
+
31186
+ # Refresh update cache in background if stale (>24h)
31187
+ nohup sh -c "gal update --check 2>/dev/null" >/dev/null 2>&1 &
31188
+
31189
+ # Config sync
31070
31190
  gal sync --pull --auto 2>/dev/null || true
31071
31191
  `;
31072
31192
  if ((0, import_fs15.existsSync)(hookPath)) {
31073
31193
  const existing = (0, import_fs15.readFileSync)(hookPath, "utf-8");
31074
- if (existing.includes('GAL_HOOK_VERSION = "1.0.0"')) {
31194
+ if (existing.includes('GAL_HOOK_VERSION = "2.0.0"')) {
31075
31195
  return {
31076
31196
  agent: "gemini",
31077
31197
  status: "up_to_date",
@@ -31609,6 +31729,11 @@ function uninstallHooks() {
31609
31729
  }
31610
31730
  }
31611
31731
  }
31732
+ const cursorScriptPath = (0, import_path14.join)((0, import_os14.homedir)(), ".cursor", "hooks", "gal-hooks.sh");
31733
+ if ((0, import_fs15.existsSync)(cursorScriptPath)) {
31734
+ (0, import_fs15.unlinkSync)(cursorScriptPath);
31735
+ hookRemoved = true;
31736
+ }
31612
31737
  } catch (error2) {
31613
31738
  errors.push(`Failed to remove Cursor hooks: ${error2 instanceof Error ? error2.message : String(error2)}`);
31614
31739
  }
@@ -31628,6 +31753,11 @@ function uninstallHooks() {
31628
31753
  }
31629
31754
  }
31630
31755
  }
31756
+ const windsurfScriptPath = (0, import_path14.join)((0, import_os14.homedir)(), ".windsurf", "hooks", "gal-hooks.sh");
31757
+ if ((0, import_fs15.existsSync)(windsurfScriptPath)) {
31758
+ (0, import_fs15.unlinkSync)(windsurfScriptPath);
31759
+ hookRemoved = true;
31760
+ }
31631
31761
  } catch (error2) {
31632
31762
  errors.push(`Failed to remove Windsurf hooks: ${error2 instanceof Error ? error2.message : String(error2)}`);
31633
31763
  }
@@ -53087,7 +53217,7 @@ function releaseLock() {
53087
53217
  }
53088
53218
  }
53089
53219
  function createUpdateCommand() {
53090
- const command = new Command("update").description("Check for and apply CLI updates").option("--check", "Check only, do not apply update").action(async (options) => {
53220
+ const command = new Command("update").alias("upgrade").description("Check for and apply CLI updates").option("--check", "Check only, do not apply update").action(async (options) => {
53091
53221
  const spinner = ora("Checking for updates...").start();
53092
53222
  try {
53093
53223
  const latestVersion = await fetchLatestVersion();
@@ -54326,11 +54456,10 @@ async function checkForUpdates() {
54326
54456
  const cache = readUpdateCache();
54327
54457
  const shouldRefresh = !cache || Date.now() - cache.lastCheck > ONE_DAY;
54328
54458
  const now = Date.now();
54329
- const isUpdateCommand = process.argv.includes("update") || process.argv[2] === "update";
54459
+ const isUpdateCommand = process.argv.includes("update") || process.argv[2] === "update" || process.argv.includes("upgrade") || process.argv[2] === "upgrade";
54330
54460
  const isCI = process.env.CI === "true";
54331
54461
  const isAutoUpdateDisabled = process.env.GAL_NO_AUTO_UPDATE === "1";
54332
54462
  const isInteractiveTTY = process.stdin.isTTY === true;
54333
- const canShowInteractivePrompt = !isCI && !isAutoUpdateDisabled && !hasJsonFlag && isInteractiveTTY && !isUpdateCommand;
54334
54463
  const updateAvailable = cache?.latestVersion && shouldShowUpdateNotification({
54335
54464
  cache,
54336
54465
  currentVersion: cliVersion9,
@@ -54338,45 +54467,49 @@ async function checkForUpdates() {
54338
54467
  now
54339
54468
  });
54340
54469
  if (updateAvailable && cache?.latestVersion) {
54341
- if (canShowInteractivePrompt) {
54342
- const ONE_HOUR = 60 * 60 * 1e3;
54343
- const lastInteractiveShown = cache.lastInteractivePromptShown || 0;
54344
- const interactiveThrottled = now - lastInteractiveShown < ONE_HOUR;
54345
- if (!interactiveThrottled) {
54346
- writeUpdateCache({
54347
- lastCheck: cache.lastCheck,
54348
- latestVersion: cache.latestVersion,
54349
- lastNotificationShown: cache.lastNotificationShown,
54350
- lastInteractivePromptShown: now
54351
- });
54352
- const userWantsUpdate = await promptUpdateInteractive(
54353
- cliVersion9,
54354
- cache.latestVersion
54355
- );
54356
- if (userWantsUpdate) {
54357
- try {
54358
- await runInlineUpdate();
54359
- const args2 = process.argv.slice(2).filter((a) => a !== "update");
54360
- console.log(source_default.dim("\nRestarting with new version...\n"));
54361
- if (args2.length > 0) {
54362
- const child = (0, import_child_process13.spawn)("gal", args2, { stdio: "inherit" });
54363
- child.on("exit", (code) => process.exit(code || 0));
54364
- } else {
54365
- process.exit(0);
54366
- }
54367
- await new Promise(() => {
54368
- });
54369
- } catch {
54370
- console.log(
54371
- source_default.dim(
54372
- "\n Update failed, continuing with current version...\n"
54373
- )
54374
- );
54470
+ if (shouldShowInteractivePrompt({
54471
+ cache,
54472
+ currentVersion: cliVersion9,
54473
+ hasJsonFlag,
54474
+ isCI,
54475
+ isInteractiveTTY,
54476
+ isUpdateCommand,
54477
+ isAutoUpdateDisabled,
54478
+ now
54479
+ })) {
54480
+ writeUpdateCache({
54481
+ lastCheck: cache.lastCheck,
54482
+ latestVersion: cache.latestVersion,
54483
+ lastNotificationShown: cache.lastNotificationShown,
54484
+ lastInteractivePromptShown: now
54485
+ });
54486
+ const userWantsUpdate = await promptUpdateInteractive(
54487
+ cliVersion9,
54488
+ cache.latestVersion
54489
+ );
54490
+ if (userWantsUpdate) {
54491
+ try {
54492
+ await runInlineUpdate();
54493
+ const args2 = process.argv.slice(2).filter((a) => a !== "update");
54494
+ console.log(source_default.dim("\nRestarting with new version...\n"));
54495
+ if (args2.length > 0) {
54496
+ const child = (0, import_child_process13.spawn)("gal", args2, { stdio: "inherit" });
54497
+ child.on("exit", (code) => process.exit(code || 0));
54498
+ } else {
54499
+ process.exit(0);
54375
54500
  }
54376
- return;
54501
+ await new Promise(() => {
54502
+ });
54503
+ } catch {
54504
+ console.log(
54505
+ source_default.dim(
54506
+ "\n Update failed, continuing with current version...\n"
54507
+ )
54508
+ );
54377
54509
  }
54378
54510
  return;
54379
54511
  }
54512
+ return;
54380
54513
  }
54381
54514
  process.on("exit", () => {
54382
54515
  showUpdateNotification(cliVersion9, cache.latestVersion);
@@ -54743,7 +54876,7 @@ var init_index = __esm({
54743
54876
  });
54744
54877
 
54745
54878
  // src/bootstrap.ts
54746
- var cliVersion10 = true ? "0.0.307" : "0.0.0-dev";
54879
+ var cliVersion10 = true ? "0.0.308" : "0.0.0-dev";
54747
54880
  var args = process.argv.slice(2);
54748
54881
  var requestedGlobalHelp = args.length === 1 && (args[0] === "--help" || args[0] === "-h");
54749
54882
  var requestedVersion = args.length === 1 && (args[0] === "--version" || args[0] === "-V");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scheduler-systems/gal-run",
3
- "version": "0.0.307",
3
+ "version": "0.0.308",
4
4
  "description": "GAL CLI - Command-line tool for managing AI agent configurations across your organization",
5
5
  "license": "Elastic-2.0",
6
6
  "private": false,