viruagent 1.0.0 → 1.0.1

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.
Files changed (2) hide show
  1. package/package.json +10 -4
  2. package/src/agent.js +39 -0
package/package.json CHANGED
@@ -1,21 +1,27 @@
1
1
  {
2
2
  "name": "viruagent",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "AI 기반 티스토리 블로그 자동 발행 CLI 도구",
5
5
  "main": "src/agent.js",
6
6
  "bin": {
7
- "viruagent": "./bin/viruagent.js"
7
+ "viruagent": "bin/viruagent.js"
8
8
  },
9
9
  "scripts": {
10
10
  "start": "node --no-deprecation src/agent.js",
11
11
  "test": "echo \"Error: no test specified\" && exit 1"
12
12
  },
13
- "keywords": ["tistory", "blog", "openai", "cli", "ai"],
13
+ "keywords": [
14
+ "tistory",
15
+ "blog",
16
+ "openai",
17
+ "cli",
18
+ "ai"
19
+ ],
14
20
  "author": "tkman",
15
21
  "license": "MIT",
16
22
  "repository": {
17
23
  "type": "git",
18
- "url": "https://github.com/greekr4/Viruagent.git"
24
+ "url": "git+https://github.com/greekr4/Viruagent.git"
19
25
  },
20
26
  "homepage": "https://github.com/greekr4/Viruagent#readme",
21
27
  "engines": {
package/src/agent.js CHANGED
@@ -613,9 +613,48 @@ const handleInput = async (input) => {
613
613
  }
614
614
  };
615
615
 
616
+ const askQuestion = (query) =>
617
+ new Promise((resolve) => {
618
+ const tmpRl = readline.createInterface({ input: process.stdin, output: process.stdout });
619
+ tmpRl.question(query, (answer) => {
620
+ tmpRl.close();
621
+ resolve(answer.trim());
622
+ });
623
+ });
624
+
625
+ const setupEnv = async () => {
626
+ const envPath = path.join(__dirname, '..', '.env');
627
+ if (fs.existsSync(envPath)) return;
628
+
629
+ console.log();
630
+ log.title('━━━ 초기 설정 ━━━');
631
+ console.log();
632
+ log.info('.env 파일이 없습니다. API 키를 설정합니다.\n');
633
+
634
+ const openaiKey = await askQuestion(chalk.cyan(' OpenAI API Key (필수): '));
635
+ if (!openaiKey) {
636
+ log.error('OpenAI API Key는 필수입니다. 프로그램을 종료합니다.');
637
+ process.exit(1);
638
+ }
639
+
640
+ const unsplashKey = await askQuestion(chalk.cyan(' Unsplash Access Key (선택, Enter로 건너뛰기): '));
641
+
642
+ const lines = [`OPENAI_API_KEY=${openaiKey}`];
643
+ if (unsplashKey) lines.push(`UNSPLASH_ACCESS_KEY=${unsplashKey}`);
644
+
645
+ fs.writeFileSync(envPath, lines.join('\n') + '\n');
646
+ log.success('.env 파일이 생성되었습니다!\n');
647
+
648
+ // 생성된 .env 즉시 로드
649
+ require('dotenv').config({ path: envPath });
650
+ };
651
+
616
652
  const main = async () => {
617
653
  await animateBanner();
618
654
 
655
+ // .env 파일 없으면 초기 설정
656
+ await setupEnv();
657
+
619
658
  // 세션 체크 — 로그인 필수
620
659
  while (!fs.existsSync(path.join(__dirname, '..', 'data', 'session.json'))) {
621
660
  log.warn('세션 파일(session.json)이 없습니다. 티스토리 로그인이 필요합니다.');