Compare commits
389 Commits
v1.10.4
...
feature/se
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7e92de7cb7 | ||
|
|
bacca8d62b | ||
|
|
aabf331e91 | ||
|
|
053e43447a | ||
|
|
039696c2de | ||
|
|
beb0a50413 | ||
|
|
e89d2da5df | ||
|
|
392c73b693 | ||
|
|
5e7c4c5f8c | ||
|
|
3f71d4932b | ||
|
|
80561ee9e9 | ||
|
|
658421c1c4 | ||
|
|
881465aa71 | ||
|
|
9f2afebc66 | ||
|
|
df3d5de8c1 | ||
|
|
b44c93d884 | ||
|
|
a1c6d667a4 | ||
|
|
0753c04783 | ||
|
|
e1275e6d3c | ||
|
|
ccb8b83692 | ||
|
|
641731b3ef | ||
|
|
d4bdc667cc | ||
|
|
ce724e6e3f | ||
|
|
b4a39c7297 | ||
|
|
44edf94f3a | ||
|
|
f6200e3e95 | ||
|
|
fa5a23897c | ||
|
|
c5e55adc89 | ||
|
|
09dd407648 | ||
|
|
89b754d186 | ||
|
|
86b6545c35 | ||
|
|
49dd3cfb23 | ||
|
|
457ca0daab | ||
|
|
09dcea05fb | ||
|
|
3969135bd4 | ||
|
|
25820ed995 | ||
|
|
fc3504eaed | ||
|
|
ec0ff974cb | ||
|
|
c471b5d3fa | ||
|
|
5758bee8a0 | ||
|
|
7763e60fb3 | ||
|
|
25b00b58de | ||
|
|
6a13e1773b | ||
|
|
6102b74455 | ||
|
|
9ef1ab533d | ||
|
|
e9c7a5041c | ||
|
|
289520814c | ||
|
|
09486016e6 | ||
|
|
4c106a5083 | ||
|
|
63e996bb77 | ||
|
|
fbad3a90f8 | ||
|
|
96463df8da | ||
|
|
31f28a2c18 | ||
|
|
8ff5f35c05 | ||
|
|
641304242d | ||
|
|
c3599cd2c4 | ||
|
|
9b11c034d9 | ||
|
|
b6d19201b6 | ||
|
|
4a569725da | ||
|
|
6ce3306947 | ||
|
|
d0dd007d0f | ||
|
|
13e97e2c71 | ||
|
|
c7a5baf147 | ||
|
|
e2459cb0f8 | ||
|
|
9552577e94 | ||
|
|
590dd42649 | ||
|
|
2207d05c1c | ||
|
|
a8dab0edcf | ||
|
|
e61f8a543d | ||
|
|
388134c7a5 | ||
|
|
ef51de259e | ||
|
|
1628868470 | ||
|
|
8f1042cf25 | ||
|
|
051a6b1e74 | ||
|
|
f1063fd339 | ||
|
|
27cd12432b | ||
|
|
004135ef01 | ||
|
|
b54cdf8168 | ||
|
|
42a131389a | ||
|
|
ebd1c0db92 | ||
|
|
6d87cc5566 | ||
|
|
17d6ec54af | ||
|
|
a41d2c713e | ||
|
|
08a6653b38 | ||
|
|
a4632dc4ce | ||
|
|
612390db53 | ||
|
|
88c60b70b0 | ||
|
|
4de8b78c6d | ||
|
|
7413c2c784 | ||
|
|
d6133ba2ad | ||
|
|
14aef73cc6 | ||
|
|
72ff134b31 | ||
|
|
95bcee0ec4 | ||
|
|
45e71a0e73 | ||
|
|
6f6dacad5e | ||
|
|
adb3a06d7e | ||
|
|
1d31c3ec83 | ||
|
|
a7299c6823 | ||
|
|
4b1e17ea38 | ||
|
|
b9c902b016 | ||
|
|
a116b95199 | ||
|
|
621853cbfb | ||
|
|
4d8fb6e30a | ||
|
|
a77f213dd5 | ||
|
|
aaa14b9fc0 | ||
|
|
8ddeeb0ce8 | ||
|
|
f4777c139f | ||
|
|
8af72570b3 | ||
|
|
12e7f074d9 | ||
|
|
e52e1a2b58 | ||
|
|
d258f4f0c7 | ||
|
|
1dc2a205dc | ||
|
|
9bceab9e1a | ||
|
|
e581a0e1cc | ||
|
|
c7dcba8d91 | ||
|
|
8afb46af2e | ||
|
|
bc164140e0 | ||
|
|
86c33c1c0c | ||
|
|
cb4fd795c9 | ||
|
|
3950c0e47f | ||
|
|
d299ab88a0 | ||
|
|
dcea8a329c | ||
|
|
844de26ada | ||
|
|
8d28438fe7 | ||
|
|
03a8f41b21 | ||
|
|
64a96b24f8 | ||
|
|
9193feb6dc | ||
|
|
2444209723 | ||
|
|
0590c5c178 | ||
|
|
2320e1d74b | ||
|
|
55dce7e784 | ||
|
|
f4615dfca3 | ||
|
|
453a1452bb | ||
|
|
b0a3fdf95f | ||
|
|
4ee88f0eb0 | ||
|
|
688d73477a | ||
|
|
198e3da89b | ||
|
|
4da27ae5f1 | ||
|
|
964d8e3231 | ||
|
|
84d4634735 | ||
|
|
14d17ae104 | ||
|
|
855e22f917 | ||
|
|
97689588aa | ||
|
|
503c384685 | ||
|
|
506d43144b | ||
|
|
9e22f42a3d | ||
|
|
9c0e864532 | ||
|
|
d19b1e949f | ||
|
|
b359c51527 | ||
|
|
a367edd515 | ||
|
|
917c353115 | ||
|
|
4ab94fce42 | ||
|
|
e3b689214f | ||
|
|
1f903baf2c | ||
|
|
5e3a7b69d7 | ||
|
|
23801e9cc1 | ||
|
|
4f6ff9260d | ||
|
|
49061bc7a3 | ||
|
|
50e097d4ac | ||
|
|
f986004319 | ||
|
|
f488a346ef | ||
|
|
82efac4704 | ||
|
|
81697d0e73 | ||
|
|
27bf09b0c1 | ||
|
|
7ccbc8d92d | ||
|
|
597e9c54b7 | ||
|
|
cccd915c33 | ||
|
|
0207a1f3a3 | ||
|
|
38a593c97f | ||
|
|
fc369d047e | ||
|
|
9d8e92b5a4 | ||
|
|
07f1d9a4a8 | ||
|
|
e853d29584 | ||
|
|
09af23bcaf | ||
|
|
520e3f2280 | ||
|
|
151e8ee808 | ||
|
|
2cfcae049b | ||
|
|
8723393b66 | ||
|
|
29b80b1905 | ||
|
|
c55e996f3a | ||
|
|
e7800c494f | ||
|
|
374fe35915 | ||
|
|
33b0ea4c4a | ||
|
|
412102c531 | ||
|
|
afe1be7fca | ||
|
|
42f13e151c | ||
|
|
272eb00602 | ||
|
|
f891316ec0 | ||
|
|
1ed3358cbd | ||
|
|
c1e025b665 | ||
|
|
cf3d23ee31 | ||
|
|
e7d6c40452 | ||
|
|
216932e7f9 | ||
|
|
e9719256fc | ||
|
|
55caaf060c | ||
|
|
f9c7321c8c | ||
|
|
88bda6e5c0 | ||
|
|
86b421c790 | ||
|
|
41ef84c283 | ||
|
|
53224e47b6 | ||
|
|
bbb51dbf99 | ||
|
|
2d06cae0ca | ||
|
|
14fb81586c | ||
|
|
4d2b592ec6 | ||
|
|
4957220a05 | ||
|
|
3debc3a249 | ||
|
|
5512e2e15b | ||
|
|
1b42dba902 | ||
|
|
ede56ad81b | ||
|
|
36094fb73f | ||
|
|
57828653bf | ||
|
|
8ef0951901 | ||
|
|
ab50c5c1a8 | ||
|
|
6726e8f44e | ||
|
|
07f89e5240 | ||
|
|
8a675a713b | ||
|
|
5724c11253 | ||
|
|
c7b9976986 | ||
|
|
f16e3e763d | ||
|
|
477bc404b0 | ||
|
|
ae5a21cd6e | ||
|
|
b2c69d6ea8 | ||
|
|
8825baf5b4 | ||
|
|
0d1a3df1f7 | ||
|
|
80732923b5 | ||
|
|
6362d35d66 | ||
|
|
10bfeed614 | ||
|
|
dab089b29f | ||
|
|
38745bdf85 | ||
|
|
9da7c1cbae | ||
|
|
844677caee | ||
|
|
e1c67fd5d0 | ||
|
|
9cd0cfc88f | ||
|
|
09f1021c59 | ||
|
|
cf0f60bc48 | ||
|
|
053d94ab9d | ||
|
|
79f7bf9a63 | ||
|
|
e85cc746b1 | ||
|
|
cc3368c591 | ||
|
|
5131d2ae27 | ||
|
|
394b95ae29 | ||
|
|
4948aa3d64 | ||
|
|
6e07f140e3 | ||
|
|
fea8e30725 | ||
|
|
9f534ce15b | ||
|
|
8cb34a73b5 | ||
|
|
74640a7f31 | ||
|
|
5800d84255 | ||
|
|
33c70a372d | ||
|
|
396f058b46 | ||
|
|
b899695772 | ||
|
|
a173817d37 | ||
|
|
73375d7653 | ||
|
|
1d48b78af2 | ||
|
|
7928285ed0 | ||
|
|
92cbb3e7d9 | ||
|
|
0517ee609e | ||
|
|
3bbf38125a | ||
|
|
9e03acb0db | ||
|
|
515ad3b336 | ||
|
|
b68a903781 | ||
|
|
a08deee6b7 | ||
|
|
9cd1b5811a | ||
|
|
ee43adb311 | ||
|
|
740f3a7f0e | ||
|
|
e1f2af1a34 | ||
|
|
50f8c4ba72 | ||
|
|
1e8e52ce8d | ||
|
|
133c762eea | ||
|
|
4216676395 | ||
|
|
ddb26c7652 | ||
|
|
b3c6e95971 | ||
|
|
f8d1ec7b9e | ||
|
|
e73960ae78 | ||
|
|
1f6c0c3899 | ||
|
|
9da8e69476 | ||
|
|
15e4db386f | ||
|
|
66e85fb2c1 | ||
|
|
42b2d5e1d9 | ||
|
|
d3c4821258 | ||
|
|
72c4b0749e | ||
|
|
35e140b941 | ||
|
|
b70728254b | ||
|
|
64ebbaf387 | ||
|
|
cdaff9d146 | ||
|
|
3f66179e72 | ||
|
|
c654f489af | ||
|
|
97ebef016a | ||
|
|
ef44942767 | ||
|
|
7b63a68e7e | ||
|
|
005033136b | ||
|
|
ee3917b3f9 | ||
|
|
8fb43d358c | ||
|
|
4c40a33255 | ||
|
|
4086fdaa4e | ||
|
|
124c1ac600 | ||
|
|
9efe433d99 | ||
|
|
189a1b174c | ||
|
|
04a0ff311e | ||
|
|
efae890e34 | ||
|
|
ea33810a4f | ||
|
|
4fe6cc4272 | ||
|
|
ba70ad8e81 | ||
|
|
b066ec4c01 | ||
|
|
104e4260a7 | ||
|
|
8af982e706 | ||
|
|
81c0773358 | ||
|
|
29783f609f | ||
|
|
ea19bd9a00 | ||
|
|
6d4e5017d0 | ||
|
|
9b217ada0d | ||
|
|
04efaa41f6 | ||
|
|
5aef9c683a | ||
|
|
724cb5bb5c | ||
|
|
4e163c8c10 | ||
|
|
b315360f8a | ||
|
|
04821b8ad5 | ||
|
|
00278a13d8 | ||
|
|
676d2415a0 | ||
|
|
babe96eedd | ||
|
|
60c8bda755 | ||
|
|
d98b112302 | ||
|
|
8186c4039f | ||
|
|
02c13b0794 | ||
|
|
a8c141cb8e | ||
|
|
fbbf7465fb | ||
|
|
7a173071f1 | ||
|
|
6bf3696991 | ||
|
|
d822a96818 | ||
|
|
19bb741af0 | ||
|
|
1f4cd16b89 | ||
|
|
09688a09ca | ||
|
|
1cc3f61b81 | ||
|
|
89c9aec5b7 | ||
|
|
e74a813093 | ||
|
|
73a0b5bebd | ||
|
|
3a72a262a9 | ||
|
|
e952cf0a42 | ||
|
|
18d0874142 | ||
|
|
33e70c4b55 | ||
|
|
98c8b14b4f | ||
|
|
544c72434a | ||
|
|
b892985700 | ||
|
|
8c629a1a05 | ||
|
|
2df8c8e786 | ||
|
|
f91f9f702d | ||
|
|
6219c273a2 | ||
|
|
33834d808b | ||
|
|
abe8cd46a2 | ||
|
|
521fce32d0 | ||
|
|
2815e206dc | ||
|
|
71e400c54f | ||
|
|
05b2b59e23 | ||
|
|
ad219c8716 | ||
|
|
ed65399dfb | ||
|
|
2fb1e1cfb0 | ||
|
|
0f4b3666fc | ||
|
|
69b7b59f00 | ||
|
|
51431832d8 | ||
|
|
1e50cfdad6 | ||
|
|
289c2334e0 | ||
|
|
de8c4d1845 | ||
|
|
23de8c7863 | ||
|
|
041c72b160 | ||
|
|
519b5e5209 | ||
|
|
7ab14750de | ||
|
|
255aed0b01 | ||
|
|
b416e542c7 | ||
|
|
43cbbb10d9 | ||
|
|
003b64f8f0 | ||
|
|
401223dcd5 | ||
|
|
499e33d910 | ||
|
|
0181883c8a | ||
|
|
a100aa598c | ||
|
|
c875907f55 | ||
|
|
b2c16002e4 | ||
|
|
c7dbab086b | ||
|
|
b31f7afdf5 | ||
|
|
06d17eb22e | ||
|
|
57739a659f | ||
|
|
a5813e66d9 | ||
|
|
18ea4a19dd | ||
|
|
1c95c598eb | ||
|
|
72e97c4fbc | ||
|
|
b5d1fed354 | ||
|
|
d1733f34e0 | ||
|
|
fefcc0f338 | ||
|
|
36f8f50d63 | ||
|
|
4e14222487 |
30
.env.example
@@ -1,5 +1,15 @@
|
|||||||
# Claude Code UI Environment Configuration
|
# CloudCLI UI Environment Configuration
|
||||||
# Only includes variables that are actually used in the code
|
# Only includes variables that are actually used in the code
|
||||||
|
#
|
||||||
|
# TIP: Run 'cloudcli status' to see where this file should be located
|
||||||
|
# and to view your current configuration.
|
||||||
|
#
|
||||||
|
# Available CLI commands:
|
||||||
|
# claude-code-ui - Start the server (default)
|
||||||
|
# cloudcli start - Start the server
|
||||||
|
# cloudcli status - Show configuration and data locations
|
||||||
|
# cloudcli help - Show help information
|
||||||
|
# cloudcli version - Show version information
|
||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# SERVER CONFIGURATION
|
# SERVER CONFIGURATION
|
||||||
@@ -7,10 +17,14 @@
|
|||||||
|
|
||||||
# Backend server port (Express API + WebSocket server)
|
# Backend server port (Express API + WebSocket server)
|
||||||
#API server
|
#API server
|
||||||
PORT=3001
|
SERVER_PORT=3001
|
||||||
#Frontend port
|
#Frontend port
|
||||||
VITE_PORT=5173
|
VITE_PORT=5173
|
||||||
|
|
||||||
|
# Host/IP to bind servers to (default: 0.0.0.0 for all interfaces)
|
||||||
|
# Use 127.0.0.1 to restrict to localhost only
|
||||||
|
HOST=0.0.0.0
|
||||||
|
|
||||||
# Uncomment the following line if you have a custom claude cli path other than the default "claude"
|
# Uncomment the following line if you have a custom claude cli path other than the default "claude"
|
||||||
# CLAUDE_CLI_PATH=claude
|
# CLAUDE_CLI_PATH=claude
|
||||||
|
|
||||||
@@ -19,11 +33,13 @@ VITE_PORT=5173
|
|||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
# Path to the authentication database file
|
# Path to the authentication database file
|
||||||
# This should be set to a persistent volume path when running in containers
|
# This is where user credentials, API keys, and tokens are stored.
|
||||||
# Default: server/database/auth.db (relative to project root)
|
#
|
||||||
# Example for Docker: /data/auth.db
|
# To use a custom location:
|
||||||
# DATABASE_PATH=/data/auth.db
|
# DATABASE_PATH=/path/to/your/custom/auth.db
|
||||||
|
#
|
||||||
# Claude Code context window size (maximum tokens per session)
|
# Claude Code context window size (maximum tokens per session)
|
||||||
# Note: VITE_ prefix makes it available to frontend
|
|
||||||
VITE_CONTEXT_WINDOW=160000
|
VITE_CONTEXT_WINDOW=160000
|
||||||
CONTEXT_WINDOW=160000
|
CONTEXT_WINDOW=160000
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
41
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Create a report to help us improve
|
||||||
|
title: ''
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
type: Bug
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Describe the bug**
|
||||||
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
|
**To Reproduce**
|
||||||
|
Steps to reproduce the behavior:
|
||||||
|
1. Go to '...'
|
||||||
|
2. Click on '....'
|
||||||
|
3. Scroll down to '....'
|
||||||
|
4. See error
|
||||||
|
|
||||||
|
**Expected behavior**
|
||||||
|
A clear and concise description of what you expected to happen.
|
||||||
|
|
||||||
|
**Screenshots**
|
||||||
|
If applicable, add screenshots to help explain your problem.
|
||||||
|
|
||||||
|
**Error message**
|
||||||
|
If applicable, add the error message you see to help explain your problem.
|
||||||
|
|
||||||
|
**Desktop (please complete the following information):**
|
||||||
|
- OS: [e.g. iOS]
|
||||||
|
- Browser [e.g. chrome, safari]
|
||||||
|
- Version [e.g. 22]
|
||||||
|
|
||||||
|
**Smartphone (please complete the following information):**
|
||||||
|
- Device: [e.g. iPhone6]
|
||||||
|
- OS: [e.g. iOS8.1]
|
||||||
|
- Browser [e.g. stock browser, safari]
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context about the problem here.
|
||||||
19
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
name: Feature request
|
||||||
|
about: Suggest an idea for this project
|
||||||
|
title: "[Feature]"
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
type: Feature
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Is your feature request related to a problem? Please describe.**
|
||||||
|
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||||
|
|
||||||
|
**Describe the solution you'd like**
|
||||||
|
A clear and concise description of what you want to happen.
|
||||||
|
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context or screenshots about the feature request here.
|
||||||
22
.github/workflows/discord-release.yml
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
name: Discord Release Notification
|
||||||
|
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types: [published]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
github-releases-to-discord:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Github Releases To Discord
|
||||||
|
uses: SethCohen/github-releases-to-discord@v1.19.0
|
||||||
|
with:
|
||||||
|
webhook_url: ${{ secrets.DISCORD_WEBHOOK_URL }}
|
||||||
|
color: "2105893"
|
||||||
|
username: "Release Changelog"
|
||||||
|
avatar_url: "https://cdn.discordapp.com/avatars/487431320314576937/bd64361e4ba6313d561d54e78c9e7171.png"
|
||||||
|
content: "||@everyone||"
|
||||||
|
footer_title: "Changelog"
|
||||||
|
reduce_headings: true
|
||||||
51
.github/workflows/docker.yml
vendored
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
name: Docker
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
extra_tag:
|
||||||
|
description: 'Additional tag to push alongside the template tag (e.g. v1.2.3, leave empty for none)'
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
template: [claude-code, codex, gemini]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Log in to Docker Hub
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Compute tags
|
||||||
|
id: tags
|
||||||
|
run: |
|
||||||
|
TAGS="docker.io/cloudcliai/sandbox:${{ matrix.template }}"
|
||||||
|
if [ -n "${{ inputs.extra_tag }}" ]; then
|
||||||
|
TAGS="$TAGS,docker.io/cloudcliai/sandbox:${{ matrix.template }}-${{ inputs.extra_tag }}"
|
||||||
|
fi
|
||||||
|
echo "tags=$TAGS" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Build and push
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: ./docker
|
||||||
|
file: ./docker/${{ matrix.template }}/Dockerfile
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
|
push: true
|
||||||
|
tags: ${{ steps.tags.outputs.tags }}
|
||||||
|
cache-from: type=gha,scope=${{ matrix.template }}
|
||||||
|
cache-to: type=gha,mode=max,scope=${{ matrix.template }}
|
||||||
50
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
increment:
|
||||||
|
description: 'Version bump: patch, minor, major, or explicit (e.g. 1.27.0)'
|
||||||
|
required: true
|
||||||
|
default: 'patch'
|
||||||
|
type: string
|
||||||
|
release_name:
|
||||||
|
description: 'Custom release name (optional, defaults to "CloudCLI UI vX.Y.Z")'
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
id-token: write
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
token: ${{ secrets.RELEASE_PAT }}
|
||||||
|
|
||||||
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version: 22
|
||||||
|
registry-url: https://registry.npmjs.org
|
||||||
|
|
||||||
|
- name: git config
|
||||||
|
run: |
|
||||||
|
git config user.name "${GITHUB_ACTOR}"
|
||||||
|
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
|
||||||
|
|
||||||
|
- run: npm ci
|
||||||
|
|
||||||
|
- name: Release
|
||||||
|
run: |
|
||||||
|
ARGS="--ci --increment=${{ inputs.increment }}"
|
||||||
|
if [ -n "${{ inputs.release_name }}" ]; then
|
||||||
|
ARGS="$ARGS --github.releaseName=\"${{ inputs.release_name }}\""
|
||||||
|
fi
|
||||||
|
npx release-it $ARGS
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.RELEASE_PAT }}
|
||||||
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
14
.gitignore
vendored
@@ -8,6 +8,7 @@ lerna-debug.log*
|
|||||||
|
|
||||||
# Build outputs
|
# Build outputs
|
||||||
dist/
|
dist/
|
||||||
|
dist-server/
|
||||||
dist-ssr/
|
dist-ssr/
|
||||||
build/
|
build/
|
||||||
out/
|
out/
|
||||||
@@ -108,7 +109,7 @@ temp/
|
|||||||
.serena/
|
.serena/
|
||||||
CLAUDE.md
|
CLAUDE.md
|
||||||
.mcp.json
|
.mcp.json
|
||||||
|
.gemini/
|
||||||
|
|
||||||
# Database files
|
# Database files
|
||||||
*.db
|
*.db
|
||||||
@@ -130,3 +131,14 @@ dev-debug.log
|
|||||||
# Task files
|
# Task files
|
||||||
tasks.json
|
tasks.json
|
||||||
tasks/
|
tasks/
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
!src/i18n/locales/en/tasks.json
|
||||||
|
!src/i18n/locales/ja/tasks.json
|
||||||
|
!src/i18n/locales/ru/tasks.json
|
||||||
|
!src/i18n/locales/de/tasks.json
|
||||||
|
!src/i18n/locales/tr/tasks.json
|
||||||
|
!src/i18n/locales/it/tasks.json
|
||||||
|
|
||||||
|
# Git worktrees
|
||||||
|
.worktrees/
|
||||||
|
|||||||
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
[submodule "plugins/starter"]
|
||||||
|
path = plugins/starter
|
||||||
|
url = https://github.com/cloudcli-ai/cloudcli-plugin-starter.git
|
||||||
1
.husky/commit-msg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
npx commitlint --edit $1
|
||||||
1
.husky/pre-commit
Normal file
@@ -0,0 +1 @@
|
|||||||
|
npx lint-staged
|
||||||
57
.npmignore
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
|
||||||
|
*.md
|
||||||
|
!README.md
|
||||||
|
.env*
|
||||||
|
.gitignore
|
||||||
|
.nvmrc
|
||||||
|
.release-it.json
|
||||||
|
release.sh
|
||||||
|
postcss.config.js
|
||||||
|
vite.config.js
|
||||||
|
tailwind.config.js
|
||||||
|
|
||||||
|
# Database files
|
||||||
|
authdb/
|
||||||
|
*.db
|
||||||
|
*.sqlite
|
||||||
|
*.sqlite3
|
||||||
|
|
||||||
|
|
||||||
|
# IDE and editor files
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
*~
|
||||||
|
|
||||||
|
# OS generated files
|
||||||
|
.DS_Store
|
||||||
|
.DS_Store?
|
||||||
|
._*
|
||||||
|
.Spotlight-V100
|
||||||
|
.Trashes
|
||||||
|
ehthumbs.db
|
||||||
|
Thumbs.db
|
||||||
|
|
||||||
|
# AI specific
|
||||||
|
.claude/
|
||||||
|
.cursor/
|
||||||
|
.roo/
|
||||||
|
.taskmaster/
|
||||||
|
.cline/
|
||||||
|
.windsurf/
|
||||||
|
.serena/
|
||||||
|
CLAUDE.md
|
||||||
|
.mcp.json
|
||||||
|
|
||||||
|
|
||||||
|
# Task files
|
||||||
|
tasks.json
|
||||||
|
tasks/
|
||||||
|
|
||||||
|
# Environment variables
|
||||||
|
.env
|
||||||
|
.env.local
|
||||||
|
.env.development.local
|
||||||
|
.env.test.local
|
||||||
|
.env.production.local
|
||||||
|
Before Width: | Height: | Size: 321 KiB |
|
Before Width: | Height: | Size: 386 KiB |
|
Before Width: | Height: | Size: 336 KiB |
|
Before Width: | Height: | Size: 342 KiB |
|
Before Width: | Height: | Size: 357 KiB |
|
Before Width: | Height: | Size: 346 KiB |
|
Before Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 414 KiB |
|
Before Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 413 KiB |
|
Before Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 452 KiB |
|
Before Width: | Height: | Size: 47 KiB |
@@ -1,21 +1,41 @@
|
|||||||
{
|
{
|
||||||
"git": {
|
"git": {
|
||||||
"commitMessage": "Release ${version}",
|
"commitMessage": "chore(release): v${version}",
|
||||||
"tagName": "v${version}",
|
"tagName": "v${version}",
|
||||||
"changelog": "git log --pretty=format:\"* %s (%h)\" ${from}...${to}"
|
"requireBranch": "main",
|
||||||
|
"requireCleanWorkingDir": true
|
||||||
},
|
},
|
||||||
"npm": {
|
"npm": {
|
||||||
"publish": true
|
"publish": true,
|
||||||
|
"publishArgs": ["--access public"]
|
||||||
},
|
},
|
||||||
"github": {
|
"github": {
|
||||||
"release": true,
|
"release": true,
|
||||||
"releaseName": "Claude Code UI v${version}",
|
"releaseName": "CloudCLI UI v${version}"
|
||||||
"releaseNotes": {
|
|
||||||
"commit": "* ${commit.subject} (${sha}){ - thanks @${author.login}!}",
|
|
||||||
"excludeMatches": ["viper151"]
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"hooks": {
|
"hooks": {
|
||||||
"before:init": ["npm run build"]
|
"before:init": ["npm run build"]
|
||||||
|
},
|
||||||
|
"plugins": {
|
||||||
|
"@release-it/conventional-changelog": {
|
||||||
|
"infile": "CHANGELOG.md",
|
||||||
|
"header": "# Changelog\n\nAll notable changes to CloudCLI UI will be documented in this file.\n",
|
||||||
|
"preset": {
|
||||||
|
"name": "conventionalcommits",
|
||||||
|
"types": [
|
||||||
|
{ "type": "feat", "section": "New Features" },
|
||||||
|
{ "type": "feature", "section": "New Features" },
|
||||||
|
{ "type": "fix", "section": "Bug Fixes" },
|
||||||
|
{ "type": "perf", "section": "Performance" },
|
||||||
|
{ "type": "refactor", "section": "Refactoring" },
|
||||||
|
{ "type": "docs", "section": "Documentation" },
|
||||||
|
{ "type": "style", "section": "Styling" },
|
||||||
|
{ "type": "chore", "section": "Maintenance" },
|
||||||
|
{ "type": "ci", "section": "CI/CD" },
|
||||||
|
{ "type": "test", "section": "Tests" },
|
||||||
|
{ "type": "build", "section": "Build" }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
325
CHANGELOG.md
Normal file
@@ -0,0 +1,325 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
All notable changes to CloudCLI UI will be documented in this file.
|
||||||
|
|
||||||
|
|
||||||
|
## [1.31.5](https://github.com/siteboon/claudecodeui/compare/v1.31.4...v1.31.5) (2026-04-30)
|
||||||
|
|
||||||
|
### New Features
|
||||||
|
|
||||||
|
* add auto mode to claude code ([3f71d49](https://github.com/siteboon/claudecodeui/commit/3f71d4932b05dfedcdf816e2a3d7d0cd69c4f566))
|
||||||
|
|
||||||
|
## [1.31.4](https://github.com/siteboon/claudecodeui/compare/v1.31.3...v1.31.4) (2026-04-30)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* bump codex sdk to latest version ([658421c](https://github.com/siteboon/claudecodeui/commit/658421c1c44ec4eb58b69ec7b1844a9fba11a3f3))
|
||||||
|
|
||||||
|
## [1.31.3](https://github.com/siteboon/claudecodeui/compare/v1.31.2...v1.31.3) (2026-04-30)
|
||||||
|
|
||||||
|
## [1.31.2](https://github.com/siteboon/claudecodeui/compare/v1.31.0...v1.31.2) (2026-04-30)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* migrations for new sqlite schema ([0753c04](https://github.com/siteboon/claudecodeui/commit/0753c047837dab17b86ae4453027e30b465870f8))
|
||||||
|
|
||||||
|
## [1.31.0](https://github.com/siteboon/claudecodeui/compare/v1.30.0...v1.31.0) (2026-04-30)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **/status:** use CLAUDE_MODELS.DEFAULT instead of stale 'claude-sonnet-4.5' fallback ([#723](https://github.com/siteboon/claudecodeui/issues/723)) ([b4a39c7](https://github.com/siteboon/claudecodeui/commit/b4a39c729710a6294c62eb742e99e05f3e3914e9))
|
||||||
|
|
||||||
|
## [1.30.0](https://github.com/siteboon/claudecodeui/compare/v1.29.5...v1.30.0) (2026-04-21)
|
||||||
|
|
||||||
|
### New Features
|
||||||
|
|
||||||
|
* **i18n:** add Italian language support ([#677](https://github.com/siteboon/claudecodeui/issues/677)) ([86b6545](https://github.com/siteboon/claudecodeui/commit/86b6545c3505475ac2de0cec75cc8f86ab22aceb))
|
||||||
|
* **i18n:** add Turkish (tr) language support ([#678](https://github.com/siteboon/claudecodeui/issues/678)) ([89b754d](https://github.com/siteboon/claudecodeui/commit/89b754d186b68f3df8aa439a2d535644406066f0)), closes [#384](https://github.com/siteboon/claudecodeui/issues/384) [#514](https://github.com/siteboon/claudecodeui/issues/514) [#525](https://github.com/siteboon/claudecodeui/issues/525) [#534](https://github.com/siteboon/claudecodeui/issues/534)
|
||||||
|
* introduce opus 4.7 ([#682](https://github.com/siteboon/claudecodeui/issues/682)) ([c5e55ad](https://github.com/siteboon/claudecodeui/commit/c5e55adc89d0316675f90a927aa40d115958ae9f))
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* iOS scrolling main chat area ([3969135](https://github.com/siteboon/claudecodeui/commit/3969135bd427fbf48f29bb3dbfedb47791ca78dc))
|
||||||
|
* migrate PlanDisplay raw params from native details to Collapsible primitive ([fc3504e](https://github.com/siteboon/claudecodeui/commit/fc3504eaed8ca7ed9214838d148ea385b8352c31))
|
||||||
|
* precise Claude SDK denial message detection in deriveToolStatus ([09dcea0](https://github.com/siteboon/claudecodeui/commit/09dcea05fbc8c208d931aa1f08618f0e8087392f))
|
||||||
|
* reduce size of permission mode button tap target and provider selector on mobile ([457ca0d](https://github.com/siteboon/claudecodeui/commit/457ca0daabcaa8397f4375ee8aa2671336b648ff))
|
||||||
|
* small mobile respnosive fixes ([25820ed](https://github.com/siteboon/claudecodeui/commit/25820ed995c1b813b1f9ed073097b08eb1d902ec))
|
||||||
|
* small mobile respnosive fixes ([c471b5d](https://github.com/siteboon/claudecodeui/commit/c471b5d3fa6ce1968adb4cf87a15ac0e18febd20))
|
||||||
|
|
||||||
|
### Refactoring
|
||||||
|
|
||||||
|
* add primitives, plan mode display, and new session model selector ([7763e60](https://github.com/siteboon/claudecodeui/commit/7763e60fb32e34742058c055c57664a503a34d1d))
|
||||||
|
* chat composer new design ([5758bee](https://github.com/siteboon/claudecodeui/commit/5758bee8a038ed50073dba882108617959dda82c))
|
||||||
|
* queue primitive, tool status badges, and tool display cleanup ([ec0ff97](https://github.com/siteboon/claudecodeui/commit/ec0ff974cba213a1100b2a071b8ba533e812fe82))
|
||||||
|
|
||||||
|
### Maintenance
|
||||||
|
|
||||||
|
* add docker sandbox action ([fa5a238](https://github.com/siteboon/claudecodeui/commit/fa5a23897c086bcacf1cf5d926c650f98a0f2222))
|
||||||
|
|
||||||
|
## [1.29.5](https://github.com/siteboon/claudecodeui/compare/v1.29.4...v1.29.5) (2026-04-16)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* update node-pty to latest version ([6a13e17](https://github.com/siteboon/claudecodeui/commit/6a13e1773b145049ade512aa6e5cac21c2e5c4de))
|
||||||
|
|
||||||
|
## [1.29.4](https://github.com/siteboon/claudecodeui/compare/v1.29.3...v1.29.4) (2026-04-16)
|
||||||
|
|
||||||
|
### New Features
|
||||||
|
|
||||||
|
* deleting from sidebar will now ask whether to remove all data as well ([e9c7a50](https://github.com/siteboon/claudecodeui/commit/e9c7a5041c31a6f7b2032f06abe19c52d3d4cd8c))
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* pass pathToClaudeCodeExecutable to SDK when CLAUDE_CLI_PATH is set ([4c106a5](https://github.com/siteboon/claudecodeui/commit/4c106a5083d90989bbeedaefdbb68f5b3fa6fd58)), closes [#468](https://github.com/siteboon/claudecodeui/issues/468)
|
||||||
|
|
||||||
|
### Refactoring
|
||||||
|
|
||||||
|
* remove the sqlite3 dependency ([2895208](https://github.com/siteboon/claudecodeui/commit/289520814cf3ca36403056739ef22021f78c6033))
|
||||||
|
* **server:** extract URL detection and color utils from index.js ([#657](https://github.com/siteboon/claudecodeui/issues/657)) ([63e996b](https://github.com/siteboon/claudecodeui/commit/63e996bb77cfa97b1f55f6bdccc50161a75a3eee))
|
||||||
|
|
||||||
|
### Maintenance
|
||||||
|
|
||||||
|
* upgrade commit lint to 20.5.0 ([0948601](https://github.com/siteboon/claudecodeui/commit/09486016e67d97358c228ebc6eb4502ccb0012e4))
|
||||||
|
|
||||||
|
## [1.29.3](https://github.com/siteboon/claudecodeui/compare/v1.29.2...v1.29.3) (2026-04-15)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **version-upgrade-modal:** implement reload countdown and update UI messages ([#655](https://github.com/siteboon/claudecodeui/issues/655)) ([6413042](https://github.com/siteboon/claudecodeui/commit/641304242d7705b54aab65faa4a7673438c92c60))
|
||||||
|
|
||||||
|
### Maintenance
|
||||||
|
|
||||||
|
* remove unused route (migrated to providers already) ([31f28a2](https://github.com/siteboon/claudecodeui/commit/31f28a2c183f6ead50941027632d7ab64b7bb2d4))
|
||||||
|
|
||||||
|
## [1.29.2](https://github.com/siteboon/claudecodeui/compare/v1.29.1...v1.29.2) (2026-04-14)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **sandbox:** use backgrounded sbx run to keep sandbox alive ([9b11c03](https://github.com/siteboon/claudecodeui/commit/9b11c034d9a19710a23b56c62dcf07c21a17bd97))
|
||||||
|
|
||||||
|
## [1.29.1](https://github.com/siteboon/claudecodeui/compare/v1.29.0...v1.29.1) (2026-04-14)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* add latest tag to docker npx command and change the detach mode to work without spawn ([4a56972](https://github.com/siteboon/claudecodeui/commit/4a569725dae320a505753359d8edfd8ca79f0fd7))
|
||||||
|
|
||||||
|
## [1.29.0](https://github.com/siteboon/claudecodeui/compare/v1.28.1...v1.29.0) (2026-04-14)
|
||||||
|
|
||||||
|
### New Features
|
||||||
|
|
||||||
|
* adding docker sandbox environments ([13e97e2](https://github.com/siteboon/claudecodeui/commit/13e97e2c71254de7a60afb5495b21064c4bc4241))
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **thinking-mode:** fix dropdown positioning ([#646](https://github.com/siteboon/claudecodeui/issues/646)) ([c7a5baf](https://github.com/siteboon/claudecodeui/commit/c7a5baf1479404bd40e23aa58bd9f677df9a04c6))
|
||||||
|
|
||||||
|
### Maintenance
|
||||||
|
|
||||||
|
* update release flow node version ([e2459cb](https://github.com/siteboon/claudecodeui/commit/e2459cb0f8b35f54827778a7b444e6c3ca326506))
|
||||||
|
|
||||||
|
## [1.28.1](https://github.com/siteboon/claudecodeui/compare/v1.28.0...v1.28.1) (2026-04-10)
|
||||||
|
|
||||||
|
### New Features
|
||||||
|
|
||||||
|
* add branding, community links, GitHub star badge, and About settings tab ([2207d05](https://github.com/siteboon/claudecodeui/commit/2207d05c1ca229214aa9c2e2c9f4d0827d421574))
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* corrupted binary downloads ([#634](https://github.com/siteboon/claudecodeui/issues/634)) ([e61f8a5](https://github.com/siteboon/claudecodeui/commit/e61f8a543d63fe7c24a04b3d2186085a06dcbcdb))
|
||||||
|
* **ui:** remove mobile bottom nav, unify processing indicator, and improve tooltip behavior on mobile ([#632](https://github.com/siteboon/claudecodeui/issues/632)) ([a8dab0e](https://github.com/siteboon/claudecodeui/commit/a8dab0edcf949ae610820bae9500c433781f7c73))
|
||||||
|
|
||||||
|
### Refactoring
|
||||||
|
|
||||||
|
* remove unused whispher transcribe logic ([#637](https://github.com/siteboon/claudecodeui/issues/637)) ([590dd42](https://github.com/siteboon/claudecodeui/commit/590dd42649424ab990353fcf59ce0965036d3d25))
|
||||||
|
|
||||||
|
## [1.28.0](https://github.com/siteboon/claudecodeui/compare/v1.27.1...v1.28.0) (2026-04-03)
|
||||||
|
|
||||||
|
### New Features
|
||||||
|
|
||||||
|
* adding session resume in the api ([8f1042c](https://github.com/siteboon/claudecodeui/commit/8f1042cf256be282f009adcceeb55ab2dddf3fba))
|
||||||
|
* moving new session button higher ([1628868](https://github.com/siteboon/claudecodeui/commit/16288684702dec894cf054291ca3d545ddb8214b))
|
||||||
|
|
||||||
|
### Maintenance
|
||||||
|
|
||||||
|
* changing package name to @cloudcli-ai/cloudcli ([ef51de2](https://github.com/siteboon/claudecodeui/commit/ef51de259ea2b963bc15f058b084e11220bc216a))
|
||||||
|
|
||||||
|
## [1.27.1](https://github.com/siteboon/claudecodeui/compare/v1.26.3...v1.27.1) (2026-03-29)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* prevent split on undefined([#491](https://github.com/siteboon/claudecodeui/issues/491)) ([#563](https://github.com/siteboon/claudecodeui/issues/563)) ([b54cdf8](https://github.com/siteboon/claudecodeui/commit/b54cdf8168fc224e9907796e4229ae8ed34e6885))
|
||||||
|
|
||||||
|
### Maintenance
|
||||||
|
|
||||||
|
* add release-it github action ([42a1313](https://github.com/siteboon/claudecodeui/commit/42a131389a6954df0d2c3bedd2cb6d3406c5ebc1))
|
||||||
|
* add terminal plugin in the plugins list ([004135e](https://github.com/siteboon/claudecodeui/commit/004135ef0187023e1da29c4a7137a28a42ebf9af))
|
||||||
|
* release tokens ([f1063fd](https://github.com/siteboon/claudecodeui/commit/f1063fd33964ccb517f5ebcdd14526ed162e1138))
|
||||||
|
* relicense to AGPL-3.0-or-later ([27cd124](https://github.com/siteboon/claudecodeui/commit/27cd12432b7d3237981f86acd9cc99532d843d4a))
|
||||||
|
|
||||||
|
## [1.26.3](https://github.com/siteboon/claudecodeui/compare/v1.26.2...v1.26.3) (2026-03-22)
|
||||||
|
|
||||||
|
## [1.26.2](https://github.com/siteboon/claudecodeui/compare/v1.26.0...v1.26.2) (2026-03-21)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* change SW cache mechanism ([17d6ec5](https://github.com/siteboon/claudecodeui/commit/17d6ec54af18d333c8b04d2ffc64793e688d996e))
|
||||||
|
* claude auth changes and adding copy on mobile ([a41d2c7](https://github.com/siteboon/claudecodeui/commit/a41d2c713e87d56f23d5884585b4bb43c43a250a))
|
||||||
|
|
||||||
|
## [1.26.0](https://github.com/siteboon/claudecodeui/compare/v1.25.2...v1.26.0) (2026-03-20)
|
||||||
|
|
||||||
|
### New Features
|
||||||
|
|
||||||
|
* add German (Deutsch) language support ([#525](https://github.com/siteboon/claudecodeui/issues/525)) ([a7299c6](https://github.com/siteboon/claudecodeui/commit/a7299c68237908c752d504c2e8eea91570a30203))
|
||||||
|
* add WebSocket proxy for plugin backends ([#553](https://github.com/siteboon/claudecodeui/issues/553)) ([88c60b7](https://github.com/siteboon/claudecodeui/commit/88c60b70b031798d51ce26c8f080a0f64d824b05))
|
||||||
|
* Browser autofill support for login form ([#521](https://github.com/siteboon/claudecodeui/issues/521)) ([72ff134](https://github.com/siteboon/claudecodeui/commit/72ff134b315b7a1d602f3cc7dd60d47c1c1c34af))
|
||||||
|
* git panel redesign ([#535](https://github.com/siteboon/claudecodeui/issues/535)) ([adb3a06](https://github.com/siteboon/claudecodeui/commit/adb3a06d7e66a6d2dbcdfb501615e617178314af))
|
||||||
|
* introduce notification system and claude notifications ([#450](https://github.com/siteboon/claudecodeui/issues/450)) ([45e71a0](https://github.com/siteboon/claudecodeui/commit/45e71a0e73b368309544165e4dcf8b7fd014e8dd))
|
||||||
|
* **refactor:** move plugins to typescript ([#557](https://github.com/siteboon/claudecodeui/issues/557)) ([612390d](https://github.com/siteboon/claudecodeui/commit/612390db536417e2f68c501329bfccf5c6795e45))
|
||||||
|
* unified message architecture with provider adapters and session store ([#558](https://github.com/siteboon/claudecodeui/issues/558)) ([a4632dc](https://github.com/siteboon/claudecodeui/commit/a4632dc4cec228a8febb7c5bae4807c358963678))
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* detect Claude auth from settings env ([#527](https://github.com/siteboon/claudecodeui/issues/527)) ([95bcee0](https://github.com/siteboon/claudecodeui/commit/95bcee0ec459f186d52aeffe100ac1a024e92909))
|
||||||
|
* remove /exit command from claude login flow during onboarding ([#552](https://github.com/siteboon/claudecodeui/issues/552)) ([4de8b78](https://github.com/siteboon/claudecodeui/commit/4de8b78c6db5d8c2c402afce0f0b4cc16d5b6496))
|
||||||
|
|
||||||
|
### Documentation
|
||||||
|
|
||||||
|
* add German language link to all README files ([#534](https://github.com/siteboon/claudecodeui/issues/534)) ([1d31c3e](https://github.com/siteboon/claudecodeui/commit/1d31c3ec8309b433a041f3099955addc8c136c35))
|
||||||
|
* **readme:** hotfix and improve for README.jp.md ([#550](https://github.com/siteboon/claudecodeui/issues/550)) ([7413c2c](https://github.com/siteboon/claudecodeui/commit/7413c2c78422c308ac949e6a83c3e9216b24b649))
|
||||||
|
* **README:** update translations with CloudCLI branding and feature restructuring ([#544](https://github.com/siteboon/claudecodeui/issues/544)) ([14aef73](https://github.com/siteboon/claudecodeui/commit/14aef73cc6085fbb519fe64aea7cac80b7d51285))
|
||||||
|
|
||||||
|
## [1.25.2](https://github.com/siteboon/claudecodeui/compare/v1.25.0...v1.25.2) (2026-03-11)
|
||||||
|
|
||||||
|
### New Features
|
||||||
|
|
||||||
|
* **i18n:** localize plugin settings for all languages ([#515](https://github.com/siteboon/claudecodeui/issues/515)) ([621853c](https://github.com/siteboon/claudecodeui/commit/621853cbfb4233b34cb8cc2e1ed10917ba424352))
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* codeql user value provided path validation ([aaa14b9](https://github.com/siteboon/claudecodeui/commit/aaa14b9fc0b9b51c4fb9d1dba40fada7cbbe0356))
|
||||||
|
* numerous bugs ([#528](https://github.com/siteboon/claudecodeui/issues/528)) ([a77f213](https://github.com/siteboon/claudecodeui/commit/a77f213dd5d0b2538dea091ab8da6e55d2002f2f))
|
||||||
|
* **security:** disable executable gray-matter frontmatter in commands ([b9c902b](https://github.com/siteboon/claudecodeui/commit/b9c902b016f411a942c8707dd07d32b60bad087c))
|
||||||
|
* session reconnect catch-up, always-on input, frozen session recovery ([#524](https://github.com/siteboon/claudecodeui/issues/524)) ([4d8fb6e](https://github.com/siteboon/claudecodeui/commit/4d8fb6e30aa03d7cdb92bd62b7709422f9d08e32))
|
||||||
|
|
||||||
|
### Refactoring
|
||||||
|
|
||||||
|
* new settings page design and new pill component ([8ddeeb0](https://github.com/siteboon/claudecodeui/commit/8ddeeb0ce8d0642560bd3fa149236011dc6e3707))
|
||||||
|
|
||||||
|
## [1.25.0](https://github.com/siteboon/claudecodeui/compare/v1.24.0...v1.25.0) (2026-03-10)
|
||||||
|
|
||||||
|
### New Features
|
||||||
|
|
||||||
|
* add copy as text or markdown feature for assistant messages ([#519](https://github.com/siteboon/claudecodeui/issues/519)) ([1dc2a20](https://github.com/siteboon/claudecodeui/commit/1dc2a205dc2a3cbf960625d7669c7c63a2b6905f))
|
||||||
|
* add full Russian language support; update Readme.md files, and .gitignore update ([#514](https://github.com/siteboon/claudecodeui/issues/514)) ([c7dcba8](https://github.com/siteboon/claudecodeui/commit/c7dcba8d9117e84db8aac7d8a7bf6a3aa683e115))
|
||||||
|
* new plugin system ([#489](https://github.com/siteboon/claudecodeui/issues/489)) ([8afb46a](https://github.com/siteboon/claudecodeui/commit/8afb46af2e5514c9284030367281793fbb014e4f))
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* resolve duplicate key issue when rendering model options ([#520](https://github.com/siteboon/claudecodeui/issues/520)) ([9bceab9](https://github.com/siteboon/claudecodeui/commit/9bceab9e1a6e063b0b4f934ed2d9f854fcc9c6a4))
|
||||||
|
|
||||||
|
### Maintenance
|
||||||
|
|
||||||
|
* add plugins section in readme ([e581a0e](https://github.com/siteboon/claudecodeui/commit/e581a0e1ccd59fd7ec7306ca76a13e73d7c674c1))
|
||||||
|
|
||||||
|
## [1.24.0](https://github.com/siteboon/claudecodeui/compare/v1.23.2...v1.24.0) (2026-03-09)
|
||||||
|
|
||||||
|
### New Features
|
||||||
|
|
||||||
|
* add full-text search across conversations ([#482](https://github.com/siteboon/claudecodeui/issues/482)) ([3950c0e](https://github.com/siteboon/claudecodeui/commit/3950c0e47f41e93227af31494690818d45c8bc7a))
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **git:** prevent shell injection in git routes ([86c33c1](https://github.com/siteboon/claudecodeui/commit/86c33c1c0cb34176725a38f46960213714fc3e04))
|
||||||
|
* replace getDatabase with better-sqlite3 db in getGithubTokenById ([#501](https://github.com/siteboon/claudecodeui/issues/501)) ([cb4fd79](https://github.com/siteboon/claudecodeui/commit/cb4fd795c938b1cc86d47f401973bfccdd68fdee))
|
||||||
|
|
||||||
|
## [1.23.2](https://github.com/siteboon/claudecodeui/compare/v1.22.1...v1.23.2) (2026-03-06)
|
||||||
|
|
||||||
|
### New Features
|
||||||
|
|
||||||
|
* add clickable overlay buttons for CLI prompts in Shell terminal ([#480](https://github.com/siteboon/claudecodeui/issues/480)) ([2444209](https://github.com/siteboon/claudecodeui/commit/2444209723701dda2b881cea2501b239e64e51c1)), closes [#427](https://github.com/siteboon/claudecodeui/issues/427)
|
||||||
|
* add terminal shortcuts panel for mobile ([#411](https://github.com/siteboon/claudecodeui/issues/411)) ([b0a3fdf](https://github.com/siteboon/claudecodeui/commit/b0a3fdf95ffdb961261194d10400267251e42f17))
|
||||||
|
* implement session rename with SQLite storage ([#413](https://github.com/siteboon/claudecodeui/issues/413)) ([198e3da](https://github.com/siteboon/claudecodeui/commit/198e3da89b353780f53a91888384da9118995e81)), closes [#72](https://github.com/siteboon/claudecodeui/issues/72) [#358](https://github.com/siteboon/claudecodeui/issues/358)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **chat:** finalize terminal lifecycle to prevent stuck processing/thinking UI ([#483](https://github.com/siteboon/claudecodeui/issues/483)) ([0590c5c](https://github.com/siteboon/claudecodeui/commit/0590c5c178f4791e2b039d525ecca4d220c3dcae))
|
||||||
|
* **codex-history:** prevent AGENTS.md/internal prompt leakage when reloading Codex sessions ([#488](https://github.com/siteboon/claudecodeui/issues/488)) ([64a96b2](https://github.com/siteboon/claudecodeui/commit/64a96b24f853acb802f700810b302f0f5cf00898))
|
||||||
|
* preserve pending permission requests across WebSocket reconnections ([#462](https://github.com/siteboon/claudecodeui/issues/462)) ([4ee88f0](https://github.com/siteboon/claudecodeui/commit/4ee88f0eb0c648b54b05f006c6796fb7b09b0fae))
|
||||||
|
* prevent React 18 batching from losing messages during session sync ([#461](https://github.com/siteboon/claudecodeui/issues/461)) ([688d734](https://github.com/siteboon/claudecodeui/commit/688d73477a50773e43c85addc96212aa6290aea5))
|
||||||
|
* release it script ([dcea8a3](https://github.com/siteboon/claudecodeui/commit/dcea8a329c7d68437e1e72c8c766cf33c74637e9))
|
||||||
|
|
||||||
|
### Styling
|
||||||
|
|
||||||
|
* improve UI for processing banner ([#477](https://github.com/siteboon/claudecodeui/issues/477)) ([2320e1d](https://github.com/siteboon/claudecodeui/commit/2320e1d74b59c65b5b7fc4fa8b05fd9208f4898c))
|
||||||
|
|
||||||
|
### Maintenance
|
||||||
|
|
||||||
|
* remove logging of received WebSocket messages in production ([#487](https://github.com/siteboon/claudecodeui/issues/487)) ([9193feb](https://github.com/siteboon/claudecodeui/commit/9193feb6dc83041f3c365204648a88468bdc001b))
|
||||||
|
|
||||||
|
## [1.22.0](https://github.com/siteboon/claudecodeui/compare/v1.21.0...v1.22.0) (2026-03-03)
|
||||||
|
|
||||||
|
### New Features
|
||||||
|
|
||||||
|
* add community button in the app ([84d4634](https://github.com/siteboon/claudecodeui/commit/84d4634735f9ee13ac1c20faa0e7e31f1b77cae8))
|
||||||
|
* Advanced file editor and file tree improvements ([#444](https://github.com/siteboon/claudecodeui/issues/444)) ([9768958](https://github.com/siteboon/claudecodeui/commit/97689588aa2e8240ba4373da5f42ab444c772e72))
|
||||||
|
* update document title based on selected project ([#448](https://github.com/siteboon/claudecodeui/issues/448)) ([9e22f42](https://github.com/siteboon/claudecodeui/commit/9e22f42a3d3a781f448ddac9d133292fe103bb8c))
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **claude:** correct project encoded path ([#451](https://github.com/siteboon/claudecodeui/issues/451)) ([9c0e864](https://github.com/siteboon/claudecodeui/commit/9c0e864532dcc5ce7ee890d3b4db722872db2b54)), closes [#447](https://github.com/siteboon/claudecodeui/issues/447)
|
||||||
|
* **claude:** move model usage log to result message only ([#454](https://github.com/siteboon/claudecodeui/issues/454)) ([506d431](https://github.com/siteboon/claudecodeui/commit/506d43144b3ec3155c3e589e7e803862c4a8f83a))
|
||||||
|
* missing translation label ([855e22f](https://github.com/siteboon/claudecodeui/commit/855e22f9176a71daa51de716370af7f19d55bfb4))
|
||||||
|
|
||||||
|
### Maintenance
|
||||||
|
|
||||||
|
* add Gemini-CLI support to README ([#453](https://github.com/siteboon/claudecodeui/issues/453)) ([503c384](https://github.com/siteboon/claudecodeui/commit/503c3846850fb843781979b0c0e10a24b07e1a4b))
|
||||||
|
|
||||||
|
## [1.21.0](https://github.com/siteboon/claudecodeui/compare/v1.20.1...v1.21.0) (2026-02-27)
|
||||||
|
|
||||||
|
### New Features
|
||||||
|
|
||||||
|
* add copy icon for user messages ([#449](https://github.com/siteboon/claudecodeui/issues/449)) ([b359c51](https://github.com/siteboon/claudecodeui/commit/b359c515277b4266fde2fb9a29b5356949c07c4f))
|
||||||
|
* Google's gemini-cli integration ([#422](https://github.com/siteboon/claudecodeui/issues/422)) ([a367edd](https://github.com/siteboon/claudecodeui/commit/a367edd51578608b3281373cb4a95169dbf17f89))
|
||||||
|
* persist active tab across reloads via localStorage ([#414](https://github.com/siteboon/claudecodeui/issues/414)) ([e3b6892](https://github.com/siteboon/claudecodeui/commit/e3b689214f11d549ffe1b3a347476d58f25c5aca)), closes [#387](https://github.com/siteboon/claudecodeui/issues/387)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* add support for Codex in the shell ([#424](https://github.com/siteboon/claudecodeui/issues/424)) ([23801e9](https://github.com/siteboon/claudecodeui/commit/23801e9cc15d2b8d1bfc6e39aee2fae93226d1ad))
|
||||||
|
|
||||||
|
### Maintenance
|
||||||
|
|
||||||
|
* upgrade @anthropic-ai/claude-agent-sdk to version 0.2.59 and add model usage logging ([#446](https://github.com/siteboon/claudecodeui/issues/446)) ([917c353](https://github.com/siteboon/claudecodeui/commit/917c353115653ee288bf97be01f62fad24123cbc))
|
||||||
|
* upgrade better-sqlite to latest version to support node 25 ([#445](https://github.com/siteboon/claudecodeui/issues/445)) ([4ab94fc](https://github.com/siteboon/claudecodeui/commit/4ab94fce4257e1e20370fa83fa4c0f6fadbb8a2b))
|
||||||
|
|
||||||
|
## [1.20.1](https://github.com/siteboon/claudecodeui/compare/v1.19.1...v1.20.1) (2026-02-23)
|
||||||
|
|
||||||
|
### New Features
|
||||||
|
|
||||||
|
* implement install mode detection and update commands in version upgrade process ([f986004](https://github.com/siteboon/claudecodeui/commit/f986004319207b068431f9f6adf338a8ce8decfc))
|
||||||
|
* migrate legacy database to new location and improve last login update handling ([50e097d](https://github.com/siteboon/claudecodeui/commit/50e097d4ac498aa9f1803ef3564843721833dc19))
|
||||||
|
|
||||||
|
## [1.19.1](https://github.com/siteboon/claudecodeui/compare/v1.19.0...v1.19.1) (2026-02-23)
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* add prepublishOnly script to build before publishing ([82efac4](https://github.com/siteboon/claudecodeui/commit/82efac4704cab11ed8d1a05fe84f41312140b223))
|
||||||
|
|
||||||
|
## [1.19.0](https://github.com/siteboon/claudecodeui/compare/v1.18.2...v1.19.0) (2026-02-23)
|
||||||
|
|
||||||
|
### New Features
|
||||||
|
|
||||||
|
* add HOST environment variable for configurable bind address ([#360](https://github.com/siteboon/claudecodeui/issues/360)) ([cccd915](https://github.com/siteboon/claudecodeui/commit/cccd915c336192216b6e6f68e2b5f3ece0ccf966))
|
||||||
|
* subagent tool grouping ([#398](https://github.com/siteboon/claudecodeui/issues/398)) ([0207a1f](https://github.com/siteboon/claudecodeui/commit/0207a1f3a3c87f1c6c1aee8213be999b23289386))
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **macos:** fix node-pty posix_spawnp error with postinstall script ([#347](https://github.com/siteboon/claudecodeui/issues/347)) ([38a593c](https://github.com/siteboon/claudecodeui/commit/38a593c97fdb2bb7f051e09e8e99c16035448655)), closes [#284](https://github.com/siteboon/claudecodeui/issues/284)
|
||||||
|
* slash commands with arguments bypass command execution ([#392](https://github.com/siteboon/claudecodeui/issues/392)) ([597e9c5](https://github.com/siteboon/claudecodeui/commit/597e9c54b76e7c6cd1947299c668c78d24019cab))
|
||||||
|
|
||||||
|
### Refactoring
|
||||||
|
|
||||||
|
* **releases:** Create a contributing guide and proper release notes using a release-it plugin ([fc369d0](https://github.com/siteboon/claudecodeui/commit/fc369d047e13cba9443fe36c0b6bb2ce3beaf61c))
|
||||||
|
|
||||||
|
### Maintenance
|
||||||
|
|
||||||
|
* update @anthropic-ai/claude-agent-sdk to version 0.1.77 in package-lock.json ([#410](https://github.com/siteboon/claudecodeui/issues/410)) ([7ccbc8d](https://github.com/siteboon/claudecodeui/commit/7ccbc8d92d440e18c157b656c9ea2635044a64f6))
|
||||||
156
CONTRIBUTING.md
Normal file
@@ -0,0 +1,156 @@
|
|||||||
|
# Contributing to CloudCLI UI
|
||||||
|
|
||||||
|
Thanks for your interest in contributing to CloudCLI UI! Before you start, please take a moment to read through this guide.
|
||||||
|
|
||||||
|
## Before You Start
|
||||||
|
|
||||||
|
- **Search first.** Check [existing issues](https://github.com/siteboon/claudecodeui/issues) and [pull requests](https://github.com/siteboon/claudecodeui/pulls) to avoid duplicating work.
|
||||||
|
- **Discuss first** for new features. Open an [issue](https://github.com/siteboon/claudecodeui/issues/new) to discuss your idea before investing time in implementation. We may already have plans or opinions on how it should work.
|
||||||
|
- **Bug fixes are always welcome.** If you spot a bug, feel free to open a PR directly.
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
- [Node.js](https://nodejs.org/) 22 or later
|
||||||
|
- [Claude Code CLI](https://docs.anthropic.com/en/docs/claude-code) installed and configured
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
1. Fork the repository
|
||||||
|
2. Clone your fork:
|
||||||
|
```bash
|
||||||
|
git clone https://github.com/<your-username>/claudecodeui.git
|
||||||
|
cd claudecodeui
|
||||||
|
```
|
||||||
|
3. Install dependencies:
|
||||||
|
```bash
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
4. Start the development server:
|
||||||
|
```bash
|
||||||
|
npm run dev
|
||||||
|
```
|
||||||
|
5. Create a branch for your changes:
|
||||||
|
```bash
|
||||||
|
git checkout -b feat/your-feature-name
|
||||||
|
```
|
||||||
|
|
||||||
|
## Project Structure
|
||||||
|
|
||||||
|
```
|
||||||
|
claudecodeui/
|
||||||
|
├── src/ # React frontend (Vite + Tailwind)
|
||||||
|
│ ├── components/ # UI components
|
||||||
|
│ ├── contexts/ # React context providers
|
||||||
|
│ ├── hooks/ # Custom React hooks
|
||||||
|
│ ├── i18n/ # Internationalization and translations
|
||||||
|
│ ├── lib/ # Shared frontend libraries
|
||||||
|
│ ├── types/ # TypeScript type definitions
|
||||||
|
│ └── utils/ # Frontend utilities
|
||||||
|
├── server/ # Express backend
|
||||||
|
│ ├── routes/ # API route handlers
|
||||||
|
│ ├── middleware/ # Express middleware
|
||||||
|
│ ├── database/ # SQLite database layer
|
||||||
|
│ └── tools/ # CLI tool integrations
|
||||||
|
├── shared/ # Code shared between client and server
|
||||||
|
└── public/ # Static assets, icons, PWA manifest
|
||||||
|
```
|
||||||
|
|
||||||
|
## Development Workflow
|
||||||
|
|
||||||
|
- `npm run dev` — Start both the frontend and backend in development mode
|
||||||
|
- `npm run build` — Create a production build
|
||||||
|
- `npm run server` — Start only the backend server
|
||||||
|
- `npm run client` — Start only the Vite dev server
|
||||||
|
|
||||||
|
## Making Changes
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
- Reference the issue number in your PR if one exists
|
||||||
|
- Describe how to reproduce the bug in your PR description
|
||||||
|
- Add a screenshot or recording for visual bugs
|
||||||
|
|
||||||
|
### New Features
|
||||||
|
|
||||||
|
- Keep the scope focused — one feature per PR
|
||||||
|
- Include screenshots or recordings for UI changes
|
||||||
|
|
||||||
|
### Documentation
|
||||||
|
|
||||||
|
- Documentation improvements are always welcome
|
||||||
|
- Keep language clear and concise
|
||||||
|
|
||||||
|
## Commit Convention
|
||||||
|
|
||||||
|
We follow [Conventional Commits](https://conventionalcommits.org/) to generate release notes automatically. Every commit message should follow this format:
|
||||||
|
|
||||||
|
```
|
||||||
|
<type>(optional scope): <description>
|
||||||
|
```
|
||||||
|
|
||||||
|
Use imperative, present tense: "add feature" not "added feature" or "adds feature".
|
||||||
|
|
||||||
|
### Types
|
||||||
|
|
||||||
|
| Type | Description |
|
||||||
|
|------|-------------|
|
||||||
|
| `feat` | A new feature |
|
||||||
|
| `fix` | A bug fix |
|
||||||
|
| `perf` | A performance improvement |
|
||||||
|
| `refactor` | Code change that neither fixes a bug nor adds a feature |
|
||||||
|
| `docs` | Documentation only |
|
||||||
|
| `style` | CSS, formatting, visual changes |
|
||||||
|
| `chore` | Maintenance, dependencies, config |
|
||||||
|
| `ci` | CI/CD pipeline changes |
|
||||||
|
| `test` | Adding or updating tests |
|
||||||
|
| `build` | Build system changes |
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
```bash
|
||||||
|
feat: add conversation search
|
||||||
|
feat(i18n): add Japanese language support
|
||||||
|
fix: redirect unauthenticated users to login
|
||||||
|
fix(editor): syntax highlighting for .env files
|
||||||
|
perf: lazy load code editor component
|
||||||
|
refactor(chat): extract message list component
|
||||||
|
docs: update API configuration guide
|
||||||
|
```
|
||||||
|
|
||||||
|
### Breaking Changes
|
||||||
|
|
||||||
|
Add `!` after the type or include `BREAKING CHANGE:` in the commit footer:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
feat!: redesign settings page layout
|
||||||
|
```
|
||||||
|
|
||||||
|
## Pull Requests
|
||||||
|
|
||||||
|
- Give your PR a clear, descriptive title following the commit convention above
|
||||||
|
- Fill in the PR description with what changed and why
|
||||||
|
- Link any related issues
|
||||||
|
- Include screenshots for UI changes
|
||||||
|
- Make sure the build passes (`npm run build`)
|
||||||
|
- Keep PRs focused — avoid unrelated changes
|
||||||
|
|
||||||
|
## Releases
|
||||||
|
|
||||||
|
Releases are managed by maintainers using [release-it](https://github.com/release-it/release-it) with the [conventional changelog plugin](https://github.com/release-it/conventional-changelog).
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm run release # interactive (prompts for version bump)
|
||||||
|
npm run release -- patch # patch release
|
||||||
|
npm run release -- minor # minor release
|
||||||
|
```
|
||||||
|
|
||||||
|
This automatically:
|
||||||
|
- Bumps the version based on commit types (`feat` = minor, `fix` = patch)
|
||||||
|
- Generates categorized release notes
|
||||||
|
- Updates `CHANGELOG.md`
|
||||||
|
- Creates a git tag and GitHub Release
|
||||||
|
- Publishes to npm
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
By contributing, you agree that your contributions will be licensed under the [AGPL-3.0-or-later License](LICENSE), including the additional terms specified in Section 7 of the LICENSE file.
|
||||||
13
NOTICE
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
CloudCLI UI
|
||||||
|
Copyright 2025-2026 Siteboon AI B.V. and contributors
|
||||||
|
|
||||||
|
This software is licensed under the GNU Affero General Public License v3.0
|
||||||
|
or later (AGPL-3.0-or-later). See the LICENSE file for the full license text,
|
||||||
|
including additional terms under Section 7.
|
||||||
|
|
||||||
|
Originally developed by Siteboon AI B.V. (https://github.com/siteboon/claudecodeui).
|
||||||
|
|
||||||
|
Contributions by Siteboon AI B.V. prior to commit 004135ef were originally
|
||||||
|
published under GPL-3.0 and are hereby relicensed to AGPL-3.0-or-later.
|
||||||
|
Contributions by other authors prior to that commit remain under GPL-3.0
|
||||||
|
and are incorporated into this work as permitted by GPL-3.0 Section 13.
|
||||||
250
README.de.md
Normal file
@@ -0,0 +1,250 @@
|
|||||||
|
<div align="center">
|
||||||
|
<img src="public/logo.svg" alt="CloudCLI UI" width="64" height="64">
|
||||||
|
<h1>Cloud CLI (auch bekannt als Claude Code UI)</h1>
|
||||||
|
<p>Eine Desktop- und Mobile-Oberfläche für <a href="https://docs.anthropic.com/en/docs/claude-code">Claude Code</a>, <a href="https://docs.cursor.com/en/cli/overview">Cursor CLI</a>, <a href="https://developers.openai.com/codex">Codex</a> und <a href="https://geminicli.com/">Gemini-CLI</a>.<br>Lokal oder remote nutzbar – verwalte deine aktiven Projekte und Sitzungen von überall.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://cloudcli.ai">CloudCLI Cloud</a> · <a href="https://cloudcli.ai/docs">Dokumentation</a> · <a href="https://discord.gg/buxwujPNRE">Discord</a> · <a href="https://github.com/siteboon/claudecodeui/issues">Fehler melden</a> · <a href="CONTRIBUTING.md">Mitwirken</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://cloudcli.ai"><img src="https://img.shields.io/badge/☁️_CloudCLI_Cloud-Try_Now-0066FF?style=for-the-badge" alt="CloudCLI Cloud"></a>
|
||||||
|
<a href="https://discord.gg/buxwujPNRE"><img src="https://img.shields.io/badge/Discord-Join_Community-5865F2?style=for-the-badge&logo=discord&logoColor=white" alt="Join Community"></a>
|
||||||
|
<br><br>
|
||||||
|
<a href="https://trendshift.io/repositories/15586" target="_blank"><img src="https://trendshift.io/api/badge/repositories/15586" alt="siteboon%2Fclaudecodeui | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div align="right"><i><a href="./README.md">English</a> · <a href="./README.ru.md">Русский</a> · <b>Deutsch</b> · <a href="./README.ko.md">한국어</a> · <a href="./README.zh-CN.md">中文</a> · <a href="./README.ja.md">日本語</a> · <a href="./README.tr.md">Türkçe</a></i></div>
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Screenshots
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td align="center">
|
||||||
|
<h3>Desktop-Ansicht</h3>
|
||||||
|
<img src="public/screenshots/desktop-main.png" alt="Desktop-Oberfläche" width="400">
|
||||||
|
<br>
|
||||||
|
<em>Hauptoberfläche mit Projektübersicht und Chat</em>
|
||||||
|
</td>
|
||||||
|
<td align="center">
|
||||||
|
<h3>Mobile-Erfahrung</h3>
|
||||||
|
<img src="public/screenshots/mobile-chat.png" alt="Mobile-Oberfläche" width="250">
|
||||||
|
<br>
|
||||||
|
<em>Responsives mobiles Design mit Touch-Navigation</em>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="center" colspan="2">
|
||||||
|
<h3>CLI-Auswahl</h3>
|
||||||
|
<img src="public/screenshots/cli-selection.png" alt="CLI-Auswahl" width="400">
|
||||||
|
<br>
|
||||||
|
<em>Wähle zwischen Claude Code, Gemini, Cursor CLI und Codex</em>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
## Funktionen
|
||||||
|
|
||||||
|
- **Responsives Design** – Funktioniert nahtlos auf Desktop, Tablet und Mobilgerät, sodass du Agents auch vom Smartphone aus nutzen kannst
|
||||||
|
- **Interaktives Chat-Interface** – Eingebaute Chat-Oberfläche für die reibungslose Kommunikation mit den Agents
|
||||||
|
- **Integriertes Shell-Terminal** – Direkter Zugriff auf die Agents CLI über die eingebaute Shell-Funktionalität
|
||||||
|
- **Datei-Explorer** – Interaktiver Dateibaum mit Syntaxhervorhebung und Live-Bearbeitung
|
||||||
|
- **Git-Explorer** – Änderungen anzeigen, stagen und committen. Branches wechseln ebenfalls möglich
|
||||||
|
- **Sitzungsverwaltung** – Gespräche fortsetzen, mehrere Sitzungen verwalten und Verlauf nachverfolgen
|
||||||
|
- **Plugin-System** – CloudCLI mit eigenen Plugins erweitern – neue Tabs, Backend-Dienste und Integrationen hinzufügen. [Eigenes Plugin erstellen →](https://github.com/cloudcli-ai/cloudcli-plugin-starter)
|
||||||
|
- **TaskMaster AI Integration** *(Optional)* – Erweitertes Projektmanagement mit KI-gestützter Aufgabenplanung, PRD-Parsing und Workflow-Automatisierung
|
||||||
|
- **Modell-Kompatibilität** – Funktioniert mit Claude, GPT und Gemini (vollständige Liste unterstützter Modelle in [`shared/modelConstants.js`](shared/modelConstants.js))
|
||||||
|
|
||||||
|
|
||||||
|
## Schnellstart
|
||||||
|
|
||||||
|
### CloudCLI Cloud (Empfohlen)
|
||||||
|
|
||||||
|
Der schnellste Einstieg – keine lokale Einrichtung erforderlich. Erhalte eine vollständig verwaltete, containerisierte Entwicklungsumgebung, die über Web, Mobile App, API oder deine bevorzugte IDE erreichbar ist.
|
||||||
|
|
||||||
|
**[Mit CloudCLI Cloud starten](https://cloudcli.ai)**
|
||||||
|
|
||||||
|
|
||||||
|
### Self-Hosted (Open Source)
|
||||||
|
|
||||||
|
#### npm
|
||||||
|
|
||||||
|
CloudCLI UI sofort mit **npx** ausprobieren (erfordert **Node.js** v22+):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npx @cloudcli-ai/cloudcli
|
||||||
|
```
|
||||||
|
|
||||||
|
Oder **global** installieren für regelmäßige Nutzung:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install -g @cloudcli-ai/cloudcli
|
||||||
|
cloudcli
|
||||||
|
```
|
||||||
|
|
||||||
|
Öffne `http://localhost:3001` – alle vorhandenen Sitzungen werden automatisch erkannt.
|
||||||
|
|
||||||
|
Die **[Dokumentation →](https://cloudcli.ai/docs)** enthält weitere Konfigurationsoptionen, PM2, Remote-Server-Einrichtung und mehr.
|
||||||
|
|
||||||
|
#### Docker Sandboxes (Experimentell)
|
||||||
|
|
||||||
|
Agents in isolierten Sandboxes mit Hypervisor-Isolation ausführen. Standardmäßig wird Claude Code gestartet. Erfordert die [`sbx` CLI](https://docs.docker.com/ai/sandboxes/get-started/).
|
||||||
|
|
||||||
|
```
|
||||||
|
npx @cloudcli-ai/cloudcli@latest sandbox ~/my-project
|
||||||
|
```
|
||||||
|
|
||||||
|
Unterstützt Claude Code, Codex und Gemini CLI. Weitere Details in der [Sandbox-Dokumentation](docker/).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Welche Option passt zu dir?
|
||||||
|
|
||||||
|
CloudCLI UI ist die Open-Source-UI-Schicht, die CloudCLI Cloud antreibt. Du kannst es auf deinem eigenen Rechner selbst hosten oder CloudCLI Cloud nutzen, das darauf aufbaut und eine vollständig verwaltete Cloud-Umgebung, Team-Funktionen und tiefere Integrationen bietet.
|
||||||
|
|
||||||
|
| | CloudCLI UI (Self-hosted) | CloudCLI Cloud |
|
||||||
|
|---|---|---|
|
||||||
|
| **Am besten für** | Entwickler:innen, die eine vollständige UI für lokale Agent-Sitzungen auf ihrem eigenen Rechner möchten | Teams und Entwickler:innen, die Agents in der Cloud betreiben möchten, überall erreichbar |
|
||||||
|
| **Zugriff** | Browser via `[deineIP]:port` | Browser, jede IDE, REST API, n8n |
|
||||||
|
| **Einrichtung** | `npx @cloudcli-ai/cloudcli` | Keine Einrichtung erforderlich |
|
||||||
|
| **Rechner muss laufen** | Ja | Nein |
|
||||||
|
| **Mobiler Zugriff** | Jeder Browser im Netzwerk | Jedes Gerät, native App in Entwicklung |
|
||||||
|
| **Verfügbare Sitzungen** | Alle Sitzungen automatisch aus `~/.claude` erkannt | Alle Sitzungen in deiner Cloud-Umgebung |
|
||||||
|
| **Unterstützte Agents** | Claude Code, Cursor CLI, Codex, Gemini CLI | Claude Code, Cursor CLI, Codex, Gemini CLI |
|
||||||
|
| **Datei-Explorer und Git** | Ja, direkt in der UI | Ja, direkt in der UI |
|
||||||
|
| **MCP-Konfiguration** | Über UI verwaltet, synchronisiert mit lokalem `~/.claude` | Über UI verwaltet |
|
||||||
|
| **IDE-Zugriff** | Deine lokale IDE | Jede IDE, die mit deiner Cloud-Umgebung verbunden ist |
|
||||||
|
| **REST API** | Ja | Ja |
|
||||||
|
| **n8n-Node** | Nein | Ja |
|
||||||
|
| **Team-Sharing** | Nein | Ja |
|
||||||
|
| **Plattformkosten** | Kostenlos, Open Source | Ab $7/Monat |
|
||||||
|
|
||||||
|
> Beide Optionen verwenden deine eigenen KI-Abonnements (Claude, Cursor usw.) – CloudCLI stellt die Umgebung bereit, nicht die KI.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Sicherheit & Tool-Konfiguration
|
||||||
|
|
||||||
|
**🔒 Wichtiger Hinweis**: Alle Claude Code Tools sind **standardmäßig deaktiviert**. Dies verhindert, dass potenziell schädliche Operationen automatisch ausgeführt werden.
|
||||||
|
|
||||||
|
### Tools aktivieren
|
||||||
|
|
||||||
|
Um den vollen Funktionsumfang von Claude Code zu nutzen, müssen Tools manuell aktiviert werden:
|
||||||
|
|
||||||
|
1. **Tool-Einstellungen öffnen** – Klicke auf das Zahnrad-Symbol in der Seitenleiste
|
||||||
|
2. **Selektiv aktivieren** – Nur die benötigten Tools einschalten
|
||||||
|
3. **Einstellungen übernehmen** – Deine Einstellungen werden lokal gespeichert
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
|
||||||
|

|
||||||
|
*Tool-Einstellungen – nur aktivieren, was benötigt wird*
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
**Empfohlene Vorgehensweise**: Mit grundlegenden Tools starten und bei Bedarf weitere hinzufügen. Die Einstellungen können jederzeit angepasst werden.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Plugins
|
||||||
|
|
||||||
|
CloudCLI verfügt über ein Plugin-System, mit dem benutzerdefinierte Tabs mit eigener Frontend-UI und optionalem Node.js-Backend hinzugefügt werden können. Plugins können direkt in **Einstellungen > Plugins** aus Git-Repos installiert oder selbst entwickelt werden.
|
||||||
|
|
||||||
|
### Verfügbare Plugins
|
||||||
|
|
||||||
|
| Plugin | Beschreibung |
|
||||||
|
|---|---|
|
||||||
|
| **[Project Stats](https://github.com/cloudcli-ai/cloudcli-plugin-starter)** | Zeigt Dateianzahl, Codezeilen, Dateityp-Aufschlüsselung, größte Dateien und zuletzt geänderte Dateien des aktuellen Projekts |
|
||||||
|
|
||||||
|
### Eigenes Plugin erstellen
|
||||||
|
|
||||||
|
**[Plugin-Starter-Vorlage →](https://github.com/cloudcli-ai/cloudcli-plugin-starter)** – Forke dieses Repository, um ein eigenes Plugin zu erstellen. Es enthält ein funktionierendes Beispiel mit Frontend-Rendering, Live-Kontext-Updates und RPC-Kommunikation zu einem Backend-Server.
|
||||||
|
|
||||||
|
**[Plugin-Dokumentation →](https://cloudcli.ai/docs/plugin-overview)** – Vollständige Anleitung zur Plugin-API, zum Manifest-Format, zum Sicherheitsmodell und mehr.
|
||||||
|
|
||||||
|
---
|
||||||
|
## FAQ
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Wie unterscheidet sich das von Claude Code Remote Control?</summary>
|
||||||
|
|
||||||
|
Claude Code Remote Control ermöglicht es, Nachrichten an eine bereits im lokalen Terminal laufende Sitzung zu senden. Der Rechner muss eingeschaltet bleiben, das Terminal muss offen bleiben, und Sitzungen laufen nach etwa 10 Minuten ohne Netzwerkverbindung ab.
|
||||||
|
|
||||||
|
CloudCLI UI und CloudCLI Cloud erweitern Claude Code, anstatt neben ihm zu laufen – MCP-Server, Berechtigungen, Einstellungen und Sitzungen sind exakt dieselben, die Claude Code nativ verwendet. Nichts wird dupliziert oder separat verwaltet.
|
||||||
|
|
||||||
|
Das bedeutet in der Praxis:
|
||||||
|
|
||||||
|
- **Alle Sitzungen, nicht nur eine** – CloudCLI UI erkennt automatisch jede Sitzung aus dem `~/.claude`-Ordner. Remote Control stellt nur die einzelne aktive Sitzung bereit, um sie in der Claude Mobile App verfügbar zu machen.
|
||||||
|
- **Deine Einstellungen sind deine Einstellungen** – MCP-Server, Tool-Berechtigungen und Projektkonfiguration, die in CloudCLI UI geändert werden, werden direkt in die Claude Code-Konfiguration geschrieben und treten sofort in Kraft – und umgekehrt.
|
||||||
|
- **Funktioniert mit mehr Agents** – Claude Code, Cursor CLI, Codex und Gemini CLI, nicht nur Claude Code.
|
||||||
|
- **Vollständige UI, nicht nur ein Chat-Fenster** – Datei-Explorer, Git-Integration, MCP-Verwaltung und ein Shell-Terminal sind alle eingebaut.
|
||||||
|
- **CloudCLI Cloud läuft in der Cloud** – Laptop zuklappen, der Agent läuft weiter. Kein Terminal zu überwachen, kein Rechner, der laufen muss.
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Muss ich ein KI-Abonnement separat bezahlen?</summary>
|
||||||
|
|
||||||
|
Ja. CloudCLI stellt die Umgebung bereit, nicht die KI. Du bringst dein eigenes Claude-, Cursor-, Codex- oder Gemini-Abonnement mit. CloudCLI Cloud beginnt bei $7/Monat für die gehostete Umgebung zusätzlich dazu.
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Kann ich CloudCLI UI auf meinem Smartphone nutzen?</summary>
|
||||||
|
|
||||||
|
Ja. Bei Self-Hosted: Server auf dem eigenen Rechner starten und `[deineIP]:port` in einem beliebigen Browser im Netzwerk öffnen. Bei CloudCLI Cloud: Von jedem Gerät aus öffnen – kein VPN, keine Portweiterleitung, keine Einrichtung. Eine native App ist ebenfalls in Entwicklung.
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Wirken sich Änderungen in der UI auf mein lokales Claude Code-Setup aus?</summary>
|
||||||
|
|
||||||
|
Ja, bei Self-Hosted. CloudCLI UI liest aus und schreibt in dieselbe `~/.claude`-Konfiguration, die Claude Code nativ verwendet. MCP-Server, die über die UI hinzugefügt werden, erscheinen sofort in Claude Code und umgekehrt.
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Community & Support
|
||||||
|
|
||||||
|
- **[Dokumentation](https://cloudcli.ai/docs)** — Installation, Konfiguration, Funktionen und Fehlerbehebung
|
||||||
|
- **[Discord](https://discord.gg/buxwujPNRE)** — Hilfe erhalten und mit anderen Nutzer:innen in Kontakt treten
|
||||||
|
- **[GitHub Issues](https://github.com/siteboon/claudecodeui/issues)** — Fehlerberichte und Feature-Anfragen
|
||||||
|
- **[Beitragsrichtlinien](CONTRIBUTING.md)** — So kannst du zum Projekt beitragen
|
||||||
|
|
||||||
|
## Lizenz
|
||||||
|
|
||||||
|
GNU General Public License v3.0 – siehe [LICENSE](LICENSE)-Datei für Details.
|
||||||
|
|
||||||
|
Dieses Projekt ist Open Source und kann unter der GPL v3-Lizenz kostenlos genutzt, modifiziert und verteilt werden.
|
||||||
|
|
||||||
|
## Danksagungen
|
||||||
|
|
||||||
|
### Erstellt mit
|
||||||
|
- **[Claude Code](https://docs.anthropic.com/en/docs/claude-code)** - Anthropics offizielle CLI
|
||||||
|
- **[Cursor CLI](https://docs.cursor.com/en/cli/overview)** - Cursors offizielle CLI
|
||||||
|
- **[Codex](https://developers.openai.com/codex)** - OpenAI Codex
|
||||||
|
- **[Gemini-CLI](https://geminicli.com/)** - Google Gemini CLI
|
||||||
|
- **[React](https://react.dev/)** - UI-Bibliothek
|
||||||
|
- **[Vite](https://vitejs.dev/)** - Schnelles Build-Tool und Dev-Server
|
||||||
|
- **[Tailwind CSS](https://tailwindcss.com/)** - Utility-first CSS-Framework
|
||||||
|
- **[CodeMirror](https://codemirror.net/)** - Erweiterter Code-Editor
|
||||||
|
- **[TaskMaster AI](https://github.com/eyaltoledano/claude-task-master)** *(Optional)* - KI-gestütztes Projektmanagement und Aufgabenplanung
|
||||||
|
|
||||||
|
|
||||||
|
### Sponsoren
|
||||||
|
- [Siteboon - KI-gestützter Website-Builder](https://siteboon.ai)
|
||||||
|
---
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
<strong>Mit Sorgfalt für die Claude Code-, Cursor- und Codex-Community erstellt.</strong>
|
||||||
|
</div>
|
||||||
242
README.ja.md
Normal file
@@ -0,0 +1,242 @@
|
|||||||
|
<div align="center">
|
||||||
|
<img src="public/logo.svg" alt="CloudCLI UI" width="64" height="64">
|
||||||
|
<h1>Cloud CLI(別名 Claude Code UI)</h1>
|
||||||
|
<p><a href="https://docs.anthropic.com/en/docs/claude-code">Claude Code</a>、<a href="https://docs.cursor.com/en/cli/overview">Cursor CLI</a>、<a href="https://developers.openai.com/codex">Codex</a>、<a href="https://geminicli.com/">Gemini-CLI</a> のためのデスクトップ/モバイル UI。<br>ローカルでもリモートでも使え、アクティブなプロジェクトとセッションをどこからでも閲覧できます。</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://cloudcli.ai">CloudCLI Cloud</a> · <a href="https://cloudcli.ai/docs">ドキュメント</a> · <a href="https://discord.gg/buxwujPNRE">Discord</a> · <a href="https://github.com/siteboon/claudecodeui/issues">バグ報告</a> · <a href="CONTRIBUTING.md">コントリビュート</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://cloudcli.ai"><img src="https://img.shields.io/badge/☁️_CloudCLI_Cloud-Try_Now-0066FF?style=for-the-badge" alt="CloudCLI Cloud"></a>
|
||||||
|
<a href="https://discord.gg/buxwujPNRE"><img src="https://img.shields.io/badge/Discord-Join%20Community-5865F2?style=for-the-badge&logo=discord&logoColor=white" alt="Discord コミュニティに参加"></a>
|
||||||
|
<br><br>
|
||||||
|
<a href="https://trendshift.io/repositories/15586" target="_blank"><img src="https://trendshift.io/api/badge/repositories/15586" alt="siteboon%2Fclaudecodeui | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div align="right"><i><a href="./README.md">English</a> · <a href="./README.ru.md">Русский</a> · <a href="./README.de.md">Deutsch</a> · <a href="./README.ko.md">한국어</a> · <a href="./README.zh-CN.md">中文</a> · <b>日本語</b> · <a href="./README.tr.md">Türkçe</a></i></div>
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## スクリーンショット
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td align="center">
|
||||||
|
<h3>デスクトップビュー</h3>
|
||||||
|
<img src="public/screenshots/desktop-main.png" alt="デスクトップインターフェース" width="400">
|
||||||
|
<br>
|
||||||
|
<em>プロジェクト概要とチャットを表示するメイン画面</em>
|
||||||
|
</td>
|
||||||
|
<td align="center">
|
||||||
|
<h3>モバイル体験</h3>
|
||||||
|
<img src="public/screenshots/mobile-chat.png" alt="モバイルインターフェース" width="250">
|
||||||
|
<br>
|
||||||
|
<em>タッチ操作に対応したレスポンシブなモバイルデザイン</em>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="center" colspan="2">
|
||||||
|
<h3>CLI 選択</h3>
|
||||||
|
<img src="public/screenshots/cli-selection.png" alt="CLI 選択" width="400">
|
||||||
|
<br>
|
||||||
|
<em>Claude Code、Gemini、Cursor CLI、Codex から選択</em>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
## 機能
|
||||||
|
|
||||||
|
- **レスポンシブデザイン** - デスクトップ/タブレット/モバイルでシームレスに動作し、モバイルからも Agents を利用可能
|
||||||
|
- **インタラクティブチャット UI** - Agents とスムーズにやり取りできる内蔵チャット UI
|
||||||
|
- **統合シェルターミナル** - 内蔵シェル機能で Agents の CLI に直接アクセス
|
||||||
|
- **ファイルエクスプローラー** - シンタックスハイライトとライブ編集に対応したインタラクティブなファイルツリー
|
||||||
|
- **Git エクスプローラー** - 変更の表示、ステージ、コミット。ブランチ切り替えも可能
|
||||||
|
- **セッション管理** - 会話の再開、複数セッションの管理、履歴の追跡
|
||||||
|
- **プラグインシステム** - カスタムプラグインで CloudCLI を拡張 — 新しいタブ、バックエンドサービス、連携を追加できます。[自分で構築する →](https://github.com/cloudcli-ai/cloudcli-plugin-starter)
|
||||||
|
|
||||||
|
## クイックスタート
|
||||||
|
|
||||||
|
### CloudCLI Cloud(推奨)
|
||||||
|
|
||||||
|
最速で始める方法 — ローカルのセットアップは不要です。Web、モバイルアプリ、API、またはお気に入りの IDE からアクセスできる、フルマネージドでコンテナ化された開発環境を利用できます。
|
||||||
|
|
||||||
|
**[CloudCLI Cloud を始める](https://cloudcli.ai)**
|
||||||
|
|
||||||
|
### セルフホスト(オープンソース)
|
||||||
|
|
||||||
|
#### npm
|
||||||
|
|
||||||
|
**npx** で今すぐ CloudCLI UI を試せます(**Node.js** v22+ が必要):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npx @cloudcli-ai/cloudcli
|
||||||
|
```
|
||||||
|
|
||||||
|
または、普段使いするなら **グローバル** にインストール:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install -g @cloudcli-ai/cloudcli
|
||||||
|
cloudcli
|
||||||
|
```
|
||||||
|
|
||||||
|
`http://localhost:3001` を開いてください — 既存のセッションは自動的に検出されます。
|
||||||
|
|
||||||
|
より詳細な設定オプション、PM2、リモートサーバー設定などについては **[ドキュメントはこちら →](https://cloudcli.ai/docs)** を参照してください。
|
||||||
|
|
||||||
|
#### Docker Sandboxes(実験的)
|
||||||
|
|
||||||
|
ハイパーバイザーレベルの分離でエージェントをサンドボックスで実行します。デフォルトでは Claude Code が起動します。[`sbx` CLI](https://docs.docker.com/ai/sandboxes/get-started/) が必要です。
|
||||||
|
|
||||||
|
```
|
||||||
|
npx @cloudcli-ai/cloudcli@latest sandbox ~/my-project
|
||||||
|
```
|
||||||
|
|
||||||
|
Claude Code、Codex、Gemini CLI に対応。詳細は[サンドボックスのドキュメント](docker/)をご覧ください。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## どちらの選択肢が適していますか?
|
||||||
|
|
||||||
|
CloudCLI UI は、CloudCLI Cloud を支えるオープンソースの UI レイヤーです。自分のマシンにセルフホストすることも、フルマネージドのクラウド環境、チーム機能、より深い統合を備えた CloudCLI Cloud を使うこともできます。
|
||||||
|
|
||||||
|
| | CloudCLI UI(セルフホスト) | CloudCLI Cloud |
|
||||||
|
|---|---|---|
|
||||||
|
| **対象ユーザー** | 自分のマシン上でローカルの agent セッションに対してフル UI を使いたい開発者 | クラウド上で動く agents をどこからでも利用したいチーム/開発者 |
|
||||||
|
| **アクセス方法** | ブラウザ(`[yourip]:port`) | ブラウザ、任意の IDE、REST API、n8n |
|
||||||
|
| **セットアップ** | `npx @cloudcli-ai/cloudcli` | セットアップ不要 |
|
||||||
|
| **マシンの稼働継続** | はい | いいえ |
|
||||||
|
| **モバイルアクセス** | 同一ネットワーク内の任意のブラウザ | 任意のデバイス(ネイティブアプリも準備中) |
|
||||||
|
| **利用可能なセッション** | `~/.claude` から全セッションを自動検出 | クラウド環境内の全セッション |
|
||||||
|
| **対応エージェント** | Claude Code、Cursor CLI、Codex、Gemini CLI | Claude Code、Cursor CLI、Codex、Gemini CLI |
|
||||||
|
| **ファイルエクスプローラとGit** | はい(UI に内蔵) | はい(UI に内蔵) |
|
||||||
|
| **MCP設定** | UI で管理し、ローカルの `~/.claude` 設定と同期 | UI で管理 |
|
||||||
|
| **IDEアクセス** | ローカル IDE | クラウド環境に接続された任意の IDE |
|
||||||
|
| **REST API** | はい | はい |
|
||||||
|
| **n8n ノード** | いいえ | はい |
|
||||||
|
| **チーム共有** | いいえ | はい |
|
||||||
|
| **料金プラン** | 無料(オープンソース) | 月 $7〜 |
|
||||||
|
|
||||||
|
> どちらの選択肢でも、AI のサブスクリプション(Claude、Cursor など)はご自身のものを使用します — CloudCLI が提供するのは環境であり、AI そのものではありません。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## セキュリティとツール設定
|
||||||
|
|
||||||
|
**🔒 重要なお知らせ** すべての Claude Code ツールは **デフォルトで無効** です。これにより、潜在的に有害な操作が自動的に実行されることを防ぎます。
|
||||||
|
|
||||||
|
### ツールの有効化
|
||||||
|
|
||||||
|
1. **ツール設定を開く** - サイドバーの歯車アイコンをクリック
|
||||||
|
2. **必要なツールだけを選んで有効化** - 本当に使うものだけをオンにする
|
||||||
|
3. **設定を適用** - 設定内容はローカルに保存されます
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
|
||||||
|

|
||||||
|
*Tools 設定画面 - 必要なものだけを有効にしてください*
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
**推奨アプローチ**: まずは基本ツールだけを有効にし、必要に応じて追加してください。これらの設定は後からいつでも調整できます。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## プラグイン
|
||||||
|
|
||||||
|
CloudCLI にはプラグインシステムがあり、独自のフロントエンド UI と(必要に応じて)Node.js バックエンドを持つカスタムタブを追加できます。プラグインは **Settings > Plugins** から git リポジトリを直接指定してインストールするか、自作できます。
|
||||||
|
|
||||||
|
### 利用可能なプラグイン
|
||||||
|
|
||||||
|
| プラグイン | 説明 |
|
||||||
|
|---|---|
|
||||||
|
| **[Project Stats](https://github.com/cloudcli-ai/cloudcli-plugin-starter)** | 現在のプロジェクトについて、ファイル数、コード行数、ファイル種別の内訳、最大ファイル、最近変更されたファイルを表示 |
|
||||||
|
|
||||||
|
### 自作する
|
||||||
|
|
||||||
|
**[Plugin Starter Template →](https://github.com/cloudcli-ai/cloudcli-plugin-starter)** — このリポジトリを fork して独自プラグインを作れます。フロントエンド描画、ライブコンテキスト更新、バックエンドサーバーへの RPC 通信を含む動作例が入っています。
|
||||||
|
|
||||||
|
**[プラグインのドキュメント →](https://cloudcli.ai/docs/plugin-overview)** — プラグイン API、manifest 形式、セキュリティモデルなどの完全ガイド。
|
||||||
|
|
||||||
|
---
|
||||||
|
## FAQ
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Claude Code Remote Control とはどう違いますか?</summary>
|
||||||
|
|
||||||
|
Claude Code Remote Control は、ローカル端末で既に動作しているセッションへメッセージを送れる仕組みです。マシンを起動したままにし、端末も開いたままにする必要があり、ネットワーク接続がない状態が約 10 分続くとセッションがタイムアウトします。
|
||||||
|
|
||||||
|
CloudCLI UI と CloudCLI Cloud は、Claude Code の横に別物として存在するのではなく、Claude Code を拡張します — MCP サーバー、権限、設定、セッションは Claude Code がネイティブに使うものと完全に同一です。複製したり、別系統で管理したりしません。
|
||||||
|
|
||||||
|
- **すべてのセッションにアクセス** — CloudCLI UI は `~/.claude` フォルダのすべてのセッションを自動検出します。Remote Control は、Claude モバイルアプリで利用可能にするため、1つのアクティブセッションだけを公開します。
|
||||||
|
- **設定はあなたの設定** — CloudCLI UI で変更した MCP サーバー、ツール権限、プロジェクト構成は、Claude Code の設定に直接書き込まれて即座に反映され、その逆(Claude Code での変更が UI に反映)も同様です。
|
||||||
|
- **対応エージェントがさらに充実** — Claude Code に加えて Cursor CLI、Codex、Gemini CLI にも対応しています。
|
||||||
|
- **チャット窓だけではない完全な UI** — ファイルエクスプローラー、Git 統合、MCP 管理、シェル端末などがすべて組み込まれています。
|
||||||
|
- **CloudCLI Cloud はクラウド上で稼働** — ノートパソコンを閉じてもエージェントは動き続けます。監視が要る端末も、スリープ防止も不要です。
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>AI のサブスクリプションは別途支払いが必要ですか?</summary>
|
||||||
|
|
||||||
|
はい。CloudCLI は環境を提供するものであり、AI は含まれません。Claude、Cursor、Codex、または Gemini のサブスクリプションはご自身でご用意ください。CloudCLI Cloud のホスティング環境はそれに加えて月額 $7 から提供されます。
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>CloudCLI UI をスマホで使えますか?</summary>
|
||||||
|
|
||||||
|
はい。セルフホストの場合は、自身のマシンでサーバーを起動し、ネットワーク内のブラウザで `[yourip]:port` を開いてください。CloudCLI Cloud を使う場合は、任意のデバイスからアクセスできます。VPN もポートフォワーディングも不要で、セットアップも不要です。ネイティブアプリも開発中です。
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>UI で加えた変更はローカルの Claude Code 設定に影響しますか?</summary>
|
||||||
|
|
||||||
|
はい、セルフホストの場合です。CloudCLI UI は Claude Code がネイティブに使う `~/.claude` 設定を読み書きします。UI から追加した MCP サーバーは即座に Claude Code に反映され、その逆も同様です。
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## コミュニティとサポート
|
||||||
|
|
||||||
|
- **[ドキュメント](https://cloudcli.ai/docs)** — インストール、設定、機能、トラブルシューティング
|
||||||
|
- **[Discord](https://discord.gg/buxwujPNRE)** — ヘルプを得たり、ユーザー同士で交流したりできます
|
||||||
|
- **[GitHub Issues](https://github.com/siteboon/claudecodeui/issues)** — バグ報告と機能要望
|
||||||
|
- **[コントリビューションガイド](CONTRIBUTING.md)** — プロジェクトへの貢献方法
|
||||||
|
|
||||||
|
## ライセンス
|
||||||
|
|
||||||
|
GNU General Public License v3.0 - 詳細は [LICENSE](LICENSE) ファイルを参照してください。
|
||||||
|
|
||||||
|
このプロジェクトはオープンソースであり、GPL v3 ライセンスの下で無料で使用、修正、再配布できます。
|
||||||
|
|
||||||
|
## 謝辞
|
||||||
|
|
||||||
|
### 使用技術
|
||||||
|
|
||||||
|
- **[Claude Code](https://docs.anthropic.com/en/docs/claude-code)** - Anthropic の公式 CLI
|
||||||
|
- **[Cursor CLI](https://docs.cursor.com/en/cli/overview)** - Cursor の公式 CLI
|
||||||
|
- **[Codex](https://developers.openai.com/codex)** - OpenAI Codex
|
||||||
|
- **[Gemini-CLI](https://geminicli.com/)** - Google Gemini CLI
|
||||||
|
- **[React](https://react.dev/)** - ユーザーインターフェースライブラリ
|
||||||
|
- **[Vite](https://vitejs.dev/)** - 高速ビルドツールと開発サーバー
|
||||||
|
- **[Tailwind CSS](https://tailwindcss.com/)** - ユーティリティファーストの CSS フレームワーク
|
||||||
|
- **[CodeMirror](https://codemirror.net/)** - 高度なコードエディタ
|
||||||
|
- **[TaskMaster AI](https://github.com/eyaltoledano/claude-task-master)** *(オプション)* - AI を活用したプロジェクト管理とタスク計画
|
||||||
|
|
||||||
|
## スポンサー
|
||||||
|
- [Siteboon - AI を活用したウェブサイトビルダー](https://siteboon.ai)
|
||||||
|
---
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
<strong>Claude Code、Cursor、Codex コミュニティのために心を込めて作りました。</strong>
|
||||||
|
</div>
|
||||||
242
README.ko.md
Normal file
@@ -0,0 +1,242 @@
|
|||||||
|
<div align="center">
|
||||||
|
<img src="public/logo.svg" alt="CloudCLI UI" width="64" height="64">
|
||||||
|
<h1>Cloud CLI (일명 Claude Code UI)</h1>
|
||||||
|
<p><a href="https://docs.anthropic.com/en/docs/claude-code">Claude Code</a>, <a href="https://docs.cursor.com/en/cli/overview">Cursor CLI</a>, <a href="https://developers.openai.com/codex">Codex</a>, <a href="https://geminicli.com/">Gemini-CLI</a> 용 데스크톱 및 모바일 UI입니다.<br>로컬 또는 원격에서 실행하여 어디서나 활성 프로젝트와 세션을 확인하세요.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://cloudcli.ai">CloudCLI Cloud</a> · <a href="https://cloudcli.ai/docs">문서</a> · <a href="https://discord.gg/buxwujPNRE">Discord</a> · <a href="https://github.com/siteboon/claudecodeui/issues">버그 신고</a> · <a href="CONTRIBUTING.md">기여 안내</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://cloudcli.ai"><img src="https://img.shields.io/badge/☁️_CloudCLI_Cloud-Try_Now-0066FF?style=for-the-badge" alt="CloudCLI Cloud"></a>
|
||||||
|
<a href="https://discord.gg/buxwujPNRE"><img src="https://img.shields.io/badge/Discord-Join%20Community-5865F2?style=for-the-badge&logo=discord&logoColor=white" alt="Discord 커뮤니티"></a>
|
||||||
|
<br><br>
|
||||||
|
<a href="https://trendshift.io/repositories/15586" target="_blank"><img src="https://trendshift.io/api/badge/repositories/15586" alt="siteboon%2Fclaudecodeui | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div align="right"><i><a href="./README.md">English</a> · <a href="./README.ru.md">Русский</a> · <a href="./README.de.md">Deutsch</a> · <b>한국어</b> · <a href="./README.zh-CN.md">中文</a> · <a href="./README.ja.md">日本語</a> · <a href="./README.tr.md">Türkçe</a></i></div>
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 스크린샷
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td align="center">
|
||||||
|
<h3>데스크톱 보기</h3>
|
||||||
|
<img src="public/screenshots/desktop-main.png" alt="데스크톱 인터페이스" width="400">
|
||||||
|
<br>
|
||||||
|
<em>프로젝트 개요와 채팅을 보여주는 메인 인터페이스</em>
|
||||||
|
</td>
|
||||||
|
<td align="center">
|
||||||
|
<h3>모바일 경험</h3>
|
||||||
|
<img src="public/screenshots/mobile-chat.png" alt="모바일 인터페이스" width="250">
|
||||||
|
<br>
|
||||||
|
<em>터치 내비게이션이 포함된 반응형 모바일 디자인</em>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="center" colspan="2">
|
||||||
|
<h3>CLI 선택</h3>
|
||||||
|
<img src="public/screenshots/cli-selection.png" alt="CLI 선택" width="400">
|
||||||
|
<br>
|
||||||
|
<em>Claude Code, Gemini, Cursor CLI 및 Codex 중 선택</em>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
## 기능
|
||||||
|
|
||||||
|
- **반응형 디자인** - 데스크톱, 태블릿, 모바일을 아우르는 매끄러운 경험으로 어디서든 Agents를 사용할 수 있습니다
|
||||||
|
- **대화형 채팅 인터페이스** - 내장된 채팅 UI를 통해 에이전트와 자연스럽게 소통
|
||||||
|
- **통합 셸 터미널** - 셸 기능을 통해 Agents CLI에 직접 접근
|
||||||
|
- **파일 탐색기** - 구문 강조 및 실시간 편집을 갖춘 인터랙티브 파일 트리
|
||||||
|
- **Git 탐색기** - 변경 사항 보기, 스테이징 및 커밋. 브랜치 전환 기능 포함
|
||||||
|
- **세션 관리** - 대화를 재개하고, 여러 세션을 관리하며 기록을 추적
|
||||||
|
- **플러그인 시스템** - 커스텀 탭, 백엔드 서비스, 통합을 추가하여 CloudCLI 확장. [직접 빌드 →](https://github.com/cloudcli-ai/cloudcli-plugin-starter)
|
||||||
|
- **TaskMaster AI 통합** *(선택사항)* - AI 중심의 작업 계획, PRD 파싱, 워크플로 자동화를 통한 고급 프로젝트 관리
|
||||||
|
- **모델 호환성** - Claude, GPT, Gemini 모델 계열에서 작동 (`shared/modelConstants.js`에서 전체 지원 모델 확인)
|
||||||
|
|
||||||
|
## 빠른 시작
|
||||||
|
|
||||||
|
### CloudCLI Cloud (추천)
|
||||||
|
|
||||||
|
가장 빠르게 시작하는 방법 — 로컬 설정 없이도 가능합니다. 웹, 모바일 앱, API 또는 선호하는 IDE에서 이용할 수 있는 완전 관리형 컨테이너화된 개발 환경을 제공합니다.
|
||||||
|
|
||||||
|
**[CloudCLI Cloud 시작하기](https://cloudcli.ai)**
|
||||||
|
|
||||||
|
### 셀프 호스트 (오픈 소스)
|
||||||
|
|
||||||
|
#### npm
|
||||||
|
|
||||||
|
**npx**로 즉시 CloudCLI UI를 실행하세요 (Node.js v22+ 필요):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npx @cloudcli-ai/cloudcli
|
||||||
|
```
|
||||||
|
|
||||||
|
**정기적으로 사용한다면 전역 설치:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install -g @cloudcli-ai/cloudcli
|
||||||
|
cloudcli
|
||||||
|
```
|
||||||
|
|
||||||
|
`http://localhost:3001`을 열면 기존 세션이 자동으로 발견됩니다.
|
||||||
|
|
||||||
|
자세한 구성 옵션, PM2, 원격 서버 설정 등은 **[문서 →](https://cloudcli.ai/docs)**를 참고하세요.
|
||||||
|
|
||||||
|
#### Docker Sandboxes (실험적)
|
||||||
|
|
||||||
|
하이퍼바이저 수준 격리로 에이전트를 샌드박스에서 실행합니다. 기본 에이전트는 Claude Code입니다. [`sbx` CLI](https://docs.docker.com/ai/sandboxes/get-started/)가 필요합니다.
|
||||||
|
|
||||||
|
```
|
||||||
|
npx @cloudcli-ai/cloudcli@latest sandbox ~/my-project
|
||||||
|
```
|
||||||
|
|
||||||
|
Claude Code, Codex, Gemini CLI를 지원합니다. 자세한 내용은 [샌드박스 문서](docker/)를 참고하세요.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 어느 옵션이 적합한가요?
|
||||||
|
|
||||||
|
CloudCLI UI는 CloudCLI Cloud를 구동하는 오픈 소스 UI 계층입니다. 로컬 머신에서 직접 셀프 호스트하거나, CloudCLI Cloud(완전 관리형 클라우드 환경, 팀 기능, 심화 통합 제공)를 사용할 수 있습니다.
|
||||||
|
|
||||||
|
| | CloudCLI UI (셀프 호스트) | CloudCLI Cloud |
|
||||||
|
|---|---|---|
|
||||||
|
| **적합한 대상** | 로컬 에이전트 세션을 위한 전체 UI가 필요한 개발자 | 어디서든 접근 가능한 클라우드에서 에이전트를 운영하고자 하는 팀 및 개발자 |
|
||||||
|
| **접근 방법** | `[yourip]:port`를 통해 브라우저 접속 | 브라우저, IDE, REST API, n8n |
|
||||||
|
| **설정** | `npx @cloudcli-ai/cloudcli` | 설정 불필요 |
|
||||||
|
| **기기 유지 필요 여부** | 예 (머신 켜둬야 함) | 아니오 |
|
||||||
|
| **모바일 접근** | 네트워크 내 브라우저 | 모든 기기 (네이티브 앱 예정) |
|
||||||
|
| **세션 접근** | `~/.claude`에서 자동 발견 | 클라우드 환경 내 세션 |
|
||||||
|
| **지원 에이전트** | Claude Code, Cursor CLI, Codex, Gemini CLI | Claude Code, Cursor CLI, Codex, Gemini CLI |
|
||||||
|
| **파일 탐색기 및 Git** | UI에 통합됨 | UI에 통합됨 |
|
||||||
|
| **MCP 구성** | UI에서 관리, 로컬 `~/.claude` 설정과 동기화됨 | UI에서 관리 |
|
||||||
|
| **IDE 접근** | 로컬 IDE | 클라우드 환경에 연결된 모든 IDE |
|
||||||
|
| **REST API** | 예 | 예 |
|
||||||
|
| **n8n 노드** | 아니오 | 예 |
|
||||||
|
| **팀 공유** | 아니오 | 예 |
|
||||||
|
| **플랫폼 비용** | 무료, 오픈 소스 | 월 $7부터 |
|
||||||
|
|
||||||
|
> 둘 다 자체 AI 구독(Claude, Cursor 등)을 그대로 사용합니다 — CloudCLI는 환경만 제공합니다.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 보안 및 도구 구성
|
||||||
|
|
||||||
|
**🔒 중요 공지**: 모든 Claude Code 도구는 **기본적으로 비활성화**되어 있습니다. 이는 잠재적인 유해 작업이 자동 실행되는 것을 방지하기 위한 조치입니다.
|
||||||
|
|
||||||
|
### 도구 활성화
|
||||||
|
|
||||||
|
1. **도구 설정 열기** - 사이드바의 톱니바퀴 아이콘 클릭
|
||||||
|
2. **선택적으로 활성화** - 필요한 도구만 켜기
|
||||||
|
3. **설정 적용** - 선호도는 로컬에 저장됨
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
|
||||||
|

|
||||||
|
*도구 설정 인터페이스 - 필요한 것만 켜세요*
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
**권장 방법**: 기본 도구를 먼저 켜고 필요할 때 추가하세요. 언제든지 조정 가능합니다.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 플러그인
|
||||||
|
|
||||||
|
CloudCLI는 커스텀 탭과 선택적 Node.js 백엔드가 포함된 플러그인 시스템을 제공합니다. Settings > Plugins에서 Git 저장소에서 플러그인을 설치하거나 직접 빌드할 수 있습니다.
|
||||||
|
|
||||||
|
### 이용 가능한 플러그인
|
||||||
|
|
||||||
|
| 플러그인 | 설명 |
|
||||||
|
|---|---|
|
||||||
|
| **[Project Stats](https://github.com/cloudcli-ai/cloudcli-plugin-starter)** | 현재 프로젝트의 파일 수, 코드 줄 수, 파일 유형 분포, 가장 큰 파일, 최근 수정 파일을 표시 |
|
||||||
|
|
||||||
|
### 직접 만들기
|
||||||
|
|
||||||
|
**[Plugin Starter Template →](https://github.com/cloudcli-ai/cloudcli-plugin-starter)** — 이 저장소를 포크하여 플러그인 구축. 프런트엔드 렌더링, 실시간 컨텍스트 업데이트, RPC 통신 예제 포함.
|
||||||
|
|
||||||
|
**[플러그인 문서 →](https://cloudcli.ai/docs/plugin-overview)** — 플러그인 API, 매니페스트 포맷, 보안 모델 등을 설명.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## FAQ
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Claude Code Remote Control과 어떻게 다른가요?</summary>
|
||||||
|
|
||||||
|
Claude Code Remote Control은 이미 로컬 터미널에서 실행 중인 세션으로 메시지를 전송합니다. 이 경우 기계가 켜져 있어야 하고 터미널을 열어 둬야 하며, 네트워크 연결 없이 약 10분 후 타임아웃됩니다.
|
||||||
|
|
||||||
|
CloudCLI UI와 CloudCLI Cloud는 Claude Code를 확장하며 별도로 존재하지 않습니다 — MCP 서버, 권한, 설정, 세션은 Claude Code에서 그대로 사용됩니다.
|
||||||
|
|
||||||
|
- **모든 세션을 다룬다** — CloudCLI UI는 `~/.claude` 폴더에서 모든 세션을 자동 발견합니다. Remote Control은 단일 활성 세션만 노출합니다.
|
||||||
|
- **설정은 그대로** — CloudCLI UI에서 변경한 MCP, 도구 권한, 프로젝트 설정은 Claude Code에 즉시 반영됩니다.
|
||||||
|
- **지원 에이전트가 더 많음** — Claude Code, Cursor CLI, Codex, Gemini CLI 지원.
|
||||||
|
- **전체 UI 제공** — 단일 채팅 창이 아닌 파일 탐색기, Git 통합, MCP 관리 및 셸 터미널 포함.
|
||||||
|
- **CloudCLI Cloud는 클라우드에서 실행** — 노트북을 닫아도 에이전트가 실행됩니다. 터미널을 계속 확인할 필요 없음.
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>AI 구독을 별도로 결제해야 하나요?</summary>
|
||||||
|
|
||||||
|
네. CloudCLI는 환경만 제공합니다. Claude, Cursor, Codex, Gemini 구독 비용은 별도로 부과됩니다. CloudCLI Cloud는 관리형 환경을 월 $7부터 제공합니다.
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>CloudCLI UI를 휴대폰에서 사용할 수 있나요?</summary>
|
||||||
|
|
||||||
|
네. 셀프 호스트인 경우 기계에서 서버를 실행하고 네트워크의 아무 브라우저에서 `[yourip]:port`를 열면 됩니다. CloudCLI Cloud는 어떤 기기에서도 열 수 있으며, 네이티브 앱도 준비 중입니다.
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>UI에서 변경하면 로컬 Claude Code 설정에 영향을 주나요?</summary>
|
||||||
|
|
||||||
|
네, 셀프 호스트에서는 그렇습니다. CloudCLI UI는 Claude Code가 사용하는 동일한 `~/.claude` 설정을 읽고 씁니다. UI에서 추가한 MCP 서버가 Claude Code에 즉시 나타납니다.
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 커뮤니티 및 지원
|
||||||
|
|
||||||
|
- **[문서](https://cloudcli.ai/docs)** — 설치, 구성, 기능, 문제 해결 안내
|
||||||
|
- **[Discord](https://discord.gg/buxwujPNRE)** — 도움 및 커뮤니티 참여
|
||||||
|
- **[GitHub Issues](https://github.com/siteboon/claudecodeui/issues)** — 버그 보고 및 기능 요청
|
||||||
|
- **[기여 안내](CONTRIBUTING.md)** — 프로젝트 참여 방법
|
||||||
|
|
||||||
|
## 라이선스
|
||||||
|
|
||||||
|
GNU General Public License v3.0 - 자세한 내용은 [LICENSE](LICENSE) 파일 참조.
|
||||||
|
|
||||||
|
이 프로젝트는 GPL v3 라이선스 하에 오픈 소스로 공개되어 있으며 자유롭게 사용, 수정, 배포할 수 있습니다.
|
||||||
|
|
||||||
|
## 감사의 말
|
||||||
|
|
||||||
|
### 사용 기술
|
||||||
|
- **[Claude Code](https://docs.anthropic.com/en/docs/claude-code)** - Anthropic 공식 CLI
|
||||||
|
- **[Cursor CLI](https://docs.cursor.com/en/cli/overview)** - Cursor 공식 CLI
|
||||||
|
- **[Codex](https://developers.openai.com/codex)** - OpenAI Codex
|
||||||
|
- **[Gemini-CLI](https://geminicli.com/)** - Google Gemini CLI
|
||||||
|
- **[React](https://react.dev/)** - 사용자 인터페이스 라이브러리
|
||||||
|
- **[Vite](https://vitejs.dev/)** - 빠른 빌드 도구 및 개발 서버
|
||||||
|
- **[Tailwind CSS](https://tailwindcss.com/)** - 유틸리티 우선 CSS 프레임워크
|
||||||
|
- **[CodeMirror](https://codemirror.net/)** - 고급 코드 에디터
|
||||||
|
- **[TaskMaster AI](https://github.com/eyaltoledano/claude-task-master)** *(선택사항)* - AI 기반 프로젝트 관리 및 작업 계획
|
||||||
|
|
||||||
|
### 스폰서
|
||||||
|
- [Siteboon - AI powered website builder](https://siteboon.ai)
|
||||||
|
---
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
<strong>Claude Code, Cursor, Codex 커뮤니티를 위해 정성껏 제작되었습니다.</strong>
|
||||||
|
</div>
|
||||||
333
README.md
@@ -1,10 +1,23 @@
|
|||||||
<div align="center">
|
<div align="center">
|
||||||
<img src="public/logo.svg" alt="Claude Code UI" width="64" height="64">
|
<img src="public/logo.svg" alt="CloudCLI UI" width="64" height="64">
|
||||||
<h1>Claude Code UI</h1>
|
<h1>Cloud CLI (aka Claude Code UI)</h1>
|
||||||
|
<p>A desktop and mobile UI for <a href="https://docs.anthropic.com/en/docs/claude-code">Claude Code</a>, <a href="https://docs.cursor.com/en/cli/overview">Cursor CLI</a>, <a href="https://developers.openai.com/codex">Codex</a>, and <a href="https://geminicli.com/">Gemini-CLI</a>.<br>Use it locally or remotely to view your active projects and sessions from everywhere.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://cloudcli.ai">CloudCLI Cloud</a> · <a href="https://cloudcli.ai/docs">Documentation</a> · <a href="https://discord.gg/buxwujPNRE">Discord</a> · <a href="https://github.com/siteboon/claudecodeui/issues">Bug Reports</a> · <a href="CONTRIBUTING.md">Contributing</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
A desktop and mobile UI for [Claude Code](https://docs.anthropic.com/en/docs/claude-code), and [Cursor CLI](https://docs.cursor.com/en/cli/overview). You can use it locally or remotely to view your active projects and sessions in Claude Code or Cursor and make changes to them from everywhere (mobile or desktop). This gives you a proper interface that works everywhere. Supports models including **Claude Sonnet 4**, **Opus 4.1**, and **GPT-5**
|
<p align="center">
|
||||||
|
<a href="https://cloudcli.ai"><img src="https://img.shields.io/badge/☁️_CloudCLI_Cloud-Try_Now-0066FF?style=for-the-badge" alt="CloudCLI Cloud"></a>
|
||||||
|
<a href="https://discord.gg/buxwujPNRE"><img src="https://img.shields.io/badge/Discord-Join%20Community-5865F2?style=for-the-badge&logo=discord&logoColor=white" alt="Join our Discord"></a>
|
||||||
|
<br><br>
|
||||||
|
<a href="https://trendshift.io/repositories/15586" target="_blank"><img src="https://trendshift.io/api/badge/repositories/15586" alt="siteboon%2Fclaudecodeui | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div align="right"><i><b>English</b> · <a href="./README.ru.md">Русский</a> · <a href="./README.de.md">Deutsch</a> · <a href="./README.ko.md">한국어</a> · <a href="./README.zh-CN.md">中文</a> · <a href="./README.ja.md">日本語</a> · <a href="./README.tr.md">Türkçe</a></i></div>
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Screenshots
|
## Screenshots
|
||||||
|
|
||||||
@@ -30,7 +43,7 @@ A desktop and mobile UI for [Claude Code](https://docs.anthropic.com/en/docs/cla
|
|||||||
<h3>CLI Selection</h3>
|
<h3>CLI Selection</h3>
|
||||||
<img src="public/screenshots/cli-selection.png" alt="CLI Selection" width="400">
|
<img src="public/screenshots/cli-selection.png" alt="CLI Selection" width="400">
|
||||||
<br>
|
<br>
|
||||||
<em>Select between Claude Code and Cursor CLI</em>
|
<em>Select between Claude Code, Gemini, Cursor CLI and Codex</em>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@@ -41,105 +54,82 @@ A desktop and mobile UI for [Claude Code](https://docs.anthropic.com/en/docs/cla
|
|||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- **Responsive Design** - Works seamlessly across desktop, tablet, and mobile so you can also use Claude Code from mobile
|
- **Responsive Design** - Works seamlessly across desktop, tablet, and mobile so you can also use Agents from mobile
|
||||||
- **Interactive Chat Interface** - Built-in chat interface for seamless communication with Claude Code or Cursor
|
- **Interactive Chat Interface** - Built-in chat interface for seamless communication with the Agents
|
||||||
- **Integrated Shell Terminal** - Direct access to Claude Code or Cursor CLI through built-in shell functionality
|
- **Integrated Shell Terminal** - Direct access to the Agents CLI through built-in shell functionality
|
||||||
- **File Explorer** - Interactive file tree with syntax highlighting and live editing
|
- **File Explorer** - Interactive file tree with syntax highlighting and live editing
|
||||||
- **Git Explorer** - View, stage and commit your changes. You can also switch branches
|
- **Git Explorer** - View, stage and commit your changes. You can also switch branches
|
||||||
- **Session Management** - Resume conversations, manage multiple sessions, and track history
|
- **Session Management** - Resume conversations, manage multiple sessions, and track history
|
||||||
|
- **Plugin System** - Extend CloudCLI with custom plugins — add new tabs, backend services, and integrations. [Build your own →](https://github.com/cloudcli-ai/cloudcli-plugin-starter)
|
||||||
- **TaskMaster AI Integration** *(Optional)* - Advanced project management with AI-powered task planning, PRD parsing, and workflow automation
|
- **TaskMaster AI Integration** *(Optional)* - Advanced project management with AI-powered task planning, PRD parsing, and workflow automation
|
||||||
- **Model Compatibility** - Works with Claude Sonnet 4, Opus 4.1, and GPT-5
|
- **Model Compatibility** - Works with Claude, GPT, and Gemini model families (see [`shared/modelConstants.js`](shared/modelConstants.js) for the full list of supported models)
|
||||||
|
|
||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
### Prerequisites
|
### CloudCLI Cloud (Recommended)
|
||||||
|
|
||||||
- [Node.js](https://nodejs.org/) v20 or higher
|
The fastest way to get started — no local setup required. Get a fully managed, containerized development environment accessible from the web, mobile app, API, or your favorite IDE.
|
||||||
- [Claude Code CLI](https://docs.anthropic.com/en/docs/claude-code) installed and configured, and/or
|
|
||||||
- [Cursor CLI](https://docs.cursor.com/en/cli/overview) installed and configured
|
|
||||||
|
|
||||||
### One-click Operation (Recommended)
|
**[Get started with CloudCLI Cloud](https://cloudcli.ai)**
|
||||||
|
|
||||||
No installation required, direct operation:
|
|
||||||
|
|
||||||
```bash
|
### Self-Hosted (Open source)
|
||||||
npx @siteboon/claude-code-ui
|
|
||||||
```
|
|
||||||
|
|
||||||
The server will start and be accessible at `http://localhost:3001` (or your configured PORT).
|
#### npm
|
||||||
|
|
||||||
**To restart**: Simply run the same `npx` command again after stopping the server (Ctrl+C or Cmd+C).
|
Try CloudCLI UI instantly with **npx** (requires **Node.js** v22+):
|
||||||
|
|
||||||
### Global Installation (For Regular Use)
|
|
||||||
|
|
||||||
For frequent use, install globally once:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm install -g @siteboon/claude-code-ui
|
|
||||||
```
|
|
||||||
|
|
||||||
Then start with a simple command:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
claude-code-ui
|
|
||||||
```
|
|
||||||
|
|
||||||
**Benefits**:
|
|
||||||
- Faster startup (no download/cache check)
|
|
||||||
- Simple command to remember
|
|
||||||
- Same experience every time
|
|
||||||
|
|
||||||
**To restart**: Stop with Ctrl+C and run `claude-code-ui` again.
|
|
||||||
|
|
||||||
### Run as Background Service (Optional)
|
|
||||||
|
|
||||||
To keep the server running in the background, use PM2:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Install PM2 globally (one-time)
|
|
||||||
npm install -g pm2
|
|
||||||
|
|
||||||
# Start the server
|
|
||||||
pm2 start claude-code-ui --name "claude-ui"
|
|
||||||
|
|
||||||
# Manage the service
|
|
||||||
pm2 list # View status
|
|
||||||
pm2 restart claude-ui # Restart
|
|
||||||
pm2 stop claude-ui # Stop
|
|
||||||
pm2 logs claude-ui # View logs
|
|
||||||
pm2 startup # Auto-start on system boot
|
|
||||||
```
|
|
||||||
|
|
||||||
### Local Development Installation
|
|
||||||
|
|
||||||
1. **Clone the repository:**
|
|
||||||
```bash
|
|
||||||
git clone https://github.com/siteboon/claudecodeui.git
|
|
||||||
cd claudecodeui
|
|
||||||
```
|
|
||||||
|
|
||||||
2. **Install dependencies:**
|
|
||||||
```bash
|
|
||||||
npm install
|
|
||||||
```
|
|
||||||
|
|
||||||
3. **Configure environment:**
|
|
||||||
```bash
|
|
||||||
cp .env.example .env
|
|
||||||
# Edit .env with your preferred settings
|
|
||||||
```
|
|
||||||
|
|
||||||
4. **Start the application:**
|
|
||||||
```bash
|
|
||||||
# Development mode (with hot reload)
|
|
||||||
npm run dev
|
|
||||||
|
|
||||||
```
|
```
|
||||||
The application will start at the port you specified in your .env
|
npx @cloudcli-ai/cloudcli
|
||||||
|
```
|
||||||
|
|
||||||
5. **Open your browser:**
|
Or install **globally** for regular use:
|
||||||
- Development: `http://localhost:3001`
|
|
||||||
|
```
|
||||||
|
npm install -g @cloudcli-ai/cloudcli
|
||||||
|
cloudcli
|
||||||
|
```
|
||||||
|
|
||||||
|
Open `http://localhost:3001` — all your existing sessions are discovered automatically.
|
||||||
|
|
||||||
|
Visit the **[documentation →](https://cloudcli.ai/docs)** for full configuration options, PM2, remote server setup and more.
|
||||||
|
|
||||||
|
#### Docker Sandboxes (Experimental)
|
||||||
|
|
||||||
|
Run agents in isolated sandboxes with hypervisor-level isolation. Starts Claude Code by default. Requires the [`sbx` CLI](https://docs.docker.com/ai/sandboxes/get-started/).
|
||||||
|
|
||||||
|
```
|
||||||
|
npx @cloudcli-ai/cloudcli@latest sandbox ~/my-project
|
||||||
|
```
|
||||||
|
|
||||||
|
Supports Claude Code, Codex, and Gemini CLI. See the [sandbox docs](docker/) for setup and advanced options.
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Which option is right for you?
|
||||||
|
|
||||||
|
CloudCLI UI is the open source UI layer that powers CloudCLI Cloud. You can self-host it on your own machine, run it in a Docker sandbox for isolation, or use CloudCLI Cloud for a fully managed environment.
|
||||||
|
|
||||||
|
| | Self-Hosted (npm) | Self-Hosted (Docker Sandbox) *(Experimental)* | CloudCLI Cloud |
|
||||||
|
|---|---|---|---|
|
||||||
|
| **Best for** | Local agent sessions on your own machine | Isolated agents with web/mobile IDE | Teams who want agents in the cloud |
|
||||||
|
| **How you access it** | Browser via `[yourip]:port` | Browser via `localhost:port` | Browser, any IDE, REST API, n8n |
|
||||||
|
| **Setup** | `npx @cloudcli-ai/cloudcli` | `npx @cloudcli-ai/cloudcli@latest sandbox ~/project` | No setup required |
|
||||||
|
| **Isolation** | Runs on your host | Hypervisor-level sandbox (microVM) | Full cloud isolation |
|
||||||
|
| **Machine needs to stay on** | Yes | Yes | No |
|
||||||
|
| **Mobile access** | Any browser on your network | Any browser on your network | Any device, native app coming |
|
||||||
|
| **Agents supported** | Claude Code, Cursor CLI, Codex, Gemini CLI | Claude Code, Codex, Gemini CLI | Claude Code, Cursor CLI, Codex, Gemini CLI |
|
||||||
|
| **File explorer and Git** | Yes | Yes | Yes |
|
||||||
|
| **MCP configuration** | Synced with `~/.claude` | Managed via UI | Managed via UI |
|
||||||
|
| **REST API** | Yes | Yes | Yes |
|
||||||
|
| **Team sharing** | No | No | Yes |
|
||||||
|
| **Platform cost** | Free, open source | Free, open source | Starts at $7/month |
|
||||||
|
|
||||||
|
> All options use your own AI subscriptions (Claude, Cursor, etc.) — CloudCLI provides the environment, not the AI.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Security & Tools Configuration
|
## Security & Tools Configuration
|
||||||
|
|
||||||
@@ -150,8 +140,8 @@ The application will start at the port you specified in your .env
|
|||||||
To use Claude Code's full functionality, you'll need to manually enable tools:
|
To use Claude Code's full functionality, you'll need to manually enable tools:
|
||||||
|
|
||||||
1. **Open Tools Settings** - Click the gear icon in the sidebar
|
1. **Open Tools Settings** - Click the gear icon in the sidebar
|
||||||
3. **Enable Selectively** - Turn on only the tools you need
|
2. **Enable Selectively** - Turn on only the tools you need
|
||||||
4. **Apply Settings** - Your preferences are saved locally
|
3. **Apply Settings** - Your preferences are saved locally
|
||||||
|
|
||||||
<div align="center">
|
<div align="center">
|
||||||
|
|
||||||
@@ -162,166 +152,101 @@ To use Claude Code's full functionality, you'll need to manually enable tools:
|
|||||||
|
|
||||||
**Recommended approach**: Start with basic tools enabled and add more as needed. You can always adjust these settings later.
|
**Recommended approach**: Start with basic tools enabled and add more as needed. You can always adjust these settings later.
|
||||||
|
|
||||||
## TaskMaster AI Integration *(Optional)*
|
---
|
||||||
|
|
||||||
Claude Code UI supports **[TaskMaster AI](https://github.com/eyaltoledano/claude-task-master)** (aka claude-task-master) integration for advanced project management and AI-powered task planning.
|
## Plugins
|
||||||
|
|
||||||
It provides
|
CloudCLI has a plugin system that lets you add custom tabs with their own frontend UI and optional Node.js backend. Install plugins from git repos directly in **Settings > Plugins**, or build your own.
|
||||||
- AI-powered task generation from PRDs (Product Requirements Documents)
|
|
||||||
- Smart task breakdown and dependency management
|
|
||||||
- Visual task boards and progress tracking
|
|
||||||
|
|
||||||
**Setup & Documentation**: Visit the [TaskMaster AI GitHub repository](https://github.com/eyaltoledano/claude-task-master) for installation instructions, configuration guides, and usage examples.
|
### Available Plugins
|
||||||
After installing it you should be able to enable it from the Settings
|
|
||||||
|
|
||||||
|
| Plugin | Description |
|
||||||
|
|---|---|
|
||||||
|
| **[Project Stats](https://github.com/cloudcli-ai/cloudcli-plugin-starter)** | Shows file counts, lines of code, file-type breakdown, largest files, and recently modified files for your current project |
|
||||||
|
| **[Web Terminal](https://github.com/cloudcli-ai/cloudcli-plugin-terminal)** | Full xterm.js terminal with multi-tab support|
|
||||||
|
| **[CloudCLI Scheduler](https://github.com/grostim/cloudcli-cron)** | Create workspace-scoped scheduled prompts and execute them through a local CLI such as Codex, Claude Code, or Gemini CLI|
|
||||||
|
### Build Your Own
|
||||||
|
|
||||||
## Usage Guide
|
**[Plugin Starter Template →](https://github.com/cloudcli-ai/cloudcli-plugin-starter)** — fork this repo to create your own plugin. It includes a working example with frontend rendering, live context updates, and RPC communication to a backend server.
|
||||||
|
|
||||||
### Core Features
|
**[Plugin Documentation →](https://cloudcli.ai/docs/plugin-overview)** — full guide to the plugin API, manifest format, security model, and more.
|
||||||
|
|
||||||
#### Project Management
|
---
|
||||||
The UI automatically discovers Claude Code projects from `~/.claude/projects/` and provides:
|
## FAQ
|
||||||
- **Visual Project Browser** - All available projects with metadata and session counts
|
|
||||||
- **Project Actions** - Rename, delete, and organize projects
|
|
||||||
- **Smart Navigation** - Quick access to recent projects and sessions
|
|
||||||
- **MCP support** - Add your own MCP servers through the UI
|
|
||||||
|
|
||||||
#### Chat Interface
|
<details>
|
||||||
- **Use responsive chat or Claude Code/Cursor CLI** - You can either use the adapted chat interface or use the shell button to connect to your selected CLI.
|
<summary>How is this different from Claude Code Remote Control?</summary>
|
||||||
- **Real-time Communication** - Stream responses from Claude with WebSocket connection
|
|
||||||
- **Session Management** - Resume previous conversations or start fresh sessions
|
|
||||||
- **Message History** - Complete conversation history with timestamps and metadata
|
|
||||||
- **Multi-format Support** - Text, code blocks, and file references
|
|
||||||
|
|
||||||
#### File Explorer & Editor
|
Claude Code Remote Control lets you send messages to a session already running in your local terminal. Your machine has to stay on, your terminal has to stay open, and sessions time out after roughly 10 minutes without a network connection.
|
||||||
- **Interactive File Tree** - Browse project structure with expand/collapse navigation
|
|
||||||
- **Live File Editing** - Read, modify, and save files directly in the interface
|
|
||||||
- **Syntax Highlighting** - Support for multiple programming languages
|
|
||||||
- **File Operations** - Create, rename, delete files and directories
|
|
||||||
|
|
||||||
#### Git Explorer
|
CloudCLI UI and CloudCLI Cloud extend Claude Code rather than sit alongside it — your MCP servers, permissions, settings, and sessions are the exact same ones Claude Code uses natively. Nothing is duplicated or managed separately.
|
||||||
|
|
||||||
|
Here's what that means in practice:
|
||||||
|
|
||||||
#### TaskMaster AI Integration *(Optional)*
|
- **All your sessions, not just one** — CloudCLI UI auto-discovers every session from your `~/.claude` folder. Remote Control only exposes the single active session to make it available in the Claude mobile app.
|
||||||
- **Visual Task Board** - Kanban-style interface for managing development tasks
|
- **Your settings are your settings** — MCP servers, tool permissions, and project config you change in CloudCLI UI are written directly to your Claude Code config and take effect immediately, and vice versa.
|
||||||
- **PRD Parser** - Create Product Requirements Documents and parse them into structured tasks
|
- **Works with more agents** — Claude Code, Cursor CLI, Codex, and Gemini CLI, not just Claude Code.
|
||||||
- **Progress Tracking** - Real-time status updates and completion tracking
|
- **Full UI, not just a chat window** — file explorer, Git integration, MCP management, and a shell terminal are all built in.
|
||||||
|
- **CloudCLI Cloud runs in the cloud** — close your laptop, the agent keeps running. No terminal to babysit, no machine to keep awake.
|
||||||
|
|
||||||
#### Session Management
|
</details>
|
||||||
- **Session Persistence** - All conversations automatically saved
|
|
||||||
- **Session Organization** - Group sessions by project and timestamp
|
|
||||||
- **Session Actions** - Rename, delete, and export conversation history
|
|
||||||
- **Cross-device Sync** - Access sessions from any device
|
|
||||||
|
|
||||||
### Mobile App
|
<details>
|
||||||
- **Responsive Design** - Optimized for all screen sizes
|
<summary>Do I need to pay for an AI subscription separately?</summary>
|
||||||
- **Touch-friendly Interface** - Swipe gestures and touch navigation
|
|
||||||
- **Mobile Navigation** - Bottom tab bar for easy thumb navigation
|
|
||||||
- **Adaptive Layout** - Collapsible sidebar and smart content prioritization
|
|
||||||
- **Add shortcut to Home Screen** - Add a shortcut to your home screen and the app will behave like a PWA
|
|
||||||
|
|
||||||
## Architecture
|
Yes. CloudCLI provides the environment, not the AI. You bring your own Claude, Cursor, Codex, or Gemini subscription. CloudCLI Cloud starts at $7/month for the hosted environment on top of that.
|
||||||
|
|
||||||
### System Overview
|
</details>
|
||||||
|
|
||||||
```
|
<details>
|
||||||
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
|
<summary>Can I use CloudCLI UI on my phone?</summary>
|
||||||
│ Frontend │ │ Backend │ │ Claude CLI │
|
|
||||||
│ (React/Vite) │◄──►│ (Express/WS) │◄──►│ Integration │
|
|
||||||
└─────────────────┘ └─────────────────┘ └─────────────────┘
|
|
||||||
```
|
|
||||||
|
|
||||||
### Backend (Node.js + Express)
|
Yes. For self-hosted, run the server on your machine and open `[yourip]:port` in any browser on your network. For CloudCLI Cloud, open it from any device — no VPN, no port forwarding, no setup. A native app is also in the works.
|
||||||
- **Express Server** - RESTful API with static file serving
|
|
||||||
- **WebSocket Server** - Communication for chats and project refresh
|
|
||||||
- **CLI Integration (Claude Code / Cursor)** - Process spawning and management
|
|
||||||
- **Session Management** - JSONL parsing and conversation persistence
|
|
||||||
- **File System API** - Exposing file browser for projects
|
|
||||||
|
|
||||||
### Frontend (React + Vite)
|
</details>
|
||||||
- **React 18** - Modern component architecture with hooks
|
|
||||||
- **CodeMirror** - Advanced code editor with syntax highlighting
|
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Will changes I make in the UI affect my local Claude Code setup?</summary>
|
||||||
|
|
||||||
|
Yes, for self-hosted. CloudCLI UI reads from and writes to the same `~/.claude` config that Claude Code uses natively. MCP servers you add via the UI show up in Claude Code immediately and vice versa.
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
### Contributing
|
## Community & Support
|
||||||
|
|
||||||
We welcome contributions! Please follow these guidelines:
|
|
||||||
|
|
||||||
#### Getting Started
|
|
||||||
1. **Fork** the repository
|
|
||||||
2. **Clone** your fork: `git clone <your-fork-url>`
|
|
||||||
3. **Install** dependencies: `npm install`
|
|
||||||
4. **Create** a feature branch: `git checkout -b feature/amazing-feature`
|
|
||||||
|
|
||||||
#### Development Process
|
|
||||||
1. **Make your changes** following the existing code style
|
|
||||||
2. **Test thoroughly** - ensure all features work correctly
|
|
||||||
3. **Run quality checks**: `npm run lint && npm run format`
|
|
||||||
4. **Commit** with descriptive messages following [Conventional Commits](https://conventionalcommits.org/)
|
|
||||||
5. **Push** to your branch: `git push origin feature/amazing-feature`
|
|
||||||
6. **Submit** a Pull Request with:
|
|
||||||
- Clear description of changes
|
|
||||||
- Screenshots for UI changes
|
|
||||||
- Test results if applicable
|
|
||||||
|
|
||||||
#### What to Contribute
|
|
||||||
- **Bug fixes** - Help us improve stability
|
|
||||||
- **New features** - Enhance functionality (discuss in issues first)
|
|
||||||
- **Documentation** - Improve guides and API docs
|
|
||||||
- **UI/UX improvements** - Better user experience
|
|
||||||
- **Performance optimizations** - Make it faster
|
|
||||||
|
|
||||||
## Troubleshooting
|
|
||||||
|
|
||||||
### Common Issues & Solutions
|
|
||||||
|
|
||||||
|
|
||||||
#### "No Claude projects found"
|
|
||||||
**Problem**: The UI shows no projects or empty project list
|
|
||||||
**Solutions**:
|
|
||||||
- Ensure [Claude CLI](https://docs.anthropic.com/en/docs/claude-code) is properly installed
|
|
||||||
- Run `claude` command in at least one project directory to initialize
|
|
||||||
- Verify `~/.claude/projects/` directory exists and has proper permissions
|
|
||||||
|
|
||||||
#### File Explorer Issues
|
|
||||||
**Problem**: Files not loading, permission errors, empty directories
|
|
||||||
**Solutions**:
|
|
||||||
- Check project directory permissions (`ls -la` in terminal)
|
|
||||||
- Verify the project path exists and is accessible
|
|
||||||
- Review server console logs for detailed error messages
|
|
||||||
- Ensure you're not trying to access system directories outside project scope
|
|
||||||
|
|
||||||
|
- **[Documentation](https://cloudcli.ai/docs)** — installation, configuration, features, and troubleshooting
|
||||||
|
- **[Discord](https://discord.gg/buxwujPNRE)** — get help and connect with other users
|
||||||
|
- **[GitHub Issues](https://github.com/siteboon/claudecodeui/issues)** — bug reports and feature requests
|
||||||
|
- **[Contributing Guide](CONTRIBUTING.md)** — how to contribute to the project
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
GNU General Public License v3.0 - see [LICENSE](LICENSE) file for details.
|
GNU Affero General Public License v3.0 or later (AGPL-3.0-or-later) — see [LICENSE](LICENSE) for the full text, including additional terms under Section 7.
|
||||||
|
|
||||||
This project is open source and free to use, modify, and distribute under the GPL v3 license.
|
This project is open source and free to use, modify, and distribute under the AGPL-3.0-or-later license. If you modify this software and run it as a network service, you must make your modified source code available to users of that service.
|
||||||
|
|
||||||
|
CloudCLI UI - (https://cloudcli.ai).
|
||||||
|
|
||||||
## Acknowledgments
|
## Acknowledgments
|
||||||
|
|
||||||
### Built With
|
### Built With
|
||||||
- **[Claude Code](https://docs.anthropic.com/en/docs/claude-code)** - Anthropic's official CLI
|
- **[Claude Code](https://docs.anthropic.com/en/docs/claude-code)** - Anthropic's official CLI
|
||||||
|
- **[Cursor CLI](https://docs.cursor.com/en/cli/overview)** - Cursor's official CLI
|
||||||
|
- **[Codex](https://developers.openai.com/codex)** - OpenAI Codex
|
||||||
|
- **[Gemini-CLI](https://geminicli.com/)** - Google Gemini CLI
|
||||||
- **[React](https://react.dev/)** - User interface library
|
- **[React](https://react.dev/)** - User interface library
|
||||||
- **[Vite](https://vitejs.dev/)** - Fast build tool and dev server
|
- **[Vite](https://vitejs.dev/)** - Fast build tool and dev server
|
||||||
- **[Tailwind CSS](https://tailwindcss.com/)** - Utility-first CSS framework
|
- **[Tailwind CSS](https://tailwindcss.com/)** - Utility-first CSS framework
|
||||||
- **[CodeMirror](https://codemirror.net/)** - Advanced code editor
|
- **[CodeMirror](https://codemirror.net/)** - Advanced code editor
|
||||||
- **[TaskMaster AI](https://github.com/eyaltoledano/claude-task-master)** *(Optional)* - AI-powered project management and task planning
|
- **[TaskMaster AI](https://github.com/eyaltoledano/claude-task-master)** *(Optional)* - AI-powered project management and task planning
|
||||||
|
|
||||||
## Support & Community
|
|
||||||
|
|
||||||
### Stay Updated
|
|
||||||
- **Star** this repository to show support
|
|
||||||
- **Watch** for updates and new releases
|
|
||||||
- **Follow** the project for announcements
|
|
||||||
|
|
||||||
### Sponsors
|
### Sponsors
|
||||||
- [Siteboon - AI powered website builder](https://siteboon.ai)
|
- [Siteboon - AI powered website builder](https://siteboon.ai)
|
||||||
---
|
---
|
||||||
|
|
||||||
<div align="center">
|
<div align="center">
|
||||||
<strong>Made with care for the Claude Code community.</strong>
|
<strong>Made with care for the Claude Code, Cursor and Codex community.</strong>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
250
README.ru.md
Normal file
@@ -0,0 +1,250 @@
|
|||||||
|
<div align="center">
|
||||||
|
<img src="public/logo.svg" alt="CloudCLI UI" width="64" height="64">
|
||||||
|
<h1>Cloud CLI (aka Claude Code UI)</h1>
|
||||||
|
<p>Десктопный и мобильный UI для <a href="https://docs.anthropic.com/en/docs/claude-code">Claude Code</a>, <a href="https://docs.cursor.com/en/cli/overview">Cursor CLI</a>, <a href="https://developers.openai.com/codex">Codex</a> и <a href="https://geminicli.com/">Gemini-CLI</a>.<br>Используйте локально или удалённо, чтобы просматривать активные проекты и сессии отовсюду.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://cloudcli.ai">CloudCLI Cloud</a> · <a href="https://cloudcli.ai/docs">Документация</a> · <a href="https://discord.gg/buxwujPNRE">Discord</a> · <a href="https://github.com/siteboon/claudecodeui/issues">Сообщить об ошибке</a> · <a href="CONTRIBUTING.md">Участие в разработке</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://cloudcli.ai"><img src="https://img.shields.io/badge/☁️_CloudCLI_Cloud-Try_Now-0066FF?style=for-the-badge" alt="CloudCLI Cloud"></a>
|
||||||
|
<a href="https://discord.gg/buxwujPNRE"><img src="https://img.shields.io/badge/Discord-Join%20Community-5865F2?style=for-the-badge&logo=discord&logoColor=white" alt="Join our Discord"></a>
|
||||||
|
<br><br>
|
||||||
|
<a href="https://trendshift.io/repositories/15586" target="_blank"><img src="https://trendshift.io/api/badge/repositories/15586" alt="siteboon%2Fclaudecodeui | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div align="right"><i><a href="./README.md">English</a> · <b>Русский</b> · <a href="./README.de.md">Deutsch</a> · <a href="./README.ko.md">한국어</a> · <a href="./README.zh-CN.md">中文</a> · <a href="./README.ja.md">日本語</a> · <a href="./README.tr.md">Türkçe</a></i></div>
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Скриншоты
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td align="center">
|
||||||
|
<h3>Версия для десктопа</h3>
|
||||||
|
<img src="public/screenshots/desktop-main.png" alt="Desktop Interface" width="400">
|
||||||
|
<br>
|
||||||
|
<em>Основной интерфейс с обзором проекта и чатом</em>
|
||||||
|
</td>
|
||||||
|
<td align="center">
|
||||||
|
<h3>Мобильный режим</h3>
|
||||||
|
<img src="public/screenshots/mobile-chat.png" alt="Mobile Interface" width="250">
|
||||||
|
<br>
|
||||||
|
<em>Адаптивный мобильный дизайн с сенсорной навигацией</em>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="center" colspan="2">
|
||||||
|
<h3>Выбор CLI</h3>
|
||||||
|
<img src="public/screenshots/cli-selection.png" alt="CLI Selection" width="400">
|
||||||
|
<br>
|
||||||
|
<em>Выбирайте между Claude Code, Gemini, Cursor CLI и Codex</em>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
## Возможности
|
||||||
|
|
||||||
|
- **Адаптивный дизайн** - одинаково хорошо работает на десктопе, планшете и телефоне, поэтому можно пользоваться агентами и с мобильных устройств
|
||||||
|
- **Интерактивный чат-интерфейс** - встроенный чат для бесшовного общения с агентами
|
||||||
|
- **Интегрированный shell-терминал** - прямой доступ к CLI агентов через встроенную оболочку
|
||||||
|
- **Проводник файлов** - интерактивное дерево файлов с подсветкой синтаксиса и редактированием в реальном времени
|
||||||
|
- **Git Explorer** - просмотр, stage и commit изменений. Также можно переключать ветки
|
||||||
|
- **Управление сессиями** - возобновляйте диалоги, управляйте несколькими сессиями и отслеживайте историю
|
||||||
|
- **Система плагинов** - расширяйте CloudCLI кастомными плагинами — добавляйте новые вкладки, бэкенд-сервисы и интеграции. [Создать свой →](https://github.com/cloudcli-ai/cloudcli-plugin-starter)
|
||||||
|
- **Интеграция с TaskMaster AI** *(опционально)* - продвинутое управление проектами с планированием задач на базе AI, разбором PRD и автоматизацией workflow
|
||||||
|
- **Совместимость с моделями** - работает с семействами моделей Claude, GPT и Gemini (см. [`shared/modelConstants.js`](shared/modelConstants.js) для полного списка поддерживаемых моделей)
|
||||||
|
|
||||||
|
|
||||||
|
## Быстрый старт
|
||||||
|
|
||||||
|
### CloudCLI Cloud (рекомендуется)
|
||||||
|
|
||||||
|
Самый быстрый способ начать — локальная настройка не требуется. Получите полностью управляемую контейнеризированную среду разработки с доступом из веба, мобильного приложения, API или вашей любимой IDE.
|
||||||
|
|
||||||
|
**[Начать с CloudCLI Cloud](https://cloudcli.ai)**
|
||||||
|
|
||||||
|
|
||||||
|
### Self-Hosted (Open source)
|
||||||
|
|
||||||
|
#### npm
|
||||||
|
|
||||||
|
Попробовать CloudCLI UI можно сразу через **npx** (требуется **Node.js** v22+):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npx @cloudcli-ai/cloudcli
|
||||||
|
```
|
||||||
|
|
||||||
|
Или установить **глобально** для регулярного использования:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install -g @cloudcli-ai/cloudcli
|
||||||
|
cloudcli
|
||||||
|
```
|
||||||
|
|
||||||
|
Откройте `http://localhost:3001` — все ваши существующие сессии будут обнаружены автоматически.
|
||||||
|
|
||||||
|
Посетите **[документацию →](https://cloudcli.ai/docs)**, чтобы узнать про дополнительные варианты конфигурации, PM2, настройку удалённого сервера и многое другое.
|
||||||
|
|
||||||
|
#### Docker Sandboxes (Экспериментально)
|
||||||
|
|
||||||
|
Запускайте агентов в изолированных песочницах с гипервизорной изоляцией. По умолчанию запускается Claude Code. Требуется [`sbx` CLI](https://docs.docker.com/ai/sandboxes/get-started/).
|
||||||
|
|
||||||
|
```
|
||||||
|
npx @cloudcli-ai/cloudcli@latest sandbox ~/my-project
|
||||||
|
```
|
||||||
|
|
||||||
|
Поддерживаются Claude Code, Codex и Gemini CLI. Подробнее в [документации sandbox](docker/).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Какой вариант подходит вам?
|
||||||
|
|
||||||
|
CloudCLI UI — это open source UI-слой, на котором построен CloudCLI Cloud. Вы можете развернуть его на своей машине или использовать CloudCLI Cloud, который добавляет полностью управляемую облачную среду, командные функции и более глубокие интеграции.
|
||||||
|
|
||||||
|
| | CloudCLI UI (Self-hosted) | CloudCLI Cloud |
|
||||||
|
|---|---|---|
|
||||||
|
| **Лучше всего подходит для** | Разработчиков, которым нужен полноценный UI для локальных агентских сессий на своей машине | Команд и разработчиков, которым нужны агенты в облаке с доступом откуда угодно |
|
||||||
|
| **Как вы получаете доступ** | Браузер через `[yourip]:port` | Браузер, любая IDE, REST API, n8n |
|
||||||
|
| **Настройка** | `npx @cloudcli-ai/cloudcli` | Настройка не требуется |
|
||||||
|
| **Машина должна оставаться включённой** | Да | Нет |
|
||||||
|
| **Доступ с мобильных устройств** | Любой браузер в вашей сети | Любое устройство, нативное приложение в разработке |
|
||||||
|
| **Доступные сессии** | Все сессии автоматически обнаруживаются из `~/.claude` | Все сессии внутри вашей облачной среды |
|
||||||
|
| **Поддерживаемые агенты** | Claude Code, Cursor CLI, Codex, Gemini CLI | Claude Code, Cursor CLI, Codex, Gemini CLI |
|
||||||
|
| **Проводник файлов и Git** | Да, встроены в UI | Да, встроены в UI |
|
||||||
|
| **Конфигурация MCP** | Управляется через UI, синхронизируется с вашим локальным конфигом `~/.claude` | Управляется через UI |
|
||||||
|
| **Доступ из IDE** | Ваша локальная IDE | Любая IDE, подключенная к вашей облачной среде |
|
||||||
|
| **REST API** | Да | Да |
|
||||||
|
| **n8n node** | Нет | Да |
|
||||||
|
| **Совместная работа** | Нет | Да |
|
||||||
|
| **Стоимость платформы** | Бесплатно, open source | От $7/месяц |
|
||||||
|
|
||||||
|
> В обоих вариантах используются ваши собственные AI-подписки (Claude, Cursor и т.д.) — CloudCLI предоставляет среду, а не сам AI.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Безопасность и конфигурация инструментов
|
||||||
|
|
||||||
|
**🔒 Важное примечание**: все инструменты Claude Code **по умолчанию отключены**. Это предотвращает автоматический запуск потенциально опасных операций.
|
||||||
|
|
||||||
|
### Включение инструментов
|
||||||
|
|
||||||
|
Чтобы использовать всю функциональность Claude Code, вам нужно вручную включить инструменты:
|
||||||
|
|
||||||
|
1. **Откройте настройки инструментов** - нажмите на иконку шестерёнки в боковой панели
|
||||||
|
2. **Включайте выборочно** - активируйте только те инструменты, которые вам нужны
|
||||||
|
3. **Примените настройки** - ваши предпочтения сохраняются локально
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
|
||||||
|

|
||||||
|
*Интерфейс настройки инструментов — включайте только то, что вам нужно*
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
**Рекомендуемый подход**: начните с базовых инструментов и добавляйте остальные по мере необходимости. Эти настройки всегда можно изменить позже.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Плагины
|
||||||
|
|
||||||
|
У CloudCLI есть система плагинов, которая позволяет добавлять кастомные вкладки со своим frontend UI и (опционально) Node.js бэкендом. Устанавливайте плагины напрямую из git-репозиториев в **Settings > Plugins** или создавайте свои.
|
||||||
|
|
||||||
|
### Доступные плагины
|
||||||
|
|
||||||
|
| Плагин | Описание |
|
||||||
|
|---|---|
|
||||||
|
| **[Project Stats](https://github.com/cloudcli-ai/cloudcli-plugin-starter)** | Показывает количество файлов, строки кода, разбивку по типам файлов, самые большие файлы и недавно изменённые файлы для текущего проекта |
|
||||||
|
|
||||||
|
### Создать свой
|
||||||
|
|
||||||
|
**[Plugin Starter Template →](https://github.com/cloudcli-ai/cloudcli-plugin-starter)** — сделайте форк этого репозитория, чтобы создать свой плагин. В шаблоне есть рабочий пример с рендерингом на фронтенде, live-обновлением контекста и RPC-коммуникацией с бэкенд-сервером.
|
||||||
|
|
||||||
|
**[Plugin Documentation →](https://cloudcli.ai/docs/plugin-overview)** — полный гайд по plugin API, формату манифеста, модели безопасности и другому.
|
||||||
|
|
||||||
|
---
|
||||||
|
## FAQ
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Чем это отличается от Claude Code Remote Control?</summary>
|
||||||
|
|
||||||
|
Claude Code Remote Control позволяет отправлять сообщения в сессию, которая уже запущена в вашем локальном терминале. Ваша машина должна оставаться включённой, терминал — открытым, а сессии завершаются примерно через 10 минут без сетевого соединения.
|
||||||
|
|
||||||
|
CloudCLI UI и CloudCLI Cloud расширяют Claude Code, а не работают рядом с ним — ваши MCP-серверы, разрешения, настройки и сессии остаются теми же самыми, что и в нативном Claude Code. Ничего не дублируется и не управляется отдельно.
|
||||||
|
|
||||||
|
Вот что это означает на практике:
|
||||||
|
|
||||||
|
- **Все ваши сессии, а не одна** — CloudCLI UI автоматически находит каждую сессию из папки `~/.claude`. Remote Control предоставляет только одну активную сессию, чтобы сделать её доступной в мобильном приложении Claude.
|
||||||
|
- **Ваши настройки — это ваши настройки** — MCP-серверы, права инструментов и конфигурация проекта, изменённые в CloudCLI UI, записываются напрямую в конфиг Claude Code и вступают в силу сразу же, и наоборот.
|
||||||
|
- **Работает с большим числом агентов** — Claude Code, Cursor CLI, Codex и Gemini CLI, а не только Claude Code.
|
||||||
|
- **Полноценный UI, а не просто окно чата** — проводник файлов, Git-интеграция, управление MCP и shell-терминал — всё встроено.
|
||||||
|
- **CloudCLI Cloud работает в облаке** — закройте ноутбук, и агент продолжит работать. Не нужно следить за терминалом и держать машину постоянно активной.
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Нужно ли отдельно платить за AI-подписку?</summary>
|
||||||
|
|
||||||
|
Да. CloudCLI предоставляет среду, а не сам AI. Вы приносите свою подписку Claude, Cursor, Codex или Gemini. CloudCLI Cloud начинается от $7/месяц за хостируемую среду поверх этого.
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Можно ли пользоваться CloudCLI UI с телефона?</summary>
|
||||||
|
|
||||||
|
Да. Для self-hosted запустите сервер на своей машине и откройте `[yourip]:port` в любом браузере в вашей сети. Для CloudCLI Cloud откройте сервис с любого устройства — без VPN, проброса портов и дополнительной настройки. Нативное приложение тоже в разработке.
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Повлияют ли изменения, сделанные в UI, на мой локальный Claude Code?</summary>
|
||||||
|
|
||||||
|
Да, в self-hosted режиме. CloudCLI UI читает и записывает тот же конфиг `~/.claude`, который Claude Code использует нативно. MCP-серверы, добавленные через UI, сразу появляются в Claude Code, и наоборот.
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Сообщество и поддержка
|
||||||
|
|
||||||
|
- **[Документация](https://cloudcli.ai/docs)** — установка, настройка, возможности и устранение неполадок
|
||||||
|
- **[Discord](https://discord.gg/buxwujPNRE)** — помощь и общение с другими пользователями
|
||||||
|
- **[GitHub Issues](https://github.com/siteboon/claudecodeui/issues)** — сообщения об ошибках и запросы новых функций
|
||||||
|
- **[Руководство для контрибьюторов](CONTRIBUTING.md)** — как участвовать в развитии проекта
|
||||||
|
|
||||||
|
## Лицензия
|
||||||
|
|
||||||
|
GNU General Public License v3.0 - подробности в файле [LICENSE](LICENSE).
|
||||||
|
|
||||||
|
Этот проект open source и бесплатен для использования, модификации и распространения в рамках лицензии GPL v3.
|
||||||
|
|
||||||
|
## Благодарности
|
||||||
|
|
||||||
|
### Используется
|
||||||
|
- **[Claude Code](https://docs.anthropic.com/en/docs/claude-code)** - официальный CLI от Anthropic
|
||||||
|
- **[Cursor CLI](https://docs.cursor.com/en/cli/overview)** - официальный CLI от Cursor
|
||||||
|
- **[Codex](https://developers.openai.com/codex)** - OpenAI Codex
|
||||||
|
- **[Gemini-CLI](https://geminicli.com/)** - Google Gemini CLI
|
||||||
|
- **[React](https://react.dev/)** - библиотека пользовательских интерфейсов
|
||||||
|
- **[Vite](https://vitejs.dev/)** - быстрый инструмент сборки и dev-сервер
|
||||||
|
- **[Tailwind CSS](https://tailwindcss.com/)** - utility-first CSS framework
|
||||||
|
- **[CodeMirror](https://codemirror.net/)** - продвинутый редактор кода
|
||||||
|
- **[TaskMaster AI](https://github.com/eyaltoledano/claude-task-master)** *(опционально)* - AI-управление проектами и планирование задач
|
||||||
|
|
||||||
|
|
||||||
|
### Спонсоры
|
||||||
|
- [Siteboon - AI powered website builder](https://siteboon.ai)
|
||||||
|
---
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
<strong>Сделано с заботой для сообщества Claude Code, Cursor и Codex.</strong>
|
||||||
|
</div>
|
||||||
252
README.tr.md
Normal file
@@ -0,0 +1,252 @@
|
|||||||
|
<div align="center">
|
||||||
|
<img src="public/logo.svg" alt="CloudCLI UI" width="64" height="64">
|
||||||
|
<h1>Cloud CLI (Claude Code UI olarak da bilinir)</h1>
|
||||||
|
<p><a href="https://docs.anthropic.com/en/docs/claude-code">Claude Code</a>, <a href="https://docs.cursor.com/en/cli/overview">Cursor CLI</a>, <a href="https://developers.openai.com/codex">Codex</a> ve <a href="https://geminicli.com/">Gemini-CLI</a> için masaüstü ve mobil arayüz.<br>Yerel ya da uzaktan kullanarak aktif projelerine ve oturumlarına her yerden erişebilirsin.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://cloudcli.ai">CloudCLI Cloud</a> · <a href="https://cloudcli.ai/docs">Dokümantasyon</a> · <a href="https://discord.gg/buxwujPNRE">Discord</a> · <a href="https://github.com/siteboon/claudecodeui/issues">Sorun Bildir</a> · <a href="CONTRIBUTING.md">Katkıda Bulun</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://cloudcli.ai"><img src="https://img.shields.io/badge/☁️_CloudCLI_Cloud-Hemen_Dene-0066FF?style=for-the-badge" alt="CloudCLI Cloud"></a>
|
||||||
|
<a href="https://discord.gg/buxwujPNRE"><img src="https://img.shields.io/badge/Discord-Toplulu%C4%9Fa%20Kat%C4%B1l-5865F2?style=for-the-badge&logo=discord&logoColor=white" alt="Discord'a Katıl"></a>
|
||||||
|
<br><br>
|
||||||
|
<a href="https://trendshift.io/repositories/15586" target="_blank"><img src="https://trendshift.io/api/badge/repositories/15586" alt="siteboon%2Fclaudecodeui | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div align="right"><i><a href="./README.md">English</a> · <a href="./README.ru.md">Русский</a> · <a href="./README.de.md">Deutsch</a> · <a href="./README.ko.md">한국어</a> · <a href="./README.zh-CN.md">中文</a> · <a href="./README.ja.md">日本語</a> · <b>Türkçe</b></i></div>
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Ekran Görüntüleri
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td align="center">
|
||||||
|
<h3>Masaüstü Görünümü</h3>
|
||||||
|
<img src="public/screenshots/desktop-main.png" alt="Masaüstü Arayüzü" width="400">
|
||||||
|
<br>
|
||||||
|
<em>Proje genel bakışı ve sohbeti gösteren ana arayüz</em>
|
||||||
|
</td>
|
||||||
|
<td align="center">
|
||||||
|
<h3>Mobil Deneyim</h3>
|
||||||
|
<img src="public/screenshots/mobile-chat.png" alt="Mobil Arayüz" width="250">
|
||||||
|
<br>
|
||||||
|
<em>Dokunma gezinmesiyle duyarlı mobil tasarım</em>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="center" colspan="2">
|
||||||
|
<h3>CLI Seçimi</h3>
|
||||||
|
<img src="public/screenshots/cli-selection.png" alt="CLI Seçimi" width="400">
|
||||||
|
<br>
|
||||||
|
<em>Claude Code, Gemini, Cursor CLI ve Codex arasında seçim yap</em>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
## Özellikler
|
||||||
|
|
||||||
|
- **Duyarlı Tasarım** — Masaüstü, tablet ve mobilde sorunsuz çalışır; böylece ajanlarını telefondan da kullanabilirsin
|
||||||
|
- **Etkileşimli Sohbet Arayüzü** — Ajanlarla akıcı iletişim için dahili sohbet arayüzü
|
||||||
|
- **Entegre Shell Terminali** — Yerleşik shell özelliği üzerinden ajan CLI'larına doğrudan erişim
|
||||||
|
- **Dosya Gezgini** — Sözdizimi vurgulama ve canlı düzenleme ile etkileşimli dosya ağacı
|
||||||
|
- **Git Gezgini** — Değişikliklerini görüntüle, staging'e ekle ve commit'le. Dallar arası geçiş de yapabilirsin
|
||||||
|
- **Oturum Yönetimi** — Konuşmalara devam et, birden fazla oturumu yönet ve geçmişi takip et
|
||||||
|
- **Eklenti Sistemi** — CloudCLI'ı özel eklentilerle genişlet: yeni sekmeler, arka uç servisleri ve entegrasyonlar ekle. [Kendi eklentini yaz →](https://github.com/cloudcli-ai/cloudcli-plugin-starter)
|
||||||
|
- **TaskMaster AI Entegrasyonu** *(İsteğe Bağlı)* — AI destekli görev planlama, PRD ayrıştırma ve iş akışı otomasyonu ile gelişmiş proje yönetimi
|
||||||
|
- **Model Uyumluluğu** — Claude, GPT ve Gemini model aileleriyle çalışır (desteklenen tüm modeller için [`shared/modelConstants.js`](shared/modelConstants.js) dosyasına bak)
|
||||||
|
|
||||||
|
|
||||||
|
## Hızlı Başlangıç
|
||||||
|
|
||||||
|
### CloudCLI Cloud (Önerilen)
|
||||||
|
|
||||||
|
Başlamanın en hızlı yolu — yerel kurulum yok. Web, mobil uygulama, API veya favori IDE'nden erişilebilen, tam yönetilen, konteyner tabanlı bir geliştirme ortamına sahip ol.
|
||||||
|
|
||||||
|
**[CloudCLI Cloud ile başla](https://cloudcli.ai)**
|
||||||
|
|
||||||
|
|
||||||
|
### Kendin Barındır (Açık Kaynak)
|
||||||
|
|
||||||
|
#### npm
|
||||||
|
|
||||||
|
CloudCLI UI'yi **npx** ile anında dene (**Node.js** v22+ gerekir):
|
||||||
|
|
||||||
|
```
|
||||||
|
npx @cloudcli-ai/cloudcli
|
||||||
|
```
|
||||||
|
|
||||||
|
Veya düzenli kullanım için **genel olarak** kur:
|
||||||
|
|
||||||
|
```
|
||||||
|
npm install -g @cloudcli-ai/cloudcli
|
||||||
|
cloudcli
|
||||||
|
```
|
||||||
|
|
||||||
|
`http://localhost:3001` adresini aç — mevcut tüm oturumların otomatik olarak keşfedilir.
|
||||||
|
|
||||||
|
Tam yapılandırma seçenekleri, PM2, uzak sunucu kurulumu ve daha fazlası için **[dokümantasyonu ziyaret et →](https://cloudcli.ai/docs)**.
|
||||||
|
|
||||||
|
#### Docker Sandbox'lar (Deneysel)
|
||||||
|
|
||||||
|
Ajanları hipervizör seviyesinde izolasyonlu sandbox'larda çalıştır. Varsayılan olarak Claude Code başlar. [`sbx` CLI](https://docs.docker.com/ai/sandboxes/get-started/) gerekir.
|
||||||
|
|
||||||
|
```
|
||||||
|
npx @cloudcli-ai/cloudcli@latest sandbox ~/my-project
|
||||||
|
```
|
||||||
|
|
||||||
|
Claude Code, Codex ve Gemini CLI destekler. Kurulum ve gelişmiş seçenekler için [sandbox dokümantasyonuna](docker/) bak.
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Hangi seçenek sana uygun?
|
||||||
|
|
||||||
|
CloudCLI UI, CloudCLI Cloud'u güçlendiren açık kaynak arayüz katmanıdır. Kendi makinende barındırabilir, izolasyon için Docker sandbox'ta çalıştırabilir veya tam yönetilen ortam için CloudCLI Cloud kullanabilirsin.
|
||||||
|
|
||||||
|
| | Kendin Barındır (npm) | Kendin Barındır (Docker Sandbox) *(Deneysel)* | CloudCLI Cloud |
|
||||||
|
|---|---|---|---|
|
||||||
|
| **En iyi şunun için** | Kendi makinende yerel ajan oturumları | Web/mobil IDE ile izole ajanlar | Ajanlarını bulutta isteyen ekipler |
|
||||||
|
| **Nasıl erişilir** | `[yourip]:port` üzerinden tarayıcıda | `localhost:port` üzerinden tarayıcıda | Tarayıcı, herhangi bir IDE, REST API, n8n |
|
||||||
|
| **Kurulum** | `npx @cloudcli-ai/cloudcli` | `npx @cloudcli-ai/cloudcli@latest sandbox ~/project` | Kurulum gerekmez |
|
||||||
|
| **İzolasyon** | Kendi host'unda çalışır | Hipervizör seviyesi sandbox (microVM) | Tam bulut izolasyonu |
|
||||||
|
| **Makinenin açık kalması gerek** | Evet | Evet | Hayır |
|
||||||
|
| **Mobil erişim** | Ağındaki herhangi bir tarayıcı | Ağındaki herhangi bir tarayıcı | Herhangi bir cihaz, native uygulama yolda |
|
||||||
|
| **Desteklenen ajanlar** | Claude Code, Cursor CLI, Codex, Gemini CLI | Claude Code, Codex, Gemini CLI | Claude Code, Cursor CLI, Codex, Gemini CLI |
|
||||||
|
| **Dosya gezgini ve Git** | Evet | Evet | Evet |
|
||||||
|
| **MCP yapılandırması** | `~/.claude` ile senkron | UI üzerinden yönetilir | UI üzerinden yönetilir |
|
||||||
|
| **REST API** | Evet | Evet | Evet |
|
||||||
|
| **Ekip paylaşımı** | Hayır | Hayır | Evet |
|
||||||
|
| **Platform maliyeti** | Ücretsiz, açık kaynak | Ücretsiz, açık kaynak | Aylık 7 $'dan başlar |
|
||||||
|
|
||||||
|
> Tüm seçenekler kendi AI aboneliklerini (Claude, Cursor, vb.) kullanır — CloudCLI AI'ı değil, ortamı sağlar.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Güvenlik ve Araç Yapılandırması
|
||||||
|
|
||||||
|
**🔒 Önemli Uyarı**: Tüm Claude Code araçları **varsayılan olarak devre dışıdır**. Bu, potansiyel olarak zararlı işlemlerin otomatik çalışmasını önler.
|
||||||
|
|
||||||
|
### Araçları Etkinleştirme
|
||||||
|
|
||||||
|
Claude Code'un tam işlevselliğinden yararlanmak için araçları manuel olarak etkinleştirmen gerekir:
|
||||||
|
|
||||||
|
1. **Araç Ayarlarını Aç** — Kenar çubuğundaki dişli simgesine tıkla
|
||||||
|
2. **Seçerek Etkinleştir** — Yalnızca ihtiyacın olan araçları aç
|
||||||
|
3. **Ayarları Uygula** — Tercihlerin yerel olarak kaydedilir
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
|
||||||
|

|
||||||
|
*Araç Ayarları arayüzü — yalnızca ihtiyacın olanı etkinleştir*
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
**Önerilen yaklaşım**: Temel araçlarla başla ve gerektikçe daha fazlasını ekle. Bu ayarları sonra her zaman değiştirebilirsin.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Eklentiler
|
||||||
|
|
||||||
|
CloudCLI, kendi frontend UI'sı ve isteğe bağlı Node.js arka ucu olan özel sekmeler eklemeni sağlayan bir eklenti sistemine sahiptir. Git depolarından eklentileri doğrudan **Ayarlar > Eklentiler**'den yükleyebilir veya kendi eklentini yazabilirsin.
|
||||||
|
|
||||||
|
### Mevcut Eklentiler
|
||||||
|
|
||||||
|
| Eklenti | Açıklama |
|
||||||
|
|---|---|
|
||||||
|
| **[Project Stats](https://github.com/cloudcli-ai/cloudcli-plugin-starter)** | Mevcut projen için dosya sayıları, kod satırları, dosya türü dağılımı, en büyük dosyalar ve son değiştirilen dosyaları gösterir |
|
||||||
|
| **[Web Terminal](https://github.com/cloudcli-ai/cloudcli-plugin-terminal)** | Çoklu sekme destekli tam xterm.js terminali |
|
||||||
|
|
||||||
|
### Kendi Eklentini Yaz
|
||||||
|
|
||||||
|
**[Plugin Starter Şablonu →](https://github.com/cloudcli-ai/cloudcli-plugin-starter)** — kendi eklentini oluşturmak için bu repo'yu fork'la. Frontend render, canlı bağlam güncellemeleri ve arka uç sunucusuyla RPC iletişimi içeren çalışan bir örnek içerir.
|
||||||
|
|
||||||
|
**[Plugin Dokümantasyonu →](https://cloudcli.ai/docs/plugin-overview)** — plugin API'sı, manifest formatı, güvenlik modeli ve daha fazlası için tam rehber.
|
||||||
|
|
||||||
|
---
|
||||||
|
## Sık Sorulan Sorular
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Bu Claude Code Remote Control'dan nasıl farklı?</summary>
|
||||||
|
|
||||||
|
Claude Code Remote Control, yerel terminalinde zaten çalışan bir oturuma mesaj göndermeni sağlar. Makinen açık kalmak zorunda, terminalin açık kalmak zorunda ve ağ bağlantısı olmadan yaklaşık 10 dakika sonra oturumlar zaman aşımına uğrar.
|
||||||
|
|
||||||
|
CloudCLI UI ve CloudCLI Cloud, Claude Code'un yanında değil içinde çalışır — MCP sunucuların, izinlerin, ayarların ve oturumların, Claude Code'un yerel olarak kullandığının birebir aynısıdır. Hiçbir şey çoğaltılmaz veya ayrı yönetilmez.
|
||||||
|
|
||||||
|
Pratikte bu ne demek:
|
||||||
|
|
||||||
|
- **Tek oturum değil, tüm oturumların** — CloudCLI UI, `~/.claude` klasöründeki her oturumu otomatik keşfeder. Remote Control yalnızca tek aktif oturumu Claude mobil uygulamasına açar.
|
||||||
|
- **Ayarların sana ait** — UI'da değiştirdiğin MCP sunucuları, araç izinleri ve proje yapılandırması doğrudan Claude Code yapılandırmana yazılır ve anında etkili olur; tersi de geçerli.
|
||||||
|
- **Daha fazla ajanla çalışır** — Sadece Claude Code değil; Cursor CLI, Codex ve Gemini CLI de.
|
||||||
|
- **Sadece sohbet penceresi değil, tam UI** — dosya gezgini, Git entegrasyonu, MCP yönetimi ve shell terminali hepsi yerleşik.
|
||||||
|
- **CloudCLI Cloud bulutta çalışır** — laptop'unu kapat, ajan çalışmaya devam eder. Beklemen gereken terminal yok, uyanık tutman gereken makine yok.
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>AI aboneliği için ayrıca ödeme yapmam gerekiyor mu?</summary>
|
||||||
|
|
||||||
|
Evet. CloudCLI AI'yi değil, ortamı sağlar. Kendi Claude, Cursor, Codex veya Gemini aboneliğini getirirsin. CloudCLI Cloud, barındırılan ortam için aylık 7 $'dan başlar — bunun üzerine eklenir.
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>CloudCLI UI'yi telefonumda kullanabilir miyim?</summary>
|
||||||
|
|
||||||
|
Evet. Kendin barındırdığında, sunucuyu makinende çalıştır ve ağındaki herhangi bir tarayıcıda `[yourip]:port` adresini aç. CloudCLI Cloud için, herhangi bir cihazdan aç — VPN yok, port yönlendirme yok, kurulum yok. Native bir uygulama da hazırlanıyor.
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>UI'da yaptığım değişiklikler yerel Claude Code kurulumumu etkiler mi?</summary>
|
||||||
|
|
||||||
|
Evet, kendin barındırdığında. CloudCLI UI, Claude Code'un yerel olarak kullandığı aynı `~/.claude` yapılandırmasından okur ve ona yazar. UI üzerinden eklediğin MCP sunucuları Claude Code'da anında görünür; tersi de geçerli.
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Topluluk ve Destek
|
||||||
|
|
||||||
|
- **[Dokümantasyon](https://cloudcli.ai/docs)** — kurulum, yapılandırma, özellikler ve sorun giderme
|
||||||
|
- **[Discord](https://discord.gg/buxwujPNRE)** — yardım al ve diğer kullanıcılarla tanış
|
||||||
|
- **[GitHub Issues](https://github.com/siteboon/claudecodeui/issues)** — hata raporları ve özellik istekleri
|
||||||
|
- **[Katkı Rehberi](CONTRIBUTING.md)** — projeye nasıl katkıda bulunulur
|
||||||
|
|
||||||
|
## Lisans
|
||||||
|
|
||||||
|
GNU Affero General Public License v3.0 veya sonrası (AGPL-3.0-or-later) — tam metin ve Bölüm 7 altındaki ek şartlar için [LICENSE](LICENSE) dosyasına bak.
|
||||||
|
|
||||||
|
Bu proje açık kaynaklıdır ve AGPL-3.0-or-later lisansı altında özgürce kullanılabilir, değiştirilebilir ve dağıtılabilir. Bu yazılımı değiştirir ve bir ağ servisi olarak çalıştırırsan, değiştirilmiş kaynak kodunu o servisin kullanıcılarına sunmak zorundasın.
|
||||||
|
|
||||||
|
CloudCLI UI — (https://cloudcli.ai).
|
||||||
|
|
||||||
|
## Teşekkürler
|
||||||
|
|
||||||
|
### Kullanılan Teknolojiler
|
||||||
|
- **[Claude Code](https://docs.anthropic.com/en/docs/claude-code)** — Anthropic'in resmi CLI'ı
|
||||||
|
- **[Cursor CLI](https://docs.cursor.com/en/cli/overview)** — Cursor'un resmi CLI'ı
|
||||||
|
- **[Codex](https://developers.openai.com/codex)** — OpenAI Codex
|
||||||
|
- **[Gemini-CLI](https://geminicli.com/)** — Google Gemini CLI
|
||||||
|
- **[React](https://react.dev/)** — Kullanıcı arayüzü kütüphanesi
|
||||||
|
- **[Vite](https://vitejs.dev/)** — Hızlı derleme aracı ve geliştirme sunucusu
|
||||||
|
- **[Tailwind CSS](https://tailwindcss.com/)** — Utility-first CSS framework
|
||||||
|
- **[CodeMirror](https://codemirror.net/)** — Gelişmiş kod editörü
|
||||||
|
- **[TaskMaster AI](https://github.com/eyaltoledano/claude-task-master)** *(İsteğe Bağlı)* — AI destekli proje yönetimi ve görev planlama
|
||||||
|
|
||||||
|
|
||||||
|
### Sponsorlar
|
||||||
|
- [Siteboon — AI destekli web sitesi oluşturucu](https://siteboon.ai)
|
||||||
|
---
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
<strong>Claude Code, Cursor ve Codex topluluğu için özenle yapıldı.</strong>
|
||||||
|
</div>
|
||||||
242
README.zh-CN.md
Normal file
@@ -0,0 +1,242 @@
|
|||||||
|
<div align="center">
|
||||||
|
<img src="public/logo.svg" alt="CloudCLI UI" width="64" height="64">
|
||||||
|
<h1>Cloud CLI(又名 Claude Code UI)</h1>
|
||||||
|
<p><a href="https://docs.anthropic.com/en/docs/claude-code">Claude Code</a>、<a href="https://docs.cursor.com/en/cli/overview">Cursor CLI</a>、<a href="https://developers.openai.com/codex">Codex</a> 和 <a href="https://geminicli.com/">Gemini-CLI</a> 的桌面和移动端 UI。可在本地或远程使用,从任何地方查看激活的项目与会话。</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://cloudcli.ai">CloudCLI Cloud</a> · <a href="https://cloudcli.ai/docs">文档</a> · <a href="https://discord.gg/buxwujPNRE">Discord</a> · <a href="https://github.com/siteboon/claudecodeui/issues">Bug 报告</a> · <a href="CONTRIBUTING.md">贡献指南</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://cloudcli.ai"><img src="https://img.shields.io/badge/☁️_CloudCLI_Cloud-Try_Now-0066FF?style=for-the-badge" alt="CloudCLI Cloud"></a>
|
||||||
|
<a href="https://discord.gg/buxwujPNRE"><img src="https://img.shields.io/badge/Discord-Join%20Community-5865F2?style=for-the-badge&logo=discord&logoColor=white" alt="加入 Discord 社区"></a>
|
||||||
|
<br><br>
|
||||||
|
<a href="https://trendshift.io/repositories/15586" target="_blank"><img src="https://trendshift.io/api/badge/repositories/15586" alt="siteboon%2Fclaudecodeui | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div align="right"><i><a href="./README.md">English</a> · <a href="./README.ru.md">Русский</a> · <a href="./README.de.md">Deutsch</a> · <a href="./README.ko.md">한국어</a> · <b>中文</b> · <a href="./README.ja.md">日本語</a> · <a href="./README.tr.md">Türkçe</a></i></div>
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 截图
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td align="center">
|
||||||
|
<h3>桌面视图</h3>
|
||||||
|
<img src="public/screenshots/desktop-main.png" alt="桌面界面" width="400">
|
||||||
|
<br>
|
||||||
|
<em>显示项目概览和聊天的主界面</em>
|
||||||
|
</td>
|
||||||
|
<td align="center">
|
||||||
|
<h3>移动体验</h3>
|
||||||
|
<img src="public/screenshots/mobile-chat.png" alt="移动界面" width="250">
|
||||||
|
<br>
|
||||||
|
<em>具有触控导航的响应式移动设计</em>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="center" colspan="2">
|
||||||
|
<h3>CLI 选择</h3>
|
||||||
|
<img src="public/screenshots/cli-selection.png" alt="CLI 选择" width="400">
|
||||||
|
<br>
|
||||||
|
<em>在 Claude Code、Gemini、Cursor CLI 与 Codex 之间进行选择</em>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
## 功能
|
||||||
|
|
||||||
|
- **响应式设计** - 在桌面、平板和移动设备上无缝运行,让您随时随地使用 Agents
|
||||||
|
- **交互聊天界面** - 内置聊天 UI,轻松与 Agents 交流
|
||||||
|
- **集成 Shell 终端** - 通过内置 shell 功能直接访问 Agents CLI
|
||||||
|
- **文件浏览器** - 交互式文件树,支持语法高亮与实时编辑
|
||||||
|
- **Git 浏览器** - 查看、暂存并提交更改,还可切换分支
|
||||||
|
- **会话管理** - 恢复对话、管理多个会话并跟踪历史记录
|
||||||
|
- **插件系统** - 通过自定义选项卡、后端服务与集成扩展 CloudCLI。 [开始构建 →](https://github.com/cloudcli-ai/cloudcli-plugin-starter)
|
||||||
|
- **TaskMaster AI 集成** *(可选)* - 结合 AI 任务规划、PRD 分析与工作流自动化,实现高级项目管理
|
||||||
|
- **模型兼容性** - 支持 Claude、GPT、Gemini 模型家族(完整支持列表见 [`shared/modelConstants.js`](shared/modelConstants.js))
|
||||||
|
|
||||||
|
## 快速开始
|
||||||
|
|
||||||
|
### CloudCLI Cloud(推荐)
|
||||||
|
|
||||||
|
无需本地设置即可快速启动。提供可通过网络浏览器、移动应用、API 或喜欢的 IDE 访问的完全集装式托管开发环境。
|
||||||
|
|
||||||
|
**[立即开始 CloudCLI Cloud](https://cloudcli.ai)**
|
||||||
|
|
||||||
|
### 自托管(开源)
|
||||||
|
|
||||||
|
#### npm
|
||||||
|
|
||||||
|
启动 CloudCLI UI,只需一行 `npx`(需要 Node.js v22+):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npx @cloudcli-ai/cloudcli
|
||||||
|
```
|
||||||
|
|
||||||
|
或进行全局安装,便于日常使用:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install -g @cloudcli-ai/cloudcli
|
||||||
|
cloudcli
|
||||||
|
```
|
||||||
|
|
||||||
|
打开 `http://localhost:3001`,系统会自动发现所有现有会话。
|
||||||
|
|
||||||
|
更多配置选项、PM2、远程服务器设置等,请参阅 **[文档 →](https://cloudcli.ai/docs)**。
|
||||||
|
|
||||||
|
#### Docker Sandboxes(实验性)
|
||||||
|
|
||||||
|
在隔离的沙箱中运行代理,具有虚拟机管理程序级别的隔离。默认启动 Claude Code。需要 [`sbx` CLI](https://docs.docker.com/ai/sandboxes/get-started/)。
|
||||||
|
|
||||||
|
```
|
||||||
|
npx @cloudcli-ai/cloudcli@latest sandbox ~/my-project
|
||||||
|
```
|
||||||
|
|
||||||
|
支持 Claude Code、Codex 和 Gemini CLI。详情请参阅 [沙箱文档](docker/)。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 哪个选项更适合你?
|
||||||
|
|
||||||
|
CloudCLI UI 是 CloudCLI Cloud 的开源 UI 层。你可以在本地机器上自托管它,也可以使用提供团队功能与深入集成的 CloudCLI Cloud。
|
||||||
|
|
||||||
|
| | CloudCLI UI(自托管) | CloudCLI Cloud |
|
||||||
|
|---|---|---|
|
||||||
|
| **适合对象** | 需要为本地代理会话提供完整 UI 的开发者 | 需要部署在云端,随时从任何地方访问代理的团队与开发者 |
|
||||||
|
| **访问方式** | 通过 `[yourip]:port` 在浏览器中访问 | 浏览器、任意 IDE、REST API、n8n |
|
||||||
|
| **设置** | `npx @cloudcli-ai/cloudcli` | 无需设置 |
|
||||||
|
| **机器需保持开机吗** | 是 | 否 |
|
||||||
|
| **移动端访问** | 网络内任意浏览器 | 任意设备(原生应用即将推出) |
|
||||||
|
| **可用会话** | 自动发现 `~/.claude` 中的所有会话 | 云端环境内的会话 |
|
||||||
|
| **支持的 Agents** | Claude Code、Cursor CLI、Codex、Gemini CLI | Claude Code、Cursor CLI、Codex、Gemini CLI |
|
||||||
|
| **文件浏览与 Git** | 内置于 UI | 内置于 UI |
|
||||||
|
| **MCP 配置** | UI 管理,与本地 `~/.claude` 配置同步 | UI 管理 |
|
||||||
|
| **IDE 访问** | 本地 IDE | 任何连接到云环境的 IDE |
|
||||||
|
| **REST API** | 是 | 是 |
|
||||||
|
| **n8n 节点** | 否 | 是 |
|
||||||
|
| **团队共享** | 否 | 是 |
|
||||||
|
| **平台费用** | 免费开源 | 起价 $7/月 |
|
||||||
|
|
||||||
|
> 两种方式都使用你自己的 AI 订阅(Claude、Cursor 等)— CloudCLI 提供环境,而非 AI。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 安全与工具配置
|
||||||
|
|
||||||
|
**🔒 重要提示**: 所有 Claude Code 工具默认**禁用**,可防止潜在的有害操作自动运行。
|
||||||
|
|
||||||
|
### 启用工具
|
||||||
|
|
||||||
|
1. **打开工具设置** - 点击侧边栏齿轮图标
|
||||||
|
2. **选择性启用** - 仅启用所需工具
|
||||||
|
3. **应用设置** - 偏好设置保存在本地
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
|
||||||
|

|
||||||
|
*工具设置界面 - 只启用你需要的内容*
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
**推荐做法**: 先启用基础工具,再根据需要添加其他工具。随时可以调整。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 插件
|
||||||
|
|
||||||
|
CloudCLI 配备插件系统,允许你添加带自定义前端 UI 和可选 Node.js 后端的选项卡。在 Settings > Plugins 中直接从 Git 仓库安装插件,或自行开发。
|
||||||
|
|
||||||
|
### 可用插件
|
||||||
|
|
||||||
|
| 插件 | 描述 |
|
||||||
|
|---|---|
|
||||||
|
| **[Project Stats](https://github.com/cloudcli-ai/cloudcli-plugin-starter)** | 展示当前项目的文件数、代码行数、文件类型分布、最大文件以及最近修改的文件 |
|
||||||
|
|
||||||
|
### 自行构建
|
||||||
|
|
||||||
|
**[Plugin Starter Template →](https://github.com/cloudcli-ai/cloudcli-plugin-starter)** — Fork 该仓库以构建自己的插件。示例包括前端渲染、实时上下文更新和 RPC 通信。
|
||||||
|
|
||||||
|
**[插件文档 →](https://cloudcli.ai/docs/plugin-overview)** — 提供插件 API、清单格式、安全模型等完整指南。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 常见问题
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>与 Claude Code Remote Control 有何不同?</summary>
|
||||||
|
|
||||||
|
Claude Code Remote Control 让你发送消息到本地终端中已经运行的会话。该方式要求你的机器保持开机,终端保持开启,断开网络后约 10 分钟会话会超时。
|
||||||
|
|
||||||
|
CloudCLI UI 与 CloudCLI Cloud 是对 Claude Code 的扩展,而非旁观 — MCP 服务器、权限、设置、会话与 Claude Code 完全一致。
|
||||||
|
|
||||||
|
- **覆盖全部会话** — CloudCLI UI 会自动扫描 `~/.claude` 文件夹中的每个会话。Remote Control 只暴露当前活动的会话。
|
||||||
|
- **设置统一** — 在 CloudCLI UI 中修改的 MCP、工具权限等设置会立即写入 Claude Code。
|
||||||
|
- **支持更多 Agents** — Claude Code、Cursor CLI、Codex、Gemini CLI。
|
||||||
|
- **完整 UI** — 除了聊天界面,还包括文件浏览器、Git 集成、MCP 管理和 Shell 终端。
|
||||||
|
- **CloudCLI Cloud 保持运行于云端** — 关闭本地设备也不会中断代理运行,无需监控终端。
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>需要额外购买 AI 订阅吗?</summary>
|
||||||
|
|
||||||
|
需要。CloudCLI 只提供环境。你仍需自行获取 Claude、Cursor、Codex 或 Gemini 订阅。CloudCLI Cloud 从 $7/月起提供托管环境。
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>能在手机上使用 CloudCLI UI 吗?</summary>
|
||||||
|
|
||||||
|
可以。自托管时,在你的设备上运行服务器,然后在网络中的任意浏览器打开 `[yourip]:port`。CloudCLI Cloud 可从任意设备访问,内置原生应用也在开发中。
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>UI 中的更改会影响本地 Claude Code 配置吗?</summary>
|
||||||
|
|
||||||
|
会的。自托管模式下,CloudCLI UI 读取并写入 Claude Code 使用的 `~/.claude` 配置。通过 UI 添加的 MCP 服务器会立即在 Claude Code 中可见。
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 社区与支持
|
||||||
|
|
||||||
|
- **[文档](https://cloudcli.ai/docs)** — 安装、配置、功能与故障排除指南
|
||||||
|
- **[Discord](https://discord.gg/buxwujPNRE)** — 获取帮助并与社区交流
|
||||||
|
- **[GitHub Issues](https://github.com/siteboon/claudecodeui/issues)** — 报告 Bug 与建议功能
|
||||||
|
- **[贡献指南](CONTRIBUTING.md)** — 如何参与项目贡献
|
||||||
|
|
||||||
|
## 许可证
|
||||||
|
|
||||||
|
GNU 通用公共许可证 v3.0 - 详见 [LICENSE](LICENSE) 文件。
|
||||||
|
|
||||||
|
该项目为开源软件,在 GPL v3 许可证下可自由使用、修改与分发。
|
||||||
|
|
||||||
|
## 致谢
|
||||||
|
|
||||||
|
### 使用技术
|
||||||
|
- **[Claude Code](https://docs.anthropic.com/en/docs/claude-code)** - Anthropic 官方 CLI
|
||||||
|
- **[Cursor CLI](https://docs.cursor.com/en/cli/overview)** - Cursor 官方 CLI
|
||||||
|
- **[Codex](https://developers.openai.com/codex)** - OpenAI Codex
|
||||||
|
- **[Gemini-CLI](https://geminicli.com/)** - Google Gemini CLI
|
||||||
|
- **[React](https://react.dev/)** - 用户界面库
|
||||||
|
- **[Vite](https://vitejs.dev/)** - 快速构建工具与开发服务器
|
||||||
|
- **[Tailwind CSS](https://tailwindcss.com/)** - 实用先行 CSS 框架
|
||||||
|
- **[CodeMirror](https://codemirror.net/)** - 高级代码编辑器
|
||||||
|
- **[TaskMaster AI](https://github.com/eyaltoledano/claude-task-master)** *(可选)* - AI 驱动的项目管理与任务规划
|
||||||
|
|
||||||
|
### 赞助商
|
||||||
|
- [Siteboon - AI powered website builder](https://siteboon.ai)
|
||||||
|
---
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
<strong>为 Claude Code、Cursor 和 Codex 社区精心打造。</strong>
|
||||||
|
</div>
|
||||||
3
commitlint.config.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export default {
|
||||||
|
extends: ["@commitlint/config-conventional"],
|
||||||
|
};
|
||||||
160
docker/README.md
Normal file
@@ -0,0 +1,160 @@
|
|||||||
|
<!-- Docker Hub short description (100 chars max): -->
|
||||||
|
<!-- Sandbox templates for running AI coding agents with a web & mobile IDE (Claude Code, Codex, Gemini) -->
|
||||||
|
|
||||||
|
# Sandboxed coding agents with a web & mobile IDE (CloudCLI)
|
||||||
|
|
||||||
|
[Docker Sandbox](https://docs.docker.com/ai/sandboxes/) templates that add [CloudCLI](https://cloudcli.ai) on top of Claude Code, Codex, and Gemini CLI. You get a full web and mobile IDE accessible from any browser on any device.
|
||||||
|
|
||||||
|
## Get started
|
||||||
|
|
||||||
|
### 1. Install the sbx CLI
|
||||||
|
|
||||||
|
Docker Sandboxes run agents in isolated microVMs. Install the `sbx` CLI:
|
||||||
|
|
||||||
|
- **macOS**: `brew install docker/tap/sbx`
|
||||||
|
- **Windows**: `winget install -h Docker.sbx`
|
||||||
|
- **Linux**: `sudo apt-get install docker-sbx`
|
||||||
|
|
||||||
|
Full instructions: [docs.docker.com/ai/sandboxes/get-started](https://docs.docker.com/ai/sandboxes/get-started/)
|
||||||
|
|
||||||
|
### 2. Store your API key
|
||||||
|
|
||||||
|
`sbx` manages credentials securely — your API key never enters the sandbox. Store it once:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sbx login
|
||||||
|
sbx secret set -g anthropic
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. Launch Claude Code
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npx @cloudcli-ai/cloudcli@latest sandbox ~/my-project
|
||||||
|
```
|
||||||
|
|
||||||
|
Open **http://localhost:3001**. Set a password on first visit. Start building.
|
||||||
|
|
||||||
|
### Using a different agent
|
||||||
|
|
||||||
|
Store the matching API key and pass `--agent`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# OpenAI Codex
|
||||||
|
sbx secret set -g openai
|
||||||
|
npx @cloudcli-ai/cloudcli@latest sandbox ~/my-project --agent codex
|
||||||
|
|
||||||
|
# Gemini CLI
|
||||||
|
sbx secret set -g google
|
||||||
|
npx @cloudcli-ai/cloudcli@latest sandbox ~/my-project --agent gemini
|
||||||
|
```
|
||||||
|
|
||||||
|
### Available templates
|
||||||
|
|
||||||
|
| Agent | Template |
|
||||||
|
|-------|----------|
|
||||||
|
| **Claude Code** (default) | `docker.io/cloudcliai/sandbox:claude-code` |
|
||||||
|
| OpenAI Codex | `docker.io/cloudcliai/sandbox:codex` |
|
||||||
|
| Gemini CLI | `docker.io/cloudcliai/sandbox:gemini` |
|
||||||
|
|
||||||
|
These are used with `--template` when running `sbx` directly (see [Advanced usage](#advanced-usage)).
|
||||||
|
|
||||||
|
## Managing sandboxes
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sbx ls # List all sandboxes
|
||||||
|
sbx stop my-project # Stop (preserves state)
|
||||||
|
sbx start my-project # Restart a stopped sandbox
|
||||||
|
sbx rm my-project # Remove everything
|
||||||
|
sbx exec my-project bash # Open a shell inside the sandbox
|
||||||
|
```
|
||||||
|
|
||||||
|
If you install CloudCLI globally (`npm install -g @cloudcli-ai/cloudcli`), you can also use:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cloudcli sandbox ls
|
||||||
|
cloudcli sandbox start my-project # Restart and re-launch web UI
|
||||||
|
cloudcli sandbox logs my-project # View server logs
|
||||||
|
```
|
||||||
|
|
||||||
|
## What you get
|
||||||
|
|
||||||
|
- **Chat** — Markdown rendering, code blocks, message history
|
||||||
|
- **Files** — File tree with syntax-highlighted editor
|
||||||
|
- **Git** — Diff viewer, staging, branch switching, commits
|
||||||
|
- **Shell** — Built-in terminal emulator
|
||||||
|
- **MCP** — Configure Model Context Protocol servers visually
|
||||||
|
- **Mobile** — Works on tablet and phone browsers
|
||||||
|
|
||||||
|
Your project directory is mounted bidirectionally — edits propagate in real time, both ways.
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
Set variables at creation time with `--env`:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npx @cloudcli-ai/cloudcli@latest sandbox ~/my-project --env SERVER_PORT=8080
|
||||||
|
```
|
||||||
|
|
||||||
|
Or inside a running sandbox:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sbx exec my-project bash -c 'echo "export SERVER_PORT=8080" >> /etc/sandbox-persistent.sh'
|
||||||
|
```
|
||||||
|
|
||||||
|
Restart CloudCLI for changes to take effect:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sbx exec my-project bash -c 'pkill -f "server/index.js"'
|
||||||
|
sbx exec -d my-project cloudcli start --port 3001
|
||||||
|
```
|
||||||
|
|
||||||
|
| Variable | Default | Description |
|
||||||
|
|----------|---------|-------------|
|
||||||
|
| `SERVER_PORT` | `3001` | Web UI port |
|
||||||
|
| `HOST` | `0.0.0.0` | Bind address (must be `0.0.0.0` for `sbx ports`) |
|
||||||
|
| `DATABASE_PATH` | `~/.cloudcli/auth.db` | SQLite database location |
|
||||||
|
|
||||||
|
## Advanced usage
|
||||||
|
|
||||||
|
For branch mode, multiple workspaces, memory limits, or the terminal agent experience, use `sbx` with the template:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Terminal agent + web UI
|
||||||
|
sbx run --template docker.io/cloudcliai/sandbox:claude-code claude ~/my-project --name my-project
|
||||||
|
sbx ports my-project --publish 3001:3001
|
||||||
|
|
||||||
|
# Branch mode (Git worktree isolation)
|
||||||
|
sbx run --template docker.io/cloudcliai/sandbox:claude-code claude ~/my-project --branch my-feature
|
||||||
|
|
||||||
|
# Multiple workspaces
|
||||||
|
sbx run --template docker.io/cloudcliai/sandbox:claude-code claude ~/project ~/shared-libs:ro
|
||||||
|
|
||||||
|
# Pass a prompt directly
|
||||||
|
sbx run --template docker.io/cloudcliai/sandbox:claude-code claude ~/my-project -- "Fix the auth bug"
|
||||||
|
```
|
||||||
|
|
||||||
|
CloudCLI auto-starts via `.bashrc` when using `sbx run`.
|
||||||
|
|
||||||
|
Full options in the [Docker Sandboxes usage guide](https://docs.docker.com/ai/sandboxes/usage/).
|
||||||
|
|
||||||
|
## Network policies
|
||||||
|
|
||||||
|
Sandboxes restrict outbound access by default. To reach host services from inside the sandbox:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sbx policy allow network localhost:11434
|
||||||
|
# Inside the sandbox: curl http://host.docker.internal:11434
|
||||||
|
```
|
||||||
|
|
||||||
|
The web UI itself doesn't need a policy — access it via `sbx ports`.
|
||||||
|
|
||||||
|
## Links
|
||||||
|
|
||||||
|
- [CloudCLI Cloud](https://cloudcli.ai) — fully managed, no setup required
|
||||||
|
- [Documentation](https://cloudcli.ai/docs) — full configuration guide
|
||||||
|
- [Discord](https://discord.gg/buxwujPNRE) — community support
|
||||||
|
- [GitHub](https://github.com/siteboon/claudecodeui) — source code and issues
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
AGPL-3.0-or-later
|
||||||
11
docker/claude-code/Dockerfile
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
FROM docker/sandbox-templates:claude-code
|
||||||
|
|
||||||
|
USER root
|
||||||
|
COPY shared/install-cloudcli.sh /tmp/install-cloudcli.sh
|
||||||
|
RUN chmod +x /tmp/install-cloudcli.sh && /tmp/install-cloudcli.sh
|
||||||
|
|
||||||
|
USER agent
|
||||||
|
RUN npm install -g @cloudcli-ai/cloudcli && cloudcli --version
|
||||||
|
|
||||||
|
COPY --chown=agent:agent shared/start-cloudcli.sh /home/agent/.cloudcli-start.sh
|
||||||
|
RUN echo '. ~/.cloudcli-start.sh' >> /home/agent/.bashrc
|
||||||
11
docker/codex/Dockerfile
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
FROM docker/sandbox-templates:codex
|
||||||
|
|
||||||
|
USER root
|
||||||
|
COPY shared/install-cloudcli.sh /tmp/install-cloudcli.sh
|
||||||
|
RUN chmod +x /tmp/install-cloudcli.sh && /tmp/install-cloudcli.sh
|
||||||
|
|
||||||
|
USER agent
|
||||||
|
RUN npm install -g @cloudcli-ai/cloudcli && cloudcli --version
|
||||||
|
|
||||||
|
COPY --chown=agent:agent shared/start-cloudcli.sh /home/agent/.cloudcli-start.sh
|
||||||
|
RUN echo '. ~/.cloudcli-start.sh' >> /home/agent/.bashrc
|
||||||
11
docker/gemini/Dockerfile
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
FROM docker/sandbox-templates:gemini
|
||||||
|
|
||||||
|
USER root
|
||||||
|
COPY shared/install-cloudcli.sh /tmp/install-cloudcli.sh
|
||||||
|
RUN chmod +x /tmp/install-cloudcli.sh && /tmp/install-cloudcli.sh
|
||||||
|
|
||||||
|
USER agent
|
||||||
|
RUN npm install -g @cloudcli-ai/cloudcli && cloudcli --version
|
||||||
|
|
||||||
|
COPY --chown=agent:agent shared/start-cloudcli.sh /home/agent/.cloudcli-start.sh
|
||||||
|
RUN echo '. ~/.cloudcli-start.sh' >> /home/agent/.bashrc
|
||||||
11
docker/shared/install-cloudcli.sh
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Install build tools needed for native modules (node-pty, better-sqlite3, bcrypt)
|
||||||
|
# Node.js is already provided by the sandbox base image
|
||||||
|
apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
build-essential python3 python3-setuptools \
|
||||||
|
jq ripgrep sqlite3 zip unzip tree vim-tiny
|
||||||
|
|
||||||
|
# Clean up apt cache to reduce image size
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
18
docker/shared/start-cloudcli.sh
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Auto-start CloudCLI server in background if not already running.
|
||||||
|
# This script is sourced from ~/.bashrc on sandbox shell open.
|
||||||
|
|
||||||
|
if ! pgrep -f "server/index.js" > /dev/null 2>&1; then
|
||||||
|
nohup cloudcli start --port 3001 > /tmp/cloudcli-ui.log 2>&1 &
|
||||||
|
disown
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo " CloudCLI is starting on port 3001..."
|
||||||
|
echo ""
|
||||||
|
echo " Forward the port from another terminal:"
|
||||||
|
echo " sbx ports <sandbox-name> --publish 3001:3001"
|
||||||
|
echo ""
|
||||||
|
echo " Then open: http://localhost:3001"
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
251
eslint.config.js
Normal file
@@ -0,0 +1,251 @@
|
|||||||
|
import js from "@eslint/js";
|
||||||
|
import tseslint from "typescript-eslint";
|
||||||
|
import react from "eslint-plugin-react";
|
||||||
|
import reactHooks from "eslint-plugin-react-hooks";
|
||||||
|
import reactRefresh from "eslint-plugin-react-refresh";
|
||||||
|
import { createNodeResolver, importX } from "eslint-plugin-import-x";
|
||||||
|
import { createTypeScriptImportResolver } from "eslint-import-resolver-typescript";
|
||||||
|
import boundaries from "eslint-plugin-boundaries";
|
||||||
|
import tailwindcss from "eslint-plugin-tailwindcss";
|
||||||
|
import unusedImports from "eslint-plugin-unused-imports";
|
||||||
|
import globals from "globals";
|
||||||
|
|
||||||
|
export default tseslint.config(
|
||||||
|
{
|
||||||
|
ignores: ["dist/**", "node_modules/**", "public/**"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ["src/**/*.{ts,tsx,js,jsx}"],
|
||||||
|
extends: [js.configs.recommended, ...tseslint.configs.recommended],
|
||||||
|
plugins: {
|
||||||
|
react,
|
||||||
|
"react-hooks": reactHooks, // for following React rules such as dependencies in hooks, keys in lists, etc.
|
||||||
|
"react-refresh": reactRefresh, // for Vite HMR compatibility
|
||||||
|
"import-x": importX, // for import order/sorting. It also detercts circular dependencies and duplicate imports.
|
||||||
|
tailwindcss, // for detecting invalid Tailwind classnames and enforcing classname order
|
||||||
|
"unused-imports": unusedImports, // for detecting unused imports
|
||||||
|
},
|
||||||
|
languageOptions: {
|
||||||
|
globals: {
|
||||||
|
...globals.browser,
|
||||||
|
},
|
||||||
|
parserOptions: {
|
||||||
|
ecmaFeatures: { jsx: true },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
settings: {
|
||||||
|
react: { version: "detect" },
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
// --- Unused imports/vars ---
|
||||||
|
"unused-imports/no-unused-imports": "warn",
|
||||||
|
"unused-imports/no-unused-vars": [
|
||||||
|
"warn",
|
||||||
|
{
|
||||||
|
vars: "all",
|
||||||
|
varsIgnorePattern: "^_",
|
||||||
|
args: "after-used",
|
||||||
|
argsIgnorePattern: "^_",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"no-unused-vars": "off",
|
||||||
|
"@typescript-eslint/no-unused-vars": "off",
|
||||||
|
|
||||||
|
// --- React ---
|
||||||
|
"react/jsx-key": "warn",
|
||||||
|
"react/jsx-no-duplicate-props": "error",
|
||||||
|
"react/jsx-no-undef": "error",
|
||||||
|
"react/no-children-prop": "warn",
|
||||||
|
"react/no-danger-with-children": "error",
|
||||||
|
"react/no-direct-mutation-state": "error",
|
||||||
|
"react/no-unknown-property": "warn",
|
||||||
|
"react/react-in-jsx-scope": "off",
|
||||||
|
|
||||||
|
// --- React Hooks ---
|
||||||
|
"react-hooks/rules-of-hooks": "error",
|
||||||
|
"react-hooks/exhaustive-deps": "warn",
|
||||||
|
|
||||||
|
// --- React Refresh (Vite HMR) ---
|
||||||
|
"react-refresh/only-export-components": [
|
||||||
|
"warn",
|
||||||
|
{ allowConstantExport: true },
|
||||||
|
],
|
||||||
|
|
||||||
|
// --- Import ordering & hygiene ---
|
||||||
|
"import-x/no-duplicates": "warn",
|
||||||
|
"import-x/order": [
|
||||||
|
"warn",
|
||||||
|
{
|
||||||
|
groups: [
|
||||||
|
"builtin",
|
||||||
|
"external",
|
||||||
|
"internal",
|
||||||
|
"parent",
|
||||||
|
"sibling",
|
||||||
|
"index",
|
||||||
|
],
|
||||||
|
"newlines-between": "always",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
// --- Tailwind CSS ---
|
||||||
|
"tailwindcss/classnames-order": "warn",
|
||||||
|
"tailwindcss/no-contradicting-classname": "warn",
|
||||||
|
"tailwindcss/no-unnecessary-arbitrary-value": "warn",
|
||||||
|
|
||||||
|
// --- Disabled base rules ---
|
||||||
|
"@typescript-eslint/no-explicit-any": "off",
|
||||||
|
"@typescript-eslint/no-require-imports": "off",
|
||||||
|
"no-case-declarations": "off",
|
||||||
|
"no-control-regex": "off",
|
||||||
|
"no-useless-escape": "off",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ["server/**/*.{js,ts}"], // apply this block only to backend source files
|
||||||
|
ignores: ["server/**/*.d.ts"], // skip generated declaration files in backend linting
|
||||||
|
plugins: {
|
||||||
|
boundaries, // enforce backend architecture boundaries (module-to-module contracts)
|
||||||
|
"import-x": importX, // keep import hygiene rules (duplicates, unresolved paths, etc.)
|
||||||
|
"unused-imports": unusedImports, // remove dead imports/variables from backend files
|
||||||
|
},
|
||||||
|
languageOptions: {
|
||||||
|
parser: tseslint.parser, // parse both JS and TS syntax in backend files
|
||||||
|
parserOptions: {
|
||||||
|
ecmaVersion: "latest", // support modern ECMAScript syntax in backend code
|
||||||
|
sourceType: "module", // treat backend files as ESM modules
|
||||||
|
},
|
||||||
|
globals: {
|
||||||
|
...globals.node, // expose Node.js globals such as process, Buffer, and __dirname equivalents
|
||||||
|
},
|
||||||
|
},
|
||||||
|
settings: {
|
||||||
|
"boundaries/include": ["server/**/*.{js,ts}"], // only analyze dependency boundaries inside backend files
|
||||||
|
"import/resolver": {
|
||||||
|
// boundaries resolves imports through eslint-module-utils, which reads the classic
|
||||||
|
// import/resolver setting instead of import-x/resolver-next.
|
||||||
|
typescript: {
|
||||||
|
project: ["server/tsconfig.json"], // resolve backend aliases using the canonical backend tsconfig
|
||||||
|
alwaysTryTypes: true, // keep normal TS package/type resolution working alongside aliases
|
||||||
|
},
|
||||||
|
node: {
|
||||||
|
extensions: [".mjs", ".cjs", ".js", ".json", ".node", ".ts", ".tsx"], // preserve Node-style fallback resolution for plain files
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"import-x/resolver-next": [
|
||||||
|
// ESLint's import plugin does not read tsconfig path aliases on its own.
|
||||||
|
// This resolver teaches import-x how to understand the backend-only "@/*"
|
||||||
|
// mapping defined in server/tsconfig.json, which fixes false no-unresolved errors in editors.
|
||||||
|
createTypeScriptImportResolver({
|
||||||
|
project: ["server/tsconfig.json"], // point the resolver at the canonical backend tsconfig instead of the frontend one
|
||||||
|
alwaysTryTypes: true, // keep standard TypeScript package resolution working while backend aliases are enabled
|
||||||
|
}),
|
||||||
|
// Keep Node-style resolution available for normal package imports and plain relative JS files.
|
||||||
|
// The TypeScript resolver handles aliases, while the Node resolver preserves the expected fallback behavior.
|
||||||
|
createNodeResolver({
|
||||||
|
extensions: [".mjs", ".cjs", ".js", ".json", ".node", ".ts", ".tsx"],
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
"boundaries/elements": [
|
||||||
|
{
|
||||||
|
type: "backend-shared-type-contract", // shared backend type/interface contracts that modules may consume without creating runtime coupling
|
||||||
|
pattern: [
|
||||||
|
"server/shared/types.{js,ts}",
|
||||||
|
"server/shared/interfaces.{js,ts}",
|
||||||
|
], // keep backend modules on explicit shared contract files for erased imports only
|
||||||
|
mode: "file", // treat each shared contract file itself as the boundary element instead of the whole folder
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "backend-shared-utils", // shared backend runtime helpers that modules may import directly
|
||||||
|
pattern: [
|
||||||
|
"server/shared/utils.{js,ts}",
|
||||||
|
"server/shared/frontmatter.ts",
|
||||||
|
"server/shared/claude-cli-path.ts",
|
||||||
|
], // classify shared utility files so modules can depend on them explicitly
|
||||||
|
mode: "file",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "backend-legacy-runtime", // legacy runtime persistence modules used while providers migrate into server/modules
|
||||||
|
pattern: [
|
||||||
|
"server/projects.js",
|
||||||
|
"server/sessionManager.js",
|
||||||
|
"server/utils/runtime-paths.js",
|
||||||
|
], // provider history loading still resolves session data through these legacy runtime files
|
||||||
|
mode: "file",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "backend-module", // logical element name used by boundaries rules below
|
||||||
|
pattern: "server/modules/*", // each direct folder in server/modules is treated as one module boundary
|
||||||
|
mode: "folder", // classify dependencies at folder-module level (not per individual file)
|
||||||
|
capture: ["moduleName"], // capture the module folder name for messages/debugging/template use
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
// --- Unused imports/vars (backend) ---
|
||||||
|
"unused-imports/no-unused-imports": "warn", // warn when imports are not used so they can be cleaned up
|
||||||
|
"unused-imports/no-unused-vars": "off", // keep backend signal focused on dead imports instead of local unused variables
|
||||||
|
|
||||||
|
// --- Import hygiene (backend) ---
|
||||||
|
"import-x/no-duplicates": "warn", // prevent duplicate import lines from the same module
|
||||||
|
"import-x/order": [
|
||||||
|
"warn", // keep backend import grouping/order consistent with the frontend config
|
||||||
|
{
|
||||||
|
groups: [
|
||||||
|
"builtin", // Node built-ins such as fs, path, and url come first
|
||||||
|
"external", // third-party packages come after built-ins
|
||||||
|
"internal", // aliased internal imports such as @/... come next
|
||||||
|
"parent", // ../ imports come after aliased internal imports
|
||||||
|
"sibling", // ./foo imports come after parent imports
|
||||||
|
"index", // bare ./ imports stay last
|
||||||
|
],
|
||||||
|
"newlines-between": "always", // require a blank line between import groups in backend files too
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"import-x/no-unresolved": "error", // fail when an import path cannot be resolved
|
||||||
|
"import-x/no-useless-path-segments": "warn", // prefer cleaner paths (remove redundant ./ and ../ segments)
|
||||||
|
"import-x/no-absolute-path": "error", // disallow absolute filesystem imports in backend files
|
||||||
|
|
||||||
|
// --- General safety/style (backend) ---
|
||||||
|
eqeqeq: ["warn", "always", { null: "ignore" }], // avoid accidental coercion while still allowing x == null checks
|
||||||
|
|
||||||
|
// --- Architecture boundaries (backend modules) ---
|
||||||
|
"boundaries/dependencies": [
|
||||||
|
"error", // treat architecture violations as lint errors
|
||||||
|
{
|
||||||
|
default: "allow", // allow normal imports unless a rule below explicitly disallows them
|
||||||
|
checkInternals: false, // do not apply these cross-module rules to imports inside the same module
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
from: { type: "backend-module" }, // modules may depend on shared type/interface contracts only as erased type-only imports
|
||||||
|
to: { type: "backend-shared-type-contract" },
|
||||||
|
disallow: {
|
||||||
|
dependency: { kind: ["value", "typeof"] },
|
||||||
|
}, // block runtime imports so shared contracts stay compile-time only instead of becoming hidden shared modules
|
||||||
|
message:
|
||||||
|
"Backend modules may only use `import type` when importing from server/shared/types.ts or server/shared/interfaces.ts.",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
to: { type: "backend-module" }, // when importing anything that belongs to another backend module
|
||||||
|
disallow: { to: { internalPath: "**" } }, // block all direct/deep imports into module internals by default
|
||||||
|
message:
|
||||||
|
"Cross-module imports must go through that module's barrel file (server/modules/<module>/index.ts or index.js).", // explicit error message for architecture violations
|
||||||
|
},
|
||||||
|
{
|
||||||
|
to: { type: "backend-module" }, // same target scope as the disallow rule above
|
||||||
|
allow: {
|
||||||
|
to: {
|
||||||
|
internalPath: [
|
||||||
|
"index", // allow extensionless barrel imports resolved as module root index
|
||||||
|
"index.{js,mjs,cjs,ts,tsx}", // allow explicit index.* barrel file imports
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}, // re-allow only public module entry points (barrel files)
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"boundaries/no-unknown": "error", // fail fast if boundaries cannot classify a dependency, which prevents silent rule bypasses
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
@@ -5,13 +5,13 @@
|
|||||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||||
<link rel="icon" type="image/png" href="/favicon.png" />
|
<link rel="icon" type="image/png" href="/favicon.png" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, viewport-fit=cover" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, viewport-fit=cover" />
|
||||||
<title>Claude Code UI</title>
|
<title>CloudCLI UI</title>
|
||||||
|
|
||||||
<!-- PWA Manifest -->
|
<!-- PWA Manifest -->
|
||||||
<link rel="manifest" href="/manifest.json" />
|
<link rel="manifest" href="/manifest.json" crossorigin="use-credentials" />
|
||||||
|
|
||||||
<!-- iOS Safari PWA Meta Tags -->
|
<!-- iOS Safari PWA Meta Tags -->
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
<meta name="mobile-web-app-capable" content="yes" />
|
||||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
||||||
<meta name="apple-mobile-web-app-title" content="Claude UI" />
|
<meta name="apple-mobile-web-app-title" content="Claude UI" />
|
||||||
|
|
||||||
@@ -45,4 +45,4 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
9449
package-lock.json
generated
109
package.json
@@ -1,18 +1,21 @@
|
|||||||
{
|
{
|
||||||
"name": "@siteboon/claude-code-ui",
|
"name": "@cloudcli-ai/cloudcli",
|
||||||
"version": "1.10.4",
|
"version": "1.31.5",
|
||||||
"description": "A web-based UI for Claude Code CLI",
|
"description": "A web-based UI for Claude Code CLI",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "server/index.js",
|
"main": "dist-server/server/index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
"claude-code-ui": "server/index.js"
|
"cloudcli": "dist-server/server/cli.js"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"server/",
|
"server/",
|
||||||
|
"shared/",
|
||||||
"dist/",
|
"dist/",
|
||||||
|
"dist-server/",
|
||||||
|
"scripts/",
|
||||||
"README.md"
|
"README.md"
|
||||||
],
|
],
|
||||||
"homepage": "https://claudecodeui.siteboon.ai",
|
"homepage": "https://cloudcli.ai",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/siteboon/claudecodeui.git"
|
"url": "git+https://github.com/siteboon/claudecodeui.git"
|
||||||
@@ -21,25 +24,48 @@
|
|||||||
"url": "https://github.com/siteboon/claudecodeui/issues"
|
"url": "https://github.com/siteboon/claudecodeui/issues"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "concurrently --kill-others \"npm run server\" \"npm run client\"",
|
"dev": "concurrently --kill-others \"npm run server:dev\" \"npm run client\"",
|
||||||
"server": "node server/index.js",
|
"server": "node dist-server/server/index.js",
|
||||||
"client": "vite --host",
|
"server:dev": "tsx --tsconfig server/tsconfig.json server/index.js",
|
||||||
"build": "vite build",
|
"server:dev-watch": "tsx watch --tsconfig server/tsconfig.json server/index.js",
|
||||||
|
"client": "vite",
|
||||||
|
"build": "npm run build:client && npm run build:server",
|
||||||
|
"build:client": "vite build",
|
||||||
|
"prebuild:server": "node -e \"require('node:fs').rmSync('dist-server', { recursive: true, force: true })\"",
|
||||||
|
"build:server": "tsc -p server/tsconfig.json && tsc-alias -p server/tsconfig.json",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
|
"typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p server/tsconfig.json",
|
||||||
|
"lint": "eslint src/ server/",
|
||||||
|
"lint:fix": "eslint src/ server/ --fix",
|
||||||
"start": "npm run build && npm run server",
|
"start": "npm run build && npm run server",
|
||||||
"release": "./release.sh"
|
"release": "./release.sh",
|
||||||
|
"prepublishOnly": "npm run build",
|
||||||
|
"postinstall": "node scripts/fix-node-pty.js",
|
||||||
|
"prepare": "husky",
|
||||||
|
"update:platform": "./update-platform.sh"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"claude coode",
|
"claude code",
|
||||||
"ai",
|
"claude-code",
|
||||||
|
"claude-code-ui",
|
||||||
|
"cloudcli",
|
||||||
|
"codex",
|
||||||
|
"gemini",
|
||||||
|
"gemini-cli",
|
||||||
|
"cursor",
|
||||||
|
"cursor-cli",
|
||||||
"anthropic",
|
"anthropic",
|
||||||
|
"openai",
|
||||||
|
"google",
|
||||||
|
"coding-agent",
|
||||||
|
"web-ui",
|
||||||
"ui",
|
"ui",
|
||||||
"mobile"
|
"mobile IDE"
|
||||||
],
|
],
|
||||||
"author": "Claude Code UI Contributors",
|
"author": "CloudCLI UI Contributors",
|
||||||
"license": "MIT",
|
"license": "AGPL-3.0-or-later",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@anthropic-ai/claude-agent-sdk": "^0.1.29",
|
"@anthropic-ai/claude-agent-sdk": "^0.2.116",
|
||||||
"@codemirror/lang-css": "^6.3.1",
|
"@codemirror/lang-css": "^6.3.1",
|
||||||
"@codemirror/lang-html": "^6.4.9",
|
"@codemirror/lang-html": "^6.4.9",
|
||||||
"@codemirror/lang-javascript": "^6.2.4",
|
"@codemirror/lang-javascript": "^6.2.4",
|
||||||
@@ -48,53 +74,96 @@
|
|||||||
"@codemirror/lang-python": "^6.2.1",
|
"@codemirror/lang-python": "^6.2.1",
|
||||||
"@codemirror/merge": "^6.11.1",
|
"@codemirror/merge": "^6.11.1",
|
||||||
"@codemirror/theme-one-dark": "^6.1.2",
|
"@codemirror/theme-one-dark": "^6.1.2",
|
||||||
|
"@iarna/toml": "^2.2.5",
|
||||||
"@octokit/rest": "^22.0.0",
|
"@octokit/rest": "^22.0.0",
|
||||||
|
"@openai/codex-sdk": "^0.125.0",
|
||||||
"@replit/codemirror-minimap": "^0.5.2",
|
"@replit/codemirror-minimap": "^0.5.2",
|
||||||
"@tailwindcss/typography": "^0.5.16",
|
"@tailwindcss/typography": "^0.5.16",
|
||||||
"@uiw/react-codemirror": "^4.23.13",
|
"@uiw/react-codemirror": "^4.23.13",
|
||||||
|
"@vscode/ripgrep": "^1.17.1",
|
||||||
"@xterm/addon-clipboard": "^0.1.0",
|
"@xterm/addon-clipboard": "^0.1.0",
|
||||||
"@xterm/addon-fit": "^0.10.0",
|
"@xterm/addon-fit": "^0.10.0",
|
||||||
|
"@xterm/addon-web-links": "^0.11.0",
|
||||||
"@xterm/addon-webgl": "^0.18.0",
|
"@xterm/addon-webgl": "^0.18.0",
|
||||||
"@xterm/xterm": "^5.5.0",
|
"@xterm/xterm": "^5.5.0",
|
||||||
"bcrypt": "^6.0.0",
|
"bcrypt": "^6.0.0",
|
||||||
"better-sqlite3": "^12.2.0",
|
"better-sqlite3": "^12.6.2",
|
||||||
"chokidar": "^4.0.3",
|
"chokidar": "^4.0.3",
|
||||||
"class-variance-authority": "^0.7.1",
|
"class-variance-authority": "^0.7.1",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
|
"cmdk": "^1.1.1",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"cross-spawn": "^7.0.3",
|
"cross-spawn": "^7.0.3",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"fuse.js": "^7.0.0",
|
"fuse.js": "^7.0.0",
|
||||||
"gray-matter": "^4.0.3",
|
"gray-matter": "^4.0.3",
|
||||||
|
"i18next": "^25.7.4",
|
||||||
|
"i18next-browser-languagedetector": "^8.2.0",
|
||||||
"jsonwebtoken": "^9.0.2",
|
"jsonwebtoken": "^9.0.2",
|
||||||
|
"jszip": "^3.10.1",
|
||||||
|
"katex": "^0.16.25",
|
||||||
"lucide-react": "^0.515.0",
|
"lucide-react": "^0.515.0",
|
||||||
"mime-types": "^3.0.1",
|
"mime-types": "^3.0.1",
|
||||||
"multer": "^2.0.1",
|
"multer": "^2.0.1",
|
||||||
"node-fetch": "^2.7.0",
|
"node-fetch": "^2.7.0",
|
||||||
"node-pty": "^1.1.0-beta34",
|
"node-pty": "^1.2.0-beta.12",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"react-dropzone": "^14.2.3",
|
"react-dropzone": "^14.2.3",
|
||||||
|
"react-error-boundary": "^4.1.2",
|
||||||
|
"react-i18next": "^16.5.3",
|
||||||
"react-markdown": "^10.1.0",
|
"react-markdown": "^10.1.0",
|
||||||
"react-router-dom": "^6.8.1",
|
"react-router-dom": "^6.8.1",
|
||||||
|
"react-syntax-highlighter": "^15.6.1",
|
||||||
|
"rehype-katex": "^7.0.1",
|
||||||
|
"rehype-raw": "^7.0.0",
|
||||||
"remark-gfm": "^4.0.0",
|
"remark-gfm": "^4.0.0",
|
||||||
"sqlite": "^5.1.1",
|
"remark-math": "^6.0.0",
|
||||||
"sqlite3": "^5.1.7",
|
|
||||||
"tailwind-merge": "^3.3.1",
|
"tailwind-merge": "^3.3.1",
|
||||||
|
"web-push": "^3.6.7",
|
||||||
"ws": "^8.14.2"
|
"ws": "^8.14.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@commitlint/cli": "^20.5.0",
|
||||||
|
"@commitlint/config-conventional": "^20.5.0",
|
||||||
|
"@eslint/js": "^9.39.3",
|
||||||
|
"@release-it/conventional-changelog": "^10.0.5",
|
||||||
|
"@types/better-sqlite3": "^7.6.13",
|
||||||
|
"@types/cross-spawn": "^6.0.6",
|
||||||
|
"@types/express": "^5.0.6",
|
||||||
|
"@types/node": "^22.19.7",
|
||||||
"@types/react": "^18.2.43",
|
"@types/react": "^18.2.43",
|
||||||
"@types/react-dom": "^18.2.17",
|
"@types/react-dom": "^18.2.17",
|
||||||
|
"@types/ws": "^8.18.1",
|
||||||
"@vitejs/plugin-react": "^4.6.0",
|
"@vitejs/plugin-react": "^4.6.0",
|
||||||
"auto-changelog": "^2.5.0",
|
"auto-changelog": "^2.5.0",
|
||||||
"autoprefixer": "^10.4.16",
|
"autoprefixer": "^10.4.16",
|
||||||
"concurrently": "^8.2.2",
|
"concurrently": "^8.2.2",
|
||||||
|
"eslint": "^9.39.3",
|
||||||
|
"eslint-import-resolver-typescript": "^4.4.4",
|
||||||
|
"eslint-plugin-boundaries": "^6.0.2",
|
||||||
|
"eslint-plugin-import-x": "^4.16.1",
|
||||||
|
"eslint-plugin-react": "^7.37.5",
|
||||||
|
"eslint-plugin-react-hooks": "^7.0.1",
|
||||||
|
"eslint-plugin-react-refresh": "^0.5.2",
|
||||||
|
"eslint-plugin-tailwindcss": "^3.18.2",
|
||||||
|
"eslint-plugin-unused-imports": "^4.4.1",
|
||||||
|
"globals": "^17.4.0",
|
||||||
|
"husky": "^9.1.7",
|
||||||
|
"lint-staged": "^16.3.2",
|
||||||
"node-gyp": "^10.0.0",
|
"node-gyp": "^10.0.0",
|
||||||
"postcss": "^8.4.32",
|
"postcss": "^8.4.32",
|
||||||
"release-it": "^19.0.5",
|
"release-it": "^19.0.5",
|
||||||
"sharp": "^0.34.2",
|
"sharp": "^0.34.2",
|
||||||
"tailwindcss": "^3.4.0",
|
"tailwindcss": "^3.4.0",
|
||||||
|
"tsc-alias": "^1.8.16",
|
||||||
|
"tsx": "^4.21.0",
|
||||||
|
"typescript": "^5.9.3",
|
||||||
|
"typescript-eslint": "^8.56.1",
|
||||||
"vite": "^7.0.4"
|
"vite": "^7.0.4"
|
||||||
|
},
|
||||||
|
"lint-staged": {
|
||||||
|
"src/**/*.{ts,tsx,js,jsx}": "eslint",
|
||||||
|
"server/**/*.{js,ts}": "eslint"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1
plugins/starter
Submodule
@@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Claude Code UI - API Documentation</title>
|
<title>CloudCLI - API Documentation</title>
|
||||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||||
<link rel="icon" type="image/png" href="/favicon.png" />
|
<link rel="icon" type="image/png" href="/favicon.png" />
|
||||||
|
|
||||||
@@ -418,7 +418,7 @@
|
|||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
<div class="brand-text">
|
<div class="brand-text">
|
||||||
<h1>Claude Code UI</h1>
|
<h1>CloudCLI</h1>
|
||||||
<div class="subtitle">API Documentation</div>
|
<div class="subtitle">API Documentation</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -489,7 +489,7 @@
|
|||||||
<span class="endpoint-path"><span class="api-url">http://localhost:3001</span>/api/agent</span>
|
<span class="endpoint-path"><span class="api-url">http://localhost:3001</span>/api/agent</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p>Trigger an AI agent (Claude or Cursor) to work on a project.</p>
|
<p>Trigger an AI agent (Claude, Cursor, or Codex) to work on a project.</p>
|
||||||
|
|
||||||
<h4>Request Body Parameters</h4>
|
<h4>Request Body Parameters</h4>
|
||||||
<table>
|
<table>
|
||||||
@@ -524,7 +524,7 @@
|
|||||||
<td><code>provider</code></td>
|
<td><code>provider</code></td>
|
||||||
<td>string</td>
|
<td>string</td>
|
||||||
<td><span class="badge badge-optional">Optional</span></td>
|
<td><span class="badge badge-optional">Optional</span></td>
|
||||||
<td><code>claude</code> or <code>cursor</code> (default: <code>claude</code>)</td>
|
<td><code>claude</code>, <code>cursor</code>, or <code>codex</code> (default: <code>claude</code>)</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>stream</code></td>
|
<td><code>stream</code></td>
|
||||||
@@ -536,7 +536,9 @@
|
|||||||
<td><code>model</code></td>
|
<td><code>model</code></td>
|
||||||
<td>string</td>
|
<td>string</td>
|
||||||
<td><span class="badge badge-optional">Optional</span></td>
|
<td><span class="badge badge-optional">Optional</span></td>
|
||||||
<td>Model to use (for Cursor)</td>
|
<td id="model-options-cell">
|
||||||
|
Model identifier for the AI provider (loading from constants...)
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td><code>cleanup</code></td>
|
<td><code>cleanup</code></td>
|
||||||
@@ -818,31 +820,51 @@ data: {"type":"done"}</code></pre>
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script type="module">
|
||||||
|
// Import model constants
|
||||||
|
import { CLAUDE_MODELS, CURSOR_MODELS, CODEX_MODELS } from '/shared/modelConstants.js';
|
||||||
|
|
||||||
// Dynamic URL replacement
|
// Dynamic URL replacement
|
||||||
const apiUrl = window.location.origin;
|
const apiUrl = window.location.origin;
|
||||||
document.querySelectorAll('.api-url').forEach(el => {
|
document.querySelectorAll('.api-url').forEach(el => {
|
||||||
el.textContent = apiUrl;
|
el.textContent = apiUrl;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Dynamically populate model documentation
|
||||||
|
window.addEventListener('DOMContentLoaded', () => {
|
||||||
|
const modelCell = document.getElementById('model-options-cell');
|
||||||
|
if (modelCell) {
|
||||||
|
const claudeModels = CLAUDE_MODELS.OPTIONS.map(m => `<code>${m.value}</code>`).join(', ');
|
||||||
|
const cursorModels = CURSOR_MODELS.OPTIONS.slice(0, 8).map(m => `<code>${m.value}</code>`).join(', ');
|
||||||
|
const codexModels = CODEX_MODELS.OPTIONS.map(m => `<code>${m.value}</code>`).join(', ');
|
||||||
|
|
||||||
|
modelCell.innerHTML = `
|
||||||
|
Model identifier for the AI provider:<br><br>
|
||||||
|
<strong>Claude:</strong> ${claudeModels} (default: <code>${CLAUDE_MODELS.DEFAULT}</code>)<br><br>
|
||||||
|
<strong>Cursor:</strong> ${cursorModels}, and more (default: <code>${CURSOR_MODELS.DEFAULT}</code>)<br><br>
|
||||||
|
<strong>Codex:</strong> ${codexModels} (default: <code>${CODEX_MODELS.DEFAULT}</code>)
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Tab switching
|
// Tab switching
|
||||||
function showTab(tabName) {
|
window.showTab = function(tabName) {
|
||||||
const parentBlock = event.target.closest('.example-block');
|
const parentBlock = event.target.closest('.example-block');
|
||||||
if (!parentBlock) return;
|
if (!parentBlock) return;
|
||||||
|
|
||||||
parentBlock.querySelectorAll('.tab-content').forEach(tab => {
|
parentBlock.querySelectorAll('.tab-content').forEach(tab => {
|
||||||
tab.classList.remove('active');
|
tab.classList.remove('active');
|
||||||
});
|
});
|
||||||
parentBlock.querySelectorAll('.tab-button').forEach(btn => {
|
parentBlock.querySelectorAll('.tab-button').forEach(btn => {
|
||||||
btn.classList.remove('active');
|
btn.classList.remove('active');
|
||||||
});
|
});
|
||||||
|
|
||||||
const targetTab = parentBlock.querySelector('#' + tabName);
|
const targetTab = parentBlock.querySelector('#' + tabName);
|
||||||
if (targetTab) {
|
if (targetTab) {
|
||||||
targetTab.classList.add('active');
|
targetTab.classList.add('active');
|
||||||
event.target.classList.add('active');
|
event.target.classList.add('active');
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- Prism.js -->
|
<!-- Prism.js -->
|
||||||
|
|||||||
3
public/icons/codex-white.svg
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<svg viewBox="100 100 520 520" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M304.246 295.411V249.828C304.246 245.989 305.687 243.109 309.044 241.191L400.692 188.412C413.167 181.215 428.042 177.858 443.394 177.858C500.971 177.858 537.44 222.482 537.44 269.982C537.44 273.34 537.44 277.179 536.959 281.018L441.954 225.358C436.197 222 430.437 222 424.68 225.358L304.246 295.411ZM518.245 472.945V364.024C518.245 357.304 515.364 352.507 509.608 349.149L389.174 279.096L428.519 256.543C431.877 254.626 434.757 254.626 438.115 256.543L529.762 309.323C556.154 324.679 573.905 357.304 573.905 388.971C573.905 425.436 552.315 459.024 518.245 472.941V472.945ZM275.937 376.982L236.592 353.952C233.235 352.034 231.794 349.154 231.794 345.315V239.756C231.794 188.416 271.139 149.548 324.4 149.548C344.555 149.548 363.264 156.268 379.102 168.262L284.578 222.964C278.822 226.321 275.942 231.119 275.942 237.838V376.986L275.937 376.982ZM360.626 425.922L304.246 394.255V327.083L360.626 295.416L417.002 327.083V394.255L360.626 425.922ZM396.852 571.789C376.698 571.789 357.989 565.07 342.151 553.075L436.674 498.374C442.431 495.017 445.311 490.219 445.311 483.499V344.352L485.138 367.382C488.495 369.299 489.936 372.179 489.936 376.018V481.577C489.936 532.917 450.109 571.785 396.852 571.785V571.789ZM283.134 464.79L191.486 412.01C165.094 396.654 147.343 364.029 147.343 332.362C147.343 295.416 169.415 262.309 203.48 248.393V357.791C203.48 364.51 206.361 369.308 212.117 372.665L332.074 442.237L292.729 464.79C289.372 466.707 286.491 466.707 283.134 464.79ZM277.859 543.48C223.639 543.48 183.813 502.695 183.813 452.314C183.813 448.475 184.294 444.636 184.771 440.797L279.295 495.498C285.051 498.856 290.812 498.856 296.568 495.498L417.002 425.927V471.509C417.002 475.349 415.562 478.229 412.204 480.146L320.557 532.926C308.081 540.122 293.206 543.48 277.854 543.48H277.859ZM396.852 600.576C454.911 600.576 503.37 559.313 514.41 504.612C568.149 490.696 602.696 440.315 602.696 388.976C602.696 355.387 588.303 322.762 562.392 299.25C564.791 289.173 566.231 279.096 566.231 269.024C566.231 200.411 510.571 149.067 446.274 149.067C433.322 149.067 420.846 150.984 408.37 155.305C386.775 134.192 357.026 120.758 324.4 120.758C266.342 120.758 217.883 162.02 206.843 216.721C153.104 230.637 118.557 281.018 118.557 332.357C118.557 365.946 132.95 398.571 158.861 422.083C156.462 432.16 155.022 442.237 155.022 452.309C155.022 520.922 210.682 572.266 274.978 572.266C287.931 572.266 300.407 570.349 312.883 566.028C334.473 587.141 364.222 600.576 396.852 600.576Z" fill="white"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 2.5 KiB |
3
public/icons/codex.svg
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<svg viewBox="100 100 520 520" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M304.246 294.611V249.028C304.246 245.189 305.687 242.309 309.044 240.392L400.692 187.612C413.167 180.415 428.042 177.058 443.394 177.058C500.971 177.058 537.44 221.682 537.44 269.182C537.44 272.54 537.44 276.379 536.959 280.218L441.954 224.558C436.197 221.201 430.437 221.201 424.68 224.558L304.246 294.611ZM518.245 472.145V363.224C518.245 356.505 515.364 351.707 509.608 348.349L389.174 278.296L428.519 255.743C431.877 253.826 434.757 253.826 438.115 255.743L529.762 308.523C556.154 323.879 573.905 356.505 573.905 388.171C573.905 424.636 552.315 458.225 518.245 472.141V472.145ZM275.937 376.182L236.592 353.152C233.235 351.235 231.794 348.354 231.794 344.515V238.956C231.794 187.617 271.139 148.749 324.4 148.749C344.555 148.749 363.264 155.468 379.102 167.463L284.578 222.164C278.822 225.521 275.942 230.319 275.942 237.039V376.186L275.937 376.182ZM360.626 425.122L304.246 393.455V326.283L360.626 294.616L417.002 326.283V393.455L360.626 425.122ZM396.852 570.989C376.698 570.989 357.989 564.27 342.151 552.276L436.674 497.574C442.431 494.217 445.311 489.419 445.311 482.699V343.552L485.138 366.582C488.495 368.499 489.936 371.379 489.936 375.219V480.778C489.936 532.117 450.109 570.985 396.852 570.985V570.989ZM283.134 463.99L191.486 411.211C165.094 395.854 147.343 363.229 147.343 331.562C147.343 294.616 169.415 261.509 203.48 247.593V356.991C203.48 363.71 206.361 368.508 212.117 371.866L332.074 441.437L292.729 463.99C289.372 465.907 286.491 465.907 283.134 463.99ZM277.859 542.68C223.639 542.68 183.813 501.895 183.813 451.514C183.813 447.675 184.294 443.836 184.771 439.997L279.295 494.698C285.051 498.056 290.812 498.056 296.568 494.698L417.002 425.127V470.71C417.002 474.549 415.562 477.429 412.204 479.346L320.557 532.126C308.081 539.323 293.206 542.68 277.854 542.68H277.859ZM396.852 599.776C454.911 599.776 503.37 558.513 514.41 503.812C568.149 489.896 602.696 439.515 602.696 388.176C602.696 354.587 588.303 321.962 562.392 298.45C564.791 288.373 566.231 278.296 566.231 268.224C566.231 199.611 510.571 148.267 446.274 148.267C433.322 148.267 420.846 150.184 408.37 154.505C386.775 133.392 357.026 119.958 324.4 119.958C266.342 119.958 217.883 161.22 206.843 215.921C153.104 229.837 118.557 280.218 118.557 331.557C118.557 365.146 132.95 397.771 158.861 421.283C156.462 431.36 155.022 441.437 155.022 451.51C155.022 520.123 210.682 571.466 274.978 571.466C287.931 571.466 300.407 569.549 312.883 565.228C334.473 586.341 364.222 599.776 396.852 599.776Z" fill="currentColor"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 2.5 KiB |
12
public/icons/cursor-white.svg
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<svg id="Ebene_1" xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 466.73 532.09">
|
||||||
|
<!-- Generator: Adobe Illustrator 29.6.1, SVG Export Plug-In . SVG Version: 2.1.1 Build 9) -->
|
||||||
|
<defs>
|
||||||
|
<style>
|
||||||
|
.st0 {
|
||||||
|
fill: #edecec;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</defs>
|
||||||
|
<path class="st0" d="M457.43,125.94L244.42,2.96c-6.84-3.95-15.28-3.95-22.12,0L9.3,125.94c-5.75,3.32-9.3,9.46-9.3,16.11v247.99c0,6.65,3.55,12.79,9.3,16.11l213.01,122.98c6.84,3.95,15.28,3.95,22.12,0l213.01-122.98c5.75-3.32,9.3-9.46,9.3-16.11v-247.99c0-6.65-3.55-12.79-9.3-16.11h-.01ZM444.05,151.99l-205.63,356.16c-1.39,2.4-5.06,1.42-5.06-1.36v-233.21c0-4.66-2.49-8.97-6.53-11.31L24.87,145.67c-2.4-1.39-1.42-5.06,1.36-5.06h411.26c5.84,0,9.49,6.33,6.57,11.39h-.01Z"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 793 B |
1
public/icons/gemini-ai-icon.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><title>Gemini</title><path d="M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z" fill="#3186FF"></path><path d="M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z" fill="url(#lobe-icons-gemini-fill-0)"></path><path d="M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z" fill="url(#lobe-icons-gemini-fill-1)"></path><path d="M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z" fill="url(#lobe-icons-gemini-fill-2)"></path><defs><linearGradient gradientUnits="userSpaceOnUse" id="lobe-icons-gemini-fill-0" x1="7" x2="11" y1="15.5" y2="12"><stop stop-color="#08B962"></stop><stop offset="1" stop-color="#08B962" stop-opacity="0"></stop></linearGradient><linearGradient gradientUnits="userSpaceOnUse" id="lobe-icons-gemini-fill-1" x1="8" x2="11.5" y1="5.5" y2="11"><stop stop-color="#F94543"></stop><stop offset="1" stop-color="#F94543" stop-opacity="0"></stop></linearGradient><linearGradient gradientUnits="userSpaceOnUse" id="lobe-icons-gemini-fill-2" x1="3.5" x2="17.5" y1="13.5" y2="12"><stop stop-color="#FABC12"></stop><stop offset=".46" stop-color="#FABC12" stop-opacity="0"></stop></linearGradient></defs></svg>
|
||||||
|
After Width: | Height: | Size: 2.8 KiB |
@@ -1,19 +0,0 @@
|
|||||||
# PWA Icons Required
|
|
||||||
|
|
||||||
Create the following icon files in this directory:
|
|
||||||
|
|
||||||
- icon-72x72.png
|
|
||||||
- icon-96x96.png
|
|
||||||
- icon-128x128.png
|
|
||||||
- icon-144x144.png
|
|
||||||
- icon-152x152.png
|
|
||||||
- icon-192x192.png
|
|
||||||
- icon-384x384.png
|
|
||||||
- icon-512x512.png
|
|
||||||
|
|
||||||
You can use any icon generator tool or create them manually. The icons should be square and represent your Claude Code UI application.
|
|
||||||
|
|
||||||
For a quick solution, you can:
|
|
||||||
1. Create a simple square PNG icon (512x512)
|
|
||||||
2. Use online tools like realfavicongenerator.net to generate all sizes
|
|
||||||
3. Or use ImageMagick: `convert icon-512x512.png -resize 192x192 icon-192x192.png`
|
|
||||||
BIN
public/logo-128.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
public/logo-256.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
BIN
public/logo-32.png
Normal file
|
After Width: | Height: | Size: 496 B |
BIN
public/logo-512.png
Normal file
|
After Width: | Height: | Size: 9.1 KiB |
BIN
public/logo-64.png
Normal file
|
After Width: | Height: | Size: 870 B |
@@ -1,9 +1,17 @@
|
|||||||
<svg width="32" height="32" viewBox="0 0 32 32" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg
|
||||||
<rect width="32" height="32" rx="8" fill="hsl(262.1 83.3% 57.8%)"/>
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
<path d="M8 9C8 8.44772 8.44772 8 9 8H23C23.5523 8 24 8.44772 24 9V18C24 18.5523 23.5523 19 23 19H12L8 23V9Z"
|
width="32"
|
||||||
stroke="white"
|
height="32"
|
||||||
stroke-width="2"
|
viewBox="0 0 32 32"
|
||||||
stroke-linecap="round"
|
fill="none"
|
||||||
stroke-linejoin="round"
|
>
|
||||||
fill="none"/>
|
<rect width="32" height="32" rx="8" fill="hsl(221.2 83.2% 53.3%)"/>
|
||||||
</svg>
|
<path
|
||||||
|
d="M8 9C8 8.44772 8.44772 8 9 8H23C23.5523 8 24 8.44772 24 9V18C24 18.5523 23.5523 19 23 19H12L8 23V9Z"
|
||||||
|
stroke="white"
|
||||||
|
strokeWidth="2"
|
||||||
|
strokeLinecap="round"
|
||||||
|
strokeLinejoin="round"
|
||||||
|
fill="none"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 422 B After Width: | Height: | Size: 413 B |
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "Claude Code UI",
|
"name": "CloudCLI UI",
|
||||||
"short_name": "Claude UI",
|
"short_name": "CloudCLI UI",
|
||||||
"description": "Claude Code UI web application",
|
"description": "CloudCLI UI web application",
|
||||||
"start_url": "/",
|
"start_url": "/",
|
||||||
"display": "standalone",
|
"display": "standalone",
|
||||||
"background_color": "#ffffff",
|
"background_color": "#ffffff",
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 171 KiB After Width: | Height: | Size: 340 KiB |
|
Before Width: | Height: | Size: 192 KiB After Width: | Height: | Size: 506 KiB |
131
public/sw.js
@@ -1,8 +1,8 @@
|
|||||||
// Service Worker for Claude Code UI PWA
|
// Service Worker for CloudCLI PWA
|
||||||
const CACHE_NAME = 'claude-ui-v1';
|
// Cache only manifest (needed for PWA install). HTML and JS are never pre-cached
|
||||||
|
// so a rebuild + refresh always picks up the latest assets.
|
||||||
|
const CACHE_NAME = 'claude-ui-v2';
|
||||||
const urlsToCache = [
|
const urlsToCache = [
|
||||||
'/',
|
|
||||||
'/index.html',
|
|
||||||
'/manifest.json'
|
'/manifest.json'
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -10,40 +10,115 @@ const urlsToCache = [
|
|||||||
self.addEventListener('install', event => {
|
self.addEventListener('install', event => {
|
||||||
event.waitUntil(
|
event.waitUntil(
|
||||||
caches.open(CACHE_NAME)
|
caches.open(CACHE_NAME)
|
||||||
.then(cache => {
|
.then(cache => cache.addAll(urlsToCache))
|
||||||
return cache.addAll(urlsToCache);
|
|
||||||
})
|
|
||||||
);
|
);
|
||||||
self.skipWaiting();
|
self.skipWaiting();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Fetch event
|
// Fetch event — network-first for everything except hashed assets
|
||||||
self.addEventListener('fetch', event => {
|
self.addEventListener('fetch', event => {
|
||||||
event.respondWith(
|
const url = event.request.url;
|
||||||
caches.match(event.request)
|
|
||||||
.then(response => {
|
// Never intercept API requests or WebSocket upgrades
|
||||||
// Return cached response if found
|
if (url.includes('/api/') || url.includes('/ws')) {
|
||||||
if (response) {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Navigation requests (HTML) — always go to network, no caching
|
||||||
|
if (event.request.mode === 'navigate') {
|
||||||
|
event.respondWith(
|
||||||
|
fetch(event.request).catch(() => caches.match('/manifest.json').then(() =>
|
||||||
|
new Response('<h1>Offline</h1><p>Please check your connection.</p>', {
|
||||||
|
headers: { 'Content-Type': 'text/html' }
|
||||||
|
})
|
||||||
|
))
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hashed assets (JS/CSS in /assets/) — cache-first since filenames change per build
|
||||||
|
if (url.includes('/assets/')) {
|
||||||
|
event.respondWith(
|
||||||
|
caches.match(event.request).then(cached => {
|
||||||
|
if (cached) return cached;
|
||||||
|
return fetch(event.request).then(response => {
|
||||||
|
const clone = response.clone();
|
||||||
|
caches.open(CACHE_NAME).then(cache => cache.put(event.request, clone));
|
||||||
return response;
|
return response;
|
||||||
}
|
});
|
||||||
// Otherwise fetch from network
|
})
|
||||||
return fetch(event.request);
|
);
|
||||||
}
|
return;
|
||||||
)
|
}
|
||||||
|
|
||||||
|
// Everything else — network-first
|
||||||
|
event.respondWith(
|
||||||
|
fetch(event.request).catch(() => caches.match(event.request))
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Activate event
|
// Activate event — purge old caches
|
||||||
self.addEventListener('activate', event => {
|
self.addEventListener('activate', event => {
|
||||||
event.waitUntil(
|
event.waitUntil(
|
||||||
caches.keys().then(cacheNames => {
|
caches.keys().then(cacheNames =>
|
||||||
return Promise.all(
|
Promise.all(
|
||||||
cacheNames.map(cacheName => {
|
cacheNames
|
||||||
if (cacheName !== CACHE_NAME) {
|
.filter(name => name !== CACHE_NAME)
|
||||||
return caches.delete(cacheName);
|
.map(name => caches.delete(name))
|
||||||
}
|
)
|
||||||
})
|
)
|
||||||
);
|
);
|
||||||
|
self.clients.claim();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Push notification event
|
||||||
|
self.addEventListener('push', event => {
|
||||||
|
if (!event.data) return;
|
||||||
|
|
||||||
|
let payload;
|
||||||
|
try {
|
||||||
|
payload = event.data.json();
|
||||||
|
} catch {
|
||||||
|
payload = { title: 'CloudCLI', body: event.data.text() };
|
||||||
|
}
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
body: payload.body || '',
|
||||||
|
icon: '/logo-256.png',
|
||||||
|
badge: '/logo-128.png',
|
||||||
|
data: payload.data || {},
|
||||||
|
tag: payload.data?.tag || `${payload.data?.sessionId || 'global'}:${payload.data?.code || 'default'}`,
|
||||||
|
renotify: true
|
||||||
|
};
|
||||||
|
|
||||||
|
event.waitUntil(
|
||||||
|
self.registration.showNotification(payload.title || 'CloudCLI', options)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Notification click event
|
||||||
|
self.addEventListener('notificationclick', event => {
|
||||||
|
event.notification.close();
|
||||||
|
|
||||||
|
const sessionId = event.notification.data?.sessionId;
|
||||||
|
const provider = event.notification.data?.provider || null;
|
||||||
|
const urlPath = sessionId ? `/session/${sessionId}` : '/';
|
||||||
|
|
||||||
|
event.waitUntil(
|
||||||
|
self.clients.matchAll({ type: 'window', includeUncontrolled: true }).then(async clientList => {
|
||||||
|
for (const client of clientList) {
|
||||||
|
if (client.url.includes(self.location.origin)) {
|
||||||
|
await client.focus();
|
||||||
|
client.postMessage({
|
||||||
|
type: 'notification:navigate',
|
||||||
|
sessionId: sessionId || null,
|
||||||
|
provider,
|
||||||
|
urlPath
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return self.clients.openWindow(urlPath);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
248
redirect-package/README.md
Normal file
@@ -0,0 +1,248 @@
|
|||||||
|
<div align="center">
|
||||||
|
|
||||||
|
> ## This package has moved to [`@cloudcli-ai/cloudcli`](https://www.npmjs.com/package/@cloudcli-ai/cloudcli)
|
||||||
|
>
|
||||||
|
> ```bash
|
||||||
|
> npm install -g @cloudcli-ai/cloudcli
|
||||||
|
> ```
|
||||||
|
>
|
||||||
|
> This package (`@siteboon/claude-code-ui`) is now a thin wrapper that installs the new package automatically.
|
||||||
|
> For new installations, use `@cloudcli-ai/cloudcli` directly.
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
<img src="https://raw.githubusercontent.com/siteboon/claudecodeui/main/public/logo.svg" alt="CloudCLI UI" width="64" height="64">
|
||||||
|
<h1>Cloud CLI (aka Claude Code UI)</h1>
|
||||||
|
<p>A desktop and mobile UI for <a href="https://docs.anthropic.com/en/docs/claude-code">Claude Code</a>, <a href="https://docs.cursor.com/en/cli/overview">Cursor CLI</a>, <a href="https://developers.openai.com/codex">Codex</a>, and <a href="https://geminicli.com/">Gemini-CLI</a>.<br>Use it locally or remotely to view your active projects and sessions from everywhere.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://cloudcli.ai">CloudCLI Cloud</a> · <a href="https://cloudcli.ai/docs">Documentation</a> · <a href="https://discord.gg/buxwujPNRE">Discord</a> · <a href="https://github.com/siteboon/claudecodeui/issues">Bug Reports</a> · <a href="https://github.com/siteboon/claudecodeui/blob/main/CONTRIBUTING.md">Contributing</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://cloudcli.ai"><img src="https://img.shields.io/badge/☁️_CloudCLI_Cloud-Try_Now-0066FF?style=for-the-badge" alt="CloudCLI Cloud"></a>
|
||||||
|
<a href="https://discord.gg/buxwujPNRE"><img src="https://img.shields.io/badge/Discord-Join%20Community-5865F2?style=for-the-badge&logo=discord&logoColor=white" alt="Join our Discord"></a>
|
||||||
|
<br><br>
|
||||||
|
<a href="https://trendshift.io/repositories/15586" target="_blank"><img src="https://trendshift.io/api/badge/repositories/15586" alt="siteboon%2Fclaudecodeui | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Screenshots
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td align="center">
|
||||||
|
<h3>Desktop View</h3>
|
||||||
|
<img src="https://raw.githubusercontent.com/siteboon/claudecodeui/main/public/screenshots/desktop-main.png" alt="Desktop Interface" width="400">
|
||||||
|
<br>
|
||||||
|
<em>Main interface showing project overview and chat</em>
|
||||||
|
</td>
|
||||||
|
<td align="center">
|
||||||
|
<h3>Mobile Experience</h3>
|
||||||
|
<img src="https://raw.githubusercontent.com/siteboon/claudecodeui/main/public/screenshots/mobile-chat.png" alt="Mobile Interface" width="250">
|
||||||
|
<br>
|
||||||
|
<em>Responsive mobile design with touch navigation</em>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="center" colspan="2">
|
||||||
|
<h3>CLI Selection</h3>
|
||||||
|
<img src="https://raw.githubusercontent.com/siteboon/claudecodeui/main/public/screenshots/cli-selection.png" alt="CLI Selection" width="400">
|
||||||
|
<br>
|
||||||
|
<em>Select between Claude Code, Gemini, Cursor CLI and Codex</em>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- **Responsive Design** - Works seamlessly across desktop, tablet, and mobile so you can also use Agents from mobile
|
||||||
|
- **Interactive Chat Interface** - Built-in chat interface for seamless communication with the Agents
|
||||||
|
- **Integrated Shell Terminal** - Direct access to the Agents CLI through built-in shell functionality
|
||||||
|
- **File Explorer** - Interactive file tree with syntax highlighting and live editing
|
||||||
|
- **Git Explorer** - View, stage and commit your changes. You can also switch branches
|
||||||
|
- **Session Management** - Resume conversations, manage multiple sessions, and track history
|
||||||
|
- **Plugin System** - Extend CloudCLI with custom plugins — add new tabs, backend services, and integrations. [Build your own →](https://github.com/cloudcli-ai/cloudcli-plugin-starter)
|
||||||
|
- **TaskMaster AI Integration** *(Optional)* - Advanced project management with AI-powered task planning, PRD parsing, and workflow automation
|
||||||
|
- **Model Compatibility** - Works with Claude, GPT, and Gemini model families (see [`shared/modelConstants.js`](https://github.com/siteboon/claudecodeui/blob/main/shared/modelConstants.js) for the full list of supported models)
|
||||||
|
|
||||||
|
|
||||||
|
## Quick Start
|
||||||
|
|
||||||
|
### CloudCLI Cloud (Recommended)
|
||||||
|
|
||||||
|
The fastest way to get started — no local setup required. Get a fully managed, containerized development environment accessible from the web, mobile app, API, or your favorite IDE.
|
||||||
|
|
||||||
|
**[Get started with CloudCLI Cloud](https://cloudcli.ai)**
|
||||||
|
|
||||||
|
|
||||||
|
### Self-Hosted (Open source)
|
||||||
|
|
||||||
|
Try CloudCLI UI instantly with **npx** (requires **Node.js** v22+):
|
||||||
|
|
||||||
|
```
|
||||||
|
npx @cloudcli-ai/cloudcli
|
||||||
|
```
|
||||||
|
|
||||||
|
Or install **globally** for regular use:
|
||||||
|
|
||||||
|
```
|
||||||
|
npm install -g @cloudcli-ai/cloudcli
|
||||||
|
cloudcli
|
||||||
|
```
|
||||||
|
|
||||||
|
Open `http://localhost:3001` — all your existing sessions are discovered automatically.
|
||||||
|
|
||||||
|
Visit the **[documentation →](https://cloudcli.ai/docs)** for more full configuration options, PM2, remote server setup and more
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Which option is right for you?
|
||||||
|
|
||||||
|
CloudCLI UI is the open source UI layer that powers CloudCLI Cloud. You can self-host it on your own machine, or use CloudCLI Cloud which builds on top of it with a full managed cloud environment, team features, and deeper integrations.
|
||||||
|
|
||||||
|
| | CloudCLI UI (Self-hosted) | CloudCLI Cloud |
|
||||||
|
|---|---|---|
|
||||||
|
| **Best for** | Developers who want a full UI for local agent sessions on their own machine | Teams and developers who want agents running in the cloud, accessible from anywhere |
|
||||||
|
| **How you access it** | Browser via `[yourip]:port` | Browser, any IDE, REST API, n8n |
|
||||||
|
| **Setup** | `npx @cloudcli-ai/cloudcli` | No setup required |
|
||||||
|
| **Machine needs to stay on** | Yes | No |
|
||||||
|
| **Mobile access** | Any browser on your network | Any device, native app coming |
|
||||||
|
| **Sessions available** | All sessions auto-discovered from `~/.claude` | All sessions within your cloud environment |
|
||||||
|
| **Agents supported** | Claude Code, Cursor CLI, Codex, Gemini CLI | Claude Code, Cursor CLI, Codex, Gemini CLI |
|
||||||
|
| **File explorer and Git** | Yes, built into the UI | Yes, built into the UI |
|
||||||
|
| **MCP configuration** | Managed via UI, synced with your local `~/.claude` config | Managed via UI |
|
||||||
|
| **IDE access** | Your local IDE | Any IDE connected to your cloud environment |
|
||||||
|
| **REST API** | Yes | Yes |
|
||||||
|
| **n8n node** | No | Yes |
|
||||||
|
| **Team sharing** | No | Yes |
|
||||||
|
| **Platform cost** | Free, open source | Starts at $7/month |
|
||||||
|
|
||||||
|
> Both options use your own AI subscriptions (Claude, Cursor, etc.) — CloudCLI provides the environment, not the AI.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Security & Tools Configuration
|
||||||
|
|
||||||
|
**Important Notice**: All Claude Code tools are **disabled by default**. This prevents potentially harmful operations from running automatically.
|
||||||
|
|
||||||
|
### Enabling Tools
|
||||||
|
|
||||||
|
To use Claude Code's full functionality, you'll need to manually enable tools:
|
||||||
|
|
||||||
|
1. **Open Tools Settings** - Click the gear icon in the sidebar
|
||||||
|
2. **Enable Selectively** - Turn on only the tools you need
|
||||||
|
3. **Apply Settings** - Your preferences are saved locally
|
||||||
|
|
||||||
|
**Recommended approach**: Start with basic tools enabled and add more as needed. You can always adjust these settings later.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Plugins
|
||||||
|
|
||||||
|
CloudCLI has a plugin system that lets you add custom tabs with their own frontend UI and optional Node.js backend. Install plugins from git repos directly in **Settings > Plugins**, or build your own.
|
||||||
|
|
||||||
|
### Available Plugins
|
||||||
|
|
||||||
|
| Plugin | Description |
|
||||||
|
|---|---|
|
||||||
|
| **[Project Stats](https://github.com/cloudcli-ai/cloudcli-plugin-starter)** | Shows file counts, lines of code, file-type breakdown, largest files, and recently modified files for your current project |
|
||||||
|
| **[Web Terminal](https://github.com/cloudcli-ai/cloudcli-plugin-terminal)** | Full xterm.js terminal with multi-tab support|
|
||||||
|
|
||||||
|
### Build Your Own
|
||||||
|
|
||||||
|
**[Plugin Starter Template →](https://github.com/cloudcli-ai/cloudcli-plugin-starter)** — fork this repo to create your own plugin. It includes a working example with frontend rendering, live context updates, and RPC communication to a backend server.
|
||||||
|
|
||||||
|
**[Plugin Documentation →](https://cloudcli.ai/docs/plugin-overview)** — full guide to the plugin API, manifest format, security model, and more.
|
||||||
|
|
||||||
|
---
|
||||||
|
## FAQ
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>How is this different from Claude Code Remote Control?</summary>
|
||||||
|
|
||||||
|
Claude Code Remote Control lets you send messages to a session already running in your local terminal. Your machine has to stay on, your terminal has to stay open, and sessions time out after roughly 10 minutes without a network connection.
|
||||||
|
|
||||||
|
CloudCLI UI and CloudCLI Cloud extend Claude Code rather than sit alongside it — your MCP servers, permissions, settings, and sessions are the exact same ones Claude Code uses natively. Nothing is duplicated or managed separately.
|
||||||
|
|
||||||
|
Here's what that means in practice:
|
||||||
|
|
||||||
|
- **All your sessions, not just one** — CloudCLI UI auto-discovers every session from your `~/.claude` folder. Remote Control only exposes the single active session to make it available in the Claude mobile app.
|
||||||
|
- **Your settings are your settings** — MCP servers, tool permissions, and project config you change in CloudCLI UI are written directly to your Claude Code config and take effect immediately, and vice versa.
|
||||||
|
- **Works with more agents** — Claude Code, Cursor CLI, Codex, and Gemini CLI, not just Claude Code.
|
||||||
|
- **Full UI, not just a chat window** — file explorer, Git integration, MCP management, and a shell terminal are all built in.
|
||||||
|
- **CloudCLI Cloud runs in the cloud** — close your laptop, the agent keeps running. No terminal to babysit, no machine to keep awake.
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Do I need to pay for an AI subscription separately?</summary>
|
||||||
|
|
||||||
|
Yes. CloudCLI provides the environment, not the AI. You bring your own Claude, Cursor, Codex, or Gemini subscription. CloudCLI Cloud starts at $7/month for the hosted environment on top of that.
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Can I use CloudCLI UI on my phone?</summary>
|
||||||
|
|
||||||
|
Yes. For self-hosted, run the server on your machine and open `[yourip]:port` in any browser on your network. For CloudCLI Cloud, open it from any device — no VPN, no port forwarding, no setup. A native app is also in the works.
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Will changes I make in the UI affect my local Claude Code setup?</summary>
|
||||||
|
|
||||||
|
Yes, for self-hosted. CloudCLI UI reads from and writes to the same `~/.claude` config that Claude Code uses natively. MCP servers you add via the UI show up in Claude Code immediately and vice versa.
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Community & Support
|
||||||
|
|
||||||
|
- **[Documentation](https://cloudcli.ai/docs)** — installation, configuration, features, and troubleshooting
|
||||||
|
- **[Discord](https://discord.gg/buxwujPNRE)** — get help and connect with other users
|
||||||
|
- **[GitHub Issues](https://github.com/siteboon/claudecodeui/issues)** — bug reports and feature requests
|
||||||
|
- **[Contributing Guide](https://github.com/siteboon/claudecodeui/blob/main/CONTRIBUTING.md)** — how to contribute to the project
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
GNU Affero General Public License v3.0 or later (AGPL-3.0-or-later) — see [LICENSE](https://github.com/siteboon/claudecodeui/blob/main/LICENSE) for the full text, including additional terms under Section 7.
|
||||||
|
|
||||||
|
This project is open source and free to use, modify, and distribute under the AGPL-3.0-or-later license. If you modify this software and run it as a network service, you must make your modified source code available to users of that service.
|
||||||
|
|
||||||
|
CloudCLI UI - (https://cloudcli.ai).
|
||||||
|
|
||||||
|
## Acknowledgments
|
||||||
|
|
||||||
|
### Built With
|
||||||
|
- **[Claude Code](https://docs.anthropic.com/en/docs/claude-code)** - Anthropic's official CLI
|
||||||
|
- **[Cursor CLI](https://docs.cursor.com/en/cli/overview)** - Cursor's official CLI
|
||||||
|
- **[Codex](https://developers.openai.com/codex)** - OpenAI Codex
|
||||||
|
- **[Gemini-CLI](https://geminicli.com/)** - Google Gemini CLI
|
||||||
|
- **[React](https://react.dev/)** - User interface library
|
||||||
|
- **[Vite](https://vitejs.dev/)** - Fast build tool and dev server
|
||||||
|
- **[Tailwind CSS](https://tailwindcss.com/)** - Utility-first CSS framework
|
||||||
|
- **[CodeMirror](https://codemirror.net/)** - Advanced code editor
|
||||||
|
- **[TaskMaster AI](https://github.com/eyaltoledano/claude-task-master)** *(Optional)* - AI-powered project management and task planning
|
||||||
|
|
||||||
|
|
||||||
|
### Sponsors
|
||||||
|
- [Siteboon - AI powered website builder](https://siteboon.ai)
|
||||||
|
---
|
||||||
|
|
||||||
|
<div align="center">
|
||||||
|
<strong>Made with care for the Claude Code, Cursor and Codex community.</strong>
|
||||||
|
</div>
|
||||||
2
redirect-package/bin.js
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
import('@cloudcli-ai/cloudcli/dist-server/server/cli.js');
|
||||||
2
redirect-package/index.js
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
export * from '@cloudcli-ai/cloudcli';
|
||||||
|
export { default } from '@cloudcli-ai/cloudcli';
|
||||||
43
redirect-package/package.json
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
{
|
||||||
|
"name": "@siteboon/claude-code-ui",
|
||||||
|
"version": "2.0.0",
|
||||||
|
"description": "This package has moved to @cloudcli-ai/cloudcli",
|
||||||
|
"type": "module",
|
||||||
|
"main": "index.js",
|
||||||
|
"bin": {
|
||||||
|
"claude-code-ui": "./bin.js",
|
||||||
|
"cloudcli": "./bin.js"
|
||||||
|
},
|
||||||
|
"homepage": "https://cloudcli.ai",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/siteboon/claudecodeui.git"
|
||||||
|
},
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/siteboon/claudecodeui/issues"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"claude code",
|
||||||
|
"claude-code",
|
||||||
|
"claude-code-ui",
|
||||||
|
"cloudcli",
|
||||||
|
"codex",
|
||||||
|
"gemini",
|
||||||
|
"gemini-cli",
|
||||||
|
"cursor",
|
||||||
|
"cursor-cli",
|
||||||
|
"anthropic",
|
||||||
|
"openai",
|
||||||
|
"google",
|
||||||
|
"coding-agent",
|
||||||
|
"web-ui",
|
||||||
|
"ui",
|
||||||
|
"mobile IDE"
|
||||||
|
],
|
||||||
|
"author": "CloudCLI UI Contributors",
|
||||||
|
"dependencies": {
|
||||||
|
"@cloudcli-ai/cloudcli": "*"
|
||||||
|
},
|
||||||
|
"deprecated": "This package has been renamed to @cloudcli-ai/cloudcli. Please install @cloudcli-ai/cloudcli instead.",
|
||||||
|
"license": "AGPL-3.0-or-later"
|
||||||
|
}
|
||||||
67
scripts/fix-node-pty.js
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
/**
|
||||||
|
* Fix node-pty spawn-helper permissions on macOS
|
||||||
|
*
|
||||||
|
* This script fixes a known issue with node-pty where the spawn-helper
|
||||||
|
* binary is shipped without execute permissions, causing "posix_spawnp failed" errors.
|
||||||
|
*
|
||||||
|
* @see https://github.com/microsoft/node-pty/issues/850
|
||||||
|
* @module scripts/fix-node-pty
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { promises as fs } from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
|
const __dirname = path.dirname(__filename);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fixes the spawn-helper binary permissions for node-pty on macOS.
|
||||||
|
*
|
||||||
|
* The node-pty package ships the spawn-helper binary without execute permissions
|
||||||
|
* (644 instead of 755), which causes "posix_spawnp failed" errors when trying
|
||||||
|
* to spawn terminal processes.
|
||||||
|
*
|
||||||
|
* This function:
|
||||||
|
* 1. Checks if running on macOS (darwin)
|
||||||
|
* 2. Locates spawn-helper binaries for both arm64 and x64 architectures
|
||||||
|
* 3. Sets execute permissions (755) on each binary found
|
||||||
|
*
|
||||||
|
* @async
|
||||||
|
* @function fixSpawnHelper
|
||||||
|
* @returns {Promise<void>} Resolves when permissions are fixed or skipped
|
||||||
|
* @example
|
||||||
|
* // Run as postinstall script
|
||||||
|
* await fixSpawnHelper();
|
||||||
|
*/
|
||||||
|
async function fixSpawnHelper() {
|
||||||
|
const nodeModulesPath = path.join(__dirname, '..', 'node_modules', 'node-pty', 'prebuilds');
|
||||||
|
|
||||||
|
// Only run on macOS
|
||||||
|
if (process.platform !== 'darwin') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const darwinDirs = ['darwin-arm64', 'darwin-x64'];
|
||||||
|
|
||||||
|
for (const dir of darwinDirs) {
|
||||||
|
const spawnHelperPath = path.join(nodeModulesPath, dir, 'spawn-helper');
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Check if file exists
|
||||||
|
await fs.access(spawnHelperPath);
|
||||||
|
|
||||||
|
// Make it executable (755)
|
||||||
|
await fs.chmod(spawnHelperPath, 0o755);
|
||||||
|
console.log(`[postinstall] Fixed permissions for ${spawnHelperPath}`);
|
||||||
|
} catch (err) {
|
||||||
|
// File doesn't exist or other error - ignore
|
||||||
|
if (err.code !== 'ENOENT') {
|
||||||
|
console.warn(`[postinstall] Warning: Could not fix ${spawnHelperPath}: ${err.message}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fixSpawnHelper().catch(console.error);
|
||||||
@@ -13,12 +13,132 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { query } from '@anthropic-ai/claude-agent-sdk';
|
import { query } from '@anthropic-ai/claude-agent-sdk';
|
||||||
|
import crypto from 'crypto';
|
||||||
import { promises as fs } from 'fs';
|
import { promises as fs } from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
|
import { CLAUDE_MODELS } from '../shared/modelConstants.js';
|
||||||
|
import { resolveClaudeCodeExecutablePath } from './shared/claude-cli-path.js';
|
||||||
|
import {
|
||||||
|
createNotificationEvent,
|
||||||
|
notifyRunFailed,
|
||||||
|
notifyRunStopped,
|
||||||
|
notifyUserIfEnabled
|
||||||
|
} from './services/notification-orchestrator.js';
|
||||||
|
import { sessionsService } from './modules/providers/services/sessions.service.js';
|
||||||
|
import { providerAuthService } from './modules/providers/services/provider-auth.service.js';
|
||||||
|
import { createNormalizedMessage } from './shared/utils.js';
|
||||||
|
|
||||||
// Session tracking: Map of session IDs to active query instances
|
|
||||||
const activeSessions = new Map();
|
const activeSessions = new Map();
|
||||||
|
const pendingToolApprovals = new Map();
|
||||||
|
|
||||||
|
const TOOL_APPROVAL_TIMEOUT_MS = parseInt(process.env.CLAUDE_TOOL_APPROVAL_TIMEOUT_MS, 10) || 55000;
|
||||||
|
|
||||||
|
const TOOLS_REQUIRING_INTERACTION = new Set(['AskUserQuestion', 'ExitPlanMode']);
|
||||||
|
|
||||||
|
function createRequestId() {
|
||||||
|
if (typeof crypto.randomUUID === 'function') {
|
||||||
|
return crypto.randomUUID();
|
||||||
|
}
|
||||||
|
return crypto.randomBytes(16).toString('hex');
|
||||||
|
}
|
||||||
|
|
||||||
|
function waitForToolApproval(requestId, options = {}) {
|
||||||
|
const { timeoutMs = TOOL_APPROVAL_TIMEOUT_MS, signal, onCancel, metadata } = options;
|
||||||
|
|
||||||
|
return new Promise(resolve => {
|
||||||
|
let settled = false;
|
||||||
|
|
||||||
|
const finalize = (decision) => {
|
||||||
|
if (settled) return;
|
||||||
|
settled = true;
|
||||||
|
cleanup();
|
||||||
|
resolve(decision);
|
||||||
|
};
|
||||||
|
|
||||||
|
let timeout;
|
||||||
|
|
||||||
|
const cleanup = () => {
|
||||||
|
pendingToolApprovals.delete(requestId);
|
||||||
|
if (timeout) clearTimeout(timeout);
|
||||||
|
if (signal && abortHandler) {
|
||||||
|
signal.removeEventListener('abort', abortHandler);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// timeoutMs 0 = wait indefinitely (interactive tools)
|
||||||
|
if (timeoutMs > 0) {
|
||||||
|
timeout = setTimeout(() => {
|
||||||
|
onCancel?.('timeout');
|
||||||
|
finalize(null);
|
||||||
|
}, timeoutMs);
|
||||||
|
}
|
||||||
|
|
||||||
|
const abortHandler = () => {
|
||||||
|
onCancel?.('cancelled');
|
||||||
|
finalize({ cancelled: true });
|
||||||
|
};
|
||||||
|
|
||||||
|
if (signal) {
|
||||||
|
if (signal.aborted) {
|
||||||
|
onCancel?.('cancelled');
|
||||||
|
finalize({ cancelled: true });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
signal.addEventListener('abort', abortHandler, { once: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
const resolver = (decision) => {
|
||||||
|
finalize(decision);
|
||||||
|
};
|
||||||
|
// Attach metadata for getPendingApprovalsForSession lookup
|
||||||
|
if (metadata) {
|
||||||
|
Object.assign(resolver, metadata);
|
||||||
|
}
|
||||||
|
pendingToolApprovals.set(requestId, resolver);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function resolveToolApproval(requestId, decision) {
|
||||||
|
const resolver = pendingToolApprovals.get(requestId);
|
||||||
|
if (resolver) {
|
||||||
|
resolver(decision);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Match stored permission entries against a tool + input combo.
|
||||||
|
// This only supports exact tool names and the Bash(command:*) shorthand
|
||||||
|
// used by the UI; it intentionally does not implement full glob semantics,
|
||||||
|
// introduced to stay consistent with the UI's "Allow rule" format.
|
||||||
|
function matchesToolPermission(entry, toolName, input) {
|
||||||
|
if (!entry || !toolName) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry === toolName) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const bashMatch = entry.match(/^Bash\((.+):\*\)$/);
|
||||||
|
if (toolName === 'Bash' && bashMatch) {
|
||||||
|
const allowedPrefix = bashMatch[1];
|
||||||
|
let command = '';
|
||||||
|
|
||||||
|
if (typeof input === 'string') {
|
||||||
|
command = input.trim();
|
||||||
|
} else if (input && typeof input === 'object' && typeof input.command === 'string') {
|
||||||
|
command = input.command.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!command) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return command.startsWith(allowedPrefix);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maps CLI options to SDK-compatible options format
|
* Maps CLI options to SDK-compatible options format
|
||||||
@@ -26,10 +146,18 @@ const activeSessions = new Map();
|
|||||||
* @returns {Object} SDK-compatible options
|
* @returns {Object} SDK-compatible options
|
||||||
*/
|
*/
|
||||||
function mapCliOptionsToSDK(options = {}) {
|
function mapCliOptionsToSDK(options = {}) {
|
||||||
const { sessionId, cwd, toolsSettings, permissionMode, images } = options;
|
const { sessionId, cwd, toolsSettings, permissionMode } = options;
|
||||||
|
|
||||||
const sdkOptions = {};
|
const sdkOptions = {};
|
||||||
|
|
||||||
|
// Forward all host env vars (e.g. ANTHROPIC_BASE_URL) to the subprocess.
|
||||||
|
// Since SDK 0.2.113, options.env replaces process.env instead of overlaying it.
|
||||||
|
sdkOptions.env = { ...process.env };
|
||||||
|
|
||||||
|
// Resolve the executable eagerly on Windows because the SDK uses raw child_process.spawn,
|
||||||
|
// which does not reliably follow npm's shell wrappers like cross-spawn does.
|
||||||
|
sdkOptions.pathToClaudeCodeExecutable = resolveClaudeCodeExecutablePath(process.env.CLAUDE_CLI_PATH);
|
||||||
|
|
||||||
// Map working directory
|
// Map working directory
|
||||||
if (cwd) {
|
if (cwd) {
|
||||||
sdkOptions.cwd = cwd;
|
sdkOptions.cwd = cwd;
|
||||||
@@ -51,33 +179,43 @@ function mapCliOptionsToSDK(options = {}) {
|
|||||||
if (settings.skipPermissions && permissionMode !== 'plan') {
|
if (settings.skipPermissions && permissionMode !== 'plan') {
|
||||||
// When skipping permissions, use bypassPermissions mode
|
// When skipping permissions, use bypassPermissions mode
|
||||||
sdkOptions.permissionMode = 'bypassPermissions';
|
sdkOptions.permissionMode = 'bypassPermissions';
|
||||||
} else {
|
}
|
||||||
// Map allowed tools
|
|
||||||
let allowedTools = [...(settings.allowedTools || [])];
|
|
||||||
|
|
||||||
// Add plan mode default tools
|
let allowedTools = [...(settings.allowedTools || [])];
|
||||||
if (permissionMode === 'plan') {
|
|
||||||
const planModeTools = ['Read', 'Task', 'exit_plan_mode', 'TodoRead', 'TodoWrite'];
|
// Add plan mode default tools
|
||||||
for (const tool of planModeTools) {
|
if (permissionMode === 'plan') {
|
||||||
if (!allowedTools.includes(tool)) {
|
const planModeTools = ['Read', 'Task', 'exit_plan_mode', 'TodoRead', 'TodoWrite', 'WebFetch', 'WebSearch'];
|
||||||
allowedTools.push(tool);
|
for (const tool of planModeTools) {
|
||||||
}
|
if (!allowedTools.includes(tool)) {
|
||||||
|
allowedTools.push(tool);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (allowedTools.length > 0) {
|
|
||||||
sdkOptions.allowedTools = allowedTools;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Map disallowed tools
|
|
||||||
if (settings.disallowedTools && settings.disallowedTools.length > 0) {
|
|
||||||
sdkOptions.disallowedTools = settings.disallowedTools;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sdkOptions.allowedTools = allowedTools;
|
||||||
|
|
||||||
|
// Use the tools preset to make all default built-in tools available (including AskUserQuestion).
|
||||||
|
// This was introduced in SDK 0.1.57. Omitting this preserves existing behavior (all tools available),
|
||||||
|
// but being explicit ensures forward compatibility and clarity.
|
||||||
|
sdkOptions.tools = { type: 'preset', preset: 'claude_code' };
|
||||||
|
|
||||||
|
sdkOptions.disallowedTools = settings.disallowedTools || [];
|
||||||
|
|
||||||
// Map model (default to sonnet)
|
// Map model (default to sonnet)
|
||||||
// Map model (default to sonnet)
|
// Valid models: sonnet, opus, haiku, opusplan, sonnet[1m]
|
||||||
sdkOptions.model = options.model || 'sonnet';
|
sdkOptions.model = options.model || CLAUDE_MODELS.DEFAULT;
|
||||||
|
// Model logged at query start below
|
||||||
|
|
||||||
|
// Map system prompt configuration
|
||||||
|
sdkOptions.systemPrompt = {
|
||||||
|
type: 'preset',
|
||||||
|
preset: 'claude_code' // Required to use CLAUDE.md
|
||||||
|
};
|
||||||
|
|
||||||
|
// Map setting sources for CLAUDE.md loading
|
||||||
|
// This loads CLAUDE.md from project, user (~/.config/claude/CLAUDE.md), and local directories
|
||||||
|
sdkOptions.settingSources = ['project', 'user', 'local'];
|
||||||
|
|
||||||
// Map resume session
|
// Map resume session
|
||||||
if (sessionId) {
|
if (sessionId) {
|
||||||
@@ -94,13 +232,14 @@ function mapCliOptionsToSDK(options = {}) {
|
|||||||
* @param {Array<string>} tempImagePaths - Temp image file paths for cleanup
|
* @param {Array<string>} tempImagePaths - Temp image file paths for cleanup
|
||||||
* @param {string} tempDir - Temp directory for cleanup
|
* @param {string} tempDir - Temp directory for cleanup
|
||||||
*/
|
*/
|
||||||
function addSession(sessionId, queryInstance, tempImagePaths = [], tempDir = null) {
|
function addSession(sessionId, queryInstance, tempImagePaths = [], tempDir = null, writer = null) {
|
||||||
activeSessions.set(sessionId, {
|
activeSessions.set(sessionId, {
|
||||||
instance: queryInstance,
|
instance: queryInstance,
|
||||||
startTime: Date.now(),
|
startTime: Date.now(),
|
||||||
status: 'active',
|
status: 'active',
|
||||||
tempImagePaths,
|
tempImagePaths,
|
||||||
tempDir
|
tempDir,
|
||||||
|
writer
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,9 +274,13 @@ function getAllSessions() {
|
|||||||
* @returns {Object} Transformed message ready for WebSocket
|
* @returns {Object} Transformed message ready for WebSocket
|
||||||
*/
|
*/
|
||||||
function transformMessage(sdkMessage) {
|
function transformMessage(sdkMessage) {
|
||||||
// SDK messages are already in a format compatible with the frontend
|
// Extract parent_tool_use_id for subagent tool grouping
|
||||||
// The CLI sends them wrapped in {type: 'claude-response', data: message}
|
if (sdkMessage.parent_tool_use_id) {
|
||||||
// We'll do the same here to maintain compatibility
|
return {
|
||||||
|
...sdkMessage,
|
||||||
|
parentToolUseId: sdkMessage.parent_tool_use_id
|
||||||
|
};
|
||||||
|
}
|
||||||
return sdkMessage;
|
return sdkMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,7 +316,7 @@ function extractTokenBudget(resultMessage) {
|
|||||||
// This is the user's budget limit, not the model's context window
|
// This is the user's budget limit, not the model's context window
|
||||||
const contextWindow = parseInt(process.env.CONTEXT_WINDOW) || 160000;
|
const contextWindow = parseInt(process.env.CONTEXT_WINDOW) || 160000;
|
||||||
|
|
||||||
console.log(`📊 Token calculation: input=${inputTokens}, output=${outputTokens}, cache=${cacheReadTokens + cacheCreationTokens}, total=${totalUsed}/${contextWindow}`);
|
// Token calc logged via token-budget WS event
|
||||||
|
|
||||||
return {
|
return {
|
||||||
used: totalUsed,
|
used: totalUsed,
|
||||||
@@ -229,7 +372,7 @@ async function handleImages(command, images, cwd) {
|
|||||||
modifiedCommand = command + imageNote;
|
modifiedCommand = command + imageNote;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`📸 Processed ${tempImagePaths.length} images to temp directory: ${tempDir}`);
|
// Images processed
|
||||||
return { modifiedCommand, tempImagePaths, tempDir };
|
return { modifiedCommand, tempImagePaths, tempDir };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error processing images for SDK:', error);
|
console.error('Error processing images for SDK:', error);
|
||||||
@@ -262,7 +405,7 @@ async function cleanupTempFiles(tempImagePaths, tempDir) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`🧹 Cleaned up ${tempImagePaths.length} temp image files`);
|
// Temp files cleaned
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error during temp file cleanup:', error);
|
console.error('Error during temp file cleanup:', error);
|
||||||
}
|
}
|
||||||
@@ -282,7 +425,7 @@ async function loadMcpConfig(cwd) {
|
|||||||
await fs.access(claudeConfigPath);
|
await fs.access(claudeConfigPath);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// File doesn't exist, return null
|
// File doesn't exist, return null
|
||||||
console.log('📡 No ~/.claude.json found, proceeding without MCP servers');
|
// No config file
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,7 +435,7 @@ async function loadMcpConfig(cwd) {
|
|||||||
const configContent = await fs.readFile(claudeConfigPath, 'utf8');
|
const configContent = await fs.readFile(claudeConfigPath, 'utf8');
|
||||||
claudeConfig = JSON.parse(configContent);
|
claudeConfig = JSON.parse(configContent);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('❌ Failed to parse ~/.claude.json:', error.message);
|
console.error('Failed to parse ~/.claude.json:', error.message);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -302,7 +445,7 @@ async function loadMcpConfig(cwd) {
|
|||||||
// Add global MCP servers
|
// Add global MCP servers
|
||||||
if (claudeConfig.mcpServers && typeof claudeConfig.mcpServers === 'object') {
|
if (claudeConfig.mcpServers && typeof claudeConfig.mcpServers === 'object') {
|
||||||
mcpServers = { ...claudeConfig.mcpServers };
|
mcpServers = { ...claudeConfig.mcpServers };
|
||||||
console.log(`📡 Loaded ${Object.keys(mcpServers).length} global MCP servers`);
|
// Global MCP servers loaded
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add/override with project-specific MCP servers
|
// Add/override with project-specific MCP servers
|
||||||
@@ -310,20 +453,17 @@ async function loadMcpConfig(cwd) {
|
|||||||
const projectConfig = claudeConfig.claudeProjects[cwd];
|
const projectConfig = claudeConfig.claudeProjects[cwd];
|
||||||
if (projectConfig && projectConfig.mcpServers && typeof projectConfig.mcpServers === 'object') {
|
if (projectConfig && projectConfig.mcpServers && typeof projectConfig.mcpServers === 'object') {
|
||||||
mcpServers = { ...mcpServers, ...projectConfig.mcpServers };
|
mcpServers = { ...mcpServers, ...projectConfig.mcpServers };
|
||||||
console.log(`📡 Loaded ${Object.keys(projectConfig.mcpServers).length} project-specific MCP servers`);
|
// Project MCP servers merged
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return null if no servers found
|
// Return null if no servers found
|
||||||
if (Object.keys(mcpServers).length === 0) {
|
if (Object.keys(mcpServers).length === 0) {
|
||||||
console.log('📡 No MCP servers configured');
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`✅ Total MCP servers loaded: ${Object.keys(mcpServers).length}`);
|
|
||||||
return mcpServers;
|
return mcpServers;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('❌ Error loading MCP config:', error.message);
|
console.error('Error loading MCP config:', error.message);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -336,12 +476,20 @@ async function loadMcpConfig(cwd) {
|
|||||||
* @returns {Promise<void>}
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
async function queryClaudeSDK(command, options = {}, ws) {
|
async function queryClaudeSDK(command, options = {}, ws) {
|
||||||
const { sessionId } = options;
|
const { sessionId, sessionSummary } = options;
|
||||||
let capturedSessionId = sessionId;
|
let capturedSessionId = sessionId;
|
||||||
let sessionCreatedSent = false;
|
let sessionCreatedSent = false;
|
||||||
let tempImagePaths = [];
|
let tempImagePaths = [];
|
||||||
let tempDir = null;
|
let tempDir = null;
|
||||||
|
|
||||||
|
const emitNotification = (event) => {
|
||||||
|
notifyUserIfEnabled({
|
||||||
|
userId: ws?.userId || null,
|
||||||
|
writer: ws,
|
||||||
|
event
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Map CLI options to SDK format
|
// Map CLI options to SDK format
|
||||||
const sdkOptions = mapCliOptionsToSDK(options);
|
const sdkOptions = mapCliOptionsToSDK(options);
|
||||||
@@ -358,25 +506,145 @@ async function queryClaudeSDK(command, options = {}, ws) {
|
|||||||
tempImagePaths = imageResult.tempImagePaths;
|
tempImagePaths = imageResult.tempImagePaths;
|
||||||
tempDir = imageResult.tempDir;
|
tempDir = imageResult.tempDir;
|
||||||
|
|
||||||
// Create SDK query instance
|
sdkOptions.hooks = {
|
||||||
const queryInstance = query({
|
Notification: [{
|
||||||
prompt: finalCommand,
|
matcher: '',
|
||||||
options: sdkOptions
|
hooks: [async (input) => {
|
||||||
});
|
const message = typeof input?.message === 'string' ? input.message : 'Claude requires your attention.';
|
||||||
|
emitNotification(createNotificationEvent({
|
||||||
|
provider: 'claude',
|
||||||
|
sessionId: capturedSessionId || sessionId || null,
|
||||||
|
kind: 'action_required',
|
||||||
|
code: 'agent.notification',
|
||||||
|
meta: { message, sessionName: sessionSummary },
|
||||||
|
severity: 'warning',
|
||||||
|
requiresUserAction: true,
|
||||||
|
dedupeKey: `claude:hook:notification:${capturedSessionId || sessionId || 'none'}:${message}`
|
||||||
|
}));
|
||||||
|
return {};
|
||||||
|
}]
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
|
||||||
|
// Caveat: in 'auto' and 'bypassPermissions' modes the SDK resolves approval
|
||||||
|
// at the permission-mode step and skips this callback, so interactive tools
|
||||||
|
// (AskUserQuestion, ExitPlanMode) won't reach the UI — the classifier/bypass
|
||||||
|
// auto-approves them and the model acts on a generated answer. Move these
|
||||||
|
// tools to a PreToolUse hook (runs before the mode check) if we need them
|
||||||
|
// to work in those modes.
|
||||||
|
sdkOptions.canUseTool = async (toolName, input, context) => {
|
||||||
|
const requiresInteraction = TOOLS_REQUIRING_INTERACTION.has(toolName);
|
||||||
|
|
||||||
|
if (!requiresInteraction) {
|
||||||
|
if (sdkOptions.permissionMode === 'bypassPermissions') {
|
||||||
|
return { behavior: 'allow', updatedInput: input };
|
||||||
|
}
|
||||||
|
|
||||||
|
const isDisallowed = (sdkOptions.disallowedTools || []).some(entry =>
|
||||||
|
matchesToolPermission(entry, toolName, input)
|
||||||
|
);
|
||||||
|
if (isDisallowed) {
|
||||||
|
return { behavior: 'deny', message: 'Tool disallowed by settings' };
|
||||||
|
}
|
||||||
|
|
||||||
|
const isAllowed = (sdkOptions.allowedTools || []).some(entry =>
|
||||||
|
matchesToolPermission(entry, toolName, input)
|
||||||
|
);
|
||||||
|
if (isAllowed) {
|
||||||
|
return { behavior: 'allow', updatedInput: input };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const requestId = createRequestId();
|
||||||
|
ws.send(createNormalizedMessage({ kind: 'permission_request', requestId, toolName, input, sessionId: capturedSessionId || sessionId || null, provider: 'claude' }));
|
||||||
|
emitNotification(createNotificationEvent({
|
||||||
|
provider: 'claude',
|
||||||
|
sessionId: capturedSessionId || sessionId || null,
|
||||||
|
kind: 'action_required',
|
||||||
|
code: 'permission.required',
|
||||||
|
meta: { toolName, sessionName: sessionSummary },
|
||||||
|
severity: 'warning',
|
||||||
|
requiresUserAction: true,
|
||||||
|
dedupeKey: `claude:permission:${capturedSessionId || sessionId || 'none'}:${requestId}`
|
||||||
|
}));
|
||||||
|
|
||||||
|
const decision = await waitForToolApproval(requestId, {
|
||||||
|
timeoutMs: requiresInteraction ? 0 : undefined,
|
||||||
|
signal: context?.signal,
|
||||||
|
metadata: {
|
||||||
|
_sessionId: capturedSessionId || sessionId || null,
|
||||||
|
_toolName: toolName,
|
||||||
|
_input: input,
|
||||||
|
_receivedAt: new Date(),
|
||||||
|
},
|
||||||
|
onCancel: (reason) => {
|
||||||
|
ws.send(createNormalizedMessage({ kind: 'permission_cancelled', requestId, reason, sessionId: capturedSessionId || sessionId || null, provider: 'claude' }));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (!decision) {
|
||||||
|
return { behavior: 'deny', message: 'Permission request timed out' };
|
||||||
|
}
|
||||||
|
|
||||||
|
if (decision.cancelled) {
|
||||||
|
return { behavior: 'deny', message: 'Permission request cancelled' };
|
||||||
|
}
|
||||||
|
|
||||||
|
if (decision.allow) {
|
||||||
|
if (decision.rememberEntry && typeof decision.rememberEntry === 'string') {
|
||||||
|
if (!sdkOptions.allowedTools.includes(decision.rememberEntry)) {
|
||||||
|
sdkOptions.allowedTools.push(decision.rememberEntry);
|
||||||
|
}
|
||||||
|
if (Array.isArray(sdkOptions.disallowedTools)) {
|
||||||
|
sdkOptions.disallowedTools = sdkOptions.disallowedTools.filter(entry => entry !== decision.rememberEntry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return { behavior: 'allow', updatedInput: decision.updatedInput ?? input };
|
||||||
|
}
|
||||||
|
|
||||||
|
return { behavior: 'deny', message: decision.message ?? 'User denied tool use' };
|
||||||
|
};
|
||||||
|
|
||||||
|
// Set stream-close timeout for interactive tools (Query constructor reads it synchronously). Claude Agent SDK has a default of 5s and this overrides it
|
||||||
|
const prevStreamTimeout = process.env.CLAUDE_CODE_STREAM_CLOSE_TIMEOUT;
|
||||||
|
process.env.CLAUDE_CODE_STREAM_CLOSE_TIMEOUT = '300000';
|
||||||
|
|
||||||
|
let queryInstance;
|
||||||
|
try {
|
||||||
|
queryInstance = query({
|
||||||
|
prompt: finalCommand,
|
||||||
|
options: sdkOptions
|
||||||
|
});
|
||||||
|
} catch (hookError) {
|
||||||
|
// Older/newer SDK versions may not accept hook shapes yet.
|
||||||
|
// Keep notification behavior operational via runtime events even if hook registration fails.
|
||||||
|
console.warn('Failed to initialize Claude query with hooks, retrying without hooks:', hookError?.message || hookError);
|
||||||
|
delete sdkOptions.hooks;
|
||||||
|
queryInstance = query({
|
||||||
|
prompt: finalCommand,
|
||||||
|
options: sdkOptions
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Restore immediately — Query constructor already captured the value
|
||||||
|
if (prevStreamTimeout !== undefined) {
|
||||||
|
process.env.CLAUDE_CODE_STREAM_CLOSE_TIMEOUT = prevStreamTimeout;
|
||||||
|
} else {
|
||||||
|
delete process.env.CLAUDE_CODE_STREAM_CLOSE_TIMEOUT;
|
||||||
|
}
|
||||||
|
|
||||||
// Track the query instance for abort capability
|
// Track the query instance for abort capability
|
||||||
if (capturedSessionId) {
|
if (capturedSessionId) {
|
||||||
addSession(capturedSessionId, queryInstance, tempImagePaths, tempDir);
|
addSession(capturedSessionId, queryInstance, tempImagePaths, tempDir, ws);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process streaming messages
|
// Process streaming messages
|
||||||
console.log('🔄 Starting async generator loop for session:', capturedSessionId || 'NEW');
|
console.log('Starting async generator loop for session:', capturedSessionId || 'NEW');
|
||||||
for await (const message of queryInstance) {
|
for await (const message of queryInstance) {
|
||||||
// Capture session ID from first message
|
// Capture session ID from first message
|
||||||
if (message.session_id && !capturedSessionId) {
|
if (message.session_id && !capturedSessionId) {
|
||||||
console.log('📝 Captured session ID:', message.session_id);
|
|
||||||
capturedSessionId = message.session_id;
|
capturedSessionId = message.session_id;
|
||||||
addSession(capturedSessionId, queryInstance, tempImagePaths, tempDir);
|
addSession(capturedSessionId, queryInstance, tempImagePaths, tempDir, ws);
|
||||||
|
|
||||||
// Set session ID on writer
|
// Set session ID on writer
|
||||||
if (ws.setSessionId && typeof ws.setSessionId === 'function') {
|
if (ws.setSessionId && typeof ws.setSessionId === 'function') {
|
||||||
@@ -386,33 +654,35 @@ async function queryClaudeSDK(command, options = {}, ws) {
|
|||||||
// Send session-created event only once for new sessions
|
// Send session-created event only once for new sessions
|
||||||
if (!sessionId && !sessionCreatedSent) {
|
if (!sessionId && !sessionCreatedSent) {
|
||||||
sessionCreatedSent = true;
|
sessionCreatedSent = true;
|
||||||
ws.send(JSON.stringify({
|
ws.send(createNormalizedMessage({ kind: 'session_created', newSessionId: capturedSessionId, sessionId: capturedSessionId, provider: 'claude' }));
|
||||||
type: 'session-created',
|
|
||||||
sessionId: capturedSessionId
|
|
||||||
}));
|
|
||||||
} else {
|
|
||||||
console.log('⚠️ Not sending session-created. sessionId:', sessionId, 'sessionCreatedSent:', sessionCreatedSent);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log('⚠️ No session_id in message or already captured. message.session_id:', message.session_id, 'capturedSessionId:', capturedSessionId);
|
// session_id already captured
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transform and send message to WebSocket
|
// Transform and normalize message via adapter
|
||||||
const transformedMessage = transformMessage(message);
|
const transformedMessage = transformMessage(message);
|
||||||
ws.send(JSON.stringify({
|
const sid = capturedSessionId || sessionId || null;
|
||||||
type: 'claude-response',
|
|
||||||
data: transformedMessage
|
// Use adapter to normalize SDK events into NormalizedMessage[]
|
||||||
}));
|
const normalized = sessionsService.normalizeMessage('claude', transformedMessage, sid);
|
||||||
|
for (const msg of normalized) {
|
||||||
|
// Preserve parentToolUseId from SDK wrapper for subagent tool grouping
|
||||||
|
if (transformedMessage.parentToolUseId && !msg.parentToolUseId) {
|
||||||
|
msg.parentToolUseId = transformedMessage.parentToolUseId;
|
||||||
|
}
|
||||||
|
ws.send(msg);
|
||||||
|
}
|
||||||
|
|
||||||
// Extract and send token budget updates from result messages
|
// Extract and send token budget updates from result messages
|
||||||
if (message.type === 'result') {
|
if (message.type === 'result') {
|
||||||
const tokenBudget = extractTokenBudget(message);
|
const models = Object.keys(message.modelUsage || {});
|
||||||
if (tokenBudget) {
|
if (models.length > 0) {
|
||||||
console.log('📊 Token budget from modelUsage:', tokenBudget);
|
// Model info available in result message
|
||||||
ws.send(JSON.stringify({
|
}
|
||||||
type: 'token-budget',
|
const tokenBudgetData = extractTokenBudget(message);
|
||||||
data: tokenBudget
|
if (tokenBudgetData) {
|
||||||
}));
|
ws.send(createNormalizedMessage({ kind: 'status', text: 'token_budget', tokenBudget: tokenBudgetData, sessionId: capturedSessionId || sessionId || null, provider: 'claude' }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -426,14 +696,15 @@ async function queryClaudeSDK(command, options = {}, ws) {
|
|||||||
await cleanupTempFiles(tempImagePaths, tempDir);
|
await cleanupTempFiles(tempImagePaths, tempDir);
|
||||||
|
|
||||||
// Send completion event
|
// Send completion event
|
||||||
console.log('✅ Streaming complete, sending claude-complete event');
|
ws.send(createNormalizedMessage({ kind: 'complete', exitCode: 0, isNewSession: !sessionId && !!command, sessionId: capturedSessionId, provider: 'claude' }));
|
||||||
ws.send(JSON.stringify({
|
notifyRunStopped({
|
||||||
type: 'claude-complete',
|
userId: ws?.userId || null,
|
||||||
sessionId: capturedSessionId,
|
provider: 'claude',
|
||||||
exitCode: 0,
|
sessionId: capturedSessionId || sessionId || null,
|
||||||
isNewSession: !sessionId && !!command
|
sessionName: sessionSummary,
|
||||||
}));
|
stopReason: 'completed'
|
||||||
console.log('📤 claude-complete event sent');
|
});
|
||||||
|
// Complete
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('SDK query error:', error);
|
console.error('SDK query error:', error);
|
||||||
@@ -446,13 +717,21 @@ async function queryClaudeSDK(command, options = {}, ws) {
|
|||||||
// Clean up temporary image files on error
|
// Clean up temporary image files on error
|
||||||
await cleanupTempFiles(tempImagePaths, tempDir);
|
await cleanupTempFiles(tempImagePaths, tempDir);
|
||||||
|
|
||||||
// Send error to WebSocket
|
// Check if Claude CLI is installed for a clearer error message
|
||||||
ws.send(JSON.stringify({
|
const installed = await providerAuthService.isProviderInstalled('claude');
|
||||||
type: 'claude-error',
|
const errorContent = !installed
|
||||||
error: error.message
|
? 'Claude Code is not installed. Please install it first: https://docs.anthropic.com/en/docs/claude-code'
|
||||||
}));
|
: error.message;
|
||||||
|
|
||||||
throw error;
|
// Send error to WebSocket
|
||||||
|
ws.send(createNormalizedMessage({ kind: 'error', content: errorContent, sessionId: capturedSessionId || sessionId || null, provider: 'claude' }));
|
||||||
|
notifyRunFailed({
|
||||||
|
userId: ws?.userId || null,
|
||||||
|
provider: 'claude',
|
||||||
|
sessionId: capturedSessionId || sessionId || null,
|
||||||
|
sessionName: sessionSummary,
|
||||||
|
error
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -470,7 +749,7 @@ async function abortClaudeSDKSession(sessionId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
console.log(`🛑 Aborting SDK session: ${sessionId}`);
|
console.log(`Aborting SDK session: ${sessionId}`);
|
||||||
|
|
||||||
// Call interrupt() on the query instance
|
// Call interrupt() on the query instance
|
||||||
await session.instance.interrupt();
|
await session.instance.interrupt();
|
||||||
@@ -509,10 +788,50 @@ function getActiveClaudeSDKSessions() {
|
|||||||
return getAllSessions();
|
return getAllSessions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get pending tool approvals for a specific session.
|
||||||
|
* @param {string} sessionId - The session ID
|
||||||
|
* @returns {Array} Array of pending permission request objects
|
||||||
|
*/
|
||||||
|
function getPendingApprovalsForSession(sessionId) {
|
||||||
|
const pending = [];
|
||||||
|
for (const [requestId, resolver] of pendingToolApprovals.entries()) {
|
||||||
|
if (resolver._sessionId === sessionId) {
|
||||||
|
pending.push({
|
||||||
|
requestId,
|
||||||
|
toolName: resolver._toolName || 'UnknownTool',
|
||||||
|
input: resolver._input,
|
||||||
|
context: resolver._context,
|
||||||
|
sessionId,
|
||||||
|
receivedAt: resolver._receivedAt || new Date(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pending;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reconnect a session's WebSocketWriter to a new raw WebSocket.
|
||||||
|
* Called when client reconnects (e.g. page refresh) while SDK is still running.
|
||||||
|
* @param {string} sessionId - The session ID
|
||||||
|
* @param {Object} newRawWs - The new raw WebSocket connection
|
||||||
|
* @returns {boolean} True if writer was successfully reconnected
|
||||||
|
*/
|
||||||
|
function reconnectSessionWriter(sessionId, newRawWs) {
|
||||||
|
const session = getSession(sessionId);
|
||||||
|
if (!session?.writer?.updateWebSocket) return false;
|
||||||
|
session.writer.updateWebSocket(newRawWs);
|
||||||
|
console.log(`[RECONNECT] Writer swapped for session ${sessionId}`);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Export public API
|
// Export public API
|
||||||
export {
|
export {
|
||||||
queryClaudeSDK,
|
queryClaudeSDK,
|
||||||
abortClaudeSDKSession,
|
abortClaudeSDKSession,
|
||||||
isClaudeSDKSessionActive,
|
isClaudeSDKSessionActive,
|
||||||
getActiveClaudeSDKSessions
|
getActiveClaudeSDKSessions,
|
||||||
|
resolveToolApproval,
|
||||||
|
getPendingApprovalsForSession,
|
||||||
|
reconnectSessionWriter
|
||||||
};
|
};
|
||||||
|
|||||||
689
server/cli.js
Executable file
@@ -0,0 +1,689 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
/**
|
||||||
|
* CloudCLI CLI
|
||||||
|
*
|
||||||
|
* Provides command-line utilities for managing CloudCLI
|
||||||
|
*
|
||||||
|
* Commands:
|
||||||
|
* (no args) - Start the server (default)
|
||||||
|
* start - Start the server
|
||||||
|
* sandbox - Manage Docker sandbox environments
|
||||||
|
* status - Show configuration and data locations
|
||||||
|
* help - Show help information
|
||||||
|
* version - Show version information
|
||||||
|
*/
|
||||||
|
|
||||||
|
import fs from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
import os from 'os';
|
||||||
|
import { findAppRoot, getModuleDir } from './utils/runtime-paths.js';
|
||||||
|
|
||||||
|
const __dirname = getModuleDir(import.meta.url);
|
||||||
|
// The CLI is compiled into dist-server/server, but it still needs to read the top-level
|
||||||
|
// package.json and .env file. Resolving the app root once keeps those lookups stable.
|
||||||
|
const APP_ROOT = findAppRoot(__dirname);
|
||||||
|
|
||||||
|
// ANSI color codes for terminal output
|
||||||
|
const colors = {
|
||||||
|
reset: '\x1b[0m',
|
||||||
|
bright: '\x1b[1m',
|
||||||
|
dim: '\x1b[2m',
|
||||||
|
|
||||||
|
// Foreground colors
|
||||||
|
cyan: '\x1b[36m',
|
||||||
|
green: '\x1b[32m',
|
||||||
|
yellow: '\x1b[33m',
|
||||||
|
blue: '\x1b[34m',
|
||||||
|
magenta: '\x1b[35m',
|
||||||
|
white: '\x1b[37m',
|
||||||
|
gray: '\x1b[90m',
|
||||||
|
};
|
||||||
|
|
||||||
|
// Helper to colorize text
|
||||||
|
const c = {
|
||||||
|
info: (text) => `${colors.cyan}${text}${colors.reset}`,
|
||||||
|
ok: (text) => `${colors.green}${text}${colors.reset}`,
|
||||||
|
warn: (text) => `${colors.yellow}${text}${colors.reset}`,
|
||||||
|
error: (text) => `${colors.yellow}${text}${colors.reset}`,
|
||||||
|
tip: (text) => `${colors.blue}${text}${colors.reset}`,
|
||||||
|
bright: (text) => `${colors.bright}${text}${colors.reset}`,
|
||||||
|
dim: (text) => `${colors.dim}${text}${colors.reset}`,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Load package.json for version info
|
||||||
|
const packageJsonPath = path.join(APP_ROOT, 'package.json');
|
||||||
|
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
||||||
|
// Match the runtime fallback in load-env.js so "cloudcli status" reports the same default
|
||||||
|
// database location that the backend will actually use when no DATABASE_PATH is configured.
|
||||||
|
const DEFAULT_DATABASE_PATH = path.join(os.homedir(), '.cloudcli', 'auth.db');
|
||||||
|
|
||||||
|
// Load environment variables from .env file if it exists
|
||||||
|
function loadEnvFile() {
|
||||||
|
try {
|
||||||
|
const envPath = path.join(APP_ROOT, '.env');
|
||||||
|
const envFile = fs.readFileSync(envPath, 'utf8');
|
||||||
|
envFile.split('\n').forEach(line => {
|
||||||
|
const trimmedLine = line.trim();
|
||||||
|
if (trimmedLine && !trimmedLine.startsWith('#')) {
|
||||||
|
const [key, ...valueParts] = trimmedLine.split('=');
|
||||||
|
if (key && valueParts.length > 0 && !process.env[key]) {
|
||||||
|
process.env[key] = valueParts.join('=').trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
// .env file is optional
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the database path (same logic as db.js)
|
||||||
|
function getDatabasePath() {
|
||||||
|
loadEnvFile();
|
||||||
|
return process.env.DATABASE_PATH || DEFAULT_DATABASE_PATH;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the installation directory
|
||||||
|
function getInstallDir() {
|
||||||
|
return APP_ROOT;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show status command
|
||||||
|
function showStatus() {
|
||||||
|
console.log(`\n${c.bright('CloudCLI UI - Status')}\n`);
|
||||||
|
console.log(c.dim('═'.repeat(60)));
|
||||||
|
|
||||||
|
// Version info
|
||||||
|
console.log(`\n${c.info('[INFO]')} Version: ${c.bright(packageJson.version)}`);
|
||||||
|
|
||||||
|
// Installation location
|
||||||
|
const installDir = getInstallDir();
|
||||||
|
console.log(`\n${c.info('[INFO]')} Installation Directory:`);
|
||||||
|
console.log(` ${c.dim(installDir)}`);
|
||||||
|
|
||||||
|
// Database location
|
||||||
|
const dbPath = getDatabasePath();
|
||||||
|
const dbExists = fs.existsSync(dbPath);
|
||||||
|
console.log(`\n${c.info('[INFO]')} Database Location:`);
|
||||||
|
console.log(` ${c.dim(dbPath)}`);
|
||||||
|
console.log(` Status: ${dbExists ? c.ok('[OK] Exists') : c.warn('[WARN] Not created yet (will be created on first run)')}`);
|
||||||
|
|
||||||
|
if (dbExists) {
|
||||||
|
const stats = fs.statSync(dbPath);
|
||||||
|
console.log(` Size: ${c.dim((stats.size / 1024).toFixed(2) + ' KB')}`);
|
||||||
|
console.log(` Modified: ${c.dim(stats.mtime.toLocaleString())}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Environment variables
|
||||||
|
console.log(`\n${c.info('[INFO]')} Configuration:`);
|
||||||
|
console.log(` SERVER_PORT: ${c.bright(process.env.SERVER_PORT || process.env.PORT || '3001')} ${c.dim(process.env.SERVER_PORT || process.env.PORT ? '' : '(default)')}`);
|
||||||
|
console.log(` DATABASE_PATH: ${c.dim(process.env.DATABASE_PATH || '(using default location)')}`);
|
||||||
|
console.log(` CLAUDE_CLI_PATH: ${c.dim(process.env.CLAUDE_CLI_PATH || 'claude (default)')}`);
|
||||||
|
console.log(` CONTEXT_WINDOW: ${c.dim(process.env.CONTEXT_WINDOW || '160000 (default)')}`);
|
||||||
|
|
||||||
|
// Claude projects folder
|
||||||
|
const claudeProjectsPath = path.join(os.homedir(), '.claude', 'projects');
|
||||||
|
const projectsExists = fs.existsSync(claudeProjectsPath);
|
||||||
|
console.log(`\n${c.info('[INFO]')} Claude Projects Folder:`);
|
||||||
|
console.log(` ${c.dim(claudeProjectsPath)}`);
|
||||||
|
console.log(` Status: ${projectsExists ? c.ok('[OK] Exists') : c.warn('[WARN] Not found')}`);
|
||||||
|
|
||||||
|
// Config file location
|
||||||
|
const envFilePath = path.join(APP_ROOT, '.env');
|
||||||
|
const envExists = fs.existsSync(envFilePath);
|
||||||
|
console.log(`\n${c.info('[INFO]')} Configuration File:`);
|
||||||
|
console.log(` ${c.dim(envFilePath)}`);
|
||||||
|
console.log(` Status: ${envExists ? c.ok('[OK] Exists') : c.warn('[WARN] Not found (using defaults)')}`);
|
||||||
|
|
||||||
|
console.log('\n' + c.dim('═'.repeat(60)));
|
||||||
|
console.log(`\n${c.tip('[TIP]')} Hints:`);
|
||||||
|
console.log(` ${c.dim('>')} Use ${c.bright('cloudcli --port 8080')} to run on a custom port`);
|
||||||
|
console.log(` ${c.dim('>')} Use ${c.bright('cloudcli --database-path /path/to/db')} for custom database`);
|
||||||
|
console.log(` ${c.dim('>')} Run ${c.bright('cloudcli help')} for all options`);
|
||||||
|
console.log(` ${c.dim('>')} Access the UI at http://localhost:${process.env.SERVER_PORT || process.env.PORT || '3001'}\n`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show help
|
||||||
|
function showHelp() {
|
||||||
|
console.log(`
|
||||||
|
╔═══════════════════════════════════════════════════════════════╗
|
||||||
|
║ CloudCLI - Command Line Tool ║
|
||||||
|
╚═══════════════════════════════════════════════════════════════╝
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
claude-code-ui [command] [options]
|
||||||
|
cloudcli [command] [options]
|
||||||
|
|
||||||
|
Commands:
|
||||||
|
start Start the CloudCLI server (default)
|
||||||
|
sandbox Manage Docker sandbox environments
|
||||||
|
status Show configuration and data locations
|
||||||
|
update Update to the latest version
|
||||||
|
help Show this help information
|
||||||
|
version Show version information
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-p, --port <port> Set server port (default: 3001)
|
||||||
|
--database-path <path> Set custom database location
|
||||||
|
-h, --help Show this help information
|
||||||
|
-v, --version Show version information
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
$ cloudcli # Start with defaults
|
||||||
|
$ cloudcli --port 8080 # Start on port 8080
|
||||||
|
$ cloudcli sandbox ~/my-project # Run in a Docker sandbox
|
||||||
|
$ cloudcli status # Show configuration
|
||||||
|
|
||||||
|
Environment Variables:
|
||||||
|
SERVER_PORT Set server port (default: 3001)
|
||||||
|
PORT Set server port (default: 3001) (LEGACY)
|
||||||
|
DATABASE_PATH Set custom database location
|
||||||
|
CLAUDE_CLI_PATH Set custom Claude CLI path
|
||||||
|
CONTEXT_WINDOW Set context window size (default: 160000)
|
||||||
|
|
||||||
|
Documentation:
|
||||||
|
${packageJson.homepage || 'https://github.com/siteboon/claudecodeui'}
|
||||||
|
|
||||||
|
Report Issues:
|
||||||
|
${packageJson.bugs?.url || 'https://github.com/siteboon/claudecodeui/issues'}
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show version
|
||||||
|
function showVersion() {
|
||||||
|
console.log(`${packageJson.version}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compare semver versions, returns true if v1 > v2
|
||||||
|
function isNewerVersion(v1, v2) {
|
||||||
|
const parts1 = v1.split('.').map(Number);
|
||||||
|
const parts2 = v2.split('.').map(Number);
|
||||||
|
for (let i = 0; i < 3; i++) {
|
||||||
|
if (parts1[i] > parts2[i]) return true;
|
||||||
|
if (parts1[i] < parts2[i]) return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for updates
|
||||||
|
async function checkForUpdates(silent = false) {
|
||||||
|
try {
|
||||||
|
const { execSync } = await import('child_process');
|
||||||
|
const latestVersion = execSync('npm show @cloudcli-ai/cloudcli version', { encoding: 'utf8' }).trim();
|
||||||
|
const currentVersion = packageJson.version;
|
||||||
|
|
||||||
|
if (isNewerVersion(latestVersion, currentVersion)) {
|
||||||
|
console.log(`\n${c.warn('[UPDATE]')} New version available: ${c.bright(latestVersion)} (current: ${currentVersion})`);
|
||||||
|
console.log(` Run ${c.bright('cloudcli update')} to update\n`);
|
||||||
|
return { hasUpdate: true, latestVersion, currentVersion };
|
||||||
|
} else if (!silent) {
|
||||||
|
console.log(`${c.ok('[OK]')} You are on the latest version (${currentVersion})`);
|
||||||
|
}
|
||||||
|
return { hasUpdate: false, latestVersion, currentVersion };
|
||||||
|
} catch (e) {
|
||||||
|
if (!silent) {
|
||||||
|
console.log(`${c.warn('[WARN]')} Could not check for updates`);
|
||||||
|
}
|
||||||
|
return { hasUpdate: false, error: e.message };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the package
|
||||||
|
async function updatePackage() {
|
||||||
|
try {
|
||||||
|
const { execSync } = await import('child_process');
|
||||||
|
console.log(`${c.info('[INFO]')} Checking for updates...`);
|
||||||
|
|
||||||
|
const { hasUpdate, latestVersion, currentVersion } = await checkForUpdates(true);
|
||||||
|
|
||||||
|
if (!hasUpdate) {
|
||||||
|
console.log(`${c.ok('[OK]')} Already on the latest version (${currentVersion})`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`${c.info('[INFO]')} Updating from ${currentVersion} to ${latestVersion}...`);
|
||||||
|
execSync('npm update -g @cloudcli-ai/cloudcli', { stdio: 'inherit' });
|
||||||
|
console.log(`${c.ok('[OK]')} Update complete! Restart cloudcli to use the new version.`);
|
||||||
|
} catch (e) {
|
||||||
|
console.error(`${c.error('[ERROR]')} Update failed: ${e.message}`);
|
||||||
|
console.log(`${c.tip('[TIP]')} Try running manually: npm update -g @cloudcli-ai/cloudcli`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Sandbox command ─────────────────────────────────────────
|
||||||
|
|
||||||
|
const SANDBOX_TEMPLATES = {
|
||||||
|
claude: 'docker.io/cloudcliai/sandbox:claude-code',
|
||||||
|
codex: 'docker.io/cloudcliai/sandbox:codex',
|
||||||
|
gemini: 'docker.io/cloudcliai/sandbox:gemini',
|
||||||
|
};
|
||||||
|
|
||||||
|
const SANDBOX_SECRETS = {
|
||||||
|
claude: 'anthropic',
|
||||||
|
codex: 'openai',
|
||||||
|
gemini: 'google',
|
||||||
|
};
|
||||||
|
|
||||||
|
function parseSandboxArgs(args) {
|
||||||
|
const result = {
|
||||||
|
subcommand: null,
|
||||||
|
workspace: null,
|
||||||
|
agent: 'claude',
|
||||||
|
name: null,
|
||||||
|
port: 3001,
|
||||||
|
template: null,
|
||||||
|
env: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
const subcommands = ['ls', 'stop', 'start', 'rm', 'logs', 'help'];
|
||||||
|
|
||||||
|
for (let i = 0; i < args.length; i++) {
|
||||||
|
const arg = args[i];
|
||||||
|
|
||||||
|
if (i === 0 && subcommands.includes(arg)) {
|
||||||
|
result.subcommand = arg;
|
||||||
|
} else if (arg === '--agent' || arg === '-a') {
|
||||||
|
result.agent = args[++i];
|
||||||
|
} else if (arg === '--name' || arg === '-n') {
|
||||||
|
result.name = args[++i];
|
||||||
|
} else if (arg === '--port') {
|
||||||
|
result.port = parseInt(args[++i], 10);
|
||||||
|
} else if (arg === '--template' || arg === '-t') {
|
||||||
|
result.template = args[++i];
|
||||||
|
} else if (arg === '--env' || arg === '-e') {
|
||||||
|
result.env.push(args[++i]);
|
||||||
|
} else if (!arg.startsWith('-')) {
|
||||||
|
if (!result.subcommand) {
|
||||||
|
result.workspace = arg;
|
||||||
|
} else {
|
||||||
|
result.name = arg; // for stop/start/rm/logs <name>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default subcommand based on what we got
|
||||||
|
if (!result.subcommand) {
|
||||||
|
result.subcommand = 'create';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Derive name from workspace path if not set
|
||||||
|
if (!result.name && result.workspace) {
|
||||||
|
result.name = path.basename(path.resolve(result.workspace.replace(/^~/, os.homedir())));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default template from agent
|
||||||
|
if (!result.template) {
|
||||||
|
result.template = SANDBOX_TEMPLATES[result.agent] || SANDBOX_TEMPLATES.claude;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function showSandboxHelp() {
|
||||||
|
console.log(`
|
||||||
|
${c.bright('CloudCLI Sandbox')} — Run CloudCLI inside Docker Sandboxes
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
cloudcli sandbox <workspace> Create and start a sandbox
|
||||||
|
cloudcli sandbox <subcommand> [name] Manage sandboxes
|
||||||
|
|
||||||
|
Subcommands:
|
||||||
|
${c.bright('(default)')} Create a sandbox and start the web UI
|
||||||
|
${c.bright('ls')} List all sandboxes
|
||||||
|
${c.bright('start')} Restart a stopped sandbox and re-launch the web UI
|
||||||
|
${c.bright('stop')} Stop a sandbox (preserves state)
|
||||||
|
${c.bright('rm')} Remove a sandbox
|
||||||
|
${c.bright('logs')} Show CloudCLI server logs
|
||||||
|
${c.bright('help')} Show this help
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-a, --agent <agent> Agent to use: claude, codex, gemini (default: claude)
|
||||||
|
-n, --name <name> Sandbox name (default: derived from workspace folder)
|
||||||
|
-t, --template <image> Custom template image
|
||||||
|
-e, --env <KEY=VALUE> Set environment variable (repeatable)
|
||||||
|
--port <port> Host port for the web UI (default: 3001)
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
$ cloudcli sandbox ~/my-project
|
||||||
|
$ cloudcli sandbox ~/my-project --agent codex --port 8080
|
||||||
|
$ cloudcli sandbox ~/my-project --env SERVER_PORT=8080 --env HOST=0.0.0.0
|
||||||
|
$ cloudcli sandbox ls
|
||||||
|
$ cloudcli sandbox stop my-project
|
||||||
|
$ cloudcli sandbox start my-project
|
||||||
|
$ cloudcli sandbox rm my-project
|
||||||
|
|
||||||
|
Prerequisites:
|
||||||
|
1. Install sbx CLI: https://docs.docker.com/ai/sandboxes/get-started/
|
||||||
|
2. Authenticate and store your API key:
|
||||||
|
sbx login
|
||||||
|
sbx secret set -g anthropic # for Claude
|
||||||
|
sbx secret set -g openai # for Codex
|
||||||
|
sbx secret set -g google # for Gemini
|
||||||
|
|
||||||
|
Advanced usage:
|
||||||
|
For branch mode, multiple workspaces, memory limits, network policies,
|
||||||
|
or passing prompts to the agent, use sbx directly with the template:
|
||||||
|
|
||||||
|
sbx run --template docker.io/cloudcliai/sandbox:claude-code claude ~/my-project --branch my-feature
|
||||||
|
sbx run --template docker.io/cloudcliai/sandbox:claude-code claude ~/project ~/libs:ro --memory 8g
|
||||||
|
|
||||||
|
Full Docker Sandboxes docs: https://docs.docker.com/ai/sandboxes/usage/
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function sandboxCommand(args) {
|
||||||
|
const { execFileSync, spawn: spawnProcess } = await import('child_process');
|
||||||
|
|
||||||
|
// Safe execution — uses execFileSync (no shell) to prevent injection
|
||||||
|
const sbx = (subcmd, opts = {}) => {
|
||||||
|
const result = execFileSync('sbx', subcmd, {
|
||||||
|
encoding: 'utf8',
|
||||||
|
stdio: opts.inherit ? 'inherit' : 'pipe',
|
||||||
|
});
|
||||||
|
return result || '';
|
||||||
|
};
|
||||||
|
|
||||||
|
const opts = parseSandboxArgs(args);
|
||||||
|
|
||||||
|
if (opts.subcommand === 'help') {
|
||||||
|
showSandboxHelp();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate name (alphanumeric, hyphens, underscores only)
|
||||||
|
if (opts.name && !/^[\w-]+$/.test(opts.name)) {
|
||||||
|
console.error(`\n${c.error('❌')} Invalid sandbox name: ${opts.name}`);
|
||||||
|
console.log(` Names may only contain letters, numbers, hyphens, and underscores.\n`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check sbx is installed
|
||||||
|
try {
|
||||||
|
sbx(['version']);
|
||||||
|
} catch {
|
||||||
|
console.error(`\n${c.error('❌')} ${c.bright('sbx')} CLI not found.\n`);
|
||||||
|
console.log(` Install it from: ${c.info('https://docs.docker.com/ai/sandboxes/get-started/')}`);
|
||||||
|
console.log(` Then run: ${c.bright('sbx login')}`);
|
||||||
|
console.log(` And store your API key: ${c.bright('sbx secret set -g anthropic')}\n`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (opts.subcommand) {
|
||||||
|
|
||||||
|
case 'ls':
|
||||||
|
sbx(['ls'], { inherit: true });
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'stop':
|
||||||
|
if (!opts.name) {
|
||||||
|
console.error(`\n${c.error('❌')} Sandbox name required: cloudcli sandbox stop <name>\n`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
sbx(['stop', opts.name], { inherit: true });
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'rm':
|
||||||
|
if (!opts.name) {
|
||||||
|
console.error(`\n${c.error('❌')} Sandbox name required: cloudcli sandbox rm <name>\n`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
sbx(['rm', opts.name], { inherit: true });
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'logs':
|
||||||
|
if (!opts.name) {
|
||||||
|
console.error(`\n${c.error('❌')} Sandbox name required: cloudcli sandbox logs <name>\n`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
sbx(['exec', opts.name, 'bash', '-c', 'cat /tmp/cloudcli-ui.log'], { inherit: true });
|
||||||
|
} catch (e) {
|
||||||
|
console.error(`\n${c.error('❌')} Could not read logs: ${e.message || 'Is the sandbox running?'}\n`);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'start': {
|
||||||
|
if (!opts.name) {
|
||||||
|
console.error(`\n${c.error('❌')} Sandbox name required: cloudcli sandbox start <name>\n`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
console.log(`\n${c.info('▶')} Starting sandbox ${c.bright(opts.name)}...`);
|
||||||
|
const restartRun = spawnProcess('sbx', ['run', opts.name], {
|
||||||
|
detached: true,
|
||||||
|
stdio: ['ignore', 'ignore', 'ignore'],
|
||||||
|
});
|
||||||
|
restartRun.unref();
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 5000));
|
||||||
|
|
||||||
|
console.log(`${c.info('▶')} Launching CloudCLI web server...`);
|
||||||
|
sbx(['exec', opts.name, 'bash', '-c', 'cloudcli start --port 3001 &']);
|
||||||
|
|
||||||
|
console.log(`${c.info('▶')} Forwarding port ${opts.port} → 3001...`);
|
||||||
|
try {
|
||||||
|
sbx(['ports', opts.name, '--publish', `${opts.port}:3001`]);
|
||||||
|
} catch (e) {
|
||||||
|
const msg = e.stdout || e.stderr || e.message || '';
|
||||||
|
if (msg.includes('address already in use')) {
|
||||||
|
const altPort = opts.port + 1;
|
||||||
|
console.log(`${c.warn('⚠')} Port ${opts.port} in use, trying ${altPort}...`);
|
||||||
|
try {
|
||||||
|
sbx(['ports', opts.name, '--publish', `${altPort}:3001`]);
|
||||||
|
opts.port = altPort;
|
||||||
|
} catch {
|
||||||
|
console.error(`${c.error('❌')} Ports ${opts.port} and ${altPort} both in use. Use --port to specify a free port.`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`\n${c.ok('✔')} ${c.bright('CloudCLI is ready!')}`);
|
||||||
|
console.log(` ${c.info('→')} ${c.bright(`http://localhost:${opts.port}`)}\n`);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'create': {
|
||||||
|
if (!opts.workspace) {
|
||||||
|
console.error(`\n${c.error('❌')} Workspace path required: cloudcli sandbox <path>\n`);
|
||||||
|
console.log(` Example: ${c.bright('cloudcli sandbox ~/my-project')}\n`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const workspace = opts.workspace.startsWith('~')
|
||||||
|
? opts.workspace.replace(/^~/, os.homedir())
|
||||||
|
: path.resolve(opts.workspace);
|
||||||
|
|
||||||
|
if (!fs.existsSync(workspace)) {
|
||||||
|
console.error(`\n${c.error('❌')} Workspace path not found: ${c.dim(workspace)}\n`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const secret = SANDBOX_SECRETS[opts.agent] || 'anthropic';
|
||||||
|
|
||||||
|
// Check if the required secret is stored
|
||||||
|
try {
|
||||||
|
const secretList = sbx(['secret', 'ls']);
|
||||||
|
if (!secretList.includes(secret)) {
|
||||||
|
console.error(`\n${c.error('❌')} No ${c.bright(secret)} API key found.\n`);
|
||||||
|
console.log(` Run: ${c.bright(`sbx secret set -g ${secret}`)}\n`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
} catch { /* sbx secret ls not available, skip check */ }
|
||||||
|
|
||||||
|
console.log(`\n${c.bright('CloudCLI Sandbox')}`);
|
||||||
|
console.log(c.dim('─'.repeat(50)));
|
||||||
|
console.log(` Agent: ${c.info(opts.agent)} ${c.dim(`(${secret} credentials)`)}`);
|
||||||
|
console.log(` Workspace: ${c.dim(workspace)}`);
|
||||||
|
console.log(` Name: ${c.dim(opts.name)}`);
|
||||||
|
console.log(` Template: ${c.dim(opts.template)}`);
|
||||||
|
console.log(` Port: ${c.dim(String(opts.port))}`);
|
||||||
|
if (opts.env.length > 0) {
|
||||||
|
console.log(` Env: ${c.dim(opts.env.join(', '))}`);
|
||||||
|
}
|
||||||
|
console.log(c.dim('─'.repeat(50)));
|
||||||
|
|
||||||
|
// Step 1: Launch sandbox with sbx run in background.
|
||||||
|
// sbx run creates the sandbox (or reconnects) AND holds an active session,
|
||||||
|
// which prevents the sandbox from auto-stopping.
|
||||||
|
console.log(`\n${c.info('▶')} Creating sandbox ${c.bright(opts.name)}...`);
|
||||||
|
const bgRun = spawnProcess('sbx', [
|
||||||
|
'run', '--template', opts.template, '--name', opts.name, opts.agent, workspace,
|
||||||
|
], {
|
||||||
|
detached: true,
|
||||||
|
stdio: ['ignore', 'ignore', 'ignore'],
|
||||||
|
});
|
||||||
|
bgRun.unref();
|
||||||
|
// Wait for sandbox to be ready
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 5000));
|
||||||
|
|
||||||
|
// Step 2: Inject environment variables
|
||||||
|
if (opts.env.length > 0) {
|
||||||
|
console.log(`${c.info('▶')} Setting environment variables...`);
|
||||||
|
const exports = opts.env
|
||||||
|
.filter(e => /^\w+=.+$/.test(e))
|
||||||
|
.map(e => `export ${e}`)
|
||||||
|
.join('\n');
|
||||||
|
if (exports) {
|
||||||
|
sbx(['exec', opts.name, 'bash', '-c', `echo '${exports}' >> /etc/sandbox-persistent.sh`]);
|
||||||
|
}
|
||||||
|
const invalid = opts.env.filter(e => !/^\w+=.+$/.test(e));
|
||||||
|
if (invalid.length > 0) {
|
||||||
|
console.log(`${c.warn('⚠')} Skipped invalid env vars: ${invalid.join(', ')} (expected KEY=VALUE)`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Step 3: Start CloudCLI inside the sandbox
|
||||||
|
console.log(`${c.info('▶')} Launching CloudCLI web server...`);
|
||||||
|
sbx(['exec', opts.name, 'bash', '-c', 'cloudcli start --port 3001 &']);
|
||||||
|
|
||||||
|
// Step 4: Forward port
|
||||||
|
console.log(`${c.info('▶')} Forwarding port ${opts.port} → 3001...`);
|
||||||
|
try {
|
||||||
|
sbx(['ports', opts.name, '--publish', `${opts.port}:3001`]);
|
||||||
|
} catch (e) {
|
||||||
|
const msg = e.stdout || e.stderr || e.message || '';
|
||||||
|
if (msg.includes('address already in use')) {
|
||||||
|
const altPort = opts.port + 1;
|
||||||
|
console.log(`${c.warn('⚠')} Port ${opts.port} in use, trying ${altPort}...`);
|
||||||
|
try {
|
||||||
|
sbx(['ports', opts.name, '--publish', `${altPort}:3001`]);
|
||||||
|
opts.port = altPort;
|
||||||
|
} catch {
|
||||||
|
console.error(`${c.error('❌')} Ports ${opts.port} and ${altPort} both in use. Use --port to specify a free port.`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Done
|
||||||
|
console.log(`\n${c.ok('✔')} ${c.bright('CloudCLI is ready!')}`);
|
||||||
|
console.log(` ${c.info('→')} Open ${c.bright(`http://localhost:${opts.port}`)}`);
|
||||||
|
console.log(`\n${c.dim(' Manage with:')}`);
|
||||||
|
console.log(` ${c.dim('$')} sbx ls`);
|
||||||
|
console.log(` ${c.dim('$')} sbx stop ${opts.name}`);
|
||||||
|
console.log(` ${c.dim('$')} sbx start ${opts.name}`);
|
||||||
|
console.log(` ${c.dim('$')} sbx rm ${opts.name}`);
|
||||||
|
console.log(`\n${c.dim(' Or install globally:')} npm install -g @cloudcli-ai/cloudcli\n`);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
showSandboxHelp();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Server ──────────────────────────────────────────────────
|
||||||
|
|
||||||
|
// Start the server
|
||||||
|
async function startServer() {
|
||||||
|
// Check for updates silently on startup
|
||||||
|
checkForUpdates(true);
|
||||||
|
|
||||||
|
// Import and run the server
|
||||||
|
await import('./index.js');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse CLI arguments
|
||||||
|
function parseArgs(args) {
|
||||||
|
const parsed = { command: 'start', options: {} };
|
||||||
|
|
||||||
|
for (let i = 0; i < args.length; i++) {
|
||||||
|
const arg = args[i];
|
||||||
|
|
||||||
|
if (arg === '--port' || arg === '-p') {
|
||||||
|
parsed.options.serverPort = args[++i];
|
||||||
|
} else if (arg.startsWith('--port=')) {
|
||||||
|
parsed.options.serverPort = arg.split('=')[1];
|
||||||
|
} else if (arg === '--database-path') {
|
||||||
|
parsed.options.databasePath = args[++i];
|
||||||
|
} else if (arg.startsWith('--database-path=')) {
|
||||||
|
parsed.options.databasePath = arg.split('=')[1];
|
||||||
|
} else if (arg === '--help' || arg === '-h') {
|
||||||
|
parsed.command = 'help';
|
||||||
|
} else if (arg === '--version' || arg === '-v') {
|
||||||
|
parsed.command = 'version';
|
||||||
|
} else if (!arg.startsWith('-')) {
|
||||||
|
parsed.command = arg;
|
||||||
|
if (arg === 'sandbox') {
|
||||||
|
parsed.remainingArgs = args.slice(i + 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return parsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Main CLI handler
|
||||||
|
async function main() {
|
||||||
|
const args = process.argv.slice(2);
|
||||||
|
const { command, options, remainingArgs } = parseArgs(args);
|
||||||
|
|
||||||
|
// Apply CLI options to environment variables
|
||||||
|
if (options.serverPort) {
|
||||||
|
process.env.SERVER_PORT = options.serverPort;
|
||||||
|
} else if (!process.env.SERVER_PORT && process.env.PORT) {
|
||||||
|
process.env.SERVER_PORT = process.env.PORT;
|
||||||
|
}
|
||||||
|
if (options.databasePath) {
|
||||||
|
process.env.DATABASE_PATH = options.databasePath;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (command) {
|
||||||
|
case 'start':
|
||||||
|
await startServer();
|
||||||
|
break;
|
||||||
|
case 'sandbox':
|
||||||
|
await sandboxCommand(remainingArgs || []);
|
||||||
|
break;
|
||||||
|
case 'status':
|
||||||
|
case 'info':
|
||||||
|
showStatus();
|
||||||
|
break;
|
||||||
|
case 'help':
|
||||||
|
case '-h':
|
||||||
|
case '--help':
|
||||||
|
showHelp();
|
||||||
|
break;
|
||||||
|
case 'version':
|
||||||
|
case '-v':
|
||||||
|
case '--version':
|
||||||
|
showVersion();
|
||||||
|
break;
|
||||||
|
case 'update':
|
||||||
|
await updatePackage();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
console.error(`\n❌ Unknown command: ${command}`);
|
||||||
|
console.log(' Run "cloudcli help" for usage information.\n');
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run the CLI
|
||||||
|
main().catch(error => {
|
||||||
|
console.error('\n❌ Error:', error.message);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
5
server/constants/config.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
/**
|
||||||
|
* Environment Flag: Is Platform
|
||||||
|
* Indicates if the app is running in Platform mode (hosted) or OSS mode (self-hosted)
|
||||||
|
*/
|
||||||
|
export const IS_PLATFORM = process.env.VITE_IS_PLATFORM === 'true';
|
||||||
@@ -1,84 +1,156 @@
|
|||||||
import { spawn } from 'child_process';
|
import { spawn } from 'child_process';
|
||||||
import crossSpawn from 'cross-spawn';
|
import crossSpawn from 'cross-spawn';
|
||||||
import { promises as fs } from 'fs';
|
import { notifyRunFailed, notifyRunStopped } from './services/notification-orchestrator.js';
|
||||||
import path from 'path';
|
import { sessionsService } from './modules/providers/services/sessions.service.js';
|
||||||
import os from 'os';
|
import { providerAuthService } from './modules/providers/services/provider-auth.service.js';
|
||||||
|
import { createNormalizedMessage } from './shared/utils.js';
|
||||||
|
|
||||||
// Use cross-spawn on Windows for better command execution
|
// Use cross-spawn on Windows for better command execution
|
||||||
const spawnFunction = process.platform === 'win32' ? crossSpawn : spawn;
|
const spawnFunction = process.platform === 'win32' ? crossSpawn : spawn;
|
||||||
|
|
||||||
let activeCursorProcesses = new Map(); // Track active processes by session ID
|
let activeCursorProcesses = new Map(); // Track active processes by session ID
|
||||||
|
|
||||||
|
const WORKSPACE_TRUST_PATTERNS = [
|
||||||
|
/workspace trust required/i,
|
||||||
|
/do you trust the contents of this directory/i,
|
||||||
|
/working with untrusted contents/i,
|
||||||
|
/pass --trust,\s*--yolo,\s*or -f/i
|
||||||
|
];
|
||||||
|
|
||||||
|
function isWorkspaceTrustPrompt(text = '') {
|
||||||
|
if (!text || typeof text !== 'string') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return WORKSPACE_TRUST_PATTERNS.some((pattern) => pattern.test(text));
|
||||||
|
}
|
||||||
|
|
||||||
async function spawnCursor(command, options = {}, ws) {
|
async function spawnCursor(command, options = {}, ws) {
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
const { sessionId, projectPath, cwd, resume, toolsSettings, skipPermissions, model, images } = options;
|
const { sessionId, projectPath, cwd, resume, toolsSettings, skipPermissions, model, sessionSummary } = options;
|
||||||
let capturedSessionId = sessionId; // Track session ID throughout the process
|
let capturedSessionId = sessionId; // Track session ID throughout the process
|
||||||
let sessionCreatedSent = false; // Track if we've already sent session-created event
|
let sessionCreatedSent = false; // Track if we've already sent session-created event
|
||||||
let messageBuffer = ''; // Buffer for accumulating assistant messages
|
let hasRetriedWithTrust = false;
|
||||||
|
let settled = false;
|
||||||
|
|
||||||
// Use tools settings passed from frontend, or defaults
|
// Use tools settings passed from frontend, or defaults
|
||||||
const settings = toolsSettings || {
|
const settings = toolsSettings || {
|
||||||
allowedShellCommands: [],
|
allowedShellCommands: [],
|
||||||
skipPermissions: false
|
skipPermissions: false
|
||||||
};
|
};
|
||||||
|
|
||||||
// Build Cursor CLI command
|
// Build Cursor CLI command
|
||||||
const args = [];
|
const baseArgs = [];
|
||||||
|
|
||||||
// Build flags allowing both resume and prompt together (reply in existing session)
|
// Build flags allowing both resume and prompt together (reply in existing session)
|
||||||
// Treat presence of sessionId as intention to resume, regardless of resume flag
|
// Treat presence of sessionId as intention to resume, regardless of resume flag
|
||||||
if (sessionId) {
|
if (sessionId) {
|
||||||
args.push('--resume=' + sessionId);
|
baseArgs.push('--resume=' + sessionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command && command.trim()) {
|
if (command && command.trim()) {
|
||||||
// Provide a prompt (works for both new and resumed sessions)
|
// Provide a prompt (works for both new and resumed sessions)
|
||||||
args.push('-p', command);
|
baseArgs.push('-p', command);
|
||||||
|
|
||||||
// Add model flag if specified (only meaningful for new sessions; harmless on resume)
|
// Add model flag if specified (only meaningful for new sessions; harmless on resume)
|
||||||
if (!sessionId && model) {
|
if (!sessionId && model) {
|
||||||
args.push('--model', model);
|
baseArgs.push('--model', model);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request streaming JSON when we are providing a prompt
|
// Request streaming JSON when we are providing a prompt
|
||||||
args.push('--output-format', 'stream-json');
|
baseArgs.push('--output-format', 'stream-json');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add skip permissions flag if enabled
|
// Add skip permissions flag if enabled
|
||||||
if (skipPermissions || settings.skipPermissions) {
|
if (skipPermissions || settings.skipPermissions) {
|
||||||
args.push('-f');
|
baseArgs.push('-f');
|
||||||
console.log('⚠️ Using -f flag (skip permissions)');
|
console.log('Using -f flag (skip permissions)');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use cwd (actual project directory) instead of projectPath
|
// Use cwd (actual project directory) instead of projectPath
|
||||||
const workingDir = cwd || projectPath || process.cwd();
|
const workingDir = cwd || projectPath || process.cwd();
|
||||||
|
|
||||||
console.log('Spawning Cursor CLI:', 'cursor-agent', args.join(' '));
|
|
||||||
console.log('Working directory:', workingDir);
|
|
||||||
console.log('Session info - Input sessionId:', sessionId, 'Resume:', resume);
|
|
||||||
|
|
||||||
const cursorProcess = spawnFunction('cursor-agent', args, {
|
|
||||||
cwd: workingDir,
|
|
||||||
stdio: ['pipe', 'pipe', 'pipe'],
|
|
||||||
env: { ...process.env } // Inherit all environment variables
|
|
||||||
});
|
|
||||||
|
|
||||||
// Store process reference for potential abort
|
// Store process reference for potential abort
|
||||||
const processKey = capturedSessionId || Date.now().toString();
|
const processKey = capturedSessionId || Date.now().toString();
|
||||||
activeCursorProcesses.set(processKey, cursorProcess);
|
|
||||||
|
const settleOnce = (callback) => {
|
||||||
// Handle stdout (streaming JSON responses)
|
if (settled) {
|
||||||
cursorProcess.stdout.on('data', (data) => {
|
return;
|
||||||
const rawOutput = data.toString();
|
}
|
||||||
console.log('📤 Cursor CLI stdout:', rawOutput);
|
settled = true;
|
||||||
|
callback();
|
||||||
const lines = rawOutput.split('\n').filter(line => line.trim());
|
};
|
||||||
|
|
||||||
for (const line of lines) {
|
const runCursorProcess = (args, runReason = 'initial') => {
|
||||||
|
const isTrustRetry = runReason === 'trust-retry';
|
||||||
|
let runSawWorkspaceTrustPrompt = false;
|
||||||
|
let stdoutLineBuffer = '';
|
||||||
|
let terminalNotificationSent = false;
|
||||||
|
|
||||||
|
const notifyTerminalState = ({ code = null, error = null } = {}) => {
|
||||||
|
if (terminalNotificationSent) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
terminalNotificationSent = true;
|
||||||
|
|
||||||
|
const finalSessionId = capturedSessionId || sessionId || processKey;
|
||||||
|
if (code === 0 && !error) {
|
||||||
|
notifyRunStopped({
|
||||||
|
userId: ws?.userId || null,
|
||||||
|
provider: 'cursor',
|
||||||
|
sessionId: finalSessionId,
|
||||||
|
sessionName: sessionSummary,
|
||||||
|
stopReason: 'completed'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
notifyRunFailed({
|
||||||
|
userId: ws?.userId || null,
|
||||||
|
provider: 'cursor',
|
||||||
|
sessionId: finalSessionId,
|
||||||
|
sessionName: sessionSummary,
|
||||||
|
error: error || `Cursor CLI exited with code ${code}`
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
if (isTrustRetry) {
|
||||||
|
console.log('Retrying Cursor CLI with --trust after workspace trust prompt');
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('Spawning Cursor CLI:', 'cursor-agent', args.join(' '));
|
||||||
|
console.log('Working directory:', workingDir);
|
||||||
|
console.log('Session info - Input sessionId:', sessionId, 'Resume:', resume);
|
||||||
|
|
||||||
|
const cursorProcess = spawnFunction('cursor-agent', args, {
|
||||||
|
cwd: workingDir,
|
||||||
|
stdio: ['pipe', 'pipe', 'pipe'],
|
||||||
|
env: { ...process.env } // Inherit all environment variables
|
||||||
|
});
|
||||||
|
|
||||||
|
activeCursorProcesses.set(processKey, cursorProcess);
|
||||||
|
|
||||||
|
const shouldSuppressForTrustRetry = (text) => {
|
||||||
|
if (hasRetriedWithTrust || args.includes('--trust')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!isWorkspaceTrustPrompt(text)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
runSawWorkspaceTrustPrompt = true;
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
const processCursorOutputLine = (line) => {
|
||||||
|
if (!line || !line.trim()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = JSON.parse(line);
|
const response = JSON.parse(line);
|
||||||
console.log('📄 Parsed JSON response:', response);
|
|
||||||
|
|
||||||
// Handle different message types
|
// Handle different message types
|
||||||
switch (response.type) {
|
switch (response.type) {
|
||||||
case 'system':
|
case 'system':
|
||||||
@@ -86,14 +158,13 @@ async function spawnCursor(command, options = {}, ws) {
|
|||||||
// Capture session ID
|
// Capture session ID
|
||||||
if (response.session_id && !capturedSessionId) {
|
if (response.session_id && !capturedSessionId) {
|
||||||
capturedSessionId = response.session_id;
|
capturedSessionId = response.session_id;
|
||||||
console.log('📝 Captured session ID:', capturedSessionId);
|
|
||||||
|
|
||||||
// Update process key with captured session ID
|
// Update process key with captured session ID
|
||||||
if (processKey !== capturedSessionId) {
|
if (processKey !== capturedSessionId) {
|
||||||
activeCursorProcesses.delete(processKey);
|
activeCursorProcesses.delete(processKey);
|
||||||
activeCursorProcesses.set(capturedSessionId, cursorProcess);
|
activeCursorProcesses.set(capturedSessionId, cursorProcess);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set session ID on writer (for API endpoint compatibility)
|
// Set session ID on writer (for API endpoint compatibility)
|
||||||
if (ws.setSessionId && typeof ws.setSessionId === 'function') {
|
if (ws.setSessionId && typeof ws.setSessionId === 'function') {
|
||||||
ws.setSessionId(capturedSessionId);
|
ws.setSessionId(capturedSessionId);
|
||||||
@@ -102,148 +173,144 @@ async function spawnCursor(command, options = {}, ws) {
|
|||||||
// Send session-created event only once for new sessions
|
// Send session-created event only once for new sessions
|
||||||
if (!sessionId && !sessionCreatedSent) {
|
if (!sessionId && !sessionCreatedSent) {
|
||||||
sessionCreatedSent = true;
|
sessionCreatedSent = true;
|
||||||
ws.send(JSON.stringify({
|
ws.send(createNormalizedMessage({ kind: 'session_created', newSessionId: capturedSessionId, model: response.model, cwd: response.cwd, sessionId: capturedSessionId, provider: 'cursor' }));
|
||||||
type: 'session-created',
|
|
||||||
sessionId: capturedSessionId,
|
|
||||||
model: response.model,
|
|
||||||
cwd: response.cwd
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send system info to frontend
|
// System info — no longer needed by the frontend (session-lifecycle 'created' handles nav).
|
||||||
ws.send(JSON.stringify({
|
|
||||||
type: 'cursor-system',
|
|
||||||
data: response
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'user':
|
case 'user':
|
||||||
// Forward user message
|
// User messages are not displayed in the UI — skip.
|
||||||
ws.send(JSON.stringify({
|
|
||||||
type: 'cursor-user',
|
|
||||||
data: response
|
|
||||||
}));
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'assistant':
|
case 'assistant':
|
||||||
// Accumulate assistant message chunks
|
// Accumulate assistant message chunks
|
||||||
if (response.message && response.message.content && response.message.content.length > 0) {
|
if (response.message && response.message.content && response.message.content.length > 0) {
|
||||||
const textContent = response.message.content[0].text;
|
const normalized = sessionsService.normalizeMessage('cursor', response, capturedSessionId || sessionId || null);
|
||||||
messageBuffer += textContent;
|
for (const msg of normalized) ws.send(msg);
|
||||||
|
|
||||||
// Send as Claude-compatible format for frontend
|
|
||||||
ws.send(JSON.stringify({
|
|
||||||
type: 'claude-response',
|
|
||||||
data: {
|
|
||||||
type: 'content_block_delta',
|
|
||||||
delta: {
|
|
||||||
type: 'text_delta',
|
|
||||||
text: textContent
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'result':
|
case 'result': {
|
||||||
// Session complete
|
// Session complete — send stream end + lifecycle complete with result payload
|
||||||
console.log('Cursor session result:', response);
|
const resultText = typeof response.result === 'string' ? response.result : '';
|
||||||
|
ws.send(createNormalizedMessage({
|
||||||
// Send final message if we have buffered content
|
kind: 'complete',
|
||||||
if (messageBuffer) {
|
exitCode: response.subtype === 'success' ? 0 : 1,
|
||||||
ws.send(JSON.stringify({
|
resultText,
|
||||||
type: 'claude-response',
|
isError: response.subtype !== 'success',
|
||||||
data: {
|
sessionId: capturedSessionId || sessionId, provider: 'cursor',
|
||||||
type: 'content_block_stop'
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send completion event
|
|
||||||
ws.send(JSON.stringify({
|
|
||||||
type: 'cursor-result',
|
|
||||||
sessionId: capturedSessionId || sessionId,
|
|
||||||
data: response,
|
|
||||||
success: response.subtype === 'success'
|
|
||||||
}));
|
}));
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// Forward any other message types
|
// Unknown message types — ignore.
|
||||||
ws.send(JSON.stringify({
|
|
||||||
type: 'cursor-response',
|
|
||||||
data: response
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
} catch (parseError) {
|
} catch (parseError) {
|
||||||
console.log('📄 Non-JSON response:', line);
|
if (shouldSuppressForTrustRetry(line)) {
|
||||||
// If not JSON, send as raw text
|
return;
|
||||||
ws.send(JSON.stringify({
|
}
|
||||||
type: 'cursor-output',
|
|
||||||
data: line
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Handle stderr
|
|
||||||
cursorProcess.stderr.on('data', (data) => {
|
|
||||||
console.error('Cursor CLI stderr:', data.toString());
|
|
||||||
ws.send(JSON.stringify({
|
|
||||||
type: 'cursor-error',
|
|
||||||
error: data.toString()
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
|
|
||||||
// Handle process completion
|
|
||||||
cursorProcess.on('close', async (code) => {
|
|
||||||
console.log(`Cursor CLI process exited with code ${code}`);
|
|
||||||
|
|
||||||
// Clean up process reference
|
|
||||||
const finalSessionId = capturedSessionId || sessionId || processKey;
|
|
||||||
activeCursorProcesses.delete(finalSessionId);
|
|
||||||
|
|
||||||
ws.send(JSON.stringify({
|
// If not JSON, send as stream delta via adapter
|
||||||
type: 'claude-complete',
|
const normalized = sessionsService.normalizeMessage('cursor', line, capturedSessionId || sessionId || null);
|
||||||
sessionId: finalSessionId,
|
for (const msg of normalized) ws.send(msg);
|
||||||
exitCode: code,
|
}
|
||||||
isNewSession: !sessionId && !!command // Flag to indicate this was a new session
|
};
|
||||||
}));
|
|
||||||
|
// Handle stdout (streaming JSON responses)
|
||||||
if (code === 0) {
|
cursorProcess.stdout.on('data', (data) => {
|
||||||
resolve();
|
const rawOutput = data.toString();
|
||||||
} else {
|
|
||||||
reject(new Error(`Cursor CLI exited with code ${code}`));
|
// Stream chunks can split JSON objects across packets; keep trailing partial line.
|
||||||
}
|
stdoutLineBuffer += rawOutput;
|
||||||
});
|
const completeLines = stdoutLineBuffer.split(/\r?\n/);
|
||||||
|
stdoutLineBuffer = completeLines.pop() || '';
|
||||||
// Handle process errors
|
|
||||||
cursorProcess.on('error', (error) => {
|
completeLines.forEach((line) => {
|
||||||
console.error('Cursor CLI process error:', error);
|
processCursorOutputLine(line.trim());
|
||||||
|
});
|
||||||
// Clean up process reference on error
|
});
|
||||||
const finalSessionId = capturedSessionId || sessionId || processKey;
|
|
||||||
activeCursorProcesses.delete(finalSessionId);
|
// Handle stderr
|
||||||
|
cursorProcess.stderr.on('data', (data) => {
|
||||||
ws.send(JSON.stringify({
|
const stderrText = data.toString();
|
||||||
type: 'cursor-error',
|
console.error('Cursor CLI stderr:', stderrText);
|
||||||
error: error.message
|
|
||||||
}));
|
if (shouldSuppressForTrustRetry(stderrText)) {
|
||||||
|
return;
|
||||||
reject(error);
|
}
|
||||||
});
|
|
||||||
|
ws.send(createNormalizedMessage({ kind: 'error', content: stderrText, sessionId: capturedSessionId || sessionId || null, provider: 'cursor' }));
|
||||||
// Close stdin since Cursor doesn't need interactive input
|
});
|
||||||
cursorProcess.stdin.end();
|
|
||||||
|
// Handle process completion
|
||||||
|
cursorProcess.on('close', async (code) => {
|
||||||
|
const finalSessionId = capturedSessionId || sessionId || processKey;
|
||||||
|
activeCursorProcesses.delete(finalSessionId);
|
||||||
|
|
||||||
|
// Flush any final unterminated stdout line before completion handling.
|
||||||
|
if (stdoutLineBuffer.trim()) {
|
||||||
|
processCursorOutputLine(stdoutLineBuffer.trim());
|
||||||
|
stdoutLineBuffer = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
runSawWorkspaceTrustPrompt &&
|
||||||
|
code !== 0 &&
|
||||||
|
!hasRetriedWithTrust &&
|
||||||
|
!args.includes('--trust')
|
||||||
|
) {
|
||||||
|
hasRetriedWithTrust = true;
|
||||||
|
runCursorProcess([...args, '--trust'], 'trust-retry');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ws.send(createNormalizedMessage({ kind: 'complete', exitCode: code, isNewSession: !sessionId && !!command, sessionId: finalSessionId, provider: 'cursor' }));
|
||||||
|
|
||||||
|
if (code === 0) {
|
||||||
|
notifyTerminalState({ code });
|
||||||
|
settleOnce(() => resolve());
|
||||||
|
} else {
|
||||||
|
notifyTerminalState({ code });
|
||||||
|
settleOnce(() => reject(new Error(`Cursor CLI exited with code ${code}`)));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Handle process errors
|
||||||
|
cursorProcess.on('error', async (error) => {
|
||||||
|
console.error('Cursor CLI process error:', error);
|
||||||
|
|
||||||
|
// Clean up process reference on error
|
||||||
|
const finalSessionId = capturedSessionId || sessionId || processKey;
|
||||||
|
activeCursorProcesses.delete(finalSessionId);
|
||||||
|
|
||||||
|
// Check if Cursor CLI is installed for a clearer error message
|
||||||
|
const installed = await providerAuthService.isProviderInstalled('cursor');
|
||||||
|
const errorContent = !installed
|
||||||
|
? 'Cursor CLI is not installed. Please install it from https://cursor.com'
|
||||||
|
: error.message;
|
||||||
|
|
||||||
|
ws.send(createNormalizedMessage({ kind: 'error', content: errorContent, sessionId: capturedSessionId || sessionId || null, provider: 'cursor' }));
|
||||||
|
notifyTerminalState({ error });
|
||||||
|
|
||||||
|
settleOnce(() => reject(error));
|
||||||
|
});
|
||||||
|
|
||||||
|
// Close stdin since Cursor doesn't need interactive input
|
||||||
|
cursorProcess.stdin.end();
|
||||||
|
};
|
||||||
|
|
||||||
|
runCursorProcess(baseArgs, 'initial');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function abortCursorSession(sessionId) {
|
function abortCursorSession(sessionId) {
|
||||||
const process = activeCursorProcesses.get(sessionId);
|
const process = activeCursorProcesses.get(sessionId);
|
||||||
if (process) {
|
if (process) {
|
||||||
console.log(`🛑 Aborting Cursor session: ${sessionId}`);
|
console.log(`Aborting Cursor session: ${sessionId}`);
|
||||||
process.kill('SIGTERM');
|
process.kill('SIGTERM');
|
||||||
activeCursorProcesses.delete(sessionId);
|
activeCursorProcesses.delete(sessionId);
|
||||||
return true;
|
return true;
|
||||||
@@ -264,4 +331,4 @@ export {
|
|||||||
abortCursorSession,
|
abortCursorSession,
|
||||||
isCursorSessionActive,
|
isCursorSessionActive,
|
||||||
getActiveCursorSessions
|
getActiveCursorSessions
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,263 +0,0 @@
|
|||||||
import Database from 'better-sqlite3';
|
|
||||||
import path from 'path';
|
|
||||||
import fs from 'fs';
|
|
||||||
import crypto from 'crypto';
|
|
||||||
import { fileURLToPath } from 'url';
|
|
||||||
import { dirname } from 'path';
|
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
|
||||||
const __dirname = dirname(__filename);
|
|
||||||
|
|
||||||
// Use DATABASE_PATH environment variable if set, otherwise use default location
|
|
||||||
const DB_PATH = process.env.DATABASE_PATH || path.join(__dirname, 'auth.db');
|
|
||||||
const INIT_SQL_PATH = path.join(__dirname, 'init.sql');
|
|
||||||
|
|
||||||
// Ensure database directory exists if custom path is provided
|
|
||||||
if (process.env.DATABASE_PATH) {
|
|
||||||
const dbDir = path.dirname(DB_PATH);
|
|
||||||
try {
|
|
||||||
if (!fs.existsSync(dbDir)) {
|
|
||||||
fs.mkdirSync(dbDir, { recursive: true });
|
|
||||||
console.log(`Created database directory: ${dbDir}`);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error(`Failed to create database directory ${dbDir}:`, error.message);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create database connection
|
|
||||||
const db = new Database(DB_PATH);
|
|
||||||
console.log(`Connected to SQLite database at: ${DB_PATH}`);
|
|
||||||
|
|
||||||
// Initialize database with schema
|
|
||||||
const initializeDatabase = async () => {
|
|
||||||
try {
|
|
||||||
const initSQL = fs.readFileSync(INIT_SQL_PATH, 'utf8');
|
|
||||||
db.exec(initSQL);
|
|
||||||
console.log('Database initialized successfully');
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error initializing database:', error.message);
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// User database operations
|
|
||||||
const userDb = {
|
|
||||||
// Check if any users exist
|
|
||||||
hasUsers: () => {
|
|
||||||
try {
|
|
||||||
const row = db.prepare('SELECT COUNT(*) as count FROM users').get();
|
|
||||||
return row.count > 0;
|
|
||||||
} catch (err) {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// Create a new user
|
|
||||||
createUser: (username, passwordHash) => {
|
|
||||||
try {
|
|
||||||
const stmt = db.prepare('INSERT INTO users (username, password_hash) VALUES (?, ?)');
|
|
||||||
const result = stmt.run(username, passwordHash);
|
|
||||||
return { id: result.lastInsertRowid, username };
|
|
||||||
} catch (err) {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// Get user by username
|
|
||||||
getUserByUsername: (username) => {
|
|
||||||
try {
|
|
||||||
const row = db.prepare('SELECT * FROM users WHERE username = ? AND is_active = 1').get(username);
|
|
||||||
return row;
|
|
||||||
} catch (err) {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// Update last login time
|
|
||||||
updateLastLogin: (userId) => {
|
|
||||||
try {
|
|
||||||
db.prepare('UPDATE users SET last_login = CURRENT_TIMESTAMP WHERE id = ?').run(userId);
|
|
||||||
} catch (err) {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// Get user by ID
|
|
||||||
getUserById: (userId) => {
|
|
||||||
try {
|
|
||||||
const row = db.prepare('SELECT id, username, created_at, last_login FROM users WHERE id = ? AND is_active = 1').get(userId);
|
|
||||||
return row;
|
|
||||||
} catch (err) {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// API Keys database operations
|
|
||||||
const apiKeysDb = {
|
|
||||||
// Generate a new API key
|
|
||||||
generateApiKey: () => {
|
|
||||||
return 'ck_' + crypto.randomBytes(32).toString('hex');
|
|
||||||
},
|
|
||||||
|
|
||||||
// Create a new API key
|
|
||||||
createApiKey: (userId, keyName) => {
|
|
||||||
try {
|
|
||||||
const apiKey = apiKeysDb.generateApiKey();
|
|
||||||
const stmt = db.prepare('INSERT INTO api_keys (user_id, key_name, api_key) VALUES (?, ?, ?)');
|
|
||||||
const result = stmt.run(userId, keyName, apiKey);
|
|
||||||
return { id: result.lastInsertRowid, keyName, apiKey };
|
|
||||||
} catch (err) {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// Get all API keys for a user
|
|
||||||
getApiKeys: (userId) => {
|
|
||||||
try {
|
|
||||||
const rows = db.prepare('SELECT id, key_name, api_key, created_at, last_used, is_active FROM api_keys WHERE user_id = ? ORDER BY created_at DESC').all(userId);
|
|
||||||
return rows;
|
|
||||||
} catch (err) {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// Validate API key and get user
|
|
||||||
validateApiKey: (apiKey) => {
|
|
||||||
try {
|
|
||||||
const row = db.prepare(`
|
|
||||||
SELECT u.id, u.username, ak.id as api_key_id
|
|
||||||
FROM api_keys ak
|
|
||||||
JOIN users u ON ak.user_id = u.id
|
|
||||||
WHERE ak.api_key = ? AND ak.is_active = 1 AND u.is_active = 1
|
|
||||||
`).get(apiKey);
|
|
||||||
|
|
||||||
if (row) {
|
|
||||||
// Update last_used timestamp
|
|
||||||
db.prepare('UPDATE api_keys SET last_used = CURRENT_TIMESTAMP WHERE id = ?').run(row.api_key_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
return row;
|
|
||||||
} catch (err) {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// Delete an API key
|
|
||||||
deleteApiKey: (userId, apiKeyId) => {
|
|
||||||
try {
|
|
||||||
const stmt = db.prepare('DELETE FROM api_keys WHERE id = ? AND user_id = ?');
|
|
||||||
const result = stmt.run(apiKeyId, userId);
|
|
||||||
return result.changes > 0;
|
|
||||||
} catch (err) {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// Toggle API key active status
|
|
||||||
toggleApiKey: (userId, apiKeyId, isActive) => {
|
|
||||||
try {
|
|
||||||
const stmt = db.prepare('UPDATE api_keys SET is_active = ? WHERE id = ? AND user_id = ?');
|
|
||||||
const result = stmt.run(isActive ? 1 : 0, apiKeyId, userId);
|
|
||||||
return result.changes > 0;
|
|
||||||
} catch (err) {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// User credentials database operations (for GitHub tokens, GitLab tokens, etc.)
|
|
||||||
const credentialsDb = {
|
|
||||||
// Create a new credential
|
|
||||||
createCredential: (userId, credentialName, credentialType, credentialValue, description = null) => {
|
|
||||||
try {
|
|
||||||
const stmt = db.prepare('INSERT INTO user_credentials (user_id, credential_name, credential_type, credential_value, description) VALUES (?, ?, ?, ?, ?)');
|
|
||||||
const result = stmt.run(userId, credentialName, credentialType, credentialValue, description);
|
|
||||||
return { id: result.lastInsertRowid, credentialName, credentialType };
|
|
||||||
} catch (err) {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// Get all credentials for a user, optionally filtered by type
|
|
||||||
getCredentials: (userId, credentialType = null) => {
|
|
||||||
try {
|
|
||||||
let query = 'SELECT id, credential_name, credential_type, description, created_at, is_active FROM user_credentials WHERE user_id = ?';
|
|
||||||
const params = [userId];
|
|
||||||
|
|
||||||
if (credentialType) {
|
|
||||||
query += ' AND credential_type = ?';
|
|
||||||
params.push(credentialType);
|
|
||||||
}
|
|
||||||
|
|
||||||
query += ' ORDER BY created_at DESC';
|
|
||||||
|
|
||||||
const rows = db.prepare(query).all(...params);
|
|
||||||
return rows;
|
|
||||||
} catch (err) {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// Get active credential value for a user by type (returns most recent active)
|
|
||||||
getActiveCredential: (userId, credentialType) => {
|
|
||||||
try {
|
|
||||||
const row = db.prepare('SELECT credential_value FROM user_credentials WHERE user_id = ? AND credential_type = ? AND is_active = 1 ORDER BY created_at DESC LIMIT 1').get(userId, credentialType);
|
|
||||||
return row?.credential_value || null;
|
|
||||||
} catch (err) {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// Delete a credential
|
|
||||||
deleteCredential: (userId, credentialId) => {
|
|
||||||
try {
|
|
||||||
const stmt = db.prepare('DELETE FROM user_credentials WHERE id = ? AND user_id = ?');
|
|
||||||
const result = stmt.run(credentialId, userId);
|
|
||||||
return result.changes > 0;
|
|
||||||
} catch (err) {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// Toggle credential active status
|
|
||||||
toggleCredential: (userId, credentialId, isActive) => {
|
|
||||||
try {
|
|
||||||
const stmt = db.prepare('UPDATE user_credentials SET is_active = ? WHERE id = ? AND user_id = ?');
|
|
||||||
const result = stmt.run(isActive ? 1 : 0, credentialId, userId);
|
|
||||||
return result.changes > 0;
|
|
||||||
} catch (err) {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Backward compatibility - keep old names pointing to new system
|
|
||||||
const githubTokensDb = {
|
|
||||||
createGithubToken: (userId, tokenName, githubToken, description = null) => {
|
|
||||||
return credentialsDb.createCredential(userId, tokenName, 'github_token', githubToken, description);
|
|
||||||
},
|
|
||||||
getGithubTokens: (userId) => {
|
|
||||||
return credentialsDb.getCredentials(userId, 'github_token');
|
|
||||||
},
|
|
||||||
getActiveGithubToken: (userId) => {
|
|
||||||
return credentialsDb.getActiveCredential(userId, 'github_token');
|
|
||||||
},
|
|
||||||
deleteGithubToken: (userId, tokenId) => {
|
|
||||||
return credentialsDb.deleteCredential(userId, tokenId);
|
|
||||||
},
|
|
||||||
toggleGithubToken: (userId, tokenId, isActive) => {
|
|
||||||
return credentialsDb.toggleCredential(userId, tokenId, isActive);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export {
|
|
||||||
db,
|
|
||||||
initializeDatabase,
|
|
||||||
userDb,
|
|
||||||
apiKeysDb,
|
|
||||||
credentialsDb,
|
|
||||||
githubTokensDb // Backward compatibility
|
|
||||||
};
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
-- Initialize authentication database
|
|
||||||
PRAGMA foreign_keys = ON;
|
|
||||||
|
|
||||||
-- Users table (single user system)
|
|
||||||
CREATE TABLE IF NOT EXISTS users (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
username TEXT UNIQUE NOT NULL,
|
|
||||||
password_hash TEXT NOT NULL,
|
|
||||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
last_login DATETIME,
|
|
||||||
is_active BOOLEAN DEFAULT 1
|
|
||||||
);
|
|
||||||
|
|
||||||
-- Indexes for performance
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_users_username ON users(username);
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_users_active ON users(is_active);
|
|
||||||
|
|
||||||
-- API Keys table for external API access
|
|
||||||
CREATE TABLE IF NOT EXISTS api_keys (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
user_id INTEGER NOT NULL,
|
|
||||||
key_name TEXT NOT NULL,
|
|
||||||
api_key TEXT UNIQUE NOT NULL,
|
|
||||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
last_used DATETIME,
|
|
||||||
is_active BOOLEAN DEFAULT 1,
|
|
||||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_api_keys_key ON api_keys(api_key);
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_api_keys_user_id ON api_keys(user_id);
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_api_keys_active ON api_keys(is_active);
|
|
||||||
|
|
||||||
-- User credentials table for storing various tokens/credentials (GitHub, GitLab, etc.)
|
|
||||||
CREATE TABLE IF NOT EXISTS user_credentials (
|
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
||||||
user_id INTEGER NOT NULL,
|
|
||||||
credential_name TEXT NOT NULL,
|
|
||||||
credential_type TEXT NOT NULL, -- 'github_token', 'gitlab_token', 'bitbucket_token', etc.
|
|
||||||
credential_value TEXT NOT NULL,
|
|
||||||
description TEXT,
|
|
||||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
||||||
is_active BOOLEAN DEFAULT 1,
|
|
||||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
|
||||||
);
|
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_user_credentials_user_id ON user_credentials(user_id);
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_user_credentials_type ON user_credentials(credential_type);
|
|
||||||
CREATE INDEX IF NOT EXISTS idx_user_credentials_active ON user_credentials(is_active);
|
|
||||||
617
server/gemini-cli.js
Normal file
@@ -0,0 +1,617 @@
|
|||||||
|
import { spawn } from 'child_process';
|
||||||
|
import { promises as fs } from 'fs';
|
||||||
|
import os from 'os';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
|
import crossSpawn from 'cross-spawn';
|
||||||
|
|
||||||
|
import sessionManager from './sessionManager.js';
|
||||||
|
import GeminiResponseHandler from './gemini-response-handler.js';
|
||||||
|
import { notifyRunFailed, notifyRunStopped } from './services/notification-orchestrator.js';
|
||||||
|
import { providerAuthService } from './modules/providers/services/provider-auth.service.js';
|
||||||
|
import { createNormalizedMessage } from './shared/utils.js';
|
||||||
|
|
||||||
|
// Use cross-spawn on Windows for correct .cmd resolution (same pattern as cursor-cli.js)
|
||||||
|
const spawnFunction = process.platform === 'win32' ? crossSpawn : spawn;
|
||||||
|
|
||||||
|
let activeGeminiProcesses = new Map(); // Track active processes by session ID
|
||||||
|
|
||||||
|
function mapGeminiExitCodeToMessage(exitCode) {
|
||||||
|
switch (exitCode) {
|
||||||
|
case 42:
|
||||||
|
return 'Gemini rejected the request input (exit code 42).';
|
||||||
|
case 44:
|
||||||
|
return 'Gemini sandbox error (exit code 44). Check local sandbox/container settings.';
|
||||||
|
case 52:
|
||||||
|
return 'Gemini configuration error (exit code 52). Check your Gemini settings files for invalid JSON/config.';
|
||||||
|
case 53:
|
||||||
|
return 'Gemini conversation turn limit reached (exit code 53). Start a new Gemini session.';
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const GEMINI_AUTH_ENV_KEYS = [
|
||||||
|
'GEMINI_API_KEY',
|
||||||
|
'GOOGLE_API_KEY',
|
||||||
|
'GOOGLE_CLOUD_PROJECT',
|
||||||
|
'GOOGLE_CLOUD_PROJECT_ID',
|
||||||
|
'GOOGLE_CLOUD_LOCATION',
|
||||||
|
'GOOGLE_APPLICATION_CREDENTIALS'
|
||||||
|
];
|
||||||
|
|
||||||
|
function parseEnvFileContent(content) {
|
||||||
|
const parsed = {};
|
||||||
|
|
||||||
|
for (const rawLine of content.split(/\r?\n/)) {
|
||||||
|
const line = rawLine.trim();
|
||||||
|
if (!line || line.startsWith('#')) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const exportPrefix = 'export ';
|
||||||
|
const normalizedLine = line.startsWith(exportPrefix) ? line.slice(exportPrefix.length).trim() : line;
|
||||||
|
const separatorIndex = normalizedLine.indexOf('=');
|
||||||
|
|
||||||
|
if (separatorIndex <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const key = normalizedLine.slice(0, separatorIndex).trim();
|
||||||
|
if (!key) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
let value = normalizedLine.slice(separatorIndex + 1).trim();
|
||||||
|
const hasDoubleQuotes = value.startsWith('"') && value.endsWith('"');
|
||||||
|
const hasSingleQuotes = value.startsWith('\'') && value.endsWith('\'');
|
||||||
|
|
||||||
|
if (hasDoubleQuotes || hasSingleQuotes) {
|
||||||
|
value = value.slice(1, -1);
|
||||||
|
} else {
|
||||||
|
// Support inline comments in unquoted values: KEY=value # comment
|
||||||
|
value = value.replace(/\s+#.*$/, '').trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
parsed[key] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return parsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadGeminiUserLevelEnv() {
|
||||||
|
const geminiCliHome = (process.env.GEMINI_CLI_HOME || '').trim() || os.homedir();
|
||||||
|
const envCandidates = [
|
||||||
|
path.join(geminiCliHome, '.gemini', '.env'),
|
||||||
|
path.join(geminiCliHome, '.env')
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const envPath of envCandidates) {
|
||||||
|
try {
|
||||||
|
await fs.access(envPath);
|
||||||
|
const content = await fs.readFile(envPath, 'utf8');
|
||||||
|
return parseEnvFileContent(content);
|
||||||
|
} catch {
|
||||||
|
// Keep scanning for the next candidate.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
async function buildGeminiProcessEnv() {
|
||||||
|
const processEnv = { ...process.env };
|
||||||
|
if (processEnv.GEMINI_API_KEY || processEnv.GOOGLE_API_KEY || processEnv.GOOGLE_APPLICATION_CREDENTIALS) {
|
||||||
|
return processEnv;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gemini CLI docs recommend ~/.gemini/.env for persistent headless auth settings.
|
||||||
|
// When the server process was launched without shell profile variables, we still
|
||||||
|
// want the spawned CLI process to inherit those user-level credentials.
|
||||||
|
const userEnv = await loadGeminiUserLevelEnv();
|
||||||
|
for (const key of GEMINI_AUTH_ENV_KEYS) {
|
||||||
|
if (!processEnv[key] && userEnv[key]) {
|
||||||
|
processEnv[key] = userEnv[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return processEnv;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function spawnGemini(command, options = {}, ws) {
|
||||||
|
const { sessionId, projectPath, cwd, toolsSettings, permissionMode, images, sessionSummary } = options;
|
||||||
|
let capturedSessionId = sessionId; // Track session ID throughout the process
|
||||||
|
let sessionCreatedSent = false; // Track if we've already sent session-created event
|
||||||
|
let assistantBlocks = []; // Accumulate the full response blocks including tools
|
||||||
|
|
||||||
|
// Use tools settings passed from frontend, or defaults
|
||||||
|
const settings = toolsSettings || {
|
||||||
|
allowedTools: [],
|
||||||
|
disallowedTools: [],
|
||||||
|
skipPermissions: false
|
||||||
|
};
|
||||||
|
|
||||||
|
// Build Gemini CLI command - start with print/resume flags first
|
||||||
|
const args = [];
|
||||||
|
|
||||||
|
// Add prompt flag with command if we have a command
|
||||||
|
if (command && command.trim()) {
|
||||||
|
args.push('--prompt', command);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we have a sessionId, we want to resume
|
||||||
|
if (sessionId) {
|
||||||
|
const session = sessionManager.getSession(sessionId);
|
||||||
|
if (session && session.cliSessionId) {
|
||||||
|
args.push('--resume', session.cliSessionId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use cwd (actual project directory) instead of projectPath (Gemini's metadata directory)
|
||||||
|
// Clean the path by removing any non-printable characters
|
||||||
|
const cleanPath = (cwd || projectPath || process.cwd()).replace(/[^\x20-\x7E]/g, '').trim();
|
||||||
|
const workingDir = cleanPath;
|
||||||
|
|
||||||
|
// Handle images by saving them to temporary files and passing paths to Gemini
|
||||||
|
const tempImagePaths = [];
|
||||||
|
let tempDir = null;
|
||||||
|
if (images && images.length > 0) {
|
||||||
|
try {
|
||||||
|
// Create temp directory in the project directory so Gemini can access it
|
||||||
|
tempDir = path.join(workingDir, '.tmp', 'images', Date.now().toString());
|
||||||
|
await fs.mkdir(tempDir, { recursive: true });
|
||||||
|
|
||||||
|
// Save each image to a temp file
|
||||||
|
for (const [index, image] of images.entries()) {
|
||||||
|
// Extract base64 data and mime type
|
||||||
|
const matches = image.data.match(/^data:([^;]+);base64,(.+)$/);
|
||||||
|
if (!matches) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const [, mimeType, base64Data] = matches;
|
||||||
|
const extension = mimeType.split('/')[1] || 'png';
|
||||||
|
const filename = `image_${index}.${extension}`;
|
||||||
|
const filepath = path.join(tempDir, filename);
|
||||||
|
|
||||||
|
// Write base64 data to file
|
||||||
|
await fs.writeFile(filepath, Buffer.from(base64Data, 'base64'));
|
||||||
|
tempImagePaths.push(filepath);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Include the full image paths in the prompt for Gemini to reference
|
||||||
|
// Gemini CLI can read images from file paths in the prompt
|
||||||
|
if (tempImagePaths.length > 0 && command && command.trim()) {
|
||||||
|
const imageNote = `\n\n[Images given: ${tempImagePaths.length} images are located at the following paths:]\n${tempImagePaths.map((p, i) => `${i + 1}. ${p}`).join('\n')}`;
|
||||||
|
const modifiedCommand = command + imageNote;
|
||||||
|
|
||||||
|
// Update the command in args
|
||||||
|
const promptIndex = args.indexOf('--prompt');
|
||||||
|
if (promptIndex !== -1 && args[promptIndex + 1] === command) {
|
||||||
|
args[promptIndex + 1] = modifiedCommand;
|
||||||
|
} else if (promptIndex !== -1) {
|
||||||
|
// If we're using context, update the full prompt
|
||||||
|
args[promptIndex + 1] = args[promptIndex + 1] + imageNote;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error processing images for Gemini:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add basic flags for Gemini
|
||||||
|
if (options.debug) {
|
||||||
|
args.push('--debug');
|
||||||
|
}
|
||||||
|
|
||||||
|
// This integration runs Gemini in headless mode and cannot answer trust prompts.
|
||||||
|
// Skip folder-trust interactivity so authenticated runs don't fail with
|
||||||
|
// FatalUntrustedWorkspaceError in previously unseen directories.
|
||||||
|
args.push('--skip-trust');
|
||||||
|
|
||||||
|
// Add MCP config flag only if MCP servers are configured
|
||||||
|
try {
|
||||||
|
const geminiConfigPath = path.join(os.homedir(), '.gemini.json');
|
||||||
|
let hasMcpServers = false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await fs.access(geminiConfigPath);
|
||||||
|
const geminiConfigRaw = await fs.readFile(geminiConfigPath, 'utf8');
|
||||||
|
const geminiConfig = JSON.parse(geminiConfigRaw);
|
||||||
|
|
||||||
|
// Check global MCP servers
|
||||||
|
if (geminiConfig.mcpServers && Object.keys(geminiConfig.mcpServers).length > 0) {
|
||||||
|
hasMcpServers = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check project-specific MCP servers
|
||||||
|
if (!hasMcpServers && geminiConfig.geminiProjects) {
|
||||||
|
const currentProjectPath = process.cwd();
|
||||||
|
const projectConfig = geminiConfig.geminiProjects[currentProjectPath];
|
||||||
|
if (projectConfig && projectConfig.mcpServers && Object.keys(projectConfig.mcpServers).length > 0) {
|
||||||
|
hasMcpServers = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// Ignore if file doesn't exist or isn't parsable
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasMcpServers) {
|
||||||
|
args.push('--mcp-config', geminiConfigPath);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
// Ignore outer errors
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add model for all sessions (both new and resumed)
|
||||||
|
let modelToUse = options.model || 'gemini-2.5-flash';
|
||||||
|
args.push('--model', modelToUse);
|
||||||
|
args.push('--output-format', 'stream-json');
|
||||||
|
|
||||||
|
// Handle approval modes and allowed tools
|
||||||
|
if (settings.skipPermissions || options.skipPermissions || permissionMode === 'yolo') {
|
||||||
|
args.push('--yolo');
|
||||||
|
} else if (permissionMode === 'auto_edit') {
|
||||||
|
args.push('--approval-mode', 'auto_edit');
|
||||||
|
} else if (permissionMode === 'plan') {
|
||||||
|
args.push('--approval-mode', 'plan');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (settings.allowedTools && settings.allowedTools.length > 0) {
|
||||||
|
args.push('--allowed-tools', settings.allowedTools.join(','));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try to find gemini in PATH first, then fall back to environment variable
|
||||||
|
const geminiPath = process.env.GEMINI_PATH || 'gemini';
|
||||||
|
let spawnCmd = geminiPath;
|
||||||
|
let spawnArgs = args;
|
||||||
|
|
||||||
|
// On non-Windows platforms, wrap the execution in a shell to avoid ENOEXEC
|
||||||
|
// which happens when the target is a script lacking a shebang.
|
||||||
|
if (os.platform() !== 'win32') {
|
||||||
|
spawnCmd = 'sh';
|
||||||
|
// Use exec to replace the shell process, ensuring signals hit gemini directly
|
||||||
|
spawnArgs = ['-c', 'exec "$0" "$@"', geminiPath, ...args];
|
||||||
|
}
|
||||||
|
|
||||||
|
const spawnEnv = await buildGeminiProcessEnv();
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const geminiProcess = spawnFunction(spawnCmd, spawnArgs, {
|
||||||
|
cwd: workingDir,
|
||||||
|
stdio: ['pipe', 'pipe', 'pipe'],
|
||||||
|
env: spawnEnv
|
||||||
|
});
|
||||||
|
let terminalNotificationSent = false;
|
||||||
|
let terminalFailureReason = null;
|
||||||
|
|
||||||
|
const notifyTerminalState = ({ code = null, error = null } = {}) => {
|
||||||
|
if (terminalNotificationSent) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
terminalNotificationSent = true;
|
||||||
|
|
||||||
|
const finalSessionId = capturedSessionId || sessionId || processKey;
|
||||||
|
if (code === 0 && !error) {
|
||||||
|
notifyRunStopped({
|
||||||
|
userId: ws?.userId || null,
|
||||||
|
provider: 'gemini',
|
||||||
|
sessionId: finalSessionId,
|
||||||
|
sessionName: sessionSummary,
|
||||||
|
stopReason: 'completed'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
notifyRunFailed({
|
||||||
|
userId: ws?.userId || null,
|
||||||
|
provider: 'gemini',
|
||||||
|
sessionId: finalSessionId,
|
||||||
|
sessionName: sessionSummary,
|
||||||
|
error: error || terminalFailureReason || `Gemini CLI exited with code ${code}`
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// Attach temp file info to process for cleanup later
|
||||||
|
geminiProcess.tempImagePaths = tempImagePaths;
|
||||||
|
geminiProcess.tempDir = tempDir;
|
||||||
|
|
||||||
|
// Store process reference for potential abort
|
||||||
|
const processKey = capturedSessionId || sessionId || Date.now().toString();
|
||||||
|
activeGeminiProcesses.set(processKey, geminiProcess);
|
||||||
|
|
||||||
|
// Store sessionId on the process object for debugging
|
||||||
|
geminiProcess.sessionId = processKey;
|
||||||
|
|
||||||
|
// Close stdin to signal we're done sending input
|
||||||
|
geminiProcess.stdin.end();
|
||||||
|
|
||||||
|
// Add timeout handler
|
||||||
|
const timeoutMs = 120000; // 120 seconds for slower models
|
||||||
|
let timeout;
|
||||||
|
|
||||||
|
const startTimeout = () => {
|
||||||
|
if (timeout) clearTimeout(timeout);
|
||||||
|
timeout = setTimeout(() => {
|
||||||
|
const socketSessionId = typeof ws.getSessionId === 'function' ? ws.getSessionId() : (capturedSessionId || sessionId || processKey);
|
||||||
|
terminalFailureReason = `Gemini CLI timeout - no response received for ${timeoutMs / 1000} seconds`;
|
||||||
|
ws.send(createNormalizedMessage({ kind: 'error', content: terminalFailureReason, sessionId: socketSessionId, provider: 'gemini' }));
|
||||||
|
try {
|
||||||
|
geminiProcess.kill('SIGTERM');
|
||||||
|
} catch (e) { }
|
||||||
|
}, timeoutMs);
|
||||||
|
};
|
||||||
|
|
||||||
|
startTimeout();
|
||||||
|
|
||||||
|
// Save user message to session when starting
|
||||||
|
if (command && capturedSessionId) {
|
||||||
|
sessionManager.addMessage(capturedSessionId, 'user', command);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create response handler for NDJSON buffering
|
||||||
|
let responseHandler;
|
||||||
|
if (ws) {
|
||||||
|
responseHandler = new GeminiResponseHandler(ws, {
|
||||||
|
onContentFragment: (content) => {
|
||||||
|
if (assistantBlocks.length > 0 && assistantBlocks[assistantBlocks.length - 1].type === 'text') {
|
||||||
|
assistantBlocks[assistantBlocks.length - 1].text += content;
|
||||||
|
} else {
|
||||||
|
assistantBlocks.push({ type: 'text', text: content });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onToolUse: (event) => {
|
||||||
|
assistantBlocks.push({
|
||||||
|
type: 'tool_use',
|
||||||
|
id: event.tool_id,
|
||||||
|
name: event.tool_name,
|
||||||
|
input: event.parameters
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onToolResult: (event) => {
|
||||||
|
if (capturedSessionId) {
|
||||||
|
if (assistantBlocks.length > 0) {
|
||||||
|
sessionManager.addMessage(capturedSessionId, 'assistant', [...assistantBlocks]);
|
||||||
|
assistantBlocks = [];
|
||||||
|
}
|
||||||
|
sessionManager.addMessage(capturedSessionId, 'user', [{
|
||||||
|
type: 'tool_result',
|
||||||
|
tool_use_id: event.tool_id,
|
||||||
|
content: event.output === undefined ? null : event.output,
|
||||||
|
is_error: event.status === 'error'
|
||||||
|
}]);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onInit: (event) => {
|
||||||
|
const discoveredSessionId = event?.session_id;
|
||||||
|
if (!discoveredSessionId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// New Gemini sessions announce their canonical ID asynchronously via the
|
||||||
|
// initial `init` stream event. Avoid synthetic IDs and only register
|
||||||
|
// the session once that real ID is known (same model used by Claude/Codex).
|
||||||
|
if (!capturedSessionId) {
|
||||||
|
capturedSessionId = discoveredSessionId;
|
||||||
|
|
||||||
|
sessionManager.createSession(capturedSessionId, cwd || process.cwd());
|
||||||
|
if (command) {
|
||||||
|
sessionManager.addMessage(capturedSessionId, 'user', command);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (processKey !== capturedSessionId) {
|
||||||
|
activeGeminiProcesses.delete(processKey);
|
||||||
|
activeGeminiProcesses.set(capturedSessionId, geminiProcess);
|
||||||
|
}
|
||||||
|
|
||||||
|
geminiProcess.sessionId = capturedSessionId;
|
||||||
|
|
||||||
|
if (ws.setSessionId && typeof ws.setSessionId === 'function') {
|
||||||
|
ws.setSessionId(capturedSessionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sessionId && !sessionCreatedSent) {
|
||||||
|
sessionCreatedSent = true;
|
||||||
|
ws.send(createNormalizedMessage({ kind: 'session_created', newSessionId: capturedSessionId, sessionId: capturedSessionId, provider: 'gemini' }));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const sess = sessionManager.getSession(capturedSessionId);
|
||||||
|
if (sess && !sess.cliSessionId) {
|
||||||
|
sess.cliSessionId = discoveredSessionId;
|
||||||
|
sessionManager.saveSession(capturedSessionId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle stdout
|
||||||
|
geminiProcess.stdout.on('data', (data) => {
|
||||||
|
const rawOutput = data.toString();
|
||||||
|
startTimeout(); // Re-arm the timeout
|
||||||
|
|
||||||
|
if (responseHandler) {
|
||||||
|
responseHandler.processData(rawOutput);
|
||||||
|
} else if (rawOutput) {
|
||||||
|
// Fallback to direct sending for raw CLI mode without WS
|
||||||
|
if (assistantBlocks.length > 0 && assistantBlocks[assistantBlocks.length - 1].type === 'text') {
|
||||||
|
assistantBlocks[assistantBlocks.length - 1].text += rawOutput;
|
||||||
|
} else {
|
||||||
|
assistantBlocks.push({ type: 'text', text: rawOutput });
|
||||||
|
}
|
||||||
|
const socketSessionId = typeof ws.getSessionId === 'function' ? ws.getSessionId() : (capturedSessionId || sessionId);
|
||||||
|
ws.send(createNormalizedMessage({ kind: 'stream_delta', content: rawOutput, sessionId: socketSessionId, provider: 'gemini' }));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Handle stderr
|
||||||
|
geminiProcess.stderr.on('data', (data) => {
|
||||||
|
const errorMsg = data.toString();
|
||||||
|
|
||||||
|
// Filter out deprecation warnings and "Loaded cached credentials" message
|
||||||
|
if (errorMsg.includes('[DEP0040]') ||
|
||||||
|
errorMsg.includes('DeprecationWarning') ||
|
||||||
|
errorMsg.includes('--trace-deprecation') ||
|
||||||
|
errorMsg.includes('Loaded cached credentials')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const socketSessionId = typeof ws.getSessionId === 'function' ? ws.getSessionId() : (capturedSessionId || sessionId);
|
||||||
|
ws.send(createNormalizedMessage({ kind: 'error', content: errorMsg, sessionId: socketSessionId, provider: 'gemini' }));
|
||||||
|
});
|
||||||
|
|
||||||
|
// Handle process completion
|
||||||
|
geminiProcess.on('close', async (code) => {
|
||||||
|
clearTimeout(timeout);
|
||||||
|
|
||||||
|
// Flush any remaining buffered content
|
||||||
|
if (responseHandler) {
|
||||||
|
responseHandler.forceFlush();
|
||||||
|
responseHandler.destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clean up process reference
|
||||||
|
const finalSessionId = capturedSessionId || sessionId || processKey;
|
||||||
|
activeGeminiProcesses.delete(finalSessionId);
|
||||||
|
|
||||||
|
// Save assistant response to session if we have one
|
||||||
|
if (finalSessionId && assistantBlocks.length > 0) {
|
||||||
|
sessionManager.addMessage(finalSessionId, 'assistant', assistantBlocks);
|
||||||
|
}
|
||||||
|
|
||||||
|
ws.send(createNormalizedMessage({ kind: 'complete', exitCode: code, isNewSession: !sessionId && !!command, sessionId: finalSessionId, provider: 'gemini' }));
|
||||||
|
|
||||||
|
// Clean up temporary image files if any
|
||||||
|
if (geminiProcess.tempImagePaths && geminiProcess.tempImagePaths.length > 0) {
|
||||||
|
for (const imagePath of geminiProcess.tempImagePaths) {
|
||||||
|
await fs.unlink(imagePath).catch(err => { });
|
||||||
|
}
|
||||||
|
if (geminiProcess.tempDir) {
|
||||||
|
await fs.rm(geminiProcess.tempDir, { recursive: true, force: true }).catch(err => { });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (code === 0) {
|
||||||
|
notifyTerminalState({ code });
|
||||||
|
resolve();
|
||||||
|
} else {
|
||||||
|
const socketSessionId = typeof ws.getSessionId === 'function' ? ws.getSessionId() : finalSessionId;
|
||||||
|
|
||||||
|
// code 127 = shell "command not found" - check installation
|
||||||
|
if (code === 127) {
|
||||||
|
const installed = await providerAuthService.isProviderInstalled('gemini');
|
||||||
|
if (!installed) {
|
||||||
|
terminalFailureReason = 'Gemini CLI is not installed. Please install it first: https://github.com/google-gemini/gemini-cli';
|
||||||
|
ws.send(createNormalizedMessage({ kind: 'error', content: terminalFailureReason, sessionId: socketSessionId, provider: 'gemini' }));
|
||||||
|
}
|
||||||
|
} else if (code === 41) {
|
||||||
|
// Gemini CLI documents exit code 41 as FatalAuthenticationError.
|
||||||
|
// Surface an actionable auth error instead of a generic exit-code message.
|
||||||
|
let authErrorSuffix = '';
|
||||||
|
try {
|
||||||
|
const authStatus = await providerAuthService.getProviderAuthStatus('gemini');
|
||||||
|
if (!authStatus?.authenticated && authStatus?.error) {
|
||||||
|
authErrorSuffix = ` Details: ${authStatus.error}`;
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// Keep base remediation text when auth status lookup fails.
|
||||||
|
}
|
||||||
|
|
||||||
|
terminalFailureReason =
|
||||||
|
'Gemini authentication failed (exit code 41). '
|
||||||
|
+ 'Run `gemini` in a terminal to choose an auth method, or configure a valid `GEMINI_API_KEY`.'
|
||||||
|
+ authErrorSuffix;
|
||||||
|
ws.send(createNormalizedMessage({ kind: 'error', content: terminalFailureReason, sessionId: socketSessionId, provider: 'gemini' }));
|
||||||
|
} else {
|
||||||
|
const mappedError = mapGeminiExitCodeToMessage(code);
|
||||||
|
if (mappedError) {
|
||||||
|
terminalFailureReason = mappedError;
|
||||||
|
ws.send(createNormalizedMessage({ kind: 'error', content: terminalFailureReason, sessionId: socketSessionId, provider: 'gemini' }));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
notifyTerminalState({
|
||||||
|
code,
|
||||||
|
error: code === null ? 'Gemini CLI process was terminated or timed out' : null
|
||||||
|
});
|
||||||
|
reject(
|
||||||
|
new Error(
|
||||||
|
terminalFailureReason
|
||||||
|
|| (code === null
|
||||||
|
? 'Gemini CLI process was terminated or timed out'
|
||||||
|
: `Gemini CLI exited with code ${code}`)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Handle process errors
|
||||||
|
geminiProcess.on('error', async (error) => {
|
||||||
|
// Clean up process reference on error
|
||||||
|
const finalSessionId = capturedSessionId || sessionId || processKey;
|
||||||
|
activeGeminiProcesses.delete(finalSessionId);
|
||||||
|
|
||||||
|
// Check if Gemini CLI is installed for a clearer error message
|
||||||
|
const installed = await providerAuthService.isProviderInstalled('gemini');
|
||||||
|
const errorContent = !installed
|
||||||
|
? 'Gemini CLI is not installed. Please install it first: https://github.com/google-gemini/gemini-cli'
|
||||||
|
: error.message;
|
||||||
|
|
||||||
|
const errorSessionId = typeof ws.getSessionId === 'function' ? ws.getSessionId() : finalSessionId;
|
||||||
|
ws.send(createNormalizedMessage({ kind: 'error', content: errorContent, sessionId: errorSessionId, provider: 'gemini' }));
|
||||||
|
notifyTerminalState({ error });
|
||||||
|
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function abortGeminiSession(sessionId) {
|
||||||
|
let geminiProc = activeGeminiProcesses.get(sessionId);
|
||||||
|
let processKey = sessionId;
|
||||||
|
|
||||||
|
if (!geminiProc) {
|
||||||
|
for (const [key, proc] of activeGeminiProcesses.entries()) {
|
||||||
|
if (proc.sessionId === sessionId) {
|
||||||
|
geminiProc = proc;
|
||||||
|
processKey = key;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (geminiProc) {
|
||||||
|
try {
|
||||||
|
geminiProc.kill('SIGTERM');
|
||||||
|
setTimeout(() => {
|
||||||
|
if (activeGeminiProcesses.has(processKey)) {
|
||||||
|
try {
|
||||||
|
geminiProc.kill('SIGKILL');
|
||||||
|
} catch (e) { }
|
||||||
|
}
|
||||||
|
}, 2000); // Wait 2 seconds before force kill
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} catch (error) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isGeminiSessionActive(sessionId) {
|
||||||
|
return activeGeminiProcesses.has(sessionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getActiveGeminiSessions() {
|
||||||
|
return Array.from(activeGeminiProcesses.keys());
|
||||||
|
}
|
||||||
|
|
||||||
|
export {
|
||||||
|
spawnGemini,
|
||||||
|
abortGeminiSession,
|
||||||
|
isGeminiSessionActive,
|
||||||
|
getActiveGeminiSessions
|
||||||
|
};
|
||||||
79
server/gemini-response-handler.js
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
// Gemini Response Handler - JSON Stream processing
|
||||||
|
import { sessionsService } from './modules/providers/services/sessions.service.js';
|
||||||
|
|
||||||
|
class GeminiResponseHandler {
|
||||||
|
constructor(ws, options = {}) {
|
||||||
|
this.ws = ws;
|
||||||
|
this.buffer = '';
|
||||||
|
this.onContentFragment = options.onContentFragment || null;
|
||||||
|
this.onInit = options.onInit || null;
|
||||||
|
this.onToolUse = options.onToolUse || null;
|
||||||
|
this.onToolResult = options.onToolResult || null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process incoming raw data from Gemini stream-json
|
||||||
|
processData(data) {
|
||||||
|
this.buffer += data;
|
||||||
|
|
||||||
|
// Split by newline
|
||||||
|
const lines = this.buffer.split('\n');
|
||||||
|
|
||||||
|
// Keep the last incomplete line in the buffer
|
||||||
|
this.buffer = lines.pop() || '';
|
||||||
|
|
||||||
|
for (const line of lines) {
|
||||||
|
if (!line.trim()) continue;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const event = JSON.parse(line);
|
||||||
|
this.handleEvent(event);
|
||||||
|
} catch (err) {
|
||||||
|
// Not a JSON line, probably debug output or CLI warnings
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handleEvent(event) {
|
||||||
|
const sid = typeof this.ws.getSessionId === 'function' ? this.ws.getSessionId() : null;
|
||||||
|
|
||||||
|
if (event.type === 'init') {
|
||||||
|
if (this.onInit) {
|
||||||
|
this.onInit(event);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Invoke per-type callbacks for session tracking
|
||||||
|
if (event.type === 'message' && event.role === 'assistant') {
|
||||||
|
const content = event.content || '';
|
||||||
|
if (this.onContentFragment && content) {
|
||||||
|
this.onContentFragment(content);
|
||||||
|
}
|
||||||
|
} else if (event.type === 'tool_use' && this.onToolUse) {
|
||||||
|
this.onToolUse(event);
|
||||||
|
} else if (event.type === 'tool_result' && this.onToolResult) {
|
||||||
|
this.onToolResult(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Normalize via adapter and send all resulting messages
|
||||||
|
const normalized = sessionsService.normalizeMessage('gemini', event, sid);
|
||||||
|
for (const msg of normalized) {
|
||||||
|
this.ws.send(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
forceFlush() {
|
||||||
|
if (this.buffer.trim()) {
|
||||||
|
try {
|
||||||
|
const event = JSON.parse(this.buffer);
|
||||||
|
this.handleEvent(event);
|
||||||
|
} catch (err) { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
destroy() {
|
||||||
|
this.buffer = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default GeminiResponseHandler;
|
||||||
1873
server/index.js
34
server/load-env.js
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
// Load environment variables from .env before other imports execute.
|
||||||
|
import fs from 'fs';
|
||||||
|
import os from 'os';
|
||||||
|
import path from 'path';
|
||||||
|
import { findAppRoot, getModuleDir } from './utils/runtime-paths.js';
|
||||||
|
|
||||||
|
const __dirname = getModuleDir(import.meta.url);
|
||||||
|
// Resolve the repo/app root via the nearest /server folder so this file keeps finding the
|
||||||
|
// same top-level .env file from both /server/load-env.js and /dist-server/server/load-env.js.
|
||||||
|
const APP_ROOT = findAppRoot(__dirname);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const envPath = path.join(APP_ROOT, '.env');
|
||||||
|
const envFile = fs.readFileSync(envPath, 'utf8');
|
||||||
|
envFile.split('\n').forEach(line => {
|
||||||
|
const trimmedLine = line.trim();
|
||||||
|
if (trimmedLine && !trimmedLine.startsWith('#')) {
|
||||||
|
const [key, ...valueParts] = trimmedLine.split('=');
|
||||||
|
if (key && valueParts.length > 0 && !process.env[key]) {
|
||||||
|
process.env[key] = valueParts.join('=').trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.log('No .env file found or error reading it:', e.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Keep the default database in a stable user-level location so rebuilding dist-server
|
||||||
|
// never changes where the backend stores auth.db when DATABASE_PATH is not set explicitly.
|
||||||
|
const DEFAULT_DATABASE_PATH = path.join(os.homedir(), '.cloudcli', 'auth.db');
|
||||||
|
|
||||||
|
if (!process.env.DATABASE_PATH) {
|
||||||
|
process.env.DATABASE_PATH = DEFAULT_DATABASE_PATH;
|
||||||
|
}
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
import jwt from 'jsonwebtoken';
|
import jwt from 'jsonwebtoken';
|
||||||
import { userDb } from '../database/db.js';
|
import { userDb, appConfigDb } from '../modules/database/index.js';
|
||||||
|
import { IS_PLATFORM } from '../constants/config.js';
|
||||||
|
|
||||||
// Get JWT secret from environment or use default (for development)
|
// Use env var if set, otherwise auto-generate a unique secret per installation
|
||||||
const JWT_SECRET = process.env.JWT_SECRET || 'claude-ui-dev-secret-change-in-production';
|
const JWT_SECRET = process.env.JWT_SECRET || appConfigDb.getOrCreateJwtSecret();
|
||||||
|
|
||||||
// Optional API key middleware
|
// Optional API key middleware
|
||||||
const validateApiKey = (req, res, next) => {
|
const validateApiKey = (req, res, next) => {
|
||||||
@@ -20,8 +21,29 @@ const validateApiKey = (req, res, next) => {
|
|||||||
|
|
||||||
// JWT authentication middleware
|
// JWT authentication middleware
|
||||||
const authenticateToken = async (req, res, next) => {
|
const authenticateToken = async (req, res, next) => {
|
||||||
|
// Platform mode: use single database user
|
||||||
|
if (IS_PLATFORM) {
|
||||||
|
try {
|
||||||
|
const user = userDb.getFirstUser();
|
||||||
|
if (!user) {
|
||||||
|
return res.status(500).json({ error: 'Platform mode: No user found in database' });
|
||||||
|
}
|
||||||
|
req.user = user;
|
||||||
|
return next();
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Platform mode error:', error);
|
||||||
|
return res.status(500).json({ error: 'Platform mode: Failed to fetch user' });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Normal OSS JWT validation
|
||||||
const authHeader = req.headers['authorization'];
|
const authHeader = req.headers['authorization'];
|
||||||
const token = authHeader && authHeader.split(' ')[1]; // Bearer TOKEN
|
let token = authHeader && authHeader.split(' ')[1]; // Bearer TOKEN
|
||||||
|
|
||||||
|
// Also check query param for SSE endpoints (EventSource can't set headers)
|
||||||
|
if (!token && req.query.token) {
|
||||||
|
token = req.query.token;
|
||||||
|
}
|
||||||
|
|
||||||
if (!token) {
|
if (!token) {
|
||||||
return res.status(401).json({ error: 'Access denied. No token provided.' });
|
return res.status(401).json({ error: 'Access denied. No token provided.' });
|
||||||
@@ -29,13 +51,23 @@ const authenticateToken = async (req, res, next) => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const decoded = jwt.verify(token, JWT_SECRET);
|
const decoded = jwt.verify(token, JWT_SECRET);
|
||||||
|
|
||||||
// Verify user still exists and is active
|
// Verify user still exists and is active
|
||||||
const user = userDb.getUserById(decoded.userId);
|
const user = userDb.getUserById(decoded.userId);
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return res.status(401).json({ error: 'Invalid token. User not found.' });
|
return res.status(401).json({ error: 'Invalid token. User not found.' });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Auto-refresh: if token is past halfway through its lifetime, issue a new one
|
||||||
|
if (decoded.exp && decoded.iat) {
|
||||||
|
const now = Math.floor(Date.now() / 1000);
|
||||||
|
const halfLife = (decoded.exp - decoded.iat) / 2;
|
||||||
|
if (now > decoded.iat + halfLife) {
|
||||||
|
const newToken = generateToken(user);
|
||||||
|
res.setHeader('X-Refreshed-Token', newToken);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
req.user = user;
|
req.user = user;
|
||||||
next();
|
next();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -44,27 +76,47 @@ const authenticateToken = async (req, res, next) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Generate JWT token (never expires)
|
// Generate JWT token
|
||||||
const generateToken = (user) => {
|
const generateToken = (user) => {
|
||||||
return jwt.sign(
|
return jwt.sign(
|
||||||
{
|
{
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
username: user.username
|
username: user.username
|
||||||
},
|
},
|
||||||
JWT_SECRET
|
JWT_SECRET,
|
||||||
// No expiration - token lasts forever
|
{ expiresIn: '7d' }
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
// WebSocket authentication function
|
// WebSocket authentication function
|
||||||
const authenticateWebSocket = (token) => {
|
const authenticateWebSocket = (token) => {
|
||||||
|
// Platform mode: bypass token validation, return first user
|
||||||
|
if (IS_PLATFORM) {
|
||||||
|
try {
|
||||||
|
const user = userDb.getFirstUser();
|
||||||
|
if (user) {
|
||||||
|
return { id: user.id, userId: user.id, username: user.username };
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Platform mode WebSocket error:', error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Normal OSS JWT validation
|
||||||
if (!token) {
|
if (!token) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const decoded = jwt.verify(token, JWT_SECRET);
|
const decoded = jwt.verify(token, JWT_SECRET);
|
||||||
return decoded;
|
// Verify user actually exists in database (matches REST authenticateToken behavior)
|
||||||
|
const user = userDb.getUserById(decoded.userId);
|
||||||
|
if (!user) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return { userId: user.id, username: user.username };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('WebSocket token verification error:', error);
|
console.error('WebSocket token verification error:', error);
|
||||||
return null;
|
return null;
|
||||||
@@ -77,4 +129,4 @@ export {
|
|||||||
generateToken,
|
generateToken,
|
||||||
authenticateWebSocket,
|
authenticateWebSocket,
|
||||||
JWT_SECRET
|
JWT_SECRET
|
||||||
};
|
};
|
||||||
|
|||||||
143
server/modules/database/connection.ts
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
/**
|
||||||
|
* Database connection management.
|
||||||
|
*
|
||||||
|
* Owns the single SQLite connection used across all repositories.
|
||||||
|
* Handles path resolution, directory creation, legacy database migration,
|
||||||
|
* and eager app_config bootstrap so the auth middleware can read the
|
||||||
|
* JWT secret before the full schema is applied.
|
||||||
|
*
|
||||||
|
* Consumers should never create their own Database instance — they use
|
||||||
|
* `getConnection()` to obtain the shared singleton.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import Database from 'better-sqlite3';
|
||||||
|
import fs from 'fs';
|
||||||
|
import path from 'path';
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
|
|
||||||
|
import { APP_CONFIG_TABLE_SCHEMA_SQL } from '@/modules/database/schema.js';
|
||||||
|
|
||||||
|
const __filename = fileURLToPath(import.meta.url);
|
||||||
|
const __dirname = path.dirname(__filename);
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Path resolution
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolves the database file path from environment or falls back
|
||||||
|
* to the legacy location inside the server/database/ folder.
|
||||||
|
*
|
||||||
|
* Priority:
|
||||||
|
* 1. DATABASE_PATH environment variable (set by cli.js or load-env-vars.js)
|
||||||
|
* 2. Legacy path: server/database/auth.db
|
||||||
|
*/
|
||||||
|
function resolveDatabasePath(): string {
|
||||||
|
// process.env.DATABASE_PATH is set by load-env-vars.js to either the .env value or a default(~/.cloudcli/auth.db) in the user's home directory.
|
||||||
|
return process.env.DATABASE_PATH || resolveLegacyDatabasePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolves the legacy database path (always inside server/database/).
|
||||||
|
* Used for the one-time migration to the new external location.
|
||||||
|
*/
|
||||||
|
function resolveLegacyDatabasePath(): string {
|
||||||
|
const serverDir = path.resolve(__dirname, '..', '..', '..');
|
||||||
|
return path.join(serverDir, 'database', 'auth.db');
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Directory & migration helpers
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
function ensureDatabaseDirectory(dbPath: string): void {
|
||||||
|
const dir = path.dirname(dbPath);
|
||||||
|
if (!fs.existsSync(dir)) {
|
||||||
|
fs.mkdirSync(dir, { recursive: true });
|
||||||
|
console.log('Created database directory:', dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the database was moved to an external location (e.g. ~/.cloudcli/)
|
||||||
|
* but the user still has a legacy auth.db inside the install directory,
|
||||||
|
* copy it to the new location as a one-time migration.
|
||||||
|
*/
|
||||||
|
function migrateLegacyDatabase(targetPath: string): void {
|
||||||
|
const legacyPath = resolveLegacyDatabasePath();
|
||||||
|
|
||||||
|
if (targetPath === legacyPath) return;
|
||||||
|
if (fs.existsSync(targetPath)) return;
|
||||||
|
if (!fs.existsSync(legacyPath)) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
fs.copyFileSync(legacyPath, targetPath);
|
||||||
|
console.log('Migrated legacy database', { from: legacyPath, to: targetPath });
|
||||||
|
|
||||||
|
|
||||||
|
// copy the write-ahead log and shared memory files (auth.db-wal, auth.db-shm) if they exist, to preserve any uncommitted transactions
|
||||||
|
for (const suffix of ['-wal', '-shm']) {
|
||||||
|
const src = legacyPath + suffix;
|
||||||
|
if (fs.existsSync(src)) {
|
||||||
|
fs.copyFileSync(src, targetPath + suffix);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (err: any) {
|
||||||
|
console.error('Could not migrate legacy database', { error: err.message });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Singleton connection
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
let instance: Database.Database | null = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the shared database connection, creating it on first call.
|
||||||
|
*
|
||||||
|
* The first invocation:
|
||||||
|
* 1. Resolves the target database path
|
||||||
|
* 2. Ensures the parent directory exists
|
||||||
|
* 3. Migrates from the legacy install-directory path if needed
|
||||||
|
* 4. Opens the SQLite connection
|
||||||
|
* 5. Eagerly creates the app_config table (auth reads JWT secret at import time)
|
||||||
|
* 6. Logs the database location
|
||||||
|
*/
|
||||||
|
export function getConnection(): Database.Database {
|
||||||
|
if (instance) return instance;
|
||||||
|
|
||||||
|
const dbPath = resolveDatabasePath();
|
||||||
|
|
||||||
|
ensureDatabaseDirectory(dbPath);
|
||||||
|
migrateLegacyDatabase(dbPath);
|
||||||
|
|
||||||
|
instance = new Database(dbPath);
|
||||||
|
|
||||||
|
// app_config must exist immediately — the auth middleware reads
|
||||||
|
// the JWT secret at module-load time, before initializeDatabase() runs.
|
||||||
|
instance.exec(APP_CONFIG_TABLE_SCHEMA_SQL);
|
||||||
|
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the resolved database file path without opening a connection.
|
||||||
|
* Useful for diagnostics and CLI status commands.
|
||||||
|
*/
|
||||||
|
export function getDatabasePath(): string {
|
||||||
|
return resolveDatabasePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes the database connection and clears the singleton.
|
||||||
|
* Primarily used for graceful shutdown or testing.
|
||||||
|
*/
|
||||||
|
export function closeConnection(): void {
|
||||||
|
if (instance) {
|
||||||
|
instance.close();
|
||||||
|
instance = null;
|
||||||
|
console.log('Database connection closed');
|
||||||
|
}
|
||||||
|
}
|
||||||
12
server/modules/database/index.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
export { initializeDatabase } from '@/modules/database/init-db.js';
|
||||||
|
export { apiKeysDb } from '@/modules/database/repositories/api-keys.js';
|
||||||
|
export { appConfigDb } from '@/modules/database/repositories/app-config.js';
|
||||||
|
export { credentialsDb } from '@/modules/database/repositories/credentials.js';
|
||||||
|
export { githubTokensDb } from '@/modules/database/repositories/github-tokens.js';
|
||||||
|
export { notificationPreferencesDb } from '@/modules/database/repositories/notification-preferences.js';
|
||||||
|
export { projectsDb } from '@/modules/database/repositories/projects.db.js';
|
||||||
|
export { pushSubscriptionsDb } from '@/modules/database/repositories/push-subscriptions.js';
|
||||||
|
export { scanStateDb } from '@/modules/database/repositories/scan-state.db.js';
|
||||||
|
export { sessionsDb } from '@/modules/database/repositories/sessions.db.js';
|
||||||
|
export { userDb } from '@/modules/database/repositories/users.js';
|
||||||
|
export { vapidKeysDb } from '@/modules/database/repositories/vapid-keys.js';
|
||||||
17
server/modules/database/init-db.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import { getConnection } from "@/modules/database/connection.js";
|
||||||
|
import { runMigrations } from "@/modules/database/migrations.js";
|
||||||
|
import { INIT_SCHEMA_SQL } from "@/modules/database/schema.js";
|
||||||
|
|
||||||
|
// Initialize database with schema
|
||||||
|
export const initializeDatabase = async () => {
|
||||||
|
try {
|
||||||
|
const db = getConnection();
|
||||||
|
db.exec(INIT_SCHEMA_SQL);
|
||||||
|
console.log('Database schema applied');
|
||||||
|
runMigrations(db);
|
||||||
|
} catch (err) {
|
||||||
|
const message = err instanceof Error ? err.message : String(err);
|
||||||
|
console.log('Database initialization failed', { error: message });
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
};
|
||||||
455
server/modules/database/migrations.ts
Normal file
@@ -0,0 +1,455 @@
|
|||||||
|
import { Database } from 'better-sqlite3';
|
||||||
|
|
||||||
|
import {
|
||||||
|
APP_CONFIG_TABLE_SCHEMA_SQL,
|
||||||
|
LAST_SCANNED_AT_SQL,
|
||||||
|
PROJECTS_TABLE_SCHEMA_SQL,
|
||||||
|
PUSH_SUBSCRIPTIONS_TABLE_SCHEMA_SQL,
|
||||||
|
SESSIONS_TABLE_SCHEMA_SQL,
|
||||||
|
USER_NOTIFICATION_PREFERENCES_TABLE_SCHEMA_SQL,
|
||||||
|
VAPID_KEYS_TABLE_SCHEMA_SQL,
|
||||||
|
} from '@/modules/database/schema.js';
|
||||||
|
|
||||||
|
const SQLITE_UUID_SQL = `
|
||||||
|
lower(hex(randomblob(4))) || '-' ||
|
||||||
|
lower(hex(randomblob(2))) || '-' ||
|
||||||
|
lower(hex(randomblob(2))) || '-' ||
|
||||||
|
lower(hex(randomblob(2))) || '-' ||
|
||||||
|
lower(hex(randomblob(6)))
|
||||||
|
`;
|
||||||
|
|
||||||
|
type TableInfoRow = {
|
||||||
|
name: string;
|
||||||
|
pk: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
const addColumnToTableIfNotExists = (
|
||||||
|
db: Database,
|
||||||
|
tableName: string,
|
||||||
|
columnNames: string[],
|
||||||
|
columnName: string,
|
||||||
|
columnType: string
|
||||||
|
) => {
|
||||||
|
if (!columnNames.includes(columnName)) {
|
||||||
|
console.log(`Running migration: Adding ${columnName} column to ${tableName} table`);
|
||||||
|
db.exec(`ALTER TABLE ${tableName} ADD COLUMN ${columnName} ${columnType}`);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const tableExists = (db: Database, tableName: string): boolean =>
|
||||||
|
Boolean(
|
||||||
|
db
|
||||||
|
.prepare("SELECT name FROM sqlite_master WHERE type = 'table' AND name = ?")
|
||||||
|
.get(tableName)
|
||||||
|
);
|
||||||
|
|
||||||
|
const getTableInfo = (db: Database, tableName: string): TableInfoRow[] =>
|
||||||
|
db.prepare(`PRAGMA table_info(${tableName})`).all() as TableInfoRow[];
|
||||||
|
|
||||||
|
const migrateLegacySessionNames = (db: Database): void => {
|
||||||
|
const hasLegacySessionNamesTable = tableExists(db, 'session_names');
|
||||||
|
const hasSessionsTable = tableExists(db, 'sessions');
|
||||||
|
|
||||||
|
if (!hasLegacySessionNamesTable) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasSessionsTable) {
|
||||||
|
console.log('Running migration: Merging session_names into sessions');
|
||||||
|
db.exec(`
|
||||||
|
INSERT INTO sessions (session_id, provider, custom_name, created_at, updated_at)
|
||||||
|
SELECT
|
||||||
|
session_id,
|
||||||
|
COALESCE(provider, 'claude'),
|
||||||
|
custom_name,
|
||||||
|
COALESCE(created_at, CURRENT_TIMESTAMP),
|
||||||
|
COALESCE(updated_at, CURRENT_TIMESTAMP)
|
||||||
|
FROM session_names
|
||||||
|
WHERE true
|
||||||
|
ON CONFLICT(session_id) DO UPDATE SET
|
||||||
|
provider = excluded.provider,
|
||||||
|
custom_name = COALESCE(excluded.custom_name, sessions.custom_name),
|
||||||
|
created_at = COALESCE(sessions.created_at, excluded.created_at),
|
||||||
|
updated_at = COALESCE(excluded.updated_at, sessions.updated_at)
|
||||||
|
`);
|
||||||
|
db.exec('DROP TABLE session_names');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('Running migration: Renaming session_names table to sessions');
|
||||||
|
db.exec('ALTER TABLE session_names RENAME TO sessions');
|
||||||
|
};
|
||||||
|
|
||||||
|
const migrateLegacyWorkspaceTableIntoProjects = (db: Database): void => {
|
||||||
|
db.exec(PROJECTS_TABLE_SCHEMA_SQL);
|
||||||
|
|
||||||
|
if (!tableExists(db, 'workspace_original_paths')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('Running migration: Migrating workspace_original_paths data into projects');
|
||||||
|
db.exec(`
|
||||||
|
INSERT INTO projects (project_id, project_path, custom_project_name, isStarred, isArchived)
|
||||||
|
SELECT
|
||||||
|
CASE
|
||||||
|
WHEN workspace_id IS NULL OR trim(workspace_id) = ''
|
||||||
|
THEN ${SQLITE_UUID_SQL}
|
||||||
|
ELSE workspace_id
|
||||||
|
END,
|
||||||
|
workspace_path,
|
||||||
|
custom_workspace_name,
|
||||||
|
COALESCE(isStarred, 0),
|
||||||
|
0
|
||||||
|
FROM workspace_original_paths
|
||||||
|
WHERE workspace_path IS NOT NULL AND trim(workspace_path) <> ''
|
||||||
|
ON CONFLICT(project_path) DO UPDATE SET
|
||||||
|
custom_project_name = COALESCE(projects.custom_project_name, excluded.custom_project_name),
|
||||||
|
isStarred = COALESCE(projects.isStarred, excluded.isStarred)
|
||||||
|
`);
|
||||||
|
};
|
||||||
|
|
||||||
|
const rebuildProjectsTableWithPrimaryKeySchema = (db: Database): void => {
|
||||||
|
const hasProjectsTable = tableExists(db, 'projects');
|
||||||
|
if (!hasProjectsTable) {
|
||||||
|
db.exec(PROJECTS_TABLE_SCHEMA_SQL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const projectsTableInfo = getTableInfo(db, 'projects');
|
||||||
|
const columnNames = projectsTableInfo.map((column) => column.name);
|
||||||
|
const hasProjectIdPrimaryKey = projectsTableInfo.some(
|
||||||
|
(column) => column.name === 'project_id' && column.pk === 1,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (hasProjectIdPrimaryKey) {
|
||||||
|
addColumnToTableIfNotExists(db, 'projects', columnNames, 'custom_project_name', 'TEXT DEFAULT NULL');
|
||||||
|
addColumnToTableIfNotExists(db, 'projects', columnNames, 'isStarred', 'BOOLEAN DEFAULT 0');
|
||||||
|
addColumnToTableIfNotExists(db, 'projects', columnNames, 'isArchived', 'BOOLEAN DEFAULT 0');
|
||||||
|
db.exec(`
|
||||||
|
UPDATE projects
|
||||||
|
SET project_id = ${SQLITE_UUID_SQL}
|
||||||
|
WHERE project_id IS NULL OR trim(project_id) = ''
|
||||||
|
`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('Running migration: Rebuilding projects table to enforce project_id primary key');
|
||||||
|
|
||||||
|
const projectPathExpression = columnNames.includes('project_path')
|
||||||
|
? 'project_path'
|
||||||
|
: columnNames.includes('workspace_path')
|
||||||
|
? 'workspace_path'
|
||||||
|
: 'NULL';
|
||||||
|
|
||||||
|
const customProjectNameExpression = columnNames.includes('custom_project_name')
|
||||||
|
? 'custom_project_name'
|
||||||
|
: columnNames.includes('custom_workspace_name')
|
||||||
|
? 'custom_workspace_name'
|
||||||
|
: 'NULL';
|
||||||
|
|
||||||
|
const isStarredExpression = columnNames.includes('isStarred') ? 'COALESCE(isStarred, 0)' : '0';
|
||||||
|
|
||||||
|
const isArchivedExpression = columnNames.includes('isArchived') ? 'COALESCE(isArchived, 0)' : '0';
|
||||||
|
|
||||||
|
const projectIdExpression = columnNames.includes('project_id')
|
||||||
|
? `CASE
|
||||||
|
WHEN project_id IS NULL OR trim(project_id) = ''
|
||||||
|
THEN ${SQLITE_UUID_SQL}
|
||||||
|
ELSE project_id
|
||||||
|
END`
|
||||||
|
: SQLITE_UUID_SQL;
|
||||||
|
|
||||||
|
db.exec('PRAGMA foreign_keys = OFF');
|
||||||
|
try {
|
||||||
|
db.exec('BEGIN TRANSACTION');
|
||||||
|
db.exec('DROP TABLE IF EXISTS projects__new');
|
||||||
|
db.exec(`
|
||||||
|
CREATE TABLE projects__new (
|
||||||
|
project_id TEXT PRIMARY KEY NOT NULL,
|
||||||
|
project_path TEXT NOT NULL UNIQUE,
|
||||||
|
custom_project_name TEXT DEFAULT NULL,
|
||||||
|
isStarred BOOLEAN DEFAULT 0,
|
||||||
|
isArchived BOOLEAN DEFAULT 0
|
||||||
|
)
|
||||||
|
`);
|
||||||
|
db.exec(`
|
||||||
|
WITH source_rows AS (
|
||||||
|
SELECT
|
||||||
|
${projectPathExpression} AS project_path,
|
||||||
|
${customProjectNameExpression} AS custom_project_name,
|
||||||
|
${isStarredExpression} AS isStarred,
|
||||||
|
${isArchivedExpression} AS isArchived,
|
||||||
|
${projectIdExpression} AS candidate_project_id,
|
||||||
|
rowid AS source_rowid
|
||||||
|
FROM projects
|
||||||
|
WHERE ${projectPathExpression} IS NOT NULL AND trim(${projectPathExpression}) <> ''
|
||||||
|
),
|
||||||
|
deduped_paths AS (
|
||||||
|
SELECT
|
||||||
|
project_path,
|
||||||
|
custom_project_name,
|
||||||
|
isStarred,
|
||||||
|
isArchived,
|
||||||
|
candidate_project_id,
|
||||||
|
source_rowid,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY project_path ORDER BY source_rowid) AS project_path_rank
|
||||||
|
FROM source_rows
|
||||||
|
),
|
||||||
|
prepared_rows AS (
|
||||||
|
SELECT
|
||||||
|
CASE
|
||||||
|
WHEN ROW_NUMBER() OVER (PARTITION BY candidate_project_id ORDER BY source_rowid) = 1
|
||||||
|
THEN candidate_project_id
|
||||||
|
ELSE ${SQLITE_UUID_SQL}
|
||||||
|
END AS project_id,
|
||||||
|
project_path,
|
||||||
|
custom_project_name,
|
||||||
|
isStarred,
|
||||||
|
isArchived
|
||||||
|
FROM deduped_paths
|
||||||
|
WHERE project_path_rank = 1
|
||||||
|
)
|
||||||
|
INSERT INTO projects__new (
|
||||||
|
project_id,
|
||||||
|
project_path,
|
||||||
|
custom_project_name,
|
||||||
|
isStarred,
|
||||||
|
isArchived
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
project_id,
|
||||||
|
project_path,
|
||||||
|
custom_project_name,
|
||||||
|
isStarred,
|
||||||
|
isArchived
|
||||||
|
FROM prepared_rows
|
||||||
|
`);
|
||||||
|
db.exec('DROP TABLE projects');
|
||||||
|
db.exec('ALTER TABLE projects__new RENAME TO projects');
|
||||||
|
db.exec('COMMIT');
|
||||||
|
} catch (migrationError) {
|
||||||
|
db.exec('ROLLBACK');
|
||||||
|
throw migrationError;
|
||||||
|
} finally {
|
||||||
|
db.exec('PRAGMA foreign_keys = ON');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const rebuildSessionsTableWithProjectSchema = (db: Database): void => {
|
||||||
|
const hasSessions = tableExists(db, 'sessions');
|
||||||
|
if (!hasSessions) {
|
||||||
|
db.exec(SESSIONS_TABLE_SCHEMA_SQL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const sessionsTableInfo = getTableInfo(db, 'sessions');
|
||||||
|
const columnNames = sessionsTableInfo.map((column) => column.name);
|
||||||
|
const primaryKeyColumns = sessionsTableInfo
|
||||||
|
.filter((column) => column.pk > 0)
|
||||||
|
.sort((a, b) => a.pk - b.pk)
|
||||||
|
.map((column) => column.name);
|
||||||
|
|
||||||
|
const shouldRebuild =
|
||||||
|
!columnNames.includes('project_path') ||
|
||||||
|
primaryKeyColumns.length !== 1 ||
|
||||||
|
primaryKeyColumns[0] !== 'session_id' ||
|
||||||
|
!columnNames.includes('provider');
|
||||||
|
|
||||||
|
if (!shouldRebuild) {
|
||||||
|
addColumnToTableIfNotExists(db, 'sessions', columnNames, 'jsonl_path', 'TEXT');
|
||||||
|
addColumnToTableIfNotExists(db, 'sessions', columnNames, 'isArchived', 'BOOLEAN DEFAULT 0');
|
||||||
|
addColumnToTableIfNotExists(db, 'sessions', columnNames, 'created_at', 'DATETIME');
|
||||||
|
addColumnToTableIfNotExists(db, 'sessions', columnNames, 'updated_at', 'DATETIME');
|
||||||
|
db.exec('UPDATE sessions SET isArchived = COALESCE(isArchived, 0)');
|
||||||
|
db.exec('UPDATE sessions SET created_at = COALESCE(created_at, CURRENT_TIMESTAMP)');
|
||||||
|
db.exec('UPDATE sessions SET updated_at = COALESCE(updated_at, CURRENT_TIMESTAMP)');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('Running migration: Rebuilding sessions table to project-based schema');
|
||||||
|
|
||||||
|
const projectPathExpression = columnNames.includes('project_path')
|
||||||
|
? 'project_path'
|
||||||
|
: columnNames.includes('workspace_path')
|
||||||
|
? 'workspace_path'
|
||||||
|
: 'NULL';
|
||||||
|
|
||||||
|
const providerExpression = columnNames.includes('provider')
|
||||||
|
? "COALESCE(provider, 'claude')"
|
||||||
|
: "'claude'";
|
||||||
|
|
||||||
|
const customNameExpression = columnNames.includes('custom_name')
|
||||||
|
? 'custom_name'
|
||||||
|
: 'NULL';
|
||||||
|
|
||||||
|
const jsonlPathExpression = columnNames.includes('jsonl_path')
|
||||||
|
? 'jsonl_path'
|
||||||
|
: 'NULL';
|
||||||
|
|
||||||
|
const isArchivedExpression = columnNames.includes('isArchived')
|
||||||
|
? 'COALESCE(isArchived, 0)'
|
||||||
|
: '0';
|
||||||
|
|
||||||
|
const createdAtExpression = columnNames.includes('created_at')
|
||||||
|
? 'COALESCE(created_at, CURRENT_TIMESTAMP)'
|
||||||
|
: 'CURRENT_TIMESTAMP';
|
||||||
|
|
||||||
|
const updatedAtExpression = columnNames.includes('updated_at')
|
||||||
|
? 'COALESCE(updated_at, CURRENT_TIMESTAMP)'
|
||||||
|
: 'CURRENT_TIMESTAMP';
|
||||||
|
|
||||||
|
db.exec('PRAGMA foreign_keys = OFF');
|
||||||
|
try {
|
||||||
|
db.exec('BEGIN TRANSACTION');
|
||||||
|
db.exec('DROP TABLE IF EXISTS sessions__new');
|
||||||
|
db.exec(`
|
||||||
|
CREATE TABLE sessions__new (
|
||||||
|
session_id TEXT NOT NULL,
|
||||||
|
provider TEXT NOT NULL DEFAULT 'claude',
|
||||||
|
custom_name TEXT,
|
||||||
|
project_path TEXT,
|
||||||
|
jsonl_path TEXT,
|
||||||
|
isArchived BOOLEAN DEFAULT 0,
|
||||||
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
PRIMARY KEY (session_id),
|
||||||
|
FOREIGN KEY (project_path) REFERENCES projects(project_path)
|
||||||
|
ON DELETE SET NULL
|
||||||
|
ON UPDATE CASCADE
|
||||||
|
)
|
||||||
|
`);
|
||||||
|
db.exec(`
|
||||||
|
WITH source_rows AS (
|
||||||
|
SELECT
|
||||||
|
session_id,
|
||||||
|
${providerExpression} AS provider,
|
||||||
|
${customNameExpression} AS custom_name,
|
||||||
|
${projectPathExpression} AS project_path,
|
||||||
|
${jsonlPathExpression} AS jsonl_path,
|
||||||
|
${isArchivedExpression} AS isArchived,
|
||||||
|
${createdAtExpression} AS created_at,
|
||||||
|
${updatedAtExpression} AS updated_at,
|
||||||
|
rowid AS source_rowid
|
||||||
|
FROM sessions
|
||||||
|
WHERE session_id IS NOT NULL AND trim(session_id) <> ''
|
||||||
|
),
|
||||||
|
ranked_rows AS (
|
||||||
|
SELECT
|
||||||
|
session_id,
|
||||||
|
provider,
|
||||||
|
custom_name,
|
||||||
|
project_path,
|
||||||
|
jsonl_path,
|
||||||
|
isArchived,
|
||||||
|
created_at,
|
||||||
|
updated_at,
|
||||||
|
ROW_NUMBER() OVER (
|
||||||
|
PARTITION BY session_id
|
||||||
|
ORDER BY datetime(COALESCE(updated_at, created_at)) DESC, source_rowid DESC
|
||||||
|
) AS session_rank
|
||||||
|
FROM source_rows
|
||||||
|
)
|
||||||
|
INSERT INTO sessions__new (
|
||||||
|
session_id,
|
||||||
|
provider,
|
||||||
|
custom_name,
|
||||||
|
project_path,
|
||||||
|
jsonl_path,
|
||||||
|
isArchived,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
session_id,
|
||||||
|
provider,
|
||||||
|
custom_name,
|
||||||
|
project_path,
|
||||||
|
jsonl_path,
|
||||||
|
isArchived,
|
||||||
|
created_at,
|
||||||
|
updated_at
|
||||||
|
FROM ranked_rows
|
||||||
|
WHERE session_rank = 1
|
||||||
|
`);
|
||||||
|
db.exec('DROP TABLE sessions');
|
||||||
|
db.exec('ALTER TABLE sessions__new RENAME TO sessions');
|
||||||
|
db.exec('COMMIT');
|
||||||
|
} catch (migrationError) {
|
||||||
|
db.exec('ROLLBACK');
|
||||||
|
throw migrationError;
|
||||||
|
} finally {
|
||||||
|
db.exec('PRAGMA foreign_keys = ON');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const ensureProjectsForSessionPaths = (db: Database): void => {
|
||||||
|
if (!tableExists(db, 'sessions')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
db.exec(`
|
||||||
|
INSERT INTO projects (project_id, project_path, custom_project_name, isStarred, isArchived)
|
||||||
|
SELECT
|
||||||
|
${SQLITE_UUID_SQL},
|
||||||
|
project_path,
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
FROM sessions
|
||||||
|
WHERE project_path IS NOT NULL AND trim(project_path) <> ''
|
||||||
|
ON CONFLICT(project_path) DO NOTHING
|
||||||
|
`);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const runMigrations = (db: Database) => {
|
||||||
|
try {
|
||||||
|
const usersTableInfo = db.prepare('PRAGMA table_info(users)').all() as { name: string }[];
|
||||||
|
const userColumnNames = usersTableInfo.map((column) => column.name);
|
||||||
|
|
||||||
|
addColumnToTableIfNotExists(db, 'users', userColumnNames, 'git_name', 'TEXT');
|
||||||
|
addColumnToTableIfNotExists(db, 'users', userColumnNames, 'git_email', 'TEXT');
|
||||||
|
addColumnToTableIfNotExists(
|
||||||
|
db,
|
||||||
|
'users',
|
||||||
|
userColumnNames,
|
||||||
|
'has_completed_onboarding',
|
||||||
|
'BOOLEAN DEFAULT 0'
|
||||||
|
);
|
||||||
|
|
||||||
|
db.exec(APP_CONFIG_TABLE_SCHEMA_SQL);
|
||||||
|
db.exec(USER_NOTIFICATION_PREFERENCES_TABLE_SCHEMA_SQL);
|
||||||
|
db.exec(VAPID_KEYS_TABLE_SCHEMA_SQL);
|
||||||
|
db.exec(PUSH_SUBSCRIPTIONS_TABLE_SCHEMA_SQL);
|
||||||
|
db.exec('CREATE INDEX IF NOT EXISTS idx_push_subscriptions_user_id ON push_subscriptions(user_id)');
|
||||||
|
|
||||||
|
db.exec(PROJECTS_TABLE_SCHEMA_SQL);
|
||||||
|
rebuildProjectsTableWithPrimaryKeySchema(db);
|
||||||
|
|
||||||
|
migrateLegacyWorkspaceTableIntoProjects(db);
|
||||||
|
rebuildSessionsTableWithProjectSchema(db);
|
||||||
|
migrateLegacySessionNames(db);
|
||||||
|
ensureProjectsForSessionPaths(db);
|
||||||
|
|
||||||
|
db.exec('CREATE INDEX IF NOT EXISTS idx_session_ids_lookup ON sessions(session_id)');
|
||||||
|
db.exec('CREATE INDEX IF NOT EXISTS idx_sessions_project_path ON sessions(project_path)');
|
||||||
|
db.exec('CREATE INDEX IF NOT EXISTS idx_sessions_is_archived ON sessions(isArchived)');
|
||||||
|
db.exec('CREATE INDEX IF NOT EXISTS idx_projects_is_starred ON projects(isStarred)');
|
||||||
|
db.exec('CREATE INDEX IF NOT EXISTS idx_projects_is_archived ON projects(isArchived)');
|
||||||
|
|
||||||
|
db.exec('DROP INDEX IF EXISTS idx_session_names_lookup');
|
||||||
|
db.exec('DROP INDEX IF EXISTS idx_sessions_workspace_path');
|
||||||
|
db.exec('DROP INDEX IF EXISTS idx_workspace_original_paths_is_starred');
|
||||||
|
db.exec('DROP INDEX IF EXISTS idx_workspace_original_paths_workspace_id');
|
||||||
|
|
||||||
|
if (tableExists(db, 'workspace_original_paths')) {
|
||||||
|
console.log('Running migration: Dropping legacy workspace_original_paths table');
|
||||||
|
db.exec('DROP TABLE workspace_original_paths');
|
||||||
|
}
|
||||||
|
|
||||||
|
db.exec(LAST_SCANNED_AT_SQL);
|
||||||
|
console.log('Database migrations completed successfully');
|
||||||
|
} catch (error: any) {
|
||||||
|
console.error('Error running migrations:', error.message);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
};
|
||||||
119
server/modules/database/repositories/api-keys.ts
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
/**
|
||||||
|
* API keys repository.
|
||||||
|
*
|
||||||
|
* Manages API keys used for external/programmatic access to the backend.
|
||||||
|
* Keys are prefixed with `ck_` and tied to a user via foreign key.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import crypto from 'crypto';
|
||||||
|
|
||||||
|
import { getConnection } from '@/modules/database/connection.js';
|
||||||
|
|
||||||
|
type ApiKeyRow = {
|
||||||
|
id: number;
|
||||||
|
key_name: string;
|
||||||
|
api_key: string;
|
||||||
|
created_at: string;
|
||||||
|
last_used: string | null;
|
||||||
|
is_active: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
type CreateApiKeyResult = {
|
||||||
|
id: number | bigint;
|
||||||
|
keyName: string;
|
||||||
|
apiKey: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type ValidatedApiKeyUser = {
|
||||||
|
id: number;
|
||||||
|
username: string;
|
||||||
|
api_key_id: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Helpers
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/** Generates a cryptographically random API key with the `ck_` prefix. */
|
||||||
|
function generateApiKey(): string {
|
||||||
|
return 'ck_' + crypto.randomBytes(32).toString('hex');
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Queries
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
export const apiKeysDb = {
|
||||||
|
generateApiKey,
|
||||||
|
|
||||||
|
/** Creates a new API key for the given user and returns it for one-time display. */
|
||||||
|
createApiKey(userId: number, keyName: string): CreateApiKeyResult {
|
||||||
|
const db = getConnection();
|
||||||
|
const apiKey = generateApiKey();
|
||||||
|
const result = db
|
||||||
|
.prepare(
|
||||||
|
'INSERT INTO api_keys (user_id, key_name, api_key) VALUES (?, ?, ?)'
|
||||||
|
)
|
||||||
|
.run(userId, keyName, apiKey);
|
||||||
|
return { id: result.lastInsertRowid, keyName, apiKey };
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Lists all API keys for a user, most recent first. */
|
||||||
|
getApiKeys(userId: number): ApiKeyRow[] {
|
||||||
|
const db = getConnection();
|
||||||
|
return db
|
||||||
|
.prepare(
|
||||||
|
'SELECT id, key_name, api_key, created_at, last_used, is_active FROM api_keys WHERE user_id = ? ORDER BY created_at DESC'
|
||||||
|
)
|
||||||
|
.all(userId) as ApiKeyRow[];
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates an API key and resolves the owning user.
|
||||||
|
* If the key is valid, its `last_used` timestamp is updated as a side effect.
|
||||||
|
* Returns undefined when the key is invalid or the user is inactive.
|
||||||
|
*/
|
||||||
|
validateApiKey(apiKey: string): ValidatedApiKeyUser | undefined {
|
||||||
|
const db = getConnection();
|
||||||
|
const row = db
|
||||||
|
.prepare(
|
||||||
|
`SELECT u.id, u.username, ak.id as api_key_id
|
||||||
|
FROM api_keys ak
|
||||||
|
JOIN users u ON ak.user_id = u.id
|
||||||
|
WHERE ak.api_key = ? AND ak.is_active = 1 AND u.is_active = 1`
|
||||||
|
)
|
||||||
|
.get(apiKey) as ValidatedApiKeyUser | undefined;
|
||||||
|
|
||||||
|
if (row) {
|
||||||
|
db.prepare(
|
||||||
|
'UPDATE api_keys SET last_used = CURRENT_TIMESTAMP WHERE id = ?'
|
||||||
|
).run(row.api_key_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return row;
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Permanently removes an API key. Returns true if a row was deleted. */
|
||||||
|
deleteApiKey(userId: number, apiKeyId: number): boolean {
|
||||||
|
const db = getConnection();
|
||||||
|
const result = db
|
||||||
|
.prepare('DELETE FROM api_keys WHERE id = ? AND user_id = ?')
|
||||||
|
.run(apiKeyId, userId);
|
||||||
|
return result.changes > 0;
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Enables or disables an API key without deleting it. */
|
||||||
|
toggleApiKey(
|
||||||
|
userId: number,
|
||||||
|
apiKeyId: number,
|
||||||
|
isActive: boolean
|
||||||
|
): boolean {
|
||||||
|
const db = getConnection();
|
||||||
|
const result = db
|
||||||
|
.prepare(
|
||||||
|
'UPDATE api_keys SET is_active = ? WHERE id = ? AND user_id = ?'
|
||||||
|
)
|
||||||
|
.run(isActive ? 1 : 0, apiKeyId, userId);
|
||||||
|
return result.changes > 0;
|
||||||
|
},
|
||||||
|
};
|
||||||
53
server/modules/database/repositories/app-config.ts
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
/**
|
||||||
|
* App config repository.
|
||||||
|
*
|
||||||
|
* Key-value store for application-level configuration that persists
|
||||||
|
* across restarts (JWT secret, feature flags, etc.). Values are always
|
||||||
|
* stored as strings; callers handle parsing.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import crypto from 'crypto';
|
||||||
|
|
||||||
|
import { getConnection } from '@/modules/database/connection.js';
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Queries
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
export const appConfigDb = {
|
||||||
|
/** Returns the stored value for a config key, or null if missing. */
|
||||||
|
get(key: string): string | null {
|
||||||
|
try {
|
||||||
|
const db = getConnection();
|
||||||
|
const row = db
|
||||||
|
.prepare('SELECT value FROM app_config WHERE key = ?')
|
||||||
|
.get(key) as { value: string } | undefined;
|
||||||
|
return row?.value ?? null;
|
||||||
|
} catch {
|
||||||
|
// Swallow errors so early-startup reads (e.g. JWT secret) do not crash.
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Inserts or updates a config key (upsert). */
|
||||||
|
set(key: string, value: string): void {
|
||||||
|
const db = getConnection();
|
||||||
|
db.prepare(
|
||||||
|
'INSERT INTO app_config (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value'
|
||||||
|
).run(key, value);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the JWT signing secret, generating and persisting one
|
||||||
|
* if it does not already exist. This ensures the secret survives
|
||||||
|
* server restarts while being created automatically on first boot.
|
||||||
|
*/
|
||||||
|
getOrCreateJwtSecret(): string {
|
||||||
|
let secret = appConfigDb.get('jwt_secret');
|
||||||
|
if (!secret) {
|
||||||
|
secret = crypto.randomBytes(64).toString('hex');
|
||||||
|
appConfigDb.set('jwt_secret', secret);
|
||||||
|
}
|
||||||
|
return secret;
|
||||||
|
},
|
||||||
|
};
|
||||||
106
server/modules/database/repositories/credentials.ts
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
/**
|
||||||
|
* User credentials repository.
|
||||||
|
*
|
||||||
|
* Manages external service tokens (GitHub, GitLab, Bitbucket, etc.)
|
||||||
|
* stored per-user. Each credential has a type discriminator so multiple
|
||||||
|
* credential kinds can coexist in the same table.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { getConnection } from '@/modules/database/connection.js';
|
||||||
|
import type {
|
||||||
|
CreateCredentialResult,
|
||||||
|
CredentialPublicRow,
|
||||||
|
} from '@/shared/types.js';
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Queries
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
export const credentialsDb = {
|
||||||
|
/** Stores a new credential and returns a safe (no raw value) result. */
|
||||||
|
createCredential(
|
||||||
|
userId: number,
|
||||||
|
credentialName: string,
|
||||||
|
credentialType: string,
|
||||||
|
credentialValue: string,
|
||||||
|
description: string | null = null
|
||||||
|
): CreateCredentialResult {
|
||||||
|
const db = getConnection();
|
||||||
|
const result = db
|
||||||
|
.prepare(
|
||||||
|
'INSERT INTO user_credentials (user_id, credential_name, credential_type, credential_value, description) VALUES (?, ?, ?, ?, ?)'
|
||||||
|
)
|
||||||
|
.run(userId, credentialName, credentialType, credentialValue, description);
|
||||||
|
return {
|
||||||
|
id: result.lastInsertRowid,
|
||||||
|
credentialName,
|
||||||
|
credentialType,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Lists credentials for a user (excluding raw values).
|
||||||
|
* Optionally filters by credential type (e.g. 'github_token').
|
||||||
|
*/
|
||||||
|
getCredentials(
|
||||||
|
userId: number,
|
||||||
|
credentialType: string | null = null
|
||||||
|
): CredentialPublicRow[] {
|
||||||
|
const db = getConnection();
|
||||||
|
|
||||||
|
if (credentialType) {
|
||||||
|
return db
|
||||||
|
.prepare(
|
||||||
|
'SELECT id, credential_name, credential_type, description, created_at, is_active FROM user_credentials WHERE user_id = ? AND credential_type = ? ORDER BY created_at DESC'
|
||||||
|
)
|
||||||
|
.all(userId, credentialType) as CredentialPublicRow[];
|
||||||
|
}
|
||||||
|
|
||||||
|
return db
|
||||||
|
.prepare(
|
||||||
|
'SELECT id, credential_name, credential_type, description, created_at, is_active FROM user_credentials WHERE user_id = ? ORDER BY created_at DESC'
|
||||||
|
)
|
||||||
|
.all(userId) as CredentialPublicRow[];
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the raw credential value for the most recent active
|
||||||
|
* credential of the given type, or null if none exists.
|
||||||
|
*/
|
||||||
|
getActiveCredential(
|
||||||
|
userId: number,
|
||||||
|
credentialType: string
|
||||||
|
): string | null {
|
||||||
|
const db = getConnection();
|
||||||
|
const row = db
|
||||||
|
.prepare(
|
||||||
|
'SELECT credential_value FROM user_credentials WHERE user_id = ? AND credential_type = ? AND is_active = 1 ORDER BY created_at DESC LIMIT 1'
|
||||||
|
)
|
||||||
|
.get(userId, credentialType) as { credential_value: string } | undefined;
|
||||||
|
return row?.credential_value ?? null;
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Permanently removes a credential. Returns true if a row was deleted. */
|
||||||
|
deleteCredential(userId: number, credentialId: number): boolean {
|
||||||
|
const db = getConnection();
|
||||||
|
const result = db
|
||||||
|
.prepare('DELETE FROM user_credentials WHERE id = ? AND user_id = ?')
|
||||||
|
.run(credentialId, userId);
|
||||||
|
return result.changes > 0;
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Enables or disables a credential without deleting it. */
|
||||||
|
toggleCredential(
|
||||||
|
userId: number,
|
||||||
|
credentialId: number,
|
||||||
|
isActive: boolean
|
||||||
|
): boolean {
|
||||||
|
const db = getConnection();
|
||||||
|
const result = db
|
||||||
|
.prepare(
|
||||||
|
'UPDATE user_credentials SET is_active = ? WHERE id = ? AND user_id = ?'
|
||||||
|
)
|
||||||
|
.run(isActive ? 1 : 0, credentialId, userId);
|
||||||
|
return result.changes > 0;
|
||||||
|
},
|
||||||
|
};
|
||||||
100
server/modules/database/repositories/github-tokens.ts
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
/**
|
||||||
|
* GitHub tokens repository.
|
||||||
|
*
|
||||||
|
* Backward-compatible helper layer over generic credentials storage.
|
||||||
|
* Tokens are stored in `user_credentials` with `credential_type = 'github_token'`.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { getConnection } from '@/modules/database/connection.js';
|
||||||
|
import { credentialsDb } from '@/modules/database/repositories/credentials.js';
|
||||||
|
import type {
|
||||||
|
CredentialPublicRow,
|
||||||
|
CreateCredentialResult,
|
||||||
|
} from '@/shared/types.js';
|
||||||
|
|
||||||
|
const GITHUB_TOKEN_TYPE = 'github_token';
|
||||||
|
|
||||||
|
type CredentialRow = {
|
||||||
|
id: number;
|
||||||
|
user_id: number;
|
||||||
|
credential_name: string;
|
||||||
|
credential_type: string;
|
||||||
|
credential_value: string;
|
||||||
|
description: string | null;
|
||||||
|
created_at: string;
|
||||||
|
is_active: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
type GithubTokenLookup = CredentialRow & {
|
||||||
|
github_token: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const githubTokensDb = {
|
||||||
|
/** Creates a GitHub token credential entry. */
|
||||||
|
createGithubToken(
|
||||||
|
userId: number,
|
||||||
|
tokenName: string,
|
||||||
|
githubToken: string,
|
||||||
|
description: string | null = null
|
||||||
|
): CreateCredentialResult {
|
||||||
|
return credentialsDb.createCredential(
|
||||||
|
userId,
|
||||||
|
tokenName,
|
||||||
|
GITHUB_TOKEN_TYPE,
|
||||||
|
githubToken,
|
||||||
|
description
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Returns all GitHub tokens (safe shape: no credential value). */
|
||||||
|
getGithubTokens(userId: number): CredentialPublicRow[] {
|
||||||
|
return credentialsDb.getCredentials(userId, GITHUB_TOKEN_TYPE);
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Returns the most recent active GitHub token value for a user. */
|
||||||
|
getActiveGithubToken(userId: number): string | null {
|
||||||
|
return credentialsDb.getActiveCredential(userId, GITHUB_TOKEN_TYPE);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a specific active GitHub token row by id/user, including
|
||||||
|
* a `github_token` compatibility field.
|
||||||
|
*/
|
||||||
|
getGithubTokenById(userId: number, tokenId: number): GithubTokenLookup | null {
|
||||||
|
const db = getConnection();
|
||||||
|
const row = db
|
||||||
|
.prepare(
|
||||||
|
`SELECT *
|
||||||
|
FROM user_credentials
|
||||||
|
WHERE id = ? AND user_id = ? AND credential_type = ? AND is_active = 1`
|
||||||
|
)
|
||||||
|
.get(tokenId, userId, GITHUB_TOKEN_TYPE) as CredentialRow | undefined;
|
||||||
|
|
||||||
|
if (!row) return null;
|
||||||
|
|
||||||
|
return {
|
||||||
|
...row,
|
||||||
|
github_token: row.credential_value,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Updates active state for a GitHub token. */
|
||||||
|
updateGithubToken(
|
||||||
|
userId: number,
|
||||||
|
tokenId: number,
|
||||||
|
isActive: boolean
|
||||||
|
): boolean {
|
||||||
|
return credentialsDb.toggleCredential(userId, tokenId, isActive);
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Deletes a GitHub token. */
|
||||||
|
deleteGithubToken(userId: number, tokenId: number): boolean {
|
||||||
|
return credentialsDb.deleteCredential(userId, tokenId);
|
||||||
|
},
|
||||||
|
|
||||||
|
// Legacy alias used by existing routes
|
||||||
|
toggleGithubToken(userId: number, tokenId: number, isActive: boolean): boolean {
|
||||||
|
return githubTokensDb.updateGithubToken(userId, tokenId, isActive);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
103
server/modules/database/repositories/notification-preferences.ts
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
/**
|
||||||
|
* Notification preferences repository.
|
||||||
|
*
|
||||||
|
* Stores per-user notification channel/event preferences as JSON.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { getConnection } from '@/modules/database/connection.js';
|
||||||
|
|
||||||
|
type NotificationPreferences = {
|
||||||
|
channels: {
|
||||||
|
inApp: boolean;
|
||||||
|
webPush: boolean;
|
||||||
|
};
|
||||||
|
events: {
|
||||||
|
actionRequired: boolean;
|
||||||
|
stop: boolean;
|
||||||
|
error: boolean;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const DEFAULT_NOTIFICATION_PREFERENCES: NotificationPreferences = {
|
||||||
|
channels: {
|
||||||
|
inApp: false,
|
||||||
|
webPush: false,
|
||||||
|
},
|
||||||
|
events: {
|
||||||
|
actionRequired: true,
|
||||||
|
stop: true,
|
||||||
|
error: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
function normalizeNotificationPreferences(value: unknown): NotificationPreferences {
|
||||||
|
const source = value && typeof value === 'object' ? (value as Record<string, any>) : {};
|
||||||
|
|
||||||
|
return {
|
||||||
|
channels: {
|
||||||
|
inApp: source.channels?.inApp === true,
|
||||||
|
webPush: source.channels?.webPush === true,
|
||||||
|
},
|
||||||
|
events: {
|
||||||
|
actionRequired: source.events?.actionRequired !== false,
|
||||||
|
stop: source.events?.stop !== false,
|
||||||
|
error: source.events?.error !== false,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export const notificationPreferencesDb = {
|
||||||
|
/** Returns the normalized preferences for a user, creating defaults on first read. */
|
||||||
|
getNotificationPreferences(userId: number): NotificationPreferences {
|
||||||
|
const db = getConnection();
|
||||||
|
const row = db
|
||||||
|
.prepare(
|
||||||
|
'SELECT preferences_json FROM user_notification_preferences WHERE user_id = ?'
|
||||||
|
)
|
||||||
|
.get(userId) as { preferences_json: string } | undefined;
|
||||||
|
|
||||||
|
if (!row) {
|
||||||
|
const defaults = normalizeNotificationPreferences(DEFAULT_NOTIFICATION_PREFERENCES);
|
||||||
|
db.prepare(
|
||||||
|
'INSERT INTO user_notification_preferences (user_id, preferences_json, updated_at) VALUES (?, ?, CURRENT_TIMESTAMP)'
|
||||||
|
).run(userId, JSON.stringify(defaults));
|
||||||
|
return defaults;
|
||||||
|
}
|
||||||
|
|
||||||
|
let parsed: unknown;
|
||||||
|
try {
|
||||||
|
parsed = JSON.parse(row.preferences_json);
|
||||||
|
} catch {
|
||||||
|
parsed = DEFAULT_NOTIFICATION_PREFERENCES;
|
||||||
|
}
|
||||||
|
return normalizeNotificationPreferences(parsed);
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Upserts normalized preferences for a user and returns the stored value. */
|
||||||
|
updateNotificationPreferences(
|
||||||
|
userId: number,
|
||||||
|
preferences: unknown
|
||||||
|
): NotificationPreferences {
|
||||||
|
const normalized = normalizeNotificationPreferences(preferences);
|
||||||
|
const db = getConnection();
|
||||||
|
|
||||||
|
db.prepare(
|
||||||
|
`INSERT INTO user_notification_preferences (user_id, preferences_json, updated_at)
|
||||||
|
VALUES (?, ?, CURRENT_TIMESTAMP)
|
||||||
|
ON CONFLICT(user_id) DO UPDATE SET
|
||||||
|
preferences_json = excluded.preferences_json,
|
||||||
|
updated_at = CURRENT_TIMESTAMP`
|
||||||
|
).run(userId, JSON.stringify(normalized));
|
||||||
|
|
||||||
|
return normalized;
|
||||||
|
},
|
||||||
|
|
||||||
|
// Legacy aliases used by existing services/routes
|
||||||
|
getPreferences(userId: number): NotificationPreferences {
|
||||||
|
return notificationPreferencesDb.getNotificationPreferences(userId);
|
||||||
|
},
|
||||||
|
updatePreferences(userId: number, preferences: unknown): NotificationPreferences {
|
||||||
|
return notificationPreferencesDb.updateNotificationPreferences(userId, preferences);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { mkdtemp, rm } from 'node:fs/promises';
|
||||||
|
import { tmpdir } from 'node:os';
|
||||||
|
import path from 'node:path';
|
||||||
|
import test from 'node:test';
|
||||||
|
|
||||||
|
import { closeConnection } from '@/modules/database/connection.js';
|
||||||
|
import { initializeDatabase } from '@/modules/database/init-db.js';
|
||||||
|
import { projectsDb } from '@/modules/database/repositories/projects.db.js';
|
||||||
|
|
||||||
|
async function withIsolatedDatabase(runTest: () => void | Promise<void>): Promise<void> {
|
||||||
|
const previousDatabasePath = process.env.DATABASE_PATH;
|
||||||
|
const tempDirectory = await mkdtemp(path.join(tmpdir(), 'projects-db-'));
|
||||||
|
const databasePath = path.join(tempDirectory, 'auth.db');
|
||||||
|
|
||||||
|
closeConnection();
|
||||||
|
process.env.DATABASE_PATH = databasePath;
|
||||||
|
await initializeDatabase();
|
||||||
|
|
||||||
|
try {
|
||||||
|
await runTest();
|
||||||
|
} finally {
|
||||||
|
closeConnection();
|
||||||
|
if (previousDatabasePath === undefined) {
|
||||||
|
delete process.env.DATABASE_PATH;
|
||||||
|
} else {
|
||||||
|
process.env.DATABASE_PATH = previousDatabasePath;
|
||||||
|
}
|
||||||
|
await rm(tempDirectory, { recursive: true, force: true });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
test('projectsDb.createProjectPath returns created for fresh paths', async () => {
|
||||||
|
await withIsolatedDatabase(() => {
|
||||||
|
const created = projectsDb.createProjectPath('/workspace/new-project');
|
||||||
|
|
||||||
|
assert.equal(created.outcome, 'created');
|
||||||
|
assert.ok(created.project);
|
||||||
|
assert.equal(created.project?.project_path, '/workspace/new-project');
|
||||||
|
assert.equal(created.project?.isArchived, 0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('projectsDb.createProjectPath returns reactivated_archived for archived duplicates', async () => {
|
||||||
|
await withIsolatedDatabase(() => {
|
||||||
|
const initial = projectsDb.createProjectPath('/workspace/archived-project', 'Archived Project');
|
||||||
|
assert.equal(initial.outcome, 'created');
|
||||||
|
assert.ok(initial.project);
|
||||||
|
|
||||||
|
projectsDb.updateProjectIsArchived('/workspace/archived-project', true);
|
||||||
|
|
||||||
|
const reused = projectsDb.createProjectPath('/workspace/archived-project', 'Renamed Project');
|
||||||
|
assert.equal(reused.outcome, 'reactivated_archived');
|
||||||
|
assert.ok(reused.project);
|
||||||
|
assert.equal(reused.project?.project_id, initial.project?.project_id);
|
||||||
|
assert.equal(reused.project?.isArchived, 0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('projectsDb.createProjectPath returns active_conflict for active duplicates', async () => {
|
||||||
|
await withIsolatedDatabase(() => {
|
||||||
|
const initial = projectsDb.createProjectPath('/workspace/active-project');
|
||||||
|
assert.equal(initial.outcome, 'created');
|
||||||
|
assert.ok(initial.project);
|
||||||
|
|
||||||
|
const conflict = projectsDb.createProjectPath('/workspace/active-project');
|
||||||
|
assert.equal(conflict.outcome, 'active_conflict');
|
||||||
|
assert.ok(conflict.project);
|
||||||
|
assert.equal(conflict.project?.project_id, initial.project?.project_id);
|
||||||
|
assert.equal(conflict.project?.isArchived, 0);
|
||||||
|
});
|
||||||
|
});
|
||||||
196
server/modules/database/repositories/projects.db.ts
Normal file
@@ -0,0 +1,196 @@
|
|||||||
|
import { randomUUID } from 'node:crypto';
|
||||||
|
import path from 'node:path';
|
||||||
|
|
||||||
|
import { getConnection } from '@/modules/database/connection.js';
|
||||||
|
import type { CreateProjectPathResult, ProjectRepositoryRow } from '@/shared/types.js';
|
||||||
|
import { normalizeProjectPath } from '@/shared/utils.js';
|
||||||
|
|
||||||
|
function normalizeProjectDisplayName(projectPath: string, customProjectName: string | null): string {
|
||||||
|
const trimmedCustomName = typeof customProjectName === 'string' ? customProjectName.trim() : '';
|
||||||
|
if (trimmedCustomName.length > 0) {
|
||||||
|
return trimmedCustomName;
|
||||||
|
}
|
||||||
|
|
||||||
|
const directoryName = path.basename(projectPath);
|
||||||
|
return directoryName || projectPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const projectsDb = {
|
||||||
|
createProjectPath(projectPath: string, customProjectName: string | null = null): CreateProjectPathResult {
|
||||||
|
const db = getConnection();
|
||||||
|
const normalizedProjectPath = normalizeProjectPath(projectPath);
|
||||||
|
const normalizedProjectName = normalizeProjectDisplayName(normalizedProjectPath, customProjectName);
|
||||||
|
const attemptedId = randomUUID();
|
||||||
|
const row = db.prepare(`
|
||||||
|
INSERT INTO projects (project_id, project_path, custom_project_name, isArchived)
|
||||||
|
VALUES (?, ?, ?, 0)
|
||||||
|
ON CONFLICT(project_path) DO UPDATE SET
|
||||||
|
isArchived = 0
|
||||||
|
WHERE projects.isArchived = 1
|
||||||
|
RETURNING project_id, project_path, custom_project_name, isStarred, isArchived
|
||||||
|
`).get(attemptedId, normalizedProjectPath, normalizedProjectName) as ProjectRepositoryRow | undefined;
|
||||||
|
|
||||||
|
if (row) {
|
||||||
|
return {
|
||||||
|
outcome: row.project_id === attemptedId ? 'created' : 'reactivated_archived',
|
||||||
|
project: row,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const existingProject = projectsDb.getProjectPath(normalizedProjectPath);
|
||||||
|
return {
|
||||||
|
outcome: 'active_conflict',
|
||||||
|
project: existingProject,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
getProjectPath(projectPath: string): ProjectRepositoryRow | null {
|
||||||
|
const db = getConnection();
|
||||||
|
const normalizedProjectPath = normalizeProjectPath(projectPath);
|
||||||
|
const row = db.prepare(`
|
||||||
|
SELECT project_id, project_path, custom_project_name, isStarred, isArchived
|
||||||
|
FROM projects
|
||||||
|
WHERE project_path = ?
|
||||||
|
`).get(normalizedProjectPath) as ProjectRepositoryRow | undefined;
|
||||||
|
|
||||||
|
return row ?? null;
|
||||||
|
},
|
||||||
|
|
||||||
|
getProjectById(projectId: string): ProjectRepositoryRow | null {
|
||||||
|
const db = getConnection();
|
||||||
|
const row = db.prepare(`
|
||||||
|
SELECT project_id, project_path, custom_project_name, isStarred, isArchived
|
||||||
|
FROM projects
|
||||||
|
WHERE project_id = ?
|
||||||
|
`).get(projectId) as ProjectRepositoryRow | undefined;
|
||||||
|
|
||||||
|
return row ?? null;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve the absolute project directory from a database project_id.
|
||||||
|
*
|
||||||
|
* This is the canonical lookup used after the projectName → projectId migration:
|
||||||
|
* API routes receive the DB-assigned `projectId` and must resolve the real folder
|
||||||
|
* path through this helper before touching the filesystem. Returns `null` when the
|
||||||
|
* project row does not exist so callers can respond with a 404.
|
||||||
|
*/
|
||||||
|
getProjectPathById(projectId: string): string | null {
|
||||||
|
const db = getConnection();
|
||||||
|
const row = db.prepare(`
|
||||||
|
SELECT project_path
|
||||||
|
FROM projects
|
||||||
|
WHERE project_id = ?
|
||||||
|
`).get(projectId) as Pick<ProjectRepositoryRow, 'project_path'> | undefined;
|
||||||
|
|
||||||
|
return row?.project_path ?? null;
|
||||||
|
},
|
||||||
|
|
||||||
|
getProjectPaths(): ProjectRepositoryRow[] {
|
||||||
|
const db = getConnection();
|
||||||
|
return db.prepare(`
|
||||||
|
SELECT project_id, project_path, custom_project_name, isStarred, isArchived
|
||||||
|
FROM projects
|
||||||
|
WHERE isArchived = 0
|
||||||
|
`).all() as ProjectRepositoryRow[];
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Archived rows are queried separately so archive-focused UIs can present
|
||||||
|
* hidden workspaces without reintroducing them into the active sidebar list.
|
||||||
|
*/
|
||||||
|
getArchivedProjectPaths(): ProjectRepositoryRow[] {
|
||||||
|
const db = getConnection();
|
||||||
|
return db.prepare(`
|
||||||
|
SELECT project_id, project_path, custom_project_name, isStarred, isArchived
|
||||||
|
FROM projects
|
||||||
|
WHERE isArchived = 1
|
||||||
|
`).all() as ProjectRepositoryRow[];
|
||||||
|
},
|
||||||
|
|
||||||
|
getCustomProjectName(projectPath: string): string | null {
|
||||||
|
const db = getConnection();
|
||||||
|
const normalizedProjectPath = normalizeProjectPath(projectPath);
|
||||||
|
const row = db.prepare(`
|
||||||
|
SELECT custom_project_name
|
||||||
|
FROM projects
|
||||||
|
WHERE project_path = ?
|
||||||
|
`).get(normalizedProjectPath) as Pick<ProjectRepositoryRow, 'custom_project_name'> | undefined;
|
||||||
|
|
||||||
|
return row?.custom_project_name ?? null;
|
||||||
|
},
|
||||||
|
|
||||||
|
updateCustomProjectName(projectPath: string, customProjectName: string | null): void {
|
||||||
|
const db = getConnection();
|
||||||
|
const normalizedProjectPath = normalizeProjectPath(projectPath);
|
||||||
|
db.prepare(`
|
||||||
|
INSERT INTO projects (project_id, project_path, custom_project_name)
|
||||||
|
VALUES (?, ?, ?)
|
||||||
|
ON CONFLICT(project_path) DO UPDATE SET custom_project_name = excluded.custom_project_name
|
||||||
|
`).run(randomUUID(), normalizedProjectPath, customProjectName);
|
||||||
|
},
|
||||||
|
|
||||||
|
updateCustomProjectNameById(projectId: string, customProjectName: string | null): void {
|
||||||
|
const db = getConnection();
|
||||||
|
db.prepare(`
|
||||||
|
UPDATE projects
|
||||||
|
SET custom_project_name = ?
|
||||||
|
WHERE project_id = ?
|
||||||
|
`).run(customProjectName, projectId);
|
||||||
|
},
|
||||||
|
|
||||||
|
updateProjectIsStarred(projectPath: string, isStarred: boolean): void {
|
||||||
|
const db = getConnection();
|
||||||
|
const normalizedProjectPath = normalizeProjectPath(projectPath);
|
||||||
|
db.prepare(`
|
||||||
|
UPDATE projects
|
||||||
|
SET isStarred = ?
|
||||||
|
WHERE project_path = ?
|
||||||
|
`).run(isStarred ? 1 : 0, normalizedProjectPath);
|
||||||
|
},
|
||||||
|
|
||||||
|
updateProjectIsStarredById(projectId: string, isStarred: boolean): void {
|
||||||
|
const db = getConnection();
|
||||||
|
db.prepare(`
|
||||||
|
UPDATE projects
|
||||||
|
SET isStarred = ?
|
||||||
|
WHERE project_id = ?
|
||||||
|
`).run(isStarred ? 1 : 0, projectId);
|
||||||
|
},
|
||||||
|
|
||||||
|
updateProjectIsArchived(projectPath: string, isArchived: boolean): void {
|
||||||
|
const db = getConnection();
|
||||||
|
const normalizedProjectPath = normalizeProjectPath(projectPath);
|
||||||
|
db.prepare(`
|
||||||
|
UPDATE projects
|
||||||
|
SET isArchived = ?
|
||||||
|
WHERE project_path = ?
|
||||||
|
`).run(isArchived ? 1 : 0, normalizedProjectPath);
|
||||||
|
},
|
||||||
|
|
||||||
|
updateProjectIsArchivedById(projectId: string, isArchived: boolean): void {
|
||||||
|
const db = getConnection();
|
||||||
|
db.prepare(`
|
||||||
|
UPDATE projects
|
||||||
|
SET isArchived = ?
|
||||||
|
WHERE project_id = ?
|
||||||
|
`).run(isArchived ? 1 : 0, projectId);
|
||||||
|
},
|
||||||
|
|
||||||
|
deleteProjectPath(projectPath: string): void {
|
||||||
|
const db = getConnection();
|
||||||
|
const normalizedProjectPath = normalizeProjectPath(projectPath);
|
||||||
|
db.prepare(`
|
||||||
|
DELETE FROM projects
|
||||||
|
WHERE project_path = ?
|
||||||
|
`).run(normalizedProjectPath);
|
||||||
|
},
|
||||||
|
|
||||||
|
deleteProjectById(projectId: string): void {
|
||||||
|
const db = getConnection();
|
||||||
|
db.prepare(`
|
||||||
|
DELETE FROM projects
|
||||||
|
WHERE project_id = ?
|
||||||
|
`).run(projectId);
|
||||||
|
},
|
||||||
|
};
|
||||||
80
server/modules/database/repositories/push-subscriptions.ts
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
/**
|
||||||
|
* Push subscriptions repository.
|
||||||
|
*
|
||||||
|
* Persists browser push subscription endpoints and keys per user.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { getConnection } from '@/modules/database/connection.js';
|
||||||
|
|
||||||
|
type PushSubscriptionLookupRow = {
|
||||||
|
endpoint: string;
|
||||||
|
keys_p256dh: string;
|
||||||
|
keys_auth: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const pushSubscriptionsDb = {
|
||||||
|
/** Upserts a push subscription endpoint for a user. */
|
||||||
|
createPushSubscription(
|
||||||
|
userId: number,
|
||||||
|
endpoint: string,
|
||||||
|
keysP256dh: string,
|
||||||
|
keysAuth: string
|
||||||
|
): void {
|
||||||
|
const db = getConnection();
|
||||||
|
db.prepare(
|
||||||
|
`INSERT INTO push_subscriptions (user_id, endpoint, keys_p256dh, keys_auth)
|
||||||
|
VALUES (?, ?, ?, ?)
|
||||||
|
ON CONFLICT(endpoint) DO UPDATE SET
|
||||||
|
user_id = excluded.user_id,
|
||||||
|
keys_p256dh = excluded.keys_p256dh,
|
||||||
|
keys_auth = excluded.keys_auth`
|
||||||
|
).run(userId, endpoint, keysP256dh, keysAuth);
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Returns all subscriptions for a user. */
|
||||||
|
getPushSubscriptions(userId: number): PushSubscriptionLookupRow[] {
|
||||||
|
const db = getConnection();
|
||||||
|
return db
|
||||||
|
.prepare(
|
||||||
|
'SELECT endpoint, keys_p256dh, keys_auth FROM push_subscriptions WHERE user_id = ?'
|
||||||
|
)
|
||||||
|
.all(userId) as PushSubscriptionLookupRow[];
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Deletes one subscription by endpoint. */
|
||||||
|
deletePushSubscription(endpoint: string): void {
|
||||||
|
const db = getConnection();
|
||||||
|
db.prepare('DELETE FROM push_subscriptions WHERE endpoint = ?').run(endpoint);
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Deletes all subscriptions for a user. */
|
||||||
|
deletePushSubscriptionsForUser(userId: number): void {
|
||||||
|
const db = getConnection();
|
||||||
|
db.prepare('DELETE FROM push_subscriptions WHERE user_id = ?').run(userId);
|
||||||
|
},
|
||||||
|
|
||||||
|
// Legacy aliases used by existing services/routes
|
||||||
|
saveSubscription(
|
||||||
|
userId: number,
|
||||||
|
endpoint: string,
|
||||||
|
keysP256dh: string,
|
||||||
|
keysAuth: string
|
||||||
|
): void {
|
||||||
|
pushSubscriptionsDb.createPushSubscription(
|
||||||
|
userId,
|
||||||
|
endpoint,
|
||||||
|
keysP256dh,
|
||||||
|
keysAuth
|
||||||
|
);
|
||||||
|
},
|
||||||
|
getSubscriptions(userId: number): PushSubscriptionLookupRow[] {
|
||||||
|
return pushSubscriptionsDb.getPushSubscriptions(userId);
|
||||||
|
},
|
||||||
|
removeSubscription(endpoint: string): void {
|
||||||
|
pushSubscriptionsDb.deletePushSubscription(endpoint);
|
||||||
|
},
|
||||||
|
removeAllForUser(userId: number): void {
|
||||||
|
pushSubscriptionsDb.deletePushSubscriptionsForUser(userId);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
42
server/modules/database/repositories/scan-state.db.ts
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import { getConnection } from '@/modules/database/connection.js';
|
||||||
|
|
||||||
|
type ScanStateRow = {
|
||||||
|
last_scanned_at: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const scanStateDb = {
|
||||||
|
getLastScannedAt() {
|
||||||
|
const db = getConnection();
|
||||||
|
|
||||||
|
const row = db
|
||||||
|
.prepare(`SELECT last_scanned_at FROM scan_state WHERE id = 1`)
|
||||||
|
.get() as ScanStateRow;
|
||||||
|
|
||||||
|
if (!row) {
|
||||||
|
return null; // Before any scan, the row is undefined.
|
||||||
|
}
|
||||||
|
|
||||||
|
let lastScannedDate: Date | null = null;
|
||||||
|
const lastScannedStr = row.last_scanned_at;
|
||||||
|
|
||||||
|
if (lastScannedStr) {
|
||||||
|
// SQLite CURRENT_TIMESTAMP returns UTC in "YYYY-MM-DD HH:MM:SS" format.
|
||||||
|
// Replace space with 'T' and append 'Z' to parse reliably in JS across all platforms.
|
||||||
|
lastScannedDate = new Date(lastScannedStr.replace(' ', 'T') + 'Z');
|
||||||
|
}
|
||||||
|
|
||||||
|
return lastScannedDate;
|
||||||
|
},
|
||||||
|
|
||||||
|
updateLastScannedAt(scannedAt: Date = new Date()) {
|
||||||
|
const db = getConnection();
|
||||||
|
const sqliteTimestamp = scannedAt.toISOString().slice(0, 19).replace('T', ' ');
|
||||||
|
|
||||||
|
db.prepare(`
|
||||||
|
INSERT INTO scan_state (id, last_scanned_at)
|
||||||
|
VALUES (1, ?)
|
||||||
|
ON CONFLICT (id)
|
||||||
|
DO UPDATE SET last_scanned_at = excluded.last_scanned_at
|
||||||
|
`).run(sqliteTimestamp);
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { mkdtemp, rm } from 'node:fs/promises';
|
||||||
|
import { tmpdir } from 'node:os';
|
||||||
|
import path from 'node:path';
|
||||||
|
import test from 'node:test';
|
||||||
|
|
||||||
|
import { closeConnection } from '@/modules/database/connection.js';
|
||||||
|
import { initializeDatabase } from '@/modules/database/init-db.js';
|
||||||
|
import { sessionsDb } from '@/modules/database/repositories/sessions.db.js';
|
||||||
|
|
||||||
|
async function withIsolatedDatabase(runTest: () => void | Promise<void>): Promise<void> {
|
||||||
|
const previousDatabasePath = process.env.DATABASE_PATH;
|
||||||
|
const tempDirectory = await mkdtemp(path.join(tmpdir(), 'sessions-db-'));
|
||||||
|
const databasePath = path.join(tempDirectory, 'auth.db');
|
||||||
|
|
||||||
|
closeConnection();
|
||||||
|
process.env.DATABASE_PATH = databasePath;
|
||||||
|
await initializeDatabase();
|
||||||
|
|
||||||
|
try {
|
||||||
|
await runTest();
|
||||||
|
} finally {
|
||||||
|
closeConnection();
|
||||||
|
if (previousDatabasePath === undefined) {
|
||||||
|
delete process.env.DATABASE_PATH;
|
||||||
|
} else {
|
||||||
|
process.env.DATABASE_PATH = previousDatabasePath;
|
||||||
|
}
|
||||||
|
await rm(tempDirectory, { recursive: true, force: true });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
test('session archive queries hide archived rows from active project views', async () => {
|
||||||
|
await withIsolatedDatabase(() => {
|
||||||
|
sessionsDb.createSession('session-active', 'claude', '/workspace/demo-project', 'Active Session');
|
||||||
|
sessionsDb.createSession('session-archived', 'claude', '/workspace/demo-project', 'Archived Session');
|
||||||
|
sessionsDb.updateSessionIsArchived('session-archived', true);
|
||||||
|
|
||||||
|
const activeSessions = sessionsDb.getAllSessions();
|
||||||
|
const archivedSessions = sessionsDb.getArchivedSessions();
|
||||||
|
const activeProjectSessions = sessionsDb.getSessionsByProjectPath('/workspace/demo-project');
|
||||||
|
const allProjectSessions = sessionsDb.getSessionsByProjectPathIncludingArchived('/workspace/demo-project');
|
||||||
|
|
||||||
|
assert.deepEqual(activeSessions.map((session) => session.session_id), ['session-active']);
|
||||||
|
assert.deepEqual(archivedSessions.map((session) => session.session_id), ['session-archived']);
|
||||||
|
assert.deepEqual(activeProjectSessions.map((session) => session.session_id), ['session-active']);
|
||||||
|
assert.deepEqual(
|
||||||
|
allProjectSessions.map((session) => session.session_id).sort(),
|
||||||
|
['session-active', 'session-archived'],
|
||||||
|
);
|
||||||
|
assert.equal(sessionsDb.countSessionsByProjectPath('/workspace/demo-project'), 1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('createSession reactivates archived rows when the session becomes active again', async () => {
|
||||||
|
await withIsolatedDatabase(() => {
|
||||||
|
sessionsDb.createSession('session-reused', 'claude', '/workspace/demo-project', 'First Name');
|
||||||
|
sessionsDb.updateSessionIsArchived('session-reused', true);
|
||||||
|
|
||||||
|
sessionsDb.createSession('session-reused', 'claude', '/workspace/demo-project', 'Updated Name');
|
||||||
|
|
||||||
|
const activeSessions = sessionsDb.getAllSessions();
|
||||||
|
const archivedSessions = sessionsDb.getArchivedSessions();
|
||||||
|
const restoredSession = sessionsDb.getSessionById('session-reused');
|
||||||
|
|
||||||
|
assert.equal(activeSessions.length, 1);
|
||||||
|
assert.equal(activeSessions[0]?.session_id, 'session-reused');
|
||||||
|
assert.equal(activeSessions[0]?.custom_name, 'Updated Name');
|
||||||
|
assert.equal(archivedSessions.length, 0);
|
||||||
|
assert.equal(restoredSession?.isArchived, 0);
|
||||||
|
});
|
||||||
|
});
|
||||||
225
server/modules/database/repositories/sessions.db.ts
Normal file
@@ -0,0 +1,225 @@
|
|||||||
|
import { getConnection } from '@/modules/database/connection.js';
|
||||||
|
import { projectsDb } from '@/modules/database/repositories/projects.db.js';
|
||||||
|
import { normalizeProjectPath } from '@/shared/utils.js';
|
||||||
|
|
||||||
|
type SessionRow = {
|
||||||
|
session_id: string;
|
||||||
|
provider: string;
|
||||||
|
project_path: string | null;
|
||||||
|
jsonl_path: string | null;
|
||||||
|
custom_name: string | null;
|
||||||
|
isArchived: number;
|
||||||
|
created_at: string;
|
||||||
|
updated_at: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type SessionMetadataLookupRow = Pick<
|
||||||
|
SessionRow,
|
||||||
|
'session_id' | 'provider' | 'project_path' | 'jsonl_path' | 'custom_name' | 'isArchived' | 'created_at' | 'updated_at'
|
||||||
|
>;
|
||||||
|
|
||||||
|
function normalizeTimestamp(value?: string): string | null {
|
||||||
|
if (!value) return null;
|
||||||
|
|
||||||
|
const parsed = new Date(value);
|
||||||
|
if (Number.isNaN(parsed.getTime())) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return parsed.toISOString();
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizeProjectPathForProvider(provider: string, projectPath: string): string {
|
||||||
|
void provider;
|
||||||
|
return normalizeProjectPath(projectPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
export const sessionsDb = {
|
||||||
|
createSession(
|
||||||
|
sessionId: string,
|
||||||
|
provider: string,
|
||||||
|
projectPath: string,
|
||||||
|
customName?: string,
|
||||||
|
createdAt?: string,
|
||||||
|
updatedAt?: string,
|
||||||
|
jsonlPath?: string | null
|
||||||
|
): string {
|
||||||
|
const db = getConnection();
|
||||||
|
const createdAtValue = normalizeTimestamp(createdAt);
|
||||||
|
const updatedAtValue = normalizeTimestamp(updatedAt);
|
||||||
|
const normalizedProjectPath = normalizeProjectPathForProvider(provider, projectPath);
|
||||||
|
|
||||||
|
// First, ensure the project path is recorded in the projects table,
|
||||||
|
// since it's a foreign key in the sessions table.
|
||||||
|
projectsDb.createProjectPath(normalizedProjectPath);
|
||||||
|
|
||||||
|
db.prepare(
|
||||||
|
`INSERT INTO sessions (session_id, provider, custom_name, project_path, jsonl_path, isArchived, created_at, updated_at)
|
||||||
|
VALUES (?, ?, ?, ?, ?, 0, COALESCE(?, CURRENT_TIMESTAMP), COALESCE(?, CURRENT_TIMESTAMP))
|
||||||
|
ON CONFLICT(session_id) DO UPDATE SET
|
||||||
|
provider = excluded.provider,
|
||||||
|
updated_at = excluded.updated_at,
|
||||||
|
project_path = excluded.project_path,
|
||||||
|
jsonl_path = excluded.jsonl_path,
|
||||||
|
isArchived = 0,
|
||||||
|
custom_name = COALESCE(excluded.custom_name, sessions.custom_name)`
|
||||||
|
).run(
|
||||||
|
sessionId,
|
||||||
|
provider,
|
||||||
|
customName ?? null,
|
||||||
|
normalizedProjectPath,
|
||||||
|
jsonlPath ?? null,
|
||||||
|
createdAtValue,
|
||||||
|
updatedAtValue
|
||||||
|
);
|
||||||
|
|
||||||
|
return sessionId;
|
||||||
|
},
|
||||||
|
|
||||||
|
updateSessionCustomName(sessionId: string, customName: string): void {
|
||||||
|
const db = getConnection();
|
||||||
|
db.prepare(
|
||||||
|
`UPDATE sessions
|
||||||
|
SET custom_name = ?
|
||||||
|
WHERE session_id = ?`
|
||||||
|
).run(customName, sessionId);
|
||||||
|
},
|
||||||
|
|
||||||
|
getSessionById(sessionId: string): SessionMetadataLookupRow | null {
|
||||||
|
const db = getConnection();
|
||||||
|
const row = db
|
||||||
|
.prepare(
|
||||||
|
`SELECT session_id, provider, project_path, jsonl_path, custom_name, isArchived, created_at, updated_at
|
||||||
|
FROM sessions
|
||||||
|
WHERE session_id = ?
|
||||||
|
ORDER BY updated_at DESC
|
||||||
|
LIMIT 1`
|
||||||
|
)
|
||||||
|
.get(sessionId) as SessionMetadataLookupRow | undefined;
|
||||||
|
|
||||||
|
return row ?? null;
|
||||||
|
},
|
||||||
|
|
||||||
|
getAllSessions(): SessionRow[] {
|
||||||
|
const db = getConnection();
|
||||||
|
return db
|
||||||
|
.prepare(
|
||||||
|
`SELECT session_id, provider, project_path, jsonl_path, custom_name, isArchived, created_at, updated_at
|
||||||
|
FROM sessions
|
||||||
|
WHERE isArchived = 0`
|
||||||
|
)
|
||||||
|
.all() as SessionRow[];
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Archived rows are intentionally queried separately so the caller can render
|
||||||
|
* them in a dedicated view without reintroducing them into active session lists.
|
||||||
|
*/
|
||||||
|
getArchivedSessions(): SessionRow[] {
|
||||||
|
const db = getConnection();
|
||||||
|
return db
|
||||||
|
.prepare(
|
||||||
|
`SELECT session_id, provider, project_path, jsonl_path, custom_name, isArchived, created_at, updated_at
|
||||||
|
FROM sessions
|
||||||
|
WHERE isArchived = 1
|
||||||
|
ORDER BY datetime(COALESCE(updated_at, created_at)) DESC, session_id DESC`
|
||||||
|
)
|
||||||
|
.all() as SessionRow[];
|
||||||
|
},
|
||||||
|
|
||||||
|
getSessionsByProjectPath(projectPath: string): SessionRow[] {
|
||||||
|
const db = getConnection();
|
||||||
|
const normalizedProjectPath = normalizeProjectPath(projectPath);
|
||||||
|
return db
|
||||||
|
.prepare(
|
||||||
|
`SELECT session_id, provider, project_path, jsonl_path, custom_name, isArchived, created_at, updated_at
|
||||||
|
FROM sessions
|
||||||
|
WHERE project_path = ?
|
||||||
|
AND isArchived = 0`
|
||||||
|
)
|
||||||
|
.all(normalizedProjectPath) as SessionRow[];
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Permanent project deletion must see every session row for the path,
|
||||||
|
* including archived ones, so their transcript files can be cleaned up.
|
||||||
|
*/
|
||||||
|
getSessionsByProjectPathIncludingArchived(projectPath: string): SessionRow[] {
|
||||||
|
const db = getConnection();
|
||||||
|
const normalizedProjectPath = normalizeProjectPath(projectPath);
|
||||||
|
return db
|
||||||
|
.prepare(
|
||||||
|
`SELECT session_id, provider, project_path, jsonl_path, custom_name, isArchived, created_at, updated_at
|
||||||
|
FROM sessions
|
||||||
|
WHERE project_path = ?`
|
||||||
|
)
|
||||||
|
.all(normalizedProjectPath) as SessionRow[];
|
||||||
|
},
|
||||||
|
|
||||||
|
getSessionsByProjectPathPage(projectPath: string, limit: number, offset: number): SessionRow[] {
|
||||||
|
const db = getConnection();
|
||||||
|
const normalizedProjectPath = normalizeProjectPath(projectPath);
|
||||||
|
return db
|
||||||
|
.prepare(
|
||||||
|
`SELECT session_id, provider, project_path, jsonl_path, custom_name, isArchived, created_at, updated_at
|
||||||
|
FROM sessions
|
||||||
|
WHERE project_path = ?
|
||||||
|
AND isArchived = 0
|
||||||
|
ORDER BY datetime(COALESCE(updated_at, created_at)) DESC, session_id DESC
|
||||||
|
LIMIT ? OFFSET ?`
|
||||||
|
)
|
||||||
|
.all(normalizedProjectPath, limit, offset) as SessionRow[];
|
||||||
|
},
|
||||||
|
|
||||||
|
countSessionsByProjectPath(projectPath: string): number {
|
||||||
|
const db = getConnection();
|
||||||
|
const normalizedProjectPath = normalizeProjectPath(projectPath);
|
||||||
|
const row = db
|
||||||
|
.prepare(
|
||||||
|
`SELECT COUNT(*) AS count
|
||||||
|
FROM sessions
|
||||||
|
WHERE project_path = ?
|
||||||
|
AND isArchived = 0`
|
||||||
|
)
|
||||||
|
.get(normalizedProjectPath) as { count: number } | undefined;
|
||||||
|
|
||||||
|
return Number(row?.count ?? 0);
|
||||||
|
},
|
||||||
|
|
||||||
|
deleteSessionsByProjectPath(projectPath: string): void {
|
||||||
|
const db = getConnection();
|
||||||
|
const normalizedProjectPath = normalizeProjectPath(projectPath);
|
||||||
|
db.prepare(`DELETE FROM sessions WHERE project_path = ?`).run(normalizedProjectPath);
|
||||||
|
},
|
||||||
|
|
||||||
|
getSessionName(sessionId: string, provider: string): string | null {
|
||||||
|
const db = getConnection();
|
||||||
|
const row = db
|
||||||
|
.prepare(
|
||||||
|
`SELECT custom_name
|
||||||
|
FROM sessions
|
||||||
|
WHERE session_id = ? AND provider = ?`
|
||||||
|
)
|
||||||
|
.get(sessionId, provider) as { custom_name: string | null } | undefined;
|
||||||
|
|
||||||
|
return row?.custom_name ?? null;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Soft-delete and restore both use the same flag update so callers keep the
|
||||||
|
* row, metadata, and file path intact while toggling visibility.
|
||||||
|
*/
|
||||||
|
updateSessionIsArchived(sessionId: string, isArchived: boolean): void {
|
||||||
|
const db = getConnection();
|
||||||
|
db.prepare(
|
||||||
|
`UPDATE sessions
|
||||||
|
SET isArchived = ?
|
||||||
|
WHERE session_id = ?`
|
||||||
|
).run(isArchived ? 1 : 0, sessionId);
|
||||||
|
},
|
||||||
|
|
||||||
|
deleteSessionById(sessionId: string): boolean {
|
||||||
|
const db = getConnection();
|
||||||
|
return db.prepare('DELETE FROM sessions WHERE session_id = ?').run(sessionId).changes > 0;
|
||||||
|
},
|
||||||
|
};
|
||||||
140
server/modules/database/repositories/users.ts
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
/**
|
||||||
|
* User repository.
|
||||||
|
*
|
||||||
|
* Provides typed CRUD operations for the `users` table.
|
||||||
|
* This is a single-user system, but the schema supports multiple
|
||||||
|
* users for forward compatibility.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { getConnection } from '@/modules/database/connection.js';
|
||||||
|
|
||||||
|
type UserRow = {
|
||||||
|
id: number;
|
||||||
|
username: string;
|
||||||
|
password_hash: string;
|
||||||
|
created_at: string;
|
||||||
|
last_login: string | null;
|
||||||
|
is_active: number;
|
||||||
|
git_name: string | null;
|
||||||
|
git_email: string | null;
|
||||||
|
has_completed_onboarding: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
type UserPublicRow = Pick<UserRow, 'id' | 'username' | 'created_at' | 'last_login'>;
|
||||||
|
|
||||||
|
type UserGitConfig = {
|
||||||
|
git_name: string | null;
|
||||||
|
git_email: string | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
type CreateUserResult = {
|
||||||
|
id: number | bigint;
|
||||||
|
username: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Queries
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
export const userDb = {
|
||||||
|
/** Returns true if at least one user exists in the database. */
|
||||||
|
hasUsers(): boolean {
|
||||||
|
const db = getConnection();
|
||||||
|
const row = db.prepare('SELECT COUNT(*) as count FROM users').get() as {
|
||||||
|
count: number;
|
||||||
|
};
|
||||||
|
return row.count > 0;
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Inserts a new user and returns the created ID + username. */
|
||||||
|
createUser(username: string, passwordHash: string): CreateUserResult {
|
||||||
|
const db = getConnection();
|
||||||
|
const result = db
|
||||||
|
.prepare('INSERT INTO users (username, password_hash) VALUES (?, ?)')
|
||||||
|
.run(username, passwordHash);
|
||||||
|
return { id: result.lastInsertRowid, username };
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Looks up an active user by username.
|
||||||
|
* Returns the full row (including password hash) for auth verification.
|
||||||
|
*/
|
||||||
|
getUserByUsername(username: string): UserRow | undefined {
|
||||||
|
const db = getConnection();
|
||||||
|
return db
|
||||||
|
.prepare('SELECT * FROM users WHERE username = ? AND is_active = 1')
|
||||||
|
.get(username) as UserRow | undefined;
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Updates the last_login timestamp. Non-fatal — logs but does not throw. */
|
||||||
|
updateLastLogin(userId: number): void {
|
||||||
|
try {
|
||||||
|
const db = getConnection();
|
||||||
|
db.prepare(
|
||||||
|
'UPDATE users SET last_login = CURRENT_TIMESTAMP WHERE id = ?'
|
||||||
|
).run(userId);
|
||||||
|
} catch (err) {
|
||||||
|
const message = err instanceof Error ? err.message : String(err);
|
||||||
|
console.error('Failed to update last login', { error: message });
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Returns public user fields by ID (no password hash). */
|
||||||
|
getUserById(userId: number): UserPublicRow | undefined {
|
||||||
|
const db = getConnection();
|
||||||
|
return db
|
||||||
|
.prepare(
|
||||||
|
'SELECT id, username, created_at, last_login FROM users WHERE id = ? AND is_active = 1'
|
||||||
|
)
|
||||||
|
.get(userId) as UserPublicRow | undefined;
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Returns the first active user. Used for single-user mode lookups. */
|
||||||
|
getFirstUser(): UserPublicRow | undefined {
|
||||||
|
const db = getConnection();
|
||||||
|
return db
|
||||||
|
.prepare(
|
||||||
|
'SELECT id, username, created_at, last_login FROM users WHERE is_active = 1 LIMIT 1'
|
||||||
|
)
|
||||||
|
.get() as UserPublicRow | undefined;
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Stores the user's preferred git name and email. */
|
||||||
|
updateGitConfig(
|
||||||
|
userId: number,
|
||||||
|
gitName: string,
|
||||||
|
gitEmail: string
|
||||||
|
): void {
|
||||||
|
const db = getConnection();
|
||||||
|
db.prepare('UPDATE users SET git_name = ?, git_email = ? WHERE id = ?').run(
|
||||||
|
gitName,
|
||||||
|
gitEmail,
|
||||||
|
userId
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Retrieves the user's git identity (name + email). */
|
||||||
|
getGitConfig(userId: number): UserGitConfig | undefined {
|
||||||
|
const db = getConnection();
|
||||||
|
return db
|
||||||
|
.prepare('SELECT git_name, git_email FROM users WHERE id = ?')
|
||||||
|
.get(userId) as UserGitConfig | undefined;
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Marks onboarding as complete for the given user. */
|
||||||
|
completeOnboarding(userId: number): void {
|
||||||
|
const db = getConnection();
|
||||||
|
db.prepare(
|
||||||
|
'UPDATE users SET has_completed_onboarding = 1 WHERE id = ?'
|
||||||
|
).run(userId);
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Returns true if the user has finished the onboarding flow. */
|
||||||
|
hasCompletedOnboarding(userId: number): boolean {
|
||||||
|
const db = getConnection();
|
||||||
|
const row = db
|
||||||
|
.prepare('SELECT has_completed_onboarding FROM users WHERE id = ?')
|
||||||
|
.get(userId) as { has_completed_onboarding: number } | undefined;
|
||||||
|
return row?.has_completed_onboarding === 1;
|
||||||
|
},
|
||||||
|
};
|
||||||
57
server/modules/database/repositories/vapid-keys.ts
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
/**
|
||||||
|
* VAPID keys repository.
|
||||||
|
*
|
||||||
|
* Stores and retrieves the Web Push VAPID key pair.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { getConnection } from '@/modules/database/connection.js';
|
||||||
|
|
||||||
|
type VapidKeyRow = {
|
||||||
|
public_key: string;
|
||||||
|
private_key: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
type VapidKeyPair = {
|
||||||
|
publicKey: string;
|
||||||
|
privateKey: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const vapidKeysDb = {
|
||||||
|
/** Returns the latest stored VAPID key pair, or null when unset. */
|
||||||
|
getVapidKeys(): VapidKeyPair | null {
|
||||||
|
const db = getConnection();
|
||||||
|
const row = db
|
||||||
|
.prepare(
|
||||||
|
'SELECT public_key, private_key FROM vapid_keys ORDER BY id DESC LIMIT 1'
|
||||||
|
)
|
||||||
|
.get() as Pick<VapidKeyRow, 'public_key' | 'private_key'> | undefined;
|
||||||
|
|
||||||
|
if (!row) return null;
|
||||||
|
return {
|
||||||
|
publicKey: row.public_key,
|
||||||
|
privateKey: row.private_key,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Persists a new VAPID key pair. */
|
||||||
|
createVapidKeys(publicKey: string, privateKey: string): void {
|
||||||
|
const db = getConnection();
|
||||||
|
db.prepare(
|
||||||
|
'INSERT INTO vapid_keys (public_key, private_key) VALUES (?, ?)'
|
||||||
|
).run(publicKey, privateKey);
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Replaces all existing keys with a fresh pair. */
|
||||||
|
updateVapidKeys(publicKey: string, privateKey: string): void {
|
||||||
|
const db = getConnection();
|
||||||
|
db.prepare('DELETE FROM vapid_keys').run();
|
||||||
|
vapidKeysDb.createVapidKeys(publicKey, privateKey);
|
||||||
|
},
|
||||||
|
|
||||||
|
/** Deletes all VAPID key rows. */
|
||||||
|
deleteVapidKeys(): void {
|
||||||
|
const db = getConnection();
|
||||||
|
db.prepare('DELETE FROM vapid_keys').run();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
153
server/modules/database/schema.ts
Normal file
@@ -0,0 +1,153 @@
|
|||||||
|
const USER_TABLE_SCHEMA_SQL = `
|
||||||
|
CREATE TABLE IF NOT EXISTS users (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
username TEXT UNIQUE NOT NULL,
|
||||||
|
password_hash TEXT NOT NULL,
|
||||||
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
last_login DATETIME,
|
||||||
|
is_active BOOLEAN DEFAULT 1,
|
||||||
|
git_name TEXT,
|
||||||
|
git_email TEXT,
|
||||||
|
has_completed_onboarding BOOLEAN DEFAULT 0
|
||||||
|
);
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const API_KEYS_TABLE_SCHEMA_SQL = `
|
||||||
|
CREATE TABLE IF NOT EXISTS api_keys (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
user_id INTEGER NOT NULL,
|
||||||
|
key_name TEXT NOT NULL,
|
||||||
|
api_key TEXT UNIQUE NOT NULL,
|
||||||
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
last_used DATETIME,
|
||||||
|
is_active BOOLEAN DEFAULT 1,
|
||||||
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const USER_CREDENTIALS_TABLE_SCHEMA_SQL = `
|
||||||
|
CREATE TABLE IF NOT EXISTS user_credentials (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
user_id INTEGER NOT NULL,
|
||||||
|
credential_name TEXT NOT NULL,
|
||||||
|
credential_type TEXT NOT NULL, -- 'github_token', 'gitlab_token', 'bitbucket_token', etc.
|
||||||
|
credential_value TEXT NOT NULL,
|
||||||
|
description TEXT,
|
||||||
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
is_active BOOLEAN DEFAULT 1,
|
||||||
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const USER_NOTIFICATION_PREFERENCES_TABLE_SCHEMA_SQL = `
|
||||||
|
CREATE TABLE IF NOT EXISTS user_notification_preferences (
|
||||||
|
user_id INTEGER PRIMARY KEY,
|
||||||
|
preferences_json TEXT NOT NULL,
|
||||||
|
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const VAPID_KEYS_TABLE_SCHEMA_SQL = `
|
||||||
|
CREATE TABLE IF NOT EXISTS vapid_keys (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
public_key TEXT NOT NULL,
|
||||||
|
private_key TEXT NOT NULL,
|
||||||
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||||
|
);
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const PUSH_SUBSCRIPTIONS_TABLE_SCHEMA_SQL = `
|
||||||
|
CREATE TABLE IF NOT EXISTS push_subscriptions (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
user_id INTEGER NOT NULL,
|
||||||
|
endpoint TEXT NOT NULL UNIQUE,
|
||||||
|
keys_p256dh TEXT NOT NULL,
|
||||||
|
keys_auth TEXT NOT NULL,
|
||||||
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||||
|
);
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const PROJECTS_TABLE_SCHEMA_SQL = `
|
||||||
|
CREATE TABLE IF NOT EXISTS projects (
|
||||||
|
project_id TEXT PRIMARY KEY NOT NULL,
|
||||||
|
project_path TEXT NOT NULL UNIQUE,
|
||||||
|
custom_project_name TEXT DEFAULT NULL,
|
||||||
|
isStarred BOOLEAN DEFAULT 0,
|
||||||
|
isArchived BOOLEAN DEFAULT 0
|
||||||
|
);
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const SESSIONS_TABLE_SCHEMA_SQL = `
|
||||||
|
CREATE TABLE IF NOT EXISTS sessions (
|
||||||
|
session_id TEXT NOT NULL,
|
||||||
|
provider TEXT NOT NULL DEFAULT 'claude',
|
||||||
|
custom_name TEXT,
|
||||||
|
project_path TEXT,
|
||||||
|
jsonl_path TEXT,
|
||||||
|
isArchived BOOLEAN DEFAULT 0,
|
||||||
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
PRIMARY KEY (session_id),
|
||||||
|
FOREIGN KEY (project_path) REFERENCES projects(project_path)
|
||||||
|
ON DELETE SET NULL
|
||||||
|
ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const LAST_SCANNED_AT_SQL = `
|
||||||
|
CREATE TABLE IF NOT EXISTS scan_state (
|
||||||
|
id INTEGER PRIMARY KEY CHECK (id = 1),
|
||||||
|
last_scanned_at TIMESTAMP NULL
|
||||||
|
);
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const APP_CONFIG_TABLE_SCHEMA_SQL = `
|
||||||
|
CREATE TABLE IF NOT EXISTS app_config (
|
||||||
|
key TEXT PRIMARY KEY,
|
||||||
|
value TEXT NOT NULL,
|
||||||
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
||||||
|
);
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const INIT_SCHEMA_SQL = `
|
||||||
|
-- Initialize authentication database
|
||||||
|
PRAGMA foreign_keys = ON;
|
||||||
|
|
||||||
|
${USER_TABLE_SCHEMA_SQL}
|
||||||
|
-- Indexes for performance for user lookups
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_users_username ON users(username);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_users_active ON users(is_active);
|
||||||
|
|
||||||
|
${API_KEYS_TABLE_SCHEMA_SQL}
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_api_keys_key ON api_keys(api_key);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_api_keys_user_id ON api_keys(user_id);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_api_keys_active ON api_keys(is_active);
|
||||||
|
|
||||||
|
${USER_CREDENTIALS_TABLE_SCHEMA_SQL}
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_user_credentials_user_id ON user_credentials(user_id);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_user_credentials_type ON user_credentials(credential_type);
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_user_credentials_active ON user_credentials(is_active);
|
||||||
|
|
||||||
|
${USER_NOTIFICATION_PREFERENCES_TABLE_SCHEMA_SQL}
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_user_notification_preferences_user_id ON user_notification_preferences(user_id);
|
||||||
|
|
||||||
|
${VAPID_KEYS_TABLE_SCHEMA_SQL}
|
||||||
|
|
||||||
|
${PUSH_SUBSCRIPTIONS_TABLE_SCHEMA_SQL}
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_push_subscriptions_user_id ON push_subscriptions(user_id);
|
||||||
|
|
||||||
|
${PROJECTS_TABLE_SCHEMA_SQL}
|
||||||
|
-- NOTE: These indexes are created in migrations after legacy table-shape repairs.
|
||||||
|
-- Creating them here can fail on upgraded installs where projects lacks those columns.
|
||||||
|
|
||||||
|
${SESSIONS_TABLE_SCHEMA_SQL}
|
||||||
|
CREATE INDEX IF NOT EXISTS idx_session_ids_lookup ON sessions(session_id);
|
||||||
|
-- NOTE: This index is created in migrations after sessions is rebuilt to include project_path.
|
||||||
|
-- Creating it here can fail on upgraded installs where the legacy sessions table has no project_path.
|
||||||
|
|
||||||
|
${LAST_SCANNED_AT_SQL}
|
||||||
|
|
||||||
|
${APP_CONFIG_TABLE_SCHEMA_SQL}
|
||||||
|
`;
|
||||||