quickclaude 1.0.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/bin/quickclaude.js +109 -0
- package/package.json +22 -0
- package/src/index.js +109 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import * as p from "@clack/prompts";
|
|
4
|
+
import { readdirSync, existsSync } from "fs";
|
|
5
|
+
import { join, sep } from "path";
|
|
6
|
+
import { homedir } from "os";
|
|
7
|
+
import { execSync, spawn } from "child_process";
|
|
8
|
+
|
|
9
|
+
const CLAUDE_PROJECTS_DIR = join(homedir(), ".claude", "projects");
|
|
10
|
+
|
|
11
|
+
// 인코딩된 디렉토리명에서 실제 경로를 복원
|
|
12
|
+
// "-Users-seunghyunhong-Documents-projects-mcp-overwatch" 같은 경우
|
|
13
|
+
// -를 /로 바꾸면 mcp/overwatch가 되어 틀려짐
|
|
14
|
+
// → 파일시스템을 실제로 탐색하며 매칭
|
|
15
|
+
function resolvePath(encoded) {
|
|
16
|
+
const parts = encoded.replace(/^-/, "").split("-");
|
|
17
|
+
let current = sep;
|
|
18
|
+
|
|
19
|
+
let i = 0;
|
|
20
|
+
while (i < parts.length) {
|
|
21
|
+
let matched = false;
|
|
22
|
+
// 긴 조합부터 시도 (mcp-overwatch, Unreal Projects 등)
|
|
23
|
+
for (let len = parts.length - i; len >= 1; len--) {
|
|
24
|
+
const segment = parts.slice(i, i + len);
|
|
25
|
+
// "-"와 " " 두 가지 구분자 조합을 모두 시도
|
|
26
|
+
const separators = ["-", " "];
|
|
27
|
+
for (const joiner of separators) {
|
|
28
|
+
const candidate = segment.join(joiner);
|
|
29
|
+
const fullPath = join(current, candidate);
|
|
30
|
+
if (existsSync(fullPath)) {
|
|
31
|
+
current = fullPath;
|
|
32
|
+
i += len;
|
|
33
|
+
matched = true;
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (matched) break;
|
|
38
|
+
}
|
|
39
|
+
if (!matched) return null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return current;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function getProjects() {
|
|
46
|
+
if (!existsSync(CLAUDE_PROJECTS_DIR)) {
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const entries = readdirSync(CLAUDE_PROJECTS_DIR, { withFileTypes: true });
|
|
51
|
+
|
|
52
|
+
return entries
|
|
53
|
+
.filter((e) => e.isDirectory())
|
|
54
|
+
.map((e) => {
|
|
55
|
+
const path = resolvePath(e.name);
|
|
56
|
+
return { dirName: e.name, path };
|
|
57
|
+
})
|
|
58
|
+
.filter((p) => {
|
|
59
|
+
if (!p.path) return false;
|
|
60
|
+
if (p.path.includes(`claude${sep}worktrees`)) return false;
|
|
61
|
+
return existsSync(p.path);
|
|
62
|
+
})
|
|
63
|
+
.sort((a, b) => a.path.localeCompare(b.path));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function getProjectLabel(path) {
|
|
67
|
+
const home = homedir();
|
|
68
|
+
const display = path.startsWith(home) ? "~" + path.slice(home.length) : path;
|
|
69
|
+
return display;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async function main() {
|
|
73
|
+
p.intro("quickclaude");
|
|
74
|
+
|
|
75
|
+
const projects = getProjects();
|
|
76
|
+
|
|
77
|
+
if (projects.length === 0) {
|
|
78
|
+
p.cancel("Claude 프로젝트를 찾을 수 없습니다.");
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const selected = await p.select({
|
|
83
|
+
message: "프로젝트를 선택하세요",
|
|
84
|
+
options: projects.map((proj) => ({
|
|
85
|
+
value: proj.path,
|
|
86
|
+
label: getProjectLabel(proj.path),
|
|
87
|
+
})),
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
if (p.isCancel(selected)) {
|
|
91
|
+
p.cancel("취소됨");
|
|
92
|
+
process.exit(0);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
p.outro(`${selected} 에서 Claude 시작...`);
|
|
96
|
+
|
|
97
|
+
// claude 실행 (현재 터미널에서 interactive하게)
|
|
98
|
+
const child = spawn("claude", [], {
|
|
99
|
+
cwd: selected,
|
|
100
|
+
stdio: "inherit",
|
|
101
|
+
shell: true,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
child.on("exit", (code) => {
|
|
105
|
+
process.exit(code ?? 0);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
main();
|
package/package.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "quickclaude",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Quickly launch Claude Code in your project directories",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"quickclaude": "bin/quickclaude.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"start": "node src/index.js"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"claude",
|
|
14
|
+
"cli",
|
|
15
|
+
"launcher"
|
|
16
|
+
],
|
|
17
|
+
"author": "",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@clack/prompts": "^1.1.0"
|
|
21
|
+
}
|
|
22
|
+
}
|
package/src/index.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import * as p from "@clack/prompts";
|
|
4
|
+
import { readdirSync, existsSync } from "fs";
|
|
5
|
+
import { join, sep } from "path";
|
|
6
|
+
import { homedir } from "os";
|
|
7
|
+
import { execSync, spawn } from "child_process";
|
|
8
|
+
|
|
9
|
+
const CLAUDE_PROJECTS_DIR = join(homedir(), ".claude", "projects");
|
|
10
|
+
|
|
11
|
+
// 인코딩된 디렉토리명에서 실제 경로를 복원
|
|
12
|
+
// "-Users-seunghyunhong-Documents-projects-mcp-overwatch" 같은 경우
|
|
13
|
+
// -를 /로 바꾸면 mcp/overwatch가 되어 틀려짐
|
|
14
|
+
// → 파일시스템을 실제로 탐색하며 매칭
|
|
15
|
+
function resolvePath(encoded) {
|
|
16
|
+
const parts = encoded.replace(/^-/, "").split("-");
|
|
17
|
+
let current = sep;
|
|
18
|
+
|
|
19
|
+
let i = 0;
|
|
20
|
+
while (i < parts.length) {
|
|
21
|
+
let matched = false;
|
|
22
|
+
// 긴 조합부터 시도 (mcp-overwatch, Unreal Projects 등)
|
|
23
|
+
for (let len = parts.length - i; len >= 1; len--) {
|
|
24
|
+
const segment = parts.slice(i, i + len);
|
|
25
|
+
// "-"와 " " 두 가지 구분자 조합을 모두 시도
|
|
26
|
+
const separators = ["-", " "];
|
|
27
|
+
for (const joiner of separators) {
|
|
28
|
+
const candidate = segment.join(joiner);
|
|
29
|
+
const fullPath = join(current, candidate);
|
|
30
|
+
if (existsSync(fullPath)) {
|
|
31
|
+
current = fullPath;
|
|
32
|
+
i += len;
|
|
33
|
+
matched = true;
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (matched) break;
|
|
38
|
+
}
|
|
39
|
+
if (!matched) return null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return current;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function getProjects() {
|
|
46
|
+
if (!existsSync(CLAUDE_PROJECTS_DIR)) {
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const entries = readdirSync(CLAUDE_PROJECTS_DIR, { withFileTypes: true });
|
|
51
|
+
|
|
52
|
+
return entries
|
|
53
|
+
.filter((e) => e.isDirectory())
|
|
54
|
+
.map((e) => {
|
|
55
|
+
const path = resolvePath(e.name);
|
|
56
|
+
return { dirName: e.name, path };
|
|
57
|
+
})
|
|
58
|
+
.filter((p) => {
|
|
59
|
+
if (!p.path) return false;
|
|
60
|
+
if (p.path.includes(`claude${sep}worktrees`)) return false;
|
|
61
|
+
return existsSync(p.path);
|
|
62
|
+
})
|
|
63
|
+
.sort((a, b) => a.path.localeCompare(b.path));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function getProjectLabel(path) {
|
|
67
|
+
const home = homedir();
|
|
68
|
+
const display = path.startsWith(home) ? "~" + path.slice(home.length) : path;
|
|
69
|
+
return display;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async function main() {
|
|
73
|
+
p.intro("quickclaude");
|
|
74
|
+
|
|
75
|
+
const projects = getProjects();
|
|
76
|
+
|
|
77
|
+
if (projects.length === 0) {
|
|
78
|
+
p.cancel("Claude 프로젝트를 찾을 수 없습니다.");
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const selected = await p.select({
|
|
83
|
+
message: "프로젝트를 선택하세요",
|
|
84
|
+
options: projects.map((proj) => ({
|
|
85
|
+
value: proj.path,
|
|
86
|
+
label: getProjectLabel(proj.path),
|
|
87
|
+
})),
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
if (p.isCancel(selected)) {
|
|
91
|
+
p.cancel("취소됨");
|
|
92
|
+
process.exit(0);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
p.outro(`${selected} 에서 Claude 시작...`);
|
|
96
|
+
|
|
97
|
+
// claude 실행 (현재 터미널에서 interactive하게)
|
|
98
|
+
const child = spawn("claude", [], {
|
|
99
|
+
cwd: selected,
|
|
100
|
+
stdio: "inherit",
|
|
101
|
+
shell: true,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
child.on("exit", (code) => {
|
|
105
|
+
process.exit(code ?? 0);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
main();
|