clitrigger 0.1.1 → 0.1.4
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/.env.example +1 -1
- package/README.md +34 -1
- package/README_EN.md +219 -0
- package/bin/clitrigger.js +160 -26
- package/bin/postuninstall.js +19 -0
- package/dist/client/assets/index-B4peRpUi.js +134 -0
- package/dist/client/assets/index-Bjyoy6lB.css +1 -0
- package/dist/client/index.html +3 -2
- package/dist/client/logo-icon.svg +15 -0
- package/dist/client/logo.svg +17 -0
- package/dist/server/db/queries.d.ts +7 -3
- package/dist/server/db/queries.d.ts.map +1 -1
- package/dist/server/db/queries.js +15 -3
- package/dist/server/db/queries.js.map +1 -1
- package/dist/server/db/schema.d.ts.map +1 -1
- package/dist/server/db/schema.js +4 -0
- package/dist/server/db/schema.js.map +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +36 -5
- package/dist/server/index.js.map +1 -1
- package/dist/server/middleware/auth.d.ts.map +1 -1
- package/dist/server/middleware/auth.js +0 -4
- package/dist/server/middleware/auth.js.map +1 -1
- package/dist/server/routes/auth.d.ts.map +1 -1
- package/dist/server/routes/auth.js +1 -2
- package/dist/server/routes/auth.js.map +1 -1
- package/dist/server/routes/execution.d.ts.map +1 -1
- package/dist/server/routes/execution.js +65 -5
- package/dist/server/routes/execution.js.map +1 -1
- package/dist/server/routes/projects.d.ts.map +1 -1
- package/dist/server/routes/projects.js +82 -5
- package/dist/server/routes/projects.js.map +1 -1
- package/dist/server/services/claude-manager.d.ts +1 -1
- package/dist/server/services/claude-manager.d.ts.map +1 -1
- package/dist/server/services/claude-manager.js +46 -17
- package/dist/server/services/claude-manager.js.map +1 -1
- package/dist/server/services/cli-adapters.d.ts +4 -0
- package/dist/server/services/cli-adapters.d.ts.map +1 -1
- package/dist/server/services/cli-adapters.js +12 -3
- package/dist/server/services/cli-adapters.js.map +1 -1
- package/dist/server/services/debug-logger.d.ts +1 -0
- package/dist/server/services/debug-logger.d.ts.map +1 -1
- package/dist/server/services/debug-logger.js +15 -0
- package/dist/server/services/debug-logger.js.map +1 -1
- package/dist/server/services/log-streamer.d.ts +7 -0
- package/dist/server/services/log-streamer.d.ts.map +1 -1
- package/dist/server/services/log-streamer.js +26 -13
- package/dist/server/services/log-streamer.js.map +1 -1
- package/dist/server/services/orchestrator.d.ts +8 -0
- package/dist/server/services/orchestrator.d.ts.map +1 -1
- package/dist/server/services/orchestrator.js +142 -39
- package/dist/server/services/orchestrator.js.map +1 -1
- package/dist/server/services/pty-output-filter.d.ts +18 -0
- package/dist/server/services/pty-output-filter.d.ts.map +1 -0
- package/dist/server/services/pty-output-filter.js +125 -0
- package/dist/server/services/pty-output-filter.js.map +1 -0
- package/dist/server/services/task-intent.d.ts +6 -0
- package/dist/server/services/task-intent.d.ts.map +1 -0
- package/dist/server/services/task-intent.js +4 -0
- package/dist/server/services/task-intent.js.map +1 -0
- package/dist/server/services/tunnel-manager.d.ts +2 -2
- package/dist/server/services/tunnel-manager.d.ts.map +1 -1
- package/dist/server/services/tunnel-manager.js +20 -7
- package/dist/server/services/tunnel-manager.js.map +1 -1
- package/dist/server/services/worktree-manager.d.ts +5 -0
- package/dist/server/services/worktree-manager.d.ts.map +1 -1
- package/dist/server/services/worktree-manager.js +40 -13
- package/dist/server/services/worktree-manager.js.map +1 -1
- package/dist/server/websocket/index.js +2 -2
- package/dist/server/websocket/index.js.map +1 -1
- package/package.json +6 -3
- package/dist/client/assets/index-BkOCv65b.css +0 -1
- package/dist/client/assets/index-Fbf16Lh1.js +0 -129
package/.env.example
CHANGED
package/README.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<picture>
|
|
4
|
+
<source media="(prefers-color-scheme: dark)" srcset="src/client/public/logo.svg">
|
|
5
|
+
<source media="(prefers-color-scheme: light)" srcset="src/client/public/logo.svg">
|
|
6
|
+
<img alt="CLITrigger" src="src/client/public/logo.svg" width="360">
|
|
7
|
+
</picture>
|
|
4
8
|
|
|
5
9
|
**AI-Powered Parallel Worktree Automation**
|
|
6
10
|
|
|
@@ -25,6 +29,11 @@
|
|
|
25
29
|
> 하지만 **이해 없는 바이브 코딩**은 결국 한계에 부딪힌다.
|
|
26
30
|
> CLITrigger는 AI를 병렬로 돌리면서도, 개발자가 맥락을 잃지 않도록 설계되었다.
|
|
27
31
|
|
|
32
|
+
<div align="center">
|
|
33
|
+
<img src="docs/images/screenshot-tasks.png" alt="Tasks — 병렬 워크트리 실행" width="800">
|
|
34
|
+
<p><em>병렬 워크트리에서 AI CLI가 동시에 작업을 처리하는 모습</em></p>
|
|
35
|
+
</div>
|
|
36
|
+
|
|
28
37
|
---
|
|
29
38
|
|
|
30
39
|
## 왜 CLITrigger인가?
|
|
@@ -67,9 +76,19 @@ TODO를 작성하면 각 작업마다 격리된 git worktree가 자동 생성된
|
|
|
67
76
|
### 다중 AI 토론 (Discussion)
|
|
68
77
|
아키텍트, 개발자, 리뷰어 등 역할이 다른 AI 에이전트들이 라운드 방식으로 토론한 뒤, 합의된 내용을 바탕으로 자동 구현까지 이어진다. 단일 AI의 판단보다 훨씬 검증된 설계 결과물이 나온다.
|
|
69
78
|
|
|
79
|
+
<div align="center">
|
|
80
|
+
<img src="docs/images/screenshot-discussions.png" alt="Discussions — 다중 AI 토론" width="800">
|
|
81
|
+
<p><em>여러 AI 에이전트가 역할별로 토론하는 Discussion 화면</em></p>
|
|
82
|
+
</div>
|
|
83
|
+
|
|
70
84
|
### 예약 실행 (Scheduler)
|
|
71
85
|
토큰 한도를 피해 새벽이나 특정 시각에 작업을 예약 실행할 수 있다. cron 기반 반복 스케줄과 일회성 예약 모두 지원한다.
|
|
72
86
|
|
|
87
|
+
<div align="center">
|
|
88
|
+
<img src="docs/images/screenshot-schedules.png" alt="Schedules — 예약 실행" width="800">
|
|
89
|
+
<p><em>cron 기반 반복·일회성 예약 실행 설정 화면</em></p>
|
|
90
|
+
</div>
|
|
91
|
+
|
|
73
92
|
### 파이프라인 (Pipeline)
|
|
74
93
|
여러 작업을 순차 또는 병렬로 묶어 다단계 실행 흐름을 구성한다. 복잡한 릴리스 절차도 자동화할 수 있다.
|
|
75
94
|
|
|
@@ -118,6 +137,9 @@ clitrigger config password # 비밀번호 변경
|
|
|
118
137
|
```
|
|
119
138
|
|
|
120
139
|
> **사전 요구사항**: Node.js 20+, Git, 사용할 AI CLI (Claude / Gemini / Codex 중 하나 이상)
|
|
140
|
+
>
|
|
141
|
+
> **지원 플랫폼**: Windows · macOS · Linux — 모든 핵심 코드가 크로스 플랫폼 대응되어 있다.
|
|
142
|
+
> macOS에서는 네이티브 모듈 빌드를 위해 `xcode-select --install`이 필요할 수 있다.
|
|
121
143
|
|
|
122
144
|
### 소스에서 직접 실행 (개발용)
|
|
123
145
|
|
|
@@ -154,6 +176,17 @@ npm run dev
|
|
|
154
176
|
| `start-tunnel.bat` | 터널 모드 실행 |
|
|
155
177
|
| `test.bat` | 전체 테스트 |
|
|
156
178
|
|
|
179
|
+
#### macOS / Linux
|
|
180
|
+
|
|
181
|
+
`npm run` 명령어가 모든 플랫폼에서 동일하게 동작한다. `.bat` 스크립트 대신 터미널에서 직접 실행하면 된다.
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
npm run dev # 개발 모드
|
|
185
|
+
npm run build # 빌드
|
|
186
|
+
npm run start # 프로덕션 실행
|
|
187
|
+
npm test # 테스트
|
|
188
|
+
```
|
|
189
|
+
|
|
157
190
|
</details>
|
|
158
191
|
|
|
159
192
|
### 외부 접속 (Cloudflare Tunnel)
|
package/README_EN.md
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<picture>
|
|
4
|
+
<source media="(prefers-color-scheme: dark)" srcset="src/client/public/logo.svg">
|
|
5
|
+
<source media="(prefers-color-scheme: light)" srcset="src/client/public/logo.svg">
|
|
6
|
+
<img alt="CLITrigger" src="src/client/public/logo.svg" width="360">
|
|
7
|
+
</picture>
|
|
8
|
+
|
|
9
|
+
**AI-Powered Parallel Worktree Automation**
|
|
10
|
+
|
|
11
|
+
*Write tasks. Let AI execute them in parallel. Review and merge.*
|
|
12
|
+
|
|
13
|
+
<p align="center">
|
|
14
|
+
<a href="README.md">한국어</a> ·
|
|
15
|
+
<a href="README_EN.md">English</a>
|
|
16
|
+
</p>
|
|
17
|
+
|
|
18
|
+
[](LICENSE)
|
|
19
|
+
[](https://www.npmjs.com/package/clitrigger)
|
|
20
|
+
[](https://nodejs.org)
|
|
21
|
+
[](https://www.typescriptlang.org)
|
|
22
|
+
[](https://react.dev)
|
|
23
|
+
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
> In the age of AI-generated code, the developer's role is shifting toward supervision and review.
|
|
29
|
+
> But **vibe coding without understanding** eventually hits a wall.
|
|
30
|
+
> CLITrigger lets you run AI in parallel — while keeping you in full context of what's happening.
|
|
31
|
+
|
|
32
|
+
<div align="center">
|
|
33
|
+
<img src="docs/images/screenshot-tasks.png" alt="Tasks — Parallel worktree execution" width="800">
|
|
34
|
+
<p><em>AI CLIs working simultaneously across isolated git worktrees</em></p>
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Why CLITrigger?
|
|
40
|
+
|
|
41
|
+
Boris Cherny, creator of Claude Code, emphasizes **parallelism** as the key to AI-assisted development. Waiting for one task to finish before starting the next is the new bottleneck.
|
|
42
|
+
|
|
43
|
+
At the same time, most AI services have **rate limits** — you can burn through your daily quota by noon and be stuck waiting until midnight.
|
|
44
|
+
|
|
45
|
+
CLITrigger solves both problems:
|
|
46
|
+
|
|
47
|
+
- **Right now** — Multiple tasks run in isolated git worktrees, with Claude / Gemini / Codex executing in parallel
|
|
48
|
+
- **Without hitting limits** — Schedule tasks for off-peak hours to make the most of your token quota
|
|
49
|
+
- **Better output** — Multiple AI agents debate and review before implementation, producing higher-quality results than a single AI working alone
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## How It Works
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
[Write TODOs in the browser]
|
|
57
|
+
↓
|
|
58
|
+
┌──────────────────────────────────────────────────────────────┐
|
|
59
|
+
│ TODO 1: Implement login → worktree/feature-login → Claude CLI → auto-commit │
|
|
60
|
+
│ TODO 2: Signup page → worktree/feature-signup → Gemini CLI → auto-commit │
|
|
61
|
+
│ TODO 3: Dashboard layout → worktree/feature-dashboard → Claude CLI → auto-commit │
|
|
62
|
+
└──────────────────────────────────────────────────────────────┘
|
|
63
|
+
↓
|
|
64
|
+
[Live log streaming → Review diffs → Merge to main]
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Each TODO runs in its **own isolated git worktree** — no conflicts, separate branches, independent commit history. You review the results and decide what to merge.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Features
|
|
72
|
+
|
|
73
|
+
### Parallel Worktree Execution
|
|
74
|
+
Each TODO automatically gets its own git worktree. Claude / Gemini / Codex CLIs execute simultaneously in parallel. Dependency chains let you automatically trigger follow-up tasks and branch merges once prerequisites complete.
|
|
75
|
+
|
|
76
|
+
### Multi-Agent Discussion
|
|
77
|
+
AI agents with different roles — architect, developer, reviewer — debate in rounds before implementation. The resulting design is far more robust than a single AI working in isolation.
|
|
78
|
+
|
|
79
|
+
<div align="center">
|
|
80
|
+
<img src="docs/images/screenshot-discussions.png" alt="Discussions — Multi-agent debate" width="800">
|
|
81
|
+
<p><em>Multiple AI agents with different roles debating in the Discussion view</em></p>
|
|
82
|
+
</div>
|
|
83
|
+
|
|
84
|
+
### Scheduled Execution
|
|
85
|
+
Schedule tasks for off-peak hours to avoid rate limits. Supports both recurring cron schedules and one-time scheduled runs.
|
|
86
|
+
|
|
87
|
+
<div align="center">
|
|
88
|
+
<img src="docs/images/screenshot-schedules.png" alt="Schedules — Scheduled execution" width="800">
|
|
89
|
+
<p><em>Cron-based recurring and one-time scheduled task execution</em></p>
|
|
90
|
+
</div>
|
|
91
|
+
|
|
92
|
+
### Pipeline Execution
|
|
93
|
+
Chain tasks into multi-phase sequential or parallel pipelines. Automate complex release workflows end-to-end.
|
|
94
|
+
|
|
95
|
+
### Live Logs & Built-in Git Client
|
|
96
|
+
WebSocket-based real-time log streaming. Commit, push, merge, and manage branches directly from the web UI — so you always stay in context.
|
|
97
|
+
|
|
98
|
+
### Multi-CLI & Sandbox Mode
|
|
99
|
+
Select Claude / Gemini / Codex per project or per task. Strict sandbox mode restricts CLI file access to the worktree directory only.
|
|
100
|
+
|
|
101
|
+
### Plugin System
|
|
102
|
+
Jira, GitHub, Notion integrations and gstack skill injection — add external service integrations as self-contained plugins.
|
|
103
|
+
|
|
104
|
+
### Remote Access
|
|
105
|
+
Access and control from anywhere via Cloudflare Tunnel.
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## Tech Stack
|
|
110
|
+
|
|
111
|
+
| Layer | Tech |
|
|
112
|
+
|-------|------|
|
|
113
|
+
| Backend | Node.js · Express · TypeScript · SQLite · WebSocket |
|
|
114
|
+
| Frontend | React 18 · Vite · Tailwind CSS |
|
|
115
|
+
| AI CLIs | Claude · Gemini · Codex (Adapter Pattern) |
|
|
116
|
+
| Git | simple-git (worktree management) |
|
|
117
|
+
| Scheduling | node-cron |
|
|
118
|
+
| Terminal | node-pty (TTY support) |
|
|
119
|
+
| Remote Access | Cloudflare Tunnel (optional) |
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
## Quick Start
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
npm i -g clitrigger
|
|
127
|
+
clitrigger
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
On first run, you'll be prompted to set a password. Then the server starts immediately.
|
|
131
|
+
Open `http://localhost:3000` → Register a project → Write TODOs → Click Start.
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
# Change settings
|
|
135
|
+
clitrigger config port 8080 # Change port
|
|
136
|
+
clitrigger config password # Change password
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
> **Prerequisites**: Node.js 20+, Git, at least one AI CLI (Claude / Gemini / Codex)
|
|
140
|
+
>
|
|
141
|
+
> **Supported Platforms**: Windows · macOS · Linux — all core code is cross-platform compatible.
|
|
142
|
+
> On macOS, you may need `xcode-select --install` for native module compilation.
|
|
143
|
+
|
|
144
|
+
### Run from Source (for development)
|
|
145
|
+
|
|
146
|
+
<details>
|
|
147
|
+
<summary>Click to expand</summary>
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
# 1. Clone & install
|
|
151
|
+
git clone https://github.com/OSgoodYZ/CLITrigger.git
|
|
152
|
+
cd CLITrigger
|
|
153
|
+
npm install
|
|
154
|
+
cd src/client && npm install && cd ../..
|
|
155
|
+
|
|
156
|
+
# 2. Configure environment
|
|
157
|
+
cp .env.example .env
|
|
158
|
+
# Edit .env and set AUTH_PASSWORD
|
|
159
|
+
|
|
160
|
+
# 3. Run
|
|
161
|
+
npm run dev
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Open `http://localhost:5173`.
|
|
165
|
+
|
|
166
|
+
#### Windows One-Click Scripts
|
|
167
|
+
|
|
168
|
+
Double-click any bat file in `scripts/` — no terminal needed.
|
|
169
|
+
|
|
170
|
+
| File | Action |
|
|
171
|
+
|------|--------|
|
|
172
|
+
| `install.bat` | Install dependencies (first time) |
|
|
173
|
+
| `dev.bat` | Start development mode |
|
|
174
|
+
| `build.bat` | Build project |
|
|
175
|
+
| `start.bat` | Start production server |
|
|
176
|
+
| `start-tunnel.bat` | Start with Cloudflare Tunnel |
|
|
177
|
+
| `test.bat` | Run all tests |
|
|
178
|
+
|
|
179
|
+
#### macOS / Linux
|
|
180
|
+
|
|
181
|
+
`npm run` commands work identically on all platforms. Use the terminal instead of `.bat` scripts.
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
npm run dev # Development mode
|
|
185
|
+
npm run build # Build
|
|
186
|
+
npm run start # Production server
|
|
187
|
+
npm test # Run tests
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
</details>
|
|
191
|
+
|
|
192
|
+
### Remote Access (Cloudflare Tunnel)
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
# Install cloudflared
|
|
196
|
+
winget install cloudflare.cloudflared # Windows
|
|
197
|
+
brew install cloudflared # macOS
|
|
198
|
+
|
|
199
|
+
# Set TUNNEL_ENABLED=true in .env, then:
|
|
200
|
+
npm run start:tunnel
|
|
201
|
+
# → Outputs https://xxxx.trycloudflare.com in the console
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## Documentation
|
|
207
|
+
|
|
208
|
+
| Doc | Content |
|
|
209
|
+
|-----|---------|
|
|
210
|
+
| [SETUP.md](docs/SETUP.md) | Detailed installation and usage guide |
|
|
211
|
+
| [CHANGELOG.md](docs/CHANGELOG.md) | Version history |
|
|
212
|
+
| [CICD.md](docs/CICD.md) | GitHub Actions CI/CD setup |
|
|
213
|
+
| [TESTING.md](docs/TESTING.md) | Testing guide |
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## License
|
|
218
|
+
|
|
219
|
+
[MIT](LICENSE) — Free to use, modify, and distribute.
|
package/bin/clitrigger.js
CHANGED
|
@@ -4,6 +4,7 @@ import fs from 'fs';
|
|
|
4
4
|
import path from 'path';
|
|
5
5
|
import os from 'os';
|
|
6
6
|
import { createInterface } from 'readline/promises';
|
|
7
|
+
import { execSync, spawn } from 'child_process';
|
|
7
8
|
|
|
8
9
|
const CONFIG_DIR = path.join(os.homedir(), '.clitrigger');
|
|
9
10
|
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');
|
|
@@ -15,7 +16,10 @@ if (args[0] === 'config') {
|
|
|
15
16
|
} else if (args[0] === '--help' || args[0] === '-h') {
|
|
16
17
|
printHelp();
|
|
17
18
|
} else {
|
|
18
|
-
await
|
|
19
|
+
const updated = await checkAutoUpdate();
|
|
20
|
+
if (!updated) {
|
|
21
|
+
await startServer();
|
|
22
|
+
}
|
|
19
23
|
}
|
|
20
24
|
|
|
21
25
|
async function startServer() {
|
|
@@ -26,33 +30,73 @@ async function startServer() {
|
|
|
26
30
|
console.log('Welcome to CLITrigger!\n');
|
|
27
31
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
28
32
|
|
|
29
|
-
const setPassword = await rl.question('비밀번호를 설정하시겠습니까? (y/N): ');
|
|
30
33
|
let password = '';
|
|
31
|
-
|
|
32
|
-
password = await rl.question('
|
|
34
|
+
while (!password) {
|
|
35
|
+
password = await rl.question('Set a password: ');
|
|
36
|
+
if (!password) console.log('Password is required.');
|
|
33
37
|
}
|
|
34
38
|
rl.close();
|
|
35
39
|
|
|
36
|
-
const config = { port: 3000, password };
|
|
40
|
+
const config = { port: 3000, password, tunnel: true };
|
|
37
41
|
fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
|
|
38
|
-
console.log(`\
|
|
42
|
+
console.log(`\nSetup complete! (${CONFIG_FILE})`);
|
|
39
43
|
}
|
|
40
44
|
|
|
41
45
|
// config 읽고 env 설정
|
|
42
46
|
const config = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf-8'));
|
|
47
|
+
|
|
48
|
+
// 기존 config에 비밀번호가 없으면 설정 강제
|
|
49
|
+
if (!config.password) {
|
|
50
|
+
console.log('Password is not set.\n');
|
|
51
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
52
|
+
let password = '';
|
|
53
|
+
while (!password) {
|
|
54
|
+
password = await rl.question('Set a password: ');
|
|
55
|
+
if (!password) console.log('Password is required.');
|
|
56
|
+
}
|
|
57
|
+
rl.close();
|
|
58
|
+
config.password = password;
|
|
59
|
+
fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
|
|
60
|
+
console.log('Password saved.\n');
|
|
61
|
+
}
|
|
62
|
+
|
|
43
63
|
process.env.PORT = String(config.port || 3000);
|
|
44
|
-
|
|
64
|
+
process.env.AUTH_PASSWORD = config.password;
|
|
45
65
|
process.env.DB_PATH = path.join(CONFIG_DIR, 'clitrigger.db');
|
|
66
|
+
// tunnel defaults to true (auto-enable for new and existing users)
|
|
67
|
+
if (config.tunnel !== false) {
|
|
68
|
+
process.env.TUNNEL_ENABLED = 'true';
|
|
69
|
+
}
|
|
70
|
+
if (config.tunnelName) {
|
|
71
|
+
process.env.TUNNEL_NAME = config.tunnelName;
|
|
72
|
+
}
|
|
46
73
|
|
|
47
74
|
// 서버 시작
|
|
48
75
|
await import('../dist/server/index.js');
|
|
49
76
|
}
|
|
50
77
|
|
|
51
78
|
async function handleConfig(args) {
|
|
79
|
+
if (args[0] === 'clear') {
|
|
80
|
+
if (!fs.existsSync(CONFIG_DIR)) {
|
|
81
|
+
console.log('No config to delete.');
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
85
|
+
const answer = await rl.question(`All config and data in ${CONFIG_DIR} will be deleted. Continue? (y/N) `);
|
|
86
|
+
rl.close();
|
|
87
|
+
if (answer.toLowerCase() === 'y') {
|
|
88
|
+
fs.rmSync(CONFIG_DIR, { recursive: true, force: true });
|
|
89
|
+
console.log('Config and data deleted.');
|
|
90
|
+
} else {
|
|
91
|
+
console.log('Cancelled.');
|
|
92
|
+
}
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
52
96
|
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
53
97
|
|
|
54
98
|
if (!fs.existsSync(CONFIG_FILE)) {
|
|
55
|
-
console.log('
|
|
99
|
+
console.log('No config file found. Run clitrigger first.');
|
|
56
100
|
process.exit(1);
|
|
57
101
|
}
|
|
58
102
|
|
|
@@ -60,34 +104,120 @@ async function handleConfig(args) {
|
|
|
60
104
|
|
|
61
105
|
if (args[0] === 'port') {
|
|
62
106
|
if (!args[1]) {
|
|
63
|
-
console.log(
|
|
107
|
+
console.log(`Current port: ${config.port || 3000}`);
|
|
64
108
|
return;
|
|
65
109
|
}
|
|
66
110
|
const port = parseInt(args[1], 10);
|
|
67
111
|
if (isNaN(port) || port < 1 || port > 65535) {
|
|
68
|
-
console.log('
|
|
112
|
+
console.log('Please enter a valid port number. (1-65535)');
|
|
69
113
|
process.exit(1);
|
|
70
114
|
}
|
|
71
115
|
config.port = port;
|
|
72
116
|
fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
|
|
73
|
-
console.log(
|
|
117
|
+
console.log(`Port changed to ${port}.`);
|
|
74
118
|
} else if (args[0] === 'password') {
|
|
75
119
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
76
|
-
|
|
120
|
+
let password = '';
|
|
121
|
+
while (!password) {
|
|
122
|
+
password = await rl.question('New password: ');
|
|
123
|
+
if (!password) console.log('Password is required.');
|
|
124
|
+
}
|
|
77
125
|
rl.close();
|
|
78
126
|
config.password = password;
|
|
79
127
|
fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
|
|
80
|
-
|
|
81
|
-
console.log('✅ 비밀번호가 변경되었습니다.');
|
|
82
|
-
} else {
|
|
83
|
-
console.log('✅ 비밀번호가 해제되었습니다.');
|
|
84
|
-
}
|
|
128
|
+
console.log('Password changed.');
|
|
85
129
|
} else if (args[0] === 'path') {
|
|
86
130
|
console.log(CONFIG_DIR);
|
|
131
|
+
} else if (args[0] === 'tunnel') {
|
|
132
|
+
if (!args[1]) {
|
|
133
|
+
console.log(`Tunnel: ${config.tunnel ? 'enabled' : 'disabled'}${config.tunnelName ? ` (name: ${config.tunnelName})` : ''}`);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (args[1] === 'on') {
|
|
137
|
+
config.tunnel = true;
|
|
138
|
+
if (args[2]) config.tunnelName = args[2];
|
|
139
|
+
fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
|
|
140
|
+
console.log(`Tunnel enabled.${config.tunnelName ? ` (name: ${config.tunnelName})` : ''}`);
|
|
141
|
+
} else if (args[1] === 'off') {
|
|
142
|
+
config.tunnel = false;
|
|
143
|
+
delete config.tunnelName;
|
|
144
|
+
fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
|
|
145
|
+
console.log('Tunnel disabled.');
|
|
146
|
+
} else {
|
|
147
|
+
console.log('Usage: clitrigger config tunnel [on [name] | off]');
|
|
148
|
+
}
|
|
87
149
|
} else {
|
|
88
|
-
console.log(
|
|
89
|
-
console.log(`
|
|
90
|
-
console.log(`
|
|
150
|
+
console.log(`Config (${CONFIG_FILE}):`);
|
|
151
|
+
console.log(` Port: ${config.port || 3000}`);
|
|
152
|
+
console.log(` Password: ${config.password ? 'set' : 'not set'}`);
|
|
153
|
+
console.log(` Tunnel: ${config.tunnel ? 'enabled' : 'disabled'}${config.tunnelName ? ` (name: ${config.tunnelName})` : ''}`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function isNewerVersion(latest, current) {
|
|
158
|
+
const a = latest.split('.').map(Number);
|
|
159
|
+
const b = current.split('.').map(Number);
|
|
160
|
+
for (let i = 0; i < 3; i++) {
|
|
161
|
+
if ((a[i] || 0) > (b[i] || 0)) return true;
|
|
162
|
+
if ((a[i] || 0) < (b[i] || 0)) return false;
|
|
163
|
+
}
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
async function checkAutoUpdate() {
|
|
168
|
+
// 업데이트 직후 재시작된 프로세스면 스킵
|
|
169
|
+
if (process.env.CLITRIGGER_UPDATED === '1') {
|
|
170
|
+
delete process.env.CLITRIGGER_UPDATED;
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
try {
|
|
175
|
+
if (!fs.existsSync(CONFIG_FILE)) return false;
|
|
176
|
+
|
|
177
|
+
const config = JSON.parse(fs.readFileSync(CONFIG_FILE, 'utf-8'));
|
|
178
|
+
|
|
179
|
+
// 24시간 이내에 체크했으면 스킵
|
|
180
|
+
const now = Date.now();
|
|
181
|
+
const lastCheck = config.lastUpdateCheck || 0;
|
|
182
|
+
if (now - lastCheck < 24 * 60 * 60 * 1000) return false;
|
|
183
|
+
|
|
184
|
+
// 체크 시간 저장 (네트워크 실패 시에도 반복 체크 방지)
|
|
185
|
+
config.lastUpdateCheck = now;
|
|
186
|
+
fs.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2));
|
|
187
|
+
|
|
188
|
+
// 현재 버전 읽기
|
|
189
|
+
const pkgPath = new URL('../package.json', import.meta.url);
|
|
190
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
191
|
+
const currentVersion = pkg.version;
|
|
192
|
+
|
|
193
|
+
// npm registry에서 최신 버전 조회 (5초 타임아웃)
|
|
194
|
+
const controller = new AbortController();
|
|
195
|
+
const timeout = setTimeout(() => controller.abort(), 5000);
|
|
196
|
+
const res = await fetch('https://registry.npmjs.org/clitrigger/latest', {
|
|
197
|
+
signal: controller.signal,
|
|
198
|
+
});
|
|
199
|
+
clearTimeout(timeout);
|
|
200
|
+
|
|
201
|
+
if (!res.ok) return false;
|
|
202
|
+
const data = await res.json();
|
|
203
|
+
const latestVersion = data.version;
|
|
204
|
+
|
|
205
|
+
if (!isNewerVersion(latestVersion, currentVersion)) return false;
|
|
206
|
+
|
|
207
|
+
console.log(`\nUpdate available: v${currentVersion} -> v${latestVersion}, updating...`);
|
|
208
|
+
execSync('npm i -g clitrigger@latest', { stdio: 'inherit' });
|
|
209
|
+
console.log(`Updated to v${latestVersion}. Restarting...\n`);
|
|
210
|
+
|
|
211
|
+
// 업데이트된 코드로 재시작
|
|
212
|
+
const child = spawn(process.argv[0], process.argv.slice(1), {
|
|
213
|
+
stdio: 'inherit',
|
|
214
|
+
env: { ...process.env, CLITRIGGER_UPDATED: '1' },
|
|
215
|
+
});
|
|
216
|
+
child.on('exit', (code) => process.exit(code ?? 0));
|
|
217
|
+
return true;
|
|
218
|
+
} catch {
|
|
219
|
+
// 네트워크 오류, 타임아웃 등 — 무시하고 현재 버전으로 계속
|
|
220
|
+
return false;
|
|
91
221
|
}
|
|
92
222
|
}
|
|
93
223
|
|
|
@@ -96,11 +226,15 @@ function printHelp() {
|
|
|
96
226
|
CLITrigger - AI-powered task execution tool
|
|
97
227
|
|
|
98
228
|
Usage:
|
|
99
|
-
clitrigger
|
|
100
|
-
clitrigger config
|
|
101
|
-
clitrigger config port <n>
|
|
102
|
-
clitrigger config password
|
|
103
|
-
clitrigger config
|
|
104
|
-
clitrigger
|
|
229
|
+
clitrigger Start the server
|
|
230
|
+
clitrigger config Show current config
|
|
231
|
+
clitrigger config port <n> Change port
|
|
232
|
+
clitrigger config password Change password
|
|
233
|
+
clitrigger config tunnel on Enable Cloudflare tunnel
|
|
234
|
+
clitrigger config tunnel on <name> Enable named tunnel
|
|
235
|
+
clitrigger config tunnel off Disable tunnel
|
|
236
|
+
clitrigger config path Print config directory path
|
|
237
|
+
clitrigger config clear Delete all config and data
|
|
238
|
+
clitrigger --help Show this help
|
|
105
239
|
`.trim());
|
|
106
240
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from 'fs';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import os from 'os';
|
|
6
|
+
|
|
7
|
+
const CONFIG_DIR = path.join(os.homedir(), '.clitrigger');
|
|
8
|
+
|
|
9
|
+
if (fs.existsSync(CONFIG_DIR)) {
|
|
10
|
+
console.log(`
|
|
11
|
+
CLITrigger가 제거되었습니다.
|
|
12
|
+
|
|
13
|
+
설정 및 데이터가 아래 경로에 남아 있습니다:
|
|
14
|
+
${CONFIG_DIR}
|
|
15
|
+
|
|
16
|
+
완전히 제거하려면 해당 폴더를 수동으로 삭제해주세요:
|
|
17
|
+
rm -rf ${CONFIG_DIR}
|
|
18
|
+
`.trim());
|
|
19
|
+
}
|