@synth1s/cloak 2.0.1 → 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 +1 -1
- package/src/cli.js +19 -5
- package/src/commands/create.js +4 -2
- package/src/lib/messages.js +1 -1
- package/src/lib/paths.js +1 -1
- package/src/lib/setup.js +14 -6
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -24,6 +24,20 @@ program
|
|
|
24
24
|
.name('cloak')
|
|
25
25
|
.description('Cloak your Claude. Switch identities in seconds.')
|
|
26
26
|
.version(pkg.version)
|
|
27
|
+
.addHelpText('after', `
|
|
28
|
+
Quick start:
|
|
29
|
+
cloak create work Save your current Claude session
|
|
30
|
+
cloak create home Save another session
|
|
31
|
+
cloak switch work Switch to a cloak
|
|
32
|
+
cloak list See all your cloaks
|
|
33
|
+
|
|
34
|
+
Shell integration (recommended):
|
|
35
|
+
eval "$(cloak init)" Add to .bashrc/.zshrc for:
|
|
36
|
+
claude -a work Switch and launch Claude in one step
|
|
37
|
+
claude account switch work Same as cloak switch
|
|
38
|
+
claude account list Same as cloak list
|
|
39
|
+
|
|
40
|
+
Learn more: https://github.com/synth1s/cloak`)
|
|
27
41
|
|
|
28
42
|
program
|
|
29
43
|
.command('create [name]')
|
|
@@ -37,10 +51,10 @@ program
|
|
|
37
51
|
.command('switch <name>')
|
|
38
52
|
.alias('use')
|
|
39
53
|
.description('Wear a different cloak')
|
|
40
|
-
.
|
|
41
|
-
|
|
42
|
-
if (!
|
|
43
|
-
return switchAccount(name, { printEnv
|
|
54
|
+
.action((name) => {
|
|
55
|
+
const printEnv = process.argv.includes('--print-env')
|
|
56
|
+
if (!printEnv) renderContextBar('switch')
|
|
57
|
+
return switchAccount(name, { printEnv })
|
|
44
58
|
})
|
|
45
59
|
|
|
46
60
|
program
|
|
@@ -85,7 +99,7 @@ program
|
|
|
85
99
|
|
|
86
100
|
program
|
|
87
101
|
.command('init')
|
|
88
|
-
.description('Output shell integration code
|
|
102
|
+
.description('Output shell integration code')
|
|
89
103
|
.action(initShell)
|
|
90
104
|
|
|
91
105
|
program.parse()
|
package/src/commands/create.js
CHANGED
|
@@ -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))
|
package/src/lib/messages.js
CHANGED
|
@@ -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
|
|
140
|
+
return `export CLAUDE_CONFIG_DIR="${dir}"\n`
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
export function printEnvEcho(name) {
|
package/src/lib/paths.js
CHANGED
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,
|
|
28
|
+
writeFileSync(rcFilePath, `${MARKER}\n${INIT_LINE}\n`)
|
|
26
29
|
return
|
|
27
30
|
}
|
|
28
31
|
|
|
29
|
-
//
|
|
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 =>
|
|
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
|
-
//
|
|
36
|
-
writeFileSync(rcFilePath, cleanedContent.trimEnd() +
|
|
43
|
+
// Append fresh marker + init line
|
|
44
|
+
writeFileSync(rcFilePath, cleanedContent.trimEnd() + `\n${MARKER}\n${INIT_LINE}\n`)
|
|
37
45
|
}
|