@scheduler-systems/gal-run 0.0.337 → 0.0.338

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 +875 -783
  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.337" : "0.0.0-dev";
3973
+ cliVersion = true ? "0.0.338" : "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;
@@ -4880,7 +4880,7 @@ function detectEnvironment() {
4880
4880
  return "dev";
4881
4881
  }
4882
4882
  try {
4883
- const version = true ? "0.0.337" : void 0;
4883
+ const version = true ? "0.0.338" : void 0;
4884
4884
  if (version && version.includes("-local")) {
4885
4885
  return "dev";
4886
4886
  }
@@ -5249,7 +5249,7 @@ function getId() {
5249
5249
  }
5250
5250
  function getCliVersion() {
5251
5251
  try {
5252
- return true ? "0.0.337" : "0.0.0-dev";
5252
+ return true ? "0.0.338" : "0.0.0-dev";
5253
5253
  } catch {
5254
5254
  return "0.0.0-dev";
5255
5255
  }
@@ -7701,12 +7701,12 @@ function getFeatureFlags() {
7701
7701
  let isPartnerFromApi = false;
7702
7702
  if (!isInternalEnv) {
7703
7703
  try {
7704
- const { readFileSync: readFileSync38, existsSync: existsSync42 } = require("fs");
7705
- const { join: join46 } = require("path");
7706
- const { homedir: homedir25 } = require("os");
7707
- const configPath = join46(homedir25(), ".gal", "config.json");
7708
- if (existsSync42(configPath)) {
7709
- const config = JSON.parse(readFileSync38(configPath, "utf-8"));
7704
+ const { readFileSync: readFileSync39, existsSync: existsSync43 } = require("fs");
7705
+ const { join: join47 } = require("path");
7706
+ const { homedir: homedir26 } = require("os");
7707
+ const configPath = join47(homedir26(), ".gal", "config.json");
7708
+ if (existsSync43(configPath)) {
7709
+ const config = JSON.parse(readFileSync39(configPath, "utf-8"));
7710
7710
  const cacheAge = Date.now() - (config.flagsCachedAt || config.internalOrgsCheckedAt || 0);
7711
7711
  if (cacheAge < CACHE_MAX_AGE_MS) {
7712
7712
  const userOrgs = config.orgMemberships || [];
@@ -17165,7 +17165,7 @@ var require_thread_stream = __commonJS({
17165
17165
  var { version } = require_package2();
17166
17166
  var { EventEmitter: EventEmitter3 } = require("events");
17167
17167
  var { Worker } = require("worker_threads");
17168
- var { join: join46 } = require("path");
17168
+ var { join: join47 } = require("path");
17169
17169
  var { pathToFileURL } = require("url");
17170
17170
  var { wait } = require_wait();
17171
17171
  var {
@@ -17201,7 +17201,7 @@ var require_thread_stream = __commonJS({
17201
17201
  function createWorker(stream, opts) {
17202
17202
  const { filename, workerData } = opts;
17203
17203
  const bundlerOverrides = "__bundlerPathsOverrides" in globalThis ? globalThis.__bundlerPathsOverrides : {};
17204
- const toExecute = bundlerOverrides["thread-stream-worker"] || join46(__dirname, "lib", "worker.js");
17204
+ const toExecute = bundlerOverrides["thread-stream-worker"] || join47(__dirname, "lib", "worker.js");
17205
17205
  const worker = new Worker(toExecute, {
17206
17206
  ...opts.workerOpts,
17207
17207
  trackUnmanagedFds: false,
@@ -17587,7 +17587,7 @@ var require_transport = __commonJS({
17587
17587
  "use strict";
17588
17588
  var { createRequire: createRequire3 } = require("module");
17589
17589
  var getCallers = require_caller();
17590
- var { join: join46, isAbsolute, sep } = require("node:path");
17590
+ var { join: join47, isAbsolute, sep } = require("node:path");
17591
17591
  var sleep2 = require_atomic_sleep();
17592
17592
  var onExit2 = require_on_exit_leak_free();
17593
17593
  var ThreadStream = require_thread_stream();
@@ -17650,7 +17650,7 @@ var require_transport = __commonJS({
17650
17650
  throw new Error("only one of target or targets can be specified");
17651
17651
  }
17652
17652
  if (targets) {
17653
- target = bundlerOverrides["pino-worker"] || join46(__dirname, "worker.js");
17653
+ target = bundlerOverrides["pino-worker"] || join47(__dirname, "worker.js");
17654
17654
  options.targets = targets.filter((dest) => dest.target).map((dest) => {
17655
17655
  return {
17656
17656
  ...dest,
@@ -17668,7 +17668,7 @@ var require_transport = __commonJS({
17668
17668
  });
17669
17669
  });
17670
17670
  } else if (pipeline) {
17671
- target = bundlerOverrides["pino-worker"] || join46(__dirname, "worker.js");
17671
+ target = bundlerOverrides["pino-worker"] || join47(__dirname, "worker.js");
17672
17672
  options.pipelines = [pipeline.map((dest) => {
17673
17673
  return {
17674
17674
  ...dest,
@@ -17690,7 +17690,7 @@ var require_transport = __commonJS({
17690
17690
  return origin;
17691
17691
  }
17692
17692
  if (origin === "pino/file") {
17693
- return join46(__dirname, "..", "file.js");
17693
+ return join47(__dirname, "..", "file.js");
17694
17694
  }
17695
17695
  let fixTarget2;
17696
17696
  for (const filePath of callers) {
@@ -18679,7 +18679,7 @@ var require_safe_stable_stringify = __commonJS({
18679
18679
  return circularValue;
18680
18680
  }
18681
18681
  let res = "";
18682
- let join46 = ",";
18682
+ let join47 = ",";
18683
18683
  const originalIndentation = indentation;
18684
18684
  if (Array.isArray(value)) {
18685
18685
  if (value.length === 0) {
@@ -18693,7 +18693,7 @@ var require_safe_stable_stringify = __commonJS({
18693
18693
  indentation += spacer;
18694
18694
  res += `
18695
18695
  ${indentation}`;
18696
- join46 = `,
18696
+ join47 = `,
18697
18697
  ${indentation}`;
18698
18698
  }
18699
18699
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -18701,13 +18701,13 @@ ${indentation}`;
18701
18701
  for (; i < maximumValuesToStringify - 1; i++) {
18702
18702
  const tmp2 = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
18703
18703
  res += tmp2 !== void 0 ? tmp2 : "null";
18704
- res += join46;
18704
+ res += join47;
18705
18705
  }
18706
18706
  const tmp = stringifyFnReplacer(String(i), value, stack, replacer, spacer, indentation);
18707
18707
  res += tmp !== void 0 ? tmp : "null";
18708
18708
  if (value.length - 1 > maximumBreadth) {
18709
18709
  const removedKeys = value.length - maximumBreadth - 1;
18710
- res += `${join46}"... ${getItemCount(removedKeys)} not stringified"`;
18710
+ res += `${join47}"... ${getItemCount(removedKeys)} not stringified"`;
18711
18711
  }
18712
18712
  if (spacer !== "") {
18713
18713
  res += `
@@ -18728,7 +18728,7 @@ ${originalIndentation}`;
18728
18728
  let separator = "";
18729
18729
  if (spacer !== "") {
18730
18730
  indentation += spacer;
18731
- join46 = `,
18731
+ join47 = `,
18732
18732
  ${indentation}`;
18733
18733
  whitespace = " ";
18734
18734
  }
@@ -18742,13 +18742,13 @@ ${indentation}`;
18742
18742
  const tmp = stringifyFnReplacer(key2, value, stack, replacer, spacer, indentation);
18743
18743
  if (tmp !== void 0) {
18744
18744
  res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
18745
- separator = join46;
18745
+ separator = join47;
18746
18746
  }
18747
18747
  }
18748
18748
  if (keyLength > maximumBreadth) {
18749
18749
  const removedKeys = keyLength - maximumBreadth;
18750
18750
  res += `${separator}"...":${whitespace}"${getItemCount(removedKeys)} not stringified"`;
18751
- separator = join46;
18751
+ separator = join47;
18752
18752
  }
18753
18753
  if (spacer !== "" && separator.length > 1) {
18754
18754
  res = `
@@ -18789,7 +18789,7 @@ ${originalIndentation}`;
18789
18789
  }
18790
18790
  const originalIndentation = indentation;
18791
18791
  let res = "";
18792
- let join46 = ",";
18792
+ let join47 = ",";
18793
18793
  if (Array.isArray(value)) {
18794
18794
  if (value.length === 0) {
18795
18795
  return "[]";
@@ -18802,7 +18802,7 @@ ${originalIndentation}`;
18802
18802
  indentation += spacer;
18803
18803
  res += `
18804
18804
  ${indentation}`;
18805
- join46 = `,
18805
+ join47 = `,
18806
18806
  ${indentation}`;
18807
18807
  }
18808
18808
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
@@ -18810,13 +18810,13 @@ ${indentation}`;
18810
18810
  for (; i < maximumValuesToStringify - 1; i++) {
18811
18811
  const tmp2 = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
18812
18812
  res += tmp2 !== void 0 ? tmp2 : "null";
18813
- res += join46;
18813
+ res += join47;
18814
18814
  }
18815
18815
  const tmp = stringifyArrayReplacer(String(i), value[i], stack, replacer, spacer, indentation);
18816
18816
  res += tmp !== void 0 ? tmp : "null";
18817
18817
  if (value.length - 1 > maximumBreadth) {
18818
18818
  const removedKeys = value.length - maximumBreadth - 1;
18819
- res += `${join46}"... ${getItemCount(removedKeys)} not stringified"`;
18819
+ res += `${join47}"... ${getItemCount(removedKeys)} not stringified"`;
18820
18820
  }
18821
18821
  if (spacer !== "") {
18822
18822
  res += `
@@ -18829,7 +18829,7 @@ ${originalIndentation}`;
18829
18829
  let whitespace = "";
18830
18830
  if (spacer !== "") {
18831
18831
  indentation += spacer;
18832
- join46 = `,
18832
+ join47 = `,
18833
18833
  ${indentation}`;
18834
18834
  whitespace = " ";
18835
18835
  }
@@ -18838,7 +18838,7 @@ ${indentation}`;
18838
18838
  const tmp = stringifyArrayReplacer(key2, value[key2], stack, replacer, spacer, indentation);
18839
18839
  if (tmp !== void 0) {
18840
18840
  res += `${separator}${strEscape(key2)}:${whitespace}${tmp}`;
18841
- separator = join46;
18841
+ separator = join47;
18842
18842
  }
18843
18843
  }
18844
18844
  if (spacer !== "" && separator.length > 1) {
@@ -18896,20 +18896,20 @@ ${originalIndentation}`;
18896
18896
  indentation += spacer;
18897
18897
  let res2 = `
18898
18898
  ${indentation}`;
18899
- const join47 = `,
18899
+ const join48 = `,
18900
18900
  ${indentation}`;
18901
18901
  const maximumValuesToStringify = Math.min(value.length, maximumBreadth);
18902
18902
  let i = 0;
18903
18903
  for (; i < maximumValuesToStringify - 1; i++) {
18904
18904
  const tmp2 = stringifyIndent(String(i), value[i], stack, spacer, indentation);
18905
18905
  res2 += tmp2 !== void 0 ? tmp2 : "null";
18906
- res2 += join47;
18906
+ res2 += join48;
18907
18907
  }
18908
18908
  const tmp = stringifyIndent(String(i), value[i], stack, spacer, indentation);
18909
18909
  res2 += tmp !== void 0 ? tmp : "null";
18910
18910
  if (value.length - 1 > maximumBreadth) {
18911
18911
  const removedKeys = value.length - maximumBreadth - 1;
18912
- res2 += `${join47}"... ${getItemCount(removedKeys)} not stringified"`;
18912
+ res2 += `${join48}"... ${getItemCount(removedKeys)} not stringified"`;
18913
18913
  }
18914
18914
  res2 += `
18915
18915
  ${originalIndentation}`;
@@ -18925,16 +18925,16 @@ ${originalIndentation}`;
18925
18925
  return '"[Object]"';
18926
18926
  }
18927
18927
  indentation += spacer;
18928
- const join46 = `,
18928
+ const join47 = `,
18929
18929
  ${indentation}`;
18930
18930
  let res = "";
18931
18931
  let separator = "";
18932
18932
  let maximumPropertiesToStringify = Math.min(keyLength, maximumBreadth);
18933
18933
  if (isTypedArrayWithEntries(value)) {
18934
- res += stringifyTypedArray(value, join46, maximumBreadth);
18934
+ res += stringifyTypedArray(value, join47, maximumBreadth);
18935
18935
  keys = keys.slice(value.length);
18936
18936
  maximumPropertiesToStringify -= value.length;
18937
- separator = join46;
18937
+ separator = join47;
18938
18938
  }
18939
18939
  if (deterministic) {
18940
18940
  keys = sort(keys, comparator);
@@ -18945,13 +18945,13 @@ ${indentation}`;
18945
18945
  const tmp = stringifyIndent(key2, value[key2], stack, spacer, indentation);
18946
18946
  if (tmp !== void 0) {
18947
18947
  res += `${separator}${strEscape(key2)}: ${tmp}`;
18948
- separator = join46;
18948
+ separator = join47;
18949
18949
  }
18950
18950
  }
18951
18951
  if (keyLength > maximumBreadth) {
18952
18952
  const removedKeys = keyLength - maximumBreadth;
18953
18953
  res += `${separator}"...": "${getItemCount(removedKeys)} not stringified"`;
18954
- separator = join46;
18954
+ separator = join47;
18955
18955
  }
18956
18956
  if (separator !== "") {
18957
18957
  res = `
@@ -21327,11 +21327,11 @@ function createApprovedConfigCommand() {
21327
21327
  const spinner = options.json ? null : ora(`Fetching approved config for "${org}"...`).start();
21328
21328
  try {
21329
21329
  let findMdFiles2 = function(dir) {
21330
- if (!existsSync42(dir)) return [];
21330
+ if (!existsSync43(dir)) return [];
21331
21331
  const entries = readdirSync17(dir, { withFileTypes: true });
21332
21332
  const files = [];
21333
21333
  for (const entry of entries) {
21334
- const fullPath = join46(dir, entry.name);
21334
+ const fullPath = join47(dir, entry.name);
21335
21335
  if (entry.isDirectory()) files.push(...findMdFiles2(fullPath));
21336
21336
  else if (entry.name.endsWith(".md")) files.push(fullPath);
21337
21337
  }
@@ -21349,11 +21349,11 @@ function createApprovedConfigCommand() {
21349
21349
  }
21350
21350
  return;
21351
21351
  }
21352
- const { existsSync: existsSync42, readdirSync: readdirSync17, readFileSync: readFileSync38 } = await import("fs");
21353
- const { join: join46, relative: relative10, basename: basename9 } = await import("path");
21352
+ const { existsSync: existsSync43, readdirSync: readdirSync17, readFileSync: readFileSync39 } = await import("fs");
21353
+ const { join: join47, relative: relative10, basename: basename9 } = await import("path");
21354
21354
  const baseDir = options.dir || process.cwd();
21355
- const commandsDir = join46(baseDir, ".claude", "commands");
21356
- const agentsDir = join46(baseDir, ".claude", "agents");
21355
+ const commandsDir = join47(baseDir, ".claude", "commands");
21356
+ const agentsDir = join47(baseDir, ".claude", "agents");
21357
21357
  const localCommandNames = findMdFiles2(commandsDir).map(
21358
21358
  (f) => relative10(commandsDir, f).replace(/\.md$/, "").replace(/\//g, ":")
21359
21359
  );
@@ -32617,6 +32617,122 @@ var init_agents_md_generator = __esm({
32617
32617
  }
32618
32618
  });
32619
32619
 
32620
+ // src/utils/mcp-config-writer.ts
32621
+ function resolveEnvVars(value) {
32622
+ let resolved = value.replace(/^~(?=\/|$)/, (0, import_os15.homedir)());
32623
+ resolved = resolved.replace(/\$HOME\b/g, (0, import_os15.homedir)());
32624
+ resolved = resolved.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g, (_match, varName) => {
32625
+ if (varName === "HOME") return (0, import_os15.homedir)();
32626
+ const envVal = process.env[varName];
32627
+ return envVal !== void 0 ? envVal : _match;
32628
+ });
32629
+ resolved = resolved.replace(/\$([A-Za-z_][A-Za-z0-9_]*)\b/g, (_match, varName) => {
32630
+ if (varName === "HOME") return (0, import_os15.homedir)();
32631
+ const envVal = process.env[varName];
32632
+ return envVal !== void 0 ? envVal : _match;
32633
+ });
32634
+ return resolved;
32635
+ }
32636
+ function resolveEnvVarsDeep(value) {
32637
+ if (typeof value === "string") {
32638
+ return resolveEnvVars(value);
32639
+ }
32640
+ if (Array.isArray(value)) {
32641
+ return value.map(resolveEnvVarsDeep);
32642
+ }
32643
+ if (value && typeof value === "object") {
32644
+ const result = {};
32645
+ for (const [k, v] of Object.entries(value)) {
32646
+ result[k] = resolveEnvVarsDeep(v);
32647
+ }
32648
+ return result;
32649
+ }
32650
+ return value;
32651
+ }
32652
+ function readMcpJsonFile(mcpPath) {
32653
+ if (!(0, import_fs18.existsSync)(mcpPath)) {
32654
+ return { mcpServers: {} };
32655
+ }
32656
+ try {
32657
+ const raw = (0, import_fs18.readFileSync)(mcpPath, "utf-8");
32658
+ const parsed = JSON.parse(raw);
32659
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
32660
+ return { mcpServers: {} };
32661
+ }
32662
+ return parsed;
32663
+ } catch {
32664
+ return { mcpServers: {} };
32665
+ }
32666
+ }
32667
+ function mergeMcpConfigs(existing, orgServers, orgName) {
32668
+ const merged = { ...existing };
32669
+ const existingServers = existing.mcpServers && typeof existing.mcpServers === "object" ? { ...existing.mcpServers } : {};
32670
+ const orgServerNames = new Set(Object.keys(orgServers));
32671
+ const preservedUserServers = [];
32672
+ for (const name of Object.keys(existingServers)) {
32673
+ if (!orgServerNames.has(name) && name !== "gal") {
32674
+ preservedUserServers.push(name);
32675
+ }
32676
+ }
32677
+ const mergedServers = { ...existingServers };
32678
+ let orgServersApplied = 0;
32679
+ for (const [name, config] of Object.entries(orgServers)) {
32680
+ mergedServers[name] = config;
32681
+ orgServersApplied++;
32682
+ }
32683
+ mergedServers["gal"] = {
32684
+ type: "http",
32685
+ transport: "http",
32686
+ url: "https://api.gal.run/mcp",
32687
+ ...orgName ? { headers: { "X-Gal-Organization": orgName } } : {}
32688
+ };
32689
+ for (const [name, config] of Object.entries(mergedServers)) {
32690
+ mergedServers[name] = resolveEnvVarsDeep(config);
32691
+ }
32692
+ merged.mcpServers = mergedServers;
32693
+ return { merged, orgServersApplied, preservedUserServers };
32694
+ }
32695
+ function parseOrgMcpServers(mcpContent) {
32696
+ if (!mcpContent) return {};
32697
+ try {
32698
+ const parsed = JSON.parse(mcpContent);
32699
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
32700
+ const obj = parsed;
32701
+ if (obj.mcpServers && typeof obj.mcpServers === "object" && !Array.isArray(obj.mcpServers)) {
32702
+ return obj.mcpServers;
32703
+ }
32704
+ }
32705
+ } catch {
32706
+ }
32707
+ return {};
32708
+ }
32709
+ function syncMcpConfig(directory, mcpContent, orgName) {
32710
+ const mcpPath = (0, import_path17.join)(directory, ".mcp.json");
32711
+ const existing = readMcpJsonFile(mcpPath);
32712
+ const orgServers = parseOrgMcpServers(mcpContent);
32713
+ const { merged, orgServersApplied, preservedUserServers } = mergeMcpConfigs(
32714
+ existing,
32715
+ orgServers,
32716
+ orgName
32717
+ );
32718
+ (0, import_fs18.writeFileSync)(mcpPath, JSON.stringify(merged, null, 2) + "\n", "utf-8");
32719
+ return {
32720
+ filePath: mcpPath,
32721
+ orgServersApplied,
32722
+ preservedUserServers,
32723
+ galServerIncluded: true
32724
+ };
32725
+ }
32726
+ var import_fs18, import_path17, import_os15;
32727
+ var init_mcp_config_writer = __esm({
32728
+ "src/utils/mcp-config-writer.ts"() {
32729
+ "use strict";
32730
+ import_fs18 = require("fs");
32731
+ import_path17 = require("path");
32732
+ import_os15 = require("os");
32733
+ }
32734
+ });
32735
+
32620
32736
  // src/utils/drift-check.ts
32621
32737
  var drift_check_exports = {};
32622
32738
  __export(drift_check_exports, {
@@ -32630,12 +32746,12 @@ function hashContent(content) {
32630
32746
  return (0, import_crypto5.createHash)("sha256").update(content).digest("hex").substring(0, 16);
32631
32747
  }
32632
32748
  function getUserSettingsPath() {
32633
- return (0, import_path17.join)((0, import_os15.homedir)(), ".claude", "settings.json");
32749
+ return (0, import_path18.join)((0, import_os16.homedir)(), ".claude", "settings.json");
32634
32750
  }
32635
32751
  function readLocalSettings(settingsPath) {
32636
- if (!(0, import_fs18.existsSync)(settingsPath)) return null;
32752
+ if (!(0, import_fs19.existsSync)(settingsPath)) return null;
32637
32753
  try {
32638
- return (0, import_fs18.readFileSync)(settingsPath, "utf-8");
32754
+ return (0, import_fs19.readFileSync)(settingsPath, "utf-8");
32639
32755
  } catch {
32640
32756
  return null;
32641
32757
  }
@@ -32695,10 +32811,10 @@ function printDriftWarning(result) {
32695
32811
  console.log();
32696
32812
  }
32697
32813
  async function runSessionDriftCheck(projectRoot) {
32698
- const syncStatePath = (0, import_path17.join)(projectRoot, ".gal", "sync-state.json");
32699
- if (!(0, import_fs18.existsSync)(syncStatePath)) return null;
32814
+ const syncStatePath = (0, import_path18.join)(projectRoot, ".gal", "sync-state.json");
32815
+ if (!(0, import_fs19.existsSync)(syncStatePath)) return null;
32700
32816
  try {
32701
- const stateContent = (0, import_fs18.readFileSync)(syncStatePath, "utf-8");
32817
+ const stateContent = (0, import_fs19.readFileSync)(syncStatePath, "utf-8");
32702
32818
  const state = JSON.parse(stateContent);
32703
32819
  const claudeState = state.platforms?.claude;
32704
32820
  const orgHash = claudeState?.lastSyncHash || state.lastSyncHash || null;
@@ -32728,13 +32844,13 @@ async function runSessionDriftCheck(projectRoot) {
32728
32844
  return null;
32729
32845
  }
32730
32846
  }
32731
- var import_fs18, import_path17, import_os15, import_crypto5;
32847
+ var import_fs19, import_path18, import_os16, import_crypto5;
32732
32848
  var init_drift_check = __esm({
32733
32849
  "src/utils/drift-check.ts"() {
32734
32850
  "use strict";
32735
- import_fs18 = require("fs");
32736
- import_path17 = require("path");
32737
- import_os15 = require("os");
32851
+ import_fs19 = require("fs");
32852
+ import_path18 = require("path");
32853
+ import_os16 = require("os");
32738
32854
  import_crypto5 = require("crypto");
32739
32855
  init_source();
32740
32856
  init_config_manager();
@@ -32746,30 +32862,30 @@ function countEnabledDispatchCategories(categories) {
32746
32862
  return getValidDispatchCategories(categories).filter((category) => category.enabled).length;
32747
32863
  }
32748
32864
  function installCursorGalCliRules(directory) {
32749
- const cursorRulesDir = (0, import_path18.join)(directory, ".cursor", "rules", "gal-cli");
32750
- const rulesPath = (0, import_path18.join)(cursorRulesDir, "RULE.md");
32865
+ const cursorRulesDir = (0, import_path19.join)(directory, ".cursor", "rules", "gal-cli");
32866
+ const rulesPath = (0, import_path19.join)(cursorRulesDir, "RULE.md");
32751
32867
  try {
32752
- if ((0, import_fs19.existsSync)(rulesPath)) {
32753
- const existingContent = (0, import_fs19.readFileSync)(rulesPath, "utf-8");
32868
+ if ((0, import_fs20.existsSync)(rulesPath)) {
32869
+ const existingContent = (0, import_fs20.readFileSync)(rulesPath, "utf-8");
32754
32870
  const versionMatch = existingContent.match(/GAL_CURSOR_RULES_VERSION = "([^"]+)"/);
32755
32871
  if (versionMatch && versionMatch[1] === GAL_CLI_CURSOR_RULES_VERSION) {
32756
32872
  return true;
32757
32873
  }
32758
32874
  }
32759
- if (!(0, import_fs19.existsSync)(cursorRulesDir)) {
32760
- (0, import_fs19.mkdirSync)(cursorRulesDir, { recursive: true });
32875
+ if (!(0, import_fs20.existsSync)(cursorRulesDir)) {
32876
+ (0, import_fs20.mkdirSync)(cursorRulesDir, { recursive: true });
32761
32877
  }
32762
- (0, import_fs19.writeFileSync)(rulesPath, GAL_CLI_CURSOR_RULES, "utf-8");
32878
+ (0, import_fs20.writeFileSync)(rulesPath, GAL_CLI_CURSOR_RULES, "utf-8");
32763
32879
  return true;
32764
32880
  } catch {
32765
32881
  return false;
32766
32882
  }
32767
32883
  }
32768
32884
  function writeSyncStateV2(orgName, platformStates, hookSettings) {
32769
- const galDir = (0, import_path18.join)(process.cwd(), ".gal");
32770
- const statePath = (0, import_path18.join)(galDir, "sync-state.json");
32771
- if (!(0, import_fs19.existsSync)(galDir)) {
32772
- (0, import_fs19.mkdirSync)(galDir, { recursive: true });
32885
+ const galDir = (0, import_path19.join)(process.cwd(), ".gal");
32886
+ const statePath = (0, import_path19.join)(galDir, "sync-state.json");
32887
+ if (!(0, import_fs20.existsSync)(galDir)) {
32888
+ (0, import_fs20.mkdirSync)(galDir, { recursive: true });
32773
32889
  }
32774
32890
  const platforms = {};
32775
32891
  for (const [platform5, state2] of platformStates) {
@@ -32790,7 +32906,7 @@ function writeSyncStateV2(orgName, platformStates, hookSettings) {
32790
32906
  // After a successful sync, approved hash matches local hash
32791
32907
  approvedConfigHash: primaryState?.lastSyncHash
32792
32908
  };
32793
- (0, import_fs19.writeFileSync)(statePath, JSON.stringify(state, null, 2), "utf-8");
32909
+ (0, import_fs20.writeFileSync)(statePath, JSON.stringify(state, null, 2), "utf-8");
32794
32910
  }
32795
32911
  function writeSyncState(orgName, localHash, approvedHash, version, syncedFiles = [], policyName, hookSettings) {
32796
32912
  const platformStates = /* @__PURE__ */ new Map();
@@ -32846,16 +32962,16 @@ function findChangedKeys(existing, incoming, prefix = "") {
32846
32962
  }
32847
32963
  function readSyncState() {
32848
32964
  const projectRoot = findProjectRoot();
32849
- const statePath = (0, import_path18.join)(projectRoot, ".gal", "sync-state.json");
32850
- if (!(0, import_fs19.existsSync)(statePath)) {
32965
+ const statePath = (0, import_path19.join)(projectRoot, ".gal", "sync-state.json");
32966
+ if (!(0, import_fs20.existsSync)(statePath)) {
32851
32967
  return null;
32852
32968
  }
32853
32969
  try {
32854
- const content = (0, import_fs19.readFileSync)(statePath, "utf-8");
32970
+ const content = (0, import_fs20.readFileSync)(statePath, "utf-8");
32855
32971
  const rawState = JSON.parse(content);
32856
32972
  if (!rawState.schemaVersion) {
32857
32973
  const migratedState = migrateSyncStateV1ToV2(rawState);
32858
- (0, import_fs19.writeFileSync)(statePath, JSON.stringify(migratedState, null, 2), "utf-8");
32974
+ (0, import_fs20.writeFileSync)(statePath, JSON.stringify(migratedState, null, 2), "utf-8");
32859
32975
  return migratedState;
32860
32976
  }
32861
32977
  return rawState;
@@ -33172,30 +33288,30 @@ function createSyncCommand() {
33172
33288
  }
33173
33289
  const allowlist = await res.json();
33174
33290
  spinner2.succeed(source_default.green("Domain allowlist fetched"));
33175
- const galDir = (0, import_path18.join)(directory, ".gal");
33176
- if (!(0, import_fs19.existsSync)(galDir)) {
33177
- (0, import_fs19.mkdirSync)(galDir, { recursive: true });
33291
+ const galDir = (0, import_path19.join)(directory, ".gal");
33292
+ if (!(0, import_fs20.existsSync)(galDir)) {
33293
+ (0, import_fs20.mkdirSync)(galDir, { recursive: true });
33178
33294
  }
33179
- const allowlistPath = (0, import_path18.join)(galDir, "domain-allowlist.json");
33180
- (0, import_fs19.writeFileSync)(allowlistPath, JSON.stringify(allowlist, null, 2) + "\n", "utf-8");
33295
+ const allowlistPath = (0, import_path19.join)(galDir, "domain-allowlist.json");
33296
+ (0, import_fs20.writeFileSync)(allowlistPath, JSON.stringify(allowlist, null, 2) + "\n", "utf-8");
33181
33297
  console.log(source_default.green(`
33182
33298
  Synced domain allowlist to .gal/domain-allowlist.json`));
33183
33299
  console.log(source_default.dim(` Domains: ${allowlist.allowedDomains?.length || 0}`));
33184
33300
  console.log(source_default.dim(` MCP endpoints: ${allowlist.allowedMcpEndpoints?.length || 0}`));
33185
33301
  console.log(source_default.dim(` Enforced: ${allowlist.enforced ? "yes" : "no (audit-only)"}`));
33186
- const policiesDir = (0, import_path18.join)(directory, ".github", "policies");
33187
- if ((0, import_fs19.existsSync)((0, import_path18.join)(directory, ".github"))) {
33188
- if (!(0, import_fs19.existsSync)(policiesDir)) {
33189
- (0, import_fs19.mkdirSync)(policiesDir, { recursive: true });
33302
+ const policiesDir = (0, import_path19.join)(directory, ".github", "policies");
33303
+ if ((0, import_fs20.existsSync)((0, import_path19.join)(directory, ".github"))) {
33304
+ if (!(0, import_fs20.existsSync)(policiesDir)) {
33305
+ (0, import_fs20.mkdirSync)(policiesDir, { recursive: true });
33190
33306
  }
33191
- const policyPath = (0, import_path18.join)(policiesDir, "domain-allowlist.json");
33307
+ const policyPath = (0, import_path19.join)(policiesDir, "domain-allowlist.json");
33192
33308
  const policyContent = {
33193
33309
  version: allowlist.version || 1,
33194
33310
  approvedDomains: allowlist.allowedDomains || [],
33195
33311
  approvedMcpEndpoints: allowlist.allowedMcpEndpoints || [],
33196
33312
  description: "Domains approved for AI agent WebFetch/WebSearch access. Managed by GAL org-level policy."
33197
33313
  };
33198
- (0, import_fs19.writeFileSync)(policyPath, JSON.stringify(policyContent, null, 2) + "\n", "utf-8");
33314
+ (0, import_fs20.writeFileSync)(policyPath, JSON.stringify(policyContent, null, 2) + "\n", "utf-8");
33199
33315
  console.log(source_default.dim(` Also updated .github/policies/domain-allowlist.json`));
33200
33316
  }
33201
33317
  console.log();
@@ -33521,11 +33637,11 @@ function createSyncCommand() {
33521
33637
  process.exit(0);
33522
33638
  }
33523
33639
  const directory = findProjectRoot(settingsOpts.directory || process.cwd());
33524
- const settingsPath = (0, import_path18.join)(directory, ".claude", "settings.json");
33640
+ const settingsPath = (0, import_path19.join)(directory, ".claude", "settings.json");
33525
33641
  let existingSettings = {};
33526
- if ((0, import_fs19.existsSync)(settingsPath)) {
33642
+ if ((0, import_fs20.existsSync)(settingsPath)) {
33527
33643
  try {
33528
- existingSettings = JSON.parse((0, import_fs19.readFileSync)(settingsPath, "utf-8"));
33644
+ existingSettings = JSON.parse((0, import_fs20.readFileSync)(settingsPath, "utf-8"));
33529
33645
  } catch {
33530
33646
  console.error(source_default.red("Error: Could not parse existing .claude/settings.json"));
33531
33647
  process.exit(1);
@@ -33561,11 +33677,11 @@ function createSyncCommand() {
33561
33677
  deny: mergedDeny
33562
33678
  }
33563
33679
  };
33564
- const claudeDir = (0, import_path18.join)(directory, ".claude");
33565
- if (!(0, import_fs19.existsSync)(claudeDir)) {
33566
- (0, import_fs19.mkdirSync)(claudeDir, { recursive: true });
33680
+ const claudeDir = (0, import_path19.join)(directory, ".claude");
33681
+ if (!(0, import_fs20.existsSync)(claudeDir)) {
33682
+ (0, import_fs20.mkdirSync)(claudeDir, { recursive: true });
33567
33683
  }
33568
- (0, import_fs19.writeFileSync)(settingsPath, JSON.stringify(merged, null, 2) + "\n", "utf-8");
33684
+ (0, import_fs20.writeFileSync)(settingsPath, JSON.stringify(merged, null, 2) + "\n", "utf-8");
33569
33685
  console.log(source_default.green(`
33570
33686
  \u2714 Added ${added.length} deny rule(s) to ${settingsPath}`));
33571
33687
  for (const rule of added) {
@@ -33584,67 +33700,67 @@ function scanLocalConfigs(directory, platformFilter) {
33584
33700
  for (const platform5 of platforms) {
33585
33701
  if (platformFilter && platform5 !== platformFilter) continue;
33586
33702
  const platformDir = getPlatformDirectory(platform5);
33587
- const fullPath = (0, import_path18.join)(directory, platformDir);
33588
- if (!(0, import_fs19.existsSync)(fullPath)) continue;
33703
+ const fullPath = (0, import_path19.join)(directory, platformDir);
33704
+ if (!(0, import_fs20.existsSync)(fullPath)) continue;
33589
33705
  const files = [];
33590
- const settingsPath = (0, import_path18.join)(fullPath, "settings.json");
33591
- if ((0, import_fs19.existsSync)(settingsPath)) {
33706
+ const settingsPath = (0, import_path19.join)(fullPath, "settings.json");
33707
+ if ((0, import_fs20.existsSync)(settingsPath)) {
33592
33708
  files.push({
33593
33709
  path: settingsPath,
33594
33710
  type: "settings",
33595
- content: (0, import_fs19.readFileSync)(settingsPath, "utf-8")
33711
+ content: (0, import_fs20.readFileSync)(settingsPath, "utf-8")
33596
33712
  });
33597
33713
  }
33598
- const rulesDir = (0, import_path18.join)(fullPath, "rules");
33599
- if ((0, import_fs19.existsSync)(rulesDir)) {
33600
- const ruleFiles = (0, import_fs19.readdirSync)(rulesDir).filter(
33714
+ const rulesDir = (0, import_path19.join)(fullPath, "rules");
33715
+ if ((0, import_fs20.existsSync)(rulesDir)) {
33716
+ const ruleFiles = (0, import_fs20.readdirSync)(rulesDir).filter(
33601
33717
  (f) => f.endsWith(".md") || f.endsWith(".mdc")
33602
33718
  );
33603
33719
  for (const file of ruleFiles) {
33604
- const filePath = (0, import_path18.join)(rulesDir, file);
33720
+ const filePath = (0, import_path19.join)(rulesDir, file);
33605
33721
  files.push({
33606
33722
  path: filePath,
33607
33723
  type: "rule",
33608
- content: (0, import_fs19.readFileSync)(filePath, "utf-8")
33724
+ content: (0, import_fs20.readFileSync)(filePath, "utf-8")
33609
33725
  });
33610
33726
  }
33611
33727
  }
33612
33728
  if (platform5 === "cursor") {
33613
- const cursorRulesPath = (0, import_path18.join)(directory, ".cursorrules");
33614
- if ((0, import_fs19.existsSync)(cursorRulesPath)) {
33729
+ const cursorRulesPath = (0, import_path19.join)(directory, ".cursorrules");
33730
+ if ((0, import_fs20.existsSync)(cursorRulesPath)) {
33615
33731
  files.push({
33616
33732
  path: cursorRulesPath,
33617
33733
  type: "rule",
33618
- content: (0, import_fs19.readFileSync)(cursorRulesPath, "utf-8")
33734
+ content: (0, import_fs20.readFileSync)(cursorRulesPath, "utf-8")
33619
33735
  });
33620
33736
  }
33621
33737
  }
33622
33738
  if (platform5 === "claude") {
33623
- const commandsDir = (0, import_path18.join)(fullPath, "commands");
33624
- if ((0, import_fs19.existsSync)(commandsDir)) {
33625
- const commandFiles = (0, import_fs19.readdirSync)(commandsDir).filter(
33739
+ const commandsDir = (0, import_path19.join)(fullPath, "commands");
33740
+ if ((0, import_fs20.existsSync)(commandsDir)) {
33741
+ const commandFiles = (0, import_fs20.readdirSync)(commandsDir).filter(
33626
33742
  (f) => f.endsWith(".md")
33627
33743
  );
33628
33744
  for (const file of commandFiles) {
33629
- const filePath = (0, import_path18.join)(commandsDir, file);
33745
+ const filePath = (0, import_path19.join)(commandsDir, file);
33630
33746
  files.push({
33631
33747
  path: filePath,
33632
33748
  type: "command",
33633
- content: (0, import_fs19.readFileSync)(filePath, "utf-8")
33749
+ content: (0, import_fs20.readFileSync)(filePath, "utf-8")
33634
33750
  });
33635
33751
  }
33636
33752
  }
33637
- const hooksDir = (0, import_path18.join)(fullPath, "hooks");
33638
- if ((0, import_fs19.existsSync)(hooksDir)) {
33639
- const hookFiles = (0, import_fs19.readdirSync)(hooksDir).filter(
33753
+ const hooksDir = (0, import_path19.join)(fullPath, "hooks");
33754
+ if ((0, import_fs20.existsSync)(hooksDir)) {
33755
+ const hookFiles = (0, import_fs20.readdirSync)(hooksDir).filter(
33640
33756
  (f) => f.endsWith(".py") || f.endsWith(".sh")
33641
33757
  );
33642
33758
  for (const file of hookFiles) {
33643
- const filePath = (0, import_path18.join)(hooksDir, file);
33759
+ const filePath = (0, import_path19.join)(hooksDir, file);
33644
33760
  files.push({
33645
33761
  path: filePath,
33646
33762
  type: "hook",
33647
- content: (0, import_fs19.readFileSync)(filePath, "utf-8")
33763
+ content: (0, import_fs20.readFileSync)(filePath, "utf-8")
33648
33764
  });
33649
33765
  }
33650
33766
  }
@@ -33757,16 +33873,16 @@ Sync Status for ${orgName}:
33757
33873
  }
33758
33874
  }
33759
33875
  function writeCursorConfig(directory, configData, syncedFiles, syncedItems) {
33760
- const cursorDir = (0, import_path18.join)(directory, ".cursor");
33876
+ const cursorDir = (0, import_path19.join)(directory, ".cursor");
33761
33877
  if (configData.rules && configData.rules.length > 0) {
33762
- const rulesDir = (0, import_path18.join)(cursorDir, "rules");
33763
- if (!(0, import_fs19.existsSync)(rulesDir)) {
33764
- (0, import_fs19.mkdirSync)(rulesDir, { recursive: true });
33878
+ const rulesDir = (0, import_path19.join)(cursorDir, "rules");
33879
+ if (!(0, import_fs20.existsSync)(rulesDir)) {
33880
+ (0, import_fs20.mkdirSync)(rulesDir, { recursive: true });
33765
33881
  }
33766
33882
  for (const rule of configData.rules) {
33767
33883
  const fileName = rule.name.endsWith(".mdc") || rule.name.endsWith(".md") ? rule.name : `${rule.name}.mdc`;
33768
- const filePath = (0, import_path18.join)(rulesDir, fileName);
33769
- (0, import_fs19.writeFileSync)(filePath, rule.content, "utf-8");
33884
+ const filePath = (0, import_path19.join)(rulesDir, fileName);
33885
+ (0, import_fs20.writeFileSync)(filePath, rule.content, "utf-8");
33770
33886
  const relativePath = `.cursor/rules/${fileName}`;
33771
33887
  syncedFiles.push(relativePath);
33772
33888
  syncedItems.push({
@@ -33778,8 +33894,8 @@ function writeCursorConfig(directory, configData, syncedFiles, syncedItems) {
33778
33894
  }
33779
33895
  }
33780
33896
  if (configData.cursorRules?.content) {
33781
- const cursorRulesPath = (0, import_path18.join)(directory, ".cursorrules");
33782
- (0, import_fs19.writeFileSync)(cursorRulesPath, configData.cursorRules.content, "utf-8");
33897
+ const cursorRulesPath = (0, import_path19.join)(directory, ".cursorrules");
33898
+ (0, import_fs20.writeFileSync)(cursorRulesPath, configData.cursorRules.content, "utf-8");
33783
33899
  syncedFiles.push(".cursorrules");
33784
33900
  syncedItems.push({
33785
33901
  path: ".cursorrules",
@@ -33789,11 +33905,11 @@ function writeCursorConfig(directory, configData, syncedFiles, syncedItems) {
33789
33905
  });
33790
33906
  }
33791
33907
  if (configData.settings?.content) {
33792
- if (!(0, import_fs19.existsSync)(cursorDir)) {
33793
- (0, import_fs19.mkdirSync)(cursorDir, { recursive: true });
33908
+ if (!(0, import_fs20.existsSync)(cursorDir)) {
33909
+ (0, import_fs20.mkdirSync)(cursorDir, { recursive: true });
33794
33910
  }
33795
- const settingsPath = (0, import_path18.join)(cursorDir, "settings.json");
33796
- (0, import_fs19.writeFileSync)(settingsPath, configData.settings.content, "utf-8");
33911
+ const settingsPath = (0, import_path19.join)(cursorDir, "settings.json");
33912
+ (0, import_fs20.writeFileSync)(settingsPath, configData.settings.content, "utf-8");
33797
33913
  syncedFiles.push(".cursor/settings.json");
33798
33914
  syncedItems.push({
33799
33915
  path: ".cursor/settings.json",
@@ -33804,10 +33920,10 @@ function writeCursorConfig(directory, configData, syncedFiles, syncedItems) {
33804
33920
  }
33805
33921
  }
33806
33922
  function writeClaudeConfig(directory, configData, syncedFiles, syncedItems, orgName) {
33807
- const claudeDir = (0, import_path18.join)(directory, ".claude");
33923
+ const claudeDir = (0, import_path19.join)(directory, ".claude");
33808
33924
  if (configData.instructions?.content) {
33809
- const claudeMdPath = (0, import_path18.join)(directory, "CLAUDE.md");
33810
- (0, import_fs19.writeFileSync)(claudeMdPath, configData.instructions.content, "utf-8");
33925
+ const claudeMdPath = (0, import_path19.join)(directory, "CLAUDE.md");
33926
+ (0, import_fs20.writeFileSync)(claudeMdPath, configData.instructions.content, "utf-8");
33811
33927
  syncedFiles.push("CLAUDE.md");
33812
33928
  syncedItems.push({
33813
33929
  path: "CLAUDE.md",
@@ -33817,19 +33933,19 @@ function writeClaudeConfig(directory, configData, syncedFiles, syncedItems, orgN
33817
33933
  });
33818
33934
  }
33819
33935
  if (configData.commands && configData.commands.length > 0) {
33820
- const commandsDir = (0, import_path18.join)(claudeDir, "commands");
33821
- if (!(0, import_fs19.existsSync)(commandsDir)) {
33822
- (0, import_fs19.mkdirSync)(commandsDir, { recursive: true });
33936
+ const commandsDir = (0, import_path19.join)(claudeDir, "commands");
33937
+ if (!(0, import_fs20.existsSync)(commandsDir)) {
33938
+ (0, import_fs20.mkdirSync)(commandsDir, { recursive: true });
33823
33939
  }
33824
33940
  for (const cmd of configData.commands) {
33825
33941
  const pathFromName = cmd.name.replace(/:/g, "/");
33826
33942
  const fileName = pathFromName.endsWith(".md") ? pathFromName : `${pathFromName}.md`;
33827
- const filePath = (0, import_path18.join)(commandsDir, fileName);
33828
- const fileDir = (0, import_path18.dirname)(filePath);
33829
- if (!(0, import_fs19.existsSync)(fileDir)) {
33830
- (0, import_fs19.mkdirSync)(fileDir, { recursive: true });
33943
+ const filePath = (0, import_path19.join)(commandsDir, fileName);
33944
+ const fileDir = (0, import_path19.dirname)(filePath);
33945
+ if (!(0, import_fs20.existsSync)(fileDir)) {
33946
+ (0, import_fs20.mkdirSync)(fileDir, { recursive: true });
33831
33947
  }
33832
- (0, import_fs19.writeFileSync)(filePath, cmd.content, "utf-8");
33948
+ (0, import_fs20.writeFileSync)(filePath, cmd.content, "utf-8");
33833
33949
  const relativePath = `.claude/commands/${fileName}`;
33834
33950
  syncedFiles.push(relativePath);
33835
33951
  const { description, allowedTools } = parseCommandFrontmatter(cmd.content);
@@ -33844,13 +33960,13 @@ function writeClaudeConfig(directory, configData, syncedFiles, syncedItems, orgN
33844
33960
  }
33845
33961
  }
33846
33962
  if (configData.hooks && configData.hooks.length > 0) {
33847
- const hooksDir = (0, import_path18.join)(claudeDir, "hooks");
33848
- if (!(0, import_fs19.existsSync)(hooksDir)) {
33849
- (0, import_fs19.mkdirSync)(hooksDir, { recursive: true });
33963
+ const hooksDir = (0, import_path19.join)(claudeDir, "hooks");
33964
+ if (!(0, import_fs20.existsSync)(hooksDir)) {
33965
+ (0, import_fs20.mkdirSync)(hooksDir, { recursive: true });
33850
33966
  }
33851
33967
  for (const hook of configData.hooks) {
33852
- const filePath = (0, import_path18.join)(hooksDir, hook.name);
33853
- (0, import_fs19.writeFileSync)(filePath, hook.content, "utf-8");
33968
+ const filePath = (0, import_path19.join)(hooksDir, hook.name);
33969
+ (0, import_fs20.writeFileSync)(filePath, hook.content, "utf-8");
33854
33970
  const relativePath = `.claude/hooks/${hook.name}`;
33855
33971
  syncedFiles.push(relativePath);
33856
33972
  syncedItems.push({
@@ -33862,18 +33978,18 @@ function writeClaudeConfig(directory, configData, syncedFiles, syncedItems, orgN
33862
33978
  }
33863
33979
  }
33864
33980
  if (configData.settings?.content) {
33865
- if (!(0, import_fs19.existsSync)(claudeDir)) {
33866
- (0, import_fs19.mkdirSync)(claudeDir, { recursive: true });
33981
+ if (!(0, import_fs20.existsSync)(claudeDir)) {
33982
+ (0, import_fs20.mkdirSync)(claudeDir, { recursive: true });
33867
33983
  }
33868
- const settingsPath = (0, import_path18.join)(claudeDir, "settings.json");
33869
- if ((0, import_fs19.existsSync)(settingsPath)) {
33870
- const existingContent = (0, import_fs19.readFileSync)(settingsPath, "utf-8");
33984
+ const settingsPath = (0, import_path19.join)(claudeDir, "settings.json");
33985
+ if ((0, import_fs20.existsSync)(settingsPath)) {
33986
+ const existingContent = (0, import_fs20.readFileSync)(settingsPath, "utf-8");
33871
33987
  const newContent = configData.settings.content;
33872
33988
  const existingHash = calculateConfigHash(existingContent);
33873
33989
  const newHash = calculateConfigHash(newContent);
33874
33990
  if (existingHash !== newHash) {
33875
33991
  const backupPath = `${settingsPath}.bak`;
33876
- (0, import_fs19.writeFileSync)(backupPath, existingContent, "utf-8");
33992
+ (0, import_fs20.writeFileSync)(backupPath, existingContent, "utf-8");
33877
33993
  console.log(source_default.yellow("\n Settings changes detected:"));
33878
33994
  try {
33879
33995
  const existingParsed = JSON.parse(existingContent);
@@ -33894,20 +34010,20 @@ function writeClaudeConfig(directory, configData, syncedFiles, syncedItems, orgN
33894
34010
  console.log();
33895
34011
  }
33896
34012
  }
33897
- const userSettingsPath = (0, import_path18.join)((0, import_os16.homedir)(), ".claude", "settings.json");
33898
- if ((0, import_fs19.existsSync)(userSettingsPath)) {
33899
- const userContent = (0, import_fs19.readFileSync)(userSettingsPath, "utf-8");
34013
+ const userSettingsPath = (0, import_path19.join)((0, import_os17.homedir)(), ".claude", "settings.json");
34014
+ if ((0, import_fs20.existsSync)(userSettingsPath)) {
34015
+ const userContent = (0, import_fs20.readFileSync)(userSettingsPath, "utf-8");
33900
34016
  const userHash = calculateConfigHash(userContent);
33901
34017
  const orgHash = calculateConfigHash(configData.settings.content);
33902
34018
  if (userHash !== orgHash) {
33903
34019
  const userBackupPath = `${userSettingsPath}.bak`;
33904
- (0, import_fs19.writeFileSync)(userBackupPath, userContent, "utf-8");
34020
+ (0, import_fs20.writeFileSync)(userBackupPath, userContent, "utf-8");
33905
34021
  console.log(source_default.yellow(" User-level settings differ from org baseline."));
33906
34022
  console.log(source_default.dim(` Backup: ${userBackupPath}`));
33907
34023
  console.log();
33908
34024
  }
33909
34025
  }
33910
- (0, import_fs19.writeFileSync)(settingsPath, configData.settings.content, "utf-8");
34026
+ (0, import_fs20.writeFileSync)(settingsPath, configData.settings.content, "utf-8");
33911
34027
  syncedFiles.push(".claude/settings.json");
33912
34028
  syncedItems.push({
33913
34029
  path: ".claude/settings.json",
@@ -33917,19 +34033,19 @@ function writeClaudeConfig(directory, configData, syncedFiles, syncedItems, orgN
33917
34033
  });
33918
34034
  }
33919
34035
  if (configData.subagents && configData.subagents.length > 0) {
33920
- const agentsDir = (0, import_path18.join)(claudeDir, "agents");
33921
- if (!(0, import_fs19.existsSync)(agentsDir)) {
33922
- (0, import_fs19.mkdirSync)(agentsDir, { recursive: true });
34036
+ const agentsDir = (0, import_path19.join)(claudeDir, "agents");
34037
+ if (!(0, import_fs20.existsSync)(agentsDir)) {
34038
+ (0, import_fs20.mkdirSync)(agentsDir, { recursive: true });
33923
34039
  }
33924
34040
  for (const agent of configData.subagents) {
33925
34041
  const pathFromName = agent.name.replace(/:/g, "/");
33926
34042
  const fileName = pathFromName.endsWith(".md") ? pathFromName : `${pathFromName}.md`;
33927
- const filePath = (0, import_path18.join)(agentsDir, fileName);
33928
- const fileDir = (0, import_path18.dirname)(filePath);
33929
- if (!(0, import_fs19.existsSync)(fileDir)) {
33930
- (0, import_fs19.mkdirSync)(fileDir, { recursive: true });
34043
+ const filePath = (0, import_path19.join)(agentsDir, fileName);
34044
+ const fileDir = (0, import_path19.dirname)(filePath);
34045
+ if (!(0, import_fs20.existsSync)(fileDir)) {
34046
+ (0, import_fs20.mkdirSync)(fileDir, { recursive: true });
33931
34047
  }
33932
- (0, import_fs19.writeFileSync)(filePath, agent.content, "utf-8");
34048
+ (0, import_fs20.writeFileSync)(filePath, agent.content, "utf-8");
33933
34049
  const relativePath = `.claude/agents/${fileName}`;
33934
34050
  syncedFiles.push(relativePath);
33935
34051
  const { description } = parseCommandFrontmatter(agent.content);
@@ -33943,17 +34059,17 @@ function writeClaudeConfig(directory, configData, syncedFiles, syncedItems, orgN
33943
34059
  }
33944
34060
  }
33945
34061
  if (configData.skills && configData.skills.length > 0) {
33946
- const skillsDir = (0, import_path18.join)(claudeDir, "skills");
33947
- if (!(0, import_fs19.existsSync)(skillsDir)) {
33948
- (0, import_fs19.mkdirSync)(skillsDir, { recursive: true });
34062
+ const skillsDir = (0, import_path19.join)(claudeDir, "skills");
34063
+ if (!(0, import_fs20.existsSync)(skillsDir)) {
34064
+ (0, import_fs20.mkdirSync)(skillsDir, { recursive: true });
33949
34065
  }
33950
34066
  for (const skill of configData.skills) {
33951
- const skillDir = (0, import_path18.join)(skillsDir, skill.name);
33952
- if (!(0, import_fs19.existsSync)(skillDir)) {
33953
- (0, import_fs19.mkdirSync)(skillDir, { recursive: true });
34067
+ const skillDir = (0, import_path19.join)(skillsDir, skill.name);
34068
+ if (!(0, import_fs20.existsSync)(skillDir)) {
34069
+ (0, import_fs20.mkdirSync)(skillDir, { recursive: true });
33954
34070
  }
33955
- const skillPath = (0, import_path18.join)(skillDir, "SKILL.md");
33956
- (0, import_fs19.writeFileSync)(skillPath, skill.content, "utf-8");
34071
+ const skillPath = (0, import_path19.join)(skillDir, "SKILL.md");
34072
+ (0, import_fs20.writeFileSync)(skillPath, skill.content, "utf-8");
33957
34073
  const relativePath = `.claude/skills/${skill.name}/SKILL.md`;
33958
34074
  syncedFiles.push(relativePath);
33959
34075
  syncedItems.push({
@@ -33966,14 +34082,14 @@ function writeClaudeConfig(directory, configData, syncedFiles, syncedItems, orgN
33966
34082
  }
33967
34083
  }
33968
34084
  if (configData.rules && configData.rules.length > 0) {
33969
- const rulesDir = (0, import_path18.join)(claudeDir, "rules");
33970
- if (!(0, import_fs19.existsSync)(rulesDir)) {
33971
- (0, import_fs19.mkdirSync)(rulesDir, { recursive: true });
34085
+ const rulesDir = (0, import_path19.join)(claudeDir, "rules");
34086
+ if (!(0, import_fs20.existsSync)(rulesDir)) {
34087
+ (0, import_fs20.mkdirSync)(rulesDir, { recursive: true });
33972
34088
  }
33973
34089
  for (const rule of configData.rules) {
33974
34090
  const fileName = rule.name.endsWith(".md") ? rule.name : `${rule.name}.md`;
33975
- const filePath = (0, import_path18.join)(rulesDir, fileName);
33976
- (0, import_fs19.writeFileSync)(filePath, rule.content, "utf-8");
34091
+ const filePath = (0, import_path19.join)(rulesDir, fileName);
34092
+ (0, import_fs20.writeFileSync)(filePath, rule.content, "utf-8");
33977
34093
  const relativePath = `.claude/rules/${fileName}`;
33978
34094
  syncedFiles.push(relativePath);
33979
34095
  syncedItems.push({
@@ -33984,79 +34100,25 @@ function writeClaudeConfig(directory, configData, syncedFiles, syncedItems, orgN
33984
34100
  });
33985
34101
  }
33986
34102
  }
33987
- writeMcpConfig(directory, configData.mcp?.content || "{}", syncedFiles, syncedItems, orgName);
33988
- }
33989
- function expandEnvVarsInValue(value) {
33990
- if (typeof value === "string") {
33991
- return value.replace(/\$HOME/g, (0, import_os16.homedir)()).replace(/~/g, (0, import_os16.homedir)());
33992
- }
33993
- if (Array.isArray(value)) {
33994
- return value.map(expandEnvVarsInValue);
33995
- }
33996
- if (value && typeof value === "object") {
33997
- const result = {};
33998
- for (const [k, v] of Object.entries(value)) {
33999
- result[k] = expandEnvVarsInValue(v);
34000
- }
34001
- return result;
34002
- }
34003
- return value;
34004
- }
34005
- function writeMcpConfig(directory, mcpContent, syncedFiles, syncedItems, orgName) {
34006
- const mcpPath = (0, import_path18.join)(directory, ".mcp.json");
34007
- let merged = { mcpServers: {} };
34008
- try {
34009
- const existing = JSON.parse((0, import_fs19.readFileSync)(mcpPath, "utf-8"));
34010
- merged = { ...existing, mcpServers: { ...existing.mcpServers } };
34011
- } catch {
34012
- }
34013
- try {
34014
- const approved = JSON.parse(mcpContent);
34015
- if (approved.mcpServers) {
34016
- for (const [name, config] of Object.entries(approved.mcpServers)) {
34017
- merged.mcpServers[name] = config;
34018
- }
34019
- }
34020
- } catch (e) {
34021
- console.error("Invalid MCP config content:", e);
34022
- return;
34023
- }
34024
- merged.mcpServers["gal"] = {
34025
- type: "http",
34026
- transport: "http",
34027
- url: "https://api.gal.run/mcp",
34028
- ...orgName ? { headers: { "X-Gal-Organization": orgName } } : {}
34029
- };
34030
- for (const [name, config] of Object.entries(merged.mcpServers)) {
34031
- merged.mcpServers[name] = expandEnvVarsInValue(config);
34032
- }
34033
- (0, import_fs19.writeFileSync)(mcpPath, JSON.stringify(merged, null, 2) + "\n", "utf-8");
34034
- syncedFiles.push(".mcp.json");
34035
- syncedItems.push({
34036
- path: ".mcp.json",
34037
- type: "mcp",
34038
- name: ".mcp.json",
34039
- platform: "claude"
34040
- });
34041
34103
  }
34042
34104
  function writeCodexConfig(directory, configData, syncedFiles, syncedItems) {
34043
- const codexDir = (0, import_path18.join)(directory, ".codex");
34044
- const codexDirExists = (0, import_fs19.existsSync)(codexDir);
34105
+ const codexDir = (0, import_path19.join)(directory, ".codex");
34106
+ const codexDirExists = (0, import_fs20.existsSync)(codexDir);
34045
34107
  if (!codexDirExists) {
34046
34108
  return;
34047
34109
  }
34048
34110
  if (configData.skills && configData.skills.length > 0) {
34049
- const skillsDir = (0, import_path18.join)(codexDir, "skills");
34050
- if (!(0, import_fs19.existsSync)(skillsDir)) {
34051
- (0, import_fs19.mkdirSync)(skillsDir, { recursive: true });
34111
+ const skillsDir = (0, import_path19.join)(codexDir, "skills");
34112
+ if (!(0, import_fs20.existsSync)(skillsDir)) {
34113
+ (0, import_fs20.mkdirSync)(skillsDir, { recursive: true });
34052
34114
  }
34053
34115
  for (const skill of configData.skills) {
34054
- const skillDir = (0, import_path18.join)(skillsDir, skill.name);
34055
- if (!(0, import_fs19.existsSync)(skillDir)) {
34056
- (0, import_fs19.mkdirSync)(skillDir, { recursive: true });
34116
+ const skillDir = (0, import_path19.join)(skillsDir, skill.name);
34117
+ if (!(0, import_fs20.existsSync)(skillDir)) {
34118
+ (0, import_fs20.mkdirSync)(skillDir, { recursive: true });
34057
34119
  }
34058
- const skillPath = (0, import_path18.join)(skillDir, "SKILL.md");
34059
- (0, import_fs19.writeFileSync)(skillPath, skill.content, "utf-8");
34120
+ const skillPath = (0, import_path19.join)(skillDir, "SKILL.md");
34121
+ (0, import_fs20.writeFileSync)(skillPath, skill.content, "utf-8");
34060
34122
  const relativePath = `.codex/skills/${skill.name}/SKILL.md`;
34061
34123
  syncedFiles.push(relativePath);
34062
34124
  syncedItems.push({
@@ -34068,8 +34130,8 @@ function writeCodexConfig(directory, configData, syncedFiles, syncedItems) {
34068
34130
  }
34069
34131
  }
34070
34132
  if (configData.settings?.content) {
34071
- const settingsPath = (0, import_path18.join)(codexDir, "settings.json");
34072
- (0, import_fs19.writeFileSync)(settingsPath, configData.settings.content, "utf-8");
34133
+ const settingsPath = (0, import_path19.join)(codexDir, "settings.json");
34134
+ (0, import_fs20.writeFileSync)(settingsPath, configData.settings.content, "utf-8");
34073
34135
  syncedFiles.push(".codex/settings.json");
34074
34136
  syncedItems.push({
34075
34137
  path: ".codex/settings.json",
@@ -34085,15 +34147,15 @@ function codexPromptFileNameFromCommand(commandName) {
34085
34147
  }
34086
34148
  function writeCodexPrompts(commands) {
34087
34149
  if (!commands || commands.length === 0) return 0;
34088
- const promptsDir = (0, import_path18.join)((0, import_os16.homedir)(), ".codex", "prompts");
34089
- if (!(0, import_fs19.existsSync)(promptsDir)) {
34090
- (0, import_fs19.mkdirSync)(promptsDir, { recursive: true });
34150
+ const promptsDir = (0, import_path19.join)((0, import_os17.homedir)(), ".codex", "prompts");
34151
+ if (!(0, import_fs20.existsSync)(promptsDir)) {
34152
+ (0, import_fs20.mkdirSync)(promptsDir, { recursive: true });
34091
34153
  }
34092
34154
  let written = 0;
34093
34155
  for (const command of commands) {
34094
34156
  const fileName = codexPromptFileNameFromCommand(command.name);
34095
- const filePath = (0, import_path18.join)(promptsDir, fileName);
34096
- (0, import_fs19.writeFileSync)(filePath, command.content, "utf-8");
34157
+ const filePath = (0, import_path19.join)(promptsDir, fileName);
34158
+ (0, import_fs20.writeFileSync)(filePath, command.content, "utf-8");
34097
34159
  written += 1;
34098
34160
  }
34099
34161
  return written;
@@ -34125,119 +34187,119 @@ function writeGeminiCommandsAndSkills(directory, configData) {
34125
34187
  let commandsWritten = 0;
34126
34188
  let skillsWritten = 0;
34127
34189
  if (configData.commands && configData.commands.length > 0) {
34128
- const commandsDir = (0, import_path18.join)(directory, GEMINI_COMMANDS_DIR);
34129
- if (!(0, import_fs19.existsSync)(commandsDir)) {
34130
- (0, import_fs19.mkdirSync)(commandsDir, { recursive: true });
34190
+ const commandsDir = (0, import_path19.join)(directory, GEMINI_COMMANDS_DIR);
34191
+ if (!(0, import_fs20.existsSync)(commandsDir)) {
34192
+ (0, import_fs20.mkdirSync)(commandsDir, { recursive: true });
34131
34193
  }
34132
34194
  for (const cmd of configData.commands) {
34133
34195
  const pathFromName = cmd.name.replace(/:/g, "/");
34134
- const filePath = (0, import_path18.join)(commandsDir, `${pathFromName}.toml`);
34135
- const fileDir = (0, import_path18.dirname)(filePath);
34136
- if (!(0, import_fs19.existsSync)(fileDir)) {
34137
- (0, import_fs19.mkdirSync)(fileDir, { recursive: true });
34196
+ const filePath = (0, import_path19.join)(commandsDir, `${pathFromName}.toml`);
34197
+ const fileDir = (0, import_path19.dirname)(filePath);
34198
+ if (!(0, import_fs20.existsSync)(fileDir)) {
34199
+ (0, import_fs20.mkdirSync)(fileDir, { recursive: true });
34138
34200
  }
34139
34201
  const description = extractDescription2(cmd.content);
34140
34202
  const toml = buildGeminiCommandToml(cmd.name, description, cmd.content);
34141
- (0, import_fs19.writeFileSync)(filePath, toml, "utf-8");
34203
+ (0, import_fs20.writeFileSync)(filePath, toml, "utf-8");
34142
34204
  commandsWritten += 1;
34143
34205
  }
34144
34206
  }
34145
34207
  if (configData.skills && configData.skills.length > 0) {
34146
- const skillsDir = (0, import_path18.join)(directory, GEMINI_SKILLS_DIR);
34147
- if (!(0, import_fs19.existsSync)(skillsDir)) {
34148
- (0, import_fs19.mkdirSync)(skillsDir, { recursive: true });
34208
+ const skillsDir = (0, import_path19.join)(directory, GEMINI_SKILLS_DIR);
34209
+ if (!(0, import_fs20.existsSync)(skillsDir)) {
34210
+ (0, import_fs20.mkdirSync)(skillsDir, { recursive: true });
34149
34211
  }
34150
34212
  for (const skill of configData.skills) {
34151
- const skillDir = (0, import_path18.join)(skillsDir, skill.name);
34152
- if (!(0, import_fs19.existsSync)(skillDir)) {
34153
- (0, import_fs19.mkdirSync)(skillDir, { recursive: true });
34213
+ const skillDir = (0, import_path19.join)(skillsDir, skill.name);
34214
+ if (!(0, import_fs20.existsSync)(skillDir)) {
34215
+ (0, import_fs20.mkdirSync)(skillDir, { recursive: true });
34154
34216
  }
34155
- const skillPath = (0, import_path18.join)(skillDir, "SKILL.md");
34156
- (0, import_fs19.writeFileSync)(skillPath, skill.content, "utf-8");
34217
+ const skillPath = (0, import_path19.join)(skillDir, "SKILL.md");
34218
+ (0, import_fs20.writeFileSync)(skillPath, skill.content, "utf-8");
34157
34219
  skillsWritten += 1;
34158
34220
  }
34159
34221
  }
34160
34222
  return { commandsWritten, skillsWritten };
34161
34223
  }
34162
34224
  function writeApprovedClaudeConfig(directory, configData) {
34163
- const approvedRoot = (0, import_path18.join)(directory, ".gal", "approved", "claude");
34164
- const approvedClaudeDir = (0, import_path18.join)(approvedRoot, ".claude");
34165
- if (!(0, import_fs19.existsSync)(approvedClaudeDir)) {
34166
- (0, import_fs19.mkdirSync)(approvedClaudeDir, { recursive: true });
34225
+ const approvedRoot = (0, import_path19.join)(directory, ".gal", "approved", "claude");
34226
+ const approvedClaudeDir = (0, import_path19.join)(approvedRoot, ".claude");
34227
+ if (!(0, import_fs20.existsSync)(approvedClaudeDir)) {
34228
+ (0, import_fs20.mkdirSync)(approvedClaudeDir, { recursive: true });
34167
34229
  }
34168
34230
  if (configData.instructions?.content) {
34169
- const claudeMdPath = (0, import_path18.join)(approvedRoot, "CLAUDE.md");
34170
- (0, import_fs19.writeFileSync)(claudeMdPath, configData.instructions.content, "utf-8");
34231
+ const claudeMdPath = (0, import_path19.join)(approvedRoot, "CLAUDE.md");
34232
+ (0, import_fs20.writeFileSync)(claudeMdPath, configData.instructions.content, "utf-8");
34171
34233
  }
34172
34234
  if (configData.commands && configData.commands.length > 0) {
34173
- const commandsDir = (0, import_path18.join)(approvedClaudeDir, "commands");
34174
- if (!(0, import_fs19.existsSync)(commandsDir)) {
34175
- (0, import_fs19.mkdirSync)(commandsDir, { recursive: true });
34235
+ const commandsDir = (0, import_path19.join)(approvedClaudeDir, "commands");
34236
+ if (!(0, import_fs20.existsSync)(commandsDir)) {
34237
+ (0, import_fs20.mkdirSync)(commandsDir, { recursive: true });
34176
34238
  }
34177
34239
  for (const cmd of configData.commands) {
34178
34240
  const pathFromName = cmd.name.replace(/:/g, "/");
34179
34241
  const fileName = pathFromName.endsWith(".md") ? pathFromName : `${pathFromName}.md`;
34180
- const filePath = (0, import_path18.join)(commandsDir, fileName);
34181
- const fileDir = (0, import_path18.dirname)(filePath);
34182
- if (!(0, import_fs19.existsSync)(fileDir)) {
34183
- (0, import_fs19.mkdirSync)(fileDir, { recursive: true });
34242
+ const filePath = (0, import_path19.join)(commandsDir, fileName);
34243
+ const fileDir = (0, import_path19.dirname)(filePath);
34244
+ if (!(0, import_fs20.existsSync)(fileDir)) {
34245
+ (0, import_fs20.mkdirSync)(fileDir, { recursive: true });
34184
34246
  }
34185
- (0, import_fs19.writeFileSync)(filePath, cmd.content, "utf-8");
34247
+ (0, import_fs20.writeFileSync)(filePath, cmd.content, "utf-8");
34186
34248
  }
34187
34249
  }
34188
34250
  if (configData.hooks && configData.hooks.length > 0) {
34189
- const hooksDir = (0, import_path18.join)(approvedClaudeDir, "hooks");
34190
- if (!(0, import_fs19.existsSync)(hooksDir)) {
34191
- (0, import_fs19.mkdirSync)(hooksDir, { recursive: true });
34251
+ const hooksDir = (0, import_path19.join)(approvedClaudeDir, "hooks");
34252
+ if (!(0, import_fs20.existsSync)(hooksDir)) {
34253
+ (0, import_fs20.mkdirSync)(hooksDir, { recursive: true });
34192
34254
  }
34193
34255
  for (const hook of configData.hooks) {
34194
- const filePath = (0, import_path18.join)(hooksDir, hook.name);
34195
- (0, import_fs19.writeFileSync)(filePath, hook.content, "utf-8");
34256
+ const filePath = (0, import_path19.join)(hooksDir, hook.name);
34257
+ (0, import_fs20.writeFileSync)(filePath, hook.content, "utf-8");
34196
34258
  }
34197
34259
  }
34198
34260
  if (configData.settings?.content) {
34199
- const settingsPath = (0, import_path18.join)(approvedClaudeDir, "settings.json");
34200
- (0, import_fs19.writeFileSync)(settingsPath, configData.settings.content, "utf-8");
34261
+ const settingsPath = (0, import_path19.join)(approvedClaudeDir, "settings.json");
34262
+ (0, import_fs20.writeFileSync)(settingsPath, configData.settings.content, "utf-8");
34201
34263
  }
34202
34264
  if (configData.subagents && configData.subagents.length > 0) {
34203
- const agentsDir = (0, import_path18.join)(approvedClaudeDir, "agents");
34204
- if (!(0, import_fs19.existsSync)(agentsDir)) {
34205
- (0, import_fs19.mkdirSync)(agentsDir, { recursive: true });
34265
+ const agentsDir = (0, import_path19.join)(approvedClaudeDir, "agents");
34266
+ if (!(0, import_fs20.existsSync)(agentsDir)) {
34267
+ (0, import_fs20.mkdirSync)(agentsDir, { recursive: true });
34206
34268
  }
34207
34269
  for (const agent of configData.subagents) {
34208
34270
  const pathFromName = agent.name.replace(/:/g, "/");
34209
34271
  const fileName = pathFromName.endsWith(".md") ? pathFromName : `${pathFromName}.md`;
34210
- const filePath = (0, import_path18.join)(agentsDir, fileName);
34211
- const fileDir = (0, import_path18.dirname)(filePath);
34212
- if (!(0, import_fs19.existsSync)(fileDir)) {
34213
- (0, import_fs19.mkdirSync)(fileDir, { recursive: true });
34272
+ const filePath = (0, import_path19.join)(agentsDir, fileName);
34273
+ const fileDir = (0, import_path19.dirname)(filePath);
34274
+ if (!(0, import_fs20.existsSync)(fileDir)) {
34275
+ (0, import_fs20.mkdirSync)(fileDir, { recursive: true });
34214
34276
  }
34215
- (0, import_fs19.writeFileSync)(filePath, agent.content, "utf-8");
34277
+ (0, import_fs20.writeFileSync)(filePath, agent.content, "utf-8");
34216
34278
  }
34217
34279
  }
34218
34280
  if (configData.skills && configData.skills.length > 0) {
34219
- const skillsDir = (0, import_path18.join)(approvedClaudeDir, "skills");
34220
- if (!(0, import_fs19.existsSync)(skillsDir)) {
34221
- (0, import_fs19.mkdirSync)(skillsDir, { recursive: true });
34281
+ const skillsDir = (0, import_path19.join)(approvedClaudeDir, "skills");
34282
+ if (!(0, import_fs20.existsSync)(skillsDir)) {
34283
+ (0, import_fs20.mkdirSync)(skillsDir, { recursive: true });
34222
34284
  }
34223
34285
  for (const skill of configData.skills) {
34224
- const skillDir = (0, import_path18.join)(skillsDir, skill.name);
34225
- if (!(0, import_fs19.existsSync)(skillDir)) {
34226
- (0, import_fs19.mkdirSync)(skillDir, { recursive: true });
34286
+ const skillDir = (0, import_path19.join)(skillsDir, skill.name);
34287
+ if (!(0, import_fs20.existsSync)(skillDir)) {
34288
+ (0, import_fs20.mkdirSync)(skillDir, { recursive: true });
34227
34289
  }
34228
- const skillPath = (0, import_path18.join)(skillDir, "SKILL.md");
34229
- (0, import_fs19.writeFileSync)(skillPath, skill.content, "utf-8");
34290
+ const skillPath = (0, import_path19.join)(skillDir, "SKILL.md");
34291
+ (0, import_fs20.writeFileSync)(skillPath, skill.content, "utf-8");
34230
34292
  }
34231
34293
  }
34232
34294
  if (configData.rules && configData.rules.length > 0) {
34233
- const rulesDir = (0, import_path18.join)(approvedClaudeDir, "rules");
34234
- if (!(0, import_fs19.existsSync)(rulesDir)) {
34235
- (0, import_fs19.mkdirSync)(rulesDir, { recursive: true });
34295
+ const rulesDir = (0, import_path19.join)(approvedClaudeDir, "rules");
34296
+ if (!(0, import_fs20.existsSync)(rulesDir)) {
34297
+ (0, import_fs20.mkdirSync)(rulesDir, { recursive: true });
34236
34298
  }
34237
34299
  for (const rule of configData.rules) {
34238
34300
  const fileName = rule.name.endsWith(".md") ? rule.name : `${rule.name}.md`;
34239
- const filePath = (0, import_path18.join)(rulesDir, fileName);
34240
- (0, import_fs19.writeFileSync)(filePath, rule.content, "utf-8");
34301
+ const filePath = (0, import_path19.join)(rulesDir, fileName);
34302
+ (0, import_fs20.writeFileSync)(filePath, rule.content, "utf-8");
34241
34303
  }
34242
34304
  }
34243
34305
  }
@@ -34403,6 +34465,7 @@ async function pullApprovedConfig(configRepo, authRepo, orgName, directory, plat
34403
34465
  hooks: approvedConfig.hooks,
34404
34466
  settings: approvedConfig.settings,
34405
34467
  cursorRules: approvedConfig.cursorRules,
34468
+ mcp: approvedConfig.mcp ? { content: approvedConfig.mcp.content, hash: approvedConfig.mcp.hash } : void 0,
34406
34469
  copilotInstructions: approvedConfig.copilotInstructions,
34407
34470
  copilotPathInstructions: approvedConfig.copilotPathInstructions?.map((item) => ({
34408
34471
  name: item.name,
@@ -34513,20 +34576,20 @@ async function pullApprovedConfig(configRepo, authRepo, orgName, directory, plat
34513
34576
  } else {
34514
34577
  if (configData.configContent) {
34515
34578
  const platformDir = getPlatformDirectory(platform5);
34516
- const configPath = (0, import_path18.join)(directory, platformDir);
34517
- if (!(0, import_fs19.existsSync)(configPath)) {
34518
- (0, import_fs19.mkdirSync)(configPath, { recursive: true });
34579
+ const configPath = (0, import_path19.join)(directory, platformDir);
34580
+ if (!(0, import_fs20.existsSync)(configPath)) {
34581
+ (0, import_fs20.mkdirSync)(configPath, { recursive: true });
34519
34582
  }
34520
34583
  try {
34521
34584
  const parsedContent = JSON.parse(configData.configContent);
34522
34585
  for (const [filePath, content] of Object.entries(parsedContent)) {
34523
- const fullPath = (0, import_path18.join)(configPath, filePath);
34524
- const dir = (0, import_path18.dirname)(fullPath);
34525
- if (!(0, import_fs19.existsSync)(dir)) {
34526
- (0, import_fs19.mkdirSync)(dir, { recursive: true });
34586
+ const fullPath = (0, import_path19.join)(configPath, filePath);
34587
+ const dir = (0, import_path19.dirname)(fullPath);
34588
+ if (!(0, import_fs20.existsSync)(dir)) {
34589
+ (0, import_fs20.mkdirSync)(dir, { recursive: true });
34527
34590
  }
34528
- (0, import_fs19.writeFileSync)(fullPath, content);
34529
- platformFiles.push((0, import_path18.join)(platformDir, filePath));
34591
+ (0, import_fs20.writeFileSync)(fullPath, content);
34592
+ platformFiles.push((0, import_path19.join)(platformDir, filePath));
34530
34593
  platformItems.push({
34531
34594
  path: filePath,
34532
34595
  type: getItemType(filePath),
@@ -34535,9 +34598,9 @@ async function pullApprovedConfig(configRepo, authRepo, orgName, directory, plat
34535
34598
  });
34536
34599
  }
34537
34600
  } catch {
34538
- const singlePath = (0, import_path18.join)(configPath, "approved-config.json");
34539
- (0, import_fs19.writeFileSync)(singlePath, configData.configContent);
34540
- platformFiles.push((0, import_path18.join)(platformDir, "approved-config.json"));
34601
+ const singlePath = (0, import_path19.join)(configPath, "approved-config.json");
34602
+ (0, import_fs20.writeFileSync)(singlePath, configData.configContent);
34603
+ platformFiles.push((0, import_path19.join)(platformDir, "approved-config.json"));
34541
34604
  }
34542
34605
  }
34543
34606
  }
@@ -34557,6 +34620,34 @@ async function pullApprovedConfig(configRepo, authRepo, orgName, directory, plat
34557
34620
  platformSpinner?.fail(source_default.red(` ${platform5}: Failed - ${error2 instanceof Error ? error2.message : String(error2)}`));
34558
34621
  }
34559
34622
  }
34623
+ {
34624
+ const mcpSource = configsToSync.find((c) => c.platform === "claude") || configsToSync[0];
34625
+ const mcpContent = mcpSource?.mcp?.content;
34626
+ const mcpSpinner = isFullOutput ? ora(" mcp: Syncing MCP server configs...").start() : null;
34627
+ try {
34628
+ const mcpResult = syncMcpConfig(directory, mcpContent || void 0, orgName);
34629
+ allSyncedFiles.push(".mcp.json");
34630
+ allSyncedItems.push({
34631
+ path: ".mcp.json",
34632
+ type: "mcp",
34633
+ name: ".mcp.json",
34634
+ platform: "claude"
34635
+ // Track as claude for backward compat
34636
+ });
34637
+ totalFilesWritten++;
34638
+ const parts = [];
34639
+ if (mcpResult.orgServersApplied > 0) {
34640
+ parts.push(`${mcpResult.orgServersApplied} org server(s)`);
34641
+ }
34642
+ if (mcpResult.preservedUserServers.length > 0) {
34643
+ parts.push(`${mcpResult.preservedUserServers.length} user server(s) preserved`);
34644
+ }
34645
+ parts.push("GAL hosted server included");
34646
+ mcpSpinner?.succeed(source_default.green(` mcp: ${parts.join(", ")}`));
34647
+ } catch (error2) {
34648
+ mcpSpinner?.fail(source_default.red(` mcp: Failed - ${error2 instanceof Error ? error2.message : String(error2)}`));
34649
+ }
34650
+ }
34560
34651
  const claudeApprovedConfig = configsToSync.find((c) => c.platform === "claude");
34561
34652
  const platformsToSyncList = configsToSync.map((c) => c.platform);
34562
34653
  let claudeConfigData;
@@ -34634,16 +34725,16 @@ async function pullApprovedConfig(configRepo, authRepo, orgName, directory, plat
34634
34725
  }
34635
34726
  } catch {
34636
34727
  }
34637
- const existingAgentsMdPath = (0, import_path18.join)(directory, "AGENTS.md");
34728
+ const existingAgentsMdPath = (0, import_path19.join)(directory, "AGENTS.md");
34638
34729
  let existingDocsIndex;
34639
- if ((0, import_fs19.existsSync)(existingAgentsMdPath)) {
34640
- const existingContent = (0, import_fs19.readFileSync)(existingAgentsMdPath, "utf-8");
34730
+ if ((0, import_fs20.existsSync)(existingAgentsMdPath)) {
34731
+ const existingContent = (0, import_fs20.readFileSync)(existingAgentsMdPath, "utf-8");
34641
34732
  const dispatchMarker = "|@section:background-dispatch";
34642
34733
  const markerIndex = existingContent.indexOf(dispatchMarker);
34643
34734
  existingDocsIndex = markerIndex >= 0 ? existingContent.substring(0, markerIndex).trim() : existingContent.trim();
34644
34735
  }
34645
34736
  const agentsMdContent = generateAgentsMd(existingDocsIndex, dispatchRules);
34646
- (0, import_fs19.writeFileSync)(existingAgentsMdPath, agentsMdContent, "utf-8");
34737
+ (0, import_fs20.writeFileSync)(existingAgentsMdPath, agentsMdContent, "utf-8");
34647
34738
  allSyncedFiles.push("AGENTS.md");
34648
34739
  allSyncedItems.push({
34649
34740
  path: "AGENTS.md",
@@ -34657,11 +34748,11 @@ async function pullApprovedConfig(configRepo, authRepo, orgName, directory, plat
34657
34748
  console.log(source_default.dim(` Written: AGENTS.md (universal cross-platform)`));
34658
34749
  }
34659
34750
  if (dispatchRules) {
34660
- const galDir = (0, import_path18.join)(directory, ".gal");
34661
- if (!(0, import_fs19.existsSync)(galDir)) {
34662
- (0, import_fs19.mkdirSync)(galDir, { recursive: true });
34751
+ const galDir = (0, import_path19.join)(directory, ".gal");
34752
+ if (!(0, import_fs20.existsSync)(galDir)) {
34753
+ (0, import_fs20.mkdirSync)(galDir, { recursive: true });
34663
34754
  }
34664
- (0, import_fs19.writeFileSync)((0, import_path18.join)(galDir, "dispatch-rules.json"), JSON.stringify(dispatchRules), "utf-8");
34755
+ (0, import_fs20.writeFileSync)((0, import_path19.join)(galDir, "dispatch-rules.json"), JSON.stringify(dispatchRules), "utf-8");
34665
34756
  if (isFullOutput) {
34666
34757
  console.log(source_default.dim(` Written: .gal/dispatch-rules.json (hook cache)`));
34667
34758
  }
@@ -34864,12 +34955,12 @@ async function pullPersonalRepoConfig(authRepo, repoName, directory) {
34864
34955
  const syncedItems = [];
34865
34956
  for (const config of configs) {
34866
34957
  const relativePath = config.path.replace(/^\/+/, "");
34867
- const fullPath = (0, import_path18.join)(directory, relativePath);
34868
- const dir = (0, import_path18.dirname)(fullPath);
34869
- if (!(0, import_fs19.existsSync)(dir)) {
34870
- (0, import_fs19.mkdirSync)(dir, { recursive: true });
34958
+ const fullPath = (0, import_path19.join)(directory, relativePath);
34959
+ const dir = (0, import_path19.dirname)(fullPath);
34960
+ if (!(0, import_fs20.existsSync)(dir)) {
34961
+ (0, import_fs20.mkdirSync)(dir, { recursive: true });
34871
34962
  }
34872
- (0, import_fs19.writeFileSync)(fullPath, config.content);
34963
+ (0, import_fs20.writeFileSync)(fullPath, config.content);
34873
34964
  syncedFiles.push(relativePath);
34874
34965
  const itemType = getItemType(relativePath);
34875
34966
  const itemName = getItemName(relativePath);
@@ -34919,20 +35010,20 @@ async function pullPersonalApprovedConfig(authRepo, approvedConfig, directory) {
34919
35010
  }
34920
35011
  const configData = JSON.parse(approvedConfig.configContent);
34921
35012
  const platformDir = ".claude";
34922
- const configPath = (0, import_path18.join)(directory, platformDir);
34923
- if (!(0, import_fs19.existsSync)(configPath)) {
34924
- (0, import_fs19.mkdirSync)(configPath, { recursive: true });
35013
+ const configPath = (0, import_path19.join)(directory, platformDir);
35014
+ if (!(0, import_fs20.existsSync)(configPath)) {
35015
+ (0, import_fs20.mkdirSync)(configPath, { recursive: true });
34925
35016
  }
34926
35017
  const syncedFiles = [];
34927
35018
  const syncedItems = [];
34928
35019
  for (const [filePath, content] of Object.entries(configData)) {
34929
- const fullPath = (0, import_path18.join)(configPath, filePath);
34930
- const dir = (0, import_path18.dirname)(fullPath);
34931
- if (!(0, import_fs19.existsSync)(dir)) {
34932
- (0, import_fs19.mkdirSync)(dir, { recursive: true });
35020
+ const fullPath = (0, import_path19.join)(configPath, filePath);
35021
+ const dir = (0, import_path19.dirname)(fullPath);
35022
+ if (!(0, import_fs20.existsSync)(dir)) {
35023
+ (0, import_fs20.mkdirSync)(dir, { recursive: true });
34933
35024
  }
34934
- (0, import_fs19.writeFileSync)(fullPath, content);
34935
- const relativePath = (0, import_path18.join)(platformDir, filePath);
35025
+ (0, import_fs20.writeFileSync)(fullPath, content);
35026
+ const relativePath = (0, import_path19.join)(platformDir, filePath);
34936
35027
  syncedFiles.push(relativePath);
34937
35028
  const itemType = getItemType(filePath);
34938
35029
  const itemName = getItemName(filePath);
@@ -34992,18 +35083,18 @@ async function checkApprovedConfig(configRepo, orgName, directory, platformFilte
34992
35083
  const platformDir = getPlatformDirectory(platform5);
34993
35084
  if (approvedConfig.instructions?.content) {
34994
35085
  const relativePath = "CLAUDE.md";
34995
- const fullPath = (0, import_path18.join)(directory, relativePath);
35086
+ const fullPath = (0, import_path19.join)(directory, relativePath);
34996
35087
  result.expectedFiles.push(relativePath);
34997
- if (!(0, import_fs19.existsSync)(fullPath)) {
35088
+ if (!(0, import_fs20.existsSync)(fullPath)) {
34998
35089
  result.missingFiles.push(relativePath);
34999
35090
  result.inSync = false;
35000
35091
  }
35001
35092
  }
35002
35093
  if (approvedConfig.settings?.content) {
35003
- const relativePath = (0, import_path18.join)(platformDir, "settings.json");
35004
- const fullPath = (0, import_path18.join)(directory, relativePath);
35094
+ const relativePath = (0, import_path19.join)(platformDir, "settings.json");
35095
+ const fullPath = (0, import_path19.join)(directory, relativePath);
35005
35096
  result.expectedFiles.push(relativePath);
35006
- if (!(0, import_fs19.existsSync)(fullPath)) {
35097
+ if (!(0, import_fs20.existsSync)(fullPath)) {
35007
35098
  result.missingFiles.push(relativePath);
35008
35099
  result.inSync = false;
35009
35100
  }
@@ -35012,10 +35103,10 @@ async function checkApprovedConfig(configRepo, orgName, directory, platformFilte
35012
35103
  for (const cmd of approvedConfig.commands) {
35013
35104
  const pathFromName = cmd.name.replace(/:/g, "/");
35014
35105
  const fileName = pathFromName.endsWith(".md") ? pathFromName : `${pathFromName}.md`;
35015
- const relativePath = (0, import_path18.join)(platformDir, "commands", fileName);
35016
- const fullPath = (0, import_path18.join)(directory, relativePath);
35106
+ const relativePath = (0, import_path19.join)(platformDir, "commands", fileName);
35107
+ const fullPath = (0, import_path19.join)(directory, relativePath);
35017
35108
  result.expectedFiles.push(relativePath);
35018
- if (!(0, import_fs19.existsSync)(fullPath)) {
35109
+ if (!(0, import_fs20.existsSync)(fullPath)) {
35019
35110
  result.missingFiles.push(relativePath);
35020
35111
  result.inSync = false;
35021
35112
  }
@@ -35024,10 +35115,10 @@ async function checkApprovedConfig(configRepo, orgName, directory, platformFilte
35024
35115
  if (approvedConfig.rules && approvedConfig.rules.length > 0) {
35025
35116
  for (const rule of approvedConfig.rules) {
35026
35117
  const fileName = rule.name.endsWith(".md") ? rule.name : `${rule.name}.md`;
35027
- const relativePath = (0, import_path18.join)(platformDir, "rules", fileName);
35028
- const fullPath = (0, import_path18.join)(directory, relativePath);
35118
+ const relativePath = (0, import_path19.join)(platformDir, "rules", fileName);
35119
+ const fullPath = (0, import_path19.join)(directory, relativePath);
35029
35120
  result.expectedFiles.push(relativePath);
35030
- if (!(0, import_fs19.existsSync)(fullPath)) {
35121
+ if (!(0, import_fs20.existsSync)(fullPath)) {
35031
35122
  result.missingFiles.push(relativePath);
35032
35123
  result.inSync = false;
35033
35124
  }
@@ -35038,7 +35129,7 @@ async function checkApprovedConfig(configRepo, orgName, directory, platformFilte
35038
35129
  }
35039
35130
  console.log(JSON.stringify(result));
35040
35131
  }
35041
- var import_fs19, import_path18, import_os16, import_crypto6, cliVersion4, defaultApiUrl4, GAL_CLI_CURSOR_RULES_VERSION, GAL_CLI_CURSOR_RULES, CODEX_PROMPT_PREFIX, GEMINI_COMMANDS_DIR, GEMINI_SKILLS_DIR;
35132
+ var import_fs20, import_path19, import_os17, import_crypto6, cliVersion4, defaultApiUrl4, GAL_CLI_CURSOR_RULES_VERSION, GAL_CLI_CURSOR_RULES, CODEX_PROMPT_PREFIX, GEMINI_COMMANDS_DIR, GEMINI_SKILLS_DIR;
35042
35133
  var init_sync = __esm({
35043
35134
  "src/commands/sync.ts"() {
35044
35135
  "use strict";
@@ -35048,9 +35139,9 @@ var init_sync = __esm({
35048
35139
  init_constants();
35049
35140
  init_config_manager();
35050
35141
  init_telemetry();
35051
- import_fs19 = require("fs");
35052
- import_path18 = require("path");
35053
- import_os16 = require("os");
35142
+ import_fs20 = require("fs");
35143
+ import_path19 = require("path");
35144
+ import_os17 = require("os");
35054
35145
  init_project_detection();
35055
35146
  import_crypto6 = require("crypto");
35056
35147
  init_dist2();
@@ -35060,6 +35151,7 @@ var init_sync = __esm({
35060
35151
  init_CoreServiceProvider();
35061
35152
  init_agents_md_generator();
35062
35153
  init_dispatch_categories();
35154
+ init_mcp_config_writer();
35063
35155
  cliVersion4 = constants_default[0];
35064
35156
  defaultApiUrl4 = constants_default[1];
35065
35157
  GAL_CLI_CURSOR_RULES_VERSION = "1.0.0";
@@ -35624,7 +35716,7 @@ Review status: ${source_default.cyan("gal auth status")}
35624
35716
  let accessToken;
35625
35717
  let refreshToken;
35626
35718
  let expiresAt;
35627
- const claudeDir = (0, import_path19.join)((0, import_os17.homedir)(), ".claude");
35719
+ const claudeDir = (0, import_path20.join)((0, import_os18.homedir)(), ".claude");
35628
35720
  let credentialSource2 = "";
35629
35721
  const isSetupTokenMode2 = !!options.setupToken;
35630
35722
  if (options.setupToken) {
@@ -35705,13 +35797,13 @@ Review status: ${source_default.cyan("gal auth status")}
35705
35797
  }
35706
35798
  }
35707
35799
  if (!isSetupTokenMode2 && (!accessToken || !refreshToken)) {
35708
- const legacyCredentialsPath = (0, import_path19.join)(claudeDir, ".credentials.json");
35800
+ const legacyCredentialsPath = (0, import_path20.join)(claudeDir, ".credentials.json");
35709
35801
  if (verbose) {
35710
35802
  spinner.info(source_default.dim(` Trying ${legacyCredentialsPath}...`));
35711
35803
  }
35712
- if ((0, import_fs20.existsSync)(legacyCredentialsPath)) {
35804
+ if ((0, import_fs21.existsSync)(legacyCredentialsPath)) {
35713
35805
  try {
35714
- const content = (0, import_fs20.readFileSync)(legacyCredentialsPath, "utf-8");
35806
+ const content = (0, import_fs21.readFileSync)(legacyCredentialsPath, "utf-8");
35715
35807
  const credentials = JSON.parse(content);
35716
35808
  accessToken = credentials.claudeAiOauth?.accessToken;
35717
35809
  refreshToken = credentials.claudeAiOauth?.refreshToken;
@@ -35735,13 +35827,13 @@ Review status: ${source_default.cyan("gal auth status")}
35735
35827
  }
35736
35828
  }
35737
35829
  if (!isSetupTokenMode2 && (!accessToken || !refreshToken)) {
35738
- const configPath = (0, import_path19.join)(claudeDir, ".claude.json");
35830
+ const configPath = (0, import_path20.join)(claudeDir, ".claude.json");
35739
35831
  if (verbose) {
35740
35832
  spinner.info(source_default.dim(` Trying ${configPath} (oauthCredentials field)...`));
35741
35833
  }
35742
- if ((0, import_fs20.existsSync)(configPath)) {
35834
+ if ((0, import_fs21.existsSync)(configPath)) {
35743
35835
  try {
35744
- const content = (0, import_fs20.readFileSync)(configPath, "utf-8");
35836
+ const content = (0, import_fs21.readFileSync)(configPath, "utf-8");
35745
35837
  const claudeConfig = JSON.parse(content);
35746
35838
  accessToken = claudeConfig.oauthCredentials?.claudeAiOauth?.accessToken;
35747
35839
  refreshToken = claudeConfig.oauthCredentials?.claudeAiOauth?.refreshToken;
@@ -35864,13 +35956,13 @@ Review status: ${source_default.cyan("gal auth status")}
35864
35956
  spinner.info(source_default.dim(" Using API key from command line"));
35865
35957
  }
35866
35958
  } else {
35867
- const codexAuthPath = (0, import_path19.join)((0, import_os17.homedir)(), ".codex", "auth.json");
35959
+ const codexAuthPath = (0, import_path20.join)((0, import_os18.homedir)(), ".codex", "auth.json");
35868
35960
  if (verbose) {
35869
35961
  spinner.info(source_default.dim(` Trying ${codexAuthPath}...`));
35870
35962
  }
35871
- if ((0, import_fs20.existsSync)(codexAuthPath)) {
35963
+ if ((0, import_fs21.existsSync)(codexAuthPath)) {
35872
35964
  try {
35873
- const content = (0, import_fs20.readFileSync)(codexAuthPath, "utf-8");
35965
+ const content = (0, import_fs21.readFileSync)(codexAuthPath, "utf-8");
35874
35966
  const authData = JSON.parse(content);
35875
35967
  if (verbose) {
35876
35968
  spinner.info(source_default.dim(` Found auth.json, checking tokens...`));
@@ -35982,13 +36074,13 @@ Source: ${credentialSource2}`));
35982
36074
  spinner.info(source_default.dim(" Using API key from command line"));
35983
36075
  }
35984
36076
  } else {
35985
- const geminiAuthPath = (0, import_path19.join)((0, import_os17.homedir)(), ".gemini", "oauth_creds.json");
36077
+ const geminiAuthPath = (0, import_path20.join)((0, import_os18.homedir)(), ".gemini", "oauth_creds.json");
35986
36078
  if (verbose) {
35987
36079
  spinner.info(source_default.dim(` Trying ${geminiAuthPath}...`));
35988
36080
  }
35989
- if ((0, import_fs20.existsSync)(geminiAuthPath)) {
36081
+ if ((0, import_fs21.existsSync)(geminiAuthPath)) {
35990
36082
  try {
35991
- const content = (0, import_fs20.readFileSync)(geminiAuthPath, "utf-8");
36083
+ const content = (0, import_fs21.readFileSync)(geminiAuthPath, "utf-8");
35992
36084
  const authData = JSON.parse(content);
35993
36085
  if (verbose) {
35994
36086
  spinner.info(source_default.dim(` Found oauth_creds.json, checking tokens...`));
@@ -36309,7 +36401,7 @@ Source: ${credentialSource2}`));
36309
36401
  });
36310
36402
  return auth;
36311
36403
  }
36312
- var import_http, import_child_process6, import_os17, import_fs20, import_path19, import_readline2, CLI_CALLBACK_PORT, CLI_CALLBACK_PATH, cliVersion5, defaultApiUrl5;
36404
+ var import_http, import_child_process6, import_os18, import_fs21, import_path20, import_readline2, CLI_CALLBACK_PORT, CLI_CALLBACK_PATH, cliVersion5, defaultApiUrl5;
36313
36405
  var init_auth2 = __esm({
36314
36406
  "src/commands/auth.ts"() {
36315
36407
  "use strict";
@@ -36322,9 +36414,9 @@ var init_auth2 = __esm({
36322
36414
  init_constants();
36323
36415
  init_CoreServiceProvider();
36324
36416
  init_telemetry();
36325
- import_os17 = require("os");
36326
- import_fs20 = require("fs");
36327
- import_path19 = require("path");
36417
+ import_os18 = require("os");
36418
+ import_fs21 = require("fs");
36419
+ import_path20 = require("path");
36328
36420
  init_hooks();
36329
36421
  init_sync();
36330
36422
  import_readline2 = require("readline");
@@ -36339,13 +36431,13 @@ var init_auth2 = __esm({
36339
36431
  // src/commands/check.ts
36340
36432
  function createCheckCommand() {
36341
36433
  const command = new Command("check").description("Pre-enforcement check - see what issues will block your commit").option("--fix", "Auto-fix issues where possible").option("--interactive", "Interactive mode to review issues").option("--report", "Generate detailed JSON report").option("--path <path>", "Project path to check", process.cwd()).action(async (options) => {
36342
- if (!(0, import_fs21.existsSync)(options.path)) {
36434
+ if (!(0, import_fs22.existsSync)(options.path)) {
36343
36435
  console.error(source_default.red(`
36344
36436
  Error: Path does not exist: ${options.path}
36345
36437
  `));
36346
36438
  process.exit(1);
36347
36439
  }
36348
- if (!(0, import_fs21.statSync)(options.path).isDirectory()) {
36440
+ if (!(0, import_fs22.statSync)(options.path).isDirectory()) {
36349
36441
  console.error(source_default.red(`
36350
36442
  Error: Path is not a directory: ${options.path}
36351
36443
  `));
@@ -36357,8 +36449,8 @@ Error: Path is not a directory: ${options.path}
36357
36449
  });
36358
36450
  const report = await checker.runAllChecks();
36359
36451
  if (options.report) {
36360
- const reportPath = (0, import_path20.join)(options.path, "gal-check-report.json");
36361
- (0, import_fs21.writeFileSync)(reportPath, JSON.stringify(report, null, 2));
36452
+ const reportPath = (0, import_path21.join)(options.path, "gal-check-report.json");
36453
+ (0, import_fs22.writeFileSync)(reportPath, JSON.stringify(report, null, 2));
36362
36454
  console.log(source_default.blue(`Report saved to: ${reportPath}`));
36363
36455
  }
36364
36456
  if (report.summary.blocked) {
@@ -36367,14 +36459,14 @@ Error: Path is not a directory: ${options.path}
36367
36459
  });
36368
36460
  return command;
36369
36461
  }
36370
- var import_fs21, import_path20, import_child_process7, SECRET_PATTERNS, DANGEROUS_PATTERNS, FORBIDDEN_FILES, PreEnforcementChecker;
36462
+ var import_fs22, import_path21, import_child_process7, SECRET_PATTERNS, DANGEROUS_PATTERNS, FORBIDDEN_FILES, PreEnforcementChecker;
36371
36463
  var init_check = __esm({
36372
36464
  "src/commands/check.ts"() {
36373
36465
  "use strict";
36374
36466
  init_esm();
36375
36467
  init_source();
36376
- import_fs21 = require("fs");
36377
- import_path20 = require("path");
36468
+ import_fs22 = require("fs");
36469
+ import_path21 = require("path");
36378
36470
  import_child_process7 = require("child_process");
36379
36471
  SECRET_PATTERNS = [
36380
36472
  {
@@ -36526,10 +36618,10 @@ var init_check = __esm({
36526
36618
  const scan = (currentDir, depth) => {
36527
36619
  if (depth > maxDepth) return;
36528
36620
  try {
36529
- const entries = (0, import_fs21.readdirSync)(currentDir, { withFileTypes: true });
36621
+ const entries = (0, import_fs22.readdirSync)(currentDir, { withFileTypes: true });
36530
36622
  for (const entry of entries) {
36531
- const fullPath = (0, import_path20.join)(currentDir, entry.name);
36532
- const relativePath = (0, import_path20.relative)(this.projectPath, fullPath);
36623
+ const fullPath = (0, import_path21.join)(currentDir, entry.name);
36624
+ const relativePath = (0, import_path21.relative)(this.projectPath, fullPath);
36533
36625
  if (entry.isDirectory()) {
36534
36626
  if (!ignoreDirs.includes(entry.name)) {
36535
36627
  scan(fullPath, depth + 1);
@@ -36549,10 +36641,10 @@ var init_check = __esm({
36549
36641
  */
36550
36642
  async checkForSecrets(files) {
36551
36643
  for (const file of files) {
36552
- const fullPath = (0, import_path20.join)(this.projectPath, file);
36553
- if (!(0, import_fs21.existsSync)(fullPath) || !this.isTextFile(fullPath)) continue;
36644
+ const fullPath = (0, import_path21.join)(this.projectPath, file);
36645
+ if (!(0, import_fs22.existsSync)(fullPath) || !this.isTextFile(fullPath)) continue;
36554
36646
  try {
36555
- const content = (0, import_fs21.readFileSync)(fullPath, "utf-8");
36647
+ const content = (0, import_fs22.readFileSync)(fullPath, "utf-8");
36556
36648
  const lines = content.split("\n");
36557
36649
  for (const { name, pattern, severity, suggestion } of SECRET_PATTERNS) {
36558
36650
  pattern.lastIndex = 0;
@@ -36584,13 +36676,13 @@ var init_check = __esm({
36584
36676
  async checkForDangerousCommands(files) {
36585
36677
  const scriptExtensions = [".sh", ".bash", ".zsh", ".ps1", ".bat", ".cmd"];
36586
36678
  for (const file of files) {
36587
- const fullPath = (0, import_path20.join)(this.projectPath, file);
36588
- if (!(0, import_fs21.existsSync)(fullPath)) continue;
36679
+ const fullPath = (0, import_path21.join)(this.projectPath, file);
36680
+ if (!(0, import_fs22.existsSync)(fullPath)) continue;
36589
36681
  const isScript = scriptExtensions.some((ext) => file.endsWith(ext));
36590
36682
  const isConfig = file.includes("hook") || file.includes("command");
36591
36683
  if (!isScript && !isConfig) continue;
36592
36684
  try {
36593
- const content = (0, import_fs21.readFileSync)(fullPath, "utf-8");
36685
+ const content = (0, import_fs22.readFileSync)(fullPath, "utf-8");
36594
36686
  for (const { name, pattern, severity, suggestion } of DANGEROUS_PATTERNS) {
36595
36687
  pattern.lastIndex = 0;
36596
36688
  let match;
@@ -36643,14 +36735,14 @@ var init_check = __esm({
36643
36735
  async checkAgentConfigs() {
36644
36736
  const configDirs = [".claude", ".cursor", ".gemini", ".codex", ".windsurf"];
36645
36737
  for (const dir of configDirs) {
36646
- const dirPath = (0, import_path20.join)(this.projectPath, dir);
36647
- if (!(0, import_fs21.existsSync)(dirPath)) continue;
36738
+ const dirPath = (0, import_path21.join)(this.projectPath, dir);
36739
+ if (!(0, import_fs22.existsSync)(dirPath)) continue;
36648
36740
  const files = this.scanDirectory(dirPath, 2);
36649
36741
  for (const file of files) {
36650
- const fullPath = (0, import_path20.join)(this.projectPath, file);
36651
- if (!(0, import_fs21.existsSync)(fullPath)) continue;
36742
+ const fullPath = (0, import_path21.join)(this.projectPath, file);
36743
+ if (!(0, import_fs22.existsSync)(fullPath)) continue;
36652
36744
  try {
36653
- const content = (0, import_fs21.readFileSync)(fullPath, "utf-8");
36745
+ const content = (0, import_fs22.readFileSync)(fullPath, "utf-8");
36654
36746
  if (content.includes('"allowAll": true') || content.includes("allowAll: true")) {
36655
36747
  this.issues.push({
36656
36748
  severity: "high",
@@ -36690,7 +36782,7 @@ var init_check = __esm({
36690
36782
  file.replace("src/", "src/__tests__/").replace(/\.(ts|tsx|js|jsx)$/, ".test.$1")
36691
36783
  ];
36692
36784
  const hasTest = testVariants.some(
36693
- (testFile) => (0, import_fs21.existsSync)((0, import_path20.join)(this.projectPath, testFile))
36785
+ (testFile) => (0, import_fs22.existsSync)((0, import_path21.join)(this.projectPath, testFile))
36694
36786
  );
36695
36787
  if (!hasTest) {
36696
36788
  this.issues.push({
@@ -42397,18 +42489,18 @@ Writing configs to ${outputDir}:
42397
42489
  if (!fileName.includes(".")) {
42398
42490
  fileName = `${fileName}${extension}`;
42399
42491
  }
42400
- const relativePath = categoryDir ? (0, import_path21.join)(platformDir, categoryDir, fileName) : (0, import_path21.join)(platformDir, fileName);
42401
- const fullPath = (0, import_path21.join)(outputDir, relativePath);
42492
+ const relativePath = categoryDir ? (0, import_path22.join)(platformDir, categoryDir, fileName) : (0, import_path22.join)(platformDir, fileName);
42493
+ const fullPath = (0, import_path22.join)(outputDir, relativePath);
42402
42494
  if (options.dryRun) {
42403
42495
  console.log(source_default.cyan(" [dry-run]"), relativePath);
42404
42496
  writtenFiles.push(relativePath);
42405
42497
  continue;
42406
42498
  }
42407
- const dir = (0, import_path21.dirname)(fullPath);
42408
- if (!(0, import_fs22.existsSync)(dir)) {
42409
- (0, import_fs22.mkdirSync)(dir, { recursive: true });
42499
+ const dir = (0, import_path22.dirname)(fullPath);
42500
+ if (!(0, import_fs23.existsSync)(dir)) {
42501
+ (0, import_fs23.mkdirSync)(dir, { recursive: true });
42410
42502
  }
42411
- (0, import_fs22.writeFileSync)(fullPath, file.content, "utf-8");
42503
+ (0, import_fs23.writeFileSync)(fullPath, file.content, "utf-8");
42412
42504
  writtenFiles.push(relativePath);
42413
42505
  console.log(source_default.green(" \u2713"), relativePath);
42414
42506
  }
@@ -42469,7 +42561,7 @@ Files written to ${outputDir}`));
42469
42561
  });
42470
42562
  return command;
42471
42563
  }
42472
- var import_fs22, import_path21, PLATFORM_DIRS4, CATEGORY_DIRS, FILE_EXTENSIONS;
42564
+ var import_fs23, import_path22, PLATFORM_DIRS4, CATEGORY_DIRS, FILE_EXTENSIONS;
42473
42565
  var init_fetch = __esm({
42474
42566
  "src/commands/fetch.ts"() {
42475
42567
  "use strict";
@@ -42478,8 +42570,8 @@ var init_fetch = __esm({
42478
42570
  init_ora();
42479
42571
  init_config_manager();
42480
42572
  init_CoreServiceProvider();
42481
- import_fs22 = require("fs");
42482
- import_path21 = require("path");
42573
+ import_fs23 = require("fs");
42574
+ import_path22 = require("path");
42483
42575
  init_capability_checker();
42484
42576
  init_dist2();
42485
42577
  PLATFORM_DIRS4 = { ...PLATFORM_DIRECTORY_MAP };
@@ -42741,13 +42833,13 @@ function getGitEmail() {
42741
42833
  }
42742
42834
  async function getLocalEnforcementStatus() {
42743
42835
  const { stat: stat5, readFile: readFile4 } = await import("node:fs/promises");
42744
- const { join: join46 } = await import("node:path");
42836
+ const { join: join47 } = await import("node:path");
42745
42837
  const platforms = [];
42746
42838
  let version = "0.0.0";
42747
42839
  let policyVersion = "0.0.0";
42748
42840
  const platformDirs = [".claude", ".cursor", ".gemini", ".codex", ".windsurf"];
42749
42841
  for (const dir of platformDirs) {
42750
- const hookPath = join46(process.cwd(), dir, "hooks", "gal-safety-hook.py");
42842
+ const hookPath = join47(process.cwd(), dir, "hooks", "gal-safety-hook.py");
42751
42843
  try {
42752
42844
  await stat5(hookPath);
42753
42845
  platforms.push(dir.replace(".", ""));
@@ -42760,7 +42852,7 @@ async function getLocalEnforcementStatus() {
42760
42852
  }
42761
42853
  }
42762
42854
  try {
42763
- const pkgPath = join46(import_meta2.url.replace("file://", ""), "..", "..", "..", "package.json");
42855
+ const pkgPath = join47(import_meta2.url.replace("file://", ""), "..", "..", "..", "package.json");
42764
42856
  const pkg = JSON.parse(await readFile4(pkgPath, "utf-8"));
42765
42857
  version = pkg.version || "0.1.0";
42766
42858
  } catch {
@@ -43220,15 +43312,15 @@ Task not running: ${taskId}
43220
43312
  });
43221
43313
  return command;
43222
43314
  }
43223
- var import_child_process8, import_fs23, import_path22, DEFAULT_CONFIG, TASK_TEMPLATES, HeadlessRunner;
43315
+ var import_child_process8, import_fs24, import_path23, DEFAULT_CONFIG, TASK_TEMPLATES, HeadlessRunner;
43224
43316
  var init_headless = __esm({
43225
43317
  "src/commands/headless.ts"() {
43226
43318
  "use strict";
43227
43319
  init_esm();
43228
43320
  init_source();
43229
43321
  import_child_process8 = require("child_process");
43230
- import_fs23 = require("fs");
43231
- import_path22 = require("path");
43322
+ import_fs24 = require("fs");
43323
+ import_path23 = require("path");
43232
43324
  DEFAULT_CONFIG = {
43233
43325
  dataDir: ".gal/headless",
43234
43326
  logDir: ".gal/headless/logs",
@@ -43282,23 +43374,23 @@ var init_headless = __esm({
43282
43374
  * Ensure required directories exist
43283
43375
  */
43284
43376
  ensureDirectories() {
43285
- const dataDir = (0, import_path22.join)(this.projectPath, this.config.dataDir);
43286
- const logDir = (0, import_path22.join)(this.projectPath, this.config.logDir);
43287
- if (!(0, import_fs23.existsSync)(dataDir)) {
43288
- (0, import_fs23.mkdirSync)(dataDir, { recursive: true });
43377
+ const dataDir = (0, import_path23.join)(this.projectPath, this.config.dataDir);
43378
+ const logDir = (0, import_path23.join)(this.projectPath, this.config.logDir);
43379
+ if (!(0, import_fs24.existsSync)(dataDir)) {
43380
+ (0, import_fs24.mkdirSync)(dataDir, { recursive: true });
43289
43381
  }
43290
- if (!(0, import_fs23.existsSync)(logDir)) {
43291
- (0, import_fs23.mkdirSync)(logDir, { recursive: true });
43382
+ if (!(0, import_fs24.existsSync)(logDir)) {
43383
+ (0, import_fs24.mkdirSync)(logDir, { recursive: true });
43292
43384
  }
43293
43385
  }
43294
43386
  /**
43295
43387
  * Load tasks from disk
43296
43388
  */
43297
43389
  loadTasks() {
43298
- const tasksFile = (0, import_path22.join)(this.projectPath, this.config.dataDir, "tasks.json");
43299
- if ((0, import_fs23.existsSync)(tasksFile)) {
43390
+ const tasksFile = (0, import_path23.join)(this.projectPath, this.config.dataDir, "tasks.json");
43391
+ if ((0, import_fs24.existsSync)(tasksFile)) {
43300
43392
  try {
43301
- const data = JSON.parse((0, import_fs23.readFileSync)(tasksFile, "utf-8"));
43393
+ const data = JSON.parse((0, import_fs24.readFileSync)(tasksFile, "utf-8"));
43302
43394
  for (const task of data.tasks || []) {
43303
43395
  this.tasks.set(task.id, {
43304
43396
  ...task,
@@ -43315,12 +43407,12 @@ var init_headless = __esm({
43315
43407
  * Save tasks to disk
43316
43408
  */
43317
43409
  saveTasks() {
43318
- const tasksFile = (0, import_path22.join)(this.projectPath, this.config.dataDir, "tasks.json");
43410
+ const tasksFile = (0, import_path23.join)(this.projectPath, this.config.dataDir, "tasks.json");
43319
43411
  const data = {
43320
43412
  tasks: Array.from(this.tasks.values()),
43321
43413
  updatedAt: (/* @__PURE__ */ new Date()).toISOString()
43322
43414
  };
43323
- (0, import_fs23.writeFileSync)(tasksFile, JSON.stringify(data, null, 2));
43415
+ (0, import_fs24.writeFileSync)(tasksFile, JSON.stringify(data, null, 2));
43324
43416
  }
43325
43417
  /**
43326
43418
  * Create a new task
@@ -43371,7 +43463,7 @@ var init_headless = __esm({
43371
43463
  task.status = "running";
43372
43464
  task.startedAt = /* @__PURE__ */ new Date();
43373
43465
  this.saveTasks();
43374
- const logFile = (0, import_path22.join)(
43466
+ const logFile = (0, import_path23.join)(
43375
43467
  this.projectPath,
43376
43468
  this.config.logDir,
43377
43469
  `${task.id}_${Date.now()}.log`
@@ -43397,7 +43489,7 @@ var init_headless = __esm({
43397
43489
  const logStream = (data, isError = false) => {
43398
43490
  const text = data.toString();
43399
43491
  const prefix = isError ? "[ERROR] " : "";
43400
- (0, import_fs23.appendFileSync)(logFile, `${(/* @__PURE__ */ new Date()).toISOString()} ${prefix}${text}`);
43492
+ (0, import_fs24.appendFileSync)(logFile, `${(/* @__PURE__ */ new Date()).toISOString()} ${prefix}${text}`);
43401
43493
  if (!task.output) task.output = "";
43402
43494
  task.output += text;
43403
43495
  };
@@ -43841,7 +43933,7 @@ if __name__ == '__main__':
43841
43933
  `;
43842
43934
  }
43843
43935
  function createJoinCommand() {
43844
- const join46 = new Command("join").description("Join an organization using an invite code (GAL-100)").option("-c, --code <code>", "Invite code (e.g., GAL-XXXX-XXXX)").option("-e, --email <email>", "Developer email (defaults to git config)").option("--skip-hooks", "Skip enforcement hook installation").option("--dry-run", "Validate invite without joining").action(async (options) => {
43936
+ const join47 = new Command("join").description("Join an organization using an invite code (GAL-100)").option("-c, --code <code>", "Invite code (e.g., GAL-XXXX-XXXX)").option("-e, --email <email>", "Developer email (defaults to git config)").option("--skip-hooks", "Skip enforcement hook installation").option("--dry-run", "Validate invite without joining").action(async (options) => {
43845
43937
  const spinner = ora();
43846
43938
  if (!options.code) {
43847
43939
  console.log(source_default.bold("\nGAL Developer Onboarding\n"));
@@ -43957,7 +44049,7 @@ Error: ${useResult.error || "Unknown error"}`));
43957
44049
  process.exit(1);
43958
44050
  }
43959
44051
  });
43960
- return join46;
44052
+ return join47;
43961
44053
  }
43962
44054
  var import_node_os5, import_node_child_process2, import_node_crypto3, import_promises6, import_node_path4, defaultApiUrl9;
43963
44055
  var init_join = __esm({
@@ -44284,10 +44376,10 @@ function parseMcpJsonRpcBody(body) {
44284
44376
  return null;
44285
44377
  }
44286
44378
  function readMcpConfig(mcpPath) {
44287
- if (!(0, import_fs24.existsSync)(mcpPath)) {
44379
+ if (!(0, import_fs25.existsSync)(mcpPath)) {
44288
44380
  return { mcpServers: {} };
44289
44381
  }
44290
- const raw = (0, import_fs24.readFileSync)(mcpPath, "utf-8");
44382
+ const raw = (0, import_fs25.readFileSync)(mcpPath, "utf-8");
44291
44383
  const parsed = JSON.parse(raw);
44292
44384
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
44293
44385
  throw new Error(`${mcpPath} must be a JSON object`);
@@ -44343,11 +44435,11 @@ async function postMcpJsonRpc(endpoint, authToken, method, params, timeoutMs) {
44343
44435
  }
44344
44436
  async function runMcpDoctor(options = {}) {
44345
44437
  const config = ConfigManager.load();
44346
- const directory = (0, import_path23.resolve)(options.directory || process.cwd());
44438
+ const directory = (0, import_path24.resolve)(options.directory || process.cwd());
44347
44439
  const serverName = options.serverName || DEFAULT_SERVER_NAME;
44348
44440
  const fallbackApiUrl = resolveApiUrl(options.apiUrl || config.apiUrl || defaultApiUrl10);
44349
44441
  let endpoint = buildMcpUrl(fallbackApiUrl);
44350
- const mcpPath = (0, import_path23.join)(directory, ".mcp.json");
44442
+ const mcpPath = (0, import_path24.join)(directory, ".mcp.json");
44351
44443
  const authToken = options.authToken ?? config.authToken;
44352
44444
  const timeoutMs = options.timeoutMs ?? 1e4;
44353
44445
  const result = {
@@ -44498,11 +44590,11 @@ MCP is healthy. ${result.toolsCount} GAL tools are available.
44498
44590
  }
44499
44591
  function createSetupCommand() {
44500
44592
  return new Command("setup").description("Create or update .mcp.json with hosted GAL MCP server").option("--dir <path>", "Target directory (default: current directory)").option("--api-url <url>", "GAL API URL (default: config/default)").option("--server-name <name>", `MCP server key (default: ${DEFAULT_SERVER_NAME})`).option("--skip-doctor", "Skip running MCP diagnostics after setup").action(async (options) => {
44501
- const directory = (0, import_path23.resolve)(options.dir || process.cwd());
44593
+ const directory = (0, import_path24.resolve)(options.dir || process.cwd());
44502
44594
  const serverName = options.serverName || DEFAULT_SERVER_NAME;
44503
44595
  const config = ConfigManager.load();
44504
44596
  const apiUrl = resolveApiUrl(options.apiUrl || config.apiUrl || defaultApiUrl10);
44505
- const mcpPath = (0, import_path23.join)(directory, ".mcp.json");
44597
+ const mcpPath = (0, import_path24.join)(directory, ".mcp.json");
44506
44598
  let existing = { mcpServers: {} };
44507
44599
  try {
44508
44600
  existing = readMcpConfig(mcpPath);
@@ -44511,8 +44603,8 @@ function createSetupCommand() {
44511
44603
  process.exit(1);
44512
44604
  }
44513
44605
  const next = upsertHostedGalServer(existing, serverName, apiUrl);
44514
- (0, import_fs24.mkdirSync)(directory, { recursive: true });
44515
- (0, import_fs24.writeFileSync)(mcpPath, JSON.stringify(next, null, 2) + "\n", "utf-8");
44606
+ (0, import_fs25.mkdirSync)(directory, { recursive: true });
44607
+ (0, import_fs25.writeFileSync)(mcpPath, JSON.stringify(next, null, 2) + "\n", "utf-8");
44516
44608
  console.log(source_default.green(`\u2713 Updated ${mcpPath}`));
44517
44609
  console.log(source_default.dim(` mcpServers.${serverName}.url = ${buildMcpUrl(apiUrl)}
44518
44610
  `));
@@ -44561,15 +44653,15 @@ function createDoctorCommand() {
44561
44653
  function createMcpCommand() {
44562
44654
  return new Command("mcp").description("Set up and validate GAL hosted MCP connectivity").addCommand(createSetupCommand()).addCommand(createDoctorCommand());
44563
44655
  }
44564
- var import_fs24, import_path23, DEFAULT_SERVER_NAME, defaultApiUrl10;
44656
+ var import_fs25, import_path24, DEFAULT_SERVER_NAME, defaultApiUrl10;
44565
44657
  var init_mcp = __esm({
44566
44658
  "src/commands/mcp.ts"() {
44567
44659
  "use strict";
44568
44660
  init_esm();
44569
44661
  init_source();
44570
44662
  init_ora();
44571
- import_fs24 = require("fs");
44572
- import_path23 = require("path");
44663
+ import_fs25 = require("fs");
44664
+ import_path24 = require("path");
44573
44665
  init_config_manager();
44574
44666
  init_constants();
44575
44667
  DEFAULT_SERVER_NAME = "gal";
@@ -44580,12 +44672,12 @@ var init_mcp = __esm({
44580
44672
  // src/commands/memory.ts
44581
44673
  function parseClaudeMemoryFile(filePath) {
44582
44674
  try {
44583
- const raw = (0, import_fs25.readFileSync)(filePath, "utf-8");
44675
+ const raw = (0, import_fs26.readFileSync)(filePath, "utf-8");
44584
44676
  const frontmatterMatch = raw.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);
44585
44677
  if (!frontmatterMatch) {
44586
44678
  return {
44587
- name: (0, import_path24.basename)(filePath, ".md"),
44588
- description: (0, import_path24.basename)(filePath, ".md").replace(/[-_]/g, " "),
44679
+ name: (0, import_path25.basename)(filePath, ".md"),
44680
+ description: (0, import_path25.basename)(filePath, ".md").replace(/[-_]/g, " "),
44589
44681
  type: "project",
44590
44682
  content: raw.trim(),
44591
44683
  source: "claude"
@@ -44599,8 +44691,8 @@ function parseClaudeMemoryFile(filePath) {
44599
44691
  const memType = getType?.[1]?.trim();
44600
44692
  const validTypes = ["user", "feedback", "project", "reference"];
44601
44693
  return {
44602
- name: getName?.[1]?.trim() || (0, import_path24.basename)(filePath, ".md"),
44603
- description: getDesc?.[1]?.trim() || (0, import_path24.basename)(filePath, ".md").replace(/[-_]/g, " "),
44694
+ name: getName?.[1]?.trim() || (0, import_path25.basename)(filePath, ".md"),
44695
+ description: getDesc?.[1]?.trim() || (0, import_path25.basename)(filePath, ".md").replace(/[-_]/g, " "),
44604
44696
  type: validTypes.includes(memType) ? memType : "project",
44605
44697
  content: body,
44606
44698
  source: "claude",
@@ -44614,22 +44706,22 @@ function discoverMemoryFiles(projectRoot, platform5, includeGlobal) {
44614
44706
  const files = [];
44615
44707
  const pattern = PLATFORM_PATTERNS[platform5];
44616
44708
  if (pattern.memoryDir) {
44617
- const memDir = (0, import_path24.join)(projectRoot, pattern.directory, pattern.memoryDir);
44618
- if ((0, import_fs25.existsSync)(memDir) && (0, import_fs25.statSync)(memDir).isDirectory()) {
44709
+ const memDir = (0, import_path25.join)(projectRoot, pattern.directory, pattern.memoryDir);
44710
+ if ((0, import_fs26.existsSync)(memDir) && (0, import_fs26.statSync)(memDir).isDirectory()) {
44619
44711
  scanMemoryDir(memDir, projectRoot, files, false);
44620
44712
  }
44621
44713
  }
44622
44714
  if (includeGlobal) {
44623
- const home = (0, import_os18.homedir)();
44715
+ const home = (0, import_os19.homedir)();
44624
44716
  if (platform5 === "claude") {
44625
- const projectsDir = (0, import_path24.join)(home, ".claude", "projects");
44626
- if ((0, import_fs25.existsSync)(projectsDir)) {
44717
+ const projectsDir = (0, import_path25.join)(home, ".claude", "projects");
44718
+ if ((0, import_fs26.existsSync)(projectsDir)) {
44627
44719
  try {
44628
- const projectDirs = (0, import_fs25.readdirSync)(projectsDir, { withFileTypes: true });
44720
+ const projectDirs = (0, import_fs26.readdirSync)(projectsDir, { withFileTypes: true });
44629
44721
  for (const projDir of projectDirs) {
44630
44722
  if (!projDir.isDirectory()) continue;
44631
- const memDir = (0, import_path24.join)(projectsDir, projDir.name, "memory");
44632
- if ((0, import_fs25.existsSync)(memDir) && (0, import_fs25.statSync)(memDir).isDirectory()) {
44723
+ const memDir = (0, import_path25.join)(projectsDir, projDir.name, "memory");
44724
+ if ((0, import_fs26.existsSync)(memDir) && (0, import_fs26.statSync)(memDir).isDirectory()) {
44633
44725
  scanMemoryDir(memDir, home, files, true);
44634
44726
  }
44635
44727
  }
@@ -44637,8 +44729,8 @@ function discoverMemoryFiles(projectRoot, platform5, includeGlobal) {
44637
44729
  }
44638
44730
  }
44639
44731
  } else if (platform5 === "windsurf") {
44640
- const memoriesDir = (0, import_path24.join)(home, ".codeium", "windsurf", "memories");
44641
- if ((0, import_fs25.existsSync)(memoriesDir)) {
44732
+ const memoriesDir = (0, import_path25.join)(home, ".codeium", "windsurf", "memories");
44733
+ if ((0, import_fs26.existsSync)(memoriesDir)) {
44642
44734
  scanMemoryDir(memoriesDir, home, files, true);
44643
44735
  }
44644
44736
  }
@@ -44647,16 +44739,16 @@ function discoverMemoryFiles(projectRoot, platform5, includeGlobal) {
44647
44739
  }
44648
44740
  function scanMemoryDir(dir, rootDir, files, isGlobal) {
44649
44741
  try {
44650
- const entries = (0, import_fs25.readdirSync)(dir, { withFileTypes: true });
44742
+ const entries = (0, import_fs26.readdirSync)(dir, { withFileTypes: true });
44651
44743
  for (const entry of entries) {
44652
- const fullPath = (0, import_path24.join)(dir, entry.name);
44744
+ const fullPath = (0, import_path25.join)(dir, entry.name);
44653
44745
  if (entry.isDirectory()) {
44654
44746
  scanMemoryDir(fullPath, rootDir, files, isGlobal);
44655
44747
  } else if (entry.isFile() && (entry.name.endsWith(".md") || entry.name.endsWith(".json"))) {
44656
44748
  if (entry.name === "MEMORY.md") continue;
44657
44749
  files.push({
44658
44750
  path: fullPath,
44659
- relativePath: (0, import_path24.relative)(rootDir, fullPath),
44751
+ relativePath: (0, import_path25.relative)(rootDir, fullPath),
44660
44752
  isGlobal
44661
44753
  });
44662
44754
  }
@@ -44737,9 +44829,9 @@ Examples:
44737
44829
  mem = parseClaudeMemoryFile(file.path);
44738
44830
  } else {
44739
44831
  try {
44740
- const content = (0, import_fs25.readFileSync)(file.path, "utf-8");
44832
+ const content = (0, import_fs26.readFileSync)(file.path, "utf-8");
44741
44833
  mem = {
44742
- name: (0, import_path24.basename)(file.path, ".md").replace(/[-_]/g, "-"),
44834
+ name: (0, import_path25.basename)(file.path, ".md").replace(/[-_]/g, "-"),
44743
44835
  description: `Imported from ${source}: ${file.relativePath}`,
44744
44836
  type: "project",
44745
44837
  content: content.trim(),
@@ -44856,15 +44948,15 @@ Examples:
44856
44948
  });
44857
44949
  return command;
44858
44950
  }
44859
- var import_fs25, import_path24, import_os18;
44951
+ var import_fs26, import_path25, import_os19;
44860
44952
  var init_memory2 = __esm({
44861
44953
  "src/commands/memory.ts"() {
44862
44954
  "use strict";
44863
44955
  init_esm();
44864
44956
  init_source();
44865
- import_fs25 = require("fs");
44866
- import_path24 = require("path");
44867
- import_os18 = require("os");
44957
+ import_fs26 = require("fs");
44958
+ import_path25 = require("path");
44959
+ import_os19 = require("os");
44868
44960
  init_dist2();
44869
44961
  init_project_detection();
44870
44962
  init_gal_config_service();
@@ -45390,21 +45482,21 @@ var init_policy = __esm({
45390
45482
  async function readLocalConfig() {
45391
45483
  const projectRoot = findProjectRoot();
45392
45484
  const canonicalSources = [
45393
- { path: (0, import_path25.join)(projectRoot, ".gal", "config.yaml"), label: ".gal/config.yaml" },
45394
- { path: (0, import_path25.join)((0, import_os19.homedir)(), ".gal", "config.yaml"), label: "~/.gal/config.yaml" }
45485
+ { path: (0, import_path26.join)(projectRoot, ".gal", "config.yaml"), label: ".gal/config.yaml" },
45486
+ { path: (0, import_path26.join)((0, import_os20.homedir)(), ".gal", "config.yaml"), label: "~/.gal/config.yaml" }
45395
45487
  ];
45396
45488
  for (const source of canonicalSources) {
45397
- if (!(0, import_fs26.existsSync)(source.path)) continue;
45489
+ if (!(0, import_fs27.existsSync)(source.path)) continue;
45398
45490
  try {
45399
- const content = (0, import_fs26.readFileSync)(source.path, "utf-8");
45491
+ const content = (0, import_fs27.readFileSync)(source.path, "utf-8");
45400
45492
  const config = (0, import_yaml2.parse)(content);
45401
45493
  return config;
45402
45494
  } catch (error2) {
45403
45495
  console.warn(`Failed to parse ${source.label}:`, error2);
45404
45496
  }
45405
45497
  }
45406
- const claudeDir = (0, import_path25.join)(projectRoot, ".claude");
45407
- if (!(0, import_fs26.existsSync)(claudeDir)) {
45498
+ const claudeDir = (0, import_path26.join)(projectRoot, ".claude");
45499
+ if (!(0, import_fs27.existsSync)(claudeDir)) {
45408
45500
  return null;
45409
45501
  }
45410
45502
  return constructConfigFromClaudeDir(claudeDir);
@@ -45417,10 +45509,10 @@ function constructConfigFromClaudeDir(claudeDir) {
45417
45509
  hash: "",
45418
45510
  syncedAt: (/* @__PURE__ */ new Date()).toISOString()
45419
45511
  };
45420
- const settingsPath = (0, import_path25.join)(claudeDir, "settings.json");
45421
- if ((0, import_fs26.existsSync)(settingsPath)) {
45512
+ const settingsPath = (0, import_path26.join)(claudeDir, "settings.json");
45513
+ if ((0, import_fs27.existsSync)(settingsPath)) {
45422
45514
  try {
45423
- const settingsContent = (0, import_fs26.readFileSync)(settingsPath, "utf-8");
45515
+ const settingsContent = (0, import_fs27.readFileSync)(settingsPath, "utf-8");
45424
45516
  let claudeSettings;
45425
45517
  try {
45426
45518
  claudeSettings = JSON.parse(settingsContent);
@@ -45436,24 +45528,24 @@ function constructConfigFromClaudeDir(claudeDir) {
45436
45528
  console.warn("Failed to read .claude/settings.json:", error2);
45437
45529
  }
45438
45530
  }
45439
- const claudeMdPath = (0, import_path25.join)(claudeDir, "..", "CLAUDE.md");
45440
- if ((0, import_fs26.existsSync)(claudeMdPath)) {
45531
+ const claudeMdPath = (0, import_path26.join)(claudeDir, "..", "CLAUDE.md");
45532
+ if ((0, import_fs27.existsSync)(claudeMdPath)) {
45441
45533
  try {
45442
- const claudeMdContent = (0, import_fs26.readFileSync)(claudeMdPath, "utf-8");
45534
+ const claudeMdContent = (0, import_fs27.readFileSync)(claudeMdPath, "utf-8");
45443
45535
  config.instructions = { content: claudeMdContent };
45444
45536
  } catch (error2) {
45445
45537
  console.warn("Failed to read CLAUDE.md:", error2);
45446
45538
  }
45447
45539
  }
45448
- const commandsDir = (0, import_path25.join)(claudeDir, "commands");
45449
- if ((0, import_fs26.existsSync)(commandsDir)) {
45540
+ const commandsDir = (0, import_path26.join)(claudeDir, "commands");
45541
+ if ((0, import_fs27.existsSync)(commandsDir)) {
45450
45542
  config.commands = [];
45451
45543
  try {
45452
45544
  const commandFiles = readDirRecursive(commandsDir, ".md");
45453
45545
  for (const file of commandFiles) {
45454
45546
  const relativePath = file.replace(commandsDir + "/", "");
45455
45547
  const commandName = relativePath.replace(/\.md$/, "").replace(/\//g, ":");
45456
- const content = (0, import_fs26.readFileSync)(file, "utf-8");
45548
+ const content = (0, import_fs27.readFileSync)(file, "utf-8");
45457
45549
  config.commands.push({
45458
45550
  name: commandName,
45459
45551
  content
@@ -45463,14 +45555,14 @@ function constructConfigFromClaudeDir(claudeDir) {
45463
45555
  console.warn("Failed to read .claude/commands/:", error2);
45464
45556
  }
45465
45557
  }
45466
- const rulesDir = (0, import_path25.join)(claudeDir, "rules");
45467
- if ((0, import_fs26.existsSync)(rulesDir)) {
45558
+ const rulesDir = (0, import_path26.join)(claudeDir, "rules");
45559
+ if ((0, import_fs27.existsSync)(rulesDir)) {
45468
45560
  config.rules = [];
45469
45561
  try {
45470
- const ruleFiles = (0, import_fs26.readdirSync)(rulesDir).filter((f) => f.endsWith(".md"));
45562
+ const ruleFiles = (0, import_fs27.readdirSync)(rulesDir).filter((f) => f.endsWith(".md"));
45471
45563
  for (const file of ruleFiles) {
45472
45564
  const ruleName = file.replace(/\.md$/, "");
45473
- const content = (0, import_fs26.readFileSync)((0, import_path25.join)(rulesDir, file), "utf-8");
45565
+ const content = (0, import_fs27.readFileSync)((0, import_path26.join)(rulesDir, file), "utf-8");
45474
45566
  config.rules.push({
45475
45567
  name: ruleName,
45476
45568
  content
@@ -45480,13 +45572,13 @@ function constructConfigFromClaudeDir(claudeDir) {
45480
45572
  console.warn("Failed to read .claude/rules/:", error2);
45481
45573
  }
45482
45574
  }
45483
- const hooksDir = (0, import_path25.join)(claudeDir, "hooks");
45484
- if ((0, import_fs26.existsSync)(hooksDir)) {
45575
+ const hooksDir = (0, import_path26.join)(claudeDir, "hooks");
45576
+ if ((0, import_fs27.existsSync)(hooksDir)) {
45485
45577
  config.hooks = [];
45486
45578
  try {
45487
- const hookFiles = (0, import_fs26.readdirSync)(hooksDir).filter((f) => f.endsWith(".js") || f.endsWith(".py") || f.endsWith(".sh"));
45579
+ const hookFiles = (0, import_fs27.readdirSync)(hooksDir).filter((f) => f.endsWith(".js") || f.endsWith(".py") || f.endsWith(".sh"));
45488
45580
  for (const file of hookFiles) {
45489
- const content = (0, import_fs26.readFileSync)((0, import_path25.join)(hooksDir, file), "utf-8");
45581
+ const content = (0, import_fs27.readFileSync)((0, import_path26.join)(hooksDir, file), "utf-8");
45490
45582
  config.hooks.push({
45491
45583
  name: file,
45492
45584
  event: "PreToolUse",
@@ -45498,15 +45590,15 @@ function constructConfigFromClaudeDir(claudeDir) {
45498
45590
  console.warn("Failed to read .claude/hooks/:", error2);
45499
45591
  }
45500
45592
  }
45501
- const agentsDir = (0, import_path25.join)(claudeDir, "agents");
45502
- if ((0, import_fs26.existsSync)(agentsDir)) {
45593
+ const agentsDir = (0, import_path26.join)(claudeDir, "agents");
45594
+ if ((0, import_fs27.existsSync)(agentsDir)) {
45503
45595
  config.agents = [];
45504
45596
  try {
45505
45597
  const agentFiles = readDirRecursive(agentsDir, ".md");
45506
45598
  for (const file of agentFiles) {
45507
45599
  const relativePath = file.replace(agentsDir + "/", "");
45508
45600
  const agentName = relativePath.replace(/\.md$/, "").replace(/\//g, ":");
45509
- const content = (0, import_fs26.readFileSync)(file, "utf-8");
45601
+ const content = (0, import_fs27.readFileSync)(file, "utf-8");
45510
45602
  config.agents.push({
45511
45603
  name: agentName,
45512
45604
  content
@@ -45525,10 +45617,10 @@ function constructConfigFromClaudeDir(claudeDir) {
45525
45617
  function readDirRecursive(dir, extension) {
45526
45618
  const results = [];
45527
45619
  try {
45528
- const files = (0, import_fs26.readdirSync)(dir);
45620
+ const files = (0, import_fs27.readdirSync)(dir);
45529
45621
  for (const file of files) {
45530
- const filePath = (0, import_path25.join)(dir, file);
45531
- const stat5 = (0, import_fs26.statSync)(filePath);
45622
+ const filePath = (0, import_path26.join)(dir, file);
45623
+ const stat5 = (0, import_fs27.statSync)(filePath);
45532
45624
  if (stat5.isDirectory()) {
45533
45625
  results.push(...readDirRecursive(filePath, extension));
45534
45626
  } else if (file.endsWith(extension)) {
@@ -45539,13 +45631,13 @@ function readDirRecursive(dir, extension) {
45539
45631
  }
45540
45632
  return results;
45541
45633
  }
45542
- var import_fs26, import_path25, import_os19, import_yaml2;
45634
+ var import_fs27, import_path26, import_os20, import_yaml2;
45543
45635
  var init_config_reader = __esm({
45544
45636
  "src/utils/config-reader.ts"() {
45545
45637
  "use strict";
45546
- import_fs26 = require("fs");
45547
- import_path25 = require("path");
45548
- import_os19 = require("os");
45638
+ import_fs27 = require("fs");
45639
+ import_path26 = require("path");
45640
+ import_os20 = require("os");
45549
45641
  init_project_detection();
45550
45642
  import_yaml2 = __toESM(require_dist(), 1);
45551
45643
  }
@@ -45555,8 +45647,8 @@ var init_config_reader = __esm({
45555
45647
  function getGitRepoInfo() {
45556
45648
  try {
45557
45649
  const projectRoot = findProjectRoot();
45558
- const gitDir = (0, import_path26.join)(projectRoot, ".git");
45559
- if (!(0, import_fs27.existsSync)(gitDir)) {
45650
+ const gitDir = (0, import_path27.join)(projectRoot, ".git");
45651
+ if (!(0, import_fs28.existsSync)(gitDir)) {
45560
45652
  return { isRepo: false };
45561
45653
  }
45562
45654
  const remoteUrl = (0, import_child_process9.execSync)("git remote get-url origin", {
@@ -45689,7 +45781,7 @@ function createProposeCommand() {
45689
45781
  });
45690
45782
  return command;
45691
45783
  }
45692
- var import_fs27, import_path26, import_child_process9;
45784
+ var import_fs28, import_path27, import_child_process9;
45693
45785
  var init_propose = __esm({
45694
45786
  "src/commands/propose.ts"() {
45695
45787
  "use strict";
@@ -45700,8 +45792,8 @@ var init_propose = __esm({
45700
45792
  init_CoreServiceProvider();
45701
45793
  init_config_reader();
45702
45794
  init_project_detection();
45703
- import_fs27 = require("fs");
45704
- import_path26 = require("path");
45795
+ import_fs28 = require("fs");
45796
+ import_path27 = require("path");
45705
45797
  import_child_process9 = require("child_process");
45706
45798
  }
45707
45799
  });
@@ -46386,7 +46478,7 @@ function createAddCommand() {
46386
46478
  let prompt2 = promptArg;
46387
46479
  if (options.promptFile) {
46388
46480
  try {
46389
- prompt2 = (0, import_fs28.readFileSync)(options.promptFile, "utf-8").trim();
46481
+ prompt2 = (0, import_fs29.readFileSync)(options.promptFile, "utf-8").trim();
46390
46482
  } catch (err) {
46391
46483
  console.error(source_default.red(`Error reading prompt file: ${err instanceof Error ? err.message : String(err)}`));
46392
46484
  process.exit(1);
@@ -46633,14 +46725,14 @@ function createCancelCommand() {
46633
46725
  }
46634
46726
  });
46635
46727
  }
46636
- var import_fs28, defaultApiUrl12, PRIORITY_LABELS, PRIORITY_COLORS, STATUS_COLORS;
46728
+ var import_fs29, defaultApiUrl12, PRIORITY_LABELS, PRIORITY_COLORS, STATUS_COLORS;
46637
46729
  var init_queue_mgmt = __esm({
46638
46730
  "src/commands/queue-mgmt.ts"() {
46639
46731
  "use strict";
46640
46732
  init_esm();
46641
46733
  init_source();
46642
46734
  init_ora();
46643
- import_fs28 = require("fs");
46735
+ import_fs29 = require("fs");
46644
46736
  init_constants();
46645
46737
  init_config_manager();
46646
46738
  init_client();
@@ -46884,11 +46976,11 @@ function createSeedCommand() {
46884
46976
  }
46885
46977
  let template = options.template;
46886
46978
  if (options.templateFile) {
46887
- if (!(0, import_fs29.existsSync)(options.templateFile)) {
46979
+ if (!(0, import_fs30.existsSync)(options.templateFile)) {
46888
46980
  console.error(source_default.red(`Error: Template file not found: ${options.templateFile}`));
46889
46981
  process.exit(1);
46890
46982
  }
46891
- template = (0, import_fs29.readFileSync)(options.templateFile, "utf-8").trim();
46983
+ template = (0, import_fs30.readFileSync)(options.templateFile, "utf-8").trim();
46892
46984
  }
46893
46985
  const config = ConfigManager.load();
46894
46986
  const apiUrl = config.apiUrl ?? process.env.GAL_API_URL ?? defaultApiUrl13;
@@ -46904,13 +46996,13 @@ function createSeedCommand() {
46904
46996
  });
46905
46997
  if (options.file) {
46906
46998
  const filePath = options.file;
46907
- if (!(0, import_fs29.existsSync)(filePath)) {
46999
+ if (!(0, import_fs30.existsSync)(filePath)) {
46908
47000
  console.error(source_default.red(`Error: File not found: ${filePath}`));
46909
47001
  process.exit(1);
46910
47002
  }
46911
47003
  let items = [];
46912
47004
  try {
46913
- const raw = (0, import_fs29.readFileSync)(filePath, "utf-8");
47005
+ const raw = (0, import_fs30.readFileSync)(filePath, "utf-8");
46914
47006
  const parsed = JSON.parse(raw);
46915
47007
  if (!Array.isArray(parsed)) {
46916
47008
  console.error(source_default.red("Error: JSON file must contain an array of work items."));
@@ -47075,14 +47167,14 @@ function createQueueCommand() {
47075
47167
  cmd.addCommand(createSeedCommand());
47076
47168
  return cmd;
47077
47169
  }
47078
- var import_fs29, defaultApiUrl13, GH_API_BASE, DEFAULT_TEMPLATE_BY_LABEL, DEFAULT_TEMPLATE;
47170
+ var import_fs30, defaultApiUrl13, GH_API_BASE, DEFAULT_TEMPLATE_BY_LABEL, DEFAULT_TEMPLATE;
47079
47171
  var init_queue_seed = __esm({
47080
47172
  "src/commands/queue-seed.ts"() {
47081
47173
  "use strict";
47082
47174
  init_esm();
47083
47175
  init_source();
47084
47176
  init_ora();
47085
- import_fs29 = require("fs");
47177
+ import_fs30 = require("fs");
47086
47178
  init_config_manager();
47087
47179
  init_constants();
47088
47180
  init_client();
@@ -47138,10 +47230,10 @@ function parseFrontmatter(content) {
47138
47230
  };
47139
47231
  }
47140
47232
  function parseCommandFile(filePath) {
47141
- const content = (0, import_fs30.readFileSync)(filePath, "utf-8");
47233
+ const content = (0, import_fs31.readFileSync)(filePath, "utf-8");
47142
47234
  const { metadata, body } = parseFrontmatter(content);
47143
- const fileName = (0, import_path27.basename)(filePath);
47144
- const name = (0, import_path27.basename)(filePath, (0, import_path27.extname)(filePath));
47235
+ const fileName = (0, import_path28.basename)(filePath);
47236
+ const name = (0, import_path28.basename)(filePath, (0, import_path28.extname)(filePath));
47145
47237
  return {
47146
47238
  name,
47147
47239
  fileName,
@@ -47154,10 +47246,10 @@ function parseCommandFile(filePath) {
47154
47246
  function findCommandFiles(dir, recursive = true) {
47155
47247
  const files = [];
47156
47248
  try {
47157
- const entries = (0, import_fs30.readdirSync)(dir);
47249
+ const entries = (0, import_fs31.readdirSync)(dir);
47158
47250
  for (const entry of entries) {
47159
- const fullPath = (0, import_path27.join)(dir, entry);
47160
- const stats = (0, import_fs30.statSync)(fullPath);
47251
+ const fullPath = (0, import_path28.join)(dir, entry);
47252
+ const stats = (0, import_fs31.statSync)(fullPath);
47161
47253
  if (stats.isDirectory()) {
47162
47254
  if (entry.startsWith(".") || entry === "node_modules" || entry === ".templates") {
47163
47255
  continue;
@@ -47232,12 +47324,12 @@ function substituteArguments(commandBody, args2) {
47232
47324
  }
47233
47325
  return result;
47234
47326
  }
47235
- var import_fs30, import_path27;
47327
+ var import_fs31, import_path28;
47236
47328
  var init_command_parser = __esm({
47237
47329
  "src/parser/command-parser.ts"() {
47238
47330
  "use strict";
47239
- import_fs30 = require("fs");
47240
- import_path27 = require("path");
47331
+ import_fs31 = require("fs");
47332
+ import_path28 = require("path");
47241
47333
  }
47242
47334
  });
47243
47335
 
@@ -47478,12 +47570,12 @@ var init_headless_executor = __esm({
47478
47570
 
47479
47571
  // src/commands/run.ts
47480
47572
  function findCommandsDirectory() {
47481
- const localCommandsDir = (0, import_path28.join)(process.cwd(), ".claude", "commands");
47482
- if ((0, import_fs31.existsSync)(localCommandsDir)) {
47573
+ const localCommandsDir = (0, import_path29.join)(process.cwd(), ".claude", "commands");
47574
+ if ((0, import_fs32.existsSync)(localCommandsDir)) {
47483
47575
  return localCommandsDir;
47484
47576
  }
47485
- const homeCommandsDir = (0, import_path28.join)((0, import_os20.homedir)(), ".claude", "commands");
47486
- if ((0, import_fs31.existsSync)(homeCommandsDir)) {
47577
+ const homeCommandsDir = (0, import_path29.join)((0, import_os21.homedir)(), ".claude", "commands");
47578
+ if ((0, import_fs32.existsSync)(homeCommandsDir)) {
47487
47579
  return homeCommandsDir;
47488
47580
  }
47489
47581
  return null;
@@ -47571,7 +47663,7 @@ async function handleRunCommand(commandName, args2, options) {
47571
47663
  let commandsDir = options.dir || findCommandsDirectory();
47572
47664
  let command;
47573
47665
  if (options.file) {
47574
- if (!(0, import_fs31.existsSync)(options.file)) {
47666
+ if (!(0, import_fs32.existsSync)(options.file)) {
47575
47667
  console.error(source_default.red(`Error: Command file not found: ${options.file}`));
47576
47668
  process.exit(1);
47577
47669
  }
@@ -47653,16 +47745,16 @@ Executing command: ${command.name}`));
47653
47745
  throw error2;
47654
47746
  }
47655
47747
  }
47656
- var import_os20, import_path28, import_fs31;
47748
+ var import_os21, import_path29, import_fs32;
47657
47749
  var init_run = __esm({
47658
47750
  "src/commands/run.ts"() {
47659
47751
  "use strict";
47660
47752
  init_esm();
47661
47753
  init_source();
47662
47754
  init_ora();
47663
- import_os20 = require("os");
47664
- import_path28 = require("path");
47665
- import_fs31 = require("fs");
47755
+ import_os21 = require("os");
47756
+ import_path29 = require("path");
47757
+ import_fs32 = require("fs");
47666
47758
  init_command_parser();
47667
47759
  init_headless_executor();
47668
47760
  }
@@ -47670,30 +47762,30 @@ var init_run = __esm({
47670
47762
 
47671
47763
  // src/commands/run-design.ts
47672
47764
  function ensureDir() {
47673
- if (!(0, import_fs32.existsSync)(DESIGN_PROJECTS_DIR)) {
47674
- (0, import_fs32.mkdirSync)(DESIGN_PROJECTS_DIR, { recursive: true });
47765
+ if (!(0, import_fs33.existsSync)(DESIGN_PROJECTS_DIR)) {
47766
+ (0, import_fs33.mkdirSync)(DESIGN_PROJECTS_DIR, { recursive: true });
47675
47767
  }
47676
47768
  }
47677
47769
  function projectPath(id) {
47678
- return (0, import_path29.join)(DESIGN_PROJECTS_DIR, `${id}.json`);
47770
+ return (0, import_path30.join)(DESIGN_PROJECTS_DIR, `${id}.json`);
47679
47771
  }
47680
47772
  function saveProject(project) {
47681
47773
  ensureDir();
47682
- (0, import_fs32.writeFileSync)(projectPath(project.id), JSON.stringify(project, null, 2));
47774
+ (0, import_fs33.writeFileSync)(projectPath(project.id), JSON.stringify(project, null, 2));
47683
47775
  }
47684
47776
  function loadProject(id) {
47685
47777
  const p = projectPath(id);
47686
- if (!(0, import_fs32.existsSync)(p)) return null;
47778
+ if (!(0, import_fs33.existsSync)(p)) return null;
47687
47779
  try {
47688
- return JSON.parse((0, import_fs32.readFileSync)(p, "utf-8"));
47780
+ return JSON.parse((0, import_fs33.readFileSync)(p, "utf-8"));
47689
47781
  } catch {
47690
47782
  return null;
47691
47783
  }
47692
47784
  }
47693
47785
  function getActiveId() {
47694
- if (!(0, import_fs32.existsSync)(ACTIVE_FILE)) return null;
47786
+ if (!(0, import_fs33.existsSync)(ACTIVE_FILE)) return null;
47695
47787
  try {
47696
- const data = JSON.parse((0, import_fs32.readFileSync)(ACTIVE_FILE, "utf-8"));
47788
+ const data = JSON.parse((0, import_fs33.readFileSync)(ACTIVE_FILE, "utf-8"));
47697
47789
  return data.id ?? null;
47698
47790
  } catch {
47699
47791
  return null;
@@ -47701,7 +47793,7 @@ function getActiveId() {
47701
47793
  }
47702
47794
  function setActiveId(id) {
47703
47795
  ensureDir();
47704
- (0, import_fs32.writeFileSync)(ACTIVE_FILE, JSON.stringify({ id }, null, 2));
47796
+ (0, import_fs33.writeFileSync)(ACTIVE_FILE, JSON.stringify({ id }, null, 2));
47705
47797
  }
47706
47798
  function getActiveProject() {
47707
47799
  const id = getActiveId();
@@ -47822,7 +47914,7 @@ function handleStatus(options) {
47822
47914
  project = getActiveProject();
47823
47915
  if (!project) {
47824
47916
  ensureDir();
47825
- const files = (0, import_fs32.readdirSync)(DESIGN_PROJECTS_DIR).filter(
47917
+ const files = (0, import_fs33.readdirSync)(DESIGN_PROJECTS_DIR).filter(
47826
47918
  (f) => f.endsWith(".json") && f !== "active.json"
47827
47919
  );
47828
47920
  if (files.length === 0) {
@@ -47937,8 +48029,8 @@ function handleSync() {
47937
48029
  const project = getActiveProject();
47938
48030
  if (!project) {
47939
48031
  ensureDir();
47940
- (0, import_fs32.writeFileSync)(
47941
- (0, import_path29.join)(DESIGN_PROJECTS_DIR, "extension-sync.json"),
48032
+ (0, import_fs33.writeFileSync)(
48033
+ (0, import_path30.join)(DESIGN_PROJECTS_DIR, "extension-sync.json"),
47942
48034
  JSON.stringify(null, null, 2)
47943
48035
  );
47944
48036
  console.log(source_default.yellow("No active project. Extension card cleared."));
@@ -47955,8 +48047,8 @@ function handleSync() {
47955
48047
  completedScenes: done
47956
48048
  };
47957
48049
  ensureDir();
47958
- (0, import_fs32.writeFileSync)(
47959
- (0, import_path29.join)(DESIGN_PROJECTS_DIR, "extension-sync.json"),
48050
+ (0, import_fs33.writeFileSync)(
48051
+ (0, import_path30.join)(DESIGN_PROJECTS_DIR, "extension-sync.json"),
47960
48052
  JSON.stringify(summary, null, 2)
47961
48053
  );
47962
48054
  console.log(source_default.green("\nSynced active project to extension:\n"));
@@ -48000,17 +48092,17 @@ function createRunDesignCommand() {
48000
48092
  runDesign.addCommand(syncCmd);
48001
48093
  return runDesign;
48002
48094
  }
48003
- var import_os21, import_path29, import_fs32, DESIGN_PROJECTS_DIR, ACTIVE_FILE, IMAGE_STATUS_ICON, VIDEO_STATUS_ICON;
48095
+ var import_os22, import_path30, import_fs33, DESIGN_PROJECTS_DIR, ACTIVE_FILE, IMAGE_STATUS_ICON, VIDEO_STATUS_ICON;
48004
48096
  var init_run_design = __esm({
48005
48097
  "src/commands/run-design.ts"() {
48006
48098
  "use strict";
48007
48099
  init_esm();
48008
48100
  init_source();
48009
- import_os21 = require("os");
48010
- import_path29 = require("path");
48011
- import_fs32 = require("fs");
48012
- DESIGN_PROJECTS_DIR = (0, import_path29.join)((0, import_os21.homedir)(), ".gal", "design-projects");
48013
- ACTIVE_FILE = (0, import_path29.join)(DESIGN_PROJECTS_DIR, "active.json");
48101
+ import_os22 = require("os");
48102
+ import_path30 = require("path");
48103
+ import_fs33 = require("fs");
48104
+ DESIGN_PROJECTS_DIR = (0, import_path30.join)((0, import_os22.homedir)(), ".gal", "design-projects");
48105
+ ACTIVE_FILE = (0, import_path30.join)(DESIGN_PROJECTS_DIR, "active.json");
48014
48106
  IMAGE_STATUS_ICON = {
48015
48107
  pending: " ",
48016
48108
  generating: " ",
@@ -48031,104 +48123,104 @@ var init_run_design = __esm({
48031
48123
  function scanPlatform(rootDir, pattern) {
48032
48124
  const configs = [];
48033
48125
  const platform5 = pattern.platform;
48034
- const platformDir = (0, import_path30.join)(rootDir, pattern.directory);
48126
+ const platformDir = (0, import_path31.join)(rootDir, pattern.directory);
48035
48127
  if (pattern.settingsFile) {
48036
- const settingsPath = (0, import_path30.join)(platformDir, pattern.settingsFile);
48037
- if ((0, import_fs33.existsSync)(settingsPath)) {
48128
+ const settingsPath = (0, import_path31.join)(platformDir, pattern.settingsFile);
48129
+ if ((0, import_fs34.existsSync)(settingsPath)) {
48038
48130
  configs.push({
48039
48131
  platform: platform5,
48040
48132
  type: "settings",
48041
48133
  name: pattern.settingsFile,
48042
48134
  path: settingsPath,
48043
- relativePath: (0, import_path30.relative)(rootDir, settingsPath),
48044
- sizeBytes: (0, import_fs33.statSync)(settingsPath).size
48135
+ relativePath: (0, import_path31.relative)(rootDir, settingsPath),
48136
+ sizeBytes: (0, import_fs34.statSync)(settingsPath).size
48045
48137
  });
48046
48138
  }
48047
48139
  }
48048
48140
  if (pattern.configFile) {
48049
- const configPath = (0, import_path30.join)(platformDir, pattern.configFile);
48050
- if ((0, import_fs33.existsSync)(configPath)) {
48141
+ const configPath = (0, import_path31.join)(platformDir, pattern.configFile);
48142
+ if ((0, import_fs34.existsSync)(configPath)) {
48051
48143
  configs.push({
48052
48144
  platform: platform5,
48053
48145
  type: "settings",
48054
48146
  name: pattern.configFile,
48055
48147
  path: configPath,
48056
- relativePath: (0, import_path30.relative)(rootDir, configPath),
48057
- sizeBytes: (0, import_fs33.statSync)(configPath).size
48148
+ relativePath: (0, import_path31.relative)(rootDir, configPath),
48149
+ sizeBytes: (0, import_fs34.statSync)(configPath).size
48058
48150
  });
48059
48151
  }
48060
48152
  }
48061
48153
  if (pattern.rulesDir) {
48062
- const rulesDir = (0, import_path30.join)(platformDir, pattern.rulesDir);
48063
- if ((0, import_fs33.existsSync)(rulesDir) && (0, import_fs33.statSync)(rulesDir).isDirectory()) {
48154
+ const rulesDir = (0, import_path31.join)(platformDir, pattern.rulesDir);
48155
+ if ((0, import_fs34.existsSync)(rulesDir) && (0, import_fs34.statSync)(rulesDir).isDirectory()) {
48064
48156
  scanDir(rulesDir, rootDir, platform5, "rules", pattern.ruleExtensions, configs);
48065
48157
  }
48066
48158
  }
48067
48159
  if (pattern.rulesFile) {
48068
- const rulesPath = (0, import_path30.join)(platformDir, pattern.rulesFile);
48069
- if ((0, import_fs33.existsSync)(rulesPath)) {
48160
+ const rulesPath = (0, import_path31.join)(platformDir, pattern.rulesFile);
48161
+ if ((0, import_fs34.existsSync)(rulesPath)) {
48070
48162
  configs.push({
48071
48163
  platform: platform5,
48072
48164
  type: "rules",
48073
48165
  name: pattern.rulesFile,
48074
48166
  path: rulesPath,
48075
- relativePath: (0, import_path30.relative)(rootDir, rulesPath),
48076
- sizeBytes: (0, import_fs33.statSync)(rulesPath).size
48167
+ relativePath: (0, import_path31.relative)(rootDir, rulesPath),
48168
+ sizeBytes: (0, import_fs34.statSync)(rulesPath).size
48077
48169
  });
48078
48170
  }
48079
48171
  }
48080
48172
  if (pattern.commandsDir) {
48081
- const commandsDir = (0, import_path30.join)(platformDir, pattern.commandsDir);
48082
- if ((0, import_fs33.existsSync)(commandsDir) && (0, import_fs33.statSync)(commandsDir).isDirectory()) {
48173
+ const commandsDir = (0, import_path31.join)(platformDir, pattern.commandsDir);
48174
+ if ((0, import_fs34.existsSync)(commandsDir) && (0, import_fs34.statSync)(commandsDir).isDirectory()) {
48083
48175
  scanDir(commandsDir, rootDir, platform5, "commands", [".md", ".toml"], configs);
48084
48176
  }
48085
48177
  }
48086
48178
  if (pattern.hooksDir) {
48087
- const hooksDir = (0, import_path30.join)(platformDir, pattern.hooksDir);
48088
- if ((0, import_fs33.existsSync)(hooksDir) && (0, import_fs33.statSync)(hooksDir).isDirectory()) {
48179
+ const hooksDir = (0, import_path31.join)(platformDir, pattern.hooksDir);
48180
+ if ((0, import_fs34.existsSync)(hooksDir) && (0, import_fs34.statSync)(hooksDir).isDirectory()) {
48089
48181
  scanDir(hooksDir, rootDir, platform5, "hooks", [".md", ".json", ".sh", ".ts", ".js"], configs);
48090
48182
  }
48091
48183
  }
48092
48184
  if (pattern.hooksConfigFile) {
48093
- const hooksConfigPath = (0, import_path30.join)(platformDir, pattern.hooksConfigFile);
48094
- if ((0, import_fs33.existsSync)(hooksConfigPath)) {
48185
+ const hooksConfigPath = (0, import_path31.join)(platformDir, pattern.hooksConfigFile);
48186
+ if ((0, import_fs34.existsSync)(hooksConfigPath)) {
48095
48187
  configs.push({
48096
48188
  platform: platform5,
48097
48189
  type: "hooks",
48098
48190
  name: pattern.hooksConfigFile,
48099
48191
  path: hooksConfigPath,
48100
- relativePath: (0, import_path30.relative)(rootDir, hooksConfigPath),
48101
- sizeBytes: (0, import_fs33.statSync)(hooksConfigPath).size
48192
+ relativePath: (0, import_path31.relative)(rootDir, hooksConfigPath),
48193
+ sizeBytes: (0, import_fs34.statSync)(hooksConfigPath).size
48102
48194
  });
48103
48195
  }
48104
48196
  }
48105
48197
  if (pattern.agentsDir) {
48106
- const agentsDir = (0, import_path30.join)(platformDir, pattern.agentsDir);
48107
- if ((0, import_fs33.existsSync)(agentsDir) && (0, import_fs33.statSync)(agentsDir).isDirectory()) {
48198
+ const agentsDir = (0, import_path31.join)(platformDir, pattern.agentsDir);
48199
+ if ((0, import_fs34.existsSync)(agentsDir) && (0, import_fs34.statSync)(agentsDir).isDirectory()) {
48108
48200
  scanDir(agentsDir, rootDir, platform5, "agents", [".md", ".toml", ".agent.md"], configs);
48109
48201
  }
48110
48202
  }
48111
48203
  if (pattern.skillsDir) {
48112
- const skillsDir = (0, import_path30.join)(platformDir, pattern.skillsDir);
48113
- if ((0, import_fs33.existsSync)(skillsDir) && (0, import_fs33.statSync)(skillsDir).isDirectory()) {
48204
+ const skillsDir = (0, import_path31.join)(platformDir, pattern.skillsDir);
48205
+ if ((0, import_fs34.existsSync)(skillsDir) && (0, import_fs34.statSync)(skillsDir).isDirectory()) {
48114
48206
  scanDir(skillsDir, rootDir, platform5, "skills", [".md"], configs);
48115
48207
  }
48116
48208
  }
48117
48209
  if (pattern.policiesDir) {
48118
- const policiesDir = (0, import_path30.join)(platformDir, pattern.policiesDir);
48119
- if ((0, import_fs33.existsSync)(policiesDir) && (0, import_fs33.statSync)(policiesDir).isDirectory()) {
48210
+ const policiesDir = (0, import_path31.join)(platformDir, pattern.policiesDir);
48211
+ if ((0, import_fs34.existsSync)(policiesDir) && (0, import_fs34.statSync)(policiesDir).isDirectory()) {
48120
48212
  scanDir(policiesDir, rootDir, platform5, "policies", [".toml", ".md"], configs);
48121
48213
  }
48122
48214
  }
48123
48215
  if (pattern.workflowsDir) {
48124
- const workflowsDir = (0, import_path30.join)(platformDir, pattern.workflowsDir);
48125
- if ((0, import_fs33.existsSync)(workflowsDir) && (0, import_fs33.statSync)(workflowsDir).isDirectory()) {
48216
+ const workflowsDir = (0, import_path31.join)(platformDir, pattern.workflowsDir);
48217
+ if ((0, import_fs34.existsSync)(workflowsDir) && (0, import_fs34.statSync)(workflowsDir).isDirectory()) {
48126
48218
  scanDir(workflowsDir, rootDir, platform5, "workflows", [".md"], configs);
48127
48219
  }
48128
48220
  }
48129
48221
  if (pattern.promptsDir) {
48130
- const promptsDir = (0, import_path30.join)(platformDir, pattern.promptsDir);
48131
- if ((0, import_fs33.existsSync)(promptsDir) && (0, import_fs33.statSync)(promptsDir).isDirectory()) {
48222
+ const promptsDir = (0, import_path31.join)(platformDir, pattern.promptsDir);
48223
+ if ((0, import_fs34.existsSync)(promptsDir) && (0, import_fs34.statSync)(promptsDir).isDirectory()) {
48132
48224
  scanDir(promptsDir, rootDir, platform5, "prompts", [".prompt.md", ".md"], configs);
48133
48225
  }
48134
48226
  }
@@ -48147,59 +48239,59 @@ function scanPlatform(rootDir, pattern) {
48147
48239
  for (const { key, type } of rootInstructionFiles) {
48148
48240
  const fileName = pattern[key];
48149
48241
  if (fileName) {
48150
- const rootPath = (0, import_path30.join)(rootDir, fileName);
48151
- const platformPath = (0, import_path30.join)(platformDir, fileName);
48152
- if ((0, import_fs33.existsSync)(rootPath)) {
48242
+ const rootPath = (0, import_path31.join)(rootDir, fileName);
48243
+ const platformPath = (0, import_path31.join)(platformDir, fileName);
48244
+ if ((0, import_fs34.existsSync)(rootPath)) {
48153
48245
  configs.push({
48154
48246
  platform: platform5,
48155
48247
  type,
48156
48248
  name: fileName,
48157
48249
  path: rootPath,
48158
- relativePath: (0, import_path30.relative)(rootDir, rootPath),
48159
- sizeBytes: (0, import_fs33.statSync)(rootPath).size
48250
+ relativePath: (0, import_path31.relative)(rootDir, rootPath),
48251
+ sizeBytes: (0, import_fs34.statSync)(rootPath).size
48160
48252
  });
48161
- } else if ((0, import_fs33.existsSync)(platformPath) && platformPath !== rootPath) {
48253
+ } else if ((0, import_fs34.existsSync)(platformPath) && platformPath !== rootPath) {
48162
48254
  configs.push({
48163
48255
  platform: platform5,
48164
48256
  type,
48165
48257
  name: fileName,
48166
48258
  path: platformPath,
48167
- relativePath: (0, import_path30.relative)(rootDir, platformPath),
48168
- sizeBytes: (0, import_fs33.statSync)(platformPath).size
48259
+ relativePath: (0, import_path31.relative)(rootDir, platformPath),
48260
+ sizeBytes: (0, import_fs34.statSync)(platformPath).size
48169
48261
  });
48170
48262
  }
48171
48263
  }
48172
48264
  }
48173
48265
  if (pattern.mcpFile) {
48174
- const mcpPath = (0, import_path30.join)(rootDir, pattern.mcpFile);
48175
- if ((0, import_fs33.existsSync)(mcpPath)) {
48266
+ const mcpPath = (0, import_path31.join)(rootDir, pattern.mcpFile);
48267
+ if ((0, import_fs34.existsSync)(mcpPath)) {
48176
48268
  configs.push({
48177
48269
  platform: platform5,
48178
48270
  type: "mcp",
48179
48271
  name: pattern.mcpFile,
48180
48272
  path: mcpPath,
48181
- relativePath: (0, import_path30.relative)(rootDir, mcpPath),
48182
- sizeBytes: (0, import_fs33.statSync)(mcpPath).size
48273
+ relativePath: (0, import_path31.relative)(rootDir, mcpPath),
48274
+ sizeBytes: (0, import_fs34.statSync)(mcpPath).size
48183
48275
  });
48184
48276
  }
48185
48277
  }
48186
48278
  if (pattern.memoryDir) {
48187
- const memDir = (0, import_path30.join)(platformDir, pattern.memoryDir);
48188
- if ((0, import_fs33.existsSync)(memDir) && (0, import_fs33.statSync)(memDir).isDirectory()) {
48279
+ const memDir = (0, import_path31.join)(platformDir, pattern.memoryDir);
48280
+ if ((0, import_fs34.existsSync)(memDir) && (0, import_fs34.statSync)(memDir).isDirectory()) {
48189
48281
  const exts = pattern.memoryExtensions || [".md"];
48190
48282
  scanDir(memDir, rootDir, platform5, "memory", exts, configs);
48191
48283
  }
48192
48284
  }
48193
48285
  if (pattern.cliConfigFile) {
48194
- const cliPath = (0, import_path30.join)(platformDir, pattern.cliConfigFile);
48195
- if ((0, import_fs33.existsSync)(cliPath)) {
48286
+ const cliPath = (0, import_path31.join)(platformDir, pattern.cliConfigFile);
48287
+ if ((0, import_fs34.existsSync)(cliPath)) {
48196
48288
  configs.push({
48197
48289
  platform: platform5,
48198
48290
  type: "settings",
48199
48291
  name: pattern.cliConfigFile,
48200
48292
  path: cliPath,
48201
- relativePath: (0, import_path30.relative)(rootDir, cliPath),
48202
- sizeBytes: (0, import_fs33.statSync)(cliPath).size
48293
+ relativePath: (0, import_path31.relative)(rootDir, cliPath),
48294
+ sizeBytes: (0, import_fs34.statSync)(cliPath).size
48203
48295
  });
48204
48296
  }
48205
48297
  }
@@ -48207,9 +48299,9 @@ function scanPlatform(rootDir, pattern) {
48207
48299
  }
48208
48300
  function scanDir(dir, rootDir, platform5, type, extensions, configs) {
48209
48301
  try {
48210
- const entries = (0, import_fs33.readdirSync)(dir, { withFileTypes: true });
48302
+ const entries = (0, import_fs34.readdirSync)(dir, { withFileTypes: true });
48211
48303
  for (const entry of entries) {
48212
- const fullPath = (0, import_path30.join)(dir, entry.name);
48304
+ const fullPath = (0, import_path31.join)(dir, entry.name);
48213
48305
  if (entry.isDirectory()) {
48214
48306
  scanDir(fullPath, rootDir, platform5, type, extensions, configs);
48215
48307
  } else if (entry.isFile()) {
@@ -48220,8 +48312,8 @@ function scanDir(dir, rootDir, platform5, type, extensions, configs) {
48220
48312
  type,
48221
48313
  name: entry.name,
48222
48314
  path: fullPath,
48223
- relativePath: (0, import_path30.relative)(rootDir, fullPath),
48224
- sizeBytes: (0, import_fs33.statSync)(fullPath).size
48315
+ relativePath: (0, import_path31.relative)(rootDir, fullPath),
48316
+ sizeBytes: (0, import_fs34.statSync)(fullPath).size
48225
48317
  });
48226
48318
  }
48227
48319
  }
@@ -48238,7 +48330,7 @@ function createScanCommand() {
48238
48330
  const command = new Command("scan");
48239
48331
  command.description("Scan local directory for AI agent configurations (no auth required)").option("--path <path>", "Directory to scan (default: current directory or project root)").option("-p, --platform <platform>", `Filter by platform (${ALL_PLATFORM_IDS.join(", ")})`).option("--format <format>", "Output format: table (default) or json", "table").option("-r, --recursive", "Scan subdirectories for additional projects").option("--include-global", "Include global/home-directory memory locations").action(async (options) => {
48240
48332
  const targetDir = options.path ? options.path : findProjectRoot(process.cwd());
48241
- if (!(0, import_fs33.existsSync)(targetDir)) {
48333
+ if (!(0, import_fs34.existsSync)(targetDir)) {
48242
48334
  console.error(source_default.red(`Directory not found: ${targetDir}`));
48243
48335
  process.exit(1);
48244
48336
  }
@@ -48269,12 +48361,12 @@ function createScanCommand() {
48269
48361
  }
48270
48362
  }
48271
48363
  if (options.includeGlobal) {
48272
- const home = (0, import_os22.homedir)();
48364
+ const home = (0, import_os23.homedir)();
48273
48365
  for (const loc of GLOBAL_MEMORY_LOCATIONS) {
48274
48366
  if (platformFilter && loc.platform !== platformFilter) continue;
48275
48367
  for (const relPath of loc.paths) {
48276
- const globalDir = (0, import_path30.join)(home, relPath);
48277
- if (!(0, import_fs33.existsSync)(globalDir) || !(0, import_fs33.statSync)(globalDir).isDirectory()) continue;
48368
+ const globalDir = (0, import_path31.join)(home, relPath);
48369
+ if (!(0, import_fs34.existsSync)(globalDir) || !(0, import_fs34.statSync)(globalDir).isDirectory()) continue;
48278
48370
  const globalConfigs = [];
48279
48371
  scanDir(globalDir, home, loc.platform, "memory", loc.extensions, globalConfigs);
48280
48372
  if (globalConfigs.length > 0) {
@@ -48350,15 +48442,15 @@ function createScanCommand() {
48350
48442
  });
48351
48443
  return command;
48352
48444
  }
48353
- var import_fs33, import_path30, import_os22, GLOBAL_MEMORY_LOCATIONS, PLATFORM_LABELS, PLATFORM_COLORS;
48445
+ var import_fs34, import_path31, import_os23, GLOBAL_MEMORY_LOCATIONS, PLATFORM_LABELS, PLATFORM_COLORS;
48354
48446
  var init_scan = __esm({
48355
48447
  "src/commands/scan.ts"() {
48356
48448
  "use strict";
48357
48449
  init_esm();
48358
48450
  init_source();
48359
- import_fs33 = require("fs");
48360
- import_path30 = require("path");
48361
- import_os22 = require("os");
48451
+ import_fs34 = require("fs");
48452
+ import_path31 = require("path");
48453
+ import_os23 = require("os");
48362
48454
  init_dist2();
48363
48455
  init_project_detection();
48364
48456
  GLOBAL_MEMORY_LOCATIONS = [
@@ -49030,8 +49122,8 @@ function createSandboxCommand() {
49030
49122
  return sandboxCmd;
49031
49123
  }
49032
49124
  async function validateConfigFile(sandbox, options) {
49033
- const configPath = import_path31.default.resolve(options.config);
49034
- const fileName = import_path31.default.basename(configPath);
49125
+ const configPath = import_path32.default.resolve(options.config);
49126
+ const fileName = import_path32.default.basename(configPath);
49035
49127
  const spinner = ora(`Loading configuration: ${fileName}`).start();
49036
49128
  try {
49037
49129
  const configContent = await import_promises8.default.readFile(configPath, "utf-8");
@@ -49146,7 +49238,7 @@ async function startInteractiveSession(sandbox) {
49146
49238
  rl.on("close", resolve8);
49147
49239
  });
49148
49240
  }
49149
- var import_promises8, import_path31;
49241
+ var import_promises8, import_path32;
49150
49242
  var init_sandbox = __esm({
49151
49243
  "src/commands/sandbox.ts"() {
49152
49244
  "use strict";
@@ -49155,7 +49247,7 @@ var init_sandbox = __esm({
49155
49247
  init_ora();
49156
49248
  init_e2b_sandbox();
49157
49249
  import_promises8 = __toESM(require("fs/promises"), 1);
49158
- import_path31 = __toESM(require("path"), 1);
49250
+ import_path32 = __toESM(require("path"), 1);
49159
49251
  }
49160
49252
  });
49161
49253
 
@@ -49164,7 +49256,7 @@ function isTestFile(filename) {
49164
49256
  return /\.(test|spec)\.(ts|tsx|js|jsx)$/.test(filename);
49165
49257
  }
49166
49258
  function isImplFile(filename) {
49167
- const ext = (0, import_path32.extname)(filename);
49259
+ const ext = (0, import_path33.extname)(filename);
49168
49260
  if (!IMPL_EXTENSIONS.has(ext)) return false;
49169
49261
  if (isTestFile(filename)) return false;
49170
49262
  if (IGNORE_FILES.has(filename)) return false;
@@ -49179,16 +49271,16 @@ function scanDirectory(dir, maxDepth = 6) {
49179
49271
  if (depth > maxDepth) return;
49180
49272
  let entries;
49181
49273
  try {
49182
- entries = (0, import_fs34.readdirSync)(currentDir);
49274
+ entries = (0, import_fs35.readdirSync)(currentDir);
49183
49275
  } catch {
49184
49276
  return;
49185
49277
  }
49186
49278
  for (const entry of entries) {
49187
49279
  if (IGNORE_DIRS.has(entry)) continue;
49188
- const fullPath = (0, import_path32.join)(currentDir, entry);
49280
+ const fullPath = (0, import_path33.join)(currentDir, entry);
49189
49281
  let stat5;
49190
49282
  try {
49191
- stat5 = (0, import_fs34.statSync)(fullPath);
49283
+ stat5 = (0, import_fs35.statSync)(fullPath);
49192
49284
  } catch {
49193
49285
  continue;
49194
49286
  }
@@ -49198,7 +49290,7 @@ function scanDirectory(dir, maxDepth = 6) {
49198
49290
  }
49199
49291
  walk(fullPath, depth + 1);
49200
49292
  } else if (stat5.isFile()) {
49201
- const relPath = (0, import_path32.relative)(dir, fullPath);
49293
+ const relPath = (0, import_path33.relative)(dir, fullPath);
49202
49294
  if (isTestFile(entry)) {
49203
49295
  testFiles.push(relPath);
49204
49296
  } else if (isImplFile(entry)) {
@@ -49218,15 +49310,15 @@ function findSpecFiles(dir) {
49218
49310
  if (depth > 4) return;
49219
49311
  let entries;
49220
49312
  try {
49221
- entries = (0, import_fs34.readdirSync)(currentDir);
49313
+ entries = (0, import_fs35.readdirSync)(currentDir);
49222
49314
  } catch {
49223
49315
  return;
49224
49316
  }
49225
49317
  for (const entry of entries) {
49226
- const fullPath = (0, import_path32.join)(currentDir, entry);
49318
+ const fullPath = (0, import_path33.join)(currentDir, entry);
49227
49319
  let stat5;
49228
49320
  try {
49229
- stat5 = (0, import_fs34.statSync)(fullPath);
49321
+ stat5 = (0, import_fs35.statSync)(fullPath);
49230
49322
  } catch {
49231
49323
  continue;
49232
49324
  }
@@ -49242,10 +49334,10 @@ function findSpecFiles(dir) {
49242
49334
  }
49243
49335
  function findImplFilesWithoutTests(implFiles, testFiles) {
49244
49336
  const testBasenames = new Set(
49245
- testFiles.map((f) => (0, import_path32.basename)(f).replace(/\.(test|spec)\.(ts|tsx|js|jsx)$/, ""))
49337
+ testFiles.map((f) => (0, import_path33.basename)(f).replace(/\.(test|spec)\.(ts|tsx|js|jsx)$/, ""))
49246
49338
  );
49247
49339
  return implFiles.filter((f) => {
49248
- const base = (0, import_path32.basename)(f).replace(/\.(ts|tsx|js|jsx)$/, "");
49340
+ const base = (0, import_path33.basename)(f).replace(/\.(ts|tsx|js|jsx)$/, "");
49249
49341
  return !testBasenames.has(base);
49250
49342
  });
49251
49343
  }
@@ -49275,8 +49367,8 @@ function runChecks(basePath) {
49275
49367
  const weight2 = 25;
49276
49368
  maxScore += weight2;
49277
49369
  const hasSpecs = specFiles.length > 0;
49278
- const hasClaudeDir = (0, import_fs34.existsSync)((0, import_path32.join)(basePath, ".claude"));
49279
- const hasSpecsDir = (0, import_fs34.existsSync)((0, import_path32.join)(basePath, "specs"));
49370
+ const hasClaudeDir = (0, import_fs35.existsSync)((0, import_path33.join)(basePath, ".claude"));
49371
+ const hasSpecsDir = (0, import_fs35.existsSync)((0, import_path33.join)(basePath, "specs"));
49280
49372
  let specScore = 0;
49281
49373
  if (hasSpecs) specScore += 15;
49282
49374
  if (hasClaudeDir) specScore += 5;
@@ -49295,8 +49387,8 @@ function runChecks(basePath) {
49295
49387
  }
49296
49388
  const weight3 = 15;
49297
49389
  maxScore += weight3;
49298
- const hasClaudeMd = (0, import_fs34.existsSync)((0, import_path32.join)(basePath, "CLAUDE.md"));
49299
- const hasClaudeSettings = (0, import_fs34.existsSync)((0, import_path32.join)(basePath, ".claude", "settings.json"));
49390
+ const hasClaudeMd = (0, import_fs35.existsSync)((0, import_path33.join)(basePath, "CLAUDE.md"));
49391
+ const hasClaudeSettings = (0, import_fs35.existsSync)((0, import_path33.join)(basePath, ".claude", "settings.json"));
49300
49392
  let claudeScore = 0;
49301
49393
  if (hasClaudeMd) claudeScore += 10;
49302
49394
  if (hasClaudeSettings) claudeScore += 5;
@@ -49314,9 +49406,9 @@ function runChecks(basePath) {
49314
49406
  }
49315
49407
  const weight4 = 15;
49316
49408
  maxScore += weight4;
49317
- const hasPackageJson = (0, import_fs34.existsSync)((0, import_path32.join)(basePath, "package.json"));
49318
- const hasReadme = (0, import_fs34.existsSync)((0, import_path32.join)(basePath, "README.md"));
49319
- const hasTsConfig = (0, import_fs34.existsSync)((0, import_path32.join)(basePath, "tsconfig.json"));
49409
+ const hasPackageJson = (0, import_fs35.existsSync)((0, import_path33.join)(basePath, "package.json"));
49410
+ const hasReadme = (0, import_fs35.existsSync)((0, import_path33.join)(basePath, "README.md"));
49411
+ const hasTsConfig = (0, import_fs35.existsSync)((0, import_path33.join)(basePath, "tsconfig.json"));
49320
49412
  let structureScore = 0;
49321
49413
  if (hasPackageJson) structureScore += 5;
49322
49414
  if (hasReadme) structureScore += 5;
@@ -49336,9 +49428,9 @@ function runChecks(basePath) {
49336
49428
  });
49337
49429
  const weight5 = 15;
49338
49430
  maxScore += weight5;
49339
- const hasGitDir = (0, import_fs34.existsSync)((0, import_path32.join)(basePath, ".git"));
49340
- const hasGithubDir = (0, import_fs34.existsSync)((0, import_path32.join)(basePath, ".github"));
49341
- const hasWorkflows = (0, import_fs34.existsSync)((0, import_path32.join)(basePath, ".github", "workflows"));
49431
+ const hasGitDir = (0, import_fs35.existsSync)((0, import_path33.join)(basePath, ".git"));
49432
+ const hasGithubDir = (0, import_fs35.existsSync)((0, import_path33.join)(basePath, ".github"));
49433
+ const hasWorkflows = (0, import_fs35.existsSync)((0, import_path33.join)(basePath, ".github", "workflows"));
49342
49434
  let gitScore = 0;
49343
49435
  if (hasGitDir) gitScore += 5;
49344
49436
  if (hasGithubDir) gitScore += 5;
@@ -49677,8 +49769,8 @@ function createSdlcCommand() {
49677
49769
  spinner.start("Scanning git history and local artifacts...");
49678
49770
  const basePath = process.cwd();
49679
49771
  const SDLC_PHASES_ORDERED = ["specify", "design", "test", "implement", "deploy-verify", "review", "merge"];
49680
- const hasSpec = (0, import_fs34.existsSync)((0, import_path32.join)(basePath, "spec.md")) || (0, import_fs34.existsSync)((0, import_path32.join)(basePath, "specs")) || (0, import_fs34.existsSync)((0, import_path32.join)(basePath, ".claude", "spec.md"));
49681
- const hasPlan = (0, import_fs34.existsSync)((0, import_path32.join)(basePath, "plan.md")) || (0, import_fs34.existsSync)((0, import_path32.join)(basePath, ".claude", "plan.md")) || (0, import_fs34.existsSync)((0, import_path32.join)(basePath, "tasks.md"));
49772
+ const hasSpec = (0, import_fs35.existsSync)((0, import_path33.join)(basePath, "spec.md")) || (0, import_fs35.existsSync)((0, import_path33.join)(basePath, "specs")) || (0, import_fs35.existsSync)((0, import_path33.join)(basePath, ".claude", "spec.md"));
49773
+ const hasPlan = (0, import_fs35.existsSync)((0, import_path33.join)(basePath, "plan.md")) || (0, import_fs35.existsSync)((0, import_path33.join)(basePath, ".claude", "plan.md")) || (0, import_fs35.existsSync)((0, import_path33.join)(basePath, "tasks.md"));
49682
49774
  const scanResult = scanDirectory(basePath);
49683
49775
  const hasTests = scanResult.testFiles.length > 0;
49684
49776
  const hasImpl = scanResult.implFiles.length > 0;
@@ -49821,15 +49913,15 @@ function createSdlcCommand() {
49821
49913
  });
49822
49914
  return cmd;
49823
49915
  }
49824
- var import_fs34, import_path32, import_child_process10, IMPL_EXTENSIONS, IGNORE_DIRS, IGNORE_FILES;
49916
+ var import_fs35, import_path33, import_child_process10, IMPL_EXTENSIONS, IGNORE_DIRS, IGNORE_FILES;
49825
49917
  var init_sdlc = __esm({
49826
49918
  "src/commands/sdlc.ts"() {
49827
49919
  "use strict";
49828
49920
  init_esm();
49829
49921
  init_source();
49830
49922
  init_ora();
49831
- import_fs34 = require("fs");
49832
- import_path32 = require("path");
49923
+ import_fs35 = require("fs");
49924
+ import_path33 = require("path");
49833
49925
  import_child_process10 = require("child_process");
49834
49926
  init_config_manager();
49835
49927
  IMPL_EXTENSIONS = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx"]);
@@ -49948,10 +50040,10 @@ var init_security = __esm({
49948
50040
 
49949
50041
  // src/commands/status.ts
49950
50042
  function readTermsAcceptance() {
49951
- const configFile = (0, import_path33.join)((0, import_os23.homedir)(), ".gal", "config.json");
50043
+ const configFile = (0, import_path34.join)((0, import_os24.homedir)(), ".gal", "config.json");
49952
50044
  try {
49953
- if ((0, import_fs35.existsSync)(configFile)) {
49954
- const raw = JSON.parse((0, import_fs35.readFileSync)(configFile, "utf-8"));
50045
+ if ((0, import_fs36.existsSync)(configFile)) {
50046
+ const raw = JSON.parse((0, import_fs36.readFileSync)(configFile, "utf-8"));
49955
50047
  if (typeof raw.termsAcceptedAt === "string" && raw.termsAcceptedAt.length > 0) {
49956
50048
  return { accepted: true, acceptedAt: raw.termsAcceptedAt };
49957
50049
  }
@@ -50123,7 +50215,7 @@ function displayStatusJson(result, health) {
50123
50215
  }
50124
50216
  function isRateLimited(projectId) {
50125
50217
  try {
50126
- const raw = (0, import_fs35.readFileSync)(DRIFT_REPORT_CACHE_PATH, "utf-8");
50218
+ const raw = (0, import_fs36.readFileSync)(DRIFT_REPORT_CACHE_PATH, "utf-8");
50127
50219
  const cache = JSON.parse(raw);
50128
50220
  const lastReport = cache[projectId];
50129
50221
  if (lastReport && Date.now() - lastReport < RATE_LIMIT_MS) {
@@ -50137,13 +50229,13 @@ function recordReport(projectId) {
50137
50229
  try {
50138
50230
  let cache = {};
50139
50231
  try {
50140
- const raw = (0, import_fs35.readFileSync)(DRIFT_REPORT_CACHE_PATH, "utf-8");
50232
+ const raw = (0, import_fs36.readFileSync)(DRIFT_REPORT_CACHE_PATH, "utf-8");
50141
50233
  cache = JSON.parse(raw);
50142
50234
  } catch {
50143
50235
  }
50144
50236
  cache[projectId] = Date.now();
50145
- (0, import_fs35.mkdirSync)((0, import_path33.join)((0, import_os23.homedir)(), ".gal"), { recursive: true });
50146
- (0, import_fs35.writeFileSync)(DRIFT_REPORT_CACHE_PATH, JSON.stringify(cache));
50237
+ (0, import_fs36.mkdirSync)((0, import_path34.join)((0, import_os24.homedir)(), ".gal"), { recursive: true });
50238
+ (0, import_fs36.writeFileSync)(DRIFT_REPORT_CACHE_PATH, JSON.stringify(cache));
50147
50239
  } catch {
50148
50240
  }
50149
50241
  }
@@ -50248,16 +50340,16 @@ function createStatusCommand2() {
50248
50340
  });
50249
50341
  return command;
50250
50342
  }
50251
- var import_path33, import_os23, import_fs35, cliVersion6, defaultApiUrl15, PLATFORM_LABELS2, RATE_LIMIT_MS, DRIFT_REPORT_CACHE_PATH;
50343
+ var import_path34, import_os24, import_fs36, cliVersion6, defaultApiUrl15, PLATFORM_LABELS2, RATE_LIMIT_MS, DRIFT_REPORT_CACHE_PATH;
50252
50344
  var init_status = __esm({
50253
50345
  "src/commands/status.ts"() {
50254
50346
  "use strict";
50255
50347
  init_esm();
50256
50348
  init_source();
50257
50349
  init_ora();
50258
- import_path33 = require("path");
50259
- import_os23 = require("os");
50260
- import_fs35 = require("fs");
50350
+ import_path34 = require("path");
50351
+ import_os24 = require("os");
50352
+ import_fs36 = require("fs");
50261
50353
  init_gal_config_service();
50262
50354
  init_config_manager();
50263
50355
  init_CoreServiceProvider();
@@ -50273,7 +50365,7 @@ var init_status = __esm({
50273
50365
  ])
50274
50366
  );
50275
50367
  RATE_LIMIT_MS = 5 * 60 * 1e3;
50276
- DRIFT_REPORT_CACHE_PATH = (0, import_path33.join)((0, import_os23.homedir)(), ".gal", "drift-report-cache.json");
50368
+ DRIFT_REPORT_CACHE_PATH = (0, import_path34.join)((0, import_os24.homedir)(), ".gal", "drift-report-cache.json");
50277
50369
  }
50278
50370
  });
50279
50371
 
@@ -51601,13 +51693,13 @@ function getGitHookManager() {
51601
51693
  }
51602
51694
  return defaultManager;
51603
51695
  }
51604
- var import_child_process11, import_fs36, import_path34, DEFAULT_GIT_HOOK_CONFIG, GitHookManager, defaultManager;
51696
+ var import_child_process11, import_fs37, import_path35, DEFAULT_GIT_HOOK_CONFIG, GitHookManager, defaultManager;
51605
51697
  var init_git_hooks = __esm({
51606
51698
  "src/triggers/git-hooks.ts"() {
51607
51699
  "use strict";
51608
51700
  import_child_process11 = require("child_process");
51609
- import_fs36 = require("fs");
51610
- import_path34 = require("path");
51701
+ import_fs37 = require("fs");
51702
+ import_path35 = require("path");
51611
51703
  init_source();
51612
51704
  init_triggers();
51613
51705
  DEFAULT_GIT_HOOK_CONFIG = {
@@ -51650,12 +51742,12 @@ var init_git_hooks = __esm({
51650
51742
  if (this.gitDir) return this.gitDir;
51651
51743
  let currentPath = startPath;
51652
51744
  while (currentPath !== "/") {
51653
- const gitPath = (0, import_path34.join)(currentPath, ".git");
51654
- if ((0, import_fs36.existsSync)(gitPath)) {
51745
+ const gitPath = (0, import_path35.join)(currentPath, ".git");
51746
+ if ((0, import_fs37.existsSync)(gitPath)) {
51655
51747
  this.gitDir = gitPath;
51656
51748
  return gitPath;
51657
51749
  }
51658
- currentPath = (0, import_path34.dirname)(currentPath);
51750
+ currentPath = (0, import_path35.dirname)(currentPath);
51659
51751
  }
51660
51752
  return null;
51661
51753
  }
@@ -51677,29 +51769,29 @@ var init_git_hooks = __esm({
51677
51769
  ]
51678
51770
  };
51679
51771
  }
51680
- const hooksDir = (0, import_path34.join)(gitDir, "hooks");
51681
- if (!(0, import_fs36.existsSync)(hooksDir)) {
51682
- (0, import_fs36.mkdirSync)(hooksDir, { recursive: true });
51772
+ const hooksDir = (0, import_path35.join)(gitDir, "hooks");
51773
+ if (!(0, import_fs37.existsSync)(hooksDir)) {
51774
+ (0, import_fs37.mkdirSync)(hooksDir, { recursive: true });
51683
51775
  }
51684
51776
  const installed = [];
51685
51777
  const skipped = [];
51686
51778
  const warnings = [];
51687
51779
  for (const hookType of this.config.hooks) {
51688
- const hookPath = (0, import_path34.join)(hooksDir, hookType);
51780
+ const hookPath = (0, import_path35.join)(hooksDir, hookType);
51689
51781
  const hookScript = this.generateHookScript(hookType);
51690
- if ((0, import_fs36.existsSync)(hookPath)) {
51691
- const existing = (0, import_fs36.readFileSync)(hookPath, "utf-8");
51782
+ if ((0, import_fs37.existsSync)(hookPath)) {
51783
+ const existing = (0, import_fs37.readFileSync)(hookPath, "utf-8");
51692
51784
  if (existing.includes("GAL_HOOK_MARKER")) {
51693
- (0, import_fs36.writeFileSync)(hookPath, hookScript);
51694
- (0, import_fs36.chmodSync)(hookPath, "755");
51785
+ (0, import_fs37.writeFileSync)(hookPath, hookScript);
51786
+ (0, import_fs37.chmodSync)(hookPath, "755");
51695
51787
  installed.push(hookType);
51696
51788
  } else {
51697
51789
  console.log(source_default.yellow(`Skipping ${hookType}: existing hook found`));
51698
51790
  skipped.push(hookType);
51699
51791
  }
51700
51792
  } else {
51701
- (0, import_fs36.writeFileSync)(hookPath, hookScript);
51702
- (0, import_fs36.chmodSync)(hookPath, "755");
51793
+ (0, import_fs37.writeFileSync)(hookPath, hookScript);
51794
+ (0, import_fs37.chmodSync)(hookPath, "755");
51703
51795
  installed.push(hookType);
51704
51796
  }
51705
51797
  }
@@ -51716,12 +51808,12 @@ var init_git_hooks = __esm({
51716
51808
  if (!gitDir) {
51717
51809
  return [];
51718
51810
  }
51719
- const hooksDir = (0, import_path34.join)(gitDir, "hooks");
51811
+ const hooksDir = (0, import_path35.join)(gitDir, "hooks");
51720
51812
  const removed = [];
51721
51813
  for (const hookType of this.config.hooks) {
51722
- const hookPath = (0, import_path34.join)(hooksDir, hookType);
51723
- if ((0, import_fs36.existsSync)(hookPath)) {
51724
- const content = (0, import_fs36.readFileSync)(hookPath, "utf-8");
51814
+ const hookPath = (0, import_path35.join)(hooksDir, hookType);
51815
+ if ((0, import_fs37.existsSync)(hookPath)) {
51816
+ const content = (0, import_fs37.readFileSync)(hookPath, "utf-8");
51725
51817
  if (content.includes("GAL_HOOK_MARKER")) {
51726
51818
  const { unlinkSync: unlinkSync6 } = require("fs");
51727
51819
  unlinkSync6(hookPath);
@@ -51944,13 +52036,13 @@ exit 0
51944
52036
  if (!gitDir) {
51945
52037
  return { installed: [], missing: this.config.hooks };
51946
52038
  }
51947
- const hooksDir = (0, import_path34.join)(gitDir, "hooks");
52039
+ const hooksDir = (0, import_path35.join)(gitDir, "hooks");
51948
52040
  const installed = [];
51949
52041
  const missing = [];
51950
52042
  for (const hookType of this.config.hooks) {
51951
- const hookPath = (0, import_path34.join)(hooksDir, hookType);
51952
- if ((0, import_fs36.existsSync)(hookPath)) {
51953
- const content = (0, import_fs36.readFileSync)(hookPath, "utf-8");
52043
+ const hookPath = (0, import_path35.join)(hooksDir, hookType);
52044
+ if ((0, import_fs37.existsSync)(hookPath)) {
52045
+ const content = (0, import_fs37.readFileSync)(hookPath, "utf-8");
51954
52046
  if (content.includes("GAL_HOOK_MARKER")) {
51955
52047
  installed.push(hookType);
51956
52048
  } else {
@@ -51974,12 +52066,12 @@ function getFileWatcher() {
51974
52066
  }
51975
52067
  return defaultWatcher;
51976
52068
  }
51977
- var import_fs37, import_path35, DEFAULT_FILE_WATCHER_CONFIG, AGENT_CONFIG_PATTERNS, FileWatcher, defaultWatcher;
52069
+ var import_fs38, import_path36, DEFAULT_FILE_WATCHER_CONFIG, AGENT_CONFIG_PATTERNS, FileWatcher, defaultWatcher;
51978
52070
  var init_file_watcher = __esm({
51979
52071
  "src/triggers/file-watcher.ts"() {
51980
52072
  "use strict";
51981
- import_fs37 = require("fs");
51982
- import_path35 = require("path");
52073
+ import_fs38 = require("fs");
52074
+ import_path36 = require("path");
51983
52075
  init_source();
51984
52076
  init_triggers();
51985
52077
  DEFAULT_FILE_WATCHER_CONFIG = {
@@ -52035,13 +52127,13 @@ var init_file_watcher = __esm({
52035
52127
  const watching = [];
52036
52128
  const notFound = [];
52037
52129
  for (const watchPath of this.config.watchPaths) {
52038
- const fullPath = (0, import_path35.join)(basePath, watchPath);
52039
- if (!(0, import_fs37.existsSync)(fullPath)) {
52130
+ const fullPath = (0, import_path36.join)(basePath, watchPath);
52131
+ if (!(0, import_fs38.existsSync)(fullPath)) {
52040
52132
  notFound.push(watchPath);
52041
52133
  continue;
52042
52134
  }
52043
52135
  try {
52044
- const watcher = (0, import_fs37.watch)(
52136
+ const watcher = (0, import_fs38.watch)(
52045
52137
  fullPath,
52046
52138
  { recursive: this.config.recursive },
52047
52139
  (eventType, filename) => {
@@ -52088,7 +52180,7 @@ var init_file_watcher = __esm({
52088
52180
  * @returns True if the file matches any ignore pattern and should be skipped
52089
52181
  */
52090
52182
  shouldIgnore(filename) {
52091
- const name = (0, import_path35.basename)(filename);
52183
+ const name = (0, import_path36.basename)(filename);
52092
52184
  for (const pattern of this.config.ignorePatterns) {
52093
52185
  if (pattern.startsWith("*")) {
52094
52186
  if (name.endsWith(pattern.slice(1))) {
@@ -52114,7 +52206,7 @@ var init_file_watcher = __esm({
52114
52206
  * @param filename - The name of the file that changed
52115
52207
  */
52116
52208
  handleFileEvent(eventType, watchPath, filename) {
52117
- const fullPath = (0, import_path35.join)(watchPath, filename);
52209
+ const fullPath = (0, import_path36.join)(watchPath, filename);
52118
52210
  const debounceKey = `${eventType}:${fullPath}`;
52119
52211
  const existingTimer = this.debounceTimers.get(debounceKey);
52120
52212
  if (existingTimer) {
@@ -52134,13 +52226,13 @@ var init_file_watcher = __esm({
52134
52226
  * @param filename - The name of the file that changed
52135
52227
  */
52136
52228
  async processFileEvent(eventType, watchPath, filename) {
52137
- const fullPath = (0, import_path35.join)(watchPath, filename);
52229
+ const fullPath = (0, import_path36.join)(watchPath, filename);
52138
52230
  let fsEventType;
52139
52231
  let isDirectory = false;
52140
52232
  let size;
52141
52233
  try {
52142
- if ((0, import_fs37.existsSync)(fullPath)) {
52143
- const stats = (0, import_fs37.statSync)(fullPath);
52234
+ if ((0, import_fs38.existsSync)(fullPath)) {
52235
+ const stats = (0, import_fs38.statSync)(fullPath);
52144
52236
  isDirectory = stats.isDirectory();
52145
52237
  size = stats.size;
52146
52238
  fsEventType = eventType === "rename" ? "create" : "modify";
@@ -52285,12 +52377,12 @@ var init_file_watcher = __esm({
52285
52377
  this.config.watchPaths.push(path8);
52286
52378
  return true;
52287
52379
  }
52288
- const fullPath = (0, import_path35.join)(basePath, path8);
52289
- if (!(0, import_fs37.existsSync)(fullPath)) {
52380
+ const fullPath = (0, import_path36.join)(basePath, path8);
52381
+ if (!(0, import_fs38.existsSync)(fullPath)) {
52290
52382
  return false;
52291
52383
  }
52292
52384
  try {
52293
- const watcher = (0, import_fs37.watch)(
52385
+ const watcher = (0, import_fs38.watch)(
52294
52386
  fullPath,
52295
52387
  { recursive: this.config.recursive },
52296
52388
  (eventType, filename) => {
@@ -52603,9 +52695,9 @@ async function confirm(message) {
52603
52695
  });
52604
52696
  }
52605
52697
  function isGalCreatedFile(filePath) {
52606
- if (!(0, import_fs38.existsSync)(filePath)) return false;
52698
+ if (!(0, import_fs39.existsSync)(filePath)) return false;
52607
52699
  try {
52608
- const content = (0, import_fs38.readFileSync)(filePath, "utf-8");
52700
+ const content = (0, import_fs39.readFileSync)(filePath, "utf-8");
52609
52701
  const galMarkers = [
52610
52702
  "GAL Config",
52611
52703
  "GAL CLI",
@@ -52625,9 +52717,9 @@ function isGalCreatedFile(filePath) {
52625
52717
  }
52626
52718
  }
52627
52719
  function isNpmInstalledFile(filePath) {
52628
- if (!(0, import_fs38.existsSync)(filePath)) return false;
52720
+ if (!(0, import_fs39.existsSync)(filePath)) return false;
52629
52721
  try {
52630
- const content = (0, import_fs38.readFileSync)(filePath, "utf-8");
52722
+ const content = (0, import_fs39.readFileSync)(filePath, "utf-8");
52631
52723
  return content.includes("CURRENT_VERSION =") || content.includes("const CURRENT_VERSION");
52632
52724
  } catch {
52633
52725
  return false;
@@ -52644,15 +52736,15 @@ function detectFileSource(filePath) {
52644
52736
  }
52645
52737
  function detectUserLevelItems(options) {
52646
52738
  const items = [];
52647
- const claudeDir = (0, import_path36.join)((0, import_os24.homedir)(), ".claude");
52648
- const claudeHooksDir = (0, import_path36.join)(claudeDir, "hooks");
52649
- const statusLinesDir = (0, import_path36.join)(claudeDir, "status_lines");
52739
+ const claudeDir = (0, import_path37.join)((0, import_os25.homedir)(), ".claude");
52740
+ const claudeHooksDir = (0, import_path37.join)(claudeDir, "hooks");
52741
+ const statusLinesDir = (0, import_path37.join)(claudeDir, "status_lines");
52650
52742
  const includeNpm = options?.includeNpmInstalled ?? true;
52651
- if ((0, import_fs38.existsSync)(claudeHooksDir)) {
52652
- const files = (0, import_fs38.readdirSync)(claudeHooksDir);
52743
+ if ((0, import_fs39.existsSync)(claudeHooksDir)) {
52744
+ const files = (0, import_fs39.readdirSync)(claudeHooksDir);
52653
52745
  for (const file of files) {
52654
52746
  if (file.startsWith("gal-")) {
52655
- const filePath = (0, import_path36.join)(claudeHooksDir, file);
52747
+ const filePath = (0, import_path37.join)(claudeHooksDir, file);
52656
52748
  const source = detectFileSource(filePath);
52657
52749
  if (!includeNpm && source === "npm") {
52658
52750
  continue;
@@ -52667,11 +52759,11 @@ function detectUserLevelItems(options) {
52667
52759
  }
52668
52760
  }
52669
52761
  }
52670
- if ((0, import_fs38.existsSync)(statusLinesDir)) {
52671
- const files = (0, import_fs38.readdirSync)(statusLinesDir);
52762
+ if ((0, import_fs39.existsSync)(statusLinesDir)) {
52763
+ const files = (0, import_fs39.readdirSync)(statusLinesDir);
52672
52764
  for (const file of files) {
52673
52765
  if (file.startsWith("gal-")) {
52674
- const filePath = (0, import_path36.join)(statusLinesDir, file);
52766
+ const filePath = (0, import_path37.join)(statusLinesDir, file);
52675
52767
  const source = detectFileSource(filePath);
52676
52768
  if (!includeNpm && source === "npm") {
52677
52769
  continue;
@@ -52686,10 +52778,10 @@ function detectUserLevelItems(options) {
52686
52778
  }
52687
52779
  }
52688
52780
  }
52689
- const claudeSettingsPath = (0, import_path36.join)(claudeDir, "settings.json");
52690
- if ((0, import_fs38.existsSync)(claudeSettingsPath)) {
52781
+ const claudeSettingsPath = (0, import_path37.join)(claudeDir, "settings.json");
52782
+ if ((0, import_fs39.existsSync)(claudeSettingsPath)) {
52691
52783
  try {
52692
- const settings = JSON.parse((0, import_fs38.readFileSync)(claudeSettingsPath, "utf-8"));
52784
+ const settings = JSON.parse((0, import_fs39.readFileSync)(claudeSettingsPath, "utf-8"));
52693
52785
  if (settings.hooks?.SessionStart) {
52694
52786
  const hasGalHooks = settings.hooks.SessionStart.some(
52695
52787
  (entry) => entry.hooks?.some(
@@ -52736,14 +52828,14 @@ function detectUserLevelItems(options) {
52736
52828
  } catch {
52737
52829
  }
52738
52830
  }
52739
- const cursorDir = (0, import_path36.join)((0, import_os24.homedir)(), ".cursor");
52740
- const cursorHooksDir = (0, import_path36.join)(cursorDir, "hooks");
52741
- if ((0, import_fs38.existsSync)(cursorHooksDir)) {
52742
- const files = (0, import_fs38.readdirSync)(cursorHooksDir);
52831
+ const cursorDir = (0, import_path37.join)((0, import_os25.homedir)(), ".cursor");
52832
+ const cursorHooksDir = (0, import_path37.join)(cursorDir, "hooks");
52833
+ if ((0, import_fs39.existsSync)(cursorHooksDir)) {
52834
+ const files = (0, import_fs39.readdirSync)(cursorHooksDir);
52743
52835
  for (const file of files) {
52744
52836
  if (file.startsWith("gal-")) {
52745
52837
  items.push({
52746
- path: (0, import_path36.join)(cursorHooksDir, file),
52838
+ path: (0, import_path37.join)(cursorHooksDir, file),
52747
52839
  type: "file",
52748
52840
  reason: "GAL hook file for Cursor IDE",
52749
52841
  isGalOwned: true
@@ -52751,10 +52843,10 @@ function detectUserLevelItems(options) {
52751
52843
  }
52752
52844
  }
52753
52845
  }
52754
- const cursorHooksJsonPath = (0, import_path36.join)(cursorDir, "hooks.json");
52755
- if ((0, import_fs38.existsSync)(cursorHooksJsonPath)) {
52846
+ const cursorHooksJsonPath = (0, import_path37.join)(cursorDir, "hooks.json");
52847
+ if ((0, import_fs39.existsSync)(cursorHooksJsonPath)) {
52756
52848
  try {
52757
- const hooksConfig = JSON.parse((0, import_fs38.readFileSync)(cursorHooksJsonPath, "utf-8"));
52849
+ const hooksConfig = JSON.parse((0, import_fs39.readFileSync)(cursorHooksJsonPath, "utf-8"));
52758
52850
  const hookTypes = ["beforeShellExecution", "beforeSubmitPrompt"];
52759
52851
  for (const hookType of hookTypes) {
52760
52852
  if (hooksConfig.hooks?.[hookType]) {
@@ -52780,8 +52872,8 @@ function detectUserLevelItems(options) {
52780
52872
  }
52781
52873
  function detectProjectLevelItems(directory) {
52782
52874
  const items = [];
52783
- const galDir = (0, import_path36.join)(directory, ".gal");
52784
- if ((0, import_fs38.existsSync)(galDir)) {
52875
+ const galDir = (0, import_path37.join)(directory, ".gal");
52876
+ if ((0, import_fs39.existsSync)(galDir)) {
52785
52877
  items.push({
52786
52878
  path: galDir,
52787
52879
  type: "directory",
@@ -52789,8 +52881,8 @@ function detectProjectLevelItems(directory) {
52789
52881
  isGalOwned: true
52790
52882
  });
52791
52883
  }
52792
- const galConfig = (0, import_path36.join)(directory, "gal.config.json");
52793
- if ((0, import_fs38.existsSync)(galConfig)) {
52884
+ const galConfig = (0, import_path37.join)(directory, "gal.config.json");
52885
+ if ((0, import_fs39.existsSync)(galConfig)) {
52794
52886
  items.push({
52795
52887
  path: galConfig,
52796
52888
  type: "file",
@@ -52799,11 +52891,11 @@ function detectProjectLevelItems(directory) {
52799
52891
  });
52800
52892
  }
52801
52893
  const gitHookPaths = [
52802
- (0, import_path36.join)(directory, ".git", "hooks", "pre-commit"),
52803
- (0, import_path36.join)(directory, ".husky", "pre-commit")
52894
+ (0, import_path37.join)(directory, ".git", "hooks", "pre-commit"),
52895
+ (0, import_path37.join)(directory, ".husky", "pre-commit")
52804
52896
  ];
52805
52897
  for (const hookPath of gitHookPaths) {
52806
- if ((0, import_fs38.existsSync)(hookPath) && isGalCreatedFile(hookPath)) {
52898
+ if ((0, import_fs39.existsSync)(hookPath) && isGalCreatedFile(hookPath)) {
52807
52899
  items.push({
52808
52900
  path: hookPath,
52809
52901
  type: "file",
@@ -52813,18 +52905,18 @@ function detectProjectLevelItems(directory) {
52813
52905
  }
52814
52906
  }
52815
52907
  const setupFiles = [
52816
- { path: (0, import_path36.join)(directory, "CLAUDE.md"), reason: "GAL-generated CLAUDE.md" },
52817
- { path: (0, import_path36.join)(directory, ".claude", "settings.json"), reason: "GAL-generated settings" },
52818
- { path: (0, import_path36.join)(directory, ".claude", "commands", "review.md"), reason: "GAL-generated command" },
52819
- { path: (0, import_path36.join)(directory, ".claude", "commands", "check.md"), reason: "GAL-generated command" },
52820
- { path: (0, import_path36.join)(directory, ".github", "workflows", "ci.yml"), reason: "GAL-generated workflow" },
52821
- { path: (0, import_path36.join)(directory, ".github", "workflows", "pr-governance.yml"), reason: "GAL-generated workflow" },
52822
- { path: (0, import_path36.join)(directory, ".gitleaks.toml"), reason: "GAL-generated security config" },
52823
- { path: (0, import_path36.join)(directory, "SECURITY.md"), reason: "GAL-generated security docs" },
52824
- { path: (0, import_path36.join)(directory, ".env.example"), reason: "GAL-generated env template" }
52908
+ { path: (0, import_path37.join)(directory, "CLAUDE.md"), reason: "GAL-generated CLAUDE.md" },
52909
+ { path: (0, import_path37.join)(directory, ".claude", "settings.json"), reason: "GAL-generated settings" },
52910
+ { path: (0, import_path37.join)(directory, ".claude", "commands", "review.md"), reason: "GAL-generated command" },
52911
+ { path: (0, import_path37.join)(directory, ".claude", "commands", "check.md"), reason: "GAL-generated command" },
52912
+ { path: (0, import_path37.join)(directory, ".github", "workflows", "ci.yml"), reason: "GAL-generated workflow" },
52913
+ { path: (0, import_path37.join)(directory, ".github", "workflows", "pr-governance.yml"), reason: "GAL-generated workflow" },
52914
+ { path: (0, import_path37.join)(directory, ".gitleaks.toml"), reason: "GAL-generated security config" },
52915
+ { path: (0, import_path37.join)(directory, "SECURITY.md"), reason: "GAL-generated security docs" },
52916
+ { path: (0, import_path37.join)(directory, ".env.example"), reason: "GAL-generated env template" }
52825
52917
  ];
52826
52918
  for (const { path: path8, reason } of setupFiles) {
52827
- if ((0, import_fs38.existsSync)(path8) && isGalCreatedFile(path8)) {
52919
+ if ((0, import_fs39.existsSync)(path8) && isGalCreatedFile(path8)) {
52828
52920
  items.push({
52829
52921
  path: path8,
52830
52922
  type: "file",
@@ -52837,12 +52929,12 @@ function detectProjectLevelItems(directory) {
52837
52929
  }
52838
52930
  function removeGalStatusLineEntry(settingsPath) {
52839
52931
  try {
52840
- const settings = JSON.parse((0, import_fs38.readFileSync)(settingsPath, "utf-8"));
52932
+ const settings = JSON.parse((0, import_fs39.readFileSync)(settingsPath, "utf-8"));
52841
52933
  if (!settings.statusLine?.command?.includes("gal-")) {
52842
52934
  return false;
52843
52935
  }
52844
52936
  delete settings.statusLine;
52845
- (0, import_fs38.writeFileSync)(settingsPath, JSON.stringify(settings, null, 2));
52937
+ (0, import_fs39.writeFileSync)(settingsPath, JSON.stringify(settings, null, 2));
52846
52938
  return true;
52847
52939
  } catch {
52848
52940
  return false;
@@ -52850,7 +52942,7 @@ function removeGalStatusLineEntry(settingsPath) {
52850
52942
  }
52851
52943
  function removeGalHookEntries(settingsPath) {
52852
52944
  try {
52853
- const settings = JSON.parse((0, import_fs38.readFileSync)(settingsPath, "utf-8"));
52945
+ const settings = JSON.parse((0, import_fs39.readFileSync)(settingsPath, "utf-8"));
52854
52946
  let modified = false;
52855
52947
  for (const hookEvent of ["SessionStart", "UserPromptSubmit"]) {
52856
52948
  if (!settings.hooks?.[hookEvent]) continue;
@@ -52873,7 +52965,7 @@ function removeGalHookEntries(settingsPath) {
52873
52965
  delete settings.hooks;
52874
52966
  }
52875
52967
  if (modified) {
52876
- (0, import_fs38.writeFileSync)(settingsPath, JSON.stringify(settings, null, 2));
52968
+ (0, import_fs39.writeFileSync)(settingsPath, JSON.stringify(settings, null, 2));
52877
52969
  return true;
52878
52970
  }
52879
52971
  return false;
@@ -52883,7 +52975,7 @@ function removeGalHookEntries(settingsPath) {
52883
52975
  }
52884
52976
  function removeGalCursorHookEntries(hooksJsonPath) {
52885
52977
  try {
52886
- const hooksConfig = JSON.parse((0, import_fs38.readFileSync)(hooksJsonPath, "utf-8"));
52978
+ const hooksConfig = JSON.parse((0, import_fs39.readFileSync)(hooksJsonPath, "utf-8"));
52887
52979
  if (!hooksConfig.hooks) {
52888
52980
  return false;
52889
52981
  }
@@ -52907,7 +52999,7 @@ function removeGalCursorHookEntries(hooksJsonPath) {
52907
52999
  delete hooksConfig.hooks;
52908
53000
  }
52909
53001
  if (modified) {
52910
- (0, import_fs38.writeFileSync)(hooksJsonPath, JSON.stringify(hooksConfig, null, 2));
53002
+ (0, import_fs39.writeFileSync)(hooksJsonPath, JSON.stringify(hooksConfig, null, 2));
52911
53003
  return true;
52912
53004
  }
52913
53005
  return false;
@@ -52942,10 +53034,10 @@ function performUninstall(items, dryRun) {
52942
53034
  result.skipped.push(`${item.path} (no GAL statusLine found)`);
52943
53035
  }
52944
53036
  } else if (item.type === "directory") {
52945
- (0, import_fs38.rmSync)(item.path, { recursive: true, force: true });
53037
+ (0, import_fs39.rmSync)(item.path, { recursive: true, force: true });
52946
53038
  result.removed.push(item.path);
52947
53039
  } else {
52948
- (0, import_fs38.unlinkSync)(item.path);
53040
+ (0, import_fs39.unlinkSync)(item.path);
52949
53041
  result.removed.push(item.path);
52950
53042
  }
52951
53043
  } catch (error2) {
@@ -53041,15 +53133,15 @@ function createUninstallCommand() {
53041
53133
  });
53042
53134
  return command;
53043
53135
  }
53044
- var import_fs38, import_path36, import_os24, import_readline4;
53136
+ var import_fs39, import_path37, import_os25, import_readline4;
53045
53137
  var init_uninstall = __esm({
53046
53138
  "src/commands/uninstall.ts"() {
53047
53139
  "use strict";
53048
53140
  init_esm();
53049
53141
  init_source();
53050
- import_fs38 = require("fs");
53051
- import_path36 = require("path");
53052
- import_os24 = require("os");
53142
+ import_fs39 = require("fs");
53143
+ import_path37 = require("path");
53144
+ import_os25 = require("os");
53053
53145
  import_readline4 = require("readline");
53054
53146
  }
53055
53147
  });
@@ -53467,27 +53559,27 @@ function compareVersions2(v1, v2) {
53467
53559
  }
53468
53560
  function acquireLock() {
53469
53561
  try {
53470
- const galDir = (0, import_path37.join)((0, import_os25.homedir)(), ".gal");
53471
- if (!(0, import_fs39.existsSync)(galDir)) {
53472
- (0, import_fs39.mkdirSync)(galDir, { recursive: true });
53562
+ const galDir = (0, import_path38.join)((0, import_os26.homedir)(), ".gal");
53563
+ if (!(0, import_fs40.existsSync)(galDir)) {
53564
+ (0, import_fs40.mkdirSync)(galDir, { recursive: true });
53473
53565
  }
53474
- if ((0, import_fs39.existsSync)(UPDATE_LOCK_FILE)) {
53566
+ if ((0, import_fs40.existsSync)(UPDATE_LOCK_FILE)) {
53475
53567
  try {
53476
- const lockContent = (0, import_fs39.readFileSync)(UPDATE_LOCK_FILE, "utf-8");
53568
+ const lockContent = (0, import_fs40.readFileSync)(UPDATE_LOCK_FILE, "utf-8");
53477
53569
  const lockTime = parseInt(lockContent, 10);
53478
53570
  if (Number.isNaN(lockTime) || Date.now() - lockTime > 5 * 60 * 1e3) {
53479
- (0, import_fs39.unlinkSync)(UPDATE_LOCK_FILE);
53571
+ (0, import_fs40.unlinkSync)(UPDATE_LOCK_FILE);
53480
53572
  } else {
53481
53573
  return false;
53482
53574
  }
53483
53575
  } catch {
53484
53576
  try {
53485
- (0, import_fs39.unlinkSync)(UPDATE_LOCK_FILE);
53577
+ (0, import_fs40.unlinkSync)(UPDATE_LOCK_FILE);
53486
53578
  } catch {
53487
53579
  }
53488
53580
  }
53489
53581
  }
53490
- (0, import_fs39.writeFileSync)(UPDATE_LOCK_FILE, String(Date.now()), { flag: "wx" });
53582
+ (0, import_fs40.writeFileSync)(UPDATE_LOCK_FILE, String(Date.now()), { flag: "wx" });
53491
53583
  return true;
53492
53584
  } catch {
53493
53585
  return false;
@@ -53495,8 +53587,8 @@ function acquireLock() {
53495
53587
  }
53496
53588
  function releaseLock() {
53497
53589
  try {
53498
- if ((0, import_fs39.existsSync)(UPDATE_LOCK_FILE)) {
53499
- (0, import_fs39.unlinkSync)(UPDATE_LOCK_FILE);
53590
+ if ((0, import_fs40.existsSync)(UPDATE_LOCK_FILE)) {
53591
+ (0, import_fs40.unlinkSync)(UPDATE_LOCK_FILE);
53500
53592
  }
53501
53593
  } catch {
53502
53594
  }
@@ -53607,7 +53699,7 @@ Retry manually with: ${source_default.cyan(installCommand)}`);
53607
53699
  });
53608
53700
  return command;
53609
53701
  }
53610
- var import_https, import_child_process12, import_fs39, import_path37, import_os25, UPDATE_LOCK_FILE, cliVersion7, REGISTRY_URL;
53702
+ var import_https, import_child_process12, import_fs40, import_path38, import_os26, UPDATE_LOCK_FILE, cliVersion7, REGISTRY_URL;
53611
53703
  var init_update = __esm({
53612
53704
  "src/commands/update.ts"() {
53613
53705
  "use strict";
@@ -53616,14 +53708,14 @@ var init_update = __esm({
53616
53708
  init_ora();
53617
53709
  import_https = __toESM(require("https"), 1);
53618
53710
  import_child_process12 = require("child_process");
53619
- import_fs39 = require("fs");
53620
- import_path37 = require("path");
53621
- import_os25 = require("os");
53711
+ import_fs40 = require("fs");
53712
+ import_path38 = require("path");
53713
+ import_os26 = require("os");
53622
53714
  init_constants();
53623
53715
  init_path_conflict();
53624
53716
  init_install();
53625
53717
  init_telemetry();
53626
- UPDATE_LOCK_FILE = (0, import_path37.join)((0, import_os25.homedir)(), ".gal", "update.lock");
53718
+ UPDATE_LOCK_FILE = (0, import_path38.join)((0, import_os26.homedir)(), ".gal", "update.lock");
53627
53719
  cliVersion7 = constants_default[0];
53628
53720
  REGISTRY_URL = getRegistryUrl();
53629
53721
  }
@@ -54131,9 +54223,9 @@ function createWorkflowCommand() {
54131
54223
  const apiUrl = process.env.GAL_API_URL || defaultApiUrl17;
54132
54224
  try {
54133
54225
  const spinner = ora(`Reading ${filePath}...`).start();
54134
- const absolutePath = import_path38.default.resolve(filePath);
54226
+ const absolutePath = import_path39.default.resolve(filePath);
54135
54227
  const content = await import_promises9.default.readFile(absolutePath, "utf-8");
54136
- const fileName = import_path38.default.basename(filePath);
54228
+ const fileName = import_path39.default.basename(filePath);
54137
54229
  let type = options.type;
54138
54230
  if (!type) {
54139
54231
  if (fileName.endsWith(".md")) {
@@ -54189,7 +54281,7 @@ function createWorkflowCommand() {
54189
54281
  spinner.fail(source_default.red("No organization found. Please connect GitHub via dashboard or use --org flag"));
54190
54282
  process.exit(1);
54191
54283
  }
54192
- const dirPath = import_path38.default.resolve(directory);
54284
+ const dirPath = import_path39.default.resolve(directory);
54193
54285
  const files = await import_promises9.default.readdir(dirPath);
54194
54286
  const workflowFiles = files.filter(
54195
54287
  (f) => f.endsWith(".md") || f.includes("hook") && (f.endsWith(".json") || f.endsWith(".py") || f.endsWith(".js"))
@@ -54201,7 +54293,7 @@ function createWorkflowCommand() {
54201
54293
  spinner.text = `Found ${workflowFiles.length} workflow files. Preparing batch test...`;
54202
54294
  const requests = [];
54203
54295
  for (const file of workflowFiles) {
54204
- const filePath = import_path38.default.join(dirPath, file);
54296
+ const filePath = import_path39.default.join(dirPath, file);
54205
54297
  const content = await import_promises9.default.readFile(filePath, "utf-8");
54206
54298
  const type = file.endsWith(".md") ? "command" : "hook";
54207
54299
  requests.push({
@@ -54299,7 +54391,7 @@ function displayTestResult(result) {
54299
54391
  }
54300
54392
  console.log();
54301
54393
  }
54302
- var import_promises9, import_path38, defaultApiUrl17;
54394
+ var import_promises9, import_path39, defaultApiUrl17;
54303
54395
  var init_workflow2 = __esm({
54304
54396
  "src/commands/workflow.ts"() {
54305
54397
  "use strict";
@@ -54307,7 +54399,7 @@ var init_workflow2 = __esm({
54307
54399
  init_source();
54308
54400
  init_ora();
54309
54401
  import_promises9 = __toESM(require("fs/promises"), 1);
54310
- import_path38 = __toESM(require("path"), 1);
54402
+ import_path39 = __toESM(require("path"), 1);
54311
54403
  init_constants();
54312
54404
  init_client();
54313
54405
  defaultApiUrl17 = constants_default[1];
@@ -54635,11 +54727,11 @@ function getRegistryAuthToken2() {
54635
54727
  return void 0;
54636
54728
  }
54637
54729
  try {
54638
- const npmrcPath = (0, import_path39.join)((0, import_os26.homedir)(), ".npmrc");
54639
- if (!(0, import_fs40.existsSync)(npmrcPath)) {
54730
+ const npmrcPath = (0, import_path40.join)((0, import_os27.homedir)(), ".npmrc");
54731
+ if (!(0, import_fs41.existsSync)(npmrcPath)) {
54640
54732
  return void 0;
54641
54733
  }
54642
- const npmrc = (0, import_fs40.readFileSync)(npmrcPath, "utf-8");
54734
+ const npmrc = (0, import_fs41.readFileSync)(npmrcPath, "utf-8");
54643
54735
  const escapedHost = REGISTRY_HOST.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
54644
54736
  const match = npmrc.match(
54645
54737
  new RegExp(`^//${escapedHost}/:_authToken=(.+)$`, "m")
@@ -54659,8 +54751,8 @@ function getRegistryAuthToken2() {
54659
54751
  }
54660
54752
  function readUpdateCache() {
54661
54753
  try {
54662
- if ((0, import_fs40.existsSync)(UPDATE_CACHE_FILE)) {
54663
- return JSON.parse((0, import_fs40.readFileSync)(UPDATE_CACHE_FILE, "utf-8"));
54754
+ if ((0, import_fs41.existsSync)(UPDATE_CACHE_FILE)) {
54755
+ return JSON.parse((0, import_fs41.readFileSync)(UPDATE_CACHE_FILE, "utf-8"));
54664
54756
  }
54665
54757
  } catch {
54666
54758
  }
@@ -54668,10 +54760,10 @@ function readUpdateCache() {
54668
54760
  }
54669
54761
  function writeUpdateCache(cache) {
54670
54762
  try {
54671
- if (!(0, import_fs40.existsSync)(UPDATE_CACHE_DIR)) {
54672
- (0, import_fs40.mkdirSync)(UPDATE_CACHE_DIR, { recursive: true });
54763
+ if (!(0, import_fs41.existsSync)(UPDATE_CACHE_DIR)) {
54764
+ (0, import_fs41.mkdirSync)(UPDATE_CACHE_DIR, { recursive: true });
54673
54765
  }
54674
- (0, import_fs40.writeFileSync)(UPDATE_CACHE_FILE, JSON.stringify(cache));
54766
+ (0, import_fs41.writeFileSync)(UPDATE_CACHE_FILE, JSON.stringify(cache));
54675
54767
  } catch {
54676
54768
  }
54677
54769
  }
@@ -54809,8 +54901,8 @@ async function checkForUpdates() {
54809
54901
  });
54810
54902
  if (!isUpdateCommand && !isCI && !isAutoUpdateDisabled) {
54811
54903
  try {
54812
- const lockFile = (0, import_path39.join)((0, import_os26.homedir)(), ".gal", "update.lock");
54813
- if (!(0, import_fs40.existsSync)(lockFile)) {
54904
+ const lockFile = (0, import_path40.join)((0, import_os27.homedir)(), ".gal", "update.lock");
54905
+ if (!(0, import_fs41.existsSync)(lockFile)) {
54814
54906
  const child = (0, import_child_process13.spawn)("gal", ["update"], {
54815
54907
  detached: true,
54816
54908
  stdio: "ignore",
@@ -54859,9 +54951,9 @@ async function checkForUpdates() {
54859
54951
  function checkPathConflicts() {
54860
54952
  try {
54861
54953
  if (process.env.CI === "true" || process.argv.includes("--json")) return;
54862
- const CONFLICT_CACHE = (0, import_path39.join)(UPDATE_CACHE_DIR, "path-conflict-cache.json");
54863
- if ((0, import_fs40.existsSync)(CONFLICT_CACHE)) {
54864
- const cached = JSON.parse((0, import_fs40.readFileSync)(CONFLICT_CACHE, "utf-8"));
54954
+ const CONFLICT_CACHE = (0, import_path40.join)(UPDATE_CACHE_DIR, "path-conflict-cache.json");
54955
+ if ((0, import_fs41.existsSync)(CONFLICT_CACHE)) {
54956
+ const cached = JSON.parse((0, import_fs41.readFileSync)(CONFLICT_CACHE, "utf-8"));
54865
54957
  if (Date.now() - (cached.lastCheck || 0) < ONE_DAY) {
54866
54958
  if (cached.hasConflict) {
54867
54959
  process.on("exit", () => {
@@ -54875,10 +54967,10 @@ function checkPathConflicts() {
54875
54967
  const conflict = detectPathConflict(cliVersion9);
54876
54968
  const cacheData = { lastCheck: Date.now(), hasConflict: !!conflict };
54877
54969
  try {
54878
- if (!(0, import_fs40.existsSync)(UPDATE_CACHE_DIR)) {
54879
- (0, import_fs40.mkdirSync)(UPDATE_CACHE_DIR, { recursive: true });
54970
+ if (!(0, import_fs41.existsSync)(UPDATE_CACHE_DIR)) {
54971
+ (0, import_fs41.mkdirSync)(UPDATE_CACHE_DIR, { recursive: true });
54880
54972
  }
54881
- (0, import_fs40.writeFileSync)(CONFLICT_CACHE, JSON.stringify(cacheData));
54973
+ (0, import_fs41.writeFileSync)(CONFLICT_CACHE, JSON.stringify(cacheData));
54882
54974
  } catch {
54883
54975
  }
54884
54976
  if (conflict) {
@@ -54891,9 +54983,9 @@ function checkPathConflicts() {
54891
54983
  }
54892
54984
  function refreshOrgMemberships() {
54893
54985
  try {
54894
- const configPath = (0, import_path39.join)((0, import_os26.homedir)(), ".gal", "config.json");
54895
- if (!(0, import_fs40.existsSync)(configPath)) return;
54896
- const config = JSON.parse((0, import_fs40.readFileSync)(configPath, "utf-8"));
54986
+ const configPath = (0, import_path40.join)((0, import_os27.homedir)(), ".gal", "config.json");
54987
+ if (!(0, import_fs41.existsSync)(configPath)) return;
54988
+ const config = JSON.parse((0, import_fs41.readFileSync)(configPath, "utf-8"));
54897
54989
  if (!config.authToken) return;
54898
54990
  const checkedAt = config.orgMembershipsCheckedAt || 0;
54899
54991
  if (Date.now() - checkedAt < ONE_DAY) return;
@@ -54925,10 +55017,10 @@ function refreshOrgMemberships() {
54925
55017
  config.capabilities = user.capabilities;
54926
55018
  config.capabilitiesCachedAt = Date.now();
54927
55019
  }
54928
- if (!(0, import_fs40.existsSync)(UPDATE_CACHE_DIR)) {
54929
- (0, import_fs40.mkdirSync)(UPDATE_CACHE_DIR, { recursive: true });
55020
+ if (!(0, import_fs41.existsSync)(UPDATE_CACHE_DIR)) {
55021
+ (0, import_fs41.mkdirSync)(UPDATE_CACHE_DIR, { recursive: true });
54930
55022
  }
54931
- (0, import_fs40.writeFileSync)(configPath, JSON.stringify(config, null, 2));
55023
+ (0, import_fs41.writeFileSync)(configPath, JSON.stringify(config, null, 2));
54932
55024
  }
54933
55025
  } catch {
54934
55026
  }
@@ -54955,11 +55047,11 @@ function refreshOrgMemberships() {
54955
55047
  if (res.statusCode !== 200) return;
54956
55048
  const flags = JSON.parse(data);
54957
55049
  if (flags.orgAudienceTierMap) {
54958
- const freshConfig = JSON.parse((0, import_fs40.readFileSync)(configPath, "utf-8"));
55050
+ const freshConfig = JSON.parse((0, import_fs41.readFileSync)(configPath, "utf-8"));
54959
55051
  freshConfig.orgAudienceTierMap = flags.orgAudienceTierMap;
54960
55052
  freshConfig.orgPlanMap = flags.orgPlanMap || freshConfig.orgPlanMap || {};
54961
55053
  freshConfig.flagsCachedAt = Date.now();
54962
- (0, import_fs40.writeFileSync)(configPath, JSON.stringify(freshConfig, null, 2));
55054
+ (0, import_fs41.writeFileSync)(configPath, JSON.stringify(freshConfig, null, 2));
54963
55055
  }
54964
55056
  } catch {
54965
55057
  }
@@ -54978,7 +55070,7 @@ function refreshOrgMemberships() {
54978
55070
  } catch {
54979
55071
  }
54980
55072
  }
54981
- var import_dotenv, import_https2, import_readline5, import_child_process13, import_fs40, import_path39, import_os26, originalEmit, GLOBAL_TIMEOUT_MS, globalTimeout, cliVersion9, UPDATE_CACHE_DIR, UPDATE_CACHE_FILE, ONE_DAY, REGISTRY_URL2, REGISTRY_HOST, sessionStartTime, isReadOnlyStatusCommand, isMachineMode, exitHooksRan, featureFlags, knownCommands, isKnownCommand, program2, allInternalFlags;
55073
+ var import_dotenv, import_https2, import_readline5, import_child_process13, import_fs41, import_path40, import_os27, originalEmit, GLOBAL_TIMEOUT_MS, globalTimeout, cliVersion9, UPDATE_CACHE_DIR, UPDATE_CACHE_FILE, ONE_DAY, REGISTRY_URL2, REGISTRY_HOST, sessionStartTime, isReadOnlyStatusCommand, isMachineMode, exitHooksRan, featureFlags, knownCommands, isKnownCommand, program2, allInternalFlags;
54982
55074
  var init_index = __esm({
54983
55075
  "src/index.ts"() {
54984
55076
  "use strict";
@@ -54987,9 +55079,9 @@ var init_index = __esm({
54987
55079
  import_https2 = __toESM(require("https"), 1);
54988
55080
  import_readline5 = __toESM(require("readline"), 1);
54989
55081
  import_child_process13 = require("child_process");
54990
- import_fs40 = require("fs");
54991
- import_path39 = require("path");
54992
- import_os26 = require("os");
55082
+ import_fs41 = require("fs");
55083
+ import_path40 = require("path");
55084
+ import_os27 = require("os");
54993
55085
  init_source();
54994
55086
  init_constants();
54995
55087
  init_sentry2();
@@ -55019,8 +55111,8 @@ var init_index = __esm({
55019
55111
  }, GLOBAL_TIMEOUT_MS);
55020
55112
  globalTimeout.unref();
55021
55113
  cliVersion9 = constants_default[0];
55022
- UPDATE_CACHE_DIR = (0, import_path39.join)((0, import_os26.homedir)(), ".gal");
55023
- UPDATE_CACHE_FILE = (0, import_path39.join)(UPDATE_CACHE_DIR, "update-cache.json");
55114
+ UPDATE_CACHE_DIR = (0, import_path40.join)((0, import_os27.homedir)(), ".gal");
55115
+ UPDATE_CACHE_FILE = (0, import_path40.join)(UPDATE_CACHE_DIR, "update-cache.json");
55024
55116
  ONE_DAY = 24 * 60 * 60 * 1e3;
55025
55117
  REGISTRY_URL2 = (() => {
55026
55118
  const raw = process.env.GAL_REGISTRY_URL || "https://registry.npmjs.org";
@@ -55167,7 +55259,7 @@ var init_index = __esm({
55167
55259
  });
55168
55260
 
55169
55261
  // src/bootstrap.ts
55170
- var cliVersion10 = true ? "0.0.337" : "0.0.0-dev";
55262
+ var cliVersion10 = true ? "0.0.338" : "0.0.0-dev";
55171
55263
  var args = process.argv.slice(2);
55172
55264
  var requestedGlobalHelp = args.length === 1 && (args[0] === "--help" || args[0] === "-h");
55173
55265
  var requestedVersion = args.length === 1 && (args[0] === "--version" || args[0] === "-V");