Skip to content

Commit 692233b

Browse files
makotanclaude
andcommitted
feat: installコマンドでagentsディレクトリもコピーするよう修正
- ビルドプロセスでdist/agentsディレクトリを作成し、agents/*.mdをコピー - installコマンドで.claude/agentsディレクトリも作成してagentsファイルをコピー - コピー結果の表示でagents/プレフィックス付きで表示 - agentsディレクトリが存在しない場合のエラーハンドリングを追加 - テスト済み: 23個のファイル(commands: 22個、agents: 1個)が正常コピー 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 1bce89d commit 692233b

File tree

2 files changed

+36
-13
lines changed

2 files changed

+36
-13
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"dist"
4141
],
4242
"scripts": {
43-
"build": "rm -rf dist && mkdir -p dist/commands && cp ./commands/*.md ./commands/*.sh dist/commands/ 2>/dev/null || true && tsup",
43+
"build": "rm -rf dist && mkdir -p dist/commands dist/agents && cp ./commands/*.md ./commands/*.sh dist/commands/ 2>/dev/null || true && cp ./agents/*.md dist/agents/ 2>/dev/null || true && tsup",
4444
"build:run": "pnpm build && node dist/cli.js",
4545
"check": "biome check src",
4646
"fix": "biome check src --write",

src/commands/install.tsx

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,55 @@ const InstallComponent: React.FC = () => {
2323

2424
// 現在のディレクトリを取得
2525
const currentDir = process.cwd();
26-
const targetDir = path.join(currentDir, ".claude", "commands");
26+
const commandsTargetDir = path.join(currentDir, ".claude", "commands");
27+
const agentsTargetDir = path.join(currentDir, ".claude", "agents");
2728

28-
// tsumikiのcommandsディレクトリを取得
29+
// tsumikiのcommandsディレクトリとagentsディレクトリを取得
2930
const __filename = fileURLToPath(import.meta.url);
3031
const __dirname = path.dirname(__filename);
31-
// ビルド後はdist/commandsを参照(cli.jsがdist/にあるため)
32-
const tsumikiDir = path.join(__dirname, "commands");
32+
// ビルド後はdist/commands, dist/agentsを参照(cli.jsがdist/にあるため)
33+
const tsumikiCommandsDir = path.join(__dirname, "commands");
34+
const tsumikiAgentsDir = path.join(__dirname, "agents");
3335

34-
// .claude/commandsディレクトリが存在しない場合は作成
35-
await fs.ensureDir(targetDir);
36+
// .claude/commandsと.claude/agentsディレクトリが存在しない場合は作成
37+
await fs.ensureDir(commandsTargetDir);
38+
await fs.ensureDir(agentsTargetDir);
3639

3740
setStatus("copying");
3841

3942
// commandsディレクトリ内のすべての.mdファイルと.shファイルを取得
40-
const files = await fs.readdir(tsumikiDir);
41-
const targetFiles = files.filter(
43+
const commandFiles = await fs.readdir(tsumikiCommandsDir);
44+
const targetCommandFiles = commandFiles.filter(
4245
(file) => file.endsWith(".md") || file.endsWith(".sh"),
4346
);
4447

48+
// agentsディレクトリ内のすべての.mdファイルを取得
49+
let targetAgentFiles: string[] = [];
50+
try {
51+
const agentFiles = await fs.readdir(tsumikiAgentsDir);
52+
targetAgentFiles = agentFiles.filter((file) => file.endsWith(".md"));
53+
} catch {
54+
// agentsディレクトリが存在しない場合はスキップ
55+
}
56+
4557
const copiedFilesList: string[] = [];
4658

47-
for (const file of targetFiles) {
48-
const sourcePath = path.join(tsumikiDir, file);
49-
const targetPath = path.join(targetDir, file);
59+
// commandsファイルをコピー
60+
for (const file of targetCommandFiles) {
61+
const sourcePath = path.join(tsumikiCommandsDir, file);
62+
const targetPath = path.join(commandsTargetDir, file);
63+
64+
await fs.copy(sourcePath, targetPath);
65+
copiedFilesList.push(`commands/${file}`);
66+
}
67+
68+
// agentsファイルをコピー
69+
for (const file of targetAgentFiles) {
70+
const sourcePath = path.join(tsumikiAgentsDir, file);
71+
const targetPath = path.join(agentsTargetDir, file);
5072

5173
await fs.copy(sourcePath, targetPath);
52-
copiedFilesList.push(file);
74+
copiedFilesList.push(`agents/${file}`);
5375
}
5476

5577
setCopiedFiles(copiedFilesList);
@@ -125,6 +147,7 @@ const InstallComponent: React.FC = () => {
125147
</Text>
126148
<Text color="white"> /tdd-requirements</Text>
127149
<Text color="white"> /kairo-design</Text>
150+
<Text color="white"> @agent-symbol-searcher</Text>
128151
<Text color="white"> ...</Text>
129152
</Box>
130153
);

0 commit comments

Comments
 (0)