@synth1s/cloak 2.0.2 → 2.1.0

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": "2.0.2",
3
+ "version": "2.1.0",
4
4
  "description": "Cloak your Claude. Switch identities in seconds.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,4 +1,4 @@
1
- import { existsSync, copyFileSync, mkdirSync } from 'fs'
1
+ import { existsSync, copyFileSync, mkdirSync, chmodSync } from 'fs'
2
2
  import inquirer from 'inquirer'
3
3
  import {
4
4
  claudeAuthPath,
@@ -62,13 +62,15 @@ export async function createAccount(name, options = {}) {
62
62
 
63
63
  ensureProfilesDir()
64
64
  const dir = profileDir(name)
65
- mkdirSync(dir, { recursive: true })
65
+ mkdirSync(dir, { recursive: true, mode: 0o700 })
66
66
 
67
67
  copyFileSync(authSource, profileAuthPath(name))
68
+ chmodSync(profileAuthPath(name), 0o600)
68
69
 
69
70
  const settingsSource = claudeSettingsPath()
70
71
  if (existsSync(settingsSource)) {
71
72
  copyFileSync(settingsSource, profileSettingsPath(name))
73
+ chmodSync(profileSettingsPath(name), 0o600)
72
74
  }
73
75
 
74
76
  console.log(msg.cloakCreated(name))
@@ -137,7 +137,7 @@ export function wearingCloak(name) {
137
137
  // --- Print-env (stdout, no chalk — evaluated by shell) ---
138
138
 
139
139
  export function printEnvExport(dir) {
140
- return `export CLAUDE_CONFIG_DIR=${dir}\n`
140
+ return `export CLAUDE_CONFIG_DIR="${dir}"\n`
141
141
  }
142
142
 
143
143
  export function printEnvEcho(name) {
package/src/lib/paths.js CHANGED
@@ -40,7 +40,7 @@ export function profileSettingsPath(name) {
40
40
 
41
41
  export function ensureProfilesDir() {
42
42
  if (!existsSync(PROFILES_DIR)) {
43
- mkdirSync(PROFILES_DIR, { recursive: true })
43
+ mkdirSync(PROFILES_DIR, { recursive: true, mode: 0o700 })
44
44
  }
45
45
  }
46
46
 
package/src/lib/setup.js CHANGED
@@ -1,7 +1,10 @@
1
- import { readFileSync, writeFileSync, existsSync } from 'fs'
1
+ import { readFileSync, writeFileSync, copyFileSync, existsSync } from 'fs'
2
2
  import { join } from 'path'
3
3
  import { homedir } from 'os'
4
4
 
5
+ const MARKER = '# Added by @synth1s/cloak'
6
+ const INIT_LINE = 'eval "$(cloak init)"'
7
+
5
8
  function getHome() {
6
9
  return process.env.HOME || homedir()
7
10
  }
@@ -22,16 +25,21 @@ export function isAlreadyInstalled(rcFilePath) {
22
25
 
23
26
  export function installToRcFile(rcFilePath) {
24
27
  if (!existsSync(rcFilePath)) {
25
- writeFileSync(rcFilePath, 'eval "$(cloak init)"\n')
28
+ writeFileSync(rcFilePath, `${MARKER}\n${INIT_LINE}\n`)
26
29
  return
27
30
  }
28
31
 
29
- // Read existing content and remove ALL lines containing 'cloak init'
32
+ // Backup before modifying
33
+ copyFileSync(rcFilePath, rcFilePath + '.cloak-backup')
34
+
35
+ // Remove ALL lines containing 'cloak init' or the marker
30
36
  const content = readFileSync(rcFilePath, 'utf8')
31
37
  const lines = content.split('\n')
32
- const cleaned = lines.filter(line => !line.includes('cloak init'))
38
+ const cleaned = lines.filter(line =>
39
+ !line.includes('cloak init') && line !== MARKER
40
+ )
33
41
  const cleanedContent = cleaned.join('\n').replace(/\n{3,}/g, '\n\n')
34
42
 
35
- // Write cleaned content + fresh init line
36
- writeFileSync(rcFilePath, cleanedContent.trimEnd() + '\neval "$(cloak init)"\n')
43
+ // Append fresh marker + init line
44
+ writeFileSync(rcFilePath, cleanedContent.trimEnd() + `\n${MARKER}\n${INIT_LINE}\n`)
37
45
  }