setclaw 1.3.1 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/bin/setclaw.js +17 -51
  2. package/package.json +1 -1
package/bin/setclaw.js CHANGED
@@ -71,36 +71,16 @@ const isFirstRun = !isNpx && existsSync(MARKER_FILE);
71
71
  // ════════════════════════════════════════════════════════════════════
72
72
 
73
73
  if (restore) {
74
- if (!existsSync(BACKUP_FILE)) {
75
- fail("No backup found. Nothing to restore.");
76
- process.exit(1);
77
- }
78
-
79
- const backup = JSON.parse(readFileSync(BACKUP_FILE, "utf-8"));
80
- log("Restoring original environment variables...");
74
+ log("Removing setclaw environment variables...");
81
75
 
82
76
  if (OS === "win32") {
83
77
  for (const key of VAR_KEYS) {
84
- if (backup.env[key] !== undefined) {
85
- // Restore to both user and system
86
- try {
87
- execSync(`reg add "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment" /v "${key}" /t REG_SZ /d "${backup.env[key]}" /f`, { stdio: "ignore" });
88
- } catch {}
89
- execSync(`reg add "HKCU\\Environment" /v "${key}" /t REG_SZ /d "${backup.env[key]}" /f`, { stdio: "ignore" });
90
- ok(`Restored ${key} = ${backup.env[key] || "(empty)"}`);
91
- } else {
92
- // Was not set before — delete it
93
- try {
94
- execSync(`reg delete "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment" /v "${key}" /f`, { stdio: "ignore" });
95
- } catch {}
96
- try {
97
- execSync(`reg delete "HKCU\\Environment" /v "${key}" /f`, { stdio: "ignore" });
98
- } catch {}
99
- ok(`Removed ${key} (was not set before)`);
100
- }
78
+ // Delete from both HKLM and HKCU — don't "restore", just remove
79
+ try { execSync(`reg delete "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment" /v "${key}" /f`, { stdio: "ignore" }); } catch {}
80
+ try { execSync(`reg delete "HKCU\\Environment" /v "${key}" /f`, { stdio: "ignore" }); } catch {}
81
+ ok(`Removed ${key}`);
101
82
  }
102
83
  } else {
103
- // Remove setclaw block from all rc files
104
84
  const marker = "# --- Quatarly / Claude Code env ---";
105
85
  const endMarker = "# --- end Quatarly ---";
106
86
  const rcFiles = ["/etc/environment", "/etc/zshenv", "/etc/bash.bashrc",
@@ -117,12 +97,17 @@ if (restore) {
117
97
  }
118
98
  }
119
99
 
120
- // Restore Factory settings
100
+ // Restore Factory settings from backup if it exists
121
101
  const factoryPath = join(HOME, ".factory", "settings.json");
122
- if (backup.factory && existsSync(factoryPath)) {
123
- log("Restoring Factory settings...");
124
- writeFileSync(factoryPath, JSON.stringify(backup.factory, null, 2), "utf-8");
125
- ok("Factory settings restored.");
102
+ if (existsSync(BACKUP_FILE)) {
103
+ const backup = JSON.parse(readFileSync(BACKUP_FILE, "utf-8"));
104
+ if (backup.factory && existsSync(factoryPath)) {
105
+ log("Restoring Factory settings...");
106
+ writeFileSync(factoryPath, JSON.stringify(backup.factory, null, 2), "utf-8");
107
+ ok("Factory settings restored.");
108
+ }
109
+ } else {
110
+ warn("No backup found — env vars removed, Factory settings unchanged.");
126
111
  }
127
112
 
128
113
  // Clean up backup
@@ -158,30 +143,11 @@ if (!key) { fail("API key cannot be empty."); process.exit(1); }
158
143
 
159
144
  err("");
160
145
 
161
- // ─── Backup current state ─────────────────────────────────────────────
146
+ // ─── Backup current state (Factory config only) ───────────────────────
162
147
 
163
148
  mkdirSync(BACKUP_DIR, { recursive: true });
164
149
 
165
- const backup = { env: {}, factory: null };
166
-
167
- if (OS === "win32") {
168
- for (const k of VAR_KEYS) {
169
- try {
170
- const val = execSync(`reg query "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment" /v "${k}" 2>nul`, { encoding: "utf-8" });
171
- const match = val.match(/REG_SZ\s+(.+)/);
172
- backup.env[k] = match ? match[1].trim() : "";
173
- } catch {
174
- // Also try HKCU
175
- try {
176
- const val = execSync(`reg query "HKCU\\Environment" /v "${k}" 2>nul`, { encoding: "utf-8" });
177
- const match = val.match(/REG_SZ\s+(.+)/);
178
- backup.env[k] = match ? match[1].trim() : "";
179
- } catch {
180
- backup.env[k] = undefined; // Was not set
181
- }
182
- }
183
- }
184
- }
150
+ const backup = { factory: null };
185
151
 
186
152
  // Backup Factory settings
187
153
  const factoryPath = join(HOME, ".factory", "settings.json");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "setclaw",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "BOA & Quatarly setup for Claude Code and Factory",
5
5
  "type": "module",
6
6
  "bin": {