@synth1s/cloak 1.9.1 → 1.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synth1s/cloak",
3
- "version": "1.9.1",
3
+ "version": "1.9.3",
4
4
  "description": "Cloak your Claude. Switch identities in seconds.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -14,14 +14,15 @@ export async function switchAccount(name, options = {}) {
14
14
 
15
15
  if (!profileExists(name)) {
16
16
  console.error(msg.accountNotFound(name))
17
- console.log(msg.suggestCreate(name))
17
+ console.error(msg.suggestCreate(name))
18
18
  process.exit(1)
19
19
  return
20
20
  }
21
21
 
22
22
  const active = getActiveProfile()
23
23
  if (active === name) {
24
- console.log(msg.alreadyWearing(name))
24
+ // Always stderr — stdout is reserved for eval-able output when --print-env
25
+ console.error(msg.alreadyWearing(name))
25
26
  return
26
27
  }
27
28
 
package/src/lib/setup.js CHANGED
@@ -21,7 +21,17 @@ export function isAlreadyInstalled(rcFilePath) {
21
21
  }
22
22
 
23
23
  export function installToRcFile(rcFilePath) {
24
- if (isAlreadyInstalled(rcFilePath)) return
25
- const line = '\neval "$(cloak init)"\n'
26
- writeFileSync(rcFilePath, line, { flag: 'a' })
24
+ if (!existsSync(rcFilePath)) {
25
+ writeFileSync(rcFilePath, 'eval "$(cloak init)"\n')
26
+ return
27
+ }
28
+
29
+ // Read existing content and remove ALL lines containing 'cloak init'
30
+ const content = readFileSync(rcFilePath, 'utf8')
31
+ const lines = content.split('\n')
32
+ const cleaned = lines.filter(line => !line.includes('cloak init'))
33
+ const cleanedContent = cleaned.join('\n').replace(/\n{3,}/g, '\n\n')
34
+
35
+ // Write cleaned content + fresh init line
36
+ writeFileSync(rcFilePath, cleanedContent.trimEnd() + '\neval "$(cloak init)"\n')
27
37
  }