makecc 0.2.8 → 0.2.11

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.
@@ -5,7 +5,7 @@
5
5
  <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>vite-temp</title>
8
- <script type="module" crossorigin src="/assets/index-C2Yw-VLu.js"></script>
8
+ <script type="module" crossorigin src="/assets/index-lpZin4sA.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/assets/index-v9IFpWkA.css">
10
10
  </head>
11
11
  <body>
@@ -1,4 +1,4 @@
1
- import 'dotenv/config';
1
+ import dotenv from 'dotenv';
2
2
  import express from 'express';
3
3
  import { createServer } from 'http';
4
4
  import { Server } from 'socket.io';
@@ -6,6 +6,18 @@ import cors from 'cors';
6
6
  import { join, dirname } from 'path';
7
7
  import { fileURLToPath } from 'url';
8
8
  import { existsSync, promises as fs } from 'fs';
9
+ // 프로젝트 경로의 .env 파일을 명시적으로 로드
10
+ // npx makecc 실행 시 MAKECC_PROJECT_PATH가 사용자 프로젝트 경로를 가리킴
11
+ const projectPath = process.env.MAKECC_PROJECT_PATH || process.cwd();
12
+ const envPath = join(projectPath, '.env');
13
+ if (existsSync(envPath)) {
14
+ dotenv.config({ path: envPath });
15
+ console.log(`Loaded .env from: ${envPath}`);
16
+ }
17
+ else {
18
+ // 폴백: 현재 디렉토리에서 로드 시도
19
+ dotenv.config();
20
+ }
9
21
  import { ClaudeService } from './services/claudeService';
10
22
  import { fileService } from './services/fileService';
11
23
  import { workflowAIService } from './services/workflowAIService';
@@ -66,20 +66,33 @@ export class SkillGeneratorService {
66
66
  this.projectRoot = projectRoot || process.env.MAKECC_PROJECT_PATH || process.cwd();
67
67
  }
68
68
  getClient(settings) {
69
- if (settings?.apiMode === 'direct' && settings.apiKey) {
70
- return new Anthropic({ apiKey: settings.apiKey });
71
- }
72
- if (settings?.apiMode === 'proxy' && settings.proxyUrl) {
69
+ const DEFAULT_ANTHROPIC_URL = 'https://api.anthropic.com';
70
+ // 1. 프록시 우선: proxyUrl이 설정되어 있고, 기본 Anthropic URL이 아닌 경우
71
+ // 프록시 서버가 API 키를 관리하므로 클라이언트는 키 불필요
72
+ if (settings?.proxyUrl && settings.proxyUrl !== DEFAULT_ANTHROPIC_URL) {
73
+ console.log(`Using proxy server: ${settings.proxyUrl}`);
73
74
  return new Anthropic({
74
75
  baseURL: settings.proxyUrl,
75
- apiKey: process.env.ANTHROPIC_API_KEY || 'proxy-mode',
76
+ apiKey: 'proxy-mode', // 프록시 서버가 실제 키를 관리
76
77
  });
77
78
  }
79
+ // 2. 환경변수에 API 키가 있으면 직접 호출
78
80
  const envApiKey = process.env.ANTHROPIC_API_KEY;
79
- if (!envApiKey) {
80
- throw new Error('API 키가 설정되지 않았습니다. 설정에서 API 키를 입력하세요.');
81
+ if (envApiKey) {
82
+ console.log('Using API key from environment variable');
83
+ return new Anthropic({ apiKey: envApiKey });
84
+ }
85
+ // 3. UI에서 direct 모드로 API 키를 직접 입력한 경우
86
+ if (settings?.apiMode === 'direct' && settings.apiKey) {
87
+ console.log('Using API key from UI settings');
88
+ return new Anthropic({ apiKey: settings.apiKey });
81
89
  }
82
- return new Anthropic({ apiKey: envApiKey });
90
+ // 4. 아무것도 없으면 에러
91
+ throw new Error('API 키가 설정되지 않았습니다.\n' +
92
+ '해결 방법:\n' +
93
+ '1. 프록시 서버 URL을 설정하거나\n' +
94
+ '2. 프로젝트 .env 파일에 ANTHROPIC_API_KEY를 추가하거나\n' +
95
+ '3. 설정에서 Direct 모드로 API 키를 직접 입력하세요.');
83
96
  }
84
97
  async generate(prompt, settings, onProgress) {
85
98
  const progress = onProgress || (() => { });
@@ -124,28 +124,33 @@ ${AVAILABLE_TOOLS.join(', ')}
124
124
  `;
125
125
  export class WorkflowAIService {
126
126
  getClient(settings) {
127
- // 1. Direct mode with user-provided API key
128
- if (settings?.apiMode === 'direct' && settings.apiKey) {
129
- return new Anthropic({
130
- apiKey: settings.apiKey,
131
- });
132
- }
133
- // 2. Proxy mode with custom base URL
134
- if (settings?.apiMode === 'proxy' && settings.proxyUrl) {
127
+ const DEFAULT_ANTHROPIC_URL = 'https://api.anthropic.com';
128
+ // 1. 프록시 우선: proxyUrl이 설정되어 있고, 기본 Anthropic URL이 아닌 경우
129
+ // 프록시 서버가 API 키를 관리하므로 클라이언트는 키 불필요
130
+ if (settings?.proxyUrl && settings.proxyUrl !== DEFAULT_ANTHROPIC_URL) {
131
+ console.log(`Using proxy server: ${settings.proxyUrl}`);
135
132
  return new Anthropic({
136
133
  baseURL: settings.proxyUrl,
137
- // Proxy server handles the API key
138
- apiKey: process.env.ANTHROPIC_API_KEY || 'proxy-mode',
134
+ apiKey: 'proxy-mode', // 프록시 서버가 실제 키를 관리
139
135
  });
140
136
  }
141
- // 3. Default: use environment variable
137
+ // 2. 환경변수에 API 키가 있으면 직접 호출
142
138
  const envApiKey = process.env.ANTHROPIC_API_KEY;
143
- if (!envApiKey) {
144
- throw new Error('API 키가 설정되지 않았습니다. 설정에서 API 키를 입력하거나 프록시 서버를 설정하세요.');
139
+ if (envApiKey) {
140
+ console.log('Using API key from environment variable');
141
+ return new Anthropic({ apiKey: envApiKey });
145
142
  }
146
- return new Anthropic({
147
- apiKey: envApiKey,
148
- });
143
+ // 3. UI에서 direct 모드로 API 키를 직접 입력한 경우
144
+ if (settings?.apiMode === 'direct' && settings.apiKey) {
145
+ console.log('Using API key from UI settings');
146
+ return new Anthropic({ apiKey: settings.apiKey });
147
+ }
148
+ // 4. 아무것도 없으면 에러
149
+ throw new Error('API 키가 설정되지 않았습니다.\n' +
150
+ '해결 방법:\n' +
151
+ '1. 프록시 서버 URL을 설정하거나\n' +
152
+ '2. 프로젝트 .env 파일에 ANTHROPIC_API_KEY를 추가하거나\n' +
153
+ '3. 설정에서 Direct 모드로 API 키를 직접 입력하세요.');
149
154
  }
150
155
  async generate(prompt, settings) {
151
156
  const client = this.getClient(settings);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "makecc",
3
- "version": "0.2.8",
3
+ "version": "0.2.11",
4
4
  "type": "module",
5
5
  "description": "Visual workflow builder for Claude Code agents and skills",
6
6
  "keywords": [
package/server/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import 'dotenv/config';
1
+ import dotenv from 'dotenv';
2
2
  import express from 'express';
3
3
  import { createServer } from 'http';
4
4
  import { Server } from 'socket.io';
@@ -6,6 +6,18 @@ import cors from 'cors';
6
6
  import { join, dirname } from 'path';
7
7
  import { fileURLToPath } from 'url';
8
8
  import { existsSync, promises as fs } from 'fs';
9
+
10
+ // 프로젝트 경로의 .env 파일을 명시적으로 로드
11
+ // npx makecc 실행 시 MAKECC_PROJECT_PATH가 사용자 프로젝트 경로를 가리킴
12
+ const projectPath = process.env.MAKECC_PROJECT_PATH || process.cwd();
13
+ const envPath = join(projectPath, '.env');
14
+ if (existsSync(envPath)) {
15
+ dotenv.config({ path: envPath });
16
+ console.log(`Loaded .env from: ${envPath}`);
17
+ } else {
18
+ // 폴백: 현재 디렉토리에서 로드 시도
19
+ dotenv.config();
20
+ }
9
21
  import { ClaudeService } from './services/claudeService';
10
22
  import { fileService } from './services/fileService';
11
23
  import { workflowAIService } from './services/workflowAIService';
@@ -107,23 +107,39 @@ export class SkillGeneratorService {
107
107
  }
108
108
 
109
109
  private getClient(settings?: ApiSettings): Anthropic {
110
- if (settings?.apiMode === 'direct' && settings.apiKey) {
111
- return new Anthropic({ apiKey: settings.apiKey });
112
- }
110
+ const DEFAULT_ANTHROPIC_URL = 'https://api.anthropic.com';
113
111
 
114
- if (settings?.apiMode === 'proxy' && settings.proxyUrl) {
112
+ // 1. 프록시 우선: proxyUrl 설정되어 있고, 기본 Anthropic URL이 아닌 경우
113
+ // 프록시 서버가 API 키를 관리하므로 클라이언트는 키 불필요
114
+ if (settings?.proxyUrl && settings.proxyUrl !== DEFAULT_ANTHROPIC_URL) {
115
+ console.log(`Using proxy server: ${settings.proxyUrl}`);
115
116
  return new Anthropic({
116
117
  baseURL: settings.proxyUrl,
117
- apiKey: process.env.ANTHROPIC_API_KEY || 'proxy-mode',
118
+ apiKey: 'proxy-mode', // 프록시 서버가 실제 키를 관리
118
119
  });
119
120
  }
120
121
 
122
+ // 2. 환경변수에 API 키가 있으면 직접 호출
121
123
  const envApiKey = process.env.ANTHROPIC_API_KEY;
122
- if (!envApiKey) {
123
- throw new Error('API 키가 설정되지 않았습니다. 설정에서 API 키를 입력하세요.');
124
+ if (envApiKey) {
125
+ console.log('Using API key from environment variable');
126
+ return new Anthropic({ apiKey: envApiKey });
127
+ }
128
+
129
+ // 3. UI에서 direct 모드로 API 키를 직접 입력한 경우
130
+ if (settings?.apiMode === 'direct' && settings.apiKey) {
131
+ console.log('Using API key from UI settings');
132
+ return new Anthropic({ apiKey: settings.apiKey });
124
133
  }
125
134
 
126
- return new Anthropic({ apiKey: envApiKey });
135
+ // 4. 아무것도 없으면 에러
136
+ throw new Error(
137
+ 'API 키가 설정되지 않았습니다.\n' +
138
+ '해결 방법:\n' +
139
+ '1. 프록시 서버 URL을 설정하거나\n' +
140
+ '2. 프로젝트 .env 파일에 ANTHROPIC_API_KEY를 추가하거나\n' +
141
+ '3. 설정에서 Direct 모드로 API 키를 직접 입력하세요.'
142
+ );
127
143
  }
128
144
 
129
145
  async generate(
@@ -165,31 +165,39 @@ ${AVAILABLE_TOOLS.join(', ')}
165
165
 
166
166
  export class WorkflowAIService {
167
167
  private getClient(settings?: ApiSettings): Anthropic {
168
- // 1. Direct mode with user-provided API key
169
- if (settings?.apiMode === 'direct' && settings.apiKey) {
170
- return new Anthropic({
171
- apiKey: settings.apiKey,
172
- });
173
- }
168
+ const DEFAULT_ANTHROPIC_URL = 'https://api.anthropic.com';
174
169
 
175
- // 2. Proxy mode with custom base URL
176
- if (settings?.apiMode === 'proxy' && settings.proxyUrl) {
170
+ // 1. 프록시 우선: proxyUrl이 설정되어 있고, 기본 Anthropic URL이 아닌 경우
171
+ // 프록시 서버가 API 키를 관리하므로 클라이언트는 키 불필요
172
+ if (settings?.proxyUrl && settings.proxyUrl !== DEFAULT_ANTHROPIC_URL) {
173
+ console.log(`Using proxy server: ${settings.proxyUrl}`);
177
174
  return new Anthropic({
178
175
  baseURL: settings.proxyUrl,
179
- // Proxy server handles the API key
180
- apiKey: process.env.ANTHROPIC_API_KEY || 'proxy-mode',
176
+ apiKey: 'proxy-mode', // 프록시 서버가 실제 키를 관리
181
177
  });
182
178
  }
183
179
 
184
- // 3. Default: use environment variable
180
+ // 2. 환경변수에 API 키가 있으면 직접 호출
185
181
  const envApiKey = process.env.ANTHROPIC_API_KEY;
186
- if (!envApiKey) {
187
- throw new Error('API 키가 설정되지 않았습니다. 설정에서 API 키를 입력하거나 프록시 서버를 설정하세요.');
182
+ if (envApiKey) {
183
+ console.log('Using API key from environment variable');
184
+ return new Anthropic({ apiKey: envApiKey });
188
185
  }
189
186
 
190
- return new Anthropic({
191
- apiKey: envApiKey,
192
- });
187
+ // 3. UI에서 direct 모드로 API 키를 직접 입력한 경우
188
+ if (settings?.apiMode === 'direct' && settings.apiKey) {
189
+ console.log('Using API key from UI settings');
190
+ return new Anthropic({ apiKey: settings.apiKey });
191
+ }
192
+
193
+ // 4. 아무것도 없으면 에러
194
+ throw new Error(
195
+ 'API 키가 설정되지 않았습니다.\n' +
196
+ '해결 방법:\n' +
197
+ '1. 프록시 서버 URL을 설정하거나\n' +
198
+ '2. 프로젝트 .env 파일에 ANTHROPIC_API_KEY를 추가하거나\n' +
199
+ '3. 설정에서 Direct 모드로 API 키를 직접 입력하세요.'
200
+ );
193
201
  }
194
202
 
195
203
  async generate(prompt: string, settings?: ApiSettings): Promise<AIWorkflowResult> {